mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-10 01:44:59 +08:00
83 lines
2.3 KiB
JavaScript
83 lines
2.3 KiB
JavaScript
![]() |
import RightDropdownButtonWidget from "./right_dropdown_button.js";
|
||
|
import linkService from "../../services/link.js";
|
||
|
|
||
|
const DROPDOWN_TPL = `
|
||
|
<div class="bookmark-folder-widget">
|
||
|
<style>
|
||
|
.bookmark-folder-widget {
|
||
|
min-width: 200px;
|
||
|
max-height: 500px;
|
||
|
padding: 10px 20px 10px 20px;
|
||
|
font-size: 110%;
|
||
|
overflow: auto;
|
||
|
}
|
||
|
|
||
|
.bookmark-folder-widget ul {
|
||
|
padding: 0;
|
||
|
list-style-type: none;
|
||
|
}
|
||
|
|
||
|
.bookmark-folder-widget .note-link {
|
||
|
display: block;
|
||
|
padding: 5px 10px 5px 5px;
|
||
|
}
|
||
|
|
||
|
.bookmark-folder-widget .note-link:hover {
|
||
|
background-color: var(--accented-background-color);
|
||
|
text-decoration: none;
|
||
|
}
|
||
|
|
||
|
.dropdown-menu .bookmark-folder-widget a:hover {
|
||
|
text-decoration: none;
|
||
|
background: transparent !important;
|
||
|
}
|
||
|
|
||
|
.bookmark-folder-widget li .note-link {
|
||
|
padding-left: 35px;
|
||
|
}
|
||
|
</style>
|
||
|
|
||
|
<div class="parent-note"></div>
|
||
|
|
||
|
<ul class="children-notes"></ul>
|
||
|
</div>`;
|
||
|
|
||
|
export default class BookmarkFolderWidget extends RightDropdownButtonWidget {
|
||
|
constructor(note) {
|
||
|
super(note.getIcon(), note.title, DROPDOWN_TPL);
|
||
|
|
||
|
this.note = note;
|
||
|
}
|
||
|
|
||
|
doRender() {
|
||
|
super.doRender();
|
||
|
|
||
|
this.$parentNote = this.$dropdownContent.find('.parent-note');
|
||
|
this.$childrenNotes = this.$dropdownContent.find('.children-notes');
|
||
|
|
||
|
// this.$dropdownContent.on("click", "a", () => this.hideDropdown());
|
||
|
}
|
||
|
|
||
|
async dropdownShown() {
|
||
|
this.$parentNote.empty();
|
||
|
this.$childrenNotes.empty();
|
||
|
|
||
|
this.$parentNote.append(
|
||
|
(await linkService.createNoteLink(this.note.noteId, {showTooltip: false}))
|
||
|
.addClass("note-link")
|
||
|
);
|
||
|
|
||
|
for (const childNote of await this.note.getChildNotes()) {
|
||
|
this.$childrenNotes.append(
|
||
|
$("<li>")
|
||
|
.append(
|
||
|
(await linkService.createNoteLink(childNote.noteId, {showTooltip: false}))
|
||
|
.addClass("note-link")
|
||
|
)
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
refreshIcon() {}
|
||
|
}
|