Compare commits
1 Commits
v13.0.0-66
...
v13.0.0-63
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86dc602a8d |
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yjs",
|
||||
"version": "13.0.0-66",
|
||||
"version": "13.0.0-63",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yjs",
|
||||
"version": "13.0.0-66",
|
||||
"version": "13.0.0-63",
|
||||
"description": "A framework for real-time p2p shared editing on any data",
|
||||
"main": "./y.node.js",
|
||||
"browser": "./y.js",
|
||||
|
||||
@@ -140,6 +140,7 @@ export default class DomBinding extends Binding {
|
||||
restoreSelection (selection) {
|
||||
if (selection !== null) {
|
||||
const { to, from } = selection
|
||||
let shouldUpdate = false
|
||||
/**
|
||||
* 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
|
||||
@@ -158,6 +159,7 @@ export default class DomBinding extends Binding {
|
||||
if (node !== baseNode || offset !== baseOffset) {
|
||||
baseNode = node
|
||||
baseOffset = offset
|
||||
shouldUpdate = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,15 +171,18 @@ export default class DomBinding extends Binding {
|
||||
if (node !== extentNode || offset !== extentOffset) {
|
||||
extentNode = node
|
||||
extentOffset = offset
|
||||
shouldUpdate = true
|
||||
}
|
||||
}
|
||||
}
|
||||
browserSelection.setBaseAndExtent(
|
||||
baseNode,
|
||||
baseOffset,
|
||||
extentNode,
|
||||
extentOffset
|
||||
)
|
||||
if (shouldUpdate) {
|
||||
browserSelection.setBaseAndExtent(
|
||||
baseNode,
|
||||
baseOffset,
|
||||
extentNode,
|
||||
extentOffset
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,17 +19,17 @@ function _getCurrentRelativeSelection (domBinding) {
|
||||
|
||||
export const getCurrentRelativeSelection = typeof getSelection !== 'undefined' ? _getCurrentRelativeSelection : () => null
|
||||
|
||||
export function beforeTransactionSelectionFixer (domBinding) {
|
||||
relativeSelection = getCurrentRelativeSelection(domBinding)
|
||||
export function beforeTransactionSelectionFixer (domBinding, remote) {
|
||||
if (remote) {
|
||||
relativeSelection = getCurrentRelativeSelection(domBinding)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the browser range after every transaction.
|
||||
* This prevents any collapsing issues with the local selection.
|
||||
* @private
|
||||
*/
|
||||
export function afterTransactionSelectionFixer (domBinding) {
|
||||
if (relativeSelection !== null) {
|
||||
export function afterTransactionSelectionFixer (domBinding, remote) {
|
||||
if (relativeSelection !== null && remote) {
|
||||
domBinding.restoreSelection(relativeSelection)
|
||||
}
|
||||
}
|
||||
|
||||
31
y.node.js
31
y.node.js
@@ -1,7 +1,7 @@
|
||||
|
||||
/**
|
||||
* yjs - A framework for real-time p2p shared editing on any data
|
||||
* @version v13.0.0-66
|
||||
* @version v13.0.0-63
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
@@ -5217,17 +5217,17 @@ function _getCurrentRelativeSelection (domBinding) {
|
||||
|
||||
const getCurrentRelativeSelection = typeof getSelection !== 'undefined' ? _getCurrentRelativeSelection : () => null;
|
||||
|
||||
function beforeTransactionSelectionFixer (domBinding) {
|
||||
relativeSelection = getCurrentRelativeSelection(domBinding);
|
||||
function beforeTransactionSelectionFixer (domBinding, remote) {
|
||||
if (remote) {
|
||||
relativeSelection = getCurrentRelativeSelection(domBinding);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the browser range after every transaction.
|
||||
* This prevents any collapsing issues with the local selection.
|
||||
* @private
|
||||
*/
|
||||
function afterTransactionSelectionFixer (domBinding) {
|
||||
if (relativeSelection !== null) {
|
||||
function afterTransactionSelectionFixer (domBinding, remote) {
|
||||
if (relativeSelection !== null && remote) {
|
||||
domBinding.restoreSelection(relativeSelection);
|
||||
}
|
||||
}
|
||||
@@ -5645,6 +5645,7 @@ class DomBinding extends Binding {
|
||||
restoreSelection (selection) {
|
||||
if (selection !== null) {
|
||||
const { to, from } = selection;
|
||||
let shouldUpdate = false;
|
||||
/**
|
||||
* 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
|
||||
@@ -5663,6 +5664,7 @@ class DomBinding extends Binding {
|
||||
if (node !== baseNode || offset !== baseOffset) {
|
||||
baseNode = node;
|
||||
baseOffset = offset;
|
||||
shouldUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5674,15 +5676,18 @@ class DomBinding extends Binding {
|
||||
if (node !== extentNode || offset !== extentOffset) {
|
||||
extentNode = node;
|
||||
extentOffset = offset;
|
||||
shouldUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
browserSelection.setBaseAndExtent(
|
||||
baseNode,
|
||||
baseOffset,
|
||||
extentNode,
|
||||
extentOffset
|
||||
);
|
||||
if (shouldUpdate) {
|
||||
browserSelection.setBaseAndExtent(
|
||||
baseNode,
|
||||
baseOffset,
|
||||
extentNode,
|
||||
extentOffset
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user