diff --git a/apps/client/src/components/app_context.ts b/apps/client/src/components/app_context.ts index 161846dde..ffff952d1 100644 --- a/apps/client/src/components/app_context.ts +++ b/apps/client/src/components/app_context.ts @@ -122,9 +122,11 @@ export type CommandMappings = { showImportDialog: CommandData & { noteId: string }; openNewNoteSplit: NoteCommandData; openInWindow: NoteCommandData; + openInPopup: CommandData & { noteIdOrPath: string; }; openNoteInNewTab: CommandData; openNoteInNewSplit: CommandData; openNoteInNewWindow: CommandData; + openNoteInPopup: CommandData; openAboutDialog: CommandData; hideFloatingButtons: {}; hideLeftPane: CommandData; diff --git a/apps/client/src/menus/link_context_menu.ts b/apps/client/src/menus/link_context_menu.ts index cef67b7da..e73f333af 100644 --- a/apps/client/src/menus/link_context_menu.ts +++ b/apps/client/src/menus/link_context_menu.ts @@ -16,7 +16,8 @@ function getItems(): MenuItem[] { return [ { title: t("link_context_menu.open_note_in_new_tab"), command: "openNoteInNewTab", uiIcon: "bx bx-link-external" }, { title: t("link_context_menu.open_note_in_new_split"), command: "openNoteInNewSplit", uiIcon: "bx bx-dock-right" }, - { title: t("link_context_menu.open_note_in_new_window"), command: "openNoteInNewWindow", uiIcon: "bx bx-window-open" } + { title: t("link_context_menu.open_note_in_new_window"), command: "openNoteInNewWindow", uiIcon: "bx bx-window-open" }, + { title: t("link_context_menu.open_note_in_popup"), command: "openNoteInPopup", uiIcon: "bx bx-edit" } ]; } @@ -40,6 +41,8 @@ function handleLinkContextMenuItem(command: string | undefined, notePath: string appContext.triggerCommand("openNewNoteSplit", { ntxId, notePath, hoistedNoteId, viewScope }); } else if (command === "openNoteInNewWindow") { appContext.triggerCommand("openInWindow", { notePath, hoistedNoteId, viewScope }); + } else if (command === "openNoteInPopup") { + appContext.triggerCommand("openInPopup", { noteIdOrPath: notePath }) } } diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index cf79ca8c1..90f3b95fb 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -1832,7 +1832,8 @@ "link_context_menu": { "open_note_in_new_tab": "Open note in a new tab", "open_note_in_new_split": "Open note in a new split", - "open_note_in_new_window": "Open note in a new window" + "open_note_in_new_window": "Open note in a new window", + "open_note_in_popup": "Quick edit" }, "electron_integration": { "desktop-application": "Desktop Application", diff --git a/apps/client/src/widgets/dialogs/popup_editor.ts b/apps/client/src/widgets/dialogs/popup_editor.ts index 2c3701b1f..1489179cb 100644 --- a/apps/client/src/widgets/dialogs/popup_editor.ts +++ b/apps/client/src/widgets/dialogs/popup_editor.ts @@ -68,15 +68,6 @@ const TPL = /*html*/`\ export default class PopupEditorDialog extends Container { - private noteId?: string; - - constructor() { - super(); - setTimeout(() => { - this.openPopupEditorEvent("f4sIt7iRg0Lc"); - }, 750); - } - doRender() { // This will populate this.$widget with the content of the children. super.doRender(); @@ -92,28 +83,16 @@ export default class PopupEditorDialog extends Container { this.$widget = $newWidget; } - async refresh() { - if (!this.noteId) { - console.warn("Popup editor noteId is not set, cannot refresh."); - return false; - } - - const note = await froca.getNote(this.noteId); - if (!note) { - console.warn(`Popup editor note with ID ${this.noteId} not found.`); - return false; - } - + async refresh(noteIdOrPath: string) { const noteContext = new NoteContext("_popup-editor"); - await noteContext.setNote(note.noteId); + await noteContext.setNote(noteIdOrPath); await this.handleEventInChildren("activeContextChanged", { noteContext }); return true; } - async openPopupEditorEvent(noteId: string) { - this.noteId = noteId; - if (await this.refresh()) { + async openInPopupEvent({ noteIdOrPath }: EventData<"openInPopup">) { + if (await this.refresh(noteIdOrPath)) { const $dialog = await openDialog(this.$widget); $dialog.on("shown.bs.modal", () => { // Reduce the z-index of modals so that ckeditor popups are properly shown on top of it.