@elementor/editor-components 4.2.0-beta1 → 4.3.0-1000

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
@@ -2503,7 +2503,7 @@ async function getComponentDocuments({
2503
2503
  }
2504
2504
  async function getComponentIds(elements, cache, isRecursive) {
2505
2505
  const results = await Promise.all(
2506
- elements.map(async ({ widgetType, elType, elements: childElements, settings }) => {
2506
+ elements.filter(Boolean).map(async ({ widgetType, elType, elements: childElements, settings }) => {
2507
2507
  const ids = [];
2508
2508
  if (isComponentInstance({ widgetType, elType })) {
2509
2509
  const componentId = settings?.component_instance?.value?.component_id.value;
@@ -2543,17 +2543,20 @@ async function getDocumentsMap(ids, cache) {
2543
2543
 
2544
2544
  // src/store/actions/load-components-overridable-props.ts
2545
2545
  import { __dispatch as dispatch3, __getState as getState6 } from "@elementor/store";
2546
- async function loadComponentsOverridableProps(componentIds) {
2547
- const unloadedIds = componentIds.filter((id) => !selectIsOverridablePropsLoaded(getState6(), id));
2548
- if (!unloadedIds.length) {
2546
+ async function loadComponentsOverridableProps(componentIds, { force = false } = {}) {
2547
+ const idsToLoad = force ? componentIds : componentIds.filter((id) => !selectIsOverridablePropsLoaded(getState6(), id));
2548
+ if (!idsToLoad.length) {
2549
2549
  return;
2550
2550
  }
2551
- const { data } = await apiClient.getOverridableProps(unloadedIds);
2551
+ const { data } = await apiClient.getOverridableProps(idsToLoad);
2552
2552
  dispatch3(slice.actions.loadOverridableProps(data));
2553
2553
  }
2554
2554
 
2555
2555
  // src/store/actions/load-components-assets.ts
2556
2556
  async function loadComponentsAssets(elements) {
2557
+ if (!elements.length) {
2558
+ return;
2559
+ }
2557
2560
  const documents = await getComponentDocuments({ elements, isRecursive: false });
2558
2561
  updateDocumentState(documents);
2559
2562
  documents.forEach((document2, id) => {
@@ -2622,6 +2625,7 @@ async function switchToComponent(componentId, componentInstanceId, element) {
2622
2625
  setAsInitial: false,
2623
2626
  shouldScroll: false
2624
2627
  });
2628
+ await loadComponentsOverridableProps([componentId], { force: true });
2625
2629
  const currentDocumentContainer = getCurrentDocumentContainer();
2626
2630
  const topLevelElement = currentDocumentContainer?.children?.[0];
2627
2631
  if (topLevelElement) {
@@ -3211,8 +3215,12 @@ function initLoadComponentDataAfterInstanceAdded() {
3211
3215
  });
3212
3216
  }
3213
3217
  function load(result) {
3218
+ if (!result) {
3219
+ return;
3220
+ }
3214
3221
  const containers = Array.isArray(result) ? result : [result];
3215
- loadComponentsAssets(containers.map((container) => container.model.toJSON()));
3222
+ const elements = containers.map((container) => container.model?.toJSON()).filter((element) => !!element);
3223
+ loadComponentsAssets(elements);
3216
3224
  }
3217
3225
 
3218
3226
  // src/init.ts