tiptap-markdown-react 0.14.5 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/THIRD_PARTY_LICENSES.md +2 -0
- package/dist/{ReportContent-DxldXfpO.js → ReportContent-JC-DkC9D.js} +9 -7
- package/dist/{ReportContent-DxldXfpO.js.map → ReportContent-JC-DkC9D.js.map} +1 -1
- package/dist/components/MarkdownWysiwygEditor.d.ts +16 -1
- package/dist/{extractToc-C2zqDjSP.js → extractToc-FJquRnX7.js} +2 -2
- package/dist/{extractToc-C2zqDjSP.js.map → extractToc-FJquRnX7.js.map} +1 -1
- package/dist/icons/index.d.ts +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +600 -42
- package/dist/index.js.map +1 -1
- package/dist/labels.d.ts +57 -0
- package/dist/reader.js +2 -2
- package/dist/{scrollToTocHeading-DKL19FQG.js → scrollToTocHeading-DTphNbqx.js} +2 -2
- package/dist/{scrollToTocHeading-DKL19FQG.js.map → scrollToTocHeading-DTphNbqx.js.map} +1 -1
- package/dist/server.js +4 -4
- package/dist/shortcuts/ShortcutPanel.d.ts +13 -0
- package/dist/shortcuts/shortcutPanel.test.d.ts +1 -0
- package/dist/shortcuts/types.d.ts +32 -0
- package/dist/slashMenu/SlashMenuExtension.d.ts +21 -0
- package/dist/slashMenu/SlashMenuPopup.d.ts +18 -0
- package/dist/slashMenu/insertSlashMarkdown.d.ts +8 -0
- package/dist/slashMenu/items.d.ts +12 -0
- package/dist/slashMenu/slashMenu.test.d.ts +1 -0
- package/dist/slashMenu/slashMenuTyping.test.d.ts +1 -0
- package/dist/slashMenu/types.d.ts +33 -0
- package/dist/style.css +353 -52
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Markdown, MarkdownManager } from "@tiptap/markdown";
|
|
3
|
-
import { c as renderOrUpdateChart, d as destroyChart } from "./scrollToTocHeading-
|
|
4
|
-
import { C, a, R, b, f, m, r, s } from "./scrollToTocHeading-
|
|
5
|
-
import { jsx, jsxs, Fragment as Fragment$
|
|
3
|
+
import { c as renderOrUpdateChart, d as destroyChart } from "./scrollToTocHeading-DTphNbqx.js";
|
|
4
|
+
import { C, a, R, b, f, m, r, s } from "./scrollToTocHeading-DTphNbqx.js";
|
|
5
|
+
import { jsx, jsxs, Fragment as Fragment$2 } from "react/jsx-runtime";
|
|
6
6
|
import CodeBlockLowlight from "@tiptap/extension-code-block-lowlight";
|
|
7
7
|
import FindAndReplace, { FindAndReplacePluginKey, createSearchRegex } from "@tiptap/extension-find-and-replace";
|
|
8
8
|
import { default as default2 } from "@tiptap/extension-find-and-replace";
|
|
9
9
|
import Image from "@tiptap/extension-image";
|
|
10
10
|
import { TableOfContents } from "@tiptap/extension-table-of-contents";
|
|
11
|
-
import { NodeViewWrapper, ReactNodeViewRenderer, useEditorState, NodeViewContent, useEditor, EditorContent } from "@tiptap/react";
|
|
11
|
+
import { NodeViewWrapper, ReactNodeViewRenderer, useEditorState, ReactRenderer, NodeViewContent, useEditor, EditorContent } from "@tiptap/react";
|
|
12
12
|
import { createPortal } from "react-dom";
|
|
13
|
-
import { useState, useEffect, useCallback, useRef, useMemo, forwardRef, useImperativeHandle, useId, useContext, createContext } from "react";
|
|
14
|
-
import { e as enrichMarkdownCitations, c as styles$
|
|
15
|
-
import { R as R2, a as a2, b as b2, s as s2 } from "./ReportContent-
|
|
16
|
-
import { C as CitationRef, i as mergeCommentIntervals, h as mapCommentAnchors, p as prepareChartMarkdown, j as reportChart, b as baseExtensions, f as CommentMark, l as lowlight, m as makeTocGetId, k as parseCodeTokenAsChartOrCodeBlock, a as pureCodeBlock, c as pureImage, n as renderMathInto, o as subscribeMathClick, d as pureChart } from "./extractToc-
|
|
17
|
-
import { g, e, s as s3 } from "./extractToc-
|
|
13
|
+
import { useState, useEffect, useCallback, useRef, useMemo, forwardRef, useImperativeHandle, Fragment as Fragment$1, useId, useContext, createContext } from "react";
|
|
14
|
+
import { e as enrichMarkdownCitations, c as styles$8 } from "./ReportContent-JC-DkC9D.js";
|
|
15
|
+
import { R as R2, a as a2, b as b2, s as s2 } from "./ReportContent-JC-DkC9D.js";
|
|
16
|
+
import { C as CitationRef, i as mergeCommentIntervals, h as mapCommentAnchors, p as prepareChartMarkdown, j as reportChart, b as baseExtensions, f as CommentMark, l as lowlight, m as makeTocGetId, k as parseCodeTokenAsChartOrCodeBlock, a as pureCodeBlock, c as pureImage, n as renderMathInto, o as subscribeMathClick, d as pureChart } from "./extractToc-FJquRnX7.js";
|
|
17
|
+
import { g, e, s as s3 } from "./extractToc-FJquRnX7.js";
|
|
18
18
|
import { Slice, Fragment } from "@tiptap/pm/model";
|
|
19
19
|
import { Extension, Node as Node$1 } from "@tiptap/core";
|
|
20
20
|
import { PluginKey, Plugin, NodeSelection, TextSelection } from "@tiptap/pm/state";
|
|
21
21
|
import { DecorationSet, Decoration } from "@tiptap/pm/view";
|
|
22
|
+
import Suggestion from "@tiptap/suggestion";
|
|
22
23
|
import { FileHandlePlugin } from "@tiptap/extension-file-handler";
|
|
23
24
|
import { skipTrailingNodeMeta } from "@tiptap/extensions";
|
|
24
25
|
import { CellSelection, isInTable, selectedRect, rowIsHeader } from "@tiptap/pm/tables";
|
|
@@ -533,6 +534,18 @@ const ChevronsUpDownIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
|
533
534
|
/* @__PURE__ */ jsx("path", { d: "m7 15 5 5 5-5" }),
|
|
534
535
|
/* @__PURE__ */ jsx("path", { d: "m7 9 5-5 5 5" })
|
|
535
536
|
] });
|
|
537
|
+
const KeyboardIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
538
|
+
/* @__PURE__ */ jsx("rect", { width: "20", height: "16", x: "2", y: "4", rx: "2" }),
|
|
539
|
+
/* @__PURE__ */ jsx("path", { d: "M6 8h.01" }),
|
|
540
|
+
/* @__PURE__ */ jsx("path", { d: "M10 8h.01" }),
|
|
541
|
+
/* @__PURE__ */ jsx("path", { d: "M14 8h.01" }),
|
|
542
|
+
/* @__PURE__ */ jsx("path", { d: "M18 8h.01" }),
|
|
543
|
+
/* @__PURE__ */ jsx("path", { d: "M6 12h.01" }),
|
|
544
|
+
/* @__PURE__ */ jsx("path", { d: "M10 12h.01" }),
|
|
545
|
+
/* @__PURE__ */ jsx("path", { d: "M14 12h.01" }),
|
|
546
|
+
/* @__PURE__ */ jsx("path", { d: "M18 12h.01" }),
|
|
547
|
+
/* @__PURE__ */ jsx("path", { d: "M7 16h10" })
|
|
548
|
+
] });
|
|
536
549
|
const defaultChartLabels = {
|
|
537
550
|
tabLabel: (chartType, index) => `${chartType} ${index + 1}`,
|
|
538
551
|
done: "Done",
|
|
@@ -605,6 +618,51 @@ const defaultToolbarLabels = {
|
|
|
605
618
|
mathNewInline: "New equation",
|
|
606
619
|
mathNewBlock: "Add a TeX equation"
|
|
607
620
|
};
|
|
621
|
+
const defaultSlashMenuLabels = {
|
|
622
|
+
menuLabel: "Insert block",
|
|
623
|
+
groupText: "Text",
|
|
624
|
+
groupList: "Lists",
|
|
625
|
+
groupAdvanced: "Advanced",
|
|
626
|
+
normalText: "Normal text",
|
|
627
|
+
headingLabel: (level) => `Heading ${level}`,
|
|
628
|
+
bulletList: "Bullet list",
|
|
629
|
+
orderedList: "Ordered list",
|
|
630
|
+
taskList: "Task list",
|
|
631
|
+
blockquote: "Blockquote",
|
|
632
|
+
codeBlock: "Code block",
|
|
633
|
+
divider: "Divider",
|
|
634
|
+
table: "Table",
|
|
635
|
+
inlineMath: "Inline equation",
|
|
636
|
+
blockMath: "Block equation"
|
|
637
|
+
};
|
|
638
|
+
const defaultShortcutLabels = {
|
|
639
|
+
panelTitle: "Shortcuts",
|
|
640
|
+
close: "Close",
|
|
641
|
+
colFormat: "Format",
|
|
642
|
+
colShortcut: "Shortcut",
|
|
643
|
+
colMarkdown: "Markdown",
|
|
644
|
+
formatGroup: "Formatting",
|
|
645
|
+
insertGroup: "Insert",
|
|
646
|
+
editGroup: "Editing",
|
|
647
|
+
bold: "Bold",
|
|
648
|
+
italic: "Italic",
|
|
649
|
+
strike: "Strikethrough",
|
|
650
|
+
underline: "Underline",
|
|
651
|
+
inlineCode: "Inline code",
|
|
652
|
+
highlight: "Highlight",
|
|
653
|
+
headingLabel: (level) => `Heading ${level}`,
|
|
654
|
+
paragraph: "Normal text",
|
|
655
|
+
blockquote: "Blockquote",
|
|
656
|
+
bulletList: "Bullet list",
|
|
657
|
+
orderedList: "Ordered list",
|
|
658
|
+
taskList: "Task list",
|
|
659
|
+
codeBlock: "Code block",
|
|
660
|
+
divider: "Divider",
|
|
661
|
+
undo: "Undo",
|
|
662
|
+
redo: "Redo",
|
|
663
|
+
hardBreak: "Hard break",
|
|
664
|
+
findReplace: "Find & replace"
|
|
665
|
+
};
|
|
608
666
|
const defaultColorPaletteLabels = {
|
|
609
667
|
none: "None",
|
|
610
668
|
theme: "THEME"
|
|
@@ -646,7 +704,7 @@ const defaultFindLabels = {
|
|
|
646
704
|
readOnly: "Read-only"
|
|
647
705
|
};
|
|
648
706
|
const bar = "_bar_1h61e_3";
|
|
649
|
-
const row = "_row_1h61e_25";
|
|
707
|
+
const row$1 = "_row_1h61e_25";
|
|
650
708
|
const field = "_field_1h61e_43";
|
|
651
709
|
const fieldIcon = "_fieldIcon_1h61e_62";
|
|
652
710
|
const input = "_input_1h61e_67";
|
|
@@ -658,9 +716,9 @@ const toggleOn = "_toggleOn_1h61e_135";
|
|
|
658
716
|
const iconGroup = "_iconGroup_1h61e_29";
|
|
659
717
|
const spacer = "_spacer_1h61e_150";
|
|
660
718
|
const readOnly = "_readOnly_1h61e_155";
|
|
661
|
-
const styles$
|
|
719
|
+
const styles$7 = {
|
|
662
720
|
bar,
|
|
663
|
-
row,
|
|
721
|
+
row: row$1,
|
|
664
722
|
field,
|
|
665
723
|
fieldIcon,
|
|
666
724
|
input,
|
|
@@ -778,11 +836,11 @@ function FindReplaceBar({
|
|
|
778
836
|
});
|
|
779
837
|
};
|
|
780
838
|
if (!hasExtension) return null;
|
|
781
|
-
const toggleClass = (on) => `${styles$
|
|
839
|
+
const toggleClass = (on) => `${styles$7.btn} ${styles$7.toggle}${on ? ` ${styles$7.toggleOn}` : ""}`;
|
|
782
840
|
return /* @__PURE__ */ jsxs(
|
|
783
841
|
"div",
|
|
784
842
|
{
|
|
785
|
-
className: className ? `${styles$
|
|
843
|
+
className: className ? `${styles$7.bar} ${className}` : styles$7.bar,
|
|
786
844
|
style,
|
|
787
845
|
role: "dialog",
|
|
788
846
|
"aria-label": t.find,
|
|
@@ -793,14 +851,14 @@ function FindReplaceBar({
|
|
|
793
851
|
}
|
|
794
852
|
},
|
|
795
853
|
children: [
|
|
796
|
-
/* @__PURE__ */ jsxs("div", { className: styles$
|
|
797
|
-
/* @__PURE__ */ jsxs("span", { className: styles$
|
|
798
|
-
/* @__PURE__ */ jsx(SearchIcon, { size: 14, className: styles$
|
|
854
|
+
/* @__PURE__ */ jsxs("div", { className: styles$7.row, children: [
|
|
855
|
+
/* @__PURE__ */ jsxs("span", { className: styles$7.field, children: [
|
|
856
|
+
/* @__PURE__ */ jsx(SearchIcon, { size: 14, className: styles$7.fieldIcon }),
|
|
799
857
|
/* @__PURE__ */ jsx(
|
|
800
858
|
"input",
|
|
801
859
|
{
|
|
802
860
|
ref: inputRef,
|
|
803
|
-
className: styles$
|
|
861
|
+
className: styles$7.input,
|
|
804
862
|
value: term,
|
|
805
863
|
onChange: (e2) => setTerm(e2.target.value),
|
|
806
864
|
onKeyDown: onFindKeyDown,
|
|
@@ -813,7 +871,7 @@ function FindReplaceBar({
|
|
|
813
871
|
/* @__PURE__ */ jsx(
|
|
814
872
|
"span",
|
|
815
873
|
{
|
|
816
|
-
className: `${styles$
|
|
874
|
+
className: `${styles$7.counter}${invalidPattern ? ` ${styles$7.counterInvalid}` : ""}`,
|
|
817
875
|
"aria-live": "polite",
|
|
818
876
|
title: invalidPattern ? t.invalidRegex : void 0,
|
|
819
877
|
children: invalidPattern ? t.invalidRegex : counter2
|
|
@@ -846,13 +904,13 @@ function FindReplaceBar({
|
|
|
846
904
|
children: "ab"
|
|
847
905
|
}
|
|
848
906
|
),
|
|
849
|
-
/* @__PURE__ */ jsx("span", { className: styles$
|
|
850
|
-
/* @__PURE__ */ jsxs("span", { className: styles$
|
|
907
|
+
/* @__PURE__ */ jsx("span", { className: styles$7.spacer }),
|
|
908
|
+
/* @__PURE__ */ jsxs("span", { className: styles$7.iconGroup, children: [
|
|
851
909
|
/* @__PURE__ */ jsx(
|
|
852
910
|
"button",
|
|
853
911
|
{
|
|
854
912
|
type: "button",
|
|
855
|
-
className: styles$
|
|
913
|
+
className: styles$7.btn,
|
|
856
914
|
title: t.previous,
|
|
857
915
|
"aria-label": t.previous,
|
|
858
916
|
disabled: state.total === 0,
|
|
@@ -865,7 +923,7 @@ function FindReplaceBar({
|
|
|
865
923
|
"button",
|
|
866
924
|
{
|
|
867
925
|
type: "button",
|
|
868
|
-
className: styles$
|
|
926
|
+
className: styles$7.btn,
|
|
869
927
|
title: t.next,
|
|
870
928
|
"aria-label": t.next,
|
|
871
929
|
disabled: state.total === 0,
|
|
@@ -878,7 +936,7 @@ function FindReplaceBar({
|
|
|
878
936
|
"button",
|
|
879
937
|
{
|
|
880
938
|
type: "button",
|
|
881
|
-
className: styles$
|
|
939
|
+
className: styles$7.btn,
|
|
882
940
|
title: t.close,
|
|
883
941
|
"aria-label": t.close,
|
|
884
942
|
onClick: onClose,
|
|
@@ -887,11 +945,11 @@ function FindReplaceBar({
|
|
|
887
945
|
)
|
|
888
946
|
] })
|
|
889
947
|
] }),
|
|
890
|
-
editor.isEditable ? /* @__PURE__ */ jsxs("div", { className: styles$
|
|
891
|
-
/* @__PURE__ */ jsx("span", { className: styles$
|
|
948
|
+
editor.isEditable ? /* @__PURE__ */ jsxs("div", { className: styles$7.row, children: [
|
|
949
|
+
/* @__PURE__ */ jsx("span", { className: styles$7.field, children: /* @__PURE__ */ jsx(
|
|
892
950
|
"input",
|
|
893
951
|
{
|
|
894
|
-
className: styles$
|
|
952
|
+
className: styles$7.input,
|
|
895
953
|
value: replaceTerm,
|
|
896
954
|
onChange: (e2) => setReplaceTerm(e2.target.value),
|
|
897
955
|
onKeyDown: onReplaceKeyDown,
|
|
@@ -900,12 +958,12 @@ function FindReplaceBar({
|
|
|
900
958
|
spellCheck: false
|
|
901
959
|
}
|
|
902
960
|
) }),
|
|
903
|
-
/* @__PURE__ */ jsx("span", { className: styles$
|
|
961
|
+
/* @__PURE__ */ jsx("span", { className: styles$7.spacer }),
|
|
904
962
|
/* @__PURE__ */ jsx(
|
|
905
963
|
"button",
|
|
906
964
|
{
|
|
907
965
|
type: "button",
|
|
908
|
-
className: styles$
|
|
966
|
+
className: styles$7.btn,
|
|
909
967
|
title: t.replaceOne,
|
|
910
968
|
"aria-label": t.replaceOne,
|
|
911
969
|
disabled: state.total === 0,
|
|
@@ -918,7 +976,7 @@ function FindReplaceBar({
|
|
|
918
976
|
"button",
|
|
919
977
|
{
|
|
920
978
|
type: "button",
|
|
921
|
-
className: styles$
|
|
979
|
+
className: styles$7.btn,
|
|
922
980
|
title: t.replaceAll,
|
|
923
981
|
"aria-label": t.replaceAll,
|
|
924
982
|
disabled: state.total === 0,
|
|
@@ -927,7 +985,7 @@ function FindReplaceBar({
|
|
|
927
985
|
children: /* @__PURE__ */ jsx(ReplaceAllIcon, { size: 16 })
|
|
928
986
|
}
|
|
929
987
|
)
|
|
930
|
-
] }) : /* @__PURE__ */ jsx("div", { className: styles$
|
|
988
|
+
] }) : /* @__PURE__ */ jsx("div", { className: styles$7.row, children: /* @__PURE__ */ jsx("span", { className: styles$7.readOnly, children: t.readOnly }) })
|
|
931
989
|
]
|
|
932
990
|
}
|
|
933
991
|
);
|
|
@@ -1014,6 +1072,455 @@ const ImportPlaceholder = Node$1.create({
|
|
|
1014
1072
|
};
|
|
1015
1073
|
}
|
|
1016
1074
|
});
|
|
1075
|
+
const popupHost = "_popupHost_1noza_11";
|
|
1076
|
+
const menu$1 = "_menu_1noza_1";
|
|
1077
|
+
const groupLabel = "_groupLabel_1noza_43";
|
|
1078
|
+
const item$1 = "_item_1noza_53";
|
|
1079
|
+
const itemActive = "_itemActive_1noza_54";
|
|
1080
|
+
const itemIcon = "_itemIcon_1noza_79";
|
|
1081
|
+
const itemTitle = "_itemTitle_1noza_102";
|
|
1082
|
+
const styles$6 = {
|
|
1083
|
+
popupHost,
|
|
1084
|
+
menu: menu$1,
|
|
1085
|
+
groupLabel,
|
|
1086
|
+
item: item$1,
|
|
1087
|
+
itemActive,
|
|
1088
|
+
itemIcon,
|
|
1089
|
+
itemTitle
|
|
1090
|
+
};
|
|
1091
|
+
function createDefaultSlashMenuItems(labels = defaultSlashMenuLabels) {
|
|
1092
|
+
return [
|
|
1093
|
+
{
|
|
1094
|
+
id: "normal-text",
|
|
1095
|
+
title: labels.normalText,
|
|
1096
|
+
group: labels.groupText,
|
|
1097
|
+
icon: "¶",
|
|
1098
|
+
aliases: ["zhengwen", "正文", "paragraph", "text"],
|
|
1099
|
+
order: 0,
|
|
1100
|
+
apply: (editor, range) => {
|
|
1101
|
+
editor.chain().focus().deleteRange(range).setParagraph().run();
|
|
1102
|
+
}
|
|
1103
|
+
},
|
|
1104
|
+
...[1, 2, 3].map((level) => ({
|
|
1105
|
+
id: `heading-${level}`,
|
|
1106
|
+
title: labels.headingLabel(level),
|
|
1107
|
+
group: labels.groupText,
|
|
1108
|
+
icon: `H${level}`,
|
|
1109
|
+
aliases: [`h${level}`, "biaoti", "标题", "heading"],
|
|
1110
|
+
order: level,
|
|
1111
|
+
apply: (editor, range) => {
|
|
1112
|
+
editor.chain().focus().deleteRange(range).setHeading({ level }).run();
|
|
1113
|
+
}
|
|
1114
|
+
})),
|
|
1115
|
+
{
|
|
1116
|
+
id: "bullet-list",
|
|
1117
|
+
title: labels.bulletList,
|
|
1118
|
+
group: labels.groupList,
|
|
1119
|
+
icon: "•",
|
|
1120
|
+
aliases: ["wuxu", "无序", "列表", "bullet", "ul"],
|
|
1121
|
+
order: 4,
|
|
1122
|
+
apply: (editor, range) => {
|
|
1123
|
+
editor.chain().focus().deleteRange(range).toggleBulletList().run();
|
|
1124
|
+
}
|
|
1125
|
+
},
|
|
1126
|
+
{
|
|
1127
|
+
id: "ordered-list",
|
|
1128
|
+
title: labels.orderedList,
|
|
1129
|
+
group: labels.groupList,
|
|
1130
|
+
icon: "1.",
|
|
1131
|
+
aliases: ["youxu", "有序", "列表", "ordered", "ol"],
|
|
1132
|
+
order: 5,
|
|
1133
|
+
apply: (editor, range) => {
|
|
1134
|
+
editor.chain().focus().deleteRange(range).toggleOrderedList().run();
|
|
1135
|
+
}
|
|
1136
|
+
},
|
|
1137
|
+
{
|
|
1138
|
+
id: "task-list",
|
|
1139
|
+
title: labels.taskList,
|
|
1140
|
+
group: labels.groupList,
|
|
1141
|
+
icon: "✓",
|
|
1142
|
+
aliases: ["renwu", "任务", "待办", "task", "todo", "checklist"],
|
|
1143
|
+
order: 6,
|
|
1144
|
+
apply: (editor, range) => {
|
|
1145
|
+
editor.chain().focus().deleteRange(range).toggleTaskList().run();
|
|
1146
|
+
}
|
|
1147
|
+
},
|
|
1148
|
+
{
|
|
1149
|
+
id: "blockquote",
|
|
1150
|
+
title: labels.blockquote,
|
|
1151
|
+
group: labels.groupAdvanced,
|
|
1152
|
+
icon: "❝",
|
|
1153
|
+
aliases: ["yinyong", "引用", "quote", "blockquote"],
|
|
1154
|
+
order: 7,
|
|
1155
|
+
apply: (editor, range) => {
|
|
1156
|
+
editor.chain().focus().deleteRange(range).toggleBlockquote().run();
|
|
1157
|
+
}
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
id: "code-block",
|
|
1161
|
+
title: labels.codeBlock,
|
|
1162
|
+
group: labels.groupAdvanced,
|
|
1163
|
+
icon: "{ }",
|
|
1164
|
+
aliases: ["daima", "代码", "code", "fence"],
|
|
1165
|
+
order: 8,
|
|
1166
|
+
apply: (editor, range) => {
|
|
1167
|
+
editor.chain().focus().deleteRange(range).toggleCodeBlock().run();
|
|
1168
|
+
}
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
id: "divider",
|
|
1172
|
+
title: labels.divider,
|
|
1173
|
+
group: labels.groupAdvanced,
|
|
1174
|
+
icon: "—",
|
|
1175
|
+
aliases: ["fenge", "分割线", "分隔线", "hr", "divider"],
|
|
1176
|
+
order: 9,
|
|
1177
|
+
apply: (editor, range) => {
|
|
1178
|
+
editor.chain().focus().deleteRange(range).setHorizontalRule().run();
|
|
1179
|
+
}
|
|
1180
|
+
},
|
|
1181
|
+
{
|
|
1182
|
+
id: "table",
|
|
1183
|
+
title: labels.table,
|
|
1184
|
+
group: labels.groupAdvanced,
|
|
1185
|
+
icon: "▦",
|
|
1186
|
+
aliases: ["biaoge", "表格", "table"],
|
|
1187
|
+
order: 10,
|
|
1188
|
+
apply: (editor, range) => {
|
|
1189
|
+
editor.chain().focus().deleteRange(range).insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run();
|
|
1190
|
+
}
|
|
1191
|
+
},
|
|
1192
|
+
{
|
|
1193
|
+
id: "inline-math",
|
|
1194
|
+
title: labels.inlineMath,
|
|
1195
|
+
group: labels.groupAdvanced,
|
|
1196
|
+
icon: "√x",
|
|
1197
|
+
aliases: ["gongshi", "公式", "行内公式", "math", "latex"],
|
|
1198
|
+
order: 11,
|
|
1199
|
+
apply: (editor, range) => {
|
|
1200
|
+
editor.chain().focus().deleteRange(range).insertContent({ type: "inlineMath", attrs: { latex: "E=mc^2" } }).run();
|
|
1201
|
+
}
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
id: "block-math",
|
|
1205
|
+
title: labels.blockMath,
|
|
1206
|
+
group: labels.groupAdvanced,
|
|
1207
|
+
icon: "∑",
|
|
1208
|
+
aliases: ["gongshi", "公式", "块级公式", "mathblock", "latex"],
|
|
1209
|
+
order: 12,
|
|
1210
|
+
apply: (editor, range) => {
|
|
1211
|
+
editor.chain().focus().deleteRange(range).insertContent({ type: "blockMath", attrs: { latex: "E=mc^2" } }).run();
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
];
|
|
1215
|
+
}
|
|
1216
|
+
function filterSlashItems(items, query) {
|
|
1217
|
+
const q = query.trim().toLowerCase();
|
|
1218
|
+
if (!q) return items;
|
|
1219
|
+
return items.filter(
|
|
1220
|
+
(item2) => {
|
|
1221
|
+
var _a;
|
|
1222
|
+
return item2.title.toLowerCase().includes(q) || ((_a = item2.aliases) == null ? void 0 : _a.some((alias) => alias.toLowerCase().includes(q)));
|
|
1223
|
+
}
|
|
1224
|
+
);
|
|
1225
|
+
}
|
|
1226
|
+
function withGroupHeaders(items) {
|
|
1227
|
+
const rows = [];
|
|
1228
|
+
let lastGroup;
|
|
1229
|
+
for (const item2 of items) {
|
|
1230
|
+
if (item2.group && item2.group !== lastGroup) {
|
|
1231
|
+
rows.push([item2.group, item2]);
|
|
1232
|
+
lastGroup = item2.group;
|
|
1233
|
+
} else {
|
|
1234
|
+
if (!item2.group) lastGroup = void 0;
|
|
1235
|
+
rows.push([null, item2]);
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
return rows;
|
|
1239
|
+
}
|
|
1240
|
+
const SlashMenuPopup = forwardRef(function SlashMenuPopup2({ items, query, menuLabel, command }, ref) {
|
|
1241
|
+
const [index, setIndex] = useState(0);
|
|
1242
|
+
useEffect(() => {
|
|
1243
|
+
setIndex(0);
|
|
1244
|
+
}, [query]);
|
|
1245
|
+
useImperativeHandle(
|
|
1246
|
+
ref,
|
|
1247
|
+
() => ({
|
|
1248
|
+
onKeyDown(event) {
|
|
1249
|
+
if (!items.length) return false;
|
|
1250
|
+
if (event.key === "ArrowDown" || event.key === "Tab" && !event.shiftKey) {
|
|
1251
|
+
setIndex((i) => (i + 1) % items.length);
|
|
1252
|
+
return true;
|
|
1253
|
+
}
|
|
1254
|
+
if (event.key === "ArrowUp" || event.key === "Tab" && event.shiftKey) {
|
|
1255
|
+
setIndex((i) => (i - 1 + items.length) % items.length);
|
|
1256
|
+
return true;
|
|
1257
|
+
}
|
|
1258
|
+
if (event.key === "Enter") {
|
|
1259
|
+
const item2 = items[index];
|
|
1260
|
+
if (!item2) return false;
|
|
1261
|
+
command(item2);
|
|
1262
|
+
return true;
|
|
1263
|
+
}
|
|
1264
|
+
return false;
|
|
1265
|
+
}
|
|
1266
|
+
}),
|
|
1267
|
+
[items, index, command]
|
|
1268
|
+
);
|
|
1269
|
+
if (!items.length) return null;
|
|
1270
|
+
let optionIndex = -1;
|
|
1271
|
+
return /* @__PURE__ */ jsx("div", { className: styles$6.menu, role: "listbox", "aria-label": menuLabel, children: withGroupHeaders(items).map(([header2, item2]) => {
|
|
1272
|
+
optionIndex += 1;
|
|
1273
|
+
const i = optionIndex;
|
|
1274
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1275
|
+
header2 !== null ? /* @__PURE__ */ jsx("div", { className: styles$6.groupLabel, "aria-hidden": "true", children: header2 }) : null,
|
|
1276
|
+
/* @__PURE__ */ jsxs(
|
|
1277
|
+
"button",
|
|
1278
|
+
{
|
|
1279
|
+
type: "button",
|
|
1280
|
+
role: "option",
|
|
1281
|
+
"aria-selected": i === index,
|
|
1282
|
+
title: item2.title,
|
|
1283
|
+
className: i === index ? styles$6.itemActive : styles$6.item,
|
|
1284
|
+
tabIndex: -1,
|
|
1285
|
+
onMouseEnter: () => setIndex(i),
|
|
1286
|
+
onMouseDown: (e2) => {
|
|
1287
|
+
e2.preventDefault();
|
|
1288
|
+
command(item2);
|
|
1289
|
+
},
|
|
1290
|
+
children: [
|
|
1291
|
+
item2.icon != null ? /* @__PURE__ */ jsx("span", { className: styles$6.itemIcon, "aria-hidden": "true", children: item2.icon }) : /* @__PURE__ */ jsx("span", { className: styles$6.itemIcon, "aria-hidden": "true" }),
|
|
1292
|
+
/* @__PURE__ */ jsx("span", { className: styles$6.itemTitle, children: item2.title })
|
|
1293
|
+
]
|
|
1294
|
+
}
|
|
1295
|
+
)
|
|
1296
|
+
] }, item2.id);
|
|
1297
|
+
}) });
|
|
1298
|
+
});
|
|
1299
|
+
function isComposing(event, view) {
|
|
1300
|
+
return view.composing || event.isComposing || event.keyCode === 229;
|
|
1301
|
+
}
|
|
1302
|
+
const SlashMenu = Extension.create({
|
|
1303
|
+
name: "slashMenu",
|
|
1304
|
+
addOptions() {
|
|
1305
|
+
return { items: void 0, labels: void 0 };
|
|
1306
|
+
},
|
|
1307
|
+
addProseMirrorPlugins() {
|
|
1308
|
+
const { items: extraItems, labels } = this.options;
|
|
1309
|
+
const allItems = [
|
|
1310
|
+
...createDefaultSlashMenuItems({ ...defaultSlashMenuLabels, ...labels }),
|
|
1311
|
+
...extraItems ?? []
|
|
1312
|
+
];
|
|
1313
|
+
let renderer = null;
|
|
1314
|
+
let unmountPopup = null;
|
|
1315
|
+
return [
|
|
1316
|
+
Suggestion({
|
|
1317
|
+
editor: this.editor,
|
|
1318
|
+
pluginKey: new PluginKey("tmrSlashMenu"),
|
|
1319
|
+
char: "/",
|
|
1320
|
+
// 行首(节点内起始,空 prefix 天然放行)或空白后触发
|
|
1321
|
+
allowedPrefixes: [" ", " ", " "],
|
|
1322
|
+
allowSpaces: false,
|
|
1323
|
+
decorationClass: "tmr-slash-suggestion",
|
|
1324
|
+
decorationEmptyClass: "tmr-slash-suggestion-empty",
|
|
1325
|
+
items: ({ query }) => filterSlashItems(allItems, query),
|
|
1326
|
+
command: ({ editor, range, props: item2 }) => {
|
|
1327
|
+
item2.apply(editor, range);
|
|
1328
|
+
},
|
|
1329
|
+
allow: ({ editor }) => editor.isEditable && !editor.isActive("codeBlock"),
|
|
1330
|
+
render: () => ({
|
|
1331
|
+
onStart: (props) => {
|
|
1332
|
+
var _a;
|
|
1333
|
+
renderer = new ReactRenderer(
|
|
1334
|
+
SlashMenuPopup,
|
|
1335
|
+
{
|
|
1336
|
+
editor: props.editor,
|
|
1337
|
+
props: {
|
|
1338
|
+
items: props.items,
|
|
1339
|
+
query: props.query,
|
|
1340
|
+
menuLabel: ((_a = this.options.labels) == null ? void 0 : _a.menuLabel) ?? defaultSlashMenuLabels.menuLabel,
|
|
1341
|
+
command: props.command
|
|
1342
|
+
},
|
|
1343
|
+
className: styles$6.popupHost
|
|
1344
|
+
}
|
|
1345
|
+
);
|
|
1346
|
+
const pmStyle = getComputedStyle(props.editor.view.dom);
|
|
1347
|
+
for (const name of [
|
|
1348
|
+
"--tmr-text",
|
|
1349
|
+
"--tmr-accent",
|
|
1350
|
+
"--tmr-toolbar-border",
|
|
1351
|
+
"--tmr-toolbar-muted"
|
|
1352
|
+
]) {
|
|
1353
|
+
const value = pmStyle.getPropertyValue(name);
|
|
1354
|
+
if (value) renderer.element.style.setProperty(name, value);
|
|
1355
|
+
}
|
|
1356
|
+
unmountPopup = props.mount(renderer.element);
|
|
1357
|
+
},
|
|
1358
|
+
onUpdate: (props) => {
|
|
1359
|
+
renderer == null ? void 0 : renderer.updateProps({
|
|
1360
|
+
items: props.items,
|
|
1361
|
+
query: props.query,
|
|
1362
|
+
command: props.command
|
|
1363
|
+
});
|
|
1364
|
+
},
|
|
1365
|
+
onKeyDown: (props) => {
|
|
1366
|
+
var _a;
|
|
1367
|
+
if (!renderer || isComposing(props.event, props.view)) return false;
|
|
1368
|
+
return ((_a = renderer.ref) == null ? void 0 : _a.onKeyDown(props.event)) ?? false;
|
|
1369
|
+
},
|
|
1370
|
+
onExit: () => {
|
|
1371
|
+
unmountPopup == null ? void 0 : unmountPopup();
|
|
1372
|
+
unmountPopup = null;
|
|
1373
|
+
renderer == null ? void 0 : renderer.destroy();
|
|
1374
|
+
renderer = null;
|
|
1375
|
+
}
|
|
1376
|
+
})
|
|
1377
|
+
})
|
|
1378
|
+
];
|
|
1379
|
+
}
|
|
1380
|
+
});
|
|
1381
|
+
const drawer = "_drawer_ljnq6_5";
|
|
1382
|
+
const closeBtn = "_closeBtn_ljnq6_44";
|
|
1383
|
+
const head = "_head_ljnq6_68";
|
|
1384
|
+
const colShortcut = "_colShortcut_ljnq6_79";
|
|
1385
|
+
const colMarkdown = "_colMarkdown_ljnq6_83";
|
|
1386
|
+
const body = "_body_ljnq6_88";
|
|
1387
|
+
const group = "_group_ljnq6_95";
|
|
1388
|
+
const groupTitle = "_groupTitle_ljnq6_99";
|
|
1389
|
+
const row = "_row_ljnq6_107";
|
|
1390
|
+
const rowLabel = "_rowLabel_ljnq6_120";
|
|
1391
|
+
const rowKeys = "_rowKeys_ljnq6_127";
|
|
1392
|
+
const rowMd = "_rowMd_ljnq6_128";
|
|
1393
|
+
const keycap = "_keycap_ljnq6_138";
|
|
1394
|
+
const none = "_none_ljnq6_163";
|
|
1395
|
+
const styles$5 = {
|
|
1396
|
+
drawer,
|
|
1397
|
+
closeBtn,
|
|
1398
|
+
head,
|
|
1399
|
+
colShortcut,
|
|
1400
|
+
colMarkdown,
|
|
1401
|
+
body,
|
|
1402
|
+
group,
|
|
1403
|
+
groupTitle,
|
|
1404
|
+
row,
|
|
1405
|
+
rowLabel,
|
|
1406
|
+
rowKeys,
|
|
1407
|
+
rowMd,
|
|
1408
|
+
keycap,
|
|
1409
|
+
none
|
|
1410
|
+
};
|
|
1411
|
+
function buildShortcutGroups(labels) {
|
|
1412
|
+
return [
|
|
1413
|
+
{
|
|
1414
|
+
id: "format",
|
|
1415
|
+
title: labels.formatGroup,
|
|
1416
|
+
entries: [
|
|
1417
|
+
{ id: "bold", label: labels.bold, keys: ["Mod", "b"], markdown: { marker: "**x**" } },
|
|
1418
|
+
{ id: "italic", label: labels.italic, keys: ["Mod", "i"], markdown: { marker: "*x*" } },
|
|
1419
|
+
{ id: "strike", label: labels.strike, keys: ["Mod", "Shift", "s"], markdown: { marker: "~~x~~" } },
|
|
1420
|
+
{ id: "underline", label: labels.underline, keys: ["Mod", "u"] },
|
|
1421
|
+
{ id: "inline-code", label: labels.inlineCode, keys: ["Mod", "e"], markdown: { marker: "`x`" } },
|
|
1422
|
+
{ id: "highlight", label: labels.highlight, keys: ["Mod", "Shift", "h"], markdown: { marker: "==x==" } },
|
|
1423
|
+
...[1, 2, 3, 4, 5, 6].map((level) => ({
|
|
1424
|
+
id: `heading-${level}`,
|
|
1425
|
+
label: labels.headingLabel(level),
|
|
1426
|
+
keys: ["Mod", "Alt", String(level)],
|
|
1427
|
+
markdown: { marker: "#".repeat(level), terminator: "Space" }
|
|
1428
|
+
})),
|
|
1429
|
+
{ id: "paragraph", label: labels.paragraph, keys: ["Mod", "Alt", "0"] }
|
|
1430
|
+
]
|
|
1431
|
+
},
|
|
1432
|
+
{
|
|
1433
|
+
id: "insert",
|
|
1434
|
+
title: labels.insertGroup,
|
|
1435
|
+
entries: [
|
|
1436
|
+
{ id: "blockquote", label: labels.blockquote, keys: ["Mod", "Shift", "b"], markdown: { marker: ">", terminator: "Space" } },
|
|
1437
|
+
{ id: "bullet-list", label: labels.bulletList, keys: ["Mod", "Shift", "8"], markdown: { marker: "-", terminator: "Space" } },
|
|
1438
|
+
{ id: "ordered-list", label: labels.orderedList, keys: ["Mod", "Shift", "7"], markdown: { marker: "1.", terminator: "Space" } },
|
|
1439
|
+
{ id: "task-list", label: labels.taskList, markdown: { marker: "[]", terminator: "Space" } },
|
|
1440
|
+
{ id: "code-block", label: labels.codeBlock, markdown: { marker: "```", terminator: "Space" } },
|
|
1441
|
+
{ id: "divider", label: labels.divider, markdown: { marker: "---", terminator: "Space" } }
|
|
1442
|
+
]
|
|
1443
|
+
},
|
|
1444
|
+
{
|
|
1445
|
+
id: "edit",
|
|
1446
|
+
title: labels.editGroup,
|
|
1447
|
+
entries: [
|
|
1448
|
+
{ id: "undo", label: labels.undo, keys: ["Mod", "z"] },
|
|
1449
|
+
{ id: "redo", label: labels.redo, keys: ["Mod", "Shift", "z"] },
|
|
1450
|
+
{ id: "hard-break", label: labels.hardBreak, keys: ["Shift", "Enter"] },
|
|
1451
|
+
{ id: "find-replace", label: labels.findReplace, keys: ["Mod", "f"] }
|
|
1452
|
+
]
|
|
1453
|
+
}
|
|
1454
|
+
];
|
|
1455
|
+
}
|
|
1456
|
+
function isMacPlatform() {
|
|
1457
|
+
if (typeof navigator === "undefined") return false;
|
|
1458
|
+
return /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
|
|
1459
|
+
}
|
|
1460
|
+
function keycapText(key, mac) {
|
|
1461
|
+
if (key === "Mod") return mac ? "Cmd" : "Ctrl";
|
|
1462
|
+
if (key === "Alt") return mac ? "Opt" : "Alt";
|
|
1463
|
+
if (/^[a-z]$/.test(key)) return key.toUpperCase();
|
|
1464
|
+
return key;
|
|
1465
|
+
}
|
|
1466
|
+
function ShortcutPanel({ open, onClose, labels }) {
|
|
1467
|
+
const t = useMemo(
|
|
1468
|
+
() => ({ ...defaultShortcutLabels, ...labels }),
|
|
1469
|
+
[labels]
|
|
1470
|
+
);
|
|
1471
|
+
useEffect(() => {
|
|
1472
|
+
if (!open) return;
|
|
1473
|
+
const onKey = (e2) => {
|
|
1474
|
+
if (e2.key === "Escape") onClose();
|
|
1475
|
+
};
|
|
1476
|
+
document.addEventListener("keydown", onKey);
|
|
1477
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
1478
|
+
}, [open, onClose]);
|
|
1479
|
+
const groups = useMemo(
|
|
1480
|
+
() => open ? buildShortcutGroups(t) : [],
|
|
1481
|
+
[open, t]
|
|
1482
|
+
);
|
|
1483
|
+
const mac = useMemo(isMacPlatform, []);
|
|
1484
|
+
if (!open) return null;
|
|
1485
|
+
return /* @__PURE__ */ jsxs(
|
|
1486
|
+
"aside",
|
|
1487
|
+
{
|
|
1488
|
+
className: styles$5.drawer,
|
|
1489
|
+
role: "dialog",
|
|
1490
|
+
"aria-modal": "false",
|
|
1491
|
+
"aria-label": t.panelTitle,
|
|
1492
|
+
children: [
|
|
1493
|
+
/* @__PURE__ */ jsx(
|
|
1494
|
+
"button",
|
|
1495
|
+
{
|
|
1496
|
+
type: "button",
|
|
1497
|
+
className: styles$5.closeBtn,
|
|
1498
|
+
title: t.close,
|
|
1499
|
+
"aria-label": t.close,
|
|
1500
|
+
onClick: onClose,
|
|
1501
|
+
children: /* @__PURE__ */ jsx(XIcon, { size: 16 })
|
|
1502
|
+
}
|
|
1503
|
+
),
|
|
1504
|
+
/* @__PURE__ */ jsxs("div", { className: styles$5.head, children: [
|
|
1505
|
+
/* @__PURE__ */ jsx("span", { className: styles$5.colFormat, children: t.colFormat }),
|
|
1506
|
+
/* @__PURE__ */ jsx("span", { className: styles$5.colShortcut, children: t.colShortcut }),
|
|
1507
|
+
/* @__PURE__ */ jsx("span", { className: styles$5.colMarkdown, children: t.colMarkdown })
|
|
1508
|
+
] }),
|
|
1509
|
+
/* @__PURE__ */ jsx("div", { className: styles$5.body, children: groups.map((group2) => /* @__PURE__ */ jsxs("section", { className: styles$5.group, children: [
|
|
1510
|
+
/* @__PURE__ */ jsx("h3", { className: styles$5.groupTitle, children: group2.title }),
|
|
1511
|
+
group2.entries.map((entry) => /* @__PURE__ */ jsxs("div", { className: styles$5.row, children: [
|
|
1512
|
+
/* @__PURE__ */ jsx("span", { className: styles$5.rowLabel, children: entry.label }),
|
|
1513
|
+
/* @__PURE__ */ jsx("span", { className: styles$5.rowKeys, children: entry.keys ? entry.keys.map((key, i) => /* @__PURE__ */ jsx("kbd", { className: styles$5.keycap, children: keycapText(key, mac) }, i)) : /* @__PURE__ */ jsx("span", { className: styles$5.none, children: "—" }) }),
|
|
1514
|
+
/* @__PURE__ */ jsx("span", { className: styles$5.rowMd, children: entry.markdown ? /* @__PURE__ */ jsxs(Fragment$2, { children: [
|
|
1515
|
+
/* @__PURE__ */ jsx("kbd", { className: styles$5.keycap, children: entry.markdown.marker }),
|
|
1516
|
+
entry.markdown.terminator ? /* @__PURE__ */ jsx("kbd", { className: styles$5.keycap, children: entry.markdown.terminator }) : null
|
|
1517
|
+
] }) : /* @__PURE__ */ jsx("span", { className: styles$5.none, children: "—" }) })
|
|
1518
|
+
] }, entry.id))
|
|
1519
|
+
] }, group2.id)) })
|
|
1520
|
+
]
|
|
1521
|
+
}
|
|
1522
|
+
);
|
|
1523
|
+
}
|
|
1017
1524
|
const MD_FILE_RE$1 = /\.(md|markdown)$/i;
|
|
1018
1525
|
const MD_MIME_TYPES = ["text/markdown", "text/x-markdown", ""];
|
|
1019
1526
|
async function insertMarkdownFiles(editor, files, pos) {
|
|
@@ -1609,12 +2116,17 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
|
|
|
1609
2116
|
findBarContainer,
|
|
1610
2117
|
findBarOffset = DEFAULT_FIND_BAR_OFFSET,
|
|
1611
2118
|
findShortcut = true,
|
|
1612
|
-
findLabels
|
|
2119
|
+
findLabels,
|
|
2120
|
+
slashMenu = true,
|
|
2121
|
+
slashMenuLabels,
|
|
2122
|
+
shortcutPanel = true,
|
|
2123
|
+
shortcutLabels
|
|
1613
2124
|
}, ref) {
|
|
1614
2125
|
const preparedInitial = prepareChartMarkdown(
|
|
1615
2126
|
enrichMarkdownCitations(initialMarkdown, sources ?? [])
|
|
1616
2127
|
);
|
|
1617
2128
|
const [findOpen, setFindOpen] = useState(false);
|
|
2129
|
+
const [shortcutsOpen, setShortcutsOpen] = useState(false);
|
|
1618
2130
|
const findInputRef = useRef(null);
|
|
1619
2131
|
const editor = useEditor({
|
|
1620
2132
|
extensions: [
|
|
@@ -1647,6 +2159,8 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
|
|
|
1647
2159
|
}),
|
|
1648
2160
|
...markdownPaste ? [MarkdownPaste] : [],
|
|
1649
2161
|
...markdownFileDrop ? [MarkdownFileDrop] : [],
|
|
2162
|
+
// 斜杠菜单(键入 / 唤起):默认开,只读态由 suggestion 状态机自身短路
|
|
2163
|
+
...slashMenu ? [SlashMenu.configure({ labels: slashMenuLabels })] : [],
|
|
1650
2164
|
...extraExtensions ?? []
|
|
1651
2165
|
],
|
|
1652
2166
|
content: preparedInitial,
|
|
@@ -1656,7 +2170,7 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
|
|
|
1656
2170
|
immediatelyRender: false,
|
|
1657
2171
|
editorProps: {
|
|
1658
2172
|
attributes: {
|
|
1659
|
-
class: styles$
|
|
2173
|
+
class: styles$8.editorContent,
|
|
1660
2174
|
"data-placeholder": placeholder ?? ""
|
|
1661
2175
|
}
|
|
1662
2176
|
}
|
|
@@ -1822,20 +2336,44 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
|
|
|
1822
2336
|
labels: findLabels,
|
|
1823
2337
|
onClose: closeFind,
|
|
1824
2338
|
inputRef: findInputRef,
|
|
1825
|
-
className: styles$
|
|
2339
|
+
className: styles$8.findBar,
|
|
1826
2340
|
style: findBarOffsetStyle(findBarOffset)
|
|
1827
2341
|
}
|
|
1828
2342
|
) : null;
|
|
1829
|
-
|
|
1830
|
-
|
|
2343
|
+
const shortcutT = useMemo(
|
|
2344
|
+
() => ({ ...defaultShortcutLabels, ...shortcutLabels }),
|
|
2345
|
+
[shortcutLabels]
|
|
2346
|
+
);
|
|
2347
|
+
return /* @__PURE__ */ jsxs("div", { className: styles$8.editorHost, children: [
|
|
2348
|
+
findBarNode && !findBarTarget ? /* @__PURE__ */ jsx("div", { className: styles$8.findBarAnchor, children: findBarNode }) : null,
|
|
1831
2349
|
findBarNode && findBarTarget ? createPortal(findBarNode, findBarTarget) : null,
|
|
1832
2350
|
/* @__PURE__ */ jsx(
|
|
1833
2351
|
EditorContent,
|
|
1834
2352
|
{
|
|
1835
2353
|
editor,
|
|
1836
|
-
className: className ? `${styles$
|
|
2354
|
+
className: className ? `${styles$8.editorScroll} ${className}` : styles$8.editorScroll
|
|
1837
2355
|
}
|
|
1838
|
-
)
|
|
2356
|
+
),
|
|
2357
|
+
shortcutPanel && editable ? /* @__PURE__ */ jsx(
|
|
2358
|
+
"button",
|
|
2359
|
+
{
|
|
2360
|
+
type: "button",
|
|
2361
|
+
className: styles$8.shortcutFab,
|
|
2362
|
+
title: shortcutT.panelTitle,
|
|
2363
|
+
"aria-label": shortcutT.panelTitle,
|
|
2364
|
+
"aria-expanded": shortcutsOpen,
|
|
2365
|
+
onClick: () => setShortcutsOpen((v) => !v),
|
|
2366
|
+
children: /* @__PURE__ */ jsx(KeyboardIcon, { size: 18 })
|
|
2367
|
+
}
|
|
2368
|
+
) : null,
|
|
2369
|
+
shortcutPanel && editable ? /* @__PURE__ */ jsx(
|
|
2370
|
+
ShortcutPanel,
|
|
2371
|
+
{
|
|
2372
|
+
open: shortcutsOpen,
|
|
2373
|
+
onClose: () => setShortcutsOpen(false),
|
|
2374
|
+
labels: shortcutLabels
|
|
2375
|
+
}
|
|
2376
|
+
) : null
|
|
1839
2377
|
] });
|
|
1840
2378
|
});
|
|
1841
2379
|
function MarkdownPreview({
|
|
@@ -1877,7 +2415,7 @@ function MarkdownPreview({
|
|
|
1877
2415
|
editable: false,
|
|
1878
2416
|
immediatelyRender: false,
|
|
1879
2417
|
editorProps: {
|
|
1880
|
-
attributes: { class: styles$
|
|
2418
|
+
attributes: { class: styles$8.editorContent }
|
|
1881
2419
|
}
|
|
1882
2420
|
},
|
|
1883
2421
|
[extensions]
|
|
@@ -1890,7 +2428,7 @@ function MarkdownPreview({
|
|
|
1890
2428
|
EditorContent,
|
|
1891
2429
|
{
|
|
1892
2430
|
editor,
|
|
1893
|
-
className: className ?? styles$
|
|
2431
|
+
className: className ?? styles$8.editorScroll
|
|
1894
2432
|
}
|
|
1895
2433
|
);
|
|
1896
2434
|
}
|
|
@@ -2954,7 +3492,7 @@ function EditorToolbar({
|
|
|
2954
3492
|
setMathEdit(null);
|
|
2955
3493
|
};
|
|
2956
3494
|
const scriptActive = state.superscript ? "superscript" : state.subscript ? "subscript" : "normal";
|
|
2957
|
-
return /* @__PURE__ */ jsxs(Fragment$
|
|
3495
|
+
return /* @__PURE__ */ jsxs(Fragment$2, { children: [
|
|
2958
3496
|
/* @__PURE__ */ jsx(
|
|
2959
3497
|
"div",
|
|
2960
3498
|
{
|
|
@@ -3197,7 +3735,7 @@ function EditorToolbar({
|
|
|
3197
3735
|
),
|
|
3198
3736
|
/* @__PURE__ */ jsx(Divider, {}),
|
|
3199
3737
|
/* @__PURE__ */ jsx(ToolbarButton, { title: t.link, active: state.link, onClick: toggleLink, children: /* @__PURE__ */ jsx(LinkIcon, {}) }),
|
|
3200
|
-
onImageUpload ? /* @__PURE__ */ jsxs(Fragment$
|
|
3738
|
+
onImageUpload ? /* @__PURE__ */ jsxs(Fragment$2, { children: [
|
|
3201
3739
|
/* @__PURE__ */ jsx(ToolbarButton, { title: t.image, onClick: handlePickImage, children: /* @__PURE__ */ jsx(ImageIcon, {}) }),
|
|
3202
3740
|
/* @__PURE__ */ jsx(
|
|
3203
3741
|
"input",
|
|
@@ -3764,6 +4302,17 @@ function insertPlainParagraphAt(editor, from, to, text) {
|
|
|
3764
4302
|
return false;
|
|
3765
4303
|
}
|
|
3766
4304
|
}
|
|
4305
|
+
function insertSlashMarkdown(editor, range, markdown) {
|
|
4306
|
+
const prepared = prepareChartMarkdown(markdown);
|
|
4307
|
+
if (!prepared) return;
|
|
4308
|
+
try {
|
|
4309
|
+
const ok = editor.chain().focus().deleteRange(range).insertContent(prepared, { contentType: "markdown" }).run();
|
|
4310
|
+
if (ok) return;
|
|
4311
|
+
} catch {
|
|
4312
|
+
}
|
|
4313
|
+
editor.chain().focus().deleteRange(range).run();
|
|
4314
|
+
insertMarkdown(editor, prepared);
|
|
4315
|
+
}
|
|
3767
4316
|
export {
|
|
3768
4317
|
BoldIcon,
|
|
3769
4318
|
COMMENT_ACTIVE_META,
|
|
@@ -3793,6 +4342,7 @@ export {
|
|
|
3793
4342
|
ImportIcon,
|
|
3794
4343
|
ImportPlaceholder,
|
|
3795
4344
|
ItalicIcon,
|
|
4345
|
+
KeyboardIcon,
|
|
3796
4346
|
LinkIcon,
|
|
3797
4347
|
ListChecksIcon,
|
|
3798
4348
|
ListOrderedIcon,
|
|
@@ -3814,6 +4364,8 @@ export {
|
|
|
3814
4364
|
RowBeforeIcon,
|
|
3815
4365
|
RowDeleteIcon,
|
|
3816
4366
|
SearchIcon,
|
|
4367
|
+
ShortcutPanel,
|
|
4368
|
+
SlashMenu,
|
|
3817
4369
|
StrikethroughIcon,
|
|
3818
4370
|
TableDeleteIcon,
|
|
3819
4371
|
TocPanel,
|
|
@@ -3825,6 +4377,7 @@ export {
|
|
|
3825
4377
|
applyCommentAnchorsToEditor,
|
|
3826
4378
|
baseExtensions,
|
|
3827
4379
|
g as blockTextHash,
|
|
4380
|
+
buildShortcutGroups,
|
|
3828
4381
|
collectCommentIds,
|
|
3829
4382
|
commentAnchorExtension,
|
|
3830
4383
|
commentAnchorPlugin,
|
|
@@ -3832,21 +4385,26 @@ export {
|
|
|
3832
4385
|
commentRangesById,
|
|
3833
4386
|
createChart,
|
|
3834
4387
|
createCitationRef,
|
|
4388
|
+
createDefaultSlashMenuItems,
|
|
3835
4389
|
defaultChartLabels,
|
|
3836
4390
|
defaultCodeBlockLabels,
|
|
3837
4391
|
defaultColorPaletteLabels,
|
|
3838
4392
|
defaultCommentLabels,
|
|
3839
4393
|
defaultFindLabels,
|
|
4394
|
+
defaultShortcutLabels,
|
|
4395
|
+
defaultSlashMenuLabels,
|
|
3840
4396
|
defaultTocLabels,
|
|
3841
4397
|
defaultToolbarLabels,
|
|
3842
4398
|
enrichMarkdownCitations,
|
|
3843
4399
|
b2 as extractFootnoteSources,
|
|
3844
4400
|
e as extractToc,
|
|
4401
|
+
filterSlashItems,
|
|
3845
4402
|
f as findCitationRefElement,
|
|
3846
4403
|
findRangeByAnchor,
|
|
3847
4404
|
focusComment,
|
|
3848
4405
|
getMarkdownForRange,
|
|
3849
4406
|
insertMarkdown,
|
|
4407
|
+
insertSlashMarkdown,
|
|
3850
4408
|
looksLikeMarkdown,
|
|
3851
4409
|
lowlight,
|
|
3852
4410
|
makeTocGetId,
|