@elementor/editor-components 3.35.0-394 → 3.35.0-396
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 +157 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +145 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -22
- package/src/hooks/regenerate-override-keys.ts +2 -8
- package/src/init.ts +3 -0
- package/src/prevent-circular-nesting.ts +214 -0
- package/src/utils/tracking.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -42,9 +42,9 @@ var import_editor_editing_panel8 = require("@elementor/editor-editing-panel");
|
|
|
42
42
|
var import_editor_elements_panel = require("@elementor/editor-elements-panel");
|
|
43
43
|
var import_editor_panels4 = require("@elementor/editor-panels");
|
|
44
44
|
var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
var
|
|
45
|
+
var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
|
|
46
|
+
var import_store65 = require("@elementor/store");
|
|
47
|
+
var import_i18n25 = require("@wordpress/i18n");
|
|
48
48
|
|
|
49
49
|
// src/component-instance-transformer.ts
|
|
50
50
|
var import_editor_canvas = require("@elementor/editor-canvas");
|
|
@@ -1656,7 +1656,7 @@ var trackComponentEvent = ({ action, ...data }) => {
|
|
|
1656
1656
|
dispatchEvent?.(name, data);
|
|
1657
1657
|
};
|
|
1658
1658
|
var onElementDrop = (_args, element) => {
|
|
1659
|
-
if (!(element
|
|
1659
|
+
if (!(element?.model?.get("widgetType") === "e-component")) {
|
|
1660
1660
|
return;
|
|
1661
1661
|
}
|
|
1662
1662
|
const editorSettings = element.model.get("editor_settings");
|
|
@@ -3533,11 +3533,7 @@ function regenerateOverrideKeysRecursive(elementId) {
|
|
|
3533
3533
|
if (!container) {
|
|
3534
3534
|
return;
|
|
3535
3535
|
}
|
|
3536
|
-
|
|
3537
|
-
}
|
|
3538
|
-
function getAllElements(container) {
|
|
3539
|
-
const children = (container.children ?? []).flatMap(getAllElements) ?? [];
|
|
3540
|
-
return [container, ...children];
|
|
3536
|
+
(0, import_editor_elements13.getAllDescendants)(container).forEach(regenerateOverrideKeys);
|
|
3541
3537
|
}
|
|
3542
3538
|
function regenerateOverrideKeys(element) {
|
|
3543
3539
|
if (!isComponentInstance(element.model.toJSON())) {
|
|
@@ -3932,20 +3928,147 @@ function PopulateStore() {
|
|
|
3932
3928
|
return null;
|
|
3933
3929
|
}
|
|
3934
3930
|
|
|
3935
|
-
// src/
|
|
3931
|
+
// src/prevent-circular-nesting.ts
|
|
3932
|
+
var import_editor_elements15 = require("@elementor/editor-elements");
|
|
3933
|
+
var import_editor_notifications = require("@elementor/editor-notifications");
|
|
3934
|
+
var import_editor_v1_adapters7 = require("@elementor/editor-v1-adapters");
|
|
3936
3935
|
var import_store53 = require("@elementor/store");
|
|
3936
|
+
var import_i18n24 = require("@wordpress/i18n");
|
|
3937
|
+
var COMPONENT_TYPE = "e-component";
|
|
3938
|
+
var COMPONENT_CIRCULAR_NESTING_ALERT = {
|
|
3939
|
+
type: "default",
|
|
3940
|
+
message: (0, import_i18n24.__)("Cannot add this component here - it would create a circular reference.", "elementor"),
|
|
3941
|
+
id: "circular-component-nesting-blocked"
|
|
3942
|
+
};
|
|
3943
|
+
function initCircularNestingPrevention() {
|
|
3944
|
+
(0, import_editor_v1_adapters7.blockCommand)({
|
|
3945
|
+
command: "document/elements/create",
|
|
3946
|
+
condition: blockCircularCreate
|
|
3947
|
+
});
|
|
3948
|
+
(0, import_editor_v1_adapters7.blockCommand)({
|
|
3949
|
+
command: "document/elements/move",
|
|
3950
|
+
condition: blockCircularMove
|
|
3951
|
+
});
|
|
3952
|
+
(0, import_editor_v1_adapters7.blockCommand)({
|
|
3953
|
+
command: "document/elements/paste",
|
|
3954
|
+
condition: blockCircularPaste
|
|
3955
|
+
});
|
|
3956
|
+
}
|
|
3957
|
+
function wouldCreateCircularNesting(componentIdToAdd) {
|
|
3958
|
+
if (componentIdToAdd === void 0) {
|
|
3959
|
+
return false;
|
|
3960
|
+
}
|
|
3961
|
+
const state = (0, import_store53.__getState)();
|
|
3962
|
+
const currentComponentId = selectCurrentComponentId(state);
|
|
3963
|
+
const path = selectPath(state);
|
|
3964
|
+
if (currentComponentId === null) {
|
|
3965
|
+
return false;
|
|
3966
|
+
}
|
|
3967
|
+
if (componentIdToAdd === currentComponentId) {
|
|
3968
|
+
return true;
|
|
3969
|
+
}
|
|
3970
|
+
return path.some((item) => item.componentId === componentIdToAdd);
|
|
3971
|
+
}
|
|
3972
|
+
function extractComponentIdFromModel(model) {
|
|
3973
|
+
if (!model) {
|
|
3974
|
+
return null;
|
|
3975
|
+
}
|
|
3976
|
+
const isComponent = model.widgetType === COMPONENT_TYPE;
|
|
3977
|
+
if (!isComponent) {
|
|
3978
|
+
return null;
|
|
3979
|
+
}
|
|
3980
|
+
return model.settings?.component_instance?.value?.component_id?.value ?? null;
|
|
3981
|
+
}
|
|
3982
|
+
function extractComponentIdFromElement(element) {
|
|
3983
|
+
if (element.widgetType !== COMPONENT_TYPE) {
|
|
3984
|
+
return null;
|
|
3985
|
+
}
|
|
3986
|
+
return element.settings?.component_instance?.value?.component_id?.value ?? null;
|
|
3987
|
+
}
|
|
3988
|
+
function extractComponentIdsFromElements(elements) {
|
|
3989
|
+
const ids = [];
|
|
3990
|
+
for (const element of elements) {
|
|
3991
|
+
const componentId = extractComponentIdFromElement(element);
|
|
3992
|
+
if (componentId !== null) {
|
|
3993
|
+
ids.push(componentId);
|
|
3994
|
+
}
|
|
3995
|
+
if (element.elements?.length) {
|
|
3996
|
+
ids.push(...extractComponentIdsFromElements(element.elements));
|
|
3997
|
+
}
|
|
3998
|
+
}
|
|
3999
|
+
return ids;
|
|
4000
|
+
}
|
|
4001
|
+
function extractComponentIdFromContainer(container) {
|
|
4002
|
+
const widgetType = container.model?.get?.("widgetType");
|
|
4003
|
+
if (widgetType !== COMPONENT_TYPE) {
|
|
4004
|
+
return null;
|
|
4005
|
+
}
|
|
4006
|
+
const settings = container.model?.get?.("settings");
|
|
4007
|
+
const componentInstance = settings?.get?.("component_instance");
|
|
4008
|
+
return componentInstance?.value?.component_id?.value ?? null;
|
|
4009
|
+
}
|
|
4010
|
+
function blockCircularCreate(args) {
|
|
4011
|
+
const componentId = extractComponentIdFromModel(args.model);
|
|
4012
|
+
if (componentId === null) {
|
|
4013
|
+
return false;
|
|
4014
|
+
}
|
|
4015
|
+
const isBlocked = wouldCreateCircularNesting(componentId);
|
|
4016
|
+
if (isBlocked) {
|
|
4017
|
+
(0, import_editor_notifications.notify)(COMPONENT_CIRCULAR_NESTING_ALERT);
|
|
4018
|
+
}
|
|
4019
|
+
return isBlocked;
|
|
4020
|
+
}
|
|
4021
|
+
function blockCircularMove(args) {
|
|
4022
|
+
const { containers = [args.container] } = args;
|
|
4023
|
+
const hasCircularComponent = containers.some((container) => {
|
|
4024
|
+
if (!container) {
|
|
4025
|
+
return false;
|
|
4026
|
+
}
|
|
4027
|
+
const allElements = (0, import_editor_elements15.getAllDescendants)(container);
|
|
4028
|
+
return allElements.some((element) => {
|
|
4029
|
+
const componentId = extractComponentIdFromContainer(element);
|
|
4030
|
+
if (componentId === null) {
|
|
4031
|
+
return false;
|
|
4032
|
+
}
|
|
4033
|
+
return wouldCreateCircularNesting(componentId);
|
|
4034
|
+
});
|
|
4035
|
+
});
|
|
4036
|
+
if (hasCircularComponent) {
|
|
4037
|
+
(0, import_editor_notifications.notify)(COMPONENT_CIRCULAR_NESTING_ALERT);
|
|
4038
|
+
}
|
|
4039
|
+
return hasCircularComponent;
|
|
4040
|
+
}
|
|
4041
|
+
function blockCircularPaste(args) {
|
|
4042
|
+
const { storageType } = args;
|
|
4043
|
+
if (storageType !== "localstorage") {
|
|
4044
|
+
return false;
|
|
4045
|
+
}
|
|
4046
|
+
const data = window?.elementorCommon?.storage?.get();
|
|
4047
|
+
if (!data?.clipboard?.elements) {
|
|
4048
|
+
return false;
|
|
4049
|
+
}
|
|
4050
|
+
const allComponentIds = extractComponentIdsFromElements(data.clipboard.elements);
|
|
4051
|
+
const hasCircularComponent = allComponentIds.some(wouldCreateCircularNesting);
|
|
4052
|
+
if (hasCircularComponent) {
|
|
4053
|
+
(0, import_editor_notifications.notify)(COMPONENT_CIRCULAR_NESTING_ALERT);
|
|
4054
|
+
}
|
|
4055
|
+
return hasCircularComponent;
|
|
4056
|
+
}
|
|
4057
|
+
|
|
4058
|
+
// src/store/actions/remove-component-styles.ts
|
|
4059
|
+
var import_store55 = require("@elementor/store");
|
|
3937
4060
|
function removeComponentStyles(id2) {
|
|
3938
4061
|
apiClient.invalidateComponentConfigCache(id2);
|
|
3939
|
-
(0,
|
|
4062
|
+
(0, import_store55.__dispatch)(slice.actions.removeStyles({ id: id2 }));
|
|
3940
4063
|
}
|
|
3941
4064
|
|
|
3942
4065
|
// src/store/components-styles-provider.ts
|
|
3943
4066
|
var import_editor_styles_repository = require("@elementor/editor-styles-repository");
|
|
3944
|
-
var
|
|
4067
|
+
var import_store57 = require("@elementor/store");
|
|
3945
4068
|
var componentsStylesProvider = (0, import_editor_styles_repository.createStylesProvider)({
|
|
3946
4069
|
key: "components-styles",
|
|
3947
4070
|
priority: 100,
|
|
3948
|
-
subscribe: (cb) => (0,
|
|
4071
|
+
subscribe: (cb) => (0, import_store57.__subscribeWithSelector)(
|
|
3949
4072
|
(state) => state[SLICE_NAME],
|
|
3950
4073
|
() => {
|
|
3951
4074
|
cb();
|
|
@@ -3953,29 +4076,29 @@ var componentsStylesProvider = (0, import_editor_styles_repository.createStylesP
|
|
|
3953
4076
|
),
|
|
3954
4077
|
actions: {
|
|
3955
4078
|
all: () => {
|
|
3956
|
-
return selectFlatStyles((0,
|
|
4079
|
+
return selectFlatStyles((0, import_store57.__getState)());
|
|
3957
4080
|
},
|
|
3958
4081
|
get: (id2) => {
|
|
3959
|
-
return selectFlatStyles((0,
|
|
4082
|
+
return selectFlatStyles((0, import_store57.__getState)()).find((style) => style.id === id2) ?? null;
|
|
3960
4083
|
}
|
|
3961
4084
|
}
|
|
3962
4085
|
});
|
|
3963
4086
|
|
|
3964
4087
|
// src/sync/create-components-before-save.ts
|
|
3965
|
-
var
|
|
3966
|
-
var
|
|
4088
|
+
var import_editor_elements16 = require("@elementor/editor-elements");
|
|
4089
|
+
var import_store59 = require("@elementor/store");
|
|
3967
4090
|
async function createComponentsBeforeSave({
|
|
3968
4091
|
elements,
|
|
3969
4092
|
status
|
|
3970
4093
|
}) {
|
|
3971
|
-
const unpublishedComponents = selectUnpublishedComponents((0,
|
|
4094
|
+
const unpublishedComponents = selectUnpublishedComponents((0, import_store59.__getState)());
|
|
3972
4095
|
if (!unpublishedComponents.length) {
|
|
3973
4096
|
return;
|
|
3974
4097
|
}
|
|
3975
4098
|
try {
|
|
3976
4099
|
const uidToComponentId = await createComponents(unpublishedComponents, status);
|
|
3977
4100
|
updateComponentInstances(elements, uidToComponentId);
|
|
3978
|
-
(0,
|
|
4101
|
+
(0, import_store59.__dispatch)(
|
|
3979
4102
|
slice.actions.add(
|
|
3980
4103
|
unpublishedComponents.map((component) => ({
|
|
3981
4104
|
id: uidToComponentId.get(component.uid),
|
|
@@ -3985,7 +4108,7 @@ async function createComponentsBeforeSave({
|
|
|
3985
4108
|
}))
|
|
3986
4109
|
)
|
|
3987
4110
|
);
|
|
3988
|
-
(0,
|
|
4111
|
+
(0, import_store59.__dispatch)(slice.actions.resetUnpublished());
|
|
3989
4112
|
} catch (error) {
|
|
3990
4113
|
throw new Error(`Failed to publish components and update component instances: ${error}`);
|
|
3991
4114
|
}
|
|
@@ -4030,7 +4153,7 @@ function shouldUpdateElement(element, uidToComponentId) {
|
|
|
4030
4153
|
return { shouldUpdate: false, newComponentId: null };
|
|
4031
4154
|
}
|
|
4032
4155
|
function updateElementComponentId(elementId, componentId) {
|
|
4033
|
-
(0,
|
|
4156
|
+
(0, import_editor_elements16.updateElementSettings)({
|
|
4034
4157
|
id: elementId,
|
|
4035
4158
|
props: {
|
|
4036
4159
|
component_instance: {
|
|
@@ -4045,7 +4168,7 @@ function updateElementComponentId(elementId, componentId) {
|
|
|
4045
4168
|
}
|
|
4046
4169
|
|
|
4047
4170
|
// src/sync/set-component-overridable-props-settings-before-save.ts
|
|
4048
|
-
var
|
|
4171
|
+
var import_store61 = require("@elementor/store");
|
|
4049
4172
|
var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
4050
4173
|
container
|
|
4051
4174
|
}) => {
|
|
@@ -4053,15 +4176,15 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
|
4053
4176
|
if (!currentDocument || currentDocument.config.type !== COMPONENT_DOCUMENT_TYPE) {
|
|
4054
4177
|
return;
|
|
4055
4178
|
}
|
|
4056
|
-
const overridableProps = selectOverridableProps((0,
|
|
4179
|
+
const overridableProps = selectOverridableProps((0, import_store61.__getState)(), currentDocument.id);
|
|
4057
4180
|
if (overridableProps) {
|
|
4058
4181
|
container.settings.set("overridable_props", overridableProps);
|
|
4059
4182
|
}
|
|
4060
4183
|
};
|
|
4061
4184
|
|
|
4062
4185
|
// src/sync/update-archived-component-before-save.ts
|
|
4063
|
-
var
|
|
4064
|
-
var
|
|
4186
|
+
var import_editor_notifications2 = require("@elementor/editor-notifications");
|
|
4187
|
+
var import_store63 = require("@elementor/store");
|
|
4065
4188
|
var failedNotification = (message) => ({
|
|
4066
4189
|
type: "error",
|
|
4067
4190
|
message: `Failed to archive components: ${message}`,
|
|
@@ -4074,7 +4197,7 @@ var successNotification = (message) => ({
|
|
|
4074
4197
|
});
|
|
4075
4198
|
var updateArchivedComponentBeforeSave = async () => {
|
|
4076
4199
|
try {
|
|
4077
|
-
const archivedComponents = selectArchivedComponents((0,
|
|
4200
|
+
const archivedComponents = selectArchivedComponents((0, import_store63.__getState)());
|
|
4078
4201
|
if (!archivedComponents.length) {
|
|
4079
4202
|
return;
|
|
4080
4203
|
}
|
|
@@ -4084,10 +4207,10 @@ var updateArchivedComponentBeforeSave = async () => {
|
|
|
4084
4207
|
const failedIds = result.failedIds.join(", ");
|
|
4085
4208
|
const successIds = result.successIds.join(", ");
|
|
4086
4209
|
if (failedIds) {
|
|
4087
|
-
(0,
|
|
4210
|
+
(0, import_editor_notifications2.notify)(failedNotification(failedIds));
|
|
4088
4211
|
}
|
|
4089
4212
|
if (successIds) {
|
|
4090
|
-
(0,
|
|
4213
|
+
(0, import_editor_notifications2.notify)(successNotification(successIds));
|
|
4091
4214
|
}
|
|
4092
4215
|
} catch (error) {
|
|
4093
4216
|
throw new Error(`Failed to update archived components: ${error}`);
|
|
@@ -4124,24 +4247,24 @@ var beforeSave = ({ container, status }) => {
|
|
|
4124
4247
|
// src/init.ts
|
|
4125
4248
|
function init() {
|
|
4126
4249
|
import_editor_styles_repository2.stylesRepository.register(componentsStylesProvider);
|
|
4127
|
-
(0,
|
|
4250
|
+
(0, import_store65.__registerSlice)(slice);
|
|
4128
4251
|
(0, import_editor_panels4.__registerPanel)(panel);
|
|
4129
4252
|
(0, import_editor_canvas8.registerElementType)(
|
|
4130
4253
|
COMPONENT_WIDGET_TYPE,
|
|
4131
4254
|
(options) => createComponentType({ ...options, showLockedByModal: openEditModeDialog })
|
|
4132
4255
|
);
|
|
4133
|
-
(0,
|
|
4256
|
+
(0, import_editor_v1_adapters8.registerDataHook)("dependency", "editor/documents/close", (args) => {
|
|
4134
4257
|
const document = (0, import_editor_documents12.getV1CurrentDocument)();
|
|
4135
4258
|
if (document.config.type === COMPONENT_DOCUMENT_TYPE) {
|
|
4136
4259
|
args.mode = "autosave";
|
|
4137
4260
|
}
|
|
4138
4261
|
return true;
|
|
4139
4262
|
});
|
|
4140
|
-
(0,
|
|
4263
|
+
(0, import_editor_v1_adapters8.registerDataHook)("after", "preview/drop", onElementDrop);
|
|
4141
4264
|
window.elementorCommon.__beforeSave = beforeSave;
|
|
4142
4265
|
(0, import_editor_elements_panel.injectTab)({
|
|
4143
4266
|
id: "components",
|
|
4144
|
-
label: (0,
|
|
4267
|
+
label: (0, import_i18n25.__)("Components", "elementor"),
|
|
4145
4268
|
component: Components
|
|
4146
4269
|
});
|
|
4147
4270
|
(0, import_editor.injectIntoTop)({
|
|
@@ -4160,7 +4283,7 @@ function init() {
|
|
|
4160
4283
|
id: "component-panel-header",
|
|
4161
4284
|
component: ComponentPanelHeader
|
|
4162
4285
|
});
|
|
4163
|
-
(0,
|
|
4286
|
+
(0, import_editor_v1_adapters8.registerDataHook)("after", "editor/documents/attach-preview", async () => {
|
|
4164
4287
|
const { id: id2, config } = (0, import_editor_documents12.getV1CurrentDocument)();
|
|
4165
4288
|
if (id2) {
|
|
4166
4289
|
removeComponentStyles(id2);
|
|
@@ -4187,6 +4310,7 @@ function init() {
|
|
|
4187
4310
|
import_editor_canvas8.settingsTransformersRegistry.register("override", componentOverrideTransformer);
|
|
4188
4311
|
initRegenerateOverrideKeys();
|
|
4189
4312
|
initMcp();
|
|
4313
|
+
initCircularNestingPrevention();
|
|
4190
4314
|
}
|
|
4191
4315
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4192
4316
|
0 && (module.exports = {
|