@thangph2146/lexical-editor 0.0.6 → 0.0.9
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/editor-x/editor.cjs +604 -497
- package/dist/editor-x/editor.cjs.map +1 -1
- package/dist/editor-x/editor.css +159 -69
- package/dist/editor-x/editor.css.map +1 -1
- package/dist/editor-x/editor.js +344 -237
- package/dist/editor-x/editor.js.map +1 -1
- package/dist/index.cjs +610 -503
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +159 -69
- package/dist/index.css.map +1 -1
- package/dist/index.js +344 -237
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/editor-ui/content-editable.tsx +30 -42
- package/src/editor-x/plugins.tsx +8 -5
- package/src/plugins/images-plugin.tsx +3 -2
- package/src/plugins/layout-plugin.tsx +93 -62
- package/src/themes/_mixins.scss +12 -7
- package/src/themes/_variables.scss +2 -1
- package/src/themes/core/_reset.scss +10 -6
- package/src/themes/plugins/_color-picker.scss +1 -0
- package/src/themes/plugins/_layout.scss +3 -7
- package/src/themes/plugins/_list-color.scss +2 -0
- package/src/themes/plugins/_menus-and-pickers.scss +2 -0
- package/src/themes/plugins/_toolbar.scss +7 -7
- package/src/themes/ui-components/_button.scss +3 -3
- package/src/themes/ui-components/_flex.scss +2 -0
- package/src/themes/ui-components/_number-input.scss +81 -0
- package/src/themes/ui-components/_text-utilities.scss +1 -1
- package/src/themes/ui-components.scss +1 -0
- package/src/ui/flex.tsx +9 -2
- package/src/ui/number-input.tsx +104 -0
package/dist/editor-x/editor.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React21 = require('react');
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
6
6
|
var selection = require('@lexical/selection');
|
|
@@ -74,7 +74,7 @@ function _interopNamespace(e) {
|
|
|
74
74
|
return Object.freeze(n);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
var
|
|
77
|
+
var React21__namespace = /*#__PURE__*/_interopNamespace(React21);
|
|
78
78
|
var Image__default = /*#__PURE__*/_interopDefault(Image);
|
|
79
79
|
var dynamic__default = /*#__PURE__*/_interopDefault(dynamic);
|
|
80
80
|
var SliderPrimitive__namespace = /*#__PURE__*/_interopNamespace(SliderPrimitive);
|
|
@@ -117,9 +117,9 @@ var init_tooltip = __esm({
|
|
|
117
117
|
TooltipProvider = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
118
118
|
Tooltip = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-tooltip-group", children });
|
|
119
119
|
TooltipTrigger = ({ asChild, children, ...props }) => {
|
|
120
|
-
const child = asChild ?
|
|
121
|
-
if (!
|
|
122
|
-
return
|
|
120
|
+
const child = asChild ? React21__namespace.Children.only(children) : children;
|
|
121
|
+
if (!React21__namespace.isValidElement(child)) return null;
|
|
122
|
+
return React21__namespace.cloneElement(child, {
|
|
123
123
|
...props,
|
|
124
124
|
className: cn(child.props.className, "editor-tooltip-trigger")
|
|
125
125
|
});
|
|
@@ -154,16 +154,16 @@ var init_logger = __esm({
|
|
|
154
154
|
var useIsomorphicLayoutEffect;
|
|
155
155
|
var init_use_isomorphic_layout_effect = __esm({
|
|
156
156
|
"src/hooks/use-isomorphic-layout-effect.ts"() {
|
|
157
|
-
useIsomorphicLayoutEffect = typeof window !== "undefined" ?
|
|
157
|
+
useIsomorphicLayoutEffect = typeof window !== "undefined" ? React21.useLayoutEffect : React21.useEffect;
|
|
158
158
|
}
|
|
159
159
|
});
|
|
160
160
|
function useElementSize() {
|
|
161
|
-
const [node, setNode] =
|
|
162
|
-
const [size, setSize] =
|
|
161
|
+
const [node, setNode] = React21.useState(null);
|
|
162
|
+
const [size, setSize] = React21.useState({
|
|
163
163
|
width: 0,
|
|
164
164
|
height: 0
|
|
165
165
|
});
|
|
166
|
-
const handleSize =
|
|
166
|
+
const handleSize = React21.useCallback(() => {
|
|
167
167
|
if (!node) return;
|
|
168
168
|
setSize({
|
|
169
169
|
width: node.offsetWidth || 0,
|
|
@@ -201,13 +201,13 @@ function EditorContainerProvider({
|
|
|
201
201
|
return /* @__PURE__ */ jsxRuntime.jsx(EditorContainerContext.Provider, { value, children });
|
|
202
202
|
}
|
|
203
203
|
function useEditorContainer() {
|
|
204
|
-
return
|
|
204
|
+
return React21.useContext(EditorContainerContext);
|
|
205
205
|
}
|
|
206
206
|
var EditorContainerContext;
|
|
207
207
|
var init_editor_container_context = __esm({
|
|
208
208
|
"src/context/editor-container-context.tsx"() {
|
|
209
209
|
"use client";
|
|
210
|
-
EditorContainerContext =
|
|
210
|
+
EditorContainerContext = React21.createContext(
|
|
211
211
|
null
|
|
212
212
|
);
|
|
213
213
|
}
|
|
@@ -307,7 +307,7 @@ function $search(selection$1) {
|
|
|
307
307
|
return [true, word.reverse().join("")];
|
|
308
308
|
}
|
|
309
309
|
function useQuery() {
|
|
310
|
-
return
|
|
310
|
+
return React21.useCallback((searchText) => {
|
|
311
311
|
const server = new AutocompleteServer();
|
|
312
312
|
const response = server.query(searchText);
|
|
313
313
|
return response;
|
|
@@ -321,7 +321,7 @@ function formatSuggestionText(suggestion) {
|
|
|
321
321
|
function AutocompletePlugin() {
|
|
322
322
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
323
323
|
const query = useQuery();
|
|
324
|
-
|
|
324
|
+
React21.useEffect(() => {
|
|
325
325
|
let autocompleteNodeKey = null;
|
|
326
326
|
let lastMatch = null;
|
|
327
327
|
let lastSuggestion = null;
|
|
@@ -2842,10 +2842,10 @@ function TweetComponent({
|
|
|
2842
2842
|
onLoad,
|
|
2843
2843
|
tweetID
|
|
2844
2844
|
}) {
|
|
2845
|
-
const containerRef =
|
|
2846
|
-
const previousTweetIDRef =
|
|
2847
|
-
const [isTweetLoading, setIsTweetLoading] =
|
|
2848
|
-
const createTweet =
|
|
2845
|
+
const containerRef = React21.useRef(null);
|
|
2846
|
+
const previousTweetIDRef = React21.useRef("");
|
|
2847
|
+
const [isTweetLoading, setIsTweetLoading] = React21.useState(false);
|
|
2848
|
+
const createTweet = React21.useCallback(async () => {
|
|
2849
2849
|
try {
|
|
2850
2850
|
await window.twttr.widgets.createTweet(tweetID, containerRef.current);
|
|
2851
2851
|
setIsTweetLoading(false);
|
|
@@ -2859,7 +2859,7 @@ function TweetComponent({
|
|
|
2859
2859
|
}
|
|
2860
2860
|
}
|
|
2861
2861
|
}, [onError, onLoad, tweetID]);
|
|
2862
|
-
|
|
2862
|
+
React21.useEffect(() => {
|
|
2863
2863
|
if (tweetID !== previousTweetIDRef.current) {
|
|
2864
2864
|
setTimeout(() => {
|
|
2865
2865
|
setIsTweetLoading(true);
|
|
@@ -2989,7 +2989,7 @@ var Button;
|
|
|
2989
2989
|
var init_button = __esm({
|
|
2990
2990
|
"src/ui/button.tsx"() {
|
|
2991
2991
|
init_utils();
|
|
2992
|
-
Button =
|
|
2992
|
+
Button = React21__namespace.forwardRef(
|
|
2993
2993
|
({ className, variant = "default", size = "default", type = "button", isLoading, disabled, children, ...props }, ref) => {
|
|
2994
2994
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2995
2995
|
"button",
|
|
@@ -3130,22 +3130,22 @@ var init_typography = __esm({
|
|
|
3130
3130
|
md: "editor-icon-md",
|
|
3131
3131
|
lg: "editor-icon-lg"
|
|
3132
3132
|
};
|
|
3133
|
-
if (
|
|
3134
|
-
return
|
|
3133
|
+
if (React21__namespace.isValidElement(children)) {
|
|
3134
|
+
return React21__namespace.cloneElement(children, {
|
|
3135
3135
|
className: cn(sizeMap[size] || sizeMap.medium, children.props.className, className)
|
|
3136
3136
|
});
|
|
3137
3137
|
}
|
|
3138
3138
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
3139
3139
|
};
|
|
3140
|
-
TypographyP =
|
|
3140
|
+
TypographyP = React21__namespace.forwardRef(
|
|
3141
3141
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("p", { ref, className: cn("editor-typography-p", className), ...props })
|
|
3142
3142
|
);
|
|
3143
3143
|
TypographyP.displayName = "TypographyP";
|
|
3144
|
-
TypographyPSmall =
|
|
3144
|
+
TypographyPSmall = React21__namespace.forwardRef(
|
|
3145
3145
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("p", { ref, className: cn("editor-typography-p-small", className), ...props })
|
|
3146
3146
|
);
|
|
3147
3147
|
TypographyPSmall.displayName = "TypographyPSmall";
|
|
3148
|
-
TypographySpanSmallMuted =
|
|
3148
|
+
TypographySpanSmallMuted = React21__namespace.forwardRef(
|
|
3149
3149
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("span", { ref, className: cn("editor-typography-span-small-muted", className), ...props })
|
|
3150
3150
|
);
|
|
3151
3151
|
TypographySpanSmallMuted.displayName = "TypographySpanSmallMuted";
|
|
@@ -3174,12 +3174,12 @@ function MediaResizer({
|
|
|
3174
3174
|
onDelete,
|
|
3175
3175
|
onAlign
|
|
3176
3176
|
}) {
|
|
3177
|
-
const controlWrapperRef =
|
|
3178
|
-
const userSelect =
|
|
3177
|
+
const controlWrapperRef = React21.useRef(null);
|
|
3178
|
+
const userSelect = React21.useRef({
|
|
3179
3179
|
priority: "",
|
|
3180
3180
|
value: "default"
|
|
3181
3181
|
});
|
|
3182
|
-
const positioningRef =
|
|
3182
|
+
const positioningRef = React21.useRef({
|
|
3183
3183
|
currentHeight: 0,
|
|
3184
3184
|
currentWidth: 0,
|
|
3185
3185
|
direction: 0,
|
|
@@ -3197,7 +3197,7 @@ function MediaResizer({
|
|
|
3197
3197
|
const hardWidthLimit = maxWidth ?? editorContainer?.maxWidth;
|
|
3198
3198
|
const minWidth = 100;
|
|
3199
3199
|
const minHeight = 100;
|
|
3200
|
-
|
|
3200
|
+
React21__namespace.useEffect(() => {
|
|
3201
3201
|
}, [mediaRef, unlockBoundaries]);
|
|
3202
3202
|
const setStartCursor = (direction) => {
|
|
3203
3203
|
const ew = direction === Direction.east || direction === Direction.west;
|
|
@@ -3544,14 +3544,14 @@ function YouTubeComponent({
|
|
|
3544
3544
|
}) {
|
|
3545
3545
|
const isEditable = useLexicalEditable.useLexicalEditable();
|
|
3546
3546
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
|
|
3547
|
-
const [isResizing, setIsResizing] =
|
|
3548
|
-
const wrapperRef =
|
|
3549
|
-
const [wrapperElement, setWrapperElement] =
|
|
3550
|
-
const buttonRef =
|
|
3551
|
-
const [containerWidth, setContainerWidth] =
|
|
3547
|
+
const [isResizing, setIsResizing] = React21__namespace.useState(false);
|
|
3548
|
+
const wrapperRef = React21__namespace.useRef(null);
|
|
3549
|
+
const [wrapperElement, setWrapperElement] = React21__namespace.useState(null);
|
|
3550
|
+
const buttonRef = React21__namespace.useRef(null);
|
|
3551
|
+
const [containerWidth, setContainerWidth] = React21__namespace.useState(maxWidth);
|
|
3552
3552
|
const editorContainer = useEditorContainer();
|
|
3553
3553
|
const editorHardWidthLimit = editorContainer?.maxWidth;
|
|
3554
|
-
const updateNode =
|
|
3554
|
+
const updateNode = React21__namespace.useCallback(
|
|
3555
3555
|
(updater) => {
|
|
3556
3556
|
editor.update(() => {
|
|
3557
3557
|
const node = lexical.$getNodeByKey(nodeKey);
|
|
@@ -3563,14 +3563,14 @@ function YouTubeComponent({
|
|
|
3563
3563
|
[editor, nodeKey]
|
|
3564
3564
|
);
|
|
3565
3565
|
const aspectRatio = 16 / 9;
|
|
3566
|
-
const clampToContainer =
|
|
3566
|
+
const clampToContainer = React21__namespace.useCallback(
|
|
3567
3567
|
(value) => {
|
|
3568
3568
|
const limit = typeof editorHardWidthLimit === "number" && editorHardWidthLimit > 0 ? editorHardWidthLimit : containerWidth || value;
|
|
3569
3569
|
return Math.min(value, limit);
|
|
3570
3570
|
},
|
|
3571
3571
|
[containerWidth, editorHardWidthLimit]
|
|
3572
3572
|
);
|
|
3573
|
-
|
|
3573
|
+
React21__namespace.useEffect(() => {
|
|
3574
3574
|
if (!wrapperElement) {
|
|
3575
3575
|
return;
|
|
3576
3576
|
}
|
|
@@ -3615,7 +3615,7 @@ function YouTubeComponent({
|
|
|
3615
3615
|
return () => window.removeEventListener("resize", updateAvailableWidth);
|
|
3616
3616
|
}
|
|
3617
3617
|
}, [editor, editorHardWidthLimit, maxWidth, wrapperElement]);
|
|
3618
|
-
|
|
3618
|
+
React21__namespace.useEffect(() => {
|
|
3619
3619
|
if (!containerWidth) {
|
|
3620
3620
|
return;
|
|
3621
3621
|
}
|
|
@@ -3642,11 +3642,11 @@ function YouTubeComponent({
|
|
|
3642
3642
|
const disablePlaybackInteractions = isEditable;
|
|
3643
3643
|
const iframeWidth = safeRenderedWidth;
|
|
3644
3644
|
const iframeHeight = Math.round(iframeWidth / aspectRatio);
|
|
3645
|
-
const handleWrapperRef =
|
|
3645
|
+
const handleWrapperRef = React21__namespace.useCallback((node) => {
|
|
3646
3646
|
wrapperRef.current = node;
|
|
3647
3647
|
setWrapperElement(node);
|
|
3648
3648
|
}, []);
|
|
3649
|
-
|
|
3649
|
+
React21__namespace.useEffect(() => {
|
|
3650
3650
|
if (!isEditable) {
|
|
3651
3651
|
return;
|
|
3652
3652
|
}
|
|
@@ -3677,7 +3677,7 @@ function YouTubeComponent({
|
|
|
3677
3677
|
)
|
|
3678
3678
|
);
|
|
3679
3679
|
}, [clearSelection, editor, isEditable, isResizing, isSelected, setSelected]);
|
|
3680
|
-
|
|
3680
|
+
React21__namespace.useEffect(() => {
|
|
3681
3681
|
if (!containerWidth || typeof width !== "number" || fullWidth || width <= containerWidth) {
|
|
3682
3682
|
return;
|
|
3683
3683
|
}
|
|
@@ -3977,15 +3977,15 @@ function Dialog({ open = false, onOpenChange = () => {
|
|
|
3977
3977
|
return /* @__PURE__ */ jsxRuntime.jsx(DialogContext.Provider, { value: { open, onOpenChange }, children });
|
|
3978
3978
|
}
|
|
3979
3979
|
function DialogTrigger({ asChild, children, className, ...props }) {
|
|
3980
|
-
const context =
|
|
3980
|
+
const context = React21__namespace.useContext(DialogContext);
|
|
3981
3981
|
const handleClick = (e) => {
|
|
3982
3982
|
context?.onOpenChange(true);
|
|
3983
|
-
if (
|
|
3983
|
+
if (React21__namespace.isValidElement(children)) {
|
|
3984
3984
|
children.props.onClick?.(e);
|
|
3985
3985
|
}
|
|
3986
3986
|
};
|
|
3987
|
-
if (asChild &&
|
|
3988
|
-
return
|
|
3987
|
+
if (asChild && React21__namespace.isValidElement(children)) {
|
|
3988
|
+
return React21__namespace.cloneElement(children, {
|
|
3989
3989
|
onClick: handleClick,
|
|
3990
3990
|
...props
|
|
3991
3991
|
});
|
|
@@ -3993,15 +3993,15 @@ function DialogTrigger({ asChild, children, className, ...props }) {
|
|
|
3993
3993
|
return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleClick, className, ...props, children });
|
|
3994
3994
|
}
|
|
3995
3995
|
function DialogClose({ asChild, children, className, ...props }) {
|
|
3996
|
-
const context =
|
|
3996
|
+
const context = React21__namespace.useContext(DialogContext);
|
|
3997
3997
|
const handleClick = (e) => {
|
|
3998
3998
|
context?.onOpenChange(false);
|
|
3999
|
-
if (
|
|
3999
|
+
if (React21__namespace.isValidElement(children)) {
|
|
4000
4000
|
children.props.onClick?.(e);
|
|
4001
4001
|
}
|
|
4002
4002
|
};
|
|
4003
|
-
if (asChild &&
|
|
4004
|
-
return
|
|
4003
|
+
if (asChild && React21__namespace.isValidElement(children)) {
|
|
4004
|
+
return React21__namespace.cloneElement(children, {
|
|
4005
4005
|
onClick: handleClick,
|
|
4006
4006
|
...props
|
|
4007
4007
|
});
|
|
@@ -4009,9 +4009,9 @@ function DialogClose({ asChild, children, className, ...props }) {
|
|
|
4009
4009
|
return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleClick, className, ...props, children });
|
|
4010
4010
|
}
|
|
4011
4011
|
function DialogContent({ children, className, disableOutsideClick, ...props }) {
|
|
4012
|
-
const context =
|
|
4013
|
-
const [mounted, setMounted] =
|
|
4014
|
-
|
|
4012
|
+
const context = React21__namespace.useContext(DialogContext);
|
|
4013
|
+
const [mounted, setMounted] = React21__namespace.useState(false);
|
|
4014
|
+
React21__namespace.useEffect(() => {
|
|
4015
4015
|
setMounted(true);
|
|
4016
4016
|
return () => setMounted(false);
|
|
4017
4017
|
}, []);
|
|
@@ -4070,7 +4070,7 @@ var DialogContext;
|
|
|
4070
4070
|
var init_dialog = __esm({
|
|
4071
4071
|
"src/ui/dialog.tsx"() {
|
|
4072
4072
|
init_utils();
|
|
4073
|
-
DialogContext =
|
|
4073
|
+
DialogContext = React21__namespace.createContext(null);
|
|
4074
4074
|
}
|
|
4075
4075
|
});
|
|
4076
4076
|
|
|
@@ -4085,7 +4085,7 @@ var Input;
|
|
|
4085
4085
|
var init_input = __esm({
|
|
4086
4086
|
"src/ui/input.tsx"() {
|
|
4087
4087
|
init_utils();
|
|
4088
|
-
Input =
|
|
4088
|
+
Input = React21__namespace.forwardRef(
|
|
4089
4089
|
({ className, type, ...props }, ref) => {
|
|
4090
4090
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4091
4091
|
"input",
|
|
@@ -4105,7 +4105,7 @@ var Label;
|
|
|
4105
4105
|
var init_label = __esm({
|
|
4106
4106
|
"src/ui/label.tsx"() {
|
|
4107
4107
|
init_utils();
|
|
4108
|
-
Label =
|
|
4108
|
+
Label = React21__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4109
4109
|
"label",
|
|
4110
4110
|
{
|
|
4111
4111
|
ref,
|
|
@@ -4120,6 +4120,37 @@ var init_label = __esm({
|
|
|
4120
4120
|
Label.displayName = "Label";
|
|
4121
4121
|
}
|
|
4122
4122
|
});
|
|
4123
|
+
var Flex;
|
|
4124
|
+
var init_flex = __esm({
|
|
4125
|
+
"src/ui/flex.tsx"() {
|
|
4126
|
+
init_utils();
|
|
4127
|
+
Flex = React21__namespace.forwardRef(
|
|
4128
|
+
({ className, align, justify, direction, wrap, gap, style, ...props }, ref) => {
|
|
4129
|
+
const isStandardGap = typeof gap === "number" && [0.5, 1, 1.5, 2, 3, 4, 5].includes(gap);
|
|
4130
|
+
const gapClass = isStandardGap ? `editor-gap-${gap.toString().replace(".", "-")}` : void 0;
|
|
4131
|
+
const gapStyle = !isStandardGap && typeof gap === "number" ? { gap: `${gap * 0.25}rem` } : !isStandardGap && typeof gap !== "undefined" ? { gap } : void 0;
|
|
4132
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4133
|
+
"div",
|
|
4134
|
+
{
|
|
4135
|
+
ref,
|
|
4136
|
+
className: cn(
|
|
4137
|
+
"editor-flex",
|
|
4138
|
+
align && `editor-items-${align}`,
|
|
4139
|
+
justify && `editor-justify-${justify}`,
|
|
4140
|
+
direction && `editor-flex-${direction}`,
|
|
4141
|
+
wrap && `editor-flex-${wrap}`,
|
|
4142
|
+
gapClass,
|
|
4143
|
+
className
|
|
4144
|
+
),
|
|
4145
|
+
style: { ...gapStyle, ...style },
|
|
4146
|
+
...props
|
|
4147
|
+
}
|
|
4148
|
+
);
|
|
4149
|
+
}
|
|
4150
|
+
);
|
|
4151
|
+
Flex.displayName = "Flex";
|
|
4152
|
+
}
|
|
4153
|
+
});
|
|
4123
4154
|
function Tabs({
|
|
4124
4155
|
defaultValue,
|
|
4125
4156
|
value: controlledValue,
|
|
@@ -4128,7 +4159,7 @@ function Tabs({
|
|
|
4128
4159
|
className,
|
|
4129
4160
|
...props
|
|
4130
4161
|
}) {
|
|
4131
|
-
const [uncontrolledValue, setUncontrolledValue] =
|
|
4162
|
+
const [uncontrolledValue, setUncontrolledValue] = React21__namespace.useState(defaultValue || "");
|
|
4132
4163
|
const value = controlledValue ?? uncontrolledValue;
|
|
4133
4164
|
const setValue = onValueChange ?? setUncontrolledValue;
|
|
4134
4165
|
return /* @__PURE__ */ jsxRuntime.jsx(TabsContext.Provider, { value: { value, onValueChange: setValue }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(className), ...props, children }) });
|
|
@@ -4147,7 +4178,7 @@ function TabsList({ className, children, ...props }) {
|
|
|
4147
4178
|
);
|
|
4148
4179
|
}
|
|
4149
4180
|
function TabsTrigger({ value, className, children, ...props }) {
|
|
4150
|
-
const context =
|
|
4181
|
+
const context = React21__namespace.useContext(TabsContext);
|
|
4151
4182
|
const isSelected = context?.value === value;
|
|
4152
4183
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4153
4184
|
"button",
|
|
@@ -4165,7 +4196,7 @@ function TabsTrigger({ value, className, children, ...props }) {
|
|
|
4165
4196
|
);
|
|
4166
4197
|
}
|
|
4167
4198
|
function TabsContent({ value, className, children, ...props }) {
|
|
4168
|
-
const context =
|
|
4199
|
+
const context = React21__namespace.useContext(TabsContext);
|
|
4169
4200
|
const isSelected = context?.value === value;
|
|
4170
4201
|
if (!isSelected) return null;
|
|
4171
4202
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4184,11 +4215,11 @@ var TabsContext;
|
|
|
4184
4215
|
var init_tabs = __esm({
|
|
4185
4216
|
"src/ui/tabs.tsx"() {
|
|
4186
4217
|
init_utils();
|
|
4187
|
-
TabsContext =
|
|
4218
|
+
TabsContext = React21__namespace.createContext(null);
|
|
4188
4219
|
}
|
|
4189
4220
|
});
|
|
4190
4221
|
function useEditorUploads() {
|
|
4191
|
-
const context =
|
|
4222
|
+
const context = React21.useContext(EditorUploadsContext);
|
|
4192
4223
|
if (context === void 0) {
|
|
4193
4224
|
return {
|
|
4194
4225
|
isLoading: false,
|
|
@@ -4201,7 +4232,7 @@ var EditorUploadsContext;
|
|
|
4201
4232
|
var init_uploads_context = __esm({
|
|
4202
4233
|
"src/context/uploads-context.tsx"() {
|
|
4203
4234
|
"use client";
|
|
4204
|
-
EditorUploadsContext =
|
|
4235
|
+
EditorUploadsContext = React21.createContext(void 0);
|
|
4205
4236
|
}
|
|
4206
4237
|
});
|
|
4207
4238
|
function Collapsible({
|
|
@@ -4211,27 +4242,27 @@ function Collapsible({
|
|
|
4211
4242
|
className,
|
|
4212
4243
|
...props
|
|
4213
4244
|
}) {
|
|
4214
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
4245
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React21__namespace.useState(false);
|
|
4215
4246
|
const open = controlledOpen ?? uncontrolledOpen;
|
|
4216
4247
|
const setOpen = onOpenChange ?? setUncontrolledOpen;
|
|
4217
4248
|
return /* @__PURE__ */ jsxRuntime.jsx(CollapsibleContext.Provider, { value: { open, setOpen }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("editor-collapsible", className), "data-state": open ? "open" : "closed", ...props, children }) });
|
|
4218
4249
|
}
|
|
4219
4250
|
function CollapsibleTrigger({ children, asChild, ...props }) {
|
|
4220
|
-
const context =
|
|
4251
|
+
const context = React21__namespace.useContext(CollapsibleContext);
|
|
4221
4252
|
if (!context) throw new Error("CollapsibleTrigger must be used within Collapsible");
|
|
4222
4253
|
const handleClick = (e) => {
|
|
4223
4254
|
context.setOpen(!context.open);
|
|
4224
|
-
if (
|
|
4255
|
+
if (React21__namespace.isValidElement(children)) {
|
|
4225
4256
|
children.props.onClick?.(e);
|
|
4226
4257
|
}
|
|
4227
4258
|
};
|
|
4228
|
-
if (asChild &&
|
|
4229
|
-
return
|
|
4259
|
+
if (asChild && React21__namespace.isValidElement(children)) {
|
|
4260
|
+
return React21__namespace.cloneElement(children, { onClick: handleClick, ...props });
|
|
4230
4261
|
}
|
|
4231
4262
|
return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleClick, ...props, children });
|
|
4232
4263
|
}
|
|
4233
4264
|
function CollapsibleContent({ children, className, ...props }) {
|
|
4234
|
-
const context =
|
|
4265
|
+
const context = React21__namespace.useContext(CollapsibleContext);
|
|
4235
4266
|
if (!context) throw new Error("CollapsibleContent must be used within Collapsible");
|
|
4236
4267
|
if (!context.open) return null;
|
|
4237
4268
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("editor-overflow-hidden", className), ...props, children });
|
|
@@ -4240,14 +4271,14 @@ var CollapsibleContext;
|
|
|
4240
4271
|
var init_collapsible = __esm({
|
|
4241
4272
|
"src/ui/collapsible.tsx"() {
|
|
4242
4273
|
init_utils();
|
|
4243
|
-
CollapsibleContext =
|
|
4274
|
+
CollapsibleContext = React21__namespace.createContext(null);
|
|
4244
4275
|
}
|
|
4245
4276
|
});
|
|
4246
4277
|
function InsertImageUriDialogBody({
|
|
4247
4278
|
onClick
|
|
4248
4279
|
}) {
|
|
4249
|
-
const [src, setSrc] =
|
|
4250
|
-
const [altText, setAltText] =
|
|
4280
|
+
const [src, setSrc] = React21.useState("");
|
|
4281
|
+
const [altText, setAltText] = React21.useState("");
|
|
4251
4282
|
const isDisabled = src === "";
|
|
4252
4283
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "editor-form-grid", children: [
|
|
4253
4284
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "editor-form-item", children: [
|
|
@@ -4291,8 +4322,8 @@ function InsertImageUriDialogBody({
|
|
|
4291
4322
|
function InsertImageUploadedDialogBody({
|
|
4292
4323
|
onClick
|
|
4293
4324
|
}) {
|
|
4294
|
-
const [src, setSrc] =
|
|
4295
|
-
const [altText, setAltText] =
|
|
4325
|
+
const [src, setSrc] = React21.useState("");
|
|
4326
|
+
const [altText, setAltText] = React21.useState("");
|
|
4296
4327
|
const isDisabled = src === "";
|
|
4297
4328
|
const loadImage = (files) => {
|
|
4298
4329
|
const reader = new FileReader();
|
|
@@ -4355,7 +4386,7 @@ function ImagePickerFolderTree({
|
|
|
4355
4386
|
}) {
|
|
4356
4387
|
const hasContent = folder.images.length > 0 || folder.subfolders.length > 0;
|
|
4357
4388
|
const isOpen = openFolders.has(folder.path);
|
|
4358
|
-
const handleOpenChange =
|
|
4389
|
+
const handleOpenChange = React21__namespace.useCallback(
|
|
4359
4390
|
(open) => {
|
|
4360
4391
|
if (open) {
|
|
4361
4392
|
setOpenFolders((prev) => {
|
|
@@ -4430,16 +4461,16 @@ function ImagePickerFolderTree({
|
|
|
4430
4461
|
function InsertImageUploadsDialogBody({
|
|
4431
4462
|
onClick
|
|
4432
4463
|
}) {
|
|
4433
|
-
const [selectedImage, setSelectedImage] =
|
|
4434
|
-
const [altText, setAltText] =
|
|
4435
|
-
const [openFolders, setOpenFolders] =
|
|
4464
|
+
const [selectedImage, setSelectedImage] = React21.useState(null);
|
|
4465
|
+
const [altText, setAltText] = React21.useState("");
|
|
4466
|
+
const [openFolders, setOpenFolders] = React21.useState(/* @__PURE__ */ new Set());
|
|
4436
4467
|
const { folderTree, isLoading } = useEditorUploads();
|
|
4437
4468
|
const isDisabled = !selectedImage;
|
|
4438
|
-
const handleImageSelect =
|
|
4469
|
+
const handleImageSelect = React21__namespace.useCallback((imageUrl, originalName) => {
|
|
4439
4470
|
setSelectedImage(imageUrl);
|
|
4440
4471
|
setAltText((prev) => prev || originalName);
|
|
4441
4472
|
}, []);
|
|
4442
|
-
const handleConfirm =
|
|
4473
|
+
const handleConfirm = React21__namespace.useCallback(() => {
|
|
4443
4474
|
if (selectedImage) {
|
|
4444
4475
|
let imageUrl = selectedImage;
|
|
4445
4476
|
if (imageUrl.startsWith("/api/uploads")) {
|
|
@@ -4450,7 +4481,7 @@ function InsertImageUploadsDialogBody({
|
|
|
4450
4481
|
onClick({ altText: altText || "", src: imageUrl });
|
|
4451
4482
|
}
|
|
4452
4483
|
}, [selectedImage, altText, onClick]);
|
|
4453
|
-
|
|
4484
|
+
React21__namespace.useEffect(() => {
|
|
4454
4485
|
const handleDoubleClickConfirm = () => {
|
|
4455
4486
|
setTimeout(() => {
|
|
4456
4487
|
handleConfirm();
|
|
@@ -4461,7 +4492,7 @@ function InsertImageUploadsDialogBody({
|
|
|
4461
4492
|
document.removeEventListener("confirm-image-insert", handleDoubleClickConfirm);
|
|
4462
4493
|
};
|
|
4463
4494
|
}, [handleConfirm]);
|
|
4464
|
-
|
|
4495
|
+
React21__namespace.useEffect(() => {
|
|
4465
4496
|
if (folderTree && folderTree.subfolders.length > 0) {
|
|
4466
4497
|
setOpenFolders(new Set(folderTree.subfolders.map((f) => f.path)));
|
|
4467
4498
|
}
|
|
@@ -4469,7 +4500,7 @@ function InsertImageUploadsDialogBody({
|
|
|
4469
4500
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "editor-form-grid", children: [
|
|
4470
4501
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "editor-form-item", children: [
|
|
4471
4502
|
/* @__PURE__ */ jsxRuntime.jsx(Label, { children: "Ch\u1ECDn h\xECnh \u1EA3nh t\u1EEB th\u01B0 vi\u1EC7n" }),
|
|
4472
|
-
isLoading ? /* @__PURE__ */ jsxRuntime.jsx("
|
|
4503
|
+
isLoading ? /* @__PURE__ */ jsxRuntime.jsx(Flex, { align: "center", justify: "center", className: "editor-py-8", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "editor-loader" }) }) : !folderTree || folderTree.subfolders.length === 0 && folderTree.images.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-empty-state", children: /* @__PURE__ */ jsxRuntime.jsx(TypographySpanSmallMuted, { children: "Ch\u01B0a c\xF3 h\xECnh \u1EA3nh n\xE0o \u0111\u01B0\u1EE3c upload" }) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "editor-scroll-area editor-flex editor-flex-col editor-gap-1", children: [
|
|
4473
4504
|
folderTree.images.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "editor-mb-3", children: [
|
|
4474
4505
|
/* @__PURE__ */ jsxRuntime.jsx(TypographySpanSmallMuted, { className: "editor-mb-2 editor-px-1", children: "Root" }),
|
|
4475
4506
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-image-grid editor-gap-2", children: folderTree.images.map((image) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4548,8 +4579,8 @@ function InsertImageDialog({
|
|
|
4548
4579
|
onInsert,
|
|
4549
4580
|
activeTab = "uploads"
|
|
4550
4581
|
}) {
|
|
4551
|
-
const hasModifier =
|
|
4552
|
-
|
|
4582
|
+
const hasModifier = React21.useRef(false);
|
|
4583
|
+
React21.useEffect(() => {
|
|
4553
4584
|
hasModifier.current = false;
|
|
4554
4585
|
const handler = (e) => {
|
|
4555
4586
|
hasModifier.current = e.altKey;
|
|
@@ -4582,7 +4613,7 @@ function ImagesPlugin({
|
|
|
4582
4613
|
captionsEnabled
|
|
4583
4614
|
}) {
|
|
4584
4615
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
4585
|
-
|
|
4616
|
+
React21.useEffect(() => {
|
|
4586
4617
|
if (!editor.hasNodes([ImageNode])) {
|
|
4587
4618
|
throw new Error("ImagesPlugin: ImageNode not registered on editor");
|
|
4588
4619
|
}
|
|
@@ -4737,6 +4768,7 @@ var init_images_plugin = __esm({
|
|
|
4737
4768
|
init_dialog();
|
|
4738
4769
|
init_input();
|
|
4739
4770
|
init_label();
|
|
4771
|
+
init_flex();
|
|
4740
4772
|
init_tabs();
|
|
4741
4773
|
init_uploads_context();
|
|
4742
4774
|
init_collapsible();
|
|
@@ -4749,8 +4781,8 @@ var PriorityImageContext, usePriorityImage;
|
|
|
4749
4781
|
var init_priority_image_context = __esm({
|
|
4750
4782
|
"src/context/priority-image-context.tsx"() {
|
|
4751
4783
|
"use client";
|
|
4752
|
-
PriorityImageContext =
|
|
4753
|
-
usePriorityImage = () =>
|
|
4784
|
+
PriorityImageContext = React21.createContext(null);
|
|
4785
|
+
usePriorityImage = () => React21.useContext(PriorityImageContext);
|
|
4754
4786
|
}
|
|
4755
4787
|
});
|
|
4756
4788
|
function useResponsiveImageDimensions({
|
|
@@ -4763,11 +4795,11 @@ function useResponsiveImageDimensions({
|
|
|
4763
4795
|
maxWidthLimit,
|
|
4764
4796
|
src
|
|
4765
4797
|
}) {
|
|
4766
|
-
const [dimensions, setDimensions] =
|
|
4798
|
+
const [dimensions, setDimensions] = React21.useState({
|
|
4767
4799
|
width,
|
|
4768
4800
|
height
|
|
4769
4801
|
});
|
|
4770
|
-
|
|
4802
|
+
React21.useEffect(() => {
|
|
4771
4803
|
if (isResizing) {
|
|
4772
4804
|
return;
|
|
4773
4805
|
}
|
|
@@ -4919,11 +4951,11 @@ function LazyImage({
|
|
|
4919
4951
|
const widthAttr = getNumericValue(width);
|
|
4920
4952
|
const heightAttr = getNumericValue(height);
|
|
4921
4953
|
const cachedDims = imageCache.get(src);
|
|
4922
|
-
const [actualDimensions, setActualDimensions] =
|
|
4954
|
+
const [actualDimensions, setActualDimensions] = React21.useState(
|
|
4923
4955
|
cachedDims || DEFAULT_DIMENSIONS
|
|
4924
4956
|
);
|
|
4925
|
-
const wrapperRef =
|
|
4926
|
-
|
|
4957
|
+
const wrapperRef = React21.useRef(null);
|
|
4958
|
+
React21.useEffect(() => {
|
|
4927
4959
|
if (wrapperRef.current) {
|
|
4928
4960
|
const imgElement = wrapperRef.current.querySelector("img");
|
|
4929
4961
|
if (imgElement) {
|
|
@@ -5077,19 +5109,7 @@ function ContentEditable({
|
|
|
5077
5109
|
!isReadOnlyOrReview && "min-h-72 px-8 py-4",
|
|
5078
5110
|
className
|
|
5079
5111
|
),
|
|
5080
|
-
"aria-
|
|
5081
|
-
"aria-label": placeholder || "Editor n\u1ED9i dung",
|
|
5082
|
-
placeholder: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5083
|
-
"div",
|
|
5084
|
-
{
|
|
5085
|
-
className: cn(
|
|
5086
|
-
placeholderClassName,
|
|
5087
|
-
"text-muted-foreground pointer-events-none select-none",
|
|
5088
|
-
placeholderDefaults && !isReadOnlyOrReview && "absolute top-0 left-0 overflow-hidden px-8 py-[18px] text-ellipsis"
|
|
5089
|
-
),
|
|
5090
|
-
children: placeholder
|
|
5091
|
-
}
|
|
5092
|
-
)
|
|
5112
|
+
"aria-label": "Editor n\u1ED9i dung"
|
|
5093
5113
|
}
|
|
5094
5114
|
);
|
|
5095
5115
|
}
|
|
@@ -5133,11 +5153,11 @@ function useImageCaptionControls({
|
|
|
5133
5153
|
nodeKey,
|
|
5134
5154
|
showCaption
|
|
5135
5155
|
}) {
|
|
5136
|
-
const [hasCaptionContent, setHasCaptionContent] =
|
|
5137
|
-
const [localShowCaption, setLocalShowCaption] =
|
|
5138
|
-
const isUpdatingCaptionRef =
|
|
5139
|
-
const lastShowCaptionRef =
|
|
5140
|
-
|
|
5156
|
+
const [hasCaptionContent, setHasCaptionContent] = React21.useState(false);
|
|
5157
|
+
const [localShowCaption, setLocalShowCaption] = React21.useState(showCaption);
|
|
5158
|
+
const isUpdatingCaptionRef = React21.useRef(false);
|
|
5159
|
+
const lastShowCaptionRef = React21.useRef(showCaption);
|
|
5160
|
+
React21.useEffect(() => {
|
|
5141
5161
|
let timeout = null;
|
|
5142
5162
|
timeout = setTimeout(() => {
|
|
5143
5163
|
if (!showCaption) {
|
|
@@ -5155,7 +5175,7 @@ function useImageCaptionControls({
|
|
|
5155
5175
|
}
|
|
5156
5176
|
};
|
|
5157
5177
|
}, [showCaption]);
|
|
5158
|
-
const setShowCaption =
|
|
5178
|
+
const setShowCaption = React21.useCallback(
|
|
5159
5179
|
(show) => {
|
|
5160
5180
|
isUpdatingCaptionRef.current = true;
|
|
5161
5181
|
lastShowCaptionRef.current = show;
|
|
@@ -5178,7 +5198,7 @@ function useImageCaptionControls({
|
|
|
5178
5198
|
},
|
|
5179
5199
|
[caption, editor, nodeKey]
|
|
5180
5200
|
);
|
|
5181
|
-
|
|
5201
|
+
React21.useEffect(() => {
|
|
5182
5202
|
const computeHasContent = () => {
|
|
5183
5203
|
const state = caption.getEditorState();
|
|
5184
5204
|
const hasContent = state.read(() => {
|
|
@@ -5227,10 +5247,10 @@ function useImageNodeInteractions({
|
|
|
5227
5247
|
nodeKey,
|
|
5228
5248
|
showCaption
|
|
5229
5249
|
}) {
|
|
5230
|
-
const [selection, setSelection] =
|
|
5250
|
+
const [selection, setSelection] = React21.useState(null);
|
|
5231
5251
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
|
|
5232
|
-
const activeEditorRef =
|
|
5233
|
-
const $onDelete =
|
|
5252
|
+
const activeEditorRef = React21.useRef(null);
|
|
5253
|
+
const $onDelete = React21.useCallback(
|
|
5234
5254
|
(payload) => {
|
|
5235
5255
|
const deleteSelection = lexical.$getSelection();
|
|
5236
5256
|
if (isSelected && lexical.$isNodeSelection(deleteSelection)) {
|
|
@@ -5249,7 +5269,7 @@ function useImageNodeInteractions({
|
|
|
5249
5269
|
},
|
|
5250
5270
|
[editor, isSelected]
|
|
5251
5271
|
);
|
|
5252
|
-
const $onEnter =
|
|
5272
|
+
const $onEnter = React21.useCallback(
|
|
5253
5273
|
(event) => {
|
|
5254
5274
|
const latestSelection = lexical.$getSelection();
|
|
5255
5275
|
const buttonElem = buttonRef.current;
|
|
@@ -5269,7 +5289,7 @@ function useImageNodeInteractions({
|
|
|
5269
5289
|
},
|
|
5270
5290
|
[buttonRef, caption, isSelected, showCaption]
|
|
5271
5291
|
);
|
|
5272
|
-
const $onEscape =
|
|
5292
|
+
const $onEscape = React21.useCallback(
|
|
5273
5293
|
(event) => {
|
|
5274
5294
|
if (activeEditorRef.current === caption || buttonRef.current === event.target) {
|
|
5275
5295
|
lexical.$setSelection(null);
|
|
@@ -5286,7 +5306,7 @@ function useImageNodeInteractions({
|
|
|
5286
5306
|
},
|
|
5287
5307
|
[buttonRef, caption, editor, setSelected]
|
|
5288
5308
|
);
|
|
5289
|
-
const onClick =
|
|
5309
|
+
const onClick = React21.useCallback(
|
|
5290
5310
|
(payload) => {
|
|
5291
5311
|
const event = payload;
|
|
5292
5312
|
if (isResizing) {
|
|
@@ -5305,7 +5325,7 @@ function useImageNodeInteractions({
|
|
|
5305
5325
|
},
|
|
5306
5326
|
[clearSelection, imageRef, isResizing, isSelected, setSelected]
|
|
5307
5327
|
);
|
|
5308
|
-
const onRightClick =
|
|
5328
|
+
const onRightClick = React21.useCallback(
|
|
5309
5329
|
(event) => {
|
|
5310
5330
|
editor.getEditorState().read(() => {
|
|
5311
5331
|
const latestSelection = lexical.$getSelection();
|
|
@@ -5320,7 +5340,7 @@ function useImageNodeInteractions({
|
|
|
5320
5340
|
},
|
|
5321
5341
|
[editor]
|
|
5322
5342
|
);
|
|
5323
|
-
|
|
5343
|
+
React21.useEffect(() => {
|
|
5324
5344
|
let isMounted = true;
|
|
5325
5345
|
const rootElement = editor.getRootElement();
|
|
5326
5346
|
const unregister = utils.mergeRegister(
|
|
@@ -5424,13 +5444,13 @@ function ImageComponent({
|
|
|
5424
5444
|
src,
|
|
5425
5445
|
width
|
|
5426
5446
|
}) {
|
|
5427
|
-
const imageRef =
|
|
5428
|
-
const buttonRef =
|
|
5429
|
-
const [isResizing, setIsResizing] =
|
|
5430
|
-
const resizeTimeoutRef =
|
|
5447
|
+
const imageRef = React21.useRef(null);
|
|
5448
|
+
const buttonRef = React21.useRef(null);
|
|
5449
|
+
const [isResizing, setIsResizing] = React21.useState(false);
|
|
5450
|
+
const resizeTimeoutRef = React21.useRef(null);
|
|
5431
5451
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
5432
|
-
const [isLoadError, setIsLoadError] =
|
|
5433
|
-
const [isReplaceDialogOpen, setIsReplaceDialogOpen] =
|
|
5452
|
+
const [isLoadError, setIsLoadError] = React21.useState(false);
|
|
5453
|
+
const [isReplaceDialogOpen, setIsReplaceDialogOpen] = React21.useState(false);
|
|
5434
5454
|
const isEditable = useLexicalEditable.useLexicalEditable();
|
|
5435
5455
|
const editorContainer = useEditorContainer();
|
|
5436
5456
|
const prioritySrc = usePriorityImage();
|
|
@@ -5464,21 +5484,21 @@ function ImageComponent({
|
|
|
5464
5484
|
nodeKey,
|
|
5465
5485
|
showCaption
|
|
5466
5486
|
});
|
|
5467
|
-
|
|
5487
|
+
React21.useEffect(() => {
|
|
5468
5488
|
if (!isEditable && isReplaceDialogOpen) {
|
|
5469
5489
|
setTimeout(() => {
|
|
5470
5490
|
setIsReplaceDialogOpen(false);
|
|
5471
5491
|
}, 0);
|
|
5472
5492
|
}
|
|
5473
5493
|
}, [isEditable, isReplaceDialogOpen]);
|
|
5474
|
-
|
|
5494
|
+
React21.useEffect(() => {
|
|
5475
5495
|
return () => {
|
|
5476
5496
|
if (resizeTimeoutRef.current) {
|
|
5477
5497
|
clearTimeout(resizeTimeoutRef.current);
|
|
5478
5498
|
}
|
|
5479
5499
|
};
|
|
5480
5500
|
}, []);
|
|
5481
|
-
const onResizeEnd =
|
|
5501
|
+
const onResizeEnd = React21.useCallback(
|
|
5482
5502
|
(nextWidth, nextHeight) => {
|
|
5483
5503
|
if (resizeTimeoutRef.current) {
|
|
5484
5504
|
clearTimeout(resizeTimeoutRef.current);
|
|
@@ -5495,7 +5515,7 @@ function ImageComponent({
|
|
|
5495
5515
|
},
|
|
5496
5516
|
[editor, nodeKey]
|
|
5497
5517
|
);
|
|
5498
|
-
const onResizeStart =
|
|
5518
|
+
const onResizeStart = React21.useCallback(() => {
|
|
5499
5519
|
setIsResizing(true);
|
|
5500
5520
|
editor.update(() => {
|
|
5501
5521
|
const node = lexical.$getNodeByKey(nodeKey);
|
|
@@ -5504,7 +5524,7 @@ function ImageComponent({
|
|
|
5504
5524
|
}
|
|
5505
5525
|
});
|
|
5506
5526
|
}, [editor, nodeKey]);
|
|
5507
|
-
|
|
5527
|
+
React21.useEffect(() => {
|
|
5508
5528
|
const element = editor.getElementByKey(nodeKey);
|
|
5509
5529
|
if (element) {
|
|
5510
5530
|
if (fullWidth) {
|
|
@@ -5516,7 +5536,7 @@ function ImageComponent({
|
|
|
5516
5536
|
}
|
|
5517
5537
|
}
|
|
5518
5538
|
}, [editor, nodeKey, fullWidth]);
|
|
5519
|
-
const onSetFullWidth =
|
|
5539
|
+
const onSetFullWidth = React21.useCallback(() => {
|
|
5520
5540
|
editor.update(() => {
|
|
5521
5541
|
const node = lexical.$getNodeByKey(nodeKey);
|
|
5522
5542
|
if ($isImageNode(node)) {
|
|
@@ -5524,13 +5544,13 @@ function ImageComponent({
|
|
|
5524
5544
|
}
|
|
5525
5545
|
});
|
|
5526
5546
|
}, [editor, fullWidth, nodeKey]);
|
|
5527
|
-
const onAlign =
|
|
5547
|
+
const onAlign = React21.useCallback(
|
|
5528
5548
|
(format) => {
|
|
5529
5549
|
editor.dispatchCommand(lexical.FORMAT_ELEMENT_COMMAND, format);
|
|
5530
5550
|
},
|
|
5531
5551
|
[editor]
|
|
5532
5552
|
);
|
|
5533
|
-
const handleReplaceImage =
|
|
5553
|
+
const handleReplaceImage = React21.useCallback(
|
|
5534
5554
|
(payload) => {
|
|
5535
5555
|
if (!payload?.src) {
|
|
5536
5556
|
return;
|
|
@@ -5548,7 +5568,7 @@ function ImageComponent({
|
|
|
5548
5568
|
},
|
|
5549
5569
|
[editor, nodeKey]
|
|
5550
5570
|
);
|
|
5551
|
-
const onDelete =
|
|
5571
|
+
const onDelete = React21.useCallback(() => {
|
|
5552
5572
|
editor.update(() => {
|
|
5553
5573
|
const node = lexical.$getNodeByKey(nodeKey);
|
|
5554
5574
|
if ($isImageNode(node)) {
|
|
@@ -5570,7 +5590,7 @@ function ImageComponent({
|
|
|
5570
5590
|
isEditable ? "editable" : "readonly"
|
|
5571
5591
|
);
|
|
5572
5592
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5573
|
-
|
|
5593
|
+
React21.Suspense,
|
|
5574
5594
|
{
|
|
5575
5595
|
fallback: /* @__PURE__ */ jsxRuntime.jsx("div", { draggable, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5576
5596
|
ImagePlaceholder,
|
|
@@ -5721,7 +5741,7 @@ function $isImageNode(node) {
|
|
|
5721
5741
|
var ImageComponent2, WHITESPACE_REGEX, ImageNode;
|
|
5722
5742
|
var init_image_node = __esm({
|
|
5723
5743
|
"src/nodes/image-node.tsx"() {
|
|
5724
|
-
ImageComponent2 =
|
|
5744
|
+
ImageComponent2 = React21__namespace.lazy(() => Promise.resolve().then(() => (init_image_component(), image_component_exports)));
|
|
5725
5745
|
WHITESPACE_REGEX = /[\u200B\u00A0\s]+/g;
|
|
5726
5746
|
ImageNode = class _ImageNode extends lexical.DecoratorNode {
|
|
5727
5747
|
__src;
|
|
@@ -5864,7 +5884,7 @@ var init_image_node = __esm({
|
|
|
5864
5884
|
return this.__altText;
|
|
5865
5885
|
}
|
|
5866
5886
|
decorate() {
|
|
5867
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5887
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React21.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5868
5888
|
ImageComponent2,
|
|
5869
5889
|
{
|
|
5870
5890
|
src: this.__src,
|
|
@@ -6384,7 +6404,7 @@ var init_actions_plugin = __esm({
|
|
|
6384
6404
|
});
|
|
6385
6405
|
function AlignPlugin() {
|
|
6386
6406
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6387
|
-
|
|
6407
|
+
React21.useEffect(() => {
|
|
6388
6408
|
const config = editor._config;
|
|
6389
6409
|
if (config.theme && !config.theme.textAlign) {
|
|
6390
6410
|
config.theme.textAlign = {
|
|
@@ -6483,7 +6503,7 @@ var Separator;
|
|
|
6483
6503
|
var init_separator = __esm({
|
|
6484
6504
|
"src/ui/separator.tsx"() {
|
|
6485
6505
|
init_utils();
|
|
6486
|
-
Separator =
|
|
6506
|
+
Separator = React21__namespace.forwardRef(({ className, orientation = "horizontal", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6487
6507
|
"div",
|
|
6488
6508
|
{
|
|
6489
6509
|
ref,
|
|
@@ -6500,34 +6520,6 @@ var init_separator = __esm({
|
|
|
6500
6520
|
Separator.displayName = "Separator";
|
|
6501
6521
|
}
|
|
6502
6522
|
});
|
|
6503
|
-
var Flex;
|
|
6504
|
-
var init_flex = __esm({
|
|
6505
|
-
"src/ui/flex.tsx"() {
|
|
6506
|
-
init_utils();
|
|
6507
|
-
Flex = React20__namespace.forwardRef(
|
|
6508
|
-
({ className, align, justify, direction, wrap, gap, style, ...props }, ref) => {
|
|
6509
|
-
const gapStyle = typeof gap === "number" ? { gap: `${gap * 0.25}rem` } : typeof gap !== "undefined" ? { gap } : void 0;
|
|
6510
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6511
|
-
"div",
|
|
6512
|
-
{
|
|
6513
|
-
ref,
|
|
6514
|
-
className: cn(
|
|
6515
|
-
"editor-flex",
|
|
6516
|
-
align && `editor-items-${align}`,
|
|
6517
|
-
justify && `editor-justify-${justify}`,
|
|
6518
|
-
direction && `editor-flex-${direction}`,
|
|
6519
|
-
wrap && `editor-flex-${wrap}`,
|
|
6520
|
-
className
|
|
6521
|
-
),
|
|
6522
|
-
style: { ...gapStyle, ...style },
|
|
6523
|
-
...props
|
|
6524
|
-
}
|
|
6525
|
-
);
|
|
6526
|
-
}
|
|
6527
|
-
);
|
|
6528
|
-
Flex.displayName = "Flex";
|
|
6529
|
-
}
|
|
6530
|
-
});
|
|
6531
6523
|
function textEncoder() {
|
|
6532
6524
|
if (window.TextEncoder === void 0) {
|
|
6533
6525
|
return null;
|
|
@@ -6549,14 +6541,14 @@ function CounterCharacterPlugin({
|
|
|
6549
6541
|
charset = "UTF-16"
|
|
6550
6542
|
}) {
|
|
6551
6543
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6552
|
-
const [stats, setStats] =
|
|
6544
|
+
const [stats, setStats] = React21.useState(() => {
|
|
6553
6545
|
const initialText = editor.getEditorState().read(text.$rootTextContent);
|
|
6554
6546
|
return {
|
|
6555
6547
|
characters: strlen(initialText, charset),
|
|
6556
6548
|
words: countWords(initialText)
|
|
6557
6549
|
};
|
|
6558
6550
|
});
|
|
6559
|
-
|
|
6551
|
+
React21.useEffect(() => {
|
|
6560
6552
|
return editor.registerTextContentListener((currentText) => {
|
|
6561
6553
|
setStats({
|
|
6562
6554
|
characters: strlen(currentText, charset),
|
|
@@ -6598,7 +6590,7 @@ var init_counter_character_plugin = __esm({
|
|
|
6598
6590
|
});
|
|
6599
6591
|
function EditModeTogglePlugin() {
|
|
6600
6592
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6601
|
-
const [isEditable, setIsEditable] =
|
|
6593
|
+
const [isEditable, setIsEditable] = React21.useState(() => editor.isEditable());
|
|
6602
6594
|
return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
6603
6595
|
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6604
6596
|
Button,
|
|
@@ -6677,7 +6669,7 @@ function MarkdownTogglePlugin({
|
|
|
6677
6669
|
transformers
|
|
6678
6670
|
}) {
|
|
6679
6671
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6680
|
-
const handleMarkdownToggle =
|
|
6672
|
+
const handleMarkdownToggle = React21.useCallback(() => {
|
|
6681
6673
|
editor.update(() => {
|
|
6682
6674
|
const root = lexical.$getRoot();
|
|
6683
6675
|
const firstChild = root.getFirstChild();
|
|
@@ -6796,7 +6788,7 @@ function ShareContentPlugin() {
|
|
|
6796
6788
|
window.history.replaceState({}, "", newUrl);
|
|
6797
6789
|
await window.navigator.clipboard.writeText(newUrl);
|
|
6798
6790
|
}
|
|
6799
|
-
|
|
6791
|
+
React21.useEffect(() => {
|
|
6800
6792
|
docFromHash(window.location.hash).then((doc) => {
|
|
6801
6793
|
if (doc && doc.source === "editor") {
|
|
6802
6794
|
editor.setEditorState(file.editorStateFromSerializedDocument(editor, doc));
|
|
@@ -6837,8 +6829,8 @@ var init_share_content_plugin = __esm({
|
|
|
6837
6829
|
}
|
|
6838
6830
|
});
|
|
6839
6831
|
function useReport() {
|
|
6840
|
-
const timer =
|
|
6841
|
-
const cleanup =
|
|
6832
|
+
const timer = React21.useRef(null);
|
|
6833
|
+
const cleanup = React21.useCallback(() => {
|
|
6842
6834
|
if (timer.current !== null) {
|
|
6843
6835
|
clearTimeout(timer.current);
|
|
6844
6836
|
timer.current = null;
|
|
@@ -6847,10 +6839,10 @@ function useReport() {
|
|
|
6847
6839
|
document.body.removeChild(getElement());
|
|
6848
6840
|
}
|
|
6849
6841
|
}, []);
|
|
6850
|
-
|
|
6842
|
+
React21.useEffect(() => {
|
|
6851
6843
|
return cleanup;
|
|
6852
6844
|
}, [cleanup]);
|
|
6853
|
-
return
|
|
6845
|
+
return React21.useCallback(
|
|
6854
6846
|
(content) => {
|
|
6855
6847
|
logger.debug("Report content", { content });
|
|
6856
6848
|
const element = getElement();
|
|
@@ -6891,13 +6883,13 @@ var init_use_report = __esm({
|
|
|
6891
6883
|
});
|
|
6892
6884
|
function SpeechToTextPluginImpl() {
|
|
6893
6885
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
6894
|
-
const [isEnabled, setIsEnabled] =
|
|
6895
|
-
const [isSpeechToText, setIsSpeechToText] =
|
|
6886
|
+
const [isEnabled, setIsEnabled] = React21.useState(false);
|
|
6887
|
+
const [isSpeechToText, setIsSpeechToText] = React21.useState(false);
|
|
6896
6888
|
const SpeechRecognition = CAN_USE_DOM && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6897
6889
|
(window.SpeechRecognition || window.webkitSpeechRecognition);
|
|
6898
|
-
const recognition =
|
|
6890
|
+
const recognition = React21.useRef(null);
|
|
6899
6891
|
const report = useReport();
|
|
6900
|
-
|
|
6892
|
+
React21.useEffect(() => {
|
|
6901
6893
|
if (isEnabled && recognition.current === null) {
|
|
6902
6894
|
recognition.current = new SpeechRecognition();
|
|
6903
6895
|
recognition.current.continuous = true;
|
|
@@ -6943,7 +6935,7 @@ function SpeechToTextPluginImpl() {
|
|
|
6943
6935
|
}
|
|
6944
6936
|
};
|
|
6945
6937
|
}, [SpeechRecognition, editor, isEnabled, report]);
|
|
6946
|
-
|
|
6938
|
+
React21.useEffect(() => {
|
|
6947
6939
|
return editor.registerCommand(
|
|
6948
6940
|
SPEECH_TO_TEXT_COMMAND,
|
|
6949
6941
|
(_isEnabled) => {
|
|
@@ -7003,7 +6995,7 @@ var ScrollArea, ScrollBar;
|
|
|
7003
6995
|
var init_scroll_area = __esm({
|
|
7004
6996
|
"src/ui/scroll-area.tsx"() {
|
|
7005
6997
|
init_utils();
|
|
7006
|
-
ScrollArea =
|
|
6998
|
+
ScrollArea = React21__namespace.forwardRef(
|
|
7007
6999
|
({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7008
7000
|
"div",
|
|
7009
7001
|
{
|
|
@@ -7106,12 +7098,12 @@ function debounce(fn, ms, options) {
|
|
|
7106
7098
|
return debounced;
|
|
7107
7099
|
}
|
|
7108
7100
|
function useDebounce(fn, ms, maxWait) {
|
|
7109
|
-
const funcRef =
|
|
7110
|
-
const debouncedRef =
|
|
7111
|
-
|
|
7101
|
+
const funcRef = React21.useRef(fn);
|
|
7102
|
+
const debouncedRef = React21.useRef(null);
|
|
7103
|
+
React21.useEffect(() => {
|
|
7112
7104
|
funcRef.current = fn;
|
|
7113
7105
|
}, [fn]);
|
|
7114
|
-
|
|
7106
|
+
React21.useEffect(() => {
|
|
7115
7107
|
const debounced = debounce(
|
|
7116
7108
|
((...args) => {
|
|
7117
7109
|
funcRef.current(...args);
|
|
@@ -7125,7 +7117,7 @@ function useDebounce(fn, ms, maxWait) {
|
|
|
7125
7117
|
debouncedRef.current = null;
|
|
7126
7118
|
};
|
|
7127
7119
|
}, [ms, maxWait]);
|
|
7128
|
-
return
|
|
7120
|
+
return React21.useMemo(() => {
|
|
7129
7121
|
const run = (...args) => {
|
|
7130
7122
|
debouncedRef.current?.(...args);
|
|
7131
7123
|
};
|
|
@@ -7140,7 +7132,7 @@ var init_use_debounce = __esm({
|
|
|
7140
7132
|
}
|
|
7141
7133
|
});
|
|
7142
7134
|
function CopyButton({ editor, getCodeDOMNode }) {
|
|
7143
|
-
const [isCopyCompleted, setCopyCompleted] =
|
|
7135
|
+
const [isCopyCompleted, setCopyCompleted] = React21.useState(false);
|
|
7144
7136
|
const removeSuccessIcon = useDebounce(() => {
|
|
7145
7137
|
setCopyCompleted(false);
|
|
7146
7138
|
}, 1e3);
|
|
@@ -7185,9 +7177,9 @@ var init_code_button = __esm({
|
|
|
7185
7177
|
}
|
|
7186
7178
|
});
|
|
7187
7179
|
function Select({ value, onValueChange, children, disabled }) {
|
|
7188
|
-
const [open, setOpen] =
|
|
7189
|
-
const triggerRef =
|
|
7190
|
-
const contextValue =
|
|
7180
|
+
const [open, setOpen] = React21__namespace.useState(false);
|
|
7181
|
+
const triggerRef = React21__namespace.useRef(null);
|
|
7182
|
+
const contextValue = React21__namespace.useMemo(() => ({
|
|
7191
7183
|
value,
|
|
7192
7184
|
onValueChange,
|
|
7193
7185
|
open,
|
|
@@ -7198,7 +7190,7 @@ function Select({ value, onValueChange, children, disabled }) {
|
|
|
7198
7190
|
return /* @__PURE__ */ jsxRuntime.jsx(SelectContext.Provider, { value: contextValue, children });
|
|
7199
7191
|
}
|
|
7200
7192
|
function SelectTrigger({ className, children, size = "default", ...props }) {
|
|
7201
|
-
const context =
|
|
7193
|
+
const context = React21__namespace.useContext(SelectContext);
|
|
7202
7194
|
if (!context) throw new Error("SelectTrigger must be used within Select");
|
|
7203
7195
|
const { triggerRef, disabled, open, setOpen } = context;
|
|
7204
7196
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -7222,15 +7214,15 @@ function SelectTrigger({ className, children, size = "default", ...props }) {
|
|
|
7222
7214
|
);
|
|
7223
7215
|
}
|
|
7224
7216
|
function SelectValue({ placeholder }) {
|
|
7225
|
-
const context =
|
|
7217
|
+
const context = React21__namespace.useContext(SelectContext);
|
|
7226
7218
|
if (!context) throw new Error("SelectValue must be used within Select");
|
|
7227
7219
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { children: context.value || placeholder });
|
|
7228
7220
|
}
|
|
7229
7221
|
function SelectContent({ className, children, ...props }) {
|
|
7230
|
-
const context =
|
|
7231
|
-
const [position, setPosition] =
|
|
7232
|
-
const contentRef =
|
|
7233
|
-
|
|
7222
|
+
const context = React21__namespace.useContext(SelectContext);
|
|
7223
|
+
const [position, setPosition] = React21__namespace.useState({ top: 0, left: 0, width: 0 });
|
|
7224
|
+
const contentRef = React21__namespace.useRef(null);
|
|
7225
|
+
React21__namespace.useEffect(() => {
|
|
7234
7226
|
if (context?.open && context.triggerRef.current) {
|
|
7235
7227
|
const rect = context.triggerRef.current.getBoundingClientRect();
|
|
7236
7228
|
setPosition({
|
|
@@ -7272,7 +7264,7 @@ function SelectContent({ className, children, ...props }) {
|
|
|
7272
7264
|
);
|
|
7273
7265
|
}
|
|
7274
7266
|
function SelectItem({ value, children, className, ...props }) {
|
|
7275
|
-
const context =
|
|
7267
|
+
const context = React21__namespace.useContext(SelectContext);
|
|
7276
7268
|
if (!context) throw new Error("SelectItem must be used within Select");
|
|
7277
7269
|
const isSelected = context.value === value;
|
|
7278
7270
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -7302,7 +7294,7 @@ var SelectContext;
|
|
|
7302
7294
|
var init_select = __esm({
|
|
7303
7295
|
"src/ui/select.tsx"() {
|
|
7304
7296
|
init_utils();
|
|
7305
|
-
SelectContext =
|
|
7297
|
+
SelectContext = React21__namespace.createContext(null);
|
|
7306
7298
|
}
|
|
7307
7299
|
});
|
|
7308
7300
|
function getCodeLanguageOptions() {
|
|
@@ -7318,16 +7310,16 @@ function CodeActionMenuContainer({
|
|
|
7318
7310
|
anchorElem
|
|
7319
7311
|
}) {
|
|
7320
7312
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
7321
|
-
const [lang, setLang] =
|
|
7322
|
-
const [nodeKey, setNodeKey] =
|
|
7323
|
-
const [isShown, setShown] =
|
|
7324
|
-
const [shouldListenMouseMove, setShouldListenMouseMove] =
|
|
7325
|
-
const [position, setPosition] =
|
|
7313
|
+
const [lang, setLang] = React21.useState("");
|
|
7314
|
+
const [nodeKey, setNodeKey] = React21.useState(null);
|
|
7315
|
+
const [isShown, setShown] = React21.useState(false);
|
|
7316
|
+
const [shouldListenMouseMove, setShouldListenMouseMove] = React21.useState(false);
|
|
7317
|
+
const [position, setPosition] = React21.useState({
|
|
7326
7318
|
right: "0",
|
|
7327
7319
|
top: "0"
|
|
7328
7320
|
});
|
|
7329
|
-
const codeSetRef =
|
|
7330
|
-
const codeDOMNodeRef =
|
|
7321
|
+
const codeSetRef = React21.useRef(/* @__PURE__ */ new Set());
|
|
7322
|
+
const codeDOMNodeRef = React21.useRef(null);
|
|
7331
7323
|
function getCodeDOMNode() {
|
|
7332
7324
|
return codeDOMNodeRef.current;
|
|
7333
7325
|
}
|
|
@@ -7368,7 +7360,7 @@ function CodeActionMenuContainer({
|
|
|
7368
7360
|
50,
|
|
7369
7361
|
1e3
|
|
7370
7362
|
);
|
|
7371
|
-
const onCodeLanguageSelect =
|
|
7363
|
+
const onCodeLanguageSelect = React21.useCallback(
|
|
7372
7364
|
(value) => {
|
|
7373
7365
|
editor.update(() => {
|
|
7374
7366
|
if (nodeKey !== null) {
|
|
@@ -7382,7 +7374,7 @@ function CodeActionMenuContainer({
|
|
|
7382
7374
|
},
|
|
7383
7375
|
[editor, nodeKey]
|
|
7384
7376
|
);
|
|
7385
|
-
|
|
7377
|
+
React21.useEffect(() => {
|
|
7386
7378
|
if (!shouldListenMouseMove) {
|
|
7387
7379
|
return;
|
|
7388
7380
|
}
|
|
@@ -7393,7 +7385,7 @@ function CodeActionMenuContainer({
|
|
|
7393
7385
|
document.removeEventListener("mousemove", debouncedOnMouseMove);
|
|
7394
7386
|
};
|
|
7395
7387
|
}, [shouldListenMouseMove, debouncedOnMouseMove]);
|
|
7396
|
-
|
|
7388
|
+
React21.useEffect(() => {
|
|
7397
7389
|
return editor.registerMutationListener(
|
|
7398
7390
|
code.CodeNode,
|
|
7399
7391
|
(mutations) => {
|
|
@@ -7482,7 +7474,7 @@ var init_code_action_menu_plugin = __esm({
|
|
|
7482
7474
|
});
|
|
7483
7475
|
function CodeHighlightPlugin() {
|
|
7484
7476
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
7485
|
-
|
|
7477
|
+
React21.useEffect(() => {
|
|
7486
7478
|
return code.registerCodeHighlighting(editor);
|
|
7487
7479
|
}, [editor]);
|
|
7488
7480
|
return null;
|
|
@@ -7493,11 +7485,11 @@ var init_code_highlight_plugin = __esm({
|
|
|
7493
7485
|
}
|
|
7494
7486
|
});
|
|
7495
7487
|
function useEditorModal() {
|
|
7496
|
-
const [modalContent, setModalContent] =
|
|
7497
|
-
const onClose =
|
|
7488
|
+
const [modalContent, setModalContent] = React21.useState(null);
|
|
7489
|
+
const onClose = React21.useCallback(() => {
|
|
7498
7490
|
setModalContent(null);
|
|
7499
7491
|
}, []);
|
|
7500
|
-
const modal =
|
|
7492
|
+
const modal = React21.useMemo(() => {
|
|
7501
7493
|
if (modalContent === null) {
|
|
7502
7494
|
return null;
|
|
7503
7495
|
}
|
|
@@ -7510,7 +7502,7 @@ function useEditorModal() {
|
|
|
7510
7502
|
content
|
|
7511
7503
|
] }) });
|
|
7512
7504
|
}, [modalContent, onClose]);
|
|
7513
|
-
const showModal =
|
|
7505
|
+
const showModal = React21.useCallback(
|
|
7514
7506
|
(title, getContent, closeOnClickOutside = false) => {
|
|
7515
7507
|
setModalContent({
|
|
7516
7508
|
closeOnClickOutside,
|
|
@@ -7531,7 +7523,7 @@ var Command, CommandList, CommandGroup, CommandItem;
|
|
|
7531
7523
|
var init_command = __esm({
|
|
7532
7524
|
"src/ui/command.tsx"() {
|
|
7533
7525
|
init_utils();
|
|
7534
|
-
Command =
|
|
7526
|
+
Command = React21__namespace.forwardRef(
|
|
7535
7527
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7536
7528
|
"div",
|
|
7537
7529
|
{
|
|
@@ -7542,7 +7534,7 @@ var init_command = __esm({
|
|
|
7542
7534
|
)
|
|
7543
7535
|
);
|
|
7544
7536
|
Command.displayName = "Command";
|
|
7545
|
-
CommandList =
|
|
7537
|
+
CommandList = React21__namespace.forwardRef(
|
|
7546
7538
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7547
7539
|
"div",
|
|
7548
7540
|
{
|
|
@@ -7553,7 +7545,7 @@ var init_command = __esm({
|
|
|
7553
7545
|
)
|
|
7554
7546
|
);
|
|
7555
7547
|
CommandList.displayName = "CommandList";
|
|
7556
|
-
CommandGroup =
|
|
7548
|
+
CommandGroup = React21__namespace.forwardRef(
|
|
7557
7549
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7558
7550
|
"div",
|
|
7559
7551
|
{
|
|
@@ -7564,7 +7556,7 @@ var init_command = __esm({
|
|
|
7564
7556
|
)
|
|
7565
7557
|
);
|
|
7566
7558
|
CommandGroup.displayName = "CommandGroup";
|
|
7567
|
-
CommandItem =
|
|
7559
|
+
CommandItem = React21__namespace.forwardRef(({ className, onSelect, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7568
7560
|
"div",
|
|
7569
7561
|
{
|
|
7570
7562
|
ref,
|
|
@@ -7582,8 +7574,8 @@ function MenuContent({
|
|
|
7582
7574
|
selectOptionAndCleanUp,
|
|
7583
7575
|
setHighlightedIndex
|
|
7584
7576
|
}) {
|
|
7585
|
-
const containerRef =
|
|
7586
|
-
|
|
7577
|
+
const containerRef = React21.useRef(null);
|
|
7578
|
+
React21.useEffect(() => {
|
|
7587
7579
|
if (selectedIndex !== null && selectedIndex >= 0 && selectedIndex < options.length) {
|
|
7588
7580
|
const timeoutId = setTimeout(() => {
|
|
7589
7581
|
const container = containerRef.current;
|
|
@@ -7742,7 +7734,7 @@ function ComponentPickerMenuPlugin({
|
|
|
7742
7734
|
}) {
|
|
7743
7735
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
7744
7736
|
const [modal, showModal] = useEditorModal();
|
|
7745
|
-
const [queryString, setQueryString] =
|
|
7737
|
+
const [queryString, setQueryString] = React21.useState(null);
|
|
7746
7738
|
logger.debug("ComponentPickerMenuPlugin initialized", {
|
|
7747
7739
|
baseOptionsCount: baseOptions.length,
|
|
7748
7740
|
hasDynamicOptionsFn: !!dynamicOptionsFn
|
|
@@ -7750,7 +7742,7 @@ function ComponentPickerMenuPlugin({
|
|
|
7750
7742
|
const checkForTriggerMatch = LexicalTypeaheadMenuPlugin$1.useBasicTypeaheadTriggerMatch("/", {
|
|
7751
7743
|
minLength: 0
|
|
7752
7744
|
});
|
|
7753
|
-
const options =
|
|
7745
|
+
const options = React21.useMemo(() => {
|
|
7754
7746
|
if (!queryString) {
|
|
7755
7747
|
logger.debug("ComponentPickerMenuPlugin: No query string, returning baseOptions", {
|
|
7756
7748
|
baseOptionsCount: baseOptions.length,
|
|
@@ -7775,7 +7767,7 @@ function ComponentPickerMenuPlugin({
|
|
|
7775
7767
|
});
|
|
7776
7768
|
return filtered;
|
|
7777
7769
|
}, [baseOptions, dynamicOptionsFn, queryString]);
|
|
7778
|
-
const onSelectOption =
|
|
7770
|
+
const onSelectOption = React21.useCallback(
|
|
7779
7771
|
(selectedOption, nodeToRemove, closeMenu, matchingString) => {
|
|
7780
7772
|
editor.update(() => {
|
|
7781
7773
|
nodeToRemove?.remove();
|
|
@@ -7900,6 +7892,98 @@ var init_component_picker_menu_plugin = __esm({
|
|
|
7900
7892
|
);
|
|
7901
7893
|
}
|
|
7902
7894
|
});
|
|
7895
|
+
var NumberInput;
|
|
7896
|
+
var init_number_input = __esm({
|
|
7897
|
+
"src/ui/number-input.tsx"() {
|
|
7898
|
+
"use client";
|
|
7899
|
+
init_utils();
|
|
7900
|
+
init_button();
|
|
7901
|
+
init_input();
|
|
7902
|
+
NumberInput = React21__namespace.forwardRef(
|
|
7903
|
+
({ value, onValueChange, min = 0, max = 100, step = 1, unit = "px", className, ...props }, ref) => {
|
|
7904
|
+
const timerRef = React21__namespace.useRef(null);
|
|
7905
|
+
const intervalRef = React21__namespace.useRef(null);
|
|
7906
|
+
const valueRef = React21__namespace.useRef(value);
|
|
7907
|
+
React21__namespace.useEffect(() => {
|
|
7908
|
+
valueRef.current = value;
|
|
7909
|
+
}, [value]);
|
|
7910
|
+
const updateValue = React21__namespace.useCallback((delta) => {
|
|
7911
|
+
onValueChange(Math.min(Math.max(valueRef.current + delta, min), max));
|
|
7912
|
+
}, [onValueChange, min, max]);
|
|
7913
|
+
const startLongPress = (delta) => {
|
|
7914
|
+
updateValue(delta);
|
|
7915
|
+
timerRef.current = setTimeout(() => {
|
|
7916
|
+
intervalRef.current = setInterval(() => {
|
|
7917
|
+
updateValue(delta);
|
|
7918
|
+
}, 50);
|
|
7919
|
+
}, 300);
|
|
7920
|
+
};
|
|
7921
|
+
const stopLongPress = React21__namespace.useCallback(() => {
|
|
7922
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
7923
|
+
if (intervalRef.current) clearInterval(intervalRef.current);
|
|
7924
|
+
}, []);
|
|
7925
|
+
const handleBlur = () => {
|
|
7926
|
+
onValueChange(Math.min(Math.max(value, min), max));
|
|
7927
|
+
};
|
|
7928
|
+
React21__namespace.useEffect(() => {
|
|
7929
|
+
return () => stopLongPress();
|
|
7930
|
+
}, [stopLongPress]);
|
|
7931
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("editor-number-input-container", className), children: [
|
|
7932
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7933
|
+
Button,
|
|
7934
|
+
{
|
|
7935
|
+
variant: "ghost",
|
|
7936
|
+
size: "icon",
|
|
7937
|
+
className: "editor-number-input-btn",
|
|
7938
|
+
onMouseDown: () => startLongPress(-step),
|
|
7939
|
+
onMouseUp: stopLongPress,
|
|
7940
|
+
onMouseLeave: stopLongPress,
|
|
7941
|
+
onTouchStart: () => startLongPress(-step),
|
|
7942
|
+
onTouchEnd: stopLongPress,
|
|
7943
|
+
tabIndex: -1,
|
|
7944
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minus, { size: 14 })
|
|
7945
|
+
}
|
|
7946
|
+
),
|
|
7947
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "editor-number-input-wrapper", children: [
|
|
7948
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7949
|
+
Input,
|
|
7950
|
+
{
|
|
7951
|
+
...props,
|
|
7952
|
+
ref,
|
|
7953
|
+
type: "number",
|
|
7954
|
+
value,
|
|
7955
|
+
onBlur: handleBlur,
|
|
7956
|
+
onChange: (e) => {
|
|
7957
|
+
const val = parseInt(e.target.value, 10);
|
|
7958
|
+
if (!isNaN(val)) onValueChange(val);
|
|
7959
|
+
else onValueChange(0);
|
|
7960
|
+
},
|
|
7961
|
+
className: "editor-number-input-field"
|
|
7962
|
+
}
|
|
7963
|
+
),
|
|
7964
|
+
unit && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "editor-number-input-unit", children: unit })
|
|
7965
|
+
] }),
|
|
7966
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7967
|
+
Button,
|
|
7968
|
+
{
|
|
7969
|
+
variant: "ghost",
|
|
7970
|
+
size: "icon",
|
|
7971
|
+
className: "editor-number-input-btn",
|
|
7972
|
+
onMouseDown: () => startLongPress(step),
|
|
7973
|
+
onMouseUp: stopLongPress,
|
|
7974
|
+
onMouseLeave: stopLongPress,
|
|
7975
|
+
onTouchStart: () => startLongPress(step),
|
|
7976
|
+
onTouchEnd: stopLongPress,
|
|
7977
|
+
tabIndex: -1,
|
|
7978
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { size: 14 })
|
|
7979
|
+
}
|
|
7980
|
+
)
|
|
7981
|
+
] });
|
|
7982
|
+
}
|
|
7983
|
+
);
|
|
7984
|
+
NumberInput.displayName = "NumberInput";
|
|
7985
|
+
}
|
|
7986
|
+
});
|
|
7903
7987
|
var Slot;
|
|
7904
7988
|
var init_slot = __esm({
|
|
7905
7989
|
"src/ui/slot.tsx"() {
|
|
@@ -7907,11 +7991,11 @@ var init_slot = __esm({
|
|
|
7907
7991
|
}
|
|
7908
7992
|
});
|
|
7909
7993
|
function Popover({ children, open: controlledOpen, defaultOpen = false, onOpenChange, modal = false }) {
|
|
7910
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
7911
|
-
const triggerRef =
|
|
7994
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React21__namespace.useState(defaultOpen);
|
|
7995
|
+
const triggerRef = React21__namespace.useRef(null);
|
|
7912
7996
|
const open = controlledOpen ?? uncontrolledOpen;
|
|
7913
7997
|
const setOpen = onOpenChange ?? setUncontrolledOpen;
|
|
7914
|
-
const contextValue =
|
|
7998
|
+
const contextValue = React21__namespace.useMemo(() => ({
|
|
7915
7999
|
open,
|
|
7916
8000
|
setOpen,
|
|
7917
8001
|
triggerRef,
|
|
@@ -7920,17 +8004,17 @@ function Popover({ children, open: controlledOpen, defaultOpen = false, onOpenCh
|
|
|
7920
8004
|
return /* @__PURE__ */ jsxRuntime.jsx(PopoverContext.Provider, { value: contextValue, children });
|
|
7921
8005
|
}
|
|
7922
8006
|
function PopoverTrigger({ children, asChild, ...props }) {
|
|
7923
|
-
const context =
|
|
8007
|
+
const context = React21__namespace.useContext(PopoverContext);
|
|
7924
8008
|
if (!context) throw new Error("PopoverTrigger must be used within Popover");
|
|
7925
8009
|
const { triggerRef, open, setOpen } = context;
|
|
7926
8010
|
const handleClick = (e) => {
|
|
7927
8011
|
setOpen(!open);
|
|
7928
|
-
if (
|
|
8012
|
+
if (React21__namespace.isValidElement(children)) {
|
|
7929
8013
|
children.props.onClick?.(e);
|
|
7930
8014
|
}
|
|
7931
8015
|
};
|
|
7932
|
-
if (asChild &&
|
|
7933
|
-
return
|
|
8016
|
+
if (asChild && React21__namespace.isValidElement(children)) {
|
|
8017
|
+
return React21__namespace.cloneElement(children, {
|
|
7934
8018
|
ref: triggerRef,
|
|
7935
8019
|
onClick: handleClick,
|
|
7936
8020
|
...props
|
|
@@ -7948,10 +8032,10 @@ function PopoverTrigger({ children, asChild, ...props }) {
|
|
|
7948
8032
|
);
|
|
7949
8033
|
}
|
|
7950
8034
|
function PopoverContent({ children, className, align = "center", sideOffset = 4, ...props }) {
|
|
7951
|
-
const context =
|
|
7952
|
-
const [position, setPosition] =
|
|
7953
|
-
const contentRef =
|
|
7954
|
-
|
|
8035
|
+
const context = React21__namespace.useContext(PopoverContext);
|
|
8036
|
+
const [position, setPosition] = React21__namespace.useState({ top: 0, left: 0 });
|
|
8037
|
+
const contentRef = React21__namespace.useRef(null);
|
|
8038
|
+
React21__namespace.useEffect(() => {
|
|
7955
8039
|
if (context?.open && context.triggerRef.current) {
|
|
7956
8040
|
const rect = context.triggerRef.current.getBoundingClientRect();
|
|
7957
8041
|
let left = rect.left;
|
|
@@ -8001,7 +8085,7 @@ var PopoverContext;
|
|
|
8001
8085
|
var init_popover = __esm({
|
|
8002
8086
|
"src/ui/popover.tsx"() {
|
|
8003
8087
|
init_utils();
|
|
8004
|
-
PopoverContext =
|
|
8088
|
+
PopoverContext = React21__namespace.createContext(null);
|
|
8005
8089
|
}
|
|
8006
8090
|
});
|
|
8007
8091
|
function setRef(ref, value) {
|
|
@@ -8037,7 +8121,7 @@ function composeRefs(...refs) {
|
|
|
8037
8121
|
};
|
|
8038
8122
|
}
|
|
8039
8123
|
function useComposedRefs(...refs) {
|
|
8040
|
-
return
|
|
8124
|
+
return React21__namespace.useCallback(
|
|
8041
8125
|
(value) => {
|
|
8042
8126
|
composeRefs(...refs)(value);
|
|
8043
8127
|
},
|
|
@@ -8055,19 +8139,19 @@ function VisuallyHiddenInput(props) {
|
|
|
8055
8139
|
style,
|
|
8056
8140
|
...inputProps
|
|
8057
8141
|
} = props;
|
|
8058
|
-
const isCheckInput =
|
|
8142
|
+
const isCheckInput = React21__namespace.useMemo(
|
|
8059
8143
|
() => type === "checkbox" || type === "radio" || type === "switch",
|
|
8060
8144
|
[type]
|
|
8061
8145
|
);
|
|
8062
|
-
const inputRef =
|
|
8063
|
-
const prevValueRef =
|
|
8146
|
+
const inputRef = React21__namespace.useRef(null);
|
|
8147
|
+
const prevValueRef = React21__namespace.useRef({
|
|
8064
8148
|
value: isCheckInput ? checked : value,
|
|
8065
8149
|
previous: isCheckInput ? checked : value
|
|
8066
8150
|
});
|
|
8067
|
-
const [prevValue, setPrevValue] =
|
|
8151
|
+
const [prevValue, setPrevValue] = React21__namespace.useState(
|
|
8068
8152
|
isCheckInput ? checked : value
|
|
8069
8153
|
);
|
|
8070
|
-
|
|
8154
|
+
React21__namespace.useEffect(() => {
|
|
8071
8155
|
const currentValue = isCheckInput ? checked : value;
|
|
8072
8156
|
if (prevValueRef.current.value !== currentValue) {
|
|
8073
8157
|
prevValueRef.current.previous = prevValueRef.current.value;
|
|
@@ -8075,8 +8159,8 @@ function VisuallyHiddenInput(props) {
|
|
|
8075
8159
|
setPrevValue(prevValueRef.current.previous);
|
|
8076
8160
|
}
|
|
8077
8161
|
}, [isCheckInput, value, checked]);
|
|
8078
|
-
const [controlSize, setControlSize] =
|
|
8079
|
-
|
|
8162
|
+
const [controlSize, setControlSize] = React21__namespace.useState({});
|
|
8163
|
+
React21__namespace.useLayoutEffect(() => {
|
|
8080
8164
|
if (!control) {
|
|
8081
8165
|
setControlSize({});
|
|
8082
8166
|
return;
|
|
@@ -8108,7 +8192,7 @@ function VisuallyHiddenInput(props) {
|
|
|
8108
8192
|
resizeObserver.disconnect();
|
|
8109
8193
|
};
|
|
8110
8194
|
}, [control]);
|
|
8111
|
-
|
|
8195
|
+
React21__namespace.useEffect(() => {
|
|
8112
8196
|
const input = inputRef.current;
|
|
8113
8197
|
if (!input) return;
|
|
8114
8198
|
const inputProto = window.HTMLInputElement.prototype;
|
|
@@ -8124,7 +8208,7 @@ function VisuallyHiddenInput(props) {
|
|
|
8124
8208
|
input.dispatchEvent(event);
|
|
8125
8209
|
}
|
|
8126
8210
|
}, [prevValue, value, checked, bubbles, isCheckInput]);
|
|
8127
|
-
const composedStyle =
|
|
8211
|
+
const composedStyle = React21__namespace.useMemo(() => {
|
|
8128
8212
|
return {
|
|
8129
8213
|
...style,
|
|
8130
8214
|
...controlSize.width !== void 0 && controlSize.height !== void 0 ? controlSize : {},
|
|
@@ -8436,11 +8520,11 @@ function parseColorString(value) {
|
|
|
8436
8520
|
return null;
|
|
8437
8521
|
}
|
|
8438
8522
|
function useDirection(dirProp) {
|
|
8439
|
-
const contextDir =
|
|
8523
|
+
const contextDir = React21__namespace.useContext(DirectionContext);
|
|
8440
8524
|
return dirProp ?? contextDir ?? "ltr";
|
|
8441
8525
|
}
|
|
8442
8526
|
function useLazyRef(fn) {
|
|
8443
|
-
const ref =
|
|
8527
|
+
const ref = React21__namespace.useRef(null);
|
|
8444
8528
|
if (ref.current === null) {
|
|
8445
8529
|
ref.current = fn();
|
|
8446
8530
|
}
|
|
@@ -8514,7 +8598,7 @@ function createColorPickerStore(listenersRef, stateRef, callbacks) {
|
|
|
8514
8598
|
return store;
|
|
8515
8599
|
}
|
|
8516
8600
|
function useColorPickerStoreContext(consumerName) {
|
|
8517
|
-
const context =
|
|
8601
|
+
const context = React21__namespace.useContext(ColorPickerStoreContext);
|
|
8518
8602
|
if (!context) {
|
|
8519
8603
|
throw new Error(
|
|
8520
8604
|
`\`${consumerName}\` must be used within \`ColorPickerRoot\``
|
|
@@ -8524,14 +8608,14 @@ function useColorPickerStoreContext(consumerName) {
|
|
|
8524
8608
|
}
|
|
8525
8609
|
function useColorPickerStore(selector) {
|
|
8526
8610
|
const store = useColorPickerStoreContext("useColorPickerStoreSelector");
|
|
8527
|
-
const getSnapshot =
|
|
8611
|
+
const getSnapshot = React21__namespace.useCallback(
|
|
8528
8612
|
() => selector(store.getState()),
|
|
8529
8613
|
[store, selector]
|
|
8530
8614
|
);
|
|
8531
|
-
return
|
|
8615
|
+
return React21__namespace.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
|
|
8532
8616
|
}
|
|
8533
8617
|
function useColorPickerContext(consumerName) {
|
|
8534
|
-
const context =
|
|
8618
|
+
const context = React21__namespace.useContext(ColorPickerContext);
|
|
8535
8619
|
if (!context) {
|
|
8536
8620
|
throw new Error(
|
|
8537
8621
|
`\`${consumerName}\` must be used within \`ColorPickerRoot\``
|
|
@@ -8558,12 +8642,12 @@ function ColorPickerRootImpl(props) {
|
|
|
8558
8642
|
} = props;
|
|
8559
8643
|
const store = useColorPickerStoreContext("ColorPickerRootImpl");
|
|
8560
8644
|
const dir = useDirection(dirProp);
|
|
8561
|
-
const [formTrigger, setFormTrigger] =
|
|
8645
|
+
const [formTrigger, setFormTrigger] = React21__namespace.useState(
|
|
8562
8646
|
null
|
|
8563
8647
|
);
|
|
8564
8648
|
const composedRef = useComposedRefs(ref, (node) => setFormTrigger(node));
|
|
8565
8649
|
const isFormControl = formTrigger ? !!formTrigger.closest("form") : true;
|
|
8566
|
-
|
|
8650
|
+
React21__namespace.useEffect(() => {
|
|
8567
8651
|
if (valueProp !== void 0) {
|
|
8568
8652
|
const color = parseColorString(valueProp);
|
|
8569
8653
|
if (color) {
|
|
@@ -8573,12 +8657,12 @@ function ColorPickerRootImpl(props) {
|
|
|
8573
8657
|
}
|
|
8574
8658
|
}
|
|
8575
8659
|
}, [valueProp, store]);
|
|
8576
|
-
|
|
8660
|
+
React21__namespace.useEffect(() => {
|
|
8577
8661
|
if (openProp !== void 0) {
|
|
8578
8662
|
store.setOpen(openProp);
|
|
8579
8663
|
}
|
|
8580
8664
|
}, [openProp, store]);
|
|
8581
|
-
const contextValue =
|
|
8665
|
+
const contextValue = React21__namespace.useMemo(
|
|
8582
8666
|
() => ({
|
|
8583
8667
|
dir,
|
|
8584
8668
|
disabled,
|
|
@@ -8590,7 +8674,7 @@ function ColorPickerRootImpl(props) {
|
|
|
8590
8674
|
);
|
|
8591
8675
|
const value = useColorPickerStore((state) => rgbToHex(state.color));
|
|
8592
8676
|
const open = useColorPickerStore((state) => state.open);
|
|
8593
|
-
const onPopoverOpenChange =
|
|
8677
|
+
const onPopoverOpenChange = React21__namespace.useCallback(
|
|
8594
8678
|
(newOpen) => {
|
|
8595
8679
|
store.setOpen(newOpen);
|
|
8596
8680
|
onOpenChange?.(newOpen);
|
|
@@ -8676,10 +8760,10 @@ function ColorPickerArea(props) {
|
|
|
8676
8760
|
const context = useColorPickerContext("ColorPickerArea");
|
|
8677
8761
|
const store = useColorPickerStoreContext("ColorPickerArea");
|
|
8678
8762
|
const hsv = useColorPickerStore((state) => state.hsv);
|
|
8679
|
-
const isDraggingRef =
|
|
8680
|
-
const areaRef =
|
|
8763
|
+
const isDraggingRef = React21__namespace.useRef(false);
|
|
8764
|
+
const areaRef = React21__namespace.useRef(null);
|
|
8681
8765
|
const composedRef = useComposedRefs(ref, areaRef);
|
|
8682
|
-
const updateColorFromPosition =
|
|
8766
|
+
const updateColorFromPosition = React21__namespace.useCallback(
|
|
8683
8767
|
(clientX, clientY) => {
|
|
8684
8768
|
if (!areaRef.current) return;
|
|
8685
8769
|
const rect = areaRef.current.getBoundingClientRect();
|
|
@@ -8696,7 +8780,7 @@ function ColorPickerArea(props) {
|
|
|
8696
8780
|
},
|
|
8697
8781
|
[hsv, store]
|
|
8698
8782
|
);
|
|
8699
|
-
const onPointerDown =
|
|
8783
|
+
const onPointerDown = React21__namespace.useCallback(
|
|
8700
8784
|
(event) => {
|
|
8701
8785
|
if (context.disabled) return;
|
|
8702
8786
|
event.preventDefault();
|
|
@@ -8706,7 +8790,7 @@ function ColorPickerArea(props) {
|
|
|
8706
8790
|
},
|
|
8707
8791
|
[context.disabled, updateColorFromPosition]
|
|
8708
8792
|
);
|
|
8709
|
-
const onPointerMove =
|
|
8793
|
+
const onPointerMove = React21__namespace.useCallback(
|
|
8710
8794
|
(event) => {
|
|
8711
8795
|
if (isDraggingRef.current) {
|
|
8712
8796
|
updateColorFromPosition(event.clientX, event.clientY);
|
|
@@ -8714,7 +8798,7 @@ function ColorPickerArea(props) {
|
|
|
8714
8798
|
},
|
|
8715
8799
|
[updateColorFromPosition]
|
|
8716
8800
|
);
|
|
8717
|
-
const onPointerUp =
|
|
8801
|
+
const onPointerUp = React21__namespace.useCallback((event) => {
|
|
8718
8802
|
isDraggingRef.current = false;
|
|
8719
8803
|
areaRef.current?.releasePointerCapture(event.pointerId);
|
|
8720
8804
|
}, []);
|
|
@@ -8784,7 +8868,7 @@ function ColorPickerHueSlider(props) {
|
|
|
8784
8868
|
const context = useColorPickerContext("ColorPickerHueSlider");
|
|
8785
8869
|
const store = useColorPickerStoreContext("ColorPickerHueSlider");
|
|
8786
8870
|
const hsv = useColorPickerStore((state) => state.hsv);
|
|
8787
|
-
const onValueChange =
|
|
8871
|
+
const onValueChange = React21__namespace.useCallback(
|
|
8788
8872
|
(values) => {
|
|
8789
8873
|
const newHsv = {
|
|
8790
8874
|
h: values[0] ?? 0,
|
|
@@ -8824,7 +8908,7 @@ function ColorPickerAlphaSlider(props) {
|
|
|
8824
8908
|
const store = useColorPickerStoreContext("ColorPickerAlphaSlider");
|
|
8825
8909
|
const color = useColorPickerStore((state) => state.color);
|
|
8826
8910
|
const hsv = useColorPickerStore((state) => state.hsv);
|
|
8827
|
-
const onValueChange =
|
|
8911
|
+
const onValueChange = React21__namespace.useCallback(
|
|
8828
8912
|
(values) => {
|
|
8829
8913
|
const alpha = (values[0] ?? 0) / 100;
|
|
8830
8914
|
const newColor = { ...color, a: alpha };
|
|
@@ -8883,7 +8967,7 @@ function ColorPickerEyeDropper(props) {
|
|
|
8883
8967
|
const context = useColorPickerContext("ColorPickerEyeDropper");
|
|
8884
8968
|
const store = useColorPickerStoreContext("ColorPickerEyeDropper");
|
|
8885
8969
|
const color = useColorPickerStore((state) => state.color);
|
|
8886
|
-
const onEyeDropper =
|
|
8970
|
+
const onEyeDropper = React21__namespace.useCallback(async () => {
|
|
8887
8971
|
if (!window.EyeDropper) return;
|
|
8888
8972
|
try {
|
|
8889
8973
|
const eyeDropper = new window.EyeDropper();
|
|
@@ -8920,7 +9004,7 @@ function ColorPickerFormatSelect(props) {
|
|
|
8920
9004
|
const context = useColorPickerContext("ColorPickerFormatSelector");
|
|
8921
9005
|
const store = useColorPickerStoreContext("ColorPickerFormatSelector");
|
|
8922
9006
|
const format = useColorPickerStore((state) => state.format);
|
|
8923
|
-
const onFormatChange =
|
|
9007
|
+
const onFormatChange = React21__namespace.useCallback(
|
|
8924
9008
|
(value) => {
|
|
8925
9009
|
if (colorFormats.includes(value)) {
|
|
8926
9010
|
store.setFormat(value);
|
|
@@ -8957,7 +9041,7 @@ function ColorPickerInput(props) {
|
|
|
8957
9041
|
const color = useColorPickerStore((state) => state.color);
|
|
8958
9042
|
const format = useColorPickerStore((state) => state.format);
|
|
8959
9043
|
const hsv = useColorPickerStore((state) => state.hsv);
|
|
8960
|
-
const onColorChange =
|
|
9044
|
+
const onColorChange = React21__namespace.useCallback(
|
|
8961
9045
|
(newColor) => {
|
|
8962
9046
|
const newHsv = rgbToHsv(newColor);
|
|
8963
9047
|
store.setColor(newColor);
|
|
@@ -9039,7 +9123,7 @@ function HexInput(props) {
|
|
|
9039
9123
|
} = props;
|
|
9040
9124
|
const hexValue = rgbToHex(color);
|
|
9041
9125
|
const alphaValue = Math.round((color?.a ?? 1) * 100);
|
|
9042
|
-
const onHexChange =
|
|
9126
|
+
const onHexChange = React21__namespace.useCallback(
|
|
9043
9127
|
(event) => {
|
|
9044
9128
|
const value = event.target.value;
|
|
9045
9129
|
const parsedColor = parseColorString(value);
|
|
@@ -9049,7 +9133,7 @@ function HexInput(props) {
|
|
|
9049
9133
|
},
|
|
9050
9134
|
[color, onColorChange]
|
|
9051
9135
|
);
|
|
9052
|
-
const onAlphaChange =
|
|
9136
|
+
const onAlphaChange = React21__namespace.useCallback(
|
|
9053
9137
|
(event) => {
|
|
9054
9138
|
const value = Number.parseInt(event.target.value, 10);
|
|
9055
9139
|
if (!Number.isNaN(value) && value >= 0 && value <= 100) {
|
|
@@ -9126,7 +9210,7 @@ function RgbInput(props) {
|
|
|
9126
9210
|
const gValue = Math.round(color?.g ?? 0);
|
|
9127
9211
|
const bValue = Math.round(color?.b ?? 0);
|
|
9128
9212
|
const alphaValue = Math.round((color?.a ?? 1) * 100);
|
|
9129
|
-
const onChannelChange =
|
|
9213
|
+
const onChannelChange = React21__namespace.useCallback(
|
|
9130
9214
|
(channel, max, isAlpha = false) => (event) => {
|
|
9131
9215
|
const value = Number.parseInt(event.target.value, 10);
|
|
9132
9216
|
if (!Number.isNaN(value) && value >= 0 && value <= max) {
|
|
@@ -9223,9 +9307,9 @@ function HslInput(props) {
|
|
|
9223
9307
|
className,
|
|
9224
9308
|
...inputProps
|
|
9225
9309
|
} = props;
|
|
9226
|
-
const hsl =
|
|
9310
|
+
const hsl = React21__namespace.useMemo(() => rgbToHsl(color), [color]);
|
|
9227
9311
|
const alphaValue = Math.round((color?.a ?? 1) * 100);
|
|
9228
|
-
const onHslChannelChange =
|
|
9312
|
+
const onHslChannelChange = React21__namespace.useCallback(
|
|
9229
9313
|
(channel, max) => (event) => {
|
|
9230
9314
|
const value = Number.parseInt(event.target.value, 10);
|
|
9231
9315
|
if (!Number.isNaN(value) && value >= 0 && value <= max) {
|
|
@@ -9236,7 +9320,7 @@ function HslInput(props) {
|
|
|
9236
9320
|
},
|
|
9237
9321
|
[hsl, color, onColorChange]
|
|
9238
9322
|
);
|
|
9239
|
-
const onAlphaChange =
|
|
9323
|
+
const onAlphaChange = React21__namespace.useCallback(
|
|
9240
9324
|
(event) => {
|
|
9241
9325
|
const value = Number.parseInt(event.target.value, 10);
|
|
9242
9326
|
if (!Number.isNaN(value) && value >= 0 && value <= 100) {
|
|
@@ -9333,7 +9417,7 @@ function HsbInput(props) {
|
|
|
9333
9417
|
...inputProps
|
|
9334
9418
|
} = props;
|
|
9335
9419
|
const alphaValue = Math.round((hsv?.a ?? 1) * 100);
|
|
9336
|
-
const onHsvChannelChange =
|
|
9420
|
+
const onHsvChannelChange = React21__namespace.useCallback(
|
|
9337
9421
|
(channel, max) => (event) => {
|
|
9338
9422
|
const value = Number.parseInt(event.target.value, 10);
|
|
9339
9423
|
if (!Number.isNaN(value) && value >= 0 && value <= max) {
|
|
@@ -9344,7 +9428,7 @@ function HsbInput(props) {
|
|
|
9344
9428
|
},
|
|
9345
9429
|
[hsv, onColorChange]
|
|
9346
9430
|
);
|
|
9347
|
-
const onAlphaChange =
|
|
9431
|
+
const onAlphaChange = React21__namespace.useCallback(
|
|
9348
9432
|
(event) => {
|
|
9349
9433
|
const value = Number.parseInt(event.target.value, 10);
|
|
9350
9434
|
if (!Number.isNaN(value) && value >= 0 && value <= 100) {
|
|
@@ -9437,7 +9521,7 @@ function ColorPickerPresets(props) {
|
|
|
9437
9521
|
const context = useColorPickerContext("ColorPickerPresets");
|
|
9438
9522
|
const store = useColorPickerStoreContext("ColorPickerPresets");
|
|
9439
9523
|
const color = useColorPickerStore((state) => state.color);
|
|
9440
|
-
const onPresetClick =
|
|
9524
|
+
const onPresetClick = React21__namespace.useCallback(
|
|
9441
9525
|
(hex, alpha) => {
|
|
9442
9526
|
const nextAlpha = alpha ?? (color?.a ?? 1);
|
|
9443
9527
|
const newColor = hexToRgb(hex, nextAlpha);
|
|
@@ -9498,14 +9582,14 @@ var init_color_picker = __esm({
|
|
|
9498
9582
|
// --muted in light theme is #F5F5F5, /50 -> alpha 0.5
|
|
9499
9583
|
{ label: "bg-muted/50", value: "#F5F5F5", alpha: 0.5 }
|
|
9500
9584
|
];
|
|
9501
|
-
DirectionContext =
|
|
9502
|
-
ColorPickerStoreContext =
|
|
9585
|
+
DirectionContext = React21__namespace.createContext(void 0);
|
|
9586
|
+
ColorPickerStoreContext = React21__namespace.createContext(
|
|
9503
9587
|
null
|
|
9504
9588
|
);
|
|
9505
|
-
ColorPickerContext =
|
|
9589
|
+
ColorPickerContext = React21__namespace.createContext(
|
|
9506
9590
|
null
|
|
9507
9591
|
);
|
|
9508
|
-
ColorPickerRoot =
|
|
9592
|
+
ColorPickerRoot = React21__namespace.memo(function ColorPickerRoot2(props) {
|
|
9509
9593
|
const {
|
|
9510
9594
|
value: valueProp,
|
|
9511
9595
|
defaultValue = "#000000",
|
|
@@ -9523,7 +9607,7 @@ var init_color_picker = __esm({
|
|
|
9523
9607
|
required,
|
|
9524
9608
|
...rootProps
|
|
9525
9609
|
} = props;
|
|
9526
|
-
const initialColor =
|
|
9610
|
+
const initialColor = React21__namespace.useMemo(() => {
|
|
9527
9611
|
const colorString = valueProp ?? defaultValue;
|
|
9528
9612
|
const color = parseColorString(colorString) ?? hexToRgb(defaultValue);
|
|
9529
9613
|
return {
|
|
@@ -9542,7 +9626,7 @@ var init_color_picker = __esm({
|
|
|
9542
9626
|
]);
|
|
9543
9627
|
const stateRef = useLazyRef(() => initialColor);
|
|
9544
9628
|
const listenersRef = useLazyRef(() => /* @__PURE__ */ new Set());
|
|
9545
|
-
const storeCallbacks =
|
|
9629
|
+
const storeCallbacks = React21__namespace.useMemo(
|
|
9546
9630
|
() => ({
|
|
9547
9631
|
onColorChange: onValueChange,
|
|
9548
9632
|
onOpenChange,
|
|
@@ -9550,7 +9634,7 @@ var init_color_picker = __esm({
|
|
|
9550
9634
|
}),
|
|
9551
9635
|
[onValueChange, onOpenChange, onFormatChange]
|
|
9552
9636
|
);
|
|
9553
|
-
const store =
|
|
9637
|
+
const store = React21__namespace.useMemo(
|
|
9554
9638
|
() => createColorPickerStore(listenersRef, stateRef, storeCallbacks),
|
|
9555
9639
|
[listenersRef, stateRef, storeCallbacks]
|
|
9556
9640
|
);
|
|
@@ -9579,38 +9663,48 @@ function InsertLayoutDialog({
|
|
|
9579
9663
|
submitLabel = "Insert",
|
|
9580
9664
|
onSubmit
|
|
9581
9665
|
}) {
|
|
9582
|
-
const [layout, setLayout] =
|
|
9583
|
-
const [backgroundColor, setBackgroundColor] =
|
|
9666
|
+
const [layout, setLayout] = React21.useState(initialValues?.template ?? (LAYOUTS[0]?.value || "1fr"));
|
|
9667
|
+
const [backgroundColor, setBackgroundColor] = React21.useState(
|
|
9584
9668
|
initialValues?.itemBackgroundColor ?? "#ffffff"
|
|
9585
9669
|
);
|
|
9586
|
-
const [
|
|
9587
|
-
const [
|
|
9670
|
+
const [paddingXPx, setPaddingXPx] = React21.useState(initialValues?.itemPaddingXPx ?? 12);
|
|
9671
|
+
const [paddingYPx, setPaddingYPx] = React21.useState(initialValues?.itemPaddingYPx ?? 12);
|
|
9672
|
+
const [borderRadiusPx, setBorderRadiusPx] = React21.useState(
|
|
9588
9673
|
initialValues?.itemBorderRadiusPx ?? 8
|
|
9589
9674
|
);
|
|
9590
|
-
const layoutRef =
|
|
9591
|
-
const backgroundColorRef =
|
|
9592
|
-
const
|
|
9593
|
-
const
|
|
9594
|
-
|
|
9675
|
+
const layoutRef = React21.useRef(layout);
|
|
9676
|
+
const backgroundColorRef = React21.useRef(backgroundColor);
|
|
9677
|
+
const paddingXPxRef = React21.useRef(paddingXPx);
|
|
9678
|
+
const paddingYPxRef = React21.useRef(paddingYPx);
|
|
9679
|
+
const borderRadiusPxRef = React21.useRef(borderRadiusPx);
|
|
9680
|
+
React21.useEffect(() => {
|
|
9595
9681
|
layoutRef.current = layout;
|
|
9596
9682
|
}, [layout]);
|
|
9597
|
-
|
|
9683
|
+
React21.useEffect(() => {
|
|
9598
9684
|
backgroundColorRef.current = backgroundColor;
|
|
9599
9685
|
}, [backgroundColor]);
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
}, [
|
|
9603
|
-
|
|
9686
|
+
React21.useEffect(() => {
|
|
9687
|
+
paddingXPxRef.current = paddingXPx;
|
|
9688
|
+
}, [paddingXPx]);
|
|
9689
|
+
React21.useEffect(() => {
|
|
9690
|
+
paddingYPxRef.current = paddingYPx;
|
|
9691
|
+
}, [paddingYPx]);
|
|
9692
|
+
React21.useEffect(() => {
|
|
9604
9693
|
borderRadiusPxRef.current = borderRadiusPx;
|
|
9605
9694
|
}, [borderRadiusPx]);
|
|
9606
9695
|
const onBackgroundColorChange = (value) => {
|
|
9607
9696
|
backgroundColorRef.current = value;
|
|
9608
9697
|
setBackgroundColor(value);
|
|
9609
9698
|
};
|
|
9610
|
-
const
|
|
9699
|
+
const onPaddingXChange = (next) => {
|
|
9700
|
+
const value = Math.min(Math.max(next, 0), 64);
|
|
9701
|
+
paddingXPxRef.current = value;
|
|
9702
|
+
setPaddingXPx(value);
|
|
9703
|
+
};
|
|
9704
|
+
const onPaddingYChange = (next) => {
|
|
9611
9705
|
const value = Math.min(Math.max(next, 0), 64);
|
|
9612
|
-
|
|
9613
|
-
|
|
9706
|
+
paddingYPxRef.current = value;
|
|
9707
|
+
setPaddingYPx(value);
|
|
9614
9708
|
};
|
|
9615
9709
|
const onBorderRadiusChange = (next) => {
|
|
9616
9710
|
const value = Math.min(Math.max(next, 0), 64);
|
|
@@ -9622,7 +9716,8 @@ function InsertLayoutDialog({
|
|
|
9622
9716
|
const values = {
|
|
9623
9717
|
template: layoutRef.current,
|
|
9624
9718
|
itemBackgroundColor: backgroundColorRef.current,
|
|
9625
|
-
|
|
9719
|
+
itemPaddingXPx: paddingXPxRef.current,
|
|
9720
|
+
itemPaddingYPx: paddingYPxRef.current,
|
|
9626
9721
|
itemBorderRadiusPx: borderRadiusPxRef.current
|
|
9627
9722
|
};
|
|
9628
9723
|
logger.info("[Layout] Submit dialog values", {
|
|
@@ -9637,13 +9732,13 @@ function InsertLayoutDialog({
|
|
|
9637
9732
|
activeEditor.dispatchCommand(INSERT_LAYOUT_COMMAND, values);
|
|
9638
9733
|
onClose();
|
|
9639
9734
|
};
|
|
9640
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9735
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Flex, { direction: "column", gap: 4, children: [
|
|
9641
9736
|
/* @__PURE__ */ jsxRuntime.jsxs(Select, { onValueChange: setLayout, value: layout, children: [
|
|
9642
9737
|
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "editor-input-lg editor-w-full", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: buttonLabel }) }),
|
|
9643
9738
|
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { className: "editor-w-full", children: LAYOUTS.map(({ label, value }) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value, children: label }, value)) })
|
|
9644
9739
|
] }),
|
|
9645
9740
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "editor-layout-dialog-grid", children: [
|
|
9646
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9741
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Flex, { direction: "column", gap: 1.5, children: [
|
|
9647
9742
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-text-xs-muted", children: "Background" }),
|
|
9648
9743
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9649
9744
|
ColorPickerRoot,
|
|
@@ -9689,47 +9784,39 @@ function InsertLayoutDialog({
|
|
|
9689
9784
|
}
|
|
9690
9785
|
)
|
|
9691
9786
|
] }),
|
|
9692
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9693
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-text-xs-muted", children: "Padding (px)" }),
|
|
9787
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Flex, { direction: "column", gap: 1.5, children: [
|
|
9788
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-text-xs-muted", children: "Padding X (px)" }),
|
|
9694
9789
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9695
|
-
|
|
9790
|
+
NumberInput,
|
|
9696
9791
|
{
|
|
9697
|
-
type: "number",
|
|
9698
9792
|
min: 0,
|
|
9699
9793
|
max: 64,
|
|
9700
|
-
|
|
9701
|
-
|
|
9702
|
-
onChange: (event) => {
|
|
9703
|
-
const next = Number.parseInt(event.target.value, 10);
|
|
9704
|
-
if (Number.isFinite(next)) {
|
|
9705
|
-
onPaddingChange(next);
|
|
9706
|
-
} else {
|
|
9707
|
-
onPaddingChange(0);
|
|
9708
|
-
}
|
|
9709
|
-
},
|
|
9710
|
-
className: "editor-input-lg editor-w-full"
|
|
9794
|
+
value: paddingXPx,
|
|
9795
|
+
onValueChange: onPaddingXChange
|
|
9711
9796
|
}
|
|
9712
9797
|
)
|
|
9713
9798
|
] }),
|
|
9714
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9799
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Flex, { direction: "column", gap: 1.5, children: [
|
|
9800
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-text-xs-muted", children: "Padding Y (px)" }),
|
|
9801
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9802
|
+
NumberInput,
|
|
9803
|
+
{
|
|
9804
|
+
min: 0,
|
|
9805
|
+
max: 64,
|
|
9806
|
+
value: paddingYPx,
|
|
9807
|
+
onValueChange: onPaddingYChange
|
|
9808
|
+
}
|
|
9809
|
+
)
|
|
9810
|
+
] }),
|
|
9811
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Flex, { direction: "column", gap: 1.5, children: [
|
|
9715
9812
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-text-xs-muted", children: "Border radius (px)" }),
|
|
9716
9813
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9717
|
-
|
|
9814
|
+
NumberInput,
|
|
9718
9815
|
{
|
|
9719
|
-
type: "number",
|
|
9720
9816
|
min: 0,
|
|
9721
9817
|
max: 64,
|
|
9722
|
-
step: 1,
|
|
9723
9818
|
value: borderRadiusPx,
|
|
9724
|
-
|
|
9725
|
-
const next = Number.parseInt(event.target.value, 10);
|
|
9726
|
-
if (Number.isFinite(next)) {
|
|
9727
|
-
onBorderRadiusChange(next);
|
|
9728
|
-
} else {
|
|
9729
|
-
onBorderRadiusChange(0);
|
|
9730
|
-
}
|
|
9731
|
-
},
|
|
9732
|
-
className: "editor-input-lg editor-w-full"
|
|
9819
|
+
onValueChange: onBorderRadiusChange
|
|
9733
9820
|
}
|
|
9734
9821
|
)
|
|
9735
9822
|
] })
|
|
@@ -9740,7 +9827,7 @@ function InsertLayoutDialog({
|
|
|
9740
9827
|
function LayoutPlugin() {
|
|
9741
9828
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
9742
9829
|
const [modal, showModal] = useEditorModal();
|
|
9743
|
-
|
|
9830
|
+
React21.useEffect(() => {
|
|
9744
9831
|
if (!editor.hasNodes([LayoutContainerNode, LayoutItemNode])) {
|
|
9745
9832
|
throw new Error(
|
|
9746
9833
|
"LayoutPlugin: LayoutContainerNode, or LayoutItemNode not registered on editor"
|
|
@@ -9780,23 +9867,32 @@ function LayoutPlugin() {
|
|
|
9780
9867
|
if (!value) {
|
|
9781
9868
|
return void 0;
|
|
9782
9869
|
}
|
|
9783
|
-
const
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
|
|
9788
|
-
|
|
9870
|
+
const values = value.replace(/!important/gi, "").trim().split(/\s+/);
|
|
9871
|
+
const parsedValues = values.map((v) => {
|
|
9872
|
+
const match = v.match(/^(\d+)px/i);
|
|
9873
|
+
if (!match?.[1]) return null;
|
|
9874
|
+
const parsed = Number.parseInt(match[1], 10);
|
|
9875
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
9876
|
+
}).filter((v) => v !== null);
|
|
9877
|
+
if (parsedValues.length === 0) return void 0;
|
|
9878
|
+
return parsedValues;
|
|
9789
9879
|
};
|
|
9790
9880
|
const buildLayoutItemStyle = ({
|
|
9791
9881
|
itemBackgroundColor,
|
|
9792
|
-
|
|
9882
|
+
itemPaddingXPx,
|
|
9883
|
+
itemPaddingYPx,
|
|
9793
9884
|
itemBorderRadiusPx
|
|
9794
9885
|
}) => {
|
|
9795
9886
|
const itemStyles = [];
|
|
9796
9887
|
if (itemBackgroundColor.trim()) {
|
|
9797
9888
|
itemStyles.push(`background-color: ${itemBackgroundColor.trim()}`);
|
|
9798
9889
|
}
|
|
9799
|
-
itemStyles.push(
|
|
9890
|
+
itemStyles.push(
|
|
9891
|
+
`padding: ${Math.min(Math.max(itemPaddingYPx, 0), 64)}px ${Math.min(
|
|
9892
|
+
Math.max(itemPaddingXPx, 0),
|
|
9893
|
+
64
|
|
9894
|
+
)}px`
|
|
9895
|
+
);
|
|
9800
9896
|
itemStyles.push(
|
|
9801
9897
|
`border-radius: ${Math.min(Math.max(itemBorderRadiusPx, 0), 64)}px`
|
|
9802
9898
|
);
|
|
@@ -9809,7 +9905,10 @@ function LayoutPlugin() {
|
|
|
9809
9905
|
return;
|
|
9810
9906
|
}
|
|
9811
9907
|
const background = values.itemBackgroundColor.trim();
|
|
9812
|
-
const padding = `${Math.min(Math.max(values.
|
|
9908
|
+
const padding = `${Math.min(Math.max(values.itemPaddingYPx, 0), 64)}px ${Math.min(
|
|
9909
|
+
Math.max(values.itemPaddingXPx, 0),
|
|
9910
|
+
64
|
|
9911
|
+
)}px`;
|
|
9813
9912
|
const borderRadius = `${Math.min(Math.max(values.itemBorderRadiusPx, 0), 64)}px`;
|
|
9814
9913
|
if (background) {
|
|
9815
9914
|
element.style.setProperty("background-color", background);
|
|
@@ -9860,14 +9959,17 @@ function LayoutPlugin() {
|
|
|
9860
9959
|
return;
|
|
9861
9960
|
}
|
|
9862
9961
|
const style = layoutItem.getStyle();
|
|
9962
|
+
const paddingValues = extractNumericStyle(style, "padding");
|
|
9963
|
+
const borderRadiusValues = extractNumericStyle(style, "border-radius");
|
|
9863
9964
|
payload = {
|
|
9864
9965
|
containerKey: parentContainer.getKey(),
|
|
9865
9966
|
layoutItemKey: layoutItem.getKey(),
|
|
9866
9967
|
values: {
|
|
9867
9968
|
template: parentContainer.getTemplateColumns(),
|
|
9868
9969
|
itemBackgroundColor: extractStyleValue(style, "background-color") ?? "#ffffff",
|
|
9869
|
-
|
|
9870
|
-
|
|
9970
|
+
itemPaddingXPx: paddingValues?.[1] ?? paddingValues?.[0] ?? 12,
|
|
9971
|
+
itemPaddingYPx: paddingValues?.[0] ?? 12,
|
|
9972
|
+
itemBorderRadiusPx: borderRadiusValues?.[0] ?? 8
|
|
9871
9973
|
}
|
|
9872
9974
|
};
|
|
9873
9975
|
logger.debug("[Layout] Resolved payload from target", payload);
|
|
@@ -9980,11 +10082,13 @@ function LayoutPlugin() {
|
|
|
9980
10082
|
editor.update(() => {
|
|
9981
10083
|
const template = typeof payload === "string" ? payload : payload.template;
|
|
9982
10084
|
const itemBackgroundColor = typeof payload === "string" ? void 0 : payload.itemBackgroundColor?.trim();
|
|
9983
|
-
const
|
|
10085
|
+
const itemPaddingXPx = typeof payload === "string" ? void 0 : typeof payload.itemPaddingXPx === "number" && Number.isFinite(payload.itemPaddingXPx) ? Math.min(Math.max(payload.itemPaddingXPx, 0), 64) : void 0;
|
|
10086
|
+
const itemPaddingYPx = typeof payload === "string" ? void 0 : typeof payload.itemPaddingYPx === "number" && Number.isFinite(payload.itemPaddingYPx) ? Math.min(Math.max(payload.itemPaddingYPx, 0), 64) : void 0;
|
|
9984
10087
|
const itemBorderRadiusPx = typeof payload === "string" ? void 0 : typeof payload.itemBorderRadiusPx === "number" && Number.isFinite(payload.itemBorderRadiusPx) ? Math.min(Math.max(payload.itemBorderRadiusPx, 0), 64) : void 0;
|
|
9985
10088
|
const itemStyle = buildLayoutItemStyle({
|
|
9986
10089
|
itemBackgroundColor: itemBackgroundColor ?? "#ffffff",
|
|
9987
|
-
|
|
10090
|
+
itemPaddingXPx: itemPaddingXPx ?? 12,
|
|
10091
|
+
itemPaddingYPx: itemPaddingYPx ?? 12,
|
|
9988
10092
|
itemBorderRadiusPx: itemBorderRadiusPx ?? 8
|
|
9989
10093
|
});
|
|
9990
10094
|
const container = $createLayoutContainerNode(template);
|
|
@@ -10055,9 +10159,9 @@ var init_layout_plugin = __esm({
|
|
|
10055
10159
|
init_layout_container_node();
|
|
10056
10160
|
init_layout_item_node();
|
|
10057
10161
|
init_button();
|
|
10162
|
+
init_number_input();
|
|
10058
10163
|
init_select();
|
|
10059
10164
|
init_color_picker();
|
|
10060
|
-
init_input();
|
|
10061
10165
|
init_flex();
|
|
10062
10166
|
init_use_modal();
|
|
10063
10167
|
init_logger();
|
|
@@ -10094,7 +10198,7 @@ function applyListColor(editor) {
|
|
|
10094
10198
|
function ListColorPlugin() {
|
|
10095
10199
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
10096
10200
|
const [modal, showModal] = useEditorModal();
|
|
10097
|
-
|
|
10201
|
+
React21__namespace.useEffect(() => {
|
|
10098
10202
|
const applyColor = (color, listKey) => {
|
|
10099
10203
|
listColorStore.set(listKey, color);
|
|
10100
10204
|
editor.update(() => {
|
|
@@ -10140,7 +10244,7 @@ function ListColorPlugin() {
|
|
|
10140
10244
|
const fromAttr = listEl.getAttribute("data-list-color");
|
|
10141
10245
|
const initialColor = fromStore || fromVar || fromAttr || "#000000";
|
|
10142
10246
|
function ListColorModalContent({ onClose }) {
|
|
10143
|
-
const [color, setColor] =
|
|
10247
|
+
const [color, setColor] = React21__namespace.useState(initialColor);
|
|
10144
10248
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-list-color-dialog", children: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { direction: "column", gap: 4, children: [
|
|
10145
10249
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-text-xs-muted", children: "Ch\u1ECDn m\xE0u cho bullet ho\u1EB7c s\u1ED1 th\u1EE9 t\u1EF1 c\u1EE7a list." }),
|
|
10146
10250
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -10194,9 +10298,9 @@ var init_list_color_plugin = __esm({
|
|
|
10194
10298
|
});
|
|
10195
10299
|
function ContextMenuPlugin() {
|
|
10196
10300
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
10197
|
-
const [contextTarget, setContextTarget] =
|
|
10198
|
-
const [showMarkerDialog, setShowMarkerDialog] =
|
|
10199
|
-
const [customMarker, setCustomMarker] =
|
|
10301
|
+
const [contextTarget, setContextTarget] = React21.useState(null);
|
|
10302
|
+
const [showMarkerDialog, setShowMarkerDialog] = React21.useState(false);
|
|
10303
|
+
const [customMarker, setCustomMarker] = React21.useState("");
|
|
10200
10304
|
const isInTable = (node) => utils.$findMatchingParent(node, table.$isTableCellNode) !== null;
|
|
10201
10305
|
const isMergedCell = (node) => {
|
|
10202
10306
|
const cell = utils.$findMatchingParent(node, table.$isTableCellNode);
|
|
@@ -10212,7 +10316,7 @@ function ContextMenuPlugin() {
|
|
|
10212
10316
|
const listNode = utils.$findMatchingParent(node, list.$isListNode);
|
|
10213
10317
|
return list.$isListNode(listNode) && listNode.getListType() === "number";
|
|
10214
10318
|
};
|
|
10215
|
-
|
|
10319
|
+
React21.useEffect(() => {
|
|
10216
10320
|
const rootElement = editor.getRootElement();
|
|
10217
10321
|
if (!rootElement) return;
|
|
10218
10322
|
const onContextMenu = (event) => {
|
|
@@ -10225,7 +10329,7 @@ function ContextMenuPlugin() {
|
|
|
10225
10329
|
rootElement.removeEventListener("contextmenu", onContextMenu);
|
|
10226
10330
|
};
|
|
10227
10331
|
}, [editor]);
|
|
10228
|
-
const getContextAnchorNode =
|
|
10332
|
+
const getContextAnchorNode = React21.useCallback(() => {
|
|
10229
10333
|
if (contextTarget) {
|
|
10230
10334
|
const nearestNode = lexical.$getNearestNodeFromDOMNode(contextTarget);
|
|
10231
10335
|
if (nearestNode) return nearestNode;
|
|
@@ -10236,7 +10340,7 @@ function ContextMenuPlugin() {
|
|
|
10236
10340
|
}
|
|
10237
10341
|
return null;
|
|
10238
10342
|
}, [contextTarget]);
|
|
10239
|
-
const updateNumberListMarkerType =
|
|
10343
|
+
const updateNumberListMarkerType = React21.useCallback((markerType) => {
|
|
10240
10344
|
editor.update(() => {
|
|
10241
10345
|
const anchorNode = getContextAnchorNode();
|
|
10242
10346
|
if (!anchorNode) return;
|
|
@@ -10270,7 +10374,7 @@ function ContextMenuPlugin() {
|
|
|
10270
10374
|
listNode.replace(newList);
|
|
10271
10375
|
});
|
|
10272
10376
|
}, [editor, getContextAnchorNode]);
|
|
10273
|
-
const syncMarkerToSameLevelLists =
|
|
10377
|
+
const syncMarkerToSameLevelLists = React21.useCallback((targetListNode, markerType) => {
|
|
10274
10378
|
editor.update(() => {
|
|
10275
10379
|
const parent = targetListNode.getParent();
|
|
10276
10380
|
if (!parent) return;
|
|
@@ -10307,7 +10411,7 @@ function ContextMenuPlugin() {
|
|
|
10307
10411
|
setCustomMarker("");
|
|
10308
10412
|
}
|
|
10309
10413
|
};
|
|
10310
|
-
const items =
|
|
10414
|
+
const items = React21.useMemo(() => {
|
|
10311
10415
|
return [
|
|
10312
10416
|
new LexicalNodeContextMenuPlugin.NodeContextMenuOption(`G\u1ED9p \xF4`, {
|
|
10313
10417
|
$onSelect: () => {
|
|
@@ -10661,7 +10765,7 @@ var init_context_menu_plugin = __esm({
|
|
|
10661
10765
|
});
|
|
10662
10766
|
function DragDropPastePlugin() {
|
|
10663
10767
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
10664
|
-
|
|
10768
|
+
React21.useEffect(() => {
|
|
10665
10769
|
return editor.registerCommand(
|
|
10666
10770
|
richText.DRAG_DROP_PASTE,
|
|
10667
10771
|
(files) => {
|
|
@@ -10706,8 +10810,8 @@ function isOnMenu(element) {
|
|
|
10706
10810
|
function DraggableBlockPlugin({
|
|
10707
10811
|
anchorElem
|
|
10708
10812
|
}) {
|
|
10709
|
-
const menuRef =
|
|
10710
|
-
const targetLineRef =
|
|
10813
|
+
const menuRef = React21.useRef(null);
|
|
10814
|
+
const targetLineRef = React21.useRef(null);
|
|
10711
10815
|
if (!anchorElem) {
|
|
10712
10816
|
return null;
|
|
10713
10817
|
}
|
|
@@ -10746,7 +10850,7 @@ var init_draggable_block_plugin = __esm({
|
|
|
10746
10850
|
});
|
|
10747
10851
|
function TwitterPlugin() {
|
|
10748
10852
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
10749
|
-
|
|
10853
|
+
React21.useEffect(() => {
|
|
10750
10854
|
if (!editor.hasNodes([TweetNode])) {
|
|
10751
10855
|
throw new Error("TwitterPlugin: TweetNode not registered on editor");
|
|
10752
10856
|
}
|
|
@@ -10774,7 +10878,7 @@ var init_twitter_plugin = __esm({
|
|
|
10774
10878
|
});
|
|
10775
10879
|
function YouTubePlugin() {
|
|
10776
10880
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
10777
|
-
|
|
10881
|
+
React21.useEffect(() => {
|
|
10778
10882
|
if (!editor.hasNodes([YouTubeNode])) {
|
|
10779
10883
|
throw new Error("YouTubePlugin: YouTubeNode not registered on editor");
|
|
10780
10884
|
}
|
|
@@ -10831,9 +10935,9 @@ function AutoEmbedDialogContent({
|
|
|
10831
10935
|
onClose,
|
|
10832
10936
|
editor
|
|
10833
10937
|
}) {
|
|
10834
|
-
const [text, setText] =
|
|
10835
|
-
const [embedResult, setEmbedResult] =
|
|
10836
|
-
const validateText =
|
|
10938
|
+
const [text, setText] = React21.useState("");
|
|
10939
|
+
const [embedResult, setEmbedResult] = React21.useState(null);
|
|
10940
|
+
const validateText = React21.useMemo(
|
|
10837
10941
|
() => debounce2((inputText) => {
|
|
10838
10942
|
const urlMatch = LexicalAutoEmbedPlugin.URL_MATCHER.exec(inputText);
|
|
10839
10943
|
if (embedConfig != null && inputText != null && urlMatch != null) {
|
|
@@ -27655,13 +27759,13 @@ var init_emoji_list = __esm({
|
|
|
27655
27759
|
});
|
|
27656
27760
|
function EmojiPickerPlugin() {
|
|
27657
27761
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
27658
|
-
const [queryString, setQueryString] =
|
|
27659
|
-
const [emojis2, setEmojis] =
|
|
27660
|
-
const [, setIsOpen] =
|
|
27661
|
-
|
|
27762
|
+
const [queryString, setQueryString] = React21.useState(null);
|
|
27763
|
+
const [emojis2, setEmojis] = React21.useState([]);
|
|
27764
|
+
const [, setIsOpen] = React21.useState(false);
|
|
27765
|
+
React21.useEffect(() => {
|
|
27662
27766
|
Promise.resolve().then(() => (init_emoji_list(), emoji_list_exports)).then((file) => setEmojis(file.default));
|
|
27663
27767
|
}, []);
|
|
27664
|
-
const emojiOptions =
|
|
27768
|
+
const emojiOptions = React21.useMemo(
|
|
27665
27769
|
() => emojis2 != null ? emojis2.map(
|
|
27666
27770
|
({ emoji, aliases, tags }) => new EmojiOption(aliases[0] || "emoji", emoji, {
|
|
27667
27771
|
keywords: [...aliases, ...tags]
|
|
@@ -27672,14 +27776,14 @@ function EmojiPickerPlugin() {
|
|
|
27672
27776
|
const checkForTriggerMatch = LexicalTypeaheadMenuPlugin$1.useBasicTypeaheadTriggerMatch(":", {
|
|
27673
27777
|
minLength: 0
|
|
27674
27778
|
});
|
|
27675
|
-
const options =
|
|
27779
|
+
const options = React21.useMemo(() => {
|
|
27676
27780
|
return emojiOptions.filter((option) => {
|
|
27677
27781
|
return queryString != null ? new RegExp(queryString, "gi").exec(option.title) || option.keywords != null ? option.keywords.some(
|
|
27678
27782
|
(keyword) => new RegExp(queryString, "gi").exec(keyword)
|
|
27679
27783
|
) : false : emojiOptions;
|
|
27680
27784
|
}).slice(0, MAX_EMOJI_SUGGESTION_COUNT);
|
|
27681
27785
|
}, [emojiOptions, queryString]);
|
|
27682
|
-
const onSelectOption =
|
|
27786
|
+
const onSelectOption = React21.useCallback(
|
|
27683
27787
|
(selectedOption, nodeToRemove, closeMenu) => {
|
|
27684
27788
|
editor.update(() => {
|
|
27685
27789
|
const selection = lexical.$getSelection();
|
|
@@ -27810,7 +27914,7 @@ function $textNodeTransform(node) {
|
|
|
27810
27914
|
}
|
|
27811
27915
|
}
|
|
27812
27916
|
function useEmojis(editor) {
|
|
27813
|
-
|
|
27917
|
+
React21.useEffect(() => {
|
|
27814
27918
|
if (!editor.hasNodes([EmojiNode])) {
|
|
27815
27919
|
throw new Error("EmojisPlugin: EmojiNode not registered on editor");
|
|
27816
27920
|
}
|
|
@@ -27928,12 +28032,12 @@ function FloatingLinkEditor({
|
|
|
27928
28032
|
isLinkEditMode,
|
|
27929
28033
|
setIsLinkEditMode
|
|
27930
28034
|
}) {
|
|
27931
|
-
const editorRef =
|
|
27932
|
-
const inputRef =
|
|
27933
|
-
const [linkUrl, setLinkUrl] =
|
|
27934
|
-
const [editedLinkUrl, setEditedLinkUrl] =
|
|
27935
|
-
const [lastSelection, setLastSelection] =
|
|
27936
|
-
const $updateLinkEditor =
|
|
28035
|
+
const editorRef = React21.useRef(null);
|
|
28036
|
+
const inputRef = React21.useRef(null);
|
|
28037
|
+
const [linkUrl, setLinkUrl] = React21.useState("");
|
|
28038
|
+
const [editedLinkUrl, setEditedLinkUrl] = React21.useState("https://");
|
|
28039
|
+
const [lastSelection, setLastSelection] = React21.useState(null);
|
|
28040
|
+
const $updateLinkEditor = React21.useCallback(() => {
|
|
27937
28041
|
const selection = lexical.$getSelection();
|
|
27938
28042
|
let linkNode = null;
|
|
27939
28043
|
let selectedNode = null;
|
|
@@ -28058,7 +28162,7 @@ function FloatingLinkEditor({
|
|
|
28058
28162
|
}
|
|
28059
28163
|
return true;
|
|
28060
28164
|
}, [anchorElem, editor, setIsLinkEditMode, isLinkEditMode, linkUrl]);
|
|
28061
|
-
|
|
28165
|
+
React21.useEffect(() => {
|
|
28062
28166
|
const scrollerElem = anchorElem.parentElement;
|
|
28063
28167
|
const update = () => {
|
|
28064
28168
|
editor.getEditorState().read(() => {
|
|
@@ -28076,7 +28180,7 @@ function FloatingLinkEditor({
|
|
|
28076
28180
|
}
|
|
28077
28181
|
};
|
|
28078
28182
|
}, [anchorElem.parentElement, editor, $updateLinkEditor]);
|
|
28079
|
-
|
|
28183
|
+
React21.useEffect(() => {
|
|
28080
28184
|
return utils.mergeRegister(
|
|
28081
28185
|
editor.registerUpdateListener(({ editorState }) => {
|
|
28082
28186
|
editorState.read(() => {
|
|
@@ -28104,12 +28208,12 @@ function FloatingLinkEditor({
|
|
|
28104
28208
|
)
|
|
28105
28209
|
);
|
|
28106
28210
|
}, [editor, $updateLinkEditor, setIsLink, isLink]);
|
|
28107
|
-
|
|
28211
|
+
React21.useEffect(() => {
|
|
28108
28212
|
editor.getEditorState().read(() => {
|
|
28109
28213
|
$updateLinkEditor();
|
|
28110
28214
|
});
|
|
28111
28215
|
}, [editor, $updateLinkEditor]);
|
|
28112
|
-
|
|
28216
|
+
React21.useEffect(() => {
|
|
28113
28217
|
if (isLinkEditMode && inputRef.current) {
|
|
28114
28218
|
inputRef.current.focus();
|
|
28115
28219
|
setTimeout(() => {
|
|
@@ -28278,9 +28382,9 @@ function FloatingLinkEditor({
|
|
|
28278
28382
|
);
|
|
28279
28383
|
}
|
|
28280
28384
|
function useFloatingLinkEditorToolbar(editor, anchorElem, isLinkEditMode, setIsLinkEditMode) {
|
|
28281
|
-
const [activeEditor, setActiveEditor] =
|
|
28282
|
-
const [isLink, setIsLink] =
|
|
28283
|
-
|
|
28385
|
+
const [activeEditor, setActiveEditor] = React21.useState(editor);
|
|
28386
|
+
const [isLink, setIsLink] = React21.useState(false);
|
|
28387
|
+
React21.useEffect(() => {
|
|
28284
28388
|
function $updateToolbar() {
|
|
28285
28389
|
const selection = lexical.$getSelection();
|
|
28286
28390
|
if (lexical.$isRangeSelection(selection)) {
|
|
@@ -28596,10 +28700,10 @@ var ToggleGroupContext, ToggleGroup, ToggleGroupItem;
|
|
|
28596
28700
|
var init_toggle_group = __esm({
|
|
28597
28701
|
"src/ui/toggle-group.tsx"() {
|
|
28598
28702
|
init_utils();
|
|
28599
|
-
ToggleGroupContext =
|
|
28600
|
-
ToggleGroup =
|
|
28703
|
+
ToggleGroupContext = React21__namespace.createContext(null);
|
|
28704
|
+
ToggleGroup = React21__namespace.forwardRef(
|
|
28601
28705
|
({ className, type = "single", value, onValueChange, children, size, variant, ...props }, ref) => {
|
|
28602
|
-
const contextValue =
|
|
28706
|
+
const contextValue = React21__namespace.useMemo(() => ({
|
|
28603
28707
|
type,
|
|
28604
28708
|
value: value || (type === "multiple" ? [] : ""),
|
|
28605
28709
|
onValueChange: (val) => {
|
|
@@ -28616,8 +28720,8 @@ var init_toggle_group = __esm({
|
|
|
28616
28720
|
}
|
|
28617
28721
|
);
|
|
28618
28722
|
ToggleGroup.displayName = "ToggleGroup";
|
|
28619
|
-
ToggleGroupItem =
|
|
28620
|
-
const context =
|
|
28723
|
+
ToggleGroupItem = React21__namespace.forwardRef(({ className, value, onClick, size: itemSize, variant: itemVariant, ...props }, ref) => {
|
|
28724
|
+
const context = React21__namespace.useContext(ToggleGroupContext);
|
|
28621
28725
|
const size = itemSize || context?.size || "default";
|
|
28622
28726
|
if (!context) {
|
|
28623
28727
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -28672,7 +28776,7 @@ function FontColorModalContent({
|
|
|
28672
28776
|
onApply,
|
|
28673
28777
|
onClose
|
|
28674
28778
|
}) {
|
|
28675
|
-
const [color, setColor] =
|
|
28779
|
+
const [color, setColor] = React21.useState(initialColor);
|
|
28676
28780
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-list-color-dialog", children: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { direction: "column", gap: 4, children: [
|
|
28677
28781
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-text-xs-muted", children: "Ch\u1ECDn m\xE0u cho v\u0103n b\u1EA3n \u0111ang ch\u1ECDn." }),
|
|
28678
28782
|
/* @__PURE__ */ jsxRuntime.jsx(ColorPickerRoot, { inline: true, value: color, onValueChange: setColor, children: /* @__PURE__ */ jsxRuntime.jsxs(ColorPickerContent, { className: "editor-w-full editor-border-0 editor-shadow-none editor-p-0", children: [
|
|
@@ -28706,7 +28810,7 @@ function BgColorModalContent({
|
|
|
28706
28810
|
onApply,
|
|
28707
28811
|
onClose
|
|
28708
28812
|
}) {
|
|
28709
|
-
const [color, setColor] =
|
|
28813
|
+
const [color, setColor] = React21.useState(initialColor);
|
|
28710
28814
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-list-color-dialog", children: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { direction: "column", gap: 4, children: [
|
|
28711
28815
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-text-xs-muted", children: "Ch\u1ECDn m\xE0u n\u1EC1n cho v\u0103n b\u1EA3n \u0111ang ch\u1ECDn." }),
|
|
28712
28816
|
/* @__PURE__ */ jsxRuntime.jsx(ColorPickerRoot, { inline: true, value: color, onValueChange: setColor, children: /* @__PURE__ */ jsxRuntime.jsxs(ColorPickerContent, { className: "editor-w-full editor-border-0 editor-shadow-none editor-p-0", children: [
|
|
@@ -28752,8 +28856,8 @@ function FloatingTextFormat({
|
|
|
28752
28856
|
showModal,
|
|
28753
28857
|
isModalOpen
|
|
28754
28858
|
}) {
|
|
28755
|
-
const popupCharStylesEditorRef =
|
|
28756
|
-
const insertLink =
|
|
28859
|
+
const popupCharStylesEditorRef = React21.useRef(null);
|
|
28860
|
+
const insertLink = React21.useCallback(() => {
|
|
28757
28861
|
if (!isLink) {
|
|
28758
28862
|
setIsLinkEditMode(true);
|
|
28759
28863
|
editor.dispatchCommand(link.TOGGLE_LINK_COMMAND, "https://");
|
|
@@ -28762,7 +28866,7 @@ function FloatingTextFormat({
|
|
|
28762
28866
|
editor.dispatchCommand(link.TOGGLE_LINK_COMMAND, null);
|
|
28763
28867
|
}
|
|
28764
28868
|
}, [editor, isLink, setIsLinkEditMode]);
|
|
28765
|
-
const applyStyleText =
|
|
28869
|
+
const applyStyleText = React21.useCallback(
|
|
28766
28870
|
(styles) => {
|
|
28767
28871
|
editor.update(() => {
|
|
28768
28872
|
const selection$1 = lexical.$getSelection();
|
|
@@ -28773,7 +28877,7 @@ function FloatingTextFormat({
|
|
|
28773
28877
|
},
|
|
28774
28878
|
[editor]
|
|
28775
28879
|
);
|
|
28776
|
-
const onFontColorSelect =
|
|
28880
|
+
const onFontColorSelect = React21.useCallback(
|
|
28777
28881
|
(value) => {
|
|
28778
28882
|
if (value !== "inherit") {
|
|
28779
28883
|
applyStyleText({ color: value });
|
|
@@ -28781,7 +28885,7 @@ function FloatingTextFormat({
|
|
|
28781
28885
|
},
|
|
28782
28886
|
[applyStyleText]
|
|
28783
28887
|
);
|
|
28784
|
-
const onBgColorSelect =
|
|
28888
|
+
const onBgColorSelect = React21.useCallback(
|
|
28785
28889
|
(value) => {
|
|
28786
28890
|
if (value !== "inherit") {
|
|
28787
28891
|
applyStyleText({ "background-color": value });
|
|
@@ -28809,7 +28913,7 @@ function FloatingTextFormat({
|
|
|
28809
28913
|
}
|
|
28810
28914
|
));
|
|
28811
28915
|
};
|
|
28812
|
-
|
|
28916
|
+
React21.useEffect(() => {
|
|
28813
28917
|
function mouseMoveListener(e) {
|
|
28814
28918
|
if (popupCharStylesEditorRef?.current && (e.buttons === 1 || e.buttons === 3)) {
|
|
28815
28919
|
if (popupCharStylesEditorRef.current.style.pointerEvents !== "none") {
|
|
@@ -28838,7 +28942,7 @@ function FloatingTextFormat({
|
|
|
28838
28942
|
};
|
|
28839
28943
|
}
|
|
28840
28944
|
}, [popupCharStylesEditorRef, isModalOpen]);
|
|
28841
|
-
const $updateTextFormatFloatingToolbar =
|
|
28945
|
+
const $updateTextFormatFloatingToolbar = React21.useCallback(() => {
|
|
28842
28946
|
const selection = lexical.$getSelection();
|
|
28843
28947
|
const popupCharStylesEditorElem = popupCharStylesEditorRef.current;
|
|
28844
28948
|
const nativeSelection = window.getSelection();
|
|
@@ -28864,7 +28968,7 @@ function FloatingTextFormat({
|
|
|
28864
28968
|
);
|
|
28865
28969
|
}
|
|
28866
28970
|
}, [editor, anchorElem, isLink]);
|
|
28867
|
-
|
|
28971
|
+
React21.useEffect(() => {
|
|
28868
28972
|
const scrollerElem = anchorElem.parentElement;
|
|
28869
28973
|
const update = () => {
|
|
28870
28974
|
editor.getEditorState().read(() => {
|
|
@@ -28882,7 +28986,7 @@ function FloatingTextFormat({
|
|
|
28882
28986
|
}
|
|
28883
28987
|
};
|
|
28884
28988
|
}, [editor, $updateTextFormatFloatingToolbar, anchorElem]);
|
|
28885
|
-
|
|
28989
|
+
React21.useEffect(() => {
|
|
28886
28990
|
editor.getEditorState().read(() => {
|
|
28887
28991
|
$updateTextFormatFloatingToolbar();
|
|
28888
28992
|
});
|
|
@@ -29057,18 +29161,18 @@ function FloatingTextFormat({
|
|
|
29057
29161
|
);
|
|
29058
29162
|
}
|
|
29059
29163
|
function useFloatingTextFormatToolbar(editor, anchorElem, setIsLinkEditMode, showModal, isModalOpen) {
|
|
29060
|
-
const [isText, setIsText] =
|
|
29061
|
-
const [isLink, setIsLink] =
|
|
29062
|
-
const [isBold, setIsBold] =
|
|
29063
|
-
const [isItalic, setIsItalic] =
|
|
29064
|
-
const [isUnderline, setIsUnderline] =
|
|
29065
|
-
const [isStrikethrough, setIsStrikethrough] =
|
|
29066
|
-
const [isSubscript, setIsSubscript] =
|
|
29067
|
-
const [isSuperscript, setIsSuperscript] =
|
|
29068
|
-
const [isCode, setIsCode] =
|
|
29069
|
-
const [fontColor, setFontColor] =
|
|
29070
|
-
const [bgColor, setBgColor] =
|
|
29071
|
-
const updatePopup =
|
|
29164
|
+
const [isText, setIsText] = React21.useState(false);
|
|
29165
|
+
const [isLink, setIsLink] = React21.useState(false);
|
|
29166
|
+
const [isBold, setIsBold] = React21.useState(false);
|
|
29167
|
+
const [isItalic, setIsItalic] = React21.useState(false);
|
|
29168
|
+
const [isUnderline, setIsUnderline] = React21.useState(false);
|
|
29169
|
+
const [isStrikethrough, setIsStrikethrough] = React21.useState(false);
|
|
29170
|
+
const [isSubscript, setIsSubscript] = React21.useState(false);
|
|
29171
|
+
const [isSuperscript, setIsSuperscript] = React21.useState(false);
|
|
29172
|
+
const [isCode, setIsCode] = React21.useState(false);
|
|
29173
|
+
const [fontColor, setFontColor] = React21.useState("inherit");
|
|
29174
|
+
const [bgColor, setBgColor] = React21.useState("inherit");
|
|
29175
|
+
const updatePopup = React21.useCallback(() => {
|
|
29072
29176
|
editor.getEditorState().read(() => {
|
|
29073
29177
|
if (editor.isComposing()) {
|
|
29074
29178
|
return;
|
|
@@ -29113,13 +29217,13 @@ function useFloatingTextFormatToolbar(editor, anchorElem, setIsLinkEditMode, sho
|
|
|
29113
29217
|
}
|
|
29114
29218
|
});
|
|
29115
29219
|
}, [editor]);
|
|
29116
|
-
|
|
29220
|
+
React21.useEffect(() => {
|
|
29117
29221
|
document.addEventListener("selectionchange", updatePopup);
|
|
29118
29222
|
return () => {
|
|
29119
29223
|
document.removeEventListener("selectionchange", updatePopup);
|
|
29120
29224
|
};
|
|
29121
29225
|
}, [updatePopup]);
|
|
29122
|
-
|
|
29226
|
+
React21.useEffect(() => {
|
|
29123
29227
|
return utils.mergeRegister(
|
|
29124
29228
|
editor.registerUpdateListener(() => {
|
|
29125
29229
|
updatePopup();
|
|
@@ -29194,15 +29298,15 @@ var init_floating_text_format_plugin = __esm({
|
|
|
29194
29298
|
});
|
|
29195
29299
|
function KeywordsPlugin() {
|
|
29196
29300
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
29197
|
-
|
|
29301
|
+
React21.useEffect(() => {
|
|
29198
29302
|
if (!editor.hasNodes([KeywordNode])) {
|
|
29199
29303
|
throw new Error("KeywordsPlugin: KeywordNode not registered on editor");
|
|
29200
29304
|
}
|
|
29201
29305
|
}, [editor]);
|
|
29202
|
-
const $createKeywordNode_ =
|
|
29306
|
+
const $createKeywordNode_ = React21.useCallback((textNode) => {
|
|
29203
29307
|
return $createKeywordNode(textNode.getTextContent());
|
|
29204
29308
|
}, []);
|
|
29205
|
-
const getKeywordMatch =
|
|
29309
|
+
const getKeywordMatch = React21.useCallback((text) => {
|
|
29206
29310
|
const matchArr = KEYWORDS_REGEX.exec(text);
|
|
29207
29311
|
if (matchArr === null || !matchArr[2] || !matchArr[1]) {
|
|
29208
29312
|
return null;
|
|
@@ -29277,7 +29381,7 @@ function ListMaxIndentLevelPlugin({
|
|
|
29277
29381
|
maxDepth = 7
|
|
29278
29382
|
}) {
|
|
29279
29383
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
29280
|
-
|
|
29384
|
+
React21.useEffect(() => {
|
|
29281
29385
|
return editor.registerCommand(
|
|
29282
29386
|
lexical.INDENT_CONTENT_COMMAND,
|
|
29283
29387
|
() => $shouldPreventIndent(maxDepth),
|
|
@@ -29292,8 +29396,8 @@ var init_list_max_indent_level_plugin = __esm({
|
|
|
29292
29396
|
}
|
|
29293
29397
|
});
|
|
29294
29398
|
function useMentionLookupService(mentionString) {
|
|
29295
|
-
const [results, setResults] =
|
|
29296
|
-
|
|
29399
|
+
const [results, setResults] = React21.useState([]);
|
|
29400
|
+
React21.useEffect(() => {
|
|
29297
29401
|
const cachedResults = mentionsCache.get(mentionString);
|
|
29298
29402
|
if (mentionString == null) {
|
|
29299
29403
|
setTimeout(() => {
|
|
@@ -29339,12 +29443,12 @@ function getPossibleQueryMatch(text) {
|
|
|
29339
29443
|
}
|
|
29340
29444
|
function MentionsPlugin() {
|
|
29341
29445
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
29342
|
-
const [queryString, setQueryString] =
|
|
29446
|
+
const [queryString, setQueryString] = React21.useState(null);
|
|
29343
29447
|
const results = useMentionLookupService(queryString);
|
|
29344
29448
|
const checkForSlashTriggerMatch = LexicalTypeaheadMenuPlugin$1.useBasicTypeaheadTriggerMatch("/", {
|
|
29345
29449
|
minLength: 0
|
|
29346
29450
|
});
|
|
29347
|
-
const options =
|
|
29451
|
+
const options = React21.useMemo(
|
|
29348
29452
|
() => results.map(
|
|
29349
29453
|
(result) => new MentionTypeaheadOption(
|
|
29350
29454
|
result,
|
|
@@ -29353,7 +29457,7 @@ function MentionsPlugin() {
|
|
|
29353
29457
|
).slice(0, SUGGESTION_LIST_LENGTH_LIMIT),
|
|
29354
29458
|
[results]
|
|
29355
29459
|
);
|
|
29356
|
-
const onSelectOption =
|
|
29460
|
+
const onSelectOption = React21.useCallback(
|
|
29357
29461
|
(selectedOption, nodeToReplace, closeMenu) => {
|
|
29358
29462
|
editor.update(() => {
|
|
29359
29463
|
const mentionNode = $createMentionNode(selectedOption.name);
|
|
@@ -29366,7 +29470,7 @@ function MentionsPlugin() {
|
|
|
29366
29470
|
},
|
|
29367
29471
|
[editor]
|
|
29368
29472
|
);
|
|
29369
|
-
const checkForMentionMatch =
|
|
29473
|
+
const checkForMentionMatch = React21.useCallback(
|
|
29370
29474
|
(text) => {
|
|
29371
29475
|
const slashMatch = checkForSlashTriggerMatch(text, editor);
|
|
29372
29476
|
if (slashMatch !== null) {
|
|
@@ -30167,10 +30271,10 @@ function InsertTableDialog({
|
|
|
30167
30271
|
activeEditor,
|
|
30168
30272
|
onClose
|
|
30169
30273
|
}) {
|
|
30170
|
-
const [rows, setRows] =
|
|
30171
|
-
const [columns, setColumns] =
|
|
30172
|
-
const [includeHeaders, setIncludeHeaders] =
|
|
30173
|
-
const isDisabled =
|
|
30274
|
+
const [rows, setRows] = React21.useState("5");
|
|
30275
|
+
const [columns, setColumns] = React21.useState("5");
|
|
30276
|
+
const [includeHeaders, setIncludeHeaders] = React21.useState(true);
|
|
30277
|
+
const isDisabled = React21.useMemo(() => {
|
|
30174
30278
|
const row = Number(rows);
|
|
30175
30279
|
const column = Number(columns);
|
|
30176
30280
|
return !(row && row > 0 && row <= 500 && column && column > 0 && column <= 100);
|
|
@@ -30254,7 +30358,7 @@ function InsertTableDialog({
|
|
|
30254
30358
|
}
|
|
30255
30359
|
function InsertTableCommandPlugin() {
|
|
30256
30360
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
30257
|
-
|
|
30361
|
+
React21.useEffect(() => {
|
|
30258
30362
|
if (!editor.hasNodes([table.TableNode])) return;
|
|
30259
30363
|
return editor.registerCommand(
|
|
30260
30364
|
INSERT_NEW_TABLE_COMMAND,
|
|
@@ -30278,7 +30382,7 @@ var init_table_plugin = __esm({
|
|
|
30278
30382
|
init_input();
|
|
30279
30383
|
init_label();
|
|
30280
30384
|
INSERT_NEW_TABLE_COMMAND = lexical.createCommand("INSERT_NEW_TABLE_COMMAND");
|
|
30281
|
-
|
|
30385
|
+
React21.createContext({
|
|
30282
30386
|
cellEditorConfig: null,
|
|
30283
30387
|
cellEditorPlugins: null,
|
|
30284
30388
|
set: () => {
|
|
@@ -30336,7 +30440,7 @@ function registerKeyTimeStampTracker() {
|
|
|
30336
30440
|
}
|
|
30337
30441
|
function TabFocusPlugin() {
|
|
30338
30442
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
30339
|
-
|
|
30443
|
+
React21.useEffect(() => {
|
|
30340
30444
|
if (!hasRegisteredKeyDownListener) {
|
|
30341
30445
|
registerKeyTimeStampTracker();
|
|
30342
30446
|
hasRegisteredKeyDownListener = true;
|
|
@@ -30404,10 +30508,10 @@ function TableColumnResizerPlugin({
|
|
|
30404
30508
|
}) {
|
|
30405
30509
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
30406
30510
|
const isEditable = useLexicalEditable.useLexicalEditable();
|
|
30407
|
-
const dragRef =
|
|
30408
|
-
const [hoverState, setHoverState] =
|
|
30409
|
-
const resizerRef =
|
|
30410
|
-
const onPointerDownImpl =
|
|
30511
|
+
const dragRef = React21.useRef(null);
|
|
30512
|
+
const [hoverState, setHoverState] = React21.useState(null);
|
|
30513
|
+
const resizerRef = React21.useRef(null);
|
|
30514
|
+
const onPointerDownImpl = React21.useCallback((event, cell, edge) => {
|
|
30411
30515
|
if (event.button !== 0) return;
|
|
30412
30516
|
event.preventDefault();
|
|
30413
30517
|
const target = event.target;
|
|
@@ -30535,7 +30639,7 @@ function TableColumnResizerPlugin({
|
|
|
30535
30639
|
document.addEventListener("pointermove", onPointerMoveDocument);
|
|
30536
30640
|
document.addEventListener("pointerup", onPointerUpDocument);
|
|
30537
30641
|
}, [editor]);
|
|
30538
|
-
const updateResizerPosition =
|
|
30642
|
+
const updateResizerPosition = React21.useCallback(() => {
|
|
30539
30643
|
const state = hoverState;
|
|
30540
30644
|
if (state === null || !resizerRef.current) return;
|
|
30541
30645
|
const { cellKey, edge } = state;
|
|
@@ -30557,7 +30661,7 @@ function TableColumnResizerPlugin({
|
|
|
30557
30661
|
resizerElem.style.height = `${height}px`;
|
|
30558
30662
|
resizerElem.style.opacity = "1";
|
|
30559
30663
|
}, [editor, hoverState, anchorElem]);
|
|
30560
|
-
|
|
30664
|
+
React21.useLayoutEffect(() => {
|
|
30561
30665
|
updateResizerPosition();
|
|
30562
30666
|
window.addEventListener("resize", updateResizerPosition);
|
|
30563
30667
|
window.addEventListener("scroll", updateResizerPosition, true);
|
|
@@ -30580,7 +30684,7 @@ function TableColumnResizerPlugin({
|
|
|
30580
30684
|
updateListener();
|
|
30581
30685
|
};
|
|
30582
30686
|
}, [editor, hoverState, updateResizerPosition]);
|
|
30583
|
-
|
|
30687
|
+
React21.useEffect(() => {
|
|
30584
30688
|
if (!isEditable) return;
|
|
30585
30689
|
const rootElement = editor.getRootElement();
|
|
30586
30690
|
if (!rootElement) return;
|
|
@@ -30637,7 +30741,7 @@ function TableColumnResizerPlugin({
|
|
|
30637
30741
|
clearCursor();
|
|
30638
30742
|
};
|
|
30639
30743
|
}, [editor, isEditable, hoverState, anchorElem]);
|
|
30640
|
-
const resizer =
|
|
30744
|
+
const resizer = React21.useMemo(() => {
|
|
30641
30745
|
const state = hoverState;
|
|
30642
30746
|
if (state === null) return null;
|
|
30643
30747
|
const { cellKey, edge } = state;
|
|
@@ -30709,13 +30813,13 @@ function ToolbarContext({
|
|
|
30709
30813
|
);
|
|
30710
30814
|
}
|
|
30711
30815
|
function useToolbarContext() {
|
|
30712
|
-
return
|
|
30816
|
+
return React21.useContext(Context);
|
|
30713
30817
|
}
|
|
30714
30818
|
var Context;
|
|
30715
30819
|
var init_toolbar_context = __esm({
|
|
30716
30820
|
"src/context/toolbar-context.tsx"() {
|
|
30717
30821
|
"use client";
|
|
30718
|
-
Context =
|
|
30822
|
+
Context = React21.createContext({
|
|
30719
30823
|
activeEditor: {},
|
|
30720
30824
|
$updateToolbar: () => {
|
|
30721
30825
|
},
|
|
@@ -30730,7 +30834,7 @@ var init_toolbar_context = __esm({
|
|
|
30730
30834
|
function useUpdateToolbarHandler(callback) {
|
|
30731
30835
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
30732
30836
|
const { activeEditor } = useToolbarContext();
|
|
30733
|
-
|
|
30837
|
+
React21.useEffect(() => {
|
|
30734
30838
|
return activeEditor.registerCommand(
|
|
30735
30839
|
lexical.SELECTION_CHANGE_COMMAND,
|
|
30736
30840
|
() => {
|
|
@@ -30743,7 +30847,7 @@ function useUpdateToolbarHandler(callback) {
|
|
|
30743
30847
|
lexical.COMMAND_PRIORITY_CRITICAL
|
|
30744
30848
|
);
|
|
30745
30849
|
}, [editor, callback]);
|
|
30746
|
-
|
|
30850
|
+
React21.useEffect(() => {
|
|
30747
30851
|
activeEditor.getEditorState().read(() => {
|
|
30748
30852
|
const selection = lexical.$getSelection();
|
|
30749
30853
|
if (selection) {
|
|
@@ -30823,7 +30927,7 @@ function BlockFormatDropDown({
|
|
|
30823
30927
|
const { activeEditor, blockType, setBlockType } = useToolbarContext();
|
|
30824
30928
|
const currentBlockType = blockTypeToBlockName[blockType] ? blockType : "paragraph";
|
|
30825
30929
|
const currentBlockMeta = blockTypeToBlockName[currentBlockType];
|
|
30826
|
-
const $updateToolbar =
|
|
30930
|
+
const $updateToolbar = React21.useCallback(
|
|
30827
30931
|
(selection) => {
|
|
30828
30932
|
if (!lexical.$isRangeSelection(selection)) return;
|
|
30829
30933
|
const anchorNode = selection.anchor.getNode();
|
|
@@ -31316,7 +31420,7 @@ var init_insert_table = __esm({
|
|
|
31316
31420
|
});
|
|
31317
31421
|
function ClearFormattingToolbarPlugin() {
|
|
31318
31422
|
const { activeEditor } = useToolbarContext();
|
|
31319
|
-
const clearFormatting =
|
|
31423
|
+
const clearFormatting = React21.useCallback(() => {
|
|
31320
31424
|
activeEditor.update(() => {
|
|
31321
31425
|
const selection = lexical.$getSelection();
|
|
31322
31426
|
if (lexical.$isRangeSelection(selection) || table.$isTableSelection(selection)) {
|
|
@@ -31388,8 +31492,8 @@ function getCodeLanguageOptions2() {
|
|
|
31388
31492
|
}
|
|
31389
31493
|
function CodeLanguageToolbarPlugin() {
|
|
31390
31494
|
const { activeEditor } = useToolbarContext();
|
|
31391
|
-
const [codeLanguage, setCodeLanguage] =
|
|
31392
|
-
const [selectedElementKey, setSelectedElementKey] =
|
|
31495
|
+
const [codeLanguage, setCodeLanguage] = React21.useState("");
|
|
31496
|
+
const [selectedElementKey, setSelectedElementKey] = React21.useState(
|
|
31393
31497
|
null
|
|
31394
31498
|
);
|
|
31395
31499
|
const $updateToolbar = (selection) => {
|
|
@@ -31417,7 +31521,7 @@ function CodeLanguageToolbarPlugin() {
|
|
|
31417
31521
|
}
|
|
31418
31522
|
};
|
|
31419
31523
|
useUpdateToolbarHandler($updateToolbar);
|
|
31420
|
-
const onCodeLanguageSelect =
|
|
31524
|
+
const onCodeLanguageSelect = React21.useCallback(
|
|
31421
31525
|
(value) => {
|
|
31422
31526
|
activeEditor.update(() => {
|
|
31423
31527
|
if (selectedElementKey !== null) {
|
|
@@ -31464,8 +31568,8 @@ function ElementFormatToolbarPlugin({
|
|
|
31464
31568
|
separator = true
|
|
31465
31569
|
}) {
|
|
31466
31570
|
const { activeEditor } = useToolbarContext();
|
|
31467
|
-
const [elementFormat, setElementFormat] =
|
|
31468
|
-
const activeLayoutItemKeyRef =
|
|
31571
|
+
const [elementFormat, setElementFormat] = React21.useState("left");
|
|
31572
|
+
const activeLayoutItemKeyRef = React21.useRef(null);
|
|
31469
31573
|
const extractPadding = (style) => {
|
|
31470
31574
|
const match = style.match(/padding\s*:\s*(\d+)px/i);
|
|
31471
31575
|
if (!match?.[1]) return null;
|
|
@@ -31644,8 +31748,8 @@ var init_element_format_toolbar_plugin = __esm({
|
|
|
31644
31748
|
});
|
|
31645
31749
|
function FontBackgroundToolbarPlugin() {
|
|
31646
31750
|
const { activeEditor } = useToolbarContext();
|
|
31647
|
-
const [bgColor, setBgColor] =
|
|
31648
|
-
const activeLayoutItemKeyRef =
|
|
31751
|
+
const [bgColor, setBgColor] = React21.useState("#fff");
|
|
31752
|
+
const activeLayoutItemKeyRef = React21.useRef(null);
|
|
31649
31753
|
const extractStyleValue = (style, property) => {
|
|
31650
31754
|
const escapedProperty = property.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
31651
31755
|
const match = style.match(new RegExp(`${escapedProperty}\\s*:\\s*([^;]+)`, "i"));
|
|
@@ -31686,7 +31790,7 @@ function FontBackgroundToolbarPlugin() {
|
|
|
31686
31790
|
}
|
|
31687
31791
|
};
|
|
31688
31792
|
useUpdateToolbarHandler($updateToolbar);
|
|
31689
|
-
const applyStyleText =
|
|
31793
|
+
const applyStyleText = React21.useCallback(
|
|
31690
31794
|
(styles, skipHistoryStack) => {
|
|
31691
31795
|
activeEditor.update(
|
|
31692
31796
|
() => {
|
|
@@ -31701,7 +31805,7 @@ function FontBackgroundToolbarPlugin() {
|
|
|
31701
31805
|
},
|
|
31702
31806
|
[activeEditor]
|
|
31703
31807
|
);
|
|
31704
|
-
const onBgColorSelect =
|
|
31808
|
+
const onBgColorSelect = React21.useCallback(
|
|
31705
31809
|
(value) => {
|
|
31706
31810
|
let shouldApplyTextStyle = true;
|
|
31707
31811
|
activeEditor.update(() => {
|
|
@@ -31782,7 +31886,7 @@ var init_font_background_toolbar_plugin = __esm({
|
|
|
31782
31886
|
});
|
|
31783
31887
|
function FontColorToolbarPlugin() {
|
|
31784
31888
|
const { activeEditor } = useToolbarContext();
|
|
31785
|
-
const [fontColor, setFontColor] =
|
|
31889
|
+
const [fontColor, setFontColor] = React21.useState("#000");
|
|
31786
31890
|
const $updateToolbar = (selection$1) => {
|
|
31787
31891
|
if (lexical.$isRangeSelection(selection$1)) {
|
|
31788
31892
|
setFontColor(
|
|
@@ -31791,7 +31895,7 @@ function FontColorToolbarPlugin() {
|
|
|
31791
31895
|
}
|
|
31792
31896
|
};
|
|
31793
31897
|
useUpdateToolbarHandler($updateToolbar);
|
|
31794
|
-
const applyStyleText =
|
|
31898
|
+
const applyStyleText = React21.useCallback(
|
|
31795
31899
|
(styles) => {
|
|
31796
31900
|
activeEditor.update(() => {
|
|
31797
31901
|
const selection$1 = lexical.$getSelection();
|
|
@@ -31803,7 +31907,7 @@ function FontColorToolbarPlugin() {
|
|
|
31803
31907
|
},
|
|
31804
31908
|
[activeEditor]
|
|
31805
31909
|
);
|
|
31806
|
-
const onFontColorSelect =
|
|
31910
|
+
const onFontColorSelect = React21.useCallback(
|
|
31807
31911
|
(value) => {
|
|
31808
31912
|
applyStyleText({ color: value });
|
|
31809
31913
|
},
|
|
@@ -31856,7 +31960,7 @@ var init_font_color_toolbar_plugin = __esm({
|
|
|
31856
31960
|
});
|
|
31857
31961
|
function FontFamilyToolbarPlugin() {
|
|
31858
31962
|
const style = "font-family";
|
|
31859
|
-
const [fontFamily, setFontFamily] =
|
|
31963
|
+
const [fontFamily, setFontFamily] = React21.useState("Arial");
|
|
31860
31964
|
const { activeEditor } = useToolbarContext();
|
|
31861
31965
|
const $updateToolbar = (selection$1) => {
|
|
31862
31966
|
if (lexical.$isRangeSelection(selection$1)) {
|
|
@@ -31866,7 +31970,7 @@ function FontFamilyToolbarPlugin() {
|
|
|
31866
31970
|
}
|
|
31867
31971
|
};
|
|
31868
31972
|
useUpdateToolbarHandler($updateToolbar);
|
|
31869
|
-
const handleClick =
|
|
31973
|
+
const handleClick = React21.useCallback(
|
|
31870
31974
|
(option) => {
|
|
31871
31975
|
activeEditor.update(() => {
|
|
31872
31976
|
const selection$1 = lexical.$getSelection();
|
|
@@ -31928,8 +32032,8 @@ var init_font_family_toolbar_plugin = __esm({
|
|
|
31928
32032
|
});
|
|
31929
32033
|
function FontFormatToolbarPlugin() {
|
|
31930
32034
|
const { activeEditor } = useToolbarContext();
|
|
31931
|
-
const [activeFormats, setActiveFormats] =
|
|
31932
|
-
const $updateToolbar =
|
|
32035
|
+
const [activeFormats, setActiveFormats] = React21.useState([]);
|
|
32036
|
+
const $updateToolbar = React21.useCallback((selection) => {
|
|
31933
32037
|
if (lexical.$isRangeSelection(selection) || table.$isTableSelection(selection)) {
|
|
31934
32038
|
const formats = [];
|
|
31935
32039
|
FORMATS.forEach(({ format }) => {
|
|
@@ -31982,9 +32086,9 @@ var init_font_format_toolbar_plugin = __esm({
|
|
|
31982
32086
|
});
|
|
31983
32087
|
function FontSizeToolbarPlugin() {
|
|
31984
32088
|
const style = "font-size";
|
|
31985
|
-
const [fontSize, setFontSize] =
|
|
31986
|
-
const fontSizeRef =
|
|
31987
|
-
|
|
32089
|
+
const [fontSize, setFontSize] = React21.useState(DEFAULT_FONT_SIZE);
|
|
32090
|
+
const fontSizeRef = React21.useRef(fontSize);
|
|
32091
|
+
React21.useEffect(() => {
|
|
31988
32092
|
fontSizeRef.current = fontSize;
|
|
31989
32093
|
}, [fontSize]);
|
|
31990
32094
|
const { activeEditor } = useToolbarContext();
|
|
@@ -32000,7 +32104,7 @@ function FontSizeToolbarPlugin() {
|
|
|
32000
32104
|
}
|
|
32001
32105
|
};
|
|
32002
32106
|
useUpdateToolbarHandler($updateToolbar);
|
|
32003
|
-
const updateFontSize =
|
|
32107
|
+
const updateFontSize = React21.useCallback(
|
|
32004
32108
|
(newSize) => {
|
|
32005
32109
|
const size = Math.min(Math.max(newSize, MIN_FONT_SIZE), MAX_FONT_SIZE);
|
|
32006
32110
|
activeEditor.update(() => {
|
|
@@ -32034,9 +32138,9 @@ function FontSizeToolbarPlugin() {
|
|
|
32034
32138
|
updateFontSize(fontSize);
|
|
32035
32139
|
}
|
|
32036
32140
|
};
|
|
32037
|
-
const timerRef =
|
|
32038
|
-
const intervalRef =
|
|
32039
|
-
const stopTimer =
|
|
32141
|
+
const timerRef = React21.useRef(null);
|
|
32142
|
+
const intervalRef = React21.useRef(null);
|
|
32143
|
+
const stopTimer = React21.useCallback(() => {
|
|
32040
32144
|
if (timerRef.current) {
|
|
32041
32145
|
clearTimeout(timerRef.current);
|
|
32042
32146
|
timerRef.current = null;
|
|
@@ -32046,7 +32150,7 @@ function FontSizeToolbarPlugin() {
|
|
|
32046
32150
|
intervalRef.current = null;
|
|
32047
32151
|
}
|
|
32048
32152
|
}, []);
|
|
32049
|
-
const startTimer =
|
|
32153
|
+
const startTimer = React21.useCallback(
|
|
32050
32154
|
(increment) => {
|
|
32051
32155
|
stopTimer();
|
|
32052
32156
|
const currentSize = typeof fontSizeRef.current === "number" ? fontSizeRef.current : DEFAULT_FONT_SIZE;
|
|
@@ -32066,7 +32170,7 @@ function FontSizeToolbarPlugin() {
|
|
|
32066
32170
|
},
|
|
32067
32171
|
[updateFontSize, stopTimer]
|
|
32068
32172
|
);
|
|
32069
|
-
|
|
32173
|
+
React21.useEffect(() => {
|
|
32070
32174
|
return () => stopTimer();
|
|
32071
32175
|
}, [stopTimer]);
|
|
32072
32176
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -32138,10 +32242,10 @@ var init_font_size_toolbar_plugin = __esm({
|
|
|
32138
32242
|
function HistoryToolbarPlugin() {
|
|
32139
32243
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
32140
32244
|
const { activeEditor, $updateToolbar } = useToolbarContext();
|
|
32141
|
-
const [isEditable, setIsEditable] =
|
|
32142
|
-
const [canUndo, setCanUndo] =
|
|
32143
|
-
const [canRedo, setCanRedo] =
|
|
32144
|
-
|
|
32245
|
+
const [isEditable, setIsEditable] = React21.useState(editor.isEditable());
|
|
32246
|
+
const [canUndo, setCanUndo] = React21.useState(false);
|
|
32247
|
+
const [canRedo, setCanRedo] = React21.useState(false);
|
|
32248
|
+
React21.useEffect(() => {
|
|
32145
32249
|
return utils.mergeRegister(
|
|
32146
32250
|
editor.registerEditableListener((editable) => {
|
|
32147
32251
|
setIsEditable(editable);
|
|
@@ -32213,7 +32317,7 @@ var Toggle;
|
|
|
32213
32317
|
var init_toggle = __esm({
|
|
32214
32318
|
"src/ui/toggle.tsx"() {
|
|
32215
32319
|
init_utils();
|
|
32216
|
-
Toggle =
|
|
32320
|
+
Toggle = React21__namespace.forwardRef(({ className, pressed, onPressedChange, variant = "default", size = "default", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
32217
32321
|
"button",
|
|
32218
32322
|
{
|
|
32219
32323
|
ref,
|
|
@@ -32237,7 +32341,7 @@ function LinkToolbarPlugin({
|
|
|
32237
32341
|
setIsLinkEditMode
|
|
32238
32342
|
}) {
|
|
32239
32343
|
const { activeEditor } = useToolbarContext();
|
|
32240
|
-
const [isLink, setIsLink] =
|
|
32344
|
+
const [isLink, setIsLink] = React21.useState(false);
|
|
32241
32345
|
const $updateToolbar = (selection) => {
|
|
32242
32346
|
if (lexical.$isRangeSelection(selection)) {
|
|
32243
32347
|
const node = getSelectedNode(selection);
|
|
@@ -32250,7 +32354,7 @@ function LinkToolbarPlugin({
|
|
|
32250
32354
|
}
|
|
32251
32355
|
};
|
|
32252
32356
|
useUpdateToolbarHandler($updateToolbar);
|
|
32253
|
-
|
|
32357
|
+
React21.useEffect(() => {
|
|
32254
32358
|
return activeEditor.registerCommand(
|
|
32255
32359
|
lexical.KEY_MODIFIER_COMMAND,
|
|
32256
32360
|
(payload) => {
|
|
@@ -32273,7 +32377,7 @@ function LinkToolbarPlugin({
|
|
|
32273
32377
|
lexical.COMMAND_PRIORITY_NORMAL
|
|
32274
32378
|
);
|
|
32275
32379
|
}, [activeEditor, isLink, setIsLinkEditMode]);
|
|
32276
|
-
const insertLink =
|
|
32380
|
+
const insertLink = React21.useCallback(() => {
|
|
32277
32381
|
if (!isLink) {
|
|
32278
32382
|
setIsLinkEditMode(true);
|
|
32279
32383
|
activeEditor.dispatchCommand(link.TOGGLE_LINK_COMMAND, sanitizeUrl("https://"));
|
|
@@ -32307,8 +32411,8 @@ var init_link_toolbar_plugin = __esm({
|
|
|
32307
32411
|
});
|
|
32308
32412
|
function SubSuperToolbarPlugin() {
|
|
32309
32413
|
const { activeEditor } = useToolbarContext();
|
|
32310
|
-
const [isSubscript, setIsSubscript] =
|
|
32311
|
-
const [isSuperscript, setIsSuperscript] =
|
|
32414
|
+
const [isSubscript, setIsSubscript] = React21.useState(false);
|
|
32415
|
+
const [isSuperscript, setIsSuperscript] = React21.useState(false);
|
|
32312
32416
|
const $updateToolbar = (selection) => {
|
|
32313
32417
|
if (lexical.$isRangeSelection(selection) || table.$isTableSelection(selection)) {
|
|
32314
32418
|
setIsSubscript(selection.hasFormat("subscript"));
|
|
@@ -32358,8 +32462,8 @@ var init_subsuper_toolbar_plugin = __esm({
|
|
|
32358
32462
|
});
|
|
32359
32463
|
function useHeaderHeight() {
|
|
32360
32464
|
const { ref: headerRef, height: headerHeightValue } = useElementSize();
|
|
32361
|
-
const [headerHeight, setHeaderHeight] =
|
|
32362
|
-
const findAndSetHeader =
|
|
32465
|
+
const [headerHeight, setHeaderHeight] = React21.useState(0);
|
|
32466
|
+
const findAndSetHeader = React21.useCallback(() => {
|
|
32363
32467
|
if (typeof document === "undefined") {
|
|
32364
32468
|
return null;
|
|
32365
32469
|
}
|
|
@@ -32373,7 +32477,7 @@ function useHeaderHeight() {
|
|
|
32373
32477
|
}
|
|
32374
32478
|
return null;
|
|
32375
32479
|
}, [headerRef]);
|
|
32376
|
-
|
|
32480
|
+
React21.useEffect(() => {
|
|
32377
32481
|
if (typeof document === "undefined") {
|
|
32378
32482
|
return;
|
|
32379
32483
|
}
|
|
@@ -32401,7 +32505,7 @@ function useHeaderHeight() {
|
|
|
32401
32505
|
headerRef(null);
|
|
32402
32506
|
};
|
|
32403
32507
|
}, [findAndSetHeader, headerRef]);
|
|
32404
|
-
|
|
32508
|
+
React21.useEffect(() => {
|
|
32405
32509
|
if (headerHeightValue > 0) {
|
|
32406
32510
|
setHeaderHeight(headerHeightValue);
|
|
32407
32511
|
} else {
|
|
@@ -32433,12 +32537,12 @@ function ToolbarPlugin({
|
|
|
32433
32537
|
}) {
|
|
32434
32538
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
32435
32539
|
const { headerHeight } = useHeaderHeight();
|
|
32436
|
-
const [activeEditor, setActiveEditor] =
|
|
32437
|
-
const [blockType, setBlockType] =
|
|
32540
|
+
const [activeEditor, setActiveEditor] = React21.useState(editor);
|
|
32541
|
+
const [blockType, setBlockType] = React21.useState("paragraph");
|
|
32438
32542
|
const [modal, showModal] = useEditorModal();
|
|
32439
32543
|
const $updateToolbar = () => {
|
|
32440
32544
|
};
|
|
32441
|
-
|
|
32545
|
+
React21.useEffect(() => {
|
|
32442
32546
|
return activeEditor.registerCommand(
|
|
32443
32547
|
lexical.SELECTION_CHANGE_COMMAND,
|
|
32444
32548
|
(_payload, newEditor) => {
|
|
@@ -32487,7 +32591,7 @@ var init_toolbar_plugin = __esm({
|
|
|
32487
32591
|
});
|
|
32488
32592
|
function TypingPerfPlugin() {
|
|
32489
32593
|
const report = useReport();
|
|
32490
|
-
|
|
32594
|
+
React21.useEffect(() => {
|
|
32491
32595
|
let start = 0;
|
|
32492
32596
|
let timerId;
|
|
32493
32597
|
let keyPressTimerId;
|
|
@@ -32868,8 +32972,8 @@ function Plugins({
|
|
|
32868
32972
|
readOnly = false,
|
|
32869
32973
|
placeholder = ""
|
|
32870
32974
|
}) {
|
|
32871
|
-
const [floatingAnchorElem, setFloatingAnchorElem] =
|
|
32872
|
-
const [isLinkEditMode, setIsLinkEditMode] =
|
|
32975
|
+
const [floatingAnchorElem, setFloatingAnchorElem] = React21.useState(null);
|
|
32976
|
+
const [isLinkEditMode, setIsLinkEditMode] = React21.useState(false);
|
|
32873
32977
|
const onRef = (_floatingAnchorElem) => {
|
|
32874
32978
|
if (_floatingAnchorElem !== null) {
|
|
32875
32979
|
setFloatingAnchorElem(_floatingAnchorElem);
|
|
@@ -32959,11 +33063,13 @@ function Plugins({
|
|
|
32959
33063
|
contentEditable: /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("editor-relative-full"), children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("editor-relative-full"), ref: onRef, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
32960
33064
|
ContentEditable,
|
|
32961
33065
|
{
|
|
32962
|
-
placeholder:
|
|
33066
|
+
placeholder: "",
|
|
32963
33067
|
className: cn(
|
|
32964
33068
|
"editor-content-editable",
|
|
32965
33069
|
readOnly && "editor-content-editable--readonly"
|
|
32966
|
-
)
|
|
33070
|
+
),
|
|
33071
|
+
placeholderClassName: "editor-placeholder",
|
|
33072
|
+
placeholderDefaults: false
|
|
32967
33073
|
}
|
|
32968
33074
|
) }) }),
|
|
32969
33075
|
ErrorBoundary: LexicalErrorBoundary.LexicalErrorBoundary,
|
|
@@ -33074,9 +33180,9 @@ function Plugins({
|
|
|
33074
33180
|
] })
|
|
33075
33181
|
] }),
|
|
33076
33182
|
!readOnly && /* @__PURE__ */ jsxRuntime.jsx(ActionsPlugin, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "editor-actions-bar", children: [
|
|
33077
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
33183
|
+
/* @__PURE__ */ jsxRuntime.jsx(Flex, { align: "center", className: "editor-flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(CounterCharacterPlugin, { charset: "UTF-16" }) }),
|
|
33078
33184
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-flex-1" }),
|
|
33079
|
-
/* @__PURE__ */ jsxRuntime.jsxs("
|
|
33185
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Flex, { align: "center", justify: "end", gap: 1, wrap: "nowrap", className: "editor-flex-shrink-0", children: [
|
|
33080
33186
|
/* @__PURE__ */ jsxRuntime.jsx(SpeechToTextPlugin, {}),
|
|
33081
33187
|
/* @__PURE__ */ jsxRuntime.jsx(ShareContentPlugin, {}),
|
|
33082
33188
|
/* @__PURE__ */ jsxRuntime.jsx(ImportExportPlugin, {}),
|
|
@@ -33194,6 +33300,7 @@ var init_plugins = __esm({
|
|
|
33194
33300
|
init_markdown_tweet_transformer();
|
|
33195
33301
|
init_markdown_list_transformer();
|
|
33196
33302
|
init_separator();
|
|
33303
|
+
init_flex();
|
|
33197
33304
|
}
|
|
33198
33305
|
});
|
|
33199
33306
|
|
|
@@ -33342,14 +33449,14 @@ function Editor({
|
|
|
33342
33449
|
}) {
|
|
33343
33450
|
const { ref: editorRef, width: editorWidth } = useElementSize();
|
|
33344
33451
|
const editorMaxWidth = editorWidth || void 0;
|
|
33345
|
-
const [config, setConfig] =
|
|
33346
|
-
|
|
33452
|
+
const [config, setConfig] = React21.useState(null);
|
|
33453
|
+
React21.useEffect(() => {
|
|
33347
33454
|
Promise.all([
|
|
33348
33455
|
Promise.resolve().then(() => (init_nodes(), nodes_exports)).then((m) => m.nodes),
|
|
33349
33456
|
Promise.resolve().then(() => (init_plugins(), plugins_exports)).then((m) => ({ Plugins: m.Plugins }))
|
|
33350
33457
|
]).then(([nodes2, { Plugins: Plugins3 }]) => setConfig({ nodes: nodes2, Plugins: Plugins3 }));
|
|
33351
33458
|
}, []);
|
|
33352
|
-
const editorConfig =
|
|
33459
|
+
const editorConfig = React21.useMemo(() => {
|
|
33353
33460
|
if (!config || !config.nodes) return null;
|
|
33354
33461
|
const validNodes = config.nodes.filter((node) => {
|
|
33355
33462
|
if (node === void 0) {
|