Grapesjs strips entities (mostly inserted by CKEditor)
I think the issue might be here https://github.com/artf/grapesjs/blob/0a122cd7b558bcf391cfd7e4608dffad3ba9de53/src/parser/model/ParserHtml.js#L169-L172 unfortunately nodeValue returns already processed string, without Try to use this option: https://github.com/artf/grapesjs/blob/0a122cd7b558bcf391cfd7e4608dffad...
Read full answer below ↓Question
Hi @artf ,
We have just noticed that, if you import this code into grapesjs:
<label class="c3100 c3152 c3212" style="box-sizing: border-box;">My label field 1</label> <label class="c3111 c3163 c3223" style="box-sizing: border-box;">My label field 2</label>
With an between the two label tags, the is being stripped from the code, leaving the two <label> tags "glued" together.
I reproduced the issue with the Newsletter demo:

If I put anything else between the two (even, sometimes... real spaces), everything is kept.
Do you know if there's any explicit removal code somewhere?
I looked into grapes.js and found only a reference to issue #1362 ,but it doesn't seem to have anything to do with my current problem:
// Change some spaces to NBSP to prevent the browser from collapsing
// trailing spaces at the end of a line when rendering text (issue #1362).
function splitSpaces()
Issue #180 sounds rather close;
You told the OP to add a space between all his tags to fix his issue, but the OP replied that it was actually fixed by an update...
And I tested this as well on your demo (on which, I suppose, CKEditor should be rather up-to-date, not to mention grapesjs itself) and the "space between tags" trick doesn't prevent grapesjs from stripping in my case...
Maybe I could try to prevent this by catching , through isComponent(), but I'd like to read your opinion on this first, in case it'd be a real bug somewhere, if not an explicit choice from you.
Thanks! -Maxime
Answers (3)
I think the issue might be here
https://github.com/artf/grapesjs/blob/0a122cd7b558bcf391cfd7e4608dffad3ba9de53/src/parser/model/ParserHtml.js#L169-L172
unfortunately nodeValue returns already processed string, without
Try to use this option:
https://github.com/artf/grapesjs/blob/0a122cd7b558bcf391cfd7e4608dffad3ba9de53/src/editor/config/config.js#L104-L105
Thank you very much for the tip @artf , this (undocumented?) Parser config option seems to solve my issue!
Of course, I had to set it to true, not 0, as I wanted to keep those empty spaces ;)
And had to set it on the editor.Parser.getConfig() object. Setting this option through grapesjs.init() has no effect.

I'm closing the issue! But you should add this on your documentation ;)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1333
Bug in WebPage Demo
To reproduce: 1) Open https://grapesjs.com/demo.html in incognito mode. 2) Import this code: 3) Clear Canvas 4) Press Import. Result: The c...
Issue #1556
Add new block to block manager: predefined content and editor content is different
I try to use template engine with grapesjs. Add new block by this: Drag new block to editor then the content of editor is different from ab...
Issue #1471
[Question] Blockmanager and Image
Hi! I use this code to add a new block: blockManager.add("image", { label: 'Image', category: 'Basic', attributes: { class: "gjs-fonts gjs-...
Issue #493
[QUESTION] Can i set content dynamically from block API ?
Hi @artf , very great web builder framework and keep it up :+1: code : As you can see, can i make tag dynamically from my backend? i use EJ...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Related tutorials
In-depth guides on the same topic.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.