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