Skip to content

Build your personal knowledge base with Trilium Notes

support for cloned notes including updating clones. Creating clones is not supported. Renaming is handled a bit differently - all clones and original share the same name, while in Notecase desktop each clone has separate name.

azivnerb986e9335600
diff --git a/src/tree.py b/src/tree.py
index c380663273..42a8557839 100644
--- a/src/tree.py
+++ b/src/tree.py
@@ -7,7 +7,15 @@ from sql import getResults
class Tree(Resource):
def get(self):
- notes = getResults("select notes_tree.*, notes.note_title from notes_tree join notes on notes.note_id = notes_tree.note_id order by note_pid, note_pos")
+ notes = getResults("select "
+ "notes_tree.*, "
+ "COALESCE(clone.note_title, notes.note_title) as note_title, "
+ "notes.note_clone_id, "
+ "case when notes.note_clone_id is null or notes.note_clone_id = '' then 0 else 1 end as is_clone "
+ "from notes_tree "
+ "join notes on notes.note_id = notes_tree.note_id "
+ "left join notes as clone on notes.note_clone_id = clone.note_id "
+ "order by note_pid, note_pos")
rootNotes = []
notesMap = {}
diff --git a/static/js/note.js b/static/js/note.js
index cfaae36caf..23411617d1 100644
--- a/static/js/note.js
+++ b/static/js/note.js
@@ -28,8 +28,10 @@ function noteChanged() {
note.detail.note_title = title;
+ const note_id = note.detail.is_clone ? note.detail.note_clone_id : note.detail.note_id;
+
$.ajax({
- url: baseUrl + 'notes/' + note.detail.note_id,
+ url: baseUrl + 'notes/' + note_id,
type: 'PUT',
data: JSON.stringify(note),
contentType: "application/json",
diff --git a/static/js/tree.js b/static/js/tree.js
index beb401eb23..2968164ca1 100644
--- a/static/js/tree.js
+++ b/static/js/tree.js
@@ -3,6 +3,11 @@ $(function(){
function copyTitle(notes) {
for (let note of notes) {
note.title = note.note_title;
+
+ if (note.is_clone) {
+ note.title += " (clone)";
+ }
+
note.key = note.note_id;
note.expanded = note.is_expanded;
@@ -31,8 +36,8 @@ $(function(){
extensions: ["hotkeys"],
source: notes,
activate: function(event, data){
- var node = data.node.data;
- var noteId = node.note_id;
+ const node = data.node.data;
+ const noteId = node.is_clone ? node.note_clone_id : node.note_id;
loadNote(noteId);
},