Skip to content

Commit

Permalink
fix: do not strip style attribute from the htmlValue (#7394) (#7397)
Browse files Browse the repository at this point in the history
Co-authored-by: Serhii Kulykov <[email protected]>
  • Loading branch information
vaadin-bot and web-padawan authored May 10, 2024
1 parent f020440 commit 8f8eb94
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ export const RichTextEditorMixin = (superClass) =>
return `class="${classes.join(' ')}"`;
});
// Remove meta spans, e.g. cursor which are empty after Quill classes removed
content = content.replace(/<\/?span[^>]*>/gu, '');
content = content.replace(/<span[^>]*><\/span>/gu, '');

// Replace Quill align classes with inline styles
[this.__dir === 'rtl' ? 'left' : 'right', 'center', 'justify'].forEach((align) => {
Expand Down
6 changes: 6 additions & 0 deletions packages/rich-text-editor/test/basic.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,12 @@ describe('rich text editor', () => {
expect(rte.htmlValue).to.equal('<p><strong>Hello </strong></p><p><strong>world</strong></p>');
});

it('should not filter out span elements with style from the resulting htmlValue', () => {
setValueAndFormatText('color', '#e60000');
// Empty span should be stripped
expect(rte.htmlValue).to.equal('<p><span style="color: rgb(230, 0, 0);">Foo</span></p>');
});

it('should not lose leading tab characters from the resulting htmlValue', () => {
const htmlWithLeadingTab = '<p>\tTab</p>';
rte.dangerouslySetHtmlValue(htmlWithLeadingTab);
Expand Down

0 comments on commit 8f8eb94

Please sign in to comment.