mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
feat(obsidian): add text search and browse features for note finding
Enhanced the Obsidian note finding system with: **ObsidianBridge:** - searchNotes(query): Search vault by filename - listAllNotes(): Browse all notes in vault **Obsidian Notes Editor:** - Text search box with auto-populated state/province - "Browse All Notes" button to see full vault - Display burg's state and province in dialog - Pre-fill search with state name for easier finding - Enter key triggers search - Click any result to load that note **getElementData enhancement:** - Extract and include state/province names for burgs - Extract state/province from cell data for markers Now users can: 1. See which state/province the burg belongs to 2. Search by state name (pre-filled) 3. Search by any text in filename 4. Browse all notes manually 5. Click to select matching note This addresses the user's organization structure where notes are stored in State/Province folders matching the map structure.
This commit is contained in:
parent
9243c43d2d
commit
28cf8db82d
3 changed files with 251 additions and 14 deletions
|
|
@ -396,6 +396,66 @@ Add your lore here...
|
|||
`;
|
||||
}
|
||||
|
||||
// Search notes by text query (searches in filename and frontmatter)
|
||||
async function searchNotes(query) {
|
||||
if (!query || query.trim() === "") {
|
||||
return [];
|
||||
}
|
||||
|
||||
const allFiles = await getVaultFiles();
|
||||
const searchTerm = query.toLowerCase();
|
||||
const results = [];
|
||||
|
||||
for (const filePath of allFiles) {
|
||||
const fileName = filePath.split("/").pop().replace(".md", "").toLowerCase();
|
||||
|
||||
// Check if filename matches
|
||||
if (fileName.includes(searchTerm)) {
|
||||
try {
|
||||
const content = await getNote(filePath);
|
||||
const {frontmatter} = parseFrontmatter(content);
|
||||
|
||||
results.push({
|
||||
path: filePath,
|
||||
name: filePath.split("/").pop().replace(".md", ""),
|
||||
frontmatter,
|
||||
matchType: "filename"
|
||||
});
|
||||
} catch (error) {
|
||||
WARN && console.warn(`Could not read file ${filePath}:`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
// List all notes with basic info
|
||||
async function listAllNotes() {
|
||||
const allFiles = await getVaultFiles();
|
||||
const notes = [];
|
||||
|
||||
for (const filePath of allFiles) {
|
||||
try {
|
||||
const content = await getNote(filePath);
|
||||
const {frontmatter} = parseFrontmatter(content);
|
||||
|
||||
notes.push({
|
||||
path: filePath,
|
||||
name: filePath.split("/").pop().replace(".md", ""),
|
||||
frontmatter,
|
||||
folder: filePath.includes("/") ? filePath.substring(0, filePath.lastIndexOf("/")) : ""
|
||||
});
|
||||
} catch (error) {
|
||||
WARN && console.warn(`Could not read file ${filePath}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
// Sort by path
|
||||
notes.sort((a, b) => a.path.localeCompare(b.path));
|
||||
return notes;
|
||||
}
|
||||
|
||||
return {
|
||||
init,
|
||||
config,
|
||||
|
|
@ -408,7 +468,9 @@ Add your lore here...
|
|||
parseFrontmatter,
|
||||
findNotesByCoordinates,
|
||||
findNoteByFmgId,
|
||||
generateNoteTemplate
|
||||
generateNoteTemplate,
|
||||
searchNotes,
|
||||
listAllNotes
|
||||
};
|
||||
})();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue