Add codable element

This commit is contained in:
Henrik Giesel 2021-06-17 13:46:25 +02:00
parent b26e125cbd
commit 709c1be7a0
3 changed files with 13 additions and 0 deletions

6
ts/editor/codable.ts Normal file
View file

@ -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 {}
}

View file

@ -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 {

View file

@ -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" });