@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.mjs CHANGED
@@ -6203,19 +6203,17 @@ var DateTimeControl = createControl(({ inputDisabled }) => {
6203
6203
  });
6204
6204
 
6205
6205
  // src/controls/inline-editing-control.tsx
6206
- import * as React101 from "react";
6206
+ import * as React99 from "react";
6207
6207
  import { htmlPropTypeUtil } from "@elementor/editor-props";
6208
- import { Box as Box24 } from "@elementor/ui";
6208
+ import { Box as Box23 } from "@elementor/ui";
6209
6209
 
6210
6210
  // src/components/inline-editor.tsx
6211
- import * as React100 from "react";
6211
+ import * as React98 from "react";
6212
6212
  import {
6213
- forwardRef as forwardRef10,
6214
- useEffect as useEffect13,
6215
- useRef as useRef26,
6216
- useState as useState18
6213
+ useEffect as useEffect11,
6214
+ useRef as useRef24
6217
6215
  } from "react";
6218
- import { bindPopover as bindPopover8, Box as Box23, ClickAwayListener, Popover as Popover8, usePopupState as usePopupState9 } from "@elementor/ui";
6216
+ import { Box as Box22, ClickAwayListener } from "@elementor/ui";
6219
6217
  import Bold from "@tiptap/extension-bold";
6220
6218
  import Document from "@tiptap/extension-document";
6221
6219
  import HardBreak from "@tiptap/extension-hard-break";
@@ -6240,474 +6238,147 @@ function isEmpty(value = "") {
6240
6238
  return !pseudoElement.textContent?.length;
6241
6239
  }
6242
6240
 
