@elementor/editor-controls 0.21.0 → 0.24.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # @elementor/editor-controls
2
2
 
3
+ ## 0.24.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f644084: Added a "take me there" button in link-in-link restriction info-tip
8
+
9
+ ### Patch Changes
10
+
11
+ - e1bbdf1: Reset repeater item open on mount state.
12
+ - 3973dda: Disable "open in new page" switcher when link control has no value
13
+ - f045ee0: Fix repeaters color and box shadow color indication
14
+ - 830012f: Fix background image overlay label item
15
+ - babfa1c: Center font control select items
16
+ - Updated dependencies [f644084]
17
+ - @elementor/editor-elements@0.8.0
18
+ - @elementor/editor-ui@0.7.0
19
+
20
+ ## 0.23.0
21
+
22
+ ### Minor Changes
23
+
24
+ - ad1f2ff: Update unit size text color to secondary
25
+
26
+ ## 0.22.0
27
+
28
+ ### Minor Changes
29
+
30
+ - 548209b: Add link restriction infotip
31
+
32
+ ### Patch Changes
33
+
34
+ - Updated dependencies [fdfc87a]
35
+ - Updated dependencies [548209b]
36
+ - @elementor/editor-ui@0.6.0
37
+ - @elementor/editor-elements@0.7.1
38
+
3
39
  ## 0.21.0
4
40
 
5
41
  ### Minor Changes
package/dist/index.js CHANGED
@@ -521,11 +521,11 @@ var SelectionEndAdornment = ({
521
521
  import_ui9.Button,
522
522
  {
523
523
  size: "small",
524
- color: "inherit",
525
- sx: { font: "inherit", minWidth: "initial" },
524
+ color: "secondary",
525
+ sx: { font: "inherit", minWidth: "initial", textTransform: "uppercase" },
526
526
  ...(0, import_ui9.bindTrigger)(popupState)
527
527
  },
528
- value.toUpperCase()
528
+ value
529
529
  ), /* @__PURE__ */ React13.createElement(import_ui9.Menu, { MenuListProps: { dense: true }, ...(0, import_ui9.bindMenu)(popupState) }, options.map((option, index) => /* @__PURE__ */ React13.createElement(import_editor_ui2.MenuListItem, { key: option, onClick: () => handleMenuItemClick(index) }, option.toUpperCase()))));
530
530
  };
531
531
 
@@ -752,21 +752,10 @@ var SortableItem = ({ id, children }) => {
752
752
  triggerProps,
753
753
  itemStyle,
754
754
  triggerStyle,
755
- isDragOverlay,
756
755
  showDropIndication,
757
756
  dropIndicationStyle
758
757
  }) => {
759
- return /* @__PURE__ */ React22.createElement(
760
- StyledListItem,
761
- {
762
- ...itemProps,
763
- style: itemStyle,
764
- sx: { backgroundColor: isDragOverlay ? "background.paper" : void 0 }
765
- },
766
- /* @__PURE__ */ React22.createElement(SortableTrigger, { ...triggerProps, style: triggerStyle }),
767
- children,
768
- showDropIndication && /* @__PURE__ */ React22.createElement(StyledDivider, { style: dropIndicationStyle })
769
- );
758
+ return /* @__PURE__ */ React22.createElement(StyledListItem, { ...itemProps, style: itemStyle }, /* @__PURE__ */ React22.createElement(SortableTrigger, { ...triggerProps, style: triggerStyle }), children, showDropIndication && /* @__PURE__ */ React22.createElement(StyledDivider, { style: dropIndicationStyle }));
770
759
  }
771
760
  }
772
761
  );
@@ -789,6 +778,11 @@ var StyledListItem = (0, import_ui16.styled)(import_ui16.ListItem)`
789
778
  transform: translate( -75%, -50% );
790
779
  }
791
780
 
781
+ &[aria-describedby=''] > .MuiTag-root {
782
+ background-color: ${({ theme }) => theme.palette.background.paper};
783
+ box-shadow: ${({ theme }) => theme.shadows[3]};
784
+ }
785
+
792
786
  &:hover {
793
787
  & .class-item-sortable-trigger {
794
788
  visibility: visible;
@@ -815,6 +809,7 @@ var StyledDivider = (0, import_ui16.styled)(import_ui16.Divider)`
815
809
 
816
810
  // src/components/repeater.tsx
817
811
  var SIZE = "tiny";
