@tarviks/lexical-rich-editor 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +91 -2
- package/dist/index.css.map +1 -1
- package/dist/index.js +703 -637
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +555 -489
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var utils = require('@lexical/utils');
|
|
4
|
-
var
|
|
4
|
+
var React10 = require('react');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
7
7
|
var useLexicalEditable = require('@lexical/react/useLexicalEditable');
|
|
@@ -49,7 +49,7 @@ function _interopNamespace(e) {
|
|
|
49
49
|
return Object.freeze(n);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
var
|
|
52
|
+
var React10__namespace = /*#__PURE__*/_interopNamespace(React10);
|
|
53
53
|
|
|
54
54
|
var __defProp = Object.defineProperty;
|
|
55
55
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -83,12 +83,12 @@ var init_ImageResizer = __esm({
|
|
|
83
83
|
setShowCaption,
|
|
84
84
|
captionsEnabled
|
|
85
85
|
}) => {
|
|
86
|
-
const controlWrapperRef =
|
|
87
|
-
const userSelect =
|
|
86
|
+
const controlWrapperRef = React10.useRef(null);
|
|
87
|
+
const userSelect = React10.useRef({
|
|
88
88
|
priority: "",
|
|
89
89
|
value: "default"
|
|
90
90
|
});
|
|
91
|
-
const positioningRef =
|
|
91
|
+
const positioningRef = React10.useRef({
|
|
92
92
|
currentHeight: 0,
|
|
93
93
|
currentWidth: 0,
|
|
94
94
|
direction: 0,
|
|
@@ -419,15 +419,15 @@ var init_ImageComponent = __esm({
|
|
|
419
419
|
};
|
|
420
420
|
ImageComponent = ({ src, altText, nodeKey, width, height, maxWidth, resizable, showCaption, caption, captionsEnabled }) => {
|
|
421
421
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
|
|
422
|
-
const [selection, setSelection] =
|
|
423
|
-
const [isLoadError, setIsLoadError] =
|
|
424
|
-
const [isResizing, setIsResizing] =
|
|
422
|
+
const [selection, setSelection] = React10.useState(null);
|
|
423
|
+
const [isLoadError, setIsLoadError] = React10.useState(false);
|
|
424
|
+
const [isResizing, setIsResizing] = React10.useState(false);
|
|
425
425
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
426
|
-
const activeEditorRef =
|
|
427
|
-
const buttonRef =
|
|
428
|
-
const imageRef =
|
|
426
|
+
const activeEditorRef = React10.useRef(null);
|
|
427
|
+
const buttonRef = React10.useRef(null);
|
|
428
|
+
const imageRef = React10.useRef(null);
|
|
429
429
|
const isEditable = useLexicalEditable.useLexicalEditable();
|
|
430
|
-
const $onDelete =
|
|
430
|
+
const $onDelete = React10.useCallback(
|
|
431
431
|
(payload) => {
|
|
432
432
|
const deleteSelection = lexical.$getSelection();
|
|
433
433
|
if (isSelected && lexical.$isNodeSelection(deleteSelection)) {
|
|
@@ -443,7 +443,7 @@ var init_ImageComponent = __esm({
|
|
|
443
443
|
},
|
|
444
444
|
[isSelected]
|
|
445
445
|
);
|
|
446
|
-
const $onEnter =
|
|
446
|
+
const $onEnter = React10.useCallback(
|
|
447
447
|
(event) => {
|
|
448
448
|
const latestSelection = lexical.$getSelection();
|
|
449
449
|
const buttonElem = buttonRef.current;
|
|
@@ -463,7 +463,7 @@ var init_ImageComponent = __esm({
|
|
|
463
463
|
},
|
|
464
464
|
[caption, isSelected, showCaption]
|
|
465
465
|
);
|
|
466
|
-
const $onEscape =
|
|
466
|
+
const $onEscape = React10.useCallback(
|
|
467
467
|
(event) => {
|
|
468
468
|
if (activeEditorRef.current === caption || buttonRef.current === event.target) {
|
|
469
469
|
lexical.$setSelection(null);
|
|
@@ -480,7 +480,7 @@ var init_ImageComponent = __esm({
|
|
|
480
480
|
},
|
|
481
481
|
[caption, editor, setSelected]
|
|
482
482
|
);
|
|
483
|
-
const onClick =
|
|
483
|
+
const onClick = React10.useCallback(
|
|
484
484
|
(payload) => {
|
|
485
485
|
const event = payload;
|
|
486
486
|
if (isResizing) {
|
|
@@ -499,7 +499,7 @@ var init_ImageComponent = __esm({
|
|
|
499
499
|
},
|
|
500
500
|
[isResizing, isSelected, setSelected, clearSelection]
|
|
501
501
|
);
|
|
502
|
-
const onRightClick =
|
|
502
|
+
const onRightClick = React10.useCallback(
|
|
503
503
|
(event) => {
|
|
504
504
|
editor.getEditorState().read(() => {
|
|
505
505
|
const latestSelection = lexical.$getSelection();
|
|
@@ -514,7 +514,7 @@ var init_ImageComponent = __esm({
|
|
|
514
514
|
},
|
|
515
515
|
[editor]
|
|
516
516
|
);
|
|
517
|
-
|
|
517
|
+
React10.useEffect(() => {
|
|
518
518
|
const rootElement = editor.getRootElement();
|
|
519
519
|
const unregister = utils.mergeRegister(
|
|
520
520
|
editor.registerUpdateListener(({ editorState }) => {
|
|
@@ -602,7 +602,7 @@ var init_ImageComponent = __esm({
|
|
|
602
602
|
};
|
|
603
603
|
const draggable = !isResizing;
|
|
604
604
|
const isFocused = (isSelected || isResizing) && isEditable;
|
|
605
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
605
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React10.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
606
606
|
"div",
|
|
607
607
|
{
|
|
608
608
|
draggable,
|
|
@@ -663,7 +663,7 @@ function parseDimFromStyleOrAttr(img3) {
|
|
|
663
663
|
var ImageComponent2, isGoogleDocCheckboxImg, $convertImageElement, ImageNode, $createImageNode, $isImageNode;
|
|
664
664
|
var init_ImageNode = __esm({
|
|
665
665
|
"src/Nodes/ImageNode.tsx"() {
|
|
666
|
-
ImageComponent2 =
|
|
666
|
+
ImageComponent2 = React10__namespace.lazy(() => Promise.resolve().then(() => (init_ImageComponent(), ImageComponent_exports)));
|
|
667
667
|
isGoogleDocCheckboxImg = (img3) => {
|
|
668
668
|
return img3.parentElement != null && img3.parentElement.tagName === "LI" && img3.previousSibling === null && img3.getAttribute("aria-roledescription") === "checkbox";
|
|
669
669
|
};
|
|
@@ -908,14 +908,14 @@ var init_InlineImageComponent = __esm({
|
|
|
908
908
|
};
|
|
909
909
|
InlineImageComponent = ({ src, altText, nodeKey, width, height, showCaption, caption, position }) => {
|
|
910
910
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
|
|
911
|
-
const [isResizing, setIsResizing] =
|
|
912
|
-
const [selection, setSelection] =
|
|
913
|
-
const activeEditorRef =
|
|
914
|
-
const imageRef =
|
|
915
|
-
const buttonRef =
|
|
911
|
+
const [isResizing, setIsResizing] = React10.useState(false);
|
|
912
|
+
const [selection, setSelection] = React10.useState(null);
|
|
913
|
+
const activeEditorRef = React10.useRef(null);
|
|
914
|
+
const imageRef = React10.useRef(null);
|
|
915
|
+
const buttonRef = React10.useRef(null);
|
|
916
916
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
917
917
|
const isEditable = useLexicalEditable.useLexicalEditable();
|
|
918
|
-
const $onDelete =
|
|
918
|
+
const $onDelete = React10.useCallback(
|
|
919
919
|
(payload) => {
|
|
920
920
|
const deleteSelection = lexical.$getSelection();
|
|
921
921
|
if (isSelected && lexical.$isNodeSelection(deleteSelection)) {
|
|
@@ -933,7 +933,7 @@ var init_InlineImageComponent = __esm({
|
|
|
933
933
|
},
|
|
934
934
|
[isSelected]
|
|
935
935
|
);
|
|
936
|
-
const $onEnter =
|
|
936
|
+
const $onEnter = React10.useCallback(
|
|
937
937
|
(event) => {
|
|
938
938
|
const latestSelection = lexical.$getSelection();
|
|
939
939
|
const buttonElem = buttonRef.current;
|
|
@@ -953,7 +953,7 @@ var init_InlineImageComponent = __esm({
|
|
|
953
953
|
},
|
|
954
954
|
[caption, isSelected, showCaption]
|
|
955
955
|
);
|
|
956
|
-
const $onEscape =
|
|
956
|
+
const $onEscape = React10.useCallback(
|
|
957
957
|
(event) => {
|
|
958
958
|
if (activeEditorRef.current === caption || buttonRef.current === event.target) {
|
|
959
959
|
lexical.$setSelection(null);
|
|
@@ -970,7 +970,7 @@ var init_InlineImageComponent = __esm({
|
|
|
970
970
|
},
|
|
971
971
|
[caption, editor, setSelected]
|
|
972
972
|
);
|
|
973
|
-
const onClick =
|
|
973
|
+
const onClick = React10.useCallback(
|
|
974
974
|
(payload) => {
|
|
975
975
|
const event = payload;
|
|
976
976
|
if (isResizing) {
|
|
@@ -989,7 +989,7 @@ var init_InlineImageComponent = __esm({
|
|
|
989
989
|
},
|
|
990
990
|
[isResizing, isSelected, setSelected, clearSelection]
|
|
991
991
|
);
|
|
992
|
-
|
|
992
|
+
React10.useEffect(() => {
|
|
993
993
|
let isMounted = true;
|
|
994
994
|
const unregister = utils.mergeRegister(
|
|
995
995
|
editor.registerUpdateListener(({ editorState }) => {
|
|
@@ -1047,7 +1047,7 @@ var init_InlineImageComponent = __esm({
|
|
|
1047
1047
|
};
|
|
1048
1048
|
const draggable = !isResizing;
|
|
1049
1049
|
const isFocused = (isSelected || isResizing) && isEditable;
|
|
1050
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1050
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React10.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { draggable, style: { position: "relative", display: "inline-block" }, children: [
|
|
1051
1051
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1052
1052
|
LazyImage2,
|
|
1053
1053
|
{
|
|
@@ -1082,7 +1082,7 @@ var init_InlineImageComponent = __esm({
|
|
|
1082
1082
|
var InlineImageComponent2, $convertInlineImageElement, InlineImageNode, $createInlineImageNode, $isInlineImageNode;
|
|
1083
1083
|
var init_InlineImageNode = __esm({
|
|
1084
1084
|
"src/Nodes/InlineImageNode.tsx"() {
|
|
1085
|
-
InlineImageComponent2 =
|
|
1085
|
+
InlineImageComponent2 = React10__namespace.lazy(() => Promise.resolve().then(() => (init_InlineImageComponent(), InlineImageComponent_exports)));
|
|
1086
1086
|
$convertInlineImageElement = (domNode) => {
|
|
1087
1087
|
if (lexical.isHTMLElement(domNode) && domNode.nodeName === "IMG") {
|
|
1088
1088
|
const { alt: altText, src, width, height } = domNode;
|
|
@@ -1537,7 +1537,7 @@ init_InlineImageNode();
|
|
|
1537
1537
|
var PageBreakComponent = ({ nodeKey }) => {
|
|
1538
1538
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
1539
1539
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
|
|
1540
|
-
const $onDelete =
|
|
1540
|
+
const $onDelete = React10.useCallback(
|
|
1541
1541
|
(event) => {
|
|
1542
1542
|
event.preventDefault();
|
|
1543
1543
|
const deleteSelection = lexical.$getSelection();
|
|
@@ -1552,7 +1552,7 @@ var PageBreakComponent = ({ nodeKey }) => {
|
|
|
1552
1552
|
},
|
|
1553
1553
|
[isSelected]
|
|
1554
1554
|
);
|
|
1555
|
-
|
|
1555
|
+
React10.useEffect(() => {
|
|
1556
1556
|
return utils.mergeRegister(
|
|
1557
1557
|
editor.registerCommand(
|
|
1558
1558
|
lexical.CLICK_COMMAND,
|
|
@@ -1581,7 +1581,7 @@ var PageBreakComponent = ({ nodeKey }) => {
|
|
|
1581
1581
|
)
|
|
1582
1582
|
);
|
|
1583
1583
|
}, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected]);
|
|
1584
|
-
|
|
1584
|
+
React10.useEffect(() => {
|
|
1585
1585
|
const pbElem = editor.getElementByKey(nodeKey);
|
|
1586
1586
|
if (pbElem !== null) {
|
|
1587
1587
|
pbElem.className = isSelected ? "selected" : "";
|
|
@@ -1723,7 +1723,7 @@ function VideoResizer({
|
|
|
1723
1723
|
onResizeStart,
|
|
1724
1724
|
onResizeEnd
|
|
1725
1725
|
}) {
|
|
1726
|
-
const resizeState =
|
|
1726
|
+
const resizeState = React10__namespace.useRef(null);
|
|
1727
1727
|
const startResize = (e, dir) => {
|
|
1728
1728
|
e.preventDefault();
|
|
1729
1729
|
e.stopPropagation();
|
|
@@ -1850,15 +1850,15 @@ function YouTubeComponent({
|
|
|
1850
1850
|
height,
|
|
1851
1851
|
editor
|
|
1852
1852
|
}) {
|
|
1853
|
-
const wrapperRef =
|
|
1854
|
-
const containerRef =
|
|
1855
|
-
const iframeRef =
|
|
1856
|
-
const isResizingRef =
|
|
1853
|
+
const wrapperRef = React10__namespace.useRef(null);
|
|
1854
|
+
const containerRef = React10__namespace.useRef(null);
|
|
1855
|
+
const iframeRef = React10__namespace.useRef(null);
|
|
1856
|
+
const isResizingRef = React10__namespace.useRef(false);
|
|
1857
1857
|
const [isNodeSelected, setNodeSelected, clearNodeSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
|
|
1858
|
-
const [isHovered, setIsHovered] =
|
|
1859
|
-
const [isResizing, setIsResizing] =
|
|
1860
|
-
const [isPlaying, setIsPlaying] =
|
|
1861
|
-
|
|
1858
|
+
const [isHovered, setIsHovered] = React10__namespace.useState(false);
|
|
1859
|
+
const [isResizing, setIsResizing] = React10__namespace.useState(false);
|
|
1860
|
+
const [isPlaying, setIsPlaying] = React10__namespace.useState(false);
|
|
1861
|
+
React10__namespace.useEffect(() => {
|
|
1862
1862
|
return utils.mergeRegister(
|
|
1863
1863
|
editor.registerCommand(
|
|
1864
1864
|
lexical.FORMAT_ELEMENT_COMMAND,
|
|
@@ -2247,13 +2247,13 @@ function AutocompletePlugin({
|
|
|
2247
2247
|
prefixWindow = 300
|
|
2248
2248
|
}) {
|
|
2249
2249
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
2250
|
-
const ghostKeyRef =
|
|
2251
|
-
const idleTimerRef =
|
|
2252
|
-
const inflightRef =
|
|
2253
|
-
const reqCounterRef =
|
|
2254
|
-
const lastTriggerRef =
|
|
2255
|
-
const lastShownCtxRef =
|
|
2256
|
-
const clearGhost =
|
|
2250
|
+
const ghostKeyRef = React10__namespace.useRef(null);
|
|
2251
|
+
const idleTimerRef = React10__namespace.useRef(null);
|
|
2252
|
+
const inflightRef = React10__namespace.useRef(null);
|
|
2253
|
+
const reqCounterRef = React10__namespace.useRef(0);
|
|
2254
|
+
const lastTriggerRef = React10__namespace.useRef("");
|
|
2255
|
+
const lastShownCtxRef = React10__namespace.useRef("");
|
|
2256
|
+
const clearGhost = React10__namespace.useCallback(() => {
|
|
2257
2257
|
editor.update(
|
|
2258
2258
|
() => {
|
|
2259
2259
|
const key = ghostKeyRef.current;
|
|
@@ -2265,7 +2265,7 @@ function AutocompletePlugin({
|
|
|
2265
2265
|
{ tag: "autocomplete-ghost" }
|
|
2266
2266
|
);
|
|
2267
2267
|
}, [editor]);
|
|
2268
|
-
const upsertGhost =
|
|
2268
|
+
const upsertGhost = React10__namespace.useCallback(
|
|
2269
2269
|
(text, insertAtCharOffset) => {
|
|
2270
2270
|
editor.update(
|
|
2271
2271
|
() => {
|
|
@@ -2329,12 +2329,12 @@ function AutocompletePlugin({
|
|
|
2329
2329
|
},
|
|
2330
2330
|
[editor]
|
|
2331
2331
|
);
|
|
2332
|
-
const cancelInflight =
|
|
2332
|
+
const cancelInflight = React10__namespace.useCallback(() => {
|
|
2333
2333
|
if (!inflightRef.current) return;
|
|
2334
2334
|
inflightRef.current.dismiss();
|
|
2335
2335
|
inflightRef.current = null;
|
|
2336
2336
|
}, []);
|
|
2337
|
-
const resetIdleTimer =
|
|
2337
|
+
const resetIdleTimer = React10__namespace.useCallback(
|
|
2338
2338
|
(callback) => {
|
|
2339
2339
|
if (idleTimerRef.current) {
|
|
2340
2340
|
clearTimeout(idleTimerRef.current);
|
|
@@ -2349,7 +2349,7 @@ function AutocompletePlugin({
|
|
|
2349
2349
|
},
|
|
2350
2350
|
[idleMs, cancelInflight, clearGhost]
|
|
2351
2351
|
);
|
|
2352
|
-
const fireQuery =
|
|
2352
|
+
const fireQuery = React10__namespace.useCallback(() => {
|
|
2353
2353
|
if (!useQuery || isReadOnly) return;
|
|
2354
2354
|
let context = "";
|
|
2355
2355
|
let prefix = "";
|
|
@@ -2421,7 +2421,7 @@ function AutocompletePlugin({
|
|
|
2421
2421
|
upsertGhost,
|
|
2422
2422
|
onSuggestionShown
|
|
2423
2423
|
]);
|
|
2424
|
-
|
|
2424
|
+
React10__namespace.useEffect(() => {
|
|
2425
2425
|
if (!useQuery || isReadOnly) return;
|
|
2426
2426
|
return editor.registerUpdateListener(({ tags }) => {
|
|
2427
2427
|
if (tags.has("history-merge") || tags.has("collaboration")) return;
|
|
@@ -2430,7 +2430,7 @@ function AutocompletePlugin({
|
|
|
2430
2430
|
resetIdleTimer(fireQuery);
|
|
2431
2431
|
});
|
|
2432
2432
|
}, [editor, useQuery, isReadOnly, resetIdleTimer, fireQuery]);
|
|
2433
|
-
|
|
2433
|
+
React10__namespace.useEffect(() => {
|
|
2434
2434
|
if (!useQuery || isReadOnly) return;
|
|
2435
2435
|
return editor.registerCommand(
|
|
2436
2436
|
lexical.SELECTION_CHANGE_COMMAND,
|
|
@@ -2454,7 +2454,7 @@ function AutocompletePlugin({
|
|
|
2454
2454
|
lexical.COMMAND_PRIORITY_LOW
|
|
2455
2455
|
);
|
|
2456
2456
|
}, [editor, useQuery, isReadOnly, resetIdleTimer, fireQuery]);
|
|
2457
|
-
|
|
2457
|
+
React10__namespace.useEffect(() => {
|
|
2458
2458
|
return editor.registerCommand(
|
|
2459
2459
|
lexical.KEY_DOWN_COMMAND,
|
|
2460
2460
|
(e) => {
|
|
@@ -2495,7 +2495,7 @@ function AutocompletePlugin({
|
|
|
2495
2495
|
lexical.COMMAND_PRIORITY_HIGH
|
|
2496
2496
|
);
|
|
2497
2497
|
}, [editor, clearGhost, onSuggestionAccept, prefixWindow]);
|
|
2498
|
-
|
|
2498
|
+
React10__namespace.useEffect(() => {
|
|
2499
2499
|
return () => {
|
|
2500
2500
|
cancelInflight();
|
|
2501
2501
|
if (idleTimerRef.current) clearTimeout(idleTimerRef.current);
|
|
@@ -2507,8 +2507,8 @@ function clamp2(n, min, max) {
|
|
|
2507
2507
|
return Math.max(min, Math.min(max, n));
|
|
2508
2508
|
}
|
|
2509
2509
|
function useFloatingPortalContainer(editor) {
|
|
2510
|
-
const [container, setContainer] =
|
|
2511
|
-
|
|
2510
|
+
const [container, setContainer] = React10.useState(null);
|
|
2511
|
+
React10.useEffect(() => {
|
|
2512
2512
|
const root = editor.getRootElement();
|
|
2513
2513
|
if (!root) return;
|
|
2514
2514
|
const panelOrLayer = root.closest(".ms-Panel-main") || root.closest(".ms-Panel") || root.closest(".ms-Layer") || document.body;
|
|
@@ -2546,22 +2546,22 @@ function FloatingCharacterStylesEditor({
|
|
|
2546
2546
|
isEditable,
|
|
2547
2547
|
readOnly
|
|
2548
2548
|
}) {
|
|
2549
|
-
const popupRef =
|
|
2550
|
-
const mouseDownRef =
|
|
2549
|
+
const popupRef = React10.useRef(null);
|
|
2550
|
+
const mouseDownRef = React10.useRef(false);
|
|
2551
2551
|
const theme2 = react.useTheme();
|
|
2552
2552
|
const disabled = !(isEditable ?? editor.isEditable()) || !!readOnly;
|
|
2553
|
-
const format =
|
|
2553
|
+
const format = React10.useCallback(
|
|
2554
2554
|
(type) => {
|
|
2555
2555
|
if (disabled) return;
|
|
2556
2556
|
editor.dispatchCommand(lexical.FORMAT_TEXT_COMMAND, type);
|
|
2557
2557
|
},
|
|
2558
2558
|
[editor, disabled]
|
|
2559
2559
|
);
|
|
2560
|
-
const toggleLink =
|
|
2560
|
+
const toggleLink = React10.useCallback(() => {
|
|
2561
2561
|
if (disabled) return;
|
|
2562
2562
|
editor.dispatchCommand(link.TOGGLE_LINK_COMMAND, isLink ? null : "https://");
|
|
2563
2563
|
}, [editor, disabled, isLink]);
|
|
2564
|
-
const updatePosition =
|
|
2564
|
+
const updatePosition = React10.useCallback(() => {
|
|
2565
2565
|
const popupEl = popupRef.current;
|
|
2566
2566
|
if (!popupEl) return;
|
|
2567
2567
|
const sel = window.getSelection();
|
|
@@ -2589,7 +2589,7 @@ function FloatingCharacterStylesEditor({
|
|
|
2589
2589
|
}
|
|
2590
2590
|
popupEl.classList.add("is-open");
|
|
2591
2591
|
}, [editor]);
|
|
2592
|
-
|
|
2592
|
+
React10.useEffect(() => {
|
|
2593
2593
|
const onResize = () => editor.getEditorState().read(updatePosition);
|
|
2594
2594
|
const onScroll = () => editor.getEditorState().read(updatePosition);
|
|
2595
2595
|
const root = editor.getRootElement();
|
|
@@ -2602,7 +2602,7 @@ function FloatingCharacterStylesEditor({
|
|
|
2602
2602
|
root?.removeEventListener("scroll", onScroll);
|
|
2603
2603
|
};
|
|
2604
2604
|
}, [editor, updatePosition]);
|
|
2605
|
-
|
|
2605
|
+
React10.useEffect(() => {
|
|
2606
2606
|
editor.getEditorState().read(updatePosition);
|
|
2607
2607
|
return utils.mergeRegister(
|
|
2608
2608
|
editor.registerUpdateListener(({ editorState }) => {
|
|
@@ -2773,18 +2773,18 @@ function getSelectedNode(selection$1) {
|
|
|
2773
2773
|
return isBackward ? selection.$isAtNodeEnd(selection$1.focus) ? anchorNode : focusNode : selection.$isAtNodeEnd(selection$1.anchor) ? focusNode : anchorNode;
|
|
2774
2774
|
}
|
|
2775
2775
|
function useCharacterStylesPopup(editor, opts) {
|
|
2776
|
-
const [isText, setIsText] =
|
|
2777
|
-
const [isLink, setIsLink] =
|
|
2778
|
-
const [isBold, setIsBold] =
|
|
2779
|
-
const [isItalic, setIsItalic] =
|
|
2780
|
-
const [isUnderline, setIsUnderline] =
|
|
2781
|
-
const [isStrikethrough, setIsStrikethrough] =
|
|
2782
|
-
const [isSubscript, setIsSubscript] =
|
|
2783
|
-
const [isSuperscript, setIsSuperscript] =
|
|
2784
|
-
const [isCode, setIsCode] =
|
|
2776
|
+
const [isText, setIsText] = React10.useState(false);
|
|
2777
|
+
const [isLink, setIsLink] = React10.useState(false);
|
|
2778
|
+
const [isBold, setIsBold] = React10.useState(false);
|
|
2779
|
+
const [isItalic, setIsItalic] = React10.useState(false);
|
|
2780
|
+
const [isUnderline, setIsUnderline] = React10.useState(false);
|
|
2781
|
+
const [isStrikethrough, setIsStrikethrough] = React10.useState(false);
|
|
2782
|
+
const [isSubscript, setIsSubscript] = React10.useState(false);
|
|
2783
|
+
const [isSuperscript, setIsSuperscript] = React10.useState(false);
|
|
2784
|
+
const [isCode, setIsCode] = React10.useState(false);
|
|
2785
2785
|
const isEditable = opts?.isEditable ?? editor.isEditable();
|
|
2786
2786
|
const portalContainer = useFloatingPortalContainer(editor);
|
|
2787
|
-
const updatePopupState =
|
|
2787
|
+
const updatePopupState = React10.useCallback(() => {
|
|
2788
2788
|
editor.getEditorState().read(() => {
|
|
2789
2789
|
const selection = lexical.$getSelection();
|
|
2790
2790
|
const nativeSelection = window.getSelection();
|
|
@@ -2816,7 +2816,7 @@ function useCharacterStylesPopup(editor, opts) {
|
|
|
2816
2816
|
}
|
|
2817
2817
|
});
|
|
2818
2818
|
}, [editor]);
|
|
2819
|
-
|
|
2819
|
+
React10.useEffect(() => {
|
|
2820
2820
|
document.addEventListener("selectionchange", updatePopupState);
|
|
2821
2821
|
document.addEventListener("focusin", updatePopupState);
|
|
2822
2822
|
return () => {
|
|
@@ -2824,7 +2824,7 @@ function useCharacterStylesPopup(editor, opts) {
|
|
|
2824
2824
|
document.removeEventListener("focusin", updatePopupState);
|
|
2825
2825
|
};
|
|
2826
2826
|
}, [updatePopupState]);
|
|
2827
|
-
|
|
2827
|
+
React10.useEffect(() => editor.registerUpdateListener(updatePopupState), [editor, updatePopupState]);
|
|
2828
2828
|
if (!portalContainer || !isText || isLink) return null;
|
|
2829
2829
|
return reactDom.createPortal(
|
|
2830
2830
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3107,8 +3107,8 @@ function splitHeadingsAtBrSequences(html) {
|
|
|
3107
3107
|
}
|
|
3108
3108
|
var CustomOnChangePlugin = ({ value, onChange }) => {
|
|
3109
3109
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
3110
|
-
const initializedRef =
|
|
3111
|
-
|
|
3110
|
+
const initializedRef = React10.useRef(false);
|
|
3111
|
+
React10.useEffect(() => {
|
|
3112
3112
|
if (!value || initializedRef.current) return;
|
|
3113
3113
|
initializedRef.current = true;
|
|
3114
3114
|
editor.update(() => {
|
|
@@ -3151,28 +3151,44 @@ var getSelectedNode2 = (selection$1) => {
|
|
|
3151
3151
|
};
|
|
3152
3152
|
var VERTICAL_GAP = 10;
|
|
3153
3153
|
var HORIZONTAL_OFFSET = 5;
|
|
3154
|
-
var
|
|
3155
|
-
|
|
3156
|
-
|
|
3154
|
+
var VIEWPORT_MARGIN = 8;
|
|
3155
|
+
function useFloatingPortalContainer2(editor) {
|
|
3156
|
+
const [container, setContainer] = React10.useState(null);
|
|
3157
|
+
React10.useEffect(() => {
|
|
3158
|
+
const root = editor.getRootElement();
|
|
3159
|
+
if (!root) return;
|
|
3160
|
+
const panelOrLayer = root.closest(".ms-Panel-main") || root.closest(".ms-Panel") || root.closest(".ms-Layer") || document.body;
|
|
3161
|
+
const host = document.createElement("div");
|
|
3162
|
+
host.className = "lexical-floating-ui-host";
|
|
3163
|
+
panelOrLayer.appendChild(host);
|
|
3164
|
+
setContainer(host);
|
|
3165
|
+
return () => {
|
|
3166
|
+
host.remove();
|
|
3167
|
+
setContainer(null);
|
|
3168
|
+
};
|
|
3169
|
+
}, [editor]);
|
|
3170
|
+
return container;
|
|
3171
|
+
}
|
|
3172
|
+
var setFloatingElemPositionForLinkEditor = (targetRect, floatingElem, topBoundary = VIEWPORT_MARGIN, verticalGap = VERTICAL_GAP, horizontalOffset = HORIZONTAL_OFFSET) => {
|
|
3173
|
+
if (targetRect === null) {
|
|
3157
3174
|
floatingElem.style.opacity = "0";
|
|
3158
3175
|
floatingElem.style.transform = "translate(-10000px, -10000px)";
|
|
3159
3176
|
return;
|
|
3160
3177
|
}
|
|
3161
3178
|
const floatingElemRect = floatingElem.getBoundingClientRect();
|
|
3162
|
-
|
|
3163
|
-
const editorScrollerRect = scrollerElem.getBoundingClientRect();
|
|
3164
|
-
let top = targetRect.top - verticalGap;
|
|
3179
|
+
let top = targetRect.bottom + verticalGap;
|
|
3165
3180
|
let left = targetRect.left - horizontalOffset;
|
|
3166
|
-
if (top
|
|
3167
|
-
top
|
|
3181
|
+
if (top + floatingElemRect.height > window.innerHeight - VIEWPORT_MARGIN) {
|
|
3182
|
+
top = targetRect.top - floatingElemRect.height - verticalGap;
|
|
3168
3183
|
}
|
|
3169
|
-
if (
|
|
3170
|
-
|
|
3184
|
+
if (top < topBoundary) {
|
|
3185
|
+
top = topBoundary;
|
|
3171
3186
|
}
|
|
3172
|
-
|
|
3173
|
-
left -= anchorElementRect.left;
|
|
3187
|
+
left = Math.max(VIEWPORT_MARGIN, Math.min(left, window.innerWidth - floatingElemRect.width - VIEWPORT_MARGIN));
|
|
3174
3188
|
floatingElem.style.opacity = "1";
|
|
3175
|
-
floatingElem.style.transform =
|
|
3189
|
+
floatingElem.style.transform = "none";
|
|
3190
|
+
floatingElem.style.top = `${top}px`;
|
|
3191
|
+
floatingElem.style.left = `${left}px`;
|
|
3176
3192
|
};
|
|
3177
3193
|
var SUPPORTED_URL_PROTOCOLS = /* @__PURE__ */ new Set([
|
|
3178
3194
|
"http:",
|
|
@@ -3195,13 +3211,13 @@ var sanitizeUrl = (url) => {
|
|
|
3195
3211
|
var preventDefault = (event) => {
|
|
3196
3212
|
event.preventDefault();
|
|
3197
3213
|
};
|
|
3198
|
-
var FloatingLinkEditor = ({ editor, isLink, setIsLink,
|
|
3199
|
-
const [editedLinkUrl, setEditedLinkUrl] =
|
|
3200
|
-
const [lastSelection, setLastSelection] =
|
|
3201
|
-
const [linkUrl, setLinkUrl] =
|
|
3202
|
-
const editorRef =
|
|
3203
|
-
const inputRef =
|
|
3204
|
-
const $updateLinkEditor =
|
|
3214
|
+
var FloatingLinkEditor = ({ editor, isLink, setIsLink, isLinkEditMode, setIsLinkEditMode }) => {
|
|
3215
|
+
const [editedLinkUrl, setEditedLinkUrl] = React10.useState("https://");
|
|
3216
|
+
const [lastSelection, setLastSelection] = React10.useState(null);
|
|
3217
|
+
const [linkUrl, setLinkUrl] = React10.useState("");
|
|
3218
|
+
const editorRef = React10.useRef(null);
|
|
3219
|
+
const inputRef = React10.useRef(null);
|
|
3220
|
+
const $updateLinkEditor = React10.useCallback(() => {
|
|
3205
3221
|
const selection = lexical.$getSelection();
|
|
3206
3222
|
if (lexical.$isRangeSelection(selection)) {
|
|
3207
3223
|
const node = getSelectedNode2(selection);
|
|
@@ -3227,39 +3243,38 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, anchorElem, isLinkEditMod
|
|
|
3227
3243
|
if (isLink && selection !== null && nativeSelection !== null && rootElement !== null && rootElement.contains(nativeSelection.anchorNode) && editor.isEditable()) {
|
|
3228
3244
|
const domRect = nativeSelection.focusNode?.parentElement?.getBoundingClientRect();
|
|
3229
3245
|
if (domRect) {
|
|
3230
|
-
|
|
3231
|
-
|
|
3246
|
+
const toolbarEl = rootElement.closest(".lexical-rich-editor-root")?.querySelector(".editor-toolbar-root");
|
|
3247
|
+
const topBoundary = toolbarEl ? toolbarEl.getBoundingClientRect().bottom + 8 : 8;
|
|
3248
|
+
setFloatingElemPositionForLinkEditor(domRect, editorElem, topBoundary);
|
|
3232
3249
|
}
|
|
3233
3250
|
setLastSelection(selection);
|
|
3234
3251
|
} else if (!activeElement || activeElement.className !== "aoLinkInput") {
|
|
3235
3252
|
if (rootElement !== null) {
|
|
3236
|
-
setFloatingElemPositionForLinkEditor(null, editorElem
|
|
3253
|
+
setFloatingElemPositionForLinkEditor(null, editorElem);
|
|
3237
3254
|
}
|
|
3238
3255
|
setLastSelection(null);
|
|
3239
3256
|
setIsLinkEditMode(false);
|
|
3240
3257
|
setLinkUrl("");
|
|
3241
3258
|
}
|
|
3242
3259
|
return true;
|
|
3243
|
-
}, [
|
|
3244
|
-
|
|
3245
|
-
const scrollerElem = anchorElem.parentElement;
|
|
3260
|
+
}, [editor, setIsLinkEditMode, isLinkEditMode, isLink, linkUrl]);
|
|
3261
|
+
React10.useEffect(() => {
|
|
3246
3262
|
const update = () => {
|
|
3247
3263
|
editor.getEditorState().read(() => {
|
|
3248
3264
|
$updateLinkEditor();
|
|
3249
3265
|
});
|
|
3250
3266
|
};
|
|
3267
|
+
const root = editor.getRootElement();
|
|
3251
3268
|
window.addEventListener("resize", update);
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
}
|
|
3269
|
+
window.addEventListener("scroll", update, true);
|
|
3270
|
+
root?.addEventListener("scroll", update, { passive: true });
|
|
3255
3271
|
return () => {
|
|
3256
3272
|
window.removeEventListener("resize", update);
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
}
|
|
3273
|
+
window.removeEventListener("scroll", update, true);
|
|
3274
|
+
root?.removeEventListener("scroll", update);
|
|
3260
3275
|
};
|
|
3261
|
-
}, [
|
|
3262
|
-
|
|
3276
|
+
}, [editor, $updateLinkEditor]);
|
|
3277
|
+
React10.useEffect(() => {
|
|
3263
3278
|
return utils.mergeRegister(
|
|
3264
3279
|
editor.registerUpdateListener(({ editorState }) => {
|
|
3265
3280
|
editorState.read(() => {
|
|
@@ -3287,12 +3302,12 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, anchorElem, isLinkEditMod
|
|
|
3287
3302
|
)
|
|
3288
3303
|
);
|
|
3289
3304
|
}, [editor, $updateLinkEditor, setIsLink, isLink]);
|
|
3290
|
-
|
|
3305
|
+
React10.useEffect(() => {
|
|
3291
3306
|
editor.getEditorState().read(() => {
|
|
3292
3307
|
$updateLinkEditor();
|
|
3293
3308
|
});
|
|
3294
3309
|
}, [editor, $updateLinkEditor]);
|
|
3295
|
-
|
|
3310
|
+
React10.useEffect(() => {
|
|
3296
3311
|
if (isLinkEditMode && inputRef.current) {
|
|
3297
3312
|
inputRef.current.focus();
|
|
3298
3313
|
}
|
|
@@ -3422,9 +3437,10 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, anchorElem, isLinkEditMod
|
|
|
3422
3437
|
] }) });
|
|
3423
3438
|
};
|
|
3424
3439
|
var useFloatingLinkEditorToolbar = (editor, anchorElem, isLinkEditMode, setIsLinkEditMode) => {
|
|
3425
|
-
const [activeEditor, setActiveEditor] =
|
|
3426
|
-
const [isLink, setIsLink] =
|
|
3427
|
-
|
|
3440
|
+
const [activeEditor, setActiveEditor] = React10.useState(editor);
|
|
3441
|
+
const [isLink, setIsLink] = React10.useState(false);
|
|
3442
|
+
const portalContainer = useFloatingPortalContainer2(editor);
|
|
3443
|
+
React10.useEffect(() => {
|
|
3428
3444
|
function $updateToolbar() {
|
|
3429
3445
|
const selection = lexical.$getSelection();
|
|
3430
3446
|
if (lexical.$isRangeSelection(selection)) {
|
|
@@ -3471,7 +3487,7 @@ var useFloatingLinkEditorToolbar = (editor, anchorElem, isLinkEditMode, setIsLin
|
|
|
3471
3487
|
)
|
|
3472
3488
|
);
|
|
3473
3489
|
}, [editor]);
|
|
3474
|
-
if (!anchorElem || !(anchorElem instanceof HTMLElement)) {
|
|
3490
|
+
if (!anchorElem || !(anchorElem instanceof HTMLElement) || !portalContainer) {
|
|
3475
3491
|
return null;
|
|
3476
3492
|
}
|
|
3477
3493
|
return reactDom.createPortal(
|
|
@@ -3481,12 +3497,11 @@ var useFloatingLinkEditorToolbar = (editor, anchorElem, isLinkEditMode, setIsLin
|
|
|
3481
3497
|
isLink,
|
|
3482
3498
|
editor: activeEditor,
|
|
3483
3499
|
setIsLink,
|
|
3484
|
-
anchorElem,
|
|
3485
3500
|
isLinkEditMode,
|
|
3486
3501
|
setIsLinkEditMode
|
|
3487
3502
|
}
|
|
3488
3503
|
),
|
|
3489
|
-
|
|
3504
|
+
portalContainer
|
|
3490
3505
|
);
|
|
3491
3506
|
};
|
|
3492
3507
|
var FloatingLinkEditorPlugin = ({ anchorElem, isLinkEditMode, setIsLinkEditMode }) => {
|
|
@@ -3499,6 +3514,61 @@ var FloatingLinkEditorPlugin = ({ anchorElem, isLinkEditMode, setIsLinkEditMode
|
|
|
3499
3514
|
setIsLinkEditMode
|
|
3500
3515
|
);
|
|
3501
3516
|
};
|
|
3517
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React10__namespace.useLayoutEffect : React10__namespace.useEffect;
|
|
3518
|
+
var AoModal = ({
|
|
3519
|
+
isOpen,
|
|
3520
|
+
onDismiss,
|
|
3521
|
+
title,
|
|
3522
|
+
maxWidth = 280,
|
|
3523
|
+
// Default to a smaller, compact size
|
|
3524
|
+
actions,
|
|
3525
|
+
children
|
|
3526
|
+
}) => {
|
|
3527
|
+
const [hostElement, setHostElement] = React10__namespace.useState(null);
|
|
3528
|
+
const mountRef = React10__namespace.useRef(null);
|
|
3529
|
+
useIsomorphicLayoutEffect(() => {
|
|
3530
|
+
if (isOpen && mountRef.current) {
|
|
3531
|
+
const root = mountRef.current.closest(".lexical-rich-editor-root");
|
|
3532
|
+
if (root) {
|
|
3533
|
+
setHostElement(root);
|
|
3534
|
+
} else {
|
|
3535
|
+
setHostElement(mountRef.current.parentElement);
|
|
3536
|
+
}
|
|
3537
|
+
}
|
|
3538
|
+
}, [isOpen]);
|
|
3539
|
+
if (!isOpen) return null;
|
|
3540
|
+
const modalContent = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aoModalBackdrop", onClick: onDismiss, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3541
|
+
reactComponents.FluentProvider,
|
|
3542
|
+
{
|
|
3543
|
+
theme: reactComponents.webLightTheme,
|
|
3544
|
+
className: "aoModalWrapper aoModalContainer",
|
|
3545
|
+
style: { maxWidth, width: "90vw" },
|
|
3546
|
+
onClick: (e) => e.stopPropagation(),
|
|
3547
|
+
children: [
|
|
3548
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "aoModalHeader", children: [
|
|
3549
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "aoModalTitle", children: title }),
|
|
3550
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3551
|
+
"button",
|
|
3552
|
+
{
|
|
3553
|
+
className: "aoModalCloseButton",
|
|
3554
|
+
"aria-label": "Close popup",
|
|
3555
|
+
onClick: onDismiss,
|
|
3556
|
+
children: "\u2715"
|
|
3557
|
+
}
|
|
3558
|
+
)
|
|
3559
|
+
] }),
|
|
3560
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "aoModalBody", children }),
|
|
3561
|
+
actions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aoModalActions", children: actions })
|
|
3562
|
+
]
|
|
3563
|
+
}
|
|
3564
|
+
) });
|
|
3565
|
+
if (hostElement) {
|
|
3566
|
+
return reactDom.createPortal(modalContent, hostElement);
|
|
3567
|
+
}
|
|
3568
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: mountRef, style: { display: "none" } });
|
|
3569
|
+
};
|
|
3570
|
+
|
|
3571
|
+
// src/Plugins/ImagePlugin.tsx
|
|
3502
3572
|
init_ImageNode();
|
|
3503
3573
|
var INSERT_IMAGE_COMMAND = lexical.createCommand("INSERT_IMAGE_COMMAND");
|
|
3504
3574
|
var readClipboardImageAsDataURL = async (event) => {
|
|
@@ -3522,8 +3592,8 @@ var InsertImageByURL = ({
|
|
|
3522
3592
|
onClick,
|
|
3523
3593
|
disabled
|
|
3524
3594
|
}) => {
|
|
3525
|
-
const [altText, setAltText] =
|
|
3526
|
-
const [src, setSrc] =
|
|
3595
|
+
const [altText, setAltText] = React10.useState("");
|
|
3596
|
+
const [src, setSrc] = React10.useState("");
|
|
3527
3597
|
const isDisabled = disabled || src === "";
|
|
3528
3598
|
return /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { tokens: { childrenGap: 6, padding: "10px 0px 0px 0px" }, children: [
|
|
3529
3599
|
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Field, { label: "Enter URL", size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3579,16 +3649,16 @@ var InsertImageDialog = ({
|
|
|
3579
3649
|
maxImageSizeMB,
|
|
3580
3650
|
validationMessages
|
|
3581
3651
|
}) => {
|
|
3582
|
-
const [src, setSrc] =
|
|
3583
|
-
const [altText, setAltText] =
|
|
3584
|
-
const [isOpen, setIsOpen] =
|
|
3585
|
-
const [selectedValue, setSelectedValue] =
|
|
3586
|
-
const [fileName, setFileName] =
|
|
3587
|
-
const [fileSizeError, setFileSizeError] =
|
|
3588
|
-
const hasModifier =
|
|
3652
|
+
const [src, setSrc] = React10.useState("");
|
|
3653
|
+
const [altText, setAltText] = React10.useState("");
|
|
3654
|
+
const [isOpen, setIsOpen] = React10.useState(false);
|
|
3655
|
+
const [selectedValue, setSelectedValue] = React10.useState("Upload");
|
|
3656
|
+
const [fileName, setFileName] = React10.useState("");
|
|
3657
|
+
const [fileSizeError, setFileSizeError] = React10.useState(null);
|
|
3658
|
+
const hasModifier = React10.useRef(false);
|
|
3589
3659
|
const iconColor = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
|
|
3590
3660
|
const isDisabled = disabled || src === "" || !!fileSizeError;
|
|
3591
|
-
|
|
3661
|
+
React10.useEffect(() => {
|
|
3592
3662
|
hasModifier.current = false;
|
|
3593
3663
|
const handler = (e) => {
|
|
3594
3664
|
hasModifier.current = e.altKey;
|
|
@@ -3632,112 +3702,109 @@ var InsertImageDialog = ({
|
|
|
3632
3702
|
};
|
|
3633
3703
|
reader.readAsDataURL(file);
|
|
3634
3704
|
};
|
|
3635
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3705
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3706
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3707
|
+
reactComponents.Button,
|
|
3708
|
+
{
|
|
3709
|
+
size: "small",
|
|
3710
|
+
title: "Add Image",
|
|
3711
|
+
disabled,
|
|
3712
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(reactIcons.ImageAddRegular, { style: { color: iconColor } }),
|
|
3713
|
+
style: {
|
|
3714
|
+
background: isOpen && !disabled ? "#ebebeb" : "none",
|
|
3715
|
+
border: "none",
|
|
3716
|
+
margin: 2,
|
|
3717
|
+
opacity: disabled ? 0.55 : 1,
|
|
3718
|
+
cursor: disabled ? "not-allowed" : "pointer"
|
|
3719
|
+
},
|
|
3720
|
+
onClick: () => {
|
|
3721
|
+
if (disabled) return;
|
|
3722
|
+
setIsOpen((prev) => !prev);
|
|
3723
|
+
setSrc("");
|
|
3724
|
+
setAltText("");
|
|
3725
|
+
setFileName("");
|
|
3726
|
+
}
|
|
3641
3727
|
},
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
},
|
|
3680
|
-
children: [
|
|
3728
|
+
"upload-image"
|
|
3729
|
+
),
|
|
3730
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3731
|
+
AoModal,
|
|
3732
|
+
{
|
|
3733
|
+
isOpen: disabled ? false : isOpen,
|
|
3734
|
+
onDismiss: () => !disabled && setIsOpen(false),
|
|
3735
|
+
title: "Insert image",
|
|
3736
|
+
maxWidth: 340,
|
|
3737
|
+
actions: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3738
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Button, { size: "small", disabled: isDisabled, onClick: () => onClick({ altText, src }), children: "Add" }),
|
|
3739
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Button, { size: "small", disabled, onClick: () => setIsOpen(false), children: "Cancel" })
|
|
3740
|
+
] }),
|
|
3741
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { tokens: { childrenGap: 8 }, children: [
|
|
3742
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Field, { label: "Upload", size: "small", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3743
|
+
"label",
|
|
3744
|
+
{
|
|
3745
|
+
style: {
|
|
3746
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
3747
|
+
display: "flex",
|
|
3748
|
+
alignItems: "center",
|
|
3749
|
+
gap: 8,
|
|
3750
|
+
opacity: disabled ? 0.75 : 1
|
|
3751
|
+
},
|
|
3752
|
+
children: [
|
|
3753
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3754
|
+
"input",
|
|
3755
|
+
{
|
|
3756
|
+
type: "file",
|
|
3757
|
+
accept: "image/*",
|
|
3758
|
+
style: { display: "none" },
|
|
3759
|
+
disabled,
|
|
3760
|
+
onChange: loadImage
|
|
3761
|
+
},
|
|
3762
|
+
"inline-image-upload"
|
|
3763
|
+
),
|
|
3764
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { horizontal: true, children: [
|
|
3681
3765
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3682
|
-
|
|
3766
|
+
reactIcons.AttachFilled,
|
|
3683
3767
|
{
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
onChange: loadImage
|
|
3689
|
-
},
|
|
3690
|
-
"inline-image-upload"
|
|
3691
|
-
),
|
|
3692
|
-
/* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { horizontal: true, children: [
|
|
3693
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3694
|
-
reactIcons.AttachFilled,
|
|
3695
|
-
{
|
|
3696
|
-
style: {
|
|
3697
|
-
fontSize: "16px",
|
|
3698
|
-
color: disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#808080",
|
|
3699
|
-
marginTop: 2
|
|
3700
|
-
}
|
|
3768
|
+
style: {
|
|
3769
|
+
fontSize: "16px",
|
|
3770
|
+
color: disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#808080",
|
|
3771
|
+
marginTop: 2
|
|
3701
3772
|
}
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
] }) })
|
|
3734
|
-
]
|
|
3735
|
-
}
|
|
3736
|
-
);
|
|
3773
|
+
}
|
|
3774
|
+
),
|
|
3775
|
+
!fileName && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 12, color: "#808080" }, children: "Upload File" })
|
|
3776
|
+
] }),
|
|
3777
|
+
fileName && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 12, color: "#808080" }, children: fileName })
|
|
3778
|
+
]
|
|
3779
|
+
}
|
|
3780
|
+
) }),
|
|
3781
|
+
fileSizeError && /* @__PURE__ */ jsxRuntime.jsx(reactComponents.MessageBar, { intent: "error", style: { marginTop: 4 }, children: /* @__PURE__ */ jsxRuntime.jsx(reactComponents.MessageBarBody, { children: fileSizeError }) }),
|
|
3782
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Field, { label: "Alt Text", size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3783
|
+
reactComponents.Input,
|
|
3784
|
+
{
|
|
3785
|
+
placeholder: "Alt text",
|
|
3786
|
+
appearance: "underline",
|
|
3787
|
+
disabled,
|
|
3788
|
+
onChange: (_, d) => setAltText(d.value),
|
|
3789
|
+
value: altText
|
|
3790
|
+
}
|
|
3791
|
+
) }),
|
|
3792
|
+
selectedValue === "URL" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3793
|
+
InsertImageByURL,
|
|
3794
|
+
{
|
|
3795
|
+
disabled,
|
|
3796
|
+
setIsOpen: (open) => setIsOpen(open),
|
|
3797
|
+
onClick: (payload) => onClick(payload)
|
|
3798
|
+
}
|
|
3799
|
+
)
|
|
3800
|
+
] })
|
|
3801
|
+
}
|
|
3802
|
+
)
|
|
3803
|
+
] });
|
|
3737
3804
|
};
|
|
3738
3805
|
var ImagesPlugin = ({ captionsEnabled }) => {
|
|
3739
3806
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
3740
|
-
|
|
3807
|
+
React10.useEffect(() => {
|
|
3741
3808
|
if (!editor.hasNodes([ImageNode])) {
|
|
3742
3809
|
throw new Error("ImagesPlugin: ImageNode not registered on editor");
|
|
3743
3810
|
}
|
|
@@ -3929,13 +3996,13 @@ var InsertInlineImageDialog = ({
|
|
|
3929
3996
|
maxImageSizeMB,
|
|
3930
3997
|
validationMessages
|
|
3931
3998
|
}) => {
|
|
3932
|
-
const hasModifier =
|
|
3933
|
-
const [src, setSrc] =
|
|
3934
|
-
const [isOpen, setIsOpen] =
|
|
3935
|
-
const [altText, setAltText] =
|
|
3936
|
-
const [fileName, setFileName] =
|
|
3937
|
-
const [position, setPosition] =
|
|
3938
|
-
const [fileSizeError, setFileSizeError] =
|
|
3999
|
+
const hasModifier = React10.useRef(false);
|
|
4000
|
+
const [src, setSrc] = React10.useState("");
|
|
4001
|
+
const [isOpen, setIsOpen] = React10.useState(false);
|
|
4002
|
+
const [altText, setAltText] = React10.useState("");
|
|
4003
|
+
const [fileName, setFileName] = React10.useState("");
|
|
4004
|
+
const [position, setPosition] = React10.useState("left");
|
|
4005
|
+
const [fileSizeError, setFileSizeError] = React10.useState(null);
|
|
3939
4006
|
const styles = useStyles();
|
|
3940
4007
|
const iconColor = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
|
|
3941
4008
|
const isDisabled = disabled || src === "" || !!fileSizeError;
|
|
@@ -3966,7 +4033,7 @@ var InsertInlineImageDialog = ({
|
|
|
3966
4033
|
};
|
|
3967
4034
|
reader.readAsDataURL(file);
|
|
3968
4035
|
};
|
|
3969
|
-
|
|
4036
|
+
React10.useEffect(() => {
|
|
3970
4037
|
const handler = (e) => {
|
|
3971
4038
|
hasModifier.current = e.altKey;
|
|
3972
4039
|
};
|
|
@@ -3983,139 +4050,136 @@ var InsertInlineImageDialog = ({
|
|
|
3983
4050
|
setFileName("");
|
|
3984
4051
|
setFileSizeError(null);
|
|
3985
4052
|
};
|
|
3986
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
4053
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4054
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4055
|
+
reactComponents.Button,
|
|
4056
|
+
{
|
|
4057
|
+
size: "small",
|
|
4058
|
+
title: "Add Inline Image",
|
|
4059
|
+
disabled,
|
|
4060
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(reactIcons.ImageEditRegular, { style: { color: iconColor } }),
|
|
4061
|
+
style: {
|
|
4062
|
+
background: isOpen && !disabled ? "#ebebeb" : "none",
|
|
4063
|
+
border: "none",
|
|
4064
|
+
margin: 2,
|
|
4065
|
+
opacity: disabled ? 0.55 : 1,
|
|
4066
|
+
cursor: disabled ? "not-allowed" : "pointer"
|
|
4067
|
+
},
|
|
4068
|
+
onClick: () => {
|
|
4069
|
+
if (disabled) return;
|
|
4070
|
+
setIsOpen((prev) => !prev);
|
|
4071
|
+
setAltText("");
|
|
4072
|
+
setSrc("");
|
|
4073
|
+
setFileName("");
|
|
4074
|
+
}
|
|
3992
4075
|
},
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4076
|
+
"upload-inline-image"
|
|
4077
|
+
),
|
|
4078
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4079
|
+
AoModal,
|
|
4080
|
+
{
|
|
4081
|
+
isOpen: disabled ? false : isOpen,
|
|
4082
|
+
onDismiss: () => !disabled && setIsOpen(false),
|
|
4083
|
+
title: "Insert inline image",
|
|
4084
|
+
maxWidth: 360,
|
|
4085
|
+
actions: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4086
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4087
|
+
reactComponents.Button,
|
|
4088
|
+
{
|
|
4089
|
+
size: "small",
|
|
4090
|
+
disabled: isDisabled,
|
|
4091
|
+
onClick: handleOnClick,
|
|
4092
|
+
children: "Add"
|
|
4007
4093
|
},
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4094
|
+
"file-inline-upload-btn"
|
|
4095
|
+
),
|
|
4096
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4097
|
+
reactComponents.Button,
|
|
4098
|
+
{
|
|
4099
|
+
size: "small",
|
|
4100
|
+
disabled,
|
|
4101
|
+
onClick: () => setIsOpen(false),
|
|
4102
|
+
children: "Cancel"
|
|
4103
|
+
},
|
|
4104
|
+
"file-inline-upload-cancel"
|
|
4105
|
+
)
|
|
4106
|
+
] }),
|
|
4107
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { tokens: { childrenGap: 8 }, children: [
|
|
4108
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Field, { label: "Upload", size: "small", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4109
|
+
"label",
|
|
4110
|
+
{
|
|
4111
|
+
style: {
|
|
4112
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
4113
|
+
display: "flex",
|
|
4114
|
+
alignItems: "center",
|
|
4115
|
+
gap: 8,
|
|
4116
|
+
opacity: disabled ? 0.75 : 1
|
|
4117
|
+
},
|
|
4118
|
+
children: [
|
|
4119
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4120
|
+
"input",
|
|
4121
|
+
{
|
|
4122
|
+
type: "file",
|
|
4123
|
+
accept: "image/*",
|
|
4124
|
+
style: { display: "none" },
|
|
4125
|
+
disabled,
|
|
4126
|
+
onChange: loadImage
|
|
4127
|
+
},
|
|
4128
|
+
"inline-image-upload"
|
|
4129
|
+
),
|
|
4130
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { horizontal: true, children: [
|
|
4032
4131
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4033
|
-
|
|
4132
|
+
reactIcons.AttachFilled,
|
|
4034
4133
|
{
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
onChange: loadImage
|
|
4040
|
-
},
|
|
4041
|
-
"inline-image-upload"
|
|
4042
|
-
),
|
|
4043
|
-
/* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { horizontal: true, children: [
|
|
4044
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4045
|
-
reactIcons.AttachFilled,
|
|
4046
|
-
{
|
|
4047
|
-
style: {
|
|
4048
|
-
fontSize: "16px",
|
|
4049
|
-
color: disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#808080",
|
|
4050
|
-
marginTop: 2
|
|
4051
|
-
}
|
|
4134
|
+
style: {
|
|
4135
|
+
fontSize: "16px",
|
|
4136
|
+
color: disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#808080",
|
|
4137
|
+
marginTop: 2
|
|
4052
4138
|
}
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
size: "small",
|
|
4094
|
-
disabled: isDisabled,
|
|
4095
|
-
onClick: handleOnClick,
|
|
4096
|
-
children: "Add"
|
|
4097
|
-
},
|
|
4098
|
-
"file-inline-upload-btn"
|
|
4099
|
-
),
|
|
4100
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4101
|
-
reactComponents.Button,
|
|
4102
|
-
{
|
|
4103
|
-
size: "small",
|
|
4104
|
-
disabled,
|
|
4105
|
-
onClick: () => setIsOpen(false),
|
|
4106
|
-
children: "Cancel"
|
|
4107
|
-
},
|
|
4108
|
-
"file-inline-upload-cancel"
|
|
4109
|
-
)
|
|
4110
|
-
] })
|
|
4111
|
-
] }) })
|
|
4112
|
-
]
|
|
4113
|
-
}
|
|
4114
|
-
);
|
|
4139
|
+
}
|
|
4140
|
+
),
|
|
4141
|
+
!fileName && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 12, color: "#808080" }, children: "Upload File" })
|
|
4142
|
+
] }),
|
|
4143
|
+
fileName && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 12, color: "#808080" }, children: fileName })
|
|
4144
|
+
]
|
|
4145
|
+
}
|
|
4146
|
+
) }),
|
|
4147
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Field, { label: "Position", size: "small", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4148
|
+
reactComponents.Dropdown,
|
|
4149
|
+
{
|
|
4150
|
+
className: styles.alignDropdown,
|
|
4151
|
+
disabled,
|
|
4152
|
+
value: position === "full" ? "Full" : position === "right" ? "Right" : "Left",
|
|
4153
|
+
selectedOptions: [position ?? "left"],
|
|
4154
|
+
listbox: { style: { width: "120px" } },
|
|
4155
|
+
root: { style: { borderBottom: "1px solid black" } },
|
|
4156
|
+
onOptionSelect: (_, data) => setPosition(data.optionValue),
|
|
4157
|
+
children: [
|
|
4158
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Option, { value: "left", children: "Left" }, "left"),
|
|
4159
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Option, { value: "right", children: "Right" }, "right"),
|
|
4160
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Option, { value: "full", children: "Full" }, "full")
|
|
4161
|
+
]
|
|
4162
|
+
}
|
|
4163
|
+
) }),
|
|
4164
|
+
fileSizeError && /* @__PURE__ */ jsxRuntime.jsx(reactComponents.MessageBar, { intent: "error", style: { marginTop: 4 }, children: /* @__PURE__ */ jsxRuntime.jsx(reactComponents.MessageBarBody, { children: fileSizeError }) }),
|
|
4165
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Field, { label: "Alt Text", size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4166
|
+
reactComponents.Input,
|
|
4167
|
+
{
|
|
4168
|
+
placeholder: "Alt text",
|
|
4169
|
+
appearance: "underline",
|
|
4170
|
+
disabled,
|
|
4171
|
+
value: altText,
|
|
4172
|
+
onChange: (_, d) => setAltText(d.value)
|
|
4173
|
+
}
|
|
4174
|
+
) })
|
|
4175
|
+
] })
|
|
4176
|
+
}
|
|
4177
|
+
)
|
|
4178
|
+
] });
|
|
4115
4179
|
};
|
|
4116
4180
|
var InlineImagePlugin = () => {
|
|
4117
4181
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
4118
|
-
|
|
4182
|
+
React10.useEffect(() => {
|
|
4119
4183
|
if (!editor.hasNodes([InlineImageNode])) {
|
|
4120
4184
|
throw new Error("ImagesPlugin: ImageNode not registered on editor");
|
|
4121
4185
|
}
|
|
@@ -4258,7 +4322,7 @@ var getDragSelection2 = (event) => {
|
|
|
4258
4322
|
var INSERT_PAGE_BREAK = lexical.createCommand();
|
|
4259
4323
|
function PageBreakPlugin() {
|
|
4260
4324
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
4261
|
-
|
|
4325
|
+
React10.useEffect(() => {
|
|
4262
4326
|
if (!editor.hasNodes([PageBreakNode])) {
|
|
4263
4327
|
throw new Error(
|
|
4264
4328
|
"PageBreakPlugin: PageBreakNode is not registered on editor"
|
|
@@ -4374,8 +4438,8 @@ function RefApiPlugin({
|
|
|
4374
4438
|
focusedRef
|
|
4375
4439
|
}) {
|
|
4376
4440
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
4377
|
-
const cleanBaselineRef =
|
|
4378
|
-
|
|
4441
|
+
const cleanBaselineRef = React10__namespace.default.useRef(null);
|
|
4442
|
+
React10__namespace.default.useEffect(() => {
|
|
4379
4443
|
const capture = () => {
|
|
4380
4444
|
if (cleanBaselineRef.current === null) {
|
|
4381
4445
|
cleanBaselineRef.current = getUserContentSignature(editor);
|
|
@@ -4396,7 +4460,7 @@ function RefApiPlugin({
|
|
|
4396
4460
|
unregister();
|
|
4397
4461
|
};
|
|
4398
4462
|
}, [editor]);
|
|
4399
|
-
|
|
4463
|
+
React10.useImperativeHandle(
|
|
4400
4464
|
forwardedRef,
|
|
4401
4465
|
() => ({
|
|
4402
4466
|
setValue: (html$1) => {
|
|
@@ -4589,28 +4653,28 @@ function SpellPopover({
|
|
|
4589
4653
|
onImprove,
|
|
4590
4654
|
onAcceptGrammar
|
|
4591
4655
|
}) {
|
|
4592
|
-
const ref =
|
|
4656
|
+
const ref = React10__namespace.useRef(null);
|
|
4593
4657
|
const type = state.issue.type ?? "spelling";
|
|
4594
|
-
const [pos, setPos] =
|
|
4595
|
-
|
|
4658
|
+
const [pos, setPos] = React10__namespace.useState({ left: state.x, top: state.y });
|
|
4659
|
+
React10__namespace.useEffect(() => {
|
|
4596
4660
|
if (!ref.current) return;
|
|
4597
4661
|
const { offsetHeight: h, offsetWidth: w } = ref.current;
|
|
4598
4662
|
const top = state.y + h > window.innerHeight - 8 ? state.y - h - 32 : state.y;
|
|
4599
4663
|
setPos({ left: Math.min(state.x, window.innerWidth - w - 8), top });
|
|
4600
4664
|
}, [state.x, state.y]);
|
|
4601
|
-
|
|
4665
|
+
React10__namespace.useEffect(() => {
|
|
4602
4666
|
const h = (e) => {
|
|
4603
4667
|
if (ref.current && !ref.current.contains(e.target)) onClose();
|
|
4604
4668
|
};
|
|
4605
4669
|
document.addEventListener("mousedown", h, true);
|
|
4606
4670
|
return () => document.removeEventListener("mousedown", h, true);
|
|
4607
4671
|
}, [onClose]);
|
|
4608
|
-
|
|
4672
|
+
React10__namespace.useEffect(() => {
|
|
4609
4673
|
const h = () => onClose();
|
|
4610
4674
|
window.addEventListener("scroll", h, { capture: true, passive: true });
|
|
4611
4675
|
return () => window.removeEventListener("scroll", h, true);
|
|
4612
4676
|
}, [onClose]);
|
|
4613
|
-
|
|
4677
|
+
React10__namespace.useEffect(() => {
|
|
4614
4678
|
const h = (e) => {
|
|
4615
4679
|
if (e.key === "Escape") onClose();
|
|
4616
4680
|
};
|
|
@@ -4727,17 +4791,17 @@ function SpellCheckPlugin({
|
|
|
4727
4791
|
enabled = true
|
|
4728
4792
|
}) {
|
|
4729
4793
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
4730
|
-
const timerRef =
|
|
4731
|
-
const dismissRef =
|
|
4732
|
-
const reqIdRef =
|
|
4733
|
-
const lastTextRef =
|
|
4734
|
-
const applyingRef =
|
|
4735
|
-
const grammarCorrectionRef =
|
|
4736
|
-
const [popover, setPopover] =
|
|
4737
|
-
|
|
4794
|
+
const timerRef = React10__namespace.useRef(null);
|
|
4795
|
+
const dismissRef = React10__namespace.useRef(null);
|
|
4796
|
+
const reqIdRef = React10__namespace.useRef(0);
|
|
4797
|
+
const lastTextRef = React10__namespace.useRef("");
|
|
4798
|
+
const applyingRef = React10__namespace.useRef(false);
|
|
4799
|
+
const grammarCorrectionRef = React10__namespace.useRef(void 0);
|
|
4800
|
+
const [popover, setPopover] = React10__namespace.useState(null);
|
|
4801
|
+
React10__namespace.useEffect(() => {
|
|
4738
4802
|
injectCSS();
|
|
4739
4803
|
}, []);
|
|
4740
|
-
const clearErrors =
|
|
4804
|
+
const clearErrors = React10__namespace.useCallback(() => {
|
|
4741
4805
|
setPopover(null);
|
|
4742
4806
|
grammarCorrectionRef.current = void 0;
|
|
4743
4807
|
applyingRef.current = true;
|
|
@@ -4753,7 +4817,7 @@ function SpellCheckPlugin({
|
|
|
4753
4817
|
}
|
|
4754
4818
|
);
|
|
4755
4819
|
}, [editor]);
|
|
4756
|
-
const applyIssues =
|
|
4820
|
+
const applyIssues = React10__namespace.useCallback(
|
|
4757
4821
|
(issues, improvedText, trimOffset = 0) => {
|
|
4758
4822
|
let savedCharOffset = -1;
|
|
4759
4823
|
editor.getEditorState().read(() => {
|
|
@@ -4896,7 +4960,7 @@ function SpellCheckPlugin({
|
|
|
4896
4960
|
},
|
|
4897
4961
|
[editor]
|
|
4898
4962
|
);
|
|
4899
|
-
|
|
4963
|
+
React10__namespace.useEffect(() => {
|
|
4900
4964
|
let currentRoot = null;
|
|
4901
4965
|
const onClick = (e) => {
|
|
4902
4966
|
const span = e.target.closest("[data-spell-offset]");
|
|
@@ -4940,7 +5004,7 @@ function SpellCheckPlugin({
|
|
|
4940
5004
|
if (currentRoot) currentRoot.removeEventListener("click", onClick);
|
|
4941
5005
|
};
|
|
4942
5006
|
}, [editor]);
|
|
4943
|
-
const handleAccept =
|
|
5007
|
+
const handleAccept = React10__namespace.useCallback(
|
|
4944
5008
|
(replacement, nodeKey) => {
|
|
4945
5009
|
let original = "";
|
|
4946
5010
|
editor.getEditorState().read(() => {
|
|
@@ -4966,7 +5030,7 @@ function SpellCheckPlugin({
|
|
|
4966
5030
|
},
|
|
4967
5031
|
[editor, onSpellCheckAccept, popover]
|
|
4968
5032
|
);
|
|
4969
|
-
const handleDismiss =
|
|
5033
|
+
const handleDismiss = React10__namespace.useCallback(
|
|
4970
5034
|
(nodeKey) => {
|
|
4971
5035
|
editor.update(
|
|
4972
5036
|
() => {
|
|
@@ -4980,7 +5044,7 @@ function SpellCheckPlugin({
|
|
|
4980
5044
|
},
|
|
4981
5045
|
[editor]
|
|
4982
5046
|
);
|
|
4983
|
-
const handleImprove =
|
|
5047
|
+
const handleImprove = React10__namespace.useCallback(
|
|
4984
5048
|
(text) => {
|
|
4985
5049
|
const original = lastTextRef.current;
|
|
4986
5050
|
applyingRef.current = true;
|
|
@@ -5000,7 +5064,7 @@ function SpellCheckPlugin({
|
|
|
5000
5064
|
},
|
|
5001
5065
|
[editor, onSpellCheckAccept]
|
|
5002
5066
|
);
|
|
5003
|
-
const handleAcceptGrammar =
|
|
5067
|
+
const handleAcceptGrammar = React10__namespace.useCallback(
|
|
5004
5068
|
(corrected) => {
|
|
5005
5069
|
const original = lastTextRef.current;
|
|
5006
5070
|
applyingRef.current = true;
|
|
@@ -5020,7 +5084,7 @@ function SpellCheckPlugin({
|
|
|
5020
5084
|
},
|
|
5021
5085
|
[editor, onSpellCheckAccept]
|
|
5022
5086
|
);
|
|
5023
|
-
|
|
5087
|
+
React10__namespace.useEffect(() => {
|
|
5024
5088
|
if (!enabled || !useSpellCheck) return;
|
|
5025
5089
|
return editor.registerUpdateListener(({ tags }) => {
|
|
5026
5090
|
if (applyingRef.current) return;
|
|
@@ -5058,13 +5122,13 @@ function SpellCheckPlugin({
|
|
|
5058
5122
|
}, idleMs);
|
|
5059
5123
|
});
|
|
5060
5124
|
}, [editor, useSpellCheck, enabled, idleMs, applyIssues, clearErrors]);
|
|
5061
|
-
|
|
5125
|
+
React10__namespace.useEffect(() => {
|
|
5062
5126
|
if (!enabled) {
|
|
5063
5127
|
clearErrors();
|
|
5064
5128
|
lastTextRef.current = "";
|
|
5065
5129
|
}
|
|
5066
5130
|
}, [enabled, clearErrors]);
|
|
5067
|
-
|
|
5131
|
+
React10__namespace.useEffect(
|
|
5068
5132
|
() => () => {
|
|
5069
5133
|
dismissRef.current?.();
|
|
5070
5134
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
@@ -5085,13 +5149,13 @@ function SpellCheckPlugin({
|
|
|
5085
5149
|
}
|
|
5086
5150
|
function TableActionMenuPlugin({ disabled = false }) {
|
|
5087
5151
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
5088
|
-
const [isInTable, setIsInTable] =
|
|
5089
|
-
const [anchorRect, setAnchorRect] =
|
|
5090
|
-
const [contentRight, setContentRight] =
|
|
5091
|
-
const [open, setOpen] =
|
|
5092
|
-
const openRef =
|
|
5093
|
-
const savedAnchorRef =
|
|
5094
|
-
const measureContentRight =
|
|
5152
|
+
const [isInTable, setIsInTable] = React10__namespace.useState(false);
|
|
5153
|
+
const [anchorRect, setAnchorRect] = React10__namespace.useState(null);
|
|
5154
|
+
const [contentRight, setContentRight] = React10__namespace.useState(null);
|
|
5155
|
+
const [open, setOpen] = React10__namespace.useState(false);
|
|
5156
|
+
const openRef = React10__namespace.useRef(false);
|
|
5157
|
+
const savedAnchorRef = React10__namespace.useRef(null);
|
|
5158
|
+
const measureContentRight = React10__namespace.useCallback((cellDom) => {
|
|
5095
5159
|
try {
|
|
5096
5160
|
const range = document.createRange();
|
|
5097
5161
|
range.selectNodeContents(cellDom);
|
|
@@ -5101,7 +5165,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5101
5165
|
return null;
|
|
5102
5166
|
}
|
|
5103
5167
|
}, []);
|
|
5104
|
-
const updateFromSelection =
|
|
5168
|
+
const updateFromSelection = React10__namespace.useCallback(() => {
|
|
5105
5169
|
if (openRef.current) return;
|
|
5106
5170
|
const root = editor.getRootElement();
|
|
5107
5171
|
if (!root) return;
|
|
@@ -5152,7 +5216,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5152
5216
|
}
|
|
5153
5217
|
});
|
|
5154
5218
|
}, [editor, measureContentRight]);
|
|
5155
|
-
|
|
5219
|
+
React10__namespace.useEffect(() => {
|
|
5156
5220
|
return utils.mergeRegister(
|
|
5157
5221
|
editor.registerCommand(
|
|
5158
5222
|
lexical.SELECTION_CHANGE_COMMAND,
|
|
@@ -5167,7 +5231,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5167
5231
|
})
|
|
5168
5232
|
);
|
|
5169
5233
|
}, [editor, updateFromSelection]);
|
|
5170
|
-
|
|
5234
|
+
React10__namespace.useEffect(() => {
|
|
5171
5235
|
return editor.registerCommand(
|
|
5172
5236
|
lexical.KEY_DOWN_COMMAND,
|
|
5173
5237
|
(event) => {
|
|
@@ -5209,7 +5273,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5209
5273
|
);
|
|
5210
5274
|
}, [editor, disabled]);
|
|
5211
5275
|
const canShow = isInTable && !!anchorRect && !disabled;
|
|
5212
|
-
const handleStyle =
|
|
5276
|
+
const handleStyle = React10__namespace.useMemo(() => {
|
|
5213
5277
|
if (!anchorRect) return void 0;
|
|
5214
5278
|
const top = Math.max(8, anchorRect.top + 6);
|
|
5215
5279
|
const clampedCellRight = Math.min(anchorRect.right, window.innerWidth - 8);
|
|
@@ -5224,7 +5288,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
5224
5288
|
const dangerStyle = {
|
|
5225
5289
|
color: "var(--colorPaletteRedForeground1)"
|
|
5226
5290
|
};
|
|
5227
|
-
const run =
|
|
5291
|
+
const run = React10__namespace.useCallback(
|
|
5228
5292
|
(fn) => {
|
|
5229
5293
|
if (disabled) return;
|
|
5230
5294
|
openRef.current = false;
|
|
@@ -5327,17 +5391,17 @@ function TableCellResizer({
|
|
|
5327
5391
|
editor,
|
|
5328
5392
|
anchorElem
|
|
5329
5393
|
}) {
|
|
5330
|
-
const targetRef =
|
|
5331
|
-
const resizerRef =
|
|
5332
|
-
const tableRectRef =
|
|
5333
|
-
const mouseStartPosRef =
|
|
5334
|
-
const [mouseCurrentPos, updateMouseCurrentPos] =
|
|
5335
|
-
const [activeCell, updateActiveCell] =
|
|
5336
|
-
const [isSelectingGrid, updateIsSelectingGrid] =
|
|
5337
|
-
const [draggingDirection, updateDraggingDirection] =
|
|
5394
|
+
const targetRef = React10.useRef(null);
|
|
5395
|
+
const resizerRef = React10.useRef(null);
|
|
5396
|
+
const tableRectRef = React10.useRef(null);
|
|
5397
|
+
const mouseStartPosRef = React10.useRef(null);
|
|
5398
|
+
const [mouseCurrentPos, updateMouseCurrentPos] = React10.useState(null);
|
|
5399
|
+
const [activeCell, updateActiveCell] = React10.useState(null);
|
|
5400
|
+
const [isSelectingGrid, updateIsSelectingGrid] = React10.useState(false);
|
|
5401
|
+
const [draggingDirection, updateDraggingDirection] = React10.useState(
|
|
5338
5402
|
null
|
|
5339
5403
|
);
|
|
5340
|
-
|
|
5404
|
+
React10.useEffect(() => {
|
|
5341
5405
|
return editor.registerCommand(
|
|
5342
5406
|
lexical.SELECTION_CHANGE_COMMAND,
|
|
5343
5407
|
() => {
|
|
@@ -5360,7 +5424,7 @@ function TableCellResizer({
|
|
|
5360
5424
|
lexical.COMMAND_PRIORITY_HIGH
|
|
5361
5425
|
);
|
|
5362
5426
|
}, [editor]);
|
|
5363
|
-
const resetState =
|
|
5427
|
+
const resetState = React10.useCallback(() => {
|
|
5364
5428
|
updateActiveCell(null);
|
|
5365
5429
|
targetRef.current = null;
|
|
5366
5430
|
updateDraggingDirection(null);
|
|
@@ -5368,7 +5432,7 @@ function TableCellResizer({
|
|
|
5368
5432
|
tableRectRef.current = null;
|
|
5369
5433
|
updateMouseCurrentPos(null);
|
|
5370
5434
|
}, []);
|
|
5371
|
-
|
|
5435
|
+
React10.useEffect(() => {
|
|
5372
5436
|
const onMouseMove = (event) => {
|
|
5373
5437
|
if (draggingDirection) {
|
|
5374
5438
|
updateMouseCurrentPos({ x: event.clientX, y: event.clientY });
|
|
@@ -5412,7 +5476,7 @@ function TableCellResizer({
|
|
|
5412
5476
|
};
|
|
5413
5477
|
}, [activeCell, draggingDirection, editor, resetState, anchorElem]);
|
|
5414
5478
|
const isHeightChanging = (direction) => direction === "bottom";
|
|
5415
|
-
const updateRowHeight =
|
|
5479
|
+
const updateRowHeight = React10.useCallback(
|
|
5416
5480
|
(newHeight) => {
|
|
5417
5481
|
if (!activeCell) return;
|
|
5418
5482
|
editor.update(() => {
|
|
@@ -5429,7 +5493,7 @@ function TableCellResizer({
|
|
|
5429
5493
|
},
|
|
5430
5494
|
[activeCell, editor]
|
|
5431
5495
|
);
|
|
5432
|
-
const updateColumnWidth =
|
|
5496
|
+
const updateColumnWidth = React10.useCallback(
|
|
5433
5497
|
(newWidth) => {
|
|
5434
5498
|
if (!activeCell) return;
|
|
5435
5499
|
editor.update(() => {
|
|
@@ -5451,7 +5515,7 @@ function TableCellResizer({
|
|
|
5451
5515
|
},
|
|
5452
5516
|
[activeCell, editor]
|
|
5453
5517
|
);
|
|
5454
|
-
const toggleResize =
|
|
5518
|
+
const toggleResize = React10.useCallback(
|
|
5455
5519
|
(direction) => (event) => {
|
|
5456
5520
|
event.preventDefault();
|
|
5457
5521
|
event.stopPropagation();
|
|
@@ -5482,7 +5546,7 @@ function TableCellResizer({
|
|
|
5482
5546
|
},
|
|
5483
5547
|
[activeCell, draggingDirection, resetState, updateColumnWidth, updateRowHeight]
|
|
5484
5548
|
);
|
|
5485
|
-
const getResizers =
|
|
5549
|
+
const getResizers = React10.useCallback(() => {
|
|
5486
5550
|
const empty = { bottom: {}, right: {} };
|
|
5487
5551
|
if (!activeCell) return empty;
|
|
5488
5552
|
const cellRect = activeCell.elem.getBoundingClientRect();
|
|
@@ -5557,7 +5621,7 @@ function TableCellResizerPlugin({
|
|
|
5557
5621
|
anchorElem
|
|
5558
5622
|
}) {
|
|
5559
5623
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
5560
|
-
return
|
|
5624
|
+
return React10.useMemo(
|
|
5561
5625
|
() => reactDom.createPortal(/* @__PURE__ */ jsxRuntime.jsx(TableCellResizer, { editor, anchorElem }), anchorElem),
|
|
5562
5626
|
[editor, anchorElem]
|
|
5563
5627
|
);
|
|
@@ -5785,22 +5849,22 @@ var hsvToRgb = (h, s, v) => {
|
|
|
5785
5849
|
};
|
|
5786
5850
|
};
|
|
5787
5851
|
var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange }) => {
|
|
5788
|
-
const [open, setOpen] =
|
|
5789
|
-
const btnRef =
|
|
5790
|
-
const setOpenAndNotify =
|
|
5852
|
+
const [open, setOpen] = React10__namespace.useState(false);
|
|
5853
|
+
const btnRef = React10__namespace.useRef(null);
|
|
5854
|
+
const setOpenAndNotify = React10__namespace.useCallback(
|
|
5791
5855
|
(next) => {
|
|
5792
5856
|
setOpen(next);
|
|
5793
5857
|
onOpenChange?.(next);
|
|
5794
5858
|
},
|
|
5795
5859
|
[onOpenChange]
|
|
5796
5860
|
);
|
|
5797
|
-
const handleDismiss =
|
|
5798
|
-
const preventDismissOnEvent =
|
|
5861
|
+
const handleDismiss = React10__namespace.useCallback(() => setOpenAndNotify(false), [setOpenAndNotify]);
|
|
5862
|
+
const preventDismissOnEvent = React10__namespace.useCallback(
|
|
5799
5863
|
(ev) => ev.type !== "click",
|
|
5800
5864
|
[]
|
|
5801
5865
|
);
|
|
5802
|
-
const [, forceReposition] =
|
|
5803
|
-
|
|
5866
|
+
const [, forceReposition] = React10__namespace.useState(0);
|
|
5867
|
+
React10__namespace.useEffect(() => {
|
|
5804
5868
|
if (!open) return;
|
|
5805
5869
|
let rafId = null;
|
|
5806
5870
|
const reposition = () => {
|
|
@@ -5818,15 +5882,15 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5818
5882
|
window.removeEventListener("resize", reposition);
|
|
5819
5883
|
};
|
|
5820
5884
|
}, [open]);
|
|
5821
|
-
const appliedHex =
|
|
5822
|
-
const [hex, setHexState] =
|
|
5823
|
-
const [hexText, setHexText] =
|
|
5824
|
-
const { r, g, b } =
|
|
5825
|
-
const hsv =
|
|
5826
|
-
const [h, setH] =
|
|
5827
|
-
const [s, setS] =
|
|
5828
|
-
const [v, setV] =
|
|
5829
|
-
const commit =
|
|
5885
|
+
const appliedHex = React10__namespace.useMemo(() => normalizeHex(value || "#000000"), [value]);
|
|
5886
|
+
const [hex, setHexState] = React10__namespace.useState(appliedHex);
|
|
5887
|
+
const [hexText, setHexText] = React10__namespace.useState(appliedHex);
|
|
5888
|
+
const { r, g, b } = React10__namespace.useMemo(() => hexToRgb(hex), [hex]);
|
|
5889
|
+
const hsv = React10__namespace.useMemo(() => rgbToHsv(r, g, b), [r, g, b]);
|
|
5890
|
+
const [h, setH] = React10__namespace.useState(hsv.h);
|
|
5891
|
+
const [s, setS] = React10__namespace.useState(hsv.s);
|
|
5892
|
+
const [v, setV] = React10__namespace.useState(hsv.v);
|
|
5893
|
+
const commit = React10__namespace.useCallback(
|
|
5830
5894
|
(nextHex) => {
|
|
5831
5895
|
const rgb = hexToRgb(nextHex);
|
|
5832
5896
|
const next = rgbToHsv(rgb.r, rgb.g, rgb.b);
|
|
@@ -5839,7 +5903,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5839
5903
|
},
|
|
5840
5904
|
[onChange]
|
|
5841
5905
|
);
|
|
5842
|
-
const commitFromHsv =
|
|
5906
|
+
const commitFromHsv = React10__namespace.useCallback(
|
|
5843
5907
|
(hh, ss, vv) => {
|
|
5844
5908
|
const rgb = hsvToRgb(hh, ss, vv);
|
|
5845
5909
|
const nextHex = rgbToHex(rgb.r, rgb.g, rgb.b);
|
|
@@ -5852,8 +5916,8 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5852
5916
|
},
|
|
5853
5917
|
[onChange]
|
|
5854
5918
|
);
|
|
5855
|
-
const wasOpenRef =
|
|
5856
|
-
|
|
5919
|
+
const wasOpenRef = React10__namespace.useRef(open);
|
|
5920
|
+
React10__namespace.useEffect(() => {
|
|
5857
5921
|
const justOpened = open && !wasOpenRef.current;
|
|
5858
5922
|
wasOpenRef.current = open;
|
|
5859
5923
|
if (!justOpened) return;
|
|
@@ -5865,8 +5929,8 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5865
5929
|
setS(next.s);
|
|
5866
5930
|
setV(next.v);
|
|
5867
5931
|
}, [appliedHex, open]);
|
|
5868
|
-
const svRef =
|
|
5869
|
-
const svPointFromEvent =
|
|
5932
|
+
const svRef = React10__namespace.useRef(null);
|
|
5933
|
+
const svPointFromEvent = React10__namespace.useCallback((clientX, clientY) => {
|
|
5870
5934
|
if (!svRef.current) return null;
|
|
5871
5935
|
const rect = svRef.current.getBoundingClientRect();
|
|
5872
5936
|
const x = clamp3(clientX - rect.left, 0, rect.width);
|
|
@@ -5875,9 +5939,9 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5875
5939
|
const vv = rect.height === 0 ? 0 : 1 - y / rect.height;
|
|
5876
5940
|
return { ss, vv };
|
|
5877
5941
|
}, []);
|
|
5878
|
-
const hRef =
|
|
5942
|
+
const hRef = React10__namespace.useRef(h);
|
|
5879
5943
|
hRef.current = h;
|
|
5880
|
-
const handleSVPointerDown =
|
|
5944
|
+
const handleSVPointerDown = React10__namespace.useCallback(
|
|
5881
5945
|
(e) => {
|
|
5882
5946
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
5883
5947
|
const pt = svPointFromEvent(e.clientX, e.clientY);
|
|
@@ -5885,7 +5949,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5885
5949
|
},
|
|
5886
5950
|
[svPointFromEvent, commitFromHsv]
|
|
5887
5951
|
);
|
|
5888
|
-
const handleSVPointerMove =
|
|
5952
|
+
const handleSVPointerMove = React10__namespace.useCallback(
|
|
5889
5953
|
(e) => {
|
|
5890
5954
|
if (e.buttons !== 1) return;
|
|
5891
5955
|
const pt = svPointFromEvent(e.clientX, e.clientY);
|
|
@@ -5893,18 +5957,18 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5893
5957
|
},
|
|
5894
5958
|
[svPointFromEvent, commitFromHsv]
|
|
5895
5959
|
);
|
|
5896
|
-
const hueRef =
|
|
5897
|
-
const sRef =
|
|
5960
|
+
const hueRef = React10__namespace.useRef(null);
|
|
5961
|
+
const sRef = React10__namespace.useRef(s);
|
|
5898
5962
|
sRef.current = s;
|
|
5899
|
-
const vRef =
|
|
5963
|
+
const vRef = React10__namespace.useRef(v);
|
|
5900
5964
|
vRef.current = v;
|
|
5901
|
-
const huePointFromEvent =
|
|
5965
|
+
const huePointFromEvent = React10__namespace.useCallback((clientX) => {
|
|
5902
5966
|
if (!hueRef.current) return null;
|
|
5903
5967
|
const rect = hueRef.current.getBoundingClientRect();
|
|
5904
5968
|
const x = clamp3(clientX - rect.left, 0, rect.width);
|
|
5905
5969
|
return rect.width === 0 ? 0 : x / rect.width * 360;
|
|
5906
5970
|
}, []);
|
|
5907
|
-
const handleHuePointerDown =
|
|
5971
|
+
const handleHuePointerDown = React10__namespace.useCallback(
|
|
5908
5972
|
(e) => {
|
|
5909
5973
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
5910
5974
|
const hh = huePointFromEvent(e.clientX);
|
|
@@ -5912,7 +5976,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5912
5976
|
},
|
|
5913
5977
|
[huePointFromEvent, commitFromHsv]
|
|
5914
5978
|
);
|
|
5915
|
-
const handleHuePointerMove =
|
|
5979
|
+
const handleHuePointerMove = React10__namespace.useCallback(
|
|
5916
5980
|
(e) => {
|
|
5917
5981
|
if (e.buttons !== 1) return;
|
|
5918
5982
|
const hh = huePointFromEvent(e.clientX);
|
|
@@ -5920,7 +5984,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5920
5984
|
},
|
|
5921
5985
|
[huePointFromEvent, commitFromHsv]
|
|
5922
5986
|
);
|
|
5923
|
-
const handleHexChange =
|
|
5987
|
+
const handleHexChange = React10__namespace.useCallback(
|
|
5924
5988
|
(_, val) => {
|
|
5925
5989
|
const next = val ?? "";
|
|
5926
5990
|
setHexText(next);
|
|
@@ -5928,12 +5992,12 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5928
5992
|
},
|
|
5929
5993
|
[commit]
|
|
5930
5994
|
);
|
|
5931
|
-
const handleHexBlur =
|
|
5995
|
+
const handleHexBlur = React10__namespace.useCallback(() => {
|
|
5932
5996
|
commit(normalizeHex(hexText));
|
|
5933
5997
|
}, [hexText, commit]);
|
|
5934
|
-
const svThumb =
|
|
5935
|
-
const hueThumb =
|
|
5936
|
-
const hueColor =
|
|
5998
|
+
const svThumb = React10__namespace.useMemo(() => ({ left: `${s * 100}%`, top: `${(1 - v) * 100}%` }), [s, v]);
|
|
5999
|
+
const hueThumb = React10__namespace.useMemo(() => ({ left: `${h / 360 * 100}%` }), [h]);
|
|
6000
|
+
const hueColor = React10__namespace.useMemo(() => {
|
|
5937
6001
|
const { r: r2, g: g2, b: b2 } = hsvToRgb(h, 1, 1);
|
|
5938
6002
|
return rgbToHex(r2, g2, b2);
|
|
5939
6003
|
}, [h]);
|
|
@@ -6179,8 +6243,8 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
6179
6243
|
};
|
|
6180
6244
|
var ColorPickerPlugin = ({ disabled }) => {
|
|
6181
6245
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6182
|
-
const [{ color, bgColor }, setColors] =
|
|
6183
|
-
const lastRangeSelectionRef =
|
|
6246
|
+
const [{ color, bgColor }, setColors] = React10__namespace.default.useState({ color: "#000000", bgColor: "#ffffff" });
|
|
6247
|
+
const lastRangeSelectionRef = React10__namespace.default.useRef(null);
|
|
6184
6248
|
const updateToolbar = () => {
|
|
6185
6249
|
const selection$1 = lexical.$getSelection();
|
|
6186
6250
|
if (lexical.$isRangeSelection(selection$1)) {
|
|
@@ -6190,7 +6254,7 @@ var ColorPickerPlugin = ({ disabled }) => {
|
|
|
6190
6254
|
setColors({ color: c, bgColor: bg });
|
|
6191
6255
|
}
|
|
6192
6256
|
};
|
|
6193
|
-
|
|
6257
|
+
React10__namespace.default.useEffect(() => {
|
|
6194
6258
|
return utils.mergeRegister(
|
|
6195
6259
|
editor.registerUpdateListener(({ editorState }) => {
|
|
6196
6260
|
editorState.read(() => updateToolbar());
|
|
@@ -6205,7 +6269,7 @@ var ColorPickerPlugin = ({ disabled }) => {
|
|
|
6205
6269
|
)
|
|
6206
6270
|
);
|
|
6207
6271
|
}, [editor]);
|
|
6208
|
-
const wasEditorActiveRef =
|
|
6272
|
+
const wasEditorActiveRef = React10__namespace.default.useRef(false);
|
|
6209
6273
|
const handleOpenChange = (open) => {
|
|
6210
6274
|
if (open) {
|
|
6211
6275
|
const root = editor.getRootElement();
|
|
@@ -6297,9 +6361,9 @@ var FONT_FAMILY_OPTIONS = [
|
|
|
6297
6361
|
var FontFamilyPlugin = ({ disabled = false }) => {
|
|
6298
6362
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6299
6363
|
const styles = useStyles2();
|
|
6300
|
-
const [fontFamily, setFontFamily] =
|
|
6364
|
+
const [fontFamily, setFontFamily] = React10.useState("");
|
|
6301
6365
|
const fg = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
|
|
6302
|
-
|
|
6366
|
+
React10.useEffect(() => {
|
|
6303
6367
|
const readFontFamily = () => {
|
|
6304
6368
|
const selection$1 = lexical.$getSelection();
|
|
6305
6369
|
if (lexical.$isRangeSelection(selection$1)) {
|
|
@@ -6321,7 +6385,7 @@ var FontFamilyPlugin = ({ disabled = false }) => {
|
|
|
6321
6385
|
)
|
|
6322
6386
|
);
|
|
6323
6387
|
}, [editor]);
|
|
6324
|
-
const handleClick =
|
|
6388
|
+
const handleClick = React10.useCallback(
|
|
6325
6389
|
(option) => {
|
|
6326
6390
|
if (disabled) return;
|
|
6327
6391
|
editor.update(() => {
|
|
@@ -6423,9 +6487,9 @@ var useStyles3 = reactComponents.makeStyles({
|
|
|
6423
6487
|
var FontSizePlugin = ({ disabled }) => {
|
|
6424
6488
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6425
6489
|
const styles = useStyles3();
|
|
6426
|
-
const [fontSize2, setFontSize] =
|
|
6490
|
+
const [fontSize2, setFontSize] = React10__namespace.useState(String(DEFAULT_FONT_SIZE));
|
|
6427
6491
|
const fg = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
|
|
6428
|
-
|
|
6492
|
+
React10__namespace.useEffect(() => {
|
|
6429
6493
|
const readFontSize = () => {
|
|
6430
6494
|
const selection$1 = lexical.$getSelection();
|
|
6431
6495
|
if (lexical.$isRangeSelection(selection$1)) {
|
|
@@ -6595,9 +6659,9 @@ function PageSetupPlugin({ disabled, value, onChange }) {
|
|
|
6595
6659
|
}
|
|
6596
6660
|
var TableItemPlugin = ({ disabled }) => {
|
|
6597
6661
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6598
|
-
const [columns, setColumns] =
|
|
6599
|
-
const [rows, setRows] =
|
|
6600
|
-
const [isOpen, setIsOpen] =
|
|
6662
|
+
const [columns, setColumns] = React10.useState("");
|
|
6663
|
+
const [rows, setRows] = React10.useState("");
|
|
6664
|
+
const [isOpen, setIsOpen] = React10.useState(false);
|
|
6601
6665
|
const iconColor = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
|
|
6602
6666
|
const onAddTable = () => {
|
|
6603
6667
|
if (disabled) return;
|
|
@@ -6612,83 +6676,80 @@ var TableItemPlugin = ({ disabled }) => {
|
|
|
6612
6676
|
setColumns("");
|
|
6613
6677
|
setIsOpen(false);
|
|
6614
6678
|
};
|
|
6615
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6679
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6680
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6681
|
+
reactComponents.Button,
|
|
6682
|
+
{
|
|
6683
|
+
size: "small",
|
|
6684
|
+
title: "Add table",
|
|
6685
|
+
disabled,
|
|
6686
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(reactIcons.TableAddRegular, { style: { color: iconColor } }),
|
|
6687
|
+
style: {
|
|
6688
|
+
background: isOpen && !disabled ? "#ebebeb" : "none",
|
|
6689
|
+
border: "none",
|
|
6690
|
+
margin: 2,
|
|
6691
|
+
opacity: disabled ? 0.55 : 1,
|
|
6692
|
+
cursor: disabled ? "not-allowed" : "pointer"
|
|
6693
|
+
},
|
|
6694
|
+
onClick: () => {
|
|
6695
|
+
if (disabled) return;
|
|
6696
|
+
setIsOpen((prev) => !prev);
|
|
6697
|
+
setRows("");
|
|
6698
|
+
setColumns("");
|
|
6699
|
+
}
|
|
6621
6700
|
},
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
setRows("");
|
|
6641
|
-
setColumns("");
|
|
6701
|
+
"insert-table-nodes"
|
|
6702
|
+
),
|
|
6703
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6704
|
+
AoModal,
|
|
6705
|
+
{
|
|
6706
|
+
isOpen: disabled ? false : isOpen,
|
|
6707
|
+
onDismiss: () => !disabled && setIsOpen(false),
|
|
6708
|
+
title: "Insert table",
|
|
6709
|
+
maxWidth: 300,
|
|
6710
|
+
actions: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6711
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6712
|
+
reactComponents.Button,
|
|
6713
|
+
{
|
|
6714
|
+
size: "small",
|
|
6715
|
+
appearance: "primary",
|
|
6716
|
+
disabled: disabled || !rows || !columns,
|
|
6717
|
+
onClick: onAddTable,
|
|
6718
|
+
children: "Add"
|
|
6642
6719
|
}
|
|
6643
|
-
|
|
6644
|
-
"
|
|
6645
|
-
|
|
6646
|
-
/* @__PURE__ */ jsxRuntime.
|
|
6647
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6673
|
-
reactComponents.Button,
|
|
6674
|
-
{
|
|
6675
|
-
size: "small",
|
|
6676
|
-
appearance: "primary",
|
|
6677
|
-
disabled: disabled || !rows || !columns,
|
|
6678
|
-
onClick: onAddTable,
|
|
6679
|
-
children: "Add"
|
|
6680
|
-
}
|
|
6681
|
-
),
|
|
6682
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Button, { size: "small", disabled, onClick: () => setIsOpen(false), children: "Cancel" })
|
|
6683
|
-
] })
|
|
6684
|
-
] }) })
|
|
6685
|
-
]
|
|
6686
|
-
}
|
|
6687
|
-
);
|
|
6720
|
+
),
|
|
6721
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Button, { size: "small", disabled, onClick: () => setIsOpen(false), children: "Cancel" })
|
|
6722
|
+
] }),
|
|
6723
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { tokens: { childrenGap: 8 }, children: [
|
|
6724
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Field, { label: "Rows", size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6725
|
+
reactComponents.Input,
|
|
6726
|
+
{
|
|
6727
|
+
autoFocus: !disabled,
|
|
6728
|
+
value: rows,
|
|
6729
|
+
placeholder: "Rows",
|
|
6730
|
+
appearance: "underline",
|
|
6731
|
+
disabled,
|
|
6732
|
+
onChange: (_, v) => setRows(v.value)
|
|
6733
|
+
}
|
|
6734
|
+
) }),
|
|
6735
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Field, { label: "Columns", size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6736
|
+
reactComponents.Input,
|
|
6737
|
+
{
|
|
6738
|
+
value: columns,
|
|
6739
|
+
placeholder: "Columns",
|
|
6740
|
+
appearance: "underline",
|
|
6741
|
+
disabled,
|
|
6742
|
+
onChange: (_, v) => setColumns(v.value)
|
|
6743
|
+
}
|
|
6744
|
+
) })
|
|
6745
|
+
] })
|
|
6746
|
+
}
|
|
6747
|
+
)
|
|
6748
|
+
] });
|
|
6688
6749
|
};
|
|
6689
6750
|
var YoutubeUploadPlugin = ({ disabled }) => {
|
|
6690
|
-
const [url, setURL] =
|
|
6691
|
-
const [isOpen, setIsOpen] =
|
|
6751
|
+
const [url, setURL] = React10.useState("");
|
|
6752
|
+
const [isOpen, setIsOpen] = React10.useState(false);
|
|
6692
6753
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6693
6754
|
const iconColor = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#424242";
|
|
6694
6755
|
const onHandleEmbeded = () => {
|
|
@@ -6704,57 +6765,54 @@ var YoutubeUploadPlugin = ({ disabled }) => {
|
|
|
6704
6765
|
setURL("");
|
|
6705
6766
|
setIsOpen(false);
|
|
6706
6767
|
};
|
|
6707
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6768
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6769
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6770
|
+
reactComponents.Button,
|
|
6771
|
+
{
|
|
6772
|
+
title: "Add youtube URL",
|
|
6773
|
+
size: "small",
|
|
6774
|
+
disabled,
|
|
6775
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(reactIcons.VideoClipRegular, { style: { color: iconColor } }),
|
|
6776
|
+
style: {
|
|
6777
|
+
background: isOpen && !disabled ? "#ebebeb" : "none",
|
|
6778
|
+
border: "none",
|
|
6779
|
+
margin: 2,
|
|
6780
|
+
opacity: disabled ? 0.55 : 1,
|
|
6781
|
+
cursor: disabled ? "not-allowed" : "pointer"
|
|
6782
|
+
},
|
|
6783
|
+
onClick: () => {
|
|
6784
|
+
if (disabled) return;
|
|
6785
|
+
setIsOpen((prev) => !prev);
|
|
6786
|
+
setURL("");
|
|
6787
|
+
}
|
|
6713
6788
|
},
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6789
|
+
"upload-video"
|
|
6790
|
+
),
|
|
6791
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6792
|
+
AoModal,
|
|
6793
|
+
{
|
|
6794
|
+
isOpen: disabled ? false : isOpen,
|
|
6795
|
+
onDismiss: () => !disabled && setIsOpen(false),
|
|
6796
|
+
title: "Embed YouTube video",
|
|
6797
|
+
maxWidth: 320,
|
|
6798
|
+
actions: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6799
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Button, { size: "small", disabled: disabled || !url, onClick: onHandleEmbeded, children: "Add" }),
|
|
6800
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Button, { size: "small", disabled, onClick: () => setIsOpen(false), children: "Cancel" })
|
|
6801
|
+
] }),
|
|
6802
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(react.Stack, { tokens: { childrenGap: 8 }, children: /* @__PURE__ */ jsxRuntime.jsx(reactComponents.Field, { label: "URL", size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6803
|
+
reactComponents.Input,
|
|
6717
6804
|
{
|
|
6718
|
-
|
|
6719
|
-
size: "small",
|
|
6805
|
+
autoFocus: !disabled,
|
|
6720
6806
|
disabled,
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
if (disabled) return;
|
|
6731
|
-
setIsOpen((prev) => !prev);
|
|
6732
|
-
setURL("");
|
|
6733
|
-
}
|
|
6734
|
-
},
|
|
6735
|
-
"upload-video"
|
|
6736
|
-
) }),
|
|
6737
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.DialogSurface, { style: { maxWidth: 320 }, children: /* @__PURE__ */ jsxRuntime.jsxs(reactComponents.DialogBody, { children: [
|
|
6738
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.DialogTitle, { children: "Embed YouTube video" }),
|
|
6739
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.DialogContent, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Stack, { tokens: { childrenGap: 8 }, children: /* @__PURE__ */ jsxRuntime.jsx(reactComponents.Field, { label: "URL", size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6740
|
-
reactComponents.Input,
|
|
6741
|
-
{
|
|
6742
|
-
autoFocus: !disabled,
|
|
6743
|
-
disabled,
|
|
6744
|
-
value: url,
|
|
6745
|
-
appearance: "underline",
|
|
6746
|
-
placeholder: "Add Youtube video URL",
|
|
6747
|
-
onChange: (_, v) => setURL(v.value)
|
|
6748
|
-
}
|
|
6749
|
-
) }) }) }),
|
|
6750
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactComponents.DialogActions, { children: [
|
|
6751
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Button, { size: "small", disabled: disabled || !url, onClick: onHandleEmbeded, children: "Add" }),
|
|
6752
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Button, { size: "small", disabled, onClick: () => setIsOpen(false), children: "Cancel" })
|
|
6753
|
-
] })
|
|
6754
|
-
] }) })
|
|
6755
|
-
]
|
|
6756
|
-
}
|
|
6757
|
-
);
|
|
6807
|
+
value: url,
|
|
6808
|
+
appearance: "underline",
|
|
6809
|
+
placeholder: "Add Youtube video URL",
|
|
6810
|
+
onChange: (_, v) => setURL(v.value)
|
|
6811
|
+
}
|
|
6812
|
+
) }) })
|
|
6813
|
+
}
|
|
6814
|
+
)
|
|
6815
|
+
] });
|
|
6758
6816
|
};
|
|
6759
6817
|
var TextAlphaListLtrFilled = ({ style }) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", style, children: [
|
|
6760
6818
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8.75 4a.75.75 0 1 0 0 1.5h7.5a.75.75 0 0 0 0-1.5h-7.5Z" }),
|
|
@@ -6823,23 +6881,24 @@ var ToolBarPlugins = (props) => {
|
|
|
6823
6881
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6824
6882
|
const theme2 = react.useTheme();
|
|
6825
6883
|
const styles = useStyles4();
|
|
6826
|
-
const [selectNodeType, setSelectNodeType] =
|
|
6827
|
-
const [isEditable, setIsEditable] =
|
|
6828
|
-
const [isBold, setIsBold] =
|
|
6829
|
-
const [isItalic, setIsItalic] =
|
|
6830
|
-
const [isUnderline, setIsUnderline] =
|
|
6831
|
-
const [isStrikethrough, setIsStrikethrough] =
|
|
6832
|
-
const [isSuperscript, setIsSuperscript] =
|
|
6833
|
-
const [isSubscript, setIsSubscript] =
|
|
6834
|
-
const [isHighlight, setIsHighlight] =
|
|
6835
|
-
const [isUppercase, setIsUppercase] =
|
|
6836
|
-
const [isLowercase, setIsLowercase] =
|
|
6837
|
-
const [isCapitalize, setIsCapitalize] =
|
|
6838
|
-
const [alignment, setAlignment] =
|
|
6839
|
-
const [
|
|
6840
|
-
const
|
|
6884
|
+
const [selectNodeType, setSelectNodeType] = React10.useState("paragraph");
|
|
6885
|
+
const [isEditable, setIsEditable] = React10.useState(() => editor.isEditable());
|
|
6886
|
+
const [isBold, setIsBold] = React10.useState(false);
|
|
6887
|
+
const [isItalic, setIsItalic] = React10.useState(false);
|
|
6888
|
+
const [isUnderline, setIsUnderline] = React10.useState(false);
|
|
6889
|
+
const [isStrikethrough, setIsStrikethrough] = React10.useState(false);
|
|
6890
|
+
const [isSuperscript, setIsSuperscript] = React10.useState(false);
|
|
6891
|
+
const [isSubscript, setIsSubscript] = React10.useState(false);
|
|
6892
|
+
const [isHighlight, setIsHighlight] = React10.useState(false);
|
|
6893
|
+
const [isUppercase, setIsUppercase] = React10.useState(false);
|
|
6894
|
+
const [isLowercase, setIsLowercase] = React10.useState(false);
|
|
6895
|
+
const [isCapitalize, setIsCapitalize] = React10.useState(false);
|
|
6896
|
+
const [alignment, setAlignment] = React10.useState("left");
|
|
6897
|
+
const [hasTextSelection, setHasTextSelection] = React10.useState(false);
|
|
6898
|
+
const [decoratorOpen, setDecoratorOpen] = React10.useState(false);
|
|
6899
|
+
const decoratorSelectingRef = React10__namespace.default.useRef(false);
|
|
6841
6900
|
const presetGroups = props.customToolbar ?? getToolbarGroupsByLevel(props.level);
|
|
6842
|
-
const pluginGroups =
|
|
6901
|
+
const pluginGroups = React10.useMemo(() => sanitizePluginGroups(presetGroups), [presetGroups]);
|
|
6843
6902
|
const updateToolbarPlugins = () => {
|
|
6844
6903
|
const selection = lexical.$getSelection();
|
|
6845
6904
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -6854,8 +6913,10 @@ var ToolBarPlugins = (props) => {
|
|
|
6854
6913
|
setIsLowercase(false);
|
|
6855
6914
|
setIsCapitalize(false);
|
|
6856
6915
|
setSelectNodeType("paragraph");
|
|
6916
|
+
setHasTextSelection(false);
|
|
6857
6917
|
return;
|
|
6858
6918
|
}
|
|
6919
|
+
setHasTextSelection(!selection.isCollapsed());
|
|
6859
6920
|
setIsBold(selection.hasFormat("bold"));
|
|
6860
6921
|
setIsItalic(selection.hasFormat("italic"));
|
|
6861
6922
|
setIsUnderline(selection.hasFormat("underline"));
|
|
@@ -6907,7 +6968,7 @@ var ToolBarPlugins = (props) => {
|
|
|
6907
6968
|
}
|
|
6908
6969
|
});
|
|
6909
6970
|
};
|
|
6910
|
-
|
|
6971
|
+
React10__namespace.default.useEffect(() => {
|
|
6911
6972
|
return utils.mergeRegister(
|
|
6912
6973
|
editor.registerEditableListener((editable) => {
|
|
6913
6974
|
setIsEditable(editable);
|
|
@@ -7111,7 +7172,7 @@ var ToolBarPlugins = (props) => {
|
|
|
7111
7172
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7112
7173
|
InsertLinkPlugin,
|
|
7113
7174
|
{
|
|
7114
|
-
disabled: !isEditable || props.readOnly,
|
|
7175
|
+
disabled: !isEditable || props.readOnly || !hasTextSelection,
|
|
7115
7176
|
setIsLinkEditMode: props.setIsLinkEditMode
|
|
7116
7177
|
},
|
|
7117
7178
|
key
|
|
@@ -7781,7 +7842,7 @@ var ToolBarPlugins = (props) => {
|
|
|
7781
7842
|
padding: "0px",
|
|
7782
7843
|
minHeight: 36
|
|
7783
7844
|
},
|
|
7784
|
-
children: pluginGroups.map((group, groupIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7845
|
+
children: pluginGroups.map((group, groupIndex) => /* @__PURE__ */ jsxRuntime.jsx(React10__namespace.default.Fragment, { children: group.map((token, tokenIndex) => {
|
|
7785
7846
|
try {
|
|
7786
7847
|
return renderToken(token, groupIndex, tokenIndex);
|
|
7787
7848
|
} catch {
|
|
@@ -7800,7 +7861,7 @@ function isYoutubeLikeNode(node) {
|
|
|
7800
7861
|
}
|
|
7801
7862
|
function YoutubeDeletePlugin() {
|
|
7802
7863
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
7803
|
-
|
|
7864
|
+
React10.useEffect(() => {
|
|
7804
7865
|
const removeIfYoutubeAtCursor = (direction) => {
|
|
7805
7866
|
const selection = lexical.$getSelection();
|
|
7806
7867
|
if (!lexical.$isRangeSelection(selection)) return false;
|
|
@@ -7832,7 +7893,7 @@ function YoutubeDeletePlugin() {
|
|
|
7832
7893
|
lexical.COMMAND_PRIORITY_HIGH
|
|
7833
7894
|
);
|
|
7834
7895
|
}, [editor]);
|
|
7835
|
-
|
|
7896
|
+
React10.useEffect(() => {
|
|
7836
7897
|
return editor.registerCommand(
|
|
7837
7898
|
lexical.KEY_DELETE_COMMAND,
|
|
7838
7899
|
() => {
|
|
@@ -7921,14 +7982,14 @@ var theme = {
|
|
|
7921
7982
|
};
|
|
7922
7983
|
function ReadOnlyPlugin({ readonly }) {
|
|
7923
7984
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
7924
|
-
|
|
7985
|
+
React10.useEffect(() => {
|
|
7925
7986
|
editor.setEditable(!readonly);
|
|
7926
7987
|
}, [editor, readonly]);
|
|
7927
7988
|
return null;
|
|
7928
7989
|
}
|
|
7929
7990
|
function BrowserSpellCheckPlugin({ enabled }) {
|
|
7930
7991
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
7931
|
-
|
|
7992
|
+
React10.useEffect(() => {
|
|
7932
7993
|
const el = editor.getRootElement();
|
|
7933
7994
|
if (!el) return;
|
|
7934
7995
|
el.spellcheck = enabled;
|
|
@@ -7943,8 +8004,8 @@ function ContentMetricsPlugin({
|
|
|
7943
8004
|
onMetricsChange
|
|
7944
8005
|
}) {
|
|
7945
8006
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
7946
|
-
const prevRef =
|
|
7947
|
-
|
|
8007
|
+
const prevRef = React10.useRef({ words: 0, chars: 0, images: 0, links: 0, tables: 0 });
|
|
8008
|
+
React10.useEffect(() => {
|
|
7948
8009
|
return editor.registerUpdateListener(({ dirtyElements, dirtyLeaves }) => {
|
|
7949
8010
|
if (dirtyElements.size === 0 && dirtyLeaves.size === 0) return;
|
|
7950
8011
|
const root = editor.getRootElement();
|
|
@@ -7973,7 +8034,7 @@ function FocusEventsPlugin({
|
|
|
7973
8034
|
containerRef
|
|
7974
8035
|
}) {
|
|
7975
8036
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
7976
|
-
|
|
8037
|
+
React10.useEffect(() => {
|
|
7977
8038
|
const root = editor.getRootElement();
|
|
7978
8039
|
if (!root) return;
|
|
7979
8040
|
const handleFocusIn = () => {
|
|
@@ -8097,51 +8158,51 @@ function _makeQueryFn(fn) {
|
|
|
8097
8158
|
}
|
|
8098
8159
|
function EditorReadyPlugin({ onReady }) {
|
|
8099
8160
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
8100
|
-
const calledRef =
|
|
8101
|
-
|
|
8161
|
+
const calledRef = React10.useRef(false);
|
|
8162
|
+
React10.useEffect(() => {
|
|
8102
8163
|
if (!onReady || calledRef.current) return;
|
|
8103
8164
|
calledRef.current = true;
|
|
8104
8165
|
onReady(editor);
|
|
8105
8166
|
}, [editor, onReady]);
|
|
8106
8167
|
return null;
|
|
8107
8168
|
}
|
|
8108
|
-
var ContentEditorComponent =
|
|
8169
|
+
var ContentEditorComponent = React10.forwardRef(
|
|
8109
8170
|
(props, ref) => {
|
|
8110
8171
|
const isReadOnly = !!props.readOnly;
|
|
8111
|
-
const resolvedSpellCheck =
|
|
8172
|
+
const resolvedSpellCheck = React10__namespace.default.useMemo(
|
|
8112
8173
|
() => props.spellCheckFn ? _makeSpellCheckFn(props.spellCheckFn) : props.useSpellCheck,
|
|
8113
8174
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8114
8175
|
[props.spellCheckFn, props.useSpellCheck]
|
|
8115
8176
|
);
|
|
8116
|
-
const resolvedQuery =
|
|
8177
|
+
const resolvedQuery = React10__namespace.default.useMemo(
|
|
8117
8178
|
() => props.suggestFn ? _makeQueryFn(props.suggestFn) : props.useQuery,
|
|
8118
8179
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8119
8180
|
[props.suggestFn, props.useQuery]
|
|
8120
8181
|
);
|
|
8121
|
-
const [floatingAnchorElem, setFloatingAnchorElem] =
|
|
8122
|
-
const [isLinkEditMode, setIsLinkEditMode] =
|
|
8123
|
-
const [metrics, setMetrics] =
|
|
8182
|
+
const [floatingAnchorElem, setFloatingAnchorElem] = React10.useState(null);
|
|
8183
|
+
const [isLinkEditMode, setIsLinkEditMode] = React10.useState(false);
|
|
8184
|
+
const [metrics, setMetrics] = React10.useState({
|
|
8124
8185
|
words: 0,
|
|
8125
8186
|
chars: 0,
|
|
8126
8187
|
images: 0,
|
|
8127
8188
|
links: 0,
|
|
8128
8189
|
tables: 0
|
|
8129
8190
|
});
|
|
8130
|
-
const handleMetrics =
|
|
8131
|
-
const [pageSetup, setPageSetup] =
|
|
8191
|
+
const handleMetrics = React10.useCallback((m) => setMetrics(m), []);
|
|
8192
|
+
const [pageSetup, setPageSetup] = React10.useState(DEFAULT_PAGE_SETUP);
|
|
8132
8193
|
const pageCanvas = resolvePageCanvasMetrics(pageSetup);
|
|
8133
8194
|
const wordCount = metrics.words;
|
|
8134
|
-
const contentEditableDomRef =
|
|
8135
|
-
const previousOverLimitRef =
|
|
8136
|
-
const focusedRef =
|
|
8195
|
+
const contentEditableDomRef = React10.useRef(null);
|
|
8196
|
+
const previousOverLimitRef = React10.useRef(false);
|
|
8197
|
+
const focusedRef = React10.useRef(false);
|
|
8137
8198
|
const setFocused = (focused) => {
|
|
8138
8199
|
focusedRef.current = focused;
|
|
8139
8200
|
};
|
|
8140
|
-
const containerRef =
|
|
8201
|
+
const containerRef = React10.useRef(null);
|
|
8141
8202
|
const onAnchorRef = (elem) => {
|
|
8142
8203
|
if (elem) setFloatingAnchorElem(elem);
|
|
8143
8204
|
};
|
|
8144
|
-
const initialConfig =
|
|
8205
|
+
const initialConfig = React10__namespace.default.useMemo(() => {
|
|
8145
8206
|
const config = {
|
|
8146
8207
|
namespace: props.namespace ?? "",
|
|
8147
8208
|
theme,
|
|
@@ -8177,8 +8238,13 @@ var ContentEditorComponent = React9.forwardRef(
|
|
|
8177
8238
|
color: "var(--colorNeutralForeground3, grey)",
|
|
8178
8239
|
position: "absolute",
|
|
8179
8240
|
top: props.level !== "none" /* None */ ? "17px" : "27px",
|
|
8180
|
-
left:
|
|
8181
|
-
right:
|
|
8241
|
+
left: 0,
|
|
8242
|
+
right: 0,
|
|
8243
|
+
maxWidth: pageCanvas.widthPx,
|
|
8244
|
+
marginLeft: pageCanvas.widthPx !== void 0 ? "auto" : void 0,
|
|
8245
|
+
marginRight: pageCanvas.widthPx !== void 0 ? "auto" : void 0,
|
|
8246
|
+
paddingLeft: pageCanvas.paddingPx,
|
|
8247
|
+
paddingRight: pageCanvas.paddingPx,
|
|
8182
8248
|
fontSize: "14px",
|
|
8183
8249
|
pointerEvents: "none",
|
|
8184
8250
|
userSelect: "none"
|
|
@@ -8214,7 +8280,7 @@ var ContentEditorComponent = React9.forwardRef(
|
|
|
8214
8280
|
}
|
|
8215
8281
|
};
|
|
8216
8282
|
const isOverLimit = props.wordLimit !== void 0 && wordCount > props.wordLimit;
|
|
8217
|
-
|
|
8283
|
+
React10.useEffect(() => {
|
|
8218
8284
|
if (props.wordLimit === void 0 || !props.onWordLimitExceeded) return;
|
|
8219
8285
|
const wasOverLimit = previousOverLimitRef.current;
|
|
8220
8286
|
if (isOverLimit !== wasOverLimit) {
|
|
@@ -8226,7 +8292,7 @@ var ContentEditorComponent = React9.forwardRef(
|
|
|
8226
8292
|
previousOverLimitRef.current = isOverLimit;
|
|
8227
8293
|
}
|
|
8228
8294
|
}, [isOverLimit, wordCount, props.wordLimit, props.onWordLimitExceeded]);
|
|
8229
|
-
const validationErrors =
|
|
8295
|
+
const validationErrors = React10__namespace.default.useMemo(() => {
|
|
8230
8296
|
const errors = [];
|
|
8231
8297
|
const custom = props.validationMessages ?? {};
|
|
8232
8298
|
const { words, chars, images, links, tables } = metrics;
|
|
@@ -8283,8 +8349,8 @@ var ContentEditorComponent = React9.forwardRef(
|
|
|
8283
8349
|
props.noTables,
|
|
8284
8350
|
props.validationMessages
|
|
8285
8351
|
]);
|
|
8286
|
-
const previousErrorTypesRef =
|
|
8287
|
-
|
|
8352
|
+
const previousErrorTypesRef = React10.useRef("");
|
|
8353
|
+
React10.useEffect(() => {
|
|
8288
8354
|
if (!props.onValidationChange) return;
|
|
8289
8355
|
const key = validationErrors.map((e) => e.type).join(",");
|
|
8290
8356
|
if (key !== previousErrorTypesRef.current) {
|
|
@@ -8295,7 +8361,7 @@ var ContentEditorComponent = React9.forwardRef(
|
|
|
8295
8361
|
const trimmedErrorMessage = props.errorMessage?.trim() || "";
|
|
8296
8362
|
const hasValidationError = validationErrors.length > 0 || !!trimmedErrorMessage;
|
|
8297
8363
|
return /* @__PURE__ */ jsxRuntime.jsx(reactComponents.FluentProvider, { theme: reactComponents.webLightTheme, style: { height: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsxs(LexicalComposer.LexicalComposer, { initialConfig, children: [
|
|
8298
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className: "lexical-rich-editor-root", style: { height: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8364
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className: "lexical-rich-editor-root", style: { height: "100%", position: "relative" }, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8299
8365
|
react.Stack,
|
|
8300
8366
|
{
|
|
8301
8367
|
style: {
|