Skip to content

Build your personal knowledge base with Trilium Notes

better filtering of empty HTML content (just tags and whitespace)

azivner0da13994a6bb
diff --git a/public/javascripts/note_editor.js b/public/javascripts/note_editor.js
index f8baf6efb8..bd0d55ffa9 100644
--- a/public/javascripts/note_editor.js
+++ b/public/javascripts/note_editor.js
@@ -68,6 +68,12 @@ const noteEditor = (function() {
function updateNoteFromInputs(note) {
if (note.detail.type === 'text') {
note.detail.note_text = editor.getData();
+
+ // if content is only tags/whitespace (typically <p>&nbsp;</p>), then just make it empty
+ // this is important when setting new note to code
+ if ($(note.detail.note_text).text().trim() === '') {
+ note.detail.note_text = ''
+ }
}
else if (note.detail.type === 'code') {
note.detail.note_text = codeEditor.getValue();
diff --git a/public/javascripts/note_tree.js b/public/javascripts/note_tree.js
index 736ca05977..52dbe1eca8 100644
--- a/public/javascripts/note_tree.js
+++ b/public/javascripts/note_tree.js
@@ -800,8 +800,6 @@ const noteTree = (function() {
}
$(document).bind('keydown', 'ctrl+o', e => {
- console.log("pressed O");
-
const node = getCurrentNode();
const parentNoteId = node.data.parent_note_id;
const isProtected = treeUtils.getParentProtectedStatus(node);
diff --git a/services/notes.js b/services/notes.js
index 741af8e55e..f36bb0632a 100644
--- a/services/notes.js
+++ b/services/notes.js
@@ -210,10 +210,6 @@ async function saveNoteImages(noteId, noteText, sourceId) {
}
async function updateNote(noteId, newNote, dataKey, sourceId) {
- if (newNote.detail.note_text === '<p>&nbsp;</p>') {
- newNote.detail.note_text = ''
- }
-
if (newNote.detail.is_protected) {
await protected_session.encryptNote(dataKey, newNote.detail);
}