var NodeFragment = function(document, params) {
Fragment.call(this, document);
this.node = params.node;
+ this.nodePath = this.isValid() ? params.node.getPath() : null;
};
NodeFragment.prototype = Object.create(Fragment.prototype);
$.extend(NodeFragment.prototype, {
isValid: function() {
return this.document.containsNode(this.node);
+ },
+ restoreFromPaths: function() {
+ if(this.nodePath) {
+ this.node = this.document.getNodeByPath(this.nodePath);
+ }
}
});
var CaretFragment = function(document, params) {
- NodeFragment.call(this, document, params);
this.offset = params.offset;
+ NodeFragment.call(this, document, params);
};
CaretFragment.prototype = Object.create(NodeFragment.prototype);
this[prefix + 'Node'] = params['node'+(idx+1)];
}.bind(this));
}
+ this.startNodePath = this.startNode.getPath();
+ this.endNodePath = this.endNode.getPath();
};
RangeFragment.prototype = Object.create(Fragment.prototype);
$.extend(RangeFragment.prototype, {
isValid: function() {
return this.document.containsNode(this.startNode) && this.document.containsNode(this.endNode);
},
+ restoreFromPaths: function() {
+ this.startNode = this.document.getNodeByPath(this.startNodePath);
+ this.endNode = this.document.getNodeByPath(this.endNodePath);
+ },
hasSiblingBoundries: function() {
return this.isValid() && this.startNode.isSiblingOf(this.endNode);
},
+ hasSameBoundries: function() {
+ return this.isValid() && this.startNode.sameNode(this.endNode);
+ },
boundriesSiblingParents: function() {
return this.startNode.document.getSiblingParents({
node1: this.startNode,