@qingwu-ui/ai-editor 0.9.0-beta.13 → 0.9.0-beta.14
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 +2 -1
- package/dist/components/toc.d.ts.map +1 -1
- package/dist/editor/ai-editor.d.ts.map +1 -1
- package/dist/index.cjs +10 -10
- package/dist/index.js +1035 -982
- 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
|
|
10
|
-
import { BubbleMenu as
|
|
11
|
-
import { createPortal as
|
|
12
|
-
import { Extension as
|
|
13
|
-
import { NodeSelection 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
|
|
9
|
+
import { EditorContent as P, NodeViewContent as F, NodeViewWrapper as I, ReactNodeViewRenderer as L, useEditor as ee } from "@tiptap/react";
|
|
10
|
+
import { BubbleMenu as te } from "@tiptap/react/menus";
|
|
11
|
+
import { createPortal as ne } from "react-dom";
|
|
12
|
+
import { Extension as R, Node as re } from "@tiptap/core";
|
|
13
|
+
import { NodeSelection as ie, Plugin as z, PluginKey as B, TextSelection as ae } from "@tiptap/pm/state";
|
|
14
|
+
import { Decoration as oe, DecorationSet as se } from "@tiptap/pm/view";
|
|
15
|
+
import { Image as ce } from "@tiptap/extension-image";
|
|
16
|
+
import { Link as V } from "@tiptap/extension-link";
|
|
17
|
+
import { Underline as H } from "@tiptap/extension-underline";
|
|
18
|
+
import le from "@tiptap/starter-kit";
|
|
19
|
+
import { CharacterCount as U } from "@tiptap/extension-character-count";
|
|
20
|
+
import { Color as W } from "@tiptap/extension-color";
|
|
21
|
+
import { Highlight as ue } from "@tiptap/extension-highlight";
|
|
22
|
+
import { HorizontalRule as de } from "@tiptap/extension-horizontal-rule";
|
|
23
|
+
import { Placeholder as G } from "@tiptap/extension-placeholder";
|
|
24
|
+
import { Table as fe } from "@tiptap/extension-table";
|
|
25
|
+
import { TableCell as pe } from "@tiptap/extension-table-cell";
|
|
26
|
+
import { TableHeader as me } from "@tiptap/extension-table-header";
|
|
27
|
+
import { TableRow as K } from "@tiptap/extension-table-row";
|
|
28
|
+
import { TaskItem as he } from "@tiptap/extension-task-item";
|
|
29
|
+
import { TaskList as ge } from "@tiptap/extension-task-list";
|
|
30
|
+
import { TextStyle as _e } from "@tiptap/extension-text-style";
|
|
31
|
+
import { Markdown as ve } from "tiptap-markdown";
|
|
32
|
+
import { CodeBlockLowlight as ye } from "@tiptap/extension-code-block-lowlight";
|
|
33
|
+
import be from "highlight.js/lib/languages/dockerfile";
|
|
34
|
+
import { common as xe, createLowlight as Se } from "lowlight";
|
|
35
|
+
import Ce, { findSuggestionMatch as we } 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 Te = null, Ee = null;
|
|
38
|
+
function De() {
|
|
39
|
+
return Ee || (typeof document > "u" ? null : (Te = document.createElement("canvas"), Ee = Te.getContext("2d"), Ee));
|
|
40
|
+
}
|
|
41
|
+
var Oe = /* @__PURE__ */ new Map();
|
|
42
|
+
function ke(e, t) {
|
|
43
|
+
let n = Oe.get(t);
|
|
44
|
+
n || (n = /* @__PURE__ */ new Map(), Oe.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 = De();
|
|
48
|
+
return i ? (i.font = t, r = i.measureText(e).width) : r = Ae(e, t), n.set(e, r), r;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Ae(e, t) {
|
|
51
51
|
let n = parseFloat(t) || 16, r = 0;
|
|
52
|
-
for (let t of e)
|
|
52
|
+
for (let t of e) je(t.codePointAt(0) ?? 0) ? r += n : t === " " ? r += n * .3 : r += n * .55;
|
|
53
53
|
return r;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function je(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 Me(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 q(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 K(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" : je(r) && (i = Me(r) ? "punct" : "cjk"), n.push({
|
|
73
73
|
text: e,
|
|
74
|
-
width:
|
|
74
|
+
width: ke(e, t),
|
|
75
75
|
type: i
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
return n;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function Ne(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 J(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
|
-
function
|
|
92
|
-
let { maxWidth: r, lineHeight: i, maxLines: a, overflowWrap: o = "break-word" } = t, s =
|
|
91
|
+
function Pe(e, t, n = "16px system-ui") {
|
|
92
|
+
let { maxWidth: r, lineHeight: i, maxLines: a, overflowWrap: o = "break-word" } = t, s = q(e, n), c = [], l = {
|
|
93
93
|
lineStart: 0,
|
|
94
94
|
lineWidth: 0,
|
|
95
95
|
lastBreakIdx: -1,
|
|
@@ -98,28 +98,28 @@ function Fe(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(J(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(J(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Ne(s, l.lineStart, e + 1)) : (c.push(J(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(J(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(J(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Ne(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(J(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Ne(s, l.lineStart, e + 1), l.lastBreakIdx = -1) : o === "break-word" ? (c.push(J(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 = Ne(s, l.lineStart, s.length);
|
|
122
|
+
c.push(J(s, l.lineStart, s.length, e));
|
|
123
123
|
}
|
|
124
124
|
return {
|
|
125
125
|
lines: c,
|
|
@@ -130,36 +130,36 @@ function Fe(e, t, n = "16px system-ui") {
|
|
|
130
130
|
}
|
|
131
131
|
//#endregion
|
|
132
132
|
//#region ../toast/dist/index.mjs
|
|
133
|
-
var
|
|
134
|
-
function
|
|
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 Y() {
|
|
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;
|
|
138
138
|
}
|
|
139
|
-
var
|
|
139
|
+
var Le = {
|
|
140
140
|
info: "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"12\" y1=\"16\" x2=\"12\" y2=\"12\"/><line x1=\"12\" y1=\"8\" x2=\"12.01\" y2=\"8\"/></svg>",
|
|
141
141
|
success: "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"M9 12l2 2 4-4\"/></svg>",
|
|
142
142
|
warning: "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z\"/><line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\"/><line x1=\"12\" y1=\"17\" x2=\"12.01\" y2=\"17\"/></svg>",
|
|
143
143
|
error: "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"15\" y1=\"9\" x2=\"9\" y2=\"15\"/><line x1=\"9\" y1=\"9\" x2=\"15\" y2=\"15\"/></svg>"
|
|
144
|
-
},
|
|
145
|
-
function
|
|
146
|
-
return `qt${
|
|
144
|
+
}, Re = 1;
|
|
145
|
+
function ze() {
|
|
146
|
+
return `qt${Re++}${Date.now().toString(36)}`;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function X(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 Be(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 = X("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 Ve = {
|
|
163
163
|
type: "info",
|
|
164
164
|
position: "top-center",
|
|
165
165
|
duration: 4e3,
|
|
@@ -168,19 +168,19 @@ var He = {
|
|
|
168
168
|
persistMaxVisible: 3,
|
|
169
169
|
maxLines: void 0,
|
|
170
170
|
vibrate: !0
|
|
171
|
-
},
|
|
171
|
+
}, He = [
|
|
172
172
|
80,
|
|
173
173
|
40,
|
|
174
174
|
80
|
|
175
175
|
];
|
|
176
|
-
function
|
|
176
|
+
function Ue() {
|
|
177
177
|
if (!(typeof navigator > "u" || !("vibrate" in navigator))) try {
|
|
178
|
-
navigator.vibrate(
|
|
178
|
+
navigator.vibrate(He);
|
|
179
179
|
} catch {}
|
|
180
180
|
}
|
|
181
|
-
var
|
|
181
|
+
var We = class {
|
|
182
182
|
containers = /* @__PURE__ */ new Map();
|
|
183
|
-
opts = { ...
|
|
183
|
+
opts = { ...Ve };
|
|
184
184
|
toasts = /* @__PURE__ */ new Map();
|
|
185
185
|
queue = [];
|
|
186
186
|
_seq = 0;
|
|
@@ -189,10 +189,10 @@ var Ge = class {
|
|
|
189
189
|
}
|
|
190
190
|
ensureContainer(e) {
|
|
191
191
|
let t = this.containers.get(e);
|
|
192
|
-
return t || (t =
|
|
192
|
+
return t || (t = X("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
|
-
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 =
|
|
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 = {
|
|
196
196
|
id: l,
|
|
197
197
|
type: n,
|
|
198
198
|
dismissible: a,
|
|
@@ -275,30 +275,30 @@ var Ge = class {
|
|
|
275
275
|
this.containers.clear();
|
|
276
276
|
}
|
|
277
277
|
buildElement(e, t, n, r, i, a, o) {
|
|
278
|
-
let s =
|
|
278
|
+
let s = X("div", `qt-toast qt-${n}${i == null ? "" : " qt-truncate"}${a || o ? " qt-rich" : ""}`);
|
|
279
279
|
s.setAttribute("data-qt-id", e);
|
|
280
|
-
let c =
|
|
281
|
-
c.innerHTML =
|
|
282
|
-
let l =
|
|
283
|
-
maxWidth:
|
|
280
|
+
let c = X("span", "qt-icon");
|
|
281
|
+
c.innerHTML = Le[n], s.appendChild(c);
|
|
282
|
+
let l = X("div", "qt-body"), u = X("span", "qt-msg"), d = Pe(t, {
|
|
283
|
+
maxWidth: Y(),
|
|
284
284
|
lineHeight: 1,
|
|
285
285
|
maxLines: i
|
|
286
|
-
},
|
|
287
|
-
if (d.lineCount <= 1 ?
|
|
288
|
-
let n =
|
|
289
|
-
t === d.lines.length - 1 && d.truncated && !r.endsWith("…") && (r += "…"),
|
|
286
|
+
}, Ie);
|
|
287
|
+
if (d.lineCount <= 1 ? Be(u, t) : d.lines.forEach((e, t) => {
|
|
288
|
+
let n = X("span", "qt-line"), r = e.text;
|
|
289
|
+
t === d.lines.length - 1 && d.truncated && !r.endsWith("…") && (r += "…"), Be(n, r), u.appendChild(n);
|
|
290
290
|
}), l.appendChild(u), a) {
|
|
291
|
-
let e =
|
|
291
|
+
let e = X("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 = X("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 = X("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 Ge = 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 && Ue(), requestAnimationFrame(() => {
|
|
314
314
|
requestAnimationFrame(() => {
|
|
315
315
|
e.element.classList.add("qt-enter");
|
|
316
316
|
});
|
|
@@ -332,7 +332,7 @@ var Ge = class {
|
|
|
332
332
|
let t = () => {
|
|
333
333
|
e.element.remove(), this.toasts.delete(e.id), this._dequeue();
|
|
334
334
|
};
|
|
335
|
-
if (
|
|
335
|
+
if (Fe) t();
|
|
336
336
|
else {
|
|
337
337
|
let n = !1, r = () => {
|
|
338
338
|
n || (n = !0, t());
|
|
@@ -345,46 +345,46 @@ var Ge = 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
|
-
|
|
364
|
-
}
|
|
365
|
-
function
|
|
348
|
+
}, Ge = null;
|
|
349
|
+
function Ke() {
|
|
350
|
+
return Ge ||= new We(), Ge;
|
|
351
|
+
}
|
|
352
|
+
var qe = Object.assign((e, t) => Ke().show(e, t), {
|
|
353
|
+
info: (e, t) => Ke().info(e, t),
|
|
354
|
+
success: (e, t) => Ke().success(e, t),
|
|
355
|
+
warn: (e, t) => Ke().warn(e, t),
|
|
356
|
+
error: (e, t) => Ke().error(e, t),
|
|
357
|
+
promise: (e, t, n) => Ke().promise(e, t, n),
|
|
358
|
+
dismiss: (e) => Ke().dismiss(e),
|
|
359
|
+
dismissAll: () => Ke().dismissAll(),
|
|
360
|
+
configure: (e) => Ke().configure(e)
|
|
361
|
+
}), Je = /* @__PURE__ */ new Set(), Ye = null;
|
|
362
|
+
function Xe(e) {
|
|
363
|
+
Ye = e;
|
|
364
|
+
}
|
|
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 (Je.size > 0) {
|
|
371
|
+
for (let n of Je) n(e, t, r);
|
|
372
372
|
return;
|
|
373
373
|
}
|
|
374
|
-
if (
|
|
375
|
-
|
|
374
|
+
if (Ye) {
|
|
375
|
+
Ye(e, t, r);
|
|
376
376
|
return;
|
|
377
377
|
}
|
|
378
|
-
t === "success" ?
|
|
378
|
+
t === "success" ? qe.success(e, r) : t === "info" ? qe.info(e, r) : qe.error(e, r);
|
|
379
379
|
}
|
|
380
|
-
function
|
|
381
|
-
return
|
|
382
|
-
|
|
380
|
+
function Ze(e) {
|
|
381
|
+
return Je.add(e), () => {
|
|
382
|
+
Je.delete(e);
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
385
|
//#endregion
|
|
386
386
|
//#region src/components/image-upload-dialog.tsx
|
|
387
|
-
var
|
|
387
|
+
var Qe = /* @__PURE__ */ e({ ImageUploadDialog: () => $e }), $e = ({ 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();
|
|
@@ -419,7 +419,7 @@ var $e = /* @__PURE__ */ e({ ImageUploadDialog: () => et }), et = ({ open: e, on
|
|
|
419
419
|
}
|
|
420
420
|
let n = r ? r(e) : e.size > 20 * 1024 * 1024 ? "图片大小不能超过 20MB" : null;
|
|
421
421
|
if (n) {
|
|
422
|
-
f(n),
|
|
422
|
+
f(n), Z(n);
|
|
423
423
|
return;
|
|
424
424
|
}
|
|
425
425
|
u(!0), f(null);
|
|
@@ -676,10 +676,10 @@ var $e = /* @__PURE__ */ e({ ImageUploadDialog: () => et }), et = ({ open: e, on
|
|
|
676
676
|
};
|
|
677
677
|
//#endregion
|
|
678
678
|
//#region src/components/toc.tsx
|
|
679
|
-
function
|
|
679
|
+
function et(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 tt(e) {
|
|
683
683
|
let t = [], n = [];
|
|
684
684
|
for (let r of e) {
|
|
685
685
|
let e = {
|
|
@@ -691,18 +691,18 @@ function nt(e) {
|
|
|
691
691
|
}
|
|
692
692
|
return t;
|
|
693
693
|
}
|
|
694
|
-
function
|
|
694
|
+
function nt(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 rt(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(...rt(r.children, t));
|
|
703
703
|
return n;
|
|
704
704
|
}
|
|
705
|
-
function
|
|
705
|
+
function it(e, t) {
|
|
706
706
|
let n = t.toLowerCase(), r = (e) => {
|
|
707
707
|
let t = [];
|
|
708
708
|
for (let i of e) {
|
|
@@ -716,7 +716,7 @@ function at(e, t) {
|
|
|
716
716
|
};
|
|
717
717
|
return r(e);
|
|
718
718
|
}
|
|
719
|
-
function
|
|
719
|
+
function at(e) {
|
|
720
720
|
let t = e.parentElement;
|
|
721
721
|
for (; t && t !== document.documentElement;) {
|
|
722
722
|
let e = getComputedStyle(t).overflowY;
|
|
@@ -725,7 +725,7 @@ function ot(e) {
|
|
|
725
725
|
}
|
|
726
726
|
return null;
|
|
727
727
|
}
|
|
728
|
-
function
|
|
728
|
+
function ot(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,45 +738,69 @@ function st(e, t) {
|
|
|
738
738
|
}
|
|
739
739
|
return a < e.length && i.push(e.slice(a)), i.length ? i : e;
|
|
740
740
|
}
|
|
741
|
-
var ct = ({ editor: e, className: t = "", onClose: n }) => {
|
|
742
|
-
let [r, i] = T([]), [a, o] = T(""), [s, c] = T(/* @__PURE__ */ new Set()), [l, u] = T(""), d = w(
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
let
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
741
|
+
var st = 84, ct = 3e3, lt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
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
|
+
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 ||= et(e.textContent || "", t), {
|
|
745
|
+
id: e.id,
|
|
746
|
+
level: Number(e.tagName.slice(1)),
|
|
747
|
+
text: e.textContent?.trim() || "(无标题)",
|
|
748
|
+
el: e
|
|
749
|
+
})), [e]), y = b(() => {
|
|
750
|
+
let e = f.current;
|
|
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) + st, r = t ? t.scrollHeight - t.scrollTop - t.clientHeight < 2 : document.documentElement.scrollHeight - window.scrollY - window.innerHeight < 2, i = "";
|
|
753
|
+
for (let t of e) t.el.isConnected && t.el.getBoundingClientRect().top <= n && (i = t.id);
|
|
754
|
+
if (r) {
|
|
755
|
+
for (let t = e.length - 1; t >= 0; t--) if (e[t].el.isConnected) {
|
|
756
|
+
i = e[t].id;
|
|
757
|
+
break;
|
|
754
758
|
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
759
|
+
}
|
|
760
|
+
let a = h.current;
|
|
761
|
+
if (a) {
|
|
762
|
+
let t = e.find((e) => e.id === a.id);
|
|
763
|
+
if (!(!t || !t.el.isConnected || r || t.el.getBoundingClientRect().top <= n)) return;
|
|
764
|
+
_();
|
|
765
|
+
}
|
|
766
|
+
o(i);
|
|
767
|
+
}, [v, _]), S = b(() => {
|
|
768
|
+
g.current ||= requestAnimationFrame(() => {
|
|
769
|
+
g.current = 0, y();
|
|
763
770
|
});
|
|
764
|
-
|
|
765
|
-
|
|
771
|
+
}, [y]), E = b(() => {
|
|
772
|
+
let e = v(), t = e.map((e) => `${e.level}:${e.text}`).join("|");
|
|
773
|
+
t !== d.current && (d.current = t, f.current = e, i(e), S());
|
|
774
|
+
}, [v, S]);
|
|
766
775
|
x(() => {
|
|
776
|
+
let t = at(e.view.dom);
|
|
777
|
+
m.current = t;
|
|
778
|
+
let n = t ?? window;
|
|
779
|
+
return n.addEventListener("scroll", S, { passive: !0 }), window.addEventListener("resize", S), n.addEventListener("wheel", _, { passive: !0 }), n.addEventListener("touchstart", _, { passive: !0 }), () => {
|
|
780
|
+
n.removeEventListener("scroll", S), window.removeEventListener("resize", S), n.removeEventListener("wheel", _), n.removeEventListener("touchstart", _);
|
|
781
|
+
};
|
|
782
|
+
}, [
|
|
783
|
+
e,
|
|
784
|
+
S,
|
|
785
|
+
_
|
|
786
|
+
]), x(() => {
|
|
767
787
|
let t = null, n = () => {
|
|
768
788
|
let n = [];
|
|
769
789
|
e.state.doc.descendants((e) => {
|
|
770
790
|
e.type.name === "heading" && n.push(`${e.attrs.level}:${e.textContent}`);
|
|
771
|
-
}), n.join("|") !==
|
|
791
|
+
}), n.join("|") !== d.current && (t && clearTimeout(t), t = setTimeout(E, 300));
|
|
772
792
|
};
|
|
773
793
|
e.on("update", n);
|
|
774
|
-
let r = requestAnimationFrame(
|
|
794
|
+
let r = requestAnimationFrame(E);
|
|
775
795
|
return () => {
|
|
776
|
-
e.off("update", n), t && clearTimeout(t), cancelAnimationFrame(r),
|
|
796
|
+
e.off("update", n), t && clearTimeout(t), cancelAnimationFrame(r), _(), g.current &&= (cancelAnimationFrame(g.current), 0);
|
|
777
797
|
};
|
|
778
|
-
}, [
|
|
779
|
-
|
|
798
|
+
}, [
|
|
799
|
+
e,
|
|
800
|
+
E,
|
|
801
|
+
_
|
|
802
|
+
]);
|
|
803
|
+
let k = b((t) => {
|
|
780
804
|
let n = t.el;
|
|
781
805
|
if ((!n || !e.view.dom.contains(n)) && (n = e.view.dom.querySelector(`[id="${CSS.escape(t.id)}"]`)), !n) {
|
|
782
806
|
let r = `h${t.level}`, i = e.view.dom.querySelectorAll(r);
|
|
@@ -785,29 +809,57 @@ var ct = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
785
809
|
break;
|
|
786
810
|
}
|
|
787
811
|
}
|
|
788
|
-
n && (
|
|
812
|
+
n && (_(), h.current = {
|
|
813
|
+
id: t.id,
|
|
814
|
+
timer: setTimeout(_, ct)
|
|
815
|
+
}, o(t.id), n.scrollIntoView({
|
|
789
816
|
behavior: "smooth",
|
|
790
817
|
block: "start"
|
|
791
|
-
})
|
|
792
|
-
}, [e]),
|
|
793
|
-
|
|
794
|
-
|
|
818
|
+
}));
|
|
819
|
+
}, [e, _]), A = C(() => tt(r), [r]), j = C(() => nt(A), [A]), M = C(() => {
|
|
820
|
+
let e = /* @__PURE__ */ new Map(), t = (n, r) => {
|
|
821
|
+
for (let i of n) r && e.set(i.id, r), t(i.children, i.id);
|
|
822
|
+
};
|
|
823
|
+
return t(A, ""), e;
|
|
824
|
+
}, [A]), N = l.trim().length > 0, P = C(() => N ? it(A, l.trim()) : A, [
|
|
825
|
+
A,
|
|
826
|
+
N,
|
|
795
827
|
l
|
|
796
|
-
]),
|
|
797
|
-
|
|
828
|
+
]), F = C(() => rt(P, N ? /* @__PURE__ */ new Set() : s), [
|
|
829
|
+
P,
|
|
798
830
|
s,
|
|
799
|
-
|
|
800
|
-
]),
|
|
831
|
+
N
|
|
832
|
+
]), I = C(() => new Set(F.map((e) => e.id)), [F]), L = C(() => {
|
|
833
|
+
let e = a;
|
|
834
|
+
for (; e && !I.has(e);) e = M.get(e) ?? "";
|
|
835
|
+
return e;
|
|
836
|
+
}, [
|
|
837
|
+
a,
|
|
838
|
+
I,
|
|
839
|
+
M
|
|
840
|
+
]);
|
|
841
|
+
x(() => {
|
|
842
|
+
let e = p.current;
|
|
843
|
+
if (!e || !L) return;
|
|
844
|
+
let t = e.closest(".toc-scroll");
|
|
845
|
+
if (!(t instanceof HTMLElement)) return;
|
|
846
|
+
let n = e.querySelector(`[data-toc-id="${CSS.escape(L)}"]`);
|
|
847
|
+
if (!n) return;
|
|
848
|
+
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect();
|
|
849
|
+
i.top < r.top + 8 ? t.scrollTop -= r.top + 8 - i.top : i.bottom > r.bottom - 8 && (t.scrollTop += i.bottom - (r.bottom - 8));
|
|
850
|
+
}, [L]);
|
|
851
|
+
let ee = b((e) => {
|
|
801
852
|
c((t) => {
|
|
802
853
|
let n = new Set(t);
|
|
803
854
|
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
804
855
|
});
|
|
805
|
-
}, []),
|
|
806
|
-
c(new Set(
|
|
807
|
-
}, [
|
|
856
|
+
}, []), te = b(() => {
|
|
857
|
+
c(new Set(j));
|
|
858
|
+
}, [j]), ne = b(() => {
|
|
808
859
|
c(/* @__PURE__ */ new Set());
|
|
809
860
|
}, []);
|
|
810
861
|
return r.length ? /* @__PURE__ */ O("nav", {
|
|
862
|
+
ref: p,
|
|
811
863
|
className: `toc-panel ${t}`,
|
|
812
864
|
"aria-label": "目录",
|
|
813
865
|
children: [
|
|
@@ -874,10 +926,10 @@ var ct = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
874
926
|
children: [/* @__PURE__ */ D("button", {
|
|
875
927
|
type: "button",
|
|
876
928
|
className: "toc-action-btn",
|
|
877
|
-
onClick:
|
|
929
|
+
onClick: te,
|
|
878
930
|
title: "全部折叠",
|
|
879
931
|
"aria-label": "全部折叠",
|
|
880
|
-
disabled:
|
|
932
|
+
disabled: N,
|
|
881
933
|
children: /* @__PURE__ */ D("svg", {
|
|
882
934
|
width: "14",
|
|
883
935
|
height: "14",
|
|
@@ -895,10 +947,10 @@ var ct = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
895
947
|
}), /* @__PURE__ */ D("button", {
|
|
896
948
|
type: "button",
|
|
897
949
|
className: "toc-action-btn",
|
|
898
|
-
onClick:
|
|
950
|
+
onClick: ne,
|
|
899
951
|
title: "全部展开",
|
|
900
952
|
"aria-label": "全部展开",
|
|
901
|
-
disabled:
|
|
953
|
+
disabled: N,
|
|
902
954
|
children: /* @__PURE__ */ D("svg", {
|
|
903
955
|
width: "14",
|
|
904
956
|
height: "14",
|
|
@@ -966,21 +1018,22 @@ var ct = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
966
1018
|
})
|
|
967
1019
|
]
|
|
968
1020
|
}),
|
|
969
|
-
|
|
1021
|
+
F.length === 0 ? /* @__PURE__ */ D("div", {
|
|
970
1022
|
className: "toc-search__empty",
|
|
971
|
-
children:
|
|
1023
|
+
children: N ? `未找到"${l.trim()}"相关标题` : "文档暂无标题"
|
|
972
1024
|
}) : /* @__PURE__ */ D("ul", {
|
|
973
1025
|
className: "toc-list",
|
|
974
|
-
children:
|
|
975
|
-
let t =
|
|
1026
|
+
children: F.map((e) => {
|
|
1027
|
+
let t = j.has(e.id), n = s.has(e.id);
|
|
976
1028
|
return /* @__PURE__ */ O("li", {
|
|
977
|
-
|
|
1029
|
+
"data-toc-id": e.id,
|
|
1030
|
+
className: `toc-item ${L === e.id ? "is-active" : ""}`,
|
|
978
1031
|
style: { paddingLeft: `${(e.level - 1) * 12 + 12}px` },
|
|
979
1032
|
children: [t ? /* @__PURE__ */ D("button", {
|
|
980
1033
|
type: "button",
|
|
981
1034
|
className: `toc-toggle ${n ? "is-collapsed" : "is-expanded"}`,
|
|
982
1035
|
onClick: (t) => {
|
|
983
|
-
t.stopPropagation(),
|
|
1036
|
+
t.stopPropagation(), ee(e.id);
|
|
984
1037
|
},
|
|
985
1038
|
title: n ? "展开子标题" : "折叠子标题",
|
|
986
1039
|
"aria-label": n ? "展开子标题" : "折叠子标题",
|
|
@@ -999,11 +1052,11 @@ var ct = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
999
1052
|
}), /* @__PURE__ */ D("button", {
|
|
1000
1053
|
type: "button",
|
|
1001
1054
|
className: "toc-link",
|
|
1002
|
-
onClick: () =>
|
|
1055
|
+
onClick: () => k(e),
|
|
1003
1056
|
title: e.text,
|
|
1004
1057
|
children: /* @__PURE__ */ D("span", {
|
|
1005
1058
|
className: "toc-text",
|
|
1006
|
-
children:
|
|
1059
|
+
children: N ? ot(e.text, l.trim()) : e.text
|
|
1007
1060
|
})
|
|
1008
1061
|
})]
|
|
1009
1062
|
}, e.id);
|
|
@@ -1027,7 +1080,7 @@ var ct = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1027
1080
|
};
|
|
1028
1081
|
//#endregion
|
|
1029
1082
|
//#region src/editor/ai/index.ts
|
|
1030
|
-
function
|
|
1083
|
+
function ut(e, t) {
|
|
1031
1084
|
return {
|
|
1032
1085
|
continue: "你是一个写作助手。请从下文尾部自然流畅地续写内容,保持风格一致。只输出续写的内容,不要加任何前缀说明。",
|
|
1033
1086
|
improve: "你是一个文字润色专家。请优化以下文本的表达,提升文采和流畅度,保持原意不变。只输出润色后的文本。",
|
|
@@ -1038,8 +1091,8 @@ function lt(e, t) {
|
|
|
1038
1091
|
zap: t || "你是一个全能的 AI 写作助手。请根据用户的指令处理文本。"
|
|
1039
1092
|
}[e];
|
|
1040
1093
|
}
|
|
1041
|
-
var
|
|
1042
|
-
async function
|
|
1094
|
+
var dt = null;
|
|
1095
|
+
async function ft(e) {
|
|
1043
1096
|
let t;
|
|
1044
1097
|
try {
|
|
1045
1098
|
({createOpenAI: t} = await import("@ai-sdk/openai"));
|
|
@@ -1054,7 +1107,7 @@ async function dt(e) {
|
|
|
1054
1107
|
async *stream(e) {
|
|
1055
1108
|
let t = await A({
|
|
1056
1109
|
model: n,
|
|
1057
|
-
system:
|
|
1110
|
+
system: ut(e.mode, e.instruction),
|
|
1058
1111
|
prompt: e.context,
|
|
1059
1112
|
temperature: .7,
|
|
1060
1113
|
maxOutputTokens: 2048
|
|
@@ -1064,7 +1117,7 @@ async function dt(e) {
|
|
|
1064
1117
|
async generate(e) {
|
|
1065
1118
|
return (await k({
|
|
1066
1119
|
model: n,
|
|
1067
|
-
system:
|
|
1120
|
+
system: ut(e.mode, e.instruction),
|
|
1068
1121
|
prompt: e.context,
|
|
1069
1122
|
temperature: .7,
|
|
1070
1123
|
maxOutputTokens: 2048
|
|
@@ -1072,16 +1125,16 @@ async function dt(e) {
|
|
|
1072
1125
|
}
|
|
1073
1126
|
};
|
|
1074
1127
|
}
|
|
1075
|
-
function
|
|
1076
|
-
|
|
1128
|
+
function pt(e) {
|
|
1129
|
+
dt = e;
|
|
1077
1130
|
}
|
|
1078
|
-
function
|
|
1079
|
-
if (!
|
|
1080
|
-
return
|
|
1131
|
+
function mt() {
|
|
1132
|
+
if (!dt) throw Error("未配置 AI 服务。请调用 createAILanguageModelProvider() 创建并通过 setAIProvider() 注册。");
|
|
1133
|
+
return dt;
|
|
1081
1134
|
}
|
|
1082
1135
|
//#endregion
|
|
1083
1136
|
//#region src/editor/ai/providers/openai-compat.ts
|
|
1084
|
-
function
|
|
1137
|
+
function ht(e) {
|
|
1085
1138
|
let { apiKey: t, baseURL: n, model: r, headers: i } = e;
|
|
1086
1139
|
async function* a(e, a) {
|
|
1087
1140
|
let o = await fetch(`${n}/chat/completions`, {
|
|
@@ -1132,10 +1185,10 @@ function mt(e) {
|
|
|
1132
1185
|
}
|
|
1133
1186
|
return {
|
|
1134
1187
|
async *stream(e) {
|
|
1135
|
-
yield* a(
|
|
1188
|
+
yield* a(ut(e.mode, e.instruction), e.context);
|
|
1136
1189
|
},
|
|
1137
1190
|
async generate(e) {
|
|
1138
|
-
let t =
|
|
1191
|
+
let t = ut(e.mode, e.instruction), n = "";
|
|
1139
1192
|
for await (let r of a(t, e.context)) n += r;
|
|
1140
1193
|
return n;
|
|
1141
1194
|
}
|
|
@@ -1143,8 +1196,8 @@ function mt(e) {
|
|
|
1143
1196
|
}
|
|
1144
1197
|
//#endregion
|
|
1145
1198
|
//#region src/editor/ai/providers/deepseek.ts
|
|
1146
|
-
function
|
|
1147
|
-
return
|
|
1199
|
+
function gt(e) {
|
|
1200
|
+
return ht({
|
|
1148
1201
|
apiKey: e.apiKey,
|
|
1149
1202
|
baseURL: e.baseURL || "https://api.deepseek.com/v1",
|
|
1150
1203
|
model: e.model || "deepseek-v4-flash",
|
|
@@ -1153,8 +1206,8 @@ function ht(e) {
|
|
|
1153
1206
|
}
|
|
1154
1207
|
//#endregion
|
|
1155
1208
|
//#region src/editor/ai/providers/openai.ts
|
|
1156
|
-
function
|
|
1157
|
-
return
|
|
1209
|
+
function _t(e) {
|
|
1210
|
+
return ht({
|
|
1158
1211
|
apiKey: e.apiKey,
|
|
1159
1212
|
baseURL: e.baseURL || "https://api.openai.com/v1",
|
|
1160
1213
|
model: e.model || "gpt-5.6-luna",
|
|
@@ -1163,8 +1216,8 @@ function gt(e) {
|
|
|
1163
1216
|
}
|
|
1164
1217
|
//#endregion
|
|
1165
1218
|
//#region src/editor/ai/providers/qwen.ts
|
|
1166
|
-
function
|
|
1167
|
-
return
|
|
1219
|
+
function vt(e) {
|
|
1220
|
+
return ht({
|
|
1168
1221
|
apiKey: e.apiKey,
|
|
1169
1222
|
baseURL: e.baseURL || "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
1170
1223
|
model: e.model || "qwen3.7-plus",
|
|
@@ -1173,20 +1226,20 @@ function _t(e) {
|
|
|
1173
1226
|
}
|
|
1174
1227
|
//#endregion
|
|
1175
1228
|
//#region src/editor/extensions/search-highlight.ts
|
|
1176
|
-
var
|
|
1229
|
+
var yt = {
|
|
1177
1230
|
keyword: "",
|
|
1178
1231
|
caseSensitive: !1,
|
|
1179
1232
|
wholeWord: !1,
|
|
1180
1233
|
matches: [],
|
|
1181
1234
|
currentIndex: -1
|
|
1182
|
-
},
|
|
1183
|
-
function
|
|
1235
|
+
}, bt = new B("search-highlight");
|
|
1236
|
+
function xt(e) {
|
|
1184
1237
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1185
1238
|
}
|
|
1186
|
-
function
|
|
1239
|
+
function St(e, t) {
|
|
1187
1240
|
let { keyword: n, caseSensitive: r, wholeWord: i } = t;
|
|
1188
1241
|
if (!n) return [];
|
|
1189
|
-
let a = r ? "g" : "gi", o = i ? `\\b${
|
|
1242
|
+
let a = r ? "g" : "gi", o = i ? `\\b${xt(n)}\\b` : xt(n), s = new RegExp(o, a), c = [];
|
|
1190
1243
|
return e.descendants((e, t) => {
|
|
1191
1244
|
if (!e.isText || !e.text) return;
|
|
1192
1245
|
s.lastIndex = 0;
|
|
@@ -1200,12 +1253,12 @@ function bt(e, t) {
|
|
|
1200
1253
|
}
|
|
1201
1254
|
}), c;
|
|
1202
1255
|
}
|
|
1203
|
-
function
|
|
1204
|
-
if (t.matches.length === 0) return
|
|
1205
|
-
let n = t.matches.map((e, n) =>
|
|
1206
|
-
return
|
|
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);
|
|
1207
1260
|
}
|
|
1208
|
-
function
|
|
1261
|
+
function wt(e, t) {
|
|
1209
1262
|
if (t.currentIndex < 0 || t.currentIndex >= t.matches.length) return;
|
|
1210
1263
|
let n = t.matches[t.currentIndex];
|
|
1211
1264
|
n && requestAnimationFrame(() => {
|
|
@@ -1230,15 +1283,15 @@ function St(e, t) {
|
|
|
1230
1283
|
} catch {}
|
|
1231
1284
|
});
|
|
1232
1285
|
}
|
|
1233
|
-
var
|
|
1286
|
+
var Tt = R.create({
|
|
1234
1287
|
name: "searchHighlight",
|
|
1235
1288
|
addProseMirrorPlugins() {
|
|
1236
|
-
return [new
|
|
1237
|
-
key:
|
|
1289
|
+
return [new z({
|
|
1290
|
+
key: bt,
|
|
1238
1291
|
state: {
|
|
1239
|
-
init: () =>
|
|
1292
|
+
init: () => yt,
|
|
1240
1293
|
apply(e, t) {
|
|
1241
|
-
let n = e.getMeta(
|
|
1294
|
+
let n = e.getMeta(bt);
|
|
1242
1295
|
if (n) return {
|
|
1243
1296
|
...t,
|
|
1244
1297
|
...n,
|
|
@@ -1246,7 +1299,7 @@ var Ct = F.create({
|
|
|
1246
1299
|
currentIndex: n.currentIndex === void 0 ? t.currentIndex : n.currentIndex
|
|
1247
1300
|
};
|
|
1248
1301
|
if (e.docChanged && t.keyword) {
|
|
1249
|
-
let n =
|
|
1302
|
+
let n = St(e.doc, t), r = t.currentIndex;
|
|
1250
1303
|
return r >= n.length && (r = n.length - 1), r < 0 && (r = n.length > 0 ? 0 : -1), {
|
|
1251
1304
|
...t,
|
|
1252
1305
|
matches: n,
|
|
@@ -1257,52 +1310,52 @@ var Ct = F.create({
|
|
|
1257
1310
|
}
|
|
1258
1311
|
},
|
|
1259
1312
|
props: { decorations(e) {
|
|
1260
|
-
let t =
|
|
1261
|
-
return t ?
|
|
1313
|
+
let t = bt.getState(e);
|
|
1314
|
+
return t ? Ct(e.doc, t) : se.empty;
|
|
1262
1315
|
} }
|
|
1263
1316
|
})];
|
|
1264
1317
|
},
|
|
1265
1318
|
addCommands() {
|
|
1266
1319
|
return {
|
|
1267
1320
|
setSearch: (e, t = {}) => ({ state: n, dispatch: r, view: i }) => {
|
|
1268
|
-
let a =
|
|
1321
|
+
let a = bt.getState(n) || yt, o = {
|
|
1269
1322
|
keyword: e,
|
|
1270
1323
|
caseSensitive: t.caseSensitive ?? a.caseSensitive,
|
|
1271
1324
|
wholeWord: t.wholeWord ?? a.wholeWord,
|
|
1272
1325
|
matches: [],
|
|
1273
1326
|
currentIndex: -1
|
|
1274
1327
|
};
|
|
1275
|
-
return o.matches =
|
|
1328
|
+
return o.matches = St(n.doc, o), o.currentIndex = o.matches.length > 0 ? 0 : -1, r && (r(n.tr.setMeta(bt, o)), i && wt(i, o)), !0;
|
|
1276
1329
|
},
|
|
1277
1330
|
nextMatch: () => ({ state: e, dispatch: t, view: n }) => {
|
|
1278
|
-
let r =
|
|
1331
|
+
let r = bt.getState(e) || yt;
|
|
1279
1332
|
if (r.matches.length === 0) return !1;
|
|
1280
1333
|
let i = (r.currentIndex + 1) % r.matches.length;
|
|
1281
|
-
return t && (t(e.tr.setMeta(
|
|
1334
|
+
return t && (t(e.tr.setMeta(bt, { currentIndex: i })), n && wt(n, {
|
|
1282
1335
|
...r,
|
|
1283
1336
|
currentIndex: i
|
|
1284
1337
|
})), !0;
|
|
1285
1338
|
},
|
|
1286
1339
|
prevMatch: () => ({ state: e, dispatch: t, view: n }) => {
|
|
1287
|
-
let r =
|
|
1340
|
+
let r = bt.getState(e) || yt;
|
|
1288
1341
|
if (r.matches.length === 0) return !1;
|
|
1289
1342
|
let i = (r.currentIndex - 1 + r.matches.length) % r.matches.length;
|
|
1290
|
-
return t && (t(e.tr.setMeta(
|
|
1343
|
+
return t && (t(e.tr.setMeta(bt, { currentIndex: i })), n && wt(n, {
|
|
1291
1344
|
...r,
|
|
1292
1345
|
currentIndex: i
|
|
1293
1346
|
})), !0;
|
|
1294
1347
|
},
|
|
1295
|
-
clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(
|
|
1348
|
+
clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(bt, yt)), !0)
|
|
1296
1349
|
};
|
|
1297
1350
|
}
|
|
1298
1351
|
});
|
|
1299
|
-
function
|
|
1352
|
+
function Et(e) {
|
|
1300
1353
|
let t = e.state;
|
|
1301
|
-
return
|
|
1354
|
+
return bt.getState(t) || yt;
|
|
1302
1355
|
}
|
|
1303
1356
|
//#endregion
|
|
1304
1357
|
//#region src/components/search-bar.tsx
|
|
1305
|
-
var
|
|
1358
|
+
var Dt = ({ editor: e, onClose: t }) => {
|
|
1306
1359
|
let [n, r] = T(""), [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(0), u = w(null), d = w({
|
|
1307
1360
|
keyword: n,
|
|
1308
1361
|
caseSensitive: i,
|
|
@@ -1367,7 +1420,7 @@ var Tt = ({ editor: e, onClose: t }) => {
|
|
|
1367
1420
|
}, [f, p]), h = C(() => {
|
|
1368
1421
|
if (!e) return null;
|
|
1369
1422
|
try {
|
|
1370
|
-
return
|
|
1423
|
+
return Et(e);
|
|
1371
1424
|
} catch {
|
|
1372
1425
|
return null;
|
|
1373
1426
|
}
|
|
@@ -1519,36 +1572,36 @@ function Q({ children: e, ...t }) {
|
|
|
1519
1572
|
children: e
|
|
1520
1573
|
});
|
|
1521
1574
|
}
|
|
1522
|
-
var
|
|
1575
|
+
var Ot = (e) => /* @__PURE__ */ O(Q, {
|
|
1523
1576
|
...e,
|
|
1524
1577
|
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" })]
|
|
1525
|
-
}),
|
|
1578
|
+
}), kt = (e) => /* @__PURE__ */ O(Q, {
|
|
1526
1579
|
...e,
|
|
1527
1580
|
children: [
|
|
1528
1581
|
/* @__PURE__ */ D("path", { d: "M19 4h-9" }),
|
|
1529
1582
|
/* @__PURE__ */ D("path", { d: "M14 20H5" }),
|
|
1530
1583
|
/* @__PURE__ */ D("path", { d: "M15 4 9 20" })
|
|
1531
1584
|
]
|
|
1532
|
-
}),
|
|
1585
|
+
}), At = (e) => /* @__PURE__ */ O(Q, {
|
|
1533
1586
|
...e,
|
|
1534
1587
|
children: [/* @__PURE__ */ D("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }), /* @__PURE__ */ D("path", { d: "M4 20h16" })]
|
|
1535
|
-
}),
|
|
1588
|
+
}), jt = (e) => /* @__PURE__ */ O(Q, {
|
|
1536
1589
|
...e,
|
|
1537
1590
|
children: [
|
|
1538
1591
|
/* @__PURE__ */ D("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
|
|
1539
1592
|
/* @__PURE__ */ D("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
|
|
1540
1593
|
/* @__PURE__ */ D("path", { d: "M4 12h16" })
|
|
1541
1594
|
]
|
|
1542
|
-
}),
|
|
1595
|
+
}), Mt = (e) => /* @__PURE__ */ O(Q, {
|
|
1543
1596
|
...e,
|
|
1544
1597
|
children: [/* @__PURE__ */ D("path", { d: "m16 18 6-6-6-6" }), /* @__PURE__ */ D("path", { d: "m8 6-6 6 6 6" })]
|
|
1545
|
-
}),
|
|
1598
|
+
}), Nt = (e) => /* @__PURE__ */ O(Q, {
|
|
1546
1599
|
...e,
|
|
1547
1600
|
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" })]
|
|
1548
|
-
}),
|
|
1601
|
+
}), Pt = (e) => /* @__PURE__ */ O(Q, {
|
|
1549
1602
|
...e,
|
|
1550
1603
|
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" })]
|
|
1551
|
-
}),
|
|
1604
|
+
}), Ft = (e) => /* @__PURE__ */ O(Q, {
|
|
1552
1605
|
...e,
|
|
1553
1606
|
children: [/* @__PURE__ */ D("rect", {
|
|
1554
1607
|
x: "3",
|
|
@@ -1558,7 +1611,7 @@ var Et = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1558
1611
|
rx: "2",
|
|
1559
1612
|
ry: "2"
|
|
1560
1613
|
}), /* @__PURE__ */ D("path", { d: "M3 9h18M3 15h18M9 3v18M15 3v18" })]
|
|
1561
|
-
}),
|
|
1614
|
+
}), It = (e) => /* @__PURE__ */ O(Q, {
|
|
1562
1615
|
...e,
|
|
1563
1616
|
children: [/* @__PURE__ */ D("rect", {
|
|
1564
1617
|
x: "8",
|
|
@@ -1568,17 +1621,17 @@ var Et = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1568
1621
|
rx: "2",
|
|
1569
1622
|
ry: "2"
|
|
1570
1623
|
}), /* @__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" })]
|
|
1571
|
-
}),
|
|
1624
|
+
}), Lt = (e) => /* @__PURE__ */ O(Q, {
|
|
1572
1625
|
...e,
|
|
1573
1626
|
children: [/* @__PURE__ */ D("circle", {
|
|
1574
1627
|
cx: "11",
|
|
1575
1628
|
cy: "11",
|
|
1576
1629
|
r: "8"
|
|
1577
1630
|
}), /* @__PURE__ */ D("path", { d: "m21 21-4.3-4.3" })]
|
|
1578
|
-
}),
|
|
1631
|
+
}), Rt = (e) => /* @__PURE__ */ O(Q, {
|
|
1579
1632
|
...e,
|
|
1580
1633
|
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" })]
|
|
1581
|
-
}),
|
|
1634
|
+
}), zt = (e) => /* @__PURE__ */ O(Q, {
|
|
1582
1635
|
...e,
|
|
1583
1636
|
children: [
|
|
1584
1637
|
/* @__PURE__ */ D("circle", {
|
|
@@ -1597,13 +1650,13 @@ var Et = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1597
1650
|
r: "1"
|
|
1598
1651
|
})
|
|
1599
1652
|
]
|
|
1600
|
-
}),
|
|
1653
|
+
}), Bt = (e) => /* @__PURE__ */ O(Q, {
|
|
1601
1654
|
...e,
|
|
1602
1655
|
children: [/* @__PURE__ */ D("path", { d: "M18 6 6 18" }), /* @__PURE__ */ D("path", { d: "m6 6 12 12" })]
|
|
1603
1656
|
});
|
|
1604
1657
|
//#endregion
|
|
1605
1658
|
//#region src/editor/storage/remove-resource.ts
|
|
1606
|
-
async function
|
|
1659
|
+
async function Vt(e) {
|
|
1607
1660
|
if (e) {
|
|
1608
1661
|
if (e.startsWith("blob:")) {
|
|
1609
1662
|
URL.revokeObjectURL(e);
|
|
@@ -1618,61 +1671,61 @@ async function zt(e) {
|
|
|
1618
1671
|
}
|
|
1619
1672
|
//#endregion
|
|
1620
1673
|
//#region src/editor/ai/pending-removal.ts
|
|
1621
|
-
var
|
|
1674
|
+
var Ht = 3e4, Ut = /* @__PURE__ */ new Set([
|
|
1622
1675
|
"image",
|
|
1623
1676
|
"attachmentEmbed",
|
|
1624
1677
|
"audioEmbed",
|
|
1625
1678
|
"videoEmbed"
|
|
1626
|
-
]),
|
|
1627
|
-
function
|
|
1679
|
+
]), Wt = /* @__PURE__ */ new WeakMap();
|
|
1680
|
+
function Gt(e) {
|
|
1628
1681
|
let t = /* @__PURE__ */ new Set();
|
|
1629
1682
|
return e.state.doc.descendants((e) => {
|
|
1630
|
-
if (
|
|
1683
|
+
if (Ut.has(e.type.name)) {
|
|
1631
1684
|
let n = e.attrs.src;
|
|
1632
1685
|
n && t.add(n);
|
|
1633
1686
|
}
|
|
1634
1687
|
return !0;
|
|
1635
1688
|
}), t;
|
|
1636
1689
|
}
|
|
1637
|
-
function
|
|
1638
|
-
let t =
|
|
1690
|
+
function Kt(e) {
|
|
1691
|
+
let t = Wt.get(e);
|
|
1639
1692
|
return t || (t = {
|
|
1640
1693
|
timers: /* @__PURE__ */ new Map(),
|
|
1641
1694
|
onTransaction: () => {},
|
|
1642
1695
|
listening: !1
|
|
1643
|
-
},
|
|
1696
|
+
}, Wt.set(e, t)), t;
|
|
1644
1697
|
}
|
|
1645
|
-
function
|
|
1698
|
+
function qt(e, t) {
|
|
1646
1699
|
let n = [...new Set(t.filter(Boolean))];
|
|
1647
1700
|
if (n.length === 0) return;
|
|
1648
|
-
let r =
|
|
1701
|
+
let r = Kt(e);
|
|
1649
1702
|
r.listening ||= (r.onTransaction = () => {
|
|
1650
1703
|
if (r.timers.size === 0) return;
|
|
1651
|
-
let t =
|
|
1704
|
+
let t = Gt(e);
|
|
1652
1705
|
for (let [e, n] of r.timers) t.has(e) && (clearTimeout(n), r.timers.delete(e));
|
|
1653
1706
|
}, e.on("transaction", r.onTransaction), !0);
|
|
1654
1707
|
for (let t of n) {
|
|
1655
1708
|
if (r.timers.has(t)) continue;
|
|
1656
1709
|
let n = setTimeout(() => {
|
|
1657
|
-
|
|
1658
|
-
},
|
|
1710
|
+
Gt(e).has(t) || Vt(t), r.timers.delete(t);
|
|
1711
|
+
}, Ht);
|
|
1659
1712
|
r.timers.set(t, n);
|
|
1660
1713
|
}
|
|
1661
1714
|
}
|
|
1662
|
-
function
|
|
1663
|
-
let t =
|
|
1715
|
+
function Jt(e) {
|
|
1716
|
+
let t = Wt.get(e);
|
|
1664
1717
|
if (t) {
|
|
1665
1718
|
if (t.listening &&= (e.off("transaction", t.onTransaction), !1), t.timers.size > 0) {
|
|
1666
|
-
let n =
|
|
1667
|
-
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) ||
|
|
1719
|
+
let n = Gt(e);
|
|
1720
|
+
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) || Vt(e);
|
|
1668
1721
|
t.timers.clear();
|
|
1669
1722
|
}
|
|
1670
|
-
|
|
1723
|
+
Wt.delete(e);
|
|
1671
1724
|
}
|
|
1672
1725
|
}
|
|
1673
1726
|
//#endregion
|
|
1674
1727
|
//#region src/editor/ai/components/ai-selector.tsx
|
|
1675
|
-
var
|
|
1728
|
+
var Yt = [
|
|
1676
1729
|
{
|
|
1677
1730
|
mode: "continue",
|
|
1678
1731
|
labelKey: "editor.ai.continue",
|
|
@@ -1715,24 +1768,24 @@ var qt = [
|
|
|
1715
1768
|
descKey: "editor.ai.zapDesc",
|
|
1716
1769
|
icon: "⚡"
|
|
1717
1770
|
}
|
|
1718
|
-
],
|
|
1771
|
+
], Xt = /* @__PURE__ */ new Set([
|
|
1719
1772
|
"image",
|
|
1720
1773
|
"attachmentEmbed",
|
|
1721
1774
|
"audioEmbed",
|
|
1722
1775
|
"videoEmbed"
|
|
1723
|
-
]),
|
|
1776
|
+
]), Zt = {
|
|
1724
1777
|
image: "editor.ai.nodeImage",
|
|
1725
1778
|
attachmentEmbed: "editor.ai.nodeAttachment",
|
|
1726
1779
|
videoEmbed: "editor.ai.nodeVideo",
|
|
1727
1780
|
audioEmbed: "editor.ai.nodeAudio"
|
|
1728
1781
|
};
|
|
1729
|
-
function
|
|
1782
|
+
function Qt(e, t) {
|
|
1730
1783
|
return e.storage.qingwuUI?.parseMd?.(e.schema, t) || null;
|
|
1731
1784
|
}
|
|
1732
|
-
function
|
|
1785
|
+
function $t(e, t, n) {
|
|
1733
1786
|
let r = [];
|
|
1734
1787
|
return e.state.doc.nodesBetween(t, n, (e) => {
|
|
1735
|
-
if (
|
|
1788
|
+
if (Xt.has(e.type.name)) {
|
|
1736
1789
|
let t = e.attrs.src;
|
|
1737
1790
|
t && r.push({
|
|
1738
1791
|
type: e.type.name,
|
|
@@ -1742,27 +1795,27 @@ function Zt(e, t, n) {
|
|
|
1742
1795
|
return !0;
|
|
1743
1796
|
}), r;
|
|
1744
1797
|
}
|
|
1745
|
-
function
|
|
1798
|
+
function en(e) {
|
|
1746
1799
|
let t = /* @__PURE__ */ new Set();
|
|
1747
1800
|
return e.state.doc.descendants((e) => {
|
|
1748
|
-
if (
|
|
1801
|
+
if (Xt.has(e.type.name)) {
|
|
1749
1802
|
let n = e.attrs.src;
|
|
1750
1803
|
n && t.add(n);
|
|
1751
1804
|
}
|
|
1752
1805
|
return !0;
|
|
1753
1806
|
}), t;
|
|
1754
1807
|
}
|
|
1755
|
-
function
|
|
1756
|
-
let n =
|
|
1808
|
+
function tn(e, t) {
|
|
1809
|
+
let n = Qt(e, t);
|
|
1757
1810
|
if (n && n.size > 0) {
|
|
1758
1811
|
let t = e.state.tr;
|
|
1759
|
-
t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(
|
|
1812
|
+
t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(ae.create(t.doc, t.doc.content.size)), e.view.dispatch(t.scrollIntoView()), e.commands.focus();
|
|
1760
1813
|
return;
|
|
1761
1814
|
}
|
|
1762
1815
|
e.commands.setContent(t), e.commands.focus();
|
|
1763
1816
|
}
|
|
1764
|
-
function
|
|
1765
|
-
let i =
|
|
1817
|
+
function nn(e, t, n, r) {
|
|
1818
|
+
let i = Qt(e, t);
|
|
1766
1819
|
if (e.commands.focus(), !i) {
|
|
1767
1820
|
let i = e.chain().focus();
|
|
1768
1821
|
n === "replace" ? i.setTextSelection({
|
|
@@ -1774,7 +1827,7 @@ function en(e, t, n, r) {
|
|
|
1774
1827
|
let a = e.state.tr;
|
|
1775
1828
|
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());
|
|
1776
1829
|
}
|
|
1777
|
-
function
|
|
1830
|
+
function rn({ editor: e, onClose: t }) {
|
|
1778
1831
|
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({
|
|
1779
1832
|
from: 0,
|
|
1780
1833
|
to: 0,
|
|
@@ -1793,7 +1846,7 @@ function tn({ editor: e, onClose: t }) {
|
|
|
1793
1846
|
empty: n.empty
|
|
1794
1847
|
}, l(!0), s(""), v.current = !0, d(null);
|
|
1795
1848
|
try {
|
|
1796
|
-
let r =
|
|
1849
|
+
let r = mt(), a = n.empty ? e.state.doc.textContent : e.state.doc.textBetween(n.from, n.to), o = [];
|
|
1797
1850
|
for await (let e of r.stream({
|
|
1798
1851
|
mode: t,
|
|
1799
1852
|
context: a,
|
|
@@ -1818,13 +1871,13 @@ function tn({ editor: e, onClose: t }) {
|
|
|
1818
1871
|
!e || !v.current || (e.scrollTop = e.scrollHeight);
|
|
1819
1872
|
}, [o]);
|
|
1820
1873
|
let k = b((t, n, r) => {
|
|
1821
|
-
let i = new Set(
|
|
1822
|
-
t === "replaceAll" ?
|
|
1823
|
-
let a =
|
|
1824
|
-
|
|
1874
|
+
let i = new Set($t(e, r.from, r.to).map((e) => e.src));
|
|
1875
|
+
t === "replaceAll" ? tn(e, n) : nn(e, n, "replace", h.current);
|
|
1876
|
+
let a = en(e);
|
|
1877
|
+
qt(e, [...i].filter((e) => !a.has(e)));
|
|
1825
1878
|
}, [e]), A = b((n) => {
|
|
1826
1879
|
if (n === "below") {
|
|
1827
|
-
|
|
1880
|
+
nn(e, o, "below", h.current), t();
|
|
1828
1881
|
return;
|
|
1829
1882
|
}
|
|
1830
1883
|
let r = h.current, i = n === "replaceAll" ? {
|
|
@@ -1833,7 +1886,7 @@ function tn({ editor: e, onClose: t }) {
|
|
|
1833
1886
|
} : {
|
|
1834
1887
|
from: r.from,
|
|
1835
1888
|
to: r.to
|
|
1836
|
-
}, a =
|
|
1889
|
+
}, a = $t(e, i.from, i.to);
|
|
1837
1890
|
if (a.length > 0) {
|
|
1838
1891
|
m({
|
|
1839
1892
|
position: n,
|
|
@@ -1874,19 +1927,19 @@ function tn({ editor: e, onClose: t }) {
|
|
|
1874
1927
|
className: "flex items-center justify-between pl-3 pr-1.5 py-1.5 border-b border-default-100 shrink-0",
|
|
1875
1928
|
children: [/* @__PURE__ */ O("span", {
|
|
1876
1929
|
className: "flex items-center gap-1.5 text-xs font-medium text-default-500",
|
|
1877
|
-
children: [/* @__PURE__ */ D(
|
|
1930
|
+
children: [/* @__PURE__ */ D(Rt, { className: "text-primary" }), f("editor.ai.trigger")]
|
|
1878
1931
|
}), /* @__PURE__ */ D("button", {
|
|
1879
1932
|
type: "button",
|
|
1880
1933
|
onClick: t,
|
|
1881
1934
|
"aria-label": f("editor.ai.close"),
|
|
1882
1935
|
title: f("editor.ai.close"),
|
|
1883
1936
|
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",
|
|
1884
|
-
children: /* @__PURE__ */ D(
|
|
1937
|
+
children: /* @__PURE__ */ D(Bt, {})
|
|
1885
1938
|
})]
|
|
1886
1939
|
}),
|
|
1887
1940
|
/* @__PURE__ */ D("div", {
|
|
1888
1941
|
className: "grid grid-cols-[repeat(auto-fit,minmax(64px,1fr))] gap-1.5 p-2 shrink-0",
|
|
1889
|
-
children:
|
|
1942
|
+
children: Yt.map(({ mode: e, labelKey: t, descKey: r, icon: i }) => /* @__PURE__ */ O("button", {
|
|
1890
1943
|
type: "button",
|
|
1891
1944
|
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"}`,
|
|
1892
1945
|
onClick: () => y(e),
|
|
@@ -2029,7 +2082,7 @@ function tn({ editor: e, onClose: t }) {
|
|
|
2029
2082
|
children: Object.entries(N).map(([e, t]) => /* @__PURE__ */ O("li", {
|
|
2030
2083
|
className: "text-sm text-default-700",
|
|
2031
2084
|
children: [
|
|
2032
|
-
f(
|
|
2085
|
+
f(Zt[e] ?? e),
|
|
2033
2086
|
" ×",
|
|
2034
2087
|
t
|
|
2035
2088
|
]
|
|
@@ -2061,19 +2114,19 @@ function tn({ editor: e, onClose: t }) {
|
|
|
2061
2114
|
}
|
|
2062
2115
|
//#endregion
|
|
2063
2116
|
//#region src/editor/attachment-limits.ts
|
|
2064
|
-
var
|
|
2117
|
+
var an = /* @__PURE__ */ new Set([
|
|
2065
2118
|
"attachmentEmbed",
|
|
2066
2119
|
"videoEmbed",
|
|
2067
2120
|
"audioEmbed",
|
|
2068
2121
|
"image"
|
|
2069
2122
|
]);
|
|
2070
|
-
function
|
|
2123
|
+
function on(e) {
|
|
2071
2124
|
let t = 0;
|
|
2072
2125
|
return e.descendants((e) => {
|
|
2073
|
-
|
|
2126
|
+
an.has(e.type.name) && (t += Number(e.attrs?.size) || 0);
|
|
2074
2127
|
}), t;
|
|
2075
2128
|
}
|
|
2076
|
-
function
|
|
2129
|
+
function sn(e) {
|
|
2077
2130
|
if (!Number.isFinite(e) || e <= 0) return "0 B";
|
|
2078
2131
|
let t = [
|
|
2079
2132
|
"B",
|
|
@@ -2084,41 +2137,41 @@ function an(e) {
|
|
|
2084
2137
|
], n = Math.min(t.length - 1, Math.floor(Math.log(e) / Math.log(1024))), r = e / 1024 ** n;
|
|
2085
2138
|
return `${n === 0 || r >= 100 ? `${Math.round(r)}` : `${Math.round(r * 10) / 10}`} ${t[n]}`;
|
|
2086
2139
|
}
|
|
2087
|
-
function
|
|
2140
|
+
function cn(e) {
|
|
2088
2141
|
return (e?.storage)?.qingwuUI?.limits;
|
|
2089
2142
|
}
|
|
2090
|
-
function
|
|
2143
|
+
function ln(e, t, n) {
|
|
2091
2144
|
let { maxAttachmentSize: r, maxTotalAttachmentSize: i } = n;
|
|
2092
|
-
if (r && t.size > r) return `单文件大小不能超过 ${
|
|
2145
|
+
if (r && t.size > r) return `单文件大小不能超过 ${sn(r)}(当前 ${sn(t.size)})`;
|
|
2093
2146
|
if (i) {
|
|
2094
|
-
let n =
|
|
2095
|
-
if (n > i) return `附件总大小不能超过 ${
|
|
2147
|
+
let n = on(e) + t.size;
|
|
2148
|
+
if (n > i) return `附件总大小不能超过 ${sn(i)}(当前合计 ${sn(n)})`;
|
|
2096
2149
|
}
|
|
2097
2150
|
return null;
|
|
2098
2151
|
}
|
|
2099
2152
|
//#endregion
|
|
2100
2153
|
//#region src/editor/utils/delete-confirm.ts
|
|
2101
|
-
var
|
|
2102
|
-
function
|
|
2103
|
-
return
|
|
2154
|
+
var un = !1, dn = null, fn = 5e3;
|
|
2155
|
+
function pn() {
|
|
2156
|
+
return un;
|
|
2104
2157
|
}
|
|
2105
2158
|
function $(e) {
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
},
|
|
2159
|
+
un = e, dn &&= (clearTimeout(dn), null), e && (dn = setTimeout(() => {
|
|
2160
|
+
un = !1, dn = null;
|
|
2161
|
+
}, fn));
|
|
2109
2162
|
}
|
|
2110
|
-
var
|
|
2111
|
-
function
|
|
2112
|
-
|
|
2163
|
+
var mn = null;
|
|
2164
|
+
function hn(e) {
|
|
2165
|
+
mn = e;
|
|
2113
2166
|
}
|
|
2114
|
-
function
|
|
2115
|
-
return
|
|
2167
|
+
function gn() {
|
|
2168
|
+
return mn;
|
|
2116
2169
|
}
|
|
2117
2170
|
//#endregion
|
|
2118
2171
|
//#region src/editor/utils/delete-confirm-dialog.tsx
|
|
2119
|
-
var
|
|
2120
|
-
function
|
|
2121
|
-
let [s, c] = T(!1), l = w(!1), u =
|
|
2172
|
+
var _n = 300;
|
|
2173
|
+
function vn({ open: e, title: t, message: n, confirmText: r = "删除", cancelText: i = "取消", onConfirm: a, onCancel: o }) {
|
|
2174
|
+
let [s, c] = T(!1), l = w(!1), u = gn();
|
|
2122
2175
|
return x(() => {
|
|
2123
2176
|
if (!e) {
|
|
2124
2177
|
l.current = !1;
|
|
@@ -2144,7 +2197,7 @@ function gn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2144
2197
|
o
|
|
2145
2198
|
]), x(() => {
|
|
2146
2199
|
e || c(!1);
|
|
2147
|
-
}, [e]), u || !e ? null :
|
|
2200
|
+
}, [e]), u || !e ? null : ne(/* @__PURE__ */ D("div", {
|
|
2148
2201
|
className: "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none",
|
|
2149
2202
|
onClick: () => {
|
|
2150
2203
|
s || o();
|
|
@@ -2188,7 +2241,7 @@ function gn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2188
2241
|
await a();
|
|
2189
2242
|
} finally {
|
|
2190
2243
|
let t = Date.now() - e;
|
|
2191
|
-
t <
|
|
2244
|
+
t < _n && await new Promise((e) => setTimeout(e, _n - t)), c(!1), o();
|
|
2192
2245
|
}
|
|
2193
2246
|
},
|
|
2194
2247
|
disabled: s,
|
|
@@ -2201,18 +2254,18 @@ function gn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2201
2254
|
}
|
|
2202
2255
|
//#endregion
|
|
2203
2256
|
//#region src/editor/extensions/image-view.tsx
|
|
2204
|
-
function
|
|
2257
|
+
function yn(e) {
|
|
2205
2258
|
return /^(\.\.?\/|[a-zA-Z]:\\|file:\/\/)/.test(e) ? !0 : !(/^[a-z]+:\/\//i.test(e) || e.startsWith("/") || e.startsWith("data:") || e.startsWith("blob:"));
|
|
2206
2259
|
}
|
|
2207
|
-
function
|
|
2208
|
-
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,
|
|
2260
|
+
function bn({ node: e, deleteNode: t, editor: r }) {
|
|
2261
|
+
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(() => {
|
|
2209
2262
|
o || (A.current = window.scrollY, a(!0));
|
|
2210
|
-
}, [o]),
|
|
2263
|
+
}, [o]), F = b(() => {
|
|
2211
2264
|
a(!1), requestAnimationFrame(() => window.scrollTo(0, A.current));
|
|
2212
|
-
}, []),
|
|
2265
|
+
}, []), L = b(() => {
|
|
2213
2266
|
let e = _.current;
|
|
2214
2267
|
e && (A.current = window.scrollY, e.requestFullscreen ? e.requestFullscreen() : e.webkitRequestFullscreen && e.webkitRequestFullscreen());
|
|
2215
|
-
}, []),
|
|
2268
|
+
}, []), ee = b(() => {
|
|
2216
2269
|
let e = v.current;
|
|
2217
2270
|
e && (A.current = window.scrollY, e.requestFullscreen ? e.requestFullscreen() : e.webkitRequestFullscreen && e.webkitRequestFullscreen());
|
|
2218
2271
|
}, []);
|
|
@@ -2257,20 +2310,20 @@ function vn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2257
2310
|
};
|
|
2258
2311
|
return document.addEventListener("fullscreenchange", e), () => document.removeEventListener("fullscreenchange", e);
|
|
2259
2312
|
}, []);
|
|
2260
|
-
let
|
|
2261
|
-
return /* @__PURE__ */ O(
|
|
2313
|
+
let te = o || yn(p);
|
|
2314
|
+
return /* @__PURE__ */ O(I, {
|
|
2262
2315
|
as: "div",
|
|
2263
2316
|
className: "image-node-view group/img",
|
|
2264
2317
|
contentEditable: !1,
|
|
2265
2318
|
children: [
|
|
2266
|
-
|
|
2319
|
+
te ? /* @__PURE__ */ O("div", {
|
|
2267
2320
|
className: "image-placeholder",
|
|
2268
2321
|
children: [
|
|
2269
2322
|
N && /* @__PURE__ */ D("button", {
|
|
2270
2323
|
type: "button",
|
|
2271
2324
|
className: "img-ctrl-btn img-ctrl-btn--del image-placeholder-del",
|
|
2272
2325
|
onClick: () => {
|
|
2273
|
-
|
|
2326
|
+
pn() || ($(!0), f(!0));
|
|
2274
2327
|
},
|
|
2275
2328
|
title: "删除",
|
|
2276
2329
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2302,7 +2355,7 @@ function vn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2302
2355
|
}),
|
|
2303
2356
|
/* @__PURE__ */ D("span", {
|
|
2304
2357
|
className: "image-placeholder-text",
|
|
2305
|
-
children:
|
|
2358
|
+
children: yn(p) ? "本地图片无法加载" : "图片加载失败"
|
|
2306
2359
|
}),
|
|
2307
2360
|
/* @__PURE__ */ D("span", {
|
|
2308
2361
|
className: "image-placeholder-path",
|
|
@@ -2318,7 +2371,7 @@ function vn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2318
2371
|
alt: m,
|
|
2319
2372
|
width: h || void 0,
|
|
2320
2373
|
height: g || void 0,
|
|
2321
|
-
onClick:
|
|
2374
|
+
onClick: P,
|
|
2322
2375
|
onError: () => {
|
|
2323
2376
|
E.current || o || (E.current = !0, (async () => {
|
|
2324
2377
|
try {
|
|
@@ -2344,7 +2397,7 @@ function vn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2344
2397
|
/* @__PURE__ */ D("button", {
|
|
2345
2398
|
type: "button",
|
|
2346
2399
|
className: "img-ctrl-btn",
|
|
2347
|
-
onClick:
|
|
2400
|
+
onClick: P,
|
|
2348
2401
|
title: "网页全屏",
|
|
2349
2402
|
children: /* @__PURE__ */ D("svg", {
|
|
2350
2403
|
width: "14",
|
|
@@ -2363,7 +2416,7 @@ function vn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2363
2416
|
/* @__PURE__ */ D("button", {
|
|
2364
2417
|
type: "button",
|
|
2365
2418
|
className: "img-ctrl-btn",
|
|
2366
|
-
onClick:
|
|
2419
|
+
onClick: L,
|
|
2367
2420
|
title: "全屏",
|
|
2368
2421
|
children: /* @__PURE__ */ D("svg", {
|
|
2369
2422
|
width: "14",
|
|
@@ -2383,7 +2436,7 @@ function vn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2383
2436
|
type: "button",
|
|
2384
2437
|
className: "img-ctrl-btn img-ctrl-btn--del",
|
|
2385
2438
|
onClick: () => {
|
|
2386
|
-
|
|
2439
|
+
pn() || ($(!0), f(!0));
|
|
2387
2440
|
},
|
|
2388
2441
|
title: "删除",
|
|
2389
2442
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2403,15 +2456,15 @@ function vn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2403
2456
|
]
|
|
2404
2457
|
})]
|
|
2405
2458
|
}),
|
|
2406
|
-
i && !
|
|
2459
|
+
i && !te && /* @__PURE__ */ O("div", {
|
|
2407
2460
|
className: "image-lightbox",
|
|
2408
|
-
onClick:
|
|
2461
|
+
onClick: F,
|
|
2409
2462
|
children: [/* @__PURE__ */ O("div", {
|
|
2410
2463
|
className: "image-lightbox-bar",
|
|
2411
2464
|
children: [/* @__PURE__ */ D("button", {
|
|
2412
2465
|
type: "button",
|
|
2413
2466
|
className: "image-lightbox-bar-btn",
|
|
2414
|
-
onClick:
|
|
2467
|
+
onClick: ee,
|
|
2415
2468
|
title: "全屏",
|
|
2416
2469
|
children: /* @__PURE__ */ D("svg", {
|
|
2417
2470
|
width: "18",
|
|
@@ -2429,7 +2482,7 @@ function vn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2429
2482
|
}), /* @__PURE__ */ D("button", {
|
|
2430
2483
|
type: "button",
|
|
2431
2484
|
className: "image-lightbox-bar-btn",
|
|
2432
|
-
onClick:
|
|
2485
|
+
onClick: F,
|
|
2433
2486
|
title: "关闭",
|
|
2434
2487
|
children: /* @__PURE__ */ D("svg", {
|
|
2435
2488
|
width: "18",
|
|
@@ -2470,16 +2523,16 @@ function vn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2470
2523
|
}
|
|
2471
2524
|
})]
|
|
2472
2525
|
}),
|
|
2473
|
-
/* @__PURE__ */ D(
|
|
2526
|
+
/* @__PURE__ */ D(vn, {
|
|
2474
2527
|
open: d,
|
|
2475
2528
|
title: "确认删除图片",
|
|
2476
|
-
message:
|
|
2529
|
+
message: te ? "该图片无法在当前环境加载,仅从编辑器中移除该图片节点,不影响存储文件。" : "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
2477
2530
|
onCancel: () => {
|
|
2478
2531
|
$(!1), f(!1);
|
|
2479
2532
|
},
|
|
2480
2533
|
onConfirm: async () => {
|
|
2481
|
-
if (!
|
|
2482
|
-
await
|
|
2534
|
+
if (!te) try {
|
|
2535
|
+
await Vt(p);
|
|
2483
2536
|
} catch {}
|
|
2484
2537
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
2485
2538
|
}
|
|
@@ -2489,7 +2542,7 @@ function vn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2489
2542
|
}
|
|
2490
2543
|
//#endregion
|
|
2491
2544
|
//#region src/editor/embeds/attachment-view.tsx
|
|
2492
|
-
var
|
|
2545
|
+
var xn = y(() => import("@file-viewer/react")), Sn = /* @__PURE__ */ new Set(), Cn = {
|
|
2493
2546
|
rendererMode: "replace",
|
|
2494
2547
|
autoRenderers: !0,
|
|
2495
2548
|
theme: "light",
|
|
@@ -2518,7 +2571,7 @@ var yn = y(() => import("@file-viewer/react")), bn = /* @__PURE__ */ new Set(),
|
|
|
2518
2571
|
cache: !0,
|
|
2519
2572
|
workerTimeoutMs: 3e4
|
|
2520
2573
|
}
|
|
2521
|
-
},
|
|
2574
|
+
}, wn = {
|
|
2522
2575
|
pdf: "pdf",
|
|
2523
2576
|
docx: "word",
|
|
2524
2577
|
docm: "word",
|
|
@@ -2573,7 +2626,7 @@ var yn = y(() => import("@file-viewer/react")), bn = /* @__PURE__ */ new Set(),
|
|
|
2573
2626
|
xml: "text",
|
|
2574
2627
|
yml: "text",
|
|
2575
2628
|
yaml: "text"
|
|
2576
|
-
},
|
|
2629
|
+
}, Tn = {
|
|
2577
2630
|
pdf: () => import("@file-viewer/renderer-pdf").then((e) => e.pdfRenderer),
|
|
2578
2631
|
word: () => import("@file-viewer/renderer-word").then((e) => e.wordRenderer),
|
|
2579
2632
|
spreadsheet: () => import("@file-viewer/renderer-spreadsheet").then((e) => e.spreadsheetRenderer),
|
|
@@ -2581,10 +2634,10 @@ var yn = y(() => import("@file-viewer/react")), bn = /* @__PURE__ */ new Set(),
|
|
|
2581
2634
|
archive: () => import("@file-viewer/renderer-archive").then((e) => e.archiveRenderer),
|
|
2582
2635
|
text: () => import("@file-viewer/renderer-text").then((e) => e.textRenderer)
|
|
2583
2636
|
};
|
|
2584
|
-
function
|
|
2637
|
+
function En(e) {
|
|
2585
2638
|
return e ? e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1048576).toFixed(1)} MB` : "";
|
|
2586
2639
|
}
|
|
2587
|
-
function
|
|
2640
|
+
function Dn(e) {
|
|
2588
2641
|
let t = e.split(".").pop()?.toLowerCase() || "", n = {
|
|
2589
2642
|
pdf: {
|
|
2590
2643
|
label: "PDF",
|
|
@@ -2757,22 +2810,22 @@ function Tn(e) {
|
|
|
2757
2810
|
]
|
|
2758
2811
|
});
|
|
2759
2812
|
}
|
|
2760
|
-
function
|
|
2813
|
+
function On(e) {
|
|
2761
2814
|
return e.split(".").pop()?.toLowerCase() || "";
|
|
2762
2815
|
}
|
|
2763
|
-
function
|
|
2816
|
+
function kn(e) {
|
|
2764
2817
|
let t = e.split(".").pop()?.toLowerCase() || "";
|
|
2765
2818
|
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);
|
|
2766
2819
|
}
|
|
2767
|
-
function
|
|
2820
|
+
function An(e) {
|
|
2768
2821
|
return !!e && !e.startsWith("file:");
|
|
2769
2822
|
}
|
|
2770
|
-
function
|
|
2823
|
+
function jn(e) {
|
|
2771
2824
|
return btoa(encodeURIComponent(e)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
2772
2825
|
}
|
|
2773
|
-
async function
|
|
2826
|
+
async function Mn(e, t) {
|
|
2774
2827
|
try {
|
|
2775
|
-
let n =
|
|
2828
|
+
let n = jn(e), r = await fetch(`/api/preview/${n}`, {
|
|
2776
2829
|
signal: t,
|
|
2777
2830
|
cache: "no-store"
|
|
2778
2831
|
});
|
|
@@ -2784,7 +2837,7 @@ async function An(e, t) {
|
|
|
2784
2837
|
return null;
|
|
2785
2838
|
}
|
|
2786
2839
|
}
|
|
2787
|
-
function
|
|
2840
|
+
function Nn(e, t, n) {
|
|
2788
2841
|
return new Promise((r, i) => {
|
|
2789
2842
|
let a = new XMLHttpRequest();
|
|
2790
2843
|
if (a.open("GET", e, !0), a.responseType = "arraybuffer", t) {
|
|
@@ -2822,72 +2875,72 @@ function jn(e, t, n) {
|
|
|
2822
2875
|
a.send();
|
|
2823
2876
|
});
|
|
2824
2877
|
}
|
|
2825
|
-
function
|
|
2826
|
-
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() =>
|
|
2878
|
+
function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
2879
|
+
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() => Sn.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), F = w(!1), L = w(null), ee = w(0), [te, ne] = T(!1), R = w(null), [re, ie] = T(0), [z, B] = T("none"), [ae, oe] = T(void 0), [se, ce] = T(!1), V = e.attrs.src || "", H = e.attrs.name || V && V.split("/").pop()?.split("?")[0] || (V ? "attachment" : f("editor.attachment.lost")), le = e.attrs.size || 0, U = On(H), W = !V;
|
|
2827
2880
|
x(() => {
|
|
2828
2881
|
if (!c) {
|
|
2829
|
-
|
|
2882
|
+
oe(void 0), ce(!1);
|
|
2830
2883
|
return;
|
|
2831
2884
|
}
|
|
2832
|
-
let e =
|
|
2885
|
+
let e = wn[U];
|
|
2833
2886
|
if (!e) {
|
|
2834
|
-
|
|
2887
|
+
oe(void 0), ce(!1);
|
|
2835
2888
|
return;
|
|
2836
2889
|
}
|
|
2837
2890
|
let t = !0;
|
|
2838
|
-
return
|
|
2839
|
-
t &&
|
|
2891
|
+
return oe(void 0), ce(!1), Tn[e]().then((e) => {
|
|
2892
|
+
t && oe(e);
|
|
2840
2893
|
}).catch((n) => {
|
|
2841
|
-
console.error(`[attachment] renderer "${e}" load failed:`, n), t &&
|
|
2894
|
+
console.error(`[attachment] renderer "${e}" load failed:`, n), t && ce(!0);
|
|
2842
2895
|
}), () => {
|
|
2843
2896
|
t = !1;
|
|
2844
2897
|
};
|
|
2845
|
-
}, [c,
|
|
2846
|
-
let
|
|
2847
|
-
...
|
|
2848
|
-
renderers:
|
|
2898
|
+
}, [c, U]);
|
|
2899
|
+
let ue = C(() => ({
|
|
2900
|
+
...Cn,
|
|
2901
|
+
renderers: ae ? [ae] : [],
|
|
2849
2902
|
rendererMode: "replace"
|
|
2850
|
-
}), [
|
|
2903
|
+
}), [ae]), de = b((e) => {
|
|
2851
2904
|
l((t) => {
|
|
2852
2905
|
let n = typeof e == "function" ? e(t) : e;
|
|
2853
|
-
return
|
|
2906
|
+
return V && (n ? Sn.add(V) : Sn.delete(V)), n;
|
|
2854
2907
|
});
|
|
2855
|
-
}, [
|
|
2908
|
+
}, [V]);
|
|
2856
2909
|
x(() => {
|
|
2857
|
-
l(
|
|
2858
|
-
}, [
|
|
2859
|
-
let
|
|
2860
|
-
|
|
2861
|
-
window.scrollTo(0,
|
|
2910
|
+
l(V ? Sn.has(V) : !1);
|
|
2911
|
+
}, [V]);
|
|
2912
|
+
let G = b(() => {
|
|
2913
|
+
F.current = !0, de(!0), window.setTimeout(() => {
|
|
2914
|
+
window.scrollTo(0, P.current), L.current && (L.current.scrollTop = ee.current), F.current && de(!0), F.current = !1;
|
|
2862
2915
|
}, 0);
|
|
2863
|
-
}, [
|
|
2864
|
-
|
|
2865
|
-
}, [
|
|
2916
|
+
}, [de]), fe = b(async () => {
|
|
2917
|
+
z === "web" ? (B("none"), document.body.style.overflow = "", G()) : (z === "native" && document.fullscreenElement && await document.exitFullscreen(), P.current = window.scrollY, ee.current = L.current?.scrollTop ?? 0, document.body.style.overflow = "hidden", B("web"));
|
|
2918
|
+
}, [z]), pe = b(async () => {
|
|
2866
2919
|
let e = M.current;
|
|
2867
|
-
e && (
|
|
2868
|
-
}, [
|
|
2869
|
-
|
|
2870
|
-
}, [
|
|
2920
|
+
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, G]), me = b(() => {
|
|
2922
|
+
z === "none" && (F.current || de((e) => !e));
|
|
2923
|
+
}, [z]);
|
|
2871
2924
|
x(() => {
|
|
2872
2925
|
let e = () => {
|
|
2873
|
-
document.fullscreenElement || (
|
|
2926
|
+
document.fullscreenElement || (z === "native" && B("none"), G());
|
|
2874
2927
|
}, t = (e) => {
|
|
2875
|
-
e.key === "Escape" &&
|
|
2928
|
+
e.key === "Escape" && z === "web" && (B("none"), document.body.style.overflow = "", G());
|
|
2876
2929
|
};
|
|
2877
2930
|
return document.addEventListener("fullscreenchange", e), window.addEventListener("keydown", t), () => {
|
|
2878
2931
|
document.removeEventListener("fullscreenchange", e), window.removeEventListener("keydown", t);
|
|
2879
2932
|
};
|
|
2880
|
-
}, [
|
|
2933
|
+
}, [z, G]), x(() => {
|
|
2881
2934
|
let e = (e) => {
|
|
2882
|
-
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && i && !
|
|
2935
|
+
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && i && !pn()) {
|
|
2883
2936
|
if (e.preventDefault(), e.stopPropagation(), a) {
|
|
2884
2937
|
let { from: e, to: t } = a.state.selection;
|
|
2885
|
-
|
|
2938
|
+
R.current = {
|
|
2886
2939
|
from: e,
|
|
2887
2940
|
to: t
|
|
2888
2941
|
};
|
|
2889
2942
|
}
|
|
2890
|
-
window.getSelection()?.removeAllRanges(), $(!0),
|
|
2943
|
+
window.getSelection()?.removeAllRanges(), $(!0), ne(!0);
|
|
2891
2944
|
}
|
|
2892
2945
|
};
|
|
2893
2946
|
return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
|
|
@@ -2896,29 +2949,29 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2896
2949
|
a,
|
|
2897
2950
|
o
|
|
2898
2951
|
]), x(() => {
|
|
2899
|
-
if (!c || !
|
|
2952
|
+
if (!c || !An(V)) {
|
|
2900
2953
|
d(null), y(null), N.current = null;
|
|
2901
2954
|
return;
|
|
2902
2955
|
}
|
|
2903
|
-
if (N.current ===
|
|
2956
|
+
if (N.current === V) return;
|
|
2904
2957
|
let e = new AbortController(), r = !0;
|
|
2905
2958
|
return g(!0), y(null), (async () => {
|
|
2906
|
-
let i =
|
|
2907
|
-
if (!a && !i && (a = await
|
|
2908
|
-
let n = await t(
|
|
2909
|
-
n && (a = await
|
|
2959
|
+
let i = V.includes("?X-Amz-"), a = null, o = null;
|
|
2960
|
+
if (!a && !i && (a = await Mn(V, e.signal)), !a && !i) try {
|
|
2961
|
+
let n = await t(V);
|
|
2962
|
+
n && (a = await Mn(n, e.signal) || await Nn(n, void 0, e.signal));
|
|
2910
2963
|
} catch (e) {
|
|
2911
2964
|
console.warn("[attachment] signPreviewUrl failed:", e);
|
|
2912
2965
|
}
|
|
2913
2966
|
if (!a && !i) try {
|
|
2914
|
-
let t = await n(
|
|
2967
|
+
let t = await n(V);
|
|
2915
2968
|
if (t) {
|
|
2916
2969
|
let n = { "X-Requested-With": "XMLHttpRequest" };
|
|
2917
2970
|
t.forEach((e, t) => {
|
|
2918
2971
|
n[t] = e;
|
|
2919
2972
|
});
|
|
2920
2973
|
try {
|
|
2921
|
-
a = await
|
|
2974
|
+
a = await Nn(V, n, e.signal);
|
|
2922
2975
|
} catch (e) {
|
|
2923
2976
|
console.warn("[attachment] signed headers XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
2924
2977
|
}
|
|
@@ -2927,18 +2980,18 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2927
2980
|
console.warn("[attachment] signPreviewUrlHeaders failed:", e);
|
|
2928
2981
|
}
|
|
2929
2982
|
if (!a) try {
|
|
2930
|
-
a = await
|
|
2983
|
+
a = await Nn(V, i ? void 0 : { "X-Requested-With": "XMLHttpRequest" }, e.signal);
|
|
2931
2984
|
} catch (e) {
|
|
2932
2985
|
console.warn("[attachment] plain XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
2933
2986
|
}
|
|
2934
2987
|
if (!a) throw o || /* @__PURE__ */ Error("所有 fetch 方法均失败");
|
|
2935
2988
|
if (!r) return;
|
|
2936
|
-
d(a), N.current =
|
|
2989
|
+
d(a), N.current = V;
|
|
2937
2990
|
let s = URL.createObjectURL(new Blob([a], { type: "application/octet-stream" }));
|
|
2938
2991
|
m(s), g(!1);
|
|
2939
2992
|
})().catch((e) => {
|
|
2940
2993
|
if (r && !(e instanceof DOMException && e.name === "AbortError")) {
|
|
2941
|
-
if (N.current ===
|
|
2994
|
+
if (N.current === V) {
|
|
2942
2995
|
g(!1);
|
|
2943
2996
|
return;
|
|
2944
2997
|
}
|
|
@@ -2947,49 +3000,49 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2947
3000
|
}), () => {
|
|
2948
3001
|
r = !1, e.abort();
|
|
2949
3002
|
};
|
|
2950
|
-
}, [c,
|
|
3003
|
+
}, [c, V]), x(() => () => {
|
|
2951
3004
|
p && URL.revokeObjectURL(p), d(null);
|
|
2952
3005
|
}, []), x(() => () => {
|
|
2953
3006
|
p && URL.revokeObjectURL(p), m(null), d(null), N.current = null;
|
|
2954
|
-
}, [
|
|
3007
|
+
}, [V]), x(() => {
|
|
2955
3008
|
if (k !== "success" && k !== "error") return;
|
|
2956
3009
|
let e = window.setTimeout(() => A(null), 2400);
|
|
2957
3010
|
return () => window.clearTimeout(e);
|
|
2958
3011
|
}, [k]);
|
|
2959
|
-
let
|
|
3012
|
+
let K = b(async () => {
|
|
2960
3013
|
E(!0), A("loading");
|
|
2961
3014
|
try {
|
|
2962
3015
|
if (p) {
|
|
2963
3016
|
let e = document.createElement("a");
|
|
2964
|
-
e.href = p, e.download =
|
|
3017
|
+
e.href = p, e.download = H, document.body.appendChild(e), e.click(), document.body.removeChild(e), A("success");
|
|
2965
3018
|
return;
|
|
2966
3019
|
}
|
|
2967
|
-
let e =
|
|
3020
|
+
let e = V.includes("?X-Amz-"), r = null;
|
|
2968
3021
|
if (!e) try {
|
|
2969
|
-
let e = await t(
|
|
3022
|
+
let e = await t(V);
|
|
2970
3023
|
e && (r = await fetch(e, { headers: { "X-Requested-With": "XMLHttpRequest" } }), r.ok || (r = null));
|
|
2971
3024
|
} catch {}
|
|
2972
3025
|
if (!r && !e) try {
|
|
2973
|
-
let e = await n(
|
|
2974
|
-
e && (r = await fetch(
|
|
3026
|
+
let e = await n(V);
|
|
3027
|
+
e && (r = await fetch(V, { headers: (() => {
|
|
2975
3028
|
let t = new Headers(e);
|
|
2976
3029
|
return t.set("X-Requested-With", "XMLHttpRequest"), t;
|
|
2977
3030
|
})() }), r.ok || (r = null));
|
|
2978
3031
|
} catch {}
|
|
2979
|
-
if (r ||= await fetch(
|
|
3032
|
+
if (r ||= await fetch(V, { headers: { "X-Requested-With": "XMLHttpRequest" } }), !r || !r.ok) throw Error("下载失败");
|
|
2980
3033
|
let i = await r.blob(), a = URL.createObjectURL(i), o = document.createElement("a");
|
|
2981
|
-
o.href = a, o.download =
|
|
3034
|
+
o.href = a, o.download = H, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(a), A("success");
|
|
2982
3035
|
} catch (e) {
|
|
2983
3036
|
console.error("[attachment] download failed:", e), A("error");
|
|
2984
3037
|
} finally {
|
|
2985
3038
|
E(!1);
|
|
2986
3039
|
}
|
|
2987
3040
|
}, [
|
|
2988
|
-
|
|
2989
|
-
|
|
3041
|
+
V,
|
|
3042
|
+
H,
|
|
2990
3043
|
p
|
|
2991
3044
|
]);
|
|
2992
|
-
return /* @__PURE__ */ O(
|
|
3045
|
+
return /* @__PURE__ */ O(I, {
|
|
2993
3046
|
ref: j,
|
|
2994
3047
|
as: "div",
|
|
2995
3048
|
className: `attachment-embed group/att ${i ? "is-selected" : ""}`,
|
|
@@ -3006,7 +3059,7 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3006
3059
|
className: "att-info",
|
|
3007
3060
|
children: [/* @__PURE__ */ D("span", {
|
|
3008
3061
|
className: "att-icon",
|
|
3009
|
-
children:
|
|
3062
|
+
children: W ? /* @__PURE__ */ O("svg", {
|
|
3010
3063
|
width: "22",
|
|
3011
3064
|
height: "22",
|
|
3012
3065
|
viewBox: "0 0 24 24",
|
|
@@ -3022,15 +3075,15 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3022
3075
|
/* @__PURE__ */ D("path", { d: "M12 9v4" }),
|
|
3023
3076
|
/* @__PURE__ */ D("path", { d: "M12 17h.01" })
|
|
3024
3077
|
]
|
|
3025
|
-
}) :
|
|
3078
|
+
}) : Dn(H)
|
|
3026
3079
|
}), /* @__PURE__ */ O("div", {
|
|
3027
3080
|
className: "att-meta",
|
|
3028
3081
|
children: [/* @__PURE__ */ D("span", {
|
|
3029
3082
|
className: "att-name",
|
|
3030
|
-
children:
|
|
3031
|
-
}),
|
|
3083
|
+
children: H
|
|
3084
|
+
}), le > 0 && /* @__PURE__ */ D("span", {
|
|
3032
3085
|
className: "att-size",
|
|
3033
|
-
children:
|
|
3086
|
+
children: En(le)
|
|
3034
3087
|
})]
|
|
3035
3088
|
})]
|
|
3036
3089
|
}), /* @__PURE__ */ O("div", {
|
|
@@ -3083,11 +3136,11 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3083
3136
|
}), /* @__PURE__ */ O("div", {
|
|
3084
3137
|
className: "att-actions",
|
|
3085
3138
|
children: [
|
|
3086
|
-
|
|
3139
|
+
V && kn(H) && /* @__PURE__ */ D("button", {
|
|
3087
3140
|
type: "button",
|
|
3088
3141
|
className: "att-btn",
|
|
3089
3142
|
onMouseDown: (e) => {
|
|
3090
|
-
e.preventDefault(), e.stopPropagation(),
|
|
3143
|
+
e.preventDefault(), e.stopPropagation(), me();
|
|
3091
3144
|
},
|
|
3092
3145
|
title: f("editor.attachment.preview"),
|
|
3093
3146
|
"aria-label": f("editor.attachment.preview"),
|
|
@@ -3113,8 +3166,8 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3113
3166
|
/* @__PURE__ */ D("button", {
|
|
3114
3167
|
type: "button",
|
|
3115
3168
|
className: "att-btn",
|
|
3116
|
-
onClick:
|
|
3117
|
-
disabled: S ||
|
|
3169
|
+
onClick: K,
|
|
3170
|
+
disabled: S || W,
|
|
3118
3171
|
title: S ? "正在准备下载" : f("editor.attachment.download"),
|
|
3119
3172
|
"aria-label": S ? "正在准备下载" : f("editor.attachment.download"),
|
|
3120
3173
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -3136,7 +3189,7 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3136
3189
|
type: "button",
|
|
3137
3190
|
className: "att-btn att-btn--del",
|
|
3138
3191
|
onClick: () => {
|
|
3139
|
-
!o ||
|
|
3192
|
+
!o || pn() || ($(!0), ne(!0));
|
|
3140
3193
|
},
|
|
3141
3194
|
title: f("editor.attachment.delete"),
|
|
3142
3195
|
"aria-label": f("editor.attachment.delete"),
|
|
@@ -3160,7 +3213,7 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3160
3213
|
})]
|
|
3161
3214
|
}), c && /* @__PURE__ */ O("div", {
|
|
3162
3215
|
ref: M,
|
|
3163
|
-
className: `att-preview-wrap ${
|
|
3216
|
+
className: `att-preview-wrap ${z === "web" ? "is-web-fs" : ""}`,
|
|
3164
3217
|
style: {
|
|
3165
3218
|
position: "relative",
|
|
3166
3219
|
height: 500,
|
|
@@ -3168,7 +3221,7 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3168
3221
|
background: "#fff"
|
|
3169
3222
|
},
|
|
3170
3223
|
children: [/* @__PURE__ */ D("div", {
|
|
3171
|
-
ref:
|
|
3224
|
+
ref: L,
|
|
3172
3225
|
className: "att-preview-scroll",
|
|
3173
3226
|
style: {
|
|
3174
3227
|
height: "100%",
|
|
@@ -3177,7 +3230,7 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3177
3230
|
children: h && !u && !p ? /* @__PURE__ */ D("div", {
|
|
3178
3231
|
className: "flex items-center justify-center h-full text-default-400 text-sm",
|
|
3179
3232
|
children: f("editor.attachment.loadingPreview")
|
|
3180
|
-
}) : (_ ||
|
|
3233
|
+
}) : (_ || se) && !u && !p ? /* @__PURE__ */ O("div", {
|
|
3181
3234
|
className: "flex h-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-default-500",
|
|
3182
3235
|
children: [/* @__PURE__ */ D("div", {
|
|
3183
3236
|
className: "font-medium text-default-700",
|
|
@@ -3192,15 +3245,15 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3192
3245
|
style: { background: "#fff" },
|
|
3193
3246
|
children: f("editor.attachment.loadingPreview")
|
|
3194
3247
|
}),
|
|
3195
|
-
children: u || p ||
|
|
3248
|
+
children: u || p || V ? ae ? /* @__PURE__ */ D(xn, {
|
|
3196
3249
|
buffer: u || void 0,
|
|
3197
|
-
url: p ||
|
|
3198
|
-
name:
|
|
3199
|
-
filename:
|
|
3200
|
-
type:
|
|
3201
|
-
size:
|
|
3202
|
-
options:
|
|
3203
|
-
}, `${
|
|
3250
|
+
url: p || V,
|
|
3251
|
+
name: H,
|
|
3252
|
+
filename: H,
|
|
3253
|
+
type: U,
|
|
3254
|
+
size: le || u?.byteLength || 0,
|
|
3255
|
+
options: ue
|
|
3256
|
+
}, `${V}-${re}`) : /* @__PURE__ */ D("div", {
|
|
3204
3257
|
className: "flex h-full items-center justify-center text-sm text-default-400",
|
|
3205
3258
|
children: "正在加载预览引擎..."
|
|
3206
3259
|
}) : /* @__PURE__ */ D("div", {
|
|
@@ -3227,15 +3280,15 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3227
3280
|
},
|
|
3228
3281
|
children: [/* @__PURE__ */ D("button", {
|
|
3229
3282
|
type: "button",
|
|
3230
|
-
onClick:
|
|
3231
|
-
title:
|
|
3232
|
-
"aria-label":
|
|
3283
|
+
onClick: fe,
|
|
3284
|
+
title: z === "web" ? "退出网页全屏" : "网页全屏",
|
|
3285
|
+
"aria-label": z === "web" ? "退出网页全屏" : "网页全屏",
|
|
3233
3286
|
style: {
|
|
3234
3287
|
width: 28,
|
|
3235
3288
|
height: 28,
|
|
3236
3289
|
borderRadius: 6,
|
|
3237
3290
|
border: "none",
|
|
3238
|
-
background:
|
|
3291
|
+
background: z === "web" ? "#e4e4e7" : "transparent",
|
|
3239
3292
|
cursor: "pointer",
|
|
3240
3293
|
display: "flex",
|
|
3241
3294
|
alignItems: "center",
|
|
@@ -3244,10 +3297,10 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3244
3297
|
transition: "background 0.12s"
|
|
3245
3298
|
},
|
|
3246
3299
|
onMouseEnter: (e) => {
|
|
3247
|
-
|
|
3300
|
+
z !== "web" && (e.currentTarget.style.background = "#f4f4f5");
|
|
3248
3301
|
},
|
|
3249
3302
|
onMouseLeave: (e) => {
|
|
3250
|
-
|
|
3303
|
+
z !== "web" && (e.currentTarget.style.background = "transparent");
|
|
3251
3304
|
},
|
|
3252
3305
|
children: /* @__PURE__ */ D("svg", {
|
|
3253
3306
|
width: "14",
|
|
@@ -3265,15 +3318,15 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3265
3318
|
})
|
|
3266
3319
|
}), /* @__PURE__ */ D("button", {
|
|
3267
3320
|
type: "button",
|
|
3268
|
-
onClick:
|
|
3269
|
-
title:
|
|
3270
|
-
"aria-label":
|
|
3321
|
+
onClick: pe,
|
|
3322
|
+
title: z === "native" ? "退出全屏" : "全屏",
|
|
3323
|
+
"aria-label": z === "native" ? "退出全屏" : "全屏",
|
|
3271
3324
|
style: {
|
|
3272
3325
|
width: 28,
|
|
3273
3326
|
height: 28,
|
|
3274
3327
|
borderRadius: 6,
|
|
3275
3328
|
border: "none",
|
|
3276
|
-
background:
|
|
3329
|
+
background: z === "native" ? "#e4e4e7" : "transparent",
|
|
3277
3330
|
cursor: "pointer",
|
|
3278
3331
|
display: "flex",
|
|
3279
3332
|
alignItems: "center",
|
|
@@ -3282,10 +3335,10 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3282
3335
|
transition: "background 0.12s"
|
|
3283
3336
|
},
|
|
3284
3337
|
onMouseEnter: (e) => {
|
|
3285
|
-
|
|
3338
|
+
z !== "native" && (e.currentTarget.style.background = "#f4f4f5");
|
|
3286
3339
|
},
|
|
3287
3340
|
onMouseLeave: (e) => {
|
|
3288
|
-
|
|
3341
|
+
z !== "native" && (e.currentTarget.style.background = "transparent");
|
|
3289
3342
|
},
|
|
3290
3343
|
children: /* @__PURE__ */ D("svg", {
|
|
3291
3344
|
width: "14",
|
|
@@ -3304,24 +3357,24 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3304
3357
|
})]
|
|
3305
3358
|
})]
|
|
3306
3359
|
})]
|
|
3307
|
-
}), /* @__PURE__ */ D(
|
|
3308
|
-
open:
|
|
3360
|
+
}), /* @__PURE__ */ D(vn, {
|
|
3361
|
+
open: te,
|
|
3309
3362
|
title: "确认删除附件",
|
|
3310
|
-
message:
|
|
3363
|
+
message: W ? "此操作将删除该附件节点,不可撤销。" : `此操作将同时删除对象存储中的文件(${H}),不可撤销。`,
|
|
3311
3364
|
onCancel: () => {
|
|
3312
|
-
$(!1),
|
|
3365
|
+
$(!1), ne(!1);
|
|
3313
3366
|
},
|
|
3314
3367
|
onConfirm: async () => {
|
|
3315
3368
|
try {
|
|
3316
3369
|
if (a) {
|
|
3317
|
-
let e =
|
|
3370
|
+
let e = R.current, t = e?.from ?? a.state.selection.from, n = e?.to ?? a.state.selection.to, r = [];
|
|
3318
3371
|
a.state.doc.nodesBetween(t, n, (e) => {
|
|
3319
|
-
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(
|
|
3372
|
+
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(Vt(e.attrs.src));
|
|
3320
3373
|
}), await Promise.all(r), $(!1), await new Promise((e) => setTimeout(e, 300)), a.chain().focus().setTextSelection({
|
|
3321
3374
|
from: t,
|
|
3322
3375
|
to: n
|
|
3323
3376
|
}).deleteSelection().run();
|
|
3324
|
-
} else await
|
|
3377
|
+
} else await Vt(V), $(!1), await new Promise((e) => setTimeout(e, 300)), r();
|
|
3325
3378
|
} catch {
|
|
3326
3379
|
$(!1);
|
|
3327
3380
|
}
|
|
@@ -3331,13 +3384,13 @@ function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3331
3384
|
}
|
|
3332
3385
|
//#endregion
|
|
3333
3386
|
//#region src/editor/embeds/attachment.ts
|
|
3334
|
-
var
|
|
3387
|
+
var Fn = re.create({
|
|
3335
3388
|
name: "attachmentEmbed",
|
|
3336
3389
|
group: "block",
|
|
3337
3390
|
atom: !0,
|
|
3338
3391
|
inline: !1,
|
|
3339
3392
|
addNodeView() {
|
|
3340
|
-
return
|
|
3393
|
+
return L(Pn);
|
|
3341
3394
|
},
|
|
3342
3395
|
addAttributes() {
|
|
3343
3396
|
return {
|
|
@@ -3386,7 +3439,7 @@ var Nn = oe.create({
|
|
|
3386
3439
|
});
|
|
3387
3440
|
//#endregion
|
|
3388
3441
|
//#region src/editor/embeds/audio-view.tsx
|
|
3389
|
-
function
|
|
3442
|
+
function In({ node: e, deleteNode: t, editor: r }) {
|
|
3390
3443
|
let i = e.attrs.src || "", a = e.attrs.name || i.split("/").pop()?.split("?")[0] || "audio", [o, s] = T(!1), c = r?.isEditable ?? !0;
|
|
3391
3444
|
x(() => () => {
|
|
3392
3445
|
i.startsWith("blob:") && URL.revokeObjectURL(i);
|
|
@@ -3418,7 +3471,7 @@ function Pn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3418
3471
|
})(), () => {
|
|
3419
3472
|
e = !0, m.current &&= (URL.revokeObjectURL(m.current), null);
|
|
3420
3473
|
};
|
|
3421
|
-
}, [i]), /* @__PURE__ */ O(
|
|
3474
|
+
}, [i]), /* @__PURE__ */ O(I, {
|
|
3422
3475
|
as: "div",
|
|
3423
3476
|
className: "audio-embed group/audio",
|
|
3424
3477
|
style: { margin: "1rem 0" },
|
|
@@ -3452,7 +3505,7 @@ function Pn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3452
3505
|
type: "button",
|
|
3453
3506
|
className: "audio-embed-btn audio-embed-btn--del",
|
|
3454
3507
|
onClick: () => {
|
|
3455
|
-
|
|
3508
|
+
pn() || ($(!0), s(!0));
|
|
3456
3509
|
},
|
|
3457
3510
|
title: "删除",
|
|
3458
3511
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -3498,7 +3551,7 @@ function Pn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3498
3551
|
}), "音频文件缺失"]
|
|
3499
3552
|
})
|
|
3500
3553
|
})]
|
|
3501
|
-
}), /* @__PURE__ */ D(
|
|
3554
|
+
}), /* @__PURE__ */ D(vn, {
|
|
3502
3555
|
open: o,
|
|
3503
3556
|
title: "确认删除音频",
|
|
3504
3557
|
message: `此操作将同时删除对象存储中的文件(${a}),不可撤销。`,
|
|
@@ -3507,7 +3560,7 @@ function Pn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3507
3560
|
},
|
|
3508
3561
|
onConfirm: async () => {
|
|
3509
3562
|
try {
|
|
3510
|
-
await
|
|
3563
|
+
await Vt(i);
|
|
3511
3564
|
} catch {}
|
|
3512
3565
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3513
3566
|
}
|
|
@@ -3516,25 +3569,25 @@ function Pn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3516
3569
|
}
|
|
3517
3570
|
//#endregion
|
|
3518
3571
|
//#region src/editor/embeds/audio.ts
|
|
3519
|
-
function
|
|
3572
|
+
function Ln(e) {
|
|
3520
3573
|
return /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|$)/i.test(e) || /\/.*\.(mp3|wav|ogg|flac)/i.test(e);
|
|
3521
3574
|
}
|
|
3522
|
-
var
|
|
3575
|
+
var Rn = re.create({
|
|
3523
3576
|
name: "audioEmbed",
|
|
3524
3577
|
group: "block",
|
|
3525
3578
|
atom: !0,
|
|
3526
3579
|
inline: !1,
|
|
3527
3580
|
addNodeView() {
|
|
3528
|
-
return
|
|
3581
|
+
return L(In);
|
|
3529
3582
|
},
|
|
3530
3583
|
addProseMirrorPlugins() {
|
|
3531
|
-
return [new
|
|
3584
|
+
return [new z({ props: { handlePaste(e, t) {
|
|
3532
3585
|
let n = t.clipboardData?.getData("text/plain");
|
|
3533
3586
|
if (!n) return !1;
|
|
3534
3587
|
let r = n.split(/\r?\n/);
|
|
3535
3588
|
for (let n of r) {
|
|
3536
3589
|
let r = n.trim();
|
|
3537
|
-
if (!r || r.includes(" ") || !
|
|
3590
|
+
if (!r || r.includes(" ") || !Ln(r)) continue;
|
|
3538
3591
|
t.preventDefault();
|
|
3539
3592
|
let i = e.state.schema.nodes.audioEmbed.create({ src: r });
|
|
3540
3593
|
return e.dispatch(e.state.tr.replaceSelectionWith(i)), !0;
|
|
@@ -3581,17 +3634,17 @@ var In = oe.create({
|
|
|
3581
3634
|
});
|
|
3582
3635
|
//#endregion
|
|
3583
3636
|
//#region src/editor/embeds/video-view.tsx
|
|
3584
|
-
function
|
|
3637
|
+
function zn(e) {
|
|
3585
3638
|
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";
|
|
3586
3639
|
}
|
|
3587
|
-
function
|
|
3640
|
+
function Bn(e) {
|
|
3588
3641
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
3589
3642
|
if (t) return t[0];
|
|
3590
3643
|
let n = e.match(/av(\d+)/i);
|
|
3591
3644
|
return n ? n[0] : e;
|
|
3592
3645
|
}
|
|
3593
|
-
function
|
|
3594
|
-
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ?
|
|
3646
|
+
function Vn({ node: e, deleteNode: t, editor: n }) {
|
|
3647
|
+
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ? zn(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(vn, {
|
|
3595
3648
|
open: o,
|
|
3596
3649
|
title: "确认删除视频",
|
|
3597
3650
|
message: "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
@@ -3600,7 +3653,7 @@ function zn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3600
3653
|
},
|
|
3601
3654
|
onConfirm: async () => {
|
|
3602
3655
|
try {
|
|
3603
|
-
await
|
|
3656
|
+
await Vt(r);
|
|
3604
3657
|
} catch {}
|
|
3605
3658
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3606
3659
|
}
|
|
@@ -3614,7 +3667,7 @@ function zn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3614
3667
|
e && (e.style.position === "fixed" ? A() : (e.style.position = "fixed", e.style.inset = "0", e.style.zIndex = "99999", e.style.borderRadius = "0", document.body.style.overflow = "hidden"));
|
|
3615
3668
|
}, [A]), N = b(() => {
|
|
3616
3669
|
k.current = window.scrollY, S.current?.requestFullscreen?.();
|
|
3617
|
-
}, []),
|
|
3670
|
+
}, []), P = b(() => {
|
|
3618
3671
|
let e = v.current?.closest(".video-embed--direct") || v.current;
|
|
3619
3672
|
e && (k.current = window.scrollY, e.requestFullscreen?.());
|
|
3620
3673
|
}, []);
|
|
@@ -3703,8 +3756,8 @@ function zn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3703
3756
|
}, [a, h]), x(() => {
|
|
3704
3757
|
u && (_.current?.destroy(), _.current = null);
|
|
3705
3758
|
}, [u]), a === "bilibili") {
|
|
3706
|
-
let e =
|
|
3707
|
-
return /* @__PURE__ */ O(
|
|
3759
|
+
let e = Bn(r);
|
|
3760
|
+
return /* @__PURE__ */ O(I, {
|
|
3708
3761
|
as: "div",
|
|
3709
3762
|
className: "video-embed video-embed--bilibili group/video",
|
|
3710
3763
|
style: { margin: "1rem 0" },
|
|
@@ -3780,7 +3833,7 @@ function zn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3780
3833
|
className: "video-fs-btn video-fs-btn--del",
|
|
3781
3834
|
title: "删除",
|
|
3782
3835
|
onClick: () => {
|
|
3783
|
-
|
|
3836
|
+
pn() || ($(!0), s(!0));
|
|
3784
3837
|
},
|
|
3785
3838
|
children: /* @__PURE__ */ D("svg", {
|
|
3786
3839
|
width: "12",
|
|
@@ -3822,7 +3875,7 @@ function zn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3822
3875
|
}), m]
|
|
3823
3876
|
});
|
|
3824
3877
|
}
|
|
3825
|
-
return a === "xiaohongshu" ? /* @__PURE__ */ O(
|
|
3878
|
+
return a === "xiaohongshu" ? /* @__PURE__ */ O(I, {
|
|
3826
3879
|
as: "div",
|
|
3827
3880
|
className: "video-embed video-embed--xiaohongshu",
|
|
3828
3881
|
style: {
|
|
@@ -3868,7 +3921,7 @@ function zn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3868
3921
|
},
|
|
3869
3922
|
children: "在小红书中打开 →"
|
|
3870
3923
|
})] })]
|
|
3871
|
-
}) : /* @__PURE__ */ O(
|
|
3924
|
+
}) : /* @__PURE__ */ O(I, {
|
|
3872
3925
|
as: "div",
|
|
3873
3926
|
className: "video-embed video-embed--direct group/video",
|
|
3874
3927
|
style: {
|
|
@@ -3887,7 +3940,7 @@ function zn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3887
3940
|
className: "video-fs-btn video-fs-btn--del",
|
|
3888
3941
|
title: "删除",
|
|
3889
3942
|
onClick: () => {
|
|
3890
|
-
|
|
3943
|
+
pn() || ($(!0), s(!0));
|
|
3891
3944
|
},
|
|
3892
3945
|
children: /* @__PURE__ */ D("svg", {
|
|
3893
3946
|
width: "12",
|
|
@@ -3906,7 +3959,7 @@ function zn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3906
3959
|
type: "button",
|
|
3907
3960
|
className: "video-fs-btn",
|
|
3908
3961
|
title: "全屏",
|
|
3909
|
-
onClick:
|
|
3962
|
+
onClick: P,
|
|
3910
3963
|
children: /* @__PURE__ */ D("svg", {
|
|
3911
3964
|
width: "12",
|
|
3912
3965
|
height: "12",
|
|
@@ -4044,33 +4097,33 @@ function zn({ node: e, deleteNode: t, editor: n }) {
|
|
|
4044
4097
|
}
|
|
4045
4098
|
//#endregion
|
|
4046
4099
|
//#region src/editor/embeds/video.ts
|
|
4047
|
-
function
|
|
4100
|
+
function Hn(e) {
|
|
4048
4101
|
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";
|
|
4049
4102
|
}
|
|
4050
|
-
function
|
|
4103
|
+
function Un(e) {
|
|
4051
4104
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
4052
4105
|
if (t) return t[0];
|
|
4053
4106
|
let n = e.match(/av(\d+)/i);
|
|
4054
4107
|
return n ? n[0] : e;
|
|
4055
4108
|
}
|
|
4056
|
-
function
|
|
4109
|
+
function Wn(e) {
|
|
4057
4110
|
let t = e.match(/explore\/([a-zA-Z0-9]+)/);
|
|
4058
4111
|
return t ? t[1] : e;
|
|
4059
4112
|
}
|
|
4060
|
-
var
|
|
4113
|
+
var Gn = re.create({
|
|
4061
4114
|
name: "videoEmbed",
|
|
4062
4115
|
group: "block",
|
|
4063
4116
|
atom: !0,
|
|
4064
4117
|
inline: !1,
|
|
4065
4118
|
addNodeView() {
|
|
4066
|
-
return
|
|
4119
|
+
return L(Vn);
|
|
4067
4120
|
},
|
|
4068
4121
|
addProseMirrorPlugins() {
|
|
4069
|
-
return [new
|
|
4122
|
+
return [new z({ props: {
|
|
4070
4123
|
handleKeyDown(e, t) {
|
|
4071
4124
|
if (t.key !== " ") return !1;
|
|
4072
4125
|
let n = e.state.selection;
|
|
4073
|
-
if (n instanceof
|
|
4126
|
+
if (n instanceof ie && n.node.type.name === "videoEmbed") {
|
|
4074
4127
|
t.preventDefault();
|
|
4075
4128
|
let r = e.nodeDOM(n.from);
|
|
4076
4129
|
if (r) {
|
|
@@ -4088,7 +4141,7 @@ var Un = oe.create({
|
|
|
4088
4141
|
for (let n of r) {
|
|
4089
4142
|
let r = n.trim();
|
|
4090
4143
|
if (!r || r.includes(" ")) continue;
|
|
4091
|
-
let i =
|
|
4144
|
+
let i = Hn(r);
|
|
4092
4145
|
if (i === "unknown") continue;
|
|
4093
4146
|
t.preventDefault();
|
|
4094
4147
|
let a = e.state.schema.nodes.videoEmbed.create({
|
|
@@ -4120,7 +4173,7 @@ var Un = oe.create({
|
|
|
4120
4173
|
let t = e, n = t.getAttribute("src") || t.getAttribute("data-src") || "";
|
|
4121
4174
|
return {
|
|
4122
4175
|
src: n,
|
|
4123
|
-
source:
|
|
4176
|
+
source: Hn(n)
|
|
4124
4177
|
};
|
|
4125
4178
|
}
|
|
4126
4179
|
},
|
|
@@ -4129,9 +4182,9 @@ var Un = oe.create({
|
|
|
4129
4182
|
];
|
|
4130
4183
|
},
|
|
4131
4184
|
renderHTML({ HTMLAttributes: e }) {
|
|
4132
|
-
let t = e.src || "", n =
|
|
4185
|
+
let t = e.src || "", n = Hn(t);
|
|
4133
4186
|
if (n === "bilibili") {
|
|
4134
|
-
let e =
|
|
4187
|
+
let e = Un(t);
|
|
4135
4188
|
return [
|
|
4136
4189
|
"div",
|
|
4137
4190
|
{
|
|
@@ -4152,7 +4205,7 @@ var Un = oe.create({
|
|
|
4152
4205
|
}]
|
|
4153
4206
|
];
|
|
4154
4207
|
}
|
|
4155
|
-
if (n === "xiaohongshu") return
|
|
4208
|
+
if (n === "xiaohongshu") return Wn(t), [
|
|
4156
4209
|
"div",
|
|
4157
4210
|
{
|
|
4158
4211
|
"data-video-embed": "xiaohongshu",
|
|
@@ -4204,7 +4257,7 @@ var Un = oe.create({
|
|
|
4204
4257
|
},
|
|
4205
4258
|
addCommands() {
|
|
4206
4259
|
return { insertVideo: (e) => ({ chain: t }) => {
|
|
4207
|
-
let n =
|
|
4260
|
+
let n = Hn(e.src);
|
|
4208
4261
|
return t().insertContent({
|
|
4209
4262
|
type: this.name,
|
|
4210
4263
|
attrs: {
|
|
@@ -4214,13 +4267,13 @@ var Un = oe.create({
|
|
|
4214
4267
|
}).focus().run();
|
|
4215
4268
|
} };
|
|
4216
4269
|
}
|
|
4217
|
-
}),
|
|
4218
|
-
async function
|
|
4219
|
-
|
|
4220
|
-
let t =
|
|
4270
|
+
}), Kn = null;
|
|
4271
|
+
async function qn(e) {
|
|
4272
|
+
Kn ||= await import("beautiful-mermaid");
|
|
4273
|
+
let t = Kn.renderMermaidSVG;
|
|
4221
4274
|
return t(e);
|
|
4222
4275
|
}
|
|
4223
|
-
var
|
|
4276
|
+
var Jn = [
|
|
4224
4277
|
{
|
|
4225
4278
|
value: "javascript",
|
|
4226
4279
|
label: "JavaScript",
|
|
@@ -4381,7 +4434,7 @@ var Kn = [
|
|
|
4381
4434
|
label: "Plain Text",
|
|
4382
4435
|
color: "#6b7280"
|
|
4383
4436
|
}
|
|
4384
|
-
],
|
|
4437
|
+
], Yn = {
|
|
4385
4438
|
javascript: "js",
|
|
4386
4439
|
typescript: "ts",
|
|
4387
4440
|
python: "py",
|
|
@@ -4407,7 +4460,7 @@ var Kn = [
|
|
|
4407
4460
|
txt: "txt",
|
|
4408
4461
|
vue: "vue",
|
|
4409
4462
|
react: "jsx"
|
|
4410
|
-
},
|
|
4463
|
+
}, Xn = {
|
|
4411
4464
|
js: "javascript",
|
|
4412
4465
|
ts: "typescript",
|
|
4413
4466
|
py: "python",
|
|
@@ -4423,13 +4476,13 @@ var Kn = [
|
|
|
4423
4476
|
jsx: "javascript",
|
|
4424
4477
|
tsx: "typescript"
|
|
4425
4478
|
};
|
|
4426
|
-
function
|
|
4479
|
+
function Zn(e) {
|
|
4427
4480
|
return e instanceof Element && !!e.closest(".cb-code-area");
|
|
4428
4481
|
}
|
|
4429
|
-
function
|
|
4430
|
-
let o = n?.isEditable ?? !0, s = !o, [c, l] = T(!1), [u, d] = T(!1), [f, m] = T(!1), [h, g] = T(""), [_, v] = T(!1), [y, k] = T(null), [A, j] = T(null), [M, N] = T(!1), [
|
|
4431
|
-
|
|
4432
|
-
}, []),
|
|
4482
|
+
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(""), [_, v] = T(!1), [y, k] = T(null), [A, j] = T(null), [M, N] = T(!1), [P, L] = T([]), ee = w(null), te = w(null), ne = w(null), R = w(null), re = w(null), ie = e.attrs.language || "", z = Jn.find((e) => e.value === (Xn[ie] ?? ie)), B = ie === "mermaid", ae = b((e) => {
|
|
4484
|
+
Zn(e.target) || e.stopPropagation();
|
|
4485
|
+
}, []), oe = b(() => {
|
|
4433
4486
|
if (!n || typeof r != "function") return null;
|
|
4434
4487
|
let t = r();
|
|
4435
4488
|
return typeof t == "number" ? {
|
|
@@ -4440,18 +4493,18 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4440
4493
|
n,
|
|
4441
4494
|
r,
|
|
4442
4495
|
e.nodeSize
|
|
4443
|
-
]),
|
|
4444
|
-
o && (
|
|
4445
|
-
}, [
|
|
4496
|
+
]), se = b(() => {
|
|
4497
|
+
o && (pn() || (re.current = oe(), window.getSelection()?.removeAllRanges(), $(!0), v(!0)));
|
|
4498
|
+
}, [oe, o]), ce = C(() => e.textContent ? e.textContent.split("\n") : [""], [e.textContent]), V = ce.length, H = C(() => Array.from({ length: V }, (e, t) => t + 1), [V]), le = C(() => {
|
|
4446
4499
|
let e = h.trim().toLowerCase();
|
|
4447
|
-
return e ?
|
|
4500
|
+
return e ? Jn.filter((t) => t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e)) : Jn;
|
|
4448
4501
|
}, [h]);
|
|
4449
4502
|
x(() => {
|
|
4450
|
-
f && (g(""), setTimeout(() =>
|
|
4503
|
+
f && (g(""), setTimeout(() => te.current?.focus(), 50));
|
|
4451
4504
|
}, [f]), x(() => {
|
|
4452
4505
|
if (!f) return;
|
|
4453
4506
|
let e = (e) => {
|
|
4454
|
-
|
|
4507
|
+
ee.current && !ee.current.contains(e.target) && m(!1);
|
|
4455
4508
|
};
|
|
4456
4509
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
4457
4510
|
}, [f]), x(() => {
|
|
@@ -4462,10 +4515,10 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4462
4515
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
4463
4516
|
}, [f]), x(() => {
|
|
4464
4517
|
let e = (e) => {
|
|
4465
|
-
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && a && !
|
|
4518
|
+
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && a && !pn()) {
|
|
4466
4519
|
if (e.preventDefault(), e.stopPropagation(), n) {
|
|
4467
4520
|
let { from: e, to: t } = n.state.selection;
|
|
4468
|
-
|
|
4521
|
+
re.current = {
|
|
4469
4522
|
from: e,
|
|
4470
4523
|
to: t
|
|
4471
4524
|
};
|
|
@@ -4479,29 +4532,29 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4479
4532
|
n,
|
|
4480
4533
|
o
|
|
4481
4534
|
]);
|
|
4482
|
-
let
|
|
4483
|
-
|
|
4484
|
-
}, []),
|
|
4485
|
-
let e =
|
|
4535
|
+
let U = b((e) => {
|
|
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;
|
|
4486
4539
|
if (!e || !t) return;
|
|
4487
4540
|
t.style.width = `${e.clientWidth}px`;
|
|
4488
4541
|
let n = t.children, r = Array(n.length);
|
|
4489
4542
|
for (let e = 0; e < n.length; e++) r[e] = n[e].offsetHeight;
|
|
4490
|
-
|
|
4491
|
-
}, [
|
|
4543
|
+
U(r);
|
|
4544
|
+
}, [U]);
|
|
4492
4545
|
S(() => {
|
|
4493
|
-
|
|
4494
|
-
}, [
|
|
4495
|
-
let e =
|
|
4546
|
+
W();
|
|
4547
|
+
}, [W, ce]), x(() => {
|
|
4548
|
+
let e = ne.current;
|
|
4496
4549
|
if (!e) return;
|
|
4497
|
-
let t = new ResizeObserver(() =>
|
|
4498
|
-
return t.observe(e), window.addEventListener("resize",
|
|
4499
|
-
t.disconnect(), window.removeEventListener("resize",
|
|
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);
|
|
4500
4553
|
};
|
|
4501
|
-
}, [
|
|
4502
|
-
let
|
|
4554
|
+
}, [W]);
|
|
4555
|
+
let ue = b((e) => {
|
|
4503
4556
|
t({ language: e || null }), m(!1);
|
|
4504
|
-
}, [t]),
|
|
4557
|
+
}, [t]), de = b(() => {
|
|
4505
4558
|
if (o) {
|
|
4506
4559
|
if (n && r) {
|
|
4507
4560
|
let e = r();
|
|
@@ -4513,12 +4566,12 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4513
4566
|
n,
|
|
4514
4567
|
r,
|
|
4515
4568
|
o
|
|
4516
|
-
]),
|
|
4569
|
+
]), G = b(() => {
|
|
4517
4570
|
navigator.clipboard.writeText(e.textContent), l(!0), setTimeout(() => l(!1), 1500);
|
|
4518
|
-
}, [e.textContent]),
|
|
4519
|
-
let t =
|
|
4571
|
+
}, [e.textContent]), fe = b(() => {
|
|
4572
|
+
let t = Yn[ie] || "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");
|
|
4520
4573
|
a.href = i, a.download = n, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
4521
|
-
}, [e.textContent,
|
|
4574
|
+
}, [e.textContent, ie]), pe = b(async () => {
|
|
4522
4575
|
if (y || M) {
|
|
4523
4576
|
k(null), j(null), N(!1);
|
|
4524
4577
|
return;
|
|
@@ -4530,7 +4583,7 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4530
4583
|
j("代码块内容为空");
|
|
4531
4584
|
return;
|
|
4532
4585
|
}
|
|
4533
|
-
let n = p(await
|
|
4586
|
+
let n = p(await qn(t));
|
|
4534
4587
|
k(n);
|
|
4535
4588
|
} catch (e) {
|
|
4536
4589
|
j(e instanceof Error ? e.message : "Mermaid 渲染失败");
|
|
@@ -4541,9 +4594,9 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4541
4594
|
e.textContent,
|
|
4542
4595
|
y,
|
|
4543
4596
|
M
|
|
4544
|
-
]),
|
|
4545
|
-
className: `${
|
|
4546
|
-
style: { color:
|
|
4597
|
+
]), me = /* @__PURE__ */ O(E, { children: [z ? z.deviconClass ? /* @__PURE__ */ D("i", {
|
|
4598
|
+
className: `${z.deviconClass} colored cb-lang-icon`,
|
|
4599
|
+
style: { color: z.color }
|
|
4547
4600
|
}) : /* @__PURE__ */ D("span", {
|
|
4548
4601
|
className: "cb-lang-icon cb-lang-icon--auto",
|
|
4549
4602
|
children: "Tx"
|
|
@@ -4552,29 +4605,29 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4552
4605
|
children: "?"
|
|
4553
4606
|
}), /* @__PURE__ */ D("span", {
|
|
4554
4607
|
className: "cb-lang-label",
|
|
4555
|
-
children:
|
|
4608
|
+
children: z?.label || "自动"
|
|
4556
4609
|
})] });
|
|
4557
|
-
return /* @__PURE__ */ O(
|
|
4610
|
+
return /* @__PURE__ */ O(I, {
|
|
4558
4611
|
as: "div",
|
|
4559
4612
|
className: "code-block-node-view group/cb",
|
|
4560
|
-
onMouseDown:
|
|
4561
|
-
onTouchStart:
|
|
4613
|
+
onMouseDown: ae,
|
|
4614
|
+
onTouchStart: ae,
|
|
4562
4615
|
children: [
|
|
4563
4616
|
/* @__PURE__ */ O("div", {
|
|
4564
4617
|
className: "cb-header",
|
|
4565
4618
|
contentEditable: !1,
|
|
4566
4619
|
children: [/* @__PURE__ */ O("div", {
|
|
4567
4620
|
className: "cb-lang-wrap",
|
|
4568
|
-
ref:
|
|
4621
|
+
ref: ee,
|
|
4569
4622
|
contentEditable: !1,
|
|
4570
4623
|
children: [s ? /* @__PURE__ */ D("span", {
|
|
4571
4624
|
className: "cb-lang-trigger cb-lang-trigger--static",
|
|
4572
|
-
children:
|
|
4625
|
+
children: me
|
|
4573
4626
|
}) : /* @__PURE__ */ O("button", {
|
|
4574
4627
|
type: "button",
|
|
4575
4628
|
className: "cb-lang-trigger",
|
|
4576
4629
|
onClick: () => m(!f),
|
|
4577
|
-
children: [
|
|
4630
|
+
children: [me, /* @__PURE__ */ D("svg", {
|
|
4578
4631
|
className: `cb-lang-chevron${f ? " cb-lang-chevron--open" : ""}`,
|
|
4579
4632
|
width: "10",
|
|
4580
4633
|
height: "10",
|
|
@@ -4606,7 +4659,7 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4606
4659
|
d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
|
4607
4660
|
})
|
|
4608
4661
|
}), /* @__PURE__ */ D("input", {
|
|
4609
|
-
ref:
|
|
4662
|
+
ref: te,
|
|
4610
4663
|
className: "cb-lang-search",
|
|
4611
4664
|
type: "text",
|
|
4612
4665
|
placeholder: "搜索语言...",
|
|
@@ -4619,17 +4672,17 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4619
4672
|
children: [
|
|
4620
4673
|
/* @__PURE__ */ O("button", {
|
|
4621
4674
|
type: "button",
|
|
4622
|
-
className: `cb-lang-option${
|
|
4623
|
-
onClick: () =>
|
|
4675
|
+
className: `cb-lang-option${ie ? "" : " cb-lang-option--active"}`,
|
|
4676
|
+
onClick: () => ue(""),
|
|
4624
4677
|
children: [/* @__PURE__ */ D("span", {
|
|
4625
4678
|
className: "cb-lang-icon cb-lang-icon--auto",
|
|
4626
4679
|
children: "?"
|
|
4627
4680
|
}), /* @__PURE__ */ D("span", { children: "自动检测" })]
|
|
4628
4681
|
}),
|
|
4629
|
-
|
|
4682
|
+
le.map((e) => /* @__PURE__ */ O("button", {
|
|
4630
4683
|
type: "button",
|
|
4631
|
-
className: `cb-lang-option${
|
|
4632
|
-
onClick: () =>
|
|
4684
|
+
className: `cb-lang-option${ie === e.value ? " cb-lang-option--active" : ""}`,
|
|
4685
|
+
onClick: () => ue(e.value),
|
|
4633
4686
|
children: [e.deviconClass ? /* @__PURE__ */ D("i", {
|
|
4634
4687
|
className: `${e.deviconClass} colored cb-lang-icon`,
|
|
4635
4688
|
style: { color: e.color }
|
|
@@ -4638,7 +4691,7 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4638
4691
|
children: "Tx"
|
|
4639
4692
|
}), /* @__PURE__ */ D("span", { children: e.label })]
|
|
4640
4693
|
}, e.value)),
|
|
4641
|
-
|
|
4694
|
+
le.length === 0 && /* @__PURE__ */ D("div", {
|
|
4642
4695
|
className: "cb-lang-empty",
|
|
4643
4696
|
children: "无匹配语言"
|
|
4644
4697
|
})
|
|
@@ -4674,7 +4727,7 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4674
4727
|
/* @__PURE__ */ D("button", {
|
|
4675
4728
|
type: "button",
|
|
4676
4729
|
className: "cb-btn",
|
|
4677
|
-
onClick:
|
|
4730
|
+
onClick: G,
|
|
4678
4731
|
contentEditable: !1,
|
|
4679
4732
|
title: "复制",
|
|
4680
4733
|
children: c ? /* @__PURE__ */ D("svg", {
|
|
@@ -4704,7 +4757,7 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4704
4757
|
/* @__PURE__ */ D("button", {
|
|
4705
4758
|
type: "button",
|
|
4706
4759
|
className: "cb-btn",
|
|
4707
|
-
onClick:
|
|
4760
|
+
onClick: fe,
|
|
4708
4761
|
contentEditable: !1,
|
|
4709
4762
|
title: "下载",
|
|
4710
4763
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4723,7 +4776,7 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4723
4776
|
o && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("button", {
|
|
4724
4777
|
type: "button",
|
|
4725
4778
|
className: "cb-btn cb-btn--ai",
|
|
4726
|
-
onClick:
|
|
4779
|
+
onClick: de,
|
|
4727
4780
|
contentEditable: !1,
|
|
4728
4781
|
title: "写作助手",
|
|
4729
4782
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4741,7 +4794,7 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4741
4794
|
}), /* @__PURE__ */ D("button", {
|
|
4742
4795
|
type: "button",
|
|
4743
4796
|
className: "cb-btn cb-btn--del",
|
|
4744
|
-
onClick:
|
|
4797
|
+
onClick: se,
|
|
4745
4798
|
contentEditable: !1,
|
|
4746
4799
|
title: "删除代码块",
|
|
4747
4800
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4757,10 +4810,10 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4757
4810
|
})
|
|
4758
4811
|
})
|
|
4759
4812
|
})] }),
|
|
4760
|
-
|
|
4813
|
+
B && /* @__PURE__ */ D("button", {
|
|
4761
4814
|
type: "button",
|
|
4762
4815
|
className: "cb-btn cb-btn--diagram",
|
|
4763
|
-
onClick:
|
|
4816
|
+
onClick: pe,
|
|
4764
4817
|
contentEditable: !1,
|
|
4765
4818
|
title: y || M ? "取消渲染" : "渲染图表",
|
|
4766
4819
|
disabled: M,
|
|
@@ -4787,23 +4840,23 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4787
4840
|
className: "cb-line-numbers",
|
|
4788
4841
|
contentEditable: !1,
|
|
4789
4842
|
"aria-hidden": "true",
|
|
4790
|
-
children:
|
|
4843
|
+
children: H.map((e, t) => /* @__PURE__ */ D("span", {
|
|
4791
4844
|
className: "cb-line-num",
|
|
4792
|
-
style:
|
|
4845
|
+
style: P[t] ? { height: P[t] } : void 0,
|
|
4793
4846
|
children: e
|
|
4794
4847
|
}, e))
|
|
4795
4848
|
}),
|
|
4796
4849
|
/* @__PURE__ */ D("pre", {
|
|
4797
4850
|
className: "cb-code-pre",
|
|
4798
|
-
ref:
|
|
4799
|
-
children: /* @__PURE__ */ D(
|
|
4851
|
+
ref: ne,
|
|
4852
|
+
children: /* @__PURE__ */ D(F, { as: "code" })
|
|
4800
4853
|
}),
|
|
4801
4854
|
/* @__PURE__ */ D("div", {
|
|
4802
|
-
ref:
|
|
4855
|
+
ref: R,
|
|
4803
4856
|
className: "cb-code-mirror",
|
|
4804
4857
|
contentEditable: !1,
|
|
4805
4858
|
"aria-hidden": "true",
|
|
4806
|
-
children:
|
|
4859
|
+
children: ce.map((e, t) => /* @__PURE__ */ D("span", {
|
|
4807
4860
|
className: "cb-mirror-line",
|
|
4808
4861
|
children: e.length ? e : "\xA0"
|
|
4809
4862
|
}, t))
|
|
@@ -4831,7 +4884,7 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4831
4884
|
})
|
|
4832
4885
|
]
|
|
4833
4886
|
}),
|
|
4834
|
-
/* @__PURE__ */ D(
|
|
4887
|
+
/* @__PURE__ */ D(vn, {
|
|
4835
4888
|
open: _,
|
|
4836
4889
|
title: "确认删除代码块",
|
|
4837
4890
|
message: "此操作不可撤销。",
|
|
@@ -4840,7 +4893,7 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4840
4893
|
},
|
|
4841
4894
|
onConfirm: async () => {
|
|
4842
4895
|
if (await new Promise((e) => setTimeout(e, 300)), $(!1), n) {
|
|
4843
|
-
let e =
|
|
4896
|
+
let e = re.current ?? oe();
|
|
4844
4897
|
e ? n.chain().focus().setTextSelection(e).deleteSelection().run() : i();
|
|
4845
4898
|
} else i();
|
|
4846
4899
|
}
|
|
@@ -4850,7 +4903,7 @@ function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4850
4903
|
}
|
|
4851
4904
|
//#endregion
|
|
4852
4905
|
//#region src/editor/extensions/code-block.ts
|
|
4853
|
-
var
|
|
4906
|
+
var $n = [
|
|
4854
4907
|
{
|
|
4855
4908
|
value: "javascript",
|
|
4856
4909
|
label: "JavaScript"
|
|
@@ -4951,11 +5004,11 @@ var Zn = [
|
|
|
4951
5004
|
value: "mermaid",
|
|
4952
5005
|
label: "Mermaid"
|
|
4953
5006
|
}
|
|
4954
|
-
],
|
|
4955
|
-
|
|
4956
|
-
var
|
|
5007
|
+
], er = Se(xe);
|
|
5008
|
+
er.register({ dockerfile: be }), er.registerAlias("xml", ["vue", "html"]), er.registerAlias("javascript", ["react", "jsx"]), er.registerAlias("typescript", ["tsx"]);
|
|
5009
|
+
var tr = ye.extend({
|
|
4957
5010
|
addNodeView() {
|
|
4958
|
-
return
|
|
5011
|
+
return L(Qn);
|
|
4959
5012
|
},
|
|
4960
5013
|
parseHTML() {
|
|
4961
5014
|
return (this.parent?.() ?? []).map((e) => ({
|
|
@@ -4971,10 +5024,10 @@ var $n = be.extend({
|
|
|
4971
5024
|
}
|
|
4972
5025
|
}));
|
|
4973
5026
|
}
|
|
4974
|
-
}).configure({ lowlight:
|
|
5027
|
+
}).configure({ lowlight: er });
|
|
4975
5028
|
//#endregion
|
|
4976
5029
|
//#region src/editor/utils/import-choice-dialog.ts
|
|
4977
|
-
function
|
|
5030
|
+
function nr(e) {
|
|
4978
5031
|
return new Promise((t) => {
|
|
4979
5032
|
let n = document.createElement("div");
|
|
4980
5033
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5004,16 +5057,16 @@ function er(e) {
|
|
|
5004
5057
|
}
|
|
5005
5058
|
//#endregion
|
|
5006
5059
|
//#region src/editor/utils/local-media.ts
|
|
5007
|
-
var
|
|
5008
|
-
function
|
|
5060
|
+
var rr = /\.(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, ir = /^(?:mailto:|tel:|javascript:|about:|data:|blob:)/i;
|
|
5061
|
+
function ar(e) {
|
|
5009
5062
|
if (!e) return !1;
|
|
5010
5063
|
let t = e.trim();
|
|
5011
|
-
return !(!t || /^(?:https?:)?\/\//i.test(t) ||
|
|
5064
|
+
return !(!t || /^(?:https?:)?\/\//i.test(t) || ir.test(t) || t.startsWith("#"));
|
|
5012
5065
|
}
|
|
5013
|
-
function
|
|
5014
|
-
return
|
|
5066
|
+
function or(e) {
|
|
5067
|
+
return rr.test(e);
|
|
5015
5068
|
}
|
|
5016
|
-
function
|
|
5069
|
+
function sr(e) {
|
|
5017
5070
|
let t = e.trim();
|
|
5018
5071
|
t = t.replace(/^(?:file|app):\/\/(?:localhost)?/i, "");
|
|
5019
5072
|
try {
|
|
@@ -5021,26 +5074,26 @@ function ar(e) {
|
|
|
5021
5074
|
} catch {}
|
|
5022
5075
|
return t = t.replace(/\\/g, "/"), t = t.replace(/^\.\//, ""), t = t.replace(/^\/+/, ""), t = t.replace(/^[a-zA-Z]:\//, ""), t;
|
|
5023
5076
|
}
|
|
5024
|
-
function
|
|
5025
|
-
let t =
|
|
5077
|
+
function cr(e) {
|
|
5078
|
+
let t = sr(e), n = t.split("/").filter(Boolean);
|
|
5026
5079
|
return (n[n.length - 1] || t).toLowerCase();
|
|
5027
5080
|
}
|
|
5028
|
-
function
|
|
5081
|
+
function lr() {
|
|
5029
5082
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showDirectoryPicker == "function";
|
|
5030
5083
|
}
|
|
5031
|
-
async function
|
|
5032
|
-
if (!
|
|
5084
|
+
async function ur() {
|
|
5085
|
+
if (!lr()) return null;
|
|
5033
5086
|
try {
|
|
5034
5087
|
return await window.showDirectoryPicker.call(window, { mode: "read" }) ?? null;
|
|
5035
5088
|
} catch {
|
|
5036
5089
|
return null;
|
|
5037
5090
|
}
|
|
5038
5091
|
}
|
|
5039
|
-
function
|
|
5092
|
+
function dr() {
|
|
5040
5093
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showOpenFilePicker == "function";
|
|
5041
5094
|
}
|
|
5042
|
-
async function
|
|
5043
|
-
if (!
|
|
5095
|
+
async function fr() {
|
|
5096
|
+
if (!dr()) return null;
|
|
5044
5097
|
try {
|
|
5045
5098
|
let e = await window.showOpenFilePicker.call(window, { multiple: !0 });
|
|
5046
5099
|
return await Promise.all(e.map((e) => e.getFile()));
|
|
@@ -5048,7 +5101,7 @@ async function ur() {
|
|
|
5048
5101
|
return null;
|
|
5049
5102
|
}
|
|
5050
5103
|
}
|
|
5051
|
-
async function
|
|
5104
|
+
async function pr(e, t) {
|
|
5052
5105
|
if (t.length === 0) return { file: null };
|
|
5053
5106
|
let n = e;
|
|
5054
5107
|
for (let e = 0; e < t.length - 1; e++) try {
|
|
@@ -5070,7 +5123,7 @@ async function dr(e, t) {
|
|
|
5070
5123
|
return { file: null };
|
|
5071
5124
|
}
|
|
5072
5125
|
}
|
|
5073
|
-
async function
|
|
5126
|
+
async function mr(e, t, n = 5e3) {
|
|
5074
5127
|
let r = t.toLowerCase(), i = [e], a = 0, o;
|
|
5075
5128
|
for (; i.length > 0 && a < n;) {
|
|
5076
5129
|
let e = i.pop();
|
|
@@ -5092,37 +5145,37 @@ async function fr(e, t, n = 5e3) {
|
|
|
5092
5145
|
readError: o
|
|
5093
5146
|
};
|
|
5094
5147
|
}
|
|
5095
|
-
async function
|
|
5096
|
-
let n =
|
|
5148
|
+
async function hr(e, t) {
|
|
5149
|
+
let n = sr(t).split("/").filter(Boolean);
|
|
5097
5150
|
if (n.length === 0) return { file: null };
|
|
5098
5151
|
let r;
|
|
5099
5152
|
for (let t = 0; t < n.length; t++) {
|
|
5100
|
-
let i = await
|
|
5153
|
+
let i = await pr(e, n.slice(t));
|
|
5101
5154
|
if (i.file) return i;
|
|
5102
5155
|
i.readError && (r = i.readError);
|
|
5103
5156
|
}
|
|
5104
|
-
let i = await
|
|
5157
|
+
let i = await mr(e, n[n.length - 1]);
|
|
5105
5158
|
return i.file || i.readError ? i : {
|
|
5106
5159
|
file: null,
|
|
5107
5160
|
readError: r
|
|
5108
5161
|
};
|
|
5109
5162
|
}
|
|
5110
|
-
var
|
|
5163
|
+
var gr = {
|
|
5111
5164
|
image: "image",
|
|
5112
5165
|
videoEmbed: "video",
|
|
5113
5166
|
audioEmbed: "audio",
|
|
5114
5167
|
attachmentEmbed: "attachment"
|
|
5115
5168
|
};
|
|
5116
|
-
function
|
|
5169
|
+
function _r(e, t) {
|
|
5117
5170
|
let n = /* @__PURE__ */ new Set(), r = [];
|
|
5118
5171
|
return e.descendants((e) => {
|
|
5119
|
-
let i =
|
|
5172
|
+
let i = gr[e.type?.name];
|
|
5120
5173
|
if (i) {
|
|
5121
5174
|
let a = e.attrs?.src, o = `node:${a}`;
|
|
5122
|
-
typeof a == "string" &&
|
|
5175
|
+
typeof a == "string" && ar(a) && !n.has(o) && !t?.(a) && (n.add(o), r.push({
|
|
5123
5176
|
src: a,
|
|
5124
|
-
normalized:
|
|
5125
|
-
basename:
|
|
5177
|
+
normalized: sr(a),
|
|
5178
|
+
basename: cr(a),
|
|
5126
5179
|
kind: i,
|
|
5127
5180
|
isLink: !1
|
|
5128
5181
|
}));
|
|
@@ -5131,17 +5184,17 @@ function hr(e, t) {
|
|
|
5131
5184
|
if (e.isText && e.marks) for (let i of e.marks) {
|
|
5132
5185
|
if (i.type.name !== "link") continue;
|
|
5133
5186
|
let e = i.attrs?.href, a = `link:${e}`;
|
|
5134
|
-
typeof e == "string" &&
|
|
5187
|
+
typeof e == "string" && ar(e) && or(e) && !n.has(a) && !t?.(e) && (n.add(a), r.push({
|
|
5135
5188
|
src: e,
|
|
5136
|
-
normalized:
|
|
5137
|
-
basename:
|
|
5189
|
+
normalized: sr(e),
|
|
5190
|
+
basename: cr(e),
|
|
5138
5191
|
kind: "attachment",
|
|
5139
5192
|
isLink: !0
|
|
5140
5193
|
}));
|
|
5141
5194
|
}
|
|
5142
5195
|
}), r;
|
|
5143
5196
|
}
|
|
5144
|
-
function
|
|
5197
|
+
function vr(e, t, n) {
|
|
5145
5198
|
let r = t ? `${e}\n${t}` : e;
|
|
5146
5199
|
if (!r) return !1;
|
|
5147
5200
|
let i = [];
|
|
@@ -5149,30 +5202,30 @@ function gr(e, t, n) {
|
|
|
5149
5202
|
for (let e of r.matchAll(/!?\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g)) i.push(e[1]);
|
|
5150
5203
|
for (let e of r.matchAll(/<(?:img|video|audio|source)[^>]*\bsrc=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5151
5204
|
for (let e of r.matchAll(/<a[^>]*\bhref=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5152
|
-
return i.some((e) =>
|
|
5205
|
+
return i.some((e) => or(e) && ar(e) && !n?.(e));
|
|
5153
5206
|
}
|
|
5154
5207
|
//#endregion
|
|
5155
5208
|
//#region src/editor/extensions/image-upload.ts
|
|
5156
|
-
function
|
|
5209
|
+
function yr(e) {
|
|
5157
5210
|
if (e.type.startsWith("image/")) return "image";
|
|
5158
5211
|
if (e.type.startsWith("video/")) return "video";
|
|
5159
5212
|
if (e.type.startsWith("audio/")) return "audio";
|
|
5160
5213
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5161
5214
|
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";
|
|
5162
5215
|
}
|
|
5163
|
-
function
|
|
5216
|
+
function br(e) {
|
|
5164
5217
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5165
5218
|
return t === "md" || t === "markdown";
|
|
5166
5219
|
}
|
|
5167
|
-
async function
|
|
5168
|
-
let i = n ?? e.state.selection.from, a = r ?
|
|
5169
|
-
o?.chooseMd ? o.chooseMd(t.name, e) :
|
|
5220
|
+
async function xr(e, t, n, r) {
|
|
5221
|
+
let i = n ?? e.state.selection.from, a = r ? cn(r) : void 0, o = r?.storage?.qingwuUI, s = await new Promise((e) => {
|
|
5222
|
+
o?.chooseMd ? o.chooseMd(t.name, e) : nr(t.name).then(e);
|
|
5170
5223
|
});
|
|
5171
5224
|
if (s === null) return;
|
|
5172
5225
|
if (s === "attach") {
|
|
5173
|
-
let n = a ?
|
|
5226
|
+
let n = a ? ln(e.state.doc, t, a) : null;
|
|
5174
5227
|
if (n) {
|
|
5175
|
-
|
|
5228
|
+
Z(n);
|
|
5176
5229
|
return;
|
|
5177
5230
|
}
|
|
5178
5231
|
let r = URL.createObjectURL(t), o = e.state.schema.nodes.attachmentEmbed?.create({
|
|
@@ -5201,8 +5254,8 @@ async function yr(e, t, n, r) {
|
|
|
5201
5254
|
e.dispatch(e.state.tr.insert(i, t.from(u)));
|
|
5202
5255
|
}
|
|
5203
5256
|
}
|
|
5204
|
-
function
|
|
5205
|
-
switch (
|
|
5257
|
+
function Sr(e, t, n) {
|
|
5258
|
+
switch (yr(t)) {
|
|
5206
5259
|
case "image": return e.nodes.image?.create({
|
|
5207
5260
|
src: n,
|
|
5208
5261
|
alt: t.name
|
|
@@ -5228,7 +5281,7 @@ function br(e, t, n) {
|
|
|
5228
5281
|
}
|
|
5229
5282
|
}
|
|
5230
5283
|
}
|
|
5231
|
-
async function
|
|
5284
|
+
async function Cr(e, t, n) {
|
|
5232
5285
|
let r;
|
|
5233
5286
|
try {
|
|
5234
5287
|
r = o();
|
|
@@ -5247,13 +5300,13 @@ async function xr(e, t, n) {
|
|
|
5247
5300
|
return console.error(`${t.type} upload failed:`, e), URL.revokeObjectURL(n), null;
|
|
5248
5301
|
}
|
|
5249
5302
|
}
|
|
5250
|
-
async function
|
|
5251
|
-
let i = r ?
|
|
5303
|
+
async function wr(e, t, n, r) {
|
|
5304
|
+
let i = r ? cn(r) : void 0, a = i ? ln(e.state.doc, t, i) : null;
|
|
5252
5305
|
if (a) {
|
|
5253
|
-
|
|
5306
|
+
Z(a);
|
|
5254
5307
|
return;
|
|
5255
5308
|
}
|
|
5256
|
-
let o = URL.createObjectURL(t), s =
|
|
5309
|
+
let o = URL.createObjectURL(t), s = Sr(e.state.schema, t, o);
|
|
5257
5310
|
if (!s) return;
|
|
5258
5311
|
let c = n ?? e.state.selection.from;
|
|
5259
5312
|
try {
|
|
@@ -5261,9 +5314,9 @@ async function Sr(e, t, n, r) {
|
|
|
5261
5314
|
} catch {
|
|
5262
5315
|
return;
|
|
5263
5316
|
}
|
|
5264
|
-
await
|
|
5317
|
+
await Cr(e, t, o);
|
|
5265
5318
|
}
|
|
5266
|
-
var
|
|
5319
|
+
var Tr = R.create({
|
|
5267
5320
|
name: "imageUpload",
|
|
5268
5321
|
addOptions() {
|
|
5269
5322
|
return {
|
|
@@ -5273,8 +5326,8 @@ var Cr = F.create({
|
|
|
5273
5326
|
},
|
|
5274
5327
|
addProseMirrorPlugins() {
|
|
5275
5328
|
let e = this.editor;
|
|
5276
|
-
return [new
|
|
5277
|
-
key: new
|
|
5329
|
+
return [new z({
|
|
5330
|
+
key: new B("imageUpload"),
|
|
5278
5331
|
props: {
|
|
5279
5332
|
handleDrop(t, n) {
|
|
5280
5333
|
let r = n.dataTransfer?.files;
|
|
@@ -5284,23 +5337,23 @@ var Cr = F.create({
|
|
|
5284
5337
|
left: n.clientX,
|
|
5285
5338
|
top: n.clientY
|
|
5286
5339
|
});
|
|
5287
|
-
for (let n of Array.from(r))
|
|
5340
|
+
for (let n of Array.from(r)) br(n) ? xr(t, n, i?.pos, e) : wr(t, n, i?.pos, e);
|
|
5288
5341
|
return !0;
|
|
5289
5342
|
},
|
|
5290
5343
|
handlePaste(t, n) {
|
|
5291
5344
|
let r = n.clipboardData?.items;
|
|
5292
5345
|
if (!r) return !1;
|
|
5293
5346
|
let i = n.clipboardData?.getData("text/plain") || "";
|
|
5294
|
-
if ((n.clipboardData?.files?.length ?? 0) > 0 &&
|
|
5347
|
+
if ((n.clipboardData?.files?.length ?? 0) > 0 && vr(i, void 0, a())) return !1;
|
|
5295
5348
|
for (let i of Array.from(r)) {
|
|
5296
5349
|
if (i.type.startsWith("image/") || i.type.startsWith("video/") || i.type.startsWith("audio/")) {
|
|
5297
5350
|
n.preventDefault();
|
|
5298
5351
|
let r = i.getAsFile();
|
|
5299
|
-
return r &&
|
|
5352
|
+
return r && yr(r) !== "file" && wr(t, r, void 0, e), !0;
|
|
5300
5353
|
}
|
|
5301
5354
|
if (i.kind === "file") {
|
|
5302
5355
|
let r = i.getAsFile();
|
|
5303
|
-
if (r &&
|
|
5356
|
+
if (r && br(r)) return n.preventDefault(), xr(t, r, void 0, e), !0;
|
|
5304
5357
|
}
|
|
5305
5358
|
}
|
|
5306
5359
|
return !1;
|
|
@@ -5308,25 +5361,25 @@ var Cr = F.create({
|
|
|
5308
5361
|
}
|
|
5309
5362
|
})];
|
|
5310
5363
|
}
|
|
5311
|
-
}),
|
|
5312
|
-
function
|
|
5364
|
+
}), Er = /\.(png|jpe?g|gif|webp|bmp|svg|avif)(\?|#|$)/i, Dr = /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|#|$)/i, Or = /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|#|$)/i;
|
|
5365
|
+
function kr(e) {
|
|
5313
5366
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
5314
5367
|
}
|
|
5315
|
-
function
|
|
5368
|
+
function Ar(e) {
|
|
5316
5369
|
let t = e.trim().replace(/\\/g, "/");
|
|
5317
5370
|
return t.split("/").pop() || t;
|
|
5318
5371
|
}
|
|
5319
|
-
function
|
|
5372
|
+
function jr(e, t) {
|
|
5320
5373
|
let n = e.src.slice(e.pos), r = /^!\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !0;
|
|
5321
5374
|
if (r || (r = /^\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !1), !r) return !1;
|
|
5322
5375
|
let a = r[1].trim(), o = r[2]?.trim();
|
|
5323
5376
|
if (!t) {
|
|
5324
|
-
let t = o ||
|
|
5377
|
+
let t = o || Ar(a);
|
|
5325
5378
|
if (i) {
|
|
5326
5379
|
let n = "";
|
|
5327
|
-
if (
|
|
5328
|
-
else if (
|
|
5329
|
-
else if (
|
|
5380
|
+
if (Er.test(a) || /^data:image\//i.test(a)) n = `<img src="${kr(a)}" alt="${kr(t)}">`;
|
|
5381
|
+
else if (Dr.test(a) || /^data:video\//i.test(a)) n = `<div data-video-embed src="${kr(a)}"></div>`;
|
|
5382
|
+
else if (Or.test(a) || /^data:audio\//i.test(a)) n = `<audio src="${kr(a)}"></audio>`;
|
|
5330
5383
|
else {
|
|
5331
5384
|
let n = e.push("link_open", "a", 1);
|
|
5332
5385
|
n.attrs = [["href", a]];
|
|
@@ -5344,14 +5397,14 @@ function kr(e, t) {
|
|
|
5344
5397
|
}
|
|
5345
5398
|
return e.pos += r[0].length, !0;
|
|
5346
5399
|
}
|
|
5347
|
-
var
|
|
5400
|
+
var Mr = R.create({
|
|
5348
5401
|
name: "obsidianMarkdown",
|
|
5349
5402
|
addStorage() {
|
|
5350
5403
|
return { markdown: { parse: { setup(e) {
|
|
5351
|
-
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed",
|
|
5404
|
+
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed", jr));
|
|
5352
5405
|
} } } };
|
|
5353
5406
|
}
|
|
5354
|
-
}),
|
|
5407
|
+
}), Nr = R.create({
|
|
5355
5408
|
name: "qingwuUI",
|
|
5356
5409
|
addStorage() {
|
|
5357
5410
|
return {};
|
|
@@ -5359,7 +5412,7 @@ var Ar = F.create({
|
|
|
5359
5412
|
});
|
|
5360
5413
|
//#endregion
|
|
5361
5414
|
//#region src/editor/utils/render-probe.ts
|
|
5362
|
-
function
|
|
5415
|
+
function Pr(e, t) {
|
|
5363
5416
|
return new Promise((n) => {
|
|
5364
5417
|
if (typeof Image != "function") return n(!0);
|
|
5365
5418
|
let r = new Image(), i = !1, a = setTimeout(() => o(!1), t), o = (e) => {
|
|
@@ -5368,14 +5421,14 @@ function Mr(e, t) {
|
|
|
5368
5421
|
r.onload = () => o(!0), r.onerror = () => o(!1), r.src = e;
|
|
5369
5422
|
});
|
|
5370
5423
|
}
|
|
5371
|
-
async function
|
|
5372
|
-
if (await
|
|
5424
|
+
async function Fr(e, t = 8e3) {
|
|
5425
|
+
if (await Pr(e, t)) return !0;
|
|
5373
5426
|
try {
|
|
5374
5427
|
let r = await n(e);
|
|
5375
5428
|
if (!r) return !1;
|
|
5376
5429
|
let i = await fetch(e, { headers: r });
|
|
5377
5430
|
if (!i.ok) return !1;
|
|
5378
|
-
let a = URL.createObjectURL(await i.blob()), o = await
|
|
5431
|
+
let a = URL.createObjectURL(await i.blob()), o = await Pr(a, t);
|
|
5379
5432
|
return URL.revokeObjectURL(a), o;
|
|
5380
5433
|
} catch {
|
|
5381
5434
|
return !1;
|
|
@@ -5383,7 +5436,7 @@ async function Nr(e, t = 8e3) {
|
|
|
5383
5436
|
}
|
|
5384
5437
|
//#endregion
|
|
5385
5438
|
//#region src/editor/utils/resolve-local-media.ts
|
|
5386
|
-
function
|
|
5439
|
+
function Ir() {
|
|
5387
5440
|
return {
|
|
5388
5441
|
uploaded: 0,
|
|
5389
5442
|
sessionOnly: 0,
|
|
@@ -5393,10 +5446,10 @@ function Pr() {
|
|
|
5393
5446
|
readFailed: []
|
|
5394
5447
|
};
|
|
5395
5448
|
}
|
|
5396
|
-
function
|
|
5449
|
+
function Lr(e, t) {
|
|
5397
5450
|
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);
|
|
5398
5451
|
}
|
|
5399
|
-
function
|
|
5452
|
+
function Rr(e, t, n, r) {
|
|
5400
5453
|
let { state: i } = e, a = [];
|
|
5401
5454
|
if (i.doc.descendants((e, n) => {
|
|
5402
5455
|
e.attrs?.src === t && a.push(n);
|
|
@@ -5412,7 +5465,7 @@ function Ir(e, t, n, r) {
|
|
|
5412
5465
|
}
|
|
5413
5466
|
return e.dispatch(o), !0;
|
|
5414
5467
|
}
|
|
5415
|
-
function
|
|
5468
|
+
function zr(e, t, n) {
|
|
5416
5469
|
let { state: r } = e, i = r.schema.marks.link;
|
|
5417
5470
|
if (!i) return !1;
|
|
5418
5471
|
let a = [];
|
|
@@ -5430,7 +5483,7 @@ function Lr(e, t, n) {
|
|
|
5430
5483
|
}));
|
|
5431
5484
|
return e.dispatch(o), !0;
|
|
5432
5485
|
}
|
|
5433
|
-
function
|
|
5486
|
+
function Br(e) {
|
|
5434
5487
|
let t = /* @__PURE__ */ new Map();
|
|
5435
5488
|
for (let n of e) {
|
|
5436
5489
|
let e = t.get(n.normalized);
|
|
@@ -5438,36 +5491,36 @@ function Rr(e) {
|
|
|
5438
5491
|
}
|
|
5439
5492
|
return Array.from(t.values());
|
|
5440
5493
|
}
|
|
5441
|
-
async function
|
|
5494
|
+
async function Vr(e, t, n, r) {
|
|
5442
5495
|
if (n.length === 0) return "sessionOnly";
|
|
5443
|
-
let i = n[0], a =
|
|
5496
|
+
let i = n[0], a = cn(t);
|
|
5444
5497
|
if (a) {
|
|
5445
|
-
let t =
|
|
5446
|
-
if (t) return
|
|
5498
|
+
let t = ln(e.state.doc, r, a);
|
|
5499
|
+
if (t) return Z(`${i.basename}:${t}`, "error"), "limitRejected";
|
|
5447
5500
|
}
|
|
5448
5501
|
let s = n.filter((e) => !e.isLink), c = n.filter((e) => e.isLink);
|
|
5449
5502
|
if (s.length === 0) try {
|
|
5450
5503
|
let t = await o().upload(r, "editor"), n = !1;
|
|
5451
|
-
for (let r of c)
|
|
5504
|
+
for (let r of c) zr(e, r.src, t) && (n = !0);
|
|
5452
5505
|
return n ? "uploaded" : "sessionOnly";
|
|
5453
5506
|
} catch (e) {
|
|
5454
|
-
return console.error(`本地附件 ${i.basename} 上传失败:`, e),
|
|
5507
|
+
return console.error(`本地附件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), "sessionOnly";
|
|
5455
5508
|
}
|
|
5456
5509
|
let l = URL.createObjectURL(r), u = !1;
|
|
5457
|
-
for (let t of s)
|
|
5510
|
+
for (let t of s) Rr(e, t.src, l, r.size) && (u = !0);
|
|
5458
5511
|
let d;
|
|
5459
5512
|
try {
|
|
5460
5513
|
d = await o().upload(r, "editor");
|
|
5461
5514
|
} catch (e) {
|
|
5462
|
-
return console.error(`本地文件 ${i.basename} 上传失败:`, e),
|
|
5515
|
+
return console.error(`本地文件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), URL.revokeObjectURL(l), "sessionOnly";
|
|
5463
5516
|
}
|
|
5464
|
-
URL.revokeObjectURL(l), u &&
|
|
5465
|
-
for (let t of c)
|
|
5466
|
-
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await
|
|
5517
|
+
URL.revokeObjectURL(l), u && Rr(e, l, d, r.size);
|
|
5518
|
+
for (let t of c) zr(e, t.src, d);
|
|
5519
|
+
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await Fr(d) ? "uploaded" : "renderFailed" : "uploaded";
|
|
5467
5520
|
}
|
|
5468
|
-
function
|
|
5521
|
+
function Hr(e, t) {
|
|
5469
5522
|
let n = [], r = [];
|
|
5470
|
-
for (let i of
|
|
5523
|
+
for (let i of Br(e)) {
|
|
5471
5524
|
let e = i[0], a = t.get(e.basename);
|
|
5472
5525
|
a ? (n.push({
|
|
5473
5526
|
refs: i,
|
|
@@ -5479,30 +5532,30 @@ function Br(e, t) {
|
|
|
5479
5532
|
unmatched: r
|
|
5480
5533
|
};
|
|
5481
5534
|
}
|
|
5482
|
-
async function
|
|
5483
|
-
let i =
|
|
5484
|
-
for (let a of
|
|
5485
|
-
let n = a[0], { file: o, readError: s } = await
|
|
5535
|
+
async function Ur(e, t, n, r) {
|
|
5536
|
+
let i = Ir();
|
|
5537
|
+
for (let a of Br(n)) {
|
|
5538
|
+
let n = a[0], { file: o, readError: s } = await hr(r, n.src);
|
|
5486
5539
|
if (!o) {
|
|
5487
5540
|
s ? (console.warn(`本地文件「${n.basename}」在所选文件夹中找到但读取失败:`, s), i.readFailed.push(n)) : (console.warn(`本地文件「${n.basename}」未在所选文件夹「${r.name}」中找到`), i.missing.push(n));
|
|
5488
5541
|
continue;
|
|
5489
5542
|
}
|
|
5490
|
-
let c = await
|
|
5543
|
+
let c = await Vr(e, t, a, o);
|
|
5491
5544
|
i[c]++;
|
|
5492
5545
|
}
|
|
5493
5546
|
return i;
|
|
5494
5547
|
}
|
|
5495
|
-
function
|
|
5548
|
+
function Wr(e) {
|
|
5496
5549
|
let t = e.map((e) => e.basename);
|
|
5497
5550
|
return t.length <= 3 ? t.join("、") : `${t.slice(0, 3).join("、")} 等 ${t.length} 个文件`;
|
|
5498
5551
|
}
|
|
5499
|
-
function
|
|
5552
|
+
function Gr(e) {
|
|
5500
5553
|
let t = [];
|
|
5501
|
-
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} 个找到但读取失败:${
|
|
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} 个找到但读取失败:${Wr(e.readFailed)}(若在 OneDrive / WPS 云盘等同步目录,请右键文件选择「始终保留在此设备」后重试)`), e.missing.length > 0 && t.push(`${e.missing.length} 个未能获取:${Wr(e.missing)}(可把文件直接拖进编辑器上传)`), t.length === 0) return;
|
|
5502
5555
|
let n = e.uploaded > 0 && e.renderFailed === 0 && e.missing.length === 0 && e.readFailed.length === 0;
|
|
5503
|
-
|
|
5556
|
+
Z(`本地文件解析完成:${t.join(";")}`, n ? "success" : "info");
|
|
5504
5557
|
}
|
|
5505
|
-
function
|
|
5558
|
+
function Kr(e) {
|
|
5506
5559
|
return new Promise((t) => {
|
|
5507
5560
|
let n = document.createElement("div");
|
|
5508
5561
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5529,7 +5582,7 @@ function Wr(e) {
|
|
|
5529
5582
|
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);
|
|
5530
5583
|
});
|
|
5531
5584
|
}
|
|
5532
|
-
function
|
|
5585
|
+
function qr(e) {
|
|
5533
5586
|
let t = document.createElement("div");
|
|
5534
5587
|
t.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
5535
5588
|
let n = document.createElement("div");
|
|
@@ -5551,7 +5604,7 @@ function Gr(e) {
|
|
|
5551
5604
|
let c = document.createElement("button");
|
|
5552
5605
|
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);
|
|
5553
5606
|
}
|
|
5554
|
-
function
|
|
5607
|
+
function Jr(e) {
|
|
5555
5608
|
return new Promise((t) => {
|
|
5556
5609
|
let n = document.createElement("div");
|
|
5557
5610
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5577,8 +5630,8 @@ function Kr(e) {
|
|
|
5577
5630
|
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);
|
|
5578
5631
|
});
|
|
5579
5632
|
}
|
|
5580
|
-
async function
|
|
5581
|
-
let r =
|
|
5633
|
+
async function Yr(e, t, n) {
|
|
5634
|
+
let r = Ir(), i = Br(n), a = await fr();
|
|
5582
5635
|
if (!a) {
|
|
5583
5636
|
for (let e of i) r.missing.push(e[0]);
|
|
5584
5637
|
return r;
|
|
@@ -5591,14 +5644,14 @@ async function qr(e, t, n) {
|
|
|
5591
5644
|
continue;
|
|
5592
5645
|
}
|
|
5593
5646
|
o.delete(i.basename);
|
|
5594
|
-
let s = await
|
|
5647
|
+
let s = await Vr(e, t, n, a);
|
|
5595
5648
|
r[s]++;
|
|
5596
5649
|
}
|
|
5597
5650
|
return r;
|
|
5598
5651
|
}
|
|
5599
5652
|
//#endregion
|
|
5600
5653
|
//#region src/editor/extensions/relative-media.ts
|
|
5601
|
-
var
|
|
5654
|
+
var Xr = R.create({
|
|
5602
5655
|
name: "relativeMedia",
|
|
5603
5656
|
addStorage() {
|
|
5604
5657
|
return {
|
|
@@ -5608,42 +5661,42 @@ var Jr = F.create({
|
|
|
5608
5661
|
},
|
|
5609
5662
|
addProseMirrorPlugins() {
|
|
5610
5663
|
let e = this.editor, t = this.storage, n = !1, r = null, i = async (n, i) => {
|
|
5611
|
-
let a = e.view, o =
|
|
5664
|
+
let a = e.view, o = Ir(), { matched: s, unmatched: c } = Hr(n, t.clipboardFiles);
|
|
5612
5665
|
for (let { refs: t, file: n } of s) {
|
|
5613
|
-
let r = await
|
|
5666
|
+
let r = await Vr(a, e, t, n);
|
|
5614
5667
|
o[r]++;
|
|
5615
5668
|
}
|
|
5616
5669
|
if (c.length > 0) {
|
|
5617
|
-
let t =
|
|
5618
|
-
if (
|
|
5670
|
+
let t = Br(c).length;
|
|
5671
|
+
if (lr()) {
|
|
5619
5672
|
let n = i ?? null;
|
|
5620
|
-
if (n || (await
|
|
5621
|
-
r = n,
|
|
5673
|
+
if (n || (await Kr(t) === "pick" ? (n = await ur(), n || Z("没有选择文件夹。本地文件暂以占位显示,稍后可直接把文件拖进编辑器上传", "info")) : Z("已选择稍后处理。本地文件暂以占位显示,可直接把文件拖进编辑器上传", "info")), n) {
|
|
5674
|
+
r = n, Lr(o, await Ur(a, e, c, n));
|
|
5622
5675
|
let t = [...o.missing, ...o.readFailed];
|
|
5623
|
-
if (t.length > 0 &&
|
|
5624
|
-
let n = await
|
|
5625
|
-
|
|
5676
|
+
if (t.length > 0 && dr() && await Jr(t.map((e) => e.basename)) === "pick") {
|
|
5677
|
+
let n = await Yr(a, e, t);
|
|
5678
|
+
Lr(o, n), o.missing = n.missing, o.readFailed = [];
|
|
5626
5679
|
}
|
|
5627
5680
|
}
|
|
5628
|
-
} else
|
|
5681
|
+
} else qr(t);
|
|
5629
5682
|
}
|
|
5630
|
-
|
|
5683
|
+
Gr(o);
|
|
5631
5684
|
}, o = () => {
|
|
5632
5685
|
if (!e || e.isDestroyed || t.pausedUntilPaste) return;
|
|
5633
|
-
let o = a(), s =
|
|
5686
|
+
let o = a(), s = _r(e.state.doc, o);
|
|
5634
5687
|
if (s.length === 0 || n) return;
|
|
5635
5688
|
n = !0;
|
|
5636
5689
|
let c = new Set(s.map((e) => e.src));
|
|
5637
5690
|
i(s).then(() => {
|
|
5638
5691
|
if (e.isDestroyed) return;
|
|
5639
|
-
let t =
|
|
5692
|
+
let t = _r(e.state.doc, o).filter((e) => !c.has(e.src));
|
|
5640
5693
|
if (t.length !== 0) return i(t, r);
|
|
5641
5694
|
}).finally(() => {
|
|
5642
|
-
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste =
|
|
5695
|
+
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste = _r(e.state.doc, o).length > 0);
|
|
5643
5696
|
});
|
|
5644
5697
|
};
|
|
5645
|
-
return [new
|
|
5646
|
-
key: new
|
|
5698
|
+
return [new z({
|
|
5699
|
+
key: new B("relativeMedia"),
|
|
5647
5700
|
props: { handlePaste(e, n) {
|
|
5648
5701
|
let r = n.clipboardData?.files;
|
|
5649
5702
|
return t.clipboardFiles = new Map(Array.from(r ?? []).map((e) => [e.name.toLowerCase(), e])), t.pausedUntilPaste = !1, !1;
|
|
@@ -5653,18 +5706,18 @@ var Jr = F.create({
|
|
|
5653
5706
|
}
|
|
5654
5707
|
})];
|
|
5655
5708
|
}
|
|
5656
|
-
}),
|
|
5657
|
-
function
|
|
5658
|
-
return
|
|
5709
|
+
}), Zr = new B("slashCommand");
|
|
5710
|
+
function Qr(e) {
|
|
5711
|
+
return R.create({
|
|
5659
5712
|
name: "slashCommand",
|
|
5660
5713
|
addProseMirrorPlugins() {
|
|
5661
5714
|
let t = {
|
|
5662
5715
|
char: "/",
|
|
5663
|
-
pluginKey:
|
|
5716
|
+
pluginKey: Zr,
|
|
5664
5717
|
findSuggestionMatch: (e) => {
|
|
5665
5718
|
let { $position: t } = e;
|
|
5666
5719
|
for (let e = t.depth; e >= 0; e--) if (t.node(e).type.name === "codeBlock") return null;
|
|
5667
|
-
return t.marks().some((e) => e.type.name === "code") ? null :
|
|
5720
|
+
return t.marks().some((e) => e.type.name === "code") ? null : we(e);
|
|
5668
5721
|
},
|
|
5669
5722
|
allow: ({ editor: e, state: t }) => {
|
|
5670
5723
|
if (!e.isEditable) return !1;
|
|
@@ -5744,11 +5797,11 @@ function Xr(e) {
|
|
|
5744
5797
|
};
|
|
5745
5798
|
}
|
|
5746
5799
|
};
|
|
5747
|
-
return [
|
|
5800
|
+
return [Ce({
|
|
5748
5801
|
editor: this.editor,
|
|
5749
5802
|
...t
|
|
5750
|
-
}), new
|
|
5751
|
-
key: new
|
|
5803
|
+
}), new z({
|
|
5804
|
+
key: new B("slashCodeBlockGuard"),
|
|
5752
5805
|
appendTransaction: (e, t, n) => {
|
|
5753
5806
|
let { $from: r } = n.selection, i = !1;
|
|
5754
5807
|
for (let e = r.depth; e >= 0; e--) if (r.node(e).type.name === "codeBlock") {
|
|
@@ -5756,14 +5809,14 @@ function Xr(e) {
|
|
|
5756
5809
|
break;
|
|
5757
5810
|
}
|
|
5758
5811
|
if (!i && !r.marks().some((e) => e.type.name === "code")) return null;
|
|
5759
|
-
let a =
|
|
5760
|
-
return a && a.active ? n.tr.setMeta(
|
|
5812
|
+
let a = Zr.getState(n);
|
|
5813
|
+
return a && a.active ? n.tr.setMeta(Zr, { exit: !0 }) : null;
|
|
5761
5814
|
}
|
|
5762
5815
|
})];
|
|
5763
5816
|
}
|
|
5764
5817
|
});
|
|
5765
5818
|
}
|
|
5766
|
-
function
|
|
5819
|
+
function $r(e, t) {
|
|
5767
5820
|
return [
|
|
5768
5821
|
{
|
|
5769
5822
|
title: e("editor.slash.heading1"),
|
|
@@ -5862,9 +5915,9 @@ function Zr(e, t) {
|
|
|
5862
5915
|
n.type = "file", n.accept = "audio/*", n.onchange = async () => {
|
|
5863
5916
|
let r = n.files?.[0];
|
|
5864
5917
|
if (!r) return;
|
|
5865
|
-
let i =
|
|
5918
|
+
let i = cn(e) ?? t, a = i ? ln(e.state.doc, r, i) : null;
|
|
5866
5919
|
if (a) {
|
|
5867
|
-
|
|
5920
|
+
Z(a);
|
|
5868
5921
|
return;
|
|
5869
5922
|
}
|
|
5870
5923
|
let o = URL.createObjectURL(r), s = e.schema.nodes.audioEmbed?.create({
|
|
@@ -5872,7 +5925,7 @@ function Zr(e, t) {
|
|
|
5872
5925
|
name: r.name,
|
|
5873
5926
|
size: r.size
|
|
5874
5927
|
});
|
|
5875
|
-
s && (e.chain().focus().insertContent(s).run(), await
|
|
5928
|
+
s && (e.chain().focus().insertContent(s).run(), await Cr(e.view, r, o));
|
|
5876
5929
|
}, n.click();
|
|
5877
5930
|
}
|
|
5878
5931
|
},
|
|
@@ -5885,9 +5938,9 @@ function Zr(e, t) {
|
|
|
5885
5938
|
n.type = "file", n.accept = "*/*", n.multiple = !0, n.onchange = async () => {
|
|
5886
5939
|
let r = n.files;
|
|
5887
5940
|
if (!(!r || r.length === 0)) for (let n of Array.from(r)) {
|
|
5888
|
-
let r =
|
|
5941
|
+
let r = cn(e) ?? t, i = r ? ln(e.state.doc, n, r) : null;
|
|
5889
5942
|
if (i) {
|
|
5890
|
-
|
|
5943
|
+
Z(i);
|
|
5891
5944
|
continue;
|
|
5892
5945
|
}
|
|
5893
5946
|
let a = URL.createObjectURL(n), o = e.schema.nodes.attachmentEmbed;
|
|
@@ -5902,7 +5955,7 @@ function Zr(e, t) {
|
|
|
5902
5955
|
} catch {
|
|
5903
5956
|
continue;
|
|
5904
5957
|
}
|
|
5905
|
-
await
|
|
5958
|
+
await Cr(e.view, n, a);
|
|
5906
5959
|
}
|
|
5907
5960
|
}
|
|
5908
5961
|
}, n.click();
|
|
@@ -5912,9 +5965,9 @@ function Zr(e, t) {
|
|
|
5912
5965
|
}
|
|
5913
5966
|
//#endregion
|
|
5914
5967
|
//#region src/editor/extensions/index.ts
|
|
5915
|
-
var
|
|
5968
|
+
var ei = ce.extend({
|
|
5916
5969
|
addNodeView() {
|
|
5917
|
-
return
|
|
5970
|
+
return L(bn);
|
|
5918
5971
|
},
|
|
5919
5972
|
addAttributes() {
|
|
5920
5973
|
return {
|
|
@@ -5937,111 +5990,111 @@ var Qr = ue.extend({
|
|
|
5937
5990
|
};
|
|
5938
5991
|
}
|
|
5939
5992
|
});
|
|
5940
|
-
function
|
|
5993
|
+
function ti(e = {}) {
|
|
5941
5994
|
return [
|
|
5942
|
-
|
|
5995
|
+
le.configure({
|
|
5943
5996
|
codeBlock: !1,
|
|
5944
5997
|
horizontalRule: !1,
|
|
5945
5998
|
underline: !1,
|
|
5946
5999
|
link: !1
|
|
5947
6000
|
}),
|
|
5948
|
-
|
|
5949
|
-
|
|
6001
|
+
H,
|
|
6002
|
+
V.configure({
|
|
5950
6003
|
openOnClick: !0,
|
|
5951
6004
|
HTMLAttributes: {
|
|
5952
6005
|
rel: "noopener noreferrer",
|
|
5953
6006
|
target: "_blank"
|
|
5954
6007
|
}
|
|
5955
6008
|
}),
|
|
5956
|
-
|
|
6009
|
+
ei.configure({
|
|
5957
6010
|
inline: !1,
|
|
5958
6011
|
allowBase64: !0
|
|
5959
6012
|
}),
|
|
6013
|
+
ge,
|
|
6014
|
+
he.configure({ nested: !0 }),
|
|
6015
|
+
ue.configure({ multicolor: !0 }),
|
|
5960
6016
|
_e,
|
|
5961
|
-
ge.configure({ nested: !0 }),
|
|
5962
|
-
fe.configure({ multicolor: !0 }),
|
|
5963
|
-
ve,
|
|
5964
|
-
H,
|
|
5965
|
-
V.configure(e.maxLength ? { limit: e.maxLength } : {}),
|
|
5966
|
-
pe,
|
|
5967
|
-
$n,
|
|
5968
|
-
me.configure({ resizable: !0 }),
|
|
5969
|
-
G,
|
|
5970
6017
|
W,
|
|
5971
|
-
|
|
5972
|
-
|
|
6018
|
+
U.configure(e.maxLength ? { limit: e.maxLength } : {}),
|
|
6019
|
+
de,
|
|
6020
|
+
tr,
|
|
6021
|
+
fe.configure({ resizable: !0 }),
|
|
6022
|
+
K,
|
|
6023
|
+
pe,
|
|
6024
|
+
me,
|
|
6025
|
+
ve.configure({
|
|
5973
6026
|
html: !0,
|
|
5974
6027
|
transformPastedText: !0,
|
|
5975
6028
|
transformCopiedText: !1
|
|
5976
6029
|
}),
|
|
5977
|
-
|
|
5978
|
-
|
|
6030
|
+
G.configure({ placeholder: e.placeholder || "输入 '/' 打开菜单…" }),
|
|
6031
|
+
Qr(() => $r((e) => f(e), {
|
|
5979
6032
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
5980
6033
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
5981
6034
|
})),
|
|
5982
|
-
|
|
6035
|
+
Tr.configure({
|
|
5983
6036
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
5984
6037
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
5985
6038
|
}),
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
|
|
6039
|
+
Xr,
|
|
6040
|
+
Mr,
|
|
6041
|
+
Tt,
|
|
6042
|
+
Nr,
|
|
6043
|
+
Gn,
|
|
6044
|
+
Rn,
|
|
6045
|
+
Fn
|
|
5993
6046
|
];
|
|
5994
6047
|
}
|
|
5995
6048
|
//#endregion
|
|
5996
6049
|
//#region src/editor/extensions/bubble-menu.tsx
|
|
5997
|
-
var
|
|
5998
|
-
function
|
|
5999
|
-
|
|
6050
|
+
var ni = "https://www.bing.com/search?q={query}";
|
|
6051
|
+
function ri(e) {
|
|
6052
|
+
ni = e;
|
|
6000
6053
|
}
|
|
6001
|
-
function
|
|
6002
|
-
return
|
|
6054
|
+
function ii() {
|
|
6055
|
+
return ni;
|
|
6003
6056
|
}
|
|
6004
|
-
function
|
|
6057
|
+
function ai(e) {
|
|
6005
6058
|
return [
|
|
6006
6059
|
{
|
|
6007
6060
|
key: "bold",
|
|
6008
6061
|
label: e("editor.bubble.bold"),
|
|
6009
|
-
icon: /* @__PURE__ */ D(
|
|
6062
|
+
icon: /* @__PURE__ */ D(Ot, {}),
|
|
6010
6063
|
isActive: (e) => e.isActive("bold"),
|
|
6011
6064
|
command: (e) => e.isEditable && e.chain().focus().toggleBold().run()
|
|
6012
6065
|
},
|
|
6013
6066
|
{
|
|
6014
6067
|
key: "italic",
|
|
6015
6068
|
label: e("editor.bubble.italic"),
|
|
6016
|
-
icon: /* @__PURE__ */ D(
|
|
6069
|
+
icon: /* @__PURE__ */ D(kt, {}),
|
|
6017
6070
|
isActive: (e) => e.isActive("italic"),
|
|
6018
6071
|
command: (e) => e.isEditable && e.chain().focus().toggleItalic().run()
|
|
6019
6072
|
},
|
|
6020
6073
|
{
|
|
6021
6074
|
key: "underline",
|
|
6022
6075
|
label: e("editor.bubble.underline"),
|
|
6023
|
-
icon: /* @__PURE__ */ D(
|
|
6076
|
+
icon: /* @__PURE__ */ D(At, {}),
|
|
6024
6077
|
isActive: (e) => e.isActive("underline"),
|
|
6025
6078
|
command: (e) => e.isEditable && e.chain().focus().toggleUnderline().run()
|
|
6026
6079
|
},
|
|
6027
6080
|
{
|
|
6028
6081
|
key: "strikethrough",
|
|
6029
6082
|
label: e("editor.bubble.strikethrough"),
|
|
6030
|
-
icon: /* @__PURE__ */ D(
|
|
6083
|
+
icon: /* @__PURE__ */ D(jt, {}),
|
|
6031
6084
|
isActive: (e) => e.isActive("strike"),
|
|
6032
6085
|
command: (e) => e.isEditable && e.chain().focus().toggleStrike().run()
|
|
6033
6086
|
},
|
|
6034
6087
|
{
|
|
6035
6088
|
key: "code",
|
|
6036
6089
|
label: e("editor.bubble.emphasis"),
|
|
6037
|
-
icon: /* @__PURE__ */ D(
|
|
6090
|
+
icon: /* @__PURE__ */ D(Mt, {}),
|
|
6038
6091
|
isActive: (e) => e.isActive("code"),
|
|
6039
6092
|
command: (e) => e.isEditable && e.chain().focus().toggleCode().run()
|
|
6040
6093
|
},
|
|
6041
6094
|
{
|
|
6042
6095
|
key: "highlight",
|
|
6043
6096
|
label: e("editor.bubble.highlight"),
|
|
6044
|
-
icon: /* @__PURE__ */ D(
|
|
6097
|
+
icon: /* @__PURE__ */ D(Nt, {}),
|
|
6045
6098
|
more: !0,
|
|
6046
6099
|
isActive: (e) => e.isActive("highlight"),
|
|
6047
6100
|
command: () => {}
|
|
@@ -6049,7 +6102,7 @@ function ri(e) {
|
|
|
6049
6102
|
{
|
|
6050
6103
|
key: "link",
|
|
6051
6104
|
label: e("editor.bubble.link"),
|
|
6052
|
-
icon: /* @__PURE__ */ D(
|
|
6105
|
+
icon: /* @__PURE__ */ D(Pt, {}),
|
|
6053
6106
|
more: !0,
|
|
6054
6107
|
isActive: (e) => e.isActive("link"),
|
|
6055
6108
|
command: () => {}
|
|
@@ -6057,7 +6110,7 @@ function ri(e) {
|
|
|
6057
6110
|
{
|
|
6058
6111
|
key: "copy",
|
|
6059
6112
|
label: e("editor.bubble.copy"),
|
|
6060
|
-
icon: /* @__PURE__ */ D(
|
|
6113
|
+
icon: /* @__PURE__ */ D(It, {}),
|
|
6061
6114
|
more: !0,
|
|
6062
6115
|
isActive: () => !1,
|
|
6063
6116
|
command: (e) => {
|
|
@@ -6068,21 +6121,21 @@ function ri(e) {
|
|
|
6068
6121
|
{
|
|
6069
6122
|
key: "search",
|
|
6070
6123
|
label: e("editor.bubble.search"),
|
|
6071
|
-
icon: /* @__PURE__ */ D(
|
|
6124
|
+
icon: /* @__PURE__ */ D(Lt, {}),
|
|
6072
6125
|
more: !0,
|
|
6073
6126
|
isActive: () => !1,
|
|
6074
6127
|
command: (e) => {
|
|
6075
6128
|
if (e.isActive("table")) return;
|
|
6076
6129
|
let { from: t, to: n } = e.state.selection, r = e.state.doc.textBetween(t, n, " ").trim();
|
|
6077
6130
|
if (!r) return;
|
|
6078
|
-
let i =
|
|
6131
|
+
let i = ni.replace("{query}", encodeURIComponent(r));
|
|
6079
6132
|
window.open(i, "_blank", "noopener,noreferrer");
|
|
6080
6133
|
}
|
|
6081
6134
|
},
|
|
6082
6135
|
{
|
|
6083
6136
|
key: "table",
|
|
6084
6137
|
label: e("editor.bubble.table"),
|
|
6085
|
-
icon: /* @__PURE__ */ D(
|
|
6138
|
+
icon: /* @__PURE__ */ D(Ft, {}),
|
|
6086
6139
|
more: !0,
|
|
6087
6140
|
isActive: (e) => e.isActive("table"),
|
|
6088
6141
|
command: (e) => {
|
|
@@ -6098,7 +6151,7 @@ function ri(e) {
|
|
|
6098
6151
|
{
|
|
6099
6152
|
key: "ai",
|
|
6100
6153
|
label: e("editor.ai.trigger"),
|
|
6101
|
-
icon: /* @__PURE__ */ D(
|
|
6154
|
+
icon: /* @__PURE__ */ D(Rt, {}),
|
|
6102
6155
|
isActive: () => !1,
|
|
6103
6156
|
command: (e) => {
|
|
6104
6157
|
e.isEditable && e.storage.qingwuUI?.openAI?.();
|
|
@@ -6106,10 +6159,10 @@ function ri(e) {
|
|
|
6106
6159
|
}
|
|
6107
6160
|
];
|
|
6108
6161
|
}
|
|
6109
|
-
|
|
6162
|
+
R.create({ name: "bubbleMenu" });
|
|
6110
6163
|
//#endregion
|
|
6111
6164
|
//#region src/editor/extensions/table-toolbar.tsx
|
|
6112
|
-
function
|
|
6165
|
+
function oi(e) {
|
|
6113
6166
|
let { $from: t } = e.state.selection;
|
|
6114
6167
|
for (let e = t.depth; e > 0; e--) {
|
|
6115
6168
|
let n = t.node(e);
|
|
@@ -6120,7 +6173,7 @@ function ii(e) {
|
|
|
6120
6173
|
}
|
|
6121
6174
|
return null;
|
|
6122
6175
|
}
|
|
6123
|
-
function
|
|
6176
|
+
function si(e) {
|
|
6124
6177
|
let t = [];
|
|
6125
6178
|
return e.forEach((e) => {
|
|
6126
6179
|
let n = [];
|
|
@@ -6129,7 +6182,7 @@ function ai(e) {
|
|
|
6129
6182
|
}), t.push(n);
|
|
6130
6183
|
}), t;
|
|
6131
6184
|
}
|
|
6132
|
-
function
|
|
6185
|
+
function ci(e) {
|
|
6133
6186
|
if (e.length === 0) return "";
|
|
6134
6187
|
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(" | ")} |`;
|
|
6135
6188
|
return [
|
|
@@ -6138,11 +6191,11 @@ function oi(e) {
|
|
|
6138
6191
|
...i.map(a)
|
|
6139
6192
|
].join("\n");
|
|
6140
6193
|
}
|
|
6141
|
-
function
|
|
6194
|
+
function li(e) {
|
|
6142
6195
|
let t = (e) => /[",\n]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e;
|
|
6143
6196
|
return e.map((e) => e.map(t).join(",")).join("\n");
|
|
6144
6197
|
}
|
|
6145
|
-
function
|
|
6198
|
+
function ui(e) {
|
|
6146
6199
|
let t = e.trim();
|
|
6147
6200
|
if (!t) return null;
|
|
6148
6201
|
let n = t.split(/\r?\n/);
|
|
@@ -6156,7 +6209,7 @@ function ci(e) {
|
|
|
6156
6209
|
}
|
|
6157
6210
|
return null;
|
|
6158
6211
|
}
|
|
6159
|
-
function
|
|
6212
|
+
function di({ editor: e }) {
|
|
6160
6213
|
let [t, n] = T(null), [r, i] = T(!1), [a, o] = T(!1), s = w(null), c = w(null), l = e.isEditable, u = b(() => {
|
|
6161
6214
|
c.current != null && cancelAnimationFrame(c.current), c.current = requestAnimationFrame(() => {
|
|
6162
6215
|
c.current = null;
|
|
@@ -6172,7 +6225,7 @@ function li({ editor: e }) {
|
|
|
6172
6225
|
n(null);
|
|
6173
6226
|
return;
|
|
6174
6227
|
}
|
|
6175
|
-
let t =
|
|
6228
|
+
let t = oi(e);
|
|
6176
6229
|
if (!t) {
|
|
6177
6230
|
n(null);
|
|
6178
6231
|
return;
|
|
@@ -6201,24 +6254,24 @@ function li({ editor: e }) {
|
|
|
6201
6254
|
});
|
|
6202
6255
|
return n.nodes.table.create(null, i);
|
|
6203
6256
|
}, p = () => {
|
|
6204
|
-
let t =
|
|
6257
|
+
let t = oi(e);
|
|
6205
6258
|
if (!t) return;
|
|
6206
|
-
let n =
|
|
6259
|
+
let n = ci(si(t.node));
|
|
6207
6260
|
navigator.clipboard?.writeText(n), i(!0), setTimeout(() => i(!1), 1500);
|
|
6208
6261
|
}, m = () => {
|
|
6209
|
-
let t =
|
|
6262
|
+
let t = oi(e);
|
|
6210
6263
|
if (!t) return;
|
|
6211
|
-
let n = si(
|
|
6264
|
+
let n = li(si(t.node)), r = new Blob([`\ufeff${n}`], { type: "text/csv;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
6212
6265
|
a.href = i, a.download = "table.csv", document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
6213
6266
|
}, h = async () => {
|
|
6214
6267
|
if (l) try {
|
|
6215
6268
|
let t = await navigator.clipboard?.readText();
|
|
6216
6269
|
if (!t) return;
|
|
6217
|
-
let n =
|
|
6270
|
+
let n = ui(t);
|
|
6218
6271
|
if (!n || n.length === 0) return;
|
|
6219
6272
|
let r = f(n);
|
|
6220
6273
|
if (!r) return;
|
|
6221
|
-
let i =
|
|
6274
|
+
let i = oi(e), a = e.chain().focus();
|
|
6222
6275
|
if (i) {
|
|
6223
6276
|
let t = Math.min(i.pos + i.node.nodeSize, e.state.doc.content.size);
|
|
6224
6277
|
a.setTextSelection(t);
|
|
@@ -6338,7 +6391,7 @@ function li({ editor: e }) {
|
|
|
6338
6391
|
type: "button",
|
|
6339
6392
|
className: "tbl-btn tbl-btn--del",
|
|
6340
6393
|
onClick: () => {
|
|
6341
|
-
!l ||
|
|
6394
|
+
!l || pn() || ($(!0), o(!0));
|
|
6342
6395
|
},
|
|
6343
6396
|
title: "删除",
|
|
6344
6397
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -6356,7 +6409,7 @@ function li({ editor: e }) {
|
|
|
6356
6409
|
})
|
|
6357
6410
|
})
|
|
6358
6411
|
}),
|
|
6359
|
-
/* @__PURE__ */ D(
|
|
6412
|
+
/* @__PURE__ */ D(vn, {
|
|
6360
6413
|
open: a,
|
|
6361
6414
|
title: "确认删除表格",
|
|
6362
6415
|
message: "此操作不可撤销。",
|
|
@@ -6372,7 +6425,7 @@ function li({ editor: e }) {
|
|
|
6372
6425
|
}
|
|
6373
6426
|
//#endregion
|
|
6374
6427
|
//#region src/editor/ai-editor.tsx
|
|
6375
|
-
var
|
|
6428
|
+
var fi = [
|
|
6376
6429
|
{
|
|
6377
6430
|
color: "#fef08a",
|
|
6378
6431
|
name: "黄"
|
|
@@ -6397,9 +6450,9 @@ var ui = [
|
|
|
6397
6450
|
color: "#ddd6fe",
|
|
6398
6451
|
name: "紫"
|
|
6399
6452
|
}
|
|
6400
|
-
],
|
|
6401
|
-
function
|
|
6402
|
-
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth ||
|
|
6453
|
+
], pi = 288, mi = 480, hi = 320;
|
|
6454
|
+
function gi(e, t, n = {}) {
|
|
6455
|
+
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth || pi, mi, r - 32), o = Math.max(t || hi, 160);
|
|
6403
6456
|
if (r < 640) {
|
|
6404
6457
|
let t = Math.max(8, Math.min(e.top + 10, i - 420));
|
|
6405
6458
|
return {
|
|
@@ -6440,10 +6493,10 @@ function mi(e, t, n = {}) {
|
|
|
6440
6493
|
arrowLeft: p
|
|
6441
6494
|
};
|
|
6442
6495
|
}
|
|
6443
|
-
function
|
|
6496
|
+
function _i(e) {
|
|
6444
6497
|
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);
|
|
6445
6498
|
}
|
|
6446
|
-
function
|
|
6499
|
+
function vi(e, t) {
|
|
6447
6500
|
try {
|
|
6448
6501
|
let n = e.storage?.markdown?.parser;
|
|
6449
6502
|
if (!n) return null;
|
|
@@ -6453,20 +6506,20 @@ function gi(e, t) {
|
|
|
6453
6506
|
return null;
|
|
6454
6507
|
}
|
|
6455
6508
|
}
|
|
6456
|
-
var
|
|
6509
|
+
var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.ImageUploadDialog }))), bi = y(() => import("./storage-settings-dialog-DZqqDAiO.js").then((e) => ({ default: e.StorageSettingsDialog }))), xi = y(() => import("./export-dialog-CL7ie13Z.js").then((e) => ({ default: e.ExportDialog }))), Si = y(() => import("./video-embed-dialog-AeGcMb4X.js").then((e) => ({ default: e.VideoEmbedDialog }))), Ci = y(() => import("./md-import-dialog-Cf3ZOwA_.js").then((e) => ({ default: e.MdImportDialog }))), wi = () => /* @__PURE__ */ O("div", {
|
|
6457
6510
|
className: "fixed inset-0 z-[9999] flex items-center justify-center",
|
|
6458
6511
|
children: [/* @__PURE__ */ D("div", { className: "absolute inset-0 bg-black/40 backdrop-blur-sm" }), /* @__PURE__ */ D("div", {
|
|
6459
6512
|
className: "relative bg-background rounded-2xl border border-default-200 p-8 flex items-center justify-center",
|
|
6460
6513
|
children: /* @__PURE__ */ D("div", { className: "w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin" })
|
|
6461
6514
|
})]
|
|
6462
|
-
}),
|
|
6463
|
-
let k = r === "view" || i, A = C(() => typeof e == "object" && e ||
|
|
6515
|
+
}), Ti = ({ 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 }) => {
|
|
6516
|
+
let k = r === "view" || i, A = C(() => typeof e == "object" && e || _i(e) ? e : d(e), [e]), [j, M] = T(!1), [F, I] = T({}), [L, R] = T("below"), [re, ie] = T(50), z = w(null), [B, ae] = T(!1), [oe, se] = T(!1), [ce, V] = T(!1), [H, le] = T(!1), [U, W] = T("none"), [ue, de] = T({}), [G, fe] = T(""), [pe, me] = T(null), [K, he] = T(m), [ge, _e] = T(!1);
|
|
6464
6517
|
x(() => {
|
|
6465
|
-
|
|
6518
|
+
he(m);
|
|
6466
6519
|
}, [m]);
|
|
6467
|
-
let [
|
|
6468
|
-
let e =
|
|
6469
|
-
e && (
|
|
6520
|
+
let [ve, ye] = T(!1), [be, xe] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 80rem)").matches : !0), [Se, Ce] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 64rem)").matches : !0), we = w(null), Te = w(null), Ee = w(null), De = w(0), Oe = w(null), ke = w(null), Ae = w(null), [je, Me] = T(!1), [q, Ne] = T(!1), [J, Pe] = T(!1), Fe = b(() => {
|
|
6521
|
+
let e = Te.current, t = Ee.current;
|
|
6522
|
+
e && (q ? (document.body.style.overflow = "", Object.assign(e.style, {
|
|
6470
6523
|
position: "",
|
|
6471
6524
|
top: "",
|
|
6472
6525
|
left: "",
|
|
@@ -6482,9 +6535,9 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6482
6535
|
flex: "",
|
|
6483
6536
|
overflow: "",
|
|
6484
6537
|
minHeight: ""
|
|
6485
|
-
}),
|
|
6486
|
-
window.scrollTo(0,
|
|
6487
|
-
})) : (document.fullscreenElement && document.exitFullscreen(),
|
|
6538
|
+
}), Ne(!1), requestAnimationFrame(() => {
|
|
6539
|
+
window.scrollTo(0, De.current);
|
|
6540
|
+
})) : (document.fullscreenElement && document.exitFullscreen(), De.current = window.scrollY, Object.assign(e.style, {
|
|
6488
6541
|
position: "fixed",
|
|
6489
6542
|
top: "0",
|
|
6490
6543
|
left: "0",
|
|
@@ -6500,42 +6553,42 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6500
6553
|
flex: "1",
|
|
6501
6554
|
overflow: "auto",
|
|
6502
6555
|
minHeight: "0"
|
|
6503
|
-
}), document.body.style.overflow = "hidden",
|
|
6504
|
-
}, [
|
|
6505
|
-
let e =
|
|
6506
|
-
e && (document.fullscreenElement ? document.exitFullscreen() : (
|
|
6507
|
-
}, [
|
|
6556
|
+
}), document.body.style.overflow = "hidden", Ne(!0)));
|
|
6557
|
+
}, [q]), Ie = b(() => {
|
|
6558
|
+
let e = Te.current;
|
|
6559
|
+
e && (document.fullscreenElement ? document.exitFullscreen() : (q && Fe(), De.current = window.scrollY, e.requestFullscreen()));
|
|
6560
|
+
}, [q, Fe]);
|
|
6508
6561
|
x(() => {
|
|
6509
6562
|
let e = (e) => {
|
|
6510
|
-
e.key === "Escape" &&
|
|
6563
|
+
e.key === "Escape" && q && Fe();
|
|
6511
6564
|
}, t = () => {
|
|
6512
|
-
document.fullscreenElement ?
|
|
6513
|
-
window.scrollTo(0,
|
|
6565
|
+
document.fullscreenElement ? Pe(!0) : (Pe(!1), requestAnimationFrame(() => {
|
|
6566
|
+
window.scrollTo(0, De.current);
|
|
6514
6567
|
}));
|
|
6515
6568
|
};
|
|
6516
6569
|
return window.addEventListener("keydown", e), document.addEventListener("fullscreenchange", t), () => {
|
|
6517
6570
|
window.removeEventListener("keydown", e), document.removeEventListener("fullscreenchange", t);
|
|
6518
6571
|
};
|
|
6519
|
-
}, [
|
|
6572
|
+
}, [q, Fe]), x(() => {
|
|
6520
6573
|
if (!h) return;
|
|
6521
6574
|
let e = (e) => {
|
|
6522
6575
|
if ((e.ctrlKey || e.metaKey) && (e.key === "f" || e.key === "F")) {
|
|
6523
|
-
if (!
|
|
6524
|
-
e.preventDefault(), e.stopPropagation(),
|
|
6576
|
+
if (!Te.current) return;
|
|
6577
|
+
e.preventDefault(), e.stopPropagation(), ye(!0);
|
|
6525
6578
|
}
|
|
6526
6579
|
};
|
|
6527
6580
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
6528
6581
|
}, [h]), x(() => {
|
|
6529
6582
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
6530
|
-
let e = window.matchMedia("(min-width: 80rem)"), t = (e) =>
|
|
6531
|
-
return
|
|
6583
|
+
let e = window.matchMedia("(min-width: 80rem)"), t = (e) => xe(e.matches);
|
|
6584
|
+
return xe(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
6532
6585
|
}, []), x(() => {
|
|
6533
6586
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
6534
|
-
let e = window.matchMedia("(min-width: 64rem)"), t = (e) =>
|
|
6535
|
-
return
|
|
6587
|
+
let e = window.matchMedia("(min-width: 64rem)"), t = (e) => Ce(e.matches);
|
|
6588
|
+
return Ce(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
6536
6589
|
}, []);
|
|
6537
|
-
let
|
|
6538
|
-
extensions:
|
|
6590
|
+
let Y = ee({
|
|
6591
|
+
extensions: ti({
|
|
6539
6592
|
placeholder: n || f("editor.placeholder"),
|
|
6540
6593
|
maxLength: a,
|
|
6541
6594
|
maxAttachmentSize: o,
|
|
@@ -6545,7 +6598,7 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6545
6598
|
editable: !k,
|
|
6546
6599
|
immediatelyRender: _,
|
|
6547
6600
|
onUpdate: ({ editor: e }) => {
|
|
6548
|
-
t && (
|
|
6601
|
+
t && (we.current && clearTimeout(we.current), we.current = setTimeout(() => {
|
|
6549
6602
|
t?.(e.getHTML(), e.getJSON());
|
|
6550
6603
|
}, 300));
|
|
6551
6604
|
},
|
|
@@ -6558,9 +6611,9 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6558
6611
|
let r = n.getData("text/plain");
|
|
6559
6612
|
if (!r || !r.includes("[[")) return !1;
|
|
6560
6613
|
t.preventDefault();
|
|
6561
|
-
let i =
|
|
6614
|
+
let i = ke.current?.storage?.relativeMedia;
|
|
6562
6615
|
i && (i.clipboardFiles = new Map(Array.from(n.files ?? []).map((e) => [e.name.toLowerCase(), e])), i.pausedUntilPaste = !1);
|
|
6563
|
-
let a =
|
|
6616
|
+
let a = ke.current ? vi(ke.current, r) : null;
|
|
6564
6617
|
if (a) {
|
|
6565
6618
|
let t = new N(a, 0, 0);
|
|
6566
6619
|
e.dispatch(e.state.tr.replaceSelection(t).scrollIntoView());
|
|
@@ -6570,21 +6623,21 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6570
6623
|
}
|
|
6571
6624
|
});
|
|
6572
6625
|
x(() => {
|
|
6573
|
-
|
|
6574
|
-
}, [
|
|
6575
|
-
if (
|
|
6576
|
-
}, [
|
|
6577
|
-
!
|
|
6578
|
-
}, [
|
|
6579
|
-
if (!
|
|
6626
|
+
ke.current = Y, window.__editor = Y;
|
|
6627
|
+
}, [Y]), x(() => {
|
|
6628
|
+
if (Y) return () => Jt(Y);
|
|
6629
|
+
}, [Y]), x(() => {
|
|
6630
|
+
!Y || !g || g(Y);
|
|
6631
|
+
}, [Y, g]), x(() => {
|
|
6632
|
+
if (!Y) return;
|
|
6580
6633
|
let e = () => {
|
|
6581
|
-
|
|
6634
|
+
Y.state.selection.empty && (W("none"), Me(!1));
|
|
6582
6635
|
};
|
|
6583
|
-
return
|
|
6584
|
-
|
|
6636
|
+
return Y.on("selectionUpdate", e), () => {
|
|
6637
|
+
Y.off("selectionUpdate", e);
|
|
6585
6638
|
};
|
|
6586
|
-
}, [
|
|
6587
|
-
|
|
6639
|
+
}, [Y]), x(() => {
|
|
6640
|
+
Y && Y.setOptions({ extensions: ti({
|
|
6588
6641
|
placeholder: n || f("editor.placeholder"),
|
|
6589
6642
|
maxLength: a,
|
|
6590
6643
|
maxAttachmentSize: o,
|
|
@@ -6596,80 +6649,80 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6596
6649
|
o,
|
|
6597
6650
|
s
|
|
6598
6651
|
]);
|
|
6599
|
-
let
|
|
6652
|
+
let Le = w(e);
|
|
6600
6653
|
x(() => {
|
|
6601
|
-
if (!
|
|
6602
|
-
|
|
6603
|
-
let t = typeof e == "object" && e ||
|
|
6604
|
-
|
|
6605
|
-
}, [
|
|
6606
|
-
|
|
6607
|
-
}, [
|
|
6608
|
-
if (y) return
|
|
6654
|
+
if (!Y || e === Le.current) return;
|
|
6655
|
+
Le.current = e;
|
|
6656
|
+
let t = typeof e == "object" && e || _i(e) ? e : d(e);
|
|
6657
|
+
Y.commands.setContent(t, { emitUpdate: !1 });
|
|
6658
|
+
}, [Y, e]), x(() => {
|
|
6659
|
+
Y && Y.setEditable(!k, !1);
|
|
6660
|
+
}, [Y, k]), x(() => {
|
|
6661
|
+
if (y) return Ze(y);
|
|
6609
6662
|
}, [y]), x(() => {
|
|
6610
|
-
if (!
|
|
6611
|
-
let e =
|
|
6612
|
-
e > s &&
|
|
6613
|
-
}, [
|
|
6614
|
-
if (!
|
|
6615
|
-
let e =
|
|
6663
|
+
if (!Y) return;
|
|
6664
|
+
let e = on(Y.state.doc);
|
|
6665
|
+
e > s && Z(`文档内附件总大小 ${sn(e)} 已超过限制 ${sn(s)}`, "info");
|
|
6666
|
+
}, [Y, s]), x(() => {
|
|
6667
|
+
if (!Y) return;
|
|
6668
|
+
let e = Y.storage.qingwuUI;
|
|
6616
6669
|
e && (e.limits = {
|
|
6617
6670
|
maxAttachmentSize: o,
|
|
6618
6671
|
maxTotalAttachmentSize: s
|
|
6619
6672
|
});
|
|
6620
6673
|
}, [
|
|
6621
|
-
|
|
6674
|
+
Y,
|
|
6622
6675
|
o,
|
|
6623
6676
|
s
|
|
6624
6677
|
]);
|
|
6625
|
-
let
|
|
6626
|
-
let t =
|
|
6627
|
-
|
|
6678
|
+
let Re = b((e) => {
|
|
6679
|
+
let t = Ae.current?.getBoundingClientRect();
|
|
6680
|
+
W(e), Me(!1), de({
|
|
6628
6681
|
position: "fixed",
|
|
6629
6682
|
top: t ? t.bottom + 8 : void 0,
|
|
6630
6683
|
left: t ? Math.max(8, Math.min(t.left, window.innerWidth - 240)) : 8,
|
|
6631
6684
|
zIndex: 9999
|
|
6632
6685
|
});
|
|
6633
|
-
}, []),
|
|
6634
|
-
if (
|
|
6686
|
+
}, []), ze = ai((e) => f(e)), X = ze.filter((e) => !e.more), Be = ze.filter((e) => e.more), Ve = X.filter((e) => e.key !== "ai"), He = X.find((e) => e.key === "ai"), Ue = b((e) => {
|
|
6687
|
+
if (Y) if (Me(!1), e.key === "link") if (Y.isActive("link")) Y.chain().focus().unsetLink().run();
|
|
6635
6688
|
else {
|
|
6636
|
-
let e =
|
|
6637
|
-
|
|
6689
|
+
let e = Y.getAttributes("link").href || "";
|
|
6690
|
+
fe(e), Re("link");
|
|
6638
6691
|
}
|
|
6639
|
-
else e.key === "highlight" ?
|
|
6692
|
+
else e.key === "highlight" ? U === "highlight" ? W("none") : Re("highlight") : e.command(Y);
|
|
6640
6693
|
}, [
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
]),
|
|
6694
|
+
Y,
|
|
6695
|
+
U,
|
|
6696
|
+
Re
|
|
6697
|
+
]), We = b((e) => Y ? e.key === "highlight" ? U === "highlight" : e.key === "link" ? Y.isActive("link") : e.isActive(Y) : !1, [Y, U]), [Ge, Ke] = T(0);
|
|
6645
6698
|
x(() => {
|
|
6646
|
-
if (!
|
|
6647
|
-
let e = () =>
|
|
6648
|
-
return
|
|
6649
|
-
|
|
6699
|
+
if (!Y) return;
|
|
6700
|
+
let e = () => Ke((e) => (e + 1) % 1e6);
|
|
6701
|
+
return Y.on("update", e), () => {
|
|
6702
|
+
Y.off("update", e);
|
|
6650
6703
|
};
|
|
6651
|
-
}, [
|
|
6652
|
-
let [
|
|
6704
|
+
}, [Y]);
|
|
6705
|
+
let [qe, Je] = T(!1);
|
|
6653
6706
|
x(() => {
|
|
6654
|
-
if (!
|
|
6707
|
+
if (!Y) return;
|
|
6655
6708
|
let e = () => {
|
|
6656
6709
|
let e = !1;
|
|
6657
|
-
|
|
6710
|
+
Y.state.doc.descendants((t) => {
|
|
6658
6711
|
t.type.name === "heading" && (e = !0);
|
|
6659
|
-
}),
|
|
6712
|
+
}), Je(e);
|
|
6660
6713
|
};
|
|
6661
|
-
return e(),
|
|
6662
|
-
|
|
6714
|
+
return e(), Y.on("update", e), () => {
|
|
6715
|
+
Y.off("update", e);
|
|
6663
6716
|
};
|
|
6664
|
-
}, [
|
|
6665
|
-
let
|
|
6717
|
+
}, [Y]);
|
|
6718
|
+
let Ye = C(() => Y?.storage?.characterCount?.characters?.() ?? 0, [Y, Ge]), Xe = a ? Ye > a : !1;
|
|
6666
6719
|
x(() => () => {
|
|
6667
|
-
|
|
6720
|
+
we.current && clearTimeout(we.current);
|
|
6668
6721
|
}, []), x(() => () => {
|
|
6669
|
-
|
|
6722
|
+
pe && pe.resolve(null);
|
|
6670
6723
|
}, []);
|
|
6671
|
-
let
|
|
6672
|
-
if (!
|
|
6724
|
+
let Qe = b((e) => {
|
|
6725
|
+
if (!Y?.isEditable) return;
|
|
6673
6726
|
let t = window.getSelection(), n;
|
|
6674
6727
|
if (e) {
|
|
6675
6728
|
let t = e.getBoundingClientRect();
|
|
@@ -6686,66 +6739,66 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6686
6739
|
width: e.width
|
|
6687
6740
|
};
|
|
6688
6741
|
} else {
|
|
6689
|
-
let e =
|
|
6742
|
+
let e = Y.view.coordsAtPos(Y.state.selection.from);
|
|
6690
6743
|
n = {
|
|
6691
6744
|
top: e.bottom,
|
|
6692
6745
|
left: e.left,
|
|
6693
6746
|
width: 0
|
|
6694
6747
|
};
|
|
6695
6748
|
}
|
|
6696
|
-
|
|
6697
|
-
let r =
|
|
6749
|
+
Oe.current = n;
|
|
6750
|
+
let r = Te.current?.getBoundingClientRect(), i = gi(n, void 0, {
|
|
6698
6751
|
panelWidth: r?.width,
|
|
6699
6752
|
editorLeft: r?.left
|
|
6700
6753
|
});
|
|
6701
|
-
M(!0),
|
|
6702
|
-
}, [
|
|
6754
|
+
M(!0), I(i.style), R(i.placement), ie(i.arrowLeft);
|
|
6755
|
+
}, [Y]);
|
|
6703
6756
|
x(() => {
|
|
6704
|
-
if (!
|
|
6705
|
-
let e =
|
|
6706
|
-
if (e) return e.openImageDialog = () =>
|
|
6707
|
-
|
|
6757
|
+
if (!Y) return;
|
|
6758
|
+
let e = Y.storage.qingwuUI;
|
|
6759
|
+
if (e) return e.openImageDialog = () => ae(!0), e.openVideoDialog = () => se(!0), e.chooseMd = (e, t) => {
|
|
6760
|
+
me({
|
|
6708
6761
|
filename: e,
|
|
6709
6762
|
resolve: t
|
|
6710
6763
|
});
|
|
6711
|
-
}, e.openAI =
|
|
6764
|
+
}, e.openAI = Qe, e.parseMd = (e, t) => Y ? vi(Y, t) : null, () => {
|
|
6712
6765
|
delete e.openImageDialog, delete e.openVideoDialog, delete e.openAI, delete e.parseMd, delete e.chooseMd;
|
|
6713
6766
|
};
|
|
6714
|
-
}, [
|
|
6715
|
-
if (!j || !
|
|
6716
|
-
let e =
|
|
6767
|
+
}, [Y, Qe]), S(() => {
|
|
6768
|
+
if (!j || !Y) return;
|
|
6769
|
+
let e = Oe.current;
|
|
6717
6770
|
if (!e) return;
|
|
6718
|
-
let t =
|
|
6771
|
+
let t = z.current, n = Te.current?.getBoundingClientRect(), r = gi(e, t?.offsetHeight || void 0, {
|
|
6719
6772
|
panelWidth: n?.width,
|
|
6720
6773
|
editorLeft: n?.left
|
|
6721
6774
|
});
|
|
6722
|
-
|
|
6723
|
-
}, [j,
|
|
6724
|
-
if (!j || !
|
|
6775
|
+
R(r.placement), ie(r.arrowLeft), I(r.style);
|
|
6776
|
+
}, [j, Y]), x(() => {
|
|
6777
|
+
if (!j || !Y) return;
|
|
6725
6778
|
let e = () => {
|
|
6726
|
-
let e =
|
|
6779
|
+
let e = Oe.current;
|
|
6727
6780
|
if (!e) return;
|
|
6728
|
-
let t =
|
|
6781
|
+
let t = z.current, n = Te.current?.getBoundingClientRect(), r = gi(e, t?.offsetHeight || void 0, {
|
|
6729
6782
|
panelWidth: n?.width,
|
|
6730
6783
|
editorLeft: n?.left
|
|
6731
6784
|
});
|
|
6732
|
-
|
|
6785
|
+
R(r.placement), ie(r.arrowLeft), I(r.style);
|
|
6733
6786
|
};
|
|
6734
6787
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
6735
|
-
}, [j,
|
|
6736
|
-
j || (
|
|
6788
|
+
}, [j, Y]), x(() => {
|
|
6789
|
+
j || (Oe.current = null);
|
|
6737
6790
|
}, [j]);
|
|
6738
|
-
let
|
|
6739
|
-
|
|
6740
|
-
}, [
|
|
6741
|
-
(
|
|
6742
|
-
}, [
|
|
6791
|
+
let $e = b((e) => {
|
|
6792
|
+
Y?.chain().focus().setImage({ src: e }).run();
|
|
6793
|
+
}, [Y]), et = b((e) => {
|
|
6794
|
+
(Y?.commands).insertVideo?.({ src: e });
|
|
6795
|
+
}, [Y]), tt = K && be && !q && !J, nt = !tt && !ge && (K || qe && !(!k && Se)), rt = w(!1);
|
|
6743
6796
|
return x(() => {
|
|
6744
|
-
|
|
6745
|
-
}, [
|
|
6797
|
+
rt.current || (rt.current = !0, K && !tt && _e(!0));
|
|
6798
|
+
}, [K, tt]), Y ? /* @__PURE__ */ O("div", {
|
|
6746
6799
|
className: "qingwu-editor-row",
|
|
6747
6800
|
children: [/* @__PURE__ */ O("div", {
|
|
6748
|
-
ref:
|
|
6801
|
+
ref: Te,
|
|
6749
6802
|
className: `qingwu-editor relative flex-1 min-w-0 bg-background ${k ? "qingwu-editor--readonly" : ""} ${l ? "" : "rounded-xl border border-default-200"} ${c}`,
|
|
6750
6803
|
style: u,
|
|
6751
6804
|
children: [
|
|
@@ -6756,13 +6809,13 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6756
6809
|
children: [
|
|
6757
6810
|
/* @__PURE__ */ D("button", {
|
|
6758
6811
|
type: "button",
|
|
6759
|
-
className: `qed-tb-btn qed-tb-btn--desktop-only${
|
|
6812
|
+
className: `qed-tb-btn qed-tb-btn--desktop-only${K ? " is-active" : ""}`,
|
|
6760
6813
|
onClick: () => {
|
|
6761
|
-
|
|
6814
|
+
K ? (he(!1), _e(!1)) : (he(!0), be && !q && !J || _e(!0));
|
|
6762
6815
|
},
|
|
6763
|
-
title:
|
|
6764
|
-
"aria-label":
|
|
6765
|
-
"aria-pressed":
|
|
6816
|
+
title: K ? "隐藏目录" : "显示目录",
|
|
6817
|
+
"aria-label": K ? "隐藏目录" : "显示目录",
|
|
6818
|
+
"aria-pressed": K,
|
|
6766
6819
|
children: /* @__PURE__ */ D("svg", {
|
|
6767
6820
|
fill: "none",
|
|
6768
6821
|
viewBox: "0 0 24 24",
|
|
@@ -6778,11 +6831,11 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6778
6831
|
}),
|
|
6779
6832
|
h && /* @__PURE__ */ D("button", {
|
|
6780
6833
|
type: "button",
|
|
6781
|
-
className: `qed-tb-btn${
|
|
6782
|
-
onClick: () =>
|
|
6834
|
+
className: `qed-tb-btn${ve ? " is-active" : ""}`,
|
|
6835
|
+
onClick: () => ye(!ve),
|
|
6783
6836
|
title: "查找 (Ctrl+F)",
|
|
6784
6837
|
"aria-label": "查找",
|
|
6785
|
-
"aria-pressed":
|
|
6838
|
+
"aria-pressed": ve,
|
|
6786
6839
|
children: /* @__PURE__ */ D("svg", {
|
|
6787
6840
|
fill: "none",
|
|
6788
6841
|
viewBox: "0 0 24 24",
|
|
@@ -6799,7 +6852,7 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6799
6852
|
!k && /* @__PURE__ */ D("button", {
|
|
6800
6853
|
type: "button",
|
|
6801
6854
|
className: `qed-tb-btn qed-tb-btn--ai${j ? " is-active" : ""}`,
|
|
6802
|
-
onClick: (e) => j ? M(!1) :
|
|
6855
|
+
onClick: (e) => j ? M(!1) : Qe(e.currentTarget),
|
|
6803
6856
|
title: f("editor.toolbar.aiTitle"),
|
|
6804
6857
|
"aria-label": f("editor.toolbar.ai"),
|
|
6805
6858
|
"aria-pressed": j,
|
|
@@ -6827,7 +6880,7 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6827
6880
|
/* @__PURE__ */ O("button", {
|
|
6828
6881
|
type: "button",
|
|
6829
6882
|
className: "qed-tb-btn qed-tb-btn--solid",
|
|
6830
|
-
onClick: () =>
|
|
6883
|
+
onClick: () => le(!0),
|
|
6831
6884
|
title: f("editor.toolbar.exportTitle"),
|
|
6832
6885
|
children: [/* @__PURE__ */ D("svg", {
|
|
6833
6886
|
fill: "none",
|
|
@@ -6847,11 +6900,11 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6847
6900
|
}),
|
|
6848
6901
|
/* @__PURE__ */ D("button", {
|
|
6849
6902
|
type: "button",
|
|
6850
|
-
className: `qed-tb-btn${
|
|
6851
|
-
onClick:
|
|
6852
|
-
title:
|
|
6853
|
-
"aria-label":
|
|
6854
|
-
"aria-pressed":
|
|
6903
|
+
className: `qed-tb-btn${q ? " is-active" : ""}`,
|
|
6904
|
+
onClick: Fe,
|
|
6905
|
+
title: q ? "退出网页全屏" : "网页全屏",
|
|
6906
|
+
"aria-label": q ? "退出网页全屏" : "网页全屏",
|
|
6907
|
+
"aria-pressed": q,
|
|
6855
6908
|
children: /* @__PURE__ */ D("svg", {
|
|
6856
6909
|
fill: "none",
|
|
6857
6910
|
viewBox: "0 0 24 24",
|
|
@@ -6867,11 +6920,11 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6867
6920
|
}),
|
|
6868
6921
|
/* @__PURE__ */ D("button", {
|
|
6869
6922
|
type: "button",
|
|
6870
|
-
className: `qed-tb-btn${
|
|
6871
|
-
onClick:
|
|
6872
|
-
title:
|
|
6873
|
-
"aria-label":
|
|
6874
|
-
"aria-pressed":
|
|
6923
|
+
className: `qed-tb-btn${J ? " is-active" : ""}`,
|
|
6924
|
+
onClick: Ie,
|
|
6925
|
+
title: J ? "退出全屏" : "全屏",
|
|
6926
|
+
"aria-label": J ? "退出全屏" : "全屏",
|
|
6927
|
+
"aria-pressed": J,
|
|
6875
6928
|
children: /* @__PURE__ */ D("svg", {
|
|
6876
6929
|
fill: "none",
|
|
6877
6930
|
viewBox: "0 0 24 24",
|
|
@@ -6888,8 +6941,8 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6888
6941
|
]
|
|
6889
6942
|
})]
|
|
6890
6943
|
}),
|
|
6891
|
-
|
|
6892
|
-
editor:
|
|
6944
|
+
Y && !k && Y.isEditable && /* @__PURE__ */ D(te, {
|
|
6945
|
+
editor: Y,
|
|
6893
6946
|
shouldShow: ({ editor: e, state: t }) => !(e.isActive("image") || e.isActive("videoEmbed") || e.isActive("codeBlock") || e.isActive("audioEmbed") || e.isActive("attachmentEmbed") || t.selection.empty),
|
|
6894
6947
|
options: {
|
|
6895
6948
|
placement: "bottom",
|
|
@@ -6898,17 +6951,17 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6898
6951
|
},
|
|
6899
6952
|
className: "bubble-menu-pop bg-background border border-default-200 rounded-xl p-1 shadow-lg",
|
|
6900
6953
|
children: /* @__PURE__ */ O("div", {
|
|
6901
|
-
ref:
|
|
6954
|
+
ref: Ae,
|
|
6902
6955
|
className: "bubble-menu-items relative flex items-center gap-0.5",
|
|
6903
6956
|
onPointerDown: (e) => {
|
|
6904
6957
|
e.target.closest("button") && e.preventDefault();
|
|
6905
6958
|
},
|
|
6906
6959
|
children: [
|
|
6907
|
-
|
|
6960
|
+
Ve.map((e) => /* @__PURE__ */ D("button", {
|
|
6908
6961
|
type: "button",
|
|
6909
|
-
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${e.isActive(
|
|
6962
|
+
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${e.isActive(Y) ? "bg-primary/10 text-primary" : "text-default-600 hover:bg-default-100"}`,
|
|
6910
6963
|
onClick: (t) => {
|
|
6911
|
-
t.preventDefault(),
|
|
6964
|
+
t.preventDefault(), Ue(e);
|
|
6912
6965
|
},
|
|
6913
6966
|
title: e.label,
|
|
6914
6967
|
"aria-label": e.label,
|
|
@@ -6922,11 +6975,11 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6922
6975
|
type: "button",
|
|
6923
6976
|
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"}`,
|
|
6924
6977
|
onClick: (e) => {
|
|
6925
|
-
e.preventDefault(),
|
|
6978
|
+
e.preventDefault(), Me(!1), He?.command(Y);
|
|
6926
6979
|
},
|
|
6927
|
-
title:
|
|
6928
|
-
"aria-label":
|
|
6929
|
-
children: /* @__PURE__ */ D(
|
|
6980
|
+
title: He?.label,
|
|
6981
|
+
"aria-label": He?.label,
|
|
6982
|
+
children: /* @__PURE__ */ D(Rt, {})
|
|
6930
6983
|
}),
|
|
6931
6984
|
/* @__PURE__ */ D("span", {
|
|
6932
6985
|
className: "w-px h-4 bg-default-200 mx-0.5 shrink-0",
|
|
@@ -6934,27 +6987,27 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6934
6987
|
}),
|
|
6935
6988
|
/* @__PURE__ */ D("button", {
|
|
6936
6989
|
type: "button",
|
|
6937
|
-
"aria-expanded":
|
|
6938
|
-
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${
|
|
6990
|
+
"aria-expanded": je,
|
|
6991
|
+
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${je ? "bg-default-100 text-default-900" : "text-default-600 hover:bg-default-100"}`,
|
|
6939
6992
|
onClick: (e) => {
|
|
6940
|
-
e.preventDefault(),
|
|
6993
|
+
e.preventDefault(), Me((e) => !e);
|
|
6941
6994
|
},
|
|
6942
6995
|
title: f("editor.bubble.more"),
|
|
6943
6996
|
"aria-label": f("editor.bubble.more"),
|
|
6944
|
-
children: /* @__PURE__ */ D(
|
|
6997
|
+
children: /* @__PURE__ */ D(zt, {})
|
|
6945
6998
|
}),
|
|
6946
|
-
|
|
6999
|
+
je && /* @__PURE__ */ D("div", {
|
|
6947
7000
|
role: "menu",
|
|
6948
7001
|
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",
|
|
6949
7002
|
onPointerDown: (e) => {
|
|
6950
7003
|
e.target.closest("button") && e.preventDefault();
|
|
6951
7004
|
},
|
|
6952
|
-
children:
|
|
7005
|
+
children: Be.map((e) => /* @__PURE__ */ O("button", {
|
|
6953
7006
|
type: "button",
|
|
6954
7007
|
role: "menuitem",
|
|
6955
|
-
className: `flex items-center gap-2 w-full whitespace-nowrap px-3 py-1.5 text-xs rounded-md transition-colors ${
|
|
7008
|
+
className: `flex items-center gap-2 w-full whitespace-nowrap px-3 py-1.5 text-xs rounded-md transition-colors ${We(e) ? "bg-primary/10 text-primary" : "text-default-600 hover:bg-default-100"}`,
|
|
6956
7009
|
onClick: (t) => {
|
|
6957
|
-
t.preventDefault(),
|
|
7010
|
+
t.preventDefault(), Ue(e);
|
|
6958
7011
|
},
|
|
6959
7012
|
title: e.label,
|
|
6960
7013
|
children: [/* @__PURE__ */ D("span", {
|
|
@@ -6969,29 +7022,29 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6969
7022
|
]
|
|
6970
7023
|
})
|
|
6971
7024
|
}),
|
|
6972
|
-
|
|
7025
|
+
Y && U !== "none" && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
6973
7026
|
className: "fixed inset-0 z-[9998]",
|
|
6974
|
-
onClick: () =>
|
|
7027
|
+
onClick: () => W("none")
|
|
6975
7028
|
}), /* @__PURE__ */ D("div", {
|
|
6976
|
-
style:
|
|
7029
|
+
style: ue,
|
|
6977
7030
|
className: "bg-background border border-default-200 rounded-xl shadow-xl",
|
|
6978
7031
|
onClick: (e) => e.stopPropagation(),
|
|
6979
|
-
children:
|
|
7032
|
+
children: U === "highlight" ? /* @__PURE__ */ O("div", {
|
|
6980
7033
|
className: "flex items-center gap-1 p-1.5 flex-wrap",
|
|
6981
|
-
children: [
|
|
7034
|
+
children: [fi.map((e) => /* @__PURE__ */ D("button", {
|
|
6982
7035
|
type: "button",
|
|
6983
7036
|
className: "w-5 h-5 rounded-full border border-default-200 hover:scale-110 transition-transform",
|
|
6984
7037
|
style: { background: e.color },
|
|
6985
7038
|
title: e.name,
|
|
6986
7039
|
onClick: () => {
|
|
6987
|
-
|
|
7040
|
+
Y.chain().focus().setHighlight({ color: e.color }).run(), W("none");
|
|
6988
7041
|
}
|
|
6989
7042
|
}, e.color)), /* @__PURE__ */ O("button", {
|
|
6990
7043
|
type: "button",
|
|
6991
7044
|
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]",
|
|
6992
7045
|
title: "清除高亮",
|
|
6993
7046
|
onClick: () => {
|
|
6994
|
-
|
|
7047
|
+
Y.chain().focus().unsetHighlight().run(), W("none");
|
|
6995
7048
|
},
|
|
6996
7049
|
children: ["✕", " "]
|
|
6997
7050
|
})]
|
|
@@ -7001,104 +7054,104 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7001
7054
|
type: "url",
|
|
7002
7055
|
className: "flex-1 px-2 py-1 text-xs rounded-md border border-default-200 bg-background focus:outline-none focus:border-primary",
|
|
7003
7056
|
placeholder: "https://...",
|
|
7004
|
-
value:
|
|
7005
|
-
onChange: (e) =>
|
|
7057
|
+
value: G,
|
|
7058
|
+
onChange: (e) => fe(e.target.value),
|
|
7006
7059
|
onKeyDown: (e) => {
|
|
7007
|
-
e.key === "Enter" ? (
|
|
7060
|
+
e.key === "Enter" ? (G.trim() && Y.chain().focus().setLink({ href: G.trim() }).run(), W("none")) : e.key === "Escape" && W("none");
|
|
7008
7061
|
}
|
|
7009
7062
|
}), /* @__PURE__ */ D("button", {
|
|
7010
7063
|
type: "button",
|
|
7011
7064
|
className: "px-2 py-1 text-xs rounded-md bg-primary text-white hover:opacity-90",
|
|
7012
7065
|
onClick: () => {
|
|
7013
|
-
|
|
7066
|
+
G.trim() && Y.chain().focus().setLink({ href: G.trim() }).run(), W("none");
|
|
7014
7067
|
},
|
|
7015
7068
|
children: "确定"
|
|
7016
7069
|
})]
|
|
7017
7070
|
})
|
|
7018
7071
|
})] }),
|
|
7019
|
-
!k && j &&
|
|
7072
|
+
!k && j && ne(/* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
7020
7073
|
className: "fixed inset-0 z-[9998]",
|
|
7021
7074
|
onClick: () => M(!1)
|
|
7022
7075
|
}), /* @__PURE__ */ O("div", {
|
|
7023
|
-
ref:
|
|
7076
|
+
ref: z,
|
|
7024
7077
|
"data-lenis-prevent": !0,
|
|
7025
|
-
style:
|
|
7026
|
-
className: `ai-panel relative flex flex-col bg-background border border-default-200 rounded-xl shadow-xl${
|
|
7078
|
+
style: F,
|
|
7079
|
+
className: `ai-panel relative flex flex-col bg-background border border-default-200 rounded-xl shadow-xl${L === "above" ? " ai-panel--above" : ""}`,
|
|
7027
7080
|
onClick: (e) => e.stopPropagation(),
|
|
7028
7081
|
children: [/* @__PURE__ */ D("span", {
|
|
7029
7082
|
className: "ai-panel__arrow",
|
|
7030
|
-
style: { left: `${
|
|
7083
|
+
style: { left: `${re}%` },
|
|
7031
7084
|
"aria-hidden": "true"
|
|
7032
|
-
}), /* @__PURE__ */ D(
|
|
7033
|
-
editor:
|
|
7085
|
+
}), /* @__PURE__ */ D(rn, {
|
|
7086
|
+
editor: Y,
|
|
7034
7087
|
onClose: () => M(!1)
|
|
7035
7088
|
})]
|
|
7036
7089
|
})] }), document.body),
|
|
7037
|
-
|
|
7038
|
-
fallback: /* @__PURE__ */ D(
|
|
7039
|
-
children: /* @__PURE__ */ D(
|
|
7040
|
-
open:
|
|
7041
|
-
onClose: () =>
|
|
7042
|
-
onInsert:
|
|
7043
|
-
validate: (e) =>
|
|
7090
|
+
B && /* @__PURE__ */ D(v, {
|
|
7091
|
+
fallback: /* @__PURE__ */ D(wi, {}),
|
|
7092
|
+
children: /* @__PURE__ */ D(yi, {
|
|
7093
|
+
open: B,
|
|
7094
|
+
onClose: () => ae(!1),
|
|
7095
|
+
onInsert: $e,
|
|
7096
|
+
validate: (e) => Y ? ln(Y.state.doc, e, {
|
|
7044
7097
|
maxAttachmentSize: o,
|
|
7045
7098
|
maxTotalAttachmentSize: s
|
|
7046
7099
|
}) : null
|
|
7047
7100
|
})
|
|
7048
7101
|
}),
|
|
7102
|
+
oe && /* @__PURE__ */ D(v, {
|
|
7103
|
+
fallback: /* @__PURE__ */ D(wi, {}),
|
|
7104
|
+
children: /* @__PURE__ */ D(Si, {
|
|
7105
|
+
open: oe,
|
|
7106
|
+
onClose: () => se(!1),
|
|
7107
|
+
onInsert: et
|
|
7108
|
+
})
|
|
7109
|
+
}),
|
|
7049
7110
|
ce && /* @__PURE__ */ D(v, {
|
|
7050
|
-
fallback: /* @__PURE__ */ D(
|
|
7111
|
+
fallback: /* @__PURE__ */ D(wi, {}),
|
|
7051
7112
|
children: /* @__PURE__ */ D(bi, {
|
|
7052
7113
|
open: ce,
|
|
7053
|
-
onClose: () =>
|
|
7054
|
-
onInsert: tt
|
|
7055
|
-
})
|
|
7056
|
-
}),
|
|
7057
|
-
ue && /* @__PURE__ */ D(v, {
|
|
7058
|
-
fallback: /* @__PURE__ */ D(Si, {}),
|
|
7059
|
-
children: /* @__PURE__ */ D(vi, {
|
|
7060
|
-
open: ue,
|
|
7061
|
-
onClose: () => z(!1)
|
|
7114
|
+
onClose: () => V(!1)
|
|
7062
7115
|
})
|
|
7063
7116
|
}),
|
|
7064
|
-
|
|
7065
|
-
fallback: /* @__PURE__ */ D(
|
|
7066
|
-
children: /* @__PURE__ */ D(
|
|
7067
|
-
open:
|
|
7068
|
-
onClose: () =>
|
|
7069
|
-
editor:
|
|
7117
|
+
H && /* @__PURE__ */ D(v, {
|
|
7118
|
+
fallback: /* @__PURE__ */ D(wi, {}),
|
|
7119
|
+
children: /* @__PURE__ */ D(xi, {
|
|
7120
|
+
open: H,
|
|
7121
|
+
onClose: () => le(!1),
|
|
7122
|
+
editor: Y
|
|
7070
7123
|
})
|
|
7071
7124
|
}),
|
|
7072
|
-
|
|
7073
|
-
fallback: /* @__PURE__ */ D(
|
|
7074
|
-
children: /* @__PURE__ */ D(
|
|
7075
|
-
open: !!
|
|
7076
|
-
filename:
|
|
7125
|
+
pe && /* @__PURE__ */ D(v, {
|
|
7126
|
+
fallback: /* @__PURE__ */ D(wi, {}),
|
|
7127
|
+
children: /* @__PURE__ */ D(Ci, {
|
|
7128
|
+
open: !!pe,
|
|
7129
|
+
filename: pe.filename,
|
|
7077
7130
|
onRender: () => {
|
|
7078
|
-
|
|
7131
|
+
pe.resolve("render"), me(null);
|
|
7079
7132
|
},
|
|
7080
7133
|
onAttach: () => {
|
|
7081
|
-
|
|
7134
|
+
pe.resolve("attach"), me(null);
|
|
7082
7135
|
},
|
|
7083
7136
|
onClose: () => {
|
|
7084
|
-
|
|
7137
|
+
pe.resolve(null), me(null);
|
|
7085
7138
|
}
|
|
7086
7139
|
})
|
|
7087
7140
|
}),
|
|
7088
7141
|
/* @__PURE__ */ D("div", {
|
|
7089
|
-
ref:
|
|
7142
|
+
ref: Ee,
|
|
7090
7143
|
className: "flex editor-body",
|
|
7091
7144
|
children: /* @__PURE__ */ O("div", {
|
|
7092
7145
|
className: "relative min-w-0 flex-1",
|
|
7093
7146
|
children: [
|
|
7094
|
-
/* @__PURE__ */ D(
|
|
7095
|
-
!k && /* @__PURE__ */ D(
|
|
7147
|
+
/* @__PURE__ */ D(P, { editor: Y }),
|
|
7148
|
+
!k && /* @__PURE__ */ D(di, { editor: Y }),
|
|
7096
7149
|
/* @__PURE__ */ D("div", {
|
|
7097
|
-
className: `${
|
|
7150
|
+
className: `${q || J ? "fixed" : "absolute"} bottom-2 right-4 z-10 pointer-events-none select-none`,
|
|
7098
7151
|
children: /* @__PURE__ */ O("span", {
|
|
7099
|
-
className: `text-xs ${
|
|
7152
|
+
className: `text-xs ${Xe ? "bg-danger/10 text-danger font-medium px-2 py-0.5 rounded" : a && Ye > a * .9 ? "bg-warning/10 text-warning px-2 py-0.5 rounded" : "text-default-300"}`,
|
|
7100
7153
|
children: [
|
|
7101
|
-
|
|
7154
|
+
Ye,
|
|
7102
7155
|
a ? ` / ${a}` : "",
|
|
7103
7156
|
" 字"
|
|
7104
7157
|
]
|
|
@@ -7107,14 +7160,14 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7107
7160
|
]
|
|
7108
7161
|
})
|
|
7109
7162
|
}),
|
|
7110
|
-
h &&
|
|
7111
|
-
editor:
|
|
7112
|
-
onClose: () =>
|
|
7163
|
+
h && ve && /* @__PURE__ */ D(Dt, {
|
|
7164
|
+
editor: Y,
|
|
7165
|
+
onClose: () => ye(!1)
|
|
7113
7166
|
}),
|
|
7114
|
-
|
|
7167
|
+
nt && /* @__PURE__ */ D("button", {
|
|
7115
7168
|
type: "button",
|
|
7116
7169
|
className: "qingwu-toc-fab",
|
|
7117
|
-
onClick: () =>
|
|
7170
|
+
onClick: () => _e(!0),
|
|
7118
7171
|
title: "目录",
|
|
7119
7172
|
"aria-label": "打开目录",
|
|
7120
7173
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -7130,7 +7183,7 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7130
7183
|
})
|
|
7131
7184
|
})
|
|
7132
7185
|
}),
|
|
7133
|
-
|
|
7186
|
+
ge && /* @__PURE__ */ O("div", {
|
|
7134
7187
|
className: "qingwu-toc-drawer toc-scroll",
|
|
7135
7188
|
children: [/* @__PURE__ */ O("div", {
|
|
7136
7189
|
className: "qed-drawer-head",
|
|
@@ -7140,7 +7193,7 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7140
7193
|
}), /* @__PURE__ */ D("button", {
|
|
7141
7194
|
type: "button",
|
|
7142
7195
|
className: "qed-drawer-head__close",
|
|
7143
|
-
onClick: () =>
|
|
7196
|
+
onClick: () => _e(!1),
|
|
7144
7197
|
"aria-label": "关闭目录",
|
|
7145
7198
|
children: /* @__PURE__ */ D("svg", {
|
|
7146
7199
|
fill: "none",
|
|
@@ -7155,20 +7208,20 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7155
7208
|
})
|
|
7156
7209
|
})
|
|
7157
7210
|
})]
|
|
7158
|
-
}), /* @__PURE__ */ D(
|
|
7159
|
-
editor:
|
|
7211
|
+
}), /* @__PURE__ */ D(lt, {
|
|
7212
|
+
editor: Y,
|
|
7160
7213
|
className: "!p-3",
|
|
7161
7214
|
onClose: () => {
|
|
7162
|
-
|
|
7215
|
+
_e(!1), he(!1);
|
|
7163
7216
|
}
|
|
7164
7217
|
})]
|
|
7165
7218
|
})
|
|
7166
7219
|
]
|
|
7167
|
-
}),
|
|
7220
|
+
}), tt && /* @__PURE__ */ D("aside", {
|
|
7168
7221
|
className: "qingwu-toc-desktop toc-scroll",
|
|
7169
|
-
children: /* @__PURE__ */ D(
|
|
7170
|
-
editor:
|
|
7171
|
-
onClose: () =>
|
|
7222
|
+
children: /* @__PURE__ */ D(lt, {
|
|
7223
|
+
editor: Y,
|
|
7224
|
+
onClose: () => he(!1)
|
|
7172
7225
|
})
|
|
7173
7226
|
})]
|
|
7174
7227
|
}) : /* @__PURE__ */ D("div", {
|
|
@@ -7178,7 +7231,7 @@ var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7178
7231
|
};
|
|
7179
7232
|
//#endregion
|
|
7180
7233
|
//#region src/editor/clipper/receiver-browser.ts
|
|
7181
|
-
function
|
|
7234
|
+
function Ei(e) {
|
|
7182
7235
|
let t = async (t) => {
|
|
7183
7236
|
let n = t.data;
|
|
7184
7237
|
if (!n || typeof n != "object" || n.kind !== "qingwu-clip") return;
|
|
@@ -7195,7 +7248,7 @@ function wi(e) {
|
|
|
7195
7248
|
}
|
|
7196
7249
|
//#endregion
|
|
7197
7250
|
//#region src/editor/storage/providers/cos.ts
|
|
7198
|
-
function
|
|
7251
|
+
function Di(e) {
|
|
7199
7252
|
return g({
|
|
7200
7253
|
endpoint: `https://cos.${e.region}.myqcloud.com`,
|
|
7201
7254
|
bucket: e.bucket,
|
|
@@ -7209,7 +7262,7 @@ function Ti(e) {
|
|
|
7209
7262
|
}
|
|
7210
7263
|
//#endregion
|
|
7211
7264
|
//#region src/editor/storage/providers/oss.ts
|
|
7212
|
-
function
|
|
7265
|
+
function Oi(e) {
|
|
7213
7266
|
return g({
|
|
7214
7267
|
endpoint: `https://${e.bucket}.${e.region}.aliyuncs.com`,
|
|
7215
7268
|
bucket: e.bucket,
|
|
@@ -7222,4 +7275,4 @@ function Ei(e) {
|
|
|
7222
7275
|
});
|
|
7223
7276
|
}
|
|
7224
7277
|
//#endregion
|
|
7225
|
-
export {
|
|
7278
|
+
export { $n as CODE_LANGUAGES, tr as CodeBlock, Tr as ImageUpload, $e as ImageUploadDialog, Ti as QingWuAIEditor, Xr as RelativeMedia, Tt as SearchHighlight, lt as TocPanel, Gn as VideoEmbed, ut as buildSystemPrompt, ft as createAILanguageModelProvider, Di as createCOSStorage, gt as createDeepSeekProvider, _ as createLocalStorage, Oi as createOSSStorage, ht as createOpenAICompatProvider, _t as createOpenAIProvider, vt as createQwenProvider, g as createS3Storage, Qr as createSlashCommandExtension, h as escapeHtml, sn as formatBytes, mt as getAIProvider, ai as getBubbleMenuActions, $r as getDefaultSlashCommands, on as getDocAttachmentTotal, ti as getEditorExtensions, u as getLocale, ii as getSearchEngine, Et as getSearchState, c as getStorageInfo, o as getStorageProvider, s as loadStorageConfig, r as registerS3PreviewConfig, d as sanitizeHtml, p as sanitizeSvg, pt as setAIProvider, hn as setConfirmProvider, l as setLocale, ri as setSearchEngine, i as setStorageProvider, Xe as setToastProvider, n as signPreviewUrlHeaders, Ei as startBrowserClipperReceiver, Ze as subscribeToast, f as t, m as tf, Z as toast, ln as validateAttachmentFile };
|