@elementor/editor-controls 4.1.0-740 → 4.1.0-742

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.d.mts CHANGED
@@ -640,6 +640,7 @@ type InlineEditorProps = {
640
640
  onEditorCreate?: Dispatch<SetStateAction<Editor | null>>;
641
641
  wrapperClassName?: string;
642
642
  onSelectionEnd?: (view: EditorView) => void;
643
+ mountElement?: HTMLElement | null;
643
644
  };
644
645
  declare const InlineEditor: React$1.ForwardRefExoticComponent<InlineEditorProps & React$1.RefAttributes<unknown>>;
645
646
 
package/dist/index.d.ts CHANGED
@@ -640,6 +640,7 @@ type InlineEditorProps = {
640
640
  onEditorCreate?: Dispatch<SetStateAction<Editor | null>>;
641
641
  wrapperClassName?: string;
642
642
  onSelectionEnd?: (view: EditorView) => void;
643
+ mountElement?: HTMLElement | null;
643
644
  };
644
645
  declare const InlineEditor: React$1.ForwardRefExoticComponent<InlineEditorProps & React$1.RefAttributes<unknown>>;
645
646
 
package/dist/index.js CHANGED
@@ -6523,9 +6523,12 @@ var InlineEditor = React100.forwardRef((props, ref) => {
6523
6523
  expectedTag = null,
6524
6524
  onEditorCreate,
6525
6525
  wrapperClassName,
6526
- onSelectionEnd
6526
+ onSelectionEnd,
6527
+ mountElement = null
6527
6528
  } = props;
6528
6529
  const containerRef = (0, import_react55.useRef)(null);
6530
+ const onBlurRef = (0, import_react55.useRef)(onBlur);
6531
+ onBlurRef.current = onBlur;
6529
6532
  const documentContentSettings = !!expectedTag ? "block+" : "inline*";
6530
6533
  const onUpdate = ({ editor: updatedEditor }) => {
6531
6534
  const newValue = updatedEditor.getHTML();
@@ -6533,7 +6536,7 @@ var InlineEditor = React100.forwardRef((props, ref) => {
6533
6536
  };
6534
6537
  const onKeyDown = (_, event) => {
6535
6538
  if (event.key === "Escape") {
6536
- onBlur?.();
6539
+ onBlurRef.current?.();
6537
6540
  }
6538
6541
  if (!event.metaKey && !event.ctrlKey || event.altKey) {
6539
6542
  return;
@@ -6547,6 +6550,7 @@ var InlineEditor = React100.forwardRef((props, ref) => {
6547
6550
  class: elementClasses
6548
6551
  });
6549
6552
  const editor = (0, import_react56.useEditor)({
6553
+ ...mountElement ? { element: mountElement } : {},
6550
6554
  extensions: [
6551
6555
  import_extension_document.default.extend({
6552
6556
  content: documentContentSettings
@@ -6600,6 +6604,7 @@ var InlineEditor = React100.forwardRef((props, ref) => {
6600
6604
  }
6601
6605
  },
6602
6606
  onCreate: onEditorCreate ? ({ editor: mountedEditor }) => onEditorCreate(mountedEditor) : void 0,
6607
+ onBlur: mountElement ? void 0 : () => onBlurRef.current?.(),
6603
6608
  onSelectionUpdate: onSelectionEnd ? ({ editor: updatedEditor }) => onSelectionEnd(updatedEditor.view) : void 0
6604
6609
  });
6605
6610
  useOnUpdate(() => {
@@ -6611,33 +6616,11 @@ var InlineEditor = React100.forwardRef((props, ref) => {
6611
6616
  editor.commands.setContent(value, { emitUpdate: false });
6612
6617
  }
6613
6618
  }, [editor, value]);
6614
- return /* @__PURE__ */ React100.createElement(React100.Fragment, null, /* @__PURE__ */ React100.createElement(
6615
- Wrapper,
6616
- {
6617
- containerRef,
6618
- editor,
6619
- sx,
6620
- onBlur,
6621
- className: wrapperClassName
6622
- },
6623
- /* @__PURE__ */ React100.createElement(import_react56.EditorContent, { ref, editor })
6624
- ));
6619
+ if (mountElement) {
6620
+ return null;
6621
+ }
6622
+ return /* @__PURE__ */ React100.createElement(import_ui86.Box, { ref: containerRef, sx, className: wrapperClassName }, /* @__PURE__ */ React100.createElement(import_react56.EditorContent, { ref, editor }));
6625
6623
  });
6626
- var Wrapper = ({ children, containerRef, editor, sx, onBlur, className }) => {
6627
- const wrappedChildren = /* @__PURE__ */ React100.createElement(import_ui86.Box, { ref: containerRef, ...sx, className }, children);
6628
- return onBlur ? /* @__PURE__ */ React100.createElement(
6629
- import_ui86.ClickAwayListener,
6630
- {
6631
- onClickAway: (event) => {
6632
- if (containerRef.current?.contains(event.target) || editor.view.dom.contains(event.target)) {
6633
- return;
6634
- }
6635
- onBlur?.();
6636
- }
6637
- },
6638
- wrappedChildren
6639
- ) : /* @__PURE__ */ React100.createElement(React100.Fragment, null, wrappedChildren);
6640
- };
6641
6624
  var useOnUpdate = (callback, dependencies) => {
6642
6625
  const hasMounted = (0, import_react55.useRef)(false);
6643
6626
  (0, import_react55.useEffect)(() => {