@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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as React21 from 'react';
|
|
2
2
|
import { createContext, useRef, useState, useEffect, useCallback, Suspense, useMemo, useContext, useLayoutEffect } from 'react';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
@@ -91,9 +91,9 @@ var init_tooltip = __esm({
|
|
|
91
91
|
TooltipProvider = ({ children }) => /* @__PURE__ */ jsx(Fragment, { children });
|
|
92
92
|
Tooltip = ({ children }) => /* @__PURE__ */ jsx("div", { className: "editor-tooltip-group", children });
|
|
93
93
|
TooltipTrigger = ({ asChild, children, ...props }) => {
|
|
94
|
-
const child = asChild ?
|
|
95
|
-
if (!
|
|
96
|
-
return
|
|
94
|
+
const child = asChild ? React21.Children.only(children) : children;
|
|
95
|
+
if (!React21.isValidElement(child)) return null;
|
|
96
|
+
return React21.cloneElement(child, {
|
|
97
97
|
...props,
|
|
98
98
|
className: cn(child.props.className, "editor-tooltip-trigger")
|
|
99
99
|
});
|
|
@@ -2963,7 +2963,7 @@ var Button;
|
|
|
2963
2963
|
var init_button = __esm({
|
|
2964
2964
|
"src/ui/button.tsx"() {
|
|
2965
2965
|
init_utils();
|
|
2966
|
-
Button =
|
|
2966
|
+
Button = React21.forwardRef(
|
|
2967
2967
|
({ className, variant = "default", size = "default", type = "button", isLoading, disabled, children, ...props }, ref) => {
|
|
2968
2968
|
return /* @__PURE__ */ jsxs(
|
|
2969
2969
|
"button",
|
|
@@ -3104,22 +3104,22 @@ var init_typography = __esm({
|
|
|
3104
3104
|
md: "editor-icon-md",
|
|
3105
3105
|
lg: "editor-icon-lg"
|
|
3106
3106
|
};
|
|
3107
|
-
if (
|
|
3108
|
-
return
|
|
3107
|
+
if (React21.isValidElement(children)) {
|
|
3108
|
+
return React21.cloneElement(children, {
|
|
3109
3109
|
className: cn(sizeMap[size] || sizeMap.medium, children.props.className, className)
|
|
3110
3110
|
});
|
|
3111
3111
|
}
|
|
3112
3112
|
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
3113
3113
|
};
|
|
3114
|
-
TypographyP =
|
|
3114
|
+
TypographyP = React21.forwardRef(
|
|
3115
3115
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx("p", { ref, className: cn("editor-typography-p", className), ...props })
|
|
3116
3116
|
);
|
|
3117
3117
|
TypographyP.displayName = "TypographyP";
|
|
3118
|
-
TypographyPSmall =
|
|
3118
|
+
TypographyPSmall = React21.forwardRef(
|
|
3119
3119
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx("p", { ref, className: cn("editor-typography-p-small", className), ...props })
|
|
3120
3120
|
);
|
|
3121
3121
|
TypographyPSmall.displayName = "TypographyPSmall";
|
|
3122
|
-
TypographySpanSmallMuted =
|
|
3122
|
+
TypographySpanSmallMuted = React21.forwardRef(
|
|
3123
3123
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx("span", { ref, className: cn("editor-typography-span-small-muted", className), ...props })
|
|
3124
3124
|
);
|
|
3125
3125
|
TypographySpanSmallMuted.displayName = "TypographySpanSmallMuted";
|
|
@@ -3171,7 +3171,7 @@ function MediaResizer({
|
|
|
3171
3171
|
const hardWidthLimit = maxWidth ?? editorContainer?.maxWidth;
|
|
3172
3172
|
const minWidth = 100;
|
|
3173
3173
|
const minHeight = 100;
|
|
3174
|
-
|
|
3174
|
+
React21.useEffect(() => {
|
|
3175
3175
|
}, [mediaRef, unlockBoundaries]);
|
|
3176
3176
|
const setStartCursor = (direction) => {
|
|
3177
3177
|
const ew = direction === Direction.east || direction === Direction.west;
|
|
@@ -3518,14 +3518,14 @@ function YouTubeComponent({
|
|
|
3518
3518
|
}) {
|
|
3519
3519
|
const isEditable = useLexicalEditable();
|
|
3520
3520
|
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
|
|
3521
|
-
const [isResizing, setIsResizing] =
|
|
3522
|
-
const wrapperRef =
|
|
3523
|
-
const [wrapperElement, setWrapperElement] =
|
|
3524
|
-
const buttonRef =
|
|
3525
|
-
const [containerWidth, setContainerWidth] =
|
|
3521
|
+
const [isResizing, setIsResizing] = React21.useState(false);
|
|
3522
|
+
const wrapperRef = React21.useRef(null);
|
|
3523
|
+
const [wrapperElement, setWrapperElement] = React21.useState(null);
|
|
3524
|
+
const buttonRef = React21.useRef(null);
|
|
3525
|
+
const [containerWidth, setContainerWidth] = React21.useState(maxWidth);
|
|
3526
3526
|
const editorContainer = useEditorContainer();
|
|
3527
3527
|
const editorHardWidthLimit = editorContainer?.maxWidth;
|
|
3528
|
-
const updateNode =
|
|
3528
|
+
const updateNode = React21.useCallback(
|
|
3529
3529
|
(updater) => {
|
|
3530
3530
|
editor.update(() => {
|
|
3531
3531
|
const node = $getNodeByKey(nodeKey);
|
|
@@ -3537,14 +3537,14 @@ function YouTubeComponent({
|
|
|
3537
3537
|
[editor, nodeKey]
|
|
3538
3538
|
);
|
|
3539
3539
|
const aspectRatio = 16 / 9;
|
|
3540
|
-
const clampToContainer =
|
|
3540
|
+
const clampToContainer = React21.useCallback(
|
|
3541
3541
|
(value) => {
|
|
3542
3542
|
const limit = typeof editorHardWidthLimit === "number" && editorHardWidthLimit > 0 ? editorHardWidthLimit : containerWidth || value;
|
|
3543
3543
|
return Math.min(value, limit);
|
|
3544
3544
|
},
|
|
3545
3545
|
[containerWidth, editorHardWidthLimit]
|
|
3546
3546
|
);
|
|
3547
|
-
|
|
3547
|
+
React21.useEffect(() => {
|
|
3548
3548
|
if (!wrapperElement) {
|
|
3549
3549
|
return;
|
|
3550
3550
|
}
|
|
@@ -3589,7 +3589,7 @@ function YouTubeComponent({
|
|
|
3589
3589
|
return () => window.removeEventListener("resize", updateAvailableWidth);
|
|
3590
3590
|
}
|
|
3591
3591
|
}, [editor, editorHardWidthLimit, maxWidth, wrapperElement]);
|
|
3592
|
-
|
|
3592
|
+
React21.useEffect(() => {
|
|
3593
3593
|
if (!containerWidth) {
|
|
3594
3594
|
return;
|
|
3595
3595
|
}
|
|
@@ -3616,11 +3616,11 @@ function YouTubeComponent({
|
|
|
3616
3616
|
const disablePlaybackInteractions = isEditable;
|
|
3617
3617
|
const iframeWidth = safeRenderedWidth;
|
|
3618
3618
|
const iframeHeight = Math.round(iframeWidth / aspectRatio);
|
|
3619
|
-
const handleWrapperRef =
|
|
3619
|
+
const handleWrapperRef = React21.useCallback((node) => {
|
|
3620
3620
|
wrapperRef.current = node;
|
|
3621
3621
|
setWrapperElement(node);
|
|
3622
3622
|
}, []);
|
|
3623
|
-
|
|
3623
|
+
React21.useEffect(() => {
|
|
3624
3624
|
if (!isEditable) {
|
|
3625
3625
|
return;
|
|
3626
3626
|
}
|
|
@@ -3651,7 +3651,7 @@ function YouTubeComponent({
|
|
|
3651
3651
|
)
|
|
3652
3652
|
);
|
|
3653
3653
|
}, [clearSelection, editor, isEditable, isResizing, isSelected, setSelected]);
|
|
3654
|
-
|
|
3654
|
+
React21.useEffect(() => {
|
|
3655
3655
|
if (!containerWidth || typeof width !== "number" || fullWidth || width <= containerWidth) {
|
|
3656
3656
|
return;
|
|
3657
3657
|
}
|
|
@@ -3951,15 +3951,15 @@ function Dialog({ open = false, onOpenChange = () => {
|
|
|
3951
3951
|
return /* @__PURE__ */ jsx(DialogContext.Provider, { value: { open, onOpenChange }, children });
|
|
3952
3952
|
}
|
|
3953
3953
|
function DialogTrigger({ asChild, children, className, ...props }) {
|
|
3954
|
-
const context =
|
|
3954
|
+
const context = React21.useContext(DialogContext);
|
|
3955
3955
|
const handleClick = (e) => {
|
|
3956
3956
|
context?.onOpenChange(true);
|
|
3957
|
-
if (
|
|
3957
|
+
if (React21.isValidElement(children)) {
|
|
3958
3958
|
children.props.onClick?.(e);
|
|
3959
3959
|
}
|
|
3960
3960
|
};
|
|
3961
|
-
if (asChild &&
|
|
3962
|
-
return
|
|
3961
|
+
if (asChild && React21.isValidElement(children)) {
|
|
3962
|
+
return React21.cloneElement(children, {
|
|
3963
3963
|
onClick: handleClick,
|
|
3964
3964
|
...props
|
|
3965
3965
|
});
|
|
@@ -3967,15 +3967,15 @@ function DialogTrigger({ asChild, children, className, ...props }) {
|
|
|
3967
3967
|
return /* @__PURE__ */ jsx("button", { type: "button", onClick: handleClick, className, ...props, children });
|
|
3968
3968
|
}
|
|
3969
3969
|
function DialogClose({ asChild, children, className, ...props }) {
|
|
3970
|
-
const context =
|
|
3970
|
+
const context = React21.useContext(DialogContext);
|
|
3971
3971
|
const handleClick = (e) => {
|
|
3972
3972
|
context?.onOpenChange(false);
|
|
3973
|
-
if (
|
|
3973
|
+
if (React21.isValidElement(children)) {
|
|
3974
3974
|
children.props.onClick?.(e);
|
|
3975
3975
|
}
|
|
3976
3976
|
};
|
|
3977
|
-
if (asChild &&
|
|
3978
|
-
return
|
|
3977
|
+
if (asChild && React21.isValidElement(children)) {
|
|
3978
|
+
return React21.cloneElement(children, {
|
|
3979
3979
|
onClick: handleClick,
|
|
3980
3980
|
...props
|
|
3981
3981
|
});
|
|
@@ -3983,9 +3983,9 @@ function DialogClose({ asChild, children, className, ...props }) {
|
|
|
3983
3983
|
return /* @__PURE__ */ jsx("button", { type: "button", onClick: handleClick, className, ...props, children });
|
|
3984
3984
|
}
|
|
3985
3985
|
function DialogContent({ children, className, disableOutsideClick, ...props }) {
|
|
3986
|
-
const context =
|
|
3987
|
-
const [mounted, setMounted] =
|
|
3988
|
-
|
|
3986
|
+
const context = React21.useContext(DialogContext);
|
|
3987
|
+
const [mounted, setMounted] = React21.useState(false);
|
|
3988
|
+
React21.useEffect(() => {
|
|
3989
3989
|
setMounted(true);
|
|
3990
3990
|
return () => setMounted(false);
|
|
3991
3991
|
}, []);
|
|
@@ -4044,7 +4044,7 @@ var DialogContext;
|
|
|
4044
4044
|
var init_dialog = __esm({
|
|
4045
4045
|
"src/ui/dialog.tsx"() {
|
|
4046
4046
|
init_utils();
|
|
4047
|
-
DialogContext =
|
|
4047
|
+
DialogContext = React21.createContext(null);
|
|
4048
4048
|
}
|
|
4049
4049
|
});
|
|
4050
4050
|
|
|
@@ -4059,7 +4059,7 @@ var Input;
|
|
|
4059
4059
|
var init_input = __esm({
|
|
4060
4060
|
"src/ui/input.tsx"() {
|
|
4061
4061
|
init_utils();
|
|
4062
|
-
Input =
|
|
4062
|
+
Input = React21.forwardRef(
|
|
4063
4063
|
({ className, type, ...props }, ref) => {
|
|
4064
4064
|
return /* @__PURE__ */ jsx(
|
|
4065
4065
|
"input",
|
|
@@ -4079,7 +4079,7 @@ var Label;
|
|
|
4079
4079
|
var init_label = __esm({
|
|
4080
4080
|
"src/ui/label.tsx"() {
|
|
4081
4081
|
init_utils();
|
|
4082
|
-
Label =
|
|
4082
|
+
Label = React21.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
4083
4083
|
"label",
|
|
4084
4084
|
{
|
|
4085
4085
|
ref,
|
|
@@ -4094,6 +4094,37 @@ var init_label = __esm({
|
|
|
4094
4094
|
Label.displayName = "Label";
|
|
4095
4095
|
}
|
|
4096
4096
|
});
|
|
4097
|
+
var Flex;
|
|
4098
|
+
var init_flex = __esm({
|
|
4099
|
+
"src/ui/flex.tsx"() {
|
|
4100
|
+
init_utils();
|
|
4101
|
+
Flex = React21.forwardRef(
|
|
4102
|
+
({ className, align, justify, direction, wrap, gap, style, ...props }, ref) => {
|
|
4103
|
+
const isStandardGap = typeof gap === "number" && [0.5, 1, 1.5, 2, 3, 4, 5].includes(gap);
|
|
4104
|
+
const gapClass = isStandardGap ? `editor-gap-${gap.toString().replace(".", "-")}` : void 0;
|
|
4105
|
+
const gapStyle = !isStandardGap && typeof gap === "number" ? { gap: `${gap * 0.25}rem` } : !isStandardGap && typeof gap !== "undefined" ? { gap } : void 0;
|
|
4106
|
+
return /* @__PURE__ */ jsx(
|
|
4107
|
+
"div",
|
|
4108
|
+
{
|
|
4109
|
+
ref,
|
|
4110
|
+
className: cn(
|
|
4111
|
+
"editor-flex",
|
|
4112
|
+
align && `editor-items-${align}`,
|
|
4113
|
+
justify && `editor-justify-${justify}`,
|
|
4114
|
+
direction && `editor-flex-${direction}`,
|
|
4115
|
+
wrap && `editor-flex-${wrap}`,
|
|
4116
|
+
gapClass,
|
|
4117
|
+
className
|
|
4118
|
+
),
|
|
4119
|
+
style: { ...gapStyle, ...style },
|
|
4120
|
+
...props
|
|
4121
|
+
}
|
|
4122
|
+
);
|
|
4123
|
+
}
|
|
4124
|
+
);
|
|
4125
|
+
Flex.displayName = "Flex";
|
|
4126
|
+
}
|
|
4127
|
+
});
|
|
4097
4128
|
function Tabs({
|
|
4098
4129
|
defaultValue,
|
|
4099
4130
|
value: controlledValue,
|
|
@@ -4102,7 +4133,7 @@ function Tabs({
|
|
|
4102
4133
|
className,
|
|
4103
4134
|
...props
|
|
4104
4135
|
}) {
|
|
4105
|
-
const [uncontrolledValue, setUncontrolledValue] =
|
|
4136
|
+
const [uncontrolledValue, setUncontrolledValue] = React21.useState(defaultValue || "");
|
|
4106
4137
|
const value = controlledValue ?? uncontrolledValue;
|
|
4107
4138
|
const setValue = onValueChange ?? setUncontrolledValue;
|
|
4108
4139
|
return /* @__PURE__ */ jsx(TabsContext.Provider, { value: { value, onValueChange: setValue }, children: /* @__PURE__ */ jsx("div", { className: cn(className), ...props, children }) });
|
|
@@ -4121,7 +4152,7 @@ function TabsList({ className, children, ...props }) {
|
|
|
4121
4152
|
);
|
|
4122
4153
|
}
|
|
4123
4154
|
function TabsTrigger({ value, className, children, ...props }) {
|
|
4124
|
-
const context =
|
|
4155
|
+
const context = React21.useContext(TabsContext);
|
|
4125
4156
|
const isSelected = context?.value === value;
|
|
4126
4157
|
return /* @__PURE__ */ jsx(
|
|
4127
4158
|
"button",
|
|
@@ -4139,7 +4170,7 @@ function TabsTrigger({ value, className, children, ...props }) {
|
|
|
4139
4170
|
);
|
|
4140
4171
|
}
|
|
4141
4172
|
function TabsContent({ value, className, children, ...props }) {
|
|
4142
|
-
const context =
|
|
4173
|
+
const context = React21.useContext(TabsContext);
|
|
4143
4174
|
const isSelected = context?.value === value;
|
|
4144
4175
|
if (!isSelected) return null;
|
|
4145
4176
|
return /* @__PURE__ */ jsx(
|
|
@@ -4158,7 +4189,7 @@ var TabsContext;
|
|
|
4158
4189
|
var init_tabs = __esm({
|
|
4159
4190
|
"src/ui/tabs.tsx"() {
|
|
4160
4191
|
init_utils();
|
|
4161
|
-
TabsContext =
|
|
4192
|
+
TabsContext = React21.createContext(null);
|
|
4162
4193
|
}
|
|
4163
4194
|
});
|
|
4164
4195
|
function useEditorUploads() {
|
|
@@ -4185,27 +4216,27 @@ function Collapsible({
|
|
|
4185
4216
|
className,
|
|
4186
4217
|
...props
|
|
4187
4218
|
}) {
|
|
4188
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
4219
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React21.useState(false);
|
|
4189
4220
|
const open = controlledOpen ?? uncontrolledOpen;
|
|
4190
4221
|
const setOpen = onOpenChange ?? setUncontrolledOpen;
|
|
4191
4222
|
return /* @__PURE__ */ jsx(CollapsibleContext.Provider, { value: { open, setOpen }, children: /* @__PURE__ */ jsx("div", { className: cn("editor-collapsible", className), "data-state": open ? "open" : "closed", ...props, children }) });
|
|
4192
4223
|
}
|
|
4193
4224
|
function CollapsibleTrigger({ children, asChild, ...props }) {
|
|
4194
|
-
const context =
|
|
4225
|
+
const context = React21.useContext(CollapsibleContext);
|
|
4195
4226
|
if (!context) throw new Error("CollapsibleTrigger must be used within Collapsible");
|
|
4196
4227
|
const handleClick = (e) => {
|
|
4197
4228
|
context.setOpen(!context.open);
|
|
4198
|
-
if (
|
|
4229
|
+
if (React21.isValidElement(children)) {
|
|
4199
4230
|
children.props.onClick?.(e);
|
|
4200
4231
|
}
|
|
4201
4232
|
};
|
|
4202
|
-
if (asChild &&
|
|
4203
|
-
return
|
|
4233
|
+
if (asChild && React21.isValidElement(children)) {
|
|
4234
|
+
return React21.cloneElement(children, { onClick: handleClick, ...props });
|
|
4204
4235
|
}
|
|
4205
4236
|
return /* @__PURE__ */ jsx("button", { type: "button", onClick: handleClick, ...props, children });
|
|
4206
4237
|
}
|
|
4207
4238
|
function CollapsibleContent({ children, className, ...props }) {
|
|
4208
|
-
const context =
|
|
4239
|
+
const context = React21.useContext(CollapsibleContext);
|
|
4209
4240
|
if (!context) throw new Error("CollapsibleContent must be used within Collapsible");
|
|
4210
4241
|
if (!context.open) return null;
|
|
4211
4242
|
return /* @__PURE__ */ jsx("div", { className: cn("editor-overflow-hidden", className), ...props, children });
|
|
@@ -4214,7 +4245,7 @@ var CollapsibleContext;
|
|
|
4214
4245
|
var init_collapsible = __esm({
|
|
4215
4246
|
"src/ui/collapsible.tsx"() {
|
|
4216
4247
|
init_utils();
|
|
4217
|
-
CollapsibleContext =
|
|
4248
|
+
CollapsibleContext = React21.createContext(null);
|
|
4218
4249
|
}
|
|
4219
4250
|
});
|
|
4220
4251
|
function InsertImageUriDialogBody({
|
|
@@ -4329,7 +4360,7 @@ function ImagePickerFolderTree({
|
|
|
4329
4360
|
}) {
|
|
4330
4361
|
const hasContent = folder.images.length > 0 || folder.subfolders.length > 0;
|
|
4331
4362
|
const isOpen = openFolders.has(folder.path);
|
|
4332
|
-
const handleOpenChange =
|
|
4363
|
+
const handleOpenChange = React21.useCallback(
|
|
4333
4364
|
(open) => {
|
|
4334
4365
|
if (open) {
|
|
4335
4366
|
setOpenFolders((prev) => {
|
|
@@ -4409,11 +4440,11 @@ function InsertImageUploadsDialogBody({
|
|
|
4409
4440
|
const [openFolders, setOpenFolders] = useState(/* @__PURE__ */ new Set());
|
|
4410
4441
|
const { folderTree, isLoading } = useEditorUploads();
|
|
4411
4442
|
const isDisabled = !selectedImage;
|
|
4412
|
-
const handleImageSelect =
|
|
4443
|
+
const handleImageSelect = React21.useCallback((imageUrl, originalName) => {
|
|
4413
4444
|
setSelectedImage(imageUrl);
|
|
4414
4445
|
setAltText((prev) => prev || originalName);
|
|
4415
4446
|
}, []);
|
|
4416
|
-
const handleConfirm =
|
|
4447
|
+
const handleConfirm = React21.useCallback(() => {
|
|
4417
4448
|
if (selectedImage) {
|
|
4418
4449
|
let imageUrl = selectedImage;
|
|
4419
4450
|
if (imageUrl.startsWith("/api/uploads")) {
|
|
@@ -4424,7 +4455,7 @@ function InsertImageUploadsDialogBody({
|
|
|
4424
4455
|
onClick({ altText: altText || "", src: imageUrl });
|
|
4425
4456
|
}
|
|
4426
4457
|
}, [selectedImage, altText, onClick]);
|
|
4427
|
-
|
|
4458
|
+
React21.useEffect(() => {
|
|
4428
4459
|
const handleDoubleClickConfirm = () => {
|
|
4429
4460
|
setTimeout(() => {
|
|
4430
4461
|
handleConfirm();
|
|
@@ -4435,7 +4466,7 @@ function InsertImageUploadsDialogBody({
|
|
|
4435
4466
|
document.removeEventListener("confirm-image-insert", handleDoubleClickConfirm);
|
|
4436
4467
|
};
|
|
4437
4468
|
}, [handleConfirm]);
|
|
4438
|
-
|
|
4469
|
+
React21.useEffect(() => {
|
|
4439
4470
|
if (folderTree && folderTree.subfolders.length > 0) {
|
|
4440
4471
|
setOpenFolders(new Set(folderTree.subfolders.map((f) => f.path)));
|
|
4441
4472
|
}
|
|
@@ -4443,7 +4474,7 @@ function InsertImageUploadsDialogBody({
|
|
|
4443
4474
|
return /* @__PURE__ */ jsxs("div", { className: "editor-form-grid", children: [
|
|
4444
4475
|
/* @__PURE__ */ jsxs("div", { className: "editor-form-item", children: [
|
|
4445
4476
|
/* @__PURE__ */ jsx(Label, { children: "Ch\u1ECDn h\xECnh \u1EA3nh t\u1EEB th\u01B0 vi\u1EC7n" }),
|
|
4446
|
-
isLoading ? /* @__PURE__ */ jsx("
|
|
4477
|
+
isLoading ? /* @__PURE__ */ jsx(Flex, { align: "center", justify: "center", className: "editor-py-8", children: /* @__PURE__ */ jsx(Loader2, { className: "editor-loader" }) }) : !folderTree || folderTree.subfolders.length === 0 && folderTree.images.length === 0 ? /* @__PURE__ */ jsx("div", { className: "editor-empty-state", children: /* @__PURE__ */ jsx(TypographySpanSmallMuted, { children: "Ch\u01B0a c\xF3 h\xECnh \u1EA3nh n\xE0o \u0111\u01B0\u1EE3c upload" }) }) : /* @__PURE__ */ jsxs("div", { className: "editor-scroll-area editor-flex editor-flex-col editor-gap-1", children: [
|
|
4447
4478
|
folderTree.images.length > 0 && /* @__PURE__ */ jsxs("div", { className: "editor-mb-3", children: [
|
|
4448
4479
|
/* @__PURE__ */ jsx(TypographySpanSmallMuted, { className: "editor-mb-2 editor-px-1", children: "Root" }),
|
|
4449
4480
|
/* @__PURE__ */ jsx("div", { className: "editor-image-grid editor-gap-2", children: folderTree.images.map((image) => /* @__PURE__ */ jsx(
|
|
@@ -4711,6 +4742,7 @@ var init_images_plugin = __esm({
|
|
|
4711
4742
|
init_dialog();
|
|
4712
4743
|
init_input();
|
|
4713
4744
|
init_label();
|
|
4745
|
+
init_flex();
|
|
4714
4746
|
init_tabs();
|
|
4715
4747
|
init_uploads_context();
|
|
4716
4748
|
init_collapsible();
|
|
@@ -5051,19 +5083,7 @@ function ContentEditable({
|
|
|
5051
5083
|
!isReadOnlyOrReview && "min-h-72 px-8 py-4",
|
|
5052
5084
|
className
|
|
5053
5085
|
),
|
|
5054
|
-
"aria-
|
|
5055
|
-
"aria-label": placeholder || "Editor n\u1ED9i dung",
|
|
5056
|
-
placeholder: /* @__PURE__ */ jsx(
|
|
5057
|
-
"div",
|
|
5058
|
-
{
|
|
5059
|
-
className: cn(
|
|
5060
|
-
placeholderClassName,
|
|
5061
|
-
"text-muted-foreground pointer-events-none select-none",
|
|
5062
|
-
placeholderDefaults && !isReadOnlyOrReview && "absolute top-0 left-0 overflow-hidden px-8 py-[18px] text-ellipsis"
|
|
5063
|
-
),
|
|
5064
|
-
children: placeholder
|
|
5065
|
-
}
|
|
5066
|
-
)
|
|
5086
|
+
"aria-label": "Editor n\u1ED9i dung"
|
|
5067
5087
|
}
|
|
5068
5088
|
);
|
|
5069
5089
|
}
|
|
@@ -5695,7 +5715,7 @@ function $isImageNode(node) {
|
|
|
5695
5715
|
var ImageComponent2, WHITESPACE_REGEX, ImageNode;
|
|
5696
5716
|
var init_image_node = __esm({
|
|
5697
5717
|
"src/nodes/image-node.tsx"() {
|
|
5698
|
-
ImageComponent2 =
|
|
5718
|
+
ImageComponent2 = React21.lazy(() => Promise.resolve().then(() => (init_image_component(), image_component_exports)));
|
|
5699
5719
|
WHITESPACE_REGEX = /[\u200B\u00A0\s]+/g;
|
|
5700
5720
|
ImageNode = class _ImageNode extends DecoratorNode {
|
|
5701
5721
|
__src;
|
|
@@ -6457,7 +6477,7 @@ var Separator;
|
|
|
6457
6477
|
var init_separator = __esm({
|
|
6458
6478
|
"src/ui/separator.tsx"() {
|
|
6459
6479
|
init_utils();
|
|
6460
|
-
Separator =
|
|
6480
|
+
Separator = React21.forwardRef(({ className, orientation = "horizontal", ...props }, ref) => /* @__PURE__ */ jsx(
|
|
6461
6481
|
"div",
|
|
6462
6482
|
{
|
|
6463
6483
|
ref,
|
|
@@ -6474,34 +6494,6 @@ var init_separator = __esm({
|
|
|
6474
6494
|
Separator.displayName = "Separator";
|
|
6475
6495
|
}
|
|
6476
6496
|
});
|
|
6477
|
-
var Flex;
|
|
6478
|
-
var init_flex = __esm({
|
|
6479
|
-
"src/ui/flex.tsx"() {
|
|
6480
|
-
init_utils();
|
|
6481
|
-
Flex = React20.forwardRef(
|
|
6482
|
-
({ className, align, justify, direction, wrap, gap, style, ...props }, ref) => {
|
|
6483
|
-
const gapStyle = typeof gap === "number" ? { gap: `${gap * 0.25}rem` } : typeof gap !== "undefined" ? { gap } : void 0;
|
|
6484
|
-
return /* @__PURE__ */ jsx(
|
|
6485
|
-
"div",
|
|
6486
|
-
{
|
|
6487
|
-
ref,
|
|
6488
|
-
className: cn(
|
|
6489
|
-
"editor-flex",
|
|
6490
|
-
align && `editor-items-${align}`,
|
|
6491
|
-
justify && `editor-justify-${justify}`,
|
|
6492
|
-
direction && `editor-flex-${direction}`,
|
|
6493
|
-
wrap && `editor-flex-${wrap}`,
|
|
6494
|
-
className
|
|
6495
|
-
),
|
|
6496
|
-
style: { ...gapStyle, ...style },
|
|
6497
|
-
...props
|
|
6498
|
-
}
|
|
6499
|
-
);
|
|
6500
|
-
}
|
|
6501
|
-
);
|
|
6502
|
-
Flex.displayName = "Flex";
|
|
6503
|
-
}
|
|
6504
|
-
});
|
|
6505
6497
|
function textEncoder() {
|
|
6506
6498
|
if (window.TextEncoder === void 0) {
|
|
6507
6499
|
return null;
|
|
@@ -6977,7 +6969,7 @@ var ScrollArea, ScrollBar;
|
|
|
6977
6969
|
var init_scroll_area = __esm({
|
|
6978
6970
|
"src/ui/scroll-area.tsx"() {
|
|
6979
6971
|
init_utils();
|
|
6980
|
-
ScrollArea =
|
|
6972
|
+
ScrollArea = React21.forwardRef(
|
|
6981
6973
|
({ className, children, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
6982
6974
|
"div",
|
|
6983
6975
|
{
|
|
@@ -7159,9 +7151,9 @@ var init_code_button = __esm({
|
|
|
7159
7151
|
}
|
|
7160
7152
|
});
|
|
7161
7153
|
function Select({ value, onValueChange, children, disabled }) {
|
|
7162
|
-
const [open, setOpen] =
|
|
7163
|
-
const triggerRef =
|
|
7164
|
-
const contextValue =
|
|
7154
|
+
const [open, setOpen] = React21.useState(false);
|
|
7155
|
+
const triggerRef = React21.useRef(null);
|
|
7156
|
+
const contextValue = React21.useMemo(() => ({
|
|
7165
7157
|
value,
|
|
7166
7158
|
onValueChange,
|
|
7167
7159
|
open,
|
|
@@ -7172,7 +7164,7 @@ function Select({ value, onValueChange, children, disabled }) {
|
|
|
7172
7164
|
return /* @__PURE__ */ jsx(SelectContext.Provider, { value: contextValue, children });
|
|
7173
7165
|
}
|
|
7174
7166
|
function SelectTrigger({ className, children, size = "default", ...props }) {
|
|
7175
|
-
const context =
|
|
7167
|
+
const context = React21.useContext(SelectContext);
|
|
7176
7168
|
if (!context) throw new Error("SelectTrigger must be used within Select");
|
|
7177
7169
|
const { triggerRef, disabled, open, setOpen } = context;
|
|
7178
7170
|
return /* @__PURE__ */ jsxs(
|
|
@@ -7196,15 +7188,15 @@ function SelectTrigger({ className, children, size = "default", ...props }) {
|
|
|
7196
7188
|
);
|
|
7197
7189
|
}
|
|
7198
7190
|
function SelectValue({ placeholder }) {
|
|
7199
|
-
const context =
|
|
7191
|
+
const context = React21.useContext(SelectContext);
|
|
7200
7192
|
if (!context) throw new Error("SelectValue must be used within Select");
|
|
7201
7193
|
return /* @__PURE__ */ jsx("span", { children: context.value || placeholder });
|
|
7202
7194
|
}
|
|
7203
7195
|
function SelectContent({ className, children, ...props }) {
|
|
7204
|
-
const context =
|
|
7205
|
-
const [position, setPosition] =
|
|
7206
|
-
const contentRef =
|
|
7207
|
-
|
|
7196
|
+
const context = React21.useContext(SelectContext);
|
|
7197
|
+
const [position, setPosition] = React21.useState({ top: 0, left: 0, width: 0 });
|
|
7198
|
+
const contentRef = React21.useRef(null);
|
|
7199
|
+
React21.useEffect(() => {
|
|
7208
7200
|
if (context?.open && context.triggerRef.current) {
|
|
7209
7201
|
const rect = context.triggerRef.current.getBoundingClientRect();
|
|
7210
7202
|
setPosition({
|
|
@@ -7246,7 +7238,7 @@ function SelectContent({ className, children, ...props }) {
|
|
|
7246
7238
|
);
|
|
7247
7239
|
}
|
|
7248
7240
|
function SelectItem({ value, children, className, ...props }) {
|
|
7249
|
-
const context =
|
|
7241
|
+
const context = React21.useContext(SelectContext);
|
|
7250
7242
|
if (!context) throw new Error("SelectItem must be used within Select");
|
|
7251
7243
|
const isSelected = context.value === value;
|
|
7252
7244
|
return /* @__PURE__ */ jsxs(
|
|
@@ -7276,7 +7268,7 @@ var SelectContext;
|
|
|
7276
7268
|
var init_select = __esm({
|
|
7277
7269
|
"src/ui/select.tsx"() {
|
|
7278
7270
|
init_utils();
|
|
7279
|
-
SelectContext =
|
|
7271
|
+
SelectContext = React21.createContext(null);
|
|
7280
7272
|
}
|
|
7281
7273
|
});
|
|
7282
7274
|
function getCodeLanguageOptions() {
|
|
@@ -7505,7 +7497,7 @@ var Command, CommandList, CommandGroup, CommandItem;
|
|
|
7505
7497
|
var init_command = __esm({
|
|
7506
7498
|
"src/ui/command.tsx"() {
|
|
7507
7499
|
init_utils();
|
|
7508
|
-
Command =
|
|
7500
|
+
Command = React21.forwardRef(
|
|
7509
7501
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
7510
7502
|
"div",
|
|
7511
7503
|
{
|
|
@@ -7516,7 +7508,7 @@ var init_command = __esm({
|
|
|
7516
7508
|
)
|
|
7517
7509
|
);
|
|
7518
7510
|
Command.displayName = "Command";
|
|
7519
|
-
CommandList =
|
|
7511
|
+
CommandList = React21.forwardRef(
|
|
7520
7512
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
7521
7513
|
"div",
|
|
7522
7514
|
{
|
|
@@ -7527,7 +7519,7 @@ var init_command = __esm({
|
|
|
7527
7519
|
)
|
|
7528
7520
|
);
|
|
7529
7521
|
CommandList.displayName = "CommandList";
|
|
7530
|
-
CommandGroup =
|
|
7522
|
+
CommandGroup = React21.forwardRef(
|
|
7531
7523
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
7532
7524
|
"div",
|
|
7533
7525
|
{
|
|
@@ -7538,7 +7530,7 @@ var init_command = __esm({
|
|
|
7538
7530
|
)
|
|
7539
7531
|
);
|
|
7540
7532
|
CommandGroup.displayName = "CommandGroup";
|
|
7541
|
-
CommandItem =
|
|
7533
|
+
CommandItem = React21.forwardRef(({ className, onSelect, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
7542
7534
|
"div",
|
|
7543
7535
|
{
|
|
7544
7536
|
ref,
|
|
@@ -7874,6 +7866,98 @@ var init_component_picker_menu_plugin = __esm({
|
|
|
7874
7866
|
);
|
|
7875
7867
|
}
|
|
7876
7868
|
});
|
|
7869
|
+
var NumberInput;
|
|
7870
|
+
var init_number_input = __esm({
|
|
7871
|
+
"src/ui/number-input.tsx"() {
|
|
7872
|
+
"use client";
|
|
7873
|
+
init_utils();
|
|
7874
|
+
init_button();
|
|
7875
|
+
init_input();
|
|
7876
|
+
NumberInput = React21.forwardRef(
|
|
7877
|
+
({ value, onValueChange, min = 0, max = 100, step = 1, unit = "px", className, ...props }, ref) => {
|
|
7878
|
+
const timerRef = React21.useRef(null);
|
|
7879
|
+
const intervalRef = React21.useRef(null);
|
|
7880
|
+
const valueRef = React21.useRef(value);
|
|
7881
|
+
React21.useEffect(() => {
|
|
7882
|
+
valueRef.current = value;
|
|
7883
|
+
}, [value]);
|
|
7884
|
+
const updateValue = React21.useCallback((delta) => {
|
|
7885
|
+
onValueChange(Math.min(Math.max(valueRef.current + delta, min), max));
|
|
7886
|
+
}, [onValueChange, min, max]);
|
|
7887
|
+
const startLongPress = (delta) => {
|
|
7888
|
+
updateValue(delta);
|
|
7889
|
+
timerRef.current = setTimeout(() => {
|
|
7890
|
+
intervalRef.current = setInterval(() => {
|
|
7891
|
+
updateValue(delta);
|
|
7892
|
+
}, 50);
|
|
7893
|
+
}, 300);
|
|
7894
|
+
};
|
|
7895
|
+
const stopLongPress = React21.useCallback(() => {
|
|
7896
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
7897
|
+
if (intervalRef.current) clearInterval(intervalRef.current);
|
|
7898
|
+
}, []);
|
|
7899
|
+
const handleBlur = () => {
|
|
7900
|
+
onValueChange(Math.min(Math.max(value, min), max));
|
|
7901
|
+
};
|
|
7902
|
+
React21.useEffect(() => {
|
|
7903
|
+
return () => stopLongPress();
|
|
7904
|
+
}, [stopLongPress]);
|
|
7905
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("editor-number-input-container", className), children: [
|
|
7906
|
+
/* @__PURE__ */ jsx(
|
|
7907
|
+
Button,
|
|
7908
|
+
{
|
|
7909
|
+
variant: "ghost",
|
|
7910
|
+
size: "icon",
|
|
7911
|
+
className: "editor-number-input-btn",
|
|
7912
|
+
onMouseDown: () => startLongPress(-step),
|
|
7913
|
+
onMouseUp: stopLongPress,
|
|
7914
|
+
onMouseLeave: stopLongPress,
|
|
7915
|
+
onTouchStart: () => startLongPress(-step),
|
|
7916
|
+
onTouchEnd: stopLongPress,
|
|
7917
|
+
tabIndex: -1,
|
|
7918
|
+
children: /* @__PURE__ */ jsx(Minus, { size: 14 })
|
|
7919
|
+
}
|
|
7920
|
+
),
|
|
7921
|
+
/* @__PURE__ */ jsxs("div", { className: "editor-number-input-wrapper", children: [
|
|
7922
|
+
/* @__PURE__ */ jsx(
|
|
7923
|
+
Input,
|
|
7924
|
+
{
|
|
7925
|
+
...props,
|
|
7926
|
+
ref,
|
|
7927
|
+
type: "number",
|
|
7928
|
+
value,
|
|
7929
|
+
onBlur: handleBlur,
|
|
7930
|
+
onChange: (e) => {
|
|
7931
|
+
const val = parseInt(e.target.value, 10);
|
|
7932
|
+
if (!isNaN(val)) onValueChange(val);
|
|
7933
|
+
else onValueChange(0);
|
|
7934
|
+
},
|
|
7935
|
+
className: "editor-number-input-field"
|
|
7936
|
+
}
|
|
7937
|
+
),
|
|
7938
|
+
unit && /* @__PURE__ */ jsx("span", { className: "editor-number-input-unit", children: unit })
|
|
7939
|
+
] }),
|
|
7940
|
+
/* @__PURE__ */ jsx(
|
|
7941
|
+
Button,
|
|
7942
|
+
{
|
|
7943
|
+
variant: "ghost",
|
|
7944
|
+
size: "icon",
|
|
7945
|
+
className: "editor-number-input-btn",
|
|
7946
|
+
onMouseDown: () => startLongPress(step),
|
|
7947
|
+
onMouseUp: stopLongPress,
|
|
7948
|
+
onMouseLeave: stopLongPress,
|
|
7949
|
+
onTouchStart: () => startLongPress(step),
|
|
7950
|
+
onTouchEnd: stopLongPress,
|
|
7951
|
+
tabIndex: -1,
|
|
7952
|
+
children: /* @__PURE__ */ jsx(Plus, { size: 14 })
|
|
7953
|
+
}
|
|
7954
|
+
)
|
|
7955
|
+
] });
|
|
7956
|
+
}
|
|
7957
|
+
);
|
|
7958
|
+
NumberInput.displayName = "NumberInput";
|
|
7959
|
+
}
|
|
7960
|
+
});
|
|
7877
7961
|
var Slot;
|
|
7878
7962
|
var init_slot = __esm({
|
|
7879
7963
|
"src/ui/slot.tsx"() {
|
|
@@ -7881,11 +7965,11 @@ var init_slot = __esm({
|
|
|
7881
7965
|
}
|
|
7882
7966
|
});
|
|
7883
7967
|
function Popover({ children, open: controlledOpen, defaultOpen = false, onOpenChange, modal = false }) {
|
|
7884
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
7885
|
-
const triggerRef =
|
|
7968
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React21.useState(defaultOpen);
|
|
7969
|
+
const triggerRef = React21.useRef(null);
|
|
7886
7970
|
const open = controlledOpen ?? uncontrolledOpen;
|
|
7887
7971
|
const setOpen = onOpenChange ?? setUncontrolledOpen;
|
|
7888
|
-
const contextValue =
|
|
7972
|
+
const contextValue = React21.useMemo(() => ({
|
|
7889
7973
|
open,
|
|
7890
7974
|
setOpen,
|
|
7891
7975
|
triggerRef,
|
|
@@ -7894,17 +7978,17 @@ function Popover({ children, open: controlledOpen, defaultOpen = false, onOpenCh
|
|
|
7894
7978
|
return /* @__PURE__ */ jsx(PopoverContext.Provider, { value: contextValue, children });
|
|
7895
7979
|
}
|
|
7896
7980
|
function PopoverTrigger({ children, asChild, ...props }) {
|
|
7897
|
-
const context =
|
|
7981
|
+
const context = React21.useContext(PopoverContext);
|
|
7898
7982
|
if (!context) throw new Error("PopoverTrigger must be used within Popover");
|
|
7899
7983
|
const { triggerRef, open, setOpen } = context;
|
|
7900
7984
|
const handleClick = (e) => {
|
|
7901
7985
|
setOpen(!open);
|
|
7902
|
-
if (
|
|
7986
|
+
if (React21.isValidElement(children)) {
|
|
7903
7987
|
children.props.onClick?.(e);
|
|
7904
7988
|
}
|
|
7905
7989
|
};
|
|
7906
|
-
if (asChild &&
|
|
7907
|
-
return
|
|
7990
|
+
if (asChild && React21.isValidElement(children)) {
|
|
7991
|
+
return React21.cloneElement(children, {
|
|
7908
7992
|
ref: triggerRef,
|
|
7909
7993
|
onClick: handleClick,
|
|
7910
7994
|
...props
|
|
@@ -7922,10 +8006,10 @@ function PopoverTrigger({ children, asChild, ...props }) {
|
|
|
7922
8006
|
);
|
|
7923
8007
|
}
|
|
7924
8008
|
function PopoverContent({ children, className, align = "center", sideOffset = 4, ...props }) {
|
|
7925
|
-
const context =
|
|
7926
|
-
const [position, setPosition] =
|
|
7927
|
-
const contentRef =
|
|
7928
|
-
|
|
8009
|
+
const context = React21.useContext(PopoverContext);
|
|
8010
|
+
const [position, setPosition] = React21.useState({ top: 0, left: 0 });
|
|
8011
|
+
const contentRef = React21.useRef(null);
|
|
8012
|
+
React21.useEffect(() => {
|
|
7929
8013
|
if (context?.open && context.triggerRef.current) {
|
|
7930
8014
|
const rect = context.triggerRef.current.getBoundingClientRect();
|
|
7931
8015
|
let left = rect.left;
|
|
@@ -7975,7 +8059,7 @@ var PopoverContext;
|
|
|
7975
8059
|
var init_popover = __esm({
|
|
7976
8060
|
"src/ui/popover.tsx"() {
|
|
7977
8061
|
init_utils();
|
|
7978
|
-
PopoverContext =
|
|
8062
|
+
PopoverContext = React21.createContext(null);
|
|
7979
8063
|
}
|
|
7980
8064
|
});
|
|
7981
8065
|
function setRef(ref, value) {
|
|
@@ -8011,7 +8095,7 @@ function composeRefs(...refs) {
|
|
|
8011
8095
|
};
|
|
8012
8096
|
}
|
|
8013
8097
|
function useComposedRefs(...refs) {
|
|
8014
|
-
return
|
|
8098
|
+
return React21.useCallback(
|
|
8015
8099
|
(value) => {
|
|
8016
8100
|
composeRefs(...refs)(value);
|
|
8017
8101
|
},
|
|
@@ -8029,19 +8113,19 @@ function VisuallyHiddenInput(props) {
|
|
|
8029
8113
|
style,
|
|
8030
8114
|
...inputProps
|
|
8031
8115
|
} = props;
|
|
8032
|
-
const isCheckInput =
|
|
8116
|
+
const isCheckInput = React21.useMemo(
|
|
8033
8117
|
() => type === "checkbox" || type === "radio" || type === "switch",
|
|
8034
8118
|
[type]
|
|
8035
8119
|
);
|
|
8036
|
-
const inputRef =
|
|
8037
|
-
const prevValueRef =
|
|
8120
|
+
const inputRef = React21.useRef(null);
|
|
8121
|
+
const prevValueRef = React21.useRef({
|
|
8038
8122
|
value: isCheckInput ? checked : value,
|
|
8039
8123
|
previous: isCheckInput ? checked : value
|
|
8040
8124
|
});
|
|
8041
|
-
const [prevValue, setPrevValue] =
|
|
8125
|
+
const [prevValue, setPrevValue] = React21.useState(
|
|
8042
8126
|
isCheckInput ? checked : value
|
|
8043
8127
|
);
|
|
8044
|
-
|
|
8128
|
+
React21.useEffect(() => {
|
|
8045
8129
|
const currentValue = isCheckInput ? checked : value;
|
|
8046
8130
|
if (prevValueRef.current.value !== currentValue) {
|
|
8047
8131
|
prevValueRef.current.previous = prevValueRef.current.value;
|
|
@@ -8049,8 +8133,8 @@ function VisuallyHiddenInput(props) {
|
|
|
8049
8133
|
setPrevValue(prevValueRef.current.previous);
|
|
8050
8134
|
}
|
|
8051
8135
|
}, [isCheckInput, value, checked]);
|
|
8052
|
-
const [controlSize, setControlSize] =
|
|
8053
|
-
|
|
8136
|
+
const [controlSize, setControlSize] = React21.useState({});
|
|
8137
|
+
React21.useLayoutEffect(() => {
|
|
8054
8138
|
if (!control) {
|
|
8055
8139
|
setControlSize({});
|
|
8056
8140
|
return;
|
|
@@ -8082,7 +8166,7 @@ function VisuallyHiddenInput(props) {
|
|
|
8082
8166
|
resizeObserver.disconnect();
|
|
8083
8167
|
};
|
|
8084
8168
|
}, [control]);
|
|
8085
|
-
|
|
8169
|
+
React21.useEffect(() => {
|
|
8086
8170
|
const input = inputRef.current;
|
|
8087
8171
|
if (!input) return;
|
|
8088
8172
|
const inputProto = window.HTMLInputElement.prototype;
|
|
@@ -8098,7 +8182,7 @@ function VisuallyHiddenInput(props) {
|
|
|
8098
8182
|
input.dispatchEvent(event);
|
|
8099
8183
|
}
|
|
8100
8184
|
}, [prevValue, value, checked, bubbles, isCheckInput]);
|
|
8101
|
-
const composedStyle =
|
|
8185
|
+
const composedStyle = React21.useMemo(() => {
|
|
8102
8186
|
return {
|
|
8103
8187
|
...style,
|
|
8104
8188
|
...controlSize.width !== void 0 && controlSize.height !== void 0 ? controlSize : {},
|
|
@@ -8410,11 +8494,11 @@ function parseColorString(value) {
|
|
|
8410
8494
|
return null;
|
|
8411
8495
|
}
|
|
8412
8496
|
function useDirection(dirProp) {
|
|
8413
|
-
const contextDir =
|
|
8497
|
+
const contextDir = React21.useContext(DirectionContext);
|
|
8414
8498
|
return dirProp ?? contextDir ?? "ltr";
|
|
8415
8499
|
}
|
|
8416
8500
|
function useLazyRef(fn) {
|
|
8417
|
-
const ref =
|
|
8501
|
+
const ref = React21.useRef(null);
|
|
8418
8502
|
if (ref.current === null) {
|
|
8419
8503
|
ref.current = fn();
|
|
8420
8504
|
}
|
|
@@ -8488,7 +8572,7 @@ function createColorPickerStore(listenersRef, stateRef, callbacks) {
|
|
|
8488
8572
|
return store;
|
|
8489
8573
|
}
|
|
8490
8574
|
function useColorPickerStoreContext(consumerName) {
|
|
8491
|
-
const context =
|
|
8575
|
+
const context = React21.useContext(ColorPickerStoreContext);
|
|
8492
8576
|
if (!context) {
|
|
8493
8577
|
throw new Error(
|
|
8494
8578
|
`\`${consumerName}\` must be used within \`ColorPickerRoot\``
|
|
@@ -8498,14 +8582,14 @@ function useColorPickerStoreContext(consumerName) {
|
|
|
8498
8582
|
}
|
|
8499
8583
|
function useColorPickerStore(selector) {
|
|
8500
8584
|
const store = useColorPickerStoreContext("useColorPickerStoreSelector");
|
|
8501
|
-
const getSnapshot =
|
|
8585
|
+
const getSnapshot = React21.useCallback(
|
|
8502
8586
|
() => selector(store.getState()),
|
|
8503
8587
|
[store, selector]
|
|
8504
8588
|
);
|
|
8505
|
-
return
|
|
8589
|
+
return React21.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
|
|
8506
8590
|
}
|
|
8507
8591
|
function useColorPickerContext(consumerName) {
|
|
8508
|
-
const context =
|
|
8592
|
+
const context = React21.useContext(ColorPickerContext);
|
|
8509
8593
|
if (!context) {
|
|
8510
8594
|
throw new Error(
|
|
8511
8595
|
`\`${consumerName}\` must be used within \`ColorPickerRoot\``
|
|
@@ -8532,12 +8616,12 @@ function ColorPickerRootImpl(props) {
|
|
|
8532
8616
|
} = props;
|
|
8533
8617
|
const store = useColorPickerStoreContext("ColorPickerRootImpl");
|
|
8534
8618
|
const dir = useDirection(dirProp);
|
|
8535
|
-
const [formTrigger, setFormTrigger] =
|
|
8619
|
+
const [formTrigger, setFormTrigger] = React21.useState(
|
|
8536
8620
|
null
|
|
8537
8621
|
);
|
|
8538
8622
|
const composedRef = useComposedRefs(ref, (node) => setFormTrigger(node));
|
|
8539
8623
|
const isFormControl = formTrigger ? !!formTrigger.closest("form") : true;
|
|
8540
|
-
|
|
8624
|
+
React21.useEffect(() => {
|
|
8541
8625
|
if (valueProp !== void 0) {
|
|
8542
8626
|
const color = parseColorString(valueProp);
|
|
8543
8627
|
if (color) {
|
|
@@ -8547,12 +8631,12 @@ function ColorPickerRootImpl(props) {
|
|
|
8547
8631
|
}
|
|
8548
8632
|
}
|
|
8549
8633
|
}, [valueProp, store]);
|
|
8550
|
-
|
|
8634
|
+
React21.useEffect(() => {
|
|
8551
8635
|
if (openProp !== void 0) {
|
|
8552
8636
|
store.setOpen(openProp);
|
|
8553
8637
|
}
|
|
8554
8638
|
}, [openProp, store]);
|
|
8555
|
-
const contextValue =
|
|
8639
|
+
const contextValue = React21.useMemo(
|
|
8556
8640
|
() => ({
|
|
8557
8641
|
dir,
|
|
8558
8642
|
disabled,
|
|
@@ -8564,7 +8648,7 @@ function ColorPickerRootImpl(props) {
|
|
|
8564
8648
|
);
|
|
8565
8649
|
const value = useColorPickerStore((state) => rgbToHex(state.color));
|
|
8566
8650
|
const open = useColorPickerStore((state) => state.open);
|
|
8567
|
-
const onPopoverOpenChange =
|
|
8651
|
+
const onPopoverOpenChange = React21.useCallback(
|
|
8568
8652
|
(newOpen) => {
|
|
8569
8653
|
store.setOpen(newOpen);
|
|
8570
8654
|
onOpenChange?.(newOpen);
|
|
@@ -8650,10 +8734,10 @@ function ColorPickerArea(props) {
|
|
|
8650
8734
|
const context = useColorPickerContext("ColorPickerArea");
|
|
8651
8735
|
const store = useColorPickerStoreContext("ColorPickerArea");
|
|
8652
8736
|
const hsv = useColorPickerStore((state) => state.hsv);
|
|
8653
|
-
const isDraggingRef =
|
|
8654
|
-
const areaRef =
|
|
8737
|
+
const isDraggingRef = React21.useRef(false);
|
|
8738
|
+
const areaRef = React21.useRef(null);
|
|
8655
8739
|
const composedRef = useComposedRefs(ref, areaRef);
|
|
8656
|
-
const updateColorFromPosition =
|
|
8740
|
+
const updateColorFromPosition = React21.useCallback(
|
|
8657
8741
|
(clientX, clientY) => {
|
|
8658
8742
|
if (!areaRef.current) return;
|
|
8659
8743
|
const rect = areaRef.current.getBoundingClientRect();
|
|
@@ -8670,7 +8754,7 @@ function ColorPickerArea(props) {
|
|
|
8670
8754
|
},
|
|
8671
8755
|
[hsv, store]
|
|
8672
8756
|
);
|
|
8673
|
-
const onPointerDown =
|
|
8757
|
+
const onPointerDown = React21.useCallback(
|
|
8674
8758
|
(event) => {
|
|
8675
8759
|
if (context.disabled) return;
|
|
8676
8760
|
event.preventDefault();
|
|
@@ -8680,7 +8764,7 @@ function ColorPickerArea(props) {
|
|
|
8680
8764
|
},
|
|
8681
8765
|
[context.disabled, updateColorFromPosition]
|
|
8682
8766
|
);
|
|
8683
|
-
const onPointerMove =
|
|
8767
|
+
const onPointerMove = React21.useCallback(
|
|
8684
8768
|
(event) => {
|
|
8685
8769
|
if (isDraggingRef.current) {
|
|
8686
8770
|
updateColorFromPosition(event.clientX, event.clientY);
|
|
@@ -8688,7 +8772,7 @@ function ColorPickerArea(props) {
|
|
|
8688
8772
|
},
|
|
8689
8773
|
[updateColorFromPosition]
|
|
8690
8774
|
);
|
|
8691
|
-
const onPointerUp =
|
|
8775
|
+
const onPointerUp = React21.useCallback((event) => {
|
|
8692
8776
|
isDraggingRef.current = false;
|
|
8693
8777
|
areaRef.current?.releasePointerCapture(event.pointerId);
|
|
8694
8778
|
}, []);
|
|
@@ -8758,7 +8842,7 @@ function ColorPickerHueSlider(props) {
|
|
|
8758
8842
|
const context = useColorPickerContext("ColorPickerHueSlider");
|
|
8759
8843
|
const store = useColorPickerStoreContext("ColorPickerHueSlider");
|
|
8760
8844
|
const hsv = useColorPickerStore((state) => state.hsv);
|
|
8761
|
-
const onValueChange =
|
|
8845
|
+
const onValueChange = React21.useCallback(
|
|
8762
8846
|
(values) => {
|
|
8763
8847
|
const newHsv = {
|
|
8764
8848
|
h: values[0] ?? 0,
|
|
@@ -8798,7 +8882,7 @@ function ColorPickerAlphaSlider(props) {
|
|
|
8798
8882
|
const store = useColorPickerStoreContext("ColorPickerAlphaSlider");
|
|
8799
8883
|
const color = useColorPickerStore((state) => state.color);
|
|
8800
8884
|
const hsv = useColorPickerStore((state) => state.hsv);
|
|
8801
|
-
const onValueChange =
|
|
8885
|
+
const onValueChange = React21.useCallback(
|
|
8802
8886
|
(values) => {
|
|
8803
8887
|
const alpha = (values[0] ?? 0) / 100;
|
|
8804
8888
|
const newColor = { ...color, a: alpha };
|
|
@@ -8857,7 +8941,7 @@ function ColorPickerEyeDropper(props) {
|
|
|
8857
8941
|
const context = useColorPickerContext("ColorPickerEyeDropper");
|
|
8858
8942
|
const store = useColorPickerStoreContext("ColorPickerEyeDropper");
|
|
8859
8943
|
const color = useColorPickerStore((state) => state.color);
|
|
8860
|
-
const onEyeDropper =
|
|
8944
|
+
const onEyeDropper = React21.useCallback(async () => {
|
|
8861
8945
|
if (!window.EyeDropper) return;
|
|
8862
8946
|
try {
|
|
8863
8947
|
const eyeDropper = new window.EyeDropper();
|
|
@@ -8894,7 +8978,7 @@ function ColorPickerFormatSelect(props) {
|
|
|
8894
8978
|
const context = useColorPickerContext("ColorPickerFormatSelector");
|
|
8895
8979
|
const store = useColorPickerStoreContext("ColorPickerFormatSelector");
|
|
8896
8980
|
const format = useColorPickerStore((state) => state.format);
|
|
8897
|
-
const onFormatChange =
|
|
8981
|
+
const onFormatChange = React21.useCallback(
|
|
8898
8982
|
(value) => {
|
|
8899
8983
|
if (colorFormats.includes(value)) {
|
|
8900
8984
|
store.setFormat(value);
|
|
@@ -8931,7 +9015,7 @@ function ColorPickerInput(props) {
|
|
|
8931
9015
|
const color = useColorPickerStore((state) => state.color);
|
|
8932
9016
|
const format = useColorPickerStore((state) => state.format);
|
|
8933
9017
|
const hsv = useColorPickerStore((state) => state.hsv);
|
|
8934
|
-
const onColorChange =
|
|
9018
|
+
const onColorChange = React21.useCallback(
|
|
8935
9019
|
(newColor) => {
|
|
8936
9020
|
const newHsv = rgbToHsv(newColor);
|
|
8937
9021
|
store.setColor(newColor);
|
|
@@ -9013,7 +9097,7 @@ function HexInput(props) {
|
|
|
9013
9097
|
} = props;
|
|
9014
9098
|
const hexValue = rgbToHex(color);
|
|
9015
9099
|
const alphaValue = Math.round((color?.a ?? 1) * 100);
|
|
9016
|
-
const onHexChange =
|
|
9100
|
+
const onHexChange = React21.useCallback(
|
|
9017
9101
|
(event) => {
|
|
9018
9102
|
const value = event.target.value;
|
|
9019
9103
|
const parsedColor = parseColorString(value);
|
|
@@ -9023,7 +9107,7 @@ function HexInput(props) {
|
|
|
9023
9107
|
},
|
|
9024
9108
|
[color, onColorChange]
|
|
9025
9109
|
);
|
|
9026
|
-
const onAlphaChange =
|
|
9110
|
+
const onAlphaChange = React21.useCallback(
|
|
9027
9111
|
(event) => {
|
|
9028
9112
|
const value = Number.parseInt(event.target.value, 10);
|
|
9029
9113
|
if (!Number.isNaN(value) && value >= 0 && value <= 100) {
|
|
@@ -9100,7 +9184,7 @@ function RgbInput(props) {
|
|
|
9100
9184
|
const gValue = Math.round(color?.g ?? 0);
|
|
9101
9185
|
const bValue = Math.round(color?.b ?? 0);
|
|
9102
9186
|
const alphaValue = Math.round((color?.a ?? 1) * 100);
|
|
9103
|
-
const onChannelChange =
|
|
9187
|
+
const onChannelChange = React21.useCallback(
|
|
9104
9188
|
(channel, max, isAlpha = false) => (event) => {
|
|
9105
9189
|
const value = Number.parseInt(event.target.value, 10);
|
|
9106
9190
|
if (!Number.isNaN(value) && value >= 0 && value <= max) {
|
|
@@ -9197,9 +9281,9 @@ function HslInput(props) {
|
|
|
9197
9281
|
className,
|
|
9198
9282
|
...inputProps
|
|
9199
9283
|
} = props;
|
|
9200
|
-
const hsl =
|
|
9284
|
+
const hsl = React21.useMemo(() => rgbToHsl(color), [color]);
|
|
9201
9285
|
const alphaValue = Math.round((color?.a ?? 1) * 100);
|
|
9202
|
-
const onHslChannelChange =
|
|
9286
|
+
const onHslChannelChange = React21.useCallback(
|
|
9203
9287
|
(channel, max) => (event) => {
|
|
9204
9288
|
const value = Number.parseInt(event.target.value, 10);
|
|
9205
9289
|
if (!Number.isNaN(value) && value >= 0 && value <= max) {
|
|
@@ -9210,7 +9294,7 @@ function HslInput(props) {
|
|
|
9210
9294
|
},
|
|
9211
9295
|
[hsl, color, onColorChange]
|
|
9212
9296
|
);
|
|
9213
|
-
const onAlphaChange =
|
|
9297
|
+
const onAlphaChange = React21.useCallback(
|
|
9214
9298
|
(event) => {
|
|
9215
9299
|
const value = Number.parseInt(event.target.value, 10);
|
|
9216
9300
|
if (!Number.isNaN(value) && value >= 0 && value <= 100) {
|
|
@@ -9307,7 +9391,7 @@ function HsbInput(props) {
|
|
|
9307
9391
|
...inputProps
|
|
9308
9392
|
} = props;
|
|
9309
9393
|
const alphaValue = Math.round((hsv?.a ?? 1) * 100);
|
|
9310
|
-
const onHsvChannelChange =
|
|
9394
|
+
const onHsvChannelChange = React21.useCallback(
|
|
9311
9395
|
(channel, max) => (event) => {
|
|
9312
9396
|
const value = Number.parseInt(event.target.value, 10);
|
|
9313
9397
|
if (!Number.isNaN(value) && value >= 0 && value <= max) {
|
|
@@ -9318,7 +9402,7 @@ function HsbInput(props) {
|
|
|
9318
9402
|
},
|
|
9319
9403
|
[hsv, onColorChange]
|
|
9320
9404
|
);
|
|
9321
|
-
const onAlphaChange =
|
|
9405
|
+
const onAlphaChange = React21.useCallback(
|
|
9322
9406
|
(event) => {
|
|
9323
9407
|
const value = Number.parseInt(event.target.value, 10);
|
|
9324
9408
|
if (!Number.isNaN(value) && value >= 0 && value <= 100) {
|
|
@@ -9411,7 +9495,7 @@ function ColorPickerPresets(props) {
|
|
|
9411
9495
|
const context = useColorPickerContext("ColorPickerPresets");
|
|
9412
9496
|
const store = useColorPickerStoreContext("ColorPickerPresets");
|
|
9413
9497
|
const color = useColorPickerStore((state) => state.color);
|
|
9414
|
-
const onPresetClick =
|
|
9498
|
+
const onPresetClick = React21.useCallback(
|
|
9415
9499
|
(hex, alpha) => {
|
|
9416
9500
|
const nextAlpha = alpha ?? (color?.a ?? 1);
|
|
9417
9501
|
const newColor = hexToRgb(hex, nextAlpha);
|
|
@@ -9472,14 +9556,14 @@ var init_color_picker = __esm({
|
|
|
9472
9556
|
// --muted in light theme is #F5F5F5, /50 -> alpha 0.5
|
|
9473
9557
|
{ label: "bg-muted/50", value: "#F5F5F5", alpha: 0.5 }
|
|
9474
9558
|
];
|
|
9475
|
-
DirectionContext =
|
|
9476
|
-
ColorPickerStoreContext =
|
|
9559
|
+
DirectionContext = React21.createContext(void 0);
|
|
9560
|
+
ColorPickerStoreContext = React21.createContext(
|
|
9477
9561
|
null
|
|
9478
9562
|
);
|
|
9479
|
-
ColorPickerContext =
|
|
9563
|
+
ColorPickerContext = React21.createContext(
|
|
9480
9564
|
null
|
|
9481
9565
|
);
|
|
9482
|
-
ColorPickerRoot =
|
|
9566
|
+
ColorPickerRoot = React21.memo(function ColorPickerRoot2(props) {
|
|
9483
9567
|
const {
|
|
9484
9568
|
value: valueProp,
|
|
9485
9569
|
defaultValue = "#000000",
|
|
@@ -9497,7 +9581,7 @@ var init_color_picker = __esm({
|
|
|
9497
9581
|
required,
|
|
9498
9582
|
...rootProps
|
|
9499
9583
|
} = props;
|
|
9500
|
-
const initialColor =
|
|
9584
|
+
const initialColor = React21.useMemo(() => {
|
|
9501
9585
|
const colorString = valueProp ?? defaultValue;
|
|
9502
9586
|
const color = parseColorString(colorString) ?? hexToRgb(defaultValue);
|
|
9503
9587
|
return {
|
|
@@ -9516,7 +9600,7 @@ var init_color_picker = __esm({
|
|
|
9516
9600
|
]);
|
|
9517
9601
|
const stateRef = useLazyRef(() => initialColor);
|
|
9518
9602
|
const listenersRef = useLazyRef(() => /* @__PURE__ */ new Set());
|
|
9519
|
-
const storeCallbacks =
|
|
9603
|
+
const storeCallbacks = React21.useMemo(
|
|
9520
9604
|
() => ({
|
|
9521
9605
|
onColorChange: onValueChange,
|
|
9522
9606
|
onOpenChange,
|
|
@@ -9524,7 +9608,7 @@ var init_color_picker = __esm({
|
|
|
9524
9608
|
}),
|
|
9525
9609
|
[onValueChange, onOpenChange, onFormatChange]
|
|
9526
9610
|
);
|
|
9527
|
-
const store =
|
|
9611
|
+
const store = React21.useMemo(
|
|
9528
9612
|
() => createColorPickerStore(listenersRef, stateRef, storeCallbacks),
|
|
9529
9613
|
[listenersRef, stateRef, storeCallbacks]
|
|
9530
9614
|
);
|
|
@@ -9557,13 +9641,15 @@ function InsertLayoutDialog({
|
|
|
9557
9641
|
const [backgroundColor, setBackgroundColor] = useState(
|
|
9558
9642
|
initialValues?.itemBackgroundColor ?? "#ffffff"
|
|
9559
9643
|
);
|
|
9560
|
-
const [
|
|
9644
|
+
const [paddingXPx, setPaddingXPx] = useState(initialValues?.itemPaddingXPx ?? 12);
|
|
9645
|
+
const [paddingYPx, setPaddingYPx] = useState(initialValues?.itemPaddingYPx ?? 12);
|
|
9561
9646
|
const [borderRadiusPx, setBorderRadiusPx] = useState(
|
|
9562
9647
|
initialValues?.itemBorderRadiusPx ?? 8
|
|
9563
9648
|
);
|
|
9564
9649
|
const layoutRef = useRef(layout);
|
|
9565
9650
|
const backgroundColorRef = useRef(backgroundColor);
|
|
9566
|
-
const
|
|
9651
|
+
const paddingXPxRef = useRef(paddingXPx);
|
|
9652
|
+
const paddingYPxRef = useRef(paddingYPx);
|
|
9567
9653
|
const borderRadiusPxRef = useRef(borderRadiusPx);
|
|
9568
9654
|
useEffect(() => {
|
|
9569
9655
|
layoutRef.current = layout;
|
|
@@ -9572,8 +9658,11 @@ function InsertLayoutDialog({
|
|
|
9572
9658
|
backgroundColorRef.current = backgroundColor;
|
|
9573
9659
|
}, [backgroundColor]);
|
|
9574
9660
|
useEffect(() => {
|
|
9575
|
-
|
|
9576
|
-
}, [
|
|
9661
|
+
paddingXPxRef.current = paddingXPx;
|
|
9662
|
+
}, [paddingXPx]);
|
|
9663
|
+
useEffect(() => {
|
|
9664
|
+
paddingYPxRef.current = paddingYPx;
|
|
9665
|
+
}, [paddingYPx]);
|
|
9577
9666
|
useEffect(() => {
|
|
9578
9667
|
borderRadiusPxRef.current = borderRadiusPx;
|
|
9579
9668
|
}, [borderRadiusPx]);
|
|
@@ -9581,10 +9670,15 @@ function InsertLayoutDialog({
|
|
|
9581
9670
|
backgroundColorRef.current = value;
|
|
9582
9671
|
setBackgroundColor(value);
|
|
9583
9672
|
};
|
|
9584
|
-
const
|
|
9673
|
+
const onPaddingXChange = (next) => {
|
|
9674
|
+
const value = Math.min(Math.max(next, 0), 64);
|
|
9675
|
+
paddingXPxRef.current = value;
|
|
9676
|
+
setPaddingXPx(value);
|
|
9677
|
+
};
|
|
9678
|
+
const onPaddingYChange = (next) => {
|
|
9585
9679
|
const value = Math.min(Math.max(next, 0), 64);
|
|
9586
|
-
|
|
9587
|
-
|
|
9680
|
+
paddingYPxRef.current = value;
|
|
9681
|
+
setPaddingYPx(value);
|
|
9588
9682
|
};
|
|
9589
9683
|
const onBorderRadiusChange = (next) => {
|
|
9590
9684
|
const value = Math.min(Math.max(next, 0), 64);
|
|
@@ -9596,7 +9690,8 @@ function InsertLayoutDialog({
|
|
|
9596
9690
|
const values = {
|
|
9597
9691
|
template: layoutRef.current,
|
|
9598
9692
|
itemBackgroundColor: backgroundColorRef.current,
|
|
9599
|
-
|
|
9693
|
+
itemPaddingXPx: paddingXPxRef.current,
|
|
9694
|
+
itemPaddingYPx: paddingYPxRef.current,
|
|
9600
9695
|
itemBorderRadiusPx: borderRadiusPxRef.current
|
|
9601
9696
|
};
|
|
9602
9697
|
logger.info("[Layout] Submit dialog values", {
|
|
@@ -9611,13 +9706,13 @@ function InsertLayoutDialog({
|
|
|
9611
9706
|
activeEditor.dispatchCommand(INSERT_LAYOUT_COMMAND, values);
|
|
9612
9707
|
onClose();
|
|
9613
9708
|
};
|
|
9614
|
-
return /* @__PURE__ */ jsxs(
|
|
9709
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, children: [
|
|
9615
9710
|
/* @__PURE__ */ jsxs(Select, { onValueChange: setLayout, value: layout, children: [
|
|
9616
9711
|
/* @__PURE__ */ jsx(SelectTrigger, { className: "editor-input-lg editor-w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: buttonLabel }) }),
|
|
9617
9712
|
/* @__PURE__ */ jsx(SelectContent, { className: "editor-w-full", children: LAYOUTS.map(({ label, value }) => /* @__PURE__ */ jsx(SelectItem, { value, children: label }, value)) })
|
|
9618
9713
|
] }),
|
|
9619
9714
|
/* @__PURE__ */ jsxs("div", { className: "editor-layout-dialog-grid", children: [
|
|
9620
|
-
/* @__PURE__ */ jsxs(
|
|
9715
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1.5, children: [
|
|
9621
9716
|
/* @__PURE__ */ jsx("div", { className: "editor-text-xs-muted", children: "Background" }),
|
|
9622
9717
|
/* @__PURE__ */ jsxs(
|
|
9623
9718
|
ColorPickerRoot,
|
|
@@ -9663,47 +9758,39 @@ function InsertLayoutDialog({
|
|
|
9663
9758
|
}
|
|
9664
9759
|
)
|
|
9665
9760
|
] }),
|
|
9666
|
-
/* @__PURE__ */ jsxs(
|
|
9667
|
-
/* @__PURE__ */ jsx("div", { className: "editor-text-xs-muted", children: "Padding (px)" }),
|
|
9761
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1.5, children: [
|
|
9762
|
+
/* @__PURE__ */ jsx("div", { className: "editor-text-xs-muted", children: "Padding X (px)" }),
|
|
9668
9763
|
/* @__PURE__ */ jsx(
|
|
9669
|
-
|
|
9764
|
+
NumberInput,
|
|
9670
9765
|
{
|
|
9671
|
-
type: "number",
|
|
9672
9766
|
min: 0,
|
|
9673
9767
|
max: 64,
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
onChange: (event) => {
|
|
9677
|
-
const next = Number.parseInt(event.target.value, 10);
|
|
9678
|
-
if (Number.isFinite(next)) {
|
|
9679
|
-
onPaddingChange(next);
|
|
9680
|
-
} else {
|
|
9681
|
-
onPaddingChange(0);
|
|
9682
|
-
}
|
|
9683
|
-
},
|
|
9684
|
-
className: "editor-input-lg editor-w-full"
|
|
9768
|
+
value: paddingXPx,
|
|
9769
|
+
onValueChange: onPaddingXChange
|
|
9685
9770
|
}
|
|
9686
9771
|
)
|
|
9687
9772
|
] }),
|
|
9688
|
-
/* @__PURE__ */ jsxs(
|
|
9773
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1.5, children: [
|
|
9774
|
+
/* @__PURE__ */ jsx("div", { className: "editor-text-xs-muted", children: "Padding Y (px)" }),
|
|
9775
|
+
/* @__PURE__ */ jsx(
|
|
9776
|
+
NumberInput,
|
|
9777
|
+
{
|
|
9778
|
+
min: 0,
|
|
9779
|
+
max: 64,
|
|
9780
|
+
value: paddingYPx,
|
|
9781
|
+
onValueChange: onPaddingYChange
|
|
9782
|
+
}
|
|
9783
|
+
)
|
|
9784
|
+
] }),
|
|
9785
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1.5, children: [
|
|
9689
9786
|
/* @__PURE__ */ jsx("div", { className: "editor-text-xs-muted", children: "Border radius (px)" }),
|
|
9690
9787
|
/* @__PURE__ */ jsx(
|
|
9691
|
-
|
|
9788
|
+
NumberInput,
|
|
9692
9789
|
{
|
|
9693
|
-
type: "number",
|
|
9694
9790
|
min: 0,
|
|
9695
9791
|
max: 64,
|
|
9696
|
-
step: 1,
|
|
9697
9792
|
value: borderRadiusPx,
|
|
9698
|
-
|
|
9699
|
-
const next = Number.parseInt(event.target.value, 10);
|
|
9700
|
-
if (Number.isFinite(next)) {
|
|
9701
|
-
onBorderRadiusChange(next);
|
|
9702
|
-
} else {
|
|
9703
|
-
onBorderRadiusChange(0);
|
|
9704
|
-
}
|
|
9705
|
-
},
|
|
9706
|
-
className: "editor-input-lg editor-w-full"
|
|
9793
|
+
onValueChange: onBorderRadiusChange
|
|
9707
9794
|
}
|
|
9708
9795
|
)
|
|
9709
9796
|
] })
|
|
@@ -9754,23 +9841,32 @@ function LayoutPlugin() {
|
|
|
9754
9841
|
if (!value) {
|
|
9755
9842
|
return void 0;
|
|
9756
9843
|
}
|
|
9757
|
-
const
|
|
9758
|
-
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
|
|
9762
|
-
|
|
9844
|
+
const values = value.replace(/!important/gi, "").trim().split(/\s+/);
|
|
9845
|
+
const parsedValues = values.map((v) => {
|
|
9846
|
+
const match = v.match(/^(\d+)px/i);
|
|
9847
|
+
if (!match?.[1]) return null;
|
|
9848
|
+
const parsed = Number.parseInt(match[1], 10);
|
|
9849
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
9850
|
+
}).filter((v) => v !== null);
|
|
9851
|
+
if (parsedValues.length === 0) return void 0;
|
|
9852
|
+
return parsedValues;
|
|
9763
9853
|
};
|
|
9764
9854
|
const buildLayoutItemStyle = ({
|
|
9765
9855
|
itemBackgroundColor,
|
|
9766
|
-
|
|
9856
|
+
itemPaddingXPx,
|
|
9857
|
+
itemPaddingYPx,
|
|
9767
9858
|
itemBorderRadiusPx
|
|
9768
9859
|
}) => {
|
|
9769
9860
|
const itemStyles = [];
|
|
9770
9861
|
if (itemBackgroundColor.trim()) {
|
|
9771
9862
|
itemStyles.push(`background-color: ${itemBackgroundColor.trim()}`);
|
|
9772
9863
|
}
|
|
9773
|
-
itemStyles.push(
|
|
9864
|
+
itemStyles.push(
|
|
9865
|
+
`padding: ${Math.min(Math.max(itemPaddingYPx, 0), 64)}px ${Math.min(
|
|
9866
|
+
Math.max(itemPaddingXPx, 0),
|
|
9867
|
+
64
|
|
9868
|
+
)}px`
|
|
9869
|
+
);
|
|
9774
9870
|
itemStyles.push(
|
|
9775
9871
|
`border-radius: ${Math.min(Math.max(itemBorderRadiusPx, 0), 64)}px`
|
|
9776
9872
|
);
|
|
@@ -9783,7 +9879,10 @@ function LayoutPlugin() {
|
|
|
9783
9879
|
return;
|
|
9784
9880
|
}
|
|
9785
9881
|
const background = values.itemBackgroundColor.trim();
|
|
9786
|
-
const padding = `${Math.min(Math.max(values.
|
|
9882
|
+
const padding = `${Math.min(Math.max(values.itemPaddingYPx, 0), 64)}px ${Math.min(
|
|
9883
|
+
Math.max(values.itemPaddingXPx, 0),
|
|
9884
|
+
64
|
|
9885
|
+
)}px`;
|
|
9787
9886
|
const borderRadius = `${Math.min(Math.max(values.itemBorderRadiusPx, 0), 64)}px`;
|
|
9788
9887
|
if (background) {
|
|
9789
9888
|
element.style.setProperty("background-color", background);
|
|
@@ -9834,14 +9933,17 @@ function LayoutPlugin() {
|
|
|
9834
9933
|
return;
|
|
9835
9934
|
}
|
|
9836
9935
|
const style = layoutItem.getStyle();
|
|
9936
|
+
const paddingValues = extractNumericStyle(style, "padding");
|
|
9937
|
+
const borderRadiusValues = extractNumericStyle(style, "border-radius");
|
|
9837
9938
|
payload = {
|
|
9838
9939
|
containerKey: parentContainer.getKey(),
|
|
9839
9940
|
layoutItemKey: layoutItem.getKey(),
|
|
9840
9941
|
values: {
|
|
9841
9942
|
template: parentContainer.getTemplateColumns(),
|
|
9842
9943
|
itemBackgroundColor: extractStyleValue(style, "background-color") ?? "#ffffff",
|
|
9843
|
-
|
|
9844
|
-
|
|
9944
|
+
itemPaddingXPx: paddingValues?.[1] ?? paddingValues?.[0] ?? 12,
|
|
9945
|
+
itemPaddingYPx: paddingValues?.[0] ?? 12,
|
|
9946
|
+
itemBorderRadiusPx: borderRadiusValues?.[0] ?? 8
|
|
9845
9947
|
}
|
|
9846
9948
|
};
|
|
9847
9949
|
logger.debug("[Layout] Resolved payload from target", payload);
|
|
@@ -9954,11 +10056,13 @@ function LayoutPlugin() {
|
|
|
9954
10056
|
editor.update(() => {
|
|
9955
10057
|
const template = typeof payload === "string" ? payload : payload.template;
|
|
9956
10058
|
const itemBackgroundColor = typeof payload === "string" ? void 0 : payload.itemBackgroundColor?.trim();
|
|
9957
|
-
const
|
|
10059
|
+
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;
|
|
10060
|
+
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;
|
|
9958
10061
|
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;
|
|
9959
10062
|
const itemStyle = buildLayoutItemStyle({
|
|
9960
10063
|
itemBackgroundColor: itemBackgroundColor ?? "#ffffff",
|
|
9961
|
-
|
|
10064
|
+
itemPaddingXPx: itemPaddingXPx ?? 12,
|
|
10065
|
+
itemPaddingYPx: itemPaddingYPx ?? 12,
|
|
9962
10066
|
itemBorderRadiusPx: itemBorderRadiusPx ?? 8
|
|
9963
10067
|
});
|
|
9964
10068
|
const container = $createLayoutContainerNode(template);
|
|
@@ -10029,9 +10133,9 @@ var init_layout_plugin = __esm({
|
|
|
10029
10133
|
init_layout_container_node();
|
|
10030
10134
|
init_layout_item_node();
|
|
10031
10135
|
init_button();
|
|
10136
|
+
init_number_input();
|
|
10032
10137
|
init_select();
|
|
10033
10138
|
init_color_picker();
|
|
10034
|
-
init_input();
|
|
10035
10139
|
init_flex();
|
|
10036
10140
|
init_use_modal();
|
|
10037
10141
|
init_logger();
|
|
@@ -10068,7 +10172,7 @@ function applyListColor(editor) {
|
|
|
10068
10172
|
function ListColorPlugin() {
|
|
10069
10173
|
const [editor] = useLexicalComposerContext();
|
|
10070
10174
|
const [modal, showModal] = useEditorModal();
|
|
10071
|
-
|
|
10175
|
+
React21.useEffect(() => {
|
|
10072
10176
|
const applyColor = (color, listKey) => {
|
|
10073
10177
|
listColorStore.set(listKey, color);
|
|
10074
10178
|
editor.update(() => {
|
|
@@ -10114,7 +10218,7 @@ function ListColorPlugin() {
|
|
|
10114
10218
|
const fromAttr = listEl.getAttribute("data-list-color");
|
|
10115
10219
|
const initialColor = fromStore || fromVar || fromAttr || "#000000";
|
|
10116
10220
|
function ListColorModalContent({ onClose }) {
|
|
10117
|
-
const [color, setColor] =
|
|
10221
|
+
const [color, setColor] = React21.useState(initialColor);
|
|
10118
10222
|
return /* @__PURE__ */ jsx("div", { className: "editor-list-color-dialog", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, children: [
|
|
10119
10223
|
/* @__PURE__ */ 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." }),
|
|
10120
10224
|
/* @__PURE__ */ jsx(
|
|
@@ -28570,10 +28674,10 @@ var ToggleGroupContext, ToggleGroup, ToggleGroupItem;
|
|
|
28570
28674
|
var init_toggle_group = __esm({
|
|
28571
28675
|
"src/ui/toggle-group.tsx"() {
|
|
28572
28676
|
init_utils();
|
|
28573
|
-
ToggleGroupContext =
|
|
28574
|
-
ToggleGroup =
|
|
28677
|
+
ToggleGroupContext = React21.createContext(null);
|
|
28678
|
+
ToggleGroup = React21.forwardRef(
|
|
28575
28679
|
({ className, type = "single", value, onValueChange, children, size, variant, ...props }, ref) => {
|
|
28576
|
-
const contextValue =
|
|
28680
|
+
const contextValue = React21.useMemo(() => ({
|
|
28577
28681
|
type,
|
|
28578
28682
|
value: value || (type === "multiple" ? [] : ""),
|
|
28579
28683
|
onValueChange: (val) => {
|
|
@@ -28590,8 +28694,8 @@ var init_toggle_group = __esm({
|
|
|
28590
28694
|
}
|
|
28591
28695
|
);
|
|
28592
28696
|
ToggleGroup.displayName = "ToggleGroup";
|
|
28593
|
-
ToggleGroupItem =
|
|
28594
|
-
const context =
|
|
28697
|
+
ToggleGroupItem = React21.forwardRef(({ className, value, onClick, size: itemSize, variant: itemVariant, ...props }, ref) => {
|
|
28698
|
+
const context = React21.useContext(ToggleGroupContext);
|
|
28595
28699
|
const size = itemSize || context?.size || "default";
|
|
28596
28700
|
if (!context) {
|
|
28597
28701
|
return /* @__PURE__ */ jsx(
|
|
@@ -32187,7 +32291,7 @@ var Toggle;
|
|
|
32187
32291
|
var init_toggle = __esm({
|
|
32188
32292
|
"src/ui/toggle.tsx"() {
|
|
32189
32293
|
init_utils();
|
|
32190
|
-
Toggle =
|
|
32294
|
+
Toggle = React21.forwardRef(({ className, pressed, onPressedChange, variant = "default", size = "default", ...props }, ref) => /* @__PURE__ */ jsx(
|
|
32191
32295
|
"button",
|
|
32192
32296
|
{
|
|
32193
32297
|
ref,
|
|
@@ -32933,11 +33037,13 @@ function Plugins({
|
|
|
32933
33037
|
contentEditable: /* @__PURE__ */ jsx("div", { className: cn("editor-relative-full"), children: /* @__PURE__ */ jsx("div", { className: cn("editor-relative-full"), ref: onRef, children: /* @__PURE__ */ jsx(
|
|
32934
33038
|
ContentEditable,
|
|
32935
33039
|
{
|
|
32936
|
-
placeholder:
|
|
33040
|
+
placeholder: "",
|
|
32937
33041
|
className: cn(
|
|
32938
33042
|
"editor-content-editable",
|
|
32939
33043
|
readOnly && "editor-content-editable--readonly"
|
|
32940
|
-
)
|
|
33044
|
+
),
|
|
33045
|
+
placeholderClassName: "editor-placeholder",
|
|
33046
|
+
placeholderDefaults: false
|
|
32941
33047
|
}
|
|
32942
33048
|
) }) }),
|
|
32943
33049
|
ErrorBoundary: LexicalErrorBoundary,
|
|
@@ -33048,9 +33154,9 @@ function Plugins({
|
|
|
33048
33154
|
] })
|
|
33049
33155
|
] }),
|
|
33050
33156
|
!readOnly && /* @__PURE__ */ jsx(ActionsPlugin, { children: /* @__PURE__ */ jsxs("div", { className: "editor-actions-bar", children: [
|
|
33051
|
-
/* @__PURE__ */ jsx("
|
|
33157
|
+
/* @__PURE__ */ jsx(Flex, { align: "center", className: "editor-flex-shrink-0", children: /* @__PURE__ */ jsx(CounterCharacterPlugin, { charset: "UTF-16" }) }),
|
|
33052
33158
|
/* @__PURE__ */ jsx("div", { className: "editor-flex-1" }),
|
|
33053
|
-
/* @__PURE__ */ jsxs("
|
|
33159
|
+
/* @__PURE__ */ jsxs(Flex, { align: "center", justify: "end", gap: 1, wrap: "nowrap", className: "editor-flex-shrink-0", children: [
|
|
33054
33160
|
/* @__PURE__ */ jsx(SpeechToTextPlugin, {}),
|
|
33055
33161
|
/* @__PURE__ */ jsx(ShareContentPlugin, {}),
|
|
33056
33162
|
/* @__PURE__ */ jsx(ImportExportPlugin, {}),
|
|
@@ -33168,6 +33274,7 @@ var init_plugins = __esm({
|
|
|
33168
33274
|
init_markdown_tweet_transformer();
|
|
33169
33275
|
init_markdown_list_transformer();
|
|
33170
33276
|
init_separator();
|
|
33277
|
+
init_flex();
|
|
33171
33278
|
}
|
|
33172
33279
|
});
|
|
33173
33280
|
|