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

Editing bug: creates and preserves styles from h1-h6 while turning it into paragraph #4039

Open
ile opened this issue Mar 7, 2024 · 14 comments

Comments

@ile
Copy link

ile commented Mar 7, 2024

I could not reproduce this on Codepen, but I could reproduce it on my local machine and Quill.com.

  1. Create some content with p and h1
    image
    image
  2. Go to the empty line
    image
  3. Hit del key (on PC)
    image
  4. You should see that the line is turned into p span ... resembling the original h1
    image
    image

Expected behavior:

p with no style

Actual behavior:

p span with styles

Platforms:

Brave

Version:

'2.0.0-rc.2'

@ile ile changed the title Editing bug: creates styles from h1-h6 while turning it into paragraph Editing bug: creates and preserves styles from h1-h6 while turning it into paragraph Mar 7, 2024
@ile
Copy link
Author

ile commented Mar 8, 2024

The styles eventually creep into the h1-h6 too.

Feels like this should never happen in an HTML editor unless it's broken in some severe manner. If some random tags and styles appear into the HTML code, it feels like we are in a basic contenteditable.

image

@luin
Copy link
Member

luin commented Mar 12, 2024

Thanks for reporting! Can you reproduce this in Chrome? I can't reproduce it with Mac + Chrome 122.

@ile
Copy link
Author

ile commented Mar 12, 2024

Yes, it does happen in the latest Chrome for Linux and Ubuntu 23. At the main page demo of https://quilljs.com/

It doesn't seem to happen in Firefox for Linux.

image
image

@ile
Copy link
Author

ile commented Apr 8, 2024

Happens with the latest (rc-5) version on https://quilljs.com demo.

@ile
Copy link
Author

ile commented Apr 9, 2024

My platform is Linux btw.

@ile
Copy link
Author

ile commented Apr 17, 2024

Still happens with 2.0 on quill.com. .

@ile ile mentioned this issue Apr 17, 2024
@ile
Copy link
Author

ile commented Apr 21, 2024

Do you think it will be possible to fix this? For me it looks like the most important thing to fix, otherwise the editor isn't really much different than a plain contenteditable.

@luin
Copy link
Member

luin commented Apr 22, 2024

Sorry for the delay! I just started looking into this. I tried Chrome 120 on Window and Chrome 121 on Linux, but haven't reproduced the issue yet. Would be good if you could help me to reproduce it:

  1. Can you go to https://w3c.github.io/uievents/tools/key-event-viewer.html and press the Del key that can reproduce the bug and see what's the keyCode/key/code?
  2. Would you try running Chrome without any extensions enabled?

@ile
Copy link
Author

ile commented Apr 22, 2024

Hey,

Good to hear from you! Here's a little video I made with Chromium 124 (no extensions installed) on Ubuntu 23.

All browsers I tried on Ubuntu (Chromium, Brave, Firefox) gave keycode 46 for the 'del'.

quilljs.webm

@luin
Copy link
Member

luin commented Apr 22, 2024

Thanks for the details! Could you try out if the playground fixes your issue: link. I added a key handler for 46 key code.

@ile
Copy link
Author

ile commented Apr 22, 2024

The bug doesn't happen there - the source code will have <h1> like it should after deleting that line with del.

Here https://quilljs.com/playground/snow it happens yet in another way: there will be <p> in the code, but no styles.

@luin
Copy link
Member

luin commented Apr 22, 2024

the source code will have <h1> like it should after deleting that line with del.

By the source code, do you mean the inner HTML in the .ql-editor?

Can you also try the link and see what get printed in the console?

@ile
Copy link
Author

ile commented Apr 22, 2024

By the source code, do you mean the inner HTML in the .ql-editor?

Yes, exactly. So it looks like the handler solves the problem.

image

image

@luin
Copy link
Member

luin commented Apr 22, 2024

Okay that sounds good! I will double check the key code in different keyboard layouts but in the meantime you can use the code here to fix the issue: link

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