Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a61c90261 | ||
|
|
6fa8778fc7 | ||
|
|
1bc9308566 | ||
|
|
a5e0448a92 | ||
|
|
8937494bdd |
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.5.39",
|
"version": "13.5.40",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.5.39",
|
"version": "13.5.40",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lib0": "^0.2.49"
|
"lib0": "^0.2.49"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.5.39",
|
"version": "13.5.40",
|
||||||
"description": "Shared Editing Library",
|
"description": "Shared Editing Library",
|
||||||
"main": "./dist/yjs.cjs",
|
"main": "./dist/yjs.cjs",
|
||||||
"module": "./dist/yjs.mjs",
|
"module": "./dist/yjs.mjs",
|
||||||
|
|||||||
14
src/index.js
14
src/index.js
@@ -93,10 +93,12 @@ export {
|
|||||||
UpdateEncoderV1
|
UpdateEncoderV1
|
||||||
} from './internals.js'
|
} from './internals.js'
|
||||||
|
|
||||||
const glo = /** @type {any} */ (typeof window !== 'undefined'
|
const glo = /** @type {any} */ (typeof globalThis !== 'undefined'
|
||||||
? window
|
? globalThis
|
||||||
// @ts-ignore
|
: typeof window !== 'undefined'
|
||||||
: typeof global !== 'undefined' ? global : {})
|
? window
|
||||||
|
// @ts-ignore
|
||||||
|
: typeof global !== 'undefined' ? global : {})
|
||||||
|
|
||||||
const importIdentifier = '__ $YJS$ __'
|
const importIdentifier = '__ $YJS$ __'
|
||||||
|
|
||||||
@@ -112,7 +114,9 @@ if (glo[importIdentifier] === true) {
|
|||||||
* This often leads to issues that are hard to debug. We often need to perform constructor checks,
|
* This often leads to issues that are hard to debug. We often need to perform constructor checks,
|
||||||
* e.g. `struct instanceof GC`. If you imported different versions of Yjs, it is impossible for us to
|
* e.g. `struct instanceof GC`. If you imported different versions of Yjs, it is impossible for us to
|
||||||
* do the constructor checks anymore - which might break the CRDT algorithm.
|
* do the constructor checks anymore - which might break the CRDT algorithm.
|
||||||
|
*
|
||||||
|
* https://github.com/yjs/yjs/issues/438
|
||||||
*/
|
*/
|
||||||
console.error('Yjs was already imported. This breaks constructor checks and will lead to isssues!')
|
console.error('Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438')
|
||||||
}
|
}
|
||||||
glo[importIdentifier] = true
|
glo[importIdentifier] = true
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ const popStackItem = (undoManager, stack, eventType) => {
|
|||||||
* undo/redo scope.
|
* undo/redo scope.
|
||||||
* @property {Set<any>} [UndoManagerOptions.trackedOrigins=new Set([null])]
|
* @property {Set<any>} [UndoManagerOptions.trackedOrigins=new Set([null])]
|
||||||
* @property {boolean} [ignoreRemoteMapChanges] Experimental. By default, the UndoManager will never overwrite remote changes. Enable this property to enable overwriting remote changes on key-value changes (Y.Map, properties on Y.Xml, etc..).
|
* @property {boolean} [ignoreRemoteMapChanges] Experimental. By default, the UndoManager will never overwrite remote changes. Enable this property to enable overwriting remote changes on key-value changes (Y.Map, properties on Y.Xml, etc..).
|
||||||
|
* @property {Doc} [doc] The document that this UndoManager operates on. Only needed if typeScope is empty.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,7 +161,8 @@ export class UndoManager extends Observable {
|
|||||||
captureTransaction = tr => true,
|
captureTransaction = tr => true,
|
||||||
deleteFilter = () => true,
|
deleteFilter = () => true,
|
||||||
trackedOrigins = new Set([null]),
|
trackedOrigins = new Set([null]),
|
||||||
ignoreRemoteMapChanges = false
|
ignoreRemoteMapChanges = false,
|
||||||
|
doc = /** @type {Doc} */ (array.isArray(typeScope) ? typeScope[0].doc : typeScope.doc)
|
||||||
} = {}) {
|
} = {}) {
|
||||||
super()
|
super()
|
||||||
/**
|
/**
|
||||||
@@ -187,7 +189,7 @@ export class UndoManager extends Observable {
|
|||||||
*/
|
*/
|
||||||
this.undoing = false
|
this.undoing = false
|
||||||
this.redoing = false
|
this.redoing = false
|
||||||
this.doc = /** @type {Doc} */ (this.scope[0].doc)
|
this.doc = doc
|
||||||
this.lastChange = 0
|
this.lastChange = 0
|
||||||
this.ignoreRemoteMapChanges = ignoreRemoteMapChanges
|
this.ignoreRemoteMapChanges = ignoreRemoteMapChanges
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -49,6 +49,20 @@ export const testUndoText = tc => {
|
|||||||
t.compare(text0.toDelta(), [{ insert: 'b' }, { insert: 'cxy', attributes: { bold: true } }, { insert: 'z' }])
|
t.compare(text0.toDelta(), [{ insert: 'b' }, { insert: 'cxy', attributes: { bold: true } }, { insert: 'z' }])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test case to fix #241
|
||||||
|
* @param {t.TestCase} tc
|
||||||
|
*/
|
||||||
|
export const testEmptyTypeScope = tc => {
|
||||||
|
const ydoc = new Y.Doc()
|
||||||
|
const um = new Y.UndoManager([], { doc: ydoc })
|
||||||
|
const yarray = ydoc.getArray()
|
||||||
|
um.addToScope(yarray)
|
||||||
|
yarray.insert(0, [1])
|
||||||
|
um.undo()
|
||||||
|
t.assert(yarray.length === 0)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test case to fix #241
|
* Test case to fix #241
|
||||||
* @param {t.TestCase} tc
|
* @param {t.TestCase} tc
|
||||||
|
|||||||
Reference in New Issue
Block a user