Compare commits

...

3 Commits

Author SHA1 Message Date
Kevin Jahns
4f670a3b5e v13.0.0-40 -- distribution files 2017-12-05 21:50:47 -08:00
Kevin Jahns
4efa16e2dd 13.0.0-40 2017-12-05 21:50:34 -08:00
Kevin Jahns
ad44f59def implement new dom update algorithm 2017-12-05 21:50:00 -08:00
11 changed files with 25255 additions and 16 deletions

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "yjs",
"version": "13.0.0-39",
"version": "13.0.0-40",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "yjs",
"version": "13.0.0-39",
"version": "13.0.0-40",
"description": "A framework for real-time p2p shared editing on any data",
"main": "./y.node.js",
"browser": "./y.js",

View File

@@ -254,9 +254,7 @@ export default class YXmlFragment extends YArray {
})
// Apply Y.Xml events to dom
this.observeDeep(events => {
this._mutualExclude(() => {
reflectChangesOnDom.call(this, events, _document)
})
reflectChangesOnDom.call(this, events, _document)
})
// Apply Dom changes on Y.Xml
if (typeof MutationObserver !== 'undefined') {

View File

@@ -68,7 +68,6 @@ export function afterTransactionSelectionFixer (y, transaction, remote) {
}
}
if (shouldUpdate) {
console.info('updating selection!!')
browserSelection.setBaseAndExtent(
anchorNode,
anchorOffset,

View File

@@ -193,19 +193,27 @@ export function reflectChangesOnDom (events, _document) {
* only in the attributes (above)
*/
if (event.childListChanged && yxml.constructor !== YXmlHook) {
// create fragment of undeleted nodes
const fragment = _document.createDocumentFragment()
let currentChild = dom.firstChild
yxml.forEach(function (t) {
fragment.appendChild(t.getDom(_document))
let expectedChild = t.getDom(_document)
if (expectedChild.parentNode === dom) {
// is already attached to the dom. Look for it
while (currentChild !== expectedChild) {
let del = currentChild
currentChild = currentChild.nextSibling
dom.removeChild(del)
}
currentChild = currentChild.nextSibling
} else {
// this dom is not yet attached to dom
dom.insertBefore(expectedChild, currentChild)
}
})
// remove remainding nodes
let lastChild = dom.lastChild
while (lastChild !== null) {
dom.removeChild(lastChild)
lastChild = dom.lastChild
while (currentChild !== null) {
let tmp = currentChild.nextSibling
dom.removeChild(currentChild)
currentChild = tmp
}
// insert fragment of undeleted nodes
dom.appendChild(fragment)
}
}
/* TODO: smartscrolling

9
y.js Normal file

File diff suppressed because one or more lines are too long

1
y.js.map Normal file

File diff suppressed because one or more lines are too long

5717
y.node.js Normal file

File diff suppressed because it is too large Load Diff

1
y.node.js.map Normal file

File diff suppressed because one or more lines are too long

19505
y.test.js Normal file

File diff suppressed because one or more lines are too long

1
y.test.js.map Normal file

File diff suppressed because one or more lines are too long