Remove the extra <div> when saving content from CKEditor
I need to have a single top-level element in order to serialize to XML when returning the editor’s content back to the text area, because, unlike PostgreSQL, XMLSerializer only works with XML documents. I added a <div> because this is the least “semantic” block element there is, but Oriol seems to have trouble in services when trying to align services using a grid due to this extra div. Now i still use the div to serialize to XML, but then remove that top-level element from the output string by stripping out its label. I can not be sure that all browsers would serialize the <div> in the same way, thus i can not use fixed indices in call to substring.
This commit is contained in:
parent
cf527ce070
commit
64dc533949
|
@ -118,7 +118,10 @@ ready(function () {
|
|||
editor.ui.focusTracker.on('change:isFocused', (event, name, focused) => {
|
||||
if (!focused) {
|
||||
xml.innerHTML = editor.getData();
|
||||
textarea.value = serializer.serializeToString(xml).replace(' ', ' ');
|
||||
let text = serializer.serializeToString(xml);
|
||||
text = text.replace(' ', ' ');
|
||||
text = text.substring(text.indexOf('>') + 1, text.lastIndexOf('<'));
|
||||
textarea.value = text;
|
||||
}
|
||||
});
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue