@elementor/editor-elements 3.33.0-261 → 3.33.0-263
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/errors.ts +10 -0
- package/src/sync/replace-element.ts +13 -7
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:
|
|
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:
|
|
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
|
|
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
|
|
740
|
+
throw new ElementParentNotFoundError({ context: { elementId: currentElement.id } });
|
|
729
741
|
}
|
|
730
|
-
const elementIndex =
|
|
742
|
+
const elementIndex = currentElementContainer.view?._index ?? 0;
|
|
731
743
|
if (elementIndex === void 0 || elementIndex === -1) {
|
|
732
|
-
throw new
|
|
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") {
|