@dotcms/uve 1.2.2 → 1.2.3-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -33
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -44,6 +44,7 @@ With `@dotcms/uve`, framework SDKs are able to:
|
|
|
44
44
|
- [Accessing Style Values](#accessing-style-values)
|
|
45
45
|
- [Best Practices](#best-practices)
|
|
46
46
|
- [Complete Example](#complete-example)
|
|
47
|
+
- [Current Capabilities and Limitations](#current-capabilities-and-limitations)
|
|
47
48
|
- [Troubleshooting](#troubleshooting)
|
|
48
49
|
- [Common Issues & Solutions](#common-issues--solutions)
|
|
49
50
|
- [Debugging Tips](#debugging-tips)
|
|
@@ -496,7 +497,7 @@ The Style Editor is a powerful feature that enables content authors and develope
|
|
|
496
497
|
**Key Benefits:**
|
|
497
498
|
|
|
498
499
|
- **Real-Time Visual Editing**: Modify component styles and see changes instantly in the editor
|
|
499
|
-
- **Content-Specific Customization**: Different content types can have unique style schemas
|
|
500
|
+
- **Content-Specific Customization**: Different content types can have unique style schemas, and the same contentlet could have different styles depending on if it is located in a different container or page
|
|
500
501
|
- **Developer-Controlled**: Developers define which properties are editable and how they're presented
|
|
501
502
|
- **Flexible Configuration**: Support for text inputs, dropdowns, radio buttons, and checkbox groups
|
|
502
503
|
- **Type-Safe**: Full TypeScript support with type inference for option values
|
|
@@ -1074,27 +1075,27 @@ function BlogPostEditor() {
|
|
|
1074
1075
|
|
|
1075
1076
|
### Accessing Style Values
|
|
1076
1077
|
|
|
1077
|
-
Style Editor values are managed internally by UVE and passed to your components through the `
|
|
1078
|
+
Style Editor values are managed internally by UVE and passed to your components through the `dotStyleProperties` attribute. This attribute is available in your contentlet component props.
|
|
1078
1079
|
|
|
1079
1080
|
#### In React Components
|
|
1080
1081
|
|
|
1081
|
-
When rendering contentlets, style properties are accessed through the `
|
|
1082
|
+
When rendering contentlets, style properties are accessed through the `dotStyleProperties` prop:
|
|
1082
1083
|
|
|
1083
1084
|
```typescript
|
|
1084
1085
|
import { DotCMSContentlet } from '@dotcms/types';
|
|
1085
1086
|
|
|
1086
1087
|
interface ActivityProps {
|
|
1087
1088
|
contentlet: DotCMSContentlet;
|
|
1088
|
-
|
|
1089
|
+
dotStyleProperties?: Record<string, any>;
|
|
1089
1090
|
}
|
|
1090
1091
|
|
|
1091
1092
|
function Activity(props: ActivityProps) {
|
|
1092
|
-
const { title, description,
|
|
1093
|
+
const { title, description, dotStyleProperties } = props; // Contentlet information
|
|
1093
1094
|
|
|
1094
1095
|
// Access style values using dot notation or bracket notation
|
|
1095
|
-
const fontSize =
|
|
1096
|
-
const textAlign =
|
|
1097
|
-
const layout =
|
|
1096
|
+
const fontSize = dotStyleProperties?.['font-size'];
|
|
1097
|
+
const textAlign = dotStyleProperties?.text;
|
|
1098
|
+
const layout = dotStyleProperties?.layout;
|
|
1098
1099
|
|
|
1099
1100
|
return (
|
|
1100
1101
|
<div style={{ fontSize, textAlign }}>
|
|
@@ -1154,17 +1155,17 @@ Use the style values to conditionally render styles, classes, or component varia
|
|
|
1154
1155
|
|
|
1155
1156
|
```typescript
|
|
1156
1157
|
function BlogPost(props) {
|
|
1157
|
-
const { title, body,
|
|
1158
|
+
const { title, body, dotStyleProperties } = props;
|
|
1158
1159
|
|
|
1159
1160
|
// Example: Apply dynamic font size
|
|
1160
|
-
const fontSize =
|
|
1161
|
+
const fontSize = dotStyleProperties?.['font-size'] || '16px';
|
|
1161
1162
|
|
|
1162
1163
|
// Example: Apply layout classes
|
|
1163
|
-
const layout =
|
|
1164
|
+
const layout = dotStyleProperties?.layout || 'default';
|
|
1164
1165
|
const layoutClass = `layout-${layout}`;
|
|
1165
1166
|
|
|
1166
1167
|
// Example: Apply checkbox group values
|
|
1167
|
-
const textStyles =
|
|
1168
|
+
const textStyles = dotStyleProperties?.['text-style'] || {};
|
|
1168
1169
|
const textStyleClasses = [
|
|
1169
1170
|
textStyles.bold ? 'font-bold' : '',
|
|
1170
1171
|
textStyles.italic ? 'font-italic' : '',
|
|
@@ -1182,7 +1183,7 @@ function BlogPost(props) {
|
|
|
1182
1183
|
}
|
|
1183
1184
|
```
|
|
1184
1185
|
|
|
1185
|
-
**💡 Note:** The `
|
|
1186
|
+
**💡 Note:** The `dotStyleProperties` prop is automatically passed to your contentlet components by the framework SDK when UVE is active and style schemas are registered.
|
|
1186
1187
|
|
|
1187
1188
|
### Best Practices
|
|
1188
1189
|
|
|
@@ -1331,13 +1332,13 @@ When using style properties, always provide fallback defaults:
|
|
|
1331
1332
|
|
|
1332
1333
|
```typescript
|
|
1333
1334
|
// ✅ Good: Fallback values prevent errors
|
|
1334
|
-
const fontSize =
|
|
1335
|
-
const layout =
|
|
1336
|
-
const textStyles =
|
|
1335
|
+
const fontSize = dotStyleProperties?.['font-size'] || '16px';
|
|
1336
|
+
const layout = dotStyleProperties?.layout || 'default';
|
|
1337
|
+
const textStyles = dotStyleProperties?.['text-style'] || {};
|
|
1337
1338
|
|
|
1338
1339
|
// ❌ Bad: No fallbacks (could cause errors)
|
|
1339
|
-
const fontSize =
|
|
1340
|
-
const layout =
|
|
1340
|
+
const fontSize = dotStyleProperties?.['font-size'];
|
|
1341
|
+
const layout = dotStyleProperties?.layout;
|
|
1341
1342
|
```
|
|
1342
1343
|
|
|
1343
1344
|
### Complete Example
|
|
@@ -1538,24 +1539,24 @@ export function BlogPostStyleEditor() {
|
|
|
1538
1539
|
|
|
1539
1540
|
// Example: Using style properties in a component
|
|
1540
1541
|
export function BlogPostRenderer(props) {
|
|
1541
|
-
const { title, body,
|
|
1542
|
+
const { title, body, dotStyleProperties } = props;
|
|
1542
1543
|
|
|
1543
1544
|
// Extract style values with defaults
|
|
1544
|
-
const headingSize =
|
|
1545
|
-
const bodySize =
|
|
1546
|
-
const fontFamily =
|
|
1547
|
-
const lineHeight =
|
|
1548
|
-
const layout =
|
|
1549
|
-
const contentWidth =
|
|
1550
|
-
const sectionSpacing =
|
|
1551
|
-
const theme =
|
|
1552
|
-
const primaryColor =
|
|
1553
|
-
const backgroundColor =
|
|
1545
|
+
const headingSize = dotStyleProperties?.['heading-font-size'] || '24px';
|
|
1546
|
+
const bodySize = dotStyleProperties?.['body-font-size'] || '16px';
|
|
1547
|
+
const fontFamily = dotStyleProperties?.['font-family'] || 'arial';
|
|
1548
|
+
const lineHeight = dotStyleProperties?.['line-height'] || '1.5';
|
|
1549
|
+
const layout = dotStyleProperties?.['page-layout'] || 'full-width';
|
|
1550
|
+
const contentWidth = dotStyleProperties?.['content-width'] || '1000px';
|
|
1551
|
+
const sectionSpacing = dotStyleProperties?.['section-spacing'] || 40;
|
|
1552
|
+
const theme = dotStyleProperties?.['color-theme'] || 'light';
|
|
1553
|
+
const primaryColor = dotStyleProperties?.['primary-color'] || '#007bff';
|
|
1554
|
+
const backgroundColor = dotStyleProperties?.['background-color'] || '#ffffff';
|
|
1554
1555
|
|
|
1555
1556
|
// Extract checkbox group values
|
|
1556
|
-
const textStyle =
|
|
1557
|
-
const features =
|
|
1558
|
-
const responsive =
|
|
1557
|
+
const textStyle = dotStyleProperties?.['text-style'] || {};
|
|
1558
|
+
const features = dotStyleProperties?.features || {};
|
|
1559
|
+
const responsive = dotStyleProperties?.responsive || {};
|
|
1559
1560
|
|
|
1560
1561
|
// Build CSS classes based on values
|
|
1561
1562
|
const containerClasses = [
|
|
@@ -1613,9 +1614,26 @@ export function BlogPostRenderer(props) {
|
|
|
1613
1614
|
- ✅ Visual layout selection with images
|
|
1614
1615
|
- ✅ Checkbox groups for boolean flags
|
|
1615
1616
|
- ✅ Clear, descriptive labels
|
|
1616
|
-
- ✅ Safe value extraction with defaults using `
|
|
1617
|
+
- ✅ Safe value extraction with defaults using `dotStyleProperties`
|
|
1617
1618
|
- ✅ Dynamic styling based on style values
|
|
1618
1619
|
|
|
1620
|
+
### Current Capabilities and Limitations:
|
|
1621
|
+
|
|
1622
|
+
When **defining styles** for a contentlet within a page using **Style Editor**, the following behaviors might occur:
|
|
1623
|
+
|
|
1624
|
+
| Scenario | Behavior | Result |
|
|
1625
|
+
|---------------------------------------------------|-----------------------------------------------------------------------------------|---------------------------------------------|
|
|
1626
|
+
| Same Contentlet, Different Containers, Same Page | Page A: { Container_1: contentlet_1, Container_2: contentlet_1 } | 🎨 Styles are different |
|
|
1627
|
+
| Same Contentlet, Same Container, Different Pages | Page A: { Container_1: contentlet_1 }, Page B: { Container_1: contentlet_1 } | 🎨 Styles are different |
|
|
1628
|
+
| Copying a Page with Styled Content | Creating Page B as a copy of Page A, where Page A includes styled content | ✅ Styles preserved, 🎨 Styles are different |
|
|
1629
|
+
| Moving Styled Content to Same Container Type | system-container → system-container | ✅ Styles preserved |
|
|
1630
|
+
| Moving Styled Content to Different Container Type | system-container → custom-container | ⚠️ Styles lost |
|
|
1631
|
+
| Adding, Deleting, or Moving Unstyled Content | Performing any structural change on the page that does not involve styled content | if any: ✅ Styles preserved |
|
|
1632
|
+
|
|
1633
|
+
> **NOTE:** (🎨 Styles are different) means the capability to define distinct styles, even when utilizing the identical Contentlet.
|
|
1634
|
+
|
|
1635
|
+
The only known limitation is that moving a contentlet with defined styles between different container types (5th scenario), results in the loss of those styles. See the [technical details document](https://docs.google.com/document/d/1UiuJlIn8ZjybIB-0oHeoTLXZo1k-YExITEqEMfyvVlU/edit?tab=t.0) for our planned solution.
|
|
1636
|
+
|
|
1619
1637
|
## Troubleshooting
|
|
1620
1638
|
|
|
1621
1639
|
### Common Issues & Solutions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcms/uve",
|
|
3
|
-
"version": "1.2.2",
|
|
3
|
+
"version": "1.2.3-next.2",
|
|
4
4
|
"description": "Official JavaScript library for interacting with Universal Visual Editor (UVE)",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -50,4 +50,4 @@
|
|
|
50
50
|
"module": "./index.esm.js",
|
|
51
51
|
"main": "./index.cjs.js",
|
|
52
52
|
"types": "./index.d.ts"
|
|
53
|
-
}
|
|
53
|
+
}
|