As mentioned in title, empty content keeps empty html tags (p, h1, h2, ...), but through Placeholder extension class is added to content container when it's empty. Is there any method on Editor which can check for empty content which returns true/false or at least get content (there are only getHtml and getJSON methods mentioned in docs); based on this I could just update data to an empty string instead of empty html tags.
I can write custom method in my code which checks for content using getJSON result; I was wondering if there is already method for that, but it's missing from docs.
My temporary workaround
.....
onUpdate: ({ getHTML, getJSON }) => {
if (!('content' in getJSON().content[0])) {
this.context.model = null
return
}
this.context.model = getHTML()
},
Thanks for the suggestion @kikky7! And thanks for sharing @tguelcan!
We added editor.isEmpty() to the upcoming tiptap v2 for that purpose. 馃檶
Most helpful comment
Thanks for the suggestion @kikky7! And thanks for sharing @tguelcan!
We added
editor.isEmpty()to the upcoming tiptap v2 for that purpose. 馃檶