]> BookStack Code Mirror - bookstack/blob - resources/js/wysiwyg/ui/framework/containers.ts
Lexical: Added ui container type
[bookstack] / resources / js / wysiwyg / ui / framework / containers.ts
1 import {EditorUiContext, EditorUiElement, EditorUiStateUpdate} from "./base-elements";
2 import {el} from "../../helpers";
3
4 export class EditorContainerUiElement extends EditorUiElement {
5     protected children : EditorUiElement[];
6
7     constructor(children: EditorUiElement[]) {
8         super();
9         this.children = children;
10     }
11
12     protected buildDOM(): HTMLElement {
13         return el('div', {}, this.getChildren().map(child => child.getDOMElement()));
14     }
15
16     getChildren(): EditorUiElement[] {
17         return this.children;
18     }
19
20     updateState(state: EditorUiStateUpdate): void {
21         for (const child of this.children) {
22             child.updateState(state);
23         }
24     }
25
26     setContext(context: EditorUiContext) {
27         for (const child of this.getChildren()) {
28             child.setContext(context);
29         }
30     }
31 }
32
33 export class EditorFormatMenu extends EditorContainerUiElement {
34     buildDOM(): HTMLElement {
35         return el('div', {
36             class: 'editor-format-menu'
37         }, this.getChildren().map(child => child.getDOMElement()));
38     }
39
40 }