1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2026-01-03 23:42:28 +03:00

Lexical: Added base context toolbar logic

This commit is contained in:
Dan Brown
2024-06-30 12:13:13 +01:00
parent 517c578a5f
commit c9a03c5b01
4 changed files with 106 additions and 6 deletions

View File

@@ -0,0 +1,36 @@
import {EditorContainerUiElement, EditorUiElement} from "./core";
import {el} from "../../helpers";
export type EditorContextToolbarDefinition = {
selector: string;
content: EditorUiElement[],
displayTargetLocator?: (originalTarget: HTMLElement) => HTMLElement;
};
export class EditorContextToolbar extends EditorContainerUiElement {
protected buildDOM(): HTMLElement {
return el('div', {
class: 'editor-context-toolbar',
}, this.getChildren().map(child => child.getDOMElement()));
}
attachTo(target: HTMLElement) {
// Todo - attach to target position
console.log('attaching context toolbar to', target);
}
insert(children: EditorUiElement[]) {
this.addChildren(...children);
const dom = this.getDOMElement();
dom.append(...children.map(child => child.getDOMElement()));
}
empty() {
const children = this.getChildren();
for (const child of children) {
child.getDOMElement().remove();
}
this.removeChildren(...children);
}
}