diff --git a/qt/aqt/data/web/js/editor.ts b/qt/aqt/data/web/js/editor.ts index 7b49b174f..97c24d37c 100644 --- a/qt/aqt/data/web/js/editor.ts +++ b/qt/aqt/data/web/js/editor.ts @@ -424,10 +424,6 @@ function onCutOrCopy(): boolean { } class EditingArea extends HTMLElement { - connectedCallback() { - this.setAttribute("contenteditable", ""); - } - set fieldHTML(content: string) { this.innerHTML = content; @@ -441,6 +437,10 @@ class EditingArea extends HTMLElement { ? this.innerHTML.slice(0, -4) // trim trailing
: this.innerHTML; } + + connectedCallback() { + this.setAttribute("contenteditable", ""); + } } customElements.define("editing-area", EditingArea); @@ -471,6 +471,14 @@ class EditingContainer extends HTMLDivElement { return Number(this.getAttribute("ord")); } + set fieldHTML(content: string) { + this.editingArea.fieldHTML = content; + } + + get fieldHTML(): string { + return this.editingArea.fieldHTML; + } + connectedCallback(): void { this.addEventListener("keydown", onKey); this.addEventListener("keyup", onKeyUp); @@ -530,14 +538,6 @@ class EditingContainer extends HTMLDivElement { blurEditingArea(): void { this.editingArea.blur(); } - - set fieldHTML(content: string) { - this.editingArea.fieldHTML = content; - } - - get fieldHTML(): string { - return this.editingArea.fieldHTML; - } } customElements.define("editing-container", EditingContainer, { extends: "div" }); @@ -567,6 +567,10 @@ class EditorField extends HTMLDivElement { return ["ord"]; } + set ord(n: number) { + this.setAttribute("ord", String(n)); + } + attributeChangedCallback(name: string, _oldValue: string, newValue: string): void { switch (name) { case "ord": @@ -574,10 +578,6 @@ class EditorField extends HTMLDivElement { } } - set ord(n: number) { - this.setAttribute("ord", String(n)); - } - initialize(label: string, color: string, content: string): void { this.label.innerText = label; this.editingContainer.initialize(color, content);