mirror of
https://github.com/zadam/trilium.git
synced 2025-11-04 20:36:13 +01:00
added unhoist button to the tree node + onclick fixes
This commit is contained in:
@@ -85,7 +85,7 @@ class AppContext extends Component {
|
||||
}
|
||||
|
||||
/** @return {Promise} */
|
||||
triggerCommand(name, data = {}) {console.log("CMD", name);
|
||||
triggerCommand(name, data = {}) {
|
||||
for (const executor of this.executors) {
|
||||
const fun = executor[name + "Command"];
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class TreeContextMenu {
|
||||
{ title: 'Search in subtree <kbd data-command="searchInSubtree"></kbd>', command: "searchInSubtree", uiIcon: "search",
|
||||
enabled: notSearch && noSelectedNotes },
|
||||
isHoisted ? null : { title: 'Hoist note <kbd data-command="toggleNoteHoisting"></kbd>', command: "toggleNoteHoisting", uiIcon: "empty", enabled: noSelectedNotes && notSearch },
|
||||
!isHoisted || !isNotRoot ? null : { title: 'Unhoist note <kbd data-command="toggleNoteHoisting"></kbd>', command: "toggleNoteHoisting", uiIcon: "arrow-from-bottom" },
|
||||
!isHoisted || !isNotRoot ? null : { title: 'Unhoist note <kbd data-command="toggleNoteHoisting"></kbd>', command: "toggleNoteHoisting", uiIcon: "door-open" },
|
||||
{ title: 'Edit branch prefix <kbd data-command="editBranchPrefix"></kbd>', command: "editBranchPrefix", uiIcon: "empty",
|
||||
enabled: isNotRoot && parentNotSearch && noSelectedNotes},
|
||||
{ title: "Advanced", uiIcon: "empty", enabled: true, items: [
|
||||
|
||||
@@ -198,9 +198,9 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
||||
this.$widget = $(TPL);
|
||||
this.$tree = this.$widget.find('.tree');
|
||||
|
||||
this.$tree.on("click", ".unhoist-button", hoistedNoteService.unhoist);
|
||||
this.$tree.on("click", ".refresh-search-button", e => this.refreshSearch(e));
|
||||
this.$tree.on("click", ".add-note-button", e => {
|
||||
this.$tree.on("mousedown", ".unhoist-button", () => hoistedNoteService.unhoist());
|
||||
this.$tree.on("mousedown", ".refresh-search-button", e => this.refreshSearch(e));
|
||||
this.$tree.on("mousedown", ".add-note-button", e => {
|
||||
const node = $.ui.fancytree.getNode(e);
|
||||
|
||||
noteCreateService.createNote(node.data.noteId, {
|
||||
@@ -208,18 +208,12 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
||||
});
|
||||
});
|
||||
|
||||
this.$tree.on("click", ".enter-workspace-button", e => {
|
||||
this.$tree.on("mousedown", ".enter-workspace-button", e => {
|
||||
const node = $.ui.fancytree.getNode(e);
|
||||
|
||||
this.triggerCommand('hoistNote', {noteId: node.data.noteId});
|
||||
});
|
||||
|
||||
this.$tree.on("click", ".unhoist-button", e => {
|
||||
const node = $.ui.fancytree.getNode(e);
|
||||
|
||||
this.triggerCommand('unhoist');
|
||||
});
|
||||
|
||||
// fancytree doesn't support middle click so this is a way to support it
|
||||
this.$tree.on('mousedown', '.fancytree-title', e => {
|
||||
if (e.which === 2) {
|
||||
@@ -514,11 +508,20 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
const note = await treeCache.getNote(node.data.noteId);
|
||||
const activeTabContext = appContext.tabManager.getActiveTabContext();
|
||||
|
||||
const $span = $(node.span);
|
||||
|
||||
$span.find('.tree-item-button').remove();
|
||||
|
||||
const note = await treeCache.getNote(node.data.noteId);
|
||||
if (activeTabContext && activeTabContext.hoistedNoteId === note.noteId && note.noteId !== 'root') {
|
||||
const $unhoistButton = $('<span class="tree-item-button unhoist-button bx bx-door-open" title="Unhoist"></span>');
|
||||
|
||||
$unhoistButton.on('click', () => alert("bebe"));
|
||||
|
||||
$span.append($unhoistButton);
|
||||
}
|
||||
|
||||
if (note.hasLabel('workspace')) {
|
||||
const $enterWorkspaceButton = $('<span class="tree-item-button enter-workspace-button bx bx-door-open" title="Hoist this note (workspace)"></span>');
|
||||
|
||||
Reference in New Issue
Block a user