Improve YAML language detection in config.html

Refactored the logic for detecting the YAML language in Monaco editor to handle cases where getLanguages may not be available or Monaco is not loaded. This increases robustness and prevents potential runtime errors.
This commit is contained in:
Sergey Krashevich
2025-12-27 08:08:28 +03:00
parent 11ad1129ed
commit 0f4607a070
+7 -1
View File
@@ -52,7 +52,13 @@
container.textContent = '';
const ensureYamlLanguage = () => {
const hasYaml = (monaco.languages.getLanguages?.() || []).some((l) => l.id === 'yaml');
const languages =
(window.monaco &&
monaco.languages &&
typeof monaco.languages.getLanguages === 'function' &&
monaco.languages.getLanguages()) ||
[];
const hasYaml = languages.some((l) => l.id === 'yaml');
if (hasYaml) return;
monaco.languages.register({