Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
prevent pasting notes into search parent note
zadamb45df29937e3
diff --git a/src/services/cloning.js b/src/services/cloning.jsindex d929a1cbfa..395cb67727 100644--- a/src/services/cloning.js+++ b/src/services/cloning.js@@ -3,10 +3,7 @@const sql = require('./sql');const eventChangesService = require('./entity_changes');const treeService = require('./tree');-const noteService = require('./notes');const Branch = require('../becca/entities/branch');-const TaskContext = require("./task_context");-const utils = require('./utils');const becca = require("../becca/becca");const beccaService = require("../becca/becca_service");const log = require("./log");@@ -18,6 +15,15 @@ function cloneNoteToNote(noteId, parentNoteId, prefix) {specialNotesService.getShareRoot();}+ const parentNote = becca.getNote(parentNoteId);++ if (parentNote.type === 'search') {+ return {+ success: false,+ message: "Can't clone into a search note"+ };+ }+if (isNoteDeleted(noteId) || isNoteDeleted(parentNoteId)) {return { success: false, message: 'Note is deleted.' };}@@ -53,7 +59,7 @@ function cloneNoteToBranch(noteId, parentBranchId, prefix) {const ret = cloneNoteToNote(noteId, parentBranch.noteId, prefix);- parentBranch.isExpanded = true; // the new target should be expanded so it immediately shows up to the user+ parentBranch.isExpanded = true; // the new target should be expanded, so it immediately shows up to the userparentBranch.save();return ret;@@ -64,6 +70,15 @@ function ensureNoteIsPresentInParent(noteId, parentNoteId, prefix) {return { success: false, message: 'Note is deleted.' };}+ const parentNote = becca.getNote(parentNoteId);++ if (parentNote.type === 'search') {+ return {+ success: false,+ message: "Can't clone into a search note"+ };+ }+const validationResult = treeService.validateParentChild(parentNoteId, noteId);if (!validationResult.success) {@@ -78,6 +93,8 @@ function ensureNoteIsPresentInParent(noteId, parentNoteId, prefix) {}).save();log.info(`Ensured note ${noteId} is in parent note ${parentNoteId} with prefix ${prefix}`);++ return { success: true };}function ensureNoteIsAbsentFromParent(noteId, parentNoteId) {@@ -111,6 +128,15 @@ function cloneNoteAfter(noteId, afterBranchId) {return { success: false, message: 'Note is deleted.' };}+ const parentNote = becca.getNote(afterNote.parentNoteId);++ if (parentNote.type === 'search') {+ return {+ success: false,+ message: "Can't clone into a search note"+ };+ }+const validationResult = treeService.validateParentChild(afterNote.parentNoteId, noteId);if (!validationResult.success) {