]> BookStack Code Mirror - bookstack/blobdiff - resources/js/wysiwyg/ui/framework/manager.ts
Lexical: Integrated image manager to image button/form
[bookstack] / resources / js / wysiwyg / ui / framework / manager.ts
index 29d959910757573d77484ef741c5a6b3281ef285..92891b5408466146f1085d1a33401bba86cbe59e 100644 (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;
     }