Merge remote-tracking branch 'origin' into v13-doc

This commit is contained in:
Kevin Jahns 2018-03-23 04:40:08 +01:00
commit 689bca8602
5 changed files with 27 additions and 11 deletions

View File

@ -6,6 +6,13 @@ text, richtext, json, or XML. It is fairly easy to get started, as Yjs hides
most of the complexity of concurrent editing. For additional information, demos, most of the complexity of concurrent editing. For additional information, demos,
and tutorials visit [y-js.org](http://y-js.org/). and tutorials visit [y-js.org](http://y-js.org/).
>**If you ever felt like giving back - now is the time! Me and a group of friends have organized a fundraiser to bring heathy food to unprivileged children in Vegas. Good food is often hard to come by. Thus some children dont eat vegetables on a regular basis. We are offering free daily meals with fresh produce and we are going to build a self-sustainable garden at an elementary school to educate children how to live healthy. https://urbanseedfoundation.networkforgood.com/projects/48182-kevin-jahns-s-fundraiser**
>
> Your support on my funding page would mean the world to me :raised_hands:
>
> Also check the description in the link above: If we get to 2500$, I'm going to publish a premium Yjs documentation for the upcoming v13 release! There are also some other goals. The fundraising campaign ends very soon!
### Extensions ### Extensions
Yjs only knows how to resolve conflicts on shared data. You have to choose a .. Yjs only knows how to resolve conflicts on shared data. You have to choose a ..
* *Connector* - a communication protocol that propagates changes to the clients * *Connector* - a communication protocol that propagates changes to the clients

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "yjs", "name": "yjs",
"version": "13.0.0-53", "version": "13.0.0-54",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "yjs", "name": "yjs",
"version": "13.0.0-53", "version": "13.0.0-54",
"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",

View File

@ -91,18 +91,19 @@ export default class Item {
if (parent._redone !== null) { if (parent._redone !== null) {
parent = parent._redone parent = parent._redone
// find next cloned items // find next cloned items
while (left !== null && left._redone === null) { while (left !== null) {
if (left._redone !== null && left._redone._parent === parent) {
left = left._redone
break
}
left = left._left left = left._left
} }
if (left !== null) { while (right !== null) {
left = left._redone if (right._redone !== null && right._redone._parent === parent) {
} right = right._redone
while (right !== null && right._redone === null) { }
right = right._right right = right._right
} }
if (right !== null) {
right = right._redone
}
} }
struct._origin = left struct._origin = left
struct._left = left struct._left = left

View File

@ -72,6 +72,7 @@ export default class UndoManager {
this._scope = scope this._scope = scope
this._undoing = false this._undoing = false
this._redoing = false this._redoing = false
this._lastTransactionWasUndo = false
const y = scope._y const y = scope._y
this.y = y this.y = y
y.on('afterTransaction', (y, transaction, remote) => { y.on('afterTransaction', (y, transaction, remote) => {
@ -79,7 +80,12 @@ export default class UndoManager {
let reverseOperation = new ReverseOperation(y, transaction) let reverseOperation = new ReverseOperation(y, transaction)
if (!this._undoing) { if (!this._undoing) {
let lastUndoOp = this._undoBuffer.length > 0 ? this._undoBuffer[this._undoBuffer.length - 1] : null let lastUndoOp = this._undoBuffer.length > 0 ? this._undoBuffer[this._undoBuffer.length - 1] : null
if (lastUndoOp !== null && reverseOperation.created - lastUndoOp.created <= options.captureTimeout) { if (
this._redoing === false &&
this._lastTransactionWasUndo === false &&
lastUndoOp !== null &&
reverseOperation.created - lastUndoOp.created <= options.captureTimeout
) {
lastUndoOp.created = reverseOperation.created lastUndoOp.created = reverseOperation.created
if (reverseOperation.toState !== null) { if (reverseOperation.toState !== null) {
lastUndoOp.toState = reverseOperation.toState lastUndoOp.toState = reverseOperation.toState
@ -89,12 +95,14 @@ export default class UndoManager {
} }
reverseOperation.deletedStructs.forEach(lastUndoOp.deletedStructs.add, lastUndoOp.deletedStructs) reverseOperation.deletedStructs.forEach(lastUndoOp.deletedStructs.add, lastUndoOp.deletedStructs)
} else { } else {
this._lastTransactionWasUndo = false
this._undoBuffer.push(reverseOperation) this._undoBuffer.push(reverseOperation)
} }
if (!this._redoing) { if (!this._redoing) {
this._redoBuffer = [] this._redoBuffer = []
} }
} else { } else {
this._lastTransactionWasUndo = true
this._redoBuffer.push(reverseOperation) this._redoBuffer.push(reverseOperation)
} }
} }