Compare commits

..

7 Commits

Author SHA1 Message Date
Kevin Jahns
dc1fe7957b v13.0.0-39 -- distribution files 2017-12-05 17:06:12 -08:00
Kevin Jahns
9c471ea24d 13.0.0-39 2017-12-05 17:06:01 -08:00
Kevin Jahns
d9e76014f5 fix remaining cursor relocation issues 2017-12-05 17:05:12 -08:00
Kevin Jahns
4091b7d004 13.0.0-38 2017-12-05 00:53:25 -08:00
Kevin Jahns
dfc183643d support data-yjs-hook attribute for yjs hooks 2017-12-05 00:52:52 -08:00
Kevin Jahns
cf8698f2b6 13.0.0-37 2017-12-02 01:45:55 -08:00
Kevin Jahns
3595f14da7 fix insert in y-text 2017-12-02 01:45:22 -08:00
9 changed files with 29 additions and 25 deletions

2
package-lock.json generated
View File

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

View File

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

View File

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

View File

@@ -17,7 +17,7 @@ function domToYXml (parent, doms, _document) {
} }
if (parent._domFilter(d.nodeName, new Map()) !== null) { if (parent._domFilter(d.nodeName, new Map()) !== null) {
let type let type
const hookName = d._yjsHook const hookName = d._yjsHook || (d.dataset != null ? d.dataset.yjsHook : undefined)
if (hookName !== undefined) { if (hookName !== undefined) {
type = new YXmlHook(hookName, d) type = new YXmlHook(hookName, d)
} else if (d.nodeType === d.TEXT_NODE) { } else if (d.nodeType === d.TEXT_NODE) {
@@ -254,7 +254,9 @@ export default class YXmlFragment extends YArray {
}) })
// Apply Y.Xml events to dom // Apply Y.Xml events to dom
this.observeDeep(events => { this.observeDeep(events => {
reflectChangesOnDom.call(this, events, _document) this._mutualExclude(() => {
reflectChangesOnDom.call(this, events, _document)
})
}) })
// Apply Dom changes on Y.Xml // Apply Dom changes on Y.Xml
if (typeof MutationObserver !== 'undefined') { if (typeof MutationObserver !== 'undefined') {

View File

@@ -76,7 +76,4 @@ export function afterTransactionSelectionFixer (y, transaction, remote) {
focusOffset focusOffset
) )
} }
// delete, so the objects can be gc'd
relativeSelection = null
browserSelection = null
} }

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 * yjs - A framework for real-time p2p shared editing on any data
* @version v13.0.0-36 * @version v13.0.0-39
* @license MIT * @license MIT
*/ */
@@ -2556,14 +2556,17 @@ class YText extends YArray {
let right = this._start; let right = this._start;
let count = 0; let count = 0;
while (right !== null) { while (right !== null) {
if (count <= pos && pos < count + right._length) { const rightLen = right._deleted ? 0 : (right._length - 1);
if (count <= pos && pos <= count + rightLen) {
const splitDiff = pos - count; const splitDiff = pos - count;
right = right._splitAt(this._y, pos - count); right = right._splitAt(this._y, splitDiff);
left = right._left; left = right._left;
count += splitDiff; count += splitDiff;
break break
} }
count += right._length; if (!right._deleted) {
count += right._length;
}
left = right; left = right;
right = right._right; right = right._right;
} }
@@ -2944,9 +2947,6 @@ function afterTransactionSelectionFixer (y, transaction, remote) {
focusOffset focusOffset
); );
} }
// delete, so the objects can be gc'd
relativeSelection = null;
browserSelection = null;
} }
class YXmlEvent extends YEvent { class YXmlEvent extends YEvent {
@@ -3714,7 +3714,7 @@ function domToYXml (parent, doms, _document) {
} }
if (parent._domFilter(d.nodeName, new Map()) !== null) { if (parent._domFilter(d.nodeName, new Map()) !== null) {
let type; let type;
const hookName = d._yjsHook; const hookName = d._yjsHook || (d.dataset != null ? d.dataset.yjsHook : undefined);
if (hookName !== undefined) { if (hookName !== undefined) {
type = new YXmlHook(hookName, d); type = new YXmlHook(hookName, d);
} else if (d.nodeType === d.TEXT_NODE) { } else if (d.nodeType === d.TEXT_NODE) {
@@ -3951,7 +3951,9 @@ class YXmlFragment extends YArray {
}); });
// Apply Y.Xml events to dom // Apply Y.Xml events to dom
this.observeDeep(events => { this.observeDeep(events => {
reflectChangesOnDom.call(this, events, _document); this._mutualExclude(() => {
reflectChangesOnDom.call(this, events, _document);
});
}); });
// Apply Dom changes on Y.Xml // Apply Dom changes on Y.Xml
if (typeof MutationObserver !== 'undefined') { if (typeof MutationObserver !== 'undefined') {

File diff suppressed because one or more lines are too long