Skip to content

Commit 3f3c9f8

Browse files
AndyButlandCopilotiOvergaard
authored
Fixed issue with syntax highlighting in code editor (#19414)
* Fixed issue with syntax highlighting in code editor. * Update src/Umbraco.Web.UI.Client/src/packages/code-editor/property-editor/property-editor-ui-code-editor.element.ts Co-authored-by: Copilot <[email protected]> * Refactor introducing helper method. --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Jacob Overgaard <[email protected]>
1 parent 95c6173 commit 3f3c9f8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Umbraco.Web.UI.Client/src/packages/code-editor/property-editor/property-editor-ui-code-editor.element.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,20 @@ export class UmbPropertyEditorUICodeEditorElement extends UmbLitElement implemen
3838
public set config(config: UmbPropertyEditorConfigCollection | undefined) {
3939
if (!config) return;
4040

41-
this._language = config?.getValueByAlias<CodeEditorLanguage>('language') ?? this.#defaultLanguage;
41+
this._language = this.#getConfiguredLanguage(config);
4242
this._height = Number(config?.getValueByAlias('height')) || 400;
4343
this._lineNumbers = config?.getValueByAlias('lineNumbers') ?? false;
4444
this._minimap = config?.getValueByAlias('minimap') ?? false;
4545
this._wordWrap = config?.getValueByAlias('wordWrap') ?? false;
4646
}
4747

48+
#getConfiguredLanguage(config: UmbPropertyEditorConfigCollection) {
49+
const configuredLanguage = config?.getValueByAlias<CodeEditorLanguage>('language') ?? this.#defaultLanguage;
50+
return Array.isArray(configuredLanguage)
51+
? (configuredLanguage.length > 0 ? configuredLanguage[0] : this.#defaultLanguage)
52+
: configuredLanguage;
53+
}
54+
4855
#onChange(event: UmbInputEvent & { target: UmbCodeEditorElement }) {
4956
if (!(event instanceof UmbInputEvent)) return;
5057
this.value = event.target.code;

0 commit comments

Comments
 (0)