parent.contents().some(function(n) {
return move(n, newNode);
});
+ // span can't be the last node
+ newNode.append({'text': ''});
if(newNodes.second.contents()[0].getText().length === 0) {
var textNode = newNodes.second.contents()[0];
newNodes.second.detach();
offsetEnd: params.fragment.endOffset,
textNodeIdx: [params.fragment.startNode.getIndex(), params.fragment.endNode.getIndex()]
});
+ if(wrapper.next() === null) {
+ // span can't be the last node
+ parent.append({text: ''});
+ }
lastTextNode = wrapper.getLastTextNode();
if(lastTextNode) {
});
nativeNode.normalize();
$(nativeNode).find('*').each(function() {
- if (this.childNodes.length === 0) {
+ 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);
}
}
}
- if(!text.transformed && !onlyChild) {
+ if(!text.transformed && !(el.is(':only-child') || (el.is(':last-child') && hasSpanBefore))) {
addInfo(text.original, 'below');
el.remove();
return true; // continue