code editor modal fix

This commit is contained in:
Lone Iversen
2023-10-11 13:32:37 +02:00
parent f6da3ab2b1
commit eb5ce70005
2 changed files with 5 additions and 20 deletions

View File

@@ -5,10 +5,7 @@ import { uriAttributeSanitizer } from './input-tiny-mce.sanitizer.js';
import { FormControlMixin } from '@umbraco-cms/backoffice/external/uui';
import { renderEditor, type tinymce } from '@umbraco-cms/backoffice/external/tinymce';
import { UMB_AUTH, UmbLoggedInUser } from '@umbraco-cms/backoffice/auth';
import {
TinyMcePluginArguments,
UmbTinyMcePluginBase,
} from '@umbraco-cms/backoffice/components';
import { TinyMcePluginArguments, UmbTinyMcePluginBase } from '@umbraco-cms/backoffice/components';
import { ClassConstructor, hasDefaultExport, loadExtension } from '@umbraco-cms/backoffice/extension-api';
import { ManifestTinyMcePlugin, umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
import {
@@ -210,11 +207,11 @@ export class UmbInputTinyMceElement extends FormControlMixin(UmbLitElement) {
// define keyboard shortcuts
editor.addShortcut('Ctrl+S', '', () =>
this.dispatchEvent(new CustomEvent('rte.shortcut.save', { composed: true, bubbles: true }))
this.dispatchEvent(new CustomEvent('rte.shortcut.save', { composed: true, bubbles: true })),
);
editor.addShortcut('Ctrl+P', '', () =>
this.dispatchEvent(new CustomEvent('rte.shortcut.saveAndPublish', { composed: true, bubbles: true }))
this.dispatchEvent(new CustomEvent('rte.shortcut.saveAndPublish', { composed: true, bubbles: true })),
);
// bind editor events

View File

@@ -15,12 +15,11 @@ export class UmbCodeEditorModalElement extends UmbModalBaseElement<UmbCodeEditor
constructor() {
super();
this.#loadCodeEditor();
}
#handleConfirm() {
this.modalContext?.submit({ content: this.data?.content ?? '' });
this.modalContext?.submit({ content: this._codeEditor?.editor?.monacoEditor?.getValue() ?? '' });
}
#handleCancel() {
@@ -36,21 +35,10 @@ export class UmbCodeEditorModalElement extends UmbModalBaseElement<UmbCodeEditor
}
}
// TODO => debounce?
#onCodeEditorInput(e: UUIInputEvent) {
e.preventDefault();
if (!this.data) {
return;
}
this.data.content = this._codeEditor?.code ?? '';
}
#renderCodeEditor() {
return html`<umb-code-editor
language=${ifDefined(this.data?.language)}
.code=${this.data?.content ?? ''}
@input=${this.#onCodeEditorInput}></umb-code-editor>`;
.code=${this.data?.content ?? ''}></umb-code-editor>`;
}
#renderLoading() {