@qingwu-ui/ai-editor 0.9.0-beta.14 → 0.9.0-beta.16
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/components/toc.d.ts.map +1 -1
- package/dist/editor/ai-editor.d.ts.map +1 -1
- package/dist/editor/extensions/code-block-view.d.ts.map +1 -1
- package/dist/editor/extensions/code-block.d.ts.map +1 -1
- package/dist/editor/extensions/slash-command.d.ts.map +1 -1
- package/dist/index.cjs +11 -10
- package/dist/index.js +1317 -1103
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,59 +6,59 @@ import { Suspense as v, lazy as y, useCallback as b, useEffect as x, useLayoutEf
|
|
|
6
6
|
import { Fragment as E, jsx as D, jsxs as O } from "react/jsx-runtime";
|
|
7
7
|
import { generateText as k, streamText as A } from "ai";
|
|
8
8
|
import { DOMParser as j, Fragment as M, Slice as N } from "@tiptap/pm/model";
|
|
9
|
-
import { EditorContent as P,
|
|
9
|
+
import { EditorContent as P, NodeViewWrapper as F, ReactNodeViewRenderer as I, ReactRenderer as L, useEditor as ee } from "@tiptap/react";
|
|
10
10
|
import { BubbleMenu as te } from "@tiptap/react/menus";
|
|
11
11
|
import { createPortal as ne } from "react-dom";
|
|
12
12
|
import { Extension as R, Node as re } from "@tiptap/core";
|
|
13
|
-
import { NodeSelection as ie, Plugin as z, PluginKey as B, TextSelection as
|
|
14
|
-
import { Decoration as
|
|
15
|
-
import { Image as
|
|
16
|
-
import { Link as
|
|
17
|
-
import { Underline as
|
|
18
|
-
import
|
|
19
|
-
import { CharacterCount as
|
|
20
|
-
import { Color as
|
|
21
|
-
import { Highlight as
|
|
22
|
-
import { HorizontalRule as
|
|
23
|
-
import { Placeholder as
|
|
24
|
-
import { Table as
|
|
25
|
-
import { TableCell as
|
|
26
|
-
import { TableHeader as
|
|
27
|
-
import { TableRow as
|
|
28
|
-
import { TaskItem as
|
|
29
|
-
import { TaskList as
|
|
30
|
-
import { TextStyle as
|
|
31
|
-
import { Markdown as
|
|
32
|
-
import { CodeBlockLowlight as
|
|
33
|
-
import
|
|
34
|
-
import { common as
|
|
35
|
-
import
|
|
13
|
+
import { NodeSelection as ie, Plugin as z, PluginKey as B, TextSelection as V } from "@tiptap/pm/state";
|
|
14
|
+
import { Decoration as H, DecorationSet as ae } from "@tiptap/pm/view";
|
|
15
|
+
import { Image as oe } from "@tiptap/extension-image";
|
|
16
|
+
import { Link as U } from "@tiptap/extension-link";
|
|
17
|
+
import { Underline as W } from "@tiptap/extension-underline";
|
|
18
|
+
import G from "@tiptap/starter-kit";
|
|
19
|
+
import { CharacterCount as K } from "@tiptap/extension-character-count";
|
|
20
|
+
import { Color as q } from "@tiptap/extension-color";
|
|
21
|
+
import { Highlight as se } from "@tiptap/extension-highlight";
|
|
22
|
+
import { HorizontalRule as ce } from "@tiptap/extension-horizontal-rule";
|
|
23
|
+
import { Placeholder as J } from "@tiptap/extension-placeholder";
|
|
24
|
+
import { Table as le } from "@tiptap/extension-table";
|
|
25
|
+
import { TableCell as ue } from "@tiptap/extension-table-cell";
|
|
26
|
+
import { TableHeader as de } from "@tiptap/extension-table-header";
|
|
27
|
+
import { TableRow as fe } from "@tiptap/extension-table-row";
|
|
28
|
+
import { TaskItem as pe } from "@tiptap/extension-task-item";
|
|
29
|
+
import { TaskList as me } from "@tiptap/extension-task-list";
|
|
30
|
+
import { TextStyle as he } from "@tiptap/extension-text-style";
|
|
31
|
+
import { Markdown as ge } from "tiptap-markdown";
|
|
32
|
+
import { CodeBlockLowlight as _e } from "@tiptap/extension-code-block-lowlight";
|
|
33
|
+
import ve from "highlight.js/lib/languages/dockerfile";
|
|
34
|
+
import { common as ye, createLowlight as be } from "lowlight";
|
|
35
|
+
import xe, { exitSuggestion as Se, findSuggestionMatch as Ce } from "@tiptap/suggestion";
|
|
36
36
|
//#region ../text-layout/dist/index.mjs
|
|
37
|
-
var
|
|
38
|
-
function
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
var
|
|
42
|
-
function
|
|
43
|
-
let n =
|
|
44
|
-
n || (n = /* @__PURE__ */ new Map(),
|
|
37
|
+
var we = null, Te = null;
|
|
38
|
+
function Ee() {
|
|
39
|
+
return Te || (typeof document > "u" ? null : (we = document.createElement("canvas"), Te = we.getContext("2d"), Te));
|
|
40
|
+
}
|
|
41
|
+
var De = /* @__PURE__ */ new Map();
|
|
42
|
+
function Oe(e, t) {
|
|
43
|
+
let n = De.get(t);
|
|
44
|
+
n || (n = /* @__PURE__ */ new Map(), De.set(t, n));
|
|
45
45
|
let r = n.get(e);
|
|
46
46
|
if (r !== void 0) return r;
|
|
47
|
-
let i =
|
|
48
|
-
return i ? (i.font = t, r = i.measureText(e).width) : r =
|
|
47
|
+
let i = Ee();
|
|
48
|
+
return i ? (i.font = t, r = i.measureText(e).width) : r = ke(e, t), n.set(e, r), r;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function ke(e, t) {
|
|
51
51
|
let n = parseFloat(t) || 16, r = 0;
|
|
52
|
-
for (let t of e)
|
|
52
|
+
for (let t of e) Ae(t.codePointAt(0) ?? 0) ? r += n : t === " " ? r += n * .3 : r += n * .55;
|
|
53
53
|
return r;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function Ae(e) {
|
|
56
56
|
return e >= 19968 && e <= 40959 || e >= 13312 && e <= 19903 || e >= 131072 && e <= 173791 || e >= 63744 && e <= 64255 || e >= 194560 && e <= 195103 || e >= 12288 && e <= 12351 || e >= 65280 && e <= 65519 || e >= 11904 && e <= 12031 || e >= 12736 && e <= 12783 || e >= 44032 && e <= 55215;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function Y(e) {
|
|
59
59
|
return e === 12289 || e === 12290 || e === 65292 || e === 65294 || e === 65306 || e === 65307 || e === 65311 || e === 65281 || e === 65289 || e === 65341 || e === 12301 || e === 12303 || e === 12299 || e === 12305;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function je(e, t) {
|
|
62
62
|
let n = [], r = [];
|
|
63
63
|
if (typeof Intl < "u" && Intl.Segmenter) try {
|
|
64
64
|
let t = new Intl.Segmenter("zh", { granularity: "grapheme" });
|
|
@@ -69,27 +69,27 @@ function q(e, t) {
|
|
|
69
69
|
else r = [...e];
|
|
70
70
|
for (let e of r) {
|
|
71
71
|
let r = e.codePointAt(0) ?? 0, i = "latin";
|
|
72
|
-
e === "\n" ? i = "break" : e === " " || e === " " ? i = "space" :
|
|
72
|
+
e === "\n" ? i = "break" : e === " " || e === " " ? i = "space" : Ae(r) && (i = Y(r) ? "punct" : "cjk"), n.push({
|
|
73
73
|
text: e,
|
|
74
|
-
width:
|
|
74
|
+
width: Oe(e, t),
|
|
75
75
|
type: i
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
return n;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function Me(e, t, n) {
|
|
81
81
|
let r = 0, i = Math.min(n, e.length);
|
|
82
82
|
for (let n = t; n < i; n++) r += e[n].width;
|
|
83
83
|
return r;
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function Ne(e, t, n, r) {
|
|
86
86
|
return {
|
|
87
87
|
text: e.slice(t, Math.min(n, e.length)).map((e) => e.text).join(""),
|
|
88
88
|
width: r
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
function Pe(e, t, n = "16px system-ui") {
|
|
92
|
-
let { maxWidth: r, lineHeight: i, maxLines: a, overflowWrap: o = "break-word" } = t, s =
|
|
92
|
+
let { maxWidth: r, lineHeight: i, maxLines: a, overflowWrap: o = "break-word" } = t, s = je(e, n), c = [], l = {
|
|
93
93
|
lineStart: 0,
|
|
94
94
|
lineWidth: 0,
|
|
95
95
|
lastBreakIdx: -1,
|
|
@@ -98,28 +98,28 @@ function Pe(e, t, n = "16px system-ui") {
|
|
|
98
98
|
for (let e = 0; e < s.length; e++) {
|
|
99
99
|
let t = s[e];
|
|
100
100
|
if (t.type === "break") {
|
|
101
|
-
c.push(
|
|
101
|
+
c.push(Ne(s, l.lineStart, e, l.lineWidth)), l.lineStart = e + 1, l.lineWidth = 0, l.lastBreakIdx = -1;
|
|
102
102
|
continue;
|
|
103
103
|
}
|
|
104
104
|
let n = l.lineWidth + t.width;
|
|
105
105
|
if (t.type === "space") {
|
|
106
|
-
if (n > r && l.lineWidth > 0 ? (l.lastBreakIdx >= 0 ? (c.push(
|
|
106
|
+
if (n > r && l.lineWidth > 0 ? (l.lastBreakIdx >= 0 ? (c.push(Ne(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Me(s, l.lineStart, e + 1)) : (c.push(Ne(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width), l.lastBreakIdx = -1) : (l.lineWidth = n, l.lastBreakIdx = e, l.lastBreakWidth = l.lineWidth), a && c.length >= a) break;
|
|
107
107
|
continue;
|
|
108
108
|
}
|
|
109
109
|
if (t.type === "cjk") {
|
|
110
|
-
if (n > r && l.lineWidth > 0 ? (c.push(
|
|
110
|
+
if (n > r && l.lineWidth > 0 ? (c.push(Ne(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width, l.lastBreakIdx = -1) : (l.lineWidth = n, l.lastBreakIdx = e, l.lastBreakWidth = l.lineWidth), a && c.length >= a) break;
|
|
111
111
|
continue;
|
|
112
112
|
}
|
|
113
113
|
if (t.type === "punct") {
|
|
114
|
-
if (l.lineWidth === 0 && c.length > 0 ? c[c.length - 1].text.length > 0 && (l.lineWidth = t.width) : n > r ? (l.lastBreakIdx >= 0 ? (c.push(
|
|
114
|
+
if (l.lineWidth === 0 && c.length > 0 ? c[c.length - 1].text.length > 0 && (l.lineWidth = t.width) : n > r ? (l.lastBreakIdx >= 0 ? (c.push(Ne(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Me(s, l.lineStart, e + 1)) : l.lineWidth = n, l.lastBreakIdx = -1) : l.lineWidth = n, a && c.length >= a) break;
|
|
115
115
|
continue;
|
|
116
116
|
}
|
|
117
|
-
if (n > r && l.lineWidth > 0 ? l.lastBreakIdx >= 0 ? (c.push(
|
|
117
|
+
if (n > r && l.lineWidth > 0 ? l.lastBreakIdx >= 0 ? (c.push(Ne(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Me(s, l.lineStart, e + 1), l.lastBreakIdx = -1) : o === "break-word" ? (c.push(Ne(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width) : l.lineWidth = n : l.lineWidth = n, a && c.length >= a) break;
|
|
118
118
|
}
|
|
119
119
|
let u = l.lineStart < s.length;
|
|
120
120
|
if (u && (!a || c.length < a)) {
|
|
121
|
-
let e =
|
|
122
|
-
c.push(
|
|
121
|
+
let e = Me(s, l.lineStart, s.length);
|
|
122
|
+
c.push(Ne(s, l.lineStart, s.length, e));
|
|
123
123
|
}
|
|
124
124
|
return {
|
|
125
125
|
lines: c,
|
|
@@ -131,7 +131,7 @@ function Pe(e, t, n = "16px system-ui") {
|
|
|
131
131
|
//#endregion
|
|
132
132
|
//#region ../toast/dist/index.mjs
|
|
133
133
|
var Fe = typeof window < "u" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, Ie = "13.5px -apple-system, BlinkMacSystemFont, \"SF Pro Text\", \"PingFang SC\", \"Microsoft YaHei\", system-ui, sans-serif";
|
|
134
|
-
function
|
|
134
|
+
function X() {
|
|
135
135
|
if (typeof window > "u") return 290;
|
|
136
136
|
let e = window.innerWidth;
|
|
137
137
|
return e <= 480 ? Math.max(140, e - 98) : 290;
|
|
@@ -145,21 +145,21 @@ var Le = {
|
|
|
145
145
|
function ze() {
|
|
146
146
|
return `qt${Re++}${Date.now().toString(36)}`;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function Be(e, t, n) {
|
|
149
149
|
let r = document.createElement(e);
|
|
150
150
|
return t && (r.className = t), n != null && (r.innerHTML = n), r;
|
|
151
151
|
}
|
|
152
|
-
function
|
|
152
|
+
function Ve(e, t) {
|
|
153
153
|
let n = t.split(/\*\*(.+?)\*\*/g);
|
|
154
154
|
for (let t = 0; t < n.length; t++) {
|
|
155
155
|
let r = n[t];
|
|
156
156
|
if (r) if (t % 2 == 1) {
|
|
157
|
-
let t =
|
|
157
|
+
let t = Be("em", "qt-mark");
|
|
158
158
|
t.textContent = r, e.appendChild(t);
|
|
159
159
|
} else e.appendChild(document.createTextNode(r));
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
var
|
|
162
|
+
var He = {
|
|
163
163
|
type: "info",
|
|
164
164
|
position: "top-center",
|
|
165
165
|
duration: 4e3,
|
|
@@ -168,19 +168,19 @@ var Ve = {
|
|
|
168
168
|
persistMaxVisible: 3,
|
|
169
169
|
maxLines: void 0,
|
|
170
170
|
vibrate: !0
|
|
171
|
-
},
|
|
171
|
+
}, Ue = [
|
|
172
172
|
80,
|
|
173
173
|
40,
|
|
174
174
|
80
|
|
175
175
|
];
|
|
176
|
-
function
|
|
176
|
+
function We() {
|
|
177
177
|
if (!(typeof navigator > "u" || !("vibrate" in navigator))) try {
|
|
178
|
-
navigator.vibrate(
|
|
178
|
+
navigator.vibrate(Ue);
|
|
179
179
|
} catch {}
|
|
180
180
|
}
|
|
181
|
-
var
|
|
181
|
+
var Ge = class {
|
|
182
182
|
containers = /* @__PURE__ */ new Map();
|
|
183
|
-
opts = { ...
|
|
183
|
+
opts = { ...He };
|
|
184
184
|
toasts = /* @__PURE__ */ new Map();
|
|
185
185
|
queue = [];
|
|
186
186
|
_seq = 0;
|
|
@@ -189,7 +189,7 @@ var We = class {
|
|
|
189
189
|
}
|
|
190
190
|
ensureContainer(e) {
|
|
191
191
|
let t = this.containers.get(e);
|
|
192
|
-
return t || (t =
|
|
192
|
+
return t || (t = Be("div", "qt-container"), t.setAttribute("data-qt-pos", e), t.setAttribute("role", "status"), t.setAttribute("aria-live", "polite"), t.setAttribute("aria-atomic", "false"), document.body.appendChild(t), this.containers.set(e, t)), t;
|
|
193
193
|
}
|
|
194
194
|
show(e, t) {
|
|
195
195
|
let n = t?.type ?? this.opts.type, r = t?.position ?? this.opts.position, i = t?.persist ?? this.opts.persist ? 0 : t?.duration ?? this.opts.duration, a = t?.dismissible ?? !0, o = t?.maxLines ?? this.opts.maxLines, s = t?.description, c = t?.action, l = ze(), u = {
|
|
@@ -275,30 +275,30 @@ var We = class {
|
|
|
275
275
|
this.containers.clear();
|
|
276
276
|
}
|
|
277
277
|
buildElement(e, t, n, r, i, a, o) {
|
|
278
|
-
let s =
|
|
278
|
+
let s = Be("div", `qt-toast qt-${n}${i == null ? "" : " qt-truncate"}${a || o ? " qt-rich" : ""}`);
|
|
279
279
|
s.setAttribute("data-qt-id", e);
|
|
280
|
-
let c =
|
|
280
|
+
let c = Be("span", "qt-icon");
|
|
281
281
|
c.innerHTML = Le[n], s.appendChild(c);
|
|
282
|
-
let l =
|
|
283
|
-
maxWidth:
|
|
282
|
+
let l = Be("div", "qt-body"), u = Be("span", "qt-msg"), d = Pe(t, {
|
|
283
|
+
maxWidth: X(),
|
|
284
284
|
lineHeight: 1,
|
|
285
285
|
maxLines: i
|
|
286
286
|
}, Ie);
|
|
287
|
-
if (d.lineCount <= 1 ?
|
|
288
|
-
let n =
|
|
289
|
-
t === d.lines.length - 1 && d.truncated && !r.endsWith("…") && (r += "…"),
|
|
287
|
+
if (d.lineCount <= 1 ? Ve(u, t) : d.lines.forEach((e, t) => {
|
|
288
|
+
let n = Be("span", "qt-line"), r = e.text;
|
|
289
|
+
t === d.lines.length - 1 && d.truncated && !r.endsWith("…") && (r += "…"), Ve(n, r), u.appendChild(n);
|
|
290
290
|
}), l.appendChild(u), a) {
|
|
291
|
-
let e =
|
|
291
|
+
let e = Be("div", "qt-desc");
|
|
292
292
|
e.textContent = a, l.appendChild(e);
|
|
293
293
|
}
|
|
294
294
|
if (s.appendChild(l), o) {
|
|
295
|
-
let t =
|
|
295
|
+
let t = Be("button", "qt-action");
|
|
296
296
|
t.type = "button", t.textContent = o.label, t.addEventListener("click", (t) => {
|
|
297
297
|
t.stopPropagation(), this.dismiss(e), o.onClick();
|
|
298
298
|
}), s.appendChild(t);
|
|
299
299
|
}
|
|
300
300
|
if (r) {
|
|
301
|
-
let t =
|
|
301
|
+
let t = Be("button", "qt-close", "<svg width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"><path d=\"M18 6 6 18M6 6l12 12\"/></svg>");
|
|
302
302
|
t.type = "button", t.setAttribute("aria-label", "关闭通知"), t.addEventListener("click", (t) => {
|
|
303
303
|
t.stopPropagation(), this.dismiss(e);
|
|
304
304
|
}), s.appendChild(t);
|
|
@@ -310,7 +310,7 @@ var We = class {
|
|
|
310
310
|
mount(e) {
|
|
311
311
|
e.duration === 0 && this.evictPersistIfNeeded(e);
|
|
312
312
|
let t = this.ensureContainer(e.position);
|
|
313
|
-
this.toasts.set(e.id, e), t.appendChild(e.element), e.type === "error" && this.opts.vibrate &&
|
|
313
|
+
this.toasts.set(e.id, e), t.appendChild(e.element), e.type === "error" && this.opts.vibrate && We(), requestAnimationFrame(() => {
|
|
314
314
|
requestAnimationFrame(() => {
|
|
315
315
|
e.element.classList.add("qt-enter");
|
|
316
316
|
});
|
|
@@ -345,46 +345,46 @@ var We = class {
|
|
|
345
345
|
let e = this.queue.shift();
|
|
346
346
|
this.mount(e);
|
|
347
347
|
}
|
|
348
|
-
},
|
|
349
|
-
function
|
|
350
|
-
return
|
|
351
|
-
}
|
|
352
|
-
var
|
|
353
|
-
info: (e, t) =>
|
|
354
|
-
success: (e, t) =>
|
|
355
|
-
warn: (e, t) =>
|
|
356
|
-
error: (e, t) =>
|
|
357
|
-
promise: (e, t, n) =>
|
|
358
|
-
dismiss: (e) =>
|
|
359
|
-
dismissAll: () =>
|
|
360
|
-
configure: (e) =>
|
|
361
|
-
}),
|
|
362
|
-
function
|
|
363
|
-
|
|
348
|
+
}, Ke = null;
|
|
349
|
+
function qe() {
|
|
350
|
+
return Ke ||= new Ge(), Ke;
|
|
351
|
+
}
|
|
352
|
+
var Je = Object.assign((e, t) => qe().show(e, t), {
|
|
353
|
+
info: (e, t) => qe().info(e, t),
|
|
354
|
+
success: (e, t) => qe().success(e, t),
|
|
355
|
+
warn: (e, t) => qe().warn(e, t),
|
|
356
|
+
error: (e, t) => qe().error(e, t),
|
|
357
|
+
promise: (e, t, n) => qe().promise(e, t, n),
|
|
358
|
+
dismiss: (e) => qe().dismiss(e),
|
|
359
|
+
dismissAll: () => qe().dismissAll(),
|
|
360
|
+
configure: (e) => qe().configure(e)
|
|
361
|
+
}), Ye = /* @__PURE__ */ new Set(), Xe = null;
|
|
362
|
+
function Ze(e) {
|
|
363
|
+
Xe = e;
|
|
364
364
|
}
|
|
365
365
|
function Z(e, t = "error", n) {
|
|
366
366
|
let r = {
|
|
367
367
|
persist: !0,
|
|
368
368
|
...n
|
|
369
369
|
};
|
|
370
|
-
if (
|
|
371
|
-
for (let n of
|
|
370
|
+
if (Ye.size > 0) {
|
|
371
|
+
for (let n of Ye) n(e, t, r);
|
|
372
372
|
return;
|
|
373
373
|
}
|
|
374
|
-
if (
|
|
375
|
-
|
|
374
|
+
if (Xe) {
|
|
375
|
+
Xe(e, t, r);
|
|
376
376
|
return;
|
|
377
377
|
}
|
|
378
|
-
t === "success" ?
|
|
378
|
+
t === "success" ? Je.success(e, r) : t === "info" ? Je.info(e, r) : Je.error(e, r);
|
|
379
379
|
}
|
|
380
|
-
function
|
|
381
|
-
return
|
|
382
|
-
|
|
380
|
+
function Qe(e) {
|
|
381
|
+
return Ye.add(e), () => {
|
|
382
|
+
Ye.delete(e);
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
385
|
//#endregion
|
|
386
386
|
//#region src/components/image-upload-dialog.tsx
|
|
387
|
-
var
|
|
387
|
+
var $e = /* @__PURE__ */ e({ ImageUploadDialog: () => et }), et = ({ open: e, onClose: t, onInsert: n, validate: r }) => {
|
|
388
388
|
let [i, a] = T("upload"), [s, c] = T(!1), [l, u] = T(!1), [d, f] = T(null), [p, m] = T(null), [h, g] = T(""), [_, v] = T(null), y = w(null), x = (() => {
|
|
389
389
|
try {
|
|
390
390
|
let e = o();
|
|
@@ -676,10 +676,10 @@ var Qe = /* @__PURE__ */ e({ ImageUploadDialog: () => $e }), $e = ({ open: e, on
|
|
|
676
676
|
};
|
|
677
677
|
//#endregion
|
|
678
678
|
//#region src/components/toc.tsx
|
|
679
|
-
function
|
|
679
|
+
function tt(e, t) {
|
|
680
680
|
return `${e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu, "").replace(/\s+/g, "-").slice(0, 40) || "heading"}-${t}`;
|
|
681
681
|
}
|
|
682
|
-
function
|
|
682
|
+
function nt(e) {
|
|
683
683
|
let t = [], n = [];
|
|
684
684
|
for (let r of e) {
|
|
685
685
|
let e = {
|
|
@@ -691,18 +691,18 @@ function tt(e) {
|
|
|
691
691
|
}
|
|
692
692
|
return t;
|
|
693
693
|
}
|
|
694
|
-
function
|
|
694
|
+
function rt(e) {
|
|
695
695
|
let t = /* @__PURE__ */ new Set(), n = (e) => {
|
|
696
696
|
for (let r of e) r.children.length > 0 && (t.add(r.id), n(r.children));
|
|
697
697
|
};
|
|
698
698
|
return n(e), t;
|
|
699
699
|
}
|
|
700
|
-
function
|
|
700
|
+
function it(e, t) {
|
|
701
701
|
let n = [];
|
|
702
|
-
for (let r of e) n.push(r), r.children.length > 0 && !t.has(r.id) && n.push(...
|
|
702
|
+
for (let r of e) n.push(r), r.children.length > 0 && !t.has(r.id) && n.push(...it(r.children, t));
|
|
703
703
|
return n;
|
|
704
704
|
}
|
|
705
|
-
function
|
|
705
|
+
function at(e, t) {
|
|
706
706
|
let n = t.toLowerCase(), r = (e) => {
|
|
707
707
|
let t = [];
|
|
708
708
|
for (let i of e) {
|
|
@@ -716,16 +716,16 @@ function it(e, t) {
|
|
|
716
716
|
};
|
|
717
717
|
return r(e);
|
|
718
718
|
}
|
|
719
|
-
function
|
|
719
|
+
function ot(e) {
|
|
720
720
|
let t = e.parentElement;
|
|
721
721
|
for (; t && t !== document.documentElement;) {
|
|
722
722
|
let e = getComputedStyle(t).overflowY;
|
|
723
|
-
if (e === "auto" || e === "scroll" || e === "overlay") return t;
|
|
723
|
+
if ((e === "auto" || e === "scroll" || e === "overlay") && t.scrollHeight > t.clientHeight) return t;
|
|
724
724
|
t = t.parentElement;
|
|
725
725
|
}
|
|
726
726
|
return null;
|
|
727
727
|
}
|
|
728
|
-
function
|
|
728
|
+
function st(e, t) {
|
|
729
729
|
if (!t) return e;
|
|
730
730
|
let n = e.toLowerCase(), r = t.toLowerCase(), i = [], a = 0, o = 0;
|
|
731
731
|
for (;;) {
|
|
@@ -738,10 +738,10 @@ function ot(e, t) {
|
|
|
738
738
|
}
|
|
739
739
|
return a < e.length && i.push(e.slice(a)), i.length ? i : e;
|
|
740
740
|
}
|
|
741
|
-
var
|
|
741
|
+
var ct = 84, lt = 3e3, ut = ({ editor: e, className: t = "", onClose: n }) => {
|
|
742
742
|
let [r, i] = T([]), [a, o] = T(""), [s, c] = T(/* @__PURE__ */ new Set()), [l, u] = T(""), d = w(""), f = w([]), p = w(null), m = w(null), h = w(null), g = w(0), _ = b(() => {
|
|
743
743
|
h.current &&= (clearTimeout(h.current.timer), null);
|
|
744
|
-
}, []), v = b(() => Array.from(e.view.dom.querySelectorAll("h1,h2,h3,h4,h5,h6")).map((e, t) => (e.id ||=
|
|
744
|
+
}, []), v = b(() => Array.from(e.view.dom.querySelectorAll("h1,h2,h3,h4,h5,h6")).map((e, t) => (e.id ||= tt(e.textContent || "", t), {
|
|
745
745
|
id: e.id,
|
|
746
746
|
level: Number(e.tagName.slice(1)),
|
|
747
747
|
text: e.textContent?.trim() || "(无标题)",
|
|
@@ -749,7 +749,7 @@ var st = 84, ct = 3e3, lt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
749
749
|
})), [e]), y = b(() => {
|
|
750
750
|
let e = f.current;
|
|
751
751
|
if ((!e.length || e.some((e) => !e.el.isConnected)) && (e = v(), f.current = e), !e.length) return;
|
|
752
|
-
let t = m.current, n = (t ? t.getBoundingClientRect().top : 0) +
|
|
752
|
+
let t = m.current, n = (t ? t.getBoundingClientRect().top : 0) + ct, r = t ? t.scrollHeight - t.scrollTop - t.clientHeight < 2 : document.documentElement.scrollHeight - window.scrollY - window.innerHeight < 2, i = "";
|
|
753
753
|
for (let t of e) t.el.isConnected && t.el.getBoundingClientRect().top <= n && (i = t.id);
|
|
754
754
|
if (r) {
|
|
755
755
|
for (let t = e.length - 1; t >= 0; t--) if (e[t].el.isConnected) {
|
|
@@ -773,7 +773,7 @@ var st = 84, ct = 3e3, lt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
773
773
|
t !== d.current && (d.current = t, f.current = e, i(e), S());
|
|
774
774
|
}, [v, S]);
|
|
775
775
|
x(() => {
|
|
776
|
-
let t =
|
|
776
|
+
let t = ot(e.view.dom);
|
|
777
777
|
m.current = t;
|
|
778
778
|
let n = t ?? window;
|
|
779
779
|
return n.addEventListener("scroll", S, { passive: !0 }), window.addEventListener("resize", S), n.addEventListener("wheel", _, { passive: !0 }), n.addEventListener("touchstart", _, { passive: !0 }), () => {
|
|
@@ -809,23 +809,32 @@ var st = 84, ct = 3e3, lt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
809
809
|
break;
|
|
810
810
|
}
|
|
811
811
|
}
|
|
812
|
-
|
|
812
|
+
if (!n) return;
|
|
813
|
+
_(), h.current = {
|
|
813
814
|
id: t.id,
|
|
814
|
-
timer: setTimeout(_,
|
|
815
|
-
}, o(t.id)
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
815
|
+
timer: setTimeout(_, lt)
|
|
816
|
+
}, o(t.id);
|
|
817
|
+
let r = m.current, i = n.getBoundingClientRect().top;
|
|
818
|
+
if (r) {
|
|
819
|
+
let e = r.getBoundingClientRect().top;
|
|
820
|
+
r.scrollTo({
|
|
821
|
+
top: r.scrollTop + i - e - ct,
|
|
822
|
+
behavior: "smooth"
|
|
823
|
+
});
|
|
824
|
+
} else window.scrollTo({
|
|
825
|
+
top: window.scrollY + i - ct,
|
|
826
|
+
behavior: "smooth"
|
|
827
|
+
});
|
|
828
|
+
}, [e, _]), A = C(() => nt(r), [r]), j = C(() => rt(A), [A]), M = C(() => {
|
|
820
829
|
let e = /* @__PURE__ */ new Map(), t = (n, r) => {
|
|
821
830
|
for (let i of n) r && e.set(i.id, r), t(i.children, i.id);
|
|
822
831
|
};
|
|
823
832
|
return t(A, ""), e;
|
|
824
|
-
}, [A]), N = l.trim().length > 0, P = C(() => N ?
|
|
833
|
+
}, [A]), N = l.trim().length > 0, P = C(() => N ? at(A, l.trim()) : A, [
|
|
825
834
|
A,
|
|
826
835
|
N,
|
|
827
836
|
l
|
|
828
|
-
]), F = C(() =>
|
|
837
|
+
]), F = C(() => it(P, N ? /* @__PURE__ */ new Set() : s), [
|
|
829
838
|
P,
|
|
830
839
|
s,
|
|
831
840
|
N
|
|
@@ -1056,7 +1065,7 @@ var st = 84, ct = 3e3, lt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1056
1065
|
title: e.text,
|
|
1057
1066
|
children: /* @__PURE__ */ D("span", {
|
|
1058
1067
|
className: "toc-text",
|
|
1059
|
-
children: N ?
|
|
1068
|
+
children: N ? st(e.text, l.trim()) : e.text
|
|
1060
1069
|
})
|
|
1061
1070
|
})]
|
|
1062
1071
|
}, e.id);
|
|
@@ -1080,7 +1089,7 @@ var st = 84, ct = 3e3, lt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1080
1089
|
};
|
|
1081
1090
|
//#endregion
|
|
1082
1091
|
//#region src/editor/ai/index.ts
|
|
1083
|
-
function
|
|
1092
|
+
function dt(e, t) {
|
|
1084
1093
|
return {
|
|
1085
1094
|
continue: "你是一个写作助手。请从下文尾部自然流畅地续写内容,保持风格一致。只输出续写的内容,不要加任何前缀说明。",
|
|
1086
1095
|
improve: "你是一个文字润色专家。请优化以下文本的表达,提升文采和流畅度,保持原意不变。只输出润色后的文本。",
|
|
@@ -1091,8 +1100,8 @@ function ut(e, t) {
|
|
|
1091
1100
|
zap: t || "你是一个全能的 AI 写作助手。请根据用户的指令处理文本。"
|
|
1092
1101
|
}[e];
|
|
1093
1102
|
}
|
|
1094
|
-
var
|
|
1095
|
-
async function
|
|
1103
|
+
var ft = null;
|
|
1104
|
+
async function pt(e) {
|
|
1096
1105
|
let t;
|
|
1097
1106
|
try {
|
|
1098
1107
|
({createOpenAI: t} = await import("@ai-sdk/openai"));
|
|
@@ -1107,7 +1116,7 @@ async function ft(e) {
|
|
|
1107
1116
|
async *stream(e) {
|
|
1108
1117
|
let t = await A({
|
|
1109
1118
|
model: n,
|
|
1110
|
-
system:
|
|
1119
|
+
system: dt(e.mode, e.instruction),
|
|
1111
1120
|
prompt: e.context,
|
|
1112
1121
|
temperature: .7,
|
|
1113
1122
|
maxOutputTokens: 2048
|
|
@@ -1117,7 +1126,7 @@ async function ft(e) {
|
|
|
1117
1126
|
async generate(e) {
|
|
1118
1127
|
return (await k({
|
|
1119
1128
|
model: n,
|
|
1120
|
-
system:
|
|
1129
|
+
system: dt(e.mode, e.instruction),
|
|
1121
1130
|
prompt: e.context,
|
|
1122
1131
|
temperature: .7,
|
|
1123
1132
|
maxOutputTokens: 2048
|
|
@@ -1125,16 +1134,16 @@ async function ft(e) {
|
|
|
1125
1134
|
}
|
|
1126
1135
|
};
|
|
1127
1136
|
}
|
|
1128
|
-
function
|
|
1129
|
-
|
|
1137
|
+
function mt(e) {
|
|
1138
|
+
ft = e;
|
|
1130
1139
|
}
|
|
1131
|
-
function
|
|
1132
|
-
if (!
|
|
1133
|
-
return
|
|
1140
|
+
function ht() {
|
|
1141
|
+
if (!ft) throw Error("未配置 AI 服务。请调用 createAILanguageModelProvider() 创建并通过 setAIProvider() 注册。");
|
|
1142
|
+
return ft;
|
|
1134
1143
|
}
|
|
1135
1144
|
//#endregion
|
|
1136
1145
|
//#region src/editor/ai/providers/openai-compat.ts
|
|
1137
|
-
function
|
|
1146
|
+
function gt(e) {
|
|
1138
1147
|
let { apiKey: t, baseURL: n, model: r, headers: i } = e;
|
|
1139
1148
|
async function* a(e, a) {
|
|
1140
1149
|
let o = await fetch(`${n}/chat/completions`, {
|
|
@@ -1185,10 +1194,10 @@ function ht(e) {
|
|
|
1185
1194
|
}
|
|
1186
1195
|
return {
|
|
1187
1196
|
async *stream(e) {
|
|
1188
|
-
yield* a(
|
|
1197
|
+
yield* a(dt(e.mode, e.instruction), e.context);
|
|
1189
1198
|
},
|
|
1190
1199
|
async generate(e) {
|
|
1191
|
-
let t =
|
|
1200
|
+
let t = dt(e.mode, e.instruction), n = "";
|
|
1192
1201
|
for await (let r of a(t, e.context)) n += r;
|
|
1193
1202
|
return n;
|
|
1194
1203
|
}
|
|
@@ -1196,8 +1205,8 @@ function ht(e) {
|
|
|
1196
1205
|
}
|
|
1197
1206
|
//#endregion
|
|
1198
1207
|
//#region src/editor/ai/providers/deepseek.ts
|
|
1199
|
-
function
|
|
1200
|
-
return
|
|
1208
|
+
function _t(e) {
|
|
1209
|
+
return gt({
|
|
1201
1210
|
apiKey: e.apiKey,
|
|
1202
1211
|
baseURL: e.baseURL || "https://api.deepseek.com/v1",
|
|
1203
1212
|
model: e.model || "deepseek-v4-flash",
|
|
@@ -1206,8 +1215,8 @@ function gt(e) {
|
|
|
1206
1215
|
}
|
|
1207
1216
|
//#endregion
|
|
1208
1217
|
//#region src/editor/ai/providers/openai.ts
|
|
1209
|
-
function
|
|
1210
|
-
return
|
|
1218
|
+
function vt(e) {
|
|
1219
|
+
return gt({
|
|
1211
1220
|
apiKey: e.apiKey,
|
|
1212
1221
|
baseURL: e.baseURL || "https://api.openai.com/v1",
|
|
1213
1222
|
model: e.model || "gpt-5.6-luna",
|
|
@@ -1216,8 +1225,8 @@ function _t(e) {
|
|
|
1216
1225
|
}
|
|
1217
1226
|
//#endregion
|
|
1218
1227
|
//#region src/editor/ai/providers/qwen.ts
|
|
1219
|
-
function
|
|
1220
|
-
return
|
|
1228
|
+
function yt(e) {
|
|
1229
|
+
return gt({
|
|
1221
1230
|
apiKey: e.apiKey,
|
|
1222
1231
|
baseURL: e.baseURL || "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
1223
1232
|
model: e.model || "qwen3.7-plus",
|
|
@@ -1226,20 +1235,20 @@ function vt(e) {
|
|
|
1226
1235
|
}
|
|
1227
1236
|
//#endregion
|
|
1228
1237
|
//#region src/editor/extensions/search-highlight.ts
|
|
1229
|
-
var
|
|
1238
|
+
var bt = {
|
|
1230
1239
|
keyword: "",
|
|
1231
1240
|
caseSensitive: !1,
|
|
1232
1241
|
wholeWord: !1,
|
|
1233
1242
|
matches: [],
|
|
1234
1243
|
currentIndex: -1
|
|
1235
|
-
},
|
|
1236
|
-
function
|
|
1244
|
+
}, xt = new B("search-highlight");
|
|
1245
|
+
function St(e) {
|
|
1237
1246
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1238
1247
|
}
|
|
1239
|
-
function
|
|
1248
|
+
function Ct(e, t) {
|
|
1240
1249
|
let { keyword: n, caseSensitive: r, wholeWord: i } = t;
|
|
1241
1250
|
if (!n) return [];
|
|
1242
|
-
let a = r ? "g" : "gi", o = i ? `\\b${
|
|
1251
|
+
let a = r ? "g" : "gi", o = i ? `\\b${St(n)}\\b` : St(n), s = new RegExp(o, a), c = [];
|
|
1243
1252
|
return e.descendants((e, t) => {
|
|
1244
1253
|
if (!e.isText || !e.text) return;
|
|
1245
1254
|
s.lastIndex = 0;
|
|
@@ -1253,12 +1262,12 @@ function St(e, t) {
|
|
|
1253
1262
|
}
|
|
1254
1263
|
}), c;
|
|
1255
1264
|
}
|
|
1256
|
-
function Ct(e, t) {
|
|
1257
|
-
if (t.matches.length === 0) return se.empty;
|
|
1258
|
-
let n = t.matches.map((e, n) => oe.inline(e.from, e.to, { class: n === t.currentIndex ? "search-highlight search-highlight--active" : "search-highlight" }));
|
|
1259
|
-
return se.create(e, n);
|
|
1260
|
-
}
|
|
1261
1265
|
function wt(e, t) {
|
|
1266
|
+
if (t.matches.length === 0) return ae.empty;
|
|
1267
|
+
let n = t.matches.map((e, n) => H.inline(e.from, e.to, { class: n === t.currentIndex ? "search-highlight search-highlight--active" : "search-highlight" }));
|
|
1268
|
+
return ae.create(e, n);
|
|
1269
|
+
}
|
|
1270
|
+
function Tt(e, t) {
|
|
1262
1271
|
if (t.currentIndex < 0 || t.currentIndex >= t.matches.length) return;
|
|
1263
1272
|
let n = t.matches[t.currentIndex];
|
|
1264
1273
|
n && requestAnimationFrame(() => {
|
|
@@ -1283,15 +1292,15 @@ function wt(e, t) {
|
|
|
1283
1292
|
} catch {}
|
|
1284
1293
|
});
|
|
1285
1294
|
}
|
|
1286
|
-
var
|
|
1295
|
+
var Et = R.create({
|
|
1287
1296
|
name: "searchHighlight",
|
|
1288
1297
|
addProseMirrorPlugins() {
|
|
1289
1298
|
return [new z({
|
|
1290
|
-
key:
|
|
1299
|
+
key: xt,
|
|
1291
1300
|
state: {
|
|
1292
|
-
init: () =>
|
|
1301
|
+
init: () => bt,
|
|
1293
1302
|
apply(e, t) {
|
|
1294
|
-
let n = e.getMeta(
|
|
1303
|
+
let n = e.getMeta(xt);
|
|
1295
1304
|
if (n) return {
|
|
1296
1305
|
...t,
|
|
1297
1306
|
...n,
|
|
@@ -1299,7 +1308,7 @@ var Tt = R.create({
|
|
|
1299
1308
|
currentIndex: n.currentIndex === void 0 ? t.currentIndex : n.currentIndex
|
|
1300
1309
|
};
|
|
1301
1310
|
if (e.docChanged && t.keyword) {
|
|
1302
|
-
let n =
|
|
1311
|
+
let n = Ct(e.doc, t), r = t.currentIndex;
|
|
1303
1312
|
return r >= n.length && (r = n.length - 1), r < 0 && (r = n.length > 0 ? 0 : -1), {
|
|
1304
1313
|
...t,
|
|
1305
1314
|
matches: n,
|
|
@@ -1310,52 +1319,52 @@ var Tt = R.create({
|
|
|
1310
1319
|
}
|
|
1311
1320
|
},
|
|
1312
1321
|
props: { decorations(e) {
|
|
1313
|
-
let t =
|
|
1314
|
-
return t ?
|
|
1322
|
+
let t = xt.getState(e);
|
|
1323
|
+
return t ? wt(e.doc, t) : ae.empty;
|
|
1315
1324
|
} }
|
|
1316
1325
|
})];
|
|
1317
1326
|
},
|
|
1318
1327
|
addCommands() {
|
|
1319
1328
|
return {
|
|
1320
1329
|
setSearch: (e, t = {}) => ({ state: n, dispatch: r, view: i }) => {
|
|
1321
|
-
let a =
|
|
1330
|
+
let a = xt.getState(n) || bt, o = {
|
|
1322
1331
|
keyword: e,
|
|
1323
1332
|
caseSensitive: t.caseSensitive ?? a.caseSensitive,
|
|
1324
1333
|
wholeWord: t.wholeWord ?? a.wholeWord,
|
|
1325
1334
|
matches: [],
|
|
1326
1335
|
currentIndex: -1
|
|
1327
1336
|
};
|
|
1328
|
-
return o.matches =
|
|
1337
|
+
return o.matches = Ct(n.doc, o), o.currentIndex = o.matches.length > 0 ? 0 : -1, r && (r(n.tr.setMeta(xt, o)), i && Tt(i, o)), !0;
|
|
1329
1338
|
},
|
|
1330
1339
|
nextMatch: () => ({ state: e, dispatch: t, view: n }) => {
|
|
1331
|
-
let r =
|
|
1340
|
+
let r = xt.getState(e) || bt;
|
|
1332
1341
|
if (r.matches.length === 0) return !1;
|
|
1333
1342
|
let i = (r.currentIndex + 1) % r.matches.length;
|
|
1334
|
-
return t && (t(e.tr.setMeta(
|
|
1343
|
+
return t && (t(e.tr.setMeta(xt, { currentIndex: i })), n && Tt(n, {
|
|
1335
1344
|
...r,
|
|
1336
1345
|
currentIndex: i
|
|
1337
1346
|
})), !0;
|
|
1338
1347
|
},
|
|
1339
1348
|
prevMatch: () => ({ state: e, dispatch: t, view: n }) => {
|
|
1340
|
-
let r =
|
|
1349
|
+
let r = xt.getState(e) || bt;
|
|
1341
1350
|
if (r.matches.length === 0) return !1;
|
|
1342
1351
|
let i = (r.currentIndex - 1 + r.matches.length) % r.matches.length;
|
|
1343
|
-
return t && (t(e.tr.setMeta(
|
|
1352
|
+
return t && (t(e.tr.setMeta(xt, { currentIndex: i })), n && Tt(n, {
|
|
1344
1353
|
...r,
|
|
1345
1354
|
currentIndex: i
|
|
1346
1355
|
})), !0;
|
|
1347
1356
|
},
|
|
1348
|
-
clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(
|
|
1357
|
+
clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(xt, bt)), !0)
|
|
1349
1358
|
};
|
|
1350
1359
|
}
|
|
1351
1360
|
});
|
|
1352
|
-
function
|
|
1361
|
+
function Dt(e) {
|
|
1353
1362
|
let t = e.state;
|
|
1354
|
-
return
|
|
1363
|
+
return xt.getState(t) || bt;
|
|
1355
1364
|
}
|
|
1356
1365
|
//#endregion
|
|
1357
1366
|
//#region src/components/search-bar.tsx
|
|
1358
|
-
var
|
|
1367
|
+
var Ot = ({ editor: e, onClose: t }) => {
|
|
1359
1368
|
let [n, r] = T(""), [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(0), u = w(null), d = w({
|
|
1360
1369
|
keyword: n,
|
|
1361
1370
|
caseSensitive: i,
|
|
@@ -1420,7 +1429,7 @@ var Dt = ({ editor: e, onClose: t }) => {
|
|
|
1420
1429
|
}, [f, p]), h = C(() => {
|
|
1421
1430
|
if (!e) return null;
|
|
1422
1431
|
try {
|
|
1423
|
-
return
|
|
1432
|
+
return Dt(e);
|
|
1424
1433
|
} catch {
|
|
1425
1434
|
return null;
|
|
1426
1435
|
}
|
|
@@ -1572,36 +1581,36 @@ function Q({ children: e, ...t }) {
|
|
|
1572
1581
|
children: e
|
|
1573
1582
|
});
|
|
1574
1583
|
}
|
|
1575
|
-
var
|
|
1584
|
+
var kt = (e) => /* @__PURE__ */ O(Q, {
|
|
1576
1585
|
...e,
|
|
1577
1586
|
children: [/* @__PURE__ */ D("path", { d: "M6 4h8a4 4 0 0 1 0 8H6z" }), /* @__PURE__ */ D("path", { d: "M6 12h9a4 4 0 0 1 0 8H6z" })]
|
|
1578
|
-
}),
|
|
1587
|
+
}), At = (e) => /* @__PURE__ */ O(Q, {
|
|
1579
1588
|
...e,
|
|
1580
1589
|
children: [
|
|
1581
1590
|
/* @__PURE__ */ D("path", { d: "M19 4h-9" }),
|
|
1582
1591
|
/* @__PURE__ */ D("path", { d: "M14 20H5" }),
|
|
1583
1592
|
/* @__PURE__ */ D("path", { d: "M15 4 9 20" })
|
|
1584
1593
|
]
|
|
1585
|
-
}),
|
|
1594
|
+
}), jt = (e) => /* @__PURE__ */ O(Q, {
|
|
1586
1595
|
...e,
|
|
1587
1596
|
children: [/* @__PURE__ */ D("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }), /* @__PURE__ */ D("path", { d: "M4 20h16" })]
|
|
1588
|
-
}),
|
|
1597
|
+
}), Mt = (e) => /* @__PURE__ */ O(Q, {
|
|
1589
1598
|
...e,
|
|
1590
1599
|
children: [
|
|
1591
1600
|
/* @__PURE__ */ D("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
|
|
1592
1601
|
/* @__PURE__ */ D("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
|
|
1593
1602
|
/* @__PURE__ */ D("path", { d: "M4 12h16" })
|
|
1594
1603
|
]
|
|
1595
|
-
}),
|
|
1604
|
+
}), Nt = (e) => /* @__PURE__ */ O(Q, {
|
|
1596
1605
|
...e,
|
|
1597
1606
|
children: [/* @__PURE__ */ D("path", { d: "m16 18 6-6-6-6" }), /* @__PURE__ */ D("path", { d: "m8 6-6 6 6 6" })]
|
|
1598
|
-
}),
|
|
1607
|
+
}), Pt = (e) => /* @__PURE__ */ O(Q, {
|
|
1599
1608
|
...e,
|
|
1600
1609
|
children: [/* @__PURE__ */ D("path", { d: "m9 11-6 6v3h9l3-3" }), /* @__PURE__ */ D("path", { d: "m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4" })]
|
|
1601
|
-
}),
|
|
1610
|
+
}), Ft = (e) => /* @__PURE__ */ O(Q, {
|
|
1602
1611
|
...e,
|
|
1603
1612
|
children: [/* @__PURE__ */ D("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }), /* @__PURE__ */ D("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })]
|
|
1604
|
-
}),
|
|
1613
|
+
}), It = (e) => /* @__PURE__ */ O(Q, {
|
|
1605
1614
|
...e,
|
|
1606
1615
|
children: [/* @__PURE__ */ D("rect", {
|
|
1607
1616
|
x: "3",
|
|
@@ -1611,7 +1620,7 @@ var Ot = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1611
1620
|
rx: "2",
|
|
1612
1621
|
ry: "2"
|
|
1613
1622
|
}), /* @__PURE__ */ D("path", { d: "M3 9h18M3 15h18M9 3v18M15 3v18" })]
|
|
1614
|
-
}),
|
|
1623
|
+
}), Lt = (e) => /* @__PURE__ */ O(Q, {
|
|
1615
1624
|
...e,
|
|
1616
1625
|
children: [/* @__PURE__ */ D("rect", {
|
|
1617
1626
|
x: "8",
|
|
@@ -1621,17 +1630,17 @@ var Ot = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1621
1630
|
rx: "2",
|
|
1622
1631
|
ry: "2"
|
|
1623
1632
|
}), /* @__PURE__ */ D("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })]
|
|
1624
|
-
}),
|
|
1633
|
+
}), Rt = (e) => /* @__PURE__ */ O(Q, {
|
|
1625
1634
|
...e,
|
|
1626
1635
|
children: [/* @__PURE__ */ D("circle", {
|
|
1627
1636
|
cx: "11",
|
|
1628
1637
|
cy: "11",
|
|
1629
1638
|
r: "8"
|
|
1630
1639
|
}), /* @__PURE__ */ D("path", { d: "m21 21-4.3-4.3" })]
|
|
1631
|
-
}),
|
|
1640
|
+
}), zt = (e) => /* @__PURE__ */ O(Q, {
|
|
1632
1641
|
...e,
|
|
1633
1642
|
children: [/* @__PURE__ */ D("path", { d: "M12 3l1.6 4.4L18 9l-4.4 1.6L12 15l-1.6-4.4L6 9l4.4-1.6L12 3z" }), /* @__PURE__ */ D("path", { d: "M18.5 14l.7 1.9 1.9.7-1.9.7-.7 1.9-.7-1.9-1.9-.7 1.9-.7.7-1.9z" })]
|
|
1634
|
-
}),
|
|
1643
|
+
}), Bt = (e) => /* @__PURE__ */ O(Q, {
|
|
1635
1644
|
...e,
|
|
1636
1645
|
children: [
|
|
1637
1646
|
/* @__PURE__ */ D("circle", {
|
|
@@ -1650,13 +1659,13 @@ var Ot = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1650
1659
|
r: "1"
|
|
1651
1660
|
})
|
|
1652
1661
|
]
|
|
1653
|
-
}),
|
|
1662
|
+
}), Vt = (e) => /* @__PURE__ */ O(Q, {
|
|
1654
1663
|
...e,
|
|
1655
1664
|
children: [/* @__PURE__ */ D("path", { d: "M18 6 6 18" }), /* @__PURE__ */ D("path", { d: "m6 6 12 12" })]
|
|
1656
1665
|
});
|
|
1657
1666
|
//#endregion
|
|
1658
1667
|
//#region src/editor/storage/remove-resource.ts
|
|
1659
|
-
async function
|
|
1668
|
+
async function Ht(e) {
|
|
1660
1669
|
if (e) {
|
|
1661
1670
|
if (e.startsWith("blob:")) {
|
|
1662
1671
|
URL.revokeObjectURL(e);
|
|
@@ -1671,61 +1680,61 @@ async function Vt(e) {
|
|
|
1671
1680
|
}
|
|
1672
1681
|
//#endregion
|
|
1673
1682
|
//#region src/editor/ai/pending-removal.ts
|
|
1674
|
-
var
|
|
1683
|
+
var Ut = 3e4, Wt = /* @__PURE__ */ new Set([
|
|
1675
1684
|
"image",
|
|
1676
1685
|
"attachmentEmbed",
|
|
1677
1686
|
"audioEmbed",
|
|
1678
1687
|
"videoEmbed"
|
|
1679
|
-
]),
|
|
1680
|
-
function
|
|
1688
|
+
]), Gt = /* @__PURE__ */ new WeakMap();
|
|
1689
|
+
function Kt(e) {
|
|
1681
1690
|
let t = /* @__PURE__ */ new Set();
|
|
1682
1691
|
return e.state.doc.descendants((e) => {
|
|
1683
|
-
if (
|
|
1692
|
+
if (Wt.has(e.type.name)) {
|
|
1684
1693
|
let n = e.attrs.src;
|
|
1685
1694
|
n && t.add(n);
|
|
1686
1695
|
}
|
|
1687
1696
|
return !0;
|
|
1688
1697
|
}), t;
|
|
1689
1698
|
}
|
|
1690
|
-
function
|
|
1691
|
-
let t =
|
|
1699
|
+
function qt(e) {
|
|
1700
|
+
let t = Gt.get(e);
|
|
1692
1701
|
return t || (t = {
|
|
1693
1702
|
timers: /* @__PURE__ */ new Map(),
|
|
1694
1703
|
onTransaction: () => {},
|
|
1695
1704
|
listening: !1
|
|
1696
|
-
},
|
|
1705
|
+
}, Gt.set(e, t)), t;
|
|
1697
1706
|
}
|
|
1698
|
-
function
|
|
1707
|
+
function Jt(e, t) {
|
|
1699
1708
|
let n = [...new Set(t.filter(Boolean))];
|
|
1700
1709
|
if (n.length === 0) return;
|
|
1701
|
-
let r =
|
|
1710
|
+
let r = qt(e);
|
|
1702
1711
|
r.listening ||= (r.onTransaction = () => {
|
|
1703
1712
|
if (r.timers.size === 0) return;
|
|
1704
|
-
let t =
|
|
1713
|
+
let t = Kt(e);
|
|
1705
1714
|
for (let [e, n] of r.timers) t.has(e) && (clearTimeout(n), r.timers.delete(e));
|
|
1706
1715
|
}, e.on("transaction", r.onTransaction), !0);
|
|
1707
1716
|
for (let t of n) {
|
|
1708
1717
|
if (r.timers.has(t)) continue;
|
|
1709
1718
|
let n = setTimeout(() => {
|
|
1710
|
-
|
|
1711
|
-
},
|
|
1719
|
+
Kt(e).has(t) || Ht(t), r.timers.delete(t);
|
|
1720
|
+
}, Ut);
|
|
1712
1721
|
r.timers.set(t, n);
|
|
1713
1722
|
}
|
|
1714
1723
|
}
|
|
1715
|
-
function
|
|
1716
|
-
let t =
|
|
1724
|
+
function Yt(e) {
|
|
1725
|
+
let t = Gt.get(e);
|
|
1717
1726
|
if (t) {
|
|
1718
1727
|
if (t.listening &&= (e.off("transaction", t.onTransaction), !1), t.timers.size > 0) {
|
|
1719
|
-
let n =
|
|
1720
|
-
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) ||
|
|
1728
|
+
let n = Kt(e);
|
|
1729
|
+
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) || Ht(e);
|
|
1721
1730
|
t.timers.clear();
|
|
1722
1731
|
}
|
|
1723
|
-
|
|
1732
|
+
Gt.delete(e);
|
|
1724
1733
|
}
|
|
1725
1734
|
}
|
|
1726
1735
|
//#endregion
|
|
1727
1736
|
//#region src/editor/ai/components/ai-selector.tsx
|
|
1728
|
-
var
|
|
1737
|
+
var Xt = [
|
|
1729
1738
|
{
|
|
1730
1739
|
mode: "continue",
|
|
1731
1740
|
labelKey: "editor.ai.continue",
|
|
@@ -1768,24 +1777,24 @@ var Yt = [
|
|
|
1768
1777
|
descKey: "editor.ai.zapDesc",
|
|
1769
1778
|
icon: "⚡"
|
|
1770
1779
|
}
|
|
1771
|
-
],
|
|
1780
|
+
], Zt = /* @__PURE__ */ new Set([
|
|
1772
1781
|
"image",
|
|
1773
1782
|
"attachmentEmbed",
|
|
1774
1783
|
"audioEmbed",
|
|
1775
1784
|
"videoEmbed"
|
|
1776
|
-
]),
|
|
1785
|
+
]), Qt = {
|
|
1777
1786
|
image: "editor.ai.nodeImage",
|
|
1778
1787
|
attachmentEmbed: "editor.ai.nodeAttachment",
|
|
1779
1788
|
videoEmbed: "editor.ai.nodeVideo",
|
|
1780
1789
|
audioEmbed: "editor.ai.nodeAudio"
|
|
1781
1790
|
};
|
|
1782
|
-
function
|
|
1791
|
+
function $t(e, t) {
|
|
1783
1792
|
return e.storage.qingwuUI?.parseMd?.(e.schema, t) || null;
|
|
1784
1793
|
}
|
|
1785
|
-
function
|
|
1794
|
+
function en(e, t, n) {
|
|
1786
1795
|
let r = [];
|
|
1787
1796
|
return e.state.doc.nodesBetween(t, n, (e) => {
|
|
1788
|
-
if (
|
|
1797
|
+
if (Zt.has(e.type.name)) {
|
|
1789
1798
|
let t = e.attrs.src;
|
|
1790
1799
|
t && r.push({
|
|
1791
1800
|
type: e.type.name,
|
|
@@ -1795,27 +1804,27 @@ function $t(e, t, n) {
|
|
|
1795
1804
|
return !0;
|
|
1796
1805
|
}), r;
|
|
1797
1806
|
}
|
|
1798
|
-
function
|
|
1807
|
+
function tn(e) {
|
|
1799
1808
|
let t = /* @__PURE__ */ new Set();
|
|
1800
1809
|
return e.state.doc.descendants((e) => {
|
|
1801
|
-
if (
|
|
1810
|
+
if (Zt.has(e.type.name)) {
|
|
1802
1811
|
let n = e.attrs.src;
|
|
1803
1812
|
n && t.add(n);
|
|
1804
1813
|
}
|
|
1805
1814
|
return !0;
|
|
1806
1815
|
}), t;
|
|
1807
1816
|
}
|
|
1808
|
-
function
|
|
1809
|
-
let n =
|
|
1817
|
+
function nn(e, t) {
|
|
1818
|
+
let n = $t(e, t);
|
|
1810
1819
|
if (n && n.size > 0) {
|
|
1811
1820
|
let t = e.state.tr;
|
|
1812
|
-
t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(
|
|
1821
|
+
t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(V.create(t.doc, t.doc.content.size)), e.view.dispatch(t.scrollIntoView()), e.commands.focus();
|
|
1813
1822
|
return;
|
|
1814
1823
|
}
|
|
1815
1824
|
e.commands.setContent(t), e.commands.focus();
|
|
1816
1825
|
}
|
|
1817
|
-
function
|
|
1818
|
-
let i =
|
|
1826
|
+
function rn(e, t, n, r) {
|
|
1827
|
+
let i = $t(e, t);
|
|
1819
1828
|
if (e.commands.focus(), !i) {
|
|
1820
1829
|
let i = e.chain().focus();
|
|
1821
1830
|
n === "replace" ? i.setTextSelection({
|
|
@@ -1827,7 +1836,7 @@ function nn(e, t, n, r) {
|
|
|
1827
1836
|
let a = e.state.tr;
|
|
1828
1837
|
n === "replace" ? a.replaceRange(r.from, r.to, new N(i, 0, 0)) : a.insert(Math.min(r.to, e.state.doc.content.size), i), e.view.dispatch(a.scrollIntoView());
|
|
1829
1838
|
}
|
|
1830
|
-
function
|
|
1839
|
+
function an({ editor: e, onClose: t }) {
|
|
1831
1840
|
let [n, r] = T(null), [i, a] = T(""), [o, s] = T(""), [c, l] = T(!1), [u, d] = T(null), [p, m] = T(null), h = w({
|
|
1832
1841
|
from: 0,
|
|
1833
1842
|
to: 0,
|
|
@@ -1846,7 +1855,7 @@ function rn({ editor: e, onClose: t }) {
|
|
|
1846
1855
|
empty: n.empty
|
|
1847
1856
|
}, l(!0), s(""), v.current = !0, d(null);
|
|
1848
1857
|
try {
|
|
1849
|
-
let r =
|
|
1858
|
+
let r = ht(), a = n.empty ? e.state.doc.textContent : e.state.doc.textBetween(n.from, n.to), o = [];
|
|
1850
1859
|
for await (let e of r.stream({
|
|
1851
1860
|
mode: t,
|
|
1852
1861
|
context: a,
|
|
@@ -1871,13 +1880,13 @@ function rn({ editor: e, onClose: t }) {
|
|
|
1871
1880
|
!e || !v.current || (e.scrollTop = e.scrollHeight);
|
|
1872
1881
|
}, [o]);
|
|
1873
1882
|
let k = b((t, n, r) => {
|
|
1874
|
-
let i = new Set(
|
|
1875
|
-
t === "replaceAll" ?
|
|
1876
|
-
let a =
|
|
1877
|
-
|
|
1883
|
+
let i = new Set(en(e, r.from, r.to).map((e) => e.src));
|
|
1884
|
+
t === "replaceAll" ? nn(e, n) : rn(e, n, "replace", h.current);
|
|
1885
|
+
let a = tn(e);
|
|
1886
|
+
Jt(e, [...i].filter((e) => !a.has(e)));
|
|
1878
1887
|
}, [e]), A = b((n) => {
|
|
1879
1888
|
if (n === "below") {
|
|
1880
|
-
|
|
1889
|
+
rn(e, o, "below", h.current), t();
|
|
1881
1890
|
return;
|
|
1882
1891
|
}
|
|
1883
1892
|
let r = h.current, i = n === "replaceAll" ? {
|
|
@@ -1886,7 +1895,7 @@ function rn({ editor: e, onClose: t }) {
|
|
|
1886
1895
|
} : {
|
|
1887
1896
|
from: r.from,
|
|
1888
1897
|
to: r.to
|
|
1889
|
-
}, a =
|
|
1898
|
+
}, a = en(e, i.from, i.to);
|
|
1890
1899
|
if (a.length > 0) {
|
|
1891
1900
|
m({
|
|
1892
1901
|
position: n,
|
|
@@ -1927,19 +1936,19 @@ function rn({ editor: e, onClose: t }) {
|
|
|
1927
1936
|
className: "flex items-center justify-between pl-3 pr-1.5 py-1.5 border-b border-default-100 shrink-0",
|
|
1928
1937
|
children: [/* @__PURE__ */ O("span", {
|
|
1929
1938
|
className: "flex items-center gap-1.5 text-xs font-medium text-default-500",
|
|
1930
|
-
children: [/* @__PURE__ */ D(
|
|
1939
|
+
children: [/* @__PURE__ */ D(zt, { className: "text-primary" }), f("editor.ai.trigger")]
|
|
1931
1940
|
}), /* @__PURE__ */ D("button", {
|
|
1932
1941
|
type: "button",
|
|
1933
1942
|
onClick: t,
|
|
1934
1943
|
"aria-label": f("editor.ai.close"),
|
|
1935
1944
|
title: f("editor.ai.close"),
|
|
1936
1945
|
className: "flex items-center justify-center w-6 h-6 rounded-md text-default-400 hover:bg-default-100 hover:text-default-700 transition-colors",
|
|
1937
|
-
children: /* @__PURE__ */ D(
|
|
1946
|
+
children: /* @__PURE__ */ D(Vt, {})
|
|
1938
1947
|
})]
|
|
1939
1948
|
}),
|
|
1940
1949
|
/* @__PURE__ */ D("div", {
|
|
1941
1950
|
className: "grid grid-cols-[repeat(auto-fit,minmax(64px,1fr))] gap-1.5 p-2 shrink-0",
|
|
1942
|
-
children:
|
|
1951
|
+
children: Xt.map(({ mode: e, labelKey: t, descKey: r, icon: i }) => /* @__PURE__ */ O("button", {
|
|
1943
1952
|
type: "button",
|
|
1944
1953
|
className: `flex flex-col items-center gap-1 px-1 py-2 rounded-xl border transition-colors ${n === e ? "border-primary/40 bg-primary/10 text-primary" : "border-default-200 text-default-600 hover:bg-default-100 hover:text-default-900"}`,
|
|
1945
1954
|
onClick: () => y(e),
|
|
@@ -2082,7 +2091,7 @@ function rn({ editor: e, onClose: t }) {
|
|
|
2082
2091
|
children: Object.entries(N).map(([e, t]) => /* @__PURE__ */ O("li", {
|
|
2083
2092
|
className: "text-sm text-default-700",
|
|
2084
2093
|
children: [
|
|
2085
|
-
f(
|
|
2094
|
+
f(Qt[e] ?? e),
|
|
2086
2095
|
" ×",
|
|
2087
2096
|
t
|
|
2088
2097
|
]
|
|
@@ -2114,19 +2123,19 @@ function rn({ editor: e, onClose: t }) {
|
|
|
2114
2123
|
}
|
|
2115
2124
|
//#endregion
|
|
2116
2125
|
//#region src/editor/attachment-limits.ts
|
|
2117
|
-
var
|
|
2126
|
+
var on = /* @__PURE__ */ new Set([
|
|
2118
2127
|
"attachmentEmbed",
|
|
2119
2128
|
"videoEmbed",
|
|
2120
2129
|
"audioEmbed",
|
|
2121
2130
|
"image"
|
|
2122
2131
|
]);
|
|
2123
|
-
function
|
|
2132
|
+
function sn(e) {
|
|
2124
2133
|
let t = 0;
|
|
2125
2134
|
return e.descendants((e) => {
|
|
2126
|
-
|
|
2135
|
+
on.has(e.type.name) && (t += Number(e.attrs?.size) || 0);
|
|
2127
2136
|
}), t;
|
|
2128
2137
|
}
|
|
2129
|
-
function
|
|
2138
|
+
function cn(e) {
|
|
2130
2139
|
if (!Number.isFinite(e) || e <= 0) return "0 B";
|
|
2131
2140
|
let t = [
|
|
2132
2141
|
"B",
|
|
@@ -2137,41 +2146,41 @@ function sn(e) {
|
|
|
2137
2146
|
], n = Math.min(t.length - 1, Math.floor(Math.log(e) / Math.log(1024))), r = e / 1024 ** n;
|
|
2138
2147
|
return `${n === 0 || r >= 100 ? `${Math.round(r)}` : `${Math.round(r * 10) / 10}`} ${t[n]}`;
|
|
2139
2148
|
}
|
|
2140
|
-
function
|
|
2149
|
+
function ln(e) {
|
|
2141
2150
|
return (e?.storage)?.qingwuUI?.limits;
|
|
2142
2151
|
}
|
|
2143
|
-
function
|
|
2152
|
+
function un(e, t, n) {
|
|
2144
2153
|
let { maxAttachmentSize: r, maxTotalAttachmentSize: i } = n;
|
|
2145
|
-
if (r && t.size > r) return `单文件大小不能超过 ${
|
|
2154
|
+
if (r && t.size > r) return `单文件大小不能超过 ${cn(r)}(当前 ${cn(t.size)})`;
|
|
2146
2155
|
if (i) {
|
|
2147
|
-
let n =
|
|
2148
|
-
if (n > i) return `附件总大小不能超过 ${
|
|
2156
|
+
let n = sn(e) + t.size;
|
|
2157
|
+
if (n > i) return `附件总大小不能超过 ${cn(i)}(当前合计 ${cn(n)})`;
|
|
2149
2158
|
}
|
|
2150
2159
|
return null;
|
|
2151
2160
|
}
|
|
2152
2161
|
//#endregion
|
|
2153
2162
|
//#region src/editor/utils/delete-confirm.ts
|
|
2154
|
-
var
|
|
2155
|
-
function
|
|
2156
|
-
return
|
|
2163
|
+
var dn = !1, fn = null, pn = 5e3;
|
|
2164
|
+
function mn() {
|
|
2165
|
+
return dn;
|
|
2157
2166
|
}
|
|
2158
2167
|
function $(e) {
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
},
|
|
2168
|
+
dn = e, fn &&= (clearTimeout(fn), null), e && (fn = setTimeout(() => {
|
|
2169
|
+
dn = !1, fn = null;
|
|
2170
|
+
}, pn));
|
|
2162
2171
|
}
|
|
2163
|
-
var
|
|
2164
|
-
function
|
|
2165
|
-
|
|
2172
|
+
var hn = null;
|
|
2173
|
+
function gn(e) {
|
|
2174
|
+
hn = e;
|
|
2166
2175
|
}
|
|
2167
|
-
function
|
|
2168
|
-
return
|
|
2176
|
+
function _n() {
|
|
2177
|
+
return hn;
|
|
2169
2178
|
}
|
|
2170
2179
|
//#endregion
|
|
2171
2180
|
//#region src/editor/utils/delete-confirm-dialog.tsx
|
|
2172
|
-
var
|
|
2173
|
-
function
|
|
2174
|
-
let [s, c] = T(!1), l = w(!1), u =
|
|
2181
|
+
var vn = 300;
|
|
2182
|
+
function yn({ open: e, title: t, message: n, confirmText: r = "删除", cancelText: i = "取消", onConfirm: a, onCancel: o }) {
|
|
2183
|
+
let [s, c] = T(!1), l = w(!1), u = _n();
|
|
2175
2184
|
return x(() => {
|
|
2176
2185
|
if (!e) {
|
|
2177
2186
|
l.current = !1;
|
|
@@ -2241,7 +2250,7 @@ function vn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2241
2250
|
await a();
|
|
2242
2251
|
} finally {
|
|
2243
2252
|
let t = Date.now() - e;
|
|
2244
|
-
t <
|
|
2253
|
+
t < vn && await new Promise((e) => setTimeout(e, vn - t)), c(!1), o();
|
|
2245
2254
|
}
|
|
2246
2255
|
},
|
|
2247
2256
|
disabled: s,
|
|
@@ -2254,13 +2263,13 @@ function vn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2254
2263
|
}
|
|
2255
2264
|
//#endregion
|
|
2256
2265
|
//#region src/editor/extensions/image-view.tsx
|
|
2257
|
-
function
|
|
2266
|
+
function bn(e) {
|
|
2258
2267
|
return /^(\.\.?\/|[a-zA-Z]:\\|file:\/\/)/.test(e) ? !0 : !(/^[a-z]+:\/\//i.test(e) || e.startsWith("/") || e.startsWith("data:") || e.startsWith("blob:"));
|
|
2259
2268
|
}
|
|
2260
|
-
function
|
|
2269
|
+
function xn({ node: e, deleteNode: t, editor: r }) {
|
|
2261
2270
|
let [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(!1), u = w(!1), [d, f] = T(!1), p = e.attrs.src || "", m = e.attrs.alt || "", h = e.attrs.width || null, g = e.attrs.height || null, _ = w(null), v = w(null), y = w(null), S = w(null), C = w(null), E = w(!1), k = w(!1), A = w(0), [j, M] = T(p), N = r?.isEditable ?? !0, P = b(() => {
|
|
2262
2271
|
o || (A.current = window.scrollY, a(!0));
|
|
2263
|
-
}, [o]),
|
|
2272
|
+
}, [o]), I = b(() => {
|
|
2264
2273
|
a(!1), requestAnimationFrame(() => window.scrollTo(0, A.current));
|
|
2265
2274
|
}, []), L = b(() => {
|
|
2266
2275
|
let e = _.current;
|
|
@@ -2310,8 +2319,8 @@ function bn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2310
2319
|
};
|
|
2311
2320
|
return document.addEventListener("fullscreenchange", e), () => document.removeEventListener("fullscreenchange", e);
|
|
2312
2321
|
}, []);
|
|
2313
|
-
let te = o ||
|
|
2314
|
-
return /* @__PURE__ */ O(
|
|
2322
|
+
let te = o || bn(p);
|
|
2323
|
+
return /* @__PURE__ */ O(F, {
|
|
2315
2324
|
as: "div",
|
|
2316
2325
|
className: "image-node-view group/img",
|
|
2317
2326
|
contentEditable: !1,
|
|
@@ -2323,7 +2332,7 @@ function bn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2323
2332
|
type: "button",
|
|
2324
2333
|
className: "img-ctrl-btn img-ctrl-btn--del image-placeholder-del",
|
|
2325
2334
|
onClick: () => {
|
|
2326
|
-
|
|
2335
|
+
mn() || ($(!0), f(!0));
|
|
2327
2336
|
},
|
|
2328
2337
|
title: "删除",
|
|
2329
2338
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2355,7 +2364,7 @@ function bn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2355
2364
|
}),
|
|
2356
2365
|
/* @__PURE__ */ D("span", {
|
|
2357
2366
|
className: "image-placeholder-text",
|
|
2358
|
-
children:
|
|
2367
|
+
children: bn(p) ? "本地图片无法加载" : "图片加载失败"
|
|
2359
2368
|
}),
|
|
2360
2369
|
/* @__PURE__ */ D("span", {
|
|
2361
2370
|
className: "image-placeholder-path",
|
|
@@ -2436,7 +2445,7 @@ function bn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2436
2445
|
type: "button",
|
|
2437
2446
|
className: "img-ctrl-btn img-ctrl-btn--del",
|
|
2438
2447
|
onClick: () => {
|
|
2439
|
-
|
|
2448
|
+
mn() || ($(!0), f(!0));
|
|
2440
2449
|
},
|
|
2441
2450
|
title: "删除",
|
|
2442
2451
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2458,7 +2467,7 @@ function bn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2458
2467
|
}),
|
|
2459
2468
|
i && !te && /* @__PURE__ */ O("div", {
|
|
2460
2469
|
className: "image-lightbox",
|
|
2461
|
-
onClick:
|
|
2470
|
+
onClick: I,
|
|
2462
2471
|
children: [/* @__PURE__ */ O("div", {
|
|
2463
2472
|
className: "image-lightbox-bar",
|
|
2464
2473
|
children: [/* @__PURE__ */ D("button", {
|
|
@@ -2482,7 +2491,7 @@ function bn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2482
2491
|
}), /* @__PURE__ */ D("button", {
|
|
2483
2492
|
type: "button",
|
|
2484
2493
|
className: "image-lightbox-bar-btn",
|
|
2485
|
-
onClick:
|
|
2494
|
+
onClick: I,
|
|
2486
2495
|
title: "关闭",
|
|
2487
2496
|
children: /* @__PURE__ */ D("svg", {
|
|
2488
2497
|
width: "18",
|
|
@@ -2523,7 +2532,7 @@ function bn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2523
2532
|
}
|
|
2524
2533
|
})]
|
|
2525
2534
|
}),
|
|
2526
|
-
/* @__PURE__ */ D(
|
|
2535
|
+
/* @__PURE__ */ D(yn, {
|
|
2527
2536
|
open: d,
|
|
2528
2537
|
title: "确认删除图片",
|
|
2529
2538
|
message: te ? "该图片无法在当前环境加载,仅从编辑器中移除该图片节点,不影响存储文件。" : "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
@@ -2532,7 +2541,7 @@ function bn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2532
2541
|
},
|
|
2533
2542
|
onConfirm: async () => {
|
|
2534
2543
|
if (!te) try {
|
|
2535
|
-
await
|
|
2544
|
+
await Ht(p);
|
|
2536
2545
|
} catch {}
|
|
2537
2546
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
2538
2547
|
}
|
|
@@ -2542,7 +2551,7 @@ function bn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2542
2551
|
}
|
|
2543
2552
|
//#endregion
|
|
2544
2553
|
//#region src/editor/embeds/attachment-view.tsx
|
|
2545
|
-
var
|
|
2554
|
+
var Sn = y(() => import("@file-viewer/react")), Cn = /* @__PURE__ */ new Set(), wn = {
|
|
2546
2555
|
rendererMode: "replace",
|
|
2547
2556
|
autoRenderers: !0,
|
|
2548
2557
|
theme: "light",
|
|
@@ -2571,7 +2580,7 @@ var xn = y(() => import("@file-viewer/react")), Sn = /* @__PURE__ */ new Set(),
|
|
|
2571
2580
|
cache: !0,
|
|
2572
2581
|
workerTimeoutMs: 3e4
|
|
2573
2582
|
}
|
|
2574
|
-
},
|
|
2583
|
+
}, Tn = {
|
|
2575
2584
|
pdf: "pdf",
|
|
2576
2585
|
docx: "word",
|
|
2577
2586
|
docm: "word",
|
|
@@ -2626,7 +2635,7 @@ var xn = y(() => import("@file-viewer/react")), Sn = /* @__PURE__ */ new Set(),
|
|
|
2626
2635
|
xml: "text",
|
|
2627
2636
|
yml: "text",
|
|
2628
2637
|
yaml: "text"
|
|
2629
|
-
},
|
|
2638
|
+
}, En = {
|
|
2630
2639
|
pdf: () => import("@file-viewer/renderer-pdf").then((e) => e.pdfRenderer),
|
|
2631
2640
|
word: () => import("@file-viewer/renderer-word").then((e) => e.wordRenderer),
|
|
2632
2641
|
spreadsheet: () => import("@file-viewer/renderer-spreadsheet").then((e) => e.spreadsheetRenderer),
|
|
@@ -2634,10 +2643,10 @@ var xn = y(() => import("@file-viewer/react")), Sn = /* @__PURE__ */ new Set(),
|
|
|
2634
2643
|
archive: () => import("@file-viewer/renderer-archive").then((e) => e.archiveRenderer),
|
|
2635
2644
|
text: () => import("@file-viewer/renderer-text").then((e) => e.textRenderer)
|
|
2636
2645
|
};
|
|
2637
|
-
function
|
|
2646
|
+
function Dn(e) {
|
|
2638
2647
|
return e ? e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1048576).toFixed(1)} MB` : "";
|
|
2639
2648
|
}
|
|
2640
|
-
function
|
|
2649
|
+
function On(e) {
|
|
2641
2650
|
let t = e.split(".").pop()?.toLowerCase() || "", n = {
|
|
2642
2651
|
pdf: {
|
|
2643
2652
|
label: "PDF",
|
|
@@ -2810,22 +2819,22 @@ function Dn(e) {
|
|
|
2810
2819
|
]
|
|
2811
2820
|
});
|
|
2812
2821
|
}
|
|
2813
|
-
function
|
|
2822
|
+
function kn(e) {
|
|
2814
2823
|
return e.split(".").pop()?.toLowerCase() || "";
|
|
2815
2824
|
}
|
|
2816
|
-
function
|
|
2825
|
+
function An(e) {
|
|
2817
2826
|
let t = e.split(".").pop()?.toLowerCase() || "";
|
|
2818
2827
|
return /^(pdf|docx?|dotx?|xlsx?|xltx?|pptx?|potx?|txt|md|html?|csv|json|xml|yml|yaml|log|zip|rar|7z|tar|gz|odt|ods|odp|rtf|xlsm|xlsb|ppsx|numbers|tgz|bz2|xz|zst|js|ts|tsx|py|sh|sql)$/.test(t);
|
|
2819
2828
|
}
|
|
2820
|
-
function
|
|
2829
|
+
function jn(e) {
|
|
2821
2830
|
return !!e && !e.startsWith("file:");
|
|
2822
2831
|
}
|
|
2823
|
-
function
|
|
2832
|
+
function Mn(e) {
|
|
2824
2833
|
return btoa(encodeURIComponent(e)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
2825
2834
|
}
|
|
2826
|
-
async function
|
|
2835
|
+
async function Nn(e, t) {
|
|
2827
2836
|
try {
|
|
2828
|
-
let n =
|
|
2837
|
+
let n = Mn(e), r = await fetch(`/api/preview/${n}`, {
|
|
2829
2838
|
signal: t,
|
|
2830
2839
|
cache: "no-store"
|
|
2831
2840
|
});
|
|
@@ -2837,7 +2846,7 @@ async function Mn(e, t) {
|
|
|
2837
2846
|
return null;
|
|
2838
2847
|
}
|
|
2839
2848
|
}
|
|
2840
|
-
function
|
|
2849
|
+
function Pn(e, t, n) {
|
|
2841
2850
|
return new Promise((r, i) => {
|
|
2842
2851
|
let a = new XMLHttpRequest();
|
|
2843
2852
|
if (a.open("GET", e, !0), a.responseType = "arraybuffer", t) {
|
|
@@ -2875,64 +2884,64 @@ function Nn(e, t, n) {
|
|
|
2875
2884
|
a.send();
|
|
2876
2885
|
});
|
|
2877
2886
|
}
|
|
2878
|
-
function
|
|
2879
|
-
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() =>
|
|
2887
|
+
function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
2888
|
+
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() => Cn.has(s)), [u, d] = T(null), [p, m] = T(null), [h, g] = T(!1), [_, y] = T(null), [S, E] = T(!1), [k, A] = T(null), j = w(null), M = w(null), N = w(null), P = w(0), I = w(!1), L = w(null), ee = w(0), [te, ne] = T(!1), R = w(null), [re, ie] = T(0), [z, B] = T("none"), [V, H] = T(void 0), [ae, oe] = T(!1), U = e.attrs.src || "", W = e.attrs.name || U && U.split("/").pop()?.split("?")[0] || (U ? "attachment" : f("editor.attachment.lost")), G = e.attrs.size || 0, K = kn(W), q = !U;
|
|
2880
2889
|
x(() => {
|
|
2881
2890
|
if (!c) {
|
|
2882
|
-
|
|
2891
|
+
H(void 0), oe(!1);
|
|
2883
2892
|
return;
|
|
2884
2893
|
}
|
|
2885
|
-
let e =
|
|
2894
|
+
let e = Tn[K];
|
|
2886
2895
|
if (!e) {
|
|
2887
|
-
|
|
2896
|
+
H(void 0), oe(!1);
|
|
2888
2897
|
return;
|
|
2889
2898
|
}
|
|
2890
2899
|
let t = !0;
|
|
2891
|
-
return
|
|
2892
|
-
t &&
|
|
2900
|
+
return H(void 0), oe(!1), En[e]().then((e) => {
|
|
2901
|
+
t && H(e);
|
|
2893
2902
|
}).catch((n) => {
|
|
2894
|
-
console.error(`[attachment] renderer "${e}" load failed:`, n), t &&
|
|
2903
|
+
console.error(`[attachment] renderer "${e}" load failed:`, n), t && oe(!0);
|
|
2895
2904
|
}), () => {
|
|
2896
2905
|
t = !1;
|
|
2897
2906
|
};
|
|
2898
|
-
}, [c,
|
|
2899
|
-
let
|
|
2900
|
-
...
|
|
2901
|
-
renderers:
|
|
2907
|
+
}, [c, K]);
|
|
2908
|
+
let se = C(() => ({
|
|
2909
|
+
...wn,
|
|
2910
|
+
renderers: V ? [V] : [],
|
|
2902
2911
|
rendererMode: "replace"
|
|
2903
|
-
}), [
|
|
2912
|
+
}), [V]), ce = b((e) => {
|
|
2904
2913
|
l((t) => {
|
|
2905
2914
|
let n = typeof e == "function" ? e(t) : e;
|
|
2906
|
-
return
|
|
2915
|
+
return U && (n ? Cn.add(U) : Cn.delete(U)), n;
|
|
2907
2916
|
});
|
|
2908
|
-
}, [
|
|
2917
|
+
}, [U]);
|
|
2909
2918
|
x(() => {
|
|
2910
|
-
l(
|
|
2911
|
-
}, [
|
|
2912
|
-
let
|
|
2913
|
-
|
|
2914
|
-
window.scrollTo(0, P.current), L.current && (L.current.scrollTop = ee.current),
|
|
2919
|
+
l(U ? Cn.has(U) : !1);
|
|
2920
|
+
}, [U]);
|
|
2921
|
+
let J = b(() => {
|
|
2922
|
+
I.current = !0, ce(!0), window.setTimeout(() => {
|
|
2923
|
+
window.scrollTo(0, P.current), L.current && (L.current.scrollTop = ee.current), I.current && ce(!0), I.current = !1;
|
|
2915
2924
|
}, 0);
|
|
2916
|
-
}, [
|
|
2917
|
-
z === "web" ? (B("none"), document.body.style.overflow = "",
|
|
2918
|
-
}, [z]),
|
|
2925
|
+
}, [ce]), le = b(async () => {
|
|
2926
|
+
z === "web" ? (B("none"), document.body.style.overflow = "", J()) : (z === "native" && document.fullscreenElement && await document.exitFullscreen(), P.current = window.scrollY, ee.current = L.current?.scrollTop ?? 0, document.body.style.overflow = "hidden", B("web"));
|
|
2927
|
+
}, [z]), ue = b(async () => {
|
|
2919
2928
|
let e = M.current;
|
|
2920
2929
|
e && (z === "native" ? await document.exitFullscreen() : (z === "web" && (B("none"), document.body.style.overflow = ""), P.current = window.scrollY, ee.current = L.current?.scrollTop ?? 0, await e.requestFullscreen(), B("native")));
|
|
2921
|
-
}, [z,
|
|
2922
|
-
z === "none" && (
|
|
2930
|
+
}, [z, J]), de = b(() => {
|
|
2931
|
+
z === "none" && (I.current || ce((e) => !e));
|
|
2923
2932
|
}, [z]);
|
|
2924
2933
|
x(() => {
|
|
2925
2934
|
let e = () => {
|
|
2926
|
-
document.fullscreenElement || (z === "native" && B("none"),
|
|
2935
|
+
document.fullscreenElement || (z === "native" && B("none"), J());
|
|
2927
2936
|
}, t = (e) => {
|
|
2928
|
-
e.key === "Escape" && z === "web" && (B("none"), document.body.style.overflow = "",
|
|
2937
|
+
e.key === "Escape" && z === "web" && (B("none"), document.body.style.overflow = "", J());
|
|
2929
2938
|
};
|
|
2930
2939
|
return document.addEventListener("fullscreenchange", e), window.addEventListener("keydown", t), () => {
|
|
2931
2940
|
document.removeEventListener("fullscreenchange", e), window.removeEventListener("keydown", t);
|
|
2932
2941
|
};
|
|
2933
|
-
}, [z,
|
|
2942
|
+
}, [z, J]), x(() => {
|
|
2934
2943
|
let e = (e) => {
|
|
2935
|
-
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && i && !
|
|
2944
|
+
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && i && !mn()) {
|
|
2936
2945
|
if (e.preventDefault(), e.stopPropagation(), a) {
|
|
2937
2946
|
let { from: e, to: t } = a.state.selection;
|
|
2938
2947
|
R.current = {
|
|
@@ -2949,29 +2958,29 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2949
2958
|
a,
|
|
2950
2959
|
o
|
|
2951
2960
|
]), x(() => {
|
|
2952
|
-
if (!c || !
|
|
2961
|
+
if (!c || !jn(U)) {
|
|
2953
2962
|
d(null), y(null), N.current = null;
|
|
2954
2963
|
return;
|
|
2955
2964
|
}
|
|
2956
|
-
if (N.current ===
|
|
2965
|
+
if (N.current === U) return;
|
|
2957
2966
|
let e = new AbortController(), r = !0;
|
|
2958
2967
|
return g(!0), y(null), (async () => {
|
|
2959
|
-
let i =
|
|
2960
|
-
if (!a && !i && (a = await
|
|
2961
|
-
let n = await t(
|
|
2962
|
-
n && (a = await
|
|
2968
|
+
let i = U.includes("?X-Amz-"), a = null, o = null;
|
|
2969
|
+
if (!a && !i && (a = await Nn(U, e.signal)), !a && !i) try {
|
|
2970
|
+
let n = await t(U);
|
|
2971
|
+
n && (a = await Nn(n, e.signal) || await Pn(n, void 0, e.signal));
|
|
2963
2972
|
} catch (e) {
|
|
2964
2973
|
console.warn("[attachment] signPreviewUrl failed:", e);
|
|
2965
2974
|
}
|
|
2966
2975
|
if (!a && !i) try {
|
|
2967
|
-
let t = await n(
|
|
2976
|
+
let t = await n(U);
|
|
2968
2977
|
if (t) {
|
|
2969
2978
|
let n = { "X-Requested-With": "XMLHttpRequest" };
|
|
2970
2979
|
t.forEach((e, t) => {
|
|
2971
2980
|
n[t] = e;
|
|
2972
2981
|
});
|
|
2973
2982
|
try {
|
|
2974
|
-
a = await
|
|
2983
|
+
a = await Pn(U, n, e.signal);
|
|
2975
2984
|
} catch (e) {
|
|
2976
2985
|
console.warn("[attachment] signed headers XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
2977
2986
|
}
|
|
@@ -2980,18 +2989,18 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2980
2989
|
console.warn("[attachment] signPreviewUrlHeaders failed:", e);
|
|
2981
2990
|
}
|
|
2982
2991
|
if (!a) try {
|
|
2983
|
-
a = await
|
|
2992
|
+
a = await Pn(U, i ? void 0 : { "X-Requested-With": "XMLHttpRequest" }, e.signal);
|
|
2984
2993
|
} catch (e) {
|
|
2985
2994
|
console.warn("[attachment] plain XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
2986
2995
|
}
|
|
2987
2996
|
if (!a) throw o || /* @__PURE__ */ Error("所有 fetch 方法均失败");
|
|
2988
2997
|
if (!r) return;
|
|
2989
|
-
d(a), N.current =
|
|
2998
|
+
d(a), N.current = U;
|
|
2990
2999
|
let s = URL.createObjectURL(new Blob([a], { type: "application/octet-stream" }));
|
|
2991
3000
|
m(s), g(!1);
|
|
2992
3001
|
})().catch((e) => {
|
|
2993
3002
|
if (r && !(e instanceof DOMException && e.name === "AbortError")) {
|
|
2994
|
-
if (N.current ===
|
|
3003
|
+
if (N.current === U) {
|
|
2995
3004
|
g(!1);
|
|
2996
3005
|
return;
|
|
2997
3006
|
}
|
|
@@ -3000,49 +3009,49 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3000
3009
|
}), () => {
|
|
3001
3010
|
r = !1, e.abort();
|
|
3002
3011
|
};
|
|
3003
|
-
}, [c,
|
|
3012
|
+
}, [c, U]), x(() => () => {
|
|
3004
3013
|
p && URL.revokeObjectURL(p), d(null);
|
|
3005
3014
|
}, []), x(() => () => {
|
|
3006
3015
|
p && URL.revokeObjectURL(p), m(null), d(null), N.current = null;
|
|
3007
|
-
}, [
|
|
3016
|
+
}, [U]), x(() => {
|
|
3008
3017
|
if (k !== "success" && k !== "error") return;
|
|
3009
3018
|
let e = window.setTimeout(() => A(null), 2400);
|
|
3010
3019
|
return () => window.clearTimeout(e);
|
|
3011
3020
|
}, [k]);
|
|
3012
|
-
let
|
|
3021
|
+
let fe = b(async () => {
|
|
3013
3022
|
E(!0), A("loading");
|
|
3014
3023
|
try {
|
|
3015
3024
|
if (p) {
|
|
3016
3025
|
let e = document.createElement("a");
|
|
3017
|
-
e.href = p, e.download =
|
|
3026
|
+
e.href = p, e.download = W, document.body.appendChild(e), e.click(), document.body.removeChild(e), A("success");
|
|
3018
3027
|
return;
|
|
3019
3028
|
}
|
|
3020
|
-
let e =
|
|
3029
|
+
let e = U.includes("?X-Amz-"), r = null;
|
|
3021
3030
|
if (!e) try {
|
|
3022
|
-
let e = await t(
|
|
3031
|
+
let e = await t(U);
|
|
3023
3032
|
e && (r = await fetch(e, { headers: { "X-Requested-With": "XMLHttpRequest" } }), r.ok || (r = null));
|
|
3024
3033
|
} catch {}
|
|
3025
3034
|
if (!r && !e) try {
|
|
3026
|
-
let e = await n(
|
|
3027
|
-
e && (r = await fetch(
|
|
3035
|
+
let e = await n(U);
|
|
3036
|
+
e && (r = await fetch(U, { headers: (() => {
|
|
3028
3037
|
let t = new Headers(e);
|
|
3029
3038
|
return t.set("X-Requested-With", "XMLHttpRequest"), t;
|
|
3030
3039
|
})() }), r.ok || (r = null));
|
|
3031
3040
|
} catch {}
|
|
3032
|
-
if (r ||= await fetch(
|
|
3041
|
+
if (r ||= await fetch(U, { headers: { "X-Requested-With": "XMLHttpRequest" } }), !r || !r.ok) throw Error("下载失败");
|
|
3033
3042
|
let i = await r.blob(), a = URL.createObjectURL(i), o = document.createElement("a");
|
|
3034
|
-
o.href = a, o.download =
|
|
3043
|
+
o.href = a, o.download = W, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(a), A("success");
|
|
3035
3044
|
} catch (e) {
|
|
3036
3045
|
console.error("[attachment] download failed:", e), A("error");
|
|
3037
3046
|
} finally {
|
|
3038
3047
|
E(!1);
|
|
3039
3048
|
}
|
|
3040
3049
|
}, [
|
|
3041
|
-
|
|
3042
|
-
|
|
3050
|
+
U,
|
|
3051
|
+
W,
|
|
3043
3052
|
p
|
|
3044
3053
|
]);
|
|
3045
|
-
return /* @__PURE__ */ O(
|
|
3054
|
+
return /* @__PURE__ */ O(F, {
|
|
3046
3055
|
ref: j,
|
|
3047
3056
|
as: "div",
|
|
3048
3057
|
className: `attachment-embed group/att ${i ? "is-selected" : ""}`,
|
|
@@ -3059,7 +3068,7 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3059
3068
|
className: "att-info",
|
|
3060
3069
|
children: [/* @__PURE__ */ D("span", {
|
|
3061
3070
|
className: "att-icon",
|
|
3062
|
-
children:
|
|
3071
|
+
children: q ? /* @__PURE__ */ O("svg", {
|
|
3063
3072
|
width: "22",
|
|
3064
3073
|
height: "22",
|
|
3065
3074
|
viewBox: "0 0 24 24",
|
|
@@ -3075,15 +3084,15 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3075
3084
|
/* @__PURE__ */ D("path", { d: "M12 9v4" }),
|
|
3076
3085
|
/* @__PURE__ */ D("path", { d: "M12 17h.01" })
|
|
3077
3086
|
]
|
|
3078
|
-
}) :
|
|
3087
|
+
}) : On(W)
|
|
3079
3088
|
}), /* @__PURE__ */ O("div", {
|
|
3080
3089
|
className: "att-meta",
|
|
3081
3090
|
children: [/* @__PURE__ */ D("span", {
|
|
3082
3091
|
className: "att-name",
|
|
3083
|
-
children:
|
|
3084
|
-
}),
|
|
3092
|
+
children: W
|
|
3093
|
+
}), G > 0 && /* @__PURE__ */ D("span", {
|
|
3085
3094
|
className: "att-size",
|
|
3086
|
-
children:
|
|
3095
|
+
children: Dn(G)
|
|
3087
3096
|
})]
|
|
3088
3097
|
})]
|
|
3089
3098
|
}), /* @__PURE__ */ O("div", {
|
|
@@ -3136,11 +3145,11 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3136
3145
|
}), /* @__PURE__ */ O("div", {
|
|
3137
3146
|
className: "att-actions",
|
|
3138
3147
|
children: [
|
|
3139
|
-
|
|
3148
|
+
U && An(W) && /* @__PURE__ */ D("button", {
|
|
3140
3149
|
type: "button",
|
|
3141
3150
|
className: "att-btn",
|
|
3142
3151
|
onMouseDown: (e) => {
|
|
3143
|
-
e.preventDefault(), e.stopPropagation(),
|
|
3152
|
+
e.preventDefault(), e.stopPropagation(), de();
|
|
3144
3153
|
},
|
|
3145
3154
|
title: f("editor.attachment.preview"),
|
|
3146
3155
|
"aria-label": f("editor.attachment.preview"),
|
|
@@ -3166,8 +3175,8 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3166
3175
|
/* @__PURE__ */ D("button", {
|
|
3167
3176
|
type: "button",
|
|
3168
3177
|
className: "att-btn",
|
|
3169
|
-
onClick:
|
|
3170
|
-
disabled: S ||
|
|
3178
|
+
onClick: fe,
|
|
3179
|
+
disabled: S || q,
|
|
3171
3180
|
title: S ? "正在准备下载" : f("editor.attachment.download"),
|
|
3172
3181
|
"aria-label": S ? "正在准备下载" : f("editor.attachment.download"),
|
|
3173
3182
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -3189,7 +3198,7 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3189
3198
|
type: "button",
|
|
3190
3199
|
className: "att-btn att-btn--del",
|
|
3191
3200
|
onClick: () => {
|
|
3192
|
-
!o ||
|
|
3201
|
+
!o || mn() || ($(!0), ne(!0));
|
|
3193
3202
|
},
|
|
3194
3203
|
title: f("editor.attachment.delete"),
|
|
3195
3204
|
"aria-label": f("editor.attachment.delete"),
|
|
@@ -3230,7 +3239,7 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3230
3239
|
children: h && !u && !p ? /* @__PURE__ */ D("div", {
|
|
3231
3240
|
className: "flex items-center justify-center h-full text-default-400 text-sm",
|
|
3232
3241
|
children: f("editor.attachment.loadingPreview")
|
|
3233
|
-
}) : (_ ||
|
|
3242
|
+
}) : (_ || ae) && !u && !p ? /* @__PURE__ */ O("div", {
|
|
3234
3243
|
className: "flex h-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-default-500",
|
|
3235
3244
|
children: [/* @__PURE__ */ D("div", {
|
|
3236
3245
|
className: "font-medium text-default-700",
|
|
@@ -3245,15 +3254,15 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3245
3254
|
style: { background: "#fff" },
|
|
3246
3255
|
children: f("editor.attachment.loadingPreview")
|
|
3247
3256
|
}),
|
|
3248
|
-
children: u || p ||
|
|
3257
|
+
children: u || p || U ? V ? /* @__PURE__ */ D(Sn, {
|
|
3249
3258
|
buffer: u || void 0,
|
|
3250
|
-
url: p ||
|
|
3251
|
-
name:
|
|
3252
|
-
filename:
|
|
3253
|
-
type:
|
|
3254
|
-
size:
|
|
3255
|
-
options:
|
|
3256
|
-
}, `${
|
|
3259
|
+
url: p || U,
|
|
3260
|
+
name: W,
|
|
3261
|
+
filename: W,
|
|
3262
|
+
type: K,
|
|
3263
|
+
size: G || u?.byteLength || 0,
|
|
3264
|
+
options: se
|
|
3265
|
+
}, `${U}-${re}`) : /* @__PURE__ */ D("div", {
|
|
3257
3266
|
className: "flex h-full items-center justify-center text-sm text-default-400",
|
|
3258
3267
|
children: "正在加载预览引擎..."
|
|
3259
3268
|
}) : /* @__PURE__ */ D("div", {
|
|
@@ -3280,7 +3289,7 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3280
3289
|
},
|
|
3281
3290
|
children: [/* @__PURE__ */ D("button", {
|
|
3282
3291
|
type: "button",
|
|
3283
|
-
onClick:
|
|
3292
|
+
onClick: le,
|
|
3284
3293
|
title: z === "web" ? "退出网页全屏" : "网页全屏",
|
|
3285
3294
|
"aria-label": z === "web" ? "退出网页全屏" : "网页全屏",
|
|
3286
3295
|
style: {
|
|
@@ -3318,7 +3327,7 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3318
3327
|
})
|
|
3319
3328
|
}), /* @__PURE__ */ D("button", {
|
|
3320
3329
|
type: "button",
|
|
3321
|
-
onClick:
|
|
3330
|
+
onClick: ue,
|
|
3322
3331
|
title: z === "native" ? "退出全屏" : "全屏",
|
|
3323
3332
|
"aria-label": z === "native" ? "退出全屏" : "全屏",
|
|
3324
3333
|
style: {
|
|
@@ -3357,10 +3366,10 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3357
3366
|
})]
|
|
3358
3367
|
})]
|
|
3359
3368
|
})]
|
|
3360
|
-
}), /* @__PURE__ */ D(
|
|
3369
|
+
}), /* @__PURE__ */ D(yn, {
|
|
3361
3370
|
open: te,
|
|
3362
3371
|
title: "确认删除附件",
|
|
3363
|
-
message:
|
|
3372
|
+
message: q ? "此操作将删除该附件节点,不可撤销。" : `此操作将同时删除对象存储中的文件(${W}),不可撤销。`,
|
|
3364
3373
|
onCancel: () => {
|
|
3365
3374
|
$(!1), ne(!1);
|
|
3366
3375
|
},
|
|
@@ -3369,12 +3378,12 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3369
3378
|
if (a) {
|
|
3370
3379
|
let e = R.current, t = e?.from ?? a.state.selection.from, n = e?.to ?? a.state.selection.to, r = [];
|
|
3371
3380
|
a.state.doc.nodesBetween(t, n, (e) => {
|
|
3372
|
-
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(
|
|
3381
|
+
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(Ht(e.attrs.src));
|
|
3373
3382
|
}), await Promise.all(r), $(!1), await new Promise((e) => setTimeout(e, 300)), a.chain().focus().setTextSelection({
|
|
3374
3383
|
from: t,
|
|
3375
3384
|
to: n
|
|
3376
3385
|
}).deleteSelection().run();
|
|
3377
|
-
} else await
|
|
3386
|
+
} else await Ht(U), $(!1), await new Promise((e) => setTimeout(e, 300)), r();
|
|
3378
3387
|
} catch {
|
|
3379
3388
|
$(!1);
|
|
3380
3389
|
}
|
|
@@ -3384,13 +3393,13 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3384
3393
|
}
|
|
3385
3394
|
//#endregion
|
|
3386
3395
|
//#region src/editor/embeds/attachment.ts
|
|
3387
|
-
var
|
|
3396
|
+
var In = re.create({
|
|
3388
3397
|
name: "attachmentEmbed",
|
|
3389
3398
|
group: "block",
|
|
3390
3399
|
atom: !0,
|
|
3391
3400
|
inline: !1,
|
|
3392
3401
|
addNodeView() {
|
|
3393
|
-
return
|
|
3402
|
+
return I(Fn);
|
|
3394
3403
|
},
|
|
3395
3404
|
addAttributes() {
|
|
3396
3405
|
return {
|
|
@@ -3439,7 +3448,7 @@ var Fn = re.create({
|
|
|
3439
3448
|
});
|
|
3440
3449
|
//#endregion
|
|
3441
3450
|
//#region src/editor/embeds/audio-view.tsx
|
|
3442
|
-
function
|
|
3451
|
+
function Ln({ node: e, deleteNode: t, editor: r }) {
|
|
3443
3452
|
let i = e.attrs.src || "", a = e.attrs.name || i.split("/").pop()?.split("?")[0] || "audio", [o, s] = T(!1), c = r?.isEditable ?? !0;
|
|
3444
3453
|
x(() => () => {
|
|
3445
3454
|
i.startsWith("blob:") && URL.revokeObjectURL(i);
|
|
@@ -3471,7 +3480,7 @@ function In({ node: e, deleteNode: t, editor: r }) {
|
|
|
3471
3480
|
})(), () => {
|
|
3472
3481
|
e = !0, m.current &&= (URL.revokeObjectURL(m.current), null);
|
|
3473
3482
|
};
|
|
3474
|
-
}, [i]), /* @__PURE__ */ O(
|
|
3483
|
+
}, [i]), /* @__PURE__ */ O(F, {
|
|
3475
3484
|
as: "div",
|
|
3476
3485
|
className: "audio-embed group/audio",
|
|
3477
3486
|
style: { margin: "1rem 0" },
|
|
@@ -3505,7 +3514,7 @@ function In({ node: e, deleteNode: t, editor: r }) {
|
|
|
3505
3514
|
type: "button",
|
|
3506
3515
|
className: "audio-embed-btn audio-embed-btn--del",
|
|
3507
3516
|
onClick: () => {
|
|
3508
|
-
|
|
3517
|
+
mn() || ($(!0), s(!0));
|
|
3509
3518
|
},
|
|
3510
3519
|
title: "删除",
|
|
3511
3520
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -3551,7 +3560,7 @@ function In({ node: e, deleteNode: t, editor: r }) {
|
|
|
3551
3560
|
}), "音频文件缺失"]
|
|
3552
3561
|
})
|
|
3553
3562
|
})]
|
|
3554
|
-
}), /* @__PURE__ */ D(
|
|
3563
|
+
}), /* @__PURE__ */ D(yn, {
|
|
3555
3564
|
open: o,
|
|
3556
3565
|
title: "确认删除音频",
|
|
3557
3566
|
message: `此操作将同时删除对象存储中的文件(${a}),不可撤销。`,
|
|
@@ -3560,7 +3569,7 @@ function In({ node: e, deleteNode: t, editor: r }) {
|
|
|
3560
3569
|
},
|
|
3561
3570
|
onConfirm: async () => {
|
|
3562
3571
|
try {
|
|
3563
|
-
await
|
|
3572
|
+
await Ht(i);
|
|
3564
3573
|
} catch {}
|
|
3565
3574
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3566
3575
|
}
|
|
@@ -3569,16 +3578,16 @@ function In({ node: e, deleteNode: t, editor: r }) {
|
|
|
3569
3578
|
}
|
|
3570
3579
|
//#endregion
|
|
3571
3580
|
//#region src/editor/embeds/audio.ts
|
|
3572
|
-
function
|
|
3581
|
+
function Rn(e) {
|
|
3573
3582
|
return /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|$)/i.test(e) || /\/.*\.(mp3|wav|ogg|flac)/i.test(e);
|
|
3574
3583
|
}
|
|
3575
|
-
var
|
|
3584
|
+
var zn = re.create({
|
|
3576
3585
|
name: "audioEmbed",
|
|
3577
3586
|
group: "block",
|
|
3578
3587
|
atom: !0,
|
|
3579
3588
|
inline: !1,
|
|
3580
3589
|
addNodeView() {
|
|
3581
|
-
return
|
|
3590
|
+
return I(Ln);
|
|
3582
3591
|
},
|
|
3583
3592
|
addProseMirrorPlugins() {
|
|
3584
3593
|
return [new z({ props: { handlePaste(e, t) {
|
|
@@ -3587,7 +3596,7 @@ var Rn = re.create({
|
|
|
3587
3596
|
let r = n.split(/\r?\n/);
|
|
3588
3597
|
for (let n of r) {
|
|
3589
3598
|
let r = n.trim();
|
|
3590
|
-
if (!r || r.includes(" ") || !
|
|
3599
|
+
if (!r || r.includes(" ") || !Rn(r)) continue;
|
|
3591
3600
|
t.preventDefault();
|
|
3592
3601
|
let i = e.state.schema.nodes.audioEmbed.create({ src: r });
|
|
3593
3602
|
return e.dispatch(e.state.tr.replaceSelectionWith(i)), !0;
|
|
@@ -3634,17 +3643,17 @@ var Rn = re.create({
|
|
|
3634
3643
|
});
|
|
3635
3644
|
//#endregion
|
|
3636
3645
|
//#region src/editor/embeds/video-view.tsx
|
|
3637
|
-
function
|
|
3646
|
+
function Bn(e) {
|
|
3638
3647
|
return e ? /bilibili\.com|BV[a-zA-Z0-9]{10}|av\d+/i.test(e) ? "bilibili" : /xiaohongshu\.com|xhslink\.com/i.test(e) ? "xiaohongshu" : /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|$)/i.test(e) || /\/.*\.(mp4|m3u8|mov|webm|flv|mkv)/i.test(e) ? "direct" : "unknown" : "unknown";
|
|
3639
3648
|
}
|
|
3640
|
-
function
|
|
3649
|
+
function Vn(e) {
|
|
3641
3650
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
3642
3651
|
if (t) return t[0];
|
|
3643
3652
|
let n = e.match(/av(\d+)/i);
|
|
3644
3653
|
return n ? n[0] : e;
|
|
3645
3654
|
}
|
|
3646
|
-
function
|
|
3647
|
-
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ?
|
|
3655
|
+
function Hn({ node: e, deleteNode: t, editor: n }) {
|
|
3656
|
+
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ? Bn(r) : i, [o, s] = T(!1), [c, l] = T(!1), [u, d] = T(!1), f = n?.isEditable ?? !0, p = !f && r.startsWith("blob:"), m = /* @__PURE__ */ D(yn, {
|
|
3648
3657
|
open: o,
|
|
3649
3658
|
title: "确认删除视频",
|
|
3650
3659
|
message: "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
@@ -3653,7 +3662,7 @@ function Vn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3653
3662
|
},
|
|
3654
3663
|
onConfirm: async () => {
|
|
3655
3664
|
try {
|
|
3656
|
-
await
|
|
3665
|
+
await Ht(r);
|
|
3657
3666
|
} catch {}
|
|
3658
3667
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3659
3668
|
}
|
|
@@ -3756,8 +3765,8 @@ function Vn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3756
3765
|
}, [a, h]), x(() => {
|
|
3757
3766
|
u && (_.current?.destroy(), _.current = null);
|
|
3758
3767
|
}, [u]), a === "bilibili") {
|
|
3759
|
-
let e =
|
|
3760
|
-
return /* @__PURE__ */ O(
|
|
3768
|
+
let e = Vn(r);
|
|
3769
|
+
return /* @__PURE__ */ O(F, {
|
|
3761
3770
|
as: "div",
|
|
3762
3771
|
className: "video-embed video-embed--bilibili group/video",
|
|
3763
3772
|
style: { margin: "1rem 0" },
|
|
@@ -3833,7 +3842,7 @@ function Vn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3833
3842
|
className: "video-fs-btn video-fs-btn--del",
|
|
3834
3843
|
title: "删除",
|
|
3835
3844
|
onClick: () => {
|
|
3836
|
-
|
|
3845
|
+
mn() || ($(!0), s(!0));
|
|
3837
3846
|
},
|
|
3838
3847
|
children: /* @__PURE__ */ D("svg", {
|
|
3839
3848
|
width: "12",
|
|
@@ -3875,7 +3884,7 @@ function Vn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3875
3884
|
}), m]
|
|
3876
3885
|
});
|
|
3877
3886
|
}
|
|
3878
|
-
return a === "xiaohongshu" ? /* @__PURE__ */ O(
|
|
3887
|
+
return a === "xiaohongshu" ? /* @__PURE__ */ O(F, {
|
|
3879
3888
|
as: "div",
|
|
3880
3889
|
className: "video-embed video-embed--xiaohongshu",
|
|
3881
3890
|
style: {
|
|
@@ -3921,7 +3930,7 @@ function Vn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3921
3930
|
},
|
|
3922
3931
|
children: "在小红书中打开 →"
|
|
3923
3932
|
})] })]
|
|
3924
|
-
}) : /* @__PURE__ */ O(
|
|
3933
|
+
}) : /* @__PURE__ */ O(F, {
|
|
3925
3934
|
as: "div",
|
|
3926
3935
|
className: "video-embed video-embed--direct group/video",
|
|
3927
3936
|
style: {
|
|
@@ -3940,7 +3949,7 @@ function Vn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3940
3949
|
className: "video-fs-btn video-fs-btn--del",
|
|
3941
3950
|
title: "删除",
|
|
3942
3951
|
onClick: () => {
|
|
3943
|
-
|
|
3952
|
+
mn() || ($(!0), s(!0));
|
|
3944
3953
|
},
|
|
3945
3954
|
children: /* @__PURE__ */ D("svg", {
|
|
3946
3955
|
width: "12",
|
|
@@ -4097,26 +4106,26 @@ function Vn({ node: e, deleteNode: t, editor: n }) {
|
|
|
4097
4106
|
}
|
|
4098
4107
|
//#endregion
|
|
4099
4108
|
//#region src/editor/embeds/video.ts
|
|
4100
|
-
function
|
|
4109
|
+
function Un(e) {
|
|
4101
4110
|
return /bilibili\.com|BV[a-zA-Z0-9]{10}|av\d+/i.test(e) ? "bilibili" : /xiaohongshu\.com|xhslink\.com/i.test(e) ? "xiaohongshu" : /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|$)/i.test(e) || /\/.*\.(mp4|m3u8|mov|webm|flv|mkv)/i.test(e) ? "direct" : "unknown";
|
|
4102
4111
|
}
|
|
4103
|
-
function
|
|
4112
|
+
function Wn(e) {
|
|
4104
4113
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
4105
4114
|
if (t) return t[0];
|
|
4106
4115
|
let n = e.match(/av(\d+)/i);
|
|
4107
4116
|
return n ? n[0] : e;
|
|
4108
4117
|
}
|
|
4109
|
-
function
|
|
4118
|
+
function Gn(e) {
|
|
4110
4119
|
let t = e.match(/explore\/([a-zA-Z0-9]+)/);
|
|
4111
4120
|
return t ? t[1] : e;
|
|
4112
4121
|
}
|
|
4113
|
-
var
|
|
4122
|
+
var Kn = re.create({
|
|
4114
4123
|
name: "videoEmbed",
|
|
4115
4124
|
group: "block",
|
|
4116
4125
|
atom: !0,
|
|
4117
4126
|
inline: !1,
|
|
4118
4127
|
addNodeView() {
|
|
4119
|
-
return
|
|
4128
|
+
return I(Hn);
|
|
4120
4129
|
},
|
|
4121
4130
|
addProseMirrorPlugins() {
|
|
4122
4131
|
return [new z({ props: {
|
|
@@ -4141,7 +4150,7 @@ var Gn = re.create({
|
|
|
4141
4150
|
for (let n of r) {
|
|
4142
4151
|
let r = n.trim();
|
|
4143
4152
|
if (!r || r.includes(" ")) continue;
|
|
4144
|
-
let i =
|
|
4153
|
+
let i = Un(r);
|
|
4145
4154
|
if (i === "unknown") continue;
|
|
4146
4155
|
t.preventDefault();
|
|
4147
4156
|
let a = e.state.schema.nodes.videoEmbed.create({
|
|
@@ -4173,7 +4182,7 @@ var Gn = re.create({
|
|
|
4173
4182
|
let t = e, n = t.getAttribute("src") || t.getAttribute("data-src") || "";
|
|
4174
4183
|
return {
|
|
4175
4184
|
src: n,
|
|
4176
|
-
source:
|
|
4185
|
+
source: Un(n)
|
|
4177
4186
|
};
|
|
4178
4187
|
}
|
|
4179
4188
|
},
|
|
@@ -4182,9 +4191,9 @@ var Gn = re.create({
|
|
|
4182
4191
|
];
|
|
4183
4192
|
},
|
|
4184
4193
|
renderHTML({ HTMLAttributes: e }) {
|
|
4185
|
-
let t = e.src || "", n =
|
|
4194
|
+
let t = e.src || "", n = Un(t);
|
|
4186
4195
|
if (n === "bilibili") {
|
|
4187
|
-
let e =
|
|
4196
|
+
let e = Wn(t);
|
|
4188
4197
|
return [
|
|
4189
4198
|
"div",
|
|
4190
4199
|
{
|
|
@@ -4205,7 +4214,7 @@ var Gn = re.create({
|
|
|
4205
4214
|
}]
|
|
4206
4215
|
];
|
|
4207
4216
|
}
|
|
4208
|
-
if (n === "xiaohongshu") return
|
|
4217
|
+
if (n === "xiaohongshu") return Gn(t), [
|
|
4209
4218
|
"div",
|
|
4210
4219
|
{
|
|
4211
4220
|
"data-video-embed": "xiaohongshu",
|
|
@@ -4257,7 +4266,7 @@ var Gn = re.create({
|
|
|
4257
4266
|
},
|
|
4258
4267
|
addCommands() {
|
|
4259
4268
|
return { insertVideo: (e) => ({ chain: t }) => {
|
|
4260
|
-
let n =
|
|
4269
|
+
let n = Un(e.src);
|
|
4261
4270
|
return t().insertContent({
|
|
4262
4271
|
type: this.name,
|
|
4263
4272
|
attrs: {
|
|
@@ -4267,13 +4276,13 @@ var Gn = re.create({
|
|
|
4267
4276
|
}).focus().run();
|
|
4268
4277
|
} };
|
|
4269
4278
|
}
|
|
4270
|
-
}),
|
|
4271
|
-
async function
|
|
4272
|
-
|
|
4273
|
-
let t =
|
|
4279
|
+
}), qn = null;
|
|
4280
|
+
async function Jn(e) {
|
|
4281
|
+
qn ||= await import("beautiful-mermaid");
|
|
4282
|
+
let t = qn.renderMermaidSVG;
|
|
4274
4283
|
return t(e);
|
|
4275
4284
|
}
|
|
4276
|
-
var
|
|
4285
|
+
var Yn = [
|
|
4277
4286
|
{
|
|
4278
4287
|
value: "javascript",
|
|
4279
4288
|
label: "JavaScript",
|
|
@@ -4434,7 +4443,7 @@ var Jn = [
|
|
|
4434
4443
|
label: "Plain Text",
|
|
4435
4444
|
color: "#6b7280"
|
|
4436
4445
|
}
|
|
4437
|
-
],
|
|
4446
|
+
], Xn = {
|
|
4438
4447
|
javascript: "js",
|
|
4439
4448
|
typescript: "ts",
|
|
4440
4449
|
python: "py",
|
|
@@ -4460,7 +4469,7 @@ var Jn = [
|
|
|
4460
4469
|
txt: "txt",
|
|
4461
4470
|
vue: "vue",
|
|
4462
4471
|
react: "jsx"
|
|
4463
|
-
},
|
|
4472
|
+
}, Zn = {
|
|
4464
4473
|
js: "javascript",
|
|
4465
4474
|
ts: "typescript",
|
|
4466
4475
|
py: "python",
|
|
@@ -4476,13 +4485,12 @@ var Jn = [
|
|
|
4476
4485
|
jsx: "javascript",
|
|
4477
4486
|
tsx: "typescript"
|
|
4478
4487
|
};
|
|
4479
|
-
function Zn(e) {
|
|
4480
|
-
return e instanceof Element && !!e.closest(".cb-code-area");
|
|
4481
|
-
}
|
|
4482
4488
|
function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i, selected: a }) {
|
|
4483
|
-
let o = n?.isEditable ?? !0, s = !o, [c, l] = T(!1), [u, d] = T(!1), [f, m] = T(!1), [h, g] = T(
|
|
4484
|
-
|
|
4485
|
-
|
|
4489
|
+
let o = n?.isEditable ?? !0, s = !o, [c, l] = T(!1), [u, d] = T(!1), [f, m] = T(!1), [h, g] = T(!1), [_, v] = T(220), [y, S] = T({
|
|
4490
|
+
top: 0,
|
|
4491
|
+
left: 0,
|
|
4492
|
+
width: 210
|
|
4493
|
+
}), [k, A] = T(""), [j, M] = T(!1), [N, P] = T(null), [F, I] = T(null), [L, ee] = T(!1), te = w(null), R = w(null), re = w(null), ie = w(null), z = w(null), B = w(null), V = e.attrs.language || "", H = Yn.find((e) => e.value === (Zn[V] ?? V)), ae = V === "mermaid", oe = b(() => {
|
|
4486
4494
|
if (!n || typeof r != "function") return null;
|
|
4487
4495
|
let t = r();
|
|
4488
4496
|
return typeof t == "number" ? {
|
|
@@ -4493,18 +4501,41 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4493
4501
|
n,
|
|
4494
4502
|
r,
|
|
4495
4503
|
e.nodeSize
|
|
4496
|
-
]),
|
|
4497
|
-
o && (
|
|
4498
|
-
}, [oe, o]),
|
|
4499
|
-
let e =
|
|
4500
|
-
return e ?
|
|
4501
|
-
}, [
|
|
4504
|
+
]), U = b(() => {
|
|
4505
|
+
o && (mn() || (B.current = oe(), window.getSelection()?.removeAllRanges(), $(!0), M(!0)));
|
|
4506
|
+
}, [oe, o]), W = C(() => {
|
|
4507
|
+
let e = k.trim().toLowerCase();
|
|
4508
|
+
return e ? Yn.filter((t) => t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e)) : Yn;
|
|
4509
|
+
}, [k]);
|
|
4510
|
+
x(() => {
|
|
4511
|
+
(z.current?.parentElement?.querySelector(".cb-code-area"))?.classList.toggle("cb-code-area--collapsed", u);
|
|
4512
|
+
}, [u]);
|
|
4513
|
+
let G = b(() => {
|
|
4514
|
+
let e = re.current;
|
|
4515
|
+
if (!e) return;
|
|
4516
|
+
let t = e.getBoundingClientRect(), n = Math.min(t.left, window.innerWidth - 210 - 8), r = window.innerHeight - t.bottom - 12, i = t.top - 12, a = Yn.length * 31 + 8, o = r - 52, s = i - 52;
|
|
4517
|
+
o < 220 && s > o ? (g(!0), v(Math.max(120, Math.min(a, s))), S({
|
|
4518
|
+
top: t.top,
|
|
4519
|
+
left: n,
|
|
4520
|
+
width: 210
|
|
4521
|
+
})) : (g(!1), v(Math.max(120, Math.min(a, o))), S({
|
|
4522
|
+
top: t.bottom + 4,
|
|
4523
|
+
left: n,
|
|
4524
|
+
width: 210
|
|
4525
|
+
}));
|
|
4526
|
+
}, []);
|
|
4502
4527
|
x(() => {
|
|
4503
|
-
|
|
4504
|
-
|
|
4528
|
+
if (!f) return;
|
|
4529
|
+
A(""), G();
|
|
4530
|
+
let e = setTimeout(() => ie.current?.focus(), 50);
|
|
4531
|
+
return window.addEventListener("resize", G), window.addEventListener("scroll", G, !0), () => {
|
|
4532
|
+
clearTimeout(e), window.removeEventListener("resize", G), window.removeEventListener("scroll", G, !0);
|
|
4533
|
+
};
|
|
4534
|
+
}, [f, G]), x(() => {
|
|
4505
4535
|
if (!f) return;
|
|
4506
4536
|
let e = (e) => {
|
|
4507
|
-
|
|
4537
|
+
let t = e.target;
|
|
4538
|
+
t && (re.current?.contains(t) || R.current?.contains(t) || m(!1));
|
|
4508
4539
|
};
|
|
4509
4540
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
4510
4541
|
}, [f]), x(() => {
|
|
@@ -4515,15 +4546,15 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4515
4546
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
4516
4547
|
}, [f]), x(() => {
|
|
4517
4548
|
let e = (e) => {
|
|
4518
|
-
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && a && !
|
|
4549
|
+
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && a && !mn()) {
|
|
4519
4550
|
if (e.preventDefault(), e.stopPropagation(), n) {
|
|
4520
4551
|
let { from: e, to: t } = n.state.selection;
|
|
4521
|
-
|
|
4552
|
+
B.current = {
|
|
4522
4553
|
from: e,
|
|
4523
4554
|
to: t
|
|
4524
4555
|
};
|
|
4525
4556
|
}
|
|
4526
|
-
window.getSelection()?.removeAllRanges(), $(!0),
|
|
4557
|
+
window.getSelection()?.removeAllRanges(), $(!0), M(!0);
|
|
4527
4558
|
}
|
|
4528
4559
|
};
|
|
4529
4560
|
return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
|
|
@@ -4532,29 +4563,9 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4532
4563
|
n,
|
|
4533
4564
|
o
|
|
4534
4565
|
]);
|
|
4535
|
-
let
|
|
4536
|
-
L((t) => t.length === e.length && t.every((t, n) => t === e[n]) ? t : e);
|
|
4537
|
-
}, []), W = b(() => {
|
|
4538
|
-
let e = ne.current, t = R.current;
|
|
4539
|
-
if (!e || !t) return;
|
|
4540
|
-
t.style.width = `${e.clientWidth}px`;
|
|
4541
|
-
let n = t.children, r = Array(n.length);
|
|
4542
|
-
for (let e = 0; e < n.length; e++) r[e] = n[e].offsetHeight;
|
|
4543
|
-
U(r);
|
|
4544
|
-
}, [U]);
|
|
4545
|
-
S(() => {
|
|
4546
|
-
W();
|
|
4547
|
-
}, [W, ce]), x(() => {
|
|
4548
|
-
let e = ne.current;
|
|
4549
|
-
if (!e) return;
|
|
4550
|
-
let t = new ResizeObserver(() => W());
|
|
4551
|
-
return t.observe(e), window.addEventListener("resize", W), document.fonts?.ready?.then(() => W()), () => {
|
|
4552
|
-
t.disconnect(), window.removeEventListener("resize", W);
|
|
4553
|
-
};
|
|
4554
|
-
}, [W]);
|
|
4555
|
-
let ue = b((e) => {
|
|
4566
|
+
let K = b((e) => {
|
|
4556
4567
|
t({ language: e || null }), m(!1);
|
|
4557
|
-
}, [t]),
|
|
4568
|
+
}, [t]), q = b(() => {
|
|
4558
4569
|
if (o) {
|
|
4559
4570
|
if (n && r) {
|
|
4560
4571
|
let e = r();
|
|
@@ -4566,37 +4577,45 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4566
4577
|
n,
|
|
4567
4578
|
r,
|
|
4568
4579
|
o
|
|
4569
|
-
]),
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4580
|
+
]), se = b(() => {
|
|
4581
|
+
let t = e.textContent, n = (e) => {
|
|
4582
|
+
let t = document.createElement("textarea");
|
|
4583
|
+
t.value = e, t.style.position = "fixed", t.style.opacity = "0", document.body.appendChild(t), t.select();
|
|
4584
|
+
try {
|
|
4585
|
+
document.execCommand("copy");
|
|
4586
|
+
} catch {}
|
|
4587
|
+
document.body.removeChild(t);
|
|
4588
|
+
};
|
|
4589
|
+
navigator.clipboard?.writeText ? navigator.clipboard.writeText(t).catch(() => n(t)) : n(t), l(!0), setTimeout(() => l(!1), 1500);
|
|
4590
|
+
}, [e.textContent]), ce = b(() => {
|
|
4591
|
+
let t = Xn[V] || "txt", n = t ? `code.${t}` : "code.txt", r = new Blob([e.textContent], { type: "text/plain;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
4573
4592
|
a.href = i, a.download = n, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
4574
|
-
}, [e.textContent,
|
|
4575
|
-
if (
|
|
4576
|
-
|
|
4593
|
+
}, [e.textContent, V]), J = b(async () => {
|
|
4594
|
+
if (N || L) {
|
|
4595
|
+
P(null), I(null), ee(!1);
|
|
4577
4596
|
return;
|
|
4578
4597
|
}
|
|
4579
|
-
|
|
4598
|
+
ee(!0), I(null), P(null);
|
|
4580
4599
|
try {
|
|
4581
4600
|
let t = (e.textContent || "").trim();
|
|
4582
4601
|
if (!t) {
|
|
4583
|
-
|
|
4602
|
+
I("代码块内容为空");
|
|
4584
4603
|
return;
|
|
4585
4604
|
}
|
|
4586
|
-
let n = p(await
|
|
4587
|
-
|
|
4605
|
+
let n = p(await Jn(t));
|
|
4606
|
+
P(n);
|
|
4588
4607
|
} catch (e) {
|
|
4589
|
-
|
|
4608
|
+
I(e instanceof Error ? e.message : "Mermaid 渲染失败");
|
|
4590
4609
|
} finally {
|
|
4591
|
-
|
|
4610
|
+
ee(!1);
|
|
4592
4611
|
}
|
|
4593
4612
|
}, [
|
|
4594
4613
|
e.textContent,
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
]),
|
|
4598
|
-
className: `${
|
|
4599
|
-
style: { color:
|
|
4614
|
+
N,
|
|
4615
|
+
L
|
|
4616
|
+
]), le = /* @__PURE__ */ O(E, { children: [H ? H.deviconClass ? /* @__PURE__ */ D("i", {
|
|
4617
|
+
className: `${H.deviconClass} colored cb-lang-icon`,
|
|
4618
|
+
style: { color: H.color }
|
|
4600
4619
|
}) : /* @__PURE__ */ D("span", {
|
|
4601
4620
|
className: "cb-lang-icon cb-lang-icon--auto",
|
|
4602
4621
|
children: "Tx"
|
|
@@ -4605,44 +4624,55 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4605
4624
|
children: "?"
|
|
4606
4625
|
}), /* @__PURE__ */ D("span", {
|
|
4607
4626
|
className: "cb-lang-label",
|
|
4608
|
-
children:
|
|
4627
|
+
children: H?.label || "自动"
|
|
4609
4628
|
})] });
|
|
4610
|
-
return /* @__PURE__ */ O(
|
|
4611
|
-
|
|
4612
|
-
className: "
|
|
4613
|
-
|
|
4614
|
-
onTouchStart: ae,
|
|
4629
|
+
return /* @__PURE__ */ O("div", {
|
|
4630
|
+
ref: z,
|
|
4631
|
+
className: "cb-react-shell group/cb",
|
|
4632
|
+
style: { display: "contents" },
|
|
4615
4633
|
children: [
|
|
4616
4634
|
/* @__PURE__ */ O("div", {
|
|
4617
4635
|
className: "cb-header",
|
|
4618
4636
|
contentEditable: !1,
|
|
4619
|
-
children: [
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4637
|
+
children: [
|
|
4638
|
+
/* @__PURE__ */ D("div", {
|
|
4639
|
+
className: "cb-lang-wrap",
|
|
4640
|
+
ref: te,
|
|
4641
|
+
contentEditable: !1,
|
|
4642
|
+
children: s ? /* @__PURE__ */ D("span", {
|
|
4643
|
+
className: "cb-lang-trigger cb-lang-trigger--static",
|
|
4644
|
+
children: le
|
|
4645
|
+
}) : /* @__PURE__ */ O("button", {
|
|
4646
|
+
ref: re,
|
|
4647
|
+
type: "button",
|
|
4648
|
+
className: "cb-lang-trigger",
|
|
4649
|
+
onClick: () => m(!f),
|
|
4650
|
+
children: [le, /* @__PURE__ */ D("svg", {
|
|
4651
|
+
className: `cb-lang-chevron${f ? " cb-lang-chevron--open" : ""}`,
|
|
4652
|
+
width: "10",
|
|
4653
|
+
height: "10",
|
|
4654
|
+
viewBox: "0 0 24 24",
|
|
4655
|
+
fill: "none",
|
|
4656
|
+
stroke: "currentColor",
|
|
4657
|
+
strokeWidth: "2.5",
|
|
4658
|
+
children: /* @__PURE__ */ D("path", {
|
|
4659
|
+
strokeLinecap: "round",
|
|
4660
|
+
strokeLinejoin: "round",
|
|
4661
|
+
d: "M6 9l6 6 6-6"
|
|
4662
|
+
})
|
|
4663
|
+
})]
|
|
4664
|
+
})
|
|
4665
|
+
}),
|
|
4666
|
+
o && f && ne(/* @__PURE__ */ O("div", {
|
|
4667
|
+
ref: R,
|
|
4668
|
+
className: `cb-lang-dropdown${h ? " cb-lang-dropdown--up" : ""}`,
|
|
4669
|
+
style: {
|
|
4670
|
+
position: "fixed",
|
|
4671
|
+
top: y.top,
|
|
4672
|
+
left: y.left,
|
|
4673
|
+
width: y.width,
|
|
4674
|
+
zIndex: 10002
|
|
4675
|
+
},
|
|
4646
4676
|
children: [/* @__PURE__ */ O("div", {
|
|
4647
4677
|
className: "cb-lang-search-wrap",
|
|
4648
4678
|
children: [/* @__PURE__ */ D("svg", {
|
|
@@ -4659,30 +4689,31 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4659
4689
|
d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
|
4660
4690
|
})
|
|
4661
4691
|
}), /* @__PURE__ */ D("input", {
|
|
4662
|
-
ref:
|
|
4692
|
+
ref: ie,
|
|
4663
4693
|
className: "cb-lang-search",
|
|
4664
4694
|
type: "text",
|
|
4665
4695
|
placeholder: "搜索语言...",
|
|
4666
|
-
value:
|
|
4667
|
-
onChange: (e) =>
|
|
4696
|
+
value: k,
|
|
4697
|
+
onChange: (e) => A(e.target.value),
|
|
4668
4698
|
onKeyDown: (e) => e.stopPropagation()
|
|
4669
4699
|
})]
|
|
4670
4700
|
}), /* @__PURE__ */ O("div", {
|
|
4671
4701
|
className: "cb-lang-list",
|
|
4702
|
+
style: { maxHeight: _ },
|
|
4672
4703
|
children: [
|
|
4673
4704
|
/* @__PURE__ */ O("button", {
|
|
4674
4705
|
type: "button",
|
|
4675
|
-
className: `cb-lang-option${
|
|
4676
|
-
onClick: () =>
|
|
4706
|
+
className: `cb-lang-option${V ? "" : " cb-lang-option--active"}`,
|
|
4707
|
+
onClick: () => K(""),
|
|
4677
4708
|
children: [/* @__PURE__ */ D("span", {
|
|
4678
4709
|
className: "cb-lang-icon cb-lang-icon--auto",
|
|
4679
4710
|
children: "?"
|
|
4680
4711
|
}), /* @__PURE__ */ D("span", { children: "自动检测" })]
|
|
4681
4712
|
}),
|
|
4682
|
-
|
|
4713
|
+
W.map((e) => /* @__PURE__ */ O("button", {
|
|
4683
4714
|
type: "button",
|
|
4684
|
-
className: `cb-lang-option${
|
|
4685
|
-
onClick: () =>
|
|
4715
|
+
className: `cb-lang-option${V === e.value ? " cb-lang-option--active" : ""}`,
|
|
4716
|
+
onClick: () => K(e.value),
|
|
4686
4717
|
children: [e.deviconClass ? /* @__PURE__ */ D("i", {
|
|
4687
4718
|
className: `${e.deviconClass} colored cb-lang-icon`,
|
|
4688
4719
|
style: { color: e.color }
|
|
@@ -4691,211 +4722,179 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4691
4722
|
children: "Tx"
|
|
4692
4723
|
}), /* @__PURE__ */ D("span", { children: e.label })]
|
|
4693
4724
|
}, e.value)),
|
|
4694
|
-
|
|
4725
|
+
W.length === 0 && /* @__PURE__ */ D("div", {
|
|
4695
4726
|
className: "cb-lang-empty",
|
|
4696
4727
|
children: "无匹配语言"
|
|
4697
4728
|
})
|
|
4698
4729
|
]
|
|
4699
4730
|
})]
|
|
4700
|
-
})
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
})
|
|
4726
|
-
}),
|
|
4727
|
-
/* @__PURE__ */ D("button", {
|
|
4728
|
-
type: "button",
|
|
4729
|
-
className: "cb-btn",
|
|
4730
|
-
onClick: G,
|
|
4731
|
-
contentEditable: !1,
|
|
4732
|
-
title: "复制",
|
|
4733
|
-
children: c ? /* @__PURE__ */ D("svg", {
|
|
4734
|
-
className: "cb-btn-icon cb-btn-icon--check",
|
|
4735
|
-
fill: "none",
|
|
4736
|
-
viewBox: "0 0 24 24",
|
|
4737
|
-
stroke: "currentColor",
|
|
4738
|
-
strokeWidth: "2.5",
|
|
4739
|
-
children: /* @__PURE__ */ D("path", {
|
|
4740
|
-
strokeLinecap: "round",
|
|
4741
|
-
strokeLinejoin: "round",
|
|
4742
|
-
d: "M5 13l4 4L19 7"
|
|
4731
|
+
}), document.body),
|
|
4732
|
+
/* @__PURE__ */ O("div", {
|
|
4733
|
+
className: "cb-actions",
|
|
4734
|
+
children: [
|
|
4735
|
+
/* @__PURE__ */ D("button", {
|
|
4736
|
+
type: "button",
|
|
4737
|
+
className: "cb-btn",
|
|
4738
|
+
onClick: () => d(!u),
|
|
4739
|
+
contentEditable: !1,
|
|
4740
|
+
title: u ? "展开" : "折叠",
|
|
4741
|
+
children: /* @__PURE__ */ D("svg", {
|
|
4742
|
+
className: "cb-btn-icon",
|
|
4743
|
+
fill: "none",
|
|
4744
|
+
viewBox: "0 0 24 24",
|
|
4745
|
+
stroke: "currentColor",
|
|
4746
|
+
strokeWidth: "2",
|
|
4747
|
+
children: u ? /* @__PURE__ */ D("path", {
|
|
4748
|
+
strokeLinecap: "round",
|
|
4749
|
+
strokeLinejoin: "round",
|
|
4750
|
+
d: "M6 9l6 6 6-6"
|
|
4751
|
+
}) : /* @__PURE__ */ D("path", {
|
|
4752
|
+
strokeLinecap: "round",
|
|
4753
|
+
strokeLinejoin: "round",
|
|
4754
|
+
d: "M6 15l6-6 6 6"
|
|
4755
|
+
})
|
|
4743
4756
|
})
|
|
4744
|
-
})
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4757
|
+
}),
|
|
4758
|
+
/* @__PURE__ */ D("button", {
|
|
4759
|
+
type: "button",
|
|
4760
|
+
className: "cb-btn",
|
|
4761
|
+
onClick: se,
|
|
4762
|
+
contentEditable: !1,
|
|
4763
|
+
title: "复制",
|
|
4764
|
+
children: c ? /* @__PURE__ */ D("svg", {
|
|
4765
|
+
className: "cb-btn-icon cb-btn-icon--check",
|
|
4766
|
+
fill: "none",
|
|
4767
|
+
viewBox: "0 0 24 24",
|
|
4768
|
+
stroke: "currentColor",
|
|
4769
|
+
strokeWidth: "2.5",
|
|
4770
|
+
children: /* @__PURE__ */ D("path", {
|
|
4771
|
+
strokeLinecap: "round",
|
|
4772
|
+
strokeLinejoin: "round",
|
|
4773
|
+
d: "M5 13l4 4L19 7"
|
|
4774
|
+
})
|
|
4775
|
+
}) : /* @__PURE__ */ D("svg", {
|
|
4776
|
+
className: "cb-btn-icon",
|
|
4777
|
+
fill: "none",
|
|
4778
|
+
viewBox: "0 0 24 24",
|
|
4779
|
+
stroke: "currentColor",
|
|
4780
|
+
strokeWidth: "2",
|
|
4781
|
+
children: /* @__PURE__ */ D("path", {
|
|
4782
|
+
strokeLinecap: "round",
|
|
4783
|
+
strokeLinejoin: "round",
|
|
4784
|
+
d: "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"
|
|
4785
|
+
})
|
|
4754
4786
|
})
|
|
4755
|
-
})
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4787
|
+
}),
|
|
4788
|
+
/* @__PURE__ */ D("button", {
|
|
4789
|
+
type: "button",
|
|
4790
|
+
className: "cb-btn",
|
|
4791
|
+
onClick: ce,
|
|
4792
|
+
contentEditable: !1,
|
|
4793
|
+
title: "下载",
|
|
4794
|
+
children: /* @__PURE__ */ D("svg", {
|
|
4795
|
+
className: "cb-btn-icon",
|
|
4796
|
+
fill: "none",
|
|
4797
|
+
viewBox: "0 0 24 24",
|
|
4798
|
+
stroke: "currentColor",
|
|
4799
|
+
strokeWidth: "2",
|
|
4800
|
+
children: /* @__PURE__ */ D("path", {
|
|
4801
|
+
strokeLinecap: "round",
|
|
4802
|
+
strokeLinejoin: "round",
|
|
4803
|
+
d: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"
|
|
4804
|
+
})
|
|
4773
4805
|
})
|
|
4774
|
-
})
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4806
|
+
}),
|
|
4807
|
+
o && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("button", {
|
|
4808
|
+
type: "button",
|
|
4809
|
+
className: "cb-btn cb-btn--ai",
|
|
4810
|
+
onClick: q,
|
|
4811
|
+
contentEditable: !1,
|
|
4812
|
+
title: "写作助手",
|
|
4813
|
+
children: /* @__PURE__ */ D("svg", {
|
|
4814
|
+
className: "cb-btn-icon",
|
|
4815
|
+
fill: "none",
|
|
4816
|
+
viewBox: "0 0 24 24",
|
|
4817
|
+
stroke: "currentColor",
|
|
4818
|
+
strokeWidth: "2",
|
|
4819
|
+
children: /* @__PURE__ */ D("path", {
|
|
4820
|
+
strokeLinecap: "round",
|
|
4821
|
+
strokeLinejoin: "round",
|
|
4822
|
+
d: "M13 10V3L4 14h7v7l9-11h-7z"
|
|
4823
|
+
})
|
|
4792
4824
|
})
|
|
4793
|
-
})
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4825
|
+
}), /* @__PURE__ */ D("button", {
|
|
4826
|
+
type: "button",
|
|
4827
|
+
className: "cb-btn cb-btn--del",
|
|
4828
|
+
onClick: U,
|
|
4829
|
+
contentEditable: !1,
|
|
4830
|
+
title: "删除代码块",
|
|
4831
|
+
children: /* @__PURE__ */ D("svg", {
|
|
4832
|
+
className: "cb-btn-icon",
|
|
4833
|
+
fill: "none",
|
|
4834
|
+
viewBox: "0 0 24 24",
|
|
4835
|
+
stroke: "currentColor",
|
|
4836
|
+
strokeWidth: "2",
|
|
4837
|
+
children: /* @__PURE__ */ D("path", {
|
|
4838
|
+
strokeLinecap: "round",
|
|
4839
|
+
strokeLinejoin: "round",
|
|
4840
|
+
d: "M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
|
|
4841
|
+
})
|
|
4810
4842
|
})
|
|
4811
|
-
})
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4843
|
+
})] }),
|
|
4844
|
+
ae && /* @__PURE__ */ D("button", {
|
|
4845
|
+
type: "button",
|
|
4846
|
+
className: "cb-btn cb-btn--diagram",
|
|
4847
|
+
onClick: J,
|
|
4848
|
+
contentEditable: !1,
|
|
4849
|
+
title: N || L ? "取消渲染" : "渲染图表",
|
|
4850
|
+
disabled: L,
|
|
4851
|
+
children: /* @__PURE__ */ D("svg", {
|
|
4852
|
+
className: "cb-btn-icon",
|
|
4853
|
+
fill: "none",
|
|
4854
|
+
viewBox: "0 0 24 24",
|
|
4855
|
+
stroke: "currentColor",
|
|
4856
|
+
strokeWidth: "2",
|
|
4857
|
+
children: /* @__PURE__ */ D("path", {
|
|
4858
|
+
strokeLinecap: "round",
|
|
4859
|
+
strokeLinejoin: "round",
|
|
4860
|
+
d: "M4 5a1 1 0 011-1h4a1 1 0 011 1v5a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM14 5a1 1 0 011-1h4a1 1 0 011 1v2a1 1 0 01-1 1h-4a1 1 0 01-1-1V5zM4 16a1 1 0 011-1h4a1 1 0 011 1v3a1 1 0 01-1 1H5a1 1 0 01-1-1v-3zM14 13a1 1 0 011-1h4a1 1 0 011 1v6a1 1 0 01-1 1h-4a1 1 0 01-1-1v-6z"
|
|
4861
|
+
})
|
|
4830
4862
|
})
|
|
4831
4863
|
})
|
|
4832
|
-
|
|
4833
|
-
]
|
|
4834
|
-
})]
|
|
4835
|
-
}),
|
|
4836
|
-
/* @__PURE__ */ O("div", {
|
|
4837
|
-
className: `cb-code-area${u ? " cb-code-area--collapsed" : ""}`,
|
|
4838
|
-
children: [
|
|
4839
|
-
/* @__PURE__ */ D("div", {
|
|
4840
|
-
className: "cb-line-numbers",
|
|
4841
|
-
contentEditable: !1,
|
|
4842
|
-
"aria-hidden": "true",
|
|
4843
|
-
children: H.map((e, t) => /* @__PURE__ */ D("span", {
|
|
4844
|
-
className: "cb-line-num",
|
|
4845
|
-
style: P[t] ? { height: P[t] } : void 0,
|
|
4846
|
-
children: e
|
|
4847
|
-
}, e))
|
|
4848
|
-
}),
|
|
4849
|
-
/* @__PURE__ */ D("pre", {
|
|
4850
|
-
className: "cb-code-pre",
|
|
4851
|
-
ref: ne,
|
|
4852
|
-
children: /* @__PURE__ */ D(F, { as: "code" })
|
|
4853
|
-
}),
|
|
4854
|
-
/* @__PURE__ */ D("div", {
|
|
4855
|
-
ref: R,
|
|
4856
|
-
className: "cb-code-mirror",
|
|
4857
|
-
contentEditable: !1,
|
|
4858
|
-
"aria-hidden": "true",
|
|
4859
|
-
children: ce.map((e, t) => /* @__PURE__ */ D("span", {
|
|
4860
|
-
className: "cb-mirror-line",
|
|
4861
|
-
children: e.length ? e : "\xA0"
|
|
4862
|
-
}, t))
|
|
4864
|
+
]
|
|
4863
4865
|
})
|
|
4864
4866
|
]
|
|
4865
4867
|
}),
|
|
4866
|
-
(
|
|
4868
|
+
(N || F || L) && /* @__PURE__ */ O("div", {
|
|
4867
4869
|
className: "cb-diagram-output",
|
|
4868
4870
|
contentEditable: !1,
|
|
4869
4871
|
children: [
|
|
4870
|
-
|
|
4872
|
+
L && /* @__PURE__ */ D("div", {
|
|
4871
4873
|
className: "cb-diagram-loading",
|
|
4872
4874
|
children: "渲染图表中…"
|
|
4873
4875
|
}),
|
|
4874
|
-
|
|
4876
|
+
F && /* @__PURE__ */ O("div", {
|
|
4875
4877
|
className: "cb-diagram-error",
|
|
4876
4878
|
children: [/* @__PURE__ */ D("span", {
|
|
4877
4879
|
className: "cb-diagram-error-icon",
|
|
4878
4880
|
children: "!"
|
|
4879
|
-
}),
|
|
4881
|
+
}), F]
|
|
4880
4882
|
}),
|
|
4881
|
-
|
|
4883
|
+
N && /* @__PURE__ */ D("div", {
|
|
4882
4884
|
className: "cb-diagram-svg",
|
|
4883
|
-
dangerouslySetInnerHTML: { __html:
|
|
4885
|
+
dangerouslySetInnerHTML: { __html: N }
|
|
4884
4886
|
})
|
|
4885
4887
|
]
|
|
4886
4888
|
}),
|
|
4887
|
-
/* @__PURE__ */ D(
|
|
4888
|
-
open:
|
|
4889
|
+
/* @__PURE__ */ D(yn, {
|
|
4890
|
+
open: j,
|
|
4889
4891
|
title: "确认删除代码块",
|
|
4890
4892
|
message: "此操作不可撤销。",
|
|
4891
4893
|
onCancel: () => {
|
|
4892
|
-
$(!1),
|
|
4894
|
+
$(!1), M(!1);
|
|
4893
4895
|
},
|
|
4894
4896
|
onConfirm: async () => {
|
|
4895
|
-
|
|
4896
|
-
let e = re.current ?? oe();
|
|
4897
|
-
e ? n.chain().focus().setTextSelection(e).deleteSelection().run() : i();
|
|
4898
|
-
} else i();
|
|
4897
|
+
await new Promise((e) => setTimeout(e, 300)), $(!1), i();
|
|
4899
4898
|
}
|
|
4900
4899
|
})
|
|
4901
4900
|
]
|
|
@@ -5004,11 +5003,165 @@ var $n = [
|
|
|
5004
5003
|
value: "mermaid",
|
|
5005
5004
|
label: "Mermaid"
|
|
5006
5005
|
}
|
|
5007
|
-
], er =
|
|
5008
|
-
er.register({ dockerfile:
|
|
5009
|
-
|
|
5006
|
+
], er = be(ye);
|
|
5007
|
+
er.register({ dockerfile: ve }), er.registerAlias("xml", ["vue", "html"]), er.registerAlias("javascript", ["react", "jsx"]), er.registerAlias("typescript", ["tsx"]);
|
|
5008
|
+
function tr(e) {
|
|
5009
|
+
return e ? e.split("\n") : [""];
|
|
5010
|
+
}
|
|
5011
|
+
function nr(e, t) {
|
|
5012
|
+
if (e.childElementCount !== t) {
|
|
5013
|
+
e.replaceChildren();
|
|
5014
|
+
for (let n = 1; n <= t; n++) {
|
|
5015
|
+
let t = document.createElement("span");
|
|
5016
|
+
t.className = "cb-line-num", t.textContent = String(n), e.appendChild(t);
|
|
5017
|
+
}
|
|
5018
|
+
}
|
|
5019
|
+
}
|
|
5020
|
+
function rr(e, t) {
|
|
5021
|
+
e.replaceChildren();
|
|
5022
|
+
for (let n of t) {
|
|
5023
|
+
let t = document.createElement("span");
|
|
5024
|
+
t.className = "cb-mirror-line", t.textContent = n.length ? n : "\xA0", e.appendChild(t);
|
|
5025
|
+
}
|
|
5026
|
+
}
|
|
5027
|
+
function ir(e, t, n) {
|
|
5028
|
+
let r = getComputedStyle(e), i = parseFloat(r.paddingLeft), a = parseFloat(r.paddingRight);
|
|
5029
|
+
t.style.boxSizing = "content-box", t.style.width = `${Math.max(0, e.clientWidth - i - a)}px`, t.style.padding = r.padding;
|
|
5030
|
+
let o = getComputedStyle(n);
|
|
5031
|
+
(o.paddingTop !== r.paddingTop || o.paddingBottom !== r.paddingBottom) && (n.style.paddingTop = r.paddingTop, n.style.paddingBottom = r.paddingBottom);
|
|
5032
|
+
let s = e.querySelector("code"), c = parseFloat(r.lineHeight) || 24;
|
|
5033
|
+
if (!s) {
|
|
5034
|
+
for (let e = 0; e < n.children.length; e++) n.children[e].style.height = `${c}px`;
|
|
5035
|
+
return;
|
|
5036
|
+
}
|
|
5037
|
+
let l = s.textContent ?? "", u = [], d = 0;
|
|
5038
|
+
for (let e = 0; e <= l.length; e++) (e === l.length || l[e] === "\n") && (u.push([d, e]), d = e + 1);
|
|
5039
|
+
let f = [], p = [], m = 0, h = document.createTreeWalker(s, NodeFilter.SHOW_TEXT), g;
|
|
5040
|
+
for (; g = h.nextNode();) f.push(g), p.push(m), m += g.textContent?.length ?? 0;
|
|
5041
|
+
let _ = (e) => {
|
|
5042
|
+
for (let t = 0; t < f.length; t++) {
|
|
5043
|
+
let n = p[t];
|
|
5044
|
+
if (e <= n + (f[t].textContent?.length ?? 0)) return {
|
|
5045
|
+
node: f[t],
|
|
5046
|
+
offset: e - n
|
|
5047
|
+
};
|
|
5048
|
+
}
|
|
5049
|
+
let t = f[f.length - 1];
|
|
5050
|
+
return t ? {
|
|
5051
|
+
node: t,
|
|
5052
|
+
offset: t.textContent?.length ?? 0
|
|
5053
|
+
} : null;
|
|
5054
|
+
}, v = e.getBoundingClientRect(), y = parseFloat(r.paddingTop), b = v.top + y, x = v.bottom - parseFloat(r.paddingBottom), S = document.createRange(), C = [];
|
|
5055
|
+
for (let e = 0; e < u.length; e++) {
|
|
5056
|
+
let [t, n] = u[e], r = NaN, i = _(t), a = _(n);
|
|
5057
|
+
if (i && a) {
|
|
5058
|
+
S.setStart(i.node, i.offset), S.setEnd(a.node, a.offset);
|
|
5059
|
+
let e = S.getClientRects(), t = Infinity;
|
|
5060
|
+
for (let n = 0; n < e.length; n++) e[n].height > 0 && e[n].top < t && (t = e[n].top);
|
|
5061
|
+
Number.isFinite(t) && (r = t - b);
|
|
5062
|
+
}
|
|
5063
|
+
C.push(r);
|
|
5064
|
+
}
|
|
5065
|
+
for (let e = 0; e < C.length; e++) Number.isFinite(C[e]) || (C[e] = e > 0 ? C[e - 1] + c : 0);
|
|
5066
|
+
let w = x - b, T = 0;
|
|
5067
|
+
for (let e = 0; e < u.length; e++) {
|
|
5068
|
+
let t = n.children[e];
|
|
5069
|
+
if (!t) continue;
|
|
5070
|
+
let r;
|
|
5071
|
+
r = e + 1 < C.length ? C[e + 1] - C[e] : w - T, (!Number.isFinite(r) || r < 1) && (r = c), t.style.height = `${r}px`, T += r;
|
|
5072
|
+
}
|
|
5073
|
+
}
|
|
5074
|
+
var ar = _e.extend({
|
|
5010
5075
|
addNodeView() {
|
|
5011
|
-
return
|
|
5076
|
+
return (e) => {
|
|
5077
|
+
let { node: t, editor: n, getPos: r } = e, i = t, a = (e) => {
|
|
5078
|
+
let t = typeof r == "function" ? r() : void 0;
|
|
5079
|
+
typeof t == "number" && n.chain().command(({ tr: n }) => (n.setNodeMarkup(t, void 0, {
|
|
5080
|
+
...i.attrs,
|
|
5081
|
+
...e
|
|
5082
|
+
}), !0)).run();
|
|
5083
|
+
}, o = () => {
|
|
5084
|
+
let e = typeof r == "function" ? r() : void 0;
|
|
5085
|
+
typeof e == "number" && n.chain().command(({ tr: t }) => (t.delete(e, e + i.nodeSize), !0)).run();
|
|
5086
|
+
}, s = document.createElement("div");
|
|
5087
|
+
s.className = "code-block-node-view group/cb";
|
|
5088
|
+
let c = document.createElement("div");
|
|
5089
|
+
c.contentEditable = "false", s.appendChild(c);
|
|
5090
|
+
let l = document.createElement("div");
|
|
5091
|
+
l.className = "cb-code-area";
|
|
5092
|
+
let u = document.createElement("div");
|
|
5093
|
+
u.className = "cb-line-numbers", u.contentEditable = "false", u.setAttribute("aria-hidden", "true");
|
|
5094
|
+
let d = document.createElement("pre");
|
|
5095
|
+
d.className = "cb-code-pre";
|
|
5096
|
+
let f = document.createElement("code");
|
|
5097
|
+
d.appendChild(f);
|
|
5098
|
+
let p = document.createElement("div");
|
|
5099
|
+
p.className = "cb-code-mirror", p.contentEditable = "false", p.setAttribute("aria-hidden", "true"), l.appendChild(u), l.appendChild(d), l.appendChild(p), s.appendChild(l);
|
|
5100
|
+
let m = tr(t.textContent);
|
|
5101
|
+
nr(u, m.length), rr(p, m);
|
|
5102
|
+
let h = new L(Qn, {
|
|
5103
|
+
editor: n,
|
|
5104
|
+
props: {
|
|
5105
|
+
node: t,
|
|
5106
|
+
editor: n,
|
|
5107
|
+
getPos: r,
|
|
5108
|
+
updateAttributes: a,
|
|
5109
|
+
deleteNode: o,
|
|
5110
|
+
selected: !1
|
|
5111
|
+
}
|
|
5112
|
+
});
|
|
5113
|
+
c.appendChild(h.element);
|
|
5114
|
+
let g = (e) => {
|
|
5115
|
+
let t = tr(e.textContent);
|
|
5116
|
+
nr(u, t.length), rr(p, t), requestAnimationFrame(() => ir(d, p, u));
|
|
5117
|
+
};
|
|
5118
|
+
requestAnimationFrame(() => ir(d, p, u));
|
|
5119
|
+
let _ = new ResizeObserver(() => ir(d, p, u));
|
|
5120
|
+
return _.observe(d), document.fonts?.ready?.then(() => ir(d, p, u)), {
|
|
5121
|
+
dom: s,
|
|
5122
|
+
contentDOM: f,
|
|
5123
|
+
update(e) {
|
|
5124
|
+
return e.type !== t.type || !e.sameMarkup(i) ? !1 : (i = e, h.updateProps({
|
|
5125
|
+
node: e,
|
|
5126
|
+
editor: n,
|
|
5127
|
+
getPos: r,
|
|
5128
|
+
updateAttributes: a,
|
|
5129
|
+
deleteNode: o,
|
|
5130
|
+
selected: s.classList.contains("ProseMirror-selectednode")
|
|
5131
|
+
}), g(e), !0);
|
|
5132
|
+
},
|
|
5133
|
+
selectNode() {
|
|
5134
|
+
s.classList.add("ProseMirror-selectednode"), h.updateProps({
|
|
5135
|
+
node: i,
|
|
5136
|
+
editor: n,
|
|
5137
|
+
getPos: r,
|
|
5138
|
+
updateAttributes: a,
|
|
5139
|
+
deleteNode: o,
|
|
5140
|
+
selected: !0
|
|
5141
|
+
});
|
|
5142
|
+
},
|
|
5143
|
+
deselectNode() {
|
|
5144
|
+
s.classList.remove("ProseMirror-selectednode"), h.updateProps({
|
|
5145
|
+
node: i,
|
|
5146
|
+
editor: n,
|
|
5147
|
+
getPos: r,
|
|
5148
|
+
updateAttributes: a,
|
|
5149
|
+
deleteNode: o,
|
|
5150
|
+
selected: !1
|
|
5151
|
+
});
|
|
5152
|
+
},
|
|
5153
|
+
stopEvent(e) {
|
|
5154
|
+
let t = e.target;
|
|
5155
|
+
return !!(t && c.contains(t));
|
|
5156
|
+
},
|
|
5157
|
+
ignoreMutation(e) {
|
|
5158
|
+
return !f.contains(e.target);
|
|
5159
|
+
},
|
|
5160
|
+
destroy() {
|
|
5161
|
+
_.disconnect(), h.destroy();
|
|
5162
|
+
}
|
|
5163
|
+
};
|
|
5164
|
+
};
|
|
5012
5165
|
},
|
|
5013
5166
|
parseHTML() {
|
|
5014
5167
|
return (this.parent?.() ?? []).map((e) => ({
|
|
@@ -5027,7 +5180,7 @@ var tr = ye.extend({
|
|
|
5027
5180
|
}).configure({ lowlight: er });
|
|
5028
5181
|
//#endregion
|
|
5029
5182
|
//#region src/editor/utils/import-choice-dialog.ts
|
|
5030
|
-
function
|
|
5183
|
+
function or(e) {
|
|
5031
5184
|
return new Promise((t) => {
|
|
5032
5185
|
let n = document.createElement("div");
|
|
5033
5186
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5057,16 +5210,16 @@ function nr(e) {
|
|
|
5057
5210
|
}
|
|
5058
5211
|
//#endregion
|
|
5059
5212
|
//#region src/editor/utils/local-media.ts
|
|
5060
|
-
var
|
|
5061
|
-
function
|
|
5213
|
+
var sr = /\.(png|jpe?g|gif|webp|bmp|svg|avif|mp4|m4v|webm|ogg|mov|avi|mkv|mp3|wav|flac|m4a|aac|opus|pdf|docx?|xlsx?|pptx?|odt|rtf|txt|md|csv|zip|rar|7z|json)(\?|#|$)/i, cr = /^(?:mailto:|tel:|javascript:|about:|data:|blob:)/i;
|
|
5214
|
+
function lr(e) {
|
|
5062
5215
|
if (!e) return !1;
|
|
5063
5216
|
let t = e.trim();
|
|
5064
|
-
return !(!t || /^(?:https?:)?\/\//i.test(t) ||
|
|
5217
|
+
return !(!t || /^(?:https?:)?\/\//i.test(t) || cr.test(t) || t.startsWith("#"));
|
|
5065
5218
|
}
|
|
5066
|
-
function
|
|
5067
|
-
return
|
|
5219
|
+
function ur(e) {
|
|
5220
|
+
return sr.test(e);
|
|
5068
5221
|
}
|
|
5069
|
-
function
|
|
5222
|
+
function dr(e) {
|
|
5070
5223
|
let t = e.trim();
|
|
5071
5224
|
t = t.replace(/^(?:file|app):\/\/(?:localhost)?/i, "");
|
|
5072
5225
|
try {
|
|
@@ -5074,26 +5227,26 @@ function sr(e) {
|
|
|
5074
5227
|
} catch {}
|
|
5075
5228
|
return t = t.replace(/\\/g, "/"), t = t.replace(/^\.\//, ""), t = t.replace(/^\/+/, ""), t = t.replace(/^[a-zA-Z]:\//, ""), t;
|
|
5076
5229
|
}
|
|
5077
|
-
function
|
|
5078
|
-
let t =
|
|
5230
|
+
function fr(e) {
|
|
5231
|
+
let t = dr(e), n = t.split("/").filter(Boolean);
|
|
5079
5232
|
return (n[n.length - 1] || t).toLowerCase();
|
|
5080
5233
|
}
|
|
5081
|
-
function
|
|
5234
|
+
function pr() {
|
|
5082
5235
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showDirectoryPicker == "function";
|
|
5083
5236
|
}
|
|
5084
|
-
async function
|
|
5085
|
-
if (!
|
|
5237
|
+
async function mr() {
|
|
5238
|
+
if (!pr()) return null;
|
|
5086
5239
|
try {
|
|
5087
5240
|
return await window.showDirectoryPicker.call(window, { mode: "read" }) ?? null;
|
|
5088
5241
|
} catch {
|
|
5089
5242
|
return null;
|
|
5090
5243
|
}
|
|
5091
5244
|
}
|
|
5092
|
-
function
|
|
5245
|
+
function hr() {
|
|
5093
5246
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showOpenFilePicker == "function";
|
|
5094
5247
|
}
|
|
5095
|
-
async function
|
|
5096
|
-
if (!
|
|
5248
|
+
async function gr() {
|
|
5249
|
+
if (!hr()) return null;
|
|
5097
5250
|
try {
|
|
5098
5251
|
let e = await window.showOpenFilePicker.call(window, { multiple: !0 });
|
|
5099
5252
|
return await Promise.all(e.map((e) => e.getFile()));
|
|
@@ -5101,7 +5254,7 @@ async function fr() {
|
|
|
5101
5254
|
return null;
|
|
5102
5255
|
}
|
|
5103
5256
|
}
|
|
5104
|
-
async function
|
|
5257
|
+
async function _r(e, t) {
|
|
5105
5258
|
if (t.length === 0) return { file: null };
|
|
5106
5259
|
let n = e;
|
|
5107
5260
|
for (let e = 0; e < t.length - 1; e++) try {
|
|
@@ -5123,7 +5276,7 @@ async function pr(e, t) {
|
|
|
5123
5276
|
return { file: null };
|
|
5124
5277
|
}
|
|
5125
5278
|
}
|
|
5126
|
-
async function
|
|
5279
|
+
async function vr(e, t, n = 5e3) {
|
|
5127
5280
|
let r = t.toLowerCase(), i = [e], a = 0, o;
|
|
5128
5281
|
for (; i.length > 0 && a < n;) {
|
|
5129
5282
|
let e = i.pop();
|
|
@@ -5145,37 +5298,37 @@ async function mr(e, t, n = 5e3) {
|
|
|
5145
5298
|
readError: o
|
|
5146
5299
|
};
|
|
5147
5300
|
}
|
|
5148
|
-
async function
|
|
5149
|
-
let n =
|
|
5301
|
+
async function yr(e, t) {
|
|
5302
|
+
let n = dr(t).split("/").filter(Boolean);
|
|
5150
5303
|
if (n.length === 0) return { file: null };
|
|
5151
5304
|
let r;
|
|
5152
5305
|
for (let t = 0; t < n.length; t++) {
|
|
5153
|
-
let i = await
|
|
5306
|
+
let i = await _r(e, n.slice(t));
|
|
5154
5307
|
if (i.file) return i;
|
|
5155
5308
|
i.readError && (r = i.readError);
|
|
5156
5309
|
}
|
|
5157
|
-
let i = await
|
|
5310
|
+
let i = await vr(e, n[n.length - 1]);
|
|
5158
5311
|
return i.file || i.readError ? i : {
|
|
5159
5312
|
file: null,
|
|
5160
5313
|
readError: r
|
|
5161
5314
|
};
|
|
5162
5315
|
}
|
|
5163
|
-
var
|
|
5316
|
+
var br = {
|
|
5164
5317
|
image: "image",
|
|
5165
5318
|
videoEmbed: "video",
|
|
5166
5319
|
audioEmbed: "audio",
|
|
5167
5320
|
attachmentEmbed: "attachment"
|
|
5168
5321
|
};
|
|
5169
|
-
function
|
|
5322
|
+
function xr(e, t) {
|
|
5170
5323
|
let n = /* @__PURE__ */ new Set(), r = [];
|
|
5171
5324
|
return e.descendants((e) => {
|
|
5172
|
-
let i =
|
|
5325
|
+
let i = br[e.type?.name];
|
|
5173
5326
|
if (i) {
|
|
5174
5327
|
let a = e.attrs?.src, o = `node:${a}`;
|
|
5175
|
-
typeof a == "string" &&
|
|
5328
|
+
typeof a == "string" && lr(a) && !n.has(o) && !t?.(a) && (n.add(o), r.push({
|
|
5176
5329
|
src: a,
|
|
5177
|
-
normalized:
|
|
5178
|
-
basename:
|
|
5330
|
+
normalized: dr(a),
|
|
5331
|
+
basename: fr(a),
|
|
5179
5332
|
kind: i,
|
|
5180
5333
|
isLink: !1
|
|
5181
5334
|
}));
|
|
@@ -5184,17 +5337,17 @@ function _r(e, t) {
|
|
|
5184
5337
|
if (e.isText && e.marks) for (let i of e.marks) {
|
|
5185
5338
|
if (i.type.name !== "link") continue;
|
|
5186
5339
|
let e = i.attrs?.href, a = `link:${e}`;
|
|
5187
|
-
typeof e == "string" &&
|
|
5340
|
+
typeof e == "string" && lr(e) && ur(e) && !n.has(a) && !t?.(e) && (n.add(a), r.push({
|
|
5188
5341
|
src: e,
|
|
5189
|
-
normalized:
|
|
5190
|
-
basename:
|
|
5342
|
+
normalized: dr(e),
|
|
5343
|
+
basename: fr(e),
|
|
5191
5344
|
kind: "attachment",
|
|
5192
5345
|
isLink: !0
|
|
5193
5346
|
}));
|
|
5194
5347
|
}
|
|
5195
5348
|
}), r;
|
|
5196
5349
|
}
|
|
5197
|
-
function
|
|
5350
|
+
function Sr(e, t, n) {
|
|
5198
5351
|
let r = t ? `${e}\n${t}` : e;
|
|
5199
5352
|
if (!r) return !1;
|
|
5200
5353
|
let i = [];
|
|
@@ -5202,28 +5355,28 @@ function vr(e, t, n) {
|
|
|
5202
5355
|
for (let e of r.matchAll(/!?\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g)) i.push(e[1]);
|
|
5203
5356
|
for (let e of r.matchAll(/<(?:img|video|audio|source)[^>]*\bsrc=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5204
5357
|
for (let e of r.matchAll(/<a[^>]*\bhref=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5205
|
-
return i.some((e) =>
|
|
5358
|
+
return i.some((e) => ur(e) && lr(e) && !n?.(e));
|
|
5206
5359
|
}
|
|
5207
5360
|
//#endregion
|
|
5208
5361
|
//#region src/editor/extensions/image-upload.ts
|
|
5209
|
-
function
|
|
5362
|
+
function Cr(e) {
|
|
5210
5363
|
if (e.type.startsWith("image/")) return "image";
|
|
5211
5364
|
if (e.type.startsWith("video/")) return "video";
|
|
5212
5365
|
if (e.type.startsWith("audio/")) return "audio";
|
|
5213
5366
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5214
5367
|
return /^(png|jpe?g|gif|webp|bmp|svg|avif)$/.test(t) ? "image" : /^(mp4|m3u8|webm|ogg|mov|avi|wmv|flv|mkv|ts|m4v|3gp|f4v|rmvb)$/.test(t) ? "video" : /^(mp3|wav|flac|aac|m4a|wma|opus)$/.test(t) ? "audio" : /^(md|markdown)$/.test(t) ? "markdown" : "file";
|
|
5215
5368
|
}
|
|
5216
|
-
function
|
|
5369
|
+
function wr(e) {
|
|
5217
5370
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5218
5371
|
return t === "md" || t === "markdown";
|
|
5219
5372
|
}
|
|
5220
|
-
async function
|
|
5221
|
-
let i = n ?? e.state.selection.from, a = r ?
|
|
5222
|
-
o?.chooseMd ? o.chooseMd(t.name, e) :
|
|
5373
|
+
async function Tr(e, t, n, r) {
|
|
5374
|
+
let i = n ?? e.state.selection.from, a = r ? ln(r) : void 0, o = r?.storage?.qingwuUI, s = await new Promise((e) => {
|
|
5375
|
+
o?.chooseMd ? o.chooseMd(t.name, e) : or(t.name).then(e);
|
|
5223
5376
|
});
|
|
5224
5377
|
if (s === null) return;
|
|
5225
5378
|
if (s === "attach") {
|
|
5226
|
-
let n = a ?
|
|
5379
|
+
let n = a ? un(e.state.doc, t, a) : null;
|
|
5227
5380
|
if (n) {
|
|
5228
5381
|
Z(n);
|
|
5229
5382
|
return;
|
|
@@ -5254,8 +5407,8 @@ async function xr(e, t, n, r) {
|
|
|
5254
5407
|
e.dispatch(e.state.tr.insert(i, t.from(u)));
|
|
5255
5408
|
}
|
|
5256
5409
|
}
|
|
5257
|
-
function
|
|
5258
|
-
switch (
|
|
5410
|
+
function Er(e, t, n) {
|
|
5411
|
+
switch (Cr(t)) {
|
|
5259
5412
|
case "image": return e.nodes.image?.create({
|
|
5260
5413
|
src: n,
|
|
5261
5414
|
alt: t.name
|
|
@@ -5281,7 +5434,7 @@ function Sr(e, t, n) {
|
|
|
5281
5434
|
}
|
|
5282
5435
|
}
|
|
5283
5436
|
}
|
|
5284
|
-
async function
|
|
5437
|
+
async function Dr(e, t, n) {
|
|
5285
5438
|
let r;
|
|
5286
5439
|
try {
|
|
5287
5440
|
r = o();
|
|
@@ -5300,13 +5453,13 @@ async function Cr(e, t, n) {
|
|
|
5300
5453
|
return console.error(`${t.type} upload failed:`, e), URL.revokeObjectURL(n), null;
|
|
5301
5454
|
}
|
|
5302
5455
|
}
|
|
5303
|
-
async function
|
|
5304
|
-
let i = r ?
|
|
5456
|
+
async function Or(e, t, n, r) {
|
|
5457
|
+
let i = r ? ln(r) : void 0, a = i ? un(e.state.doc, t, i) : null;
|
|
5305
5458
|
if (a) {
|
|
5306
5459
|
Z(a);
|
|
5307
5460
|
return;
|
|
5308
5461
|
}
|
|
5309
|
-
let o = URL.createObjectURL(t), s =
|
|
5462
|
+
let o = URL.createObjectURL(t), s = Er(e.state.schema, t, o);
|
|
5310
5463
|
if (!s) return;
|
|
5311
5464
|
let c = n ?? e.state.selection.from;
|
|
5312
5465
|
try {
|
|
@@ -5314,9 +5467,9 @@ async function wr(e, t, n, r) {
|
|
|
5314
5467
|
} catch {
|
|
5315
5468
|
return;
|
|
5316
5469
|
}
|
|
5317
|
-
await
|
|
5470
|
+
await Dr(e, t, o);
|
|
5318
5471
|
}
|
|
5319
|
-
var
|
|
5472
|
+
var kr = R.create({
|
|
5320
5473
|
name: "imageUpload",
|
|
5321
5474
|
addOptions() {
|
|
5322
5475
|
return {
|
|
@@ -5337,23 +5490,23 @@ var Tr = R.create({
|
|
|
5337
5490
|
left: n.clientX,
|
|
5338
5491
|
top: n.clientY
|
|
5339
5492
|
});
|
|
5340
|
-
for (let n of Array.from(r))
|
|
5493
|
+
for (let n of Array.from(r)) wr(n) ? Tr(t, n, i?.pos, e) : Or(t, n, i?.pos, e);
|
|
5341
5494
|
return !0;
|
|
5342
5495
|
},
|
|
5343
5496
|
handlePaste(t, n) {
|
|
5344
5497
|
let r = n.clipboardData?.items;
|
|
5345
5498
|
if (!r) return !1;
|
|
5346
5499
|
let i = n.clipboardData?.getData("text/plain") || "";
|
|
5347
|
-
if ((n.clipboardData?.files?.length ?? 0) > 0 &&
|
|
5500
|
+
if ((n.clipboardData?.files?.length ?? 0) > 0 && Sr(i, void 0, a())) return !1;
|
|
5348
5501
|
for (let i of Array.from(r)) {
|
|
5349
5502
|
if (i.type.startsWith("image/") || i.type.startsWith("video/") || i.type.startsWith("audio/")) {
|
|
5350
5503
|
n.preventDefault();
|
|
5351
5504
|
let r = i.getAsFile();
|
|
5352
|
-
return r &&
|
|
5505
|
+
return r && Cr(r) !== "file" && Or(t, r, void 0, e), !0;
|
|
5353
5506
|
}
|
|
5354
5507
|
if (i.kind === "file") {
|
|
5355
5508
|
let r = i.getAsFile();
|
|
5356
|
-
if (r &&
|
|
5509
|
+
if (r && wr(r)) return n.preventDefault(), Tr(t, r, void 0, e), !0;
|
|
5357
5510
|
}
|
|
5358
5511
|
}
|
|
5359
5512
|
return !1;
|
|
@@ -5361,25 +5514,25 @@ var Tr = R.create({
|
|
|
5361
5514
|
}
|
|
5362
5515
|
})];
|
|
5363
5516
|
}
|
|
5364
|
-
}),
|
|
5365
|
-
function
|
|
5517
|
+
}), Ar = /\.(png|jpe?g|gif|webp|bmp|svg|avif)(\?|#|$)/i, jr = /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|#|$)/i, Mr = /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|#|$)/i;
|
|
5518
|
+
function Nr(e) {
|
|
5366
5519
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
5367
5520
|
}
|
|
5368
|
-
function
|
|
5521
|
+
function Pr(e) {
|
|
5369
5522
|
let t = e.trim().replace(/\\/g, "/");
|
|
5370
5523
|
return t.split("/").pop() || t;
|
|
5371
5524
|
}
|
|
5372
|
-
function
|
|
5525
|
+
function Fr(e, t) {
|
|
5373
5526
|
let n = e.src.slice(e.pos), r = /^!\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !0;
|
|
5374
5527
|
if (r || (r = /^\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !1), !r) return !1;
|
|
5375
5528
|
let a = r[1].trim(), o = r[2]?.trim();
|
|
5376
5529
|
if (!t) {
|
|
5377
|
-
let t = o ||
|
|
5530
|
+
let t = o || Pr(a);
|
|
5378
5531
|
if (i) {
|
|
5379
5532
|
let n = "";
|
|
5380
|
-
if (
|
|
5381
|
-
else if (
|
|
5382
|
-
else if (
|
|
5533
|
+
if (Ar.test(a) || /^data:image\//i.test(a)) n = `<img src="${Nr(a)}" alt="${Nr(t)}">`;
|
|
5534
|
+
else if (jr.test(a) || /^data:video\//i.test(a)) n = `<div data-video-embed src="${Nr(a)}"></div>`;
|
|
5535
|
+
else if (Mr.test(a) || /^data:audio\//i.test(a)) n = `<audio src="${Nr(a)}"></audio>`;
|
|
5383
5536
|
else {
|
|
5384
5537
|
let n = e.push("link_open", "a", 1);
|
|
5385
5538
|
n.attrs = [["href", a]];
|
|
@@ -5397,14 +5550,14 @@ function jr(e, t) {
|
|
|
5397
5550
|
}
|
|
5398
5551
|
return e.pos += r[0].length, !0;
|
|
5399
5552
|
}
|
|
5400
|
-
var
|
|
5553
|
+
var Ir = R.create({
|
|
5401
5554
|
name: "obsidianMarkdown",
|
|
5402
5555
|
addStorage() {
|
|
5403
5556
|
return { markdown: { parse: { setup(e) {
|
|
5404
|
-
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed",
|
|
5557
|
+
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed", Fr));
|
|
5405
5558
|
} } } };
|
|
5406
5559
|
}
|
|
5407
|
-
}),
|
|
5560
|
+
}), Lr = R.create({
|
|
5408
5561
|
name: "qingwuUI",
|
|
5409
5562
|
addStorage() {
|
|
5410
5563
|
return {};
|
|
@@ -5412,7 +5565,7 @@ var Mr = R.create({
|
|
|
5412
5565
|
});
|
|
5413
5566
|
//#endregion
|
|
5414
5567
|
//#region src/editor/utils/render-probe.ts
|
|
5415
|
-
function
|
|
5568
|
+
function Rr(e, t) {
|
|
5416
5569
|
return new Promise((n) => {
|
|
5417
5570
|
if (typeof Image != "function") return n(!0);
|
|
5418
5571
|
let r = new Image(), i = !1, a = setTimeout(() => o(!1), t), o = (e) => {
|
|
@@ -5421,14 +5574,14 @@ function Pr(e, t) {
|
|
|
5421
5574
|
r.onload = () => o(!0), r.onerror = () => o(!1), r.src = e;
|
|
5422
5575
|
});
|
|
5423
5576
|
}
|
|
5424
|
-
async function
|
|
5425
|
-
if (await
|
|
5577
|
+
async function zr(e, t = 8e3) {
|
|
5578
|
+
if (await Rr(e, t)) return !0;
|
|
5426
5579
|
try {
|
|
5427
5580
|
let r = await n(e);
|
|
5428
5581
|
if (!r) return !1;
|
|
5429
5582
|
let i = await fetch(e, { headers: r });
|
|
5430
5583
|
if (!i.ok) return !1;
|
|
5431
|
-
let a = URL.createObjectURL(await i.blob()), o = await
|
|
5584
|
+
let a = URL.createObjectURL(await i.blob()), o = await Rr(a, t);
|
|
5432
5585
|
return URL.revokeObjectURL(a), o;
|
|
5433
5586
|
} catch {
|
|
5434
5587
|
return !1;
|
|
@@ -5436,7 +5589,7 @@ async function Fr(e, t = 8e3) {
|
|
|
5436
5589
|
}
|
|
5437
5590
|
//#endregion
|
|
5438
5591
|
//#region src/editor/utils/resolve-local-media.ts
|
|
5439
|
-
function
|
|
5592
|
+
function Br() {
|
|
5440
5593
|
return {
|
|
5441
5594
|
uploaded: 0,
|
|
5442
5595
|
sessionOnly: 0,
|
|
@@ -5446,10 +5599,10 @@ function Ir() {
|
|
|
5446
5599
|
readFailed: []
|
|
5447
5600
|
};
|
|
5448
5601
|
}
|
|
5449
|
-
function
|
|
5602
|
+
function Vr(e, t) {
|
|
5450
5603
|
e.uploaded += t.uploaded, e.sessionOnly += t.sessionOnly, e.limitRejected += t.limitRejected, e.renderFailed += t.renderFailed, e.missing.push(...t.missing), e.readFailed.push(...t.readFailed);
|
|
5451
5604
|
}
|
|
5452
|
-
function
|
|
5605
|
+
function Hr(e, t, n, r) {
|
|
5453
5606
|
let { state: i } = e, a = [];
|
|
5454
5607
|
if (i.doc.descendants((e, n) => {
|
|
5455
5608
|
e.attrs?.src === t && a.push(n);
|
|
@@ -5465,7 +5618,7 @@ function Rr(e, t, n, r) {
|
|
|
5465
5618
|
}
|
|
5466
5619
|
return e.dispatch(o), !0;
|
|
5467
5620
|
}
|
|
5468
|
-
function
|
|
5621
|
+
function Ur(e, t, n) {
|
|
5469
5622
|
let { state: r } = e, i = r.schema.marks.link;
|
|
5470
5623
|
if (!i) return !1;
|
|
5471
5624
|
let a = [];
|
|
@@ -5483,7 +5636,7 @@ function zr(e, t, n) {
|
|
|
5483
5636
|
}));
|
|
5484
5637
|
return e.dispatch(o), !0;
|
|
5485
5638
|
}
|
|
5486
|
-
function
|
|
5639
|
+
function Wr(e) {
|
|
5487
5640
|
let t = /* @__PURE__ */ new Map();
|
|
5488
5641
|
for (let n of e) {
|
|
5489
5642
|
let e = t.get(n.normalized);
|
|
@@ -5491,36 +5644,36 @@ function Br(e) {
|
|
|
5491
5644
|
}
|
|
5492
5645
|
return Array.from(t.values());
|
|
5493
5646
|
}
|
|
5494
|
-
async function
|
|
5647
|
+
async function Gr(e, t, n, r) {
|
|
5495
5648
|
if (n.length === 0) return "sessionOnly";
|
|
5496
|
-
let i = n[0], a =
|
|
5649
|
+
let i = n[0], a = ln(t);
|
|
5497
5650
|
if (a) {
|
|
5498
|
-
let t =
|
|
5651
|
+
let t = un(e.state.doc, r, a);
|
|
5499
5652
|
if (t) return Z(`${i.basename}:${t}`, "error"), "limitRejected";
|
|
5500
5653
|
}
|
|
5501
5654
|
let s = n.filter((e) => !e.isLink), c = n.filter((e) => e.isLink);
|
|
5502
5655
|
if (s.length === 0) try {
|
|
5503
5656
|
let t = await o().upload(r, "editor"), n = !1;
|
|
5504
|
-
for (let r of c)
|
|
5657
|
+
for (let r of c) Ur(e, r.src, t) && (n = !0);
|
|
5505
5658
|
return n ? "uploaded" : "sessionOnly";
|
|
5506
5659
|
} catch (e) {
|
|
5507
5660
|
return console.error(`本地附件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), "sessionOnly";
|
|
5508
5661
|
}
|
|
5509
5662
|
let l = URL.createObjectURL(r), u = !1;
|
|
5510
|
-
for (let t of s)
|
|
5663
|
+
for (let t of s) Hr(e, t.src, l, r.size) && (u = !0);
|
|
5511
5664
|
let d;
|
|
5512
5665
|
try {
|
|
5513
5666
|
d = await o().upload(r, "editor");
|
|
5514
5667
|
} catch (e) {
|
|
5515
5668
|
return console.error(`本地文件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), URL.revokeObjectURL(l), "sessionOnly";
|
|
5516
5669
|
}
|
|
5517
|
-
URL.revokeObjectURL(l), u &&
|
|
5518
|
-
for (let t of c)
|
|
5519
|
-
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await
|
|
5670
|
+
URL.revokeObjectURL(l), u && Hr(e, l, d, r.size);
|
|
5671
|
+
for (let t of c) Ur(e, t.src, d);
|
|
5672
|
+
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await zr(d) ? "uploaded" : "renderFailed" : "uploaded";
|
|
5520
5673
|
}
|
|
5521
|
-
function
|
|
5674
|
+
function Kr(e, t) {
|
|
5522
5675
|
let n = [], r = [];
|
|
5523
|
-
for (let i of
|
|
5676
|
+
for (let i of Wr(e)) {
|
|
5524
5677
|
let e = i[0], a = t.get(e.basename);
|
|
5525
5678
|
a ? (n.push({
|
|
5526
5679
|
refs: i,
|
|
@@ -5532,30 +5685,30 @@ function Hr(e, t) {
|
|
|
5532
5685
|
unmatched: r
|
|
5533
5686
|
};
|
|
5534
5687
|
}
|
|
5535
|
-
async function
|
|
5536
|
-
let i =
|
|
5537
|
-
for (let a of
|
|
5538
|
-
let n = a[0], { file: o, readError: s } = await
|
|
5688
|
+
async function qr(e, t, n, r) {
|
|
5689
|
+
let i = Br();
|
|
5690
|
+
for (let a of Wr(n)) {
|
|
5691
|
+
let n = a[0], { file: o, readError: s } = await yr(r, n.src);
|
|
5539
5692
|
if (!o) {
|
|
5540
5693
|
s ? (console.warn(`本地文件「${n.basename}」在所选文件夹中找到但读取失败:`, s), i.readFailed.push(n)) : (console.warn(`本地文件「${n.basename}」未在所选文件夹「${r.name}」中找到`), i.missing.push(n));
|
|
5541
5694
|
continue;
|
|
5542
5695
|
}
|
|
5543
|
-
let c = await
|
|
5696
|
+
let c = await Gr(e, t, a, o);
|
|
5544
5697
|
i[c]++;
|
|
5545
5698
|
}
|
|
5546
5699
|
return i;
|
|
5547
5700
|
}
|
|
5548
|
-
function
|
|
5701
|
+
function Jr(e) {
|
|
5549
5702
|
let t = e.map((e) => e.basename);
|
|
5550
5703
|
return t.length <= 3 ? t.join("、") : `${t.slice(0, 3).join("、")} 等 ${t.length} 个文件`;
|
|
5551
5704
|
}
|
|
5552
|
-
function
|
|
5705
|
+
function Yr(e) {
|
|
5553
5706
|
let t = [];
|
|
5554
|
-
if (e.uploaded > 0 && t.push(`${e.uploaded} 个已上传至存储`), e.sessionOnly > 0 && t.push(`${e.sessionOnly} 个仅本次会话可见(未配置存储或上传失败)`), e.limitRejected > 0 && t.push(`${e.limitRejected} 个超出大小限制`), e.renderFailed > 0 && t.push(`${e.renderFailed} 个上传成功但页面渲染失败(存储 URL 无法在浏览器访问/解码)`), e.readFailed.length > 0 && t.push(`${e.readFailed.length} 个找到但读取失败:${
|
|
5707
|
+
if (e.uploaded > 0 && t.push(`${e.uploaded} 个已上传至存储`), e.sessionOnly > 0 && t.push(`${e.sessionOnly} 个仅本次会话可见(未配置存储或上传失败)`), e.limitRejected > 0 && t.push(`${e.limitRejected} 个超出大小限制`), e.renderFailed > 0 && t.push(`${e.renderFailed} 个上传成功但页面渲染失败(存储 URL 无法在浏览器访问/解码)`), e.readFailed.length > 0 && t.push(`${e.readFailed.length} 个找到但读取失败:${Jr(e.readFailed)}(若在 OneDrive / WPS 云盘等同步目录,请右键文件选择「始终保留在此设备」后重试)`), e.missing.length > 0 && t.push(`${e.missing.length} 个未能获取:${Jr(e.missing)}(可把文件直接拖进编辑器上传)`), t.length === 0) return;
|
|
5555
5708
|
let n = e.uploaded > 0 && e.renderFailed === 0 && e.missing.length === 0 && e.readFailed.length === 0;
|
|
5556
5709
|
Z(`本地文件解析完成:${t.join(";")}`, n ? "success" : "info");
|
|
5557
5710
|
}
|
|
5558
|
-
function
|
|
5711
|
+
function Xr(e) {
|
|
5559
5712
|
return new Promise((t) => {
|
|
5560
5713
|
let n = document.createElement("div");
|
|
5561
5714
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5582,7 +5735,7 @@ function Kr(e) {
|
|
|
5582
5735
|
u.type = "button", u.className = "px-3 py-1.5 text-xs rounded-lg bg-blue-500 hover:bg-blue-600 text-white", u.textContent = "选择文件夹…", u.addEventListener("click", () => s("pick")), o.append(l, u), r.append(i, a, o), n.appendChild(r), document.addEventListener("keydown", c), document.body.appendChild(n);
|
|
5583
5736
|
});
|
|
5584
5737
|
}
|
|
5585
|
-
function
|
|
5738
|
+
function Zr(e) {
|
|
5586
5739
|
let t = document.createElement("div");
|
|
5587
5740
|
t.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
5588
5741
|
let n = document.createElement("div");
|
|
@@ -5604,7 +5757,7 @@ function qr(e) {
|
|
|
5604
5757
|
let c = document.createElement("button");
|
|
5605
5758
|
c.type = "button", c.className = "px-3 py-1.5 text-xs rounded-lg bg-blue-500 hover:bg-blue-600 text-white", c.textContent = "知道了", c.addEventListener("click", o), a.append(c), n.append(r, i, a), t.appendChild(n), document.addEventListener("keydown", s), document.body.appendChild(t);
|
|
5606
5759
|
}
|
|
5607
|
-
function
|
|
5760
|
+
function Qr(e) {
|
|
5608
5761
|
return new Promise((t) => {
|
|
5609
5762
|
let n = document.createElement("div");
|
|
5610
5763
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5630,8 +5783,8 @@ function Jr(e) {
|
|
|
5630
5783
|
u.type = "button", u.className = "px-3 py-1.5 text-xs rounded-lg bg-blue-500 hover:bg-blue-600 text-white", u.textContent = "选择文件…", u.addEventListener("click", () => s("pick")), o.append(l, u), r.append(i, a, o), n.appendChild(r), document.addEventListener("keydown", c), document.body.appendChild(n);
|
|
5631
5784
|
});
|
|
5632
5785
|
}
|
|
5633
|
-
async function
|
|
5634
|
-
let r =
|
|
5786
|
+
async function $r(e, t, n) {
|
|
5787
|
+
let r = Br(), i = Wr(n), a = await gr();
|
|
5635
5788
|
if (!a) {
|
|
5636
5789
|
for (let e of i) r.missing.push(e[0]);
|
|
5637
5790
|
return r;
|
|
@@ -5644,14 +5797,14 @@ async function Yr(e, t, n) {
|
|
|
5644
5797
|
continue;
|
|
5645
5798
|
}
|
|
5646
5799
|
o.delete(i.basename);
|
|
5647
|
-
let s = await
|
|
5800
|
+
let s = await Gr(e, t, n, a);
|
|
5648
5801
|
r[s]++;
|
|
5649
5802
|
}
|
|
5650
5803
|
return r;
|
|
5651
5804
|
}
|
|
5652
5805
|
//#endregion
|
|
5653
5806
|
//#region src/editor/extensions/relative-media.ts
|
|
5654
|
-
var
|
|
5807
|
+
var ei = R.create({
|
|
5655
5808
|
name: "relativeMedia",
|
|
5656
5809
|
addStorage() {
|
|
5657
5810
|
return {
|
|
@@ -5661,38 +5814,38 @@ var Xr = R.create({
|
|
|
5661
5814
|
},
|
|
5662
5815
|
addProseMirrorPlugins() {
|
|
5663
5816
|
let e = this.editor, t = this.storage, n = !1, r = null, i = async (n, i) => {
|
|
5664
|
-
let a = e.view, o =
|
|
5817
|
+
let a = e.view, o = Br(), { matched: s, unmatched: c } = Kr(n, t.clipboardFiles);
|
|
5665
5818
|
for (let { refs: t, file: n } of s) {
|
|
5666
|
-
let r = await
|
|
5819
|
+
let r = await Gr(a, e, t, n);
|
|
5667
5820
|
o[r]++;
|
|
5668
5821
|
}
|
|
5669
5822
|
if (c.length > 0) {
|
|
5670
|
-
let t =
|
|
5671
|
-
if (
|
|
5823
|
+
let t = Wr(c).length;
|
|
5824
|
+
if (pr()) {
|
|
5672
5825
|
let n = i ?? null;
|
|
5673
|
-
if (n || (await
|
|
5674
|
-
r = n,
|
|
5826
|
+
if (n || (await Xr(t) === "pick" ? (n = await mr(), n || Z("没有选择文件夹。本地文件暂以占位显示,稍后可直接把文件拖进编辑器上传", "info")) : Z("已选择稍后处理。本地文件暂以占位显示,可直接把文件拖进编辑器上传", "info")), n) {
|
|
5827
|
+
r = n, Vr(o, await qr(a, e, c, n));
|
|
5675
5828
|
let t = [...o.missing, ...o.readFailed];
|
|
5676
|
-
if (t.length > 0 &&
|
|
5677
|
-
let n = await
|
|
5678
|
-
|
|
5829
|
+
if (t.length > 0 && hr() && await Qr(t.map((e) => e.basename)) === "pick") {
|
|
5830
|
+
let n = await $r(a, e, t);
|
|
5831
|
+
Vr(o, n), o.missing = n.missing, o.readFailed = [];
|
|
5679
5832
|
}
|
|
5680
5833
|
}
|
|
5681
|
-
} else
|
|
5834
|
+
} else Zr(t);
|
|
5682
5835
|
}
|
|
5683
|
-
|
|
5836
|
+
Yr(o);
|
|
5684
5837
|
}, o = () => {
|
|
5685
5838
|
if (!e || e.isDestroyed || t.pausedUntilPaste) return;
|
|
5686
|
-
let o = a(), s =
|
|
5839
|
+
let o = a(), s = xr(e.state.doc, o);
|
|
5687
5840
|
if (s.length === 0 || n) return;
|
|
5688
5841
|
n = !0;
|
|
5689
5842
|
let c = new Set(s.map((e) => e.src));
|
|
5690
5843
|
i(s).then(() => {
|
|
5691
5844
|
if (e.isDestroyed) return;
|
|
5692
|
-
let t =
|
|
5845
|
+
let t = xr(e.state.doc, o).filter((e) => !c.has(e.src));
|
|
5693
5846
|
if (t.length !== 0) return i(t, r);
|
|
5694
5847
|
}).finally(() => {
|
|
5695
|
-
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste =
|
|
5848
|
+
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste = xr(e.state.doc, o).length > 0);
|
|
5696
5849
|
});
|
|
5697
5850
|
};
|
|
5698
5851
|
return [new z({
|
|
@@ -5706,18 +5859,18 @@ var Xr = R.create({
|
|
|
5706
5859
|
}
|
|
5707
5860
|
})];
|
|
5708
5861
|
}
|
|
5709
|
-
}),
|
|
5710
|
-
function
|
|
5862
|
+
}), ti = new B("slashCommand");
|
|
5863
|
+
function ni(e) {
|
|
5711
5864
|
return R.create({
|
|
5712
5865
|
name: "slashCommand",
|
|
5713
5866
|
addProseMirrorPlugins() {
|
|
5714
5867
|
let t = {
|
|
5715
5868
|
char: "/",
|
|
5716
|
-
pluginKey:
|
|
5869
|
+
pluginKey: ti,
|
|
5717
5870
|
findSuggestionMatch: (e) => {
|
|
5718
5871
|
let { $position: t } = e;
|
|
5719
5872
|
for (let e = t.depth; e >= 0; e--) if (t.node(e).type.name === "codeBlock") return null;
|
|
5720
|
-
return t.marks().some((e) => e.type.name === "code") ? null :
|
|
5873
|
+
return t.marks().some((e) => e.type.name === "code") ? null : Ce(e);
|
|
5721
5874
|
},
|
|
5722
5875
|
allow: ({ editor: e, state: t }) => {
|
|
5723
5876
|
if (!e.isEditable) return !1;
|
|
@@ -5735,69 +5888,113 @@ function Qr(e) {
|
|
|
5735
5888
|
return n.filter((e) => e.title.toLowerCase().includes(r) || (e.description?.toLowerCase().includes(r) ?? !1));
|
|
5736
5889
|
},
|
|
5737
5890
|
render: () => {
|
|
5738
|
-
let e = null, t = null, n = 0, r = [];
|
|
5739
|
-
function
|
|
5891
|
+
let e = null, t = null, n = 0, r = [], i = null, a = null, o = null;
|
|
5892
|
+
function s(e, o) {
|
|
5740
5893
|
if (!t) return;
|
|
5741
|
-
r = e, t.textContent = "";
|
|
5742
|
-
let a = document.createElement("div");
|
|
5743
|
-
a.style.cssText = "padding:6px 8px;border-bottom:1px solid #f4f4f5;";
|
|
5744
|
-
let o = document.createElement("input");
|
|
5745
|
-
o.type = "text", o.placeholder = "搜索命令…", o.style.cssText = "width:100%;padding:6px 8px;border:1px solid #e4e4e7;border-radius:8px;font-size:13px;outline:none;background:#fafafa;", a.appendChild(o), t.appendChild(a);
|
|
5894
|
+
r = e, i = o, t.textContent = "";
|
|
5746
5895
|
let s = document.createElement("div");
|
|
5747
|
-
|
|
5896
|
+
s.style.cssText = "padding:6px 8px;border-bottom:1px solid #f4f4f5;";
|
|
5897
|
+
let c = document.createElement("input");
|
|
5898
|
+
c.type = "text", c.placeholder = "搜索命令…", c.style.cssText = "width:100%;padding:6px 8px;border:1px solid #e4e4e7;border-radius:8px;font-size:13px;outline:none;background:#fafafa;", s.appendChild(c), t.appendChild(s);
|
|
5899
|
+
let l = document.createElement("div");
|
|
5900
|
+
if (l.className = "slash-item-list", l.style.cssText = "max-height:300px;overflow-y:auto;", e.length === 0) {
|
|
5748
5901
|
let e = document.createElement("div");
|
|
5749
|
-
e.style.cssText = "padding:12px;text-align:center;color:#a1a1aa;font-size:13px;", e.textContent = "未找到匹配",
|
|
5902
|
+
e.style.cssText = "padding:12px;text-align:center;color:#a1a1aa;font-size:13px;", e.textContent = "未找到匹配", l.appendChild(e);
|
|
5750
5903
|
} else e.forEach((e, t) => {
|
|
5751
5904
|
let r = document.createElement("button");
|
|
5752
5905
|
r.type = "button", r.className = `slash-item${t === n ? " slash-item--selected" : ""}`, r.dataset.index = String(t), r.style.cssText = `display:flex;align-items:center;gap:12px;width:100%;padding:8px 12px;border:none;background:${t === n ? "#f4f4f5" : "transparent"};cursor:pointer;text-align:left;border-radius:8px;font-size:14px;transition:background 0.1s;`;
|
|
5753
|
-
let
|
|
5754
|
-
|
|
5755
|
-
let
|
|
5756
|
-
|
|
5757
|
-
let
|
|
5758
|
-
if (
|
|
5906
|
+
let i = document.createElement("span");
|
|
5907
|
+
i.style.cssText = "font-size:16px;width:24px;text-align:center;flex-shrink:0;", i.textContent = e.icon || "", r.appendChild(i);
|
|
5908
|
+
let a = document.createElement("div");
|
|
5909
|
+
a.style.cssText = "min-width:0;";
|
|
5910
|
+
let s = document.createElement("div");
|
|
5911
|
+
if (s.style.cssText = "font-weight:500;color:#18181b;", s.textContent = e.title, a.appendChild(s), e.description) {
|
|
5759
5912
|
let t = document.createElement("div");
|
|
5760
|
-
t.style.cssText = "font-size:12px;color:#a1a1aa;margin-top:1px;", t.textContent = e.description,
|
|
5913
|
+
t.style.cssText = "font-size:12px;color:#a1a1aa;margin-top:1px;", t.textContent = e.description, a.appendChild(t);
|
|
5761
5914
|
}
|
|
5762
|
-
r.appendChild(
|
|
5763
|
-
|
|
5764
|
-
}),
|
|
5915
|
+
r.appendChild(a), r.addEventListener("click", () => {
|
|
5916
|
+
o(e);
|
|
5917
|
+
}), l.appendChild(r);
|
|
5765
5918
|
});
|
|
5766
|
-
t.appendChild(
|
|
5767
|
-
let
|
|
5768
|
-
if (
|
|
5769
|
-
let e =
|
|
5770
|
-
t.top < e.top ?
|
|
5919
|
+
t.appendChild(l);
|
|
5920
|
+
let u = l.querySelector(".slash-item--selected");
|
|
5921
|
+
if (u) {
|
|
5922
|
+
let e = l.getBoundingClientRect(), t = u.getBoundingClientRect();
|
|
5923
|
+
t.top < e.top ? l.scrollTop -= e.top - t.top : t.bottom > e.bottom && (l.scrollTop += t.bottom - e.bottom);
|
|
5771
5924
|
}
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5925
|
+
let d = () => Array.from(l.querySelectorAll(".slash-item")).filter((e) => e.style.display !== "none" && !e.disabled), f = (e) => {
|
|
5926
|
+
l.querySelectorAll(".slash-item").forEach((t) => {
|
|
5927
|
+
t.classList.toggle("slash-item--selected", t === e), t.style.background = t === e ? "#f4f4f5" : "transparent";
|
|
5928
|
+
});
|
|
5929
|
+
let t = l.getBoundingClientRect(), n = e.getBoundingClientRect();
|
|
5930
|
+
n.top < t.top ? l.scrollTop -= t.top - n.top : n.bottom > t.bottom && (l.scrollTop += n.bottom - t.bottom);
|
|
5931
|
+
};
|
|
5932
|
+
c.addEventListener("input", () => {
|
|
5933
|
+
let e = c.value.toLowerCase();
|
|
5934
|
+
l.querySelectorAll(".slash-item").forEach((t) => {
|
|
5775
5935
|
let n = (t.textContent || "").toLowerCase();
|
|
5776
5936
|
t.style.display = n.includes(e) ? "" : "none";
|
|
5777
5937
|
});
|
|
5938
|
+
let t = d()[0];
|
|
5939
|
+
t && (n = Number(t.dataset.index ?? 0), f(t));
|
|
5940
|
+
}), c.addEventListener("keydown", (e) => {
|
|
5941
|
+
let t = d();
|
|
5942
|
+
if (e.key === "Enter") {
|
|
5943
|
+
e.preventDefault(), (t.find((e) => e.classList.contains("slash-item--selected")) ?? t[0])?.click();
|
|
5944
|
+
return;
|
|
5945
|
+
}
|
|
5946
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
5947
|
+
if (e.preventDefault(), t.length === 0) return;
|
|
5948
|
+
let r = t.findIndex((e) => e.classList.contains("slash-item--selected")), i = t[e.key === "ArrowDown" ? (r + 1) % t.length : (r - 1 + t.length) % t.length];
|
|
5949
|
+
n = Number(i.dataset.index ?? 0), f(i);
|
|
5950
|
+
return;
|
|
5951
|
+
}
|
|
5952
|
+
if (e.key === "Escape") {
|
|
5953
|
+
e.preventDefault();
|
|
5954
|
+
let t = a?.view;
|
|
5955
|
+
t && Se(t, ti);
|
|
5956
|
+
}
|
|
5778
5957
|
});
|
|
5779
5958
|
}
|
|
5780
|
-
let
|
|
5781
|
-
function
|
|
5782
|
-
if (!e || !
|
|
5783
|
-
let t =
|
|
5959
|
+
let c = null, l = null;
|
|
5960
|
+
function u() {
|
|
5961
|
+
if (!e || !c) return;
|
|
5962
|
+
let t = c();
|
|
5784
5963
|
t && (e.style.top = `${t.bottom + 4}px`, e.style.left = `${t.left}px`);
|
|
5785
5964
|
}
|
|
5786
5965
|
return {
|
|
5787
|
-
onStart: (
|
|
5788
|
-
n = 0,
|
|
5966
|
+
onStart: (i) => {
|
|
5967
|
+
if (n = 0, c = i.clientRect || null, a = { view: i.editor.view }, e || (e = document.createElement("div"), e.style.position = "fixed", e.style.zIndex = "9999", document.body.appendChild(e)), t || (t = document.createElement("div"), t.className = "slash-command-popup", t.style.cssText = "background:#fff;border:1px solid #e4e4e7;border-radius:12px;box-shadow:0 4px 24px rgba(0,0,0,0.12);min-width:260px;max-width:340px;", t.setAttribute("data-lenis-prevent", ""), e.appendChild(t)), u(), r = i.items, s(i.items, i.command), e.style.display = "block", l = () => u(), window.addEventListener("scroll", l, !0), !o) {
|
|
5968
|
+
let t = !1;
|
|
5969
|
+
o = (n) => {
|
|
5970
|
+
if (!e || e.style.display === "none" || n.target instanceof Node && e.contains(n.target) || t) return;
|
|
5971
|
+
let r = a?.view;
|
|
5972
|
+
r && (t = !0, window.setTimeout(() => {
|
|
5973
|
+
t = !1, e?.style.display !== "none" && Se(r, ti);
|
|
5974
|
+
}, 0));
|
|
5975
|
+
}, document.addEventListener("mousedown", o, !0), document.addEventListener("touchstart", o, !0);
|
|
5976
|
+
}
|
|
5789
5977
|
},
|
|
5790
5978
|
onUpdate: (e) => {
|
|
5791
|
-
n = 0,
|
|
5979
|
+
n = 0, c = e.clientRect || null, a = { view: e.editor.view }, r = e.items, s(e.items, e.command), u();
|
|
5980
|
+
},
|
|
5981
|
+
onKeyDown: (e) => {
|
|
5982
|
+
if (e.event.key === "ArrowDown") return e.event.preventDefault(), n = Math.min(n + 1, r.length - 1), i && s(r, i), !0;
|
|
5983
|
+
if (e.event.key === "ArrowUp") return e.event.preventDefault(), n = Math.max(n - 1, 0), i && s(r, i), !0;
|
|
5984
|
+
if (e.event.key === "Enter") {
|
|
5985
|
+
e.event.preventDefault();
|
|
5986
|
+
let t = r[n];
|
|
5987
|
+
return t && typeof t.command == "function" && i && i(t), !0;
|
|
5988
|
+
}
|
|
5989
|
+
return e.event.key === "Escape";
|
|
5792
5990
|
},
|
|
5793
|
-
onKeyDown: (e) => e.event.key === "ArrowDown" ? (e.event.preventDefault(), n = Math.min(n + 1, r.length - 1), i(r, e.command), !0) : e.event.key === "ArrowUp" ? (e.event.preventDefault(), n = Math.max(n - 1, 0), i(r, e.command), !0) : e.event.key === "Enter" ? (e.event.preventDefault(), r[n] && e.command(r[n]), !0) : e.event.key === "Escape",
|
|
5794
5991
|
onExit: () => {
|
|
5795
|
-
e && (e.style.display = "none"), n = 0, r = [], a = null,
|
|
5992
|
+
e && (e.style.display = "none"), n = 0, r = [], i = null, c = null, a = null, l &&= (window.removeEventListener("scroll", l, !0), null), o &&= (document.removeEventListener("mousedown", o, !0), document.removeEventListener("touchstart", o, !0), null);
|
|
5796
5993
|
}
|
|
5797
5994
|
};
|
|
5798
5995
|
}
|
|
5799
5996
|
};
|
|
5800
|
-
return [
|
|
5997
|
+
return [xe({
|
|
5801
5998
|
editor: this.editor,
|
|
5802
5999
|
...t
|
|
5803
6000
|
}), new z({
|
|
@@ -5809,14 +6006,14 @@ function Qr(e) {
|
|
|
5809
6006
|
break;
|
|
5810
6007
|
}
|
|
5811
6008
|
if (!i && !r.marks().some((e) => e.type.name === "code")) return null;
|
|
5812
|
-
let a =
|
|
5813
|
-
return a && a.active ? n.tr.setMeta(
|
|
6009
|
+
let a = ti.getState(n);
|
|
6010
|
+
return a && a.active ? n.tr.setMeta(ti, { exit: !0 }) : null;
|
|
5814
6011
|
}
|
|
5815
6012
|
})];
|
|
5816
6013
|
}
|
|
5817
6014
|
});
|
|
5818
6015
|
}
|
|
5819
|
-
function
|
|
6016
|
+
function ri(e, t) {
|
|
5820
6017
|
return [
|
|
5821
6018
|
{
|
|
5822
6019
|
title: e("editor.slash.heading1"),
|
|
@@ -5915,7 +6112,7 @@ function $r(e, t) {
|
|
|
5915
6112
|
n.type = "file", n.accept = "audio/*", n.onchange = async () => {
|
|
5916
6113
|
let r = n.files?.[0];
|
|
5917
6114
|
if (!r) return;
|
|
5918
|
-
let i =
|
|
6115
|
+
let i = ln(e) ?? t, a = i ? un(e.state.doc, r, i) : null;
|
|
5919
6116
|
if (a) {
|
|
5920
6117
|
Z(a);
|
|
5921
6118
|
return;
|
|
@@ -5925,7 +6122,7 @@ function $r(e, t) {
|
|
|
5925
6122
|
name: r.name,
|
|
5926
6123
|
size: r.size
|
|
5927
6124
|
});
|
|
5928
|
-
s && (e.chain().focus().insertContent(s).run(), await
|
|
6125
|
+
s && (e.chain().focus().insertContent(s).run(), await Dr(e.view, r, o));
|
|
5929
6126
|
}, n.click();
|
|
5930
6127
|
}
|
|
5931
6128
|
},
|
|
@@ -5938,7 +6135,7 @@ function $r(e, t) {
|
|
|
5938
6135
|
n.type = "file", n.accept = "*/*", n.multiple = !0, n.onchange = async () => {
|
|
5939
6136
|
let r = n.files;
|
|
5940
6137
|
if (!(!r || r.length === 0)) for (let n of Array.from(r)) {
|
|
5941
|
-
let r =
|
|
6138
|
+
let r = ln(e) ?? t, i = r ? un(e.state.doc, n, r) : null;
|
|
5942
6139
|
if (i) {
|
|
5943
6140
|
Z(i);
|
|
5944
6141
|
continue;
|
|
@@ -5955,7 +6152,7 @@ function $r(e, t) {
|
|
|
5955
6152
|
} catch {
|
|
5956
6153
|
continue;
|
|
5957
6154
|
}
|
|
5958
|
-
await
|
|
6155
|
+
await Dr(e.view, n, a);
|
|
5959
6156
|
}
|
|
5960
6157
|
}
|
|
5961
6158
|
}, n.click();
|
|
@@ -5965,9 +6162,9 @@ function $r(e, t) {
|
|
|
5965
6162
|
}
|
|
5966
6163
|
//#endregion
|
|
5967
6164
|
//#region src/editor/extensions/index.ts
|
|
5968
|
-
var
|
|
6165
|
+
var ii = oe.extend({
|
|
5969
6166
|
addNodeView() {
|
|
5970
|
-
return
|
|
6167
|
+
return I(xn);
|
|
5971
6168
|
},
|
|
5972
6169
|
addAttributes() {
|
|
5973
6170
|
return {
|
|
@@ -5990,111 +6187,111 @@ var ei = ce.extend({
|
|
|
5990
6187
|
};
|
|
5991
6188
|
}
|
|
5992
6189
|
});
|
|
5993
|
-
function
|
|
6190
|
+
function ai(e = {}) {
|
|
5994
6191
|
return [
|
|
5995
|
-
|
|
6192
|
+
G.configure({
|
|
5996
6193
|
codeBlock: !1,
|
|
5997
6194
|
horizontalRule: !1,
|
|
5998
6195
|
underline: !1,
|
|
5999
6196
|
link: !1
|
|
6000
6197
|
}),
|
|
6001
|
-
|
|
6002
|
-
|
|
6198
|
+
W,
|
|
6199
|
+
U.configure({
|
|
6003
6200
|
openOnClick: !0,
|
|
6004
6201
|
HTMLAttributes: {
|
|
6005
6202
|
rel: "noopener noreferrer",
|
|
6006
6203
|
target: "_blank"
|
|
6007
6204
|
}
|
|
6008
6205
|
}),
|
|
6009
|
-
|
|
6206
|
+
ii.configure({
|
|
6010
6207
|
inline: !1,
|
|
6011
6208
|
allowBase64: !0
|
|
6012
6209
|
}),
|
|
6013
|
-
ge,
|
|
6014
|
-
he.configure({ nested: !0 }),
|
|
6015
|
-
ue.configure({ multicolor: !0 }),
|
|
6016
|
-
_e,
|
|
6017
|
-
W,
|
|
6018
|
-
U.configure(e.maxLength ? { limit: e.maxLength } : {}),
|
|
6019
|
-
de,
|
|
6020
|
-
tr,
|
|
6021
|
-
fe.configure({ resizable: !0 }),
|
|
6022
|
-
K,
|
|
6023
|
-
pe,
|
|
6024
6210
|
me,
|
|
6025
|
-
|
|
6211
|
+
pe.configure({ nested: !0 }),
|
|
6212
|
+
se.configure({ multicolor: !0 }),
|
|
6213
|
+
he,
|
|
6214
|
+
q,
|
|
6215
|
+
K.configure(e.maxLength ? { limit: e.maxLength } : {}),
|
|
6216
|
+
ce,
|
|
6217
|
+
ar,
|
|
6218
|
+
le.configure({ resizable: !0 }),
|
|
6219
|
+
fe,
|
|
6220
|
+
ue,
|
|
6221
|
+
de,
|
|
6222
|
+
ge.configure({
|
|
6026
6223
|
html: !0,
|
|
6027
6224
|
transformPastedText: !0,
|
|
6028
6225
|
transformCopiedText: !1
|
|
6029
6226
|
}),
|
|
6030
|
-
|
|
6031
|
-
|
|
6227
|
+
J.configure({ placeholder: e.placeholder || "输入 '/' 打开菜单…" }),
|
|
6228
|
+
ni(() => ri((e) => f(e), {
|
|
6032
6229
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6033
6230
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6034
6231
|
})),
|
|
6035
|
-
|
|
6232
|
+
kr.configure({
|
|
6036
6233
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6037
6234
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6038
6235
|
}),
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6236
|
+
ei,
|
|
6237
|
+
Ir,
|
|
6238
|
+
Et,
|
|
6239
|
+
Lr,
|
|
6240
|
+
Kn,
|
|
6241
|
+
zn,
|
|
6242
|
+
In
|
|
6046
6243
|
];
|
|
6047
6244
|
}
|
|
6048
6245
|
//#endregion
|
|
6049
6246
|
//#region src/editor/extensions/bubble-menu.tsx
|
|
6050
|
-
var
|
|
6051
|
-
function
|
|
6052
|
-
|
|
6247
|
+
var oi = "https://www.bing.com/search?q={query}";
|
|
6248
|
+
function si(e) {
|
|
6249
|
+
oi = e;
|
|
6053
6250
|
}
|
|
6054
|
-
function
|
|
6055
|
-
return
|
|
6251
|
+
function ci() {
|
|
6252
|
+
return oi;
|
|
6056
6253
|
}
|
|
6057
|
-
function
|
|
6254
|
+
function li(e) {
|
|
6058
6255
|
return [
|
|
6059
6256
|
{
|
|
6060
6257
|
key: "bold",
|
|
6061
6258
|
label: e("editor.bubble.bold"),
|
|
6062
|
-
icon: /* @__PURE__ */ D(
|
|
6259
|
+
icon: /* @__PURE__ */ D(kt, {}),
|
|
6063
6260
|
isActive: (e) => e.isActive("bold"),
|
|
6064
6261
|
command: (e) => e.isEditable && e.chain().focus().toggleBold().run()
|
|
6065
6262
|
},
|
|
6066
6263
|
{
|
|
6067
6264
|
key: "italic",
|
|
6068
6265
|
label: e("editor.bubble.italic"),
|
|
6069
|
-
icon: /* @__PURE__ */ D(
|
|
6266
|
+
icon: /* @__PURE__ */ D(At, {}),
|
|
6070
6267
|
isActive: (e) => e.isActive("italic"),
|
|
6071
6268
|
command: (e) => e.isEditable && e.chain().focus().toggleItalic().run()
|
|
6072
6269
|
},
|
|
6073
6270
|
{
|
|
6074
6271
|
key: "underline",
|
|
6075
6272
|
label: e("editor.bubble.underline"),
|
|
6076
|
-
icon: /* @__PURE__ */ D(
|
|
6273
|
+
icon: /* @__PURE__ */ D(jt, {}),
|
|
6077
6274
|
isActive: (e) => e.isActive("underline"),
|
|
6078
6275
|
command: (e) => e.isEditable && e.chain().focus().toggleUnderline().run()
|
|
6079
6276
|
},
|
|
6080
6277
|
{
|
|
6081
6278
|
key: "strikethrough",
|
|
6082
6279
|
label: e("editor.bubble.strikethrough"),
|
|
6083
|
-
icon: /* @__PURE__ */ D(
|
|
6280
|
+
icon: /* @__PURE__ */ D(Mt, {}),
|
|
6084
6281
|
isActive: (e) => e.isActive("strike"),
|
|
6085
6282
|
command: (e) => e.isEditable && e.chain().focus().toggleStrike().run()
|
|
6086
6283
|
},
|
|
6087
6284
|
{
|
|
6088
6285
|
key: "code",
|
|
6089
6286
|
label: e("editor.bubble.emphasis"),
|
|
6090
|
-
icon: /* @__PURE__ */ D(
|
|
6287
|
+
icon: /* @__PURE__ */ D(Nt, {}),
|
|
6091
6288
|
isActive: (e) => e.isActive("code"),
|
|
6092
6289
|
command: (e) => e.isEditable && e.chain().focus().toggleCode().run()
|
|
6093
6290
|
},
|
|
6094
6291
|
{
|
|
6095
6292
|
key: "highlight",
|
|
6096
6293
|
label: e("editor.bubble.highlight"),
|
|
6097
|
-
icon: /* @__PURE__ */ D(
|
|
6294
|
+
icon: /* @__PURE__ */ D(Pt, {}),
|
|
6098
6295
|
more: !0,
|
|
6099
6296
|
isActive: (e) => e.isActive("highlight"),
|
|
6100
6297
|
command: () => {}
|
|
@@ -6102,7 +6299,7 @@ function ai(e) {
|
|
|
6102
6299
|
{
|
|
6103
6300
|
key: "link",
|
|
6104
6301
|
label: e("editor.bubble.link"),
|
|
6105
|
-
icon: /* @__PURE__ */ D(
|
|
6302
|
+
icon: /* @__PURE__ */ D(Ft, {}),
|
|
6106
6303
|
more: !0,
|
|
6107
6304
|
isActive: (e) => e.isActive("link"),
|
|
6108
6305
|
command: () => {}
|
|
@@ -6110,7 +6307,7 @@ function ai(e) {
|
|
|
6110
6307
|
{
|
|
6111
6308
|
key: "copy",
|
|
6112
6309
|
label: e("editor.bubble.copy"),
|
|
6113
|
-
icon: /* @__PURE__ */ D(
|
|
6310
|
+
icon: /* @__PURE__ */ D(Lt, {}),
|
|
6114
6311
|
more: !0,
|
|
6115
6312
|
isActive: () => !1,
|
|
6116
6313
|
command: (e) => {
|
|
@@ -6121,21 +6318,21 @@ function ai(e) {
|
|
|
6121
6318
|
{
|
|
6122
6319
|
key: "search",
|
|
6123
6320
|
label: e("editor.bubble.search"),
|
|
6124
|
-
icon: /* @__PURE__ */ D(
|
|
6321
|
+
icon: /* @__PURE__ */ D(Rt, {}),
|
|
6125
6322
|
more: !0,
|
|
6126
6323
|
isActive: () => !1,
|
|
6127
6324
|
command: (e) => {
|
|
6128
6325
|
if (e.isActive("table")) return;
|
|
6129
6326
|
let { from: t, to: n } = e.state.selection, r = e.state.doc.textBetween(t, n, " ").trim();
|
|
6130
6327
|
if (!r) return;
|
|
6131
|
-
let i =
|
|
6328
|
+
let i = oi.replace("{query}", encodeURIComponent(r));
|
|
6132
6329
|
window.open(i, "_blank", "noopener,noreferrer");
|
|
6133
6330
|
}
|
|
6134
6331
|
},
|
|
6135
6332
|
{
|
|
6136
6333
|
key: "table",
|
|
6137
6334
|
label: e("editor.bubble.table"),
|
|
6138
|
-
icon: /* @__PURE__ */ D(
|
|
6335
|
+
icon: /* @__PURE__ */ D(It, {}),
|
|
6139
6336
|
more: !0,
|
|
6140
6337
|
isActive: (e) => e.isActive("table"),
|
|
6141
6338
|
command: (e) => {
|
|
@@ -6151,7 +6348,7 @@ function ai(e) {
|
|
|
6151
6348
|
{
|
|
6152
6349
|
key: "ai",
|
|
6153
6350
|
label: e("editor.ai.trigger"),
|
|
6154
|
-
icon: /* @__PURE__ */ D(
|
|
6351
|
+
icon: /* @__PURE__ */ D(zt, {}),
|
|
6155
6352
|
isActive: () => !1,
|
|
6156
6353
|
command: (e) => {
|
|
6157
6354
|
e.isEditable && e.storage.qingwuUI?.openAI?.();
|
|
@@ -6162,7 +6359,7 @@ function ai(e) {
|
|
|
6162
6359
|
R.create({ name: "bubbleMenu" });
|
|
6163
6360
|
//#endregion
|
|
6164
6361
|
//#region src/editor/extensions/table-toolbar.tsx
|
|
6165
|
-
function
|
|
6362
|
+
function ui(e) {
|
|
6166
6363
|
let { $from: t } = e.state.selection;
|
|
6167
6364
|
for (let e = t.depth; e > 0; e--) {
|
|
6168
6365
|
let n = t.node(e);
|
|
@@ -6173,7 +6370,7 @@ function oi(e) {
|
|
|
6173
6370
|
}
|
|
6174
6371
|
return null;
|
|
6175
6372
|
}
|
|
6176
|
-
function
|
|
6373
|
+
function di(e) {
|
|
6177
6374
|
let t = [];
|
|
6178
6375
|
return e.forEach((e) => {
|
|
6179
6376
|
let n = [];
|
|
@@ -6182,7 +6379,7 @@ function si(e) {
|
|
|
6182
6379
|
}), t.push(n);
|
|
6183
6380
|
}), t;
|
|
6184
6381
|
}
|
|
6185
|
-
function
|
|
6382
|
+
function fi(e) {
|
|
6186
6383
|
if (e.length === 0) return "";
|
|
6187
6384
|
let t = Math.max(...e.map((e) => e.length), 1), n = (e) => e.concat(Array(Math.max(0, t - e.length)).fill("")).slice(0, t), r = n(e[0]), i = e.slice(1).map(n), a = (e) => `| ${e.join(" | ")} |`;
|
|
6188
6385
|
return [
|
|
@@ -6191,11 +6388,11 @@ function ci(e) {
|
|
|
6191
6388
|
...i.map(a)
|
|
6192
6389
|
].join("\n");
|
|
6193
6390
|
}
|
|
6194
|
-
function
|
|
6391
|
+
function pi(e) {
|
|
6195
6392
|
let t = (e) => /[",\n]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e;
|
|
6196
6393
|
return e.map((e) => e.map(t).join(",")).join("\n");
|
|
6197
6394
|
}
|
|
6198
|
-
function
|
|
6395
|
+
function mi(e) {
|
|
6199
6396
|
let t = e.trim();
|
|
6200
6397
|
if (!t) return null;
|
|
6201
6398
|
let n = t.split(/\r?\n/);
|
|
@@ -6209,7 +6406,7 @@ function ui(e) {
|
|
|
6209
6406
|
}
|
|
6210
6407
|
return null;
|
|
6211
6408
|
}
|
|
6212
|
-
function
|
|
6409
|
+
function hi({ editor: e }) {
|
|
6213
6410
|
let [t, n] = T(null), [r, i] = T(!1), [a, o] = T(!1), s = w(null), c = w(null), l = e.isEditable, u = b(() => {
|
|
6214
6411
|
c.current != null && cancelAnimationFrame(c.current), c.current = requestAnimationFrame(() => {
|
|
6215
6412
|
c.current = null;
|
|
@@ -6225,7 +6422,7 @@ function di({ editor: e }) {
|
|
|
6225
6422
|
n(null);
|
|
6226
6423
|
return;
|
|
6227
6424
|
}
|
|
6228
|
-
let t =
|
|
6425
|
+
let t = ui(e);
|
|
6229
6426
|
if (!t) {
|
|
6230
6427
|
n(null);
|
|
6231
6428
|
return;
|
|
@@ -6254,24 +6451,24 @@ function di({ editor: e }) {
|
|
|
6254
6451
|
});
|
|
6255
6452
|
return n.nodes.table.create(null, i);
|
|
6256
6453
|
}, p = () => {
|
|
6257
|
-
let t =
|
|
6454
|
+
let t = ui(e);
|
|
6258
6455
|
if (!t) return;
|
|
6259
|
-
let n =
|
|
6456
|
+
let n = fi(di(t.node));
|
|
6260
6457
|
navigator.clipboard?.writeText(n), i(!0), setTimeout(() => i(!1), 1500);
|
|
6261
6458
|
}, m = () => {
|
|
6262
|
-
let t =
|
|
6459
|
+
let t = ui(e);
|
|
6263
6460
|
if (!t) return;
|
|
6264
|
-
let n =
|
|
6461
|
+
let n = pi(di(t.node)), r = new Blob([`\ufeff${n}`], { type: "text/csv;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
6265
6462
|
a.href = i, a.download = "table.csv", document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
6266
6463
|
}, h = async () => {
|
|
6267
6464
|
if (l) try {
|
|
6268
6465
|
let t = await navigator.clipboard?.readText();
|
|
6269
6466
|
if (!t) return;
|
|
6270
|
-
let n =
|
|
6467
|
+
let n = mi(t);
|
|
6271
6468
|
if (!n || n.length === 0) return;
|
|
6272
6469
|
let r = f(n);
|
|
6273
6470
|
if (!r) return;
|
|
6274
|
-
let i =
|
|
6471
|
+
let i = ui(e), a = e.chain().focus();
|
|
6275
6472
|
if (i) {
|
|
6276
6473
|
let t = Math.min(i.pos + i.node.nodeSize, e.state.doc.content.size);
|
|
6277
6474
|
a.setTextSelection(t);
|
|
@@ -6391,7 +6588,7 @@ function di({ editor: e }) {
|
|
|
6391
6588
|
type: "button",
|
|
6392
6589
|
className: "tbl-btn tbl-btn--del",
|
|
6393
6590
|
onClick: () => {
|
|
6394
|
-
!l ||
|
|
6591
|
+
!l || mn() || ($(!0), o(!0));
|
|
6395
6592
|
},
|
|
6396
6593
|
title: "删除",
|
|
6397
6594
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -6409,7 +6606,7 @@ function di({ editor: e }) {
|
|
|
6409
6606
|
})
|
|
6410
6607
|
})
|
|
6411
6608
|
}),
|
|
6412
|
-
/* @__PURE__ */ D(
|
|
6609
|
+
/* @__PURE__ */ D(yn, {
|
|
6413
6610
|
open: a,
|
|
6414
6611
|
title: "确认删除表格",
|
|
6415
6612
|
message: "此操作不可撤销。",
|
|
@@ -6425,7 +6622,7 @@ function di({ editor: e }) {
|
|
|
6425
6622
|
}
|
|
6426
6623
|
//#endregion
|
|
6427
6624
|
//#region src/editor/ai-editor.tsx
|
|
6428
|
-
var
|
|
6625
|
+
var gi = [
|
|
6429
6626
|
{
|
|
6430
6627
|
color: "#fef08a",
|
|
6431
6628
|
name: "黄"
|
|
@@ -6450,9 +6647,9 @@ var fi = [
|
|
|
6450
6647
|
color: "#ddd6fe",
|
|
6451
6648
|
name: "紫"
|
|
6452
6649
|
}
|
|
6453
|
-
],
|
|
6454
|
-
function
|
|
6455
|
-
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth ||
|
|
6650
|
+
], _i = 288, vi = 480, yi = 320;
|
|
6651
|
+
function bi(e, t, n = {}) {
|
|
6652
|
+
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth || _i, vi, r - 32), o = Math.max(t || yi, 160);
|
|
6456
6653
|
if (r < 640) {
|
|
6457
6654
|
let t = Math.max(8, Math.min(e.top + 10, i - 420));
|
|
6458
6655
|
return {
|
|
@@ -6493,10 +6690,10 @@ function gi(e, t, n = {}) {
|
|
|
6493
6690
|
arrowLeft: p
|
|
6494
6691
|
};
|
|
6495
6692
|
}
|
|
6496
|
-
function
|
|
6693
|
+
function xi(e) {
|
|
6497
6694
|
return /(^|\n)```|(^|\n)#{1,6}\s|(^|\n)>\s?|(^|\n)\s*([-*_])(?:\s*\4){2,}\s*(?=\n|$)|(^|\n)\s*[-*+]\s+|(^|\n)\s*\d+[.)]\s+|(^|\n)\s*<img\s+|(^|\n)\s*\|.+\|/i.test(e);
|
|
6498
6695
|
}
|
|
6499
|
-
function
|
|
6696
|
+
function Si(e, t) {
|
|
6500
6697
|
try {
|
|
6501
6698
|
let n = e.storage?.markdown?.parser;
|
|
6502
6699
|
if (!n) return null;
|
|
@@ -6506,20 +6703,20 @@ function vi(e, t) {
|
|
|
6506
6703
|
return null;
|
|
6507
6704
|
}
|
|
6508
6705
|
}
|
|
6509
|
-
var
|
|
6706
|
+
var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.ImageUploadDialog }))), wi = y(() => import("./storage-settings-dialog-DZqqDAiO.js").then((e) => ({ default: e.StorageSettingsDialog }))), Ti = y(() => import("./export-dialog-CL7ie13Z.js").then((e) => ({ default: e.ExportDialog }))), Ei = y(() => import("./video-embed-dialog-AeGcMb4X.js").then((e) => ({ default: e.VideoEmbedDialog }))), Di = y(() => import("./md-import-dialog-Cf3ZOwA_.js").then((e) => ({ default: e.MdImportDialog }))), Oi = () => /* @__PURE__ */ O("div", {
|
|
6510
6707
|
className: "fixed inset-0 z-[9999] flex items-center justify-center",
|
|
6511
6708
|
children: [/* @__PURE__ */ D("div", { className: "absolute inset-0 bg-black/40 backdrop-blur-sm" }), /* @__PURE__ */ D("div", {
|
|
6512
6709
|
className: "relative bg-background rounded-2xl border border-default-200 p-8 flex items-center justify-center",
|
|
6513
6710
|
children: /* @__PURE__ */ D("div", { className: "w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin" })
|
|
6514
6711
|
})]
|
|
6515
|
-
}),
|
|
6516
|
-
let k = r === "view" || i, A = C(() => typeof e == "object" && e ||
|
|
6712
|
+
}), ki = ({ initialContent: e = "", onChange: t, placeholder: n, mode: r, readonly: i = !1, maxLength: a, maxAttachmentSize: o, maxTotalAttachmentSize: s, className: c = "", borderless: l = !1, style: u, showToolbar: p = !0, showToc: m = !0, showSearch: h = !0, onEditorReady: g, immediatelyRender: _, onToast: y }) => {
|
|
6713
|
+
let k = r === "view" || i, A = C(() => typeof e == "object" && e || xi(e) ? e : d(e), [e]), [j, M] = T(!1), [F, I] = T({}), [L, R] = T("below"), [re, ie] = T(50), z = w(null), [B, V] = T(!1), [H, ae] = T(!1), [oe, U] = T(!1), [W, G] = T(!1), [K, q] = T("none"), [se, ce] = T({}), [J, le] = T(""), [ue, de] = T(null), [fe, pe] = T(m), [me, he] = T(!1);
|
|
6517
6714
|
x(() => {
|
|
6518
|
-
|
|
6715
|
+
pe(m);
|
|
6519
6716
|
}, [m]);
|
|
6520
|
-
let [
|
|
6521
|
-
let e =
|
|
6522
|
-
e && (
|
|
6717
|
+
let [ge, _e] = T(!1), [ve, ye] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 80rem)").matches : !0), [be, xe] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 64rem)").matches : !0), Se = w(null), Ce = w(null), we = w(null), Te = w(0), Ee = w(null), De = w(null), Oe = w(null), [ke, Ae] = T(!1), [Y, je] = T(!1), [Me, Ne] = T(!1), Pe = w(null), Fe = b(() => {
|
|
6718
|
+
let e = Ce.current, t = we.current;
|
|
6719
|
+
e && (Y ? (document.body.style.overflow = "", Object.assign(e.style, {
|
|
6523
6720
|
position: "",
|
|
6524
6721
|
top: "",
|
|
6525
6722
|
left: "",
|
|
@@ -6535,9 +6732,9 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6535
6732
|
flex: "",
|
|
6536
6733
|
overflow: "",
|
|
6537
6734
|
minHeight: ""
|
|
6538
|
-
}),
|
|
6539
|
-
window.scrollTo(0,
|
|
6540
|
-
})) : (document.fullscreenElement && document.exitFullscreen(),
|
|
6735
|
+
}), je(!1), requestAnimationFrame(() => {
|
|
6736
|
+
window.scrollTo(0, Te.current);
|
|
6737
|
+
})) : (document.fullscreenElement && document.exitFullscreen(), Te.current = window.scrollY, Object.assign(e.style, {
|
|
6541
6738
|
position: "fixed",
|
|
6542
6739
|
top: "0",
|
|
6543
6740
|
left: "0",
|
|
@@ -6553,42 +6750,42 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6553
6750
|
flex: "1",
|
|
6554
6751
|
overflow: "auto",
|
|
6555
6752
|
minHeight: "0"
|
|
6556
|
-
}), document.body.style.overflow = "hidden",
|
|
6557
|
-
}, [
|
|
6558
|
-
let e =
|
|
6559
|
-
e && (document.fullscreenElement ? document.exitFullscreen() : (
|
|
6560
|
-
}, [
|
|
6753
|
+
}), document.body.style.overflow = "hidden", je(!0)));
|
|
6754
|
+
}, [Y]), Ie = b(() => {
|
|
6755
|
+
let e = Ce.current;
|
|
6756
|
+
e && (document.fullscreenElement ? document.exitFullscreen() : (Y && Fe(), Te.current = window.scrollY, e.requestFullscreen()));
|
|
6757
|
+
}, [Y, Fe]);
|
|
6561
6758
|
x(() => {
|
|
6562
6759
|
let e = (e) => {
|
|
6563
|
-
e.key === "Escape" &&
|
|
6760
|
+
e.key === "Escape" && Y && Fe();
|
|
6564
6761
|
}, t = () => {
|
|
6565
|
-
document.fullscreenElement ?
|
|
6566
|
-
window.scrollTo(0,
|
|
6762
|
+
document.fullscreenElement ? Ne(!0) : (Ne(!1), requestAnimationFrame(() => {
|
|
6763
|
+
window.scrollTo(0, Te.current);
|
|
6567
6764
|
}));
|
|
6568
6765
|
};
|
|
6569
6766
|
return window.addEventListener("keydown", e), document.addEventListener("fullscreenchange", t), () => {
|
|
6570
6767
|
window.removeEventListener("keydown", e), document.removeEventListener("fullscreenchange", t);
|
|
6571
6768
|
};
|
|
6572
|
-
}, [
|
|
6769
|
+
}, [Y, Fe]), x(() => {
|
|
6573
6770
|
if (!h) return;
|
|
6574
6771
|
let e = (e) => {
|
|
6575
6772
|
if ((e.ctrlKey || e.metaKey) && (e.key === "f" || e.key === "F")) {
|
|
6576
|
-
if (!
|
|
6577
|
-
e.preventDefault(), e.stopPropagation(),
|
|
6773
|
+
if (!Ce.current) return;
|
|
6774
|
+
e.preventDefault(), e.stopPropagation(), _e(!0);
|
|
6578
6775
|
}
|
|
6579
6776
|
};
|
|
6580
6777
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
6581
6778
|
}, [h]), x(() => {
|
|
6582
6779
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
6583
|
-
let e = window.matchMedia("(min-width: 80rem)"), t = (e) =>
|
|
6584
|
-
return
|
|
6780
|
+
let e = window.matchMedia("(min-width: 80rem)"), t = (e) => ye(e.matches);
|
|
6781
|
+
return ye(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
6585
6782
|
}, []), x(() => {
|
|
6586
6783
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
6587
|
-
let e = window.matchMedia("(min-width: 64rem)"), t = (e) =>
|
|
6588
|
-
return
|
|
6784
|
+
let e = window.matchMedia("(min-width: 64rem)"), t = (e) => xe(e.matches);
|
|
6785
|
+
return xe(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
6589
6786
|
}, []);
|
|
6590
|
-
let
|
|
6591
|
-
extensions:
|
|
6787
|
+
let X = ee({
|
|
6788
|
+
extensions: ai({
|
|
6592
6789
|
placeholder: n || f("editor.placeholder"),
|
|
6593
6790
|
maxLength: a,
|
|
6594
6791
|
maxAttachmentSize: o,
|
|
@@ -6598,22 +6795,25 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6598
6795
|
editable: !k,
|
|
6599
6796
|
immediatelyRender: _,
|
|
6600
6797
|
onUpdate: ({ editor: e }) => {
|
|
6601
|
-
t && (
|
|
6798
|
+
t && (Se.current && clearTimeout(Se.current), Se.current = setTimeout(() => {
|
|
6602
6799
|
t?.(e.getHTML(), e.getJSON());
|
|
6603
6800
|
}, 300));
|
|
6604
6801
|
},
|
|
6605
6802
|
onCreate: () => {},
|
|
6606
6803
|
editorProps: {
|
|
6607
|
-
attributes: {
|
|
6804
|
+
attributes: {
|
|
6805
|
+
class: "prose prose-neutral dark:prose-invert max-w-none focus:outline-none min-h-[200px] px-4 sm:px-8 py-4",
|
|
6806
|
+
...k ? {} : { style: "padding-left: 2.75rem" }
|
|
6807
|
+
},
|
|
6608
6808
|
handlePaste(e, t) {
|
|
6609
6809
|
let n = t.clipboardData;
|
|
6610
6810
|
if (!n) return !1;
|
|
6611
6811
|
let r = n.getData("text/plain");
|
|
6612
6812
|
if (!r || !r.includes("[[")) return !1;
|
|
6613
6813
|
t.preventDefault();
|
|
6614
|
-
let i =
|
|
6814
|
+
let i = De.current?.storage?.relativeMedia;
|
|
6615
6815
|
i && (i.clipboardFiles = new Map(Array.from(n.files ?? []).map((e) => [e.name.toLowerCase(), e])), i.pausedUntilPaste = !1);
|
|
6616
|
-
let a =
|
|
6816
|
+
let a = De.current ? Si(De.current, r) : null;
|
|
6617
6817
|
if (a) {
|
|
6618
6818
|
let t = new N(a, 0, 0);
|
|
6619
6819
|
e.dispatch(e.state.tr.replaceSelection(t).scrollIntoView());
|
|
@@ -6623,21 +6823,21 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6623
6823
|
}
|
|
6624
6824
|
});
|
|
6625
6825
|
x(() => {
|
|
6626
|
-
|
|
6627
|
-
}, [
|
|
6628
|
-
if (
|
|
6629
|
-
}, [
|
|
6630
|
-
!
|
|
6631
|
-
}, [
|
|
6632
|
-
if (!
|
|
6826
|
+
De.current = X, window.__editor = X;
|
|
6827
|
+
}, [X]), x(() => {
|
|
6828
|
+
if (X) return () => Yt(X);
|
|
6829
|
+
}, [X]), x(() => {
|
|
6830
|
+
!X || !g || g(X);
|
|
6831
|
+
}, [X, g]), x(() => {
|
|
6832
|
+
if (!X) return;
|
|
6633
6833
|
let e = () => {
|
|
6634
|
-
|
|
6834
|
+
X.state.selection.empty && (q("none"), Ae(!1));
|
|
6635
6835
|
};
|
|
6636
|
-
return
|
|
6637
|
-
|
|
6836
|
+
return X.on("selectionUpdate", e), () => {
|
|
6837
|
+
X.off("selectionUpdate", e);
|
|
6638
6838
|
};
|
|
6639
|
-
}, [
|
|
6640
|
-
|
|
6839
|
+
}, [X]), x(() => {
|
|
6840
|
+
X && X.setOptions({ extensions: ai({
|
|
6641
6841
|
placeholder: n || f("editor.placeholder"),
|
|
6642
6842
|
maxLength: a,
|
|
6643
6843
|
maxAttachmentSize: o,
|
|
@@ -6651,78 +6851,78 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6651
6851
|
]);
|
|
6652
6852
|
let Le = w(e);
|
|
6653
6853
|
x(() => {
|
|
6654
|
-
if (!
|
|
6854
|
+
if (!X || e === Le.current) return;
|
|
6655
6855
|
Le.current = e;
|
|
6656
|
-
let t = typeof e == "object" && e ||
|
|
6657
|
-
|
|
6658
|
-
}, [
|
|
6659
|
-
|
|
6660
|
-
}, [
|
|
6661
|
-
if (y) return
|
|
6856
|
+
let t = typeof e == "object" && e || xi(e) ? e : d(e);
|
|
6857
|
+
X.commands.setContent(t, { emitUpdate: !1 });
|
|
6858
|
+
}, [X, e]), x(() => {
|
|
6859
|
+
X && X.setEditable(!k, !1);
|
|
6860
|
+
}, [X, k]), x(() => {
|
|
6861
|
+
if (y) return Qe(y);
|
|
6662
6862
|
}, [y]), x(() => {
|
|
6663
|
-
if (!
|
|
6664
|
-
let e =
|
|
6665
|
-
e > s && Z(`文档内附件总大小 ${
|
|
6666
|
-
}, [
|
|
6667
|
-
if (!
|
|
6668
|
-
let e =
|
|
6863
|
+
if (!X) return;
|
|
6864
|
+
let e = sn(X.state.doc);
|
|
6865
|
+
e > s && Z(`文档内附件总大小 ${cn(e)} 已超过限制 ${cn(s)}`, "info");
|
|
6866
|
+
}, [X, s]), x(() => {
|
|
6867
|
+
if (!X) return;
|
|
6868
|
+
let e = X.storage.qingwuUI;
|
|
6669
6869
|
e && (e.limits = {
|
|
6670
6870
|
maxAttachmentSize: o,
|
|
6671
6871
|
maxTotalAttachmentSize: s
|
|
6672
6872
|
});
|
|
6673
6873
|
}, [
|
|
6674
|
-
|
|
6874
|
+
X,
|
|
6675
6875
|
o,
|
|
6676
6876
|
s
|
|
6677
6877
|
]);
|
|
6678
6878
|
let Re = b((e) => {
|
|
6679
|
-
let t =
|
|
6680
|
-
|
|
6879
|
+
let t = Oe.current?.getBoundingClientRect();
|
|
6880
|
+
q(e), Ae(!1), ce({
|
|
6681
6881
|
position: "fixed",
|
|
6682
6882
|
top: t ? t.bottom + 8 : void 0,
|
|
6683
6883
|
left: t ? Math.max(8, Math.min(t.left, window.innerWidth - 240)) : 8,
|
|
6684
6884
|
zIndex: 9999
|
|
6685
6885
|
});
|
|
6686
|
-
}, []), ze =
|
|
6687
|
-
if (
|
|
6886
|
+
}, []), ze = li((e) => f(e)), Be = ze.filter((e) => !e.more), Ve = ze.filter((e) => e.more), He = Be.filter((e) => e.key !== "ai"), Ue = Be.find((e) => e.key === "ai"), We = b((e) => {
|
|
6887
|
+
if (X) if (Ae(!1), e.key === "link") if (X.isActive("link")) X.chain().focus().unsetLink().run();
|
|
6688
6888
|
else {
|
|
6689
|
-
let e =
|
|
6690
|
-
|
|
6889
|
+
let e = X.getAttributes("link").href || "";
|
|
6890
|
+
le(e), Re("link");
|
|
6691
6891
|
}
|
|
6692
|
-
else e.key === "highlight" ?
|
|
6892
|
+
else e.key === "highlight" ? K === "highlight" ? q("none") : Re("highlight") : e.command(X);
|
|
6693
6893
|
}, [
|
|
6694
|
-
|
|
6695
|
-
|
|
6894
|
+
X,
|
|
6895
|
+
K,
|
|
6696
6896
|
Re
|
|
6697
|
-
]),
|
|
6897
|
+
]), Ge = b((e) => X ? e.key === "highlight" ? K === "highlight" : e.key === "link" ? X.isActive("link") : e.isActive(X) : !1, [X, K]), [Ke, qe] = T(0);
|
|
6698
6898
|
x(() => {
|
|
6699
|
-
if (!
|
|
6700
|
-
let e = () =>
|
|
6701
|
-
return
|
|
6702
|
-
|
|
6899
|
+
if (!X) return;
|
|
6900
|
+
let e = () => qe((e) => (e + 1) % 1e6);
|
|
6901
|
+
return X.on("update", e), () => {
|
|
6902
|
+
X.off("update", e);
|
|
6703
6903
|
};
|
|
6704
|
-
}, [
|
|
6705
|
-
let [
|
|
6904
|
+
}, [X]);
|
|
6905
|
+
let [Je, Ye] = T(!1);
|
|
6706
6906
|
x(() => {
|
|
6707
|
-
if (!
|
|
6907
|
+
if (!X) return;
|
|
6708
6908
|
let e = () => {
|
|
6709
6909
|
let e = !1;
|
|
6710
|
-
|
|
6910
|
+
X.state.doc.descendants((t) => {
|
|
6711
6911
|
t.type.name === "heading" && (e = !0);
|
|
6712
|
-
}),
|
|
6912
|
+
}), Ye(e);
|
|
6713
6913
|
};
|
|
6714
|
-
return e(),
|
|
6715
|
-
|
|
6914
|
+
return e(), X.on("update", e), () => {
|
|
6915
|
+
X.off("update", e);
|
|
6716
6916
|
};
|
|
6717
|
-
}, [
|
|
6718
|
-
let
|
|
6917
|
+
}, [X]);
|
|
6918
|
+
let Xe = C(() => X?.storage?.characterCount?.characters?.() ?? 0, [X, Ke]), Ze = a ? Xe > a : !1;
|
|
6719
6919
|
x(() => () => {
|
|
6720
|
-
|
|
6920
|
+
Se.current && clearTimeout(Se.current);
|
|
6721
6921
|
}, []), x(() => () => {
|
|
6722
|
-
|
|
6922
|
+
ue && ue.resolve(null);
|
|
6723
6923
|
}, []);
|
|
6724
|
-
let
|
|
6725
|
-
if (!
|
|
6924
|
+
let $e = b((e) => {
|
|
6925
|
+
if (!X?.isEditable) return;
|
|
6726
6926
|
let t = window.getSelection(), n;
|
|
6727
6927
|
if (e) {
|
|
6728
6928
|
let t = e.getBoundingClientRect();
|
|
@@ -6739,66 +6939,77 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6739
6939
|
width: e.width
|
|
6740
6940
|
};
|
|
6741
6941
|
} else {
|
|
6742
|
-
let e =
|
|
6942
|
+
let e = X.view.coordsAtPos(X.state.selection.from);
|
|
6743
6943
|
n = {
|
|
6744
6944
|
top: e.bottom,
|
|
6745
6945
|
left: e.left,
|
|
6746
6946
|
width: 0
|
|
6747
6947
|
};
|
|
6748
6948
|
}
|
|
6749
|
-
|
|
6750
|
-
let r =
|
|
6949
|
+
Ee.current = n;
|
|
6950
|
+
let r = Ce.current?.getBoundingClientRect(), i = bi(n, void 0, {
|
|
6751
6951
|
panelWidth: r?.width,
|
|
6752
6952
|
editorLeft: r?.left
|
|
6753
6953
|
});
|
|
6754
6954
|
M(!0), I(i.style), R(i.placement), ie(i.arrowLeft);
|
|
6755
|
-
}, [
|
|
6955
|
+
}, [X]);
|
|
6756
6956
|
x(() => {
|
|
6757
|
-
if (!
|
|
6758
|
-
let e =
|
|
6759
|
-
if (e) return e.openImageDialog = () =>
|
|
6760
|
-
|
|
6957
|
+
if (!X) return;
|
|
6958
|
+
let e = X.storage.qingwuUI;
|
|
6959
|
+
if (e) return e.openImageDialog = () => V(!0), e.openVideoDialog = () => ae(!0), e.chooseMd = (e, t) => {
|
|
6960
|
+
de({
|
|
6761
6961
|
filename: e,
|
|
6762
6962
|
resolve: t
|
|
6763
6963
|
});
|
|
6764
|
-
}, e.openAI =
|
|
6964
|
+
}, e.openAI = $e, e.parseMd = (e, t) => X ? Si(X, t) : null, () => {
|
|
6765
6965
|
delete e.openImageDialog, delete e.openVideoDialog, delete e.openAI, delete e.parseMd, delete e.chooseMd;
|
|
6766
6966
|
};
|
|
6767
|
-
}, [
|
|
6768
|
-
if (!j || !
|
|
6769
|
-
let e =
|
|
6967
|
+
}, [X, $e]), S(() => {
|
|
6968
|
+
if (!j || !X) return;
|
|
6969
|
+
let e = Ee.current;
|
|
6770
6970
|
if (!e) return;
|
|
6771
|
-
let t = z.current, n =
|
|
6971
|
+
let t = z.current, n = Ce.current?.getBoundingClientRect(), r = bi(e, t?.offsetHeight || void 0, {
|
|
6772
6972
|
panelWidth: n?.width,
|
|
6773
6973
|
editorLeft: n?.left
|
|
6774
6974
|
});
|
|
6775
6975
|
R(r.placement), ie(r.arrowLeft), I(r.style);
|
|
6776
|
-
}, [j,
|
|
6777
|
-
if (!j || !
|
|
6976
|
+
}, [j, X]), x(() => {
|
|
6977
|
+
if (!j || !X) return;
|
|
6778
6978
|
let e = () => {
|
|
6779
|
-
let e =
|
|
6979
|
+
let e = Ee.current;
|
|
6780
6980
|
if (!e) return;
|
|
6781
|
-
let t = z.current, n =
|
|
6981
|
+
let t = z.current, n = Ce.current?.getBoundingClientRect(), r = bi(e, t?.offsetHeight || void 0, {
|
|
6782
6982
|
panelWidth: n?.width,
|
|
6783
6983
|
editorLeft: n?.left
|
|
6784
6984
|
});
|
|
6785
6985
|
R(r.placement), ie(r.arrowLeft), I(r.style);
|
|
6786
6986
|
};
|
|
6787
6987
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
6788
|
-
}, [j,
|
|
6789
|
-
j || (
|
|
6988
|
+
}, [j, X]), x(() => {
|
|
6989
|
+
j || (Ee.current = null);
|
|
6790
6990
|
}, [j]);
|
|
6791
|
-
let
|
|
6792
|
-
|
|
6793
|
-
}, [
|
|
6794
|
-
(
|
|
6795
|
-
}, [
|
|
6991
|
+
let et = b((e) => {
|
|
6992
|
+
X?.chain().focus().setImage({ src: e }).run();
|
|
6993
|
+
}, [X]), tt = b((e) => {
|
|
6994
|
+
(X?.commands).insertVideo?.({ src: e });
|
|
6995
|
+
}, [X]), nt = fe && ve && !Y && !Me, rt = !nt && !me && (fe || Je && !(!k && be)), it = w(!1);
|
|
6796
6996
|
return x(() => {
|
|
6797
|
-
|
|
6798
|
-
}, [
|
|
6997
|
+
it.current || (it.current = !0, fe && !nt && he(!0));
|
|
6998
|
+
}, [fe, nt]), x(() => {
|
|
6999
|
+
if (!me) return;
|
|
7000
|
+
let e = (e) => {
|
|
7001
|
+
let t = e.target;
|
|
7002
|
+
Pe.current?.contains(t) || he(!1);
|
|
7003
|
+
}, t = (e) => {
|
|
7004
|
+
e.key === "Escape" && he(!1);
|
|
7005
|
+
};
|
|
7006
|
+
return document.addEventListener("mousedown", e), document.addEventListener("touchstart", e, { passive: !0 }), document.addEventListener("keydown", t), () => {
|
|
7007
|
+
document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e), document.removeEventListener("keydown", t);
|
|
7008
|
+
};
|
|
7009
|
+
}, [me]), X ? /* @__PURE__ */ O("div", {
|
|
6799
7010
|
className: "qingwu-editor-row",
|
|
6800
7011
|
children: [/* @__PURE__ */ O("div", {
|
|
6801
|
-
ref:
|
|
7012
|
+
ref: Ce,
|
|
6802
7013
|
className: `qingwu-editor relative flex-1 min-w-0 bg-background ${k ? "qingwu-editor--readonly" : ""} ${l ? "" : "rounded-xl border border-default-200"} ${c}`,
|
|
6803
7014
|
style: u,
|
|
6804
7015
|
children: [
|
|
@@ -6809,13 +7020,13 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6809
7020
|
children: [
|
|
6810
7021
|
/* @__PURE__ */ D("button", {
|
|
6811
7022
|
type: "button",
|
|
6812
|
-
className: `qed-tb-btn qed-tb-btn--desktop-only${
|
|
7023
|
+
className: `qed-tb-btn qed-tb-btn--desktop-only${fe ? " is-active" : ""}`,
|
|
6813
7024
|
onClick: () => {
|
|
6814
|
-
|
|
7025
|
+
fe ? (pe(!1), he(!1)) : (pe(!0), ve && !Y && !Me || he(!0));
|
|
6815
7026
|
},
|
|
6816
|
-
title:
|
|
6817
|
-
"aria-label":
|
|
6818
|
-
"aria-pressed":
|
|
7027
|
+
title: fe ? "隐藏目录" : "显示目录",
|
|
7028
|
+
"aria-label": fe ? "隐藏目录" : "显示目录",
|
|
7029
|
+
"aria-pressed": fe,
|
|
6819
7030
|
children: /* @__PURE__ */ D("svg", {
|
|
6820
7031
|
fill: "none",
|
|
6821
7032
|
viewBox: "0 0 24 24",
|
|
@@ -6831,11 +7042,11 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6831
7042
|
}),
|
|
6832
7043
|
h && /* @__PURE__ */ D("button", {
|
|
6833
7044
|
type: "button",
|
|
6834
|
-
className: `qed-tb-btn${
|
|
6835
|
-
onClick: () =>
|
|
7045
|
+
className: `qed-tb-btn${ge ? " is-active" : ""}`,
|
|
7046
|
+
onClick: () => _e(!ge),
|
|
6836
7047
|
title: "查找 (Ctrl+F)",
|
|
6837
7048
|
"aria-label": "查找",
|
|
6838
|
-
"aria-pressed":
|
|
7049
|
+
"aria-pressed": ge,
|
|
6839
7050
|
children: /* @__PURE__ */ D("svg", {
|
|
6840
7051
|
fill: "none",
|
|
6841
7052
|
viewBox: "0 0 24 24",
|
|
@@ -6852,7 +7063,7 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6852
7063
|
!k && /* @__PURE__ */ D("button", {
|
|
6853
7064
|
type: "button",
|
|
6854
7065
|
className: `qed-tb-btn qed-tb-btn--ai${j ? " is-active" : ""}`,
|
|
6855
|
-
onClick: (e) => j ? M(!1) :
|
|
7066
|
+
onClick: (e) => j ? M(!1) : $e(e.currentTarget),
|
|
6856
7067
|
title: f("editor.toolbar.aiTitle"),
|
|
6857
7068
|
"aria-label": f("editor.toolbar.ai"),
|
|
6858
7069
|
"aria-pressed": j,
|
|
@@ -6880,7 +7091,7 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6880
7091
|
/* @__PURE__ */ O("button", {
|
|
6881
7092
|
type: "button",
|
|
6882
7093
|
className: "qed-tb-btn qed-tb-btn--solid",
|
|
6883
|
-
onClick: () =>
|
|
7094
|
+
onClick: () => G(!0),
|
|
6884
7095
|
title: f("editor.toolbar.exportTitle"),
|
|
6885
7096
|
children: [/* @__PURE__ */ D("svg", {
|
|
6886
7097
|
fill: "none",
|
|
@@ -6900,11 +7111,11 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6900
7111
|
}),
|
|
6901
7112
|
/* @__PURE__ */ D("button", {
|
|
6902
7113
|
type: "button",
|
|
6903
|
-
className: `qed-tb-btn${
|
|
7114
|
+
className: `qed-tb-btn${Y ? " is-active" : ""}`,
|
|
6904
7115
|
onClick: Fe,
|
|
6905
|
-
title:
|
|
6906
|
-
"aria-label":
|
|
6907
|
-
"aria-pressed":
|
|
7116
|
+
title: Y ? "退出网页全屏" : "网页全屏",
|
|
7117
|
+
"aria-label": Y ? "退出网页全屏" : "网页全屏",
|
|
7118
|
+
"aria-pressed": Y,
|
|
6908
7119
|
children: /* @__PURE__ */ D("svg", {
|
|
6909
7120
|
fill: "none",
|
|
6910
7121
|
viewBox: "0 0 24 24",
|
|
@@ -6920,11 +7131,11 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6920
7131
|
}),
|
|
6921
7132
|
/* @__PURE__ */ D("button", {
|
|
6922
7133
|
type: "button",
|
|
6923
|
-
className: `qed-tb-btn${
|
|
7134
|
+
className: `qed-tb-btn${Me ? " is-active" : ""}`,
|
|
6924
7135
|
onClick: Ie,
|
|
6925
|
-
title:
|
|
6926
|
-
"aria-label":
|
|
6927
|
-
"aria-pressed":
|
|
7136
|
+
title: Me ? "退出全屏" : "全屏",
|
|
7137
|
+
"aria-label": Me ? "退出全屏" : "全屏",
|
|
7138
|
+
"aria-pressed": Me,
|
|
6928
7139
|
children: /* @__PURE__ */ D("svg", {
|
|
6929
7140
|
fill: "none",
|
|
6930
7141
|
viewBox: "0 0 24 24",
|
|
@@ -6941,8 +7152,8 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6941
7152
|
]
|
|
6942
7153
|
})]
|
|
6943
7154
|
}),
|
|
6944
|
-
|
|
6945
|
-
editor:
|
|
7155
|
+
X && !k && X.isEditable && /* @__PURE__ */ D(te, {
|
|
7156
|
+
editor: X,
|
|
6946
7157
|
shouldShow: ({ editor: e, state: t }) => !(e.isActive("image") || e.isActive("videoEmbed") || e.isActive("codeBlock") || e.isActive("audioEmbed") || e.isActive("attachmentEmbed") || t.selection.empty),
|
|
6947
7158
|
options: {
|
|
6948
7159
|
placement: "bottom",
|
|
@@ -6951,17 +7162,17 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6951
7162
|
},
|
|
6952
7163
|
className: "bubble-menu-pop bg-background border border-default-200 rounded-xl p-1 shadow-lg",
|
|
6953
7164
|
children: /* @__PURE__ */ O("div", {
|
|
6954
|
-
ref:
|
|
7165
|
+
ref: Oe,
|
|
6955
7166
|
className: "bubble-menu-items relative flex items-center gap-0.5",
|
|
6956
7167
|
onPointerDown: (e) => {
|
|
6957
7168
|
e.target.closest("button") && e.preventDefault();
|
|
6958
7169
|
},
|
|
6959
7170
|
children: [
|
|
6960
|
-
|
|
7171
|
+
He.map((e) => /* @__PURE__ */ D("button", {
|
|
6961
7172
|
type: "button",
|
|
6962
|
-
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${e.isActive(
|
|
7173
|
+
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${e.isActive(X) ? "bg-primary/10 text-primary" : "text-default-600 hover:bg-default-100"}`,
|
|
6963
7174
|
onClick: (t) => {
|
|
6964
|
-
t.preventDefault(),
|
|
7175
|
+
t.preventDefault(), We(e);
|
|
6965
7176
|
},
|
|
6966
7177
|
title: e.label,
|
|
6967
7178
|
"aria-label": e.label,
|
|
@@ -6975,11 +7186,11 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6975
7186
|
type: "button",
|
|
6976
7187
|
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${j ? "bg-primary/15 text-primary" : "text-primary hover:bg-primary/10"}`,
|
|
6977
7188
|
onClick: (e) => {
|
|
6978
|
-
e.preventDefault(),
|
|
7189
|
+
e.preventDefault(), Ae(!1), Ue?.command(X);
|
|
6979
7190
|
},
|
|
6980
|
-
title:
|
|
6981
|
-
"aria-label":
|
|
6982
|
-
children: /* @__PURE__ */ D(
|
|
7191
|
+
title: Ue?.label,
|
|
7192
|
+
"aria-label": Ue?.label,
|
|
7193
|
+
children: /* @__PURE__ */ D(zt, {})
|
|
6983
7194
|
}),
|
|
6984
7195
|
/* @__PURE__ */ D("span", {
|
|
6985
7196
|
className: "w-px h-4 bg-default-200 mx-0.5 shrink-0",
|
|
@@ -6987,27 +7198,27 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6987
7198
|
}),
|
|
6988
7199
|
/* @__PURE__ */ D("button", {
|
|
6989
7200
|
type: "button",
|
|
6990
|
-
"aria-expanded":
|
|
6991
|
-
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${
|
|
7201
|
+
"aria-expanded": ke,
|
|
7202
|
+
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${ke ? "bg-default-100 text-default-900" : "text-default-600 hover:bg-default-100"}`,
|
|
6992
7203
|
onClick: (e) => {
|
|
6993
|
-
e.preventDefault(),
|
|
7204
|
+
e.preventDefault(), Ae((e) => !e);
|
|
6994
7205
|
},
|
|
6995
7206
|
title: f("editor.bubble.more"),
|
|
6996
7207
|
"aria-label": f("editor.bubble.more"),
|
|
6997
|
-
children: /* @__PURE__ */ D(
|
|
7208
|
+
children: /* @__PURE__ */ D(Bt, {})
|
|
6998
7209
|
}),
|
|
6999
|
-
|
|
7210
|
+
ke && /* @__PURE__ */ D("div", {
|
|
7000
7211
|
role: "menu",
|
|
7001
7212
|
className: "bubble-more-menu absolute right-0 top-full z-[9999] mt-1 w-max max-h-[70vh] overflow-y-auto flex-col gap-1 rounded-xl border border-default-200 bg-background p-1.5 shadow-xl",
|
|
7002
7213
|
onPointerDown: (e) => {
|
|
7003
7214
|
e.target.closest("button") && e.preventDefault();
|
|
7004
7215
|
},
|
|
7005
|
-
children:
|
|
7216
|
+
children: Ve.map((e) => /* @__PURE__ */ O("button", {
|
|
7006
7217
|
type: "button",
|
|
7007
7218
|
role: "menuitem",
|
|
7008
|
-
className: `flex items-center gap-2 w-full whitespace-nowrap px-3 py-1.5 text-xs rounded-md transition-colors ${
|
|
7219
|
+
className: `flex items-center gap-2 w-full whitespace-nowrap px-3 py-1.5 text-xs rounded-md transition-colors ${Ge(e) ? "bg-primary/10 text-primary" : "text-default-600 hover:bg-default-100"}`,
|
|
7009
7220
|
onClick: (t) => {
|
|
7010
|
-
t.preventDefault(),
|
|
7221
|
+
t.preventDefault(), We(e);
|
|
7011
7222
|
},
|
|
7012
7223
|
title: e.label,
|
|
7013
7224
|
children: [/* @__PURE__ */ D("span", {
|
|
@@ -7022,29 +7233,29 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
7022
7233
|
]
|
|
7023
7234
|
})
|
|
7024
7235
|
}),
|
|
7025
|
-
|
|
7236
|
+
X && K !== "none" && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
7026
7237
|
className: "fixed inset-0 z-[9998]",
|
|
7027
|
-
onClick: () =>
|
|
7238
|
+
onClick: () => q("none")
|
|
7028
7239
|
}), /* @__PURE__ */ D("div", {
|
|
7029
|
-
style:
|
|
7240
|
+
style: se,
|
|
7030
7241
|
className: "bg-background border border-default-200 rounded-xl shadow-xl",
|
|
7031
7242
|
onClick: (e) => e.stopPropagation(),
|
|
7032
|
-
children:
|
|
7243
|
+
children: K === "highlight" ? /* @__PURE__ */ O("div", {
|
|
7033
7244
|
className: "flex items-center gap-1 p-1.5 flex-wrap",
|
|
7034
|
-
children: [
|
|
7245
|
+
children: [gi.map((e) => /* @__PURE__ */ D("button", {
|
|
7035
7246
|
type: "button",
|
|
7036
7247
|
className: "w-5 h-5 rounded-full border border-default-200 hover:scale-110 transition-transform",
|
|
7037
7248
|
style: { background: e.color },
|
|
7038
7249
|
title: e.name,
|
|
7039
7250
|
onClick: () => {
|
|
7040
|
-
|
|
7251
|
+
X.chain().focus().setHighlight({ color: e.color }).run(), q("none");
|
|
7041
7252
|
}
|
|
7042
7253
|
}, e.color)), /* @__PURE__ */ O("button", {
|
|
7043
7254
|
type: "button",
|
|
7044
7255
|
className: "w-5 h-5 rounded-full border border-default-200 text-default-500 hover:bg-default-100 flex items-center justify-center text-[10px]",
|
|
7045
7256
|
title: "清除高亮",
|
|
7046
7257
|
onClick: () => {
|
|
7047
|
-
|
|
7258
|
+
X.chain().focus().unsetHighlight().run(), q("none");
|
|
7048
7259
|
},
|
|
7049
7260
|
children: ["✕", " "]
|
|
7050
7261
|
})]
|
|
@@ -7054,16 +7265,16 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
7054
7265
|
type: "url",
|
|
7055
7266
|
className: "flex-1 px-2 py-1 text-xs rounded-md border border-default-200 bg-background focus:outline-none focus:border-primary",
|
|
7056
7267
|
placeholder: "https://...",
|
|
7057
|
-
value:
|
|
7058
|
-
onChange: (e) =>
|
|
7268
|
+
value: J,
|
|
7269
|
+
onChange: (e) => le(e.target.value),
|
|
7059
7270
|
onKeyDown: (e) => {
|
|
7060
|
-
e.key === "Enter" ? (
|
|
7271
|
+
e.key === "Enter" ? (J.trim() && X.chain().focus().setLink({ href: J.trim() }).run(), q("none")) : e.key === "Escape" && q("none");
|
|
7061
7272
|
}
|
|
7062
7273
|
}), /* @__PURE__ */ D("button", {
|
|
7063
7274
|
type: "button",
|
|
7064
7275
|
className: "px-2 py-1 text-xs rounded-md bg-primary text-white hover:opacity-90",
|
|
7065
7276
|
onClick: () => {
|
|
7066
|
-
|
|
7277
|
+
J.trim() && X.chain().focus().setLink({ href: J.trim() }).run(), q("none");
|
|
7067
7278
|
},
|
|
7068
7279
|
children: "确定"
|
|
7069
7280
|
})]
|
|
@@ -7082,76 +7293,76 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
7082
7293
|
className: "ai-panel__arrow",
|
|
7083
7294
|
style: { left: `${re}%` },
|
|
7084
7295
|
"aria-hidden": "true"
|
|
7085
|
-
}), /* @__PURE__ */ D(
|
|
7086
|
-
editor:
|
|
7296
|
+
}), /* @__PURE__ */ D(an, {
|
|
7297
|
+
editor: X,
|
|
7087
7298
|
onClose: () => M(!1)
|
|
7088
7299
|
})]
|
|
7089
7300
|
})] }), document.body),
|
|
7090
7301
|
B && /* @__PURE__ */ D(v, {
|
|
7091
|
-
fallback: /* @__PURE__ */ D(
|
|
7092
|
-
children: /* @__PURE__ */ D(
|
|
7302
|
+
fallback: /* @__PURE__ */ D(Oi, {}),
|
|
7303
|
+
children: /* @__PURE__ */ D(Ci, {
|
|
7093
7304
|
open: B,
|
|
7094
|
-
onClose: () =>
|
|
7095
|
-
onInsert:
|
|
7096
|
-
validate: (e) =>
|
|
7305
|
+
onClose: () => V(!1),
|
|
7306
|
+
onInsert: et,
|
|
7307
|
+
validate: (e) => X ? un(X.state.doc, e, {
|
|
7097
7308
|
maxAttachmentSize: o,
|
|
7098
7309
|
maxTotalAttachmentSize: s
|
|
7099
7310
|
}) : null
|
|
7100
7311
|
})
|
|
7101
7312
|
}),
|
|
7102
|
-
|
|
7103
|
-
fallback: /* @__PURE__ */ D(
|
|
7104
|
-
children: /* @__PURE__ */ D(
|
|
7105
|
-
open:
|
|
7106
|
-
onClose: () =>
|
|
7107
|
-
onInsert:
|
|
7313
|
+
H && /* @__PURE__ */ D(v, {
|
|
7314
|
+
fallback: /* @__PURE__ */ D(Oi, {}),
|
|
7315
|
+
children: /* @__PURE__ */ D(Ei, {
|
|
7316
|
+
open: H,
|
|
7317
|
+
onClose: () => ae(!1),
|
|
7318
|
+
onInsert: tt
|
|
7108
7319
|
})
|
|
7109
7320
|
}),
|
|
7110
|
-
|
|
7111
|
-
fallback: /* @__PURE__ */ D(
|
|
7112
|
-
children: /* @__PURE__ */ D(
|
|
7113
|
-
open:
|
|
7114
|
-
onClose: () =>
|
|
7321
|
+
oe && /* @__PURE__ */ D(v, {
|
|
7322
|
+
fallback: /* @__PURE__ */ D(Oi, {}),
|
|
7323
|
+
children: /* @__PURE__ */ D(wi, {
|
|
7324
|
+
open: oe,
|
|
7325
|
+
onClose: () => U(!1)
|
|
7115
7326
|
})
|
|
7116
7327
|
}),
|
|
7117
|
-
|
|
7118
|
-
fallback: /* @__PURE__ */ D(
|
|
7119
|
-
children: /* @__PURE__ */ D(
|
|
7120
|
-
open:
|
|
7121
|
-
onClose: () =>
|
|
7122
|
-
editor:
|
|
7328
|
+
W && /* @__PURE__ */ D(v, {
|
|
7329
|
+
fallback: /* @__PURE__ */ D(Oi, {}),
|
|
7330
|
+
children: /* @__PURE__ */ D(Ti, {
|
|
7331
|
+
open: W,
|
|
7332
|
+
onClose: () => G(!1),
|
|
7333
|
+
editor: X
|
|
7123
7334
|
})
|
|
7124
7335
|
}),
|
|
7125
|
-
|
|
7126
|
-
fallback: /* @__PURE__ */ D(
|
|
7127
|
-
children: /* @__PURE__ */ D(
|
|
7128
|
-
open: !!
|
|
7129
|
-
filename:
|
|
7336
|
+
ue && /* @__PURE__ */ D(v, {
|
|
7337
|
+
fallback: /* @__PURE__ */ D(Oi, {}),
|
|
7338
|
+
children: /* @__PURE__ */ D(Di, {
|
|
7339
|
+
open: !!ue,
|
|
7340
|
+
filename: ue.filename,
|
|
7130
7341
|
onRender: () => {
|
|
7131
|
-
|
|
7342
|
+
ue.resolve("render"), de(null);
|
|
7132
7343
|
},
|
|
7133
7344
|
onAttach: () => {
|
|
7134
|
-
|
|
7345
|
+
ue.resolve("attach"), de(null);
|
|
7135
7346
|
},
|
|
7136
7347
|
onClose: () => {
|
|
7137
|
-
|
|
7348
|
+
ue.resolve(null), de(null);
|
|
7138
7349
|
}
|
|
7139
7350
|
})
|
|
7140
7351
|
}),
|
|
7141
7352
|
/* @__PURE__ */ D("div", {
|
|
7142
|
-
ref:
|
|
7353
|
+
ref: we,
|
|
7143
7354
|
className: "flex editor-body",
|
|
7144
7355
|
children: /* @__PURE__ */ O("div", {
|
|
7145
7356
|
className: "relative min-w-0 flex-1",
|
|
7146
7357
|
children: [
|
|
7147
|
-
/* @__PURE__ */ D(P, { editor:
|
|
7148
|
-
!k && /* @__PURE__ */ D(
|
|
7358
|
+
/* @__PURE__ */ D(P, { editor: X }),
|
|
7359
|
+
!k && /* @__PURE__ */ D(hi, { editor: X }),
|
|
7149
7360
|
/* @__PURE__ */ D("div", {
|
|
7150
|
-
className: `${
|
|
7361
|
+
className: `${Y || Me ? "fixed" : "absolute"} bottom-2 right-4 z-10 pointer-events-none select-none`,
|
|
7151
7362
|
children: /* @__PURE__ */ O("span", {
|
|
7152
|
-
className: `text-xs ${
|
|
7363
|
+
className: `text-xs ${Ze ? "bg-danger/10 text-danger font-medium px-2 py-0.5 rounded" : a && Xe > a * .9 ? "bg-warning/10 text-warning px-2 py-0.5 rounded" : "text-default-300"}`,
|
|
7153
7364
|
children: [
|
|
7154
|
-
|
|
7365
|
+
Xe,
|
|
7155
7366
|
a ? ` / ${a}` : "",
|
|
7156
7367
|
" 字"
|
|
7157
7368
|
]
|
|
@@ -7160,14 +7371,14 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
7160
7371
|
]
|
|
7161
7372
|
})
|
|
7162
7373
|
}),
|
|
7163
|
-
h &&
|
|
7164
|
-
editor:
|
|
7165
|
-
onClose: () =>
|
|
7374
|
+
h && ge && /* @__PURE__ */ D(Ot, {
|
|
7375
|
+
editor: X,
|
|
7376
|
+
onClose: () => _e(!1)
|
|
7166
7377
|
}),
|
|
7167
|
-
|
|
7378
|
+
rt && /* @__PURE__ */ D("button", {
|
|
7168
7379
|
type: "button",
|
|
7169
7380
|
className: "qingwu-toc-fab",
|
|
7170
|
-
onClick: () =>
|
|
7381
|
+
onClick: () => he(!0),
|
|
7171
7382
|
title: "目录",
|
|
7172
7383
|
"aria-label": "打开目录",
|
|
7173
7384
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -7183,8 +7394,10 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
7183
7394
|
})
|
|
7184
7395
|
})
|
|
7185
7396
|
}),
|
|
7186
|
-
|
|
7397
|
+
me && ne(/* @__PURE__ */ O("div", {
|
|
7398
|
+
ref: Pe,
|
|
7187
7399
|
className: "qingwu-toc-drawer toc-scroll",
|
|
7400
|
+
"data-lenis-prevent": !0,
|
|
7188
7401
|
children: [/* @__PURE__ */ O("div", {
|
|
7189
7402
|
className: "qed-drawer-head",
|
|
7190
7403
|
children: [/* @__PURE__ */ D("span", {
|
|
@@ -7193,7 +7406,7 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
7193
7406
|
}), /* @__PURE__ */ D("button", {
|
|
7194
7407
|
type: "button",
|
|
7195
7408
|
className: "qed-drawer-head__close",
|
|
7196
|
-
onClick: () =>
|
|
7409
|
+
onClick: () => he(!1),
|
|
7197
7410
|
"aria-label": "关闭目录",
|
|
7198
7411
|
children: /* @__PURE__ */ D("svg", {
|
|
7199
7412
|
fill: "none",
|
|
@@ -7208,20 +7421,21 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
7208
7421
|
})
|
|
7209
7422
|
})
|
|
7210
7423
|
})]
|
|
7211
|
-
}), /* @__PURE__ */ D(
|
|
7212
|
-
editor:
|
|
7424
|
+
}), /* @__PURE__ */ D(ut, {
|
|
7425
|
+
editor: X,
|
|
7213
7426
|
className: "!p-3",
|
|
7214
7427
|
onClose: () => {
|
|
7215
|
-
|
|
7428
|
+
he(!1), pe(!1);
|
|
7216
7429
|
}
|
|
7217
7430
|
})]
|
|
7218
|
-
})
|
|
7431
|
+
}), document.body)
|
|
7219
7432
|
]
|
|
7220
|
-
}),
|
|
7433
|
+
}), nt && /* @__PURE__ */ D("aside", {
|
|
7221
7434
|
className: "qingwu-toc-desktop toc-scroll",
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7435
|
+
"data-lenis-prevent": !0,
|
|
7436
|
+
children: /* @__PURE__ */ D(ut, {
|
|
7437
|
+
editor: X,
|
|
7438
|
+
onClose: () => pe(!1)
|
|
7225
7439
|
})
|
|
7226
7440
|
})]
|
|
7227
7441
|
}) : /* @__PURE__ */ D("div", {
|
|
@@ -7231,7 +7445,7 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
7231
7445
|
};
|
|
7232
7446
|
//#endregion
|
|
7233
7447
|
//#region src/editor/clipper/receiver-browser.ts
|
|
7234
|
-
function
|
|
7448
|
+
function Ai(e) {
|
|
7235
7449
|
let t = async (t) => {
|
|
7236
7450
|
let n = t.data;
|
|
7237
7451
|
if (!n || typeof n != "object" || n.kind !== "qingwu-clip") return;
|
|
@@ -7248,7 +7462,7 @@ function Ei(e) {
|
|
|
7248
7462
|
}
|
|
7249
7463
|
//#endregion
|
|
7250
7464
|
//#region src/editor/storage/providers/cos.ts
|
|
7251
|
-
function
|
|
7465
|
+
function ji(e) {
|
|
7252
7466
|
return g({
|
|
7253
7467
|
endpoint: `https://cos.${e.region}.myqcloud.com`,
|
|
7254
7468
|
bucket: e.bucket,
|
|
@@ -7262,7 +7476,7 @@ function Di(e) {
|
|
|
7262
7476
|
}
|
|
7263
7477
|
//#endregion
|
|
7264
7478
|
//#region src/editor/storage/providers/oss.ts
|
|
7265
|
-
function
|
|
7479
|
+
function Mi(e) {
|
|
7266
7480
|
return g({
|
|
7267
7481
|
endpoint: `https://${e.bucket}.${e.region}.aliyuncs.com`,
|
|
7268
7482
|
bucket: e.bucket,
|
|
@@ -7275,4 +7489,4 @@ function Oi(e) {
|
|
|
7275
7489
|
});
|
|
7276
7490
|
}
|
|
7277
7491
|
//#endregion
|
|
7278
|
-
export { $n as CODE_LANGUAGES,
|
|
7492
|
+
export { $n as CODE_LANGUAGES, ar as CodeBlock, kr as ImageUpload, et as ImageUploadDialog, ki as QingWuAIEditor, ei as RelativeMedia, Et as SearchHighlight, ut as TocPanel, Kn as VideoEmbed, dt as buildSystemPrompt, pt as createAILanguageModelProvider, ji as createCOSStorage, _t as createDeepSeekProvider, _ as createLocalStorage, Mi as createOSSStorage, gt as createOpenAICompatProvider, vt as createOpenAIProvider, yt as createQwenProvider, g as createS3Storage, ni as createSlashCommandExtension, h as escapeHtml, cn as formatBytes, ht as getAIProvider, li as getBubbleMenuActions, ri as getDefaultSlashCommands, sn as getDocAttachmentTotal, ai as getEditorExtensions, u as getLocale, ci as getSearchEngine, Dt as getSearchState, c as getStorageInfo, o as getStorageProvider, s as loadStorageConfig, r as registerS3PreviewConfig, d as sanitizeHtml, p as sanitizeSvg, mt as setAIProvider, gn as setConfirmProvider, l as setLocale, si as setSearchEngine, i as setStorageProvider, Ze as setToastProvider, n as signPreviewUrlHeaders, Ai as startBrowserClipperReceiver, Qe as subscribeToast, f as t, m as tf, Z as toast, un as validateAttachmentFile };
|