@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.cjs +195 -127
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +173 -105
- package/dist/index.js.map +1 -1
- package/dist/style.css +165 -25
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,7 @@ __export(index_exports, {
|
|
|
41
41
|
module.exports = __toCommonJS(index_exports);
|
|
42
42
|
|
|
43
43
|
// src/rte-text-editor.tsx
|
|
44
|
-
var
|
|
44
|
+
var import_react16 = require("react");
|
|
45
45
|
|
|
46
46
|
// src/ui/utils.ts
|
|
47
47
|
var import_clsx = require("clsx");
|
|
@@ -304,13 +304,80 @@ function Toolbar({
|
|
|
304
304
|
);
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
// src/rte-
|
|
307
|
+
// src/rte-footer.tsx
|
|
308
|
+
var import_react4 = require("react");
|
|
308
309
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
310
|
+
function Footer({
|
|
311
|
+
children,
|
|
312
|
+
className,
|
|
313
|
+
sticky = false,
|
|
314
|
+
stickyOffset = 0,
|
|
315
|
+
showWordCount = false,
|
|
316
|
+
wordCountClassName,
|
|
317
|
+
wordCountFormatter
|
|
318
|
+
}) {
|
|
319
|
+
const { editor, variant } = useRichTextEditorContext();
|
|
320
|
+
const [, forceUpdate] = (0, import_react4.useState)(0);
|
|
321
|
+
const rafRef = (0, import_react4.useRef)(null);
|
|
322
|
+
(0, import_react4.useEffect)(() => {
|
|
323
|
+
if (!editor || !showWordCount) return;
|
|
324
|
+
const scheduleUpdate = () => {
|
|
325
|
+
if (rafRef.current != null) return;
|
|
326
|
+
rafRef.current = requestAnimationFrame(() => {
|
|
327
|
+
rafRef.current = null;
|
|
328
|
+
forceUpdate((t) => t + 1);
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
const handleTransaction = ({
|
|
332
|
+
transaction
|
|
333
|
+
}) => {
|
|
334
|
+
if (transaction.docChanged) scheduleUpdate();
|
|
335
|
+
};
|
|
336
|
+
editor.on("transaction", handleTransaction);
|
|
337
|
+
scheduleUpdate();
|
|
338
|
+
return () => {
|
|
339
|
+
editor.off("transaction", handleTransaction);
|
|
340
|
+
if (rafRef.current != null) cancelAnimationFrame(rafRef.current);
|
|
341
|
+
};
|
|
342
|
+
}, [editor, showWordCount]);
|
|
343
|
+
const wordCount = (0, import_react4.useMemo)(() => {
|
|
344
|
+
if (!editor || !showWordCount) return null;
|
|
345
|
+
const words = editor.storage.characterCount?.words() ?? 0;
|
|
346
|
+
const characters = editor.storage.characterCount?.characters() ?? 0;
|
|
347
|
+
return wordCountFormatter ? wordCountFormatter({ words, characters }) : `${words} words | ${characters} characters`;
|
|
348
|
+
}, [
|
|
349
|
+
editor,
|
|
350
|
+
showWordCount,
|
|
351
|
+
wordCountFormatter,
|
|
352
|
+
editor?.state.doc.content.size
|
|
353
|
+
]);
|
|
354
|
+
if (!showWordCount && !children) return null;
|
|
355
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
356
|
+
"div",
|
|
357
|
+
{
|
|
358
|
+
className: cn(
|
|
359
|
+
"rte-footer",
|
|
360
|
+
variant !== "default" && `rte-footer--${variant}`,
|
|
361
|
+
sticky && "sticky z-10",
|
|
362
|
+
className
|
|
363
|
+
),
|
|
364
|
+
"data-sticky": sticky ? "" : void 0,
|
|
365
|
+
style: sticky ? { bottom: stickyOffset } : void 0,
|
|
366
|
+
children: [
|
|
367
|
+
showWordCount && wordCount && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: cn("rte-footer-word-count", wordCountClassName), children: wordCount }),
|
|
368
|
+
children
|
|
369
|
+
]
|
|
370
|
+
}
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// src/rte-controls-group.tsx
|
|
375
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
309
376
|
function ControlsGroup({
|
|
310
377
|
children,
|
|
311
378
|
className
|
|
312
379
|
}) {
|
|
313
|
-
return /* @__PURE__ */ (0,
|
|
380
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
314
381
|
"div",
|
|
315
382
|
{
|
|
316
383
|
className: cn("rte-controls-group", className),
|
|
@@ -320,13 +387,13 @@ function ControlsGroup({
|
|
|
320
387
|
}
|
|
321
388
|
|
|
322
389
|
// src/rte-content.tsx
|
|
323
|
-
var
|
|
324
|
-
var
|
|
390
|
+
var import_react5 = require("@tiptap/react");
|
|
391
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
325
392
|
function Content({ children, className }) {
|
|
326
393
|
const { editor } = useRichTextEditorContext();
|
|
327
|
-
return /* @__PURE__ */ (0,
|
|
328
|
-
/* @__PURE__ */ (0,
|
|
329
|
-
|
|
394
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative", children: [
|
|
395
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
396
|
+
import_react5.EditorContent,
|
|
330
397
|
{
|
|
331
398
|
editor,
|
|
332
399
|
className: cn("rte-content w-full", className)
|
|
@@ -337,13 +404,13 @@ function Content({ children, className }) {
|
|
|
337
404
|
}
|
|
338
405
|
|
|
339
406
|
// src/controls/rte-control.tsx
|
|
340
|
-
var
|
|
341
|
-
var
|
|
407
|
+
var import_react6 = require("@tiptap/react");
|
|
408
|
+
var import_react7 = require("react");
|
|
342
409
|
|
|
343
410
|
// src/ui/toggle.tsx
|
|
344
411
|
var import_toggle = require("@base-ui/react/toggle");
|
|
345
412
|
var import_class_variance_authority = require("class-variance-authority");
|
|
346
|
-
var
|
|
413
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
347
414
|
var toggleVariants = (0, import_class_variance_authority.cva)(
|
|
348
415
|
"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",
|
|
349
416
|
{
|
|
@@ -370,7 +437,7 @@ function Toggle({
|
|
|
370
437
|
size = "default",
|
|
371
438
|
...props
|
|
372
439
|
}) {
|
|
373
|
-
return /* @__PURE__ */ (0,
|
|
440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
374
441
|
import_toggle.Toggle,
|
|
375
442
|
{
|
|
376
443
|
"data-slot": "toggle",
|
|
@@ -381,7 +448,7 @@ function Toggle({
|
|
|
381
448
|
}
|
|
382
449
|
|
|
383
450
|
// src/controls/rte-control.tsx
|
|
384
|
-
var
|
|
451
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
385
452
|
function RichTextEditorControl({
|
|
386
453
|
active,
|
|
387
454
|
interactive = true,
|
|
@@ -392,7 +459,7 @@ function RichTextEditorControl({
|
|
|
392
459
|
disabled,
|
|
393
460
|
...props
|
|
394
461
|
}) {
|
|
395
|
-
return /* @__PURE__ */ (0,
|
|
462
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
396
463
|
Toggle,
|
|
397
464
|
{
|
|
398
465
|
size: "sm",
|
|
@@ -420,7 +487,7 @@ function createControl({
|
|
|
420
487
|
function Control({ className }) {
|
|
421
488
|
const { editor, labels, icons } = useRichTextEditorContext();
|
|
422
489
|
const ariaLabel = labels[label];
|
|
423
|
-
const editorState = (0,
|
|
490
|
+
const editorState = (0, import_react6.useEditorState)({
|
|
424
491
|
editor: editor ?? null,
|
|
425
492
|
selector: (ctx) => {
|
|
426
493
|
const safeEditor = ctx.editor && !ctx.editor.isDestroyed ? ctx.editor : null;
|
|
@@ -437,7 +504,7 @@ function createControl({
|
|
|
437
504
|
});
|
|
438
505
|
const active = editorState?.active ?? false;
|
|
439
506
|
const disabled = editorState?.disabled ?? true;
|
|
440
|
-
return /* @__PURE__ */ (0,
|
|
507
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
441
508
|
RichTextEditorControl,
|
|
442
509
|
{
|
|
443
510
|
active,
|
|
@@ -461,18 +528,18 @@ function createControl({
|
|
|
461
528
|
|
|
462
529
|
// src/controls/rte-link-control.tsx
|
|
463
530
|
var React5 = __toESM(require("react"), 1);
|
|
464
|
-
var
|
|
465
|
-
var
|
|
531
|
+
var import_react8 = require("react");
|
|
532
|
+
var import_react9 = require("@tiptap/react");
|
|
466
533
|
|
|
467
534
|
// src/ui/popover.tsx
|
|
468
535
|
var React3 = require("react");
|
|
469
536
|
var import_popover = require("@base-ui/react/popover");
|
|
470
|
-
var
|
|
537
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
471
538
|
function Popover({ ...props }) {
|
|
472
|
-
return /* @__PURE__ */ (0,
|
|
539
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_popover.Popover.Root, { "data-slot": "popover", ...props });
|
|
473
540
|
}
|
|
474
541
|
function PopoverTrigger({ ...props }) {
|
|
475
|
-
return /* @__PURE__ */ (0,
|
|
542
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_popover.Popover.Trigger, { "data-slot": "popover-trigger", ...props });
|
|
476
543
|
}
|
|
477
544
|
function PopoverContent({
|
|
478
545
|
className,
|
|
@@ -482,7 +549,7 @@ function PopoverContent({
|
|
|
482
549
|
sideOffset = 4,
|
|
483
550
|
...props
|
|
484
551
|
}) {
|
|
485
|
-
return /* @__PURE__ */ (0,
|
|
552
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_popover.Popover.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
486
553
|
import_popover.Popover.Positioner,
|
|
487
554
|
{
|
|
488
555
|
align,
|
|
@@ -490,7 +557,7 @@ function PopoverContent({
|
|
|
490
557
|
side,
|
|
491
558
|
sideOffset,
|
|
492
559
|
className: "isolate z-50",
|
|
493
|
-
children: /* @__PURE__ */ (0,
|
|
560
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
494
561
|
import_popover.Popover.Popup,
|
|
495
562
|
{
|
|
496
563
|
"data-slot": "popover-content",
|
|
@@ -508,9 +575,9 @@ function PopoverContent({
|
|
|
508
575
|
// src/ui/input.tsx
|
|
509
576
|
var React4 = require("react");
|
|
510
577
|
var import_input = require("@base-ui/react/input");
|
|
511
|
-
var
|
|
578
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
512
579
|
function Input({ className, type, ...props }) {
|
|
513
|
-
return /* @__PURE__ */ (0,
|
|
580
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
514
581
|
import_input.Input,
|
|
515
582
|
{
|
|
516
583
|
type,
|
|
@@ -527,7 +594,7 @@ function Input({ className, type, ...props }) {
|
|
|
527
594
|
// src/ui/button.tsx
|
|
528
595
|
var import_button = require("@base-ui/react/button");
|
|
529
596
|
var import_class_variance_authority2 = require("class-variance-authority");
|
|
530
|
-
var
|
|
597
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
531
598
|
var buttonVariants = (0, import_class_variance_authority2.cva)(
|
|
532
599
|
"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",
|
|
533
600
|
{
|
|
@@ -563,7 +630,7 @@ function Button({
|
|
|
563
630
|
size = "default",
|
|
564
631
|
...props
|
|
565
632
|
}) {
|
|
566
|
-
return /* @__PURE__ */ (0,
|
|
633
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
567
634
|
import_button.Button,
|
|
568
635
|
{
|
|
569
636
|
"data-slot": "button",
|
|
@@ -574,12 +641,12 @@ function Button({
|
|
|
574
641
|
}
|
|
575
642
|
|
|
576
643
|
// src/controls/rte-link-control.tsx
|
|
577
|
-
var
|
|
644
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
578
645
|
function LinkControl() {
|
|
579
646
|
const { editor, labels, icons } = useRichTextEditorContext();
|
|
580
|
-
const [url, setUrl] = (0,
|
|
581
|
-
const [open, setOpen] = (0,
|
|
582
|
-
const active = (0,
|
|
647
|
+
const [url, setUrl] = (0, import_react8.useState)("");
|
|
648
|
+
const [open, setOpen] = (0, import_react8.useState)(false);
|
|
649
|
+
const active = (0, import_react9.useEditorState)({
|
|
583
650
|
editor: editor ?? null,
|
|
584
651
|
selector: (ctx) => ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("link") : false
|
|
585
652
|
});
|
|
@@ -613,12 +680,12 @@ function LinkControl() {
|
|
|
613
680
|
window.addEventListener("edit-link", handler);
|
|
614
681
|
return () => window.removeEventListener("edit-link", handler);
|
|
615
682
|
}, [editor]);
|
|
616
|
-
return /* @__PURE__ */ (0,
|
|
617
|
-
/* @__PURE__ */ (0,
|
|
683
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Popover, { open, onOpenChange: handleOpen, children: [
|
|
684
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
618
685
|
PopoverTrigger,
|
|
619
686
|
{
|
|
620
687
|
onMouseDown: (e) => e.preventDefault(),
|
|
621
|
-
children: /* @__PURE__ */ (0,
|
|
688
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
622
689
|
Toggle,
|
|
623
690
|
{
|
|
624
691
|
size: "sm",
|
|
@@ -631,8 +698,8 @@ function LinkControl() {
|
|
|
631
698
|
)
|
|
632
699
|
}
|
|
633
700
|
),
|
|
634
|
-
/* @__PURE__ */ (0,
|
|
635
|
-
/* @__PURE__ */ (0,
|
|
701
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PopoverContent, { className: "w-72 p-3", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "rte-link-editor", children: [
|
|
702
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
636
703
|
Input,
|
|
637
704
|
{
|
|
638
705
|
type: "url",
|
|
@@ -644,7 +711,7 @@ function LinkControl() {
|
|
|
644
711
|
className: "rte-link-editor-input h-8 text-sm"
|
|
645
712
|
}
|
|
646
713
|
),
|
|
647
|
-
/* @__PURE__ */ (0,
|
|
714
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
648
715
|
Button,
|
|
649
716
|
{
|
|
650
717
|
size: "sm",
|
|
@@ -819,31 +886,31 @@ var SuperscriptControl = createControl({
|
|
|
819
886
|
});
|
|
820
887
|
|
|
821
888
|
// src/controls/rte-youtube-control.tsx
|
|
822
|
-
var
|
|
889
|
+
var import_react12 = require("react");
|
|
823
890
|
var import_core = require("@tiptap/core");
|
|
824
|
-
var
|
|
891
|
+
var import_react13 = require("@tiptap/react");
|
|
825
892
|
|
|
826
893
|
// src/ui/dialog.tsx
|
|
827
894
|
var React6 = require("react");
|
|
828
895
|
var import_dialog = require("@base-ui/react/dialog");
|
|
829
|
-
var
|
|
896
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
830
897
|
function Dialog({ ...props }) {
|
|
831
|
-
return /* @__PURE__ */ (0,
|
|
898
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dialog.Dialog.Root, { "data-slot": "dialog", ...props });
|
|
832
899
|
}
|
|
833
900
|
function DialogTrigger({ ...props }) {
|
|
834
|
-
return /* @__PURE__ */ (0,
|
|
901
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dialog.Dialog.Trigger, { "data-slot": "dialog-trigger", ...props });
|
|
835
902
|
}
|
|
836
903
|
function DialogPortal({ ...props }) {
|
|
837
|
-
return /* @__PURE__ */ (0,
|
|
904
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dialog.Dialog.Portal, { "data-slot": "dialog-portal", ...props });
|
|
838
905
|
}
|
|
839
906
|
function DialogClose({ ...props }) {
|
|
840
|
-
return /* @__PURE__ */ (0,
|
|
907
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dialog.Dialog.Close, { "data-slot": "dialog-close", ...props });
|
|
841
908
|
}
|
|
842
909
|
function DialogOverlay({
|
|
843
910
|
className,
|
|
844
911
|
...props
|
|
845
912
|
}) {
|
|
846
|
-
return /* @__PURE__ */ (0,
|
|
913
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
847
914
|
import_dialog.Dialog.Backdrop,
|
|
848
915
|
{
|
|
849
916
|
"data-slot": "dialog-overlay",
|
|
@@ -861,9 +928,9 @@ function DialogContent({
|
|
|
861
928
|
showCloseButton = true,
|
|
862
929
|
...props
|
|
863
930
|
}) {
|
|
864
|
-
return /* @__PURE__ */ (0,
|
|
865
|
-
/* @__PURE__ */ (0,
|
|
866
|
-
/* @__PURE__ */ (0,
|
|
931
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(DialogPortal, { children: [
|
|
932
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DialogOverlay, {}),
|
|
933
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
867
934
|
import_dialog.Dialog.Popup,
|
|
868
935
|
{
|
|
869
936
|
"data-slot": "dialog-content",
|
|
@@ -874,11 +941,11 @@ function DialogContent({
|
|
|
874
941
|
...props,
|
|
875
942
|
children: [
|
|
876
943
|
children,
|
|
877
|
-
showCloseButton && /* @__PURE__ */ (0,
|
|
944
|
+
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
878
945
|
import_dialog.Dialog.Close,
|
|
879
946
|
{
|
|
880
947
|
"data-slot": "dialog-close",
|
|
881
|
-
render: /* @__PURE__ */ (0,
|
|
948
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
882
949
|
Button,
|
|
883
950
|
{
|
|
884
951
|
variant: "ghost",
|
|
@@ -888,7 +955,7 @@ function DialogContent({
|
|
|
888
955
|
),
|
|
889
956
|
children: [
|
|
890
957
|
"X",
|
|
891
|
-
/* @__PURE__ */ (0,
|
|
958
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "sr-only", children: "Close" })
|
|
892
959
|
]
|
|
893
960
|
}
|
|
894
961
|
)
|
|
@@ -898,7 +965,7 @@ function DialogContent({
|
|
|
898
965
|
] });
|
|
899
966
|
}
|
|
900
967
|
function DialogHeader({ className, ...props }) {
|
|
901
|
-
return /* @__PURE__ */ (0,
|
|
968
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
902
969
|
"div",
|
|
903
970
|
{
|
|
904
971
|
"data-slot": "dialog-header",
|
|
@@ -913,7 +980,7 @@ function DialogFooter({
|
|
|
913
980
|
children,
|
|
914
981
|
...props
|
|
915
982
|
}) {
|
|
916
|
-
return /* @__PURE__ */ (0,
|
|
983
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
917
984
|
"div",
|
|
918
985
|
{
|
|
919
986
|
"data-slot": "dialog-footer",
|
|
@@ -924,13 +991,13 @@ function DialogFooter({
|
|
|
924
991
|
...props,
|
|
925
992
|
children: [
|
|
926
993
|
children,
|
|
927
|
-
showCloseButton && /* @__PURE__ */ (0,
|
|
994
|
+
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dialog.Dialog.Close, { render: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button, { variant: "outline" }), children: "Close" })
|
|
928
995
|
]
|
|
929
996
|
}
|
|
930
997
|
);
|
|
931
998
|
}
|
|
932
999
|
function DialogTitle({ className, ...props }) {
|
|
933
|
-
return /* @__PURE__ */ (0,
|
|
1000
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
934
1001
|
import_dialog.Dialog.Title,
|
|
935
1002
|
{
|
|
936
1003
|
"data-slot": "dialog-title",
|
|
@@ -943,7 +1010,7 @@ function DialogDescription({
|
|
|
943
1010
|
className,
|
|
944
1011
|
...props
|
|
945
1012
|
}) {
|
|
946
|
-
return /* @__PURE__ */ (0,
|
|
1013
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
947
1014
|
import_dialog.Dialog.Description,
|
|
948
1015
|
{
|
|
949
1016
|
"data-slot": "dialog-description",
|
|
@@ -957,9 +1024,9 @@ function DialogDescription({
|
|
|
957
1024
|
}
|
|
958
1025
|
|
|
959
1026
|
// src/extensions/resizable-node-view.tsx
|
|
960
|
-
var
|
|
961
|
-
var
|
|
962
|
-
var
|
|
1027
|
+
var import_react10 = require("react");
|
|
1028
|
+
var import_react11 = require("@tiptap/react");
|
|
1029
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
963
1030
|
function ResizableNodeView({
|
|
964
1031
|
node,
|
|
965
1032
|
selected,
|
|
@@ -971,15 +1038,15 @@ function ResizableNodeView({
|
|
|
971
1038
|
minWidth = 300,
|
|
972
1039
|
maxWidth = 1200
|
|
973
1040
|
}) {
|
|
974
|
-
const containerRef = (0,
|
|
975
|
-
const resizingRef = (0,
|
|
1041
|
+
const containerRef = (0, import_react10.useRef)(null);
|
|
1042
|
+
const resizingRef = (0, import_react10.useRef)(null);
|
|
976
1043
|
const width = node.attrs.width;
|
|
977
1044
|
const height = node.attrs.height;
|
|
978
1045
|
const align = node.attrs.align || "center";
|
|
979
|
-
const getEditorWidth = (0,
|
|
1046
|
+
const getEditorWidth = (0, import_react10.useCallback)(() => {
|
|
980
1047
|
return view?.dom?.parentElement?.offsetWidth ?? 0;
|
|
981
1048
|
}, [view]);
|
|
982
|
-
const handleMouseDown = (0,
|
|
1049
|
+
const handleMouseDown = (0, import_react10.useCallback)(
|
|
983
1050
|
(e, direction) => {
|
|
984
1051
|
e.preventDefault();
|
|
985
1052
|
e.stopPropagation();
|
|
@@ -1001,7 +1068,7 @@ function ResizableNodeView({
|
|
|
1001
1068
|
},
|
|
1002
1069
|
[width, height, getEditorWidth]
|
|
1003
1070
|
);
|
|
1004
|
-
const handleMouseMove = (0,
|
|
1071
|
+
const handleMouseMove = (0, import_react10.useCallback)(
|
|
1005
1072
|
(e) => {
|
|
1006
1073
|
const resize = resizingRef.current;
|
|
1007
1074
|
if (!resize) return;
|
|
@@ -1037,7 +1104,7 @@ function ResizableNodeView({
|
|
|
1037
1104
|
},
|
|
1038
1105
|
[lockAspect, aspectRatio, minWidth, maxWidth]
|
|
1039
1106
|
);
|
|
1040
|
-
const handleMouseUp = (0,
|
|
1107
|
+
const handleMouseUp = (0, import_react10.useCallback)(() => {
|
|
1041
1108
|
const resize = resizingRef.current;
|
|
1042
1109
|
if (!resize) return;
|
|
1043
1110
|
document.removeEventListener("mousemove", handleMouseMove);
|
|
@@ -1051,7 +1118,7 @@ function ResizableNodeView({
|
|
|
1051
1118
|
}
|
|
1052
1119
|
resizingRef.current = null;
|
|
1053
1120
|
}, [handleMouseMove, updateAttributes]);
|
|
1054
|
-
(0,
|
|
1121
|
+
(0, import_react10.useEffect)(() => {
|
|
1055
1122
|
return () => {
|
|
1056
1123
|
document.removeEventListener("mousemove", handleMouseMove);
|
|
1057
1124
|
document.removeEventListener("mouseup", handleMouseUp);
|
|
@@ -1059,13 +1126,13 @@ function ResizableNodeView({
|
|
|
1059
1126
|
document.body.style.userSelect = "";
|
|
1060
1127
|
};
|
|
1061
1128
|
}, [handleMouseMove]);
|
|
1062
|
-
return /* @__PURE__ */ (0,
|
|
1063
|
-
|
|
1129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1130
|
+
import_react11.NodeViewWrapper,
|
|
1064
1131
|
{
|
|
1065
1132
|
className: "rte-embed-wrapper",
|
|
1066
1133
|
"data-selected": selected || void 0,
|
|
1067
1134
|
"data-align": align,
|
|
1068
|
-
children: /* @__PURE__ */ (0,
|
|
1135
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1069
1136
|
"div",
|
|
1070
1137
|
{
|
|
1071
1138
|
ref: containerRef,
|
|
@@ -1078,22 +1145,22 @@ function ResizableNodeView({
|
|
|
1078
1145
|
},
|
|
1079
1146
|
children: [
|
|
1080
1147
|
children,
|
|
1081
|
-
selected && /* @__PURE__ */ (0,
|
|
1082
|
-
/* @__PURE__ */ (0,
|
|
1148
|
+
selected && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
1149
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1083
1150
|
"div",
|
|
1084
1151
|
{
|
|
1085
1152
|
className: "rte-resize-handle rte-resize-handle--right",
|
|
1086
1153
|
onMouseDown: (e) => handleMouseDown(e, "right")
|
|
1087
1154
|
}
|
|
1088
1155
|
),
|
|
1089
|
-
/* @__PURE__ */ (0,
|
|
1156
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1090
1157
|
"div",
|
|
1091
1158
|
{
|
|
1092
1159
|
className: "rte-resize-handle rte-resize-handle--bottom",
|
|
1093
1160
|
onMouseDown: (e) => handleMouseDown(e, "bottom")
|
|
1094
1161
|
}
|
|
1095
1162
|
),
|
|
1096
|
-
/* @__PURE__ */ (0,
|
|
1163
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1097
1164
|
"div",
|
|
1098
1165
|
{
|
|
1099
1166
|
className: "rte-resize-handle rte-resize-handle--corner",
|
|
@@ -1109,7 +1176,7 @@ function ResizableNodeView({
|
|
|
1109
1176
|
}
|
|
1110
1177
|
|
|
1111
1178
|
// src/controls/rte-youtube-control.tsx
|
|
1112
|
-
var
|
|
1179
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1113
1180
|
function getYouTubeId(url) {
|
|
1114
1181
|
const clean = url.trim();
|
|
1115
1182
|
const patterns = [
|
|
@@ -1130,7 +1197,7 @@ function getYouTubeId(url) {
|
|
|
1130
1197
|
function YouTubeNodeView(props) {
|
|
1131
1198
|
const { node } = props;
|
|
1132
1199
|
const videoId = getYouTubeId(node.attrs.src) || node.attrs.src;
|
|
1133
|
-
return /* @__PURE__ */ (0,
|
|
1200
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ResizableNodeView, { ...props, lockAspect: true, aspectRatio: 16 / 9, minWidth: 320, maxWidth: 1200, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1134
1201
|
"iframe",
|
|
1135
1202
|
{
|
|
1136
1203
|
src: `https://www.youtube-nocookie.com/embed/${videoId}`,
|
|
@@ -1194,7 +1261,7 @@ var YouTubeEmbed = import_core.Node.create({
|
|
|
1194
1261
|
];
|
|
1195
1262
|
},
|
|
1196
1263
|
addNodeView() {
|
|
1197
|
-
return (0,
|
|
1264
|
+
return (0, import_react13.ReactNodeViewRenderer)(YouTubeNodeView);
|
|
1198
1265
|
},
|
|
1199
1266
|
addCommands() {
|
|
1200
1267
|
return {
|
|
@@ -1218,32 +1285,32 @@ var YouTubeEmbed = import_core.Node.create({
|
|
|
1218
1285
|
});
|
|
1219
1286
|
function YouTubeEmbedControl({ className }) {
|
|
1220
1287
|
const { editor } = useRichTextEditorContext();
|
|
1221
|
-
const [open, setOpen] = (0,
|
|
1222
|
-
const [url, setUrl] = (0,
|
|
1223
|
-
const { active } = (0,
|
|
1288
|
+
const [open, setOpen] = (0, import_react12.useState)(false);
|
|
1289
|
+
const [url, setUrl] = (0, import_react12.useState)("");
|
|
1290
|
+
const { active } = (0, import_react13.useEditorState)({
|
|
1224
1291
|
editor: editor ?? null,
|
|
1225
1292
|
selector: (ctx) => ({
|
|
1226
1293
|
active: ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("youtube") : false
|
|
1227
1294
|
})
|
|
1228
1295
|
}) ?? { active: false };
|
|
1229
|
-
const handleInsert = (0,
|
|
1296
|
+
const handleInsert = (0, import_react12.useCallback)(() => {
|
|
1230
1297
|
if (url && editor) {
|
|
1231
1298
|
editor.chain().focus().setYouTubeEmbed(url).run();
|
|
1232
1299
|
setUrl("");
|
|
1233
1300
|
}
|
|
1234
1301
|
}, [url, editor]);
|
|
1235
|
-
return /* @__PURE__ */ (0,
|
|
1236
|
-
/* @__PURE__ */ (0,
|
|
1302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Dialog, { open, onOpenChange: setOpen, children: [
|
|
1303
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1237
1304
|
DialogTrigger,
|
|
1238
1305
|
{
|
|
1239
|
-
render: /* @__PURE__ */ (0,
|
|
1306
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1240
1307
|
RichTextEditorControl,
|
|
1241
1308
|
{
|
|
1242
1309
|
active,
|
|
1243
1310
|
className,
|
|
1244
1311
|
title: "Embed YouTube video",
|
|
1245
1312
|
"aria-label": "Embed YouTube video",
|
|
1246
|
-
children: /* @__PURE__ */ (0,
|
|
1313
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1247
1314
|
"svg",
|
|
1248
1315
|
{
|
|
1249
1316
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1255,8 +1322,8 @@ function YouTubeEmbedControl({ className }) {
|
|
|
1255
1322
|
"stroke-linejoin": "round",
|
|
1256
1323
|
className: "rte-editor-icon",
|
|
1257
1324
|
children: [
|
|
1258
|
-
/* @__PURE__ */ (0,
|
|
1259
|
-
/* @__PURE__ */ (0,
|
|
1325
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("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" }),
|
|
1326
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9.5 15.5V8.5l6.2 3.5z" })
|
|
1260
1327
|
]
|
|
1261
1328
|
}
|
|
1262
1329
|
)
|
|
@@ -1264,12 +1331,12 @@ function YouTubeEmbedControl({ className }) {
|
|
|
1264
1331
|
)
|
|
1265
1332
|
}
|
|
1266
1333
|
),
|
|
1267
|
-
/* @__PURE__ */ (0,
|
|
1268
|
-
/* @__PURE__ */ (0,
|
|
1269
|
-
/* @__PURE__ */ (0,
|
|
1270
|
-
/* @__PURE__ */ (0,
|
|
1334
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(DialogContent, { showCloseButton: false, children: [
|
|
1335
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(DialogHeader, { children: [
|
|
1336
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DialogTitle, { children: "Embed YouTube video" }),
|
|
1337
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DialogDescription, { children: "Paste a YouTube video URL or ID." })
|
|
1271
1338
|
] }),
|
|
1272
|
-
/* @__PURE__ */ (0,
|
|
1339
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1273
1340
|
Input,
|
|
1274
1341
|
{
|
|
1275
1342
|
value: url,
|
|
@@ -1283,9 +1350,9 @@ function YouTubeEmbedControl({ className }) {
|
|
|
1283
1350
|
}
|
|
1284
1351
|
}
|
|
1285
1352
|
),
|
|
1286
|
-
/* @__PURE__ */ (0,
|
|
1287
|
-
/* @__PURE__ */ (0,
|
|
1288
|
-
/* @__PURE__ */ (0,
|
|
1353
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(DialogFooter, { children: [
|
|
1354
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DialogClose, { children: "Cancel" }),
|
|
1355
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1289
1356
|
DialogClose,
|
|
1290
1357
|
{
|
|
1291
1358
|
disabled: !url,
|
|
@@ -1300,19 +1367,19 @@ function YouTubeEmbedControl({ className }) {
|
|
|
1300
1367
|
}
|
|
1301
1368
|
|
|
1302
1369
|
// src/controls/rte-twitter-control.tsx
|
|
1303
|
-
var
|
|
1370
|
+
var import_react14 = require("react");
|
|
1304
1371
|
var import_core2 = require("@tiptap/core");
|
|
1305
|
-
var
|
|
1306
|
-
var
|
|
1372
|
+
var import_react15 = require("@tiptap/react");
|
|
1373
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1307
1374
|
var WIDGET_SCRIPT_URL = "https://platform.twitter.com/widgets.js";
|
|
1308
1375
|
function TwitterNodeView(props) {
|
|
1309
1376
|
const { node } = props;
|
|
1310
|
-
const containerRef = (0,
|
|
1311
|
-
const [loading, setLoading] = (0,
|
|
1377
|
+
const containerRef = (0, import_react14.useRef)(null);
|
|
1378
|
+
const [loading, setLoading] = (0, import_react14.useState)(true);
|
|
1312
1379
|
const tweetId = node.attrs.tweetId;
|
|
1313
1380
|
const w = node.attrs.width;
|
|
1314
1381
|
const h = node.attrs.height;
|
|
1315
|
-
const renderTweet = (0,
|
|
1382
|
+
const renderTweet = (0, import_react14.useCallback)(() => {
|
|
1316
1383
|
if (!containerRef.current || !tweetId) return;
|
|
1317
1384
|
containerRef.current.innerHTML = "";
|
|
1318
1385
|
setLoading(true);
|
|
@@ -1323,7 +1390,7 @@ function TwitterNodeView(props) {
|
|
|
1323
1390
|
});
|
|
1324
1391
|
}
|
|
1325
1392
|
}, [tweetId]);
|
|
1326
|
-
(0,
|
|
1393
|
+
(0, import_react14.useEffect)(() => {
|
|
1327
1394
|
if (!containerRef.current || !tweetId) return;
|
|
1328
1395
|
if (window.twttr?.widgets) {
|
|
1329
1396
|
renderTweet();
|
|
@@ -1335,9 +1402,9 @@ function TwitterNodeView(props) {
|
|
|
1335
1402
|
document.body.appendChild(script);
|
|
1336
1403
|
}
|
|
1337
1404
|
}, [tweetId, w, h, renderTweet]);
|
|
1338
|
-
return /* @__PURE__ */ (0,
|
|
1339
|
-
loading && /* @__PURE__ */ (0,
|
|
1340
|
-
/* @__PURE__ */ (0,
|
|
1405
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(ResizableNodeView, { ...props, lockAspect: false, minWidth: 300, maxWidth: 1200, children: [
|
|
1406
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "rte-embed-loading", children: "Loading tweet..." }),
|
|
1407
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { ref: containerRef })
|
|
1341
1408
|
] });
|
|
1342
1409
|
}
|
|
1343
1410
|
var TwitterEmbed = import_core2.Node.create({
|
|
@@ -1393,7 +1460,7 @@ var TwitterEmbed = import_core2.Node.create({
|
|
|
1393
1460
|
];
|
|
1394
1461
|
},
|
|
1395
1462
|
addNodeView() {
|
|
1396
|
-
return (0,
|
|
1463
|
+
return (0, import_react15.ReactNodeViewRenderer)(TwitterNodeView);
|
|
1397
1464
|
},
|
|
1398
1465
|
addCommands() {
|
|
1399
1466
|
return {
|
|
@@ -1422,15 +1489,15 @@ function extractTweetId(input) {
|
|
|
1422
1489
|
}
|
|
1423
1490
|
function TwitterEmbedControl({ className }) {
|
|
1424
1491
|
const { editor } = useRichTextEditorContext();
|
|
1425
|
-
const [open, setOpen] = (0,
|
|
1426
|
-
const [url, setUrl] = (0,
|
|
1427
|
-
const { active } = (0,
|
|
1492
|
+
const [open, setOpen] = (0, import_react14.useState)(false);
|
|
1493
|
+
const [url, setUrl] = (0, import_react14.useState)("");
|
|
1494
|
+
const { active } = (0, import_react15.useEditorState)({
|
|
1428
1495
|
editor: editor ?? null,
|
|
1429
1496
|
selector: (ctx) => ({
|
|
1430
1497
|
active: ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("twitter") : false
|
|
1431
1498
|
})
|
|
1432
1499
|
}) ?? { active: false };
|
|
1433
|
-
const handleInsert = (0,
|
|
1500
|
+
const handleInsert = (0, import_react14.useCallback)(() => {
|
|
1434
1501
|
if (url && editor) {
|
|
1435
1502
|
const tweetId = extractTweetId(url);
|
|
1436
1503
|
if (tweetId) {
|
|
@@ -1439,37 +1506,37 @@ function TwitterEmbedControl({ className }) {
|
|
|
1439
1506
|
}
|
|
1440
1507
|
}
|
|
1441
1508
|
}, [url, editor]);
|
|
1442
|
-
return /* @__PURE__ */ (0,
|
|
1443
|
-
/* @__PURE__ */ (0,
|
|
1509
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Dialog, { open, onOpenChange: setOpen, children: [
|
|
1510
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1444
1511
|
DialogTrigger,
|
|
1445
1512
|
{
|
|
1446
|
-
render: /* @__PURE__ */ (0,
|
|
1513
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1447
1514
|
RichTextEditorControl,
|
|
1448
1515
|
{
|
|
1449
1516
|
active,
|
|
1450
1517
|
className,
|
|
1451
1518
|
title: "Embed Tweet",
|
|
1452
1519
|
"aria-label": "Embed Tweet",
|
|
1453
|
-
children: /* @__PURE__ */ (0,
|
|
1520
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1454
1521
|
"svg",
|
|
1455
1522
|
{
|
|
1456
1523
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1457
1524
|
viewBox: "0 0 24 24",
|
|
1458
1525
|
fill: "currentColor",
|
|
1459
1526
|
className: "rte-editor-icon",
|
|
1460
|
-
children: /* @__PURE__ */ (0,
|
|
1527
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("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" })
|
|
1461
1528
|
}
|
|
1462
1529
|
)
|
|
1463
1530
|
}
|
|
1464
1531
|
)
|
|
1465
1532
|
}
|
|
1466
1533
|
),
|
|
1467
|
-
/* @__PURE__ */ (0,
|
|
1468
|
-
/* @__PURE__ */ (0,
|
|
1469
|
-
/* @__PURE__ */ (0,
|
|
1470
|
-
/* @__PURE__ */ (0,
|
|
1534
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(DialogContent, { children: [
|
|
1535
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(DialogHeader, { children: [
|
|
1536
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DialogTitle, { children: "Embed Tweet" }),
|
|
1537
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DialogDescription, { children: "Paste a tweet URL or ID." })
|
|
1471
1538
|
] }),
|
|
1472
|
-
/* @__PURE__ */ (0,
|
|
1539
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1473
1540
|
Input,
|
|
1474
1541
|
{
|
|
1475
1542
|
value: url,
|
|
@@ -1483,9 +1550,9 @@ function TwitterEmbedControl({ className }) {
|
|
|
1483
1550
|
}
|
|
1484
1551
|
}
|
|
1485
1552
|
),
|
|
1486
|
-
/* @__PURE__ */ (0,
|
|
1487
|
-
/* @__PURE__ */ (0,
|
|
1488
|
-
/* @__PURE__ */ (0,
|
|
1553
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(DialogFooter, { children: [
|
|
1554
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DialogClose, { children: "Cancel" }),
|
|
1555
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1489
1556
|
DialogClose,
|
|
1490
1557
|
{
|
|
1491
1558
|
disabled: !url,
|
|
@@ -1500,7 +1567,7 @@ function TwitterEmbedControl({ className }) {
|
|
|
1500
1567
|
}
|
|
1501
1568
|
|
|
1502
1569
|
// src/rte-text-editor.tsx
|
|
1503
|
-
var
|
|
1570
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1504
1571
|
function RichTextEditorRoot({
|
|
1505
1572
|
editor,
|
|
1506
1573
|
children,
|
|
@@ -1510,20 +1577,20 @@ function RichTextEditorRoot({
|
|
|
1510
1577
|
variant = "default",
|
|
1511
1578
|
editable = true
|
|
1512
1579
|
}) {
|
|
1513
|
-
const mergedLabels = (0,
|
|
1580
|
+
const mergedLabels = (0, import_react16.useMemo)(
|
|
1514
1581
|
() => ({ ...DEFAULT_LABELS, ...labels }),
|
|
1515
1582
|
[labels]
|
|
1516
1583
|
);
|
|
1517
|
-
const mergedIcons = (0,
|
|
1584
|
+
const mergedIcons = (0, import_react16.useMemo)(
|
|
1518
1585
|
() => ({ ...DEFAULT_ICONS, ...icons }),
|
|
1519
1586
|
[icons]
|
|
1520
1587
|
);
|
|
1521
|
-
(0,
|
|
1588
|
+
(0, import_react16.useEffect)(() => {
|
|
1522
1589
|
if (editor && editor.isEditable !== editable) {
|
|
1523
1590
|
editor.setEditable(editable);
|
|
1524
1591
|
}
|
|
1525
1592
|
}, [editor, editable]);
|
|
1526
|
-
return /* @__PURE__ */ (0,
|
|
1593
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(RichTextEditorContext.Provider, { value: { editor, labels: mergedLabels, icons: mergedIcons, variant, editable }, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1527
1594
|
"div",
|
|
1528
1595
|
{
|
|
1529
1596
|
className: cn(
|
|
@@ -1538,6 +1605,7 @@ function RichTextEditorRoot({
|
|
|
1538
1605
|
}
|
|
1539
1606
|
var RichTextEditor = Object.assign(RichTextEditorRoot, {
|
|
1540
1607
|
Toolbar,
|
|
1608
|
+
Footer,
|
|
1541
1609
|
ControlsGroup,
|
|
1542
1610
|
Content,
|
|
1543
1611
|
Control: RichTextEditorControl,
|