@elementor/editor-controls 3.33.0-113 → 3.33.0-115

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
@@ -5364,14 +5364,25 @@ var TransitionRepeaterControl = createControl(
5364
5364
  );
5365
5365
 
5366
5366
  // src/components/css-code-editor/css-editor.tsx
5367
- import * as React92 from "react";
5367
+ import * as React93 from "react";
5368
5368
  import { useActiveBreakpoint as useActiveBreakpoint2 } from "@elementor/editor-responsive";
5369
5369
  import { useTheme as useTheme2 } from "@elementor/ui";
5370
5370
  import { Editor } from "@monaco-editor/react";
5371
+ import { __ as __49 } from "@wordpress/i18n";
5372
+
5373
+ // src/components/icon-buttons/clear-icon-button.tsx
5374
+ import * as React91 from "react";
5375
+ import { BrushBigIcon } from "@elementor/icons";
5376
+ import { IconButton as IconButton8, styled as styled9, Tooltip as Tooltip8 } from "@elementor/ui";
5377
+ var CustomIconButton = styled9(IconButton8)(({ theme }) => ({
5378
+ width: theme.spacing(2.5),
5379
+ height: theme.spacing(2.5)
5380
+ }));
5381
+ var ClearIconButton = ({ tooltipText, onClick, disabled, size = "tiny" }) => /* @__PURE__ */ React91.createElement(Tooltip8, { title: tooltipText, placement: "top", disableInteractive: true }, /* @__PURE__ */ React91.createElement(CustomIconButton, { "aria-label": tooltipText, size, onClick, disabled }, /* @__PURE__ */ React91.createElement(BrushBigIcon, { fontSize: size })));
5371
5382
 
5372
5383
  // src/components/css-code-editor/css-editor.styles.ts
5373
- import { Box as Box19, Button as Button5, styled as styled9 } from "@elementor/ui";
5374
- var EditorWrapper = styled9(Box19)`
5384
+ import { Box as Box19, Button as Button5, styled as styled10 } from "@elementor/ui";
5385
+ var EditorWrapper = styled10(Box19)`
5375
5386
  border: 1px solid var( --e-a-border-color );
5376
5387
  border-radius: 8px;
5377
5388
  padding: 10px 12px;
@@ -5381,6 +5392,7 @@ var EditorWrapper = styled9(Box19)`
5381
5392
  .monaco-editor .suggest-widget {
5382
5393
  width: 220px !important;
5383
5394
  max-width: 220px !important;
5395
+ z-index: 1001;
5384
5396
  }
5385
5397
 
5386
5398
  .visual-content-dimmed {
@@ -5389,7 +5401,7 @@ var EditorWrapper = styled9(Box19)`
5389
5401
  pointer-events: none;
5390
5402
  }
5391
5403
  `;
5392
- var ResizeHandle = styled9(Button5)`
5404
+ var ResizeHandle = styled10(Button5)`
5393
5405
  position: absolute;
5394
5406
  bottom: 0;
5395
5407
  left: 0;
@@ -5489,9 +5501,9 @@ function clearMarkersFromVisualContent(editor, monaco) {
5489
5501
  }
5490
5502
 
5491
5503
  // src/components/css-code-editor/resize-handle.tsx
5492
- import * as React91 from "react";
5504
+ import * as React92 from "react";
5493
5505
  var ResizeHandleComponent = ({ onResize, containerRef, onHeightChange }) => {
5494
- const handleResizeMove = React91.useCallback(
5506
+ const handleResizeMove = React92.useCallback(
5495
5507
  (e) => {
5496
5508
  const container = containerRef.current;
5497
5509
  if (!container) {
@@ -5504,11 +5516,11 @@ var ResizeHandleComponent = ({ onResize, containerRef, onHeightChange }) => {
5504
5516
  },
5505
5517
  [containerRef, onResize, onHeightChange]
5506
5518
  );
5507
- const handleResizeEnd = React91.useCallback(() => {
5519
+ const handleResizeEnd = React92.useCallback(() => {
5508
5520
  document.removeEventListener("mousemove", handleResizeMove);
5509
5521
  document.removeEventListener("mouseup", handleResizeEnd);
5510
5522
  }, [handleResizeMove]);
5511
- const handleResizeStart = React91.useCallback(
5523
+ const handleResizeStart = React92.useCallback(
5512
5524
  (e) => {
5513
5525
  e.preventDefault();
5514
5526
  e.stopPropagation();
@@ -5517,13 +5529,13 @@ var ResizeHandleComponent = ({ onResize, containerRef, onHeightChange }) => {
5517
5529
  },
5518
5530
  [handleResizeMove, handleResizeEnd]
5519
5531
  );
5520
- React91.useEffect(() => {
5532
+ React92.useEffect(() => {
5521
5533
  return () => {
5522
5534
  document.removeEventListener("mousemove", handleResizeMove);
5523
5535
  document.removeEventListener("mouseup", handleResizeEnd);
5524
5536
  };
5525
5537
  }, [handleResizeMove, handleResizeEnd]);
5526
- return /* @__PURE__ */ React91.createElement(
5538
+ return /* @__PURE__ */ React92.createElement(
5527
5539
  ResizeHandle,
5528
5540
  {
5529
5541
  onMouseDown: handleResizeStart,
@@ -5600,12 +5612,15 @@ var getActual = (value) => {
5600
5612
  }
5601
5613
  return lines.slice(1, -1).map((line) => line.replace(/^ {2}/, "")).join("\n");
5602
5614
  };
5603
- var createEditorDidMountHandler = (editorRef, monacoRef) => {
5615
+ var createEditorDidMountHandler = (editorRef, monacoRef, onUserContentChange) => {
5604
5616
  return (editor, monaco) => {
5605
5617
  editorRef.current = editor;
5606
5618
  monacoRef.current = monaco;
5607
5619
  preventChangeOnVisualContent(editor);
5608
5620
  setCustomSyntaxRules(editor, monaco);
5621
+ const initialCode = editor.getModel()?.getValue() ?? "";
5622
+ const initialUserContent = getActual(initialCode);
5623
+ onUserContentChange(initialUserContent);
5609
5624
  monaco.editor.onDidChangeMarkers(() => {
5610
5625
  setTimeout(() => clearMarkersFromVisualContent(editor, monaco), 0);
5611
5626
  });
@@ -5614,15 +5629,19 @@ var createEditorDidMountHandler = (editorRef, monacoRef) => {
5614
5629
  };
5615
5630
  var CssEditor = ({ value, onChange }) => {
5616
5631
  const theme = useTheme2();
5617
- const containerRef = React92.useRef(null);
5618
- const editorRef = React92.useRef(null);
5619
- const monacoRef = React92.useRef(null);
5620
- const debounceTimer = React92.useRef(null);
5632
+ const containerRef = React93.useRef(null);
5633
+ const editorRef = React93.useRef(null);
5634
+ const monacoRef = React93.useRef(null);
5635
+ const debounceTimer = React93.useRef(null);
5621
5636
  const activeBreakpoint = useActiveBreakpoint2();
5622
- const handleResize = React92.useCallback(() => {
5637
+ const [hasContent, setHasContent] = React93.useState(value.trim() !== "");
5638
+ const handleUserContentChange = React93.useCallback((newValue) => {
5639
+ setHasContent(newValue.trim() !== "");
5640
+ }, []);
5641
+ const handleResize = React93.useCallback(() => {
5623
5642
  editorRef.current?.layout();
5624
5643
  }, []);
5625
- const handleHeightChange = React92.useCallback((height) => {
5644
+ const handleHeightChange = React93.useCallback((height) => {
5626
5645
  if (containerRef.current) {
5627
5646
  containerRef.current.style.height = `${height}px`;
5628
5647
  }
@@ -5633,6 +5652,7 @@ var CssEditor = ({ value, onChange }) => {
5633
5652
  }
5634
5653
  const code = editorRef.current?.getModel()?.getValue() ?? "";
5635
5654
  const userContent = getActual(code);
5655
+ setHasContent(userContent.trim() !== "");
5636
5656
  setCustomSyntaxRules(editorRef?.current, monacoRef.current);
5637
5657
  const currentTimer = debounceTimer.current;
5638
5658
  if (currentTimer) {
@@ -5647,8 +5667,9 @@ var CssEditor = ({ value, onChange }) => {
5647
5667
  }, 500);
5648
5668
  debounceTimer.current = newTimer;
5649
5669
  };
5650
- const handleEditorDidMount = createEditorDidMountHandler(editorRef, monacoRef);
5651
- React92.useEffect(() => {
5670
+ const handleEditorDidMount = createEditorDidMountHandler(editorRef, monacoRef, handleUserContentChange);
5671
+ const handleReset = () => editorRef.current?.getModel()?.setValue(setVisualContent(""));
5672
+ React93.useEffect(() => {
5652
5673
  const timerRef = debounceTimer;
5653
5674
  return () => {
5654
5675
  const timer = timerRef.current;
@@ -5657,60 +5678,75 @@ var CssEditor = ({ value, onChange }) => {
5657
5678
  }
5658
5679
  };
5659
5680
  }, []);
5660
- return /* @__PURE__ */ React92.createElement(EditorWrapper, { ref: containerRef }, /* @__PURE__ */ React92.createElement(
5661
- Editor,
5681
+ return /* @__PURE__ */ React93.createElement(
5682
+ FloatingActionsBar,
5662
5683
  {
5663
- key: activeBreakpoint,
5664
- height: "100%",
5665
- language: "css",
5666
- theme: theme.palette.mode === "dark" ? "vs-dark" : "vs",
5667
- value: setVisualContent(value),
5668
- onMount: handleEditorDidMount,
5669
- onChange: handleEditorChange,
5670
- options: {
5671
- lineNumbers: "on",
5672
- folding: true,
5673
- minimap: { enabled: false },
5674
- fontFamily: "Roboto, Arial, Helvetica, Verdana, sans-serif",
5675
- fontSize: 12,
5676
- renderLineHighlight: "none",
5677
- hideCursorInOverviewRuler: true,
5678
- fixedOverflowWidgets: true,
5679
- suggestFontSize: 10,
5680
- suggestLineHeight: 14,
5681
- stickyScroll: {
5682
- enabled: false
5683
- },
5684
- lineDecorationsWidth: 2
5684
+ actions: hasContent ? [
5685
+ /* @__PURE__ */ React93.createElement(
5686
+ ClearIconButton,
5687
+ {
5688
+ key: "clear",
5689
+ tooltipText: __49("Clear", "elementor"),
5690
+ onClick: handleReset
5691
+ }
5692
+ )
5693
+ ] : []
5694
+ },
5695
+ /* @__PURE__ */ React93.createElement(EditorWrapper, { ref: containerRef }, /* @__PURE__ */ React93.createElement(
5696
+ Editor,
5697
+ {
5698
+ key: activeBreakpoint,
5699
+ height: "100%",
5700
+ language: "css",
5701
+ theme: theme.palette.mode === "dark" ? "vs-dark" : "vs",
5702
+ value: setVisualContent(value),
5703
+ onMount: handleEditorDidMount,
5704
+ onChange: handleEditorChange,
5705
+ options: {
5706
+ lineNumbers: "on",
5707
+ folding: true,
5708
+ minimap: { enabled: false },
5709
+ fontFamily: "Roboto, Arial, Helvetica, Verdana, sans-serif",
5710
+ fontSize: 12,
5711
+ renderLineHighlight: "none",
5712
+ hideCursorInOverviewRuler: true,
5713
+ fixedOverflowWidgets: true,
5714
+ suggestFontSize: 10,
5715
+ suggestLineHeight: 14,
5716
+ stickyScroll: {
5717
+ enabled: false
5718
+ },
5719
+ lineDecorationsWidth: 2
5720
+ }
5685
5721
  }
5686
- }
5687
- ), /* @__PURE__ */ React92.createElement(
5688
- ResizeHandleComponent,
5689
- {
5690
- onResize: handleResize,
5691
- containerRef,
5692
- onHeightChange: handleHeightChange
5693
- }
5694
- ));
5722
+ ), /* @__PURE__ */ React93.createElement(
5723
+ ResizeHandleComponent,
5724
+ {
5725
+ onResize: handleResize,
5726
+ containerRef,
5727
+ onHeightChange: handleHeightChange
5728
+ }
5729
+ ))
5730
+ );
5695
5731
  };
5696
5732
 
5697
5733
  // src/components/repeater.tsx
5698
- import * as React93 from "react";
5699
- import { useEffect as useEffect11, useState as useState15 } from "react";
5734
+ import * as React94 from "react";
5735
+ import { useEffect as useEffect11, useState as useState16 } from "react";
5700
5736
  import { CopyIcon as CopyIcon2, EyeIcon as EyeIcon2, EyeOffIcon as EyeOffIcon2, PlusIcon as PlusIcon3, XIcon as XIcon4 } from "@elementor/icons";
5701
5737
  import {
5702
5738
  bindPopover as bindPopover7,
5703
5739
  bindTrigger as bindTrigger6,
5704
5740
  Box as Box20,
5705
- IconButton as IconButton8,
5741
+ IconButton as IconButton9,
5706
5742
  Popover as Popover7,
5707
5743
  Stack as Stack16,
5708
- Tooltip as Tooltip8,
5744
+ Tooltip as Tooltip9,
5709
5745
  Typography as Typography7,
5710
5746
  UnstableTag as UnstableTag4,
5711
5747
  usePopupState as usePopupState8
5712
5748
  } from "@elementor/ui";
5713
- import { __ as __49 } from "@wordpress/i18n";
5749
+ import { __ as __50 } from "@wordpress/i18n";
5714
5750
  var SIZE9 = "tiny";
5715
5751
  var EMPTY_OPEN_ITEM2 = -1;
5716
5752
  var Repeater3 = ({
@@ -5726,14 +5762,14 @@ var Repeater3 = ({
5726
5762
  isSortable = true,
5727
5763
  collectionPropUtil
5728
5764
  }) => {
5729
- const [openItem, setOpenItem] = useState15(EMPTY_OPEN_ITEM2);
5765
+ const [openItem, setOpenItem] = useState16(EMPTY_OPEN_ITEM2);
5730
5766
  const [items2, setItems] = useSyncExternalState({
5731
5767
  external: repeaterValues,
5732
5768
  // @ts-expect-error - as long as persistWhen => true, value will never be null
5733
5769
  setExternal: setRepeaterValues,
5734
5770
  persistWhen: () => true
5735
5771
  });
5736
- const [uniqueKeys, setUniqueKeys] = useState15(items2.map((_, index) => index));
5772
+ const [uniqueKeys, setUniqueKeys] = useState16(items2.map((_, index) => index));
5737
5773
  const generateNextKey = (source) => {
5738
5774
  return 1 + Math.max(0, ...source);
5739
5775
  };
@@ -5800,7 +5836,7 @@ var Repeater3 = ({
5800
5836
  { action: { type: "reorder", payload: { ...meta } } }
5801
5837
  );
5802
5838
  };
5803
- return /* @__PURE__ */ React93.createElement(SectionContent, null, /* @__PURE__ */ React93.createElement(
5839
+ return /* @__PURE__ */ React94.createElement(SectionContent, null, /* @__PURE__ */ React94.createElement(
5804
5840
  Stack16,
5805
5841
  {
5806
5842
  direction: "row",
@@ -5809,31 +5845,31 @@ var Repeater3 = ({
5809
5845
  gap: 1,
5810
5846
  sx: { marginInlineEnd: -0.75 }
5811
5847
  },
5812
- /* @__PURE__ */ React93.createElement(Typography7, { component: "label", variant: "caption", color: "text.secondary" }, label),
5813
- /* @__PURE__ */ React93.createElement(ControlAdornments, null),
5814
- /* @__PURE__ */ React93.createElement(
5815
- IconButton8,
5848
+ /* @__PURE__ */ React94.createElement(Typography7, { component: "label", variant: "caption", color: "text.secondary" }, label),
5849
+ /* @__PURE__ */ React94.createElement(ControlAdornments, null),
5850
+ /* @__PURE__ */ React94.createElement(
5851
+ IconButton9,
5816
5852
  {
5817
5853
  size: SIZE9,
5818
5854
  sx: { ml: "auto" },
5819
5855
  disabled,
5820
5856
  onClick: addRepeaterItem,
5821
- "aria-label": __49("Add item", "elementor")
5857
+ "aria-label": __50("Add item", "elementor")
5822
5858
  },
5823
- /* @__PURE__ */ React93.createElement(PlusIcon3, { fontSize: SIZE9 })
5859
+ /* @__PURE__ */ React94.createElement(PlusIcon3, { fontSize: SIZE9 })
5824
5860
  )
5825
- ), 0 < uniqueKeys.length && /* @__PURE__ */ React93.createElement(SortableProvider, { value: uniqueKeys, onChange: onChangeOrder }, uniqueKeys.map((key, index) => {
5861
+ ), 0 < uniqueKeys.length && /* @__PURE__ */ React94.createElement(SortableProvider, { value: uniqueKeys, onChange: onChangeOrder }, uniqueKeys.map((key, index) => {
5826
5862
  const value = items2[index];
5827
5863
  if (!value) {
5828
5864
  return null;
5829
5865
  }
5830
- return /* @__PURE__ */ React93.createElement(SortableItem, { id: key, key: `sortable-${key}`, disabled: !isSortable }, /* @__PURE__ */ React93.createElement(
5866
+ return /* @__PURE__ */ React94.createElement(SortableItem, { id: key, key: `sortable-${key}`, disabled: !isSortable }, /* @__PURE__ */ React94.createElement(
5831
5867
  RepeaterItem,
5832
5868
  {
5833
5869
  disabled,
5834
5870
  propDisabled: value?.disabled,
5835
- label: /* @__PURE__ */ React93.createElement(RepeaterItemLabelSlot, { value }, /* @__PURE__ */ React93.createElement(itemSettings.Label, { value })),
5836
- startIcon: /* @__PURE__ */ React93.createElement(RepeaterItemIconSlot, { value }, /* @__PURE__ */ React93.createElement(itemSettings.Icon, { value })),
5871
+ label: /* @__PURE__ */ React94.createElement(RepeaterItemLabelSlot, { value }, /* @__PURE__ */ React94.createElement(itemSettings.Label, { value })),
5872
+ startIcon: /* @__PURE__ */ React94.createElement(RepeaterItemIconSlot, { value }, /* @__PURE__ */ React94.createElement(itemSettings.Icon, { value })),
5837
5873
  removeItem: () => removeRepeaterItem(index),
5838
5874
  duplicateItem: () => duplicateRepeaterItem(index),
5839
5875
  toggleDisableItem: () => toggleDisableRepeaterItem(index),
@@ -5843,7 +5879,7 @@ var Repeater3 = ({
5843
5879
  showToggle,
5844
5880
  collectionPropUtil
5845
5881
  },
5846
- (props) => /* @__PURE__ */ React93.createElement(itemSettings.Content, { ...props, value, bind: String(index) })
5882
+ (props) => /* @__PURE__ */ React94.createElement(itemSettings.Content, { ...props, value, bind: String(index) })
5847
5883
  ));
5848
5884
  })));
5849
5885
  };
@@ -5862,12 +5898,12 @@ var RepeaterItem = ({
5862
5898
  disabled,
5863
5899
  collectionPropUtil
5864
5900
  }) => {
5865
- const [anchorEl, setAnchorEl] = useState15(null);
5901
+ const [anchorEl, setAnchorEl] = useState16(null);
5866
5902
  const { popoverState, popoverProps, ref, setRef } = usePopover(openOnMount, onOpen);
5867
- const duplicateLabel = __49("Duplicate", "elementor");
5868
- const toggleLabel = propDisabled ? __49("Show", "elementor") : __49("Hide", "elementor");
5869
- const removeLabel = __49("Remove", "elementor");
5870
- return /* @__PURE__ */ React93.createElement(React93.Fragment, null, /* @__PURE__ */ React93.createElement(
5903
+ const duplicateLabel = __50("Duplicate", "elementor");
5904
+ const toggleLabel = propDisabled ? __50("Show", "elementor") : __50("Hide", "elementor");
5905
+ const removeLabel = __50("Remove", "elementor");
5906
+ return /* @__PURE__ */ React94.createElement(React94.Fragment, null, /* @__PURE__ */ React94.createElement(
5871
5907
  UnstableTag4,
5872
5908
  {
5873
5909
  disabled,
@@ -5876,12 +5912,12 @@ var RepeaterItem = ({
5876
5912
  fullWidth: true,
5877
5913
  ref: setRef,
5878
5914
  variant: "outlined",
5879
- "aria-label": __49("Open item", "elementor"),
5915
+ "aria-label": __50("Open item", "elementor"),
5880
5916
  ...bindTrigger6(popoverState),
5881
5917
  startIcon,
5882
- actions: /* @__PURE__ */ React93.createElement(React93.Fragment, null, showDuplicate && /* @__PURE__ */ React93.createElement(Tooltip8, { title: duplicateLabel, placement: "top" }, /* @__PURE__ */ React93.createElement(IconButton8, { size: SIZE9, onClick: duplicateItem, "aria-label": duplicateLabel }, /* @__PURE__ */ React93.createElement(CopyIcon2, { fontSize: SIZE9 }))), showToggle && /* @__PURE__ */ React93.createElement(Tooltip8, { title: toggleLabel, placement: "top" }, /* @__PURE__ */ React93.createElement(IconButton8, { size: SIZE9, onClick: toggleDisableItem, "aria-label": toggleLabel }, propDisabled ? /* @__PURE__ */ React93.createElement(EyeOffIcon2, { fontSize: SIZE9 }) : /* @__PURE__ */ React93.createElement(EyeIcon2, { fontSize: SIZE9 }))), /* @__PURE__ */ React93.createElement(Tooltip8, { title: removeLabel, placement: "top" }, /* @__PURE__ */ React93.createElement(IconButton8, { size: SIZE9, onClick: removeItem, "aria-label": removeLabel }, /* @__PURE__ */ React93.createElement(XIcon4, { fontSize: SIZE9 }))))
5918
+ actions: /* @__PURE__ */ React94.createElement(React94.Fragment, null, showDuplicate && /* @__PURE__ */ React94.createElement(Tooltip9, { title: duplicateLabel, placement: "top" }, /* @__PURE__ */ React94.createElement(IconButton9, { size: SIZE9, onClick: duplicateItem, "aria-label": duplicateLabel }, /* @__PURE__ */ React94.createElement(CopyIcon2, { fontSize: SIZE9 }))), showToggle && /* @__PURE__ */ React94.createElement(Tooltip9, { title: toggleLabel, placement: "top" }, /* @__PURE__ */ React94.createElement(IconButton9, { size: SIZE9, onClick: toggleDisableItem, "aria-label": toggleLabel }, propDisabled ? /* @__PURE__ */ React94.createElement(EyeOffIcon2, { fontSize: SIZE9 }) : /* @__PURE__ */ React94.createElement(EyeIcon2, { fontSize: SIZE9 }))), /* @__PURE__ */ React94.createElement(Tooltip9, { title: removeLabel, placement: "top" }, /* @__PURE__ */ React94.createElement(IconButton9, { size: SIZE9, onClick: removeItem, "aria-label": removeLabel }, /* @__PURE__ */ React94.createElement(XIcon4, { fontSize: SIZE9 }))))
5883
5919
  }
5884
- ), /* @__PURE__ */ React93.createElement(
5920
+ ), /* @__PURE__ */ React94.createElement(
5885
5921
  Popover7,
5886
5922
  {
5887
5923
  disablePortal: true,
@@ -5895,11 +5931,11 @@ var RepeaterItem = ({
5895
5931
  ...popoverProps,
5896
5932
  anchorEl: ref
5897
5933
  },
5898
- /* @__PURE__ */ React93.createElement(Box20, null, children({ anchorEl, collectionPropUtil }))
5934
+ /* @__PURE__ */ React94.createElement(Box20, null, children({ anchorEl, collectionPropUtil }))
5899
5935
  ));
5900
5936
  };
5901
5937
  var usePopover = (openOnMount, onOpen) => {
5902
- const [ref, setRef] = useState15(null);
5938
+ const [ref, setRef] = useState16(null);
5903
5939
  const popoverState = usePopupState8({ variant: "popover" });
5904
5940
  const popoverProps = bindPopover7(popoverState);
5905
5941
  useEffect11(() => {
@@ -5919,6 +5955,7 @@ export {
5919
5955
  AspectRatioControl,
5920
5956
  BackgroundControl,
5921
5957
  BoxShadowRepeaterControl,
5958
+ ClearIconButton,
5922
5959
  ColorControl,
5923
5960
  ControlActionsProvider,
5924
5961
  ControlAdornments,