feat(popup_editor): integrate with note link context menu

This commit is contained in:
Elian Doran 2025-07-10 17:19:10 +03:00
parent 63dc5697dd
commit 88a8311173
No known key found for this signature in database
4 changed files with 12 additions and 27 deletions

View File

@ -122,9 +122,11 @@ export type CommandMappings = {
showImportDialog: CommandData & { noteId: string }; showImportDialog: CommandData & { noteId: string };
openNewNoteSplit: NoteCommandData; openNewNoteSplit: NoteCommandData;
openInWindow: NoteCommandData; openInWindow: NoteCommandData;
openInPopup: CommandData & { noteIdOrPath: string; };
openNoteInNewTab: CommandData; openNoteInNewTab: CommandData;
openNoteInNewSplit: CommandData; openNoteInNewSplit: CommandData;
openNoteInNewWindow: CommandData; openNoteInNewWindow: CommandData;
openNoteInPopup: CommandData;
openAboutDialog: CommandData; openAboutDialog: CommandData;
hideFloatingButtons: {}; hideFloatingButtons: {};
hideLeftPane: CommandData; hideLeftPane: CommandData;

View File

@ -16,7 +16,8 @@ function getItems(): MenuItem<CommandNames>[] {
return [ 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_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_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 }); appContext.triggerCommand("openNewNoteSplit", { ntxId, notePath, hoistedNoteId, viewScope });
} else if (command === "openNoteInNewWindow") { } else if (command === "openNoteInNewWindow") {
appContext.triggerCommand("openInWindow", { notePath, hoistedNoteId, viewScope }); appContext.triggerCommand("openInWindow", { notePath, hoistedNoteId, viewScope });
} else if (command === "openNoteInPopup") {
appContext.triggerCommand("openInPopup", { noteIdOrPath: notePath })
} }
} }

View File

@ -1832,7 +1832,8 @@
"link_context_menu": { "link_context_menu": {
"open_note_in_new_tab": "Open note in a new tab", "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_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": { "electron_integration": {
"desktop-application": "Desktop Application", "desktop-application": "Desktop Application",

View File

@ -68,15 +68,6 @@ const TPL = /*html*/`\
export default class PopupEditorDialog extends Container<BasicWidget> { export default class PopupEditorDialog extends Container<BasicWidget> {
private noteId?: string;
constructor() {
super();
setTimeout(() => {
this.openPopupEditorEvent("f4sIt7iRg0Lc");
}, 750);
}
doRender() { doRender() {
// This will populate this.$widget with the content of the children. // This will populate this.$widget with the content of the children.
super.doRender(); super.doRender();
@ -92,28 +83,16 @@ export default class PopupEditorDialog extends Container<BasicWidget> {
this.$widget = $newWidget; this.$widget = $newWidget;
} }
async refresh() { async refresh(noteIdOrPath: string) {
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;
}
const noteContext = new NoteContext("_popup-editor"); const noteContext = new NoteContext("_popup-editor");
await noteContext.setNote(note.noteId); await noteContext.setNote(noteIdOrPath);
await this.handleEventInChildren("activeContextChanged", { noteContext }); await this.handleEventInChildren("activeContextChanged", { noteContext });
return true; return true;
} }
async openPopupEditorEvent(noteId: string) { async openInPopupEvent({ noteIdOrPath }: EventData<"openInPopup">) {
this.noteId = noteId; if (await this.refresh(noteIdOrPath)) {
if (await this.refresh()) {
const $dialog = await openDialog(this.$widget); const $dialog = await openDialog(this.$widget);
$dialog.on("shown.bs.modal", () => { $dialog.on("shown.bs.modal", () => {
// Reduce the z-index of modals so that ckeditor popups are properly shown on top of it. // Reduce the z-index of modals so that ckeditor popups are properly shown on top of it.