@elementor/editor-elements 3.33.0-271 → 3.33.0-273
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/dist/index.d.mts +125 -122
- package/dist/index.d.ts +125 -122
- package/dist/index.js +478 -469
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +486 -477
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/index.ts +35 -35
- package/src/sync/get-widgets-cache.ts +4 -3
- package/src/sync/move-elements.ts +11 -0
- package/src/sync/remove-elements.ts +9 -9
- package/src/sync/types.ts +2 -2
package/src/index.ts
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
1
|
// types
|
|
2
|
-
export * from './types';
|
|
3
2
|
export type {
|
|
4
3
|
V1Element,
|
|
4
|
+
V1ElementConfig,
|
|
5
5
|
V1ElementData,
|
|
6
6
|
V1ElementModelProps,
|
|
7
7
|
V1ElementSettingsProps,
|
|
8
|
-
V1ElementConfig,
|
|
9
8
|
} from './sync/types';
|
|
9
|
+
export * from './types';
|
|
10
10
|
|
|
11
11
|
// hooks
|
|
12
|
-
export { useElementSetting, useElementSettings } from './hooks/use-element-setting';
|
|
13
|
-
export { useSelectedElement } from './hooks/use-selected-element';
|
|
14
|
-
export { useParentElement } from './hooks/use-parent-element';
|
|
15
12
|
export { useElementChildren, type ElementChildren, type ElementModel } from './hooks/use-element-children';
|
|
16
13
|
export { useElementEditorSettings } from './hooks/use-element-editor-settings';
|
|
14
|
+
export { useElementSetting, useElementSettings } from './hooks/use-element-setting';
|
|
15
|
+
export { useParentElement } from './hooks/use-parent-element';
|
|
16
|
+
export { useSelectedElement } from './hooks/use-selected-element';
|
|
17
17
|
|
|
18
18
|
// utils
|
|
19
19
|
export { createElement, type CreateElementParams } from './sync/create-element';
|
|
20
|
-
export { updateElementEditorSettings } from './sync/update-element-editor-settings';
|
|
21
|
-
export { moveElement, type MoveElementParams } from './sync/move-element';
|
|
22
|
-
export {
|
|
23
|
-
moveElements,
|
|
24
|
-
type MoveElementsParams,
|
|
25
|
-
type MovedElement,
|
|
26
|
-
type MovedElementsResult,
|
|
27
|
-
} from './sync/move-elements';
|
|
28
|
-
export { duplicateElement, type DuplicateElementParams } from './sync/duplicate-element';
|
|
29
20
|
export { createElements } from './sync/create-elements';
|
|
21
|
+
export { deleteElement } from './sync/delete-element';
|
|
22
|
+
export { dropElement, type DropElementParams } from './sync/drop-element';
|
|
23
|
+
export { duplicateElement, type DuplicateElementParams } from './sync/duplicate-element';
|
|
30
24
|
export {
|
|
31
25
|
duplicateElements,
|
|
32
|
-
type DuplicateElementsParams,
|
|
33
26
|
type DuplicatedElement,
|
|
34
27
|
type DuplicatedElementsResult,
|
|
28
|
+
type DuplicateElementsParams,
|
|
35
29
|
} from './sync/duplicate-elements';
|
|
36
|
-
export {
|
|
37
|
-
export { removeElements } from './sync/remove-elements';
|
|
30
|
+
export { generateElementId } from './sync/generate-element-id';
|
|
38
31
|
export { getContainer, selectElement } from './sync/get-container';
|
|
39
|
-
export {
|
|
40
|
-
export {
|
|
32
|
+
export { getCurrentDocumentContainer } from './sync/get-current-document-container';
|
|
33
|
+
export { getCurrentDocumentId } from './sync/get-current-document-id';
|
|
41
34
|
export { getElementEditorSettings } from './sync/get-element-editor-settings';
|
|
42
|
-
export { getElementStyles } from './sync/get-element-styles';
|
|
43
35
|
export { getElementLabel } from './sync/get-element-label';
|
|
36
|
+
export { getElementSetting, getElementSettings } from './sync/get-element-setting';
|
|
37
|
+
export { getElementStyles } from './sync/get-element-styles';
|
|
38
|
+
export { getElementType } from './sync/get-element-type';
|
|
44
39
|
export { getElements } from './sync/get-elements';
|
|
45
|
-
export { getCurrentDocumentId } from './sync/get-current-document-id';
|
|
46
40
|
export { getSelectedElements } from './sync/get-selected-elements';
|
|
47
41
|
export { getWidgetsCache } from './sync/get-widgets-cache';
|
|
48
|
-
export {
|
|
49
|
-
export {
|
|
42
|
+
export { moveElement, type MoveElementParams } from './sync/move-element';
|
|
43
|
+
export {
|
|
44
|
+
moveElements,
|
|
45
|
+
type MovedElement,
|
|
46
|
+
type MovedElementsResult,
|
|
47
|
+
type MoveElementsParams,
|
|
48
|
+
} from './sync/move-elements';
|
|
49
|
+
export { removeElements } from './sync/remove-elements';
|
|
50
50
|
export { replaceElement } from './sync/replace-element';
|
|
51
|
-
export {
|
|
52
|
-
export {
|
|
51
|
+
export { updateElementEditorSettings } from './sync/update-element-editor-settings';
|
|
52
|
+
export { updateElementSettings, type UpdateElementSettingsArgs } from './sync/update-element-settings';
|
|
53
53
|
|
|
54
|
+
export {
|
|
55
|
+
getAnchoredAncestorId,
|
|
56
|
+
getAnchoredDescendantId,
|
|
57
|
+
getLinkInLinkRestriction,
|
|
58
|
+
isElementAnchored,
|
|
59
|
+
type LinkInLinkRestriction,
|
|
60
|
+
} from './link-restriction';
|
|
54
61
|
export { ELEMENT_STYLE_CHANGE_EVENT, styleRerenderEvents } from './styles/consts';
|
|
55
62
|
export {
|
|
56
63
|
createElementStyle,
|
|
57
64
|
shouldCreateNewLocalStyle,
|
|
58
65
|
type CreateElementStyleArgs,
|
|
59
66
|
} from './styles/create-element-style';
|
|
60
|
-
export { updateElementStyle, type UpdateElementStyleArgs } from './styles/update-element-style';
|
|
61
67
|
export { deleteElementStyle } from './styles/delete-element-style';
|
|
62
|
-
export {
|
|
63
|
-
isElementAnchored,
|
|
64
|
-
getAnchoredDescendantId,
|
|
65
|
-
getAnchoredAncestorId,
|
|
66
|
-
getLinkInLinkRestriction,
|
|
67
|
-
type LinkInLinkRestriction,
|
|
68
|
-
} from './link-restriction';
|
|
68
|
+
export { updateElementStyle, type UpdateElementStyleArgs } from './styles/update-element-style';
|
|
69
69
|
|
|
70
|
-
export { getElementInteractions } from './sync/get-element-interactions';
|
|
71
|
-
export { updateElementInteractions, playElementInteractions } from './sync/update-element-interactions';
|
|
72
70
|
export { useElementInteractions } from './hooks/use-element-interactions';
|
|
71
|
+
export { getElementInteractions } from './sync/get-element-interactions';
|
|
72
|
+
export { playElementInteractions, updateElementInteractions } from './sync/update-element-interactions';
|
|
73
73
|
|
|
74
74
|
export { initMcp as initElementsMcp } from './mcp';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { type ExtendedWindow } from '
|
|
1
|
+
import { type ExtendedWindow, type V1ElementConfig } from '../sync/types.js';
|
|
2
|
+
type WidgetsCache< T > = Record< string, T >;
|
|
2
3
|
|
|
3
|
-
export function getWidgetsCache() {
|
|
4
|
+
export function getWidgetsCache< T extends V1ElementConfig >(): WidgetsCache< T > | null {
|
|
4
5
|
const extendedWindow = window as unknown as ExtendedWindow;
|
|
5
6
|
|
|
6
|
-
return extendedWindow?.elementor?.widgetsCache || null;
|
|
7
|
+
return ( extendedWindow?.elementor?.widgetsCache as WidgetsCache< T > ) || null;
|
|
7
8
|
}
|
|
@@ -9,6 +9,8 @@ type MoveElementsParams = {
|
|
|
9
9
|
moves: MoveElementParams[];
|
|
10
10
|
title: string;
|
|
11
11
|
subtitle?: string;
|
|
12
|
+
onMoveElements?: () => void;
|
|
13
|
+
onRestoreElements?: () => void;
|
|
12
14
|
};
|
|
13
15
|
|
|
14
16
|
type OriginalPosition = {
|
|
@@ -34,6 +36,8 @@ export const moveElements = ( {
|
|
|
34
36
|
moves: movesToMake,
|
|
35
37
|
title,
|
|
36
38
|
subtitle = __( 'Elements moved', 'elementor' ),
|
|
39
|
+
onMoveElements,
|
|
40
|
+
onRestoreElements,
|
|
37
41
|
}: MoveElementsParams ): MovedElementsResult => {
|
|
38
42
|
const undoableMove = undoable(
|
|
39
43
|
{
|
|
@@ -62,6 +66,9 @@ export const moveElements = ( {
|
|
|
62
66
|
options: { ...move.options, useHistory: false },
|
|
63
67
|
} );
|
|
64
68
|
|
|
69
|
+
// Call onMoveElements before moving element to avoid conflicts between commands
|
|
70
|
+
onMoveElements?.();
|
|
71
|
+
|
|
65
72
|
movedElements.push( {
|
|
66
73
|
elementId,
|
|
67
74
|
originalPosition,
|
|
@@ -76,6 +83,8 @@ export const moveElements = ( {
|
|
|
76
83
|
[ ...movedElements ].reverse().forEach( ( { originalPosition } ) => {
|
|
77
84
|
const { elementId, originalContainerId, originalIndex } = originalPosition;
|
|
78
85
|
|
|
86
|
+
onRestoreElements?.();
|
|
87
|
+
|
|
79
88
|
moveElement( {
|
|
80
89
|
elementId,
|
|
81
90
|
targetContainerId: originalContainerId,
|
|
@@ -98,6 +107,8 @@ export const moveElements = ( {
|
|
|
98
107
|
options: { ...move.options, useHistory: false },
|
|
99
108
|
} );
|
|
100
109
|
|
|
110
|
+
onMoveElements?.();
|
|
111
|
+
|
|
101
112
|
newMovedElements.push( {
|
|
102
113
|
elementId: move.elementId,
|
|
103
114
|
originalPosition,
|
|
@@ -58,21 +58,21 @@ export const removeElements = ( {
|
|
|
58
58
|
}
|
|
59
59
|
} );
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
// Call onRemoveElements before deleting elements to avoid conflicts between commands
|
|
62
|
+
onRemoveElements?.();
|
|
63
|
+
|
|
64
|
+
elementIdsParam.forEach( ( elementId ) => {
|
|
65
|
+
deleteElement( {
|
|
63
66
|
elementId,
|
|
64
67
|
options: { useHistory: false },
|
|
65
68
|
} );
|
|
66
69
|
} );
|
|
67
70
|
|
|
68
|
-
// Wait for all elements to be deleted to avoid conflicts between commands
|
|
69
|
-
Promise.all( results ).then( () => {
|
|
70
|
-
onRemoveElements?.();
|
|
71
|
-
} );
|
|
72
|
-
|
|
73
71
|
return { elementIds: elementIdsParam, removedElements };
|
|
74
72
|
},
|
|
75
73
|
undo: ( _: { elementIds: string[] }, { removedElements }: RemovedElementsResult ) => {
|
|
74
|
+
onRestoreElements?.();
|
|
75
|
+
|
|
76
76
|
// Restore elements in reverse order to maintain proper hierarchy
|
|
77
77
|
[ ...removedElements ].reverse().forEach( ( { model, parent, at } ) => {
|
|
78
78
|
if ( parent && model ) {
|
|
@@ -83,12 +83,13 @@ export const removeElements = ( {
|
|
|
83
83
|
} );
|
|
84
84
|
}
|
|
85
85
|
} );
|
|
86
|
-
onRestoreElements?.();
|
|
87
86
|
},
|
|
88
87
|
redo: (
|
|
89
88
|
_: { elementIds: string[] },
|
|
90
89
|
{ elementIds: originalElementIds, removedElements }: RemovedElementsResult
|
|
91
90
|
): RemovedElementsResult => {
|
|
91
|
+
onRemoveElements?.();
|
|
92
|
+
|
|
92
93
|
originalElementIds.forEach( ( elementId ) => {
|
|
93
94
|
deleteElement( {
|
|
94
95
|
elementId,
|
|
@@ -96,7 +97,6 @@ export const removeElements = ( {
|
|
|
96
97
|
} );
|
|
97
98
|
} );
|
|
98
99
|
|
|
99
|
-
onRemoveElements?.();
|
|
100
100
|
return { elementIds: originalElementIds, removedElements };
|
|
101
101
|
},
|
|
102
102
|
},
|
package/src/sync/types.ts
CHANGED
|
@@ -66,7 +66,7 @@ export type V1ElementEditorSettingsProps = {
|
|
|
66
66
|
|
|
67
67
|
export type V1ElementSettingsProps = Record< string, PropValue >;
|
|
68
68
|
|
|
69
|
-
export type V1ElementConfig = {
|
|
69
|
+
export type V1ElementConfig< T = object > = {
|
|
70
70
|
title: string;
|
|
71
71
|
controls: object;
|
|
72
72
|
atomic?: boolean;
|
|
@@ -78,7 +78,7 @@ export type V1ElementConfig = {
|
|
|
78
78
|
base_styles?: Record< string, StyleDefinition >;
|
|
79
79
|
base_styles_dictionary?: Record< string, string >;
|
|
80
80
|
atomic_style_states?: ClassState[];
|
|
81
|
-
};
|
|
81
|
+
} & T;
|
|
82
82
|
|
|
83
83
|
type V1Model< T > = {
|
|
84
84
|
get: < K extends keyof T >( key: K ) => T[ K ];
|