]> BookStack Code Mirror - bookstack/blobdiff - resources/js/wysiwyg/ui/framework/modals.ts
ZIP Imports: Added parent selector for page/chapter imports
[bookstack] / resources / js / wysiwyg / ui / framework / modals.ts
index 6b09accdc8b930c2b00f7135d354dfc261ede34b..3eea62ebb94d9cca2e1ab1ae9bfff7f1990467e0 100644 (file)
@@ -1,7 +1,7 @@
 import {EditorForm, EditorFormDefinition} from "./forms";
-import {el} from "../../helpers";
 import {EditorContainerUiElement} from "./core";
 import closeIcon from "@icons/close.svg";
+import {el} from "../../utils/dom";
 
 export interface EditorModalDefinition {
     title: string;
@@ -13,10 +13,12 @@ export interface EditorFormModalDefinition extends EditorModalDefinition {
 
 export class EditorFormModal extends EditorContainerUiElement {
     protected definition: EditorFormModalDefinition;
+    protected key: string;
 
-    constructor(definition: EditorFormModalDefinition) {
+    constructor(definition: EditorFormModalDefinition, key: string) {
         super([new EditorForm(definition.form)]);
         this.definition = definition;
+        this.key = key;
     }
 
     show(defaultValues: Record<string, string>) {
@@ -26,13 +28,17 @@ export class EditorFormModal extends EditorContainerUiElement {
         const form = this.getForm();
         form.setValues(defaultValues);
         form.setOnCancel(this.hide.bind(this));
+        form.setOnSuccessfulSubmit(this.hide.bind(this));
+
+        this.getContext().manager.setModalActive(this.key, this);
     }
 
     hide() {
         this.getDOMElement().remove();
+        this.getContext().manager.setModalInactive(this.key);
     }
 
-    protected getForm(): EditorForm {
+    getForm(): EditorForm {
         return this.children[0] as EditorForm;
     }