@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.js
CHANGED
|
@@ -1031,7 +1031,7 @@ function findComponentInstancesByUid(documentContainer, componentUid) {
|
|
|
1031
1031
|
// src/utils/component-name-validation.ts
|
|
1032
1032
|
var import_store19 = require("@elementor/store");
|
|
1033
1033
|
|
|
1034
|
-
// src/
|
|
1034
|
+
// src/utils/component-form-schema.ts
|
|
1035
1035
|
var import_schema = require("@elementor/schema");
|
|
1036
1036
|
var import_i18n4 = require("@wordpress/i18n");
|
|
1037
1037
|
var MIN_NAME_LENGTH = 2;
|
|
@@ -3741,45 +3741,129 @@ var import_store56 = require("@elementor/store");
|
|
|
3741
3741
|
var import_ui22 = require("@elementor/ui");
|
|
3742
3742
|
var import_i18n26 = require("@wordpress/i18n");
|
|
3743
3743
|
|
|
3744
|
-
// src/extended/
|
|
3745
|
-
var
|
|
3746
|
-
var import_editor_elements13 = require("@elementor/editor-elements");
|
|
3747
|
-
var import_editor_notifications2 = require("@elementor/editor-notifications");
|
|
3744
|
+
// src/extended/store/actions/create-unpublished-component.ts
|
|
3745
|
+
var import_editor_elements14 = require("@elementor/editor-elements");
|
|
3748
3746
|
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
3747
|
+
var import_store52 = require("@elementor/store");
|
|
3748
|
+
var import_utils6 = require("@elementor/utils");
|
|
3749
3749
|
var import_i18n24 = require("@wordpress/i18n");
|
|
3750
3750
|
|
|
3751
|
+
// src/extended/utils/replace-element-with-component.ts
|
|
3752
|
+
var import_editor_elements13 = require("@elementor/editor-elements");
|
|
3753
|
+
var replaceElementWithComponent = async (element, component) => {
|
|
3754
|
+
return await (0, import_editor_elements13.replaceElement)({
|
|
3755
|
+
currentElement: element,
|
|
3756
|
+
newElement: createComponentModel2(component),
|
|
3757
|
+
withHistory: false
|
|
3758
|
+
});
|
|
3759
|
+
};
|
|
3760
|
+
|
|
3761
|
+
// src/extended/store/actions/create-unpublished-component.ts
|
|
3762
|
+
async function createUnpublishedComponent({
|
|
3763
|
+
name,
|
|
3764
|
+
element,
|
|
3765
|
+
eventData,
|
|
3766
|
+
uid,
|
|
3767
|
+
overridableProps,
|
|
3768
|
+
source
|
|
3769
|
+
}) {
|
|
3770
|
+
const generatedUid = uid ?? (0, import_utils6.generateUniqueId)("component");
|
|
3771
|
+
const componentBase = { uid: generatedUid, name };
|
|
3772
|
+
const elementDataWithOverridablesReverted = revertAllOverridablesInElementData(element);
|
|
3773
|
+
const container = (0, import_editor_elements14.getContainer)(element.id);
|
|
3774
|
+
const modelFromContainer = container?.model?.toJSON?.();
|
|
3775
|
+
const originalElement = {
|
|
3776
|
+
model: modelFromContainer ?? element,
|
|
3777
|
+
parentId: container?.parent?.id ?? "",
|
|
3778
|
+
index: container?.view?._index ?? 0
|
|
3779
|
+
};
|
|
3780
|
+
(0, import_store52.__dispatch)(
|
|
3781
|
+
slice.actions.addUnpublished({
|
|
3782
|
+
...componentBase,
|
|
3783
|
+
elements: [elementDataWithOverridablesReverted],
|
|
3784
|
+
overridableProps
|
|
3785
|
+
})
|
|
3786
|
+
);
|
|
3787
|
+
(0, import_store52.__dispatch)(slice.actions.addCreatedThisSession(generatedUid));
|
|
3788
|
+
const componentInstance = await replaceElementWithComponent(element, componentBase);
|
|
3789
|
+
trackComponentEvent({
|
|
3790
|
+
action: "created",
|
|
3791
|
+
source,
|
|
3792
|
+
component_uid: generatedUid,
|
|
3793
|
+
component_name: name,
|
|
3794
|
+
...eventData
|
|
3795
|
+
});
|
|
3796
|
+
try {
|
|
3797
|
+
await (0, import_editor_v1_adapters3.__privateRunCommand)("document/save/auto");
|
|
3798
|
+
} catch (error) {
|
|
3799
|
+
restoreOriginalElement(originalElement, componentInstance.id);
|
|
3800
|
+
(0, import_store52.__dispatch)(slice.actions.removeUnpublished(generatedUid));
|
|
3801
|
+
(0, import_store52.__dispatch)(slice.actions.removeCreatedThisSession(generatedUid));
|
|
3802
|
+
throw error;
|
|
3803
|
+
}
|
|
3804
|
+
return { uid: generatedUid, instanceId: componentInstance.id };
|
|
3805
|
+
}
|
|
3806
|
+
function restoreOriginalElement(originalElement, componentInstanceId) {
|
|
3807
|
+
const componentContainer = (0, import_editor_elements14.getContainer)(componentInstanceId);
|
|
3808
|
+
if (componentContainer) {
|
|
3809
|
+
(0, import_editor_elements14.deleteElement)({ container: componentContainer, options: { useHistory: false } });
|
|
3810
|
+
}
|
|
3811
|
+
const parentContainer = (0, import_editor_elements14.getContainer)(originalElement.parentId);
|
|
3812
|
+
if (!parentContainer) {
|
|
3813
|
+
return;
|
|
3814
|
+
}
|
|
3815
|
+
const clonedModel = structuredClone(originalElement.model);
|
|
3816
|
+
(0, import_editor_elements14.createElements)({
|
|
3817
|
+
title: (0, import_i18n24.__)("Restore Element", "elementor"),
|
|
3818
|
+
elements: [
|
|
3819
|
+
{
|
|
3820
|
+
container: parentContainer,
|
|
3821
|
+
model: clonedModel,
|
|
3822
|
+
options: { at: originalElement.index }
|
|
3823
|
+
}
|
|
3824
|
+
]
|
|
3825
|
+
});
|
|
3826
|
+
}
|
|
3827
|
+
|
|
3828
|
+
// src/extended/sync/prevent-non-atomic-nesting.ts
|
|
3829
|
+
var import_editor_canvas6 = require("@elementor/editor-canvas");
|
|
3830
|
+
var import_editor_elements15 = require("@elementor/editor-elements");
|
|
3831
|
+
var import_editor_notifications2 = require("@elementor/editor-notifications");
|
|
3832
|
+
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
3833
|
+
var import_i18n25 = require("@wordpress/i18n");
|
|
3834
|
+
|
|
3751
3835
|
// src/extended/utils/is-editing-component.ts
|
|
3752
|
-
var
|
|
3836
|
+
var import_store54 = require("@elementor/store");
|
|
3753
3837
|
function isEditingComponent() {
|
|
3754
|
-
const state = (0,
|
|
3838
|
+
const state = (0, import_store54.__getStore)()?.getState();
|
|
3755
3839
|
if (!state) {
|
|
3756
3840
|
return false;
|
|
3757
3841
|
}
|
|
3758
3842
|
return selectCurrentComponentId(state) !== null;
|
|
3759
3843
|
}
|
|
3760
3844
|
|
|
3761
|
-
// src/extended/prevent-non-atomic-nesting.ts
|
|
3845
|
+
// src/extended/sync/prevent-non-atomic-nesting.ts
|
|
3762
3846
|
var NON_ATOMIC_ELEMENT_ALERT = {
|
|
3763
3847
|
type: "default",
|
|
3764
|
-
message: (0,
|
|
3848
|
+
message: (0, import_i18n25.__)("This widget isn't compatible with components. Use atomic elements instead.", "elementor"),
|
|
3765
3849
|
id: "non-atomic-element-blocked"
|
|
3766
3850
|
};
|
|
3767
3851
|
function initNonAtomicNestingPrevention() {
|
|
3768
|
-
(0,
|
|
3852
|
+
(0, import_editor_v1_adapters4.blockCommand)({
|
|
3769
3853
|
command: "document/elements/create",
|
|
3770
3854
|
condition: blockNonAtomicCreate
|
|
3771
3855
|
});
|
|
3772
|
-
(0,
|
|
3856
|
+
(0, import_editor_v1_adapters4.blockCommand)({
|
|
3773
3857
|
command: "document/elements/move",
|
|
3774
3858
|
condition: blockNonAtomicMove
|
|
3775
3859
|
});
|
|
3776
|
-
(0,
|
|
3860
|
+
(0, import_editor_v1_adapters4.blockCommand)({
|
|
3777
3861
|
command: "document/elements/paste",
|
|
3778
3862
|
condition: blockNonAtomicPaste
|
|
3779
3863
|
});
|
|
3780
3864
|
}
|
|
3781
3865
|
function isElementAtomic(elementType) {
|
|
3782
|
-
return (0,
|
|
3866
|
+
return (0, import_editor_elements15.getElementType)(elementType) !== null;
|
|
3783
3867
|
}
|
|
3784
3868
|
function blockNonAtomicCreate(args) {
|
|
3785
3869
|
if (!isEditingComponent()) {
|
|
@@ -3805,7 +3889,7 @@ function blockNonAtomicMove(args) {
|
|
|
3805
3889
|
if (!container) {
|
|
3806
3890
|
return false;
|
|
3807
3891
|
}
|
|
3808
|
-
const allElements = (0,
|
|
3892
|
+
const allElements = (0, import_editor_elements15.getAllDescendants)(container);
|
|
3809
3893
|
return allElements.some((element) => !(0, import_editor_canvas6.isAtomicWidget)(element));
|
|
3810
3894
|
});
|
|
3811
3895
|
if (hasNonAtomicElement) {
|
|
@@ -3859,90 +3943,6 @@ function findNonAtomicElementsInElement(element) {
|
|
|
3859
3943
|
return [...new Set(nonAtomicElements)];
|
|
3860
3944
|
}
|
|
3861
3945
|
|
|
3862
|
-
// src/extended/store/actions/create-unpublished-component.ts
|
|
3863
|
-
var import_editor_elements15 = require("@elementor/editor-elements");
|
|
3864
|
-
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
3865
|
-
var import_store54 = require("@elementor/store");
|
|
3866
|
-
var import_utils6 = require("@elementor/utils");
|
|
3867
|
-
var import_i18n25 = require("@wordpress/i18n");
|
|
3868
|
-
|
|
3869
|
-
// src/extended/utils/replace-element-with-component.ts
|
|
3870
|
-
var import_editor_elements14 = require("@elementor/editor-elements");
|
|
3871
|
-
var replaceElementWithComponent = async (element, component) => {
|
|
3872
|
-
return await (0, import_editor_elements14.replaceElement)({
|
|
3873
|
-
currentElement: element,
|
|
3874
|
-
newElement: createComponentModel2(component),
|
|
3875
|
-
withHistory: false
|
|
3876
|
-
});
|
|
3877
|
-
};
|
|
3878
|
-
|
|
3879
|
-
// src/extended/store/actions/create-unpublished-component.ts
|
|
3880
|
-
async function createUnpublishedComponent({
|
|
3881
|
-
name,
|
|
3882
|
-
element,
|
|
3883
|
-
eventData,
|
|
3884
|
-
uid,
|
|
3885
|
-
overridableProps,
|
|
3886
|
-
source
|
|
3887
|
-
}) {
|
|
3888
|
-
const generatedUid = uid ?? (0, import_utils6.generateUniqueId)("component");
|
|
3889
|
-
const componentBase = { uid: generatedUid, name };
|
|
3890
|
-
const elementDataWithOverridablesReverted = revertAllOverridablesInElementData(element);
|
|
3891
|
-
const container = (0, import_editor_elements15.getContainer)(element.id);
|
|
3892
|
-
const modelFromContainer = container?.model?.toJSON?.();
|
|
3893
|
-
const originalElement = {
|
|
3894
|
-
model: modelFromContainer ?? element,
|
|
3895
|
-
parentId: container?.parent?.id ?? "",
|
|
3896
|
-
index: container?.view?._index ?? 0
|
|
3897
|
-
};
|
|
3898
|
-
(0, import_store54.__dispatch)(
|
|
3899
|
-
slice.actions.addUnpublished({
|
|
3900
|
-
...componentBase,
|
|
3901
|
-
elements: [elementDataWithOverridablesReverted],
|
|
3902
|
-
overridableProps
|
|
3903
|
-
})
|
|
3904
|
-
);
|
|
3905
|
-
(0, import_store54.__dispatch)(slice.actions.addCreatedThisSession(generatedUid));
|
|
3906
|
-
const componentInstance = await replaceElementWithComponent(element, componentBase);
|
|
3907
|
-
trackComponentEvent({
|
|
3908
|
-
action: "created",
|
|
3909
|
-
source,
|
|
3910
|
-
component_uid: generatedUid,
|
|
3911
|
-
component_name: name,
|
|
3912
|
-
...eventData
|
|
3913
|
-
});
|
|
3914
|
-
try {
|
|
3915
|
-
await (0, import_editor_v1_adapters4.__privateRunCommand)("document/save/auto");
|
|
3916
|
-
} catch (error) {
|
|
3917
|
-
restoreOriginalElement(originalElement, componentInstance.id);
|
|
3918
|
-
(0, import_store54.__dispatch)(slice.actions.removeUnpublished(generatedUid));
|
|
3919
|
-
(0, import_store54.__dispatch)(slice.actions.removeCreatedThisSession(generatedUid));
|
|
3920
|
-
throw error;
|
|
3921
|
-
}
|
|
3922
|
-
return { uid: generatedUid, instanceId: componentInstance.id };
|
|
3923
|
-
}
|
|
3924
|
-
function restoreOriginalElement(originalElement, componentInstanceId) {
|
|
3925
|
-
const componentContainer = (0, import_editor_elements15.getContainer)(componentInstanceId);
|
|
3926
|
-
if (componentContainer) {
|
|
3927
|
-
(0, import_editor_elements15.deleteElement)({ container: componentContainer, options: { useHistory: false } });
|
|
3928
|
-
}
|
|
3929
|
-
const parentContainer = (0, import_editor_elements15.getContainer)(originalElement.parentId);
|
|
3930
|
-
if (!parentContainer) {
|
|
3931
|
-
return;
|
|
3932
|
-
}
|
|
3933
|
-
const clonedModel = structuredClone(originalElement.model);
|
|
3934
|
-
(0, import_editor_elements15.createElements)({
|
|
3935
|
-
title: (0, import_i18n25.__)("Restore Element", "elementor"),
|
|
3936
|
-
elements: [
|
|
3937
|
-
{
|
|
3938
|
-
container: parentContainer,
|
|
3939
|
-
model: clonedModel,
|
|
3940
|
-
options: { at: originalElement.index }
|
|
3941
|
-
}
|
|
3942
|
-
]
|
|
3943
|
-
});
|
|
3944
|
-
}
|
|
3945
|
-
|
|
3946
3946
|
// src/extended/components/create-component-form/hooks/use-form.ts
|
|
3947
3947
|
var import_react13 = require("react");
|
|
3948
3948
|
var useForm = (initialValues) => {
|