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:
+7
-1
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user