fnp
/
fnpeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
small fix for lists
[fnpeditor.git]
/
src
/
smartxml
/
fragments.js
diff --git
a/src/smartxml/fragments.js
b/src/smartxml/fragments.js
index
9bb92cc
..
f15a9e8
100644
(file)
--- a/
src/smartxml/fragments.js
+++ b/
src/smartxml/fragments.js
@@
-19,18
+19,24
@@
$.extend(Fragment.prototype, {
var NodeFragment = function(document, params) {
Fragment.call(this, document);
this.node = params.node;
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);
};
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) {
}
});
var CaretFragment = function(document, params) {
- NodeFragment.call(this, document, params);
this.offset = params.offset;
this.offset = params.offset;
+ NodeFragment.call(this, document, params);
};
CaretFragment.prototype = Object.create(NodeFragment.prototype);
};
CaretFragment.prototype = Object.create(NodeFragment.prototype);
@@
-58,23
+64,32
@@
var RangeFragment = function(document, params) {
this[prefix + 'Node'] = params['node'+(idx+1)];
}.bind(this));
}
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);
},
};
RangeFragment.prototype = Object.create(Fragment.prototype);
$.extend(RangeFragment.prototype, {
isValid: function() {
return this.document.containsNode(this.startNode) && this.document.containsNode(this.endNode);
},
- hasSiblingBoundries: function() {
+ restoreFromPaths: function() {
+ this.startNode = this.document.getNodeByPath(this.startNodePath);
+ this.endNode = this.document.getNodeByPath(this.endNodePath);
+ },
+ hasSiblingBoundaries: function() {
return this.isValid() && this.startNode.isSiblingOf(this.endNode);
},
return this.isValid() && this.startNode.isSiblingOf(this.endNode);
},
- boundriesSiblingParents: function() {
+ hasSameBoundaries: function() {
+ return this.isValid() && this.startNode.sameNode(this.endNode);
+ },
+ boundariesSiblingParents: function() {
return this.startNode.document.getSiblingParents({
node1: this.startNode,
node2: this.endNode
});
},
getCommonParent: function() {
return this.startNode.document.getSiblingParents({
node1: this.startNode,
node2: this.endNode
});
},
getCommonParent: function() {
- var siblingParents = this.boundriesSiblingParents();
+ var siblingParents = this.bound
a
riesSiblingParents();
if(siblingParents) {
return siblingParents.node1.parent();
}
if(siblingParents) {
return siblingParents.node1.parent();
}