X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/2687ec6cbbe8101a4faa232c79f5c1321dcebe6d..6003b8824fdcba0d59db6681282c7d2d7f2bae1c:/src/smartxml/fragments.js diff --git a/src/smartxml/fragments.js b/src/smartxml/fragments.js index 9bb92cc..62a7a4c 100644 --- a/src/smartxml/fragments.js +++ b/src/smartxml/fragments.js @@ -19,11 +19,15 @@ $.extend(Fragment.prototype, { var NodeFragment = function(document, params) { Fragment.call(this, document); this.node = params.node; + this.nodePath = params.node.getPath(); }; NodeFragment.prototype = Object.create(Fragment.prototype); $.extend(NodeFragment.prototype, { isValid: function() { return this.document.containsNode(this.node); + }, + restoreFromPaths: function() { + this.node = this.document.getNodeByPath(this.nodePath); } }); @@ -58,12 +62,18 @@ var RangeFragment = function(document, params) { 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); },