From c06c17eac1471066eec4d0e19988363a7936b847 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 14 Nov 2025 06:04:21 +0000 Subject: [PATCH] feat(obsidian): add choice between automatic search and manual browse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: When clicking on a burg/marker, automatic search would run immediately without giving the user an option to skip it and browse manually. Users had to wait for the search to complete before getting to the browse option. Solution: Add initial dialog (showSearchMethodDialog) that appears first, asking the user to choose: - 🔍 Search: Run automatic search (FMG ID lookup + coordinate search) - 📁 Browse: Skip search and go straight to manual browse/folder tree - Cancel: Close without doing anything Benefits: - Users who want to browse manually can do so immediately - Users who want automatic search can still use it - No forced waiting for search when you know you want to browse - Clear visual distinction between the two methods - Folder tree is now just one click away This gives users complete control from the very first interaction, making manual browsing much more accessible. --- modules/ui/obsidian-notes-editor.js | 72 ++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 12 deletions(-) diff --git a/modules/ui/obsidian-notes-editor.js b/modules/ui/obsidian-notes-editor.js index e8d5964f..8af8582f 100644 --- a/modules/ui/obsidian-notes-editor.js +++ b/modules/ui/obsidian-notes-editor.js @@ -5,19 +5,67 @@ function editObsidianNote(elementId, elementType, coordinates) { const {x, y} = coordinates; - // Show loading dialog - showLoadingDialog(); + // Show choice dialog: automatic search or manual browse + showSearchMethodDialog(elementId, elementType, coordinates); +} - // Try to find note by FMG ID first, then by coordinates - findOrCreateNote(elementId, elementType, coordinates) - .then(noteData => { - showMarkdownEditor(noteData, elementType, elementId, coordinates); - }) - .catch(error => { - ERROR && console.error("Failed to load note:", error); - tip("Failed to load Obsidian note: " + error.message, true, "error", 5000); - closeDialogs("#obsidianNoteLoading"); - }); +function showSearchMethodDialog(elementId, elementType, coordinates) { + const element = getElementData(elementId, elementType); + const elementName = element.name || elementId; + + alertMessage.innerHTML = ` +
+

${elementName}

+

How would you like to find the note for this ${elementType}?

+ +
+
🔍 Automatic Search
+
Search by linked ID or nearby coordinates
+
+ +
+
📁 Browse Manually
+
Browse your vault's folder tree
+
+
+ `; + + $("#alert").dialog({ + title: "Select Note", + width: "450px", + buttons: { + "🔍 Search": function () { + $(this).dialog("close"); + // Show loading and do automatic search + showLoadingDialog(); + findOrCreateNote(elementId, elementType, coordinates) + .then(noteData => { + showMarkdownEditor(noteData, elementType, elementId, coordinates); + }) + .catch(error => { + ERROR && console.error("Failed to load note:", error); + tip("Failed to load Obsidian note: " + error.message, true, "error", 5000); + closeDialogs("#obsidianNoteLoading"); + }); + }, + "📁 Browse": async function () { + $(this).dialog("close"); + try { + const noteData = await promptCreateNewNote(elementId, elementType, coordinates); + showMarkdownEditor(noteData, elementType, elementId, coordinates); + } catch (error) { + if (error.message !== "Cancelled") { + ERROR && console.error("Failed to load note:", error); + tip("Failed to load Obsidian note: " + error.message, true, "error", 5000); + } + } + }, + Cancel: function () { + $(this).dialog("close"); + } + }, + position: {my: "center", at: "center", of: "svg"} + }); } async function findOrCreateNote(elementId, elementType, coordinates) {