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

fix: do not strip style attribute from the htmlValue (#7394) (CP: 24.3) #7397

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading