@elementor/editor-components 4.0.0-496 → 4.0.0-497

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@elementor/editor-components",
3
3
  "description": "Elementor editor components",
4
- "version": "4.0.0-496",
4
+ "version": "4.0.0-497",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -40,30 +40,30 @@
40
40
  "dev": "tsup --config=../../tsup.dev.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@elementor/editor": "4.0.0-496",
44
- "@elementor/editor-canvas": "4.0.0-496",
45
- "@elementor/editor-controls": "4.0.0-496",
46
- "@elementor/editor-documents": "4.0.0-496",
47
- "@elementor/editor-editing-panel": "4.0.0-496",
48
- "@elementor/editor-elements": "4.0.0-496",
49
- "@elementor/editor-elements-panel": "4.0.0-496",
50
- "@elementor/editor-mcp": "4.0.0-496",
51
- "@elementor/editor-panels": "4.0.0-496",
52
- "@elementor/editor-props": "4.0.0-496",
53
- "@elementor/editor-styles-repository": "4.0.0-496",
54
- "@elementor/editor-ui": "4.0.0-496",
55
- "@elementor/editor-v1-adapters": "4.0.0-496",
56
- "@elementor/http-client": "4.0.0-496",
43
+ "@elementor/editor": "4.0.0-497",
44
+ "@elementor/editor-canvas": "4.0.0-497",
45
+ "@elementor/editor-controls": "4.0.0-497",
46
+ "@elementor/editor-documents": "4.0.0-497",
47
+ "@elementor/editor-editing-panel": "4.0.0-497",
48
+ "@elementor/editor-elements": "4.0.0-497",
49
+ "@elementor/editor-elements-panel": "4.0.0-497",
50
+ "@elementor/editor-mcp": "4.0.0-497",
51
+ "@elementor/editor-panels": "4.0.0-497",
52
+ "@elementor/editor-props": "4.0.0-497",
53
+ "@elementor/editor-styles-repository": "4.0.0-497",
54
+ "@elementor/editor-ui": "4.0.0-497",
55
+ "@elementor/editor-v1-adapters": "4.0.0-497",
56
+ "@elementor/http-client": "4.0.0-497",
57
57
  "@elementor/icons": "^1.63.0",
58
- "@elementor/mixpanel": "4.0.0-496",
59
- "@elementor/query": "4.0.0-496",
60
- "@elementor/schema": "4.0.0-496",
61
- "@elementor/store": "4.0.0-496",
58
+ "@elementor/mixpanel": "4.0.0-497",
59
+ "@elementor/query": "4.0.0-497",
60
+ "@elementor/schema": "4.0.0-497",
61
+ "@elementor/store": "4.0.0-497",
62
62
  "@elementor/ui": "1.36.17",
63
- "@elementor/utils": "4.0.0-496",
63
+ "@elementor/utils": "4.0.0-497",
64
64
  "@wordpress/i18n": "^5.13.0",
65
- "@elementor/editor-notifications": "4.0.0-496",
66
- "@elementor/editor-current-user": "4.0.0-496"
65
+ "@elementor/editor-notifications": "4.0.0-497",
66
+ "@elementor/editor-current-user": "4.0.0-497"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "react": "^18.3.1",
@@ -37,6 +37,7 @@ const InputSchema = {
37
37
  .describe(
38
38
  'A unique, user-friendly display name for this property (e.g., "Hero Headline", "CTA Button Text"). Must be unique within the same component.'
39
39
  ),
40
+ group: z.string().optional().describe( 'Non unique, optional property grouping' ),
40
41
  } )
41
42
  ),
42
43
  } )
@@ -45,6 +46,7 @@ const InputSchema = {
45
46
  'Overridable properties configuration. Specify which CHILD element properties can be customized. ' +
46
47
  'Only elementId and propKey are required; To get the available propKeys for a child element you must use the "get-element-type-config" tool.'
47
48
  ),
49
+ groups: z.array( z.string() ).describe( 'Property Groups, by order, unique values' ).optional(),
48
50
  };
49
51
 
