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

Enabling code-block syntax highlighting results in "token" attribute being emitted by text-change event #2178

Closed
sachinrekhi opened this issue Jul 2, 2018 · 0 comments

Comments

@sachinrekhi
Copy link
Contributor

After implementing syntax highlighting in a code-block, I noticed that as you type code into the code block, on occasion the Quill text-change event incorrectly emits a "token" attribute as part of it's delta. This doesn't occur with every edit in the code block, but occurs rather frequently.

The issue is the "token" attribute shouldn't be emitted at all as part of the text-change event since syntax highlighting shouldn't have any effect on the generated delta.

Here is a video going through the below repro steps and reproducing the issue: https://cl.ly/2x440N2z230V

Any idea what's going on? Or workarounds? Thanks!

Steps for Reproduction

  1. Visit quilljs.com
  2. Open the console and paste in the following:
quill.on(Quill.events.TEXT_CHANGE, (delta) => {
    for (var i=0; i < delta.ops.length; i++) {
        if ((delta.ops[i].attributes !== undefined) && (delta.ops[i].attributes.token !== undefined)) {
            console.log('CORRUPTED!')
            console.dir(delta.ops)
        }
    }
})
  1. Go to the code block section in the sample editor and start adding code manually by typing it into the code block. You'll need to type quite a few functions, variables, etc since it doesn't occur every edit. But you'll eventually get it.

Expected behavior:
Adding code to the code block shouldn't result in any attributes other than "code-block": true being emitted as part of the text-change event.

Actual behavior:
A "token" attribute is sometimes incorrectly emitted with values like "function", "keyword", etc.

Platforms:
Chrome 67 on Mac 10.13.5

Version:
1.3.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant