Compare commits
1 Commits
v13.0.0-40
...
v13.0.0-39
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc1fe7957b |
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yjs",
|
||||
"version": "13.0.0-40",
|
||||
"version": "13.0.0-39",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yjs",
|
||||
"version": "13.0.0-40",
|
||||
"version": "13.0.0-39",
|
||||
"description": "A framework for real-time p2p shared editing on any data",
|
||||
"main": "./y.node.js",
|
||||
"browser": "./y.js",
|
||||
|
||||
@@ -254,7 +254,9 @@ export default class YXmlFragment extends YArray {
|
||||
})
|
||||
// Apply Y.Xml events to dom
|
||||
this.observeDeep(events => {
|
||||
reflectChangesOnDom.call(this, events, _document)
|
||||
this._mutualExclude(() => {
|
||||
reflectChangesOnDom.call(this, events, _document)
|
||||
})
|
||||
})
|
||||
// Apply Dom changes on Y.Xml
|
||||
if (typeof MutationObserver !== 'undefined') {
|
||||
|
||||
@@ -68,6 +68,7 @@ export function afterTransactionSelectionFixer (y, transaction, remote) {
|
||||
}
|
||||
}
|
||||
if (shouldUpdate) {
|
||||
console.info('updating selection!!')
|
||||
browserSelection.setBaseAndExtent(
|
||||
anchorNode,
|
||||
anchorOffset,
|
||||
|
||||
@@ -193,27 +193,19 @@ export function reflectChangesOnDom (events, _document) {
|
||||
* only in the attributes (above)
|
||||
*/
|
||||
if (event.childListChanged && yxml.constructor !== YXmlHook) {
|
||||
let currentChild = dom.firstChild
|
||||
// create fragment of undeleted nodes
|
||||
const fragment = _document.createDocumentFragment()
|
||||
yxml.forEach(function (t) {
|
||||
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)
|
||||
}
|
||||
fragment.appendChild(t.getDom(_document))
|
||||
})
|
||||
while (currentChild !== null) {
|
||||
let tmp = currentChild.nextSibling
|
||||
dom.removeChild(currentChild)
|
||||
currentChild = tmp
|
||||
// remove remainding nodes
|
||||
let lastChild = dom.lastChild
|
||||
while (lastChild !== null) {
|
||||
dom.removeChild(lastChild)
|
||||
lastChild = dom.lastChild
|
||||
}
|
||||
// insert fragment of undeleted nodes
|
||||
dom.appendChild(fragment)
|
||||
}
|
||||
}
|
||||
/* TODO: smartscrolling
|
||||
|
||||
35
y.node.js
35
y.node.js
@@ -1,7 +1,7 @@
|
||||
|
||||
/**
|
||||
* yjs - A framework for real-time p2p shared editing on any data
|
||||
* @version v13.0.0-40
|
||||
* @version v13.0.0-39
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
@@ -2745,27 +2745,19 @@ function reflectChangesOnDom (events, _document) {
|
||||
* only in the attributes (above)
|
||||
*/
|
||||
if (event.childListChanged && yxml.constructor !== YXmlHook) {
|
||||
let currentChild = dom.firstChild;
|
||||
// create fragment of undeleted nodes
|
||||
const fragment = _document.createDocumentFragment();
|
||||
yxml.forEach(function (t) {
|
||||
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);
|
||||
}
|
||||
fragment.appendChild(t.getDom(_document));
|
||||
});
|
||||
while (currentChild !== null) {
|
||||
let tmp = currentChild.nextSibling;
|
||||
dom.removeChild(currentChild);
|
||||
currentChild = tmp;
|
||||
// remove remainding nodes
|
||||
let lastChild = dom.lastChild;
|
||||
while (lastChild !== null) {
|
||||
dom.removeChild(lastChild);
|
||||
lastChild = dom.lastChild;
|
||||
}
|
||||
// insert fragment of undeleted nodes
|
||||
dom.appendChild(fragment);
|
||||
}
|
||||
}
|
||||
/* TODO: smartscrolling
|
||||
@@ -2947,6 +2939,7 @@ function afterTransactionSelectionFixer (y, transaction, remote) {
|
||||
}
|
||||
}
|
||||
if (shouldUpdate) {
|
||||
console.info('updating selection!!');
|
||||
browserSelection.setBaseAndExtent(
|
||||
anchorNode,
|
||||
anchorOffset,
|
||||
@@ -3958,7 +3951,9 @@ class YXmlFragment extends YArray {
|
||||
});
|
||||
// Apply Y.Xml events to dom
|
||||
this.observeDeep(events => {
|
||||
reflectChangesOnDom.call(this, events, _document);
|
||||
this._mutualExclude(() => {
|
||||
reflectChangesOnDom.call(this, events, _document);
|
||||
});
|
||||
});
|
||||
// Apply Dom changes on Y.Xml
|
||||
if (typeof MutationObserver !== 'undefined') {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user