Compare commits

..

1 Commits

Author SHA1 Message Date
Kevin Jahns
6b38a474aa v13.0.0-36 -- distribution files 2017-11-30 18:39:27 -08:00
10 changed files with 45 additions and 59 deletions

2
package-lock.json generated
View File

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

View File

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

View File

@@ -29,17 +29,14 @@ export default class YText extends YArray {
let right = this._start
let count = 0
while (right !== null) {
const rightLen = right._deleted ? 0 : (right._length - 1)
if (count <= pos && pos <= count + rightLen) {
if (count <= pos && pos < count + right._length) {
const splitDiff = pos - count
right = right._splitAt(this._y, splitDiff)
right = right._splitAt(this._y, pos - count)
left = right._left
count += splitDiff
break
}
if (!right._deleted) {
count += right._length
}
count += right._length
left = right
right = right._right
}

View File

@@ -17,7 +17,7 @@ function domToYXml (parent, doms, _document) {
}
if (parent._domFilter(d.nodeName, new Map()) !== null) {
let type
const hookName = d._yjsHook || (d.dataset != null ? d.dataset.yjsHook : undefined)
const hookName = d._yjsHook
if (hookName !== undefined) {
type = new YXmlHook(hookName, d)
} else if (d.nodeType === d.TEXT_NODE) {

View File

@@ -68,6 +68,7 @@ export function afterTransactionSelectionFixer (y, transaction, remote) {
}
}
if (shouldUpdate) {
console.info('updating selection!!')
browserSelection.setBaseAndExtent(
anchorNode,
anchorOffset,
@@ -75,4 +76,7 @@ export function afterTransactionSelectionFixer (y, transaction, remote) {
focusOffset
)
}
// delete, so the objects can be gc'd
relativeSelection = null
browserSelection = null
}

View File

@@ -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

8
y.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -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-36
* @license MIT
*/
@@ -2556,17 +2556,14 @@ class YText extends YArray {
let right = this._start;
let count = 0;
while (right !== null) {
const rightLen = right._deleted ? 0 : (right._length - 1);
if (count <= pos && pos <= count + rightLen) {
if (count <= pos && pos < count + right._length) {
const splitDiff = pos - count;
right = right._splitAt(this._y, splitDiff);
right = right._splitAt(this._y, pos - count);
left = right._left;
count += splitDiff;
break
}
if (!right._deleted) {
count += right._length;
}
count += right._length;
left = right;
right = right._right;
}
@@ -2745,27 +2742,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 +2936,7 @@ function afterTransactionSelectionFixer (y, transaction, remote) {
}
}
if (shouldUpdate) {
console.info('updating selection!!');
browserSelection.setBaseAndExtent(
anchorNode,
anchorOffset,
@@ -2954,6 +2944,9 @@ function afterTransactionSelectionFixer (y, transaction, remote) {
focusOffset
);
}
// delete, so the objects can be gc'd
relativeSelection = null;
browserSelection = null;
}
class YXmlEvent extends YEvent {
@@ -3721,7 +3714,7 @@ function domToYXml (parent, doms, _document) {
}
if (parent._domFilter(d.nodeName, new Map()) !== null) {
let type;
const hookName = d._yjsHook || (d.dataset != null ? d.dataset.yjsHook : undefined);
const hookName = d._yjsHook;
if (hookName !== undefined) {
type = new YXmlHook(hookName, d);
} else if (d.nodeType === d.TEXT_NODE) {

File diff suppressed because one or more lines are too long