quill: [2.0.3] `getSemanticHTML` is broken
Steps for Reproduction
- Reproduction
- Check the console
Expected behavior:
The text in the editor is a text with multiple spaces. getSemanticHTML returns <p>a text with multiple spaces</p>. Which is wrong - the semantics of the text has changed.
Actual behavior: See above.
Platforms: Any.
Version: 2.0.3
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 92
- Comments: 38
Commits related to this issue
- fix: rework consecutive space replacement Original author: https://github.com/slab/quill/issues/4509#issuecomment-2521334016 Refs: slab/quill#4509 — committed to lufrai/quill by katywings 2 years ago
- downgrade quilljs QuillJS 2.0.3 changed the way semanticHTML is rendered by replacing all spaces with .. what an absolute joke.. slab/quill#4509 — committed to forumify/forumify-platform by jannes-io 2 years ago
IMHO this is critical bug
Introduced wtih Commit 07b68c9.
The end result of replacing all spaces with
(Non Breaking Space) is that the words no-long wrap at word boundaries, and instead overflow.Example
An alternative implementation of editor.js converHTML() that preserves whitespace might replace all but one consecutive space character with be:
A work around (which replaces the last consecutive
with a space) until a fix is implemented is:Completely destroys displaying edited text for me, since text now fails to wrap. Please revert.
We have the same issue please revert this change. Don’t want to save nbps to the database.
This is quite critical bug to our project. This changes how the values are saved to database. Luckily this didn’t hit production before noticing.
Jeez this thread is a joke. Just do this in your code:
input.replace(" ", " ")Yes. Very much so. For example, ngx-quill (https://github.com/KillerCodeMonkey/ngx-quill) also suffers from this. If the editor is used as part of Angular reactive forms, the value of the form control has these added characters after user has finished typing something with whitespaces.
Spent the entire day only to discover this is a known and unaddressed bug.
The problem with all spaces becoming
is that it completely breaks pervious word wrapping. It’s a non-breaking space, thus all instances that would otherwise line wrap suddenly won’t. For a WYSIWYG editor, what you see is currently not what you get.I think this is bad. Sometimes I need to write
literally in the editor.Can we revert to the amazing
getSemanticHTML()method of the 2.0.2 please?We weren’t aware that a bug had been open here for several months. This has resulted in an unsightly number of non breakable characters in the database. It would be great if the bug could be fixed finally.
If that is the case, then why is
getSemanticHTML()a supported function? Emphasis is mine:An end user who presented with wrapping lines in an editor intends to have lines wrap. Swapping for
destroys the intentions of the end user’s line wrapping. It is simply the incorrect interpretation of the end user’s intentions.If the fix is using the Delta system, then
getSemanticHTML()is an unsupported function as it doesn’t generate accurate HTML. This would also change the scope of Quill and explicitly only compatible with Delta.If the fix is to revert 07b68c98b3bb61e6a6efb369a76f44a16b278517 and allow
getSemanticHTML()to output the intended HTML, then we would have the expected results.I created an alternative fix (PR #4598) that introduce options to getSemanticHTML, so it can be used as it is (with
) for internal coping and pasting in quill. SettingpreserveWhitespaceoption to true will preserve whitespace for all of us needing it.Any update on this @luin?
Hey @dimitriaguera, according to this, you can use any version of Quill as long as it’s a v2 version. I’m using quill v2.0.2 with the latest ngx-quill (v27.0.2) without any issues.
this must be some psyop. trust no patch.
I opened a pull request with a fix. Hopefully it will get approved.
Yes, it’s under the name of
Slabnow, which means soon or late it will become a commercial product (based on my experience throughout these years!).Could this be a configuration option? So when someone needs it to be “normal” spaces it can?
We are using a very vanilla implementation and as such have reverted to 2.0.2 without incident.
Yikes… breaking backwards compatibility in a patch version… Guess the one take-away we got from this is to fix quill to whatever version works and leave it there until we hit critical vulnerabilities…
The PR is this: https://github.com/slab/quill/pull/4587.
Probably you are. Most comments complain that this bug has them save
s to the DB. If that’s also your problem then yes, you’re using it wrong. You’re supposed to save the delta format, not something rendered. If you need to send html from the ui to your backend, Quill maybe isn’t the right editor for your requirements. If you need html for whatever reason, parse the delta. That’s the usp of Quill, a view agnostic storage format.The fact that this hasn’t been addressed yet has me concerned that I’m not…using Quill correctly, or something. This respectfully seems like an incredibly critical bug. Is there something I’m missing?
commenting to follow, hoping to see an update here.
Since the issue is twofold (some need
others regular spaces - as we do) maybe it’s worth adding optional parameter forgetSemanticHTMLfunction, that’s passed further to convertHTML?E.g. as suggested here by @MaciejDabek
Or, @DirkLachowski, since there are so many of us here, our way of using Quill is not wrong either. 🥰
I think @luin can help us here
Thanks