Repository navigation
[WC-3613]: Rich Text class data format improvements - #2462
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
52101c4 to
28649c5
Compare
28649c5 to
f544aa0
Compare
This comment has been minimized.
This comment has been minimized.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…yle mode Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
17bba2b to
81f613d
Compare
AI Code Review
What was reviewed
Skipped (out of scope): CI checks could not be fetched — verify green before merge. Findings
|
Pull request type
Bug fix (non-breaking change which fixes an issue)
Description
Jira: WC-3613 – Rich Text class data format improvements.
Following review, this PR uses a modern-browser-only approach for the class data format: values are rendered with CSS typed
attr(), with no extra fallbacks in the widget. Users who need other browsers get overridable styles in the documentation.1. Table border not working on class data format
attr(…) or ….oris not CSS: Sass evaluated it as a boolean operator and dropped every fallback. Also,attr(data-border-width px)cannot parse the stored"3px", and with only a color set,border-stylehad no fallback, so it wasnone.attr()with the CSS comma fallback, so a border shows even when only one property is set:TableBackgroundColorNodeView: eachdata-border-*attribute is now set or removed on its own. Before, clearing one property, such as the color, left a stale value that the CSS still picked up.2. Table sizing still using inline styles
In class mode the saved HTML no longer has a
styleattribute on<table>,<col>,<td>or<th>:attr()rules (table[data-width],[data-min-height],col[data-col-width],td/th[data-cell-width|height]).renderCellHTML,renderHTML,createColGroup). Inline output is byte-identical to before.3. Image and video sizing still using inline styles
No change needed. Since 5.1.0 the saved HTML already uses
width/heightattributes, notstyle. In the editor, the resize handles use React'sstyleprop, which writes through the CSSOM. That is allowed under a strict CSP, although DevTools shows it as astyleattribute.Typed
attr()is only supported in recent Chromium-based browsers (Chrome and Edge 133+). Firefox and Safari had no support at the time of writing; please re-check the current status. In those browsers, with the class data format:attr()(text color, highlight, background) do not show either. This was already true before this PR.The editor still applies the table's own width and min-height through the CSSOM. The documentation should describe overridable styles for apps that must support these browsers.
Tests:
RichTextFormatStyle.spec.tscompiles the SCSS and asserts the typedattr()border declarations with fallbacks, the sizing rules, and that the broken forms are gone.TableClassFormat.spec.tscovers:styleon any table, col or cell in class output;Element.prototype.setAttributeis never called with"style"during render and size updates.none) and all sizes render as expected.class mode editorscreenshot baseline must be regenerated, because class-mode rendering changes on purpose.What should be covered while testing?
Set Style data format to Class. Test in Chrome or Edge (supported) and confirm the limitation in Firefox or Safari.
styleattribute.🤖 Generated with Claude Code