@kopexa/tiptap 17.10.1 → 17.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +323 -283
- package/dist/index.mjs +170 -146
- package/package.json +26 -26
package/dist/index.js
CHANGED
|
@@ -55,7 +55,7 @@ __export(index_exports, {
|
|
|
55
55
|
sanitizeUrl: () => sanitizeUrl,
|
|
56
56
|
useCollaboration: () => useCollaboration,
|
|
57
57
|
useCollaborationRequired: () => useCollaborationRequired,
|
|
58
|
-
useCurrentEditor: () =>
|
|
58
|
+
useCurrentEditor: () => import_react66.useCurrentEditor,
|
|
59
59
|
useDocumentVisibility: () => useDocumentVisibility,
|
|
60
60
|
useEditorFile: () => useEditorFile,
|
|
61
61
|
useEditorFileRequired: () => useEditorFileRequired,
|
|
@@ -64,7 +64,7 @@ __export(index_exports, {
|
|
|
64
64
|
useVariablesWithFallback: () => useVariablesWithFallback
|
|
65
65
|
});
|
|
66
66
|
module.exports = __toCommonJS(index_exports);
|
|
67
|
-
var
|
|
67
|
+
var import_react66 = require("@tiptap/react");
|
|
68
68
|
|
|
69
69
|
// src/context/collaboration-context.tsx
|
|
70
70
|
var import_provider = require("@hocuspocus/provider");
|
|
@@ -410,13 +410,33 @@ function useEditorFileRequired() {
|
|
|
410
410
|
|
|
411
411
|
// src/extensions/callout/index.ts
|
|
412
412
|
var import_core = require("@tiptap/core");
|
|
413
|
-
var
|
|
413
|
+
var import_react9 = require("@tiptap/react");
|
|
414
414
|
|
|
415
415
|
// src/extensions/callout/callout-view.tsx
|
|
416
416
|
var import_icons2 = require("@kopexa/icons");
|
|
417
417
|
var import_theme = require("@kopexa/theme");
|
|
418
|
-
var
|
|
419
|
-
var
|
|
418
|
+
var import_react7 = require("@tiptap/react");
|
|
419
|
+
var import_react8 = require("react");
|
|
420
|
+
|
|
421
|
+
// src/hooks/use-editor-editable.ts
|
|
422
|
+
var import_react5 = require("react");
|
|
423
|
+
function useEditorEditable(editor) {
|
|
424
|
+
const subscribe2 = (0, import_react5.useCallback)(
|
|
425
|
+
(callback) => {
|
|
426
|
+
if (!editor) return () => {
|
|
427
|
+
};
|
|
428
|
+
editor.on("transaction", callback);
|
|
429
|
+
return () => editor.off("transaction", callback);
|
|
430
|
+
},
|
|
431
|
+
[editor]
|
|
432
|
+
);
|
|
433
|
+
const getSnapshot2 = (0, import_react5.useCallback)(() => {
|
|
434
|
+
var _a;
|
|
435
|
+
return (_a = editor == null ? void 0 : editor.isEditable) != null ? _a : false;
|
|
436
|
+
}, [editor]);
|
|
437
|
+
const getServerSnapshot2 = (0, import_react5.useCallback)(() => false, []);
|
|
438
|
+
return (0, import_react5.useSyncExternalStore)(subscribe2, getSnapshot2, getServerSnapshot2);
|
|
439
|
+
}
|
|
420
440
|
|
|
421
441
|
// src/extensions/callout/callout-settings.tsx
|
|
422
442
|
var import_button = require("@kopexa/button");
|
|
@@ -425,7 +445,7 @@ var import_icons = require("@kopexa/icons");
|
|
|
425
445
|
var import_input = require("@kopexa/input");
|
|
426
446
|
var import_label = require("@kopexa/label");
|
|
427
447
|
var import_select = require("@kopexa/select");
|
|
428
|
-
var
|
|
448
|
+
var import_react6 = require("react");
|
|
429
449
|
var import_react_intl2 = require("react-intl");
|
|
430
450
|
|
|
431
451
|
// src/extensions/callout/messages.ts
|
|
@@ -503,14 +523,14 @@ function CalloutSettings({
|
|
|
503
523
|
getPos
|
|
504
524
|
}) {
|
|
505
525
|
const intl = (0, import_react_intl2.useIntl)();
|
|
506
|
-
const [isOpen, setIsOpen] = (0,
|
|
507
|
-
const [localAttrs, setLocalAttrs] = (0,
|
|
508
|
-
(0,
|
|
526
|
+
const [isOpen, setIsOpen] = (0, import_react6.useState)(false);
|
|
527
|
+
const [localAttrs, setLocalAttrs] = (0, import_react6.useState)(attrs);
|
|
528
|
+
(0, import_react6.useEffect)(() => {
|
|
509
529
|
if (isOpen) {
|
|
510
530
|
setLocalAttrs(attrs);
|
|
511
531
|
}
|
|
512
532
|
}, [isOpen, attrs]);
|
|
513
|
-
const handleSave = (0,
|
|
533
|
+
const handleSave = (0, import_react6.useCallback)(() => {
|
|
514
534
|
const pos = getPos();
|
|
515
535
|
if (pos === void 0) return;
|
|
516
536
|
editor.view.dispatch(
|
|
@@ -518,17 +538,17 @@ function CalloutSettings({
|
|
|
518
538
|
);
|
|
519
539
|
setIsOpen(false);
|
|
520
540
|
}, [editor, localAttrs, getPos]);
|
|
521
|
-
const handleCancel = (0,
|
|
541
|
+
const handleCancel = (0, import_react6.useCallback)(() => {
|
|
522
542
|
setLocalAttrs(attrs);
|
|
523
543
|
setIsOpen(false);
|
|
524
544
|
}, [attrs]);
|
|
525
|
-
const handleVariantChange = (0,
|
|
545
|
+
const handleVariantChange = (0, import_react6.useCallback)((value) => {
|
|
526
546
|
setLocalAttrs((prev) => ({
|
|
527
547
|
...prev,
|
|
528
548
|
variant: String(value)
|
|
529
549
|
}));
|
|
530
550
|
}, []);
|
|
531
|
-
const handleTitleChange = (0,
|
|
551
|
+
const handleTitleChange = (0, import_react6.useCallback)(
|
|
532
552
|
(e) => {
|
|
533
553
|
const value = e.target.value;
|
|
534
554
|
setLocalAttrs((prev) => ({
|
|
@@ -614,14 +634,8 @@ function getVariantIcon(variant, iconClass) {
|
|
|
614
634
|
function CalloutNodeView({ editor, node, getPos }) {
|
|
615
635
|
const attrs = node.attrs;
|
|
616
636
|
const { variant = "info", title } = attrs;
|
|
617
|
-
const isEditable = (
|
|
618
|
-
|
|
619
|
-
selector: ({ editor: e }) => {
|
|
620
|
-
var _a;
|
|
621
|
-
return (_a = e == null ? void 0 : e.isEditable) != null ? _a : false;
|
|
622
|
-
}
|
|
623
|
-
});
|
|
624
|
-
const styles = (0, import_react7.useMemo)(
|
|
637
|
+
const isEditable = useEditorEditable(editor);
|
|
638
|
+
const styles = (0, import_react8.useMemo)(
|
|
625
639
|
() => (0, import_theme.callout)({
|
|
626
640
|
variant,
|
|
627
641
|
radius: "md",
|
|
@@ -630,7 +644,7 @@ function CalloutNodeView({ editor, node, getPos }) {
|
|
|
630
644
|
[variant]
|
|
631
645
|
);
|
|
632
646
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
633
|
-
|
|
647
|
+
import_react7.NodeViewWrapper,
|
|
634
648
|
{
|
|
635
649
|
className: styles.root(),
|
|
636
650
|
"data-type": "callout",
|
|
@@ -639,7 +653,7 @@ function CalloutNodeView({ editor, node, getPos }) {
|
|
|
639
653
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: styles.iconContainer(), children: getVariantIcon(variant, styles.icon()) }),
|
|
640
654
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: styles.content(), children: [
|
|
641
655
|
title && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: styles.title(), children: title }),
|
|
642
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
656
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react7.NodeViewContent, { className: "callout-content" })
|
|
643
657
|
] }),
|
|
644
658
|
isEditable && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "absolute top-2 right-2", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
645
659
|
CalloutSettings,
|
|
@@ -704,7 +718,7 @@ var CalloutNode = import_core.Node.create({
|
|
|
704
718
|
];
|
|
705
719
|
},
|
|
706
720
|
addNodeView() {
|
|
707
|
-
return (0,
|
|
721
|
+
return (0, import_react9.ReactNodeViewRenderer)(CalloutNodeView);
|
|
708
722
|
},
|
|
709
723
|
addCommands() {
|
|
710
724
|
return {
|
|
@@ -759,14 +773,14 @@ var CalloutNode = import_core.Node.create({
|
|
|
759
773
|
|
|
760
774
|
// src/extensions/image/index.ts
|
|
761
775
|
var import_extension_image = require("@tiptap/extension-image");
|
|
762
|
-
var
|
|
776
|
+
var import_react12 = require("@tiptap/react");
|
|
763
777
|
|
|
764
778
|
// src/extensions/image/image-view.tsx
|
|
765
779
|
var import_button2 = require("@kopexa/button");
|
|
766
780
|
var import_icons3 = require("@kopexa/icons");
|
|
767
781
|
var import_theme2 = require("@kopexa/theme");
|
|
768
|
-
var
|
|
769
|
-
var
|
|
782
|
+
var import_react10 = require("@tiptap/react");
|
|
783
|
+
var import_react11 = require("react");
|
|
770
784
|
var import_react_intl4 = require("react-intl");
|
|
771
785
|
|
|
772
786
|
// src/extensions/image/messages.ts
|
|
@@ -805,18 +819,12 @@ function ImageNodeView({ editor, node, getPos }) {
|
|
|
805
819
|
const intl = (0, import_react_intl4.useIntl)();
|
|
806
820
|
const fileHandler = useEditorFile();
|
|
807
821
|
const { src, alt, title, uploadState, uploadProgress } = node.attrs;
|
|
808
|
-
const isEditable = (
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
return (_a2 = e == null ? void 0 : e.isEditable) != null ? _a2 : false;
|
|
813
|
-
}
|
|
814
|
-
});
|
|
815
|
-
const [resolvedUrl, setResolvedUrl] = (0, import_react10.useState)(null);
|
|
816
|
-
const [resolveState, setResolveState] = (0, import_react10.useState)("idle");
|
|
817
|
-
const retryCountRef = (0, import_react10.useRef)(0);
|
|
822
|
+
const isEditable = useEditorEditable(editor);
|
|
823
|
+
const [resolvedUrl, setResolvedUrl] = (0, import_react11.useState)(null);
|
|
824
|
+
const [resolveState, setResolveState] = (0, import_react11.useState)("idle");
|
|
825
|
+
const retryCountRef = (0, import_react11.useRef)(0);
|
|
818
826
|
const needsResolve = (_a = fileHandler == null ? void 0 : fileHandler.isReference(src)) != null ? _a : false;
|
|
819
|
-
const resolveImage = (0,
|
|
827
|
+
const resolveImage = (0, import_react11.useCallback)(async () => {
|
|
820
828
|
if (!src) return;
|
|
821
829
|
if (!needsResolve) {
|
|
822
830
|
setResolvedUrl(src);
|
|
@@ -838,14 +846,14 @@ function ImageNodeView({ editor, node, getPos }) {
|
|
|
838
846
|
setResolveState("error");
|
|
839
847
|
}
|
|
840
848
|
}, [src, needsResolve, fileHandler]);
|
|
841
|
-
(0,
|
|
849
|
+
(0, import_react11.useEffect)(() => {
|
|
842
850
|
resolveImage();
|
|
843
851
|
}, [resolveImage]);
|
|
844
|
-
const handleRetry = (0,
|
|
852
|
+
const handleRetry = (0, import_react11.useCallback)(() => {
|
|
845
853
|
retryCountRef.current += 1;
|
|
846
854
|
resolveImage();
|
|
847
855
|
}, [resolveImage]);
|
|
848
|
-
const handleRemove = (0,
|
|
856
|
+
const handleRemove = (0, import_react11.useCallback)(() => {
|
|
849
857
|
const pos = getPos();
|
|
850
858
|
if (pos === void 0) return;
|
|
851
859
|
editor.commands.deleteRange({
|
|
@@ -853,16 +861,16 @@ function ImageNodeView({ editor, node, getPos }) {
|
|
|
853
861
|
to: pos + node.nodeSize
|
|
854
862
|
});
|
|
855
863
|
}, [editor, getPos, node.nodeSize]);
|
|
856
|
-
const errorStyles = (0,
|
|
864
|
+
const errorStyles = (0, import_react11.useMemo)(
|
|
857
865
|
() => (0, import_theme2.imagePlaceholder)({ size: "md", variant: "error" }),
|
|
858
866
|
[]
|
|
859
867
|
);
|
|
860
|
-
const loadingStyles = (0,
|
|
868
|
+
const loadingStyles = (0, import_react11.useMemo)(
|
|
861
869
|
() => (0, import_theme2.imagePlaceholder)({ size: "md", variant: "uploading" }),
|
|
862
870
|
[]
|
|
863
871
|
);
|
|
864
872
|
if (uploadState === "uploading") {
|
|
865
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react10.NodeViewWrapper, { className: "my-4", "data-type": "image", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: loadingStyles.root(), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: loadingStyles.content(), children: [
|
|
866
874
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative size-12", children: [
|
|
867
875
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
868
876
|
"svg",
|
|
@@ -908,7 +916,7 @@ function ImageNodeView({ editor, node, getPos }) {
|
|
|
908
916
|
] }) }) });
|
|
909
917
|
}
|
|
910
918
|
if (uploadState === "error") {
|
|
911
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
919
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react10.NodeViewWrapper, { className: "my-4", "data-type": "image", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: errorStyles.root(), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: errorStyles.content(), children: [
|
|
912
920
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_icons3.AlertCircleIcon, { className: errorStyles.icon() }),
|
|
913
921
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: errorStyles.text(), children: intl.formatMessage(messages2.upload_error) }),
|
|
914
922
|
isEditable && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
@@ -924,7 +932,7 @@ function ImageNodeView({ editor, node, getPos }) {
|
|
|
924
932
|
] }) }) });
|
|
925
933
|
}
|
|
926
934
|
if (resolveState === "resolved" && resolvedUrl) {
|
|
927
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
935
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react10.NodeViewWrapper, { className: "my-4 relative group", "data-type": "image", children: [
|
|
928
936
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
929
937
|
"img",
|
|
930
938
|
{
|
|
@@ -949,7 +957,7 @@ function ImageNodeView({ editor, node, getPos }) {
|
|
|
949
957
|
}
|
|
950
958
|
const isLoading = resolveState === "loading" || resolveState === "idle";
|
|
951
959
|
const isError = resolveState === "error";
|
|
952
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
960
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react10.NodeViewWrapper, { className: "my-4", "data-type": "image", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
953
961
|
"div",
|
|
954
962
|
{
|
|
955
963
|
className: [
|
|
@@ -1033,7 +1041,7 @@ var ImageNode = import_extension_image.Image.extend({
|
|
|
1033
1041
|
};
|
|
1034
1042
|
},
|
|
1035
1043
|
addNodeView() {
|
|
1036
|
-
return (0,
|
|
1044
|
+
return (0, import_react12.ReactNodeViewRenderer)(ImageNodeView, {
|
|
1037
1045
|
stopEvent: ({ event }) => {
|
|
1038
1046
|
const target = event.target;
|
|
1039
1047
|
if (target instanceof HTMLElement && target.closest("button, [role='button'], input, a")) {
|
|
@@ -1047,14 +1055,14 @@ var ImageNode = import_extension_image.Image.extend({
|
|
|
1047
1055
|
|
|
1048
1056
|
// src/extensions/image-upload/index.ts
|
|
1049
1057
|
var import_core2 = require("@tiptap/core");
|
|
1050
|
-
var
|
|
1058
|
+
var import_react15 = require("@tiptap/react");
|
|
1051
1059
|
|
|
1052
1060
|
// src/extensions/image-upload/image-upload-view.tsx
|
|
1053
1061
|
var import_button3 = require("@kopexa/button");
|
|
1054
1062
|
var import_icons4 = require("@kopexa/icons");
|
|
1055
1063
|
var import_theme3 = require("@kopexa/theme");
|
|
1056
|
-
var
|
|
1057
|
-
var
|
|
1064
|
+
var import_react13 = require("@tiptap/react");
|
|
1065
|
+
var import_react14 = require("react");
|
|
1058
1066
|
var import_react_intl6 = require("react-intl");
|
|
1059
1067
|
|
|
1060
1068
|
// src/extensions/image-upload/messages.ts
|
|
@@ -1095,18 +1103,12 @@ var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
|
1095
1103
|
function ImageUploadNodeView({ editor, node, getPos }) {
|
|
1096
1104
|
const intl = (0, import_react_intl6.useIntl)();
|
|
1097
1105
|
const fileHandler = useEditorFile();
|
|
1098
|
-
const isEditable = (
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
});
|
|
1105
|
-
const [uploadState, setUploadState] = (0, import_react13.useState)("idle");
|
|
1106
|
-
const [uploadProgress, setUploadProgress] = (0, import_react13.useState)(0);
|
|
1107
|
-
const [isDragOver, setIsDragOver] = (0, import_react13.useState)(false);
|
|
1108
|
-
const fileInputRef = (0, import_react13.useRef)(null);
|
|
1109
|
-
const handleRemove = (0, import_react13.useCallback)(() => {
|
|
1106
|
+
const isEditable = useEditorEditable(editor);
|
|
1107
|
+
const [uploadState, setUploadState] = (0, import_react14.useState)("idle");
|
|
1108
|
+
const [uploadProgress, setUploadProgress] = (0, import_react14.useState)(0);
|
|
1109
|
+
const [isDragOver, setIsDragOver] = (0, import_react14.useState)(false);
|
|
1110
|
+
const fileInputRef = (0, import_react14.useRef)(null);
|
|
1111
|
+
const handleRemove = (0, import_react14.useCallback)(() => {
|
|
1110
1112
|
const pos = getPos();
|
|
1111
1113
|
if (pos === void 0) return;
|
|
1112
1114
|
editor.commands.deleteRange({
|
|
@@ -1114,7 +1116,7 @@ function ImageUploadNodeView({ editor, node, getPos }) {
|
|
|
1114
1116
|
to: pos + node.nodeSize
|
|
1115
1117
|
});
|
|
1116
1118
|
}, [editor, getPos, node.nodeSize]);
|
|
1117
|
-
const handleFileSelect = (0,
|
|
1119
|
+
const handleFileSelect = (0, import_react14.useCallback)(
|
|
1118
1120
|
async (file) => {
|
|
1119
1121
|
if (!fileHandler) return;
|
|
1120
1122
|
const pos = getPos();
|
|
@@ -1143,7 +1145,7 @@ function ImageUploadNodeView({ editor, node, getPos }) {
|
|
|
1143
1145
|
},
|
|
1144
1146
|
[fileHandler, editor, getPos, node.nodeSize]
|
|
1145
1147
|
);
|
|
1146
|
-
const handleInputChange = (0,
|
|
1148
|
+
const handleInputChange = (0, import_react14.useCallback)(
|
|
1147
1149
|
(e) => {
|
|
1148
1150
|
var _a;
|
|
1149
1151
|
const file = (_a = e.target.files) == null ? void 0 : _a[0];
|
|
@@ -1154,7 +1156,7 @@ function ImageUploadNodeView({ editor, node, getPos }) {
|
|
|
1154
1156
|
},
|
|
1155
1157
|
[handleFileSelect]
|
|
1156
1158
|
);
|
|
1157
|
-
const handleDrop = (0,
|
|
1159
|
+
const handleDrop = (0, import_react14.useCallback)(
|
|
1158
1160
|
(e) => {
|
|
1159
1161
|
e.preventDefault();
|
|
1160
1162
|
e.stopPropagation();
|
|
@@ -1166,49 +1168,49 @@ function ImageUploadNodeView({ editor, node, getPos }) {
|
|
|
1166
1168
|
},
|
|
1167
1169
|
[handleFileSelect]
|
|
1168
1170
|
);
|
|
1169
|
-
const handleDragOver = (0,
|
|
1171
|
+
const handleDragOver = (0, import_react14.useCallback)((e) => {
|
|
1170
1172
|
e.preventDefault();
|
|
1171
1173
|
e.stopPropagation();
|
|
1172
1174
|
}, []);
|
|
1173
|
-
const handleDragEnter = (0,
|
|
1175
|
+
const handleDragEnter = (0, import_react14.useCallback)((e) => {
|
|
1174
1176
|
e.preventDefault();
|
|
1175
1177
|
e.stopPropagation();
|
|
1176
1178
|
setIsDragOver(true);
|
|
1177
1179
|
}, []);
|
|
1178
|
-
const handleDragLeave = (0,
|
|
1180
|
+
const handleDragLeave = (0, import_react14.useCallback)((e) => {
|
|
1179
1181
|
e.preventDefault();
|
|
1180
1182
|
e.stopPropagation();
|
|
1181
1183
|
if (!e.currentTarget.contains(e.relatedTarget)) {
|
|
1182
1184
|
setIsDragOver(false);
|
|
1183
1185
|
}
|
|
1184
1186
|
}, []);
|
|
1185
|
-
const handleClick = (0,
|
|
1187
|
+
const handleClick = (0, import_react14.useCallback)(() => {
|
|
1186
1188
|
var _a;
|
|
1187
1189
|
if (uploadState === "idle" || uploadState === "error") {
|
|
1188
1190
|
(_a = fileInputRef.current) == null ? void 0 : _a.click();
|
|
1189
1191
|
}
|
|
1190
1192
|
}, [uploadState]);
|
|
1191
|
-
const styles = (0,
|
|
1193
|
+
const styles = (0, import_react14.useMemo)(
|
|
1192
1194
|
() => (0, import_theme3.imagePlaceholder)({
|
|
1193
1195
|
size: "md",
|
|
1194
1196
|
variant: isDragOver ? "default" : void 0
|
|
1195
1197
|
}),
|
|
1196
1198
|
[isDragOver]
|
|
1197
1199
|
);
|
|
1198
|
-
const errorStyles = (0,
|
|
1200
|
+
const errorStyles = (0, import_react14.useMemo)(
|
|
1199
1201
|
() => (0, import_theme3.imagePlaceholder)({ size: "md", variant: "error" }),
|
|
1200
1202
|
[]
|
|
1201
1203
|
);
|
|
1202
|
-
const uploadingStyles = (0,
|
|
1204
|
+
const uploadingStyles = (0, import_react14.useMemo)(
|
|
1203
1205
|
() => (0, import_theme3.imagePlaceholder)({ size: "md", variant: "uploading" }),
|
|
1204
1206
|
[]
|
|
1205
1207
|
);
|
|
1206
|
-
const disabledStyles = (0,
|
|
1208
|
+
const disabledStyles = (0, import_react14.useMemo)(
|
|
1207
1209
|
() => (0, import_theme3.imagePlaceholder)({ size: "md", variant: "disabled" }),
|
|
1208
1210
|
[]
|
|
1209
1211
|
);
|
|
1210
1212
|
if (!fileHandler) {
|
|
1211
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react13.NodeViewWrapper, { className: "my-4", "data-type": "image-upload", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: disabledStyles.root(), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: disabledStyles.content(), children: [
|
|
1212
1214
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons4.ImageIcon, { className: disabledStyles.icon() }),
|
|
1213
1215
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: disabledStyles.text(), children: intl.formatMessage(messages3.files_not_supported) }),
|
|
1214
1216
|
isEditable && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -1224,7 +1226,7 @@ function ImageUploadNodeView({ editor, node, getPos }) {
|
|
|
1224
1226
|
] }) }) });
|
|
1225
1227
|
}
|
|
1226
1228
|
if (uploadState === "uploading") {
|
|
1227
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1229
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react13.NodeViewWrapper, { className: "my-4", "data-type": "image-upload", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: uploadingStyles.root(), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: uploadingStyles.content(), children: [
|
|
1228
1230
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "relative size-12", children: [
|
|
1229
1231
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1230
1232
|
"svg",
|
|
@@ -1270,7 +1272,7 @@ function ImageUploadNodeView({ editor, node, getPos }) {
|
|
|
1270
1272
|
] }) }) });
|
|
1271
1273
|
}
|
|
1272
1274
|
if (uploadState === "error") {
|
|
1273
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1275
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react13.NodeViewWrapper, { className: "my-4", "data-type": "image-upload", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: errorStyles.root(), onClick: handleClick, children: [
|
|
1274
1276
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: errorStyles.content(), children: [
|
|
1275
1277
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons4.AlertCircleIcon, { className: errorStyles.icon() }),
|
|
1276
1278
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: errorStyles.text(), children: intl.formatMessage(messages3.upload_error) }),
|
|
@@ -1302,7 +1304,7 @@ function ImageUploadNodeView({ editor, node, getPos }) {
|
|
|
1302
1304
|
)
|
|
1303
1305
|
] }) });
|
|
1304
1306
|
}
|
|
1305
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1307
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react13.NodeViewWrapper, { className: "my-4", "data-type": "image-upload", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1306
1308
|
"div",
|
|
1307
1309
|
{
|
|
1308
1310
|
className: `${styles.root()} ${isDragOver ? "border-primary bg-primary/10" : ""}`,
|
|
@@ -1384,7 +1386,7 @@ var ImageUploadNode = import_core2.Node.create({
|
|
|
1384
1386
|
return ["div", { ...HTMLAttributes, "data-type": "image-upload" }];
|
|
1385
1387
|
},
|
|
1386
1388
|
addNodeView() {
|
|
1387
|
-
return (0,
|
|
1389
|
+
return (0, import_react15.ReactNodeViewRenderer)(ImageUploadNodeView, {
|
|
1388
1390
|
stopEvent: ({ event }) => {
|
|
1389
1391
|
const target = event.target;
|
|
1390
1392
|
if (target instanceof HTMLElement && target.closest("button, [role='button'], input, a")) {
|
|
@@ -1427,17 +1429,17 @@ var ImageUploadNode = import_core2.Node.create({
|
|
|
1427
1429
|
|
|
1428
1430
|
// src/extensions/math/index.ts
|
|
1429
1431
|
var import_core4 = require("@tiptap/core");
|
|
1430
|
-
var
|
|
1432
|
+
var import_react21 = require("@tiptap/react");
|
|
1431
1433
|
|
|
1432
1434
|
// src/extensions/math/math-block-view.tsx
|
|
1433
1435
|
var import_button4 = require("@kopexa/button");
|
|
1434
1436
|
var import_dialog2 = require("@kopexa/dialog");
|
|
1435
1437
|
var import_icons5 = require("@kopexa/icons");
|
|
1436
1438
|
var import_label2 = require("@kopexa/label");
|
|
1437
|
-
var
|
|
1439
|
+
var import_react16 = require("@tiptap/react");
|
|
1438
1440
|
var import_katex = __toESM(require("katex"));
|
|
1439
1441
|
var import_katex_min = require("katex/dist/katex.min.css");
|
|
1440
|
-
var
|
|
1442
|
+
var import_react17 = require("react");
|
|
1441
1443
|
var import_react_intl8 = require("react-intl");
|
|
1442
1444
|
|
|
1443
1445
|
// src/extensions/math/messages.ts
|
|
@@ -1496,23 +1498,17 @@ function MathBlockView({ editor, node, getPos }) {
|
|
|
1496
1498
|
const intl = (0, import_react_intl8.useIntl)();
|
|
1497
1499
|
const attrs = node.attrs;
|
|
1498
1500
|
const { latex = "" } = attrs;
|
|
1499
|
-
const isEditable = (
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
}
|
|
1505
|
-
});
|
|
1506
|
-
const [isOpen, setIsOpen] = (0, import_react16.useState)(false);
|
|
1507
|
-
const [localLatex, setLocalLatex] = (0, import_react16.useState)(latex);
|
|
1508
|
-
const [error, setError] = (0, import_react16.useState)(null);
|
|
1509
|
-
(0, import_react16.useEffect)(() => {
|
|
1501
|
+
const isEditable = useEditorEditable(editor);
|
|
1502
|
+
const [isOpen, setIsOpen] = (0, import_react17.useState)(false);
|
|
1503
|
+
const [localLatex, setLocalLatex] = (0, import_react17.useState)(latex);
|
|
1504
|
+
const [error, setError] = (0, import_react17.useState)(null);
|
|
1505
|
+
(0, import_react17.useEffect)(() => {
|
|
1510
1506
|
if (isOpen) {
|
|
1511
1507
|
setLocalLatex(latex);
|
|
1512
1508
|
setError(null);
|
|
1513
1509
|
}
|
|
1514
1510
|
}, [isOpen, latex]);
|
|
1515
|
-
const renderedHtml = (0,
|
|
1511
|
+
const renderedHtml = (0, import_react17.useMemo)(() => {
|
|
1516
1512
|
if (!latex) return null;
|
|
1517
1513
|
try {
|
|
1518
1514
|
return import_katex.default.renderToString(latex, {
|
|
@@ -1524,7 +1520,7 @@ function MathBlockView({ editor, node, getPos }) {
|
|
|
1524
1520
|
return null;
|
|
1525
1521
|
}
|
|
1526
1522
|
}, [latex]);
|
|
1527
|
-
const previewHtml = (0,
|
|
1523
|
+
const previewHtml = (0, import_react17.useMemo)(() => {
|
|
1528
1524
|
if (!localLatex) return null;
|
|
1529
1525
|
try {
|
|
1530
1526
|
setError(null);
|
|
@@ -1538,7 +1534,7 @@ function MathBlockView({ editor, node, getPos }) {
|
|
|
1538
1534
|
return null;
|
|
1539
1535
|
}
|
|
1540
1536
|
}, [localLatex, intl]);
|
|
1541
|
-
const handleSave = (0,
|
|
1537
|
+
const handleSave = (0, import_react17.useCallback)(() => {
|
|
1542
1538
|
const pos = getPos();
|
|
1543
1539
|
if (pos === void 0) return;
|
|
1544
1540
|
editor.view.dispatch(
|
|
@@ -1546,12 +1542,12 @@ function MathBlockView({ editor, node, getPos }) {
|
|
|
1546
1542
|
);
|
|
1547
1543
|
setIsOpen(false);
|
|
1548
1544
|
}, [editor, localLatex, getPos]);
|
|
1549
|
-
const handleCancel = (0,
|
|
1545
|
+
const handleCancel = (0, import_react17.useCallback)(() => {
|
|
1550
1546
|
setLocalLatex(latex);
|
|
1551
1547
|
setError(null);
|
|
1552
1548
|
setIsOpen(false);
|
|
1553
1549
|
}, [latex]);
|
|
1554
|
-
const handleOpenEditor = (0,
|
|
1550
|
+
const handleOpenEditor = (0, import_react17.useCallback)(
|
|
1555
1551
|
(e) => {
|
|
1556
1552
|
e.stopPropagation();
|
|
1557
1553
|
e.preventDefault();
|
|
@@ -1563,7 +1559,7 @@ function MathBlockView({ editor, node, getPos }) {
|
|
|
1563
1559
|
);
|
|
1564
1560
|
const isEmpty = !latex;
|
|
1565
1561
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1566
|
-
|
|
1562
|
+
import_react16.NodeViewWrapper,
|
|
1567
1563
|
{
|
|
1568
1564
|
className: "my-4 relative group",
|
|
1569
1565
|
"data-type": "math-block",
|
|
@@ -1638,39 +1634,33 @@ function MathBlockView({ editor, node, getPos }) {
|
|
|
1638
1634
|
|
|
1639
1635
|
// src/extensions/math/inline-math.ts
|
|
1640
1636
|
var import_core3 = require("@tiptap/core");
|
|
1641
|
-
var
|
|
1637
|
+
var import_react20 = require("@tiptap/react");
|
|
1642
1638
|
|
|
1643
1639
|
// src/extensions/math/inline-math-view.tsx
|
|
1644
1640
|
var import_button5 = require("@kopexa/button");
|
|
1645
1641
|
var import_dialog3 = require("@kopexa/dialog");
|
|
1646
1642
|
var import_label3 = require("@kopexa/label");
|
|
1647
|
-
var
|
|
1643
|
+
var import_react18 = require("@tiptap/react");
|
|
1648
1644
|
var import_katex2 = __toESM(require("katex"));
|
|
1649
1645
|
var import_katex_min2 = require("katex/dist/katex.min.css");
|
|
1650
|
-
var
|
|
1646
|
+
var import_react19 = require("react");
|
|
1651
1647
|
var import_react_intl9 = require("react-intl");
|
|
1652
1648
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1653
1649
|
function InlineMathView({ editor, node, getPos }) {
|
|
1654
1650
|
const intl = (0, import_react_intl9.useIntl)();
|
|
1655
1651
|
const attrs = node.attrs;
|
|
1656
1652
|
const { latex = "" } = attrs;
|
|
1657
|
-
const isEditable = (
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
}
|
|
1663
|
-
});
|
|
1664
|
-
const [isOpen, setIsOpen] = (0, import_react18.useState)(false);
|
|
1665
|
-
const [localLatex, setLocalLatex] = (0, import_react18.useState)(latex);
|
|
1666
|
-
const [error, setError] = (0, import_react18.useState)(null);
|
|
1667
|
-
(0, import_react18.useEffect)(() => {
|
|
1653
|
+
const isEditable = useEditorEditable(editor);
|
|
1654
|
+
const [isOpen, setIsOpen] = (0, import_react19.useState)(false);
|
|
1655
|
+
const [localLatex, setLocalLatex] = (0, import_react19.useState)(latex);
|
|
1656
|
+
const [error, setError] = (0, import_react19.useState)(null);
|
|
1657
|
+
(0, import_react19.useEffect)(() => {
|
|
1668
1658
|
if (isOpen) {
|
|
1669
1659
|
setLocalLatex(latex);
|
|
1670
1660
|
setError(null);
|
|
1671
1661
|
}
|
|
1672
1662
|
}, [isOpen, latex]);
|
|
1673
|
-
const renderedHtml = (0,
|
|
1663
|
+
const renderedHtml = (0, import_react19.useMemo)(() => {
|
|
1674
1664
|
if (!latex) return null;
|
|
1675
1665
|
try {
|
|
1676
1666
|
return import_katex2.default.renderToString(latex, {
|
|
@@ -1682,7 +1672,7 @@ function InlineMathView({ editor, node, getPos }) {
|
|
|
1682
1672
|
return null;
|
|
1683
1673
|
}
|
|
1684
1674
|
}, [latex]);
|
|
1685
|
-
const previewHtml = (0,
|
|
1675
|
+
const previewHtml = (0, import_react19.useMemo)(() => {
|
|
1686
1676
|
if (!localLatex) return null;
|
|
1687
1677
|
try {
|
|
1688
1678
|
setError(null);
|
|
@@ -1696,7 +1686,7 @@ function InlineMathView({ editor, node, getPos }) {
|
|
|
1696
1686
|
return null;
|
|
1697
1687
|
}
|
|
1698
1688
|
}, [localLatex, intl]);
|
|
1699
|
-
const handleSave = (0,
|
|
1689
|
+
const handleSave = (0, import_react19.useCallback)(() => {
|
|
1700
1690
|
const pos = getPos();
|
|
1701
1691
|
if (pos === void 0) return;
|
|
1702
1692
|
editor.view.dispatch(
|
|
@@ -1704,12 +1694,12 @@ function InlineMathView({ editor, node, getPos }) {
|
|
|
1704
1694
|
);
|
|
1705
1695
|
setIsOpen(false);
|
|
1706
1696
|
}, [editor, localLatex, getPos]);
|
|
1707
|
-
const handleCancel = (0,
|
|
1697
|
+
const handleCancel = (0, import_react19.useCallback)(() => {
|
|
1708
1698
|
setLocalLatex(latex);
|
|
1709
1699
|
setError(null);
|
|
1710
1700
|
setIsOpen(false);
|
|
1711
1701
|
}, [latex]);
|
|
1712
|
-
const handleClick = (0,
|
|
1702
|
+
const handleClick = (0, import_react19.useCallback)(
|
|
1713
1703
|
(e) => {
|
|
1714
1704
|
e.stopPropagation();
|
|
1715
1705
|
e.preventDefault();
|
|
@@ -1721,7 +1711,7 @@ function InlineMathView({ editor, node, getPos }) {
|
|
|
1721
1711
|
);
|
|
1722
1712
|
const isEmpty = !latex;
|
|
1723
1713
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1724
|
-
|
|
1714
|
+
import_react18.NodeViewWrapper,
|
|
1725
1715
|
{
|
|
1726
1716
|
as: "span",
|
|
1727
1717
|
className: "inline-math-wrapper",
|
|
@@ -1817,7 +1807,7 @@ var InlineMath = import_core3.Node.create({
|
|
|
1817
1807
|
];
|
|
1818
1808
|
},
|
|
1819
1809
|
addNodeView() {
|
|
1820
|
-
return (0,
|
|
1810
|
+
return (0, import_react20.ReactNodeViewRenderer)(InlineMathView, {
|
|
1821
1811
|
as: "span"
|
|
1822
1812
|
});
|
|
1823
1813
|
},
|
|
@@ -1885,7 +1875,7 @@ var MathBlock = import_core4.Node.create({
|
|
|
1885
1875
|
];
|
|
1886
1876
|
},
|
|
1887
1877
|
addNodeView() {
|
|
1888
|
-
return (0,
|
|
1878
|
+
return (0, import_react21.ReactNodeViewRenderer)(MathBlockView);
|
|
1889
1879
|
},
|
|
1890
1880
|
addCommands() {
|
|
1891
1881
|
return {
|
|
@@ -1928,13 +1918,13 @@ var MathBlock = import_core4.Node.create({
|
|
|
1928
1918
|
|
|
1929
1919
|
// src/extensions/toc/index.ts
|
|
1930
1920
|
var import_core5 = require("@tiptap/core");
|
|
1931
|
-
var
|
|
1921
|
+
var import_react25 = require("@tiptap/react");
|
|
1932
1922
|
|
|
1933
1923
|
// src/extensions/toc/toc-view.tsx
|
|
1934
1924
|
var import_icons7 = require("@kopexa/icons");
|
|
1935
1925
|
var import_theme4 = require("@kopexa/theme");
|
|
1936
|
-
var
|
|
1937
|
-
var
|
|
1926
|
+
var import_react23 = require("@tiptap/react");
|
|
1927
|
+
var import_react24 = require("react");
|
|
1938
1928
|
var import_react_intl12 = require("react-intl");
|
|
1939
1929
|
|
|
1940
1930
|
// src/extensions/toc/messages.ts
|
|
@@ -2019,7 +2009,7 @@ var import_icons6 = require("@kopexa/icons");
|
|
|
2019
2009
|
var import_label4 = require("@kopexa/label");
|
|
2020
2010
|
var import_select2 = require("@kopexa/select");
|
|
2021
2011
|
var import_switch = require("@kopexa/switch");
|
|
2022
|
-
var
|
|
2012
|
+
var import_react22 = require("react");
|
|
2023
2013
|
var import_react_intl11 = require("react-intl");
|
|
2024
2014
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2025
2015
|
var HEADING_LEVELS = [
|
|
@@ -2032,14 +2022,14 @@ var HEADING_LEVELS = [
|
|
|
2032
2022
|
];
|
|
2033
2023
|
function TocSettings({ editor, attrs, getPos }) {
|
|
2034
2024
|
const intl = (0, import_react_intl11.useIntl)();
|
|
2035
|
-
const [isOpen, setIsOpen] = (0,
|
|
2036
|
-
const [localAttrs, setLocalAttrs] = (0,
|
|
2037
|
-
(0,
|
|
2025
|
+
const [isOpen, setIsOpen] = (0, import_react22.useState)(false);
|
|
2026
|
+
const [localAttrs, setLocalAttrs] = (0, import_react22.useState)(attrs);
|
|
2027
|
+
(0, import_react22.useEffect)(() => {
|
|
2038
2028
|
if (isOpen) {
|
|
2039
2029
|
setLocalAttrs(attrs);
|
|
2040
2030
|
}
|
|
2041
2031
|
}, [isOpen, attrs]);
|
|
2042
|
-
const handleSave = (0,
|
|
2032
|
+
const handleSave = (0, import_react22.useCallback)(() => {
|
|
2043
2033
|
const pos = getPos();
|
|
2044
2034
|
if (pos === void 0) return;
|
|
2045
2035
|
editor.view.dispatch(
|
|
@@ -2047,11 +2037,11 @@ function TocSettings({ editor, attrs, getPos }) {
|
|
|
2047
2037
|
);
|
|
2048
2038
|
setIsOpen(false);
|
|
2049
2039
|
}, [editor, localAttrs, getPos]);
|
|
2050
|
-
const handleCancel = (0,
|
|
2040
|
+
const handleCancel = (0, import_react22.useCallback)(() => {
|
|
2051
2041
|
setLocalAttrs(attrs);
|
|
2052
2042
|
setIsOpen(false);
|
|
2053
2043
|
}, [attrs]);
|
|
2054
|
-
const handleMinLevelChange = (0,
|
|
2044
|
+
const handleMinLevelChange = (0, import_react22.useCallback)((value) => {
|
|
2055
2045
|
const minLevel = Number.parseInt(String(value), 10);
|
|
2056
2046
|
setLocalAttrs((prev) => ({
|
|
2057
2047
|
...prev,
|
|
@@ -2060,7 +2050,7 @@ function TocSettings({ editor, attrs, getPos }) {
|
|
|
2060
2050
|
maxLevel: Math.max(prev.maxLevel, minLevel)
|
|
2061
2051
|
}));
|
|
2062
2052
|
}, []);
|
|
2063
|
-
const handleMaxLevelChange = (0,
|
|
2053
|
+
const handleMaxLevelChange = (0, import_react22.useCallback)((value) => {
|
|
2064
2054
|
const maxLevel = Number.parseInt(String(value), 10);
|
|
2065
2055
|
setLocalAttrs((prev) => ({
|
|
2066
2056
|
...prev,
|
|
@@ -2069,10 +2059,10 @@ function TocSettings({ editor, attrs, getPos }) {
|
|
|
2069
2059
|
minLevel: Math.min(prev.minLevel, maxLevel)
|
|
2070
2060
|
}));
|
|
2071
2061
|
}, []);
|
|
2072
|
-
const handleNumberedChange = (0,
|
|
2062
|
+
const handleNumberedChange = (0, import_react22.useCallback)((checked) => {
|
|
2073
2063
|
setLocalAttrs((prev) => ({ ...prev, numbered: checked }));
|
|
2074
2064
|
}, []);
|
|
2075
|
-
const handleStyleChange = (0,
|
|
2065
|
+
const handleStyleChange = (0, import_react22.useCallback)((value) => {
|
|
2076
2066
|
setLocalAttrs((prev) => ({
|
|
2077
2067
|
...prev,
|
|
2078
2068
|
style: String(value)
|
|
@@ -2212,7 +2202,7 @@ function generateHeadingNumbers(headings, minLevel) {
|
|
|
2212
2202
|
});
|
|
2213
2203
|
}
|
|
2214
2204
|
function TocNodeView({ editor, node, getPos }) {
|
|
2215
|
-
const [headings, setHeadings] = (0,
|
|
2205
|
+
const [headings, setHeadings] = (0, import_react24.useState)([]);
|
|
2216
2206
|
const intl = (0, import_react_intl12.useIntl)();
|
|
2217
2207
|
const attrs = node.attrs;
|
|
2218
2208
|
const {
|
|
@@ -2221,8 +2211,8 @@ function TocNodeView({ editor, node, getPos }) {
|
|
|
2221
2211
|
numbered = false,
|
|
2222
2212
|
style = "default"
|
|
2223
2213
|
} = attrs;
|
|
2224
|
-
const styles = (0,
|
|
2225
|
-
const updateHeadings = (0,
|
|
2214
|
+
const styles = (0, import_react24.useMemo)(() => (0, import_theme4.toc)({ style }), [style]);
|
|
2215
|
+
const updateHeadings = (0, import_react24.useCallback)(() => {
|
|
2226
2216
|
const items = [];
|
|
2227
2217
|
const { doc } = editor.state;
|
|
2228
2218
|
doc.descendants((docNode, pos) => {
|
|
@@ -2242,14 +2232,14 @@ function TocNodeView({ editor, node, getPos }) {
|
|
|
2242
2232
|
const numberedHeadings = generateHeadingNumbers(items, minLevel);
|
|
2243
2233
|
setHeadings(numberedHeadings);
|
|
2244
2234
|
}, [editor, minLevel, maxLevel]);
|
|
2245
|
-
(0,
|
|
2235
|
+
(0, import_react24.useEffect)(() => {
|
|
2246
2236
|
updateHeadings();
|
|
2247
2237
|
editor.on("update", updateHeadings);
|
|
2248
2238
|
return () => {
|
|
2249
2239
|
editor.off("update", updateHeadings);
|
|
2250
2240
|
};
|
|
2251
2241
|
}, [editor, updateHeadings]);
|
|
2252
|
-
const handleClick = (0,
|
|
2242
|
+
const handleClick = (0, import_react24.useCallback)(
|
|
2253
2243
|
(pos, id) => {
|
|
2254
2244
|
var _a;
|
|
2255
2245
|
editor.chain().focus().setTextSelection(pos).run();
|
|
@@ -2270,7 +2260,7 @@ function TocNodeView({ editor, node, getPos }) {
|
|
|
2270
2260
|
const getIndent = (level) => {
|
|
2271
2261
|
return (level - minLevel) * 16;
|
|
2272
2262
|
};
|
|
2273
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
2263
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react23.NodeViewWrapper, { className: styles.root(), "data-type": "toc", children: [
|
|
2274
2264
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: styles.header(), children: [
|
|
2275
2265
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: styles.headerContent(), children: [
|
|
2276
2266
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons7.ListIcon, { className: styles.headerIcon() }),
|
|
@@ -2369,7 +2359,7 @@ var TocNode = import_core5.Node.create({
|
|
|
2369
2359
|
];
|
|
2370
2360
|
},
|
|
2371
2361
|
addNodeView() {
|
|
2372
|
-
return (0,
|
|
2362
|
+
return (0, import_react25.ReactNodeViewRenderer)(TocNodeView);
|
|
2373
2363
|
},
|
|
2374
2364
|
addCommands() {
|
|
2375
2365
|
return {
|
|
@@ -2398,11 +2388,11 @@ var TocNode = import_core5.Node.create({
|
|
|
2398
2388
|
|
|
2399
2389
|
// src/extensions/variable/index.ts
|
|
2400
2390
|
var import_core6 = require("@tiptap/core");
|
|
2401
|
-
var
|
|
2391
|
+
var import_react27 = require("@tiptap/react");
|
|
2402
2392
|
|
|
2403
2393
|
// src/extensions/variable/variable-view.tsx
|
|
2404
2394
|
var import_theme5 = require("@kopexa/theme");
|
|
2405
|
-
var
|
|
2395
|
+
var import_react26 = require("@tiptap/react");
|
|
2406
2396
|
|
|
2407
2397
|
// src/extensions/variable/variable-context.tsx
|
|
2408
2398
|
var React = __toESM(require("react"));
|
|
@@ -2438,20 +2428,14 @@ function VariableNodeView({ node, editor }) {
|
|
|
2438
2428
|
const attrs = node.attrs;
|
|
2439
2429
|
const { name, fallback, category } = attrs;
|
|
2440
2430
|
const context = useVariables();
|
|
2441
|
-
const isEditable = (
|
|
2442
|
-
editor,
|
|
2443
|
-
selector: ({ editor: e }) => {
|
|
2444
|
-
var _a2;
|
|
2445
|
-
return (_a2 = e == null ? void 0 : e.isEditable) != null ? _a2 : true;
|
|
2446
|
-
}
|
|
2447
|
-
});
|
|
2431
|
+
const isEditable = useEditorEditable(editor);
|
|
2448
2432
|
const resolvedValue = (_a = context == null ? void 0 : context.resolveVariable) == null ? void 0 : _a.call(context, name);
|
|
2449
2433
|
const hasValue = resolvedValue !== void 0 && resolvedValue !== "";
|
|
2450
2434
|
const displayValue = resolvedValue || fallback;
|
|
2451
2435
|
const styles = (0, import_theme5.variableNode)({ resolved: hasValue });
|
|
2452
2436
|
if (!isEditable && hasValue) {
|
|
2453
2437
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2454
|
-
|
|
2438
|
+
import_react26.NodeViewWrapper,
|
|
2455
2439
|
{
|
|
2456
2440
|
as: "span",
|
|
2457
2441
|
"data-type": "variable",
|
|
@@ -2462,7 +2446,7 @@ function VariableNodeView({ node, editor }) {
|
|
|
2462
2446
|
);
|
|
2463
2447
|
}
|
|
2464
2448
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2465
|
-
|
|
2449
|
+
import_react26.NodeViewWrapper,
|
|
2466
2450
|
{
|
|
2467
2451
|
as: "span",
|
|
2468
2452
|
className: styles.wrapper(),
|
|
@@ -2551,7 +2535,7 @@ var VariableNode = import_core6.Node.create({
|
|
|
2551
2535
|
];
|
|
2552
2536
|
},
|
|
2553
2537
|
addNodeView() {
|
|
2554
|
-
return (0,
|
|
2538
|
+
return (0, import_react27.ReactNodeViewRenderer)(VariableNodeView);
|
|
2555
2539
|
},
|
|
2556
2540
|
addCommands() {
|
|
2557
2541
|
return {
|
|
@@ -2770,24 +2754,24 @@ var import_state2 = require("@tiptap/pm/state");
|
|
|
2770
2754
|
var React6 = __toESM(require("react"));
|
|
2771
2755
|
|
|
2772
2756
|
// src/ui/suggestion-menu/suggestion-menu.tsx
|
|
2773
|
-
var
|
|
2757
|
+
var import_react29 = require("@floating-ui/react");
|
|
2774
2758
|
var import_editor_utils = require("@kopexa/editor-utils");
|
|
2775
2759
|
var import_state = require("@tiptap/pm/state");
|
|
2776
2760
|
var import_suggestion = require("@tiptap/suggestion");
|
|
2777
2761
|
var React5 = __toESM(require("react"));
|
|
2778
2762
|
|
|
2779
2763
|
// src/hooks/use-floating-element.ts
|
|
2780
|
-
var
|
|
2764
|
+
var import_react28 = require("@floating-ui/react");
|
|
2781
2765
|
var React3 = __toESM(require("react"));
|
|
2782
2766
|
function useFloatingElement(show, referencePos, zIndex, options) {
|
|
2783
2767
|
const { dismissOptions, ...floatingOptions } = options || {};
|
|
2784
|
-
const { refs, update, context, floatingStyles } = (0,
|
|
2768
|
+
const { refs, update, context, floatingStyles } = (0, import_react28.useFloating)({
|
|
2785
2769
|
open: show,
|
|
2786
2770
|
...floatingOptions
|
|
2787
2771
|
});
|
|
2788
|
-
const { isMounted, styles } = (0,
|
|
2789
|
-
const dismiss = (0,
|
|
2790
|
-
const { getReferenceProps, getFloatingProps } = (0,
|
|
2772
|
+
const { isMounted, styles } = (0, import_react28.useTransitionStyles)(context);
|
|
2773
|
+
const dismiss = (0, import_react28.useDismiss)(context, dismissOptions);
|
|
2774
|
+
const { getReferenceProps, getFloatingProps } = (0, import_react28.useInteractions)([dismiss]);
|
|
2791
2775
|
React3.useEffect(() => {
|
|
2792
2776
|
update();
|
|
2793
2777
|
}, [referencePos, update]);
|
|
@@ -3021,13 +3005,13 @@ var SuggestionMenu = ({
|
|
|
3021
3005
|
{
|
|
3022
3006
|
placement: "bottom-start",
|
|
3023
3007
|
middleware: [
|
|
3024
|
-
(0,
|
|
3025
|
-
(0,
|
|
3008
|
+
(0, import_react29.offset)(10),
|
|
3009
|
+
(0, import_react29.flip)({
|
|
3026
3010
|
mainAxis: true,
|
|
3027
3011
|
crossAxis: false
|
|
3028
3012
|
}),
|
|
3029
|
-
(0,
|
|
3030
|
-
(0,
|
|
3013
|
+
(0, import_react29.shift)(),
|
|
3014
|
+
(0, import_react29.size)({
|
|
3031
3015
|
apply({ availableHeight, elements }) {
|
|
3032
3016
|
if (elements.floating) {
|
|
3033
3017
|
const maxHeightValue = maxHeight ? Math.min(maxHeight, availableHeight) : availableHeight;
|
|
@@ -3166,7 +3150,7 @@ var SuggestionMenu = ({
|
|
|
3166
3150
|
if (!isMounted || !show || !editor) {
|
|
3167
3151
|
return null;
|
|
3168
3152
|
}
|
|
3169
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3153
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react29.FloatingPortal, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3170
3154
|
"div",
|
|
3171
3155
|
{
|
|
3172
3156
|
ref,
|
|
@@ -3361,14 +3345,68 @@ var import_extension_text_style = require("@tiptap/extension-text-style");
|
|
|
3361
3345
|
var import_extension_typography = require("@tiptap/extension-typography");
|
|
3362
3346
|
var import_extension_unique_id = require("@tiptap/extension-unique-id");
|
|
3363
3347
|
var import_extensions = require("@tiptap/extensions");
|
|
3364
|
-
var
|
|
3348
|
+
var import_react34 = require("@tiptap/react");
|
|
3365
3349
|
var import_starter_kit = require("@tiptap/starter-kit");
|
|
3366
|
-
var
|
|
3350
|
+
var import_react35 = require("react");
|
|
3351
|
+
|
|
3352
|
+
// src/extensions/custom-color/index.ts
|
|
3353
|
+
var import_react30 = require("@tiptap/react");
|
|
3354
|
+
var CustomColor = import_react30.Mark.create({
|
|
3355
|
+
name: "customColor",
|
|
3356
|
+
addAttributes() {
|
|
3357
|
+
return {
|
|
3358
|
+
color: {
|
|
3359
|
+
default: null,
|
|
3360
|
+
parseHTML: (element) => element.getAttribute("data-text-color"),
|
|
3361
|
+
renderHTML: (attributes) => {
|
|
3362
|
+
const { color } = attributes;
|
|
3363
|
+
if (!color) {
|
|
3364
|
+
return {};
|
|
3365
|
+
}
|
|
3366
|
+
return {
|
|
3367
|
+
"data-text-color": color,
|
|
3368
|
+
style: `color: ${color}`
|
|
3369
|
+
};
|
|
3370
|
+
}
|
|
3371
|
+
},
|
|
3372
|
+
backgroundColor: {
|
|
3373
|
+
default: null,
|
|
3374
|
+
parseHTML: (element) => element.getAttribute("data-background-color"),
|
|
3375
|
+
renderHTML: (attributes) => {
|
|
3376
|
+
const { backgroundColor } = attributes;
|
|
3377
|
+
if (!backgroundColor) {
|
|
3378
|
+
return {};
|
|
3379
|
+
}
|
|
3380
|
+
return {
|
|
3381
|
+
"data-background-color": backgroundColor,
|
|
3382
|
+
style: `background-color: ${backgroundColor}`
|
|
3383
|
+
};
|
|
3384
|
+
}
|
|
3385
|
+
}
|
|
3386
|
+
};
|
|
3387
|
+
},
|
|
3388
|
+
parseHTML() {
|
|
3389
|
+
return [
|
|
3390
|
+
{
|
|
3391
|
+
tag: "span[data-text-color]"
|
|
3392
|
+
},
|
|
3393
|
+
{
|
|
3394
|
+
tag: "span[data-background-color]"
|
|
3395
|
+
}
|
|
3396
|
+
];
|
|
3397
|
+
},
|
|
3398
|
+
renderHTML({ HTMLAttributes }) {
|
|
3399
|
+
if (!HTMLAttributes["data-text-color"] && !HTMLAttributes["data-background-color"]) {
|
|
3400
|
+
return ["span", (0, import_react30.mergeAttributes)(HTMLAttributes), 0];
|
|
3401
|
+
}
|
|
3402
|
+
return ["span", (0, import_react30.mergeAttributes)(HTMLAttributes), 0];
|
|
3403
|
+
}
|
|
3404
|
+
});
|
|
3367
3405
|
|
|
3368
3406
|
// src/extensions/link/index.ts
|
|
3369
3407
|
var import_extension_link = __toESM(require("@tiptap/extension-link"));
|
|
3370
3408
|
var import_state3 = require("@tiptap/pm/state");
|
|
3371
|
-
var
|
|
3409
|
+
var import_react31 = require("@tiptap/react");
|
|
3372
3410
|
var Link = import_extension_link.default.extend({
|
|
3373
3411
|
inclusive: false,
|
|
3374
3412
|
parseHTML() {
|
|
@@ -3397,7 +3435,7 @@ var Link = import_extension_link.default.extend({
|
|
|
3397
3435
|
const { schema, doc, tr } = view.state;
|
|
3398
3436
|
let range;
|
|
3399
3437
|
if (schema.marks.link) {
|
|
3400
|
-
range = (0,
|
|
3438
|
+
range = (0, import_react31.getMarkRange)(doc.resolve(pos), schema.marks.link);
|
|
3401
3439
|
}
|
|
3402
3440
|
if (!range) {
|
|
3403
3441
|
return;
|
|
@@ -3703,8 +3741,8 @@ var NodeBackground = import_core8.Extension.create({
|
|
|
3703
3741
|
// src/extensions/selection/index.ts
|
|
3704
3742
|
var import_state4 = require("@tiptap/pm/state");
|
|
3705
3743
|
var import_view = require("@tiptap/pm/view");
|
|
3706
|
-
var
|
|
3707
|
-
var Selection =
|
|
3744
|
+
var import_react32 = require("@tiptap/react");
|
|
3745
|
+
var Selection = import_react32.Extension.create({
|
|
3708
3746
|
name: "selection",
|
|
3709
3747
|
addProseMirrorPlugins() {
|
|
3710
3748
|
const { editor } = this;
|
|
@@ -3719,7 +3757,7 @@ var Selection = import_react30.Extension.create({
|
|
|
3719
3757
|
if (editor.isFocused === true || !editor.isEditable) {
|
|
3720
3758
|
return null;
|
|
3721
3759
|
}
|
|
3722
|
-
if ((0,
|
|
3760
|
+
if ((0, import_react32.isNodeSelection)(state.selection)) {
|
|
3723
3761
|
return null;
|
|
3724
3762
|
}
|
|
3725
3763
|
return import_view.DecorationSet.create(state.doc, [
|
|
@@ -3794,7 +3832,7 @@ var TabHandler = import_core9.Extension.create({
|
|
|
3794
3832
|
|
|
3795
3833
|
// src/extensions/trailing-node/index.ts
|
|
3796
3834
|
var import_state5 = require("@tiptap/pm/state");
|
|
3797
|
-
var
|
|
3835
|
+
var import_react33 = require("@tiptap/react");
|
|
3798
3836
|
function nodeEqualsType({
|
|
3799
3837
|
types,
|
|
3800
3838
|
node
|
|
@@ -3805,7 +3843,7 @@ function nodeEqualsType({
|
|
|
3805
3843
|
}
|
|
3806
3844
|
return node.type === types;
|
|
3807
3845
|
}
|
|
3808
|
-
var TrailingNode =
|
|
3846
|
+
var TrailingNode = import_react33.Extension.create({
|
|
3809
3847
|
name: "trailingNode",
|
|
3810
3848
|
addOptions() {
|
|
3811
3849
|
return {
|
|
@@ -4086,10 +4124,10 @@ var useCreateEditor = ({
|
|
|
4086
4124
|
const fileHandlerFromContext = useEditorFile();
|
|
4087
4125
|
const fileHandler = fileHandlerProp != null ? fileHandlerProp : fileHandlerFromContext;
|
|
4088
4126
|
const collaboration = useCollaboration();
|
|
4089
|
-
const [collabSyncing, setCollabSyncing] = (0,
|
|
4090
|
-
const placeholderRef = (0,
|
|
4127
|
+
const [collabSyncing, setCollabSyncing] = (0, import_react35.useState)(!!collaboration);
|
|
4128
|
+
const placeholderRef = (0, import_react35.useRef)(placeholder);
|
|
4091
4129
|
placeholderRef.current = placeholder;
|
|
4092
|
-
const [extensions] = (0,
|
|
4130
|
+
const [extensions] = (0, import_react35.useState)(
|
|
4093
4131
|
() => getExtensions({
|
|
4094
4132
|
editable,
|
|
4095
4133
|
placeholder: () => {
|
|
@@ -4107,7 +4145,7 @@ var useCreateEditor = ({
|
|
|
4107
4145
|
})
|
|
4108
4146
|
);
|
|
4109
4147
|
const { onCreate: userOnCreate, ...restOptions } = options;
|
|
4110
|
-
const editor = (0,
|
|
4148
|
+
const editor = (0, import_react34.useEditor)({
|
|
4111
4149
|
editorProps: {
|
|
4112
4150
|
attributes: {
|
|
4113
4151
|
autocomplete: "off",
|
|
@@ -4152,7 +4190,7 @@ var useCreateEditor = ({
|
|
|
4152
4190
|
},
|
|
4153
4191
|
...restOptions
|
|
4154
4192
|
});
|
|
4155
|
-
(0,
|
|
4193
|
+
(0, import_react35.useEffect)(() => {
|
|
4156
4194
|
if (editor && editor.isEditable !== editable) {
|
|
4157
4195
|
editor.setEditable(editable);
|
|
4158
4196
|
}
|
|
@@ -4226,6 +4264,8 @@ function getExtensions({
|
|
|
4226
4264
|
CalloutNode,
|
|
4227
4265
|
MathBlock,
|
|
4228
4266
|
InlineMath,
|
|
4267
|
+
// Legacy support for old documents with customColor marks
|
|
4268
|
+
CustomColor,
|
|
4229
4269
|
// Image support - extended with file reference resolution
|
|
4230
4270
|
ImageNode.configure({
|
|
4231
4271
|
allowBase64: true
|
|
@@ -4372,8 +4412,8 @@ async function handleFileUpload(editor, file, fileHandler, pos) {
|
|
|
4372
4412
|
// src/presets/basic/index.tsx
|
|
4373
4413
|
var import_extension_table2 = require("@kopexa/extension-table");
|
|
4374
4414
|
var import_theme9 = require("@kopexa/theme");
|
|
4375
|
-
var
|
|
4376
|
-
var
|
|
4415
|
+
var import_react62 = require("@tiptap/react");
|
|
4416
|
+
var import_react63 = require("react");
|
|
4377
4417
|
var import_react_intl26 = require("react-intl");
|
|
4378
4418
|
|
|
4379
4419
|
// src/context/editor-context.ts
|
|
@@ -4381,10 +4421,10 @@ var import_react_utils = require("@kopexa/react-utils");
|
|
|
4381
4421
|
var [EditorUIProvider, useEditorUIContext] = (0, import_react_utils.createContext)();
|
|
4382
4422
|
|
|
4383
4423
|
// src/hooks/use-ui-editor-state.ts
|
|
4384
|
-
var
|
|
4424
|
+
var import_react36 = require("@tiptap/react");
|
|
4385
4425
|
function useUiEditorState(editor) {
|
|
4386
4426
|
var _a;
|
|
4387
|
-
return (_a = (0,
|
|
4427
|
+
return (_a = (0, import_react36.useEditorState)({
|
|
4388
4428
|
editor,
|
|
4389
4429
|
selector: ({ editor: editor2 }) => {
|
|
4390
4430
|
if (!editor2) return defaultUiState;
|
|
@@ -4411,7 +4451,7 @@ var import_icons9 = require("@kopexa/icons");
|
|
|
4411
4451
|
var import_input3 = require("@kopexa/input");
|
|
4412
4452
|
var import_popover = require("@kopexa/popover");
|
|
4413
4453
|
var import_toolbar = require("@kopexa/toolbar");
|
|
4414
|
-
var
|
|
4454
|
+
var import_react37 = require("react");
|
|
4415
4455
|
|
|
4416
4456
|
// src/ui/link-popover/use-link-popover.ts
|
|
4417
4457
|
var import_editor_utils5 = require("@kopexa/editor-utils");
|
|
@@ -4667,8 +4707,8 @@ var LinkMain = ({
|
|
|
4667
4707
|
isActive,
|
|
4668
4708
|
onSave
|
|
4669
4709
|
}) => {
|
|
4670
|
-
const [isEditing, setIsEditing] = (0,
|
|
4671
|
-
(0,
|
|
4710
|
+
const [isEditing, setIsEditing] = (0, import_react37.useState)(!isActive || !url);
|
|
4711
|
+
(0, import_react37.useEffect)(() => {
|
|
4672
4712
|
setIsEditing(!isActive || !url);
|
|
4673
4713
|
}, [isActive, url]);
|
|
4674
4714
|
const handleKeyDown = (event) => {
|
|
@@ -4784,7 +4824,7 @@ function LinkPopover({
|
|
|
4784
4824
|
...buttonProps
|
|
4785
4825
|
}) {
|
|
4786
4826
|
const { editor } = (0, import_editor_utils6.useTiptapEditor)(providedEditor);
|
|
4787
|
-
const [isOpen, setIsOpen] = (0,
|
|
4827
|
+
const [isOpen, setIsOpen] = (0, import_react37.useState)(false);
|
|
4788
4828
|
const {
|
|
4789
4829
|
isVisible,
|
|
4790
4830
|
canSet,
|
|
@@ -4800,18 +4840,18 @@ function LinkPopover({
|
|
|
4800
4840
|
hideWhenUnavailable,
|
|
4801
4841
|
onSetLink
|
|
4802
4842
|
});
|
|
4803
|
-
const handleOnOpenChange = (0,
|
|
4843
|
+
const handleOnOpenChange = (0, import_react37.useCallback)(
|
|
4804
4844
|
(nextIsOpen) => {
|
|
4805
4845
|
setIsOpen(nextIsOpen);
|
|
4806
4846
|
onOpenChange == null ? void 0 : onOpenChange(nextIsOpen);
|
|
4807
4847
|
},
|
|
4808
4848
|
[onOpenChange]
|
|
4809
4849
|
);
|
|
4810
|
-
const handleSetLink = (0,
|
|
4850
|
+
const handleSetLink = (0, import_react37.useCallback)(() => {
|
|
4811
4851
|
setLink();
|
|
4812
4852
|
setIsOpen(false);
|
|
4813
4853
|
}, [setLink]);
|
|
4814
|
-
const handleClick = (0,
|
|
4854
|
+
const handleClick = (0, import_react37.useCallback)(
|
|
4815
4855
|
(event) => {
|
|
4816
4856
|
onClick == null ? void 0 : onClick(event);
|
|
4817
4857
|
if (event.defaultPrevented) return;
|
|
@@ -4819,7 +4859,7 @@ function LinkPopover({
|
|
|
4819
4859
|
},
|
|
4820
4860
|
[onClick, isOpen]
|
|
4821
4861
|
);
|
|
4822
|
-
(0,
|
|
4862
|
+
(0, import_react37.useEffect)(() => {
|
|
4823
4863
|
if (autoOpenOnLinkActive && isActive) {
|
|
4824
4864
|
setIsOpen(true);
|
|
4825
4865
|
}
|
|
@@ -4873,8 +4913,8 @@ LinkButton.displayName = "LinkButton";
|
|
|
4873
4913
|
var import_editor_utils7 = require("@kopexa/editor-utils");
|
|
4874
4914
|
var import_icons10 = require("@kopexa/icons");
|
|
4875
4915
|
var import_toolbar2 = require("@kopexa/toolbar");
|
|
4876
|
-
var
|
|
4877
|
-
var
|
|
4916
|
+
var import_react38 = require("@tiptap/react");
|
|
4917
|
+
var import_react39 = require("react");
|
|
4878
4918
|
var import_react_intl16 = require("react-intl");
|
|
4879
4919
|
|
|
4880
4920
|
// src/ui/messages.ts
|
|
@@ -5340,7 +5380,7 @@ function shouldShowMarkButton(params) {
|
|
|
5340
5380
|
return false;
|
|
5341
5381
|
}
|
|
5342
5382
|
if (hideWhenUnavailable) {
|
|
5343
|
-
if ((0,
|
|
5383
|
+
if ((0, import_react38.isNodeSelection)(editor.state.selection) || !canToggleMark(editor, type)) {
|
|
5344
5384
|
return false;
|
|
5345
5385
|
}
|
|
5346
5386
|
}
|
|
@@ -5395,7 +5435,7 @@ var MarkButton = ({
|
|
|
5395
5435
|
shortcutKey,
|
|
5396
5436
|
formattedName
|
|
5397
5437
|
} = useMarkState(editor, type, disabled);
|
|
5398
|
-
const handleClick = (0,
|
|
5438
|
+
const handleClick = (0, import_react39.useCallback)(
|
|
5399
5439
|
(e) => {
|
|
5400
5440
|
onClick == null ? void 0 : onClick(e);
|
|
5401
5441
|
if (!e.defaultPrevented && !isDisabled && editor) {
|
|
@@ -5404,7 +5444,7 @@ var MarkButton = ({
|
|
|
5404
5444
|
},
|
|
5405
5445
|
[onClick, isDisabled, editor, type]
|
|
5406
5446
|
);
|
|
5407
|
-
const show = (0,
|
|
5447
|
+
const show = (0, import_react39.useMemo)(() => {
|
|
5408
5448
|
return shouldShowMarkButton({
|
|
5409
5449
|
editor,
|
|
5410
5450
|
type,
|
|
@@ -5484,7 +5524,7 @@ var React9 = __toESM(require("react"));
|
|
|
5484
5524
|
|
|
5485
5525
|
// src/hooks/use-floating-toolbar-visibility.ts
|
|
5486
5526
|
var import_state6 = require("@tiptap/pm/state");
|
|
5487
|
-
var
|
|
5527
|
+
var import_react40 = require("@tiptap/react");
|
|
5488
5528
|
var React8 = __toESM(require("react"));
|
|
5489
5529
|
var HIDE_FLOATING_META = "hideFloatingToolbar";
|
|
5490
5530
|
var selectNodeAndHideFloating = (editor, pos) => {
|
|
@@ -5586,39 +5626,39 @@ var import_button9 = require("@kopexa/button");
|
|
|
5586
5626
|
var import_icons11 = require("@kopexa/icons");
|
|
5587
5627
|
var import_input4 = require("@kopexa/input");
|
|
5588
5628
|
var import_menus2 = require("@tiptap/react/menus");
|
|
5589
|
-
var
|
|
5629
|
+
var import_react41 = require("react");
|
|
5590
5630
|
var import_react_intl17 = require("react-intl");
|
|
5591
5631
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
5592
5632
|
function LinkBubble({ editor }) {
|
|
5593
5633
|
const intl = (0, import_react_intl17.useIntl)();
|
|
5594
|
-
const [isEditing, setIsEditing] = (0,
|
|
5595
|
-
const [url, setUrl] = (0,
|
|
5596
|
-
const getCurrentUrl = (0,
|
|
5634
|
+
const [isEditing, setIsEditing] = (0, import_react41.useState)(false);
|
|
5635
|
+
const [url, setUrl] = (0, import_react41.useState)("");
|
|
5636
|
+
const getCurrentUrl = (0, import_react41.useCallback)(() => {
|
|
5597
5637
|
if (!editor) return "";
|
|
5598
5638
|
const attrs = editor.getAttributes("link");
|
|
5599
5639
|
return attrs.href || "";
|
|
5600
5640
|
}, [editor]);
|
|
5601
|
-
(0,
|
|
5641
|
+
(0, import_react41.useEffect)(() => {
|
|
5602
5642
|
const isLinkActive2 = editor == null ? void 0 : editor.isActive("link");
|
|
5603
5643
|
if (isLinkActive2) {
|
|
5604
5644
|
setUrl(getCurrentUrl());
|
|
5605
5645
|
setIsEditing(false);
|
|
5606
5646
|
}
|
|
5607
5647
|
}, [editor, getCurrentUrl]);
|
|
5608
|
-
const handleOpenLink = (0,
|
|
5648
|
+
const handleOpenLink = (0, import_react41.useCallback)(() => {
|
|
5609
5649
|
const href = getCurrentUrl();
|
|
5610
5650
|
if (href) {
|
|
5611
5651
|
window.open(href, "_blank", "noopener,noreferrer");
|
|
5612
5652
|
}
|
|
5613
5653
|
}, [getCurrentUrl]);
|
|
5614
|
-
const handleRemoveLink = (0,
|
|
5654
|
+
const handleRemoveLink = (0, import_react41.useCallback)(() => {
|
|
5615
5655
|
editor == null ? void 0 : editor.chain().focus().unsetLink().run();
|
|
5616
5656
|
}, [editor]);
|
|
5617
|
-
const handleEdit = (0,
|
|
5657
|
+
const handleEdit = (0, import_react41.useCallback)(() => {
|
|
5618
5658
|
setUrl(getCurrentUrl());
|
|
5619
5659
|
setIsEditing(true);
|
|
5620
5660
|
}, [getCurrentUrl]);
|
|
5621
|
-
const handleSave = (0,
|
|
5661
|
+
const handleSave = (0, import_react41.useCallback)(() => {
|
|
5622
5662
|
if (url) {
|
|
5623
5663
|
editor == null ? void 0 : editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
|
|
5624
5664
|
} else {
|
|
@@ -5626,7 +5666,7 @@ function LinkBubble({ editor }) {
|
|
|
5626
5666
|
}
|
|
5627
5667
|
setIsEditing(false);
|
|
5628
5668
|
}, [editor, url]);
|
|
5629
|
-
const handleKeyDown = (0,
|
|
5669
|
+
const handleKeyDown = (0, import_react41.useCallback)(
|
|
5630
5670
|
(e) => {
|
|
5631
5671
|
if (e.key === "Enter") {
|
|
5632
5672
|
e.preventDefault();
|
|
@@ -5751,8 +5791,8 @@ var import_react_intl19 = require("react-intl");
|
|
|
5751
5791
|
// src/ui/table-button/use-table.ts
|
|
5752
5792
|
var import_editor_utils9 = require("@kopexa/editor-utils");
|
|
5753
5793
|
var import_icons12 = require("@kopexa/icons");
|
|
5754
|
-
var
|
|
5755
|
-
var
|
|
5794
|
+
var import_react42 = require("@tiptap/react");
|
|
5795
|
+
var import_react43 = require("react");
|
|
5756
5796
|
var import_react_intl18 = require("react-intl");
|
|
5757
5797
|
function canToggle(editor) {
|
|
5758
5798
|
if (!editor || !editor.isEditable) return false;
|
|
@@ -5784,7 +5824,7 @@ function shouldShowButton(props) {
|
|
|
5784
5824
|
if (!editor || !editor.isEditable) return false;
|
|
5785
5825
|
if (!(0, import_editor_utils9.isNodeInSchema)("table", editor)) return false;
|
|
5786
5826
|
if (hideWhenUnavailable) {
|
|
5787
|
-
if ((0,
|
|
5827
|
+
if ((0, import_react42.isNodeSelection)(editor.state.selection) || !canToggle) {
|
|
5788
5828
|
return false;
|
|
5789
5829
|
}
|
|
5790
5830
|
}
|
|
@@ -5798,10 +5838,10 @@ function useTableBlock(config) {
|
|
|
5798
5838
|
} = config || {};
|
|
5799
5839
|
const intl = (0, import_react_intl18.useIntl)();
|
|
5800
5840
|
const { editor } = (0, import_editor_utils9.useTiptapEditor)(providedEditor);
|
|
5801
|
-
const [isVisible, setIsVisible] = (0,
|
|
5841
|
+
const [isVisible, setIsVisible] = (0, import_react43.useState)(true);
|
|
5802
5842
|
const canToggleState = canToggle(editor);
|
|
5803
5843
|
const isActive = (editor == null ? void 0 : editor.isActive("table")) || false;
|
|
5804
|
-
(0,
|
|
5844
|
+
(0, import_react43.useEffect)(() => {
|
|
5805
5845
|
if (!editor) return;
|
|
5806
5846
|
const handleSelectionUpdate = () => {
|
|
5807
5847
|
setIsVisible(shouldShowButton({ editor, hideWhenUnavailable }));
|
|
@@ -5812,7 +5852,7 @@ function useTableBlock(config) {
|
|
|
5812
5852
|
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
5813
5853
|
};
|
|
5814
5854
|
}, [editor, hideWhenUnavailable]);
|
|
5815
|
-
const handleToggle = (0,
|
|
5855
|
+
const handleToggle = (0, import_react43.useCallback)(() => {
|
|
5816
5856
|
if (!editor) return false;
|
|
5817
5857
|
const success = toggleTable(editor);
|
|
5818
5858
|
if (success) {
|
|
@@ -6374,7 +6414,7 @@ var import_icons26 = require("@kopexa/icons");
|
|
|
6374
6414
|
var import_popover3 = require("@kopexa/popover");
|
|
6375
6415
|
var import_toolbar10 = require("@kopexa/toolbar");
|
|
6376
6416
|
var import_use_is_mobile3 = require("@kopexa/use-is-mobile");
|
|
6377
|
-
var
|
|
6417
|
+
var import_react61 = require("react");
|
|
6378
6418
|
var import_react_intl25 = require("react-intl");
|
|
6379
6419
|
|
|
6380
6420
|
// src/hooks/use-cursor-visibility.ts
|
|
@@ -6485,13 +6525,13 @@ var import_editor_utils14 = require("@kopexa/editor-utils");
|
|
|
6485
6525
|
var import_icons15 = require("@kopexa/icons");
|
|
6486
6526
|
var import_popover2 = require("@kopexa/popover");
|
|
6487
6527
|
var import_toolbar5 = require("@kopexa/toolbar");
|
|
6488
|
-
var
|
|
6528
|
+
var import_react45 = require("react");
|
|
6489
6529
|
|
|
6490
6530
|
// src/ui/color-highlight-button/color-highlight-button.tsx
|
|
6491
6531
|
var import_editor_utils13 = require("@kopexa/editor-utils");
|
|
6492
6532
|
var import_theme8 = require("@kopexa/theme");
|
|
6493
6533
|
var import_toolbar4 = require("@kopexa/toolbar");
|
|
6494
|
-
var
|
|
6534
|
+
var import_react44 = require("react");
|
|
6495
6535
|
|
|
6496
6536
|
// src/ui/color-highlight-button/use-color-highlight.ts
|
|
6497
6537
|
var import_editor_utils12 = require("@kopexa/editor-utils");
|
|
@@ -6688,7 +6728,7 @@ var ColorHighlightButton = ({
|
|
|
6688
6728
|
hideWhenUnavailable,
|
|
6689
6729
|
onApplied
|
|
6690
6730
|
});
|
|
6691
|
-
const handleClick = (0,
|
|
6731
|
+
const handleClick = (0, import_react44.useCallback)(
|
|
6692
6732
|
(event) => {
|
|
6693
6733
|
onClick == null ? void 0 : onClick(event);
|
|
6694
6734
|
if (event.defaultPrevented) return;
|
|
@@ -6696,7 +6736,7 @@ var ColorHighlightButton = ({
|
|
|
6696
6736
|
},
|
|
6697
6737
|
[handleColorHighlight, onClick]
|
|
6698
6738
|
);
|
|
6699
|
-
const buttonStyle = (0,
|
|
6739
|
+
const buttonStyle = (0, import_react44.useMemo)(
|
|
6700
6740
|
() => ({
|
|
6701
6741
|
...style,
|
|
6702
6742
|
"--highlight-color": highlightColor
|
|
@@ -6779,8 +6819,8 @@ function ColorHighlightPopoverContent({
|
|
|
6779
6819
|
])
|
|
6780
6820
|
}) {
|
|
6781
6821
|
const { handleRemoveHighlight } = useColorHighlight({ editor });
|
|
6782
|
-
const containerRef = (0,
|
|
6783
|
-
const menuItems = (0,
|
|
6822
|
+
const containerRef = (0, import_react45.useRef)(null);
|
|
6823
|
+
const menuItems = (0, import_react45.useMemo)(
|
|
6784
6824
|
() => [...colors, { label: "Remove highlight", value: "none" }],
|
|
6785
6825
|
[colors]
|
|
6786
6826
|
);
|
|
@@ -6848,7 +6888,7 @@ function ColorHighlightPopover({
|
|
|
6848
6888
|
...props
|
|
6849
6889
|
}) {
|
|
6850
6890
|
const { editor } = (0, import_editor_utils14.useTiptapEditor)(providedEditor);
|
|
6851
|
-
const [isOpen, setIsOpen] = (0,
|
|
6891
|
+
const [isOpen, setIsOpen] = (0, import_react45.useState)(false);
|
|
6852
6892
|
const { isVisible, canColorHighlight: canColorHighlight2, isActive, label } = useColorHighlight({
|
|
6853
6893
|
editor,
|
|
6854
6894
|
hideWhenUnavailable,
|
|
@@ -6882,15 +6922,15 @@ var import_button13 = require("@kopexa/button");
|
|
|
6882
6922
|
var import_dropdown_menu = require("@kopexa/dropdown-menu");
|
|
6883
6923
|
var import_editor_utils16 = require("@kopexa/editor-utils");
|
|
6884
6924
|
var import_icons17 = require("@kopexa/icons");
|
|
6885
|
-
var
|
|
6886
|
-
var
|
|
6925
|
+
var import_react48 = require("@tiptap/react");
|
|
6926
|
+
var import_react49 = require("react");
|
|
6887
6927
|
|
|
6888
6928
|
// src/ui/list-button/index.tsx
|
|
6889
6929
|
var import_button12 = require("@kopexa/button");
|
|
6890
6930
|
var import_editor_utils15 = require("@kopexa/editor-utils");
|
|
6891
6931
|
var import_icons16 = require("@kopexa/icons");
|
|
6892
|
-
var
|
|
6893
|
-
var
|
|
6932
|
+
var import_react46 = require("@tiptap/react");
|
|
6933
|
+
var import_react47 = require("react");
|
|
6894
6934
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
6895
6935
|
var listOptions = [
|
|
6896
6936
|
{
|
|
@@ -6965,7 +7005,7 @@ function shouldShowListButton(params) {
|
|
|
6965
7005
|
return false;
|
|
6966
7006
|
}
|
|
6967
7007
|
if (hideWhenUnavailable) {
|
|
6968
|
-
if ((0,
|
|
7008
|
+
if ((0, import_react46.isNodeSelection)(editor.state.selection) || !canToggleList(editor, type)) {
|
|
6969
7009
|
return false;
|
|
6970
7010
|
}
|
|
6971
7011
|
}
|
|
@@ -7000,7 +7040,7 @@ var ListButton = ({
|
|
|
7000
7040
|
type
|
|
7001
7041
|
);
|
|
7002
7042
|
const Icon = (listOption == null ? void 0 : listOption.icon) || import_icons16.ListIcon;
|
|
7003
|
-
const handleClick = (0,
|
|
7043
|
+
const handleClick = (0, import_react47.useCallback)(
|
|
7004
7044
|
(e) => {
|
|
7005
7045
|
onClick == null ? void 0 : onClick(e);
|
|
7006
7046
|
if (!e.defaultPrevented && editor) {
|
|
@@ -7009,7 +7049,7 @@ var ListButton = ({
|
|
|
7009
7049
|
},
|
|
7010
7050
|
[onClick, editor, type]
|
|
7011
7051
|
);
|
|
7012
|
-
const show = (0,
|
|
7052
|
+
const show = (0, import_react47.useMemo)(() => {
|
|
7013
7053
|
return shouldShowListButton({
|
|
7014
7054
|
editor,
|
|
7015
7055
|
type,
|
|
@@ -7063,24 +7103,24 @@ function shouldShowListDropdown(params) {
|
|
|
7063
7103
|
return false;
|
|
7064
7104
|
}
|
|
7065
7105
|
if (hideWhenUnavailable) {
|
|
7066
|
-
if ((0,
|
|
7106
|
+
if ((0, import_react48.isNodeSelection)(editor.state.selection) || !canToggleAny) {
|
|
7067
7107
|
return false;
|
|
7068
7108
|
}
|
|
7069
7109
|
}
|
|
7070
7110
|
return true;
|
|
7071
7111
|
}
|
|
7072
7112
|
function useListDropdownState(editor, availableTypes) {
|
|
7073
|
-
const [isOpen, setIsOpen] = (0,
|
|
7113
|
+
const [isOpen, setIsOpen] = (0, import_react49.useState)(false);
|
|
7074
7114
|
const listInSchema = availableTypes.some(
|
|
7075
7115
|
(type) => (0, import_editor_utils16.isNodeInSchema)(type, editor)
|
|
7076
7116
|
);
|
|
7077
|
-
const filteredLists = (0,
|
|
7117
|
+
const filteredLists = (0, import_react49.useMemo)(
|
|
7078
7118
|
() => getFilteredListOptions(availableTypes),
|
|
7079
7119
|
[availableTypes]
|
|
7080
7120
|
);
|
|
7081
7121
|
const canToggleAny = canToggleAnyList(editor, availableTypes);
|
|
7082
7122
|
const isAnyActive = isAnyListActive(editor, availableTypes);
|
|
7083
|
-
const handleOpenChange = (0,
|
|
7123
|
+
const handleOpenChange = (0, import_react49.useCallback)(
|
|
7084
7124
|
(open, callback) => {
|
|
7085
7125
|
setIsOpen(open);
|
|
7086
7126
|
callback == null ? void 0 : callback(open);
|
|
@@ -7098,7 +7138,7 @@ function useListDropdownState(editor, availableTypes) {
|
|
|
7098
7138
|
};
|
|
7099
7139
|
}
|
|
7100
7140
|
function useActiveListIcon(editor, filteredLists) {
|
|
7101
|
-
return (0,
|
|
7141
|
+
return (0, import_react49.useCallback)(() => {
|
|
7102
7142
|
const activeOption = filteredLists.find(
|
|
7103
7143
|
(option) => isListActive(editor, option.type)
|
|
7104
7144
|
);
|
|
@@ -7122,7 +7162,7 @@ function ListDropdownMenu({
|
|
|
7122
7162
|
handleOpenChange
|
|
7123
7163
|
} = useListDropdownState(editor, types);
|
|
7124
7164
|
const getActiveIcon = useActiveListIcon(editor, filteredLists);
|
|
7125
|
-
const show = (0,
|
|
7165
|
+
const show = (0, import_react49.useMemo)(() => {
|
|
7126
7166
|
return shouldShowListDropdown({
|
|
7127
7167
|
editor,
|
|
7128
7168
|
listTypes: types,
|
|
@@ -7131,7 +7171,7 @@ function ListDropdownMenu({
|
|
|
7131
7171
|
canToggleAny
|
|
7132
7172
|
});
|
|
7133
7173
|
}, [editor, types, hideWhenUnavailable, listInSchema, canToggleAny]);
|
|
7134
|
-
const handleOnOpenChange = (0,
|
|
7174
|
+
const handleOnOpenChange = (0, import_react49.useCallback)(
|
|
7135
7175
|
(open) => handleOpenChange(open, onOpenChange),
|
|
7136
7176
|
[handleOpenChange, onOpenChange]
|
|
7137
7177
|
);
|
|
@@ -7172,7 +7212,7 @@ function ListDropdownMenu({
|
|
|
7172
7212
|
// src/ui/table-button/index.tsx
|
|
7173
7213
|
var import_editor_utils17 = require("@kopexa/editor-utils");
|
|
7174
7214
|
var import_toolbar6 = require("@kopexa/toolbar");
|
|
7175
|
-
var
|
|
7215
|
+
var import_react50 = require("react");
|
|
7176
7216
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
7177
7217
|
var TableButton = ({
|
|
7178
7218
|
editor: providedEditor,
|
|
@@ -7197,7 +7237,7 @@ var TableButton = ({
|
|
|
7197
7237
|
hideWhenUnavailable,
|
|
7198
7238
|
onToggled
|
|
7199
7239
|
});
|
|
7200
|
-
const handleClick = (0,
|
|
7240
|
+
const handleClick = (0, import_react50.useCallback)(
|
|
7201
7241
|
(event) => {
|
|
7202
7242
|
onClick == null ? void 0 : onClick(event);
|
|
7203
7243
|
if (event.defaultPrevented) return;
|
|
@@ -7235,12 +7275,12 @@ var TableButton = ({
|
|
|
7235
7275
|
// src/ui/text-align-button/text-align-button.tsx
|
|
7236
7276
|
var import_button14 = require("@kopexa/button");
|
|
7237
7277
|
var import_editor_utils19 = require("@kopexa/editor-utils");
|
|
7238
|
-
var
|
|
7278
|
+
var import_react52 = require("react");
|
|
7239
7279
|
|
|
7240
7280
|
// src/ui/text-align-button/use-text-align.ts
|
|
7241
7281
|
var import_editor_utils18 = require("@kopexa/editor-utils");
|
|
7242
7282
|
var import_icons18 = require("@kopexa/icons");
|
|
7243
|
-
var
|
|
7283
|
+
var import_react51 = require("react");
|
|
7244
7284
|
var import_react_intl21 = require("react-intl");
|
|
7245
7285
|
var TEXT_ALIGN_SHORTCUT_KEYS = {
|
|
7246
7286
|
left: "mod+shift+l",
|
|
@@ -7300,10 +7340,10 @@ function useTextAlign(config) {
|
|
|
7300
7340
|
} = config;
|
|
7301
7341
|
const intl = (0, import_react_intl21.useIntl)();
|
|
7302
7342
|
const { editor } = (0, import_editor_utils18.useTiptapEditor)(providedEditor);
|
|
7303
|
-
const [isVisible, setIsVisible] = (0,
|
|
7343
|
+
const [isVisible, setIsVisible] = (0, import_react51.useState)(true);
|
|
7304
7344
|
const canAlign = canSetTextAlign(editor, align);
|
|
7305
7345
|
const isActive = isTextAlignActive(editor, align);
|
|
7306
|
-
(0,
|
|
7346
|
+
(0, import_react51.useEffect)(() => {
|
|
7307
7347
|
if (!editor) return;
|
|
7308
7348
|
const handleSelectionUpdate = () => {
|
|
7309
7349
|
setIsVisible(shouldShowButton3({ editor, align, hideWhenUnavailable }));
|
|
@@ -7314,7 +7354,7 @@ function useTextAlign(config) {
|
|
|
7314
7354
|
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
7315
7355
|
};
|
|
7316
7356
|
}, [editor, hideWhenUnavailable, align]);
|
|
7317
|
-
const handleTextAlign = (0,
|
|
7357
|
+
const handleTextAlign = (0, import_react51.useCallback)(() => {
|
|
7318
7358
|
if (!editor) return false;
|
|
7319
7359
|
const success = setTextAlign(editor, align);
|
|
7320
7360
|
if (success) {
|
|
@@ -7361,7 +7401,7 @@ var TextAlignButton = ({
|
|
|
7361
7401
|
hideWhenUnavailable,
|
|
7362
7402
|
onAligned
|
|
7363
7403
|
});
|
|
7364
|
-
const handleClick = (0,
|
|
7404
|
+
const handleClick = (0, import_react52.useCallback)(
|
|
7365
7405
|
(e) => {
|
|
7366
7406
|
onClick == null ? void 0 : onClick(e);
|
|
7367
7407
|
if (e.defaultPrevented) return;
|
|
@@ -7397,7 +7437,7 @@ var TextAlignButton = ({
|
|
|
7397
7437
|
var import_button17 = require("@kopexa/button");
|
|
7398
7438
|
var import_dropdown_menu2 = require("@kopexa/dropdown-menu");
|
|
7399
7439
|
var import_editor_utils28 = require("@kopexa/editor-utils");
|
|
7400
|
-
var
|
|
7440
|
+
var import_react58 = require("react");
|
|
7401
7441
|
var import_react_intl23 = require("react-intl");
|
|
7402
7442
|
|
|
7403
7443
|
// src/ui/blockquote-button/blockquote-button.tsx
|
|
@@ -7585,7 +7625,7 @@ var BlockquoteButton = ({
|
|
|
7585
7625
|
var import_editor_utils23 = require("@kopexa/editor-utils");
|
|
7586
7626
|
var import_icons21 = require("@kopexa/icons");
|
|
7587
7627
|
var import_toolbar8 = require("@kopexa/toolbar");
|
|
7588
|
-
var
|
|
7628
|
+
var import_react53 = require("react");
|
|
7589
7629
|
|
|
7590
7630
|
// src/ui/codeblock-button/use-code-block.ts
|
|
7591
7631
|
var import_editor_utils22 = require("@kopexa/editor-utils");
|
|
@@ -7719,7 +7759,7 @@ var CodeBlockButton = ({
|
|
|
7719
7759
|
hideWhenUnavailable,
|
|
7720
7760
|
onToggled
|
|
7721
7761
|
});
|
|
7722
|
-
const handleClick = (0,
|
|
7762
|
+
const handleClick = (0, import_react53.useCallback)(
|
|
7723
7763
|
(event) => {
|
|
7724
7764
|
onClick == null ? void 0 : onClick(event);
|
|
7725
7765
|
if (event.defaultPrevented) return;
|
|
@@ -7762,7 +7802,7 @@ var import_icons22 = require("@kopexa/icons");
|
|
|
7762
7802
|
var React18 = __toESM(require("react"));
|
|
7763
7803
|
|
|
7764
7804
|
// src/ui/heading-button/utils.ts
|
|
7765
|
-
var
|
|
7805
|
+
var import_react54 = require("@tiptap/react");
|
|
7766
7806
|
var headingShortcutKeys = {
|
|
7767
7807
|
1: "Ctrl-Alt-1",
|
|
7768
7808
|
2: "Ctrl-Alt-2",
|
|
@@ -7803,7 +7843,7 @@ function shouldShowHeadingButton(params) {
|
|
|
7803
7843
|
return false;
|
|
7804
7844
|
}
|
|
7805
7845
|
if (hideWhenUnavailable) {
|
|
7806
|
-
if ((0,
|
|
7846
|
+
if ((0, import_react54.isNodeSelection)(editor.state.selection)) {
|
|
7807
7847
|
return false;
|
|
7808
7848
|
}
|
|
7809
7849
|
}
|
|
@@ -7909,14 +7949,14 @@ var import_button16 = require("@kopexa/button");
|
|
|
7909
7949
|
var import_chip = require("@kopexa/chip");
|
|
7910
7950
|
var import_editor_utils26 = require("@kopexa/editor-utils");
|
|
7911
7951
|
var import_shared_utils = require("@kopexa/shared-utils");
|
|
7912
|
-
var
|
|
7952
|
+
var import_react56 = require("react");
|
|
7913
7953
|
|
|
7914
7954
|
// src/ui/text-button/use-text.ts
|
|
7915
7955
|
var import_editor_utils25 = require("@kopexa/editor-utils");
|
|
7916
7956
|
var import_icons23 = require("@kopexa/icons");
|
|
7917
7957
|
var import_use_is_mobile2 = require("@kopexa/use-is-mobile");
|
|
7918
7958
|
var import_state9 = require("@tiptap/pm/state");
|
|
7919
|
-
var
|
|
7959
|
+
var import_react55 = require("react");
|
|
7920
7960
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
|
7921
7961
|
var TEXT_SHORTCUT_KEY = "mod+alt+0";
|
|
7922
7962
|
function canToggleText(editor, turnInto = true) {
|
|
@@ -8009,10 +8049,10 @@ function useText(config) {
|
|
|
8009
8049
|
} = config || {};
|
|
8010
8050
|
const { editor } = (0, import_editor_utils25.useTiptapEditor)(providedEditor);
|
|
8011
8051
|
const isMobile = (0, import_use_is_mobile2.useIsMobile)();
|
|
8012
|
-
const [isVisible, setIsVisible] = (0,
|
|
8052
|
+
const [isVisible, setIsVisible] = (0, import_react55.useState)(true);
|
|
8013
8053
|
const canToggle3 = canToggleText(editor);
|
|
8014
8054
|
const isActive = isParagraphActive(editor);
|
|
8015
|
-
(0,
|
|
8055
|
+
(0, import_react55.useEffect)(() => {
|
|
8016
8056
|
if (!editor) return;
|
|
8017
8057
|
const handleSelectionUpdate = () => {
|
|
8018
8058
|
setIsVisible(shouldShowButton6({ editor, hideWhenUnavailable }));
|
|
@@ -8023,7 +8063,7 @@ function useText(config) {
|
|
|
8023
8063
|
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
8024
8064
|
};
|
|
8025
8065
|
}, [editor, hideWhenUnavailable]);
|
|
8026
|
-
const handleToggle = (0,
|
|
8066
|
+
const handleToggle = (0, import_react55.useCallback)(() => {
|
|
8027
8067
|
if (!editor) return false;
|
|
8028
8068
|
const success = toggleParagraph(editor);
|
|
8029
8069
|
if (success) {
|
|
@@ -8086,7 +8126,7 @@ var TextButton = ({
|
|
|
8086
8126
|
hideWhenUnavailable,
|
|
8087
8127
|
onToggled
|
|
8088
8128
|
});
|
|
8089
|
-
const handleClick = (0,
|
|
8129
|
+
const handleClick = (0, import_react56.useCallback)(
|
|
8090
8130
|
(event) => {
|
|
8091
8131
|
onClick == null ? void 0 : onClick(event);
|
|
8092
8132
|
if (event.defaultPrevented) return;
|
|
@@ -8127,7 +8167,7 @@ var TextButton = ({
|
|
|
8127
8167
|
var import_editor_utils27 = require("@kopexa/editor-utils");
|
|
8128
8168
|
var import_icons24 = require("@kopexa/icons");
|
|
8129
8169
|
var import_state10 = require("@tiptap/pm/state");
|
|
8130
|
-
var
|
|
8170
|
+
var import_react57 = require("react");
|
|
8131
8171
|
var import_react_intl22 = require("react-intl");
|
|
8132
8172
|
var TURN_INTO_BLOCKS = [
|
|
8133
8173
|
"paragraph",
|
|
@@ -8225,14 +8265,14 @@ function useTurnIntoDropdown(config) {
|
|
|
8225
8265
|
} = config || {};
|
|
8226
8266
|
const intl = (0, import_react_intl22.useIntl)();
|
|
8227
8267
|
const { editor } = (0, import_editor_utils27.useTiptapEditor)(providedEditor);
|
|
8228
|
-
const [isOpen, setIsOpen] = (0,
|
|
8229
|
-
const [isVisible, setIsVisible] = (0,
|
|
8230
|
-
const translatedBlockTypeOptions = (0,
|
|
8268
|
+
const [isOpen, setIsOpen] = (0, import_react57.useState)(false);
|
|
8269
|
+
const [isVisible, setIsVisible] = (0, import_react57.useState)(true);
|
|
8270
|
+
const translatedBlockTypeOptions = (0, import_react57.useMemo)(
|
|
8231
8271
|
() => createBlockTypeOptions(intl.formatMessage),
|
|
8232
8272
|
[intl]
|
|
8233
8273
|
);
|
|
8234
8274
|
const canToggle3 = canTurnInto(editor, blockTypes);
|
|
8235
|
-
const activeBlockType = (0,
|
|
8275
|
+
const activeBlockType = (0, import_react57.useMemo)(() => {
|
|
8236
8276
|
if (!editor) return translatedBlockTypeOptions[0];
|
|
8237
8277
|
const filteredOptions2 = blockTypes ? translatedBlockTypeOptions.filter(
|
|
8238
8278
|
(opt) => blockTypes.includes(opt.type)
|
|
@@ -8242,13 +8282,13 @@ function useTurnIntoDropdown(config) {
|
|
|
8242
8282
|
);
|
|
8243
8283
|
return activeOption || filteredOptions2[0];
|
|
8244
8284
|
}, [editor, blockTypes, translatedBlockTypeOptions]);
|
|
8245
|
-
const filteredOptions = (0,
|
|
8285
|
+
const filteredOptions = (0, import_react57.useMemo)(() => {
|
|
8246
8286
|
if (!blockTypes) return translatedBlockTypeOptions;
|
|
8247
8287
|
return translatedBlockTypeOptions.filter(
|
|
8248
8288
|
(opt) => blockTypes.includes(opt.type)
|
|
8249
8289
|
);
|
|
8250
8290
|
}, [blockTypes, translatedBlockTypeOptions]);
|
|
8251
|
-
const handleOpenChange = (0,
|
|
8291
|
+
const handleOpenChange = (0, import_react57.useCallback)(
|
|
8252
8292
|
(open) => {
|
|
8253
8293
|
if (!editor || !canToggle3) return;
|
|
8254
8294
|
setIsOpen(open);
|
|
@@ -8256,7 +8296,7 @@ function useTurnIntoDropdown(config) {
|
|
|
8256
8296
|
},
|
|
8257
8297
|
[canToggle3, editor, onOpenChange]
|
|
8258
8298
|
);
|
|
8259
|
-
(0,
|
|
8299
|
+
(0, import_react57.useEffect)(() => {
|
|
8260
8300
|
if (!editor) return;
|
|
8261
8301
|
const handleSelectionUpdate = () => {
|
|
8262
8302
|
setIsVisible(
|
|
@@ -8295,7 +8335,7 @@ function useTurnIntoDropdown(config) {
|
|
|
8295
8335
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
8296
8336
|
var TurnIntoDropdownContent = ({ blockTypes }) => {
|
|
8297
8337
|
const intl = (0, import_react_intl23.useIntl)();
|
|
8298
|
-
const filteredOptions = (0,
|
|
8338
|
+
const filteredOptions = (0, import_react58.useMemo)(() => {
|
|
8299
8339
|
const allOptions = createBlockTypeOptions(intl.formatMessage);
|
|
8300
8340
|
if (!blockTypes) return allOptions;
|
|
8301
8341
|
return allOptions.filter((opt) => blockTypes.includes(opt.type));
|
|
@@ -8393,7 +8433,7 @@ function renderBlockTypeButton(option, key) {
|
|
|
8393
8433
|
return null;
|
|
8394
8434
|
}
|
|
8395
8435
|
}
|
|
8396
|
-
var TurnIntoDropdown = (0,
|
|
8436
|
+
var TurnIntoDropdown = (0, import_react58.forwardRef)(
|
|
8397
8437
|
({
|
|
8398
8438
|
editor: providedEditor,
|
|
8399
8439
|
hideWhenUnavailable = false,
|
|
@@ -8458,12 +8498,12 @@ TurnIntoDropdown.displayName = "TurnIntoDropdown";
|
|
|
8458
8498
|
// src/ui/undo-redo-button/undo-redo-button.tsx
|
|
8459
8499
|
var import_editor_utils30 = require("@kopexa/editor-utils");
|
|
8460
8500
|
var import_toolbar9 = require("@kopexa/toolbar");
|
|
8461
|
-
var
|
|
8501
|
+
var import_react60 = require("react");
|
|
8462
8502
|
|
|
8463
8503
|
// src/ui/undo-redo-button/use-undo-redo.ts
|
|
8464
8504
|
var import_editor_utils29 = require("@kopexa/editor-utils");
|
|
8465
8505
|
var import_icons25 = require("@kopexa/icons");
|
|
8466
|
-
var
|
|
8506
|
+
var import_react59 = require("react");
|
|
8467
8507
|
var import_react_intl24 = require("react-intl");
|
|
8468
8508
|
var UNDO_REDO_SHORTCUT_KEYS = {
|
|
8469
8509
|
undo: "mod+z",
|
|
@@ -8505,9 +8545,9 @@ function useUndoRedo(config) {
|
|
|
8505
8545
|
} = config;
|
|
8506
8546
|
const intl = (0, import_react_intl24.useIntl)();
|
|
8507
8547
|
const { editor } = (0, import_editor_utils29.useTiptapEditor)(providedEditor);
|
|
8508
|
-
const [isVisible, setIsVisible] = (0,
|
|
8548
|
+
const [isVisible, setIsVisible] = (0, import_react59.useState)(true);
|
|
8509
8549
|
const canExecute = canExecuteUndoRedoAction(editor, action);
|
|
8510
|
-
(0,
|
|
8550
|
+
(0, import_react59.useEffect)(() => {
|
|
8511
8551
|
if (!editor) return;
|
|
8512
8552
|
const handleUpdate = () => {
|
|
8513
8553
|
setIsVisible(shouldShowButton7({ editor, hideWhenUnavailable, action }));
|
|
@@ -8518,7 +8558,7 @@ function useUndoRedo(config) {
|
|
|
8518
8558
|
editor.off("transaction", handleUpdate);
|
|
8519
8559
|
};
|
|
8520
8560
|
}, [editor, hideWhenUnavailable, action]);
|
|
8521
|
-
const handleAction = (0,
|
|
8561
|
+
const handleAction = (0, import_react59.useCallback)(() => {
|
|
8522
8562
|
if (!editor) return false;
|
|
8523
8563
|
const success = executeUndoRedoAction(editor, action);
|
|
8524
8564
|
if (success) {
|
|
@@ -8556,7 +8596,7 @@ var UndoRedoButton = ({
|
|
|
8556
8596
|
hideWhenUnavailable,
|
|
8557
8597
|
onExecuted
|
|
8558
8598
|
});
|
|
8559
|
-
const handleClick = (0,
|
|
8599
|
+
const handleClick = (0, import_react60.useCallback)(
|
|
8560
8600
|
(event) => {
|
|
8561
8601
|
onClick == null ? void 0 : onClick(event);
|
|
8562
8602
|
if (event.defaultPrevented) return;
|
|
@@ -8598,7 +8638,7 @@ var EditorHeader = ({
|
|
|
8598
8638
|
const isMobile = (0, import_use_is_mobile3.useIsMobile)();
|
|
8599
8639
|
const windowSize = useWindowSize();
|
|
8600
8640
|
const { styles } = useEditorUIContext();
|
|
8601
|
-
const toolbarRef = (0,
|
|
8641
|
+
const toolbarRef = (0, import_react61.useRef)(null);
|
|
8602
8642
|
const bodyRect = useCursorVisibility({
|
|
8603
8643
|
editor,
|
|
8604
8644
|
overlayHeight: (_b = (_a = toolbarRef.current) == null ? void 0 : _a.getBoundingClientRect().height) != null ? _b : 0
|
|
@@ -8668,9 +8708,9 @@ function MoreOptions({
|
|
|
8668
8708
|
}) {
|
|
8669
8709
|
const intl = (0, import_react_intl25.useIntl)();
|
|
8670
8710
|
const { editor } = (0, import_editor_utils31.useTiptapEditor)(providedEditor);
|
|
8671
|
-
const [show, setShow] = (0,
|
|
8711
|
+
const [show, setShow] = (0, import_react61.useState)(false);
|
|
8672
8712
|
const moreOptionsLabel = intl.formatMessage(messages7.more_options);
|
|
8673
|
-
(0,
|
|
8713
|
+
(0, import_react61.useEffect)(() => {
|
|
8674
8714
|
if (!editor) return;
|
|
8675
8715
|
const handleSelectionUpdate = () => {
|
|
8676
8716
|
setShow(
|
|
@@ -8783,7 +8823,7 @@ var BasicEditor = ({
|
|
|
8783
8823
|
...options
|
|
8784
8824
|
});
|
|
8785
8825
|
const styles = (0, import_theme9.editorBasic)({ variant, bordered });
|
|
8786
|
-
const resolveVariable = (0,
|
|
8826
|
+
const resolveVariable = (0, import_react63.useCallback)(
|
|
8787
8827
|
(name) => variableValues == null ? void 0 : variableValues[name],
|
|
8788
8828
|
[variableValues]
|
|
8789
8829
|
);
|
|
@@ -8793,7 +8833,7 @@ var BasicEditor = ({
|
|
|
8793
8833
|
const isBottomToolbar = variant === "field";
|
|
8794
8834
|
const hasVariables = variables && variables.length > 0;
|
|
8795
8835
|
const hasPagination = !!pagesOptions;
|
|
8796
|
-
const editorContent = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(EditorUIProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: styles.root(), "data-slot": "editor", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
8836
|
+
const editorContent = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(EditorUIProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: styles.root(), "data-slot": "editor", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_react62.EditorContext.Provider, { value: { editor }, children: [
|
|
8797
8837
|
showToolbar && !isBottomToolbar && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(EditorHeader, { editor, variant }),
|
|
8798
8838
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
8799
8839
|
EditorContentArea,
|
|
@@ -8817,10 +8857,10 @@ var EditorContentArea = ({
|
|
|
8817
8857
|
hasPagination
|
|
8818
8858
|
}) => {
|
|
8819
8859
|
const styles = (0, import_theme9.editorBasic)({ variant });
|
|
8820
|
-
const { editor } = (0,
|
|
8860
|
+
const { editor } = (0, import_react63.useContext)(import_react62.EditorContext);
|
|
8821
8861
|
const { isDragging } = useUiEditorState(editor);
|
|
8822
8862
|
useScrollToHash();
|
|
8823
|
-
const handleKeyDown = (0,
|
|
8863
|
+
const handleKeyDown = (0, import_react63.useCallback)(
|
|
8824
8864
|
(e) => {
|
|
8825
8865
|
if (!(editor == null ? void 0 : editor.isFocused)) return;
|
|
8826
8866
|
const isMod = e.metaKey || e.ctrlKey;
|
|
@@ -8864,7 +8904,7 @@ var EditorContentArea = ({
|
|
|
8864
8904
|
// biome-ignore lint/a11y/noStaticElementInteractions: Wrapper intercepts keyboard shortcuts to prevent propagation
|
|
8865
8905
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: styles.wrapper(), onKeyDown: handleKeyDown, children: [
|
|
8866
8906
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
8867
|
-
|
|
8907
|
+
import_react62.EditorContent,
|
|
8868
8908
|
{
|
|
8869
8909
|
editor,
|
|
8870
8910
|
role: "presentation",
|
|
@@ -8928,7 +8968,7 @@ function LoadingSpinner({ text = "Connecting..." }) {
|
|
|
8928
8968
|
|
|
8929
8969
|
// src/presets/view/index.tsx
|
|
8930
8970
|
var import_theme10 = require("@kopexa/theme");
|
|
8931
|
-
var
|
|
8971
|
+
var import_react64 = require("@tiptap/react");
|
|
8932
8972
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
8933
8973
|
function EditorView({
|
|
8934
8974
|
content,
|
|
@@ -8948,8 +8988,8 @@ function EditorView({
|
|
|
8948
8988
|
if (!editor) {
|
|
8949
8989
|
return null;
|
|
8950
8990
|
}
|
|
8951
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: styles.root({ className }), "data-slot": "editor-view", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
8952
|
-
|
|
8991
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: styles.root({ className }), "data-slot": "editor-view", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_react64.EditorContext.Provider, { value: { editor }, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: styles.wrapper(), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
8992
|
+
import_react64.EditorContent,
|
|
8953
8993
|
{
|
|
8954
8994
|
editor,
|
|
8955
8995
|
role: "presentation",
|
|
@@ -8961,7 +9001,7 @@ function EditorView({
|
|
|
8961
9001
|
// src/presets/view/static.tsx
|
|
8962
9002
|
var import_theme11 = require("@kopexa/theme");
|
|
8963
9003
|
var import_html = require("@tiptap/html");
|
|
8964
|
-
var
|
|
9004
|
+
var import_react65 = require("react");
|
|
8965
9005
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
8966
9006
|
function EditorStaticView({
|
|
8967
9007
|
content,
|
|
@@ -8971,7 +9011,7 @@ function EditorStaticView({
|
|
|
8971
9011
|
customExtensions,
|
|
8972
9012
|
disabled
|
|
8973
9013
|
}) {
|
|
8974
|
-
const extensions = (0,
|
|
9014
|
+
const extensions = (0, import_react65.useMemo)(
|
|
8975
9015
|
() => getExtensions({
|
|
8976
9016
|
editable: false,
|
|
8977
9017
|
customExtensions,
|
|
@@ -8979,7 +9019,7 @@ function EditorStaticView({
|
|
|
8979
9019
|
}),
|
|
8980
9020
|
[customExtensions, disabled]
|
|
8981
9021
|
);
|
|
8982
|
-
const html = (0,
|
|
9022
|
+
const html = (0, import_react65.useMemo)(() => {
|
|
8983
9023
|
const parsed = safeParseContent(content);
|
|
8984
9024
|
if (!parsed) return "";
|
|
8985
9025
|
const json = parsed;
|