Skip to content

Build your personal knowledge base with Trilium Notes

fix JSON saving bug

azivner120888b53e39
diff --git a/src/entities/note.js b/src/entities/note.js
index c118336670..2b5e9e7b7a 100644
--- a/src/entities/note.js
+++ b/src/entities/note.js
@@ -21,6 +21,14 @@ class Note extends Entity {
}
}
+ setContent(content) {
+ this.content = content;
+
+ if (this.isJson()) {
+ this.jsonContent = JSON.parse(this.content);
+ }
+ }
+
isJson() {
return this.mime === "application/json";
}
diff --git a/src/services/notes.js b/src/services/notes.js
index eaa338df27..440a05bb0d 100644
--- a/src/services/notes.js
+++ b/src/services/notes.js
@@ -198,7 +198,7 @@ async function updateNote(noteId, noteUpdates) {
await saveNoteRevision(note);
note.title = noteUpdates.title;
- note.content = noteUpdates.content;
+ note.setContent(noteUpdates.content);
note.isProtected = noteUpdates.isProtected;
await note.save();