5 SELECTION_CHANGE_COMMAND
7 import {getMainEditorFullToolbar} from "./toolbars";
8 import {EditorUIManager} from "./framework/manager";
9 import {EditorForm} from "./framework/forms";
10 import {link} from "./defaults/form-definitions";
12 export function buildEditorUI(element: HTMLElement, editor: LexicalEditor) {
13 const manager = new EditorUIManager();
17 translate: (text: string): string => text,
20 // Create primary toolbar
21 const toolbar = getMainEditorFullToolbar();
22 toolbar.setContext(context);
23 element.before(toolbar.getDOMElement());
26 const linkForm = new EditorForm(link);
27 linkForm.setContext(context);
28 element.before(linkForm.getDOMElement());
30 // Update button states on editor selection change
31 editor.registerCommand(SELECTION_CHANGE_COMMAND, () => {
32 const selection = $getSelection();
33 toolbar.updateState({editor, selection});
35 }, COMMAND_PRIORITY_LOW);