@elementor/editor-elements 3.33.0-260 → 3.33.0-262

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
@@ -289,7 +289,7 @@ declare const updateElementSettings: ({ id, props, withHistory }: UpdateElementS
289
289
  declare const generateElementId: () => string;
290
290
 
291
291
  type ReplaceElementArgs = {
292
- currentElement: V1Element;
292
+ currentElement: V1ElementData;
293
293
  newElement: Omit<V1ElementModelProps, 'id'>;
294
294
  withHistory?: boolean;
295
295
  };
package/dist/index.d.ts CHANGED
@@ -289,7 +289,7 @@ declare const updateElementSettings: ({ id, props, withHistory }: UpdateElementS
289
289
  declare const generateElementId: () => string;
290
290
 
291
291
  type ReplaceElementArgs = {
292
- currentElement: V1Element;
292
+ currentElement: V1ElementData;
293
293
  newElement: Omit<V1ElementModelProps, 'id'>;
294
294
  withHistory?: boolean;
295
295
  };
package/dist/index.js CHANGED
@@ -648,6 +648,14 @@ var ElementLabelNotExistsError = (0, import_utils.createError)({
648
648
  code: "element_label_not_exists",
649
649
  message: "Element label does not exist."
650
650
  });
651
+ var ElementParentNotFoundError = (0, import_utils.createError)({
652
+ code: "element_parent_not_found",
653
+ message: "Element parent not found."
654
+ });
655
+ var ElementIndexNotFoundError = (0, import_utils.createError)({
656
+ code: "element_index_not_found",
657
+ message: "Element index not found."
658
+ });
651
659
 
652
660
  // src/sync/get-element-label.ts
653
661
  function getElementLabel(elementId) {
@@ -723,13 +731,17 @@ var replaceElement = ({ currentElement, newElement, withHistory = true }) => {
723
731
  };
724
732
  function getNewElementLocation(currentElement, newElement) {
725
733
  let location;
726
- const parent = getContainer(currentElement.id)?.parent;
734
+ const currentElementContainer = getContainer(currentElement.id);
735
+ if (!currentElementContainer) {
736
+ throw new ElementNotFoundError({ context: { elementId: currentElement.id } });
737
+ }
738
+ const parent = currentElementContainer.parent;
727
739
  if (!parent) {
728
- throw new Error(`Parent not found for element ${currentElement.id}. Cannot replace element.`);
740
+ throw new ElementParentNotFoundError({ context: { elementId: currentElement.id } });
729
741
  }
730
- const elementIndex = currentElement.view?._index ?? 0;
742
+ const elementIndex = currentElementContainer.view?._index ?? 0;
731
743
  if (elementIndex === void 0 || elementIndex === -1) {
732
- throw new Error(`Element ${currentElement.id} not found in parent container. Cannot replace element.`);
744
+ throw new ElementIndexNotFoundError({ context: { elementId: currentElement.id } });
733
745
  }
734
746
  location = { containerId: parent.id, index: elementIndex };
735
747
  if (parent.id === "document" && newElement.elType === "widget") {