empty note with just included note should be saved, closes #807

This commit is contained in:
zadam 2020-01-04 13:22:07 +01:00
parent 7793552443
commit d025cfee1b
3 changed files with 18 additions and 6 deletions

View File

@ -116,15 +116,19 @@ class NoteDetailText {
}
getContent() {
let content = this.textEditor.getData();
const content = this.textEditor.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 (jQuery(content).text().trim() === '' && !content.includes("<img")) {
content = '';
}
return this.isContentEmpty(content) ? '' : content;
}
return content;
isContentEmpty(content) {
content = content.toLowerCase();
return jQuery(content).text().trim() === ''
&& !content.includes("<img")
&& !content.includes("<section")
}
async isReadOnly() {

View File

@ -213,7 +213,11 @@ function closeActiveDialog() {
}
function isHtmlEmpty(html) {
return $("<div>").html(html).text().trim().length === 0 && !html.toLowerCase().includes('<img');
html = html.toLowerCase();
return $("<div>").html(html).text().trim().length === 0
&& !html.includes('<img')
&& !html.includes('<section');
}
async function clearBrowserCache() {

View File

@ -967,4 +967,8 @@ a.external:not(.no-arrow):after, a[href^="http://"]:not(.no-arrow):after, a[href
padding: 20px;
border-radius: 10px;
background-color: var(--accented-background-color);
}
.include-note.ck-placeholder::before { /* remove placeholder in otherwise empty note */
content: '' !important;
}