Skip to content
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

TEXT_CHANGE event generates incorrect Delta when inserting same character #746

Closed
sachinrekhi opened this issue Jun 9, 2016 · 0 comments

Comments

@sachinrekhi
Copy link
Contributor

When you insert a new character right before the same existing character, Quill incorrectly creates a Delta suggesting that the existing character was added, not the new character.

While this technically results in the same document, it does result in certain issues. For example, when I'm trying to re-implement MultiCursor support, it's resulting in shiftCursors() not moving the cursor to the new correct position since the generated delta incorrectly indicates which character was added. This will also ultimately create issues for the authorship module as well on exactly who inserted what character.

Steps for Reproduction

  1. Visit beta.quilljs.com
  2. Console: quill.setContents([{insert:'ttest\n'}])
  3. Console: quill.on(Quill.events.TEXT_CHANGE, (delta) => {console.dir(delta)})
  4. Enter "t" and the beginning of the contents of the editor

Expected behavior:
Console shows that the generated Delta is simply: [{insert: "t"}]

Actual behavior:
Actual generated delta is: [{retain: 2}, {insert: "t"}]

Platforms:
Chrome 51 on Mac 10.11

Version:
Quill 1.0 Beta 4

@jhchen jhchen closed this as completed in cad7490 Oct 20, 2016
tim-mc pushed a commit to tim-mc/quill that referenced this issue Dec 12, 2016
tim-mc pushed a commit to tim-mc/quill that referenced this issue Dec 12, 2016
pedrosanta added a commit to reedsy/quill-cursors that referenced this issue Apr 26, 2017
This was in place because the issue of misplaced deltas regarding the
edit position when adding characters to a character sequence, because of
the diff strategy of the fast-diff lib detailed on this issue/PR,
slab/quill#746.

Since this has been fixed on fast-diff at
jhchen/fast-diff#2,
the loopback fix/workaround is no longer necessary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants