Skip to content

Build your personal knowledge base with Trilium Notes

feat(popup_editor): integrate with note link context menu

Elian Doran88a8311173bd
diff --git a/apps/client/src/components/app_context.ts b/apps/client/src/components/app_context.ts
index 161846dde6..ffff952d1b 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 cef67b7da4..e73f333afe 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<CommandNames>[] {
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 cf79ca8c14..90f3b95fba 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 2c3701b1f4..1489179cbf 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<BasicWidget> {
- 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<BasicWidget> {
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.