Comparing version 13.5.24 to 13.5.25
@@ -7,3 +7,3 @@ export function followRedone(store: StructStore, id: ID): { | ||
export function splitItem(transaction: Transaction, leftItem: Item, diff: number): Item; | ||
export function redoItem(transaction: Transaction, item: Item, redoitems: Set<Item>, itemsToDelete: Array<Item>): Item | null; | ||
export function redoItem(transaction: Transaction, item: Item, redoitems: Set<Item>, itemsToDelete: DeleteSet): Item | null; | ||
/** | ||
@@ -57,3 +57,3 @@ * Abstract class that represents any content. | ||
/** | ||
* If this type's effect is reundone this type refers to the type that undid | ||
* If this type's effect is redone this type refers to the type that undid | ||
* this operation. | ||
@@ -190,2 +190,3 @@ * @type {ID | null} | ||
import { Transaction } from "../utils/Transaction.js"; | ||
import { DeleteSet } from "../utils/DeleteSet.js"; | ||
import { AbstractStruct } from "./AbstractStruct.js"; | ||
@@ -192,0 +193,0 @@ import { AbstractType } from "../types/AbstractType.js"; |
@@ -79,2 +79,14 @@ /** | ||
redo(): StackItem | null; | ||
/** | ||
* Are undo steps available? | ||
* | ||
* @return {boolean} `true` if undo is possible | ||
*/ | ||
canUndo(): boolean; | ||
/** | ||
* Are redo steps available? | ||
* | ||
* @return {boolean} `true` if redo is possible | ||
*/ | ||
canRedo(): boolean; | ||
} | ||
@@ -81,0 +93,0 @@ export type UndoManagerOptions = { |
{ | ||
"name": "yjs", | ||
"version": "13.5.24", | ||
"version": "13.5.25", | ||
"description": "Shared Editing Library", | ||
@@ -25,4 +25,3 @@ "main": "./dist/yjs.cjs", | ||
"trace-deopt": "clear && rollup -c && node --trace-deopt dist/test.cjs", | ||
"trace-opt": "clear && rollup -c && node --trace-opt dist/test.cjs", | ||
"postinstall": "node ./sponsor-y.js" | ||
"trace-opt": "clear && rollup -c && node --trace-opt dist/test.cjs" | ||
}, | ||
@@ -29,0 +28,0 @@ "exports": { |
@@ -59,10 +59,6 @@ | ||
collaborative drawing, editing, and coding tools. :star: | ||
* [https://coronavirustechhandbook.com/](https://coronavirustechhandbook.com/) | ||
A collaborative wiki that is edited by thousands of different people to work | ||
on a rapid and sophisticated response to the coronavirus outbreak and | ||
subsequent impacts. :star: | ||
* [Nimbus Note](https://nimbusweb.me/note.php) A note-taking app designed by | ||
Nimbus Web. | ||
* [JoeDocs](https://joedocs.com/) An open collaborative wiki. | ||
* [Pluxbox RadioManager](https://pluxbox.com/) A web-based app to | ||
* [Pluxbox RadioManager](https://getradiomanager.com/) A web-based app to | ||
collaboratively organize radio broadcasts. | ||
@@ -103,3 +99,3 @@ * [Alldone](https://alldone.app/) A next-gen project management and | ||
| [valtio](https://github.com/pmndrs/valtio) | | [valtio-yjs](https://github.com/dai-shi/valtio-yjs) | [demo](https://codesandbox.io/s/valtio-yjs-demo-ox3iy) | | ||
| React / Vue / MobX | | [SyncedStore](https://syncedstore.org) | [demo](https://syncedstore.org/docs/react) | | ||
| React / Vue / Svelte / MobX | | [SyncedStore](https://syncedstore.org) | [demo](https://syncedstore.org/docs/react) | | ||
@@ -147,2 +143,11 @@ ### Providers | ||
</dd> | ||
<dt><a href="https://github.com/yousefED/matrix-crdt">Matrix-CRDT</a></dt> | ||
<dd> | ||
Use <a href="https://www.matrix.org">Matrix</a> as an off-the-shelf backend for | ||
Yjs by using the <a href="https://github.com/yousefED/matrix-crdt">MatrixProvider</a>. | ||
Use Matrix as transport and storage of Yjs updates, so you can focus building | ||
your client app and Matrix can provide powerful features like Authentication, | ||
Authorization, Federation, hosting (self-hosting or SaaS) and even End-to-End | ||
Encryption (E2EE). | ||
</dd> | ||
</dl> | ||
@@ -986,3 +991,3 @@ | ||
alternative approach to *operational transformation* (OT). A very simple | ||
differenciation between the two approaches is that OT attempts to transform | ||
differentiation between the two approaches is that OT attempts to transform | ||
index positions to ensure convergence (all clients end up with the same | ||
@@ -989,0 +994,0 @@ content), while CRDTs use mathematical models that usually do not involve index |
@@ -112,3 +112,3 @@ | ||
} else { | ||
// Whis will be gc'd later and we want to merge it if possible | ||
// This will be gc'd later and we want to merge it if possible | ||
// We try to merge all deleted items after each transaction, | ||
@@ -115,0 +115,0 @@ // but we have no knowledge about that this needs to be merged |
@@ -25,3 +25,4 @@ | ||
addChangedTypeToTransaction, | ||
UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, ContentType, ContentDeleted, StructStore, ID, AbstractType, Transaction // eslint-disable-line | ||
isDeleted, | ||
DeleteSet, UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, ContentType, ContentDeleted, StructStore, ID, AbstractType, Transaction // eslint-disable-line | ||
} from '../internals.js' | ||
@@ -129,3 +130,3 @@ | ||
* @param {Set<Item>} redoitems | ||
* @param {Array<Item>} itemsToDelete | ||
* @param {DeleteSet} itemsToDelete | ||
* | ||
@@ -148,3 +149,3 @@ * @return {Item|null} | ||
*/ | ||
let left | ||
let left = null | ||
/** | ||
@@ -154,33 +155,18 @@ * @type {Item|null} | ||
let right | ||
if (item.parentSub === null) { | ||
// Is an array item. Insert at the old position | ||
left = item.left | ||
right = item | ||
} else { | ||
// Is a map item. Insert as current value | ||
left = item | ||
while (left.right !== null) { | ||
left = left.right | ||
if (left.id.client !== ownClientID) { | ||
// It is not possible to redo this item because it conflicts with a | ||
// change from another client | ||
return null | ||
} | ||
} | ||
if (left.right !== null) { | ||
left = /** @type {Item} */ (/** @type {AbstractType<any>} */ (item.parent)._map.get(item.parentSub)) | ||
} | ||
right = null | ||
} | ||
// make sure that parent is redone | ||
if (parentItem !== null && parentItem.deleted === true && parentItem.redone === null) { | ||
if (parentItem !== null && parentItem.deleted === true) { | ||
// try to undo parent if it will be undone anyway | ||
if (!redoitems.has(parentItem) || redoItem(transaction, parentItem, redoitems, itemsToDelete) === null) { | ||
if (parentItem.redone === null && (!redoitems.has(parentItem) || redoItem(transaction, parentItem, redoitems, itemsToDelete) === null)) { | ||
return null | ||
} | ||
} | ||
if (parentItem !== null && parentItem.redone !== null) { | ||
while (parentItem.redone !== null) { | ||
parentItem = getItemCleanStart(transaction, parentItem.redone) | ||
} | ||
} | ||
const parentType = parentItem === null ? /** @type {AbstractType<any>} */ (item.parent) : /** @type {ContentType} */ (parentItem.content).type | ||
if (item.parentSub === null) { | ||
// Is an array item. Insert at the old position | ||
left = item.left | ||
right = item | ||
// find next cloned_redo items | ||
@@ -217,6 +203,28 @@ while (left !== null) { | ||
} | ||
// Iterate right while right is in itemsToDelete | ||
// If it is intended to delete right while item is redone, we can expect that item should replace right. | ||
while (left !== null && left.right !== null && left.right !== right && itemsToDelete.findIndex(d => d === /** @type {Item} */ (left).right) >= 0) { | ||
left = left.right | ||
} else { | ||
right = null | ||
if (item.right) { | ||
left = item | ||
// Iterate right while right is in itemsToDelete | ||
// If it is intended to delete right while item is redone, we can expect that item should replace right. | ||
while (left !== null && left.right !== null && isDeleted(itemsToDelete, left.right.id)) { | ||
left = left.right | ||
} | ||
// follow redone | ||
// trace redone until parent matches | ||
while (left !== null && left.redone !== null) { | ||
left = getItemCleanStart(transaction, left.redone) | ||
} | ||
// check wether we were allowed to follow right (indicating that originally this op was replaced by another item) | ||
if (left === null || /** @type {AbstractType<any>} */ (left.parent)._item !== parentItem) { | ||
// invalid parent; should never happen | ||
return null | ||
} | ||
if (left && left.right !== null) { | ||
// It is not possible to redo this item because it conflicts with a | ||
// change from another client | ||
return null | ||
} | ||
} else { | ||
left = parentType._map.get(item.parentSub) || null | ||
} | ||
@@ -230,3 +238,3 @@ } | ||
right, right && right.id, | ||
parentItem === null ? item.parent : /** @type {ContentType} */ (parentItem.content).type, | ||
parentType, | ||
item.parentSub, | ||
@@ -290,3 +298,3 @@ item.content.copy() | ||
/** | ||
* If this type's effect is reundone this type refers to the type that undid | ||
* If this type's effect is redone this type refers to the type that undid | ||
* this operation. | ||
@@ -293,0 +301,0 @@ * @type {ID | null} |
@@ -91,3 +91,3 @@ import { | ||
itemsToRedo.forEach(struct => { | ||
performedChange = redoItem(transaction, struct, itemsToRedo, itemsToDelete) !== null || performedChange | ||
performedChange = redoItem(transaction, struct, itemsToRedo, stackItem.insertions) !== null || performedChange | ||
}) | ||
@@ -286,2 +286,20 @@ // We want to delete in reverse order so that children are deleted before | ||
} | ||
/** | ||
* Are undo steps available? | ||
* | ||
* @return {boolean} `true` if undo is possible | ||
*/ | ||
canUndo () { | ||
return this.undoStack.length > 0 | ||
} | ||
/** | ||
* Are redo steps available? | ||
* | ||
* @return {boolean} `true` if redo is possible | ||
*/ | ||
canRedo () { | ||
return this.redoStack.length > 0 | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
2070895
32023
1063
0
93