50
52
  const OutputSchema = {
@@ -63,7 +65,12 @@ export const ERROR_MESSAGES = {
63
65
  };
64
66
 
65
67
  export const handleSaveAsComponent = async ( params: z.infer< z.ZodObject< typeof InputSchema > > ) => {
66
- const { element_id: elementId, component_name: componentName, overridable_props: overridablePropsInput } = params;
68
+ const {
69
+ groups = [],
70
+ element_id: elementId,
71
+ component_name: componentName,
72
+ overridable_props: overridablePropsInput,
73
+ } = params;
67
74
  const validElementTypes = getValidElementTypes();
68
75
  const container = getContainer( elementId );
69
76
 
@@ -83,8 +90,15 @@ export const handleSaveAsComponent = async ( params: z.infer< z.ZodObject< typeo
83
90
  throw new Error( ERROR_MESSAGES.ELEMENT_IS_LOCKED );
84
91
  }
85
92
 
93
+ const groupsWithDefaultGroup = groups.indexOf( 'Default' ) >= 0 ? [ ...groups ] : [ 'Default', ...groups ];
94
+ const propertyGroups: PropertyGroup[] = groupsWithDefaultGroup.map( ( groupName ) => ( {
95
+ id: generateUniqueId( 'group' ),
96
+ label: groupName,
97
+ props: < string[] >[],
98
+ } ) );
99
+
86
100
  const overridableProps = overridablePropsInput
87
- ? enrichOverridableProps( overridablePropsInput, element )
101
+ ? enrichOverridableProps( overridablePropsInput, element, propertyGroups )
88
102
  : undefined;
89
103
 
90
104
  if ( overridableProps ) {
@@ -122,15 +136,25 @@ export const handleSaveAsComponent = async ( params: z.infer< z.ZodObject< typeo
122
136
  };
123
137
  };
124
138
 
139
+ type PropertyGroup = OverridableProps[ 'groups' ][ 'items' ][ string ];
140
+
125
141
  function enrichOverridableProps(
126
- input: { props: Record< string, { elementId: string; propKey: string; label: string } > },
127
- rootElement: V1ElementData
142
+ input: { props: Record< string, { elementId: string; propKey: string; label: string; group?: string } > },
143
+ rootElement: V1ElementData,
144
+ propertGroups: PropertyGroup[]
128
145
  ): OverridableProps {
129
146
  const enrichedProps: OverridableProps[ 'props' ] = {};
130
- const defaultGroupId = generateUniqueId( 'group' );
147
+ const enrichedGroups: OverridableProps[ 'groups' ][ 'items' ] = {};
148
+ const defaultGroup = propertGroups.find( ( g ) => g.label === 'Default' );
149
+
150
+ if ( ! defaultGroup ) {
151
+ throw new Error( 'Internal mcp error: could not generate default group' );
152
+ }
131
153
 
132
154
  Object.entries( input.props ).forEach( ( [ , prop ] ) => {
133
- const { elementId, propKey, label } = prop;
155
+ const { elementId, propKey, label, group = 'Default' } = prop;
156
+ const targetGroup = propertGroups.find( ( g ) => g.label === group ) || defaultGroup;
157
+ const targetGroupId = targetGroup.id;
134
158
  const element = findElementById( rootElement, elementId );
135
159
 
136
160
  if ( ! element ) {
@@ -163,6 +187,15 @@ function enrichOverridableProps(
163
187
  ? ( element.settings[ propKey ] as PropValue )
164
188
  : elementType.propsSchema[ propKey ].default ?? null;
165
189
 
190
+ if ( ! enrichedGroups[ targetGroupId ] ) {
191
+ enrichedGroups[ targetGroupId ] = {
192
+ id: targetGroupId,
193
+ label: targetGroup.label,
194
+ props: [],
195
+ };
196
+ }
197
+ enrichedGroups[ targetGroupId ].props.push( overrideKey );
198
+
166
199
  enrichedProps[ overrideKey ] = {
167
200
  overrideKey,
168
201
  label,
@@ -171,21 +204,15 @@ function enrichOverridableProps(
171
204
  elType,
172
205
  widgetType,
173
206
  originValue,
174
- groupId: defaultGroupId,
207
+ groupId: targetGroupId,
175
208
  };
176
209
  } );
177
210
 
178
211
  return {
179
212
  props: enrichedProps,
180
213
  groups: {
181
- items: {
182
- [ defaultGroupId ]: {
183
- id: defaultGroupId,
184
- label: 'Default',
185
- props: Object.keys( enrichedProps ),
186
- },
187
- },
188
- order: [ defaultGroupId ],
214
+ items: enrichedGroups,
215
+ order: [ defaultGroup.id ],
189
216
  },
190
217
  };
191
218
  }
@@ -366,17 +393,20 @@ Component with overridable properties:
366
393
  "heading-text": {
367
394
  "elementId": "heading-123",
368
395
  "propKey": "text",
369
- "label": "Card Title"
396
+ "label": "Card Title",
397
+ "group": "Content"
370
398
  },
371
399
  "button-text": {
372
400
  "elementId": "button-456",
373
401
  "propKey": "text",
374
- "label": "Button Text"
402
+ "label": "Button Text",
403
+ "group": "Content"
375
404
  },
376
405
  "button-link": {
377
406
  "elementId": "button-456",
378
407
  "propKey": "url",
379
- "label": "Button Link"
408
+ "label": "Button Link",
409
+ "group": "Settings"
380
410
  }
381
411
  }
382
412
  }