Issue #1915Opened March 22, 2019by arachnosoft0 reactions

grapesjs strips   entities (mostly inserted by CKEditor)

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>&nbsp; <label class="c3111 c3163 c3223" style="box-sizing: border-box;">My label field 2</label>

With an &nbsp; between the two label tags, the &nbsp; is being stripped from the code, leaving the two <label> tags "glued" together.

I reproduced the issue with the Newsletter demo:

grapesjs Strips nbsp

If I put anything else between the two (even, sometimes... real spaces), everything is kept.

Do you know if there's any explicit &nbsp; 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 &nbsp; in my case...

Maybe I could try to prevent this by catching &nbsp;, 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)

arachnosoftMarch 25, 20190 reactions

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.

keepEmptyTextNodes Initialization keepEmptyTextNodes Usage

I'm closing the issue! But you should add this on your documentation ;)

lock[bot]March 27, 20200 reactions

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.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.