@elementor/editor-components 4.2.0-916 → 4.2.0-918

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.js CHANGED
@@ -1404,6 +1404,9 @@ function getOverridableOverride(propValue) {
1404
1404
  }
1405
1405
 
1406
1406
  // src/utils/detach-component-instance/detach-component-instance.ts
1407
+ var DETACH_EVENT = "elementor/components/detach-instance";
1408
+ var DETACH_UNDO_EVENT = "elementor/components/undo-detach-instance";
1409
+ var DETACH_REDO_EVENT = "elementor/components/redo-detach-instance";
1407
1410
  async function detachComponentInstance({
1408
1411
  instanceId,
1409
1412
  componentId,
@@ -1429,9 +1432,16 @@ async function detachComponentInstance({
1429
1432
  rootElement,
1430
1433
  overrides
1431
1434
  );
1432
- const editedComponentOnDetach = selectCurrentComponentId((0, import_store10.__getState)());
1433
- const overridablePropsBeforeDetach = editedComponentOnDetach ? selectOverridableProps((0, import_store10.__getState)(), editedComponentOnDetach) ?? null : null;
1434
1435
  const originalInstanceModel = instanceContainer.model.toJSON();
1436
+ const actionId = (/* @__PURE__ */ new Date()).getTime();
1437
+ window.dispatchEvent(
1438
+ new CustomEvent(DETACH_EVENT, {
1439
+ detail: {
1440
+ detachedInstanceId: instanceId,
1441
+ detachActionId: actionId
1442
+ }
1443
+ })
1444
+ );
1435
1445
  const detachedElement = (0, import_editor_elements3.replaceElement)({
1436
1446
  currentElementId: instanceId,
1437
1447
  newElement: detachedInstanceElementData,
@@ -1451,51 +1461,48 @@ async function detachComponentInstance({
1451
1461
  return {
1452
1462
  detachedElement,
1453
1463
  detachedInstanceElementData,
1454
- editedComponentOnDetach,
1455
- overridablePropsBeforeDetach,
1456
- originalInstanceModel
1464
+ originalInstanceModel,
1465
+ actionId
1457
1466
  };
1458
1467
  },
1459
- undo: (_, {
1460
- detachedElement,
1461
- originalInstanceModel,
1462
- overridablePropsBeforeDetach,
1463
- editedComponentOnDetach
1464
- }) => {
1468
+ undo: (_, { detachedElement, originalInstanceModel, actionId }) => {
1465
1469
  const restoredInstance = (0, import_editor_elements3.replaceElement)({
1466
1470
  currentElementId: detachedElement.id,
1467
1471
  newElement: originalInstanceModel,
1468
1472
  withHistory: false
1469
1473
  });
1470
- const currentComponentId = selectCurrentComponentId((0, import_store10.__getState)());
1471
- if (currentComponentId && currentComponentId === editedComponentOnDetach && overridablePropsBeforeDetach) {
1472
- (0, import_store10.__dispatch)(
1473
- slice.actions.setOverridableProps({
1474
- componentId: currentComponentId,
1475
- overridableProps: overridablePropsBeforeDetach
1476
- })
1477
- );
1478
- }
1474
+ window.dispatchEvent(
1475
+ new CustomEvent(DETACH_UNDO_EVENT, {
1476
+ detail: {
1477
+ restoredInstanceId: restoredInstance.id,
1478
+ detachActionId: actionId
1479
+ }
1480
+ })
1481
+ );
1479
1482
  (0, import_editor_canvas4.doAfterRender)([restoredInstance.id], () => {
1480
1483
  (0, import_editor_elements3.selectElement)(restoredInstance.id);
1481
1484
  });
1482
1485
  return restoredInstance;
1483
1486
  },
1484
1487
  redo: (_, doReturn, restoredInstance) => {
1485
- const { detachedInstanceElementData } = doReturn;
1486
- const editedComponentOnDetach = selectCurrentComponentId((0, import_store10.__getState)());
1487
- const overridablePropsBeforeDetach = editedComponentOnDetach ? selectOverridableProps((0, import_store10.__getState)(), editedComponentOnDetach) ?? null : null;
1488
+ const { detachedInstanceElementData, actionId } = doReturn;
1488
1489
  const detachedElement = (0, import_editor_elements3.replaceElement)({
1489
1490
  currentElementId: restoredInstance.id,
1490
1491
  newElement: detachedInstanceElementData,
1491
1492
  withHistory: false
1492
1493
  });
1494
+ window.dispatchEvent(
1495
+ new CustomEvent(DETACH_REDO_EVENT, {
1496
+ detail: {
1497
+ detachedInstanceId: detachedElement.id,
1498
+ detachActionId: actionId
1499
+ }
1500
+ })
1501
+ );
1493
1502
  (0, import_editor_elements3.selectElement)(detachedElement.id);
1494
1503
  return {
1495
1504
  ...doReturn,
1496
- detachedElement,
1497
- editedComponentOnDetach,
1498
- overridablePropsBeforeDetach
1505
+ detachedElement
1499
1506
  };
1500
1507
  }
1501
1508
  },