@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.mjs
CHANGED
|
@@ -373,11 +373,30 @@ import {
|
|
|
373
373
|
import { callout } from "@kopexa/theme";
|
|
374
374
|
import {
|
|
375
375
|
NodeViewContent,
|
|
376
|
-
NodeViewWrapper
|
|
377
|
-
useEditorState
|
|
376
|
+
NodeViewWrapper
|
|
378
377
|
} from "@tiptap/react";
|
|
379
378
|
import { useMemo as useMemo3 } from "react";
|
|
380
379
|
|
|
380
|
+
// src/hooks/use-editor-editable.ts
|
|
381
|
+
import { useCallback as useCallback3, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
382
|
+
function useEditorEditable(editor) {
|
|
383
|
+
const subscribe2 = useCallback3(
|
|
384
|
+
(callback) => {
|
|
385
|
+
if (!editor) return () => {
|
|
386
|
+
};
|
|
387
|
+
editor.on("transaction", callback);
|
|
388
|
+
return () => editor.off("transaction", callback);
|
|
389
|
+
},
|
|
390
|
+
[editor]
|
|
391
|
+
);
|
|
392
|
+
const getSnapshot2 = useCallback3(() => {
|
|
393
|
+
var _a;
|
|
394
|
+
return (_a = editor == null ? void 0 : editor.isEditable) != null ? _a : false;
|
|
395
|
+
}, [editor]);
|
|
396
|
+
const getServerSnapshot2 = useCallback3(() => false, []);
|
|
397
|
+
return useSyncExternalStore2(subscribe2, getSnapshot2, getServerSnapshot2);
|
|
398
|
+
}
|
|
399
|
+
|
|
381
400
|
// src/extensions/callout/callout-settings.tsx
|
|
382
401
|
import { Button, IconButton } from "@kopexa/button";
|
|
383
402
|
import { Dialog } from "@kopexa/dialog";
|
|
@@ -385,7 +404,7 @@ import { SettingsIcon } from "@kopexa/icons";
|
|
|
385
404
|
import { Input } from "@kopexa/input";
|
|
386
405
|
import { Label } from "@kopexa/label";
|
|
387
406
|
import { Select } from "@kopexa/select";
|
|
388
|
-
import { useCallback as
|
|
407
|
+
import { useCallback as useCallback4, useEffect as useEffect3, useState as useState3 } from "react";
|
|
389
408
|
import { useIntl } from "react-intl";
|
|
390
409
|
|
|
391
410
|
// src/extensions/callout/messages.ts
|
|
@@ -470,7 +489,7 @@ function CalloutSettings({
|
|
|
470
489
|
setLocalAttrs(attrs);
|
|
471
490
|
}
|
|
472
491
|
}, [isOpen, attrs]);
|
|
473
|
-
const handleSave =
|
|
492
|
+
const handleSave = useCallback4(() => {
|
|
474
493
|
const pos = getPos();
|
|
475
494
|
if (pos === void 0) return;
|
|
476
495
|
editor.view.dispatch(
|
|
@@ -478,17 +497,17 @@ function CalloutSettings({
|
|
|
478
497
|
);
|
|
479
498
|
setIsOpen(false);
|
|
480
499
|
}, [editor, localAttrs, getPos]);
|
|
481
|
-
const handleCancel =
|
|
500
|
+
const handleCancel = useCallback4(() => {
|
|
482
501
|
setLocalAttrs(attrs);
|
|
483
502
|
setIsOpen(false);
|
|
484
503
|
}, [attrs]);
|
|
485
|
-
const handleVariantChange =
|
|
504
|
+
const handleVariantChange = useCallback4((value) => {
|
|
486
505
|
setLocalAttrs((prev) => ({
|
|
487
506
|
...prev,
|
|
488
507
|
variant: String(value)
|
|
489
508
|
}));
|
|
490
509
|
}, []);
|
|
491
|
-
const handleTitleChange =
|
|
510
|
+
const handleTitleChange = useCallback4(
|
|
492
511
|
(e) => {
|
|
493
512
|
const value = e.target.value;
|
|
494
513
|
setLocalAttrs((prev) => ({
|
|
@@ -574,13 +593,7 @@ function getVariantIcon(variant, iconClass) {
|
|
|
574
593
|
function CalloutNodeView({ editor, node, getPos }) {
|
|
575
594
|
const attrs = node.attrs;
|
|
576
595
|
const { variant = "info", title } = attrs;
|
|
577
|
-
const isEditable =
|
|
578
|
-
editor,
|
|
579
|
-
selector: ({ editor: e }) => {
|
|
580
|
-
var _a;
|
|
581
|
-
return (_a = e == null ? void 0 : e.isEditable) != null ? _a : false;
|
|
582
|
-
}
|
|
583
|
-
});
|
|
596
|
+
const isEditable = useEditorEditable(editor);
|
|
584
597
|
const styles = useMemo3(
|
|
585
598
|
() => callout({
|
|
586
599
|
variant,
|
|
@@ -729,11 +742,8 @@ import {
|
|
|
729
742
|
TrashIcon
|
|
730
743
|
} from "@kopexa/icons";
|
|
731
744
|
import { imagePlaceholder } from "@kopexa/theme";
|
|
732
|
-
import {
|
|
733
|
-
|
|
734
|
-
useEditorState as useEditorState2
|
|
735
|
-
} from "@tiptap/react";
|
|
736
|
-
import { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo4, useRef as useRef4, useState as useState4 } from "react";
|
|
745
|
+
import { NodeViewWrapper as NodeViewWrapper2 } from "@tiptap/react";
|
|
746
|
+
import { useCallback as useCallback5, useEffect as useEffect4, useMemo as useMemo4, useRef as useRef4, useState as useState4 } from "react";
|
|
737
747
|
import { useIntl as useIntl2 } from "react-intl";
|
|
738
748
|
|
|
739
749
|
// src/extensions/image/messages.ts
|
|
@@ -772,18 +782,12 @@ function ImageNodeView({ editor, node, getPos }) {
|
|
|
772
782
|
const intl = useIntl2();
|
|
773
783
|
const fileHandler = useEditorFile();
|
|
774
784
|
const { src, alt, title, uploadState, uploadProgress } = node.attrs;
|
|
775
|
-
const isEditable =
|
|
776
|
-
editor,
|
|
777
|
-
selector: ({ editor: e }) => {
|
|
778
|
-
var _a2;
|
|
779
|
-
return (_a2 = e == null ? void 0 : e.isEditable) != null ? _a2 : false;
|
|
780
|
-
}
|
|
781
|
-
});
|
|
785
|
+
const isEditable = useEditorEditable(editor);
|
|
782
786
|
const [resolvedUrl, setResolvedUrl] = useState4(null);
|
|
783
787
|
const [resolveState, setResolveState] = useState4("idle");
|
|
784
788
|
const retryCountRef = useRef4(0);
|
|
785
789
|
const needsResolve = (_a = fileHandler == null ? void 0 : fileHandler.isReference(src)) != null ? _a : false;
|
|
786
|
-
const resolveImage =
|
|
790
|
+
const resolveImage = useCallback5(async () => {
|
|
787
791
|
if (!src) return;
|
|
788
792
|
if (!needsResolve) {
|
|
789
793
|
setResolvedUrl(src);
|
|
@@ -808,11 +812,11 @@ function ImageNodeView({ editor, node, getPos }) {
|
|
|
808
812
|
useEffect4(() => {
|
|
809
813
|
resolveImage();
|
|
810
814
|
}, [resolveImage]);
|
|
811
|
-
const handleRetry =
|
|
815
|
+
const handleRetry = useCallback5(() => {
|
|
812
816
|
retryCountRef.current += 1;
|
|
813
817
|
resolveImage();
|
|
814
818
|
}, [resolveImage]);
|
|
815
|
-
const handleRemove =
|
|
819
|
+
const handleRemove = useCallback5(() => {
|
|
816
820
|
const pos = getPos();
|
|
817
821
|
if (pos === void 0) return;
|
|
818
822
|
editor.commands.deleteRange({
|
|
@@ -1025,11 +1029,8 @@ import {
|
|
|
1025
1029
|
UploadIcon
|
|
1026
1030
|
} from "@kopexa/icons";
|
|
1027
1031
|
import { imagePlaceholder as imagePlaceholder2 } from "@kopexa/theme";
|
|
1028
|
-
import {
|
|
1029
|
-
|
|
1030
|
-
useEditorState as useEditorState3
|
|
1031
|
-
} from "@tiptap/react";
|
|
1032
|
-
import { useCallback as useCallback5, useMemo as useMemo5, useRef as useRef5, useState as useState5 } from "react";
|
|
1032
|
+
import { NodeViewWrapper as NodeViewWrapper3 } from "@tiptap/react";
|
|
1033
|
+
import { useCallback as useCallback6, useMemo as useMemo5, useRef as useRef5, useState as useState5 } from "react";
|
|
1033
1034
|
import { useIntl as useIntl3 } from "react-intl";
|
|
1034
1035
|
|
|
1035
1036
|
// src/extensions/image-upload/messages.ts
|
|
@@ -1070,18 +1071,12 @@ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
|
1070
1071
|
function ImageUploadNodeView({ editor, node, getPos }) {
|
|
1071
1072
|
const intl = useIntl3();
|
|
1072
1073
|
const fileHandler = useEditorFile();
|
|
1073
|
-
const isEditable =
|
|
1074
|
-
editor,
|
|
1075
|
-
selector: ({ editor: e }) => {
|
|
1076
|
-
var _a;
|
|
1077
|
-
return (_a = e == null ? void 0 : e.isEditable) != null ? _a : false;
|
|
1078
|
-
}
|
|
1079
|
-
});
|
|
1074
|
+
const isEditable = useEditorEditable(editor);
|
|
1080
1075
|
const [uploadState, setUploadState] = useState5("idle");
|
|
1081
1076
|
const [uploadProgress, setUploadProgress] = useState5(0);
|
|
1082
1077
|
const [isDragOver, setIsDragOver] = useState5(false);
|
|
1083
1078
|
const fileInputRef = useRef5(null);
|
|
1084
|
-
const handleRemove =
|
|
1079
|
+
const handleRemove = useCallback6(() => {
|
|
1085
1080
|
const pos = getPos();
|
|
1086
1081
|
if (pos === void 0) return;
|
|
1087
1082
|
editor.commands.deleteRange({
|
|
@@ -1089,7 +1084,7 @@ function ImageUploadNodeView({ editor, node, getPos }) {
|
|
|
1089
1084
|
to: pos + node.nodeSize
|
|
1090
1085
|
});
|
|
1091
1086
|
}, [editor, getPos, node.nodeSize]);
|
|
1092
|
-
const handleFileSelect =
|
|
1087
|
+
const handleFileSelect = useCallback6(
|
|
1093
1088
|
async (file) => {
|
|
1094
1089
|
if (!fileHandler) return;
|
|
1095
1090
|
const pos = getPos();
|
|
@@ -1118,7 +1113,7 @@ function ImageUploadNodeView({ editor, node, getPos }) {
|
|
|
1118
1113
|
},
|
|
1119
1114
|
[fileHandler, editor, getPos, node.nodeSize]
|
|
1120
1115
|
);
|
|
1121
|
-
const handleInputChange =
|
|
1116
|
+
const handleInputChange = useCallback6(
|
|
1122
1117
|
(e) => {
|
|
1123
1118
|
var _a;
|
|
1124
1119
|
const file = (_a = e.target.files) == null ? void 0 : _a[0];
|
|
@@ -1129,7 +1124,7 @@ function ImageUploadNodeView({ editor, node, getPos }) {
|
|
|
1129
1124
|
},
|
|
1130
1125
|
[handleFileSelect]
|
|
1131
1126
|
);
|
|
1132
|
-
const handleDrop =
|
|
1127
|
+
const handleDrop = useCallback6(
|
|
1133
1128
|
(e) => {
|
|
1134
1129
|
e.preventDefault();
|
|
1135
1130
|
e.stopPropagation();
|
|
@@ -1141,23 +1136,23 @@ function ImageUploadNodeView({ editor, node, getPos }) {
|
|
|
1141
1136
|
},
|
|
1142
1137
|
[handleFileSelect]
|
|
1143
1138
|
);
|
|
1144
|
-
const handleDragOver =
|
|
1139
|
+
const handleDragOver = useCallback6((e) => {
|
|
1145
1140
|
e.preventDefault();
|
|
1146
1141
|
e.stopPropagation();
|
|
1147
1142
|
}, []);
|
|
1148
|
-
const handleDragEnter =
|
|
1143
|
+
const handleDragEnter = useCallback6((e) => {
|
|
1149
1144
|
e.preventDefault();
|
|
1150
1145
|
e.stopPropagation();
|
|
1151
1146
|
setIsDragOver(true);
|
|
1152
1147
|
}, []);
|
|
1153
|
-
const handleDragLeave =
|
|
1148
|
+
const handleDragLeave = useCallback6((e) => {
|
|
1154
1149
|
e.preventDefault();
|
|
1155
1150
|
e.stopPropagation();
|
|
1156
1151
|
if (!e.currentTarget.contains(e.relatedTarget)) {
|
|
1157
1152
|
setIsDragOver(false);
|
|
1158
1153
|
}
|
|
1159
1154
|
}, []);
|
|
1160
|
-
const handleClick =
|
|
1155
|
+
const handleClick = useCallback6(() => {
|
|
1161
1156
|
var _a;
|
|
1162
1157
|
if (uploadState === "idle" || uploadState === "error") {
|
|
1163
1158
|
(_a = fileInputRef.current) == null ? void 0 : _a.click();
|
|
@@ -1409,13 +1404,10 @@ import { Button as Button2, IconButton as IconButton4 } from "@kopexa/button";
|
|
|
1409
1404
|
import { Dialog as Dialog2 } from "@kopexa/dialog";
|
|
1410
1405
|
import { EditIcon } from "@kopexa/icons";
|
|
1411
1406
|
import { Label as Label2 } from "@kopexa/label";
|
|
1412
|
-
import {
|
|
1413
|
-
NodeViewWrapper as NodeViewWrapper4,
|
|
1414
|
-
useEditorState as useEditorState4
|
|
1415
|
-
} from "@tiptap/react";
|
|
1407
|
+
import { NodeViewWrapper as NodeViewWrapper4 } from "@tiptap/react";
|
|
1416
1408
|
import katex from "katex";
|
|
1417
1409
|
import "katex/dist/katex.min.css";
|
|
1418
|
-
import { useCallback as
|
|
1410
|
+
import { useCallback as useCallback7, useEffect as useEffect5, useMemo as useMemo6, useState as useState6 } from "react";
|
|
1419
1411
|
import { useIntl as useIntl4 } from "react-intl";
|
|
1420
1412
|
|
|
1421
1413
|
// src/extensions/math/messages.ts
|
|
@@ -1474,13 +1466,7 @@ function MathBlockView({ editor, node, getPos }) {
|
|
|
1474
1466
|
const intl = useIntl4();
|
|
1475
1467
|
const attrs = node.attrs;
|
|
1476
1468
|
const { latex = "" } = attrs;
|
|
1477
|
-
const isEditable =
|
|
1478
|
-
editor,
|
|
1479
|
-
selector: ({ editor: e }) => {
|
|
1480
|
-
var _a;
|
|
1481
|
-
return (_a = e == null ? void 0 : e.isEditable) != null ? _a : false;
|
|
1482
|
-
}
|
|
1483
|
-
});
|
|
1469
|
+
const isEditable = useEditorEditable(editor);
|
|
1484
1470
|
const [isOpen, setIsOpen] = useState6(false);
|
|
1485
1471
|
const [localLatex, setLocalLatex] = useState6(latex);
|
|
1486
1472
|
const [error, setError] = useState6(null);
|
|
@@ -1516,7 +1502,7 @@ function MathBlockView({ editor, node, getPos }) {
|
|
|
1516
1502
|
return null;
|
|
1517
1503
|
}
|
|
1518
1504
|
}, [localLatex, intl]);
|
|
1519
|
-
const handleSave =
|
|
1505
|
+
const handleSave = useCallback7(() => {
|
|
1520
1506
|
const pos = getPos();
|
|
1521
1507
|
if (pos === void 0) return;
|
|
1522
1508
|
editor.view.dispatch(
|
|
@@ -1524,12 +1510,12 @@ function MathBlockView({ editor, node, getPos }) {
|
|
|
1524
1510
|
);
|
|
1525
1511
|
setIsOpen(false);
|
|
1526
1512
|
}, [editor, localLatex, getPos]);
|
|
1527
|
-
const handleCancel =
|
|
1513
|
+
const handleCancel = useCallback7(() => {
|
|
1528
1514
|
setLocalLatex(latex);
|
|
1529
1515
|
setError(null);
|
|
1530
1516
|
setIsOpen(false);
|
|
1531
1517
|
}, [latex]);
|
|
1532
|
-
const handleOpenEditor =
|
|
1518
|
+
const handleOpenEditor = useCallback7(
|
|
1533
1519
|
(e) => {
|
|
1534
1520
|
e.stopPropagation();
|
|
1535
1521
|
e.preventDefault();
|
|
@@ -1622,26 +1608,17 @@ import { ReactNodeViewRenderer as ReactNodeViewRenderer4 } from "@tiptap/react";
|
|
|
1622
1608
|
import { Button as Button3 } from "@kopexa/button";
|
|
1623
1609
|
import { Dialog as Dialog3 } from "@kopexa/dialog";
|
|
1624
1610
|
import { Label as Label3 } from "@kopexa/label";
|
|
1625
|
-
import {
|
|
1626
|
-
NodeViewWrapper as NodeViewWrapper5,
|
|
1627
|
-
useEditorState as useEditorState5
|
|
1628
|
-
} from "@tiptap/react";
|
|
1611
|
+
import { NodeViewWrapper as NodeViewWrapper5 } from "@tiptap/react";
|
|
1629
1612
|
import katex2 from "katex";
|
|
1630
1613
|
import "katex/dist/katex.min.css";
|
|
1631
|
-
import { useCallback as
|
|
1614
|
+
import { useCallback as useCallback8, useEffect as useEffect6, useMemo as useMemo7, useState as useState7 } from "react";
|
|
1632
1615
|
import { useIntl as useIntl5 } from "react-intl";
|
|
1633
1616
|
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1634
1617
|
function InlineMathView({ editor, node, getPos }) {
|
|
1635
1618
|
const intl = useIntl5();
|
|
1636
1619
|
const attrs = node.attrs;
|
|
1637
1620
|
const { latex = "" } = attrs;
|
|
1638
|
-
const isEditable =
|
|
1639
|
-
editor,
|
|
1640
|
-
selector: ({ editor: e }) => {
|
|
1641
|
-
var _a;
|
|
1642
|
-
return (_a = e == null ? void 0 : e.isEditable) != null ? _a : false;
|
|
1643
|
-
}
|
|
1644
|
-
});
|
|
1621
|
+
const isEditable = useEditorEditable(editor);
|
|
1645
1622
|
const [isOpen, setIsOpen] = useState7(false);
|
|
1646
1623
|
const [localLatex, setLocalLatex] = useState7(latex);
|
|
1647
1624
|
const [error, setError] = useState7(null);
|
|
@@ -1677,7 +1654,7 @@ function InlineMathView({ editor, node, getPos }) {
|
|
|
1677
1654
|
return null;
|
|
1678
1655
|
}
|
|
1679
1656
|
}, [localLatex, intl]);
|
|
1680
|
-
const handleSave =
|
|
1657
|
+
const handleSave = useCallback8(() => {
|
|
1681
1658
|
const pos = getPos();
|
|
1682
1659
|
if (pos === void 0) return;
|
|
1683
1660
|
editor.view.dispatch(
|
|
@@ -1685,12 +1662,12 @@ function InlineMathView({ editor, node, getPos }) {
|
|
|
1685
1662
|
);
|
|
1686
1663
|
setIsOpen(false);
|
|
1687
1664
|
}, [editor, localLatex, getPos]);
|
|
1688
|
-
const handleCancel =
|
|
1665
|
+
const handleCancel = useCallback8(() => {
|
|
1689
1666
|
setLocalLatex(latex);
|
|
1690
1667
|
setError(null);
|
|
1691
1668
|
setIsOpen(false);
|
|
1692
1669
|
}, [latex]);
|
|
1693
|
-
const handleClick =
|
|
1670
|
+
const handleClick = useCallback8(
|
|
1694
1671
|
(e) => {
|
|
1695
1672
|
e.stopPropagation();
|
|
1696
1673
|
e.preventDefault();
|
|
@@ -1915,7 +1892,7 @@ import { ReactNodeViewRenderer as ReactNodeViewRenderer6 } from "@tiptap/react";
|
|
|
1915
1892
|
import { ListIcon } from "@kopexa/icons";
|
|
1916
1893
|
import { toc } from "@kopexa/theme";
|
|
1917
1894
|
import { NodeViewWrapper as NodeViewWrapper6 } from "@tiptap/react";
|
|
1918
|
-
import { useCallback as
|
|
1895
|
+
import { useCallback as useCallback10, useEffect as useEffect8, useMemo as useMemo8, useState as useState9 } from "react";
|
|
1919
1896
|
import { useIntl as useIntl7 } from "react-intl";
|
|
1920
1897
|
|
|
1921
1898
|
// src/extensions/toc/messages.ts
|
|
@@ -2000,7 +1977,7 @@ import { SettingsIcon as SettingsIcon2 } from "@kopexa/icons";
|
|
|
2000
1977
|
import { Label as Label4 } from "@kopexa/label";
|
|
2001
1978
|
import { Select as Select2 } from "@kopexa/select";
|
|
2002
1979
|
import { Switch } from "@kopexa/switch";
|
|
2003
|
-
import { useCallback as
|
|
1980
|
+
import { useCallback as useCallback9, useEffect as useEffect7, useState as useState8 } from "react";
|
|
2004
1981
|
import { useIntl as useIntl6 } from "react-intl";
|
|
2005
1982
|
import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2006
1983
|
var HEADING_LEVELS = [
|
|
@@ -2020,7 +1997,7 @@ function TocSettings({ editor, attrs, getPos }) {
|
|
|
2020
1997
|
setLocalAttrs(attrs);
|
|
2021
1998
|
}
|
|
2022
1999
|
}, [isOpen, attrs]);
|
|
2023
|
-
const handleSave =
|
|
2000
|
+
const handleSave = useCallback9(() => {
|
|
2024
2001
|
const pos = getPos();
|
|
2025
2002
|
if (pos === void 0) return;
|
|
2026
2003
|
editor.view.dispatch(
|
|
@@ -2028,11 +2005,11 @@ function TocSettings({ editor, attrs, getPos }) {
|
|
|
2028
2005
|
);
|
|
2029
2006
|
setIsOpen(false);
|
|
2030
2007
|
}, [editor, localAttrs, getPos]);
|
|
2031
|
-
const handleCancel =
|
|
2008
|
+
const handleCancel = useCallback9(() => {
|
|
2032
2009
|
setLocalAttrs(attrs);
|
|
2033
2010
|
setIsOpen(false);
|
|
2034
2011
|
}, [attrs]);
|
|
2035
|
-
const handleMinLevelChange =
|
|
2012
|
+
const handleMinLevelChange = useCallback9((value) => {
|
|
2036
2013
|
const minLevel = Number.parseInt(String(value), 10);
|
|
2037
2014
|
setLocalAttrs((prev) => ({
|
|
2038
2015
|
...prev,
|
|
@@ -2041,7 +2018,7 @@ function TocSettings({ editor, attrs, getPos }) {
|
|
|
2041
2018
|
maxLevel: Math.max(prev.maxLevel, minLevel)
|
|
2042
2019
|
}));
|
|
2043
2020
|
}, []);
|
|
2044
|
-
const handleMaxLevelChange =
|
|
2021
|
+
const handleMaxLevelChange = useCallback9((value) => {
|
|
2045
2022
|
const maxLevel = Number.parseInt(String(value), 10);
|
|
2046
2023
|
setLocalAttrs((prev) => ({
|
|
2047
2024
|
...prev,
|
|
@@ -2050,10 +2027,10 @@ function TocSettings({ editor, attrs, getPos }) {
|
|
|
2050
2027
|
minLevel: Math.min(prev.minLevel, maxLevel)
|
|
2051
2028
|
}));
|
|
2052
2029
|
}, []);
|
|
2053
|
-
const handleNumberedChange =
|
|
2030
|
+
const handleNumberedChange = useCallback9((checked) => {
|
|
2054
2031
|
setLocalAttrs((prev) => ({ ...prev, numbered: checked }));
|
|
2055
2032
|
}, []);
|
|
2056
|
-
const handleStyleChange =
|
|
2033
|
+
const handleStyleChange = useCallback9((value) => {
|
|
2057
2034
|
setLocalAttrs((prev) => ({
|
|
2058
2035
|
...prev,
|
|
2059
2036
|
style: String(value)
|
|
@@ -2203,7 +2180,7 @@ function TocNodeView({ editor, node, getPos }) {
|
|
|
2203
2180
|
style = "default"
|
|
2204
2181
|
} = attrs;
|
|
2205
2182
|
const styles = useMemo8(() => toc({ style }), [style]);
|
|
2206
|
-
const updateHeadings =
|
|
2183
|
+
const updateHeadings = useCallback10(() => {
|
|
2207
2184
|
const items = [];
|
|
2208
2185
|
const { doc } = editor.state;
|
|
2209
2186
|
doc.descendants((docNode, pos) => {
|
|
@@ -2230,7 +2207,7 @@ function TocNodeView({ editor, node, getPos }) {
|
|
|
2230
2207
|
editor.off("update", updateHeadings);
|
|
2231
2208
|
};
|
|
2232
2209
|
}, [editor, updateHeadings]);
|
|
2233
|
-
const handleClick =
|
|
2210
|
+
const handleClick = useCallback10(
|
|
2234
2211
|
(pos, id) => {
|
|
2235
2212
|
var _a;
|
|
2236
2213
|
editor.chain().focus().setTextSelection(pos).run();
|
|
@@ -2383,10 +2360,7 @@ import { ReactNodeViewRenderer as ReactNodeViewRenderer7 } from "@tiptap/react";
|
|
|
2383
2360
|
|
|
2384
2361
|
// src/extensions/variable/variable-view.tsx
|
|
2385
2362
|
import { variableNode } from "@kopexa/theme";
|
|
2386
|
-
import {
|
|
2387
|
-
NodeViewWrapper as NodeViewWrapper7,
|
|
2388
|
-
useEditorState as useEditorState6
|
|
2389
|
-
} from "@tiptap/react";
|
|
2363
|
+
import { NodeViewWrapper as NodeViewWrapper7 } from "@tiptap/react";
|
|
2390
2364
|
|
|
2391
2365
|
// src/extensions/variable/variable-context.tsx
|
|
2392
2366
|
import * as React from "react";
|
|
@@ -2422,13 +2396,7 @@ function VariableNodeView({ node, editor }) {
|
|
|
2422
2396
|
const attrs = node.attrs;
|
|
2423
2397
|
const { name, fallback, category } = attrs;
|
|
2424
2398
|
const context = useVariables();
|
|
2425
|
-
const isEditable =
|
|
2426
|
-
editor,
|
|
2427
|
-
selector: ({ editor: e }) => {
|
|
2428
|
-
var _a2;
|
|
2429
|
-
return (_a2 = e == null ? void 0 : e.isEditable) != null ? _a2 : true;
|
|
2430
|
-
}
|
|
2431
|
-
});
|
|
2399
|
+
const isEditable = useEditorEditable(editor);
|
|
2432
2400
|
const resolvedValue = (_a = context == null ? void 0 : context.resolveVariable) == null ? void 0 : _a.call(context, name);
|
|
2433
2401
|
const hasValue = resolvedValue !== void 0 && resolvedValue !== "";
|
|
2434
2402
|
const displayValue = resolvedValue || fallback;
|
|
@@ -4381,7 +4349,7 @@ import {
|
|
|
4381
4349
|
EditorContext
|
|
4382
4350
|
} from "@tiptap/react";
|
|
4383
4351
|
import {
|
|
4384
|
-
useCallback as
|
|
4352
|
+
useCallback as useCallback39,
|
|
4385
4353
|
useContext as useContext4
|
|
4386
4354
|
} from "react";
|
|
4387
4355
|
import { useIntl as useIntl19 } from "react-intl";
|
|
@@ -4391,10 +4359,10 @@ import { createContext as createContext4 } from "@kopexa/react-utils";
|
|
|
4391
4359
|
var [EditorUIProvider, useEditorUIContext] = createContext4();
|
|
4392
4360
|
|
|
4393
4361
|
// src/hooks/use-ui-editor-state.ts
|
|
4394
|
-
import { useEditorState
|
|
4362
|
+
import { useEditorState } from "@tiptap/react";
|
|
4395
4363
|
function useUiEditorState(editor) {
|
|
4396
4364
|
var _a;
|
|
4397
|
-
return (_a =
|
|
4365
|
+
return (_a = useEditorState({
|
|
4398
4366
|
editor,
|
|
4399
4367
|
selector: ({ editor: editor2 }) => {
|
|
4400
4368
|
if (!editor2) return defaultUiState;
|
|
@@ -4427,7 +4395,7 @@ import {
|
|
|
4427
4395
|
import { Input as Input3 } from "@kopexa/input";
|
|
4428
4396
|
import { Popover } from "@kopexa/popover";
|
|
4429
4397
|
import { ToolbarButton } from "@kopexa/toolbar";
|
|
4430
|
-
import { useCallback as
|
|
4398
|
+
import { useCallback as useCallback15, useEffect as useEffect16, useState as useState15 } from "react";
|
|
4431
4399
|
|
|
4432
4400
|
// src/ui/link-popover/use-link-popover.ts
|
|
4433
4401
|
import { isMarkInSchema, useTiptapEditor as useTiptapEditor2 } from "@kopexa/editor-utils";
|
|
@@ -4816,18 +4784,18 @@ function LinkPopover({
|
|
|
4816
4784
|
hideWhenUnavailable,
|
|
4817
4785
|
onSetLink
|
|
4818
4786
|
});
|
|
4819
|
-
const handleOnOpenChange =
|
|
4787
|
+
const handleOnOpenChange = useCallback15(
|
|
4820
4788
|
(nextIsOpen) => {
|
|
4821
4789
|
setIsOpen(nextIsOpen);
|
|
4822
4790
|
onOpenChange == null ? void 0 : onOpenChange(nextIsOpen);
|
|
4823
4791
|
},
|
|
4824
4792
|
[onOpenChange]
|
|
4825
4793
|
);
|
|
4826
|
-
const handleSetLink =
|
|
4794
|
+
const handleSetLink = useCallback15(() => {
|
|
4827
4795
|
setLink();
|
|
4828
4796
|
setIsOpen(false);
|
|
4829
4797
|
}, [setLink]);
|
|
4830
|
-
const handleClick =
|
|
4798
|
+
const handleClick = useCallback15(
|
|
4831
4799
|
(event) => {
|
|
4832
4800
|
onClick == null ? void 0 : onClick(event);
|
|
4833
4801
|
if (event.defaultPrevented) return;
|
|
@@ -4902,7 +4870,7 @@ import {
|
|
|
4902
4870
|
} from "@kopexa/icons";
|
|
4903
4871
|
import { ToolbarButton as ToolbarButton2 } from "@kopexa/toolbar";
|
|
4904
4872
|
import { isNodeSelection as isNodeSelection2 } from "@tiptap/react";
|
|
4905
|
-
import { useCallback as
|
|
4873
|
+
import { useCallback as useCallback16, useMemo as useMemo13 } from "react";
|
|
4906
4874
|
import { useIntl as useIntl9 } from "react-intl";
|
|
4907
4875
|
|
|
4908
4876
|
// src/ui/messages.ts
|
|
@@ -5423,7 +5391,7 @@ var MarkButton = ({
|
|
|
5423
5391
|
shortcutKey,
|
|
5424
5392
|
formattedName
|
|
5425
5393
|
} = useMarkState(editor, type, disabled);
|
|
5426
|
-
const handleClick =
|
|
5394
|
+
const handleClick = useCallback16(
|
|
5427
5395
|
(e) => {
|
|
5428
5396
|
onClick == null ? void 0 : onClick(e);
|
|
5429
5397
|
if (!e.defaultPrevented && !isDisabled && editor) {
|
|
@@ -5614,14 +5582,14 @@ import { IconButton as IconButton7 } from "@kopexa/button";
|
|
|
5614
5582
|
import { EditIcon as EditIcon3, ExternalLinkIcon as ExternalLinkIcon2, TrashIcon as TrashIcon4 } from "@kopexa/icons";
|
|
5615
5583
|
import { Input as Input4 } from "@kopexa/input";
|
|
5616
5584
|
import { BubbleMenu as TiptapBubbleMenu2 } from "@tiptap/react/menus";
|
|
5617
|
-
import { useCallback as
|
|
5585
|
+
import { useCallback as useCallback18, useEffect as useEffect19, useState as useState17 } from "react";
|
|
5618
5586
|
import { useIntl as useIntl10 } from "react-intl";
|
|
5619
5587
|
import { Fragment as Fragment3, jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
5620
5588
|
function LinkBubble({ editor }) {
|
|
5621
5589
|
const intl = useIntl10();
|
|
5622
5590
|
const [isEditing, setIsEditing] = useState17(false);
|
|
5623
5591
|
const [url, setUrl] = useState17("");
|
|
5624
|
-
const getCurrentUrl =
|
|
5592
|
+
const getCurrentUrl = useCallback18(() => {
|
|
5625
5593
|
if (!editor) return "";
|
|
5626
5594
|
const attrs = editor.getAttributes("link");
|
|
5627
5595
|
return attrs.href || "";
|
|
@@ -5633,20 +5601,20 @@ function LinkBubble({ editor }) {
|
|
|
5633
5601
|
setIsEditing(false);
|
|
5634
5602
|
}
|
|
5635
5603
|
}, [editor, getCurrentUrl]);
|
|
5636
|
-
const handleOpenLink =
|
|
5604
|
+
const handleOpenLink = useCallback18(() => {
|
|
5637
5605
|
const href = getCurrentUrl();
|
|
5638
5606
|
if (href) {
|
|
5639
5607
|
window.open(href, "_blank", "noopener,noreferrer");
|
|
5640
5608
|
}
|
|
5641
5609
|
}, [getCurrentUrl]);
|
|
5642
|
-
const handleRemoveLink =
|
|
5610
|
+
const handleRemoveLink = useCallback18(() => {
|
|
5643
5611
|
editor == null ? void 0 : editor.chain().focus().unsetLink().run();
|
|
5644
5612
|
}, [editor]);
|
|
5645
|
-
const handleEdit =
|
|
5613
|
+
const handleEdit = useCallback18(() => {
|
|
5646
5614
|
setUrl(getCurrentUrl());
|
|
5647
5615
|
setIsEditing(true);
|
|
5648
5616
|
}, [getCurrentUrl]);
|
|
5649
|
-
const handleSave =
|
|
5617
|
+
const handleSave = useCallback18(() => {
|
|
5650
5618
|
if (url) {
|
|
5651
5619
|
editor == null ? void 0 : editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
|
|
5652
5620
|
} else {
|
|
@@ -5654,7 +5622,7 @@ function LinkBubble({ editor }) {
|
|
|
5654
5622
|
}
|
|
5655
5623
|
setIsEditing(false);
|
|
5656
5624
|
}, [editor, url]);
|
|
5657
|
-
const handleKeyDown =
|
|
5625
|
+
const handleKeyDown = useCallback18(
|
|
5658
5626
|
(e) => {
|
|
5659
5627
|
if (e.key === "Enter") {
|
|
5660
5628
|
e.preventDefault();
|
|
@@ -5807,7 +5775,7 @@ import {
|
|
|
5807
5775
|
} from "@kopexa/editor-utils";
|
|
5808
5776
|
import { TableIcon } from "@kopexa/icons";
|
|
5809
5777
|
import { isNodeSelection as isNodeSelection4 } from "@tiptap/react";
|
|
5810
|
-
import { useCallback as
|
|
5778
|
+
import { useCallback as useCallback19, useEffect as useEffect20, useState as useState18 } from "react";
|
|
5811
5779
|
import { useIntl as useIntl11 } from "react-intl";
|
|
5812
5780
|
function canToggle(editor) {
|
|
5813
5781
|
if (!editor || !editor.isEditable) return false;
|
|
@@ -5867,7 +5835,7 @@ function useTableBlock(config) {
|
|
|
5867
5835
|
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
5868
5836
|
};
|
|
5869
5837
|
}, [editor, hideWhenUnavailable]);
|
|
5870
|
-
const handleToggle =
|
|
5838
|
+
const handleToggle = useCallback19(() => {
|
|
5871
5839
|
if (!editor) return false;
|
|
5872
5840
|
const success = toggleTable(editor);
|
|
5873
5841
|
if (success) {
|
|
@@ -6551,7 +6519,7 @@ import { useMemo as useMemo16, useRef as useRef11, useState as useState22 } from
|
|
|
6551
6519
|
import { useTiptapEditor as useTiptapEditor8 } from "@kopexa/editor-utils";
|
|
6552
6520
|
import { colorHighlightButton } from "@kopexa/theme";
|
|
6553
6521
|
import { ToolbarButton as ToolbarButton3 } from "@kopexa/toolbar";
|
|
6554
|
-
import { useCallback as
|
|
6522
|
+
import { useCallback as useCallback23, useMemo as useMemo15 } from "react";
|
|
6555
6523
|
|
|
6556
6524
|
// src/ui/color-highlight-button/use-color-highlight.ts
|
|
6557
6525
|
import {
|
|
@@ -6752,7 +6720,7 @@ var ColorHighlightButton = ({
|
|
|
6752
6720
|
hideWhenUnavailable,
|
|
6753
6721
|
onApplied
|
|
6754
6722
|
});
|
|
6755
|
-
const handleClick =
|
|
6723
|
+
const handleClick = useCallback23(
|
|
6756
6724
|
(event) => {
|
|
6757
6725
|
onClick == null ? void 0 : onClick(event);
|
|
6758
6726
|
if (event.defaultPrevented) return;
|
|
@@ -6947,14 +6915,14 @@ import { DropdownMenu } from "@kopexa/dropdown-menu";
|
|
|
6947
6915
|
import { isNodeInSchema as isNodeInSchema4, useTiptapEditor as useTiptapEditor11 } from "@kopexa/editor-utils";
|
|
6948
6916
|
import { ChevronDownIcon, ListIcon as ListIcon4 } from "@kopexa/icons";
|
|
6949
6917
|
import { isNodeSelection as isNodeSelection6 } from "@tiptap/react";
|
|
6950
|
-
import { useCallback as
|
|
6918
|
+
import { useCallback as useCallback25, useMemo as useMemo18, useState as useState23 } from "react";
|
|
6951
6919
|
|
|
6952
6920
|
// src/ui/list-button/index.tsx
|
|
6953
6921
|
import { Button as Button7 } from "@kopexa/button";
|
|
6954
6922
|
import { isNodeInSchema as isNodeInSchema3, useTiptapEditor as useTiptapEditor10 } from "@kopexa/editor-utils";
|
|
6955
6923
|
import { ListIcon as ListIcon3, ListOrderedIcon as ListOrderedIcon2, ListTodoIcon as ListTodoIcon2 } from "@kopexa/icons";
|
|
6956
6924
|
import { isNodeSelection as isNodeSelection5 } from "@tiptap/react";
|
|
6957
|
-
import { useCallback as
|
|
6925
|
+
import { useCallback as useCallback24, useMemo as useMemo17 } from "react";
|
|
6958
6926
|
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
6959
6927
|
var listOptions = [
|
|
6960
6928
|
{
|
|
@@ -7064,7 +7032,7 @@ var ListButton = ({
|
|
|
7064
7032
|
type
|
|
7065
7033
|
);
|
|
7066
7034
|
const Icon = (listOption == null ? void 0 : listOption.icon) || ListIcon3;
|
|
7067
|
-
const handleClick =
|
|
7035
|
+
const handleClick = useCallback24(
|
|
7068
7036
|
(e) => {
|
|
7069
7037
|
onClick == null ? void 0 : onClick(e);
|
|
7070
7038
|
if (!e.defaultPrevented && editor) {
|
|
@@ -7144,7 +7112,7 @@ function useListDropdownState(editor, availableTypes) {
|
|
|
7144
7112
|
);
|
|
7145
7113
|
const canToggleAny = canToggleAnyList(editor, availableTypes);
|
|
7146
7114
|
const isAnyActive = isAnyListActive(editor, availableTypes);
|
|
7147
|
-
const handleOpenChange =
|
|
7115
|
+
const handleOpenChange = useCallback25(
|
|
7148
7116
|
(open, callback) => {
|
|
7149
7117
|
setIsOpen(open);
|
|
7150
7118
|
callback == null ? void 0 : callback(open);
|
|
@@ -7162,7 +7130,7 @@ function useListDropdownState(editor, availableTypes) {
|
|
|
7162
7130
|
};
|
|
7163
7131
|
}
|
|
7164
7132
|
function useActiveListIcon(editor, filteredLists) {
|
|
7165
|
-
return
|
|
7133
|
+
return useCallback25(() => {
|
|
7166
7134
|
const activeOption = filteredLists.find(
|
|
7167
7135
|
(option) => isListActive(editor, option.type)
|
|
7168
7136
|
);
|
|
@@ -7195,7 +7163,7 @@ function ListDropdownMenu({
|
|
|
7195
7163
|
canToggleAny
|
|
7196
7164
|
});
|
|
7197
7165
|
}, [editor, types, hideWhenUnavailable, listInSchema, canToggleAny]);
|
|
7198
|
-
const handleOnOpenChange =
|
|
7166
|
+
const handleOnOpenChange = useCallback25(
|
|
7199
7167
|
(open) => handleOpenChange(open, onOpenChange),
|
|
7200
7168
|
[handleOpenChange, onOpenChange]
|
|
7201
7169
|
);
|
|
@@ -7236,7 +7204,7 @@ function ListDropdownMenu({
|
|
|
7236
7204
|
// src/ui/table-button/index.tsx
|
|
7237
7205
|
import { useTiptapEditor as useTiptapEditor12 } from "@kopexa/editor-utils";
|
|
7238
7206
|
import { ToolbarButton as ToolbarButton4 } from "@kopexa/toolbar";
|
|
7239
|
-
import { useCallback as
|
|
7207
|
+
import { useCallback as useCallback26 } from "react";
|
|
7240
7208
|
import { Fragment as Fragment5, jsx as jsx25, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
7241
7209
|
var TableButton = ({
|
|
7242
7210
|
editor: providedEditor,
|
|
@@ -7261,7 +7229,7 @@ var TableButton = ({
|
|
|
7261
7229
|
hideWhenUnavailable,
|
|
7262
7230
|
onToggled
|
|
7263
7231
|
});
|
|
7264
|
-
const handleClick =
|
|
7232
|
+
const handleClick = useCallback26(
|
|
7265
7233
|
(event) => {
|
|
7266
7234
|
onClick == null ? void 0 : onClick(event);
|
|
7267
7235
|
if (event.defaultPrevented) return;
|
|
@@ -7299,7 +7267,7 @@ var TableButton = ({
|
|
|
7299
7267
|
// src/ui/text-align-button/text-align-button.tsx
|
|
7300
7268
|
import { IconButton as IconButton9 } from "@kopexa/button";
|
|
7301
7269
|
import { useTiptapEditor as useTiptapEditor14 } from "@kopexa/editor-utils";
|
|
7302
|
-
import { useCallback as
|
|
7270
|
+
import { useCallback as useCallback28 } from "react";
|
|
7303
7271
|
|
|
7304
7272
|
// src/ui/text-align-button/use-text-align.ts
|
|
7305
7273
|
import {
|
|
@@ -7313,7 +7281,7 @@ import {
|
|
|
7313
7281
|
AlignLeftIcon,
|
|
7314
7282
|
AlignRightIcon
|
|
7315
7283
|
} from "@kopexa/icons";
|
|
7316
|
-
import { useCallback as
|
|
7284
|
+
import { useCallback as useCallback27, useEffect as useEffect25, useState as useState24 } from "react";
|
|
7317
7285
|
import { useIntl as useIntl14 } from "react-intl";
|
|
7318
7286
|
var TEXT_ALIGN_SHORTCUT_KEYS = {
|
|
7319
7287
|
left: "mod+shift+l",
|
|
@@ -7387,7 +7355,7 @@ function useTextAlign(config) {
|
|
|
7387
7355
|
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
7388
7356
|
};
|
|
7389
7357
|
}, [editor, hideWhenUnavailable, align]);
|
|
7390
|
-
const handleTextAlign =
|
|
7358
|
+
const handleTextAlign = useCallback27(() => {
|
|
7391
7359
|
if (!editor) return false;
|
|
7392
7360
|
const success = setTextAlign(editor, align);
|
|
7393
7361
|
if (success) {
|
|
@@ -7434,7 +7402,7 @@ var TextAlignButton = ({
|
|
|
7434
7402
|
hideWhenUnavailable,
|
|
7435
7403
|
onAligned
|
|
7436
7404
|
});
|
|
7437
|
-
const handleClick =
|
|
7405
|
+
const handleClick = useCallback28(
|
|
7438
7406
|
(e) => {
|
|
7439
7407
|
onClick == null ? void 0 : onClick(e);
|
|
7440
7408
|
if (e.defaultPrevented) return;
|
|
@@ -7664,7 +7632,7 @@ var BlockquoteButton = ({
|
|
|
7664
7632
|
import { useTiptapEditor as useTiptapEditor18 } from "@kopexa/editor-utils";
|
|
7665
7633
|
import { CodeblockIcon as CodeblockIcon2 } from "@kopexa/icons";
|
|
7666
7634
|
import { ToolbarButton as ToolbarButton6 } from "@kopexa/toolbar";
|
|
7667
|
-
import { useCallback as
|
|
7635
|
+
import { useCallback as useCallback32 } from "react";
|
|
7668
7636
|
|
|
7669
7637
|
// src/ui/codeblock-button/use-code-block.ts
|
|
7670
7638
|
import {
|
|
@@ -7804,7 +7772,7 @@ var CodeBlockButton = ({
|
|
|
7804
7772
|
hideWhenUnavailable,
|
|
7805
7773
|
onToggled
|
|
7806
7774
|
});
|
|
7807
|
-
const handleClick =
|
|
7775
|
+
const handleClick = useCallback32(
|
|
7808
7776
|
(event) => {
|
|
7809
7777
|
onClick == null ? void 0 : onClick(event);
|
|
7810
7778
|
if (event.defaultPrevented) return;
|
|
@@ -8001,7 +7969,7 @@ import { Button as Button10 } from "@kopexa/button";
|
|
|
8001
7969
|
import { Chip } from "@kopexa/chip";
|
|
8002
7970
|
import { useTiptapEditor as useTiptapEditor21 } from "@kopexa/editor-utils";
|
|
8003
7971
|
import { parseShortcutKeys } from "@kopexa/shared-utils";
|
|
8004
|
-
import { useCallback as
|
|
7972
|
+
import { useCallback as useCallback35 } from "react";
|
|
8005
7973
|
|
|
8006
7974
|
// src/ui/text-button/use-text.ts
|
|
8007
7975
|
import {
|
|
@@ -8015,7 +7983,7 @@ import {
|
|
|
8015
7983
|
import { TypeIcon as TypeIcon2 } from "@kopexa/icons";
|
|
8016
7984
|
import { useIsMobile as useIsMobile2 } from "@kopexa/use-is-mobile";
|
|
8017
7985
|
import { NodeSelection as NodeSelection4, TextSelection as TextSelection4 } from "@tiptap/pm/state";
|
|
8018
|
-
import { useCallback as
|
|
7986
|
+
import { useCallback as useCallback34, useEffect as useEffect28, useState as useState27 } from "react";
|
|
8019
7987
|
import { useHotkeys as useHotkeys2 } from "react-hotkeys-hook";
|
|
8020
7988
|
var TEXT_SHORTCUT_KEY = "mod+alt+0";
|
|
8021
7989
|
function canToggleText(editor, turnInto = true) {
|
|
@@ -8122,7 +8090,7 @@ function useText(config) {
|
|
|
8122
8090
|
editor.off("selectionUpdate", handleSelectionUpdate);
|
|
8123
8091
|
};
|
|
8124
8092
|
}, [editor, hideWhenUnavailable]);
|
|
8125
|
-
const handleToggle =
|
|
8093
|
+
const handleToggle = useCallback34(() => {
|
|
8126
8094
|
if (!editor) return false;
|
|
8127
8095
|
const success = toggleParagraph(editor);
|
|
8128
8096
|
if (success) {
|
|
@@ -8185,7 +8153,7 @@ var TextButton = ({
|
|
|
8185
8153
|
hideWhenUnavailable,
|
|
8186
8154
|
onToggled
|
|
8187
8155
|
});
|
|
8188
|
-
const handleClick =
|
|
8156
|
+
const handleClick = useCallback35(
|
|
8189
8157
|
(event) => {
|
|
8190
8158
|
onClick == null ? void 0 : onClick(event);
|
|
8191
8159
|
if (event.defaultPrevented) return;
|
|
@@ -8226,7 +8194,7 @@ var TextButton = ({
|
|
|
8226
8194
|
import { useTiptapEditor as useTiptapEditor22 } from "@kopexa/editor-utils";
|
|
8227
8195
|
import { ChevronDownIcon as ChevronDownIcon2 } from "@kopexa/icons";
|
|
8228
8196
|
import { NodeSelection as NodeSelection5 } from "@tiptap/pm/state";
|
|
8229
|
-
import { useCallback as
|
|
8197
|
+
import { useCallback as useCallback36, useEffect as useEffect29, useMemo as useMemo20, useState as useState28 } from "react";
|
|
8230
8198
|
import { useIntl as useIntl15 } from "react-intl";
|
|
8231
8199
|
var TURN_INTO_BLOCKS = [
|
|
8232
8200
|
"paragraph",
|
|
@@ -8347,7 +8315,7 @@ function useTurnIntoDropdown(config) {
|
|
|
8347
8315
|
(opt) => blockTypes.includes(opt.type)
|
|
8348
8316
|
);
|
|
8349
8317
|
}, [blockTypes, translatedBlockTypeOptions]);
|
|
8350
|
-
const handleOpenChange =
|
|
8318
|
+
const handleOpenChange = useCallback36(
|
|
8351
8319
|
(open) => {
|
|
8352
8320
|
if (!editor || !canToggle3) return;
|
|
8353
8321
|
setIsOpen(open);
|
|
@@ -8557,12 +8525,12 @@ TurnIntoDropdown.displayName = "TurnIntoDropdown";
|
|
|
8557
8525
|
// src/ui/undo-redo-button/undo-redo-button.tsx
|
|
8558
8526
|
import { useTiptapEditor as useTiptapEditor25 } from "@kopexa/editor-utils";
|
|
8559
8527
|
import { ToolbarButton as ToolbarButton7 } from "@kopexa/toolbar";
|
|
8560
|
-
import { useCallback as
|
|
8528
|
+
import { useCallback as useCallback38 } from "react";
|
|
8561
8529
|
|
|
8562
8530
|
// src/ui/undo-redo-button/use-undo-redo.ts
|
|
8563
8531
|
import { isNodeTypeSelected as isNodeTypeSelected7, useTiptapEditor as useTiptapEditor24 } from "@kopexa/editor-utils";
|
|
8564
8532
|
import { RedoIcon, UndoIcon } from "@kopexa/icons";
|
|
8565
|
-
import { useCallback as
|
|
8533
|
+
import { useCallback as useCallback37, useEffect as useEffect30, useState as useState29 } from "react";
|
|
8566
8534
|
import { useIntl as useIntl17 } from "react-intl";
|
|
8567
8535
|
var UNDO_REDO_SHORTCUT_KEYS = {
|
|
8568
8536
|
undo: "mod+z",
|
|
@@ -8617,7 +8585,7 @@ function useUndoRedo(config) {
|
|
|
8617
8585
|
editor.off("transaction", handleUpdate);
|
|
8618
8586
|
};
|
|
8619
8587
|
}, [editor, hideWhenUnavailable, action]);
|
|
8620
|
-
const handleAction =
|
|
8588
|
+
const handleAction = useCallback37(() => {
|
|
8621
8589
|
if (!editor) return false;
|
|
8622
8590
|
const success = executeUndoRedoAction(editor, action);
|
|
8623
8591
|
if (success) {
|
|
@@ -8655,7 +8623,7 @@ var UndoRedoButton = ({
|
|
|
8655
8623
|
hideWhenUnavailable,
|
|
8656
8624
|
onExecuted
|
|
8657
8625
|
});
|
|
8658
|
-
const handleClick =
|
|
8626
|
+
const handleClick = useCallback38(
|
|
8659
8627
|
(event) => {
|
|
8660
8628
|
onClick == null ? void 0 : onClick(event);
|
|
8661
8629
|
if (event.defaultPrevented) return;
|
|
@@ -8882,7 +8850,7 @@ var BasicEditor = ({
|
|
|
8882
8850
|
...options
|
|
8883
8851
|
});
|
|
8884
8852
|
const styles = editorBasic({ variant, bordered });
|
|
8885
|
-
const resolveVariable =
|
|
8853
|
+
const resolveVariable = useCallback39(
|
|
8886
8854
|
(name) => variableValues == null ? void 0 : variableValues[name],
|
|
8887
8855
|
[variableValues]
|
|
8888
8856
|
);
|
|
@@ -8919,7 +8887,7 @@ var EditorContentArea = ({
|
|
|
8919
8887
|
const { editor } = useContext4(EditorContext);
|
|
8920
8888
|
const { isDragging } = useUiEditorState(editor);
|
|
8921
8889
|
useScrollToHash();
|
|
8922
|
-
const handleKeyDown =
|
|
8890
|
+
const handleKeyDown = useCallback39(
|
|
8923
8891
|
(e) => {
|
|
8924
8892
|
if (!(editor == null ? void 0 : editor.isFocused)) return;
|
|
8925
8893
|
const isMod = e.metaKey || e.ctrlKey;
|