@kopexa/tiptap 17.10.0 → 17.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +267 -283
- package/dist/index.mjs +114 -146
- package/package.json +28 -28
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_react65.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_react65 = 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,14 @@ 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_react33 = require("@tiptap/react");
|
|
3365
3349
|
var import_starter_kit = require("@tiptap/starter-kit");
|
|
3366
|
-
var
|
|
3350
|
+
var import_react34 = require("react");
|
|
3367
3351
|
|
|
3368
3352
|
// src/extensions/link/index.ts
|
|
3369
3353
|
var import_extension_link = __toESM(require("@tiptap/extension-link"));
|
|
3370
3354
|
var import_state3 = require("@tiptap/pm/state");
|
|
3371
|
-
var
|
|
3355
|
+
var import_react30 = require("@tiptap/react");
|
|
3372
3356
|
var Link = import_extension_link.default.extend({
|
|
3373
3357
|
inclusive: false,
|
|
3374
3358
|
parseHTML() {
|
|
@@ -3397,7 +3381,7 @@ var Link = import_extension_link.default.extend({
|
|
|
3397
3381
|
const { schema, doc, tr } = view.state;
|
|
3398
3382
|
let range;
|
|
3399
3383
|
if (schema.marks.link) {
|
|
3400
|
-
range = (0,
|
|
3384
|
+
range = (0, import_react30.getMarkRange)(doc.resolve(pos), schema.marks.link);
|
|
3401
3385
|
}
|
|
3402
3386
|
if (!range) {
|
|
3403
3387
|
return;
|
|
@@ -3703,8 +3687,8 @@ var NodeBackground = import_core8.Extension.create({
|
|
|
3703
3687
|
// src/extensions/selection/index.ts
|
|
3704
3688
|
var import_state4 = require("@tiptap/pm/state");
|
|
3705
3689
|
var import_view = require("@tiptap/pm/view");
|
|
3706
|
-
var
|
|
3707
|
-
var Selection =
|
|
3690
|
+
var import_react31 = require("@tiptap/react");
|
|
3691
|
+
var Selection = import_react31.Extension.create({
|
|
3708
3692
|
name: "selection",
|
|
3709
3693
|
addProseMirrorPlugins() {
|
|
3710
3694
|
const { editor } = this;
|
|
@@ -3719,7 +3703,7 @@ var Selection = import_react30.Extension.create({
|
|
|
3719
3703
|
if (editor.isFocused === true || !editor.isEditable) {
|
|
3720
3704
|
return null;
|
|
3721
3705
|
}
|
|
3722
|
-
if ((0,
|
|
3706
|
+
if ((0, import_react31.isNodeSelection)(state.selection)) {
|
|
3723
3707
|
return null;
|
|
3724
3708
|
}
|
|
3725
3709
|
return import_view.DecorationSet.create(state.doc, [
|
|
@@ -3794,7 +3778,7 @@ var TabHandler = import_core9.Extension.create({
|
|
|
3794
3778
|
|
|
3795
3779
|
// src/extensions/trailing-node/index.ts
|
|
3796
3780
|
var import_state5 = require("@tiptap/pm/state");
|
|
3797
|
-
var
|
|
3781
|
+
var import_react32 = require("@tiptap/react");
|
|
3798
3782
|
function nodeEqualsType({
|
|
3799
3783
|
types,
|
|
3800
3784
|
node
|
|
@@ -3805,7 +3789,7 @@ function nodeEqualsType({
|
|
|
3805
3789
|
}
|
|
3806
3790
|
return node.type === types;
|
|
3807
3791
|
}
|
|
3808
|
-
var TrailingNode =
|
|
3792
|
+
var TrailingNode = import_react32.Extension.create({
|
|
3809
3793
|
name: "trailingNode",
|
|
3810
3794
|
addOptions() {
|
|
3811
3795
|
return {
|
|
@@ -4086,10 +4070,10 @@ var useCreateEditor = ({
|
|
|
4086
4070
|
const fileHandlerFromContext = useEditorFile();
|
|
4087
4071
|
const fileHandler = fileHandlerProp != null ? fileHandlerProp : fileHandlerFromContext;
|
|
4088
4072
|
const collaboration = useCollaboration();
|
|
4089
|
-
const [collabSyncing, setCollabSyncing] = (0,
|
|
4090
|
-
const placeholderRef = (0,
|
|
4073
|
+
const [collabSyncing, setCollabSyncing] = (0, import_react34.useState)(!!collaboration);
|
|
4074
|
+
const placeholderRef = (0, import_react34.useRef)(placeholder);
|
|
4091
4075
|
placeholderRef.current = placeholder;
|
|
4092
|
-
const [extensions] = (0,
|
|
4076
|
+
const [extensions] = (0, import_react34.useState)(
|
|
4093
4077
|
() => getExtensions({
|
|
4094
4078
|
editable,
|
|
4095
4079
|
placeholder: () => {
|
|
@@ -4107,7 +4091,7 @@ var useCreateEditor = ({
|
|
|
4107
4091
|
})
|
|
4108
4092
|
);
|
|
4109
4093
|
const { onCreate: userOnCreate, ...restOptions } = options;
|
|
4110
|
-
const editor = (0,
|
|
4094
|
+
const editor = (0, import_react33.useEditor)({
|
|
4111
4095
|
editorProps: {
|
|
4112
4096
|
attributes: {
|
|
4113
4097
|
autocomplete: "off",
|
|
@@ -4152,7 +4136,7 @@ var useCreateEditor = ({
|
|
|
4152
4136
|
},
|
|
4153
4137
|
...restOptions
|
|
4154
4138
|
});
|
|
4155
|
-
(0,
|
|
4139
|
+
(0, import_react34.useEffect)(() => {
|
|
4156
4140
|
if (editor && editor.isEditable !== editable) {
|
|
4157
4141
|
editor.setEditable(editable);
|
|
4158
4142
|
}
|
|
@@ -4372,8 +4356,8 @@ async function handleFileUpload(editor, file, fileHandler, pos) {
|
|
|
4372
4356
|
// src/presets/basic/index.tsx
|
|
4373
4357
|
var import_extension_table2 = require("@kopexa/extension-table");
|
|
4374
4358
|
var import_theme9 = require("@kopexa/theme");
|
|
4375
|
-
var
|
|
4376
|
-
var
|
|
4359
|
+
var import_react61 = require("@tiptap/react");
|
|
4360
|
+
var import_react62 = require("react");
|
|
4377
4361
|
var import_react_intl26 = require("react-intl");
|
|
4378
4362
|
|
|
4379
4363
|
// src/context/editor-context.ts
|
|
@@ -4381,10 +4365,10 @@ var import_react_utils = require("@kopexa/react-utils");
|
|
|
4381
4365
|
var [EditorUIProvider, useEditorUIContext] = (0, import_react_utils.createContext)();
|
|
4382
4366
|
|
|
4383
4367
|
// src/hooks/use-ui-editor-state.ts
|
|
4384
|
-
var
|
|
4368
|
+
var import_react35 = require("@tiptap/react");
|
|
4385
4369
|
function useUiEditorState(editor) {
|
|
4386
4370
|
var _a;
|
|
4387
|
-
return (_a = (0,
|
|
4371
|
+
return (_a = (0, import_react35.useEditorState)({
|
|
4388
4372
|
editor,
|
|
4389
4373
|
selector: ({ editor: editor2 }) => {
|
|
4390
4374
|
if (!editor2) return defaultUiState;
|
|
@@ -4411,7 +4395,7 @@ var import_icons9 = require("@kopexa/icons");
|
|
|
4411
4395
|
var import_input3 = require("@kopexa/input");
|
|
4412
4396
|
var import_popover = require("@kopexa/popover");
|
|
4413
4397
|
var import_toolbar = require("@kopexa/toolbar");
|
|
4414
|
-
var
|
|
4398
|
+
var import_react36 = require("react");
|
|
4415
4399
|
|
|
4416
4400
|
// src/ui/link-popover/use-link-popover.ts
|
|
4417
4401
|
var import_editor_utils5 = require("@kopexa/editor-utils");
|
|
@@ -4667,8 +4651,8 @@ var LinkMain = ({
|
|
|
4667
4651
|
isActive,
|
|
4668
4652
|
onSave
|
|
4669
4653
|
}) => {
|
|
4670
|
-
const [isEditing, setIsEditing] = (0,
|
|
4671
|
-
(0,
|
|
4654
|
+
const [isEditing, setIsEditing] = (0, import_react36.useState)(!isActive || !url);
|
|
4655
|
+
(0, import_react36.useEffect)(() => {
|
|
4672
4656
|
setIsEditing(!isActive || !url);
|
|
4673
4657
|
}, [isActive, url]);
|
|
4674
4658
|
const handleKeyDown = (event) => {
|
|
@@ -4784,7 +4768,7 @@ function LinkPopover({
|
|
|
4784
4768
|
...buttonProps
|
|
4785
4769
|
}) {
|
|
4786
4770
|
const { editor } = (0, import_editor_utils6.useTiptapEditor)(providedEditor);
|
|
4787
|
-
const [isOpen, setIsOpen] = (0,
|
|
4771
|
+
const [isOpen, setIsOpen] = (0, import_react36.useState)(false);
|
|
4788
4772
|
const {
|
|
4789
4773
|
isVisible,
|
|
4790
4774
|
canSet,
|
|
@@ -4800,18 +4784,18 @@ function LinkPopover({
|
|
|
4800
4784
|
hideWhenUnavailable,
|
|
4801
4785
|
onSetLink
|
|
4802
4786
|
});
|
|
4803
|
-
const handleOnOpenChange = (0,
|
|
4787
|
+
const handleOnOpenChange = (0, import_react36.useCallback)(
|
|
4804
4788
|
(nextIsOpen) => {
|
|
4805
4789
|
setIsOpen(nextIsOpen);
|
|
4806
4790
|
onOpenChange == null ? void 0 : onOpenChange(nextIsOpen);
|
|
4807
4791
|
},
|
|
4808
4792
|
[onOpenChange]
|
|
4809
4793
|
);
|
|
4810
|
-
const handleSetLink = (0,
|
|
4794
|
+
const handleSetLink = (0, import_react36.useCallback)(() => {
|
|
4811
4795
|
setLink();
|
|
4812
4796
|
setIsOpen(false);
|
|
4813
4797
|
}, [setLink]);
|
|
4814
|
-
const handleClick = (0,
|
|
4798
|
+
const handleClick = (0, import_react36.useCallback)(
|
|
4815
4799
|
(event) => {
|
|
4816
4800
|
onClick == null ? void 0 : onClick(event);
|
|
4817
4801
|
if (event.defaultPrevented) return;
|
|
@@ -4819,7 +4803,7 @@ function LinkPopover({
|
|
|
4819
4803
|
},
|
|
4820
4804
|
[onClick, isOpen]
|
|
4821
4805
|
);
|
|
4822
|
-
(0,
|
|
4806
|
+
(0, import_react36.useEffect)(() => {
|
|
4823
4807
|
if (autoOpenOnLinkActive && isActive) {
|
|
4824
4808
|
setIsOpen(true);
|
|
4825
4809
|
}
|
|
@@ -4873,8 +4857,8 @@ LinkButton.displayName = "LinkButton";
|
|
|
4873
4857
|
var import_editor_utils7 = require("@kopexa/editor-utils");
|
|
4874
4858
|
var import_icons10 = require("@kopexa/icons");
|
|
4875
4859
|
var import_toolbar2 = require("@kopexa/toolbar");
|
|
4876
|
-
var
|
|
4877
|
-
var
|
|
4860
|
+
var import_react37 = require("@tiptap/react");
|
|
4861
|
+
var import_react38 = require("react");
|
|
4878
4862
|
var import_react_intl16 = require("react-intl");
|
|
4879
4863
|
|
|
4880
4864
|
// src/ui/messages.ts
|
|
@@ -5340,7 +5324,7 @@ function shouldShowMarkButton(params) {
|
|
|
5340
5324
|
return false;
|
|
5341
5325
|
}
|
|
5342
5326
|
if (hideWhenUnavailable) {
|
|
5343
|
-
if ((0,
|
|
5327
|
+
if ((0, import_react37.isNodeSelection)(editor.state.selection) || !canToggleMark(editor, type)) {
|
|
5344
5328
|
return false;
|
|
5345
5329
|
}
|
|
5346
5330
|
}
|
|
@@ -5395,7 +5379,7 @@ var MarkButton = ({
|
|
|
5395
5379
|
shortcutKey,
|
|
5396
5380
|
formattedName
|
|
5397
5381
|
} = useMarkState(editor, type, disabled);
|
|
5398
|
-
const handleClick = (0,
|
|
5382
|
+
const handleClick = (0, import_react38.useCallback)(
|
|
5399
5383
|
(e) => {
|
|
5400
5384
|
onClick == null ? void 0 : onClick(e);
|
|
5401
5385
|
if (!e.defaultPrevented && !isDisabled && editor) {
|
|
@@ -5404,7 +5388,7 @@ var MarkButton = ({
|
|
|
5404
5388
|
},
|
|
5405
5389
|
[onClick, isDisabled, editor, type]
|
|
5406
5390
|
);
|
|
5407
|
-
const show = (0,
|
|
5391
|
+
const show = (0, import_react38.useMemo)(() => {
|
|
5408
5392
|
return shouldShowMarkButton({
|
|
5409
5393
|
editor,
|
|
5410
5394
|
type,
|
|
@@ -5484,7 +5468,7 @@ var React9 = __toESM(require("react"));
|
|
|
5484
5468
|
|
|
5485
5469
|
// src/hooks/use-floating-toolbar-visibility.ts
|
|
5486
5470
|
var import_state6 = require("@tiptap/pm/state");
|
|
5487
|
-
var
|
|
5471
|
+
var import_react39 = require("@tiptap/react");
|
|
5488
5472
|
var React8 = __toESM(require("react"));
|
|
5489
5473
|
var HIDE_FLOATING_META = "hideFloatingToolbar";
|
|
5490
5474
|
var selectNodeAndHideFloating = (editor, pos) => {
|
|
@@ -5586,39 +5570,39 @@ var import_button9 = require("@kopexa/button");
|
|
|
5586
5570
|
var import_icons11 = require("@kopexa/icons");
|
|
5587
5571
|
var import_input4 = require("@kopexa/input");
|
|
5588
5572
|
var import_menus2 = require("@tiptap/react/menus");
|
|
5589
|
-
var
|
|
5573
|
+
var import_react40 = require("react");
|
|
5590
5574
|
var import_react_intl17 = require("react-intl");
|
|
5591
5575
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
5592
5576
|
function LinkBubble({ editor }) {
|
|
5593
5577
|
const intl = (0, import_react_intl17.useIntl)();
|
|
5594
|
-
const [isEditing, setIsEditing] = (0,
|
|
5595
|
-
const [url, setUrl] = (0,
|
|
5596
|
-
const getCurrentUrl = (0,
|
|
5578
|
+
const [isEditing, setIsEditing] = (0, import_react40.useState)(false);
|
|
5579
|
+
const [url, setUrl] = (0, import_react40.useState)("");
|
|
5580
|
+
const getCurrentUrl = (0, import_react40.useCallback)(() => {
|
|
5597
5581
|
if (!editor) return "";
|
|
5598
5582
|
const attrs = editor.getAttributes("link");
|
|
5599
5583
|
return attrs.href || "";
|
|
5600
5584
|
}, [editor]);
|
|
5601
|
-
(0,
|
|
5585
|
+
(0, import_react40.useEffect)(() => {
|
|
5602
5586
|
const isLinkActive2 = editor == null ? void 0 : editor.isActive("link");
|
|
5603
5587
|
if (isLinkActive2) {
|
|
5604
5588
|
setUrl(getCurrentUrl());
|
|
5605
5589
|
setIsEditing(false);
|
|
5606
5590
|
}
|
|
5607
5591
|
}, [editor, getCurrentUrl]);
|
|
5608
|
-
const handleOpenLink = (0,
|
|
5592
|
+
const handleOpenLink = (0, import_react40.useCallback)(() => {
|
|
5609
5593
|
const href = getCurrentUrl();
|
|
5610
5594
|
if (href) {
|
|
5611
5595
|
window.open(href, "_blank", "noopener,noreferrer");
|
|
5612
5596
|
}
|
|
5613
5597
|
}, [getCurrentUrl]);
|
|
5614
|
-
const handleRemoveLink = (0,
|
|
5598
|
+
const handleRemoveLink = (0, import_react40.useCallback)(() => {
|
|
5615
5599
|
editor == null ? void 0 : editor.chain().focus().unsetLink().run();
|
|
5616
5600
|
}, [editor]);
|
|
5617
|
-
const handleEdit = (0,
|
|
5601
|
+
const handleEdit = (0, import_react40.useCallback)(() => {
|
|
5618
5602
|
setUrl(getCurrentUrl());
|
|
5619
5603
|
setIsEditing(true);
|
|
5620
5604
|
}, [getCurrentUrl]);
|
|
5621
|
-
const handleSave = (0,
|
|
5605
|
+
const handleSave = (0, import_react40.useCallback)(() => {
|
|
5622
5606
|
if (url) {
|
|
5623
5607
|
editor == null ? void 0 : editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
|
|
5624
5608
|
} else {
|
|
@@ -5626,7 +5610,7 @@ function LinkBubble({ editor }) {
|
|
|
5626
5610
|
}
|
|
5627
5611
|
setIsEditing(false);
|
|
5628
5612
|
}, [editor, url]);
|
|
5629
|
-
const handleKeyDown = (0,
|
|
5613
|
+
const handleKeyDown = (0, import_react40.useCallback)(
|
|
5630
5614
|
(e) => {
|
|
5631
5615
|
if (e.key === "Enter") {
|
|
5632
5616
|
e.preventDefault();
|
|
@@ -5751,8 +5735,8 @@ var import_react_intl19 = require("react-intl");
|
|
|
5751
5735
|
// src/ui/table-button/use-table.ts
|
|
5752
5736
|
var import_editor_utils9 = require("@kopexa/editor-utils");
|
|
5753
5737
|
var import_icons12 = require("@kopexa/icons");
|
|
5754
|
-
var
|
|
5755
|
-
var
|
|
5738
|
+
var import_react41 = require("@tiptap/react");
|
|
5739
|
+
var import_react42 = require("react");
|
|
5756
5740
|
var import_react_intl18 = require("react-intl");
|
|
5757
5741
|
function canToggle(editor) {
|
|
5758
5742
|
if (!editor || !editor.isEditable) return false;
|
|
@@ -5784,7 +5768,7 @@ function shouldShowButton(props) {
|
|
|
5784
5768
|
if (!editor || !editor.isEditable) return false;
|
|
5785
5769
|
if (!(0, import_editor_utils9.isNodeInSchema)("table", editor)) return false;
|
|
5786
5770
|
if (hideWhenUnavailable) {
|
|
5787
|
-
if ((0,
|
|
5771
|
+
if ((0, import_react41.isNodeSelection)(editor.state.selection) || !canToggle) {
|
|
5788
5772
|
return false;
|
|
5789
5773
|
}
|
|
5790
5774
|
}
|
|
@@ -5798,10 +5782,10 @@ function useTableBlock(config) {
|
|
|
5798
5782
|
} = config || {};
|
|
5799
5783
|
const intl = (0, import_react_intl18.useIntl)();
|
|
5800
5784
|
const { editor } = (0, import_editor_utils9.useTiptapEditor)(providedEditor);
|
|
5801
|
-
const [isVisible, setIsVisible] = (0,
|
|
5785
|
+
const [isVisible, setIsVisible] = (0, import_react42.useState)(true);
|
|
5802
5786
|
const canToggleState = canToggle(editor);
|
|
5803
5787
|
const isActive = (editor == null ? void 0 : editor.isActive("table")) || false;
|
|
5804
|
-
(0,
|
|
5788
|
+
(0, import_react42.useEffect)(() => {
|
|
5805
5789
|
if (!editor) return;
|
|
5806
5790
|
const handleSelectionUpdate = () => {
|
|
5807
5791
|
setIsVisible(shouldShowButton({ editor, hideWhenUnavailable }));
|
|
@@ -5812,7 +5796,7 @@ function useTableBlock(config) {
|
|
|
5812
5796
|
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
5813
5797
|
};
|
|
5814
5798
|
}, [editor, hideWhenUnavailable]);
|
|
5815
|
-
const handleToggle = (0,
|
|
5799
|
+
const handleToggle = (0, import_react42.useCallback)(() => {
|
|
5816
5800
|
if (!editor) return false;
|
|
5817
5801
|
const success = toggleTable(editor);
|
|
5818
5802
|
if (success) {
|
|
@@ -6374,7 +6358,7 @@ var import_icons26 = require("@kopexa/icons");
|
|
|
6374
6358
|
var import_popover3 = require("@kopexa/popover");
|
|
6375
6359
|
var import_toolbar10 = require("@kopexa/toolbar");
|
|
6376
6360
|
var import_use_is_mobile3 = require("@kopexa/use-is-mobile");
|
|
6377
|
-
var
|
|
6361
|
+
var import_react60 = require("react");
|
|
6378
6362
|
var import_react_intl25 = require("react-intl");
|
|
6379
6363
|
|
|
6380
6364
|
// src/hooks/use-cursor-visibility.ts
|
|
@@ -6485,13 +6469,13 @@ var import_editor_utils14 = require("@kopexa/editor-utils");
|
|
|
6485
6469
|
var import_icons15 = require("@kopexa/icons");
|
|
6486
6470
|
var import_popover2 = require("@kopexa/popover");
|
|
6487
6471
|
var import_toolbar5 = require("@kopexa/toolbar");
|
|
6488
|
-
var
|
|
6472
|
+
var import_react44 = require("react");
|
|
6489
6473
|
|
|
6490
6474
|
// src/ui/color-highlight-button/color-highlight-button.tsx
|
|
6491
6475
|
var import_editor_utils13 = require("@kopexa/editor-utils");
|
|
6492
6476
|
var import_theme8 = require("@kopexa/theme");
|
|
6493
6477
|
var import_toolbar4 = require("@kopexa/toolbar");
|
|
6494
|
-
var
|
|
6478
|
+
var import_react43 = require("react");
|
|
6495
6479
|
|
|
6496
6480
|
// src/ui/color-highlight-button/use-color-highlight.ts
|
|
6497
6481
|
var import_editor_utils12 = require("@kopexa/editor-utils");
|
|
@@ -6688,7 +6672,7 @@ var ColorHighlightButton = ({
|
|
|
6688
6672
|
hideWhenUnavailable,
|
|
6689
6673
|
onApplied
|
|
6690
6674
|
});
|
|
6691
|
-
const handleClick = (0,
|
|
6675
|
+
const handleClick = (0, import_react43.useCallback)(
|
|
6692
6676
|
(event) => {
|
|
6693
6677
|
onClick == null ? void 0 : onClick(event);
|
|
6694
6678
|
if (event.defaultPrevented) return;
|
|
@@ -6696,7 +6680,7 @@ var ColorHighlightButton = ({
|
|
|
6696
6680
|
},
|
|
6697
6681
|
[handleColorHighlight, onClick]
|
|
6698
6682
|
);
|
|
6699
|
-
const buttonStyle = (0,
|
|
6683
|
+
const buttonStyle = (0, import_react43.useMemo)(
|
|
6700
6684
|
() => ({
|
|
6701
6685
|
...style,
|
|
6702
6686
|
"--highlight-color": highlightColor
|
|
@@ -6779,8 +6763,8 @@ function ColorHighlightPopoverContent({
|
|
|
6779
6763
|
])
|
|
6780
6764
|
}) {
|
|
6781
6765
|
const { handleRemoveHighlight } = useColorHighlight({ editor });
|
|
6782
|
-
const containerRef = (0,
|
|
6783
|
-
const menuItems = (0,
|
|
6766
|
+
const containerRef = (0, import_react44.useRef)(null);
|
|
6767
|
+
const menuItems = (0, import_react44.useMemo)(
|
|
6784
6768
|
() => [...colors, { label: "Remove highlight", value: "none" }],
|
|
6785
6769
|
[colors]
|
|
6786
6770
|
);
|
|
@@ -6848,7 +6832,7 @@ function ColorHighlightPopover({
|
|
|
6848
6832
|
...props
|
|
6849
6833
|
}) {
|
|
6850
6834
|
const { editor } = (0, import_editor_utils14.useTiptapEditor)(providedEditor);
|
|
6851
|
-
const [isOpen, setIsOpen] = (0,
|
|
6835
|
+
const [isOpen, setIsOpen] = (0, import_react44.useState)(false);
|
|
6852
6836
|
const { isVisible, canColorHighlight: canColorHighlight2, isActive, label } = useColorHighlight({
|
|
6853
6837
|
editor,
|
|
6854
6838
|
hideWhenUnavailable,
|
|
@@ -6882,15 +6866,15 @@ var import_button13 = require("@kopexa/button");
|
|
|
6882
6866
|
var import_dropdown_menu = require("@kopexa/dropdown-menu");
|
|
6883
6867
|
var import_editor_utils16 = require("@kopexa/editor-utils");
|
|
6884
6868
|
var import_icons17 = require("@kopexa/icons");
|
|
6885
|
-
var
|
|
6886
|
-
var
|
|
6869
|
+
var import_react47 = require("@tiptap/react");
|
|
6870
|
+
var import_react48 = require("react");
|
|
6887
6871
|
|
|
6888
6872
|
// src/ui/list-button/index.tsx
|
|
6889
6873
|
var import_button12 = require("@kopexa/button");
|
|
6890
6874
|
var import_editor_utils15 = require("@kopexa/editor-utils");
|
|
6891
6875
|
var import_icons16 = require("@kopexa/icons");
|
|
6892
|
-
var
|
|
6893
|
-
var
|
|
6876
|
+
var import_react45 = require("@tiptap/react");
|
|
6877
|
+
var import_react46 = require("react");
|
|
6894
6878
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
6895
6879
|
var listOptions = [
|
|
6896
6880
|
{
|
|
@@ -6965,7 +6949,7 @@ function shouldShowListButton(params) {
|
|
|
6965
6949
|
return false;
|
|
6966
6950
|
}
|
|
6967
6951
|
if (hideWhenUnavailable) {
|
|
6968
|
-
if ((0,
|
|
6952
|
+
if ((0, import_react45.isNodeSelection)(editor.state.selection) || !canToggleList(editor, type)) {
|
|
6969
6953
|
return false;
|
|
6970
6954
|
}
|
|
6971
6955
|
}
|
|
@@ -7000,7 +6984,7 @@ var ListButton = ({
|
|
|
7000
6984
|
type
|
|
7001
6985
|
);
|
|
7002
6986
|
const Icon = (listOption == null ? void 0 : listOption.icon) || import_icons16.ListIcon;
|
|
7003
|
-
const handleClick = (0,
|
|
6987
|
+
const handleClick = (0, import_react46.useCallback)(
|
|
7004
6988
|
(e) => {
|
|
7005
6989
|
onClick == null ? void 0 : onClick(e);
|
|
7006
6990
|
if (!e.defaultPrevented && editor) {
|
|
@@ -7009,7 +6993,7 @@ var ListButton = ({
|
|
|
7009
6993
|
},
|
|
7010
6994
|
[onClick, editor, type]
|
|
7011
6995
|
);
|
|
7012
|
-
const show = (0,
|
|
6996
|
+
const show = (0, import_react46.useMemo)(() => {
|
|
7013
6997
|
return shouldShowListButton({
|
|
7014
6998
|
editor,
|
|
7015
6999
|
type,
|
|
@@ -7063,24 +7047,24 @@ function shouldShowListDropdown(params) {
|
|
|
7063
7047
|
return false;
|
|
7064
7048
|
}
|
|
7065
7049
|
if (hideWhenUnavailable) {
|
|
7066
|
-
if ((0,
|
|
7050
|
+
if ((0, import_react47.isNodeSelection)(editor.state.selection) || !canToggleAny) {
|
|
7067
7051
|
return false;
|
|
7068
7052
|
}
|
|
7069
7053
|
}
|
|
7070
7054
|
return true;
|
|
7071
7055
|
}
|
|
7072
7056
|
function useListDropdownState(editor, availableTypes) {
|
|
7073
|
-
const [isOpen, setIsOpen] = (0,
|
|
7057
|
+
const [isOpen, setIsOpen] = (0, import_react48.useState)(false);
|
|
7074
7058
|
const listInSchema = availableTypes.some(
|
|
7075
7059
|
(type) => (0, import_editor_utils16.isNodeInSchema)(type, editor)
|
|
7076
7060
|
);
|
|
7077
|
-
const filteredLists = (0,
|
|
7061
|
+
const filteredLists = (0, import_react48.useMemo)(
|
|
7078
7062
|
() => getFilteredListOptions(availableTypes),
|
|
7079
7063
|
[availableTypes]
|
|
7080
7064
|
);
|
|
7081
7065
|
const canToggleAny = canToggleAnyList(editor, availableTypes);
|
|
7082
7066
|
const isAnyActive = isAnyListActive(editor, availableTypes);
|
|
7083
|
-
const handleOpenChange = (0,
|
|
7067
|
+
const handleOpenChange = (0, import_react48.useCallback)(
|
|
7084
7068
|
(open, callback) => {
|
|
7085
7069
|
setIsOpen(open);
|
|
7086
7070
|
callback == null ? void 0 : callback(open);
|
|
@@ -7098,7 +7082,7 @@ function useListDropdownState(editor, availableTypes) {
|
|
|
7098
7082
|
};
|
|
7099
7083
|
}
|
|
7100
7084
|
function useActiveListIcon(editor, filteredLists) {
|
|
7101
|
-
return (0,
|
|
7085
|
+
return (0, import_react48.useCallback)(() => {
|
|
7102
7086
|
const activeOption = filteredLists.find(
|
|
7103
7087
|
(option) => isListActive(editor, option.type)
|
|
7104
7088
|
);
|
|
@@ -7122,7 +7106,7 @@ function ListDropdownMenu({
|
|
|
7122
7106
|
handleOpenChange
|
|
7123
7107
|
} = useListDropdownState(editor, types);
|
|
7124
7108
|
const getActiveIcon = useActiveListIcon(editor, filteredLists);
|
|
7125
|
-
const show = (0,
|
|
7109
|
+
const show = (0, import_react48.useMemo)(() => {
|
|
7126
7110
|
return shouldShowListDropdown({
|
|
7127
7111
|
editor,
|
|
7128
7112
|
listTypes: types,
|
|
@@ -7131,7 +7115,7 @@ function ListDropdownMenu({
|
|
|
7131
7115
|
canToggleAny
|
|
7132
7116
|
});
|
|
7133
7117
|
}, [editor, types, hideWhenUnavailable, listInSchema, canToggleAny]);
|
|
7134
|
-
const handleOnOpenChange = (0,
|
|
7118
|
+
const handleOnOpenChange = (0, import_react48.useCallback)(
|
|
7135
7119
|
(open) => handleOpenChange(open, onOpenChange),
|
|
7136
7120
|
[handleOpenChange, onOpenChange]
|
|
7137
7121
|
);
|
|
@@ -7172,7 +7156,7 @@ function ListDropdownMenu({
|
|
|
7172
7156
|
// src/ui/table-button/index.tsx
|
|
7173
7157
|
var import_editor_utils17 = require("@kopexa/editor-utils");
|
|
7174
7158
|
var import_toolbar6 = require("@kopexa/toolbar");
|
|
7175
|
-
var
|
|
7159
|
+
var import_react49 = require("react");
|
|
7176
7160
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
7177
7161
|
var TableButton = ({
|
|
7178
7162
|
editor: providedEditor,
|
|
@@ -7197,7 +7181,7 @@ var TableButton = ({
|
|
|
7197
7181
|
hideWhenUnavailable,
|
|
7198
7182
|
onToggled
|
|
7199
7183
|
});
|
|
7200
|
-
const handleClick = (0,
|
|
7184
|
+
const handleClick = (0, import_react49.useCallback)(
|
|
7201
7185
|
(event) => {
|
|
7202
7186
|
onClick == null ? void 0 : onClick(event);
|
|
7203
7187
|
if (event.defaultPrevented) return;
|
|
@@ -7235,12 +7219,12 @@ var TableButton = ({
|
|
|
7235
7219
|
// src/ui/text-align-button/text-align-button.tsx
|
|
7236
7220
|
var import_button14 = require("@kopexa/button");
|
|
7237
7221
|
var import_editor_utils19 = require("@kopexa/editor-utils");
|
|
7238
|
-
var
|
|
7222
|
+
var import_react51 = require("react");
|
|
7239
7223
|
|
|
7240
7224
|
// src/ui/text-align-button/use-text-align.ts
|
|
7241
7225
|
var import_editor_utils18 = require("@kopexa/editor-utils");
|
|
7242
7226
|
var import_icons18 = require("@kopexa/icons");
|
|
7243
|
-
var
|
|
7227
|
+
var import_react50 = require("react");
|
|
7244
7228
|
var import_react_intl21 = require("react-intl");
|
|
7245
7229
|
var TEXT_ALIGN_SHORTCUT_KEYS = {
|
|
7246
7230
|
left: "mod+shift+l",
|
|
@@ -7300,10 +7284,10 @@ function useTextAlign(config) {
|
|
|
7300
7284
|
} = config;
|
|
7301
7285
|
const intl = (0, import_react_intl21.useIntl)();
|
|
7302
7286
|
const { editor } = (0, import_editor_utils18.useTiptapEditor)(providedEditor);
|
|
7303
|
-
const [isVisible, setIsVisible] = (0,
|
|
7287
|
+
const [isVisible, setIsVisible] = (0, import_react50.useState)(true);
|
|
7304
7288
|
const canAlign = canSetTextAlign(editor, align);
|
|
7305
7289
|
const isActive = isTextAlignActive(editor, align);
|
|
7306
|
-
(0,
|
|
7290
|
+
(0, import_react50.useEffect)(() => {
|
|
7307
7291
|
if (!editor) return;
|
|
7308
7292
|
const handleSelectionUpdate = () => {
|
|
7309
7293
|
setIsVisible(shouldShowButton3({ editor, align, hideWhenUnavailable }));
|
|
@@ -7314,7 +7298,7 @@ function useTextAlign(config) {
|
|
|
7314
7298
|
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
7315
7299
|
};
|
|
7316
7300
|
}, [editor, hideWhenUnavailable, align]);
|
|
7317
|
-
const handleTextAlign = (0,
|
|
7301
|
+
const handleTextAlign = (0, import_react50.useCallback)(() => {
|
|
7318
7302
|
if (!editor) return false;
|
|
7319
7303
|
const success = setTextAlign(editor, align);
|
|
7320
7304
|
if (success) {
|
|
@@ -7361,7 +7345,7 @@ var TextAlignButton = ({
|
|
|
7361
7345
|
hideWhenUnavailable,
|
|
7362
7346
|
onAligned
|
|
7363
7347
|
});
|
|
7364
|
-
const handleClick = (0,
|
|
7348
|
+
const handleClick = (0, import_react51.useCallback)(
|
|
7365
7349
|
(e) => {
|
|
7366
7350
|
onClick == null ? void 0 : onClick(e);
|
|
7367
7351
|
if (e.defaultPrevented) return;
|
|
@@ -7397,7 +7381,7 @@ var TextAlignButton = ({
|
|
|
7397
7381
|
var import_button17 = require("@kopexa/button");
|
|
7398
7382
|
var import_dropdown_menu2 = require("@kopexa/dropdown-menu");
|
|
7399
7383
|
var import_editor_utils28 = require("@kopexa/editor-utils");
|
|
7400
|
-
var
|
|
7384
|
+
var import_react57 = require("react");
|
|
7401
7385
|
var import_react_intl23 = require("react-intl");
|
|
7402
7386
|
|
|
7403
7387
|
// src/ui/blockquote-button/blockquote-button.tsx
|
|
@@ -7585,7 +7569,7 @@ var BlockquoteButton = ({
|
|
|
7585
7569
|
var import_editor_utils23 = require("@kopexa/editor-utils");
|
|
7586
7570
|
var import_icons21 = require("@kopexa/icons");
|
|
7587
7571
|
var import_toolbar8 = require("@kopexa/toolbar");
|
|
7588
|
-
var
|
|
7572
|
+
var import_react52 = require("react");
|
|
7589
7573
|
|
|
7590
7574
|
// src/ui/codeblock-button/use-code-block.ts
|
|
7591
7575
|
var import_editor_utils22 = require("@kopexa/editor-utils");
|
|
@@ -7719,7 +7703,7 @@ var CodeBlockButton = ({
|
|
|
7719
7703
|
hideWhenUnavailable,
|
|
7720
7704
|
onToggled
|
|
7721
7705
|
});
|
|
7722
|
-
const handleClick = (0,
|
|
7706
|
+
const handleClick = (0, import_react52.useCallback)(
|
|
7723
7707
|
(event) => {
|
|
7724
7708
|
onClick == null ? void 0 : onClick(event);
|
|
7725
7709
|
if (event.defaultPrevented) return;
|
|
@@ -7762,7 +7746,7 @@ var import_icons22 = require("@kopexa/icons");
|
|
|
7762
7746
|
var React18 = __toESM(require("react"));
|
|
7763
7747
|
|
|
7764
7748
|
// src/ui/heading-button/utils.ts
|
|
7765
|
-
var
|
|
7749
|
+
var import_react53 = require("@tiptap/react");
|
|
7766
7750
|
var headingShortcutKeys = {
|
|
7767
7751
|
1: "Ctrl-Alt-1",
|
|
7768
7752
|
2: "Ctrl-Alt-2",
|
|
@@ -7803,7 +7787,7 @@ function shouldShowHeadingButton(params) {
|
|
|
7803
7787
|
return false;
|
|
7804
7788
|
}
|
|
7805
7789
|
if (hideWhenUnavailable) {
|
|
7806
|
-
if ((0,
|
|
7790
|
+
if ((0, import_react53.isNodeSelection)(editor.state.selection)) {
|
|
7807
7791
|
return false;
|
|
7808
7792
|
}
|
|
7809
7793
|
}
|
|
@@ -7909,14 +7893,14 @@ var import_button16 = require("@kopexa/button");
|
|
|
7909
7893
|
var import_chip = require("@kopexa/chip");
|
|
7910
7894
|
var import_editor_utils26 = require("@kopexa/editor-utils");
|
|
7911
7895
|
var import_shared_utils = require("@kopexa/shared-utils");
|
|
7912
|
-
var
|
|
7896
|
+
var import_react55 = require("react");
|
|
7913
7897
|
|
|
7914
7898
|
// src/ui/text-button/use-text.ts
|
|
7915
7899
|
var import_editor_utils25 = require("@kopexa/editor-utils");
|
|
7916
7900
|
var import_icons23 = require("@kopexa/icons");
|
|
7917
7901
|
var import_use_is_mobile2 = require("@kopexa/use-is-mobile");
|
|
7918
7902
|
var import_state9 = require("@tiptap/pm/state");
|
|
7919
|
-
var
|
|
7903
|
+
var import_react54 = require("react");
|
|
7920
7904
|
var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
|
|
7921
7905
|
var TEXT_SHORTCUT_KEY = "mod+alt+0";
|
|
7922
7906
|
function canToggleText(editor, turnInto = true) {
|
|
@@ -8009,10 +7993,10 @@ function useText(config) {
|
|
|
8009
7993
|
} = config || {};
|
|
8010
7994
|
const { editor } = (0, import_editor_utils25.useTiptapEditor)(providedEditor);
|
|
8011
7995
|
const isMobile = (0, import_use_is_mobile2.useIsMobile)();
|
|
8012
|
-
const [isVisible, setIsVisible] = (0,
|
|
7996
|
+
const [isVisible, setIsVisible] = (0, import_react54.useState)(true);
|
|
8013
7997
|
const canToggle3 = canToggleText(editor);
|
|
8014
7998
|
const isActive = isParagraphActive(editor);
|
|
8015
|
-
(0,
|
|
7999
|
+
(0, import_react54.useEffect)(() => {
|
|
8016
8000
|
if (!editor) return;
|
|
8017
8001
|
const handleSelectionUpdate = () => {
|
|
8018
8002
|
setIsVisible(shouldShowButton6({ editor, hideWhenUnavailable }));
|
|
@@ -8023,7 +8007,7 @@ function useText(config) {
|
|
|
8023
8007
|
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
8024
8008
|
};
|
|
8025
8009
|
}, [editor, hideWhenUnavailable]);
|
|
8026
|
-
const handleToggle = (0,
|
|
8010
|
+
const handleToggle = (0, import_react54.useCallback)(() => {
|
|
8027
8011
|
if (!editor) return false;
|
|
8028
8012
|
const success = toggleParagraph(editor);
|
|
8029
8013
|
if (success) {
|
|
@@ -8086,7 +8070,7 @@ var TextButton = ({
|
|
|
8086
8070
|
hideWhenUnavailable,
|
|
8087
8071
|
onToggled
|
|
8088
8072
|
});
|
|
8089
|
-
const handleClick = (0,
|
|
8073
|
+
const handleClick = (0, import_react55.useCallback)(
|
|
8090
8074
|
(event) => {
|
|
8091
8075
|
onClick == null ? void 0 : onClick(event);
|
|
8092
8076
|
if (event.defaultPrevented) return;
|
|
@@ -8127,7 +8111,7 @@ var TextButton = ({
|
|
|
8127
8111
|
var import_editor_utils27 = require("@kopexa/editor-utils");
|
|
8128
8112
|
var import_icons24 = require("@kopexa/icons");
|
|
8129
8113
|
var import_state10 = require("@tiptap/pm/state");
|
|
8130
|
-
var
|
|
8114
|
+
var import_react56 = require("react");
|
|
8131
8115
|
var import_react_intl22 = require("react-intl");
|
|
8132
8116
|
var TURN_INTO_BLOCKS = [
|
|
8133
8117
|
"paragraph",
|
|
@@ -8225,14 +8209,14 @@ function useTurnIntoDropdown(config) {
|
|
|
8225
8209
|
} = config || {};
|
|
8226
8210
|
const intl = (0, import_react_intl22.useIntl)();
|
|
8227
8211
|
const { editor } = (0, import_editor_utils27.useTiptapEditor)(providedEditor);
|
|
8228
|
-
const [isOpen, setIsOpen] = (0,
|
|
8229
|
-
const [isVisible, setIsVisible] = (0,
|
|
8230
|
-
const translatedBlockTypeOptions = (0,
|
|
8212
|
+
const [isOpen, setIsOpen] = (0, import_react56.useState)(false);
|
|
8213
|
+
const [isVisible, setIsVisible] = (0, import_react56.useState)(true);
|
|
8214
|
+
const translatedBlockTypeOptions = (0, import_react56.useMemo)(
|
|
8231
8215
|
() => createBlockTypeOptions(intl.formatMessage),
|
|
8232
8216
|
[intl]
|
|
8233
8217
|
);
|
|
8234
8218
|
const canToggle3 = canTurnInto(editor, blockTypes);
|
|
8235
|
-
const activeBlockType = (0,
|
|
8219
|
+
const activeBlockType = (0, import_react56.useMemo)(() => {
|
|
8236
8220
|
if (!editor) return translatedBlockTypeOptions[0];
|
|
8237
8221
|
const filteredOptions2 = blockTypes ? translatedBlockTypeOptions.filter(
|
|
8238
8222
|
(opt) => blockTypes.includes(opt.type)
|
|
@@ -8242,13 +8226,13 @@ function useTurnIntoDropdown(config) {
|
|
|
8242
8226
|
);
|
|
8243
8227
|
return activeOption || filteredOptions2[0];
|
|
8244
8228
|
}, [editor, blockTypes, translatedBlockTypeOptions]);
|
|
8245
|
-
const filteredOptions = (0,
|
|
8229
|
+
const filteredOptions = (0, import_react56.useMemo)(() => {
|
|
8246
8230
|
if (!blockTypes) return translatedBlockTypeOptions;
|
|
8247
8231
|
return translatedBlockTypeOptions.filter(
|
|
8248
8232
|
(opt) => blockTypes.includes(opt.type)
|
|
8249
8233
|
);
|
|
8250
8234
|
}, [blockTypes, translatedBlockTypeOptions]);
|
|
8251
|
-
const handleOpenChange = (0,
|
|
8235
|
+
const handleOpenChange = (0, import_react56.useCallback)(
|
|
8252
8236
|
(open) => {
|
|
8253
8237
|
if (!editor || !canToggle3) return;
|
|
8254
8238
|
setIsOpen(open);
|
|
@@ -8256,7 +8240,7 @@ function useTurnIntoDropdown(config) {
|
|
|
8256
8240
|
},
|
|
8257
8241
|
[canToggle3, editor, onOpenChange]
|
|
8258
8242
|
);
|
|
8259
|
-
(0,
|
|
8243
|
+
(0, import_react56.useEffect)(() => {
|
|
8260
8244
|
if (!editor) return;
|
|
8261
8245
|
const handleSelectionUpdate = () => {
|
|
8262
8246
|
setIsVisible(
|
|
@@ -8295,7 +8279,7 @@ function useTurnIntoDropdown(config) {
|
|
|
8295
8279
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
8296
8280
|
var TurnIntoDropdownContent = ({ blockTypes }) => {
|
|
8297
8281
|
const intl = (0, import_react_intl23.useIntl)();
|
|
8298
|
-
const filteredOptions = (0,
|
|
8282
|
+
const filteredOptions = (0, import_react57.useMemo)(() => {
|
|
8299
8283
|
const allOptions = createBlockTypeOptions(intl.formatMessage);
|
|
8300
8284
|
if (!blockTypes) return allOptions;
|
|
8301
8285
|
return allOptions.filter((opt) => blockTypes.includes(opt.type));
|
|
@@ -8393,7 +8377,7 @@ function renderBlockTypeButton(option, key) {
|
|
|
8393
8377
|
return null;
|
|
8394
8378
|
}
|
|
8395
8379
|
}
|
|
8396
|
-
var TurnIntoDropdown = (0,
|
|
8380
|
+
var TurnIntoDropdown = (0, import_react57.forwardRef)(
|
|
8397
8381
|
({
|
|
8398
8382
|
editor: providedEditor,
|
|
8399
8383
|
hideWhenUnavailable = false,
|
|
@@ -8458,12 +8442,12 @@ TurnIntoDropdown.displayName = "TurnIntoDropdown";
|
|
|
8458
8442
|
// src/ui/undo-redo-button/undo-redo-button.tsx
|
|
8459
8443
|
var import_editor_utils30 = require("@kopexa/editor-utils");
|
|
8460
8444
|
var import_toolbar9 = require("@kopexa/toolbar");
|
|
8461
|
-
var
|
|
8445
|
+
var import_react59 = require("react");
|
|
8462
8446
|
|
|
8463
8447
|
// src/ui/undo-redo-button/use-undo-redo.ts
|
|
8464
8448
|
var import_editor_utils29 = require("@kopexa/editor-utils");
|
|
8465
8449
|
var import_icons25 = require("@kopexa/icons");
|
|
8466
|
-
var
|
|
8450
|
+
var import_react58 = require("react");
|
|
8467
8451
|
var import_react_intl24 = require("react-intl");
|
|
8468
8452
|
var UNDO_REDO_SHORTCUT_KEYS = {
|
|
8469
8453
|
undo: "mod+z",
|
|
@@ -8505,9 +8489,9 @@ function useUndoRedo(config) {
|
|
|
8505
8489
|
} = config;
|
|
8506
8490
|
const intl = (0, import_react_intl24.useIntl)();
|
|
8507
8491
|
const { editor } = (0, import_editor_utils29.useTiptapEditor)(providedEditor);
|
|
8508
|
-
const [isVisible, setIsVisible] = (0,
|
|
8492
|
+
const [isVisible, setIsVisible] = (0, import_react58.useState)(true);
|
|
8509
8493
|
const canExecute = canExecuteUndoRedoAction(editor, action);
|
|
8510
|
-
(0,
|
|
8494
|
+
(0, import_react58.useEffect)(() => {
|
|
8511
8495
|
if (!editor) return;
|
|
8512
8496
|
const handleUpdate = () => {
|
|
8513
8497
|
setIsVisible(shouldShowButton7({ editor, hideWhenUnavailable, action }));
|
|
@@ -8518,7 +8502,7 @@ function useUndoRedo(config) {
|
|
|
8518
8502
|
editor.off("transaction", handleUpdate);
|
|
8519
8503
|
};
|
|
8520
8504
|
}, [editor, hideWhenUnavailable, action]);
|
|
8521
|
-
const handleAction = (0,
|
|
8505
|
+
const handleAction = (0, import_react58.useCallback)(() => {
|
|
8522
8506
|
if (!editor) return false;
|
|
8523
8507
|
const success = executeUndoRedoAction(editor, action);
|
|
8524
8508
|
if (success) {
|
|
@@ -8556,7 +8540,7 @@ var UndoRedoButton = ({
|
|
|
8556
8540
|
hideWhenUnavailable,
|
|
8557
8541
|
onExecuted
|
|
8558
8542
|
});
|
|
8559
|
-
const handleClick = (0,
|
|
8543
|
+
const handleClick = (0, import_react59.useCallback)(
|
|
8560
8544
|
(event) => {
|
|
8561
8545
|
onClick == null ? void 0 : onClick(event);
|
|
8562
8546
|
if (event.defaultPrevented) return;
|
|
@@ -8598,7 +8582,7 @@ var EditorHeader = ({
|
|
|
8598
8582
|
const isMobile = (0, import_use_is_mobile3.useIsMobile)();
|
|
8599
8583
|
const windowSize = useWindowSize();
|
|
8600
8584
|
const { styles } = useEditorUIContext();
|
|
8601
|
-
const toolbarRef = (0,
|
|
8585
|
+
const toolbarRef = (0, import_react60.useRef)(null);
|
|
8602
8586
|
const bodyRect = useCursorVisibility({
|
|
8603
8587
|
editor,
|
|
8604
8588
|
overlayHeight: (_b = (_a = toolbarRef.current) == null ? void 0 : _a.getBoundingClientRect().height) != null ? _b : 0
|
|
@@ -8668,9 +8652,9 @@ function MoreOptions({
|
|
|
8668
8652
|
}) {
|
|
8669
8653
|
const intl = (0, import_react_intl25.useIntl)();
|
|
8670
8654
|
const { editor } = (0, import_editor_utils31.useTiptapEditor)(providedEditor);
|
|
8671
|
-
const [show, setShow] = (0,
|
|
8655
|
+
const [show, setShow] = (0, import_react60.useState)(false);
|
|
8672
8656
|
const moreOptionsLabel = intl.formatMessage(messages7.more_options);
|
|
8673
|
-
(0,
|
|
8657
|
+
(0, import_react60.useEffect)(() => {
|
|
8674
8658
|
if (!editor) return;
|
|
8675
8659
|
const handleSelectionUpdate = () => {
|
|
8676
8660
|
setShow(
|
|
@@ -8783,7 +8767,7 @@ var BasicEditor = ({
|
|
|
8783
8767
|
...options
|
|
8784
8768
|
});
|
|
8785
8769
|
const styles = (0, import_theme9.editorBasic)({ variant, bordered });
|
|
8786
|
-
const resolveVariable = (0,
|
|
8770
|
+
const resolveVariable = (0, import_react62.useCallback)(
|
|
8787
8771
|
(name) => variableValues == null ? void 0 : variableValues[name],
|
|
8788
8772
|
[variableValues]
|
|
8789
8773
|
);
|
|
@@ -8793,7 +8777,7 @@ var BasicEditor = ({
|
|
|
8793
8777
|
const isBottomToolbar = variant === "field";
|
|
8794
8778
|
const hasVariables = variables && variables.length > 0;
|
|
8795
8779
|
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)(
|
|
8780
|
+
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_react61.EditorContext.Provider, { value: { editor }, children: [
|
|
8797
8781
|
showToolbar && !isBottomToolbar && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(EditorHeader, { editor, variant }),
|
|
8798
8782
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
8799
8783
|
EditorContentArea,
|
|
@@ -8817,10 +8801,10 @@ var EditorContentArea = ({
|
|
|
8817
8801
|
hasPagination
|
|
8818
8802
|
}) => {
|
|
8819
8803
|
const styles = (0, import_theme9.editorBasic)({ variant });
|
|
8820
|
-
const { editor } = (0,
|
|
8804
|
+
const { editor } = (0, import_react62.useContext)(import_react61.EditorContext);
|
|
8821
8805
|
const { isDragging } = useUiEditorState(editor);
|
|
8822
8806
|
useScrollToHash();
|
|
8823
|
-
const handleKeyDown = (0,
|
|
8807
|
+
const handleKeyDown = (0, import_react62.useCallback)(
|
|
8824
8808
|
(e) => {
|
|
8825
8809
|
if (!(editor == null ? void 0 : editor.isFocused)) return;
|
|
8826
8810
|
const isMod = e.metaKey || e.ctrlKey;
|
|
@@ -8864,7 +8848,7 @@ var EditorContentArea = ({
|
|
|
8864
8848
|
// biome-ignore lint/a11y/noStaticElementInteractions: Wrapper intercepts keyboard shortcuts to prevent propagation
|
|
8865
8849
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: styles.wrapper(), onKeyDown: handleKeyDown, children: [
|
|
8866
8850
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
8867
|
-
|
|
8851
|
+
import_react61.EditorContent,
|
|
8868
8852
|
{
|
|
8869
8853
|
editor,
|
|
8870
8854
|
role: "presentation",
|
|
@@ -8928,7 +8912,7 @@ function LoadingSpinner({ text = "Connecting..." }) {
|
|
|
8928
8912
|
|
|
8929
8913
|
// src/presets/view/index.tsx
|
|
8930
8914
|
var import_theme10 = require("@kopexa/theme");
|
|
8931
|
-
var
|
|
8915
|
+
var import_react63 = require("@tiptap/react");
|
|
8932
8916
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
8933
8917
|
function EditorView({
|
|
8934
8918
|
content,
|
|
@@ -8948,8 +8932,8 @@ function EditorView({
|
|
|
8948
8932
|
if (!editor) {
|
|
8949
8933
|
return null;
|
|
8950
8934
|
}
|
|
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
|
-
|
|
8935
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: styles.root({ className }), "data-slot": "editor-view", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_react63.EditorContext.Provider, { value: { editor }, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: styles.wrapper(), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
8936
|
+
import_react63.EditorContent,
|
|
8953
8937
|
{
|
|
8954
8938
|
editor,
|
|
8955
8939
|
role: "presentation",
|
|
@@ -8961,7 +8945,7 @@ function EditorView({
|
|
|
8961
8945
|
// src/presets/view/static.tsx
|
|
8962
8946
|
var import_theme11 = require("@kopexa/theme");
|
|
8963
8947
|
var import_html = require("@tiptap/html");
|
|
8964
|
-
var
|
|
8948
|
+
var import_react64 = require("react");
|
|
8965
8949
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
8966
8950
|
function EditorStaticView({
|
|
8967
8951
|
content,
|
|
@@ -8971,7 +8955,7 @@ function EditorStaticView({
|
|
|
8971
8955
|
customExtensions,
|
|
8972
8956
|
disabled
|
|
8973
8957
|
}) {
|
|
8974
|
-
const extensions = (0,
|
|
8958
|
+
const extensions = (0, import_react64.useMemo)(
|
|
8975
8959
|
() => getExtensions({
|
|
8976
8960
|
editable: false,
|
|
8977
8961
|
customExtensions,
|
|
@@ -8979,7 +8963,7 @@ function EditorStaticView({
|
|
|
8979
8963
|
}),
|
|
8980
8964
|
[customExtensions, disabled]
|
|
8981
8965
|
);
|
|
8982
|
-
const html = (0,
|
|
8966
|
+
const html = (0, import_react64.useMemo)(() => {
|
|
8983
8967
|
const parsed = safeParseContent(content);
|
|
8984
8968
|
if (!parsed) return "";
|
|
8985
8969
|
const json = parsed;
|