@tarviks/lexical-rich-editor 1.0.6 → 1.0.8
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.js +256 -244
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +108 -96
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -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 React9 = 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');
|
|
@@ -50,7 +50,7 @@ function _interopNamespace(e) {
|
|
|
50
50
|
return Object.freeze(n);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
var
|
|
53
|
+
var React9__namespace = /*#__PURE__*/_interopNamespace(React9);
|
|
54
54
|
|
|
55
55
|
var __defProp = Object.defineProperty;
|
|
56
56
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -84,12 +84,12 @@ var init_ImageResizer = __esm({
|
|
|
84
84
|
setShowCaption,
|
|
85
85
|
captionsEnabled
|
|
86
86
|
}) => {
|
|
87
|
-
const controlWrapperRef =
|
|
88
|
-
const userSelect =
|
|
87
|
+
const controlWrapperRef = React9.useRef(null);
|
|
88
|
+
const userSelect = React9.useRef({
|
|
89
89
|
priority: "",
|
|
90
90
|
value: "default"
|
|
91
91
|
});
|
|
92
|
-
const positioningRef =
|
|
92
|
+
const positioningRef = React9.useRef({
|
|
93
93
|
currentHeight: 0,
|
|
94
94
|
currentWidth: 0,
|
|
95
95
|
direction: 0,
|
|
@@ -420,15 +420,15 @@ var init_ImageComponent = __esm({
|
|
|
420
420
|
};
|
|
421
421
|
ImageComponent = ({ src, altText, nodeKey, width, height, maxWidth, resizable, showCaption, caption, captionsEnabled }) => {
|
|
422
422
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
|
|
423
|
-
const [selection, setSelection] =
|
|
424
|
-
const [isLoadError, setIsLoadError] =
|
|
425
|
-
const [isResizing, setIsResizing] =
|
|
423
|
+
const [selection, setSelection] = React9.useState(null);
|
|
424
|
+
const [isLoadError, setIsLoadError] = React9.useState(false);
|
|
425
|
+
const [isResizing, setIsResizing] = React9.useState(false);
|
|
426
426
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
427
|
-
const activeEditorRef =
|
|
428
|
-
const buttonRef =
|
|
429
|
-
const imageRef =
|
|
427
|
+
const activeEditorRef = React9.useRef(null);
|
|
428
|
+
const buttonRef = React9.useRef(null);
|
|
429
|
+
const imageRef = React9.useRef(null);
|
|
430
430
|
const isEditable = useLexicalEditable.useLexicalEditable();
|
|
431
|
-
const $onDelete =
|
|
431
|
+
const $onDelete = React9.useCallback(
|
|
432
432
|
(payload) => {
|
|
433
433
|
const deleteSelection = lexical.$getSelection();
|
|
434
434
|
if (isSelected && lexical.$isNodeSelection(deleteSelection)) {
|
|
@@ -444,7 +444,7 @@ var init_ImageComponent = __esm({
|
|
|
444
444
|
},
|
|
445
445
|
[isSelected]
|
|
446
446
|
);
|
|
447
|
-
const $onEnter =
|
|
447
|
+
const $onEnter = React9.useCallback(
|
|
448
448
|
(event) => {
|
|
449
449
|
const latestSelection = lexical.$getSelection();
|
|
450
450
|
const buttonElem = buttonRef.current;
|
|
@@ -464,7 +464,7 @@ var init_ImageComponent = __esm({
|
|
|
464
464
|
},
|
|
465
465
|
[caption, isSelected, showCaption]
|
|
466
466
|
);
|
|
467
|
-
const $onEscape =
|
|
467
|
+
const $onEscape = React9.useCallback(
|
|
468
468
|
(event) => {
|
|
469
469
|
if (activeEditorRef.current === caption || buttonRef.current === event.target) {
|
|
470
470
|
lexical.$setSelection(null);
|
|
@@ -481,7 +481,7 @@ var init_ImageComponent = __esm({
|
|
|
481
481
|
},
|
|
482
482
|
[caption, editor, setSelected]
|
|
483
483
|
);
|
|
484
|
-
const onClick =
|
|
484
|
+
const onClick = React9.useCallback(
|
|
485
485
|
(payload) => {
|
|
486
486
|
const event = payload;
|
|
487
487
|
if (isResizing) {
|
|
@@ -500,7 +500,7 @@ var init_ImageComponent = __esm({
|
|
|
500
500
|
},
|
|
501
501
|
[isResizing, isSelected, setSelected, clearSelection]
|
|
502
502
|
);
|
|
503
|
-
const onRightClick =
|
|
503
|
+
const onRightClick = React9.useCallback(
|
|
504
504
|
(event) => {
|
|
505
505
|
editor.getEditorState().read(() => {
|
|
506
506
|
const latestSelection = lexical.$getSelection();
|
|
@@ -515,7 +515,7 @@ var init_ImageComponent = __esm({
|
|
|
515
515
|
},
|
|
516
516
|
[editor]
|
|
517
517
|
);
|
|
518
|
-
|
|
518
|
+
React9.useEffect(() => {
|
|
519
519
|
const rootElement = editor.getRootElement();
|
|
520
520
|
const unregister = utils.mergeRegister(
|
|
521
521
|
editor.registerUpdateListener(({ editorState }) => {
|
|
@@ -614,7 +614,7 @@ var init_ImageComponent = __esm({
|
|
|
614
614
|
};
|
|
615
615
|
const draggable = isSelected && lexical.$isNodeSelection(selection) && !isResizing;
|
|
616
616
|
const isFocused = (isSelected || isResizing) && isEditable;
|
|
617
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
617
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React9.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
618
618
|
/* @__PURE__ */ jsxRuntime.jsx("div", { draggable, children: isLoadError ? /* @__PURE__ */ jsxRuntime.jsx(BrokenImage, {}) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
619
619
|
LazyImage,
|
|
620
620
|
{
|
|
@@ -668,7 +668,7 @@ function parseDimFromStyleOrAttr(img3) {
|
|
|
668
668
|
var ImageComponent2, isGoogleDocCheckboxImg, $convertImageElement, ImageNode, $createImageNode, $isImageNode;
|
|
669
669
|
var init_ImageNode = __esm({
|
|
670
670
|
"src/Nodes/ImageNode.tsx"() {
|
|
671
|
-
ImageComponent2 =
|
|
671
|
+
ImageComponent2 = React9__namespace.lazy(() => Promise.resolve().then(() => (init_ImageComponent(), ImageComponent_exports)));
|
|
672
672
|
isGoogleDocCheckboxImg = (img3) => {
|
|
673
673
|
return img3.parentElement != null && img3.parentElement.tagName === "LI" && img3.previousSibling === null && img3.getAttribute("aria-roledescription") === "checkbox";
|
|
674
674
|
};
|
|
@@ -912,13 +912,13 @@ var init_InlineImageComponent = __esm({
|
|
|
912
912
|
};
|
|
913
913
|
InlineImageComponent = ({ src, altText, nodeKey, width, height, showCaption, caption, position }) => {
|
|
914
914
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
|
|
915
|
-
const [selection, setSelection] =
|
|
916
|
-
const activeEditorRef =
|
|
917
|
-
const imageRef =
|
|
918
|
-
const buttonRef =
|
|
915
|
+
const [selection, setSelection] = React9.useState(null);
|
|
916
|
+
const activeEditorRef = React9.useRef(null);
|
|
917
|
+
const imageRef = React9.useRef(null);
|
|
918
|
+
const buttonRef = React9.useRef(null);
|
|
919
919
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
920
920
|
const isEditable = useLexicalEditable.useLexicalEditable();
|
|
921
|
-
const $onDelete =
|
|
921
|
+
const $onDelete = React9.useCallback(
|
|
922
922
|
(payload) => {
|
|
923
923
|
const deleteSelection = lexical.$getSelection();
|
|
924
924
|
if (isSelected && lexical.$isNodeSelection(deleteSelection)) {
|
|
@@ -936,7 +936,7 @@ var init_InlineImageComponent = __esm({
|
|
|
936
936
|
},
|
|
937
937
|
[isSelected]
|
|
938
938
|
);
|
|
939
|
-
const $onEnter =
|
|
939
|
+
const $onEnter = React9.useCallback(
|
|
940
940
|
(event) => {
|
|
941
941
|
const latestSelection = lexical.$getSelection();
|
|
942
942
|
const buttonElem = buttonRef.current;
|
|
@@ -956,7 +956,7 @@ var init_InlineImageComponent = __esm({
|
|
|
956
956
|
},
|
|
957
957
|
[caption, isSelected, showCaption]
|
|
958
958
|
);
|
|
959
|
-
const $onEscape =
|
|
959
|
+
const $onEscape = React9.useCallback(
|
|
960
960
|
(event) => {
|
|
961
961
|
if (activeEditorRef.current === caption || buttonRef.current === event.target) {
|
|
962
962
|
lexical.$setSelection(null);
|
|
@@ -973,7 +973,7 @@ var init_InlineImageComponent = __esm({
|
|
|
973
973
|
},
|
|
974
974
|
[caption, editor, setSelected]
|
|
975
975
|
);
|
|
976
|
-
|
|
976
|
+
React9.useEffect(() => {
|
|
977
977
|
let isMounted = true;
|
|
978
978
|
const unregister = utils.mergeRegister(
|
|
979
979
|
editor.registerUpdateListener(({ editorState }) => {
|
|
@@ -1050,7 +1050,7 @@ var init_InlineImageComponent = __esm({
|
|
|
1050
1050
|
]);
|
|
1051
1051
|
const draggable = isSelected && lexical.$isNodeSelection(selection);
|
|
1052
1052
|
const isFocused = isSelected && isEditable;
|
|
1053
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1053
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React9.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx("span", { draggable, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1054
1054
|
LazyImage2,
|
|
1055
1055
|
{
|
|
1056
1056
|
className: isFocused ? `focused ${lexical.$isNodeSelection(selection) ? "draggable" : ""}` : null,
|
|
@@ -1069,7 +1069,7 @@ var init_InlineImageComponent = __esm({
|
|
|
1069
1069
|
var InlineImageComponent2, $convertInlineImageElement, InlineImageNode, $createInlineImageNode, $isInlineImageNode;
|
|
1070
1070
|
var init_InlineImageNode = __esm({
|
|
1071
1071
|
"src/Nodes/InlineImageNode.tsx"() {
|
|
1072
|
-
InlineImageComponent2 =
|
|
1072
|
+
InlineImageComponent2 = React9__namespace.lazy(() => Promise.resolve().then(() => (init_InlineImageComponent(), InlineImageComponent_exports)));
|
|
1073
1073
|
$convertInlineImageElement = (domNode) => {
|
|
1074
1074
|
if (lexical.isHTMLElement(domNode) && domNode.nodeName === "IMG") {
|
|
1075
1075
|
const { alt: altText, src, width, height } = domNode;
|
|
@@ -1364,7 +1364,7 @@ init_InlineImageNode();
|
|
|
1364
1364
|
var PageBreakComponent = ({ nodeKey }) => {
|
|
1365
1365
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
1366
1366
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
|
|
1367
|
-
const $onDelete =
|
|
1367
|
+
const $onDelete = React9.useCallback(
|
|
1368
1368
|
(event) => {
|
|
1369
1369
|
event.preventDefault();
|
|
1370
1370
|
const deleteSelection = lexical.$getSelection();
|
|
@@ -1379,7 +1379,7 @@ var PageBreakComponent = ({ nodeKey }) => {
|
|
|
1379
1379
|
},
|
|
1380
1380
|
[isSelected]
|
|
1381
1381
|
);
|
|
1382
|
-
|
|
1382
|
+
React9.useEffect(() => {
|
|
1383
1383
|
return utils.mergeRegister(
|
|
1384
1384
|
editor.registerCommand(
|
|
1385
1385
|
lexical.CLICK_COMMAND,
|
|
@@ -1408,7 +1408,7 @@ var PageBreakComponent = ({ nodeKey }) => {
|
|
|
1408
1408
|
)
|
|
1409
1409
|
);
|
|
1410
1410
|
}, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected]);
|
|
1411
|
-
|
|
1411
|
+
React9.useEffect(() => {
|
|
1412
1412
|
const pbElem = editor.getElementByKey(nodeKey);
|
|
1413
1413
|
if (pbElem !== null) {
|
|
1414
1414
|
pbElem.className = isSelected ? "selected" : "";
|
|
@@ -1550,7 +1550,7 @@ function VideoResizer({
|
|
|
1550
1550
|
onResizeStart,
|
|
1551
1551
|
onResizeEnd
|
|
1552
1552
|
}) {
|
|
1553
|
-
const resizeState =
|
|
1553
|
+
const resizeState = React9__namespace.useRef(null);
|
|
1554
1554
|
const startResize = (e, dir) => {
|
|
1555
1555
|
e.preventDefault();
|
|
1556
1556
|
e.stopPropagation();
|
|
@@ -1643,9 +1643,9 @@ function YouTubeComponent({
|
|
|
1643
1643
|
height,
|
|
1644
1644
|
editor
|
|
1645
1645
|
}) {
|
|
1646
|
-
const containerRef =
|
|
1647
|
-
const [isHovered, setIsHovered] =
|
|
1648
|
-
const [isResizing, setIsResizing] =
|
|
1646
|
+
const containerRef = React9__namespace.useRef(null);
|
|
1647
|
+
const [isHovered, setIsHovered] = React9__namespace.useState(false);
|
|
1648
|
+
const [isResizing, setIsResizing] = React9__namespace.useState(false);
|
|
1649
1649
|
const handleDelete = (e) => {
|
|
1650
1650
|
e.preventDefault();
|
|
1651
1651
|
e.stopPropagation();
|
|
@@ -1905,13 +1905,13 @@ function AutocompletePlugin({
|
|
|
1905
1905
|
prefixWindow = 300
|
|
1906
1906
|
}) {
|
|
1907
1907
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
1908
|
-
const ghostKeyRef =
|
|
1909
|
-
const idleTimerRef =
|
|
1910
|
-
const inflightRef =
|
|
1911
|
-
const reqCounterRef =
|
|
1912
|
-
const lastTriggerRef =
|
|
1913
|
-
const lastShownCtxRef =
|
|
1914
|
-
const clearGhost =
|
|
1908
|
+
const ghostKeyRef = React9__namespace.useRef(null);
|
|
1909
|
+
const idleTimerRef = React9__namespace.useRef(null);
|
|
1910
|
+
const inflightRef = React9__namespace.useRef(null);
|
|
1911
|
+
const reqCounterRef = React9__namespace.useRef(0);
|
|
1912
|
+
const lastTriggerRef = React9__namespace.useRef("");
|
|
1913
|
+
const lastShownCtxRef = React9__namespace.useRef("");
|
|
1914
|
+
const clearGhost = React9__namespace.useCallback(() => {
|
|
1915
1915
|
editor.update(
|
|
1916
1916
|
() => {
|
|
1917
1917
|
const key = ghostKeyRef.current;
|
|
@@ -1923,7 +1923,7 @@ function AutocompletePlugin({
|
|
|
1923
1923
|
{ tag: "autocomplete-ghost" }
|
|
1924
1924
|
);
|
|
1925
1925
|
}, [editor]);
|
|
1926
|
-
const upsertGhost =
|
|
1926
|
+
const upsertGhost = React9__namespace.useCallback(
|
|
1927
1927
|
(text, insertAtCharOffset) => {
|
|
1928
1928
|
editor.update(
|
|
1929
1929
|
() => {
|
|
@@ -1987,12 +1987,12 @@ function AutocompletePlugin({
|
|
|
1987
1987
|
},
|
|
1988
1988
|
[editor]
|
|
1989
1989
|
);
|
|
1990
|
-
const cancelInflight =
|
|
1990
|
+
const cancelInflight = React9__namespace.useCallback(() => {
|
|
1991
1991
|
if (!inflightRef.current) return;
|
|
1992
1992
|
inflightRef.current.dismiss();
|
|
1993
1993
|
inflightRef.current = null;
|
|
1994
1994
|
}, []);
|
|
1995
|
-
const resetIdleTimer =
|
|
1995
|
+
const resetIdleTimer = React9__namespace.useCallback(
|
|
1996
1996
|
(callback) => {
|
|
1997
1997
|
if (idleTimerRef.current) {
|
|
1998
1998
|
clearTimeout(idleTimerRef.current);
|
|
@@ -2007,7 +2007,7 @@ function AutocompletePlugin({
|
|
|
2007
2007
|
},
|
|
2008
2008
|
[idleMs, cancelInflight, clearGhost]
|
|
2009
2009
|
);
|
|
2010
|
-
const fireQuery =
|
|
2010
|
+
const fireQuery = React9__namespace.useCallback(() => {
|
|
2011
2011
|
if (!useQuery || isReadOnly) return;
|
|
2012
2012
|
let context = "";
|
|
2013
2013
|
let prefix = "";
|
|
@@ -2079,7 +2079,7 @@ function AutocompletePlugin({
|
|
|
2079
2079
|
upsertGhost,
|
|
2080
2080
|
onSuggestionShown
|
|
2081
2081
|
]);
|
|
2082
|
-
|
|
2082
|
+
React9__namespace.useEffect(() => {
|
|
2083
2083
|
if (!useQuery || isReadOnly) return;
|
|
2084
2084
|
return editor.registerUpdateListener(({ tags }) => {
|
|
2085
2085
|
if (tags.has("history-merge") || tags.has("collaboration")) return;
|
|
@@ -2088,7 +2088,7 @@ function AutocompletePlugin({
|
|
|
2088
2088
|
resetIdleTimer(fireQuery);
|
|
2089
2089
|
});
|
|
2090
2090
|
}, [editor, useQuery, isReadOnly, resetIdleTimer, fireQuery]);
|
|
2091
|
-
|
|
2091
|
+
React9__namespace.useEffect(() => {
|
|
2092
2092
|
if (!useQuery || isReadOnly) return;
|
|
2093
2093
|
return editor.registerCommand(
|
|
2094
2094
|
lexical.SELECTION_CHANGE_COMMAND,
|
|
@@ -2112,7 +2112,7 @@ function AutocompletePlugin({
|
|
|
2112
2112
|
lexical.COMMAND_PRIORITY_LOW
|
|
2113
2113
|
);
|
|
2114
2114
|
}, [editor, useQuery, isReadOnly, resetIdleTimer, fireQuery]);
|
|
2115
|
-
|
|
2115
|
+
React9__namespace.useEffect(() => {
|
|
2116
2116
|
return editor.registerCommand(
|
|
2117
2117
|
lexical.KEY_DOWN_COMMAND,
|
|
2118
2118
|
(e) => {
|
|
@@ -2153,7 +2153,7 @@ function AutocompletePlugin({
|
|
|
2153
2153
|
lexical.COMMAND_PRIORITY_HIGH
|
|
2154
2154
|
);
|
|
2155
2155
|
}, [editor, clearGhost, onSuggestionAccept, prefixWindow]);
|
|
2156
|
-
|
|
2156
|
+
React9__namespace.useEffect(() => {
|
|
2157
2157
|
return () => {
|
|
2158
2158
|
cancelInflight();
|
|
2159
2159
|
if (idleTimerRef.current) clearTimeout(idleTimerRef.current);
|
|
@@ -2165,8 +2165,8 @@ function clamp2(n, min, max) {
|
|
|
2165
2165
|
return Math.max(min, Math.min(max, n));
|
|
2166
2166
|
}
|
|
2167
2167
|
function useFloatingPortalContainer(editor) {
|
|
2168
|
-
const [container, setContainer] =
|
|
2169
|
-
|
|
2168
|
+
const [container, setContainer] = React9.useState(null);
|
|
2169
|
+
React9.useEffect(() => {
|
|
2170
2170
|
const root = editor.getRootElement();
|
|
2171
2171
|
if (!root) return;
|
|
2172
2172
|
const panelOrLayer = root.closest(".ms-Panel-main") || root.closest(".ms-Panel") || root.closest(".ms-Layer") || document.body;
|
|
@@ -2204,22 +2204,22 @@ function FloatingCharacterStylesEditor({
|
|
|
2204
2204
|
isEditable,
|
|
2205
2205
|
readOnly
|
|
2206
2206
|
}) {
|
|
2207
|
-
const popupRef =
|
|
2208
|
-
const mouseDownRef =
|
|
2207
|
+
const popupRef = React9.useRef(null);
|
|
2208
|
+
const mouseDownRef = React9.useRef(false);
|
|
2209
2209
|
const theme2 = react.useTheme();
|
|
2210
2210
|
const disabled = !(isEditable ?? editor.isEditable()) || !!readOnly;
|
|
2211
|
-
const format =
|
|
2211
|
+
const format = React9.useCallback(
|
|
2212
2212
|
(type) => {
|
|
2213
2213
|
if (disabled) return;
|
|
2214
2214
|
editor.dispatchCommand(lexical.FORMAT_TEXT_COMMAND, type);
|
|
2215
2215
|
},
|
|
2216
2216
|
[editor, disabled]
|
|
2217
2217
|
);
|
|
2218
|
-
const toggleLink =
|
|
2218
|
+
const toggleLink = React9.useCallback(() => {
|
|
2219
2219
|
if (disabled) return;
|
|
2220
2220
|
editor.dispatchCommand(link.TOGGLE_LINK_COMMAND, isLink ? null : "https://");
|
|
2221
2221
|
}, [editor, disabled, isLink]);
|
|
2222
|
-
const updatePosition =
|
|
2222
|
+
const updatePosition = React9.useCallback(() => {
|
|
2223
2223
|
const popupEl = popupRef.current;
|
|
2224
2224
|
if (!popupEl) return;
|
|
2225
2225
|
const sel = window.getSelection();
|
|
@@ -2235,7 +2235,7 @@ function FloatingCharacterStylesEditor({
|
|
|
2235
2235
|
}
|
|
2236
2236
|
popupEl.classList.add("is-open");
|
|
2237
2237
|
}, [editor]);
|
|
2238
|
-
|
|
2238
|
+
React9.useEffect(() => {
|
|
2239
2239
|
const onResize = () => editor.getEditorState().read(updatePosition);
|
|
2240
2240
|
const onScroll = () => editor.getEditorState().read(updatePosition);
|
|
2241
2241
|
const root = editor.getRootElement();
|
|
@@ -2248,7 +2248,7 @@ function FloatingCharacterStylesEditor({
|
|
|
2248
2248
|
root?.removeEventListener("scroll", onScroll);
|
|
2249
2249
|
};
|
|
2250
2250
|
}, [editor, updatePosition]);
|
|
2251
|
-
|
|
2251
|
+
React9.useEffect(() => {
|
|
2252
2252
|
editor.getEditorState().read(updatePosition);
|
|
2253
2253
|
return utils.mergeRegister(
|
|
2254
2254
|
editor.registerUpdateListener(({ editorState }) => {
|
|
@@ -2419,18 +2419,18 @@ function getSelectedNode(selection$1) {
|
|
|
2419
2419
|
return isBackward ? selection.$isAtNodeEnd(selection$1.focus) ? anchorNode : focusNode : selection.$isAtNodeEnd(selection$1.anchor) ? focusNode : anchorNode;
|
|
2420
2420
|
}
|
|
2421
2421
|
function useCharacterStylesPopup(editor, opts) {
|
|
2422
|
-
const [isText, setIsText] =
|
|
2423
|
-
const [isLink, setIsLink] =
|
|
2424
|
-
const [isBold, setIsBold] =
|
|
2425
|
-
const [isItalic, setIsItalic] =
|
|
2426
|
-
const [isUnderline, setIsUnderline] =
|
|
2427
|
-
const [isStrikethrough, setIsStrikethrough] =
|
|
2428
|
-
const [isSubscript, setIsSubscript] =
|
|
2429
|
-
const [isSuperscript, setIsSuperscript] =
|
|
2430
|
-
const [isCode, setIsCode] =
|
|
2422
|
+
const [isText, setIsText] = React9.useState(false);
|
|
2423
|
+
const [isLink, setIsLink] = React9.useState(false);
|
|
2424
|
+
const [isBold, setIsBold] = React9.useState(false);
|
|
2425
|
+
const [isItalic, setIsItalic] = React9.useState(false);
|
|
2426
|
+
const [isUnderline, setIsUnderline] = React9.useState(false);
|
|
2427
|
+
const [isStrikethrough, setIsStrikethrough] = React9.useState(false);
|
|
2428
|
+
const [isSubscript, setIsSubscript] = React9.useState(false);
|
|
2429
|
+
const [isSuperscript, setIsSuperscript] = React9.useState(false);
|
|
2430
|
+
const [isCode, setIsCode] = React9.useState(false);
|
|
2431
2431
|
const isEditable = opts?.isEditable ?? editor.isEditable();
|
|
2432
2432
|
const portalContainer = useFloatingPortalContainer(editor);
|
|
2433
|
-
const updatePopupState =
|
|
2433
|
+
const updatePopupState = React9.useCallback(() => {
|
|
2434
2434
|
editor.getEditorState().read(() => {
|
|
2435
2435
|
const selection = lexical.$getSelection();
|
|
2436
2436
|
const nativeSelection = window.getSelection();
|
|
@@ -2457,11 +2457,11 @@ function useCharacterStylesPopup(editor, opts) {
|
|
|
2457
2457
|
}
|
|
2458
2458
|
});
|
|
2459
2459
|
}, [editor]);
|
|
2460
|
-
|
|
2460
|
+
React9.useEffect(() => {
|
|
2461
2461
|
document.addEventListener("selectionchange", updatePopupState);
|
|
2462
2462
|
return () => document.removeEventListener("selectionchange", updatePopupState);
|
|
2463
2463
|
}, [updatePopupState]);
|
|
2464
|
-
|
|
2464
|
+
React9.useEffect(() => editor.registerUpdateListener(updatePopupState), [editor, updatePopupState]);
|
|
2465
2465
|
if (!portalContainer || !isText || isLink) return null;
|
|
2466
2466
|
return reactDom.createPortal(
|
|
2467
2467
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2489,10 +2489,10 @@ function CharacterStylesPopupPlugin(props) {
|
|
|
2489
2489
|
}
|
|
2490
2490
|
var CustomOnChangePlugin = ({ value, onChange }) => {
|
|
2491
2491
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
2492
|
-
const initializedRef =
|
|
2493
|
-
const onChangeRef =
|
|
2492
|
+
const initializedRef = React9.useRef(false);
|
|
2493
|
+
const onChangeRef = React9.useRef(onChange);
|
|
2494
2494
|
onChangeRef.current = onChange;
|
|
2495
|
-
|
|
2495
|
+
React9.useEffect(() => {
|
|
2496
2496
|
if (!value || initializedRef.current) return;
|
|
2497
2497
|
initializedRef.current = true;
|
|
2498
2498
|
editor.update(() => {
|
|
@@ -2505,7 +2505,7 @@ var CustomOnChangePlugin = ({ value, onChange }) => {
|
|
|
2505
2505
|
lexical.$setSelection(null);
|
|
2506
2506
|
});
|
|
2507
2507
|
}, [editor, value]);
|
|
2508
|
-
const handleChange =
|
|
2508
|
+
const handleChange = React9.useCallback((editorState) => {
|
|
2509
2509
|
editorState.read(() => {
|
|
2510
2510
|
onChangeRef.current(html.$generateHtmlFromNodes(editor));
|
|
2511
2511
|
});
|
|
@@ -2580,12 +2580,12 @@ var preventDefault = (event) => {
|
|
|
2580
2580
|
event.preventDefault();
|
|
2581
2581
|
};
|
|
2582
2582
|
var FloatingLinkEditor = ({ editor, isLink, setIsLink, anchorElem, isLinkEditMode, setIsLinkEditMode }) => {
|
|
2583
|
-
const [editedLinkUrl, setEditedLinkUrl] =
|
|
2584
|
-
const [lastSelection, setLastSelection] =
|
|
2585
|
-
const [linkUrl, setLinkUrl] =
|
|
2586
|
-
const editorRef =
|
|
2587
|
-
const inputRef =
|
|
2588
|
-
const $updateLinkEditor =
|
|
2583
|
+
const [editedLinkUrl, setEditedLinkUrl] = React9.useState("https://");
|
|
2584
|
+
const [lastSelection, setLastSelection] = React9.useState(null);
|
|
2585
|
+
const [linkUrl, setLinkUrl] = React9.useState("");
|
|
2586
|
+
const editorRef = React9.useRef(null);
|
|
2587
|
+
const inputRef = React9.useRef(null);
|
|
2588
|
+
const $updateLinkEditor = React9.useCallback(() => {
|
|
2589
2589
|
const selection = lexical.$getSelection();
|
|
2590
2590
|
if (lexical.$isRangeSelection(selection)) {
|
|
2591
2591
|
const node = getSelectedNode2(selection);
|
|
@@ -2625,7 +2625,7 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, anchorElem, isLinkEditMod
|
|
|
2625
2625
|
}
|
|
2626
2626
|
return true;
|
|
2627
2627
|
}, [anchorElem, editor, setIsLinkEditMode, isLinkEditMode, linkUrl]);
|
|
2628
|
-
|
|
2628
|
+
React9.useEffect(() => {
|
|
2629
2629
|
const scrollerElem = anchorElem.parentElement;
|
|
2630
2630
|
const update = () => {
|
|
2631
2631
|
editor.getEditorState().read(() => {
|
|
@@ -2643,7 +2643,7 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, anchorElem, isLinkEditMod
|
|
|
2643
2643
|
}
|
|
2644
2644
|
};
|
|
2645
2645
|
}, [anchorElem.parentElement, editor, $updateLinkEditor]);
|
|
2646
|
-
|
|
2646
|
+
React9.useEffect(() => {
|
|
2647
2647
|
return utils.mergeRegister(
|
|
2648
2648
|
editor.registerUpdateListener(({ editorState }) => {
|
|
2649
2649
|
editorState.read(() => {
|
|
@@ -2671,12 +2671,12 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, anchorElem, isLinkEditMod
|
|
|
2671
2671
|
)
|
|
2672
2672
|
);
|
|
2673
2673
|
}, [editor, $updateLinkEditor, setIsLink, isLink]);
|
|
2674
|
-
|
|
2674
|
+
React9.useEffect(() => {
|
|
2675
2675
|
editor.getEditorState().read(() => {
|
|
2676
2676
|
$updateLinkEditor();
|
|
2677
2677
|
});
|
|
2678
2678
|
}, [editor, $updateLinkEditor]);
|
|
2679
|
-
|
|
2679
|
+
React9.useEffect(() => {
|
|
2680
2680
|
if (isLinkEditMode && inputRef.current) {
|
|
2681
2681
|
inputRef.current.focus();
|
|
2682
2682
|
}
|
|
@@ -2794,9 +2794,9 @@ var FloatingLinkEditor = ({ editor, isLink, setIsLink, anchorElem, isLinkEditMod
|
|
|
2794
2794
|
] }) });
|
|
2795
2795
|
};
|
|
2796
2796
|
var useFloatingLinkEditorToolbar = (editor, anchorElem, isLinkEditMode, setIsLinkEditMode) => {
|
|
2797
|
-
const [activeEditor, setActiveEditor] =
|
|
2798
|
-
const [isLink, setIsLink] =
|
|
2799
|
-
|
|
2797
|
+
const [activeEditor, setActiveEditor] = React9.useState(editor);
|
|
2798
|
+
const [isLink, setIsLink] = React9.useState(false);
|
|
2799
|
+
React9.useEffect(() => {
|
|
2800
2800
|
function $updateToolbar() {
|
|
2801
2801
|
const selection = lexical.$getSelection();
|
|
2802
2802
|
if (lexical.$isRangeSelection(selection)) {
|
|
@@ -2896,8 +2896,8 @@ var InsertImageByURL = ({
|
|
|
2896
2896
|
onClick,
|
|
2897
2897
|
disabled
|
|
2898
2898
|
}) => {
|
|
2899
|
-
const [altText, setAltText] =
|
|
2900
|
-
const [src, setSrc] =
|
|
2899
|
+
const [altText, setAltText] = React9.useState("");
|
|
2900
|
+
const [src, setSrc] = React9.useState("");
|
|
2901
2901
|
const isDisabled = disabled || src === "";
|
|
2902
2902
|
return /* @__PURE__ */ jsxRuntime.jsxs(react.Stack, { tokens: { childrenGap: 6, padding: "10px 0px 0px 0px" }, children: [
|
|
2903
2903
|
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Field, { label: "Enter URL", orientation: "horizontal", size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2951,15 +2951,15 @@ var InsertImageDialog = ({
|
|
|
2951
2951
|
activeEditor,
|
|
2952
2952
|
disabled
|
|
2953
2953
|
}) => {
|
|
2954
|
-
const [src, setSrc] =
|
|
2955
|
-
const [altText, setAltText] =
|
|
2956
|
-
const [isOpen, setIsOpen] =
|
|
2957
|
-
const [selectedValue, setSelectedValue] =
|
|
2958
|
-
const [fileName, setFileName] =
|
|
2959
|
-
const hasModifier =
|
|
2954
|
+
const [src, setSrc] = React9.useState("");
|
|
2955
|
+
const [altText, setAltText] = React9.useState("");
|
|
2956
|
+
const [isOpen, setIsOpen] = React9.useState(false);
|
|
2957
|
+
const [selectedValue, setSelectedValue] = React9.useState("Upload");
|
|
2958
|
+
const [fileName, setFileName] = React9.useState("");
|
|
2959
|
+
const hasModifier = React9.useRef(false);
|
|
2960
2960
|
const iconColor = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
|
|
2961
2961
|
const isDisabled = disabled || src === "";
|
|
2962
|
-
|
|
2962
|
+
React9.useEffect(() => {
|
|
2963
2963
|
hasModifier.current = false;
|
|
2964
2964
|
const handler = (e) => {
|
|
2965
2965
|
hasModifier.current = e.altKey;
|
|
@@ -3103,7 +3103,7 @@ var InsertImageDialog = ({
|
|
|
3103
3103
|
};
|
|
3104
3104
|
var ImagesPlugin = ({ captionsEnabled }) => {
|
|
3105
3105
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
3106
|
-
|
|
3106
|
+
React9.useEffect(() => {
|
|
3107
3107
|
if (!editor.hasNodes([ImageNode])) {
|
|
3108
3108
|
throw new Error("ImagesPlugin: ImageNode not registered on editor");
|
|
3109
3109
|
}
|
|
@@ -3267,12 +3267,12 @@ var InsertInlineImageDialog = ({
|
|
|
3267
3267
|
disabled,
|
|
3268
3268
|
activeEditor
|
|
3269
3269
|
}) => {
|
|
3270
|
-
const hasModifier =
|
|
3271
|
-
const [src, setSrc] =
|
|
3272
|
-
const [isOpen, setIsOpen] =
|
|
3273
|
-
const [altText, setAltText] =
|
|
3274
|
-
const [fileName, setFileName] =
|
|
3275
|
-
const [position, setPosition] =
|
|
3270
|
+
const hasModifier = React9.useRef(false);
|
|
3271
|
+
const [src, setSrc] = React9.useState("");
|
|
3272
|
+
const [isOpen, setIsOpen] = React9.useState(false);
|
|
3273
|
+
const [altText, setAltText] = React9.useState("");
|
|
3274
|
+
const [fileName, setFileName] = React9.useState("");
|
|
3275
|
+
const [position, setPosition] = React9.useState("left");
|
|
3276
3276
|
const styles = useStyles();
|
|
3277
3277
|
const iconColor = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
|
|
3278
3278
|
const isDisabled = disabled || src === "";
|
|
@@ -3289,7 +3289,7 @@ var InsertInlineImageDialog = ({
|
|
|
3289
3289
|
};
|
|
3290
3290
|
reader.readAsDataURL(files[0]);
|
|
3291
3291
|
};
|
|
3292
|
-
|
|
3292
|
+
React9.useEffect(() => {
|
|
3293
3293
|
const handler = (e) => {
|
|
3294
3294
|
hasModifier.current = e.altKey;
|
|
3295
3295
|
};
|
|
@@ -3443,7 +3443,7 @@ var InsertInlineImageDialog = ({
|
|
|
3443
3443
|
};
|
|
3444
3444
|
var InlineImagePlugin = () => {
|
|
3445
3445
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
3446
|
-
|
|
3446
|
+
React9.useEffect(() => {
|
|
3447
3447
|
if (!editor.hasNodes([InlineImageNode])) {
|
|
3448
3448
|
throw new Error("ImagesPlugin: ImageNode not registered on editor");
|
|
3449
3449
|
}
|
|
@@ -3567,7 +3567,7 @@ var getDragSelection2 = (event) => {
|
|
|
3567
3567
|
var INSERT_PAGE_BREAK = lexical.createCommand();
|
|
3568
3568
|
function PageBreakPlugin() {
|
|
3569
3569
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
3570
|
-
|
|
3570
|
+
React9.useEffect(() => {
|
|
3571
3571
|
if (!editor.hasNodes([PageBreakNode])) {
|
|
3572
3572
|
throw new Error(
|
|
3573
3573
|
"PageBreakPlugin: PageBreakNode is not registered on editor"
|
|
@@ -3845,7 +3845,7 @@ function RefApiPlugin({
|
|
|
3845
3845
|
setRefErrors
|
|
3846
3846
|
}) {
|
|
3847
3847
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
3848
|
-
|
|
3848
|
+
React9.useImperativeHandle(
|
|
3849
3849
|
forwardedRef,
|
|
3850
3850
|
() => ({
|
|
3851
3851
|
setValue: (html$1) => {
|
|
@@ -4031,28 +4031,28 @@ function SpellPopover({
|
|
|
4031
4031
|
onImprove,
|
|
4032
4032
|
onAcceptGrammar
|
|
4033
4033
|
}) {
|
|
4034
|
-
const ref =
|
|
4034
|
+
const ref = React9__namespace.useRef(null);
|
|
4035
4035
|
const type = state.issue.type ?? "spelling";
|
|
4036
|
-
const [pos, setPos] =
|
|
4037
|
-
|
|
4036
|
+
const [pos, setPos] = React9__namespace.useState({ left: state.x, top: state.y });
|
|
4037
|
+
React9__namespace.useEffect(() => {
|
|
4038
4038
|
if (!ref.current) return;
|
|
4039
4039
|
const { offsetHeight: h, offsetWidth: w } = ref.current;
|
|
4040
4040
|
const top = state.y + h > window.innerHeight - 8 ? state.y - h - 32 : state.y;
|
|
4041
4041
|
setPos({ left: Math.min(state.x, window.innerWidth - w - 8), top });
|
|
4042
4042
|
}, [state.x, state.y]);
|
|
4043
|
-
|
|
4043
|
+
React9__namespace.useEffect(() => {
|
|
4044
4044
|
const h = (e) => {
|
|
4045
4045
|
if (ref.current && !ref.current.contains(e.target)) onClose();
|
|
4046
4046
|
};
|
|
4047
4047
|
document.addEventListener("mousedown", h, true);
|
|
4048
4048
|
return () => document.removeEventListener("mousedown", h, true);
|
|
4049
4049
|
}, [onClose]);
|
|
4050
|
-
|
|
4050
|
+
React9__namespace.useEffect(() => {
|
|
4051
4051
|
const h = () => onClose();
|
|
4052
4052
|
window.addEventListener("scroll", h, { capture: true, passive: true });
|
|
4053
4053
|
return () => window.removeEventListener("scroll", h, true);
|
|
4054
4054
|
}, [onClose]);
|
|
4055
|
-
|
|
4055
|
+
React9__namespace.useEffect(() => {
|
|
4056
4056
|
const h = (e) => {
|
|
4057
4057
|
if (e.key === "Escape") onClose();
|
|
4058
4058
|
};
|
|
@@ -4169,17 +4169,17 @@ function SpellCheckPlugin({
|
|
|
4169
4169
|
enabled = true
|
|
4170
4170
|
}) {
|
|
4171
4171
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
4172
|
-
const timerRef =
|
|
4173
|
-
const dismissRef =
|
|
4174
|
-
const reqIdRef =
|
|
4175
|
-
const lastTextRef =
|
|
4176
|
-
const applyingRef =
|
|
4177
|
-
const grammarCorrectionRef =
|
|
4178
|
-
const [popover, setPopover] =
|
|
4179
|
-
|
|
4172
|
+
const timerRef = React9__namespace.useRef(null);
|
|
4173
|
+
const dismissRef = React9__namespace.useRef(null);
|
|
4174
|
+
const reqIdRef = React9__namespace.useRef(0);
|
|
4175
|
+
const lastTextRef = React9__namespace.useRef("");
|
|
4176
|
+
const applyingRef = React9__namespace.useRef(false);
|
|
4177
|
+
const grammarCorrectionRef = React9__namespace.useRef(void 0);
|
|
4178
|
+
const [popover, setPopover] = React9__namespace.useState(null);
|
|
4179
|
+
React9__namespace.useEffect(() => {
|
|
4180
4180
|
injectCSS();
|
|
4181
4181
|
}, []);
|
|
4182
|
-
const clearErrors =
|
|
4182
|
+
const clearErrors = React9__namespace.useCallback(() => {
|
|
4183
4183
|
setPopover(null);
|
|
4184
4184
|
grammarCorrectionRef.current = void 0;
|
|
4185
4185
|
applyingRef.current = true;
|
|
@@ -4195,7 +4195,7 @@ function SpellCheckPlugin({
|
|
|
4195
4195
|
}
|
|
4196
4196
|
);
|
|
4197
4197
|
}, [editor]);
|
|
4198
|
-
const applyIssues =
|
|
4198
|
+
const applyIssues = React9__namespace.useCallback(
|
|
4199
4199
|
(issues, improvedText, trimOffset = 0) => {
|
|
4200
4200
|
let savedCharOffset = -1;
|
|
4201
4201
|
editor.getEditorState().read(() => {
|
|
@@ -4338,7 +4338,7 @@ function SpellCheckPlugin({
|
|
|
4338
4338
|
},
|
|
4339
4339
|
[editor]
|
|
4340
4340
|
);
|
|
4341
|
-
|
|
4341
|
+
React9__namespace.useEffect(() => {
|
|
4342
4342
|
let currentRoot = null;
|
|
4343
4343
|
const onClick = (e) => {
|
|
4344
4344
|
const span = e.target.closest("[data-spell-offset]");
|
|
@@ -4382,7 +4382,7 @@ function SpellCheckPlugin({
|
|
|
4382
4382
|
if (currentRoot) currentRoot.removeEventListener("click", onClick);
|
|
4383
4383
|
};
|
|
4384
4384
|
}, [editor]);
|
|
4385
|
-
const handleAccept =
|
|
4385
|
+
const handleAccept = React9__namespace.useCallback(
|
|
4386
4386
|
(replacement, nodeKey) => {
|
|
4387
4387
|
let original = "";
|
|
4388
4388
|
editor.getEditorState().read(() => {
|
|
@@ -4408,7 +4408,7 @@ function SpellCheckPlugin({
|
|
|
4408
4408
|
},
|
|
4409
4409
|
[editor, onSpellCheckAccept, popover]
|
|
4410
4410
|
);
|
|
4411
|
-
const handleDismiss =
|
|
4411
|
+
const handleDismiss = React9__namespace.useCallback(
|
|
4412
4412
|
(nodeKey) => {
|
|
4413
4413
|
editor.update(
|
|
4414
4414
|
() => {
|
|
@@ -4422,7 +4422,7 @@ function SpellCheckPlugin({
|
|
|
4422
4422
|
},
|
|
4423
4423
|
[editor]
|
|
4424
4424
|
);
|
|
4425
|
-
const handleImprove =
|
|
4425
|
+
const handleImprove = React9__namespace.useCallback(
|
|
4426
4426
|
(text) => {
|
|
4427
4427
|
const original = lastTextRef.current;
|
|
4428
4428
|
applyingRef.current = true;
|
|
@@ -4442,7 +4442,7 @@ function SpellCheckPlugin({
|
|
|
4442
4442
|
},
|
|
4443
4443
|
[editor, onSpellCheckAccept]
|
|
4444
4444
|
);
|
|
4445
|
-
const handleAcceptGrammar =
|
|
4445
|
+
const handleAcceptGrammar = React9__namespace.useCallback(
|
|
4446
4446
|
(corrected) => {
|
|
4447
4447
|
const original = lastTextRef.current;
|
|
4448
4448
|
applyingRef.current = true;
|
|
@@ -4462,7 +4462,7 @@ function SpellCheckPlugin({
|
|
|
4462
4462
|
},
|
|
4463
4463
|
[editor, onSpellCheckAccept]
|
|
4464
4464
|
);
|
|
4465
|
-
|
|
4465
|
+
React9__namespace.useEffect(() => {
|
|
4466
4466
|
if (!enabled || !useSpellCheck) return;
|
|
4467
4467
|
return editor.registerUpdateListener(({ tags }) => {
|
|
4468
4468
|
if (applyingRef.current) return;
|
|
@@ -4500,13 +4500,13 @@ function SpellCheckPlugin({
|
|
|
4500
4500
|
}, idleMs);
|
|
4501
4501
|
});
|
|
4502
4502
|
}, [editor, useSpellCheck, enabled, idleMs, applyIssues, clearErrors]);
|
|
4503
|
-
|
|
4503
|
+
React9__namespace.useEffect(() => {
|
|
4504
4504
|
if (!enabled) {
|
|
4505
4505
|
clearErrors();
|
|
4506
4506
|
lastTextRef.current = "";
|
|
4507
4507
|
}
|
|
4508
4508
|
}, [enabled, clearErrors]);
|
|
4509
|
-
|
|
4509
|
+
React9__namespace.useEffect(
|
|
4510
4510
|
() => () => {
|
|
4511
4511
|
dismissRef.current?.();
|
|
4512
4512
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
@@ -4527,10 +4527,10 @@ function SpellCheckPlugin({
|
|
|
4527
4527
|
}
|
|
4528
4528
|
function TableActionMenuPlugin({ disabled = false }) {
|
|
4529
4529
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
4530
|
-
const [isInTable, setIsInTable] =
|
|
4531
|
-
const [anchorRect, setAnchorRect] =
|
|
4532
|
-
const [open, setOpen] =
|
|
4533
|
-
const updateFromSelection =
|
|
4530
|
+
const [isInTable, setIsInTable] = React9__namespace.useState(false);
|
|
4531
|
+
const [anchorRect, setAnchorRect] = React9__namespace.useState(null);
|
|
4532
|
+
const [open, setOpen] = React9__namespace.useState(false);
|
|
4533
|
+
const updateFromSelection = React9__namespace.useCallback(() => {
|
|
4534
4534
|
const root = editor.getRootElement();
|
|
4535
4535
|
if (!root) return;
|
|
4536
4536
|
editor.getEditorState().read(() => {
|
|
@@ -4568,7 +4568,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
4568
4568
|
setAnchorRect(cellDom.getBoundingClientRect());
|
|
4569
4569
|
});
|
|
4570
4570
|
}, [editor]);
|
|
4571
|
-
|
|
4571
|
+
React9__namespace.useEffect(() => {
|
|
4572
4572
|
return utils.mergeRegister(
|
|
4573
4573
|
editor.registerCommand(
|
|
4574
4574
|
lexical.SELECTION_CHANGE_COMMAND,
|
|
@@ -4583,7 +4583,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
4583
4583
|
})
|
|
4584
4584
|
);
|
|
4585
4585
|
}, [editor, updateFromSelection]);
|
|
4586
|
-
|
|
4586
|
+
React9__namespace.useEffect(() => {
|
|
4587
4587
|
return editor.registerCommand(
|
|
4588
4588
|
lexical.KEY_DOWN_COMMAND,
|
|
4589
4589
|
(event) => {
|
|
@@ -4624,11 +4624,11 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
4624
4624
|
lexical.COMMAND_PRIORITY_HIGH
|
|
4625
4625
|
);
|
|
4626
4626
|
}, [editor, disabled]);
|
|
4627
|
-
|
|
4627
|
+
React9__namespace.useEffect(() => {
|
|
4628
4628
|
if (!isInTable && open) setOpen(false);
|
|
4629
4629
|
}, [isInTable, open]);
|
|
4630
4630
|
const canShow = isInTable && !!anchorRect && !disabled;
|
|
4631
|
-
const handleStyle =
|
|
4631
|
+
const handleStyle = React9__namespace.useMemo(() => {
|
|
4632
4632
|
if (!anchorRect) return void 0;
|
|
4633
4633
|
const top = Math.max(8, anchorRect.top + 6);
|
|
4634
4634
|
const left = Math.max(8, anchorRect.right - 34);
|
|
@@ -4642,7 +4642,7 @@ function TableActionMenuPlugin({ disabled = false }) {
|
|
|
4642
4642
|
const dangerStyle = {
|
|
4643
4643
|
color: "var(--colorPaletteRedForeground1)"
|
|
4644
4644
|
};
|
|
4645
|
-
const run =
|
|
4645
|
+
const run = React9__namespace.useCallback(
|
|
4646
4646
|
(fn) => {
|
|
4647
4647
|
if (disabled) return;
|
|
4648
4648
|
editor.focus();
|
|
@@ -4737,17 +4737,17 @@ function TableCellResizer({
|
|
|
4737
4737
|
editor,
|
|
4738
4738
|
anchorElem
|
|
4739
4739
|
}) {
|
|
4740
|
-
const targetRef =
|
|
4741
|
-
const resizerRef =
|
|
4742
|
-
const tableRectRef =
|
|
4743
|
-
const mouseStartPosRef =
|
|
4744
|
-
const [mouseCurrentPos, updateMouseCurrentPos] =
|
|
4745
|
-
const [activeCell, updateActiveCell] =
|
|
4746
|
-
const [isSelectingGrid, updateIsSelectingGrid] =
|
|
4747
|
-
const [draggingDirection, updateDraggingDirection] =
|
|
4740
|
+
const targetRef = React9.useRef(null);
|
|
4741
|
+
const resizerRef = React9.useRef(null);
|
|
4742
|
+
const tableRectRef = React9.useRef(null);
|
|
4743
|
+
const mouseStartPosRef = React9.useRef(null);
|
|
4744
|
+
const [mouseCurrentPos, updateMouseCurrentPos] = React9.useState(null);
|
|
4745
|
+
const [activeCell, updateActiveCell] = React9.useState(null);
|
|
4746
|
+
const [isSelectingGrid, updateIsSelectingGrid] = React9.useState(false);
|
|
4747
|
+
const [draggingDirection, updateDraggingDirection] = React9.useState(
|
|
4748
4748
|
null
|
|
4749
4749
|
);
|
|
4750
|
-
|
|
4750
|
+
React9.useEffect(() => {
|
|
4751
4751
|
return editor.registerCommand(
|
|
4752
4752
|
lexical.SELECTION_CHANGE_COMMAND,
|
|
4753
4753
|
() => {
|
|
@@ -4770,7 +4770,7 @@ function TableCellResizer({
|
|
|
4770
4770
|
lexical.COMMAND_PRIORITY_HIGH
|
|
4771
4771
|
);
|
|
4772
4772
|
}, [editor]);
|
|
4773
|
-
const resetState =
|
|
4773
|
+
const resetState = React9.useCallback(() => {
|
|
4774
4774
|
updateActiveCell(null);
|
|
4775
4775
|
targetRef.current = null;
|
|
4776
4776
|
updateDraggingDirection(null);
|
|
@@ -4778,7 +4778,7 @@ function TableCellResizer({
|
|
|
4778
4778
|
tableRectRef.current = null;
|
|
4779
4779
|
updateMouseCurrentPos(null);
|
|
4780
4780
|
}, []);
|
|
4781
|
-
|
|
4781
|
+
React9.useEffect(() => {
|
|
4782
4782
|
const onMouseMove = (event) => {
|
|
4783
4783
|
if (draggingDirection) {
|
|
4784
4784
|
updateMouseCurrentPos({ x: event.clientX, y: event.clientY });
|
|
@@ -4822,7 +4822,7 @@ function TableCellResizer({
|
|
|
4822
4822
|
};
|
|
4823
4823
|
}, [activeCell, draggingDirection, editor, resetState, anchorElem]);
|
|
4824
4824
|
const isHeightChanging = (direction) => direction === "bottom";
|
|
4825
|
-
const updateRowHeight =
|
|
4825
|
+
const updateRowHeight = React9.useCallback(
|
|
4826
4826
|
(newHeight) => {
|
|
4827
4827
|
if (!activeCell) return;
|
|
4828
4828
|
editor.update(() => {
|
|
@@ -4839,7 +4839,7 @@ function TableCellResizer({
|
|
|
4839
4839
|
},
|
|
4840
4840
|
[activeCell, editor]
|
|
4841
4841
|
);
|
|
4842
|
-
const updateColumnWidth =
|
|
4842
|
+
const updateColumnWidth = React9.useCallback(
|
|
4843
4843
|
(newWidth) => {
|
|
4844
4844
|
if (!activeCell) return;
|
|
4845
4845
|
editor.update(() => {
|
|
@@ -4861,7 +4861,7 @@ function TableCellResizer({
|
|
|
4861
4861
|
},
|
|
4862
4862
|
[activeCell, editor]
|
|
4863
4863
|
);
|
|
4864
|
-
const toggleResize =
|
|
4864
|
+
const toggleResize = React9.useCallback(
|
|
4865
4865
|
(direction) => (event) => {
|
|
4866
4866
|
event.preventDefault();
|
|
4867
4867
|
event.stopPropagation();
|
|
@@ -4892,7 +4892,7 @@ function TableCellResizer({
|
|
|
4892
4892
|
},
|
|
4893
4893
|
[activeCell, draggingDirection, resetState, updateColumnWidth, updateRowHeight]
|
|
4894
4894
|
);
|
|
4895
|
-
const getResizers =
|
|
4895
|
+
const getResizers = React9.useCallback(() => {
|
|
4896
4896
|
const empty = { bottom: {}, right: {} };
|
|
4897
4897
|
if (!activeCell) return empty;
|
|
4898
4898
|
const cellRect = activeCell.elem.getBoundingClientRect();
|
|
@@ -4967,7 +4967,7 @@ function TableCellResizerPlugin({
|
|
|
4967
4967
|
anchorElem
|
|
4968
4968
|
}) {
|
|
4969
4969
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
4970
|
-
return
|
|
4970
|
+
return React9.useMemo(
|
|
4971
4971
|
() => reactDom.createPortal(/* @__PURE__ */ jsxRuntime.jsx(TableCellResizer, { editor, anchorElem }), anchorElem),
|
|
4972
4972
|
[editor, anchorElem]
|
|
4973
4973
|
);
|
|
@@ -5053,10 +5053,16 @@ var PRESET = [
|
|
|
5053
5053
|
];
|
|
5054
5054
|
var clamp3 = (v, min, max) => Math.min(max, Math.max(min, v));
|
|
5055
5055
|
var normalizeHex = (v) => {
|
|
5056
|
-
|
|
5056
|
+
const s = (v ?? "").trim();
|
|
5057
5057
|
if (!s) return "#000000";
|
|
5058
|
-
|
|
5059
|
-
if (
|
|
5058
|
+
const rgbMatch = s.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)$/i);
|
|
5059
|
+
if (rgbMatch) {
|
|
5060
|
+
const [, r, g, b] = rgbMatch;
|
|
5061
|
+
return rgbToHex(clamp3(+r, 0, 255), clamp3(+g, 0, 255), clamp3(+b, 0, 255));
|
|
5062
|
+
}
|
|
5063
|
+
let hex = s.startsWith("#") ? s : `#${s}`;
|
|
5064
|
+
if (hex.length === 9) hex = hex.slice(0, 7);
|
|
5065
|
+
if (hex.length === 4 || hex.length === 7) return hex.toLowerCase();
|
|
5060
5066
|
return "#000000";
|
|
5061
5067
|
};
|
|
5062
5068
|
var hexToRgb = (hex) => {
|
|
@@ -5107,8 +5113,8 @@ var hsvToRgb = (h, s, v) => {
|
|
|
5107
5113
|
};
|
|
5108
5114
|
};
|
|
5109
5115
|
function useDrag(onMove, onEnd, interactingRef) {
|
|
5110
|
-
const draggingRef =
|
|
5111
|
-
const start =
|
|
5116
|
+
const draggingRef = React9__namespace.useRef(false);
|
|
5117
|
+
const start = React9__namespace.useCallback(
|
|
5112
5118
|
(e) => {
|
|
5113
5119
|
draggingRef.current = true;
|
|
5114
5120
|
if (interactingRef) interactingRef.current = true;
|
|
@@ -5140,19 +5146,19 @@ function useDrag(onMove, onEnd, interactingRef) {
|
|
|
5140
5146
|
return start;
|
|
5141
5147
|
}
|
|
5142
5148
|
var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
|
|
5143
|
-
const [open, setOpen] =
|
|
5144
|
-
const btnRef =
|
|
5145
|
-
const interactingRef =
|
|
5146
|
-
const handleDismiss =
|
|
5147
|
-
const preventDismissOnEvent =
|
|
5149
|
+
const [open, setOpen] = React9__namespace.useState(false);
|
|
5150
|
+
const btnRef = React9__namespace.useRef(null);
|
|
5151
|
+
const interactingRef = React9__namespace.useRef(false);
|
|
5152
|
+
const handleDismiss = React9__namespace.useCallback(() => setOpen(false), []);
|
|
5153
|
+
const preventDismissOnEvent = React9__namespace.useCallback(
|
|
5148
5154
|
(ev) => {
|
|
5149
5155
|
if (interactingRef.current) return true;
|
|
5150
5156
|
return ev.type !== "click";
|
|
5151
5157
|
},
|
|
5152
5158
|
[]
|
|
5153
5159
|
);
|
|
5154
|
-
const [, forceReposition] =
|
|
5155
|
-
|
|
5160
|
+
const [, forceReposition] = React9__namespace.useState(0);
|
|
5161
|
+
React9__namespace.useEffect(() => {
|
|
5156
5162
|
if (!open) return;
|
|
5157
5163
|
let rafId = null;
|
|
5158
5164
|
const reposition = () => {
|
|
@@ -5170,13 +5176,17 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
|
|
|
5170
5176
|
window.removeEventListener("resize", reposition);
|
|
5171
5177
|
};
|
|
5172
5178
|
}, [open]);
|
|
5173
|
-
const [hex, setHex] =
|
|
5174
|
-
const { r, g, b } =
|
|
5175
|
-
const hsv =
|
|
5176
|
-
const [h, setH] =
|
|
5177
|
-
const [s, setS] =
|
|
5178
|
-
const [v, setV] =
|
|
5179
|
-
|
|
5179
|
+
const [hex, setHex] = React9__namespace.useState(normalizeHex(value || "#000000"));
|
|
5180
|
+
const { r, g, b } = React9__namespace.useMemo(() => hexToRgb(hex), [hex]);
|
|
5181
|
+
const hsv = React9__namespace.useMemo(() => rgbToHsv(r, g, b), [r, g, b]);
|
|
5182
|
+
const [h, setH] = React9__namespace.useState(hsv.h);
|
|
5183
|
+
const [s, setS] = React9__namespace.useState(hsv.s);
|
|
5184
|
+
const [v, setV] = React9__namespace.useState(hsv.v);
|
|
5185
|
+
const wasOpenRef = React9__namespace.useRef(open);
|
|
5186
|
+
React9__namespace.useEffect(() => {
|
|
5187
|
+
const justOpened = open && !wasOpenRef.current;
|
|
5188
|
+
wasOpenRef.current = open;
|
|
5189
|
+
if (!justOpened) return;
|
|
5180
5190
|
const n = normalizeHex(value || "#000000");
|
|
5181
5191
|
setHex(n);
|
|
5182
5192
|
const rgb = hexToRgb(n);
|
|
@@ -5184,8 +5194,8 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
|
|
|
5184
5194
|
setH(next.h);
|
|
5185
5195
|
setS(next.s);
|
|
5186
5196
|
setV(next.v);
|
|
5187
|
-
}, [value]);
|
|
5188
|
-
const commitHsv =
|
|
5197
|
+
}, [value, open]);
|
|
5198
|
+
const commitHsv = React9__namespace.useCallback(
|
|
5189
5199
|
(hh, ss, vv, close) => {
|
|
5190
5200
|
const rgb = hsvToRgb(hh, ss, vv);
|
|
5191
5201
|
const nextHex = rgbToHex(rgb.r, rgb.g, rgb.b);
|
|
@@ -5195,8 +5205,8 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
|
|
|
5195
5205
|
},
|
|
5196
5206
|
[onChange]
|
|
5197
5207
|
);
|
|
5198
|
-
const svRef =
|
|
5199
|
-
const onSVMove =
|
|
5208
|
+
const svRef = React9__namespace.useRef(null);
|
|
5209
|
+
const onSVMove = React9__namespace.useCallback(
|
|
5200
5210
|
(clientX, clientY) => {
|
|
5201
5211
|
if (!svRef.current) return;
|
|
5202
5212
|
const rect = svRef.current.getBoundingClientRect();
|
|
@@ -5211,8 +5221,8 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
|
|
|
5211
5221
|
[h, commitHsv]
|
|
5212
5222
|
);
|
|
5213
5223
|
const startSV = useDrag(onSVMove, void 0, interactingRef);
|
|
5214
|
-
const hueRef =
|
|
5215
|
-
const onHueMove =
|
|
5224
|
+
const hueRef = React9__namespace.useRef(null);
|
|
5225
|
+
const onHueMove = React9__namespace.useCallback(
|
|
5216
5226
|
(clientX) => {
|
|
5217
5227
|
if (!hueRef.current) return;
|
|
5218
5228
|
const rect = hueRef.current.getBoundingClientRect();
|
|
@@ -5224,9 +5234,9 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
|
|
|
5224
5234
|
[s, v, commitHsv]
|
|
5225
5235
|
);
|
|
5226
5236
|
const startHue = useDrag((x) => onHueMove(x), void 0, interactingRef);
|
|
5227
|
-
const svThumb =
|
|
5228
|
-
const hueThumb =
|
|
5229
|
-
const hueColor =
|
|
5237
|
+
const svThumb = React9__namespace.useMemo(() => ({ left: `${s * 100}%`, top: `${(1 - v) * 100}%` }), [s, v]);
|
|
5238
|
+
const hueThumb = React9__namespace.useMemo(() => ({ left: `${h / 360 * 100}%` }), [h]);
|
|
5239
|
+
const hueColor = React9__namespace.useMemo(() => {
|
|
5230
5240
|
const { r: r2, g: g2, b: b2 } = hsvToRgb(h, 1, 1);
|
|
5231
5241
|
return rgbToHex(r2, g2, b2);
|
|
5232
5242
|
}, [h]);
|
|
@@ -5234,6 +5244,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
|
|
|
5234
5244
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5235
5245
|
reactComponents.Button,
|
|
5236
5246
|
{
|
|
5247
|
+
type: "button",
|
|
5237
5248
|
size: "small",
|
|
5238
5249
|
icon,
|
|
5239
5250
|
value: title,
|
|
@@ -5333,13 +5344,14 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
|
|
|
5333
5344
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5334
5345
|
react.DefaultButton,
|
|
5335
5346
|
{
|
|
5347
|
+
type: "button",
|
|
5336
5348
|
text: "Apply",
|
|
5337
5349
|
onClick: () => {
|
|
5338
5350
|
commitHsv(h, s, v, true);
|
|
5339
5351
|
}
|
|
5340
5352
|
}
|
|
5341
5353
|
),
|
|
5342
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.DefaultButton, { text: "Close", onClick: () => setOpen(false) })
|
|
5354
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DefaultButton, { type: "button", text: "Close", onClick: () => setOpen(false) })
|
|
5343
5355
|
] })
|
|
5344
5356
|
] })
|
|
5345
5357
|
}
|
|
@@ -5348,8 +5360,8 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
|
|
|
5348
5360
|
};
|
|
5349
5361
|
var ColorPickerPlugin = ({ disabled }) => {
|
|
5350
5362
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
5351
|
-
const [{ color, bgColor }, setColors] =
|
|
5352
|
-
const lastRangeSelectionRef =
|
|
5363
|
+
const [{ color, bgColor }, setColors] = React9__namespace.default.useState({ color: "#000000", bgColor: "#ffffff" });
|
|
5364
|
+
const lastRangeSelectionRef = React9__namespace.default.useRef(null);
|
|
5353
5365
|
const updateToolbar = () => {
|
|
5354
5366
|
const selection$1 = lexical.$getSelection();
|
|
5355
5367
|
if (lexical.$isRangeSelection(selection$1)) {
|
|
@@ -5359,7 +5371,7 @@ var ColorPickerPlugin = ({ disabled }) => {
|
|
|
5359
5371
|
setColors({ color: c, bgColor: bg });
|
|
5360
5372
|
}
|
|
5361
5373
|
};
|
|
5362
|
-
|
|
5374
|
+
React9__namespace.default.useEffect(() => {
|
|
5363
5375
|
return utils.mergeRegister(
|
|
5364
5376
|
editor.registerUpdateListener(({ editorState }) => {
|
|
5365
5377
|
editorState.read(() => updateToolbar());
|
|
@@ -5448,9 +5460,9 @@ var FONT_FAMILY_OPTIONS = [
|
|
|
5448
5460
|
var FontFamilyPlugin = ({ disabled = false }) => {
|
|
5449
5461
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
5450
5462
|
const styles = useStyles2();
|
|
5451
|
-
const [fontFamily, setFontFamily] =
|
|
5463
|
+
const [fontFamily, setFontFamily] = React9.useState("");
|
|
5452
5464
|
const fg = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
|
|
5453
|
-
|
|
5465
|
+
React9.useEffect(() => {
|
|
5454
5466
|
const readFontFamily = () => {
|
|
5455
5467
|
const selection$1 = lexical.$getSelection();
|
|
5456
5468
|
if (lexical.$isRangeSelection(selection$1)) {
|
|
@@ -5472,7 +5484,7 @@ var FontFamilyPlugin = ({ disabled = false }) => {
|
|
|
5472
5484
|
)
|
|
5473
5485
|
);
|
|
5474
5486
|
}, [editor]);
|
|
5475
|
-
const handleClick =
|
|
5487
|
+
const handleClick = React9.useCallback(
|
|
5476
5488
|
(option) => {
|
|
5477
5489
|
if (disabled) return;
|
|
5478
5490
|
editor.update(() => {
|
|
@@ -5575,9 +5587,9 @@ var useStyles3 = reactComponents.makeStyles({
|
|
|
5575
5587
|
var FontSizePlugin = ({ disabled }) => {
|
|
5576
5588
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
5577
5589
|
const styles = useStyles3();
|
|
5578
|
-
const [fontSize2, setFontSize] =
|
|
5590
|
+
const [fontSize2, setFontSize] = React9__namespace.useState(String(DEFAULT_FONT_SIZE));
|
|
5579
5591
|
const fg = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
|
|
5580
|
-
|
|
5592
|
+
React9__namespace.useEffect(() => {
|
|
5581
5593
|
const readFontSize = () => {
|
|
5582
5594
|
const selection$1 = lexical.$getSelection();
|
|
5583
5595
|
if (lexical.$isRangeSelection(selection$1)) {
|
|
@@ -5655,9 +5667,9 @@ var FontSizePlugin = ({ disabled }) => {
|
|
|
5655
5667
|
};
|
|
5656
5668
|
var InsertLinkPlugin = ({ disabled }) => {
|
|
5657
5669
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
5658
|
-
const [isOpen, setIsOpen] =
|
|
5659
|
-
const [text, setText] =
|
|
5660
|
-
const [link$1, setLink] =
|
|
5670
|
+
const [isOpen, setIsOpen] = React9.useState(false);
|
|
5671
|
+
const [text, setText] = React9.useState("");
|
|
5672
|
+
const [link$1, setLink] = React9.useState("");
|
|
5661
5673
|
const iconColor = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
|
|
5662
5674
|
const insertLink = (text2, link2) => {
|
|
5663
5675
|
if (disabled) return;
|
|
@@ -5755,9 +5767,9 @@ var InsertLinkPlugin = ({ disabled }) => {
|
|
|
5755
5767
|
};
|
|
5756
5768
|
var TableItemPlugin = ({ disabled }) => {
|
|
5757
5769
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
5758
|
-
const [columns, setColumns] =
|
|
5759
|
-
const [rows, setRows] =
|
|
5760
|
-
const [isOpen, setIsOpen] =
|
|
5770
|
+
const [columns, setColumns] = React9.useState("");
|
|
5771
|
+
const [rows, setRows] = React9.useState("");
|
|
5772
|
+
const [isOpen, setIsOpen] = React9.useState(false);
|
|
5761
5773
|
const iconColor = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#333333";
|
|
5762
5774
|
const onAddTable = () => {
|
|
5763
5775
|
if (disabled) return;
|
|
@@ -5862,8 +5874,8 @@ var TableItemPlugin = ({ disabled }) => {
|
|
|
5862
5874
|
);
|
|
5863
5875
|
};
|
|
5864
5876
|
var YoutubeUploadPlugin = ({ disabled }) => {
|
|
5865
|
-
const [url, setURL] =
|
|
5866
|
-
const [isOpen, setIsOpen] =
|
|
5877
|
+
const [url, setURL] = React9.useState("");
|
|
5878
|
+
const [isOpen, setIsOpen] = React9.useState(false);
|
|
5867
5879
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
5868
5880
|
const iconColor = disabled ? "var(--colorNeutralForegroundDisabled, #A6A6A6)" : "#424242";
|
|
5869
5881
|
const onHandleEmbeded = () => {
|
|
@@ -5982,22 +5994,22 @@ var ToolBarPlugins = (props) => {
|
|
|
5982
5994
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
5983
5995
|
const theme2 = react.useTheme();
|
|
5984
5996
|
const styles = useStyles4();
|
|
5985
|
-
const [selectNodeType, setSelectNodeType] =
|
|
5986
|
-
const [isEditable, setIsEditable] =
|
|
5987
|
-
const [isBold, setIsBold] =
|
|
5988
|
-
const [isItalic, setIsItalic] =
|
|
5989
|
-
const [isUnderline, setIsUnderline] =
|
|
5990
|
-
const [isStrikethrough, setIsStrikethrough] =
|
|
5991
|
-
const [isSuperscript, setIsSuperscript] =
|
|
5992
|
-
const [isSubscript, setIsSubscript] =
|
|
5993
|
-
const [isHighlight, setIsHighlight] =
|
|
5994
|
-
const [isUppercase, setIsUppercase] =
|
|
5995
|
-
const [isLowercase, setIsLowercase] =
|
|
5996
|
-
const [isCapitalize, setIsCapitalize] =
|
|
5997
|
-
const [alignment, setAlignment] =
|
|
5998
|
-
const lastSelectionRef =
|
|
5997
|
+
const [selectNodeType, setSelectNodeType] = React9.useState("paragraph");
|
|
5998
|
+
const [isEditable, setIsEditable] = React9.useState(() => editor.isEditable());
|
|
5999
|
+
const [isBold, setIsBold] = React9.useState(false);
|
|
6000
|
+
const [isItalic, setIsItalic] = React9.useState(false);
|
|
6001
|
+
const [isUnderline, setIsUnderline] = React9.useState(false);
|
|
6002
|
+
const [isStrikethrough, setIsStrikethrough] = React9.useState(false);
|
|
6003
|
+
const [isSuperscript, setIsSuperscript] = React9.useState(false);
|
|
6004
|
+
const [isSubscript, setIsSubscript] = React9.useState(false);
|
|
6005
|
+
const [isHighlight, setIsHighlight] = React9.useState(false);
|
|
6006
|
+
const [isUppercase, setIsUppercase] = React9.useState(false);
|
|
6007
|
+
const [isLowercase, setIsLowercase] = React9.useState(false);
|
|
6008
|
+
const [isCapitalize, setIsCapitalize] = React9.useState(false);
|
|
6009
|
+
const [alignment, setAlignment] = React9.useState("left");
|
|
6010
|
+
const lastSelectionRef = React9__namespace.default.useRef(null);
|
|
5999
6011
|
const presetGroups = getToolbarGroupsByLevel(props.level);
|
|
6000
|
-
const pluginGroups =
|
|
6012
|
+
const pluginGroups = React9.useMemo(() => sanitizePluginGroups(presetGroups), [presetGroups]);
|
|
6001
6013
|
const updateToolbarPlugins = () => {
|
|
6002
6014
|
const selection = lexical.$getSelection();
|
|
6003
6015
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -6049,7 +6061,7 @@ var ToolBarPlugins = (props) => {
|
|
|
6049
6061
|
["paragraph", "h1", "h2", "h3", "h4", "h5", "h6", "ul", "ol", "quote", "code"].includes(type) ? type : "paragraph"
|
|
6050
6062
|
);
|
|
6051
6063
|
};
|
|
6052
|
-
const applyToBlock =
|
|
6064
|
+
const applyToBlock = React9__namespace.default.useCallback(
|
|
6053
6065
|
(fn) => {
|
|
6054
6066
|
editor.update(() => {
|
|
6055
6067
|
const saved = lastSelectionRef.current;
|
|
@@ -6069,7 +6081,7 @@ var ToolBarPlugins = (props) => {
|
|
|
6069
6081
|
}
|
|
6070
6082
|
});
|
|
6071
6083
|
};
|
|
6072
|
-
|
|
6084
|
+
React9__namespace.default.useEffect(() => {
|
|
6073
6085
|
return utils.mergeRegister(
|
|
6074
6086
|
editor.registerEditableListener((editable) => {
|
|
6075
6087
|
setIsEditable(editable);
|
|
@@ -6530,7 +6542,7 @@ var ToolBarPlugins = (props) => {
|
|
|
6530
6542
|
padding: "0px",
|
|
6531
6543
|
minHeight: 36
|
|
6532
6544
|
},
|
|
6533
|
-
children: pluginGroups.map((group, groupIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6545
|
+
children: pluginGroups.map((group, groupIndex) => /* @__PURE__ */ jsxRuntime.jsx(React9__namespace.default.Fragment, { children: group.map((token, tokenIndex) => {
|
|
6534
6546
|
try {
|
|
6535
6547
|
return renderToken(token, groupIndex, tokenIndex);
|
|
6536
6548
|
} catch {
|
|
@@ -6549,7 +6561,7 @@ function isYoutubeLikeNode(node) {
|
|
|
6549
6561
|
}
|
|
6550
6562
|
function YoutubeDeletePlugin() {
|
|
6551
6563
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6552
|
-
|
|
6564
|
+
React9.useEffect(() => {
|
|
6553
6565
|
const removeIfYoutubeAtCursor = (direction) => {
|
|
6554
6566
|
const selection = lexical.$getSelection();
|
|
6555
6567
|
if (!lexical.$isRangeSelection(selection)) return false;
|
|
@@ -6581,7 +6593,7 @@ function YoutubeDeletePlugin() {
|
|
|
6581
6593
|
lexical.COMMAND_PRIORITY_HIGH
|
|
6582
6594
|
);
|
|
6583
6595
|
}, [editor]);
|
|
6584
|
-
|
|
6596
|
+
React9.useEffect(() => {
|
|
6585
6597
|
return editor.registerCommand(
|
|
6586
6598
|
lexical.KEY_DELETE_COMMAND,
|
|
6587
6599
|
() => {
|
|
@@ -6670,14 +6682,14 @@ var theme = {
|
|
|
6670
6682
|
};
|
|
6671
6683
|
function ReadOnlyPlugin({ readonly }) {
|
|
6672
6684
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6673
|
-
|
|
6685
|
+
React9.useEffect(() => {
|
|
6674
6686
|
editor.setEditable(!readonly);
|
|
6675
6687
|
}, [editor, readonly]);
|
|
6676
6688
|
return null;
|
|
6677
6689
|
}
|
|
6678
6690
|
function BrowserSpellCheckPlugin({ enabled }) {
|
|
6679
6691
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6680
|
-
|
|
6692
|
+
React9.useEffect(() => {
|
|
6681
6693
|
const el = editor.getRootElement();
|
|
6682
6694
|
if (!el) return;
|
|
6683
6695
|
el.spellcheck = enabled;
|
|
@@ -6690,7 +6702,7 @@ function BrowserSpellCheckPlugin({ enabled }) {
|
|
|
6690
6702
|
}
|
|
6691
6703
|
function WordCountPlugin({ onCountChange }) {
|
|
6692
6704
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6693
|
-
|
|
6705
|
+
React9.useEffect(() => {
|
|
6694
6706
|
return editor.registerUpdateListener(({ editorState }) => {
|
|
6695
6707
|
editorState.read(() => {
|
|
6696
6708
|
const text = lexical.$getRoot().getTextContent();
|
|
@@ -6703,7 +6715,7 @@ function WordCountPlugin({ onCountChange }) {
|
|
|
6703
6715
|
}
|
|
6704
6716
|
function CharCountPlugin({ onCountChange }) {
|
|
6705
6717
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6706
|
-
|
|
6718
|
+
React9.useEffect(() => {
|
|
6707
6719
|
return editor.registerUpdateListener(({ editorState }) => {
|
|
6708
6720
|
editorState.read(() => {
|
|
6709
6721
|
onCountChange(lexical.$getRoot().getTextContent().length);
|
|
@@ -6719,7 +6731,7 @@ function FocusEventsPlugin({
|
|
|
6719
6731
|
containerRef
|
|
6720
6732
|
}) {
|
|
6721
6733
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6722
|
-
|
|
6734
|
+
React9.useEffect(() => {
|
|
6723
6735
|
const root = editor.getRootElement();
|
|
6724
6736
|
if (!root) return;
|
|
6725
6737
|
const handleFocusIn = () => {
|
|
@@ -6840,33 +6852,33 @@ function _makeQueryFn(fn) {
|
|
|
6840
6852
|
};
|
|
6841
6853
|
};
|
|
6842
6854
|
}
|
|
6843
|
-
var ContentEditorComponent =
|
|
6855
|
+
var ContentEditorComponent = React9.forwardRef(
|
|
6844
6856
|
(props, ref) => {
|
|
6845
6857
|
const isReadOnly = !!props.readOnly;
|
|
6846
|
-
const resolvedSpellCheck =
|
|
6858
|
+
const resolvedSpellCheck = React9__namespace.default.useMemo(
|
|
6847
6859
|
() => props.spellCheckFn ? _makeSpellCheckFn(props.spellCheckFn) : props.useSpellCheck,
|
|
6848
6860
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6849
6861
|
[props.spellCheckFn, props.useSpellCheck]
|
|
6850
6862
|
);
|
|
6851
|
-
const resolvedQuery =
|
|
6863
|
+
const resolvedQuery = React9__namespace.default.useMemo(
|
|
6852
6864
|
() => props.suggestFn ? _makeQueryFn(props.suggestFn) : props.useQuery,
|
|
6853
6865
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6854
6866
|
[props.suggestFn, props.useQuery]
|
|
6855
6867
|
);
|
|
6856
|
-
const [floatingAnchorElem, setFloatingAnchorElem] =
|
|
6857
|
-
const [isLinkEditMode, setIsLinkEditMode] =
|
|
6858
|
-
const [wordCount, setWordCount] =
|
|
6859
|
-
const handleWordCount =
|
|
6860
|
-
const [charCount, setCharCount] =
|
|
6861
|
-
const handleCharCount =
|
|
6862
|
-
const [refErrors, setRefErrors] =
|
|
6863
|
-
const contentEditableDomRef =
|
|
6864
|
-
const previousOverLimitRef =
|
|
6865
|
-
const focusedRef =
|
|
6868
|
+
const [floatingAnchorElem, setFloatingAnchorElem] = React9.useState(null);
|
|
6869
|
+
const [isLinkEditMode, setIsLinkEditMode] = React9.useState(false);
|
|
6870
|
+
const [wordCount, setWordCount] = React9.useState(0);
|
|
6871
|
+
const handleWordCount = React9.useCallback((count) => setWordCount(count), []);
|
|
6872
|
+
const [charCount, setCharCount] = React9.useState(0);
|
|
6873
|
+
const handleCharCount = React9.useCallback((count) => setCharCount(count), []);
|
|
6874
|
+
const [refErrors, setRefErrors] = React9.useState([]);
|
|
6875
|
+
const contentEditableDomRef = React9.useRef(null);
|
|
6876
|
+
const previousOverLimitRef = React9.useRef(false);
|
|
6877
|
+
const focusedRef = React9.useRef(false);
|
|
6866
6878
|
const setFocused = (focused) => {
|
|
6867
6879
|
focusedRef.current = focused;
|
|
6868
6880
|
};
|
|
6869
|
-
const containerRef =
|
|
6881
|
+
const containerRef = React9.useRef(null);
|
|
6870
6882
|
const onAnchorRef = (elem) => {
|
|
6871
6883
|
if (elem) setFloatingAnchorElem(elem);
|
|
6872
6884
|
};
|
|
@@ -6939,7 +6951,7 @@ var ContentEditorComponent = React6.forwardRef(
|
|
|
6939
6951
|
e.stopPropagation();
|
|
6940
6952
|
}
|
|
6941
6953
|
};
|
|
6942
|
-
const [touched, setTouched] =
|
|
6954
|
+
const [touched, setTouched] = React9.useState(false);
|
|
6943
6955
|
const isOverLimit = props.wordLimit !== void 0 && wordCount > props.wordLimit;
|
|
6944
6956
|
const internalErrors = [];
|
|
6945
6957
|
if (isOverLimit) {
|
|
@@ -6974,7 +6986,7 @@ var ContentEditorComponent = React6.forwardRef(
|
|
|
6974
6986
|
const allErrors = [...internalErrors, ...props.errors ?? [], ...refErrors];
|
|
6975
6987
|
const hasErrors = allErrors.length > 0;
|
|
6976
6988
|
const hasRedBorder = hasErrors;
|
|
6977
|
-
|
|
6989
|
+
React9.useEffect(() => {
|
|
6978
6990
|
if (props.wordLimit === void 0 || !props.onWordLimitExceeded) return;
|
|
6979
6991
|
const wasOverLimit = previousOverLimitRef.current;
|
|
6980
6992
|
if (isOverLimit !== wasOverLimit) {
|