quill
quill copied to clipboard
getSemanticHTML returns <p></p> when editor is blank/empty
getSemanticHTML() returns <p></p> when editor is blank/empty. It should return a blank/empty string instead.
Demo to reproduce issue
<link rel="stylesheet" href="node_modules/quill/dist/quill.snow.css" />
<style>
textarea,
#my-editor-container {
height: 50%;
width: 50%;
}
</style>
<textarea></textarea>
<div id="my-editor-container">
<div id="my-editor"></div>
</div>
<script src="node_modules/quill/dist/quill.js"></script>
<script>
const myEditor = new Quill('#my-editor', {
theme: 'snow',
});
myEditor.on('text-change', myFunction);
myFunction();
function myFunction() {
let myEditorText = myEditor.getSemanticHTML();
document.querySelector('textarea').value = myEditorText;
}
</script>
This might be reasonable.Cause Because when quill editor is empty,the editor contains a document node
,getSemanticHTML is to get the html of the contents