Skip to content

Build your personal knowledge base with Trilium Notes

Updated documentation for the duplicateSubtree, and removed commented out code per request.

Geekswordsman911fee0213eb
diff --git a/apps/server/src/services/backend_script_api.ts b/apps/server/src/services/backend_script_api.ts
index 6513245c4c..60af0fb970 100644
--- a/apps/server/src/services/backend_script_api.ts
+++ b/apps/server/src/services/backend_script_api.ts
@@ -413,9 +413,13 @@ export interface Api {
backupNow(backupName: string): Promise<string>;
/**
- * Exposes the backend duplicateSubtree to the API
+ * Enables the complete duplication of the specified original note and all its children into the specified parent note.
+ * The new note will be named the same as the original, with (Dup) added to the end of it.
+ *
* @param origNoteId - the noteId for the original note to be duplicated
* @param newParentNoteId - the noteId for the parent note where the duplication is to be placed.
+ *
+ * @returns the note and the branch of the newly created note.
*/
duplicateSubtree(origNoteId: string, newParentNoteId: string): { note: BNote; branch: BBranch; }
diff --git a/apps/server/src/services/notes.ts b/apps/server/src/services/notes.ts
index 1f91b4db07..e225cdb525 100644
--- a/apps/server/src/services/notes.ts
+++ b/apps/server/src/services/notes.ts
@@ -931,11 +931,6 @@ function duplicateSubtree(origNoteId: string, newParentNoteId: string) {
const noteIdMapping = getNoteIdMapping(origNote);
- // Not required - if origBranch doesn't exist, the subtree can still be created.
- // if (!origBranch) {
- // throw new Error("Unable to find original branch to duplicate.");
- // }
-
const res = duplicateSubtreeInner(origNote, origBranch, newParentNoteId, noteIdMapping);
const duplicateNoteSuffix = t("notes.duplicate-note-suffix");