@elementor/editor-elements 3.33.0-98 → 3.35.0-324

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.
Files changed (51) hide show
  1. package/dist/index.d.mts +204 -69
  2. package/dist/index.d.ts +204 -69
  3. package/dist/index.js +1163 -293
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +1149 -291
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +7 -5
  8. package/src/errors.ts +10 -0
  9. package/src/hooks/use-element-children.ts +12 -12
  10. package/src/hooks/use-element-editor-settings.ts +12 -0
  11. package/src/hooks/use-element-interactions.ts +25 -0
  12. package/src/hooks/use-element-setting.ts +1 -1
  13. package/src/hooks/use-selected-element.ts +2 -2
  14. package/src/index.ts +38 -20
  15. package/src/mcp/elements-tool.ts +345 -0
  16. package/src/mcp/handlers/common-style-utils.ts +23 -0
  17. package/src/mcp/handlers/create-element.ts +96 -0
  18. package/src/mcp/handlers/create-style.ts +42 -0
  19. package/src/mcp/handlers/delete-element.ts +17 -0
  20. package/src/mcp/handlers/delete-style.ts +22 -0
  21. package/src/mcp/handlers/deselect-element.ts +21 -0
  22. package/src/mcp/handlers/duplicate-element.ts +22 -0
  23. package/src/mcp/handlers/get-element-props.ts +28 -0
  24. package/src/mcp/handlers/get-element-schema.ts +17 -0
  25. package/src/mcp/handlers/get-selected.ts +5 -0
  26. package/src/mcp/handlers/get-styles.ts +26 -0
  27. package/src/mcp/handlers/list-available-types.ts +27 -0
  28. package/src/mcp/handlers/move-element.ts +30 -0
  29. package/src/mcp/handlers/select-element.ts +25 -0
  30. package/src/mcp/handlers/update-props.ts +22 -0
  31. package/src/mcp/handlers/update-styles.ts +45 -0
  32. package/src/mcp/index.ts +9 -0
  33. package/src/sync/delete-element.ts +8 -2
  34. package/src/sync/drop-element.ts +30 -0
  35. package/src/sync/duplicate-elements.ts +3 -4
  36. package/src/sync/get-current-document-container.ts +1 -1
  37. package/src/sync/get-element-editor-settings.ts +8 -0
  38. package/src/sync/get-element-interactions.ts +15 -0
  39. package/src/sync/get-element-label.ts +6 -1
  40. package/src/sync/get-element-type.ts +28 -0
  41. package/src/sync/get-elements.ts +1 -1
  42. package/src/sync/get-widgets-cache.ts +4 -3
  43. package/src/sync/move-element.ts +45 -0
  44. package/src/sync/move-elements.ts +127 -0
  45. package/src/sync/remove-elements.ts +11 -0
  46. package/src/sync/replace-element.ts +50 -12
  47. package/src/sync/types.ts +32 -3
  48. package/src/sync/update-element-editor-settings.ts +28 -0
  49. package/src/sync/update-element-interactions.ts +32 -0
  50. package/src/types.ts +16 -1
  51. package/src/hooks/use-element-type.ts +0 -35
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { PropsSchema, PropValue, Props } from '@elementor/editor-props';
2
- import { StyleDefinitionID, StyleDefinition, StyleDefinitionVariant } from '@elementor/editor-styles';
2
+ import { ClassState, StyleDefinitionID, StyleDefinition, StyleDefinitionVariant } from '@elementor/editor-styles';
3
3
  import * as _elementor_editor_v1_adapters from '@elementor/editor-v1-adapters';
4
4
 
5
5
  type ElementID = string;
@@ -12,6 +12,7 @@ type ElementType = {
12
12
  controls: ControlItem[];
13
13
  propsSchema: PropsSchema;
14
14
  dependenciesPerTargetMapping?: Record<string, string[]>;
15
+ styleStates?: ClassState[];
15
16
  title: string;
16
17
  };
17
18
  type ControlsSection = {
@@ -36,9 +37,41 @@ type Control = {
36
37
  };
37
38
  };
38
39
  };
39
- type ControlItem = ControlsSection | Control;
40
+ type ElementControl = {
41
+ type: 'element-control';
42
+ value: {
43
+ type: string;
44
+ label?: string;
45
+ props: Record<string, unknown>;
46
+ meta?: {
47
+ layout?: ControlLayout;
48
+ topDivider?: boolean;
49
+ };
50
+ };
51
+ };
52
+ type ControlItem = ControlsSection | Control | ElementControl;
40
53
  type ControlLayout = 'full' | 'two-columns' | 'custom';
41
54
 
55
+ type ExtendedWindow = Window & {
56
+ elementor?: {
57
+ selection?: {
58
+ getElements: () => V1Element[];
59
+ };
60
+ widgetsCache?: Record<string, V1ElementConfig>;
61
+ documents?: {
62
+ getCurrent?: () => {
63
+ container: V1Element;
64
+ } | undefined;
65
+ getCurrentId?: () => number;
66
+ };
67
+ getContainer?: (id: string) => V1Element | undefined;
68
+ };
69
+ elementorCommon?: {
70
+ helpers?: {
71
+ getUniqueId?: () => string;
72
+ };
73
+ };
74
+ };
42
75
  type V1Element = {
43
76
  id: string;
44
77
  model: V1Model<V1ElementModelProps>;
@@ -56,17 +89,41 @@ type V1Element = {
56
89
  };
57
90
  parent?: V1Element;
58
91
  };
92
+ type ElementInteractions = {
93
+ version: number;
94
+ items: InteractionItem[];
95
+ };
96
+ type InteractionItem = {
97
+ interaction_id?: string;
98
+ animation: {
99
+ animation_type: string;
100
+ animation_id: string;
101
+ };
102
+ };
59
103
  type V1ElementModelProps = {
104
+ isLocked?: boolean;
60
105
  widgetType?: string;
61
106
  elType: string;
62
107
  id: string;
63
108
  styles?: Record<StyleDefinitionID, StyleDefinition>;
64
109
  elements?: V1Model<V1ElementModelProps>[];
65
110
  settings?: V1ElementSettingsProps;
111
+ editor_settings?: V1ElementEditorSettingsProps;
112
+ interactions?: string | ElementInteractions;
113
+ };
114
+ type V1ElementData = Omit<V1ElementModelProps, 'elements'> & {
115
+ elements?: V1ElementData[];
116
+ };
117
+ type V1ElementEditorSettingsProps = {
118
+ title?: string;
119
+ initial_position?: number;
120
+ component_uid?: string;
66
121
  };
67
122
  type V1ElementSettingsProps = Record<string, PropValue>;
68
- type V1ElementConfig = {
123
+ type V1ElementConfig<T = object> = {
69
124
  title: string;
125
+ widgetType?: string;
126
+ elType?: string;
70
127
  controls: object;
71
128
  atomic?: boolean;
72
129
  atomic_controls?: ControlItem[];
@@ -76,7 +133,8 @@ type V1ElementConfig = {
76
133
  twig_main_template?: string;
77
134
  base_styles?: Record<string, StyleDefinition>;
78
135
  base_styles_dictionary?: Record<string, string>;
79
- };
136
+ atomic_style_states?: ClassState[];
137
+ } & T;
80
138
  type V1Model<T> = {
81
139
  get: <K extends keyof T>(key: K) => T[K];
82
140
  set: <K extends keyof T>(key: K, value: T[K]) => void;
@@ -85,10 +143,18 @@ type V1Model<T> = {
85
143
  }) => T;
86
144
  };
87
145
 
146
+ type ElementModel = {
147
+ id: string;
148
+ };
149
+ type ElementChildren = Record<string, ElementModel[]>;
150
+ declare function useElementChildren<T extends ElementChildren>(elementId: ElementID, childrenTypes: Record<string, string>): T;
151
+
152
+ declare const useElementEditorSettings: (elementId: ElementID) => V1ElementEditorSettingsProps;
153
+
88
154
  declare const useElementSetting: <TValue>(elementId: ElementID, settingKey: string) => TValue | null;
89
155
  declare const useElementSettings: <TValue>(elementId: ElementID, settingKeys: string[]) => Record<string, TValue>;
90
156
 
91
- declare function useElementType(type?: string): ElementType | null;
157
+ declare function useParentElement(elementId: string | null): any;
92
158
 
