Comparing version 2.2.1 to 2.2.2
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ var Manipulate = require('./ops/Manipulate') |
@@ -105,2 +105,3 @@ /** | ||
// ergo, this can be treated as an insert (this is the worst case and prolly needs fixing!) | ||
console.log('Cannot find oldParent of reparented node:', oldParent, oldParent.domOT_path) | ||
oldPath = null | ||
@@ -131,43 +132,42 @@ } | ||
// Convergence over intention preservation | ||
// e.g. <div>hello <i>world</i></div> -> <div>hello <b><i>world</i></b></div> | ||
// Since Move(nul, [0,1]) already contains <i>world</i> we remove the repanting of <i>world</i> | ||
// We could also try to extract <i>world</i> from Move(nul, [0,1]), but that'd be more complex | ||
oplist = oplist.filter(function(op1) { | ||
// Don't insert this node if its parent is already being inserted | ||
if(oplist.some(function(op2) { | ||
if(op2 === op1) return false | ||
return isPrefixOf(op2.to, op1.to) | ||
})) { | ||
if(op1.from) { | ||
op1.to = null | ||
return true | ||
oplist.sort(sortOps) | ||
// console.log(JSON.stringify(oplist, null, ' ')) | ||
// transfrom moves and manipulates against (re)moves | ||
oplist.forEach(function(op2, i) { | ||
oplist.forEach(function(op, j) { | ||
if(op === op2) return | ||
var path = (op.from || op.path) | ||
, to | ||
if(path && i<j) { | ||
to = op.to | ||
op.transformAgainst(op2) | ||
op.to = to | ||
} | ||
else return false | ||
} | ||
return true | ||
}) | ||
}) | ||
// console.log(JSON.stringify(oplist, null, ' ')) | ||
oplist.sort(sortOps) | ||
// transfrom moves and manipulates against (re)moves | ||
oplist.forEach(function(op) { | ||
if(op.from || op.path) { | ||
oplist.forEach(function(op2) { | ||
if(op === op2) return | ||
var path = (op.from || op.path) && (op.from || op.path).map(strPad.bind(null, '00000')).join('') | ||
, from2 = op2.from && op2.from.map(strPad.bind(null, '00000')).join('') | ||
, to2 = op2.to && op2.to.map(strPad.bind(null, '00000')).join('') | ||
, to | ||
if(path && from2 && path > from2 && path.length == from2.length) { | ||
to = op.to | ||
op.transformAgainst(op2) | ||
op.to = to | ||
} | ||
if(path && to2 && path > to2 && path.length == to2.length) { | ||
to = op.to | ||
op.transformAgainst(op2) | ||
op.to = to | ||
} | ||
}) | ||
// Wrapping | ||
// e.g. <div>hello <i>world</i></div> | ||
// -> <div>hello <b><i>world</i></b></div> | ||
// Since Move(nul, [0,1]) already contains <i>world</i> | ||
// we extract <i>world</i> from Move(nul, [0,1]) | ||
oplist.forEach(function(op1) { | ||
// Check if a child of this node is already being moved (i.e. this is a wrapping) | ||
var op2 | ||
oplist.some(function(op) { | ||
if(op === op1) return false | ||
if(isPrefixOf(op1.to, op.to)) { | ||
op2 = op | ||
return true | ||
} | ||
return false | ||
}) | ||
// if we've found a node being wrapped by this one | ||
// AND op1 is an insert... | ||
if(op2 && !op1.from) {// XXX: What should happen if op1 is not an insert? (prolly extremely unlikely) | ||
var vnode = JSON.parse(op1.element) | ||
vnode.children = [] | ||
op1.element = JSON.stringify(vnode) | ||
} | ||
@@ -194,4 +194,2 @@ }) | ||
return oplist | ||
@@ -198,0 +196,0 @@ } |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -55,4 +55,4 @@ /** | ||
var targetNode = nodeAt(this.path, rootNode) | ||
if(!targetNode) throw new ReferenceError('Node not found: '+this.path.join(',')) | ||
targetNode.nodeValue = changesets.apply(targetNode.nodeValue, this.diff) | ||
} |
@@ -79,5 +79,5 @@ /** | ||
if(!myNode) throw new Error('Doesn\'t fit! Trying to manipulate a non-existing node.') | ||
if(!myNode) throw new Error('Doesn\'t fit! Trying to manipulate a non-existing node: '+this.path.join(',')) | ||
myNode.setAttribute(this.prop, this.value) | ||
} |
@@ -118,2 +118,3 @@ /** | ||
var oldParent = nodeAt(this.from.slice(0, this.from.length-1), rootNode) | ||
if(!myNode) throw new ReferenceError('Node not found: '+this.from.join(',')) | ||
oldParent.removeChild(myNode) | ||
@@ -120,0 +121,0 @@ } else { |
@@ -0,0 +0,0 @@ dom-ot - operational transformation for DOM tree patches |
{ | ||
"name": "dom-ot", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "Operational transform library for DOM operations (conforms to shareJS' spec)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# dom-ot | ||
The DOM changes. You can [capture](https://github.com/marcelklehr/mutation-summary) those changes and [sync](https://github.com/marcelklehr/gulf) multiple documents in real-time using this library to transform the changes for automagic conflict resolution. Sounds awesome? It is. To learn more about operational transformation, go to [wikipedia](http://en.wikipedia.org/wiki/Operational_transformation) or check out this [guide to textual ot](http://github.com/marcelklehr/changesets#usage). | ||
The DOM changes. You can [capture](https://github.com/marcelklehr/mutation-summary) those changes and [sync](https://github.com/marcelklehr/gulf) multiple documents in real-time using this library to transform the changes for automagic conflict resolution. | ||
Sounds awesome? It is. To learn more about operational transformation, go to [wikipedia](http://en.wikipedia.org/wiki/Operational_transformation) or check out this [guide to textual ot](http://github.com/marcelklehr/changesets#usage). Also, check out [gulf-contenteditable](https://github.com/marcelklehr/gulf-contenteditable) for a ready-made wrapper. | ||
[![browser support](https://ci.testling.com/marcelklehr/dom-ot.png)](https://ci.testling.com/marcelklehr/dom-ot) | ||
@@ -5,0 +7,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
651332
17
18681
55
15
1