@elementor/editor-elements 3.33.0-272 → 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 +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +11 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/sync/move-elements.ts +11 -0
- package/src/sync/remove-elements.ts +9 -9
|
@@ -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
|
},
|