mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
context menu converted to module
This commit is contained in:
parent
9880a4d6f6
commit
ad7803f9dc
@ -1,26 +1,27 @@
|
||||
const treeEl = $("#tree");
|
||||
const contextMenu = (function() {
|
||||
const treeEl = $("#tree");
|
||||
|
||||
function pasteAfter(node) {
|
||||
function pasteAfter(node) {
|
||||
const subjectNode = getNodeByKey(glob.clipboardNoteId);
|
||||
|
||||
moveAfterNode(subjectNode, node);
|
||||
|
||||
glob.clipboardNoteId = null;
|
||||
}
|
||||
}
|
||||
|
||||
function pasteInto(node) {
|
||||
function pasteInto(node) {
|
||||
const subjectNode = getNodeByKey(glob.clipboardNoteId);
|
||||
|
||||
moveToNode(subjectNode, node);
|
||||
|
||||
glob.clipboardNoteId = null;
|
||||
}
|
||||
}
|
||||
|
||||
function cut(node) {
|
||||
function cut(node) {
|
||||
glob.clipboardNoteId = node.key;
|
||||
}
|
||||
}
|
||||
|
||||
const contextMenuSetup = {
|
||||
const contextMenuSettings = {
|
||||
delegate: "span.fancytree-title",
|
||||
autoFocus: true,
|
||||
menu: [
|
||||
@ -83,4 +84,12 @@ const contextMenuSetup = {
|
||||
console.log("Unknown command: " + ui.cmd);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
return {
|
||||
pasteAfter,
|
||||
pasteInto,
|
||||
cut,
|
||||
contextMenuSettings
|
||||
}
|
||||
})();
|
@ -161,7 +161,7 @@ const noteTree = (function() {
|
||||
console.log("CTRL-V");
|
||||
|
||||
if (event.ctrlKey) { // Ctrl-V
|
||||
pasteAfter(node);
|
||||
contextMenu.pasteAfter(node);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@ -169,7 +169,7 @@ const noteTree = (function() {
|
||||
console.log("CTRL-X");
|
||||
|
||||
if (event.ctrlKey) { // Ctrl-X
|
||||
cut(node);
|
||||
contextMenu.cut(node);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@ -177,7 +177,7 @@ const noteTree = (function() {
|
||||
}
|
||||
});
|
||||
|
||||
treeEl.contextmenu(contextMenuSetup);
|
||||
treeEl.contextmenu(contextMenu.contextMenuSettings);
|
||||
}
|
||||
|
||||
function loadTree() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user