@elementor/editor-components 4.0.0-591 → 4.0.0-598
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 +98 -98
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -89
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -23
- package/src/extended/components/create-component-form/create-component-form.tsx +2 -2
- package/src/extended/init.ts +1 -1
- package/src/extended/{prevent-non-atomic-nesting.ts → sync/prevent-non-atomic-nesting.ts} +2 -2
- package/src/utils/component-name-validation.ts +1 -1
- /package/src/{extended/components/create-component-form/utils → utils}/component-form-schema.ts +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1016,7 +1016,7 @@ function findComponentInstancesByUid(documentContainer, componentUid) {
|
|
|
1016
1016
|
// src/utils/component-name-validation.ts
|
|
1017
1017
|
import { __getState as getState6 } from "@elementor/store";
|
|
1018
1018
|
|
|
1019
|
-
// src/
|
|
1019
|
+
// src/utils/component-form-schema.ts
|
|
1020
1020
|
import { z } from "@elementor/schema";
|
|
1021
1021
|
import { __ as __4 } from "@wordpress/i18n";
|
|
1022
1022
|
var MIN_NAME_LENGTH = 2;
|
|
@@ -3765,12 +3765,96 @@ import { __getState as getState17 } from "@elementor/store";
|
|
|
3765
3765
|
import { Button as Button5, FormLabel as FormLabel2, Grid as Grid2, Popover as Popover3, Stack as Stack16, TextField as TextField3, Typography as Typography12 } from "@elementor/ui";
|
|
3766
3766
|
import { __ as __26 } from "@wordpress/i18n";
|
|
3767
3767
|
|
|
3768
|
-
// src/extended/
|
|
3768
|
+
// src/extended/store/actions/create-unpublished-component.ts
|
|
3769
|
+
import { createElements, deleteElement, getContainer as getContainer4 } from "@elementor/editor-elements";
|
|
3770
|
+
import { __privateRunCommand as runCommand2 } from "@elementor/editor-v1-adapters";
|
|
3771
|
+
import { __dispatch as dispatch14 } from "@elementor/store";
|
|
3772
|
+
import { generateUniqueId as generateUniqueId3 } from "@elementor/utils";
|
|
3773
|
+
import { __ as __24 } from "@wordpress/i18n";
|
|
3774
|
+
|
|
3775
|
+
// src/extended/utils/replace-element-with-component.ts
|
|
3776
|
+
import { replaceElement } from "@elementor/editor-elements";
|
|
3777
|
+
var replaceElementWithComponent = async (element, component) => {
|
|
3778
|
+
return await replaceElement({
|
|
3779
|
+
currentElement: element,
|
|
3780
|
+
newElement: createComponentModel2(component),
|
|
3781
|
+
withHistory: false
|
|
3782
|
+
});
|
|
3783
|
+
};
|
|
3784
|
+
|
|
3785
|
+
// src/extended/store/actions/create-unpublished-component.ts
|
|
3786
|
+
async function createUnpublishedComponent({
|
|
3787
|
+
name,
|
|
3788
|
+
element,
|
|
3789
|
+
eventData,
|
|
3790
|
+
uid,
|
|
3791
|
+
overridableProps,
|
|
3792
|
+
source
|
|
3793
|
+
}) {
|
|
3794
|
+
const generatedUid = uid ?? generateUniqueId3("component");
|
|
3795
|
+
const componentBase = { uid: generatedUid, name };
|
|
3796
|
+
const elementDataWithOverridablesReverted = revertAllOverridablesInElementData(element);
|
|
3797
|
+
const container = getContainer4(element.id);
|
|
3798
|
+
const modelFromContainer = container?.model?.toJSON?.();
|
|
3799
|
+
const originalElement = {
|
|
3800
|
+
model: modelFromContainer ?? element,
|
|
3801
|
+
parentId: container?.parent?.id ?? "",
|
|
3802
|
+
index: container?.view?._index ?? 0
|
|
3803
|
+
};
|
|
3804
|
+
dispatch14(
|
|
3805
|
+
slice.actions.addUnpublished({
|
|
3806
|
+
...componentBase,
|
|
3807
|
+
elements: [elementDataWithOverridablesReverted],
|
|
3808
|
+
overridableProps
|
|
3809
|
+
})
|
|
3810
|
+
);
|
|
3811
|
+
dispatch14(slice.actions.addCreatedThisSession(generatedUid));
|
|
3812
|
+
const componentInstance = await replaceElementWithComponent(element, componentBase);
|
|
3813
|
+
trackComponentEvent({
|
|
3814
|
+
action: "created",
|
|
3815
|
+
source,
|
|
3816
|
+
component_uid: generatedUid,
|
|
3817
|
+
component_name: name,
|
|
3818
|
+
...eventData
|
|
3819
|
+
});
|
|
3820
|
+
try {
|
|
3821
|
+
await runCommand2("document/save/auto");
|
|
3822
|
+
} catch (error) {
|
|
3823
|
+
restoreOriginalElement(originalElement, componentInstance.id);
|
|
3824
|
+
dispatch14(slice.actions.removeUnpublished(generatedUid));
|
|
3825
|
+
dispatch14(slice.actions.removeCreatedThisSession(generatedUid));
|
|
3826
|
+
throw error;
|
|
3827
|
+
}
|
|
3828
|
+
return { uid: generatedUid, instanceId: componentInstance.id };
|
|
3829
|
+
}
|
|
3830
|
+
function restoreOriginalElement(originalElement, componentInstanceId) {
|
|
3831
|
+
const componentContainer = getContainer4(componentInstanceId);
|
|
3832
|
+
if (componentContainer) {
|
|
3833
|
+
deleteElement({ container: componentContainer, options: { useHistory: false } });
|
|
3834
|
+
}
|
|
3835
|
+
const parentContainer = getContainer4(originalElement.parentId);
|
|
3836
|
+
if (!parentContainer) {
|
|
3837
|
+
return;
|
|
3838
|
+
}
|
|
3839
|
+
const clonedModel = structuredClone(originalElement.model);
|
|
3840
|
+
createElements({
|
|
3841
|
+
title: __24("Restore Element", "elementor"),
|
|
3842
|
+
elements: [
|
|
3843
|
+
{
|
|
3844
|
+
container: parentContainer,
|
|
3845
|
+
model: clonedModel,
|
|
3846
|
+
options: { at: originalElement.index }
|
|
3847
|
+
}
|
|
3848
|
+
]
|
|
3849
|
+
});
|
|
3850
|
+
}
|
|
3851
|
+
|
|
3852
|
+
// src/extended/sync/prevent-non-atomic-nesting.ts
|
|
3769
3853
|
import { isAtomicWidget } from "@elementor/editor-canvas";
|
|
3770
3854
|
import { getAllDescendants as getAllDescendants3, getElementType as getElementType3 } from "@elementor/editor-elements";
|
|
3771
3855
|
import { notify as notify2 } from "@elementor/editor-notifications";
|
|
3772
3856
|
import { blockCommand } from "@elementor/editor-v1-adapters";
|
|
3773
|
-
import { __ as
|
|
3857
|
+
import { __ as __25 } from "@wordpress/i18n";
|
|
3774
3858
|
|
|
3775
3859
|
// src/extended/utils/is-editing-component.ts
|
|
3776
3860
|
import { __getStore as getStore } from "@elementor/store";
|
|
@@ -3782,10 +3866,10 @@ function isEditingComponent() {
|
|
|
3782
3866
|
return selectCurrentComponentId(state) !== null;
|
|
3783
3867
|
}
|
|
3784
3868
|
|
|
3785
|
-
// src/extended/prevent-non-atomic-nesting.ts
|
|
3869
|
+
// src/extended/sync/prevent-non-atomic-nesting.ts
|
|
3786
3870
|
var NON_ATOMIC_ELEMENT_ALERT = {
|
|
3787
3871
|
type: "default",
|
|
3788
|
-
message:
|
|
3872
|
+
message: __25("This widget isn't compatible with components. Use atomic elements instead.", "elementor"),
|
|
3789
3873
|
id: "non-atomic-element-blocked"
|
|
3790
3874
|
};
|
|
3791
3875
|
function initNonAtomicNestingPrevention() {
|
|
@@ -3883,90 +3967,6 @@ function findNonAtomicElementsInElement(element) {
|
|
|
3883
3967
|
return [...new Set(nonAtomicElements)];
|
|
3884
3968
|
}
|
|
3885
3969
|
|
|
3886
|
-
// src/extended/store/actions/create-unpublished-component.ts
|
|
3887
|
-
import { createElements, deleteElement, getContainer as getContainer4 } from "@elementor/editor-elements";
|
|
3888
|
-
import { __privateRunCommand as runCommand2 } from "@elementor/editor-v1-adapters";
|
|
3889
|
-
import { __dispatch as dispatch14 } from "@elementor/store";
|
|
3890
|
-
import { generateUniqueId as generateUniqueId3 } from "@elementor/utils";
|
|
3891
|
-
import { __ as __25 } from "@wordpress/i18n";
|
|
3892
|
-
|
|
3893
|
-
// src/extended/utils/replace-element-with-component.ts
|
|
3894
|
-
import { replaceElement } from "@elementor/editor-elements";
|
|
3895
|
-
var replaceElementWithComponent = async (element, component) => {
|
|
3896
|
-
return await replaceElement({
|
|
3897
|
-
currentElement: element,
|
|
3898
|
-
newElement: createComponentModel2(component),
|
|
3899
|
-
withHistory: false
|
|
3900
|
-
});
|
|
3901
|
-
};
|
|
3902
|
-
|
|
3903
|
-
// src/extended/store/actions/create-unpublished-component.ts
|
|
3904
|
-
async function createUnpublishedComponent({
|
|
3905
|
-
name,
|
|
3906
|
-
element,
|
|
3907
|
-
eventData,
|
|
3908
|
-
uid,
|
|
3909
|
-
overridableProps,
|
|
3910
|
-
source
|
|
3911
|
-
}) {
|
|
3912
|
-
const generatedUid = uid ?? generateUniqueId3("component");
|
|
3913
|
-
const componentBase = { uid: generatedUid, name };
|
|
3914
|
-
const elementDataWithOverridablesReverted = revertAllOverridablesInElementData(element);
|
|
3915
|
-
const container = getContainer4(element.id);
|
|
3916
|
-
const modelFromContainer = container?.model?.toJSON?.();
|
|
3917
|
-
const originalElement = {
|
|
3918
|
-
model: modelFromContainer ?? element,
|
|
3919
|
-
parentId: container?.parent?.id ?? "",
|
|
3920
|
-
index: container?.view?._index ?? 0
|
|
3921
|
-
};
|
|
3922
|
-
dispatch14(
|
|
3923
|
-
slice.actions.addUnpublished({
|
|
3924
|
-
...componentBase,
|
|
3925
|
-
elements: [elementDataWithOverridablesReverted],
|
|
3926
|
-
overridableProps
|
|
3927
|
-
})
|
|
3928
|
-
);
|
|
3929
|
-
dispatch14(slice.actions.addCreatedThisSession(generatedUid));
|
|
3930
|
-
const componentInstance = await replaceElementWithComponent(element, componentBase);
|
|
3931
|
-
trackComponentEvent({
|
|
3932
|
-
action: "created",
|
|
3933
|
-
source,
|
|
3934
|
-
component_uid: generatedUid,
|
|
3935
|
-
component_name: name,
|
|
3936
|
-
...eventData
|
|
3937
|
-
});
|
|
3938
|
-
try {
|
|
3939
|
-
await runCommand2("document/save/auto");
|
|
3940
|
-
} catch (error) {
|
|
3941
|
-
restoreOriginalElement(originalElement, componentInstance.id);
|
|
3942
|
-
dispatch14(slice.actions.removeUnpublished(generatedUid));
|
|
3943
|
-
dispatch14(slice.actions.removeCreatedThisSession(generatedUid));
|
|
3944
|
-
throw error;
|
|
3945
|
-
}
|
|
3946
|
-
return { uid: generatedUid, instanceId: componentInstance.id };
|
|
3947
|
-
}
|
|
3948
|
-
function restoreOriginalElement(originalElement, componentInstanceId) {
|
|
3949
|
-
const componentContainer = getContainer4(componentInstanceId);
|
|
3950
|
-
if (componentContainer) {
|
|
3951
|
-
deleteElement({ container: componentContainer, options: { useHistory: false } });
|
|
3952
|
-
}
|
|
3953
|
-
const parentContainer = getContainer4(originalElement.parentId);
|
|
3954
|
-
if (!parentContainer) {
|
|
3955
|
-
return;
|
|
3956
|
-
}
|
|
3957
|
-
const clonedModel = structuredClone(originalElement.model);
|
|
3958
|
-
createElements({
|
|
3959
|
-
title: __25("Restore Element", "elementor"),
|
|
3960
|
-
elements: [
|
|
3961
|
-
{
|
|
3962
|
-
container: parentContainer,
|
|
3963
|
-
model: clonedModel,
|
|
3964
|
-
options: { at: originalElement.index }
|
|
3965
|
-
}
|
|
3966
|
-
]
|
|
3967
|
-
});
|
|
3968
|
-
}
|
|
3969
|
-
|
|
3970
3970
|
// src/extended/components/create-component-form/hooks/use-form.ts
|
|
3971
3971
|
import { useMemo as useMemo2, useState as useState7 } from "react";
|
|
3972
3972
|
var useForm = (initialValues) => {
|