1 import {BaseSelection, LexicalEditor} from "lexical";
3 export type EditorUiStateUpdate = {
5 selection: BaseSelection|null,
8 export type EditorUiContext = {
12 export abstract class EditorUiElement {
13 protected dom: HTMLElement|null = null;
14 private context: EditorUiContext|null = null;
16 protected abstract buildDOM(): HTMLElement;
18 setContext(context: EditorUiContext): void {
19 this.context = context;
22 getContext(): EditorUiContext {
23 if (this.context === null) {
24 throw new Error('Attempted to use EditorUIContext before it has been set');
30 getDOMElement(): HTMLElement {
32 this.dom = this.buildDOM();
38 abstract updateState(state: EditorUiStateUpdate): void;