From 1b0e3659c378c9431baa2e60ce519e93e98c77d3 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Thu, 1 Mar 2018 13:50:01 +0100 Subject: [PATCH 1/4] undo fixes for consecutive undo-redo --- src/Type/y-xml/YXmlText.js | 1 + src/Util/UndoManager.js | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Type/y-xml/YXmlText.js b/src/Type/y-xml/YXmlText.js index 7fbd48d5..3678774f 100644 --- a/src/Type/y-xml/YXmlText.js +++ b/src/Type/y-xml/YXmlText.js @@ -77,6 +77,7 @@ export default class YXmlText extends YText { return this._dom } _delete (y, createDelete) { + console.log('deleting text type..', this._id) this._unbindFromDom() super._delete(y, createDelete) } diff --git a/src/Util/UndoManager.js b/src/Util/UndoManager.js index c18c36d3..199b228a 100644 --- a/src/Util/UndoManager.js +++ b/src/Util/UndoManager.js @@ -73,6 +73,7 @@ export default class UndoManager { this._scope = scope this._undoing = false this._redoing = false + this._lastTransactionWasUndo = false const y = scope._y this.y = y y.on('afterTransaction', (y, transaction, remote) => { @@ -80,7 +81,12 @@ export default class UndoManager { let reverseOperation = new ReverseOperation(y, transaction) if (!this._undoing) { 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 if (reverseOperation.toState !== null) { lastUndoOp.toState = reverseOperation.toState @@ -90,12 +96,14 @@ export default class UndoManager { } reverseOperation.deletedStructs.forEach(lastUndoOp.deletedStructs.add, lastUndoOp.deletedStructs) } else { + this._lastTransactionWasUndo = false this._undoBuffer.push(reverseOperation) } if (!this._redoing) { this._redoBuffer = [] } } else { + this._lastTransactionWasUndo = true this._redoBuffer.push(reverseOperation) } } From 54453e87fa34e973145e110626cbcf7435cf387f Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Thu, 1 Mar 2018 16:44:18 +0100 Subject: [PATCH 2/4] fix consecutive undo,redo,undo,redo.. (abc test) --- src/Struct/Item.js | 17 +++++++++-------- src/Type/y-xml/YXmlText.js | 1 - 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Struct/Item.js b/src/Struct/Item.js index 2f9f87b7..c1613c8d 100644 --- a/src/Struct/Item.js +++ b/src/Struct/Item.js @@ -77,18 +77,19 @@ export default class Item { if (parent._redone !== null) { parent = parent._redone // 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 } - if (left !== null) { - left = left._redone - } - while (right !== null && right._redone === null) { + while (right !== null) { + if (right._redone !== null && right._redone._parent === parent) { + right = right._redone + } right = right._right } - if (right !== null) { - right = right._redone - } } struct._origin = left struct._left = left diff --git a/src/Type/y-xml/YXmlText.js b/src/Type/y-xml/YXmlText.js index 3678774f..7fbd48d5 100644 --- a/src/Type/y-xml/YXmlText.js +++ b/src/Type/y-xml/YXmlText.js @@ -77,7 +77,6 @@ export default class YXmlText extends YText { return this._dom } _delete (y, createDelete) { - console.log('deleting text type..', this._id) this._unbindFromDom() super._delete(y, createDelete) } From 079de07effc6ae4856cf07d3eca69326743c7250 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Thu, 1 Mar 2018 16:45:25 +0100 Subject: [PATCH 3/4] 13.0.0-54 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 710c8166..38b67aba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "yjs", - "version": "13.0.0-53", + "version": "13.0.0-54", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index d530ee81..651e6099 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yjs", - "version": "13.0.0-53", + "version": "13.0.0-54", "description": "A framework for real-time p2p shared editing on any data", "main": "./y.node.js", "browser": "./y.js", From aa8c934833fb1d089553e0fd2cafef0e461209dd Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Tue, 6 Mar 2018 05:27:03 +0100 Subject: [PATCH 4/4] Add fundraiser campaign --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 94c0b770..48e7c555 100644 --- a/README.md +++ b/README.md @@ -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, 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 don’t 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 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