diff --git a/index.html b/index.html index 68ad5fae..1e60bf17 100644 --- a/index.html +++ b/index.html @@ -8282,7 +8282,7 @@ - + diff --git a/modules/ui/obsidian-notes-editor.js b/modules/ui/obsidian-notes-editor.js index 60b93386..07500096 100644 --- a/modules/ui/obsidian-notes-editor.js +++ b/modules/ui/obsidian-notes-editor.js @@ -310,27 +310,14 @@ async function promptCreateNewNote(elementId, elementType, coordinates) { return; } - resultsDiv.innerHTML = allNotes - .map( - (note, index) => ` -
Failed to load notes: ${error.message}
`; } @@ -359,6 +357,77 @@ async function promptCreateNewNote(elementId, elementType, coordinates) { }); } +function buildFolderTree(notes) { + const root = {folders: {}, files: []}; + + notes.forEach((note, index) => { + const parts = note.path.split("/"); + const fileName = parts[parts.length - 1]; + + if (parts.length === 1) { + // Root level file + root.files.push({name: fileName, index, path: note.path}); + } else { + // Navigate/create folder structure + let current = root; + for (let i = 0; i < parts.length - 1; i++) { + const folderName = parts[i]; + if (!current.folders[folderName]) { + current.folders[folderName] = {folders: {}, files: []}; + } + current = current.folders[folderName]; + } + // Add file to final folder + current.files.push({name: fileName, index, path: note.path}); + } + }); + + return root; +} + +function renderFolderTree(node, allNotes, indent = 0) { + let html = ""; + const indentPx = indent * 20; + + // Render folders + for (const [folderName, folderData] of Object.entries(node.folders || {})) { + html += ` +