diff --git a/web/src/elements/CodeMirror.ts b/web/src/elements/CodeMirror.ts index 6d1c7381b..3f8d397b3 100644 --- a/web/src/elements/CodeMirror.ts +++ b/web/src/elements/CodeMirror.ts @@ -24,11 +24,15 @@ export class CodeMirrorTextarea extends LitElement { editor?: CodeMirror.EditorFromTextArea; + _value?: string; + @property() set value(v: string) { if (v === null) return; if (this.editor) { this.editor.setValue(v); + } else { + this._value = v; } } @@ -70,6 +74,7 @@ export class CodeMirrorTextarea extends LitElement { readOnly: this.readOnly, autoRefresh: true, lineWrapping: true, + value: this._value }); this.editor.on("blur", () => { this.editor?.save(); @@ -77,6 +82,6 @@ export class CodeMirrorTextarea extends LitElement { } render(): TemplateResult { - return html``; + return html``; } }