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

This commit is contained in:
azivner 2018-01-26 19:54:27 -05:00
parent 9f3d46ddb1
commit 0da13994a6
3 changed files with 6 additions and 6 deletions

View File

@ -68,6 +68,12 @@ const noteEditor = (function() {
function updateNoteFromInputs(note) { function updateNoteFromInputs(note) {
if (note.detail.type === 'text') { if (note.detail.type === 'text') {
note.detail.note_text = editor.getData(); 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') { else if (note.detail.type === 'code') {
note.detail.note_text = codeEditor.getValue(); note.detail.note_text = codeEditor.getValue();

View File

@ -800,8 +800,6 @@ const noteTree = (function() {
} }
$(document).bind('keydown', 'ctrl+o', e => { $(document).bind('keydown', 'ctrl+o', e => {
console.log("pressed O");
const node = getCurrentNode(); const node = getCurrentNode();
const parentNoteId = node.data.parent_note_id; const parentNoteId = node.data.parent_note_id;
const isProtected = treeUtils.getParentProtectedStatus(node); const isProtected = treeUtils.getParentProtectedStatus(node);

View File

@ -210,10 +210,6 @@ async function saveNoteImages(noteId, noteText, sourceId) {
} }
async function updateNote(noteId, newNote, dataKey, 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) { if (newNote.detail.is_protected) {
await protected_session.encryptNote(dataKey, newNote.detail); await protected_session.encryptNote(dataKey, newNote.detail);
} }