@kopexa/tiptap 17.2.0 → 17.2.1
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/{chunk-E5NW3MJZ.mjs → chunk-3ZPLSXTZ.mjs} +3 -3
- package/dist/{chunk-NEHW62L7.mjs → chunk-6552DQWB.mjs} +2 -2
- package/dist/{chunk-5GFFTVMZ.mjs → chunk-DSBJFMHK.mjs} +4 -28
- package/dist/chunk-EAAQE5ZV.mjs +283 -0
- package/dist/chunk-HTJ2RXOG.mjs +32 -0
- package/dist/{chunk-LMCQMSW2.mjs → chunk-KYLBKQ2E.mjs} +12 -154
- package/dist/chunk-N3JE67CS.mjs +81 -0
- package/dist/{chunk-UU6JK5HX.mjs → chunk-SCYH6NOA.mjs} +19 -12
- package/dist/{chunk-7SRL3P4B.mjs → chunk-VFCZOVWU.mjs} +7 -7
- package/dist/chunk-Z365KVQY.mjs +34 -0
- package/dist/extensions/image/image-view.d.mts +3 -3
- package/dist/extensions/image/image-view.d.ts +3 -3
- package/dist/extensions/image/image-view.js +13 -181
- package/dist/extensions/image/image-view.mjs +2 -2
- package/dist/extensions/image/index.d.mts +12 -49
- package/dist/extensions/image/index.d.ts +12 -49
- package/dist/extensions/image/index.js +18 -231
- package/dist/extensions/image/index.mjs +3 -3
- package/dist/extensions/image/messages.d.mts +2 -30
- package/dist/extensions/image/messages.d.ts +2 -30
- package/dist/extensions/image/messages.js +4 -32
- package/dist/extensions/image/messages.mjs +1 -1
- package/dist/extensions/image-upload/image-upload-view.d.mts +12 -0
- package/dist/extensions/image-upload/image-upload-view.d.ts +12 -0
- package/dist/extensions/image-upload/image-upload-view.js +338 -0
- package/dist/extensions/image-upload/image-upload-view.mjs +12 -0
- package/dist/extensions/image-upload/index.d.mts +46 -0
- package/dist/extensions/image-upload/index.d.ts +46 -0
- package/dist/extensions/image-upload/index.js +414 -0
- package/dist/extensions/image-upload/index.mjs +16 -0
- package/dist/extensions/image-upload/messages.d.mts +32 -0
- package/dist/extensions/image-upload/messages.d.ts +32 -0
- package/dist/extensions/image-upload/messages.js +61 -0
- package/dist/extensions/image-upload/messages.mjs +7 -0
- package/dist/extensions/math/index.mjs +1 -1
- package/dist/hooks/use-create-editor.js +549 -386
- package/dist/hooks/use-create-editor.mjs +13 -10
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +942 -777
- package/dist/index.mjs +39 -33
- package/dist/presets/basic/editor-header.mjs +14 -14
- package/dist/presets/basic/index.js +940 -777
- package/dist/presets/basic/index.mjs +32 -29
- package/dist/ui/slash-dropdown-menu/index.js +2 -2
- package/dist/ui/slash-dropdown-menu/index.mjs +4 -4
- package/dist/ui/slash-dropdown-menu/slash-dropdown-menu.js +2 -2
- package/dist/ui/slash-dropdown-menu/slash-dropdown-menu.mjs +2 -2
- package/dist/ui/slash-dropdown-menu/use-slash-dropdown-menu.js +2 -2
- package/dist/ui/slash-dropdown-menu/use-slash-dropdown-menu.mjs +1 -1
- package/package.json +25 -24
- package/dist/chunk-WAAH3NLG.mjs +0 -77
- package/dist/{chunk-QAE2D4KV.mjs → chunk-FDPXD6VC.mjs} +11 -11
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
Editor: () => BasicEditor,
|
|
36
36
|
EditorFileProvider: () => EditorFileProvider,
|
|
37
37
|
ImageNode: () => ImageNode,
|
|
38
|
+
ImageUploadNode: () => ImageUploadNode,
|
|
38
39
|
InlineMath: () => InlineMath,
|
|
39
40
|
MathBlock: () => MathBlock,
|
|
40
41
|
TocNode: () => TocNode,
|
|
@@ -461,7 +462,7 @@ var CalloutNode = import_core.Node.create({
|
|
|
461
462
|
});
|
|
462
463
|
|
|
463
464
|
// src/extensions/image/index.ts
|
|
464
|
-
var
|
|
465
|
+
var import_extension_image = require("@tiptap/extension-image");
|
|
465
466
|
var import_react8 = require("@tiptap/react");
|
|
466
467
|
|
|
467
468
|
// src/extensions/image/image-view.tsx
|
|
@@ -479,6 +480,10 @@ var messages2 = (0, import_react_intl3.defineMessages)({
|
|
|
479
480
|
id: "editor.image.loading",
|
|
480
481
|
defaultMessage: "Loading image..."
|
|
481
482
|
},
|
|
483
|
+
uploading: {
|
|
484
|
+
id: "editor.image.uploading",
|
|
485
|
+
defaultMessage: "Uploading..."
|
|
486
|
+
},
|
|
482
487
|
error: {
|
|
483
488
|
id: "editor.image.error",
|
|
484
489
|
defaultMessage: "Failed to load image"
|
|
@@ -487,38 +492,6 @@ var messages2 = (0, import_react_intl3.defineMessages)({
|
|
|
487
492
|
id: "editor.image.upload_error",
|
|
488
493
|
defaultMessage: "Failed to upload image"
|
|
489
494
|
},
|
|
490
|
-
uploading: {
|
|
491
|
-
id: "editor.image.uploading",
|
|
492
|
-
defaultMessage: "Uploading..."
|
|
493
|
-
},
|
|
494
|
-
upload_placeholder: {
|
|
495
|
-
id: "editor.image.upload_placeholder",
|
|
496
|
-
defaultMessage: "Click to upload or drag & drop"
|
|
497
|
-
},
|
|
498
|
-
upload_hint: {
|
|
499
|
-
id: "editor.image.upload_hint",
|
|
500
|
-
defaultMessage: "PNG, JPG, GIF, WebP, SVG"
|
|
501
|
-
},
|
|
502
|
-
alt_text: {
|
|
503
|
-
id: "editor.image.alt_text",
|
|
504
|
-
defaultMessage: "Alt text"
|
|
505
|
-
},
|
|
506
|
-
alt_placeholder: {
|
|
507
|
-
id: "editor.image.alt_placeholder",
|
|
508
|
-
defaultMessage: "Describe the image..."
|
|
509
|
-
},
|
|
510
|
-
files_not_supported: {
|
|
511
|
-
id: "editor.image.files_not_supported",
|
|
512
|
-
defaultMessage: "File upload is not configured"
|
|
513
|
-
},
|
|
514
|
-
file_too_large: {
|
|
515
|
-
id: "editor.image.file_too_large",
|
|
516
|
-
defaultMessage: "File is too large (max {maxSize})"
|
|
517
|
-
},
|
|
518
|
-
invalid_type: {
|
|
519
|
-
id: "editor.image.invalid_type",
|
|
520
|
-
defaultMessage: "Invalid file type"
|
|
521
|
-
},
|
|
522
495
|
retry: {
|
|
523
496
|
id: "editor.image.retry",
|
|
524
497
|
defaultMessage: "Retry"
|
|
@@ -535,7 +508,7 @@ function ImageNodeView({ editor, node, getPos }) {
|
|
|
535
508
|
var _a;
|
|
536
509
|
const intl = (0, import_react_intl4.useIntl)();
|
|
537
510
|
const fileHandler = useEditorFile();
|
|
538
|
-
const
|
|
511
|
+
const { src, alt, title, uploadState, uploadProgress } = node.attrs;
|
|
539
512
|
const isEditable = (0, import_react6.useEditorState)({
|
|
540
513
|
editor,
|
|
541
514
|
selector: ({ editor: e }) => {
|
|
@@ -543,7 +516,6 @@ function ImageNodeView({ editor, node, getPos }) {
|
|
|
543
516
|
return (_a2 = e == null ? void 0 : e.isEditable) != null ? _a2 : false;
|
|
544
517
|
}
|
|
545
518
|
});
|
|
546
|
-
const { src, alt, title, uploadState, uploadProgress } = attrs;
|
|
547
519
|
const [resolvedUrl, setResolvedUrl] = (0, import_react7.useState)(null);
|
|
548
520
|
const [resolveState, setResolveState] = (0, import_react7.useState)("idle");
|
|
549
521
|
const needsResolve = (_a = fileHandler == null ? void 0 : fileHandler.isReference(src)) != null ? _a : false;
|
|
@@ -555,7 +527,8 @@ function ImageNodeView({ editor, node, getPos }) {
|
|
|
555
527
|
return;
|
|
556
528
|
}
|
|
557
529
|
if (!fileHandler) {
|
|
558
|
-
|
|
530
|
+
setResolvedUrl(src);
|
|
531
|
+
setResolveState("resolved");
|
|
559
532
|
return;
|
|
560
533
|
}
|
|
561
534
|
setResolveState("loading");
|
|
@@ -581,156 +554,16 @@ function ImageNodeView({ editor, node, getPos }) {
|
|
|
581
554
|
to: pos + node.nodeSize
|
|
582
555
|
});
|
|
583
556
|
}, [editor, getPos, node.nodeSize]);
|
|
584
|
-
const fileInputRef = (0, import_react7.useRef)(null);
|
|
585
|
-
const handleFileSelect = (0, import_react7.useCallback)(
|
|
586
|
-
async (file) => {
|
|
587
|
-
if (!fileHandler) return;
|
|
588
|
-
const pos = getPos();
|
|
589
|
-
if (pos === void 0) return;
|
|
590
|
-
editor.view.dispatch(
|
|
591
|
-
editor.state.tr.setNodeMarkup(pos, void 0, {
|
|
592
|
-
...attrs,
|
|
593
|
-
uploadState: "uploading",
|
|
594
|
-
uploadProgress: 0
|
|
595
|
-
})
|
|
596
|
-
);
|
|
597
|
-
try {
|
|
598
|
-
const ref = await fileHandler.upload(file, (percent) => {
|
|
599
|
-
const currentPos = getPos();
|
|
600
|
-
if (currentPos === void 0) return;
|
|
601
|
-
editor.view.dispatch(
|
|
602
|
-
editor.state.tr.setNodeMarkup(currentPos, void 0, {
|
|
603
|
-
...attrs,
|
|
604
|
-
uploadState: "uploading",
|
|
605
|
-
uploadProgress: percent
|
|
606
|
-
})
|
|
607
|
-
);
|
|
608
|
-
});
|
|
609
|
-
const finalPos = getPos();
|
|
610
|
-
if (finalPos === void 0) return;
|
|
611
|
-
editor.view.dispatch(
|
|
612
|
-
editor.state.tr.setNodeMarkup(finalPos, void 0, {
|
|
613
|
-
src: ref,
|
|
614
|
-
uploadState: null,
|
|
615
|
-
uploadProgress: null
|
|
616
|
-
})
|
|
617
|
-
);
|
|
618
|
-
} catch {
|
|
619
|
-
const errorPos = getPos();
|
|
620
|
-
if (errorPos === void 0) return;
|
|
621
|
-
editor.view.dispatch(
|
|
622
|
-
editor.state.tr.setNodeMarkup(errorPos, void 0, {
|
|
623
|
-
...attrs,
|
|
624
|
-
uploadState: "error",
|
|
625
|
-
uploadProgress: null
|
|
626
|
-
})
|
|
627
|
-
);
|
|
628
|
-
}
|
|
629
|
-
},
|
|
630
|
-
[fileHandler, editor, getPos, attrs]
|
|
631
|
-
);
|
|
632
|
-
const handleInputChange = (0, import_react7.useCallback)(
|
|
633
|
-
(e) => {
|
|
634
|
-
var _a2;
|
|
635
|
-
const file = (_a2 = e.target.files) == null ? void 0 : _a2[0];
|
|
636
|
-
if (file) {
|
|
637
|
-
handleFileSelect(file);
|
|
638
|
-
}
|
|
639
|
-
},
|
|
640
|
-
[handleFileSelect]
|
|
641
|
-
);
|
|
642
|
-
const handleDrop = (0, import_react7.useCallback)(
|
|
643
|
-
(e) => {
|
|
644
|
-
e.preventDefault();
|
|
645
|
-
e.stopPropagation();
|
|
646
|
-
const file = e.dataTransfer.files[0];
|
|
647
|
-
if (file == null ? void 0 : file.type.startsWith("image/")) {
|
|
648
|
-
handleFileSelect(file);
|
|
649
|
-
}
|
|
650
|
-
},
|
|
651
|
-
[handleFileSelect]
|
|
652
|
-
);
|
|
653
|
-
const handleDragOver = (0, import_react7.useCallback)((e) => {
|
|
654
|
-
e.preventDefault();
|
|
655
|
-
e.stopPropagation();
|
|
656
|
-
}, []);
|
|
657
|
-
const styles = (0, import_react7.useMemo)(() => (0, import_theme2.imagePlaceholder)({ size: "md" }), []);
|
|
658
557
|
const errorStyles = (0, import_react7.useMemo)(
|
|
659
558
|
() => (0, import_theme2.imagePlaceholder)({ size: "md", variant: "error" }),
|
|
660
559
|
[]
|
|
661
560
|
);
|
|
662
|
-
const
|
|
561
|
+
const loadingStyles = (0, import_react7.useMemo)(
|
|
663
562
|
() => (0, import_theme2.imagePlaceholder)({ size: "md", variant: "uploading" }),
|
|
664
563
|
[]
|
|
665
564
|
);
|
|
666
|
-
const disabledStyles = (0, import_react7.useMemo)(
|
|
667
|
-
() => (0, import_theme2.imagePlaceholder)({ size: "md", variant: "disabled" }),
|
|
668
|
-
[]
|
|
669
|
-
);
|
|
670
|
-
const isEmpty = !src;
|
|
671
|
-
if (isEmpty && !uploadState) {
|
|
672
|
-
if (!fileHandler) {
|
|
673
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react6.NodeViewWrapper, { className: "my-4", "data-type": "image", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: disabledStyles.root(), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: disabledStyles.content(), children: [
|
|
674
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons3.ImageIcon, { className: disabledStyles.icon() }),
|
|
675
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: disabledStyles.text(), children: intl.formatMessage(messages2.files_not_supported) }),
|
|
676
|
-
isEditable && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
677
|
-
import_button2.IconButton,
|
|
678
|
-
{
|
|
679
|
-
size: "sm",
|
|
680
|
-
variant: "ghost",
|
|
681
|
-
onClick: handleRemove,
|
|
682
|
-
"aria-label": intl.formatMessage(messages2.remove),
|
|
683
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons3.TrashIcon, { className: "size-4" })
|
|
684
|
-
}
|
|
685
|
-
)
|
|
686
|
-
] }) }) });
|
|
687
|
-
}
|
|
688
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react6.NodeViewWrapper, { className: "my-4", "data-type": "image", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
689
|
-
"div",
|
|
690
|
-
{
|
|
691
|
-
className: styles.root(),
|
|
692
|
-
onClick: () => {
|
|
693
|
-
var _a2;
|
|
694
|
-
return (_a2 = fileInputRef.current) == null ? void 0 : _a2.click();
|
|
695
|
-
},
|
|
696
|
-
onDrop: handleDrop,
|
|
697
|
-
onDragOver: handleDragOver,
|
|
698
|
-
children: [
|
|
699
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: styles.content(), children: [
|
|
700
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons3.UploadIcon, { className: styles.icon() }),
|
|
701
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: styles.text(), children: intl.formatMessage(messages2.upload_placeholder) }),
|
|
702
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: styles.hint(), children: intl.formatMessage(messages2.upload_hint) })
|
|
703
|
-
] }),
|
|
704
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
705
|
-
"input",
|
|
706
|
-
{
|
|
707
|
-
ref: fileInputRef,
|
|
708
|
-
type: "file",
|
|
709
|
-
accept: "image/*",
|
|
710
|
-
className: "hidden",
|
|
711
|
-
onChange: handleInputChange
|
|
712
|
-
}
|
|
713
|
-
),
|
|
714
|
-
isEditable && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
715
|
-
import_button2.IconButton,
|
|
716
|
-
{
|
|
717
|
-
size: "sm",
|
|
718
|
-
variant: "ghost",
|
|
719
|
-
className: styles.removeButton(),
|
|
720
|
-
onClick: (e) => {
|
|
721
|
-
e.stopPropagation();
|
|
722
|
-
handleRemove();
|
|
723
|
-
},
|
|
724
|
-
"aria-label": intl.formatMessage(messages2.remove),
|
|
725
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons3.TrashIcon, { className: "size-3.5" })
|
|
726
|
-
}
|
|
727
|
-
)
|
|
728
|
-
]
|
|
729
|
-
}
|
|
730
|
-
) });
|
|
731
|
-
}
|
|
732
565
|
if (uploadState === "uploading") {
|
|
733
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react6.NodeViewWrapper, { className: "my-4", "data-type": "image", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className:
|
|
566
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react6.NodeViewWrapper, { className: "my-4", "data-type": "image", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: loadingStyles.root(), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: loadingStyles.content(), children: [
|
|
734
567
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "relative size-12", children: [
|
|
735
568
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
736
569
|
"svg",
|
|
@@ -772,14 +605,14 @@ function ImageNodeView({ editor, node, getPos }) {
|
|
|
772
605
|
"%"
|
|
773
606
|
] })
|
|
774
607
|
] }),
|
|
775
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className:
|
|
608
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: loadingStyles.text(), children: intl.formatMessage(messages2.uploading) })
|
|
776
609
|
] }) }) });
|
|
777
610
|
}
|
|
778
611
|
if (uploadState === "error") {
|
|
779
612
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react6.NodeViewWrapper, { className: "my-4", "data-type": "image", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: errorStyles.root(), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: errorStyles.content(), children: [
|
|
780
613
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons3.AlertCircleIcon, { className: errorStyles.icon() }),
|
|
781
614
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: errorStyles.text(), children: intl.formatMessage(messages2.upload_error) }),
|
|
782
|
-
isEditable && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
615
|
+
isEditable && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
783
616
|
import_button2.IconButton,
|
|
784
617
|
{
|
|
785
618
|
size: "sm",
|
|
@@ -788,11 +621,11 @@ function ImageNodeView({ editor, node, getPos }) {
|
|
|
788
621
|
"aria-label": intl.formatMessage(messages2.remove),
|
|
789
622
|
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons3.TrashIcon, { className: "size-4" })
|
|
790
623
|
}
|
|
791
|
-
)
|
|
624
|
+
)
|
|
792
625
|
] }) }) });
|
|
793
626
|
}
|
|
794
627
|
if (resolveState === "loading") {
|
|
795
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react6.NodeViewWrapper, { className: "my-4", "data-type": "image", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `${
|
|
628
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react6.NodeViewWrapper, { className: "my-4", "data-type": "image", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `${loadingStyles.root()} animate-pulse`, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: loadingStyles.text(), children: intl.formatMessage(messages2.loading) }) }) });
|
|
796
629
|
}
|
|
797
630
|
if (resolveState === "error") {
|
|
798
631
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react6.NodeViewWrapper, { className: "my-4", "data-type": "image", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: errorStyles.root(), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: errorStyles.content(), children: [
|
|
@@ -846,35 +679,346 @@ function ImageNodeView({ editor, node, getPos }) {
|
|
|
846
679
|
] });
|
|
847
680
|
}
|
|
848
681
|
|
|
849
|
-
// src/extensions/image/index.ts
|
|
850
|
-
var ImageNode =
|
|
851
|
-
|
|
682
|
+
// src/extensions/image/index.ts
|
|
683
|
+
var ImageNode = import_extension_image.Image.extend({
|
|
684
|
+
addAttributes() {
|
|
685
|
+
var _a;
|
|
686
|
+
return {
|
|
687
|
+
...(_a = this.parent) == null ? void 0 : _a.call(this),
|
|
688
|
+
// Upload state for drag & drop / paste uploads
|
|
689
|
+
uploadState: {
|
|
690
|
+
default: null,
|
|
691
|
+
rendered: false
|
|
692
|
+
},
|
|
693
|
+
uploadProgress: {
|
|
694
|
+
default: null,
|
|
695
|
+
rendered: false
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
},
|
|
699
|
+
addNodeView() {
|
|
700
|
+
return (0, import_react8.ReactNodeViewRenderer)(ImageNodeView);
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
// src/extensions/image-upload/index.ts
|
|
705
|
+
var import_core2 = require("@tiptap/core");
|
|
706
|
+
var import_react11 = require("@tiptap/react");
|
|
707
|
+
|
|
708
|
+
// src/extensions/image-upload/image-upload-view.tsx
|
|
709
|
+
var import_button3 = require("@kopexa/button");
|
|
710
|
+
var import_icons4 = require("@kopexa/icons");
|
|
711
|
+
var import_theme3 = require("@kopexa/theme");
|
|
712
|
+
var import_react9 = require("@tiptap/react");
|
|
713
|
+
var import_react10 = require("react");
|
|
714
|
+
var import_react_intl6 = require("react-intl");
|
|
715
|
+
|
|
716
|
+
// src/extensions/image-upload/messages.ts
|
|
717
|
+
var import_react_intl5 = require("react-intl");
|
|
718
|
+
var messages3 = (0, import_react_intl5.defineMessages)({
|
|
719
|
+
upload_error: {
|
|
720
|
+
id: "editor.image.upload_error",
|
|
721
|
+
defaultMessage: "Failed to upload image"
|
|
722
|
+
},
|
|
723
|
+
uploading: {
|
|
724
|
+
id: "editor.image.uploading",
|
|
725
|
+
defaultMessage: "Uploading..."
|
|
726
|
+
},
|
|
727
|
+
upload_placeholder: {
|
|
728
|
+
id: "editor.image.upload_placeholder",
|
|
729
|
+
defaultMessage: "Click to upload or drag & drop"
|
|
730
|
+
},
|
|
731
|
+
upload_hint: {
|
|
732
|
+
id: "editor.image.upload_hint",
|
|
733
|
+
defaultMessage: "PNG, JPG, GIF, WebP, SVG"
|
|
734
|
+
},
|
|
735
|
+
click_to_retry: {
|
|
736
|
+
id: "editor.image.click_to_retry",
|
|
737
|
+
defaultMessage: "Click to try again"
|
|
738
|
+
},
|
|
739
|
+
files_not_supported: {
|
|
740
|
+
id: "editor.image.files_not_supported",
|
|
741
|
+
defaultMessage: "File upload is not configured"
|
|
742
|
+
},
|
|
743
|
+
remove: {
|
|
744
|
+
id: "editor.image.remove",
|
|
745
|
+
defaultMessage: "Remove"
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
|
|
749
|
+
// src/extensions/image-upload/image-upload-view.tsx
|
|
750
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
751
|
+
function ImageUploadNodeView({ editor, node, getPos }) {
|
|
752
|
+
const intl = (0, import_react_intl6.useIntl)();
|
|
753
|
+
const fileHandler = useEditorFile();
|
|
754
|
+
const isEditable = (0, import_react9.useEditorState)({
|
|
755
|
+
editor,
|
|
756
|
+
selector: ({ editor: e }) => {
|
|
757
|
+
var _a;
|
|
758
|
+
return (_a = e == null ? void 0 : e.isEditable) != null ? _a : false;
|
|
759
|
+
}
|
|
760
|
+
});
|
|
761
|
+
const [uploadState, setUploadState] = (0, import_react10.useState)("idle");
|
|
762
|
+
const [uploadProgress, setUploadProgress] = (0, import_react10.useState)(0);
|
|
763
|
+
const [isDragOver, setIsDragOver] = (0, import_react10.useState)(false);
|
|
764
|
+
const fileInputRef = (0, import_react10.useRef)(null);
|
|
765
|
+
const handleRemove = (0, import_react10.useCallback)(() => {
|
|
766
|
+
const pos = getPos();
|
|
767
|
+
if (pos === void 0) return;
|
|
768
|
+
editor.commands.deleteRange({
|
|
769
|
+
from: pos,
|
|
770
|
+
to: pos + node.nodeSize
|
|
771
|
+
});
|
|
772
|
+
}, [editor, getPos, node.nodeSize]);
|
|
773
|
+
const handleFileSelect = (0, import_react10.useCallback)(
|
|
774
|
+
async (file) => {
|
|
775
|
+
if (!fileHandler) return;
|
|
776
|
+
const pos = getPos();
|
|
777
|
+
if (pos === void 0) return;
|
|
778
|
+
setUploadState("uploading");
|
|
779
|
+
setUploadProgress(0);
|
|
780
|
+
try {
|
|
781
|
+
const ref = await fileHandler.upload(file, (percent) => {
|
|
782
|
+
setUploadProgress(percent);
|
|
783
|
+
});
|
|
784
|
+
const currentPos = getPos();
|
|
785
|
+
if (currentPos === void 0) return;
|
|
786
|
+
editor.chain().focus().deleteRange({ from: currentPos, to: currentPos + node.nodeSize }).insertContentAt(currentPos, {
|
|
787
|
+
type: "image",
|
|
788
|
+
attrs: {
|
|
789
|
+
src: ref,
|
|
790
|
+
alt: file.name.replace(/\.[^/.]+$/, ""),
|
|
791
|
+
title: file.name.replace(/\.[^/.]+$/, "")
|
|
792
|
+
}
|
|
793
|
+
}).run();
|
|
794
|
+
} catch (error) {
|
|
795
|
+
console.error("[ImageUpload] Upload failed:", error);
|
|
796
|
+
setUploadState("error");
|
|
797
|
+
setUploadProgress(0);
|
|
798
|
+
}
|
|
799
|
+
},
|
|
800
|
+
[fileHandler, editor, getPos, node.nodeSize]
|
|
801
|
+
);
|
|
802
|
+
const handleInputChange = (0, import_react10.useCallback)(
|
|
803
|
+
(e) => {
|
|
804
|
+
var _a;
|
|
805
|
+
const file = (_a = e.target.files) == null ? void 0 : _a[0];
|
|
806
|
+
if (file) {
|
|
807
|
+
handleFileSelect(file);
|
|
808
|
+
}
|
|
809
|
+
e.target.value = "";
|
|
810
|
+
},
|
|
811
|
+
[handleFileSelect]
|
|
812
|
+
);
|
|
813
|
+
const handleDrop = (0, import_react10.useCallback)(
|
|
814
|
+
(e) => {
|
|
815
|
+
e.preventDefault();
|
|
816
|
+
e.stopPropagation();
|
|
817
|
+
setIsDragOver(false);
|
|
818
|
+
const file = e.dataTransfer.files[0];
|
|
819
|
+
if (file == null ? void 0 : file.type.startsWith("image/")) {
|
|
820
|
+
handleFileSelect(file);
|
|
821
|
+
}
|
|
822
|
+
},
|
|
823
|
+
[handleFileSelect]
|
|
824
|
+
);
|
|
825
|
+
const handleDragOver = (0, import_react10.useCallback)((e) => {
|
|
826
|
+
e.preventDefault();
|
|
827
|
+
e.stopPropagation();
|
|
828
|
+
}, []);
|
|
829
|
+
const handleDragEnter = (0, import_react10.useCallback)((e) => {
|
|
830
|
+
e.preventDefault();
|
|
831
|
+
e.stopPropagation();
|
|
832
|
+
setIsDragOver(true);
|
|
833
|
+
}, []);
|
|
834
|
+
const handleDragLeave = (0, import_react10.useCallback)((e) => {
|
|
835
|
+
e.preventDefault();
|
|
836
|
+
e.stopPropagation();
|
|
837
|
+
if (!e.currentTarget.contains(e.relatedTarget)) {
|
|
838
|
+
setIsDragOver(false);
|
|
839
|
+
}
|
|
840
|
+
}, []);
|
|
841
|
+
const handleClick = (0, import_react10.useCallback)(() => {
|
|
842
|
+
var _a;
|
|
843
|
+
if (uploadState === "idle" || uploadState === "error") {
|
|
844
|
+
(_a = fileInputRef.current) == null ? void 0 : _a.click();
|
|
845
|
+
}
|
|
846
|
+
}, [uploadState]);
|
|
847
|
+
const styles = (0, import_react10.useMemo)(
|
|
848
|
+
() => (0, import_theme3.imagePlaceholder)({
|
|
849
|
+
size: "md",
|
|
850
|
+
variant: isDragOver ? "default" : void 0
|
|
851
|
+
}),
|
|
852
|
+
[isDragOver]
|
|
853
|
+
);
|
|
854
|
+
const errorStyles = (0, import_react10.useMemo)(
|
|
855
|
+
() => (0, import_theme3.imagePlaceholder)({ size: "md", variant: "error" }),
|
|
856
|
+
[]
|
|
857
|
+
);
|
|
858
|
+
const uploadingStyles = (0, import_react10.useMemo)(
|
|
859
|
+
() => (0, import_theme3.imagePlaceholder)({ size: "md", variant: "uploading" }),
|
|
860
|
+
[]
|
|
861
|
+
);
|
|
862
|
+
const disabledStyles = (0, import_react10.useMemo)(
|
|
863
|
+
() => (0, import_theme3.imagePlaceholder)({ size: "md", variant: "disabled" }),
|
|
864
|
+
[]
|
|
865
|
+
);
|
|
866
|
+
if (!fileHandler) {
|
|
867
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react9.NodeViewWrapper, { className: "my-4", "data-type": "image-upload", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: disabledStyles.root(), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: disabledStyles.content(), children: [
|
|
868
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_icons4.ImageIcon, { className: disabledStyles.icon() }),
|
|
869
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: disabledStyles.text(), children: intl.formatMessage(messages3.files_not_supported) }),
|
|
870
|
+
isEditable && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
871
|
+
import_button3.IconButton,
|
|
872
|
+
{
|
|
873
|
+
size: "sm",
|
|
874
|
+
variant: "ghost",
|
|
875
|
+
onClick: handleRemove,
|
|
876
|
+
"aria-label": intl.formatMessage(messages3.remove),
|
|
877
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_icons4.TrashIcon, { className: "size-4" })
|
|
878
|
+
}
|
|
879
|
+
)
|
|
880
|
+
] }) }) });
|
|
881
|
+
}
|
|
882
|
+
if (uploadState === "uploading") {
|
|
883
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react9.NodeViewWrapper, { className: "my-4", "data-type": "image-upload", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: uploadingStyles.root(), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: uploadingStyles.content(), children: [
|
|
884
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative size-12", children: [
|
|
885
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
886
|
+
"svg",
|
|
887
|
+
{
|
|
888
|
+
className: "size-12 -rotate-90",
|
|
889
|
+
viewBox: "0 0 36 36",
|
|
890
|
+
"aria-hidden": "true",
|
|
891
|
+
children: [
|
|
892
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
893
|
+
"circle",
|
|
894
|
+
{
|
|
895
|
+
cx: "18",
|
|
896
|
+
cy: "18",
|
|
897
|
+
r: "16",
|
|
898
|
+
fill: "none",
|
|
899
|
+
className: "stroke-muted",
|
|
900
|
+
strokeWidth: "2"
|
|
901
|
+
}
|
|
902
|
+
),
|
|
903
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
904
|
+
"circle",
|
|
905
|
+
{
|
|
906
|
+
cx: "18",
|
|
907
|
+
cy: "18",
|
|
908
|
+
r: "16",
|
|
909
|
+
fill: "none",
|
|
910
|
+
className: "stroke-primary",
|
|
911
|
+
strokeWidth: "2",
|
|
912
|
+
strokeDasharray: 100,
|
|
913
|
+
strokeDashoffset: 100 - uploadProgress,
|
|
914
|
+
strokeLinecap: "round"
|
|
915
|
+
}
|
|
916
|
+
)
|
|
917
|
+
]
|
|
918
|
+
}
|
|
919
|
+
),
|
|
920
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "absolute inset-0 flex items-center justify-center text-xs font-medium", children: [
|
|
921
|
+
uploadProgress,
|
|
922
|
+
"%"
|
|
923
|
+
] })
|
|
924
|
+
] }),
|
|
925
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: uploadingStyles.text(), children: intl.formatMessage(messages3.uploading) })
|
|
926
|
+
] }) }) });
|
|
927
|
+
}
|
|
928
|
+
if (uploadState === "error") {
|
|
929
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react9.NodeViewWrapper, { className: "my-4", "data-type": "image-upload", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: errorStyles.root(), onClick: handleClick, children: [
|
|
930
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: errorStyles.content(), children: [
|
|
931
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_icons4.AlertCircleIcon, { className: errorStyles.icon() }),
|
|
932
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: errorStyles.text(), children: intl.formatMessage(messages3.upload_error) }),
|
|
933
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: errorStyles.hint(), children: intl.formatMessage(messages3.click_to_retry) })
|
|
934
|
+
] }),
|
|
935
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
936
|
+
"input",
|
|
937
|
+
{
|
|
938
|
+
ref: fileInputRef,
|
|
939
|
+
type: "file",
|
|
940
|
+
accept: "image/*",
|
|
941
|
+
className: "hidden",
|
|
942
|
+
onChange: handleInputChange
|
|
943
|
+
}
|
|
944
|
+
),
|
|
945
|
+
isEditable && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
946
|
+
import_button3.IconButton,
|
|
947
|
+
{
|
|
948
|
+
size: "sm",
|
|
949
|
+
variant: "ghost",
|
|
950
|
+
className: errorStyles.removeButton(),
|
|
951
|
+
onClick: (e) => {
|
|
952
|
+
e.stopPropagation();
|
|
953
|
+
handleRemove();
|
|
954
|
+
},
|
|
955
|
+
"aria-label": intl.formatMessage(messages3.remove),
|
|
956
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_icons4.TrashIcon, { className: "size-3.5" })
|
|
957
|
+
}
|
|
958
|
+
)
|
|
959
|
+
] }) });
|
|
960
|
+
}
|
|
961
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react9.NodeViewWrapper, { className: "my-4", "data-type": "image-upload", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
962
|
+
"div",
|
|
963
|
+
{
|
|
964
|
+
className: `${styles.root()} ${isDragOver ? "border-primary bg-primary/10" : ""}`,
|
|
965
|
+
onClick: handleClick,
|
|
966
|
+
onDrop: handleDrop,
|
|
967
|
+
onDragOver: handleDragOver,
|
|
968
|
+
onDragEnter: handleDragEnter,
|
|
969
|
+
onDragLeave: handleDragLeave,
|
|
970
|
+
children: [
|
|
971
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: styles.content(), children: [
|
|
972
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_icons4.UploadIcon, { className: styles.icon() }),
|
|
973
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: styles.text(), children: intl.formatMessage(messages3.upload_placeholder) }),
|
|
974
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: styles.hint(), children: intl.formatMessage(messages3.upload_hint) })
|
|
975
|
+
] }),
|
|
976
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
977
|
+
"input",
|
|
978
|
+
{
|
|
979
|
+
ref: fileInputRef,
|
|
980
|
+
type: "file",
|
|
981
|
+
accept: "image/*",
|
|
982
|
+
className: "hidden",
|
|
983
|
+
onChange: handleInputChange
|
|
984
|
+
}
|
|
985
|
+
),
|
|
986
|
+
isEditable && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
987
|
+
import_button3.IconButton,
|
|
988
|
+
{
|
|
989
|
+
size: "sm",
|
|
990
|
+
variant: "ghost",
|
|
991
|
+
className: styles.removeButton(),
|
|
992
|
+
onClick: (e) => {
|
|
993
|
+
e.stopPropagation();
|
|
994
|
+
handleRemove();
|
|
995
|
+
},
|
|
996
|
+
"aria-label": intl.formatMessage(messages3.remove),
|
|
997
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_icons4.TrashIcon, { className: "size-3.5" })
|
|
998
|
+
}
|
|
999
|
+
)
|
|
1000
|
+
]
|
|
1001
|
+
}
|
|
1002
|
+
) });
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
// src/extensions/image-upload/index.ts
|
|
1006
|
+
var ImageUploadNode = import_core2.Node.create({
|
|
1007
|
+
name: "imageUpload",
|
|
852
1008
|
group: "block",
|
|
853
1009
|
atom: true,
|
|
854
1010
|
draggable: true,
|
|
1011
|
+
selectable: true,
|
|
855
1012
|
addOptions() {
|
|
856
1013
|
return {
|
|
857
|
-
|
|
1014
|
+
accept: "image/*",
|
|
1015
|
+
maxSize: 0,
|
|
858
1016
|
HTMLAttributes: {}
|
|
859
1017
|
};
|
|
860
1018
|
},
|
|
861
1019
|
addAttributes() {
|
|
862
1020
|
return {
|
|
863
|
-
|
|
864
|
-
default: null
|
|
865
|
-
},
|
|
866
|
-
alt: {
|
|
867
|
-
default: null
|
|
868
|
-
},
|
|
869
|
-
title: {
|
|
870
|
-
default: null
|
|
871
|
-
},
|
|
872
|
-
width: {
|
|
873
|
-
default: null
|
|
874
|
-
},
|
|
875
|
-
height: {
|
|
876
|
-
default: null
|
|
877
|
-
},
|
|
1021
|
+
// Upload state tracking
|
|
878
1022
|
uploadState: {
|
|
879
1023
|
default: null,
|
|
880
1024
|
rendered: false
|
|
@@ -888,49 +1032,65 @@ var ImageNode = import_core2.Node.create({
|
|
|
888
1032
|
parseHTML() {
|
|
889
1033
|
return [
|
|
890
1034
|
{
|
|
891
|
-
tag: "
|
|
1035
|
+
tag: 'div[data-type="image-upload"]'
|
|
892
1036
|
}
|
|
893
1037
|
];
|
|
894
1038
|
},
|
|
895
1039
|
renderHTML({ HTMLAttributes }) {
|
|
896
|
-
return [
|
|
897
|
-
"img",
|
|
898
|
-
(0, import_core2.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes)
|
|
899
|
-
];
|
|
1040
|
+
return ["div", { ...HTMLAttributes, "data-type": "image-upload" }];
|
|
900
1041
|
},
|
|
901
1042
|
addNodeView() {
|
|
902
|
-
return (0,
|
|
1043
|
+
return (0, import_react11.ReactNodeViewRenderer)(ImageUploadNodeView);
|
|
903
1044
|
},
|
|
904
1045
|
addCommands() {
|
|
905
1046
|
return {
|
|
906
|
-
|
|
1047
|
+
setImageUpload: () => ({ commands }) => {
|
|
907
1048
|
return commands.insertContent({
|
|
908
|
-
type: this.name
|
|
909
|
-
attrs: options
|
|
1049
|
+
type: this.name
|
|
910
1050
|
});
|
|
911
1051
|
}
|
|
912
1052
|
};
|
|
1053
|
+
},
|
|
1054
|
+
addKeyboardShortcuts() {
|
|
1055
|
+
return {
|
|
1056
|
+
Enter: ({ editor }) => {
|
|
1057
|
+
const { selection } = editor.state;
|
|
1058
|
+
const { $from } = selection;
|
|
1059
|
+
const node = $from.nodeAfter;
|
|
1060
|
+
if ((node == null ? void 0 : node.type.name) === "imageUpload" && editor.isActive("imageUpload")) {
|
|
1061
|
+
const nodeEl = editor.view.nodeDOM($from.pos);
|
|
1062
|
+
if (nodeEl instanceof HTMLElement) {
|
|
1063
|
+
const input = nodeEl.querySelector('input[type="file"]');
|
|
1064
|
+
if (input instanceof HTMLElement) {
|
|
1065
|
+
input.click();
|
|
1066
|
+
return true;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
return false;
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
913
1073
|
}
|
|
914
1074
|
});
|
|
915
1075
|
|
|
916
1076
|
// src/extensions/math/index.ts
|
|
917
1077
|
var import_core4 = require("@tiptap/core");
|
|
918
|
-
var
|
|
1078
|
+
var import_react17 = require("@tiptap/react");
|
|
919
1079
|
|
|
920
1080
|
// src/extensions/math/math-block-view.tsx
|
|
921
|
-
var
|
|
1081
|
+
var import_button4 = require("@kopexa/button");
|
|
922
1082
|
var import_dialog2 = require("@kopexa/dialog");
|
|
923
|
-
var
|
|
1083
|
+
var import_icons5 = require("@kopexa/icons");
|
|
924
1084
|
var import_label2 = require("@kopexa/label");
|
|
925
|
-
var
|
|
1085
|
+
var import_react12 = require("@tiptap/react");
|
|
926
1086
|
var import_katex = __toESM(require("katex"));
|
|
927
1087
|
var import_katex_min = require("katex/dist/katex.min.css");
|
|
928
|
-
var
|
|
929
|
-
var
|
|
1088
|
+
var import_react13 = require("react");
|
|
1089
|
+
var import_react_intl8 = require("react-intl");
|
|
930
1090
|
|
|
931
1091
|
// src/extensions/math/messages.ts
|
|
932
|
-
var
|
|
933
|
-
var
|
|
1092
|
+
var import_react_intl7 = require("react-intl");
|
|
1093
|
+
var messages4 = (0, import_react_intl7.defineMessages)({
|
|
934
1094
|
title: {
|
|
935
1095
|
id: "editor.math.title",
|
|
936
1096
|
defaultMessage: "Formula",
|
|
@@ -979,28 +1139,28 @@ var messages3 = (0, import_react_intl5.defineMessages)({
|
|
|
979
1139
|
});
|
|
980
1140
|
|
|
981
1141
|
// src/extensions/math/math-block-view.tsx
|
|
982
|
-
var
|
|
1142
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
983
1143
|
function MathBlockView({ editor, node, getPos }) {
|
|
984
|
-
const intl = (0,
|
|
1144
|
+
const intl = (0, import_react_intl8.useIntl)();
|
|
985
1145
|
const attrs = node.attrs;
|
|
986
1146
|
const { latex = "" } = attrs;
|
|
987
|
-
const isEditable = (0,
|
|
1147
|
+
const isEditable = (0, import_react12.useEditorState)({
|
|
988
1148
|
editor,
|
|
989
1149
|
selector: ({ editor: e }) => {
|
|
990
1150
|
var _a;
|
|
991
1151
|
return (_a = e == null ? void 0 : e.isEditable) != null ? _a : false;
|
|
992
1152
|
}
|
|
993
1153
|
});
|
|
994
|
-
const [isOpen, setIsOpen] = (0,
|
|
995
|
-
const [localLatex, setLocalLatex] = (0,
|
|
996
|
-
const [error, setError] = (0,
|
|
997
|
-
(0,
|
|
1154
|
+
const [isOpen, setIsOpen] = (0, import_react13.useState)(false);
|
|
1155
|
+
const [localLatex, setLocalLatex] = (0, import_react13.useState)(latex);
|
|
1156
|
+
const [error, setError] = (0, import_react13.useState)(null);
|
|
1157
|
+
(0, import_react13.useEffect)(() => {
|
|
998
1158
|
if (isOpen) {
|
|
999
1159
|
setLocalLatex(latex);
|
|
1000
1160
|
setError(null);
|
|
1001
1161
|
}
|
|
1002
1162
|
}, [isOpen, latex]);
|
|
1003
|
-
const renderedHtml = (0,
|
|
1163
|
+
const renderedHtml = (0, import_react13.useMemo)(() => {
|
|
1004
1164
|
if (!latex) return null;
|
|
1005
1165
|
try {
|
|
1006
1166
|
return import_katex.default.renderToString(latex, {
|
|
@@ -1012,7 +1172,7 @@ function MathBlockView({ editor, node, getPos }) {
|
|
|
1012
1172
|
return null;
|
|
1013
1173
|
}
|
|
1014
1174
|
}, [latex]);
|
|
1015
|
-
const previewHtml = (0,
|
|
1175
|
+
const previewHtml = (0, import_react13.useMemo)(() => {
|
|
1016
1176
|
if (!localLatex) return null;
|
|
1017
1177
|
try {
|
|
1018
1178
|
setError(null);
|
|
@@ -1022,11 +1182,11 @@ function MathBlockView({ editor, node, getPos }) {
|
|
|
1022
1182
|
output: "html"
|
|
1023
1183
|
});
|
|
1024
1184
|
} catch (_e) {
|
|
1025
|
-
setError(intl.formatMessage(
|
|
1185
|
+
setError(intl.formatMessage(messages4.invalid_latex));
|
|
1026
1186
|
return null;
|
|
1027
1187
|
}
|
|
1028
1188
|
}, [localLatex, intl]);
|
|
1029
|
-
const handleSave = (0,
|
|
1189
|
+
const handleSave = (0, import_react13.useCallback)(() => {
|
|
1030
1190
|
const pos = getPos();
|
|
1031
1191
|
if (pos === void 0) return;
|
|
1032
1192
|
editor.view.dispatch(
|
|
@@ -1034,12 +1194,12 @@ function MathBlockView({ editor, node, getPos }) {
|
|
|
1034
1194
|
);
|
|
1035
1195
|
setIsOpen(false);
|
|
1036
1196
|
}, [editor, localLatex, getPos]);
|
|
1037
|
-
const handleCancel = (0,
|
|
1197
|
+
const handleCancel = (0, import_react13.useCallback)(() => {
|
|
1038
1198
|
setLocalLatex(latex);
|
|
1039
1199
|
setError(null);
|
|
1040
1200
|
setIsOpen(false);
|
|
1041
1201
|
}, [latex]);
|
|
1042
|
-
const handleOpenEditor = (0,
|
|
1202
|
+
const handleOpenEditor = (0, import_react13.useCallback)(
|
|
1043
1203
|
(e) => {
|
|
1044
1204
|
e.stopPropagation();
|
|
1045
1205
|
e.preventDefault();
|
|
@@ -1050,73 +1210,73 @@ function MathBlockView({ editor, node, getPos }) {
|
|
|
1050
1210
|
[isEditable]
|
|
1051
1211
|
);
|
|
1052
1212
|
const isEmpty = !latex;
|
|
1053
|
-
return /* @__PURE__ */ (0,
|
|
1054
|
-
|
|
1213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1214
|
+
import_react12.NodeViewWrapper,
|
|
1055
1215
|
{
|
|
1056
1216
|
className: "my-4 relative group",
|
|
1057
1217
|
"data-type": "math-block",
|
|
1058
1218
|
"data-latex": latex,
|
|
1059
1219
|
children: [
|
|
1060
|
-
/* @__PURE__ */ (0,
|
|
1220
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1061
1221
|
"button",
|
|
1062
1222
|
{
|
|
1063
1223
|
type: "button",
|
|
1064
1224
|
className: "w-full flex items-center justify-center min-h-16 p-4 rounded-md border border-border bg-muted/30 cursor-pointer hover:bg-muted/50 transition-colors",
|
|
1065
1225
|
onClick: handleOpenEditor,
|
|
1066
|
-
children: isEmpty ? /* @__PURE__ */ (0,
|
|
1067
|
-
/* @__PURE__ */ (0,
|
|
1068
|
-
/* @__PURE__ */ (0,
|
|
1069
|
-
] }) : renderedHtml ? /* @__PURE__ */ (0,
|
|
1226
|
+
children: isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-2 text-muted-foreground", children: [
|
|
1227
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-lg font-serif", children: "\u2211" }),
|
|
1228
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-sm", children: intl.formatMessage(messages4.empty_formula) })
|
|
1229
|
+
] }) : renderedHtml ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1070
1230
|
"div",
|
|
1071
1231
|
{
|
|
1072
1232
|
className: "katex-display",
|
|
1073
1233
|
dangerouslySetInnerHTML: { __html: renderedHtml }
|
|
1074
1234
|
}
|
|
1075
|
-
) : /* @__PURE__ */ (0,
|
|
1235
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-destructive text-sm", children: intl.formatMessage(messages4.invalid_latex) })
|
|
1076
1236
|
}
|
|
1077
1237
|
),
|
|
1078
|
-
isEditable && !isEmpty && /* @__PURE__ */ (0,
|
|
1079
|
-
|
|
1238
|
+
isEditable && !isEmpty && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1239
|
+
import_button4.IconButton,
|
|
1080
1240
|
{
|
|
1081
1241
|
size: "sm",
|
|
1082
1242
|
variant: "ghost",
|
|
1083
1243
|
className: "absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",
|
|
1084
|
-
"aria-label": intl.formatMessage(
|
|
1244
|
+
"aria-label": intl.formatMessage(messages4.edit),
|
|
1085
1245
|
onClick: handleOpenEditor,
|
|
1086
|
-
children: /* @__PURE__ */ (0,
|
|
1246
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons5.EditIcon, { className: "size-3.5" })
|
|
1087
1247
|
}
|
|
1088
1248
|
),
|
|
1089
|
-
/* @__PURE__ */ (0,
|
|
1090
|
-
/* @__PURE__ */ (0,
|
|
1091
|
-
/* @__PURE__ */ (0,
|
|
1092
|
-
/* @__PURE__ */ (0,
|
|
1093
|
-
/* @__PURE__ */ (0,
|
|
1094
|
-
/* @__PURE__ */ (0,
|
|
1249
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dialog2.Dialog.Root, { open: isOpen, onOpenChange: setIsOpen, size: "md", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_dialog2.Dialog.Content, { children: [
|
|
1250
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dialog2.Dialog.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dialog2.Dialog.Title, { children: intl.formatMessage(messages4.title) }) }),
|
|
1251
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_dialog2.Dialog.Body, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "space-y-4", children: [
|
|
1252
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "space-y-1.5", children: [
|
|
1253
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_label2.Label, { className: "text-sm", children: intl.formatMessage(messages4.latex_input) }),
|
|
1254
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1095
1255
|
"textarea",
|
|
1096
1256
|
{
|
|
1097
1257
|
className: "w-full min-h-24 p-3 rounded-md border border-input bg-background font-mono text-sm resize-y focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
1098
1258
|
value: localLatex,
|
|
1099
1259
|
onChange: (e) => setLocalLatex(e.target.value),
|
|
1100
|
-
placeholder: intl.formatMessage(
|
|
1260
|
+
placeholder: intl.formatMessage(messages4.latex_placeholder),
|
|
1101
1261
|
spellCheck: false
|
|
1102
1262
|
}
|
|
1103
1263
|
),
|
|
1104
|
-
error && /* @__PURE__ */ (0,
|
|
1264
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "text-xs text-destructive", children: error })
|
|
1105
1265
|
] }),
|
|
1106
|
-
/* @__PURE__ */ (0,
|
|
1107
|
-
/* @__PURE__ */ (0,
|
|
1108
|
-
/* @__PURE__ */ (0,
|
|
1266
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "space-y-1.5", children: [
|
|
1267
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_label2.Label, { className: "text-sm", children: intl.formatMessage(messages4.preview) }),
|
|
1268
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "min-h-16 p-4 rounded-md border border-border bg-muted/30 flex items-center justify-center", children: previewHtml ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1109
1269
|
"div",
|
|
1110
1270
|
{
|
|
1111
1271
|
className: "katex-display",
|
|
1112
1272
|
dangerouslySetInnerHTML: { __html: previewHtml }
|
|
1113
1273
|
}
|
|
1114
|
-
) : localLatex ? /* @__PURE__ */ (0,
|
|
1274
|
+
) : localLatex ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-muted-foreground text-sm", children: intl.formatMessage(messages4.invalid_latex) }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-muted-foreground text-sm", children: intl.formatMessage(messages4.latex_placeholder) }) })
|
|
1115
1275
|
] })
|
|
1116
1276
|
] }) }),
|
|
1117
|
-
/* @__PURE__ */ (0,
|
|
1118
|
-
/* @__PURE__ */ (0,
|
|
1119
|
-
/* @__PURE__ */ (0,
|
|
1277
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_dialog2.Dialog.Footer, { children: [
|
|
1278
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_button4.Button, { variant: "ghost", onClick: handleCancel, children: intl.formatMessage(messages4.cancel) }),
|
|
1279
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_button4.Button, { onClick: handleSave, disabled: !!error && !!localLatex, children: intl.formatMessage(messages4.save) })
|
|
1120
1280
|
] })
|
|
1121
1281
|
] }) })
|
|
1122
1282
|
]
|
|
@@ -1126,39 +1286,39 @@ function MathBlockView({ editor, node, getPos }) {
|
|
|
1126
1286
|
|
|
1127
1287
|
// src/extensions/math/inline-math.ts
|
|
1128
1288
|
var import_core3 = require("@tiptap/core");
|
|
1129
|
-
var
|
|
1289
|
+
var import_react16 = require("@tiptap/react");
|
|
1130
1290
|
|
|
1131
1291
|
// src/extensions/math/inline-math-view.tsx
|
|
1132
|
-
var
|
|
1292
|
+
var import_button5 = require("@kopexa/button");
|
|
1133
1293
|
var import_dialog3 = require("@kopexa/dialog");
|
|
1134
1294
|
var import_label3 = require("@kopexa/label");
|
|
1135
|
-
var
|
|
1295
|
+
var import_react14 = require("@tiptap/react");
|
|
1136
1296
|
var import_katex2 = __toESM(require("katex"));
|
|
1137
1297
|
var import_katex_min2 = require("katex/dist/katex.min.css");
|
|
1138
|
-
var
|
|
1139
|
-
var
|
|
1140
|
-
var
|
|
1298
|
+
var import_react15 = require("react");
|
|
1299
|
+
var import_react_intl9 = require("react-intl");
|
|
1300
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1141
1301
|
function InlineMathView({ editor, node, getPos }) {
|
|
1142
|
-
const intl = (0,
|
|
1302
|
+
const intl = (0, import_react_intl9.useIntl)();
|
|
1143
1303
|
const attrs = node.attrs;
|
|
1144
1304
|
const { latex = "" } = attrs;
|
|
1145
|
-
const isEditable = (0,
|
|
1305
|
+
const isEditable = (0, import_react14.useEditorState)({
|
|
1146
1306
|
editor,
|
|
1147
1307
|
selector: ({ editor: e }) => {
|
|
1148
1308
|
var _a;
|
|
1149
1309
|
return (_a = e == null ? void 0 : e.isEditable) != null ? _a : false;
|
|
1150
1310
|
}
|
|
1151
1311
|
});
|
|
1152
|
-
const [isOpen, setIsOpen] = (0,
|
|
1153
|
-
const [localLatex, setLocalLatex] = (0,
|
|
1154
|
-
const [error, setError] = (0,
|
|
1155
|
-
(0,
|
|
1312
|
+
const [isOpen, setIsOpen] = (0, import_react15.useState)(false);
|
|
1313
|
+
const [localLatex, setLocalLatex] = (0, import_react15.useState)(latex);
|
|
1314
|
+
const [error, setError] = (0, import_react15.useState)(null);
|
|
1315
|
+
(0, import_react15.useEffect)(() => {
|
|
1156
1316
|
if (isOpen) {
|
|
1157
1317
|
setLocalLatex(latex);
|
|
1158
1318
|
setError(null);
|
|
1159
1319
|
}
|
|
1160
1320
|
}, [isOpen, latex]);
|
|
1161
|
-
const renderedHtml = (0,
|
|
1321
|
+
const renderedHtml = (0, import_react15.useMemo)(() => {
|
|
1162
1322
|
if (!latex) return null;
|
|
1163
1323
|
try {
|
|
1164
1324
|
return import_katex2.default.renderToString(latex, {
|
|
@@ -1170,7 +1330,7 @@ function InlineMathView({ editor, node, getPos }) {
|
|
|
1170
1330
|
return null;
|
|
1171
1331
|
}
|
|
1172
1332
|
}, [latex]);
|
|
1173
|
-
const previewHtml = (0,
|
|
1333
|
+
const previewHtml = (0, import_react15.useMemo)(() => {
|
|
1174
1334
|
if (!localLatex) return null;
|
|
1175
1335
|
try {
|
|
1176
1336
|
setError(null);
|
|
@@ -1180,11 +1340,11 @@ function InlineMathView({ editor, node, getPos }) {
|
|
|
1180
1340
|
output: "html"
|
|
1181
1341
|
});
|
|
1182
1342
|
} catch (_e) {
|
|
1183
|
-
setError(intl.formatMessage(
|
|
1343
|
+
setError(intl.formatMessage(messages4.invalid_latex));
|
|
1184
1344
|
return null;
|
|
1185
1345
|
}
|
|
1186
1346
|
}, [localLatex, intl]);
|
|
1187
|
-
const handleSave = (0,
|
|
1347
|
+
const handleSave = (0, import_react15.useCallback)(() => {
|
|
1188
1348
|
const pos = getPos();
|
|
1189
1349
|
if (pos === void 0) return;
|
|
1190
1350
|
editor.view.dispatch(
|
|
@@ -1192,12 +1352,12 @@ function InlineMathView({ editor, node, getPos }) {
|
|
|
1192
1352
|
);
|
|
1193
1353
|
setIsOpen(false);
|
|
1194
1354
|
}, [editor, localLatex, getPos]);
|
|
1195
|
-
const handleCancel = (0,
|
|
1355
|
+
const handleCancel = (0, import_react15.useCallback)(() => {
|
|
1196
1356
|
setLocalLatex(latex);
|
|
1197
1357
|
setError(null);
|
|
1198
1358
|
setIsOpen(false);
|
|
1199
1359
|
}, [latex]);
|
|
1200
|
-
const handleClick = (0,
|
|
1360
|
+
const handleClick = (0, import_react15.useCallback)(
|
|
1201
1361
|
(e) => {
|
|
1202
1362
|
e.stopPropagation();
|
|
1203
1363
|
e.preventDefault();
|
|
@@ -1208,58 +1368,58 @@ function InlineMathView({ editor, node, getPos }) {
|
|
|
1208
1368
|
[isEditable]
|
|
1209
1369
|
);
|
|
1210
1370
|
const isEmpty = !latex;
|
|
1211
|
-
return /* @__PURE__ */ (0,
|
|
1212
|
-
|
|
1371
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1372
|
+
import_react14.NodeViewWrapper,
|
|
1213
1373
|
{
|
|
1214
1374
|
as: "span",
|
|
1215
1375
|
className: "inline-math-wrapper",
|
|
1216
1376
|
"data-type": "inline-math",
|
|
1217
1377
|
"data-latex": latex,
|
|
1218
1378
|
children: [
|
|
1219
|
-
/* @__PURE__ */ (0,
|
|
1379
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1220
1380
|
"span",
|
|
1221
1381
|
{
|
|
1222
1382
|
className: `inline-math cursor-pointer rounded px-0.5 transition-colors ${isEditable ? "hover:bg-primary/10 hover:ring-1 hover:ring-primary/20" : ""} ${isEmpty ? "text-muted-foreground italic" : ""}`,
|
|
1223
1383
|
onClick: handleClick,
|
|
1224
|
-
children: isEmpty ? /* @__PURE__ */ (0,
|
|
1384
|
+
children: isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-xs", children: "$?$" }) : renderedHtml ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1225
1385
|
"span",
|
|
1226
1386
|
{
|
|
1227
1387
|
dangerouslySetInnerHTML: { __html: renderedHtml }
|
|
1228
1388
|
}
|
|
1229
|
-
) : /* @__PURE__ */ (0,
|
|
1389
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-destructive text-xs", children: latex })
|
|
1230
1390
|
}
|
|
1231
1391
|
),
|
|
1232
|
-
/* @__PURE__ */ (0,
|
|
1233
|
-
/* @__PURE__ */ (0,
|
|
1234
|
-
/* @__PURE__ */ (0,
|
|
1235
|
-
/* @__PURE__ */ (0,
|
|
1236
|
-
/* @__PURE__ */ (0,
|
|
1237
|
-
/* @__PURE__ */ (0,
|
|
1392
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_dialog3.Dialog.Root, { open: isOpen, onOpenChange: setIsOpen, size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_dialog3.Dialog.Content, { children: [
|
|
1393
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_dialog3.Dialog.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_dialog3.Dialog.Title, { children: intl.formatMessage(messages4.title) }) }),
|
|
1394
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_dialog3.Dialog.Body, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-4", children: [
|
|
1395
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-1.5", children: [
|
|
1396
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_label3.Label, { className: "text-sm", children: intl.formatMessage(messages4.latex_input) }),
|
|
1397
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1238
1398
|
"input",
|
|
1239
1399
|
{
|
|
1240
1400
|
type: "text",
|
|
1241
1401
|
className: "w-full p-2 rounded-md border border-input bg-background font-mono text-sm focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
1242
1402
|
value: localLatex,
|
|
1243
1403
|
onChange: (e) => setLocalLatex(e.target.value),
|
|
1244
|
-
placeholder: intl.formatMessage(
|
|
1404
|
+
placeholder: intl.formatMessage(messages4.latex_placeholder),
|
|
1245
1405
|
spellCheck: false
|
|
1246
1406
|
}
|
|
1247
1407
|
),
|
|
1248
|
-
error && /* @__PURE__ */ (0,
|
|
1408
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-xs text-destructive", children: error })
|
|
1249
1409
|
] }),
|
|
1250
|
-
/* @__PURE__ */ (0,
|
|
1251
|
-
/* @__PURE__ */ (0,
|
|
1252
|
-
/* @__PURE__ */ (0,
|
|
1410
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-1.5", children: [
|
|
1411
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_label3.Label, { className: "text-sm", children: intl.formatMessage(messages4.preview) }),
|
|
1412
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "min-h-10 p-3 rounded-md border border-border bg-muted/30 flex items-center justify-center", children: previewHtml ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1253
1413
|
"span",
|
|
1254
1414
|
{
|
|
1255
1415
|
dangerouslySetInnerHTML: { __html: previewHtml }
|
|
1256
1416
|
}
|
|
1257
|
-
) : localLatex ? /* @__PURE__ */ (0,
|
|
1417
|
+
) : localLatex ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-muted-foreground text-sm", children: intl.formatMessage(messages4.invalid_latex) }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-muted-foreground text-sm", children: "$...$" }) })
|
|
1258
1418
|
] })
|
|
1259
1419
|
] }) }),
|
|
1260
|
-
/* @__PURE__ */ (0,
|
|
1261
|
-
/* @__PURE__ */ (0,
|
|
1262
|
-
/* @__PURE__ */ (0,
|
|
1420
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_dialog3.Dialog.Footer, { children: [
|
|
1421
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_button5.Button, { variant: "ghost", onClick: handleCancel, children: intl.formatMessage(messages4.cancel) }),
|
|
1422
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_button5.Button, { onClick: handleSave, disabled: !!error && !!localLatex, children: intl.formatMessage(messages4.save) })
|
|
1263
1423
|
] })
|
|
1264
1424
|
] }) })
|
|
1265
1425
|
]
|
|
@@ -1305,7 +1465,7 @@ var InlineMath = import_core3.Node.create({
|
|
|
1305
1465
|
];
|
|
1306
1466
|
},
|
|
1307
1467
|
addNodeView() {
|
|
1308
|
-
return (0,
|
|
1468
|
+
return (0, import_react16.ReactNodeViewRenderer)(InlineMathView, {
|
|
1309
1469
|
as: "span"
|
|
1310
1470
|
});
|
|
1311
1471
|
},
|
|
@@ -1373,7 +1533,7 @@ var MathBlock = import_core4.Node.create({
|
|
|
1373
1533
|
];
|
|
1374
1534
|
},
|
|
1375
1535
|
addNodeView() {
|
|
1376
|
-
return (0,
|
|
1536
|
+
return (0, import_react17.ReactNodeViewRenderer)(MathBlockView);
|
|
1377
1537
|
},
|
|
1378
1538
|
addCommands() {
|
|
1379
1539
|
return {
|
|
@@ -1416,18 +1576,18 @@ var MathBlock = import_core4.Node.create({
|
|
|
1416
1576
|
|
|
1417
1577
|
// src/extensions/toc/index.ts
|
|
1418
1578
|
var import_core5 = require("@tiptap/core");
|
|
1419
|
-
var
|
|
1579
|
+
var import_react21 = require("@tiptap/react");
|
|
1420
1580
|
|
|
1421
1581
|
// src/extensions/toc/toc-view.tsx
|
|
1422
|
-
var
|
|
1423
|
-
var
|
|
1424
|
-
var
|
|
1425
|
-
var
|
|
1426
|
-
var
|
|
1582
|
+
var import_icons7 = require("@kopexa/icons");
|
|
1583
|
+
var import_theme4 = require("@kopexa/theme");
|
|
1584
|
+
var import_react19 = require("@tiptap/react");
|
|
1585
|
+
var import_react20 = require("react");
|
|
1586
|
+
var import_react_intl12 = require("react-intl");
|
|
1427
1587
|
|
|
1428
1588
|
// src/extensions/toc/messages.ts
|
|
1429
|
-
var
|
|
1430
|
-
var
|
|
1589
|
+
var import_react_intl10 = require("react-intl");
|
|
1590
|
+
var messages5 = (0, import_react_intl10.defineMessages)({
|
|
1431
1591
|
title: {
|
|
1432
1592
|
id: "editor.toc.title",
|
|
1433
1593
|
defaultMessage: "Table of Contents",
|
|
@@ -1501,15 +1661,15 @@ var messages4 = (0, import_react_intl8.defineMessages)({
|
|
|
1501
1661
|
});
|
|
1502
1662
|
|
|
1503
1663
|
// src/extensions/toc/toc-settings.tsx
|
|
1504
|
-
var
|
|
1664
|
+
var import_button6 = require("@kopexa/button");
|
|
1505
1665
|
var import_dialog4 = require("@kopexa/dialog");
|
|
1506
|
-
var
|
|
1666
|
+
var import_icons6 = require("@kopexa/icons");
|
|
1507
1667
|
var import_label4 = require("@kopexa/label");
|
|
1508
1668
|
var import_select2 = require("@kopexa/select");
|
|
1509
1669
|
var import_switch = require("@kopexa/switch");
|
|
1510
|
-
var
|
|
1511
|
-
var
|
|
1512
|
-
var
|
|
1670
|
+
var import_react18 = require("react");
|
|
1671
|
+
var import_react_intl11 = require("react-intl");
|
|
1672
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1513
1673
|
var HEADING_LEVELS = [
|
|
1514
1674
|
{ value: "1", label: "H1" },
|
|
1515
1675
|
{ value: "2", label: "H2" },
|
|
@@ -1519,15 +1679,15 @@ var HEADING_LEVELS = [
|
|
|
1519
1679
|
{ value: "6", label: "H6" }
|
|
1520
1680
|
];
|
|
1521
1681
|
function TocSettings({ editor, attrs, getPos }) {
|
|
1522
|
-
const intl = (0,
|
|
1523
|
-
const [isOpen, setIsOpen] = (0,
|
|
1524
|
-
const [localAttrs, setLocalAttrs] = (0,
|
|
1525
|
-
(0,
|
|
1682
|
+
const intl = (0, import_react_intl11.useIntl)();
|
|
1683
|
+
const [isOpen, setIsOpen] = (0, import_react18.useState)(false);
|
|
1684
|
+
const [localAttrs, setLocalAttrs] = (0, import_react18.useState)(attrs);
|
|
1685
|
+
(0, import_react18.useEffect)(() => {
|
|
1526
1686
|
if (isOpen) {
|
|
1527
1687
|
setLocalAttrs(attrs);
|
|
1528
1688
|
}
|
|
1529
1689
|
}, [isOpen, attrs]);
|
|
1530
|
-
const handleSave = (0,
|
|
1690
|
+
const handleSave = (0, import_react18.useCallback)(() => {
|
|
1531
1691
|
const pos = getPos();
|
|
1532
1692
|
if (pos === void 0) return;
|
|
1533
1693
|
editor.view.dispatch(
|
|
@@ -1535,11 +1695,11 @@ function TocSettings({ editor, attrs, getPos }) {
|
|
|
1535
1695
|
);
|
|
1536
1696
|
setIsOpen(false);
|
|
1537
1697
|
}, [editor, localAttrs, getPos]);
|
|
1538
|
-
const handleCancel = (0,
|
|
1698
|
+
const handleCancel = (0, import_react18.useCallback)(() => {
|
|
1539
1699
|
setLocalAttrs(attrs);
|
|
1540
1700
|
setIsOpen(false);
|
|
1541
1701
|
}, [attrs]);
|
|
1542
|
-
const handleMinLevelChange = (0,
|
|
1702
|
+
const handleMinLevelChange = (0, import_react18.useCallback)((value) => {
|
|
1543
1703
|
const minLevel = Number.parseInt(String(value), 10);
|
|
1544
1704
|
setLocalAttrs((prev) => ({
|
|
1545
1705
|
...prev,
|
|
@@ -1548,7 +1708,7 @@ function TocSettings({ editor, attrs, getPos }) {
|
|
|
1548
1708
|
maxLevel: Math.max(prev.maxLevel, minLevel)
|
|
1549
1709
|
}));
|
|
1550
1710
|
}, []);
|
|
1551
|
-
const handleMaxLevelChange = (0,
|
|
1711
|
+
const handleMaxLevelChange = (0, import_react18.useCallback)((value) => {
|
|
1552
1712
|
const maxLevel = Number.parseInt(String(value), 10);
|
|
1553
1713
|
setLocalAttrs((prev) => ({
|
|
1554
1714
|
...prev,
|
|
@@ -1557,10 +1717,10 @@ function TocSettings({ editor, attrs, getPos }) {
|
|
|
1557
1717
|
minLevel: Math.min(prev.minLevel, maxLevel)
|
|
1558
1718
|
}));
|
|
1559
1719
|
}, []);
|
|
1560
|
-
const handleNumberedChange = (0,
|
|
1720
|
+
const handleNumberedChange = (0, import_react18.useCallback)((checked) => {
|
|
1561
1721
|
setLocalAttrs((prev) => ({ ...prev, numbered: checked }));
|
|
1562
1722
|
}, []);
|
|
1563
|
-
const handleStyleChange = (0,
|
|
1723
|
+
const handleStyleChange = (0, import_react18.useCallback)((value) => {
|
|
1564
1724
|
setLocalAttrs((prev) => ({
|
|
1565
1725
|
...prev,
|
|
1566
1726
|
style: String(value)
|
|
@@ -1569,36 +1729,36 @@ function TocSettings({ editor, attrs, getPos }) {
|
|
|
1569
1729
|
if (!editor.isEditable) {
|
|
1570
1730
|
return null;
|
|
1571
1731
|
}
|
|
1572
|
-
return /* @__PURE__ */ (0,
|
|
1573
|
-
/* @__PURE__ */ (0,
|
|
1574
|
-
|
|
1732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
1733
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1734
|
+
import_button6.IconButton,
|
|
1575
1735
|
{
|
|
1576
1736
|
size: "sm",
|
|
1577
1737
|
variant: "ghost",
|
|
1578
|
-
"aria-label": intl.formatMessage(
|
|
1738
|
+
"aria-label": intl.formatMessage(messages5.settings),
|
|
1579
1739
|
onClick: (e) => {
|
|
1580
1740
|
e.stopPropagation();
|
|
1581
1741
|
e.preventDefault();
|
|
1582
1742
|
setIsOpen(true);
|
|
1583
1743
|
},
|
|
1584
|
-
children: /* @__PURE__ */ (0,
|
|
1744
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons6.SettingsIcon, { className: "size-3.5" })
|
|
1585
1745
|
}
|
|
1586
1746
|
),
|
|
1587
|
-
/* @__PURE__ */ (0,
|
|
1588
|
-
/* @__PURE__ */ (0,
|
|
1589
|
-
/* @__PURE__ */ (0,
|
|
1590
|
-
/* @__PURE__ */ (0,
|
|
1591
|
-
/* @__PURE__ */ (0,
|
|
1592
|
-
/* @__PURE__ */ (0,
|
|
1593
|
-
/* @__PURE__ */ (0,
|
|
1747
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dialog4.Dialog.Root, { open: isOpen, onOpenChange: setIsOpen, size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_dialog4.Dialog.Content, { children: [
|
|
1748
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dialog4.Dialog.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dialog4.Dialog.Title, { children: intl.formatMessage(messages5.settings) }) }),
|
|
1749
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dialog4.Dialog.Body, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-4", children: [
|
|
1750
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
1751
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-1.5", children: [
|
|
1752
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_label4.Label, { className: "text-sm", children: intl.formatMessage(messages5.min_level) }),
|
|
1753
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1594
1754
|
import_select2.Select,
|
|
1595
1755
|
{
|
|
1596
1756
|
size: "sm",
|
|
1597
1757
|
value: String(localAttrs.minLevel),
|
|
1598
1758
|
onValueChange: handleMinLevelChange,
|
|
1599
1759
|
children: [
|
|
1600
|
-
/* @__PURE__ */ (0,
|
|
1601
|
-
/* @__PURE__ */ (0,
|
|
1760
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_select2.Select.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_select2.Select.Value, {}) }),
|
|
1761
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_select2.Select.Content, { children: HEADING_LEVELS.map((level) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1602
1762
|
import_select2.Select.Item,
|
|
1603
1763
|
{
|
|
1604
1764
|
value: level.value,
|
|
@@ -1611,17 +1771,17 @@ function TocSettings({ editor, attrs, getPos }) {
|
|
|
1611
1771
|
}
|
|
1612
1772
|
)
|
|
1613
1773
|
] }),
|
|
1614
|
-
/* @__PURE__ */ (0,
|
|
1615
|
-
/* @__PURE__ */ (0,
|
|
1616
|
-
/* @__PURE__ */ (0,
|
|
1774
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-1.5", children: [
|
|
1775
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_label4.Label, { className: "text-sm", children: intl.formatMessage(messages5.max_level) }),
|
|
1776
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1617
1777
|
import_select2.Select,
|
|
1618
1778
|
{
|
|
1619
1779
|
size: "sm",
|
|
1620
1780
|
value: String(localAttrs.maxLevel),
|
|
1621
1781
|
onValueChange: handleMaxLevelChange,
|
|
1622
1782
|
children: [
|
|
1623
|
-
/* @__PURE__ */ (0,
|
|
1624
|
-
/* @__PURE__ */ (0,
|
|
1783
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_select2.Select.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_select2.Select.Value, {}) }),
|
|
1784
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_select2.Select.Content, { children: HEADING_LEVELS.map((level) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1625
1785
|
import_select2.Select.Item,
|
|
1626
1786
|
{
|
|
1627
1787
|
value: level.value,
|
|
@@ -1635,12 +1795,12 @@ function TocSettings({ editor, attrs, getPos }) {
|
|
|
1635
1795
|
)
|
|
1636
1796
|
] })
|
|
1637
1797
|
] }),
|
|
1638
|
-
/* @__PURE__ */ (0,
|
|
1639
|
-
/* @__PURE__ */ (0,
|
|
1640
|
-
/* @__PURE__ */ (0,
|
|
1641
|
-
/* @__PURE__ */ (0,
|
|
1798
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1799
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-0.5", children: [
|
|
1800
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_label4.Label, { className: "text-sm", children: intl.formatMessage(messages5.numbered) }),
|
|
1801
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-xs text-muted-foreground", children: intl.formatMessage(messages5.numbered_hint) })
|
|
1642
1802
|
] }),
|
|
1643
|
-
/* @__PURE__ */ (0,
|
|
1803
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1644
1804
|
import_switch.Switch,
|
|
1645
1805
|
{
|
|
1646
1806
|
size: "sm",
|
|
@@ -1649,36 +1809,36 @@ function TocSettings({ editor, attrs, getPos }) {
|
|
|
1649
1809
|
}
|
|
1650
1810
|
)
|
|
1651
1811
|
] }),
|
|
1652
|
-
/* @__PURE__ */ (0,
|
|
1653
|
-
/* @__PURE__ */ (0,
|
|
1654
|
-
/* @__PURE__ */ (0,
|
|
1812
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-1.5", children: [
|
|
1813
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_label4.Label, { className: "text-sm", children: intl.formatMessage(messages5.style) }),
|
|
1814
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1655
1815
|
import_select2.Select,
|
|
1656
1816
|
{
|
|
1657
1817
|
size: "sm",
|
|
1658
1818
|
value: localAttrs.style,
|
|
1659
1819
|
onValueChange: handleStyleChange,
|
|
1660
1820
|
children: [
|
|
1661
|
-
/* @__PURE__ */ (0,
|
|
1662
|
-
/* @__PURE__ */ (0,
|
|
1663
|
-
/* @__PURE__ */ (0,
|
|
1664
|
-
/* @__PURE__ */ (0,
|
|
1665
|
-
/* @__PURE__ */ (0,
|
|
1821
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_select2.Select.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_select2.Select.Value, {}) }),
|
|
1822
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_select2.Select.Content, { children: [
|
|
1823
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_select2.Select.Item, { value: "default", children: intl.formatMessage(messages5.style_default) }),
|
|
1824
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_select2.Select.Item, { value: "flat", children: intl.formatMessage(messages5.style_flat) }),
|
|
1825
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_select2.Select.Item, { value: "compact", children: intl.formatMessage(messages5.style_compact) })
|
|
1666
1826
|
] })
|
|
1667
1827
|
]
|
|
1668
1828
|
}
|
|
1669
1829
|
)
|
|
1670
1830
|
] })
|
|
1671
1831
|
] }) }),
|
|
1672
|
-
/* @__PURE__ */ (0,
|
|
1673
|
-
/* @__PURE__ */ (0,
|
|
1674
|
-
/* @__PURE__ */ (0,
|
|
1832
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_dialog4.Dialog.Footer, { children: [
|
|
1833
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_button6.Button, { variant: "ghost", onClick: handleCancel, children: intl.formatMessage(messages5.cancel) }),
|
|
1834
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_button6.Button, { onClick: handleSave, children: intl.formatMessage(messages5.save) })
|
|
1675
1835
|
] })
|
|
1676
1836
|
] }) })
|
|
1677
1837
|
] });
|
|
1678
1838
|
}
|
|
1679
1839
|
|
|
1680
1840
|
// src/extensions/toc/toc-view.tsx
|
|
1681
|
-
var
|
|
1841
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1682
1842
|
function generateHeadingNumbers(headings, minLevel) {
|
|
1683
1843
|
const counters = [0, 0, 0, 0, 0, 0];
|
|
1684
1844
|
return headings.map((heading) => {
|
|
@@ -1700,8 +1860,8 @@ function generateHeadingNumbers(headings, minLevel) {
|
|
|
1700
1860
|
});
|
|
1701
1861
|
}
|
|
1702
1862
|
function TocNodeView({ editor, node, getPos }) {
|
|
1703
|
-
const [headings, setHeadings] = (0,
|
|
1704
|
-
const intl = (0,
|
|
1863
|
+
const [headings, setHeadings] = (0, import_react20.useState)([]);
|
|
1864
|
+
const intl = (0, import_react_intl12.useIntl)();
|
|
1705
1865
|
const attrs = node.attrs;
|
|
1706
1866
|
const {
|
|
1707
1867
|
minLevel = 1,
|
|
@@ -1709,8 +1869,8 @@ function TocNodeView({ editor, node, getPos }) {
|
|
|
1709
1869
|
numbered = false,
|
|
1710
1870
|
style = "default"
|
|
1711
1871
|
} = attrs;
|
|
1712
|
-
const styles = (0,
|
|
1713
|
-
const updateHeadings = (0,
|
|
1872
|
+
const styles = (0, import_react20.useMemo)(() => (0, import_theme4.toc)({ style }), [style]);
|
|
1873
|
+
const updateHeadings = (0, import_react20.useCallback)(() => {
|
|
1714
1874
|
const items = [];
|
|
1715
1875
|
const { doc } = editor.state;
|
|
1716
1876
|
doc.descendants((docNode, pos) => {
|
|
@@ -1730,14 +1890,14 @@ function TocNodeView({ editor, node, getPos }) {
|
|
|
1730
1890
|
const numberedHeadings = generateHeadingNumbers(items, minLevel);
|
|
1731
1891
|
setHeadings(numberedHeadings);
|
|
1732
1892
|
}, [editor, minLevel, maxLevel]);
|
|
1733
|
-
(0,
|
|
1893
|
+
(0, import_react20.useEffect)(() => {
|
|
1734
1894
|
updateHeadings();
|
|
1735
1895
|
editor.on("update", updateHeadings);
|
|
1736
1896
|
return () => {
|
|
1737
1897
|
editor.off("update", updateHeadings);
|
|
1738
1898
|
};
|
|
1739
1899
|
}, [editor, updateHeadings]);
|
|
1740
|
-
const handleClick = (0,
|
|
1900
|
+
const handleClick = (0, import_react20.useCallback)(
|
|
1741
1901
|
(pos, id) => {
|
|
1742
1902
|
var _a;
|
|
1743
1903
|
editor.chain().focus().setTextSelection(pos).run();
|
|
@@ -1758,13 +1918,13 @@ function TocNodeView({ editor, node, getPos }) {
|
|
|
1758
1918
|
const getIndent = (level) => {
|
|
1759
1919
|
return (level - minLevel) * 16;
|
|
1760
1920
|
};
|
|
1761
|
-
return /* @__PURE__ */ (0,
|
|
1762
|
-
/* @__PURE__ */ (0,
|
|
1763
|
-
/* @__PURE__ */ (0,
|
|
1764
|
-
/* @__PURE__ */ (0,
|
|
1765
|
-
/* @__PURE__ */ (0,
|
|
1921
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react19.NodeViewWrapper, { className: styles.root(), "data-type": "toc", children: [
|
|
1922
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: styles.header(), children: [
|
|
1923
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: styles.headerContent(), children: [
|
|
1924
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons7.ListIcon, { className: styles.headerIcon() }),
|
|
1925
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: styles.headerTitle(), children: intl.formatMessage(messages5.title) })
|
|
1766
1926
|
] }),
|
|
1767
|
-
/* @__PURE__ */ (0,
|
|
1927
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: styles.headerActions(), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1768
1928
|
TocSettings,
|
|
1769
1929
|
{
|
|
1770
1930
|
editor,
|
|
@@ -1773,7 +1933,7 @@ function TocNodeView({ editor, node, getPos }) {
|
|
|
1773
1933
|
}
|
|
1774
1934
|
) })
|
|
1775
1935
|
] }),
|
|
1776
|
-
isEmpty ? /* @__PURE__ */ (0,
|
|
1936
|
+
isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: styles.emptyState(), children: intl.formatMessage(messages5.empty_state) }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("nav", { className: styles.nav(), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { className: styles.list(), children: headings.map((heading) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1777
1937
|
"li",
|
|
1778
1938
|
{
|
|
1779
1939
|
className: styles.item(),
|
|
@@ -1781,14 +1941,14 @@ function TocNodeView({ editor, node, getPos }) {
|
|
|
1781
1941
|
paddingLeft: `${getIndent(heading.level)}px`
|
|
1782
1942
|
},
|
|
1783
1943
|
children: [
|
|
1784
|
-
numbered && heading.number && /* @__PURE__ */ (0,
|
|
1785
|
-
/* @__PURE__ */ (0,
|
|
1944
|
+
numbered && heading.number && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: styles.itemNumber(), children: heading.number }),
|
|
1945
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1786
1946
|
"button",
|
|
1787
1947
|
{
|
|
1788
1948
|
type: "button",
|
|
1789
1949
|
onClick: () => handleClick(heading.pos, heading.id),
|
|
1790
1950
|
className: styles.itemButton(),
|
|
1791
|
-
children: heading.text || intl.formatMessage(
|
|
1951
|
+
children: heading.text || intl.formatMessage(messages5.empty_heading)
|
|
1792
1952
|
}
|
|
1793
1953
|
)
|
|
1794
1954
|
]
|
|
@@ -1857,7 +2017,7 @@ var TocNode = import_core5.Node.create({
|
|
|
1857
2017
|
];
|
|
1858
2018
|
},
|
|
1859
2019
|
addNodeView() {
|
|
1860
|
-
return (0,
|
|
2020
|
+
return (0, import_react21.ReactNodeViewRenderer)(TocNodeView);
|
|
1861
2021
|
},
|
|
1862
2022
|
addCommands() {
|
|
1863
2023
|
return {
|
|
@@ -1900,14 +2060,14 @@ var import_extension_text_style = require("@tiptap/extension-text-style");
|
|
|
1900
2060
|
var import_extension_typography = require("@tiptap/extension-typography");
|
|
1901
2061
|
var import_extension_unique_id = require("@tiptap/extension-unique-id");
|
|
1902
2062
|
var import_extensions = require("@tiptap/extensions");
|
|
1903
|
-
var
|
|
2063
|
+
var import_react25 = require("@tiptap/react");
|
|
1904
2064
|
var import_starter_kit = require("@tiptap/starter-kit");
|
|
1905
|
-
var
|
|
2065
|
+
var import_react26 = require("react");
|
|
1906
2066
|
|
|
1907
2067
|
// src/extensions/link/index.ts
|
|
1908
2068
|
var import_extension_link = __toESM(require("@tiptap/extension-link"));
|
|
1909
2069
|
var import_state = require("@tiptap/pm/state");
|
|
1910
|
-
var
|
|
2070
|
+
var import_react22 = require("@tiptap/react");
|
|
1911
2071
|
var Link = import_extension_link.default.extend({
|
|
1912
2072
|
inclusive: false,
|
|
1913
2073
|
parseHTML() {
|
|
@@ -1935,7 +2095,7 @@ var Link = import_extension_link.default.extend({
|
|
|
1935
2095
|
const { schema, doc, tr } = view.state;
|
|
1936
2096
|
let range;
|
|
1937
2097
|
if (schema.marks.link) {
|
|
1938
|
-
range = (0,
|
|
2098
|
+
range = (0, import_react22.getMarkRange)(doc.resolve(pos), schema.marks.link);
|
|
1939
2099
|
}
|
|
1940
2100
|
if (!range) {
|
|
1941
2101
|
return;
|
|
@@ -1962,8 +2122,8 @@ var Link = import_extension_link.default.extend({
|
|
|
1962
2122
|
// src/extensions/selection/index.ts
|
|
1963
2123
|
var import_state2 = require("@tiptap/pm/state");
|
|
1964
2124
|
var import_view = require("@tiptap/pm/view");
|
|
1965
|
-
var
|
|
1966
|
-
var Selection =
|
|
2125
|
+
var import_react23 = require("@tiptap/react");
|
|
2126
|
+
var Selection = import_react23.Extension.create({
|
|
1967
2127
|
name: "selection",
|
|
1968
2128
|
addProseMirrorPlugins() {
|
|
1969
2129
|
const { editor } = this;
|
|
@@ -1978,7 +2138,7 @@ var Selection = import_react20.Extension.create({
|
|
|
1978
2138
|
if (editor.isFocused === true || !editor.isEditable) {
|
|
1979
2139
|
return null;
|
|
1980
2140
|
}
|
|
1981
|
-
if ((0,
|
|
2141
|
+
if ((0, import_react23.isNodeSelection)(state.selection)) {
|
|
1982
2142
|
return null;
|
|
1983
2143
|
}
|
|
1984
2144
|
return import_view.DecorationSet.create(state.doc, [
|
|
@@ -1995,7 +2155,7 @@ var Selection = import_react20.Extension.create({
|
|
|
1995
2155
|
|
|
1996
2156
|
// src/extensions/trailing-node/index.ts
|
|
1997
2157
|
var import_state3 = require("@tiptap/pm/state");
|
|
1998
|
-
var
|
|
2158
|
+
var import_react24 = require("@tiptap/react");
|
|
1999
2159
|
function nodeEqualsType({
|
|
2000
2160
|
types,
|
|
2001
2161
|
node
|
|
@@ -2006,7 +2166,7 @@ function nodeEqualsType({
|
|
|
2006
2166
|
}
|
|
2007
2167
|
return node.type === types;
|
|
2008
2168
|
}
|
|
2009
|
-
var TrailingNode =
|
|
2169
|
+
var TrailingNode = import_react24.Extension.create({
|
|
2010
2170
|
name: "trailingNode",
|
|
2011
2171
|
addOptions() {
|
|
2012
2172
|
return {
|
|
@@ -2282,7 +2442,7 @@ var useCreateEditor = ({
|
|
|
2282
2442
|
}) => {
|
|
2283
2443
|
const fileHandlerFromContext = useEditorFile();
|
|
2284
2444
|
const fileHandler = fileHandlerProp != null ? fileHandlerProp : fileHandlerFromContext;
|
|
2285
|
-
const editor = (0,
|
|
2445
|
+
const editor = (0, import_react25.useEditor)({
|
|
2286
2446
|
editorProps: {
|
|
2287
2447
|
attributes: {
|
|
2288
2448
|
autocomplete: "off",
|
|
@@ -2307,7 +2467,7 @@ var useCreateEditor = ({
|
|
|
2307
2467
|
content: safeParseContent(content),
|
|
2308
2468
|
...options
|
|
2309
2469
|
});
|
|
2310
|
-
(0,
|
|
2470
|
+
(0, import_react26.useEffect)(() => {
|
|
2311
2471
|
if (editor && editor.isEditable !== editable) {
|
|
2312
2472
|
editor.setEditable(editable);
|
|
2313
2473
|
}
|
|
@@ -2371,8 +2531,12 @@ function getExtensions({
|
|
|
2371
2531
|
CalloutNode,
|
|
2372
2532
|
MathBlock,
|
|
2373
2533
|
InlineMath,
|
|
2374
|
-
// Image support -
|
|
2375
|
-
ImageNode
|
|
2534
|
+
// Image support - extended with file reference resolution
|
|
2535
|
+
ImageNode.configure({
|
|
2536
|
+
allowBase64: true
|
|
2537
|
+
}),
|
|
2538
|
+
// Image upload placeholder
|
|
2539
|
+
ImageUploadNode,
|
|
2376
2540
|
import_extensions.Placeholder.configure({
|
|
2377
2541
|
placeholder,
|
|
2378
2542
|
emptyNodeClass: "is-empty with-slash"
|
|
@@ -2465,19 +2629,19 @@ async function handleFileUpload(editor, file, fileHandler, pos) {
|
|
|
2465
2629
|
}
|
|
2466
2630
|
|
|
2467
2631
|
// src/presets/basic/index.tsx
|
|
2468
|
-
var
|
|
2469
|
-
var
|
|
2470
|
-
var
|
|
2632
|
+
var import_theme7 = require("@kopexa/theme");
|
|
2633
|
+
var import_react54 = require("@tiptap/react");
|
|
2634
|
+
var import_react55 = require("react");
|
|
2471
2635
|
|
|
2472
2636
|
// src/context/editor-context.ts
|
|
2473
2637
|
var import_react_utils = require("@kopexa/react-utils");
|
|
2474
2638
|
var [EditorUIProvider, useEditorUIContext] = (0, import_react_utils.createContext)();
|
|
2475
2639
|
|
|
2476
2640
|
// src/hooks/use-ui-editor-state.ts
|
|
2477
|
-
var
|
|
2641
|
+
var import_react27 = require("@tiptap/react");
|
|
2478
2642
|
function useUiEditorState(editor) {
|
|
2479
2643
|
var _a;
|
|
2480
|
-
return (_a = (0,
|
|
2644
|
+
return (_a = (0, import_react27.useEditorState)({
|
|
2481
2645
|
editor,
|
|
2482
2646
|
selector: ({ editor: editor2 }) => {
|
|
2483
2647
|
if (!editor2) return defaultUiState;
|
|
@@ -2498,23 +2662,23 @@ var import_toolbar3 = require("@kopexa/toolbar");
|
|
|
2498
2662
|
var import_menus = require("@tiptap/react/menus");
|
|
2499
2663
|
|
|
2500
2664
|
// src/ui/link-popover/link-popover.tsx
|
|
2501
|
-
var
|
|
2502
|
-
var
|
|
2665
|
+
var import_button7 = require("@kopexa/button");
|
|
2666
|
+
var import_icons9 = require("@kopexa/icons");
|
|
2503
2667
|
var import_input2 = require("@kopexa/input");
|
|
2504
2668
|
var import_popover = require("@kopexa/popover");
|
|
2505
2669
|
var import_toolbar = require("@kopexa/toolbar");
|
|
2506
|
-
var
|
|
2670
|
+
var import_react30 = require("react");
|
|
2507
2671
|
|
|
2508
2672
|
// src/hooks/use-tiptap-editor.ts
|
|
2509
|
-
var
|
|
2510
|
-
var
|
|
2673
|
+
var import_react28 = require("@tiptap/react");
|
|
2674
|
+
var import_react29 = require("react");
|
|
2511
2675
|
function useTiptapEditor(providedEditor) {
|
|
2512
|
-
const { editor: coreEditor } = (0,
|
|
2513
|
-
const mainEditor = (0,
|
|
2676
|
+
const { editor: coreEditor } = (0, import_react28.useCurrentEditor)();
|
|
2677
|
+
const mainEditor = (0, import_react29.useMemo)(
|
|
2514
2678
|
() => providedEditor || coreEditor,
|
|
2515
2679
|
[providedEditor, coreEditor]
|
|
2516
2680
|
);
|
|
2517
|
-
const editorState = (0,
|
|
2681
|
+
const editorState = (0, import_react28.useEditorState)({
|
|
2518
2682
|
editor: mainEditor,
|
|
2519
2683
|
selector(context) {
|
|
2520
2684
|
if (!context.editor) {
|
|
@@ -2536,7 +2700,7 @@ function useTiptapEditor(providedEditor) {
|
|
|
2536
2700
|
|
|
2537
2701
|
// src/ui/link-popover/use-link-popover.ts
|
|
2538
2702
|
var import_editor_utils = require("@kopexa/editor-utils");
|
|
2539
|
-
var
|
|
2703
|
+
var import_icons8 = require("@kopexa/icons");
|
|
2540
2704
|
var React = __toESM(require("react"));
|
|
2541
2705
|
|
|
2542
2706
|
// src/utils/index.ts
|
|
@@ -2755,15 +2919,15 @@ function useLinkPopover(config) {
|
|
|
2755
2919
|
canSet,
|
|
2756
2920
|
isActive,
|
|
2757
2921
|
label: "Link",
|
|
2758
|
-
Icon:
|
|
2922
|
+
Icon: import_icons8.LinkIcon,
|
|
2759
2923
|
...linkHandler
|
|
2760
2924
|
};
|
|
2761
2925
|
}
|
|
2762
2926
|
|
|
2763
2927
|
// src/ui/link-popover/link-popover.tsx
|
|
2764
|
-
var
|
|
2928
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2765
2929
|
var LinkButton = ({ className, children, ...props }) => {
|
|
2766
|
-
return /* @__PURE__ */ (0,
|
|
2930
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2767
2931
|
import_toolbar.ToolbarButton,
|
|
2768
2932
|
{
|
|
2769
2933
|
type: "button",
|
|
@@ -2775,7 +2939,7 @@ var LinkButton = ({ className, children, ...props }) => {
|
|
|
2775
2939
|
title: "Link",
|
|
2776
2940
|
isIconOnly: !children,
|
|
2777
2941
|
...props,
|
|
2778
|
-
children: children || /* @__PURE__ */ (0,
|
|
2942
|
+
children: children || /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons9.LinkIcon, {})
|
|
2779
2943
|
}
|
|
2780
2944
|
);
|
|
2781
2945
|
};
|
|
@@ -2788,8 +2952,8 @@ var LinkMain = ({
|
|
|
2788
2952
|
isActive,
|
|
2789
2953
|
onSave
|
|
2790
2954
|
}) => {
|
|
2791
|
-
const [isEditing, setIsEditing] = (0,
|
|
2792
|
-
(0,
|
|
2955
|
+
const [isEditing, setIsEditing] = (0, import_react30.useState)(!isActive || !url);
|
|
2956
|
+
(0, import_react30.useEffect)(() => {
|
|
2793
2957
|
setIsEditing(!isActive || !url);
|
|
2794
2958
|
}, [isActive, url]);
|
|
2795
2959
|
const handleKeyDown = (event) => {
|
|
@@ -2812,8 +2976,8 @@ var LinkMain = ({
|
|
|
2812
2976
|
setIsEditing(true);
|
|
2813
2977
|
};
|
|
2814
2978
|
if (isEditing) {
|
|
2815
|
-
return /* @__PURE__ */ (0,
|
|
2816
|
-
/* @__PURE__ */ (0,
|
|
2979
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center gap-1 min-w-[280px]", children: [
|
|
2980
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2817
2981
|
import_input2.Input,
|
|
2818
2982
|
{
|
|
2819
2983
|
type: "url",
|
|
@@ -2828,8 +2992,8 @@ var LinkMain = ({
|
|
|
2828
2992
|
autoFocus: true
|
|
2829
2993
|
}
|
|
2830
2994
|
),
|
|
2831
|
-
/* @__PURE__ */ (0,
|
|
2832
|
-
|
|
2995
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2996
|
+
import_button7.IconButton,
|
|
2833
2997
|
{
|
|
2834
2998
|
type: "button",
|
|
2835
2999
|
size: "sm",
|
|
@@ -2837,13 +3001,13 @@ var LinkMain = ({
|
|
|
2837
3001
|
onClick: handleSave,
|
|
2838
3002
|
"aria-label": "Save link",
|
|
2839
3003
|
disabled: !url,
|
|
2840
|
-
children: /* @__PURE__ */ (0,
|
|
3004
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons9.CheckIcon, { className: "size-4" })
|
|
2841
3005
|
}
|
|
2842
3006
|
)
|
|
2843
3007
|
] });
|
|
2844
3008
|
}
|
|
2845
|
-
return /* @__PURE__ */ (0,
|
|
2846
|
-
/* @__PURE__ */ (0,
|
|
3009
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center gap-1 min-w-[280px]", children: [
|
|
3010
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2847
3011
|
"a",
|
|
2848
3012
|
{
|
|
2849
3013
|
href: url,
|
|
@@ -2857,38 +3021,38 @@ var LinkMain = ({
|
|
|
2857
3021
|
children: url
|
|
2858
3022
|
}
|
|
2859
3023
|
),
|
|
2860
|
-
/* @__PURE__ */ (0,
|
|
2861
|
-
/* @__PURE__ */ (0,
|
|
2862
|
-
|
|
3024
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center gap-0.5 border-l pl-1 ml-1", children: [
|
|
3025
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3026
|
+
import_button7.IconButton,
|
|
2863
3027
|
{
|
|
2864
3028
|
type: "button",
|
|
2865
3029
|
size: "sm",
|
|
2866
3030
|
variant: "ghost",
|
|
2867
3031
|
onClick: openLink,
|
|
2868
3032
|
"aria-label": "Open link in new tab",
|
|
2869
|
-
children: /* @__PURE__ */ (0,
|
|
3033
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons9.ExternalLinkIcon, { className: "size-4" })
|
|
2870
3034
|
}
|
|
2871
3035
|
),
|
|
2872
|
-
/* @__PURE__ */ (0,
|
|
2873
|
-
|
|
3036
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3037
|
+
import_button7.IconButton,
|
|
2874
3038
|
{
|
|
2875
3039
|
type: "button",
|
|
2876
3040
|
size: "sm",
|
|
2877
3041
|
variant: "ghost",
|
|
2878
3042
|
onClick: handleEdit,
|
|
2879
3043
|
"aria-label": "Edit link",
|
|
2880
|
-
children: /* @__PURE__ */ (0,
|
|
3044
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons9.EditIcon, { className: "size-4" })
|
|
2881
3045
|
}
|
|
2882
3046
|
),
|
|
2883
|
-
/* @__PURE__ */ (0,
|
|
2884
|
-
|
|
3047
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3048
|
+
import_button7.IconButton,
|
|
2885
3049
|
{
|
|
2886
3050
|
type: "button",
|
|
2887
3051
|
size: "sm",
|
|
2888
3052
|
variant: "ghost",
|
|
2889
3053
|
onClick: removeLink,
|
|
2890
3054
|
"aria-label": "Remove link",
|
|
2891
|
-
children: /* @__PURE__ */ (0,
|
|
3055
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons9.TrashIcon, { className: "size-4" })
|
|
2892
3056
|
}
|
|
2893
3057
|
)
|
|
2894
3058
|
] })
|
|
@@ -2905,7 +3069,7 @@ function LinkPopover({
|
|
|
2905
3069
|
...buttonProps
|
|
2906
3070
|
}) {
|
|
2907
3071
|
const { editor } = useTiptapEditor(providedEditor);
|
|
2908
|
-
const [isOpen, setIsOpen] = (0,
|
|
3072
|
+
const [isOpen, setIsOpen] = (0, import_react30.useState)(false);
|
|
2909
3073
|
const {
|
|
2910
3074
|
isVisible,
|
|
2911
3075
|
canSet,
|
|
@@ -2921,18 +3085,18 @@ function LinkPopover({
|
|
|
2921
3085
|
hideWhenUnavailable,
|
|
2922
3086
|
onSetLink
|
|
2923
3087
|
});
|
|
2924
|
-
const handleOnOpenChange = (0,
|
|
3088
|
+
const handleOnOpenChange = (0, import_react30.useCallback)(
|
|
2925
3089
|
(nextIsOpen) => {
|
|
2926
3090
|
setIsOpen(nextIsOpen);
|
|
2927
3091
|
onOpenChange == null ? void 0 : onOpenChange(nextIsOpen);
|
|
2928
3092
|
},
|
|
2929
3093
|
[onOpenChange]
|
|
2930
3094
|
);
|
|
2931
|
-
const handleSetLink = (0,
|
|
3095
|
+
const handleSetLink = (0, import_react30.useCallback)(() => {
|
|
2932
3096
|
setLink();
|
|
2933
3097
|
setIsOpen(false);
|
|
2934
3098
|
}, [setLink]);
|
|
2935
|
-
const handleClick = (0,
|
|
3099
|
+
const handleClick = (0, import_react30.useCallback)(
|
|
2936
3100
|
(event) => {
|
|
2937
3101
|
onClick == null ? void 0 : onClick(event);
|
|
2938
3102
|
if (event.defaultPrevented) return;
|
|
@@ -2940,7 +3104,7 @@ function LinkPopover({
|
|
|
2940
3104
|
},
|
|
2941
3105
|
[onClick, isOpen]
|
|
2942
3106
|
);
|
|
2943
|
-
(0,
|
|
3107
|
+
(0, import_react30.useEffect)(() => {
|
|
2944
3108
|
if (autoOpenOnLinkActive && isActive) {
|
|
2945
3109
|
setIsOpen(true);
|
|
2946
3110
|
}
|
|
@@ -2948,17 +3112,17 @@ function LinkPopover({
|
|
|
2948
3112
|
if (!isVisible) {
|
|
2949
3113
|
return null;
|
|
2950
3114
|
}
|
|
2951
|
-
return /* @__PURE__ */ (0,
|
|
3115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
2952
3116
|
import_popover.Popover.Root,
|
|
2953
3117
|
{
|
|
2954
3118
|
open: isOpen,
|
|
2955
3119
|
onOpenChange: handleOnOpenChange,
|
|
2956
3120
|
spacing: "dense",
|
|
2957
3121
|
children: [
|
|
2958
|
-
/* @__PURE__ */ (0,
|
|
3122
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2959
3123
|
import_popover.Popover.Trigger,
|
|
2960
3124
|
{
|
|
2961
|
-
render: /* @__PURE__ */ (0,
|
|
3125
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2962
3126
|
LinkButton,
|
|
2963
3127
|
{
|
|
2964
3128
|
"data-disabled": !canSet,
|
|
@@ -2972,7 +3136,7 @@ function LinkPopover({
|
|
|
2972
3136
|
)
|
|
2973
3137
|
}
|
|
2974
3138
|
),
|
|
2975
|
-
/* @__PURE__ */ (0,
|
|
3139
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_popover.Popover.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2976
3140
|
LinkMain,
|
|
2977
3141
|
{
|
|
2978
3142
|
url,
|
|
@@ -2992,19 +3156,19 @@ LinkButton.displayName = "LinkButton";
|
|
|
2992
3156
|
|
|
2993
3157
|
// src/ui/mark-button/index.tsx
|
|
2994
3158
|
var import_editor_utils2 = require("@kopexa/editor-utils");
|
|
2995
|
-
var
|
|
3159
|
+
var import_icons10 = require("@kopexa/icons");
|
|
2996
3160
|
var import_toolbar2 = require("@kopexa/toolbar");
|
|
2997
|
-
var
|
|
2998
|
-
var
|
|
2999
|
-
var
|
|
3161
|
+
var import_react31 = require("@tiptap/react");
|
|
3162
|
+
var import_react32 = require("react");
|
|
3163
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
3000
3164
|
var markIcons = {
|
|
3001
|
-
bold:
|
|
3002
|
-
italic:
|
|
3003
|
-
underline:
|
|
3004
|
-
strike:
|
|
3005
|
-
code:
|
|
3006
|
-
superscript:
|
|
3007
|
-
subscript:
|
|
3165
|
+
bold: import_icons10.BoldIcon,
|
|
3166
|
+
italic: import_icons10.ItalicIcon,
|
|
3167
|
+
underline: import_icons10.UnderlineIcon,
|
|
3168
|
+
strike: import_icons10.StrikeIcon,
|
|
3169
|
+
code: import_icons10.CodeIcon,
|
|
3170
|
+
superscript: import_icons10.SuperscriptIcon,
|
|
3171
|
+
subscript: import_icons10.SubscriptIcon
|
|
3008
3172
|
};
|
|
3009
3173
|
var markShortcutKeys = {
|
|
3010
3174
|
bold: "mod+b",
|
|
@@ -3042,7 +3206,7 @@ function shouldShowMarkButton(params) {
|
|
|
3042
3206
|
return false;
|
|
3043
3207
|
}
|
|
3044
3208
|
if (hideWhenUnavailable) {
|
|
3045
|
-
if ((0,
|
|
3209
|
+
if ((0, import_react31.isNodeSelection)(editor.state.selection) || !canToggleMark(editor, type)) {
|
|
3046
3210
|
return false;
|
|
3047
3211
|
}
|
|
3048
3212
|
}
|
|
@@ -3087,7 +3251,7 @@ var MarkButton = ({
|
|
|
3087
3251
|
shortcutKey,
|
|
3088
3252
|
formattedName
|
|
3089
3253
|
} = useMarkState(editor, type, disabled);
|
|
3090
|
-
const handleClick = (0,
|
|
3254
|
+
const handleClick = (0, import_react32.useCallback)(
|
|
3091
3255
|
(e) => {
|
|
3092
3256
|
onClick == null ? void 0 : onClick(e);
|
|
3093
3257
|
if (!e.defaultPrevented && !isDisabled && editor) {
|
|
@@ -3096,7 +3260,7 @@ var MarkButton = ({
|
|
|
3096
3260
|
},
|
|
3097
3261
|
[onClick, isDisabled, editor, type]
|
|
3098
3262
|
);
|
|
3099
|
-
const show = (0,
|
|
3263
|
+
const show = (0, import_react32.useMemo)(() => {
|
|
3100
3264
|
return shouldShowMarkButton({
|
|
3101
3265
|
editor,
|
|
3102
3266
|
type,
|
|
@@ -3107,7 +3271,7 @@ var MarkButton = ({
|
|
|
3107
3271
|
if (!show || !editor || !editor.isEditable) {
|
|
3108
3272
|
return null;
|
|
3109
3273
|
}
|
|
3110
|
-
return /* @__PURE__ */ (0,
|
|
3274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3111
3275
|
import_toolbar2.ToolbarButton,
|
|
3112
3276
|
{
|
|
3113
3277
|
type: "button",
|
|
@@ -3125,18 +3289,18 @@ var MarkButton = ({
|
|
|
3125
3289
|
onClick: handleClick,
|
|
3126
3290
|
isIconOnly: true,
|
|
3127
3291
|
...buttonProps,
|
|
3128
|
-
children: /* @__PURE__ */ (0,
|
|
3292
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, {})
|
|
3129
3293
|
}
|
|
3130
3294
|
);
|
|
3131
3295
|
};
|
|
3132
3296
|
|
|
3133
3297
|
// src/ui/bubble-menu/index.tsx
|
|
3134
|
-
var
|
|
3298
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3135
3299
|
function BubbleMenu({ editor }) {
|
|
3136
3300
|
if (!editor) {
|
|
3137
3301
|
return null;
|
|
3138
3302
|
}
|
|
3139
|
-
return /* @__PURE__ */ (0,
|
|
3303
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3140
3304
|
import_menus.BubbleMenu,
|
|
3141
3305
|
{
|
|
3142
3306
|
editor,
|
|
@@ -3154,15 +3318,15 @@ function BubbleMenu({ editor }) {
|
|
|
3154
3318
|
offset: 8
|
|
3155
3319
|
},
|
|
3156
3320
|
className: "rounded-lg border bg-background shadow-md",
|
|
3157
|
-
children: /* @__PURE__ */ (0,
|
|
3158
|
-
/* @__PURE__ */ (0,
|
|
3159
|
-
/* @__PURE__ */ (0,
|
|
3160
|
-
/* @__PURE__ */ (0,
|
|
3161
|
-
/* @__PURE__ */ (0,
|
|
3162
|
-
/* @__PURE__ */ (0,
|
|
3321
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_toolbar3.Toolbar, { radius: "md", border: "none", className: "p-1", children: [
|
|
3322
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_toolbar3.ToolbarGroup, { children: [
|
|
3323
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MarkButton, { type: "bold" }),
|
|
3324
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MarkButton, { type: "italic" }),
|
|
3325
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MarkButton, { type: "strike" }),
|
|
3326
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MarkButton, { type: "code" })
|
|
3163
3327
|
] }),
|
|
3164
|
-
/* @__PURE__ */ (0,
|
|
3165
|
-
/* @__PURE__ */ (0,
|
|
3328
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_toolbar3.ToolbarSeparator, {}),
|
|
3329
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_toolbar3.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(LinkPopover, { autoOpenOnLinkActive: false }) })
|
|
3166
3330
|
] })
|
|
3167
3331
|
}
|
|
3168
3332
|
);
|
|
@@ -3174,7 +3338,7 @@ var React3 = __toESM(require("react"));
|
|
|
3174
3338
|
|
|
3175
3339
|
// src/hooks/use-floating-toolbar-visibility.ts
|
|
3176
3340
|
var import_state4 = require("@tiptap/pm/state");
|
|
3177
|
-
var
|
|
3341
|
+
var import_react33 = require("@tiptap/react");
|
|
3178
3342
|
var React2 = __toESM(require("react"));
|
|
3179
3343
|
var HIDE_FLOATING_META = "hideFloatingToolbar";
|
|
3180
3344
|
var selectNodeAndHideFloating = (editor, pos) => {
|
|
@@ -3272,41 +3436,41 @@ function useScrollToHash(config = {}) {
|
|
|
3272
3436
|
}
|
|
3273
3437
|
|
|
3274
3438
|
// src/ui/link-bubble/index.tsx
|
|
3275
|
-
var
|
|
3276
|
-
var
|
|
3439
|
+
var import_button8 = require("@kopexa/button");
|
|
3440
|
+
var import_icons11 = require("@kopexa/icons");
|
|
3277
3441
|
var import_input3 = require("@kopexa/input");
|
|
3278
3442
|
var import_menus2 = require("@tiptap/react/menus");
|
|
3279
|
-
var
|
|
3280
|
-
var
|
|
3443
|
+
var import_react34 = require("react");
|
|
3444
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3281
3445
|
function LinkBubble({ editor }) {
|
|
3282
|
-
const [isEditing, setIsEditing] = (0,
|
|
3283
|
-
const [url, setUrl] = (0,
|
|
3284
|
-
const getCurrentUrl = (0,
|
|
3446
|
+
const [isEditing, setIsEditing] = (0, import_react34.useState)(false);
|
|
3447
|
+
const [url, setUrl] = (0, import_react34.useState)("");
|
|
3448
|
+
const getCurrentUrl = (0, import_react34.useCallback)(() => {
|
|
3285
3449
|
if (!editor) return "";
|
|
3286
3450
|
const attrs = editor.getAttributes("link");
|
|
3287
3451
|
return attrs.href || "";
|
|
3288
3452
|
}, [editor]);
|
|
3289
|
-
(0,
|
|
3453
|
+
(0, import_react34.useEffect)(() => {
|
|
3290
3454
|
const isLinkActive2 = editor == null ? void 0 : editor.isActive("link");
|
|
3291
3455
|
if (isLinkActive2) {
|
|
3292
3456
|
setUrl(getCurrentUrl());
|
|
3293
3457
|
setIsEditing(false);
|
|
3294
3458
|
}
|
|
3295
3459
|
}, [editor, getCurrentUrl]);
|
|
3296
|
-
const handleOpenLink = (0,
|
|
3460
|
+
const handleOpenLink = (0, import_react34.useCallback)(() => {
|
|
3297
3461
|
const href = getCurrentUrl();
|
|
3298
3462
|
if (href) {
|
|
3299
3463
|
window.open(href, "_blank", "noopener,noreferrer");
|
|
3300
3464
|
}
|
|
3301
3465
|
}, [getCurrentUrl]);
|
|
3302
|
-
const handleRemoveLink = (0,
|
|
3466
|
+
const handleRemoveLink = (0, import_react34.useCallback)(() => {
|
|
3303
3467
|
editor == null ? void 0 : editor.chain().focus().unsetLink().run();
|
|
3304
3468
|
}, [editor]);
|
|
3305
|
-
const handleEdit = (0,
|
|
3469
|
+
const handleEdit = (0, import_react34.useCallback)(() => {
|
|
3306
3470
|
setUrl(getCurrentUrl());
|
|
3307
3471
|
setIsEditing(true);
|
|
3308
3472
|
}, [getCurrentUrl]);
|
|
3309
|
-
const handleSave = (0,
|
|
3473
|
+
const handleSave = (0, import_react34.useCallback)(() => {
|
|
3310
3474
|
if (url) {
|
|
3311
3475
|
editor == null ? void 0 : editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
|
|
3312
3476
|
} else {
|
|
@@ -3314,7 +3478,7 @@ function LinkBubble({ editor }) {
|
|
|
3314
3478
|
}
|
|
3315
3479
|
setIsEditing(false);
|
|
3316
3480
|
}, [editor, url]);
|
|
3317
|
-
const handleKeyDown = (0,
|
|
3481
|
+
const handleKeyDown = (0, import_react34.useCallback)(
|
|
3318
3482
|
(e) => {
|
|
3319
3483
|
if (e.key === "Enter") {
|
|
3320
3484
|
e.preventDefault();
|
|
@@ -3330,7 +3494,7 @@ function LinkBubble({ editor }) {
|
|
|
3330
3494
|
if (!editor) {
|
|
3331
3495
|
return null;
|
|
3332
3496
|
}
|
|
3333
|
-
return /* @__PURE__ */ (0,
|
|
3497
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3334
3498
|
import_menus2.BubbleMenu,
|
|
3335
3499
|
{
|
|
3336
3500
|
editor,
|
|
@@ -3343,8 +3507,8 @@ function LinkBubble({ editor }) {
|
|
|
3343
3507
|
offset: 8
|
|
3344
3508
|
},
|
|
3345
3509
|
className: "rounded-lg border bg-background shadow-md",
|
|
3346
|
-
children: /* @__PURE__ */ (0,
|
|
3347
|
-
/* @__PURE__ */ (0,
|
|
3510
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex items-center gap-1 p-1.5 min-w-[280px]", children: isEditing ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
3511
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3348
3512
|
import_input3.Input,
|
|
3349
3513
|
{
|
|
3350
3514
|
type: "url",
|
|
@@ -3356,19 +3520,19 @@ function LinkBubble({ editor }) {
|
|
|
3356
3520
|
autoFocus: true
|
|
3357
3521
|
}
|
|
3358
3522
|
),
|
|
3359
|
-
/* @__PURE__ */ (0,
|
|
3360
|
-
|
|
3523
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3524
|
+
import_button8.IconButton,
|
|
3361
3525
|
{
|
|
3362
3526
|
type: "button",
|
|
3363
3527
|
size: "sm",
|
|
3364
3528
|
variant: "ghost",
|
|
3365
3529
|
onClick: handleSave,
|
|
3366
3530
|
"aria-label": "Save link",
|
|
3367
|
-
children: /* @__PURE__ */ (0,
|
|
3531
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons11.EditIcon, { className: "size-4" })
|
|
3368
3532
|
}
|
|
3369
3533
|
)
|
|
3370
|
-
] }) : /* @__PURE__ */ (0,
|
|
3371
|
-
/* @__PURE__ */ (0,
|
|
3534
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
3535
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3372
3536
|
"a",
|
|
3373
3537
|
{
|
|
3374
3538
|
href: getCurrentUrl(),
|
|
@@ -3382,38 +3546,38 @@ function LinkBubble({ editor }) {
|
|
|
3382
3546
|
children: getCurrentUrl()
|
|
3383
3547
|
}
|
|
3384
3548
|
),
|
|
3385
|
-
/* @__PURE__ */ (0,
|
|
3386
|
-
/* @__PURE__ */ (0,
|
|
3387
|
-
|
|
3549
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-0.5 border-l pl-1 ml-1", children: [
|
|
3550
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3551
|
+
import_button8.IconButton,
|
|
3388
3552
|
{
|
|
3389
3553
|
type: "button",
|
|
3390
3554
|
size: "sm",
|
|
3391
3555
|
variant: "ghost",
|
|
3392
3556
|
onClick: handleOpenLink,
|
|
3393
3557
|
"aria-label": "Open link in new tab",
|
|
3394
|
-
children: /* @__PURE__ */ (0,
|
|
3558
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons11.ExternalLinkIcon, { className: "size-4" })
|
|
3395
3559
|
}
|
|
3396
3560
|
),
|
|
3397
|
-
/* @__PURE__ */ (0,
|
|
3398
|
-
|
|
3561
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3562
|
+
import_button8.IconButton,
|
|
3399
3563
|
{
|
|
3400
3564
|
type: "button",
|
|
3401
3565
|
size: "sm",
|
|
3402
3566
|
variant: "ghost",
|
|
3403
3567
|
onClick: handleEdit,
|
|
3404
3568
|
"aria-label": "Edit link",
|
|
3405
|
-
children: /* @__PURE__ */ (0,
|
|
3569
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons11.EditIcon, { className: "size-4" })
|
|
3406
3570
|
}
|
|
3407
3571
|
),
|
|
3408
|
-
/* @__PURE__ */ (0,
|
|
3409
|
-
|
|
3572
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3573
|
+
import_button8.IconButton,
|
|
3410
3574
|
{
|
|
3411
3575
|
type: "button",
|
|
3412
3576
|
size: "sm",
|
|
3413
3577
|
variant: "ghost",
|
|
3414
3578
|
onClick: handleRemoveLink,
|
|
3415
3579
|
"aria-label": "Remove link",
|
|
3416
|
-
children: /* @__PURE__ */ (0,
|
|
3580
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons11.TrashIcon, { className: "size-4" })
|
|
3417
3581
|
}
|
|
3418
3582
|
)
|
|
3419
3583
|
] })
|
|
@@ -3423,30 +3587,30 @@ function LinkBubble({ editor }) {
|
|
|
3423
3587
|
}
|
|
3424
3588
|
|
|
3425
3589
|
// src/ui/slash-dropdown-menu/slash-dropdown-menu.tsx
|
|
3426
|
-
var
|
|
3590
|
+
var import_button9 = require("@kopexa/button");
|
|
3427
3591
|
var import_editor_utils6 = require("@kopexa/editor-utils");
|
|
3428
3592
|
var import_separator = require("@kopexa/separator");
|
|
3429
|
-
var
|
|
3593
|
+
var import_theme5 = require("@kopexa/theme");
|
|
3430
3594
|
var React8 = __toESM(require("react"));
|
|
3431
3595
|
|
|
3432
3596
|
// src/ui/suggestion-menu/suggestion-menu.tsx
|
|
3433
|
-
var
|
|
3597
|
+
var import_react36 = require("@floating-ui/react");
|
|
3434
3598
|
var import_state5 = require("@tiptap/pm/state");
|
|
3435
3599
|
var import_suggestion = require("@tiptap/suggestion");
|
|
3436
3600
|
var React6 = __toESM(require("react"));
|
|
3437
3601
|
|
|
3438
3602
|
// src/hooks/use-floating-element.ts
|
|
3439
|
-
var
|
|
3603
|
+
var import_react35 = require("@floating-ui/react");
|
|
3440
3604
|
var React4 = __toESM(require("react"));
|
|
3441
3605
|
function useFloatingElement(show, referencePos, zIndex, options) {
|
|
3442
3606
|
const { dismissOptions, ...floatingOptions } = options || {};
|
|
3443
|
-
const { refs, update, context, floatingStyles } = (0,
|
|
3607
|
+
const { refs, update, context, floatingStyles } = (0, import_react35.useFloating)({
|
|
3444
3608
|
open: show,
|
|
3445
3609
|
...floatingOptions
|
|
3446
3610
|
});
|
|
3447
|
-
const { isMounted, styles } = (0,
|
|
3448
|
-
const dismiss = (0,
|
|
3449
|
-
const { getReferenceProps, getFloatingProps } = (0,
|
|
3611
|
+
const { isMounted, styles } = (0, import_react35.useTransitionStyles)(context);
|
|
3612
|
+
const dismiss = (0, import_react35.useDismiss)(context, dismissOptions);
|
|
3613
|
+
const { getReferenceProps, getFloatingProps } = (0, import_react35.useInteractions)([dismiss]);
|
|
3450
3614
|
React4.useEffect(() => {
|
|
3451
3615
|
update();
|
|
3452
3616
|
}, [referencePos, update]);
|
|
@@ -3654,7 +3818,7 @@ function filterSuggestionItems(items, query) {
|
|
|
3654
3818
|
}
|
|
3655
3819
|
|
|
3656
3820
|
// src/ui/suggestion-menu/suggestion-menu.tsx
|
|
3657
|
-
var
|
|
3821
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3658
3822
|
var SuggestionMenu = ({
|
|
3659
3823
|
editor: providedEditor,
|
|
3660
3824
|
floatingOptions,
|
|
@@ -3680,13 +3844,13 @@ var SuggestionMenu = ({
|
|
|
3680
3844
|
{
|
|
3681
3845
|
placement: "bottom-start",
|
|
3682
3846
|
middleware: [
|
|
3683
|
-
(0,
|
|
3684
|
-
(0,
|
|
3847
|
+
(0, import_react36.offset)(10),
|
|
3848
|
+
(0, import_react36.flip)({
|
|
3685
3849
|
mainAxis: true,
|
|
3686
3850
|
crossAxis: false
|
|
3687
3851
|
}),
|
|
3688
|
-
(0,
|
|
3689
|
-
(0,
|
|
3852
|
+
(0, import_react36.shift)(),
|
|
3853
|
+
(0, import_react36.size)({
|
|
3690
3854
|
apply({ availableHeight, elements }) {
|
|
3691
3855
|
if (elements.floating) {
|
|
3692
3856
|
const maxHeightValue = maxHeight ? Math.min(maxHeight, availableHeight) : availableHeight;
|
|
@@ -3825,7 +3989,7 @@ var SuggestionMenu = ({
|
|
|
3825
3989
|
if (!isMounted || !show || !editor) {
|
|
3826
3990
|
return null;
|
|
3827
3991
|
}
|
|
3828
|
-
return /* @__PURE__ */ (0,
|
|
3992
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3829
3993
|
"div",
|
|
3830
3994
|
{
|
|
3831
3995
|
ref,
|
|
@@ -3847,14 +4011,14 @@ var SuggestionMenu = ({
|
|
|
3847
4011
|
|
|
3848
4012
|
// src/ui/slash-dropdown-menu/use-slash-dropdown-menu.ts
|
|
3849
4013
|
var import_editor_utils5 = require("@kopexa/editor-utils");
|
|
3850
|
-
var
|
|
4014
|
+
var import_icons13 = require("@kopexa/icons");
|
|
3851
4015
|
var React7 = __toESM(require("react"));
|
|
3852
4016
|
|
|
3853
4017
|
// src/ui/table-button/use-table.ts
|
|
3854
4018
|
var import_editor_utils4 = require("@kopexa/editor-utils");
|
|
3855
|
-
var
|
|
3856
|
-
var
|
|
3857
|
-
var
|
|
4019
|
+
var import_icons12 = require("@kopexa/icons");
|
|
4020
|
+
var import_react37 = require("@tiptap/react");
|
|
4021
|
+
var import_react38 = require("react");
|
|
3858
4022
|
function canToggle(editor) {
|
|
3859
4023
|
if (!editor || !editor.isEditable) return false;
|
|
3860
4024
|
if (!(0, import_editor_utils4.isNodeInSchema)("table", editor) || (0, import_editor_utils4.isNodeTypeSelected)(editor, ["image"])) {
|
|
@@ -3885,7 +4049,7 @@ function shouldShowButton(props) {
|
|
|
3885
4049
|
if (!editor || !editor.isEditable) return false;
|
|
3886
4050
|
if (!(0, import_editor_utils4.isNodeInSchema)("table", editor)) return false;
|
|
3887
4051
|
if (hideWhenUnavailable) {
|
|
3888
|
-
if ((0,
|
|
4052
|
+
if ((0, import_react37.isNodeSelection)(editor.state.selection) || !canToggle) {
|
|
3889
4053
|
return false;
|
|
3890
4054
|
}
|
|
3891
4055
|
}
|
|
@@ -3898,10 +4062,10 @@ function useTableBlock(config) {
|
|
|
3898
4062
|
onToggled
|
|
3899
4063
|
} = config || {};
|
|
3900
4064
|
const { editor } = useTiptapEditor(providedEditor);
|
|
3901
|
-
const [isVisible, setIsVisible] = (0,
|
|
4065
|
+
const [isVisible, setIsVisible] = (0, import_react38.useState)(true);
|
|
3902
4066
|
const canToggleState = canToggle(editor);
|
|
3903
4067
|
const isActive = (editor == null ? void 0 : editor.isActive("table")) || false;
|
|
3904
|
-
(0,
|
|
4068
|
+
(0, import_react38.useEffect)(() => {
|
|
3905
4069
|
if (!editor) return;
|
|
3906
4070
|
const handleSelectionUpdate = () => {
|
|
3907
4071
|
setIsVisible(shouldShowButton({ editor, hideWhenUnavailable }));
|
|
@@ -3912,7 +4076,7 @@ function useTableBlock(config) {
|
|
|
3912
4076
|
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
3913
4077
|
};
|
|
3914
4078
|
}, [editor, hideWhenUnavailable]);
|
|
3915
|
-
const handleToggle = (0,
|
|
4079
|
+
const handleToggle = (0, import_react38.useCallback)(() => {
|
|
3916
4080
|
if (!editor) return false;
|
|
3917
4081
|
const success = toggleTable(editor);
|
|
3918
4082
|
if (success) {
|
|
@@ -3927,7 +4091,7 @@ function useTableBlock(config) {
|
|
|
3927
4091
|
canToggle: canToggleState,
|
|
3928
4092
|
label: "Table",
|
|
3929
4093
|
// shortcutKeys: CODE_BLOCK_SHORTCUT_KEY,
|
|
3930
|
-
Icon:
|
|
4094
|
+
Icon: import_icons12.TableIcon
|
|
3931
4095
|
};
|
|
3932
4096
|
}
|
|
3933
4097
|
|
|
@@ -3938,14 +4102,14 @@ var texts = {
|
|
|
3938
4102
|
title: "Continue Writing",
|
|
3939
4103
|
subtext: "Continue writing from the current position",
|
|
3940
4104
|
keywords: ["continue", "write", "continue writing", "ai"],
|
|
3941
|
-
badge:
|
|
4105
|
+
badge: import_icons13.AiSparklesIcon,
|
|
3942
4106
|
group: "AI"
|
|
3943
4107
|
},
|
|
3944
4108
|
ai_ask_button: {
|
|
3945
4109
|
title: "Ask AI",
|
|
3946
4110
|
subtext: "Ask AI to generate content",
|
|
3947
4111
|
keywords: ["ai", "ask", "generate"],
|
|
3948
|
-
badge:
|
|
4112
|
+
badge: import_icons13.AiSparklesIcon,
|
|
3949
4113
|
group: "AI"
|
|
3950
4114
|
},
|
|
3951
4115
|
// Style
|
|
@@ -3953,63 +4117,63 @@ var texts = {
|
|
|
3953
4117
|
title: "Text",
|
|
3954
4118
|
subtext: "Regular text paragraph",
|
|
3955
4119
|
keywords: ["p", "paragraph", "text"],
|
|
3956
|
-
badge:
|
|
4120
|
+
badge: import_icons13.TypeIcon,
|
|
3957
4121
|
group: "Style"
|
|
3958
4122
|
},
|
|
3959
4123
|
heading_1: {
|
|
3960
4124
|
title: "Heading 1",
|
|
3961
4125
|
subtext: "Top-level heading",
|
|
3962
4126
|
keywords: ["h", "heading1", "h1"],
|
|
3963
|
-
badge:
|
|
4127
|
+
badge: import_icons13.HeadingOneIcon,
|
|
3964
4128
|
group: "Style"
|
|
3965
4129
|
},
|
|
3966
4130
|
heading_2: {
|
|
3967
4131
|
title: "Heading 2",
|
|
3968
4132
|
subtext: "Key section heading",
|
|
3969
4133
|
keywords: ["h2", "heading2", "subheading"],
|
|
3970
|
-
badge:
|
|
4134
|
+
badge: import_icons13.HeadingTwoIcon,
|
|
3971
4135
|
group: "Style"
|
|
3972
4136
|
},
|
|
3973
4137
|
heading_3: {
|
|
3974
4138
|
title: "Heading 3",
|
|
3975
4139
|
subtext: "Subsection and group heading",
|
|
3976
4140
|
keywords: ["h3", "heading3", "subheading"],
|
|
3977
|
-
badge:
|
|
4141
|
+
badge: import_icons13.HeadingThreeIcon,
|
|
3978
4142
|
group: "Style"
|
|
3979
4143
|
},
|
|
3980
4144
|
bullet_list: {
|
|
3981
4145
|
title: "Bullet List",
|
|
3982
4146
|
subtext: "List with unordered items",
|
|
3983
4147
|
keywords: ["ul", "li", "list", "bulletlist", "bullet list"],
|
|
3984
|
-
badge:
|
|
4148
|
+
badge: import_icons13.ListIcon,
|
|
3985
4149
|
group: "Style"
|
|
3986
4150
|
},
|
|
3987
4151
|
ordered_list: {
|
|
3988
4152
|
title: "Numbered List",
|
|
3989
4153
|
subtext: "List with ordered items",
|
|
3990
4154
|
keywords: ["ol", "li", "list", "numberedlist", "numbered list"],
|
|
3991
|
-
badge:
|
|
4155
|
+
badge: import_icons13.ListOrderedIcon,
|
|
3992
4156
|
group: "Style"
|
|
3993
4157
|
},
|
|
3994
4158
|
task_list: {
|
|
3995
4159
|
title: "To-do list",
|
|
3996
4160
|
subtext: "List with tasks",
|
|
3997
4161
|
keywords: ["tasklist", "task list", "todo", "checklist"],
|
|
3998
|
-
badge:
|
|
4162
|
+
badge: import_icons13.ListTodoIcon,
|
|
3999
4163
|
group: "Style"
|
|
4000
4164
|
},
|
|
4001
4165
|
quote: {
|
|
4002
4166
|
title: "Blockquote",
|
|
4003
4167
|
subtext: "Blockquote block",
|
|
4004
4168
|
keywords: ["quote", "blockquote"],
|
|
4005
|
-
badge:
|
|
4169
|
+
badge: import_icons13.BlockquoteIcon,
|
|
4006
4170
|
group: "Style"
|
|
4007
4171
|
},
|
|
4008
4172
|
code_block: {
|
|
4009
4173
|
title: "Code Block",
|
|
4010
4174
|
subtext: "Code block with syntax highlighting",
|
|
4011
4175
|
keywords: ["code", "pre"],
|
|
4012
|
-
badge:
|
|
4176
|
+
badge: import_icons13.CodeBlockIcon,
|
|
4013
4177
|
group: "Style"
|
|
4014
4178
|
},
|
|
4015
4179
|
// Insert
|
|
@@ -4031,49 +4195,49 @@ var texts = {
|
|
|
4031
4195
|
title: "Control",
|
|
4032
4196
|
subtext: "Insert a control block",
|
|
4033
4197
|
keywords: ["control"],
|
|
4034
|
-
badge:
|
|
4198
|
+
badge: import_icons13.ControlsIcon,
|
|
4035
4199
|
group: "Insert"
|
|
4036
4200
|
},
|
|
4037
4201
|
divider: {
|
|
4038
4202
|
title: "Separator",
|
|
4039
4203
|
subtext: "Horizontal line to separate content",
|
|
4040
4204
|
keywords: ["hr", "horizontalRule", "line", "separator"],
|
|
4041
|
-
badge:
|
|
4205
|
+
badge: import_icons13.MinusIcon,
|
|
4042
4206
|
group: "Insert"
|
|
4043
4207
|
},
|
|
4044
4208
|
table: {
|
|
4045
4209
|
title: "Table",
|
|
4046
4210
|
subtext: "Insert a table",
|
|
4047
4211
|
keywords: ["table", "grid", "spreadsheet"],
|
|
4048
|
-
badge:
|
|
4212
|
+
badge: import_icons13.TableIcon,
|
|
4049
4213
|
group: "Insert"
|
|
4050
4214
|
},
|
|
4051
4215
|
table_of_contents: {
|
|
4052
4216
|
title: "Table of Contents",
|
|
4053
4217
|
subtext: "Auto-generated list of headings",
|
|
4054
4218
|
keywords: ["toc", "table of contents", "index", "navigation", "headings"],
|
|
4055
|
-
badge:
|
|
4219
|
+
badge: import_icons13.TableOfContentsIcon,
|
|
4056
4220
|
group: "Insert"
|
|
4057
4221
|
},
|
|
4058
4222
|
callout: {
|
|
4059
4223
|
title: "Callout",
|
|
4060
4224
|
subtext: "Highlighted block for important information",
|
|
4061
4225
|
keywords: ["callout", "info", "warning", "alert", "note", "tip"],
|
|
4062
|
-
badge:
|
|
4226
|
+
badge: import_icons13.InfoIcon,
|
|
4063
4227
|
group: "Insert"
|
|
4064
4228
|
},
|
|
4065
4229
|
callout_warning: {
|
|
4066
4230
|
title: "Warning",
|
|
4067
4231
|
subtext: "Warning callout block",
|
|
4068
4232
|
keywords: ["warning", "caution", "attention"],
|
|
4069
|
-
badge:
|
|
4233
|
+
badge: import_icons13.AlertIcon,
|
|
4070
4234
|
group: "Insert"
|
|
4071
4235
|
},
|
|
4072
4236
|
math: {
|
|
4073
4237
|
title: "Formula",
|
|
4074
4238
|
subtext: "LaTeX math formula block",
|
|
4075
4239
|
keywords: ["math", "latex", "formula", "equation", "katex"],
|
|
4076
|
-
badge:
|
|
4240
|
+
badge: import_icons13.TypeIcon,
|
|
4077
4241
|
group: "Insert"
|
|
4078
4242
|
},
|
|
4079
4243
|
// Upload
|
|
@@ -4089,7 +4253,7 @@ var texts = {
|
|
|
4089
4253
|
"media",
|
|
4090
4254
|
"url"
|
|
4091
4255
|
],
|
|
4092
|
-
badge:
|
|
4256
|
+
badge: import_icons13.ImageIcon,
|
|
4093
4257
|
group: "Upload"
|
|
4094
4258
|
}
|
|
4095
4259
|
};
|
|
@@ -4251,9 +4415,9 @@ Continue writing from where the text above ends. Write ONLY ONE SENTENCE. DONT R
|
|
|
4251
4415
|
},
|
|
4252
4416
|
// Upload
|
|
4253
4417
|
image: {
|
|
4254
|
-
check: (editor) => (0, import_editor_utils5.isNodeInSchema)("
|
|
4418
|
+
check: (editor) => (0, import_editor_utils5.isNodeInSchema)("imageUpload", editor),
|
|
4255
4419
|
action: ({ editor }) => {
|
|
4256
|
-
editor.chain().focus().
|
|
4420
|
+
editor.chain().focus().setImageUpload().run();
|
|
4257
4421
|
}
|
|
4258
4422
|
}
|
|
4259
4423
|
};
|
|
@@ -4314,11 +4478,11 @@ function useSlashDropdownMenu(config) {
|
|
|
4314
4478
|
}
|
|
4315
4479
|
|
|
4316
4480
|
// src/ui/slash-dropdown-menu/slash-dropdown-menu.tsx
|
|
4317
|
-
var
|
|
4481
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
4318
4482
|
var SlashDropdownMenu = (props) => {
|
|
4319
4483
|
const { config, ...restProps } = props;
|
|
4320
4484
|
const { getSlashMenuItems } = useSlashDropdownMenu(config);
|
|
4321
|
-
return /* @__PURE__ */ (0,
|
|
4485
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4322
4486
|
SuggestionMenu,
|
|
4323
4487
|
{
|
|
4324
4488
|
char: "/",
|
|
@@ -4328,7 +4492,7 @@ var SlashDropdownMenu = (props) => {
|
|
|
4328
4492
|
selector: "tiptap-slash-dropdown-menu",
|
|
4329
4493
|
items: ({ query, editor }) => filterSuggestionItems(getSlashMenuItems(editor), query),
|
|
4330
4494
|
...restProps,
|
|
4331
|
-
children: (props2) => /* @__PURE__ */ (0,
|
|
4495
|
+
children: (props2) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(List, { ...props2, config })
|
|
4332
4496
|
}
|
|
4333
4497
|
);
|
|
4334
4498
|
};
|
|
@@ -4348,13 +4512,13 @@ var Item = (props) => {
|
|
|
4348
4512
|
}
|
|
4349
4513
|
}, [isSelected]);
|
|
4350
4514
|
const BadgeIcon = item.badge;
|
|
4351
|
-
return /* @__PURE__ */ (0,
|
|
4352
|
-
|
|
4515
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4516
|
+
import_button9.Button,
|
|
4353
4517
|
{
|
|
4354
4518
|
ref: itemRef,
|
|
4355
4519
|
variant: "ghost",
|
|
4356
4520
|
color: "default",
|
|
4357
|
-
startContent: BadgeIcon && /* @__PURE__ */ (0,
|
|
4521
|
+
startContent: BadgeIcon && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(BadgeIcon, {}),
|
|
4358
4522
|
"data-active-state": isSelected ? "on" : "off",
|
|
4359
4523
|
onClick: onSelect,
|
|
4360
4524
|
fullWidth: true,
|
|
@@ -4369,14 +4533,14 @@ var List = ({
|
|
|
4369
4533
|
onSelect,
|
|
4370
4534
|
config
|
|
4371
4535
|
}) => {
|
|
4372
|
-
const styles = (0,
|
|
4536
|
+
const styles = (0, import_theme5.slashDropdownMenu)();
|
|
4373
4537
|
const renderedItems = React8.useMemo(() => {
|
|
4374
4538
|
const rendered = [];
|
|
4375
4539
|
const showGroups = (config == null ? void 0 : config.showGroups) !== false;
|
|
4376
4540
|
if (!showGroups) {
|
|
4377
4541
|
items.forEach((item, index) => {
|
|
4378
4542
|
rendered.push(
|
|
4379
|
-
/* @__PURE__ */ (0,
|
|
4543
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4380
4544
|
Item,
|
|
4381
4545
|
{
|
|
4382
4546
|
item,
|
|
@@ -4401,7 +4565,7 @@ var List = ({
|
|
|
4401
4565
|
Object.entries(groups).forEach(([groupLabel, groupData], groupIndex) => {
|
|
4402
4566
|
if (groupIndex > 0) {
|
|
4403
4567
|
rendered.push(
|
|
4404
|
-
/* @__PURE__ */ (0,
|
|
4568
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4405
4569
|
import_separator.Separator,
|
|
4406
4570
|
{
|
|
4407
4571
|
orientation: "horizontal"
|
|
@@ -4412,7 +4576,7 @@ var List = ({
|
|
|
4412
4576
|
}
|
|
4413
4577
|
const groupItems = groupData.items.map((item, itemIndex) => {
|
|
4414
4578
|
const originalIndex = groupData.indices[itemIndex];
|
|
4415
|
-
return /* @__PURE__ */ (0,
|
|
4579
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4416
4580
|
Item,
|
|
4417
4581
|
{
|
|
4418
4582
|
item,
|
|
@@ -4424,13 +4588,13 @@ var List = ({
|
|
|
4424
4588
|
});
|
|
4425
4589
|
if (groupLabel) {
|
|
4426
4590
|
rendered.push(
|
|
4427
|
-
/* @__PURE__ */ (0,
|
|
4591
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
4428
4592
|
"div",
|
|
4429
4593
|
{
|
|
4430
4594
|
className: styles.cardItemGroup(),
|
|
4431
4595
|
children: [
|
|
4432
|
-
/* @__PURE__ */ (0,
|
|
4433
|
-
/* @__PURE__ */ (0,
|
|
4596
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: styles.cardGroupLabel(), children: groupLabel }),
|
|
4597
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: styles.cardGroup(), children: groupItems })
|
|
4434
4598
|
]
|
|
4435
4599
|
},
|
|
4436
4600
|
`group-${groupIndex}-${groupLabel}`
|
|
@@ -4445,24 +4609,24 @@ var List = ({
|
|
|
4445
4609
|
if (!renderedItems.length) {
|
|
4446
4610
|
return null;
|
|
4447
4611
|
}
|
|
4448
|
-
return /* @__PURE__ */ (0,
|
|
4612
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4449
4613
|
"div",
|
|
4450
4614
|
{
|
|
4451
4615
|
className: styles.card(),
|
|
4452
4616
|
style: {
|
|
4453
4617
|
maxHeight: "var(--suggestion-menu-max-height)"
|
|
4454
4618
|
},
|
|
4455
|
-
children: /* @__PURE__ */ (0,
|
|
4619
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: styles.body(), children: renderedItems })
|
|
4456
4620
|
}
|
|
4457
4621
|
);
|
|
4458
4622
|
};
|
|
4459
4623
|
|
|
4460
4624
|
// src/presets/basic/editor-header.tsx
|
|
4461
|
-
var
|
|
4625
|
+
var import_icons25 = require("@kopexa/icons");
|
|
4462
4626
|
var import_popover3 = require("@kopexa/popover");
|
|
4463
4627
|
var import_toolbar10 = require("@kopexa/toolbar");
|
|
4464
4628
|
var import_use_is_mobile2 = require("@kopexa/use-is-mobile");
|
|
4465
|
-
var
|
|
4629
|
+
var import_react53 = require("react");
|
|
4466
4630
|
|
|
4467
4631
|
// src/hooks/use-cursor-visibility.ts
|
|
4468
4632
|
var React10 = __toESM(require("react"));
|
|
@@ -4572,7 +4736,7 @@ var React12 = __toESM(require("react"));
|
|
|
4572
4736
|
|
|
4573
4737
|
// src/ui/blockquote-button/use-blockquote.ts
|
|
4574
4738
|
var import_editor_utils7 = require("@kopexa/editor-utils");
|
|
4575
|
-
var
|
|
4739
|
+
var import_icons14 = require("@kopexa/icons");
|
|
4576
4740
|
var import_state6 = require("@tiptap/pm/state");
|
|
4577
4741
|
var React11 = __toESM(require("react"));
|
|
4578
4742
|
var BLOCKQUOTE_SHORTCUT_KEY = "mod+shift+b";
|
|
@@ -4680,12 +4844,12 @@ function useBlockquote(config) {
|
|
|
4680
4844
|
canToggle: canToggle3,
|
|
4681
4845
|
label: "Blockquote",
|
|
4682
4846
|
shortcutKeys: BLOCKQUOTE_SHORTCUT_KEY,
|
|
4683
|
-
Icon:
|
|
4847
|
+
Icon: import_icons14.BlockquoteIcon
|
|
4684
4848
|
};
|
|
4685
4849
|
}
|
|
4686
4850
|
|
|
4687
4851
|
// src/ui/blockquote-button/blockquote-button.tsx
|
|
4688
|
-
var
|
|
4852
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
4689
4853
|
var BlockquoteButton = ({
|
|
4690
4854
|
editor: providedEditor,
|
|
4691
4855
|
text,
|
|
@@ -4721,7 +4885,7 @@ var BlockquoteButton = ({
|
|
|
4721
4885
|
if (!isVisible) {
|
|
4722
4886
|
return null;
|
|
4723
4887
|
}
|
|
4724
|
-
return /* @__PURE__ */ (0,
|
|
4888
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
4725
4889
|
import_toolbar4.ToolbarButton,
|
|
4726
4890
|
{
|
|
4727
4891
|
type: "button",
|
|
@@ -4738,22 +4902,22 @@ var BlockquoteButton = ({
|
|
|
4738
4902
|
onClick: handleClick,
|
|
4739
4903
|
isIconOnly: !text && !children,
|
|
4740
4904
|
...buttonProps,
|
|
4741
|
-
children: children != null ? children : /* @__PURE__ */ (0,
|
|
4742
|
-
/* @__PURE__ */ (0,
|
|
4743
|
-
text && /* @__PURE__ */ (0,
|
|
4905
|
+
children: children != null ? children : /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
4906
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, {}),
|
|
4907
|
+
text && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { children: text })
|
|
4744
4908
|
] })
|
|
4745
4909
|
}
|
|
4746
4910
|
);
|
|
4747
4911
|
};
|
|
4748
4912
|
|
|
4749
4913
|
// src/ui/codeblock-button/code-block-button.tsx
|
|
4750
|
-
var
|
|
4914
|
+
var import_icons16 = require("@kopexa/icons");
|
|
4751
4915
|
var import_toolbar5 = require("@kopexa/toolbar");
|
|
4752
|
-
var
|
|
4916
|
+
var import_react39 = require("react");
|
|
4753
4917
|
|
|
4754
4918
|
// src/ui/codeblock-button/use-code-block.ts
|
|
4755
4919
|
var import_editor_utils8 = require("@kopexa/editor-utils");
|
|
4756
|
-
var
|
|
4920
|
+
var import_icons15 = require("@kopexa/icons");
|
|
4757
4921
|
var import_state7 = require("@tiptap/pm/state");
|
|
4758
4922
|
var React13 = __toESM(require("react"));
|
|
4759
4923
|
var CODE_BLOCK_SHORTCUT_KEY = "mod+alt+c";
|
|
@@ -4861,12 +5025,12 @@ function useCodeBlock(config) {
|
|
|
4861
5025
|
canToggle: canToggleState,
|
|
4862
5026
|
label: "Code Block",
|
|
4863
5027
|
shortcutKeys: CODE_BLOCK_SHORTCUT_KEY,
|
|
4864
|
-
Icon:
|
|
5028
|
+
Icon: import_icons15.CodeblockIcon
|
|
4865
5029
|
};
|
|
4866
5030
|
}
|
|
4867
5031
|
|
|
4868
5032
|
// src/ui/codeblock-button/code-block-button.tsx
|
|
4869
|
-
var
|
|
5033
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
4870
5034
|
var CodeBlockButton = ({
|
|
4871
5035
|
editor: providedEditor,
|
|
4872
5036
|
text,
|
|
@@ -4883,7 +5047,7 @@ var CodeBlockButton = ({
|
|
|
4883
5047
|
hideWhenUnavailable,
|
|
4884
5048
|
onToggled
|
|
4885
5049
|
});
|
|
4886
|
-
const handleClick = (0,
|
|
5050
|
+
const handleClick = (0, import_react39.useCallback)(
|
|
4887
5051
|
(event) => {
|
|
4888
5052
|
onClick == null ? void 0 : onClick(event);
|
|
4889
5053
|
if (event.defaultPrevented) return;
|
|
@@ -4894,7 +5058,7 @@ var CodeBlockButton = ({
|
|
|
4894
5058
|
if (!isVisible) {
|
|
4895
5059
|
return null;
|
|
4896
5060
|
}
|
|
4897
|
-
return /* @__PURE__ */ (0,
|
|
5061
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4898
5062
|
import_toolbar5.ToolbarButton,
|
|
4899
5063
|
{
|
|
4900
5064
|
type: "button",
|
|
@@ -4911,26 +5075,26 @@ var CodeBlockButton = ({
|
|
|
4911
5075
|
onClick: handleClick,
|
|
4912
5076
|
isIconOnly: true,
|
|
4913
5077
|
...buttonProps,
|
|
4914
|
-
children: /* @__PURE__ */ (0,
|
|
5078
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_icons16.CodeblockIcon, {})
|
|
4915
5079
|
}
|
|
4916
5080
|
);
|
|
4917
5081
|
};
|
|
4918
5082
|
|
|
4919
5083
|
// src/ui/color-highlight-popover/color-highlight-popover.tsx
|
|
4920
|
-
var
|
|
4921
|
-
var
|
|
5084
|
+
var import_button10 = require("@kopexa/button");
|
|
5085
|
+
var import_icons18 = require("@kopexa/icons");
|
|
4922
5086
|
var import_popover2 = require("@kopexa/popover");
|
|
4923
5087
|
var import_toolbar7 = require("@kopexa/toolbar");
|
|
4924
|
-
var
|
|
5088
|
+
var import_react41 = require("react");
|
|
4925
5089
|
|
|
4926
5090
|
// src/ui/color-highlight-button/color-highlight-button.tsx
|
|
4927
|
-
var
|
|
5091
|
+
var import_theme6 = require("@kopexa/theme");
|
|
4928
5092
|
var import_toolbar6 = require("@kopexa/toolbar");
|
|
4929
|
-
var
|
|
5093
|
+
var import_react40 = require("react");
|
|
4930
5094
|
|
|
4931
5095
|
// src/ui/color-highlight-button/use-color-highlight.ts
|
|
4932
5096
|
var import_editor_utils9 = require("@kopexa/editor-utils");
|
|
4933
|
-
var
|
|
5097
|
+
var import_icons17 = require("@kopexa/icons");
|
|
4934
5098
|
var import_use_is_mobile = require("@kopexa/use-is-mobile");
|
|
4935
5099
|
var React14 = __toESM(require("react"));
|
|
4936
5100
|
var import_react_hotkeys_hook = require("react-hotkeys-hook");
|
|
@@ -5087,12 +5251,12 @@ function useColorHighlight(config) {
|
|
|
5087
5251
|
canColorHighlight: canColorHighlightState,
|
|
5088
5252
|
label: label || `Highlight`,
|
|
5089
5253
|
shortcutKeys: COLOR_HIGHLIGHT_SHORTCUT_KEY,
|
|
5090
|
-
Icon:
|
|
5254
|
+
Icon: import_icons17.HighlighterIcon
|
|
5091
5255
|
};
|
|
5092
5256
|
}
|
|
5093
5257
|
|
|
5094
5258
|
// src/ui/color-highlight-button/color-highlight-button.tsx
|
|
5095
|
-
var
|
|
5259
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
5096
5260
|
var ColorHighlightButton = ({
|
|
5097
5261
|
editor: providedEditor,
|
|
5098
5262
|
highlightColor,
|
|
@@ -5121,7 +5285,7 @@ var ColorHighlightButton = ({
|
|
|
5121
5285
|
hideWhenUnavailable,
|
|
5122
5286
|
onApplied
|
|
5123
5287
|
});
|
|
5124
|
-
const handleClick = (0,
|
|
5288
|
+
const handleClick = (0, import_react40.useCallback)(
|
|
5125
5289
|
(event) => {
|
|
5126
5290
|
onClick == null ? void 0 : onClick(event);
|
|
5127
5291
|
if (event.defaultPrevented) return;
|
|
@@ -5129,7 +5293,7 @@ var ColorHighlightButton = ({
|
|
|
5129
5293
|
},
|
|
5130
5294
|
[handleColorHighlight, onClick]
|
|
5131
5295
|
);
|
|
5132
|
-
const buttonStyle = (0,
|
|
5296
|
+
const buttonStyle = (0, import_react40.useMemo)(
|
|
5133
5297
|
() => ({
|
|
5134
5298
|
...style,
|
|
5135
5299
|
"--highlight-color": highlightColor
|
|
@@ -5139,8 +5303,8 @@ var ColorHighlightButton = ({
|
|
|
5139
5303
|
if (!isVisible) {
|
|
5140
5304
|
return null;
|
|
5141
5305
|
}
|
|
5142
|
-
const styles = (0,
|
|
5143
|
-
return /* @__PURE__ */ (0,
|
|
5306
|
+
const styles = (0, import_theme6.colorHighlightButton)();
|
|
5307
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
5144
5308
|
import_toolbar6.ToolbarButton,
|
|
5145
5309
|
{
|
|
5146
5310
|
type: "button",
|
|
@@ -5159,15 +5323,15 @@ var ColorHighlightButton = ({
|
|
|
5159
5323
|
isIconOnly: true,
|
|
5160
5324
|
...buttonProps,
|
|
5161
5325
|
children: [
|
|
5162
|
-
/* @__PURE__ */ (0,
|
|
5326
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
5163
5327
|
"span",
|
|
5164
5328
|
{
|
|
5165
5329
|
"data-active-state": isActive ? "on" : "off",
|
|
5166
5330
|
className: styles.mark()
|
|
5167
5331
|
}
|
|
5168
5332
|
),
|
|
5169
|
-
children || /* @__PURE__ */ (0,
|
|
5170
|
-
/* @__PURE__ */ (0,
|
|
5333
|
+
children || /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
5334
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
5171
5335
|
"span",
|
|
5172
5336
|
{
|
|
5173
5337
|
style: { "--highlight-color": highlightColor }
|
|
@@ -5181,13 +5345,13 @@ var ColorHighlightButton = ({
|
|
|
5181
5345
|
};
|
|
5182
5346
|
|
|
5183
5347
|
// src/ui/color-highlight-popover/color-highlight-popover.tsx
|
|
5184
|
-
var
|
|
5348
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
5185
5349
|
var ColorHighlightPopoverButton = ({
|
|
5186
5350
|
className,
|
|
5187
5351
|
children,
|
|
5188
5352
|
...props
|
|
5189
|
-
}) => /* @__PURE__ */ (0,
|
|
5190
|
-
|
|
5353
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5354
|
+
import_button10.IconButton,
|
|
5191
5355
|
{
|
|
5192
5356
|
type: "button",
|
|
5193
5357
|
className,
|
|
@@ -5198,7 +5362,7 @@ var ColorHighlightPopoverButton = ({
|
|
|
5198
5362
|
tooltip: "Highlight",
|
|
5199
5363
|
isIconOnly: !children,
|
|
5200
5364
|
...props,
|
|
5201
|
-
children: children != null ? children : /* @__PURE__ */ (0,
|
|
5365
|
+
children: children != null ? children : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_icons18.HighlighterIcon, {})
|
|
5202
5366
|
}
|
|
5203
5367
|
);
|
|
5204
5368
|
function ColorHighlightPopoverContent({
|
|
@@ -5212,8 +5376,8 @@ function ColorHighlightPopoverContent({
|
|
|
5212
5376
|
])
|
|
5213
5377
|
}) {
|
|
5214
5378
|
const { handleRemoveHighlight } = useColorHighlight({ editor });
|
|
5215
|
-
const containerRef = (0,
|
|
5216
|
-
const menuItems = (0,
|
|
5379
|
+
const containerRef = (0, import_react41.useRef)(null);
|
|
5380
|
+
const menuItems = (0, import_react41.useMemo)(
|
|
5217
5381
|
() => [...colors, { label: "Remove highlight", value: "none" }],
|
|
5218
5382
|
[colors]
|
|
5219
5383
|
);
|
|
@@ -5231,13 +5395,13 @@ function ColorHighlightPopoverContent({
|
|
|
5231
5395
|
},
|
|
5232
5396
|
autoSelectFirstItem: false
|
|
5233
5397
|
});
|
|
5234
|
-
return /* @__PURE__ */ (0,
|
|
5235
|
-
/* @__PURE__ */ (0,
|
|
5398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { ref: containerRef, className: "flex gap-1 items-center", children: [
|
|
5399
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5236
5400
|
"div",
|
|
5237
5401
|
{
|
|
5238
5402
|
className: "flex items-center gap-1 outline-none",
|
|
5239
5403
|
"data-orientation": "horizontal",
|
|
5240
|
-
children: colors.map((color, index) => /* @__PURE__ */ (0,
|
|
5404
|
+
children: colors.map((color, index) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5241
5405
|
ColorHighlightButton,
|
|
5242
5406
|
{
|
|
5243
5407
|
editor,
|
|
@@ -5250,9 +5414,9 @@ function ColorHighlightPopoverContent({
|
|
|
5250
5414
|
))
|
|
5251
5415
|
}
|
|
5252
5416
|
),
|
|
5253
|
-
/* @__PURE__ */ (0,
|
|
5254
|
-
/* @__PURE__ */ (0,
|
|
5255
|
-
|
|
5417
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_toolbar7.ToolbarSeparator, { orientation: "vertical" }),
|
|
5418
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "tiptap-button-group", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5419
|
+
import_button10.IconButton,
|
|
5256
5420
|
{
|
|
5257
5421
|
onClick: handleRemoveHighlight,
|
|
5258
5422
|
"aria-label": "Remove highlight",
|
|
@@ -5262,7 +5426,7 @@ function ColorHighlightPopoverContent({
|
|
|
5262
5426
|
variant: "ghost",
|
|
5263
5427
|
color: "default",
|
|
5264
5428
|
"data-highlighted": selectedIndex === colors.length,
|
|
5265
|
-
children: /* @__PURE__ */ (0,
|
|
5429
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_icons18.BanIcon, {})
|
|
5266
5430
|
}
|
|
5267
5431
|
) })
|
|
5268
5432
|
] });
|
|
@@ -5281,18 +5445,18 @@ function ColorHighlightPopover({
|
|
|
5281
5445
|
...props
|
|
5282
5446
|
}) {
|
|
5283
5447
|
const { editor } = useTiptapEditor(providedEditor);
|
|
5284
|
-
const [isOpen, setIsOpen] = (0,
|
|
5448
|
+
const [isOpen, setIsOpen] = (0, import_react41.useState)(false);
|
|
5285
5449
|
const { isVisible, canColorHighlight: canColorHighlight2, isActive, label } = useColorHighlight({
|
|
5286
5450
|
editor,
|
|
5287
5451
|
hideWhenUnavailable,
|
|
5288
5452
|
onApplied
|
|
5289
5453
|
});
|
|
5290
5454
|
if (!isVisible) return null;
|
|
5291
|
-
return /* @__PURE__ */ (0,
|
|
5292
|
-
/* @__PURE__ */ (0,
|
|
5455
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_popover2.Popover.Root, { open: isOpen, onOpenChange: setIsOpen, spacing: "dense", children: [
|
|
5456
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5293
5457
|
import_popover2.Popover.Trigger,
|
|
5294
5458
|
{
|
|
5295
|
-
render: /* @__PURE__ */ (0,
|
|
5459
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5296
5460
|
ColorHighlightPopoverButton,
|
|
5297
5461
|
{
|
|
5298
5462
|
disabled: !canColorHighlight2,
|
|
@@ -5306,26 +5470,26 @@ function ColorHighlightPopover({
|
|
|
5306
5470
|
)
|
|
5307
5471
|
}
|
|
5308
5472
|
),
|
|
5309
|
-
/* @__PURE__ */ (0,
|
|
5473
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_popover2.Popover.Content, { "aria-label": "Highlight colors", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ColorHighlightPopoverContent, { editor, colors }) })
|
|
5310
5474
|
] });
|
|
5311
5475
|
}
|
|
5312
5476
|
|
|
5313
5477
|
// src/ui/heading-dropdown-menu/index.tsx
|
|
5314
|
-
var
|
|
5478
|
+
var import_button12 = require("@kopexa/button");
|
|
5315
5479
|
var import_dropdown_menu = require("@kopexa/dropdown-menu");
|
|
5316
5480
|
var import_editor_utils11 = require("@kopexa/editor-utils");
|
|
5317
|
-
var
|
|
5318
|
-
var
|
|
5481
|
+
var import_icons20 = require("@kopexa/icons");
|
|
5482
|
+
var import_react43 = require("@tiptap/react");
|
|
5319
5483
|
var React16 = __toESM(require("react"));
|
|
5320
5484
|
|
|
5321
5485
|
// src/ui/heading-button/index.tsx
|
|
5322
|
-
var
|
|
5486
|
+
var import_button11 = require("@kopexa/button");
|
|
5323
5487
|
var import_editor_utils10 = require("@kopexa/editor-utils");
|
|
5324
|
-
var
|
|
5488
|
+
var import_icons19 = require("@kopexa/icons");
|
|
5325
5489
|
var React15 = __toESM(require("react"));
|
|
5326
5490
|
|
|
5327
5491
|
// src/ui/heading-button/utils.ts
|
|
5328
|
-
var
|
|
5492
|
+
var import_react42 = require("@tiptap/react");
|
|
5329
5493
|
var headingShortcutKeys = {
|
|
5330
5494
|
1: "Ctrl-Alt-1",
|
|
5331
5495
|
2: "Ctrl-Alt-2",
|
|
@@ -5366,7 +5530,7 @@ function shouldShowHeadingButton(params) {
|
|
|
5366
5530
|
return false;
|
|
5367
5531
|
}
|
|
5368
5532
|
if (hideWhenUnavailable) {
|
|
5369
|
-
if ((0,
|
|
5533
|
+
if ((0, import_react42.isNodeSelection)(editor.state.selection)) {
|
|
5370
5534
|
return false;
|
|
5371
5535
|
}
|
|
5372
5536
|
}
|
|
@@ -5377,14 +5541,14 @@ function getFormattedHeadingName(level) {
|
|
|
5377
5541
|
}
|
|
5378
5542
|
|
|
5379
5543
|
// src/ui/heading-button/index.tsx
|
|
5380
|
-
var
|
|
5544
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
5381
5545
|
var headingIcons = {
|
|
5382
|
-
1:
|
|
5383
|
-
2:
|
|
5384
|
-
3:
|
|
5385
|
-
4:
|
|
5386
|
-
5:
|
|
5387
|
-
6:
|
|
5546
|
+
1: import_icons19.HeadingOneIcon,
|
|
5547
|
+
2: import_icons19.HeadingTwoIcon,
|
|
5548
|
+
3: import_icons19.HeadingThreeIcon,
|
|
5549
|
+
4: import_icons19.HeadingFourIcon,
|
|
5550
|
+
5: import_icons19.HeadingFiveIcon,
|
|
5551
|
+
6: import_icons19.HeadingSixIcon
|
|
5388
5552
|
};
|
|
5389
5553
|
function useHeadingState(editor, level, disabled = false) {
|
|
5390
5554
|
const headingInSchema = (0, import_editor_utils10.isNodeInSchema)("heading", editor);
|
|
@@ -5443,8 +5607,8 @@ var HeadingButton = ({
|
|
|
5443
5607
|
if (!show || !editor || !editor.isEditable) {
|
|
5444
5608
|
return null;
|
|
5445
5609
|
}
|
|
5446
|
-
return /* @__PURE__ */ (0,
|
|
5447
|
-
|
|
5610
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5611
|
+
import_button11.Button,
|
|
5448
5612
|
{
|
|
5449
5613
|
type: "button",
|
|
5450
5614
|
className: className.trim(),
|
|
@@ -5459,7 +5623,7 @@ var HeadingButton = ({
|
|
|
5459
5623
|
tooltip: formattedName,
|
|
5460
5624
|
shortcutKeys: shortcutKey,
|
|
5461
5625
|
onClick: handleClick,
|
|
5462
|
-
startContent: /* @__PURE__ */ (0,
|
|
5626
|
+
startContent: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Icon, {}),
|
|
5463
5627
|
...buttonProps,
|
|
5464
5628
|
ref,
|
|
5465
5629
|
children: children || text
|
|
@@ -5468,7 +5632,7 @@ var HeadingButton = ({
|
|
|
5468
5632
|
};
|
|
5469
5633
|
|
|
5470
5634
|
// src/ui/heading-dropdown-menu/index.tsx
|
|
5471
|
-
var
|
|
5635
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
5472
5636
|
function HeadingDropdownMenu({
|
|
5473
5637
|
editor: providedEditor,
|
|
5474
5638
|
levels = [1, 2, 3, 4, 5, 6],
|
|
@@ -5488,13 +5652,13 @@ function HeadingDropdownMenu({
|
|
|
5488
5652
|
[onOpenChange]
|
|
5489
5653
|
);
|
|
5490
5654
|
const getActiveIcon = React16.useCallback(() => {
|
|
5491
|
-
if (!editor) return /* @__PURE__ */ (0,
|
|
5655
|
+
if (!editor) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_icons20.HeadingIcon, {});
|
|
5492
5656
|
const activeLevel = levels.find(
|
|
5493
5657
|
(level) => editor.isActive("heading", { level })
|
|
5494
5658
|
);
|
|
5495
|
-
if (!activeLevel) return /* @__PURE__ */ (0,
|
|
5659
|
+
if (!activeLevel) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_icons20.HeadingIcon, {});
|
|
5496
5660
|
const ActiveIcon = headingIcons[activeLevel];
|
|
5497
|
-
return /* @__PURE__ */ (0,
|
|
5661
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ActiveIcon, {});
|
|
5498
5662
|
}, [editor, levels]);
|
|
5499
5663
|
const canToggleAnyHeading = React16.useCallback(() => {
|
|
5500
5664
|
if (!editor) return false;
|
|
@@ -5509,7 +5673,7 @@ function HeadingDropdownMenu({
|
|
|
5509
5673
|
return false;
|
|
5510
5674
|
}
|
|
5511
5675
|
if (hideWhenUnavailable) {
|
|
5512
|
-
if ((0,
|
|
5676
|
+
if ((0, import_react43.isNodeSelection)(editor.state.selection) || !canToggleAnyHeading()) {
|
|
5513
5677
|
return false;
|
|
5514
5678
|
}
|
|
5515
5679
|
}
|
|
@@ -5518,9 +5682,9 @@ function HeadingDropdownMenu({
|
|
|
5518
5682
|
if (!show || !editor || !editor.isEditable) {
|
|
5519
5683
|
return null;
|
|
5520
5684
|
}
|
|
5521
|
-
return /* @__PURE__ */ (0,
|
|
5522
|
-
/* @__PURE__ */ (0,
|
|
5523
|
-
|
|
5685
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_dropdown_menu.DropdownMenu.Root, { open: isOpen, onOpenChange: handleOnOpenChange, children: [
|
|
5686
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_dropdown_menu.DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
5687
|
+
import_button12.Button,
|
|
5524
5688
|
{
|
|
5525
5689
|
type: "button",
|
|
5526
5690
|
disabled: isDisabled,
|
|
@@ -5532,12 +5696,12 @@ function HeadingDropdownMenu({
|
|
|
5532
5696
|
"aria-label": "Format text as heading",
|
|
5533
5697
|
"aria-pressed": isAnyHeadingActive,
|
|
5534
5698
|
tooltip: "Heading",
|
|
5535
|
-
endContent: /* @__PURE__ */ (0,
|
|
5699
|
+
endContent: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_icons20.ChevronDownIcon, {}),
|
|
5536
5700
|
...props,
|
|
5537
5701
|
children: getActiveIcon()
|
|
5538
5702
|
}
|
|
5539
5703
|
) }),
|
|
5540
|
-
/* @__PURE__ */ (0,
|
|
5704
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_dropdown_menu.DropdownMenu.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_dropdown_menu.DropdownMenu.Group, { children: levels.map((level) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_dropdown_menu.DropdownMenu.Item, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
5541
5705
|
HeadingButton,
|
|
5542
5706
|
{
|
|
5543
5707
|
editor,
|
|
@@ -5552,35 +5716,35 @@ function HeadingDropdownMenu({
|
|
|
5552
5716
|
}
|
|
5553
5717
|
|
|
5554
5718
|
// src/ui/list-dropdown-menu/index.tsx
|
|
5555
|
-
var
|
|
5719
|
+
var import_button14 = require("@kopexa/button");
|
|
5556
5720
|
var import_dropdown_menu2 = require("@kopexa/dropdown-menu");
|
|
5557
5721
|
var import_editor_utils13 = require("@kopexa/editor-utils");
|
|
5558
|
-
var
|
|
5559
|
-
var
|
|
5560
|
-
var
|
|
5722
|
+
var import_icons22 = require("@kopexa/icons");
|
|
5723
|
+
var import_react46 = require("@tiptap/react");
|
|
5724
|
+
var import_react47 = require("react");
|
|
5561
5725
|
|
|
5562
5726
|
// src/ui/list-button/index.tsx
|
|
5563
|
-
var
|
|
5727
|
+
var import_button13 = require("@kopexa/button");
|
|
5564
5728
|
var import_editor_utils12 = require("@kopexa/editor-utils");
|
|
5565
|
-
var
|
|
5566
|
-
var
|
|
5567
|
-
var
|
|
5568
|
-
var
|
|
5729
|
+
var import_icons21 = require("@kopexa/icons");
|
|
5730
|
+
var import_react44 = require("@tiptap/react");
|
|
5731
|
+
var import_react45 = require("react");
|
|
5732
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
5569
5733
|
var listOptions = [
|
|
5570
5734
|
{
|
|
5571
5735
|
label: "Bullet List",
|
|
5572
5736
|
type: "bulletList",
|
|
5573
|
-
icon:
|
|
5737
|
+
icon: import_icons21.ListIcon
|
|
5574
5738
|
},
|
|
5575
5739
|
{
|
|
5576
5740
|
label: "Ordered List",
|
|
5577
5741
|
type: "orderedList",
|
|
5578
|
-
icon:
|
|
5742
|
+
icon: import_icons21.ListOrderedIcon
|
|
5579
5743
|
},
|
|
5580
5744
|
{
|
|
5581
5745
|
label: "Task List",
|
|
5582
5746
|
type: "taskList",
|
|
5583
|
-
icon:
|
|
5747
|
+
icon: import_icons21.ListTodoIcon
|
|
5584
5748
|
}
|
|
5585
5749
|
];
|
|
5586
5750
|
var listShortcutKeys = {
|
|
@@ -5639,7 +5803,7 @@ function shouldShowListButton(params) {
|
|
|
5639
5803
|
return false;
|
|
5640
5804
|
}
|
|
5641
5805
|
if (hideWhenUnavailable) {
|
|
5642
|
-
if ((0,
|
|
5806
|
+
if ((0, import_react44.isNodeSelection)(editor.state.selection) || !canToggleList(editor, type)) {
|
|
5643
5807
|
return false;
|
|
5644
5808
|
}
|
|
5645
5809
|
}
|
|
@@ -5673,8 +5837,8 @@ var ListButton = ({
|
|
|
5673
5837
|
editor,
|
|
5674
5838
|
type
|
|
5675
5839
|
);
|
|
5676
|
-
const Icon = (listOption == null ? void 0 : listOption.icon) ||
|
|
5677
|
-
const handleClick = (0,
|
|
5840
|
+
const Icon = (listOption == null ? void 0 : listOption.icon) || import_icons21.ListIcon;
|
|
5841
|
+
const handleClick = (0, import_react45.useCallback)(
|
|
5678
5842
|
(e) => {
|
|
5679
5843
|
onClick == null ? void 0 : onClick(e);
|
|
5680
5844
|
if (!e.defaultPrevented && editor) {
|
|
@@ -5683,7 +5847,7 @@ var ListButton = ({
|
|
|
5683
5847
|
},
|
|
5684
5848
|
[onClick, editor, type]
|
|
5685
5849
|
);
|
|
5686
|
-
const show = (0,
|
|
5850
|
+
const show = (0, import_react45.useMemo)(() => {
|
|
5687
5851
|
return shouldShowListButton({
|
|
5688
5852
|
editor,
|
|
5689
5853
|
type,
|
|
@@ -5694,8 +5858,8 @@ var ListButton = ({
|
|
|
5694
5858
|
if (!show || !editor || !editor.isEditable) {
|
|
5695
5859
|
return null;
|
|
5696
5860
|
}
|
|
5697
|
-
return /* @__PURE__ */ (0,
|
|
5698
|
-
|
|
5861
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
5862
|
+
import_button13.Button,
|
|
5699
5863
|
{
|
|
5700
5864
|
type: "button",
|
|
5701
5865
|
className: className.trim(),
|
|
@@ -5708,7 +5872,7 @@ var ListButton = ({
|
|
|
5708
5872
|
tooltip: (listOption == null ? void 0 : listOption.label) || type,
|
|
5709
5873
|
shortcutKeys: shortcutKey,
|
|
5710
5874
|
onClick: handleClick,
|
|
5711
|
-
startContent: /* @__PURE__ */ (0,
|
|
5875
|
+
startContent: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Icon, {}),
|
|
5712
5876
|
...buttonProps,
|
|
5713
5877
|
ref,
|
|
5714
5878
|
children: children || text
|
|
@@ -5717,7 +5881,7 @@ var ListButton = ({
|
|
|
5717
5881
|
};
|
|
5718
5882
|
|
|
5719
5883
|
// src/ui/list-dropdown-menu/index.tsx
|
|
5720
|
-
var
|
|
5884
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
5721
5885
|
function canToggleAnyList(editor, listTypes) {
|
|
5722
5886
|
if (!editor) return false;
|
|
5723
5887
|
return listTypes.some((type) => canToggleList(editor, type));
|
|
@@ -5737,24 +5901,24 @@ function shouldShowListDropdown(params) {
|
|
|
5737
5901
|
return false;
|
|
5738
5902
|
}
|
|
5739
5903
|
if (hideWhenUnavailable) {
|
|
5740
|
-
if ((0,
|
|
5904
|
+
if ((0, import_react46.isNodeSelection)(editor.state.selection) || !canToggleAny) {
|
|
5741
5905
|
return false;
|
|
5742
5906
|
}
|
|
5743
5907
|
}
|
|
5744
5908
|
return true;
|
|
5745
5909
|
}
|
|
5746
5910
|
function useListDropdownState(editor, availableTypes) {
|
|
5747
|
-
const [isOpen, setIsOpen] = (0,
|
|
5911
|
+
const [isOpen, setIsOpen] = (0, import_react47.useState)(false);
|
|
5748
5912
|
const listInSchema = availableTypes.some(
|
|
5749
5913
|
(type) => (0, import_editor_utils13.isNodeInSchema)(type, editor)
|
|
5750
5914
|
);
|
|
5751
|
-
const filteredLists = (0,
|
|
5915
|
+
const filteredLists = (0, import_react47.useMemo)(
|
|
5752
5916
|
() => getFilteredListOptions(availableTypes),
|
|
5753
5917
|
[availableTypes]
|
|
5754
5918
|
);
|
|
5755
5919
|
const canToggleAny = canToggleAnyList(editor, availableTypes);
|
|
5756
5920
|
const isAnyActive = isAnyListActive(editor, availableTypes);
|
|
5757
|
-
const handleOpenChange = (0,
|
|
5921
|
+
const handleOpenChange = (0, import_react47.useCallback)(
|
|
5758
5922
|
(open, callback) => {
|
|
5759
5923
|
setIsOpen(open);
|
|
5760
5924
|
callback == null ? void 0 : callback(open);
|
|
@@ -5772,11 +5936,11 @@ function useListDropdownState(editor, availableTypes) {
|
|
|
5772
5936
|
};
|
|
5773
5937
|
}
|
|
5774
5938
|
function useActiveListIcon(editor, filteredLists) {
|
|
5775
|
-
return (0,
|
|
5939
|
+
return (0, import_react47.useCallback)(() => {
|
|
5776
5940
|
const activeOption = filteredLists.find(
|
|
5777
5941
|
(option) => isListActive(editor, option.type)
|
|
5778
5942
|
);
|
|
5779
|
-
return activeOption ? /* @__PURE__ */ (0,
|
|
5943
|
+
return activeOption ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(activeOption.icon, {}) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_icons22.ListIcon, {});
|
|
5780
5944
|
}, [editor, filteredLists]);
|
|
5781
5945
|
}
|
|
5782
5946
|
function ListDropdownMenu({
|
|
@@ -5796,7 +5960,7 @@ function ListDropdownMenu({
|
|
|
5796
5960
|
handleOpenChange
|
|
5797
5961
|
} = useListDropdownState(editor, types);
|
|
5798
5962
|
const getActiveIcon = useActiveListIcon(editor, filteredLists);
|
|
5799
|
-
const show = (0,
|
|
5963
|
+
const show = (0, import_react47.useMemo)(() => {
|
|
5800
5964
|
return shouldShowListDropdown({
|
|
5801
5965
|
editor,
|
|
5802
5966
|
listTypes: types,
|
|
@@ -5805,16 +5969,16 @@ function ListDropdownMenu({
|
|
|
5805
5969
|
canToggleAny
|
|
5806
5970
|
});
|
|
5807
5971
|
}, [editor, types, hideWhenUnavailable, listInSchema, canToggleAny]);
|
|
5808
|
-
const handleOnOpenChange = (0,
|
|
5972
|
+
const handleOnOpenChange = (0, import_react47.useCallback)(
|
|
5809
5973
|
(open) => handleOpenChange(open, onOpenChange),
|
|
5810
5974
|
[handleOpenChange, onOpenChange]
|
|
5811
5975
|
);
|
|
5812
5976
|
if (!show || !editor || !editor.isEditable) {
|
|
5813
5977
|
return null;
|
|
5814
5978
|
}
|
|
5815
|
-
return /* @__PURE__ */ (0,
|
|
5816
|
-
/* @__PURE__ */ (0,
|
|
5817
|
-
|
|
5979
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_dropdown_menu2.DropdownMenu.Root, { open: isOpen, onOpenChange: handleOnOpenChange, children: [
|
|
5980
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_dropdown_menu2.DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
5981
|
+
import_button14.Button,
|
|
5818
5982
|
{
|
|
5819
5983
|
type: "button",
|
|
5820
5984
|
variant: "ghost",
|
|
@@ -5823,12 +5987,12 @@ function ListDropdownMenu({
|
|
|
5823
5987
|
tabIndex: -1,
|
|
5824
5988
|
"aria-label": "List options",
|
|
5825
5989
|
tooltip: "List",
|
|
5826
|
-
endContent: /* @__PURE__ */ (0,
|
|
5990
|
+
endContent: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_icons22.ChevronDownIcon, {}),
|
|
5827
5991
|
...props,
|
|
5828
5992
|
children: getActiveIcon()
|
|
5829
5993
|
}
|
|
5830
5994
|
) }),
|
|
5831
|
-
/* @__PURE__ */ (0,
|
|
5995
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_dropdown_menu2.DropdownMenu.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_dropdown_menu2.DropdownMenu.Group, { children: filteredLists.map((option) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_dropdown_menu2.DropdownMenu.Item, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
5832
5996
|
ListButton,
|
|
5833
5997
|
{
|
|
5834
5998
|
editor,
|
|
@@ -5845,8 +6009,8 @@ function ListDropdownMenu({
|
|
|
5845
6009
|
|
|
5846
6010
|
// src/ui/table-button/index.tsx
|
|
5847
6011
|
var import_toolbar8 = require("@kopexa/toolbar");
|
|
5848
|
-
var
|
|
5849
|
-
var
|
|
6012
|
+
var import_react48 = require("react");
|
|
6013
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
5850
6014
|
var TableButton = ({
|
|
5851
6015
|
editor: providedEditor,
|
|
5852
6016
|
text,
|
|
@@ -5870,7 +6034,7 @@ var TableButton = ({
|
|
|
5870
6034
|
hideWhenUnavailable,
|
|
5871
6035
|
onToggled
|
|
5872
6036
|
});
|
|
5873
|
-
const handleClick = (0,
|
|
6037
|
+
const handleClick = (0, import_react48.useCallback)(
|
|
5874
6038
|
(event) => {
|
|
5875
6039
|
onClick == null ? void 0 : onClick(event);
|
|
5876
6040
|
if (event.defaultPrevented) return;
|
|
@@ -5881,7 +6045,7 @@ var TableButton = ({
|
|
|
5881
6045
|
if (!isVisible) {
|
|
5882
6046
|
return null;
|
|
5883
6047
|
}
|
|
5884
|
-
return /* @__PURE__ */ (0,
|
|
6048
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
5885
6049
|
import_toolbar8.ToolbarButton,
|
|
5886
6050
|
{
|
|
5887
6051
|
type: "button",
|
|
@@ -5897,22 +6061,22 @@ var TableButton = ({
|
|
|
5897
6061
|
onClick: handleClick,
|
|
5898
6062
|
isIconOnly: !text && !children,
|
|
5899
6063
|
...buttonProps,
|
|
5900
|
-
children: children || /* @__PURE__ */ (0,
|
|
5901
|
-
/* @__PURE__ */ (0,
|
|
5902
|
-
text && /* @__PURE__ */ (0,
|
|
6064
|
+
children: children || /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
6065
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Icon, {}),
|
|
6066
|
+
text && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { children: text })
|
|
5903
6067
|
] })
|
|
5904
6068
|
}
|
|
5905
6069
|
);
|
|
5906
6070
|
};
|
|
5907
6071
|
|
|
5908
6072
|
// src/ui/text-align-button/text-align-button.tsx
|
|
5909
|
-
var
|
|
5910
|
-
var
|
|
6073
|
+
var import_button15 = require("@kopexa/button");
|
|
6074
|
+
var import_react50 = require("react");
|
|
5911
6075
|
|
|
5912
6076
|
// src/ui/text-align-button/use-text-align.ts
|
|
5913
6077
|
var import_editor_utils14 = require("@kopexa/editor-utils");
|
|
5914
|
-
var
|
|
5915
|
-
var
|
|
6078
|
+
var import_icons23 = require("@kopexa/icons");
|
|
6079
|
+
var import_react49 = require("react");
|
|
5916
6080
|
var TEXT_ALIGN_SHORTCUT_KEYS = {
|
|
5917
6081
|
left: "mod+shift+l",
|
|
5918
6082
|
center: "mod+shift+e",
|
|
@@ -5920,10 +6084,10 @@ var TEXT_ALIGN_SHORTCUT_KEYS = {
|
|
|
5920
6084
|
justify: "mod+shift+j"
|
|
5921
6085
|
};
|
|
5922
6086
|
var textAlignIcons = {
|
|
5923
|
-
left:
|
|
5924
|
-
center:
|
|
5925
|
-
right:
|
|
5926
|
-
justify:
|
|
6087
|
+
left: import_icons23.AlignLeftIcon,
|
|
6088
|
+
center: import_icons23.AlignCenterIcon,
|
|
6089
|
+
right: import_icons23.AlignRightIcon,
|
|
6090
|
+
justify: import_icons23.AlignJustifyIcon
|
|
5927
6091
|
};
|
|
5928
6092
|
var textAlignLabels = {
|
|
5929
6093
|
left: "Align left",
|
|
@@ -5970,10 +6134,10 @@ function useTextAlign(config) {
|
|
|
5970
6134
|
onAligned
|
|
5971
6135
|
} = config;
|
|
5972
6136
|
const { editor } = useTiptapEditor(providedEditor);
|
|
5973
|
-
const [isVisible, setIsVisible] = (0,
|
|
6137
|
+
const [isVisible, setIsVisible] = (0, import_react49.useState)(true);
|
|
5974
6138
|
const canAlign = canSetTextAlign(editor, align);
|
|
5975
6139
|
const isActive = isTextAlignActive(editor, align);
|
|
5976
|
-
(0,
|
|
6140
|
+
(0, import_react49.useEffect)(() => {
|
|
5977
6141
|
if (!editor) return;
|
|
5978
6142
|
const handleSelectionUpdate = () => {
|
|
5979
6143
|
setIsVisible(shouldShowButton5({ editor, align, hideWhenUnavailable }));
|
|
@@ -5984,7 +6148,7 @@ function useTextAlign(config) {
|
|
|
5984
6148
|
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
5985
6149
|
};
|
|
5986
6150
|
}, [editor, hideWhenUnavailable, align]);
|
|
5987
|
-
const handleTextAlign = (0,
|
|
6151
|
+
const handleTextAlign = (0, import_react49.useCallback)(() => {
|
|
5988
6152
|
if (!editor) return false;
|
|
5989
6153
|
const success = setTextAlign(editor, align);
|
|
5990
6154
|
if (success) {
|
|
@@ -6004,7 +6168,7 @@ function useTextAlign(config) {
|
|
|
6004
6168
|
}
|
|
6005
6169
|
|
|
6006
6170
|
// src/ui/text-align-button/text-align-button.tsx
|
|
6007
|
-
var
|
|
6171
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
6008
6172
|
var TextAlignButton = ({
|
|
6009
6173
|
editor: providedEditor,
|
|
6010
6174
|
align,
|
|
@@ -6031,7 +6195,7 @@ var TextAlignButton = ({
|
|
|
6031
6195
|
hideWhenUnavailable,
|
|
6032
6196
|
onAligned
|
|
6033
6197
|
});
|
|
6034
|
-
const handleClick = (0,
|
|
6198
|
+
const handleClick = (0, import_react50.useCallback)(
|
|
6035
6199
|
(e) => {
|
|
6036
6200
|
onClick == null ? void 0 : onClick(e);
|
|
6037
6201
|
if (e.defaultPrevented) return;
|
|
@@ -6042,8 +6206,8 @@ var TextAlignButton = ({
|
|
|
6042
6206
|
if (!isVisible) {
|
|
6043
6207
|
return null;
|
|
6044
6208
|
}
|
|
6045
|
-
return /* @__PURE__ */ (0,
|
|
6046
|
-
|
|
6209
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
6210
|
+
import_button15.IconButton,
|
|
6047
6211
|
{
|
|
6048
6212
|
type: "button",
|
|
6049
6213
|
disabled: canAlign,
|
|
@@ -6058,19 +6222,19 @@ var TextAlignButton = ({
|
|
|
6058
6222
|
shortcutKeys,
|
|
6059
6223
|
onClick: handleClick,
|
|
6060
6224
|
...buttonProps,
|
|
6061
|
-
children: /* @__PURE__ */ (0,
|
|
6225
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Icon, {})
|
|
6062
6226
|
}
|
|
6063
6227
|
);
|
|
6064
6228
|
};
|
|
6065
6229
|
|
|
6066
6230
|
// src/ui/undo-redo-button/undo-redo-button.tsx
|
|
6067
6231
|
var import_toolbar9 = require("@kopexa/toolbar");
|
|
6068
|
-
var
|
|
6232
|
+
var import_react52 = require("react");
|
|
6069
6233
|
|
|
6070
6234
|
// src/ui/undo-redo-button/use-undo-redo.ts
|
|
6071
6235
|
var import_editor_utils15 = require("@kopexa/editor-utils");
|
|
6072
|
-
var
|
|
6073
|
-
var
|
|
6236
|
+
var import_icons24 = require("@kopexa/icons");
|
|
6237
|
+
var import_react51 = require("react");
|
|
6074
6238
|
var UNDO_REDO_SHORTCUT_KEYS = {
|
|
6075
6239
|
undo: "mod+z",
|
|
6076
6240
|
redo: "mod+shift+z"
|
|
@@ -6080,8 +6244,8 @@ var historyActionLabels = {
|
|
|
6080
6244
|
redo: "Redo"
|
|
6081
6245
|
};
|
|
6082
6246
|
var historyIcons = {
|
|
6083
|
-
undo:
|
|
6084
|
-
redo:
|
|
6247
|
+
undo: import_icons24.UndoIcon,
|
|
6248
|
+
redo: import_icons24.RedoIcon
|
|
6085
6249
|
};
|
|
6086
6250
|
function canExecuteUndoRedoAction(editor, action) {
|
|
6087
6251
|
if (!editor || !editor.isEditable) return false;
|
|
@@ -6110,9 +6274,9 @@ function useUndoRedo(config) {
|
|
|
6110
6274
|
onExecuted
|
|
6111
6275
|
} = config;
|
|
6112
6276
|
const { editor } = useTiptapEditor(providedEditor);
|
|
6113
|
-
const [isVisible, setIsVisible] = (0,
|
|
6277
|
+
const [isVisible, setIsVisible] = (0, import_react51.useState)(true);
|
|
6114
6278
|
const canExecute = canExecuteUndoRedoAction(editor, action);
|
|
6115
|
-
(0,
|
|
6279
|
+
(0, import_react51.useEffect)(() => {
|
|
6116
6280
|
if (!editor) return;
|
|
6117
6281
|
const handleUpdate = () => {
|
|
6118
6282
|
setIsVisible(shouldShowButton6({ editor, hideWhenUnavailable, action }));
|
|
@@ -6123,7 +6287,7 @@ function useUndoRedo(config) {
|
|
|
6123
6287
|
editor.off("transaction", handleUpdate);
|
|
6124
6288
|
};
|
|
6125
6289
|
}, [editor, hideWhenUnavailable, action]);
|
|
6126
|
-
const handleAction = (0,
|
|
6290
|
+
const handleAction = (0, import_react51.useCallback)(() => {
|
|
6127
6291
|
if (!editor) return false;
|
|
6128
6292
|
const success = executeUndoRedoAction(editor, action);
|
|
6129
6293
|
if (success) {
|
|
@@ -6142,7 +6306,7 @@ function useUndoRedo(config) {
|
|
|
6142
6306
|
}
|
|
6143
6307
|
|
|
6144
6308
|
// src/ui/undo-redo-button/undo-redo-button.tsx
|
|
6145
|
-
var
|
|
6309
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
6146
6310
|
var UndoRedoButton = ({
|
|
6147
6311
|
editor: providedEditor,
|
|
6148
6312
|
action,
|
|
@@ -6161,7 +6325,7 @@ var UndoRedoButton = ({
|
|
|
6161
6325
|
hideWhenUnavailable,
|
|
6162
6326
|
onExecuted
|
|
6163
6327
|
});
|
|
6164
|
-
const handleClick = (0,
|
|
6328
|
+
const handleClick = (0, import_react52.useCallback)(
|
|
6165
6329
|
(event) => {
|
|
6166
6330
|
onClick == null ? void 0 : onClick(event);
|
|
6167
6331
|
if (event.defaultPrevented) return;
|
|
@@ -6172,7 +6336,7 @@ var UndoRedoButton = ({
|
|
|
6172
6336
|
if (!isVisible) {
|
|
6173
6337
|
return null;
|
|
6174
6338
|
}
|
|
6175
|
-
return /* @__PURE__ */ (0,
|
|
6339
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
6176
6340
|
import_toolbar9.ToolbarButton,
|
|
6177
6341
|
{
|
|
6178
6342
|
type: "button",
|
|
@@ -6187,13 +6351,13 @@ var UndoRedoButton = ({
|
|
|
6187
6351
|
onClick: handleClick,
|
|
6188
6352
|
isIconOnly: true,
|
|
6189
6353
|
...buttonProps,
|
|
6190
|
-
children: /* @__PURE__ */ (0,
|
|
6354
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Icon, {})
|
|
6191
6355
|
}
|
|
6192
6356
|
);
|
|
6193
6357
|
};
|
|
6194
6358
|
|
|
6195
6359
|
// src/presets/basic/editor-header.tsx
|
|
6196
|
-
var
|
|
6360
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
6197
6361
|
var EditorHeader = ({
|
|
6198
6362
|
editor: providedEditor,
|
|
6199
6363
|
variant
|
|
@@ -6203,7 +6367,7 @@ var EditorHeader = ({
|
|
|
6203
6367
|
const isMobile = (0, import_use_is_mobile2.useIsMobile)();
|
|
6204
6368
|
const windowSize = useWindowSize();
|
|
6205
6369
|
const { styles } = useEditorUIContext();
|
|
6206
|
-
const toolbarRef = (0,
|
|
6370
|
+
const toolbarRef = (0, import_react53.useRef)(null);
|
|
6207
6371
|
const bodyRect = useCursorVisibility({
|
|
6208
6372
|
editor,
|
|
6209
6373
|
overlayHeight: (_b = (_a = toolbarRef.current) == null ? void 0 : _a.getBoundingClientRect().height) != null ? _b : 0
|
|
@@ -6212,7 +6376,7 @@ var EditorHeader = ({
|
|
|
6212
6376
|
return null;
|
|
6213
6377
|
}
|
|
6214
6378
|
const ToolbarContent = variant === "comment" ? CommentToolbarContent : variant === "field" ? FieldToolbarContent : MainToolbarContent;
|
|
6215
|
-
return /* @__PURE__ */ (0,
|
|
6379
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: styles.toolbarContainer(), "data-slot": "editor-toolbar", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
6216
6380
|
import_toolbar10.Toolbar,
|
|
6217
6381
|
{
|
|
6218
6382
|
sticky: true,
|
|
@@ -6222,54 +6386,54 @@ var EditorHeader = ({
|
|
|
6222
6386
|
bottom: `calc(100% - ${windowSize.height - bodyRect.y}px)`
|
|
6223
6387
|
} : {},
|
|
6224
6388
|
className: styles.toolbar(),
|
|
6225
|
-
children: /* @__PURE__ */ (0,
|
|
6389
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ToolbarContent, {})
|
|
6226
6390
|
}
|
|
6227
6391
|
) });
|
|
6228
6392
|
};
|
|
6229
|
-
var MainToolbarContent = () => /* @__PURE__ */ (0,
|
|
6230
|
-
/* @__PURE__ */ (0,
|
|
6231
|
-
/* @__PURE__ */ (0,
|
|
6232
|
-
/* @__PURE__ */ (0,
|
|
6393
|
+
var MainToolbarContent = () => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
6394
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_toolbar10.ToolbarGroup, { children: [
|
|
6395
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(UndoRedoButton, { action: "undo" }),
|
|
6396
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(UndoRedoButton, { action: "redo" })
|
|
6233
6397
|
] }),
|
|
6234
|
-
/* @__PURE__ */ (0,
|
|
6235
|
-
/* @__PURE__ */ (0,
|
|
6236
|
-
/* @__PURE__ */ (0,
|
|
6237
|
-
/* @__PURE__ */ (0,
|
|
6238
|
-
/* @__PURE__ */ (0,
|
|
6239
|
-
/* @__PURE__ */ (0,
|
|
6398
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_toolbar10.ToolbarSeparator, {}),
|
|
6399
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_toolbar10.ToolbarGroup, { children: [
|
|
6400
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(HeadingDropdownMenu, { levels: [1, 2, 3, 4] }),
|
|
6401
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ListDropdownMenu, { types: ["bulletList", "orderedList", "taskList"] }),
|
|
6402
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(BlockquoteButton, {}),
|
|
6403
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CodeBlockButton, {})
|
|
6240
6404
|
] }),
|
|
6241
|
-
/* @__PURE__ */ (0,
|
|
6242
|
-
/* @__PURE__ */ (0,
|
|
6243
|
-
/* @__PURE__ */ (0,
|
|
6244
|
-
/* @__PURE__ */ (0,
|
|
6245
|
-
/* @__PURE__ */ (0,
|
|
6246
|
-
/* @__PURE__ */ (0,
|
|
6247
|
-
/* @__PURE__ */ (0,
|
|
6248
|
-
/* @__PURE__ */ (0,
|
|
6249
|
-
/* @__PURE__ */ (0,
|
|
6405
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_toolbar10.ToolbarSeparator, {}),
|
|
6406
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_toolbar10.ToolbarGroup, { children: [
|
|
6407
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(MarkButton, { type: "bold" }),
|
|
6408
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(MarkButton, { type: "italic" }),
|
|
6409
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(MarkButton, { type: "strike" }),
|
|
6410
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(MarkButton, { type: "code" }),
|
|
6411
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(MarkButton, { type: "underline" }),
|
|
6412
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ColorHighlightPopover, {}),
|
|
6413
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(LinkPopover, {})
|
|
6250
6414
|
] }),
|
|
6251
|
-
/* @__PURE__ */ (0,
|
|
6252
|
-
/* @__PURE__ */ (0,
|
|
6253
|
-
/* @__PURE__ */ (0,
|
|
6415
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_toolbar10.ToolbarSeparator, {}),
|
|
6416
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_toolbar10.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(TableButton, {}) }),
|
|
6417
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(MoreOptions, { hideWhenUnavailable: true })
|
|
6254
6418
|
] });
|
|
6255
|
-
var CommentToolbarContent = () => /* @__PURE__ */ (0,
|
|
6256
|
-
/* @__PURE__ */ (0,
|
|
6257
|
-
/* @__PURE__ */ (0,
|
|
6258
|
-
/* @__PURE__ */ (0,
|
|
6259
|
-
/* @__PURE__ */ (0,
|
|
6260
|
-
/* @__PURE__ */ (0,
|
|
6419
|
+
var CommentToolbarContent = () => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
6420
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_toolbar10.ToolbarGroup, { children: [
|
|
6421
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(MarkButton, { type: "bold" }),
|
|
6422
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(MarkButton, { type: "italic" }),
|
|
6423
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(MarkButton, { type: "strike" }),
|
|
6424
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(MarkButton, { type: "code" })
|
|
6261
6425
|
] }),
|
|
6262
|
-
/* @__PURE__ */ (0,
|
|
6263
|
-
/* @__PURE__ */ (0,
|
|
6264
|
-
/* @__PURE__ */ (0,
|
|
6265
|
-
/* @__PURE__ */ (0,
|
|
6426
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_toolbar10.ToolbarSeparator, {}),
|
|
6427
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_toolbar10.ToolbarGroup, { children: [
|
|
6428
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(LinkPopover, {}),
|
|
6429
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ListDropdownMenu, { types: ["bulletList", "orderedList"] })
|
|
6266
6430
|
] })
|
|
6267
6431
|
] });
|
|
6268
|
-
var FieldToolbarContent = () => /* @__PURE__ */ (0,
|
|
6269
|
-
/* @__PURE__ */ (0,
|
|
6270
|
-
/* @__PURE__ */ (0,
|
|
6271
|
-
/* @__PURE__ */ (0,
|
|
6272
|
-
/* @__PURE__ */ (0,
|
|
6432
|
+
var FieldToolbarContent = () => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_toolbar10.ToolbarGroup, { children: [
|
|
6433
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(MarkButton, { type: "bold" }),
|
|
6434
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(MarkButton, { type: "italic" }),
|
|
6435
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(MarkButton, { type: "strike" }),
|
|
6436
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(LinkPopover, {})
|
|
6273
6437
|
] });
|
|
6274
6438
|
function MoreOptions({
|
|
6275
6439
|
editor: providedEditor,
|
|
@@ -6277,8 +6441,8 @@ function MoreOptions({
|
|
|
6277
6441
|
...props
|
|
6278
6442
|
}) {
|
|
6279
6443
|
const { editor } = useTiptapEditor(providedEditor);
|
|
6280
|
-
const [show, setShow] = (0,
|
|
6281
|
-
(0,
|
|
6444
|
+
const [show, setShow] = (0, import_react53.useState)(false);
|
|
6445
|
+
(0, import_react53.useEffect)(() => {
|
|
6282
6446
|
if (!editor) return;
|
|
6283
6447
|
const handleSelectionUpdate = () => {
|
|
6284
6448
|
setShow(
|
|
@@ -6297,13 +6461,13 @@ function MoreOptions({
|
|
|
6297
6461
|
if (!show || !editor || !editor.isEditable) {
|
|
6298
6462
|
return null;
|
|
6299
6463
|
}
|
|
6300
|
-
return /* @__PURE__ */ (0,
|
|
6301
|
-
/* @__PURE__ */ (0,
|
|
6302
|
-
/* @__PURE__ */ (0,
|
|
6303
|
-
/* @__PURE__ */ (0,
|
|
6464
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
6465
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_toolbar10.ToolbarSeparator, {}),
|
|
6466
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_toolbar10.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_popover3.Popover.Root, { spacing: "dense", width: "auto", children: [
|
|
6467
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
6304
6468
|
import_popover3.Popover.Trigger,
|
|
6305
6469
|
{
|
|
6306
|
-
render: /* @__PURE__ */ (0,
|
|
6470
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
6307
6471
|
import_toolbar10.ToolbarButton,
|
|
6308
6472
|
{
|
|
6309
6473
|
type: "button",
|
|
@@ -6315,29 +6479,29 @@ function MoreOptions({
|
|
|
6315
6479
|
title: "More options",
|
|
6316
6480
|
isIconOnly: true,
|
|
6317
6481
|
...props,
|
|
6318
|
-
children: /* @__PURE__ */ (0,
|
|
6482
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_icons25.MoreVerticalIcon, {})
|
|
6319
6483
|
}
|
|
6320
6484
|
)
|
|
6321
6485
|
}
|
|
6322
6486
|
),
|
|
6323
|
-
/* @__PURE__ */ (0,
|
|
6487
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
6324
6488
|
import_popover3.Popover.Content,
|
|
6325
6489
|
{
|
|
6326
6490
|
side: "top",
|
|
6327
6491
|
align: "end",
|
|
6328
6492
|
alignOffset: 4,
|
|
6329
6493
|
sideOffset: 4,
|
|
6330
|
-
children: /* @__PURE__ */ (0,
|
|
6331
|
-
/* @__PURE__ */ (0,
|
|
6332
|
-
/* @__PURE__ */ (0,
|
|
6333
|
-
/* @__PURE__ */ (0,
|
|
6494
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_toolbar10.Toolbar, { children: [
|
|
6495
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_toolbar10.ToolbarGroup, { children: [
|
|
6496
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(MarkButton, { type: "superscript" }),
|
|
6497
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(MarkButton, { type: "subscript" })
|
|
6334
6498
|
] }),
|
|
6335
|
-
/* @__PURE__ */ (0,
|
|
6336
|
-
/* @__PURE__ */ (0,
|
|
6337
|
-
/* @__PURE__ */ (0,
|
|
6338
|
-
/* @__PURE__ */ (0,
|
|
6339
|
-
/* @__PURE__ */ (0,
|
|
6340
|
-
/* @__PURE__ */ (0,
|
|
6499
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_toolbar10.ToolbarSeparator, {}),
|
|
6500
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_toolbar10.ToolbarGroup, { children: [
|
|
6501
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(TextAlignButton, { align: "left" }),
|
|
6502
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(TextAlignButton, { align: "center" }),
|
|
6503
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(TextAlignButton, { align: "right" }),
|
|
6504
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(TextAlignButton, { align: "justify" })
|
|
6341
6505
|
] })
|
|
6342
6506
|
] })
|
|
6343
6507
|
}
|
|
@@ -6369,7 +6533,7 @@ function shouldShowMoreOptions(params) {
|
|
|
6369
6533
|
}
|
|
6370
6534
|
|
|
6371
6535
|
// src/presets/basic/index.tsx
|
|
6372
|
-
var
|
|
6536
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
6373
6537
|
var BasicEditor = ({
|
|
6374
6538
|
variant,
|
|
6375
6539
|
bordered,
|
|
@@ -6377,28 +6541,28 @@ var BasicEditor = ({
|
|
|
6377
6541
|
...options
|
|
6378
6542
|
}) => {
|
|
6379
6543
|
const editor = useCreateEditor({ content, ...options });
|
|
6380
|
-
const styles = (0,
|
|
6544
|
+
const styles = (0, import_theme7.editorBasic)({ variant, bordered });
|
|
6381
6545
|
if (!editor) {
|
|
6382
|
-
return /* @__PURE__ */ (0,
|
|
6546
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(LoadingSpinner, {});
|
|
6383
6547
|
}
|
|
6384
6548
|
const isBottomToolbar = variant === "field";
|
|
6385
|
-
return /* @__PURE__ */ (0,
|
|
6386
|
-
!isBottomToolbar && /* @__PURE__ */ (0,
|
|
6387
|
-
/* @__PURE__ */ (0,
|
|
6388
|
-
isBottomToolbar && /* @__PURE__ */ (0,
|
|
6549
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(EditorUIProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: styles.root(), "data-slot": "editor", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_react54.EditorContext.Provider, { value: { editor }, children: [
|
|
6550
|
+
!isBottomToolbar && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(EditorHeader, { editor, variant }),
|
|
6551
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(EditorContentArea, { variant }),
|
|
6552
|
+
isBottomToolbar && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(EditorHeader, { editor, variant })
|
|
6389
6553
|
] }) }) });
|
|
6390
6554
|
};
|
|
6391
6555
|
var EditorContentArea = ({ variant }) => {
|
|
6392
|
-
const styles = (0,
|
|
6393
|
-
const { editor } = (0,
|
|
6556
|
+
const styles = (0, import_theme7.editorBasic)({ variant });
|
|
6557
|
+
const { editor } = (0, import_react55.useContext)(import_react54.EditorContext);
|
|
6394
6558
|
const { isDragging } = useUiEditorState(editor);
|
|
6395
6559
|
useScrollToHash();
|
|
6396
6560
|
if (!editor) {
|
|
6397
6561
|
return null;
|
|
6398
6562
|
}
|
|
6399
|
-
return /* @__PURE__ */ (0,
|
|
6400
|
-
/* @__PURE__ */ (0,
|
|
6401
|
-
|
|
6563
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: styles.wrapper(), children: [
|
|
6564
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
6565
|
+
import_react54.EditorContent,
|
|
6402
6566
|
{
|
|
6403
6567
|
editor,
|
|
6404
6568
|
role: "presentation",
|
|
@@ -6406,17 +6570,17 @@ var EditorContentArea = ({ variant }) => {
|
|
|
6406
6570
|
style: {
|
|
6407
6571
|
cursor: isDragging ? "grabbing" : "auto"
|
|
6408
6572
|
},
|
|
6409
|
-
children: /* @__PURE__ */ (0,
|
|
6573
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(SlashDropdownMenu, {})
|
|
6410
6574
|
}
|
|
6411
6575
|
),
|
|
6412
|
-
/* @__PURE__ */ (0,
|
|
6413
|
-
/* @__PURE__ */ (0,
|
|
6576
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(BubbleMenu, { editor }),
|
|
6577
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(LinkBubble, { editor })
|
|
6414
6578
|
] });
|
|
6415
6579
|
};
|
|
6416
6580
|
function LoadingSpinner({ text = "Connecting..." }) {
|
|
6417
|
-
const styles = (0,
|
|
6418
|
-
return /* @__PURE__ */ (0,
|
|
6419
|
-
/* @__PURE__ */ (0,
|
|
6581
|
+
const styles = (0, import_theme7.editorSpinner)();
|
|
6582
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: styles.root(), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: styles.content(), children: [
|
|
6583
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
6420
6584
|
"svg",
|
|
6421
6585
|
{
|
|
6422
6586
|
className: styles.svg(),
|
|
@@ -6424,9 +6588,9 @@ function LoadingSpinner({ text = "Connecting..." }) {
|
|
|
6424
6588
|
fill: "none",
|
|
6425
6589
|
viewBox: "0 0 24 24",
|
|
6426
6590
|
children: [
|
|
6427
|
-
/* @__PURE__ */ (0,
|
|
6428
|
-
/* @__PURE__ */ (0,
|
|
6429
|
-
/* @__PURE__ */ (0,
|
|
6591
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("title", { children: "Loading Spinner" }),
|
|
6592
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("circle", { className: styles.circle(), cx: "12", cy: "12", r: "10" }),
|
|
6593
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
6430
6594
|
"path",
|
|
6431
6595
|
{
|
|
6432
6596
|
className: styles.path(),
|
|
@@ -6436,7 +6600,7 @@ function LoadingSpinner({ text = "Connecting..." }) {
|
|
|
6436
6600
|
]
|
|
6437
6601
|
}
|
|
6438
6602
|
),
|
|
6439
|
-
/* @__PURE__ */ (0,
|
|
6603
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: styles.text(), children: text })
|
|
6440
6604
|
] }) });
|
|
6441
6605
|
}
|
|
6442
6606
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -6445,6 +6609,7 @@ function LoadingSpinner({ text = "Connecting..." }) {
|
|
|
6445
6609
|
Editor,
|
|
6446
6610
|
EditorFileProvider,
|
|
6447
6611
|
ImageNode,
|
|
6612
|
+
ImageUploadNode,
|
|
6448
6613
|
InlineMath,
|
|
6449
6614
|
MathBlock,
|
|
6450
6615
|
TocNode,
|