6243
- // src/components/inline-editor-toolbar.tsx
6244
- import * as React99 from "react";
6245
- import { useMemo as useMemo15, useRef as useRef25, useState as useState17 } from "react";
6246
- import { getElementSetting } from "@elementor/editor-elements";
6247
- import {
6248
- BoldIcon,
6249
- ItalicIcon,
6250
- LinkIcon as LinkIcon3,
6251
- MinusIcon as MinusIcon2,
6252
- StrikethroughIcon,
6253
- SubscriptIcon,
6254
- SuperscriptIcon,
6255
- UnderlineIcon
6256
- } from "@elementor/icons";
6257
- import {
6258
- Box as Box22,
6259
- IconButton as IconButton8,
6260
- ToggleButton as ToggleButton3,
6261
- ToggleButtonGroup as ToggleButtonGroup2,
6262
- toggleButtonGroupClasses,
6263
- Tooltip as Tooltip10,
6264
- usePopupState as usePopupState8
6265
- } from "@elementor/ui";
6266
- import { useEditorState } from "@tiptap/react";
6267
- import { __ as __51 } from "@wordpress/i18n";
6268
-
6269
- // src/components/url-popover.tsx
6270
- import * as React98 from "react";
6271
- import { useEffect as useEffect11, useRef as useRef24 } from "react";
6272
- import { ExternalLinkIcon } from "@elementor/icons";
6273
- import { bindPopover as bindPopover7, Popover as Popover7, Stack as Stack16, TextField as TextField8, ToggleButton as ToggleButton2, Tooltip as Tooltip9 } from "@elementor/ui";
6274
- import { __ as __50 } from "@wordpress/i18n";
6275
- var UrlPopover = ({
6276
- popupState,
6277
- restoreValue,
6278
- anchorRef,
6279
- value,
6280
- onChange,
6281
- openInNewTab,
6282
- onToggleNewTab
6283
- }) => {
6284
- const inputRef = useRef24(null);
6285
- useEffect11(() => {
6286
- if (popupState.isOpen) {
6287
- requestAnimationFrame(() => inputRef.current?.focus());
6288
- }
6289
- }, [popupState.isOpen]);
6290
- const handleClose = () => {
6291
- restoreValue();
6292
- popupState.close();
6241
+ // src/components/inline-editor.tsx
6242
+ var ITALIC_KEYBOARD_SHORTCUT = "i";
6243
+ var BOLD_KEYBOARD_SHORTCUT = "b";
6244
+ var UNDERLINE_KEYBOARD_SHORTCUT = "u";
6245
+ var InlineEditor = React98.forwardRef((props, ref) => {
6246
+ const {
6247
+ value,
6248
+ setValue,
6249
+ editorProps = {},
6250
+ elementClasses = "",
6251
+ autofocus = false,
6252
+ sx = {},
6253
+ onBlur = void 0,
6254
+ expectedTag = null,
6255
+ onEditorCreate,
6256
+ wrapperClassName,
6257
+ onSelectionEnd
6258
+ } = props;
6259
+ const containerRef = useRef24(null);
6260
+ const documentContentSettings = !!expectedTag ? "block+" : "inline*";
6261
+ const onUpdate = ({ editor: updatedEditor }) => {
6262
+ const newValue = updatedEditor.getHTML();
6263
+ setValue(isEmpty(newValue) ? null : newValue);
6293
6264
  };
6294
- return /* @__PURE__ */ React98.createElement(
6295
- Popover7,
6296
- {
6297
- slotProps: {
6298
- paper: { sx: { borderRadius: "16px", width: anchorRef.current?.offsetWidth + "px", marginTop: -1 } }
6299
- },
6300
- ...bindPopover7(popupState),
6301
- anchorOrigin: { vertical: "top", horizontal: "left" },
6302
- transformOrigin: { vertical: "top", horizontal: "left" },
6303
- onClose: handleClose
6304
- },
6305
- /* @__PURE__ */ React98.createElement(Stack16, { direction: "row", alignItems: "center", gap: 1, sx: { p: 1.5 } }, /* @__PURE__ */ React98.createElement(
6306
- TextField8,
6307
- {
6308
- value,
6309
- onChange,
6310
- size: "tiny",
6311
- fullWidth: true,
6312
- placeholder: __50("Type a URL", "elementor"),
6313
- inputProps: { ref: inputRef },
6314
- color: "secondary",
6315
- InputProps: { sx: { borderRadius: "8px" } },
6316
- onKeyUp: (event) => event.key === "Enter" && handleClose()
6317
- }
6318
- ), /* @__PURE__ */ React98.createElement(Tooltip9, { title: __50("Open in a new tab", "elementor") }, /* @__PURE__ */ React98.createElement(
6319
- ToggleButton2,
6320
- {
6321
- size: "tiny",
6322
- value: "newTab",
6323
- selected: openInNewTab,
6324
- onClick: onToggleNewTab,
6325
- "aria-label": __50("Open in a new tab", "elementor"),
6326
- sx: { borderRadius: "8px" }
6327
- },
6328
- /* @__PURE__ */ React98.createElement(ExternalLinkIcon, { fontSize: "tiny" })
6329
- )))
6330
- );
6331
- };
6332
-
6333
- // src/components/inline-editor-toolbar.tsx
6334
- var checkIfElementHasLink = (elementId) => !!getElementSetting(elementId, "link")?.value?.destination;
6335
- var toolbarButtons = {
6336
- clear: {
6337
- label: __51("Clear", "elementor"),
6338
- icon: /* @__PURE__ */ React99.createElement(MinusIcon2, { fontSize: "tiny" }),
6339
- action: "clear",
6340
- method: (editor) => {
6341
- editor.chain().focus().clearNodes().unsetAllMarks().run();
6342
- }
6343
- },
6344
- bold: {
6345
- label: __51("Bold", "elementor"),
6346
- icon: /* @__PURE__ */ React99.createElement(BoldIcon, { fontSize: "tiny" }),
6347
- action: "bold",
6348
- method: (editor) => {
6349
- editor.chain().focus().toggleBold().run();
6350
- }
6351
- },
6352
- italic: {
6353
- label: __51("Italic", "elementor"),
6354
- icon: /* @__PURE__ */ React99.createElement(ItalicIcon, { fontSize: "tiny" }),
6355
- action: "italic",
6356
- method: (editor) => {
6357
- editor.chain().focus().toggleItalic().run();
6358
- }
6359
- },
6360
- underline: {
6361
- label: __51("Underline", "elementor"),
6362
- icon: /* @__PURE__ */ React99.createElement(UnderlineIcon, { fontSize: "tiny" }),
6363
- action: "underline",
6364
- method: (editor) => {
6365
- editor.chain().focus().toggleUnderline().run();
6366
- }
6367
- },
6368
- strike: {
6369
- label: __51("Strikethrough", "elementor"),
6370
- icon: /* @__PURE__ */ React99.createElement(StrikethroughIcon, { fontSize: "tiny" }),
6371
- action: "strike",
6372
- method: (editor) => {
6373
- editor.chain().focus().toggleStrike().run();
6265
+ const onKeyDown = (_, event) => {
6266
+ if (event.key === "Escape") {
6267
+ onBlur?.();
6374
6268
  }
6375
- },
6376
- superscript: {
6377
- label: __51("Superscript", "elementor"),
6378
- icon: /* @__PURE__ */ React99.createElement(SuperscriptIcon, { fontSize: "tiny" }),
6379
- action: "superscript",
6380
- method: (editor) => {
6381
- editor.chain().focus().toggleSuperscript().run();
6382
- }
6383
- },
6384
- subscript: {
6385
- label: __51("Subscript", "elementor"),
6386
- icon: /* @__PURE__ */ React99.createElement(SubscriptIcon, { fontSize: "tiny" }),
6387
- action: "subscript",
6388
- method: (editor) => {
6389
- editor.chain().focus().toggleSubscript().run();
6390
- }
6391
- },
6392
- link: {
6393
- label: __51("Link", "elementor"),
6394
- icon: /* @__PURE__ */ React99.createElement(LinkIcon3, { fontSize: "tiny" }),
6395
- action: "link",
6396
- method: null
6397
- }
6398
- };
6399
- var { clear: clearButton, ...formatButtons } = toolbarButtons;
6400
- var possibleFormats = Object.keys(formatButtons);
6401
- var InlineEditorToolbar = ({ editor, elementId }) => {
6402
- const [urlValue, setUrlValue] = useState17("");
6403
- const [openInNewTab, setOpenInNewTab] = useState17(false);
6404
- const toolbarRef = useRef25(null);
6405
- const linkPopupState = usePopupState8({ variant: "popover" });
6406
- const hasLinkOnElement = elementId ? checkIfElementHasLink(elementId) : false;
6407
- const editorState = useEditorState({
6408
- editor,
6409
- selector: (ctx) => possibleFormats.filter((format) => ctx.editor.isActive(format))
6410
- });
6411
- const formatButtonsList = useMemo15(() => {
6412
- const buttons = Object.values(formatButtons);
6413
- if (hasLinkOnElement) {
6414
- return buttons.filter((button) => button.action !== "link");
6415
- }
6416
- return buttons;
6417
- }, [hasLinkOnElement]);
6418
- const handleLinkClick = () => {
6419
- const linkAttrs = editor.getAttributes("link");
6420
- setUrlValue(linkAttrs.href || "");
6421
- setOpenInNewTab(linkAttrs.target === "_blank");
6422
- linkPopupState.open(toolbarRef.current);
6423
- };
6424
- const handleUrlChange = (event) => {
6425
- setUrlValue(event.target.value);
6426
- };
6427
- const handleToggleNewTab = () => {
6428
- setOpenInNewTab(!openInNewTab);
6429
- };
6430
- const handleUrlSubmit = () => {
6431
- if (urlValue) {
6432
- editor.chain().focus().setLink({
6433
- href: urlValue,
6434
- target: openInNewTab ? "_blank" : "_self"
6435
- }).run();
6436
- } else {
6437
- editor.chain().focus().unsetLink().run();
6269
+ if (!event.metaKey && !event.ctrlKey || event.altKey) {
6270
+ return;
6438
6271
  }
6439
- if (elementId) {
6440
- window.dispatchEvent(
6441
- new CustomEvent("elementor:inline-link-changed", {
6442
- detail: { elementId }
6443
- })
6444
- );
6272
+ if ([ITALIC_KEYBOARD_SHORTCUT, BOLD_KEYBOARD_SHORTCUT, UNDERLINE_KEYBOARD_SHORTCUT].includes(event.key)) {
6273
+ event.stopPropagation();
6445
6274
  }
6446
- linkPopupState.close();
6447
6275
  };
6448
- React99.useEffect(() => {
6449
- editor?.commands?.focus();
6450
- }, [editor]);
6451
- return /* @__PURE__ */ React99.createElement(
6452
- Box22,
6453
- {
6454
- ref: toolbarRef,
6455
- sx: {
6456
- display: "inline-flex",
6457
- gap: 0.5,
6458
- padding: 0.5,
6459
- borderRadius: "8px",
6460
- backgroundColor: "background.paper",
6461
- boxShadow: "0 2px 8px rgba(0, 0, 0, 0.2)",
6462
- alignItems: "center",
6463
- visibility: linkPopupState.isOpen ? "hidden" : "visible",
6464
- pointerEvents: linkPopupState.isOpen ? "none" : "all"
6465
- }
6466
- },
6467
- /* @__PURE__ */ React99.createElement(Tooltip10, { title: clearButton.label, placement: "top", sx: { borderRadius: "8px" } }, /* @__PURE__ */ React99.createElement(IconButton8, { "aria-label": clearButton.label, onClick: () => clearButton.method(editor), size: "tiny" }, clearButton.icon)),
6468
- /* @__PURE__ */ React99.createElement(
6469
- ToggleButtonGroup2,
6470
- {
6471
- value: editorState,
6472
- size: "tiny",
6473
- sx: {
6474
- display: "flex",
6475
- gap: 0.5,
6476
- border: "none",
6477
- [`& .${toggleButtonGroupClasses.firstButton}, & .${toggleButtonGroupClasses.middleButton}, & .${toggleButtonGroupClasses.lastButton}`]: {
6478
- borderRadius: "8px",
6479
- border: "none",
6480
- marginLeft: 0,
6481
- "&.Mui-selected": {
6482
- marginLeft: 0
6483
- },
6484
- "& + &.Mui-selected": {
6485
- marginLeft: 0
6486
- }
6276
+ const editedElementAttributes = (HTMLAttributes) => ({
6277
+ ...HTMLAttributes,
6278
+ class: elementClasses
6279
+ });
6280
+ const editor = useEditor({
6281
+ extensions: [
6282
+ Document.extend({
6283
+ content: documentContentSettings
6284
+ }),
6285
+ Paragraph.extend({
6286
+ renderHTML({ HTMLAttributes }) {
6287
+ const tag = expectedTag ?? "p";
6288
+ return [tag, editedElementAttributes(HTMLAttributes), 0];
6289
+ }
6290
+ }),
6291
+ Heading.extend({
6292
+ renderHTML({ node, HTMLAttributes }) {
6293
+ if (expectedTag) {
6294
+ return [expectedTag, editedElementAttributes(HTMLAttributes), 0];
6487
6295
  }
6296
+ const level = this.options.levels.includes(node.attrs.level) ? node.attrs.level : this.options.levels[0];
6297
+ return [`h${level}`, editedElementAttributes(HTMLAttributes), 0];
6298
+ }
6299
+ }).configure({
6300
+ levels: [1, 2, 3, 4, 5, 6]
6301
+ }),
6302
+ Link3.configure({
6303
+ openOnClick: false
6304
+ }),
6305
+ Text,
6306
+ Bold,
6307
+ Italic,
6308
+ Strike,
6309
+ Superscript,
6310
+ Subscript,
6311
+ Underline,
6312
+ HardBreak.extend({
6313
+ addKeyboardShortcuts() {
6314
+ return {
6315
+ Enter: () => this.editor.commands.setHardBreak()
6316
+ };
6488
6317
  }
6318
+ })
6319
+ ],
6320
+ content: value,
6321
+ onUpdate,
6322
+ autofocus,
6323
+ editorProps: {
6324
+ ...editorProps,
6325
+ handleDOMEvents: {
6326
+ keydown: onKeyDown
6489
6327
  },
6490
- formatButtonsList.map((button) => /* @__PURE__ */ React99.createElement(Tooltip10, { title: button.label, key: button.action, placement: "top" }, /* @__PURE__ */ React99.createElement(
6491
- ToggleButton3,
6492
- {
6493
- value: button.action,
6494
- "aria-label": button.label,
6495
- size: "tiny",
6496
- onClick: () => {
6497
- if (button.action === "link") {
6498
- handleLinkClick();
6499
- } else {
6500
- button.method?.(editor);
6501
- }
6502
- editor?.commands?.focus();
6503
- }
6504
- },
6505
- button.icon
6506
- )))
6507
- ),
6508
- /* @__PURE__ */ React99.createElement(
6509
- UrlPopover,
6510
- {
6511
- popupState: linkPopupState,
6512
- anchorRef: toolbarRef,
6513
- restoreValue: handleUrlSubmit,
6514
- value: urlValue,
6515
- onChange: handleUrlChange,
6516
- openInNewTab,
6517
- onToggleNewTab: handleToggleNewTab
6328
+ attributes: {
6329
+ ...editorProps.attributes ?? {},
6330
+ role: "textbox"
6518
6331
  }
6519
- )
6520
- );
6521
- };
6522
-
6523
- // src/components/inline-editor.tsx
6524
- var ITALIC_KEYBOARD_SHORTCUT = "i";
6525
- var BOLD_KEYBOARD_SHORTCUT = "b";
6526
- var UNDERLINE_KEYBOARD_SHORTCUT = "u";
6527
- var INLINE_EDITOR_RESET_CLASS = "elementor-inline-editor-reset";
6528
- var useOnUpdate = (callback, dependencies) => {
6529
- const hasMounted = useRef26(false);
6530
- useEffect13(() => {
6531
- if (hasMounted.current) {
6532
- callback();
6533
- } else {
6534
- hasMounted.current = true;
6332
+ },
6333
+ onCreate: onEditorCreate ? ({ editor: mountedEditor }) => onEditorCreate(mountedEditor) : void 0,
6334
+ onSelectionUpdate: onSelectionEnd ? ({ editor: updatedEditor }) => onSelectionEnd(updatedEditor.view) : void 0
6335
+ });
6336
+ useOnUpdate(() => {
6337
+ if (!editor) {
6338
+ return;
6535
6339
  }
6536
- }, dependencies);
6537
- };
6538
- var calcSelectionCenter = (view, container) => {
6539
- if (!container) {
6540
- return null;
6541
- }
6542
- const { from, to } = view.state.selection;
6543
- const start = view.coordsAtPos(from);
6544
- const end = view.coordsAtPos(to);
6545
- const left = (start.left + end.left) / 2 - container.left;
6546
- const top = Math.min(start.top, end.top) - container.top;
6547
- return { left, top };
6548
- };
6549
- var Wrapper = ({ children, containerRef, editor, sx, onBlur }) => {
6550
- const wrappedChildren = /* @__PURE__ */ React100.createElement(Box23, { ref: containerRef, ...sx }, children);
6551
- return onBlur ? /* @__PURE__ */ React100.createElement(
6340
+ const currentContent = editor.getHTML();
6341
+ if (currentContent !== value) {
6342
+ editor.commands.setContent(value, { emitUpdate: false });
6343
+ }
6344
+ }, [editor, value]);
6345
+ return /* @__PURE__ */ React98.createElement(React98.Fragment, null, /* @__PURE__ */ React98.createElement(
6346
+ Wrapper,
6347
+ {
6348
+ containerRef,
6349
+ editor,
6350
+ sx,
6351
+ onBlur,
6352
+ className: wrapperClassName
6353
+ },
6354
+ /* @__PURE__ */ React98.createElement(EditorContent, { ref, editor })
6355
+ ));
6356
+ });
6357
+ var Wrapper = ({ children, containerRef, editor, sx, onBlur, className }) => {
6358
+ const wrappedChildren = /* @__PURE__ */ React98.createElement(Box22, { ref: containerRef, ...sx, className }, children);
6359
+ return onBlur ? /* @__PURE__ */ React98.createElement(
6552
6360
  ClickAwayListener,
6553
6361
  {
6554
6362
  onClickAway: (event) => {
6555
6363
  if (containerRef.current?.contains(event.target) || editor.view.dom.contains(event.target)) {
6556
6364
  return;
6557
6365
  }
6558
- onBlur?.(event);
6366
+ onBlur?.();
6559
6367
  }
6560
6368
  },
6561
6369
  wrappedChildren
6562
- ) : /* @__PURE__ */ React100.createElement(React100.Fragment, null, wrappedChildren);
6370
+ ) : /* @__PURE__ */ React98.createElement(React98.Fragment, null, wrappedChildren);
6371
+ };
6372
+ var useOnUpdate = (callback, dependencies) => {
6373
+ const hasMounted = useRef24(false);
6374
+ useEffect11(() => {
6375
+ if (hasMounted.current) {
6376
+ callback();
6377
+ } else {
6378
+ hasMounted.current = true;
6379
+ }
6380
+ }, dependencies);
6563
6381
  };
6564
- var InlineEditor = forwardRef10(
6565
- ({
6566
- value,
6567
- setValue,
6568
- attributes = {},
6569
- elementClasses = "",
6570
- showToolbar = false,
6571
- autofocus = false,
6572
- sx = {},
6573
- onBlur = void 0,
6574
- getInitialPopoverPosition = void 0,
6575
- expectedTag = null,
6576
- elementId = void 0
6577
- }, ref) => {
6578
- const containerRef = useRef26(null);
6579
- const popupState = usePopupState9({ variant: "popover", disableAutoFocus: true });
6580
- const [hasSelectedContent, setHasSelectedContent] = useState18(false);
6581
- const documentContentSettings = !!expectedTag ? "block+" : "inline*";
6582
- const [selectionRect, setSelectionRect] = useState18(null);
6583
- const onSelectionEnd = (view) => {
6584
- const hasSelection = !view.state.selection.empty;
6585
- setHasSelectedContent(hasSelection);
6586
- if (hasSelection) {
6587
- const container = containerRef.current?.getBoundingClientRect();
6588
- setSelectionRect(calcSelectionCenter(view, container));
6589
- } else {
6590
- setSelectionRect(null);
6591
- }
6592
- queueMicrotask(() => view.focus());
6593
- };
6594
- const onKeyDown = (_, event) => {
6595
- if (event.key === "Escape") {
6596
- onBlur?.(event);
6597
- }
6598
- if (!event.metaKey && !event.ctrlKey || event.altKey) {
6599
- return;
6600
- }
6601
- if ([ITALIC_KEYBOARD_SHORTCUT, BOLD_KEYBOARD_SHORTCUT, UNDERLINE_KEYBOARD_SHORTCUT].includes(event.key)) {
6602
- event.stopPropagation();
6603
- }
6604
- };
6605
- const toolbarRelatedListeners = showToolbar ? {
6606
- mouseup: onSelectionEnd,
6607
- keyup: onSelectionEnd,
6608
- keydown: onKeyDown
6609
- } : void 0;
6610
- const onUpdate = ({ editor: updatedEditor }) => {
6611
- const newValue = updatedEditor.getHTML();
6612
- setValue(isEmpty(newValue) ? null : newValue);
6613
- };
6614
- const classes = `${INLINE_EDITOR_RESET_CLASS} ${elementClasses}`;
6615
- const editor = useEditor({
6616
- extensions: [
6617
- Document.extend({
6618
- content: documentContentSettings
6619
- }),
6620
- Paragraph.extend({
6621
- renderHTML({ HTMLAttributes }) {
6622
- const tag = expectedTag ?? "p";
6623
- return [tag, { ...HTMLAttributes, class: classes }, 0];
6624
- }
6625
- }),
6626
- Heading.extend({
6627
- renderHTML({ node, HTMLAttributes }) {
6628
- if (expectedTag) {
6629
- return [expectedTag, { ...HTMLAttributes, class: classes }, 0];
6630
- }
6631
- const level = this.options.levels.includes(node.attrs.level) ? node.attrs.level : this.options.levels[0];
6632
- return [`h${level}`, { ...HTMLAttributes, class: classes }, 0];
6633
- }
6634
- }).configure({
6635
- levels: [1, 2, 3, 4, 5, 6]
6636
- }),
6637
- Link3.configure({
6638
- openOnClick: false
6639
- }),
6640
- Text,
6641
- Bold,
6642
- Italic,
6643
- Strike,
6644
- Superscript,
6645
- Subscript,
6646
- Underline,
6647
- HardBreak.extend({
6648
- addKeyboardShortcuts() {
6649
- return {
6650
- Enter: () => this.editor.commands.setHardBreak()
6651
- };
6652
- }
6653
- })
6654
- ],
6655
- content: value,
6656
- onUpdate,
6657
- autofocus,
6658
- editorProps: {
6659
- attributes: {
6660
- ...attributes,
6661
- class: attributes.class ?? "",
6662
- role: "textbox"
6663
- },
6664
- handleDOMEvents: toolbarRelatedListeners
6665
- }
6666
- });
6667
- useOnUpdate(() => {
6668
- if (!editor) {
6669
- return;
6670
- }
6671
- const currentContent = editor.getHTML();
6672
- if (currentContent !== value) {
6673
- editor.commands.setContent(value, { emitUpdate: false });
6674
- }
6675
- }, [editor, value]);
6676
- const computePopupPosition = () => {
6677
- if (!selectionRect) {
6678
- return { left: 0, top: 0 };
6679
- }
6680
- const container = containerRef.current?.getBoundingClientRect();
6681
- if (!container) {
6682
- return { left: 0, top: 0 };
6683
- }
6684
- const initial = getInitialPopoverPosition?.() ?? { left: 0, top: 0 };
6685
- return {
6686
- left: container.left + selectionRect.left + initial.left,
6687
- top: container.top + selectionRect.top + initial.top
6688
- };
6689
- };
6690
- return /* @__PURE__ */ React100.createElement(React100.Fragment, null, /* @__PURE__ */ React100.createElement(Wrapper, { containerRef, editor, sx, onBlur }, /* @__PURE__ */ React100.createElement(EditorContent, { ref, editor })), showToolbar && containerRef.current && /* @__PURE__ */ React100.createElement(
6691
- Popover8,
6692
- {
6693
- slotProps: {
6694
- root: {
6695
- sx: {
6696
- pointerEvents: "none"
6697
- }
6698
- }
6699
- },
6700
- ...bindPopover8(popupState),
6701
- open: hasSelectedContent && selectionRect !== null,
6702
- anchorReference: "anchorPosition",
6703
- anchorPosition: computePopupPosition(),
6704
- anchorOrigin: { vertical: "top", horizontal: "center" },
6705
- transformOrigin: { vertical: "bottom", horizontal: "center" }
6706
- },
6707
- /* @__PURE__ */ React100.createElement(InlineEditorToolbar, { editor, elementId })
6708
- ));
6709
- }
6710
- );
6711
6382
 
6712
6383
  // src/controls/inline-editing-control.tsx
6713
6384
  var InlineEditingControl = createControl(
@@ -6718,8 +6389,8 @@ var InlineEditingControl = createControl(
6718
6389
  }) => {
6719
6390
  const { value, setValue } = useBoundProp(htmlPropTypeUtil);
6720
6391
  const handleChange = (newValue) => setValue(newValue);
6721
- return /* @__PURE__ */ React101.createElement(ControlActions, null, /* @__PURE__ */ React101.createElement(
6722
- Box24,
6392
+ return /* @__PURE__ */ React99.createElement(ControlActions, null, /* @__PURE__ */ React99.createElement(
6393
+ Box23,
6723
6394
  {
6724
6395
  sx: {
6725
6396
  p: 0.8,
@@ -6756,35 +6427,35 @@ var InlineEditingControl = createControl(
6756
6427
  ...attributes,
6757
6428
  ...props
6758
6429
  },
6759
- /* @__PURE__ */ React101.createElement(InlineEditor, { value: value || "", setValue: handleChange })
6430
+ /* @__PURE__ */ React99.createElement(InlineEditor, { value: value || "", setValue: handleChange })
6760
6431
  ));
6761
6432
  }
6762
6433
  );
6763
6434
 
6764
6435
  // src/components/icon-buttons/clear-icon-button.tsx
6765
- import * as React102 from "react";
6436
+ import * as React100 from "react";
6766
6437
  import { BrushBigIcon } from "@elementor/icons";
6767
- import { IconButton as IconButton9, styled as styled9, Tooltip as Tooltip11 } from "@elementor/ui";
6768
- var CustomIconButton = styled9(IconButton9)(({ theme }) => ({
6438
+ import { IconButton as IconButton8, styled as styled9, Tooltip as Tooltip9 } from "@elementor/ui";
6439
+ var CustomIconButton = styled9(IconButton8)(({ theme }) => ({
6769
6440
  width: theme.spacing(2.5),
6770
6441
  height: theme.spacing(2.5)
6771
6442
  }));
6772
- var ClearIconButton = ({ tooltipText, onClick, disabled, size = "tiny" }) => /* @__PURE__ */ React102.createElement(Tooltip11, { title: tooltipText, placement: "top", disableInteractive: true }, /* @__PURE__ */ React102.createElement(CustomIconButton, { "aria-label": tooltipText, size, onClick, disabled }, /* @__PURE__ */ React102.createElement(BrushBigIcon, { fontSize: size })));
6443
+ var ClearIconButton = ({ tooltipText, onClick, disabled, size = "tiny" }) => /* @__PURE__ */ React100.createElement(Tooltip9, { title: tooltipText, placement: "top", disableInteractive: true }, /* @__PURE__ */ React100.createElement(CustomIconButton, { "aria-label": tooltipText, size, onClick, disabled }, /* @__PURE__ */ React100.createElement(BrushBigIcon, { fontSize: size })));
6773
6444
 
6774
6445
  // src/components/repeater/repeater.tsx
6775
- import * as React103 from "react";
6776
- import { useEffect as useEffect14, useState as useState19 } from "react";
6446
+ import * as React101 from "react";
6447
+ import { useEffect as useEffect12, useState as useState17 } from "react";
6777
6448
  import { CopyIcon as CopyIcon2, EyeIcon as EyeIcon2, EyeOffIcon as EyeOffIcon2, PlusIcon as PlusIcon3, XIcon as XIcon4 } from "@elementor/icons";
6778
6449
  import {
6779
- bindPopover as bindPopover9,
6450
+ bindPopover as bindPopover7,
6780
6451
  bindTrigger as bindTrigger6,
6781
- Box as Box25,
6782
- IconButton as IconButton10,
6452
+ Box as Box24,
6453
+ IconButton as IconButton9,
6783
6454
  Infotip as Infotip4,
6784
- Tooltip as Tooltip12,
6785
- usePopupState as usePopupState10
6455
+ Tooltip as Tooltip10,
6456
+ usePopupState as usePopupState8
6786
6457
  } from "@elementor/ui";
6787
- import { __ as __52 } from "@wordpress/i18n";
6458
+ import { __ as __50 } from "@wordpress/i18n";
6788
6459
  var SIZE9 = "tiny";
6789
6460
  var EMPTY_OPEN_ITEM2 = -1;
6790
6461
  var Repeater3 = ({
@@ -6802,7 +6473,7 @@ var Repeater3 = ({
6802
6473
  openItem: initialOpenItem = EMPTY_OPEN_ITEM2,
6803
6474
  isSortable = true
6804
6475
  }) => {
6805
- const [openItem, setOpenItem] = useState19(initialOpenItem);
6476
+ const [openItem, setOpenItem] = useState17(initialOpenItem);
6806
6477
  const uniqueKeys = items2.map(
6807
6478
  (item, index) => isSortable && "getId" in itemSettings ? itemSettings.getId({ item, index }) : String(index)
6808
6479
  );
@@ -6865,8 +6536,8 @@ var Repeater3 = ({
6865
6536
  };
6866
6537
  const isButtonDisabled = disabled || disableAddItemButton;
6867
6538
  const shouldShowInfotip = isButtonDisabled && addButtonInfotipContent;
6868
- const addButton = /* @__PURE__ */ React103.createElement(
6869
- IconButton10,
6539
+ const addButton = /* @__PURE__ */ React101.createElement(
6540
+ IconButton9,
6870
6541
  {
6871
6542
  size: SIZE9,
6872
6543
  sx: {
@@ -6874,11 +6545,11 @@ var Repeater3 = ({
6874
6545
  },
6875
6546
  disabled: isButtonDisabled,
6876
6547
  onClick: addRepeaterItem,
6877
- "aria-label": __52("Add item", "elementor")
6548
+ "aria-label": __50("Add item", "elementor")
6878
6549
  },
6879
- /* @__PURE__ */ React103.createElement(PlusIcon3, { fontSize: SIZE9 })
6550
+ /* @__PURE__ */ React101.createElement(PlusIcon3, { fontSize: SIZE9 })
6880
6551
  );
6881
- return /* @__PURE__ */ React103.createElement(SectionContent, { gap: 2 }, /* @__PURE__ */ React103.createElement(RepeaterHeader, { label, adornment: ControlAdornments }, shouldShowInfotip ? /* @__PURE__ */ React103.createElement(
6552
+ return /* @__PURE__ */ React101.createElement(SectionContent, { gap: 2 }, /* @__PURE__ */ React101.createElement(RepeaterHeader, { label, adornment: ControlAdornments }, shouldShowInfotip ? /* @__PURE__ */ React101.createElement(
6882
6553
  Infotip4,
6883
6554
  {
6884
6555
  placement: "right",
@@ -6886,20 +6557,20 @@ var Repeater3 = ({
6886
6557
  color: "secondary",
6887
6558
  slotProps: { popper: { sx: { width: 300 } } }
6888
6559
  },
6889
- /* @__PURE__ */ React103.createElement(Box25, { sx: { ...isButtonDisabled ? { cursor: "not-allowed" } : {} } }, addButton)
6890
- ) : addButton), 0 < uniqueKeys.length && /* @__PURE__ */ React103.createElement(SortableProvider, { value: uniqueKeys, onChange: onChangeOrder }, uniqueKeys.map((key) => {
6560
+ /* @__PURE__ */ React101.createElement(Box24, { sx: { ...isButtonDisabled ? { cursor: "not-allowed" } : {} } }, addButton)
6561
+ ) : addButton), 0 < uniqueKeys.length && /* @__PURE__ */ React101.createElement(SortableProvider, { value: uniqueKeys, onChange: onChangeOrder }, uniqueKeys.map((key) => {
6891
6562
  const index = uniqueKeys.indexOf(key);
6892
6563
  const value = items2[index];
6893
6564
  if (!value) {
6894
6565
  return null;
6895
6566
  }
6896
- return /* @__PURE__ */ React103.createElement(SortableItem, { id: key, key: `sortable-${key}`, disabled: !isSortable }, /* @__PURE__ */ React103.createElement(
6567
+ return /* @__PURE__ */ React101.createElement(SortableItem, { id: key, key: `sortable-${key}`, disabled: !isSortable }, /* @__PURE__ */ React101.createElement(
6897
6568
  RepeaterItem,
6898
6569
  {
6899
6570
  disabled,
6900
6571
  propDisabled: value?.disabled,
6901
- label: /* @__PURE__ */ React103.createElement(RepeaterItemLabelSlot, { value }, /* @__PURE__ */ React103.createElement(itemSettings.Label, { value, index })),
6902
- startIcon: /* @__PURE__ */ React103.createElement(RepeaterItemIconSlot, { value }, /* @__PURE__ */ React103.createElement(itemSettings.Icon, { value })),
6572
+ label: /* @__PURE__ */ React101.createElement(RepeaterItemLabelSlot, { value }, /* @__PURE__ */ React101.createElement(itemSettings.Label, { value, index })),
6573
+ startIcon: /* @__PURE__ */ React101.createElement(RepeaterItemIconSlot, { value }, /* @__PURE__ */ React101.createElement(itemSettings.Icon, { value })),
6903
6574
  removeItem: () => removeRepeaterItem(index),
6904
6575
  duplicateItem: () => duplicateRepeaterItem(index),
6905
6576
  toggleDisableItem: () => toggleDisableRepeaterItem(index),
@@ -6911,7 +6582,7 @@ var Repeater3 = ({
6911
6582
  actions: itemSettings.actions,
6912
6583
  value
6913
6584
  },
6914
- (props) => /* @__PURE__ */ React103.createElement(
6585
+ (props) => /* @__PURE__ */ React101.createElement(
6915
6586
  itemSettings.Content,
6916
6587
  {
6917
6588
  ...props,
@@ -6941,27 +6612,27 @@ var RepeaterItem = ({
6941
6612
  value
6942
6613
  }) => {
6943
6614
  const { popoverState, popoverProps, ref, setRef } = usePopover(openOnMount, onOpen);
6944
- const duplicateLabel = __52("Duplicate", "elementor");
6945
- const toggleLabel = propDisabled ? __52("Show", "elementor") : __52("Hide", "elementor");
6946
- const removeLabel = __52("Remove", "elementor");
6947
- return /* @__PURE__ */ React103.createElement(React103.Fragment, null, /* @__PURE__ */ React103.createElement(
6615
+ const duplicateLabel = __50("Duplicate", "elementor");
6616
+ const toggleLabel = propDisabled ? __50("Show", "elementor") : __50("Hide", "elementor");
6617
+ const removeLabel = __50("Remove", "elementor");
6618
+ return /* @__PURE__ */ React101.createElement(React101.Fragment, null, /* @__PURE__ */ React101.createElement(
6948
6619
  RepeaterTag,
6949
6620
  {
6950
6621
  disabled,
6951
6622
  label,
6952
6623
  ref: setRef,
6953
- "aria-label": __52("Open item", "elementor"),
6624
+ "aria-label": __50("Open item", "elementor"),
6954
6625
  ...bindTrigger6(popoverState),
6955
6626
  startIcon,
6956
- actions: /* @__PURE__ */ React103.createElement(React103.Fragment, null, showDuplicate && /* @__PURE__ */ React103.createElement(Tooltip12, { title: duplicateLabel, placement: "top" }, /* @__PURE__ */ React103.createElement(IconButton10, { size: SIZE9, onClick: duplicateItem, "aria-label": duplicateLabel }, /* @__PURE__ */ React103.createElement(CopyIcon2, { fontSize: SIZE9 }))), showToggle && /* @__PURE__ */ React103.createElement(Tooltip12, { title: toggleLabel, placement: "top" }, /* @__PURE__ */ React103.createElement(IconButton10, { size: SIZE9, onClick: toggleDisableItem, "aria-label": toggleLabel }, propDisabled ? /* @__PURE__ */ React103.createElement(EyeOffIcon2, { fontSize: SIZE9 }) : /* @__PURE__ */ React103.createElement(EyeIcon2, { fontSize: SIZE9 }))), actions?.(value), showRemove && /* @__PURE__ */ React103.createElement(Tooltip12, { title: removeLabel, placement: "top" }, /* @__PURE__ */ React103.createElement(IconButton10, { size: SIZE9, onClick: removeItem, "aria-label": removeLabel }, /* @__PURE__ */ React103.createElement(XIcon4, { fontSize: SIZE9 }))))
6627
+ actions: /* @__PURE__ */ React101.createElement(React101.Fragment, null, showDuplicate && /* @__PURE__ */ React101.createElement(Tooltip10, { title: duplicateLabel, placement: "top" }, /* @__PURE__ */ React101.createElement(IconButton9, { size: SIZE9, onClick: duplicateItem, "aria-label": duplicateLabel }, /* @__PURE__ */ React101.createElement(CopyIcon2, { fontSize: SIZE9 }))), showToggle && /* @__PURE__ */ React101.createElement(Tooltip10, { title: toggleLabel, placement: "top" }, /* @__PURE__ */ React101.createElement(IconButton9, { size: SIZE9, onClick: toggleDisableItem, "aria-label": toggleLabel }, propDisabled ? /* @__PURE__ */ React101.createElement(EyeOffIcon2, { fontSize: SIZE9 }) : /* @__PURE__ */ React101.createElement(EyeIcon2, { fontSize: SIZE9 }))), actions?.(value), showRemove && /* @__PURE__ */ React101.createElement(Tooltip10, { title: removeLabel, placement: "top" }, /* @__PURE__ */ React101.createElement(IconButton9, { size: SIZE9, onClick: removeItem, "aria-label": removeLabel }, /* @__PURE__ */ React101.createElement(XIcon4, { fontSize: SIZE9 }))))
6957
6628
  }
6958
- ), /* @__PURE__ */ React103.createElement(RepeaterPopover, { width: ref?.getBoundingClientRect().width, ...popoverProps, anchorEl: ref }, /* @__PURE__ */ React103.createElement(Box25, null, children({ anchorEl: ref }))));
6629
+ ), /* @__PURE__ */ React101.createElement(RepeaterPopover, { width: ref?.getBoundingClientRect().width, ...popoverProps, anchorEl: ref }, /* @__PURE__ */ React101.createElement(Box24, null, children({ anchorEl: ref }))));
6959
6630
  };
6960
6631
  var usePopover = (openOnMount, onOpen) => {
6961
- const [ref, setRef] = useState19(null);
6962
- const popoverState = usePopupState10({ variant: "popover" });
6963
- const popoverProps = bindPopover9(popoverState);
6964
- useEffect14(() => {
6632
+ const [ref, setRef] = useState17(null);
6633
+ const popoverState = usePopupState8({ variant: "popover" });
6634
+ const popoverProps = bindPopover7(popoverState);
6635
+ useEffect12(() => {
6965
6636
  if (openOnMount && ref) {
6966
6637
  popoverState.open(ref);
6967
6638
  onOpen?.();
@@ -6975,6 +6646,287 @@ var usePopover = (openOnMount, onOpen) => {
6975
6646
  };
6976
6647
  };
6977
6648
 
6649
+ // src/components/inline-editor-toolbar.tsx
6650
+ import * as React103 from "react";
6651
+ import { useMemo as useMemo15, useRef as useRef26, useState as useState18 } from "react";
6652
+ import { getElementSetting } from "@elementor/editor-elements";
6653
+ import {
6654
+ BoldIcon,
6655
+ ItalicIcon,
6656
+ LinkIcon as LinkIcon3,
6657
+ MinusIcon as MinusIcon2,
6658
+ StrikethroughIcon,
6659
+ SubscriptIcon,
6660
+ SuperscriptIcon,
6661
+ UnderlineIcon
6662
+ } from "@elementor/icons";
6663
+ import {
6664
+ Box as Box25,
6665
+ IconButton as IconButton10,
6666
+ ToggleButton as ToggleButton3,
6667
+ ToggleButtonGroup as ToggleButtonGroup2,
6668
+ toggleButtonGroupClasses,
6669
+ Tooltip as Tooltip12,
6670
+ usePopupState as usePopupState9
6671
+ } from "@elementor/ui";
6672
+ import { useEditorState } from "@tiptap/react";
6673
+ import { __ as __52 } from "@wordpress/i18n";
6674
+
6675
+ // src/components/url-popover.tsx
6676
+ import * as React102 from "react";
6677
+ import { useEffect as useEffect13, useRef as useRef25 } from "react";
6678
+ import { ExternalLinkIcon } from "@elementor/icons";
6679
+ import { bindPopover as bindPopover8, Popover as Popover7, Stack as Stack16, TextField as TextField8, ToggleButton as ToggleButton2, Tooltip as Tooltip11 } from "@elementor/ui";
6680
+ import { __ as __51 } from "@wordpress/i18n";
6681
+ var UrlPopover = ({
6682
+ popupState,
6683
+ restoreValue,
6684
+ anchorRef,
6685
+ value,
6686
+ onChange,
6687
+ openInNewTab,
6688
+ onToggleNewTab
6689
+ }) => {
6690
+ const inputRef = useRef25(null);
6691
+ useEffect13(() => {
6692
+ if (popupState.isOpen) {
6693
+ requestAnimationFrame(() => inputRef.current?.focus());
6694
+ }
6695
+ }, [popupState.isOpen]);
6696
+ const handleClose = () => {
6697
+ restoreValue();
6698
+ popupState.close();
6699
+ };
6700
+ return /* @__PURE__ */ React102.createElement(
6701
+ Popover7,
6702
+ {
6703
+ slotProps: {
6704
+ paper: { sx: { borderRadius: "16px", width: anchorRef.current?.offsetWidth + "px", marginTop: -1 } }
6705
+ },
6706
+ ...bindPopover8(popupState),
6707
+ anchorOrigin: { vertical: "top", horizontal: "left" },
6708
+ transformOrigin: { vertical: "top", horizontal: "left" },
6709
+ onClose: handleClose
6710
+ },
6711
+ /* @__PURE__ */ React102.createElement(Stack16, { direction: "row", alignItems: "center", gap: 1, sx: { p: 1.5 } }, /* @__PURE__ */ React102.createElement(
6712
+ TextField8,
6713
+ {
6714
+ value,
6715
+ onChange,
6716
+ size: "tiny",
6717
+ fullWidth: true,
6718
+ placeholder: __51("Type a URL", "elementor"),
6719
+ inputProps: { ref: inputRef },
6720
+ color: "secondary",
6721
+ InputProps: { sx: { borderRadius: "8px" } },
6722
+ onKeyUp: (event) => event.key === "Enter" && handleClose()
6723
+ }
6724
+ ), /* @__PURE__ */ React102.createElement(Tooltip11, { title: __51("Open in a new tab", "elementor") }, /* @__PURE__ */ React102.createElement(
6725
+ ToggleButton2,
6726
+ {
6727
+ size: "tiny",
6728
+ value: "newTab",
6729
+ selected: openInNewTab,
6730
+ onClick: onToggleNewTab,
6731
+ "aria-label": __51("Open in a new tab", "elementor"),
6732
+ sx: { borderRadius: "8px" }
6733
+ },
6734
+ /* @__PURE__ */ React102.createElement(ExternalLinkIcon, { fontSize: "tiny" })
6735
+ )))
6736
+ );
6737
+ };
6738
+
6739
+ // src/components/inline-editor-toolbar.tsx
6740
+ var InlineEditorToolbar = ({ editor, elementId, sx = {} }) => {
6741
+ const [urlValue, setUrlValue] = useState18("");
6742
+ const [openInNewTab, setOpenInNewTab] = useState18(false);
6743
+ const toolbarRef = useRef26(null);
6744
+ const linkPopupState = usePopupState9({ variant: "popover" });
6745
+ const hasLinkOnElement = elementId ? checkIfElementHasLink(elementId) : false;
6746
+ const editorState = useEditorState({
6747
+ editor,
6748
+ selector: (ctx) => possibleFormats.filter((format) => ctx.editor.isActive(format))
6749
+ });
6750
+ const formatButtonsList = useMemo15(() => {
6751
+ const buttons = Object.values(formatButtons);
6752
+ if (hasLinkOnElement) {
6753
+ return buttons.filter((button) => button.action !== "link");
6754
+ }
6755
+ return buttons;
6756
+ }, [hasLinkOnElement]);
6757
+ const handleLinkClick = () => {
6758
+ const linkAttrs = editor.getAttributes("link");
6759
+ setUrlValue(linkAttrs.href || "");
6760
+ setOpenInNewTab(linkAttrs.target === "_blank");
6761
+ linkPopupState.open(toolbarRef.current);
6762
+ };
6763
+ const handleUrlChange = (event) => {
6764
+ setUrlValue(event.target.value);
6765
+ };
6766
+ const handleToggleNewTab = () => {
6767
+ setOpenInNewTab(!openInNewTab);
6768
+ };
6769
+ const handleUrlSubmit = () => {
6770
+ if (urlValue) {
6771
+ editor.chain().focus().setLink({
6772
+ href: urlValue,
6773
+ target: openInNewTab ? "_blank" : "_self"
6774
+ }).run();
6775
+ } else {
6776
+ editor.chain().focus().unsetLink().run();
6777
+ }
6778
+ if (elementId) {
6779
+ window.dispatchEvent(
6780
+ new CustomEvent("elementor:inline-link-changed", {
6781
+ detail: { elementId }
6782
+ })
6783
+ );
6784
+ }
6785
+ linkPopupState.close();
6786
+ };
6787
+ React103.useEffect(() => {
6788
+ editor?.commands?.focus();
6789
+ }, [editor]);
6790
+ return /* @__PURE__ */ React103.createElement(
6791
+ Box25,
6792
+ {
6793
+ ref: toolbarRef,
6794
+ sx: {
6795
+ display: "inline-flex",
6796
+ gap: 0.5,
6797
+ padding: 0.5,
6798
+ borderRadius: "8px",
6799
+ backgroundColor: "background.paper",
6800
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.2)",
6801
+ alignItems: "center",
6802
+ visibility: linkPopupState.isOpen ? "hidden" : "visible",
6803
+ pointerEvents: linkPopupState.isOpen ? "none" : "all",
6804
+ ...sx
6805
+ }
6806
+ },
6807
+ /* @__PURE__ */ React103.createElement(Tooltip12, { title: clearButton.label, placement: "top", sx: { borderRadius: "8px" } }, /* @__PURE__ */ React103.createElement(IconButton10, { "aria-label": clearButton.label, onClick: () => clearButton.method(editor), size: "tiny" }, clearButton.icon)),
6808
+ /* @__PURE__ */ React103.createElement(
6809
+ ToggleButtonGroup2,
6810
+ {
6811
+ value: editorState,
6812
+ size: "tiny",
6813
+ sx: {
6814
+ display: "flex",
6815
+ gap: 0.5,
6816
+ border: "none",
6817
+ [`& .${toggleButtonGroupClasses.firstButton}, & .${toggleButtonGroupClasses.middleButton}, & .${toggleButtonGroupClasses.lastButton}`]: {
6818
+ borderRadius: "8px",
6819
+ border: "none",
6820
+ marginLeft: 0,
6821
+ "&.Mui-selected": {
6822
+ marginLeft: 0
6823
+ },
6824
+ "& + &.Mui-selected": {
6825
+ marginLeft: 0
6826
+ }
6827
+ }
6828
+ }
6829
+ },
6830
+ formatButtonsList.map((button) => /* @__PURE__ */ React103.createElement(Tooltip12, { title: button.label, key: button.action, placement: "top" }, /* @__PURE__ */ React103.createElement(
6831
+ ToggleButton3,
6832
+ {
6833
+ value: button.action,
6834
+ "aria-label": button.label,
6835
+ size: "tiny",
6836
+ onClick: () => {
6837
+ if (button.action === "link") {
6838
+ handleLinkClick();
6839
+ } else {
6840
+ button.method?.(editor);
6841
+ }
6842
+ editor?.commands?.focus();
6843
+ }
6844
+ },
6845
+ button.icon
6846
+ )))
6847
+ ),
6848
+ /* @__PURE__ */ React103.createElement(
6849
+ UrlPopover,
6850
+ {
6851
+ popupState: linkPopupState,
6852
+ anchorRef: toolbarRef,
6853
+ restoreValue: handleUrlSubmit,
6854
+ value: urlValue,
6855
+ onChange: handleUrlChange,
6856
+ openInNewTab,
6857
+ onToggleNewTab: handleToggleNewTab
6858
+ }
6859
+ )
6860
+ );
6861
+ };
6862
+ var checkIfElementHasLink = (elementId) => !!getElementSetting(elementId, "link")?.value?.destination;
6863
+ var toolbarButtons = {
6864
+ clear: {
6865
+ label: __52("Clear", "elementor"),
6866
+ icon: /* @__PURE__ */ React103.createElement(MinusIcon2, { fontSize: "tiny" }),
6867
+ action: "clear",
6868
+ method: (editor) => {
6869
+ editor.chain().focus().clearNodes().unsetAllMarks().run();
6870
+ }
6871
+ },
6872
+ bold: {
6873
+ label: __52("Bold", "elementor"),
6874
+ icon: /* @__PURE__ */ React103.createElement(BoldIcon, { fontSize: "tiny" }),
6875
+ action: "bold",
6876
+ method: (editor) => {
6877
+ editor.chain().focus().toggleBold().run();
6878
+ }
6879
+ },
6880
+ italic: {
6881
+ label: __52("Italic", "elementor"),
6882
+ icon: /* @__PURE__ */ React103.createElement(ItalicIcon, { fontSize: "tiny" }),
6883
+ action: "italic",
6884
+ method: (editor) => {
6885
+ editor.chain().focus().toggleItalic().run();
6886
+ }
6887
+ },
6888
+ underline: {
6889
+ label: __52("Underline", "elementor"),
6890
+ icon: /* @__PURE__ */ React103.createElement(UnderlineIcon, { fontSize: "tiny" }),
6891
+ action: "underline",
6892
+ method: (editor) => {
6893
+ editor.chain().focus().toggleUnderline().run();
6894
+ }
6895
+ },
6896
+ strike: {
6897
+ label: __52("Strikethrough", "elementor"),
6898
+ icon: /* @__PURE__ */ React103.createElement(StrikethroughIcon, { fontSize: "tiny" }),
6899
+ action: "strike",
6900
+ method: (editor) => {
6901
+ editor.chain().focus().toggleStrike().run();
6902
+ }
6903
+ },
6904
+ superscript: {
6905
+ label: __52("Superscript", "elementor"),
6906
+ icon: /* @__PURE__ */ React103.createElement(SuperscriptIcon, { fontSize: "tiny" }),
6907
+ action: "superscript",
6908
+ method: (editor) => {
6909
+ editor.chain().focus().toggleSuperscript().run();
6910
+ }
6911
+ },
6912
+ subscript: {
6913
+ label: __52("Subscript", "elementor"),
6914
+ icon: /* @__PURE__ */ React103.createElement(SubscriptIcon, { fontSize: "tiny" }),
6915
+ action: "subscript",
6916
+ method: (editor) => {
6917
+ editor.chain().focus().toggleSubscript().run();
6918
+ }
6919
+ },
6920
+ link: {
6921
+ label: __52("Link", "elementor"),
6922
+ icon: /* @__PURE__ */ React103.createElement(LinkIcon3, { fontSize: "tiny" }),
6923
+ action: "link",
6924
+ method: null
6925
+ }
6926
+ };
6927
+ var { clear: clearButton, ...formatButtons } = toolbarButtons;
6928
+ var possibleFormats = Object.keys(formatButtons);
6929
+
6978
6930
  // src/components/size/unstable-size-field.tsx
6979
6931
  import * as React106 from "react";
6980
6932
  import { InputAdornment as InputAdornment5 } from "@elementor/ui";
@@ -7020,14 +6972,14 @@ var differsFromExternal = (newState, externalState) => {
7020
6972
  import * as React104 from "react";
7021
6973
  import { useId as useId3 } from "react";
7022
6974
  import { MenuListItem as MenuListItem7 } from "@elementor/editor-ui";
7023
- import { bindMenu as bindMenu2, bindTrigger as bindTrigger7, Button as Button5, Menu as Menu3, styled as styled10, usePopupState as usePopupState11 } from "@elementor/ui";
6975
+ import { bindMenu as bindMenu2, bindTrigger as bindTrigger7, Button as Button5, Menu as Menu3, styled as styled10, usePopupState as usePopupState10 } from "@elementor/ui";
7024
6976
  var menuItemContentStyles = {
7025
6977
  display: "flex",
7026
6978
  flexDirection: "column",
7027
6979
  justifyContent: "center"
7028
6980
  };
7029
6981
  var UnitSelect = ({ value, showPrimaryColor, onClick, options }) => {
7030
- const popupState = usePopupState11({
6982
+ const popupState = usePopupState10({
7031
6983
  variant: "popover",
7032
6984
  popupId: useId3()
7033
6985
  });