812
+ var EMPTY_OPEN_ITEM = -1;
818
813
  var Repeater = ({
819
814
  label,
820
815
  itemSettings,
@@ -823,7 +818,7 @@ var Repeater = ({
823
818
  values: repeaterValues = [],
824
819
  setValues: setRepeaterValues
825
820
  }) => {
826
- const [openItem, setOpenItem] = (0, import_react8.useState)(-1);
821
+ const [openItem, setOpenItem] = (0, import_react8.useState)(EMPTY_OPEN_ITEM);
827
822
  const [items, setItems] = useSyncExternalState({
828
823
  external: repeaterValues,
829
824
  // @ts-expect-error - as long as persistWhen => true, value will never be null
@@ -904,14 +899,14 @@ var Repeater = ({
904
899
  return /* @__PURE__ */ React23.createElement(SortableItem, { id: key, key: `sortable-${key}` }, /* @__PURE__ */ React23.createElement(
905
900
  RepeaterItem,
906
901
  {
907
- bind: String(index),
908
902
  disabled: value?.disabled,
909
903
  label: /* @__PURE__ */ React23.createElement(itemSettings.Label, { value }),
910
904
  startIcon: /* @__PURE__ */ React23.createElement(itemSettings.Icon, { value }),
911
905
  removeItem: () => removeRepeaterItem(index),
912
906
  duplicateItem: () => duplicateRepeaterItem(index),
913
907
  toggleDisableItem: () => toggleDisableRepeaterItem(index),
914
- openOnMount: openOnAdd && openItem === key
908
+ openOnMount: openOnAdd && openItem === key,
909
+ onOpen: () => setOpenItem(EMPTY_OPEN_ITEM)
915
910
  },
916
911
  (props) => /* @__PURE__ */ React23.createElement(itemSettings.Content, { ...props, value, bind: String(index) })
917
912
  ));
@@ -925,10 +920,11 @@ var RepeaterItem = ({
925
920
  removeItem,
926
921
  duplicateItem,
927
922
  toggleDisableItem,
928
- openOnMount
923
+ openOnMount,
924
+ onOpen
929
925
  }) => {
930
926
  const [anchorEl, setAnchorEl] = (0, import_react8.useState)(null);
931
- const { popoverState, popoverProps, ref, setRef } = usePopover(openOnMount);
927
+ const { popoverState, popoverProps, ref, setRef } = usePopover(openOnMount, onOpen);
932
928
  const duplicateLabel = (0, import_i18n4.__)("Duplicate", "elementor");
933
929
  const toggleLabel = disabled ? (0, import_i18n4.__)("Show", "elementor") : (0, import_i18n4.__)("Hide", "elementor");
934
930
  const removeLabel = (0, import_i18n4.__)("Remove", "elementor");
@@ -943,8 +939,7 @@ var RepeaterItem = ({
943
939
  "aria-label": (0, import_i18n4.__)("Open item", "elementor"),
944
940
  ...(0, import_ui17.bindTrigger)(popoverState),
945
941
  startIcon,
946
- actions: /* @__PURE__ */ React23.createElement(React23.Fragment, null, /* @__PURE__ */ React23.createElement(import_ui17.Tooltip, { title: duplicateLabel, placement: "top" }, /* @__PURE__ */ React23.createElement(import_ui17.IconButton, { size: SIZE, onClick: duplicateItem, "aria-label": duplicateLabel }, /* @__PURE__ */ React23.createElement(import_icons3.CopyIcon, { fontSize: SIZE }))), /* @__PURE__ */ React23.createElement(import_ui17.Tooltip, { title: toggleLabel, placement: "top" }, /* @__PURE__ */ React23.createElement(import_ui17.IconButton, { size: SIZE, onClick: toggleDisableItem, "aria-label": toggleLabel }, disabled ? /* @__PURE__ */ React23.createElement(import_icons3.EyeOffIcon, { fontSize: SIZE }) : /* @__PURE__ */ React23.createElement(import_icons3.EyeIcon, { fontSize: SIZE }))), /* @__PURE__ */ React23.createElement(import_ui17.Tooltip, { title: removeLabel, placement: "top" }, /* @__PURE__ */ React23.createElement(import_ui17.IconButton, { size: SIZE, onClick: removeItem, "aria-label": removeLabel }, /* @__PURE__ */ React23.createElement(import_icons3.XIcon, { fontSize: SIZE })))),
947
- sx: { backgroundColor: "background.paper" }
942
+ actions: /* @__PURE__ */ React23.createElement(React23.Fragment, null, /* @__PURE__ */ React23.createElement(import_ui17.Tooltip, { title: duplicateLabel, placement: "top" }, /* @__PURE__ */ React23.createElement(import_ui17.IconButton, { size: SIZE, onClick: duplicateItem, "aria-label": duplicateLabel }, /* @__PURE__ */ React23.createElement(import_icons3.CopyIcon, { fontSize: SIZE }))), /* @__PURE__ */ React23.createElement(import_ui17.Tooltip, { title: toggleLabel, placement: "top" }, /* @__PURE__ */ React23.createElement(import_ui17.IconButton, { size: SIZE, onClick: toggleDisableItem, "aria-label": toggleLabel }, disabled ? /* @__PURE__ */ React23.createElement(import_icons3.EyeOffIcon, { fontSize: SIZE }) : /* @__PURE__ */ React23.createElement(import_icons3.EyeIcon, { fontSize: SIZE }))), /* @__PURE__ */ React23.createElement(import_ui17.Tooltip, { title: removeLabel, placement: "top" }, /* @__PURE__ */ React23.createElement(import_ui17.IconButton, { size: SIZE, onClick: removeItem, "aria-label": removeLabel }, /* @__PURE__ */ React23.createElement(import_icons3.XIcon, { fontSize: SIZE }))))
948
943
  }
949
944
  ), /* @__PURE__ */ React23.createElement(
950
945
  import_ui17.Popover,
@@ -963,13 +958,14 @@ var RepeaterItem = ({
963
958
  /* @__PURE__ */ React23.createElement(import_ui17.Box, null, children({ anchorEl }))
964
959
  ));
965
960
  };
966
- var usePopover = (openOnMount) => {
961
+ var usePopover = (openOnMount, onOpen) => {
967
962
  const [ref, setRef] = (0, import_react8.useState)(null);
968
963
  const popoverState = (0, import_ui17.usePopupState)({ variant: "popover" });
969
964
  const popoverProps = (0, import_ui17.bindPopover)(popoverState);
970
965
  (0, import_react8.useEffect)(() => {
971
966
  if (openOnMount && ref) {
972
967
  popoverState.open(ref);
968
+ onOpen?.();
973
969
  }
974
970
  }, [ref]);
975
971
  return {
@@ -1632,7 +1628,9 @@ var StyledMenuList = (0, import_ui24.styled)(import_ui24.MenuList)(({ theme }) =
1632
1628
  position: "absolute",
1633
1629
  top: 0,
1634
1630
  left: 0,
1635
- width: "100%"
1631
+ width: "100%",
1632
+ display: "flex",
1633
+ alignItems: "center"
1636
1634
  },
1637
1635
  '& > [role="option"]': {
1638
1636
  ...theme.typography.caption,
@@ -1680,6 +1678,7 @@ var React34 = __toESM(require("react"));
1680
1678
  var import_react12 = require("react");
1681
1679
  var import_editor_elements = require("@elementor/editor-elements");
1682
1680
  var import_editor_props16 = require("@elementor/editor-props");
1681
+ var import_editor_ui3 = require("@elementor/editor-ui");
1683
1682
  var import_http2 = require("@elementor/http");
1684
1683
  var import_icons7 = require("@elementor/icons");
1685
1684
  var import_session = require("@elementor/session");
@@ -1795,10 +1794,14 @@ function _factoryFilter(newValue, options, minInputLength) {
1795
1794
 
1796
1795
  // src/controls/link-control.tsx
1797
1796
  var SIZE3 = "tiny";
1797
+ var learnMoreButton = {
1798
+ label: (0, import_i18n9.__)("Learn More", "elementor"),
1799
+ href: "https://go.elementor.com/element-link-inside-link-infotip"
1800
+ };
1798
1801
  var LinkControl = createControl((props) => {
1799
1802
  const { value, path, setValue, ...propContext } = useBoundProp(import_editor_props16.linkPropTypeUtil);
1800
1803
  const [linkSessionValue, setLinkSessionValue] = (0, import_session.useSessionStorage)(path.join("/"));
1801
- const [isEnabled, setIsEnabled] = (0, import_react12.useState)(!!value);
1804
+ const [isActive, setIsActive] = (0, import_react12.useState)(!!value);
1802
1805
  const {
1803
1806
  allowCustomValues,
1804
1807
  queryOptions: { endpoint = "", requestParams = {} },
@@ -1806,17 +1809,19 @@ var LinkControl = createControl((props) => {
1806
1809
  minInputLength = 2,
1807
1810
  context: { elementId }
1808
1811
  } = props || {};
1812
+ const [linkInLinkRestriction, setLinkInLinkRestriction] = (0, import_react12.useState)((0, import_editor_elements.getLinkInLinkRestriction)(elementId));
1809
1813
  const [options, setOptions] = (0, import_react12.useState)(
1810
1814
  generateFirstLoadedOption(value)
1811
1815
  );
1816
+ const shouldDisableAddingLink = !isActive && linkInLinkRestriction.shouldRestrict;
1812
1817
  const onEnabledChange = () => {
1813
- const shouldRestrict = (0, import_editor_elements.getAncestorWithAnchorTag)(elementId) || (0, import_editor_elements.getDescendantWithAnchorTag)(elementId);
1814
- if (shouldRestrict && !isEnabled) {
1818
+ setLinkInLinkRestriction((0, import_editor_elements.getLinkInLinkRestriction)(elementId));
1819
+ if (linkInLinkRestriction.shouldRestrict && !isActive) {
1815
1820
  return;
1816
1821
  }
1817
- setIsEnabled((prevState) => !prevState);
1818
- setValue(isEnabled ? null : linkSessionValue?.value ?? null);
1819
- setLinkSessionValue({ value, meta: { isEnabled: !isEnabled } });
1822
+ setIsActive((prevState) => !prevState);
1823
+ setValue(isActive ? null : linkSessionValue?.value ?? null);
1824
+ setLinkSessionValue({ value, meta: { isEnabled: !isActive } });
1820
1825
  };
1821
1826
  const onOptionChange = (newValue) => {
1822
1827
  const valueToSave = newValue ? {
@@ -1866,15 +1871,16 @@ var LinkControl = createControl((props) => {
1866
1871
  }
1867
1872
  },
1868
1873
  /* @__PURE__ */ React34.createElement(ControlFormLabel, null, (0, import_i18n9.__)("Link", "elementor")),
1869
- /* @__PURE__ */ React34.createElement(
1874
+ /* @__PURE__ */ React34.createElement(ConditionalInfoTip, { isVisible: !isActive, linkInLinkRestriction }, /* @__PURE__ */ React34.createElement(
1870
1875
  ToggleIconControl,
1871
1876
  {
1872
- enabled: isEnabled,
1877
+ disabled: shouldDisableAddingLink,
1878
+ active: isActive,
1873
1879
  onIconClick: onEnabledChange,
1874
1880
  label: (0, import_i18n9.__)("Toggle link", "elementor")
1875
1881
  }
1876
- )
1877
- ), /* @__PURE__ */ React34.createElement(import_ui27.Collapse, { in: isEnabled, timeout: "auto", unmountOnExit: true }, /* @__PURE__ */ React34.createElement(import_ui27.Stack, { gap: 1.5 }, /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "destination" }, /* @__PURE__ */ React34.createElement(ControlActions, null, /* @__PURE__ */ React34.createElement(
1882
+ ))
1883
+ ), /* @__PURE__ */ React34.createElement(import_ui27.Collapse, { in: isActive, timeout: "auto", unmountOnExit: true }, /* @__PURE__ */ React34.createElement(import_ui27.Stack, { gap: 1.5 }, /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "destination" }, /* @__PURE__ */ React34.createElement(ControlActions, null, /* @__PURE__ */ React34.createElement(
1878
1884
  Autocomplete,
1879
1885
  {
1880
1886
  options,
@@ -1885,17 +1891,22 @@ var LinkControl = createControl((props) => {
1885
1891
  onTextChange,
1886
1892
  minInputLength
1887
1893
  }
1888
- ))), /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "isTargetBlank" }, /* @__PURE__ */ React34.createElement(SwitchControl, null))))));
1894
+ ))), /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "isTargetBlank" }, /* @__PURE__ */ React34.createElement(SwitchControl, { disabled: !value }))))));
1889
1895
  });
1890
- var ToggleIconControl = ({ enabled, onIconClick, label }) => {
1891
- return /* @__PURE__ */ React34.createElement(import_ui27.IconButton, { size: SIZE3, onClick: onIconClick, "aria-label": label }, enabled ? /* @__PURE__ */ React34.createElement(import_icons7.MinusIcon, { fontSize: SIZE3 }) : /* @__PURE__ */ React34.createElement(import_icons7.PlusIcon, { fontSize: SIZE3 }));
1896
+ var ToggleIconControl = ({ disabled, active, onIconClick, label }) => {
1897
+ return /* @__PURE__ */ React34.createElement(import_ui27.IconButton, { size: SIZE3, onClick: onIconClick, "aria-label": label, disabled }, active ? /* @__PURE__ */ React34.createElement(import_icons7.MinusIcon, { fontSize: SIZE3 }) : /* @__PURE__ */ React34.createElement(import_icons7.PlusIcon, { fontSize: SIZE3 }));
1892
1898
  };
1893
- var SwitchControl = () => {
1899
+ var SwitchControl = ({ disabled }) => {
1894
1900
  const { value = false, setValue } = useBoundProp(import_editor_props16.booleanPropTypeUtil);
1895
1901
  const onClick = () => {
1896
1902
  setValue(!value);
1897
1903
  };
1898
- return /* @__PURE__ */ React34.createElement(import_ui27.Grid, { container: true, alignItems: "center", flexWrap: "nowrap", justifyContent: "space-between" }, /* @__PURE__ */ React34.createElement(import_ui27.Grid, { item: true }, /* @__PURE__ */ React34.createElement(ControlFormLabel, null, (0, import_i18n9.__)("Open in a new tab", "elementor"))), /* @__PURE__ */ React34.createElement(import_ui27.Grid, { item: true }, /* @__PURE__ */ React34.createElement(import_ui27.Switch, { checked: value, onClick })));
1904
+ const inputProps = disabled ? {
1905
+ style: {
1906
+ opacity: 0
1907
+ }
1908
+ } : {};
1909
+ return /* @__PURE__ */ React34.createElement(import_ui27.Grid, { container: true, alignItems: "center", flexWrap: "nowrap", justifyContent: "space-between" }, /* @__PURE__ */ React34.createElement(import_ui27.Grid, { item: true }, /* @__PURE__ */ React34.createElement(ControlFormLabel, null, (0, import_i18n9.__)("Open in a new tab", "elementor"))), /* @__PURE__ */ React34.createElement(import_ui27.Grid, { item: true }, /* @__PURE__ */ React34.createElement(import_ui27.Switch, { checked: value, onClick, disabled, inputProps })));
1899
1910
  };
1900
1911
  async function fetchOptions(ajaxUrl, params) {
1901
1912
  if (!params || !ajaxUrl) {
@@ -1925,6 +1936,37 @@ function generateFirstLoadedOption(unionValue) {
1925
1936
  }
1926
1937
  ] : [];
1927
1938
  }
1939
+ var ConditionalInfoTip = ({ linkInLinkRestriction, isVisible, children }) => {
1940
+ const { shouldRestrict, reason, elementId } = linkInLinkRestriction;
1941
+ const handleTakeMeClick = () => {
1942
+ if (elementId) {
1943
+ (0, import_editor_elements.selectElement)(elementId);
1944
+ }
1945
+ };
1946
+ return shouldRestrict && isVisible ? /* @__PURE__ */ React34.createElement(
1947
+ import_ui27.Infotip,
1948
+ {
1949
+ placement: "right",
1950
+ content: /* @__PURE__ */ React34.createElement(
1951
+ import_editor_ui3.InfoTipCard,
1952
+ {
1953
+ content: INFOTIP_CONTENT[reason],
1954
+ svgIcon: /* @__PURE__ */ React34.createElement(import_icons7.AlertTriangleIcon, null),
1955
+ learnMoreButton,
1956
+ ctaButton: {
1957
+ label: (0, import_i18n9.__)("Take me there", "elementor"),
1958
+ onClick: handleTakeMeClick
1959
+ }
1960
+ }
1961
+ )
1962
+ },
1963
+ /* @__PURE__ */ React34.createElement(import_ui27.Box, null, children)
1964
+ ) : /* @__PURE__ */ React34.createElement(React34.Fragment, null, children);
1965
+ };
1966
+ var INFOTIP_CONTENT = {
1967
+ descendant: /* @__PURE__ */ React34.createElement(React34.Fragment, null, (0, import_i18n9.__)("To add a link to this container,", "elementor"), /* @__PURE__ */ React34.createElement("br", null), (0, import_i18n9.__)("first remove the link from the elements inside of it.", "elementor")),
1968
+ ancestor: /* @__PURE__ */ React34.createElement(React34.Fragment, null, (0, import_i18n9.__)("To add a link to this element,", "elementor"), /* @__PURE__ */ React34.createElement("br", null), (0, import_i18n9.__)("first remove the link from its parent container.", "elementor"))
1969
+ };
1928
1970
 
1929
1971
  // src/controls/gap-control.tsx
1930
1972
  var React35 = __toESM(require("react"));
@@ -2250,7 +2292,7 @@ var BackgroundImageOverlayAttachment = () => {
2250
2292
  // src/controls/background-control/background-overlay/background-image-overlay/background-image-overlay-position.tsx
2251
2293
  var React40 = __toESM(require("react"));
2252
2294
  var import_editor_props20 = require("@elementor/editor-props");
2253
- var import_editor_ui3 = require("@elementor/editor-ui");
2295
+ var import_editor_ui4 = require("@elementor/editor-ui");
2254
2296
  var import_icons11 = require("@elementor/icons");
2255
2297
  var import_ui33 = require("@elementor/ui");
2256
2298
  var import_i18n14 = require("@wordpress/i18n");
@@ -2286,7 +2328,7 @@ var BackgroundImageOverlayPosition = () => {
2286
2328
  onChange: handlePositionChange,
2287
2329
  fullWidth: true
2288
2330
  },
2289
- backgroundPositionOptions.map(({ label, value }) => /* @__PURE__ */ React40.createElement(import_editor_ui3.MenuListItem, { key: value, value: value ?? "" }, label))
2331
+ backgroundPositionOptions.map(({ label, value }) => /* @__PURE__ */ React40.createElement(import_editor_ui4.MenuListItem, { key: value, value: value ?? "" }, label))
2290
2332
  )))), isCustom ? /* @__PURE__ */ React40.createElement(PropProvider, { ...backgroundImageOffsetContext }, /* @__PURE__ */ React40.createElement(import_ui33.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React40.createElement(import_ui33.Grid, { container: true, spacing: 1.5 }, /* @__PURE__ */ React40.createElement(import_ui33.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React40.createElement(PropKeyProvider, { bind: "x" }, /* @__PURE__ */ React40.createElement(SizeControl, { startIcon: /* @__PURE__ */ React40.createElement(import_icons11.LetterXIcon, { fontSize: "tiny" }) }))), /* @__PURE__ */ React40.createElement(import_ui33.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React40.createElement(PropKeyProvider, { bind: "y" }, /* @__PURE__ */ React40.createElement(SizeControl, { startIcon: /* @__PURE__ */ React40.createElement(import_icons11.LetterYIcon, { fontSize: "tiny" }) })))))) : null);
2291
2333
  };
2292
2334
 
@@ -2615,7 +2657,7 @@ var useImage = (image) => {
2615
2657
  const imageSrc = image?.value.image.value?.src.value;
2616
2658
  const { data: attachment } = (0, import_wp_media3.useWpMediaAttachment)(imageSrc.id?.value || null);
2617
2659
  if (imageSrc.id) {
2618
- const imageFileTypeExtension = attachment?.subtype ? `.${attachment.subtype}` : "";
2660
+ const imageFileTypeExtension = getFileExtensionFromFilename(attachment?.filename);
2619
2661
  imageTitle = `${attachment?.title}${imageFileTypeExtension}` || null;
2620
2662
  imageUrl = attachment?.url || null;
2621
2663
  } else if (imageSrc.url) {
@@ -2624,6 +2666,13 @@ var useImage = (image) => {
2624
2666
  }
2625
2667
  return { imageTitle, imageUrl };
2626
2668
  };
2669
+ var getFileExtensionFromFilename = (filename) => {
2670
+ if (!filename) {
2671
+ return "";
2672
+ }
2673
+ const extension = filename.substring(filename.lastIndexOf(".") + 1);
2674
+ return `.${extension}`;
2675
+ };
2627
2676
  var getGradientValue = (value) => {
2628
2677
  const gradient = value.value;
2629
2678
  const stops = gradient.stops.value?.map(({ value: { color, offset } }) => `${color.value} ${offset.value ?? 0}%`)?.join(",");