mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 18:11:24 +01:00
Merge pull request #15 from n8k99/claude/fix-nested-folder-display-015Ytt8mSX9sfytMQC85P4gA
feat(obsidian): add manual browse option for coordinate matches
This commit is contained in:
commit
71dcc088ec
1 changed files with 43 additions and 2 deletions
|
|
@ -44,15 +44,16 @@ async function findOrCreateNote(elementId, elementType, coordinates) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matches.length === 1) {
|
if (matches.length === 1) {
|
||||||
// Single match - load it
|
// Single match - show dialog with option to use it or choose different one
|
||||||
const match = matches[0];
|
const match = matches[0];
|
||||||
const content = await ObsidianBridge.getNote(match.path);
|
const content = await ObsidianBridge.getNote(match.path);
|
||||||
return {
|
const noteData = {
|
||||||
path: match.path,
|
path: match.path,
|
||||||
name: match.name,
|
name: match.name,
|
||||||
content,
|
content,
|
||||||
frontmatter: match.frontmatter
|
frontmatter: match.frontmatter
|
||||||
};
|
};
|
||||||
|
return await showSingleMatchDialog(noteData, elementId, elementType, coordinates);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiple matches - show selection dialog
|
// Multiple matches - show selection dialog
|
||||||
|
|
@ -99,6 +100,46 @@ async function showLinkedNoteDialog(note, elementId, elementType, coordinates) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function showSingleMatchDialog(note, elementId, elementType, coordinates) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
alertMessage.innerHTML = `
|
||||||
|
<div style="padding: 1em;">
|
||||||
|
<p style="margin-bottom: 1em;"><strong>✓ Found note by coordinates:</strong></p>
|
||||||
|
<div style="padding: 12px; background: #f0fff0; border: 1px solid #00aa00; border-radius: 4px; margin-bottom: 1.5em;">
|
||||||
|
<div style="font-weight: bold; margin-bottom: 4px;">${note.name}</div>
|
||||||
|
<div style="font-size: 0.9em; color: #666;">Path: ${note.path}</div>
|
||||||
|
</div>
|
||||||
|
<p style="font-size: 0.9em; color: #666;">Found a note near this location. You can use it or browse for a different one.</p>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
$("#alert").dialog({
|
||||||
|
title: "Note Found Nearby",
|
||||||
|
width: "500px",
|
||||||
|
buttons: {
|
||||||
|
"Use This Note": function () {
|
||||||
|
$(this).dialog("close");
|
||||||
|
resolve(note);
|
||||||
|
},
|
||||||
|
"Browse/Search": 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() {
|
function showLoadingDialog() {
|
||||||
alertMessage.innerHTML = `
|
alertMessage.innerHTML = `
|
||||||
<div style="text-align: center; padding: 2em;">
|
<div style="text-align: center; padding: 2em;">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue