0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-04-16 09:41:05 +00:00
BookStackApp_BookStack/resources/js/wysiwyg/ui/framework/containers.ts
Dan Brown dc1a40ea74
Lexical: Added ui container type
Structured UI logical to be fairly standard and mostly covered via
a base class that handles context and core dom work.
2024-05-29 20:38:31 +01:00

40 lines
No EOL
1.1 KiB
TypeScript

import {EditorUiContext, EditorUiElement, EditorUiStateUpdate} from "./base-elements";
import {el} from "../../helpers";
export class EditorContainerUiElement extends EditorUiElement {
protected children : EditorUiElement[];
constructor(children: EditorUiElement[]) {
super();
this.children = children;
}
protected buildDOM(): HTMLElement {
return el('div', {}, this.getChildren().map(child => child.getDOMElement()));
}
getChildren(): EditorUiElement[] {
return this.children;
}
updateState(state: EditorUiStateUpdate): void {
for (const child of this.children) {
child.updateState(state);
}
}
setContext(context: EditorUiContext) {
for (const child of this.getChildren()) {
child.setContext(context);
}
}
}
export class EditorFormatMenu extends EditorContainerUiElement {
buildDOM(): HTMLElement {
return el('div', {
class: 'editor-format-menu'
}, this.getChildren().map(child => child.getDOMElement()));
}
}