@elementor/editor-elements 3.33.0-272 → 3.33.0-274
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 +37 -5
- package/dist/index.d.ts +37 -5
- package/dist/index.js +15 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/hooks/use-element-interactions.ts +4 -3
- package/src/index.ts +1 -7
- package/src/sync/get-element-interactions.ts +4 -3
- package/src/sync/move-elements.ts +11 -0
- package/src/sync/remove-elements.ts +9 -9
- package/src/sync/types.ts +13 -1
package/src/index.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
// types
|
|
2
|
-
export type {
|
|
3
|
-
V1Element,
|
|
4
|
-
V1ElementConfig,
|
|
5
|
-
V1ElementData,
|
|
6
|
-
V1ElementModelProps,
|
|
7
|
-
V1ElementSettingsProps,
|
|
8
|
-
} from './sync/types';
|
|
9
2
|
export * from './types';
|
|
3
|
+
export type * from './sync/types';
|
|
10
4
|
|
|
11
5
|
// hooks
|
|
12
6
|
export { useElementChildren, type ElementChildren, type ElementModel } from './hooks/use-element-children';
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { type ElementID } from '../types';
|
|
2
2
|
import { getContainer } from './get-container';
|
|
3
|
+
import { type ElementInteractions } from './types';
|
|
3
4
|
|
|
4
|
-
export function getElementInteractions( elementId: ElementID ) {
|
|
5
|
+
export function getElementInteractions( elementId: ElementID ): ElementInteractions | undefined {
|
|
5
6
|
const container = getContainer( elementId );
|
|
6
7
|
|
|
7
8
|
const interactions = container?.model?.get( 'interactions' );
|
|
8
9
|
|
|
9
10
|
if ( typeof interactions === 'string' ) {
|
|
10
|
-
return interactions;
|
|
11
|
+
return JSON.parse( interactions ) as ElementInteractions;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
return
|
|
14
|
+
return interactions;
|
|
14
15
|
}
|
|
@@ -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
|
@@ -44,6 +44,18 @@ export type V1Element = {
|
|
|
44
44
|
parent?: V1Element;
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
export type ElementInteractions = {
|
|
48
|
+
version: number;
|
|
49
|
+
items: InteractionItem[];
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type InteractionItem = {
|
|
53
|
+
animation: {
|
|
54
|
+
animation_type: string;
|
|
55
|
+
animation_id: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
|
|
47
59
|
export type V1ElementModelProps = {
|
|
48
60
|
widgetType?: string;
|
|
49
61
|
elType: string;
|
|
@@ -52,7 +64,7 @@ export type V1ElementModelProps = {
|
|
|
52
64
|
elements?: V1Model< V1ElementModelProps >[];
|
|
53
65
|
settings?: V1ElementSettingsProps;
|
|
54
66
|
editor_settings?: V1ElementEditorSettingsProps;
|
|
55
|
-
interactions?: string |
|
|
67
|
+
interactions?: string | ElementInteractions;
|
|
56
68
|
};
|
|
57
69
|
|
|
58
70
|
export type V1ElementData = Omit< V1ElementModelProps, 'elements' > & {
|