return;
this.canvas = canvas;
this.$element = $(htmlElement);
-
- this.wlxmlTag = this.$element.attr('wlxml-tag');
}
$.extend(DocumentElement.prototype, {
return documentElementFromHTMLElement(dom[0]);
},
wrapWithNodeElement: function(wlxmlNode) {
- if(wlxmlNode.start && wlxmlNode.end) {
+ if(typeof wlxmlNode.start === 'number' && typeof wlxmlNode.end === 'number') {
return this.canvas.wrapText({
inside: this.parent(),
textNodeIdx: this.parent().childIndex(this),
- offsetStart: wlxmlNode.start,
- offsetEnd: wlxmlNode.end,
+ offsetStart: Math.min(wlxmlNode.start, wlxmlNode.end),
+ offsetEnd: Math.max(wlxmlNode.start, wlxmlNode.end),
_with: {tag: wlxmlNode.tag, klass: wlxmlNode.klass}
});
} else {
if(prefix.length > 0)
this.setText(prefix);
else
- this.remove();
+ this.detach();
- var newElement = DocumentNodeElement.create({tag: parentElement.wlxmlTag, klass: parentElement.wlxmlClass}, myCanvas);
+ var newElement = DocumentNodeElement.create({tag: parentElement.getWlxmlTag(), klass: parentElement.getWlxmlClass()}, myCanvas);
parentElement.after(newElement);
if(suffix.length > 0)