<div link-box style="white-space: nowrap">
<a link target="blank" href="<%= url %>"><%= text %></a> <br/>--
<span>
- <a class="change" href="#"><%= gettext('change') %></a> <!-- |
- <a class="delete" href="#"><%= gettext('remove') %></a> -->
+ <a class="change" href="#"><%= gettext('change') %></a>
+ <a class="delete" href="#"><%= gettext('remove') %></a>
</span>
</div>
doc = this.wlxmlNode.document;
el.wlxmlNode.document.transaction(function() {
- var f = el.canvas.getSelection().toDocumentFragment(),
- prefLen = 0,
- ret;
-
- if(el.wlxmlNode.isPrecededByTextNode()) {
- prefLen = el.wlxmlNode.prev().getText().length;
- }
-
- ret = el.wlxmlNode.unwrapContent();
- return doc.createFragment(doc.CaretFragment, {node: ret.element1, offset: prefLen + f.offset});
+ //var f = el.canvas.getSelection().toDocumentFragment(),
+ // prefLen = 0,
+ // ret;
+ //
+ //if(el.wlxmlNode.isPrecededByTextNode()) {
+ // prefLen = el.wlxmlNode.prev().getText().length;
+ //}
+ //
+ //ret = el.wlxmlNode.unwrapContent();
+ //return doc.createFragment(doc.CaretFragment, {node: ret.element1, offset: prefLen + f.offset});
+ el.wlxmlNode.detach();
}, {
metadata: {
- description: gettext('Remove link'),
- fragment: doc.createFragment(doc.CaretFragment, {node: el.wlxmlNode.contents()[0], offset:0})
- },
- success: function(ret) {
- el.canvas.select(ret);
+ description: gettext('Remove link')
}
});
},
metadataNode.remove();
});
nativeNode.normalize();
+ $(nativeNode).find('*').each(function() {
+ if (this.childNodes.length === 0) {
+ var fakeTextNode = window.document.createTextNode("");
+ this.appendChild(fakeTextNode);
+ }
+ });
$(nativeNode).find(':not(iframe)').addBack().contents()
.filter(function() {return this.nodeType === Node.TEXT_NODE;})
elParent = el.parent(),
hasSpanParent = elParent.prop('tagName') === 'SPAN',
hasSpanBefore = el.prev().length && $(el.prev()).prop('tagName') === 'SPAN',
- hasSpanAfter = el.next().length && $(el.next()).prop('tagName') === 'SPAN';
+ hasSpanAfter = el.next().length && $(el.next()).prop('tagName') === 'SPAN',
+ onlyChild = el.is(':only-child');
var addInfo = function(toAdd, where, transformed, original) {
}
}
- if(!text.transformed) {
+ if(!text.transformed && !onlyChild) {
addInfo(text.original, 'below');
el.remove();
return true; // continue