@qingwu-ui/ai-editor 0.9.0-beta.12 → 0.9.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -5,60 +5,60 @@ import { n as g, t as _ } from "./local-B20eAPCo.js";
|
|
|
5
5
|
import { Suspense as v, lazy as y, useCallback as b, useEffect as x, useLayoutEffect as S, useMemo as C, useRef as w, useState as T } from "react";
|
|
6
6
|
import { Fragment as E, jsx as D, jsxs as O } from "react/jsx-runtime";
|
|
7
7
|
import { generateText as k, streamText as A } from "ai";
|
|
8
|
-
import { DOMParser as j,
|
|
9
|
-
import { EditorContent as
|
|
10
|
-
import { BubbleMenu as
|
|
11
|
-
import { createPortal as
|
|
12
|
-
import { Extension as
|
|
13
|
-
import { NodeSelection as
|
|
14
|
-
import { Decoration as
|
|
15
|
-
import { Image as
|
|
16
|
-
import { Link as
|
|
8
|
+
import { DOMParser as j, Fragment as M, Slice as N } from "@tiptap/pm/model";
|
|
9
|
+
import { EditorContent as ee, NodeViewContent as te, NodeViewWrapper as ne, ReactNodeViewRenderer as P, useEditor as re } from "@tiptap/react";
|
|
10
|
+
import { BubbleMenu as ie } from "@tiptap/react/menus";
|
|
11
|
+
import { createPortal as ae } from "react-dom";
|
|
12
|
+
import { Extension as F, Node as oe } from "@tiptap/core";
|
|
13
|
+
import { NodeSelection as I, Plugin as L, PluginKey as R, TextSelection as se } from "@tiptap/pm/state";
|
|
14
|
+
import { Decoration as ce, DecorationSet as le } from "@tiptap/pm/view";
|
|
15
|
+
import { Image as ue } from "@tiptap/extension-image";
|
|
16
|
+
import { Link as z } from "@tiptap/extension-link";
|
|
17
17
|
import { Underline as B } from "@tiptap/extension-underline";
|
|
18
|
-
import
|
|
19
|
-
import { CharacterCount as
|
|
18
|
+
import de from "@tiptap/starter-kit";
|
|
19
|
+
import { CharacterCount as V } from "@tiptap/extension-character-count";
|
|
20
20
|
import { Color as H } from "@tiptap/extension-color";
|
|
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
|
|
21
|
+
import { Highlight as fe } from "@tiptap/extension-highlight";
|
|
22
|
+
import { HorizontalRule as pe } from "@tiptap/extension-horizontal-rule";
|
|
23
|
+
import { Placeholder as U } from "@tiptap/extension-placeholder";
|
|
24
|
+
import { Table as me } from "@tiptap/extension-table";
|
|
25
|
+
import { TableCell as W } from "@tiptap/extension-table-cell";
|
|
26
|
+
import { TableHeader as he } from "@tiptap/extension-table-header";
|
|
27
|
+
import { TableRow as G } from "@tiptap/extension-table-row";
|
|
28
|
+
import { TaskItem as ge } from "@tiptap/extension-task-item";
|
|
29
|
+
import { TaskList as _e } from "@tiptap/extension-task-list";
|
|
30
|
+
import { TextStyle as ve } from "@tiptap/extension-text-style";
|
|
31
|
+
import { Markdown as ye } from "tiptap-markdown";
|
|
32
|
+
import { CodeBlockLowlight as be } from "@tiptap/extension-code-block-lowlight";
|
|
33
|
+
import xe from "highlight.js/lib/languages/dockerfile";
|
|
34
|
+
import { common as Se, createLowlight as Ce } from "lowlight";
|
|
35
|
+
import 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 K(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 Me(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 Pe(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 q(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 Fe(e, t, n = "16px system-ui") {
|
|
92
|
+
let { maxWidth: r, lineHeight: i, maxLines: a, overflowWrap: o = "break-word" } = t, s = K(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(q(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(q(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Pe(s, l.lineStart, e + 1)) : (c.push(q(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(q(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(q(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Pe(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(q(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Pe(s, l.lineStart, e + 1), l.lastBreakIdx = -1) : o === "break-word" ? (c.push(q(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 = Pe(s, l.lineStart, s.length);
|
|
122
|
+
c.push(q(s, l.lineStart, s.length, e));
|
|
123
123
|
}
|
|
124
124
|
return {
|
|
125
125
|
lines: c,
|
|
@@ -130,26 +130,26 @@ 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 Ie = typeof window < "u" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, Le = "13.5px -apple-system, BlinkMacSystemFont, \"SF Pro Text\", \"PingFang SC\", \"Microsoft YaHei\", system-ui, sans-serif";
|
|
134
|
+
function J() {
|
|
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 Re = {
|
|
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
|
+
}, ze = 1;
|
|
145
|
+
function Be() {
|
|
146
|
+
return `qt${ze++}${Date.now().toString(36)}`;
|
|
147
147
|
}
|
|
148
148
|
function Y(e, t, n) {
|
|
149
149
|
let r = document.createElement(e);
|
|
150
150
|
return t && (r.className = t), n != null && (r.innerHTML = n), r;
|
|
151
151
|
}
|
|
152
|
-
function
|
|
152
|
+
function Ve(e, t) {
|
|
153
153
|
let n = t.split(/\*\*(.+?)\*\*/g);
|
|
154
154
|
for (let t = 0; t < n.length; t++) {
|
|
155
155
|
let r = n[t];
|
|
@@ -159,7 +159,7 @@ function Be(e, t) {
|
|
|
159
159
|
} else e.appendChild(document.createTextNode(r));
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
var
|
|
162
|
+
var He = {
|
|
163
163
|
type: "info",
|
|
164
164
|
position: "top-center",
|
|
165
165
|
duration: 4e3,
|
|
@@ -168,19 +168,19 @@ var Ve = {
|
|
|
168
168
|
persistMaxVisible: 3,
|
|
169
169
|
maxLines: void 0,
|
|
170
170
|
vibrate: !0
|
|
171
|
-
},
|
|
171
|
+
}, Ue = [
|
|
172
172
|
80,
|
|
173
173
|
40,
|
|
174
174
|
80
|
|
175
175
|
];
|
|
176
|
-
function
|
|
176
|
+
function We() {
|
|
177
177
|
if (!(typeof navigator > "u" || !("vibrate" in navigator))) try {
|
|
178
|
-
navigator.vibrate(
|
|
178
|
+
navigator.vibrate(Ue);
|
|
179
179
|
} catch {}
|
|
180
180
|
}
|
|
181
|
-
var
|
|
181
|
+
var Ge = class {
|
|
182
182
|
containers = /* @__PURE__ */ new Map();
|
|
183
|
-
opts = { ...
|
|
183
|
+
opts = { ...He };
|
|
184
184
|
toasts = /* @__PURE__ */ new Map();
|
|
185
185
|
queue = [];
|
|
186
186
|
_seq = 0;
|
|
@@ -192,7 +192,7 @@ var We = class {
|
|
|
192
192
|
return t || (t = Y("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 = Be(), u = {
|
|
196
196
|
id: l,
|
|
197
197
|
type: n,
|
|
198
198
|
dismissible: a,
|
|
@@ -278,15 +278,15 @@ var We = class {
|
|
|
278
278
|
let s = Y("div", `qt-toast qt-${n}${i == null ? "" : " qt-truncate"}${a || o ? " qt-rich" : ""}`);
|
|
279
279
|
s.setAttribute("data-qt-id", e);
|
|
280
280
|
let c = Y("span", "qt-icon");
|
|
281
|
-
c.innerHTML =
|
|
282
|
-
let l = Y("div", "qt-body"), u = Y("span", "qt-msg"), d =
|
|
283
|
-
maxWidth:
|
|
281
|
+
c.innerHTML = Re[n], s.appendChild(c);
|
|
282
|
+
let l = Y("div", "qt-body"), u = Y("span", "qt-msg"), d = Fe(t, {
|
|
283
|
+
maxWidth: J(),
|
|
284
284
|
lineHeight: 1,
|
|
285
285
|
maxLines: i
|
|
286
|
-
},
|
|
287
|
-
if (d.lineCount <= 1 ?
|
|
286
|
+
}, Le);
|
|
287
|
+
if (d.lineCount <= 1 ? Ve(u, t) : d.lines.forEach((e, t) => {
|
|
288
288
|
let n = Y("span", "qt-line"), r = e.text;
|
|
289
|
-
t === d.lines.length - 1 && d.truncated && !r.endsWith("…") && (r += "…"),
|
|
289
|
+
t === d.lines.length - 1 && d.truncated && !r.endsWith("…") && (r += "…"), Ve(n, r), u.appendChild(n);
|
|
290
290
|
}), l.appendChild(u), a) {
|
|
291
291
|
let e = Y("div", "qt-desc");
|
|
292
292
|
e.textContent = a, l.appendChild(e);
|
|
@@ -310,7 +310,7 @@ var We = class {
|
|
|
310
310
|
mount(e) {
|
|
311
311
|
e.duration === 0 && this.evictPersistIfNeeded(e);
|
|
312
312
|
let t = this.ensureContainer(e.position);
|
|
313
|
-
this.toasts.set(e.id, e), t.appendChild(e.element), e.type === "error" && this.opts.vibrate &&
|
|
313
|
+
this.toasts.set(e.id, e), t.appendChild(e.element), e.type === "error" && this.opts.vibrate && We(), requestAnimationFrame(() => {
|
|
314
314
|
requestAnimationFrame(() => {
|
|
315
315
|
e.element.classList.add("qt-enter");
|
|
316
316
|
});
|
|
@@ -332,7 +332,7 @@ var We = class {
|
|
|
332
332
|
let t = () => {
|
|
333
333
|
e.element.remove(), this.toasts.delete(e.id), this._dequeue();
|
|
334
334
|
};
|
|
335
|
-
if (
|
|
335
|
+
if (Ie) t();
|
|
336
336
|
else {
|
|
337
337
|
let n = !1, r = () => {
|
|
338
338
|
n || (n = !0, t());
|
|
@@ -345,46 +345,46 @@ var We = class {
|
|
|
345
345
|
let e = this.queue.shift();
|
|
346
346
|
this.mount(e);
|
|
347
347
|
}
|
|
348
|
-
},
|
|
349
|
-
function
|
|
350
|
-
return
|
|
351
|
-
}
|
|
352
|
-
var
|
|
353
|
-
info: (e, t) =>
|
|
354
|
-
success: (e, t) =>
|
|
355
|
-
warn: (e, t) =>
|
|
356
|
-
error: (e, t) =>
|
|
357
|
-
promise: (e, t, n) =>
|
|
358
|
-
dismiss: (e) =>
|
|
359
|
-
dismissAll: () =>
|
|
360
|
-
configure: (e) =>
|
|
361
|
-
}),
|
|
362
|
-
function
|
|
363
|
-
|
|
348
|
+
}, Ke = null;
|
|
349
|
+
function qe() {
|
|
350
|
+
return Ke ||= new Ge(), Ke;
|
|
351
|
+
}
|
|
352
|
+
var Je = Object.assign((e, t) => qe().show(e, t), {
|
|
353
|
+
info: (e, t) => qe().info(e, t),
|
|
354
|
+
success: (e, t) => qe().success(e, t),
|
|
355
|
+
warn: (e, t) => qe().warn(e, t),
|
|
356
|
+
error: (e, t) => qe().error(e, t),
|
|
357
|
+
promise: (e, t, n) => qe().promise(e, t, n),
|
|
358
|
+
dismiss: (e) => qe().dismiss(e),
|
|
359
|
+
dismissAll: () => qe().dismissAll(),
|
|
360
|
+
configure: (e) => qe().configure(e)
|
|
361
|
+
}), Ye = /* @__PURE__ */ new Set(), Xe = null;
|
|
362
|
+
function Ze(e) {
|
|
363
|
+
Xe = e;
|
|
364
364
|
}
|
|
365
365
|
function X(e, t = "error", n) {
|
|
366
366
|
let r = {
|
|
367
367
|
persist: !0,
|
|
368
368
|
...n
|
|
369
369
|
};
|
|
370
|
-
if (
|
|
371
|
-
for (let n of
|
|
370
|
+
if (Ye.size > 0) {
|
|
371
|
+
for (let n of Ye) n(e, t, r);
|
|
372
372
|
return;
|
|
373
373
|
}
|
|
374
|
-
if (
|
|
375
|
-
|
|
374
|
+
if (Xe) {
|
|
375
|
+
Xe(e, t, r);
|
|
376
376
|
return;
|
|
377
377
|
}
|
|
378
|
-
t === "success" ?
|
|
378
|
+
t === "success" ? Je.success(e, r) : t === "info" ? Je.info(e, r) : Je.error(e, r);
|
|
379
379
|
}
|
|
380
|
-
function
|
|
381
|
-
return
|
|
382
|
-
|
|
380
|
+
function Qe(e) {
|
|
381
|
+
return Ye.add(e), () => {
|
|
382
|
+
Ye.delete(e);
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
385
|
//#endregion
|
|
386
386
|
//#region src/components/image-upload-dialog.tsx
|
|
387
|
-
var
|
|
387
|
+
var $e = /* @__PURE__ */ e({ ImageUploadDialog: () => et }), et = ({ open: e, onClose: t, onInsert: n, validate: r }) => {
|
|
388
388
|
let [i, a] = T("upload"), [s, c] = T(!1), [l, u] = T(!1), [d, f] = T(null), [p, m] = T(null), [h, g] = T(""), [_, v] = T(null), y = w(null), x = (() => {
|
|
389
389
|
try {
|
|
390
390
|
let e = o();
|
|
@@ -676,10 +676,10 @@ var Qe = /* @__PURE__ */ e({ ImageUploadDialog: () => $e }), $e = ({ open: e, on
|
|
|
676
676
|
};
|
|
677
677
|
//#endregion
|
|
678
678
|
//#region src/components/toc.tsx
|
|
679
|
-
function
|
|
679
|
+
function tt(e, t) {
|
|
680
680
|
return `${e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu, "").replace(/\s+/g, "-").slice(0, 40) || "heading"}-${t}`;
|
|
681
681
|
}
|
|
682
|
-
function
|
|
682
|
+
function nt(e) {
|
|
683
683
|
let t = [], n = [];
|
|
684
684
|
for (let r of e) {
|
|
685
685
|
let e = {
|
|
@@ -691,18 +691,18 @@ function tt(e) {
|
|
|
691
691
|
}
|
|
692
692
|
return t;
|
|
693
693
|
}
|
|
694
|
-
function
|
|
694
|
+
function rt(e) {
|
|
695
695
|
let t = /* @__PURE__ */ new Set(), n = (e) => {
|
|
696
696
|
for (let r of e) r.children.length > 0 && (t.add(r.id), n(r.children));
|
|
697
697
|
};
|
|
698
698
|
return n(e), t;
|
|
699
699
|
}
|
|
700
|
-
function
|
|
700
|
+
function it(e, t) {
|
|
701
701
|
let n = [];
|
|
702
|
-
for (let r of e) n.push(r), r.children.length > 0 && !t.has(r.id) && n.push(...
|
|
702
|
+
for (let r of e) n.push(r), r.children.length > 0 && !t.has(r.id) && n.push(...it(r.children, t));
|
|
703
703
|
return n;
|
|
704
704
|
}
|
|
705
|
-
function
|
|
705
|
+
function at(e, t) {
|
|
706
706
|
let n = t.toLowerCase(), r = (e) => {
|
|
707
707
|
let t = [];
|
|
708
708
|
for (let i of e) {
|
|
@@ -716,7 +716,7 @@ function it(e, t) {
|
|
|
716
716
|
};
|
|
717
717
|
return r(e);
|
|
718
718
|
}
|
|
719
|
-
function
|
|
719
|
+
function ot(e) {
|
|
720
720
|
let t = e.parentElement;
|
|
721
721
|
for (; t && t !== document.documentElement;) {
|
|
722
722
|
let e = getComputedStyle(t).overflowY;
|
|
@@ -725,7 +725,7 @@ function at(e) {
|
|
|
725
725
|
}
|
|
726
726
|
return null;
|
|
727
727
|
}
|
|
728
|
-
function
|
|
728
|
+
function st(e, t) {
|
|
729
729
|
if (!t) return e;
|
|
730
730
|
let n = e.toLowerCase(), r = t.toLowerCase(), i = [], a = 0, o = 0;
|
|
731
731
|
for (;;) {
|
|
@@ -738,9 +738,9 @@ function ot(e, t) {
|
|
|
738
738
|
}
|
|
739
739
|
return a < e.length && i.push(e.slice(a)), i.length ? i : e;
|
|
740
740
|
}
|
|
741
|
-
var
|
|
741
|
+
var ct = ({ editor: e, className: t = "", onClose: n }) => {
|
|
742
742
|
let [r, i] = T([]), [a, o] = T(""), [s, c] = T(/* @__PURE__ */ new Set()), [l, u] = T(""), d = w(null), f = w(/* @__PURE__ */ new Map()), p = w(""), m = b(() => {
|
|
743
|
-
let t = e.view.dom, n = Array.from(t.querySelectorAll("h1,h2,h3,h4,h5,h6")), r = n.map((e, t) => (e.id ||=
|
|
743
|
+
let t = e.view.dom, n = Array.from(t.querySelectorAll("h1,h2,h3,h4,h5,h6")), r = n.map((e, t) => (e.id ||= tt(e.textContent || "", t), {
|
|
744
744
|
id: e.id,
|
|
745
745
|
level: Number(e.tagName.slice(1)),
|
|
746
746
|
text: e.textContent?.trim() || "(无标题)",
|
|
@@ -757,7 +757,7 @@ var st = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
757
757
|
e < n && e >= 0 && (n = e, t = r);
|
|
758
758
|
}), t && o(t);
|
|
759
759
|
}, {
|
|
760
|
-
root:
|
|
760
|
+
root: ot(e.view.dom),
|
|
761
761
|
rootMargin: "0px 0px -72% 0px",
|
|
762
762
|
threshold: [0, 1]
|
|
763
763
|
});
|
|
@@ -789,11 +789,11 @@ var st = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
789
789
|
behavior: "smooth",
|
|
790
790
|
block: "start"
|
|
791
791
|
}), o(t.id));
|
|
792
|
-
}, [e]), g = C(() =>
|
|
792
|
+
}, [e]), g = C(() => nt(r), [r]), _ = C(() => rt(g), [g]), v = l.trim().length > 0, y = C(() => v ? at(g, l.trim()) : g, [
|
|
793
793
|
g,
|
|
794
794
|
v,
|
|
795
795
|
l
|
|
796
|
-
]), S = C(() =>
|
|
796
|
+
]), S = C(() => it(y, v ? /* @__PURE__ */ new Set() : s), [
|
|
797
797
|
y,
|
|
798
798
|
s,
|
|
799
799
|
v
|
|
@@ -1003,7 +1003,7 @@ var st = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1003
1003
|
title: e.text,
|
|
1004
1004
|
children: /* @__PURE__ */ D("span", {
|
|
1005
1005
|
className: "toc-text",
|
|
1006
|
-
children: v ?
|
|
1006
|
+
children: v ? st(e.text, l.trim()) : e.text
|
|
1007
1007
|
})
|
|
1008
1008
|
})]
|
|
1009
1009
|
}, e.id);
|
|
@@ -1027,7 +1027,7 @@ var st = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1027
1027
|
};
|
|
1028
1028
|
//#endregion
|
|
1029
1029
|
//#region src/editor/ai/index.ts
|
|
1030
|
-
function
|
|
1030
|
+
function lt(e, t) {
|
|
1031
1031
|
return {
|
|
1032
1032
|
continue: "你是一个写作助手。请从下文尾部自然流畅地续写内容,保持风格一致。只输出续写的内容,不要加任何前缀说明。",
|
|
1033
1033
|
improve: "你是一个文字润色专家。请优化以下文本的表达,提升文采和流畅度,保持原意不变。只输出润色后的文本。",
|
|
@@ -1038,8 +1038,8 @@ function ct(e, t) {
|
|
|
1038
1038
|
zap: t || "你是一个全能的 AI 写作助手。请根据用户的指令处理文本。"
|
|
1039
1039
|
}[e];
|
|
1040
1040
|
}
|
|
1041
|
-
var
|
|
1042
|
-
async function
|
|
1041
|
+
var ut = null;
|
|
1042
|
+
async function dt(e) {
|
|
1043
1043
|
let t;
|
|
1044
1044
|
try {
|
|
1045
1045
|
({createOpenAI: t} = await import("@ai-sdk/openai"));
|
|
@@ -1054,7 +1054,7 @@ async function ut(e) {
|
|
|
1054
1054
|
async *stream(e) {
|
|
1055
1055
|
let t = await A({
|
|
1056
1056
|
model: n,
|
|
1057
|
-
system:
|
|
1057
|
+
system: lt(e.mode, e.instruction),
|
|
1058
1058
|
prompt: e.context,
|
|
1059
1059
|
temperature: .7,
|
|
1060
1060
|
maxOutputTokens: 2048
|
|
@@ -1064,7 +1064,7 @@ async function ut(e) {
|
|
|
1064
1064
|
async generate(e) {
|
|
1065
1065
|
return (await k({
|
|
1066
1066
|
model: n,
|
|
1067
|
-
system:
|
|
1067
|
+
system: lt(e.mode, e.instruction),
|
|
1068
1068
|
prompt: e.context,
|
|
1069
1069
|
temperature: .7,
|
|
1070
1070
|
maxOutputTokens: 2048
|
|
@@ -1072,16 +1072,16 @@ async function ut(e) {
|
|
|
1072
1072
|
}
|
|
1073
1073
|
};
|
|
1074
1074
|
}
|
|
1075
|
-
function
|
|
1076
|
-
|
|
1075
|
+
function ft(e) {
|
|
1076
|
+
ut = e;
|
|
1077
1077
|
}
|
|
1078
|
-
function
|
|
1079
|
-
if (!
|
|
1080
|
-
return
|
|
1078
|
+
function pt() {
|
|
1079
|
+
if (!ut) throw Error("未配置 AI 服务。请调用 createAILanguageModelProvider() 创建并通过 setAIProvider() 注册。");
|
|
1080
|
+
return ut;
|
|
1081
1081
|
}
|
|
1082
1082
|
//#endregion
|
|
1083
1083
|
//#region src/editor/ai/providers/openai-compat.ts
|
|
1084
|
-
function
|
|
1084
|
+
function mt(e) {
|
|
1085
1085
|
let { apiKey: t, baseURL: n, model: r, headers: i } = e;
|
|
1086
1086
|
async function* a(e, a) {
|
|
1087
1087
|
let o = await fetch(`${n}/chat/completions`, {
|
|
@@ -1132,10 +1132,10 @@ function pt(e) {
|
|
|
1132
1132
|
}
|
|
1133
1133
|
return {
|
|
1134
1134
|
async *stream(e) {
|
|
1135
|
-
yield* a(
|
|
1135
|
+
yield* a(lt(e.mode, e.instruction), e.context);
|
|
1136
1136
|
},
|
|
1137
1137
|
async generate(e) {
|
|
1138
|
-
let t =
|
|
1138
|
+
let t = lt(e.mode, e.instruction), n = "";
|
|
1139
1139
|
for await (let r of a(t, e.context)) n += r;
|
|
1140
1140
|
return n;
|
|
1141
1141
|
}
|
|
@@ -1143,8 +1143,8 @@ function pt(e) {
|
|
|
1143
1143
|
}
|
|
1144
1144
|
//#endregion
|
|
1145
1145
|
//#region src/editor/ai/providers/deepseek.ts
|
|
1146
|
-
function
|
|
1147
|
-
return
|
|
1146
|
+
function ht(e) {
|
|
1147
|
+
return mt({
|
|
1148
1148
|
apiKey: e.apiKey,
|
|
1149
1149
|
baseURL: e.baseURL || "https://api.deepseek.com/v1",
|
|
1150
1150
|
model: e.model || "deepseek-v4-flash",
|
|
@@ -1153,8 +1153,8 @@ function mt(e) {
|
|
|
1153
1153
|
}
|
|
1154
1154
|
//#endregion
|
|
1155
1155
|
//#region src/editor/ai/providers/openai.ts
|
|
1156
|
-
function
|
|
1157
|
-
return
|
|
1156
|
+
function gt(e) {
|
|
1157
|
+
return mt({
|
|
1158
1158
|
apiKey: e.apiKey,
|
|
1159
1159
|
baseURL: e.baseURL || "https://api.openai.com/v1",
|
|
1160
1160
|
model: e.model || "gpt-5.6-luna",
|
|
@@ -1163,8 +1163,8 @@ function ht(e) {
|
|
|
1163
1163
|
}
|
|
1164
1164
|
//#endregion
|
|
1165
1165
|
//#region src/editor/ai/providers/qwen.ts
|
|
1166
|
-
function
|
|
1167
|
-
return
|
|
1166
|
+
function _t(e) {
|
|
1167
|
+
return mt({
|
|
1168
1168
|
apiKey: e.apiKey,
|
|
1169
1169
|
baseURL: e.baseURL || "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
1170
1170
|
model: e.model || "qwen3.7-plus",
|
|
@@ -1173,20 +1173,20 @@ function gt(e) {
|
|
|
1173
1173
|
}
|
|
1174
1174
|
//#endregion
|
|
1175
1175
|
//#region src/editor/extensions/search-highlight.ts
|
|
1176
|
-
var
|
|
1176
|
+
var vt = {
|
|
1177
1177
|
keyword: "",
|
|
1178
1178
|
caseSensitive: !1,
|
|
1179
1179
|
wholeWord: !1,
|
|
1180
1180
|
matches: [],
|
|
1181
1181
|
currentIndex: -1
|
|
1182
1182
|
}, Z = new R("search-highlight");
|
|
1183
|
-
function
|
|
1183
|
+
function yt(e) {
|
|
1184
1184
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1185
1185
|
}
|
|
1186
|
-
function
|
|
1186
|
+
function bt(e, t) {
|
|
1187
1187
|
let { keyword: n, caseSensitive: r, wholeWord: i } = t;
|
|
1188
1188
|
if (!n) return [];
|
|
1189
|
-
let a = r ? "g" : "gi", o = i ? `\\b${
|
|
1189
|
+
let a = r ? "g" : "gi", o = i ? `\\b${yt(n)}\\b` : yt(n), s = new RegExp(o, a), c = [];
|
|
1190
1190
|
return e.descendants((e, t) => {
|
|
1191
1191
|
if (!e.isText || !e.text) return;
|
|
1192
1192
|
s.lastIndex = 0;
|
|
@@ -1200,12 +1200,12 @@ function yt(e, t) {
|
|
|
1200
1200
|
}
|
|
1201
1201
|
}), c;
|
|
1202
1202
|
}
|
|
1203
|
-
function bt(e, t) {
|
|
1204
|
-
if (t.matches.length === 0) return z.empty;
|
|
1205
|
-
let n = t.matches.map((e, n) => se.inline(e.from, e.to, { class: n === t.currentIndex ? "search-highlight search-highlight--active" : "search-highlight" }));
|
|
1206
|
-
return z.create(e, n);
|
|
1207
|
-
}
|
|
1208
1203
|
function xt(e, t) {
|
|
1204
|
+
if (t.matches.length === 0) return le.empty;
|
|
1205
|
+
let n = t.matches.map((e, n) => ce.inline(e.from, e.to, { class: n === t.currentIndex ? "search-highlight search-highlight--active" : "search-highlight" }));
|
|
1206
|
+
return le.create(e, n);
|
|
1207
|
+
}
|
|
1208
|
+
function St(e, t) {
|
|
1209
1209
|
if (t.currentIndex < 0 || t.currentIndex >= t.matches.length) return;
|
|
1210
1210
|
let n = t.matches[t.currentIndex];
|
|
1211
1211
|
n && requestAnimationFrame(() => {
|
|
@@ -1230,13 +1230,13 @@ function xt(e, t) {
|
|
|
1230
1230
|
} catch {}
|
|
1231
1231
|
});
|
|
1232
1232
|
}
|
|
1233
|
-
var
|
|
1233
|
+
var Ct = F.create({
|
|
1234
1234
|
name: "searchHighlight",
|
|
1235
1235
|
addProseMirrorPlugins() {
|
|
1236
1236
|
return [new L({
|
|
1237
1237
|
key: Z,
|
|
1238
1238
|
state: {
|
|
1239
|
-
init: () =>
|
|
1239
|
+
init: () => vt,
|
|
1240
1240
|
apply(e, t) {
|
|
1241
1241
|
let n = e.getMeta(Z);
|
|
1242
1242
|
if (n) return {
|
|
@@ -1246,7 +1246,7 @@ var St = I.create({
|
|
|
1246
1246
|
currentIndex: n.currentIndex === void 0 ? t.currentIndex : n.currentIndex
|
|
1247
1247
|
};
|
|
1248
1248
|
if (e.docChanged && t.keyword) {
|
|
1249
|
-
let n =
|
|
1249
|
+
let n = bt(e.doc, t), r = t.currentIndex;
|
|
1250
1250
|
return r >= n.length && (r = n.length - 1), r < 0 && (r = n.length > 0 ? 0 : -1), {
|
|
1251
1251
|
...t,
|
|
1252
1252
|
matches: n,
|
|
@@ -1258,51 +1258,51 @@ var St = I.create({
|
|
|
1258
1258
|
},
|
|
1259
1259
|
props: { decorations(e) {
|
|
1260
1260
|
let t = Z.getState(e);
|
|
1261
|
-
return t ?
|
|
1261
|
+
return t ? xt(e.doc, t) : le.empty;
|
|
1262
1262
|
} }
|
|
1263
1263
|
})];
|
|
1264
1264
|
},
|
|
1265
1265
|
addCommands() {
|
|
1266
1266
|
return {
|
|
1267
1267
|
setSearch: (e, t = {}) => ({ state: n, dispatch: r, view: i }) => {
|
|
1268
|
-
let a = Z.getState(n) ||
|
|
1268
|
+
let a = Z.getState(n) || vt, o = {
|
|
1269
1269
|
keyword: e,
|
|
1270
1270
|
caseSensitive: t.caseSensitive ?? a.caseSensitive,
|
|
1271
1271
|
wholeWord: t.wholeWord ?? a.wholeWord,
|
|
1272
1272
|
matches: [],
|
|
1273
1273
|
currentIndex: -1
|
|
1274
1274
|
};
|
|
1275
|
-
return o.matches =
|
|
1275
|
+
return o.matches = bt(n.doc, o), o.currentIndex = o.matches.length > 0 ? 0 : -1, r && (r(n.tr.setMeta(Z, o)), i && St(i, o)), !0;
|
|
1276
1276
|
},
|
|
1277
1277
|
nextMatch: () => ({ state: e, dispatch: t, view: n }) => {
|
|
1278
|
-
let r = Z.getState(e) ||
|
|
1278
|
+
let r = Z.getState(e) || vt;
|
|
1279
1279
|
if (r.matches.length === 0) return !1;
|
|
1280
1280
|
let i = (r.currentIndex + 1) % r.matches.length;
|
|
1281
|
-
return t && (t(e.tr.setMeta(Z, { currentIndex: i })), n &&
|
|
1281
|
+
return t && (t(e.tr.setMeta(Z, { currentIndex: i })), n && St(n, {
|
|
1282
1282
|
...r,
|
|
1283
1283
|
currentIndex: i
|
|
1284
1284
|
})), !0;
|
|
1285
1285
|
},
|
|
1286
1286
|
prevMatch: () => ({ state: e, dispatch: t, view: n }) => {
|
|
1287
|
-
let r = Z.getState(e) ||
|
|
1287
|
+
let r = Z.getState(e) || vt;
|
|
1288
1288
|
if (r.matches.length === 0) return !1;
|
|
1289
1289
|
let i = (r.currentIndex - 1 + r.matches.length) % r.matches.length;
|
|
1290
|
-
return t && (t(e.tr.setMeta(Z, { currentIndex: i })), n &&
|
|
1290
|
+
return t && (t(e.tr.setMeta(Z, { currentIndex: i })), n && St(n, {
|
|
1291
1291
|
...r,
|
|
1292
1292
|
currentIndex: i
|
|
1293
1293
|
})), !0;
|
|
1294
1294
|
},
|
|
1295
|
-
clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(Z,
|
|
1295
|
+
clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(Z, vt)), !0)
|
|
1296
1296
|
};
|
|
1297
1297
|
}
|
|
1298
1298
|
});
|
|
1299
|
-
function
|
|
1299
|
+
function wt(e) {
|
|
1300
1300
|
let t = e.state;
|
|
1301
|
-
return Z.getState(t) ||
|
|
1301
|
+
return Z.getState(t) || vt;
|
|
1302
1302
|
}
|
|
1303
1303
|
//#endregion
|
|
1304
1304
|
//#region src/components/search-bar.tsx
|
|
1305
|
-
var
|
|
1305
|
+
var Tt = ({ editor: e, onClose: t }) => {
|
|
1306
1306
|
let [n, r] = T(""), [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(0), u = w(null), d = w({
|
|
1307
1307
|
keyword: n,
|
|
1308
1308
|
caseSensitive: i,
|
|
@@ -1367,7 +1367,7 @@ var wt = ({ editor: e, onClose: t }) => {
|
|
|
1367
1367
|
}, [f, p]), h = C(() => {
|
|
1368
1368
|
if (!e) return null;
|
|
1369
1369
|
try {
|
|
1370
|
-
return
|
|
1370
|
+
return wt(e);
|
|
1371
1371
|
} catch {
|
|
1372
1372
|
return null;
|
|
1373
1373
|
}
|
|
@@ -1519,36 +1519,36 @@ function Q({ children: e, ...t }) {
|
|
|
1519
1519
|
children: e
|
|
1520
1520
|
});
|
|
1521
1521
|
}
|
|
1522
|
-
var
|
|
1522
|
+
var Et = (e) => /* @__PURE__ */ O(Q, {
|
|
1523
1523
|
...e,
|
|
1524
1524
|
children: [/* @__PURE__ */ D("path", { d: "M6 4h8a4 4 0 0 1 0 8H6z" }), /* @__PURE__ */ D("path", { d: "M6 12h9a4 4 0 0 1 0 8H6z" })]
|
|
1525
|
-
}),
|
|
1525
|
+
}), Dt = (e) => /* @__PURE__ */ O(Q, {
|
|
1526
1526
|
...e,
|
|
1527
1527
|
children: [
|
|
1528
1528
|
/* @__PURE__ */ D("path", { d: "M19 4h-9" }),
|
|
1529
1529
|
/* @__PURE__ */ D("path", { d: "M14 20H5" }),
|
|
1530
1530
|
/* @__PURE__ */ D("path", { d: "M15 4 9 20" })
|
|
1531
1531
|
]
|
|
1532
|
-
}),
|
|
1532
|
+
}), Ot = (e) => /* @__PURE__ */ O(Q, {
|
|
1533
1533
|
...e,
|
|
1534
1534
|
children: [/* @__PURE__ */ D("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }), /* @__PURE__ */ D("path", { d: "M4 20h16" })]
|
|
1535
|
-
}),
|
|
1535
|
+
}), kt = (e) => /* @__PURE__ */ O(Q, {
|
|
1536
1536
|
...e,
|
|
1537
1537
|
children: [
|
|
1538
1538
|
/* @__PURE__ */ D("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
|
|
1539
1539
|
/* @__PURE__ */ D("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
|
|
1540
1540
|
/* @__PURE__ */ D("path", { d: "M4 12h16" })
|
|
1541
1541
|
]
|
|
1542
|
-
}),
|
|
1542
|
+
}), At = (e) => /* @__PURE__ */ O(Q, {
|
|
1543
1543
|
...e,
|
|
1544
1544
|
children: [/* @__PURE__ */ D("path", { d: "m16 18 6-6-6-6" }), /* @__PURE__ */ D("path", { d: "m8 6-6 6 6 6" })]
|
|
1545
|
-
}),
|
|
1545
|
+
}), jt = (e) => /* @__PURE__ */ O(Q, {
|
|
1546
1546
|
...e,
|
|
1547
1547
|
children: [/* @__PURE__ */ D("path", { d: "m9 11-6 6v3h9l3-3" }), /* @__PURE__ */ D("path", { d: "m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4" })]
|
|
1548
|
-
}),
|
|
1548
|
+
}), Mt = (e) => /* @__PURE__ */ O(Q, {
|
|
1549
1549
|
...e,
|
|
1550
1550
|
children: [/* @__PURE__ */ D("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }), /* @__PURE__ */ D("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })]
|
|
1551
|
-
}),
|
|
1551
|
+
}), Nt = (e) => /* @__PURE__ */ O(Q, {
|
|
1552
1552
|
...e,
|
|
1553
1553
|
children: [/* @__PURE__ */ D("rect", {
|
|
1554
1554
|
x: "3",
|
|
@@ -1558,7 +1558,7 @@ var Tt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1558
1558
|
rx: "2",
|
|
1559
1559
|
ry: "2"
|
|
1560
1560
|
}), /* @__PURE__ */ D("path", { d: "M3 9h18M3 15h18M9 3v18M15 3v18" })]
|
|
1561
|
-
}),
|
|
1561
|
+
}), Pt = (e) => /* @__PURE__ */ O(Q, {
|
|
1562
1562
|
...e,
|
|
1563
1563
|
children: [/* @__PURE__ */ D("rect", {
|
|
1564
1564
|
x: "8",
|
|
@@ -1568,17 +1568,17 @@ var Tt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1568
1568
|
rx: "2",
|
|
1569
1569
|
ry: "2"
|
|
1570
1570
|
}), /* @__PURE__ */ D("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })]
|
|
1571
|
-
}),
|
|
1571
|
+
}), Ft = (e) => /* @__PURE__ */ O(Q, {
|
|
1572
1572
|
...e,
|
|
1573
1573
|
children: [/* @__PURE__ */ D("circle", {
|
|
1574
1574
|
cx: "11",
|
|
1575
1575
|
cy: "11",
|
|
1576
1576
|
r: "8"
|
|
1577
1577
|
}), /* @__PURE__ */ D("path", { d: "m21 21-4.3-4.3" })]
|
|
1578
|
-
}),
|
|
1578
|
+
}), It = (e) => /* @__PURE__ */ O(Q, {
|
|
1579
1579
|
...e,
|
|
1580
1580
|
children: [/* @__PURE__ */ D("path", { d: "M12 3l1.6 4.4L18 9l-4.4 1.6L12 15l-1.6-4.4L6 9l4.4-1.6L12 3z" }), /* @__PURE__ */ D("path", { d: "M18.5 14l.7 1.9 1.9.7-1.9.7-.7 1.9-.7-1.9-1.9-.7 1.9-.7.7-1.9z" })]
|
|
1581
|
-
}),
|
|
1581
|
+
}), Lt = (e) => /* @__PURE__ */ O(Q, {
|
|
1582
1582
|
...e,
|
|
1583
1583
|
children: [
|
|
1584
1584
|
/* @__PURE__ */ D("circle", {
|
|
@@ -1597,13 +1597,13 @@ var Tt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1597
1597
|
r: "1"
|
|
1598
1598
|
})
|
|
1599
1599
|
]
|
|
1600
|
-
}),
|
|
1600
|
+
}), Rt = (e) => /* @__PURE__ */ O(Q, {
|
|
1601
1601
|
...e,
|
|
1602
1602
|
children: [/* @__PURE__ */ D("path", { d: "M18 6 6 18" }), /* @__PURE__ */ D("path", { d: "m6 6 12 12" })]
|
|
1603
1603
|
});
|
|
1604
1604
|
//#endregion
|
|
1605
1605
|
//#region src/editor/storage/remove-resource.ts
|
|
1606
|
-
async function
|
|
1606
|
+
async function zt(e) {
|
|
1607
1607
|
if (e) {
|
|
1608
1608
|
if (e.startsWith("blob:")) {
|
|
1609
1609
|
URL.revokeObjectURL(e);
|
|
@@ -1618,61 +1618,61 @@ async function Rt(e) {
|
|
|
1618
1618
|
}
|
|
1619
1619
|
//#endregion
|
|
1620
1620
|
//#region src/editor/ai/pending-removal.ts
|
|
1621
|
-
var
|
|
1621
|
+
var Bt = 3e4, Vt = /* @__PURE__ */ new Set([
|
|
1622
1622
|
"image",
|
|
1623
1623
|
"attachmentEmbed",
|
|
1624
1624
|
"audioEmbed",
|
|
1625
1625
|
"videoEmbed"
|
|
1626
|
-
]),
|
|
1627
|
-
function
|
|
1626
|
+
]), Ht = /* @__PURE__ */ new WeakMap();
|
|
1627
|
+
function Ut(e) {
|
|
1628
1628
|
let t = /* @__PURE__ */ new Set();
|
|
1629
1629
|
return e.state.doc.descendants((e) => {
|
|
1630
|
-
if (
|
|
1630
|
+
if (Vt.has(e.type.name)) {
|
|
1631
1631
|
let n = e.attrs.src;
|
|
1632
1632
|
n && t.add(n);
|
|
1633
1633
|
}
|
|
1634
1634
|
return !0;
|
|
1635
1635
|
}), t;
|
|
1636
1636
|
}
|
|
1637
|
-
function
|
|
1638
|
-
let t =
|
|
1637
|
+
function Wt(e) {
|
|
1638
|
+
let t = Ht.get(e);
|
|
1639
1639
|
return t || (t = {
|
|
1640
1640
|
timers: /* @__PURE__ */ new Map(),
|
|
1641
1641
|
onTransaction: () => {},
|
|
1642
1642
|
listening: !1
|
|
1643
|
-
},
|
|
1643
|
+
}, Ht.set(e, t)), t;
|
|
1644
1644
|
}
|
|
1645
|
-
function
|
|
1645
|
+
function Gt(e, t) {
|
|
1646
1646
|
let n = [...new Set(t.filter(Boolean))];
|
|
1647
1647
|
if (n.length === 0) return;
|
|
1648
|
-
let r =
|
|
1648
|
+
let r = Wt(e);
|
|
1649
1649
|
r.listening ||= (r.onTransaction = () => {
|
|
1650
1650
|
if (r.timers.size === 0) return;
|
|
1651
|
-
let t =
|
|
1651
|
+
let t = Ut(e);
|
|
1652
1652
|
for (let [e, n] of r.timers) t.has(e) && (clearTimeout(n), r.timers.delete(e));
|
|
1653
1653
|
}, e.on("transaction", r.onTransaction), !0);
|
|
1654
1654
|
for (let t of n) {
|
|
1655
1655
|
if (r.timers.has(t)) continue;
|
|
1656
1656
|
let n = setTimeout(() => {
|
|
1657
|
-
|
|
1658
|
-
},
|
|
1657
|
+
Ut(e).has(t) || zt(t), r.timers.delete(t);
|
|
1658
|
+
}, Bt);
|
|
1659
1659
|
r.timers.set(t, n);
|
|
1660
1660
|
}
|
|
1661
1661
|
}
|
|
1662
|
-
function
|
|
1663
|
-
let t =
|
|
1662
|
+
function Kt(e) {
|
|
1663
|
+
let t = Ht.get(e);
|
|
1664
1664
|
if (t) {
|
|
1665
1665
|
if (t.listening &&= (e.off("transaction", t.onTransaction), !1), t.timers.size > 0) {
|
|
1666
|
-
let n =
|
|
1667
|
-
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) ||
|
|
1666
|
+
let n = Ut(e);
|
|
1667
|
+
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) || zt(e);
|
|
1668
1668
|
t.timers.clear();
|
|
1669
1669
|
}
|
|
1670
|
-
|
|
1670
|
+
Ht.delete(e);
|
|
1671
1671
|
}
|
|
1672
1672
|
}
|
|
1673
1673
|
//#endregion
|
|
1674
1674
|
//#region src/editor/ai/components/ai-selector.tsx
|
|
1675
|
-
var
|
|
1675
|
+
var qt = [
|
|
1676
1676
|
{
|
|
1677
1677
|
mode: "continue",
|
|
1678
1678
|
labelKey: "editor.ai.continue",
|
|
@@ -1715,24 +1715,24 @@ var Kt = [
|
|
|
1715
1715
|
descKey: "editor.ai.zapDesc",
|
|
1716
1716
|
icon: "⚡"
|
|
1717
1717
|
}
|
|
1718
|
-
],
|
|
1718
|
+
], Jt = /* @__PURE__ */ new Set([
|
|
1719
1719
|
"image",
|
|
1720
1720
|
"attachmentEmbed",
|
|
1721
1721
|
"audioEmbed",
|
|
1722
1722
|
"videoEmbed"
|
|
1723
|
-
]),
|
|
1723
|
+
]), Yt = {
|
|
1724
1724
|
image: "editor.ai.nodeImage",
|
|
1725
1725
|
attachmentEmbed: "editor.ai.nodeAttachment",
|
|
1726
1726
|
videoEmbed: "editor.ai.nodeVideo",
|
|
1727
1727
|
audioEmbed: "editor.ai.nodeAudio"
|
|
1728
1728
|
};
|
|
1729
|
-
function
|
|
1729
|
+
function Xt(e, t) {
|
|
1730
1730
|
return e.storage.qingwuUI?.parseMd?.(e.schema, t) || null;
|
|
1731
1731
|
}
|
|
1732
|
-
function
|
|
1732
|
+
function Zt(e, t, n) {
|
|
1733
1733
|
let r = [];
|
|
1734
1734
|
return e.state.doc.nodesBetween(t, n, (e) => {
|
|
1735
|
-
if (
|
|
1735
|
+
if (Jt.has(e.type.name)) {
|
|
1736
1736
|
let t = e.attrs.src;
|
|
1737
1737
|
t && r.push({
|
|
1738
1738
|
type: e.type.name,
|
|
@@ -1742,27 +1742,27 @@ function Xt(e, t, n) {
|
|
|
1742
1742
|
return !0;
|
|
1743
1743
|
}), r;
|
|
1744
1744
|
}
|
|
1745
|
-
function
|
|
1745
|
+
function Qt(e) {
|
|
1746
1746
|
let t = /* @__PURE__ */ new Set();
|
|
1747
1747
|
return e.state.doc.descendants((e) => {
|
|
1748
|
-
if (
|
|
1748
|
+
if (Jt.has(e.type.name)) {
|
|
1749
1749
|
let n = e.attrs.src;
|
|
1750
1750
|
n && t.add(n);
|
|
1751
1751
|
}
|
|
1752
1752
|
return !0;
|
|
1753
1753
|
}), t;
|
|
1754
1754
|
}
|
|
1755
|
-
function
|
|
1756
|
-
let n =
|
|
1755
|
+
function $t(e, t) {
|
|
1756
|
+
let n = Xt(e, t);
|
|
1757
1757
|
if (n && n.size > 0) {
|
|
1758
1758
|
let t = e.state.tr;
|
|
1759
|
-
t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(
|
|
1759
|
+
t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(se.create(t.doc, t.doc.content.size)), e.view.dispatch(t.scrollIntoView()), e.commands.focus();
|
|
1760
1760
|
return;
|
|
1761
1761
|
}
|
|
1762
1762
|
e.commands.setContent(t), e.commands.focus();
|
|
1763
1763
|
}
|
|
1764
|
-
function
|
|
1765
|
-
let i =
|
|
1764
|
+
function en(e, t, n, r) {
|
|
1765
|
+
let i = Xt(e, t);
|
|
1766
1766
|
if (e.commands.focus(), !i) {
|
|
1767
1767
|
let i = e.chain().focus();
|
|
1768
1768
|
n === "replace" ? i.setTextSelection({
|
|
@@ -1772,9 +1772,9 @@ function $t(e, t, n, r) {
|
|
|
1772
1772
|
return;
|
|
1773
1773
|
}
|
|
1774
1774
|
let a = e.state.tr;
|
|
1775
|
-
n === "replace" ? a.replaceRange(r.from, r.to, new
|
|
1775
|
+
n === "replace" ? a.replaceRange(r.from, r.to, new N(i, 0, 0)) : a.insert(Math.min(r.to, e.state.doc.content.size), i), e.view.dispatch(a.scrollIntoView());
|
|
1776
1776
|
}
|
|
1777
|
-
function
|
|
1777
|
+
function tn({ editor: e, onClose: t }) {
|
|
1778
1778
|
let [n, r] = T(null), [i, a] = T(""), [o, s] = T(""), [c, l] = T(!1), [u, d] = T(null), [p, m] = T(null), h = w({
|
|
1779
1779
|
from: 0,
|
|
1780
1780
|
to: 0,
|
|
@@ -1793,7 +1793,7 @@ function en({ editor: e, onClose: t }) {
|
|
|
1793
1793
|
empty: n.empty
|
|
1794
1794
|
}, l(!0), s(""), v.current = !0, d(null);
|
|
1795
1795
|
try {
|
|
1796
|
-
let r =
|
|
1796
|
+
let r = pt(), a = n.empty ? e.state.doc.textContent : e.state.doc.textBetween(n.from, n.to), o = [];
|
|
1797
1797
|
for await (let e of r.stream({
|
|
1798
1798
|
mode: t,
|
|
1799
1799
|
context: a,
|
|
@@ -1818,13 +1818,13 @@ function en({ editor: e, onClose: t }) {
|
|
|
1818
1818
|
!e || !v.current || (e.scrollTop = e.scrollHeight);
|
|
1819
1819
|
}, [o]);
|
|
1820
1820
|
let k = b((t, n, r) => {
|
|
1821
|
-
let i = new Set(
|
|
1822
|
-
t === "replaceAll" ?
|
|
1823
|
-
let a =
|
|
1824
|
-
|
|
1821
|
+
let i = new Set(Zt(e, r.from, r.to).map((e) => e.src));
|
|
1822
|
+
t === "replaceAll" ? $t(e, n) : en(e, n, "replace", h.current);
|
|
1823
|
+
let a = Qt(e);
|
|
1824
|
+
Gt(e, [...i].filter((e) => !a.has(e)));
|
|
1825
1825
|
}, [e]), A = b((n) => {
|
|
1826
1826
|
if (n === "below") {
|
|
1827
|
-
|
|
1827
|
+
en(e, o, "below", h.current), t();
|
|
1828
1828
|
return;
|
|
1829
1829
|
}
|
|
1830
1830
|
let r = h.current, i = n === "replaceAll" ? {
|
|
@@ -1833,7 +1833,7 @@ function en({ editor: e, onClose: t }) {
|
|
|
1833
1833
|
} : {
|
|
1834
1834
|
from: r.from,
|
|
1835
1835
|
to: r.to
|
|
1836
|
-
}, a =
|
|
1836
|
+
}, a = Zt(e, i.from, i.to);
|
|
1837
1837
|
if (a.length > 0) {
|
|
1838
1838
|
m({
|
|
1839
1839
|
position: n,
|
|
@@ -1874,19 +1874,19 @@ function en({ editor: e, onClose: t }) {
|
|
|
1874
1874
|
className: "flex items-center justify-between pl-3 pr-1.5 py-1.5 border-b border-default-100 shrink-0",
|
|
1875
1875
|
children: [/* @__PURE__ */ O("span", {
|
|
1876
1876
|
className: "flex items-center gap-1.5 text-xs font-medium text-default-500",
|
|
1877
|
-
children: [/* @__PURE__ */ D(
|
|
1877
|
+
children: [/* @__PURE__ */ D(It, { className: "text-primary" }), f("editor.ai.trigger")]
|
|
1878
1878
|
}), /* @__PURE__ */ D("button", {
|
|
1879
1879
|
type: "button",
|
|
1880
1880
|
onClick: t,
|
|
1881
1881
|
"aria-label": f("editor.ai.close"),
|
|
1882
1882
|
title: f("editor.ai.close"),
|
|
1883
1883
|
className: "flex items-center justify-center w-6 h-6 rounded-md text-default-400 hover:bg-default-100 hover:text-default-700 transition-colors",
|
|
1884
|
-
children: /* @__PURE__ */ D(
|
|
1884
|
+
children: /* @__PURE__ */ D(Rt, {})
|
|
1885
1885
|
})]
|
|
1886
1886
|
}),
|
|
1887
1887
|
/* @__PURE__ */ D("div", {
|
|
1888
1888
|
className: "grid grid-cols-[repeat(auto-fit,minmax(64px,1fr))] gap-1.5 p-2 shrink-0",
|
|
1889
|
-
children:
|
|
1889
|
+
children: qt.map(({ mode: e, labelKey: t, descKey: r, icon: i }) => /* @__PURE__ */ O("button", {
|
|
1890
1890
|
type: "button",
|
|
1891
1891
|
className: `flex flex-col items-center gap-1 px-1 py-2 rounded-xl border transition-colors ${n === e ? "border-primary/40 bg-primary/10 text-primary" : "border-default-200 text-default-600 hover:bg-default-100 hover:text-default-900"}`,
|
|
1892
1892
|
onClick: () => y(e),
|
|
@@ -2029,7 +2029,7 @@ function en({ editor: e, onClose: t }) {
|
|
|
2029
2029
|
children: Object.entries(N).map(([e, t]) => /* @__PURE__ */ O("li", {
|
|
2030
2030
|
className: "text-sm text-default-700",
|
|
2031
2031
|
children: [
|
|
2032
|
-
f(
|
|
2032
|
+
f(Yt[e] ?? e),
|
|
2033
2033
|
" ×",
|
|
2034
2034
|
t
|
|
2035
2035
|
]
|
|
@@ -2061,19 +2061,19 @@ function en({ editor: e, onClose: t }) {
|
|
|
2061
2061
|
}
|
|
2062
2062
|
//#endregion
|
|
2063
2063
|
//#region src/editor/attachment-limits.ts
|
|
2064
|
-
var
|
|
2064
|
+
var nn = /* @__PURE__ */ new Set([
|
|
2065
2065
|
"attachmentEmbed",
|
|
2066
2066
|
"videoEmbed",
|
|
2067
2067
|
"audioEmbed",
|
|
2068
2068
|
"image"
|
|
2069
2069
|
]);
|
|
2070
|
-
function
|
|
2070
|
+
function rn(e) {
|
|
2071
2071
|
let t = 0;
|
|
2072
2072
|
return e.descendants((e) => {
|
|
2073
|
-
|
|
2073
|
+
nn.has(e.type.name) && (t += Number(e.attrs?.size) || 0);
|
|
2074
2074
|
}), t;
|
|
2075
2075
|
}
|
|
2076
|
-
function
|
|
2076
|
+
function an(e) {
|
|
2077
2077
|
if (!Number.isFinite(e) || e <= 0) return "0 B";
|
|
2078
2078
|
let t = [
|
|
2079
2079
|
"B",
|
|
@@ -2084,41 +2084,41 @@ function rn(e) {
|
|
|
2084
2084
|
], n = Math.min(t.length - 1, Math.floor(Math.log(e) / Math.log(1024))), r = e / 1024 ** n;
|
|
2085
2085
|
return `${n === 0 || r >= 100 ? `${Math.round(r)}` : `${Math.round(r * 10) / 10}`} ${t[n]}`;
|
|
2086
2086
|
}
|
|
2087
|
-
function
|
|
2087
|
+
function on(e) {
|
|
2088
2088
|
return (e?.storage)?.qingwuUI?.limits;
|
|
2089
2089
|
}
|
|
2090
|
-
function
|
|
2090
|
+
function sn(e, t, n) {
|
|
2091
2091
|
let { maxAttachmentSize: r, maxTotalAttachmentSize: i } = n;
|
|
2092
|
-
if (r && t.size > r) return `单文件大小不能超过 ${
|
|
2092
|
+
if (r && t.size > r) return `单文件大小不能超过 ${an(r)}(当前 ${an(t.size)})`;
|
|
2093
2093
|
if (i) {
|
|
2094
|
-
let n =
|
|
2095
|
-
if (n > i) return `附件总大小不能超过 ${
|
|
2094
|
+
let n = rn(e) + t.size;
|
|
2095
|
+
if (n > i) return `附件总大小不能超过 ${an(i)}(当前合计 ${an(n)})`;
|
|
2096
2096
|
}
|
|
2097
2097
|
return null;
|
|
2098
2098
|
}
|
|
2099
2099
|
//#endregion
|
|
2100
2100
|
//#region src/editor/utils/delete-confirm.ts
|
|
2101
|
-
var
|
|
2102
|
-
function
|
|
2103
|
-
return
|
|
2101
|
+
var cn = !1, ln = null, un = 5e3;
|
|
2102
|
+
function dn() {
|
|
2103
|
+
return cn;
|
|
2104
2104
|
}
|
|
2105
2105
|
function $(e) {
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
},
|
|
2106
|
+
cn = e, ln &&= (clearTimeout(ln), null), e && (ln = setTimeout(() => {
|
|
2107
|
+
cn = !1, ln = null;
|
|
2108
|
+
}, un));
|
|
2109
2109
|
}
|
|
2110
|
-
var
|
|
2111
|
-
function
|
|
2112
|
-
|
|
2110
|
+
var fn = null;
|
|
2111
|
+
function pn(e) {
|
|
2112
|
+
fn = e;
|
|
2113
2113
|
}
|
|
2114
|
-
function
|
|
2115
|
-
return
|
|
2114
|
+
function mn() {
|
|
2115
|
+
return fn;
|
|
2116
2116
|
}
|
|
2117
2117
|
//#endregion
|
|
2118
2118
|
//#region src/editor/utils/delete-confirm-dialog.tsx
|
|
2119
|
-
var
|
|
2120
|
-
function
|
|
2121
|
-
let [s, c] = T(!1), l = w(!1), u =
|
|
2119
|
+
var hn = 300;
|
|
2120
|
+
function gn({ open: e, title: t, message: n, confirmText: r = "删除", cancelText: i = "取消", onConfirm: a, onCancel: o }) {
|
|
2121
|
+
let [s, c] = T(!1), l = w(!1), u = mn();
|
|
2122
2122
|
return x(() => {
|
|
2123
2123
|
if (!e) {
|
|
2124
2124
|
l.current = !1;
|
|
@@ -2144,7 +2144,7 @@ function hn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2144
2144
|
o
|
|
2145
2145
|
]), x(() => {
|
|
2146
2146
|
e || c(!1);
|
|
2147
|
-
}, [e]), u || !e ? null :
|
|
2147
|
+
}, [e]), u || !e ? null : ae(/* @__PURE__ */ D("div", {
|
|
2148
2148
|
className: "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none",
|
|
2149
2149
|
onClick: () => {
|
|
2150
2150
|
s || o();
|
|
@@ -2188,7 +2188,7 @@ function hn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2188
2188
|
await a();
|
|
2189
2189
|
} finally {
|
|
2190
2190
|
let t = Date.now() - e;
|
|
2191
|
-
t <
|
|
2191
|
+
t < hn && await new Promise((e) => setTimeout(e, hn - t)), c(!1), o();
|
|
2192
2192
|
}
|
|
2193
2193
|
},
|
|
2194
2194
|
disabled: s,
|
|
@@ -2201,18 +2201,18 @@ function hn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2201
2201
|
}
|
|
2202
2202
|
//#endregion
|
|
2203
2203
|
//#region src/editor/extensions/image-view.tsx
|
|
2204
|
-
function
|
|
2204
|
+
function _n(e) {
|
|
2205
2205
|
return /^(\.\.?\/|[a-zA-Z]:\\|file:\/\/)/.test(e) ? !0 : !(/^[a-z]+:\/\//i.test(e) || e.startsWith("/") || e.startsWith("data:") || e.startsWith("blob:"));
|
|
2206
2206
|
}
|
|
2207
|
-
function
|
|
2208
|
-
let [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(!1), u = w(!1), [d, f] = T(!1), p = e.attrs.src || "", m = e.attrs.alt || "", h = e.attrs.width || null, g = e.attrs.height || null, _ = w(null), v = w(null), y = w(null), S = w(null), C = w(null), E = w(!1), k = w(!1), A = w(0), [j, M] = T(p), N = r?.isEditable ?? !0,
|
|
2207
|
+
function vn({ node: e, deleteNode: t, editor: r }) {
|
|
2208
|
+
let [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(!1), u = w(!1), [d, f] = T(!1), p = e.attrs.src || "", m = e.attrs.alt || "", h = e.attrs.width || null, g = e.attrs.height || null, _ = w(null), v = w(null), y = w(null), S = w(null), C = w(null), E = w(!1), k = w(!1), A = w(0), [j, M] = T(p), N = r?.isEditable ?? !0, ee = b(() => {
|
|
2209
2209
|
o || (A.current = window.scrollY, a(!0));
|
|
2210
|
-
}, [o]),
|
|
2210
|
+
}, [o]), te = b(() => {
|
|
2211
2211
|
a(!1), requestAnimationFrame(() => window.scrollTo(0, A.current));
|
|
2212
|
-
}, []),
|
|
2212
|
+
}, []), P = b(() => {
|
|
2213
2213
|
let e = _.current;
|
|
2214
2214
|
e && (A.current = window.scrollY, e.requestFullscreen ? e.requestFullscreen() : e.webkitRequestFullscreen && e.webkitRequestFullscreen());
|
|
2215
|
-
}, []),
|
|
2215
|
+
}, []), re = b(() => {
|
|
2216
2216
|
let e = v.current;
|
|
2217
2217
|
e && (A.current = window.scrollY, e.requestFullscreen ? e.requestFullscreen() : e.webkitRequestFullscreen && e.webkitRequestFullscreen());
|
|
2218
2218
|
}, []);
|
|
@@ -2257,20 +2257,20 @@ function _n({ node: e, deleteNode: t, editor: r }) {
|
|
|
2257
2257
|
};
|
|
2258
2258
|
return document.addEventListener("fullscreenchange", e), () => document.removeEventListener("fullscreenchange", e);
|
|
2259
2259
|
}, []);
|
|
2260
|
-
let
|
|
2261
|
-
return /* @__PURE__ */ O(
|
|
2260
|
+
let ie = o || _n(p);
|
|
2261
|
+
return /* @__PURE__ */ O(ne, {
|
|
2262
2262
|
as: "div",
|
|
2263
2263
|
className: "image-node-view group/img",
|
|
2264
2264
|
contentEditable: !1,
|
|
2265
2265
|
children: [
|
|
2266
|
-
|
|
2266
|
+
ie ? /* @__PURE__ */ O("div", {
|
|
2267
2267
|
className: "image-placeholder",
|
|
2268
2268
|
children: [
|
|
2269
2269
|
N && /* @__PURE__ */ D("button", {
|
|
2270
2270
|
type: "button",
|
|
2271
2271
|
className: "img-ctrl-btn img-ctrl-btn--del image-placeholder-del",
|
|
2272
2272
|
onClick: () => {
|
|
2273
|
-
|
|
2273
|
+
dn() || ($(!0), f(!0));
|
|
2274
2274
|
},
|
|
2275
2275
|
title: "删除",
|
|
2276
2276
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2302,7 +2302,7 @@ function _n({ node: e, deleteNode: t, editor: r }) {
|
|
|
2302
2302
|
}),
|
|
2303
2303
|
/* @__PURE__ */ D("span", {
|
|
2304
2304
|
className: "image-placeholder-text",
|
|
2305
|
-
children:
|
|
2305
|
+
children: _n(p) ? "本地图片无法加载" : "图片加载失败"
|
|
2306
2306
|
}),
|
|
2307
2307
|
/* @__PURE__ */ D("span", {
|
|
2308
2308
|
className: "image-placeholder-path",
|
|
@@ -2318,7 +2318,7 @@ function _n({ node: e, deleteNode: t, editor: r }) {
|
|
|
2318
2318
|
alt: m,
|
|
2319
2319
|
width: h || void 0,
|
|
2320
2320
|
height: g || void 0,
|
|
2321
|
-
onClick:
|
|
2321
|
+
onClick: ee,
|
|
2322
2322
|
onError: () => {
|
|
2323
2323
|
E.current || o || (E.current = !0, (async () => {
|
|
2324
2324
|
try {
|
|
@@ -2344,7 +2344,7 @@ function _n({ node: e, deleteNode: t, editor: r }) {
|
|
|
2344
2344
|
/* @__PURE__ */ D("button", {
|
|
2345
2345
|
type: "button",
|
|
2346
2346
|
className: "img-ctrl-btn",
|
|
2347
|
-
onClick:
|
|
2347
|
+
onClick: ee,
|
|
2348
2348
|
title: "网页全屏",
|
|
2349
2349
|
children: /* @__PURE__ */ D("svg", {
|
|
2350
2350
|
width: "14",
|
|
@@ -2363,7 +2363,7 @@ function _n({ node: e, deleteNode: t, editor: r }) {
|
|
|
2363
2363
|
/* @__PURE__ */ D("button", {
|
|
2364
2364
|
type: "button",
|
|
2365
2365
|
className: "img-ctrl-btn",
|
|
2366
|
-
onClick:
|
|
2366
|
+
onClick: P,
|
|
2367
2367
|
title: "全屏",
|
|
2368
2368
|
children: /* @__PURE__ */ D("svg", {
|
|
2369
2369
|
width: "14",
|
|
@@ -2383,7 +2383,7 @@ function _n({ node: e, deleteNode: t, editor: r }) {
|
|
|
2383
2383
|
type: "button",
|
|
2384
2384
|
className: "img-ctrl-btn img-ctrl-btn--del",
|
|
2385
2385
|
onClick: () => {
|
|
2386
|
-
|
|
2386
|
+
dn() || ($(!0), f(!0));
|
|
2387
2387
|
},
|
|
2388
2388
|
title: "删除",
|
|
2389
2389
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2403,15 +2403,15 @@ function _n({ node: e, deleteNode: t, editor: r }) {
|
|
|
2403
2403
|
]
|
|
2404
2404
|
})]
|
|
2405
2405
|
}),
|
|
2406
|
-
i && !
|
|
2406
|
+
i && !ie && /* @__PURE__ */ O("div", {
|
|
2407
2407
|
className: "image-lightbox",
|
|
2408
|
-
onClick:
|
|
2408
|
+
onClick: te,
|
|
2409
2409
|
children: [/* @__PURE__ */ O("div", {
|
|
2410
2410
|
className: "image-lightbox-bar",
|
|
2411
2411
|
children: [/* @__PURE__ */ D("button", {
|
|
2412
2412
|
type: "button",
|
|
2413
2413
|
className: "image-lightbox-bar-btn",
|
|
2414
|
-
onClick:
|
|
2414
|
+
onClick: re,
|
|
2415
2415
|
title: "全屏",
|
|
2416
2416
|
children: /* @__PURE__ */ D("svg", {
|
|
2417
2417
|
width: "18",
|
|
@@ -2429,7 +2429,7 @@ function _n({ node: e, deleteNode: t, editor: r }) {
|
|
|
2429
2429
|
}), /* @__PURE__ */ D("button", {
|
|
2430
2430
|
type: "button",
|
|
2431
2431
|
className: "image-lightbox-bar-btn",
|
|
2432
|
-
onClick:
|
|
2432
|
+
onClick: te,
|
|
2433
2433
|
title: "关闭",
|
|
2434
2434
|
children: /* @__PURE__ */ D("svg", {
|
|
2435
2435
|
width: "18",
|
|
@@ -2470,16 +2470,16 @@ function _n({ node: e, deleteNode: t, editor: r }) {
|
|
|
2470
2470
|
}
|
|
2471
2471
|
})]
|
|
2472
2472
|
}),
|
|
2473
|
-
/* @__PURE__ */ D(
|
|
2473
|
+
/* @__PURE__ */ D(gn, {
|
|
2474
2474
|
open: d,
|
|
2475
2475
|
title: "确认删除图片",
|
|
2476
|
-
message:
|
|
2476
|
+
message: ie ? "该图片无法在当前环境加载,仅从编辑器中移除该图片节点,不影响存储文件。" : "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
2477
2477
|
onCancel: () => {
|
|
2478
2478
|
$(!1), f(!1);
|
|
2479
2479
|
},
|
|
2480
2480
|
onConfirm: async () => {
|
|
2481
|
-
if (!
|
|
2482
|
-
await
|
|
2481
|
+
if (!ie) try {
|
|
2482
|
+
await zt(p);
|
|
2483
2483
|
} catch {}
|
|
2484
2484
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
2485
2485
|
}
|
|
@@ -2489,7 +2489,7 @@ function _n({ node: e, deleteNode: t, editor: r }) {
|
|
|
2489
2489
|
}
|
|
2490
2490
|
//#endregion
|
|
2491
2491
|
//#region src/editor/embeds/attachment-view.tsx
|
|
2492
|
-
var
|
|
2492
|
+
var yn = y(() => import("@file-viewer/react")), bn = /* @__PURE__ */ new Set(), xn = {
|
|
2493
2493
|
rendererMode: "replace",
|
|
2494
2494
|
autoRenderers: !0,
|
|
2495
2495
|
theme: "light",
|
|
@@ -2518,7 +2518,7 @@ var vn = y(() => import("@file-viewer/react")), yn = /* @__PURE__ */ new Set(),
|
|
|
2518
2518
|
cache: !0,
|
|
2519
2519
|
workerTimeoutMs: 3e4
|
|
2520
2520
|
}
|
|
2521
|
-
},
|
|
2521
|
+
}, Sn = {
|
|
2522
2522
|
pdf: "pdf",
|
|
2523
2523
|
docx: "word",
|
|
2524
2524
|
docm: "word",
|
|
@@ -2573,7 +2573,7 @@ var vn = y(() => import("@file-viewer/react")), yn = /* @__PURE__ */ new Set(),
|
|
|
2573
2573
|
xml: "text",
|
|
2574
2574
|
yml: "text",
|
|
2575
2575
|
yaml: "text"
|
|
2576
|
-
},
|
|
2576
|
+
}, Cn = {
|
|
2577
2577
|
pdf: () => import("@file-viewer/renderer-pdf").then((e) => e.pdfRenderer),
|
|
2578
2578
|
word: () => import("@file-viewer/renderer-word").then((e) => e.wordRenderer),
|
|
2579
2579
|
spreadsheet: () => import("@file-viewer/renderer-spreadsheet").then((e) => e.spreadsheetRenderer),
|
|
@@ -2581,10 +2581,10 @@ var vn = y(() => import("@file-viewer/react")), yn = /* @__PURE__ */ new Set(),
|
|
|
2581
2581
|
archive: () => import("@file-viewer/renderer-archive").then((e) => e.archiveRenderer),
|
|
2582
2582
|
text: () => import("@file-viewer/renderer-text").then((e) => e.textRenderer)
|
|
2583
2583
|
};
|
|
2584
|
-
function
|
|
2584
|
+
function wn(e) {
|
|
2585
2585
|
return e ? e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1048576).toFixed(1)} MB` : "";
|
|
2586
2586
|
}
|
|
2587
|
-
function
|
|
2587
|
+
function Tn(e) {
|
|
2588
2588
|
let t = e.split(".").pop()?.toLowerCase() || "", n = {
|
|
2589
2589
|
pdf: {
|
|
2590
2590
|
label: "PDF",
|
|
@@ -2757,22 +2757,22 @@ function wn(e) {
|
|
|
2757
2757
|
]
|
|
2758
2758
|
});
|
|
2759
2759
|
}
|
|
2760
|
-
function
|
|
2760
|
+
function En(e) {
|
|
2761
2761
|
return e.split(".").pop()?.toLowerCase() || "";
|
|
2762
2762
|
}
|
|
2763
|
-
function
|
|
2763
|
+
function Dn(e) {
|
|
2764
2764
|
let t = e.split(".").pop()?.toLowerCase() || "";
|
|
2765
2765
|
return /^(pdf|docx?|dotx?|xlsx?|xltx?|pptx?|potx?|txt|md|html?|csv|json|xml|yml|yaml|log|zip|rar|7z|tar|gz|odt|ods|odp|rtf|xlsm|xlsb|ppsx|numbers|tgz|bz2|xz|zst|js|ts|tsx|py|sh|sql)$/.test(t);
|
|
2766
2766
|
}
|
|
2767
|
-
function
|
|
2767
|
+
function On(e) {
|
|
2768
2768
|
return !!e && !e.startsWith("file:");
|
|
2769
2769
|
}
|
|
2770
|
-
function
|
|
2770
|
+
function kn(e) {
|
|
2771
2771
|
return btoa(encodeURIComponent(e)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
2772
2772
|
}
|
|
2773
|
-
async function
|
|
2773
|
+
async function An(e, t) {
|
|
2774
2774
|
try {
|
|
2775
|
-
let n =
|
|
2775
|
+
let n = kn(e), r = await fetch(`/api/preview/${n}`, {
|
|
2776
2776
|
signal: t,
|
|
2777
2777
|
cache: "no-store"
|
|
2778
2778
|
});
|
|
@@ -2784,7 +2784,7 @@ async function kn(e, t) {
|
|
|
2784
2784
|
return null;
|
|
2785
2785
|
}
|
|
2786
2786
|
}
|
|
2787
|
-
function
|
|
2787
|
+
function jn(e, t, n) {
|
|
2788
2788
|
return new Promise((r, i) => {
|
|
2789
2789
|
let a = new XMLHttpRequest();
|
|
2790
2790
|
if (a.open("GET", e, !0), a.responseType = "arraybuffer", t) {
|
|
@@ -2822,72 +2822,72 @@ function An(e, t, n) {
|
|
|
2822
2822
|
a.send();
|
|
2823
2823
|
});
|
|
2824
2824
|
}
|
|
2825
|
-
function
|
|
2826
|
-
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() =>
|
|
2825
|
+
function Mn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
2826
|
+
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() => bn.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), ee = w(0), te = w(!1), P = w(null), re = w(0), [ie, ae] = T(!1), F = w(null), [oe, I] = T(0), [L, R] = T("none"), [se, ce] = T(void 0), [le, ue] = T(!1), z = e.attrs.src || "", B = e.attrs.name || z && z.split("/").pop()?.split("?")[0] || (z ? "attachment" : f("editor.attachment.lost")), de = e.attrs.size || 0, V = En(B), H = !z;
|
|
2827
2827
|
x(() => {
|
|
2828
2828
|
if (!c) {
|
|
2829
|
-
|
|
2829
|
+
ce(void 0), ue(!1);
|
|
2830
2830
|
return;
|
|
2831
2831
|
}
|
|
2832
|
-
let e =
|
|
2832
|
+
let e = Sn[V];
|
|
2833
2833
|
if (!e) {
|
|
2834
|
-
|
|
2834
|
+
ce(void 0), ue(!1);
|
|
2835
2835
|
return;
|
|
2836
2836
|
}
|
|
2837
2837
|
let t = !0;
|
|
2838
|
-
return
|
|
2839
|
-
t &&
|
|
2838
|
+
return ce(void 0), ue(!1), Cn[e]().then((e) => {
|
|
2839
|
+
t && ce(e);
|
|
2840
2840
|
}).catch((n) => {
|
|
2841
|
-
console.error(`[attachment] renderer "${e}" load failed:`, n), t &&
|
|
2841
|
+
console.error(`[attachment] renderer "${e}" load failed:`, n), t && ue(!0);
|
|
2842
2842
|
}), () => {
|
|
2843
2843
|
t = !1;
|
|
2844
2844
|
};
|
|
2845
|
-
}, [c,
|
|
2846
|
-
let
|
|
2847
|
-
...
|
|
2845
|
+
}, [c, V]);
|
|
2846
|
+
let fe = C(() => ({
|
|
2847
|
+
...xn,
|
|
2848
2848
|
renderers: se ? [se] : [],
|
|
2849
2849
|
rendererMode: "replace"
|
|
2850
|
-
}), [se]),
|
|
2850
|
+
}), [se]), pe = b((e) => {
|
|
2851
2851
|
l((t) => {
|
|
2852
2852
|
let n = typeof e == "function" ? e(t) : e;
|
|
2853
|
-
return
|
|
2853
|
+
return z && (n ? bn.add(z) : bn.delete(z)), n;
|
|
2854
2854
|
});
|
|
2855
|
-
}, [
|
|
2855
|
+
}, [z]);
|
|
2856
2856
|
x(() => {
|
|
2857
|
-
l(
|
|
2858
|
-
}, [
|
|
2859
|
-
let
|
|
2860
|
-
|
|
2861
|
-
window.scrollTo(0,
|
|
2857
|
+
l(z ? bn.has(z) : !1);
|
|
2858
|
+
}, [z]);
|
|
2859
|
+
let U = b(() => {
|
|
2860
|
+
te.current = !0, pe(!0), window.setTimeout(() => {
|
|
2861
|
+
window.scrollTo(0, ee.current), P.current && (P.current.scrollTop = re.current), te.current && pe(!0), te.current = !1;
|
|
2862
2862
|
}, 0);
|
|
2863
|
-
}, [
|
|
2864
|
-
|
|
2865
|
-
}, [
|
|
2863
|
+
}, [pe]), me = b(async () => {
|
|
2864
|
+
L === "web" ? (R("none"), document.body.style.overflow = "", U()) : (L === "native" && document.fullscreenElement && await document.exitFullscreen(), ee.current = window.scrollY, re.current = P.current?.scrollTop ?? 0, document.body.style.overflow = "hidden", R("web"));
|
|
2865
|
+
}, [L]), W = b(async () => {
|
|
2866
2866
|
let e = M.current;
|
|
2867
|
-
e && (
|
|
2868
|
-
}, [
|
|
2869
|
-
|
|
2870
|
-
}, [
|
|
2867
|
+
e && (L === "native" ? await document.exitFullscreen() : (L === "web" && (R("none"), document.body.style.overflow = ""), ee.current = window.scrollY, re.current = P.current?.scrollTop ?? 0, await e.requestFullscreen(), R("native")));
|
|
2868
|
+
}, [L, U]), he = b(() => {
|
|
2869
|
+
L === "none" && (te.current || pe((e) => !e));
|
|
2870
|
+
}, [L]);
|
|
2871
2871
|
x(() => {
|
|
2872
2872
|
let e = () => {
|
|
2873
|
-
document.fullscreenElement || (
|
|
2873
|
+
document.fullscreenElement || (L === "native" && R("none"), U());
|
|
2874
2874
|
}, t = (e) => {
|
|
2875
|
-
e.key === "Escape" &&
|
|
2875
|
+
e.key === "Escape" && L === "web" && (R("none"), document.body.style.overflow = "", U());
|
|
2876
2876
|
};
|
|
2877
2877
|
return document.addEventListener("fullscreenchange", e), window.addEventListener("keydown", t), () => {
|
|
2878
2878
|
document.removeEventListener("fullscreenchange", e), window.removeEventListener("keydown", t);
|
|
2879
2879
|
};
|
|
2880
|
-
}, [
|
|
2880
|
+
}, [L, U]), x(() => {
|
|
2881
2881
|
let e = (e) => {
|
|
2882
|
-
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && i && !
|
|
2882
|
+
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && i && !dn()) {
|
|
2883
2883
|
if (e.preventDefault(), e.stopPropagation(), a) {
|
|
2884
2884
|
let { from: e, to: t } = a.state.selection;
|
|
2885
|
-
|
|
2885
|
+
F.current = {
|
|
2886
2886
|
from: e,
|
|
2887
2887
|
to: t
|
|
2888
2888
|
};
|
|
2889
2889
|
}
|
|
2890
|
-
window.getSelection()?.removeAllRanges(), $(!0),
|
|
2890
|
+
window.getSelection()?.removeAllRanges(), $(!0), ae(!0);
|
|
2891
2891
|
}
|
|
2892
2892
|
};
|
|
2893
2893
|
return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
|
|
@@ -2896,29 +2896,29 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2896
2896
|
a,
|
|
2897
2897
|
o
|
|
2898
2898
|
]), x(() => {
|
|
2899
|
-
if (!c || !
|
|
2899
|
+
if (!c || !On(z)) {
|
|
2900
2900
|
d(null), y(null), N.current = null;
|
|
2901
2901
|
return;
|
|
2902
2902
|
}
|
|
2903
|
-
if (N.current ===
|
|
2903
|
+
if (N.current === z) return;
|
|
2904
2904
|
let e = new AbortController(), r = !0;
|
|
2905
2905
|
return g(!0), y(null), (async () => {
|
|
2906
|
-
let i =
|
|
2907
|
-
if (!a && !i && (a = await
|
|
2908
|
-
let n = await t(
|
|
2909
|
-
n && (a = await
|
|
2906
|
+
let i = z.includes("?X-Amz-"), a = null, o = null;
|
|
2907
|
+
if (!a && !i && (a = await An(z, e.signal)), !a && !i) try {
|
|
2908
|
+
let n = await t(z);
|
|
2909
|
+
n && (a = await An(n, e.signal) || await jn(n, void 0, e.signal));
|
|
2910
2910
|
} catch (e) {
|
|
2911
2911
|
console.warn("[attachment] signPreviewUrl failed:", e);
|
|
2912
2912
|
}
|
|
2913
2913
|
if (!a && !i) try {
|
|
2914
|
-
let t = await n(
|
|
2914
|
+
let t = await n(z);
|
|
2915
2915
|
if (t) {
|
|
2916
2916
|
let n = { "X-Requested-With": "XMLHttpRequest" };
|
|
2917
2917
|
t.forEach((e, t) => {
|
|
2918
2918
|
n[t] = e;
|
|
2919
2919
|
});
|
|
2920
2920
|
try {
|
|
2921
|
-
a = await
|
|
2921
|
+
a = await jn(z, n, e.signal);
|
|
2922
2922
|
} catch (e) {
|
|
2923
2923
|
console.warn("[attachment] signed headers XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
2924
2924
|
}
|
|
@@ -2927,18 +2927,18 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2927
2927
|
console.warn("[attachment] signPreviewUrlHeaders failed:", e);
|
|
2928
2928
|
}
|
|
2929
2929
|
if (!a) try {
|
|
2930
|
-
a = await
|
|
2930
|
+
a = await jn(z, i ? void 0 : { "X-Requested-With": "XMLHttpRequest" }, e.signal);
|
|
2931
2931
|
} catch (e) {
|
|
2932
2932
|
console.warn("[attachment] plain XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
2933
2933
|
}
|
|
2934
2934
|
if (!a) throw o || /* @__PURE__ */ Error("所有 fetch 方法均失败");
|
|
2935
2935
|
if (!r) return;
|
|
2936
|
-
d(a), N.current =
|
|
2936
|
+
d(a), N.current = z;
|
|
2937
2937
|
let s = URL.createObjectURL(new Blob([a], { type: "application/octet-stream" }));
|
|
2938
2938
|
m(s), g(!1);
|
|
2939
2939
|
})().catch((e) => {
|
|
2940
2940
|
if (r && !(e instanceof DOMException && e.name === "AbortError")) {
|
|
2941
|
-
if (N.current ===
|
|
2941
|
+
if (N.current === z) {
|
|
2942
2942
|
g(!1);
|
|
2943
2943
|
return;
|
|
2944
2944
|
}
|
|
@@ -2947,49 +2947,49 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2947
2947
|
}), () => {
|
|
2948
2948
|
r = !1, e.abort();
|
|
2949
2949
|
};
|
|
2950
|
-
}, [c,
|
|
2950
|
+
}, [c, z]), x(() => () => {
|
|
2951
2951
|
p && URL.revokeObjectURL(p), d(null);
|
|
2952
2952
|
}, []), x(() => () => {
|
|
2953
2953
|
p && URL.revokeObjectURL(p), m(null), d(null), N.current = null;
|
|
2954
|
-
}, [
|
|
2954
|
+
}, [z]), x(() => {
|
|
2955
2955
|
if (k !== "success" && k !== "error") return;
|
|
2956
2956
|
let e = window.setTimeout(() => A(null), 2400);
|
|
2957
2957
|
return () => window.clearTimeout(e);
|
|
2958
2958
|
}, [k]);
|
|
2959
|
-
let
|
|
2959
|
+
let G = b(async () => {
|
|
2960
2960
|
E(!0), A("loading");
|
|
2961
2961
|
try {
|
|
2962
2962
|
if (p) {
|
|
2963
2963
|
let e = document.createElement("a");
|
|
2964
|
-
e.href = p, e.download =
|
|
2964
|
+
e.href = p, e.download = B, document.body.appendChild(e), e.click(), document.body.removeChild(e), A("success");
|
|
2965
2965
|
return;
|
|
2966
2966
|
}
|
|
2967
|
-
let e =
|
|
2967
|
+
let e = z.includes("?X-Amz-"), r = null;
|
|
2968
2968
|
if (!e) try {
|
|
2969
|
-
let e = await t(
|
|
2969
|
+
let e = await t(z);
|
|
2970
2970
|
e && (r = await fetch(e, { headers: { "X-Requested-With": "XMLHttpRequest" } }), r.ok || (r = null));
|
|
2971
2971
|
} catch {}
|
|
2972
2972
|
if (!r && !e) try {
|
|
2973
|
-
let e = await n(
|
|
2974
|
-
e && (r = await fetch(
|
|
2973
|
+
let e = await n(z);
|
|
2974
|
+
e && (r = await fetch(z, { headers: (() => {
|
|
2975
2975
|
let t = new Headers(e);
|
|
2976
2976
|
return t.set("X-Requested-With", "XMLHttpRequest"), t;
|
|
2977
2977
|
})() }), r.ok || (r = null));
|
|
2978
2978
|
} catch {}
|
|
2979
|
-
if (r ||= await fetch(
|
|
2979
|
+
if (r ||= await fetch(z, { headers: { "X-Requested-With": "XMLHttpRequest" } }), !r || !r.ok) throw Error("下载失败");
|
|
2980
2980
|
let i = await r.blob(), a = URL.createObjectURL(i), o = document.createElement("a");
|
|
2981
|
-
o.href = a, o.download =
|
|
2981
|
+
o.href = a, o.download = B, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(a), A("success");
|
|
2982
2982
|
} catch (e) {
|
|
2983
2983
|
console.error("[attachment] download failed:", e), A("error");
|
|
2984
2984
|
} finally {
|
|
2985
2985
|
E(!1);
|
|
2986
2986
|
}
|
|
2987
2987
|
}, [
|
|
2988
|
+
z,
|
|
2988
2989
|
B,
|
|
2989
|
-
V,
|
|
2990
2990
|
p
|
|
2991
2991
|
]);
|
|
2992
|
-
return /* @__PURE__ */ O(
|
|
2992
|
+
return /* @__PURE__ */ O(ne, {
|
|
2993
2993
|
ref: j,
|
|
2994
2994
|
as: "div",
|
|
2995
2995
|
className: `attachment-embed group/att ${i ? "is-selected" : ""}`,
|
|
@@ -3006,7 +3006,7 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3006
3006
|
className: "att-info",
|
|
3007
3007
|
children: [/* @__PURE__ */ D("span", {
|
|
3008
3008
|
className: "att-icon",
|
|
3009
|
-
children:
|
|
3009
|
+
children: H ? /* @__PURE__ */ O("svg", {
|
|
3010
3010
|
width: "22",
|
|
3011
3011
|
height: "22",
|
|
3012
3012
|
viewBox: "0 0 24 24",
|
|
@@ -3022,15 +3022,15 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3022
3022
|
/* @__PURE__ */ D("path", { d: "M12 9v4" }),
|
|
3023
3023
|
/* @__PURE__ */ D("path", { d: "M12 17h.01" })
|
|
3024
3024
|
]
|
|
3025
|
-
}) :
|
|
3025
|
+
}) : Tn(B)
|
|
3026
3026
|
}), /* @__PURE__ */ O("div", {
|
|
3027
3027
|
className: "att-meta",
|
|
3028
3028
|
children: [/* @__PURE__ */ D("span", {
|
|
3029
3029
|
className: "att-name",
|
|
3030
|
-
children:
|
|
3031
|
-
}),
|
|
3030
|
+
children: B
|
|
3031
|
+
}), de > 0 && /* @__PURE__ */ D("span", {
|
|
3032
3032
|
className: "att-size",
|
|
3033
|
-
children:
|
|
3033
|
+
children: wn(de)
|
|
3034
3034
|
})]
|
|
3035
3035
|
})]
|
|
3036
3036
|
}), /* @__PURE__ */ O("div", {
|
|
@@ -3083,11 +3083,11 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3083
3083
|
}), /* @__PURE__ */ O("div", {
|
|
3084
3084
|
className: "att-actions",
|
|
3085
3085
|
children: [
|
|
3086
|
-
|
|
3086
|
+
z && Dn(B) && /* @__PURE__ */ D("button", {
|
|
3087
3087
|
type: "button",
|
|
3088
3088
|
className: "att-btn",
|
|
3089
3089
|
onMouseDown: (e) => {
|
|
3090
|
-
e.preventDefault(), e.stopPropagation(),
|
|
3090
|
+
e.preventDefault(), e.stopPropagation(), he();
|
|
3091
3091
|
},
|
|
3092
3092
|
title: f("editor.attachment.preview"),
|
|
3093
3093
|
"aria-label": f("editor.attachment.preview"),
|
|
@@ -3113,8 +3113,8 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3113
3113
|
/* @__PURE__ */ D("button", {
|
|
3114
3114
|
type: "button",
|
|
3115
3115
|
className: "att-btn",
|
|
3116
|
-
onClick:
|
|
3117
|
-
disabled: S ||
|
|
3116
|
+
onClick: G,
|
|
3117
|
+
disabled: S || H,
|
|
3118
3118
|
title: S ? "正在准备下载" : f("editor.attachment.download"),
|
|
3119
3119
|
"aria-label": S ? "正在准备下载" : f("editor.attachment.download"),
|
|
3120
3120
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -3136,7 +3136,7 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3136
3136
|
type: "button",
|
|
3137
3137
|
className: "att-btn att-btn--del",
|
|
3138
3138
|
onClick: () => {
|
|
3139
|
-
!o ||
|
|
3139
|
+
!o || dn() || ($(!0), ae(!0));
|
|
3140
3140
|
},
|
|
3141
3141
|
title: f("editor.attachment.delete"),
|
|
3142
3142
|
"aria-label": f("editor.attachment.delete"),
|
|
@@ -3160,7 +3160,7 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3160
3160
|
})]
|
|
3161
3161
|
}), c && /* @__PURE__ */ O("div", {
|
|
3162
3162
|
ref: M,
|
|
3163
|
-
className: `att-preview-wrap ${
|
|
3163
|
+
className: `att-preview-wrap ${L === "web" ? "is-web-fs" : ""}`,
|
|
3164
3164
|
style: {
|
|
3165
3165
|
position: "relative",
|
|
3166
3166
|
height: 500,
|
|
@@ -3168,7 +3168,7 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3168
3168
|
background: "#fff"
|
|
3169
3169
|
},
|
|
3170
3170
|
children: [/* @__PURE__ */ D("div", {
|
|
3171
|
-
ref:
|
|
3171
|
+
ref: P,
|
|
3172
3172
|
className: "att-preview-scroll",
|
|
3173
3173
|
style: {
|
|
3174
3174
|
height: "100%",
|
|
@@ -3177,7 +3177,7 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3177
3177
|
children: h && !u && !p ? /* @__PURE__ */ D("div", {
|
|
3178
3178
|
className: "flex items-center justify-center h-full text-default-400 text-sm",
|
|
3179
3179
|
children: f("editor.attachment.loadingPreview")
|
|
3180
|
-
}) : (_ ||
|
|
3180
|
+
}) : (_ || le) && !u && !p ? /* @__PURE__ */ O("div", {
|
|
3181
3181
|
className: "flex h-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-default-500",
|
|
3182
3182
|
children: [/* @__PURE__ */ D("div", {
|
|
3183
3183
|
className: "font-medium text-default-700",
|
|
@@ -3192,15 +3192,15 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3192
3192
|
style: { background: "#fff" },
|
|
3193
3193
|
children: f("editor.attachment.loadingPreview")
|
|
3194
3194
|
}),
|
|
3195
|
-
children: u || p ||
|
|
3195
|
+
children: u || p || z ? se ? /* @__PURE__ */ D(yn, {
|
|
3196
3196
|
buffer: u || void 0,
|
|
3197
|
-
url: p ||
|
|
3198
|
-
name:
|
|
3199
|
-
filename:
|
|
3200
|
-
type:
|
|
3201
|
-
size:
|
|
3202
|
-
options:
|
|
3203
|
-
}, `${
|
|
3197
|
+
url: p || z,
|
|
3198
|
+
name: B,
|
|
3199
|
+
filename: B,
|
|
3200
|
+
type: V,
|
|
3201
|
+
size: de || u?.byteLength || 0,
|
|
3202
|
+
options: fe
|
|
3203
|
+
}, `${z}-${oe}`) : /* @__PURE__ */ D("div", {
|
|
3204
3204
|
className: "flex h-full items-center justify-center text-sm text-default-400",
|
|
3205
3205
|
children: "正在加载预览引擎..."
|
|
3206
3206
|
}) : /* @__PURE__ */ D("div", {
|
|
@@ -3227,15 +3227,15 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3227
3227
|
},
|
|
3228
3228
|
children: [/* @__PURE__ */ D("button", {
|
|
3229
3229
|
type: "button",
|
|
3230
|
-
onClick:
|
|
3231
|
-
title:
|
|
3232
|
-
"aria-label":
|
|
3230
|
+
onClick: me,
|
|
3231
|
+
title: L === "web" ? "退出网页全屏" : "网页全屏",
|
|
3232
|
+
"aria-label": L === "web" ? "退出网页全屏" : "网页全屏",
|
|
3233
3233
|
style: {
|
|
3234
3234
|
width: 28,
|
|
3235
3235
|
height: 28,
|
|
3236
3236
|
borderRadius: 6,
|
|
3237
3237
|
border: "none",
|
|
3238
|
-
background:
|
|
3238
|
+
background: L === "web" ? "#e4e4e7" : "transparent",
|
|
3239
3239
|
cursor: "pointer",
|
|
3240
3240
|
display: "flex",
|
|
3241
3241
|
alignItems: "center",
|
|
@@ -3244,10 +3244,10 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3244
3244
|
transition: "background 0.12s"
|
|
3245
3245
|
},
|
|
3246
3246
|
onMouseEnter: (e) => {
|
|
3247
|
-
|
|
3247
|
+
L !== "web" && (e.currentTarget.style.background = "#f4f4f5");
|
|
3248
3248
|
},
|
|
3249
3249
|
onMouseLeave: (e) => {
|
|
3250
|
-
|
|
3250
|
+
L !== "web" && (e.currentTarget.style.background = "transparent");
|
|
3251
3251
|
},
|
|
3252
3252
|
children: /* @__PURE__ */ D("svg", {
|
|
3253
3253
|
width: "14",
|
|
@@ -3265,15 +3265,15 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3265
3265
|
})
|
|
3266
3266
|
}), /* @__PURE__ */ D("button", {
|
|
3267
3267
|
type: "button",
|
|
3268
|
-
onClick:
|
|
3269
|
-
title:
|
|
3270
|
-
"aria-label":
|
|
3268
|
+
onClick: W,
|
|
3269
|
+
title: L === "native" ? "退出全屏" : "全屏",
|
|
3270
|
+
"aria-label": L === "native" ? "退出全屏" : "全屏",
|
|
3271
3271
|
style: {
|
|
3272
3272
|
width: 28,
|
|
3273
3273
|
height: 28,
|
|
3274
3274
|
borderRadius: 6,
|
|
3275
3275
|
border: "none",
|
|
3276
|
-
background:
|
|
3276
|
+
background: L === "native" ? "#e4e4e7" : "transparent",
|
|
3277
3277
|
cursor: "pointer",
|
|
3278
3278
|
display: "flex",
|
|
3279
3279
|
alignItems: "center",
|
|
@@ -3282,10 +3282,10 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3282
3282
|
transition: "background 0.12s"
|
|
3283
3283
|
},
|
|
3284
3284
|
onMouseEnter: (e) => {
|
|
3285
|
-
|
|
3285
|
+
L !== "native" && (e.currentTarget.style.background = "#f4f4f5");
|
|
3286
3286
|
},
|
|
3287
3287
|
onMouseLeave: (e) => {
|
|
3288
|
-
|
|
3288
|
+
L !== "native" && (e.currentTarget.style.background = "transparent");
|
|
3289
3289
|
},
|
|
3290
3290
|
children: /* @__PURE__ */ D("svg", {
|
|
3291
3291
|
width: "14",
|
|
@@ -3304,24 +3304,24 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3304
3304
|
})]
|
|
3305
3305
|
})]
|
|
3306
3306
|
})]
|
|
3307
|
-
}), /* @__PURE__ */ D(
|
|
3308
|
-
open:
|
|
3307
|
+
}), /* @__PURE__ */ D(gn, {
|
|
3308
|
+
open: ie,
|
|
3309
3309
|
title: "确认删除附件",
|
|
3310
|
-
message:
|
|
3310
|
+
message: H ? "此操作将删除该附件节点,不可撤销。" : `此操作将同时删除对象存储中的文件(${B}),不可撤销。`,
|
|
3311
3311
|
onCancel: () => {
|
|
3312
|
-
$(!1),
|
|
3312
|
+
$(!1), ae(!1);
|
|
3313
3313
|
},
|
|
3314
3314
|
onConfirm: async () => {
|
|
3315
3315
|
try {
|
|
3316
3316
|
if (a) {
|
|
3317
|
-
let e =
|
|
3317
|
+
let e = F.current, t = e?.from ?? a.state.selection.from, n = e?.to ?? a.state.selection.to, r = [];
|
|
3318
3318
|
a.state.doc.nodesBetween(t, n, (e) => {
|
|
3319
|
-
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(
|
|
3319
|
+
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(zt(e.attrs.src));
|
|
3320
3320
|
}), await Promise.all(r), $(!1), await new Promise((e) => setTimeout(e, 300)), a.chain().focus().setTextSelection({
|
|
3321
3321
|
from: t,
|
|
3322
3322
|
to: n
|
|
3323
3323
|
}).deleteSelection().run();
|
|
3324
|
-
} else await
|
|
3324
|
+
} else await zt(z), $(!1), await new Promise((e) => setTimeout(e, 300)), r();
|
|
3325
3325
|
} catch {
|
|
3326
3326
|
$(!1);
|
|
3327
3327
|
}
|
|
@@ -3331,13 +3331,13 @@ function jn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3331
3331
|
}
|
|
3332
3332
|
//#endregion
|
|
3333
3333
|
//#region src/editor/embeds/attachment.ts
|
|
3334
|
-
var
|
|
3334
|
+
var Nn = oe.create({
|
|
3335
3335
|
name: "attachmentEmbed",
|
|
3336
3336
|
group: "block",
|
|
3337
3337
|
atom: !0,
|
|
3338
3338
|
inline: !1,
|
|
3339
3339
|
addNodeView() {
|
|
3340
|
-
return
|
|
3340
|
+
return P(Mn);
|
|
3341
3341
|
},
|
|
3342
3342
|
addAttributes() {
|
|
3343
3343
|
return {
|
|
@@ -3386,7 +3386,7 @@ var Mn = ie.create({
|
|
|
3386
3386
|
});
|
|
3387
3387
|
//#endregion
|
|
3388
3388
|
//#region src/editor/embeds/audio-view.tsx
|
|
3389
|
-
function
|
|
3389
|
+
function Pn({ node: e, deleteNode: t, editor: r }) {
|
|
3390
3390
|
let i = e.attrs.src || "", a = e.attrs.name || i.split("/").pop()?.split("?")[0] || "audio", [o, s] = T(!1), c = r?.isEditable ?? !0;
|
|
3391
3391
|
x(() => () => {
|
|
3392
3392
|
i.startsWith("blob:") && URL.revokeObjectURL(i);
|
|
@@ -3418,7 +3418,7 @@ function Nn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3418
3418
|
})(), () => {
|
|
3419
3419
|
e = !0, m.current &&= (URL.revokeObjectURL(m.current), null);
|
|
3420
3420
|
};
|
|
3421
|
-
}, [i]), /* @__PURE__ */ O(
|
|
3421
|
+
}, [i]), /* @__PURE__ */ O(ne, {
|
|
3422
3422
|
as: "div",
|
|
3423
3423
|
className: "audio-embed group/audio",
|
|
3424
3424
|
style: { margin: "1rem 0" },
|
|
@@ -3452,7 +3452,7 @@ function Nn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3452
3452
|
type: "button",
|
|
3453
3453
|
className: "audio-embed-btn audio-embed-btn--del",
|
|
3454
3454
|
onClick: () => {
|
|
3455
|
-
|
|
3455
|
+
dn() || ($(!0), s(!0));
|
|
3456
3456
|
},
|
|
3457
3457
|
title: "删除",
|
|
3458
3458
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -3498,7 +3498,7 @@ function Nn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3498
3498
|
}), "音频文件缺失"]
|
|
3499
3499
|
})
|
|
3500
3500
|
})]
|
|
3501
|
-
}), /* @__PURE__ */ D(
|
|
3501
|
+
}), /* @__PURE__ */ D(gn, {
|
|
3502
3502
|
open: o,
|
|
3503
3503
|
title: "确认删除音频",
|
|
3504
3504
|
message: `此操作将同时删除对象存储中的文件(${a}),不可撤销。`,
|
|
@@ -3507,7 +3507,7 @@ function Nn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3507
3507
|
},
|
|
3508
3508
|
onConfirm: async () => {
|
|
3509
3509
|
try {
|
|
3510
|
-
await
|
|
3510
|
+
await zt(i);
|
|
3511
3511
|
} catch {}
|
|
3512
3512
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3513
3513
|
}
|
|
@@ -3516,16 +3516,16 @@ function Nn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3516
3516
|
}
|
|
3517
3517
|
//#endregion
|
|
3518
3518
|
//#region src/editor/embeds/audio.ts
|
|
3519
|
-
function
|
|
3519
|
+
function Fn(e) {
|
|
3520
3520
|
return /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|$)/i.test(e) || /\/.*\.(mp3|wav|ogg|flac)/i.test(e);
|
|
3521
3521
|
}
|
|
3522
|
-
var
|
|
3522
|
+
var In = oe.create({
|
|
3523
3523
|
name: "audioEmbed",
|
|
3524
3524
|
group: "block",
|
|
3525
3525
|
atom: !0,
|
|
3526
3526
|
inline: !1,
|
|
3527
3527
|
addNodeView() {
|
|
3528
|
-
return
|
|
3528
|
+
return P(Pn);
|
|
3529
3529
|
},
|
|
3530
3530
|
addProseMirrorPlugins() {
|
|
3531
3531
|
return [new L({ props: { handlePaste(e, t) {
|
|
@@ -3534,7 +3534,7 @@ var Fn = ie.create({
|
|
|
3534
3534
|
let r = n.split(/\r?\n/);
|
|
3535
3535
|
for (let n of r) {
|
|
3536
3536
|
let r = n.trim();
|
|
3537
|
-
if (!r || r.includes(" ") || !
|
|
3537
|
+
if (!r || r.includes(" ") || !Fn(r)) continue;
|
|
3538
3538
|
t.preventDefault();
|
|
3539
3539
|
let i = e.state.schema.nodes.audioEmbed.create({ src: r });
|
|
3540
3540
|
return e.dispatch(e.state.tr.replaceSelectionWith(i)), !0;
|
|
@@ -3581,17 +3581,17 @@ var Fn = ie.create({
|
|
|
3581
3581
|
});
|
|
3582
3582
|
//#endregion
|
|
3583
3583
|
//#region src/editor/embeds/video-view.tsx
|
|
3584
|
-
function
|
|
3584
|
+
function Ln(e) {
|
|
3585
3585
|
return e ? /bilibili\.com|BV[a-zA-Z0-9]{10}|av\d+/i.test(e) ? "bilibili" : /xiaohongshu\.com|xhslink\.com/i.test(e) ? "xiaohongshu" : /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|$)/i.test(e) || /\/.*\.(mp4|m3u8|mov|webm|flv|mkv)/i.test(e) ? "direct" : "unknown" : "unknown";
|
|
3586
3586
|
}
|
|
3587
|
-
function
|
|
3587
|
+
function Rn(e) {
|
|
3588
3588
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
3589
3589
|
if (t) return t[0];
|
|
3590
3590
|
let n = e.match(/av(\d+)/i);
|
|
3591
3591
|
return n ? n[0] : e;
|
|
3592
3592
|
}
|
|
3593
|
-
function
|
|
3594
|
-
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ?
|
|
3593
|
+
function zn({ node: e, deleteNode: t, editor: n }) {
|
|
3594
|
+
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ? Ln(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(gn, {
|
|
3595
3595
|
open: o,
|
|
3596
3596
|
title: "确认删除视频",
|
|
3597
3597
|
message: "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
@@ -3600,7 +3600,7 @@ function Rn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3600
3600
|
},
|
|
3601
3601
|
onConfirm: async () => {
|
|
3602
3602
|
try {
|
|
3603
|
-
await
|
|
3603
|
+
await zt(r);
|
|
3604
3604
|
} catch {}
|
|
3605
3605
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3606
3606
|
}
|
|
@@ -3614,7 +3614,7 @@ function Rn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3614
3614
|
e && (e.style.position === "fixed" ? A() : (e.style.position = "fixed", e.style.inset = "0", e.style.zIndex = "99999", e.style.borderRadius = "0", document.body.style.overflow = "hidden"));
|
|
3615
3615
|
}, [A]), N = b(() => {
|
|
3616
3616
|
k.current = window.scrollY, S.current?.requestFullscreen?.();
|
|
3617
|
-
}, []),
|
|
3617
|
+
}, []), ee = b(() => {
|
|
3618
3618
|
let e = v.current?.closest(".video-embed--direct") || v.current;
|
|
3619
3619
|
e && (k.current = window.scrollY, e.requestFullscreen?.());
|
|
3620
3620
|
}, []);
|
|
@@ -3703,8 +3703,8 @@ function Rn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3703
3703
|
}, [a, h]), x(() => {
|
|
3704
3704
|
u && (_.current?.destroy(), _.current = null);
|
|
3705
3705
|
}, [u]), a === "bilibili") {
|
|
3706
|
-
let e =
|
|
3707
|
-
return /* @__PURE__ */ O(
|
|
3706
|
+
let e = Rn(r);
|
|
3707
|
+
return /* @__PURE__ */ O(ne, {
|
|
3708
3708
|
as: "div",
|
|
3709
3709
|
className: "video-embed video-embed--bilibili group/video",
|
|
3710
3710
|
style: { margin: "1rem 0" },
|
|
@@ -3780,7 +3780,7 @@ function Rn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3780
3780
|
className: "video-fs-btn video-fs-btn--del",
|
|
3781
3781
|
title: "删除",
|
|
3782
3782
|
onClick: () => {
|
|
3783
|
-
|
|
3783
|
+
dn() || ($(!0), s(!0));
|
|
3784
3784
|
},
|
|
3785
3785
|
children: /* @__PURE__ */ D("svg", {
|
|
3786
3786
|
width: "12",
|
|
@@ -3822,7 +3822,7 @@ function Rn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3822
3822
|
}), m]
|
|
3823
3823
|
});
|
|
3824
3824
|
}
|
|
3825
|
-
return a === "xiaohongshu" ? /* @__PURE__ */ O(
|
|
3825
|
+
return a === "xiaohongshu" ? /* @__PURE__ */ O(ne, {
|
|
3826
3826
|
as: "div",
|
|
3827
3827
|
className: "video-embed video-embed--xiaohongshu",
|
|
3828
3828
|
style: {
|
|
@@ -3868,7 +3868,7 @@ function Rn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3868
3868
|
},
|
|
3869
3869
|
children: "在小红书中打开 →"
|
|
3870
3870
|
})] })]
|
|
3871
|
-
}) : /* @__PURE__ */ O(
|
|
3871
|
+
}) : /* @__PURE__ */ O(ne, {
|
|
3872
3872
|
as: "div",
|
|
3873
3873
|
className: "video-embed video-embed--direct group/video",
|
|
3874
3874
|
style: {
|
|
@@ -3887,7 +3887,7 @@ function Rn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3887
3887
|
className: "video-fs-btn video-fs-btn--del",
|
|
3888
3888
|
title: "删除",
|
|
3889
3889
|
onClick: () => {
|
|
3890
|
-
|
|
3890
|
+
dn() || ($(!0), s(!0));
|
|
3891
3891
|
},
|
|
3892
3892
|
children: /* @__PURE__ */ D("svg", {
|
|
3893
3893
|
width: "12",
|
|
@@ -3906,7 +3906,7 @@ function Rn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3906
3906
|
type: "button",
|
|
3907
3907
|
className: "video-fs-btn",
|
|
3908
3908
|
title: "全屏",
|
|
3909
|
-
onClick:
|
|
3909
|
+
onClick: ee,
|
|
3910
3910
|
children: /* @__PURE__ */ D("svg", {
|
|
3911
3911
|
width: "12",
|
|
3912
3912
|
height: "12",
|
|
@@ -4044,33 +4044,33 @@ function Rn({ node: e, deleteNode: t, editor: n }) {
|
|
|
4044
4044
|
}
|
|
4045
4045
|
//#endregion
|
|
4046
4046
|
//#region src/editor/embeds/video.ts
|
|
4047
|
-
function
|
|
4047
|
+
function Bn(e) {
|
|
4048
4048
|
return /bilibili\.com|BV[a-zA-Z0-9]{10}|av\d+/i.test(e) ? "bilibili" : /xiaohongshu\.com|xhslink\.com/i.test(e) ? "xiaohongshu" : /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|$)/i.test(e) || /\/.*\.(mp4|m3u8|mov|webm|flv|mkv)/i.test(e) ? "direct" : "unknown";
|
|
4049
4049
|
}
|
|
4050
|
-
function
|
|
4050
|
+
function Vn(e) {
|
|
4051
4051
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
4052
4052
|
if (t) return t[0];
|
|
4053
4053
|
let n = e.match(/av(\d+)/i);
|
|
4054
4054
|
return n ? n[0] : e;
|
|
4055
4055
|
}
|
|
4056
|
-
function
|
|
4056
|
+
function Hn(e) {
|
|
4057
4057
|
let t = e.match(/explore\/([a-zA-Z0-9]+)/);
|
|
4058
4058
|
return t ? t[1] : e;
|
|
4059
4059
|
}
|
|
4060
|
-
var
|
|
4060
|
+
var Un = oe.create({
|
|
4061
4061
|
name: "videoEmbed",
|
|
4062
4062
|
group: "block",
|
|
4063
4063
|
atom: !0,
|
|
4064
4064
|
inline: !1,
|
|
4065
4065
|
addNodeView() {
|
|
4066
|
-
return
|
|
4066
|
+
return P(zn);
|
|
4067
4067
|
},
|
|
4068
4068
|
addProseMirrorPlugins() {
|
|
4069
4069
|
return [new L({ props: {
|
|
4070
4070
|
handleKeyDown(e, t) {
|
|
4071
4071
|
if (t.key !== " ") return !1;
|
|
4072
4072
|
let n = e.state.selection;
|
|
4073
|
-
if (n instanceof
|
|
4073
|
+
if (n instanceof I && n.node.type.name === "videoEmbed") {
|
|
4074
4074
|
t.preventDefault();
|
|
4075
4075
|
let r = e.nodeDOM(n.from);
|
|
4076
4076
|
if (r) {
|
|
@@ -4088,7 +4088,7 @@ var Hn = ie.create({
|
|
|
4088
4088
|
for (let n of r) {
|
|
4089
4089
|
let r = n.trim();
|
|
4090
4090
|
if (!r || r.includes(" ")) continue;
|
|
4091
|
-
let i =
|
|
4091
|
+
let i = Bn(r);
|
|
4092
4092
|
if (i === "unknown") continue;
|
|
4093
4093
|
t.preventDefault();
|
|
4094
4094
|
let a = e.state.schema.nodes.videoEmbed.create({
|
|
@@ -4120,7 +4120,7 @@ var Hn = ie.create({
|
|
|
4120
4120
|
let t = e, n = t.getAttribute("src") || t.getAttribute("data-src") || "";
|
|
4121
4121
|
return {
|
|
4122
4122
|
src: n,
|
|
4123
|
-
source:
|
|
4123
|
+
source: Bn(n)
|
|
4124
4124
|
};
|
|
4125
4125
|
}
|
|
4126
4126
|
},
|
|
@@ -4129,9 +4129,9 @@ var Hn = ie.create({
|
|
|
4129
4129
|
];
|
|
4130
4130
|
},
|
|
4131
4131
|
renderHTML({ HTMLAttributes: e }) {
|
|
4132
|
-
let t = e.src || "", n =
|
|
4132
|
+
let t = e.src || "", n = Bn(t);
|
|
4133
4133
|
if (n === "bilibili") {
|
|
4134
|
-
let e =
|
|
4134
|
+
let e = Vn(t);
|
|
4135
4135
|
return [
|
|
4136
4136
|
"div",
|
|
4137
4137
|
{
|
|
@@ -4152,7 +4152,7 @@ var Hn = ie.create({
|
|
|
4152
4152
|
}]
|
|
4153
4153
|
];
|
|
4154
4154
|
}
|
|
4155
|
-
if (n === "xiaohongshu") return
|
|
4155
|
+
if (n === "xiaohongshu") return Hn(t), [
|
|
4156
4156
|
"div",
|
|
4157
4157
|
{
|
|
4158
4158
|
"data-video-embed": "xiaohongshu",
|
|
@@ -4204,7 +4204,7 @@ var Hn = ie.create({
|
|
|
4204
4204
|
},
|
|
4205
4205
|
addCommands() {
|
|
4206
4206
|
return { insertVideo: (e) => ({ chain: t }) => {
|
|
4207
|
-
let n =
|
|
4207
|
+
let n = Bn(e.src);
|
|
4208
4208
|
return t().insertContent({
|
|
4209
4209
|
type: this.name,
|
|
4210
4210
|
attrs: {
|
|
@@ -4214,13 +4214,13 @@ var Hn = ie.create({
|
|
|
4214
4214
|
}).focus().run();
|
|
4215
4215
|
} };
|
|
4216
4216
|
}
|
|
4217
|
-
}),
|
|
4218
|
-
async function
|
|
4219
|
-
|
|
4220
|
-
let t =
|
|
4217
|
+
}), Wn = null;
|
|
4218
|
+
async function Gn(e) {
|
|
4219
|
+
Wn ||= await import("beautiful-mermaid");
|
|
4220
|
+
let t = Wn.renderMermaidSVG;
|
|
4221
4221
|
return t(e);
|
|
4222
4222
|
}
|
|
4223
|
-
var
|
|
4223
|
+
var Kn = [
|
|
4224
4224
|
{
|
|
4225
4225
|
value: "javascript",
|
|
4226
4226
|
label: "JavaScript",
|
|
@@ -4381,7 +4381,7 @@ var Gn = [
|
|
|
4381
4381
|
label: "Plain Text",
|
|
4382
4382
|
color: "#6b7280"
|
|
4383
4383
|
}
|
|
4384
|
-
],
|
|
4384
|
+
], qn = {
|
|
4385
4385
|
javascript: "js",
|
|
4386
4386
|
typescript: "ts",
|
|
4387
4387
|
python: "py",
|
|
@@ -4407,7 +4407,7 @@ var Gn = [
|
|
|
4407
4407
|
txt: "txt",
|
|
4408
4408
|
vue: "vue",
|
|
4409
4409
|
react: "jsx"
|
|
4410
|
-
},
|
|
4410
|
+
}, Jn = {
|
|
4411
4411
|
js: "javascript",
|
|
4412
4412
|
ts: "typescript",
|
|
4413
4413
|
py: "python",
|
|
@@ -4423,13 +4423,13 @@ var Gn = [
|
|
|
4423
4423
|
jsx: "javascript",
|
|
4424
4424
|
tsx: "typescript"
|
|
4425
4425
|
};
|
|
4426
|
-
function
|
|
4426
|
+
function Yn(e) {
|
|
4427
4427
|
return e instanceof Element && !!e.closest(".cb-code-area");
|
|
4428
4428
|
}
|
|
4429
|
-
function
|
|
4430
|
-
let o = n?.isEditable ?? !0, s = !o, [c, l] = T(!1), [u, d] = T(!1), [f, m] = T(!1), [h, g] = T(""), [_, v] = T(!1), [y, k] = T(null), [A, j] = T(null), [M, N] = T(!1), [
|
|
4431
|
-
|
|
4432
|
-
}, []),
|
|
4429
|
+
function Xn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i, selected: a }) {
|
|
4430
|
+
let o = n?.isEditable ?? !0, s = !o, [c, l] = T(!1), [u, d] = T(!1), [f, m] = T(!1), [h, g] = T(""), [_, v] = T(!1), [y, k] = T(null), [A, j] = T(null), [M, N] = T(!1), [ee, P] = T([]), re = w(null), ie = w(null), ae = w(null), F = w(null), oe = w(null), I = e.attrs.language || "", L = Kn.find((e) => e.value === (Jn[I] ?? I)), R = I === "mermaid", se = b((e) => {
|
|
4431
|
+
Yn(e.target) || e.stopPropagation();
|
|
4432
|
+
}, []), ce = b(() => {
|
|
4433
4433
|
if (!n || typeof r != "function") return null;
|
|
4434
4434
|
let t = r();
|
|
4435
4435
|
return typeof t == "number" ? {
|
|
@@ -4440,18 +4440,18 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4440
4440
|
n,
|
|
4441
4441
|
r,
|
|
4442
4442
|
e.nodeSize
|
|
4443
|
-
]),
|
|
4444
|
-
o && (
|
|
4445
|
-
}, [
|
|
4443
|
+
]), le = b(() => {
|
|
4444
|
+
o && (dn() || (oe.current = ce(), window.getSelection()?.removeAllRanges(), $(!0), v(!0)));
|
|
4445
|
+
}, [ce, o]), ue = C(() => e.textContent ? e.textContent.split("\n") : [""], [e.textContent]), z = ue.length, B = C(() => Array.from({ length: z }, (e, t) => t + 1), [z]), de = C(() => {
|
|
4446
4446
|
let e = h.trim().toLowerCase();
|
|
4447
|
-
return e ?
|
|
4447
|
+
return e ? Kn.filter((t) => t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e)) : Kn;
|
|
4448
4448
|
}, [h]);
|
|
4449
4449
|
x(() => {
|
|
4450
|
-
f && (g(""), setTimeout(() =>
|
|
4450
|
+
f && (g(""), setTimeout(() => ie.current?.focus(), 50));
|
|
4451
4451
|
}, [f]), x(() => {
|
|
4452
4452
|
if (!f) return;
|
|
4453
4453
|
let e = (e) => {
|
|
4454
|
-
|
|
4454
|
+
re.current && !re.current.contains(e.target) && m(!1);
|
|
4455
4455
|
};
|
|
4456
4456
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
4457
4457
|
}, [f]), x(() => {
|
|
@@ -4462,10 +4462,10 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4462
4462
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
4463
4463
|
}, [f]), x(() => {
|
|
4464
4464
|
let e = (e) => {
|
|
4465
|
-
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && a && !
|
|
4465
|
+
if (!(e.key !== "Backspace" && e.key !== "Delete") && o && a && !dn()) {
|
|
4466
4466
|
if (e.preventDefault(), e.stopPropagation(), n) {
|
|
4467
4467
|
let { from: e, to: t } = n.state.selection;
|
|
4468
|
-
|
|
4468
|
+
oe.current = {
|
|
4469
4469
|
from: e,
|
|
4470
4470
|
to: t
|
|
4471
4471
|
};
|
|
@@ -4479,29 +4479,29 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4479
4479
|
n,
|
|
4480
4480
|
o
|
|
4481
4481
|
]);
|
|
4482
|
-
let
|
|
4483
|
-
|
|
4484
|
-
}, []),
|
|
4485
|
-
let e =
|
|
4482
|
+
let V = b((e) => {
|
|
4483
|
+
P((t) => t.length === e.length && t.every((t, n) => t === e[n]) ? t : e);
|
|
4484
|
+
}, []), H = b(() => {
|
|
4485
|
+
let e = ae.current, t = F.current;
|
|
4486
4486
|
if (!e || !t) return;
|
|
4487
4487
|
t.style.width = `${e.clientWidth}px`;
|
|
4488
4488
|
let n = t.children, r = Array(n.length);
|
|
4489
4489
|
for (let e = 0; e < n.length; e++) r[e] = n[e].offsetHeight;
|
|
4490
|
-
|
|
4491
|
-
}, [
|
|
4490
|
+
V(r);
|
|
4491
|
+
}, [V]);
|
|
4492
4492
|
S(() => {
|
|
4493
|
-
|
|
4494
|
-
}, [
|
|
4495
|
-
let e =
|
|
4493
|
+
H();
|
|
4494
|
+
}, [H, ue]), x(() => {
|
|
4495
|
+
let e = ae.current;
|
|
4496
4496
|
if (!e) return;
|
|
4497
|
-
let t = new ResizeObserver(() =>
|
|
4498
|
-
return t.observe(e), window.addEventListener("resize",
|
|
4499
|
-
t.disconnect(), window.removeEventListener("resize",
|
|
4497
|
+
let t = new ResizeObserver(() => H());
|
|
4498
|
+
return t.observe(e), window.addEventListener("resize", H), document.fonts?.ready?.then(() => H()), () => {
|
|
4499
|
+
t.disconnect(), window.removeEventListener("resize", H);
|
|
4500
4500
|
};
|
|
4501
|
-
}, [
|
|
4502
|
-
let
|
|
4501
|
+
}, [H]);
|
|
4502
|
+
let fe = b((e) => {
|
|
4503
4503
|
t({ language: e || null }), m(!1);
|
|
4504
|
-
}, [t]),
|
|
4504
|
+
}, [t]), pe = b(() => {
|
|
4505
4505
|
if (o) {
|
|
4506
4506
|
if (n && r) {
|
|
4507
4507
|
let e = r();
|
|
@@ -4513,12 +4513,12 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4513
4513
|
n,
|
|
4514
4514
|
r,
|
|
4515
4515
|
o
|
|
4516
|
-
]),
|
|
4516
|
+
]), U = b(() => {
|
|
4517
4517
|
navigator.clipboard.writeText(e.textContent), l(!0), setTimeout(() => l(!1), 1500);
|
|
4518
|
-
}, [e.textContent]),
|
|
4519
|
-
let t =
|
|
4518
|
+
}, [e.textContent]), me = b(() => {
|
|
4519
|
+
let t = qn[I] || "txt", n = t ? `code.${t}` : "code.txt", r = new Blob([e.textContent], { type: "text/plain;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
4520
4520
|
a.href = i, a.download = n, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
4521
|
-
}, [e.textContent,
|
|
4521
|
+
}, [e.textContent, I]), W = b(async () => {
|
|
4522
4522
|
if (y || M) {
|
|
4523
4523
|
k(null), j(null), N(!1);
|
|
4524
4524
|
return;
|
|
@@ -4530,7 +4530,7 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4530
4530
|
j("代码块内容为空");
|
|
4531
4531
|
return;
|
|
4532
4532
|
}
|
|
4533
|
-
let n = p(await
|
|
4533
|
+
let n = p(await Gn(t));
|
|
4534
4534
|
k(n);
|
|
4535
4535
|
} catch (e) {
|
|
4536
4536
|
j(e instanceof Error ? e.message : "Mermaid 渲染失败");
|
|
@@ -4541,9 +4541,9 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4541
4541
|
e.textContent,
|
|
4542
4542
|
y,
|
|
4543
4543
|
M
|
|
4544
|
-
]),
|
|
4545
|
-
className: `${
|
|
4546
|
-
style: { color:
|
|
4544
|
+
]), he = /* @__PURE__ */ O(E, { children: [L ? L.deviconClass ? /* @__PURE__ */ D("i", {
|
|
4545
|
+
className: `${L.deviconClass} colored cb-lang-icon`,
|
|
4546
|
+
style: { color: L.color }
|
|
4547
4547
|
}) : /* @__PURE__ */ D("span", {
|
|
4548
4548
|
className: "cb-lang-icon cb-lang-icon--auto",
|
|
4549
4549
|
children: "Tx"
|
|
@@ -4552,9 +4552,9 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4552
4552
|
children: "?"
|
|
4553
4553
|
}), /* @__PURE__ */ D("span", {
|
|
4554
4554
|
className: "cb-lang-label",
|
|
4555
|
-
children:
|
|
4555
|
+
children: L?.label || "自动"
|
|
4556
4556
|
})] });
|
|
4557
|
-
return /* @__PURE__ */ O(
|
|
4557
|
+
return /* @__PURE__ */ O(ne, {
|
|
4558
4558
|
as: "div",
|
|
4559
4559
|
className: "code-block-node-view group/cb",
|
|
4560
4560
|
onMouseDown: se,
|
|
@@ -4565,16 +4565,16 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4565
4565
|
contentEditable: !1,
|
|
4566
4566
|
children: [/* @__PURE__ */ O("div", {
|
|
4567
4567
|
className: "cb-lang-wrap",
|
|
4568
|
-
ref:
|
|
4568
|
+
ref: re,
|
|
4569
4569
|
contentEditable: !1,
|
|
4570
4570
|
children: [s ? /* @__PURE__ */ D("span", {
|
|
4571
4571
|
className: "cb-lang-trigger cb-lang-trigger--static",
|
|
4572
|
-
children:
|
|
4572
|
+
children: he
|
|
4573
4573
|
}) : /* @__PURE__ */ O("button", {
|
|
4574
4574
|
type: "button",
|
|
4575
4575
|
className: "cb-lang-trigger",
|
|
4576
4576
|
onClick: () => m(!f),
|
|
4577
|
-
children: [
|
|
4577
|
+
children: [he, /* @__PURE__ */ D("svg", {
|
|
4578
4578
|
className: `cb-lang-chevron${f ? " cb-lang-chevron--open" : ""}`,
|
|
4579
4579
|
width: "10",
|
|
4580
4580
|
height: "10",
|
|
@@ -4606,7 +4606,7 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4606
4606
|
d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
|
4607
4607
|
})
|
|
4608
4608
|
}), /* @__PURE__ */ D("input", {
|
|
4609
|
-
ref:
|
|
4609
|
+
ref: ie,
|
|
4610
4610
|
className: "cb-lang-search",
|
|
4611
4611
|
type: "text",
|
|
4612
4612
|
placeholder: "搜索语言...",
|
|
@@ -4619,17 +4619,17 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4619
4619
|
children: [
|
|
4620
4620
|
/* @__PURE__ */ O("button", {
|
|
4621
4621
|
type: "button",
|
|
4622
|
-
className: `cb-lang-option${
|
|
4623
|
-
onClick: () =>
|
|
4622
|
+
className: `cb-lang-option${I ? "" : " cb-lang-option--active"}`,
|
|
4623
|
+
onClick: () => fe(""),
|
|
4624
4624
|
children: [/* @__PURE__ */ D("span", {
|
|
4625
4625
|
className: "cb-lang-icon cb-lang-icon--auto",
|
|
4626
4626
|
children: "?"
|
|
4627
4627
|
}), /* @__PURE__ */ D("span", { children: "自动检测" })]
|
|
4628
4628
|
}),
|
|
4629
|
-
|
|
4629
|
+
de.map((e) => /* @__PURE__ */ O("button", {
|
|
4630
4630
|
type: "button",
|
|
4631
|
-
className: `cb-lang-option${
|
|
4632
|
-
onClick: () =>
|
|
4631
|
+
className: `cb-lang-option${I === e.value ? " cb-lang-option--active" : ""}`,
|
|
4632
|
+
onClick: () => fe(e.value),
|
|
4633
4633
|
children: [e.deviconClass ? /* @__PURE__ */ D("i", {
|
|
4634
4634
|
className: `${e.deviconClass} colored cb-lang-icon`,
|
|
4635
4635
|
style: { color: e.color }
|
|
@@ -4638,7 +4638,7 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4638
4638
|
children: "Tx"
|
|
4639
4639
|
}), /* @__PURE__ */ D("span", { children: e.label })]
|
|
4640
4640
|
}, e.value)),
|
|
4641
|
-
|
|
4641
|
+
de.length === 0 && /* @__PURE__ */ D("div", {
|
|
4642
4642
|
className: "cb-lang-empty",
|
|
4643
4643
|
children: "无匹配语言"
|
|
4644
4644
|
})
|
|
@@ -4674,7 +4674,7 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4674
4674
|
/* @__PURE__ */ D("button", {
|
|
4675
4675
|
type: "button",
|
|
4676
4676
|
className: "cb-btn",
|
|
4677
|
-
onClick:
|
|
4677
|
+
onClick: U,
|
|
4678
4678
|
contentEditable: !1,
|
|
4679
4679
|
title: "复制",
|
|
4680
4680
|
children: c ? /* @__PURE__ */ D("svg", {
|
|
@@ -4704,7 +4704,7 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4704
4704
|
/* @__PURE__ */ D("button", {
|
|
4705
4705
|
type: "button",
|
|
4706
4706
|
className: "cb-btn",
|
|
4707
|
-
onClick:
|
|
4707
|
+
onClick: me,
|
|
4708
4708
|
contentEditable: !1,
|
|
4709
4709
|
title: "下载",
|
|
4710
4710
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4723,7 +4723,7 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4723
4723
|
o && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("button", {
|
|
4724
4724
|
type: "button",
|
|
4725
4725
|
className: "cb-btn cb-btn--ai",
|
|
4726
|
-
onClick:
|
|
4726
|
+
onClick: pe,
|
|
4727
4727
|
contentEditable: !1,
|
|
4728
4728
|
title: "写作助手",
|
|
4729
4729
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4741,7 +4741,7 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4741
4741
|
}), /* @__PURE__ */ D("button", {
|
|
4742
4742
|
type: "button",
|
|
4743
4743
|
className: "cb-btn cb-btn--del",
|
|
4744
|
-
onClick:
|
|
4744
|
+
onClick: le,
|
|
4745
4745
|
contentEditable: !1,
|
|
4746
4746
|
title: "删除代码块",
|
|
4747
4747
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4757,10 +4757,10 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4757
4757
|
})
|
|
4758
4758
|
})
|
|
4759
4759
|
})] }),
|
|
4760
|
-
|
|
4760
|
+
R && /* @__PURE__ */ D("button", {
|
|
4761
4761
|
type: "button",
|
|
4762
4762
|
className: "cb-btn cb-btn--diagram",
|
|
4763
|
-
onClick:
|
|
4763
|
+
onClick: W,
|
|
4764
4764
|
contentEditable: !1,
|
|
4765
4765
|
title: y || M ? "取消渲染" : "渲染图表",
|
|
4766
4766
|
disabled: M,
|
|
@@ -4787,23 +4787,23 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4787
4787
|
className: "cb-line-numbers",
|
|
4788
4788
|
contentEditable: !1,
|
|
4789
4789
|
"aria-hidden": "true",
|
|
4790
|
-
children:
|
|
4790
|
+
children: B.map((e, t) => /* @__PURE__ */ D("span", {
|
|
4791
4791
|
className: "cb-line-num",
|
|
4792
|
-
style:
|
|
4792
|
+
style: ee[t] ? { height: ee[t] } : void 0,
|
|
4793
4793
|
children: e
|
|
4794
4794
|
}, e))
|
|
4795
4795
|
}),
|
|
4796
4796
|
/* @__PURE__ */ D("pre", {
|
|
4797
4797
|
className: "cb-code-pre",
|
|
4798
|
-
ref:
|
|
4799
|
-
children: /* @__PURE__ */ D(
|
|
4798
|
+
ref: ae,
|
|
4799
|
+
children: /* @__PURE__ */ D(te, { as: "code" })
|
|
4800
4800
|
}),
|
|
4801
4801
|
/* @__PURE__ */ D("div", {
|
|
4802
|
-
ref:
|
|
4802
|
+
ref: F,
|
|
4803
4803
|
className: "cb-code-mirror",
|
|
4804
4804
|
contentEditable: !1,
|
|
4805
4805
|
"aria-hidden": "true",
|
|
4806
|
-
children:
|
|
4806
|
+
children: ue.map((e, t) => /* @__PURE__ */ D("span", {
|
|
4807
4807
|
className: "cb-mirror-line",
|
|
4808
4808
|
children: e.length ? e : "\xA0"
|
|
4809
4809
|
}, t))
|
|
@@ -4831,7 +4831,7 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4831
4831
|
})
|
|
4832
4832
|
]
|
|
4833
4833
|
}),
|
|
4834
|
-
/* @__PURE__ */ D(
|
|
4834
|
+
/* @__PURE__ */ D(gn, {
|
|
4835
4835
|
open: _,
|
|
4836
4836
|
title: "确认删除代码块",
|
|
4837
4837
|
message: "此操作不可撤销。",
|
|
@@ -4840,7 +4840,7 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4840
4840
|
},
|
|
4841
4841
|
onConfirm: async () => {
|
|
4842
4842
|
if (await new Promise((e) => setTimeout(e, 300)), $(!1), n) {
|
|
4843
|
-
let e =
|
|
4843
|
+
let e = oe.current ?? ce();
|
|
4844
4844
|
e ? n.chain().focus().setTextSelection(e).deleteSelection().run() : i();
|
|
4845
4845
|
} else i();
|
|
4846
4846
|
}
|
|
@@ -4850,7 +4850,7 @@ function Yn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4850
4850
|
}
|
|
4851
4851
|
//#endregion
|
|
4852
4852
|
//#region src/editor/extensions/code-block.ts
|
|
4853
|
-
var
|
|
4853
|
+
var Zn = [
|
|
4854
4854
|
{
|
|
4855
4855
|
value: "javascript",
|
|
4856
4856
|
label: "JavaScript"
|
|
@@ -4951,14 +4951,30 @@ var Xn = [
|
|
|
4951
4951
|
value: "mermaid",
|
|
4952
4952
|
label: "Mermaid"
|
|
4953
4953
|
}
|
|
4954
|
-
],
|
|
4955
|
-
|
|
4956
|
-
var
|
|
4957
|
-
|
|
4958
|
-
|
|
4954
|
+
], Qn = Ce(Se);
|
|
4955
|
+
Qn.register({ dockerfile: xe }), Qn.registerAlias("xml", ["vue", "html"]), Qn.registerAlias("javascript", ["react", "jsx"]), Qn.registerAlias("typescript", ["tsx"]);
|
|
4956
|
+
var $n = be.extend({
|
|
4957
|
+
addNodeView() {
|
|
4958
|
+
return P(Xn);
|
|
4959
|
+
},
|
|
4960
|
+
parseHTML() {
|
|
4961
|
+
return (this.parent?.() ?? []).map((e) => ({
|
|
4962
|
+
...e,
|
|
4963
|
+
getContent: (e, t) => {
|
|
4964
|
+
let n = e, r = n.querySelector(":scope > code"), i = Array.from((r ?? n).querySelectorAll(":scope > div"));
|
|
4965
|
+
if (i.length > 0) {
|
|
4966
|
+
let e = i.map((e) => e.textContent ?? "").join("\n");
|
|
4967
|
+
return e ? M.from(t.text(e)) : M.empty;
|
|
4968
|
+
}
|
|
4969
|
+
let a = n.textContent ?? "";
|
|
4970
|
+
return a ? M.from(t.text(a)) : M.empty;
|
|
4971
|
+
}
|
|
4972
|
+
}));
|
|
4973
|
+
}
|
|
4974
|
+
}).configure({ lowlight: Qn });
|
|
4959
4975
|
//#endregion
|
|
4960
4976
|
//#region src/editor/utils/import-choice-dialog.ts
|
|
4961
|
-
function
|
|
4977
|
+
function er(e) {
|
|
4962
4978
|
return new Promise((t) => {
|
|
4963
4979
|
let n = document.createElement("div");
|
|
4964
4980
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -4988,16 +5004,16 @@ function $n(e) {
|
|
|
4988
5004
|
}
|
|
4989
5005
|
//#endregion
|
|
4990
5006
|
//#region src/editor/utils/local-media.ts
|
|
4991
|
-
var
|
|
4992
|
-
function
|
|
5007
|
+
var tr = /\.(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, nr = /^(?:mailto:|tel:|javascript:|about:|data:|blob:)/i;
|
|
5008
|
+
function rr(e) {
|
|
4993
5009
|
if (!e) return !1;
|
|
4994
5010
|
let t = e.trim();
|
|
4995
|
-
return !(!t || /^(?:https?:)?\/\//i.test(t) ||
|
|
4996
|
-
}
|
|
4997
|
-
function rr(e) {
|
|
4998
|
-
return er.test(e);
|
|
5011
|
+
return !(!t || /^(?:https?:)?\/\//i.test(t) || nr.test(t) || t.startsWith("#"));
|
|
4999
5012
|
}
|
|
5000
5013
|
function ir(e) {
|
|
5014
|
+
return tr.test(e);
|
|
5015
|
+
}
|
|
5016
|
+
function ar(e) {
|
|
5001
5017
|
let t = e.trim();
|
|
5002
5018
|
t = t.replace(/^(?:file|app):\/\/(?:localhost)?/i, "");
|
|
5003
5019
|
try {
|
|
@@ -5005,26 +5021,26 @@ function ir(e) {
|
|
|
5005
5021
|
} catch {}
|
|
5006
5022
|
return t = t.replace(/\\/g, "/"), t = t.replace(/^\.\//, ""), t = t.replace(/^\/+/, ""), t = t.replace(/^[a-zA-Z]:\//, ""), t;
|
|
5007
5023
|
}
|
|
5008
|
-
function
|
|
5009
|
-
let t =
|
|
5024
|
+
function or(e) {
|
|
5025
|
+
let t = ar(e), n = t.split("/").filter(Boolean);
|
|
5010
5026
|
return (n[n.length - 1] || t).toLowerCase();
|
|
5011
5027
|
}
|
|
5012
|
-
function
|
|
5028
|
+
function sr() {
|
|
5013
5029
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showDirectoryPicker == "function";
|
|
5014
5030
|
}
|
|
5015
|
-
async function
|
|
5016
|
-
if (!
|
|
5031
|
+
async function cr() {
|
|
5032
|
+
if (!sr()) return null;
|
|
5017
5033
|
try {
|
|
5018
5034
|
return await window.showDirectoryPicker.call(window, { mode: "read" }) ?? null;
|
|
5019
5035
|
} catch {
|
|
5020
5036
|
return null;
|
|
5021
5037
|
}
|
|
5022
5038
|
}
|
|
5023
|
-
function
|
|
5039
|
+
function lr() {
|
|
5024
5040
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showOpenFilePicker == "function";
|
|
5025
5041
|
}
|
|
5026
|
-
async function
|
|
5027
|
-
if (!
|
|
5042
|
+
async function ur() {
|
|
5043
|
+
if (!lr()) return null;
|
|
5028
5044
|
try {
|
|
5029
5045
|
let e = await window.showOpenFilePicker.call(window, { multiple: !0 });
|
|
5030
5046
|
return await Promise.all(e.map((e) => e.getFile()));
|
|
@@ -5032,7 +5048,7 @@ async function lr() {
|
|
|
5032
5048
|
return null;
|
|
5033
5049
|
}
|
|
5034
5050
|
}
|
|
5035
|
-
async function
|
|
5051
|
+
async function dr(e, t) {
|
|
5036
5052
|
if (t.length === 0) return { file: null };
|
|
5037
5053
|
let n = e;
|
|
5038
5054
|
for (let e = 0; e < t.length - 1; e++) try {
|
|
@@ -5054,7 +5070,7 @@ async function ur(e, t) {
|
|
|
5054
5070
|
return { file: null };
|
|
5055
5071
|
}
|
|
5056
5072
|
}
|
|
5057
|
-
async function
|
|
5073
|
+
async function fr(e, t, n = 5e3) {
|
|
5058
5074
|
let r = t.toLowerCase(), i = [e], a = 0, o;
|
|
5059
5075
|
for (; i.length > 0 && a < n;) {
|
|
5060
5076
|
let e = i.pop();
|
|
@@ -5076,37 +5092,37 @@ async function dr(e, t, n = 5e3) {
|
|
|
5076
5092
|
readError: o
|
|
5077
5093
|
};
|
|
5078
5094
|
}
|
|
5079
|
-
async function
|
|
5080
|
-
let n =
|
|
5095
|
+
async function pr(e, t) {
|
|
5096
|
+
let n = ar(t).split("/").filter(Boolean);
|
|
5081
5097
|
if (n.length === 0) return { file: null };
|
|
5082
5098
|
let r;
|
|
5083
5099
|
for (let t = 0; t < n.length; t++) {
|
|
5084
|
-
let i = await
|
|
5100
|
+
let i = await dr(e, n.slice(t));
|
|
5085
5101
|
if (i.file) return i;
|
|
5086
5102
|
i.readError && (r = i.readError);
|
|
5087
5103
|
}
|
|
5088
|
-
let i = await
|
|
5104
|
+
let i = await fr(e, n[n.length - 1]);
|
|
5089
5105
|
return i.file || i.readError ? i : {
|
|
5090
5106
|
file: null,
|
|
5091
5107
|
readError: r
|
|
5092
5108
|
};
|
|
5093
5109
|
}
|
|
5094
|
-
var
|
|
5110
|
+
var mr = {
|
|
5095
5111
|
image: "image",
|
|
5096
5112
|
videoEmbed: "video",
|
|
5097
5113
|
audioEmbed: "audio",
|
|
5098
5114
|
attachmentEmbed: "attachment"
|
|
5099
5115
|
};
|
|
5100
|
-
function
|
|
5116
|
+
function hr(e, t) {
|
|
5101
5117
|
let n = /* @__PURE__ */ new Set(), r = [];
|
|
5102
5118
|
return e.descendants((e) => {
|
|
5103
|
-
let i =
|
|
5119
|
+
let i = mr[e.type?.name];
|
|
5104
5120
|
if (i) {
|
|
5105
5121
|
let a = e.attrs?.src, o = `node:${a}`;
|
|
5106
|
-
typeof a == "string" &&
|
|
5122
|
+
typeof a == "string" && rr(a) && !n.has(o) && !t?.(a) && (n.add(o), r.push({
|
|
5107
5123
|
src: a,
|
|
5108
|
-
normalized:
|
|
5109
|
-
basename:
|
|
5124
|
+
normalized: ar(a),
|
|
5125
|
+
basename: or(a),
|
|
5110
5126
|
kind: i,
|
|
5111
5127
|
isLink: !1
|
|
5112
5128
|
}));
|
|
@@ -5115,17 +5131,17 @@ function mr(e, t) {
|
|
|
5115
5131
|
if (e.isText && e.marks) for (let i of e.marks) {
|
|
5116
5132
|
if (i.type.name !== "link") continue;
|
|
5117
5133
|
let e = i.attrs?.href, a = `link:${e}`;
|
|
5118
|
-
typeof e == "string" &&
|
|
5134
|
+
typeof e == "string" && rr(e) && ir(e) && !n.has(a) && !t?.(e) && (n.add(a), r.push({
|
|
5119
5135
|
src: e,
|
|
5120
|
-
normalized:
|
|
5121
|
-
basename:
|
|
5136
|
+
normalized: ar(e),
|
|
5137
|
+
basename: or(e),
|
|
5122
5138
|
kind: "attachment",
|
|
5123
5139
|
isLink: !0
|
|
5124
5140
|
}));
|
|
5125
5141
|
}
|
|
5126
5142
|
}), r;
|
|
5127
5143
|
}
|
|
5128
|
-
function
|
|
5144
|
+
function gr(e, t, n) {
|
|
5129
5145
|
let r = t ? `${e}\n${t}` : e;
|
|
5130
5146
|
if (!r) return !1;
|
|
5131
5147
|
let i = [];
|
|
@@ -5133,28 +5149,28 @@ function hr(e, t, n) {
|
|
|
5133
5149
|
for (let e of r.matchAll(/!?\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g)) i.push(e[1]);
|
|
5134
5150
|
for (let e of r.matchAll(/<(?:img|video|audio|source)[^>]*\bsrc=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5135
5151
|
for (let e of r.matchAll(/<a[^>]*\bhref=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5136
|
-
return i.some((e) =>
|
|
5152
|
+
return i.some((e) => ir(e) && rr(e) && !n?.(e));
|
|
5137
5153
|
}
|
|
5138
5154
|
//#endregion
|
|
5139
5155
|
//#region src/editor/extensions/image-upload.ts
|
|
5140
|
-
function
|
|
5156
|
+
function _r(e) {
|
|
5141
5157
|
if (e.type.startsWith("image/")) return "image";
|
|
5142
5158
|
if (e.type.startsWith("video/")) return "video";
|
|
5143
5159
|
if (e.type.startsWith("audio/")) return "audio";
|
|
5144
5160
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5145
5161
|
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";
|
|
5146
5162
|
}
|
|
5147
|
-
function
|
|
5163
|
+
function vr(e) {
|
|
5148
5164
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5149
5165
|
return t === "md" || t === "markdown";
|
|
5150
5166
|
}
|
|
5151
|
-
async function
|
|
5152
|
-
let i = n ?? e.state.selection.from, a = r ?
|
|
5153
|
-
o?.chooseMd ? o.chooseMd(t.name, e) :
|
|
5167
|
+
async function yr(e, t, n, r) {
|
|
5168
|
+
let i = n ?? e.state.selection.from, a = r ? on(r) : void 0, o = r?.storage?.qingwuUI, s = await new Promise((e) => {
|
|
5169
|
+
o?.chooseMd ? o.chooseMd(t.name, e) : er(t.name).then(e);
|
|
5154
5170
|
});
|
|
5155
5171
|
if (s === null) return;
|
|
5156
5172
|
if (s === "attach") {
|
|
5157
|
-
let n = a ?
|
|
5173
|
+
let n = a ? sn(e.state.doc, t, a) : null;
|
|
5158
5174
|
if (n) {
|
|
5159
5175
|
X(n);
|
|
5160
5176
|
return;
|
|
@@ -5185,8 +5201,8 @@ async function vr(e, t, n, r) {
|
|
|
5185
5201
|
e.dispatch(e.state.tr.insert(i, t.from(u)));
|
|
5186
5202
|
}
|
|
5187
5203
|
}
|
|
5188
|
-
function
|
|
5189
|
-
switch (
|
|
5204
|
+
function br(e, t, n) {
|
|
5205
|
+
switch (_r(t)) {
|
|
5190
5206
|
case "image": return e.nodes.image?.create({
|
|
5191
5207
|
src: n,
|
|
5192
5208
|
alt: t.name
|
|
@@ -5212,7 +5228,7 @@ function yr(e, t, n) {
|
|
|
5212
5228
|
}
|
|
5213
5229
|
}
|
|
5214
5230
|
}
|
|
5215
|
-
async function
|
|
5231
|
+
async function xr(e, t, n) {
|
|
5216
5232
|
let r;
|
|
5217
5233
|
try {
|
|
5218
5234
|
r = o();
|
|
@@ -5231,13 +5247,13 @@ async function br(e, t, n) {
|
|
|
5231
5247
|
return console.error(`${t.type} upload failed:`, e), URL.revokeObjectURL(n), null;
|
|
5232
5248
|
}
|
|
5233
5249
|
}
|
|
5234
|
-
async function
|
|
5235
|
-
let i = r ?
|
|
5250
|
+
async function Sr(e, t, n, r) {
|
|
5251
|
+
let i = r ? on(r) : void 0, a = i ? sn(e.state.doc, t, i) : null;
|
|
5236
5252
|
if (a) {
|
|
5237
5253
|
X(a);
|
|
5238
5254
|
return;
|
|
5239
5255
|
}
|
|
5240
|
-
let o = URL.createObjectURL(t), s =
|
|
5256
|
+
let o = URL.createObjectURL(t), s = br(e.state.schema, t, o);
|
|
5241
5257
|
if (!s) return;
|
|
5242
5258
|
let c = n ?? e.state.selection.from;
|
|
5243
5259
|
try {
|
|
@@ -5245,9 +5261,9 @@ async function xr(e, t, n, r) {
|
|
|
5245
5261
|
} catch {
|
|
5246
5262
|
return;
|
|
5247
5263
|
}
|
|
5248
|
-
await
|
|
5264
|
+
await xr(e, t, o);
|
|
5249
5265
|
}
|
|
5250
|
-
var
|
|
5266
|
+
var Cr = F.create({
|
|
5251
5267
|
name: "imageUpload",
|
|
5252
5268
|
addOptions() {
|
|
5253
5269
|
return {
|
|
@@ -5268,23 +5284,23 @@ var Sr = I.create({
|
|
|
5268
5284
|
left: n.clientX,
|
|
5269
5285
|
top: n.clientY
|
|
5270
5286
|
});
|
|
5271
|
-
for (let n of Array.from(r))
|
|
5287
|
+
for (let n of Array.from(r)) vr(n) ? yr(t, n, i?.pos, e) : Sr(t, n, i?.pos, e);
|
|
5272
5288
|
return !0;
|
|
5273
5289
|
},
|
|
5274
5290
|
handlePaste(t, n) {
|
|
5275
5291
|
let r = n.clipboardData?.items;
|
|
5276
5292
|
if (!r) return !1;
|
|
5277
5293
|
let i = n.clipboardData?.getData("text/plain") || "";
|
|
5278
|
-
if ((n.clipboardData?.files?.length ?? 0) > 0 &&
|
|
5294
|
+
if ((n.clipboardData?.files?.length ?? 0) > 0 && gr(i, void 0, a())) return !1;
|
|
5279
5295
|
for (let i of Array.from(r)) {
|
|
5280
5296
|
if (i.type.startsWith("image/") || i.type.startsWith("video/") || i.type.startsWith("audio/")) {
|
|
5281
5297
|
n.preventDefault();
|
|
5282
5298
|
let r = i.getAsFile();
|
|
5283
|
-
return r &&
|
|
5299
|
+
return r && _r(r) !== "file" && Sr(t, r, void 0, e), !0;
|
|
5284
5300
|
}
|
|
5285
5301
|
if (i.kind === "file") {
|
|
5286
5302
|
let r = i.getAsFile();
|
|
5287
|
-
if (r &&
|
|
5303
|
+
if (r && vr(r)) return n.preventDefault(), yr(t, r, void 0, e), !0;
|
|
5288
5304
|
}
|
|
5289
5305
|
}
|
|
5290
5306
|
return !1;
|
|
@@ -5292,25 +5308,25 @@ var Sr = I.create({
|
|
|
5292
5308
|
}
|
|
5293
5309
|
})];
|
|
5294
5310
|
}
|
|
5295
|
-
}),
|
|
5296
|
-
function
|
|
5311
|
+
}), wr = /\.(png|jpe?g|gif|webp|bmp|svg|avif)(\?|#|$)/i, Tr = /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|#|$)/i, Er = /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|#|$)/i;
|
|
5312
|
+
function Dr(e) {
|
|
5297
5313
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
5298
5314
|
}
|
|
5299
|
-
function
|
|
5315
|
+
function Or(e) {
|
|
5300
5316
|
let t = e.trim().replace(/\\/g, "/");
|
|
5301
5317
|
return t.split("/").pop() || t;
|
|
5302
5318
|
}
|
|
5303
|
-
function
|
|
5319
|
+
function kr(e, t) {
|
|
5304
5320
|
let n = e.src.slice(e.pos), r = /^!\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !0;
|
|
5305
5321
|
if (r || (r = /^\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !1), !r) return !1;
|
|
5306
5322
|
let a = r[1].trim(), o = r[2]?.trim();
|
|
5307
5323
|
if (!t) {
|
|
5308
|
-
let t = o ||
|
|
5324
|
+
let t = o || Or(a);
|
|
5309
5325
|
if (i) {
|
|
5310
5326
|
let n = "";
|
|
5311
|
-
if (
|
|
5312
|
-
else if (
|
|
5313
|
-
else if (
|
|
5327
|
+
if (wr.test(a) || /^data:image\//i.test(a)) n = `<img src="${Dr(a)}" alt="${Dr(t)}">`;
|
|
5328
|
+
else if (Tr.test(a) || /^data:video\//i.test(a)) n = `<div data-video-embed src="${Dr(a)}"></div>`;
|
|
5329
|
+
else if (Er.test(a) || /^data:audio\//i.test(a)) n = `<audio src="${Dr(a)}"></audio>`;
|
|
5314
5330
|
else {
|
|
5315
5331
|
let n = e.push("link_open", "a", 1);
|
|
5316
5332
|
n.attrs = [["href", a]];
|
|
@@ -5328,14 +5344,14 @@ function Or(e, t) {
|
|
|
5328
5344
|
}
|
|
5329
5345
|
return e.pos += r[0].length, !0;
|
|
5330
5346
|
}
|
|
5331
|
-
var
|
|
5347
|
+
var Ar = F.create({
|
|
5332
5348
|
name: "obsidianMarkdown",
|
|
5333
5349
|
addStorage() {
|
|
5334
5350
|
return { markdown: { parse: { setup(e) {
|
|
5335
|
-
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed",
|
|
5351
|
+
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed", kr));
|
|
5336
5352
|
} } } };
|
|
5337
5353
|
}
|
|
5338
|
-
}),
|
|
5354
|
+
}), jr = F.create({
|
|
5339
5355
|
name: "qingwuUI",
|
|
5340
5356
|
addStorage() {
|
|
5341
5357
|
return {};
|
|
@@ -5343,7 +5359,7 @@ var kr = I.create({
|
|
|
5343
5359
|
});
|
|
5344
5360
|
//#endregion
|
|
5345
5361
|
//#region src/editor/utils/render-probe.ts
|
|
5346
|
-
function
|
|
5362
|
+
function Mr(e, t) {
|
|
5347
5363
|
return new Promise((n) => {
|
|
5348
5364
|
if (typeof Image != "function") return n(!0);
|
|
5349
5365
|
let r = new Image(), i = !1, a = setTimeout(() => o(!1), t), o = (e) => {
|
|
@@ -5352,14 +5368,14 @@ function jr(e, t) {
|
|
|
5352
5368
|
r.onload = () => o(!0), r.onerror = () => o(!1), r.src = e;
|
|
5353
5369
|
});
|
|
5354
5370
|
}
|
|
5355
|
-
async function
|
|
5356
|
-
if (await
|
|
5371
|
+
async function Nr(e, t = 8e3) {
|
|
5372
|
+
if (await Mr(e, t)) return !0;
|
|
5357
5373
|
try {
|
|
5358
5374
|
let r = await n(e);
|
|
5359
5375
|
if (!r) return !1;
|
|
5360
5376
|
let i = await fetch(e, { headers: r });
|
|
5361
5377
|
if (!i.ok) return !1;
|
|
5362
|
-
let a = URL.createObjectURL(await i.blob()), o = await
|
|
5378
|
+
let a = URL.createObjectURL(await i.blob()), o = await Mr(a, t);
|
|
5363
5379
|
return URL.revokeObjectURL(a), o;
|
|
5364
5380
|
} catch {
|
|
5365
5381
|
return !1;
|
|
@@ -5367,7 +5383,7 @@ async function Mr(e, t = 8e3) {
|
|
|
5367
5383
|
}
|
|
5368
5384
|
//#endregion
|
|
5369
5385
|
//#region src/editor/utils/resolve-local-media.ts
|
|
5370
|
-
function
|
|
5386
|
+
function Pr() {
|
|
5371
5387
|
return {
|
|
5372
5388
|
uploaded: 0,
|
|
5373
5389
|
sessionOnly: 0,
|
|
@@ -5377,10 +5393,10 @@ function Nr() {
|
|
|
5377
5393
|
readFailed: []
|
|
5378
5394
|
};
|
|
5379
5395
|
}
|
|
5380
|
-
function
|
|
5396
|
+
function Fr(e, t) {
|
|
5381
5397
|
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);
|
|
5382
5398
|
}
|
|
5383
|
-
function
|
|
5399
|
+
function Ir(e, t, n, r) {
|
|
5384
5400
|
let { state: i } = e, a = [];
|
|
5385
5401
|
if (i.doc.descendants((e, n) => {
|
|
5386
5402
|
e.attrs?.src === t && a.push(n);
|
|
@@ -5396,7 +5412,7 @@ function Fr(e, t, n, r) {
|
|
|
5396
5412
|
}
|
|
5397
5413
|
return e.dispatch(o), !0;
|
|
5398
5414
|
}
|
|
5399
|
-
function
|
|
5415
|
+
function Lr(e, t, n) {
|
|
5400
5416
|
let { state: r } = e, i = r.schema.marks.link;
|
|
5401
5417
|
if (!i) return !1;
|
|
5402
5418
|
let a = [];
|
|
@@ -5414,7 +5430,7 @@ function Ir(e, t, n) {
|
|
|
5414
5430
|
}));
|
|
5415
5431
|
return e.dispatch(o), !0;
|
|
5416
5432
|
}
|
|
5417
|
-
function
|
|
5433
|
+
function Rr(e) {
|
|
5418
5434
|
let t = /* @__PURE__ */ new Map();
|
|
5419
5435
|
for (let n of e) {
|
|
5420
5436
|
let e = t.get(n.normalized);
|
|
@@ -5422,36 +5438,36 @@ function Lr(e) {
|
|
|
5422
5438
|
}
|
|
5423
5439
|
return Array.from(t.values());
|
|
5424
5440
|
}
|
|
5425
|
-
async function
|
|
5441
|
+
async function zr(e, t, n, r) {
|
|
5426
5442
|
if (n.length === 0) return "sessionOnly";
|
|
5427
|
-
let i = n[0], a =
|
|
5443
|
+
let i = n[0], a = on(t);
|
|
5428
5444
|
if (a) {
|
|
5429
|
-
let t =
|
|
5445
|
+
let t = sn(e.state.doc, r, a);
|
|
5430
5446
|
if (t) return X(`${i.basename}:${t}`, "error"), "limitRejected";
|
|
5431
5447
|
}
|
|
5432
5448
|
let s = n.filter((e) => !e.isLink), c = n.filter((e) => e.isLink);
|
|
5433
5449
|
if (s.length === 0) try {
|
|
5434
5450
|
let t = await o().upload(r, "editor"), n = !1;
|
|
5435
|
-
for (let r of c)
|
|
5451
|
+
for (let r of c) Lr(e, r.src, t) && (n = !0);
|
|
5436
5452
|
return n ? "uploaded" : "sessionOnly";
|
|
5437
5453
|
} catch (e) {
|
|
5438
5454
|
return console.error(`本地附件 ${i.basename} 上传失败:`, e), X(`「${i.basename}」上传失败`, "error"), "sessionOnly";
|
|
5439
5455
|
}
|
|
5440
5456
|
let l = URL.createObjectURL(r), u = !1;
|
|
5441
|
-
for (let t of s)
|
|
5457
|
+
for (let t of s) Ir(e, t.src, l, r.size) && (u = !0);
|
|
5442
5458
|
let d;
|
|
5443
5459
|
try {
|
|
5444
5460
|
d = await o().upload(r, "editor");
|
|
5445
5461
|
} catch (e) {
|
|
5446
5462
|
return console.error(`本地文件 ${i.basename} 上传失败:`, e), X(`「${i.basename}」上传失败`, "error"), URL.revokeObjectURL(l), "sessionOnly";
|
|
5447
5463
|
}
|
|
5448
|
-
URL.revokeObjectURL(l), u &&
|
|
5449
|
-
for (let t of c)
|
|
5450
|
-
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await
|
|
5464
|
+
URL.revokeObjectURL(l), u && Ir(e, l, d, r.size);
|
|
5465
|
+
for (let t of c) Lr(e, t.src, d);
|
|
5466
|
+
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await Nr(d) ? "uploaded" : "renderFailed" : "uploaded";
|
|
5451
5467
|
}
|
|
5452
|
-
function
|
|
5468
|
+
function Br(e, t) {
|
|
5453
5469
|
let n = [], r = [];
|
|
5454
|
-
for (let i of
|
|
5470
|
+
for (let i of Rr(e)) {
|
|
5455
5471
|
let e = i[0], a = t.get(e.basename);
|
|
5456
5472
|
a ? (n.push({
|
|
5457
5473
|
refs: i,
|
|
@@ -5463,30 +5479,30 @@ function zr(e, t) {
|
|
|
5463
5479
|
unmatched: r
|
|
5464
5480
|
};
|
|
5465
5481
|
}
|
|
5466
|
-
async function
|
|
5467
|
-
let i =
|
|
5468
|
-
for (let a of
|
|
5469
|
-
let n = a[0], { file: o, readError: s } = await
|
|
5482
|
+
async function Vr(e, t, n, r) {
|
|
5483
|
+
let i = Pr();
|
|
5484
|
+
for (let a of Rr(n)) {
|
|
5485
|
+
let n = a[0], { file: o, readError: s } = await pr(r, n.src);
|
|
5470
5486
|
if (!o) {
|
|
5471
5487
|
s ? (console.warn(`本地文件「${n.basename}」在所选文件夹中找到但读取失败:`, s), i.readFailed.push(n)) : (console.warn(`本地文件「${n.basename}」未在所选文件夹「${r.name}」中找到`), i.missing.push(n));
|
|
5472
5488
|
continue;
|
|
5473
5489
|
}
|
|
5474
|
-
let c = await
|
|
5490
|
+
let c = await zr(e, t, a, o);
|
|
5475
5491
|
i[c]++;
|
|
5476
5492
|
}
|
|
5477
5493
|
return i;
|
|
5478
5494
|
}
|
|
5479
|
-
function
|
|
5495
|
+
function Hr(e) {
|
|
5480
5496
|
let t = e.map((e) => e.basename);
|
|
5481
5497
|
return t.length <= 3 ? t.join("、") : `${t.slice(0, 3).join("、")} 等 ${t.length} 个文件`;
|
|
5482
5498
|
}
|
|
5483
|
-
function
|
|
5499
|
+
function Ur(e) {
|
|
5484
5500
|
let t = [];
|
|
5485
|
-
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} 个找到但读取失败:${
|
|
5501
|
+
if (e.uploaded > 0 && t.push(`${e.uploaded} 个已上传至存储`), e.sessionOnly > 0 && t.push(`${e.sessionOnly} 个仅本次会话可见(未配置存储或上传失败)`), e.limitRejected > 0 && t.push(`${e.limitRejected} 个超出大小限制`), e.renderFailed > 0 && t.push(`${e.renderFailed} 个上传成功但页面渲染失败(存储 URL 无法在浏览器访问/解码)`), e.readFailed.length > 0 && t.push(`${e.readFailed.length} 个找到但读取失败:${Hr(e.readFailed)}(若在 OneDrive / WPS 云盘等同步目录,请右键文件选择「始终保留在此设备」后重试)`), e.missing.length > 0 && t.push(`${e.missing.length} 个未能获取:${Hr(e.missing)}(可把文件直接拖进编辑器上传)`), t.length === 0) return;
|
|
5486
5502
|
let n = e.uploaded > 0 && e.renderFailed === 0 && e.missing.length === 0 && e.readFailed.length === 0;
|
|
5487
5503
|
X(`本地文件解析完成:${t.join(";")}`, n ? "success" : "info");
|
|
5488
5504
|
}
|
|
5489
|
-
function
|
|
5505
|
+
function Wr(e) {
|
|
5490
5506
|
return new Promise((t) => {
|
|
5491
5507
|
let n = document.createElement("div");
|
|
5492
5508
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5513,7 +5529,7 @@ function Ur(e) {
|
|
|
5513
5529
|
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);
|
|
5514
5530
|
});
|
|
5515
5531
|
}
|
|
5516
|
-
function
|
|
5532
|
+
function Gr(e) {
|
|
5517
5533
|
let t = document.createElement("div");
|
|
5518
5534
|
t.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
5519
5535
|
let n = document.createElement("div");
|
|
@@ -5535,7 +5551,7 @@ function Wr(e) {
|
|
|
5535
5551
|
let c = document.createElement("button");
|
|
5536
5552
|
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);
|
|
5537
5553
|
}
|
|
5538
|
-
function
|
|
5554
|
+
function Kr(e) {
|
|
5539
5555
|
return new Promise((t) => {
|
|
5540
5556
|
let n = document.createElement("div");
|
|
5541
5557
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5561,8 +5577,8 @@ function Gr(e) {
|
|
|
5561
5577
|
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);
|
|
5562
5578
|
});
|
|
5563
5579
|
}
|
|
5564
|
-
async function
|
|
5565
|
-
let r =
|
|
5580
|
+
async function qr(e, t, n) {
|
|
5581
|
+
let r = Pr(), i = Rr(n), a = await ur();
|
|
5566
5582
|
if (!a) {
|
|
5567
5583
|
for (let e of i) r.missing.push(e[0]);
|
|
5568
5584
|
return r;
|
|
@@ -5575,14 +5591,14 @@ async function Kr(e, t, n) {
|
|
|
5575
5591
|
continue;
|
|
5576
5592
|
}
|
|
5577
5593
|
o.delete(i.basename);
|
|
5578
|
-
let s = await
|
|
5594
|
+
let s = await zr(e, t, n, a);
|
|
5579
5595
|
r[s]++;
|
|
5580
5596
|
}
|
|
5581
5597
|
return r;
|
|
5582
5598
|
}
|
|
5583
5599
|
//#endregion
|
|
5584
5600
|
//#region src/editor/extensions/relative-media.ts
|
|
5585
|
-
var
|
|
5601
|
+
var Jr = F.create({
|
|
5586
5602
|
name: "relativeMedia",
|
|
5587
5603
|
addStorage() {
|
|
5588
5604
|
return {
|
|
@@ -5592,38 +5608,38 @@ var qr = I.create({
|
|
|
5592
5608
|
},
|
|
5593
5609
|
addProseMirrorPlugins() {
|
|
5594
5610
|
let e = this.editor, t = this.storage, n = !1, r = null, i = async (n, i) => {
|
|
5595
|
-
let a = e.view, o =
|
|
5611
|
+
let a = e.view, o = Pr(), { matched: s, unmatched: c } = Br(n, t.clipboardFiles);
|
|
5596
5612
|
for (let { refs: t, file: n } of s) {
|
|
5597
|
-
let r = await
|
|
5613
|
+
let r = await zr(a, e, t, n);
|
|
5598
5614
|
o[r]++;
|
|
5599
5615
|
}
|
|
5600
5616
|
if (c.length > 0) {
|
|
5601
|
-
let t =
|
|
5602
|
-
if (
|
|
5617
|
+
let t = Rr(c).length;
|
|
5618
|
+
if (sr()) {
|
|
5603
5619
|
let n = i ?? null;
|
|
5604
|
-
if (n || (await
|
|
5605
|
-
r = n,
|
|
5620
|
+
if (n || (await Wr(t) === "pick" ? (n = await cr(), n || X("没有选择文件夹。本地文件暂以占位显示,稍后可直接把文件拖进编辑器上传", "info")) : X("已选择稍后处理。本地文件暂以占位显示,可直接把文件拖进编辑器上传", "info")), n) {
|
|
5621
|
+
r = n, Fr(o, await Vr(a, e, c, n));
|
|
5606
5622
|
let t = [...o.missing, ...o.readFailed];
|
|
5607
|
-
if (t.length > 0 &&
|
|
5608
|
-
let n = await
|
|
5609
|
-
|
|
5623
|
+
if (t.length > 0 && lr() && await Kr(t.map((e) => e.basename)) === "pick") {
|
|
5624
|
+
let n = await qr(a, e, t);
|
|
5625
|
+
Fr(o, n), o.missing = n.missing, o.readFailed = [];
|
|
5610
5626
|
}
|
|
5611
5627
|
}
|
|
5612
|
-
} else
|
|
5628
|
+
} else Gr(t);
|
|
5613
5629
|
}
|
|
5614
|
-
|
|
5630
|
+
Ur(o);
|
|
5615
5631
|
}, o = () => {
|
|
5616
5632
|
if (!e || e.isDestroyed || t.pausedUntilPaste) return;
|
|
5617
|
-
let o = a(), s =
|
|
5633
|
+
let o = a(), s = hr(e.state.doc, o);
|
|
5618
5634
|
if (s.length === 0 || n) return;
|
|
5619
5635
|
n = !0;
|
|
5620
5636
|
let c = new Set(s.map((e) => e.src));
|
|
5621
5637
|
i(s).then(() => {
|
|
5622
5638
|
if (e.isDestroyed) return;
|
|
5623
|
-
let t =
|
|
5639
|
+
let t = hr(e.state.doc, o).filter((e) => !c.has(e.src));
|
|
5624
5640
|
if (t.length !== 0) return i(t, r);
|
|
5625
5641
|
}).finally(() => {
|
|
5626
|
-
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste =
|
|
5642
|
+
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste = hr(e.state.doc, o).length > 0);
|
|
5627
5643
|
});
|
|
5628
5644
|
};
|
|
5629
5645
|
return [new L({
|
|
@@ -5637,18 +5653,18 @@ var qr = I.create({
|
|
|
5637
5653
|
}
|
|
5638
5654
|
})];
|
|
5639
5655
|
}
|
|
5640
|
-
}),
|
|
5641
|
-
function
|
|
5642
|
-
return
|
|
5656
|
+
}), Yr = new R("slashCommand");
|
|
5657
|
+
function Xr(e) {
|
|
5658
|
+
return F.create({
|
|
5643
5659
|
name: "slashCommand",
|
|
5644
5660
|
addProseMirrorPlugins() {
|
|
5645
5661
|
let t = {
|
|
5646
5662
|
char: "/",
|
|
5647
|
-
pluginKey:
|
|
5663
|
+
pluginKey: Yr,
|
|
5648
5664
|
findSuggestionMatch: (e) => {
|
|
5649
5665
|
let { $position: t } = e;
|
|
5650
5666
|
for (let e = t.depth; e >= 0; e--) if (t.node(e).type.name === "codeBlock") return null;
|
|
5651
|
-
return t.marks().some((e) => e.type.name === "code") ? null :
|
|
5667
|
+
return t.marks().some((e) => e.type.name === "code") ? null : Te(e);
|
|
5652
5668
|
},
|
|
5653
5669
|
allow: ({ editor: e, state: t }) => {
|
|
5654
5670
|
if (!e.isEditable) return !1;
|
|
@@ -5728,7 +5744,7 @@ function Yr(e) {
|
|
|
5728
5744
|
};
|
|
5729
5745
|
}
|
|
5730
5746
|
};
|
|
5731
|
-
return [
|
|
5747
|
+
return [we({
|
|
5732
5748
|
editor: this.editor,
|
|
5733
5749
|
...t
|
|
5734
5750
|
}), new L({
|
|
@@ -5740,14 +5756,14 @@ function Yr(e) {
|
|
|
5740
5756
|
break;
|
|
5741
5757
|
}
|
|
5742
5758
|
if (!i && !r.marks().some((e) => e.type.name === "code")) return null;
|
|
5743
|
-
let a =
|
|
5744
|
-
return a && a.active ? n.tr.setMeta(
|
|
5759
|
+
let a = Yr.getState(n);
|
|
5760
|
+
return a && a.active ? n.tr.setMeta(Yr, { exit: !0 }) : null;
|
|
5745
5761
|
}
|
|
5746
5762
|
})];
|
|
5747
5763
|
}
|
|
5748
5764
|
});
|
|
5749
5765
|
}
|
|
5750
|
-
function
|
|
5766
|
+
function Zr(e, t) {
|
|
5751
5767
|
return [
|
|
5752
5768
|
{
|
|
5753
5769
|
title: e("editor.slash.heading1"),
|
|
@@ -5846,7 +5862,7 @@ function Xr(e, t) {
|
|
|
5846
5862
|
n.type = "file", n.accept = "audio/*", n.onchange = async () => {
|
|
5847
5863
|
let r = n.files?.[0];
|
|
5848
5864
|
if (!r) return;
|
|
5849
|
-
let i =
|
|
5865
|
+
let i = on(e) ?? t, a = i ? sn(e.state.doc, r, i) : null;
|
|
5850
5866
|
if (a) {
|
|
5851
5867
|
X(a);
|
|
5852
5868
|
return;
|
|
@@ -5856,7 +5872,7 @@ function Xr(e, t) {
|
|
|
5856
5872
|
name: r.name,
|
|
5857
5873
|
size: r.size
|
|
5858
5874
|
});
|
|
5859
|
-
s && (e.chain().focus().insertContent(s).run(), await
|
|
5875
|
+
s && (e.chain().focus().insertContent(s).run(), await xr(e.view, r, o));
|
|
5860
5876
|
}, n.click();
|
|
5861
5877
|
}
|
|
5862
5878
|
},
|
|
@@ -5869,7 +5885,7 @@ function Xr(e, t) {
|
|
|
5869
5885
|
n.type = "file", n.accept = "*/*", n.multiple = !0, n.onchange = async () => {
|
|
5870
5886
|
let r = n.files;
|
|
5871
5887
|
if (!(!r || r.length === 0)) for (let n of Array.from(r)) {
|
|
5872
|
-
let r =
|
|
5888
|
+
let r = on(e) ?? t, i = r ? sn(e.state.doc, n, r) : null;
|
|
5873
5889
|
if (i) {
|
|
5874
5890
|
X(i);
|
|
5875
5891
|
continue;
|
|
@@ -5886,7 +5902,7 @@ function Xr(e, t) {
|
|
|
5886
5902
|
} catch {
|
|
5887
5903
|
continue;
|
|
5888
5904
|
}
|
|
5889
|
-
await
|
|
5905
|
+
await xr(e.view, n, a);
|
|
5890
5906
|
}
|
|
5891
5907
|
}
|
|
5892
5908
|
}, n.click();
|
|
@@ -5896,9 +5912,9 @@ function Xr(e, t) {
|
|
|
5896
5912
|
}
|
|
5897
5913
|
//#endregion
|
|
5898
5914
|
//#region src/editor/extensions/index.ts
|
|
5899
|
-
var
|
|
5915
|
+
var Qr = ue.extend({
|
|
5900
5916
|
addNodeView() {
|
|
5901
|
-
return
|
|
5917
|
+
return P(vn);
|
|
5902
5918
|
},
|
|
5903
5919
|
addAttributes() {
|
|
5904
5920
|
return {
|
|
@@ -5921,111 +5937,111 @@ var Zr = ce.extend({
|
|
|
5921
5937
|
};
|
|
5922
5938
|
}
|
|
5923
5939
|
});
|
|
5924
|
-
function
|
|
5940
|
+
function $r(e = {}) {
|
|
5925
5941
|
return [
|
|
5926
|
-
|
|
5942
|
+
de.configure({
|
|
5927
5943
|
codeBlock: !1,
|
|
5928
5944
|
horizontalRule: !1,
|
|
5929
5945
|
underline: !1,
|
|
5930
5946
|
link: !1
|
|
5931
5947
|
}),
|
|
5932
5948
|
B,
|
|
5933
|
-
|
|
5949
|
+
z.configure({
|
|
5934
5950
|
openOnClick: !0,
|
|
5935
5951
|
HTMLAttributes: {
|
|
5936
5952
|
rel: "noopener noreferrer",
|
|
5937
5953
|
target: "_blank"
|
|
5938
5954
|
}
|
|
5939
5955
|
}),
|
|
5940
|
-
|
|
5956
|
+
Qr.configure({
|
|
5941
5957
|
inline: !1,
|
|
5942
5958
|
allowBase64: !0
|
|
5943
5959
|
}),
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5960
|
+
_e,
|
|
5961
|
+
ge.configure({ nested: !0 }),
|
|
5962
|
+
fe.configure({ multicolor: !0 }),
|
|
5963
|
+
ve,
|
|
5948
5964
|
H,
|
|
5949
|
-
|
|
5950
|
-
de,
|
|
5951
|
-
Qn,
|
|
5952
|
-
W.configure({ resizable: !0 }),
|
|
5953
|
-
me,
|
|
5965
|
+
V.configure(e.maxLength ? { limit: e.maxLength } : {}),
|
|
5954
5966
|
pe,
|
|
5967
|
+
$n,
|
|
5968
|
+
me.configure({ resizable: !0 }),
|
|
5955
5969
|
G,
|
|
5956
|
-
|
|
5970
|
+
W,
|
|
5971
|
+
he,
|
|
5972
|
+
ye.configure({
|
|
5957
5973
|
html: !0,
|
|
5958
5974
|
transformPastedText: !0,
|
|
5959
5975
|
transformCopiedText: !1
|
|
5960
5976
|
}),
|
|
5961
|
-
|
|
5962
|
-
|
|
5977
|
+
U.configure({ placeholder: e.placeholder || "输入 '/' 打开菜单…" }),
|
|
5978
|
+
Xr(() => Zr((e) => f(e), {
|
|
5963
5979
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
5964
5980
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
5965
5981
|
})),
|
|
5966
|
-
|
|
5982
|
+
Cr.configure({
|
|
5967
5983
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
5968
5984
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
5969
5985
|
}),
|
|
5970
|
-
|
|
5971
|
-
kr,
|
|
5972
|
-
St,
|
|
5986
|
+
Jr,
|
|
5973
5987
|
Ar,
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5988
|
+
Ct,
|
|
5989
|
+
jr,
|
|
5990
|
+
Un,
|
|
5991
|
+
In,
|
|
5992
|
+
Nn
|
|
5977
5993
|
];
|
|
5978
5994
|
}
|
|
5979
5995
|
//#endregion
|
|
5980
5996
|
//#region src/editor/extensions/bubble-menu.tsx
|
|
5981
|
-
var
|
|
5982
|
-
function
|
|
5983
|
-
|
|
5997
|
+
var ei = "https://www.bing.com/search?q={query}";
|
|
5998
|
+
function ti(e) {
|
|
5999
|
+
ei = e;
|
|
5984
6000
|
}
|
|
5985
|
-
function
|
|
5986
|
-
return
|
|
6001
|
+
function ni() {
|
|
6002
|
+
return ei;
|
|
5987
6003
|
}
|
|
5988
|
-
function
|
|
6004
|
+
function ri(e) {
|
|
5989
6005
|
return [
|
|
5990
6006
|
{
|
|
5991
6007
|
key: "bold",
|
|
5992
6008
|
label: e("editor.bubble.bold"),
|
|
5993
|
-
icon: /* @__PURE__ */ D(
|
|
6009
|
+
icon: /* @__PURE__ */ D(Et, {}),
|
|
5994
6010
|
isActive: (e) => e.isActive("bold"),
|
|
5995
6011
|
command: (e) => e.isEditable && e.chain().focus().toggleBold().run()
|
|
5996
6012
|
},
|
|
5997
6013
|
{
|
|
5998
6014
|
key: "italic",
|
|
5999
6015
|
label: e("editor.bubble.italic"),
|
|
6000
|
-
icon: /* @__PURE__ */ D(
|
|
6016
|
+
icon: /* @__PURE__ */ D(Dt, {}),
|
|
6001
6017
|
isActive: (e) => e.isActive("italic"),
|
|
6002
6018
|
command: (e) => e.isEditable && e.chain().focus().toggleItalic().run()
|
|
6003
6019
|
},
|
|
6004
6020
|
{
|
|
6005
6021
|
key: "underline",
|
|
6006
6022
|
label: e("editor.bubble.underline"),
|
|
6007
|
-
icon: /* @__PURE__ */ D(
|
|
6023
|
+
icon: /* @__PURE__ */ D(Ot, {}),
|
|
6008
6024
|
isActive: (e) => e.isActive("underline"),
|
|
6009
6025
|
command: (e) => e.isEditable && e.chain().focus().toggleUnderline().run()
|
|
6010
6026
|
},
|
|
6011
6027
|
{
|
|
6012
6028
|
key: "strikethrough",
|
|
6013
6029
|
label: e("editor.bubble.strikethrough"),
|
|
6014
|
-
icon: /* @__PURE__ */ D(
|
|
6030
|
+
icon: /* @__PURE__ */ D(kt, {}),
|
|
6015
6031
|
isActive: (e) => e.isActive("strike"),
|
|
6016
6032
|
command: (e) => e.isEditable && e.chain().focus().toggleStrike().run()
|
|
6017
6033
|
},
|
|
6018
6034
|
{
|
|
6019
6035
|
key: "code",
|
|
6020
6036
|
label: e("editor.bubble.emphasis"),
|
|
6021
|
-
icon: /* @__PURE__ */ D(
|
|
6037
|
+
icon: /* @__PURE__ */ D(At, {}),
|
|
6022
6038
|
isActive: (e) => e.isActive("code"),
|
|
6023
6039
|
command: (e) => e.isEditable && e.chain().focus().toggleCode().run()
|
|
6024
6040
|
},
|
|
6025
6041
|
{
|
|
6026
6042
|
key: "highlight",
|
|
6027
6043
|
label: e("editor.bubble.highlight"),
|
|
6028
|
-
icon: /* @__PURE__ */ D(
|
|
6044
|
+
icon: /* @__PURE__ */ D(jt, {}),
|
|
6029
6045
|
more: !0,
|
|
6030
6046
|
isActive: (e) => e.isActive("highlight"),
|
|
6031
6047
|
command: () => {}
|
|
@@ -6033,7 +6049,7 @@ function ni(e) {
|
|
|
6033
6049
|
{
|
|
6034
6050
|
key: "link",
|
|
6035
6051
|
label: e("editor.bubble.link"),
|
|
6036
|
-
icon: /* @__PURE__ */ D(
|
|
6052
|
+
icon: /* @__PURE__ */ D(Mt, {}),
|
|
6037
6053
|
more: !0,
|
|
6038
6054
|
isActive: (e) => e.isActive("link"),
|
|
6039
6055
|
command: () => {}
|
|
@@ -6041,7 +6057,7 @@ function ni(e) {
|
|
|
6041
6057
|
{
|
|
6042
6058
|
key: "copy",
|
|
6043
6059
|
label: e("editor.bubble.copy"),
|
|
6044
|
-
icon: /* @__PURE__ */ D(
|
|
6060
|
+
icon: /* @__PURE__ */ D(Pt, {}),
|
|
6045
6061
|
more: !0,
|
|
6046
6062
|
isActive: () => !1,
|
|
6047
6063
|
command: (e) => {
|
|
@@ -6052,21 +6068,21 @@ function ni(e) {
|
|
|
6052
6068
|
{
|
|
6053
6069
|
key: "search",
|
|
6054
6070
|
label: e("editor.bubble.search"),
|
|
6055
|
-
icon: /* @__PURE__ */ D(
|
|
6071
|
+
icon: /* @__PURE__ */ D(Ft, {}),
|
|
6056
6072
|
more: !0,
|
|
6057
6073
|
isActive: () => !1,
|
|
6058
6074
|
command: (e) => {
|
|
6059
6075
|
if (e.isActive("table")) return;
|
|
6060
6076
|
let { from: t, to: n } = e.state.selection, r = e.state.doc.textBetween(t, n, " ").trim();
|
|
6061
6077
|
if (!r) return;
|
|
6062
|
-
let i =
|
|
6078
|
+
let i = ei.replace("{query}", encodeURIComponent(r));
|
|
6063
6079
|
window.open(i, "_blank", "noopener,noreferrer");
|
|
6064
6080
|
}
|
|
6065
6081
|
},
|
|
6066
6082
|
{
|
|
6067
6083
|
key: "table",
|
|
6068
6084
|
label: e("editor.bubble.table"),
|
|
6069
|
-
icon: /* @__PURE__ */ D(
|
|
6085
|
+
icon: /* @__PURE__ */ D(Nt, {}),
|
|
6070
6086
|
more: !0,
|
|
6071
6087
|
isActive: (e) => e.isActive("table"),
|
|
6072
6088
|
command: (e) => {
|
|
@@ -6082,7 +6098,7 @@ function ni(e) {
|
|
|
6082
6098
|
{
|
|
6083
6099
|
key: "ai",
|
|
6084
6100
|
label: e("editor.ai.trigger"),
|
|
6085
|
-
icon: /* @__PURE__ */ D(
|
|
6101
|
+
icon: /* @__PURE__ */ D(It, {}),
|
|
6086
6102
|
isActive: () => !1,
|
|
6087
6103
|
command: (e) => {
|
|
6088
6104
|
e.isEditable && e.storage.qingwuUI?.openAI?.();
|
|
@@ -6090,10 +6106,10 @@ function ni(e) {
|
|
|
6090
6106
|
}
|
|
6091
6107
|
];
|
|
6092
6108
|
}
|
|
6093
|
-
|
|
6109
|
+
F.create({ name: "bubbleMenu" });
|
|
6094
6110
|
//#endregion
|
|
6095
6111
|
//#region src/editor/extensions/table-toolbar.tsx
|
|
6096
|
-
function
|
|
6112
|
+
function ii(e) {
|
|
6097
6113
|
let { $from: t } = e.state.selection;
|
|
6098
6114
|
for (let e = t.depth; e > 0; e--) {
|
|
6099
6115
|
let n = t.node(e);
|
|
@@ -6104,7 +6120,7 @@ function ri(e) {
|
|
|
6104
6120
|
}
|
|
6105
6121
|
return null;
|
|
6106
6122
|
}
|
|
6107
|
-
function
|
|
6123
|
+
function ai(e) {
|
|
6108
6124
|
let t = [];
|
|
6109
6125
|
return e.forEach((e) => {
|
|
6110
6126
|
let n = [];
|
|
@@ -6113,7 +6129,7 @@ function ii(e) {
|
|
|
6113
6129
|
}), t.push(n);
|
|
6114
6130
|
}), t;
|
|
6115
6131
|
}
|
|
6116
|
-
function
|
|
6132
|
+
function oi(e) {
|
|
6117
6133
|
if (e.length === 0) return "";
|
|
6118
6134
|
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(" | ")} |`;
|
|
6119
6135
|
return [
|
|
@@ -6122,11 +6138,11 @@ function ai(e) {
|
|
|
6122
6138
|
...i.map(a)
|
|
6123
6139
|
].join("\n");
|
|
6124
6140
|
}
|
|
6125
|
-
function
|
|
6141
|
+
function si(e) {
|
|
6126
6142
|
let t = (e) => /[",\n]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e;
|
|
6127
6143
|
return e.map((e) => e.map(t).join(",")).join("\n");
|
|
6128
6144
|
}
|
|
6129
|
-
function
|
|
6145
|
+
function ci(e) {
|
|
6130
6146
|
let t = e.trim();
|
|
6131
6147
|
if (!t) return null;
|
|
6132
6148
|
let n = t.split(/\r?\n/);
|
|
@@ -6140,7 +6156,7 @@ function si(e) {
|
|
|
6140
6156
|
}
|
|
6141
6157
|
return null;
|
|
6142
6158
|
}
|
|
6143
|
-
function
|
|
6159
|
+
function li({ editor: e }) {
|
|
6144
6160
|
let [t, n] = T(null), [r, i] = T(!1), [a, o] = T(!1), s = w(null), c = w(null), l = e.isEditable, u = b(() => {
|
|
6145
6161
|
c.current != null && cancelAnimationFrame(c.current), c.current = requestAnimationFrame(() => {
|
|
6146
6162
|
c.current = null;
|
|
@@ -6156,7 +6172,7 @@ function ci({ editor: e }) {
|
|
|
6156
6172
|
n(null);
|
|
6157
6173
|
return;
|
|
6158
6174
|
}
|
|
6159
|
-
let t =
|
|
6175
|
+
let t = ii(e);
|
|
6160
6176
|
if (!t) {
|
|
6161
6177
|
n(null);
|
|
6162
6178
|
return;
|
|
@@ -6185,24 +6201,24 @@ function ci({ editor: e }) {
|
|
|
6185
6201
|
});
|
|
6186
6202
|
return n.nodes.table.create(null, i);
|
|
6187
6203
|
}, p = () => {
|
|
6188
|
-
let t =
|
|
6204
|
+
let t = ii(e);
|
|
6189
6205
|
if (!t) return;
|
|
6190
|
-
let n = ai(
|
|
6206
|
+
let n = oi(ai(t.node));
|
|
6191
6207
|
navigator.clipboard?.writeText(n), i(!0), setTimeout(() => i(!1), 1500);
|
|
6192
6208
|
}, m = () => {
|
|
6193
|
-
let t =
|
|
6209
|
+
let t = ii(e);
|
|
6194
6210
|
if (!t) return;
|
|
6195
|
-
let n =
|
|
6211
|
+
let n = si(ai(t.node)), r = new Blob([`\ufeff${n}`], { type: "text/csv;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
6196
6212
|
a.href = i, a.download = "table.csv", document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
6197
6213
|
}, h = async () => {
|
|
6198
6214
|
if (l) try {
|
|
6199
6215
|
let t = await navigator.clipboard?.readText();
|
|
6200
6216
|
if (!t) return;
|
|
6201
|
-
let n =
|
|
6217
|
+
let n = ci(t);
|
|
6202
6218
|
if (!n || n.length === 0) return;
|
|
6203
6219
|
let r = f(n);
|
|
6204
6220
|
if (!r) return;
|
|
6205
|
-
let i =
|
|
6221
|
+
let i = ii(e), a = e.chain().focus();
|
|
6206
6222
|
if (i) {
|
|
6207
6223
|
let t = Math.min(i.pos + i.node.nodeSize, e.state.doc.content.size);
|
|
6208
6224
|
a.setTextSelection(t);
|
|
@@ -6322,7 +6338,7 @@ function ci({ editor: e }) {
|
|
|
6322
6338
|
type: "button",
|
|
6323
6339
|
className: "tbl-btn tbl-btn--del",
|
|
6324
6340
|
onClick: () => {
|
|
6325
|
-
!l ||
|
|
6341
|
+
!l || dn() || ($(!0), o(!0));
|
|
6326
6342
|
},
|
|
6327
6343
|
title: "删除",
|
|
6328
6344
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -6340,7 +6356,7 @@ function ci({ editor: e }) {
|
|
|
6340
6356
|
})
|
|
6341
6357
|
})
|
|
6342
6358
|
}),
|
|
6343
|
-
/* @__PURE__ */ D(
|
|
6359
|
+
/* @__PURE__ */ D(gn, {
|
|
6344
6360
|
open: a,
|
|
6345
6361
|
title: "确认删除表格",
|
|
6346
6362
|
message: "此操作不可撤销。",
|
|
@@ -6356,7 +6372,7 @@ function ci({ editor: e }) {
|
|
|
6356
6372
|
}
|
|
6357
6373
|
//#endregion
|
|
6358
6374
|
//#region src/editor/ai-editor.tsx
|
|
6359
|
-
var
|
|
6375
|
+
var ui = [
|
|
6360
6376
|
{
|
|
6361
6377
|
color: "#fef08a",
|
|
6362
6378
|
name: "黄"
|
|
@@ -6381,9 +6397,9 @@ var li = [
|
|
|
6381
6397
|
color: "#ddd6fe",
|
|
6382
6398
|
name: "紫"
|
|
6383
6399
|
}
|
|
6384
|
-
],
|
|
6385
|
-
function
|
|
6386
|
-
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth ||
|
|
6400
|
+
], di = 288, fi = 480, pi = 320;
|
|
6401
|
+
function mi(e, t, n = {}) {
|
|
6402
|
+
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth || di, fi, r - 32), o = Math.max(t || pi, 160);
|
|
6387
6403
|
if (r < 640) {
|
|
6388
6404
|
let t = Math.max(8, Math.min(e.top + 10, i - 420));
|
|
6389
6405
|
return {
|
|
@@ -6424,10 +6440,10 @@ function pi(e, t, n = {}) {
|
|
|
6424
6440
|
arrowLeft: p
|
|
6425
6441
|
};
|
|
6426
6442
|
}
|
|
6427
|
-
function
|
|
6443
|
+
function hi(e) {
|
|
6428
6444
|
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);
|
|
6429
6445
|
}
|
|
6430
|
-
function
|
|
6446
|
+
function gi(e, t) {
|
|
6431
6447
|
try {
|
|
6432
6448
|
let n = e.storage?.markdown?.parser;
|
|
6433
6449
|
if (!n) return null;
|
|
@@ -6437,20 +6453,20 @@ function hi(e, t) {
|
|
|
6437
6453
|
return null;
|
|
6438
6454
|
}
|
|
6439
6455
|
}
|
|
6440
|
-
var
|
|
6456
|
+
var _i = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.ImageUploadDialog }))), vi = y(() => import("./storage-settings-dialog-DZqqDAiO.js").then((e) => ({ default: e.StorageSettingsDialog }))), yi = y(() => import("./export-dialog-CL7ie13Z.js").then((e) => ({ default: e.ExportDialog }))), bi = y(() => import("./video-embed-dialog-AeGcMb4X.js").then((e) => ({ default: e.VideoEmbedDialog }))), xi = y(() => import("./md-import-dialog-Cf3ZOwA_.js").then((e) => ({ default: e.MdImportDialog }))), Si = () => /* @__PURE__ */ O("div", {
|
|
6441
6457
|
className: "fixed inset-0 z-[9999] flex items-center justify-center",
|
|
6442
6458
|
children: [/* @__PURE__ */ D("div", { className: "absolute inset-0 bg-black/40 backdrop-blur-sm" }), /* @__PURE__ */ D("div", {
|
|
6443
6459
|
className: "relative bg-background rounded-2xl border border-default-200 p-8 flex items-center justify-center",
|
|
6444
6460
|
children: /* @__PURE__ */ D("div", { className: "w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin" })
|
|
6445
6461
|
})]
|
|
6446
|
-
}),
|
|
6447
|
-
let k = r === "view" || i, A = C(() =>
|
|
6462
|
+
}), Ci = ({ 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 }) => {
|
|
6463
|
+
let k = r === "view" || i, A = C(() => typeof e == "object" && e || hi(e) ? e : d(e), [e]), [j, M] = T(!1), [te, ne] = T({}), [P, F] = T("below"), [oe, I] = T(50), L = w(null), [R, se] = T(!1), [ce, le] = T(!1), [ue, z] = T(!1), [B, de] = T(!1), [V, H] = T("none"), [fe, pe] = T({}), [U, me] = T(""), [W, he] = T(null), [G, ge] = T(m), [_e, ve] = T(!1);
|
|
6448
6464
|
x(() => {
|
|
6449
|
-
|
|
6465
|
+
ge(m);
|
|
6450
6466
|
}, [m]);
|
|
6451
|
-
let [
|
|
6452
|
-
let e =
|
|
6453
|
-
e && (
|
|
6467
|
+
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, Ne] = T(!1), [K, Pe] = T(!1), [q, Fe] = T(!1), Ie = b(() => {
|
|
6468
|
+
let e = Ee.current, t = De.current;
|
|
6469
|
+
e && (K ? (document.body.style.overflow = "", Object.assign(e.style, {
|
|
6454
6470
|
position: "",
|
|
6455
6471
|
top: "",
|
|
6456
6472
|
left: "",
|
|
@@ -6466,9 +6482,9 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6466
6482
|
flex: "",
|
|
6467
6483
|
overflow: "",
|
|
6468
6484
|
minHeight: ""
|
|
6469
|
-
}),
|
|
6470
|
-
window.scrollTo(0,
|
|
6471
|
-
})) : (document.fullscreenElement && document.exitFullscreen(),
|
|
6485
|
+
}), Pe(!1), requestAnimationFrame(() => {
|
|
6486
|
+
window.scrollTo(0, Oe.current);
|
|
6487
|
+
})) : (document.fullscreenElement && document.exitFullscreen(), Oe.current = window.scrollY, Object.assign(e.style, {
|
|
6472
6488
|
position: "fixed",
|
|
6473
6489
|
top: "0",
|
|
6474
6490
|
left: "0",
|
|
@@ -6484,42 +6500,42 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6484
6500
|
flex: "1",
|
|
6485
6501
|
overflow: "auto",
|
|
6486
6502
|
minHeight: "0"
|
|
6487
|
-
}), document.body.style.overflow = "hidden",
|
|
6488
|
-
}, [
|
|
6489
|
-
let e =
|
|
6490
|
-
e && (document.fullscreenElement ? document.exitFullscreen() : (
|
|
6491
|
-
}, [
|
|
6503
|
+
}), document.body.style.overflow = "hidden", Pe(!0)));
|
|
6504
|
+
}, [K]), Le = b(() => {
|
|
6505
|
+
let e = Ee.current;
|
|
6506
|
+
e && (document.fullscreenElement ? document.exitFullscreen() : (K && Ie(), Oe.current = window.scrollY, e.requestFullscreen()));
|
|
6507
|
+
}, [K, Ie]);
|
|
6492
6508
|
x(() => {
|
|
6493
6509
|
let e = (e) => {
|
|
6494
|
-
e.key === "Escape" &&
|
|
6510
|
+
e.key === "Escape" && K && Ie();
|
|
6495
6511
|
}, t = () => {
|
|
6496
6512
|
document.fullscreenElement ? Fe(!0) : (Fe(!1), requestAnimationFrame(() => {
|
|
6497
|
-
window.scrollTo(0,
|
|
6513
|
+
window.scrollTo(0, Oe.current);
|
|
6498
6514
|
}));
|
|
6499
6515
|
};
|
|
6500
6516
|
return window.addEventListener("keydown", e), document.addEventListener("fullscreenchange", t), () => {
|
|
6501
6517
|
window.removeEventListener("keydown", e), document.removeEventListener("fullscreenchange", t);
|
|
6502
6518
|
};
|
|
6503
|
-
}, [
|
|
6519
|
+
}, [K, Ie]), x(() => {
|
|
6504
6520
|
if (!h) return;
|
|
6505
6521
|
let e = (e) => {
|
|
6506
6522
|
if ((e.ctrlKey || e.metaKey) && (e.key === "f" || e.key === "F")) {
|
|
6507
|
-
if (!
|
|
6508
|
-
e.preventDefault(), e.stopPropagation(),
|
|
6523
|
+
if (!Ee.current) return;
|
|
6524
|
+
e.preventDefault(), e.stopPropagation(), be(!0);
|
|
6509
6525
|
}
|
|
6510
6526
|
};
|
|
6511
6527
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
6512
6528
|
}, [h]), x(() => {
|
|
6513
6529
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
6514
|
-
let e = window.matchMedia("(min-width: 80rem)"), t = (e) =>
|
|
6515
|
-
return
|
|
6530
|
+
let e = window.matchMedia("(min-width: 80rem)"), t = (e) => Se(e.matches);
|
|
6531
|
+
return Se(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
6516
6532
|
}, []), x(() => {
|
|
6517
6533
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
6518
|
-
let e = window.matchMedia("(min-width: 64rem)"), t = (e) =>
|
|
6519
|
-
return
|
|
6534
|
+
let e = window.matchMedia("(min-width: 64rem)"), t = (e) => we(e.matches);
|
|
6535
|
+
return we(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
6520
6536
|
}, []);
|
|
6521
|
-
let J =
|
|
6522
|
-
extensions:
|
|
6537
|
+
let J = re({
|
|
6538
|
+
extensions: $r({
|
|
6523
6539
|
placeholder: n || f("editor.placeholder"),
|
|
6524
6540
|
maxLength: a,
|
|
6525
6541
|
maxAttachmentSize: o,
|
|
@@ -6529,7 +6545,7 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6529
6545
|
editable: !k,
|
|
6530
6546
|
immediatelyRender: _,
|
|
6531
6547
|
onUpdate: ({ editor: e }) => {
|
|
6532
|
-
t && (
|
|
6548
|
+
t && (Te.current && clearTimeout(Te.current), Te.current = setTimeout(() => {
|
|
6533
6549
|
t?.(e.getHTML(), e.getJSON());
|
|
6534
6550
|
}, 300));
|
|
6535
6551
|
},
|
|
@@ -6542,11 +6558,11 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6542
6558
|
let r = n.getData("text/plain");
|
|
6543
6559
|
if (!r || !r.includes("[[")) return !1;
|
|
6544
6560
|
t.preventDefault();
|
|
6545
|
-
let i =
|
|
6561
|
+
let i = Ae.current?.storage?.relativeMedia;
|
|
6546
6562
|
i && (i.clipboardFiles = new Map(Array.from(n.files ?? []).map((e) => [e.name.toLowerCase(), e])), i.pausedUntilPaste = !1);
|
|
6547
|
-
let a =
|
|
6563
|
+
let a = Ae.current ? gi(Ae.current, r) : null;
|
|
6548
6564
|
if (a) {
|
|
6549
|
-
let t = new
|
|
6565
|
+
let t = new N(a, 0, 0);
|
|
6550
6566
|
e.dispatch(e.state.tr.replaceSelection(t).scrollIntoView());
|
|
6551
6567
|
} else e.dispatch(e.state.tr.insertText(r).scrollIntoView());
|
|
6552
6568
|
return !0;
|
|
@@ -6554,21 +6570,21 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6554
6570
|
}
|
|
6555
6571
|
});
|
|
6556
6572
|
x(() => {
|
|
6557
|
-
|
|
6573
|
+
Ae.current = J, window.__editor = J;
|
|
6558
6574
|
}, [J]), x(() => {
|
|
6559
|
-
if (J) return () =>
|
|
6575
|
+
if (J) return () => Kt(J);
|
|
6560
6576
|
}, [J]), x(() => {
|
|
6561
6577
|
!J || !g || g(J);
|
|
6562
6578
|
}, [J, g]), x(() => {
|
|
6563
6579
|
if (!J) return;
|
|
6564
6580
|
let e = () => {
|
|
6565
|
-
J.state.selection.empty && (
|
|
6581
|
+
J.state.selection.empty && (H("none"), Ne(!1));
|
|
6566
6582
|
};
|
|
6567
6583
|
return J.on("selectionUpdate", e), () => {
|
|
6568
6584
|
J.off("selectionUpdate", e);
|
|
6569
6585
|
};
|
|
6570
6586
|
}, [J]), x(() => {
|
|
6571
|
-
J && J.setOptions({ extensions:
|
|
6587
|
+
J && J.setOptions({ extensions: $r({
|
|
6572
6588
|
placeholder: n || f("editor.placeholder"),
|
|
6573
6589
|
maxLength: a,
|
|
6574
6590
|
maxAttachmentSize: o,
|
|
@@ -6584,16 +6600,16 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6584
6600
|
x(() => {
|
|
6585
6601
|
if (!J || e === Re.current) return;
|
|
6586
6602
|
Re.current = e;
|
|
6587
|
-
let t =
|
|
6603
|
+
let t = typeof e == "object" && e || hi(e) ? e : d(e);
|
|
6588
6604
|
J.commands.setContent(t, { emitUpdate: !1 });
|
|
6589
6605
|
}, [J, e]), x(() => {
|
|
6590
6606
|
J && J.setEditable(!k, !1);
|
|
6591
6607
|
}, [J, k]), x(() => {
|
|
6592
|
-
if (y) return
|
|
6608
|
+
if (y) return Qe(y);
|
|
6593
6609
|
}, [y]), x(() => {
|
|
6594
6610
|
if (!J) return;
|
|
6595
|
-
let e =
|
|
6596
|
-
e > s && X(`文档内附件总大小 ${
|
|
6611
|
+
let e = rn(J.state.doc);
|
|
6612
|
+
e > s && X(`文档内附件总大小 ${an(e)} 已超过限制 ${an(s)}`, "info");
|
|
6597
6613
|
}, [J, s]), x(() => {
|
|
6598
6614
|
if (!J) return;
|
|
6599
6615
|
let e = J.storage.qingwuUI;
|
|
@@ -6607,25 +6623,25 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6607
6623
|
s
|
|
6608
6624
|
]);
|
|
6609
6625
|
let ze = b((e) => {
|
|
6610
|
-
let t =
|
|
6611
|
-
|
|
6626
|
+
let t = je.current?.getBoundingClientRect();
|
|
6627
|
+
H(e), Ne(!1), pe({
|
|
6612
6628
|
position: "fixed",
|
|
6613
6629
|
top: t ? t.bottom + 8 : void 0,
|
|
6614
6630
|
left: t ? Math.max(8, Math.min(t.left, window.innerWidth - 240)) : 8,
|
|
6615
6631
|
zIndex: 9999
|
|
6616
6632
|
});
|
|
6617
|
-
}, []),
|
|
6618
|
-
if (J) if (
|
|
6633
|
+
}, []), Be = ri((e) => f(e)), Y = Be.filter((e) => !e.more), Ve = Be.filter((e) => e.more), He = Y.filter((e) => e.key !== "ai"), Ue = Y.find((e) => e.key === "ai"), We = b((e) => {
|
|
6634
|
+
if (J) if (Ne(!1), e.key === "link") if (J.isActive("link")) J.chain().focus().unsetLink().run();
|
|
6619
6635
|
else {
|
|
6620
6636
|
let e = J.getAttributes("link").href || "";
|
|
6621
|
-
|
|
6637
|
+
me(e), ze("link");
|
|
6622
6638
|
}
|
|
6623
|
-
else e.key === "highlight" ?
|
|
6639
|
+
else e.key === "highlight" ? V === "highlight" ? H("none") : ze("highlight") : e.command(J);
|
|
6624
6640
|
}, [
|
|
6625
6641
|
J,
|
|
6626
|
-
|
|
6642
|
+
V,
|
|
6627
6643
|
ze
|
|
6628
|
-
]), Ge = b((e) => J ? e.key === "highlight" ?
|
|
6644
|
+
]), Ge = b((e) => J ? e.key === "highlight" ? V === "highlight" : e.key === "link" ? J.isActive("link") : e.isActive(J) : !1, [J, V]), [Ke, qe] = T(0);
|
|
6629
6645
|
x(() => {
|
|
6630
6646
|
if (!J) return;
|
|
6631
6647
|
let e = () => qe((e) => (e + 1) % 1e6);
|
|
@@ -6646,11 +6662,11 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6646
6662
|
J.off("update", e);
|
|
6647
6663
|
};
|
|
6648
6664
|
}, [J]);
|
|
6649
|
-
let Xe = C(() => J?.storage?.characterCount?.characters?.() ?? 0, [J, Ke]),
|
|
6665
|
+
let Xe = C(() => J?.storage?.characterCount?.characters?.() ?? 0, [J, Ke]), Ze = a ? Xe > a : !1;
|
|
6650
6666
|
x(() => () => {
|
|
6651
|
-
|
|
6667
|
+
Te.current && clearTimeout(Te.current);
|
|
6652
6668
|
}, []), x(() => () => {
|
|
6653
|
-
|
|
6669
|
+
W && W.resolve(null);
|
|
6654
6670
|
}, []);
|
|
6655
6671
|
let $e = b((e) => {
|
|
6656
6672
|
if (!J?.isEditable) return;
|
|
@@ -6677,59 +6693,59 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6677
6693
|
width: 0
|
|
6678
6694
|
};
|
|
6679
6695
|
}
|
|
6680
|
-
|
|
6681
|
-
let r =
|
|
6696
|
+
ke.current = n;
|
|
6697
|
+
let r = Ee.current?.getBoundingClientRect(), i = mi(n, void 0, {
|
|
6682
6698
|
panelWidth: r?.width,
|
|
6683
6699
|
editorLeft: r?.left
|
|
6684
6700
|
});
|
|
6685
|
-
|
|
6701
|
+
M(!0), ne(i.style), F(i.placement), I(i.arrowLeft);
|
|
6686
6702
|
}, [J]);
|
|
6687
6703
|
x(() => {
|
|
6688
6704
|
if (!J) return;
|
|
6689
6705
|
let e = J.storage.qingwuUI;
|
|
6690
|
-
if (e) return e.openImageDialog = () => se(!0), e.openVideoDialog = () =>
|
|
6691
|
-
|
|
6706
|
+
if (e) return e.openImageDialog = () => se(!0), e.openVideoDialog = () => le(!0), e.chooseMd = (e, t) => {
|
|
6707
|
+
he({
|
|
6692
6708
|
filename: e,
|
|
6693
6709
|
resolve: t
|
|
6694
6710
|
});
|
|
6695
|
-
}, e.openAI = $e, e.parseMd = (e, t) => J ?
|
|
6711
|
+
}, e.openAI = $e, e.parseMd = (e, t) => J ? gi(J, t) : null, () => {
|
|
6696
6712
|
delete e.openImageDialog, delete e.openVideoDialog, delete e.openAI, delete e.parseMd, delete e.chooseMd;
|
|
6697
6713
|
};
|
|
6698
6714
|
}, [J, $e]), S(() => {
|
|
6699
6715
|
if (!j || !J) return;
|
|
6700
|
-
let e =
|
|
6716
|
+
let e = ke.current;
|
|
6701
6717
|
if (!e) return;
|
|
6702
|
-
let t =
|
|
6718
|
+
let t = L.current, n = Ee.current?.getBoundingClientRect(), r = mi(e, t?.offsetHeight || void 0, {
|
|
6703
6719
|
panelWidth: n?.width,
|
|
6704
6720
|
editorLeft: n?.left
|
|
6705
6721
|
});
|
|
6706
|
-
|
|
6722
|
+
F(r.placement), I(r.arrowLeft), ne(r.style);
|
|
6707
6723
|
}, [j, J]), x(() => {
|
|
6708
6724
|
if (!j || !J) return;
|
|
6709
6725
|
let e = () => {
|
|
6710
|
-
let e =
|
|
6726
|
+
let e = ke.current;
|
|
6711
6727
|
if (!e) return;
|
|
6712
|
-
let t =
|
|
6728
|
+
let t = L.current, n = Ee.current?.getBoundingClientRect(), r = mi(e, t?.offsetHeight || void 0, {
|
|
6713
6729
|
panelWidth: n?.width,
|
|
6714
6730
|
editorLeft: n?.left
|
|
6715
6731
|
});
|
|
6716
|
-
|
|
6732
|
+
F(r.placement), I(r.arrowLeft), ne(r.style);
|
|
6717
6733
|
};
|
|
6718
6734
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
6719
6735
|
}, [j, J]), x(() => {
|
|
6720
|
-
j || (
|
|
6736
|
+
j || (ke.current = null);
|
|
6721
6737
|
}, [j]);
|
|
6722
6738
|
let et = b((e) => {
|
|
6723
6739
|
J?.chain().focus().setImage({ src: e }).run();
|
|
6724
6740
|
}, [J]), tt = b((e) => {
|
|
6725
6741
|
(J?.commands).insertVideo?.({ src: e });
|
|
6726
|
-
}, [J]), nt =
|
|
6742
|
+
}, [J]), nt = G && xe && !K && !q, rt = !nt && !_e && (G || Je && !(!k && Ce)), it = w(!1);
|
|
6727
6743
|
return x(() => {
|
|
6728
|
-
it.current || (it.current = !0,
|
|
6729
|
-
}, [
|
|
6744
|
+
it.current || (it.current = !0, G && !nt && ve(!0));
|
|
6745
|
+
}, [G, nt]), J ? /* @__PURE__ */ O("div", {
|
|
6730
6746
|
className: "qingwu-editor-row",
|
|
6731
6747
|
children: [/* @__PURE__ */ O("div", {
|
|
6732
|
-
ref:
|
|
6748
|
+
ref: Ee,
|
|
6733
6749
|
className: `qingwu-editor relative flex-1 min-w-0 bg-background ${k ? "qingwu-editor--readonly" : ""} ${l ? "" : "rounded-xl border border-default-200"} ${c}`,
|
|
6734
6750
|
style: u,
|
|
6735
6751
|
children: [
|
|
@@ -6740,13 +6756,13 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6740
6756
|
children: [
|
|
6741
6757
|
/* @__PURE__ */ D("button", {
|
|
6742
6758
|
type: "button",
|
|
6743
|
-
className: `qed-tb-btn qed-tb-btn--desktop-only${
|
|
6759
|
+
className: `qed-tb-btn qed-tb-btn--desktop-only${G ? " is-active" : ""}`,
|
|
6744
6760
|
onClick: () => {
|
|
6745
|
-
|
|
6761
|
+
G ? (ge(!1), ve(!1)) : (ge(!0), xe && !K && !q || ve(!0));
|
|
6746
6762
|
},
|
|
6747
|
-
title:
|
|
6748
|
-
"aria-label":
|
|
6749
|
-
"aria-pressed":
|
|
6763
|
+
title: G ? "隐藏目录" : "显示目录",
|
|
6764
|
+
"aria-label": G ? "隐藏目录" : "显示目录",
|
|
6765
|
+
"aria-pressed": G,
|
|
6750
6766
|
children: /* @__PURE__ */ D("svg", {
|
|
6751
6767
|
fill: "none",
|
|
6752
6768
|
viewBox: "0 0 24 24",
|
|
@@ -6762,11 +6778,11 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6762
6778
|
}),
|
|
6763
6779
|
h && /* @__PURE__ */ D("button", {
|
|
6764
6780
|
type: "button",
|
|
6765
|
-
className: `qed-tb-btn${
|
|
6766
|
-
onClick: () =>
|
|
6781
|
+
className: `qed-tb-btn${ye ? " is-active" : ""}`,
|
|
6782
|
+
onClick: () => be(!ye),
|
|
6767
6783
|
title: "查找 (Ctrl+F)",
|
|
6768
6784
|
"aria-label": "查找",
|
|
6769
|
-
"aria-pressed":
|
|
6785
|
+
"aria-pressed": ye,
|
|
6770
6786
|
children: /* @__PURE__ */ D("svg", {
|
|
6771
6787
|
fill: "none",
|
|
6772
6788
|
viewBox: "0 0 24 24",
|
|
@@ -6783,7 +6799,7 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6783
6799
|
!k && /* @__PURE__ */ D("button", {
|
|
6784
6800
|
type: "button",
|
|
6785
6801
|
className: `qed-tb-btn qed-tb-btn--ai${j ? " is-active" : ""}`,
|
|
6786
|
-
onClick: (e) => j ?
|
|
6802
|
+
onClick: (e) => j ? M(!1) : $e(e.currentTarget),
|
|
6787
6803
|
title: f("editor.toolbar.aiTitle"),
|
|
6788
6804
|
"aria-label": f("editor.toolbar.ai"),
|
|
6789
6805
|
"aria-pressed": j,
|
|
@@ -6811,7 +6827,7 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6811
6827
|
/* @__PURE__ */ O("button", {
|
|
6812
6828
|
type: "button",
|
|
6813
6829
|
className: "qed-tb-btn qed-tb-btn--solid",
|
|
6814
|
-
onClick: () =>
|
|
6830
|
+
onClick: () => de(!0),
|
|
6815
6831
|
title: f("editor.toolbar.exportTitle"),
|
|
6816
6832
|
children: [/* @__PURE__ */ D("svg", {
|
|
6817
6833
|
fill: "none",
|
|
@@ -6831,11 +6847,11 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6831
6847
|
}),
|
|
6832
6848
|
/* @__PURE__ */ D("button", {
|
|
6833
6849
|
type: "button",
|
|
6834
|
-
className: `qed-tb-btn${
|
|
6850
|
+
className: `qed-tb-btn${K ? " is-active" : ""}`,
|
|
6835
6851
|
onClick: Ie,
|
|
6836
|
-
title:
|
|
6837
|
-
"aria-label":
|
|
6838
|
-
"aria-pressed":
|
|
6852
|
+
title: K ? "退出网页全屏" : "网页全屏",
|
|
6853
|
+
"aria-label": K ? "退出网页全屏" : "网页全屏",
|
|
6854
|
+
"aria-pressed": K,
|
|
6839
6855
|
children: /* @__PURE__ */ D("svg", {
|
|
6840
6856
|
fill: "none",
|
|
6841
6857
|
viewBox: "0 0 24 24",
|
|
@@ -6851,11 +6867,11 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6851
6867
|
}),
|
|
6852
6868
|
/* @__PURE__ */ D("button", {
|
|
6853
6869
|
type: "button",
|
|
6854
|
-
className: `qed-tb-btn${
|
|
6870
|
+
className: `qed-tb-btn${q ? " is-active" : ""}`,
|
|
6855
6871
|
onClick: Le,
|
|
6856
|
-
title:
|
|
6857
|
-
"aria-label":
|
|
6858
|
-
"aria-pressed":
|
|
6872
|
+
title: q ? "退出全屏" : "全屏",
|
|
6873
|
+
"aria-label": q ? "退出全屏" : "全屏",
|
|
6874
|
+
"aria-pressed": q,
|
|
6859
6875
|
children: /* @__PURE__ */ D("svg", {
|
|
6860
6876
|
fill: "none",
|
|
6861
6877
|
viewBox: "0 0 24 24",
|
|
@@ -6872,7 +6888,7 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6872
6888
|
]
|
|
6873
6889
|
})]
|
|
6874
6890
|
}),
|
|
6875
|
-
J && !k && J.isEditable && /* @__PURE__ */ D(
|
|
6891
|
+
J && !k && J.isEditable && /* @__PURE__ */ D(ie, {
|
|
6876
6892
|
editor: J,
|
|
6877
6893
|
shouldShow: ({ editor: e, state: t }) => !(e.isActive("image") || e.isActive("videoEmbed") || e.isActive("codeBlock") || e.isActive("audioEmbed") || e.isActive("attachmentEmbed") || t.selection.empty),
|
|
6878
6894
|
options: {
|
|
@@ -6882,7 +6898,7 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6882
6898
|
},
|
|
6883
6899
|
className: "bubble-menu-pop bg-background border border-default-200 rounded-xl p-1 shadow-lg",
|
|
6884
6900
|
children: /* @__PURE__ */ O("div", {
|
|
6885
|
-
ref:
|
|
6901
|
+
ref: je,
|
|
6886
6902
|
className: "bubble-menu-items relative flex items-center gap-0.5",
|
|
6887
6903
|
onPointerDown: (e) => {
|
|
6888
6904
|
e.target.closest("button") && e.preventDefault();
|
|
@@ -6906,11 +6922,11 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6906
6922
|
type: "button",
|
|
6907
6923
|
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"}`,
|
|
6908
6924
|
onClick: (e) => {
|
|
6909
|
-
e.preventDefault(),
|
|
6925
|
+
e.preventDefault(), Ne(!1), Ue?.command(J);
|
|
6910
6926
|
},
|
|
6911
6927
|
title: Ue?.label,
|
|
6912
6928
|
"aria-label": Ue?.label,
|
|
6913
|
-
children: /* @__PURE__ */ D(
|
|
6929
|
+
children: /* @__PURE__ */ D(It, {})
|
|
6914
6930
|
}),
|
|
6915
6931
|
/* @__PURE__ */ D("span", {
|
|
6916
6932
|
className: "w-px h-4 bg-default-200 mx-0.5 shrink-0",
|
|
@@ -6918,16 +6934,16 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6918
6934
|
}),
|
|
6919
6935
|
/* @__PURE__ */ D("button", {
|
|
6920
6936
|
type: "button",
|
|
6921
|
-
"aria-expanded":
|
|
6922
|
-
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${
|
|
6937
|
+
"aria-expanded": Me,
|
|
6938
|
+
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${Me ? "bg-default-100 text-default-900" : "text-default-600 hover:bg-default-100"}`,
|
|
6923
6939
|
onClick: (e) => {
|
|
6924
|
-
e.preventDefault(),
|
|
6940
|
+
e.preventDefault(), Ne((e) => !e);
|
|
6925
6941
|
},
|
|
6926
6942
|
title: f("editor.bubble.more"),
|
|
6927
6943
|
"aria-label": f("editor.bubble.more"),
|
|
6928
|
-
children: /* @__PURE__ */ D(
|
|
6944
|
+
children: /* @__PURE__ */ D(Lt, {})
|
|
6929
6945
|
}),
|
|
6930
|
-
|
|
6946
|
+
Me && /* @__PURE__ */ D("div", {
|
|
6931
6947
|
role: "menu",
|
|
6932
6948
|
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",
|
|
6933
6949
|
onPointerDown: (e) => {
|
|
@@ -6953,29 +6969,29 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6953
6969
|
]
|
|
6954
6970
|
})
|
|
6955
6971
|
}),
|
|
6956
|
-
J &&
|
|
6972
|
+
J && V !== "none" && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
6957
6973
|
className: "fixed inset-0 z-[9998]",
|
|
6958
|
-
onClick: () =>
|
|
6974
|
+
onClick: () => H("none")
|
|
6959
6975
|
}), /* @__PURE__ */ D("div", {
|
|
6960
|
-
style:
|
|
6976
|
+
style: fe,
|
|
6961
6977
|
className: "bg-background border border-default-200 rounded-xl shadow-xl",
|
|
6962
6978
|
onClick: (e) => e.stopPropagation(),
|
|
6963
|
-
children:
|
|
6979
|
+
children: V === "highlight" ? /* @__PURE__ */ O("div", {
|
|
6964
6980
|
className: "flex items-center gap-1 p-1.5 flex-wrap",
|
|
6965
|
-
children: [
|
|
6981
|
+
children: [ui.map((e) => /* @__PURE__ */ D("button", {
|
|
6966
6982
|
type: "button",
|
|
6967
6983
|
className: "w-5 h-5 rounded-full border border-default-200 hover:scale-110 transition-transform",
|
|
6968
6984
|
style: { background: e.color },
|
|
6969
6985
|
title: e.name,
|
|
6970
6986
|
onClick: () => {
|
|
6971
|
-
J.chain().focus().setHighlight({ color: e.color }).run(),
|
|
6987
|
+
J.chain().focus().setHighlight({ color: e.color }).run(), H("none");
|
|
6972
6988
|
}
|
|
6973
6989
|
}, e.color)), /* @__PURE__ */ O("button", {
|
|
6974
6990
|
type: "button",
|
|
6975
6991
|
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]",
|
|
6976
6992
|
title: "清除高亮",
|
|
6977
6993
|
onClick: () => {
|
|
6978
|
-
J.chain().focus().unsetHighlight().run(),
|
|
6994
|
+
J.chain().focus().unsetHighlight().run(), H("none");
|
|
6979
6995
|
},
|
|
6980
6996
|
children: ["✕", " "]
|
|
6981
6997
|
})]
|
|
@@ -6985,102 +7001,102 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
6985
7001
|
type: "url",
|
|
6986
7002
|
className: "flex-1 px-2 py-1 text-xs rounded-md border border-default-200 bg-background focus:outline-none focus:border-primary",
|
|
6987
7003
|
placeholder: "https://...",
|
|
6988
|
-
value:
|
|
6989
|
-
onChange: (e) =>
|
|
7004
|
+
value: U,
|
|
7005
|
+
onChange: (e) => me(e.target.value),
|
|
6990
7006
|
onKeyDown: (e) => {
|
|
6991
|
-
e.key === "Enter" ? (
|
|
7007
|
+
e.key === "Enter" ? (U.trim() && J.chain().focus().setLink({ href: U.trim() }).run(), H("none")) : e.key === "Escape" && H("none");
|
|
6992
7008
|
}
|
|
6993
7009
|
}), /* @__PURE__ */ D("button", {
|
|
6994
7010
|
type: "button",
|
|
6995
7011
|
className: "px-2 py-1 text-xs rounded-md bg-primary text-white hover:opacity-90",
|
|
6996
7012
|
onClick: () => {
|
|
6997
|
-
|
|
7013
|
+
U.trim() && J.chain().focus().setLink({ href: U.trim() }).run(), H("none");
|
|
6998
7014
|
},
|
|
6999
7015
|
children: "确定"
|
|
7000
7016
|
})]
|
|
7001
7017
|
})
|
|
7002
7018
|
})] }),
|
|
7003
|
-
!k && j &&
|
|
7019
|
+
!k && j && ae(/* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
7004
7020
|
className: "fixed inset-0 z-[9998]",
|
|
7005
|
-
onClick: () =>
|
|
7021
|
+
onClick: () => M(!1)
|
|
7006
7022
|
}), /* @__PURE__ */ O("div", {
|
|
7007
|
-
ref:
|
|
7023
|
+
ref: L,
|
|
7008
7024
|
"data-lenis-prevent": !0,
|
|
7009
|
-
style:
|
|
7010
|
-
className: `ai-panel relative flex flex-col bg-background border border-default-200 rounded-xl shadow-xl${
|
|
7025
|
+
style: te,
|
|
7026
|
+
className: `ai-panel relative flex flex-col bg-background border border-default-200 rounded-xl shadow-xl${P === "above" ? " ai-panel--above" : ""}`,
|
|
7011
7027
|
onClick: (e) => e.stopPropagation(),
|
|
7012
7028
|
children: [/* @__PURE__ */ D("span", {
|
|
7013
7029
|
className: "ai-panel__arrow",
|
|
7014
|
-
style: { left: `${
|
|
7030
|
+
style: { left: `${oe}%` },
|
|
7015
7031
|
"aria-hidden": "true"
|
|
7016
|
-
}), /* @__PURE__ */ D(
|
|
7032
|
+
}), /* @__PURE__ */ D(tn, {
|
|
7017
7033
|
editor: J,
|
|
7018
|
-
onClose: () =>
|
|
7034
|
+
onClose: () => M(!1)
|
|
7019
7035
|
})]
|
|
7020
7036
|
})] }), document.body),
|
|
7021
|
-
|
|
7022
|
-
fallback: /* @__PURE__ */ D(
|
|
7023
|
-
children: /* @__PURE__ */ D(
|
|
7024
|
-
open:
|
|
7037
|
+
R && /* @__PURE__ */ D(v, {
|
|
7038
|
+
fallback: /* @__PURE__ */ D(Si, {}),
|
|
7039
|
+
children: /* @__PURE__ */ D(_i, {
|
|
7040
|
+
open: R,
|
|
7025
7041
|
onClose: () => se(!1),
|
|
7026
7042
|
onInsert: et,
|
|
7027
|
-
validate: (e) => J ?
|
|
7043
|
+
validate: (e) => J ? sn(J.state.doc, e, {
|
|
7028
7044
|
maxAttachmentSize: o,
|
|
7029
7045
|
maxTotalAttachmentSize: s
|
|
7030
7046
|
}) : null
|
|
7031
7047
|
})
|
|
7032
7048
|
}),
|
|
7033
|
-
|
|
7034
|
-
fallback: /* @__PURE__ */ D(
|
|
7035
|
-
children: /* @__PURE__ */ D(
|
|
7036
|
-
open:
|
|
7037
|
-
onClose: () =>
|
|
7049
|
+
ce && /* @__PURE__ */ D(v, {
|
|
7050
|
+
fallback: /* @__PURE__ */ D(Si, {}),
|
|
7051
|
+
children: /* @__PURE__ */ D(bi, {
|
|
7052
|
+
open: ce,
|
|
7053
|
+
onClose: () => le(!1),
|
|
7038
7054
|
onInsert: tt
|
|
7039
7055
|
})
|
|
7040
7056
|
}),
|
|
7041
|
-
|
|
7042
|
-
fallback: /* @__PURE__ */ D(
|
|
7043
|
-
children: /* @__PURE__ */ D(
|
|
7044
|
-
open:
|
|
7045
|
-
onClose: () =>
|
|
7057
|
+
ue && /* @__PURE__ */ D(v, {
|
|
7058
|
+
fallback: /* @__PURE__ */ D(Si, {}),
|
|
7059
|
+
children: /* @__PURE__ */ D(vi, {
|
|
7060
|
+
open: ue,
|
|
7061
|
+
onClose: () => z(!1)
|
|
7046
7062
|
})
|
|
7047
7063
|
}),
|
|
7048
|
-
|
|
7049
|
-
fallback: /* @__PURE__ */ D(
|
|
7050
|
-
children: /* @__PURE__ */ D(
|
|
7051
|
-
open:
|
|
7052
|
-
onClose: () =>
|
|
7064
|
+
B && /* @__PURE__ */ D(v, {
|
|
7065
|
+
fallback: /* @__PURE__ */ D(Si, {}),
|
|
7066
|
+
children: /* @__PURE__ */ D(yi, {
|
|
7067
|
+
open: B,
|
|
7068
|
+
onClose: () => de(!1),
|
|
7053
7069
|
editor: J
|
|
7054
7070
|
})
|
|
7055
7071
|
}),
|
|
7056
|
-
|
|
7057
|
-
fallback: /* @__PURE__ */ D(
|
|
7058
|
-
children: /* @__PURE__ */ D(
|
|
7059
|
-
open: !!
|
|
7060
|
-
filename:
|
|
7072
|
+
W && /* @__PURE__ */ D(v, {
|
|
7073
|
+
fallback: /* @__PURE__ */ D(Si, {}),
|
|
7074
|
+
children: /* @__PURE__ */ D(xi, {
|
|
7075
|
+
open: !!W,
|
|
7076
|
+
filename: W.filename,
|
|
7061
7077
|
onRender: () => {
|
|
7062
|
-
|
|
7078
|
+
W.resolve("render"), he(null);
|
|
7063
7079
|
},
|
|
7064
7080
|
onAttach: () => {
|
|
7065
|
-
|
|
7081
|
+
W.resolve("attach"), he(null);
|
|
7066
7082
|
},
|
|
7067
7083
|
onClose: () => {
|
|
7068
|
-
|
|
7084
|
+
W.resolve(null), he(null);
|
|
7069
7085
|
}
|
|
7070
7086
|
})
|
|
7071
7087
|
}),
|
|
7072
7088
|
/* @__PURE__ */ D("div", {
|
|
7073
|
-
ref:
|
|
7089
|
+
ref: De,
|
|
7074
7090
|
className: "flex editor-body",
|
|
7075
7091
|
children: /* @__PURE__ */ O("div", {
|
|
7076
7092
|
className: "relative min-w-0 flex-1",
|
|
7077
7093
|
children: [
|
|
7078
|
-
/* @__PURE__ */ D(
|
|
7079
|
-
!k && /* @__PURE__ */ D(
|
|
7094
|
+
/* @__PURE__ */ D(ee, { editor: J }),
|
|
7095
|
+
!k && /* @__PURE__ */ D(li, { editor: J }),
|
|
7080
7096
|
/* @__PURE__ */ D("div", {
|
|
7081
|
-
className: `${
|
|
7097
|
+
className: `${K || q ? "fixed" : "absolute"} bottom-2 right-4 z-10 pointer-events-none select-none`,
|
|
7082
7098
|
children: /* @__PURE__ */ O("span", {
|
|
7083
|
-
className: `text-xs ${
|
|
7099
|
+
className: `text-xs ${Ze ? "bg-danger/10 text-danger font-medium px-2 py-0.5 rounded" : a && Xe > a * .9 ? "bg-warning/10 text-warning px-2 py-0.5 rounded" : "text-default-300"}`,
|
|
7084
7100
|
children: [
|
|
7085
7101
|
Xe,
|
|
7086
7102
|
a ? ` / ${a}` : "",
|
|
@@ -7091,14 +7107,14 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
7091
7107
|
]
|
|
7092
7108
|
})
|
|
7093
7109
|
}),
|
|
7094
|
-
h &&
|
|
7110
|
+
h && ye && /* @__PURE__ */ D(Tt, {
|
|
7095
7111
|
editor: J,
|
|
7096
|
-
onClose: () =>
|
|
7112
|
+
onClose: () => be(!1)
|
|
7097
7113
|
}),
|
|
7098
7114
|
rt && /* @__PURE__ */ D("button", {
|
|
7099
7115
|
type: "button",
|
|
7100
7116
|
className: "qingwu-toc-fab",
|
|
7101
|
-
onClick: () =>
|
|
7117
|
+
onClick: () => ve(!0),
|
|
7102
7118
|
title: "目录",
|
|
7103
7119
|
"aria-label": "打开目录",
|
|
7104
7120
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -7114,7 +7130,7 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
7114
7130
|
})
|
|
7115
7131
|
})
|
|
7116
7132
|
}),
|
|
7117
|
-
|
|
7133
|
+
_e && /* @__PURE__ */ O("div", {
|
|
7118
7134
|
className: "qingwu-toc-drawer toc-scroll",
|
|
7119
7135
|
children: [/* @__PURE__ */ O("div", {
|
|
7120
7136
|
className: "qed-drawer-head",
|
|
@@ -7124,7 +7140,7 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
7124
7140
|
}), /* @__PURE__ */ D("button", {
|
|
7125
7141
|
type: "button",
|
|
7126
7142
|
className: "qed-drawer-head__close",
|
|
7127
|
-
onClick: () =>
|
|
7143
|
+
onClick: () => ve(!1),
|
|
7128
7144
|
"aria-label": "关闭目录",
|
|
7129
7145
|
children: /* @__PURE__ */ D("svg", {
|
|
7130
7146
|
fill: "none",
|
|
@@ -7139,20 +7155,20 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
7139
7155
|
})
|
|
7140
7156
|
})
|
|
7141
7157
|
})]
|
|
7142
|
-
}), /* @__PURE__ */ D(
|
|
7158
|
+
}), /* @__PURE__ */ D(ct, {
|
|
7143
7159
|
editor: J,
|
|
7144
7160
|
className: "!p-3",
|
|
7145
7161
|
onClose: () => {
|
|
7146
|
-
|
|
7162
|
+
ve(!1), ge(!1);
|
|
7147
7163
|
}
|
|
7148
7164
|
})]
|
|
7149
7165
|
})
|
|
7150
7166
|
]
|
|
7151
7167
|
}), nt && /* @__PURE__ */ D("aside", {
|
|
7152
7168
|
className: "qingwu-toc-desktop toc-scroll",
|
|
7153
|
-
children: /* @__PURE__ */ D(
|
|
7169
|
+
children: /* @__PURE__ */ D(ct, {
|
|
7154
7170
|
editor: J,
|
|
7155
|
-
onClose: () =>
|
|
7171
|
+
onClose: () => ge(!1)
|
|
7156
7172
|
})
|
|
7157
7173
|
})]
|
|
7158
7174
|
}) : /* @__PURE__ */ D("div", {
|
|
@@ -7162,7 +7178,7 @@ var gi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
|
|
|
7162
7178
|
};
|
|
7163
7179
|
//#endregion
|
|
7164
7180
|
//#region src/editor/clipper/receiver-browser.ts
|
|
7165
|
-
function
|
|
7181
|
+
function wi(e) {
|
|
7166
7182
|
let t = async (t) => {
|
|
7167
7183
|
let n = t.data;
|
|
7168
7184
|
if (!n || typeof n != "object" || n.kind !== "qingwu-clip") return;
|
|
@@ -7179,7 +7195,7 @@ function Ci(e) {
|
|
|
7179
7195
|
}
|
|
7180
7196
|
//#endregion
|
|
7181
7197
|
//#region src/editor/storage/providers/cos.ts
|
|
7182
|
-
function
|
|
7198
|
+
function Ti(e) {
|
|
7183
7199
|
return g({
|
|
7184
7200
|
endpoint: `https://cos.${e.region}.myqcloud.com`,
|
|
7185
7201
|
bucket: e.bucket,
|
|
@@ -7193,7 +7209,7 @@ function wi(e) {
|
|
|
7193
7209
|
}
|
|
7194
7210
|
//#endregion
|
|
7195
7211
|
//#region src/editor/storage/providers/oss.ts
|
|
7196
|
-
function
|
|
7212
|
+
function Ei(e) {
|
|
7197
7213
|
return g({
|
|
7198
7214
|
endpoint: `https://${e.bucket}.${e.region}.aliyuncs.com`,
|
|
7199
7215
|
bucket: e.bucket,
|
|
@@ -7206,4 +7222,4 @@ function Ti(e) {
|
|
|
7206
7222
|
});
|
|
7207
7223
|
}
|
|
7208
7224
|
//#endregion
|
|
7209
|
-
export {
|
|
7225
|
+
export { Zn as CODE_LANGUAGES, $n as CodeBlock, Cr as ImageUpload, et as ImageUploadDialog, Ci as QingWuAIEditor, Jr as RelativeMedia, Ct as SearchHighlight, ct as TocPanel, Un as VideoEmbed, lt as buildSystemPrompt, dt as createAILanguageModelProvider, Ti as createCOSStorage, ht as createDeepSeekProvider, _ as createLocalStorage, Ei as createOSSStorage, mt as createOpenAICompatProvider, gt as createOpenAIProvider, _t as createQwenProvider, g as createS3Storage, Xr as createSlashCommandExtension, h as escapeHtml, an as formatBytes, pt as getAIProvider, ri as getBubbleMenuActions, Zr as getDefaultSlashCommands, rn as getDocAttachmentTotal, $r as getEditorExtensions, u as getLocale, ni as getSearchEngine, wt as getSearchState, c as getStorageInfo, o as getStorageProvider, s as loadStorageConfig, r as registerS3PreviewConfig, d as sanitizeHtml, p as sanitizeSvg, ft as setAIProvider, pn as setConfirmProvider, l as setLocale, ti as setSearchEngine, i as setStorageProvider, Ze as setToastProvider, n as signPreviewUrlHeaders, wi as startBrowserClipperReceiver, Qe as subscribeToast, f as t, m as tf, X as toast, sn as validateAttachmentFile };
|