@editorcn/editor 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,29 +1,546 @@
1
1
  // src/rte-text-editor.tsx
2
- import { useMemo as useMemo2, useEffect as useEffect5 } from "react";
2
+ import { useMemo as useMemo2, useEffect as useEffect6 } from "react";
3
3
 
4
4
  // src/bubble-menu/index.tsx
5
5
  import { isTextSelection } from "@tiptap/core";
6
6
  import { BubbleMenu as TiptapBubbleMenu } from "@tiptap/react/menus";
7
7
  import { useCallback as useCallback3 } from "react";
8
8
 
9
- // src/bubble-menu/language-selector.tsx
10
- import { useCallback as useCallback2, useState } from "react";
9
+ // src/ui/button.tsx
10
+ import { Button as ButtonPrimitive } from "@base-ui/react/button";
11
+ import { cva } from "class-variance-authority";
11
12
 
12
- // src/rte-context.ts
13
- import { createContext, useContext } from "react";
14
- var RichTextEditorContext = createContext(null);
15
- var useRichTextEditorContext = () => {
16
- const context = useContext(RichTextEditorContext);
17
- if (!context) {
18
- throw new Error(
19
- "useRichTextEditorContext must be used within RichTextEditor"
13
+ // src/ui/utils.ts
14
+ import { clsx } from "clsx";
15
+ import { twMerge } from "tailwind-merge";
16
+ var cn = (...inputs) => twMerge(clsx(inputs));
17
+
18
+ // src/ui/button.tsx
19
+ import { jsx } from "react/jsx-runtime";
20
+ var buttonVariants = cva(
21
+ "group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
22
+ {
23
+ defaultVariants: {
24
+ size: "default",
25
+ variant: "default"
26
+ },
27
+ variants: {
28
+ size: {
29
+ default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
30
+ icon: "size-8",
31
+ "icon-lg": "size-9",
32
+ "icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
33
+ "icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
34
+ lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
35
+ sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
36
+ xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3"
37
+ },
38
+ variant: {
39
+ default: "bg-primary text-primary-foreground hover:bg-primary/80",
40
+ destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
41
+ ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
42
+ link: "text-primary underline-offset-4 hover:underline",
43
+ outline: "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
44
+ secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground"
45
+ }
46
+ }
47
+ }
48
+ );
49
+ var Button = ({
50
+ className,
51
+ variant = "default",
52
+ size = "default",
53
+ ...props
54
+ }) => /* @__PURE__ */ jsx(
55
+ ButtonPrimitive,
56
+ {
57
+ "data-slot": "button",
58
+ className: cn(buttonVariants({ className, size, variant })),
59
+ ...props
60
+ }
61
+ );
62
+
63
+ // src/ui/dialog.tsx
64
+ import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
65
+ import "react";
66
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
67
+ var Dialog = ({ ...props }) => /* @__PURE__ */ jsx2(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
68
+ var DialogTrigger = ({ ...props }) => /* @__PURE__ */ jsx2(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
69
+ var DialogPortal = ({ ...props }) => /* @__PURE__ */ jsx2(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
70
+ var DialogClose = ({ ...props }) => /* @__PURE__ */ jsx2(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
71
+ var DialogOverlay = ({
72
+ className,
73
+ ...props
74
+ }) => /* @__PURE__ */ jsx2(
75
+ DialogPrimitive.Backdrop,
76
+ {
77
+ "data-slot": "dialog-overlay",
78
+ className: cn(
79
+ "fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
80
+ className
81
+ ),
82
+ ...props
83
+ }
84
+ );
85
+ var DialogContent = ({
86
+ className,
87
+ children,
88
+ showCloseButton = true,
89
+ ...props
90
+ }) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
91
+ /* @__PURE__ */ jsx2(DialogOverlay, {}),
92
+ /* @__PURE__ */ jsxs(
93
+ DialogPrimitive.Popup,
94
+ {
95
+ "data-slot": "dialog-content",
96
+ className: cn(
97
+ "fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-none bg-popover p-4 text-xs/relaxed text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
98
+ className
99
+ ),
100
+ ...props,
101
+ children: [
102
+ children,
103
+ showCloseButton && /* @__PURE__ */ jsxs(
104
+ DialogPrimitive.Close,
105
+ {
106
+ "data-slot": "dialog-close",
107
+ render: /* @__PURE__ */ jsx2(
108
+ Button,
109
+ {
110
+ variant: "ghost",
111
+ className: "absolute top-2 right-2",
112
+ size: "icon-sm"
113
+ }
114
+ ),
115
+ children: [
116
+ "X",
117
+ /* @__PURE__ */ jsx2("span", { className: "sr-only", children: "Close" })
118
+ ]
119
+ }
120
+ )
121
+ ]
122
+ }
123
+ )
124
+ ] });
125
+ var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsx2(
126
+ "div",
127
+ {
128
+ "data-slot": "dialog-header",
129
+ className: cn("flex flex-col gap-1 text-left", className),
130
+ ...props
131
+ }
132
+ );
133
+ var DialogFooter = ({
134
+ className,
135
+ showCloseButton = false,
136
+ children,
137
+ ...props
138
+ }) => /* @__PURE__ */ jsxs(
139
+ "div",
140
+ {
141
+ "data-slot": "dialog-footer",
142
+ className: cn(
143
+ "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
144
+ className
145
+ ),
146
+ ...props,
147
+ children: [
148
+ children,
149
+ showCloseButton && /* @__PURE__ */ jsx2(DialogPrimitive.Close, { render: /* @__PURE__ */ jsx2(Button, { variant: "outline" }), children: "Close" })
150
+ ]
151
+ }
152
+ );
153
+ var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ jsx2(
154
+ DialogPrimitive.Title,
155
+ {
156
+ "data-slot": "dialog-title",
157
+ className: cn("text-sm font-medium", className),
158
+ ...props
159
+ }
160
+ );
161
+ var DialogDescription = ({
162
+ className,
163
+ ...props
164
+ }) => /* @__PURE__ */ jsx2(
165
+ DialogPrimitive.Description,
166
+ {
167
+ "data-slot": "dialog-description",
168
+ className: cn(
169
+ "text-xs/relaxed text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
170
+ className
171
+ ),
172
+ ...props
173
+ }
174
+ );
175
+
176
+ // src/ui/input.tsx
177
+ import { Input as InputPrimitive } from "@base-ui/react/input";
178
+ import "react";
179
+ import { jsx as jsx3 } from "react/jsx-runtime";
180
+ var Input = ({
181
+ className,
182
+ type,
183
+ ...props
184
+ }) => /* @__PURE__ */ jsx3(
185
+ InputPrimitive,
186
+ {
187
+ type,
188
+ "data-slot": "input",
189
+ className: cn(
190
+ "h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
191
+ className
192
+ ),
193
+ ...props
194
+ }
195
+ );
196
+
197
+ // src/ui/popover.tsx
198
+ import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
199
+ import "react";
200
+ import { jsx as jsx4 } from "react/jsx-runtime";
201
+ var Popover = ({ ...props }) => /* @__PURE__ */ jsx4(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
202
+ var PopoverTrigger = ({ ...props }) => /* @__PURE__ */ jsx4(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
203
+ var PopoverContent = ({
204
+ className,
205
+ align = "center",
206
+ alignOffset = 0,
207
+ side = "bottom",
208
+ sideOffset = 4,
209
+ ...props
210
+ }) => /* @__PURE__ */ jsx4(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx4(
211
+ PopoverPrimitive.Positioner,
212
+ {
213
+ align,
214
+ alignOffset,
215
+ side,
216
+ sideOffset,
217
+ className: "isolate z-50",
218
+ children: /* @__PURE__ */ jsx4(
219
+ PopoverPrimitive.Popup,
220
+ {
221
+ "data-slot": "popover-content",
222
+ className: cn(
223
+ "z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-none bg-popover p-2.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
224
+ className
225
+ ),
226
+ ...props
227
+ }
228
+ )
229
+ }
230
+ ) });
231
+
232
+ // src/ui/rte-button.tsx
233
+ import * as React4 from "react";
234
+ import { jsx as jsx5 } from "react/jsx-runtime";
235
+ var RteButton = React4.forwardRef(
236
+ ({ className = "", active = false, ...props }, ref) => {
237
+ const cls = [
238
+ "rte-bubble-btn",
239
+ active ? "rte-bubble-btn--active" : "",
240
+ className
241
+ ].filter(Boolean).join(" ");
242
+ return /* @__PURE__ */ jsx5("button", { ref, type: "button", className: cls, ...props });
243
+ }
244
+ );
245
+ RteButton.displayName = "RteButton";
246
+
247
+ // src/ui/rte-button-group.tsx
248
+ import * as React5 from "react";
249
+ import { jsx as jsx6 } from "react/jsx-runtime";
250
+ var RteButtonGroup = React5.forwardRef(
251
+ ({ className = "", ...props }, ref) => /* @__PURE__ */ jsx6(
252
+ "div",
253
+ {
254
+ ref,
255
+ className: `rte-bubble-group ${className}`.trim(),
256
+ ...props
257
+ }
258
+ )
259
+ );
260
+ RteButtonGroup.displayName = "RteButtonGroup";
261
+
262
+ // src/ui/rte-icon.tsx
263
+ import * as React6 from "react";
264
+ import { jsx as jsx7 } from "react/jsx-runtime";
265
+ var RteIcon = React6.forwardRef(
266
+ ({ className = "", ...props }, ref) => /* @__PURE__ */ jsx7(
267
+ "span",
268
+ {
269
+ ref,
270
+ className: `rte-bubble-btn-icon ${className}`.trim(),
271
+ ...props
272
+ }
273
+ )
274
+ );
275
+ RteIcon.displayName = "RteIcon";
276
+
277
+ // src/ui/rte-separator.tsx
278
+ import * as React7 from "react";
279
+ import { jsx as jsx8 } from "react/jsx-runtime";
280
+ var RteSeparator = React7.forwardRef(
281
+ ({ className = "", ...props }, ref) => /* @__PURE__ */ jsx8(
282
+ "div",
283
+ {
284
+ ref,
285
+ className: `rte-bubble-separator ${className}`.trim(),
286
+ ...props
287
+ }
288
+ )
289
+ );
290
+ RteSeparator.displayName = "RteSeparator";
291
+
292
+ // src/ui/rte-overlay.tsx
293
+ import * as React8 from "react";
294
+ import { jsx as jsx9 } from "react/jsx-runtime";
295
+ var RteOverlay = React8.forwardRef(
296
+ ({ className = "", ...props }, ref) => /* @__PURE__ */ jsx9(
297
+ "div",
298
+ {
299
+ ref,
300
+ role: "presentation",
301
+ className: `rte-bubble-overlay ${className}`.trim(),
302
+ ...props
303
+ }
304
+ )
305
+ );
306
+ RteOverlay.displayName = "RteOverlay";
307
+
308
+ // src/ui/rte-dropdown.tsx
309
+ import * as React9 from "react";
310
+ import { useCallback, useRef, useState } from "react";
311
+ import { jsx as jsx10, jsxs as jsxs2 } from "react/jsx-runtime";
312
+ var variantClass = {
313
+ color: "rte-bubble-dropdown--color",
314
+ default: "",
315
+ language: "rte-bubble-dropdown--language"
316
+ };
317
+ var RteDropdown = React9.forwardRef(
318
+ ({ className = "", variant = "default", children, onMouseLeave, ...props }, ref) => {
319
+ const containerRef = useRef(null);
320
+ const [pill, setPill] = useState(null);
321
+ const handleItemEnter = useCallback((target) => {
322
+ const item = target.closest(
323
+ "[data-dropdown-item]"
324
+ );
325
+ if (!item) {
326
+ return;
327
+ }
328
+ setPill({
329
+ height: item.offsetHeight,
330
+ left: item.offsetLeft,
331
+ top: item.offsetTop,
332
+ width: item.offsetWidth
333
+ });
334
+ }, []);
335
+ const handleMouseOver = useCallback(
336
+ (event) => {
337
+ handleItemEnter(event.target);
338
+ },
339
+ [handleItemEnter]
340
+ );
341
+ const handleFocus = useCallback(
342
+ (event) => {
343
+ handleItemEnter(event.target);
344
+ },
345
+ [handleItemEnter]
346
+ );
347
+ const handleMouseLeaveFn = useCallback(
348
+ (event) => {
349
+ setPill(null);
350
+ onMouseLeave?.(event);
351
+ },
352
+ [onMouseLeave]
353
+ );
354
+ const cls = ["rte-bubble-dropdown", variantClass[variant], className].filter(Boolean).join(" ");
355
+ return /* @__PURE__ */ jsxs2(
356
+ "div",
357
+ {
358
+ ref: (node) => {
359
+ containerRef.current = node;
360
+ if (typeof ref === "function") {
361
+ ref(node);
362
+ } else if (ref) {
363
+ ref.current = node;
364
+ }
365
+ },
366
+ className: cls,
367
+ onFocus: handleFocus,
368
+ onMouseLeave: handleMouseLeaveFn,
369
+ onMouseOver: handleMouseOver,
370
+ ...props,
371
+ children: [
372
+ /* @__PURE__ */ jsx10(
373
+ "div",
374
+ {
375
+ "aria-hidden": "true",
376
+ className: [
377
+ "rte-bubble-dropdown-pill",
378
+ pill ? "rte-bubble-dropdown-pill--visible" : ""
379
+ ].filter(Boolean).join(" "),
380
+ style: pill ? {
381
+ height: pill.height,
382
+ left: pill.left,
383
+ top: pill.top,
384
+ width: pill.width
385
+ } : void 0
386
+ }
387
+ ),
388
+ children
389
+ ]
390
+ }
20
391
  );
21
392
  }
22
- return context;
393
+ );
394
+ RteDropdown.displayName = "RteDropdown";
395
+
396
+ // src/ui/rte-color-swatch.tsx
397
+ import * as React10 from "react";
398
+ import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
399
+ var getCheckColor = (hex) => {
400
+ const value = hex.replace("#", "");
401
+ const r = Number.parseInt(value.slice(0, 2), 16) / 255;
402
+ const g = Number.parseInt(value.slice(2, 4), 16) / 255;
403
+ const b = Number.parseInt(value.slice(4, 6), 16) / 255;
404
+ const luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;
405
+ return luminance > 0.5 ? "#18181b" : "#ffffff";
23
406
  };
407
+ var RteColorSwatch = React10.forwardRef(
408
+ ({ color, label, variant, active = false, onSelect }, ref) => {
409
+ const checkColor = getCheckColor(color);
410
+ return /* @__PURE__ */ jsxs3(
411
+ "button",
412
+ {
413
+ ref,
414
+ type: "button",
415
+ "aria-pressed": active,
416
+ "aria-label": label,
417
+ title: label,
418
+ className: [
419
+ "rte-bubble-color-swatch",
420
+ variant === "text" ? "rte-bubble-color-swatch--text" : "rte-bubble-color-swatch--highlight",
421
+ active ? "rte-bubble-color-swatch--active" : ""
422
+ ].filter(Boolean).join(" "),
423
+ style: {
424
+ "--swatch-check": checkColor,
425
+ "--swatch-color": color
426
+ },
427
+ onMouseDown: (e) => e.preventDefault(),
428
+ onClick: () => onSelect(color),
429
+ children: [
430
+ variant === "text" && !active ? /* @__PURE__ */ jsx11("span", { className: "rte-bubble-color-glyph", "aria-hidden": "true", children: "A" }) : null,
431
+ active ? /* @__PURE__ */ jsx11("span", { className: "rte-bubble-color-check", "aria-hidden": "true", children: /* @__PURE__ */ jsx11(
432
+ "svg",
433
+ {
434
+ xmlns: "http://www.w3.org/2000/svg",
435
+ viewBox: "0 0 24 24",
436
+ fill: "none",
437
+ stroke: "currentColor",
438
+ strokeWidth: 3,
439
+ strokeLinecap: "round",
440
+ strokeLinejoin: "round",
441
+ children: /* @__PURE__ */ jsx11("path", { d: "M20 6 9 17l-5-5" })
442
+ }
443
+ ) }) : null
444
+ ]
445
+ }
446
+ );
447
+ }
448
+ );
449
+ RteColorSwatch.displayName = "RteColorSwatch";
450
+
451
+ // src/ui/rte-dropdown-item.tsx
452
+ import * as React11 from "react";
453
+ import { jsx as jsx12 } from "react/jsx-runtime";
454
+ var RteDropdownItem = React11.forwardRef(({ className = "", active = false, ...props }, ref) => {
455
+ const cls = [
456
+ "rte-bubble-dropdown-item",
457
+ active ? "rte-bubble-dropdown-item--active" : "",
458
+ className
459
+ ].filter(Boolean).join(" ");
460
+ return /* @__PURE__ */ jsx12(
461
+ "button",
462
+ {
463
+ ref,
464
+ type: "button",
465
+ "data-dropdown-item": true,
466
+ className: cls,
467
+ ...props
468
+ }
469
+ );
470
+ });
471
+ RteDropdownItem.displayName = "RteDropdownItem";
472
+
473
+ // src/ui/rte-dropdown-divider.tsx
474
+ import * as React12 from "react";
475
+ import { jsx as jsx13 } from "react/jsx-runtime";
476
+ var RteDropdownDivider = React12.forwardRef(({ className = "", ...props }, ref) => /* @__PURE__ */ jsx13(
477
+ "div",
478
+ {
479
+ ref,
480
+ className: `rte-bubble-dropdown-divider ${className}`.trim(),
481
+ ...props
482
+ }
483
+ ));
484
+ RteDropdownDivider.displayName = "RteDropdownDivider";
485
+
486
+ // src/ui/rte-dropdown-icon.tsx
487
+ import * as React13 from "react";
488
+ import { jsx as jsx14 } from "react/jsx-runtime";
489
+ var RteDropdownIcon = React13.forwardRef(
490
+ ({ className = "", ...props }, ref) => /* @__PURE__ */ jsx14(
491
+ "span",
492
+ {
493
+ ref,
494
+ className: `rte-bubble-dropdown-icon ${className}`.trim(),
495
+ ...props
496
+ }
497
+ )
498
+ );
499
+ RteDropdownIcon.displayName = "RteDropdownIcon";
500
+
501
+ // src/ui/toggle.tsx
502
+ import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
503
+ import { cva as cva2 } from "class-variance-authority";
504
+ import { jsx as jsx15 } from "react/jsx-runtime";
505
+ var toggleVariants = cva2(
506
+ "group/toggle inline-flex items-center justify-center gap-1 rounded-none text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
507
+ {
508
+ defaultVariants: {
509
+ size: "default",
510
+ variant: "default"
511
+ },
512
+ variants: {
513
+ size: {
514
+ default: "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
515
+ lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
516
+ sm: "h-7 min-w-7 rounded-none px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5"
517
+ },
518
+ variant: {
519
+ default: "bg-transparent",
520
+ outline: "border border-input bg-transparent hover:bg-muted"
521
+ }
522
+ }
523
+ }
524
+ );
525
+ var Toggle = ({
526
+ className,
527
+ variant = "default",
528
+ size = "default",
529
+ ...props
530
+ }) => /* @__PURE__ */ jsx15(
531
+ TogglePrimitive,
532
+ {
533
+ "data-slot": "toggle",
534
+ className: cn(toggleVariants({ className, size, variant })),
535
+ ...props
536
+ }
537
+ );
538
+
539
+ // src/bubble-menu/color-selector.tsx
540
+ import { useState as useState2 } from "react";
24
541
 
25
542
  // src/bubble-menu/utils.ts
26
- import { useCallback, useRef, useSyncExternalStore } from "react";
543
+ import { useCallback as useCallback2, useEffect, useRef as useRef2, useSyncExternalStore } from "react";
27
544
  var defaultEqual = (a, b) => a === b;
28
545
  var shallowEqual = (a, b) => {
29
546
  if (a === b) {
@@ -40,14 +557,16 @@ var shallowEqual = (a, b) => {
40
557
  return ak.every((k) => a[k] === b[k]);
41
558
  };
42
559
  var useEditorState = (editor, selector, isEqual = defaultEqual) => {
43
- const selectorRef = useRef(selector);
44
- selectorRef.current = selector;
45
- const isEqualRef = useRef(isEqual);
46
- isEqualRef.current = isEqual;
47
- const snapshotRef = useRef({
560
+ const selectorRef = useRef2(selector);
561
+ const isEqualRef = useRef2(isEqual);
562
+ useEffect(() => {
563
+ selectorRef.current = selector;
564
+ isEqualRef.current = isEqual;
565
+ });
566
+ const snapshotRef = useRef2({
48
567
  value: editor ? selector(editor) : void 0
49
568
  });
50
- const updateSnapshot = useCallback(() => {
569
+ const updateSnapshot = useCallback2(() => {
51
570
  if (!editor) {
52
571
  return;
53
572
  }
@@ -57,7 +576,7 @@ var useEditorState = (editor, selector, isEqual = defaultEqual) => {
57
576
  }
58
577
  snapshotRef.current = { value: next };
59
578
  }, [editor]);
60
- const subscribe = useCallback(
579
+ const subscribe = useCallback2(
61
580
  (onStoreChange) => {
62
581
  if (!editor) {
63
582
  return () => {
@@ -76,7 +595,7 @@ var useEditorState = (editor, selector, isEqual = defaultEqual) => {
76
595
  },
77
596
  [editor, updateSnapshot]
78
597
  );
79
- const getSnapshot = useCallback(() => snapshotRef.current.value, []);
598
+ const getSnapshot = useCallback2(() => snapshotRef.current.value, []);
80
599
  return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
81
600
  };
82
601
  var CODE_BLOCK_LANGUAGES = [
@@ -127,9 +646,214 @@ var CODE_BLOCK_LANGUAGE_LABELS = {
127
646
  };
128
647
  var getLanguageLabel = (lang) => CODE_BLOCK_LANGUAGE_LABELS[lang] ?? lang;
129
648
 
649
+ // src/bubble-menu/color-selector.tsx
650
+ import { Fragment, jsx as jsx16, jsxs as jsxs4 } from "react/jsx-runtime";
651
+ var RECENT_KEY = "editorcn-editor-recent-colors";
652
+ var RECENT_LIMIT = 10;
653
+ var readRecentColors = () => {
654
+ if (typeof window === "undefined") {
655
+ return [];
656
+ }
657
+ try {
658
+ const raw = window.localStorage.getItem(RECENT_KEY);
659
+ if (!raw) {
660
+ return [];
661
+ }
662
+ const parsed = JSON.parse(raw);
663
+ return Array.isArray(parsed) ? parsed.slice(0, RECENT_LIMIT) : [];
664
+ } catch {
665
+ return [];
666
+ }
667
+ };
668
+ var persistRecentColors = (recent) => {
669
+ try {
670
+ window.localStorage.setItem(RECENT_KEY, JSON.stringify(recent));
671
+ } catch {
672
+ }
673
+ };
674
+ var TEXT_COLORS = [
675
+ { color: "#0f172a", label: "Foreground" },
676
+ { color: "#ef4444", label: "Red" },
677
+ { color: "#f97316", label: "Orange" },
678
+ { color: "#f59e0b", label: "Amber" },
679
+ { color: "#22c55e", label: "Green" },
680
+ { color: "#0ea5e9", label: "Sky" },
681
+ { color: "#3b82f6", label: "Blue" },
682
+ { color: "#6366f1", label: "Indigo" },
683
+ { color: "#a855f7", label: "Purple" },
684
+ { color: "#ec4899", label: "Pink" }
685
+ ];
686
+ var HIGHLIGHT_COLORS = [
687
+ { color: "#fef08a", label: "Yellow" },
688
+ { color: "#fed7aa", label: "Orange" },
689
+ { color: "#fecaca", label: "Red" },
690
+ { color: "#fbcfe8", label: "Pink" },
691
+ { color: "#e9d5ff", label: "Purple" },
692
+ { color: "#ddd6fe", label: "Violet" },
693
+ { color: "#bfdbfe", label: "Blue" },
694
+ { color: "#a5f3fc", label: "Cyan" },
695
+ { color: "#99f6e4", label: "Teal" },
696
+ { color: "#bbf7d0", label: "Green" }
697
+ ];
698
+ var ColorSelector = ({ editor }) => {
699
+ const [open, setOpen] = useState2(false);
700
+ const [recent, setRecent] = useState2(() => readRecentColors());
701
+ const { highlightColor, textColor } = useEditorState(
702
+ editor,
703
+ (ed) => ({
704
+ highlightColor: ed.isActive("highlight") ? ed.getAttributes("highlight").color : void 0,
705
+ textColor: ed.isActive("textStyle") ? ed.getAttributes("textStyle").color : void 0
706
+ }),
707
+ shallowEqual
708
+ );
709
+ const hasColor = editor.extensionManager.extensions.some(
710
+ (ext) => ext.name === "color"
711
+ );
712
+ const hasHighlight = editor.extensionManager.extensions.some(
713
+ (ext) => ext.name === "highlight"
714
+ );
715
+ const remember = (type, color, label) => {
716
+ setRecent((prev) => {
717
+ const next = [
718
+ { color, label, type },
719
+ ...prev.filter((item) => !(item.type === type && item.color === color))
720
+ ].slice(0, RECENT_LIMIT);
721
+ persistRecentColors(next);
722
+ return next;
723
+ });
724
+ };
725
+ const selectText = (color, label) => {
726
+ remember("text", color, label);
727
+ if (textColor === color) {
728
+ editor.chain().focus().unsetColor().run();
729
+ } else {
730
+ editor.chain().focus().setColor(color).run();
731
+ }
732
+ };
733
+ const selectHighlight = (color, label) => {
734
+ remember("highlight", color, label);
735
+ if (highlightColor === color) {
736
+ editor.chain().focus().unsetHighlight().run();
737
+ } else {
738
+ editor.chain().focus().setHighlight({ color }).run();
739
+ }
740
+ };
741
+ if (!hasColor && !hasHighlight) {
742
+ return null;
743
+ }
744
+ return /* @__PURE__ */ jsxs4("div", { style: { position: "relative" }, children: [
745
+ /* @__PURE__ */ jsx16(
746
+ RteButton,
747
+ {
748
+ active: Boolean(textColor || highlightColor),
749
+ onMouseDown: (e) => e.preventDefault(),
750
+ onClick: () => setOpen(!open),
751
+ title: "Text color",
752
+ children: /* @__PURE__ */ jsx16(RteIcon, { children: /* @__PURE__ */ jsxs4(
753
+ "svg",
754
+ {
755
+ xmlns: "http://www.w3.org/2000/svg",
756
+ viewBox: "0 0 24 24",
757
+ fill: "none",
758
+ stroke: "currentColor",
759
+ strokeWidth: 2,
760
+ strokeLinecap: "round",
761
+ strokeLinejoin: "round",
762
+ className: "rte-editor-icon",
763
+ children: [
764
+ /* @__PURE__ */ jsx16("path", { d: "M4 20h16" }),
765
+ /* @__PURE__ */ jsx16("path", { d: "m6 16 6-12 6 12" }),
766
+ /* @__PURE__ */ jsx16("path", { d: "M8 12h8" })
767
+ ]
768
+ }
769
+ ) })
770
+ }
771
+ ),
772
+ open && /* @__PURE__ */ jsxs4(Fragment, { children: [
773
+ /* @__PURE__ */ jsx16(
774
+ RteOverlay,
775
+ {
776
+ onClick: () => setOpen(false),
777
+ onKeyDown: (e) => {
778
+ if (e.key === "Escape") {
779
+ setOpen(false);
780
+ }
781
+ }
782
+ }
783
+ ),
784
+ /* @__PURE__ */ jsxs4(RteDropdown, { variant: "color", children: [
785
+ recent.length > 0 ? /* @__PURE__ */ jsxs4("div", { className: "rte-bubble-color-section", children: [
786
+ /* @__PURE__ */ jsx16("span", { className: "rte-bubble-color-label", children: "Recently Used" }),
787
+ /* @__PURE__ */ jsx16("div", { className: "rte-bubble-color-recent", children: recent.map((item) => /* @__PURE__ */ jsx16(
788
+ RteColorSwatch,
789
+ {
790
+ variant: item.type,
791
+ color: item.color,
792
+ label: item.label,
793
+ active: item.type === "text" ? textColor === item.color : highlightColor === item.color,
794
+ onSelect: () => item.type === "text" ? selectText(item.color, item.label) : selectHighlight(item.color, item.label)
795
+ },
796
+ `${item.type}-${item.color}`
797
+ )) })
798
+ ] }) : null,
799
+ hasColor ? /* @__PURE__ */ jsxs4(Fragment, { children: [
800
+ recent.length > 0 && /* @__PURE__ */ jsx16(RteDropdownDivider, {}),
801
+ /* @__PURE__ */ jsxs4("div", { className: "rte-bubble-color-section", children: [
802
+ /* @__PURE__ */ jsx16("span", { className: "rte-bubble-color-label", children: "Text Color" }),
803
+ /* @__PURE__ */ jsx16("div", { className: "rte-bubble-color-grid", children: TEXT_COLORS.map((item) => /* @__PURE__ */ jsx16(
804
+ RteColorSwatch,
805
+ {
806
+ variant: "text",
807
+ color: item.color,
808
+ label: item.label,
809
+ active: textColor === item.color,
810
+ onSelect: () => selectText(item.color, item.label)
811
+ },
812
+ item.color
813
+ )) })
814
+ ] })
815
+ ] }) : null,
816
+ hasHighlight ? /* @__PURE__ */ jsxs4(Fragment, { children: [
817
+ (recent.length > 0 || hasColor) && /* @__PURE__ */ jsx16(RteDropdownDivider, {}),
818
+ /* @__PURE__ */ jsxs4("div", { className: "rte-bubble-color-section", children: [
819
+ /* @__PURE__ */ jsx16("span", { className: "rte-bubble-color-label", children: "Highlight Color" }),
820
+ /* @__PURE__ */ jsx16("div", { className: "rte-bubble-color-grid", children: HIGHLIGHT_COLORS.map((item) => /* @__PURE__ */ jsx16(
821
+ RteColorSwatch,
822
+ {
823
+ variant: "highlight",
824
+ color: item.color,
825
+ label: item.label,
826
+ active: highlightColor === item.color,
827
+ onSelect: () => selectHighlight(item.color, item.label)
828
+ },
829
+ item.color
830
+ )) })
831
+ ] })
832
+ ] }) : null
833
+ ] })
834
+ ] })
835
+ ] });
836
+ };
837
+
838
+ // src/bubble-menu/language-selector.tsx
839
+ import { useState as useState3 } from "react";
840
+
841
+ // src/rte-context.ts
842
+ import { createContext, useContext } from "react";
843
+ var RichTextEditorContext = createContext(null);
844
+ var useRichTextEditorContext = () => {
845
+ const context = useContext(RichTextEditorContext);
846
+ if (!context) {
847
+ throw new Error(
848
+ "useRichTextEditorContext must be used within RichTextEditor"
849
+ );
850
+ }
851
+ return context;
852
+ };
853
+
130
854
  // src/bubble-menu/language-selector.tsx
131
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
132
- var FallbackIcon = () => /* @__PURE__ */ jsxs(
855
+ import { Fragment as Fragment2, jsx as jsx17, jsxs as jsxs5 } from "react/jsx-runtime";
856
+ var FallbackIcon = () => /* @__PURE__ */ jsxs5(
133
857
  "svg",
134
858
  {
135
859
  xmlns: "http://www.w3.org/2000/svg",
@@ -141,14 +865,13 @@ var FallbackIcon = () => /* @__PURE__ */ jsxs(
141
865
  strokeLinejoin: "round",
142
866
  className: "rte-editor-icon",
143
867
  children: [
144
- /* @__PURE__ */ jsx("polyline", { points: "16 18 22 12 16 6" }),
145
- /* @__PURE__ */ jsx("polyline", { points: "8 6 2 12 8 18" })
868
+ /* @__PURE__ */ jsx17("polyline", { points: "16 18 22 12 16 6" }),
869
+ /* @__PURE__ */ jsx17("polyline", { points: "8 6 2 12 8 18" })
146
870
  ]
147
871
  }
148
872
  );
149
873
  var LanguageSelector = ({ editor }) => {
150
- const [open, setOpen] = useState(false);
151
- const [pill, setPill] = useState(null);
874
+ const [open, setOpen] = useState3(false);
152
875
  const { icons } = useRichTextEditorContext();
153
876
  const { currentLanguage } = useEditorState(
154
877
  editor,
@@ -157,45 +880,17 @@ var LanguageSelector = ({ editor }) => {
157
880
  }),
158
881
  shallowEqual
159
882
  );
160
- const langIcon = icons.languageIcons[currentLanguage] ?? /* @__PURE__ */ jsx(FallbackIcon, {});
161
- const handleItemEnter = useCallback2((target) => {
162
- const item = target.closest(
163
- "[data-dropdown-item]"
164
- );
165
- if (!item) {
166
- return;
167
- }
168
- setPill({
169
- height: item.offsetHeight,
170
- left: item.offsetLeft,
171
- top: item.offsetTop,
172
- width: item.offsetWidth
173
- });
174
- }, []);
175
- const handleMouseOver = useCallback2(
176
- (event) => {
177
- handleItemEnter(event.target);
178
- },
179
- [handleItemEnter]
180
- );
181
- const handleFocus = useCallback2(
182
- (event) => {
183
- handleItemEnter(event.target);
184
- },
185
- [handleItemEnter]
186
- );
187
- return /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
188
- /* @__PURE__ */ jsxs(
189
- "button",
883
+ const langIcon = icons.languageIcons[currentLanguage] ?? /* @__PURE__ */ jsx17(FallbackIcon, {});
884
+ return /* @__PURE__ */ jsxs5("div", { style: { position: "relative" }, children: [
885
+ /* @__PURE__ */ jsxs5(
886
+ RteButton,
190
887
  {
191
- type: "button",
192
- className: "rte-bubble-btn",
193
888
  onMouseDown: (e) => e.preventDefault(),
194
889
  onClick: () => setOpen(!open),
195
890
  children: [
196
- /* @__PURE__ */ jsx("span", { className: "rte-bubble-btn-icon", children: langIcon }),
197
- /* @__PURE__ */ jsx("span", { className: "rte-bubble-btn-text", children: getLanguageLabel(currentLanguage) }),
198
- /* @__PURE__ */ jsx("span", { className: "rte-bubble-btn-icon", style: { height: 12, width: 12 }, children: /* @__PURE__ */ jsx(
891
+ /* @__PURE__ */ jsx17(RteIcon, { children: langIcon }),
892
+ /* @__PURE__ */ jsx17("span", { className: "rte-bubble-btn-text", children: getLanguageLabel(currentLanguage) }),
893
+ /* @__PURE__ */ jsx17(RteIcon, { style: { height: 12, width: 12 }, children: /* @__PURE__ */ jsx17(
199
894
  "svg",
200
895
  {
201
896
  xmlns: "http://www.w3.org/2000/svg",
@@ -205,18 +900,16 @@ var LanguageSelector = ({ editor }) => {
205
900
  strokeWidth: 2,
206
901
  strokeLinecap: "round",
207
902
  strokeLinejoin: "round",
208
- children: /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" })
903
+ children: /* @__PURE__ */ jsx17("path", { d: "m6 9 6 6 6-6" })
209
904
  }
210
905
  ) })
211
906
  ]
212
907
  }
213
908
  ),
214
- open && /* @__PURE__ */ jsxs(Fragment, { children: [
215
- /* @__PURE__ */ jsx(
216
- "div",
909
+ open && /* @__PURE__ */ jsxs5(Fragment2, { children: [
910
+ /* @__PURE__ */ jsx17(
911
+ RteOverlay,
217
912
  {
218
- className: "rte-bubble-overlay",
219
- role: "presentation",
220
913
  onClick: () => setOpen(false),
221
914
  onKeyDown: (e) => {
222
915
  if (e.key === "Escape") {
@@ -225,61 +918,32 @@ var LanguageSelector = ({ editor }) => {
225
918
  }
226
919
  }
227
920
  ),
228
- /* @__PURE__ */ jsxs(
229
- "div",
921
+ /* @__PURE__ */ jsx17(RteDropdown, { variant: "language", children: CODE_BLOCK_LANGUAGES.map((lang) => /* @__PURE__ */ jsxs5(
922
+ RteDropdownItem,
230
923
  {
231
- className: "rte-bubble-dropdown rte-bubble-dropdown--language",
232
- onFocus: handleFocus,
233
- onMouseLeave: () => setPill(null),
234
- onMouseOver: handleMouseOver,
924
+ active: currentLanguage === lang,
925
+ onMouseDown: (e) => e.preventDefault(),
926
+ onClick: () => {
927
+ editor.chain().focus().updateAttributes("codeBlock", { language: lang }).run();
928
+ setOpen(false);
929
+ },
235
930
  children: [
236
- /* @__PURE__ */ jsx(
237
- "div",
238
- {
239
- "aria-hidden": "true",
240
- className: [
241
- "rte-bubble-dropdown-pill",
242
- pill ? "rte-bubble-dropdown-pill--visible" : ""
243
- ].filter(Boolean).join(" "),
244
- style: pill ? {
245
- height: pill.height,
246
- left: pill.left,
247
- top: pill.top,
248
- width: pill.width
249
- } : void 0
250
- }
251
- ),
252
- CODE_BLOCK_LANGUAGES.map((lang) => /* @__PURE__ */ jsxs(
253
- "button",
254
- {
255
- type: "button",
256
- "data-dropdown-item": true,
257
- className: `rte-bubble-dropdown-item${currentLanguage === lang ? " rte-bubble-dropdown-item--active" : ""}`,
258
- onMouseDown: (e) => e.preventDefault(),
259
- onClick: () => {
260
- editor.chain().focus().updateAttributes("codeBlock", { language: lang }).run();
261
- setOpen(false);
262
- },
263
- children: [
264
- /* @__PURE__ */ jsx("span", { className: "rte-bubble-dropdown-icon", children: icons.languageIcons[lang] ?? /* @__PURE__ */ jsx(FallbackIcon, {}) }),
265
- /* @__PURE__ */ jsx("span", { children: getLanguageLabel(lang) })
266
- ]
267
- },
268
- lang
269
- ))
931
+ /* @__PURE__ */ jsx17(RteDropdownIcon, { children: icons.languageIcons[lang] ?? /* @__PURE__ */ jsx17(FallbackIcon, {}) }),
932
+ /* @__PURE__ */ jsx17("span", { children: getLanguageLabel(lang) })
270
933
  ]
271
- }
272
- )
934
+ },
935
+ lang
936
+ )) })
273
937
  ] })
274
938
  ] });
275
939
  };
276
940
 
277
941
  // src/bubble-menu/text-buttons.tsx
278
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
942
+ import { jsx as jsx18, jsxs as jsxs6 } from "react/jsx-runtime";
279
943
  var Svg = ({
280
944
  children,
281
945
  strokeWidth = 2
282
- }) => /* @__PURE__ */ jsx2(
946
+ }) => /* @__PURE__ */ jsx18(
283
947
  "svg",
284
948
  {
285
949
  xmlns: "http://www.w3.org/2000/svg",
@@ -293,47 +957,48 @@ var Svg = ({
293
957
  children
294
958
  }
295
959
  );
960
+ var Icon = ({ children }) => /* @__PURE__ */ jsx18(RteIcon, { children });
296
961
  var textItems = [
297
962
  {
298
963
  command: (e) => e.chain().focus().toggleBold().run(),
299
- icon: /* @__PURE__ */ jsxs2(Svg, { children: [
300
- /* @__PURE__ */ jsx2("path", { d: "M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" }),
301
- /* @__PURE__ */ jsx2("path", { d: "M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" })
302
- ] }),
964
+ icon: /* @__PURE__ */ jsx18(Icon, { children: /* @__PURE__ */ jsxs6(Svg, { children: [
965
+ /* @__PURE__ */ jsx18("path", { d: "M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" }),
966
+ /* @__PURE__ */ jsx18("path", { d: "M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" })
967
+ ] }) }),
303
968
  isActive: (s) => s.isBold
304
969
  },
305
970
  {
306
971
  command: (e) => e.chain().focus().toggleItalic().run(),
307
- icon: /* @__PURE__ */ jsxs2(Svg, { children: [
308
- /* @__PURE__ */ jsx2("line", { x1: "19", y1: "4", x2: "10", y2: "4" }),
309
- /* @__PURE__ */ jsx2("line", { x1: "14", y1: "20", x2: "5", y2: "20" }),
310
- /* @__PURE__ */ jsx2("line", { x1: "15", y1: "4", x2: "9", y2: "20" })
311
- ] }),
972
+ icon: /* @__PURE__ */ jsx18(Icon, { children: /* @__PURE__ */ jsxs6(Svg, { children: [
973
+ /* @__PURE__ */ jsx18("line", { x1: "19", y1: "4", x2: "10", y2: "4" }),
974
+ /* @__PURE__ */ jsx18("line", { x1: "14", y1: "20", x2: "5", y2: "20" }),
975
+ /* @__PURE__ */ jsx18("line", { x1: "15", y1: "4", x2: "9", y2: "20" })
976
+ ] }) }),
312
977
  isActive: (s) => s.isItalic
313
978
  },
314
979
  {
315
980
  command: (e) => e.chain().focus().toggleUnderline().run(),
316
- icon: /* @__PURE__ */ jsxs2(Svg, { children: [
317
- /* @__PURE__ */ jsx2("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
318
- /* @__PURE__ */ jsx2("line", { x1: "4", y1: "20", x2: "20", y2: "20" })
319
- ] }),
981
+ icon: /* @__PURE__ */ jsx18(Icon, { children: /* @__PURE__ */ jsxs6(Svg, { children: [
982
+ /* @__PURE__ */ jsx18("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
983
+ /* @__PURE__ */ jsx18("line", { x1: "4", y1: "20", x2: "20", y2: "20" })
984
+ ] }) }),
320
985
  isActive: (s) => s.isUnderline
321
986
  },
322
987
  {
323
988
  command: (e) => e.chain().focus().toggleStrike().run(),
324
- icon: /* @__PURE__ */ jsxs2(Svg, { children: [
325
- /* @__PURE__ */ jsx2("path", { d: "M16 4H9.5a3.5 3.5 0 0 0-2.9 5.4" }),
326
- /* @__PURE__ */ jsx2("path", { d: "M14.5 14.6a3.5 3.5 0 0 1-2.9 5.4H8" }),
327
- /* @__PURE__ */ jsx2("line", { x1: "4", y1: "12", x2: "20", y2: "12" })
328
- ] }),
989
+ icon: /* @__PURE__ */ jsx18(Icon, { children: /* @__PURE__ */ jsxs6(Svg, { children: [
990
+ /* @__PURE__ */ jsx18("path", { d: "M16 4H9.5a3.5 3.5 0 0 0-2.9 5.4" }),
991
+ /* @__PURE__ */ jsx18("path", { d: "M14.5 14.6a3.5 3.5 0 0 1-2.9 5.4H8" }),
992
+ /* @__PURE__ */ jsx18("line", { x1: "4", y1: "12", x2: "20", y2: "12" })
993
+ ] }) }),
329
994
  isActive: (s) => s.isStrike
330
995
  },
331
996
  {
332
997
  command: (e) => e.chain().focus().toggleCode().run(),
333
- icon: /* @__PURE__ */ jsxs2(Svg, { children: [
334
- /* @__PURE__ */ jsx2("polyline", { points: "16 18 22 12 16 6" }),
335
- /* @__PURE__ */ jsx2("polyline", { points: "8 6 2 12 8 18" })
336
- ] }),
998
+ icon: /* @__PURE__ */ jsx18(Icon, { children: /* @__PURE__ */ jsxs6(Svg, { children: [
999
+ /* @__PURE__ */ jsx18("polyline", { points: "16 18 22 12 16 6" }),
1000
+ /* @__PURE__ */ jsx18("polyline", { points: "8 6 2 12 8 18" })
1001
+ ] }) }),
337
1002
  isActive: (s) => s.isCode
338
1003
  }
339
1004
  ];
@@ -349,11 +1014,10 @@ var TextButtons = ({ editor }) => {
349
1014
  }),
350
1015
  shallowEqual
351
1016
  );
352
- return /* @__PURE__ */ jsx2("div", { className: "rte-bubble-group", children: textItems.map((item, i) => /* @__PURE__ */ jsx2(
353
- "button",
1017
+ return /* @__PURE__ */ jsx18(RteButtonGroup, { children: textItems.map((item, i) => /* @__PURE__ */ jsx18(
1018
+ RteButton,
354
1019
  {
355
- type: "button",
356
- className: `rte-bubble-btn${item.isActive(editorState) ? " rte-bubble-btn--active" : ""}`,
1020
+ active: item.isActive(editorState),
357
1021
  onMouseDown: (e) => e.preventDefault(),
358
1022
  onClick: () => item.command(editor),
359
1023
  children: item.icon
@@ -363,7 +1027,7 @@ var TextButtons = ({ editor }) => {
363
1027
  };
364
1028
 
365
1029
  // src/bubble-menu/index.tsx
366
- import { jsx as jsx3 } from "react/jsx-runtime";
1030
+ import { Fragment as Fragment3, jsx as jsx19, jsxs as jsxs7 } from "react/jsx-runtime";
367
1031
  var BubbleMenu = ({ editor }) => {
368
1032
  const editorState = useEditorState(
369
1033
  editor,
@@ -395,13 +1059,17 @@ var BubbleMenu = ({ editor }) => {
395
1059
  return null;
396
1060
  }
397
1061
  const isCodeBlockActive = editorState?.isCodeBlock ?? false;
398
- return /* @__PURE__ */ jsx3(
1062
+ return /* @__PURE__ */ jsx19(
399
1063
  TiptapBubbleMenu,
400
1064
  {
401
1065
  editor,
402
1066
  options: { offset: 8, placement: "top" },
403
1067
  shouldShow,
404
- children: /* @__PURE__ */ jsx3("div", { className: "rte-bubble-menu", children: isCodeBlockActive ? /* @__PURE__ */ jsx3(LanguageSelector, { editor }) : /* @__PURE__ */ jsx3(TextButtons, { editor }) })
1068
+ children: /* @__PURE__ */ jsx19("div", { className: "rte-bubble-menu", children: isCodeBlockActive ? /* @__PURE__ */ jsx19(LanguageSelector, { editor }) : /* @__PURE__ */ jsxs7(Fragment3, { children: [
1069
+ /* @__PURE__ */ jsx19(TextButtons, { editor }),
1070
+ /* @__PURE__ */ jsx19(RteSeparator, {}),
1071
+ /* @__PURE__ */ jsx19(ColorSelector, { editor })
1072
+ ] }) })
405
1073
  }
406
1074
  );
407
1075
  };
@@ -409,54 +1077,7 @@ var BubbleMenu = ({ editor }) => {
409
1077
  // src/controls/rte-control.tsx
410
1078
  import { useEditorState as useEditorState2 } from "@tiptap/react";
411
1079
  import "react";
412
-
413
- // src/ui/toggle.tsx
414
- import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
415
- import { cva } from "class-variance-authority";
416
-
417
- // src/ui/utils.ts
418
- import { clsx } from "clsx";
419
- import { twMerge } from "tailwind-merge";
420
- var cn = (...inputs) => twMerge(clsx(inputs));
421
-
422
- // src/ui/toggle.tsx
423
- import { jsx as jsx4 } from "react/jsx-runtime";
424
- var toggleVariants = cva(
425
- "group/toggle inline-flex items-center justify-center gap-1 rounded-none text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
426
- {
427
- defaultVariants: {
428
- size: "default",
429
- variant: "default"
430
- },
431
- variants: {
432
- size: {
433
- default: "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
434
- lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
435
- sm: "h-7 min-w-7 rounded-none px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5"
436
- },
437
- variant: {
438
- default: "bg-transparent",
439
- outline: "border border-input bg-transparent hover:bg-muted"
440
- }
441
- }
442
- }
443
- );
444
- var Toggle = ({
445
- className,
446
- variant = "default",
447
- size = "default",
448
- ...props
449
- }) => /* @__PURE__ */ jsx4(
450
- TogglePrimitive,
451
- {
452
- "data-slot": "toggle",
453
- className: cn(toggleVariants({ className, size, variant })),
454
- ...props
455
- }
456
- );
457
-
458
- // src/controls/rte-control.tsx
459
- import { jsx as jsx5 } from "react/jsx-runtime";
1080
+ import { jsx as jsx20 } from "react/jsx-runtime";
460
1081
  var RichTextEditorControl = ({
461
1082
  active,
462
1083
  interactive: _interactive = true,
@@ -466,7 +1087,7 @@ var RichTextEditorControl = ({
466
1087
  onClick,
467
1088
  disabled,
468
1089
  ...props
469
- }) => /* @__PURE__ */ jsx5(
1090
+ }) => /* @__PURE__ */ jsx20(
470
1091
  Toggle,
471
1092
  {
472
1093
  size: "sm",
@@ -515,7 +1136,7 @@ var createControl = ({
515
1136
  });
516
1137
  const active = editorState?.active ?? false;
517
1138
  const disabled = editorState?.disabled ?? true;
518
- return /* @__PURE__ */ jsx5(
1139
+ return /* @__PURE__ */ jsx20(
519
1140
  RichTextEditorControl,
520
1141
  {
521
1142
  active,
@@ -658,6 +1279,7 @@ var H6Control = createControl({
658
1279
  });
659
1280
  var AlignLeftControl = createControl({
660
1281
  iconKey: "alignLeftControlIcon",
1282
+ isActive: { attrs: { textAlign: "left" } },
661
1283
  label: "alignLeftControlLabel",
662
1284
  operation: { attributes: "left", name: "setTextAlign" }
663
1285
  });
@@ -699,119 +1321,14 @@ var SuperscriptControl = createControl({
699
1321
  });
700
1322
 
701
1323
  // src/controls/rte-link-control.tsx
702
- import { useEditorState as useEditorState3 } from "@tiptap/react";
703
- import * as React4 from "react";
704
- import { useCallback as useCallback4, useState as useState2 } from "react";
705
-
706
- // src/ui/button.tsx
707
- import { Button as ButtonPrimitive } from "@base-ui/react/button";
708
- import { cva as cva2 } from "class-variance-authority";
709
- import { jsx as jsx6 } from "react/jsx-runtime";
710
- var buttonVariants = cva2(
711
- "group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
712
- {
713
- defaultVariants: {
714
- size: "default",
715
- variant: "default"
716
- },
717
- variants: {
718
- size: {
719
- default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
720
- icon: "size-8",
721
- "icon-lg": "size-9",
722
- "icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
723
- "icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
724
- lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
725
- sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
726
- xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3"
727
- },
728
- variant: {
729
- default: "bg-primary text-primary-foreground hover:bg-primary/80",
730
- destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
731
- ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
732
- link: "text-primary underline-offset-4 hover:underline",
733
- outline: "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
734
- secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground"
735
- }
736
- }
737
- }
738
- );
739
- var Button = ({
740
- className,
741
- variant = "default",
742
- size = "default",
743
- ...props
744
- }) => /* @__PURE__ */ jsx6(
745
- ButtonPrimitive,
746
- {
747
- "data-slot": "button",
748
- className: cn(buttonVariants({ className, size, variant })),
749
- ...props
750
- }
751
- );
752
-
753
- // src/ui/input.tsx
754
- import { Input as InputPrimitive } from "@base-ui/react/input";
755
- import "react";
756
- import { jsx as jsx7 } from "react/jsx-runtime";
757
- var Input = ({
758
- className,
759
- type,
760
- ...props
761
- }) => /* @__PURE__ */ jsx7(
762
- InputPrimitive,
763
- {
764
- type,
765
- "data-slot": "input",
766
- className: cn(
767
- "h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
768
- className
769
- ),
770
- ...props
771
- }
772
- );
773
-
774
- // src/ui/popover.tsx
775
- import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
776
- import "react";
777
- import { jsx as jsx8 } from "react/jsx-runtime";
778
- var Popover = ({ ...props }) => /* @__PURE__ */ jsx8(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
779
- var PopoverTrigger = ({ ...props }) => /* @__PURE__ */ jsx8(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
780
- var PopoverContent = ({
781
- className,
782
- align = "center",
783
- alignOffset = 0,
784
- side = "bottom",
785
- sideOffset = 4,
786
- ...props
787
- }) => /* @__PURE__ */ jsx8(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx8(
788
- PopoverPrimitive.Positioner,
789
- {
790
- align,
791
- alignOffset,
792
- side,
793
- sideOffset,
794
- className: "isolate z-50",
795
- children: /* @__PURE__ */ jsx8(
796
- PopoverPrimitive.Popup,
797
- {
798
- "data-slot": "popover-content",
799
- className: cn(
800
- "z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-none bg-popover p-2.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
801
- className
802
- ),
803
- ...props
804
- }
805
- )
806
- }
807
- ) });
808
-
809
- // src/controls/rte-link-control.tsx
810
- import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
1324
+ import { useEditorState as useEditorState3 } from "@tiptap/react";
1325
+ import * as React15 from "react";
1326
+ import { useCallback as useCallback4, useState as useState4 } from "react";
1327
+ import { jsx as jsx21, jsxs as jsxs8 } from "react/jsx-runtime";
811
1328
  var LinkControl = () => {
812
1329
  const { editor, labels, icons } = useRichTextEditorContext();
813
- const [url, setUrl] = useState2("");
814
- const [open, setOpen] = useState2(false);
1330
+ const [url, setUrl] = useState4("");
1331
+ const [open, setOpen] = useState4(false);
815
1332
  const active = useEditorState3({
816
1333
  editor: editor ?? null,
817
1334
  selector: (ctx) => ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("link") : false
@@ -846,16 +1363,16 @@ var LinkControl = () => {
846
1363
  handleSave();
847
1364
  }
848
1365
  };
849
- React4.useEffect(() => {
1366
+ React15.useEffect(() => {
850
1367
  const handler = () => handleOpen(true);
851
1368
  window.addEventListener("edit-link", handler);
852
1369
  return () => window.removeEventListener("edit-link", handler);
853
1370
  }, [handleOpen]);
854
- return /* @__PURE__ */ jsxs3(Popover, { open, onOpenChange: handleOpen, children: [
855
- /* @__PURE__ */ jsx9(
1371
+ return /* @__PURE__ */ jsxs8(Popover, { open, onOpenChange: handleOpen, children: [
1372
+ /* @__PURE__ */ jsx21(
856
1373
  PopoverTrigger,
857
1374
  {
858
- render: /* @__PURE__ */ jsx9(
1375
+ render: /* @__PURE__ */ jsx21(
859
1376
  Toggle,
860
1377
  {
861
1378
  size: "sm",
@@ -869,8 +1386,8 @@ var LinkControl = () => {
869
1386
  children: icons.linkControlIcon
870
1387
  }
871
1388
  ),
872
- /* @__PURE__ */ jsx9(PopoverContent, { className: "w-72 p-3", children: /* @__PURE__ */ jsxs3("div", { className: "rte-link-editor", children: [
873
- /* @__PURE__ */ jsx9(
1389
+ /* @__PURE__ */ jsx21(PopoverContent, { className: "w-72 p-3", children: /* @__PURE__ */ jsxs8("div", { className: "rte-link-editor", children: [
1390
+ /* @__PURE__ */ jsx21(
874
1391
  Input,
875
1392
  {
876
1393
  type: "url",
@@ -882,7 +1399,7 @@ var LinkControl = () => {
882
1399
  className: "rte-link-editor-input h-8 text-sm"
883
1400
  }
884
1401
  ),
885
- /* @__PURE__ */ jsx9(
1402
+ /* @__PURE__ */ jsx21(
886
1403
  Button,
887
1404
  {
888
1405
  size: "sm",
@@ -899,32 +1416,453 @@ var LinkControl = () => {
899
1416
  // src/controls/rte-twitter-control.tsx
900
1417
  import { Node, nodeInputRule } from "@tiptap/core";
901
1418
  import { ReactNodeViewRenderer, useEditorState as useEditorState4 } from "@tiptap/react";
902
- import { useState as useState3, useCallback as useCallback6, useEffect as useEffect3, useRef as useRef3 } from "react";
1419
+ import { useState as useState6, useCallback as useCallback6, useEffect as useEffect4, useRef as useRef4 } from "react";
903
1420
 
904
1421
  // src/extensions/resizable-node-view.tsx
905
1422
  import { NodeViewWrapper } from "@tiptap/react";
906
- import { useCallback as useCallback5, useRef as useRef2, useEffect as useEffect2 } from "react";
907
- import { Fragment as Fragment2, jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
1423
+ import { useCallback as useCallback5, useEffect as useEffect3, useRef as useRef3, useState as useState5 } from "react";
1424
+
1425
+ // src/icons.tsx
1426
+ import {
1427
+ Bold,
1428
+ Code,
1429
+ Heading1,
1430
+ Heading2,
1431
+ Heading3,
1432
+ Heading4,
1433
+ Heading5,
1434
+ Heading6,
1435
+ Highlighter,
1436
+ Italic,
1437
+ Link,
1438
+ Link2Off,
1439
+ List,
1440
+ ListOrdered,
1441
+ Minus,
1442
+ Redo2,
1443
+ RemoveFormatting,
1444
+ SquareCode,
1445
+ Strikethrough,
1446
+ Subscript,
1447
+ Superscript,
1448
+ TextAlignCenter,
1449
+ TextAlignEnd,
1450
+ TextAlignJustify,
1451
+ TextAlignStart,
1452
+ TextQuote,
1453
+ Underline,
1454
+ Undo2
1455
+ } from "lucide-react";
1456
+ import "react";
1457
+ import { Fragment as Fragment4, jsx as jsx22, jsxs as jsxs9 } from "react/jsx-runtime";
1458
+ var ALIGN_PATHS = {
1459
+ center: /* @__PURE__ */ jsxs9(Fragment4, { children: [
1460
+ /* @__PURE__ */ jsx22("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
1461
+ /* @__PURE__ */ jsx22("line", { x1: "17", y1: "12", x2: "7", y2: "12" }),
1462
+ /* @__PURE__ */ jsx22("line", { x1: "19", y1: "18", x2: "5", y2: "18" })
1463
+ ] }),
1464
+ left: /* @__PURE__ */ jsxs9(Fragment4, { children: [
1465
+ /* @__PURE__ */ jsx22("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
1466
+ /* @__PURE__ */ jsx22("line", { x1: "15", y1: "12", x2: "3", y2: "12" }),
1467
+ /* @__PURE__ */ jsx22("line", { x1: "17", y1: "18", x2: "3", y2: "18" })
1468
+ ] }),
1469
+ right: /* @__PURE__ */ jsxs9(Fragment4, { children: [
1470
+ /* @__PURE__ */ jsx22("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
1471
+ /* @__PURE__ */ jsx22("line", { x1: "21", y1: "12", x2: "9", y2: "12" }),
1472
+ /* @__PURE__ */ jsx22("line", { x1: "21", y1: "18", x2: "7", y2: "18" })
1473
+ ] })
1474
+ };
1475
+ var AlignIcon = ({ dir }) => /* @__PURE__ */ jsx22(
1476
+ "svg",
1477
+ {
1478
+ xmlns: "http://www.w3.org/2000/svg",
1479
+ viewBox: "0 0 24 24",
1480
+ fill: "none",
1481
+ stroke: "currentColor",
1482
+ strokeWidth: "2",
1483
+ strokeLinecap: "round",
1484
+ strokeLinejoin: "round",
1485
+ className: "rte-editor-icon",
1486
+ children: ALIGN_PATHS[dir]
1487
+ }
1488
+ );
1489
+ var EditUrlIcon = () => /* @__PURE__ */ jsxs9(
1490
+ "svg",
1491
+ {
1492
+ xmlns: "http://www.w3.org/2000/svg",
1493
+ viewBox: "0 0 24 24",
1494
+ fill: "none",
1495
+ stroke: "currentColor",
1496
+ strokeWidth: "2",
1497
+ strokeLinecap: "round",
1498
+ strokeLinejoin: "round",
1499
+ className: "rte-editor-icon",
1500
+ children: [
1501
+ /* @__PURE__ */ jsx22("path", { d: "M12 20h9" }),
1502
+ /* @__PURE__ */ jsx22("path", { d: "M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z" })
1503
+ ]
1504
+ }
1505
+ );
1506
+ var OpenInYouTubeIcon = () => /* @__PURE__ */ jsxs9(
1507
+ "svg",
1508
+ {
1509
+ xmlns: "http://www.w3.org/2000/svg",
1510
+ viewBox: "0 0 24 24",
1511
+ fill: "none",
1512
+ stroke: "currentColor",
1513
+ strokeWidth: "2",
1514
+ strokeLinecap: "round",
1515
+ strokeLinejoin: "round",
1516
+ className: "rte-editor-icon",
1517
+ children: [
1518
+ /* @__PURE__ */ jsx22("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
1519
+ /* @__PURE__ */ jsx22("polyline", { points: "15 3 21 3 21 9" }),
1520
+ /* @__PURE__ */ jsx22("line", { x1: "10", y1: "14", x2: "21", y2: "3" })
1521
+ ]
1522
+ }
1523
+ );
1524
+ var DeleteEmbedIcon = () => /* @__PURE__ */ jsxs9(
1525
+ "svg",
1526
+ {
1527
+ xmlns: "http://www.w3.org/2000/svg",
1528
+ viewBox: "0 0 24 24",
1529
+ fill: "none",
1530
+ stroke: "currentColor",
1531
+ strokeWidth: "2",
1532
+ strokeLinecap: "round",
1533
+ strokeLinejoin: "round",
1534
+ className: "rte-editor-icon",
1535
+ children: [
1536
+ /* @__PURE__ */ jsx22("polyline", { points: "3 6 5 6 21 6" }),
1537
+ /* @__PURE__ */ jsx22("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })
1538
+ ]
1539
+ }
1540
+ );
1541
+ var iconProps = { className: "rte-editor-icon" };
1542
+ var LangIcon = ({
1543
+ children,
1544
+ className
1545
+ }) => /* @__PURE__ */ jsx22(
1546
+ "svg",
1547
+ {
1548
+ xmlns: "http://www.w3.org/2000/svg",
1549
+ viewBox: "0 0 24 24",
1550
+ fill: "none",
1551
+ stroke: "currentColor",
1552
+ strokeWidth: 1.5,
1553
+ strokeLinecap: "round",
1554
+ strokeLinejoin: "round",
1555
+ className,
1556
+ children
1557
+ }
1558
+ );
1559
+ var DEFAULT_LANGUAGE_ICONS = {
1560
+ bash: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1561
+ /* @__PURE__ */ jsx22("rect", { x: "2.5", y: "4", width: "19", height: "16", rx: "2" }),
1562
+ /* @__PURE__ */ jsx22("path", { d: "M6.5 9.5l3.5 3-3.5 3" }),
1563
+ /* @__PURE__ */ jsx22("path", { d: "M12 15.5h5.5" })
1564
+ ] }),
1565
+ c: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1566
+ /* @__PURE__ */ jsx22("circle", { cx: "12", cy: "12", r: "8.5" }),
1567
+ /* @__PURE__ */ jsx22("path", { d: "M15.6 9.3a4.5 4.5 0 1 0 0 5.4" })
1568
+ ] }),
1569
+ cpp: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1570
+ /* @__PURE__ */ jsx22("circle", { cx: "9.5", cy: "12", r: "6.5" }),
1571
+ /* @__PURE__ */ jsx22("path", { d: "M12.3 9.7a3.3 3.3 0 1 0 0 4.6" }),
1572
+ /* @__PURE__ */ jsx22("path", { d: "M15.7 10.5v3M14.2 12h3" }),
1573
+ /* @__PURE__ */ jsx22("path", { d: "M19.3 10.5v3M17.8 12h3" })
1574
+ ] }),
1575
+ css: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1576
+ /* @__PURE__ */ jsx22("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1577
+ /* @__PURE__ */ jsx22("path", { d: "M9.7 7.5l-1 9" }),
1578
+ /* @__PURE__ */ jsx22("path", { d: "M15.3 7.5l-1 9" }),
1579
+ /* @__PURE__ */ jsx22("path", { d: "M7 10.3h11" }),
1580
+ /* @__PURE__ */ jsx22("path", { d: "M6.5 14.3h11" })
1581
+ ] }),
1582
+ go: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1583
+ /* @__PURE__ */ jsx22("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1584
+ /* @__PURE__ */ jsx22("path", { d: "M12.6 9.7A3.3 3.3 0 1 0 12.6 14.3" }),
1585
+ /* @__PURE__ */ jsx22("path", { d: "M12.6 12h-1.9" }),
1586
+ /* @__PURE__ */ jsx22("circle", { cx: "17", cy: "12", r: "2.9" })
1587
+ ] }),
1588
+ html: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1589
+ /* @__PURE__ */ jsx22("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1590
+ /* @__PURE__ */ jsx22("path", { d: "M9.5 8.5L6.5 12l3 3.5" }),
1591
+ /* @__PURE__ */ jsx22("path", { d: "M14.5 8.5L17.5 12l-3 3.5" }),
1592
+ /* @__PURE__ */ jsx22("path", { d: "M13 7.3l-2 9.4" })
1593
+ ] }),
1594
+ java: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1595
+ /* @__PURE__ */ jsx22("path", { d: "M6 10h10v5a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3v-5z" }),
1596
+ /* @__PURE__ */ jsx22("path", { d: "M16 12h1.3a1.8 1.8 0 0 1 0 3.6H16" }),
1597
+ /* @__PURE__ */ jsx22("path", { d: "M9.3 3.8c-.9.8-.9 1.6 0 2.4M13.3 3.8c-.9.8-.9 1.6 0 2.4" }),
1598
+ /* @__PURE__ */ jsx22("path", { d: "M6 19.3h10" })
1599
+ ] }),
1600
+ javascript: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1601
+ /* @__PURE__ */ jsx22("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1602
+ /* @__PURE__ */ jsx22("path", { d: "M10.5 8v6.5a2 2 0 0 1-3.5 1.3" }),
1603
+ /* @__PURE__ */ jsx22("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
1604
+ ] }),
1605
+ json: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1606
+ /* @__PURE__ */ jsx22("path", { d: "M8 3H7a2 2 0 0 0-2 2v4a2 2 0 0 1-2 2 2 2 0 0 1 2 2v4a2 2 0 0 0 2 2" }),
1607
+ /* @__PURE__ */ jsx22("path", { d: "M16 3h1a2 2 0 0 1 2 2v4a2 2 0 0 0 2 2 2 2 0 0 0-2 2v4a2 2 0 0 1-2 2" })
1608
+ ] }),
1609
+ kotlin: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1610
+ /* @__PURE__ */ jsx22("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1611
+ /* @__PURE__ */ jsx22("path", { d: "M9 7.5v9" }),
1612
+ /* @__PURE__ */ jsx22("path", { d: "M9 12l6-4.5" }),
1613
+ /* @__PURE__ */ jsx22("path", { d: "M9 12l6 4.5" })
1614
+ ] }),
1615
+ markdown: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1616
+ /* @__PURE__ */ jsx22("rect", { x: "2", y: "5", width: "20", height: "14", rx: "2" }),
1617
+ /* @__PURE__ */ jsx22("path", { d: "M6 15V9l3 4 3-4v6" }),
1618
+ /* @__PURE__ */ jsx22("path", { d: "M16.5 9v6" }),
1619
+ /* @__PURE__ */ jsx22("path", { d: "M14.5 13l2 2 2-2" })
1620
+ ] }),
1621
+ php: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1622
+ /* @__PURE__ */ jsx22("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1623
+ /* @__PURE__ */ jsx22("path", { d: "M11.5 8.5L7.5 12l4 3.5" }),
1624
+ /* @__PURE__ */ jsx22("path", { d: "M15.2 8.2c1.1 0 1.9.6 1.9 1.6 0 1.1-.9 1.5-1.8 1.8-.6.2-1 .5-1 1.1" }),
1625
+ /* @__PURE__ */ jsx22("circle", { cx: "14.3", cy: "16.2", r: ".5", fill: "currentColor", stroke: "none" })
1626
+ ] }),
1627
+ plaintext: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1628
+ /* @__PURE__ */ jsx22("rect", { x: "4", y: "2.5", width: "16", height: "19", rx: "2" }),
1629
+ /* @__PURE__ */ jsx22("line", { x1: "7.5", y1: "7.5", x2: "16.5", y2: "7.5" }),
1630
+ /* @__PURE__ */ jsx22("line", { x1: "7.5", y1: "11.5", x2: "16.5", y2: "11.5" }),
1631
+ /* @__PURE__ */ jsx22("line", { x1: "7.5", y1: "15.5", x2: "13.5", y2: "15.5" })
1632
+ ] }),
1633
+ python: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1634
+ /* @__PURE__ */ jsx22("path", { d: "M4.5 15c0-3 2.5-4.7 5.7-4.7h1.6c2.8 0 5-2 5-4.5" }),
1635
+ /* @__PURE__ */ jsx22("path", { d: "M9.5 3.3c1.3-.3 2.6 0 3.3 1-.7 1-2 1.3-3.3 1" }),
1636
+ /* @__PURE__ */ jsx22("circle", { cx: "15.5", cy: "4.3", r: ".55", fill: "currentColor", stroke: "none" }),
1637
+ /* @__PURE__ */ jsx22("path", { d: "M17.8 4.5l1.4-.6M17.8 4.9l1.4.6" })
1638
+ ] }),
1639
+ ruby: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1640
+ /* @__PURE__ */ jsx22("polygon", { points: "12 2.5 19.5 8 12 21.5 4.5 8" }),
1641
+ /* @__PURE__ */ jsx22("path", { d: "M4.5 8h15" }),
1642
+ /* @__PURE__ */ jsx22("path", { d: "M12 2.5v19" })
1643
+ ] }),
1644
+ rust: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1645
+ /* @__PURE__ */ jsx22("circle", { cx: "12", cy: "12", r: "7" }),
1646
+ /* @__PURE__ */ jsx22("circle", { cx: "12", cy: "12", r: "2.3" }),
1647
+ /* @__PURE__ */ jsx22("path", { d: "M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3" }),
1648
+ /* @__PURE__ */ jsx22("path", { d: "M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1" })
1649
+ ] }),
1650
+ sql: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1651
+ /* @__PURE__ */ jsx22("ellipse", { cx: "12", cy: "6", rx: "8", ry: "3" }),
1652
+ /* @__PURE__ */ jsx22("path", { d: "M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6" }),
1653
+ /* @__PURE__ */ jsx22("path", { d: "M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6" })
1654
+ ] }),
1655
+ swift: /* @__PURE__ */ jsx22(LangIcon, { children: /* @__PURE__ */ jsx22("path", { d: "M19 4.5c-2.6 4-5.5 7-8.3 9 2-.2 3.7-1 4.8-2.6-.7 2.8-2.8 5-5.3 6.1 3 .5 5.6-.5 7.2-2.4.4 2-.4 3.9-1.9 4.9 3.7-1.3 6-4.2 6.6-7.6-1 2.6-2.8 4.6-4.6 5.8" }) }),
1656
+ typescript: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1657
+ /* @__PURE__ */ jsx22("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1658
+ /* @__PURE__ */ jsx22("path", { d: "M7.3 8.2h5M9.8 8.2v7.6" }),
1659
+ /* @__PURE__ */ jsx22("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
1660
+ ] }),
1661
+ xml: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1662
+ /* @__PURE__ */ jsx22("path", { d: "M8 7l-4.5 5 4.5 5" }),
1663
+ /* @__PURE__ */ jsx22("path", { d: "M16 7l4.5 5-4.5 5" }),
1664
+ /* @__PURE__ */ jsx22("path", { d: "M12 8v8" })
1665
+ ] }),
1666
+ yaml: /* @__PURE__ */ jsxs9(LangIcon, { children: [
1667
+ /* @__PURE__ */ jsx22("rect", { x: "2.5", y: "3", width: "19", height: "18", rx: "2" }),
1668
+ /* @__PURE__ */ jsx22("path", { d: "M6.5 8h2M9.5 8h8" }),
1669
+ /* @__PURE__ */ jsx22("path", { d: "M6.5 12h2M9.5 12h6" }),
1670
+ /* @__PURE__ */ jsx22("path", { d: "M6.5 16h2M9.5 16h7" })
1671
+ ] })
1672
+ };
1673
+ var DEFAULT_ICONS = {
1674
+ alignCenterControlIcon: /* @__PURE__ */ jsx22(TextAlignCenter, { ...iconProps }),
1675
+ alignJustifyControlIcon: /* @__PURE__ */ jsx22(TextAlignJustify, { ...iconProps }),
1676
+ alignLeftControlIcon: /* @__PURE__ */ jsx22(TextAlignStart, { ...iconProps }),
1677
+ alignRightControlIcon: /* @__PURE__ */ jsx22(TextAlignEnd, { ...iconProps }),
1678
+ blockquoteControlIcon: /* @__PURE__ */ jsx22(TextQuote, { ...iconProps }),
1679
+ boldControlIcon: /* @__PURE__ */ jsx22(Bold, { ...iconProps }),
1680
+ bulletListControlIcon: /* @__PURE__ */ jsx22(List, { ...iconProps }),
1681
+ clearFormattingControlIcon: /* @__PURE__ */ jsx22(RemoveFormatting, { ...iconProps }),
1682
+ codeBlockControlIcon: /* @__PURE__ */ jsx22(SquareCode, { ...iconProps }),
1683
+ codeControlIcon: /* @__PURE__ */ jsx22(Code, { ...iconProps }),
1684
+ h1ControlIcon: /* @__PURE__ */ jsx22(Heading1, { ...iconProps }),
1685
+ h2ControlIcon: /* @__PURE__ */ jsx22(Heading2, { ...iconProps }),
1686
+ h3ControlIcon: /* @__PURE__ */ jsx22(Heading3, { ...iconProps }),
1687
+ h4ControlIcon: /* @__PURE__ */ jsx22(Heading4, { ...iconProps }),
1688
+ h5ControlIcon: /* @__PURE__ */ jsx22(Heading5, { ...iconProps }),
1689
+ h6ControlIcon: /* @__PURE__ */ jsx22(Heading6, { ...iconProps }),
1690
+ highlightControlIcon: /* @__PURE__ */ jsx22(Highlighter, { ...iconProps }),
1691
+ hrControlIcon: /* @__PURE__ */ jsx22(Minus, { ...iconProps }),
1692
+ italicControlIcon: /* @__PURE__ */ jsx22(Italic, { ...iconProps }),
1693
+ languageIcons: DEFAULT_LANGUAGE_ICONS,
1694
+ linkControlIcon: /* @__PURE__ */ jsx22(Link, { ...iconProps }),
1695
+ orderedListControlIcon: /* @__PURE__ */ jsx22(ListOrdered, { ...iconProps }),
1696
+ redoControlIcon: /* @__PURE__ */ jsx22(Redo2, { ...iconProps }),
1697
+ strikeControlIcon: /* @__PURE__ */ jsx22(Strikethrough, { ...iconProps }),
1698
+ subscriptControlIcon: /* @__PURE__ */ jsx22(Subscript, { ...iconProps }),
1699
+ superscriptControlIcon: /* @__PURE__ */ jsx22(Superscript, { ...iconProps }),
1700
+ underlineControlIcon: /* @__PURE__ */ jsx22(Underline, { ...iconProps }),
1701
+ undoControlIcon: /* @__PURE__ */ jsx22(Undo2, { ...iconProps }),
1702
+ unlinkControlIcon: /* @__PURE__ */ jsx22(Link2Off, { ...iconProps })
1703
+ };
1704
+
1705
+ // src/extensions/resizable-node-view.tsx
1706
+ import { Fragment as Fragment5, jsx as jsx23, jsxs as jsxs10 } from "react/jsx-runtime";
1707
+ var EmbedToolbar = ({
1708
+ align,
1709
+ videoSrc,
1710
+ watchUrl,
1711
+ deleteNode,
1712
+ inputRef,
1713
+ isEditingUrl,
1714
+ urlInput,
1715
+ setUrlInput,
1716
+ setIsEditingUrl,
1717
+ handleSaveUrl,
1718
+ handleApplyPreset,
1719
+ updateAttributes,
1720
+ nodeSrc
1721
+ }) => {
1722
+ if (isEditingUrl) {
1723
+ return /* @__PURE__ */ jsxs10("div", { className: "rte-embed-selector-edit-form", children: [
1724
+ /* @__PURE__ */ jsx23(
1725
+ "input",
1726
+ {
1727
+ ref: inputRef,
1728
+ type: "text",
1729
+ value: urlInput,
1730
+ onChange: (e) => setUrlInput(e.target.value),
1731
+ placeholder: "Paste YouTube URL or video ID...",
1732
+ className: "rte-embed-selector-input",
1733
+ onKeyDown: (e) => {
1734
+ if (e.key === "Enter") {
1735
+ handleSaveUrl();
1736
+ } else if (e.key === "Escape") {
1737
+ setIsEditingUrl(false);
1738
+ }
1739
+ }
1740
+ }
1741
+ ),
1742
+ /* @__PURE__ */ jsx23(
1743
+ "button",
1744
+ {
1745
+ type: "button",
1746
+ onClick: handleSaveUrl,
1747
+ className: "rte-embed-selector-btn rte-embed-selector-btn--save",
1748
+ children: "Save"
1749
+ }
1750
+ ),
1751
+ /* @__PURE__ */ jsx23(
1752
+ "button",
1753
+ {
1754
+ type: "button",
1755
+ onClick: () => setIsEditingUrl(false),
1756
+ className: "rte-embed-selector-btn",
1757
+ children: "Cancel"
1758
+ }
1759
+ )
1760
+ ] });
1761
+ }
1762
+ return /* @__PURE__ */ jsxs10(Fragment5, { children: [
1763
+ /* @__PURE__ */ jsx23("div", { className: "rte-embed-selector-group", children: ["left", "center", "right"].map((dir) => /* @__PURE__ */ jsx23(
1764
+ "button",
1765
+ {
1766
+ type: "button",
1767
+ title: `Align ${dir.charAt(0).toUpperCase()}${dir.slice(1)}`,
1768
+ "aria-label": `Align ${dir.charAt(0).toUpperCase()}${dir.slice(1)}`,
1769
+ className: `rte-embed-selector-btn ${align === dir ? "rte-embed-selector-btn--active" : ""}`,
1770
+ onClick: () => updateAttributes({ align: dir }),
1771
+ children: /* @__PURE__ */ jsx23(AlignIcon, { dir })
1772
+ },
1773
+ dir
1774
+ )) }),
1775
+ /* @__PURE__ */ jsx23("div", { className: "rte-embed-selector-divider" }),
1776
+ /* @__PURE__ */ jsx23("div", { className: "rte-embed-selector-group", children: [25, 50, 75, 100].map((pct) => /* @__PURE__ */ jsxs10(
1777
+ "button",
1778
+ {
1779
+ type: "button",
1780
+ title: `${pct}%`,
1781
+ className: "rte-embed-selector-btn rte-embed-selector-btn--preset",
1782
+ onClick: () => handleApplyPreset(pct),
1783
+ children: [
1784
+ pct,
1785
+ "%"
1786
+ ]
1787
+ },
1788
+ pct
1789
+ )) }),
1790
+ /* @__PURE__ */ jsx23("div", { className: "rte-embed-selector-divider" }),
1791
+ /* @__PURE__ */ jsxs10("div", { className: "rte-embed-selector-group", children: [
1792
+ (videoSrc || nodeSrc) && /* @__PURE__ */ jsx23(
1793
+ "button",
1794
+ {
1795
+ type: "button",
1796
+ title: "Edit URL",
1797
+ "aria-label": "Edit URL",
1798
+ className: "rte-embed-selector-btn",
1799
+ onClick: () => {
1800
+ setUrlInput(videoSrc || nodeSrc || "");
1801
+ setIsEditingUrl(true);
1802
+ },
1803
+ children: /* @__PURE__ */ jsx23(EditUrlIcon, {})
1804
+ }
1805
+ ),
1806
+ watchUrl && /* @__PURE__ */ jsx23(
1807
+ "button",
1808
+ {
1809
+ type: "button",
1810
+ title: "Open video in YouTube",
1811
+ "aria-label": "Open video in YouTube",
1812
+ className: "rte-embed-selector-btn",
1813
+ onClick: () => window.open(watchUrl, "_blank"),
1814
+ children: /* @__PURE__ */ jsx23(OpenInYouTubeIcon, {})
1815
+ }
1816
+ ),
1817
+ deleteNode && /* @__PURE__ */ jsx23(
1818
+ "button",
1819
+ {
1820
+ type: "button",
1821
+ title: "Delete Embed",
1822
+ "aria-label": "Delete Embed",
1823
+ className: "rte-embed-selector-btn rte-embed-selector-btn--danger",
1824
+ onClick: () => deleteNode(),
1825
+ children: /* @__PURE__ */ jsx23(DeleteEmbedIcon, {})
1826
+ }
1827
+ )
1828
+ ] })
1829
+ ] });
1830
+ };
908
1831
  var ResizableNodeView = ({
909
1832
  node,
910
1833
  selected,
911
1834
  updateAttributes,
1835
+ deleteNode,
1836
+ editor,
912
1837
  view,
913
1838
  children,
914
1839
  lockAspect = false,
915
1840
  aspectRatio = 16 / 9,
916
1841
  minWidth = 300,
917
- maxWidth = 1200
1842
+ maxWidth = 1200,
1843
+ videoSrc,
1844
+ watchUrl,
1845
+ onSrcChange
918
1846
  }) => {
919
- const containerRef = useRef2(null);
920
- const resizingRef = useRef2(null);
1847
+ const containerRef = useRef3(null);
1848
+ const [isEditingUrl, setIsEditingUrl] = useState5(false);
1849
+ const [urlInput, setUrlInput] = useState5(videoSrc || "");
1850
+ const [isResizing, setIsResizing] = useState5(false);
1851
+ const [currentDimensions, setCurrentDimensions] = useState5(null);
1852
+ const resizingRef = useRef3(null);
921
1853
  const width = node.attrs.width;
922
1854
  const height = node.attrs.height;
923
1855
  const align = node.attrs.align || "center";
924
1856
  const getEditorWidth = useCallback5(
925
- () => view?.dom?.parentElement?.offsetWidth ?? 0,
1857
+ () => view?.dom?.parentElement?.offsetWidth ?? 800,
926
1858
  [view]
927
1859
  );
1860
+ const inputRef = useRef3(null);
1861
+ useEffect3(() => {
1862
+ if (isEditingUrl) {
1863
+ inputRef.current?.focus();
1864
+ }
1865
+ }, [isEditingUrl]);
928
1866
  const handleMouseMove = useCallback5(
929
1867
  (e) => {
930
1868
  const resize = resizingRef.current;
@@ -934,7 +1872,7 @@ var ResizableNodeView = ({
934
1872
  const effectiveMax = Math.min(maxWidth, resize.editorWidth);
935
1873
  let newWidth = resize.startWidth;
936
1874
  let newHeight = resize.startHeight;
937
- if (resize.direction === "right" || resize.direction === "corner") {
1875
+ if (resize.direction === "right" || resize.direction === "corner-br") {
938
1876
  newWidth = Math.max(
939
1877
  minWidth,
940
1878
  Math.min(
@@ -942,8 +1880,16 @@ var ResizableNodeView = ({
942
1880
  resize.startWidth + (e.clientX - resize.startX)
943
1881
  )
944
1882
  );
1883
+ } else if (resize.direction === "left" || resize.direction === "corner-bl") {
1884
+ newWidth = Math.max(
1885
+ minWidth,
1886
+ Math.min(
1887
+ effectiveMax,
1888
+ resize.startWidth - (e.clientX - resize.startX)
1889
+ )
1890
+ );
945
1891
  }
946
- if (resize.direction === "bottom" || resize.direction === "corner") {
1892
+ if (resize.direction === "bottom" || resize.direction === "corner-br" || resize.direction === "corner-bl") {
947
1893
  newHeight = Math.max(
948
1894
  Math.round(minWidth / aspectRatio),
949
1895
  Math.min(
@@ -953,7 +1899,7 @@ var ResizableNodeView = ({
953
1899
  );
954
1900
  }
955
1901
  if (lockAspect) {
956
- if (resize.direction === "right" || resize.direction === "corner") {
1902
+ if (resize.direction === "left" || resize.direction === "right" || resize.direction === "corner-br" || resize.direction === "corner-bl") {
957
1903
  newHeight = Math.round(newWidth / aspectRatio);
958
1904
  } else {
959
1905
  newWidth = Math.round(newHeight * aspectRatio);
@@ -963,6 +1909,7 @@ var ResizableNodeView = ({
963
1909
  containerRef.current.style.width = `${newWidth}px`;
964
1910
  containerRef.current.style.height = `${newHeight}px`;
965
1911
  }
1912
+ setCurrentDimensions({ h: newHeight, w: newWidth });
966
1913
  },
967
1914
  [lockAspect, aspectRatio, minWidth, maxWidth]
968
1915
  );
@@ -982,6 +1929,8 @@ var ResizableNodeView = ({
982
1929
  updateAttributes({ height: h, width: w });
983
1930
  }
984
1931
  resizingRef.current = null;
1932
+ setIsResizing(false);
1933
+ setCurrentDimensions(null);
985
1934
  },
986
1935
  [handleMouseMove, updateAttributes]
987
1936
  );
@@ -1000,20 +1949,23 @@ var ResizableNodeView = ({
1000
1949
  startX: e.clientX,
1001
1950
  startY: e.clientY
1002
1951
  };
1952
+ setIsResizing(true);
1953
+ setCurrentDimensions({ h: startHeight, w: startWidth });
1003
1954
  document.addEventListener("mousemove", handleMouseMove);
1004
1955
  document.addEventListener("mouseup", handleMouseUp);
1005
- let cursor = "nwse-resize";
1006
- if (direction === "right") {
1007
- cursor = "ew-resize";
1008
- } else if (direction === "bottom") {
1009
- cursor = "ns-resize";
1010
- }
1011
- document.body.style.cursor = cursor;
1956
+ const cursors = {
1957
+ bottom: "ns-resize",
1958
+ "corner-bl": "nesw-resize",
1959
+ "corner-br": "nwse-resize",
1960
+ left: "ew-resize",
1961
+ right: "ew-resize"
1962
+ };
1963
+ document.body.style.cursor = cursors[direction];
1012
1964
  document.body.style.userSelect = "none";
1013
1965
  },
1014
1966
  [width, height, getEditorWidth, handleMouseMove, handleMouseUp]
1015
1967
  );
1016
- useEffect2(
1968
+ useEffect3(
1017
1969
  () => () => {
1018
1970
  document.removeEventListener("mousemove", handleMouseMove);
1019
1971
  document.removeEventListener("mouseup", handleMouseUp);
@@ -1022,13 +1974,32 @@ var ResizableNodeView = ({
1022
1974
  },
1023
1975
  [handleMouseMove, handleMouseUp]
1024
1976
  );
1025
- return /* @__PURE__ */ jsx10(
1977
+ const handleApplyPreset = (percent) => {
1978
+ const editorW = getEditorWidth() || 800;
1979
+ const targetW = Math.round(
1980
+ Math.max(minWidth, Math.min(maxWidth, editorW * percent / 100))
1981
+ );
1982
+ updateAttributes({
1983
+ height: Math.round(targetW / aspectRatio),
1984
+ width: targetW
1985
+ });
1986
+ };
1987
+ const handleSaveUrl = () => {
1988
+ if (urlInput && onSrcChange) {
1989
+ onSrcChange(urlInput);
1990
+ } else if (urlInput) {
1991
+ updateAttributes({ src: urlInput });
1992
+ }
1993
+ setIsEditingUrl(false);
1994
+ };
1995
+ const isEditable = editor ? editor.isEditable : true;
1996
+ return /* @__PURE__ */ jsx23(
1026
1997
  NodeViewWrapper,
1027
1998
  {
1028
1999
  className: "rte-embed-wrapper",
1029
2000
  "data-selected": selected || void 0,
1030
2001
  "data-align": align,
1031
- children: /* @__PURE__ */ jsxs4(
2002
+ children: /* @__PURE__ */ jsxs10(
1032
2003
  "div",
1033
2004
  {
1034
2005
  ref: containerRef,
@@ -1041,8 +2012,40 @@ var ResizableNodeView = ({
1041
2012
  },
1042
2013
  children: [
1043
2014
  children,
1044
- selected && /* @__PURE__ */ jsxs4(Fragment2, { children: [
1045
- /* @__PURE__ */ jsx10(
2015
+ selected && isEditable && /* @__PURE__ */ jsx23("div", { className: "rte-embed-selector", contentEditable: false, children: /* @__PURE__ */ jsx23(
2016
+ EmbedToolbar,
2017
+ {
2018
+ align,
2019
+ videoSrc,
2020
+ watchUrl,
2021
+ deleteNode,
2022
+ inputRef,
2023
+ isEditingUrl,
2024
+ urlInput,
2025
+ setUrlInput,
2026
+ setIsEditingUrl,
2027
+ handleSaveUrl,
2028
+ handleApplyPreset,
2029
+ updateAttributes,
2030
+ nodeSrc: node.attrs.src
2031
+ }
2032
+ ) }),
2033
+ isResizing && currentDimensions && /* @__PURE__ */ jsxs10("div", { className: "rte-embed-resize-badge", children: [
2034
+ currentDimensions.w,
2035
+ " \xD7 ",
2036
+ currentDimensions.h,
2037
+ " px"
2038
+ ] }),
2039
+ selected && isEditable && /* @__PURE__ */ jsxs10(Fragment5, { children: [
2040
+ /* @__PURE__ */ jsx23(
2041
+ "div",
2042
+ {
2043
+ className: "rte-resize-handle rte-resize-handle--left",
2044
+ onMouseDown: (e) => handleMouseDown(e, "left"),
2045
+ role: "presentation"
2046
+ }
2047
+ ),
2048
+ /* @__PURE__ */ jsx23(
1046
2049
  "div",
1047
2050
  {
1048
2051
  className: "rte-resize-handle rte-resize-handle--right",
@@ -1050,7 +2053,7 @@ var ResizableNodeView = ({
1050
2053
  role: "presentation"
1051
2054
  }
1052
2055
  ),
1053
- /* @__PURE__ */ jsx10(
2056
+ /* @__PURE__ */ jsx23(
1054
2057
  "div",
1055
2058
  {
1056
2059
  className: "rte-resize-handle rte-resize-handle--bottom",
@@ -1058,186 +2061,179 @@ var ResizableNodeView = ({
1058
2061
  role: "presentation"
1059
2062
  }
1060
2063
  ),
1061
- /* @__PURE__ */ jsx10(
2064
+ /* @__PURE__ */ jsx23(
1062
2065
  "div",
1063
- {
1064
- className: "rte-resize-handle rte-resize-handle--corner",
1065
- onMouseDown: (e) => handleMouseDown(e, "corner"),
1066
- role: "presentation"
1067
- }
1068
- )
1069
- ] })
1070
- ]
1071
- }
1072
- )
1073
- }
1074
- );
1075
- };
1076
-
1077
- // src/ui/dialog.tsx
1078
- import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
1079
- import "react";
1080
- import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
1081
- var Dialog = ({ ...props }) => /* @__PURE__ */ jsx11(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
1082
- var DialogTrigger = ({ ...props }) => /* @__PURE__ */ jsx11(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
1083
- var DialogPortal = ({ ...props }) => /* @__PURE__ */ jsx11(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
1084
- var DialogClose = ({ ...props }) => /* @__PURE__ */ jsx11(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
1085
- var DialogOverlay = ({
1086
- className,
1087
- ...props
1088
- }) => /* @__PURE__ */ jsx11(
1089
- DialogPrimitive.Backdrop,
1090
- {
1091
- "data-slot": "dialog-overlay",
1092
- className: cn(
1093
- "fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
1094
- className
1095
- ),
1096
- ...props
1097
- }
1098
- );
1099
- var DialogContent = ({
1100
- className,
1101
- children,
1102
- showCloseButton = true,
1103
- ...props
1104
- }) => /* @__PURE__ */ jsxs5(DialogPortal, { children: [
1105
- /* @__PURE__ */ jsx11(DialogOverlay, {}),
1106
- /* @__PURE__ */ jsxs5(
1107
- DialogPrimitive.Popup,
1108
- {
1109
- "data-slot": "dialog-content",
1110
- className: cn(
1111
- "fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-none bg-popover p-4 text-xs/relaxed text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
1112
- className
1113
- ),
1114
- ...props,
1115
- children: [
1116
- children,
1117
- showCloseButton && /* @__PURE__ */ jsxs5(
1118
- DialogPrimitive.Close,
1119
- {
1120
- "data-slot": "dialog-close",
1121
- render: /* @__PURE__ */ jsx11(
1122
- Button,
1123
- {
1124
- variant: "ghost",
1125
- className: "absolute top-2 right-2",
1126
- size: "icon-sm"
1127
- }
1128
- ),
1129
- children: [
1130
- "X",
1131
- /* @__PURE__ */ jsx11("span", { className: "sr-only", children: "Close" })
1132
- ]
1133
- }
1134
- )
1135
- ]
2066
+ {
2067
+ className: "rte-resize-handle rte-resize-handle--corner rte-resize-handle--corner-bl",
2068
+ onMouseDown: (e) => handleMouseDown(e, "corner-bl"),
2069
+ role: "presentation"
2070
+ }
2071
+ ),
2072
+ /* @__PURE__ */ jsx23(
2073
+ "div",
2074
+ {
2075
+ className: "rte-resize-handle rte-resize-handle--corner rte-resize-handle--corner-br",
2076
+ onMouseDown: (e) => handleMouseDown(e, "corner-br"),
2077
+ role: "presentation"
2078
+ }
2079
+ )
2080
+ ] })
2081
+ ]
2082
+ }
2083
+ )
1136
2084
  }
1137
- )
1138
- ] });
1139
- var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsx11(
1140
- "div",
1141
- {
1142
- "data-slot": "dialog-header",
1143
- className: cn("flex flex-col gap-1 text-left", className),
1144
- ...props
1145
- }
1146
- );
1147
- var DialogFooter = ({
1148
- className,
1149
- showCloseButton = false,
1150
- children,
1151
- ...props
1152
- }) => /* @__PURE__ */ jsxs5(
1153
- "div",
1154
- {
1155
- "data-slot": "dialog-footer",
1156
- className: cn(
1157
- "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
1158
- className
1159
- ),
1160
- ...props,
1161
- children: [
1162
- children,
1163
- showCloseButton && /* @__PURE__ */ jsx11(DialogPrimitive.Close, { render: /* @__PURE__ */ jsx11(Button, { variant: "outline" }), children: "Close" })
1164
- ]
1165
- }
1166
- );
1167
- var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ jsx11(
1168
- DialogPrimitive.Title,
1169
- {
1170
- "data-slot": "dialog-title",
1171
- className: cn("text-sm font-medium", className),
1172
- ...props
1173
- }
1174
- );
1175
- var DialogDescription = ({
1176
- className,
1177
- ...props
1178
- }) => /* @__PURE__ */ jsx11(
1179
- DialogPrimitive.Description,
1180
- {
1181
- "data-slot": "dialog-description",
1182
- className: cn(
1183
- "text-xs/relaxed text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
1184
- className
1185
- ),
1186
- ...props
1187
- }
1188
- );
2085
+ );
2086
+ };
1189
2087
 
1190
2088
  // src/controls/rte-twitter-control.tsx
1191
- import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
2089
+ import { jsx as jsx24, jsxs as jsxs11 } from "react/jsx-runtime";
1192
2090
  var WIDGET_SCRIPT_URL = "https://platform.twitter.com/widgets.js";
2091
+ var SCRIPT_LOAD_TIMEOUT_MS = 8e3;
2092
+ var READY_POLL_INTERVAL_MS = 50;
2093
+ var twitterScriptPromise = null;
2094
+ var loadTwitterScript = () => {
2095
+ if (typeof window === "undefined") {
2096
+ return Promise.resolve();
2097
+ }
2098
+ if (window.twttr?.widgets) {
2099
+ return Promise.resolve();
2100
+ }
2101
+ if (twitterScriptPromise) {
2102
+ return twitterScriptPromise;
2103
+ }
2104
+ twitterScriptPromise = new Promise((resolve, reject) => {
2105
+ let script = document.querySelector(
2106
+ `script[src="${WIDGET_SCRIPT_URL}"]`
2107
+ );
2108
+ const isNewScript = !script;
2109
+ if (!script) {
2110
+ script = document.createElement("script");
2111
+ script.src = WIDGET_SCRIPT_URL;
2112
+ script.async = true;
2113
+ document.body.append(script);
2114
+ }
2115
+ let settled = false;
2116
+ const timers = {};
2117
+ const cleanup = () => {
2118
+ clearInterval(timers.poll);
2119
+ clearTimeout(timers.timeout);
2120
+ };
2121
+ const succeed = () => {
2122
+ if (settled) {
2123
+ return;
2124
+ }
2125
+ settled = true;
2126
+ cleanup();
2127
+ resolve();
2128
+ };
2129
+ const fail = () => {
2130
+ if (settled) {
2131
+ return;
2132
+ }
2133
+ settled = true;
2134
+ cleanup();
2135
+ twitterScriptPromise = null;
2136
+ reject(new Error("Failed to load Twitter widgets script"));
2137
+ };
2138
+ if (window.twttr?.widgets) {
2139
+ succeed();
2140
+ return;
2141
+ }
2142
+ timers.poll = setInterval(() => {
2143
+ if (window.twttr?.widgets) {
2144
+ succeed();
2145
+ }
2146
+ }, READY_POLL_INTERVAL_MS);
2147
+ timers.timeout = setTimeout(fail, SCRIPT_LOAD_TIMEOUT_MS);
2148
+ if (isNewScript) {
2149
+ script.addEventListener(
2150
+ "load",
2151
+ () => {
2152
+ if (window.twttr?.widgets) {
2153
+ succeed();
2154
+ }
2155
+ },
2156
+ { once: true }
2157
+ );
2158
+ }
2159
+ script.addEventListener("error", fail, { once: true });
2160
+ });
2161
+ return twitterScriptPromise;
2162
+ };
1193
2163
  var TwitterNodeView = (props) => {
1194
2164
  const { node } = props;
1195
- const containerRef = useRef3(null);
1196
- const [loading, setLoading] = useState3(true);
2165
+ const containerRef = useRef4(null);
2166
+ const [loading, setLoading] = useState6(true);
2167
+ const [failed, setFailed] = useState6(false);
1197
2168
  const { tweetId } = node.attrs;
1198
- const w = node.attrs.width;
1199
- const h = node.attrs.height;
1200
- const renderTweet = useCallback6(async () => {
2169
+ const renderedTweetIdRef = useRef4(null);
2170
+ const activeRenderIdRef = useRef4(0);
2171
+ const retryToken = useRef4(0);
2172
+ const [retryCount, setRetryCount] = useState6(0);
2173
+ useEffect4(() => {
1201
2174
  if (!containerRef.current || !tweetId) {
1202
2175
  return;
1203
2176
  }
1204
- containerRef.current.innerHTML = "";
1205
- setLoading(true);
1206
- const { twttr } = window;
1207
- if (twttr?.widgets && containerRef.current) {
1208
- try {
1209
- await twttr.widgets.createTweet(tweetId, containerRef.current);
1210
- setLoading(false);
1211
- } catch {
1212
- }
1213
- }
1214
- }, [tweetId]);
1215
- useEffect3(() => {
1216
- if (!containerRef.current || !tweetId) {
2177
+ if (renderedTweetIdRef.current === tweetId && containerRef.current.children.length > 0 && !failed) {
2178
+ setLoading(false);
1217
2179
  return;
1218
2180
  }
1219
- const load = async () => {
1220
- if (window.twttr?.widgets && containerRef.current) {
2181
+ let isCancelled = false;
2182
+ activeRenderIdRef.current += 1;
2183
+ const renderId = activeRenderIdRef.current;
2184
+ setLoading(true);
2185
+ setFailed(false);
2186
+ const render = async () => {
2187
+ try {
2188
+ await loadTwitterScript();
2189
+ if (isCancelled || renderId !== activeRenderIdRef.current || !containerRef.current) {
2190
+ return;
2191
+ }
2192
+ const { twttr } = window;
2193
+ if (!twttr?.widgets) {
2194
+ throw new Error("Twitter widgets script unavailable");
2195
+ }
1221
2196
  containerRef.current.innerHTML = "";
1222
- setLoading(true);
1223
- try {
1224
- await window.twttr.widgets.createTweet(tweetId, containerRef.current);
2197
+ const el = await twttr.widgets.createTweet(
2198
+ tweetId,
2199
+ containerRef.current
2200
+ );
2201
+ if (isCancelled || renderId !== activeRenderIdRef.current || !containerRef.current) {
2202
+ if (el && typeof el.remove === "function") {
2203
+ el.remove();
2204
+ } else if (containerRef.current) {
2205
+ containerRef.current.innerHTML = "";
2206
+ }
2207
+ return;
2208
+ }
2209
+ if (!el) {
2210
+ throw new Error("Tweet could not be embedded");
2211
+ }
2212
+ while (containerRef.current.children.length > 1) {
2213
+ containerRef.current.firstElementChild?.remove();
2214
+ }
2215
+ renderedTweetIdRef.current = tweetId;
2216
+ } catch {
2217
+ if (!isCancelled && renderId === activeRenderIdRef.current) {
2218
+ setFailed(true);
2219
+ renderedTweetIdRef.current = null;
2220
+ }
2221
+ } finally {
2222
+ if (!isCancelled && renderId === activeRenderIdRef.current) {
1225
2223
  setLoading(false);
1226
- } catch {
1227
2224
  }
1228
- } else {
1229
- const script = document.createElement("script");
1230
- script.src = WIDGET_SCRIPT_URL;
1231
- script.async = true;
1232
- script.addEventListener("load", () => {
1233
- void renderTweet();
1234
- });
1235
- document.body.append(script);
1236
2225
  }
1237
2226
  };
1238
- void load();
1239
- }, [tweetId, w, h, renderTweet]);
1240
- return /* @__PURE__ */ jsxs6(
2227
+ void render();
2228
+ return () => {
2229
+ isCancelled = true;
2230
+ };
2231
+ }, [tweetId, retryCount, failed]);
2232
+ const handleRetry = useCallback6(() => {
2233
+ retryToken.current += 1;
2234
+ setRetryCount(retryToken.current);
2235
+ }, []);
2236
+ return /* @__PURE__ */ jsxs11(
1241
2237
  ResizableNodeView,
1242
2238
  {
1243
2239
  ...props,
@@ -1245,8 +2241,12 @@ var TwitterNodeView = (props) => {
1245
2241
  minWidth: 300,
1246
2242
  maxWidth: 1200,
1247
2243
  children: [
1248
- loading && /* @__PURE__ */ jsx12("div", { className: "rte-embed-loading", children: "Loading tweet..." }),
1249
- /* @__PURE__ */ jsx12("div", { ref: containerRef })
2244
+ loading && /* @__PURE__ */ jsx24("div", { className: "rte-embed-loading", children: "Loading tweet..." }),
2245
+ !loading && failed && /* @__PURE__ */ jsxs11("div", { className: "rte-embed-error", children: [
2246
+ /* @__PURE__ */ jsx24("p", { children: "Couldn't load this tweet." }),
2247
+ /* @__PURE__ */ jsx24("button", { type: "button", onClick: handleRetry, children: "Retry" })
2248
+ ] }),
2249
+ /* @__PURE__ */ jsx24("div", { ref: containerRef })
1250
2250
  ]
1251
2251
  }
1252
2252
  );
@@ -1336,88 +2336,119 @@ var extractTweetId = (input) => {
1336
2336
  };
1337
2337
  var TwitterEmbedControl = ({ className }) => {
1338
2338
  const { editor } = useRichTextEditorContext();
1339
- const [open, setOpen] = useState3(false);
1340
- const [url, setUrl] = useState3("");
2339
+ const [open, setOpen] = useState6(false);
2340
+ const [url, setUrl] = useState6("");
2341
+ const [touched, setTouched] = useState6(false);
1341
2342
  const { active } = useEditorState4({
1342
2343
  editor: editor ?? null,
1343
2344
  selector: (ctx) => ({
1344
2345
  active: ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("twitter") : false
1345
2346
  })
1346
2347
  }) ?? { active: false };
2348
+ const tweetId = url ? extractTweetId(url) : null;
2349
+ const showError = touched && url.length > 0 && !tweetId;
2350
+ const resetState = useCallback6(() => {
2351
+ setUrl("");
2352
+ setTouched(false);
2353
+ }, []);
1347
2354
  const handleInsert = useCallback6(() => {
1348
- if (url && editor) {
1349
- const tweetId = extractTweetId(url);
1350
- if (tweetId) {
1351
- editor.chain().focus().setTwitterEmbed(tweetId).run();
1352
- setUrl("");
1353
- }
2355
+ setTouched(true);
2356
+ if (!tweetId || !editor) {
2357
+ return false;
1354
2358
  }
1355
- }, [url, editor]);
1356
- return /* @__PURE__ */ jsxs6(Dialog, { open, onOpenChange: setOpen, children: [
1357
- /* @__PURE__ */ jsx12(
1358
- DialogTrigger,
1359
- {
1360
- render: /* @__PURE__ */ jsx12(
1361
- RichTextEditorControl,
2359
+ editor.chain().focus().setTwitterEmbed(tweetId).run();
2360
+ resetState();
2361
+ return true;
2362
+ }, [tweetId, editor, resetState]);
2363
+ return /* @__PURE__ */ jsxs11(
2364
+ Dialog,
2365
+ {
2366
+ open,
2367
+ onOpenChange: (next) => {
2368
+ setOpen(next);
2369
+ if (!next) {
2370
+ resetState();
2371
+ }
2372
+ },
2373
+ children: [
2374
+ /* @__PURE__ */ jsx24(
2375
+ DialogTrigger,
1362
2376
  {
1363
- active,
1364
- className,
1365
- title: "Embed Tweet",
1366
- "aria-label": "Embed Tweet",
1367
- children: /* @__PURE__ */ jsx12(
1368
- "svg",
2377
+ render: /* @__PURE__ */ jsx24(
2378
+ RichTextEditorControl,
1369
2379
  {
1370
- xmlns: "http://www.w3.org/2000/svg",
1371
- viewBox: "0 0 24 24",
1372
- fill: "currentColor",
1373
- className: "rte-editor-icon",
1374
- children: /* @__PURE__ */ jsx12("path", { d: "M18.2 3.2h3.3l-7.2 8.2 8.5 11.2h-6.6l-5.2-6.8-6 6.8H2.7l7.7-8.8L2.3 3.2h6.8l4.7 6.2 5.4-6.2zm-1.2 17.3h1.8L7 4.8H5.1l11.9 15.7z" })
2380
+ active,
2381
+ className,
2382
+ title: "Embed Tweet",
2383
+ "aria-label": "Embed Tweet",
2384
+ children: /* @__PURE__ */ jsx24(
2385
+ "svg",
2386
+ {
2387
+ xmlns: "http://www.w3.org/2000/svg",
2388
+ viewBox: "0 0 24 24",
2389
+ fill: "currentColor",
2390
+ className: "rte-editor-icon",
2391
+ children: /* @__PURE__ */ jsx24("path", { d: "M18.2 3.2h3.3l-7.2 8.2 8.5 11.2h-6.6l-5.2-6.8-6 6.8H2.7l7.7-8.8L2.3 3.2h6.8l4.7 6.2 5.4-6.2zm-1.2 17.3h1.8L7 4.8H5.1l11.9 15.7z" })
2392
+ }
2393
+ )
1375
2394
  }
1376
2395
  )
1377
2396
  }
1378
- )
1379
- }
1380
- ),
1381
- /* @__PURE__ */ jsxs6(DialogContent, { children: [
1382
- /* @__PURE__ */ jsxs6(DialogHeader, { children: [
1383
- /* @__PURE__ */ jsx12(DialogTitle, { children: "Embed Tweet" }),
1384
- /* @__PURE__ */ jsx12(DialogDescription, { children: "Paste a tweet URL or ID." })
1385
- ] }),
1386
- /* @__PURE__ */ jsx12(
1387
- Input,
1388
- {
1389
- value: url,
1390
- onChange: (e) => setUrl(e.target.value),
1391
- placeholder: "https://x.com/user/status/...",
1392
- onKeyDown: (e) => {
1393
- if (e.key === "Enter" && url) {
1394
- handleInsert();
1395
- setOpen(false);
2397
+ ),
2398
+ /* @__PURE__ */ jsxs11(DialogContent, { children: [
2399
+ /* @__PURE__ */ jsxs11(DialogHeader, { children: [
2400
+ /* @__PURE__ */ jsx24(DialogTitle, { children: "Embed Tweet" }),
2401
+ /* @__PURE__ */ jsx24(DialogDescription, { children: "Paste a tweet URL or ID." })
2402
+ ] }),
2403
+ /* @__PURE__ */ jsx24(
2404
+ Input,
2405
+ {
2406
+ value: url,
2407
+ onChange: (e) => {
2408
+ setUrl(e.target.value);
2409
+ if (touched) {
2410
+ setTouched(false);
2411
+ }
2412
+ },
2413
+ onBlur: () => setTouched(true),
2414
+ placeholder: "https://x.com/user/status/...",
2415
+ "aria-invalid": showError,
2416
+ onKeyDown: (e) => {
2417
+ if (e.key === "Enter" && url && handleInsert()) {
2418
+ setOpen(false);
2419
+ }
2420
+ }
1396
2421
  }
1397
- }
1398
- }
1399
- ),
1400
- /* @__PURE__ */ jsxs6(DialogFooter, { children: [
1401
- /* @__PURE__ */ jsx12(DialogClose, { children: "Cancel" }),
1402
- /* @__PURE__ */ jsx12(
1403
- DialogClose,
1404
- {
1405
- disabled: !url,
1406
- className: "rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50",
1407
- onClick: handleInsert,
1408
- children: "Insert"
1409
- }
1410
- )
1411
- ] })
1412
- ] })
1413
- ] });
2422
+ ),
2423
+ showError && /* @__PURE__ */ jsx24("p", { className: "rte-input-error", role: "alert", children: "That doesn't look like a valid tweet URL or ID." }),
2424
+ /* @__PURE__ */ jsxs11(DialogFooter, { children: [
2425
+ /* @__PURE__ */ jsx24(DialogClose, { children: "Cancel" }),
2426
+ /* @__PURE__ */ jsx24(
2427
+ "button",
2428
+ {
2429
+ type: "button",
2430
+ disabled: !url,
2431
+ className: "rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50",
2432
+ onClick: () => {
2433
+ if (handleInsert()) {
2434
+ setOpen(false);
2435
+ }
2436
+ },
2437
+ children: "Insert"
2438
+ }
2439
+ )
2440
+ ] })
2441
+ ] })
2442
+ ]
2443
+ }
2444
+ );
1414
2445
  };
1415
2446
 
1416
2447
  // src/controls/rte-youtube-control.tsx
1417
2448
  import { Node as Node2, nodeInputRule as nodeInputRule2 } from "@tiptap/core";
1418
2449
  import { ReactNodeViewRenderer as ReactNodeViewRenderer2, useEditorState as useEditorState5 } from "@tiptap/react";
1419
- import { useState as useState4, useCallback as useCallback7 } from "react";
1420
- import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
2450
+ import { useState as useState7, useCallback as useCallback7 } from "react";
2451
+ import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
1421
2452
  var getYouTubeId = (url) => {
1422
2453
  const clean = url.trim();
1423
2454
  const patterns = [
@@ -1438,9 +2469,14 @@ var getYouTubeId = (url) => {
1438
2469
  return /^[a-zA-Z0-9_-]{11}$/.test(clean) ? clean : null;
1439
2470
  };
1440
2471
  var YouTubeNodeView = (props) => {
1441
- const { node } = props;
1442
- const videoId = getYouTubeId(node.attrs.src) || node.attrs.src;
1443
- return /* @__PURE__ */ jsx13(
2472
+ const { node, updateAttributes } = props;
2473
+ const rawSrc = node.attrs.src || "";
2474
+ const videoId = getYouTubeId(rawSrc) || rawSrc;
2475
+ let watchUrl;
2476
+ if (videoId) {
2477
+ watchUrl = videoId.startsWith("http") ? videoId : `https://www.youtube.com/watch?v=${videoId}`;
2478
+ }
2479
+ return /* @__PURE__ */ jsx25(
1444
2480
  ResizableNodeView,
1445
2481
  {
1446
2482
  ...props,
@@ -1448,7 +2484,10 @@ var YouTubeNodeView = (props) => {
1448
2484
  aspectRatio: 16 / 9,
1449
2485
  minWidth: 320,
1450
2486
  maxWidth: 1200,
1451
- children: /* @__PURE__ */ jsx13(
2487
+ videoSrc: rawSrc,
2488
+ watchUrl,
2489
+ onSrcChange: (newSrc) => updateAttributes({ src: newSrc }),
2490
+ children: /* @__PURE__ */ jsx25(
1452
2491
  "iframe",
1453
2492
  {
1454
2493
  src: `https://www.youtube-nocookie.com/embed/${videoId}`,
@@ -1536,8 +2575,8 @@ var YouTubeEmbed = Node2.create({
1536
2575
  });
1537
2576
  var YouTubeEmbedControl = ({ className }) => {
1538
2577
  const { editor } = useRichTextEditorContext();
1539
- const [open, setOpen] = useState4(false);
1540
- const [url, setUrl] = useState4("");
2578
+ const [open, setOpen] = useState7(false);
2579
+ const [url, setUrl] = useState7("");
1541
2580
  const { active } = useEditorState5({
1542
2581
  editor: editor ?? null,
1543
2582
  selector: (ctx) => ({
@@ -1550,18 +2589,18 @@ var YouTubeEmbedControl = ({ className }) => {
1550
2589
  setUrl("");
1551
2590
  }
1552
2591
  }, [url, editor]);
1553
- return /* @__PURE__ */ jsxs7(Dialog, { open, onOpenChange: setOpen, children: [
1554
- /* @__PURE__ */ jsx13(
2592
+ return /* @__PURE__ */ jsxs12(Dialog, { open, onOpenChange: setOpen, children: [
2593
+ /* @__PURE__ */ jsx25(
1555
2594
  DialogTrigger,
1556
2595
  {
1557
- render: /* @__PURE__ */ jsx13(
2596
+ render: /* @__PURE__ */ jsx25(
1558
2597
  RichTextEditorControl,
1559
2598
  {
1560
2599
  active,
1561
2600
  className,
1562
2601
  title: "Embed YouTube video",
1563
2602
  "aria-label": "Embed YouTube video",
1564
- children: /* @__PURE__ */ jsxs7(
2603
+ children: /* @__PURE__ */ jsxs12(
1565
2604
  "svg",
1566
2605
  {
1567
2606
  xmlns: "http://www.w3.org/2000/svg",
@@ -1573,8 +2612,8 @@ var YouTubeEmbedControl = ({ className }) => {
1573
2612
  strokeLinejoin: "round",
1574
2613
  className: "rte-editor-icon",
1575
2614
  children: [
1576
- /* @__PURE__ */ jsx13("path", { d: "M23.5 6.2a3 3 0 0 0-2.1-2.1C19.5 3.5 12 3.5 12 3.5s-7.5 0-9.4.6a3 3 0 0 0-2.1 2.1C0 8.1 0 12 0 12s0 3.9.5 5.8a3 3 0 0 0 2.1 2.1c1.9.6 9.4.6 9.4.6s7.5 0 9.4-.6a3 3 0 0 0 2.1-2.1c.5-1.9.5-5.8.5-5.8s0-3.9-.5-5.8z" }),
1577
- /* @__PURE__ */ jsx13("path", { d: "M9.5 15.5V8.5l6.2 3.5z" })
2615
+ /* @__PURE__ */ jsx25("path", { d: "M23.5 6.2a3 3 0 0 0-2.1-2.1C19.5 3.5 12 3.5 12 3.5s-7.5 0-9.4.6a3 3 0 0 0-2.1 2.1C0 8.1 0 12 0 12s0 3.9.5 5.8a3 3 0 0 0 2.1 2.1c1.9.6 9.4.6 9.4.6s7.5 0 9.4-.6a3 3 0 0 0 2.1-2.1c.5-1.9.5-5.8.5-5.8s0-3.9-.5-5.8z" }),
2616
+ /* @__PURE__ */ jsx25("path", { d: "M9.5 15.5V8.5l6.2 3.5z" })
1578
2617
  ]
1579
2618
  }
1580
2619
  )
@@ -1582,12 +2621,12 @@ var YouTubeEmbedControl = ({ className }) => {
1582
2621
  )
1583
2622
  }
1584
2623
  ),
1585
- /* @__PURE__ */ jsxs7(DialogContent, { showCloseButton: false, children: [
1586
- /* @__PURE__ */ jsxs7(DialogHeader, { children: [
1587
- /* @__PURE__ */ jsx13(DialogTitle, { children: "Embed YouTube video" }),
1588
- /* @__PURE__ */ jsx13(DialogDescription, { children: "Paste a YouTube video URL or ID." })
2624
+ /* @__PURE__ */ jsxs12(DialogContent, { showCloseButton: false, children: [
2625
+ /* @__PURE__ */ jsxs12(DialogHeader, { children: [
2626
+ /* @__PURE__ */ jsx25(DialogTitle, { children: "Embed YouTube video" }),
2627
+ /* @__PURE__ */ jsx25(DialogDescription, { children: "Paste a YouTube video URL or ID." })
1589
2628
  ] }),
1590
- /* @__PURE__ */ jsx13(
2629
+ /* @__PURE__ */ jsx25(
1591
2630
  Input,
1592
2631
  {
1593
2632
  value: url,
@@ -1601,9 +2640,9 @@ var YouTubeEmbedControl = ({ className }) => {
1601
2640
  }
1602
2641
  }
1603
2642
  ),
1604
- /* @__PURE__ */ jsxs7(DialogFooter, { children: [
1605
- /* @__PURE__ */ jsx13(DialogClose, { children: "Cancel" }),
1606
- /* @__PURE__ */ jsx13(
2643
+ /* @__PURE__ */ jsxs12(DialogFooter, { children: [
2644
+ /* @__PURE__ */ jsx25(DialogClose, { children: "Cancel" }),
2645
+ /* @__PURE__ */ jsx25(
1607
2646
  DialogClose,
1608
2647
  {
1609
2648
  disabled: !url,
@@ -1617,203 +2656,6 @@ var YouTubeEmbedControl = ({ className }) => {
1617
2656
  ] });
1618
2657
  };
1619
2658
 
1620
- // src/icons.tsx
1621
- import {
1622
- Bold,
1623
- Code,
1624
- Heading1,
1625
- Heading2,
1626
- Heading3,
1627
- Heading4,
1628
- Heading5,
1629
- Heading6,
1630
- Highlighter,
1631
- Italic,
1632
- Link,
1633
- Link2Off,
1634
- List,
1635
- ListOrdered,
1636
- Minus,
1637
- Redo2,
1638
- RemoveFormatting,
1639
- SquareCode,
1640
- Strikethrough,
1641
- Subscript,
1642
- Superscript,
1643
- TextAlignCenter,
1644
- TextAlignEnd,
1645
- TextAlignJustify,
1646
- TextAlignStart,
1647
- TextQuote,
1648
- Underline,
1649
- Undo2
1650
- } from "lucide-react";
1651
- import "react";
1652
- import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
1653
- var iconProps = { className: "rte-editor-icon" };
1654
- var LangIcon = ({
1655
- children,
1656
- className
1657
- }) => /* @__PURE__ */ jsx14(
1658
- "svg",
1659
- {
1660
- xmlns: "http://www.w3.org/2000/svg",
1661
- viewBox: "0 0 24 24",
1662
- fill: "none",
1663
- stroke: "currentColor",
1664
- strokeWidth: 1.5,
1665
- strokeLinecap: "round",
1666
- strokeLinejoin: "round",
1667
- className,
1668
- children
1669
- }
1670
- );
1671
- var DEFAULT_LANGUAGE_ICONS = {
1672
- bash: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1673
- /* @__PURE__ */ jsx14("rect", { x: "2.5", y: "4", width: "19", height: "16", rx: "2" }),
1674
- /* @__PURE__ */ jsx14("path", { d: "M6.5 9.5l3.5 3-3.5 3" }),
1675
- /* @__PURE__ */ jsx14("path", { d: "M12 15.5h5.5" })
1676
- ] }),
1677
- c: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1678
- /* @__PURE__ */ jsx14("circle", { cx: "12", cy: "12", r: "8.5" }),
1679
- /* @__PURE__ */ jsx14("path", { d: "M15.6 9.3a4.5 4.5 0 1 0 0 5.4" })
1680
- ] }),
1681
- cpp: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1682
- /* @__PURE__ */ jsx14("circle", { cx: "9.5", cy: "12", r: "6.5" }),
1683
- /* @__PURE__ */ jsx14("path", { d: "M12.3 9.7a3.3 3.3 0 1 0 0 4.6" }),
1684
- /* @__PURE__ */ jsx14("path", { d: "M15.7 10.5v3M14.2 12h3" }),
1685
- /* @__PURE__ */ jsx14("path", { d: "M19.3 10.5v3M17.8 12h3" })
1686
- ] }),
1687
- css: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1688
- /* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1689
- /* @__PURE__ */ jsx14("path", { d: "M9.7 7.5l-1 9" }),
1690
- /* @__PURE__ */ jsx14("path", { d: "M15.3 7.5l-1 9" }),
1691
- /* @__PURE__ */ jsx14("path", { d: "M7 10.3h11" }),
1692
- /* @__PURE__ */ jsx14("path", { d: "M6.5 14.3h11" })
1693
- ] }),
1694
- go: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1695
- /* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1696
- /* @__PURE__ */ jsx14("path", { d: "M12.6 9.7A3.3 3.3 0 1 0 12.6 14.3" }),
1697
- /* @__PURE__ */ jsx14("path", { d: "M12.6 12h-1.9" }),
1698
- /* @__PURE__ */ jsx14("circle", { cx: "17", cy: "12", r: "2.9" })
1699
- ] }),
1700
- html: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1701
- /* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1702
- /* @__PURE__ */ jsx14("path", { d: "M9.5 8.5L6.5 12l3 3.5" }),
1703
- /* @__PURE__ */ jsx14("path", { d: "M14.5 8.5L17.5 12l-3 3.5" }),
1704
- /* @__PURE__ */ jsx14("path", { d: "M13 7.3l-2 9.4" })
1705
- ] }),
1706
- java: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1707
- /* @__PURE__ */ jsx14("path", { d: "M6 10h10v5a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3v-5z" }),
1708
- /* @__PURE__ */ jsx14("path", { d: "M16 12h1.3a1.8 1.8 0 0 1 0 3.6H16" }),
1709
- /* @__PURE__ */ jsx14("path", { d: "M9.3 3.8c-.9.8-.9 1.6 0 2.4M13.3 3.8c-.9.8-.9 1.6 0 2.4" }),
1710
- /* @__PURE__ */ jsx14("path", { d: "M6 19.3h10" })
1711
- ] }),
1712
- javascript: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1713
- /* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1714
- /* @__PURE__ */ jsx14("path", { d: "M10.5 8v6.5a2 2 0 0 1-3.5 1.3" }),
1715
- /* @__PURE__ */ jsx14("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
1716
- ] }),
1717
- json: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1718
- /* @__PURE__ */ jsx14("path", { d: "M8 3H7a2 2 0 0 0-2 2v4a2 2 0 0 1-2 2 2 2 0 0 1 2 2v4a2 2 0 0 0 2 2" }),
1719
- /* @__PURE__ */ jsx14("path", { d: "M16 3h1a2 2 0 0 1 2 2v4a2 2 0 0 0 2 2 2 2 0 0 0-2 2v4a2 2 0 0 1-2 2" })
1720
- ] }),
1721
- kotlin: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1722
- /* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1723
- /* @__PURE__ */ jsx14("path", { d: "M9 7.5v9" }),
1724
- /* @__PURE__ */ jsx14("path", { d: "M9 12l6-4.5" }),
1725
- /* @__PURE__ */ jsx14("path", { d: "M9 12l6 4.5" })
1726
- ] }),
1727
- markdown: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1728
- /* @__PURE__ */ jsx14("rect", { x: "2", y: "5", width: "20", height: "14", rx: "2" }),
1729
- /* @__PURE__ */ jsx14("path", { d: "M6 15V9l3 4 3-4v6" }),
1730
- /* @__PURE__ */ jsx14("path", { d: "M16.5 9v6" }),
1731
- /* @__PURE__ */ jsx14("path", { d: "M14.5 13l2 2 2-2" })
1732
- ] }),
1733
- php: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1734
- /* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1735
- /* @__PURE__ */ jsx14("path", { d: "M11.5 8.5L7.5 12l4 3.5" }),
1736
- /* @__PURE__ */ jsx14("path", { d: "M15.2 8.2c1.1 0 1.9.6 1.9 1.6 0 1.1-.9 1.5-1.8 1.8-.6.2-1 .5-1 1.1" }),
1737
- /* @__PURE__ */ jsx14("circle", { cx: "14.3", cy: "16.2", r: ".5", fill: "currentColor", stroke: "none" })
1738
- ] }),
1739
- plaintext: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1740
- /* @__PURE__ */ jsx14("rect", { x: "4", y: "2.5", width: "16", height: "19", rx: "2" }),
1741
- /* @__PURE__ */ jsx14("line", { x1: "7.5", y1: "7.5", x2: "16.5", y2: "7.5" }),
1742
- /* @__PURE__ */ jsx14("line", { x1: "7.5", y1: "11.5", x2: "16.5", y2: "11.5" }),
1743
- /* @__PURE__ */ jsx14("line", { x1: "7.5", y1: "15.5", x2: "13.5", y2: "15.5" })
1744
- ] }),
1745
- python: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1746
- /* @__PURE__ */ jsx14("path", { d: "M4.5 15c0-3 2.5-4.7 5.7-4.7h1.6c2.8 0 5-2 5-4.5" }),
1747
- /* @__PURE__ */ jsx14("path", { d: "M9.5 3.3c1.3-.3 2.6 0 3.3 1-.7 1-2 1.3-3.3 1" }),
1748
- /* @__PURE__ */ jsx14("circle", { cx: "15.5", cy: "4.3", r: ".55", fill: "currentColor", stroke: "none" }),
1749
- /* @__PURE__ */ jsx14("path", { d: "M17.8 4.5l1.4-.6M17.8 4.9l1.4.6" })
1750
- ] }),
1751
- ruby: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1752
- /* @__PURE__ */ jsx14("polygon", { points: "12 2.5 19.5 8 12 21.5 4.5 8" }),
1753
- /* @__PURE__ */ jsx14("path", { d: "M4.5 8h15" }),
1754
- /* @__PURE__ */ jsx14("path", { d: "M12 2.5v19" })
1755
- ] }),
1756
- rust: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1757
- /* @__PURE__ */ jsx14("circle", { cx: "12", cy: "12", r: "7" }),
1758
- /* @__PURE__ */ jsx14("circle", { cx: "12", cy: "12", r: "2.3" }),
1759
- /* @__PURE__ */ jsx14("path", { d: "M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3" }),
1760
- /* @__PURE__ */ jsx14("path", { d: "M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1" })
1761
- ] }),
1762
- sql: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1763
- /* @__PURE__ */ jsx14("ellipse", { cx: "12", cy: "6", rx: "8", ry: "3" }),
1764
- /* @__PURE__ */ jsx14("path", { d: "M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6" }),
1765
- /* @__PURE__ */ jsx14("path", { d: "M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6" })
1766
- ] }),
1767
- swift: /* @__PURE__ */ jsx14(LangIcon, { children: /* @__PURE__ */ jsx14("path", { d: "M19 4.5c-2.6 4-5.5 7-8.3 9 2-.2 3.7-1 4.8-2.6-.7 2.8-2.8 5-5.3 6.1 3 .5 5.6-.5 7.2-2.4.4 2-.4 3.9-1.9 4.9 3.7-1.3 6-4.2 6.6-7.6-1 2.6-2.8 4.6-4.6 5.8" }) }),
1768
- typescript: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1769
- /* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1770
- /* @__PURE__ */ jsx14("path", { d: "M7.3 8.2h5M9.8 8.2v7.6" }),
1771
- /* @__PURE__ */ jsx14("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
1772
- ] }),
1773
- xml: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1774
- /* @__PURE__ */ jsx14("path", { d: "M8 7l-4.5 5 4.5 5" }),
1775
- /* @__PURE__ */ jsx14("path", { d: "M16 7l4.5 5-4.5 5" }),
1776
- /* @__PURE__ */ jsx14("path", { d: "M12 8v8" })
1777
- ] }),
1778
- yaml: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1779
- /* @__PURE__ */ jsx14("rect", { x: "2.5", y: "3", width: "19", height: "18", rx: "2" }),
1780
- /* @__PURE__ */ jsx14("path", { d: "M6.5 8h2M9.5 8h8" }),
1781
- /* @__PURE__ */ jsx14("path", { d: "M6.5 12h2M9.5 12h6" }),
1782
- /* @__PURE__ */ jsx14("path", { d: "M6.5 16h2M9.5 16h7" })
1783
- ] })
1784
- };
1785
- var DEFAULT_ICONS = {
1786
- alignCenterControlIcon: /* @__PURE__ */ jsx14(TextAlignCenter, { ...iconProps }),
1787
- alignJustifyControlIcon: /* @__PURE__ */ jsx14(TextAlignJustify, { ...iconProps }),
1788
- alignLeftControlIcon: /* @__PURE__ */ jsx14(TextAlignStart, { ...iconProps }),
1789
- alignRightControlIcon: /* @__PURE__ */ jsx14(TextAlignEnd, { ...iconProps }),
1790
- blockquoteControlIcon: /* @__PURE__ */ jsx14(TextQuote, { ...iconProps }),
1791
- boldControlIcon: /* @__PURE__ */ jsx14(Bold, { ...iconProps }),
1792
- bulletListControlIcon: /* @__PURE__ */ jsx14(List, { ...iconProps }),
1793
- clearFormattingControlIcon: /* @__PURE__ */ jsx14(RemoveFormatting, { ...iconProps }),
1794
- codeBlockControlIcon: /* @__PURE__ */ jsx14(SquareCode, { ...iconProps }),
1795
- codeControlIcon: /* @__PURE__ */ jsx14(Code, { ...iconProps }),
1796
- h1ControlIcon: /* @__PURE__ */ jsx14(Heading1, { ...iconProps }),
1797
- h2ControlIcon: /* @__PURE__ */ jsx14(Heading2, { ...iconProps }),
1798
- h3ControlIcon: /* @__PURE__ */ jsx14(Heading3, { ...iconProps }),
1799
- h4ControlIcon: /* @__PURE__ */ jsx14(Heading4, { ...iconProps }),
1800
- h5ControlIcon: /* @__PURE__ */ jsx14(Heading5, { ...iconProps }),
1801
- h6ControlIcon: /* @__PURE__ */ jsx14(Heading6, { ...iconProps }),
1802
- highlightControlIcon: /* @__PURE__ */ jsx14(Highlighter, { ...iconProps }),
1803
- hrControlIcon: /* @__PURE__ */ jsx14(Minus, { ...iconProps }),
1804
- italicControlIcon: /* @__PURE__ */ jsx14(Italic, { ...iconProps }),
1805
- languageIcons: DEFAULT_LANGUAGE_ICONS,
1806
- linkControlIcon: /* @__PURE__ */ jsx14(Link, { ...iconProps }),
1807
- orderedListControlIcon: /* @__PURE__ */ jsx14(ListOrdered, { ...iconProps }),
1808
- redoControlIcon: /* @__PURE__ */ jsx14(Redo2, { ...iconProps }),
1809
- strikeControlIcon: /* @__PURE__ */ jsx14(Strikethrough, { ...iconProps }),
1810
- subscriptControlIcon: /* @__PURE__ */ jsx14(Subscript, { ...iconProps }),
1811
- superscriptControlIcon: /* @__PURE__ */ jsx14(Superscript, { ...iconProps }),
1812
- underlineControlIcon: /* @__PURE__ */ jsx14(Underline, { ...iconProps }),
1813
- undoControlIcon: /* @__PURE__ */ jsx14(Undo2, { ...iconProps }),
1814
- unlinkControlIcon: /* @__PURE__ */ jsx14(Link2Off, { ...iconProps })
1815
- };
1816
-
1817
2659
  // src/labels.ts
1818
2660
  var DEFAULT_LABELS = {
1819
2661
  alignCenterControlLabel: "Align center",
@@ -1857,14 +2699,14 @@ var DEFAULT_LABELS = {
1857
2699
 
1858
2700
  // src/rte-content.tsx
1859
2701
  import { EditorContent } from "@tiptap/react";
1860
- import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
2702
+ import { jsx as jsx26, jsxs as jsxs13 } from "react/jsx-runtime";
1861
2703
  var Content = ({
1862
2704
  children,
1863
2705
  className
1864
2706
  }) => {
1865
2707
  const { editor } = useRichTextEditorContext();
1866
- return /* @__PURE__ */ jsxs9("div", { className: "relative", children: [
1867
- /* @__PURE__ */ jsx15(
2708
+ return /* @__PURE__ */ jsxs13("div", { className: "relative", children: [
2709
+ /* @__PURE__ */ jsx26(
1868
2710
  EditorContent,
1869
2711
  {
1870
2712
  editor,
@@ -1876,15 +2718,15 @@ var Content = ({
1876
2718
  };
1877
2719
 
1878
2720
  // src/rte-controls-group.tsx
1879
- import { jsx as jsx16 } from "react/jsx-runtime";
2721
+ import { jsx as jsx27 } from "react/jsx-runtime";
1880
2722
  var ControlsGroup = ({
1881
2723
  children,
1882
2724
  className
1883
- }) => /* @__PURE__ */ jsx16("div", { className: cn("rte-controls-group", className), children });
2725
+ }) => /* @__PURE__ */ jsx27("div", { className: cn("rte-controls-group", className), children });
1884
2726
 
1885
2727
  // src/rte-footer.tsx
1886
- import { useEffect as useEffect4, useMemo, useRef as useRef4, useState as useState5 } from "react";
1887
- import { Fragment as Fragment3, jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
2728
+ import { useEffect as useEffect5, useMemo, useRef as useRef5, useState as useState8 } from "react";
2729
+ import { Fragment as Fragment6, jsx as jsx28, jsxs as jsxs14 } from "react/jsx-runtime";
1888
2730
  var Footer = ({
1889
2731
  children,
1890
2732
  className,
@@ -1895,9 +2737,9 @@ var Footer = ({
1895
2737
  wordCountFormatter
1896
2738
  }) => {
1897
2739
  const { editor, variant } = useRichTextEditorContext();
1898
- const [, forceUpdate] = useState5(0);
1899
- const rafRef = useRef4(null);
1900
- useEffect4(() => {
2740
+ const [, forceUpdate] = useState8(0);
2741
+ const rafRef = useRef5(null);
2742
+ useEffect5(() => {
1901
2743
  if (!editor || !showWordCount) {
1902
2744
  return;
1903
2745
  }
@@ -1943,7 +2785,7 @@ var Footer = ({
1943
2785
  if (!showWordCount && !children) {
1944
2786
  return null;
1945
2787
  }
1946
- return /* @__PURE__ */ jsxs10(
2788
+ return /* @__PURE__ */ jsxs14(
1947
2789
  "div",
1948
2790
  {
1949
2791
  className: cn(
@@ -1955,21 +2797,21 @@ var Footer = ({
1955
2797
  "data-sticky": sticky ? "" : void 0,
1956
2798
  style: sticky ? { bottom: stickyOffset } : void 0,
1957
2799
  children: [
1958
- showWordCount && wordCount && /* @__PURE__ */ jsx17("span", { className: cn("rte-footer-word-count", wordCountClassName), children: wordCountFormatter ? wordCountFormatter(wordCount) : /* @__PURE__ */ jsxs10(Fragment3, { children: [
1959
- /* @__PURE__ */ jsxs10("span", { className: "rte-footer-word-count-stat", children: [
1960
- /* @__PURE__ */ jsx17("span", { className: "rte-footer-word-count-number", children: wordCount.words }),
1961
- /* @__PURE__ */ jsx17("span", { className: "rte-footer-word-count-unit", children: "words" })
2800
+ showWordCount && wordCount && /* @__PURE__ */ jsx28("span", { className: cn("rte-footer-word-count", wordCountClassName), children: wordCountFormatter ? wordCountFormatter(wordCount) : /* @__PURE__ */ jsxs14(Fragment6, { children: [
2801
+ /* @__PURE__ */ jsxs14("span", { className: "rte-footer-word-count-stat", children: [
2802
+ /* @__PURE__ */ jsx28("span", { className: "rte-footer-word-count-number", children: wordCount.words }),
2803
+ /* @__PURE__ */ jsx28("span", { className: "rte-footer-word-count-unit", children: "words" })
1962
2804
  ] }),
1963
- /* @__PURE__ */ jsx17(
2805
+ /* @__PURE__ */ jsx28(
1964
2806
  "span",
1965
2807
  {
1966
2808
  className: "rte-footer-word-count-separator",
1967
2809
  "aria-hidden": "true"
1968
2810
  }
1969
2811
  ),
1970
- /* @__PURE__ */ jsxs10("span", { className: "rte-footer-word-count-stat", children: [
1971
- /* @__PURE__ */ jsx17("span", { className: "rte-footer-word-count-number", children: wordCount.characters }),
1972
- /* @__PURE__ */ jsx17("span", { className: "rte-footer-word-count-unit", children: "characters" })
2812
+ /* @__PURE__ */ jsxs14("span", { className: "rte-footer-word-count-stat", children: [
2813
+ /* @__PURE__ */ jsx28("span", { className: "rte-footer-word-count-number", children: wordCount.characters }),
2814
+ /* @__PURE__ */ jsx28("span", { className: "rte-footer-word-count-unit", children: "characters" })
1973
2815
  ] })
1974
2816
  ] }) }),
1975
2817
  children
@@ -1979,7 +2821,7 @@ var Footer = ({
1979
2821
  };
1980
2822
 
1981
2823
  // src/rte-toolbar.tsx
1982
- import { jsx as jsx18 } from "react/jsx-runtime";
2824
+ import { jsx as jsx29 } from "react/jsx-runtime";
1983
2825
  var Toolbar = ({
1984
2826
  children,
1985
2827
  className,
@@ -1990,7 +2832,7 @@ var Toolbar = ({
1990
2832
  if (!editable) {
1991
2833
  return null;
1992
2834
  }
1993
- return /* @__PURE__ */ jsx18(
2835
+ return /* @__PURE__ */ jsx29(
1994
2836
  "div",
1995
2837
  {
1996
2838
  className: cn(
@@ -2007,7 +2849,7 @@ var Toolbar = ({
2007
2849
  };
2008
2850
 
2009
2851
  // src/rte-text-editor.tsx
2010
- import { jsx as jsx19 } from "react/jsx-runtime";
2852
+ import { jsx as jsx30 } from "react/jsx-runtime";
2011
2853
  var RichTextEditorRoot = ({
2012
2854
  editor,
2013
2855
  children,
@@ -2022,12 +2864,12 @@ var RichTextEditorRoot = ({
2022
2864
  [labels]
2023
2865
  );
2024
2866
  const mergedIcons = useMemo2(() => ({ ...DEFAULT_ICONS, ...icons }), [icons]);
2025
- useEffect5(() => {
2867
+ useEffect6(() => {
2026
2868
  if (editor && editor.isEditable !== editable) {
2027
2869
  editor.setEditable(editable);
2028
2870
  }
2029
2871
  }, [editor, editable]);
2030
- return /* @__PURE__ */ jsx19(
2872
+ return /* @__PURE__ */ jsx30(
2031
2873
  RichTextEditorContext.Provider,
2032
2874
  {
2033
2875
  value: {
@@ -2037,7 +2879,7 @@ var RichTextEditorRoot = ({
2037
2879
  labels: mergedLabels,
2038
2880
  variant
2039
2881
  },
2040
- children: /* @__PURE__ */ jsx19(
2882
+ children: /* @__PURE__ */ jsx30(
2041
2883
  "div",
2042
2884
  {
2043
2885
  className: cn(