@editorcn/editor 0.1.0 → 0.1.2

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,5 +1,5 @@
1
1
  // src/rte-text-editor.tsx
2
- import { useMemo, useEffect as useEffect4 } from "react";
2
+ import { useMemo as useMemo2, useEffect as useEffect5 } from "react";
3
3
 
4
4
  // src/ui/utils.ts
5
5
  import { clsx } from "clsx";
@@ -262,13 +262,80 @@ function Toolbar({
262
262
  );
263
263
  }
264
264
 
265
+ // src/rte-footer.tsx
266
+ import { useEffect, useMemo, useRef, useState } from "react";
267
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
268
+ function Footer({
269
+ children,
270
+ className,
271
+ sticky = false,
272
+ stickyOffset = 0,
273
+ showWordCount = false,
274
+ wordCountClassName,
275
+ wordCountFormatter
276
+ }) {
277
+ const { editor, variant } = useRichTextEditorContext();
278
+ const [, forceUpdate] = useState(0);
279
+ const rafRef = useRef(null);
280
+ useEffect(() => {
281
+ if (!editor || !showWordCount) return;
282
+ const scheduleUpdate = () => {
283
+ if (rafRef.current != null) return;
284
+ rafRef.current = requestAnimationFrame(() => {
285
+ rafRef.current = null;
286
+ forceUpdate((t) => t + 1);
287
+ });
288
+ };
289
+ const handleTransaction = ({
290
+ transaction
291
+ }) => {
292
+ if (transaction.docChanged) scheduleUpdate();
293
+ };
294
+ editor.on("transaction", handleTransaction);
295
+ scheduleUpdate();
296
+ return () => {
297
+ editor.off("transaction", handleTransaction);
298
+ if (rafRef.current != null) cancelAnimationFrame(rafRef.current);
299
+ };
300
+ }, [editor, showWordCount]);
301
+ const wordCount = useMemo(() => {
302
+ if (!editor || !showWordCount) return null;
303
+ const words = editor.storage.characterCount?.words() ?? 0;
304
+ const characters = editor.storage.characterCount?.characters() ?? 0;
305
+ return wordCountFormatter ? wordCountFormatter({ words, characters }) : `${words} words | ${characters} characters`;
306
+ }, [
307
+ editor,
308
+ showWordCount,
309
+ wordCountFormatter,
310
+ editor?.state.doc.content.size
311
+ ]);
312
+ if (!showWordCount && !children) return null;
313
+ return /* @__PURE__ */ jsxs2(
314
+ "div",
315
+ {
316
+ className: cn(
317
+ "rte-footer",
318
+ variant !== "default" && `rte-footer--${variant}`,
319
+ sticky && "sticky z-10",
320
+ className
321
+ ),
322
+ "data-sticky": sticky ? "" : void 0,
323
+ style: sticky ? { bottom: stickyOffset } : void 0,
324
+ children: [
325
+ showWordCount && wordCount && /* @__PURE__ */ jsx3("span", { className: cn("rte-footer-word-count", wordCountClassName), children: wordCount }),
326
+ children
327
+ ]
328
+ }
329
+ );
330
+ }
331
+
265
332
  // src/rte-controls-group.tsx
