Skip to content

Commit

Permalink
fix: workaround disappearing text on spellcheck suggestion (#6507)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan authored Sep 19, 2023
1 parent aa5388e commit 58706b9
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/rich-text-editor/src/vaadin-rich-text-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,35 @@ registerStyles('vaadin-rich-text-editor', richTextEditorStyles, { moduleId: 'vaa

const Quill = window.Quill;

// Workaround for text disappearing when accepting spellcheck suggestion
// See https://github.com/quilljs/quill/issues/2096#issuecomment-399576957
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; // eslint-disable-line no-constructor-return
}
}

CustomColor.blotName = 'customColor';
CustomColor.tagName = 'FONT';

Quill.register(CustomColor, true);

const HANDLERS = [
'bold',
'italic',
Expand Down

0 comments on commit 58706b9

Please sign in to comment.