import TabAwareWidget from "./tab_aware_widget.js"; import treeService from "../services/tree.js"; import linkService from "../services/link.js"; const TPL = `
`; export default class NotePathsWidget extends TabAwareWidget { doRender() { this.$widget = $(TPL); this.$currentPath = this.$widget.find('.current-path'); this.$dropdown = this.$widget.find(".dropdown"); this.$notePathList = this.$dropdown.find(".note-path-list"); this.$dropdown.on('show.bs.dropdown', () => this.renderDropdown()); return this.$widget; } async refreshWithNote(note, notePath) { let noteIdsPath = treeService.parseNotePath(notePath); noteIdsPath = noteIdsPath.slice(0, noteIdsPath.length - 1); this.$currentPath.empty(); let parentNoteId = 'root'; let curPath = ''; for (let i = 0; i < noteIdsPath.length; i++) { const noteId = noteIdsPath[i]; curPath += (curPath ? '/' : '') + noteId; if (noteId !== 'root' || noteIdsPath.length < 3) { this.$currentPath.append( $("") .attr('href', '#' + curPath) .addClass('no-tooltip-preview') .text(await treeService.getNoteTitle(noteId, parentNoteId)) ); if (i !== noteIdsPath.length - 1) { this.$currentPath.append(' / '); } } parentNoteId = noteId; } } async renderDropdown() { this.$notePathList.empty(); this.$notePathList.append( $("