implemented insert after and insert into in context menu

This commit is contained in:
azivner 2017-09-04 13:27:54 -04:00
parent 390568d743
commit 1f7f7d105c

View File

@ -66,9 +66,13 @@ function deleteNode(node) {
} }
} }
function getParentKey(node) {
return (node.getParent() === null || node.getParent().key === "root_1") ? "root" : node.getParent().key;
}
const keybindings = { const keybindings = {
"insert": function(node) { "insert": function(node) {
let parentKey = (node.getParent() === null || node.getParent().key === "root_1") ? "root" : node.getParent().key; const parentKey = getParentKey(node);
createNote(node, parentKey, 'after'); createNote(node, parentKey, 'after');
}, },
@ -313,22 +317,19 @@ $(function(){
ui.menu.prevKeyboard = node.tree.options.keyboard; ui.menu.prevKeyboard = node.tree.options.keyboard;
node.tree.options.keyboard = false; node.tree.options.keyboard = false;
}, },
close: function (event, ui) { close: function (event, ui) {},
// Restore tree keyboard handling
// console.log("close", event, ui, this)
// Note: ui is passed since v1.15.0
const node = $.ui.fancytree.getNode(ui.target);
// in case of move operations this can be null
if (node) {
node.tree.options.keyboard = ui.menu.prevKeyboard;
node.setFocus();
}
},
select: function (event, ui) { select: function (event, ui) {
const node = $.ui.fancytree.getNode(ui.target); const node = $.ui.fancytree.getNode(ui.target);
if (ui.cmd === "cut") { if (ui.cmd === "insertNoteHere") {
const parentKey = getParentKey(node);
createNote(node, parentKey, 'after');
}
else if (ui.cmd === "insertChildNote") {
createNote(node, node.key, 'into');
}
else if (ui.cmd === "cut") {
globalClipboardNoteId = node.key; globalClipboardNoteId = node.key;
} }
else if (ui.cmd === "pasteAfter") { else if (ui.cmd === "pasteAfter") {