@developer_tribe/react-builder 1.2.34 → 1.2.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@developer_tribe/react-builder",
3
- "version": "1.2.34",
3
+ "version": "1.2.35",
4
4
  "license": "UNLICENSED",
5
5
  "type": "module",
6
6
  "restricted": true,
@@ -81,22 +81,10 @@ export function useAttributesEditorModel({
81
81
 
82
82
  const isStyleKeyForWrite = useCallback(
83
83
  (name: string) => {
84
- const metaCategory = attributeMeta?.[name]?.category;
85
- if (metaCategory === 'style') return true;
86
84
  return styleAttributeKeys.has(name);
87
85
  },
88
- [attributeMeta, styleAttributeKeys],
86
+ [styleAttributeKeys],
89
87
  );
90
- const isStyleKeyForRead = useCallback(
91
- (name: string) => {
92
- if (isStyleKeyForWrite(name)) return true;
93
- return !!(
94
- styleBag && Object.prototype.hasOwnProperty.call(styleBag, name)
95
- );
96
- },
97
- [isStyleKeyForWrite, styleBag],
98
- );
99
-
100
88
  const legacyFlatStyleKeys = useMemo(
101
89
  () => findLegacyFlatStyleKeys(attributes, isStyleKeyForWrite),
102
90
  [attributes, isStyleKeyForWrite],
@@ -136,12 +124,12 @@ export function useAttributesEditorModel({
136
124
 
137
125
  const getAttributeValue = useCallback(
138
126
  (name: string) => {
139
- if (isStyleKeyForRead(name)) {
127
+ if (isStyleKeyForWrite(name)) {
140
128
  return styleBag?.[name];
141
129
  }
142
130
  return (attributes as Record<string, unknown>)?.[name];
143
131
  },
144
- [attributes, isStyleKeyForRead, styleBag],
132
+ [attributes, isStyleKeyForWrite, styleBag],
145
133
  );
146
134
 
147
135
  const projectColorsForPicker = useMemo<ProjectColors | undefined>(
@@ -379,6 +367,15 @@ export function useAttributesEditorModel({
379
367
  if (name in nextAttrs) delete nextAttrs[name];
380
368
  } else {
381
369
  nextAttrs[name] = val;
370
+ // If this key was previously misplaced inside styles bag (e.g. due to a
371
+ // past editor bug), clean it up so there is no stale duplicate.
372
+ if (isPlainObject(nextAttrs.styles) && name in nextAttrs.styles) {
373
+ const cleanedStyles = { ...nextAttrs.styles };
374
+ delete cleanedStyles[name];
375
+ nextAttrs.styles = Object.keys(cleanedStyles).length
376
+ ? cleanedStyles
377
+ : undefined;
378
+ }
382
379
  }
383
380
  const next: NodeData<NodeDefaultAttribute> = {
384
381
  ...baseData,
@@ -21,10 +21,12 @@ export function OnboardDot({ node }: OnboardDotComponentProps) {
21
21
  const attributeKey = node.key ?? generatedId;
22
22
  const attrs = node.attributes;
23
23
  const attrRecord = toAttributeRecord(attrs);
24
+ // Backward compat: existing JSON may still have these in styles bag (old editor bug).
25
+ // handleAttributeChange will clean them up on next edit.
24
26
  const stylesBag = getStyleBag(attrs);
25
27
  const dotType =
26
- (stylesBag?.dotType as string | undefined) ??
27
28
  (attrRecord.dotType as string | undefined) ??
29
+ (stylesBag?.dotType as string | undefined) ??
28
30
  'normal_dot';
29
31
  const {
30
32
  previewMode,
@@ -35,15 +37,15 @@ export function OnboardDot({ node }: OnboardDotComponentProps) {
35
37
  } = useBuilderParams();
36
38
  // OnboardDot specific attributes
37
39
  const inactiveDotOpacity =
38
- (stylesBag?.inactive_dot_opacity as number | undefined) ??
39
40
  (attrRecord.inactive_dot_opacity as number | undefined) ??
41
+ (stylesBag?.inactive_dot_opacity as number | undefined) ??
40
42
  0.3;
41
43
  const inactiveDotColorOverride =
42
- (stylesBag?.inactive_dot_color as string | undefined) ??
43
- (attrRecord.inactive_dot_color as string | undefined);
44
+ (attrRecord.inactive_dot_color as string | undefined) ??
45
+ (stylesBag?.inactive_dot_color as string | undefined);
44
46
  const activeDotColor =
45
- (stylesBag?.active_dot_color as string | undefined) ??
46
- (attrRecord.active_dot_color as string | undefined);
47
+ (attrRecord.active_dot_color as string | undefined) ??
48
+ (stylesBag?.active_dot_color as string | undefined);
47
49
  const resolvedActiveDotColor = useMemo(
48
50
  () => parseColor(activeDotColor, { theme, projectColors }),
49
51
  [activeDotColor, theme, projectColors],
@@ -69,8 +71,8 @@ export function OnboardDot({ node }: OnboardDotComponentProps) {
69
71
  isSelected ? SELECTED_OUTLINE_STYLE : undefined,
70
72
  );
71
73
  const dotThicknessRaw =
72
- (stylesBag?.dot_thickness as string | number | undefined) ??
73
- (attrRecord.dot_thickness as string | number | undefined);
74
+ (attrRecord.dot_thickness as string | number | undefined) ??
75
+ (stylesBag?.dot_thickness as string | number | undefined);
74
76
  const dotSizeCss = useMemo((): string => {
75
77
  const parsed = parseSize(dotThicknessRaw, baseSize);
76
78
  if (parsed === undefined) return '10px';
@@ -49,7 +49,7 @@
49
49
  "specialCategory": null,
50
50
  "sort": 1
51
51
  },
52
- "dot_thickness": {
52
+ "dot_thickness": {
53
53
  "label": "Dot Thickness",
54
54
  "description": "Dot size/diameter.",
55
55
  "category": "style",
@@ -77,7 +77,7 @@
77
77
  "specialCategory": null,
78
78
  "sort": 5
79
79
  }
80
- }
80
+ }
81
81
  }
82
82
  }
83
83
 
@@ -9,7 +9,7 @@ import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
9
9
  import { useMergedStyle } from '../../utils/useMergedStyle';
10
10
  import { defaultLocalization } from '../../types/PreviewConfig';
11
11
  import { parseColor } from '../../utils/parseColor';
12
- import { getStyleBag, toAttributeRecord } from '../../utils/attributeStyle';
12
+ import { toAttributeRecord } from '../../utils/attributeStyle';
13
13
 
14
14
  type Segment =
15
15
  | { type: 'text'; value: string }
@@ -94,6 +94,7 @@ function buildSegments(
94
94
  function OnboardFooter({ node }: OnboardFooterComponentProps) {
95
95
  useLogRender('OnboardFooter');
96
96
  node = useNode(node);
97
+ console.log('node', node);
97
98
  const attributeName = node.sourceType ?? node.type ?? 'OnboardFooter';
98
99
  const {
99
100
  localization: builderLocalization,
@@ -110,18 +111,12 @@ function OnboardFooter({ node }: OnboardFooterComponentProps) {
110
111
 
111
112
  const attrs = node?.attributes;
112
113
  const attrRecord = toAttributeRecord(attrs);
113
- const styleBag = getStyleBag(attrs);
114
114
  const text = t(attrs?.textLocalizationKey);
115
115
  const textStyle = useExtractTextStyle(node, true);
116
116
  const viewStyle = useExtractViewStyle(node);
117
117
 
118
- // Read linked-word colors from both top-level attributes and the styles bag.
119
- // The editor saves them inside `styles` (meta category === 'style'),
120
- // but legacy JSON may have them at the top level.
121
- const rawFirstColor = (attrRecord.linkedWordFirstColor ??
122
- styleBag?.linkedWordFirstColor) as string | undefined;
123
- const rawSecondColor = (attrRecord.linkedWordSecondColor ??
124
- styleBag?.linkedWordSecondColor) as string | undefined;
118
+ const rawFirstColor = attrRecord.linkedWordFirstColor as string | undefined;
119
+ const rawSecondColor = attrRecord.linkedWordSecondColor as string | undefined;
125
120
 
126
121
  // Parse colors for linked words
127
122
  const parsedFirstColor = useMemo(