@thangph2146/lexical-editor 0.0.6 → 0.0.7

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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var React20 = require('react');
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 React20__namespace = /*#__PURE__*/_interopNamespace(React20);
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 ? React20__namespace.Children.only(children) : children;
121
- if (!React20__namespace.isValidElement(child)) return null;
122
- return React20__namespace.cloneElement(child, {
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" ? React20.useLayoutEffect : React20.useEffect;
157
+ useIsomorphicLayoutEffect = typeof window !== "undefined" ? React21.useLayoutEffect : React21.useEffect;
158
158
  }
159
159
  });
160
160
  function useElementSize() {
161
- const [node, setNode] = React20.useState(null);
162
- const [size, setSize] = React20.useState({
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 = React20.useCallback(() => {
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 React20.useContext(EditorContainerContext);
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 = React20.createContext(
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 React20.useCallback((searchText) => {
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
- React20.useEffect(() => {
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 = React20.useRef(null);
2846
- const previousTweetIDRef = React20.useRef("");
2847
- const [isTweetLoading, setIsTweetLoading] = React20.useState(false);
2848
- const createTweet = React20.useCallback(async () => {
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
- React20.useEffect(() => {
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 = React20__namespace.forwardRef(
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 (React20__namespace.isValidElement(children)) {
3134
- return React20__namespace.cloneElement(children, {
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 = React20__namespace.forwardRef(
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 = React20__namespace.forwardRef(
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 = React20__namespace.forwardRef(
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 = React20.useRef(null);
3178
- const userSelect = React20.useRef({
3177
+ const controlWrapperRef = React21.useRef(null);
3178
+ const userSelect = React21.useRef({
3179
3179
  priority: "",
3180
3180
  value: "default"
3181
3181
  });
3182
- const positioningRef = React20.useRef({
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
- React20__namespace.useEffect(() => {
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] = React20__namespace.useState(false);
3548
- const wrapperRef = React20__namespace.useRef(null);
3549
- const [wrapperElement, setWrapperElement] = React20__namespace.useState(null);
3550
- const buttonRef = React20__namespace.useRef(null);
3551
- const [containerWidth, setContainerWidth] = React20__namespace.useState(maxWidth);
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 = React20__namespace.useCallback(
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 = React20__namespace.useCallback(
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
- React20__namespace.useEffect(() => {
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
- React20__namespace.useEffect(() => {
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 = React20__namespace.useCallback((node) => {
3645
+ const handleWrapperRef = React21__namespace.useCallback((node) => {
3646
3646
  wrapperRef.current = node;
3647
3647
  setWrapperElement(node);
3648
3648
  }, []);
3649
- React20__namespace.useEffect(() => {
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
- React20__namespace.useEffect(() => {
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 = React20__namespace.useContext(DialogContext);
3980
+ const context = React21__namespace.useContext(DialogContext);
3981
3981
  const handleClick = (e) => {
3982
3982
  context?.onOpenChange(true);
3983
- if (React20__namespace.isValidElement(children)) {
3983
+ if (React21__namespace.isValidElement(children)) {
3984
3984
  children.props.onClick?.(e);
3985
3985
  }
3986
3986
  };
3987
- if (asChild && React20__namespace.isValidElement(children)) {
3988
- return React20__namespace.cloneElement(children, {
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 = React20__namespace.useContext(DialogContext);
3996
+ const context = React21__namespace.useContext(DialogContext);
3997
3997
  const handleClick = (e) => {
3998
3998
  context?.onOpenChange(false);
3999
- if (React20__namespace.isValidElement(children)) {
3999
+ if (React21__namespace.isValidElement(children)) {
4000
4000
  children.props.onClick?.(e);
4001
4001
  }
4002
4002
  };
4003
- if (asChild && React20__namespace.isValidElement(children)) {
4004
- return React20__namespace.cloneElement(children, {
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 = React20__namespace.useContext(DialogContext);
4013
- const [mounted, setMounted] = React20__namespace.useState(false);
4014
- React20__namespace.useEffect(() => {
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 = React20__namespace.createContext(null);
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 = React20__namespace.forwardRef(
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 = React20__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
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] = React20__namespace.useState(defaultValue || "");
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 = React20__namespace.useContext(TabsContext);
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 = React20__namespace.useContext(TabsContext);
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 = React20__namespace.createContext(null);
4218
+ TabsContext = React21__namespace.createContext(null);
4188
4219
  }
4189
4220
  });
4190
4221
  function useEditorUploads() {
4191
- const context = React20.useContext(EditorUploadsContext);
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 = React20.createContext(void 0);
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] = React20__namespace.useState(false);
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 = React20__namespace.useContext(CollapsibleContext);
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 (React20__namespace.isValidElement(children)) {
4255
+ if (React21__namespace.isValidElement(children)) {
4225
4256
  children.props.onClick?.(e);
4226
4257
  }
4227
4258
  };
4228
- if (asChild && React20__namespace.isValidElement(children)) {
4229
- return React20__namespace.cloneElement(children, { onClick: handleClick, ...props });
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 = React20__namespace.useContext(CollapsibleContext);
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 = React20__namespace.createContext(null);
4274
+ CollapsibleContext = React21__namespace.createContext(null);
4244
4275
  }
4245
4276
  });
4246
4277
  function InsertImageUriDialogBody({
4247
4278
  onClick
4248
4279
  }) {
4249
- const [src, setSrc] = React20.useState("");
4250
- const [altText, setAltText] = React20.useState("");
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] = React20.useState("");
4295
- const [altText, setAltText] = React20.useState("");
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 = React20__namespace.useCallback(
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] = React20.useState(null);
4434
- const [altText, setAltText] = React20.useState("");
4435
- const [openFolders, setOpenFolders] = React20.useState(/* @__PURE__ */ new Set());
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 = React20__namespace.useCallback((imageUrl, originalName) => {
4469
+ const handleImageSelect = React21__namespace.useCallback((imageUrl, originalName) => {
4439
4470
  setSelectedImage(imageUrl);
4440
4471
  setAltText((prev) => prev || originalName);
4441
4472
  }, []);
4442
- const handleConfirm = React20__namespace.useCallback(() => {
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
- React20__namespace.useEffect(() => {
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
- React20__namespace.useEffect(() => {
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("div", { className: "editor-flex-center-justify-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: [
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 = React20.useRef(false);
4552
- React20.useEffect(() => {
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
- React20.useEffect(() => {
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 = React20.createContext(null);
4753
- usePriorityImage = () => React20.useContext(PriorityImageContext);
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] = React20.useState({
4798
+ const [dimensions, setDimensions] = React21.useState({
4767
4799
  width,
4768
4800
  height
4769
4801
  });
4770
- React20.useEffect(() => {
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] = React20.useState(
4954
+ const [actualDimensions, setActualDimensions] = React21.useState(
4923
4955
  cachedDims || DEFAULT_DIMENSIONS
4924
4956
  );
4925
- const wrapperRef = React20.useRef(null);
4926
- React20.useEffect(() => {
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) {
@@ -5133,11 +5165,11 @@ function useImageCaptionControls({
5133
5165
  nodeKey,
5134
5166
  showCaption
5135
5167
  }) {
5136
- const [hasCaptionContent, setHasCaptionContent] = React20.useState(false);
5137
- const [localShowCaption, setLocalShowCaption] = React20.useState(showCaption);
5138
- const isUpdatingCaptionRef = React20.useRef(false);
5139
- const lastShowCaptionRef = React20.useRef(showCaption);
5140
- React20.useEffect(() => {
5168
+ const [hasCaptionContent, setHasCaptionContent] = React21.useState(false);
5169
+ const [localShowCaption, setLocalShowCaption] = React21.useState(showCaption);
5170
+ const isUpdatingCaptionRef = React21.useRef(false);
5171
+ const lastShowCaptionRef = React21.useRef(showCaption);
5172
+ React21.useEffect(() => {
5141
5173
  let timeout = null;
5142
5174
  timeout = setTimeout(() => {
5143
5175
  if (!showCaption) {
@@ -5155,7 +5187,7 @@ function useImageCaptionControls({
5155
5187
  }
5156
5188
  };
5157
5189
  }, [showCaption]);
5158
- const setShowCaption = React20.useCallback(
5190
+ const setShowCaption = React21.useCallback(
5159
5191
  (show) => {
5160
5192
  isUpdatingCaptionRef.current = true;
5161
5193
  lastShowCaptionRef.current = show;
@@ -5178,7 +5210,7 @@ function useImageCaptionControls({
5178
5210
  },
5179
5211
  [caption, editor, nodeKey]
5180
5212
  );
5181
- React20.useEffect(() => {
5213
+ React21.useEffect(() => {
5182
5214
  const computeHasContent = () => {
5183
5215
  const state = caption.getEditorState();
5184
5216
  const hasContent = state.read(() => {
@@ -5227,10 +5259,10 @@ function useImageNodeInteractions({
5227
5259
  nodeKey,
5228
5260
  showCaption
5229
5261
  }) {
5230
- const [selection, setSelection] = React20.useState(null);
5262
+ const [selection, setSelection] = React21.useState(null);
5231
5263
  const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection.useLexicalNodeSelection(nodeKey);
5232
- const activeEditorRef = React20.useRef(null);
5233
- const $onDelete = React20.useCallback(
5264
+ const activeEditorRef = React21.useRef(null);
5265
+ const $onDelete = React21.useCallback(
5234
5266
  (payload) => {
5235
5267
  const deleteSelection = lexical.$getSelection();
5236
5268
  if (isSelected && lexical.$isNodeSelection(deleteSelection)) {
@@ -5249,7 +5281,7 @@ function useImageNodeInteractions({
5249
5281
  },
5250
5282
  [editor, isSelected]
5251
5283
  );
5252
- const $onEnter = React20.useCallback(
5284
+ const $onEnter = React21.useCallback(
5253
5285
  (event) => {
5254
5286
  const latestSelection = lexical.$getSelection();
5255
5287
  const buttonElem = buttonRef.current;
@@ -5269,7 +5301,7 @@ function useImageNodeInteractions({
5269
5301
  },
5270
5302
  [buttonRef, caption, isSelected, showCaption]
5271
5303
  );
5272
- const $onEscape = React20.useCallback(
5304
+ const $onEscape = React21.useCallback(
5273
5305
  (event) => {
5274
5306
  if (activeEditorRef.current === caption || buttonRef.current === event.target) {
5275
5307
  lexical.$setSelection(null);
@@ -5286,7 +5318,7 @@ function useImageNodeInteractions({
5286
5318
  },
5287
5319
  [buttonRef, caption, editor, setSelected]
5288
5320
  );
5289
- const onClick = React20.useCallback(
5321
+ const onClick = React21.useCallback(
5290
5322
  (payload) => {
5291
5323
  const event = payload;
5292
5324
  if (isResizing) {
@@ -5305,7 +5337,7 @@ function useImageNodeInteractions({
5305
5337
  },
5306
5338
  [clearSelection, imageRef, isResizing, isSelected, setSelected]
5307
5339
  );
5308
- const onRightClick = React20.useCallback(
5340
+ const onRightClick = React21.useCallback(
5309
5341
  (event) => {
5310
5342
  editor.getEditorState().read(() => {
5311
5343
  const latestSelection = lexical.$getSelection();
@@ -5320,7 +5352,7 @@ function useImageNodeInteractions({
5320
5352
  },
5321
5353
  [editor]
5322
5354
  );
5323
- React20.useEffect(() => {
5355
+ React21.useEffect(() => {
5324
5356
  let isMounted = true;
5325
5357
  const rootElement = editor.getRootElement();
5326
5358
  const unregister = utils.mergeRegister(
@@ -5424,13 +5456,13 @@ function ImageComponent({
5424
5456
  src,
5425
5457
  width
5426
5458
  }) {
5427
- const imageRef = React20.useRef(null);
5428
- const buttonRef = React20.useRef(null);
5429
- const [isResizing, setIsResizing] = React20.useState(false);
5430
- const resizeTimeoutRef = React20.useRef(null);
5459
+ const imageRef = React21.useRef(null);
5460
+ const buttonRef = React21.useRef(null);
5461
+ const [isResizing, setIsResizing] = React21.useState(false);
5462
+ const resizeTimeoutRef = React21.useRef(null);
5431
5463
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
5432
- const [isLoadError, setIsLoadError] = React20.useState(false);
5433
- const [isReplaceDialogOpen, setIsReplaceDialogOpen] = React20.useState(false);
5464
+ const [isLoadError, setIsLoadError] = React21.useState(false);
5465
+ const [isReplaceDialogOpen, setIsReplaceDialogOpen] = React21.useState(false);
5434
5466
  const isEditable = useLexicalEditable.useLexicalEditable();
5435
5467
  const editorContainer = useEditorContainer();
5436
5468
  const prioritySrc = usePriorityImage();
@@ -5464,21 +5496,21 @@ function ImageComponent({
5464
5496
  nodeKey,
5465
5497
  showCaption
5466
5498
  });
5467
- React20.useEffect(() => {
5499
+ React21.useEffect(() => {
5468
5500
  if (!isEditable && isReplaceDialogOpen) {
5469
5501
  setTimeout(() => {
5470
5502
  setIsReplaceDialogOpen(false);
5471
5503
  }, 0);
5472
5504
  }
5473
5505
  }, [isEditable, isReplaceDialogOpen]);
5474
- React20.useEffect(() => {
5506
+ React21.useEffect(() => {
5475
5507
  return () => {
5476
5508
  if (resizeTimeoutRef.current) {
5477
5509
  clearTimeout(resizeTimeoutRef.current);
5478
5510
  }
5479
5511
  };
5480
5512
  }, []);
5481
- const onResizeEnd = React20.useCallback(
5513
+ const onResizeEnd = React21.useCallback(
5482
5514
  (nextWidth, nextHeight) => {
5483
5515
  if (resizeTimeoutRef.current) {
5484
5516
  clearTimeout(resizeTimeoutRef.current);
@@ -5495,7 +5527,7 @@ function ImageComponent({
5495
5527
  },
5496
5528
  [editor, nodeKey]
5497
5529
  );
5498
- const onResizeStart = React20.useCallback(() => {
5530
+ const onResizeStart = React21.useCallback(() => {
5499
5531
  setIsResizing(true);
5500
5532
  editor.update(() => {
5501
5533
  const node = lexical.$getNodeByKey(nodeKey);
@@ -5504,7 +5536,7 @@ function ImageComponent({
5504
5536
  }
5505
5537
  });
5506
5538
  }, [editor, nodeKey]);
5507
- React20.useEffect(() => {
5539
+ React21.useEffect(() => {
5508
5540
  const element = editor.getElementByKey(nodeKey);
5509
5541
  if (element) {
5510
5542
  if (fullWidth) {
@@ -5516,7 +5548,7 @@ function ImageComponent({
5516
5548
  }
5517
5549
  }
5518
5550
  }, [editor, nodeKey, fullWidth]);
5519
- const onSetFullWidth = React20.useCallback(() => {
5551
+ const onSetFullWidth = React21.useCallback(() => {
5520
5552
  editor.update(() => {
5521
5553
  const node = lexical.$getNodeByKey(nodeKey);
5522
5554
  if ($isImageNode(node)) {
@@ -5524,13 +5556,13 @@ function ImageComponent({
5524
5556
  }
5525
5557
  });
5526
5558
  }, [editor, fullWidth, nodeKey]);
5527
- const onAlign = React20.useCallback(
5559
+ const onAlign = React21.useCallback(
5528
5560
  (format) => {
5529
5561
  editor.dispatchCommand(lexical.FORMAT_ELEMENT_COMMAND, format);
5530
5562
  },
5531
5563
  [editor]
5532
5564
  );
5533
- const handleReplaceImage = React20.useCallback(
5565
+ const handleReplaceImage = React21.useCallback(
5534
5566
  (payload) => {
5535
5567
  if (!payload?.src) {
5536
5568
  return;
@@ -5548,7 +5580,7 @@ function ImageComponent({
5548
5580
  },
5549
5581
  [editor, nodeKey]
5550
5582
  );
5551
- const onDelete = React20.useCallback(() => {
5583
+ const onDelete = React21.useCallback(() => {
5552
5584
  editor.update(() => {
5553
5585
  const node = lexical.$getNodeByKey(nodeKey);
5554
5586
  if ($isImageNode(node)) {
@@ -5570,7 +5602,7 @@ function ImageComponent({
5570
5602
  isEditable ? "editable" : "readonly"
5571
5603
  );
5572
5604
  return /* @__PURE__ */ jsxRuntime.jsx(
5573
- React20.Suspense,
5605
+ React21.Suspense,
5574
5606
  {
5575
5607
  fallback: /* @__PURE__ */ jsxRuntime.jsx("div", { draggable, children: /* @__PURE__ */ jsxRuntime.jsx(
5576
5608
  ImagePlaceholder,
@@ -5721,7 +5753,7 @@ function $isImageNode(node) {
5721
5753
  var ImageComponent2, WHITESPACE_REGEX, ImageNode;
5722
5754
  var init_image_node = __esm({
5723
5755
  "src/nodes/image-node.tsx"() {
5724
- ImageComponent2 = React20__namespace.lazy(() => Promise.resolve().then(() => (init_image_component(), image_component_exports)));
5756
+ ImageComponent2 = React21__namespace.lazy(() => Promise.resolve().then(() => (init_image_component(), image_component_exports)));
5725
5757
  WHITESPACE_REGEX = /[\u200B\u00A0\s]+/g;
5726
5758
  ImageNode = class _ImageNode extends lexical.DecoratorNode {
5727
5759
  __src;
@@ -5864,7 +5896,7 @@ var init_image_node = __esm({
5864
5896
  return this.__altText;
5865
5897
  }
5866
5898
  decorate() {
5867
- return /* @__PURE__ */ jsxRuntime.jsx(React20.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(
5899
+ return /* @__PURE__ */ jsxRuntime.jsx(React21.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(
5868
5900
  ImageComponent2,
5869
5901
  {
5870
5902
  src: this.__src,
@@ -6384,7 +6416,7 @@ var init_actions_plugin = __esm({
6384
6416
  });
6385
6417
  function AlignPlugin() {
6386
6418
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
6387
- React20.useEffect(() => {
6419
+ React21.useEffect(() => {
6388
6420
  const config = editor._config;
6389
6421
  if (config.theme && !config.theme.textAlign) {
6390
6422
  config.theme.textAlign = {
@@ -6483,7 +6515,7 @@ var Separator;
6483
6515
  var init_separator = __esm({
6484
6516
  "src/ui/separator.tsx"() {
6485
6517
  init_utils();
6486
- Separator = React20__namespace.forwardRef(({ className, orientation = "horizontal", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
6518
+ Separator = React21__namespace.forwardRef(({ className, orientation = "horizontal", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
6487
6519
  "div",
6488
6520
  {
6489
6521
  ref,
@@ -6500,34 +6532,6 @@ var init_separator = __esm({
6500
6532
  Separator.displayName = "Separator";
6501
6533
  }
6502
6534
  });
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
6535
  function textEncoder() {
6532
6536
  if (window.TextEncoder === void 0) {
6533
6537
  return null;
@@ -6549,14 +6553,14 @@ function CounterCharacterPlugin({
6549
6553
  charset = "UTF-16"
6550
6554
  }) {
6551
6555
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
6552
- const [stats, setStats] = React20.useState(() => {
6556
+ const [stats, setStats] = React21.useState(() => {
6553
6557
  const initialText = editor.getEditorState().read(text.$rootTextContent);
6554
6558
  return {
6555
6559
  characters: strlen(initialText, charset),
6556
6560
  words: countWords(initialText)
6557
6561
  };
6558
6562
  });
6559
- React20.useEffect(() => {
6563
+ React21.useEffect(() => {
6560
6564
  return editor.registerTextContentListener((currentText) => {
6561
6565
  setStats({
6562
6566
  characters: strlen(currentText, charset),
@@ -6598,7 +6602,7 @@ var init_counter_character_plugin = __esm({
6598
6602
  });
6599
6603
  function EditModeTogglePlugin() {
6600
6604
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
6601
- const [isEditable, setIsEditable] = React20.useState(() => editor.isEditable());
6605
+ const [isEditable, setIsEditable] = React21.useState(() => editor.isEditable());
6602
6606
  return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
6603
6607
  /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
6604
6608
  Button,
@@ -6677,7 +6681,7 @@ function MarkdownTogglePlugin({
6677
6681
  transformers
6678
6682
  }) {
6679
6683
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
6680
- const handleMarkdownToggle = React20.useCallback(() => {
6684
+ const handleMarkdownToggle = React21.useCallback(() => {
6681
6685
  editor.update(() => {
6682
6686
  const root = lexical.$getRoot();
6683
6687
  const firstChild = root.getFirstChild();
@@ -6796,7 +6800,7 @@ function ShareContentPlugin() {
6796
6800
  window.history.replaceState({}, "", newUrl);
6797
6801
  await window.navigator.clipboard.writeText(newUrl);
6798
6802
  }
6799
- React20.useEffect(() => {
6803
+ React21.useEffect(() => {
6800
6804
  docFromHash(window.location.hash).then((doc) => {
6801
6805
  if (doc && doc.source === "editor") {
6802
6806
  editor.setEditorState(file.editorStateFromSerializedDocument(editor, doc));
@@ -6837,8 +6841,8 @@ var init_share_content_plugin = __esm({
6837
6841
  }
6838
6842
  });
6839
6843
  function useReport() {
6840
- const timer = React20.useRef(null);
6841
- const cleanup = React20.useCallback(() => {
6844
+ const timer = React21.useRef(null);
6845
+ const cleanup = React21.useCallback(() => {
6842
6846
  if (timer.current !== null) {
6843
6847
  clearTimeout(timer.current);
6844
6848
  timer.current = null;
@@ -6847,10 +6851,10 @@ function useReport() {
6847
6851
  document.body.removeChild(getElement());
6848
6852
  }
6849
6853
  }, []);
6850
- React20.useEffect(() => {
6854
+ React21.useEffect(() => {
6851
6855
  return cleanup;
6852
6856
  }, [cleanup]);
6853
- return React20.useCallback(
6857
+ return React21.useCallback(
6854
6858
  (content) => {
6855
6859
  logger.debug("Report content", { content });
6856
6860
  const element = getElement();
@@ -6891,13 +6895,13 @@ var init_use_report = __esm({
6891
6895
  });
6892
6896
  function SpeechToTextPluginImpl() {
6893
6897
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
6894
- const [isEnabled, setIsEnabled] = React20.useState(false);
6895
- const [isSpeechToText, setIsSpeechToText] = React20.useState(false);
6898
+ const [isEnabled, setIsEnabled] = React21.useState(false);
6899
+ const [isSpeechToText, setIsSpeechToText] = React21.useState(false);
6896
6900
  const SpeechRecognition = CAN_USE_DOM && // eslint-disable-next-line @typescript-eslint/no-explicit-any
6897
6901
  (window.SpeechRecognition || window.webkitSpeechRecognition);
6898
- const recognition = React20.useRef(null);
6902
+ const recognition = React21.useRef(null);
6899
6903
  const report = useReport();
6900
- React20.useEffect(() => {
6904
+ React21.useEffect(() => {
6901
6905
  if (isEnabled && recognition.current === null) {
6902
6906
  recognition.current = new SpeechRecognition();
6903
6907
  recognition.current.continuous = true;
@@ -6943,7 +6947,7 @@ function SpeechToTextPluginImpl() {
6943
6947
  }
6944
6948
  };
6945
6949
  }, [SpeechRecognition, editor, isEnabled, report]);
6946
- React20.useEffect(() => {
6950
+ React21.useEffect(() => {
6947
6951
  return editor.registerCommand(
6948
6952
  SPEECH_TO_TEXT_COMMAND,
6949
6953
  (_isEnabled) => {
@@ -7003,7 +7007,7 @@ var ScrollArea, ScrollBar;
7003
7007
  var init_scroll_area = __esm({
7004
7008
  "src/ui/scroll-area.tsx"() {
7005
7009
  init_utils();
7006
- ScrollArea = React20__namespace.forwardRef(
7010
+ ScrollArea = React21__namespace.forwardRef(
7007
7011
  ({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
7008
7012
  "div",
7009
7013
  {
@@ -7106,12 +7110,12 @@ function debounce(fn, ms, options) {
7106
7110
  return debounced;
7107
7111
  }
7108
7112
  function useDebounce(fn, ms, maxWait) {
7109
- const funcRef = React20.useRef(fn);
7110
- const debouncedRef = React20.useRef(null);
7111
- React20.useEffect(() => {
7113
+ const funcRef = React21.useRef(fn);
7114
+ const debouncedRef = React21.useRef(null);
7115
+ React21.useEffect(() => {
7112
7116
  funcRef.current = fn;
7113
7117
  }, [fn]);
7114
- React20.useEffect(() => {
7118
+ React21.useEffect(() => {
7115
7119
  const debounced = debounce(
7116
7120
  ((...args) => {
7117
7121
  funcRef.current(...args);
@@ -7125,7 +7129,7 @@ function useDebounce(fn, ms, maxWait) {
7125
7129
  debouncedRef.current = null;
7126
7130
  };
7127
7131
  }, [ms, maxWait]);
7128
- return React20.useMemo(() => {
7132
+ return React21.useMemo(() => {
7129
7133
  const run = (...args) => {
7130
7134
  debouncedRef.current?.(...args);
7131
7135
  };
@@ -7140,7 +7144,7 @@ var init_use_debounce = __esm({
7140
7144
  }
7141
7145
  });
7142
7146
  function CopyButton({ editor, getCodeDOMNode }) {
7143
- const [isCopyCompleted, setCopyCompleted] = React20.useState(false);
7147
+ const [isCopyCompleted, setCopyCompleted] = React21.useState(false);
7144
7148
  const removeSuccessIcon = useDebounce(() => {
7145
7149
  setCopyCompleted(false);
7146
7150
  }, 1e3);
@@ -7185,9 +7189,9 @@ var init_code_button = __esm({
7185
7189
  }
7186
7190
  });
7187
7191
  function Select({ value, onValueChange, children, disabled }) {
7188
- const [open, setOpen] = React20__namespace.useState(false);
7189
- const triggerRef = React20__namespace.useRef(null);
7190
- const contextValue = React20__namespace.useMemo(() => ({
7192
+ const [open, setOpen] = React21__namespace.useState(false);
7193
+ const triggerRef = React21__namespace.useRef(null);
7194
+ const contextValue = React21__namespace.useMemo(() => ({
7191
7195
  value,
7192
7196
  onValueChange,
7193
7197
  open,
@@ -7198,7 +7202,7 @@ function Select({ value, onValueChange, children, disabled }) {
7198
7202
  return /* @__PURE__ */ jsxRuntime.jsx(SelectContext.Provider, { value: contextValue, children });
7199
7203
  }
7200
7204
  function SelectTrigger({ className, children, size = "default", ...props }) {
7201
- const context = React20__namespace.useContext(SelectContext);
7205
+ const context = React21__namespace.useContext(SelectContext);
7202
7206
  if (!context) throw new Error("SelectTrigger must be used within Select");
7203
7207
  const { triggerRef, disabled, open, setOpen } = context;
7204
7208
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -7222,15 +7226,15 @@ function SelectTrigger({ className, children, size = "default", ...props }) {
7222
7226
  );
7223
7227
  }
7224
7228
  function SelectValue({ placeholder }) {
7225
- const context = React20__namespace.useContext(SelectContext);
7229
+ const context = React21__namespace.useContext(SelectContext);
7226
7230
  if (!context) throw new Error("SelectValue must be used within Select");
7227
7231
  return /* @__PURE__ */ jsxRuntime.jsx("span", { children: context.value || placeholder });
7228
7232
  }
7229
7233
  function SelectContent({ className, children, ...props }) {
7230
- const context = React20__namespace.useContext(SelectContext);
7231
- const [position, setPosition] = React20__namespace.useState({ top: 0, left: 0, width: 0 });
7232
- const contentRef = React20__namespace.useRef(null);
7233
- React20__namespace.useEffect(() => {
7234
+ const context = React21__namespace.useContext(SelectContext);
7235
+ const [position, setPosition] = React21__namespace.useState({ top: 0, left: 0, width: 0 });
7236
+ const contentRef = React21__namespace.useRef(null);
7237
+ React21__namespace.useEffect(() => {
7234
7238
  if (context?.open && context.triggerRef.current) {
7235
7239
  const rect = context.triggerRef.current.getBoundingClientRect();
7236
7240
  setPosition({
@@ -7272,7 +7276,7 @@ function SelectContent({ className, children, ...props }) {
7272
7276
  );
7273
7277
  }
7274
7278
  function SelectItem({ value, children, className, ...props }) {
7275
- const context = React20__namespace.useContext(SelectContext);
7279
+ const context = React21__namespace.useContext(SelectContext);
7276
7280
  if (!context) throw new Error("SelectItem must be used within Select");
7277
7281
  const isSelected = context.value === value;
7278
7282
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -7302,7 +7306,7 @@ var SelectContext;
7302
7306
  var init_select = __esm({
7303
7307
  "src/ui/select.tsx"() {
7304
7308
  init_utils();
7305
- SelectContext = React20__namespace.createContext(null);
7309
+ SelectContext = React21__namespace.createContext(null);
7306
7310
  }
7307
7311
  });
7308
7312
  function getCodeLanguageOptions() {
@@ -7318,16 +7322,16 @@ function CodeActionMenuContainer({
7318
7322
  anchorElem
7319
7323
  }) {
7320
7324
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
7321
- const [lang, setLang] = React20.useState("");
7322
- const [nodeKey, setNodeKey] = React20.useState(null);
7323
- const [isShown, setShown] = React20.useState(false);
7324
- const [shouldListenMouseMove, setShouldListenMouseMove] = React20.useState(false);
7325
- const [position, setPosition] = React20.useState({
7325
+ const [lang, setLang] = React21.useState("");
7326
+ const [nodeKey, setNodeKey] = React21.useState(null);
7327
+ const [isShown, setShown] = React21.useState(false);
7328
+ const [shouldListenMouseMove, setShouldListenMouseMove] = React21.useState(false);
7329
+ const [position, setPosition] = React21.useState({
7326
7330
  right: "0",
7327
7331
  top: "0"
7328
7332
  });
7329
- const codeSetRef = React20.useRef(/* @__PURE__ */ new Set());
7330
- const codeDOMNodeRef = React20.useRef(null);
7333
+ const codeSetRef = React21.useRef(/* @__PURE__ */ new Set());
7334
+ const codeDOMNodeRef = React21.useRef(null);
7331
7335
  function getCodeDOMNode() {
7332
7336
  return codeDOMNodeRef.current;
7333
7337
  }
@@ -7368,7 +7372,7 @@ function CodeActionMenuContainer({
7368
7372
  50,
7369
7373
  1e3
7370
7374
  );
7371
- const onCodeLanguageSelect = React20.useCallback(
7375
+ const onCodeLanguageSelect = React21.useCallback(
7372
7376
  (value) => {
7373
7377
  editor.update(() => {
7374
7378
  if (nodeKey !== null) {
@@ -7382,7 +7386,7 @@ function CodeActionMenuContainer({
7382
7386
  },
7383
7387
  [editor, nodeKey]
7384
7388
  );
7385
- React20.useEffect(() => {
7389
+ React21.useEffect(() => {
7386
7390
  if (!shouldListenMouseMove) {
7387
7391
  return;
7388
7392
  }
@@ -7393,7 +7397,7 @@ function CodeActionMenuContainer({
7393
7397
  document.removeEventListener("mousemove", debouncedOnMouseMove);
7394
7398
  };
7395
7399
  }, [shouldListenMouseMove, debouncedOnMouseMove]);
7396
- React20.useEffect(() => {
7400
+ React21.useEffect(() => {
7397
7401
  return editor.registerMutationListener(
7398
7402
  code.CodeNode,
7399
7403
  (mutations) => {
@@ -7482,7 +7486,7 @@ var init_code_action_menu_plugin = __esm({
7482
7486
  });
7483
7487
  function CodeHighlightPlugin() {
7484
7488
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
7485
- React20.useEffect(() => {
7489
+ React21.useEffect(() => {
7486
7490
  return code.registerCodeHighlighting(editor);
7487
7491
  }, [editor]);
7488
7492
  return null;
@@ -7493,11 +7497,11 @@ var init_code_highlight_plugin = __esm({
7493
7497
  }
7494
7498
  });
7495
7499
  function useEditorModal() {
7496
- const [modalContent, setModalContent] = React20.useState(null);
7497
- const onClose = React20.useCallback(() => {
7500
+ const [modalContent, setModalContent] = React21.useState(null);
7501
+ const onClose = React21.useCallback(() => {
7498
7502
  setModalContent(null);
7499
7503
  }, []);
7500
- const modal = React20.useMemo(() => {
7504
+ const modal = React21.useMemo(() => {
7501
7505
  if (modalContent === null) {
7502
7506
  return null;
7503
7507
  }
@@ -7510,7 +7514,7 @@ function useEditorModal() {
7510
7514
  content
7511
7515
  ] }) });
7512
7516
  }, [modalContent, onClose]);
7513
- const showModal = React20.useCallback(
7517
+ const showModal = React21.useCallback(
7514
7518
  (title, getContent, closeOnClickOutside = false) => {
7515
7519
  setModalContent({
7516
7520
  closeOnClickOutside,
@@ -7531,7 +7535,7 @@ var Command, CommandList, CommandGroup, CommandItem;
7531
7535
  var init_command = __esm({
7532
7536
  "src/ui/command.tsx"() {
7533
7537
  init_utils();
7534
- Command = React20__namespace.forwardRef(
7538
+ Command = React21__namespace.forwardRef(
7535
7539
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
7536
7540
  "div",
7537
7541
  {
@@ -7542,7 +7546,7 @@ var init_command = __esm({
7542
7546
  )
7543
7547
  );
7544
7548
  Command.displayName = "Command";
7545
- CommandList = React20__namespace.forwardRef(
7549
+ CommandList = React21__namespace.forwardRef(
7546
7550
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
7547
7551
  "div",
7548
7552
  {
@@ -7553,7 +7557,7 @@ var init_command = __esm({
7553
7557
  )
7554
7558
  );
7555
7559
  CommandList.displayName = "CommandList";
7556
- CommandGroup = React20__namespace.forwardRef(
7560
+ CommandGroup = React21__namespace.forwardRef(
7557
7561
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
7558
7562
  "div",
7559
7563
  {
@@ -7564,7 +7568,7 @@ var init_command = __esm({
7564
7568
  )
7565
7569
  );
7566
7570
  CommandGroup.displayName = "CommandGroup";
7567
- CommandItem = React20__namespace.forwardRef(({ className, onSelect, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
7571
+ CommandItem = React21__namespace.forwardRef(({ className, onSelect, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
7568
7572
  "div",
7569
7573
  {
7570
7574
  ref,
@@ -7582,8 +7586,8 @@ function MenuContent({
7582
7586
  selectOptionAndCleanUp,
7583
7587
  setHighlightedIndex
7584
7588
  }) {
7585
- const containerRef = React20.useRef(null);
7586
- React20.useEffect(() => {
7589
+ const containerRef = React21.useRef(null);
7590
+ React21.useEffect(() => {
7587
7591
  if (selectedIndex !== null && selectedIndex >= 0 && selectedIndex < options.length) {
7588
7592
  const timeoutId = setTimeout(() => {
7589
7593
  const container = containerRef.current;
@@ -7742,7 +7746,7 @@ function ComponentPickerMenuPlugin({
7742
7746
  }) {
7743
7747
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
7744
7748
  const [modal, showModal] = useEditorModal();
7745
- const [queryString, setQueryString] = React20.useState(null);
7749
+ const [queryString, setQueryString] = React21.useState(null);
7746
7750
  logger.debug("ComponentPickerMenuPlugin initialized", {
7747
7751
  baseOptionsCount: baseOptions.length,
7748
7752
  hasDynamicOptionsFn: !!dynamicOptionsFn
@@ -7750,7 +7754,7 @@ function ComponentPickerMenuPlugin({
7750
7754
  const checkForTriggerMatch = LexicalTypeaheadMenuPlugin$1.useBasicTypeaheadTriggerMatch("/", {
7751
7755
  minLength: 0
7752
7756
  });
7753
- const options = React20.useMemo(() => {
7757
+ const options = React21.useMemo(() => {
7754
7758
  if (!queryString) {
7755
7759
  logger.debug("ComponentPickerMenuPlugin: No query string, returning baseOptions", {
7756
7760
  baseOptionsCount: baseOptions.length,
@@ -7775,7 +7779,7 @@ function ComponentPickerMenuPlugin({
7775
7779
  });
7776
7780
  return filtered;
7777
7781
  }, [baseOptions, dynamicOptionsFn, queryString]);
7778
- const onSelectOption = React20.useCallback(
7782
+ const onSelectOption = React21.useCallback(
7779
7783
  (selectedOption, nodeToRemove, closeMenu, matchingString) => {
7780
7784
  editor.update(() => {
7781
7785
  nodeToRemove?.remove();
@@ -7900,6 +7904,98 @@ var init_component_picker_menu_plugin = __esm({
7900
7904
  );
7901
7905
  }
7902
7906
  });
7907
+ var NumberInput;
7908
+ var init_number_input = __esm({
7909
+ "src/ui/number-input.tsx"() {
7910
+ "use client";
7911
+ init_utils();
7912
+ init_button();
7913
+ init_input();
7914
+ NumberInput = React21__namespace.forwardRef(
7915
+ ({ value, onValueChange, min = 0, max = 100, step = 1, unit = "px", className, ...props }, ref) => {
7916
+ const timerRef = React21__namespace.useRef(null);
7917
+ const intervalRef = React21__namespace.useRef(null);
7918
+ const valueRef = React21__namespace.useRef(value);
7919
+ React21__namespace.useEffect(() => {
7920
+ valueRef.current = value;
7921
+ }, [value]);
7922
+ const updateValue = React21__namespace.useCallback((delta) => {
7923
+ onValueChange(Math.min(Math.max(valueRef.current + delta, min), max));
7924
+ }, [onValueChange, min, max]);
7925
+ const startLongPress = (delta) => {
7926
+ updateValue(delta);
7927
+ timerRef.current = setTimeout(() => {
7928
+ intervalRef.current = setInterval(() => {
7929
+ updateValue(delta);
7930
+ }, 50);
7931
+ }, 300);
7932
+ };
7933
+ const stopLongPress = React21__namespace.useCallback(() => {
7934
+ if (timerRef.current) clearTimeout(timerRef.current);
7935
+ if (intervalRef.current) clearInterval(intervalRef.current);
7936
+ }, []);
7937
+ const handleBlur = () => {
7938
+ onValueChange(Math.min(Math.max(value, min), max));
7939
+ };
7940
+ React21__namespace.useEffect(() => {
7941
+ return () => stopLongPress();
7942
+ }, [stopLongPress]);
7943
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("editor-number-input-container", className), children: [
7944
+ /* @__PURE__ */ jsxRuntime.jsx(
7945
+ Button,
7946
+ {
7947
+ variant: "ghost",
7948
+ size: "icon",
7949
+ className: "editor-number-input-btn",
7950
+ onMouseDown: () => startLongPress(-step),
7951
+ onMouseUp: stopLongPress,
7952
+ onMouseLeave: stopLongPress,
7953
+ onTouchStart: () => startLongPress(-step),
7954
+ onTouchEnd: stopLongPress,
7955
+ tabIndex: -1,
7956
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minus, { size: 14 })
7957
+ }
7958
+ ),
7959
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "editor-number-input-wrapper", children: [
7960
+ /* @__PURE__ */ jsxRuntime.jsx(
7961
+ Input,
7962
+ {
7963
+ ...props,
7964
+ ref,
7965
+ type: "number",
7966
+ value,
7967
+ onBlur: handleBlur,
7968
+ onChange: (e) => {
7969
+ const val = parseInt(e.target.value, 10);
7970
+ if (!isNaN(val)) onValueChange(val);
7971
+ else onValueChange(0);
7972
+ },
7973
+ className: "editor-number-input-field"
7974
+ }
7975
+ ),
7976
+ unit && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "editor-number-input-unit", children: unit })
7977
+ ] }),
7978
+ /* @__PURE__ */ jsxRuntime.jsx(
7979
+ Button,
7980
+ {
7981
+ variant: "ghost",
7982
+ size: "icon",
7983
+ className: "editor-number-input-btn",
7984
+ onMouseDown: () => startLongPress(step),
7985
+ onMouseUp: stopLongPress,
7986
+ onMouseLeave: stopLongPress,
7987
+ onTouchStart: () => startLongPress(step),
7988
+ onTouchEnd: stopLongPress,
7989
+ tabIndex: -1,
7990
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { size: 14 })
7991
+ }
7992
+ )
7993
+ ] });
7994
+ }
7995
+ );
7996
+ NumberInput.displayName = "NumberInput";
7997
+ }
7998
+ });
7903
7999
  var Slot;
7904
8000
  var init_slot = __esm({
7905
8001
  "src/ui/slot.tsx"() {
@@ -7907,11 +8003,11 @@ var init_slot = __esm({
7907
8003
  }
7908
8004
  });
7909
8005
  function Popover({ children, open: controlledOpen, defaultOpen = false, onOpenChange, modal = false }) {
7910
- const [uncontrolledOpen, setUncontrolledOpen] = React20__namespace.useState(defaultOpen);
7911
- const triggerRef = React20__namespace.useRef(null);
8006
+ const [uncontrolledOpen, setUncontrolledOpen] = React21__namespace.useState(defaultOpen);
8007
+ const triggerRef = React21__namespace.useRef(null);
7912
8008
  const open = controlledOpen ?? uncontrolledOpen;
7913
8009
  const setOpen = onOpenChange ?? setUncontrolledOpen;
7914
- const contextValue = React20__namespace.useMemo(() => ({
8010
+ const contextValue = React21__namespace.useMemo(() => ({
7915
8011
  open,
7916
8012
  setOpen,
7917
8013
  triggerRef,
@@ -7920,17 +8016,17 @@ function Popover({ children, open: controlledOpen, defaultOpen = false, onOpenCh
7920
8016
  return /* @__PURE__ */ jsxRuntime.jsx(PopoverContext.Provider, { value: contextValue, children });
7921
8017
  }
7922
8018
  function PopoverTrigger({ children, asChild, ...props }) {
7923
- const context = React20__namespace.useContext(PopoverContext);
8019
+ const context = React21__namespace.useContext(PopoverContext);
7924
8020
  if (!context) throw new Error("PopoverTrigger must be used within Popover");
7925
8021
  const { triggerRef, open, setOpen } = context;
7926
8022
  const handleClick = (e) => {
7927
8023
  setOpen(!open);
7928
- if (React20__namespace.isValidElement(children)) {
8024
+ if (React21__namespace.isValidElement(children)) {
7929
8025
  children.props.onClick?.(e);
7930
8026
  }
7931
8027
  };
7932
- if (asChild && React20__namespace.isValidElement(children)) {
7933
- return React20__namespace.cloneElement(children, {
8028
+ if (asChild && React21__namespace.isValidElement(children)) {
8029
+ return React21__namespace.cloneElement(children, {
7934
8030
  ref: triggerRef,
7935
8031
  onClick: handleClick,
7936
8032
  ...props
@@ -7948,10 +8044,10 @@ function PopoverTrigger({ children, asChild, ...props }) {
7948
8044
  );
7949
8045
  }
7950
8046
  function PopoverContent({ children, className, align = "center", sideOffset = 4, ...props }) {
7951
- const context = React20__namespace.useContext(PopoverContext);
7952
- const [position, setPosition] = React20__namespace.useState({ top: 0, left: 0 });
7953
- const contentRef = React20__namespace.useRef(null);
7954
- React20__namespace.useEffect(() => {
8047
+ const context = React21__namespace.useContext(PopoverContext);
8048
+ const [position, setPosition] = React21__namespace.useState({ top: 0, left: 0 });
8049
+ const contentRef = React21__namespace.useRef(null);
8050
+ React21__namespace.useEffect(() => {
7955
8051
  if (context?.open && context.triggerRef.current) {
7956
8052
  const rect = context.triggerRef.current.getBoundingClientRect();
7957
8053
  let left = rect.left;
@@ -8001,7 +8097,7 @@ var PopoverContext;
8001
8097
  var init_popover = __esm({
8002
8098
  "src/ui/popover.tsx"() {
8003
8099
  init_utils();
8004
- PopoverContext = React20__namespace.createContext(null);
8100
+ PopoverContext = React21__namespace.createContext(null);
8005
8101
  }
8006
8102
  });
8007
8103
  function setRef(ref, value) {
@@ -8037,7 +8133,7 @@ function composeRefs(...refs) {
8037
8133
  };
8038
8134
  }
8039
8135
  function useComposedRefs(...refs) {
8040
- return React20__namespace.useCallback(
8136
+ return React21__namespace.useCallback(
8041
8137
  (value) => {
8042
8138
  composeRefs(...refs)(value);
8043
8139
  },
@@ -8055,19 +8151,19 @@ function VisuallyHiddenInput(props) {
8055
8151
  style,
8056
8152
  ...inputProps
8057
8153
  } = props;
8058
- const isCheckInput = React20__namespace.useMemo(
8154
+ const isCheckInput = React21__namespace.useMemo(
8059
8155
  () => type === "checkbox" || type === "radio" || type === "switch",
8060
8156
  [type]
8061
8157
  );
8062
- const inputRef = React20__namespace.useRef(null);
8063
- const prevValueRef = React20__namespace.useRef({
8158
+ const inputRef = React21__namespace.useRef(null);
8159
+ const prevValueRef = React21__namespace.useRef({
8064
8160
  value: isCheckInput ? checked : value,
8065
8161
  previous: isCheckInput ? checked : value
8066
8162
  });
8067
- const [prevValue, setPrevValue] = React20__namespace.useState(
8163
+ const [prevValue, setPrevValue] = React21__namespace.useState(
8068
8164
  isCheckInput ? checked : value
8069
8165
  );
8070
- React20__namespace.useEffect(() => {
8166
+ React21__namespace.useEffect(() => {
8071
8167
  const currentValue = isCheckInput ? checked : value;
8072
8168
  if (prevValueRef.current.value !== currentValue) {
8073
8169
  prevValueRef.current.previous = prevValueRef.current.value;
@@ -8075,8 +8171,8 @@ function VisuallyHiddenInput(props) {
8075
8171
  setPrevValue(prevValueRef.current.previous);
8076
8172
  }
8077
8173
  }, [isCheckInput, value, checked]);
8078
- const [controlSize, setControlSize] = React20__namespace.useState({});
8079
- React20__namespace.useLayoutEffect(() => {
8174
+ const [controlSize, setControlSize] = React21__namespace.useState({});
8175
+ React21__namespace.useLayoutEffect(() => {
8080
8176
  if (!control) {
8081
8177
  setControlSize({});
8082
8178
  return;
@@ -8108,7 +8204,7 @@ function VisuallyHiddenInput(props) {
8108
8204
  resizeObserver.disconnect();
8109
8205
  };
8110
8206
  }, [control]);
8111
- React20__namespace.useEffect(() => {
8207
+ React21__namespace.useEffect(() => {
8112
8208
  const input = inputRef.current;
8113
8209
  if (!input) return;
8114
8210
  const inputProto = window.HTMLInputElement.prototype;
@@ -8124,7 +8220,7 @@ function VisuallyHiddenInput(props) {
8124
8220
  input.dispatchEvent(event);
8125
8221
  }
8126
8222
  }, [prevValue, value, checked, bubbles, isCheckInput]);
8127
- const composedStyle = React20__namespace.useMemo(() => {
8223
+ const composedStyle = React21__namespace.useMemo(() => {
8128
8224
  return {
8129
8225
  ...style,
8130
8226
  ...controlSize.width !== void 0 && controlSize.height !== void 0 ? controlSize : {},
@@ -8436,11 +8532,11 @@ function parseColorString(value) {
8436
8532
  return null;
8437
8533
  }
8438
8534
  function useDirection(dirProp) {
8439
- const contextDir = React20__namespace.useContext(DirectionContext);
8535
+ const contextDir = React21__namespace.useContext(DirectionContext);
8440
8536
  return dirProp ?? contextDir ?? "ltr";
8441
8537
  }
8442
8538
  function useLazyRef(fn) {
8443
- const ref = React20__namespace.useRef(null);
8539
+ const ref = React21__namespace.useRef(null);
8444
8540
  if (ref.current === null) {
8445
8541
  ref.current = fn();
8446
8542
  }
@@ -8514,7 +8610,7 @@ function createColorPickerStore(listenersRef, stateRef, callbacks) {
8514
8610
  return store;
8515
8611
  }
8516
8612
  function useColorPickerStoreContext(consumerName) {
8517
- const context = React20__namespace.useContext(ColorPickerStoreContext);
8613
+ const context = React21__namespace.useContext(ColorPickerStoreContext);
8518
8614
  if (!context) {
8519
8615
  throw new Error(
8520
8616
  `\`${consumerName}\` must be used within \`ColorPickerRoot\``
@@ -8524,14 +8620,14 @@ function useColorPickerStoreContext(consumerName) {
8524
8620
  }
8525
8621
  function useColorPickerStore(selector) {
8526
8622
  const store = useColorPickerStoreContext("useColorPickerStoreSelector");
8527
- const getSnapshot = React20__namespace.useCallback(
8623
+ const getSnapshot = React21__namespace.useCallback(
8528
8624
  () => selector(store.getState()),
8529
8625
  [store, selector]
8530
8626
  );
8531
- return React20__namespace.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
8627
+ return React21__namespace.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
8532
8628
  }
8533
8629
  function useColorPickerContext(consumerName) {
8534
- const context = React20__namespace.useContext(ColorPickerContext);
8630
+ const context = React21__namespace.useContext(ColorPickerContext);
8535
8631
  if (!context) {
8536
8632
  throw new Error(
8537
8633
  `\`${consumerName}\` must be used within \`ColorPickerRoot\``
@@ -8558,12 +8654,12 @@ function ColorPickerRootImpl(props) {
8558
8654
  } = props;
8559
8655
  const store = useColorPickerStoreContext("ColorPickerRootImpl");
8560
8656
  const dir = useDirection(dirProp);
8561
- const [formTrigger, setFormTrigger] = React20__namespace.useState(
8657
+ const [formTrigger, setFormTrigger] = React21__namespace.useState(
8562
8658
  null
8563
8659
  );
8564
8660
  const composedRef = useComposedRefs(ref, (node) => setFormTrigger(node));
8565
8661
  const isFormControl = formTrigger ? !!formTrigger.closest("form") : true;
8566
- React20__namespace.useEffect(() => {
8662
+ React21__namespace.useEffect(() => {
8567
8663
  if (valueProp !== void 0) {
8568
8664
  const color = parseColorString(valueProp);
8569
8665
  if (color) {
@@ -8573,12 +8669,12 @@ function ColorPickerRootImpl(props) {
8573
8669
  }
8574
8670
  }
8575
8671
  }, [valueProp, store]);
8576
- React20__namespace.useEffect(() => {
8672
+ React21__namespace.useEffect(() => {
8577
8673
  if (openProp !== void 0) {
8578
8674
  store.setOpen(openProp);
8579
8675
  }
8580
8676
  }, [openProp, store]);
8581
- const contextValue = React20__namespace.useMemo(
8677
+ const contextValue = React21__namespace.useMemo(
8582
8678
  () => ({
8583
8679
  dir,
8584
8680
  disabled,
@@ -8590,7 +8686,7 @@ function ColorPickerRootImpl(props) {
8590
8686
  );
8591
8687
  const value = useColorPickerStore((state) => rgbToHex(state.color));
8592
8688
  const open = useColorPickerStore((state) => state.open);
8593
- const onPopoverOpenChange = React20__namespace.useCallback(
8689
+ const onPopoverOpenChange = React21__namespace.useCallback(
8594
8690
  (newOpen) => {
8595
8691
  store.setOpen(newOpen);
8596
8692
  onOpenChange?.(newOpen);
@@ -8676,10 +8772,10 @@ function ColorPickerArea(props) {
8676
8772
  const context = useColorPickerContext("ColorPickerArea");
8677
8773
  const store = useColorPickerStoreContext("ColorPickerArea");
8678
8774
  const hsv = useColorPickerStore((state) => state.hsv);
8679
- const isDraggingRef = React20__namespace.useRef(false);
8680
- const areaRef = React20__namespace.useRef(null);
8775
+ const isDraggingRef = React21__namespace.useRef(false);
8776
+ const areaRef = React21__namespace.useRef(null);
8681
8777
  const composedRef = useComposedRefs(ref, areaRef);
8682
- const updateColorFromPosition = React20__namespace.useCallback(
8778
+ const updateColorFromPosition = React21__namespace.useCallback(
8683
8779
  (clientX, clientY) => {
8684
8780
  if (!areaRef.current) return;
8685
8781
  const rect = areaRef.current.getBoundingClientRect();
@@ -8696,7 +8792,7 @@ function ColorPickerArea(props) {
8696
8792
  },
8697
8793
  [hsv, store]
8698
8794
  );
8699
- const onPointerDown = React20__namespace.useCallback(
8795
+ const onPointerDown = React21__namespace.useCallback(
8700
8796
  (event) => {
8701
8797
  if (context.disabled) return;
8702
8798
  event.preventDefault();
@@ -8706,7 +8802,7 @@ function ColorPickerArea(props) {
8706
8802
  },
8707
8803
  [context.disabled, updateColorFromPosition]
8708
8804
  );
8709
- const onPointerMove = React20__namespace.useCallback(
8805
+ const onPointerMove = React21__namespace.useCallback(
8710
8806
  (event) => {
8711
8807
  if (isDraggingRef.current) {
8712
8808
  updateColorFromPosition(event.clientX, event.clientY);
@@ -8714,7 +8810,7 @@ function ColorPickerArea(props) {
8714
8810
  },
8715
8811
  [updateColorFromPosition]
8716
8812
  );
8717
- const onPointerUp = React20__namespace.useCallback((event) => {
8813
+ const onPointerUp = React21__namespace.useCallback((event) => {
8718
8814
  isDraggingRef.current = false;
8719
8815
  areaRef.current?.releasePointerCapture(event.pointerId);
8720
8816
  }, []);
@@ -8784,7 +8880,7 @@ function ColorPickerHueSlider(props) {
8784
8880
  const context = useColorPickerContext("ColorPickerHueSlider");
8785
8881
  const store = useColorPickerStoreContext("ColorPickerHueSlider");
8786
8882
  const hsv = useColorPickerStore((state) => state.hsv);
8787
- const onValueChange = React20__namespace.useCallback(
8883
+ const onValueChange = React21__namespace.useCallback(
8788
8884
  (values) => {
8789
8885
  const newHsv = {
8790
8886
  h: values[0] ?? 0,
@@ -8824,7 +8920,7 @@ function ColorPickerAlphaSlider(props) {
8824
8920
  const store = useColorPickerStoreContext("ColorPickerAlphaSlider");
8825
8921
  const color = useColorPickerStore((state) => state.color);
8826
8922
  const hsv = useColorPickerStore((state) => state.hsv);
8827
- const onValueChange = React20__namespace.useCallback(
8923
+ const onValueChange = React21__namespace.useCallback(
8828
8924
  (values) => {
8829
8925
  const alpha = (values[0] ?? 0) / 100;
8830
8926
  const newColor = { ...color, a: alpha };
@@ -8883,7 +8979,7 @@ function ColorPickerEyeDropper(props) {
8883
8979
  const context = useColorPickerContext("ColorPickerEyeDropper");
8884
8980
  const store = useColorPickerStoreContext("ColorPickerEyeDropper");
8885
8981
  const color = useColorPickerStore((state) => state.color);
8886
- const onEyeDropper = React20__namespace.useCallback(async () => {
8982
+ const onEyeDropper = React21__namespace.useCallback(async () => {
8887
8983
  if (!window.EyeDropper) return;
8888
8984
  try {
8889
8985
  const eyeDropper = new window.EyeDropper();
@@ -8920,7 +9016,7 @@ function ColorPickerFormatSelect(props) {
8920
9016
  const context = useColorPickerContext("ColorPickerFormatSelector");
8921
9017
  const store = useColorPickerStoreContext("ColorPickerFormatSelector");
8922
9018
  const format = useColorPickerStore((state) => state.format);
8923
- const onFormatChange = React20__namespace.useCallback(
9019
+ const onFormatChange = React21__namespace.useCallback(
8924
9020
  (value) => {
8925
9021
  if (colorFormats.includes(value)) {
8926
9022
  store.setFormat(value);
@@ -8957,7 +9053,7 @@ function ColorPickerInput(props) {
8957
9053
  const color = useColorPickerStore((state) => state.color);
8958
9054
  const format = useColorPickerStore((state) => state.format);
8959
9055
  const hsv = useColorPickerStore((state) => state.hsv);
8960
- const onColorChange = React20__namespace.useCallback(
9056
+ const onColorChange = React21__namespace.useCallback(
8961
9057
  (newColor) => {
8962
9058
  const newHsv = rgbToHsv(newColor);
8963
9059
  store.setColor(newColor);
@@ -9039,7 +9135,7 @@ function HexInput(props) {
9039
9135
  } = props;
9040
9136
  const hexValue = rgbToHex(color);
9041
9137
  const alphaValue = Math.round((color?.a ?? 1) * 100);
9042
- const onHexChange = React20__namespace.useCallback(
9138
+ const onHexChange = React21__namespace.useCallback(
9043
9139
  (event) => {
9044
9140
  const value = event.target.value;
9045
9141
  const parsedColor = parseColorString(value);
@@ -9049,7 +9145,7 @@ function HexInput(props) {
9049
9145
  },
9050
9146
  [color, onColorChange]
9051
9147
  );
9052
- const onAlphaChange = React20__namespace.useCallback(
9148
+ const onAlphaChange = React21__namespace.useCallback(
9053
9149
  (event) => {
9054
9150
  const value = Number.parseInt(event.target.value, 10);
9055
9151
  if (!Number.isNaN(value) && value >= 0 && value <= 100) {
@@ -9126,7 +9222,7 @@ function RgbInput(props) {
9126
9222
  const gValue = Math.round(color?.g ?? 0);
9127
9223
  const bValue = Math.round(color?.b ?? 0);
9128
9224
  const alphaValue = Math.round((color?.a ?? 1) * 100);
9129
- const onChannelChange = React20__namespace.useCallback(
9225
+ const onChannelChange = React21__namespace.useCallback(
9130
9226
  (channel, max, isAlpha = false) => (event) => {
9131
9227
  const value = Number.parseInt(event.target.value, 10);
9132
9228
  if (!Number.isNaN(value) && value >= 0 && value <= max) {
@@ -9223,9 +9319,9 @@ function HslInput(props) {
9223
9319
  className,
9224
9320
  ...inputProps
9225
9321
  } = props;
9226
- const hsl = React20__namespace.useMemo(() => rgbToHsl(color), [color]);
9322
+ const hsl = React21__namespace.useMemo(() => rgbToHsl(color), [color]);
9227
9323
  const alphaValue = Math.round((color?.a ?? 1) * 100);
9228
- const onHslChannelChange = React20__namespace.useCallback(
9324
+ const onHslChannelChange = React21__namespace.useCallback(
9229
9325
  (channel, max) => (event) => {
9230
9326
  const value = Number.parseInt(event.target.value, 10);
9231
9327
  if (!Number.isNaN(value) && value >= 0 && value <= max) {
@@ -9236,7 +9332,7 @@ function HslInput(props) {
9236
9332
  },
9237
9333
  [hsl, color, onColorChange]
9238
9334
  );
9239
- const onAlphaChange = React20__namespace.useCallback(
9335
+ const onAlphaChange = React21__namespace.useCallback(
9240
9336
  (event) => {
9241
9337
  const value = Number.parseInt(event.target.value, 10);
9242
9338
  if (!Number.isNaN(value) && value >= 0 && value <= 100) {
@@ -9333,7 +9429,7 @@ function HsbInput(props) {
9333
9429
  ...inputProps
9334
9430
  } = props;
9335
9431
  const alphaValue = Math.round((hsv?.a ?? 1) * 100);
9336
- const onHsvChannelChange = React20__namespace.useCallback(
9432
+ const onHsvChannelChange = React21__namespace.useCallback(
9337
9433
  (channel, max) => (event) => {
9338
9434
  const value = Number.parseInt(event.target.value, 10);
9339
9435
  if (!Number.isNaN(value) && value >= 0 && value <= max) {
@@ -9344,7 +9440,7 @@ function HsbInput(props) {
9344
9440
  },
9345
9441
  [hsv, onColorChange]
9346
9442
  );
9347
- const onAlphaChange = React20__namespace.useCallback(
9443
+ const onAlphaChange = React21__namespace.useCallback(
9348
9444
  (event) => {
9349
9445
  const value = Number.parseInt(event.target.value, 10);
9350
9446
  if (!Number.isNaN(value) && value >= 0 && value <= 100) {
@@ -9437,7 +9533,7 @@ function ColorPickerPresets(props) {
9437
9533
  const context = useColorPickerContext("ColorPickerPresets");
9438
9534
  const store = useColorPickerStoreContext("ColorPickerPresets");
9439
9535
  const color = useColorPickerStore((state) => state.color);
9440
- const onPresetClick = React20__namespace.useCallback(
9536
+ const onPresetClick = React21__namespace.useCallback(
9441
9537
  (hex, alpha) => {
9442
9538
  const nextAlpha = alpha ?? (color?.a ?? 1);
9443
9539
  const newColor = hexToRgb(hex, nextAlpha);
@@ -9498,14 +9594,14 @@ var init_color_picker = __esm({
9498
9594
  // --muted in light theme is #F5F5F5, /50 -> alpha 0.5
9499
9595
  { label: "bg-muted/50", value: "#F5F5F5", alpha: 0.5 }
9500
9596
  ];
9501
- DirectionContext = React20__namespace.createContext(void 0);
9502
- ColorPickerStoreContext = React20__namespace.createContext(
9597
+ DirectionContext = React21__namespace.createContext(void 0);
9598
+ ColorPickerStoreContext = React21__namespace.createContext(
9503
9599
  null
9504
9600
  );
9505
- ColorPickerContext = React20__namespace.createContext(
9601
+ ColorPickerContext = React21__namespace.createContext(
9506
9602
  null
9507
9603
  );
9508
- ColorPickerRoot = React20__namespace.memo(function ColorPickerRoot2(props) {
9604
+ ColorPickerRoot = React21__namespace.memo(function ColorPickerRoot2(props) {
9509
9605
  const {
9510
9606
  value: valueProp,
9511
9607
  defaultValue = "#000000",
@@ -9523,7 +9619,7 @@ var init_color_picker = __esm({
9523
9619
  required,
9524
9620
  ...rootProps
9525
9621
  } = props;
9526
- const initialColor = React20__namespace.useMemo(() => {
9622
+ const initialColor = React21__namespace.useMemo(() => {
9527
9623
  const colorString = valueProp ?? defaultValue;
9528
9624
  const color = parseColorString(colorString) ?? hexToRgb(defaultValue);
9529
9625
  return {
@@ -9542,7 +9638,7 @@ var init_color_picker = __esm({
9542
9638
  ]);
9543
9639
  const stateRef = useLazyRef(() => initialColor);
9544
9640
  const listenersRef = useLazyRef(() => /* @__PURE__ */ new Set());
9545
- const storeCallbacks = React20__namespace.useMemo(
9641
+ const storeCallbacks = React21__namespace.useMemo(
9546
9642
  () => ({
9547
9643
  onColorChange: onValueChange,
9548
9644
  onOpenChange,
@@ -9550,7 +9646,7 @@ var init_color_picker = __esm({
9550
9646
  }),
9551
9647
  [onValueChange, onOpenChange, onFormatChange]
9552
9648
  );
9553
- const store = React20__namespace.useMemo(
9649
+ const store = React21__namespace.useMemo(
9554
9650
  () => createColorPickerStore(listenersRef, stateRef, storeCallbacks),
9555
9651
  [listenersRef, stateRef, storeCallbacks]
9556
9652
  );
@@ -9579,38 +9675,48 @@ function InsertLayoutDialog({
9579
9675
  submitLabel = "Insert",
9580
9676
  onSubmit
9581
9677
  }) {
9582
- const [layout, setLayout] = React20.useState(initialValues?.template ?? (LAYOUTS[0]?.value || "1fr"));
9583
- const [backgroundColor, setBackgroundColor] = React20.useState(
9678
+ const [layout, setLayout] = React21.useState(initialValues?.template ?? (LAYOUTS[0]?.value || "1fr"));
9679
+ const [backgroundColor, setBackgroundColor] = React21.useState(
9584
9680
  initialValues?.itemBackgroundColor ?? "#ffffff"
9585
9681
  );
9586
- const [paddingPx, setPaddingPx] = React20.useState(initialValues?.itemPaddingPx ?? 12);
9587
- const [borderRadiusPx, setBorderRadiusPx] = React20.useState(
9682
+ const [paddingXPx, setPaddingXPx] = React21.useState(initialValues?.itemPaddingXPx ?? 12);
9683
+ const [paddingYPx, setPaddingYPx] = React21.useState(initialValues?.itemPaddingYPx ?? 12);
9684
+ const [borderRadiusPx, setBorderRadiusPx] = React21.useState(
9588
9685
  initialValues?.itemBorderRadiusPx ?? 8
9589
9686
  );
9590
- const layoutRef = React20.useRef(layout);
9591
- const backgroundColorRef = React20.useRef(backgroundColor);
9592
- const paddingPxRef = React20.useRef(paddingPx);
9593
- const borderRadiusPxRef = React20.useRef(borderRadiusPx);
9594
- React20.useEffect(() => {
9687
+ const layoutRef = React21.useRef(layout);
9688
+ const backgroundColorRef = React21.useRef(backgroundColor);
9689
+ const paddingXPxRef = React21.useRef(paddingXPx);
9690
+ const paddingYPxRef = React21.useRef(paddingYPx);
9691
+ const borderRadiusPxRef = React21.useRef(borderRadiusPx);
9692
+ React21.useEffect(() => {
9595
9693
  layoutRef.current = layout;
9596
9694
  }, [layout]);
9597
- React20.useEffect(() => {
9695
+ React21.useEffect(() => {
9598
9696
  backgroundColorRef.current = backgroundColor;
9599
9697
  }, [backgroundColor]);
9600
- React20.useEffect(() => {
9601
- paddingPxRef.current = paddingPx;
9602
- }, [paddingPx]);
9603
- React20.useEffect(() => {
9698
+ React21.useEffect(() => {
9699
+ paddingXPxRef.current = paddingXPx;
9700
+ }, [paddingXPx]);
9701
+ React21.useEffect(() => {
9702
+ paddingYPxRef.current = paddingYPx;
9703
+ }, [paddingYPx]);
9704
+ React21.useEffect(() => {
9604
9705
  borderRadiusPxRef.current = borderRadiusPx;
9605
9706
  }, [borderRadiusPx]);
9606
9707
  const onBackgroundColorChange = (value) => {
9607
9708
  backgroundColorRef.current = value;
9608
9709
  setBackgroundColor(value);
9609
9710
  };
9610
- const onPaddingChange = (next) => {
9711
+ const onPaddingXChange = (next) => {
9712
+ const value = Math.min(Math.max(next, 0), 64);
9713
+ paddingXPxRef.current = value;
9714
+ setPaddingXPx(value);
9715
+ };
9716
+ const onPaddingYChange = (next) => {
9611
9717
  const value = Math.min(Math.max(next, 0), 64);
9612
- paddingPxRef.current = value;
9613
- setPaddingPx(value);
9718
+ paddingYPxRef.current = value;
9719
+ setPaddingYPx(value);
9614
9720
  };
9615
9721
  const onBorderRadiusChange = (next) => {
9616
9722
  const value = Math.min(Math.max(next, 0), 64);
@@ -9622,7 +9728,8 @@ function InsertLayoutDialog({
9622
9728
  const values = {
9623
9729
  template: layoutRef.current,
9624
9730
  itemBackgroundColor: backgroundColorRef.current,
9625
- itemPaddingPx: paddingPxRef.current,
9731
+ itemPaddingXPx: paddingXPxRef.current,
9732
+ itemPaddingYPx: paddingYPxRef.current,
9626
9733
  itemBorderRadiusPx: borderRadiusPxRef.current
9627
9734
  };
9628
9735
  logger.info("[Layout] Submit dialog values", {
@@ -9637,13 +9744,13 @@ function InsertLayoutDialog({
9637
9744
  activeEditor.dispatchCommand(INSERT_LAYOUT_COMMAND, values);
9638
9745
  onClose();
9639
9746
  };
9640
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
9747
+ return /* @__PURE__ */ jsxRuntime.jsxs(Flex, { direction: "column", gap: 4, children: [
9641
9748
  /* @__PURE__ */ jsxRuntime.jsxs(Select, { onValueChange: setLayout, value: layout, children: [
9642
9749
  /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "editor-input-lg editor-w-full", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: buttonLabel }) }),
9643
9750
  /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { className: "editor-w-full", children: LAYOUTS.map(({ label, value }) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value, children: label }, value)) })
9644
9751
  ] }),
9645
9752
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "editor-layout-dialog-grid", children: [
9646
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "editor-layout-dialog-group", children: [
9753
+ /* @__PURE__ */ jsxRuntime.jsxs(Flex, { direction: "column", gap: 1.5, children: [
9647
9754
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-text-xs-muted", children: "Background" }),
9648
9755
  /* @__PURE__ */ jsxRuntime.jsxs(
9649
9756
  ColorPickerRoot,
@@ -9689,47 +9796,39 @@ function InsertLayoutDialog({
9689
9796
  }
9690
9797
  )
9691
9798
  ] }),
9692
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "editor-layout-dialog-group", children: [
9693
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-text-xs-muted", children: "Padding (px)" }),
9799
+ /* @__PURE__ */ jsxRuntime.jsxs(Flex, { direction: "column", gap: 1.5, children: [
9800
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-text-xs-muted", children: "Padding X (px)" }),
9694
9801
  /* @__PURE__ */ jsxRuntime.jsx(
9695
- Input,
9802
+ NumberInput,
9696
9803
  {
9697
- type: "number",
9698
9804
  min: 0,
9699
9805
  max: 64,
9700
- step: 1,
9701
- value: paddingPx,
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"
9806
+ value: paddingXPx,
9807
+ onValueChange: onPaddingXChange
9711
9808
  }
9712
9809
  )
9713
9810
  ] }),
9714
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "editor-layout-dialog-group", children: [
9811
+ /* @__PURE__ */ jsxRuntime.jsxs(Flex, { direction: "column", gap: 1.5, children: [
9812
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-text-xs-muted", children: "Padding Y (px)" }),
9813
+ /* @__PURE__ */ jsxRuntime.jsx(
9814
+ NumberInput,
9815
+ {
9816
+ min: 0,
9817
+ max: 64,
9818
+ value: paddingYPx,
9819
+ onValueChange: onPaddingYChange
9820
+ }
9821
+ )
9822
+ ] }),
9823
+ /* @__PURE__ */ jsxRuntime.jsxs(Flex, { direction: "column", gap: 1.5, children: [
9715
9824
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-text-xs-muted", children: "Border radius (px)" }),
9716
9825
  /* @__PURE__ */ jsxRuntime.jsx(
9717
- Input,
9826
+ NumberInput,
9718
9827
  {
9719
- type: "number",
9720
9828
  min: 0,
9721
9829
  max: 64,
9722
- step: 1,
9723
9830
  value: borderRadiusPx,
9724
- onChange: (event) => {
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"
9831
+ onValueChange: onBorderRadiusChange
9733
9832
  }
9734
9833
  )
9735
9834
  ] })
@@ -9740,7 +9839,7 @@ function InsertLayoutDialog({
9740
9839
  function LayoutPlugin() {
9741
9840
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
9742
9841
  const [modal, showModal] = useEditorModal();
9743
- React20.useEffect(() => {
9842
+ React21.useEffect(() => {
9744
9843
  if (!editor.hasNodes([LayoutContainerNode, LayoutItemNode])) {
9745
9844
  throw new Error(
9746
9845
  "LayoutPlugin: LayoutContainerNode, or LayoutItemNode not registered on editor"
@@ -9780,23 +9879,32 @@ function LayoutPlugin() {
9780
9879
  if (!value) {
9781
9880
  return void 0;
9782
9881
  }
9783
- const match = value.match(/^(\d+)px$/i);
9784
- if (!match?.[1]) {
9785
- return void 0;
9786
- }
9787
- const parsed = Number.parseInt(match[1], 10);
9788
- return Number.isFinite(parsed) ? parsed : void 0;
9882
+ const values = value.replace(/!important/gi, "").trim().split(/\s+/);
9883
+ const parsedValues = values.map((v) => {
9884
+ const match = v.match(/^(\d+)px/i);
9885
+ if (!match?.[1]) return null;
9886
+ const parsed = Number.parseInt(match[1], 10);
9887
+ return Number.isFinite(parsed) ? parsed : null;
9888
+ }).filter((v) => v !== null);
9889
+ if (parsedValues.length === 0) return void 0;
9890
+ return parsedValues;
9789
9891
  };
9790
9892
  const buildLayoutItemStyle = ({
9791
9893
  itemBackgroundColor,
9792
- itemPaddingPx,
9894
+ itemPaddingXPx,
9895
+ itemPaddingYPx,
9793
9896
  itemBorderRadiusPx
9794
9897
  }) => {
9795
9898
  const itemStyles = [];
9796
9899
  if (itemBackgroundColor.trim()) {
9797
9900
  itemStyles.push(`background-color: ${itemBackgroundColor.trim()}`);
9798
9901
  }
9799
- itemStyles.push(`padding: ${Math.min(Math.max(itemPaddingPx, 0), 64)}px`);
9902
+ itemStyles.push(
9903
+ `padding: ${Math.min(Math.max(itemPaddingYPx, 0), 64)}px ${Math.min(
9904
+ Math.max(itemPaddingXPx, 0),
9905
+ 64
9906
+ )}px`
9907
+ );
9800
9908
  itemStyles.push(
9801
9909
  `border-radius: ${Math.min(Math.max(itemBorderRadiusPx, 0), 64)}px`
9802
9910
  );
@@ -9809,7 +9917,10 @@ function LayoutPlugin() {
9809
9917
  return;
9810
9918
  }
9811
9919
  const background = values.itemBackgroundColor.trim();
9812
- const padding = `${Math.min(Math.max(values.itemPaddingPx, 0), 64)}px`;
9920
+ const padding = `${Math.min(Math.max(values.itemPaddingYPx, 0), 64)}px ${Math.min(
9921
+ Math.max(values.itemPaddingXPx, 0),
9922
+ 64
9923
+ )}px`;
9813
9924
  const borderRadius = `${Math.min(Math.max(values.itemBorderRadiusPx, 0), 64)}px`;
9814
9925
  if (background) {
9815
9926
  element.style.setProperty("background-color", background);
@@ -9860,14 +9971,17 @@ function LayoutPlugin() {
9860
9971
  return;
9861
9972
  }
9862
9973
  const style = layoutItem.getStyle();
9974
+ const paddingValues = extractNumericStyle(style, "padding");
9975
+ const borderRadiusValues = extractNumericStyle(style, "border-radius");
9863
9976
  payload = {
9864
9977
  containerKey: parentContainer.getKey(),
9865
9978
  layoutItemKey: layoutItem.getKey(),
9866
9979
  values: {
9867
9980
  template: parentContainer.getTemplateColumns(),
9868
9981
  itemBackgroundColor: extractStyleValue(style, "background-color") ?? "#ffffff",
9869
- itemPaddingPx: extractNumericStyle(style, "padding") ?? 12,
9870
- itemBorderRadiusPx: extractNumericStyle(style, "border-radius") ?? 8
9982
+ itemPaddingXPx: paddingValues && paddingValues.length > 1 ? paddingValues[1] : paddingValues?.[0] ?? 12,
9983
+ itemPaddingYPx: paddingValues?.[0] ?? 12,
9984
+ itemBorderRadiusPx: borderRadiusValues?.[0] ?? 8
9871
9985
  }
9872
9986
  };
9873
9987
  logger.debug("[Layout] Resolved payload from target", payload);
@@ -9980,11 +10094,13 @@ function LayoutPlugin() {
9980
10094
  editor.update(() => {
9981
10095
  const template = typeof payload === "string" ? payload : payload.template;
9982
10096
  const itemBackgroundColor = typeof payload === "string" ? void 0 : payload.itemBackgroundColor?.trim();
9983
- const itemPaddingPx = typeof payload === "string" ? void 0 : typeof payload.itemPaddingPx === "number" && Number.isFinite(payload.itemPaddingPx) ? Math.min(Math.max(payload.itemPaddingPx, 0), 64) : void 0;
10097
+ 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;
10098
+ 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
10099
  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
10100
  const itemStyle = buildLayoutItemStyle({
9986
10101
  itemBackgroundColor: itemBackgroundColor ?? "#ffffff",
9987
- itemPaddingPx: itemPaddingPx ?? 12,
10102
+ itemPaddingXPx: itemPaddingXPx ?? 12,
10103
+ itemPaddingYPx: itemPaddingYPx ?? 12,
9988
10104
  itemBorderRadiusPx: itemBorderRadiusPx ?? 8
9989
10105
  });
9990
10106
  const container = $createLayoutContainerNode(template);
@@ -10055,9 +10171,9 @@ var init_layout_plugin = __esm({
10055
10171
  init_layout_container_node();
10056
10172
  init_layout_item_node();
10057
10173
  init_button();
10174
+ init_number_input();
10058
10175
  init_select();
10059
10176
  init_color_picker();
10060
- init_input();
10061
10177
  init_flex();
10062
10178
  init_use_modal();
10063
10179
  init_logger();
@@ -10094,7 +10210,7 @@ function applyListColor(editor) {
10094
10210
  function ListColorPlugin() {
10095
10211
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
10096
10212
  const [modal, showModal] = useEditorModal();
10097
- React20__namespace.useEffect(() => {
10213
+ React21__namespace.useEffect(() => {
10098
10214
  const applyColor = (color, listKey) => {
10099
10215
  listColorStore.set(listKey, color);
10100
10216
  editor.update(() => {
@@ -10140,7 +10256,7 @@ function ListColorPlugin() {
10140
10256
  const fromAttr = listEl.getAttribute("data-list-color");
10141
10257
  const initialColor = fromStore || fromVar || fromAttr || "#000000";
10142
10258
  function ListColorModalContent({ onClose }) {
10143
- const [color, setColor] = React20__namespace.useState(initialColor);
10259
+ const [color, setColor] = React21__namespace.useState(initialColor);
10144
10260
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-list-color-dialog", children: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { direction: "column", gap: 4, children: [
10145
10261
  /* @__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
10262
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -10194,9 +10310,9 @@ var init_list_color_plugin = __esm({
10194
10310
  });
10195
10311
  function ContextMenuPlugin() {
10196
10312
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
10197
- const [contextTarget, setContextTarget] = React20.useState(null);
10198
- const [showMarkerDialog, setShowMarkerDialog] = React20.useState(false);
10199
- const [customMarker, setCustomMarker] = React20.useState("");
10313
+ const [contextTarget, setContextTarget] = React21.useState(null);
10314
+ const [showMarkerDialog, setShowMarkerDialog] = React21.useState(false);
10315
+ const [customMarker, setCustomMarker] = React21.useState("");
10200
10316
  const isInTable = (node) => utils.$findMatchingParent(node, table.$isTableCellNode) !== null;
10201
10317
  const isMergedCell = (node) => {
10202
10318
  const cell = utils.$findMatchingParent(node, table.$isTableCellNode);
@@ -10212,7 +10328,7 @@ function ContextMenuPlugin() {
10212
10328
  const listNode = utils.$findMatchingParent(node, list.$isListNode);
10213
10329
  return list.$isListNode(listNode) && listNode.getListType() === "number";
10214
10330
  };
10215
- React20.useEffect(() => {
10331
+ React21.useEffect(() => {
10216
10332
  const rootElement = editor.getRootElement();
10217
10333
  if (!rootElement) return;
10218
10334
  const onContextMenu = (event) => {
@@ -10225,7 +10341,7 @@ function ContextMenuPlugin() {
10225
10341
  rootElement.removeEventListener("contextmenu", onContextMenu);
10226
10342
  };
10227
10343
  }, [editor]);
10228
- const getContextAnchorNode = React20.useCallback(() => {
10344
+ const getContextAnchorNode = React21.useCallback(() => {
10229
10345
  if (contextTarget) {
10230
10346
  const nearestNode = lexical.$getNearestNodeFromDOMNode(contextTarget);
10231
10347
  if (nearestNode) return nearestNode;
@@ -10236,7 +10352,7 @@ function ContextMenuPlugin() {
10236
10352
  }
10237
10353
  return null;
10238
10354
  }, [contextTarget]);
10239
- const updateNumberListMarkerType = React20.useCallback((markerType) => {
10355
+ const updateNumberListMarkerType = React21.useCallback((markerType) => {
10240
10356
  editor.update(() => {
10241
10357
  const anchorNode = getContextAnchorNode();
10242
10358
  if (!anchorNode) return;
@@ -10270,7 +10386,7 @@ function ContextMenuPlugin() {
10270
10386
  listNode.replace(newList);
10271
10387
  });
10272
10388
  }, [editor, getContextAnchorNode]);
10273
- const syncMarkerToSameLevelLists = React20.useCallback((targetListNode, markerType) => {
10389
+ const syncMarkerToSameLevelLists = React21.useCallback((targetListNode, markerType) => {
10274
10390
  editor.update(() => {
10275
10391
  const parent = targetListNode.getParent();
10276
10392
  if (!parent) return;
@@ -10307,7 +10423,7 @@ function ContextMenuPlugin() {
10307
10423
  setCustomMarker("");
10308
10424
  }
10309
10425
  };
10310
- const items = React20.useMemo(() => {
10426
+ const items = React21.useMemo(() => {
10311
10427
  return [
10312
10428
  new LexicalNodeContextMenuPlugin.NodeContextMenuOption(`G\u1ED9p \xF4`, {
10313
10429
  $onSelect: () => {
@@ -10661,7 +10777,7 @@ var init_context_menu_plugin = __esm({
10661
10777
  });
10662
10778
  function DragDropPastePlugin() {
10663
10779
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
10664
- React20.useEffect(() => {
10780
+ React21.useEffect(() => {
10665
10781
  return editor.registerCommand(
10666
10782
  richText.DRAG_DROP_PASTE,
10667
10783
  (files) => {
@@ -10706,8 +10822,8 @@ function isOnMenu(element) {
10706
10822
  function DraggableBlockPlugin({
10707
10823
  anchorElem
10708
10824
  }) {
10709
- const menuRef = React20.useRef(null);
10710
- const targetLineRef = React20.useRef(null);
10825
+ const menuRef = React21.useRef(null);
10826
+ const targetLineRef = React21.useRef(null);
10711
10827
  if (!anchorElem) {
10712
10828
  return null;
10713
10829
  }
@@ -10746,7 +10862,7 @@ var init_draggable_block_plugin = __esm({
10746
10862
  });
10747
10863
  function TwitterPlugin() {
10748
10864
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
10749
- React20.useEffect(() => {
10865
+ React21.useEffect(() => {
10750
10866
  if (!editor.hasNodes([TweetNode])) {
10751
10867
  throw new Error("TwitterPlugin: TweetNode not registered on editor");
10752
10868
  }
@@ -10774,7 +10890,7 @@ var init_twitter_plugin = __esm({
10774
10890
  });
10775
10891
  function YouTubePlugin() {
10776
10892
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
10777
- React20.useEffect(() => {
10893
+ React21.useEffect(() => {
10778
10894
  if (!editor.hasNodes([YouTubeNode])) {
10779
10895
  throw new Error("YouTubePlugin: YouTubeNode not registered on editor");
10780
10896
  }
@@ -10831,9 +10947,9 @@ function AutoEmbedDialogContent({
10831
10947
  onClose,
10832
10948
  editor
10833
10949
  }) {
10834
- const [text, setText] = React20.useState("");
10835
- const [embedResult, setEmbedResult] = React20.useState(null);
10836
- const validateText = React20.useMemo(
10950
+ const [text, setText] = React21.useState("");
10951
+ const [embedResult, setEmbedResult] = React21.useState(null);
10952
+ const validateText = React21.useMemo(
10837
10953
  () => debounce2((inputText) => {
10838
10954
  const urlMatch = LexicalAutoEmbedPlugin.URL_MATCHER.exec(inputText);
10839
10955
  if (embedConfig != null && inputText != null && urlMatch != null) {
@@ -27655,13 +27771,13 @@ var init_emoji_list = __esm({
27655
27771
  });
27656
27772
  function EmojiPickerPlugin() {
27657
27773
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
27658
- const [queryString, setQueryString] = React20.useState(null);
27659
- const [emojis2, setEmojis] = React20.useState([]);
27660
- const [, setIsOpen] = React20.useState(false);
27661
- React20.useEffect(() => {
27774
+ const [queryString, setQueryString] = React21.useState(null);
27775
+ const [emojis2, setEmojis] = React21.useState([]);
27776
+ const [, setIsOpen] = React21.useState(false);
27777
+ React21.useEffect(() => {
27662
27778
  Promise.resolve().then(() => (init_emoji_list(), emoji_list_exports)).then((file) => setEmojis(file.default));
27663
27779
  }, []);
27664
- const emojiOptions = React20.useMemo(
27780
+ const emojiOptions = React21.useMemo(
27665
27781
  () => emojis2 != null ? emojis2.map(
27666
27782
  ({ emoji, aliases, tags }) => new EmojiOption(aliases[0] || "emoji", emoji, {
27667
27783
  keywords: [...aliases, ...tags]
@@ -27672,14 +27788,14 @@ function EmojiPickerPlugin() {
27672
27788
  const checkForTriggerMatch = LexicalTypeaheadMenuPlugin$1.useBasicTypeaheadTriggerMatch(":", {
27673
27789
  minLength: 0
27674
27790
  });
27675
- const options = React20.useMemo(() => {
27791
+ const options = React21.useMemo(() => {
27676
27792
  return emojiOptions.filter((option) => {
27677
27793
  return queryString != null ? new RegExp(queryString, "gi").exec(option.title) || option.keywords != null ? option.keywords.some(
27678
27794
  (keyword) => new RegExp(queryString, "gi").exec(keyword)
27679
27795
  ) : false : emojiOptions;
27680
27796
  }).slice(0, MAX_EMOJI_SUGGESTION_COUNT);
27681
27797
  }, [emojiOptions, queryString]);
27682
- const onSelectOption = React20.useCallback(
27798
+ const onSelectOption = React21.useCallback(
27683
27799
  (selectedOption, nodeToRemove, closeMenu) => {
27684
27800
  editor.update(() => {
27685
27801
  const selection = lexical.$getSelection();
@@ -27810,7 +27926,7 @@ function $textNodeTransform(node) {
27810
27926
  }
27811
27927
  }
27812
27928
  function useEmojis(editor) {
27813
- React20.useEffect(() => {
27929
+ React21.useEffect(() => {
27814
27930
  if (!editor.hasNodes([EmojiNode])) {
27815
27931
  throw new Error("EmojisPlugin: EmojiNode not registered on editor");
27816
27932
  }
@@ -27928,12 +28044,12 @@ function FloatingLinkEditor({
27928
28044
  isLinkEditMode,
27929
28045
  setIsLinkEditMode
27930
28046
  }) {
27931
- const editorRef = React20.useRef(null);
27932
- const inputRef = React20.useRef(null);
27933
- const [linkUrl, setLinkUrl] = React20.useState("");
27934
- const [editedLinkUrl, setEditedLinkUrl] = React20.useState("https://");
27935
- const [lastSelection, setLastSelection] = React20.useState(null);
27936
- const $updateLinkEditor = React20.useCallback(() => {
28047
+ const editorRef = React21.useRef(null);
28048
+ const inputRef = React21.useRef(null);
28049
+ const [linkUrl, setLinkUrl] = React21.useState("");
28050
+ const [editedLinkUrl, setEditedLinkUrl] = React21.useState("https://");
28051
+ const [lastSelection, setLastSelection] = React21.useState(null);
28052
+ const $updateLinkEditor = React21.useCallback(() => {
27937
28053
  const selection = lexical.$getSelection();
27938
28054
  let linkNode = null;
27939
28055
  let selectedNode = null;
@@ -28058,7 +28174,7 @@ function FloatingLinkEditor({
28058
28174
  }
28059
28175
  return true;
28060
28176
  }, [anchorElem, editor, setIsLinkEditMode, isLinkEditMode, linkUrl]);
28061
- React20.useEffect(() => {
28177
+ React21.useEffect(() => {
28062
28178
  const scrollerElem = anchorElem.parentElement;
28063
28179
  const update = () => {
28064
28180
  editor.getEditorState().read(() => {
@@ -28076,7 +28192,7 @@ function FloatingLinkEditor({
28076
28192
  }
28077
28193
  };
28078
28194
  }, [anchorElem.parentElement, editor, $updateLinkEditor]);
28079
- React20.useEffect(() => {
28195
+ React21.useEffect(() => {
28080
28196
  return utils.mergeRegister(
28081
28197
  editor.registerUpdateListener(({ editorState }) => {
28082
28198
  editorState.read(() => {
@@ -28104,12 +28220,12 @@ function FloatingLinkEditor({
28104
28220
  )
28105
28221
  );
28106
28222
  }, [editor, $updateLinkEditor, setIsLink, isLink]);
28107
- React20.useEffect(() => {
28223
+ React21.useEffect(() => {
28108
28224
  editor.getEditorState().read(() => {
28109
28225
  $updateLinkEditor();
28110
28226
  });
28111
28227
  }, [editor, $updateLinkEditor]);
28112
- React20.useEffect(() => {
28228
+ React21.useEffect(() => {
28113
28229
  if (isLinkEditMode && inputRef.current) {
28114
28230
  inputRef.current.focus();
28115
28231
  setTimeout(() => {
@@ -28278,9 +28394,9 @@ function FloatingLinkEditor({
28278
28394
  );
28279
28395
  }
28280
28396
  function useFloatingLinkEditorToolbar(editor, anchorElem, isLinkEditMode, setIsLinkEditMode) {
28281
- const [activeEditor, setActiveEditor] = React20.useState(editor);
28282
- const [isLink, setIsLink] = React20.useState(false);
28283
- React20.useEffect(() => {
28397
+ const [activeEditor, setActiveEditor] = React21.useState(editor);
28398
+ const [isLink, setIsLink] = React21.useState(false);
28399
+ React21.useEffect(() => {
28284
28400
  function $updateToolbar() {
28285
28401
  const selection = lexical.$getSelection();
28286
28402
  if (lexical.$isRangeSelection(selection)) {
@@ -28596,10 +28712,10 @@ var ToggleGroupContext, ToggleGroup, ToggleGroupItem;
28596
28712
  var init_toggle_group = __esm({
28597
28713
  "src/ui/toggle-group.tsx"() {
28598
28714
  init_utils();
28599
- ToggleGroupContext = React20__namespace.createContext(null);
28600
- ToggleGroup = React20__namespace.forwardRef(
28715
+ ToggleGroupContext = React21__namespace.createContext(null);
28716
+ ToggleGroup = React21__namespace.forwardRef(
28601
28717
  ({ className, type = "single", value, onValueChange, children, size, variant, ...props }, ref) => {
28602
- const contextValue = React20__namespace.useMemo(() => ({
28718
+ const contextValue = React21__namespace.useMemo(() => ({
28603
28719
  type,
28604
28720
  value: value || (type === "multiple" ? [] : ""),
28605
28721
  onValueChange: (val) => {
@@ -28616,8 +28732,8 @@ var init_toggle_group = __esm({
28616
28732
  }
28617
28733
  );
28618
28734
  ToggleGroup.displayName = "ToggleGroup";
28619
- ToggleGroupItem = React20__namespace.forwardRef(({ className, value, onClick, size: itemSize, variant: itemVariant, ...props }, ref) => {
28620
- const context = React20__namespace.useContext(ToggleGroupContext);
28735
+ ToggleGroupItem = React21__namespace.forwardRef(({ className, value, onClick, size: itemSize, variant: itemVariant, ...props }, ref) => {
28736
+ const context = React21__namespace.useContext(ToggleGroupContext);
28621
28737
  const size = itemSize || context?.size || "default";
28622
28738
  if (!context) {
28623
28739
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -28672,7 +28788,7 @@ function FontColorModalContent({
28672
28788
  onApply,
28673
28789
  onClose
28674
28790
  }) {
28675
- const [color, setColor] = React20.useState(initialColor);
28791
+ const [color, setColor] = React21.useState(initialColor);
28676
28792
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-list-color-dialog", children: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { direction: "column", gap: 4, children: [
28677
28793
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-text-xs-muted", children: "Ch\u1ECDn m\xE0u cho v\u0103n b\u1EA3n \u0111ang ch\u1ECDn." }),
28678
28794
  /* @__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 +28822,7 @@ function BgColorModalContent({
28706
28822
  onApply,
28707
28823
  onClose
28708
28824
  }) {
28709
- const [color, setColor] = React20.useState(initialColor);
28825
+ const [color, setColor] = React21.useState(initialColor);
28710
28826
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-list-color-dialog", children: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { direction: "column", gap: 4, children: [
28711
28827
  /* @__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
28828
  /* @__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 +28868,8 @@ function FloatingTextFormat({
28752
28868
  showModal,
28753
28869
  isModalOpen
28754
28870
  }) {
28755
- const popupCharStylesEditorRef = React20.useRef(null);
28756
- const insertLink = React20.useCallback(() => {
28871
+ const popupCharStylesEditorRef = React21.useRef(null);
28872
+ const insertLink = React21.useCallback(() => {
28757
28873
  if (!isLink) {
28758
28874
  setIsLinkEditMode(true);
28759
28875
  editor.dispatchCommand(link.TOGGLE_LINK_COMMAND, "https://");
@@ -28762,7 +28878,7 @@ function FloatingTextFormat({
28762
28878
  editor.dispatchCommand(link.TOGGLE_LINK_COMMAND, null);
28763
28879
  }
28764
28880
  }, [editor, isLink, setIsLinkEditMode]);
28765
- const applyStyleText = React20.useCallback(
28881
+ const applyStyleText = React21.useCallback(
28766
28882
  (styles) => {
28767
28883
  editor.update(() => {
28768
28884
  const selection$1 = lexical.$getSelection();
@@ -28773,7 +28889,7 @@ function FloatingTextFormat({
28773
28889
  },
28774
28890
  [editor]
28775
28891
  );
28776
- const onFontColorSelect = React20.useCallback(
28892
+ const onFontColorSelect = React21.useCallback(
28777
28893
  (value) => {
28778
28894
  if (value !== "inherit") {
28779
28895
  applyStyleText({ color: value });
@@ -28781,7 +28897,7 @@ function FloatingTextFormat({
28781
28897
  },
28782
28898
  [applyStyleText]
28783
28899
  );
28784
- const onBgColorSelect = React20.useCallback(
28900
+ const onBgColorSelect = React21.useCallback(
28785
28901
  (value) => {
28786
28902
  if (value !== "inherit") {
28787
28903
  applyStyleText({ "background-color": value });
@@ -28809,7 +28925,7 @@ function FloatingTextFormat({
28809
28925
  }
28810
28926
  ));
28811
28927
  };
28812
- React20.useEffect(() => {
28928
+ React21.useEffect(() => {
28813
28929
  function mouseMoveListener(e) {
28814
28930
  if (popupCharStylesEditorRef?.current && (e.buttons === 1 || e.buttons === 3)) {
28815
28931
  if (popupCharStylesEditorRef.current.style.pointerEvents !== "none") {
@@ -28838,7 +28954,7 @@ function FloatingTextFormat({
28838
28954
  };
28839
28955
  }
28840
28956
  }, [popupCharStylesEditorRef, isModalOpen]);
28841
- const $updateTextFormatFloatingToolbar = React20.useCallback(() => {
28957
+ const $updateTextFormatFloatingToolbar = React21.useCallback(() => {
28842
28958
  const selection = lexical.$getSelection();
28843
28959
  const popupCharStylesEditorElem = popupCharStylesEditorRef.current;
28844
28960
  const nativeSelection = window.getSelection();
@@ -28864,7 +28980,7 @@ function FloatingTextFormat({
28864
28980
  );
28865
28981
  }
28866
28982
  }, [editor, anchorElem, isLink]);
28867
- React20.useEffect(() => {
28983
+ React21.useEffect(() => {
28868
28984
  const scrollerElem = anchorElem.parentElement;
28869
28985
  const update = () => {
28870
28986
  editor.getEditorState().read(() => {
@@ -28882,7 +28998,7 @@ function FloatingTextFormat({
28882
28998
  }
28883
28999
  };
28884
29000
  }, [editor, $updateTextFormatFloatingToolbar, anchorElem]);
28885
- React20.useEffect(() => {
29001
+ React21.useEffect(() => {
28886
29002
  editor.getEditorState().read(() => {
28887
29003
  $updateTextFormatFloatingToolbar();
28888
29004
  });
@@ -29057,18 +29173,18 @@ function FloatingTextFormat({
29057
29173
  );
29058
29174
  }
29059
29175
  function useFloatingTextFormatToolbar(editor, anchorElem, setIsLinkEditMode, showModal, isModalOpen) {
29060
- const [isText, setIsText] = React20.useState(false);
29061
- const [isLink, setIsLink] = React20.useState(false);
29062
- const [isBold, setIsBold] = React20.useState(false);
29063
- const [isItalic, setIsItalic] = React20.useState(false);
29064
- const [isUnderline, setIsUnderline] = React20.useState(false);
29065
- const [isStrikethrough, setIsStrikethrough] = React20.useState(false);
29066
- const [isSubscript, setIsSubscript] = React20.useState(false);
29067
- const [isSuperscript, setIsSuperscript] = React20.useState(false);
29068
- const [isCode, setIsCode] = React20.useState(false);
29069
- const [fontColor, setFontColor] = React20.useState("inherit");
29070
- const [bgColor, setBgColor] = React20.useState("inherit");
29071
- const updatePopup = React20.useCallback(() => {
29176
+ const [isText, setIsText] = React21.useState(false);
29177
+ const [isLink, setIsLink] = React21.useState(false);
29178
+ const [isBold, setIsBold] = React21.useState(false);
29179
+ const [isItalic, setIsItalic] = React21.useState(false);
29180
+ const [isUnderline, setIsUnderline] = React21.useState(false);
29181
+ const [isStrikethrough, setIsStrikethrough] = React21.useState(false);
29182
+ const [isSubscript, setIsSubscript] = React21.useState(false);
29183
+ const [isSuperscript, setIsSuperscript] = React21.useState(false);
29184
+ const [isCode, setIsCode] = React21.useState(false);
29185
+ const [fontColor, setFontColor] = React21.useState("inherit");
29186
+ const [bgColor, setBgColor] = React21.useState("inherit");
29187
+ const updatePopup = React21.useCallback(() => {
29072
29188
  editor.getEditorState().read(() => {
29073
29189
  if (editor.isComposing()) {
29074
29190
  return;
@@ -29113,13 +29229,13 @@ function useFloatingTextFormatToolbar(editor, anchorElem, setIsLinkEditMode, sho
29113
29229
  }
29114
29230
  });
29115
29231
  }, [editor]);
29116
- React20.useEffect(() => {
29232
+ React21.useEffect(() => {
29117
29233
  document.addEventListener("selectionchange", updatePopup);
29118
29234
  return () => {
29119
29235
  document.removeEventListener("selectionchange", updatePopup);
29120
29236
  };
29121
29237
  }, [updatePopup]);
29122
- React20.useEffect(() => {
29238
+ React21.useEffect(() => {
29123
29239
  return utils.mergeRegister(
29124
29240
  editor.registerUpdateListener(() => {
29125
29241
  updatePopup();
@@ -29194,15 +29310,15 @@ var init_floating_text_format_plugin = __esm({
29194
29310
  });
29195
29311
  function KeywordsPlugin() {
29196
29312
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
29197
- React20.useEffect(() => {
29313
+ React21.useEffect(() => {
29198
29314
  if (!editor.hasNodes([KeywordNode])) {
29199
29315
  throw new Error("KeywordsPlugin: KeywordNode not registered on editor");
29200
29316
  }
29201
29317
  }, [editor]);
29202
- const $createKeywordNode_ = React20.useCallback((textNode) => {
29318
+ const $createKeywordNode_ = React21.useCallback((textNode) => {
29203
29319
  return $createKeywordNode(textNode.getTextContent());
29204
29320
  }, []);
29205
- const getKeywordMatch = React20.useCallback((text) => {
29321
+ const getKeywordMatch = React21.useCallback((text) => {
29206
29322
  const matchArr = KEYWORDS_REGEX.exec(text);
29207
29323
  if (matchArr === null || !matchArr[2] || !matchArr[1]) {
29208
29324
  return null;
@@ -29277,7 +29393,7 @@ function ListMaxIndentLevelPlugin({
29277
29393
  maxDepth = 7
29278
29394
  }) {
29279
29395
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
29280
- React20.useEffect(() => {
29396
+ React21.useEffect(() => {
29281
29397
  return editor.registerCommand(
29282
29398
  lexical.INDENT_CONTENT_COMMAND,
29283
29399
  () => $shouldPreventIndent(maxDepth),
@@ -29292,8 +29408,8 @@ var init_list_max_indent_level_plugin = __esm({
29292
29408
  }
29293
29409
  });
29294
29410
  function useMentionLookupService(mentionString) {
29295
- const [results, setResults] = React20.useState([]);
29296
- React20.useEffect(() => {
29411
+ const [results, setResults] = React21.useState([]);
29412
+ React21.useEffect(() => {
29297
29413
  const cachedResults = mentionsCache.get(mentionString);
29298
29414
  if (mentionString == null) {
29299
29415
  setTimeout(() => {
@@ -29339,12 +29455,12 @@ function getPossibleQueryMatch(text) {
29339
29455
  }
29340
29456
  function MentionsPlugin() {
29341
29457
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
29342
- const [queryString, setQueryString] = React20.useState(null);
29458
+ const [queryString, setQueryString] = React21.useState(null);
29343
29459
  const results = useMentionLookupService(queryString);
29344
29460
  const checkForSlashTriggerMatch = LexicalTypeaheadMenuPlugin$1.useBasicTypeaheadTriggerMatch("/", {
29345
29461
  minLength: 0
29346
29462
  });
29347
- const options = React20.useMemo(
29463
+ const options = React21.useMemo(
29348
29464
  () => results.map(
29349
29465
  (result) => new MentionTypeaheadOption(
29350
29466
  result,
@@ -29353,7 +29469,7 @@ function MentionsPlugin() {
29353
29469
  ).slice(0, SUGGESTION_LIST_LENGTH_LIMIT),
29354
29470
  [results]
29355
29471
  );
29356
- const onSelectOption = React20.useCallback(
29472
+ const onSelectOption = React21.useCallback(
29357
29473
  (selectedOption, nodeToReplace, closeMenu) => {
29358
29474
  editor.update(() => {
29359
29475
  const mentionNode = $createMentionNode(selectedOption.name);
@@ -29366,7 +29482,7 @@ function MentionsPlugin() {
29366
29482
  },
29367
29483
  [editor]
29368
29484
  );
29369
- const checkForMentionMatch = React20.useCallback(
29485
+ const checkForMentionMatch = React21.useCallback(
29370
29486
  (text) => {
29371
29487
  const slashMatch = checkForSlashTriggerMatch(text, editor);
29372
29488
  if (slashMatch !== null) {
@@ -30167,10 +30283,10 @@ function InsertTableDialog({
30167
30283
  activeEditor,
30168
30284
  onClose
30169
30285
  }) {
30170
- const [rows, setRows] = React20.useState("5");
30171
- const [columns, setColumns] = React20.useState("5");
30172
- const [includeHeaders, setIncludeHeaders] = React20.useState(true);
30173
- const isDisabled = React20.useMemo(() => {
30286
+ const [rows, setRows] = React21.useState("5");
30287
+ const [columns, setColumns] = React21.useState("5");
30288
+ const [includeHeaders, setIncludeHeaders] = React21.useState(true);
30289
+ const isDisabled = React21.useMemo(() => {
30174
30290
  const row = Number(rows);
30175
30291
  const column = Number(columns);
30176
30292
  return !(row && row > 0 && row <= 500 && column && column > 0 && column <= 100);
@@ -30254,7 +30370,7 @@ function InsertTableDialog({
30254
30370
  }
30255
30371
  function InsertTableCommandPlugin() {
30256
30372
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
30257
- React20.useEffect(() => {
30373
+ React21.useEffect(() => {
30258
30374
  if (!editor.hasNodes([table.TableNode])) return;
30259
30375
  return editor.registerCommand(
30260
30376
  INSERT_NEW_TABLE_COMMAND,
@@ -30278,7 +30394,7 @@ var init_table_plugin = __esm({
30278
30394
  init_input();
30279
30395
  init_label();
30280
30396
  INSERT_NEW_TABLE_COMMAND = lexical.createCommand("INSERT_NEW_TABLE_COMMAND");
30281
- React20.createContext({
30397
+ React21.createContext({
30282
30398
  cellEditorConfig: null,
30283
30399
  cellEditorPlugins: null,
30284
30400
  set: () => {
@@ -30336,7 +30452,7 @@ function registerKeyTimeStampTracker() {
30336
30452
  }
30337
30453
  function TabFocusPlugin() {
30338
30454
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
30339
- React20.useEffect(() => {
30455
+ React21.useEffect(() => {
30340
30456
  if (!hasRegisteredKeyDownListener) {
30341
30457
  registerKeyTimeStampTracker();
30342
30458
  hasRegisteredKeyDownListener = true;
@@ -30404,10 +30520,10 @@ function TableColumnResizerPlugin({
30404
30520
  }) {
30405
30521
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
30406
30522
  const isEditable = useLexicalEditable.useLexicalEditable();
30407
- const dragRef = React20.useRef(null);
30408
- const [hoverState, setHoverState] = React20.useState(null);
30409
- const resizerRef = React20.useRef(null);
30410
- const onPointerDownImpl = React20.useCallback((event, cell, edge) => {
30523
+ const dragRef = React21.useRef(null);
30524
+ const [hoverState, setHoverState] = React21.useState(null);
30525
+ const resizerRef = React21.useRef(null);
30526
+ const onPointerDownImpl = React21.useCallback((event, cell, edge) => {
30411
30527
  if (event.button !== 0) return;
30412
30528
  event.preventDefault();
30413
30529
  const target = event.target;
@@ -30535,7 +30651,7 @@ function TableColumnResizerPlugin({
30535
30651
  document.addEventListener("pointermove", onPointerMoveDocument);
30536
30652
  document.addEventListener("pointerup", onPointerUpDocument);
30537
30653
  }, [editor]);
30538
- const updateResizerPosition = React20.useCallback(() => {
30654
+ const updateResizerPosition = React21.useCallback(() => {
30539
30655
  const state = hoverState;
30540
30656
  if (state === null || !resizerRef.current) return;
30541
30657
  const { cellKey, edge } = state;
@@ -30557,7 +30673,7 @@ function TableColumnResizerPlugin({
30557
30673
  resizerElem.style.height = `${height}px`;
30558
30674
  resizerElem.style.opacity = "1";
30559
30675
  }, [editor, hoverState, anchorElem]);
30560
- React20.useLayoutEffect(() => {
30676
+ React21.useLayoutEffect(() => {
30561
30677
  updateResizerPosition();
30562
30678
  window.addEventListener("resize", updateResizerPosition);
30563
30679
  window.addEventListener("scroll", updateResizerPosition, true);
@@ -30580,7 +30696,7 @@ function TableColumnResizerPlugin({
30580
30696
  updateListener();
30581
30697
  };
30582
30698
  }, [editor, hoverState, updateResizerPosition]);
30583
- React20.useEffect(() => {
30699
+ React21.useEffect(() => {
30584
30700
  if (!isEditable) return;
30585
30701
  const rootElement = editor.getRootElement();
30586
30702
  if (!rootElement) return;
@@ -30637,7 +30753,7 @@ function TableColumnResizerPlugin({
30637
30753
  clearCursor();
30638
30754
  };
30639
30755
  }, [editor, isEditable, hoverState, anchorElem]);
30640
- const resizer = React20.useMemo(() => {
30756
+ const resizer = React21.useMemo(() => {
30641
30757
  const state = hoverState;
30642
30758
  if (state === null) return null;
30643
30759
  const { cellKey, edge } = state;
@@ -30709,13 +30825,13 @@ function ToolbarContext({
30709
30825
  );
30710
30826
  }
30711
30827
  function useToolbarContext() {
30712
- return React20.useContext(Context);
30828
+ return React21.useContext(Context);
30713
30829
  }
30714
30830
  var Context;
30715
30831
  var init_toolbar_context = __esm({
30716
30832
  "src/context/toolbar-context.tsx"() {
30717
30833
  "use client";
30718
- Context = React20.createContext({
30834
+ Context = React21.createContext({
30719
30835
  activeEditor: {},
30720
30836
  $updateToolbar: () => {
30721
30837
  },
@@ -30730,7 +30846,7 @@ var init_toolbar_context = __esm({
30730
30846
  function useUpdateToolbarHandler(callback) {
30731
30847
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
30732
30848
  const { activeEditor } = useToolbarContext();
30733
- React20.useEffect(() => {
30849
+ React21.useEffect(() => {
30734
30850
  return activeEditor.registerCommand(
30735
30851
  lexical.SELECTION_CHANGE_COMMAND,
30736
30852
  () => {
@@ -30743,7 +30859,7 @@ function useUpdateToolbarHandler(callback) {
30743
30859
  lexical.COMMAND_PRIORITY_CRITICAL
30744
30860
  );
30745
30861
  }, [editor, callback]);
30746
- React20.useEffect(() => {
30862
+ React21.useEffect(() => {
30747
30863
  activeEditor.getEditorState().read(() => {
30748
30864
  const selection = lexical.$getSelection();
30749
30865
  if (selection) {
@@ -30823,7 +30939,7 @@ function BlockFormatDropDown({
30823
30939
  const { activeEditor, blockType, setBlockType } = useToolbarContext();
30824
30940
  const currentBlockType = blockTypeToBlockName[blockType] ? blockType : "paragraph";
30825
30941
  const currentBlockMeta = blockTypeToBlockName[currentBlockType];
30826
- const $updateToolbar = React20.useCallback(
30942
+ const $updateToolbar = React21.useCallback(
30827
30943
  (selection) => {
30828
30944
  if (!lexical.$isRangeSelection(selection)) return;
30829
30945
  const anchorNode = selection.anchor.getNode();
@@ -31316,7 +31432,7 @@ var init_insert_table = __esm({
31316
31432
  });
31317
31433
  function ClearFormattingToolbarPlugin() {
31318
31434
  const { activeEditor } = useToolbarContext();
31319
- const clearFormatting = React20.useCallback(() => {
31435
+ const clearFormatting = React21.useCallback(() => {
31320
31436
  activeEditor.update(() => {
31321
31437
  const selection = lexical.$getSelection();
31322
31438
  if (lexical.$isRangeSelection(selection) || table.$isTableSelection(selection)) {
@@ -31388,8 +31504,8 @@ function getCodeLanguageOptions2() {
31388
31504
  }
31389
31505
  function CodeLanguageToolbarPlugin() {
31390
31506
  const { activeEditor } = useToolbarContext();
31391
- const [codeLanguage, setCodeLanguage] = React20.useState("");
31392
- const [selectedElementKey, setSelectedElementKey] = React20.useState(
31507
+ const [codeLanguage, setCodeLanguage] = React21.useState("");
31508
+ const [selectedElementKey, setSelectedElementKey] = React21.useState(
31393
31509
  null
31394
31510
  );
31395
31511
  const $updateToolbar = (selection) => {
@@ -31417,7 +31533,7 @@ function CodeLanguageToolbarPlugin() {
31417
31533
  }
31418
31534
  };
31419
31535
  useUpdateToolbarHandler($updateToolbar);
31420
- const onCodeLanguageSelect = React20.useCallback(
31536
+ const onCodeLanguageSelect = React21.useCallback(
31421
31537
  (value) => {
31422
31538
  activeEditor.update(() => {
31423
31539
  if (selectedElementKey !== null) {
@@ -31464,8 +31580,8 @@ function ElementFormatToolbarPlugin({
31464
31580
  separator = true
31465
31581
  }) {
31466
31582
  const { activeEditor } = useToolbarContext();
31467
- const [elementFormat, setElementFormat] = React20.useState("left");
31468
- const activeLayoutItemKeyRef = React20.useRef(null);
31583
+ const [elementFormat, setElementFormat] = React21.useState("left");
31584
+ const activeLayoutItemKeyRef = React21.useRef(null);
31469
31585
  const extractPadding = (style) => {
31470
31586
  const match = style.match(/padding\s*:\s*(\d+)px/i);
31471
31587
  if (!match?.[1]) return null;
@@ -31644,8 +31760,8 @@ var init_element_format_toolbar_plugin = __esm({
31644
31760
  });
31645
31761
  function FontBackgroundToolbarPlugin() {
31646
31762
  const { activeEditor } = useToolbarContext();
31647
- const [bgColor, setBgColor] = React20.useState("#fff");
31648
- const activeLayoutItemKeyRef = React20.useRef(null);
31763
+ const [bgColor, setBgColor] = React21.useState("#fff");
31764
+ const activeLayoutItemKeyRef = React21.useRef(null);
31649
31765
  const extractStyleValue = (style, property) => {
31650
31766
  const escapedProperty = property.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
31651
31767
  const match = style.match(new RegExp(`${escapedProperty}\\s*:\\s*([^;]+)`, "i"));
@@ -31686,7 +31802,7 @@ function FontBackgroundToolbarPlugin() {
31686
31802
  }
31687
31803
  };
31688
31804
  useUpdateToolbarHandler($updateToolbar);
31689
- const applyStyleText = React20.useCallback(
31805
+ const applyStyleText = React21.useCallback(
31690
31806
  (styles, skipHistoryStack) => {
31691
31807
  activeEditor.update(
31692
31808
  () => {
@@ -31701,7 +31817,7 @@ function FontBackgroundToolbarPlugin() {
31701
31817
  },
31702
31818
  [activeEditor]
31703
31819
  );
31704
- const onBgColorSelect = React20.useCallback(
31820
+ const onBgColorSelect = React21.useCallback(
31705
31821
  (value) => {
31706
31822
  let shouldApplyTextStyle = true;
31707
31823
  activeEditor.update(() => {
@@ -31782,7 +31898,7 @@ var init_font_background_toolbar_plugin = __esm({
31782
31898
  });
31783
31899
  function FontColorToolbarPlugin() {
31784
31900
  const { activeEditor } = useToolbarContext();
31785
- const [fontColor, setFontColor] = React20.useState("#000");
31901
+ const [fontColor, setFontColor] = React21.useState("#000");
31786
31902
  const $updateToolbar = (selection$1) => {
31787
31903
  if (lexical.$isRangeSelection(selection$1)) {
31788
31904
  setFontColor(
@@ -31791,7 +31907,7 @@ function FontColorToolbarPlugin() {
31791
31907
  }
31792
31908
  };
31793
31909
  useUpdateToolbarHandler($updateToolbar);
31794
- const applyStyleText = React20.useCallback(
31910
+ const applyStyleText = React21.useCallback(
31795
31911
  (styles) => {
31796
31912
  activeEditor.update(() => {
31797
31913
  const selection$1 = lexical.$getSelection();
@@ -31803,7 +31919,7 @@ function FontColorToolbarPlugin() {
31803
31919
  },
31804
31920
  [activeEditor]
31805
31921
  );
31806
- const onFontColorSelect = React20.useCallback(
31922
+ const onFontColorSelect = React21.useCallback(
31807
31923
  (value) => {
31808
31924
  applyStyleText({ color: value });
31809
31925
  },
@@ -31856,7 +31972,7 @@ var init_font_color_toolbar_plugin = __esm({
31856
31972
  });
31857
31973
  function FontFamilyToolbarPlugin() {
31858
31974
  const style = "font-family";
31859
- const [fontFamily, setFontFamily] = React20.useState("Arial");
31975
+ const [fontFamily, setFontFamily] = React21.useState("Arial");
31860
31976
  const { activeEditor } = useToolbarContext();
31861
31977
  const $updateToolbar = (selection$1) => {
31862
31978
  if (lexical.$isRangeSelection(selection$1)) {
@@ -31866,7 +31982,7 @@ function FontFamilyToolbarPlugin() {
31866
31982
  }
31867
31983
  };
31868
31984
  useUpdateToolbarHandler($updateToolbar);
31869
- const handleClick = React20.useCallback(
31985
+ const handleClick = React21.useCallback(
31870
31986
  (option) => {
31871
31987
  activeEditor.update(() => {
31872
31988
  const selection$1 = lexical.$getSelection();
@@ -31928,8 +32044,8 @@ var init_font_family_toolbar_plugin = __esm({
31928
32044
  });
31929
32045
  function FontFormatToolbarPlugin() {
31930
32046
  const { activeEditor } = useToolbarContext();
31931
- const [activeFormats, setActiveFormats] = React20.useState([]);
31932
- const $updateToolbar = React20.useCallback((selection) => {
32047
+ const [activeFormats, setActiveFormats] = React21.useState([]);
32048
+ const $updateToolbar = React21.useCallback((selection) => {
31933
32049
  if (lexical.$isRangeSelection(selection) || table.$isTableSelection(selection)) {
31934
32050
  const formats = [];
31935
32051
  FORMATS.forEach(({ format }) => {
@@ -31982,9 +32098,9 @@ var init_font_format_toolbar_plugin = __esm({
31982
32098
  });
31983
32099
  function FontSizeToolbarPlugin() {
31984
32100
  const style = "font-size";
31985
- const [fontSize, setFontSize] = React20.useState(DEFAULT_FONT_SIZE);
31986
- const fontSizeRef = React20.useRef(fontSize);
31987
- React20.useEffect(() => {
32101
+ const [fontSize, setFontSize] = React21.useState(DEFAULT_FONT_SIZE);
32102
+ const fontSizeRef = React21.useRef(fontSize);
32103
+ React21.useEffect(() => {
31988
32104
  fontSizeRef.current = fontSize;
31989
32105
  }, [fontSize]);
31990
32106
  const { activeEditor } = useToolbarContext();
@@ -32000,7 +32116,7 @@ function FontSizeToolbarPlugin() {
32000
32116
  }
32001
32117
  };
32002
32118
  useUpdateToolbarHandler($updateToolbar);
32003
- const updateFontSize = React20.useCallback(
32119
+ const updateFontSize = React21.useCallback(
32004
32120
  (newSize) => {
32005
32121
  const size = Math.min(Math.max(newSize, MIN_FONT_SIZE), MAX_FONT_SIZE);
32006
32122
  activeEditor.update(() => {
@@ -32034,9 +32150,9 @@ function FontSizeToolbarPlugin() {
32034
32150
  updateFontSize(fontSize);
32035
32151
  }
32036
32152
  };
32037
- const timerRef = React20.useRef(null);
32038
- const intervalRef = React20.useRef(null);
32039
- const stopTimer = React20.useCallback(() => {
32153
+ const timerRef = React21.useRef(null);
32154
+ const intervalRef = React21.useRef(null);
32155
+ const stopTimer = React21.useCallback(() => {
32040
32156
  if (timerRef.current) {
32041
32157
  clearTimeout(timerRef.current);
32042
32158
  timerRef.current = null;
@@ -32046,7 +32162,7 @@ function FontSizeToolbarPlugin() {
32046
32162
  intervalRef.current = null;
32047
32163
  }
32048
32164
  }, []);
32049
- const startTimer = React20.useCallback(
32165
+ const startTimer = React21.useCallback(
32050
32166
  (increment) => {
32051
32167
  stopTimer();
32052
32168
  const currentSize = typeof fontSizeRef.current === "number" ? fontSizeRef.current : DEFAULT_FONT_SIZE;
@@ -32066,7 +32182,7 @@ function FontSizeToolbarPlugin() {
32066
32182
  },
32067
32183
  [updateFontSize, stopTimer]
32068
32184
  );
32069
- React20.useEffect(() => {
32185
+ React21.useEffect(() => {
32070
32186
  return () => stopTimer();
32071
32187
  }, [stopTimer]);
32072
32188
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -32138,10 +32254,10 @@ var init_font_size_toolbar_plugin = __esm({
32138
32254
  function HistoryToolbarPlugin() {
32139
32255
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
32140
32256
  const { activeEditor, $updateToolbar } = useToolbarContext();
32141
- const [isEditable, setIsEditable] = React20.useState(editor.isEditable());
32142
- const [canUndo, setCanUndo] = React20.useState(false);
32143
- const [canRedo, setCanRedo] = React20.useState(false);
32144
- React20.useEffect(() => {
32257
+ const [isEditable, setIsEditable] = React21.useState(editor.isEditable());
32258
+ const [canUndo, setCanUndo] = React21.useState(false);
32259
+ const [canRedo, setCanRedo] = React21.useState(false);
32260
+ React21.useEffect(() => {
32145
32261
  return utils.mergeRegister(
32146
32262
  editor.registerEditableListener((editable) => {
32147
32263
  setIsEditable(editable);
@@ -32213,7 +32329,7 @@ var Toggle;
32213
32329
  var init_toggle = __esm({
32214
32330
  "src/ui/toggle.tsx"() {
32215
32331
  init_utils();
32216
- Toggle = React20__namespace.forwardRef(({ className, pressed, onPressedChange, variant = "default", size = "default", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
32332
+ Toggle = React21__namespace.forwardRef(({ className, pressed, onPressedChange, variant = "default", size = "default", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
32217
32333
  "button",
32218
32334
  {
32219
32335
  ref,
@@ -32237,7 +32353,7 @@ function LinkToolbarPlugin({
32237
32353
  setIsLinkEditMode
32238
32354
  }) {
32239
32355
  const { activeEditor } = useToolbarContext();
32240
- const [isLink, setIsLink] = React20.useState(false);
32356
+ const [isLink, setIsLink] = React21.useState(false);
32241
32357
  const $updateToolbar = (selection) => {
32242
32358
  if (lexical.$isRangeSelection(selection)) {
32243
32359
  const node = getSelectedNode(selection);
@@ -32250,7 +32366,7 @@ function LinkToolbarPlugin({
32250
32366
  }
32251
32367
  };
32252
32368
  useUpdateToolbarHandler($updateToolbar);
32253
- React20.useEffect(() => {
32369
+ React21.useEffect(() => {
32254
32370
  return activeEditor.registerCommand(
32255
32371
  lexical.KEY_MODIFIER_COMMAND,
32256
32372
  (payload) => {
@@ -32273,7 +32389,7 @@ function LinkToolbarPlugin({
32273
32389
  lexical.COMMAND_PRIORITY_NORMAL
32274
32390
  );
32275
32391
  }, [activeEditor, isLink, setIsLinkEditMode]);
32276
- const insertLink = React20.useCallback(() => {
32392
+ const insertLink = React21.useCallback(() => {
32277
32393
  if (!isLink) {
32278
32394
  setIsLinkEditMode(true);
32279
32395
  activeEditor.dispatchCommand(link.TOGGLE_LINK_COMMAND, sanitizeUrl("https://"));
@@ -32307,8 +32423,8 @@ var init_link_toolbar_plugin = __esm({
32307
32423
  });
32308
32424
  function SubSuperToolbarPlugin() {
32309
32425
  const { activeEditor } = useToolbarContext();
32310
- const [isSubscript, setIsSubscript] = React20.useState(false);
32311
- const [isSuperscript, setIsSuperscript] = React20.useState(false);
32426
+ const [isSubscript, setIsSubscript] = React21.useState(false);
32427
+ const [isSuperscript, setIsSuperscript] = React21.useState(false);
32312
32428
  const $updateToolbar = (selection) => {
32313
32429
  if (lexical.$isRangeSelection(selection) || table.$isTableSelection(selection)) {
32314
32430
  setIsSubscript(selection.hasFormat("subscript"));
@@ -32358,8 +32474,8 @@ var init_subsuper_toolbar_plugin = __esm({
32358
32474
  });
32359
32475
  function useHeaderHeight() {
32360
32476
  const { ref: headerRef, height: headerHeightValue } = useElementSize();
32361
- const [headerHeight, setHeaderHeight] = React20.useState(0);
32362
- const findAndSetHeader = React20.useCallback(() => {
32477
+ const [headerHeight, setHeaderHeight] = React21.useState(0);
32478
+ const findAndSetHeader = React21.useCallback(() => {
32363
32479
  if (typeof document === "undefined") {
32364
32480
  return null;
32365
32481
  }
@@ -32373,7 +32489,7 @@ function useHeaderHeight() {
32373
32489
  }
32374
32490
  return null;
32375
32491
  }, [headerRef]);
32376
- React20.useEffect(() => {
32492
+ React21.useEffect(() => {
32377
32493
  if (typeof document === "undefined") {
32378
32494
  return;
32379
32495
  }
@@ -32401,7 +32517,7 @@ function useHeaderHeight() {
32401
32517
  headerRef(null);
32402
32518
  };
32403
32519
  }, [findAndSetHeader, headerRef]);
32404
- React20.useEffect(() => {
32520
+ React21.useEffect(() => {
32405
32521
  if (headerHeightValue > 0) {
32406
32522
  setHeaderHeight(headerHeightValue);
32407
32523
  } else {
@@ -32433,12 +32549,12 @@ function ToolbarPlugin({
32433
32549
  }) {
32434
32550
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
32435
32551
  const { headerHeight } = useHeaderHeight();
32436
- const [activeEditor, setActiveEditor] = React20.useState(editor);
32437
- const [blockType, setBlockType] = React20.useState("paragraph");
32552
+ const [activeEditor, setActiveEditor] = React21.useState(editor);
32553
+ const [blockType, setBlockType] = React21.useState("paragraph");
32438
32554
  const [modal, showModal] = useEditorModal();
32439
32555
  const $updateToolbar = () => {
32440
32556
  };
32441
- React20.useEffect(() => {
32557
+ React21.useEffect(() => {
32442
32558
  return activeEditor.registerCommand(
32443
32559
  lexical.SELECTION_CHANGE_COMMAND,
32444
32560
  (_payload, newEditor) => {
@@ -32487,7 +32603,7 @@ var init_toolbar_plugin = __esm({
32487
32603
  });
32488
32604
  function TypingPerfPlugin() {
32489
32605
  const report = useReport();
32490
- React20.useEffect(() => {
32606
+ React21.useEffect(() => {
32491
32607
  let start = 0;
32492
32608
  let timerId;
32493
32609
  let keyPressTimerId;
@@ -32868,8 +32984,8 @@ function Plugins({
32868
32984
  readOnly = false,
32869
32985
  placeholder = ""
32870
32986
  }) {
32871
- const [floatingAnchorElem, setFloatingAnchorElem] = React20.useState(null);
32872
- const [isLinkEditMode, setIsLinkEditMode] = React20.useState(false);
32987
+ const [floatingAnchorElem, setFloatingAnchorElem] = React21.useState(null);
32988
+ const [isLinkEditMode, setIsLinkEditMode] = React21.useState(false);
32873
32989
  const onRef = (_floatingAnchorElem) => {
32874
32990
  if (_floatingAnchorElem !== null) {
32875
32991
  setFloatingAnchorElem(_floatingAnchorElem);
@@ -33074,9 +33190,9 @@ function Plugins({
33074
33190
  ] })
33075
33191
  ] }),
33076
33192
  !readOnly && /* @__PURE__ */ jsxRuntime.jsx(ActionsPlugin, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "editor-actions-bar", children: [
33077
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(CounterCharacterPlugin, { charset: "UTF-16" }) }),
33193
+ /* @__PURE__ */ jsxRuntime.jsx(Flex, { align: "center", className: "editor-flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(CounterCharacterPlugin, { charset: "UTF-16" }) }),
33078
33194
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-flex-1" }),
33079
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "editor-flex-shrink-0 editor-flex-end", children: [
33195
+ /* @__PURE__ */ jsxRuntime.jsxs(Flex, { align: "center", justify: "end", gap: 1, wrap: "nowrap", className: "editor-flex-shrink-0", children: [
33080
33196
  /* @__PURE__ */ jsxRuntime.jsx(SpeechToTextPlugin, {}),
33081
33197
  /* @__PURE__ */ jsxRuntime.jsx(ShareContentPlugin, {}),
33082
33198
  /* @__PURE__ */ jsxRuntime.jsx(ImportExportPlugin, {}),
@@ -33194,6 +33310,7 @@ var init_plugins = __esm({
33194
33310
  init_markdown_tweet_transformer();
33195
33311
  init_markdown_list_transformer();
33196
33312
  init_separator();
33313
+ init_flex();
33197
33314
  }
33198
33315
  });
33199
33316
 
@@ -33342,14 +33459,14 @@ function Editor({
33342
33459
  }) {
33343
33460
  const { ref: editorRef, width: editorWidth } = useElementSize();
33344
33461
  const editorMaxWidth = editorWidth || void 0;
33345
- const [config, setConfig] = React20.useState(null);
33346
- React20.useEffect(() => {
33462
+ const [config, setConfig] = React21.useState(null);
33463
+ React21.useEffect(() => {
33347
33464
  Promise.all([
33348
33465
  Promise.resolve().then(() => (init_nodes(), nodes_exports)).then((m) => m.nodes),
33349
33466
  Promise.resolve().then(() => (init_plugins(), plugins_exports)).then((m) => ({ Plugins: m.Plugins }))
33350
33467
  ]).then(([nodes2, { Plugins: Plugins3 }]) => setConfig({ nodes: nodes2, Plugins: Plugins3 }));
33351
33468
  }, []);
33352
- const editorConfig = React20.useMemo(() => {
33469
+ const editorConfig = React21.useMemo(() => {
33353
33470
  if (!config || !config.nodes) return null;
33354
33471
  const validNodes = config.nodes.filter((node) => {
33355
33472
  if (node === void 0) {