mirror of
https://github.com/zadam/trilium.git
synced 2025-02-25 15:35:43 +08:00
drag & drop notes from the tree into relation map
This commit is contained in:
parent
bbe36fc7fb
commit
340916d5da
2 changed files with 21 additions and 2 deletions
|
@ -8,11 +8,21 @@ const dragAndDropSetup = {
|
|||
return false;
|
||||
}
|
||||
|
||||
// this is for dragging notes into relation map
|
||||
data.dataTransfer.setData("text", JSON.stringify({
|
||||
noteId: node.data.noteId,
|
||||
title: node.data.title
|
||||
}));
|
||||
|
||||
// This function MUST be defined to enable dragging for the tree.
|
||||
// Return false to cancel dragging of node.
|
||||
return true;
|
||||
},
|
||||
dragEnter: (node, data) => true, // allow drop on any node
|
||||
dragEnter: (node, data) => {
|
||||
// we don't allow moving root to any other location in the tree
|
||||
// we allow it to be placed on the relation map though, that's handled in a different drop handler
|
||||
return node.data.noteId === 'root';
|
||||
}, // allow drop on any node
|
||||
dragDrop: (node, data) => {
|
||||
// This function MUST be defined to enable dropping of items on the tree.
|
||||
// data.hitMode is 'before', 'after', or 'over'.
|
||||
|
|
|
@ -456,10 +456,19 @@ function dragover_handler(ev) {
|
|||
|
||||
console.log("DRAGOVER");
|
||||
}
|
||||
|
||||
function drop_handler(ev) {
|
||||
ev.preventDefault();
|
||||
|
||||
console.log("DROP!", ev);
|
||||
const note = JSON.parse(ev.originalEvent.dataTransfer.getData("text"));
|
||||
|
||||
let {x, y} = getMousePosition(ev);
|
||||
|
||||
// modifying position so that cursor is on the top-center of the box
|
||||
x -= 80;
|
||||
y -= 15;
|
||||
|
||||
createNoteBox(note.noteId, note.title, x, y);
|
||||
}
|
||||
|
||||
function getMousePosition(evt) {
|
||||
|
|
Loading…
Reference in a new issue