Skip to content

Build your personal knowledge base with Trilium Notes

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

zadamd025cfee1bd9
diff --git a/src/public/javascripts/services/note_detail_text.js b/src/public/javascripts/services/note_detail_text.js
index 068cedd461..d81d5aed0d 100644
--- a/src/public/javascripts/services/note_detail_text.js
+++ b/src/public/javascripts/services/note_detail_text.js
@@ -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;
+ }
+
+ isContentEmpty(content) {
+ content = content.toLowerCase();
- return content;
+ return jQuery(content).text().trim() === ''
+ && !content.includes("<img")
+ && !content.includes("<section")
}
async isReadOnly() {
diff --git a/src/public/javascripts/services/utils.js b/src/public/javascripts/services/utils.js
index 4436232dfd..c64882fd74 100644
--- a/src/public/javascripts/services/utils.js
+++ b/src/public/javascripts/services/utils.js
@@ -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() {
diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css
index 456f04f248..9ba8c9505a 100644
--- a/src/public/stylesheets/style.css
+++ b/src/public/stylesheets/style.css
@@ -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;
}
\ No newline at end of file