quill icon indicating copy to clipboard operation
quill copied to clipboard

getSemanticHTML returns <p></p> when editor is blank/empty

Open trymeouteh opened this issue 1 year ago • 1 comments

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>

trymeouteh avatar Jan 31 '25 16:01 trymeouteh

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

BowenTew avatar Apr 16 '25 09:04 BowenTew