@elementor/editor-components 4.0.0-504 → 4.0.0-506

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.mjs CHANGED
@@ -165,6 +165,12 @@ var slice = createSlice({
165
165
  }
166
166
  component.overridableProps = payload.overridableProps;
167
167
  },
168
+ clearOverridableProps: (state, { payload }) => {
169
+ const component = state.data.find((comp) => comp.id === payload.componentId);
170
+ if (component) {
171
+ component.overridableProps = void 0;
172
+ }
173
+ },
168
174
  rename: (state, { payload }) => {
169
175
  const component = state.data.find((comp) => comp.uid === payload.componentUid);
170
176
  if (!component) {
@@ -282,6 +288,7 @@ var selectUpdatedComponentNames = createSelector(
282
288
 
283
289
  // src/utils/component-document-data.ts
284
290
  import { getV1DocumentsManager } from "@elementor/editor-documents";
291
+ import { __dispatch as dispatch } from "@elementor/store";
285
292
  var getComponentDocumentData = async (id2) => {
286
293
  const documentManager = getV1DocumentsManager();
287
294
  try {
@@ -290,9 +297,11 @@ var getComponentDocumentData = async (id2) => {
290
297
  return null;
291
298
  }
292
299
  };
293
- var invalidateComponentDocumentData = (id2) => {
300
+ var invalidateComponentCache = (id2) => {
294
301
  const documentManager = getV1DocumentsManager();
295
302
  documentManager.invalidateCache(id2);
303
+ dispatch(slice.actions.removeStyles({ id: id2 }));
304
+ dispatch(slice.actions.clearOverridableProps({ componentId: id2 }));
296
305
  };
297
306
 
298
307
  // src/component-instance-transformer.ts
@@ -391,6 +400,7 @@ async function expandNavigator() {
391
400
  // src/utils/switch-to-component.ts
392
401
  async function switchToComponent(componentId, componentInstanceId, element) {
393
402
  const selector = getSelector(element, componentInstanceId);
403
+ invalidateComponentCache(componentId);
394
404
  await runCommand2("editor/documents/switch", {
395
405
  id: componentId,
396
406
  selector,
@@ -504,7 +514,7 @@ import { generateUniqueId as generateUniqueId2 } from "@elementor/utils";
504
514
  import { __ as __10 } from "@wordpress/i18n";
505
515
 
506
516
  // src/store/actions/add-overridable-group.ts
507
- import { __dispatch as dispatch, __getState as getState3 } from "@elementor/store";
517
+ import { __dispatch as dispatch2, __getState as getState3 } from "@elementor/store";
508
518
  function addOverridableGroup({
509
519
  componentId,
510
520
  groupId,
@@ -521,7 +531,7 @@ function addOverridableGroup({
521
531
  label,
522
532
  props: []
523
533
  };
524
- dispatch(
534
+ dispatch2(
525
535
  slice.actions.setOverridableProps({
526
536
  componentId,
527
537
  overridableProps: {
@@ -547,7 +557,7 @@ function addOverridableGroup({
547
557
  }
548
558
 
549
559
  // src/store/actions/delete-overridable-group.ts
550
- import { __dispatch as dispatch2, __getState as getState4 } from "@elementor/store";
560
+ import { __dispatch as dispatch3, __getState as getState4 } from "@elementor/store";
551
561
 
552
562
  // src/store/utils/groups-transformers.ts
553
563
  import { generateUniqueId } from "@elementor/utils";
@@ -704,7 +714,7 @@ function deleteOverridableGroup({ componentId, groupId }) {
704
714
  return false;
705
715
  }
706
716
  const updatedGroups = deleteGroup(overridableProps.groups, groupId);
707
- dispatch2(
717
+ dispatch3(
708
718
  slice.actions.setOverridableProps({
709
719
  componentId,
710
720
  overridableProps: {
@@ -717,7 +727,7 @@ function deleteOverridableGroup({ componentId, groupId }) {
717
727
  }
718
728
 
719
729
  // src/store/actions/delete-overridable-prop.ts
720
- import { __dispatch as dispatch3, __getState as getState6 } from "@elementor/store";
730
+ import { __dispatch as dispatch4, __getState as getState6 } from "@elementor/store";
721
731
 
722
732
  // src/utils/revert-overridable-settings.ts
723
733
  import {
@@ -1171,7 +1181,7 @@ function deleteOverridableProp({ componentId, propKey, source }) {
1171
1181
  revertElementOverridableSetting(prop.elementId, prop.propKey, prop.originValue, propKey);
1172
1182
  const { [propKey]: removedProp, ...remainingProps } = overridableProps.props;
1173
1183
  const updatedGroups = removePropFromAllGroups(overridableProps.groups, propKey);
1174
- dispatch3(
1184
+ dispatch4(
1175
1185
  slice.actions.setOverridableProps({
1176
1186
  componentId,
1177
1187
  overridableProps: {
@@ -1194,7 +1204,7 @@ function deleteOverridableProp({ componentId, propKey, source }) {
1194
1204
  }
1195
1205
 
1196
1206
  // src/store/actions/reorder-group-props.ts
1197
- import { __dispatch as dispatch4, __getState as getState7 } from "@elementor/store";
1207
+ import { __dispatch as dispatch5, __getState as getState7 } from "@elementor/store";
1198
1208
  function reorderGroupProps({ componentId, groupId, newPropsOrder }) {
1199
1209
  const overridableProps = selectOverridableProps(getState7(), componentId);
1200
1210
  if (!overridableProps) {
@@ -1204,7 +1214,7 @@ function reorderGroupProps({ componentId, groupId, newPropsOrder }) {
1204
1214
  if (!group) {
1205
1215
  return;
1206
1216
  }
1207
- dispatch4(
1217
+ dispatch5(
1208
1218
  slice.actions.setOverridableProps({
1209
1219
  componentId,
1210
1220
  overridableProps: {
@@ -1225,13 +1235,13 @@ function reorderGroupProps({ componentId, groupId, newPropsOrder }) {
1225
1235
  }
1226
1236
 
1227
1237
  // src/store/actions/reorder-overridable-groups.ts
1228
- import { __dispatch as dispatch5, __getState as getState8 } from "@elementor/store";
1238
+ import { __dispatch as dispatch6, __getState as getState8 } from "@elementor/store";
1229
1239
  function reorderOverridableGroups({ componentId, newOrder }) {
1230
1240
  const overridableProps = selectOverridableProps(getState8(), componentId);
1231
1241
  if (!overridableProps) {
1232
1242
  return;
1233
1243
  }
1234
- dispatch5(
1244
+ dispatch6(
1235
1245
  slice.actions.setOverridableProps({
1236
1246
  componentId,
1237
1247
  overridableProps: {
@@ -1246,7 +1256,7 @@ function reorderOverridableGroups({ componentId, newOrder }) {
1246
1256
  }
1247
1257
 
1248
1258
  // src/store/actions/update-overridable-prop-params.ts
1249
- import { __dispatch as dispatch6, __getState as getState9 } from "@elementor/store";
1259
+ import { __dispatch as dispatch7, __getState as getState9 } from "@elementor/store";
1250
1260
  function updateOverridablePropParams({
1251
1261
  componentId,
1252
1262
  overrideKey,
@@ -1269,7 +1279,7 @@ function updateOverridablePropParams({
1269
1279
  groupId: newGroupId
1270
1280
  };
1271
1281
  const updatedGroups = movePropBetweenGroups(overridableProps.groups, overrideKey, oldGroupId, newGroupId);
1272
- dispatch6(
1282
+ dispatch7(
1273
1283
  slice.actions.setOverridableProps({
1274
1284
  componentId,
1275
1285
  overridableProps: {
@@ -1853,7 +1863,7 @@ import { useEditable } from "@elementor/editor-ui";
1853
1863
  import { __ as __9 } from "@wordpress/i18n";
1854
1864
 
1855
1865
  // src/store/actions/rename-overridable-group.ts
1856
- import { __dispatch as dispatch7, __getState as getState10 } from "@elementor/store";
1866
+ import { __dispatch as dispatch8, __getState as getState10 } from "@elementor/store";
1857
1867
  function renameOverridableGroup({ componentId, groupId, label }) {
1858
1868
  const overridableProps = selectOverridableProps(getState10(), componentId);
1859
1869
  if (!overridableProps) {
@@ -1864,7 +1874,7 @@ function renameOverridableGroup({ componentId, groupId, label }) {
1864
1874
  return false;
1865
1875
  }
1866
1876
  const updatedGroups = renameGroup(overridableProps.groups, groupId, label);
1867
- dispatch7(
1877
+ dispatch8(
1868
1878
  slice.actions.setOverridableProps({
1869
1879
  componentId,
1870
1880
  overridableProps: {
@@ -2300,10 +2310,10 @@ var useComponentsPermissions = () => {
2300
2310
  // src/store/actions/rename-component.ts
2301
2311
  import { getV1DocumentsManager as getV1DocumentsManager4, setDocumentModifiedStatus as setDocumentModifiedStatus3 } from "@elementor/editor-documents";
2302
2312
  import { getAllDescendants as getAllDescendants2 } from "@elementor/editor-elements";
2303
- import { __dispatch as dispatch8 } from "@elementor/store";
2313
+ import { __dispatch as dispatch9 } from "@elementor/store";
2304
2314
  var TITLE_EXTERNAL_CHANGE_COMMAND = "title_external_change";
2305
2315
  var renameComponent = (componentUid, newName) => {
2306
- dispatch8(slice.actions.rename({ componentUid, name: newName }));
2316
+ dispatch9(slice.actions.rename({ componentUid, name: newName }));
2307
2317
  setDocumentModifiedStatus3(true);
2308
2318
  refreshComponentInstanceTitles(componentUid);
2309
2319
  };
@@ -2356,7 +2366,7 @@ import { __ as __18 } from "@wordpress/i18n";
2356
2366
  // src/store/actions/archive-component.ts
2357
2367
  import { setDocumentModifiedStatus as setDocumentModifiedStatus4 } from "@elementor/editor-documents";
2358
2368
  import { notify } from "@elementor/editor-notifications";
2359
- import { __dispatch as dispatch9 } from "@elementor/store";
2369
+ import { __dispatch as dispatch10 } from "@elementor/store";
2360
2370
  import { __ as __15 } from "@wordpress/i18n";
2361
2371
  var successNotification = (componentId, componentName) => ({
2362
2372
  type: "success",
@@ -2365,7 +2375,7 @@ var successNotification = (componentId, componentName) => ({
2365
2375
  id: `success-archived-components-notification-${componentId}`
2366
2376
  });
2367
2377
  var archiveComponent = (componentId, componentName) => {
2368
- dispatch9(slice.actions.archive(componentId));
2378
+ dispatch10(slice.actions.archive(componentId));
2369
2379
  setDocumentModifiedStatus4(true);
2370
2380
  notify(successNotification(componentId, componentName));
2371
2381
  };
@@ -2417,7 +2427,7 @@ async function getDocumentsMap(ids, cache) {
2417
2427
  }
2418
2428
 
2419
2429
  // src/store/actions/load-components-overridable-props.ts
2420
- import { __dispatch as dispatch10, __getState as getState12 } from "@elementor/store";
2430
+ import { __dispatch as dispatch11, __getState as getState12 } from "@elementor/store";
2421
2431
  function loadComponentsOverridableProps(componentIds) {
2422
2432
  if (!componentIds.length) {
2423
2433
  return;
@@ -2433,7 +2443,7 @@ async function loadComponentOverrides(componentId) {
2433
2443
  if (!overridableProps) {
2434
2444
  return;
2435
2445
  }
2436
- dispatch10(
2446
+ dispatch11(
2437
2447
  slice.actions.setOverridableProps({
2438
2448
  componentId,
2439
2449
  overridableProps
@@ -2442,7 +2452,7 @@ async function loadComponentOverrides(componentId) {
2442
2452
  }
2443
2453
 
2444
2454
  // src/store/actions/load-components-styles.ts
2445
- import { __dispatch as dispatch11, __getState as getState13 } from "@elementor/store";
2455
+ import { __dispatch as dispatch12, __getState as getState13 } from "@elementor/store";
2446
2456
  function loadComponentsStyles(documents) {
2447
2457
  if (!documents.size) {
2448
2458
  return;
@@ -2458,7 +2468,7 @@ function addStyles(documents) {
2458
2468
  const styles = Object.fromEntries(
2459
2469
  [...documents.entries()].map(([id2, document]) => [id2, extractStylesFromDocument(document)])
2460
2470
  );
2461
- dispatch11(slice.actions.addStyles(styles));
2471
+ dispatch12(slice.actions.addStyles(styles));
2462
2472
  }
2463
2473
  function extractStylesFromDocument(document) {
2464
2474
  if (!document.elements?.length) {
@@ -3132,7 +3142,7 @@ function findNonAtomicElementsInElement(element) {
3132
3142
  // src/store/actions/create-unpublished-component.ts
3133
3143
  import { createElements, deleteElement, getContainer as getContainer3 } from "@elementor/editor-elements";
3134
3144
  import { __privateRunCommand as runCommand3 } from "@elementor/editor-v1-adapters";
3135
- import { __dispatch as dispatch12 } from "@elementor/store";
3145
+ import { __dispatch as dispatch13 } from "@elementor/store";
3136
3146
  import { generateUniqueId as generateUniqueId3 } from "@elementor/utils";
3137
3147
  import { __ as __22 } from "@wordpress/i18n";
3138
3148
  async function createUnpublishedComponent({
@@ -3153,14 +3163,14 @@ async function createUnpublishedComponent({
3153
3163
  parentId: container?.parent?.id ?? "",
3154
3164
  index: container?.view?._index ?? 0
3155
3165
  };
3156
- dispatch12(
3166
+ dispatch13(
3157
3167
  slice.actions.addUnpublished({
3158
3168
  ...componentBase,
3159
3169
  elements: [elementDataWithOverridablesReverted],
3160
3170
  overridableProps
3161
3171
  })
3162
3172
  );
3163
- dispatch12(slice.actions.addCreatedThisSession(generatedUid));
3173
+ dispatch13(slice.actions.addCreatedThisSession(generatedUid));
3164
3174
  const componentInstance = await replaceElementWithComponent(element, componentBase);
3165
3175
  trackComponentEvent({
3166
3176
  action: "created",
@@ -3173,8 +3183,8 @@ async function createUnpublishedComponent({
3173
3183
  await runCommand3("document/save/auto");
3174
3184
  } catch (error) {
3175
3185
  restoreOriginalElement(originalElement, componentInstance.id);
3176
- dispatch12(slice.actions.removeUnpublished(generatedUid));
3177
- dispatch12(slice.actions.removeCreatedThisSession(generatedUid));
3186
+ dispatch13(slice.actions.removeUnpublished(generatedUid));
3187
+ dispatch13(slice.actions.removeCreatedThisSession(generatedUid));
3178
3188
  throw error;
3179
3189
  }
3180
3190
  return { uid: generatedUid, instanceId: componentInstance.id };
@@ -3468,12 +3478,12 @@ function updateCurrentComponent({
3468
3478
  path,
3469
3479
  currentComponentId
3470
3480
  }) {
3471
- const dispatch20 = getStore2()?.dispatch;
3472
- if (!dispatch20) {
3481
+ const dispatch21 = getStore2()?.dispatch;
3482
+ if (!dispatch21) {
3473
3483
  return;
3474
3484
  }
3475
- dispatch20(slice.actions.setPath(path));
3476
- dispatch20(slice.actions.setCurrentComponentId(currentComponentId));
3485
+ dispatch21(slice.actions.setPath(path));
3486
+ dispatch21(slice.actions.setCurrentComponentId(currentComponentId));
3477
3487
  }
3478
3488
 
3479
3489
  // src/components/edit-component/component-modal.tsx
@@ -3887,7 +3897,7 @@ var useOverridablePropValue = () => useContext2(OverridablePropContext)?.value;
3887
3897
  var useComponentInstanceElement = () => useContext2(OverridablePropContext)?.componentInstanceElement;
3888
3898
 
3889
3899
  // src/store/actions/update-overridable-prop.ts
3890
- import { __dispatch as dispatch13, __getState as getState16 } from "@elementor/store";
3900
+ import { __dispatch as dispatch14, __getState as getState16 } from "@elementor/store";
3891
3901
 
3892
3902
  // src/utils/resolve-override-prop-value.ts
3893
3903
  var resolveOverridePropValue = (originalPropValue) => {
@@ -3947,7 +3957,7 @@ function updateOverridableProp(componentId, propValue, originPropFields) {
3947
3957
  }
3948
3958
  }
3949
3959
  };
3950
- dispatch13(
3960
+ dispatch14(
3951
3961
  slice.actions.setOverridableProps({
3952
3962
  componentId,
3953
3963
  overridableProps: newOverridableProps
@@ -4316,7 +4326,7 @@ import { bindPopover as bindPopover2, bindTrigger as bindTrigger4, Popover as Po
4316
4326
  import { __ as __29 } from "@wordpress/i18n";
4317
4327
 
4318
4328
  // src/store/actions/set-overridable-prop.ts
4319
- import { __dispatch as dispatch14, __getState as getState17 } from "@elementor/store";
4329
+ import { __dispatch as dispatch15, __getState as getState17 } from "@elementor/store";
4320
4330
  import { generateUniqueId as generateUniqueId4 } from "@elementor/utils";
4321
4331
  function setOverridableProp({
4322
4332
  componentId,
@@ -4368,7 +4378,7 @@ function setOverridableProp({
4368
4378
  if (isChangingGroups) {
4369
4379
  groups = removePropFromGroup(groups, existingOverridableProp.groupId, overridableProp.overrideKey);
4370
4380
  }
4371
- dispatch14(
4381
+ dispatch15(
4372
4382
  slice.actions.setOverridableProps({
4373
4383
  componentId,
4374
4384
  overridableProps: {
@@ -4933,10 +4943,10 @@ function initMcp() {
4933
4943
 
4934
4944
  // src/populate-store.ts
4935
4945
  import { useEffect as useEffect6 } from "react";
4936
- import { __dispatch as dispatch15 } from "@elementor/store";
4946
+ import { __dispatch as dispatch16 } from "@elementor/store";
4937
4947
  function PopulateStore() {
4938
4948
  useEffect6(() => {
4939
- dispatch15(loadComponents());
4949
+ dispatch16(loadComponents());
4940
4950
  }, []);
4941
4951
  return null;
4942
4952
  }
@@ -5069,10 +5079,10 @@ function blockCircularPaste(args) {
5069
5079
  }
5070
5080
 
5071
5081
  // src/store/actions/remove-component-styles.ts
5072
- import { __dispatch as dispatch16 } from "@elementor/store";
5082
+ import { __dispatch as dispatch17 } from "@elementor/store";
5073
5083
  function removeComponentStyles(id2) {
5074
5084
  apiClient.invalidateComponentConfigCache(id2);
5075
- dispatch16(slice.actions.removeStyles({ id: id2 }));
5085
+ dispatch17(slice.actions.removeStyles({ id: id2 }));
5076
5086
  }
5077
5087
 
5078
5088
  // src/store/components-styles-provider.ts
@@ -5099,7 +5109,7 @@ var componentsStylesProvider = createStylesProvider({
5099
5109
 
5100
5110
  // src/sync/create-components-before-save.ts
5101
5111
  import { updateElementSettings as updateElementSettings2 } from "@elementor/editor-elements";
5102
- import { __dispatch as dispatch17, __getState as getState21 } from "@elementor/store";
5112
+ import { __dispatch as dispatch18, __getState as getState21 } from "@elementor/store";
5103
5113
  async function createComponentsBeforeSave({
5104
5114
  elements,
5105
5115
  status
@@ -5111,7 +5121,7 @@ async function createComponentsBeforeSave({
5111
5121
  try {
5112
5122
  const uidToComponentId = await createComponents(unpublishedComponents, status);
5113
5123
  updateComponentInstances(elements, uidToComponentId);
5114
- dispatch17(
5124
+ dispatch18(
5115
5125
  slice.actions.add(
5116
5126
  unpublishedComponents.map((component) => ({
5117
5127
  id: uidToComponentId.get(component.uid),
@@ -5121,10 +5131,10 @@ async function createComponentsBeforeSave({
5121
5131
  }))
5122
5132
  )
5123
5133
  );
5124
- dispatch17(slice.actions.resetUnpublished());
5134
+ dispatch18(slice.actions.resetUnpublished());
5125
5135
  } catch (error) {
5126
5136
  const failedUids = unpublishedComponents.map((component) => component.uid);
5127
- dispatch17(slice.actions.removeUnpublished(failedUids));
5137
+ dispatch18(slice.actions.removeUnpublished(failedUids));
5128
5138
  throw new Error(`Failed to publish components: ${error}`);
5129
5139
  }
5130
5140
  }
@@ -5194,7 +5204,7 @@ async function publishDraftComponentsInPageBeforeSave({ status, elements }) {
5194
5204
  return;
5195
5205
  }
5196
5206
  await apiClient.updateStatuses(draftIds, "publish");
5197
- draftIds.forEach((id2) => invalidateComponentDocumentData(id2));
5207
+ draftIds.forEach((id2) => invalidateComponentCache(id2));
5198
5208
  }
5199
5209
 
5200
5210
  // src/sync/set-component-overridable-props-settings-before-save.ts
@@ -5237,7 +5247,7 @@ var updateArchivedComponentBeforeSave = async (status) => {
5237
5247
  };
5238
5248
 
5239
5249
  // src/sync/update-component-title-before-save.ts
5240
- import { __dispatch as dispatch18, __getState as getState24 } from "@elementor/store";
5250
+ import { __dispatch as dispatch19, __getState as getState24 } from "@elementor/store";
5241
5251
  var updateComponentTitleBeforeSave = async (status) => {
5242
5252
  const updatedComponentNames = selectUpdatedComponentNames(getState24());
5243
5253
  if (!updatedComponentNames.length) {
@@ -5245,7 +5255,7 @@ var updateComponentTitleBeforeSave = async (status) => {
5245
5255
  }
5246
5256
  const result = await apiClient.updateComponentTitle(updatedComponentNames, status);
5247
5257
  if (result.failedIds.length === 0) {
5248
- dispatch18(slice.actions.cleanUpdatedComponentNames());
5258
+ dispatch19(slice.actions.cleanUpdatedComponentNames());
5249
5259
  }
5250
5260
  };
5251
5261
 
@@ -5273,7 +5283,7 @@ var updateExistingComponentsBeforeSave = async ({
5273
5283
  // src/sync/cleanup-overridable-props-on-delete.ts
5274
5284
  import { getAllDescendants as getAllDescendants5 } from "@elementor/editor-elements";
5275
5285
  import { registerDataHook } from "@elementor/editor-v1-adapters";
5276
- import { __dispatch as dispatch19, __getState as getState25 } from "@elementor/store";
5286
+ import { __dispatch as dispatch20, __getState as getState25 } from "@elementor/store";
5277
5287
  function initCleanupOverridablePropsOnDelete() {
5278
5288
  registerDataHook("dependency", "document/elements/delete", (args) => {
5279
5289
  const state = getState25();
@@ -5307,7 +5317,7 @@ function initCleanupOverridablePropsOnDelete() {
5307
5317
  for (const propKey of propKeysToDelete) {
5308
5318
  updatedGroups = removePropFromAllGroups(updatedGroups, propKey);
5309
5319
  }
5310
- dispatch19(
5320
+ dispatch20(
5311
5321
  slice.actions.setOverridableProps({
5312
5322
  componentId: currentComponentId,
5313
5323
  overridableProps: {