@elementor/editor-controls 4.0.0 → 4.0.1

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
@@ -3980,7 +3980,7 @@ var AspectRatioControl = createControl(({ label }) => {
3980
3980
  import * as React71 from "react";
3981
3981
  import { useState as useState14 } from "react";
3982
3982
  import { useCurrentUserCapabilities } from "@elementor/editor-current-user";
3983
- import { imageSrcPropTypeUtil as imageSrcPropTypeUtil2 } from "@elementor/editor-props";
3983
+ import { svgSrcPropTypeUtil, urlPropTypeUtil as urlPropTypeUtil3 } from "@elementor/editor-props";
3984
3984
  import { UploadIcon as UploadIcon2 } from "@elementor/icons";
3985
3985
  import { Button as Button4, Card as Card2, CardMedia as CardMedia2, CardOverlay as CardOverlay2, CircularProgress as CircularProgress3, Stack as Stack13, styled as styled7, ThemeProvider } from "@elementor/ui";
3986
3986
  import { useWpMediaAttachment as useWpMediaAttachment2, useWpMediaFrame as useWpMediaFrame2 } from "@elementor/wp-media";
@@ -4072,8 +4072,9 @@ var StyledCardMediaContainer = styled7(Stack13)`
4072
4072
  var MODE_BROWSE = { mode: "browse" };
4073
4073
  var MODE_UPLOAD = { mode: "upload" };
4074
4074
  var SvgMediaControl = createControl(() => {
4075
- const { value, setValue } = useBoundProp(imageSrcPropTypeUtil2);
4076
- const { id, url } = value ?? {};
4075
+ const { value, setValue } = useBoundProp(svgSrcPropTypeUtil);
4076
+ const id = value?.id;
4077
+ const url = value?.url;
4077
4078
  const { data: attachment, isFetching } = useWpMediaAttachment2(id?.value || null);
4078
4079
  const src = attachment?.url ?? url?.value ?? null;
4079
4080
  const { data: allowSvgUpload } = useUnfilteredFilesUpload();
@@ -4089,7 +4090,7 @@ var SvgMediaControl = createControl(() => {
4089
4090
  $$type: "image-attachment-id",
4090
4091
  value: selectedAttachment.id
4091
4092
  },
4092
- url: null
4093
+ url: urlPropTypeUtil3.create(selectedAttachment.url)
4093
4094
  });
4094
4095
  }
4095
4096
  });
@@ -6428,11 +6429,8 @@ import { debounce as debounce4 } from "@elementor/utils";
6428
6429
 
6429
6430
  // src/components/inline-editor.tsx
6430
6431
  import * as React100 from "react";
6431
- import {
6432
- useEffect as useEffect12,
6433
- useRef as useRef24
6434
- } from "react";
6435
- import { Box as Box22, ClickAwayListener } from "@elementor/ui";
6432
+ import { useEffect as useEffect12, useRef as useRef24 } from "react";
6433
+ import { Box as Box22 } from "@elementor/ui";
6436
6434
  import Bold from "@tiptap/extension-bold";
6437
6435
  import Document from "@tiptap/extension-document";
6438
6436
  import HardBreak from "@tiptap/extension-hard-break";
@@ -6473,9 +6471,12 @@ var InlineEditor = React100.forwardRef((props, ref) => {
6473
6471
  expectedTag = null,
6474
6472
  onEditorCreate,
6475
6473
  wrapperClassName,
6476
- onSelectionEnd
6474
+ onSelectionEnd,
6475
+ mountElement = null
6477
6476
  } = props;
6478
6477
  const containerRef = useRef24(null);
6478
+ const onBlurRef = useRef24(onBlur);
6479
+ onBlurRef.current = onBlur;
6479
6480
  const documentContentSettings = !!expectedTag ? "block+" : "inline*";
6480
6481
  const onUpdate = ({ editor: updatedEditor }) => {
6481
6482
  const newValue = updatedEditor.getHTML();
@@ -6483,7 +6484,7 @@ var InlineEditor = React100.forwardRef((props, ref) => {
6483
6484
  };
6484
6485
  const onKeyDown = (_, event) => {
6485
6486
  if (event.key === "Escape") {
6486
- onBlur?.();
6487
+ onBlurRef.current?.();
6487
6488
  }
6488
6489
  if (!event.metaKey && !event.ctrlKey || event.altKey) {
6489
6490
  return;
@@ -6497,6 +6498,7 @@ var InlineEditor = React100.forwardRef((props, ref) => {
6497
6498
  class: elementClasses
6498
6499
  });
6499
6500
  const editor = useEditor({
6501
+ ...mountElement ? { element: mountElement } : {},
6500
6502
  extensions: [
6501
6503
  Document.extend({
6502
6504
  content: documentContentSettings
@@ -6550,6 +6552,7 @@ var InlineEditor = React100.forwardRef((props, ref) => {
6550
6552
  }
6551
6553
  },
6552
6554
  onCreate: onEditorCreate ? ({ editor: mountedEditor }) => onEditorCreate(mountedEditor) : void 0,
6555
+ onBlur: mountElement ? void 0 : () => onBlurRef.current?.(),
6553
6556
  onSelectionUpdate: onSelectionEnd ? ({ editor: updatedEditor }) => onSelectionEnd(updatedEditor.view) : void 0
6554
6557
  });
6555
6558
  useOnUpdate(() => {
@@ -6561,33 +6564,11 @@ var InlineEditor = React100.forwardRef((props, ref) => {
6561
6564
  editor.commands.setContent(value, { emitUpdate: false });
6562
6565
  }
6563
6566
  }, [editor, value]);
6564
- return /* @__PURE__ */ React100.createElement(React100.Fragment, null, /* @__PURE__ */ React100.createElement(
6565
- Wrapper,
6566
- {
6567
- containerRef,
6568
- editor,
6569
- sx,
6570
- onBlur,
6571
- className: wrapperClassName
6572
- },
6573
- /* @__PURE__ */ React100.createElement(EditorContent, { ref, editor })
6574
- ));
6567
+ if (mountElement) {
6568
+ return null;
6569
+ }
6570
+ return /* @__PURE__ */ React100.createElement(Box22, { ref: containerRef, sx, className: wrapperClassName }, /* @__PURE__ */ React100.createElement(EditorContent, { ref, editor }));
6575
6571
  });
6576
- var Wrapper = ({ children, containerRef, editor, sx, onBlur, className }) => {
6577
- const wrappedChildren = /* @__PURE__ */ React100.createElement(Box22, { ref: containerRef, ...sx, className }, children);
6578
- return onBlur ? /* @__PURE__ */ React100.createElement(
6579
- ClickAwayListener,
6580
- {
6581
- onClickAway: (event) => {
6582
- if (containerRef.current?.contains(event.target) || editor.view.dom.contains(event.target)) {
6583
- return;
6584
- }
6585
- onBlur?.();
6586
- }
6587
- },
6588
- wrappedChildren
6589
- ) : /* @__PURE__ */ React100.createElement(React100.Fragment, null, wrappedChildren);
6590
- };
6591
6572
  var useOnUpdate = (callback, dependencies) => {
6592
6573
  const hasMounted = useRef24(false);
6593
6574
  useEffect12(() => {