mirror of
https://github.com/zadam/trilium.git
synced 2025-10-27 16:26:31 +01:00
cloning in context menu (copy & paste) and a lot of related refactoring and fixes
This commit is contained in:
@@ -25,6 +25,17 @@ const treeChanges = (function() {
|
||||
noteTree.setCurrentNotePathToHash(node);
|
||||
}
|
||||
|
||||
// beware that first arg is noteId and second is noteTreeId!
|
||||
async function cloneNoteAfter(noteId, afterNoteTreeId) {
|
||||
await $.ajax({
|
||||
url: baseApiUrl + 'notes/' + noteId + '/cloneAfter/' + afterNoteTreeId,
|
||||
type: 'PUT',
|
||||
error: () => showError("Error cloning note.")
|
||||
});
|
||||
|
||||
await noteTree.reload();
|
||||
}
|
||||
|
||||
async function moveToNode(node, toNode) {
|
||||
await $.ajax({
|
||||
url: baseApiUrl + 'notes/' + node.data.note_tree_id + '/moveTo/' + toNode.data.note_id,
|
||||
@@ -42,6 +53,16 @@ const treeChanges = (function() {
|
||||
noteTree.setCurrentNotePathToHash(node);
|
||||
}
|
||||
|
||||
async function cloneNoteTo(childNoteId, parentNoteId) {
|
||||
await $.ajax({
|
||||
url: baseApiUrl + 'notes/' + childNoteId + '/cloneTo/' + parentNoteId,
|
||||
type: 'PUT',
|
||||
error: () => showError("Error cloning note.")
|
||||
});
|
||||
|
||||
await noteTree.reload();
|
||||
}
|
||||
|
||||
async function deleteNode(node) {
|
||||
if (!confirm('Are you sure you want to delete note "' + node.title + '"?')) {
|
||||
return;
|
||||
@@ -97,6 +118,8 @@ const treeChanges = (function() {
|
||||
moveAfterNode,
|
||||
moveToNode,
|
||||
deleteNode,
|
||||
moveNodeUp
|
||||
moveNodeUp,
|
||||
cloneNoteAfter,
|
||||
cloneNoteTo
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user