@elementor/editor-controls 4.0.0 → 4.0.2
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 +15 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -37
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/inline-editor.tsx +16 -57
- package/src/controls/svg-media-control.tsx +5 -4
package/dist/index.d.mts
CHANGED
|
@@ -630,6 +630,7 @@ type InlineEditorProps = {
|
|
|
630
630
|
onEditorCreate?: Dispatch<SetStateAction<Editor | null>>;
|
|
631
631
|
wrapperClassName?: string;
|
|
632
632
|
onSelectionEnd?: (view: EditorView) => void;
|
|
633
|
+
mountElement?: HTMLElement | null;
|
|
633
634
|
};
|
|
634
635
|
declare const InlineEditor: React$1.ForwardRefExoticComponent<InlineEditorProps & React$1.RefAttributes<unknown>>;
|
|
635
636
|
|
package/dist/index.d.ts
CHANGED
|
@@ -630,6 +630,7 @@ type InlineEditorProps = {
|
|
|
630
630
|
onEditorCreate?: Dispatch<SetStateAction<Editor | null>>;
|
|
631
631
|
wrapperClassName?: string;
|
|
632
632
|
onSelectionEnd?: (view: EditorView) => void;
|
|
633
|
+
mountElement?: HTMLElement | null;
|
|
633
634
|
};
|
|
634
635
|
declare const InlineEditor: React$1.ForwardRefExoticComponent<InlineEditorProps & React$1.RefAttributes<unknown>>;
|
|
635
636
|
|
package/dist/index.js
CHANGED
|
@@ -4134,8 +4134,9 @@ var StyledCardMediaContainer = (0, import_ui56.styled)(import_ui56.Stack)`
|
|
|
4134
4134
|
var MODE_BROWSE = { mode: "browse" };
|
|
4135
4135
|
var MODE_UPLOAD = { mode: "upload" };
|
|
4136
4136
|
var SvgMediaControl = createControl(() => {
|
|
4137
|
-
const { value, setValue } = useBoundProp(import_editor_props28.
|
|
4138
|
-
const
|
|
4137
|
+
const { value, setValue } = useBoundProp(import_editor_props28.svgSrcPropTypeUtil);
|
|
4138
|
+
const id = value?.id;
|
|
4139
|
+
const url = value?.url;
|
|
4139
4140
|
const { data: attachment, isFetching } = (0, import_wp_media2.useWpMediaAttachment)(id?.value || null);
|
|
4140
4141
|
const src = attachment?.url ?? url?.value ?? null;
|
|
4141
4142
|
const { data: allowSvgUpload } = useUnfilteredFilesUpload();
|
|
@@ -4151,7 +4152,7 @@ var SvgMediaControl = createControl(() => {
|
|
|
4151
4152
|
$$type: "image-attachment-id",
|
|
4152
4153
|
value: selectedAttachment.id
|
|
4153
4154
|
},
|
|
4154
|
-
url:
|
|
4155
|
+
url: import_editor_props28.urlPropTypeUtil.create(selectedAttachment.url)
|
|
4155
4156
|
});
|
|
4156
4157
|
}
|
|
4157
4158
|
});
|
|
@@ -6492,9 +6493,12 @@ var InlineEditor = React100.forwardRef((props, ref) => {
|
|
|
6492
6493
|
expectedTag = null,
|
|
6493
6494
|
onEditorCreate,
|
|
6494
6495
|
wrapperClassName,
|
|
6495
|
-
onSelectionEnd
|
|
6496
|
+
onSelectionEnd,
|
|
6497
|
+
mountElement = null
|
|
6496
6498
|
} = props;
|
|
6497
6499
|
const containerRef = (0, import_react51.useRef)(null);
|
|
6500
|
+
const onBlurRef = (0, import_react51.useRef)(onBlur);
|
|
6501
|
+
onBlurRef.current = onBlur;
|
|
6498
6502
|
const documentContentSettings = !!expectedTag ? "block+" : "inline*";
|
|
6499
6503
|
const onUpdate = ({ editor: updatedEditor }) => {
|
|
6500
6504
|
const newValue = updatedEditor.getHTML();
|
|
@@ -6502,7 +6506,7 @@ var InlineEditor = React100.forwardRef((props, ref) => {
|
|
|
6502
6506
|
};
|
|
6503
6507
|
const onKeyDown = (_, event) => {
|
|
6504
6508
|
if (event.key === "Escape") {
|
|
6505
|
-
|
|
6509
|
+
onBlurRef.current?.();
|
|
6506
6510
|
}
|
|
6507
6511
|
if (!event.metaKey && !event.ctrlKey || event.altKey) {
|
|
6508
6512
|
return;
|
|
@@ -6516,6 +6520,7 @@ var InlineEditor = React100.forwardRef((props, ref) => {
|
|
|
6516
6520
|
class: elementClasses
|
|
6517
6521
|
});
|
|
6518
6522
|
const editor = (0, import_react52.useEditor)({
|
|
6523
|
+
...mountElement ? { element: mountElement } : {},
|
|
6519
6524
|
extensions: [
|
|
6520
6525
|
import_extension_document.default.extend({
|
|
6521
6526
|
content: documentContentSettings
|
|
@@ -6569,6 +6574,7 @@ var InlineEditor = React100.forwardRef((props, ref) => {
|
|
|
6569
6574
|
}
|
|
6570
6575
|
},
|
|
6571
6576
|
onCreate: onEditorCreate ? ({ editor: mountedEditor }) => onEditorCreate(mountedEditor) : void 0,
|
|
6577
|
+
onBlur: mountElement ? void 0 : () => onBlurRef.current?.(),
|
|
6572
6578
|
onSelectionUpdate: onSelectionEnd ? ({ editor: updatedEditor }) => onSelectionEnd(updatedEditor.view) : void 0
|
|
6573
6579
|
});
|
|
6574
6580
|
useOnUpdate(() => {
|
|
@@ -6580,33 +6586,11 @@ var InlineEditor = React100.forwardRef((props, ref) => {
|
|
|
6580
6586
|
editor.commands.setContent(value, { emitUpdate: false });
|
|
6581
6587
|
}
|
|
6582
6588
|
}, [editor, value]);
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
editor,
|
|
6588
|
-
sx,
|
|
6589
|
-
onBlur,
|
|
6590
|
-
className: wrapperClassName
|
|
6591
|
-
},
|
|
6592
|
-
/* @__PURE__ */ React100.createElement(import_react52.EditorContent, { ref, editor })
|
|
6593
|
-
));
|
|
6589
|
+
if (mountElement) {
|
|
6590
|
+
return null;
|
|
6591
|
+
}
|
|
6592
|
+
return /* @__PURE__ */ React100.createElement(import_ui86.Box, { ref: containerRef, sx, className: wrapperClassName }, /* @__PURE__ */ React100.createElement(import_react52.EditorContent, { ref, editor }));
|
|
6594
6593
|
});
|
|
6595
|
-
var Wrapper = ({ children, containerRef, editor, sx, onBlur, className }) => {
|
|
6596
|
-
const wrappedChildren = /* @__PURE__ */ React100.createElement(import_ui86.Box, { ref: containerRef, ...sx, className }, children);
|
|
6597
|
-
return onBlur ? /* @__PURE__ */ React100.createElement(
|
|
6598
|
-
import_ui86.ClickAwayListener,
|
|
6599
|
-
{
|
|
6600
|
-
onClickAway: (event) => {
|
|
6601
|
-
if (containerRef.current?.contains(event.target) || editor.view.dom.contains(event.target)) {
|
|
6602
|
-
return;
|
|
6603
|
-
}
|
|
6604
|
-
onBlur?.();
|
|
6605
|
-
}
|
|
6606
|
-
},
|
|
6607
|
-
wrappedChildren
|
|
6608
|
-
) : /* @__PURE__ */ React100.createElement(React100.Fragment, null, wrappedChildren);
|
|
6609
|
-
};
|
|
6610
6594
|
var useOnUpdate = (callback, dependencies) => {
|
|
6611
6595
|
const hasMounted = (0, import_react51.useRef)(false);
|
|
6612
6596
|
(0, import_react51.useEffect)(() => {
|