Compare commits
1 Commits
v13.0.0-66
...
v13.0.0-62
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00135dcfab |
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.0.0-66",
|
"version": "13.0.0-62",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.0.0-66",
|
"version": "13.0.0-62",
|
||||||
"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",
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ export default class DomBinding extends Binding {
|
|||||||
restoreSelection (selection) {
|
restoreSelection (selection) {
|
||||||
if (selection !== null) {
|
if (selection !== null) {
|
||||||
const { to, from } = selection
|
const { to, from } = selection
|
||||||
|
let shouldUpdate = false
|
||||||
/**
|
/**
|
||||||
* There is little information on the difference between anchor/focus and base/extent.
|
* There is little information on the difference between anchor/focus and base/extent.
|
||||||
* MDN doesn't even mention base/extent anymore.. though you still have to call
|
* MDN doesn't even mention base/extent anymore.. though you still have to call
|
||||||
@@ -158,6 +159,7 @@ export default class DomBinding extends Binding {
|
|||||||
if (node !== baseNode || offset !== baseOffset) {
|
if (node !== baseNode || offset !== baseOffset) {
|
||||||
baseNode = node
|
baseNode = node
|
||||||
baseOffset = offset
|
baseOffset = offset
|
||||||
|
shouldUpdate = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,15 +171,18 @@ export default class DomBinding extends Binding {
|
|||||||
if (node !== extentNode || offset !== extentOffset) {
|
if (node !== extentNode || offset !== extentOffset) {
|
||||||
extentNode = node
|
extentNode = node
|
||||||
extentOffset = offset
|
extentOffset = offset
|
||||||
|
shouldUpdate = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
browserSelection.setBaseAndExtent(
|
if (shouldUpdate) {
|
||||||
baseNode,
|
browserSelection.setBaseAndExtent(
|
||||||
baseOffset,
|
baseNode,
|
||||||
extentNode,
|
baseOffset,
|
||||||
extentOffset
|
extentNode,
|
||||||
)
|
extentOffset
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,17 +19,17 @@ function _getCurrentRelativeSelection (domBinding) {
|
|||||||
|
|
||||||
export const getCurrentRelativeSelection = typeof getSelection !== 'undefined' ? _getCurrentRelativeSelection : () => null
|
export const getCurrentRelativeSelection = typeof getSelection !== 'undefined' ? _getCurrentRelativeSelection : () => null
|
||||||
|
|
||||||
export function beforeTransactionSelectionFixer (domBinding) {
|
export function beforeTransactionSelectionFixer (domBinding, remote) {
|
||||||
relativeSelection = getCurrentRelativeSelection(domBinding)
|
if (remote) {
|
||||||
|
relativeSelection = getCurrentRelativeSelection(domBinding)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the browser range after every transaction.
|
|
||||||
* This prevents any collapsing issues with the local selection.
|
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
export function afterTransactionSelectionFixer (domBinding) {
|
export function afterTransactionSelectionFixer (domBinding, remote) {
|
||||||
if (relativeSelection !== null) {
|
if (relativeSelection !== null && remote) {
|
||||||
domBinding.restoreSelection(relativeSelection)
|
domBinding.restoreSelection(relativeSelection)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ export default class Item {
|
|||||||
* If the parent refers to this item with some kind of key (e.g. YMap, the
|
* If the parent refers to this item with some kind of key (e.g. YMap, the
|
||||||
* key is specified here. The key is then used to refer to the list in which
|
* key is specified here. The key is then used to refer to the list in which
|
||||||
* to insert this item. If `parentSub = null` type._start is the list in
|
* to insert this item. If `parentSub = null` type._start is the list in
|
||||||
* which to insert to. Otherwise it is `parent._map`.
|
* which to insert to. Otherwise it is `parent._start`.
|
||||||
* @type {String}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
this._parentSub = null
|
this._parentSub = null
|
||||||
@@ -125,17 +125,8 @@ export default class Item {
|
|||||||
return this._redone
|
return this._redone
|
||||||
}
|
}
|
||||||
let struct = this._copy()
|
let struct = this._copy()
|
||||||
let left, right
|
let left = this._left
|
||||||
if (this._parentSub === null) {
|
let right = this
|
||||||
// Is an array item. Insert at the old position
|
|
||||||
left = this._left
|
|
||||||
right = this
|
|
||||||
} else {
|
|
||||||
// Is a map item. Insert at the start
|
|
||||||
left = null
|
|
||||||
right = this._parent._map.get(this._parentSub)
|
|
||||||
right._delete(y)
|
|
||||||
}
|
|
||||||
let parent = this._parent
|
let parent = this._parent
|
||||||
// make sure that parent is redone
|
// make sure that parent is redone
|
||||||
if (parent._deleted === true && parent._redone === null) {
|
if (parent._deleted === true && parent._redone === null) {
|
||||||
|
|||||||
46
y.node.js
46
y.node.js
@@ -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-66
|
* @version v13.0.0-62
|
||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -1644,7 +1644,7 @@ class Item {
|
|||||||
* If the parent refers to this item with some kind of key (e.g. YMap, the
|
* If the parent refers to this item with some kind of key (e.g. YMap, the
|
||||||
* key is specified here. The key is then used to refer to the list in which
|
* key is specified here. The key is then used to refer to the list in which
|
||||||
* to insert this item. If `parentSub = null` type._start is the list in
|
* to insert this item. If `parentSub = null` type._start is the list in
|
||||||
* which to insert to. Otherwise it is `parent._map`.
|
* which to insert to. Otherwise it is `parent._start`.
|
||||||
* @type {String}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
this._parentSub = null;
|
this._parentSub = null;
|
||||||
@@ -1682,17 +1682,8 @@ class Item {
|
|||||||
return this._redone
|
return this._redone
|
||||||
}
|
}
|
||||||
let struct = this._copy();
|
let struct = this._copy();
|
||||||
let left, right;
|
let left = this._left;
|
||||||
if (this._parentSub === null) {
|
let right = this;
|
||||||
// Is an array item. Insert at the old position
|
|
||||||
left = this._left;
|
|
||||||
right = this;
|
|
||||||
} else {
|
|
||||||
// Is a map item. Insert at the start
|
|
||||||
left = null;
|
|
||||||
right = this._parent._map.get(this._parentSub);
|
|
||||||
right._delete(y);
|
|
||||||
}
|
|
||||||
let parent = this._parent;
|
let parent = this._parent;
|
||||||
// make sure that parent is redone
|
// make sure that parent is redone
|
||||||
if (parent._deleted === true && parent._redone === null) {
|
if (parent._deleted === true && parent._redone === null) {
|
||||||
@@ -5217,17 +5208,17 @@ function _getCurrentRelativeSelection (domBinding) {
|
|||||||
|
|
||||||
const getCurrentRelativeSelection = typeof getSelection !== 'undefined' ? _getCurrentRelativeSelection : () => null;
|
const getCurrentRelativeSelection = typeof getSelection !== 'undefined' ? _getCurrentRelativeSelection : () => null;
|
||||||
|
|
||||||
function beforeTransactionSelectionFixer (domBinding) {
|
function beforeTransactionSelectionFixer (domBinding, remote) {
|
||||||
relativeSelection = getCurrentRelativeSelection(domBinding);
|
if (remote) {
|
||||||
|
relativeSelection = getCurrentRelativeSelection(domBinding);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the browser range after every transaction.
|
|
||||||
* This prevents any collapsing issues with the local selection.
|
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function afterTransactionSelectionFixer (domBinding) {
|
function afterTransactionSelectionFixer (domBinding, remote) {
|
||||||
if (relativeSelection !== null) {
|
if (relativeSelection !== null && remote) {
|
||||||
domBinding.restoreSelection(relativeSelection);
|
domBinding.restoreSelection(relativeSelection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5645,6 +5636,7 @@ class DomBinding extends Binding {
|
|||||||
restoreSelection (selection) {
|
restoreSelection (selection) {
|
||||||
if (selection !== null) {
|
if (selection !== null) {
|
||||||
const { to, from } = selection;
|
const { to, from } = selection;
|
||||||
|
let shouldUpdate = false;
|
||||||
/**
|
/**
|
||||||
* There is little information on the difference between anchor/focus and base/extent.
|
* There is little information on the difference between anchor/focus and base/extent.
|
||||||
* MDN doesn't even mention base/extent anymore.. though you still have to call
|
* MDN doesn't even mention base/extent anymore.. though you still have to call
|
||||||
@@ -5663,6 +5655,7 @@ class DomBinding extends Binding {
|
|||||||
if (node !== baseNode || offset !== baseOffset) {
|
if (node !== baseNode || offset !== baseOffset) {
|
||||||
baseNode = node;
|
baseNode = node;
|
||||||
baseOffset = offset;
|
baseOffset = offset;
|
||||||
|
shouldUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5674,15 +5667,18 @@ class DomBinding extends Binding {
|
|||||||
if (node !== extentNode || offset !== extentOffset) {
|
if (node !== extentNode || offset !== extentOffset) {
|
||||||
extentNode = node;
|
extentNode = node;
|
||||||
extentOffset = offset;
|
extentOffset = offset;
|
||||||
|
shouldUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
browserSelection.setBaseAndExtent(
|
if (shouldUpdate) {
|
||||||
baseNode,
|
browserSelection.setBaseAndExtent(
|
||||||
baseOffset,
|
baseNode,
|
||||||
extentNode,
|
baseOffset,
|
||||||
extentOffset
|
extentNode,
|
||||||
);
|
extentOffset
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user