93
159
  declare function useSelectedElement(): {
94
160
  element: null;
@@ -98,22 +164,14 @@ declare function useSelectedElement(): {
98
164
  elementType: ElementType;
99
165
  };
100
166
 
101
- declare function useParentElement(elementId: string | null): V1Element | null | undefined;
102
-
103
- type ElementModel = {
104
- id: string;
105
- };
106
- type ElementChildren = Record<string, ElementModel[]>;
107
- declare function useElementChildren<T extends ElementChildren>(elementId: ElementID, childrenTypes: (keyof T & string)[]): T;
108
-
109
- type Options$2 = {
167
+ type Options$4 = {
110
168
  useHistory?: boolean;
111
169
  at?: number;
112
170
  clone?: boolean;
113
171
  };
114
172
  type CreateElementParams = {
115
173
  containerId: string;
116
- options?: Options$2;
174
+ options?: Options$4;
117
175
  model?: Omit<V1ElementModelProps, 'settings' | 'id'> & {
118
176
  settings?: V1ElementSettingsProps;
119
177
  id?: string;
@@ -121,17 +179,6 @@ type CreateElementParams = {
121
179
  };
122
180
  declare function createElement({ containerId, model, options }: CreateElementParams): V1Element;
123
181
 
124
- type Options$1 = {
125
- useHistory?: boolean;
126
- at?: number;
127
- clone?: boolean;
128
- };
129
- type DuplicateElementParams = {
130
- elementId: string;
131
- options?: Options$1;
132
- };
133
- declare function duplicateElement({ elementId, options }: DuplicateElementParams): V1Element;
134
-
135
182
  type CreateNestedElementsParams = {
136
183
  elements: CreateElementParams[];
137
184
  title: string;
@@ -148,11 +195,46 @@ type CreatedElementsResult = {
148
195
 
149
196
  declare const createElements: ({ elements, title, subtitle, }: CreateNestedElementsParams) => CreatedElementsResult;
150
197
 
198
+ type Options$3 = {
199
+ useHistory?: boolean;
200
+ at?: number;
201
+ };
202
+ declare function deleteElement({ elementId, options, }: {
203
+ elementId: string;
204
+ options?: Options$3;
205
+ }): Promise<void>;
206
+
207
+ type Options$2 = {
208
+ useHistory?: boolean;
209
+ at?: number;
210
+ scrollIntoView: boolean;
211
+ };
212
+ type DropElementParams = {
213
+ containerId: string;
214
+ options?: Options$2;
215
+ model?: Omit<V1ElementModelProps, 'settings' | 'id'> & {
216
+ settings?: V1ElementSettingsProps;
217
+ id?: string;
218
+ };
219
+ };
220
+ declare function dropElement({ containerId, model, options }: DropElementParams): V1Element;
221
+
222
+ type Options$1 = {
223
+ useHistory?: boolean;
224
+ at?: number;
225
+ clone?: boolean;
226
+ };
227
+ type DuplicateElementParams = {
228
+ elementId: string;
229
+ options?: Options$1;
230
+ };
231
+ declare function duplicateElement({ elementId, options }: DuplicateElementParams): V1Element;
232
+
151
233
  type DuplicateElementsParams = {
152
234
  elementIds: string[];
153
235
  title: string;
154
236
  subtitle?: string;
155
- onCreate?: (duplicatedElements: DuplicatedElement[]) => DuplicatedElement[];
237
+ onCreate?: (duplicatedElements: DuplicatedElement[]) => void;
156
238
  };
157
239
  type DuplicatedElement = {
158
240
  id: string;
@@ -166,21 +248,77 @@ type DuplicatedElementsResult = {
166
248
  duplicatedElements: DuplicatedElement[];
167
249
  };
168
250
 
169
- declare const duplicateElements: ({ elementIds, title, subtitle, onCreate, }: DuplicateElementsParams) => DuplicatedElementsResult;
251
+ declare const duplicateElements: ({ elementIds, title, subtitle, }: DuplicateElementsParams) => DuplicatedElementsResult;
252
+
253
+ declare const generateElementId: () => string;
254
+
255
+ declare function getContainer(id: string): V1Element | null;
256
+ declare const selectElement: (elementId: string) => void;
257
+
258
+ declare function getCurrentDocumentContainer(): V1Element | null;
259
+
260
+ declare function getCurrentDocumentId(): number | null;
261
+
262
+ declare function getElementEditorSettings(elementId: ElementID): V1ElementEditorSettingsProps;
263
+
264
+ declare function getElementLabel(elementId?: ElementID): string;
265
+
266
+ declare const getElementSetting: <TValue>(elementId: ElementID, settingKey: string) => TValue | null;
267
+ declare const getElementSettings: <TValue>(elementId: ElementID, settingKey: string[]) => Record<string, TValue | null>;
268
+
269
+ declare const getElementStyles: (elementID: ElementID) => Record<string, StyleDefinition> | null;
270
+
271
+ declare function getElementType(type: string): ElementType | null;
272
+
273
+ declare function getElements(root?: ElementID): V1Element[];
274
+
275
+ declare function getSelectedElements(): Element[];
276
+
277
+ type WidgetsCache<T> = Record<string, T>;
278
+ declare function getWidgetsCache<T extends V1ElementConfig>(): WidgetsCache<T> | null;
170
279
 
171
280
  type Options = {
172
281
  useHistory?: boolean;
173
282
  at?: number;
283
+ edit?: boolean;
174
284
  };
175
- declare function deleteElement({ elementId, options }: {
285
+ type MoveElementParams = {
176
286
  elementId: string;
287
+ targetContainerId: string;
177
288
  options?: Options;
178
- }): void;
289
+ };
290
+ declare function moveElement({ elementId, targetContainerId, options }: MoveElementParams): V1Element;
291
+
292
+ type MoveElementsParams = {
293
+ moves: MoveElementParams[];
294
+ title: string;
295
+ subtitle?: string;
296
+ onMoveElements?: () => void;
297
+ onRestoreElements?: () => void;
298
+ };
299
+ type OriginalPosition = {
300
+ elementId: string;
301
+ originalContainerId: string;
302
+ originalIndex: number;
303
+ };
304
+ type MovedElement = {
305
+ elementId: string;
306
+ originalPosition: OriginalPosition;
307
+ move: MoveElementParams;
308
+ element: V1Element;
309
+ };
310
+ type MovedElementsResult = {
311
+ movedElements: MovedElement[];
312
+ };
313
+
314
+ declare const moveElements: ({ moves: movesToMake, title, subtitle, onMoveElements, onRestoreElements, }: MoveElementsParams) => MovedElementsResult;
179
315
 
180
316
  type RemoveNestedElementsParams = {
181
317
  elementIds: string[];
182
318
  title: string;
183
319
  subtitle?: string;
320
+ onRemoveElements?: () => void;
321
+ onRestoreElements?: () => void;
184
322
  };
185
323
  type RemovedElement = {
186
324
  elementId: string;
@@ -193,25 +331,19 @@ type RemovedElementsResult = {
193
331
  removedElements: RemovedElement[];
194
332
  };
195
333
 
196
- declare const removeElements: ({ elementIds, title, subtitle, }: RemoveNestedElementsParams) => RemovedElementsResult;
197
-
198
- declare function getContainer(id: string): V1Element | null;
199
- declare const selectElement: (elementId: string) => void;
200
-
201
- declare const getElementSetting: <TValue>(elementId: ElementID, settingKey: string) => TValue | null;
202
- declare const getElementSettings: <TValue>(elementId: ElementID, settingKey: string[]) => Record<string, TValue | null>;
203
-
204
- declare const getElementStyles: (elementID: ElementID) => Record<string, StyleDefinition> | null;
205
-
206
- declare function getElementLabel(elementId: ElementID): string;
207
-
208
- declare function getElements(root?: ElementID): V1Element[];
209
-
210
- declare function getCurrentDocumentId(): number | null;
334
+ declare const removeElements: ({ elementIds, title, subtitle, onRemoveElements, onRestoreElements, }: RemoveNestedElementsParams) => RemovedElementsResult;
211
335
 
212
- declare function getSelectedElements(): Element[];
336
+ type ReplaceElementArgs = {
337
+ currentElement: V1ElementData;
338
+ newElement: Omit<V1ElementModelProps, 'id'>;
339
+ withHistory?: boolean;
340
+ };
341
+ declare const replaceElement: ({ currentElement, newElement, withHistory }: ReplaceElementArgs) => void;
213
342
 
214
- declare function getWidgetsCache(): Record<string, V1ElementConfig> | null;
343
+ declare const updateElementEditorSettings: ({ elementId, settings, }: {
344
+ elementId: string;
345
+ settings: V1ElementModelProps["editor_settings"];
346
+ }) => void;
215
347
 
216
348
  type UpdateElementSettingsArgs = {
217
349
  id: ElementID;
@@ -220,14 +352,19 @@ type UpdateElementSettingsArgs = {
220
352
  };
221
353
  declare const updateElementSettings: ({ id, props, withHistory }: UpdateElementSettingsArgs) => void;
222
354
 
223
- declare const generateElementId: () => string;
224
-
225
- type ReplaceElementArgs = {
226
- currentElement: V1Element;
227
- newElement: Omit<V1ElementModelProps, 'id'>;
228
- withHistory?: boolean;
355
+ type LinkInLinkRestriction = {
356
+ shouldRestrict: true;
357
+ reason: 'ancestor' | 'descendant';
358
+ elementId: string | null;
359
+ } | {
360
+ shouldRestrict: false;
361
+ reason?: never;
362
+ elementId?: never;
229
363
  };
230
- declare const replaceElement: ({ currentElement, newElement, withHistory }: ReplaceElementArgs) => void;
364
+ declare function getLinkInLinkRestriction(elementId: string): LinkInLinkRestriction;
365
+ declare function getAnchoredDescendantId(elementId: string): string | null;
366
+ declare function getAnchoredAncestorId(elementId: string): string | null;
367
+ declare function isElementAnchored(elementId: string): boolean;
231
368
 
232
369
  declare const ELEMENT_STYLE_CHANGE_EVENT = "elementor/editor-v2/editor-elements/style";
233
370
  declare const styleRerenderEvents: (_elementor_editor_v1_adapters.CommandEventDescriptor | _elementor_editor_v1_adapters.WindowEventDescriptor)[];
@@ -248,6 +385,8 @@ declare function shouldCreateNewLocalStyle<T>(payload: {
248
385
  provider: T | null;
249
386
  } | null): boolean;
250
387
 
388
+ declare function deleteElementStyle(elementId: ElementID, styleId: StyleDefinitionID): void;
389
+
251
390
  type UpdateElementStyleArgs = {
252
391
  elementId: ElementID;
253
392
  styleId: StyleDefinition['id'];
@@ -257,20 +396,16 @@ type UpdateElementStyleArgs = {
257
396
  };
258
397
  declare function updateElementStyle(args: UpdateElementStyleArgs): void;
259
398
 
260
- declare function deleteElementStyle(elementId: ElementID, styleId: StyleDefinitionID): void;
399
+ declare const useElementInteractions: (elementId: ElementID) => ElementInteractions;
261
400
 
262
- type LinkInLinkRestriction = {
263
- shouldRestrict: true;
264
- reason: 'ancestor' | 'descendant';
265
- elementId: string | null;
266
- } | {
267
- shouldRestrict: false;
268
- reason?: never;
269
- elementId?: never;
270
- };
271
- declare function getLinkInLinkRestriction(elementId: string): LinkInLinkRestriction;
272
- declare function getAnchoredDescendantId(elementId: string): string | null;
273
- declare function getAnchoredAncestorId(elementId: string): string | null;
274
- declare function isElementAnchored(elementId: string): boolean;
401
+ declare function getElementInteractions(elementId: ElementID): ElementInteractions | undefined;
402
+
403
+ declare const updateElementInteractions: ({ elementId, interactions, }: {
404
+ elementId: string;
405
+ interactions: V1ElementModelProps["interactions"];
406
+ }) => void;
407
+ declare const playElementInteractions: (elementId: string, animationId: string) => void;
408
+
409
+ declare function initMcp(): void;
275
410
 
276
- export { type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementID, type ElementType, type LinkInLinkRestriction, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, duplicateElement, duplicateElements, generateElementId, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentId, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, removeElements, replaceElement, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementSettings, updateElementStyle, useElementChildren, useElementSetting, useElementSettings, useElementType, useParentElement, useSelectedElement };
411
+ export { type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementInteractions, type ElementModel, type ElementType, type ExtendedWindow, type InteractionItem, type LinkInLinkRestriction, type MoveElementParams, type MoveElementsParams, type MovedElement, type MovedElementsResult, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementEditorSettingsProps, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, generateElementId, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getElementEditorSettings, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementType, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, initMcp as initElementsMcp, isElementAnchored, moveElement, moveElements, playElementInteractions, removeElements, replaceElement, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useElementInteractions, useElementSetting, useElementSettings, useParentElement, useSelectedElement };