@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.js CHANGED
@@ -2562,7 +2562,7 @@ async function getComponentDocuments({
2562
2562
  }
2563
2563
  async function getComponentIds(elements, cache, isRecursive) {
2564
2564
  const results = await Promise.all(
2565
- elements.map(async ({ widgetType, elType, elements: childElements, settings }) => {
2565
+ elements.filter(Boolean).map(async ({ widgetType, elType, elements: childElements, settings }) => {
2566
2566
  const ids = [];
2567
2567
  if (isComponentInstance({ widgetType, elType })) {
2568
2568
  const componentId = settings?.component_instance?.value?.component_id.value;
@@ -2602,17 +2602,20 @@ async function getDocumentsMap(ids, cache) {
2602
2602
 
2603
2603
  // src/store/actions/load-components-overridable-props.ts
2604
2604
  var import_store21 = require("@elementor/store");
2605
- async function loadComponentsOverridableProps(componentIds) {
2606
- const unloadedIds = componentIds.filter((id) => !selectIsOverridablePropsLoaded((0, import_store21.__getState)(), id));
2607
- if (!unloadedIds.length) {
2605
+ async function loadComponentsOverridableProps(componentIds, { force = false } = {}) {
2606
+ const idsToLoad = force ? componentIds : componentIds.filter((id) => !selectIsOverridablePropsLoaded((0, import_store21.__getState)(), id));
2607
+ if (!idsToLoad.length) {
2608
2608
  return;
2609
2609
  }
2610
- const { data } = await apiClient.getOverridableProps(unloadedIds);
2610
+ const { data } = await apiClient.getOverridableProps(idsToLoad);
2611
2611
  (0, import_store21.__dispatch)(slice.actions.loadOverridableProps(data));
2612
2612
  }
2613
2613
 
2614
2614
  // src/store/actions/load-components-assets.ts
2615
2615
  async function loadComponentsAssets(elements) {
2616
+ if (!elements.length) {
2617
+ return;
2618
+ }
2616
2619
  const documents = await getComponentDocuments({ elements, isRecursive: false });
2617
2620
  updateDocumentState(documents);
2618
2621
  documents.forEach((document2, id) => {
@@ -2679,6 +2682,7 @@ async function switchToComponent(componentId, componentInstanceId, element) {
2679
2682
  setAsInitial: false,
2680
2683
  shouldScroll: false
2681
2684
  });
2685
+ await loadComponentsOverridableProps([componentId], { force: true });
2682
2686
  const currentDocumentContainer = (0, import_editor_elements8.getCurrentDocumentContainer)();
2683
2687
  const topLevelElement = currentDocumentContainer?.children?.[0];
2684
2688
  if (topLevelElement) {
@@ -3268,8 +3272,12 @@ function initLoadComponentDataAfterInstanceAdded() {
3268
3272
  });
3269
3273
  }
3270
3274
  function load(result) {
3275
+ if (!result) {
3276
+ return;
3277
+ }
3271
3278
  const containers = Array.isArray(result) ? result : [result];
3272
- loadComponentsAssets(containers.map((container) => container.model.toJSON()));
3279
+ const elements = containers.map((container) => container.model?.toJSON()).filter((element) => !!element);
3280
+ loadComponentsAssets(elements);
3273
3281
  }
3274
3282
 
3275
3283
  // src/init.ts