@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 CHANGED
@@ -258,6 +258,8 @@ type MoveElementsParams = {
258
258
  moves: MoveElementParams[];
259
259
  title: string;
260
260
  subtitle?: string;
261
+ onMoveElements?: () => void;
262
+ onRestoreElements?: () => void;
261
263
  };
262
264
  type OriginalPosition = {
263
265
  elementId: string;
@@ -274,7 +276,7 @@ type MovedElementsResult = {
274
276
  movedElements: MovedElement[];
275
277
  };
276
278
 
277
- declare const moveElements: ({ moves: movesToMake, title, subtitle, }: MoveElementsParams) => MovedElementsResult;
279
+ declare const moveElements: ({ moves: movesToMake, title, subtitle, onMoveElements, onRestoreElements, }: MoveElementsParams) => MovedElementsResult;
278
280
 
279
281
  type RemoveNestedElementsParams = {
280
282
  elementIds: string[];
package/dist/index.d.ts CHANGED
@@ -258,6 +258,8 @@ type MoveElementsParams = {
258
258
  moves: MoveElementParams[];
259
259
  title: string;
260
260
  subtitle?: string;
261
+ onMoveElements?: () => void;
262
+ onRestoreElements?: () => void;
261
263
  };
262
264
  type OriginalPosition = {
263
265
  elementId: string;
@@ -274,7 +276,7 @@ type MovedElementsResult = {
274
276
  movedElements: MovedElement[];
275
277
  };
276
278
 
277
- declare const moveElements: ({ moves: movesToMake, title, subtitle, }: MoveElementsParams) => MovedElementsResult;
279
+ declare const moveElements: ({ moves: movesToMake, title, subtitle, onMoveElements, onRestoreElements, }: MoveElementsParams) => MovedElementsResult;
278
280
 
279
281
  type RemoveNestedElementsParams = {
280
282
  elementIds: string[];
package/dist/index.js CHANGED
@@ -574,7 +574,9 @@ var import_i18n3 = require("@wordpress/i18n");
574
574
  var moveElements = ({
575
575
  moves: movesToMake,
576
576
  title,
577
- subtitle = (0, import_i18n3.__)("Elements moved", "elementor")
577
+ subtitle = (0, import_i18n3.__)("Elements moved", "elementor"),
578
+ onMoveElements,
579
+ onRestoreElements
578
580
  }) => {
579
581
  const undoableMove = (0, import_editor_v1_adapters12.undoable)(
580
582
  {
@@ -597,6 +599,7 @@ var moveElements = ({
597
599
  ...move,
598
600
  options: { ...move.options, useHistory: false }
599
601
  });
602
+ onMoveElements?.();
600
603
  movedElements.push({
601
604
  elementId,
602
605
  originalPosition,
@@ -609,6 +612,7 @@ var moveElements = ({
609
612
  undo: (_, { movedElements }) => {
610
613
  [...movedElements].reverse().forEach(({ originalPosition }) => {
611
614
  const { elementId, originalContainerId, originalIndex } = originalPosition;
615
+ onRestoreElements?.();
612
616
  moveElement({
613
617
  elementId,
614
618
  targetContainerId: originalContainerId,
@@ -626,6 +630,7 @@ var moveElements = ({
626
630
  ...move,
627
631
  options: { ...move.options, useHistory: false }
628
632
  });
633
+ onMoveElements?.();
629
634
  newMovedElements.push({
630
635
  elementId: move.elementId,
631
636
  originalPosition,
@@ -672,18 +677,17 @@ var removeElements = ({
672
677
  });
673
678
  }
674
679
  });
675
- const results = elementIdsParam.map((elementId) => {
676
- return deleteElement({
680
+ onRemoveElements?.();
681
+ elementIdsParam.forEach((elementId) => {
682
+ deleteElement({
677
683
  elementId,
678
684
  options: { useHistory: false }
679
685
  });
680
686
  });
681
- Promise.all(results).then(() => {
682
- onRemoveElements?.();
683
- });
684
687
  return { elementIds: elementIdsParam, removedElements };
685
688
  },
686
689
  undo: (_, { removedElements }) => {
690
+ onRestoreElements?.();
687
691
  [...removedElements].reverse().forEach(({ model, parent, at }) => {
688
692
  if (parent && model) {
689
693
  createElement({
@@ -693,16 +697,15 @@ var removeElements = ({
693
697
  });
694
698
  }
695
699
  });
696
- onRestoreElements?.();
697
700
  },
698
701
  redo: (_, { elementIds: originalElementIds, removedElements }) => {
702
+ onRemoveElements?.();
699
703
  originalElementIds.forEach((elementId) => {
700
704
  deleteElement({
701
705
  elementId,
702
706
  options: { useHistory: false }
703
707
  });
704
708
  });
705
- onRemoveElements?.();
706
709
  return { elementIds: originalElementIds, removedElements };
707
710
  }
708
711
  },