@elementor/editor-controls 4.1.0-739 → 4.1.0-741
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +11 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/inline-editor.tsx +16 -57
package/dist/index.mjs
CHANGED
|
@@ -6457,11 +6457,8 @@ import { debounce as debounce4 } from "@elementor/utils";
|
|
|
6457
6457
|
|
|
6458
6458
|
// src/components/inline-editor.tsx
|
|
6459
6459
|
import * as React100 from "react";
|
|
6460
|
-
import {
|
|
6461
|
-
|
|
6462
|
-
useRef as useRef24
|
|
6463
|
-
} from "react";
|
|
6464
|
-
import { Box as Box22, ClickAwayListener } from "@elementor/ui";
|
|
6460
|
+
import { useEffect as useEffect12, useRef as useRef24 } from "react";
|
|
6461
|
+
import { Box as Box22 } from "@elementor/ui";
|
|
6465
6462
|
import Bold from "@tiptap/extension-bold";
|
|
6466
6463
|
import Document from "@tiptap/extension-document";
|
|
6467
6464
|
import HardBreak from "@tiptap/extension-hard-break";
|
|
@@ -6502,9 +6499,12 @@ var InlineEditor = React100.forwardRef((props, ref) => {
|
|
|
6502
6499
|
expectedTag = null,
|
|
6503
6500
|
onEditorCreate,
|
|
6504
6501
|
wrapperClassName,
|
|
6505
|
-
onSelectionEnd
|
|
6502
|
+
onSelectionEnd,
|
|
6503
|
+
mountElement = null
|
|
6506
6504
|
} = props;
|
|
6507
6505
|
const containerRef = useRef24(null);
|
|
6506
|
+
const onBlurRef = useRef24(onBlur);
|
|
6507
|
+
onBlurRef.current = onBlur;
|
|
6508
6508
|
const documentContentSettings = !!expectedTag ? "block+" : "inline*";
|
|
6509
6509
|
const onUpdate = ({ editor: updatedEditor }) => {
|
|
6510
6510
|
const newValue = updatedEditor.getHTML();
|
|
@@ -6512,7 +6512,7 @@ var InlineEditor = React100.forwardRef((props, ref) => {
|
|
|
6512
6512
|
};
|
|
6513
6513
|
const onKeyDown = (_, event) => {
|
|
6514
6514
|
if (event.key === "Escape") {
|
|
6515
|
-
|
|
6515
|
+
onBlurRef.current?.();
|
|
6516
6516
|
}
|
|
6517
6517
|
if (!event.metaKey && !event.ctrlKey || event.altKey) {
|
|
6518
6518
|
return;
|
|
@@ -6526,6 +6526,7 @@ var InlineEditor = React100.forwardRef((props, ref) => {
|
|
|
6526
6526
|
class: elementClasses
|
|
6527
6527
|
});
|
|
6528
6528
|
const editor = useEditor({
|
|
6529
|
+
...mountElement ? { element: mountElement } : {},
|
|
6529
6530
|
extensions: [
|
|
6530
6531
|
Document.extend({
|
|
6531
6532
|
content: documentContentSettings
|
|
@@ -6579,6 +6580,7 @@ var InlineEditor = React100.forwardRef((props, ref) => {
|
|
|
6579
6580
|
}
|
|
6580
6581
|
},
|
|
6581
6582
|
onCreate: onEditorCreate ? ({ editor: mountedEditor }) => onEditorCreate(mountedEditor) : void 0,
|
|
6583
|
+
onBlur: mountElement ? void 0 : () => onBlurRef.current?.(),
|
|
6582
6584
|
onSelectionUpdate: onSelectionEnd ? ({ editor: updatedEditor }) => onSelectionEnd(updatedEditor.view) : void 0
|
|
6583
6585
|
});
|
|
6584
6586
|
useOnUpdate(() => {
|
|
@@ -6590,33 +6592,11 @@ var InlineEditor = React100.forwardRef((props, ref) => {
|
|
|
6590
6592
|
editor.commands.setContent(value, { emitUpdate: false });
|
|
6591
6593
|
}
|
|
6592
6594
|
}, [editor, value]);
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
editor,
|
|
6598
|
-
sx,
|
|
6599
|
-
onBlur,
|
|
6600
|
-
className: wrapperClassName
|
|
6601
|
-
},
|
|
6602
|
-
/* @__PURE__ */ React100.createElement(EditorContent, { ref, editor })
|
|
6603
|
-
));
|
|
6595
|
+
if (mountElement) {
|
|
6596
|
+
return null;
|
|
6597
|
+
}
|
|
6598
|
+
return /* @__PURE__ */ React100.createElement(Box22, { ref: containerRef, sx, className: wrapperClassName }, /* @__PURE__ */ React100.createElement(EditorContent, { ref, editor }));
|
|
6604
6599
|
});
|
|
6605
|
-
var Wrapper = ({ children, containerRef, editor, sx, onBlur, className }) => {
|
|
6606
|
-
const wrappedChildren = /* @__PURE__ */ React100.createElement(Box22, { ref: containerRef, ...sx, className }, children);
|
|
6607
|
-
return onBlur ? /* @__PURE__ */ React100.createElement(
|
|
6608
|
-
ClickAwayListener,
|
|
6609
|
-
{
|
|
6610
|
-
onClickAway: (event) => {
|
|
6611
|
-
if (containerRef.current?.contains(event.target) || editor.view.dom.contains(event.target)) {
|
|
6612
|
-
return;
|
|
6613
|
-
}
|
|
6614
|
-
onBlur?.();
|
|
6615
|
-
}
|
|
6616
|
-
},
|
|
6617
|
-
wrappedChildren
|
|
6618
|
-
) : /* @__PURE__ */ React100.createElement(React100.Fragment, null, wrappedChildren);
|
|
6619
|
-
};
|
|
6620
6600
|
var useOnUpdate = (callback, dependencies) => {
|
|
6621
6601
|
const hasMounted = useRef24(false);
|
|
6622
6602
|
useEffect12(() => {
|