-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quill changes Delta after returning it in "text-change" event #296
Comments
@calibr Why are you saving and printing [{"retain":12},{"insert":"12"}] |
@rocketraman it's just a test case which shows "delta changing" behaviour. sorry but I don't see any difference between my and yours fiddle. |
I don't understand your problem then. The delta behavior seems perfectly fine. |
I'm new to OT related things and maybe have wrong idea about working with deltas. In my project I save all deltas in an array which composed in one Delta when user clicks Save button, but composing generates wrong result because deltas in array have not their original values. It's not real problem for me because I create workaround by cloning "ops" array to preserve original values, but I found it strange that the object is changed after the user got it, I can provide more samples if it make sense.. |
Hah, I see that for some reason my changes didn't get saved in the fiddle. Anyway, are you saying that the delta objects are being modified by quill after they are returned? That doesn't seem to be happening in this test case: var editor = new Quill('#editor');
var res = document.getElementById("res");
var deltaOps = []
editor.on('text-change', function (delta, source) {
deltaOps.push(delta.ops)
res.innerHTML += "<br>" + JSON.stringify(deltaOps);
});
|
Yes operations array is remains unchanged, but whole
By default this value is 1000 and delta can be changed in this time interval. |
Ah interesting. Thanks for explaining the issue! |
I also ran into this when doing client side-buffering before sending ops over the network. The result is duplicated data and a server-representation that differs from the client view. Like @calibr I'm working around it by cloning the ops before buffering, but it's definitely surprising that they're not treated as immutable by quill. |
http://jsfiddle.net/ek464Lc3/
When type relatively fast, Quill changes a first returned Delta, I think is not normal behaviour, isn't it?
Steps:
When "1" typed - [{"retain":12},{"insert":"1"}]
When "2" typed - [{"retain":12},{"insert":"12"}]
When "3" typed - [{"retain":12},{"insert":"123"}]
The text was updated successfully, but these errors were encountered: