X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/e10030e66aab8b55dab8b8ba507a9140243129fa..7263e5132059abc0e93deac2175db475f90e7617:/src/wlxml/wlxml.js?ds=inline diff --git a/src/wlxml/wlxml.js b/src/wlxml/wlxml.js index ef70d3d..989fe5d 100644 --- a/src/wlxml/wlxml.js +++ b/src/wlxml/wlxml.js @@ -238,6 +238,14 @@ $.extend(WLXMLDocument.prototype, { metadataNode.remove(); }); nativeNode.normalize(); + $(nativeNode).find('*').each(function() { + var emptyNode = this.childNodes.length === 0; + var endsWithSpan = !emptyNode && this.childNodes[this.childNodes.length - 1].nodeName.toLowerCase() === 'span'; + if(emptyNode || endsWithSpan) { + var fakeTextNode = window.document.createTextNode(""); + this.appendChild(fakeTextNode); + } + }); $(nativeNode).find(':not(iframe)').addBack().contents() .filter(function() {return this.nodeType === Node.TEXT_NODE;}) @@ -288,7 +296,7 @@ $.extend(WLXMLDocument.prototype, { } } - if(!text.transformed) { + if(!text.transformed && !(el.is(':only-child') || (el.is(':last-child') && hasSpanBefore))) { addInfo(text.original, 'below'); el.remove(); return true; // continue