reactjs-tiptap-editor 1.0.9 → 1.0.11
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/lib/{ActionMenuButton-CmDopTWt.cjs → ActionMenuButton-BLlse5KO.cjs} +1 -1
- package/lib/{ActionMenuButton-C4aNFFa8.js → ActionMenuButton-DTXFBdGX.js} +2 -2
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.js +7 -7
- package/lib/Blockquote.cjs +1 -1
- package/lib/Blockquote.js +3 -3
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +6 -6
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +3 -3
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +3 -3
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +6 -6
- package/lib/CodeBlock.cjs +1 -1
- package/lib/CodeBlock.js +4 -4
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +3 -3
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +5 -5
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +8 -8
- package/lib/{Drawer-DG0gPU_U.js → Drawer-D0yQ0wR7.js} +6 -6
- package/lib/{Drawer-CTr2snNd.cjs → Drawer-kv6BU_6O.cjs} +1 -1
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +3 -3
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +8 -7
- package/lib/{Excalidraw-DtezFdjR.cjs → Excalidraw-B82ThkJA.cjs} +1 -1
- package/lib/{Excalidraw-DpgdxOsc.js → Excalidraw-CO4IRHmG.js} +7 -7
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +2 -2
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.js +3 -3
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +3 -3
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +5 -5
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +5 -5
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +5 -5
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +5 -5
- package/lib/History.cjs +1 -1
- package/lib/History.js +4 -4
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +3 -3
- package/lib/{Icon-C_buGjWy.js → Icon-DRuJhcHK.js} +1 -1
- package/lib/{Icon-b6HQAURz.cjs → Icon-DXePECFW.cjs} +1 -1
- package/lib/{Iframe-CUrXCDxj.cjs → Iframe-03dn9wcM.cjs} +1 -1
- package/lib/{Iframe-De88TYvj.js → Iframe-BEO28NPs.js} +8 -8
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +2 -2
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +13 -13
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +14 -14
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +3 -3
- package/lib/{Indent-Bensb2nf.js → Indent-CXurBbOr.js} +5 -5
- package/lib/{Indent-D_KtZNHW.cjs → Indent-Cqjdn3Jt.cjs} +1 -1
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +3 -3
- package/lib/{Katex-C0dtqznb.js → Katex-Bvj469K1.js} +7 -7
- package/lib/{Katex-NqelWRoi.cjs → Katex-DdWTV5NJ.cjs} +1 -1
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +2 -2
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +5 -5
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-BSZ-vgNB.cjs → LinkEditBlock-8ePAZ-G1.cjs} +1 -1
- package/lib/{LinkEditBlock-Bv12sKvW.js → LinkEditBlock-DjXUEubR.js} +32 -32
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.js +23 -22
- package/lib/Mermaid.cjs +1 -1
- package/lib/Mermaid.js +26 -26
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +5 -5
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +3 -3
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +9 -9
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +39 -266
- package/lib/SlashCommandNodeView-Bl_gwZJB.cjs +1 -0
- package/lib/SlashCommandNodeView-CcqL8ymb.js +254 -0
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +3 -3
- package/lib/{Table-D9ckv6Tb.js → Table-9Y0Cg8Ab.js} +5 -5
- package/lib/{Table-cy1mUM2X.cjs → Table-DBGjezZK.cjs} +1 -1
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +3 -3
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +5 -5
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +5 -5
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +3 -3
- package/lib/{Twitter-Bvs3sW8F.cjs → Twitter-Cnvt7GBg.cjs} +1 -1
- package/lib/{Twitter-KUvyySA0.js → Twitter-DWwd0vHR.js} +46 -46
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +2 -2
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +7 -7
- package/lib/bubble.cjs +4 -4
- package/lib/bubble.js +1659 -1567
- package/lib/{button-U6XpZt2X.cjs → button-BW5bDPz_.cjs} +1 -1
- package/lib/{button-D8SI-g7p.js → button-RnHbJfd-.js} +1 -1
- package/lib/{checkbox-xrY2c5yo.js → checkbox-CLSoR1Qj.js} +1 -1
- package/lib/{checkbox-DaIBNthL.cjs → checkbox-CTEN0q4y.cjs} +1 -1
- package/lib/{dialog-DgnnVCfv.cjs → dialog-CMC9hsCo.cjs} +1 -1
- package/lib/{dialog-DjnkASYP.js → dialog-D_HCtKvc.js} +1 -1
- package/lib/{dropdown-menu-bI14Gyw4.js → dropdown-menu-66q7Ofc5.js} +3 -2
- package/lib/dropdown-menu-DKSAS-w_.cjs +1 -0
- package/lib/extensions/SlashCommand/types.d.ts +1 -0
- package/lib/index-9A6-kVBM.js +1351 -0
- package/lib/{index-4pRt5Vqu.js → index-C3zg3DPB.js} +442 -403
- package/lib/index-C838s-or.cjs +8 -0
- package/lib/index-Cv9Z6dyV.cjs +1 -0
- package/lib/{index-EKFybgpP.js → index-DKt5wfAc.js} +1 -1
- package/lib/{index-BimeTI7q.js → index-DRHrDScg.js} +1 -1
- package/lib/{index-BQ6ZdLsu.js → index-DmPwbBqm.js} +1 -1
- package/lib/{index-CbIQPoF6.js → index-sVScpCFG.js} +20 -20
- package/lib/index.cjs +1 -1
- package/lib/index.js +5 -5
- package/lib/{input-C5zU49Q1.js → input-CvyMYMZG.js} +1 -1
- package/lib/{input-BtDj0NeF.cjs → input-D555880-.cjs} +1 -1
- package/lib/{isNumber-8HKEgTkA.js → isNumber-DF0fU3ob.js} +1 -1
- package/lib/{label-BEUVs-IA.js → label-DsOYPjAo.js} +1 -1
- package/lib/{label-C8BonzOY.cjs → label-E6jF3Xud.cjs} +1 -1
- package/lib/{popover-CPY5lMCj.js → popover-B7ec5-u2.js} +1 -1
- package/lib/{popover-DjL0De8d.cjs → popover-BSzR_R01.cjs} +1 -1
- package/lib/{separator-BlIlS7LP.js → separator-JaTTqb3J.js} +4 -4
- package/lib/{separator-BzMkiI_c.cjs → separator-PGnA-6Hr.cjs} +1 -1
- package/lib/{store-D_GvIPxo.js → store-Cf7tFiiI.js} +1 -1
- package/lib/{store-BSCjQxMK.cjs → store-oDk-lTPM.cjs} +1 -1
- package/lib/style.css +1 -1
- package/lib/{tabs-CHy82_rs.cjs → tabs-BTwiZkWd.cjs} +1 -1
- package/lib/{tabs-tQpXIzfV.js → tabs-CWr9HYaM.js} +1 -1
- package/lib/{textarea-CMDYVXYo.js → textarea-BdeLXbp8.js} +1 -1
- package/lib/{textarea-B-qfanCT.cjs → textarea-Yetl_PZi.cjs} +1 -1
- package/lib/{throttle-BIkZV3Y_.js → throttle-DsowOft0.js} +1 -1
- package/lib/updatePosition-Bbd8ETMv.js +16 -0
- package/lib/updatePosition-M2IyqkI1.cjs +1 -0
- package/lib/{useButtonProps-BqBGuqoP.cjs → useButtonProps-DfnJiJLV.cjs} +1 -1
- package/lib/{useButtonProps-DTngjZge.js → useButtonProps-cMoicZgd.js} +14 -14
- package/package.json +1 -1
- package/lib/dropdown-menu-BvVMltdB.cjs +0 -1
- package/lib/floating-ui.dom-U1vPFQ5f.js +0 -1151
- package/lib/floating-ui.dom-VCrc58uF.cjs +0 -1
- package/lib/index-DvvMf6Wu.cjs +0 -7
- package/lib/updatePosition-GLTrgcib.js +0 -215
- package/lib/updatePosition-u2mTh3mG.cjs +0 -1
package/lib/SlashCommand.js
CHANGED
|
@@ -1,251 +1,24 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
import { PluginKey as
|
|
3
|
-
import { S as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
function J({ t }) {
|
|
18
|
-
const n = [
|
|
19
|
-
{
|
|
20
|
-
name: "format",
|
|
21
|
-
title: t("editor.slash.format"),
|
|
22
|
-
commands: []
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
name: "insert",
|
|
26
|
-
title: t("editor.slash.insert"),
|
|
27
|
-
commands: []
|
|
28
|
-
}
|
|
29
|
-
];
|
|
30
|
-
return [1, 2, 3, 4, 5, 6].forEach((e) => {
|
|
31
|
-
n[0].commands.push({
|
|
32
|
-
name: `heading${e}`,
|
|
33
|
-
label: t(`editor.heading.h${e}.tooltip`),
|
|
34
|
-
aliases: [`h${e}`, "bt", `bt${e}`],
|
|
35
|
-
iconName: `Heading${e}`,
|
|
36
|
-
action: ({ editor: o, range: l }) => {
|
|
37
|
-
o.chain().focus().deleteRange(l).setHeading({ level: e }).run();
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}), n[0].commands.push({
|
|
41
|
-
name: "bulletList",
|
|
42
|
-
label: t("editor.bulletlist.tooltip"),
|
|
43
|
-
aliases: ["ul", "yxlb"],
|
|
44
|
-
iconName: "List",
|
|
45
|
-
action: ({ editor: e, range: o }) => {
|
|
46
|
-
e.chain().focus().deleteRange(o).toggleBulletList().run();
|
|
47
|
-
}
|
|
48
|
-
}), n[0].commands.push({
|
|
49
|
-
name: "numberedList",
|
|
50
|
-
label: t("editor.orderedlist.tooltip"),
|
|
51
|
-
aliases: ["ol", "yxlb"],
|
|
52
|
-
iconName: "ListOrdered",
|
|
53
|
-
action: ({ editor: e, range: o }) => {
|
|
54
|
-
e.chain().focus().deleteRange(o).toggleOrderedList().run();
|
|
55
|
-
}
|
|
56
|
-
}), n[0].commands.push({
|
|
57
|
-
name: "taskList",
|
|
58
|
-
label: t("editor.tasklist.tooltip"),
|
|
59
|
-
iconName: "ListTodo",
|
|
60
|
-
description: "Task list with todo items",
|
|
61
|
-
aliases: ["todo"],
|
|
62
|
-
action: ({ editor: e, range: o }) => {
|
|
63
|
-
e.chain().focus().deleteRange(o).toggleTaskList().run();
|
|
64
|
-
}
|
|
65
|
-
}), n[0].commands.push({
|
|
66
|
-
name: "blockquote",
|
|
67
|
-
label: t("editor.blockquote.tooltip"),
|
|
68
|
-
description: "插入引入格式",
|
|
69
|
-
aliases: ["yr"],
|
|
70
|
-
iconName: "TextQuote",
|
|
71
|
-
action: ({ editor: e, range: o }) => {
|
|
72
|
-
e.chain().focus().deleteRange(o).setBlockquote().run();
|
|
73
|
-
}
|
|
74
|
-
}), n[0].commands.push({
|
|
75
|
-
name: "codeBlock",
|
|
76
|
-
label: t("editor.codeblock.tooltip"),
|
|
77
|
-
iconName: "Code2",
|
|
78
|
-
description: "Code block with syntax highlighting",
|
|
79
|
-
shouldBeHidden: (e) => e.isActive("columns"),
|
|
80
|
-
action: ({ editor: e, range: o }) => {
|
|
81
|
-
e.chain().focus().deleteRange(o).setCodeBlock().run();
|
|
82
|
-
}
|
|
83
|
-
}), n[1].commands.push({
|
|
84
|
-
name: "image",
|
|
85
|
-
label: t("editor.image.tooltip"),
|
|
86
|
-
iconName: "ImageUp",
|
|
87
|
-
description: "Insert a image",
|
|
88
|
-
aliases: ["image", "tp", "tupian"],
|
|
89
|
-
shouldBeHidden: (e) => e.isActive("columns"),
|
|
90
|
-
action: ({ editor: e, range: o }) => {
|
|
91
|
-
e.chain().focus().deleteRange(o).run(), T.setOpen(e.id, !0);
|
|
92
|
-
}
|
|
93
|
-
}), n[1].commands.push({
|
|
94
|
-
name: "video",
|
|
95
|
-
label: t("editor.video.tooltip"),
|
|
96
|
-
iconName: "Video",
|
|
97
|
-
description: "Insert a video",
|
|
98
|
-
aliases: ["video", "sp", "shipin"],
|
|
99
|
-
shouldBeHidden: (e) => e.isActive("columns"),
|
|
100
|
-
action: ({ editor: e, range: o }) => {
|
|
101
|
-
e.chain().focus().deleteRange(o).run(), _.setOpen(e.id, !0);
|
|
102
|
-
}
|
|
103
|
-
}), n[1].commands.push({
|
|
104
|
-
name: "table",
|
|
105
|
-
label: t("editor.table.tooltip"),
|
|
106
|
-
iconName: "Table",
|
|
107
|
-
description: "Insert a table",
|
|
108
|
-
aliases: ["table", "bg", "biaoge", "biao"],
|
|
109
|
-
shouldBeHidden: (e) => e.isActive("columns"),
|
|
110
|
-
action: ({ editor: e, range: o }) => {
|
|
111
|
-
e.chain().focus().deleteRange(o).insertTable({ rows: 3, cols: 3, withHeaderRow: !1 }).run();
|
|
112
|
-
}
|
|
113
|
-
}), n[1].commands.push({
|
|
114
|
-
name: "horizontalRule",
|
|
115
|
-
label: t("editor.horizontalrule.tooltip"),
|
|
116
|
-
iconName: "Minus",
|
|
117
|
-
description: "Insert a horizontal divider",
|
|
118
|
-
aliases: ["hr", "fgx", "fg"],
|
|
119
|
-
action: ({ editor: e, range: o }) => {
|
|
120
|
-
e.chain().focus().deleteRange(o).setHorizontalRule().run();
|
|
121
|
-
}
|
|
122
|
-
}), n[1].commands.push({
|
|
123
|
-
name: "columns",
|
|
124
|
-
label: t("editor.columns.tooltip"),
|
|
125
|
-
iconName: "Columns2",
|
|
126
|
-
description: "Add two column content",
|
|
127
|
-
action: ({ editor: e }) => {
|
|
128
|
-
e.chain().focus().insertColumns({ cols: 2 }).run();
|
|
129
|
-
}
|
|
130
|
-
}), n;
|
|
131
|
-
}
|
|
132
|
-
function W(t, n) {
|
|
133
|
-
return t.map((l) => ({
|
|
134
|
-
...l,
|
|
135
|
-
commands: l.commands.filter((c) => {
|
|
136
|
-
const u = c.label.toLowerCase().trim(), d = n.toLowerCase().trim();
|
|
137
|
-
if (c.aliases) {
|
|
138
|
-
const p = c.aliases.map((h) => h.toLowerCase().trim()), a = u.match(d), f = p.some((h) => h.match(d));
|
|
139
|
-
return a || f;
|
|
140
|
-
}
|
|
141
|
-
return u.match(d);
|
|
142
|
-
})
|
|
143
|
-
})).filter((l) => l.commands.length > 0);
|
|
144
|
-
}
|
|
145
|
-
const X = q([]);
|
|
146
|
-
function R() {
|
|
147
|
-
const [t, n] = K(X);
|
|
148
|
-
return [t, n];
|
|
149
|
-
}
|
|
150
|
-
function Y(t, n) {
|
|
151
|
-
const [e] = R(), [o, l] = C(0), [c, u] = C(0), d = N(null), { t: p } = y(), a = W(e, t.query), f = N([]);
|
|
152
|
-
G(n, () => ({
|
|
153
|
-
onKeyDown: h
|
|
154
|
-
})), v(() => {
|
|
155
|
-
if (!d.current)
|
|
156
|
-
return;
|
|
157
|
-
const r = c * 1e3 + o, i = f.current[r];
|
|
158
|
-
i && i.scrollIntoView({
|
|
159
|
-
behavior: "smooth",
|
|
160
|
-
block: "nearest"
|
|
161
|
-
});
|
|
162
|
-
}, [o, c]);
|
|
163
|
-
function h({ event: r }) {
|
|
164
|
-
return r.key === "ArrowUp" ? (I(), !0) : r.key === "ArrowDown" ? (L(), !0) : r.key === "Enter" ? (k(), !0) : !1;
|
|
165
|
-
}
|
|
166
|
-
function I() {
|
|
167
|
-
var s;
|
|
168
|
-
if (a.length === 0)
|
|
169
|
-
return !1;
|
|
170
|
-
let r = o - 1, i = c;
|
|
171
|
-
r < 0 && (i = c - 1, r = ((s = a[i]) == null ? void 0 : s.commands.length) - 1 || 0), i < 0 && (i = a.length - 1, r = a[i].commands.length - 1), l(r), u(i);
|
|
172
|
-
}
|
|
173
|
-
function L() {
|
|
174
|
-
if (a.length === 0)
|
|
175
|
-
return !1;
|
|
176
|
-
const r = a[c].commands;
|
|
177
|
-
let i = o + 1, s = c;
|
|
178
|
-
r.length - 1 < i && (i = 0, s = c + 1), a.length - 1 < s && (s = 0), l(i), u(s);
|
|
179
|
-
}
|
|
180
|
-
function k() {
|
|
181
|
-
if (a.length === 0 || c === -1 || o === -1)
|
|
182
|
-
return !1;
|
|
183
|
-
g(c, o);
|
|
184
|
-
}
|
|
185
|
-
function g(r, i) {
|
|
186
|
-
const s = a[r].commands[i];
|
|
187
|
-
t == null || t.command(s);
|
|
188
|
-
}
|
|
189
|
-
function S(r, i) {
|
|
190
|
-
g(r, i);
|
|
191
|
-
}
|
|
192
|
-
function E(r, i, s) {
|
|
193
|
-
f.current[r * 1e3 + i] = s;
|
|
194
|
-
}
|
|
195
|
-
return /* @__PURE__ */ m(
|
|
196
|
-
"div",
|
|
197
|
-
{
|
|
198
|
-
className: "richtext-max-h-[min(80vh,24rem)] richtext-flex-wrap richtext-overflow-y-auto richtext-overflow-x-hidden richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",
|
|
199
|
-
"data-richtext-portal": !0,
|
|
200
|
-
ref: d,
|
|
201
|
-
children: a != null && a.length ? /* @__PURE__ */ m("div", { className: "richtext-grid richtext-min-w-48 richtext-grid-cols-1 richtext-gap-0.5", children: a == null ? void 0 : a.map((r, i) => /* @__PURE__ */ w(O, { children: [
|
|
202
|
-
/* @__PURE__ */ m(M, { className: "richtext-mx-[4px] richtext-mb-[4px] richtext-mt-[8px] !richtext-text-[0.65rem] richtext-uppercase ", children: r.title }),
|
|
203
|
-
r.commands.map((s, x) => /* @__PURE__ */ w(
|
|
204
|
-
"button",
|
|
205
|
-
{
|
|
206
|
-
onClick: () => S(i, x),
|
|
207
|
-
ref: (H) => E(i, x, H),
|
|
208
|
-
className: P("richtext-flex richtext-items-center richtext-gap-3 richtext-px-2 richtext-py-1.5 richtext-text-sm richtext-text-foreground richtext-text-left richtext-w-full richtext-rounded-sm !richtext-outline-none !richtext-border-none richtext-transition-colors !richtext-bg-transparent hover:!richtext-bg-accent ", {
|
|
209
|
-
"bg-item-active": c === i && o === x
|
|
210
|
-
}),
|
|
211
|
-
children: [
|
|
212
|
-
s.iconUrl && /* @__PURE__ */ m(
|
|
213
|
-
"img",
|
|
214
|
-
{
|
|
215
|
-
alt: "",
|
|
216
|
-
className: "richtext-size-6",
|
|
217
|
-
src: s.iconUrl
|
|
218
|
-
}
|
|
219
|
-
),
|
|
220
|
-
s.iconName && /* @__PURE__ */ m(
|
|
221
|
-
j,
|
|
222
|
-
{
|
|
223
|
-
className: "!richtext-mr-1 !richtext-text-lg",
|
|
224
|
-
name: s.iconName
|
|
225
|
-
}
|
|
226
|
-
),
|
|
227
|
-
s.label
|
|
228
|
-
]
|
|
229
|
-
},
|
|
230
|
-
`command-${x}`
|
|
231
|
-
))
|
|
232
|
-
] }, `slash-${r.title}`)) }) : /* @__PURE__ */ m("div", { className: "richtext-p-3", children: /* @__PURE__ */ m("span", { className: "richtext-text-xs richtext-text-foreground", children: p("editor.slash.empty") }) })
|
|
233
|
-
}
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
const Z = z(Y);
|
|
237
|
-
function me({ commandList: t }) {
|
|
238
|
-
const [, n] = R(), { t: e } = y();
|
|
239
|
-
return v(() => {
|
|
240
|
-
if (!(t != null && t.length)) {
|
|
241
|
-
const o = J({ t: e });
|
|
242
|
-
n(o);
|
|
1
|
+
import { E as i, R as a } from "./index-sVScpCFG.js";
|
|
2
|
+
import { PluginKey as m } from "@tiptap/pm/state";
|
|
3
|
+
import { S as s } from "./index-9A6-kVBM.js";
|
|
4
|
+
import { u, r as l, S as d } from "./SlashCommandNodeView-CcqL8ymb.js";
|
|
5
|
+
import { a as b } from "./SlashCommandNodeView-CcqL8ymb.js";
|
|
6
|
+
import { u as o } from "./updatePosition-Bbd8ETMv.js";
|
|
7
|
+
import { jsx as f, Fragment as c } from "react/jsx-runtime";
|
|
8
|
+
import { u as h } from "./index-0OnGZkVF.js";
|
|
9
|
+
import { useEffect as C } from "react";
|
|
10
|
+
function E({ commandList: e }) {
|
|
11
|
+
const [, t] = u(), { t: r } = h();
|
|
12
|
+
return C(() => {
|
|
13
|
+
if (!(e != null && e.length)) {
|
|
14
|
+
const n = l({ t: r });
|
|
15
|
+
t(n);
|
|
243
16
|
return;
|
|
244
17
|
}
|
|
245
|
-
|
|
246
|
-
}, [
|
|
18
|
+
t(e);
|
|
19
|
+
}, [r, e]), /* @__PURE__ */ f(c, {});
|
|
247
20
|
}
|
|
248
|
-
const
|
|
21
|
+
const v = /* @__PURE__ */ i.create({
|
|
249
22
|
name: "richtextSlashCommand",
|
|
250
23
|
priority: 200,
|
|
251
24
|
// addOptions() {
|
|
@@ -257,8 +30,8 @@ const de = /* @__PURE__ */ A.create({
|
|
|
257
30
|
// },
|
|
258
31
|
addProseMirrorPlugins() {
|
|
259
32
|
return [
|
|
260
|
-
|
|
261
|
-
pluginKey: new
|
|
33
|
+
s({
|
|
34
|
+
pluginKey: new m("richtextSlashCommandPlugin"),
|
|
262
35
|
editor: this.editor,
|
|
263
36
|
char: "/",
|
|
264
37
|
// allowSpaces: true,
|
|
@@ -280,28 +53,28 @@ const de = /* @__PURE__ */ A.create({
|
|
|
280
53
|
// && isValidAfterContent
|
|
281
54
|
// );
|
|
282
55
|
// },
|
|
283
|
-
command: ({ editor:
|
|
284
|
-
const { view:
|
|
285
|
-
|
|
56
|
+
command: ({ editor: e, range: t, props: r }) => {
|
|
57
|
+
const { view: n } = e;
|
|
58
|
+
r.action({ editor: e, range: t }), n.focus();
|
|
286
59
|
},
|
|
287
60
|
render: () => {
|
|
288
|
-
let
|
|
61
|
+
let e;
|
|
289
62
|
return {
|
|
290
|
-
onStart: (
|
|
291
|
-
|
|
292
|
-
props:
|
|
293
|
-
editor:
|
|
294
|
-
}),
|
|
63
|
+
onStart: (t) => {
|
|
64
|
+
t.clientRect && (e = new a(d, {
|
|
65
|
+
props: t,
|
|
66
|
+
editor: t.editor
|
|
67
|
+
}), e.element.style.position = "absolute", document.body.appendChild(e.element), o(t.editor, e.element));
|
|
295
68
|
},
|
|
296
|
-
onUpdate(
|
|
297
|
-
|
|
69
|
+
onUpdate(t) {
|
|
70
|
+
e.updateProps(t), t.clientRect && o(t.editor, e.element);
|
|
298
71
|
},
|
|
299
|
-
onKeyDown(
|
|
300
|
-
var
|
|
301
|
-
return
|
|
72
|
+
onKeyDown(t) {
|
|
73
|
+
var r;
|
|
74
|
+
return t.event.key === "Escape" ? (e.destroy(), e.element.remove(), !0) : (r = e.ref) == null ? void 0 : r.onKeyDown(t);
|
|
302
75
|
},
|
|
303
76
|
onExit() {
|
|
304
|
-
|
|
77
|
+
e && (e.destroy(), e.element.remove());
|
|
305
78
|
}
|
|
306
79
|
};
|
|
307
80
|
}
|
|
@@ -310,8 +83,8 @@ const de = /* @__PURE__ */ A.create({
|
|
|
310
83
|
}
|
|
311
84
|
});
|
|
312
85
|
export {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
86
|
+
v as SlashCommand,
|
|
87
|
+
E as SlashCommandList,
|
|
88
|
+
l as renderCommandListDefault,
|
|
89
|
+
b as useFilterCommandList
|
|
317
90
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const d=require("react/jsx-runtime"),m=require("react"),q=require("./index-C838s-or.cjs"),f=require("./index-FSRjMsxW.cjs"),y=require("./store-oDk-lTPM.cjs"),w=require("./events.constant-DQYeJpu5.cjs"),S=require("./label-E6jF3Xud.cjs"),E=require("./Icon-DXePECFW.cjs"),j={setOpen:(i,s)=>{w.dispatchEvent(w.EVENTS.UPLOAD_VIDEO(i),s)}};function D({t:i}){const s=[{name:"format",title:i("editor.slash.format"),commands:[]},{name:"insert",title:i("editor.slash.insert"),commands:[]}];return f.HEADINGS.forEach(e=>{s[0].commands.push({name:`heading${e}`,label:i(e==="Paragraph"?"editor.paragraph.tooltip":`editor.heading.h${e}.tooltip`),aliases:[`h${e}`,"bt",`bt${e}`],iconName:`Heading${e}`,isActive:t=>e==="Paragraph"?!1:t.isActive("heading",{level:e})||!1,action:({editor:t,range:l})=>{const a=f.HEADINGS.find(u=>t.isActive("heading",{level:u}));if(e==="Paragraph"){a!==void 0&&a!=="Paragraph"?(t.commands.toggleHeading({level:a}),t.chain().focus().deleteRange(l).run(),console.log("AAA")):t.chain().focus().deleteRange(l).run();return}if(e){t.chain().focus().deleteRange(l).setHeading({level:e}).run();return}t.chain().focus().deleteRange(l).run()}})}),s[0].commands.push({name:"bulletList",label:i("editor.bulletlist.tooltip"),aliases:["ul","yxlb"],iconName:"List",isActive:e=>e.isActive("bulletList"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleBulletList().run()}}),s[0].commands.push({name:"orderedlist",label:i("editor.orderedlist.tooltip"),aliases:["ol","yxlb"],iconName:"ListOrdered",isActive:e=>e.isActive("orderedList"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleOrderedList().run()}}),s[0].commands.push({name:"taskList",label:i("editor.tasklist.tooltip"),iconName:"ListTodo",description:"Task list with todo items",aliases:["todo"],isActive:e=>e.isActive("taskList"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleTaskList().run()}}),s[0].commands.push({name:"blockquote",label:i("editor.blockquote.tooltip"),description:"插入引入格式",aliases:["yr"],iconName:"TextQuote",isActive:e=>e.isActive("blockquote"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setBlockquote().run()}}),s[0].commands.push({name:"codeBlock",label:i("editor.codeblock.tooltip"),iconName:"Code2",description:"Code block with syntax highlighting",shouldBeHidden:e=>e.isActive("columns"),isActive:e=>e.isActive("codeBlock"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setCodeBlock().run()}}),s[1].commands.push({name:"image",label:i("editor.image.tooltip"),iconName:"ImageUp",description:"Insert a image",aliases:["image","tp","tupian"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).run(),y.actionDialogImage.setOpen(e.id,!0)}}),s[1].commands.push({name:"video",label:i("editor.video.tooltip"),iconName:"Video",description:"Insert a video",aliases:["video","sp","shipin"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).run(),j.setOpen(e.id,!0)}}),s[1].commands.push({name:"table",label:i("editor.table.tooltip"),iconName:"Table",description:"Insert a table",aliases:["table","bg","biaoge","biao"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!1}).run()}}),s[1].commands.push({name:"horizontalRule",label:i("editor.horizontalrule.tooltip"),iconName:"Minus",description:"Insert a horizontal divider",aliases:["hr","fgx","fg"],action:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setHorizontalRule().run()}}),s[1].commands.push({name:"columns",label:i("editor.columns.tooltip"),iconName:"Columns2",description:"Add two column content",action:({editor:e})=>{e.chain().focus().insertColumns({cols:2}).run()}}),s}function C(i,s){return i.map(l=>({...l,commands:l.commands.filter(a=>{const u=a.label.toLowerCase().trim(),h=s.toLowerCase().trim();if(a.aliases){const b=a.aliases.map(x=>x.toLowerCase().trim()),r=u.match(h),g=b.some(x=>x.match(h));return r||g}return u.match(h)})})).filter(l=>l.commands.length>0)}const B=f.d([]);function N(){const[i,s]=f.x(B);return[i,s]}function $(i,s){const[e]=N(),[t,l]=m.useState(0),[a,u]=m.useState(0),h=m.useRef(null),{t:b}=f.useLocale(),r=C(e,i.query),g=m.useRef([]);m.useImperativeHandle(s,()=>({onKeyDown:x})),m.useEffect(()=>{if(!h.current)return;const o=a*1e3+t,n=g.current[o];n&&n.scrollIntoView({behavior:"smooth",block:"nearest"})},[t,a]);function x({event:o}){return o.key==="ArrowUp"?(A(),!0):o.key==="ArrowDown"?(L(),!0):o.key==="Enter"?(R(),!0):!1}function A(){var c;if(r.length===0)return!1;let o=t-1,n=a;o<0&&(n=a-1,o=((c=r[n])==null?void 0:c.commands.length)-1||0),n<0&&(n=r.length-1,o=r[n].commands.length-1),l(o),u(n)}function L(){if(r.length===0)return!1;const o=r[a].commands;let n=t+1,c=a;o.length-1<n&&(n=0,c=a+1),r.length-1<c&&(c=0),l(n),u(c)}function R(){if(r.length===0||a===-1||t===-1)return!1;v(a,t)}function v(o,n){const c=r[o].commands[n];i==null||i.command(c)}function I(o,n){v(o,n)}function k(o,n,c){g.current[o*1e3+n]=c}return d.jsx("div",{className:"richtext-max-h-[min(80vh,24rem)] richtext-flex-wrap richtext-overflow-y-auto richtext-overflow-x-hidden richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none","data-richtext-portal":!0,ref:h,children:r!=null&&r.length?d.jsx("div",{className:"richtext-grid richtext-min-w-48 richtext-grid-cols-1 richtext-gap-0.5",children:r==null?void 0:r.map((o,n)=>d.jsxs(m.Fragment,{children:[d.jsx(S.Label,{className:"richtext-mx-[4px] richtext-mb-[4px] richtext-mt-[8px] !richtext-text-[0.65rem] richtext-uppercase ",children:o.title}),o.commands.map((c,p)=>d.jsxs("button",{onClick:()=>I(n,p),ref:H=>k(n,p,H),className:q.cn("richtext-flex richtext-items-center richtext-gap-3 richtext-px-2 richtext-py-1.5 richtext-text-sm richtext-text-foreground richtext-text-left richtext-w-full richtext-rounded-sm !richtext-outline-none !richtext-border-none richtext-transition-colors !richtext-bg-transparent hover:!richtext-bg-accent ",{"bg-item-active":a===n&&t===p}),children:[c.iconUrl&&d.jsx("img",{alt:"",className:"richtext-size-6",src:c.iconUrl}),c.iconName&&d.jsx(E.IconComponent,{className:"!richtext-mr-1 !richtext-text-lg",name:c.iconName}),c.label]},`command-${p}`))]},`slash-${o.title}`))}):d.jsx("div",{className:"richtext-p-3",children:d.jsx("span",{className:"richtext-text-xs richtext-text-foreground",children:b("editor.slash.empty")})})})}const G=m.forwardRef($);exports.SlashCommandNodeView=G;exports.renderCommandListDefault=D;exports.useFilterCommandList=C;exports.useSignalCommandList=N;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { jsx as d, jsxs as b } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as H, useState as v, useRef as w, useImperativeHandle as y, useEffect as E, Fragment as B } from "react";
|
|
3
|
+
import { c as S } from "./index-C3zg3DPB.js";
|
|
4
|
+
import { H as A, m as D, x as $, u as z } from "./index-0OnGZkVF.js";
|
|
5
|
+
import { a as G } from "./store-Cf7tFiiI.js";
|
|
6
|
+
import { d as O, E as T } from "./events.constant-wrlJ_7JZ.js";
|
|
7
|
+
import { L as V } from "./label-DsOYPjAo.js";
|
|
8
|
+
import { I as q } from "./Icon-DRuJhcHK.js";
|
|
9
|
+
const P = {
|
|
10
|
+
setOpen: (i, a) => {
|
|
11
|
+
O(T.UPLOAD_VIDEO(i), a);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
function ee({ t: i }) {
|
|
15
|
+
const a = [
|
|
16
|
+
{
|
|
17
|
+
name: "format",
|
|
18
|
+
title: i("editor.slash.format"),
|
|
19
|
+
commands: []
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "insert",
|
|
23
|
+
title: i("editor.slash.insert"),
|
|
24
|
+
commands: []
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
return A.forEach((e) => {
|
|
28
|
+
a[0].commands.push({
|
|
29
|
+
name: `heading${e}`,
|
|
30
|
+
label: i(e === "Paragraph" ? "editor.paragraph.tooltip" : `editor.heading.h${e}.tooltip`),
|
|
31
|
+
aliases: [`h${e}`, "bt", `bt${e}`],
|
|
32
|
+
iconName: `Heading${e}`,
|
|
33
|
+
isActive: (t) => e === "Paragraph" ? !1 : t.isActive("heading", { level: e }) || !1,
|
|
34
|
+
action: ({ editor: t, range: l }) => {
|
|
35
|
+
const s = A.find((m) => t.isActive("heading", { level: m }));
|
|
36
|
+
if (e === "Paragraph") {
|
|
37
|
+
s !== void 0 && s !== "Paragraph" ? (t.commands.toggleHeading({ level: s }), t.chain().focus().deleteRange(l).run(), console.log("AAA")) : t.chain().focus().deleteRange(l).run();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (e) {
|
|
41
|
+
t.chain().focus().deleteRange(l).setHeading({ level: e }).run();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
t.chain().focus().deleteRange(l).run();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}), a[0].commands.push({
|
|
48
|
+
name: "bulletList",
|
|
49
|
+
label: i("editor.bulletlist.tooltip"),
|
|
50
|
+
aliases: ["ul", "yxlb"],
|
|
51
|
+
iconName: "List",
|
|
52
|
+
isActive: (e) => e.isActive("bulletList"),
|
|
53
|
+
action: ({ editor: e, range: t }) => {
|
|
54
|
+
e.chain().focus().deleteRange(t).toggleBulletList().run();
|
|
55
|
+
}
|
|
56
|
+
}), a[0].commands.push({
|
|
57
|
+
name: "orderedlist",
|
|
58
|
+
label: i("editor.orderedlist.tooltip"),
|
|
59
|
+
aliases: ["ol", "yxlb"],
|
|
60
|
+
iconName: "ListOrdered",
|
|
61
|
+
isActive: (e) => e.isActive("orderedList"),
|
|
62
|
+
action: ({ editor: e, range: t }) => {
|
|
63
|
+
e.chain().focus().deleteRange(t).toggleOrderedList().run();
|
|
64
|
+
}
|
|
65
|
+
}), a[0].commands.push({
|
|
66
|
+
name: "taskList",
|
|
67
|
+
label: i("editor.tasklist.tooltip"),
|
|
68
|
+
iconName: "ListTodo",
|
|
69
|
+
description: "Task list with todo items",
|
|
70
|
+
aliases: ["todo"],
|
|
71
|
+
isActive: (e) => e.isActive("taskList"),
|
|
72
|
+
action: ({ editor: e, range: t }) => {
|
|
73
|
+
e.chain().focus().deleteRange(t).toggleTaskList().run();
|
|
74
|
+
}
|
|
75
|
+
}), a[0].commands.push({
|
|
76
|
+
name: "blockquote",
|
|
77
|
+
label: i("editor.blockquote.tooltip"),
|
|
78
|
+
description: "插入引入格式",
|
|
79
|
+
aliases: ["yr"],
|
|
80
|
+
iconName: "TextQuote",
|
|
81
|
+
isActive: (e) => e.isActive("blockquote"),
|
|
82
|
+
action: ({ editor: e, range: t }) => {
|
|
83
|
+
e.chain().focus().deleteRange(t).setBlockquote().run();
|
|
84
|
+
}
|
|
85
|
+
}), a[0].commands.push({
|
|
86
|
+
name: "codeBlock",
|
|
87
|
+
label: i("editor.codeblock.tooltip"),
|
|
88
|
+
iconName: "Code2",
|
|
89
|
+
description: "Code block with syntax highlighting",
|
|
90
|
+
shouldBeHidden: (e) => e.isActive("columns"),
|
|
91
|
+
isActive: (e) => e.isActive("codeBlock"),
|
|
92
|
+
action: ({ editor: e, range: t }) => {
|
|
93
|
+
e.chain().focus().deleteRange(t).setCodeBlock().run();
|
|
94
|
+
}
|
|
95
|
+
}), a[1].commands.push({
|
|
96
|
+
name: "image",
|
|
97
|
+
label: i("editor.image.tooltip"),
|
|
98
|
+
iconName: "ImageUp",
|
|
99
|
+
description: "Insert a image",
|
|
100
|
+
aliases: ["image", "tp", "tupian"],
|
|
101
|
+
shouldBeHidden: (e) => e.isActive("columns"),
|
|
102
|
+
action: ({ editor: e, range: t }) => {
|
|
103
|
+
e.chain().focus().deleteRange(t).run(), G.setOpen(e.id, !0);
|
|
104
|
+
}
|
|
105
|
+
}), a[1].commands.push({
|
|
106
|
+
name: "video",
|
|
107
|
+
label: i("editor.video.tooltip"),
|
|
108
|
+
iconName: "Video",
|
|
109
|
+
description: "Insert a video",
|
|
110
|
+
aliases: ["video", "sp", "shipin"],
|
|
111
|
+
shouldBeHidden: (e) => e.isActive("columns"),
|
|
112
|
+
action: ({ editor: e, range: t }) => {
|
|
113
|
+
e.chain().focus().deleteRange(t).run(), P.setOpen(e.id, !0);
|
|
114
|
+
}
|
|
115
|
+
}), a[1].commands.push({
|
|
116
|
+
name: "table",
|
|
117
|
+
label: i("editor.table.tooltip"),
|
|
118
|
+
iconName: "Table",
|
|
119
|
+
description: "Insert a table",
|
|
120
|
+
aliases: ["table", "bg", "biaoge", "biao"],
|
|
121
|
+
shouldBeHidden: (e) => e.isActive("columns"),
|
|
122
|
+
action: ({ editor: e, range: t }) => {
|
|
123
|
+
e.chain().focus().deleteRange(t).insertTable({ rows: 3, cols: 3, withHeaderRow: !1 }).run();
|
|
124
|
+
}
|
|
125
|
+
}), a[1].commands.push({
|
|
126
|
+
name: "horizontalRule",
|
|
127
|
+
label: i("editor.horizontalrule.tooltip"),
|
|
128
|
+
iconName: "Minus",
|
|
129
|
+
description: "Insert a horizontal divider",
|
|
130
|
+
aliases: ["hr", "fgx", "fg"],
|
|
131
|
+
action: ({ editor: e, range: t }) => {
|
|
132
|
+
e.chain().focus().deleteRange(t).setHorizontalRule().run();
|
|
133
|
+
}
|
|
134
|
+
}), a[1].commands.push({
|
|
135
|
+
name: "columns",
|
|
136
|
+
label: i("editor.columns.tooltip"),
|
|
137
|
+
iconName: "Columns2",
|
|
138
|
+
description: "Add two column content",
|
|
139
|
+
action: ({ editor: e }) => {
|
|
140
|
+
e.chain().focus().insertColumns({ cols: 2 }).run();
|
|
141
|
+
}
|
|
142
|
+
}), a;
|
|
143
|
+
}
|
|
144
|
+
function U(i, a) {
|
|
145
|
+
return i.map((l) => ({
|
|
146
|
+
...l,
|
|
147
|
+
commands: l.commands.filter((s) => {
|
|
148
|
+
const m = s.label.toLowerCase().trim(), u = a.toLowerCase().trim();
|
|
149
|
+
if (s.aliases) {
|
|
150
|
+
const x = s.aliases.map((h) => h.toLowerCase().trim()), r = m.match(u), f = x.some((h) => h.match(u));
|
|
151
|
+
return r || f;
|
|
152
|
+
}
|
|
153
|
+
return m.match(u);
|
|
154
|
+
})
|
|
155
|
+
})).filter((l) => l.commands.length > 0);
|
|
156
|
+
}
|
|
157
|
+
const F = D([]);
|
|
158
|
+
function M() {
|
|
159
|
+
const [i, a] = $(F);
|
|
160
|
+
return [i, a];
|
|
161
|
+
}
|
|
162
|
+
function j(i, a) {
|
|
163
|
+
const [e] = M(), [t, l] = v(0), [s, m] = v(0), u = w(null), { t: x } = z(), r = U(e, i.query), f = w([]);
|
|
164
|
+
y(a, () => ({
|
|
165
|
+
onKeyDown: h
|
|
166
|
+
})), E(() => {
|
|
167
|
+
if (!u.current)
|
|
168
|
+
return;
|
|
169
|
+
const o = s * 1e3 + t, n = f.current[o];
|
|
170
|
+
n && n.scrollIntoView({
|
|
171
|
+
behavior: "smooth",
|
|
172
|
+
block: "nearest"
|
|
173
|
+
});
|
|
174
|
+
}, [t, s]);
|
|
175
|
+
function h({ event: o }) {
|
|
176
|
+
return o.key === "ArrowUp" ? (N(), !0) : o.key === "ArrowDown" ? (C(), !0) : o.key === "Enter" ? (L(), !0) : !1;
|
|
177
|
+
}
|
|
178
|
+
function N() {
|
|
179
|
+
var c;
|
|
180
|
+
if (r.length === 0)
|
|
181
|
+
return !1;
|
|
182
|
+
let o = t - 1, n = s;
|
|
183
|
+
o < 0 && (n = s - 1, o = ((c = r[n]) == null ? void 0 : c.commands.length) - 1 || 0), n < 0 && (n = r.length - 1, o = r[n].commands.length - 1), l(o), m(n);
|
|
184
|
+
}
|
|
185
|
+
function C() {
|
|
186
|
+
if (r.length === 0)
|
|
187
|
+
return !1;
|
|
188
|
+
const o = r[s].commands;
|
|
189
|
+
let n = t + 1, c = s;
|
|
190
|
+
o.length - 1 < n && (n = 0, c = s + 1), r.length - 1 < c && (c = 0), l(n), m(c);
|
|
191
|
+
}
|
|
192
|
+
function L() {
|
|
193
|
+
if (r.length === 0 || s === -1 || t === -1)
|
|
194
|
+
return !1;
|
|
195
|
+
g(s, t);
|
|
196
|
+
}
|
|
197
|
+
function g(o, n) {
|
|
198
|
+
const c = r[o].commands[n];
|
|
199
|
+
i == null || i.command(c);
|
|
200
|
+
}
|
|
201
|
+
function I(o, n) {
|
|
202
|
+
g(o, n);
|
|
203
|
+
}
|
|
204
|
+
function k(o, n, c) {
|
|
205
|
+
f.current[o * 1e3 + n] = c;
|
|
206
|
+
}
|
|
207
|
+
return /* @__PURE__ */ d(
|
|
208
|
+
"div",
|
|
209
|
+
{
|
|
210
|
+
className: "richtext-max-h-[min(80vh,24rem)] richtext-flex-wrap richtext-overflow-y-auto richtext-overflow-x-hidden richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",
|
|
211
|
+
"data-richtext-portal": !0,
|
|
212
|
+
ref: u,
|
|
213
|
+
children: r != null && r.length ? /* @__PURE__ */ d("div", { className: "richtext-grid richtext-min-w-48 richtext-grid-cols-1 richtext-gap-0.5", children: r == null ? void 0 : r.map((o, n) => /* @__PURE__ */ b(B, { children: [
|
|
214
|
+
/* @__PURE__ */ d(V, { className: "richtext-mx-[4px] richtext-mb-[4px] richtext-mt-[8px] !richtext-text-[0.65rem] richtext-uppercase ", children: o.title }),
|
|
215
|
+
o.commands.map((c, p) => /* @__PURE__ */ b(
|
|
216
|
+
"button",
|
|
217
|
+
{
|
|
218
|
+
onClick: () => I(n, p),
|
|
219
|
+
ref: (R) => k(n, p, R),
|
|
220
|
+
className: S("richtext-flex richtext-items-center richtext-gap-3 richtext-px-2 richtext-py-1.5 richtext-text-sm richtext-text-foreground richtext-text-left richtext-w-full richtext-rounded-sm !richtext-outline-none !richtext-border-none richtext-transition-colors !richtext-bg-transparent hover:!richtext-bg-accent ", {
|
|
221
|
+
"bg-item-active": s === n && t === p
|
|
222
|
+
}),
|
|
223
|
+
children: [
|
|
224
|
+
c.iconUrl && /* @__PURE__ */ d(
|
|
225
|
+
"img",
|
|
226
|
+
{
|
|
227
|
+
alt: "",
|
|
228
|
+
className: "richtext-size-6",
|
|
229
|
+
src: c.iconUrl
|
|
230
|
+
}
|
|
231
|
+
),
|
|
232
|
+
c.iconName && /* @__PURE__ */ d(
|
|
233
|
+
q,
|
|
234
|
+
{
|
|
235
|
+
className: "!richtext-mr-1 !richtext-text-lg",
|
|
236
|
+
name: c.iconName
|
|
237
|
+
}
|
|
238
|
+
),
|
|
239
|
+
c.label
|
|
240
|
+
]
|
|
241
|
+
},
|
|
242
|
+
`command-${p}`
|
|
243
|
+
))
|
|
244
|
+
] }, `slash-${o.title}`)) }) : /* @__PURE__ */ d("div", { className: "richtext-p-3", children: /* @__PURE__ */ d("span", { className: "richtext-text-xs richtext-text-foreground", children: x("editor.slash.empty") }) })
|
|
245
|
+
}
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
const te = H(j);
|
|
249
|
+
export {
|
|
250
|
+
te as S,
|
|
251
|
+
U as a,
|
|
252
|
+
ee as r,
|
|
253
|
+
M as u
|
|
254
|
+
};
|
package/lib/Strike.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-BBNITgNi.cjs"),s=require("react/jsx-runtime"),m=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-BBNITgNi.cjs"),s=require("react/jsx-runtime"),m=require("./index-C838s-or.cjs");require("react");const u=require("./useButtonProps-DfnJiJLV.cjs");var h=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,S=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,f=r.Mark.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",r.mergeAttributes(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[r.markInputRule({find:h,type:this.type})]},addPasteRules(){return[r.markPasteRule({find:S,type:this.type})]}});function v(){const t=u.useButtonProps(d.name),{icon:e=void 0,tooltip:i=void 0,shortcutKeys:n=void 0,tooltipOptions:c={},action:o=void 0,isActive:l=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:p,disabled:a,update:k}=u.useToggleActive(l),g=()=>{a||o&&(o(),k())};return t?s.jsx(m.ActionButton,{action:g,dataState:p,disabled:a,icon:e,shortcutKeys:n,tooltip:i,tooltipOptions:c}):s.jsx(s.Fragment,{})}const d=f.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:e,t:i,extension:n})=>({componentProps:{action:()=>e.commands.toggleStrike(),isActive:()=>e.isActive("strike")||!1,disabled:!1,icon:"Strikethrough",shortcutKeys:n.options.shortcutKeys??["shift","mod","S"],tooltip:i("editor.strike.tooltip")}})}}});exports.RichTextStrike=v;exports.Strike=d;
|
package/lib/Strike.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { M as c,
|
|
1
|
+
import { M as c, f as k, h as l, m as g } from "./index-sVScpCFG.js";
|
|
2
2
|
import { jsx as n, Fragment as h } from "react/jsx-runtime";
|
|
3
|
-
import { A as f } from "./index-
|
|
3
|
+
import { A as f } from "./index-C3zg3DPB.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import { u as M, a as S } from "./useButtonProps-
|
|
5
|
+
import { u as M, a as S } from "./useButtonProps-cMoicZgd.js";
|
|
6
6
|
var v = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/, A = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g, y = c.create({
|
|
7
7
|
name: "strike",
|
|
8
8
|
addOptions() {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { U as de, S as E, Z as Ve, T as $, F as v, x as L, Q as ke, v as Ke, _ as Xe, N as Z, m as J, W as Ue, X as Ge, E as Ee, $ as qe } from "./index-
|
|
1
|
+
import { U as de, S as E, Z as Ve, T as $, F as v, x as L, Q as ke, v as Ke, _ as Xe, N as Z, m as J, W as Ue, X as Ge, E as Ee, $ as qe } from "./index-sVScpCFG.js";
|
|
2
2
|
import { TextSelection as Ze } from "@tiptap/pm/state";
|
|
3
|
-
import { k as Je, D as oe, a as ne } from "./index-
|
|
3
|
+
import { k as Je, D as oe, a as ne } from "./index-DKt5wfAc.js";
|
|
4
4
|
import { jsxs as ee, jsx as k, Fragment as Ye } from "react/jsx-runtime";
|
|
5
|
-
import { A as Qe } from "./index-
|
|
5
|
+
import { A as Qe } from "./index-C3zg3DPB.js";
|
|
6
6
|
import { useState as _ } from "react";
|
|
7
7
|
import { T as O, n as F, o as j } from "./index-0OnGZkVF.js";
|
|
8
|
-
import { P as et, a as tt, b as ot } from "./popover-
|
|
9
|
-
import { c as nt, u as lt, a as rt } from "./useButtonProps-
|
|
8
|
+
import { P as et, a as tt, b as ot } from "./popover-B7ec5-u2.js";
|
|
9
|
+
import { c as nt, u as lt, a as rt } from "./useButtonProps-cMoicZgd.js";
|
|
10
10
|
let le, re;
|
|
11
11
|
if (typeof WeakMap < "u") {
|
|
12
12
|
let t = /* @__PURE__ */ new WeakMap();
|