@elementor/editor-controls 3.35.0-376 → 3.35.0-377
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +27 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/inline-editor.tsx +23 -13
- package/src/controls/inline-editing-control.tsx +24 -4
package/dist/index.mjs
CHANGED
|
@@ -5932,12 +5932,22 @@ var DateTimeControl = createControl(({ inputDisabled }) => {
|
|
|
5932
5932
|
|
|
5933
5933
|
// src/controls/inline-editing-control.tsx
|
|
5934
5934
|
import * as React102 from "react";
|
|
5935
|
+
import { useEffect as useEffect12, useState as useState20 } from "react";
|
|
5935
5936
|
import { htmlPropTypeUtil } from "@elementor/editor-props";
|
|
5937
|
+
import {
|
|
5938
|
+
__privateListenTo as listenTo,
|
|
5939
|
+
commandEndEvent
|
|
5940
|
+
} from "@elementor/editor-v1-adapters";
|
|
5936
5941
|
import { Box as Box23 } from "@elementor/ui";
|
|
5937
5942
|
|
|
5938
5943
|
// src/components/inline-editor.tsx
|
|
5939
5944
|
import * as React101 from "react";
|
|
5940
|
-
import {
|
|
5945
|
+
import {
|
|
5946
|
+
forwardRef as forwardRef10,
|
|
5947
|
+
useEffect as useEffect11,
|
|
5948
|
+
useRef as useRef26,
|
|
5949
|
+
useState as useState19
|
|
5950
|
+
} from "react";
|
|
5941
5951
|
import { bindPopover as bindPopover8, Box as Box22, ClickAwayListener, Popover as Popover8, usePopupState as usePopupState9 } from "@elementor/ui";
|
|
5942
5952
|
import Bold from "@tiptap/extension-bold";
|
|
5943
5953
|
import Document from "@tiptap/extension-document";
|
|
@@ -6228,7 +6238,7 @@ var InlineEditorToolbar = ({ editor }) => {
|
|
|
6228
6238
|
|
|
6229
6239
|
// src/components/inline-editor.tsx
|
|
6230
6240
|
var useOnUpdate = (callback, dependencies) => {
|
|
6231
|
-
const hasMounted =
|
|
6241
|
+
const hasMounted = useRef26(false);
|
|
6232
6242
|
useEffect11(() => {
|
|
6233
6243
|
if (hasMounted.current) {
|
|
6234
6244
|
callback();
|
|
@@ -6263,7 +6273,7 @@ var Wrapper = ({ children, containerRef, editor, sx, onBlur }) => {
|
|
|
6263
6273
|
wrappedChildren
|
|
6264
6274
|
) : /* @__PURE__ */ React101.createElement(React101.Fragment, null, wrappedChildren);
|
|
6265
6275
|
};
|
|
6266
|
-
var InlineEditor =
|
|
6276
|
+
var InlineEditor = forwardRef10(
|
|
6267
6277
|
({
|
|
6268
6278
|
value,
|
|
6269
6279
|
setValue,
|
|
@@ -6275,11 +6285,11 @@ var InlineEditor = React101.forwardRef(
|
|
|
6275
6285
|
getInitialPopoverPosition = void 0,
|
|
6276
6286
|
expectedTag = null
|
|
6277
6287
|
}, ref) => {
|
|
6278
|
-
const containerRef =
|
|
6288
|
+
const containerRef = useRef26(null);
|
|
6279
6289
|
const popupState = usePopupState9({ variant: "popover", disableAutoFocus: true });
|
|
6280
|
-
const [hasSelectedContent, setHasSelectedContent] =
|
|
6290
|
+
const [hasSelectedContent, setHasSelectedContent] = useState19(false);
|
|
6281
6291
|
const documentContentSettings = !!expectedTag ? "block+" : "inline*";
|
|
6282
|
-
const [selectionRect, setSelectionRect] =
|
|
6292
|
+
const [selectionRect, setSelectionRect] = useState19(null);
|
|
6283
6293
|
const onSelectionEnd = (view) => {
|
|
6284
6294
|
const hasSelection = !view.state.selection.empty;
|
|
6285
6295
|
setHasSelectedContent(hasSelection);
|
|
@@ -6301,6 +6311,10 @@ var InlineEditor = React101.forwardRef(
|
|
|
6301
6311
|
keyup: onSelectionEnd,
|
|
6302
6312
|
keydown: onKeyDown
|
|
6303
6313
|
} : void 0;
|
|
6314
|
+
const onUpdate = ({ editor: updatedEditor }) => {
|
|
6315
|
+
const newValue = updatedEditor.getHTML();
|
|
6316
|
+
setValue(isEmpty(newValue) ? null : newValue);
|
|
6317
|
+
};
|
|
6304
6318
|
const editor = useEditor({
|
|
6305
6319
|
extensions: [
|
|
6306
6320
|
Document.extend({
|
|
@@ -6342,10 +6356,7 @@ var InlineEditor = React101.forwardRef(
|
|
|
6342
6356
|
})
|
|
6343
6357
|
],
|
|
6344
6358
|
content: value,
|
|
6345
|
-
onUpdate
|
|
6346
|
-
const newValue = updatedEditor.getHTML();
|
|
6347
|
-
setValue(isEmpty(newValue) ? null : newValue);
|
|
6348
|
-
},
|
|
6359
|
+
onUpdate,
|
|
6349
6360
|
autofocus,
|
|
6350
6361
|
editorProps: {
|
|
6351
6362
|
attributes: {
|
|
@@ -6408,8 +6419,18 @@ var InlineEditingControl = createControl(
|
|
|
6408
6419
|
attributes,
|
|
6409
6420
|
props
|
|
6410
6421
|
}) => {
|
|
6411
|
-
const { value, setValue } = useBoundProp(htmlPropTypeUtil);
|
|
6422
|
+
const { value, setValue, bind } = useBoundProp(htmlPropTypeUtil);
|
|
6423
|
+
const [actualValue, setActualValue] = useState20(value);
|
|
6412
6424
|
const handleChange = (newValue) => setValue(newValue);
|
|
6425
|
+
useEffect12(() => {
|
|
6426
|
+
return listenTo(commandEndEvent("document/elements/settings"), (e) => {
|
|
6427
|
+
const { args, type } = e;
|
|
6428
|
+
const settingValue = args?.settings?.[bind]?.value ?? null;
|
|
6429
|
+
if (type !== "command" || settingValue !== actualValue) {
|
|
6430
|
+
setActualValue(settingValue);
|
|
6431
|
+
}
|
|
6432
|
+
});
|
|
6433
|
+
}, []);
|
|
6413
6434
|
return /* @__PURE__ */ React102.createElement(ControlActions, null, /* @__PURE__ */ React102.createElement(
|
|
6414
6435
|
Box23,
|
|
6415
6436
|
{
|
|
@@ -6444,7 +6465,7 @@ var InlineEditingControl = createControl(
|
|
|
6444
6465
|
...attributes,
|
|
6445
6466
|
...props
|
|
6446
6467
|
},
|
|
6447
|
-
/* @__PURE__ */ React102.createElement(InlineEditor, { value:
|
|
6468
|
+
/* @__PURE__ */ React102.createElement(InlineEditor, { value: actualValue || "", setValue: handleChange })
|
|
6448
6469
|
));
|
|
6449
6470
|
}
|
|
6450
6471
|
);
|
|
@@ -6461,7 +6482,7 @@ var ClearIconButton = ({ tooltipText, onClick, disabled, size = "tiny" }) => /*
|
|
|
6461
6482
|
|
|
6462
6483
|
// src/components/repeater/repeater.tsx
|
|
6463
6484
|
import * as React104 from "react";
|
|
6464
|
-
import { useEffect as
|
|
6485
|
+
import { useEffect as useEffect13, useState as useState21 } from "react";
|
|
6465
6486
|
import { CopyIcon as CopyIcon2, EyeIcon as EyeIcon2, EyeOffIcon as EyeOffIcon2, PlusIcon as PlusIcon3, XIcon as XIcon4 } from "@elementor/icons";
|
|
6466
6487
|
import {
|
|
6467
6488
|
bindPopover as bindPopover9,
|
|
@@ -6490,7 +6511,7 @@ var Repeater3 = ({
|
|
|
6490
6511
|
openItem: initialOpenItem = EMPTY_OPEN_ITEM2,
|
|
6491
6512
|
isSortable = true
|
|
6492
6513
|
}) => {
|
|
6493
|
-
const [openItem, setOpenItem] =
|
|
6514
|
+
const [openItem, setOpenItem] = useState21(initialOpenItem);
|
|
6494
6515
|
const uniqueKeys = items2.map(
|
|
6495
6516
|
(item, index) => isSortable && "getId" in itemSettings ? itemSettings.getId({ item, index }) : String(index)
|
|
6496
6517
|
);
|
|
@@ -6646,10 +6667,10 @@ var RepeaterItem = ({
|
|
|
6646
6667
|
), /* @__PURE__ */ React104.createElement(RepeaterPopover, { width: ref?.getBoundingClientRect().width, ...popoverProps, anchorEl: ref }, /* @__PURE__ */ React104.createElement(Box24, null, children({ anchorEl: ref }))));
|
|
6647
6668
|
};
|
|
6648
6669
|
var usePopover = (openOnMount, onOpen) => {
|
|
6649
|
-
const [ref, setRef] =
|
|
6670
|
+
const [ref, setRef] = useState21(null);
|
|
6650
6671
|
const popoverState = usePopupState10({ variant: "popover" });
|
|
6651
6672
|
const popoverProps = bindPopover9(popoverState);
|
|
6652
|
-
|
|
6673
|
+
useEffect13(() => {
|
|
6653
6674
|
if (openOnMount && ref) {
|
|
6654
6675
|
popoverState.open(ref);
|
|
6655
6676
|
onOpen?.();
|