@elementor/editor-controls 4.0.0-512 → 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 +11 -12
- package/dist/index.d.ts +11 -12
- package/dist/index.js +434 -480
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +448 -496
- 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/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -6213,14 +6213,14 @@ var DateTimeControl = createControl(({ inputDisabled }) => {
|
|
|
6213
6213
|
});
|
|
6214
6214
|
|
|
6215
6215
|
// src/controls/inline-editing-control.tsx
|
|
6216
|
-
var
|
|
6216
|
+
var React99 = __toESM(require("react"));
|
|
6217
6217
|
var import_editor_props51 = require("@elementor/editor-props");
|
|
6218
|
-
var
|
|
6218
|
+
var import_ui85 = require("@elementor/ui");
|
|
6219
6219
|
|
|
6220
6220
|
// src/components/inline-editor.tsx
|
|
6221
|
-
var
|
|
6222
|
-
var
|
|
6223
|
-
var
|
|
6221
|
+
var React98 = __toESM(require("react"));
|
|
6222
|
+
var import_react52 = require("react");
|
|
6223
|
+
var import_ui84 = require("@elementor/ui");
|
|
6224
6224
|
var import_extension_bold = __toESM(require("@tiptap/extension-bold"));
|
|
6225
6225
|
var import_extension_document = __toESM(require("@tiptap/extension-document"));
|
|
6226
6226
|
var import_extension_hard_break = __toESM(require("@tiptap/extension-hard-break"));
|
|
@@ -6233,7 +6233,7 @@ var import_extension_subscript = __toESM(require("@tiptap/extension-subscript"))
|
|
|
6233
6233
|
var import_extension_superscript = __toESM(require("@tiptap/extension-superscript"));
|
|
6234
6234
|
var import_extension_text = __toESM(require("@tiptap/extension-text"));
|
|
6235
6235
|
var import_extension_underline = __toESM(require("@tiptap/extension-underline"));
|
|
6236
|
-
var
|
|
6236
|
+
var import_react53 = require("@tiptap/react");
|
|
6237
6237
|
|
|
6238
6238
|
// src/utils/inline-editing.ts
|
|
6239
6239
|
function isEmpty(value = "") {
|
|
@@ -6245,457 +6245,147 @@ function isEmpty(value = "") {
|
|
|
6245
6245
|
return !pseudoElement.textContent?.length;
|
|
6246
6246
|
}
|
|
6247
6247
|
|
|
6248
|
-
// src/components/inline-editor
|
|
6249
|
-
var
|
|
6250
|
-
var
|
|
6251
|
-
var
|
|
6252
|
-
var
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
}) => {
|
|
6272
|
-
const inputRef = (0, import_react52.useRef)(null);
|
|
6273
|
-
(0, import_react52.useEffect)(() => {
|
|
6274
|
-
if (popupState.isOpen) {
|
|
6275
|
-
requestAnimationFrame(() => inputRef.current?.focus());
|
|
6276
|
-
}
|
|
6277
|
-
}, [popupState.isOpen]);
|
|
6278
|
-
const handleClose = () => {
|
|
6279
|
-
restoreValue();
|
|
6280
|
-
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);
|
|
6281
6271
|
};
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
slotProps: {
|
|
6286
|
-
paper: { sx: { borderRadius: "16px", width: anchorRef.current?.offsetWidth + "px", marginTop: -1 } }
|
|
6287
|
-
},
|
|
6288
|
-
...(0, import_ui84.bindPopover)(popupState),
|
|
6289
|
-
anchorOrigin: { vertical: "top", horizontal: "left" },
|
|
6290
|
-
transformOrigin: { vertical: "top", horizontal: "left" },
|
|
6291
|
-
onClose: handleClose
|
|
6292
|
-
},
|
|
6293
|
-
/* @__PURE__ */ React98.createElement(import_ui84.Stack, { direction: "row", alignItems: "center", gap: 1, sx: { p: 1.5 } }, /* @__PURE__ */ React98.createElement(
|
|
6294
|
-
import_ui84.TextField,
|
|
6295
|
-
{
|
|
6296
|
-
value,
|
|
6297
|
-
onChange,
|
|
6298
|
-
size: "tiny",
|
|
6299
|
-
fullWidth: true,
|
|
6300
|
-
placeholder: (0, import_i18n50.__)("Type a URL", "elementor"),
|
|
6301
|
-
inputProps: { ref: inputRef },
|
|
6302
|
-
color: "secondary",
|
|
6303
|
-
InputProps: { sx: { borderRadius: "8px" } },
|
|
6304
|
-
onKeyUp: (event) => event.key === "Enter" && handleClose()
|
|
6305
|
-
}
|
|
6306
|
-
), /* @__PURE__ */ React98.createElement(import_ui84.Tooltip, { title: (0, import_i18n50.__)("Open in a new tab", "elementor") }, /* @__PURE__ */ React98.createElement(
|
|
6307
|
-
import_ui84.ToggleButton,
|
|
6308
|
-
{
|
|
6309
|
-
size: "tiny",
|
|
6310
|
-
value: "newTab",
|
|
6311
|
-
selected: openInNewTab,
|
|
6312
|
-
onClick: onToggleNewTab,
|
|
6313
|
-
"aria-label": (0, import_i18n50.__)("Open in a new tab", "elementor"),
|
|
6314
|
-
sx: { borderRadius: "8px" }
|
|
6315
|
-
},
|
|
6316
|
-
/* @__PURE__ */ React98.createElement(import_icons33.ExternalLinkIcon, { fontSize: "tiny" })
|
|
6317
|
-
)))
|
|
6318
|
-
);
|
|
6319
|
-
};
|
|
6320
|
-
|
|
6321
|
-
// src/components/inline-editor-toolbar.tsx
|
|
6322
|
-
var checkIfElementHasLink = (elementId) => !!(0, import_editor_elements6.getElementSetting)(elementId, "link")?.value?.destination;
|
|
6323
|
-
var toolbarButtons = {
|
|
6324
|
-
clear: {
|
|
6325
|
-
label: (0, import_i18n51.__)("Clear", "elementor"),
|
|
6326
|
-
icon: /* @__PURE__ */ React99.createElement(import_icons34.MinusIcon, { fontSize: "tiny" }),
|
|
6327
|
-
action: "clear",
|
|
6328
|
-
method: (editor) => {
|
|
6329
|
-
editor.chain().focus().clearNodes().unsetAllMarks().run();
|
|
6330
|
-
}
|
|
6331
|
-
},
|
|
6332
|
-
bold: {
|
|
6333
|
-
label: (0, import_i18n51.__)("Bold", "elementor"),
|
|
6334
|
-
icon: /* @__PURE__ */ React99.createElement(import_icons34.BoldIcon, { fontSize: "tiny" }),
|
|
6335
|
-
action: "bold",
|
|
6336
|
-
method: (editor) => {
|
|
6337
|
-
editor.chain().focus().toggleBold().run();
|
|
6272
|
+
const onKeyDown = (_, event) => {
|
|
6273
|
+
if (event.key === "Escape") {
|
|
6274
|
+
onBlur?.();
|
|
6338
6275
|
}
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
label: (0, import_i18n51.__)("Italic", "elementor"),
|
|
6342
|
-
icon: /* @__PURE__ */ React99.createElement(import_icons34.ItalicIcon, { fontSize: "tiny" }),
|
|
6343
|
-
action: "italic",
|
|
6344
|
-
method: (editor) => {
|
|
6345
|
-
editor.chain().focus().toggleItalic().run();
|
|
6346
|
-
}
|
|
6347
|
-
},
|
|
6348
|
-
underline: {
|
|
6349
|
-
label: (0, import_i18n51.__)("Underline", "elementor"),
|
|
6350
|
-
icon: /* @__PURE__ */ React99.createElement(import_icons34.UnderlineIcon, { fontSize: "tiny" }),
|
|
6351
|
-
action: "underline",
|
|
6352
|
-
method: (editor) => {
|
|
6353
|
-
editor.chain().focus().toggleUnderline().run();
|
|
6354
|
-
}
|
|
6355
|
-
},
|
|
6356
|
-
strike: {
|
|
6357
|
-
label: (0, import_i18n51.__)("Strikethrough", "elementor"),
|
|
6358
|
-
icon: /* @__PURE__ */ React99.createElement(import_icons34.StrikethroughIcon, { fontSize: "tiny" }),
|
|
6359
|
-
action: "strike",
|
|
6360
|
-
method: (editor) => {
|
|
6361
|
-
editor.chain().focus().toggleStrike().run();
|
|
6362
|
-
}
|
|
6363
|
-
},
|
|
6364
|
-
superscript: {
|
|
6365
|
-
label: (0, import_i18n51.__)("Superscript", "elementor"),
|
|
6366
|
-
icon: /* @__PURE__ */ React99.createElement(import_icons34.SuperscriptIcon, { fontSize: "tiny" }),
|
|
6367
|
-
action: "superscript",
|
|
6368
|
-
method: (editor) => {
|
|
6369
|
-
editor.chain().focus().toggleSuperscript().run();
|
|
6370
|
-
}
|
|
6371
|
-
},
|
|
6372
|
-
subscript: {
|
|
6373
|
-
label: (0, import_i18n51.__)("Subscript", "elementor"),
|
|
6374
|
-
icon: /* @__PURE__ */ React99.createElement(import_icons34.SubscriptIcon, { fontSize: "tiny" }),
|
|
6375
|
-
action: "subscript",
|
|
6376
|
-
method: (editor) => {
|
|
6377
|
-
editor.chain().focus().toggleSubscript().run();
|
|
6378
|
-
}
|
|
6379
|
-
},
|
|
6380
|
-
link: {
|
|
6381
|
-
label: (0, import_i18n51.__)("Link", "elementor"),
|
|
6382
|
-
icon: /* @__PURE__ */ React99.createElement(import_icons34.LinkIcon, { fontSize: "tiny" }),
|
|
6383
|
-
action: "link",
|
|
6384
|
-
method: null
|
|
6385
|
-
}
|
|
6386
|
-
};
|
|
6387
|
-
var { clear: clearButton, ...formatButtons } = toolbarButtons;
|
|
6388
|
-
var possibleFormats = Object.keys(formatButtons);
|
|
6389
|
-
var InlineEditorToolbar = ({ editor, elementId }) => {
|
|
6390
|
-
const [urlValue, setUrlValue] = (0, import_react53.useState)("");
|
|
6391
|
-
const [openInNewTab, setOpenInNewTab] = (0, import_react53.useState)(false);
|
|
6392
|
-
const toolbarRef = (0, import_react53.useRef)(null);
|
|
6393
|
-
const linkPopupState = (0, import_ui85.usePopupState)({ variant: "popover" });
|
|
6394
|
-
const hasLinkOnElement = elementId ? checkIfElementHasLink(elementId) : false;
|
|
6395
|
-
const editorState = (0, import_react54.useEditorState)({
|
|
6396
|
-
editor,
|
|
6397
|
-
selector: (ctx) => possibleFormats.filter((format) => ctx.editor.isActive(format))
|
|
6398
|
-
});
|
|
6399
|
-
const formatButtonsList = (0, import_react53.useMemo)(() => {
|
|
6400
|
-
const buttons = Object.values(formatButtons);
|
|
6401
|
-
if (hasLinkOnElement) {
|
|
6402
|
-
return buttons.filter((button) => button.action !== "link");
|
|
6403
|
-
}
|
|
6404
|
-
return buttons;
|
|
6405
|
-
}, [hasLinkOnElement]);
|
|
6406
|
-
const handleLinkClick = () => {
|
|
6407
|
-
const linkAttrs = editor.getAttributes("link");
|
|
6408
|
-
setUrlValue(linkAttrs.href || "");
|
|
6409
|
-
setOpenInNewTab(linkAttrs.target === "_blank");
|
|
6410
|
-
linkPopupState.open(toolbarRef.current);
|
|
6411
|
-
};
|
|
6412
|
-
const handleUrlChange = (event) => {
|
|
6413
|
-
setUrlValue(event.target.value);
|
|
6414
|
-
};
|
|
6415
|
-
const handleToggleNewTab = () => {
|
|
6416
|
-
setOpenInNewTab(!openInNewTab);
|
|
6417
|
-
};
|
|
6418
|
-
const handleUrlSubmit = () => {
|
|
6419
|
-
if (urlValue) {
|
|
6420
|
-
editor.chain().focus().setLink({
|
|
6421
|
-
href: urlValue,
|
|
6422
|
-
target: openInNewTab ? "_blank" : "_self"
|
|
6423
|
-
}).run();
|
|
6424
|
-
} else {
|
|
6425
|
-
editor.chain().focus().unsetLink().run();
|
|
6276
|
+
if (!event.metaKey && !event.ctrlKey || event.altKey) {
|
|
6277
|
+
return;
|
|
6426
6278
|
}
|
|
6427
|
-
if (
|
|
6428
|
-
|
|
6429
|
-
new CustomEvent("elementor:inline-link-changed", {
|
|
6430
|
-
detail: { elementId }
|
|
6431
|
-
})
|
|
6432
|
-
);
|
|
6279
|
+
if ([ITALIC_KEYBOARD_SHORTCUT, BOLD_KEYBOARD_SHORTCUT, UNDERLINE_KEYBOARD_SHORTCUT].includes(event.key)) {
|
|
6280
|
+
event.stopPropagation();
|
|
6433
6281
|
}
|
|
6434
|
-
linkPopupState.close();
|
|
6435
6282
|
};
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
/* @__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)),
|
|
6456
|
-
/* @__PURE__ */ React99.createElement(
|
|
6457
|
-
import_ui85.ToggleButtonGroup,
|
|
6458
|
-
{
|
|
6459
|
-
value: editorState,
|
|
6460
|
-
size: "tiny",
|
|
6461
|
-
sx: {
|
|
6462
|
-
display: "flex",
|
|
6463
|
-
gap: 0.5,
|
|
6464
|
-
border: "none",
|
|
6465
|
-
[`& .${import_ui85.toggleButtonGroupClasses.firstButton}, & .${import_ui85.toggleButtonGroupClasses.middleButton}, & .${import_ui85.toggleButtonGroupClasses.lastButton}`]: {
|
|
6466
|
-
borderRadius: "8px",
|
|
6467
|
-
border: "none",
|
|
6468
|
-
marginLeft: 0,
|
|
6469
|
-
"&.Mui-selected": {
|
|
6470
|
-
marginLeft: 0
|
|
6471
|
-
},
|
|
6472
|
-
"& + &.Mui-selected": {
|
|
6473
|
-
marginLeft: 0
|
|
6474
|
-
}
|
|
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];
|
|
6475
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
|
+
};
|
|
6476
6324
|
}
|
|
6325
|
+
})
|
|
6326
|
+
],
|
|
6327
|
+
content: value,
|
|
6328
|
+
onUpdate,
|
|
6329
|
+
autofocus,
|
|
6330
|
+
editorProps: {
|
|
6331
|
+
...editorProps,
|
|
6332
|
+
handleDOMEvents: {
|
|
6333
|
+
keydown: onKeyDown
|
|
6477
6334
|
},
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
value: button.action,
|
|
6482
|
-
"aria-label": button.label,
|
|
6483
|
-
size: "tiny",
|
|
6484
|
-
onClick: () => {
|
|
6485
|
-
if (button.action === "link") {
|
|
6486
|
-
handleLinkClick();
|
|
6487
|
-
} else {
|
|
6488
|
-
button.method?.(editor);
|
|
6489
|
-
}
|
|
6490
|
-
editor?.commands?.focus();
|
|
6491
|
-
}
|
|
6492
|
-
},
|
|
6493
|
-
button.icon
|
|
6494
|
-
)))
|
|
6495
|
-
),
|
|
6496
|
-
/* @__PURE__ */ React99.createElement(
|
|
6497
|
-
UrlPopover,
|
|
6498
|
-
{
|
|
6499
|
-
popupState: linkPopupState,
|
|
6500
|
-
anchorRef: toolbarRef,
|
|
6501
|
-
restoreValue: handleUrlSubmit,
|
|
6502
|
-
value: urlValue,
|
|
6503
|
-
onChange: handleUrlChange,
|
|
6504
|
-
openInNewTab,
|
|
6505
|
-
onToggleNewTab: handleToggleNewTab
|
|
6335
|
+
attributes: {
|
|
6336
|
+
...editorProps.attributes ?? {},
|
|
6337
|
+
role: "textbox"
|
|
6506
6338
|
}
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
}
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
var UNDERLINE_KEYBOARD_SHORTCUT = "u";
|
|
6515
|
-
var INLINE_EDITOR_RESET_CLASS = "elementor-inline-editor-reset";
|
|
6516
|
-
var useOnUpdate = (callback, dependencies) => {
|
|
6517
|
-
const hasMounted = (0, import_react55.useRef)(false);
|
|
6518
|
-
(0, import_react55.useEffect)(() => {
|
|
6519
|
-
if (hasMounted.current) {
|
|
6520
|
-
callback();
|
|
6521
|
-
} else {
|
|
6522
|
-
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;
|
|
6523
6346
|
}
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
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,
|
|
6541
6368
|
{
|
|
6542
6369
|
onClickAway: (event) => {
|
|
6543
6370
|
if (containerRef.current?.contains(event.target) || editor.view.dom.contains(event.target)) {
|
|
6544
6371
|
return;
|
|
6545
|
-
}
|
|
6546
|
-
onBlur?.(
|
|
6547
|
-
}
|
|
6548
|
-
},
|
|
6549
|
-
wrappedChildren
|
|
6550
|
-
) : /* @__PURE__ */ React100.createElement(React100.Fragment, null, wrappedChildren);
|
|
6551
|
-
};
|
|
6552
|
-
var InlineEditor = (0, import_react55.forwardRef)(
|
|
6553
|
-
({
|
|
6554
|
-
value,
|
|
6555
|
-
setValue,
|
|
6556
|
-
attributes = {},
|
|
6557
|
-
elementClasses = "",
|
|
6558
|
-
showToolbar = false,
|
|
6559
|
-
autofocus = false,
|
|
6560
|
-
sx = {},
|
|
6561
|
-
onBlur = void 0,
|
|
6562
|
-
getInitialPopoverPosition = void 0,
|
|
6563
|
-
expectedTag = null,
|
|
6564
|
-
elementId = void 0
|
|
6565
|
-
}, ref) => {
|
|
6566
|
-
const containerRef = (0, import_react55.useRef)(null);
|
|
6567
|
-
const popupState = (0, import_ui86.usePopupState)({ variant: "popover", disableAutoFocus: true });
|
|
6568
|
-
const [hasSelectedContent, setHasSelectedContent] = (0, import_react55.useState)(false);
|
|
6569
|
-
const documentContentSettings = !!expectedTag ? "block+" : "inline*";
|
|
6570
|
-
const [selectionRect, setSelectionRect] = (0, import_react55.useState)(null);
|
|
6571
|
-
const onSelectionEnd = (view) => {
|
|
6572
|
-
const hasSelection = !view.state.selection.empty;
|
|
6573
|
-
setHasSelectedContent(hasSelection);
|
|
6574
|
-
if (hasSelection) {
|
|
6575
|
-
const container = containerRef.current?.getBoundingClientRect();
|
|
6576
|
-
setSelectionRect(calcSelectionCenter(view, container));
|
|
6577
|
-
} else {
|
|
6578
|
-
setSelectionRect(null);
|
|
6579
|
-
}
|
|
6580
|
-
queueMicrotask(() => view.focus());
|
|
6581
|
-
};
|
|
6582
|
-
const onKeyDown = (_, event) => {
|
|
6583
|
-
if (event.key === "Escape") {
|
|
6584
|
-
onBlur?.(event);
|
|
6585
|
-
}
|
|
6586
|
-
if (!event.metaKey && !event.ctrlKey || event.altKey) {
|
|
6587
|
-
return;
|
|
6588
|
-
}
|
|
6589
|
-
if ([ITALIC_KEYBOARD_SHORTCUT, BOLD_KEYBOARD_SHORTCUT, UNDERLINE_KEYBOARD_SHORTCUT].includes(event.key)) {
|
|
6590
|
-
event.stopPropagation();
|
|
6591
|
-
}
|
|
6592
|
-
};
|
|
6593
|
-
const toolbarRelatedListeners = showToolbar ? {
|
|
6594
|
-
mouseup: onSelectionEnd,
|
|
6595
|
-
keyup: onSelectionEnd,
|
|
6596
|
-
keydown: onKeyDown
|
|
6597
|
-
} : void 0;
|
|
6598
|
-
const onUpdate = ({ editor: updatedEditor }) => {
|
|
6599
|
-
const newValue = updatedEditor.getHTML();
|
|
6600
|
-
setValue(isEmpty(newValue) ? null : newValue);
|
|
6601
|
-
};
|
|
6602
|
-
const classes = `${INLINE_EDITOR_RESET_CLASS} ${elementClasses}`;
|
|
6603
|
-
const editor = (0, import_react56.useEditor)({
|
|
6604
|
-
extensions: [
|
|
6605
|
-
import_extension_document.default.extend({
|
|
6606
|
-
content: documentContentSettings
|
|
6607
|
-
}),
|
|
6608
|
-
import_extension_paragraph.default.extend({
|
|
6609
|
-
renderHTML({ HTMLAttributes }) {
|
|
6610
|
-
const tag = expectedTag ?? "p";
|
|
6611
|
-
return [tag, { ...HTMLAttributes, class: classes }, 0];
|
|
6612
|
-
}
|
|
6613
|
-
}),
|
|
6614
|
-
import_extension_heading.default.extend({
|
|
6615
|
-
renderHTML({ node, HTMLAttributes }) {
|
|
6616
|
-
if (expectedTag) {
|
|
6617
|
-
return [expectedTag, { ...HTMLAttributes, class: classes }, 0];
|
|
6618
|
-
}
|
|
6619
|
-
const level = this.options.levels.includes(node.attrs.level) ? node.attrs.level : this.options.levels[0];
|
|
6620
|
-
return [`h${level}`, { ...HTMLAttributes, class: classes }, 0];
|
|
6621
|
-
}
|
|
6622
|
-
}).configure({
|
|
6623
|
-
levels: [1, 2, 3, 4, 5, 6]
|
|
6624
|
-
}),
|
|
6625
|
-
import_extension_link.default.configure({
|
|
6626
|
-
openOnClick: false
|
|
6627
|
-
}),
|
|
6628
|
-
import_extension_text.default,
|
|
6629
|
-
import_extension_bold.default,
|
|
6630
|
-
import_extension_italic.default,
|
|
6631
|
-
import_extension_strike.default,
|
|
6632
|
-
import_extension_superscript.default,
|
|
6633
|
-
import_extension_subscript.default,
|
|
6634
|
-
import_extension_underline.default,
|
|
6635
|
-
import_extension_hard_break.default.extend({
|
|
6636
|
-
addKeyboardShortcuts() {
|
|
6637
|
-
return {
|
|
6638
|
-
Enter: () => this.editor.commands.setHardBreak()
|
|
6639
|
-
};
|
|
6640
|
-
}
|
|
6641
|
-
})
|
|
6642
|
-
],
|
|
6643
|
-
content: value,
|
|
6644
|
-
onUpdate,
|
|
6645
|
-
autofocus,
|
|
6646
|
-
editorProps: {
|
|
6647
|
-
attributes: {
|
|
6648
|
-
...attributes,
|
|
6649
|
-
class: attributes.class ?? "",
|
|
6650
|
-
role: "textbox"
|
|
6651
|
-
},
|
|
6652
|
-
handleDOMEvents: toolbarRelatedListeners
|
|
6653
|
-
}
|
|
6654
|
-
});
|
|
6655
|
-
useOnUpdate(() => {
|
|
6656
|
-
if (!editor) {
|
|
6657
|
-
return;
|
|
6658
|
-
}
|
|
6659
|
-
const currentContent = editor.getHTML();
|
|
6660
|
-
if (currentContent !== value) {
|
|
6661
|
-
editor.commands.setContent(value, { emitUpdate: false });
|
|
6662
|
-
}
|
|
6663
|
-
}, [editor, value]);
|
|
6664
|
-
const computePopupPosition = () => {
|
|
6665
|
-
if (!selectionRect) {
|
|
6666
|
-
return { left: 0, top: 0 };
|
|
6667
|
-
}
|
|
6668
|
-
const container = containerRef.current?.getBoundingClientRect();
|
|
6669
|
-
if (!container) {
|
|
6670
|
-
return { left: 0, top: 0 };
|
|
6372
|
+
}
|
|
6373
|
+
onBlur?.();
|
|
6671
6374
|
}
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
}
|
|
6687
|
-
},
|
|
6688
|
-
...(0, import_ui86.bindPopover)(popupState),
|
|
6689
|
-
open: hasSelectedContent && selectionRect !== null,
|
|
6690
|
-
anchorReference: "anchorPosition",
|
|
6691
|
-
anchorPosition: computePopupPosition(),
|
|
6692
|
-
anchorOrigin: { vertical: "top", horizontal: "center" },
|
|
6693
|
-
transformOrigin: { vertical: "bottom", horizontal: "center" }
|
|
6694
|
-
},
|
|
6695
|
-
/* @__PURE__ */ React100.createElement(InlineEditorToolbar, { editor, elementId })
|
|
6696
|
-
));
|
|
6697
|
-
}
|
|
6698
|
-
);
|
|
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
|
+
};
|
|
6699
6389
|
|
|
6700
6390
|
// src/controls/inline-editing-control.tsx
|
|
6701
6391
|
var InlineEditingControl = createControl(
|
|
@@ -6706,8 +6396,8 @@ var InlineEditingControl = createControl(
|
|
|
6706
6396
|
}) => {
|
|
6707
6397
|
const { value, setValue } = useBoundProp(import_editor_props51.htmlPropTypeUtil);
|
|
6708
6398
|
const handleChange = (newValue) => setValue(newValue);
|
|
6709
|
-
return /* @__PURE__ */
|
|
6710
|
-
|
|
6399
|
+
return /* @__PURE__ */ React99.createElement(ControlActions, null, /* @__PURE__ */ React99.createElement(
|
|
6400
|
+
import_ui85.Box,
|
|
6711
6401
|
{
|
|
6712
6402
|
sx: {
|
|
6713
6403
|
p: 0.8,
|
|
@@ -6744,27 +6434,27 @@ var InlineEditingControl = createControl(
|
|
|
6744
6434
|
...attributes,
|
|
6745
6435
|
...props
|
|
6746
6436
|
},
|
|
6747
|
-
/* @__PURE__ */
|
|
6437
|
+
/* @__PURE__ */ React99.createElement(InlineEditor, { value: value || "", setValue: handleChange })
|
|
6748
6438
|
));
|
|
6749
6439
|
}
|
|
6750
6440
|
);
|
|
6751
6441
|
|
|
6752
6442
|
// src/components/icon-buttons/clear-icon-button.tsx
|
|
6753
|
-
var
|
|
6754
|
-
var
|
|
6755
|
-
var
|
|
6756
|
-
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 }) => ({
|
|
6757
6447
|
width: theme.spacing(2.5),
|
|
6758
6448
|
height: theme.spacing(2.5)
|
|
6759
6449
|
}));
|
|
6760
|
-
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 })));
|
|
6761
6451
|
|
|
6762
6452
|
// src/components/repeater/repeater.tsx
|
|
6763
|
-
var
|
|
6764
|
-
var
|
|
6765
|
-
var
|
|
6766
|
-
var
|
|
6767
|
-
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");
|
|
6768
6458
|
var SIZE9 = "tiny";
|
|
6769
6459
|
var EMPTY_OPEN_ITEM2 = -1;
|
|
6770
6460
|
var Repeater3 = ({
|
|
@@ -6782,7 +6472,7 @@ var Repeater3 = ({
|
|
|
6782
6472
|
openItem: initialOpenItem = EMPTY_OPEN_ITEM2,
|
|
6783
6473
|
isSortable = true
|
|
6784
6474
|
}) => {
|
|
6785
|
-
const [openItem, setOpenItem] = (0,
|
|
6475
|
+
const [openItem, setOpenItem] = (0, import_react54.useState)(initialOpenItem);
|
|
6786
6476
|
const uniqueKeys = items2.map(
|
|
6787
6477
|
(item, index) => isSortable && "getId" in itemSettings ? itemSettings.getId({ item, index }) : String(index)
|
|
6788
6478
|
);
|
|
@@ -6845,8 +6535,8 @@ var Repeater3 = ({
|
|
|
6845
6535
|
};
|
|
6846
6536
|
const isButtonDisabled = disabled || disableAddItemButton;
|
|
6847
6537
|
const shouldShowInfotip = isButtonDisabled && addButtonInfotipContent;
|
|
6848
|
-
const addButton = /* @__PURE__ */
|
|
6849
|
-
|
|
6538
|
+
const addButton = /* @__PURE__ */ React101.createElement(
|
|
6539
|
+
import_ui87.IconButton,
|
|
6850
6540
|
{
|
|
6851
6541
|
size: SIZE9,
|
|
6852
6542
|
sx: {
|
|
@@ -6854,32 +6544,32 @@ var Repeater3 = ({
|
|
|
6854
6544
|
},
|
|
6855
6545
|
disabled: isButtonDisabled,
|
|
6856
6546
|
onClick: addRepeaterItem,
|
|
6857
|
-
"aria-label": (0,
|
|
6547
|
+
"aria-label": (0, import_i18n50.__)("Add item", "elementor")
|
|
6858
6548
|
},
|
|
6859
|
-
/* @__PURE__ */
|
|
6549
|
+
/* @__PURE__ */ React101.createElement(import_icons34.PlusIcon, { fontSize: SIZE9 })
|
|
6860
6550
|
);
|
|
6861
|
-
return /* @__PURE__ */
|
|
6862
|
-
|
|
6551
|
+
return /* @__PURE__ */ React101.createElement(SectionContent, { gap: 2 }, /* @__PURE__ */ React101.createElement(RepeaterHeader, { label, adornment: ControlAdornments }, shouldShowInfotip ? /* @__PURE__ */ React101.createElement(
|
|
6552
|
+
import_ui87.Infotip,
|
|
6863
6553
|
{
|
|
6864
6554
|
placement: "right",
|
|
6865
6555
|
content: addButtonInfotipContent,
|
|
6866
6556
|
color: "secondary",
|
|
6867
6557
|
slotProps: { popper: { sx: { width: 300 } } }
|
|
6868
6558
|
},
|
|
6869
|
-
/* @__PURE__ */
|
|
6870
|
-
) : 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) => {
|
|
6871
6561
|
const index = uniqueKeys.indexOf(key);
|
|
6872
6562
|
const value = items2[index];
|
|
6873
6563
|
if (!value) {
|
|
6874
6564
|
return null;
|
|
6875
6565
|
}
|
|
6876
|
-
return /* @__PURE__ */
|
|
6566
|
+
return /* @__PURE__ */ React101.createElement(SortableItem, { id: key, key: `sortable-${key}`, disabled: !isSortable }, /* @__PURE__ */ React101.createElement(
|
|
6877
6567
|
RepeaterItem,
|
|
6878
6568
|
{
|
|
6879
6569
|
disabled,
|
|
6880
6570
|
propDisabled: value?.disabled,
|
|
6881
|
-
label: /* @__PURE__ */
|
|
6882
|
-
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 })),
|
|
6883
6573
|
removeItem: () => removeRepeaterItem(index),
|
|
6884
6574
|
duplicateItem: () => duplicateRepeaterItem(index),
|
|
6885
6575
|
toggleDisableItem: () => toggleDisableRepeaterItem(index),
|
|
@@ -6891,7 +6581,7 @@ var Repeater3 = ({
|
|
|
6891
6581
|
actions: itemSettings.actions,
|
|
6892
6582
|
value
|
|
6893
6583
|
},
|
|
6894
|
-
(props) => /* @__PURE__ */
|
|
6584
|
+
(props) => /* @__PURE__ */ React101.createElement(
|
|
6895
6585
|
itemSettings.Content,
|
|
6896
6586
|
{
|
|
6897
6587
|
...props,
|
|
@@ -6921,27 +6611,27 @@ var RepeaterItem = ({
|
|
|
6921
6611
|
value
|
|
6922
6612
|
}) => {
|
|
6923
6613
|
const { popoverState, popoverProps, ref, setRef } = usePopover(openOnMount, onOpen);
|
|
6924
|
-
const duplicateLabel = (0,
|
|
6925
|
-
const toggleLabel = propDisabled ? (0,
|
|
6926
|
-
const removeLabel = (0,
|
|
6927
|
-
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(
|
|
6928
6618
|
RepeaterTag,
|
|
6929
6619
|
{
|
|
6930
6620
|
disabled,
|
|
6931
6621
|
label,
|
|
6932
6622
|
ref: setRef,
|
|
6933
|
-
"aria-label": (0,
|
|
6934
|
-
...(0,
|
|
6623
|
+
"aria-label": (0, import_i18n50.__)("Open item", "elementor"),
|
|
6624
|
+
...(0, import_ui87.bindTrigger)(popoverState),
|
|
6935
6625
|
startIcon,
|
|
6936
|
-
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 }))))
|
|
6937
6627
|
}
|
|
6938
|
-
), /* @__PURE__ */
|
|
6628
|
+
), /* @__PURE__ */ React101.createElement(RepeaterPopover, { width: ref?.getBoundingClientRect().width, ...popoverProps, anchorEl: ref }, /* @__PURE__ */ React101.createElement(import_ui87.Box, null, children({ anchorEl: ref }))));
|
|
6939
6629
|
};
|
|
6940
6630
|
var usePopover = (openOnMount, onOpen) => {
|
|
6941
|
-
const [ref, setRef] = (0,
|
|
6942
|
-
const popoverState = (0,
|
|
6943
|
-
const popoverProps = (0,
|
|
6944
|
-
(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)(() => {
|
|
6945
6635
|
if (openOnMount && ref) {
|
|
6946
6636
|
popoverState.open(ref);
|
|
6947
6637
|
onOpen?.();
|
|
@@ -6955,6 +6645,270 @@ var usePopover = (openOnMount, onOpen) => {
|
|
|
6955
6645
|
};
|
|
6956
6646
|
};
|
|
6957
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
|
+
|
|
6958
6912
|
// src/components/size/unstable-size-field.tsx
|
|
6959
6913
|
var React106 = __toESM(require("react"));
|
|
6960
6914
|
var import_ui91 = require("@elementor/ui");
|