You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CMS-46481 Enhance RichText component documentation with detailed attribute and CSS property support, including conversion rules and examples for React compatibility.
Copy file name to clipboardExpand all lines: docs/6.1-richtext-component-react.md
+295-1Lines changed: 295 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ function Article({ content }) {
26
26
>
27
27
> When rich text content is created through Optimizely's Integration API (REST API) rather than the CMS editor interface, certain features may not function correctly:
28
28
>
29
-
> -**Inline styles**will not be processed or rendered
29
+
> -**Inline styles**- Some inline CSS properties might not work as expected. See [Attribute and CSS Property Support](#attribute-and-css-property-support) for details on supported CSS properties
30
30
> -**HTML validation** is bypassed, which can result in malformed or invalid HTML that causes rendering issues
31
31
> -**Advanced formatting** that relies on TinyMCE editor processing may be missing
32
32
> -**Custom attributes or props** might not be mapped properly from raw HTML to React components
@@ -425,6 +425,300 @@ function Article({ content }) {
425
425
}
426
426
```
427
427
428
+
## Attribute and CSS Property Support
429
+
430
+
The RichText component provides comprehensive support for HTML attributes and CSS properties, automatically converting them to React-compatible formats and handling styling appropriately.
431
+
432
+
### HTML Attributes (Converted to React Props)
433
+
434
+
The following HTML attributes are automatically converted to React props with proper camelCase naming:
{ text: 'This content has mixed HTML attributes and CSS properties' },
698
+
],
699
+
},
700
+
],
701
+
};
702
+
703
+
// Rendered as:
704
+
<div
705
+
className="content-block"
706
+
data-testid="rich-content"
707
+
aria-label="Article content"
708
+
width="100%"
709
+
style={{
710
+
fontSize: '16px',
711
+
backgroundColor: 'lightblue',
712
+
marginTop: '20px',
713
+
border: '1px solid #ccc',
714
+
}}
715
+
>
716
+
This content has mixed HTML attributes and CSS properties
717
+
</div>;
718
+
```
719
+
720
+
This comprehensive attribute and CSS property support ensures that rich text content from Optimizely CMS renders correctly in React applications while maintaining proper HTML semantics and React compatibility.
721
+
428
722
## Best Practices
429
723
430
724
1.**Performance**: Only override elements/leafs you need to customize
0 commit comments