@yuku123/z-team-component 0.2.80 → 0.2.83
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/ChangeLogView-_bRZ55Yi.js +542 -0
- package/dist/ComponentDoc-BFoF51we.js +3998 -0
- package/dist/InvitationManagementPage-CTPCZXHu.js +495 -0
- package/dist/OnboardingPage-DwtuTL61.js +393 -0
- package/dist/ScheduledTasks-yeTm2bOY.js +9407 -0
- package/dist/SystemShell-D9OzKxL-.js +689 -0
- package/dist/_commonjsHelpers-B52_cu2H.js +26 -0
- package/dist/api-CIhVblfa.js +2155 -0
- package/dist/api-DXLNhtCX.js +20 -0
- package/dist/browser-jb_PFvU3.js +1538 -0
- package/dist/createWorkspaceWsHandler-BWP5S5X3.js +12951 -0
- package/dist/ctc-sso-DtJHC-2M.js +117 -0
- package/dist/echarts-B1OU1xr4.js +16 -0
- package/dist/history-BlrA1eaW.js +41 -0
- package/dist/index-BCp5EtqR.js +914 -0
- package/dist/index-BHrMl3Jq.js +9585 -0
- package/dist/index-BP7WTzVH.js +137 -0
- package/dist/index-B_LJRFsK.js +339 -0
- package/dist/index-BgIheStI.js +133 -0
- package/dist/index-BohoJQPr.js +7631 -0
- package/dist/index-BydWNuk5.js +1229 -0
- package/dist/index-C815hPWS.js +430 -0
- package/dist/index-CBQMS6rx.js +178 -0
- package/dist/index-CESmMALI.js +242 -0
- package/dist/index-CUVdeb8y.js +638 -0
- package/dist/index-CijskN6t.js +316 -0
- package/dist/index-CoBZZQBy.js +112 -0
- package/dist/index-Co_0idJY.js +2936 -0
- package/dist/index-Cvx6rrxD.js +956 -0
- package/dist/index-Cwr5Slv1.js +480 -0
- package/dist/index-CxFAICql.js +42050 -0
- package/dist/index-DK70mOTz.js +143 -0
- package/dist/index-DT80Pwa_.js +5893 -0
- package/dist/index-DWsfQMp8.js +208 -0
- package/dist/index-DhDdFRHC.js +279 -0
- package/dist/index-Dm3wmB0K.js +435 -0
- package/dist/index-DzS6-D3M.js +1640 -0
- package/dist/index-PKkV63Sw.js +1143 -0
- package/dist/index-SbMjh8t4.js +574 -0
- package/dist/index-cdB5K3gx.js +814 -0
- package/dist/index-mnWs_wA3.js +93 -0
- package/dist/index-nU-V276i.js +170 -0
- package/dist/index-nW0ikV2R.js +2700 -0
- package/dist/index-uF04Ucsi.js +8 -0
- package/dist/index-x_7Rmav9.js +118 -0
- package/dist/index.js +10 -0
- package/dist/index.module-CAa-2T7m.js +72 -0
- package/dist/index.module-UI0iz8K0.js +42 -0
- package/dist/{menuPermission-D9NGpBZP.js → menuPermission-DHUqvHfu.js} +1 -1
- package/dist/pages.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,638 @@
|
|
|
1
|
+
import { jsxs as K, jsx as s, Fragment as re } from "react/jsx-runtime";
|
|
2
|
+
import { BoldOutlined as ne, ItalicOutlined as ie, StrikethroughOutlined as oe, UnorderedListOutlined as se, OrderedListOutlined as ae, CheckSquareOutlined as ce, CodeOutlined as le, ConsoleSqlOutlined as ue, LinkOutlined as de, PictureOutlined as me, TableOutlined as fe } from "@ant-design/icons";
|
|
3
|
+
import { message as O, Empty as U, Tooltip as pe, Button as ge } from "antd";
|
|
4
|
+
import { useRef as M, useState as he, useEffect as A, forwardRef as we, useImperativeHandle as ye, useCallback as L } from "react";
|
|
5
|
+
import Ee from "vditor";
|
|
6
|
+
import ve from "react-markdown";
|
|
7
|
+
import _e from "rehype-highlight";
|
|
8
|
+
import Me from "remark-gfm";
|
|
9
|
+
const be = "_wrap_ihp63_1", Te = "_live_ihp63_11", ke = "_mdToolbar_ihp63_158", Le = "_mdBtn_ihp63_169", Se = "_mdSep_ihp63_185", De = "_textarea_ihp63_193", Ce = "_preview_ihp63_207", qe = "_mermaid_ihp63_298", xe = "_mermaidError_ihp63_309", Ae = "_mermaidErrorTitle_ihp63_317", Pe = "_mermaidErrorMsg_ihp63_324", Be = "_mermaidSource_ihp63_331", g = {
|
|
10
|
+
wrap: be,
|
|
11
|
+
live: Te,
|
|
12
|
+
mdToolbar: ke,
|
|
13
|
+
mdBtn: Le,
|
|
14
|
+
mdSep: Se,
|
|
15
|
+
textarea: De,
|
|
16
|
+
preview: Ce,
|
|
17
|
+
mermaid: qe,
|
|
18
|
+
mermaidError: xe,
|
|
19
|
+
mermaidErrorTitle: Ae,
|
|
20
|
+
mermaidErrorMsg: Pe,
|
|
21
|
+
mermaidSource: Be
|
|
22
|
+
}, Re = /* @__PURE__ */ new Set(["sequencediagram", "sequence"]), Fe = "\n```mermaid\nflowchart TD\n A[开始] --> B[结束]\n```\n", Ne = `
|
|
23
|
+
\`\`\`mermaid
|
|
24
|
+
sequenceDiagram
|
|
25
|
+
participant A as 用户
|
|
26
|
+
participant B as 系统
|
|
27
|
+
A->>B: 请求
|
|
28
|
+
B-->>A: 响应
|
|
29
|
+
\`\`\`
|
|
30
|
+
`;
|
|
31
|
+
function Oe(t) {
|
|
32
|
+
return t ? /\blanguage-(mermaid|sequencediagram|sequence)\b/i.test(t) : !1;
|
|
33
|
+
}
|
|
34
|
+
function Ie(t, i) {
|
|
35
|
+
const r = t.replace(/\r\n/g, `
|
|
36
|
+
`).trim();
|
|
37
|
+
if (!r) return r;
|
|
38
|
+
const a = (i || "").replace(/^language-/i, "").toLowerCase();
|
|
39
|
+
return Re.has(a) && !/^sequenceDiagram\b/i.test(r) ? `sequenceDiagram
|
|
40
|
+
${r}` : r;
|
|
41
|
+
}
|
|
42
|
+
let I = null, Q = !1;
|
|
43
|
+
function Ke() {
|
|
44
|
+
const t = window.publicPath || "/";
|
|
45
|
+
return `${String(t).replace(/\/$/, "")}/vditor`;
|
|
46
|
+
}
|
|
47
|
+
function $e(t) {
|
|
48
|
+
return new Promise((i, r) => {
|
|
49
|
+
if (window.mermaid) {
|
|
50
|
+
i();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const a = document.querySelector(`script[src="${t}"]`);
|
|
54
|
+
if (a) {
|
|
55
|
+
a.addEventListener("load", () => i(), { once: !0 }), a.addEventListener(
|
|
56
|
+
"error",
|
|
57
|
+
() => r(new Error("mermaid load failed")),
|
|
58
|
+
{ once: !0 }
|
|
59
|
+
);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const l = document.createElement("script");
|
|
63
|
+
l.src = t, l.async = !0, l.onload = () => i(), l.onerror = () => r(new Error("mermaid load failed")), document.head.appendChild(l);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function je() {
|
|
67
|
+
return Q && window.mermaid ? Promise.resolve() : (I || (I = $e(
|
|
68
|
+
`${Ke()}/dist/js/mermaid/mermaid.min.js?v=11.16.1`
|
|
69
|
+
).then(() => {
|
|
70
|
+
if (!window.mermaid)
|
|
71
|
+
throw new Error("mermaid unavailable");
|
|
72
|
+
window.mermaid.initialize({
|
|
73
|
+
securityLevel: "loose",
|
|
74
|
+
startOnLoad: !1,
|
|
75
|
+
fontFamily: "sans-serif",
|
|
76
|
+
altFontFamily: "sans-serif",
|
|
77
|
+
flowchart: { htmlLabels: !0, useMaxWidth: !0 },
|
|
78
|
+
sequence: {
|
|
79
|
+
useMaxWidth: !0,
|
|
80
|
+
diagramMarginX: 8,
|
|
81
|
+
diagramMarginY: 8,
|
|
82
|
+
boxMargin: 8,
|
|
83
|
+
showSequenceNumbers: !0
|
|
84
|
+
}
|
|
85
|
+
}), Q = !0;
|
|
86
|
+
})), I);
|
|
87
|
+
}
|
|
88
|
+
let He = 0;
|
|
89
|
+
async function J(t, i) {
|
|
90
|
+
await je();
|
|
91
|
+
const r = window.mermaid;
|
|
92
|
+
if (!r)
|
|
93
|
+
throw new Error("mermaid unavailable");
|
|
94
|
+
const a = `team-mermaid-${++He}`, l = Ie(t, i);
|
|
95
|
+
return (await r.render(a, l)).svg;
|
|
96
|
+
}
|
|
97
|
+
async function X(t, i) {
|
|
98
|
+
const r = t.firstElementChild;
|
|
99
|
+
if (!r) return;
|
|
100
|
+
const a = r.textContent || "";
|
|
101
|
+
try {
|
|
102
|
+
const l = await J(a, i);
|
|
103
|
+
r.innerHTML = l, r.classList.add("language-mermaid");
|
|
104
|
+
} catch (l) {
|
|
105
|
+
const f = l instanceof Error ? l.message : "Mermaid 渲染失败";
|
|
106
|
+
r.innerHTML = `<pre class="vditor-mermaid-error">${f}</pre>`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function We({ code: t, lang: i }) {
|
|
110
|
+
const r = M(null), [a, l] = he(null);
|
|
111
|
+
return A(() => {
|
|
112
|
+
let f = !1;
|
|
113
|
+
if (!t.trim()) {
|
|
114
|
+
l(null), r.current && (r.current.innerHTML = "");
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
return l(null), J(t, i).then((w) => {
|
|
118
|
+
f || !r.current || (r.current.innerHTML = w);
|
|
119
|
+
}).catch((w) => {
|
|
120
|
+
f || (l(w instanceof Error ? w.message : "Mermaid 渲染失败"), r.current && (r.current.innerHTML = ""));
|
|
121
|
+
}), () => {
|
|
122
|
+
f = !0;
|
|
123
|
+
};
|
|
124
|
+
}, [t, i]), a ? /* @__PURE__ */ K("div", { className: g.mermaidError, children: [
|
|
125
|
+
/* @__PURE__ */ s("div", { className: g.mermaidErrorTitle, children: "Mermaid 渲染失败" }),
|
|
126
|
+
/* @__PURE__ */ s("pre", { className: g.mermaidErrorMsg, children: a }),
|
|
127
|
+
/* @__PURE__ */ s("pre", { className: g.mermaidSource, children: t })
|
|
128
|
+
] }) : /* @__PURE__ */ s("div", { ref: r, className: g.mermaid });
|
|
129
|
+
}
|
|
130
|
+
function $(t) {
|
|
131
|
+
var i;
|
|
132
|
+
return typeof t == "string" ? t.replace(/\n$/, "") : Array.isArray(t) ? t.map((r) => $(r)).join("") : t && typeof t == "object" && "props" in t ? $(((i = t.props) == null ? void 0 : i.children) ?? "") : String(t ?? "").replace(/\n$/, "");
|
|
133
|
+
}
|
|
134
|
+
const ze = {
|
|
135
|
+
pre({ children: t }) {
|
|
136
|
+
return /* @__PURE__ */ s("pre", { children: t });
|
|
137
|
+
},
|
|
138
|
+
code({ className: t, children: i, ...r }) {
|
|
139
|
+
const a = $(i);
|
|
140
|
+
if (Oe(t)) {
|
|
141
|
+
const l = t == null ? void 0 : t.match(/\blanguage-([\w-]+)/i);
|
|
142
|
+
return /* @__PURE__ */ s(We, { code: a, lang: l == null ? void 0 : l[1] });
|
|
143
|
+
}
|
|
144
|
+
return /* @__PURE__ */ s("code", { className: t, ...r, children: i });
|
|
145
|
+
}
|
|
146
|
+
}, Ve = [
|
|
147
|
+
[
|
|
148
|
+
_e,
|
|
149
|
+
{
|
|
150
|
+
filter: (t) => {
|
|
151
|
+
var r;
|
|
152
|
+
const i = (r = t.properties) == null ? void 0 : r.className;
|
|
153
|
+
return Array.isArray(i) ? !i.some(
|
|
154
|
+
(a) => a === "language-mermaid" || /^language-sequence/i.test(a)
|
|
155
|
+
) : typeof i == "string" ? !/\blanguage-(mermaid|sequencediagram|sequence)\b/i.test(i) : !0;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
];
|
|
160
|
+
function Ge({ children: t, className: i }) {
|
|
161
|
+
return /* @__PURE__ */ s("div", { className: i, children: /* @__PURE__ */ s(
|
|
162
|
+
ve,
|
|
163
|
+
{
|
|
164
|
+
remarkPlugins: [Me],
|
|
165
|
+
rehypePlugins: Ve,
|
|
166
|
+
components: ze,
|
|
167
|
+
children: t
|
|
168
|
+
}
|
|
169
|
+
) });
|
|
170
|
+
}
|
|
171
|
+
const Ue = [
|
|
172
|
+
"headings",
|
|
173
|
+
"bold",
|
|
174
|
+
"italic",
|
|
175
|
+
"strike",
|
|
176
|
+
"|",
|
|
177
|
+
"quote",
|
|
178
|
+
"list",
|
|
179
|
+
"ordered-list",
|
|
180
|
+
"check",
|
|
181
|
+
"|",
|
|
182
|
+
"code",
|
|
183
|
+
"inline-code",
|
|
184
|
+
"link",
|
|
185
|
+
"upload",
|
|
186
|
+
"table",
|
|
187
|
+
"line",
|
|
188
|
+
"|",
|
|
189
|
+
"undo",
|
|
190
|
+
"redo"
|
|
191
|
+
], Qe = Fe;
|
|
192
|
+
function Xe() {
|
|
193
|
+
const t = window.publicPath || "/";
|
|
194
|
+
return `${String(t).replace(/\/$/, "")}/vditor`;
|
|
195
|
+
}
|
|
196
|
+
function Ye(t, i, r, a, l, f) {
|
|
197
|
+
const S = t.slice(i, r) || f, w = a + S + l;
|
|
198
|
+
return {
|
|
199
|
+
content: t.slice(0, i) + w + t.slice(r),
|
|
200
|
+
selectFrom: i + a.length,
|
|
201
|
+
selectTo: i + a.length + S.length
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function Je(t, i, r, a) {
|
|
205
|
+
const f = t.slice(0, i).lastIndexOf(`
|
|
206
|
+
`) + 1, w = t.slice(f, r).split(`
|
|
207
|
+
`).map((P) => P.startsWith(a) ? P.slice(a.length) : a + P).join(`
|
|
208
|
+
`);
|
|
209
|
+
return {
|
|
210
|
+
content: t.slice(0, f) + w + t.slice(r),
|
|
211
|
+
selectFrom: f,
|
|
212
|
+
selectTo: f + w.length
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function Y(t, i, r, a) {
|
|
216
|
+
return {
|
|
217
|
+
content: t.slice(0, i) + a + t.slice(r),
|
|
218
|
+
selectFrom: i,
|
|
219
|
+
selectTo: i + a.length
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
function Ze(t) {
|
|
223
|
+
return /^https?:\/\/.+\.(png|jpg|jpeg|gif|webp|svg|bmp|ico)(\?.*)?$/i.test(
|
|
224
|
+
t
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
const ct = we(function({
|
|
228
|
+
mode: i,
|
|
229
|
+
value: r,
|
|
230
|
+
onChange: a,
|
|
231
|
+
readOnly: l = !1,
|
|
232
|
+
onUploadImage: f,
|
|
233
|
+
placeholder: S = "在此输入 Markdown,支持工具栏 / 快捷键 / 粘贴或拖拽图片…",
|
|
234
|
+
onSave: w
|
|
235
|
+
}, P) {
|
|
236
|
+
const j = M(null), R = M(null), D = M(null), H = M(null), W = M(null), z = M(a), E = M(w), N = M(f), b = M(r), V = (e) => {
|
|
237
|
+
if (e)
|
|
238
|
+
try {
|
|
239
|
+
e.destroy();
|
|
240
|
+
} catch {
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
A(() => {
|
|
244
|
+
z.current = a;
|
|
245
|
+
}, [a]), A(() => {
|
|
246
|
+
E.current = w;
|
|
247
|
+
}, [w]), A(() => {
|
|
248
|
+
N.current = f;
|
|
249
|
+
}, [f]), A(() => {
|
|
250
|
+
b.current = r;
|
|
251
|
+
}, [r]), ye(P, () => ({
|
|
252
|
+
getTextarea: () => D.current,
|
|
253
|
+
getLiveRoot: () => R.current
|
|
254
|
+
}));
|
|
255
|
+
const T = L((e) => {
|
|
256
|
+
b.current = e, z.current(e);
|
|
257
|
+
}, []);
|
|
258
|
+
A(() => {
|
|
259
|
+
if (l || i !== "live") return;
|
|
260
|
+
const e = R.current;
|
|
261
|
+
if (!e) return;
|
|
262
|
+
let n = !1, c = !1;
|
|
263
|
+
const u = { current: null }, y = (o) => {
|
|
264
|
+
var h;
|
|
265
|
+
const m = `
|
|
266
|
+

|
|
267
|
+
`;
|
|
268
|
+
(h = u.current) == null || h.insertValue(m);
|
|
269
|
+
}, _ = async (o) => {
|
|
270
|
+
const m = N.current;
|
|
271
|
+
if (!m) return "未配置图片上传";
|
|
272
|
+
const h = o.filter((x) => x.type.startsWith("image/"));
|
|
273
|
+
if (h.length === 0) return "仅支持上传图片";
|
|
274
|
+
const q = O.loading("上传图片中...", 0);
|
|
275
|
+
try {
|
|
276
|
+
for (const x of h) {
|
|
277
|
+
const G = await m(x);
|
|
278
|
+
G && y(G);
|
|
279
|
+
}
|
|
280
|
+
return null;
|
|
281
|
+
} catch {
|
|
282
|
+
return "图片上传失败";
|
|
283
|
+
} finally {
|
|
284
|
+
q();
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
u.current = new Ee(e, {
|
|
288
|
+
cdn: Xe(),
|
|
289
|
+
mode: "ir",
|
|
290
|
+
value: b.current,
|
|
291
|
+
height: "100%",
|
|
292
|
+
lang: "zh_CN",
|
|
293
|
+
icon: "ant",
|
|
294
|
+
placeholder: S,
|
|
295
|
+
cache: { enable: !1 },
|
|
296
|
+
toolbar: Ue,
|
|
297
|
+
toolbarConfig: { pin: !0 },
|
|
298
|
+
hint: { emoji: {} },
|
|
299
|
+
// maxWidth 默认 800 会居中留白;设大后左右只剩最小 padding,铺满可用宽度
|
|
300
|
+
preview: {
|
|
301
|
+
maxWidth: 9999,
|
|
302
|
+
hljs: { enable: !0, lineNumber: !1, style: "github" },
|
|
303
|
+
math: { engine: "KaTeX", inlineDigit: !1 },
|
|
304
|
+
// 代码块默认渲染高亮预览;点进块内才编辑源码(配合 CSS 互斥显示)
|
|
305
|
+
//
|
|
306
|
+
// 原来写的是顶层 `markdown: {codeBlockPreview, mathBlockPreview}`,
|
|
307
|
+
// 但 vditor 4 运行时读的是 options.preview.markdown.codeBlockPreview
|
|
308
|
+
// (见 vditor/src/index.ts:561 与 previewRender.ts:66),
|
|
309
|
+
// 顶层那份从未生效。
|
|
310
|
+
// 另:vditor 4 的 IPreviewOptions["markdown"] 类型也漏了
|
|
311
|
+
// codeBlockPreview/mathBlockPreview(上游类型 bug),故用 as 收口。
|
|
312
|
+
markdown: {
|
|
313
|
+
codeBlockPreview: !0,
|
|
314
|
+
mathBlockPreview: !0
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
customRenders: [
|
|
318
|
+
{
|
|
319
|
+
language: "sequenceDiagram",
|
|
320
|
+
render: (o) => {
|
|
321
|
+
X(o, "sequenceDiagram");
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
language: "sequence",
|
|
326
|
+
render: (o) => {
|
|
327
|
+
X(o, "sequence");
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
],
|
|
331
|
+
after: () => {
|
|
332
|
+
if (n) {
|
|
333
|
+
V(u.current);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
c = !0;
|
|
337
|
+
},
|
|
338
|
+
input: (o) => {
|
|
339
|
+
c && T(o);
|
|
340
|
+
},
|
|
341
|
+
keydown: (o) => {
|
|
342
|
+
var m;
|
|
343
|
+
(o.ctrlKey || o.metaKey) && o.key.toLowerCase() === "s" && (o.preventDefault(), (m = E.current) == null || m.call(E));
|
|
344
|
+
},
|
|
345
|
+
upload: {
|
|
346
|
+
accept: "image/*",
|
|
347
|
+
multiple: !0,
|
|
348
|
+
filename: (o) => o,
|
|
349
|
+
handler: (o) => _(o)
|
|
350
|
+
}
|
|
351
|
+
}), W.current = u.current;
|
|
352
|
+
const p = (o) => {
|
|
353
|
+
var m;
|
|
354
|
+
(o.ctrlKey || o.metaKey) && o.key.toLowerCase() === "s" && (o.preventDefault(), (m = E.current) == null || m.call(E));
|
|
355
|
+
};
|
|
356
|
+
return e.addEventListener("keydown", p), () => {
|
|
357
|
+
n = !0, e.removeEventListener("keydown", p), V(u.current), W.current = null;
|
|
358
|
+
};
|
|
359
|
+
}, [i, l, S, T]);
|
|
360
|
+
const k = L(
|
|
361
|
+
(e) => {
|
|
362
|
+
T(e.content);
|
|
363
|
+
const n = D.current;
|
|
364
|
+
n && requestAnimationFrame(() => {
|
|
365
|
+
n.focus(), n.setSelectionRange(e.selectFrom, e.selectTo);
|
|
366
|
+
});
|
|
367
|
+
},
|
|
368
|
+
[T]
|
|
369
|
+
), v = L(
|
|
370
|
+
(e, n, c) => {
|
|
371
|
+
const u = D.current;
|
|
372
|
+
u && k(
|
|
373
|
+
Ye(
|
|
374
|
+
u.value,
|
|
375
|
+
u.selectionStart,
|
|
376
|
+
u.selectionEnd,
|
|
377
|
+
e,
|
|
378
|
+
n,
|
|
379
|
+
c
|
|
380
|
+
)
|
|
381
|
+
);
|
|
382
|
+
},
|
|
383
|
+
[k]
|
|
384
|
+
), C = L(
|
|
385
|
+
(e) => {
|
|
386
|
+
const n = D.current;
|
|
387
|
+
n && k(
|
|
388
|
+
Je(n.value, n.selectionStart, n.selectionEnd, e)
|
|
389
|
+
);
|
|
390
|
+
},
|
|
391
|
+
[k]
|
|
392
|
+
), F = L(
|
|
393
|
+
(e) => {
|
|
394
|
+
const n = D.current;
|
|
395
|
+
n && k(Y(n.value, n.selectionStart, n.selectionEnd, e));
|
|
396
|
+
},
|
|
397
|
+
[k]
|
|
398
|
+
), B = L(
|
|
399
|
+
async (e) => {
|
|
400
|
+
const n = N.current;
|
|
401
|
+
if (!n) return;
|
|
402
|
+
const c = D.current, u = (c == null ? void 0 : c.selectionStart) ?? b.current.length, y = (c == null ? void 0 : c.selectionEnd) ?? b.current.length, _ = O.loading("上传图片中...", 0);
|
|
403
|
+
try {
|
|
404
|
+
const o = `
|
|
405
|
+
})
|
|
406
|
+
`, m = b.current.slice(0, u) + o + b.current.slice(y);
|
|
407
|
+
T(m), requestAnimationFrame(() => {
|
|
408
|
+
if (c) {
|
|
409
|
+
const h = u + o.length;
|
|
410
|
+
c.focus(), c.setSelectionRange(h, h);
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
} catch {
|
|
414
|
+
O.error("图片上传失败");
|
|
415
|
+
} finally {
|
|
416
|
+
_();
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
[T]
|
|
420
|
+
), Z = L(
|
|
421
|
+
async (e) => {
|
|
422
|
+
var y, _;
|
|
423
|
+
const n = (y = e.clipboardData) == null ? void 0 : y.items;
|
|
424
|
+
if (!n) return;
|
|
425
|
+
const c = [];
|
|
426
|
+
for (let p = 0; p < n.length; p++) {
|
|
427
|
+
const o = n[p];
|
|
428
|
+
if (o.kind === "file" && o.type.startsWith("image/")) {
|
|
429
|
+
const m = o.getAsFile();
|
|
430
|
+
m && c.push(m);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
if (c.length > 0) {
|
|
434
|
+
e.preventDefault();
|
|
435
|
+
for (const p of c)
|
|
436
|
+
await B(p);
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
const u = (_ = e.clipboardData.getData("text/plain")) == null ? void 0 : _.trim();
|
|
440
|
+
if (u && Ze(u)) {
|
|
441
|
+
e.preventDefault();
|
|
442
|
+
const p = e.currentTarget, o = p.selectionStart, m = p.selectionEnd, h = `
|
|
443
|
+

|
|
444
|
+
`, q = b.current.slice(0, o) + h + b.current.slice(m);
|
|
445
|
+
T(q), requestAnimationFrame(() => {
|
|
446
|
+
const x = o + h.length;
|
|
447
|
+
p.focus(), p.setSelectionRange(x, x);
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
},
|
|
451
|
+
[T, B]
|
|
452
|
+
), ee = L(
|
|
453
|
+
(e) => {
|
|
454
|
+
var u;
|
|
455
|
+
const n = (u = e.dataTransfer) == null ? void 0 : u.files;
|
|
456
|
+
if (!n || n.length === 0) return;
|
|
457
|
+
const c = Array.from(n).filter(
|
|
458
|
+
(y) => y.type.startsWith("image/")
|
|
459
|
+
);
|
|
460
|
+
if (c.length !== 0) {
|
|
461
|
+
e.preventDefault();
|
|
462
|
+
for (const y of c)
|
|
463
|
+
B(y);
|
|
464
|
+
}
|
|
465
|
+
},
|
|
466
|
+
[B]
|
|
467
|
+
), te = L(
|
|
468
|
+
(e) => {
|
|
469
|
+
var u;
|
|
470
|
+
const n = e.currentTarget, c = e.ctrlKey || e.metaKey;
|
|
471
|
+
if (e.key === "Tab") {
|
|
472
|
+
e.preventDefault();
|
|
473
|
+
const { selectionStart: y, selectionEnd: _ } = n;
|
|
474
|
+
if (e.shiftKey) {
|
|
475
|
+
const o = n.value.slice(0, y).lastIndexOf(`
|
|
476
|
+
`) + 1, h = n.value.slice(o, _).split(`
|
|
477
|
+
`).map((q) => q.startsWith(" ") ? q.slice(2) : q.replace(/^ /, "")).join(`
|
|
478
|
+
`);
|
|
479
|
+
k({
|
|
480
|
+
content: n.value.slice(0, o) + h + n.value.slice(_),
|
|
481
|
+
selectFrom: o,
|
|
482
|
+
selectTo: o + h.length
|
|
483
|
+
});
|
|
484
|
+
} else
|
|
485
|
+
k(Y(n.value, y, _, " "));
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
c && !e.shiftKey && e.key.toLowerCase() === "b" ? (e.preventDefault(), v("**", "**", "加粗")) : c && !e.shiftKey && e.key.toLowerCase() === "i" ? (e.preventDefault(), v("*", "*", "斜体")) : c && !e.shiftKey && e.key.toLowerCase() === "k" ? (e.preventDefault(), v("[", "](url)", "链接文本")) : c && e.key.toLowerCase() === "s" && (e.preventDefault(), (u = E.current) == null || u.call(E));
|
|
489
|
+
},
|
|
490
|
+
[k, v]
|
|
491
|
+
), d = (e, n, c, u) => /* @__PURE__ */ s(pe, { title: c, children: /* @__PURE__ */ s(
|
|
492
|
+
ge,
|
|
493
|
+
{
|
|
494
|
+
size: "small",
|
|
495
|
+
type: "text",
|
|
496
|
+
className: g.mdBtn,
|
|
497
|
+
icon: n,
|
|
498
|
+
onClick: u
|
|
499
|
+
}
|
|
500
|
+
) }, e);
|
|
501
|
+
return l ? /* @__PURE__ */ s("div", { ref: j, className: g.wrap, children: /* @__PURE__ */ s("div", { ref: R, className: g.preview, children: r ? /* @__PURE__ */ s(Ge, { children: r }) : /* @__PURE__ */ s(
|
|
502
|
+
U,
|
|
503
|
+
{
|
|
504
|
+
description: "暂无内容",
|
|
505
|
+
image: U.PRESENTED_IMAGE_SIMPLE
|
|
506
|
+
}
|
|
507
|
+
) }) }) : /* @__PURE__ */ s("div", { ref: j, className: g.wrap, children: i === "live" ? /* @__PURE__ */ s("div", { ref: R, className: g.live }) : /* @__PURE__ */ K(re, { children: [
|
|
508
|
+
/* @__PURE__ */ K("div", { className: g.mdToolbar, children: [
|
|
509
|
+
d("h1", "H1", "一级标题", () => C("# ")),
|
|
510
|
+
d("h2", "H2", "二级标题", () => C("## ")),
|
|
511
|
+
d("h3", "H3", "三级标题", () => C("### ")),
|
|
512
|
+
/* @__PURE__ */ s("span", { className: g.mdSep }),
|
|
513
|
+
d(
|
|
514
|
+
"bold",
|
|
515
|
+
/* @__PURE__ */ s(ne, {}),
|
|
516
|
+
"加粗 Ctrl+B",
|
|
517
|
+
() => v("**", "**", "加粗")
|
|
518
|
+
),
|
|
519
|
+
d(
|
|
520
|
+
"italic",
|
|
521
|
+
/* @__PURE__ */ s(ie, {}),
|
|
522
|
+
"斜体 Ctrl+I",
|
|
523
|
+
() => v("*", "*", "斜体")
|
|
524
|
+
),
|
|
525
|
+
d(
|
|
526
|
+
"strike",
|
|
527
|
+
/* @__PURE__ */ s(oe, {}),
|
|
528
|
+
"删除线",
|
|
529
|
+
() => v("~~", "~~", "删除线")
|
|
530
|
+
),
|
|
531
|
+
/* @__PURE__ */ s("span", { className: g.mdSep }),
|
|
532
|
+
d("quote", "❝", "引用", () => C("> ")),
|
|
533
|
+
d(
|
|
534
|
+
"ul",
|
|
535
|
+
/* @__PURE__ */ s(se, {}),
|
|
536
|
+
"无序列表",
|
|
537
|
+
() => C("- ")
|
|
538
|
+
),
|
|
539
|
+
d(
|
|
540
|
+
"ol",
|
|
541
|
+
/* @__PURE__ */ s(ae, {}),
|
|
542
|
+
"有序列表",
|
|
543
|
+
() => C("1. ")
|
|
544
|
+
),
|
|
545
|
+
d(
|
|
546
|
+
"task",
|
|
547
|
+
/* @__PURE__ */ s(ce, {}),
|
|
548
|
+
"任务列表",
|
|
549
|
+
() => C("- [ ] ")
|
|
550
|
+
),
|
|
551
|
+
/* @__PURE__ */ s("span", { className: g.mdSep }),
|
|
552
|
+
d(
|
|
553
|
+
"code",
|
|
554
|
+
/* @__PURE__ */ s(le, {}),
|
|
555
|
+
"代码块",
|
|
556
|
+
() => v("```ts\n", "\n```", "code")
|
|
557
|
+
),
|
|
558
|
+
d(
|
|
559
|
+
"inlineCode",
|
|
560
|
+
/* @__PURE__ */ s(ue, {}),
|
|
561
|
+
"行内代码",
|
|
562
|
+
() => v("`", "`", "code")
|
|
563
|
+
),
|
|
564
|
+
d(
|
|
565
|
+
"link",
|
|
566
|
+
/* @__PURE__ */ s(de, {}),
|
|
567
|
+
"链接 Ctrl+K",
|
|
568
|
+
() => v("[", "](url)", "链接文本")
|
|
569
|
+
),
|
|
570
|
+
d(
|
|
571
|
+
"image",
|
|
572
|
+
/* @__PURE__ */ s(me, {}),
|
|
573
|
+
"图片(可粘贴/拖拽)",
|
|
574
|
+
() => {
|
|
575
|
+
var e;
|
|
576
|
+
return (e = H.current) == null ? void 0 : e.click();
|
|
577
|
+
}
|
|
578
|
+
),
|
|
579
|
+
d(
|
|
580
|
+
"table",
|
|
581
|
+
/* @__PURE__ */ s(fe, {}),
|
|
582
|
+
"表格",
|
|
583
|
+
() => F(`
|
|
584
|
+
| 列1 | 列2 | 列3 |
|
|
585
|
+
| --- | --- | --- |
|
|
586
|
+
| | | |
|
|
587
|
+
`)
|
|
588
|
+
),
|
|
589
|
+
d("hr", "—", "分割线", () => F(`
|
|
590
|
+
---
|
|
591
|
+
`)),
|
|
592
|
+
d(
|
|
593
|
+
"mermaid",
|
|
594
|
+
"M",
|
|
595
|
+
"Mermaid 流程图",
|
|
596
|
+
() => F(Qe)
|
|
597
|
+
),
|
|
598
|
+
d(
|
|
599
|
+
"sequence",
|
|
600
|
+
"Seq",
|
|
601
|
+
"Mermaid 时序图",
|
|
602
|
+
() => F(Ne)
|
|
603
|
+
)
|
|
604
|
+
] }),
|
|
605
|
+
/* @__PURE__ */ s(
|
|
606
|
+
"textarea",
|
|
607
|
+
{
|
|
608
|
+
ref: D,
|
|
609
|
+
className: g.textarea,
|
|
610
|
+
value: r,
|
|
611
|
+
onChange: (e) => T(e.target.value),
|
|
612
|
+
onKeyDown: te,
|
|
613
|
+
onPaste: Z,
|
|
614
|
+
onDrop: ee,
|
|
615
|
+
onDragOver: (e) => e.preventDefault(),
|
|
616
|
+
placeholder: S,
|
|
617
|
+
spellCheck: !1
|
|
618
|
+
}
|
|
619
|
+
),
|
|
620
|
+
/* @__PURE__ */ s(
|
|
621
|
+
"input",
|
|
622
|
+
{
|
|
623
|
+
ref: H,
|
|
624
|
+
type: "file",
|
|
625
|
+
accept: "image/*",
|
|
626
|
+
style: { display: "none" },
|
|
627
|
+
onChange: (e) => {
|
|
628
|
+
var c;
|
|
629
|
+
const n = (c = e.target.files) == null ? void 0 : c[0];
|
|
630
|
+
n && B(n), e.target.value = "";
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
)
|
|
634
|
+
] }) });
|
|
635
|
+
});
|
|
636
|
+
export {
|
|
637
|
+
ct as M
|
|
638
|
+
};
|