mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-16 09:41:05 +00:00

Structured UI logical to be fairly standard and mostly covered via a base class that handles context and core dom work.
40 lines
No EOL
1.1 KiB
TypeScript
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()));
|
|
}
|
|
|
|
} |