diff --git a/ts/editor/codable.ts b/ts/editor/codable.ts new file mode 100644 index 000000000..00a03562e --- /dev/null +++ b/ts/editor/codable.ts @@ -0,0 +1,6 @@ +// Copyright: Ankitects Pty Ltd and contributors +// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html + +export class Codable extends HTMLTextAreaElement { + connectedCallback(): void {} +} diff --git a/ts/editor/editingArea.ts b/ts/editor/editingArea.ts index b5345a630..6732cecae 100644 --- a/ts/editor/editingArea.ts +++ b/ts/editor/editingArea.ts @@ -6,6 +6,7 @@ */ import type { Editable } from "./editable"; +import type { Codable } from "./codable"; import { updateActiveButtons } from "./toolbar"; import { bridgeCommand } from "./lib"; @@ -23,6 +24,7 @@ function onCutOrCopy(): void { export class EditingArea extends HTMLDivElement { editable: Editable; + codable: Codable; baseStyle: HTMLStyleElement; constructor() { @@ -41,6 +43,9 @@ export class EditingArea extends HTMLDivElement { this.editable = document.createElement("anki-editable") as Editable; this.shadowRoot!.appendChild(this.editable); + + this.codable = document.createElement("textarea", { is: "anki-codable" }) as Codable; + this.shadowRoot!.appendChild(this.codable); } get ord(): number { diff --git a/ts/editor/index.ts b/ts/editor/index.ts index eb2980e2c..88295b255 100644 --- a/ts/editor/index.ts +++ b/ts/editor/index.ts @@ -18,6 +18,7 @@ import { EditorField } from "./editorField"; import { LabelContainer } from "./labelContainer"; import { EditingArea } from "./editingArea"; import { Editable } from "./editable"; +import { Codable } from "./codable"; import { initToolbar } from "./toolbar"; export { setNoteId, getNoteId } from "./noteId"; @@ -35,6 +36,7 @@ declare global { } customElements.define("anki-editable", Editable); +customElements.define("anki-codable", Codable, { extends: "textarea" }); customElements.define("anki-editing-area", EditingArea, { extends: "div" }); customElements.define("anki-label-container", LabelContainer, { extends: "div" }); customElements.define("anki-editor-field", EditorField, { extends: "div" });