Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0c2b3347b | ||
|
|
6258ba1ce9 | ||
|
|
5a7ee74f68 | ||
|
|
29fb4a0aab | ||
|
|
4504196d5c | ||
|
|
0c8d29bfff | ||
|
|
43384e4148 | ||
|
|
a2b62b0a58 | ||
|
|
6febf51b1a | ||
|
|
5a4816a1b2 | ||
|
|
4ad8af9a80 |
@@ -15,6 +15,7 @@ suited for even large documents.
|
|||||||
|
|
||||||
* Demos: [https://github.com/yjs/yjs-demos](https://github.com/yjs/yjs-demos)
|
* Demos: [https://github.com/yjs/yjs-demos](https://github.com/yjs/yjs-demos)
|
||||||
* Discuss: [https://discuss.yjs.dev](https://discuss.yjs.dev)
|
* Discuss: [https://discuss.yjs.dev](https://discuss.yjs.dev)
|
||||||
|
* Chat: [Gitter](https://gitter.im/Yjs/community) | [Discord](https://discord.gg/T3nqMT6qbM)
|
||||||
* Benchmark Yjs vs. Automerge:
|
* Benchmark Yjs vs. Automerge:
|
||||||
[https://github.com/dmonad/crdt-benchmarks](https://github.com/dmonad/crdt-benchmarks)
|
[https://github.com/dmonad/crdt-benchmarks](https://github.com/dmonad/crdt-benchmarks)
|
||||||
* Podcast [**"Yjs Deep Dive into real time collaborative editing solutions":**](https://www.tag1consulting.com/blog/deep-dive-real-time-collaborative-editing-solutions-tagteamtalk-001-0)
|
* Podcast [**"Yjs Deep Dive into real time collaborative editing solutions":**](https://www.tag1consulting.com/blog/deep-dive-real-time-collaborative-editing-solutions-tagteamtalk-001-0)
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.5.36",
|
"version": "13.5.39",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.5.36",
|
"version": "13.5.39",
|
||||||
"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.36",
|
"version": "13.5.39",
|
||||||
"description": "Shared Editing Library",
|
"description": "Shared Editing Library",
|
||||||
"main": "./dist/yjs.cjs",
|
"main": "./dist/yjs.cjs",
|
||||||
"module": "./dist/yjs.mjs",
|
"module": "./dist/yjs.mjs",
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
|
"types": "./dist/src/index.d.ts",
|
||||||
"import": "./dist/yjs.mjs",
|
"import": "./dist/yjs.mjs",
|
||||||
"require": "./dist/yjs.cjs"
|
"require": "./dist/yjs.cjs"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -89,7 +89,8 @@ export {
|
|||||||
diffUpdate,
|
diffUpdate,
|
||||||
diffUpdateV2,
|
diffUpdateV2,
|
||||||
convertUpdateFormatV1ToV2,
|
convertUpdateFormatV1ToV2,
|
||||||
convertUpdateFormatV2ToV1
|
convertUpdateFormatV2ToV1,
|
||||||
|
UpdateEncoderV1
|
||||||
} from './internals.js'
|
} from './internals.js'
|
||||||
|
|
||||||
const glo = /** @type {any} */ (typeof window !== 'undefined'
|
const glo = /** @type {any} */ (typeof window !== 'undefined'
|
||||||
@@ -101,9 +102,9 @@ const importIdentifier = '__ $YJS$ __'
|
|||||||
|
|
||||||
if (glo[importIdentifier] === true) {
|
if (glo[importIdentifier] === true) {
|
||||||
/**
|
/**
|
||||||
* Dear reader of this warning message. Please take this seriously.
|
* Dear reader of this message. Please take this seriously.
|
||||||
*
|
*
|
||||||
* If you see this message, please make sure that you only import one version of Yjs. In many cases,
|
* If you see this message, make sure that you only import one version of Yjs. In many cases,
|
||||||
* your package manager installs two versions of Yjs that are used by different packages within your project.
|
* your package manager installs two versions of Yjs that are used by different packages within your project.
|
||||||
* Another reason for this message is that some parts of your project use the commonjs version of Yjs
|
* Another reason for this message is that some parts of your project use the commonjs version of Yjs
|
||||||
* and others use the EcmaScript version of Yjs.
|
* and others use the EcmaScript version of Yjs.
|
||||||
@@ -112,6 +113,6 @@ if (glo[importIdentifier] === true) {
|
|||||||
* 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.
|
||||||
*/
|
*/
|
||||||
console.warn('Yjs was already imported. Importing different versions of Yjs often leads to issues.')
|
console.error('Yjs was already imported. This breaks constructor checks and will lead to isssues!')
|
||||||
}
|
}
|
||||||
glo[importIdentifier] = true
|
glo[importIdentifier] = true
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ const popStackItem = (undoManager, stack, eventType) => {
|
|||||||
/**
|
/**
|
||||||
* @typedef {Object} UndoManagerOptions
|
* @typedef {Object} UndoManagerOptions
|
||||||
* @property {number} [UndoManagerOptions.captureTimeout=500]
|
* @property {number} [UndoManagerOptions.captureTimeout=500]
|
||||||
|
* @property {function(Transaction):boolean} [UndoManagerOptions.captureTransaction] Do not capture changes of a Transaction if result false.
|
||||||
* @property {function(Item):boolean} [UndoManagerOptions.deleteFilter=()=>true] Sometimes
|
* @property {function(Item):boolean} [UndoManagerOptions.deleteFilter=()=>true] Sometimes
|
||||||
* it is necessary to filter whan an Undo/Redo operation can delete. If this
|
* it is necessary to filter whan an Undo/Redo operation can delete. If this
|
||||||
* filter returns false, the type/item won't be deleted even it is in the
|
* filter returns false, the type/item won't be deleted even it is in the
|
||||||
@@ -154,7 +155,13 @@ export class UndoManager extends Observable {
|
|||||||
* @param {AbstractType<any>|Array<AbstractType<any>>} typeScope Accepts either a single type, or an array of types
|
* @param {AbstractType<any>|Array<AbstractType<any>>} typeScope Accepts either a single type, or an array of types
|
||||||
* @param {UndoManagerOptions} options
|
* @param {UndoManagerOptions} options
|
||||||
*/
|
*/
|
||||||
constructor (typeScope, { captureTimeout = 500, deleteFilter = () => true, trackedOrigins = new Set([null]), ignoreRemoteMapChanges = false } = {}) {
|
constructor (typeScope, {
|
||||||
|
captureTimeout = 500,
|
||||||
|
captureTransaction = tr => true,
|
||||||
|
deleteFilter = () => true,
|
||||||
|
trackedOrigins = new Set([null]),
|
||||||
|
ignoreRemoteMapChanges = false
|
||||||
|
} = {}) {
|
||||||
super()
|
super()
|
||||||
/**
|
/**
|
||||||
* @type {Array<AbstractType<any>>}
|
* @type {Array<AbstractType<any>>}
|
||||||
@@ -164,6 +171,7 @@ export class UndoManager extends Observable {
|
|||||||
this.deleteFilter = deleteFilter
|
this.deleteFilter = deleteFilter
|
||||||
trackedOrigins.add(this)
|
trackedOrigins.add(this)
|
||||||
this.trackedOrigins = trackedOrigins
|
this.trackedOrigins = trackedOrigins
|
||||||
|
this.captureTransaction = captureTransaction
|
||||||
/**
|
/**
|
||||||
* @type {Array<StackItem>}
|
* @type {Array<StackItem>}
|
||||||
*/
|
*/
|
||||||
@@ -187,7 +195,11 @@ export class UndoManager extends Observable {
|
|||||||
*/
|
*/
|
||||||
this.afterTransactionHandler = transaction => {
|
this.afterTransactionHandler = transaction => {
|
||||||
// Only track certain transactions
|
// Only track certain transactions
|
||||||
if (!this.scope.some(type => transaction.changedParentTypes.has(type)) || (!this.trackedOrigins.has(transaction.origin) && (!transaction.origin || !this.trackedOrigins.has(transaction.origin.constructor)))) {
|
if (
|
||||||
|
!this.captureTransaction(transaction) ||
|
||||||
|
!this.scope.some(type => transaction.changedParentTypes.has(type)) ||
|
||||||
|
(!this.trackedOrigins.has(transaction.origin) && (!transaction.origin || !this.trackedOrigins.has(transaction.origin.constructor)))
|
||||||
|
) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const undoing = this.undoing
|
const undoing = this.undoing
|
||||||
|
|||||||
Reference in New Issue
Block a user