@elementor/editor-controls 4.0.0-511 → 4.0.0-513
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 +13 -12
- package/dist/index.d.ts +13 -12
- package/dist/index.js +442 -483
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +454 -499
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/inline-editor-toolbar.tsx +78 -74
- package/src/components/inline-editor.tsx +157 -231
- package/src/control-replacements.tsx +2 -0
- package/src/index.ts +3 -0
package/dist/index.js
CHANGED
|
@@ -82,9 +82,11 @@ __export(index_exports, {
|
|
|
82
82
|
createControl: () => createControl,
|
|
83
83
|
createControlReplacementsRegistry: () => createControlReplacementsRegistry,
|
|
84
84
|
enqueueFont: () => enqueueFont,
|
|
85
|
+
getControlReplacements: () => getControlReplacements,
|
|
85
86
|
injectIntoRepeaterItemActions: () => injectIntoRepeaterItemActions,
|
|
86
87
|
injectIntoRepeaterItemIcon: () => injectIntoRepeaterItemIcon,
|
|
87
88
|
injectIntoRepeaterItemLabel: () => injectIntoRepeaterItemLabel,
|
|
89
|
+
registerControlReplacement: () => registerControlReplacement,
|
|
88
90
|
transitionProperties: () => transitionProperties,
|
|
89
91
|
transitionsItemsList: () => transitionsItemsList,
|
|
90
92
|
useBoundProp: () => useBoundProp,
|
|
@@ -362,14 +364,15 @@ var useControlReplacement = (OriginalComponent) => {
|
|
|
362
364
|
};
|
|
363
365
|
var createControlReplacementsRegistry = () => {
|
|
364
366
|
const controlReplacements = [];
|
|
365
|
-
function
|
|
367
|
+
function registerControlReplacement2(replacement) {
|
|
366
368
|
controlReplacements.push(replacement);
|
|
367
369
|
}
|
|
368
|
-
function
|
|
370
|
+
function getControlReplacements2() {
|
|
369
371
|
return controlReplacements;
|
|
370
372
|
}
|
|
371
|
-
return { registerControlReplacement, getControlReplacements };
|
|
373
|
+
return { registerControlReplacement: registerControlReplacement2, getControlReplacements: getControlReplacements2 };
|
|
372
374
|
};
|
|
375
|
+
var { registerControlReplacement, getControlReplacements } = createControlReplacementsRegistry();
|
|
373
376
|
|
|
374
377
|
// src/create-control.tsx
|
|
375
378
|
var brandSymbol = Symbol("control");
|
|
@@ -6210,14 +6213,14 @@ var DateTimeControl = createControl(({ inputDisabled }) => {
|
|
|
6210
6213
|
});
|
|
6211
6214
|
|
|
6212
6215
|
// src/controls/inline-editing-control.tsx
|
|
6213
|
-
var
|
|
6216
|
+
var React99 = __toESM(require("react"));
|
|
6214
6217
|
var import_editor_props51 = require("@elementor/editor-props");
|
|
6215
|
-
var
|
|
6218
|
+
var import_ui85 = require("@elementor/ui");
|
|
6216
6219
|
|
|
6217
6220
|
// src/components/inline-editor.tsx
|
|
6218
|
-
var
|
|
6219
|
-
var
|
|
6220
|
-
var
|
|
6221
|
+
var React98 = __toESM(require("react"));
|
|
6222
|
+
var import_react52 = require("react");
|
|
6223
|
+
var import_ui84 = require("@elementor/ui");
|
|
6221
6224
|
var import_extension_bold = __toESM(require("@tiptap/extension-bold"));
|
|
6222
6225
|
var import_extension_document = __toESM(require("@tiptap/extension-document"));
|
|
6223
6226
|
var import_extension_hard_break = __toESM(require("@tiptap/extension-hard-break"));
|
|
@@ -6230,7 +6233,7 @@ var import_extension_subscript = __toESM(require("@tiptap/extension-subscript"))
|
|
|
6230
6233
|
var import_extension_superscript = __toESM(require("@tiptap/extension-superscript"));
|
|
6231
6234
|
var import_extension_text = __toESM(require("@tiptap/extension-text"));
|
|
6232
6235
|
var import_extension_underline = __toESM(require("@tiptap/extension-underline"));
|
|
6233
|
-
var
|
|
6236
|
+
var import_react53 = require("@tiptap/react");
|
|
6234
6237
|
|
|
6235
6238
|
// src/utils/inline-editing.ts
|
|
6236
6239
|
function isEmpty(value = "") {
|
|
@@ -6242,457 +6245,147 @@ function isEmpty(value = "") {
|
|
|
6242
6245
|
return !pseudoElement.textContent?.length;
|
|
6243
6246
|
}
|
|
6244
6247
|
|
|
6245
|
-
// src/components/inline-editor
|
|
6246
|
-
var
|
|
6247
|
-
var
|
|
6248
|
-
var
|
|
6249
|
-
var
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
}) => {
|
|
6269
|
-
const inputRef = (0, import_react52.useRef)(null);
|
|
6270
|
-
(0, import_react52.useEffect)(() => {
|
|
6271
|
-
if (popupState.isOpen) {
|
|
6272
|
-
requestAnimationFrame(() => inputRef.current?.focus());
|
|
6273
|
-
}
|
|
6274
|
-
}, [popupState.isOpen]);
|
|
6275
|
-
const handleClose = () => {
|
|
6276
|
-
restoreValue();
|
|
6277
|
-
popupState.close();
|
|
6248
|
+
// src/components/inline-editor.tsx
|
|
6249
|
+
var ITALIC_KEYBOARD_SHORTCUT = "i";
|
|
6250
|
+
var BOLD_KEYBOARD_SHORTCUT = "b";
|
|
6251
|
+
var UNDERLINE_KEYBOARD_SHORTCUT = "u";
|
|
6252
|
+
var InlineEditor = React98.forwardRef((props, ref) => {
|
|
6253
|
+
const {
|
|
6254
|
+
value,
|
|
6255
|
+
setValue,
|
|
6256
|
+
editorProps = {},
|
|
6257
|
+
elementClasses = "",
|
|
6258
|
+
autofocus = false,
|
|
6259
|
+
sx = {},
|
|
6260
|
+
onBlur = void 0,
|
|
6261
|
+
expectedTag = null,
|
|
6262
|
+
onEditorCreate,
|
|
6263
|
+
wrapperClassName,
|
|
6264
|
+
onSelectionEnd
|
|
6265
|
+
} = props;
|
|
6266
|
+
const containerRef = (0, import_react52.useRef)(null);
|
|
6267
|
+
const documentContentSettings = !!expectedTag ? "block+" : "inline*";
|
|
6268
|
+
const onUpdate = ({ editor: updatedEditor }) => {
|
|
6269
|
+
const newValue = updatedEditor.getHTML();
|
|
6270
|
+
setValue(isEmpty(newValue) ? null : newValue);
|
|
6278
6271
|
};
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
slotProps: {
|
|
6283
|
-
paper: { sx: { borderRadius: "16px", width: anchorRef.current?.offsetWidth + "px", marginTop: -1 } }
|
|
6284
|
-
},
|
|
6285
|
-
...(0, import_ui84.bindPopover)(popupState),
|
|
6286
|
-
anchorOrigin: { vertical: "top", horizontal: "left" },
|
|
6287
|
-
transformOrigin: { vertical: "top", horizontal: "left" },
|
|
6288
|
-
onClose: handleClose
|
|
6289
|
-
},
|
|
6290
|
-
/* @__PURE__ */ React98.createElement(import_ui84.Stack, { direction: "row", alignItems: "center", gap: 1, sx: { p: 1.5 } }, /* @__PURE__ */ React98.createElement(
|
|
6291
|
-
import_ui84.TextField,
|
|
6292
|
-
{
|
|
6293
|
-
value,
|
|
6294
|
-
onChange,
|
|
6295
|
-
size: "tiny",
|
|
6296
|
-
fullWidth: true,
|
|
6297
|
-
placeholder: (0, import_i18n50.__)("Type a URL", "elementor"),
|
|
6298
|
-
inputProps: { ref: inputRef },
|
|
6299
|
-
color: "secondary",
|
|
6300
|
-
InputProps: { sx: { borderRadius: "8px" } },
|
|
6301
|
-
onKeyUp: (event) => event.key === "Enter" && handleClose()
|
|
6302
|
-
}
|
|
6303
|
-
), /* @__PURE__ */ React98.createElement(import_ui84.Tooltip, { title: (0, import_i18n50.__)("Open in a new tab", "elementor") }, /* @__PURE__ */ React98.createElement(
|
|
6304
|
-
import_ui84.ToggleButton,
|
|
6305
|
-
{
|
|
6306
|
-
size: "tiny",
|
|
6307
|
-
value: "newTab",
|
|
6308
|
-
selected: openInNewTab,
|
|
6309
|
-
onClick: onToggleNewTab,
|
|
6310
|
-
"aria-label": (0, import_i18n50.__)("Open in a new tab", "elementor"),
|
|
6311
|
-
sx: { borderRadius: "8px" }
|
|
6312
|
-
},
|
|
6313
|
-
/* @__PURE__ */ React98.createElement(import_icons33.ExternalLinkIcon, { fontSize: "tiny" })
|
|
6314
|
-
)))
|
|
6315
|
-
);
|
|
6316
|
-
};
|
|
6317
|
-
|
|
6318
|
-
// src/components/inline-editor-toolbar.tsx
|
|
6319
|
-
var checkIfElementHasLink = (elementId) => !!(0, import_editor_elements6.getElementSetting)(elementId, "link")?.value?.destination;
|
|
6320
|
-
var toolbarButtons = {
|
|
6321
|
-
clear: {
|
|
6322
|
-
label: (0, import_i18n51.__)("Clear", "elementor"),
|
|
6323
|
-
icon: /* @__PURE__ */ React99.createElement(import_icons34.MinusIcon, { fontSize: "tiny" }),
|
|
6324
|
-
action: "clear",
|
|
6325
|
-
method: (editor) => {
|
|
6326
|
-
editor.chain().focus().clearNodes().unsetAllMarks().run();
|
|
6327
|
-
}
|
|
6328
|
-
},
|
|
6329
|
-
bold: {
|
|
6330
|
-
label: (0, import_i18n51.__)("Bold", "elementor"),
|
|
6331
|
-
icon: /* @__PURE__ */ React99.createElement(import_icons34.BoldIcon, { fontSize: "tiny" }),
|
|
6332
|
-
action: "bold",
|
|
6333
|
-
method: (editor) => {
|
|
6334
|
-
editor.chain().focus().toggleBold().run();
|
|
6272
|
+
const onKeyDown = (_, event) => {
|
|
6273
|
+
if (event.key === "Escape") {
|
|
6274
|
+
onBlur?.();
|
|
6335
6275
|
}
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
label: (0, import_i18n51.__)("Italic", "elementor"),
|
|
6339
|
-
icon: /* @__PURE__ */ React99.createElement(import_icons34.ItalicIcon, { fontSize: "tiny" }),
|
|
6340
|
-
action: "italic",
|
|
6341
|
-
method: (editor) => {
|
|
6342
|
-
editor.chain().focus().toggleItalic().run();
|
|
6343
|
-
}
|
|
6344
|
-
},
|
|
6345
|
-
underline: {
|
|
6346
|
-
label: (0, import_i18n51.__)("Underline", "elementor"),
|
|
6347
|
-
icon: /* @__PURE__ */ React99.createElement(import_icons34.UnderlineIcon, { fontSize: "tiny" }),
|
|
6348
|
-
action: "underline",
|
|
6349
|
-
method: (editor) => {
|
|
6350
|
-
editor.chain().focus().toggleUnderline().run();
|
|
6351
|
-
}
|
|
6352
|
-
},
|
|
6353
|
-
strike: {
|
|
6354
|
-
label: (0, import_i18n51.__)("Strikethrough", "elementor"),
|
|
6355
|
-
icon: /* @__PURE__ */ React99.createElement(import_icons34.StrikethroughIcon, { fontSize: "tiny" }),
|
|
6356
|
-
action: "strike",
|
|
6357
|
-
method: (editor) => {
|
|
6358
|
-
editor.chain().focus().toggleStrike().run();
|
|
6359
|
-
}
|
|
6360
|
-
},
|
|
6361
|
-
superscript: {
|
|
6362
|
-
label: (0, import_i18n51.__)("Superscript", "elementor"),
|
|
6363
|
-
icon: /* @__PURE__ */ React99.createElement(import_icons34.SuperscriptIcon, { fontSize: "tiny" }),
|
|
6364
|
-
action: "superscript",
|
|
6365
|
-
method: (editor) => {
|
|
6366
|
-
editor.chain().focus().toggleSuperscript().run();
|
|
6367
|
-
}
|
|
6368
|
-
},
|
|
6369
|
-
subscript: {
|
|
6370
|
-
label: (0, import_i18n51.__)("Subscript", "elementor"),
|
|
6371
|
-
icon: /* @__PURE__ */ React99.createElement(import_icons34.SubscriptIcon, { fontSize: "tiny" }),
|
|
6372
|
-
action: "subscript",
|
|
6373
|
-
method: (editor) => {
|
|
6374
|
-
editor.chain().focus().toggleSubscript().run();
|
|
6375
|
-
}
|
|
6376
|
-
},
|
|
6377
|
-
link: {
|
|
6378
|
-
label: (0, import_i18n51.__)("Link", "elementor"),
|
|
6379
|
-
icon: /* @__PURE__ */ React99.createElement(import_icons34.LinkIcon, { fontSize: "tiny" }),
|
|
6380
|
-
action: "link",
|
|
6381
|
-
method: null
|
|
6382
|
-
}
|
|
6383
|
-
};
|
|
6384
|
-
var { clear: clearButton, ...formatButtons } = toolbarButtons;
|
|
6385
|
-
var possibleFormats = Object.keys(formatButtons);
|
|
6386
|
-
var InlineEditorToolbar = ({ editor, elementId }) => {
|
|
6387
|
-
const [urlValue, setUrlValue] = (0, import_react53.useState)("");
|
|
6388
|
-
const [openInNewTab, setOpenInNewTab] = (0, import_react53.useState)(false);
|
|
6389
|
-
const toolbarRef = (0, import_react53.useRef)(null);
|
|
6390
|
-
const linkPopupState = (0, import_ui85.usePopupState)({ variant: "popover" });
|
|
6391
|
-
const hasLinkOnElement = elementId ? checkIfElementHasLink(elementId) : false;
|
|
6392
|
-
const editorState = (0, import_react54.useEditorState)({
|
|
6393
|
-
editor,
|
|
6394
|
-
selector: (ctx) => possibleFormats.filter((format) => ctx.editor.isActive(format))
|
|
6395
|
-
});
|
|
6396
|
-
const formatButtonsList = (0, import_react53.useMemo)(() => {
|
|
6397
|
-
const buttons = Object.values(formatButtons);
|
|
6398
|
-
if (hasLinkOnElement) {
|
|
6399
|
-
return buttons.filter((button) => button.action !== "link");
|
|
6400
|
-
}
|
|
6401
|
-
return buttons;
|
|
6402
|
-
}, [hasLinkOnElement]);
|
|
6403
|
-
const handleLinkClick = () => {
|
|
6404
|
-
const linkAttrs = editor.getAttributes("link");
|
|
6405
|
-
setUrlValue(linkAttrs.href || "");
|
|
6406
|
-
setOpenInNewTab(linkAttrs.target === "_blank");
|
|
6407
|
-
linkPopupState.open(toolbarRef.current);
|
|
6408
|
-
};
|
|
6409
|
-
const handleUrlChange = (event) => {
|
|
6410
|
-
setUrlValue(event.target.value);
|
|
6411
|
-
};
|
|
6412
|
-
const handleToggleNewTab = () => {
|
|
6413
|
-
setOpenInNewTab(!openInNewTab);
|
|
6414
|
-
};
|
|
6415
|
-
const handleUrlSubmit = () => {
|
|
6416
|
-
if (urlValue) {
|
|
6417
|
-
editor.chain().focus().setLink({
|
|
6418
|
-
href: urlValue,
|
|
6419
|
-
target: openInNewTab ? "_blank" : "_self"
|
|
6420
|
-
}).run();
|
|
6421
|
-
} else {
|
|
6422
|
-
editor.chain().focus().unsetLink().run();
|
|
6276
|
+
if (!event.metaKey && !event.ctrlKey || event.altKey) {
|
|
6277
|
+
return;
|
|
6423
6278
|
}
|
|
6424
|
-
if (
|
|
6425
|
-
|
|
6426
|
-
new CustomEvent("elementor:inline-link-changed", {
|
|
6427
|
-
detail: { elementId }
|
|
6428
|
-
})
|
|
6429
|
-
);
|
|
6279
|
+
if ([ITALIC_KEYBOARD_SHORTCUT, BOLD_KEYBOARD_SHORTCUT, UNDERLINE_KEYBOARD_SHORTCUT].includes(event.key)) {
|
|
6280
|
+
event.stopPropagation();
|
|
6430
6281
|
}
|
|
6431
|
-
linkPopupState.close();
|
|
6432
6282
|
};
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
/* @__PURE__ */ React99.createElement(import_ui85.Tooltip, { title: clearButton.label, placement: "top", sx: { borderRadius: "8px" } }, /* @__PURE__ */ React99.createElement(import_ui85.IconButton, { "aria-label": clearButton.label, onClick: () => clearButton.method(editor), size: "tiny" }, clearButton.icon)),
|
|
6453
|
-
/* @__PURE__ */ React99.createElement(
|
|
6454
|
-
import_ui85.ToggleButtonGroup,
|
|
6455
|
-
{
|
|
6456
|
-
value: editorState,
|
|
6457
|
-
size: "tiny",
|
|
6458
|
-
sx: {
|
|
6459
|
-
display: "flex",
|
|
6460
|
-
gap: 0.5,
|
|
6461
|
-
border: "none",
|
|
6462
|
-
[`& .${import_ui85.toggleButtonGroupClasses.firstButton}, & .${import_ui85.toggleButtonGroupClasses.middleButton}, & .${import_ui85.toggleButtonGroupClasses.lastButton}`]: {
|
|
6463
|
-
borderRadius: "8px",
|
|
6464
|
-
border: "none",
|
|
6465
|
-
marginLeft: 0,
|
|
6466
|
-
"&.Mui-selected": {
|
|
6467
|
-
marginLeft: 0
|
|
6468
|
-
},
|
|
6469
|
-
"& + &.Mui-selected": {
|
|
6470
|
-
marginLeft: 0
|
|
6471
|
-
}
|
|
6283
|
+
const editedElementAttributes = (HTMLAttributes) => ({
|
|
6284
|
+
...HTMLAttributes,
|
|
6285
|
+
class: elementClasses
|
|
6286
|
+
});
|
|
6287
|
+
const editor = (0, import_react53.useEditor)({
|
|
6288
|
+
extensions: [
|
|
6289
|
+
import_extension_document.default.extend({
|
|
6290
|
+
content: documentContentSettings
|
|
6291
|
+
}),
|
|
6292
|
+
import_extension_paragraph.default.extend({
|
|
6293
|
+
renderHTML({ HTMLAttributes }) {
|
|
6294
|
+
const tag = expectedTag ?? "p";
|
|
6295
|
+
return [tag, editedElementAttributes(HTMLAttributes), 0];
|
|
6296
|
+
}
|
|
6297
|
+
}),
|
|
6298
|
+
import_extension_heading.default.extend({
|
|
6299
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
6300
|
+
if (expectedTag) {
|
|
6301
|
+
return [expectedTag, editedElementAttributes(HTMLAttributes), 0];
|
|
6472
6302
|
}
|
|
6303
|
+
const level = this.options.levels.includes(node.attrs.level) ? node.attrs.level : this.options.levels[0];
|
|
6304
|
+
return [`h${level}`, editedElementAttributes(HTMLAttributes), 0];
|
|
6305
|
+
}
|
|
6306
|
+
}).configure({
|
|
6307
|
+
levels: [1, 2, 3, 4, 5, 6]
|
|
6308
|
+
}),
|
|
6309
|
+
import_extension_link.default.configure({
|
|
6310
|
+
openOnClick: false
|
|
6311
|
+
}),
|
|
6312
|
+
import_extension_text.default,
|
|
6313
|
+
import_extension_bold.default,
|
|
6314
|
+
import_extension_italic.default,
|
|
6315
|
+
import_extension_strike.default,
|
|
6316
|
+
import_extension_superscript.default,
|
|
6317
|
+
import_extension_subscript.default,
|
|
6318
|
+
import_extension_underline.default,
|
|
6319
|
+
import_extension_hard_break.default.extend({
|
|
6320
|
+
addKeyboardShortcuts() {
|
|
6321
|
+
return {
|
|
6322
|
+
Enter: () => this.editor.commands.setHardBreak()
|
|
6323
|
+
};
|
|
6473
6324
|
}
|
|
6325
|
+
})
|
|
6326
|
+
],
|
|
6327
|
+
content: value,
|
|
6328
|
+
onUpdate,
|
|
6329
|
+
autofocus,
|
|
6330
|
+
editorProps: {
|
|
6331
|
+
...editorProps,
|
|
6332
|
+
handleDOMEvents: {
|
|
6333
|
+
keydown: onKeyDown
|
|
6474
6334
|
},
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
value: button.action,
|
|
6479
|
-
"aria-label": button.label,
|
|
6480
|
-
size: "tiny",
|
|
6481
|
-
onClick: () => {
|
|
6482
|
-
if (button.action === "link") {
|
|
6483
|
-
handleLinkClick();
|
|
6484
|
-
} else {
|
|
6485
|
-
button.method?.(editor);
|
|
6486
|
-
}
|
|
6487
|
-
editor?.commands?.focus();
|
|
6488
|
-
}
|
|
6489
|
-
},
|
|
6490
|
-
button.icon
|
|
6491
|
-
)))
|
|
6492
|
-
),
|
|
6493
|
-
/* @__PURE__ */ React99.createElement(
|
|
6494
|
-
UrlPopover,
|
|
6495
|
-
{
|
|
6496
|
-
popupState: linkPopupState,
|
|
6497
|
-
anchorRef: toolbarRef,
|
|
6498
|
-
restoreValue: handleUrlSubmit,
|
|
6499
|
-
value: urlValue,
|
|
6500
|
-
onChange: handleUrlChange,
|
|
6501
|
-
openInNewTab,
|
|
6502
|
-
onToggleNewTab: handleToggleNewTab
|
|
6335
|
+
attributes: {
|
|
6336
|
+
...editorProps.attributes ?? {},
|
|
6337
|
+
role: "textbox"
|
|
6503
6338
|
}
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
}
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
var UNDERLINE_KEYBOARD_SHORTCUT = "u";
|
|
6512
|
-
var INLINE_EDITOR_RESET_CLASS = "elementor-inline-editor-reset";
|
|
6513
|
-
var useOnUpdate = (callback, dependencies) => {
|
|
6514
|
-
const hasMounted = (0, import_react55.useRef)(false);
|
|
6515
|
-
(0, import_react55.useEffect)(() => {
|
|
6516
|
-
if (hasMounted.current) {
|
|
6517
|
-
callback();
|
|
6518
|
-
} else {
|
|
6519
|
-
hasMounted.current = true;
|
|
6339
|
+
},
|
|
6340
|
+
onCreate: onEditorCreate ? ({ editor: mountedEditor }) => onEditorCreate(mountedEditor) : void 0,
|
|
6341
|
+
onSelectionUpdate: onSelectionEnd ? ({ editor: updatedEditor }) => onSelectionEnd(updatedEditor.view) : void 0
|
|
6342
|
+
});
|
|
6343
|
+
useOnUpdate(() => {
|
|
6344
|
+
if (!editor) {
|
|
6345
|
+
return;
|
|
6520
6346
|
}
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6347
|
+
const currentContent = editor.getHTML();
|
|
6348
|
+
if (currentContent !== value) {
|
|
6349
|
+
editor.commands.setContent(value, { emitUpdate: false });
|
|
6350
|
+
}
|
|
6351
|
+
}, [editor, value]);
|
|
6352
|
+
return /* @__PURE__ */ React98.createElement(React98.Fragment, null, /* @__PURE__ */ React98.createElement(
|
|
6353
|
+
Wrapper,
|
|
6354
|
+
{
|
|
6355
|
+
containerRef,
|
|
6356
|
+
editor,
|
|
6357
|
+
sx,
|
|
6358
|
+
onBlur,
|
|
6359
|
+
className: wrapperClassName
|
|
6360
|
+
},
|
|
6361
|
+
/* @__PURE__ */ React98.createElement(import_react53.EditorContent, { ref, editor })
|
|
6362
|
+
));
|
|
6363
|
+
});
|
|
6364
|
+
var Wrapper = ({ children, containerRef, editor, sx, onBlur, className }) => {
|
|
6365
|
+
const wrappedChildren = /* @__PURE__ */ React98.createElement(import_ui84.Box, { ref: containerRef, ...sx, className }, children);
|
|
6366
|
+
return onBlur ? /* @__PURE__ */ React98.createElement(
|
|
6367
|
+
import_ui84.ClickAwayListener,
|
|
6538
6368
|
{
|
|
6539
6369
|
onClickAway: (event) => {
|
|
6540
6370
|
if (containerRef.current?.contains(event.target) || editor.view.dom.contains(event.target)) {
|
|
6541
6371
|
return;
|
|
6542
|
-
}
|
|
6543
|
-
onBlur?.(
|
|
6544
|
-
}
|
|
6545
|
-
},
|
|
6546
|
-
wrappedChildren
|
|
6547
|
-
) : /* @__PURE__ */ React100.createElement(React100.Fragment, null, wrappedChildren);
|
|
6548
|
-
};
|
|
6549
|
-
var InlineEditor = (0, import_react55.forwardRef)(
|
|
6550
|
-
({
|
|
6551
|
-
value,
|
|
6552
|
-
setValue,
|
|
6553
|
-
attributes = {},
|
|
6554
|
-
elementClasses = "",
|
|
6555
|
-
showToolbar = false,
|
|
6556
|
-
autofocus = false,
|
|
6557
|
-
sx = {},
|
|
6558
|
-
onBlur = void 0,
|
|
6559
|
-
getInitialPopoverPosition = void 0,
|
|
6560
|
-
expectedTag = null,
|
|
6561
|
-
elementId = void 0
|
|
6562
|
-
}, ref) => {
|
|
6563
|
-
const containerRef = (0, import_react55.useRef)(null);
|
|
6564
|
-
const popupState = (0, import_ui86.usePopupState)({ variant: "popover", disableAutoFocus: true });
|
|
6565
|
-
const [hasSelectedContent, setHasSelectedContent] = (0, import_react55.useState)(false);
|
|
6566
|
-
const documentContentSettings = !!expectedTag ? "block+" : "inline*";
|
|
6567
|
-
const [selectionRect, setSelectionRect] = (0, import_react55.useState)(null);
|
|
6568
|
-
const onSelectionEnd = (view) => {
|
|
6569
|
-
const hasSelection = !view.state.selection.empty;
|
|
6570
|
-
setHasSelectedContent(hasSelection);
|
|
6571
|
-
if (hasSelection) {
|
|
6572
|
-
const container = containerRef.current?.getBoundingClientRect();
|
|
6573
|
-
setSelectionRect(calcSelectionCenter(view, container));
|
|
6574
|
-
} else {
|
|
6575
|
-
setSelectionRect(null);
|
|
6576
|
-
}
|
|
6577
|
-
queueMicrotask(() => view.focus());
|
|
6578
|
-
};
|
|
6579
|
-
const onKeyDown = (_, event) => {
|
|
6580
|
-
if (event.key === "Escape") {
|
|
6581
|
-
onBlur?.(event);
|
|
6582
|
-
}
|
|
6583
|
-
if (!event.metaKey && !event.ctrlKey || event.altKey) {
|
|
6584
|
-
return;
|
|
6585
|
-
}
|
|
6586
|
-
if ([ITALIC_KEYBOARD_SHORTCUT, BOLD_KEYBOARD_SHORTCUT, UNDERLINE_KEYBOARD_SHORTCUT].includes(event.key)) {
|
|
6587
|
-
event.stopPropagation();
|
|
6588
|
-
}
|
|
6589
|
-
};
|
|
6590
|
-
const toolbarRelatedListeners = showToolbar ? {
|
|
6591
|
-
mouseup: onSelectionEnd,
|
|
6592
|
-
keyup: onSelectionEnd,
|
|
6593
|
-
keydown: onKeyDown
|
|
6594
|
-
} : void 0;
|
|
6595
|
-
const onUpdate = ({ editor: updatedEditor }) => {
|
|
6596
|
-
const newValue = updatedEditor.getHTML();
|
|
6597
|
-
setValue(isEmpty(newValue) ? null : newValue);
|
|
6598
|
-
};
|
|
6599
|
-
const classes = `${INLINE_EDITOR_RESET_CLASS} ${elementClasses}`;
|
|
6600
|
-
const editor = (0, import_react56.useEditor)({
|
|
6601
|
-
extensions: [
|
|
6602
|
-
import_extension_document.default.extend({
|
|
6603
|
-
content: documentContentSettings
|
|
6604
|
-
}),
|
|
6605
|
-
import_extension_paragraph.default.extend({
|
|
6606
|
-
renderHTML({ HTMLAttributes }) {
|
|
6607
|
-
const tag = expectedTag ?? "p";
|
|
6608
|
-
return [tag, { ...HTMLAttributes, class: classes }, 0];
|
|
6609
|
-
}
|
|
6610
|
-
}),
|
|
6611
|
-
import_extension_heading.default.extend({
|
|
6612
|
-
renderHTML({ node, HTMLAttributes }) {
|
|
6613
|
-
if (expectedTag) {
|
|
6614
|
-
return [expectedTag, { ...HTMLAttributes, class: classes }, 0];
|
|
6615
|
-
}
|
|
6616
|
-
const level = this.options.levels.includes(node.attrs.level) ? node.attrs.level : this.options.levels[0];
|
|
6617
|
-
return [`h${level}`, { ...HTMLAttributes, class: classes }, 0];
|
|
6618
|
-
}
|
|
6619
|
-
}).configure({
|
|
6620
|
-
levels: [1, 2, 3, 4, 5, 6]
|
|
6621
|
-
}),
|
|
6622
|
-
import_extension_link.default.configure({
|
|
6623
|
-
openOnClick: false
|
|
6624
|
-
}),
|
|
6625
|
-
import_extension_text.default,
|
|
6626
|
-
import_extension_bold.default,
|
|
6627
|
-
import_extension_italic.default,
|
|
6628
|
-
import_extension_strike.default,
|
|
6629
|
-
import_extension_superscript.default,
|
|
6630
|
-
import_extension_subscript.default,
|
|
6631
|
-
import_extension_underline.default,
|
|
6632
|
-
import_extension_hard_break.default.extend({
|
|
6633
|
-
addKeyboardShortcuts() {
|
|
6634
|
-
return {
|
|
6635
|
-
Enter: () => this.editor.commands.setHardBreak()
|
|
6636
|
-
};
|
|
6637
|
-
}
|
|
6638
|
-
})
|
|
6639
|
-
],
|
|
6640
|
-
content: value,
|
|
6641
|
-
onUpdate,
|
|
6642
|
-
autofocus,
|
|
6643
|
-
editorProps: {
|
|
6644
|
-
attributes: {
|
|
6645
|
-
...attributes,
|
|
6646
|
-
class: attributes.class ?? "",
|
|
6647
|
-
role: "textbox"
|
|
6648
|
-
},
|
|
6649
|
-
handleDOMEvents: toolbarRelatedListeners
|
|
6650
|
-
}
|
|
6651
|
-
});
|
|
6652
|
-
useOnUpdate(() => {
|
|
6653
|
-
if (!editor) {
|
|
6654
|
-
return;
|
|
6655
|
-
}
|
|
6656
|
-
const currentContent = editor.getHTML();
|
|
6657
|
-
if (currentContent !== value) {
|
|
6658
|
-
editor.commands.setContent(value, { emitUpdate: false });
|
|
6659
|
-
}
|
|
6660
|
-
}, [editor, value]);
|
|
6661
|
-
const computePopupPosition = () => {
|
|
6662
|
-
if (!selectionRect) {
|
|
6663
|
-
return { left: 0, top: 0 };
|
|
6664
|
-
}
|
|
6665
|
-
const container = containerRef.current?.getBoundingClientRect();
|
|
6666
|
-
if (!container) {
|
|
6667
|
-
return { left: 0, top: 0 };
|
|
6372
|
+
}
|
|
6373
|
+
onBlur?.();
|
|
6668
6374
|
}
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
}
|
|
6684
|
-
},
|
|
6685
|
-
...(0, import_ui86.bindPopover)(popupState),
|
|
6686
|
-
open: hasSelectedContent && selectionRect !== null,
|
|
6687
|
-
anchorReference: "anchorPosition",
|
|
6688
|
-
anchorPosition: computePopupPosition(),
|
|
6689
|
-
anchorOrigin: { vertical: "top", horizontal: "center" },
|
|
6690
|
-
transformOrigin: { vertical: "bottom", horizontal: "center" }
|
|
6691
|
-
},
|
|
6692
|
-
/* @__PURE__ */ React100.createElement(InlineEditorToolbar, { editor, elementId })
|
|
6693
|
-
));
|
|
6694
|
-
}
|
|
6695
|
-
);
|
|
6375
|
+
},
|
|
6376
|
+
wrappedChildren
|
|
6377
|
+
) : /* @__PURE__ */ React98.createElement(React98.Fragment, null, wrappedChildren);
|
|
6378
|
+
};
|
|
6379
|
+
var useOnUpdate = (callback, dependencies) => {
|
|
6380
|
+
const hasMounted = (0, import_react52.useRef)(false);
|
|
6381
|
+
(0, import_react52.useEffect)(() => {
|
|
6382
|
+
if (hasMounted.current) {
|
|
6383
|
+
callback();
|
|
6384
|
+
} else {
|
|
6385
|
+
hasMounted.current = true;
|
|
6386
|
+
}
|
|
6387
|
+
}, dependencies);
|
|
6388
|
+
};
|
|
6696
6389
|
|
|
6697
6390
|
// src/controls/inline-editing-control.tsx
|
|
6698
6391
|
var InlineEditingControl = createControl(
|
|
@@ -6703,8 +6396,8 @@ var InlineEditingControl = createControl(
|
|
|
6703
6396
|
}) => {
|
|
6704
6397
|
const { value, setValue } = useBoundProp(import_editor_props51.htmlPropTypeUtil);
|
|
6705
6398
|
const handleChange = (newValue) => setValue(newValue);
|
|
6706
|
-
return /* @__PURE__ */
|
|
6707
|
-
|
|
6399
|
+
return /* @__PURE__ */ React99.createElement(ControlActions, null, /* @__PURE__ */ React99.createElement(
|
|
6400
|
+
import_ui85.Box,
|
|
6708
6401
|
{
|
|
6709
6402
|
sx: {
|
|
6710
6403
|
p: 0.8,
|
|
@@ -6741,27 +6434,27 @@ var InlineEditingControl = createControl(
|
|
|
6741
6434
|
...attributes,
|
|
6742
6435
|
...props
|
|
6743
6436
|
},
|
|
6744
|
-
/* @__PURE__ */
|
|
6437
|
+
/* @__PURE__ */ React99.createElement(InlineEditor, { value: value || "", setValue: handleChange })
|
|
6745
6438
|
));
|
|
6746
6439
|
}
|
|
6747
6440
|
);
|
|
6748
6441
|
|
|
6749
6442
|
// src/components/icon-buttons/clear-icon-button.tsx
|
|
6750
|
-
var
|
|
6751
|
-
var
|
|
6752
|
-
var
|
|
6753
|
-
var CustomIconButton = (0,
|
|
6443
|
+
var React100 = __toESM(require("react"));
|
|
6444
|
+
var import_icons33 = require("@elementor/icons");
|
|
6445
|
+
var import_ui86 = require("@elementor/ui");
|
|
6446
|
+
var CustomIconButton = (0, import_ui86.styled)(import_ui86.IconButton)(({ theme }) => ({
|
|
6754
6447
|
width: theme.spacing(2.5),
|
|
6755
6448
|
height: theme.spacing(2.5)
|
|
6756
6449
|
}));
|
|
6757
|
-
var ClearIconButton = ({ tooltipText, onClick, disabled, size = "tiny" }) => /* @__PURE__ */
|
|
6450
|
+
var ClearIconButton = ({ tooltipText, onClick, disabled, size = "tiny" }) => /* @__PURE__ */ React100.createElement(import_ui86.Tooltip, { title: tooltipText, placement: "top", disableInteractive: true }, /* @__PURE__ */ React100.createElement(CustomIconButton, { "aria-label": tooltipText, size, onClick, disabled }, /* @__PURE__ */ React100.createElement(import_icons33.BrushBigIcon, { fontSize: size })));
|
|
6758
6451
|
|
|
6759
6452
|
// src/components/repeater/repeater.tsx
|
|
6760
|
-
var
|
|
6761
|
-
var
|
|
6762
|
-
var
|
|
6763
|
-
var
|
|
6764
|
-
var
|
|
6453
|
+
var React101 = __toESM(require("react"));
|
|
6454
|
+
var import_react54 = require("react");
|
|
6455
|
+
var import_icons34 = require("@elementor/icons");
|
|
6456
|
+
var import_ui87 = require("@elementor/ui");
|
|
6457
|
+
var import_i18n50 = require("@wordpress/i18n");
|
|
6765
6458
|
var SIZE9 = "tiny";
|
|
6766
6459
|
var EMPTY_OPEN_ITEM2 = -1;
|
|
6767
6460
|
var Repeater3 = ({
|
|
@@ -6779,7 +6472,7 @@ var Repeater3 = ({
|
|
|
6779
6472
|
openItem: initialOpenItem = EMPTY_OPEN_ITEM2,
|
|
6780
6473
|
isSortable = true
|
|
6781
6474
|
}) => {
|
|
6782
|
-
const [openItem, setOpenItem] = (0,
|
|
6475
|
+
const [openItem, setOpenItem] = (0, import_react54.useState)(initialOpenItem);
|
|
6783
6476
|
const uniqueKeys = items2.map(
|
|
6784
6477
|
(item, index) => isSortable && "getId" in itemSettings ? itemSettings.getId({ item, index }) : String(index)
|
|
6785
6478
|
);
|
|
@@ -6842,8 +6535,8 @@ var Repeater3 = ({
|
|
|
6842
6535
|
};
|
|
6843
6536
|
const isButtonDisabled = disabled || disableAddItemButton;
|
|
6844
6537
|
const shouldShowInfotip = isButtonDisabled && addButtonInfotipContent;
|
|
6845
|
-
const addButton = /* @__PURE__ */
|
|
6846
|
-
|
|
6538
|
+
const addButton = /* @__PURE__ */ React101.createElement(
|
|
6539
|
+
import_ui87.IconButton,
|
|
6847
6540
|
{
|
|
6848
6541
|
size: SIZE9,
|
|
6849
6542
|
sx: {
|
|
@@ -6851,32 +6544,32 @@ var Repeater3 = ({
|
|
|
6851
6544
|
},
|
|
6852
6545
|
disabled: isButtonDisabled,
|
|
6853
6546
|
onClick: addRepeaterItem,
|
|
6854
|
-
"aria-label": (0,
|
|
6547
|
+
"aria-label": (0, import_i18n50.__)("Add item", "elementor")
|
|
6855
6548
|
},
|
|
6856
|
-
/* @__PURE__ */
|
|
6549
|
+
/* @__PURE__ */ React101.createElement(import_icons34.PlusIcon, { fontSize: SIZE9 })
|
|
6857
6550
|
);
|
|
6858
|
-
return /* @__PURE__ */
|
|
6859
|
-
|
|
6551
|
+
return /* @__PURE__ */ React101.createElement(SectionContent, { gap: 2 }, /* @__PURE__ */ React101.createElement(RepeaterHeader, { label, adornment: ControlAdornments }, shouldShowInfotip ? /* @__PURE__ */ React101.createElement(
|
|
6552
|
+
import_ui87.Infotip,
|
|
6860
6553
|
{
|
|
6861
6554
|
placement: "right",
|
|
6862
6555
|
content: addButtonInfotipContent,
|
|
6863
6556
|
color: "secondary",
|
|
6864
6557
|
slotProps: { popper: { sx: { width: 300 } } }
|
|
6865
6558
|
},
|
|
6866
|
-
/* @__PURE__ */
|
|
6867
|
-
) : addButton), 0 < uniqueKeys.length && /* @__PURE__ */
|
|
6559
|
+
/* @__PURE__ */ React101.createElement(import_ui87.Box, { sx: { ...isButtonDisabled ? { cursor: "not-allowed" } : {} } }, addButton)
|
|
6560
|
+
) : addButton), 0 < uniqueKeys.length && /* @__PURE__ */ React101.createElement(SortableProvider, { value: uniqueKeys, onChange: onChangeOrder }, uniqueKeys.map((key) => {
|
|
6868
6561
|
const index = uniqueKeys.indexOf(key);
|
|
6869
6562
|
const value = items2[index];
|
|
6870
6563
|
if (!value) {
|
|
6871
6564
|
return null;
|
|
6872
6565
|
}
|
|
6873
|
-
return /* @__PURE__ */
|
|
6566
|
+
return /* @__PURE__ */ React101.createElement(SortableItem, { id: key, key: `sortable-${key}`, disabled: !isSortable }, /* @__PURE__ */ React101.createElement(
|
|
6874
6567
|
RepeaterItem,
|
|
6875
6568
|
{
|
|
6876
6569
|
disabled,
|
|
6877
6570
|
propDisabled: value?.disabled,
|
|
6878
|
-
label: /* @__PURE__ */
|
|
6879
|
-
startIcon: /* @__PURE__ */
|
|
6571
|
+
label: /* @__PURE__ */ React101.createElement(RepeaterItemLabelSlot, { value }, /* @__PURE__ */ React101.createElement(itemSettings.Label, { value, index })),
|
|
6572
|
+
startIcon: /* @__PURE__ */ React101.createElement(RepeaterItemIconSlot, { value }, /* @__PURE__ */ React101.createElement(itemSettings.Icon, { value })),
|
|
6880
6573
|
removeItem: () => removeRepeaterItem(index),
|
|
6881
6574
|
duplicateItem: () => duplicateRepeaterItem(index),
|
|
6882
6575
|
toggleDisableItem: () => toggleDisableRepeaterItem(index),
|
|
@@ -6888,7 +6581,7 @@ var Repeater3 = ({
|
|
|
6888
6581
|
actions: itemSettings.actions,
|
|
6889
6582
|
value
|
|
6890
6583
|
},
|
|
6891
|
-
(props) => /* @__PURE__ */
|
|
6584
|
+
(props) => /* @__PURE__ */ React101.createElement(
|
|
6892
6585
|
itemSettings.Content,
|
|
6893
6586
|
{
|
|
6894
6587
|
...props,
|
|
@@ -6918,27 +6611,27 @@ var RepeaterItem = ({
|
|
|
6918
6611
|
value
|
|
6919
6612
|
}) => {
|
|
6920
6613
|
const { popoverState, popoverProps, ref, setRef } = usePopover(openOnMount, onOpen);
|
|
6921
|
-
const duplicateLabel = (0,
|
|
6922
|
-
const toggleLabel = propDisabled ? (0,
|
|
6923
|
-
const removeLabel = (0,
|
|
6924
|
-
return /* @__PURE__ */
|
|
6614
|
+
const duplicateLabel = (0, import_i18n50.__)("Duplicate", "elementor");
|
|
6615
|
+
const toggleLabel = propDisabled ? (0, import_i18n50.__)("Show", "elementor") : (0, import_i18n50.__)("Hide", "elementor");
|
|
6616
|
+
const removeLabel = (0, import_i18n50.__)("Remove", "elementor");
|
|
6617
|
+
return /* @__PURE__ */ React101.createElement(React101.Fragment, null, /* @__PURE__ */ React101.createElement(
|
|
6925
6618
|
RepeaterTag,
|
|
6926
6619
|
{
|
|
6927
6620
|
disabled,
|
|
6928
6621
|
label,
|
|
6929
6622
|
ref: setRef,
|
|
6930
|
-
"aria-label": (0,
|
|
6931
|
-
...(0,
|
|
6623
|
+
"aria-label": (0, import_i18n50.__)("Open item", "elementor"),
|
|
6624
|
+
...(0, import_ui87.bindTrigger)(popoverState),
|
|
6932
6625
|
startIcon,
|
|
6933
|
-
actions: /* @__PURE__ */
|
|
6626
|
+
actions: /* @__PURE__ */ React101.createElement(React101.Fragment, null, showDuplicate && /* @__PURE__ */ React101.createElement(import_ui87.Tooltip, { title: duplicateLabel, placement: "top" }, /* @__PURE__ */ React101.createElement(import_ui87.IconButton, { size: SIZE9, onClick: duplicateItem, "aria-label": duplicateLabel }, /* @__PURE__ */ React101.createElement(import_icons34.CopyIcon, { fontSize: SIZE9 }))), showToggle && /* @__PURE__ */ React101.createElement(import_ui87.Tooltip, { title: toggleLabel, placement: "top" }, /* @__PURE__ */ React101.createElement(import_ui87.IconButton, { size: SIZE9, onClick: toggleDisableItem, "aria-label": toggleLabel }, propDisabled ? /* @__PURE__ */ React101.createElement(import_icons34.EyeOffIcon, { fontSize: SIZE9 }) : /* @__PURE__ */ React101.createElement(import_icons34.EyeIcon, { fontSize: SIZE9 }))), actions?.(value), showRemove && /* @__PURE__ */ React101.createElement(import_ui87.Tooltip, { title: removeLabel, placement: "top" }, /* @__PURE__ */ React101.createElement(import_ui87.IconButton, { size: SIZE9, onClick: removeItem, "aria-label": removeLabel }, /* @__PURE__ */ React101.createElement(import_icons34.XIcon, { fontSize: SIZE9 }))))
|
|
6934
6627
|
}
|
|
6935
|
-
), /* @__PURE__ */
|
|
6628
|
+
), /* @__PURE__ */ React101.createElement(RepeaterPopover, { width: ref?.getBoundingClientRect().width, ...popoverProps, anchorEl: ref }, /* @__PURE__ */ React101.createElement(import_ui87.Box, null, children({ anchorEl: ref }))));
|
|
6936
6629
|
};
|
|
6937
6630
|
var usePopover = (openOnMount, onOpen) => {
|
|
6938
|
-
const [ref, setRef] = (0,
|
|
6939
|
-
const popoverState = (0,
|
|
6940
|
-
const popoverProps = (0,
|
|
6941
|
-
(0,
|
|
6631
|
+
const [ref, setRef] = (0, import_react54.useState)(null);
|
|
6632
|
+
const popoverState = (0, import_ui87.usePopupState)({ variant: "popover" });
|
|
6633
|
+
const popoverProps = (0, import_ui87.bindPopover)(popoverState);
|
|
6634
|
+
(0, import_react54.useEffect)(() => {
|
|
6942
6635
|
if (openOnMount && ref) {
|
|
6943
6636
|
popoverState.open(ref);
|
|
6944
6637
|
onOpen?.();
|
|
@@ -6952,6 +6645,270 @@ var usePopover = (openOnMount, onOpen) => {
|
|
|
6952
6645
|
};
|
|
6953
6646
|
};
|
|
6954
6647
|
|
|
6648
|
+
// src/components/inline-editor-toolbar.tsx
|
|
6649
|
+
var React103 = __toESM(require("react"));
|
|
6650
|
+
var import_react56 = require("react");
|
|
6651
|
+
var import_editor_elements6 = require("@elementor/editor-elements");
|
|
6652
|
+
var import_icons36 = require("@elementor/icons");
|
|
6653
|
+
var import_ui89 = require("@elementor/ui");
|
|
6654
|
+
var import_react57 = require("@tiptap/react");
|
|
6655
|
+
var import_i18n52 = require("@wordpress/i18n");
|
|
6656
|
+
|
|
6657
|
+
// src/components/url-popover.tsx
|
|
6658
|
+
var React102 = __toESM(require("react"));
|
|
6659
|
+
var import_react55 = require("react");
|
|
6660
|
+
var import_icons35 = require("@elementor/icons");
|
|
6661
|
+
var import_ui88 = require("@elementor/ui");
|
|
6662
|
+
var import_i18n51 = require("@wordpress/i18n");
|
|
6663
|
+
var UrlPopover = ({
|
|
6664
|
+
popupState,
|
|
6665
|
+
restoreValue,
|
|
6666
|
+
anchorRef,
|
|
6667
|
+
value,
|
|
6668
|
+
onChange,
|
|
6669
|
+
openInNewTab,
|
|
6670
|
+
onToggleNewTab
|
|
6671
|
+
}) => {
|
|
6672
|
+
const inputRef = (0, import_react55.useRef)(null);
|
|
6673
|
+
(0, import_react55.useEffect)(() => {
|
|
6674
|
+
if (popupState.isOpen) {
|
|
6675
|
+
requestAnimationFrame(() => inputRef.current?.focus());
|
|
6676
|
+
}
|
|
6677
|
+
}, [popupState.isOpen]);
|
|
6678
|
+
const handleClose = () => {
|
|
6679
|
+
restoreValue();
|
|
6680
|
+
popupState.close();
|
|
6681
|
+
};
|
|
6682
|
+
return /* @__PURE__ */ React102.createElement(
|
|
6683
|
+
import_ui88.Popover,
|
|
6684
|
+
{
|
|
6685
|
+
slotProps: {
|
|
6686
|
+
paper: { sx: { borderRadius: "16px", width: anchorRef.current?.offsetWidth + "px", marginTop: -1 } }
|
|
6687
|
+
},
|
|
6688
|
+
...(0, import_ui88.bindPopover)(popupState),
|
|
6689
|
+
anchorOrigin: { vertical: "top", horizontal: "left" },
|
|
6690
|
+
transformOrigin: { vertical: "top", horizontal: "left" },
|
|
6691
|
+
onClose: handleClose
|
|
6692
|
+
},
|
|
6693
|
+
/* @__PURE__ */ React102.createElement(import_ui88.Stack, { direction: "row", alignItems: "center", gap: 1, sx: { p: 1.5 } }, /* @__PURE__ */ React102.createElement(
|
|
6694
|
+
import_ui88.TextField,
|
|
6695
|
+
{
|
|
6696
|
+
value,
|
|
6697
|
+
onChange,
|
|
6698
|
+
size: "tiny",
|
|
6699
|
+
fullWidth: true,
|
|
6700
|
+
placeholder: (0, import_i18n51.__)("Type a URL", "elementor"),
|
|
6701
|
+
inputProps: { ref: inputRef },
|
|
6702
|
+
color: "secondary",
|
|
6703
|
+
InputProps: { sx: { borderRadius: "8px" } },
|
|
6704
|
+
onKeyUp: (event) => event.key === "Enter" && handleClose()
|
|
6705
|
+
}
|
|
6706
|
+
), /* @__PURE__ */ React102.createElement(import_ui88.Tooltip, { title: (0, import_i18n51.__)("Open in a new tab", "elementor") }, /* @__PURE__ */ React102.createElement(
|
|
6707
|
+
import_ui88.ToggleButton,
|
|
6708
|
+
{
|
|
6709
|
+
size: "tiny",
|
|
6710
|
+
value: "newTab",
|
|
6711
|
+
selected: openInNewTab,
|
|
6712
|
+
onClick: onToggleNewTab,
|
|
6713
|
+
"aria-label": (0, import_i18n51.__)("Open in a new tab", "elementor"),
|
|
6714
|
+
sx: { borderRadius: "8px" }
|
|
6715
|
+
},
|
|
6716
|
+
/* @__PURE__ */ React102.createElement(import_icons35.ExternalLinkIcon, { fontSize: "tiny" })
|
|
6717
|
+
)))
|
|
6718
|
+
);
|
|
6719
|
+
};
|
|
6720
|
+
|
|
6721
|
+
// src/components/inline-editor-toolbar.tsx
|
|
6722
|
+
var InlineEditorToolbar = ({ editor, elementId, sx = {} }) => {
|
|
6723
|
+
const [urlValue, setUrlValue] = (0, import_react56.useState)("");
|
|
6724
|
+
const [openInNewTab, setOpenInNewTab] = (0, import_react56.useState)(false);
|
|
6725
|
+
const toolbarRef = (0, import_react56.useRef)(null);
|
|
6726
|
+
const linkPopupState = (0, import_ui89.usePopupState)({ variant: "popover" });
|
|
6727
|
+
const hasLinkOnElement = elementId ? checkIfElementHasLink(elementId) : false;
|
|
6728
|
+
const editorState = (0, import_react57.useEditorState)({
|
|
6729
|
+
editor,
|
|
6730
|
+
selector: (ctx) => possibleFormats.filter((format) => ctx.editor.isActive(format))
|
|
6731
|
+
});
|
|
6732
|
+
const formatButtonsList = (0, import_react56.useMemo)(() => {
|
|
6733
|
+
const buttons = Object.values(formatButtons);
|
|
6734
|
+
if (hasLinkOnElement) {
|
|
6735
|
+
return buttons.filter((button) => button.action !== "link");
|
|
6736
|
+
}
|
|
6737
|
+
return buttons;
|
|
6738
|
+
}, [hasLinkOnElement]);
|
|
6739
|
+
const handleLinkClick = () => {
|
|
6740
|
+
const linkAttrs = editor.getAttributes("link");
|
|
6741
|
+
setUrlValue(linkAttrs.href || "");
|
|
6742
|
+
setOpenInNewTab(linkAttrs.target === "_blank");
|
|
6743
|
+
linkPopupState.open(toolbarRef.current);
|
|
6744
|
+
};
|
|
6745
|
+
const handleUrlChange = (event) => {
|
|
6746
|
+
setUrlValue(event.target.value);
|
|
6747
|
+
};
|
|
6748
|
+
const handleToggleNewTab = () => {
|
|
6749
|
+
setOpenInNewTab(!openInNewTab);
|
|
6750
|
+
};
|
|
6751
|
+
const handleUrlSubmit = () => {
|
|
6752
|
+
if (urlValue) {
|
|
6753
|
+
editor.chain().focus().setLink({
|
|
6754
|
+
href: urlValue,
|
|
6755
|
+
target: openInNewTab ? "_blank" : "_self"
|
|
6756
|
+
}).run();
|
|
6757
|
+
} else {
|
|
6758
|
+
editor.chain().focus().unsetLink().run();
|
|
6759
|
+
}
|
|
6760
|
+
if (elementId) {
|
|
6761
|
+
window.dispatchEvent(
|
|
6762
|
+
new CustomEvent("elementor:inline-link-changed", {
|
|
6763
|
+
detail: { elementId }
|
|
6764
|
+
})
|
|
6765
|
+
);
|
|
6766
|
+
}
|
|
6767
|
+
linkPopupState.close();
|
|
6768
|
+
};
|
|
6769
|
+
React103.useEffect(() => {
|
|
6770
|
+
editor?.commands?.focus();
|
|
6771
|
+
}, [editor]);
|
|
6772
|
+
return /* @__PURE__ */ React103.createElement(
|
|
6773
|
+
import_ui89.Box,
|
|
6774
|
+
{
|
|
6775
|
+
ref: toolbarRef,
|
|
6776
|
+
sx: {
|
|
6777
|
+
display: "inline-flex",
|
|
6778
|
+
gap: 0.5,
|
|
6779
|
+
padding: 0.5,
|
|
6780
|
+
borderRadius: "8px",
|
|
6781
|
+
backgroundColor: "background.paper",
|
|
6782
|
+
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.2)",
|
|
6783
|
+
alignItems: "center",
|
|
6784
|
+
visibility: linkPopupState.isOpen ? "hidden" : "visible",
|
|
6785
|
+
pointerEvents: linkPopupState.isOpen ? "none" : "all",
|
|
6786
|
+
...sx
|
|
6787
|
+
}
|
|
6788
|
+
},
|
|
6789
|
+
/* @__PURE__ */ React103.createElement(import_ui89.Tooltip, { title: clearButton.label, placement: "top", sx: { borderRadius: "8px" } }, /* @__PURE__ */ React103.createElement(import_ui89.IconButton, { "aria-label": clearButton.label, onClick: () => clearButton.method(editor), size: "tiny" }, clearButton.icon)),
|
|
6790
|
+
/* @__PURE__ */ React103.createElement(
|
|
6791
|
+
import_ui89.ToggleButtonGroup,
|
|
6792
|
+
{
|
|
6793
|
+
value: editorState,
|
|
6794
|
+
size: "tiny",
|
|
6795
|
+
sx: {
|
|
6796
|
+
display: "flex",
|
|
6797
|
+
gap: 0.5,
|
|
6798
|
+
border: "none",
|
|
6799
|
+
[`& .${import_ui89.toggleButtonGroupClasses.firstButton}, & .${import_ui89.toggleButtonGroupClasses.middleButton}, & .${import_ui89.toggleButtonGroupClasses.lastButton}`]: {
|
|
6800
|
+
borderRadius: "8px",
|
|
6801
|
+
border: "none",
|
|
6802
|
+
marginLeft: 0,
|
|
6803
|
+
"&.Mui-selected": {
|
|
6804
|
+
marginLeft: 0
|
|
6805
|
+
},
|
|
6806
|
+
"& + &.Mui-selected": {
|
|
6807
|
+
marginLeft: 0
|
|
6808
|
+
}
|
|
6809
|
+
}
|
|
6810
|
+
}
|
|
6811
|
+
},
|
|
6812
|
+
formatButtonsList.map((button) => /* @__PURE__ */ React103.createElement(import_ui89.Tooltip, { title: button.label, key: button.action, placement: "top" }, /* @__PURE__ */ React103.createElement(
|
|
6813
|
+
import_ui89.ToggleButton,
|
|
6814
|
+
{
|
|
6815
|
+
value: button.action,
|
|
6816
|
+
"aria-label": button.label,
|
|
6817
|
+
size: "tiny",
|
|
6818
|
+
onClick: () => {
|
|
6819
|
+
if (button.action === "link") {
|
|
6820
|
+
handleLinkClick();
|
|
6821
|
+
} else {
|
|
6822
|
+
button.method?.(editor);
|
|
6823
|
+
}
|
|
6824
|
+
editor?.commands?.focus();
|
|
6825
|
+
}
|
|
6826
|
+
},
|
|
6827
|
+
button.icon
|
|
6828
|
+
)))
|
|
6829
|
+
),
|
|
6830
|
+
/* @__PURE__ */ React103.createElement(
|
|
6831
|
+
UrlPopover,
|
|
6832
|
+
{
|
|
6833
|
+
popupState: linkPopupState,
|
|
6834
|
+
anchorRef: toolbarRef,
|
|
6835
|
+
restoreValue: handleUrlSubmit,
|
|
6836
|
+
value: urlValue,
|
|
6837
|
+
onChange: handleUrlChange,
|
|
6838
|
+
openInNewTab,
|
|
6839
|
+
onToggleNewTab: handleToggleNewTab
|
|
6840
|
+
}
|
|
6841
|
+
)
|
|
6842
|
+
);
|
|
6843
|
+
};
|
|
6844
|
+
var checkIfElementHasLink = (elementId) => !!(0, import_editor_elements6.getElementSetting)(elementId, "link")?.value?.destination;
|
|
6845
|
+
var toolbarButtons = {
|
|
6846
|
+
clear: {
|
|
6847
|
+
label: (0, import_i18n52.__)("Clear", "elementor"),
|
|
6848
|
+
icon: /* @__PURE__ */ React103.createElement(import_icons36.MinusIcon, { fontSize: "tiny" }),
|
|
6849
|
+
action: "clear",
|
|
6850
|
+
method: (editor) => {
|
|
6851
|
+
editor.chain().focus().clearNodes().unsetAllMarks().run();
|
|
6852
|
+
}
|
|
6853
|
+
},
|
|
6854
|
+
bold: {
|
|
6855
|
+
label: (0, import_i18n52.__)("Bold", "elementor"),
|
|
6856
|
+
icon: /* @__PURE__ */ React103.createElement(import_icons36.BoldIcon, { fontSize: "tiny" }),
|
|
6857
|
+
action: "bold",
|
|
6858
|
+
method: (editor) => {
|
|
6859
|
+
editor.chain().focus().toggleBold().run();
|
|
6860
|
+
}
|
|
6861
|
+
},
|
|
6862
|
+
italic: {
|
|
6863
|
+
label: (0, import_i18n52.__)("Italic", "elementor"),
|
|
6864
|
+
icon: /* @__PURE__ */ React103.createElement(import_icons36.ItalicIcon, { fontSize: "tiny" }),
|
|
6865
|
+
action: "italic",
|
|
6866
|
+
method: (editor) => {
|
|
6867
|
+
editor.chain().focus().toggleItalic().run();
|
|
6868
|
+
}
|
|
6869
|
+
},
|
|
6870
|
+
underline: {
|
|
6871
|
+
label: (0, import_i18n52.__)("Underline", "elementor"),
|
|
6872
|
+
icon: /* @__PURE__ */ React103.createElement(import_icons36.UnderlineIcon, { fontSize: "tiny" }),
|
|
6873
|
+
action: "underline",
|
|
6874
|
+
method: (editor) => {
|
|
6875
|
+
editor.chain().focus().toggleUnderline().run();
|
|
6876
|
+
}
|
|
6877
|
+
},
|
|
6878
|
+
strike: {
|
|
6879
|
+
label: (0, import_i18n52.__)("Strikethrough", "elementor"),
|
|
6880
|
+
icon: /* @__PURE__ */ React103.createElement(import_icons36.StrikethroughIcon, { fontSize: "tiny" }),
|
|
6881
|
+
action: "strike",
|
|
6882
|
+
method: (editor) => {
|
|
6883
|
+
editor.chain().focus().toggleStrike().run();
|
|
6884
|
+
}
|
|
6885
|
+
},
|
|
6886
|
+
superscript: {
|
|
6887
|
+
label: (0, import_i18n52.__)("Superscript", "elementor"),
|
|
6888
|
+
icon: /* @__PURE__ */ React103.createElement(import_icons36.SuperscriptIcon, { fontSize: "tiny" }),
|
|
6889
|
+
action: "superscript",
|
|
6890
|
+
method: (editor) => {
|
|
6891
|
+
editor.chain().focus().toggleSuperscript().run();
|
|
6892
|
+
}
|
|
6893
|
+
},
|
|
6894
|
+
subscript: {
|
|
6895
|
+
label: (0, import_i18n52.__)("Subscript", "elementor"),
|
|
6896
|
+
icon: /* @__PURE__ */ React103.createElement(import_icons36.SubscriptIcon, { fontSize: "tiny" }),
|
|
6897
|
+
action: "subscript",
|
|
6898
|
+
method: (editor) => {
|
|
6899
|
+
editor.chain().focus().toggleSubscript().run();
|
|
6900
|
+
}
|
|
6901
|
+
},
|
|
6902
|
+
link: {
|
|
6903
|
+
label: (0, import_i18n52.__)("Link", "elementor"),
|
|
6904
|
+
icon: /* @__PURE__ */ React103.createElement(import_icons36.LinkIcon, { fontSize: "tiny" }),
|
|
6905
|
+
action: "link",
|
|
6906
|
+
method: null
|
|
6907
|
+
}
|
|
6908
|
+
};
|
|
6909
|
+
var { clear: clearButton, ...formatButtons } = toolbarButtons;
|
|
6910
|
+
var possibleFormats = Object.keys(formatButtons);
|
|
6911
|
+
|
|
6955
6912
|
// src/components/size/unstable-size-field.tsx
|
|
6956
6913
|
var React106 = __toESM(require("react"));
|
|
6957
6914
|
var import_ui91 = require("@elementor/ui");
|
|
@@ -7204,9 +7161,11 @@ var useFontFamilies = () => {
|
|
|
7204
7161
|
createControl,
|
|
7205
7162
|
createControlReplacementsRegistry,
|
|
7206
7163
|
enqueueFont,
|
|
7164
|
+
getControlReplacements,
|
|
7207
7165
|
injectIntoRepeaterItemActions,
|
|
7208
7166
|
injectIntoRepeaterItemIcon,
|
|
7209
7167
|
injectIntoRepeaterItemLabel,
|
|
7168
|
+
registerControlReplacement,
|
|
7210
7169
|
transitionProperties,
|
|
7211
7170
|
transitionsItemsList,
|
|
7212
7171
|
useBoundProp,
|