@elementor/editor-elements 3.33.0-267 → 3.33.0-269

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-elements",
3
3
  "description": "This package contains the elements model for the Elementor editor",
4
- "version": "3.33.0-267",
4
+ "version": "3.33.0-269",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -40,12 +40,12 @@
40
40
  "dev": "tsup --config=../../tsup.dev.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@elementor/editor-mcp": "3.33.0-267",
44
- "@elementor/editor-props": "3.33.0-267",
45
- "@elementor/editor-styles": "3.33.0-267",
46
- "@elementor/editor-v1-adapters": "3.33.0-267",
47
- "@elementor/schema": "3.33.0-267",
48
- "@elementor/utils": "3.33.0-267",
43
+ "@elementor/editor-mcp": "3.33.0-269",
44
+ "@elementor/editor-props": "3.33.0-269",
45
+ "@elementor/editor-styles": "3.33.0-269",
46
+ "@elementor/editor-v1-adapters": "3.33.0-269",
47
+ "@elementor/schema": "3.33.0-269",
48
+ "@elementor/utils": "3.33.0-269",
49
49
  "@wordpress/i18n": "^3.1.0"
50
50
  },
51
51
  "peerDependencies": {
@@ -7,14 +7,20 @@ type Options = {
7
7
  at?: number;
8
8
  };
9
9
 
10
- export function deleteElement( { elementId, options = {} }: { elementId: string; options?: Options } ): void {
10
+ export function deleteElement( {
11
+ elementId,
12
+ options = {},
13
+ }: {
14
+ elementId: string;
15
+ options?: Options;
16
+ } ): Promise< void > {
11
17
  const container = getContainer( elementId );
12
18
 
13
19
  if ( ! container ) {
14
20
  throw new Error( `Element with ID "${ elementId }" not found` );
15
21
  }
16
22
 
17
- runCommand( 'document/elements/delete', {
23
+ return runCommand( 'document/elements/delete', {
18
24
  container,
19
25
  options,
20
26
  } );
@@ -10,6 +10,8 @@ type RemoveNestedElementsParams = {
10
10
  elementIds: string[];
11
11
  title: string;
12
12
  subtitle?: string;
13
+ onRemoveElements?: () => void;
14
+ onRestoreElements?: () => void;
13
15
  };
14
16
 
15
17
  type RemovedElement = {
@@ -30,6 +32,8 @@ export const removeElements = ( {
30
32
  elementIds,
31
33
  title,
32
34
  subtitle = __( 'Item removed', 'elementor' ),
35
+ onRemoveElements,
36
+ onRestoreElements,
33
37
  }: RemoveNestedElementsParams ): RemovedElementsResult => {
34
38
  const undoableRemove = undoable(
35
39
  {
@@ -54,13 +58,18 @@ export const removeElements = ( {
54
58
  }
55
59
  } );
56
60
 
57
- elementIdsParam.forEach( ( elementId ) => {
58
- deleteElement( {
61
+ const results = elementIdsParam.map( ( elementId ) => {
62
+ return deleteElement( {
59
63
  elementId,
60
64
  options: { useHistory: false },
61
65
  } );
62
66
  } );
63
67
 
68
+ // Wait for all elements to be deleted to avoid conflicts between commands
69
+ Promise.all( results ).then( () => {
70
+ onRemoveElements?.();
71
+ } );
72
+
64
73
  return { elementIds: elementIdsParam, removedElements };
65
74
  },
66
75
  undo: ( _: { elementIds: string[] }, { removedElements }: RemovedElementsResult ) => {
@@ -74,6 +83,7 @@ export const removeElements = ( {
74
83
  } );
75
84
  }
76
85
  } );
86
+ onRestoreElements?.();
77
87
  },
78
88
  redo: (
79
89
  _: { elementIds: string[] },
@@ -86,6 +96,7 @@ export const removeElements = ( {
86
96
  } );
87
97
  } );
88
98
 
99
+ onRemoveElements?.();
89
100
  return { elementIds: originalElementIds, removedElements };
90
101
  },
91
102
  },