mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
feat(obsidian): add choice between automatic search and manual browse
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.
This commit is contained in:
parent
d45ca10748
commit
c06c17eac1
1 changed files with 60 additions and 12 deletions
|
|
@ -5,10 +5,39 @@
|
|||
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
|
||||
function showSearchMethodDialog(elementId, elementType, coordinates) {
|
||||
const element = getElementData(elementId, elementType);
|
||||
const elementName = element.name || elementId;
|
||||
|
||||
alertMessage.innerHTML = `
|
||||
<div style="padding: 1em;">
|
||||
<p style="margin-bottom: 1em;"><strong>${elementName}</strong></p>
|
||||
<p style="margin-bottom: 1.5em; color: #666;">How would you like to find the note for this ${elementType}?</p>
|
||||
|
||||
<div style="margin: 1em 0; padding: 12px; background: #f0f8ff; border: 1px solid #0066cc; border-radius: 4px;">
|
||||
<div style="font-weight: bold; margin-bottom: 4px;">🔍 Automatic Search</div>
|
||||
<div style="font-size: 0.9em; color: #666;">Search by linked ID or nearby coordinates</div>
|
||||
</div>
|
||||
|
||||
<div style="margin: 1em 0; padding: 12px; background: #fff8e1; border: 1px solid #ffa000; border-radius: 4px;">
|
||||
<div style="font-weight: bold; margin-bottom: 4px;">📁 Browse Manually</div>
|
||||
<div style="font-size: 0.9em; color: #666;">Browse your vault's folder tree</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
$("#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);
|
||||
|
|
@ -18,6 +47,25 @@ function editObsidianNote(elementId, elementType, coordinates) {
|
|||
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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue