@elementor/editor-elements 4.1.0-725 → 4.1.0-727

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
@@ -58,6 +58,19 @@ type ControlItem = ControlsSection | Control | ElementControl;
58
58
  type ControlLayout = 'full' | 'two-columns' | 'custom';
59
59
 
60
60
  type ExtendedWindow = Window & {
61
+ $e?: {
62
+ components?: {
63
+ get?: (name: string) => {
64
+ utils?: {
65
+ findModelById?: (id: string, collection?: unknown) => BackboneModel | null;
66
+ addModelToParent?: (parentId: string, childData: unknown, options?: {
67
+ at?: number;
68
+ }) => boolean;
69
+ removeModelFromParent?: (parentId: string, childId: string) => boolean;
70
+ };
71
+ };
72
+ };
73
+ };
61
74
  elementor?: {
62
75
  selection?: {
63
76
  getElements: () => V1Element[];
@@ -70,6 +83,9 @@ type ExtendedWindow = Window & {
70
83
  getCurrentId?: () => number;
71
84
  };
72
85
  getContainer?: (id: string) => V1Element | undefined;
86
+ helpers?: {
87
+ isAtomicWidget?: (model: unknown) => boolean;
88
+ };
73
89
  };
74
90
  elementorCommon?: {
75
91
  helpers?: {
@@ -77,6 +93,17 @@ type ExtendedWindow = Window & {
77
93
  };
78
94
  };
79
95
  };
96
+ type BackboneModel = {
97
+ get: (key: string) => unknown;
98
+ set: (key: string, value: unknown) => void;
99
+ toJSON: () => Record<string, unknown>;
100
+ };
101
+ type BackboneCollection = {
102
+ models: BackboneModel[];
103
+ add: (model: unknown, options?: Record<string, unknown>) => void;
104
+ remove: (model: BackboneModel, options?: Record<string, unknown>) => void;
105
+ findWhere: (attrs: Record<string, unknown>) => BackboneModel | undefined;
106
+ };
80
107
  type V1Element = {
81
108
  id: string;
82
109
  model: V1Model$1<V1ElementModelProps>;
@@ -267,6 +294,8 @@ type CreatedElement = {
267
294
  parentContainer: V1Element;
268
295
  model: V1ElementModelProps;
269
296
  options?: CreateElementParams['options'];
297
+ containerId: string;
298
+ parentContainerId: string;
270
299
  };
271
300
  type CreatedElementsResult = {
272
301
  createdElements: CreatedElement[];
@@ -322,6 +351,8 @@ type DuplicatedElement = {
322
351
  parentContainer: V1Element;
323
352
  model: V1ElementModelProps;
324
353
  at?: number;
354
+ containerId: string;
355
+ parentContainerId: string;
325
356
  };
326
357
  type DuplicatedElementsResult = {
327
358
  duplicatedElements: DuplicatedElement[];
@@ -400,6 +431,9 @@ type MovedElement = {
400
431
  originalIndex: number;
401
432
  targetContainer: V1Element;
402
433
  options?: MoveOptions;
434
+ elementId: string;
435
+ originalContainerId: string;
436
+ targetContainerId: string;
403
437
  };
404
438
  type MovedElementsResult = {
405
439
  movedElements: MovedElement[];
@@ -419,6 +453,8 @@ type RemovedElement = {
419
453
  parent: V1Element;
420
454
  model: V1ElementModelProps;
421
455
  at: number;
456
+ containerId: string;
457
+ parentId: string;
422
458
  };
423
459
  type RemovedElementsResult = {
424
460
  removedElements: RemovedElement[];
@@ -497,4 +533,4 @@ declare const updateElementInteractions: ({ elementId, interactions, }: {
497
533
  }) => void;
498
534
  declare const playElementInteractions: (elementId: string, interactionId: string) => void;
499
535
 
500
- export { type AnimationPresetPropValue, type BooleanPropValue, type ConfigPropValue, type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementInteractions, type ElementModel, type ElementType, type ExcludedBreakpointsPropValue, type ExtendedWindow, type InteractionBreakpointsPropValue, type InteractionItemPropValue, type LinkInLinkRestriction, type ModelResult, type MoveElementParams, type NumberPropValue, type PseudoState, type StringPropValue, type TimingConfigPropValue, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementEditorSettingsProps, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, findChildRecursive, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementType, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, playElementInteractions, removeElements, replaceElement, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useParentElement, useSelectedElement, useSelectedElementSettings };
536
+ export { type AnimationPresetPropValue, type BackboneCollection, type BackboneModel, type BooleanPropValue, type ConfigPropValue, type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementInteractions, type ElementModel, type ElementType, type ExcludedBreakpointsPropValue, type ExtendedWindow, type InteractionBreakpointsPropValue, type InteractionItemPropValue, type LinkInLinkRestriction, type ModelResult, type MoveElementParams, type NumberPropValue, type PseudoState, type StringPropValue, type TimingConfigPropValue, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementEditorSettingsProps, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, findChildRecursive, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementType, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, playElementInteractions, removeElements, replaceElement, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useParentElement, useSelectedElement, useSelectedElementSettings };
package/dist/index.d.ts CHANGED
@@ -58,6 +58,19 @@ type ControlItem = ControlsSection | Control | ElementControl;
58
58
  type ControlLayout = 'full' | 'two-columns' | 'custom';
59
59
 
60
60
  type ExtendedWindow = Window & {
61
+ $e?: {
62
+ components?: {
63
+ get?: (name: string) => {
64
+ utils?: {
65
+ findModelById?: (id: string, collection?: unknown) => BackboneModel | null;
66
+ addModelToParent?: (parentId: string, childData: unknown, options?: {
67
+ at?: number;
68
+ }) => boolean;
69
+ removeModelFromParent?: (parentId: string, childId: string) => boolean;
70
+ };
71
+ };
72
+ };
73
+ };
61
74
  elementor?: {
62
75
  selection?: {
63
76
  getElements: () => V1Element[];
@@ -70,6 +83,9 @@ type ExtendedWindow = Window & {
70
83
  getCurrentId?: () => number;
71
84
  };
72
85
  getContainer?: (id: string) => V1Element | undefined;
86
+ helpers?: {
87
+ isAtomicWidget?: (model: unknown) => boolean;
88
+ };
73
89
  };
74
90
  elementorCommon?: {
75
91
  helpers?: {
@@ -77,6 +93,17 @@ type ExtendedWindow = Window & {
77
93
  };
78
94
  };
79
95
  };
96
+ type BackboneModel = {
97
+ get: (key: string) => unknown;
98
+ set: (key: string, value: unknown) => void;
99
+ toJSON: () => Record<string, unknown>;
100
+ };
101
+ type BackboneCollection = {
102
+ models: BackboneModel[];
103
+ add: (model: unknown, options?: Record<string, unknown>) => void;
104
+ remove: (model: BackboneModel, options?: Record<string, unknown>) => void;
105
+ findWhere: (attrs: Record<string, unknown>) => BackboneModel | undefined;
106
+ };
80
107
  type V1Element = {
81
108
  id: string;
82
109
  model: V1Model$1<V1ElementModelProps>;
@@ -267,6 +294,8 @@ type CreatedElement = {
267
294
  parentContainer: V1Element;
268
295
  model: V1ElementModelProps;
269
296
  options?: CreateElementParams['options'];
297
+ containerId: string;
298
+ parentContainerId: string;
270
299
  };
271
300
  type CreatedElementsResult = {
272
301
  createdElements: CreatedElement[];
@@ -322,6 +351,8 @@ type DuplicatedElement = {
322
351
  parentContainer: V1Element;
323
352
  model: V1ElementModelProps;
324
353
  at?: number;
354
+ containerId: string;
355
+ parentContainerId: string;
325
356
  };
326
357
  type DuplicatedElementsResult = {
327
358
  duplicatedElements: DuplicatedElement[];
@@ -400,6 +431,9 @@ type MovedElement = {
400
431
  originalIndex: number;
401
432
  targetContainer: V1Element;
402
433
  options?: MoveOptions;
434
+ elementId: string;
435
+ originalContainerId: string;
436
+ targetContainerId: string;
403
437
  };
404
438
  type MovedElementsResult = {
405
439
  movedElements: MovedElement[];
@@ -419,6 +453,8 @@ type RemovedElement = {
419
453
  parent: V1Element;
420
454
  model: V1ElementModelProps;
421
455
  at: number;
456
+ containerId: string;
457
+ parentId: string;
422
458
  };
423
459
  type RemovedElementsResult = {
424
460
  removedElements: RemovedElement[];
@@ -497,4 +533,4 @@ declare const updateElementInteractions: ({ elementId, interactions, }: {
497
533
  }) => void;
498
534
  declare const playElementInteractions: (elementId: string, interactionId: string) => void;
499
535
 
500
- export { type AnimationPresetPropValue, type BooleanPropValue, type ConfigPropValue, type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementInteractions, type ElementModel, type ElementType, type ExcludedBreakpointsPropValue, type ExtendedWindow, type InteractionBreakpointsPropValue, type InteractionItemPropValue, type LinkInLinkRestriction, type ModelResult, type MoveElementParams, type NumberPropValue, type PseudoState, type StringPropValue, type TimingConfigPropValue, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementEditorSettingsProps, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, findChildRecursive, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementType, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, playElementInteractions, removeElements, replaceElement, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useParentElement, useSelectedElement, useSelectedElementSettings };
536
+ export { type AnimationPresetPropValue, type BackboneCollection, type BackboneModel, type BooleanPropValue, type ConfigPropValue, type Control, type ControlItem, type ControlLayout, type ControlsSection, type CreateElementParams, type CreateElementStyleArgs, type DropElementParams, type DuplicateElementParams, type DuplicateElementsParams, type DuplicatedElement, type DuplicatedElementsResult, ELEMENT_STYLE_CHANGE_EVENT, type Element, type ElementChildren, type ElementControl, type ElementID, type ElementInteractions, type ElementModel, type ElementType, type ExcludedBreakpointsPropValue, type ExtendedWindow, type InteractionBreakpointsPropValue, type InteractionItemPropValue, type LinkInLinkRestriction, type ModelResult, type MoveElementParams, type NumberPropValue, type PseudoState, type StringPropValue, type TimingConfigPropValue, type UpdateElementSettingsArgs, type UpdateElementStyleArgs, type V1Element, type V1ElementConfig, type V1ElementData, type V1ElementEditorSettingsProps, type V1ElementModelProps, type V1ElementSettingsProps, createElement, createElementStyle, createElements, deleteElement, deleteElementStyle, dropElement, duplicateElement, duplicateElements, findChildRecursive, generateElementId, getAllDescendants, getAnchoredAncestorId, getAnchoredDescendantId, getContainer, getCurrentDocumentContainer, getCurrentDocumentId, getElementChildren as getElementChildrenWithFallback, getElementEditorSettings, getElementInteractions, getElementLabel, getElementSetting, getElementSettings, getElementStyles, getElementType, getElements, getLinkInLinkRestriction, getSelectedElements, getWidgetsCache, isElementAnchored, moveElement, moveElements, playElementInteractions, removeElements, replaceElement, selectElement, shouldCreateNewLocalStyle, styleRerenderEvents, updateElementEditorSettings, updateElementInteractions, updateElementSettings, updateElementStyle, useElementChildren, useElementEditorSettings, useParentElement, useSelectedElement, useSelectedElementSettings };
package/dist/index.js CHANGED
@@ -314,6 +314,37 @@ function deleteElement({ container, options = {} }) {
314
314
  });
315
315
  }
316
316
 
317
+ // src/sync/resolve-element.ts
318
+ function isConnected(container) {
319
+ if (!container) {
320
+ return false;
321
+ }
322
+ if (!container.view?.el) {
323
+ return true;
324
+ }
325
+ return container.view.el.isConnected;
326
+ }
327
+ function resolveContainer(container, id) {
328
+ const looked = container.lookup?.();
329
+ if (isConnected(looked)) {
330
+ return looked;
331
+ }
332
+ const byId = getContainer(id);
333
+ if (isConnected(byId)) {
334
+ return byId;
335
+ }
336
+ return null;
337
+ }
338
+ function getDocumentUtils() {
339
+ return window.$e?.components?.get?.("document")?.utils;
340
+ }
341
+ function addModelToParent(parentId, childData, options) {
342
+ return getDocumentUtils()?.addModelToParent?.(parentId, childData, options) ?? false;
343
+ }
344
+ function removeModelFromParent(parentId, childId) {
345
+ return getDocumentUtils()?.removeModelFromParent?.(parentId, childId) ?? false;
346
+ }
347
+
317
348
  // src/sync/create-elements.ts
318
349
  var createElements = ({
319
350
  elements,
@@ -338,39 +369,54 @@ var createElements = ({
338
369
  container: element,
339
370
  parentContainer,
340
371
  model: element.model?.toJSON() || {},
341
- options
372
+ options,
373
+ containerId: element.id,
374
+ parentContainerId: parentContainer.id
342
375
  });
343
376
  });
344
377
  return { createdElements };
345
378
  },
346
379
  undo: (_, { createdElements }) => {
347
- [...createdElements].reverse().forEach(({ container }) => {
348
- const freshContainer = container.lookup?.();
380
+ [...createdElements].reverse().forEach(({ container, containerId, parentContainerId }) => {
381
+ const freshContainer = resolveContainer(container, containerId);
349
382
  if (freshContainer) {
350
383
  deleteElement({
351
384
  container: freshContainer,
352
385
  options: { useHistory: false }
353
386
  });
387
+ return;
354
388
  }
389
+ removeModelFromParent(parentContainerId, containerId);
355
390
  });
356
391
  },
357
392
  redo: (_, { createdElements }) => {
358
393
  const newElements = [];
359
- createdElements.forEach(({ parentContainer, model, options }) => {
360
- const freshParent = parentContainer.lookup?.();
361
- if (!freshParent) {
394
+ createdElements.forEach(({ parentContainer, parentContainerId, model, options }) => {
395
+ const freshParent = resolveContainer(parentContainer, parentContainerId);
396
+ if (freshParent) {
397
+ const element = createElement({
398
+ container: freshParent,
399
+ model,
400
+ options: { ...options, useHistory: false }
401
+ });
402
+ newElements.push({
403
+ container: element,
404
+ parentContainer: freshParent,
405
+ model: element.model.toJSON(),
406
+ options,
407
+ containerId: element.id,
408
+ parentContainerId: freshParent.id
409
+ });
362
410
  return;
363
411
  }
364
- const element = createElement({
365
- container: freshParent,
366
- model,
367
- options: { ...options, useHistory: false }
368
- });
412
+ addModelToParent(parentContainerId, model);
369
413
  newElements.push({
370
- container: element,
371
- parentContainer: freshParent,
372
- model: element.model.toJSON(),
373
- options
414
+ container: parentContainer,
415
+ parentContainer,
416
+ model,
417
+ options,
418
+ containerId: model.id ?? "",
419
+ parentContainerId
374
420
  });
375
421
  });
376
422
  return { createdElements: newElements };
@@ -440,25 +486,32 @@ var duplicateElements = ({
440
486
  container: duplicatedElement,
441
487
  parentContainer: duplicatedElement.parent,
442
488
  model: duplicatedElement.model.toJSON(),
443
- at: duplicatedElement.view?._index
489
+ at: duplicatedElement.view?._index,
490
+ containerId: duplicatedElement.id,
491
+ parentContainerId: duplicatedElement.parent.id
444
492
  });
445
493
  });
446
494
  return { duplicatedElements };
447
495
  },
448
496
  undo: (_, { duplicatedElements }) => {
449
497
  onRestoreElements?.();
450
- [...duplicatedElements].reverse().forEach(({ container }) => {
451
- deleteElement({
452
- container,
453
- options: { useHistory: false }
454
- });
498
+ [...duplicatedElements].reverse().forEach(({ container, containerId, parentContainerId }) => {
499
+ const freshContainer = resolveContainer(container, containerId);
500
+ if (freshContainer) {
501
+ deleteElement({
502
+ container: freshContainer,
503
+ options: { useHistory: false }
504
+ });
505
+ return;
506
+ }
507
+ removeModelFromParent(parentContainerId, containerId);
455
508
  });
456
509
  },
457
510
  redo: (_, { duplicatedElements: previousElements }) => {
458
511
  onDuplicateElements?.();
459
512
  const duplicatedElements = [];
460
- previousElements.forEach(({ parentContainer, model, at }) => {
461
- const freshParent = parentContainer.lookup?.();
513
+ previousElements.forEach(({ parentContainer, parentContainerId, model, at }) => {
514
+ const freshParent = resolveContainer(parentContainer, parentContainerId);
462
515
  if (freshParent) {
463
516
  const createdElement = createElement({
464
517
  container: freshParent,
@@ -469,9 +522,21 @@ var duplicateElements = ({
469
522
  container: createdElement,
470
523
  parentContainer: freshParent,
471
524
  model,
472
- at
525
+ at,
526
+ containerId: createdElement.id,
527
+ parentContainerId: freshParent.id
473
528
  });
529
+ return;
474
530
  }
531
+ addModelToParent(parentContainerId, model, { at });
532
+ duplicatedElements.push({
533
+ container: parentContainer,
534
+ parentContainer,
535
+ model,
536
+ at,
537
+ containerId: model.id ?? "",
538
+ parentContainerId
539
+ });
475
540
  });
476
541
  return { duplicatedElements };
477
542
  }
@@ -632,16 +697,19 @@ var moveElements = ({
632
697
  originalContainer,
633
698
  originalIndex,
634
699
  targetContainer: target,
635
- options
700
+ options,
701
+ elementId: newElement.id,
702
+ originalContainerId: originalContainer.id,
703
+ targetContainerId: target.id
636
704
  });
637
705
  });
638
706
  return { movedElements };
639
707
  },
640
708
  undo: (_, { movedElements }) => {
641
709
  onRestoreElements?.();
642
- [...movedElements].reverse().forEach(({ element, originalContainer, originalIndex }) => {
643
- const freshElement = element.lookup?.();
644
- const freshOriginalContainer = originalContainer.lookup?.();
710
+ [...movedElements].reverse().forEach(({ element, elementId, originalContainer, originalContainerId, originalIndex }) => {
711
+ const freshElement = resolveContainer(element, elementId);
712
+ const freshOriginalContainer = resolveContainer(originalContainer, originalContainerId);
645
713
  if (!freshElement || !freshOriginalContainer) {
646
714
  return;
647
715
  }
@@ -658,26 +726,40 @@ var moveElements = ({
658
726
  redo: (_, { movedElements }) => {
659
727
  const newMovedElements = [];
660
728
  onMoveElements?.();
661
- movedElements.forEach(({ element, originalContainer, originalIndex, targetContainer, options }) => {
662
- const freshElement = element.lookup?.();
663
- const freshOriginalContainer = originalContainer.lookup?.();
664
- const freshTarget = targetContainer.lookup?.();
665
- if (!freshElement || !freshOriginalContainer || !freshTarget) {
666
- return;
667
- }
668
- const newElement = moveElement({
669
- element: freshElement,
670
- targetContainer: freshTarget,
671
- options: { ...options, useHistory: false }
672
- });
673
- newMovedElements.push({
674
- element: newElement,
675
- originalContainer: freshOriginalContainer,
729
+ movedElements.forEach(
730
+ ({
731
+ element,
732
+ elementId,
733
+ originalContainer,
734
+ originalContainerId,
676
735
  originalIndex,
677
- targetContainer: freshTarget,
736
+ targetContainer,
737
+ targetContainerId,
678
738
  options
679
- });
680
- });
739
+ }) => {
740
+ const freshElement = resolveContainer(element, elementId);
741
+ const freshOriginalContainer = resolveContainer(originalContainer, originalContainerId);
742
+ const freshTarget = resolveContainer(targetContainer, targetContainerId);
743
+ if (!freshElement || !freshOriginalContainer || !freshTarget) {
744
+ return;
745
+ }
746
+ const newElement = moveElement({
747
+ element: freshElement,
748
+ targetContainer: freshTarget,
749
+ options: { ...options, useHistory: false }
750
+ });
751
+ newMovedElements.push({
752
+ element: newElement,
753
+ originalContainer: freshOriginalContainer,
754
+ originalIndex,
755
+ targetContainer: freshTarget,
756
+ options,
757
+ elementId: newElement.id,
758
+ originalContainerId: freshOriginalContainer.id,
759
+ targetContainerId: freshTarget.id
760
+ });
761
+ }
762
+ );
681
763
  return { movedElements: newMovedElements };
682
764
  }
683
765
  },
@@ -710,7 +792,9 @@ var removeElements = ({
710
792
  container,
711
793
  parent: container.parent,
712
794
  model: container.model.toJSON(),
713
- at: container.view?._index ?? 0
795
+ at: container.view?._index ?? 0,
796
+ containerId: container.id,
797
+ parentId: container.parent.id
714
798
  });
715
799
  }
716
800
  });
@@ -725,35 +809,48 @@ var removeElements = ({
725
809
  },
726
810
  undo: (_, { removedElements }) => {
727
811
  onRestoreElements?.();
728
- [...removedElements].reverse().forEach(({ parent, model, at }) => {
729
- const freshParent = parent.lookup?.();
812
+ [...removedElements].reverse().forEach(({ parent, parentId, model, at }) => {
813
+ const freshParent = resolveContainer(parent, parentId);
730
814
  if (freshParent) {
731
815
  createElement({
732
816
  container: freshParent,
733
817
  model,
734
818
  options: { useHistory: false, at }
735
819
  });
820
+ return;
736
821
  }
822
+ addModelToParent(parentId, model, { at });
737
823
  });
738
824
  },
739
825
  redo: (_, { removedElements }) => {
740
826
  onRemoveElements?.();
741
827
  const newRemovedElements = [];
742
- removedElements.forEach(({ container, parent, model, at }) => {
743
- const freshContainer = container.lookup?.();
744
- const freshParent = parent.lookup?.();
745
- if (!freshContainer || !freshParent) {
828
+ removedElements.forEach(({ container, parent, model, at, containerId, parentId }) => {
829
+ const freshContainer = resolveContainer(container, containerId);
830
+ const freshParent = resolveContainer(parent, parentId);
831
+ if (freshContainer && freshParent) {
832
+ deleteElement({
833
+ container: freshContainer,
834
+ options: { useHistory: false }
835
+ });
836
+ newRemovedElements.push({
837
+ container: freshContainer,
838
+ parent: freshParent,
839
+ model,
840
+ at,
841
+ containerId,
842
+ parentId
843
+ });
746
844
  return;
747
845
  }
748
- deleteElement({
749
- container: freshContainer,
750
- options: { useHistory: false }
751
- });
846
+ removeModelFromParent(parentId, containerId);
752
847
  newRemovedElements.push({
753
- container: freshContainer,
754
- parent: freshParent,
848
+ container,
849
+ parent,
755
850
  model,
756
- at
851
+ at,
852
+ containerId,
853
+ parentId
757
854
  });
758
855
  });
759
856
  return { removedElements: newRemovedElements };