Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#8905 closed Bug (invalid)

CKEDITOR.htmlWriter giving unexpected results

Reported by: Lynne Kues Owned by:
Priority: Normal Milestone:
Component: General Version: 3.6.2
Keywords: IBM Cc:

Description (last modified by Jakub Ś)

var writer = new CKEDITOR.htmlWriter();
var contents = '<div>'  
+ '<p id="_1334328943223">'
+ '<span class="showContent com-ibm-rdm-editor-EmbeddedResourceDecorator embeddedContentLoadRequired">'
+     '<a id="_1334328943227" class="embedded" href="">'
+        '<u>  </u>'
+      '</a>'
+    '</span>'
+  '</p>'
+  '<span>  </span>'
+ '<p id="_1334328943224"/>'
+  '<p id="_1334328943225">'
+   '<span class="showContent com-ibm-rdm-editor-EmbeddedResourceDecorator embeddedContentLoadRequired">'
+      '<a id="_1334328943228" class="embedded" href="">'
+        '<u> </u>'
+      '</a>'
+    '</span>'
+  '</p>'
+  '<span> </span>'
+  '<p id="_1334328943226"/>'
+ '</div>';
var frag = CKEDITOR.htmlParser.fragment.fromHtml(contents);
console.log("CONTENTS " + writer.getHtml());

Executing the above gives the following result, which is unexpected as it removes data (seen on FF10 and IE9:

<p id="_1334328943223"> </p> 
<p id="_1334328943224"> </p> 
<p id="_1334328943225"> </p> 
<p id="_1334328943226"> </p> 

Change History (3)

comment:1 Changed 12 years ago by Jakub Ś

Description: modified (diff)

comment:2 Changed 12 years ago by Garry Yao

Resolution: invalid
Status: newclosed

It's not a bug - the inline elements (those are stripped) contains nothing but whitespace which is at the beginning of the block thus are not visible from rendered HTML, those contents are considered as garbage thus is removed when parsing.

comment:3 Changed 12 years ago by Jakub Ś

To workaround this problem simply add &nbsp; in your most nested inline element. Instead of '<u> </u>' please use <u>&nbsp;</u>

This is not only an issue with htmlWriter but how CKEditor works - to test it simply insert

<span> </span>

and switch modes and you will see that first span will be removed.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy