From d58dc10b55fc6cb42abc47a866fef08af1348bdf Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 14 Nov 2025 05:51:18 +0000 Subject: [PATCH] feat(obsidian): add option to choose different note even when linked Problem: When clicking on a burg/marker that already has a linked note, it would automatically open that note without giving the user any choice. Users need the ability to manually browse/search for a different note. Solution: Show a dialog when a linked note is found with 3 options: 1. "Open Linked Note" - Open the currently linked note (default/fast path) 2. "Choose Different Note" - Browse/search for a different note to link 3. "Cancel" - Close the dialog Benefits: - Gives users full control over note selection - Still makes the common case (opening linked note) fast and easy - Allows re-linking burgs/markers to different notes - Shows the path of the linked note before opening This addresses the need to manually browse even when a note is already linked, while preserving the fast instant-open behavior for linked notes. --- modules/ui/obsidian-notes-editor.js | 44 ++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/modules/ui/obsidian-notes-editor.js b/modules/ui/obsidian-notes-editor.js index 86a28946..81878548 100644 --- a/modules/ui/obsidian-notes-editor.js +++ b/modules/ui/obsidian-notes-editor.js @@ -28,7 +28,9 @@ async function findOrCreateNote(elementId, elementType, coordinates) { if (note) { INFO && console.log("Found note by FMG ID:", note.path); - return note; + closeDialogs("#obsidianNoteLoading"); + // Show dialog with option to open linked note or choose different one + return await showLinkedNoteDialog(note, elementId, elementType, coordinates); } // Find by coordinates @@ -57,6 +59,46 @@ async function findOrCreateNote(elementId, elementType, coordinates) { return await showNoteSelectionDialog(matches, elementId, elementType, coordinates); } +async function showLinkedNoteDialog(note, elementId, elementType, coordinates) { + return new Promise((resolve, reject) => { + alertMessage.innerHTML = ` +
+

✓ Found linked note:

+
+
${note.name}
+
Path: ${note.path}
+
+

This element is already linked to the note above. You can open it or choose a different note.

+
+ `; + + $("#alert").dialog({ + title: "Linked Note Found", + width: "500px", + buttons: { + "Open Linked Note": function () { + $(this).dialog("close"); + resolve(note); + }, + "Choose Different Note": async function () { + $(this).dialog("close"); + try { + const differentNote = await promptCreateNewNote(elementId, elementType, coordinates); + resolve(differentNote); + } catch (error) { + reject(error); + } + }, + Cancel: function () { + $(this).dialog("close"); + reject(new Error("Cancelled")); + } + }, + position: {my: "center", at: "center", of: "svg"} + }); + }); +} + function showLoadingDialog() { alertMessage.innerHTML = `