1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-12-23 23:02:08 +03:00

Lexical: Integrated image manager to image button/form

This commit is contained in:
Dan Brown
2024-08-13 19:36:18 +01:00
parent ec965f28c0
commit accf2565a0
12 changed files with 231 additions and 109 deletions

View File

@@ -11,6 +11,7 @@ export type SelectionChangeHandler = (selection: BaseSelection|null) => void;
export class EditorUIManager {
protected modalDefinitionsByKey: Record<string, EditorFormModalDefinition> = {};
protected activeModalsByKey: Record<string, EditorFormModal> = {};
protected decoratorConstructorsByType: Record<string, typeof EditorDecorator> = {};
protected decoratorInstancesByNodeKey: Record<string, EditorDecorator> = {};
protected context: EditorUiContext|null = null;
@@ -50,12 +51,24 @@ export class EditorUIManager {
throw new Error(`Attempted to show modal of key [${key}] but no modal registered for that key`);
}
const modal = new EditorFormModal(modalDefinition);
const modal = new EditorFormModal(modalDefinition, key);
modal.setContext(this.getContext());
return modal;
}
setModalActive(key: string, modal: EditorFormModal): void {
this.activeModalsByKey[key] = modal;
}
setModalInactive(key: string): void {
delete this.activeModalsByKey[key];
}
getActiveModal(key: string): EditorFormModal|null {
return this.activeModalsByKey[key];
}
registerDecoratorType(type: string, decorator: typeof EditorDecorator) {
this.decoratorConstructorsByType[type] = decorator;
}