-
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
Spell check deletes words if there's color formatting on the line #2096
Comments
I've just encountered this as well. It seems to happen when there's any styling, not just colour. |
Just here to say I'm experiencing this too. Gonna see if I can find a fix but this is a pretty troublesome bug. |
Hey, guys... I found a solution. So here's the breakdown of what's happening: Quill's color format puts out code like this: <span style="color: rgba(0, 0, 0, 1);">Mispeled word</span> The browser's spell-check functionality changes that to: <font style="color: rgba(0, 0, 0, 1);">Mispelled word</font> Quill doesn't seem to recognize that font tag as a valid color blot so it deletes it (although once could argue that's still a bug in Quill, deleting content should never happen unless done explicitly IMO). But the fix is quite easy. I just created an additional blot that recognizes both the font tag and the color attribute, this way when Quill comes across it it knows what to do. I haven't had time to put together a demo but here's my code. [edit]: Use this instead. Then just import that into your file and use |
Brilliant!! Awesome work @foleyatwork! |
It needs a little more work though:
|
Good feedback, this could definitely use some improvement, I'm no expert in creating these blots yet. I'll work on refining this. If you've got any code improvements to share, please do. |
This seems to do everything correctly, I'll update it with any fixes: const Inline = Quill.import('blots/inline');
class CustomColor extends Inline {
constructor(domNode, value) {
super(domNode, value);
// Map <font> properties
domNode.style.color = domNode.color;
const span = this.replaceWith(new Inline(Inline.create()));
span.children.forEach(child => {
if (child.attributes) child.attributes.copy(span);
if (child.unwrap) child.unwrap();
});
this.remove();
return span;
}
}
CustomColor.blotName = "customColor";
CustomColor.tagName = "FONT";
Quill.register(CustomColor, true); |
Nice one! Is there a reason you didn't do the workaround of using classes instead of inline styles? I'm looking into it as it makes sanitising XSS easier anyway. |
Mostly because we support a continuous range of colors in our app, so I didn't want to generate 256^3 classes. It should totally work if you only allow a set of colors though. |
This works well, but unfortunately we have block formatting at the P-level that seem to get lost as soon as the code is hit. The block level is being set with the following:
which will result in the markup to result in this ( so the font size is set block related in the paragraph)
As soon as the typo is corrected, the text shows fine yet it clears the style from the paragraph. This results in:
Any help to avoid losing the block-level formatting is appreciated. |
Here another version of @chearon that keeps font-family :
|
It's still a problem. I think it's worth fixing instead of relying on programmers to create workarounds. Spell correcting is a pretty basic and commonly used feature. |
Hello, I am here as this issue actually is impacting a client who is using custom rich text fields in a Salesforce org. In Salesforce Lightning Experience, they use the open-source Quill Library for the rich text editors in custom fields. The issue occurs if they change the font to anything other than the default font. There's currently a known issue that is related to this in Salesforce, however, this Known issue is considered as No Fix as it was found that the root cause is an issue with Quill code and not a Salesforce issue. https://trailblazer.salesforce.com/issues_view?id=a1p3A000001YmYBQA0 I see that this issue has been around since at least 2018. Is there any idea as to what this would be resolved? |
I want to add to @LeeMustache comment that safari on OSX also uses some autocomplete functionality, which will have the same effect. Basicly, what happen is that the text disappears while the user is till typing and they don't even know what is happening. I've used these workarounds, which seem to be working but it is necesarry that autocomplete/autocorrect will be handled correctly. |
What's the state of things with this? |
|
👋 Sorry for the late update. We are working on the next release. This is fixed in #3807. Feel free to let me know if there is anything missing. |
@luin when will be the next release date, that this bug fix is going live. please let us know. |
@venugmp I don't have a timeline yet but we are working actively on the next release. |
@chearon @kamelito78 thank you for the fix. However, I'm using Angular, and I placed the code you provided in node_modules/quill/dist/quill.js. Now, I need to deploy the application. Should I put it in another location or just commit node_modules? What are your thoughts? |
You can put that anywhere, e.g. at the top of a module that uses Quill. |
QUICK FIX: #2096 (comment)
Steps for Reproduction
Expected behavior:
The spelling should be corrected just like regular, non-formatted text
Actual behavior:
Characters are deleted. Sometimes it's just the word, sometimes it's everything before it
Platforms:
macOS High Sierra. Chrome and Safari (notably, not Firefox)
Version:
1.3.6
Related:
The issue doesn't happen when you use classes instead of inline styles, which makes me think it's some kind of issue with normalized,
rgb()
values and quill uses hex. I tried forcing the Delta to usergb()
but it didn't help.The text was updated successfully, but these errors were encountered: