mirror of
https://github.com/zadam/trilium.git
synced 2025-02-25 07:25:32 +08:00
context menu disables actions not applicable to search note
This commit is contained in:
parent
0fd5102a26
commit
9c32f66329
2 changed files with 18 additions and 5 deletions
|
@ -95,9 +95,17 @@ const contextMenu = (function() {
|
||||||
],
|
],
|
||||||
beforeOpen: (event, ui) => {
|
beforeOpen: (event, ui) => {
|
||||||
const node = $.ui.fancytree.getNode(ui.target);
|
const node = $.ui.fancytree.getNode(ui.target);
|
||||||
|
const nt = noteTree.getNoteTree(node.data.noteTreeId);
|
||||||
|
const note = noteTree.getNote(node.data.noteId);
|
||||||
|
const parentNote = noteTree.getNote(nt.parentNoteId);
|
||||||
|
|
||||||
// Modify menu entries depending on node status
|
// Modify menu entries depending on node status
|
||||||
$tree.contextmenu("enableEntry", "pasteAfter", clipboardIds.length > 0);
|
$tree.contextmenu("enableEntry", "pasteAfter", clipboardIds.length > 0 && (!parentNote || parentNote.type !== 'search'));
|
||||||
$tree.contextmenu("enableEntry", "pasteInto", clipboardIds.length > 0);
|
$tree.contextmenu("enableEntry", "pasteInto", clipboardIds.length > 0 && note.type !== 'search');
|
||||||
|
$tree.contextmenu("enableEntry", "insertNoteHere", !parentNote || parentNote.type !== 'search');
|
||||||
|
$tree.contextmenu("enableEntry", "insertChildNote", note.type !== 'search');
|
||||||
|
$tree.contextmenu("enableEntry", "importSubTree", note.type !== 'search');
|
||||||
|
$tree.contextmenu("enableEntry", "exportSubTree", note.type !== 'search');
|
||||||
|
|
||||||
// Activate node on right-click
|
// Activate node on right-click
|
||||||
node.setActive();
|
node.setActive();
|
||||||
|
|
|
@ -204,7 +204,7 @@ const noteTree = (function() {
|
||||||
title: escapeHtml(title),
|
title: escapeHtml(title),
|
||||||
extraClasses: getExtraClasses(note),
|
extraClasses: getExtraClasses(note),
|
||||||
refKey: noteId,
|
refKey: noteId,
|
||||||
expanded: noteTree.isExpanded
|
expanded: note.type !== 'search' && noteTree.isExpanded
|
||||||
};
|
};
|
||||||
|
|
||||||
const hasChildren = parentToChildren[noteId] && parentToChildren[noteId].length > 0;
|
const hasChildren = parentToChildren[noteId] && parentToChildren[noteId].length > 0;
|
||||||
|
@ -212,7 +212,7 @@ const noteTree = (function() {
|
||||||
if (hasChildren || note.type === 'search') {
|
if (hasChildren || note.type === 'search') {
|
||||||
node.folder = true;
|
node.folder = true;
|
||||||
|
|
||||||
if (node.expanded) {
|
if (node.expanded && note.type !== 'search') {
|
||||||
node.children = prepareNoteTreeInner(noteId);
|
node.children = prepareNoteTreeInner(noteId);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -889,6 +889,10 @@ const noteTree = (function() {
|
||||||
return notesTreeMap[noteTreeId];
|
return notesTreeMap[noteTreeId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getNote(noteId) {
|
||||||
|
return noteIdToNote[noteId];
|
||||||
|
}
|
||||||
|
|
||||||
$(document).bind('keydown', 'ctrl+o', e => {
|
$(document).bind('keydown', 'ctrl+o', e => {
|
||||||
const node = getCurrentNode();
|
const node = getCurrentNode();
|
||||||
const parentNoteId = node.data.parentNoteId;
|
const parentNoteId = node.data.parentNoteId;
|
||||||
|
@ -965,6 +969,7 @@ const noteTree = (function() {
|
||||||
sortAlphabetically,
|
sortAlphabetically,
|
||||||
noteExists,
|
noteExists,
|
||||||
getInstanceName,
|
getInstanceName,
|
||||||
getNoteTree
|
getNoteTree,
|
||||||
|
getNote
|
||||||
};
|
};
|
||||||
})();
|
})();
|
Loading…
Reference in a new issue