@qingwu-ui/ai-editor 0.9.0-beta.20 → 0.9.0-beta.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -11
- package/dist/components/release-notes-dialog.d.ts +8 -0
- package/dist/components/release-notes-dialog.d.ts.map +1 -0
- package/dist/editor/ai-editor.d.ts.map +1 -1
- package/dist/editor/extensions/index.d.ts.map +1 -1
- package/dist/editor/extensions/inline-code-end.d.ts +9 -0
- package/dist/editor/extensions/inline-code-end.d.ts.map +1 -0
- package/dist/index.cjs +8 -8
- package/dist/index.js +808 -777
- package/dist/styles.css +1 -1
- package/package.json +25 -69
- package/scripts/cli.mjs +28 -0
- package/scripts/copy-assets.mjs +114 -0
package/dist/index.js
CHANGED
|
@@ -9,56 +9,56 @@ import { DOMParser as j, Fragment as M, Slice as N } from "@tiptap/pm/model";
|
|
|
9
9
|
import { EditorContent as P, NodeViewWrapper as F, ReactNodeViewRenderer as I, ReactRenderer as L, useEditor as ee } from "@tiptap/react";
|
|
10
10
|
import { BubbleMenu as te } from "@tiptap/react/menus";
|
|
11
11
|
import { createPortal as ne } from "react-dom";
|
|
12
|
-
import { Extension as R, Node as re } from "@tiptap/core";
|
|
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
|
|
12
|
+
import { Extension as R, Node as re, markInputRule as ie } from "@tiptap/core";
|
|
13
|
+
import { NodeSelection as z, Plugin as B, PluginKey as V, TextSelection as H } from "@tiptap/pm/state";
|
|
14
|
+
import { Decoration as ae, DecorationSet as oe } from "@tiptap/pm/view";
|
|
15
|
+
import { Image as U } from "@tiptap/extension-image";
|
|
16
|
+
import { Link as W } from "@tiptap/extension-link";
|
|
17
|
+
import { Underline as G } from "@tiptap/extension-underline";
|
|
18
|
+
import K from "@tiptap/starter-kit";
|
|
19
|
+
import { CharacterCount as q } from "@tiptap/extension-character-count";
|
|
20
|
+
import { Color as se } from "@tiptap/extension-color";
|
|
21
|
+
import { Highlight as ce } from "@tiptap/extension-highlight";
|
|
22
|
+
import { HorizontalRule as le } from "@tiptap/extension-horizontal-rule";
|
|
23
|
+
import { Placeholder as ue } from "@tiptap/extension-placeholder";
|
|
24
|
+
import { Table as de } from "@tiptap/extension-table";
|
|
25
|
+
import { TableCell as fe } from "@tiptap/extension-table-cell";
|
|
26
|
+
import { TableHeader as pe } from "@tiptap/extension-table-header";
|
|
27
|
+
import { TableRow as me } 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, { exitSuggestion as we, findSuggestionMatch as Te } 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 Ee = null, De = null;
|
|
38
|
+
function Oe() {
|
|
39
|
+
return De || (typeof document > "u" ? null : (Ee = document.createElement("canvas"), De = Ee.getContext("2d"), De));
|
|
40
|
+
}
|
|
41
|
+
var ke = /* @__PURE__ */ new Map();
|
|
42
|
+
function Ae(e, t) {
|
|
43
|
+
let n = ke.get(t);
|
|
44
|
+
n || (n = /* @__PURE__ */ new Map(), ke.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 = Oe();
|
|
48
|
+
return i ? (i.font = t, r = i.measureText(e).width) : r = je(e, t), n.set(e, r), r;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function je(e, t) {
|
|
51
51
|
let n = parseFloat(t) || 16, r = 0;
|
|
52
|
-
for (let t of e)
|
|
52
|
+
for (let t of e) Me(t.codePointAt(0) ?? 0) ? r += n : t === " " ? r += n * .3 : r += n * .55;
|
|
53
53
|
return r;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function Me(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 Ne(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 Pe(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 J(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" : Me(r) && (i = Ne(r) ? "punct" : "cjk"), n.push({
|
|
73
73
|
text: e,
|
|
74
|
-
width:
|
|
74
|
+
width: Ae(e, t),
|
|
75
75
|
type: i
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
return n;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function J(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 Fe(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 Ie(e, t, n = "16px system-ui") {
|
|
92
|
+
let { maxWidth: r, lineHeight: i, maxLines: a, overflowWrap: o = "break-word" } = t, s = Pe(e, n), c = [], l = {
|
|
93
93
|
lineStart: 0,
|
|
94
94
|
lineWidth: 0,
|
|
95
95
|
lastBreakIdx: -1,
|
|
@@ -98,28 +98,28 @@ function Pe(e, t, n = "16px system-ui") {
|
|
|
98
98
|
for (let e = 0; e < s.length; e++) {
|
|
99
99
|
let t = s[e];
|
|
100
100
|
if (t.type === "break") {
|
|
101
|
-
c.push(
|
|
101
|
+
c.push(Fe(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(Fe(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = J(s, l.lineStart, e + 1)) : (c.push(Fe(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(Fe(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(Fe(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = J(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(Fe(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = J(s, l.lineStart, e + 1), l.lastBreakIdx = -1) : o === "break-word" ? (c.push(Fe(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 = J(s, l.lineStart, s.length);
|
|
122
|
+
c.push(Fe(s, l.lineStart, s.length, e));
|
|
123
123
|
}
|
|
124
124
|
return {
|
|
125
125
|
lines: c,
|
|
@@ -130,36 +130,36 @@ function Pe(e, t, n = "16px system-ui") {
|
|
|
130
130
|
}
|
|
131
131
|
//#endregion
|
|
132
132
|
//#region ../toast/dist/index.mjs
|
|
133
|
-
var
|
|
134
|
-
function
|
|
133
|
+
var Le = typeof window < "u" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, Re = "13.5px -apple-system, BlinkMacSystemFont, \"SF Pro Text\", \"PingFang SC\", \"Microsoft YaHei\", system-ui, sans-serif";
|
|
134
|
+
function ze() {
|
|
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 Be = {
|
|
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
|
+
}, Y = 1;
|
|
145
|
+
function Ve() {
|
|
146
|
+
return `qt${Y++}${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 He(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 Ue = {
|
|
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
|
+
}, We = [
|
|
172
172
|
80,
|
|
173
173
|
40,
|
|
174
174
|
80
|
|
175
175
|
];
|
|
176
|
-
function
|
|
176
|
+
function Ge() {
|
|
177
177
|
if (!(typeof navigator > "u" || !("vibrate" in navigator))) try {
|
|
178
|
-
navigator.vibrate(
|
|
178
|
+
navigator.vibrate(We);
|
|
179
179
|
} catch {}
|
|
180
180
|
}
|
|
181
|
-
var
|
|
181
|
+
var Ke = class {
|
|
182
182
|
containers = /* @__PURE__ */ new Map();
|
|
183
|
-
opts = { ...
|
|
183
|
+
opts = { ...Ue };
|
|
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 = Ve(), 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 = Be[n], s.appendChild(c);
|
|
282
|
+
let l = X("div", "qt-body"), u = X("span", "qt-msg"), d = Ie(t, {
|
|
283
|
+
maxWidth: ze(),
|
|
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
|
+
}, Re);
|
|
287
|
+
if (d.lineCount <= 1 ? He(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 += "…"), He(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 && Ge(), 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 (Le) 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
|
-
|
|
348
|
+
}, qe = null;
|
|
349
|
+
function Je() {
|
|
350
|
+
return qe ||= new Ke(), qe;
|
|
351
|
+
}
|
|
352
|
+
var Ye = Object.assign((e, t) => Je().show(e, t), {
|
|
353
|
+
info: (e, t) => Je().info(e, t),
|
|
354
|
+
success: (e, t) => Je().success(e, t),
|
|
355
|
+
warn: (e, t) => Je().warn(e, t),
|
|
356
|
+
error: (e, t) => Je().error(e, t),
|
|
357
|
+
promise: (e, t, n) => Je().promise(e, t, n),
|
|
358
|
+
dismiss: (e) => Je().dismiss(e),
|
|
359
|
+
dismissAll: () => Je().dismissAll(),
|
|
360
|
+
configure: (e) => Je().configure(e)
|
|
361
|
+
}), Xe = /* @__PURE__ */ new Set(), Ze = null;
|
|
362
|
+
function Qe(e) {
|
|
363
|
+
Ze = e;
|
|
364
364
|
}
|
|
365
365
|
function Z(e, t = "error", n) {
|
|
366
366
|
let r = {
|
|
367
367
|
persist: !0,
|
|
368
368
|
...n
|
|
369
369
|
};
|
|
370
|
-
if (
|
|
371
|
-
for (let n of
|
|
370
|
+
if (Xe.size > 0) {
|
|
371
|
+
for (let n of Xe) n(e, t, r);
|
|
372
372
|
return;
|
|
373
373
|
}
|
|
374
|
-
if (
|
|
375
|
-
|
|
374
|
+
if (Ze) {
|
|
375
|
+
Ze(e, t, r);
|
|
376
376
|
return;
|
|
377
377
|
}
|
|
378
|
-
t === "success" ?
|
|
378
|
+
t === "success" ? Ye.success(e, r) : t === "info" ? Ye.info(e, r) : Ye.error(e, r);
|
|
379
379
|
}
|
|
380
|
-
function
|
|
381
|
-
return
|
|
382
|
-
|
|
380
|
+
function $e(e) {
|
|
381
|
+
return Xe.add(e), () => {
|
|
382
|
+
Xe.delete(e);
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
385
|
//#endregion
|
|
386
386
|
//#region src/components/image-upload-dialog.tsx
|
|
387
|
-
var
|
|
387
|
+
var et = /* @__PURE__ */ e({ ImageUploadDialog: () => tt }), tt = ({ open: e, onClose: t, onInsert: n, validate: r }) => {
|
|
388
388
|
let [i, a] = T("upload"), [s, c] = T(!1), [l, u] = T(!1), [d, f] = T(null), [p, m] = T(null), [h, g] = T(""), [_, v] = T(null), y = w(null), x = (() => {
|
|
389
389
|
try {
|
|
390
390
|
let e = o();
|
|
@@ -676,10 +676,10 @@ var $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 nt(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 rt(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 it(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 at(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(...at(r.children, t));
|
|
703
703
|
return n;
|
|
704
704
|
}
|
|
705
|
-
function
|
|
705
|
+
function ot(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 st(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 ct(e) {
|
|
729
729
|
if (e.isDestroyed) return null;
|
|
730
730
|
try {
|
|
731
731
|
return e.view.dom;
|
|
@@ -733,7 +733,7 @@ function st(e) {
|
|
|
733
733
|
return null;
|
|
734
734
|
}
|
|
735
735
|
}
|
|
736
|
-
function
|
|
736
|
+
function lt(e, t) {
|
|
737
737
|
if (!t) return e;
|
|
738
738
|
let n = e.toLowerCase(), r = t.toLowerCase(), i = [], a = 0, o = 0;
|
|
739
739
|
for (;;) {
|
|
@@ -746,12 +746,12 @@ function ct(e, t) {
|
|
|
746
746
|
}
|
|
747
747
|
return a < e.length && i.push(e.slice(a)), i.length ? i : e;
|
|
748
748
|
}
|
|
749
|
-
var
|
|
749
|
+
var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
750
750
|
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(() => {
|
|
751
751
|
h.current &&= (clearTimeout(h.current.timer), null);
|
|
752
752
|
}, []), v = b(() => {
|
|
753
|
-
let t =
|
|
754
|
-
return t ? Array.from(t.querySelectorAll("h1,h2,h3,h4,h5,h6")).map((e, t) => (e.id ||=
|
|
753
|
+
let t = ct(e);
|
|
754
|
+
return t ? Array.from(t.querySelectorAll("h1,h2,h3,h4,h5,h6")).map((e, t) => (e.id ||= nt(e.textContent || "", t), {
|
|
755
755
|
id: e.id,
|
|
756
756
|
level: Number(e.tagName.slice(1)),
|
|
757
757
|
text: e.textContent?.trim() || "(无标题)",
|
|
@@ -760,7 +760,7 @@ var lt = 84, ut = 3e3, dt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
760
760
|
}, [e]), y = b(() => {
|
|
761
761
|
let e = f.current;
|
|
762
762
|
if ((!e.length || e.some((e) => !e.el.isConnected)) && (e = v(), f.current = e), !e.length) return;
|
|
763
|
-
let t = m.current, n = (t ? t.getBoundingClientRect().top : 0) +
|
|
763
|
+
let t = m.current, n = (t ? t.getBoundingClientRect().top : 0) + ut, r = t ? t.scrollHeight - t.scrollTop - t.clientHeight < 2 : document.documentElement.scrollHeight - window.scrollY - window.innerHeight < 2, i = "";
|
|
764
764
|
for (let t of e) t.el.isConnected && t.el.getBoundingClientRect().top <= n && (i = t.id);
|
|
765
765
|
if (r) {
|
|
766
766
|
for (let t = e.length - 1; t >= 0; t--) if (e[t].el.isConnected) {
|
|
@@ -784,7 +784,7 @@ var lt = 84, ut = 3e3, dt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
784
784
|
t !== d.current && (d.current = t, f.current = e, i(e), S());
|
|
785
785
|
}, [v, S]);
|
|
786
786
|
x(() => {
|
|
787
|
-
let t =
|
|
787
|
+
let t = ct(e), n = t ? st(t) : null;
|
|
788
788
|
m.current = n;
|
|
789
789
|
let r = n ?? window;
|
|
790
790
|
return r.addEventListener("scroll", S, { passive: !0 }), window.addEventListener("resize", S), r.addEventListener("wheel", _, { passive: !0 }), r.addEventListener("touchstart", _, { passive: !0 }), () => {
|
|
@@ -812,7 +812,7 @@ var lt = 84, ut = 3e3, dt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
812
812
|
_
|
|
813
813
|
]);
|
|
814
814
|
let k = b((t) => {
|
|
815
|
-
let n =
|
|
815
|
+
let n = ct(e);
|
|
816
816
|
if (!n) return;
|
|
817
817
|
let r = t.el;
|
|
818
818
|
if ((!r || !n.contains(r)) && (r = n.querySelector(`[id="${CSS.escape(t.id)}"]`)), !r) {
|
|
@@ -825,29 +825,29 @@ var lt = 84, ut = 3e3, dt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
825
825
|
if (!r) return;
|
|
826
826
|
_(), h.current = {
|
|
827
827
|
id: t.id,
|
|
828
|
-
timer: setTimeout(_,
|
|
828
|
+
timer: setTimeout(_, dt)
|
|
829
829
|
}, o(t.id);
|
|
830
830
|
let i = m.current, a = r.getBoundingClientRect().top;
|
|
831
831
|
if (i) {
|
|
832
832
|
let e = i.getBoundingClientRect().top;
|
|
833
833
|
i.scrollTo({
|
|
834
|
-
top: i.scrollTop + a - e -
|
|
834
|
+
top: i.scrollTop + a - e - ut,
|
|
835
835
|
behavior: "smooth"
|
|
836
836
|
});
|
|
837
837
|
} else window.scrollTo({
|
|
838
|
-
top: window.scrollY + a -
|
|
838
|
+
top: window.scrollY + a - ut,
|
|
839
839
|
behavior: "smooth"
|
|
840
840
|
});
|
|
841
|
-
}, [e, _]), A = C(() =>
|
|
841
|
+
}, [e, _]), A = C(() => rt(r), [r]), j = C(() => it(A), [A]), M = C(() => {
|
|
842
842
|
let e = /* @__PURE__ */ new Map(), t = (n, r) => {
|
|
843
843
|
for (let i of n) r && e.set(i.id, r), t(i.children, i.id);
|
|
844
844
|
};
|
|
845
845
|
return t(A, ""), e;
|
|
846
|
-
}, [A]), N = l.trim().length > 0, P = C(() => N ?
|
|
846
|
+
}, [A]), N = l.trim().length > 0, P = C(() => N ? ot(A, l.trim()) : A, [
|
|
847
847
|
A,
|
|
848
848
|
N,
|
|
849
849
|
l
|
|
850
|
-
]), F = C(() =>
|
|
850
|
+
]), F = C(() => at(P, N ? /* @__PURE__ */ new Set() : s), [
|
|
851
851
|
P,
|
|
852
852
|
s,
|
|
853
853
|
N
|
|
@@ -1078,7 +1078,7 @@ var lt = 84, ut = 3e3, dt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1078
1078
|
title: e.text,
|
|
1079
1079
|
children: /* @__PURE__ */ D("span", {
|
|
1080
1080
|
className: "toc-text",
|
|
1081
|
-
children: N ?
|
|
1081
|
+
children: N ? lt(e.text, l.trim()) : e.text
|
|
1082
1082
|
})
|
|
1083
1083
|
})]
|
|
1084
1084
|
}, e.id);
|
|
@@ -1102,7 +1102,7 @@ var lt = 84, ut = 3e3, dt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1102
1102
|
};
|
|
1103
1103
|
//#endregion
|
|
1104
1104
|
//#region src/editor/ai/index.ts
|
|
1105
|
-
function
|
|
1105
|
+
function pt(e, t) {
|
|
1106
1106
|
return {
|
|
1107
1107
|
continue: "你是一个写作助手。请从下文尾部自然流畅地续写内容,保持风格一致。只输出续写的内容,不要加任何前缀说明。",
|
|
1108
1108
|
improve: "你是一个文字润色专家。请优化以下文本的表达,提升文采和流畅度,保持原意不变。只输出润色后的文本。",
|
|
@@ -1113,8 +1113,8 @@ function ft(e, t) {
|
|
|
1113
1113
|
zap: t || "你是一个全能的 AI 写作助手。请根据用户的指令处理文本。"
|
|
1114
1114
|
}[e];
|
|
1115
1115
|
}
|
|
1116
|
-
var
|
|
1117
|
-
async function
|
|
1116
|
+
var mt = null;
|
|
1117
|
+
async function ht(e) {
|
|
1118
1118
|
let t;
|
|
1119
1119
|
try {
|
|
1120
1120
|
({createOpenAI: t} = await import("@ai-sdk/openai"));
|
|
@@ -1129,7 +1129,7 @@ async function mt(e) {
|
|
|
1129
1129
|
async *stream(e) {
|
|
1130
1130
|
let t = await A({
|
|
1131
1131
|
model: n,
|
|
1132
|
-
system:
|
|
1132
|
+
system: pt(e.mode, e.instruction),
|
|
1133
1133
|
prompt: e.context,
|
|
1134
1134
|
temperature: .7,
|
|
1135
1135
|
maxOutputTokens: 2048
|
|
@@ -1139,7 +1139,7 @@ async function mt(e) {
|
|
|
1139
1139
|
async generate(e) {
|
|
1140
1140
|
return (await k({
|
|
1141
1141
|
model: n,
|
|
1142
|
-
system:
|
|
1142
|
+
system: pt(e.mode, e.instruction),
|
|
1143
1143
|
prompt: e.context,
|
|
1144
1144
|
temperature: .7,
|
|
1145
1145
|
maxOutputTokens: 2048
|
|
@@ -1147,16 +1147,16 @@ async function mt(e) {
|
|
|
1147
1147
|
}
|
|
1148
1148
|
};
|
|
1149
1149
|
}
|
|
1150
|
-
function
|
|
1151
|
-
|
|
1150
|
+
function gt(e) {
|
|
1151
|
+
mt = e;
|
|
1152
1152
|
}
|
|
1153
|
-
function
|
|
1154
|
-
if (!
|
|
1155
|
-
return
|
|
1153
|
+
function _t() {
|
|
1154
|
+
if (!mt) throw Error("未配置 AI 服务。请调用 createAILanguageModelProvider() 创建并通过 setAIProvider() 注册。");
|
|
1155
|
+
return mt;
|
|
1156
1156
|
}
|
|
1157
1157
|
//#endregion
|
|
1158
1158
|
//#region src/editor/ai/providers/openai-compat.ts
|
|
1159
|
-
function
|
|
1159
|
+
function vt(e) {
|
|
1160
1160
|
let { apiKey: t, baseURL: n, model: r, headers: i } = e;
|
|
1161
1161
|
async function* a(e, a) {
|
|
1162
1162
|
let o = await fetch(`${n}/chat/completions`, {
|
|
@@ -1207,10 +1207,10 @@ function _t(e) {
|
|
|
1207
1207
|
}
|
|
1208
1208
|
return {
|
|
1209
1209
|
async *stream(e) {
|
|
1210
|
-
yield* a(
|
|
1210
|
+
yield* a(pt(e.mode, e.instruction), e.context);
|
|
1211
1211
|
},
|
|
1212
1212
|
async generate(e) {
|
|
1213
|
-
let t =
|
|
1213
|
+
let t = pt(e.mode, e.instruction), n = "";
|
|
1214
1214
|
for await (let r of a(t, e.context)) n += r;
|
|
1215
1215
|
return n;
|
|
1216
1216
|
}
|
|
@@ -1218,8 +1218,8 @@ function _t(e) {
|
|
|
1218
1218
|
}
|
|
1219
1219
|
//#endregion
|
|
1220
1220
|
//#region src/editor/ai/providers/deepseek.ts
|
|
1221
|
-
function
|
|
1222
|
-
return
|
|
1221
|
+
function yt(e) {
|
|
1222
|
+
return vt({
|
|
1223
1223
|
apiKey: e.apiKey,
|
|
1224
1224
|
baseURL: e.baseURL || "https://api.deepseek.com/v1",
|
|
1225
1225
|
model: e.model || "deepseek-v4-flash",
|
|
@@ -1228,8 +1228,8 @@ function vt(e) {
|
|
|
1228
1228
|
}
|
|
1229
1229
|
//#endregion
|
|
1230
1230
|
//#region src/editor/ai/providers/openai.ts
|
|
1231
|
-
function
|
|
1232
|
-
return
|
|
1231
|
+
function bt(e) {
|
|
1232
|
+
return vt({
|
|
1233
1233
|
apiKey: e.apiKey,
|
|
1234
1234
|
baseURL: e.baseURL || "https://api.openai.com/v1",
|
|
1235
1235
|
model: e.model || "gpt-5.6-luna",
|
|
@@ -1238,8 +1238,8 @@ function yt(e) {
|
|
|
1238
1238
|
}
|
|
1239
1239
|
//#endregion
|
|
1240
1240
|
//#region src/editor/ai/providers/qwen.ts
|
|
1241
|
-
function
|
|
1242
|
-
return
|
|
1241
|
+
function xt(e) {
|
|
1242
|
+
return vt({
|
|
1243
1243
|
apiKey: e.apiKey,
|
|
1244
1244
|
baseURL: e.baseURL || "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
1245
1245
|
model: e.model || "qwen3.7-plus",
|
|
@@ -1248,20 +1248,20 @@ function bt(e) {
|
|
|
1248
1248
|
}
|
|
1249
1249
|
//#endregion
|
|
1250
1250
|
//#region src/editor/extensions/search-highlight.ts
|
|
1251
|
-
var
|
|
1251
|
+
var St = {
|
|
1252
1252
|
keyword: "",
|
|
1253
1253
|
caseSensitive: !1,
|
|
1254
1254
|
wholeWord: !1,
|
|
1255
1255
|
matches: [],
|
|
1256
1256
|
currentIndex: -1
|
|
1257
|
-
},
|
|
1258
|
-
function
|
|
1257
|
+
}, Ct = new V("search-highlight");
|
|
1258
|
+
function wt(e) {
|
|
1259
1259
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1260
1260
|
}
|
|
1261
|
-
function
|
|
1261
|
+
function Tt(e, t) {
|
|
1262
1262
|
let { keyword: n, caseSensitive: r, wholeWord: i } = t;
|
|
1263
1263
|
if (!n) return [];
|
|
1264
|
-
let a = r ? "g" : "gi", o = i ? `\\b${
|
|
1264
|
+
let a = r ? "g" : "gi", o = i ? `\\b${wt(n)}\\b` : wt(n), s = new RegExp(o, a), c = [];
|
|
1265
1265
|
return e.descendants((e, t) => {
|
|
1266
1266
|
if (!e.isText || !e.text) return;
|
|
1267
1267
|
s.lastIndex = 0;
|
|
@@ -1275,12 +1275,12 @@ function wt(e, t) {
|
|
|
1275
1275
|
}
|
|
1276
1276
|
}), c;
|
|
1277
1277
|
}
|
|
1278
|
-
function Tt(e, t) {
|
|
1279
|
-
if (t.matches.length === 0) return ae.empty;
|
|
1280
|
-
let n = t.matches.map((e, n) => H.inline(e.from, e.to, { class: n === t.currentIndex ? "search-highlight search-highlight--active" : "search-highlight" }));
|
|
1281
|
-
return ae.create(e, n);
|
|
1282
|
-
}
|
|
1283
1278
|
function Et(e, t) {
|
|
1279
|
+
if (t.matches.length === 0) return oe.empty;
|
|
1280
|
+
let n = t.matches.map((e, n) => ae.inline(e.from, e.to, { class: n === t.currentIndex ? "search-highlight search-highlight--active" : "search-highlight" }));
|
|
1281
|
+
return oe.create(e, n);
|
|
1282
|
+
}
|
|
1283
|
+
function Dt(e, t) {
|
|
1284
1284
|
if (t.currentIndex < 0 || t.currentIndex >= t.matches.length) return;
|
|
1285
1285
|
let n = t.matches[t.currentIndex];
|
|
1286
1286
|
n && requestAnimationFrame(() => {
|
|
@@ -1305,15 +1305,15 @@ function Et(e, t) {
|
|
|
1305
1305
|
} catch {}
|
|
1306
1306
|
});
|
|
1307
1307
|
}
|
|
1308
|
-
var
|
|
1308
|
+
var Ot = R.create({
|
|
1309
1309
|
name: "searchHighlight",
|
|
1310
1310
|
addProseMirrorPlugins() {
|
|
1311
|
-
return [new
|
|
1312
|
-
key:
|
|
1311
|
+
return [new B({
|
|
1312
|
+
key: Ct,
|
|
1313
1313
|
state: {
|
|
1314
|
-
init: () =>
|
|
1314
|
+
init: () => St,
|
|
1315
1315
|
apply(e, t) {
|
|
1316
|
-
let n = e.getMeta(
|
|
1316
|
+
let n = e.getMeta(Ct);
|
|
1317
1317
|
if (n) return {
|
|
1318
1318
|
...t,
|
|
1319
1319
|
...n,
|
|
@@ -1321,7 +1321,7 @@ var Dt = R.create({
|
|
|
1321
1321
|
currentIndex: n.currentIndex === void 0 ? t.currentIndex : n.currentIndex
|
|
1322
1322
|
};
|
|
1323
1323
|
if (e.docChanged && t.keyword) {
|
|
1324
|
-
let n =
|
|
1324
|
+
let n = Tt(e.doc, t), r = t.currentIndex;
|
|
1325
1325
|
return r >= n.length && (r = n.length - 1), r < 0 && (r = n.length > 0 ? 0 : -1), {
|
|
1326
1326
|
...t,
|
|
1327
1327
|
matches: n,
|
|
@@ -1332,52 +1332,52 @@ var Dt = R.create({
|
|
|
1332
1332
|
}
|
|
1333
1333
|
},
|
|
1334
1334
|
props: { decorations(e) {
|
|
1335
|
-
let t =
|
|
1336
|
-
return t ?
|
|
1335
|
+
let t = Ct.getState(e);
|
|
1336
|
+
return t ? Et(e.doc, t) : oe.empty;
|
|
1337
1337
|
} }
|
|
1338
1338
|
})];
|
|
1339
1339
|
},
|
|
1340
1340
|
addCommands() {
|
|
1341
1341
|
return {
|
|
1342
1342
|
setSearch: (e, t = {}) => ({ state: n, dispatch: r, view: i }) => {
|
|
1343
|
-
let a =
|
|
1343
|
+
let a = Ct.getState(n) || St, o = {
|
|
1344
1344
|
keyword: e,
|
|
1345
1345
|
caseSensitive: t.caseSensitive ?? a.caseSensitive,
|
|
1346
1346
|
wholeWord: t.wholeWord ?? a.wholeWord,
|
|
1347
1347
|
matches: [],
|
|
1348
1348
|
currentIndex: -1
|
|
1349
1349
|
};
|
|
1350
|
-
return o.matches =
|
|
1350
|
+
return o.matches = Tt(n.doc, o), o.currentIndex = o.matches.length > 0 ? 0 : -1, r && (r(n.tr.setMeta(Ct, o)), i && Dt(i, o)), !0;
|
|
1351
1351
|
},
|
|
1352
1352
|
nextMatch: () => ({ state: e, dispatch: t, view: n }) => {
|
|
1353
|
-
let r =
|
|
1353
|
+
let r = Ct.getState(e) || St;
|
|
1354
1354
|
if (r.matches.length === 0) return !1;
|
|
1355
1355
|
let i = (r.currentIndex + 1) % r.matches.length;
|
|
1356
|
-
return t && (t(e.tr.setMeta(
|
|
1356
|
+
return t && (t(e.tr.setMeta(Ct, { currentIndex: i })), n && Dt(n, {
|
|
1357
1357
|
...r,
|
|
1358
1358
|
currentIndex: i
|
|
1359
1359
|
})), !0;
|
|
1360
1360
|
},
|
|
1361
1361
|
prevMatch: () => ({ state: e, dispatch: t, view: n }) => {
|
|
1362
|
-
let r =
|
|
1362
|
+
let r = Ct.getState(e) || St;
|
|
1363
1363
|
if (r.matches.length === 0) return !1;
|
|
1364
1364
|
let i = (r.currentIndex - 1 + r.matches.length) % r.matches.length;
|
|
1365
|
-
return t && (t(e.tr.setMeta(
|
|
1365
|
+
return t && (t(e.tr.setMeta(Ct, { currentIndex: i })), n && Dt(n, {
|
|
1366
1366
|
...r,
|
|
1367
1367
|
currentIndex: i
|
|
1368
1368
|
})), !0;
|
|
1369
1369
|
},
|
|
1370
|
-
clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(
|
|
1370
|
+
clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(Ct, St)), !0)
|
|
1371
1371
|
};
|
|
1372
1372
|
}
|
|
1373
1373
|
});
|
|
1374
|
-
function
|
|
1374
|
+
function kt(e) {
|
|
1375
1375
|
let t = e.state;
|
|
1376
|
-
return
|
|
1376
|
+
return Ct.getState(t) || St;
|
|
1377
1377
|
}
|
|
1378
1378
|
//#endregion
|
|
1379
1379
|
//#region src/components/search-bar.tsx
|
|
1380
|
-
var
|
|
1380
|
+
var At = ({ editor: e, onClose: t }) => {
|
|
1381
1381
|
let [n, r] = T(""), [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(0), u = w(null), d = w({
|
|
1382
1382
|
keyword: n,
|
|
1383
1383
|
caseSensitive: i,
|
|
@@ -1442,7 +1442,7 @@ var kt = ({ editor: e, onClose: t }) => {
|
|
|
1442
1442
|
}, [f, p]), h = C(() => {
|
|
1443
1443
|
if (!e) return null;
|
|
1444
1444
|
try {
|
|
1445
|
-
return
|
|
1445
|
+
return kt(e);
|
|
1446
1446
|
} catch {
|
|
1447
1447
|
return null;
|
|
1448
1448
|
}
|
|
@@ -1594,36 +1594,36 @@ function Q({ children: e, ...t }) {
|
|
|
1594
1594
|
children: e
|
|
1595
1595
|
});
|
|
1596
1596
|
}
|
|
1597
|
-
var
|
|
1597
|
+
var jt = (e) => /* @__PURE__ */ O(Q, {
|
|
1598
1598
|
...e,
|
|
1599
1599
|
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" })]
|
|
1600
|
-
}),
|
|
1600
|
+
}), Mt = (e) => /* @__PURE__ */ O(Q, {
|
|
1601
1601
|
...e,
|
|
1602
1602
|
children: [
|
|
1603
1603
|
/* @__PURE__ */ D("path", { d: "M19 4h-9" }),
|
|
1604
1604
|
/* @__PURE__ */ D("path", { d: "M14 20H5" }),
|
|
1605
1605
|
/* @__PURE__ */ D("path", { d: "M15 4 9 20" })
|
|
1606
1606
|
]
|
|
1607
|
-
}),
|
|
1607
|
+
}), Nt = (e) => /* @__PURE__ */ O(Q, {
|
|
1608
1608
|
...e,
|
|
1609
1609
|
children: [/* @__PURE__ */ D("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }), /* @__PURE__ */ D("path", { d: "M4 20h16" })]
|
|
1610
|
-
}),
|
|
1610
|
+
}), Pt = (e) => /* @__PURE__ */ O(Q, {
|
|
1611
1611
|
...e,
|
|
1612
1612
|
children: [
|
|
1613
1613
|
/* @__PURE__ */ D("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
|
|
1614
1614
|
/* @__PURE__ */ D("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
|
|
1615
1615
|
/* @__PURE__ */ D("path", { d: "M4 12h16" })
|
|
1616
1616
|
]
|
|
1617
|
-
}),
|
|
1617
|
+
}), Ft = (e) => /* @__PURE__ */ O(Q, {
|
|
1618
1618
|
...e,
|
|
1619
1619
|
children: [/* @__PURE__ */ D("path", { d: "m16 18 6-6-6-6" }), /* @__PURE__ */ D("path", { d: "m8 6-6 6 6 6" })]
|
|
1620
|
-
}),
|
|
1620
|
+
}), It = (e) => /* @__PURE__ */ O(Q, {
|
|
1621
1621
|
...e,
|
|
1622
1622
|
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" })]
|
|
1623
|
-
}),
|
|
1623
|
+
}), Lt = (e) => /* @__PURE__ */ O(Q, {
|
|
1624
1624
|
...e,
|
|
1625
1625
|
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" })]
|
|
1626
|
-
}),
|
|
1626
|
+
}), Rt = (e) => /* @__PURE__ */ O(Q, {
|
|
1627
1627
|
...e,
|
|
1628
1628
|
children: [/* @__PURE__ */ D("rect", {
|
|
1629
1629
|
x: "3",
|
|
@@ -1633,7 +1633,7 @@ var At = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1633
1633
|
rx: "2",
|
|
1634
1634
|
ry: "2"
|
|
1635
1635
|
}), /* @__PURE__ */ D("path", { d: "M3 9h18M3 15h18M9 3v18M15 3v18" })]
|
|
1636
|
-
}),
|
|
1636
|
+
}), zt = (e) => /* @__PURE__ */ O(Q, {
|
|
1637
1637
|
...e,
|
|
1638
1638
|
children: [/* @__PURE__ */ D("rect", {
|
|
1639
1639
|
x: "8",
|
|
@@ -1643,17 +1643,17 @@ var At = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1643
1643
|
rx: "2",
|
|
1644
1644
|
ry: "2"
|
|
1645
1645
|
}), /* @__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" })]
|
|
1646
|
-
}),
|
|
1646
|
+
}), Bt = (e) => /* @__PURE__ */ O(Q, {
|
|
1647
1647
|
...e,
|
|
1648
1648
|
children: [/* @__PURE__ */ D("circle", {
|
|
1649
1649
|
cx: "11",
|
|
1650
1650
|
cy: "11",
|
|
1651
1651
|
r: "8"
|
|
1652
1652
|
}), /* @__PURE__ */ D("path", { d: "m21 21-4.3-4.3" })]
|
|
1653
|
-
}),
|
|
1653
|
+
}), Vt = (e) => /* @__PURE__ */ O(Q, {
|
|
1654
1654
|
...e,
|
|
1655
1655
|
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" })]
|
|
1656
|
-
}),
|
|
1656
|
+
}), Ht = (e) => /* @__PURE__ */ O(Q, {
|
|
1657
1657
|
...e,
|
|
1658
1658
|
children: [
|
|
1659
1659
|
/* @__PURE__ */ D("circle", {
|
|
@@ -1672,13 +1672,13 @@ var At = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1672
1672
|
r: "1"
|
|
1673
1673
|
})
|
|
1674
1674
|
]
|
|
1675
|
-
}),
|
|
1675
|
+
}), Ut = (e) => /* @__PURE__ */ O(Q, {
|
|
1676
1676
|
...e,
|
|
1677
1677
|
children: [/* @__PURE__ */ D("path", { d: "M18 6 6 18" }), /* @__PURE__ */ D("path", { d: "m6 6 12 12" })]
|
|
1678
1678
|
});
|
|
1679
1679
|
//#endregion
|
|
1680
1680
|
//#region src/editor/storage/remove-resource.ts
|
|
1681
|
-
async function
|
|
1681
|
+
async function Wt(e) {
|
|
1682
1682
|
if (e) {
|
|
1683
1683
|
if (e.startsWith("blob:")) {
|
|
1684
1684
|
URL.revokeObjectURL(e);
|
|
@@ -1693,61 +1693,61 @@ async function Ut(e) {
|
|
|
1693
1693
|
}
|
|
1694
1694
|
//#endregion
|
|
1695
1695
|
//#region src/editor/ai/pending-removal.ts
|
|
1696
|
-
var
|
|
1696
|
+
var Gt = 3e4, Kt = /* @__PURE__ */ new Set([
|
|
1697
1697
|
"image",
|
|
1698
1698
|
"attachmentEmbed",
|
|
1699
1699
|
"audioEmbed",
|
|
1700
1700
|
"videoEmbed"
|
|
1701
|
-
]),
|
|
1702
|
-
function
|
|
1701
|
+
]), qt = /* @__PURE__ */ new WeakMap();
|
|
1702
|
+
function Jt(e) {
|
|
1703
1703
|
let t = /* @__PURE__ */ new Set();
|
|
1704
1704
|
return e.state.doc.descendants((e) => {
|
|
1705
|
-
if (
|
|
1705
|
+
if (Kt.has(e.type.name)) {
|
|
1706
1706
|
let n = e.attrs.src;
|
|
1707
1707
|
n && t.add(n);
|
|
1708
1708
|
}
|
|
1709
1709
|
return !0;
|
|
1710
1710
|
}), t;
|
|
1711
1711
|
}
|
|
1712
|
-
function
|
|
1713
|
-
let t =
|
|
1712
|
+
function Yt(e) {
|
|
1713
|
+
let t = qt.get(e);
|
|
1714
1714
|
return t || (t = {
|
|
1715
1715
|
timers: /* @__PURE__ */ new Map(),
|
|
1716
1716
|
onTransaction: () => {},
|
|
1717
1717
|
listening: !1
|
|
1718
|
-
},
|
|
1718
|
+
}, qt.set(e, t)), t;
|
|
1719
1719
|
}
|
|
1720
|
-
function
|
|
1720
|
+
function Xt(e, t) {
|
|
1721
1721
|
let n = [...new Set(t.filter(Boolean))];
|
|
1722
1722
|
if (n.length === 0) return;
|
|
1723
|
-
let r =
|
|
1723
|
+
let r = Yt(e);
|
|
1724
1724
|
r.listening ||= (r.onTransaction = () => {
|
|
1725
1725
|
if (r.timers.size === 0) return;
|
|
1726
|
-
let t =
|
|
1726
|
+
let t = Jt(e);
|
|
1727
1727
|
for (let [e, n] of r.timers) t.has(e) && (clearTimeout(n), r.timers.delete(e));
|
|
1728
1728
|
}, e.on("transaction", r.onTransaction), !0);
|
|
1729
1729
|
for (let t of n) {
|
|
1730
1730
|
if (r.timers.has(t)) continue;
|
|
1731
1731
|
let n = setTimeout(() => {
|
|
1732
|
-
|
|
1733
|
-
},
|
|
1732
|
+
Jt(e).has(t) || Wt(t), r.timers.delete(t);
|
|
1733
|
+
}, Gt);
|
|
1734
1734
|
r.timers.set(t, n);
|
|
1735
1735
|
}
|
|
1736
1736
|
}
|
|
1737
|
-
function
|
|
1738
|
-
let t =
|
|
1737
|
+
function Zt(e) {
|
|
1738
|
+
let t = qt.get(e);
|
|
1739
1739
|
if (t) {
|
|
1740
1740
|
if (t.listening &&= (e.off("transaction", t.onTransaction), !1), t.timers.size > 0) {
|
|
1741
|
-
let n =
|
|
1742
|
-
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) ||
|
|
1741
|
+
let n = Jt(e);
|
|
1742
|
+
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) || Wt(e);
|
|
1743
1743
|
t.timers.clear();
|
|
1744
1744
|
}
|
|
1745
|
-
|
|
1745
|
+
qt.delete(e);
|
|
1746
1746
|
}
|
|
1747
1747
|
}
|
|
1748
1748
|
//#endregion
|
|
1749
1749
|
//#region src/editor/ai/components/ai-selector.tsx
|
|
1750
|
-
var
|
|
1750
|
+
var Qt = [
|
|
1751
1751
|
{
|
|
1752
1752
|
mode: "continue",
|
|
1753
1753
|
labelKey: "editor.ai.continue",
|
|
@@ -1790,24 +1790,24 @@ var Zt = [
|
|
|
1790
1790
|
descKey: "editor.ai.zapDesc",
|
|
1791
1791
|
icon: "⚡"
|
|
1792
1792
|
}
|
|
1793
|
-
],
|
|
1793
|
+
], $t = /* @__PURE__ */ new Set([
|
|
1794
1794
|
"image",
|
|
1795
1795
|
"attachmentEmbed",
|
|
1796
1796
|
"audioEmbed",
|
|
1797
1797
|
"videoEmbed"
|
|
1798
|
-
]),
|
|
1798
|
+
]), en = {
|
|
1799
1799
|
image: "editor.ai.nodeImage",
|
|
1800
1800
|
attachmentEmbed: "editor.ai.nodeAttachment",
|
|
1801
1801
|
videoEmbed: "editor.ai.nodeVideo",
|
|
1802
1802
|
audioEmbed: "editor.ai.nodeAudio"
|
|
1803
1803
|
};
|
|
1804
|
-
function
|
|
1804
|
+
function tn(e, t) {
|
|
1805
1805
|
return e.storage.qingwuUI?.parseMd?.(e.schema, t) || null;
|
|
1806
1806
|
}
|
|
1807
|
-
function
|
|
1807
|
+
function nn(e, t, n) {
|
|
1808
1808
|
let r = [];
|
|
1809
1809
|
return e.state.doc.nodesBetween(t, n, (e) => {
|
|
1810
|
-
if (
|
|
1810
|
+
if ($t.has(e.type.name)) {
|
|
1811
1811
|
let t = e.attrs.src;
|
|
1812
1812
|
t && r.push({
|
|
1813
1813
|
type: e.type.name,
|
|
@@ -1817,27 +1817,27 @@ function tn(e, t, n) {
|
|
|
1817
1817
|
return !0;
|
|
1818
1818
|
}), r;
|
|
1819
1819
|
}
|
|
1820
|
-
function
|
|
1820
|
+
function rn(e) {
|
|
1821
1821
|
let t = /* @__PURE__ */ new Set();
|
|
1822
1822
|
return e.state.doc.descendants((e) => {
|
|
1823
|
-
if (
|
|
1823
|
+
if ($t.has(e.type.name)) {
|
|
1824
1824
|
let n = e.attrs.src;
|
|
1825
1825
|
n && t.add(n);
|
|
1826
1826
|
}
|
|
1827
1827
|
return !0;
|
|
1828
1828
|
}), t;
|
|
1829
1829
|
}
|
|
1830
|
-
function
|
|
1831
|
-
let n =
|
|
1830
|
+
function an(e, t) {
|
|
1831
|
+
let n = tn(e, t);
|
|
1832
1832
|
if (n && n.size > 0) {
|
|
1833
1833
|
let t = e.state.tr;
|
|
1834
|
-
t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(
|
|
1834
|
+
t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(H.create(t.doc, t.doc.content.size)), e.view.dispatch(t.scrollIntoView()), e.commands.focus();
|
|
1835
1835
|
return;
|
|
1836
1836
|
}
|
|
1837
1837
|
e.commands.setContent(t), e.commands.focus();
|
|
1838
1838
|
}
|
|
1839
|
-
function
|
|
1840
|
-
let i =
|
|
1839
|
+
function on(e, t, n, r) {
|
|
1840
|
+
let i = tn(e, t);
|
|
1841
1841
|
if (e.commands.focus(), !i) {
|
|
1842
1842
|
let i = e.chain().focus();
|
|
1843
1843
|
n === "replace" ? i.setTextSelection({
|
|
@@ -1849,7 +1849,7 @@ function an(e, t, n, r) {
|
|
|
1849
1849
|
let a = e.state.tr;
|
|
1850
1850
|
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());
|
|
1851
1851
|
}
|
|
1852
|
-
function
|
|
1852
|
+
function sn({ editor: e, onClose: t }) {
|
|
1853
1853
|
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({
|
|
1854
1854
|
from: 0,
|
|
1855
1855
|
to: 0,
|
|
@@ -1868,7 +1868,7 @@ function on({ editor: e, onClose: t }) {
|
|
|
1868
1868
|
empty: n.empty
|
|
1869
1869
|
}, l(!0), s(""), v.current = !0, d(null);
|
|
1870
1870
|
try {
|
|
1871
|
-
let r =
|
|
1871
|
+
let r = _t(), a = n.empty ? e.state.doc.textContent : e.state.doc.textBetween(n.from, n.to), o = [];
|
|
1872
1872
|
for await (let e of r.stream({
|
|
1873
1873
|
mode: t,
|
|
1874
1874
|
context: a,
|
|
@@ -1893,13 +1893,13 @@ function on({ editor: e, onClose: t }) {
|
|
|
1893
1893
|
!e || !v.current || (e.scrollTop = e.scrollHeight);
|
|
1894
1894
|
}, [o]);
|
|
1895
1895
|
let k = b((t, n, r) => {
|
|
1896
|
-
let i = new Set(
|
|
1897
|
-
t === "replaceAll" ?
|
|
1898
|
-
let a =
|
|
1899
|
-
|
|
1896
|
+
let i = new Set(nn(e, r.from, r.to).map((e) => e.src));
|
|
1897
|
+
t === "replaceAll" ? an(e, n) : on(e, n, "replace", h.current);
|
|
1898
|
+
let a = rn(e);
|
|
1899
|
+
Xt(e, [...i].filter((e) => !a.has(e)));
|
|
1900
1900
|
}, [e]), A = b((n) => {
|
|
1901
1901
|
if (n === "below") {
|
|
1902
|
-
|
|
1902
|
+
on(e, o, "below", h.current), t();
|
|
1903
1903
|
return;
|
|
1904
1904
|
}
|
|
1905
1905
|
let r = h.current, i = n === "replaceAll" ? {
|
|
@@ -1908,7 +1908,7 @@ function on({ editor: e, onClose: t }) {
|
|
|
1908
1908
|
} : {
|
|
1909
1909
|
from: r.from,
|
|
1910
1910
|
to: r.to
|
|
1911
|
-
}, a =
|
|
1911
|
+
}, a = nn(e, i.from, i.to);
|
|
1912
1912
|
if (a.length > 0) {
|
|
1913
1913
|
m({
|
|
1914
1914
|
position: n,
|
|
@@ -1949,19 +1949,19 @@ function on({ editor: e, onClose: t }) {
|
|
|
1949
1949
|
className: "flex items-center justify-between pl-3 pr-1.5 py-1.5 border-b border-default-100 shrink-0",
|
|
1950
1950
|
children: [/* @__PURE__ */ O("span", {
|
|
1951
1951
|
className: "flex items-center gap-1.5 text-xs font-medium text-default-500",
|
|
1952
|
-
children: [/* @__PURE__ */ D(
|
|
1952
|
+
children: [/* @__PURE__ */ D(Vt, { className: "text-primary" }), f("editor.ai.trigger")]
|
|
1953
1953
|
}), /* @__PURE__ */ D("button", {
|
|
1954
1954
|
type: "button",
|
|
1955
1955
|
onClick: t,
|
|
1956
1956
|
"aria-label": f("editor.ai.close"),
|
|
1957
1957
|
title: f("editor.ai.close"),
|
|
1958
1958
|
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",
|
|
1959
|
-
children: /* @__PURE__ */ D(
|
|
1959
|
+
children: /* @__PURE__ */ D(Ut, {})
|
|
1960
1960
|
})]
|
|
1961
1961
|
}),
|
|
1962
1962
|
/* @__PURE__ */ D("div", {
|
|
1963
1963
|
className: "grid grid-cols-[repeat(auto-fit,minmax(64px,1fr))] gap-1.5 p-2 shrink-0",
|
|
1964
|
-
children:
|
|
1964
|
+
children: Qt.map(({ mode: e, labelKey: t, descKey: r, icon: i }) => /* @__PURE__ */ O("button", {
|
|
1965
1965
|
type: "button",
|
|
1966
1966
|
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"}`,
|
|
1967
1967
|
onClick: () => y(e),
|
|
@@ -2104,7 +2104,7 @@ function on({ editor: e, onClose: t }) {
|
|
|
2104
2104
|
children: Object.entries(N).map(([e, t]) => /* @__PURE__ */ O("li", {
|
|
2105
2105
|
className: "text-sm text-default-700",
|
|
2106
2106
|
children: [
|
|
2107
|
-
f(
|
|
2107
|
+
f(en[e] ?? e),
|
|
2108
2108
|
" ×",
|
|
2109
2109
|
t
|
|
2110
2110
|
]
|
|
@@ -2136,19 +2136,19 @@ function on({ editor: e, onClose: t }) {
|
|
|
2136
2136
|
}
|
|
2137
2137
|
//#endregion
|
|
2138
2138
|
//#region src/editor/attachment-limits.ts
|
|
2139
|
-
var
|
|
2139
|
+
var cn = /* @__PURE__ */ new Set([
|
|
2140
2140
|
"attachmentEmbed",
|
|
2141
2141
|
"videoEmbed",
|
|
2142
2142
|
"audioEmbed",
|
|
2143
2143
|
"image"
|
|
2144
2144
|
]);
|
|
2145
|
-
function
|
|
2145
|
+
function ln(e) {
|
|
2146
2146
|
let t = 0;
|
|
2147
2147
|
return e.descendants((e) => {
|
|
2148
|
-
|
|
2148
|
+
cn.has(e.type.name) && (t += Number(e.attrs?.size) || 0);
|
|
2149
2149
|
}), t;
|
|
2150
2150
|
}
|
|
2151
|
-
function
|
|
2151
|
+
function un(e) {
|
|
2152
2152
|
if (!Number.isFinite(e) || e <= 0) return "0 B";
|
|
2153
2153
|
let t = [
|
|
2154
2154
|
"B",
|
|
@@ -2159,41 +2159,41 @@ function ln(e) {
|
|
|
2159
2159
|
], n = Math.min(t.length - 1, Math.floor(Math.log(e) / Math.log(1024))), r = e / 1024 ** n;
|
|
2160
2160
|
return `${n === 0 || r >= 100 ? `${Math.round(r)}` : `${Math.round(r * 10) / 10}`} ${t[n]}`;
|
|
2161
2161
|
}
|
|
2162
|
-
function
|
|
2162
|
+
function dn(e) {
|
|
2163
2163
|
return (e?.storage)?.qingwuUI?.limits;
|
|
2164
2164
|
}
|
|
2165
|
-
function
|
|
2165
|
+
function fn(e, t, n) {
|
|
2166
2166
|
let { maxAttachmentSize: r, maxTotalAttachmentSize: i } = n;
|
|
2167
|
-
if (r && t.size > r) return `单文件大小不能超过 ${
|
|
2167
|
+
if (r && t.size > r) return `单文件大小不能超过 ${un(r)}(当前 ${un(t.size)})`;
|
|
2168
2168
|
if (i) {
|
|
2169
|
-
let n =
|
|
2170
|
-
if (n > i) return `附件总大小不能超过 ${
|
|
2169
|
+
let n = ln(e) + t.size;
|
|
2170
|
+
if (n > i) return `附件总大小不能超过 ${un(i)}(当前合计 ${un(n)})`;
|
|
2171
2171
|
}
|
|
2172
2172
|
return null;
|
|
2173
2173
|
}
|
|
2174
2174
|
//#endregion
|
|
2175
2175
|
//#region src/editor/utils/delete-confirm.ts
|
|
2176
|
-
var
|
|
2177
|
-
function
|
|
2178
|
-
return
|
|
2176
|
+
var pn = !1, mn = null, hn = 5e3;
|
|
2177
|
+
function gn() {
|
|
2178
|
+
return pn;
|
|
2179
2179
|
}
|
|
2180
2180
|
function $(e) {
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
},
|
|
2181
|
+
pn = e, mn &&= (clearTimeout(mn), null), e && (mn = setTimeout(() => {
|
|
2182
|
+
pn = !1, mn = null;
|
|
2183
|
+
}, hn));
|
|
2184
2184
|
}
|
|
2185
|
-
var
|
|
2186
|
-
function
|
|
2187
|
-
|
|
2185
|
+
var _n = null;
|
|
2186
|
+
function vn(e) {
|
|
2187
|
+
_n = e;
|
|
2188
2188
|
}
|
|
2189
|
-
function
|
|
2190
|
-
return
|
|
2189
|
+
function yn() {
|
|
2190
|
+
return _n;
|
|
2191
2191
|
}
|
|
2192
2192
|
//#endregion
|
|
2193
2193
|
//#region src/editor/utils/delete-confirm-dialog.tsx
|
|
2194
|
-
var
|
|
2195
|
-
function
|
|
2196
|
-
let [s, c] = T(!1), l = w(!1), u =
|
|
2194
|
+
var bn = 300;
|
|
2195
|
+
function xn({ open: e, title: t, message: n, confirmText: r = "删除", cancelText: i = "取消", onConfirm: a, onCancel: o }) {
|
|
2196
|
+
let [s, c] = T(!1), l = w(!1), u = yn();
|
|
2197
2197
|
return x(() => {
|
|
2198
2198
|
if (!e) {
|
|
2199
2199
|
l.current = !1;
|
|
@@ -2263,7 +2263,7 @@ function bn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2263
2263
|
await a();
|
|
2264
2264
|
} finally {
|
|
2265
2265
|
let t = Date.now() - e;
|
|
2266
|
-
t <
|
|
2266
|
+
t < bn && await new Promise((e) => setTimeout(e, bn - t)), c(!1), o();
|
|
2267
2267
|
}
|
|
2268
2268
|
},
|
|
2269
2269
|
disabled: s,
|
|
@@ -2276,10 +2276,10 @@ function bn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2276
2276
|
}
|
|
2277
2277
|
//#endregion
|
|
2278
2278
|
//#region src/editor/extensions/image-view.tsx
|
|
2279
|
-
function
|
|
2279
|
+
function Sn(e) {
|
|
2280
2280
|
return /^(\.\.?\/|[a-zA-Z]:\\|file:\/\/)/.test(e) ? !0 : !(/^[a-z]+:\/\//i.test(e) || e.startsWith("/") || e.startsWith("data:") || e.startsWith("blob:"));
|
|
2281
2281
|
}
|
|
2282
|
-
function
|
|
2282
|
+
function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
2283
2283
|
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(() => {
|
|
2284
2284
|
o || (A.current = window.scrollY, a(!0));
|
|
2285
2285
|
}, [o]), I = b(() => {
|
|
@@ -2332,7 +2332,7 @@ function Sn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2332
2332
|
};
|
|
2333
2333
|
return document.addEventListener("fullscreenchange", e), () => document.removeEventListener("fullscreenchange", e);
|
|
2334
2334
|
}, []);
|
|
2335
|
-
let te = o ||
|
|
2335
|
+
let te = o || Sn(p);
|
|
2336
2336
|
return /* @__PURE__ */ O(F, {
|
|
2337
2337
|
as: "div",
|
|
2338
2338
|
className: "image-node-view group/img",
|
|
@@ -2345,7 +2345,7 @@ function Sn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2345
2345
|
type: "button",
|
|
2346
2346
|
className: "img-ctrl-btn img-ctrl-btn--del image-placeholder-del",
|
|
2347
2347
|
onClick: () => {
|
|
2348
|
-
|
|
2348
|
+
gn() || ($(!0), f(!0));
|
|
2349
2349
|
},
|
|
2350
2350
|
title: "删除",
|
|
2351
2351
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2377,7 +2377,7 @@ function Sn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2377
2377
|
}),
|
|
2378
2378
|
/* @__PURE__ */ D("span", {
|
|
2379
2379
|
className: "image-placeholder-text",
|
|
2380
|
-
children:
|
|
2380
|
+
children: Sn(p) ? "本地图片无法加载" : "图片加载失败"
|
|
2381
2381
|
}),
|
|
2382
2382
|
/* @__PURE__ */ D("span", {
|
|
2383
2383
|
className: "image-placeholder-path",
|
|
@@ -2458,7 +2458,7 @@ function Sn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2458
2458
|
type: "button",
|
|
2459
2459
|
className: "img-ctrl-btn img-ctrl-btn--del",
|
|
2460
2460
|
onClick: () => {
|
|
2461
|
-
|
|
2461
|
+
gn() || ($(!0), f(!0));
|
|
2462
2462
|
},
|
|
2463
2463
|
title: "删除",
|
|
2464
2464
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2545,7 +2545,7 @@ function Sn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2545
2545
|
}
|
|
2546
2546
|
})]
|
|
2547
2547
|
}),
|
|
2548
|
-
/* @__PURE__ */ D(
|
|
2548
|
+
/* @__PURE__ */ D(xn, {
|
|
2549
2549
|
open: d,
|
|
2550
2550
|
title: "确认删除图片",
|
|
2551
2551
|
message: te ? "该图片无法在当前环境加载,仅从编辑器中移除该图片节点,不影响存储文件。" : "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
@@ -2554,7 +2554,7 @@ function Sn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2554
2554
|
},
|
|
2555
2555
|
onConfirm: async () => {
|
|
2556
2556
|
if (!te) try {
|
|
2557
|
-
await
|
|
2557
|
+
await Wt(p);
|
|
2558
2558
|
} catch {}
|
|
2559
2559
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
2560
2560
|
}
|
|
@@ -2564,7 +2564,7 @@ function Sn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2564
2564
|
}
|
|
2565
2565
|
//#endregion
|
|
2566
2566
|
//#region src/editor/embeds/attachment-view.tsx
|
|
2567
|
-
var
|
|
2567
|
+
var wn = y(() => import("@file-viewer/react")), Tn = /* @__PURE__ */ new Set(), En = {
|
|
2568
2568
|
rendererMode: "replace",
|
|
2569
2569
|
autoRenderers: !0,
|
|
2570
2570
|
theme: "light",
|
|
@@ -2593,7 +2593,7 @@ var Cn = y(() => import("@file-viewer/react")), wn = /* @__PURE__ */ new Set(),
|
|
|
2593
2593
|
cache: !0,
|
|
2594
2594
|
workerTimeoutMs: 3e4
|
|
2595
2595
|
}
|
|
2596
|
-
},
|
|
2596
|
+
}, Dn = {
|
|
2597
2597
|
pdf: "pdf",
|
|
2598
2598
|
docx: "word",
|
|
2599
2599
|
docm: "word",
|
|
@@ -2648,7 +2648,7 @@ var Cn = y(() => import("@file-viewer/react")), wn = /* @__PURE__ */ new Set(),
|
|
|
2648
2648
|
xml: "text",
|
|
2649
2649
|
yml: "text",
|
|
2650
2650
|
yaml: "text"
|
|
2651
|
-
},
|
|
2651
|
+
}, On = {
|
|
2652
2652
|
pdf: () => import("@file-viewer/renderer-pdf").then((e) => e.pdfRenderer),
|
|
2653
2653
|
word: () => import("@file-viewer/renderer-word").then((e) => e.wordRenderer),
|
|
2654
2654
|
spreadsheet: () => import("@file-viewer/renderer-spreadsheet").then((e) => e.spreadsheetRenderer),
|
|
@@ -2656,10 +2656,10 @@ var Cn = y(() => import("@file-viewer/react")), wn = /* @__PURE__ */ new Set(),
|
|
|
2656
2656
|
archive: () => import("@file-viewer/renderer-archive").then((e) => e.archiveRenderer),
|
|
2657
2657
|
text: () => import("@file-viewer/renderer-text").then((e) => e.textRenderer)
|
|
2658
2658
|
};
|
|
2659
|
-
function
|
|
2659
|
+
function kn(e) {
|
|
2660
2660
|
return e ? e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1048576).toFixed(1)} MB` : "";
|
|
2661
2661
|
}
|
|
2662
|
-
function
|
|
2662
|
+
function An(e) {
|
|
2663
2663
|
let t = e.split(".").pop()?.toLowerCase() || "", n = {
|
|
2664
2664
|
pdf: {
|
|
2665
2665
|
label: "PDF",
|
|
@@ -2832,22 +2832,22 @@ function kn(e) {
|
|
|
2832
2832
|
]
|
|
2833
2833
|
});
|
|
2834
2834
|
}
|
|
2835
|
-
function
|
|
2835
|
+
function jn(e) {
|
|
2836
2836
|
return e.split(".").pop()?.toLowerCase() || "";
|
|
2837
2837
|
}
|
|
2838
|
-
function
|
|
2838
|
+
function Mn(e) {
|
|
2839
2839
|
let t = e.split(".").pop()?.toLowerCase() || "";
|
|
2840
2840
|
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);
|
|
2841
2841
|
}
|
|
2842
|
-
function
|
|
2842
|
+
function Nn(e) {
|
|
2843
2843
|
return !!e && !e.startsWith("file:");
|
|
2844
2844
|
}
|
|
2845
|
-
function
|
|
2845
|
+
function Pn(e) {
|
|
2846
2846
|
return btoa(encodeURIComponent(e)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
2847
2847
|
}
|
|
2848
|
-
async function
|
|
2848
|
+
async function Fn(e, t) {
|
|
2849
2849
|
try {
|
|
2850
|
-
let n =
|
|
2850
|
+
let n = Pn(e), r = await fetch(`/api/preview/${n}`, {
|
|
2851
2851
|
signal: t,
|
|
2852
2852
|
cache: "no-store"
|
|
2853
2853
|
});
|
|
@@ -2859,7 +2859,7 @@ async function Pn(e, t) {
|
|
|
2859
2859
|
return null;
|
|
2860
2860
|
}
|
|
2861
2861
|
}
|
|
2862
|
-
function
|
|
2862
|
+
function In(e, t, n) {
|
|
2863
2863
|
return new Promise((r, i) => {
|
|
2864
2864
|
let a = new XMLHttpRequest();
|
|
2865
2865
|
if (a.open("GET", e, !0), a.responseType = "arraybuffer", t) {
|
|
@@ -2897,20 +2897,20 @@ function Fn(e, t, n) {
|
|
|
2897
2897
|
a.send();
|
|
2898
2898
|
});
|
|
2899
2899
|
}
|
|
2900
|
-
function
|
|
2901
|
-
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() =>
|
|
2900
|
+
function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
2901
|
+
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() => Tn.has(s)), [u, d] = T(null), [p, m] = T(null), [h, g] = T(!1), [_, y] = T(null), [S, E] = T(!1), [k, A] = T(null), j = w(null), M = w(null), N = w(null), P = w(0), I = w(!1), L = w(null), ee = w(0), [te, ne] = T(!1), R = w(null), [re, ie] = T(0), [z, B] = T("none"), [V, H] = T(void 0), [ae, oe] = T(!1), U = e.attrs.src || "", W = e.attrs.name || U && U.split("/").pop()?.split("?")[0] || (U ? "attachment" : f("editor.attachment.lost")), G = e.attrs.size || 0, K = jn(W), q = !U;
|
|
2902
2902
|
x(() => {
|
|
2903
2903
|
if (!c) {
|
|
2904
2904
|
H(void 0), oe(!1);
|
|
2905
2905
|
return;
|
|
2906
2906
|
}
|
|
2907
|
-
let e =
|
|
2907
|
+
let e = Dn[K];
|
|
2908
2908
|
if (!e) {
|
|
2909
2909
|
H(void 0), oe(!1);
|
|
2910
2910
|
return;
|
|
2911
2911
|
}
|
|
2912
2912
|
let t = !0;
|
|
2913
|
-
return H(void 0), oe(!1),
|
|
2913
|
+
return H(void 0), oe(!1), On[e]().then((e) => {
|
|
2914
2914
|
t && H(e);
|
|
2915
2915
|
}).catch((n) => {
|
|
2916
2916
|
console.error(`[attachment] renderer "${e}" load failed:`, n), t && oe(!0);
|
|
@@ -2919,17 +2919,17 @@ function In({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2919
2919
|
};
|
|
2920
2920
|
}, [c, K]);
|
|
2921
2921
|
let se = C(() => ({
|
|
2922
|
-
...
|
|
2922
|
+
...En,
|
|
2923
2923
|
renderers: V ? [V] : [],
|
|
2924
2924
|
rendererMode: "replace"
|
|
2925
2925
|
}), [V]), ce = b((e) => {
|
|
2926
2926
|
l((t) => {
|
|
2927
2927
|
let n = typeof e == "function" ? e(t) : e;
|
|
2928
|
-
return U && (n ?
|
|
2928
|
+
return U && (n ? Tn.add(U) : Tn.delete(U)), n;
|
|
2929
2929
|
});
|
|
2930
2930
|
}, [U]);
|
|
2931
2931
|
x(() => {
|
|
2932
|
-
l(U ?
|
|
2932
|
+
l(U ? Tn.has(U) : !1);
|
|
2933
2933
|
}, [U]);
|
|
2934
2934
|
let le = b(() => {
|
|
2935
2935
|
I.current = !0, ce(!0), window.setTimeout(() => {
|
|
@@ -2954,7 +2954,7 @@ function In({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2954
2954
|
};
|
|
2955
2955
|
}, [z, le]), x(() => {
|
|
2956
2956
|
let e = (e) => {
|
|
2957
|
-
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && i && !
|
|
2957
|
+
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && i && !gn()) {
|
|
2958
2958
|
if (e.preventDefault(), e.stopPropagation(), a) {
|
|
2959
2959
|
let { from: e, to: t } = a.state.selection;
|
|
2960
2960
|
R.current = {
|
|
@@ -2971,7 +2971,7 @@ function In({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2971
2971
|
a,
|
|
2972
2972
|
o
|
|
2973
2973
|
]), x(() => {
|
|
2974
|
-
if (!c || !
|
|
2974
|
+
if (!c || !Nn(U)) {
|
|
2975
2975
|
d(null), y(null), N.current = null;
|
|
2976
2976
|
return;
|
|
2977
2977
|
}
|
|
@@ -2979,9 +2979,9 @@ function In({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2979
2979
|
let e = new AbortController(), r = !0;
|
|
2980
2980
|
return g(!0), y(null), (async () => {
|
|
2981
2981
|
let i = U.includes("?X-Amz-"), a = null, o = null;
|
|
2982
|
-
if (!a && !i && (a = await
|
|
2982
|
+
if (!a && !i && (a = await Fn(U, e.signal)), !a && !i) try {
|
|
2983
2983
|
let n = await t(U);
|
|
2984
|
-
n && (a = await
|
|
2984
|
+
n && (a = await Fn(n, e.signal) || await In(n, void 0, e.signal));
|
|
2985
2985
|
} catch (e) {
|
|
2986
2986
|
console.warn("[attachment] signPreviewUrl failed:", e);
|
|
2987
2987
|
}
|
|
@@ -2993,7 +2993,7 @@ function In({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2993
2993
|
n[t] = e;
|
|
2994
2994
|
});
|
|
2995
2995
|
try {
|
|
2996
|
-
a = await
|
|
2996
|
+
a = await In(U, n, e.signal);
|
|
2997
2997
|
} catch (e) {
|
|
2998
2998
|
console.warn("[attachment] signed headers XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
2999
2999
|
}
|
|
@@ -3002,7 +3002,7 @@ function In({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3002
3002
|
console.warn("[attachment] signPreviewUrlHeaders failed:", e);
|
|
3003
3003
|
}
|
|
3004
3004
|
if (!a) try {
|
|
3005
|
-
a = await
|
|
3005
|
+
a = await In(U, i ? void 0 : { "X-Requested-With": "XMLHttpRequest" }, e.signal);
|
|
3006
3006
|
} catch (e) {
|
|
3007
3007
|
console.warn("[attachment] plain XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
3008
3008
|
}
|
|
@@ -3097,7 +3097,7 @@ function In({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3097
3097
|
/* @__PURE__ */ D("path", { d: "M12 9v4" }),
|
|
3098
3098
|
/* @__PURE__ */ D("path", { d: "M12 17h.01" })
|
|
3099
3099
|
]
|
|
3100
|
-
}) :
|
|
3100
|
+
}) : An(W)
|
|
3101
3101
|
}), /* @__PURE__ */ O("div", {
|
|
3102
3102
|
className: "att-meta",
|
|
3103
3103
|
children: [/* @__PURE__ */ D("span", {
|
|
@@ -3105,7 +3105,7 @@ function In({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3105
3105
|
children: W
|
|
3106
3106
|
}), G > 0 && /* @__PURE__ */ D("span", {
|
|
3107
3107
|
className: "att-size",
|
|
3108
|
-
children:
|
|
3108
|
+
children: kn(G)
|
|
3109
3109
|
})]
|
|
3110
3110
|
})]
|
|
3111
3111
|
}), /* @__PURE__ */ O("div", {
|
|
@@ -3158,7 +3158,7 @@ function In({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3158
3158
|
}), /* @__PURE__ */ O("div", {
|
|
3159
3159
|
className: "att-actions",
|
|
3160
3160
|
children: [
|
|
3161
|
-
U &&
|
|
3161
|
+
U && Mn(W) && /* @__PURE__ */ D("button", {
|
|
3162
3162
|
type: "button",
|
|
3163
3163
|
className: "att-btn",
|
|
3164
3164
|
onMouseDown: (e) => {
|
|
@@ -3211,7 +3211,7 @@ function In({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3211
3211
|
type: "button",
|
|
3212
3212
|
className: "att-btn att-btn--del",
|
|
3213
3213
|
onClick: () => {
|
|
3214
|
-
!o ||
|
|
3214
|
+
!o || gn() || ($(!0), ne(!0));
|
|
3215
3215
|
},
|
|
3216
3216
|
title: f("editor.attachment.delete"),
|
|
3217
3217
|
"aria-label": f("editor.attachment.delete"),
|
|
@@ -3267,7 +3267,7 @@ function In({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3267
3267
|
style: { background: "#fff" },
|
|
3268
3268
|
children: f("editor.attachment.loadingPreview")
|
|
3269
3269
|
}),
|
|
3270
|
-
children: u || p || U ? V ? /* @__PURE__ */ D(
|
|
3270
|
+
children: u || p || U ? V ? /* @__PURE__ */ D(wn, {
|
|
3271
3271
|
buffer: u || void 0,
|
|
3272
3272
|
url: p || U,
|
|
3273
3273
|
name: W,
|
|
@@ -3379,7 +3379,7 @@ function In({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3379
3379
|
})]
|
|
3380
3380
|
})]
|
|
3381
3381
|
})]
|
|
3382
|
-
}), /* @__PURE__ */ D(
|
|
3382
|
+
}), /* @__PURE__ */ D(xn, {
|
|
3383
3383
|
open: te,
|
|
3384
3384
|
title: "确认删除附件",
|
|
3385
3385
|
message: q ? "此操作将删除该附件节点,不可撤销。" : `此操作将同时删除对象存储中的文件(${W}),不可撤销。`,
|
|
@@ -3391,12 +3391,12 @@ function In({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3391
3391
|
if (a) {
|
|
3392
3392
|
let e = R.current, t = e?.from ?? a.state.selection.from, n = e?.to ?? a.state.selection.to, r = [];
|
|
3393
3393
|
a.state.doc.nodesBetween(t, n, (e) => {
|
|
3394
|
-
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(
|
|
3394
|
+
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(Wt(e.attrs.src));
|
|
3395
3395
|
}), await Promise.all(r), $(!1), await new Promise((e) => setTimeout(e, 300)), a.chain().focus().setTextSelection({
|
|
3396
3396
|
from: t,
|
|
3397
3397
|
to: n
|
|
3398
3398
|
}).deleteSelection().run();
|
|
3399
|
-
} else await
|
|
3399
|
+
} else await Wt(U), $(!1), await new Promise((e) => setTimeout(e, 300)), r();
|
|
3400
3400
|
} catch {
|
|
3401
3401
|
$(!1);
|
|
3402
3402
|
}
|
|
@@ -3406,13 +3406,13 @@ function In({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3406
3406
|
}
|
|
3407
3407
|
//#endregion
|
|
3408
3408
|
//#region src/editor/embeds/attachment.ts
|
|
3409
|
-
var
|
|
3409
|
+
var Rn = re.create({
|
|
3410
3410
|
name: "attachmentEmbed",
|
|
3411
3411
|
group: "block",
|
|
3412
3412
|
atom: !0,
|
|
3413
3413
|
inline: !1,
|
|
3414
3414
|
addNodeView() {
|
|
3415
|
-
return I(
|
|
3415
|
+
return I(Ln);
|
|
3416
3416
|
},
|
|
3417
3417
|
addAttributes() {
|
|
3418
3418
|
return {
|
|
@@ -3461,7 +3461,7 @@ var Ln = re.create({
|
|
|
3461
3461
|
});
|
|
3462
3462
|
//#endregion
|
|
3463
3463
|
//#region src/editor/embeds/audio-view.tsx
|
|
3464
|
-
function
|
|
3464
|
+
function zn({ node: e, deleteNode: t, editor: r }) {
|
|
3465
3465
|
let i = e.attrs.src || "", a = e.attrs.name || i.split("/").pop()?.split("?")[0] || "audio", [o, s] = T(!1), c = r?.isEditable ?? !0;
|
|
3466
3466
|
x(() => () => {
|
|
3467
3467
|
i.startsWith("blob:") && URL.revokeObjectURL(i);
|
|
@@ -3527,7 +3527,7 @@ function Rn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3527
3527
|
type: "button",
|
|
3528
3528
|
className: "audio-embed-btn audio-embed-btn--del",
|
|
3529
3529
|
onClick: () => {
|
|
3530
|
-
|
|
3530
|
+
gn() || ($(!0), s(!0));
|
|
3531
3531
|
},
|
|
3532
3532
|
title: "删除",
|
|
3533
3533
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -3573,7 +3573,7 @@ function Rn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3573
3573
|
}), "音频文件缺失"]
|
|
3574
3574
|
})
|
|
3575
3575
|
})]
|
|
3576
|
-
}), /* @__PURE__ */ D(
|
|
3576
|
+
}), /* @__PURE__ */ D(xn, {
|
|
3577
3577
|
open: o,
|
|
3578
3578
|
title: "确认删除音频",
|
|
3579
3579
|
message: `此操作将同时删除对象存储中的文件(${a}),不可撤销。`,
|
|
@@ -3582,7 +3582,7 @@ function Rn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3582
3582
|
},
|
|
3583
3583
|
onConfirm: async () => {
|
|
3584
3584
|
try {
|
|
3585
|
-
await
|
|
3585
|
+
await Wt(i);
|
|
3586
3586
|
} catch {}
|
|
3587
3587
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3588
3588
|
}
|
|
@@ -3591,25 +3591,25 @@ function Rn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3591
3591
|
}
|
|
3592
3592
|
//#endregion
|
|
3593
3593
|
//#region src/editor/embeds/audio.ts
|
|
3594
|
-
function
|
|
3594
|
+
function Bn(e) {
|
|
3595
3595
|
return /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|$)/i.test(e) || /\/.*\.(mp3|wav|ogg|flac)/i.test(e);
|
|
3596
3596
|
}
|
|
3597
|
-
var
|
|
3597
|
+
var Vn = re.create({
|
|
3598
3598
|
name: "audioEmbed",
|
|
3599
3599
|
group: "block",
|
|
3600
3600
|
atom: !0,
|
|
3601
3601
|
inline: !1,
|
|
3602
3602
|
addNodeView() {
|
|
3603
|
-
return I(
|
|
3603
|
+
return I(zn);
|
|
3604
3604
|
},
|
|
3605
3605
|
addProseMirrorPlugins() {
|
|
3606
|
-
return [new
|
|
3606
|
+
return [new B({ props: { handlePaste(e, t) {
|
|
3607
3607
|
let n = t.clipboardData?.getData("text/plain");
|
|
3608
3608
|
if (!n) return !1;
|
|
3609
3609
|
let r = n.split(/\r?\n/);
|
|
3610
3610
|
for (let n of r) {
|
|
3611
3611
|
let r = n.trim();
|
|
3612
|
-
if (!r || r.includes(" ") || !
|
|
3612
|
+
if (!r || r.includes(" ") || !Bn(r)) continue;
|
|
3613
3613
|
t.preventDefault();
|
|
3614
3614
|
let i = e.state.schema.nodes.audioEmbed.create({ src: r });
|
|
3615
3615
|
return e.dispatch(e.state.tr.replaceSelectionWith(i)), !0;
|
|
@@ -3656,17 +3656,17 @@ var Bn = re.create({
|
|
|
3656
3656
|
});
|
|
3657
3657
|
//#endregion
|
|
3658
3658
|
//#region src/editor/embeds/video-view.tsx
|
|
3659
|
-
function
|
|
3659
|
+
function Hn(e) {
|
|
3660
3660
|
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";
|
|
3661
3661
|
}
|
|
3662
|
-
function
|
|
3662
|
+
function Un(e) {
|
|
3663
3663
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
3664
3664
|
if (t) return t[0];
|
|
3665
3665
|
let n = e.match(/av(\d+)/i);
|
|
3666
3666
|
return n ? n[0] : e;
|
|
3667
3667
|
}
|
|
3668
|
-
function
|
|
3669
|
-
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ?
|
|
3668
|
+
function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
3669
|
+
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ? Hn(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(xn, {
|
|
3670
3670
|
open: o,
|
|
3671
3671
|
title: "确认删除视频",
|
|
3672
3672
|
message: "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
@@ -3675,7 +3675,7 @@ function Un({ node: e, deleteNode: t, editor: n }) {
|
|
|
3675
3675
|
},
|
|
3676
3676
|
onConfirm: async () => {
|
|
3677
3677
|
try {
|
|
3678
|
-
await
|
|
3678
|
+
await Wt(r);
|
|
3679
3679
|
} catch {}
|
|
3680
3680
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3681
3681
|
}
|
|
@@ -3778,7 +3778,7 @@ function Un({ node: e, deleteNode: t, editor: n }) {
|
|
|
3778
3778
|
}, [a, h]), x(() => {
|
|
3779
3779
|
u && (_.current?.destroy(), _.current = null);
|
|
3780
3780
|
}, [u]), a === "bilibili") {
|
|
3781
|
-
let e =
|
|
3781
|
+
let e = Un(r);
|
|
3782
3782
|
return /* @__PURE__ */ O(F, {
|
|
3783
3783
|
as: "div",
|
|
3784
3784
|
className: "video-embed video-embed--bilibili group/video",
|
|
@@ -3855,7 +3855,7 @@ function Un({ node: e, deleteNode: t, editor: n }) {
|
|
|
3855
3855
|
className: "video-fs-btn video-fs-btn--del",
|
|
3856
3856
|
title: "删除",
|
|
3857
3857
|
onClick: () => {
|
|
3858
|
-
|
|
3858
|
+
gn() || ($(!0), s(!0));
|
|
3859
3859
|
},
|
|
3860
3860
|
children: /* @__PURE__ */ D("svg", {
|
|
3861
3861
|
width: "12",
|
|
@@ -3962,7 +3962,7 @@ function Un({ node: e, deleteNode: t, editor: n }) {
|
|
|
3962
3962
|
className: "video-fs-btn video-fs-btn--del",
|
|
3963
3963
|
title: "删除",
|
|
3964
3964
|
onClick: () => {
|
|
3965
|
-
|
|
3965
|
+
gn() || ($(!0), s(!0));
|
|
3966
3966
|
},
|
|
3967
3967
|
children: /* @__PURE__ */ D("svg", {
|
|
3968
3968
|
width: "12",
|
|
@@ -4119,33 +4119,33 @@ function Un({ node: e, deleteNode: t, editor: n }) {
|
|
|
4119
4119
|
}
|
|
4120
4120
|
//#endregion
|
|
4121
4121
|
//#region src/editor/embeds/video.ts
|
|
4122
|
-
function
|
|
4122
|
+
function Gn(e) {
|
|
4123
4123
|
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";
|
|
4124
4124
|
}
|
|
4125
|
-
function
|
|
4125
|
+
function Kn(e) {
|
|
4126
4126
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
4127
4127
|
if (t) return t[0];
|
|
4128
4128
|
let n = e.match(/av(\d+)/i);
|
|
4129
4129
|
return n ? n[0] : e;
|
|
4130
4130
|
}
|
|
4131
|
-
function
|
|
4131
|
+
function qn(e) {
|
|
4132
4132
|
let t = e.match(/explore\/([a-zA-Z0-9]+)/);
|
|
4133
4133
|
return t ? t[1] : e;
|
|
4134
4134
|
}
|
|
4135
|
-
var
|
|
4135
|
+
var Jn = re.create({
|
|
4136
4136
|
name: "videoEmbed",
|
|
4137
4137
|
group: "block",
|
|
4138
4138
|
atom: !0,
|
|
4139
4139
|
inline: !1,
|
|
4140
4140
|
addNodeView() {
|
|
4141
|
-
return I(
|
|
4141
|
+
return I(Wn);
|
|
4142
4142
|
},
|
|
4143
4143
|
addProseMirrorPlugins() {
|
|
4144
|
-
return [new
|
|
4144
|
+
return [new B({ props: {
|
|
4145
4145
|
handleKeyDown(e, t) {
|
|
4146
4146
|
if (t.key !== " ") return !1;
|
|
4147
4147
|
let n = e.state.selection;
|
|
4148
|
-
if (n instanceof
|
|
4148
|
+
if (n instanceof z && n.node.type.name === "videoEmbed") {
|
|
4149
4149
|
t.preventDefault();
|
|
4150
4150
|
let r = e.nodeDOM(n.from);
|
|
4151
4151
|
if (r) {
|
|
@@ -4163,7 +4163,7 @@ var qn = re.create({
|
|
|
4163
4163
|
for (let n of r) {
|
|
4164
4164
|
let r = n.trim();
|
|
4165
4165
|
if (!r || r.includes(" ")) continue;
|
|
4166
|
-
let i =
|
|
4166
|
+
let i = Gn(r);
|
|
4167
4167
|
if (i === "unknown") continue;
|
|
4168
4168
|
t.preventDefault();
|
|
4169
4169
|
let a = e.state.schema.nodes.videoEmbed.create({
|
|
@@ -4195,7 +4195,7 @@ var qn = re.create({
|
|
|
4195
4195
|
let t = e, n = t.getAttribute("src") || t.getAttribute("data-src") || "";
|
|
4196
4196
|
return {
|
|
4197
4197
|
src: n,
|
|
4198
|
-
source:
|
|
4198
|
+
source: Gn(n)
|
|
4199
4199
|
};
|
|
4200
4200
|
}
|
|
4201
4201
|
},
|
|
@@ -4204,9 +4204,9 @@ var qn = re.create({
|
|
|
4204
4204
|
];
|
|
4205
4205
|
},
|
|
4206
4206
|
renderHTML({ HTMLAttributes: e }) {
|
|
4207
|
-
let t = e.src || "", n =
|
|
4207
|
+
let t = e.src || "", n = Gn(t);
|
|
4208
4208
|
if (n === "bilibili") {
|
|
4209
|
-
let e =
|
|
4209
|
+
let e = Kn(t);
|
|
4210
4210
|
return [
|
|
4211
4211
|
"div",
|
|
4212
4212
|
{
|
|
@@ -4227,7 +4227,7 @@ var qn = re.create({
|
|
|
4227
4227
|
}]
|
|
4228
4228
|
];
|
|
4229
4229
|
}
|
|
4230
|
-
if (n === "xiaohongshu") return
|
|
4230
|
+
if (n === "xiaohongshu") return qn(t), [
|
|
4231
4231
|
"div",
|
|
4232
4232
|
{
|
|
4233
4233
|
"data-video-embed": "xiaohongshu",
|
|
@@ -4279,7 +4279,7 @@ var qn = re.create({
|
|
|
4279
4279
|
},
|
|
4280
4280
|
addCommands() {
|
|
4281
4281
|
return { insertVideo: (e) => ({ chain: t }) => {
|
|
4282
|
-
let n =
|
|
4282
|
+
let n = Gn(e.src);
|
|
4283
4283
|
return t().insertContent({
|
|
4284
4284
|
type: this.name,
|
|
4285
4285
|
attrs: {
|
|
@@ -4289,13 +4289,13 @@ var qn = re.create({
|
|
|
4289
4289
|
}).focus().run();
|
|
4290
4290
|
} };
|
|
4291
4291
|
}
|
|
4292
|
-
}),
|
|
4293
|
-
async function
|
|
4294
|
-
|
|
4295
|
-
let t =
|
|
4292
|
+
}), Yn = null;
|
|
4293
|
+
async function Xn(e) {
|
|
4294
|
+
Yn ||= await import("beautiful-mermaid");
|
|
4295
|
+
let t = Yn.renderMermaidSVG;
|
|
4296
4296
|
return t(e);
|
|
4297
4297
|
}
|
|
4298
|
-
var
|
|
4298
|
+
var Zn = [
|
|
4299
4299
|
{
|
|
4300
4300
|
value: "javascript",
|
|
4301
4301
|
label: "JavaScript",
|
|
@@ -4456,7 +4456,7 @@ var Xn = [
|
|
|
4456
4456
|
label: "Plain Text",
|
|
4457
4457
|
color: "#6b7280"
|
|
4458
4458
|
}
|
|
4459
|
-
],
|
|
4459
|
+
], Qn = {
|
|
4460
4460
|
javascript: "js",
|
|
4461
4461
|
typescript: "ts",
|
|
4462
4462
|
python: "py",
|
|
@@ -4482,7 +4482,7 @@ var Xn = [
|
|
|
4482
4482
|
txt: "txt",
|
|
4483
4483
|
vue: "vue",
|
|
4484
4484
|
react: "jsx"
|
|
4485
|
-
},
|
|
4485
|
+
}, $n = {
|
|
4486
4486
|
js: "javascript",
|
|
4487
4487
|
ts: "typescript",
|
|
4488
4488
|
py: "python",
|
|
@@ -4498,12 +4498,12 @@ var Xn = [
|
|
|
4498
4498
|
jsx: "javascript",
|
|
4499
4499
|
tsx: "typescript"
|
|
4500
4500
|
};
|
|
4501
|
-
function
|
|
4501
|
+
function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i, selected: a }) {
|
|
4502
4502
|
let o = n?.isEditable ?? !0, s = !o, [c, l] = T(!1), [u, d] = T(!1), [f, m] = T(!1), [h, g] = T(!1), [_, v] = T(220), [y, S] = T({
|
|
4503
4503
|
top: 0,
|
|
4504
4504
|
left: 0,
|
|
4505
4505
|
width: 210
|
|
4506
|
-
}), [k, A] = T(""), [j, M] = T(!1), [N, P] = T(null), [F, I] = T(null), [L, ee] = T(!1), te = w(null), R = w(null), re = w(null), ie = w(null), z = w(null), B = w(null), V = e.attrs.language || "", H =
|
|
4506
|
+
}), [k, A] = T(""), [j, M] = T(!1), [N, P] = T(null), [F, I] = T(null), [L, ee] = T(!1), te = w(null), R = w(null), re = w(null), ie = w(null), z = w(null), B = w(null), V = e.attrs.language || "", H = Zn.find((e) => e.value === ($n[V] ?? V)), ae = V === "mermaid", oe = b(() => {
|
|
4507
4507
|
if (!n || typeof r != "function") return null;
|
|
4508
4508
|
let t = r();
|
|
4509
4509
|
return typeof t == "number" ? {
|
|
@@ -4515,10 +4515,10 @@ function $n({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4515
4515
|
r,
|
|
4516
4516
|
e.nodeSize
|
|
4517
4517
|
]), U = b(() => {
|
|
4518
|
-
o && (
|
|
4518
|
+
o && (gn() || (B.current = oe(), window.getSelection()?.removeAllRanges(), $(!0), M(!0)));
|
|
4519
4519
|
}, [oe, o]), W = C(() => {
|
|
4520
4520
|
let e = k.trim().toLowerCase();
|
|
4521
|
-
return e ?
|
|
4521
|
+
return e ? Zn.filter((t) => t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e)) : Zn;
|
|
4522
4522
|
}, [k]);
|
|
4523
4523
|
x(() => {
|
|
4524
4524
|
(z.current?.parentElement?.querySelector(".cb-code-area"))?.classList.toggle("cb-code-area--collapsed", u);
|
|
@@ -4526,7 +4526,7 @@ function $n({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4526
4526
|
let G = b(() => {
|
|
4527
4527
|
let e = re.current;
|
|
4528
4528
|
if (!e) return;
|
|
4529
|
-
let t = e.getBoundingClientRect(), n = Math.min(t.left, window.innerWidth - 210 - 8), r = window.innerHeight - t.bottom - 12, i = t.top - 12, a =
|
|
4529
|
+
let t = e.getBoundingClientRect(), n = Math.min(t.left, window.innerWidth - 210 - 8), r = window.innerHeight - t.bottom - 12, i = t.top - 12, a = Zn.length * 31 + 8, o = r - 52, s = i - 52;
|
|
4530
4530
|
o < 220 && s > o ? (g(!0), v(Math.max(120, Math.min(a, s))), S({
|
|
4531
4531
|
top: t.top,
|
|
4532
4532
|
left: n,
|
|
@@ -4559,7 +4559,7 @@ function $n({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4559
4559
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
4560
4560
|
}, [f]), x(() => {
|
|
4561
4561
|
let e = (e) => {
|
|
4562
|
-
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && a && !
|
|
4562
|
+
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && a && !gn()) {
|
|
4563
4563
|
if (e.preventDefault(), e.stopPropagation(), n) {
|
|
4564
4564
|
let { from: e, to: t } = n.state.selection;
|
|
4565
4565
|
B.current = {
|
|
@@ -4601,7 +4601,7 @@ function $n({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4601
4601
|
};
|
|
4602
4602
|
navigator.clipboard?.writeText ? navigator.clipboard.writeText(t).catch(() => n(t)) : n(t), l(!0), setTimeout(() => l(!1), 1500);
|
|
4603
4603
|
}, [e.textContent]), ce = b(() => {
|
|
4604
|
-
let t =
|
|
4604
|
+
let t = Qn[V] || "txt", n = t ? `code.${t}` : "code.txt", r = new Blob([e.textContent], { type: "text/plain;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
4605
4605
|
a.href = i, a.download = n, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
4606
4606
|
}, [e.textContent, V]), le = b(async () => {
|
|
4607
4607
|
if (N || L) {
|
|
@@ -4615,7 +4615,7 @@ function $n({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4615
4615
|
I("代码块内容为空");
|
|
4616
4616
|
return;
|
|
4617
4617
|
}
|
|
4618
|
-
let n = p(await
|
|
4618
|
+
let n = p(await Xn(t));
|
|
4619
4619
|
P(n);
|
|
4620
4620
|
} catch (e) {
|
|
4621
4621
|
I(e instanceof Error ? e.message : "Mermaid 渲染失败");
|
|
@@ -4900,7 +4900,7 @@ function $n({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4900
4900
|
})
|
|
4901
4901
|
]
|
|
4902
4902
|
}),
|
|
4903
|
-
/* @__PURE__ */ D(
|
|
4903
|
+
/* @__PURE__ */ D(xn, {
|
|
4904
4904
|
open: j,
|
|
4905
4905
|
title: "确认删除代码块",
|
|
4906
4906
|
message: "此操作不可撤销。",
|
|
@@ -4916,7 +4916,7 @@ function $n({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4916
4916
|
}
|
|
4917
4917
|
//#endregion
|
|
4918
4918
|
//#region src/editor/extensions/code-block.ts
|
|
4919
|
-
var
|
|
4919
|
+
var tr = [
|
|
4920
4920
|
{
|
|
4921
4921
|
value: "javascript",
|
|
4922
4922
|
label: "JavaScript"
|
|
@@ -5017,12 +5017,12 @@ var er = [
|
|
|
5017
5017
|
value: "mermaid",
|
|
5018
5018
|
label: "Mermaid"
|
|
5019
5019
|
}
|
|
5020
|
-
],
|
|
5021
|
-
|
|
5022
|
-
function
|
|
5020
|
+
], nr = Se(xe);
|
|
5021
|
+
nr.register({ dockerfile: be }), nr.registerAlias("xml", ["vue", "html"]), nr.registerAlias("javascript", ["react", "jsx"]), nr.registerAlias("typescript", ["tsx"]);
|
|
5022
|
+
function rr(e) {
|
|
5023
5023
|
return e ? e.split("\n") : [""];
|
|
5024
5024
|
}
|
|
5025
|
-
function
|
|
5025
|
+
function ir(e, t) {
|
|
5026
5026
|
if (e.childElementCount !== t) {
|
|
5027
5027
|
e.replaceChildren();
|
|
5028
5028
|
for (let n = 1; n <= t; n++) {
|
|
@@ -5031,14 +5031,14 @@ function rr(e, t) {
|
|
|
5031
5031
|
}
|
|
5032
5032
|
}
|
|
5033
5033
|
}
|
|
5034
|
-
function
|
|
5034
|
+
function ar(e, t) {
|
|
5035
5035
|
e.replaceChildren();
|
|
5036
5036
|
for (let n of t) {
|
|
5037
5037
|
let t = document.createElement("span");
|
|
5038
5038
|
t.className = "cb-mirror-line", t.textContent = n.length ? n : "\xA0", e.appendChild(t);
|
|
5039
5039
|
}
|
|
5040
5040
|
}
|
|
5041
|
-
function
|
|
5041
|
+
function or(e, t, n) {
|
|
5042
5042
|
let r = getComputedStyle(e), i = parseFloat(r.paddingLeft), a = parseFloat(r.paddingRight);
|
|
5043
5043
|
t.style.boxSizing = "content-box", t.style.width = `${Math.max(0, e.clientWidth - i - a)}px`, t.style.padding = r.padding;
|
|
5044
5044
|
let o = getComputedStyle(n);
|
|
@@ -5085,7 +5085,7 @@ function ar(e, t, n) {
|
|
|
5085
5085
|
r = e + 1 < C.length ? C[e + 1] - C[e] : w - T, (!Number.isFinite(r) || r < 1) && (r = c), t.style.height = `${r}px`, T += r;
|
|
5086
5086
|
}
|
|
5087
5087
|
}
|
|
5088
|
-
var
|
|
5088
|
+
var sr = ye.extend({
|
|
5089
5089
|
addNodeView() {
|
|
5090
5090
|
return (e) => {
|
|
5091
5091
|
let { node: t, editor: n, getPos: r } = e, i = t, a = (e) => {
|
|
@@ -5111,9 +5111,9 @@ var or = ve.extend({
|
|
|
5111
5111
|
d.appendChild(f);
|
|
5112
5112
|
let p = document.createElement("div");
|
|
5113
5113
|
p.className = "cb-code-mirror", p.contentEditable = "false", p.setAttribute("aria-hidden", "true"), l.appendChild(u), l.appendChild(d), l.appendChild(p), s.appendChild(l);
|
|
5114
|
-
let m =
|
|
5115
|
-
|
|
5116
|
-
let h = new L(
|
|
5114
|
+
let m = rr(t.textContent);
|
|
5115
|
+
ir(u, m.length), ar(p, m);
|
|
5116
|
+
let h = new L(er, {
|
|
5117
5117
|
editor: n,
|
|
5118
5118
|
props: {
|
|
5119
5119
|
node: t,
|
|
@@ -5126,12 +5126,12 @@ var or = ve.extend({
|
|
|
5126
5126
|
});
|
|
5127
5127
|
c.appendChild(h.element);
|
|
5128
5128
|
let g = (e) => {
|
|
5129
|
-
let t =
|
|
5130
|
-
|
|
5129
|
+
let t = rr(e.textContent);
|
|
5130
|
+
ir(u, t.length), ar(p, t), requestAnimationFrame(() => or(d, p, u));
|
|
5131
5131
|
};
|
|
5132
|
-
requestAnimationFrame(() =>
|
|
5133
|
-
let _ = new ResizeObserver(() =>
|
|
5134
|
-
return _.observe(d), document.fonts?.ready?.then(() =>
|
|
5132
|
+
requestAnimationFrame(() => or(d, p, u));
|
|
5133
|
+
let _ = new ResizeObserver(() => or(d, p, u));
|
|
5134
|
+
return _.observe(d), document.fonts?.ready?.then(() => or(d, p, u)), {
|
|
5135
5135
|
dom: s,
|
|
5136
5136
|
contentDOM: f,
|
|
5137
5137
|
update(e) {
|
|
@@ -5191,10 +5191,10 @@ var or = ve.extend({
|
|
|
5191
5191
|
}
|
|
5192
5192
|
}));
|
|
5193
5193
|
}
|
|
5194
|
-
}).configure({ lowlight:
|
|
5194
|
+
}).configure({ lowlight: nr });
|
|
5195
5195
|
//#endregion
|
|
5196
5196
|
//#region src/editor/utils/import-choice-dialog.ts
|
|
5197
|
-
function
|
|
5197
|
+
function cr(e) {
|
|
5198
5198
|
return new Promise((t) => {
|
|
5199
5199
|
let n = document.createElement("div");
|
|
5200
5200
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5224,16 +5224,16 @@ function sr(e) {
|
|
|
5224
5224
|
}
|
|
5225
5225
|
//#endregion
|
|
5226
5226
|
//#region src/editor/utils/local-media.ts
|
|
5227
|
-
var
|
|
5228
|
-
function
|
|
5227
|
+
var lr = /\.(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, ur = /^(?:mailto:|tel:|javascript:|about:|data:|blob:)/i;
|
|
5228
|
+
function dr(e) {
|
|
5229
5229
|
if (!e) return !1;
|
|
5230
5230
|
let t = e.trim();
|
|
5231
|
-
return !(!t || /^(?:https?:)?\/\//i.test(t) ||
|
|
5232
|
-
}
|
|
5233
|
-
function dr(e) {
|
|
5234
|
-
return cr.test(e);
|
|
5231
|
+
return !(!t || /^(?:https?:)?\/\//i.test(t) || ur.test(t) || t.startsWith("#"));
|
|
5235
5232
|
}
|
|
5236
5233
|
function fr(e) {
|
|
5234
|
+
return lr.test(e);
|
|
5235
|
+
}
|
|
5236
|
+
function pr(e) {
|
|
5237
5237
|
let t = e.trim();
|
|
5238
5238
|
t = t.replace(/^(?:file|app):\/\/(?:localhost)?/i, "");
|
|
5239
5239
|
try {
|
|
@@ -5241,26 +5241,26 @@ function fr(e) {
|
|
|
5241
5241
|
} catch {}
|
|
5242
5242
|
return t = t.replace(/\\/g, "/"), t = t.replace(/^\.\//, ""), t = t.replace(/^\/+/, ""), t = t.replace(/^[a-zA-Z]:\//, ""), t;
|
|
5243
5243
|
}
|
|
5244
|
-
function
|
|
5245
|
-
let t =
|
|
5244
|
+
function mr(e) {
|
|
5245
|
+
let t = pr(e), n = t.split("/").filter(Boolean);
|
|
5246
5246
|
return (n[n.length - 1] || t).toLowerCase();
|
|
5247
5247
|
}
|
|
5248
|
-
function
|
|
5248
|
+
function hr() {
|
|
5249
5249
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showDirectoryPicker == "function";
|
|
5250
5250
|
}
|
|
5251
|
-
async function
|
|
5252
|
-
if (!
|
|
5251
|
+
async function gr() {
|
|
5252
|
+
if (!hr()) return null;
|
|
5253
5253
|
try {
|
|
5254
5254
|
return await window.showDirectoryPicker.call(window, { mode: "read" }) ?? null;
|
|
5255
5255
|
} catch {
|
|
5256
5256
|
return null;
|
|
5257
5257
|
}
|
|
5258
5258
|
}
|
|
5259
|
-
function
|
|
5259
|
+
function _r() {
|
|
5260
5260
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showOpenFilePicker == "function";
|
|
5261
5261
|
}
|
|
5262
|
-
async function
|
|
5263
|
-
if (!
|
|
5262
|
+
async function vr() {
|
|
5263
|
+
if (!_r()) return null;
|
|
5264
5264
|
try {
|
|
5265
5265
|
let e = await window.showOpenFilePicker.call(window, { multiple: !0 });
|
|
5266
5266
|
return await Promise.all(e.map((e) => e.getFile()));
|
|
@@ -5268,7 +5268,7 @@ async function _r() {
|
|
|
5268
5268
|
return null;
|
|
5269
5269
|
}
|
|
5270
5270
|
}
|
|
5271
|
-
async function
|
|
5271
|
+
async function yr(e, t) {
|
|
5272
5272
|
if (t.length === 0) return { file: null };
|
|
5273
5273
|
let n = e;
|
|
5274
5274
|
for (let e = 0; e < t.length - 1; e++) try {
|
|
@@ -5290,7 +5290,7 @@ async function vr(e, t) {
|
|
|
5290
5290
|
return { file: null };
|
|
5291
5291
|
}
|
|
5292
5292
|
}
|
|
5293
|
-
async function
|
|
5293
|
+
async function br(e, t, n = 5e3) {
|
|
5294
5294
|
let r = t.toLowerCase(), i = [e], a = 0, o;
|
|
5295
5295
|
for (; i.length > 0 && a < n;) {
|
|
5296
5296
|
let e = i.pop();
|
|
@@ -5312,37 +5312,37 @@ async function yr(e, t, n = 5e3) {
|
|
|
5312
5312
|
readError: o
|
|
5313
5313
|
};
|
|
5314
5314
|
}
|
|
5315
|
-
async function
|
|
5316
|
-
let n =
|
|
5315
|
+
async function xr(e, t) {
|
|
5316
|
+
let n = pr(t).split("/").filter(Boolean);
|
|
5317
5317
|
if (n.length === 0) return { file: null };
|
|
5318
5318
|
let r;
|
|
5319
5319
|
for (let t = 0; t < n.length; t++) {
|
|
5320
|
-
let i = await
|
|
5320
|
+
let i = await yr(e, n.slice(t));
|
|
5321
5321
|
if (i.file) return i;
|
|
5322
5322
|
i.readError && (r = i.readError);
|
|
5323
5323
|
}
|
|
5324
|
-
let i = await
|
|
5324
|
+
let i = await br(e, n[n.length - 1]);
|
|
5325
5325
|
return i.file || i.readError ? i : {
|
|
5326
5326
|
file: null,
|
|
5327
5327
|
readError: r
|
|
5328
5328
|
};
|
|
5329
5329
|
}
|
|
5330
|
-
var
|
|
5330
|
+
var Sr = {
|
|
5331
5331
|
image: "image",
|
|
5332
5332
|
videoEmbed: "video",
|
|
5333
5333
|
audioEmbed: "audio",
|
|
5334
5334
|
attachmentEmbed: "attachment"
|
|
5335
5335
|
};
|
|
5336
|
-
function
|
|
5336
|
+
function Cr(e, t) {
|
|
5337
5337
|
let n = /* @__PURE__ */ new Set(), r = [];
|
|
5338
5338
|
return e.descendants((e) => {
|
|
5339
|
-
let i =
|
|
5339
|
+
let i = Sr[e.type?.name];
|
|
5340
5340
|
if (i) {
|
|
5341
5341
|
let a = e.attrs?.src, o = `node:${a}`;
|
|
5342
|
-
typeof a == "string" &&
|
|
5342
|
+
typeof a == "string" && dr(a) && !n.has(o) && !t?.(a) && (n.add(o), r.push({
|
|
5343
5343
|
src: a,
|
|
5344
|
-
normalized:
|
|
5345
|
-
basename:
|
|
5344
|
+
normalized: pr(a),
|
|
5345
|
+
basename: mr(a),
|
|
5346
5346
|
kind: i,
|
|
5347
5347
|
isLink: !1
|
|
5348
5348
|
}));
|
|
@@ -5351,17 +5351,17 @@ function Sr(e, t) {
|
|
|
5351
5351
|
if (e.isText && e.marks) for (let i of e.marks) {
|
|
5352
5352
|
if (i.type.name !== "link") continue;
|
|
5353
5353
|
let e = i.attrs?.href, a = `link:${e}`;
|
|
5354
|
-
typeof e == "string" &&
|
|
5354
|
+
typeof e == "string" && dr(e) && fr(e) && !n.has(a) && !t?.(e) && (n.add(a), r.push({
|
|
5355
5355
|
src: e,
|
|
5356
|
-
normalized:
|
|
5357
|
-
basename:
|
|
5356
|
+
normalized: pr(e),
|
|
5357
|
+
basename: mr(e),
|
|
5358
5358
|
kind: "attachment",
|
|
5359
5359
|
isLink: !0
|
|
5360
5360
|
}));
|
|
5361
5361
|
}
|
|
5362
5362
|
}), r;
|
|
5363
5363
|
}
|
|
5364
|
-
function
|
|
5364
|
+
function wr(e, t, n) {
|
|
5365
5365
|
let r = t ? `${e}\n${t}` : e;
|
|
5366
5366
|
if (!r) return !1;
|
|
5367
5367
|
let i = [];
|
|
@@ -5369,28 +5369,28 @@ function Cr(e, t, n) {
|
|
|
5369
5369
|
for (let e of r.matchAll(/!?\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g)) i.push(e[1]);
|
|
5370
5370
|
for (let e of r.matchAll(/<(?:img|video|audio|source)[^>]*\bsrc=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5371
5371
|
for (let e of r.matchAll(/<a[^>]*\bhref=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5372
|
-
return i.some((e) =>
|
|
5372
|
+
return i.some((e) => fr(e) && dr(e) && !n?.(e));
|
|
5373
5373
|
}
|
|
5374
5374
|
//#endregion
|
|
5375
5375
|
//#region src/editor/extensions/image-upload.ts
|
|
5376
|
-
function
|
|
5376
|
+
function Tr(e) {
|
|
5377
5377
|
if (e.type.startsWith("image/")) return "image";
|
|
5378
5378
|
if (e.type.startsWith("video/")) return "video";
|
|
5379
5379
|
if (e.type.startsWith("audio/")) return "audio";
|
|
5380
5380
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5381
5381
|
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";
|
|
5382
5382
|
}
|
|
5383
|
-
function
|
|
5383
|
+
function Er(e) {
|
|
5384
5384
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5385
5385
|
return t === "md" || t === "markdown";
|
|
5386
5386
|
}
|
|
5387
|
-
async function
|
|
5388
|
-
let i = n ?? e.state.selection.from, a = r ?
|
|
5389
|
-
o?.chooseMd ? o.chooseMd(t.name, e) :
|
|
5387
|
+
async function Dr(e, t, n, r) {
|
|
5388
|
+
let i = n ?? e.state.selection.from, a = r ? dn(r) : void 0, o = r?.storage?.qingwuUI, s = await new Promise((e) => {
|
|
5389
|
+
o?.chooseMd ? o.chooseMd(t.name, e) : cr(t.name).then(e);
|
|
5390
5390
|
});
|
|
5391
5391
|
if (s === null) return;
|
|
5392
5392
|
if (s === "attach") {
|
|
5393
|
-
let n = a ?
|
|
5393
|
+
let n = a ? fn(e.state.doc, t, a) : null;
|
|
5394
5394
|
if (n) {
|
|
5395
5395
|
Z(n);
|
|
5396
5396
|
return;
|
|
@@ -5421,8 +5421,8 @@ async function Er(e, t, n, r) {
|
|
|
5421
5421
|
e.dispatch(e.state.tr.insert(i, t.from(u)));
|
|
5422
5422
|
}
|
|
5423
5423
|
}
|
|
5424
|
-
function
|
|
5425
|
-
switch (
|
|
5424
|
+
function Or(e, t, n) {
|
|
5425
|
+
switch (Tr(t)) {
|
|
5426
5426
|
case "image": return e.nodes.image?.create({
|
|
5427
5427
|
src: n,
|
|
5428
5428
|
alt: t.name
|
|
@@ -5448,7 +5448,7 @@ function Dr(e, t, n) {
|
|
|
5448
5448
|
}
|
|
5449
5449
|
}
|
|
5450
5450
|
}
|
|
5451
|
-
async function
|
|
5451
|
+
async function kr(e, t, n) {
|
|
5452
5452
|
let r;
|
|
5453
5453
|
try {
|
|
5454
5454
|
r = o();
|
|
@@ -5467,13 +5467,13 @@ async function Or(e, t, n) {
|
|
|
5467
5467
|
return console.error(`${t.type} upload failed:`, e), URL.revokeObjectURL(n), null;
|
|
5468
5468
|
}
|
|
5469
5469
|
}
|
|
5470
|
-
async function
|
|
5471
|
-
let i = r ?
|
|
5470
|
+
async function Ar(e, t, n, r) {
|
|
5471
|
+
let i = r ? dn(r) : void 0, a = i ? fn(e.state.doc, t, i) : null;
|
|
5472
5472
|
if (a) {
|
|
5473
5473
|
Z(a);
|
|
5474
5474
|
return;
|
|
5475
5475
|
}
|
|
5476
|
-
let o = URL.createObjectURL(t), s =
|
|
5476
|
+
let o = URL.createObjectURL(t), s = Or(e.state.schema, t, o);
|
|
5477
5477
|
if (!s) return;
|
|
5478
5478
|
let c = n ?? e.state.selection.from;
|
|
5479
5479
|
try {
|
|
@@ -5481,9 +5481,9 @@ async function kr(e, t, n, r) {
|
|
|
5481
5481
|
} catch {
|
|
5482
5482
|
return;
|
|
5483
5483
|
}
|
|
5484
|
-
await
|
|
5484
|
+
await kr(e, t, o);
|
|
5485
5485
|
}
|
|
5486
|
-
var
|
|
5486
|
+
var jr = R.create({
|
|
5487
5487
|
name: "imageUpload",
|
|
5488
5488
|
addOptions() {
|
|
5489
5489
|
return {
|
|
@@ -5493,8 +5493,8 @@ var Ar = R.create({
|
|
|
5493
5493
|
},
|
|
5494
5494
|
addProseMirrorPlugins() {
|
|
5495
5495
|
let e = this.editor;
|
|
5496
|
-
return [new
|
|
5497
|
-
key: new
|
|
5496
|
+
return [new B({
|
|
5497
|
+
key: new V("imageUpload"),
|
|
5498
5498
|
props: {
|
|
5499
5499
|
handleDrop(t, n) {
|
|
5500
5500
|
let r = n.dataTransfer?.files;
|
|
@@ -5504,23 +5504,23 @@ var Ar = R.create({
|
|
|
5504
5504
|
left: n.clientX,
|
|
5505
5505
|
top: n.clientY
|
|
5506
5506
|
});
|
|
5507
|
-
for (let n of Array.from(r))
|
|
5507
|
+
for (let n of Array.from(r)) Er(n) ? Dr(t, n, i?.pos, e) : Ar(t, n, i?.pos, e);
|
|
5508
5508
|
return !0;
|
|
5509
5509
|
},
|
|
5510
5510
|
handlePaste(t, n) {
|
|
5511
5511
|
let r = n.clipboardData?.items;
|
|
5512
5512
|
if (!r) return !1;
|
|
5513
5513
|
let i = n.clipboardData?.getData("text/plain") || "";
|
|
5514
|
-
if ((n.clipboardData?.files?.length ?? 0) > 0 &&
|
|
5514
|
+
if ((n.clipboardData?.files?.length ?? 0) > 0 && wr(i, void 0, a())) return !1;
|
|
5515
5515
|
for (let i of Array.from(r)) {
|
|
5516
5516
|
if (i.type.startsWith("image/") || i.type.startsWith("video/") || i.type.startsWith("audio/")) {
|
|
5517
5517
|
n.preventDefault();
|
|
5518
5518
|
let r = i.getAsFile();
|
|
5519
|
-
return r &&
|
|
5519
|
+
return r && Tr(r) !== "file" && Ar(t, r, void 0, e), !0;
|
|
5520
5520
|
}
|
|
5521
5521
|
if (i.kind === "file") {
|
|
5522
5522
|
let r = i.getAsFile();
|
|
5523
|
-
if (r &&
|
|
5523
|
+
if (r && Er(r)) return n.preventDefault(), Dr(t, r, void 0, e), !0;
|
|
5524
5524
|
}
|
|
5525
5525
|
}
|
|
5526
5526
|
return !1;
|
|
@@ -5528,12 +5528,12 @@ var Ar = R.create({
|
|
|
5528
5528
|
}
|
|
5529
5529
|
})];
|
|
5530
5530
|
}
|
|
5531
|
-
}),
|
|
5531
|
+
}), Mr = 100, Nr = R.create({
|
|
5532
5532
|
name: "imeCommitSpaceGuard",
|
|
5533
5533
|
addProseMirrorPlugins() {
|
|
5534
5534
|
let e = 0;
|
|
5535
|
-
return [new
|
|
5536
|
-
key: new
|
|
5535
|
+
return [new B({
|
|
5536
|
+
key: new V("imeCommitSpaceGuard"),
|
|
5537
5537
|
props: { handleDOMEvents: {
|
|
5538
5538
|
compositionend() {
|
|
5539
5539
|
return e = performance.now(), !1;
|
|
@@ -5543,30 +5543,39 @@ var Ar = R.create({
|
|
|
5543
5543
|
},
|
|
5544
5544
|
beforeinput(t, n) {
|
|
5545
5545
|
let r = n;
|
|
5546
|
-
return r.inputType !== "insertText" || r.data !== " " || r.isComposing || performance.now() - e >
|
|
5546
|
+
return r.inputType !== "insertText" || r.data !== " " || r.isComposing || performance.now() - e > Mr ? !1 : (r.preventDefault(), !0);
|
|
5547
5547
|
}
|
|
5548
5548
|
} }
|
|
5549
5549
|
})];
|
|
5550
5550
|
}
|
|
5551
|
-
}),
|
|
5552
|
-
|
|
5551
|
+
}), Pr = R.create({
|
|
5552
|
+
name: "inlineCodeEnd",
|
|
5553
|
+
addInputRules() {
|
|
5554
|
+
let e = this.editor.schema.marks.code;
|
|
5555
|
+
return e ? [ie({
|
|
5556
|
+
find: /`([^`]+)`$/,
|
|
5557
|
+
type: e
|
|
5558
|
+
})] : [];
|
|
5559
|
+
}
|
|
5560
|
+
}), Fr = /\.(png|jpe?g|gif|webp|bmp|svg|avif)(\?|#|$)/i, Ir = /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|#|$)/i, Lr = /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|#|$)/i;
|
|
5561
|
+
function Rr(e) {
|
|
5553
5562
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
5554
5563
|
}
|
|
5555
|
-
function
|
|
5564
|
+
function zr(e) {
|
|
5556
5565
|
let t = e.trim().replace(/\\/g, "/");
|
|
5557
5566
|
return t.split("/").pop() || t;
|
|
5558
5567
|
}
|
|
5559
|
-
function
|
|
5568
|
+
function Br(e, t) {
|
|
5560
5569
|
let n = e.src.slice(e.pos), r = /^!\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !0;
|
|
5561
5570
|
if (r || (r = /^\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !1), !r) return !1;
|
|
5562
5571
|
let a = r[1].trim(), o = r[2]?.trim();
|
|
5563
5572
|
if (!t) {
|
|
5564
|
-
let t = o ||
|
|
5573
|
+
let t = o || zr(a);
|
|
5565
5574
|
if (i) {
|
|
5566
5575
|
let n = "";
|
|
5567
|
-
if (
|
|
5568
|
-
else if (
|
|
5569
|
-
else if (
|
|
5576
|
+
if (Fr.test(a) || /^data:image\//i.test(a)) n = `<img src="${Rr(a)}" alt="${Rr(t)}">`;
|
|
5577
|
+
else if (Ir.test(a) || /^data:video\//i.test(a)) n = `<div data-video-embed src="${Rr(a)}"></div>`;
|
|
5578
|
+
else if (Lr.test(a) || /^data:audio\//i.test(a)) n = `<audio src="${Rr(a)}"></audio>`;
|
|
5570
5579
|
else {
|
|
5571
5580
|
let n = e.push("link_open", "a", 1);
|
|
5572
5581
|
n.attrs = [["href", a]];
|
|
@@ -5584,14 +5593,14 @@ function Rr(e, t) {
|
|
|
5584
5593
|
}
|
|
5585
5594
|
return e.pos += r[0].length, !0;
|
|
5586
5595
|
}
|
|
5587
|
-
var
|
|
5596
|
+
var Vr = R.create({
|
|
5588
5597
|
name: "obsidianMarkdown",
|
|
5589
5598
|
addStorage() {
|
|
5590
5599
|
return { markdown: { parse: { setup(e) {
|
|
5591
|
-
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed",
|
|
5600
|
+
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed", Br));
|
|
5592
5601
|
} } } };
|
|
5593
5602
|
}
|
|
5594
|
-
}),
|
|
5603
|
+
}), Hr = R.create({
|
|
5595
5604
|
name: "qingwuUI",
|
|
5596
5605
|
addStorage() {
|
|
5597
5606
|
return {};
|
|
@@ -5599,7 +5608,7 @@ var zr = R.create({
|
|
|
5599
5608
|
});
|
|
5600
5609
|
//#endregion
|
|
5601
5610
|
//#region src/editor/utils/render-probe.ts
|
|
5602
|
-
function
|
|
5611
|
+
function Ur(e, t) {
|
|
5603
5612
|
return new Promise((n) => {
|
|
5604
5613
|
if (typeof Image != "function") return n(!0);
|
|
5605
5614
|
let r = new Image(), i = !1, a = setTimeout(() => o(!1), t), o = (e) => {
|
|
@@ -5608,14 +5617,14 @@ function Vr(e, t) {
|
|
|
5608
5617
|
r.onload = () => o(!0), r.onerror = () => o(!1), r.src = e;
|
|
5609
5618
|
});
|
|
5610
5619
|
}
|
|
5611
|
-
async function
|
|
5612
|
-
if (await
|
|
5620
|
+
async function Wr(e, t = 8e3) {
|
|
5621
|
+
if (await Ur(e, t)) return !0;
|
|
5613
5622
|
try {
|
|
5614
5623
|
let r = await n(e);
|
|
5615
5624
|
if (!r) return !1;
|
|
5616
5625
|
let i = await fetch(e, { headers: r });
|
|
5617
5626
|
if (!i.ok) return !1;
|
|
5618
|
-
let a = URL.createObjectURL(await i.blob()), o = await
|
|
5627
|
+
let a = URL.createObjectURL(await i.blob()), o = await Ur(a, t);
|
|
5619
5628
|
return URL.revokeObjectURL(a), o;
|
|
5620
5629
|
} catch {
|
|
5621
5630
|
return !1;
|
|
@@ -5623,7 +5632,7 @@ async function Hr(e, t = 8e3) {
|
|
|
5623
5632
|
}
|
|
5624
5633
|
//#endregion
|
|
5625
5634
|
//#region src/editor/utils/resolve-local-media.ts
|
|
5626
|
-
function
|
|
5635
|
+
function Gr() {
|
|
5627
5636
|
return {
|
|
5628
5637
|
uploaded: 0,
|
|
5629
5638
|
sessionOnly: 0,
|
|
@@ -5633,10 +5642,10 @@ function Ur() {
|
|
|
5633
5642
|
readFailed: []
|
|
5634
5643
|
};
|
|
5635
5644
|
}
|
|
5636
|
-
function
|
|
5645
|
+
function Kr(e, t) {
|
|
5637
5646
|
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);
|
|
5638
5647
|
}
|
|
5639
|
-
function
|
|
5648
|
+
function qr(e, t, n, r) {
|
|
5640
5649
|
let { state: i } = e, a = [];
|
|
5641
5650
|
if (i.doc.descendants((e, n) => {
|
|
5642
5651
|
e.attrs?.src === t && a.push(n);
|
|
@@ -5652,7 +5661,7 @@ function Gr(e, t, n, r) {
|
|
|
5652
5661
|
}
|
|
5653
5662
|
return e.dispatch(o), !0;
|
|
5654
5663
|
}
|
|
5655
|
-
function
|
|
5664
|
+
function Jr(e, t, n) {
|
|
5656
5665
|
let { state: r } = e, i = r.schema.marks.link;
|
|
5657
5666
|
if (!i) return !1;
|
|
5658
5667
|
let a = [];
|
|
@@ -5670,7 +5679,7 @@ function Kr(e, t, n) {
|
|
|
5670
5679
|
}));
|
|
5671
5680
|
return e.dispatch(o), !0;
|
|
5672
5681
|
}
|
|
5673
|
-
function
|
|
5682
|
+
function Yr(e) {
|
|
5674
5683
|
let t = /* @__PURE__ */ new Map();
|
|
5675
5684
|
for (let n of e) {
|
|
5676
5685
|
let e = t.get(n.normalized);
|
|
@@ -5678,36 +5687,36 @@ function qr(e) {
|
|
|
5678
5687
|
}
|
|
5679
5688
|
return Array.from(t.values());
|
|
5680
5689
|
}
|
|
5681
|
-
async function
|
|
5690
|
+
async function Xr(e, t, n, r) {
|
|
5682
5691
|
if (n.length === 0) return "sessionOnly";
|
|
5683
|
-
let i = n[0], a =
|
|
5692
|
+
let i = n[0], a = dn(t);
|
|
5684
5693
|
if (a) {
|
|
5685
|
-
let t =
|
|
5694
|
+
let t = fn(e.state.doc, r, a);
|
|
5686
5695
|
if (t) return Z(`${i.basename}:${t}`, "error"), "limitRejected";
|
|
5687
5696
|
}
|
|
5688
5697
|
let s = n.filter((e) => !e.isLink), c = n.filter((e) => e.isLink);
|
|
5689
5698
|
if (s.length === 0) try {
|
|
5690
5699
|
let t = await o().upload(r, "editor"), n = !1;
|
|
5691
|
-
for (let r of c)
|
|
5700
|
+
for (let r of c) Jr(e, r.src, t) && (n = !0);
|
|
5692
5701
|
return n ? "uploaded" : "sessionOnly";
|
|
5693
5702
|
} catch (e) {
|
|
5694
5703
|
return console.error(`本地附件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), "sessionOnly";
|
|
5695
5704
|
}
|
|
5696
5705
|
let l = URL.createObjectURL(r), u = !1;
|
|
5697
|
-
for (let t of s)
|
|
5706
|
+
for (let t of s) qr(e, t.src, l, r.size) && (u = !0);
|
|
5698
5707
|
let d;
|
|
5699
5708
|
try {
|
|
5700
5709
|
d = await o().upload(r, "editor");
|
|
5701
5710
|
} catch (e) {
|
|
5702
5711
|
return console.error(`本地文件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), URL.revokeObjectURL(l), "sessionOnly";
|
|
5703
5712
|
}
|
|
5704
|
-
URL.revokeObjectURL(l), u &&
|
|
5705
|
-
for (let t of c)
|
|
5706
|
-
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await
|
|
5713
|
+
URL.revokeObjectURL(l), u && qr(e, l, d, r.size);
|
|
5714
|
+
for (let t of c) Jr(e, t.src, d);
|
|
5715
|
+
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await Wr(d) ? "uploaded" : "renderFailed" : "uploaded";
|
|
5707
5716
|
}
|
|
5708
|
-
function
|
|
5717
|
+
function Zr(e, t) {
|
|
5709
5718
|
let n = [], r = [];
|
|
5710
|
-
for (let i of
|
|
5719
|
+
for (let i of Yr(e)) {
|
|
5711
5720
|
let e = i[0], a = t.get(e.basename);
|
|
5712
5721
|
a ? (n.push({
|
|
5713
5722
|
refs: i,
|
|
@@ -5719,30 +5728,30 @@ function Yr(e, t) {
|
|
|
5719
5728
|
unmatched: r
|
|
5720
5729
|
};
|
|
5721
5730
|
}
|
|
5722
|
-
async function
|
|
5723
|
-
let i =
|
|
5724
|
-
for (let a of
|
|
5725
|
-
let n = a[0], { file: o, readError: s } = await
|
|
5731
|
+
async function Qr(e, t, n, r) {
|
|
5732
|
+
let i = Gr();
|
|
5733
|
+
for (let a of Yr(n)) {
|
|
5734
|
+
let n = a[0], { file: o, readError: s } = await xr(r, n.src);
|
|
5726
5735
|
if (!o) {
|
|
5727
5736
|
s ? (console.warn(`本地文件「${n.basename}」在所选文件夹中找到但读取失败:`, s), i.readFailed.push(n)) : (console.warn(`本地文件「${n.basename}」未在所选文件夹「${r.name}」中找到`), i.missing.push(n));
|
|
5728
5737
|
continue;
|
|
5729
5738
|
}
|
|
5730
|
-
let c = await
|
|
5739
|
+
let c = await Xr(e, t, a, o);
|
|
5731
5740
|
i[c]++;
|
|
5732
5741
|
}
|
|
5733
5742
|
return i;
|
|
5734
5743
|
}
|
|
5735
|
-
function
|
|
5744
|
+
function $r(e) {
|
|
5736
5745
|
let t = e.map((e) => e.basename);
|
|
5737
5746
|
return t.length <= 3 ? t.join("、") : `${t.slice(0, 3).join("、")} 等 ${t.length} 个文件`;
|
|
5738
5747
|
}
|
|
5739
|
-
function
|
|
5748
|
+
function ei(e) {
|
|
5740
5749
|
let t = [];
|
|
5741
|
-
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} 个找到但读取失败:${
|
|
5750
|
+
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} 个找到但读取失败:${$r(e.readFailed)}(若在 OneDrive / WPS 云盘等同步目录,请右键文件选择「始终保留在此设备」后重试)`), e.missing.length > 0 && t.push(`${e.missing.length} 个未能获取:${$r(e.missing)}(可把文件直接拖进编辑器上传)`), t.length === 0) return;
|
|
5742
5751
|
let n = e.uploaded > 0 && e.renderFailed === 0 && e.missing.length === 0 && e.readFailed.length === 0;
|
|
5743
5752
|
Z(`本地文件解析完成:${t.join(";")}`, n ? "success" : "info");
|
|
5744
5753
|
}
|
|
5745
|
-
function
|
|
5754
|
+
function ti(e) {
|
|
5746
5755
|
return new Promise((t) => {
|
|
5747
5756
|
let n = document.createElement("div");
|
|
5748
5757
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5769,7 +5778,7 @@ function $r(e) {
|
|
|
5769
5778
|
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);
|
|
5770
5779
|
});
|
|
5771
5780
|
}
|
|
5772
|
-
function
|
|
5781
|
+
function ni(e) {
|
|
5773
5782
|
let t = document.createElement("div");
|
|
5774
5783
|
t.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
5775
5784
|
let n = document.createElement("div");
|
|
@@ -5791,7 +5800,7 @@ function ei(e) {
|
|
|
5791
5800
|
let c = document.createElement("button");
|
|
5792
5801
|
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);
|
|
5793
5802
|
}
|
|
5794
|
-
function
|
|
5803
|
+
function ri(e) {
|
|
5795
5804
|
return new Promise((t) => {
|
|
5796
5805
|
let n = document.createElement("div");
|
|
5797
5806
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5817,8 +5826,8 @@ function ti(e) {
|
|
|
5817
5826
|
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);
|
|
5818
5827
|
});
|
|
5819
5828
|
}
|
|
5820
|
-
async function
|
|
5821
|
-
let r =
|
|
5829
|
+
async function ii(e, t, n) {
|
|
5830
|
+
let r = Gr(), i = Yr(n), a = await vr();
|
|
5822
5831
|
if (!a) {
|
|
5823
5832
|
for (let e of i) r.missing.push(e[0]);
|
|
5824
5833
|
return r;
|
|
@@ -5831,14 +5840,14 @@ async function ni(e, t, n) {
|
|
|
5831
5840
|
continue;
|
|
5832
5841
|
}
|
|
5833
5842
|
o.delete(i.basename);
|
|
5834
|
-
let s = await
|
|
5843
|
+
let s = await Xr(e, t, n, a);
|
|
5835
5844
|
r[s]++;
|
|
5836
5845
|
}
|
|
5837
5846
|
return r;
|
|
5838
5847
|
}
|
|
5839
5848
|
//#endregion
|
|
5840
5849
|
//#region src/editor/extensions/relative-media.ts
|
|
5841
|
-
var
|
|
5850
|
+
var ai = R.create({
|
|
5842
5851
|
name: "relativeMedia",
|
|
5843
5852
|
addStorage() {
|
|
5844
5853
|
return {
|
|
@@ -5848,42 +5857,42 @@ var ri = R.create({
|
|
|
5848
5857
|
},
|
|
5849
5858
|
addProseMirrorPlugins() {
|
|
5850
5859
|
let e = this.editor, t = this.storage, n = !1, r = null, i = async (n, i) => {
|
|
5851
|
-
let a = e.view, o =
|
|
5860
|
+
let a = e.view, o = Gr(), { matched: s, unmatched: c } = Zr(n, t.clipboardFiles);
|
|
5852
5861
|
for (let { refs: t, file: n } of s) {
|
|
5853
|
-
let r = await
|
|
5862
|
+
let r = await Xr(a, e, t, n);
|
|
5854
5863
|
o[r]++;
|
|
5855
5864
|
}
|
|
5856
5865
|
if (c.length > 0) {
|
|
5857
|
-
let t =
|
|
5858
|
-
if (
|
|
5866
|
+
let t = Yr(c).length;
|
|
5867
|
+
if (hr()) {
|
|
5859
5868
|
let n = i ?? null;
|
|
5860
|
-
if (n || (await
|
|
5861
|
-
r = n,
|
|
5869
|
+
if (n || (await ti(t) === "pick" ? (n = await gr(), n || Z("没有选择文件夹。本地文件暂以占位显示,稍后可直接把文件拖进编辑器上传", "info")) : Z("已选择稍后处理。本地文件暂以占位显示,可直接把文件拖进编辑器上传", "info")), n) {
|
|
5870
|
+
r = n, Kr(o, await Qr(a, e, c, n));
|
|
5862
5871
|
let t = [...o.missing, ...o.readFailed];
|
|
5863
|
-
if (t.length > 0 &&
|
|
5864
|
-
let n = await
|
|
5865
|
-
|
|
5872
|
+
if (t.length > 0 && _r() && await ri(t.map((e) => e.basename)) === "pick") {
|
|
5873
|
+
let n = await ii(a, e, t);
|
|
5874
|
+
Kr(o, n), o.missing = n.missing, o.readFailed = [];
|
|
5866
5875
|
}
|
|
5867
5876
|
}
|
|
5868
|
-
} else
|
|
5877
|
+
} else ni(t);
|
|
5869
5878
|
}
|
|
5870
|
-
|
|
5879
|
+
ei(o);
|
|
5871
5880
|
}, o = () => {
|
|
5872
5881
|
if (!e || e.isDestroyed || t.pausedUntilPaste) return;
|
|
5873
|
-
let o = a(), s =
|
|
5882
|
+
let o = a(), s = Cr(e.state.doc, o);
|
|
5874
5883
|
if (s.length === 0 || n) return;
|
|
5875
5884
|
n = !0;
|
|
5876
5885
|
let c = new Set(s.map((e) => e.src));
|
|
5877
5886
|
i(s).then(() => {
|
|
5878
5887
|
if (e.isDestroyed) return;
|
|
5879
|
-
let t =
|
|
5888
|
+
let t = Cr(e.state.doc, o).filter((e) => !c.has(e.src));
|
|
5880
5889
|
if (t.length !== 0) return i(t, r);
|
|
5881
5890
|
}).finally(() => {
|
|
5882
|
-
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste =
|
|
5891
|
+
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste = Cr(e.state.doc, o).length > 0);
|
|
5883
5892
|
});
|
|
5884
5893
|
};
|
|
5885
|
-
return [new
|
|
5886
|
-
key: new
|
|
5894
|
+
return [new B({
|
|
5895
|
+
key: new V("relativeMedia"),
|
|
5887
5896
|
props: { handlePaste(e, n) {
|
|
5888
5897
|
let r = n.clipboardData?.files;
|
|
5889
5898
|
return t.clipboardFiles = new Map(Array.from(r ?? []).map((e) => [e.name.toLowerCase(), e])), t.pausedUntilPaste = !1, !1;
|
|
@@ -5893,18 +5902,18 @@ var ri = R.create({
|
|
|
5893
5902
|
}
|
|
5894
5903
|
})];
|
|
5895
5904
|
}
|
|
5896
|
-
}),
|
|
5897
|
-
function
|
|
5905
|
+
}), oi = new V("slashCommand");
|
|
5906
|
+
function si(e) {
|
|
5898
5907
|
return R.create({
|
|
5899
5908
|
name: "slashCommand",
|
|
5900
5909
|
addProseMirrorPlugins() {
|
|
5901
5910
|
let t = {
|
|
5902
5911
|
char: "/",
|
|
5903
|
-
pluginKey:
|
|
5912
|
+
pluginKey: oi,
|
|
5904
5913
|
findSuggestionMatch: (e) => {
|
|
5905
5914
|
let { $position: t } = e;
|
|
5906
5915
|
for (let e = t.depth; e >= 0; e--) if (t.node(e).type.name === "codeBlock") return null;
|
|
5907
|
-
return t.marks().some((e) => e.type.name === "code") ? null :
|
|
5916
|
+
return t.marks().some((e) => e.type.name === "code") ? null : Te(e);
|
|
5908
5917
|
},
|
|
5909
5918
|
allow: ({ editor: e, state: t }) => {
|
|
5910
5919
|
if (!e.isEditable) return !1;
|
|
@@ -5986,7 +5995,7 @@ function ai(e) {
|
|
|
5986
5995
|
if (e.key === "Escape") {
|
|
5987
5996
|
e.preventDefault();
|
|
5988
5997
|
let t = a?.view;
|
|
5989
|
-
t &&
|
|
5998
|
+
t && we(t, oi);
|
|
5990
5999
|
}
|
|
5991
6000
|
});
|
|
5992
6001
|
}
|
|
@@ -6004,7 +6013,7 @@ function ai(e) {
|
|
|
6004
6013
|
if (!e || e.style.display === "none" || n.target instanceof Node && e.contains(n.target) || t) return;
|
|
6005
6014
|
let r = a?.view;
|
|
6006
6015
|
r && (t = !0, window.setTimeout(() => {
|
|
6007
|
-
t = !1, e?.style.display !== "none" &&
|
|
6016
|
+
t = !1, e?.style.display !== "none" && we(r, oi);
|
|
6008
6017
|
}, 0));
|
|
6009
6018
|
}, document.addEventListener("mousedown", o, !0), document.addEventListener("touchstart", o, !0);
|
|
6010
6019
|
}
|
|
@@ -6028,11 +6037,11 @@ function ai(e) {
|
|
|
6028
6037
|
};
|
|
6029
6038
|
}
|
|
6030
6039
|
};
|
|
6031
|
-
return [
|
|
6040
|
+
return [Ce({
|
|
6032
6041
|
editor: this.editor,
|
|
6033
6042
|
...t
|
|
6034
|
-
}), new
|
|
6035
|
-
key: new
|
|
6043
|
+
}), new B({
|
|
6044
|
+
key: new V("slashCodeBlockGuard"),
|
|
6036
6045
|
appendTransaction: (e, t, n) => {
|
|
6037
6046
|
let { $from: r } = n.selection, i = !1;
|
|
6038
6047
|
for (let e = r.depth; e >= 0; e--) if (r.node(e).type.name === "codeBlock") {
|
|
@@ -6040,14 +6049,14 @@ function ai(e) {
|
|
|
6040
6049
|
break;
|
|
6041
6050
|
}
|
|
6042
6051
|
if (!i && !r.marks().some((e) => e.type.name === "code")) return null;
|
|
6043
|
-
let a =
|
|
6044
|
-
return a && a.active ? n.tr.setMeta(
|
|
6052
|
+
let a = oi.getState(n);
|
|
6053
|
+
return a && a.active ? n.tr.setMeta(oi, { exit: !0 }) : null;
|
|
6045
6054
|
}
|
|
6046
6055
|
})];
|
|
6047
6056
|
}
|
|
6048
6057
|
});
|
|
6049
6058
|
}
|
|
6050
|
-
function
|
|
6059
|
+
function ci(e, t) {
|
|
6051
6060
|
return [
|
|
6052
6061
|
{
|
|
6053
6062
|
title: e("editor.slash.heading1"),
|
|
@@ -6146,7 +6155,7 @@ function oi(e, t) {
|
|
|
6146
6155
|
n.type = "file", n.accept = "audio/*", n.onchange = async () => {
|
|
6147
6156
|
let r = n.files?.[0];
|
|
6148
6157
|
if (!r) return;
|
|
6149
|
-
let i =
|
|
6158
|
+
let i = dn(e) ?? t, a = i ? fn(e.state.doc, r, i) : null;
|
|
6150
6159
|
if (a) {
|
|
6151
6160
|
Z(a);
|
|
6152
6161
|
return;
|
|
@@ -6156,7 +6165,7 @@ function oi(e, t) {
|
|
|
6156
6165
|
name: r.name,
|
|
6157
6166
|
size: r.size
|
|
6158
6167
|
});
|
|
6159
|
-
s && (e.chain().focus().insertContent(s).run(), await
|
|
6168
|
+
s && (e.chain().focus().insertContent(s).run(), await kr(e.view, r, o));
|
|
6160
6169
|
}, n.click();
|
|
6161
6170
|
}
|
|
6162
6171
|
},
|
|
@@ -6169,7 +6178,7 @@ function oi(e, t) {
|
|
|
6169
6178
|
n.type = "file", n.accept = "*/*", n.multiple = !0, n.onchange = async () => {
|
|
6170
6179
|
let r = n.files;
|
|
6171
6180
|
if (!(!r || r.length === 0)) for (let n of Array.from(r)) {
|
|
6172
|
-
let r =
|
|
6181
|
+
let r = dn(e) ?? t, i = r ? fn(e.state.doc, n, r) : null;
|
|
6173
6182
|
if (i) {
|
|
6174
6183
|
Z(i);
|
|
6175
6184
|
continue;
|
|
@@ -6186,7 +6195,7 @@ function oi(e, t) {
|
|
|
6186
6195
|
} catch {
|
|
6187
6196
|
continue;
|
|
6188
6197
|
}
|
|
6189
|
-
await
|
|
6198
|
+
await kr(e.view, n, a);
|
|
6190
6199
|
}
|
|
6191
6200
|
}
|
|
6192
6201
|
}, n.click();
|
|
@@ -6196,9 +6205,9 @@ function oi(e, t) {
|
|
|
6196
6205
|
}
|
|
6197
6206
|
//#endregion
|
|
6198
6207
|
//#region src/editor/extensions/index.ts
|
|
6199
|
-
var
|
|
6208
|
+
var li = U.extend({
|
|
6200
6209
|
addNodeView() {
|
|
6201
|
-
return I(
|
|
6210
|
+
return I(Cn);
|
|
6202
6211
|
},
|
|
6203
6212
|
addAttributes() {
|
|
6204
6213
|
return {
|
|
@@ -6221,112 +6230,113 @@ var si = oe.extend({
|
|
|
6221
6230
|
};
|
|
6222
6231
|
}
|
|
6223
6232
|
});
|
|
6224
|
-
function
|
|
6233
|
+
function ui(e = {}) {
|
|
6225
6234
|
return [
|
|
6226
|
-
|
|
6235
|
+
K.configure({
|
|
6227
6236
|
codeBlock: !1,
|
|
6228
6237
|
horizontalRule: !1,
|
|
6229
6238
|
underline: !1,
|
|
6230
6239
|
link: !1
|
|
6231
6240
|
}),
|
|
6232
|
-
|
|
6233
|
-
|
|
6241
|
+
G,
|
|
6242
|
+
W.configure({
|
|
6234
6243
|
openOnClick: !0,
|
|
6235
6244
|
HTMLAttributes: {
|
|
6236
6245
|
rel: "noopener noreferrer",
|
|
6237
6246
|
target: "_blank"
|
|
6238
6247
|
}
|
|
6239
6248
|
}),
|
|
6240
|
-
|
|
6249
|
+
li.configure({
|
|
6241
6250
|
inline: !1,
|
|
6242
6251
|
allowBase64: !0
|
|
6243
6252
|
}),
|
|
6244
|
-
he,
|
|
6245
|
-
me.configure({ nested: !0 }),
|
|
6246
|
-
se.configure({ multicolor: !0 }),
|
|
6247
6253
|
ge,
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6254
|
+
he.configure({ nested: !0 }),
|
|
6255
|
+
ce.configure({ multicolor: !0 }),
|
|
6256
|
+
_e,
|
|
6257
|
+
se,
|
|
6258
|
+
q.configure(e.maxLength ? { limit: e.maxLength } : {}),
|
|
6259
|
+
le,
|
|
6260
|
+
Pr,
|
|
6261
|
+
sr,
|
|
6262
|
+
de.configure({ resizable: !0 }),
|
|
6263
|
+
me,
|
|
6255
6264
|
fe,
|
|
6256
|
-
|
|
6265
|
+
pe,
|
|
6266
|
+
ve.configure({
|
|
6257
6267
|
html: !0,
|
|
6258
6268
|
transformPastedText: !0,
|
|
6259
6269
|
transformCopiedText: !1
|
|
6260
6270
|
}),
|
|
6261
|
-
|
|
6262
|
-
|
|
6271
|
+
ue.configure({ placeholder: e.placeholder || "输入 '/' 打开菜单…" }),
|
|
6272
|
+
si(() => ci((e) => f(e), {
|
|
6263
6273
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6264
6274
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6265
6275
|
})),
|
|
6266
|
-
|
|
6276
|
+
jr.configure({
|
|
6267
6277
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6268
6278
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6269
6279
|
}),
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6280
|
+
ai,
|
|
6281
|
+
Vr,
|
|
6282
|
+
Ot,
|
|
6283
|
+
Nr,
|
|
6284
|
+
Hr,
|
|
6285
|
+
Jn,
|
|
6286
|
+
Vn,
|
|
6287
|
+
Rn
|
|
6278
6288
|
];
|
|
6279
6289
|
}
|
|
6280
6290
|
//#endregion
|
|
6281
6291
|
//#region src/editor/extensions/bubble-menu.tsx
|
|
6282
|
-
var
|
|
6283
|
-
function
|
|
6284
|
-
|
|
6292
|
+
var di = "https://www.bing.com/search?q={query}";
|
|
6293
|
+
function fi(e) {
|
|
6294
|
+
di = e;
|
|
6285
6295
|
}
|
|
6286
|
-
function
|
|
6287
|
-
return
|
|
6296
|
+
function pi() {
|
|
6297
|
+
return di;
|
|
6288
6298
|
}
|
|
6289
|
-
function
|
|
6299
|
+
function mi(e) {
|
|
6290
6300
|
return [
|
|
6291
6301
|
{
|
|
6292
6302
|
key: "bold",
|
|
6293
6303
|
label: e("editor.bubble.bold"),
|
|
6294
|
-
icon: /* @__PURE__ */ D(
|
|
6304
|
+
icon: /* @__PURE__ */ D(jt, {}),
|
|
6295
6305
|
isActive: (e) => e.isActive("bold"),
|
|
6296
6306
|
command: (e) => e.isEditable && e.chain().focus().toggleBold().run()
|
|
6297
6307
|
},
|
|
6298
6308
|
{
|
|
6299
6309
|
key: "italic",
|
|
6300
6310
|
label: e("editor.bubble.italic"),
|
|
6301
|
-
icon: /* @__PURE__ */ D(
|
|
6311
|
+
icon: /* @__PURE__ */ D(Mt, {}),
|
|
6302
6312
|
isActive: (e) => e.isActive("italic"),
|
|
6303
6313
|
command: (e) => e.isEditable && e.chain().focus().toggleItalic().run()
|
|
6304
6314
|
},
|
|
6305
6315
|
{
|
|
6306
6316
|
key: "underline",
|
|
6307
6317
|
label: e("editor.bubble.underline"),
|
|
6308
|
-
icon: /* @__PURE__ */ D(
|
|
6318
|
+
icon: /* @__PURE__ */ D(Nt, {}),
|
|
6309
6319
|
isActive: (e) => e.isActive("underline"),
|
|
6310
6320
|
command: (e) => e.isEditable && e.chain().focus().toggleUnderline().run()
|
|
6311
6321
|
},
|
|
6312
6322
|
{
|
|
6313
6323
|
key: "strikethrough",
|
|
6314
6324
|
label: e("editor.bubble.strikethrough"),
|
|
6315
|
-
icon: /* @__PURE__ */ D(
|
|
6325
|
+
icon: /* @__PURE__ */ D(Pt, {}),
|
|
6316
6326
|
isActive: (e) => e.isActive("strike"),
|
|
6317
6327
|
command: (e) => e.isEditable && e.chain().focus().toggleStrike().run()
|
|
6318
6328
|
},
|
|
6319
6329
|
{
|
|
6320
6330
|
key: "code",
|
|
6321
6331
|
label: e("editor.bubble.emphasis"),
|
|
6322
|
-
icon: /* @__PURE__ */ D(
|
|
6332
|
+
icon: /* @__PURE__ */ D(Ft, {}),
|
|
6323
6333
|
isActive: (e) => e.isActive("code"),
|
|
6324
6334
|
command: (e) => e.isEditable && e.chain().focus().toggleCode().run()
|
|
6325
6335
|
},
|
|
6326
6336
|
{
|
|
6327
6337
|
key: "highlight",
|
|
6328
6338
|
label: e("editor.bubble.highlight"),
|
|
6329
|
-
icon: /* @__PURE__ */ D(
|
|
6339
|
+
icon: /* @__PURE__ */ D(It, {}),
|
|
6330
6340
|
more: !0,
|
|
6331
6341
|
isActive: (e) => e.isActive("highlight"),
|
|
6332
6342
|
command: () => {}
|
|
@@ -6334,7 +6344,7 @@ function fi(e) {
|
|
|
6334
6344
|
{
|
|
6335
6345
|
key: "link",
|
|
6336
6346
|
label: e("editor.bubble.link"),
|
|
6337
|
-
icon: /* @__PURE__ */ D(
|
|
6347
|
+
icon: /* @__PURE__ */ D(Lt, {}),
|
|
6338
6348
|
more: !0,
|
|
6339
6349
|
isActive: (e) => e.isActive("link"),
|
|
6340
6350
|
command: () => {}
|
|
@@ -6342,7 +6352,7 @@ function fi(e) {
|
|
|
6342
6352
|
{
|
|
6343
6353
|
key: "copy",
|
|
6344
6354
|
label: e("editor.bubble.copy"),
|
|
6345
|
-
icon: /* @__PURE__ */ D(
|
|
6355
|
+
icon: /* @__PURE__ */ D(zt, {}),
|
|
6346
6356
|
more: !0,
|
|
6347
6357
|
isActive: () => !1,
|
|
6348
6358
|
command: (e) => {
|
|
@@ -6353,21 +6363,21 @@ function fi(e) {
|
|
|
6353
6363
|
{
|
|
6354
6364
|
key: "search",
|
|
6355
6365
|
label: e("editor.bubble.search"),
|
|
6356
|
-
icon: /* @__PURE__ */ D(
|
|
6366
|
+
icon: /* @__PURE__ */ D(Bt, {}),
|
|
6357
6367
|
more: !0,
|
|
6358
6368
|
isActive: () => !1,
|
|
6359
6369
|
command: (e) => {
|
|
6360
6370
|
if (e.isActive("table")) return;
|
|
6361
6371
|
let { from: t, to: n } = e.state.selection, r = e.state.doc.textBetween(t, n, " ").trim();
|
|
6362
6372
|
if (!r) return;
|
|
6363
|
-
let i =
|
|
6373
|
+
let i = di.replace("{query}", encodeURIComponent(r));
|
|
6364
6374
|
window.open(i, "_blank", "noopener,noreferrer");
|
|
6365
6375
|
}
|
|
6366
6376
|
},
|
|
6367
6377
|
{
|
|
6368
6378
|
key: "table",
|
|
6369
6379
|
label: e("editor.bubble.table"),
|
|
6370
|
-
icon: /* @__PURE__ */ D(
|
|
6380
|
+
icon: /* @__PURE__ */ D(Rt, {}),
|
|
6371
6381
|
more: !0,
|
|
6372
6382
|
isActive: (e) => e.isActive("table"),
|
|
6373
6383
|
command: (e) => {
|
|
@@ -6383,7 +6393,7 @@ function fi(e) {
|
|
|
6383
6393
|
{
|
|
6384
6394
|
key: "ai",
|
|
6385
6395
|
label: e("editor.ai.trigger"),
|
|
6386
|
-
icon: /* @__PURE__ */ D(
|
|
6396
|
+
icon: /* @__PURE__ */ D(Vt, {}),
|
|
6387
6397
|
isActive: () => !1,
|
|
6388
6398
|
command: (e) => {
|
|
6389
6399
|
e.isEditable && e.storage.qingwuUI?.openAI?.();
|
|
@@ -6394,7 +6404,7 @@ function fi(e) {
|
|
|
6394
6404
|
R.create({ name: "bubbleMenu" });
|
|
6395
6405
|
//#endregion
|
|
6396
6406
|
//#region src/editor/extensions/table-toolbar.tsx
|
|
6397
|
-
function
|
|
6407
|
+
function hi(e) {
|
|
6398
6408
|
let { $from: t } = e.state.selection;
|
|
6399
6409
|
for (let e = t.depth; e > 0; e--) {
|
|
6400
6410
|
let n = t.node(e);
|
|
@@ -6405,7 +6415,7 @@ function pi(e) {
|
|
|
6405
6415
|
}
|
|
6406
6416
|
return null;
|
|
6407
6417
|
}
|
|
6408
|
-
function
|
|
6418
|
+
function gi(e) {
|
|
6409
6419
|
let t = [];
|
|
6410
6420
|
return e.forEach((e) => {
|
|
6411
6421
|
let n = [];
|
|
@@ -6414,7 +6424,7 @@ function mi(e) {
|
|
|
6414
6424
|
}), t.push(n);
|
|
6415
6425
|
}), t;
|
|
6416
6426
|
}
|
|
6417
|
-
function
|
|
6427
|
+
function _i(e) {
|
|
6418
6428
|
if (e.length === 0) return "";
|
|
6419
6429
|
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(" | ")} |`;
|
|
6420
6430
|
return [
|
|
@@ -6423,11 +6433,11 @@ function hi(e) {
|
|
|
6423
6433
|
...i.map(a)
|
|
6424
6434
|
].join("\n");
|
|
6425
6435
|
}
|
|
6426
|
-
function
|
|
6436
|
+
function vi(e) {
|
|
6427
6437
|
let t = (e) => /[",\n]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e;
|
|
6428
6438
|
return e.map((e) => e.map(t).join(",")).join("\n");
|
|
6429
6439
|
}
|
|
6430
|
-
function
|
|
6440
|
+
function yi(e) {
|
|
6431
6441
|
let t = e.trim();
|
|
6432
6442
|
if (!t) return null;
|
|
6433
6443
|
let n = t.split(/\r?\n/);
|
|
@@ -6441,7 +6451,7 @@ function _i(e) {
|
|
|
6441
6451
|
}
|
|
6442
6452
|
return null;
|
|
6443
6453
|
}
|
|
6444
|
-
function
|
|
6454
|
+
function bi({ editor: e }) {
|
|
6445
6455
|
let [t, n] = T(null), [r, i] = T(!1), [a, o] = T(!1), s = w(null), c = w(null), l = e.isEditable, u = b(() => {
|
|
6446
6456
|
c.current != null && cancelAnimationFrame(c.current), c.current = requestAnimationFrame(() => {
|
|
6447
6457
|
c.current = null;
|
|
@@ -6457,7 +6467,7 @@ function vi({ editor: e }) {
|
|
|
6457
6467
|
n(null);
|
|
6458
6468
|
return;
|
|
6459
6469
|
}
|
|
6460
|
-
let t =
|
|
6470
|
+
let t = hi(e);
|
|
6461
6471
|
if (!t) {
|
|
6462
6472
|
n(null);
|
|
6463
6473
|
return;
|
|
@@ -6486,24 +6496,24 @@ function vi({ editor: e }) {
|
|
|
6486
6496
|
});
|
|
6487
6497
|
return n.nodes.table.create(null, i);
|
|
6488
6498
|
}, p = () => {
|
|
6489
|
-
let t =
|
|
6499
|
+
let t = hi(e);
|
|
6490
6500
|
if (!t) return;
|
|
6491
|
-
let n =
|
|
6501
|
+
let n = _i(gi(t.node));
|
|
6492
6502
|
navigator.clipboard?.writeText(n), i(!0), setTimeout(() => i(!1), 1500);
|
|
6493
6503
|
}, m = () => {
|
|
6494
|
-
let t =
|
|
6504
|
+
let t = hi(e);
|
|
6495
6505
|
if (!t) return;
|
|
6496
|
-
let n = gi(
|
|
6506
|
+
let n = vi(gi(t.node)), r = new Blob([`\ufeff${n}`], { type: "text/csv;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
6497
6507
|
a.href = i, a.download = "table.csv", document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
6498
6508
|
}, h = async () => {
|
|
6499
6509
|
if (l) try {
|
|
6500
6510
|
let t = await navigator.clipboard?.readText();
|
|
6501
6511
|
if (!t) return;
|
|
6502
|
-
let n =
|
|
6512
|
+
let n = yi(t);
|
|
6503
6513
|
if (!n || n.length === 0) return;
|
|
6504
6514
|
let r = f(n);
|
|
6505
6515
|
if (!r) return;
|
|
6506
|
-
let i =
|
|
6516
|
+
let i = hi(e), a = e.chain().focus();
|
|
6507
6517
|
if (i) {
|
|
6508
6518
|
let t = Math.min(i.pos + i.node.nodeSize, e.state.doc.content.size);
|
|
6509
6519
|
a.setTextSelection(t);
|
|
@@ -6623,7 +6633,7 @@ function vi({ editor: e }) {
|
|
|
6623
6633
|
type: "button",
|
|
6624
6634
|
className: "tbl-btn tbl-btn--del",
|
|
6625
6635
|
onClick: () => {
|
|
6626
|
-
!l ||
|
|
6636
|
+
!l || gn() || ($(!0), o(!0));
|
|
6627
6637
|
},
|
|
6628
6638
|
title: "删除",
|
|
6629
6639
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -6641,7 +6651,7 @@ function vi({ editor: e }) {
|
|
|
6641
6651
|
})
|
|
6642
6652
|
})
|
|
6643
6653
|
}),
|
|
6644
|
-
/* @__PURE__ */ D(
|
|
6654
|
+
/* @__PURE__ */ D(xn, {
|
|
6645
6655
|
open: a,
|
|
6646
6656
|
title: "确认删除表格",
|
|
6647
6657
|
message: "此操作不可撤销。",
|
|
@@ -6657,7 +6667,7 @@ function vi({ editor: e }) {
|
|
|
6657
6667
|
}
|
|
6658
6668
|
//#endregion
|
|
6659
6669
|
//#region src/editor/ai-editor.tsx
|
|
6660
|
-
var
|
|
6670
|
+
var xi = [
|
|
6661
6671
|
{
|
|
6662
6672
|
color: "#fef08a",
|
|
6663
6673
|
name: "黄"
|
|
@@ -6682,9 +6692,9 @@ var yi = [
|
|
|
6682
6692
|
color: "#ddd6fe",
|
|
6683
6693
|
name: "紫"
|
|
6684
6694
|
}
|
|
6685
|
-
],
|
|
6686
|
-
function
|
|
6687
|
-
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth ||
|
|
6695
|
+
], Si = 288, Ci = 480, wi = 320;
|
|
6696
|
+
function Ti(e, t, n = {}) {
|
|
6697
|
+
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth || Si, Ci, r - 32), o = Math.max(t || wi, 160);
|
|
6688
6698
|
if (r < 640) {
|
|
6689
6699
|
let t = Math.max(8, Math.min(e.top + 10, i - 420));
|
|
6690
6700
|
return {
|
|
@@ -6725,10 +6735,10 @@ function Ci(e, t, n = {}) {
|
|
|
6725
6735
|
arrowLeft: p
|
|
6726
6736
|
};
|
|
6727
6737
|
}
|
|
6728
|
-
function
|
|
6738
|
+
function Ei(e) {
|
|
6729
6739
|
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);
|
|
6730
6740
|
}
|
|
6731
|
-
function
|
|
6741
|
+
function Di(e, t) {
|
|
6732
6742
|
try {
|
|
6733
6743
|
let n = e.storage?.markdown?.parser;
|
|
6734
6744
|
if (!n) return null;
|
|
@@ -6738,19 +6748,19 @@ function Ti(e, t) {
|
|
|
6738
6748
|
return null;
|
|
6739
6749
|
}
|
|
6740
6750
|
}
|
|
6741
|
-
var
|
|
6751
|
+
var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.ImageUploadDialog }))), ki = y(() => import("./storage-settings-dialog-DZqqDAiO.js").then((e) => ({ default: e.StorageSettingsDialog }))), Ai = y(() => import("./export-dialog-CL7ie13Z.js").then((e) => ({ default: e.ExportDialog }))), ji = y(() => import("./video-embed-dialog-AeGcMb4X.js").then((e) => ({ default: e.VideoEmbedDialog }))), Mi = y(() => import("./md-import-dialog-Cf3ZOwA_.js").then((e) => ({ default: e.MdImportDialog }))), Ni = () => /* @__PURE__ */ O("div", {
|
|
6742
6752
|
className: "fixed inset-0 z-[9999] flex items-center justify-center",
|
|
6743
6753
|
children: [/* @__PURE__ */ D("div", { className: "absolute inset-0 bg-black/40 backdrop-blur-sm" }), /* @__PURE__ */ D("div", {
|
|
6744
6754
|
className: "relative bg-background rounded-2xl border border-default-200 p-8 flex items-center justify-center",
|
|
6745
6755
|
children: /* @__PURE__ */ D("div", { className: "w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin" })
|
|
6746
6756
|
})]
|
|
6747
|
-
}),
|
|
6748
|
-
let k = r === "view" || i, A = C(() => typeof e == "object" && e ||
|
|
6757
|
+
}), Pi = ({ 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 }) => {
|
|
6758
|
+
let k = r === "view" || i, A = C(() => typeof e == "object" && e || Ei(e) ? e : d(e), [e]), [j, M] = T(!1), [F, I] = T({}), [L, R] = T("below"), [re, ie] = T(50), z = w(null), [B, V] = T(!1), [H, ae] = T(!1), [oe, U] = T(!1), [W, G] = T(!1), [K, q] = T("none"), [se, ce] = T({}), le = w(null), ue = w(null), [de, fe] = T(""), [pe, me] = T(null), [he, ge] = T(m), [_e, ve] = T(!1);
|
|
6749
6759
|
x(() => {
|
|
6750
|
-
|
|
6760
|
+
ge(m);
|
|
6751
6761
|
}, [m]);
|
|
6752
|
-
let [
|
|
6753
|
-
let e =
|
|
6762
|
+
let [ye, be] = T(!1), [xe, Se] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 80rem)").matches : !0), [Ce, we] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 64rem)").matches : !0), Te = w(null), Ee = w(null), De = w(null), Oe = w(0), ke = w(null), Ae = w(null), je = w(null), Me = w(null), [Ne, Pe] = T(!1), [J, Fe] = T(!1), [Ie, Le] = T(!1), Re = w(null), ze = b(() => {
|
|
6763
|
+
let e = Ee.current, t = De.current;
|
|
6754
6764
|
e && (J ? (document.body.style.overflow = "", Object.assign(e.style, {
|
|
6755
6765
|
position: "",
|
|
6756
6766
|
top: "",
|
|
@@ -6767,9 +6777,9 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6767
6777
|
flex: "",
|
|
6768
6778
|
overflow: "",
|
|
6769
6779
|
minHeight: ""
|
|
6770
|
-
}),
|
|
6771
|
-
window.scrollTo(0,
|
|
6772
|
-
})) : (document.fullscreenElement && document.exitFullscreen(),
|
|
6780
|
+
}), Fe(!1), requestAnimationFrame(() => {
|
|
6781
|
+
window.scrollTo(0, Oe.current);
|
|
6782
|
+
})) : (document.fullscreenElement && document.exitFullscreen(), Oe.current = window.scrollY, Object.assign(e.style, {
|
|
6773
6783
|
position: "fixed",
|
|
6774
6784
|
top: "0",
|
|
6775
6785
|
left: "0",
|
|
@@ -6785,42 +6795,42 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6785
6795
|
flex: "1",
|
|
6786
6796
|
overflow: "auto",
|
|
6787
6797
|
minHeight: "0"
|
|
6788
|
-
}), document.body.style.overflow = "hidden",
|
|
6789
|
-
}, [J]),
|
|
6790
|
-
let e =
|
|
6791
|
-
e && (document.fullscreenElement ? document.exitFullscreen() : (J &&
|
|
6792
|
-
}, [J,
|
|
6798
|
+
}), document.body.style.overflow = "hidden", Fe(!0)));
|
|
6799
|
+
}, [J]), Be = b(() => {
|
|
6800
|
+
let e = Ee.current;
|
|
6801
|
+
e && (document.fullscreenElement ? document.exitFullscreen() : (J && ze(), Oe.current = window.scrollY, e.requestFullscreen()));
|
|
6802
|
+
}, [J, ze]);
|
|
6793
6803
|
x(() => {
|
|
6794
6804
|
let e = (e) => {
|
|
6795
|
-
e.key === "Escape" && J &&
|
|
6805
|
+
e.key === "Escape" && J && ze();
|
|
6796
6806
|
}, t = () => {
|
|
6797
|
-
document.fullscreenElement ?
|
|
6798
|
-
window.scrollTo(0,
|
|
6807
|
+
document.fullscreenElement ? Le(!0) : (Le(!1), requestAnimationFrame(() => {
|
|
6808
|
+
window.scrollTo(0, Oe.current);
|
|
6799
6809
|
}));
|
|
6800
6810
|
};
|
|
6801
6811
|
return window.addEventListener("keydown", e), document.addEventListener("fullscreenchange", t), () => {
|
|
6802
6812
|
window.removeEventListener("keydown", e), document.removeEventListener("fullscreenchange", t);
|
|
6803
6813
|
};
|
|
6804
|
-
}, [J,
|
|
6814
|
+
}, [J, ze]), x(() => {
|
|
6805
6815
|
if (!h) return;
|
|
6806
6816
|
let e = (e) => {
|
|
6807
6817
|
if ((e.ctrlKey || e.metaKey) && (e.key === "f" || e.key === "F")) {
|
|
6808
|
-
if (!
|
|
6809
|
-
e.preventDefault(), e.stopPropagation(),
|
|
6818
|
+
if (!Ee.current) return;
|
|
6819
|
+
e.preventDefault(), e.stopPropagation(), be(!0);
|
|
6810
6820
|
}
|
|
6811
6821
|
};
|
|
6812
6822
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
6813
6823
|
}, [h]), x(() => {
|
|
6814
6824
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
6815
|
-
let e = window.matchMedia("(min-width: 80rem)"), t = (e) =>
|
|
6816
|
-
return
|
|
6825
|
+
let e = window.matchMedia("(min-width: 80rem)"), t = (e) => Se(e.matches);
|
|
6826
|
+
return Se(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
6817
6827
|
}, []), x(() => {
|
|
6818
6828
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
6819
|
-
let e = window.matchMedia("(min-width: 64rem)"), t = (e) =>
|
|
6820
|
-
return
|
|
6829
|
+
let e = window.matchMedia("(min-width: 64rem)"), t = (e) => we(e.matches);
|
|
6830
|
+
return we(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
6821
6831
|
}, []);
|
|
6822
|
-
let
|
|
6823
|
-
extensions:
|
|
6832
|
+
let Y = ee({
|
|
6833
|
+
extensions: ui({
|
|
6824
6834
|
placeholder: n || f("editor.placeholder"),
|
|
6825
6835
|
maxLength: a,
|
|
6826
6836
|
maxAttachmentSize: o,
|
|
@@ -6830,7 +6840,7 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6830
6840
|
editable: !k,
|
|
6831
6841
|
immediatelyRender: _,
|
|
6832
6842
|
onUpdate: ({ editor: e }) => {
|
|
6833
|
-
t && (
|
|
6843
|
+
t && (Te.current && clearTimeout(Te.current), Te.current = setTimeout(() => {
|
|
6834
6844
|
t?.(e.getHTML(), e.getJSON());
|
|
6835
6845
|
}, 300));
|
|
6836
6846
|
},
|
|
@@ -6846,9 +6856,9 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6846
6856
|
let r = n.getData("text/plain");
|
|
6847
6857
|
if (!r || !r.includes("[[")) return !1;
|
|
6848
6858
|
t.preventDefault();
|
|
6849
|
-
let i =
|
|
6859
|
+
let i = Ae.current?.storage?.relativeMedia;
|
|
6850
6860
|
i && (i.clipboardFiles = new Map(Array.from(n.files ?? []).map((e) => [e.name.toLowerCase(), e])), i.pausedUntilPaste = !1);
|
|
6851
|
-
let a =
|
|
6861
|
+
let a = Ae.current ? Di(Ae.current, r) : null;
|
|
6852
6862
|
if (a) {
|
|
6853
6863
|
let t = new N(a, 0, 0);
|
|
6854
6864
|
e.dispatch(e.state.tr.replaceSelection(t).scrollIntoView());
|
|
@@ -6858,21 +6868,21 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6858
6868
|
}
|
|
6859
6869
|
});
|
|
6860
6870
|
x(() => {
|
|
6861
|
-
|
|
6862
|
-
}, [
|
|
6863
|
-
if (
|
|
6864
|
-
}, [
|
|
6865
|
-
!
|
|
6866
|
-
}, [
|
|
6867
|
-
if (!
|
|
6871
|
+
Ae.current = Y, window.__editor = Y;
|
|
6872
|
+
}, [Y]), x(() => {
|
|
6873
|
+
if (Y) return () => Zt(Y);
|
|
6874
|
+
}, [Y]), x(() => {
|
|
6875
|
+
!Y || !g || g(Y);
|
|
6876
|
+
}, [Y, g]), x(() => {
|
|
6877
|
+
if (!Y) return;
|
|
6868
6878
|
let e = () => {
|
|
6869
|
-
|
|
6879
|
+
Y.state.selection.empty && (q("none"), Pe(!1));
|
|
6870
6880
|
};
|
|
6871
|
-
return
|
|
6872
|
-
|
|
6881
|
+
return Y.on("selectionUpdate", e), () => {
|
|
6882
|
+
Y.off("selectionUpdate", e);
|
|
6873
6883
|
};
|
|
6874
|
-
}, [
|
|
6875
|
-
|
|
6884
|
+
}, [Y]), x(() => {
|
|
6885
|
+
Y && Y.setOptions({ extensions: ui({
|
|
6876
6886
|
placeholder: n || f("editor.placeholder"),
|
|
6877
6887
|
maxLength: a,
|
|
6878
6888
|
maxAttachmentSize: o,
|
|
@@ -6884,80 +6894,100 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6884
6894
|
o,
|
|
6885
6895
|
s
|
|
6886
6896
|
]);
|
|
6887
|
-
let
|
|
6897
|
+
let Ve = w(e);
|
|
6888
6898
|
x(() => {
|
|
6889
|
-
if (!
|
|
6890
|
-
|
|
6891
|
-
let t = typeof e == "object" && e ||
|
|
6892
|
-
|
|
6893
|
-
}, [
|
|
6894
|
-
|
|
6895
|
-
}, [
|
|
6896
|
-
if (y) return
|
|
6899
|
+
if (!Y || e === Ve.current) return;
|
|
6900
|
+
Ve.current = e;
|
|
6901
|
+
let t = typeof e == "object" && e || Ei(e) ? e : d(e);
|
|
6902
|
+
Y.commands.setContent(t, { emitUpdate: !1 });
|
|
6903
|
+
}, [Y, e]), x(() => {
|
|
6904
|
+
Y && Y.setEditable(!k, !1);
|
|
6905
|
+
}, [Y, k]), x(() => {
|
|
6906
|
+
if (y) return $e(y);
|
|
6897
6907
|
}, [y]), x(() => {
|
|
6898
|
-
if (!
|
|
6899
|
-
let e =
|
|
6900
|
-
e > s && Z(`文档内附件总大小 ${
|
|
6901
|
-
}, [
|
|
6902
|
-
if (!
|
|
6903
|
-
let e =
|
|
6908
|
+
if (!Y) return;
|
|
6909
|
+
let e = ln(Y.state.doc);
|
|
6910
|
+
e > s && Z(`文档内附件总大小 ${un(e)} 已超过限制 ${un(s)}`, "info");
|
|
6911
|
+
}, [Y, s]), x(() => {
|
|
6912
|
+
if (!Y) return;
|
|
6913
|
+
let e = Y.storage.qingwuUI;
|
|
6904
6914
|
e && (e.limits = {
|
|
6905
6915
|
maxAttachmentSize: o,
|
|
6906
6916
|
maxTotalAttachmentSize: s
|
|
6907
6917
|
});
|
|
6908
6918
|
}, [
|
|
6909
|
-
|
|
6919
|
+
Y,
|
|
6910
6920
|
o,
|
|
6911
6921
|
s
|
|
6912
6922
|
]);
|
|
6913
|
-
let
|
|
6914
|
-
let
|
|
6915
|
-
|
|
6923
|
+
let X = b((e, t) => {
|
|
6924
|
+
let n = e ? Math.max(8, Math.min(e.left, window.innerWidth - 240 - 8)) : 8, r;
|
|
6925
|
+
return r = e ? t && e.bottom + 8 + t > window.innerHeight ? Math.max(8, e.top - t - 8) : e.bottom + 8 : 8, {
|
|
6916
6926
|
position: "fixed",
|
|
6917
|
-
top:
|
|
6918
|
-
left:
|
|
6927
|
+
top: r,
|
|
6928
|
+
left: n,
|
|
6919
6929
|
zIndex: 9999
|
|
6920
|
-
}
|
|
6921
|
-
}, []),
|
|
6922
|
-
|
|
6930
|
+
};
|
|
6931
|
+
}, []), He = b((e) => {
|
|
6932
|
+
let t = Me.current?.getBoundingClientRect() ?? null;
|
|
6933
|
+
ue.current = t, q(e), Pe(!1), ce(X(t, void 0));
|
|
6934
|
+
}, [X]);
|
|
6935
|
+
S(() => {
|
|
6936
|
+
if (K === "none") return;
|
|
6937
|
+
let e = le.current;
|
|
6938
|
+
ce(X(ue.current, e?.offsetHeight || void 0));
|
|
6939
|
+
}, [K, X]), x(() => {
|
|
6940
|
+
if (K === "none") return;
|
|
6941
|
+
let e = () => q("none"), t = () => {
|
|
6942
|
+
let e = le.current;
|
|
6943
|
+
ce(X(ue.current, e?.offsetHeight || void 0));
|
|
6944
|
+
};
|
|
6945
|
+
return window.addEventListener("scroll", e, !0), window.addEventListener("resize", t), () => {
|
|
6946
|
+
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", t);
|
|
6947
|
+
};
|
|
6948
|
+
}, [K, X]), x(() => {
|
|
6949
|
+
K === "none" && (ue.current = null);
|
|
6950
|
+
}, [K]);
|
|
6951
|
+
let Ue = mi((e) => f(e)), We = Ue.filter((e) => !e.more), Ge = Ue.filter((e) => e.more), Ke = We.filter((e) => e.key !== "ai"), qe = We.find((e) => e.key === "ai"), Je = b((e) => {
|
|
6952
|
+
if (Y) if (Pe(!1), e.key === "link") if (Y.isActive("link")) Y.chain().focus().unsetLink().run();
|
|
6923
6953
|
else {
|
|
6924
|
-
let e =
|
|
6925
|
-
|
|
6954
|
+
let e = Y.getAttributes("link").href || "";
|
|
6955
|
+
fe(e), He("link");
|
|
6926
6956
|
}
|
|
6927
|
-
else e.key === "highlight" ? K === "highlight" ? q("none") :
|
|
6957
|
+
else e.key === "highlight" ? K === "highlight" ? q("none") : He("highlight") : e.command(Y);
|
|
6928
6958
|
}, [
|
|
6929
|
-
|
|
6959
|
+
Y,
|
|
6930
6960
|
K,
|
|
6931
|
-
|
|
6932
|
-
]),
|
|
6961
|
+
He
|
|
6962
|
+
]), Ye = b((e) => Y ? e.key === "highlight" ? K === "highlight" : e.key === "link" ? Y.isActive("link") : e.isActive(Y) : !1, [Y, K]), [Xe, Ze] = T(0);
|
|
6933
6963
|
x(() => {
|
|
6934
|
-
if (!
|
|
6935
|
-
let e = () =>
|
|
6936
|
-
return
|
|
6937
|
-
|
|
6964
|
+
if (!Y) return;
|
|
6965
|
+
let e = () => Ze((e) => (e + 1) % 1e6);
|
|
6966
|
+
return Y.on("update", e), () => {
|
|
6967
|
+
Y.off("update", e);
|
|
6938
6968
|
};
|
|
6939
|
-
}, [
|
|
6940
|
-
let [
|
|
6969
|
+
}, [Y]);
|
|
6970
|
+
let [Qe, et] = T(!1);
|
|
6941
6971
|
x(() => {
|
|
6942
|
-
if (!
|
|
6972
|
+
if (!Y) return;
|
|
6943
6973
|
let e = () => {
|
|
6944
6974
|
let e = !1;
|
|
6945
|
-
|
|
6975
|
+
Y.state.doc.descendants((t) => {
|
|
6946
6976
|
t.type.name === "heading" && (e = !0);
|
|
6947
|
-
}),
|
|
6977
|
+
}), et(e);
|
|
6948
6978
|
};
|
|
6949
|
-
return e(),
|
|
6950
|
-
|
|
6979
|
+
return e(), Y.on("update", e), () => {
|
|
6980
|
+
Y.off("update", e);
|
|
6951
6981
|
};
|
|
6952
|
-
}, [
|
|
6953
|
-
let
|
|
6982
|
+
}, [Y]);
|
|
6983
|
+
let tt = C(() => Y?.storage?.characterCount?.characters?.() ?? 0, [Y, Xe]), nt = a ? tt > a : !1;
|
|
6954
6984
|
x(() => () => {
|
|
6955
|
-
|
|
6985
|
+
Te.current && clearTimeout(Te.current);
|
|
6956
6986
|
}, []), x(() => () => {
|
|
6957
|
-
|
|
6987
|
+
pe && pe.resolve(null);
|
|
6958
6988
|
}, []);
|
|
6959
|
-
let
|
|
6960
|
-
if (!
|
|
6989
|
+
let rt = b((e) => {
|
|
6990
|
+
if (!Y?.isEditable) return;
|
|
6961
6991
|
let t = window.getSelection(), n;
|
|
6962
6992
|
if (e) {
|
|
6963
6993
|
let t = e.getBoundingClientRect();
|
|
@@ -6974,76 +7004,76 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
6974
7004
|
width: e.width
|
|
6975
7005
|
};
|
|
6976
7006
|
} else {
|
|
6977
|
-
let e =
|
|
7007
|
+
let e = Y.view.coordsAtPos(Y.state.selection.from);
|
|
6978
7008
|
n = {
|
|
6979
7009
|
top: e.bottom,
|
|
6980
7010
|
left: e.left,
|
|
6981
7011
|
width: 0
|
|
6982
7012
|
};
|
|
6983
7013
|
}
|
|
6984
|
-
|
|
6985
|
-
let r =
|
|
7014
|
+
ke.current = n;
|
|
7015
|
+
let r = Ee.current?.getBoundingClientRect(), i = Ti(n, void 0, {
|
|
6986
7016
|
panelWidth: r?.width,
|
|
6987
7017
|
editorLeft: r?.left
|
|
6988
7018
|
});
|
|
6989
7019
|
M(!0), I(i.style), R(i.placement), ie(i.arrowLeft);
|
|
6990
|
-
}, [
|
|
7020
|
+
}, [Y]);
|
|
6991
7021
|
x(() => {
|
|
6992
|
-
if (!
|
|
6993
|
-
let e =
|
|
7022
|
+
if (!Y) return;
|
|
7023
|
+
let e = Y.storage.qingwuUI;
|
|
6994
7024
|
if (e) return e.openImageDialog = () => V(!0), e.openVideoDialog = () => ae(!0), e.chooseMd = (e, t) => {
|
|
6995
|
-
|
|
7025
|
+
me({
|
|
6996
7026
|
filename: e,
|
|
6997
7027
|
resolve: t
|
|
6998
7028
|
});
|
|
6999
|
-
}, e.openAI =
|
|
7029
|
+
}, e.openAI = rt, e.parseMd = (e, t) => Y ? Di(Y, t) : null, () => {
|
|
7000
7030
|
delete e.openImageDialog, delete e.openVideoDialog, delete e.openAI, delete e.parseMd, delete e.chooseMd;
|
|
7001
7031
|
};
|
|
7002
|
-
}, [
|
|
7003
|
-
if (!j || !
|
|
7004
|
-
let e =
|
|
7032
|
+
}, [Y, rt]), S(() => {
|
|
7033
|
+
if (!j || !Y) return;
|
|
7034
|
+
let e = ke.current;
|
|
7005
7035
|
if (!e) return;
|
|
7006
|
-
let t = z.current, n =
|
|
7036
|
+
let t = z.current, n = Ee.current?.getBoundingClientRect(), r = Ti(e, t?.offsetHeight || void 0, {
|
|
7007
7037
|
panelWidth: n?.width,
|
|
7008
7038
|
editorLeft: n?.left
|
|
7009
7039
|
});
|
|
7010
7040
|
R(r.placement), ie(r.arrowLeft), I(r.style);
|
|
7011
|
-
}, [j,
|
|
7012
|
-
if (!j || !
|
|
7041
|
+
}, [j, Y]), x(() => {
|
|
7042
|
+
if (!j || !Y) return;
|
|
7013
7043
|
let e = () => {
|
|
7014
|
-
let e =
|
|
7044
|
+
let e = ke.current;
|
|
7015
7045
|
if (!e) return;
|
|
7016
|
-
let t = z.current, n =
|
|
7046
|
+
let t = z.current, n = Ee.current?.getBoundingClientRect(), r = Ti(e, t?.offsetHeight || void 0, {
|
|
7017
7047
|
panelWidth: n?.width,
|
|
7018
7048
|
editorLeft: n?.left
|
|
7019
7049
|
});
|
|
7020
7050
|
R(r.placement), ie(r.arrowLeft), I(r.style);
|
|
7021
7051
|
};
|
|
7022
7052
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
7023
|
-
}, [j,
|
|
7024
|
-
j || (
|
|
7053
|
+
}, [j, Y]), x(() => {
|
|
7054
|
+
j || (ke.current = null);
|
|
7025
7055
|
}, [j]);
|
|
7026
|
-
let
|
|
7027
|
-
|
|
7028
|
-
}, [
|
|
7029
|
-
(
|
|
7030
|
-
}, [
|
|
7056
|
+
let it = b((e) => {
|
|
7057
|
+
Y?.chain().focus().setImage({ src: e }).run();
|
|
7058
|
+
}, [Y]), at = b((e) => {
|
|
7059
|
+
(Y?.commands).insertVideo?.({ src: e });
|
|
7060
|
+
}, [Y]), ot = he && xe && !J && !Ie, lt = !ot && !_e && (he || Qe && !(!k && Ce)), ut = w(!1);
|
|
7031
7061
|
return x(() => {
|
|
7032
|
-
|
|
7033
|
-
}, [
|
|
7034
|
-
if (!
|
|
7062
|
+
ut.current || (ut.current = !0, he && !ot && ve(!0));
|
|
7063
|
+
}, [he, ot]), x(() => {
|
|
7064
|
+
if (!_e) return;
|
|
7035
7065
|
let e = (e) => {
|
|
7036
7066
|
let t = e.target;
|
|
7037
|
-
|
|
7067
|
+
Re.current?.contains(t) || ve(!1);
|
|
7038
7068
|
}, t = (e) => {
|
|
7039
|
-
e.key === "Escape" &&
|
|
7069
|
+
e.key === "Escape" && ve(!1);
|
|
7040
7070
|
};
|
|
7041
7071
|
return document.addEventListener("mousedown", e), document.addEventListener("touchstart", e, { passive: !0 }), document.addEventListener("keydown", t), () => {
|
|
7042
7072
|
document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e), document.removeEventListener("keydown", t);
|
|
7043
7073
|
};
|
|
7044
|
-
}, [
|
|
7045
|
-
if (!
|
|
7046
|
-
let e =
|
|
7074
|
+
}, [_e]), x(() => {
|
|
7075
|
+
if (!Y || !ot) return;
|
|
7076
|
+
let e = je.current;
|
|
7047
7077
|
if (!(e instanceof HTMLElement)) return;
|
|
7048
7078
|
let t = (t) => {
|
|
7049
7079
|
let n = t.deltaY;
|
|
@@ -7053,17 +7083,17 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7053
7083
|
e.scrollTop += n, t.preventDefault(), t.stopPropagation();
|
|
7054
7084
|
return;
|
|
7055
7085
|
}
|
|
7056
|
-
let a =
|
|
7086
|
+
let a = ct(Y), o = a ? st(a) : null;
|
|
7057
7087
|
if (o) {
|
|
7058
7088
|
o.scrollTop += n, t.preventDefault(), t.stopPropagation();
|
|
7059
7089
|
return;
|
|
7060
7090
|
}
|
|
7061
7091
|
};
|
|
7062
7092
|
return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
|
|
7063
|
-
}, [
|
|
7093
|
+
}, [Y, ot]), Y ? /* @__PURE__ */ O("div", {
|
|
7064
7094
|
className: "qingwu-editor-row",
|
|
7065
7095
|
children: [/* @__PURE__ */ O("div", {
|
|
7066
|
-
ref:
|
|
7096
|
+
ref: Ee,
|
|
7067
7097
|
className: `qingwu-editor relative flex-1 min-w-0 bg-background ${k ? "qingwu-editor--readonly" : ""} ${l ? "" : "rounded-xl border border-default-200"} ${c}`,
|
|
7068
7098
|
style: u,
|
|
7069
7099
|
children: [
|
|
@@ -7074,13 +7104,13 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7074
7104
|
children: [
|
|
7075
7105
|
/* @__PURE__ */ D("button", {
|
|
7076
7106
|
type: "button",
|
|
7077
|
-
className: `qed-tb-btn qed-tb-btn--desktop-only${
|
|
7107
|
+
className: `qed-tb-btn qed-tb-btn--desktop-only${he ? " is-active" : ""}`,
|
|
7078
7108
|
onClick: () => {
|
|
7079
|
-
|
|
7109
|
+
he ? (ge(!1), ve(!1)) : (ge(!0), xe && !J && !Ie || ve(!0));
|
|
7080
7110
|
},
|
|
7081
|
-
title:
|
|
7082
|
-
"aria-label":
|
|
7083
|
-
"aria-pressed":
|
|
7111
|
+
title: he ? "隐藏目录" : "显示目录",
|
|
7112
|
+
"aria-label": he ? "隐藏目录" : "显示目录",
|
|
7113
|
+
"aria-pressed": he,
|
|
7084
7114
|
children: /* @__PURE__ */ D("svg", {
|
|
7085
7115
|
fill: "none",
|
|
7086
7116
|
viewBox: "0 0 24 24",
|
|
@@ -7096,11 +7126,11 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7096
7126
|
}),
|
|
7097
7127
|
h && /* @__PURE__ */ D("button", {
|
|
7098
7128
|
type: "button",
|
|
7099
|
-
className: `qed-tb-btn${
|
|
7100
|
-
onClick: () =>
|
|
7129
|
+
className: `qed-tb-btn${ye ? " is-active" : ""}`,
|
|
7130
|
+
onClick: () => be(!ye),
|
|
7101
7131
|
title: "查找 (Ctrl+F)",
|
|
7102
7132
|
"aria-label": "查找",
|
|
7103
|
-
"aria-pressed":
|
|
7133
|
+
"aria-pressed": ye,
|
|
7104
7134
|
children: /* @__PURE__ */ D("svg", {
|
|
7105
7135
|
fill: "none",
|
|
7106
7136
|
viewBox: "0 0 24 24",
|
|
@@ -7117,7 +7147,7 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7117
7147
|
!k && /* @__PURE__ */ D("button", {
|
|
7118
7148
|
type: "button",
|
|
7119
7149
|
className: `qed-tb-btn qed-tb-btn--ai${j ? " is-active" : ""}`,
|
|
7120
|
-
onClick: (e) => j ? M(!1) :
|
|
7150
|
+
onClick: (e) => j ? M(!1) : rt(e.currentTarget),
|
|
7121
7151
|
title: f("editor.toolbar.aiTitle"),
|
|
7122
7152
|
"aria-label": f("editor.toolbar.ai"),
|
|
7123
7153
|
"aria-pressed": j,
|
|
@@ -7166,7 +7196,7 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7166
7196
|
/* @__PURE__ */ D("button", {
|
|
7167
7197
|
type: "button",
|
|
7168
7198
|
className: `qed-tb-btn${J ? " is-active" : ""}`,
|
|
7169
|
-
onClick:
|
|
7199
|
+
onClick: ze,
|
|
7170
7200
|
title: J ? "退出网页全屏" : "网页全屏",
|
|
7171
7201
|
"aria-label": J ? "退出网页全屏" : "网页全屏",
|
|
7172
7202
|
"aria-pressed": J,
|
|
@@ -7185,11 +7215,11 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7185
7215
|
}),
|
|
7186
7216
|
/* @__PURE__ */ D("button", {
|
|
7187
7217
|
type: "button",
|
|
7188
|
-
className: `qed-tb-btn${
|
|
7189
|
-
onClick:
|
|
7190
|
-
title:
|
|
7191
|
-
"aria-label":
|
|
7192
|
-
"aria-pressed":
|
|
7218
|
+
className: `qed-tb-btn${Ie ? " is-active" : ""}`,
|
|
7219
|
+
onClick: Be,
|
|
7220
|
+
title: Ie ? "退出全屏" : "全屏",
|
|
7221
|
+
"aria-label": Ie ? "退出全屏" : "全屏",
|
|
7222
|
+
"aria-pressed": Ie,
|
|
7193
7223
|
children: /* @__PURE__ */ D("svg", {
|
|
7194
7224
|
fill: "none",
|
|
7195
7225
|
viewBox: "0 0 24 24",
|
|
@@ -7206,8 +7236,8 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7206
7236
|
]
|
|
7207
7237
|
})]
|
|
7208
7238
|
}),
|
|
7209
|
-
|
|
7210
|
-
editor:
|
|
7239
|
+
Y && !k && Y.isEditable && /* @__PURE__ */ D(te, {
|
|
7240
|
+
editor: Y,
|
|
7211
7241
|
shouldShow: ({ editor: e, state: t }) => !(e.isActive("image") || e.isActive("videoEmbed") || e.isActive("codeBlock") || e.isActive("audioEmbed") || e.isActive("attachmentEmbed") || t.selection.empty),
|
|
7212
7242
|
options: {
|
|
7213
7243
|
placement: "bottom",
|
|
@@ -7216,17 +7246,17 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7216
7246
|
},
|
|
7217
7247
|
className: "bubble-menu-pop bg-background border border-default-200 rounded-xl p-1 shadow-lg",
|
|
7218
7248
|
children: /* @__PURE__ */ O("div", {
|
|
7219
|
-
ref:
|
|
7249
|
+
ref: Me,
|
|
7220
7250
|
className: "bubble-menu-items relative flex items-center gap-0.5",
|
|
7221
7251
|
onPointerDown: (e) => {
|
|
7222
7252
|
e.target.closest("button") && e.preventDefault();
|
|
7223
7253
|
},
|
|
7224
7254
|
children: [
|
|
7225
|
-
|
|
7255
|
+
Ke.map((e) => /* @__PURE__ */ D("button", {
|
|
7226
7256
|
type: "button",
|
|
7227
|
-
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${e.isActive(
|
|
7257
|
+
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"}`,
|
|
7228
7258
|
onClick: (t) => {
|
|
7229
|
-
t.preventDefault(),
|
|
7259
|
+
t.preventDefault(), Je(e);
|
|
7230
7260
|
},
|
|
7231
7261
|
title: e.label,
|
|
7232
7262
|
"aria-label": e.label,
|
|
@@ -7240,11 +7270,11 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7240
7270
|
type: "button",
|
|
7241
7271
|
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"}`,
|
|
7242
7272
|
onClick: (e) => {
|
|
7243
|
-
e.preventDefault(),
|
|
7273
|
+
e.preventDefault(), Pe(!1), qe?.command(Y);
|
|
7244
7274
|
},
|
|
7245
|
-
title:
|
|
7246
|
-
"aria-label":
|
|
7247
|
-
children: /* @__PURE__ */ D(
|
|
7275
|
+
title: qe?.label,
|
|
7276
|
+
"aria-label": qe?.label,
|
|
7277
|
+
children: /* @__PURE__ */ D(Vt, {})
|
|
7248
7278
|
}),
|
|
7249
7279
|
/* @__PURE__ */ D("span", {
|
|
7250
7280
|
className: "w-px h-4 bg-default-200 mx-0.5 shrink-0",
|
|
@@ -7252,27 +7282,27 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7252
7282
|
}),
|
|
7253
7283
|
/* @__PURE__ */ D("button", {
|
|
7254
7284
|
type: "button",
|
|
7255
|
-
"aria-expanded":
|
|
7256
|
-
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${
|
|
7285
|
+
"aria-expanded": Ne,
|
|
7286
|
+
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${Ne ? "bg-default-100 text-default-900" : "text-default-600 hover:bg-default-100"}`,
|
|
7257
7287
|
onClick: (e) => {
|
|
7258
|
-
e.preventDefault(),
|
|
7288
|
+
e.preventDefault(), Pe((e) => !e);
|
|
7259
7289
|
},
|
|
7260
7290
|
title: f("editor.bubble.more"),
|
|
7261
7291
|
"aria-label": f("editor.bubble.more"),
|
|
7262
|
-
children: /* @__PURE__ */ D(
|
|
7292
|
+
children: /* @__PURE__ */ D(Ht, {})
|
|
7263
7293
|
}),
|
|
7264
|
-
|
|
7294
|
+
Ne && /* @__PURE__ */ D("div", {
|
|
7265
7295
|
role: "menu",
|
|
7266
7296
|
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",
|
|
7267
7297
|
onPointerDown: (e) => {
|
|
7268
7298
|
e.target.closest("button") && e.preventDefault();
|
|
7269
7299
|
},
|
|
7270
|
-
children:
|
|
7300
|
+
children: Ge.map((e) => /* @__PURE__ */ O("button", {
|
|
7271
7301
|
type: "button",
|
|
7272
7302
|
role: "menuitem",
|
|
7273
|
-
className: `flex items-center gap-2 w-full whitespace-nowrap px-3 py-1.5 text-xs rounded-md transition-colors ${
|
|
7303
|
+
className: `flex items-center gap-2 w-full whitespace-nowrap px-3 py-1.5 text-xs rounded-md transition-colors ${Ye(e) ? "bg-primary/10 text-primary" : "text-default-600 hover:bg-default-100"}`,
|
|
7274
7304
|
onClick: (t) => {
|
|
7275
|
-
t.preventDefault(),
|
|
7305
|
+
t.preventDefault(), Je(e);
|
|
7276
7306
|
},
|
|
7277
7307
|
title: e.label,
|
|
7278
7308
|
children: [/* @__PURE__ */ D("span", {
|
|
@@ -7287,29 +7317,30 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7287
7317
|
]
|
|
7288
7318
|
})
|
|
7289
7319
|
}),
|
|
7290
|
-
|
|
7320
|
+
Y && K !== "none" && ne(/* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
7291
7321
|
className: "fixed inset-0 z-[9998]",
|
|
7292
7322
|
onClick: () => q("none")
|
|
7293
7323
|
}), /* @__PURE__ */ D("div", {
|
|
7324
|
+
ref: le,
|
|
7294
7325
|
style: se,
|
|
7295
7326
|
className: "bg-background border border-default-200 rounded-xl shadow-xl",
|
|
7296
7327
|
onClick: (e) => e.stopPropagation(),
|
|
7297
7328
|
children: K === "highlight" ? /* @__PURE__ */ O("div", {
|
|
7298
7329
|
className: "flex items-center gap-1 p-1.5 flex-wrap",
|
|
7299
|
-
children: [
|
|
7330
|
+
children: [xi.map((e) => /* @__PURE__ */ D("button", {
|
|
7300
7331
|
type: "button",
|
|
7301
7332
|
className: "w-5 h-5 rounded-full border border-default-200 hover:scale-110 transition-transform",
|
|
7302
7333
|
style: { background: e.color },
|
|
7303
7334
|
title: e.name,
|
|
7304
7335
|
onClick: () => {
|
|
7305
|
-
|
|
7336
|
+
Y.chain().focus().setHighlight({ color: e.color }).run(), q("none");
|
|
7306
7337
|
}
|
|
7307
7338
|
}, e.color)), /* @__PURE__ */ O("button", {
|
|
7308
7339
|
type: "button",
|
|
7309
7340
|
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]",
|
|
7310
7341
|
title: "清除高亮",
|
|
7311
7342
|
onClick: () => {
|
|
7312
|
-
|
|
7343
|
+
Y.chain().focus().unsetHighlight().run(), q("none");
|
|
7313
7344
|
},
|
|
7314
7345
|
children: ["✕", " "]
|
|
7315
7346
|
})]
|
|
@@ -7319,21 +7350,21 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7319
7350
|
type: "url",
|
|
7320
7351
|
className: "flex-1 px-2 py-1 text-xs rounded-md border border-default-200 bg-background focus:outline-none focus:border-primary",
|
|
7321
7352
|
placeholder: "https://...",
|
|
7322
|
-
value:
|
|
7323
|
-
onChange: (e) =>
|
|
7353
|
+
value: de,
|
|
7354
|
+
onChange: (e) => fe(e.target.value),
|
|
7324
7355
|
onKeyDown: (e) => {
|
|
7325
|
-
e.key === "Enter" ? (
|
|
7356
|
+
e.key === "Enter" ? (de.trim() && Y.chain().focus().setLink({ href: de.trim() }).run(), q("none")) : e.key === "Escape" && q("none");
|
|
7326
7357
|
}
|
|
7327
7358
|
}), /* @__PURE__ */ D("button", {
|
|
7328
7359
|
type: "button",
|
|
7329
7360
|
className: "px-2 py-1 text-xs rounded-md bg-primary text-white hover:opacity-90",
|
|
7330
7361
|
onClick: () => {
|
|
7331
|
-
|
|
7362
|
+
de.trim() && Y.chain().focus().setLink({ href: de.trim() }).run(), q("none");
|
|
7332
7363
|
},
|
|
7333
7364
|
children: "确定"
|
|
7334
7365
|
})]
|
|
7335
7366
|
})
|
|
7336
|
-
})] }),
|
|
7367
|
+
})] }), document.body),
|
|
7337
7368
|
!k && j && ne(/* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
7338
7369
|
className: "fixed inset-0 z-[9998]",
|
|
7339
7370
|
onClick: () => M(!1)
|
|
@@ -7347,76 +7378,76 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7347
7378
|
className: "ai-panel__arrow",
|
|
7348
7379
|
style: { left: `${re}%` },
|
|
7349
7380
|
"aria-hidden": "true"
|
|
7350
|
-
}), /* @__PURE__ */ D(
|
|
7351
|
-
editor:
|
|
7381
|
+
}), /* @__PURE__ */ D(sn, {
|
|
7382
|
+
editor: Y,
|
|
7352
7383
|
onClose: () => M(!1)
|
|
7353
7384
|
})]
|
|
7354
7385
|
})] }), document.body),
|
|
7355
7386
|
B && /* @__PURE__ */ D(v, {
|
|
7356
|
-
fallback: /* @__PURE__ */ D(
|
|
7357
|
-
children: /* @__PURE__ */ D(
|
|
7387
|
+
fallback: /* @__PURE__ */ D(Ni, {}),
|
|
7388
|
+
children: /* @__PURE__ */ D(Oi, {
|
|
7358
7389
|
open: B,
|
|
7359
7390
|
onClose: () => V(!1),
|
|
7360
|
-
onInsert:
|
|
7361
|
-
validate: (e) =>
|
|
7391
|
+
onInsert: it,
|
|
7392
|
+
validate: (e) => Y ? fn(Y.state.doc, e, {
|
|
7362
7393
|
maxAttachmentSize: o,
|
|
7363
7394
|
maxTotalAttachmentSize: s
|
|
7364
7395
|
}) : null
|
|
7365
7396
|
})
|
|
7366
7397
|
}),
|
|
7367
7398
|
H && /* @__PURE__ */ D(v, {
|
|
7368
|
-
fallback: /* @__PURE__ */ D(
|
|
7369
|
-
children: /* @__PURE__ */ D(
|
|
7399
|
+
fallback: /* @__PURE__ */ D(Ni, {}),
|
|
7400
|
+
children: /* @__PURE__ */ D(ji, {
|
|
7370
7401
|
open: H,
|
|
7371
7402
|
onClose: () => ae(!1),
|
|
7372
|
-
onInsert:
|
|
7403
|
+
onInsert: at
|
|
7373
7404
|
})
|
|
7374
7405
|
}),
|
|
7375
7406
|
oe && /* @__PURE__ */ D(v, {
|
|
7376
|
-
fallback: /* @__PURE__ */ D(
|
|
7377
|
-
children: /* @__PURE__ */ D(
|
|
7407
|
+
fallback: /* @__PURE__ */ D(Ni, {}),
|
|
7408
|
+
children: /* @__PURE__ */ D(ki, {
|
|
7378
7409
|
open: oe,
|
|
7379
7410
|
onClose: () => U(!1)
|
|
7380
7411
|
})
|
|
7381
7412
|
}),
|
|
7382
7413
|
W && /* @__PURE__ */ D(v, {
|
|
7383
|
-
fallback: /* @__PURE__ */ D(
|
|
7384
|
-
children: /* @__PURE__ */ D(
|
|
7414
|
+
fallback: /* @__PURE__ */ D(Ni, {}),
|
|
7415
|
+
children: /* @__PURE__ */ D(Ai, {
|
|
7385
7416
|
open: W,
|
|
7386
7417
|
onClose: () => G(!1),
|
|
7387
|
-
editor:
|
|
7418
|
+
editor: Y
|
|
7388
7419
|
})
|
|
7389
7420
|
}),
|
|
7390
|
-
|
|
7391
|
-
fallback: /* @__PURE__ */ D(
|
|
7392
|
-
children: /* @__PURE__ */ D(
|
|
7393
|
-
open: !!
|
|
7394
|
-
filename:
|
|
7421
|
+
pe && /* @__PURE__ */ D(v, {
|
|
7422
|
+
fallback: /* @__PURE__ */ D(Ni, {}),
|
|
7423
|
+
children: /* @__PURE__ */ D(Mi, {
|
|
7424
|
+
open: !!pe,
|
|
7425
|
+
filename: pe.filename,
|
|
7395
7426
|
onRender: () => {
|
|
7396
|
-
|
|
7427
|
+
pe.resolve("render"), me(null);
|
|
7397
7428
|
},
|
|
7398
7429
|
onAttach: () => {
|
|
7399
|
-
|
|
7430
|
+
pe.resolve("attach"), me(null);
|
|
7400
7431
|
},
|
|
7401
7432
|
onClose: () => {
|
|
7402
|
-
|
|
7433
|
+
pe.resolve(null), me(null);
|
|
7403
7434
|
}
|
|
7404
7435
|
})
|
|
7405
7436
|
}),
|
|
7406
7437
|
/* @__PURE__ */ D("div", {
|
|
7407
|
-
ref:
|
|
7438
|
+
ref: De,
|
|
7408
7439
|
className: "flex editor-body",
|
|
7409
7440
|
children: /* @__PURE__ */ O("div", {
|
|
7410
7441
|
className: "relative min-w-0 flex-1",
|
|
7411
7442
|
children: [
|
|
7412
|
-
/* @__PURE__ */ D(P, { editor:
|
|
7413
|
-
!k && /* @__PURE__ */ D(
|
|
7443
|
+
/* @__PURE__ */ D(P, { editor: Y }),
|
|
7444
|
+
!k && /* @__PURE__ */ D(bi, { editor: Y }),
|
|
7414
7445
|
/* @__PURE__ */ D("div", {
|
|
7415
|
-
className: `${J ||
|
|
7446
|
+
className: `${J || Ie ? "fixed" : "absolute"} bottom-2 right-4 z-10 pointer-events-none select-none`,
|
|
7416
7447
|
children: /* @__PURE__ */ O("span", {
|
|
7417
|
-
className: `text-xs ${
|
|
7448
|
+
className: `text-xs ${nt ? "bg-danger/10 text-danger font-medium px-2 py-0.5 rounded" : a && tt > a * .9 ? "bg-warning/10 text-warning px-2 py-0.5 rounded" : "text-default-300"}`,
|
|
7418
7449
|
children: [
|
|
7419
|
-
|
|
7450
|
+
tt,
|
|
7420
7451
|
a ? ` / ${a}` : "",
|
|
7421
7452
|
" 字"
|
|
7422
7453
|
]
|
|
@@ -7425,14 +7456,14 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7425
7456
|
]
|
|
7426
7457
|
})
|
|
7427
7458
|
}),
|
|
7428
|
-
h &&
|
|
7429
|
-
editor:
|
|
7430
|
-
onClose: () =>
|
|
7459
|
+
h && ye && /* @__PURE__ */ D(At, {
|
|
7460
|
+
editor: Y,
|
|
7461
|
+
onClose: () => be(!1)
|
|
7431
7462
|
}),
|
|
7432
|
-
|
|
7463
|
+
lt && /* @__PURE__ */ D("button", {
|
|
7433
7464
|
type: "button",
|
|
7434
7465
|
className: "qingwu-toc-fab",
|
|
7435
|
-
onClick: () =>
|
|
7466
|
+
onClick: () => ve(!0),
|
|
7436
7467
|
title: "目录",
|
|
7437
7468
|
"aria-label": "打开目录",
|
|
7438
7469
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -7448,8 +7479,8 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7448
7479
|
})
|
|
7449
7480
|
})
|
|
7450
7481
|
}),
|
|
7451
|
-
|
|
7452
|
-
ref:
|
|
7482
|
+
_e && ne(/* @__PURE__ */ O("div", {
|
|
7483
|
+
ref: Re,
|
|
7453
7484
|
className: "qingwu-toc-drawer toc-scroll",
|
|
7454
7485
|
"data-lenis-prevent": !0,
|
|
7455
7486
|
children: [/* @__PURE__ */ O("div", {
|
|
@@ -7460,7 +7491,7 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7460
7491
|
}), /* @__PURE__ */ D("button", {
|
|
7461
7492
|
type: "button",
|
|
7462
7493
|
className: "qed-drawer-head__close",
|
|
7463
|
-
onClick: () =>
|
|
7494
|
+
onClick: () => ve(!1),
|
|
7464
7495
|
"aria-label": "关闭目录",
|
|
7465
7496
|
children: /* @__PURE__ */ D("svg", {
|
|
7466
7497
|
fill: "none",
|
|
@@ -7475,21 +7506,21 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7475
7506
|
})
|
|
7476
7507
|
})
|
|
7477
7508
|
})]
|
|
7478
|
-
}), /* @__PURE__ */ D(
|
|
7479
|
-
editor:
|
|
7509
|
+
}), /* @__PURE__ */ D(ft, {
|
|
7510
|
+
editor: Y,
|
|
7480
7511
|
className: "!p-3",
|
|
7481
7512
|
onClose: () => {
|
|
7482
|
-
|
|
7513
|
+
ve(!1), ge(!1);
|
|
7483
7514
|
}
|
|
7484
7515
|
})]
|
|
7485
7516
|
}), document.body)
|
|
7486
7517
|
]
|
|
7487
|
-
}),
|
|
7488
|
-
ref:
|
|
7518
|
+
}), ot && ne(/* @__PURE__ */ D("aside", {
|
|
7519
|
+
ref: je,
|
|
7489
7520
|
className: "qingwu-toc-desktop toc-scroll",
|
|
7490
|
-
children: /* @__PURE__ */ D(
|
|
7491
|
-
editor:
|
|
7492
|
-
onClose: () =>
|
|
7521
|
+
children: /* @__PURE__ */ D(ft, {
|
|
7522
|
+
editor: Y,
|
|
7523
|
+
onClose: () => ge(!1)
|
|
7493
7524
|
})
|
|
7494
7525
|
}), document.body)]
|
|
7495
7526
|
}) : /* @__PURE__ */ D("div", {
|
|
@@ -7499,7 +7530,7 @@ var Ei = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
|
|
|
7499
7530
|
};
|
|
7500
7531
|
//#endregion
|
|
7501
7532
|
//#region src/editor/clipper/receiver-browser.ts
|
|
7502
|
-
function
|
|
7533
|
+
function Fi(e) {
|
|
7503
7534
|
let t = async (t) => {
|
|
7504
7535
|
let n = t.data;
|
|
7505
7536
|
if (!n || typeof n != "object" || n.kind !== "qingwu-clip") return;
|
|
@@ -7516,7 +7547,7 @@ function Ni(e) {
|
|
|
7516
7547
|
}
|
|
7517
7548
|
//#endregion
|
|
7518
7549
|
//#region src/editor/storage/providers/cos.ts
|
|
7519
|
-
function
|
|
7550
|
+
function Ii(e) {
|
|
7520
7551
|
return g({
|
|
7521
7552
|
endpoint: `https://cos.${e.region}.myqcloud.com`,
|
|
7522
7553
|
bucket: e.bucket,
|
|
@@ -7530,7 +7561,7 @@ function Pi(e) {
|
|
|
7530
7561
|
}
|
|
7531
7562
|
//#endregion
|
|
7532
7563
|
//#region src/editor/storage/providers/oss.ts
|
|
7533
|
-
function
|
|
7564
|
+
function Li(e) {
|
|
7534
7565
|
return g({
|
|
7535
7566
|
endpoint: `https://${e.bucket}.${e.region}.aliyuncs.com`,
|
|
7536
7567
|
bucket: e.bucket,
|
|
@@ -7543,4 +7574,4 @@ function Fi(e) {
|
|
|
7543
7574
|
});
|
|
7544
7575
|
}
|
|
7545
7576
|
//#endregion
|
|
7546
|
-
export {
|
|
7577
|
+
export { tr as CODE_LANGUAGES, sr as CodeBlock, jr as ImageUpload, tt as ImageUploadDialog, Pi as QingWuAIEditor, ai as RelativeMedia, Ot as SearchHighlight, ft as TocPanel, Jn as VideoEmbed, pt as buildSystemPrompt, ht as createAILanguageModelProvider, Ii as createCOSStorage, yt as createDeepSeekProvider, _ as createLocalStorage, Li as createOSSStorage, vt as createOpenAICompatProvider, bt as createOpenAIProvider, xt as createQwenProvider, g as createS3Storage, si as createSlashCommandExtension, h as escapeHtml, un as formatBytes, _t as getAIProvider, mi as getBubbleMenuActions, ci as getDefaultSlashCommands, ln as getDocAttachmentTotal, ui as getEditorExtensions, u as getLocale, pi as getSearchEngine, kt as getSearchState, c as getStorageInfo, o as getStorageProvider, s as loadStorageConfig, r as registerS3PreviewConfig, d as sanitizeHtml, p as sanitizeSvg, gt as setAIProvider, vn as setConfirmProvider, l as setLocale, fi as setSearchEngine, i as setStorageProvider, Qe as setToastProvider, n as signPreviewUrlHeaders, Fi as startBrowserClipperReceiver, $e as subscribeToast, f as t, m as tf, Z as toast, fn as validateAttachmentFile };
|