266
- import { jsx as jsx3 } from "react/jsx-runtime";
333
+ import { jsx as jsx4 } from "react/jsx-runtime";
267
334
  function ControlsGroup({
268
335
  children,
269
336
  className
270
337
  }) {
271
- return /* @__PURE__ */ jsx3(
338
+ return /* @__PURE__ */ jsx4(
272
339
  "div",
273
340
  {
274
341
  className: cn("rte-controls-group", className),
@@ -279,11 +346,11 @@ function ControlsGroup({
279
346
 
280
347
  // src/rte-content.tsx
281
348
  import { EditorContent } from "@tiptap/react";
282
- import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
349
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
283
350
  function Content({ children, className }) {
284
351
  const { editor } = useRichTextEditorContext();
285
- return /* @__PURE__ */ jsxs2("div", { className: "relative", children: [
286
- /* @__PURE__ */ jsx4(
352
+ return /* @__PURE__ */ jsxs3("div", { className: "relative", children: [
353
+ /* @__PURE__ */ jsx5(
287
354
  EditorContent,
288
355
  {
289
356
  editor,
@@ -301,7 +368,7 @@ import "react";
301
368
  // src/ui/toggle.tsx
302
369
  import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
303
370
  import { cva } from "class-variance-authority";
304
- import { jsx as jsx5 } from "react/jsx-runtime";
371
+ import { jsx as jsx6 } from "react/jsx-runtime";
305
372
  var toggleVariants = cva(
306
373
  "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",
307
374
  {
@@ -328,7 +395,7 @@ function Toggle({
328
395
  size = "default",
329
396
  ...props
330
397
  }) {
331
- return /* @__PURE__ */ jsx5(
398
+ return /* @__PURE__ */ jsx6(
332
399
  TogglePrimitive,
333
400
  {
334
401
  "data-slot": "toggle",
@@ -339,7 +406,7 @@ function Toggle({
339
406
  }
340
407
 
341
408
  // src/controls/rte-control.tsx
342
- import { jsx as jsx6 } from "react/jsx-runtime";
409
+ import { jsx as jsx7 } from "react/jsx-runtime";
343
410
  function RichTextEditorControl({
344
411
  active,
345
412
  interactive = true,
@@ -350,7 +417,7 @@ function RichTextEditorControl({
350
417
  disabled,
351
418
  ...props
352
419
  }) {
353
- return /* @__PURE__ */ jsx6(
420
+ return /* @__PURE__ */ jsx7(
354
421
  Toggle,
355
422
  {
356
423
  size: "sm",
@@ -395,7 +462,7 @@ function createControl({
395
462
  });
396
463
  const active = editorState?.active ?? false;
397
464
  const disabled = editorState?.disabled ?? true;
398
- return /* @__PURE__ */ jsx6(
465
+ return /* @__PURE__ */ jsx7(
399
466
  RichTextEditorControl,
400
467
  {
401
468
  active,
@@ -419,18 +486,18 @@ function createControl({
419
486
 
420
487
  // src/controls/rte-link-control.tsx
421
488
  import * as React5 from "react";
422
- import { useState } from "react";
489
+ import { useState as useState2 } from "react";
423
490
  import { useEditorState as useEditorState2 } from "@tiptap/react";
424
491
 
425
492
  // src/ui/popover.tsx
426
493
  import "react";
427
494
  import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
428
- import { jsx as jsx7 } from "react/jsx-runtime";
495
+ import { jsx as jsx8 } from "react/jsx-runtime";
429
496
  function Popover({ ...props }) {
430
- return /* @__PURE__ */ jsx7(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
497
+ return /* @__PURE__ */ jsx8(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
431
498
  }
432
499
  function PopoverTrigger({ ...props }) {
433
- return /* @__PURE__ */ jsx7(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
500
+ return /* @__PURE__ */ jsx8(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
434
501
  }
435
502
  function PopoverContent({
436
503
  className,
@@ -440,7 +507,7 @@ function PopoverContent({
440
507
  sideOffset = 4,
441
508
  ...props
442
509
  }) {
443
- return /* @__PURE__ */ jsx7(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx7(
510
+ return /* @__PURE__ */ jsx8(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx8(
444
511
  PopoverPrimitive.Positioner,
445
512
  {
446
513
  align,
@@ -448,7 +515,7 @@ function PopoverContent({
448
515
  side,
449
516
  sideOffset,
450
517
  className: "isolate z-50",
451
- children: /* @__PURE__ */ jsx7(
518
+ children: /* @__PURE__ */ jsx8(
452
519
  PopoverPrimitive.Popup,
453
520
  {
454
521
  "data-slot": "popover-content",
@@ -466,9 +533,9 @@ function PopoverContent({
466
533
  // src/ui/input.tsx
467
534
  import "react";
468
535
  import { Input as InputPrimitive } from "@base-ui/react/input";
469
- import { jsx as jsx8 } from "react/jsx-runtime";
536
+ import { jsx as jsx9 } from "react/jsx-runtime";
470
537
  function Input({ className, type, ...props }) {
471
- return /* @__PURE__ */ jsx8(
538
+ return /* @__PURE__ */ jsx9(
472
539
  InputPrimitive,
473
540
  {
474
541
  type,
@@ -485,7 +552,7 @@ function Input({ className, type, ...props }) {
485
552
  // src/ui/button.tsx
486
553
  import { Button as ButtonPrimitive } from "@base-ui/react/button";
487
554
  import { cva as cva2 } from "class-variance-authority";
488
- import { jsx as jsx9 } from "react/jsx-runtime";
555
+ import { jsx as jsx10 } from "react/jsx-runtime";
489
556
  var buttonVariants = cva2(
490
557
  "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",
491
558
  {
@@ -521,7 +588,7 @@ function Button({
521
588
  size = "default",
522
589
  ...props
523
590
  }) {
524
- return /* @__PURE__ */ jsx9(
591
+ return /* @__PURE__ */ jsx10(
525
592
  ButtonPrimitive,
526
593
  {
527
594
  "data-slot": "button",
@@ -532,11 +599,11 @@ function Button({
532
599
  }
533
600
 
534
601
  // src/controls/rte-link-control.tsx
535
- import { jsx as jsx10, jsxs as jsxs3 } from "react/jsx-runtime";
602
+ import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
536
603
  function LinkControl() {
537
604
  const { editor, labels, icons } = useRichTextEditorContext();
538
- const [url, setUrl] = useState("");
539
- const [open, setOpen] = useState(false);
605
+ const [url, setUrl] = useState2("");
606
+ const [open, setOpen] = useState2(false);
540
607
  const active = useEditorState2({
541
608
  editor: editor ?? null,
542
609
  selector: (ctx) => ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("link") : false
@@ -571,12 +638,12 @@ function LinkControl() {
571
638
  window.addEventListener("edit-link", handler);
572
639
  return () => window.removeEventListener("edit-link", handler);
573
640
  }, [editor]);
574
- return /* @__PURE__ */ jsxs3(Popover, { open, onOpenChange: handleOpen, children: [
575
- /* @__PURE__ */ jsx10(
641
+ return /* @__PURE__ */ jsxs4(Popover, { open, onOpenChange: handleOpen, children: [
642
+ /* @__PURE__ */ jsx11(
576
643
  PopoverTrigger,
577
644
  {
578
645
  onMouseDown: (e) => e.preventDefault(),
579
- children: /* @__PURE__ */ jsx10(
646
+ children: /* @__PURE__ */ jsx11(
580
647
  Toggle,
581
648
  {
582
649
  size: "sm",
@@ -589,8 +656,8 @@ function LinkControl() {
589
656
  )
590
657
  }
591
658
  ),
592
- /* @__PURE__ */ jsx10(PopoverContent, { className: "w-72 p-3", children: /* @__PURE__ */ jsxs3("div", { className: "rte-link-editor", children: [
593
- /* @__PURE__ */ jsx10(
659
+ /* @__PURE__ */ jsx11(PopoverContent, { className: "w-72 p-3", children: /* @__PURE__ */ jsxs4("div", { className: "rte-link-editor", children: [
660
+ /* @__PURE__ */ jsx11(
594
661
  Input,
595
662
  {
596
663
  type: "url",
@@ -602,7 +669,7 @@ function LinkControl() {
602
669
  className: "rte-link-editor-input h-8 text-sm"
603
670
  }
604
671
  ),
605
- /* @__PURE__ */ jsx10(
672
+ /* @__PURE__ */ jsx11(
606
673
  Button,
607
674
  {
608
675
  size: "sm",
@@ -777,7 +844,7 @@ var SuperscriptControl = createControl({
777
844
  });
778
845
 
779
846
  // src/controls/rte-youtube-control.tsx
780
- import { useState as useState2, useCallback as useCallback2 } from "react";
847
+ import { useState as useState3, useCallback as useCallback2 } from "react";
781
848
  import { Node, nodeInputRule } from "@tiptap/core";
782
849
  import {
783
850
  ReactNodeViewRenderer,
@@ -787,24 +854,24 @@ import {
787
854
  // src/ui/dialog.tsx
788
855
  import "react";
789
856
  import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
790
- import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
857
+ import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
791
858
  function Dialog({ ...props }) {
792
- return /* @__PURE__ */ jsx11(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
859
+ return /* @__PURE__ */ jsx12(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
793
860
  }
794
861
  function DialogTrigger({ ...props }) {
795
- return /* @__PURE__ */ jsx11(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
862
+ return /* @__PURE__ */ jsx12(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
796
863
  }
797
864
  function DialogPortal({ ...props }) {
798
- return /* @__PURE__ */ jsx11(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
865
+ return /* @__PURE__ */ jsx12(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
799
866
  }
800
867
  function DialogClose({ ...props }) {
801
- return /* @__PURE__ */ jsx11(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
868
+ return /* @__PURE__ */ jsx12(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
802
869
  }
803
870
  function DialogOverlay({
804
871
  className,
805
872
  ...props
806
873
  }) {
807
- return /* @__PURE__ */ jsx11(
874
+ return /* @__PURE__ */ jsx12(
808
875
  DialogPrimitive.Backdrop,
809
876
  {
810
877
  "data-slot": "dialog-overlay",
@@ -822,9 +889,9 @@ function DialogContent({
822
889
  showCloseButton = true,
823
890
  ...props
824
891
  }) {
825
- return /* @__PURE__ */ jsxs4(DialogPortal, { children: [
826
- /* @__PURE__ */ jsx11(DialogOverlay, {}),
827
- /* @__PURE__ */ jsxs4(
892
+ return /* @__PURE__ */ jsxs5(DialogPortal, { children: [
893
+ /* @__PURE__ */ jsx12(DialogOverlay, {}),
894
+ /* @__PURE__ */ jsxs5(
828
895
  DialogPrimitive.Popup,
829
896
  {
830
897
  "data-slot": "dialog-content",
@@ -835,11 +902,11 @@ function DialogContent({
835
902
  ...props,
836
903
  children: [
837
904
  children,
838
- showCloseButton && /* @__PURE__ */ jsxs4(
905
+ showCloseButton && /* @__PURE__ */ jsxs5(
839
906
  DialogPrimitive.Close,
840
907
  {
841
908
  "data-slot": "dialog-close",
842
- render: /* @__PURE__ */ jsx11(
909
+ render: /* @__PURE__ */ jsx12(
843
910
  Button,
844
911
  {
845
912
  variant: "ghost",
@@ -849,7 +916,7 @@ function DialogContent({
849
916
  ),
850
917
  children: [
851
918
  "X",
852
- /* @__PURE__ */ jsx11("span", { className: "sr-only", children: "Close" })
919
+ /* @__PURE__ */ jsx12("span", { className: "sr-only", children: "Close" })
853
920
  ]
854
921
  }
855
922
  )
@@ -859,7 +926,7 @@ function DialogContent({
859
926
  ] });
860
927
  }
861
928
  function DialogHeader({ className, ...props }) {
862
- return /* @__PURE__ */ jsx11(
929
+ return /* @__PURE__ */ jsx12(
863
930
  "div",
864
931
  {
865
932
  "data-slot": "dialog-header",
@@ -874,7 +941,7 @@ function DialogFooter({
874
941
  children,
875
942
  ...props
876
943
  }) {
877
- return /* @__PURE__ */ jsxs4(
944
+ return /* @__PURE__ */ jsxs5(
878
945
  "div",
879
946
  {
880
947
  "data-slot": "dialog-footer",
@@ -885,13 +952,13 @@ function DialogFooter({
885
952
  ...props,
886
953
  children: [
887
954
  children,
888
- showCloseButton && /* @__PURE__ */ jsx11(DialogPrimitive.Close, { render: /* @__PURE__ */ jsx11(Button, { variant: "outline" }), children: "Close" })
955
+ showCloseButton && /* @__PURE__ */ jsx12(DialogPrimitive.Close, { render: /* @__PURE__ */ jsx12(Button, { variant: "outline" }), children: "Close" })
889
956
  ]
890
957
  }
891
958
  );
892
959
  }
893
960
  function DialogTitle({ className, ...props }) {
894
- return /* @__PURE__ */ jsx11(
961
+ return /* @__PURE__ */ jsx12(
895
962
  DialogPrimitive.Title,
896
963
  {
897
964
  "data-slot": "dialog-title",
@@ -904,7 +971,7 @@ function DialogDescription({
904
971
  className,
905
972
  ...props
906
973
  }) {
907
- return /* @__PURE__ */ jsx11(
974
+ return /* @__PURE__ */ jsx12(
908
975
  DialogPrimitive.Description,
909
976
  {
910
977
  "data-slot": "dialog-description",
@@ -918,9 +985,9 @@ function DialogDescription({
918
985
  }
919
986
 
920
987
  // src/extensions/resizable-node-view.tsx
921
- import { useCallback, useRef, useEffect as useEffect2 } from "react";
988
+ import { useCallback, useRef as useRef2, useEffect as useEffect3 } from "react";
922
989
  import { NodeViewWrapper } from "@tiptap/react";
923
- import { Fragment, jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
990
+ import { Fragment, jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
924
991
  function ResizableNodeView({
925
992
  node,
926
993
  selected,
@@ -932,8 +999,8 @@ function ResizableNodeView({
932
999
  minWidth = 300,
933
1000
  maxWidth = 1200
934
1001
  }) {
935
- const containerRef = useRef(null);
936
- const resizingRef = useRef(null);
1002
+ const containerRef = useRef2(null);
1003
+ const resizingRef = useRef2(null);
937
1004
  const width = node.attrs.width;
938
1005
  const height = node.attrs.height;
939
1006
  const align = node.attrs.align || "center";
@@ -1012,7 +1079,7 @@ function ResizableNodeView({
1012
1079
  }
1013
1080
  resizingRef.current = null;
1014
1081
  }, [handleMouseMove, updateAttributes]);
1015
- useEffect2(() => {
1082
+ useEffect3(() => {
1016
1083
  return () => {
1017
1084
  document.removeEventListener("mousemove", handleMouseMove);
1018
1085
  document.removeEventListener("mouseup", handleMouseUp);
@@ -1020,13 +1087,13 @@ function ResizableNodeView({
1020
1087
  document.body.style.userSelect = "";
1021
1088
  };
1022
1089
  }, [handleMouseMove]);
1023
- return /* @__PURE__ */ jsx12(
1090
+ return /* @__PURE__ */ jsx13(
1024
1091
  NodeViewWrapper,
1025
1092
  {
1026
1093
  className: "rte-embed-wrapper",
1027
1094
  "data-selected": selected || void 0,
1028
1095
  "data-align": align,
1029
- children: /* @__PURE__ */ jsxs5(
1096
+ children: /* @__PURE__ */ jsxs6(
1030
1097
  "div",
1031
1098
  {
1032
1099
  ref: containerRef,
@@ -1039,22 +1106,22 @@ function ResizableNodeView({
1039
1106
  },
1040
1107
  children: [
1041
1108
  children,
1042
- selected && /* @__PURE__ */ jsxs5(Fragment, { children: [
1043
- /* @__PURE__ */ jsx12(
1109
+ selected && /* @__PURE__ */ jsxs6(Fragment, { children: [
1110
+ /* @__PURE__ */ jsx13(
1044
1111
  "div",
1045
1112
  {
1046
1113
  className: "rte-resize-handle rte-resize-handle--right",
1047
1114
  onMouseDown: (e) => handleMouseDown(e, "right")
1048
1115
  }
1049
1116
  ),
1050
- /* @__PURE__ */ jsx12(
1117
+ /* @__PURE__ */ jsx13(
1051
1118
  "div",
1052
1119
  {
1053
1120
  className: "rte-resize-handle rte-resize-handle--bottom",
1054
1121
  onMouseDown: (e) => handleMouseDown(e, "bottom")
1055
1122
  }
1056
1123
  ),
1057
- /* @__PURE__ */ jsx12(
1124
+ /* @__PURE__ */ jsx13(
1058
1125
  "div",
1059
1126
  {
1060
1127
  className: "rte-resize-handle rte-resize-handle--corner",
@@ -1070,7 +1137,7 @@ function ResizableNodeView({
1070
1137
  }
1071
1138
 
1072
1139
  // src/controls/rte-youtube-control.tsx
1073
- import { jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
1140
+ import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
1074
1141
  function getYouTubeId(url) {
1075
1142
  const clean = url.trim();
1076
1143
  const patterns = [
@@ -1091,7 +1158,7 @@ function getYouTubeId(url) {
1091
1158
  function YouTubeNodeView(props) {
1092
1159
  const { node } = props;
1093
1160
  const videoId = getYouTubeId(node.attrs.src) || node.attrs.src;
1094
- return /* @__PURE__ */ jsx13(ResizableNodeView, { ...props, lockAspect: true, aspectRatio: 16 / 9, minWidth: 320, maxWidth: 1200, children: /* @__PURE__ */ jsx13(
1161
+ return /* @__PURE__ */ jsx14(ResizableNodeView, { ...props, lockAspect: true, aspectRatio: 16 / 9, minWidth: 320, maxWidth: 1200, children: /* @__PURE__ */ jsx14(
1095
1162
  "iframe",
1096
1163
  {
1097
1164
  src: `https://www.youtube-nocookie.com/embed/${videoId}`,
@@ -1179,8 +1246,8 @@ var YouTubeEmbed = Node.create({
1179
1246
  });
1180
1247
  function YouTubeEmbedControl({ className }) {
1181
1248
  const { editor } = useRichTextEditorContext();
1182
- const [open, setOpen] = useState2(false);
1183
- const [url, setUrl] = useState2("");
1249
+ const [open, setOpen] = useState3(false);
1250
+ const [url, setUrl] = useState3("");
1184
1251
  const { active } = useEditorState3({
1185
1252
  editor: editor ?? null,
1186
1253
  selector: (ctx) => ({
@@ -1193,18 +1260,18 @@ function YouTubeEmbedControl({ className }) {
1193
1260
  setUrl("");
1194
1261
  }
1195
1262
  }, [url, editor]);
1196
- return /* @__PURE__ */ jsxs6(Dialog, { open, onOpenChange: setOpen, children: [
1197
- /* @__PURE__ */ jsx13(
1263
+ return /* @__PURE__ */ jsxs7(Dialog, { open, onOpenChange: setOpen, children: [
1264
+ /* @__PURE__ */ jsx14(
1198
1265
  DialogTrigger,
1199
1266
  {
1200
- render: /* @__PURE__ */ jsx13(
1267
+ render: /* @__PURE__ */ jsx14(
1201
1268
  RichTextEditorControl,
1202
1269
  {
1203
1270
  active,
1204
1271
  className,
1205
1272
  title: "Embed YouTube video",
1206
1273
  "aria-label": "Embed YouTube video",
1207
- children: /* @__PURE__ */ jsxs6(
1274
+ children: /* @__PURE__ */ jsxs7(
1208
1275
  "svg",
1209
1276
  {
1210
1277
  xmlns: "http://www.w3.org/2000/svg",
@@ -1216,8 +1283,8 @@ function YouTubeEmbedControl({ className }) {
1216
1283
  "stroke-linejoin": "round",
1217
1284
  className: "rte-editor-icon",
1218
1285
  children: [
1219
- /* @__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" }),
1220
- /* @__PURE__ */ jsx13("path", { d: "M9.5 15.5V8.5l6.2 3.5z" })
1286
+ /* @__PURE__ */ jsx14("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" }),
1287
+ /* @__PURE__ */ jsx14("path", { d: "M9.5 15.5V8.5l6.2 3.5z" })
1221
1288
  ]
1222
1289
  }
1223
1290
  )
@@ -1225,12 +1292,12 @@ function YouTubeEmbedControl({ className }) {
1225
1292
  )
1226
1293
  }
1227
1294
  ),
1228
- /* @__PURE__ */ jsxs6(DialogContent, { showCloseButton: false, children: [
1229
- /* @__PURE__ */ jsxs6(DialogHeader, { children: [
1230
- /* @__PURE__ */ jsx13(DialogTitle, { children: "Embed YouTube video" }),
1231
- /* @__PURE__ */ jsx13(DialogDescription, { children: "Paste a YouTube video URL or ID." })
1295
+ /* @__PURE__ */ jsxs7(DialogContent, { showCloseButton: false, children: [
1296
+ /* @__PURE__ */ jsxs7(DialogHeader, { children: [
1297
+ /* @__PURE__ */ jsx14(DialogTitle, { children: "Embed YouTube video" }),
1298
+ /* @__PURE__ */ jsx14(DialogDescription, { children: "Paste a YouTube video URL or ID." })
1232
1299
  ] }),
1233
- /* @__PURE__ */ jsx13(
1300
+ /* @__PURE__ */ jsx14(
1234
1301
  Input,
1235
1302
  {
1236
1303
  value: url,
@@ -1244,9 +1311,9 @@ function YouTubeEmbedControl({ className }) {
1244
1311
  }
1245
1312
  }
1246
1313
  ),
1247
- /* @__PURE__ */ jsxs6(DialogFooter, { children: [
1248
- /* @__PURE__ */ jsx13(DialogClose, { children: "Cancel" }),
1249
- /* @__PURE__ */ jsx13(
1314
+ /* @__PURE__ */ jsxs7(DialogFooter, { children: [
1315
+ /* @__PURE__ */ jsx14(DialogClose, { children: "Cancel" }),
1316
+ /* @__PURE__ */ jsx14(
1250
1317
  DialogClose,
1251
1318
  {
1252
1319
  disabled: !url,
@@ -1261,18 +1328,18 @@ function YouTubeEmbedControl({ className }) {
1261
1328
  }
1262
1329
 
1263
1330
  // src/controls/rte-twitter-control.tsx
1264
- import { useState as useState3, useCallback as useCallback3, useEffect as useEffect3, useRef as useRef2 } from "react";
1331
+ import { useState as useState4, useCallback as useCallback3, useEffect as useEffect4, useRef as useRef3 } from "react";
1265
1332
  import { Node as Node2, nodeInputRule as nodeInputRule2 } from "@tiptap/core";
1266
1333
  import {
1267
1334
  ReactNodeViewRenderer as ReactNodeViewRenderer2,
1268
1335
  useEditorState as useEditorState4
1269
1336
  } from "@tiptap/react";
1270
- import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
1337
+ import { jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
1271
1338
  var WIDGET_SCRIPT_URL = "https://platform.twitter.com/widgets.js";
1272
1339
  function TwitterNodeView(props) {
1273
1340
  const { node } = props;
1274
- const containerRef = useRef2(null);
1275
- const [loading, setLoading] = useState3(true);
1341
+ const containerRef = useRef3(null);
1342
+ const [loading, setLoading] = useState4(true);
1276
1343
  const tweetId = node.attrs.tweetId;
1277
1344
  const w = node.attrs.width;
1278
1345
  const h = node.attrs.height;
@@ -1287,7 +1354,7 @@ function TwitterNodeView(props) {
1287
1354
  });
1288
1355
  }
1289
1356
  }, [tweetId]);
1290
- useEffect3(() => {
1357
+ useEffect4(() => {
1291
1358
  if (!containerRef.current || !tweetId) return;
1292
1359
  if (window.twttr?.widgets) {
1293
1360
  renderTweet();
@@ -1299,9 +1366,9 @@ function TwitterNodeView(props) {
1299
1366
  document.body.appendChild(script);
1300
1367
  }
1301
1368
  }, [tweetId, w, h, renderTweet]);
1302
- return /* @__PURE__ */ jsxs7(ResizableNodeView, { ...props, lockAspect: false, minWidth: 300, maxWidth: 1200, children: [
1303
- loading && /* @__PURE__ */ jsx14("div", { className: "rte-embed-loading", children: "Loading tweet..." }),
1304
- /* @__PURE__ */ jsx14("div", { ref: containerRef })
1369
+ return /* @__PURE__ */ jsxs8(ResizableNodeView, { ...props, lockAspect: false, minWidth: 300, maxWidth: 1200, children: [
1370
+ loading && /* @__PURE__ */ jsx15("div", { className: "rte-embed-loading", children: "Loading tweet..." }),
1371
+ /* @__PURE__ */ jsx15("div", { ref: containerRef })
1305
1372
  ] });
1306
1373
  }
1307
1374
  var TwitterEmbed = Node2.create({
@@ -1386,8 +1453,8 @@ function extractTweetId(input) {
1386
1453
  }
1387
1454
  function TwitterEmbedControl({ className }) {
1388
1455
  const { editor } = useRichTextEditorContext();
1389
- const [open, setOpen] = useState3(false);
1390
- const [url, setUrl] = useState3("");
1456
+ const [open, setOpen] = useState4(false);
1457
+ const [url, setUrl] = useState4("");
1391
1458
  const { active } = useEditorState4({
1392
1459
  editor: editor ?? null,
1393
1460
  selector: (ctx) => ({
@@ -1403,37 +1470,37 @@ function TwitterEmbedControl({ className }) {
1403
1470
  }
1404
1471
  }
1405
1472
  }, [url, editor]);
1406
- return /* @__PURE__ */ jsxs7(Dialog, { open, onOpenChange: setOpen, children: [
1407
- /* @__PURE__ */ jsx14(
1473
+ return /* @__PURE__ */ jsxs8(Dialog, { open, onOpenChange: setOpen, children: [
1474
+ /* @__PURE__ */ jsx15(
1408
1475
  DialogTrigger,
1409
1476
  {
1410
- render: /* @__PURE__ */ jsx14(
1477
+ render: /* @__PURE__ */ jsx15(
1411
1478
  RichTextEditorControl,
1412
1479
  {
1413
1480
  active,
1414
1481
  className,
1415
1482
  title: "Embed Tweet",
1416
1483
  "aria-label": "Embed Tweet",
1417
- children: /* @__PURE__ */ jsx14(
1484
+ children: /* @__PURE__ */ jsx15(
1418
1485
  "svg",
1419
1486
  {
1420
1487
  xmlns: "http://www.w3.org/2000/svg",
1421
1488
  viewBox: "0 0 24 24",
1422
1489
  fill: "currentColor",
1423
1490
  className: "rte-editor-icon",
1424
- children: /* @__PURE__ */ jsx14("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" })
1491
+ children: /* @__PURE__ */ jsx15("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" })
1425
1492
  }
1426
1493
  )
1427
1494
  }
1428
1495
  )
1429
1496
  }
1430
1497
  ),
1431
- /* @__PURE__ */ jsxs7(DialogContent, { children: [
1432
- /* @__PURE__ */ jsxs7(DialogHeader, { children: [
1433
- /* @__PURE__ */ jsx14(DialogTitle, { children: "Embed Tweet" }),
1434
- /* @__PURE__ */ jsx14(DialogDescription, { children: "Paste a tweet URL or ID." })
1498
+ /* @__PURE__ */ jsxs8(DialogContent, { children: [
1499
+ /* @__PURE__ */ jsxs8(DialogHeader, { children: [
1500
+ /* @__PURE__ */ jsx15(DialogTitle, { children: "Embed Tweet" }),
1501
+ /* @__PURE__ */ jsx15(DialogDescription, { children: "Paste a tweet URL or ID." })
1435
1502
  ] }),
1436
- /* @__PURE__ */ jsx14(
1503
+ /* @__PURE__ */ jsx15(
1437
1504
  Input,
1438
1505
  {
1439
1506
  value: url,
@@ -1447,9 +1514,9 @@ function TwitterEmbedControl({ className }) {
1447
1514
  }
1448
1515
  }
1449
1516
  ),
1450
- /* @__PURE__ */ jsxs7(DialogFooter, { children: [
1451
- /* @__PURE__ */ jsx14(DialogClose, { children: "Cancel" }),
1452
- /* @__PURE__ */ jsx14(
1517
+ /* @__PURE__ */ jsxs8(DialogFooter, { children: [
1518
+ /* @__PURE__ */ jsx15(DialogClose, { children: "Cancel" }),
1519
+ /* @__PURE__ */ jsx15(
1453
1520
  DialogClose,
1454
1521
  {
1455
1522
  disabled: !url,
@@ -1464,7 +1531,7 @@ function TwitterEmbedControl({ className }) {
1464
1531
  }
1465
1532
 
1466
1533
  // src/rte-text-editor.tsx
1467
- import { jsx as jsx15 } from "react/jsx-runtime";
1534
+ import { jsx as jsx16 } from "react/jsx-runtime";
1468
1535
  function RichTextEditorRoot({
1469
1536
  editor,
1470
1537
  children,
@@ -1474,20 +1541,20 @@ function RichTextEditorRoot({
1474
1541
  variant = "default",
1475
1542
  editable = true
1476
1543
  }) {
1477
- const mergedLabels = useMemo(
1544
+ const mergedLabels = useMemo2(
1478
1545
  () => ({ ...DEFAULT_LABELS, ...labels }),
1479
1546
  [labels]
1480
1547
  );
1481
- const mergedIcons = useMemo(
1548
+ const mergedIcons = useMemo2(
1482
1549
  () => ({ ...DEFAULT_ICONS, ...icons }),
1483
1550
  [icons]
1484
1551
  );
1485
- useEffect4(() => {
1552
+ useEffect5(() => {
1486
1553
  if (editor && editor.isEditable !== editable) {
1487
1554
  editor.setEditable(editable);
1488
1555
  }
1489
1556
  }, [editor, editable]);
1490
- return /* @__PURE__ */ jsx15(RichTextEditorContext.Provider, { value: { editor, labels: mergedLabels, icons: mergedIcons, variant, editable }, children: /* @__PURE__ */ jsx15(
1557
+ return /* @__PURE__ */ jsx16(RichTextEditorContext.Provider, { value: { editor, labels: mergedLabels, icons: mergedIcons, variant, editable }, children: /* @__PURE__ */ jsx16(
1491
1558
  "div",
1492
1559
  {
1493
1560
  className: cn(
@@ -1502,6 +1569,7 @@ function RichTextEditorRoot({
1502
1569
  }
1503
1570
  var RichTextEditor = Object.assign(RichTextEditorRoot, {
1504
1571
  Toolbar,
1572
+ Footer,
1505
1573
  ControlsGroup,
1506
1574
  Content,
1507
1575
  Control: RichTextEditorControl,