From 39eac83d38a758ac5b89ee7ec5db44ce10a0dde0 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 10 Jul 2025 23:21:37 +0300 Subject: [PATCH] fix(popup_editor): mermaid not rendering properly --- .../src/widgets/dialogs/popup_editor.ts | 44 ++++++++----------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/apps/client/src/widgets/dialogs/popup_editor.ts b/apps/client/src/widgets/dialogs/popup_editor.ts index 252d4769e..be3650874 100644 --- a/apps/client/src/widgets/dialogs/popup_editor.ts +++ b/apps/client/src/widgets/dialogs/popup_editor.ts @@ -80,6 +80,13 @@ const TPL = /*html*/`\ export default class PopupEditorDialog extends Container { + private noteContext: NoteContext; + + constructor() { + super(); + this.noteContext = new NoteContext("_popup-editor"); + } + doRender() { // This will populate this.$widget with the content of the children. super.doRender(); @@ -95,34 +102,21 @@ export default class PopupEditorDialog extends Container { this.$widget = $newWidget; } - async refresh(noteIdOrPath: string) { - const noteContext = new NoteContext("_popup-editor"); - await noteContext.setNote(noteIdOrPath); - - await this.handleEventInChildren("activeContextChanged", { noteContext }); - return true; - } - async openInPopupEvent({ noteIdOrPath }: EventData<"openInPopup">) { - if (await this.refresh(noteIdOrPath)) { - const $dialog = await openDialog(this.$widget, false, { - focus: false - }); + const $dialog = await openDialog(this.$widget, false, { + focus: false + }); - $dialog.on("shown.bs.modal", () => { - // Reduce the z-index of modals so that ckeditor popups are properly shown on top of it. - // The backdrop instance is not shared so it's OK to make a one-off modification. - $("body > .modal-backdrop").css("z-index", "998"); - $dialog.css("z-index", "999"); + await this.noteContext.setNote(noteIdOrPath); - // Mind map doesn't render off screen properly, so it needs refreshing once the modal is shown. - const $mindmap = $dialog.find(".note-detail-mind-map"); - if ($mindmap.length) { - const mindmapComponent = appContext.getComponentByEl($mindmap[0]); - mindmapComponent.refresh(); - } - }); - } + $dialog.on("shown.bs.modal", () => { + // Reduce the z-index of modals so that ckeditor popups are properly shown on top of it. + // The backdrop instance is not shared so it's OK to make a one-off modification. + $("body > .modal-backdrop").css("z-index", "998"); + $dialog.css("z-index", "999"); + + this.handleEventInChildren("activeContextChanged", { noteContext: this.noteContext }); + }); } handleEventInChildren(name: T, data: EventData): Promise | null {