import NoteContextAwareWidget from "../note_context_aware_widget.js"; import treeService from "../../services/tree.js"; import linkService from "../../services/link.js"; const TPL = `
`; export default class NotePathsWidget extends NoteContextAwareWidget { isEnabled() { return this.note; } getTitle() { return { show: true, title: 'Note Paths', icon: 'bx bx-collection' }; } doRender() { this.$widget = $(TPL); this.contentSized(); this.$notePathIntro = this.$widget.find(".note-path-intro"); this.$notePathList = this.$widget.find(".note-path-list"); this.$widget.on('show.bs.dropdown', () => this.renderDropdown()); } async refreshWithNote(note) { this.$notePathList.empty(); if (this.noteId === 'root') { await this.addPath('root'); return; } const sortedNotePaths = this.note.getSortedNotePaths(this.hoistedNoteId) .filter(notePath => !notePath.isHidden); if (sortedNotePaths.length > 0) { this.$notePathIntro.text("This note is placed into the following paths:"); } else { this.$notePathIntro.text("This note is not yet placed into the note tree."); } for (const notePathRecord of sortedNotePaths) { await this.addPath(notePathRecord); } } async addPath(notePathRecord) { const notePath = notePathRecord.notePath.join('/'); const title = await treeService.getNotePathTitle(notePath); const $noteLink = await linkService.createNoteLink(notePath, {title}); $noteLink .find('a') .addClass("no-tooltip-preview"); const icons = []; if (this.notePath === notePath) { $noteLink.addClass("path-current"); } if (notePathRecord.isInHoistedSubTree) { $noteLink.addClass("path-in-hoisted-subtree"); } else { icons.push(``); } if (notePathRecord.isArchived) { $noteLink.addClass("path-archived"); icons.push(``); } if (notePathRecord.isSearch) { $noteLink.addClass("path-search"); icons.push(``); } if (icons.length > 0) { $noteLink.append(` ${icons.join(' ')}`); } this.$notePathList.append($("