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 <175728472+Copilot@users.noreply.github.com> * Refactor introducing helper method. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com>
This commit is contained in:
@@ -38,13 +38,20 @@ export class UmbPropertyEditorUICodeEditorElement extends UmbLitElement implemen
|
||||
public set config(config: UmbPropertyEditorConfigCollection | undefined) {
|
||||
if (!config) return;
|
||||
|
||||
this._language = config?.getValueByAlias<CodeEditorLanguage>('language') ?? this.#defaultLanguage;
|
||||
this._language = this.#getConfiguredLanguage(config);
|
||||
this._height = Number(config?.getValueByAlias('height')) || 400;
|
||||
this._lineNumbers = config?.getValueByAlias('lineNumbers') ?? false;
|
||||
this._minimap = config?.getValueByAlias('minimap') ?? false;
|
||||
this._wordWrap = config?.getValueByAlias('wordWrap') ?? false;
|
||||
}
|
||||
|
||||
#getConfiguredLanguage(config: UmbPropertyEditorConfigCollection) {
|
||||
const configuredLanguage = config?.getValueByAlias<CodeEditorLanguage>('language') ?? this.#defaultLanguage;
|
||||
return Array.isArray(configuredLanguage)
|
||||
? (configuredLanguage.length > 0 ? configuredLanguage[0] : this.#defaultLanguage)
|
||||
: configuredLanguage;
|
||||
}
|
||||
|
||||
#onChange(event: UmbInputEvent & { target: UmbCodeEditorElement }) {
|
||||
if (!(event instanceof UmbInputEvent)) return;
|
||||
this.value = event.target.code;
|
||||
|
||||
Reference in New Issue
Block a user