@elementor/editor-components 3.35.0-401 → 3.35.0-403

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
@@ -362,15 +362,44 @@ var import_store5 = require("@elementor/store");
362
362
 
363
363
  // src/utils/switch-to-component.ts
364
364
  var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
365
- function switchToComponent(componentId, componentInstanceId) {
365
+ function switchToComponent(componentId, componentInstanceId, element) {
366
+ const selector = getSelector(element, componentInstanceId);
366
367
  (0, import_editor_v1_adapters2.__privateRunCommand)("editor/documents/switch", {
367
368
  id: componentId,
368
- selector: componentInstanceId ? `[data-id="${componentInstanceId}"]` : void 0,
369
+ selector,
369
370
  mode: "autosave",
370
371
  setAsInitial: false,
371
372
  shouldScroll: false
372
373
  });
373
374
  }
375
+ function getSelector(element, componentInstanceId) {
376
+ if (element) {
377
+ return buildUniqueSelector(element);
378
+ }
379
+ if (componentInstanceId) {
380
+ return `[data-id="${componentInstanceId}"]`;
381
+ }
382
+ return void 0;
383
+ }
384
+ function buildUniqueSelector(element) {
385
+ const selectors = [];
386
+ let current = element.closest("[data-id]");
387
+ while (current) {
388
+ const dataId = current.dataset.id;
389
+ const isComponentInstance2 = current.hasAttribute("data-elementor-id");
390
+ if (isComponentInstance2) {
391
+ selectors.unshift(`[data-id="${dataId}"]`);
392
+ }
393
+ current = current.parentElement?.closest("[data-id]") ?? null;
394
+ }
395
+ if (selectors.length === 0) {
396
+ const closestElement = element.closest("[data-id]");
397
+ if (closestElement?.dataset?.id) {
398
+ return `[data-id="${closestElement.dataset.id}"]`;
399
+ }
400
+ }
401
+ return selectors.join(" ");
402
+ }
374
403
 
375
404
  // src/hooks/use-navigate-back.ts
376
405
  function useNavigateBack() {
@@ -794,13 +823,23 @@ var ComponentIntroduction = ({
794
823
  src: "https://assets.elementor.com/packages/v1/images/components-properties-intro.png",
795
824
  alt: ""
796
825
  }
797
- ), /* @__PURE__ */ React.createElement(import_editor_controls.PopoverContent, null, /* @__PURE__ */ React.createElement(import_ui.Stack, { gap: 1, sx: { p: 2 } }, /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2" }, (0, import_i18n2.__)("Properties make instances flexible.", "elementor")), /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2" }, (0, import_i18n2.__)(
826
+ ), /* @__PURE__ */ React.createElement(import_editor_controls.PopoverContent, null, /* @__PURE__ */ React.createElement(import_ui.Stack, { sx: { p: 2 } }, /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2" }, (0, import_i18n2.__)("Properties make instances flexible.", "elementor")), /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2" }, (0, import_i18n2.__)(
798
827
  "Click next to any setting you want users to customize - like text, images, or links.",
799
828
  "elementor"
800
- )), /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2" }, (0, import_i18n2.__)(
829
+ )), /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2", sx: { mt: 2 } }, (0, import_i18n2.__)(
801
830
  "Your properties will appear in the Properties panel, where you can organize and manage them anytime.",
802
831
  "elementor"
803
- )), /* @__PURE__ */ React.createElement(import_ui.Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end" }, /* @__PURE__ */ React.createElement(import_ui.Button, { size: "medium", variant: "contained", onClick: onClose }, (0, import_i18n2.__)("Got it", "elementor"))))))
832
+ )), /* @__PURE__ */ React.createElement(
833
+ import_ui.Link,
834
+ {
835
+ href: "http://go.elementor.com/components-guide",
836
+ target: "_blank",
837
+ sx: { mt: 2 },
838
+ color: "info.main",
839
+ variant: "body2"
840
+ },
841
+ (0, import_i18n2.__)("Learn more", "elementor")
842
+ ), /* @__PURE__ */ React.createElement(import_ui.Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end", sx: { pt: 1 } }, /* @__PURE__ */ React.createElement(import_ui.Button, { size: "medium", variant: "contained", onClick: onClose }, (0, import_i18n2.__)("Got it", "elementor"))))))
804
843
  );
805
844
  };
806
845
 
@@ -1780,7 +1819,7 @@ function createComponentView(options) {
1780
1819
  if (!isAllowedToSwitchDocument) {
1781
1820
  options.showLockedByModal?.(lockedBy || "");
1782
1821
  } else {
1783
- switchToComponent(this.getComponentId(), this.model.get("id"));
1822
+ switchToComponent(this.getComponentId(), this.model.get("id"), this.el);
1784
1823
  }
1785
1824
  }
1786
1825
  editComponent({ trigger, location, secondaryLocation }) {