@elementor/editor-components 3.35.0-434 → 3.35.0-436
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 +105 -50
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +91 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -22
- package/src/hooks/cleanup-overridable-props-on-delete.ts +83 -0
- package/src/init.ts +3 -0
package/dist/index.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import { injectTab } from "@elementor/editor-elements-panel";
|
|
16
16
|
import { __registerPanel as registerPanel } from "@elementor/editor-panels";
|
|
17
17
|
import { stylesRepository } from "@elementor/editor-styles-repository";
|
|
18
|
-
import { registerDataHook as
|
|
18
|
+
import { registerDataHook as registerDataHook3 } from "@elementor/editor-v1-adapters";
|
|
19
19
|
import { __registerSlice as registerSlice } from "@elementor/store";
|
|
20
20
|
import { __ as __30 } from "@wordpress/i18n";
|
|
21
21
|
|
|
@@ -3158,12 +3158,12 @@ function updateCurrentComponent({
|
|
|
3158
3158
|
path,
|
|
3159
3159
|
currentComponentId
|
|
3160
3160
|
}) {
|
|
3161
|
-
const
|
|
3162
|
-
if (!
|
|
3161
|
+
const dispatch20 = getStore2()?.dispatch;
|
|
3162
|
+
if (!dispatch20) {
|
|
3163
3163
|
return;
|
|
3164
3164
|
}
|
|
3165
|
-
|
|
3166
|
-
|
|
3165
|
+
dispatch20(slice.actions.setPath(path));
|
|
3166
|
+
dispatch20(slice.actions.setCurrentComponentId(currentComponentId));
|
|
3167
3167
|
}
|
|
3168
3168
|
|
|
3169
3169
|
// src/components/edit-component/component-modal.tsx
|
|
@@ -4233,18 +4233,72 @@ function isPropAllowed(bind) {
|
|
|
4233
4233
|
return !FORBIDDEN_KEYS.includes(bind);
|
|
4234
4234
|
}
|
|
4235
4235
|
|
|
4236
|
-
// src/hooks/
|
|
4237
|
-
import { getAllDescendants as getAllDescendants3
|
|
4236
|
+
// src/hooks/cleanup-overridable-props-on-delete.ts
|
|
4237
|
+
import { getAllDescendants as getAllDescendants3 } from "@elementor/editor-elements";
|
|
4238
4238
|
import { registerDataHook } from "@elementor/editor-v1-adapters";
|
|
4239
|
+
import { __dispatch as dispatch15, __getState as getState19 } from "@elementor/store";
|
|
4240
|
+
function initCleanupOverridablePropsOnDelete() {
|
|
4241
|
+
registerDataHook("after", "document/elements/delete", (args) => {
|
|
4242
|
+
const state = getState19();
|
|
4243
|
+
if (!state) {
|
|
4244
|
+
return;
|
|
4245
|
+
}
|
|
4246
|
+
const currentComponentId = selectCurrentComponentId(state);
|
|
4247
|
+
if (!currentComponentId) {
|
|
4248
|
+
return;
|
|
4249
|
+
}
|
|
4250
|
+
const overridableProps = selectOverridableProps(state, currentComponentId);
|
|
4251
|
+
if (!overridableProps || Object.keys(overridableProps.props).length === 0) {
|
|
4252
|
+
return;
|
|
4253
|
+
}
|
|
4254
|
+
const containers = args.containers ?? (args.container ? [args.container] : []);
|
|
4255
|
+
if (containers.length === 0) {
|
|
4256
|
+
return;
|
|
4257
|
+
}
|
|
4258
|
+
const deletedElementIds = collectDeletedElementIds(containers);
|
|
4259
|
+
if (deletedElementIds.length === 0) {
|
|
4260
|
+
return;
|
|
4261
|
+
}
|
|
4262
|
+
const propKeysToDelete = Object.entries(overridableProps.props).filter(([, prop]) => deletedElementIds.includes(prop.elementId)).map(([propKey]) => propKey);
|
|
4263
|
+
if (propKeysToDelete.length === 0) {
|
|
4264
|
+
return;
|
|
4265
|
+
}
|
|
4266
|
+
const remainingProps = Object.fromEntries(
|
|
4267
|
+
Object.entries(overridableProps.props).filter(([propKey]) => !propKeysToDelete.includes(propKey))
|
|
4268
|
+
);
|
|
4269
|
+
let updatedGroups = overridableProps.groups;
|
|
4270
|
+
for (const propKey of propKeysToDelete) {
|
|
4271
|
+
updatedGroups = removePropFromAllGroups(updatedGroups, propKey);
|
|
4272
|
+
}
|
|
4273
|
+
dispatch15(
|
|
4274
|
+
slice.actions.setOverridableProps({
|
|
4275
|
+
componentId: currentComponentId,
|
|
4276
|
+
overridableProps: {
|
|
4277
|
+
...overridableProps,
|
|
4278
|
+
props: remainingProps,
|
|
4279
|
+
groups: updatedGroups
|
|
4280
|
+
}
|
|
4281
|
+
})
|
|
4282
|
+
);
|
|
4283
|
+
});
|
|
4284
|
+
}
|
|
4285
|
+
function collectDeletedElementIds(containers) {
|
|
4286
|
+
const elementIds = containers.filter(Boolean).flatMap((container) => [container, ...getAllDescendants3(container)]).map((element) => element.model?.get?.("id") ?? element.id).filter((id2) => Boolean(id2));
|
|
4287
|
+
return elementIds;
|
|
4288
|
+
}
|
|
4289
|
+
|
|
4290
|
+
// src/hooks/regenerate-override-keys.ts
|
|
4291
|
+
import { getAllDescendants as getAllDescendants4, getContainer as getContainer3, updateElementSettings as updateElementSettings2 } from "@elementor/editor-elements";
|
|
4292
|
+
import { registerDataHook as registerDataHook2 } from "@elementor/editor-v1-adapters";
|
|
4239
4293
|
import { generateUniqueId as generateUniqueId5 } from "@elementor/utils";
|
|
4240
4294
|
function initRegenerateOverrideKeys() {
|
|
4241
|
-
|
|
4295
|
+
registerDataHook2("after", "document/elements/duplicate", (_args, result) => {
|
|
4242
4296
|
regenerateOverrideKeysForContainers(result);
|
|
4243
4297
|
});
|
|
4244
|
-
|
|
4298
|
+
registerDataHook2("after", "document/elements/paste", (_args, result) => {
|
|
4245
4299
|
regenerateOverrideKeysForContainers(result);
|
|
4246
4300
|
});
|
|
4247
|
-
|
|
4301
|
+
registerDataHook2("after", "document/elements/import", (_args, result) => {
|
|
4248
4302
|
regenerateOverrideKeysForContainers(result);
|
|
4249
4303
|
});
|
|
4250
4304
|
}
|
|
@@ -4259,7 +4313,7 @@ function regenerateOverrideKeysRecursive(elementId) {
|
|
|
4259
4313
|
if (!container) {
|
|
4260
4314
|
return;
|
|
4261
4315
|
}
|
|
4262
|
-
|
|
4316
|
+
getAllDescendants4(container).forEach(regenerateOverrideKeys);
|
|
4263
4317
|
}
|
|
4264
4318
|
function regenerateOverrideKeys(element) {
|
|
4265
4319
|
if (!isComponentInstance(element.model.toJSON())) {
|
|
@@ -4649,19 +4703,19 @@ function initMcp() {
|
|
|
4649
4703
|
|
|
4650
4704
|
// src/populate-store.ts
|
|
4651
4705
|
import { useEffect as useEffect6 } from "react";
|
|
4652
|
-
import { __dispatch as
|
|
4706
|
+
import { __dispatch as dispatch16 } from "@elementor/store";
|
|
4653
4707
|
function PopulateStore() {
|
|
4654
4708
|
useEffect6(() => {
|
|
4655
|
-
|
|
4709
|
+
dispatch16(loadComponents());
|
|
4656
4710
|
}, []);
|
|
4657
4711
|
return null;
|
|
4658
4712
|
}
|
|
4659
4713
|
|
|
4660
4714
|
// src/prevent-circular-nesting.ts
|
|
4661
|
-
import { getAllDescendants as
|
|
4715
|
+
import { getAllDescendants as getAllDescendants5 } from "@elementor/editor-elements";
|
|
4662
4716
|
import { notify as notify4 } from "@elementor/editor-notifications";
|
|
4663
4717
|
import { blockCommand as blockCommand2 } from "@elementor/editor-v1-adapters";
|
|
4664
|
-
import { __getState as
|
|
4718
|
+
import { __getState as getState20 } from "@elementor/store";
|
|
4665
4719
|
import { __ as __29 } from "@wordpress/i18n";
|
|
4666
4720
|
var COMPONENT_TYPE = "e-component";
|
|
4667
4721
|
var COMPONENT_CIRCULAR_NESTING_ALERT = {
|
|
@@ -4687,7 +4741,7 @@ function wouldCreateCircularNesting(componentIdToAdd) {
|
|
|
4687
4741
|
if (componentIdToAdd === void 0) {
|
|
4688
4742
|
return false;
|
|
4689
4743
|
}
|
|
4690
|
-
const state =
|
|
4744
|
+
const state = getState20();
|
|
4691
4745
|
const currentComponentId = selectCurrentComponentId(state);
|
|
4692
4746
|
const path = selectPath(state);
|
|
4693
4747
|
if (currentComponentId === null) {
|
|
@@ -4753,7 +4807,7 @@ function blockCircularMove(args) {
|
|
|
4753
4807
|
if (!container) {
|
|
4754
4808
|
return false;
|
|
4755
4809
|
}
|
|
4756
|
-
const allElements =
|
|
4810
|
+
const allElements = getAllDescendants5(container);
|
|
4757
4811
|
return allElements.some((element) => {
|
|
4758
4812
|
const componentId = extractComponentIdFromContainer(element);
|
|
4759
4813
|
if (componentId === null) {
|
|
@@ -4785,15 +4839,15 @@ function blockCircularPaste(args) {
|
|
|
4785
4839
|
}
|
|
4786
4840
|
|
|
4787
4841
|
// src/store/actions/remove-component-styles.ts
|
|
4788
|
-
import { __dispatch as
|
|
4842
|
+
import { __dispatch as dispatch17 } from "@elementor/store";
|
|
4789
4843
|
function removeComponentStyles(id2) {
|
|
4790
4844
|
apiClient.invalidateComponentConfigCache(id2);
|
|
4791
|
-
|
|
4845
|
+
dispatch17(slice.actions.removeStyles({ id: id2 }));
|
|
4792
4846
|
}
|
|
4793
4847
|
|
|
4794
4848
|
// src/store/components-styles-provider.ts
|
|
4795
4849
|
import { createStylesProvider } from "@elementor/editor-styles-repository";
|
|
4796
|
-
import { __getState as
|
|
4850
|
+
import { __getState as getState21, __subscribeWithSelector as subscribeWithSelector } from "@elementor/store";
|
|
4797
4851
|
var componentsStylesProvider = createStylesProvider({
|
|
4798
4852
|
key: "components-styles",
|
|
4799
4853
|
priority: 100,
|
|
@@ -4805,29 +4859,29 @@ var componentsStylesProvider = createStylesProvider({
|
|
|
4805
4859
|
),
|
|
4806
4860
|
actions: {
|
|
4807
4861
|
all: () => {
|
|
4808
|
-
return selectFlatStyles(
|
|
4862
|
+
return selectFlatStyles(getState21());
|
|
4809
4863
|
},
|
|
4810
4864
|
get: (id2) => {
|
|
4811
|
-
return selectFlatStyles(
|
|
4865
|
+
return selectFlatStyles(getState21()).find((style) => style.id === id2) ?? null;
|
|
4812
4866
|
}
|
|
4813
4867
|
}
|
|
4814
4868
|
});
|
|
4815
4869
|
|
|
4816
4870
|
// src/sync/create-components-before-save.ts
|
|
4817
4871
|
import { updateElementSettings as updateElementSettings3 } from "@elementor/editor-elements";
|
|
4818
|
-
import { __dispatch as
|
|
4872
|
+
import { __dispatch as dispatch18, __getState as getState22 } from "@elementor/store";
|
|
4819
4873
|
async function createComponentsBeforeSave({
|
|
4820
4874
|
elements,
|
|
4821
4875
|
status
|
|
4822
4876
|
}) {
|
|
4823
|
-
const unpublishedComponents = selectUnpublishedComponents(
|
|
4877
|
+
const unpublishedComponents = selectUnpublishedComponents(getState22());
|
|
4824
4878
|
if (!unpublishedComponents.length) {
|
|
4825
4879
|
return;
|
|
4826
4880
|
}
|
|
4827
4881
|
try {
|
|
4828
4882
|
const uidToComponentId = await createComponents(unpublishedComponents, status);
|
|
4829
4883
|
updateComponentInstances(elements, uidToComponentId);
|
|
4830
|
-
|
|
4884
|
+
dispatch18(
|
|
4831
4885
|
slice.actions.add(
|
|
4832
4886
|
unpublishedComponents.map((component) => ({
|
|
4833
4887
|
id: uidToComponentId.get(component.uid),
|
|
@@ -4837,7 +4891,7 @@ async function createComponentsBeforeSave({
|
|
|
4837
4891
|
}))
|
|
4838
4892
|
)
|
|
4839
4893
|
);
|
|
4840
|
-
|
|
4894
|
+
dispatch18(slice.actions.resetUnpublished());
|
|
4841
4895
|
} catch (error) {
|
|
4842
4896
|
throw new Error(`Failed to publish components and update component instances: ${error}`);
|
|
4843
4897
|
}
|
|
@@ -4897,7 +4951,7 @@ function updateElementComponentId(elementId, componentId) {
|
|
|
4897
4951
|
}
|
|
4898
4952
|
|
|
4899
4953
|
// src/sync/set-component-overridable-props-settings-before-save.ts
|
|
4900
|
-
import { __getState as
|
|
4954
|
+
import { __getState as getState23 } from "@elementor/store";
|
|
4901
4955
|
var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
4902
4956
|
container
|
|
4903
4957
|
}) => {
|
|
@@ -4905,7 +4959,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
|
4905
4959
|
if (!currentDocument || currentDocument.config.type !== COMPONENT_DOCUMENT_TYPE) {
|
|
4906
4960
|
return;
|
|
4907
4961
|
}
|
|
4908
|
-
const overridableProps = selectOverridableProps(
|
|
4962
|
+
const overridableProps = selectOverridableProps(getState23(), currentDocument.id);
|
|
4909
4963
|
if (overridableProps) {
|
|
4910
4964
|
container.settings.set("overridable_props", overridableProps);
|
|
4911
4965
|
}
|
|
@@ -4913,7 +4967,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
|
|
|
4913
4967
|
|
|
4914
4968
|
// src/sync/update-archived-component-before-save.ts
|
|
4915
4969
|
import { notify as notify5 } from "@elementor/editor-notifications";
|
|
4916
|
-
import { __getState as
|
|
4970
|
+
import { __getState as getState24 } from "@elementor/store";
|
|
4917
4971
|
var failedNotification = (message) => ({
|
|
4918
4972
|
type: "error",
|
|
4919
4973
|
message: `Failed to archive components: ${message}`,
|
|
@@ -4921,7 +4975,7 @@ var failedNotification = (message) => ({
|
|
|
4921
4975
|
});
|
|
4922
4976
|
var updateArchivedComponentBeforeSave = async () => {
|
|
4923
4977
|
try {
|
|
4924
|
-
const archivedComponents = selectArchivedComponents(
|
|
4978
|
+
const archivedComponents = selectArchivedComponents(getState24());
|
|
4925
4979
|
if (!archivedComponents.length) {
|
|
4926
4980
|
return;
|
|
4927
4981
|
}
|
|
@@ -4938,15 +4992,15 @@ var updateArchivedComponentBeforeSave = async () => {
|
|
|
4938
4992
|
};
|
|
4939
4993
|
|
|
4940
4994
|
// src/sync/update-component-title-before-save.ts
|
|
4941
|
-
import { __dispatch as
|
|
4995
|
+
import { __dispatch as dispatch19, __getState as getState25 } from "@elementor/store";
|
|
4942
4996
|
var updateComponentTitleBeforeSave = async () => {
|
|
4943
|
-
const updatedComponentNames = selectUpdatedComponentNames(
|
|
4997
|
+
const updatedComponentNames = selectUpdatedComponentNames(getState25());
|
|
4944
4998
|
if (!updatedComponentNames.length) {
|
|
4945
4999
|
return;
|
|
4946
5000
|
}
|
|
4947
5001
|
const result = await apiClient.updateComponentTitle(updatedComponentNames);
|
|
4948
5002
|
if (result.failedIds.length === 0) {
|
|
4949
|
-
|
|
5003
|
+
dispatch19(slice.actions.cleanUpdatedComponentNames());
|
|
4950
5004
|
}
|
|
4951
5005
|
};
|
|
4952
5006
|
|
|
@@ -4987,14 +5041,14 @@ function init() {
|
|
|
4987
5041
|
COMPONENT_WIDGET_TYPE,
|
|
4988
5042
|
(options) => createComponentType({ ...options, showLockedByModal: openEditModeDialog })
|
|
4989
5043
|
);
|
|
4990
|
-
|
|
5044
|
+
registerDataHook3("dependency", "editor/documents/close", (args) => {
|
|
4991
5045
|
const document = getV1CurrentDocument();
|
|
4992
5046
|
if (document.config.type === COMPONENT_DOCUMENT_TYPE) {
|
|
4993
5047
|
args.mode = "autosave";
|
|
4994
5048
|
}
|
|
4995
5049
|
return true;
|
|
4996
5050
|
});
|
|
4997
|
-
|
|
5051
|
+
registerDataHook3("after", "preview/drop", onElementDrop);
|
|
4998
5052
|
window.elementorCommon.__beforeSave = beforeSave;
|
|
4999
5053
|
injectTab({
|
|
5000
5054
|
id: "components",
|
|
@@ -5018,7 +5072,7 @@ function init() {
|
|
|
5018
5072
|
id: "component-panel-header",
|
|
5019
5073
|
component: ComponentPanelHeader
|
|
5020
5074
|
});
|
|
5021
|
-
|
|
5075
|
+
registerDataHook3("after", "editor/documents/attach-preview", async () => {
|
|
5022
5076
|
const { id: id2, config } = getV1CurrentDocument();
|
|
5023
5077
|
if (id2) {
|
|
5024
5078
|
removeComponentStyles(id2);
|
|
@@ -5045,6 +5099,7 @@ function init() {
|
|
|
5045
5099
|
settingsTransformersRegistry2.register("overridable", componentOverridableTransformer);
|
|
5046
5100
|
settingsTransformersRegistry2.register("override", componentOverrideTransformer);
|
|
5047
5101
|
initRegenerateOverrideKeys();
|
|
5102
|
+
initCleanupOverridablePropsOnDelete();
|
|
5048
5103
|
initMcp();
|
|
5049
5104
|
initCircularNestingPrevention();
|
|
5050
5105
|
initNonAtomicNestingPrevention();
|