return wrapper;
},
- detach: function() {
- this.dom().detach();
- this.canvas = null;
- },
-
markAsCurrent: function() {
this.canvas.markAsCurrent(this);
},
_container: function() {
return this.dom().children('[document-element-content]');
},
+ detach: function() {
+ var parent = this.parent();
+ if(!parent)
+ return;
+
+ var parentChildren = parent.children(),
+ myIdx = parent.childIndex(this);
+
+ if(myIdx > 0 && myIdx < parentChildren.length) {
+ if((parentChildren[myIdx-1] instanceof DocumentTextElement) && (parentChildren[myIdx+1] instanceof DocumentTextElement)) {
+ parentChildren[myIdx-1].appendText(parentChildren[myIdx+1].getText());
+ parentChildren[myIdx+1].detach();
+ }
+ }
+ this.dom().detach();
+ this.canvas = null;
+ return this;
+ },
data: function() {
var dom = this.dom(),
args = Array.prototype.slice.call(arguments, 0);
this.toggleHighlight(toggle);
},
- toggleHighlight: function(toogle) {
- this._container().toggleClass('highlighted-element');
+ toggleHighlight: function(toggle) {
+ this._container().toggleClass('highlighted-element', toggle);
},
toggle: function(toggle) {
else
this.$element = $element;
},
+ detach: function() {
+ this.dom().detach();
+ this.canvas = null;
+ return this;
+ },
setText: function(text) {
this.dom().contents()[0].data = text;
},
+ appendText: function(text) {
+ this.dom().contents()[0].data += text;
+ },
getText: function() {
return this.dom().text().replace(utils.unicode.ZWS, '');
},
idx = grandParent.childIndex(parent),
prev = idx - 1 > -1 ? grandParentChildren[idx-1] : null,
next = idx + 1 < grandParentChildren.length ? grandParentChildren[idx+1] : null;
+
+ prev = (prev instanceof DocumentTextElement) ? prev : null;
+ next = (next instanceof DocumentTextElement) ? next : null;
+
if(prev && next) {
prev.setText(prev.getText() + this.getText() + next.getText());
next.detach();