@qingwu-ui/ai-editor 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/release-notes-dialog.d.ts.map +1 -1
- package/dist/editor/ai-editor.d.ts.map +1 -1
- package/dist/editor/extensions/bubble-menu.d.ts +4 -0
- package/dist/editor/extensions/bubble-menu.d.ts.map +1 -1
- package/dist/editor/extensions/code-block-view.d.ts.map +1 -1
- package/dist/editor/extensions/math-view.d.ts +5 -4
- package/dist/editor/extensions/math-view.d.ts.map +1 -1
- package/dist/editor/i18n/en-US.d.ts +2 -0
- package/dist/editor/i18n/en-US.d.ts.map +1 -1
- package/dist/editor/i18n/zh-CN.d.ts +2 -0
- package/dist/editor/i18n/zh-CN.d.ts.map +1 -1
- package/dist/editor/icons.d.ts +1 -0
- package/dist/editor/icons.d.ts.map +1 -1
- package/dist/{export-dialog-DMY_QIVq.js → export-dialog-BwVrBASi.js} +1 -1
- package/dist/{export-dialog-BKShGPNv.cjs → export-dialog-wG4oZtsB.cjs} +1 -1
- package/dist/index.cjs +16 -14
- package/dist/index.js +970 -927
- package/dist/{sanitize-DdIs-mcO.js → sanitize-Cm8YOT1D.js} +4 -0
- package/dist/sanitize-DfFeo1bZ.cjs +1 -0
- package/dist/{signed-fetch-ULpEJyn5.cjs → signed-fetch-BO5NjYGN.cjs} +1 -1
- package/dist/{storage-settings-dialog-WBHfAUak.cjs → storage-settings-dialog-LY_-VFA4.cjs} +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
- package/dist/sanitize-D4Bd9RtA.cjs +0 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as e, n as t, r as n, t as r } from "./signed-fetch-CPPWCUUS.js";
|
|
2
2
|
import { a as i, i as a, n as o, r as s, t as c } from "./storage-DUcmM2Ex.js";
|
|
3
|
-
import { a as l, i as u, n as d, o as f, r as p, s as m, t as h } from "./sanitize-
|
|
3
|
+
import { a as l, i as u, n as d, o as f, r as p, s as m, t as h } from "./sanitize-Cm8YOT1D.js";
|
|
4
4
|
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";
|
|
@@ -8,58 +8,58 @@ import { generateText as k, streamText as A } from "ai";
|
|
|
8
8
|
import { DOMParser as j, Fragment as M, Slice as N } from "@tiptap/pm/model";
|
|
9
9
|
import { EditorContent as ee, NodeViewWrapper as P, ReactNodeViewRenderer as F, ReactRenderer as I, useEditor as te } from "@tiptap/react";
|
|
10
10
|
import { BubbleMenu as ne } from "@tiptap/react/menus";
|
|
11
|
-
import { createPortal as
|
|
12
|
-
import { Extension as
|
|
13
|
-
import { NodeSelection as
|
|
14
|
-
import { Decoration as
|
|
15
|
-
import { Image as
|
|
16
|
-
import { Link as
|
|
17
|
-
import { Underline as
|
|
18
|
-
import
|
|
19
|
-
import { CharacterCount as
|
|
20
|
-
import { Color as
|
|
21
|
-
import { Highlight as
|
|
22
|
-
import { HorizontalRule as
|
|
23
|
-
import { Placeholder as
|
|
24
|
-
import { Table as
|
|
25
|
-
import { TableCell as
|
|
26
|
-
import { TableHeader as
|
|
27
|
-
import { TableRow as
|
|
28
|
-
import { TaskItem as
|
|
29
|
-
import { TaskList as
|
|
30
|
-
import { TextStyle as
|
|
31
|
-
import { Markdown as
|
|
32
|
-
import { CodeBlockLowlight as
|
|
33
|
-
import
|
|
34
|
-
import { common as
|
|
35
|
-
import
|
|
36
|
-
import
|
|
11
|
+
import { createPortal as re } from "react-dom";
|
|
12
|
+
import { Extension as L, InputRule as ie, Node as ae, markInputRule as R } from "@tiptap/core";
|
|
13
|
+
import { NodeSelection as z, Plugin as B, PluginKey as V, TextSelection as oe } from "@tiptap/pm/state";
|
|
14
|
+
import { Decoration as se, DecorationSet as H } from "@tiptap/pm/view";
|
|
15
|
+
import { Image as U } from "@tiptap/extension-image";
|
|
16
|
+
import { Link as ce } from "@tiptap/extension-link";
|
|
17
|
+
import { Underline as W } from "@tiptap/extension-underline";
|
|
18
|
+
import G from "@tiptap/starter-kit";
|
|
19
|
+
import { CharacterCount as le } from "@tiptap/extension-character-count";
|
|
20
|
+
import { Color as K } from "@tiptap/extension-color";
|
|
21
|
+
import { Highlight as ue } from "@tiptap/extension-highlight";
|
|
22
|
+
import { HorizontalRule as de } from "@tiptap/extension-horizontal-rule";
|
|
23
|
+
import { Placeholder as fe } from "@tiptap/extension-placeholder";
|
|
24
|
+
import { Table as pe } from "@tiptap/extension-table";
|
|
25
|
+
import { TableCell as q } from "@tiptap/extension-table-cell";
|
|
26
|
+
import { TableHeader as me } from "@tiptap/extension-table-header";
|
|
27
|
+
import { TableRow as he } from "@tiptap/extension-table-row";
|
|
28
|
+
import { TaskItem as ge } from "@tiptap/extension-task-item";
|
|
29
|
+
import { TaskList as _e } from "@tiptap/extension-task-list";
|
|
30
|
+
import { TextStyle as ve } from "@tiptap/extension-text-style";
|
|
31
|
+
import { Markdown as ye } from "tiptap-markdown";
|
|
32
|
+
import { CodeBlockLowlight as be } from "@tiptap/extension-code-block-lowlight";
|
|
33
|
+
import xe from "highlight.js/lib/languages/dockerfile";
|
|
34
|
+
import { common as Se, createLowlight as Ce } from "lowlight";
|
|
35
|
+
import we from "katex";
|
|
36
|
+
import Te, { exitSuggestion as Ee, findSuggestionMatch as De } from "@tiptap/suggestion";
|
|
37
37
|
//#region ../text-layout/dist/index.mjs
|
|
38
|
-
var
|
|
39
|
-
function
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
var
|
|
43
|
-
function
|
|
44
|
-
let n =
|
|
45
|
-
n || (n = /* @__PURE__ */ new Map(),
|
|
38
|
+
var Oe = null, ke = null;
|
|
39
|
+
function Ae() {
|
|
40
|
+
return ke || (typeof document > "u" ? null : (Oe = document.createElement("canvas"), ke = Oe.getContext("2d"), ke));
|
|
41
|
+
}
|
|
42
|
+
var je = /* @__PURE__ */ new Map();
|
|
43
|
+
function Me(e, t) {
|
|
44
|
+
let n = je.get(t);
|
|
45
|
+
n || (n = /* @__PURE__ */ new Map(), je.set(t, n));
|
|
46
46
|
let r = n.get(e);
|
|
47
47
|
if (r !== void 0) return r;
|
|
48
|
-
let i =
|
|
49
|
-
return i ? (i.font = t, r = i.measureText(e).width) : r =
|
|
48
|
+
let i = Ae();
|
|
49
|
+
return i ? (i.font = t, r = i.measureText(e).width) : r = Ne(e, t), n.set(e, r), r;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function Ne(e, t) {
|
|
52
52
|
let n = parseFloat(t) || 16, r = 0;
|
|
53
|
-
for (let t of e)
|
|
53
|
+
for (let t of e) Pe(t.codePointAt(0) ?? 0) ? r += n : t === " " ? r += n * .3 : r += n * .55;
|
|
54
54
|
return r;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function Pe(e) {
|
|
57
57
|
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;
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function Fe(e) {
|
|
60
60
|
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;
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function Ie(e, t) {
|
|
63
63
|
let n = [], r = [];
|
|
64
64
|
if (typeof Intl < "u" && Intl.Segmenter) try {
|
|
65
65
|
let t = new Intl.Segmenter("zh", { granularity: "grapheme" });
|
|
@@ -70,27 +70,27 @@ function Pe(e, t) {
|
|
|
70
70
|
else r = [...e];
|
|
71
71
|
for (let e of r) {
|
|
72
72
|
let r = e.codePointAt(0) ?? 0, i = "latin";
|
|
73
|
-
e === "\n" ? i = "break" : e === " " || e === " " ? i = "space" :
|
|
73
|
+
e === "\n" ? i = "break" : e === " " || e === " " ? i = "space" : Pe(r) && (i = Fe(r) ? "punct" : "cjk"), n.push({
|
|
74
74
|
text: e,
|
|
75
|
-
width:
|
|
75
|
+
width: Me(e, t),
|
|
76
76
|
type: i
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
return n;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function J(e, t, n) {
|
|
82
82
|
let r = 0, i = Math.min(n, e.length);
|
|
83
83
|
for (let n = t; n < i; n++) r += e[n].width;
|
|
84
84
|
return r;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function Le(e, t, n, r) {
|
|
87
87
|
return {
|
|
88
88
|
text: e.slice(t, Math.min(n, e.length)).map((e) => e.text).join(""),
|
|
89
89
|
width: r
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
let { maxWidth: r, lineHeight: i, maxLines: a, overflowWrap: o = "break-word" } = t, s =
|
|
92
|
+
function Re(e, t, n = "16px system-ui") {
|
|
93
|
+
let { maxWidth: r, lineHeight: i, maxLines: a, overflowWrap: o = "break-word" } = t, s = Ie(e, n), c = [], l = {
|
|
94
94
|
lineStart: 0,
|
|
95
95
|
lineWidth: 0,
|
|
96
96
|
lastBreakIdx: -1,
|
|
@@ -99,28 +99,28 @@ function Le(e, t, n = "16px system-ui") {
|
|
|
99
99
|
for (let e = 0; e < s.length; e++) {
|
|
100
100
|
let t = s[e];
|
|
101
101
|
if (t.type === "break") {
|
|
102
|
-
c.push(
|
|
102
|
+
c.push(Le(s, l.lineStart, e, l.lineWidth)), l.lineStart = e + 1, l.lineWidth = 0, l.lastBreakIdx = -1;
|
|
103
103
|
continue;
|
|
104
104
|
}
|
|
105
105
|
let n = l.lineWidth + t.width;
|
|
106
106
|
if (t.type === "space") {
|
|
107
|
-
if (n > r && l.lineWidth > 0 ? (l.lastBreakIdx >= 0 ? (c.push(
|
|
107
|
+
if (n > r && l.lineWidth > 0 ? (l.lastBreakIdx >= 0 ? (c.push(Le(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = J(s, l.lineStart, e + 1)) : (c.push(Le(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;
|
|
108
108
|
continue;
|
|
109
109
|
}
|
|
110
110
|
if (t.type === "cjk") {
|
|
111
|
-
if (n > r && l.lineWidth > 0 ? (c.push(
|
|
111
|
+
if (n > r && l.lineWidth > 0 ? (c.push(Le(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;
|
|
112
112
|
continue;
|
|
113
113
|
}
|
|
114
114
|
if (t.type === "punct") {
|
|
115
|
-
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(
|
|
115
|
+
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(Le(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = J(s, l.lineStart, e + 1)) : l.lineWidth = n, l.lastBreakIdx = -1) : l.lineWidth = n, a && c.length >= a) break;
|
|
116
116
|
continue;
|
|
117
117
|
}
|
|
118
|
-
if (n > r && l.lineWidth > 0 ? l.lastBreakIdx >= 0 ? (c.push(
|
|
118
|
+
if (n > r && l.lineWidth > 0 ? l.lastBreakIdx >= 0 ? (c.push(Le(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = J(s, l.lineStart, e + 1), l.lastBreakIdx = -1) : o === "break-word" ? (c.push(Le(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width) : l.lineWidth = n : l.lineWidth = n, a && c.length >= a) break;
|
|
119
119
|
}
|
|
120
120
|
let u = l.lineStart < s.length;
|
|
121
121
|
if (u && (!a || c.length < a)) {
|
|
122
|
-
let e =
|
|
123
|
-
c.push(
|
|
122
|
+
let e = J(s, l.lineStart, s.length);
|
|
123
|
+
c.push(Le(s, l.lineStart, s.length, e));
|
|
124
124
|
}
|
|
125
125
|
return {
|
|
126
126
|
lines: c,
|
|
@@ -131,22 +131,22 @@ function Le(e, t, n = "16px system-ui") {
|
|
|
131
131
|
}
|
|
132
132
|
//#endregion
|
|
133
133
|
//#region ../toast/dist/index.mjs
|
|
134
|
-
var
|
|
135
|
-
function
|
|
134
|
+
var ze = typeof window < "u" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, Be = "13.5px -apple-system, BlinkMacSystemFont, \"SF Pro Text\", \"PingFang SC\", \"Microsoft YaHei\", system-ui, sans-serif";
|
|
135
|
+
function Ve() {
|
|
136
136
|
if (typeof window > "u") return 290;
|
|
137
137
|
let e = window.innerWidth;
|
|
138
138
|
return e <= 480 ? Math.max(140, e - 98) : 290;
|
|
139
139
|
}
|
|
140
|
-
var
|
|
140
|
+
var He = {
|
|
141
141
|
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>",
|
|
142
142
|
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>",
|
|
143
143
|
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>",
|
|
144
144
|
error: "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"15\" y1=\"9\" x2=\"9\" y2=\"15\"/><line x1=\"9\" y1=\"9\" x2=\"15\" y2=\"15\"/></svg>"
|
|
145
|
-
},
|
|
146
|
-
function
|
|
147
|
-
return `qt${
|
|
145
|
+
}, Y = 1;
|
|
146
|
+
function Ue() {
|
|
147
|
+
return `qt${Y++}${Date.now().toString(36)}`;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function X(e, t, n) {
|
|
150
150
|
let r = document.createElement(e);
|
|
151
151
|
return t && (r.className = t), n != null && (r.innerHTML = n), r;
|
|
152
152
|
}
|
|
@@ -155,7 +155,7 @@ function We(e, t) {
|
|
|
155
155
|
for (let t = 0; t < n.length; t++) {
|
|
156
156
|
let r = n[t];
|
|
157
157
|
if (r) if (t % 2 == 1) {
|
|
158
|
-
let t =
|
|
158
|
+
let t = X("em", "qt-mark");
|
|
159
159
|
t.textContent = r, e.appendChild(t);
|
|
160
160
|
} else e.appendChild(document.createTextNode(r));
|
|
161
161
|
}
|
|
@@ -190,10 +190,10 @@ var Je = class {
|
|
|
190
190
|
}
|
|
191
191
|
ensureContainer(e) {
|
|
192
192
|
let t = this.containers.get(e);
|
|
193
|
-
return t || (t =
|
|
193
|
+
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;
|
|
194
194
|
}
|
|
195
195
|
show(e, t) {
|
|
196
|
-
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 =
|
|
196
|
+
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 = Ue(), u = {
|
|
197
197
|
id: l,
|
|
198
198
|
type: n,
|
|
199
199
|
dismissible: a,
|
|
@@ -276,30 +276,30 @@ var Je = class {
|
|
|
276
276
|
this.containers.clear();
|
|
277
277
|
}
|
|
278
278
|
buildElement(e, t, n, r, i, a, o) {
|
|
279
|
-
let s =
|
|
279
|
+
let s = X("div", `qt-toast qt-${n}${i == null ? "" : " qt-truncate"}${a || o ? " qt-rich" : ""}`);
|
|
280
280
|
s.setAttribute("data-qt-id", e);
|
|
281
|
-
let c =
|
|
282
|
-
c.innerHTML =
|
|
283
|
-
let l =
|
|
284
|
-
maxWidth:
|
|
281
|
+
let c = X("span", "qt-icon");
|
|
282
|
+
c.innerHTML = He[n], s.appendChild(c);
|
|
283
|
+
let l = X("div", "qt-body"), u = X("span", "qt-msg"), d = Re(t, {
|
|
284
|
+
maxWidth: Ve(),
|
|
285
285
|
lineHeight: 1,
|
|
286
286
|
maxLines: i
|
|
287
|
-
},
|
|
287
|
+
}, Be);
|
|
288
288
|
if (d.lineCount <= 1 ? We(u, t) : d.lines.forEach((e, t) => {
|
|
289
|
-
let n =
|
|
289
|
+
let n = X("span", "qt-line"), r = e.text;
|
|
290
290
|
t === d.lines.length - 1 && d.truncated && !r.endsWith("…") && (r += "…"), We(n, r), u.appendChild(n);
|
|
291
291
|
}), l.appendChild(u), a) {
|
|
292
|
-
let e =
|
|
292
|
+
let e = X("div", "qt-desc");
|
|
293
293
|
e.textContent = a, l.appendChild(e);
|
|
294
294
|
}
|
|
295
295
|
if (s.appendChild(l), o) {
|
|
296
|
-
let t =
|
|
296
|
+
let t = X("button", "qt-action");
|
|
297
297
|
t.type = "button", t.textContent = o.label, t.addEventListener("click", (t) => {
|
|
298
298
|
t.stopPropagation(), this.dismiss(e), o.onClick();
|
|
299
299
|
}), s.appendChild(t);
|
|
300
300
|
}
|
|
301
301
|
if (r) {
|
|
302
|
-
let t =
|
|
302
|
+
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>");
|
|
303
303
|
t.type = "button", t.setAttribute("aria-label", "关闭通知"), t.addEventListener("click", (t) => {
|
|
304
304
|
t.stopPropagation(), this.dismiss(e);
|
|
305
305
|
}), s.appendChild(t);
|
|
@@ -333,7 +333,7 @@ var Je = class {
|
|
|
333
333
|
let t = () => {
|
|
334
334
|
e.element.remove(), this.toasts.delete(e.id), this._dequeue();
|
|
335
335
|
};
|
|
336
|
-
if (
|
|
336
|
+
if (ze) t();
|
|
337
337
|
else {
|
|
338
338
|
let n = !1, r = () => {
|
|
339
339
|
n || (n = !0, t());
|
|
@@ -878,7 +878,7 @@ var ft = 84, pt = 3e3, mt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
878
878
|
});
|
|
879
879
|
}, []), ne = b(() => {
|
|
880
880
|
c(new Set(j));
|
|
881
|
-
}, [j]),
|
|
881
|
+
}, [j]), re = b(() => {
|
|
882
882
|
c(/* @__PURE__ */ new Set());
|
|
883
883
|
}, []);
|
|
884
884
|
return r.length ? /* @__PURE__ */ O("nav", {
|
|
@@ -970,7 +970,7 @@ var ft = 84, pt = 3e3, mt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
970
970
|
}), /* @__PURE__ */ D("button", {
|
|
971
971
|
type: "button",
|
|
972
972
|
className: "toc-action-btn",
|
|
973
|
-
onClick:
|
|
973
|
+
onClick: re,
|
|
974
974
|
title: "全部展开",
|
|
975
975
|
"aria-label": "全部展开",
|
|
976
976
|
disabled: N,
|
|
@@ -1255,7 +1255,7 @@ var wt = {
|
|
|
1255
1255
|
wholeWord: !1,
|
|
1256
1256
|
matches: [],
|
|
1257
1257
|
currentIndex: -1
|
|
1258
|
-
}, Tt = new
|
|
1258
|
+
}, Tt = new V("search-highlight");
|
|
1259
1259
|
function Et(e) {
|
|
1260
1260
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1261
1261
|
}
|
|
@@ -1277,9 +1277,9 @@ function Dt(e, t) {
|
|
|
1277
1277
|
}), c;
|
|
1278
1278
|
}
|
|
1279
1279
|
function Ot(e, t) {
|
|
1280
|
-
if (t.matches.length === 0) return
|
|
1281
|
-
let n = t.matches.map((e, n) =>
|
|
1282
|
-
return
|
|
1280
|
+
if (t.matches.length === 0) return H.empty;
|
|
1281
|
+
let n = t.matches.map((e, n) => se.inline(e.from, e.to, { class: n === t.currentIndex ? "search-highlight search-highlight--active" : "search-highlight" }));
|
|
1282
|
+
return H.create(e, n);
|
|
1283
1283
|
}
|
|
1284
1284
|
function kt(e, t) {
|
|
1285
1285
|
if (t.currentIndex < 0 || t.currentIndex >= t.matches.length) return;
|
|
@@ -1306,10 +1306,10 @@ function kt(e, t) {
|
|
|
1306
1306
|
} catch {}
|
|
1307
1307
|
});
|
|
1308
1308
|
}
|
|
1309
|
-
var At =
|
|
1309
|
+
var At = L.create({
|
|
1310
1310
|
name: "searchHighlight",
|
|
1311
1311
|
addProseMirrorPlugins() {
|
|
1312
|
-
return [new
|
|
1312
|
+
return [new B({
|
|
1313
1313
|
key: Tt,
|
|
1314
1314
|
state: {
|
|
1315
1315
|
init: () => wt,
|
|
@@ -1334,7 +1334,7 @@ var At = R.create({
|
|
|
1334
1334
|
},
|
|
1335
1335
|
props: { decorations(e) {
|
|
1336
1336
|
let t = Tt.getState(e);
|
|
1337
|
-
return t ? Ot(e.doc, t) :
|
|
1337
|
+
return t ? Ot(e.doc, t) : H.empty;
|
|
1338
1338
|
} }
|
|
1339
1339
|
})];
|
|
1340
1340
|
},
|
|
@@ -1654,7 +1654,10 @@ var Nt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1654
1654
|
}), Ut = (e) => /* @__PURE__ */ O(Q, {
|
|
1655
1655
|
...e,
|
|
1656
1656
|
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" })]
|
|
1657
|
-
}), Wt = (e) => /* @__PURE__ */
|
|
1657
|
+
}), Wt = (e) => /* @__PURE__ */ D(Q, {
|
|
1658
|
+
...e,
|
|
1659
|
+
children: /* @__PURE__ */ D("path", { d: "M18 5H6l6 7-6 7h12" })
|
|
1660
|
+
}), Gt = (e) => /* @__PURE__ */ O(Q, {
|
|
1658
1661
|
...e,
|
|
1659
1662
|
children: [
|
|
1660
1663
|
/* @__PURE__ */ D("circle", {
|
|
@@ -1673,13 +1676,13 @@ var Nt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1673
1676
|
r: "1"
|
|
1674
1677
|
})
|
|
1675
1678
|
]
|
|
1676
|
-
}),
|
|
1679
|
+
}), Kt = (e) => /* @__PURE__ */ O(Q, {
|
|
1677
1680
|
...e,
|
|
1678
1681
|
children: [/* @__PURE__ */ D("path", { d: "M18 6 6 18" }), /* @__PURE__ */ D("path", { d: "m6 6 12 12" })]
|
|
1679
1682
|
});
|
|
1680
1683
|
//#endregion
|
|
1681
1684
|
//#region src/editor/storage/remove-resource.ts
|
|
1682
|
-
async function
|
|
1685
|
+
async function qt(e) {
|
|
1683
1686
|
if (e) {
|
|
1684
1687
|
if (e.startsWith("blob:")) {
|
|
1685
1688
|
URL.revokeObjectURL(e);
|
|
@@ -1694,61 +1697,61 @@ async function Kt(e) {
|
|
|
1694
1697
|
}
|
|
1695
1698
|
//#endregion
|
|
1696
1699
|
//#region src/editor/ai/pending-removal.ts
|
|
1697
|
-
var
|
|
1700
|
+
var Jt = 3e4, Yt = /* @__PURE__ */ new Set([
|
|
1698
1701
|
"image",
|
|
1699
1702
|
"attachmentEmbed",
|
|
1700
1703
|
"audioEmbed",
|
|
1701
1704
|
"videoEmbed"
|
|
1702
|
-
]),
|
|
1703
|
-
function
|
|
1705
|
+
]), Xt = /* @__PURE__ */ new WeakMap();
|
|
1706
|
+
function Zt(e) {
|
|
1704
1707
|
let t = /* @__PURE__ */ new Set();
|
|
1705
1708
|
return e.state.doc.descendants((e) => {
|
|
1706
|
-
if (
|
|
1709
|
+
if (Yt.has(e.type.name)) {
|
|
1707
1710
|
let n = e.attrs.src;
|
|
1708
1711
|
n && t.add(n);
|
|
1709
1712
|
}
|
|
1710
1713
|
return !0;
|
|
1711
1714
|
}), t;
|
|
1712
1715
|
}
|
|
1713
|
-
function
|
|
1714
|
-
let t =
|
|
1716
|
+
function Qt(e) {
|
|
1717
|
+
let t = Xt.get(e);
|
|
1715
1718
|
return t || (t = {
|
|
1716
1719
|
timers: /* @__PURE__ */ new Map(),
|
|
1717
1720
|
onTransaction: () => {},
|
|
1718
1721
|
listening: !1
|
|
1719
|
-
},
|
|
1722
|
+
}, Xt.set(e, t)), t;
|
|
1720
1723
|
}
|
|
1721
|
-
function
|
|
1724
|
+
function $t(e, t) {
|
|
1722
1725
|
let n = [...new Set(t.filter(Boolean))];
|
|
1723
1726
|
if (n.length === 0) return;
|
|
1724
|
-
let r =
|
|
1727
|
+
let r = Qt(e);
|
|
1725
1728
|
r.listening ||= (r.onTransaction = () => {
|
|
1726
1729
|
if (r.timers.size === 0) return;
|
|
1727
|
-
let t =
|
|
1730
|
+
let t = Zt(e);
|
|
1728
1731
|
for (let [e, n] of r.timers) t.has(e) && (clearTimeout(n), r.timers.delete(e));
|
|
1729
1732
|
}, e.on("transaction", r.onTransaction), !0);
|
|
1730
1733
|
for (let t of n) {
|
|
1731
1734
|
if (r.timers.has(t)) continue;
|
|
1732
1735
|
let n = setTimeout(() => {
|
|
1733
|
-
|
|
1734
|
-
},
|
|
1736
|
+
Zt(e).has(t) || qt(t), r.timers.delete(t);
|
|
1737
|
+
}, Jt);
|
|
1735
1738
|
r.timers.set(t, n);
|
|
1736
1739
|
}
|
|
1737
1740
|
}
|
|
1738
|
-
function
|
|
1739
|
-
let t =
|
|
1741
|
+
function en(e) {
|
|
1742
|
+
let t = Xt.get(e);
|
|
1740
1743
|
if (t) {
|
|
1741
1744
|
if (t.listening &&= (e.off("transaction", t.onTransaction), !1), t.timers.size > 0) {
|
|
1742
|
-
let n =
|
|
1743
|
-
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) ||
|
|
1745
|
+
let n = Zt(e);
|
|
1746
|
+
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) || qt(e);
|
|
1744
1747
|
t.timers.clear();
|
|
1745
1748
|
}
|
|
1746
|
-
|
|
1749
|
+
Xt.delete(e);
|
|
1747
1750
|
}
|
|
1748
1751
|
}
|
|
1749
1752
|
//#endregion
|
|
1750
1753
|
//#region src/editor/ai/components/ai-selector.tsx
|
|
1751
|
-
var
|
|
1754
|
+
var tn = [
|
|
1752
1755
|
{
|
|
1753
1756
|
mode: "continue",
|
|
1754
1757
|
labelKey: "editor.ai.continue",
|
|
@@ -1791,24 +1794,24 @@ var en = [
|
|
|
1791
1794
|
descKey: "editor.ai.zapDesc",
|
|
1792
1795
|
icon: "⚡"
|
|
1793
1796
|
}
|
|
1794
|
-
],
|
|
1797
|
+
], nn = /* @__PURE__ */ new Set([
|
|
1795
1798
|
"image",
|
|
1796
1799
|
"attachmentEmbed",
|
|
1797
1800
|
"audioEmbed",
|
|
1798
1801
|
"videoEmbed"
|
|
1799
|
-
]),
|
|
1802
|
+
]), rn = {
|
|
1800
1803
|
image: "editor.ai.nodeImage",
|
|
1801
1804
|
attachmentEmbed: "editor.ai.nodeAttachment",
|
|
1802
1805
|
videoEmbed: "editor.ai.nodeVideo",
|
|
1803
1806
|
audioEmbed: "editor.ai.nodeAudio"
|
|
1804
1807
|
};
|
|
1805
|
-
function
|
|
1808
|
+
function an(e, t) {
|
|
1806
1809
|
return e.storage.qingwuUI?.parseMd?.(e.schema, t) || null;
|
|
1807
1810
|
}
|
|
1808
|
-
function
|
|
1811
|
+
function on(e, t, n) {
|
|
1809
1812
|
let r = [];
|
|
1810
1813
|
return e.state.doc.nodesBetween(t, n, (e) => {
|
|
1811
|
-
if (
|
|
1814
|
+
if (nn.has(e.type.name)) {
|
|
1812
1815
|
let t = e.attrs.src;
|
|
1813
1816
|
t && r.push({
|
|
1814
1817
|
type: e.type.name,
|
|
@@ -1818,27 +1821,27 @@ function an(e, t, n) {
|
|
|
1818
1821
|
return !0;
|
|
1819
1822
|
}), r;
|
|
1820
1823
|
}
|
|
1821
|
-
function
|
|
1824
|
+
function sn(e) {
|
|
1822
1825
|
let t = /* @__PURE__ */ new Set();
|
|
1823
1826
|
return e.state.doc.descendants((e) => {
|
|
1824
|
-
if (
|
|
1827
|
+
if (nn.has(e.type.name)) {
|
|
1825
1828
|
let n = e.attrs.src;
|
|
1826
1829
|
n && t.add(n);
|
|
1827
1830
|
}
|
|
1828
1831
|
return !0;
|
|
1829
1832
|
}), t;
|
|
1830
1833
|
}
|
|
1831
|
-
function
|
|
1832
|
-
let n =
|
|
1834
|
+
function cn(e, t) {
|
|
1835
|
+
let n = an(e, t);
|
|
1833
1836
|
if (n && n.size > 0) {
|
|
1834
1837
|
let t = e.state.tr;
|
|
1835
|
-
t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(
|
|
1838
|
+
t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(oe.create(t.doc, t.doc.content.size)), e.view.dispatch(t.scrollIntoView()), e.commands.focus();
|
|
1836
1839
|
return;
|
|
1837
1840
|
}
|
|
1838
1841
|
e.commands.setContent(t), e.commands.focus();
|
|
1839
1842
|
}
|
|
1840
|
-
function
|
|
1841
|
-
let i =
|
|
1843
|
+
function ln(e, t, n, r) {
|
|
1844
|
+
let i = an(e, t);
|
|
1842
1845
|
if (e.commands.focus(), !i) {
|
|
1843
1846
|
let i = e.chain().focus();
|
|
1844
1847
|
n === "replace" ? i.setTextSelection({
|
|
@@ -1850,7 +1853,7 @@ function cn(e, t, n, r) {
|
|
|
1850
1853
|
let a = e.state.tr;
|
|
1851
1854
|
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());
|
|
1852
1855
|
}
|
|
1853
|
-
function
|
|
1856
|
+
function un({ editor: e, onClose: t }) {
|
|
1854
1857
|
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({
|
|
1855
1858
|
from: 0,
|
|
1856
1859
|
to: 0,
|
|
@@ -1894,13 +1897,13 @@ function ln({ editor: e, onClose: t }) {
|
|
|
1894
1897
|
!e || !v.current || (e.scrollTop = e.scrollHeight);
|
|
1895
1898
|
}, [o]);
|
|
1896
1899
|
let k = b((t, n, r) => {
|
|
1897
|
-
let i = new Set(
|
|
1898
|
-
t === "replaceAll" ?
|
|
1899
|
-
let a =
|
|
1900
|
-
|
|
1900
|
+
let i = new Set(on(e, r.from, r.to).map((e) => e.src));
|
|
1901
|
+
t === "replaceAll" ? cn(e, n) : ln(e, n, "replace", h.current);
|
|
1902
|
+
let a = sn(e);
|
|
1903
|
+
$t(e, [...i].filter((e) => !a.has(e)));
|
|
1901
1904
|
}, [e]), A = b((n) => {
|
|
1902
1905
|
if (n === "below") {
|
|
1903
|
-
|
|
1906
|
+
ln(e, o, "below", h.current), t();
|
|
1904
1907
|
return;
|
|
1905
1908
|
}
|
|
1906
1909
|
let r = h.current, i = n === "replaceAll" ? {
|
|
@@ -1909,7 +1912,7 @@ function ln({ editor: e, onClose: t }) {
|
|
|
1909
1912
|
} : {
|
|
1910
1913
|
from: r.from,
|
|
1911
1914
|
to: r.to
|
|
1912
|
-
}, a =
|
|
1915
|
+
}, a = on(e, i.from, i.to);
|
|
1913
1916
|
if (a.length > 0) {
|
|
1914
1917
|
m({
|
|
1915
1918
|
position: n,
|
|
@@ -1957,12 +1960,12 @@ function ln({ editor: e, onClose: t }) {
|
|
|
1957
1960
|
"aria-label": f("editor.ai.close"),
|
|
1958
1961
|
title: f("editor.ai.close"),
|
|
1959
1962
|
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",
|
|
1960
|
-
children: /* @__PURE__ */ D(
|
|
1963
|
+
children: /* @__PURE__ */ D(Kt, {})
|
|
1961
1964
|
})]
|
|
1962
1965
|
}),
|
|
1963
1966
|
/* @__PURE__ */ D("div", {
|
|
1964
1967
|
className: "grid grid-cols-[repeat(auto-fit,minmax(64px,1fr))] gap-1.5 p-2 shrink-0",
|
|
1965
|
-
children:
|
|
1968
|
+
children: tn.map(({ mode: e, labelKey: t, descKey: r, icon: i }) => /* @__PURE__ */ O("button", {
|
|
1966
1969
|
type: "button",
|
|
1967
1970
|
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"}`,
|
|
1968
1971
|
onClick: () => y(e),
|
|
@@ -2105,7 +2108,7 @@ function ln({ editor: e, onClose: t }) {
|
|
|
2105
2108
|
children: Object.entries(N).map(([e, t]) => /* @__PURE__ */ O("li", {
|
|
2106
2109
|
className: "text-sm text-default-700",
|
|
2107
2110
|
children: [
|
|
2108
|
-
f(
|
|
2111
|
+
f(rn[e] ?? e),
|
|
2109
2112
|
" ×",
|
|
2110
2113
|
t
|
|
2111
2114
|
]
|
|
@@ -2137,19 +2140,19 @@ function ln({ editor: e, onClose: t }) {
|
|
|
2137
2140
|
}
|
|
2138
2141
|
//#endregion
|
|
2139
2142
|
//#region src/editor/attachment-limits.ts
|
|
2140
|
-
var
|
|
2143
|
+
var dn = /* @__PURE__ */ new Set([
|
|
2141
2144
|
"attachmentEmbed",
|
|
2142
2145
|
"videoEmbed",
|
|
2143
2146
|
"audioEmbed",
|
|
2144
2147
|
"image"
|
|
2145
2148
|
]);
|
|
2146
|
-
function
|
|
2149
|
+
function fn(e) {
|
|
2147
2150
|
let t = 0;
|
|
2148
2151
|
return e.descendants((e) => {
|
|
2149
|
-
|
|
2152
|
+
dn.has(e.type.name) && (t += Number(e.attrs?.size) || 0);
|
|
2150
2153
|
}), t;
|
|
2151
2154
|
}
|
|
2152
|
-
function
|
|
2155
|
+
function pn(e) {
|
|
2153
2156
|
if (!Number.isFinite(e) || e <= 0) return "0 B";
|
|
2154
2157
|
let t = [
|
|
2155
2158
|
"B",
|
|
@@ -2160,41 +2163,41 @@ function fn(e) {
|
|
|
2160
2163
|
], n = Math.min(t.length - 1, Math.floor(Math.log(e) / Math.log(1024))), r = e / 1024 ** n;
|
|
2161
2164
|
return `${n === 0 || r >= 100 ? `${Math.round(r)}` : `${Math.round(r * 10) / 10}`} ${t[n]}`;
|
|
2162
2165
|
}
|
|
2163
|
-
function
|
|
2166
|
+
function mn(e) {
|
|
2164
2167
|
return (e?.storage)?.qingwuUI?.limits;
|
|
2165
2168
|
}
|
|
2166
|
-
function
|
|
2169
|
+
function hn(e, t, n) {
|
|
2167
2170
|
let { maxAttachmentSize: r, maxTotalAttachmentSize: i } = n;
|
|
2168
|
-
if (r && t.size > r) return `单文件大小不能超过 ${
|
|
2171
|
+
if (r && t.size > r) return `单文件大小不能超过 ${pn(r)}(当前 ${pn(t.size)})`;
|
|
2169
2172
|
if (i) {
|
|
2170
|
-
let n =
|
|
2171
|
-
if (n > i) return `附件总大小不能超过 ${
|
|
2173
|
+
let n = fn(e) + t.size;
|
|
2174
|
+
if (n > i) return `附件总大小不能超过 ${pn(i)}(当前合计 ${pn(n)})`;
|
|
2172
2175
|
}
|
|
2173
2176
|
return null;
|
|
2174
2177
|
}
|
|
2175
2178
|
//#endregion
|
|
2176
2179
|
//#region src/editor/utils/delete-confirm.ts
|
|
2177
|
-
var
|
|
2178
|
-
function
|
|
2179
|
-
return
|
|
2180
|
+
var gn = !1, _n = null, vn = 5e3;
|
|
2181
|
+
function yn() {
|
|
2182
|
+
return gn;
|
|
2180
2183
|
}
|
|
2181
2184
|
function $(e) {
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
},
|
|
2185
|
+
gn = e, _n &&= (clearTimeout(_n), null), e && (_n = setTimeout(() => {
|
|
2186
|
+
gn = !1, _n = null;
|
|
2187
|
+
}, vn));
|
|
2185
2188
|
}
|
|
2186
|
-
var
|
|
2187
|
-
function
|
|
2188
|
-
|
|
2189
|
+
var bn = null;
|
|
2190
|
+
function xn(e) {
|
|
2191
|
+
bn = e;
|
|
2189
2192
|
}
|
|
2190
|
-
function
|
|
2191
|
-
return
|
|
2193
|
+
function Sn() {
|
|
2194
|
+
return bn;
|
|
2192
2195
|
}
|
|
2193
2196
|
//#endregion
|
|
2194
2197
|
//#region src/editor/utils/delete-confirm-dialog.tsx
|
|
2195
|
-
var
|
|
2196
|
-
function
|
|
2197
|
-
let [s, c] = T(!1), l = w(!1), u =
|
|
2198
|
+
var Cn = 300;
|
|
2199
|
+
function wn({ open: e, title: t, message: n, confirmText: r = "删除", cancelText: i = "取消", onConfirm: a, onCancel: o }) {
|
|
2200
|
+
let [s, c] = T(!1), l = w(!1), u = Sn();
|
|
2198
2201
|
return x(() => {
|
|
2199
2202
|
if (!e) {
|
|
2200
2203
|
l.current = !1;
|
|
@@ -2220,7 +2223,7 @@ function Cn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2220
2223
|
o
|
|
2221
2224
|
]), x(() => {
|
|
2222
2225
|
e || c(!1);
|
|
2223
|
-
}, [e]), u || !e ? null :
|
|
2226
|
+
}, [e]), u || !e ? null : re(/* @__PURE__ */ D("div", {
|
|
2224
2227
|
className: "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none",
|
|
2225
2228
|
onClick: () => {
|
|
2226
2229
|
s || o();
|
|
@@ -2264,7 +2267,7 @@ function Cn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2264
2267
|
await a();
|
|
2265
2268
|
} finally {
|
|
2266
2269
|
let t = Date.now() - e;
|
|
2267
|
-
t <
|
|
2270
|
+
t < Cn && await new Promise((e) => setTimeout(e, Cn - t)), c(!1), o();
|
|
2268
2271
|
}
|
|
2269
2272
|
},
|
|
2270
2273
|
disabled: s,
|
|
@@ -2277,10 +2280,10 @@ function Cn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2277
2280
|
}
|
|
2278
2281
|
//#endregion
|
|
2279
2282
|
//#region src/editor/extensions/image-view.tsx
|
|
2280
|
-
function
|
|
2283
|
+
function Tn(e) {
|
|
2281
2284
|
return /^(\.\.?\/|[a-zA-Z]:\\|file:\/\/)/.test(e) ? !0 : !(/^[a-z]+:\/\//i.test(e) || e.startsWith("/") || e.startsWith("data:") || e.startsWith("blob:"));
|
|
2282
2285
|
}
|
|
2283
|
-
function
|
|
2286
|
+
function En({ node: e, deleteNode: t, editor: r }) {
|
|
2284
2287
|
let [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(!1), u = w(!1), [d, f] = T(!1), p = e.attrs.src || "", m = e.attrs.alt || "", h = e.attrs.width || null, g = e.attrs.height || null, _ = w(null), v = w(null), y = w(null), S = w(null), C = w(null), E = w(!1), k = w(!1), A = w(0), [j, M] = T(p), N = r?.isEditable ?? !0, ee = b(() => {
|
|
2285
2288
|
o || (A.current = window.scrollY, a(!0));
|
|
2286
2289
|
}, [o]), F = b(() => {
|
|
@@ -2333,7 +2336,7 @@ function Tn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2333
2336
|
};
|
|
2334
2337
|
return document.addEventListener("fullscreenchange", e), () => document.removeEventListener("fullscreenchange", e);
|
|
2335
2338
|
}, []);
|
|
2336
|
-
let ne = o ||
|
|
2339
|
+
let ne = o || Tn(p);
|
|
2337
2340
|
return /* @__PURE__ */ O(P, {
|
|
2338
2341
|
as: "div",
|
|
2339
2342
|
className: "image-node-view group/img",
|
|
@@ -2346,7 +2349,7 @@ function Tn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2346
2349
|
type: "button",
|
|
2347
2350
|
className: "img-ctrl-btn img-ctrl-btn--del image-placeholder-del",
|
|
2348
2351
|
onClick: () => {
|
|
2349
|
-
|
|
2352
|
+
yn() || ($(!0), f(!0));
|
|
2350
2353
|
},
|
|
2351
2354
|
title: "删除",
|
|
2352
2355
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2378,7 +2381,7 @@ function Tn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2378
2381
|
}),
|
|
2379
2382
|
/* @__PURE__ */ D("span", {
|
|
2380
2383
|
className: "image-placeholder-text",
|
|
2381
|
-
children:
|
|
2384
|
+
children: Tn(p) ? "本地图片无法加载" : "图片加载失败"
|
|
2382
2385
|
}),
|
|
2383
2386
|
/* @__PURE__ */ D("span", {
|
|
2384
2387
|
className: "image-placeholder-path",
|
|
@@ -2459,7 +2462,7 @@ function Tn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2459
2462
|
type: "button",
|
|
2460
2463
|
className: "img-ctrl-btn img-ctrl-btn--del",
|
|
2461
2464
|
onClick: () => {
|
|
2462
|
-
|
|
2465
|
+
yn() || ($(!0), f(!0));
|
|
2463
2466
|
},
|
|
2464
2467
|
title: "删除",
|
|
2465
2468
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2546,7 +2549,7 @@ function Tn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2546
2549
|
}
|
|
2547
2550
|
})]
|
|
2548
2551
|
}),
|
|
2549
|
-
/* @__PURE__ */ D(
|
|
2552
|
+
/* @__PURE__ */ D(wn, {
|
|
2550
2553
|
open: d,
|
|
2551
2554
|
title: "确认删除图片",
|
|
2552
2555
|
message: ne ? "该图片无法在当前环境加载,仅从编辑器中移除该图片节点,不影响存储文件。" : "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
@@ -2555,7 +2558,7 @@ function Tn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2555
2558
|
},
|
|
2556
2559
|
onConfirm: async () => {
|
|
2557
2560
|
if (!ne) try {
|
|
2558
|
-
await
|
|
2561
|
+
await qt(p);
|
|
2559
2562
|
} catch {}
|
|
2560
2563
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
2561
2564
|
}
|
|
@@ -2565,7 +2568,7 @@ function Tn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2565
2568
|
}
|
|
2566
2569
|
//#endregion
|
|
2567
2570
|
//#region src/editor/embeds/attachment-view.tsx
|
|
2568
|
-
var
|
|
2571
|
+
var Dn = y(() => import("@file-viewer/react")), On = /* @__PURE__ */ new Set(), kn = {
|
|
2569
2572
|
rendererMode: "replace",
|
|
2570
2573
|
autoRenderers: !0,
|
|
2571
2574
|
theme: "light",
|
|
@@ -2594,7 +2597,7 @@ var En = y(() => import("@file-viewer/react")), Dn = /* @__PURE__ */ new Set(),
|
|
|
2594
2597
|
cache: !0,
|
|
2595
2598
|
workerTimeoutMs: 3e4
|
|
2596
2599
|
}
|
|
2597
|
-
},
|
|
2600
|
+
}, An = {
|
|
2598
2601
|
pdf: "pdf",
|
|
2599
2602
|
docx: "word",
|
|
2600
2603
|
docm: "word",
|
|
@@ -2649,7 +2652,7 @@ var En = y(() => import("@file-viewer/react")), Dn = /* @__PURE__ */ new Set(),
|
|
|
2649
2652
|
xml: "text",
|
|
2650
2653
|
yml: "text",
|
|
2651
2654
|
yaml: "text"
|
|
2652
|
-
},
|
|
2655
|
+
}, jn = {
|
|
2653
2656
|
pdf: () => import("@file-viewer/renderer-pdf").then((e) => e.pdfRenderer),
|
|
2654
2657
|
word: () => import("@file-viewer/renderer-word").then((e) => e.wordRenderer),
|
|
2655
2658
|
spreadsheet: () => import("@file-viewer/renderer-spreadsheet").then((e) => e.spreadsheetRenderer),
|
|
@@ -2657,10 +2660,10 @@ var En = y(() => import("@file-viewer/react")), Dn = /* @__PURE__ */ new Set(),
|
|
|
2657
2660
|
archive: () => import("@file-viewer/renderer-archive").then((e) => e.archiveRenderer),
|
|
2658
2661
|
text: () => import("@file-viewer/renderer-text").then((e) => e.textRenderer)
|
|
2659
2662
|
};
|
|
2660
|
-
function
|
|
2663
|
+
function Mn(e) {
|
|
2661
2664
|
return e ? e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1048576).toFixed(1)} MB` : "";
|
|
2662
2665
|
}
|
|
2663
|
-
function
|
|
2666
|
+
function Nn(e) {
|
|
2664
2667
|
let t = e.split(".").pop()?.toLowerCase() || "", n = {
|
|
2665
2668
|
pdf: {
|
|
2666
2669
|
label: "PDF",
|
|
@@ -2833,22 +2836,22 @@ function Mn(e) {
|
|
|
2833
2836
|
]
|
|
2834
2837
|
});
|
|
2835
2838
|
}
|
|
2836
|
-
function
|
|
2839
|
+
function Pn(e) {
|
|
2837
2840
|
return e.split(".").pop()?.toLowerCase() || "";
|
|
2838
2841
|
}
|
|
2839
|
-
function
|
|
2842
|
+
function Fn(e) {
|
|
2840
2843
|
let t = e.split(".").pop()?.toLowerCase() || "";
|
|
2841
2844
|
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);
|
|
2842
2845
|
}
|
|
2843
|
-
function
|
|
2846
|
+
function In(e) {
|
|
2844
2847
|
return !!e && !e.startsWith("file:");
|
|
2845
2848
|
}
|
|
2846
|
-
function
|
|
2849
|
+
function Ln(e) {
|
|
2847
2850
|
return btoa(encodeURIComponent(e)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
2848
2851
|
}
|
|
2849
|
-
async function
|
|
2852
|
+
async function Rn(e, t) {
|
|
2850
2853
|
try {
|
|
2851
|
-
let n =
|
|
2854
|
+
let n = Ln(e), r = await fetch(`/api/preview/${n}`, {
|
|
2852
2855
|
signal: t,
|
|
2853
2856
|
cache: "no-store"
|
|
2854
2857
|
});
|
|
@@ -2860,7 +2863,7 @@ async function Ln(e, t) {
|
|
|
2860
2863
|
return null;
|
|
2861
2864
|
}
|
|
2862
2865
|
}
|
|
2863
|
-
function
|
|
2866
|
+
function zn(e, t, n) {
|
|
2864
2867
|
return new Promise((r, i) => {
|
|
2865
2868
|
let a = new XMLHttpRequest();
|
|
2866
2869
|
if (a.open("GET", e, !0), a.responseType = "arraybuffer", t) {
|
|
@@ -2898,74 +2901,74 @@ function Rn(e, t, n) {
|
|
|
2898
2901
|
a.send();
|
|
2899
2902
|
});
|
|
2900
2903
|
}
|
|
2901
|
-
function
|
|
2902
|
-
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() =>
|
|
2904
|
+
function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
2905
|
+
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() => On.has(s)), [u, d] = T(null), [p, m] = T(null), [h, g] = T(!1), [_, y] = T(null), [S, E] = T(!1), [k, A] = T(null), j = w(null), M = w(null), N = w(null), ee = w(0), F = w(!1), I = w(null), te = w(0), [ne, re] = T(!1), L = w(null), [ie, ae] = T(0), [R, z] = T("none"), [B, V] = T(void 0), [oe, se] = T(!1), H = e.attrs.src || "", U = e.attrs.name || H && H.split("/").pop()?.split("?")[0] || (H ? "attachment" : f("editor.attachment.lost")), ce = e.attrs.size || 0, W = Pn(U), G = !H;
|
|
2903
2906
|
x(() => {
|
|
2904
2907
|
if (!c) {
|
|
2905
|
-
|
|
2908
|
+
V(void 0), se(!1);
|
|
2906
2909
|
return;
|
|
2907
2910
|
}
|
|
2908
|
-
let e =
|
|
2911
|
+
let e = An[W];
|
|
2909
2912
|
if (!e) {
|
|
2910
|
-
|
|
2913
|
+
V(void 0), se(!1);
|
|
2911
2914
|
return;
|
|
2912
2915
|
}
|
|
2913
2916
|
let t = !0;
|
|
2914
|
-
return
|
|
2915
|
-
t &&
|
|
2917
|
+
return V(void 0), se(!1), jn[e]().then((e) => {
|
|
2918
|
+
t && V(e);
|
|
2916
2919
|
}).catch((n) => {
|
|
2917
|
-
console.error(`[attachment] renderer "${e}" load failed:`, n), t &&
|
|
2920
|
+
console.error(`[attachment] renderer "${e}" load failed:`, n), t && se(!0);
|
|
2918
2921
|
}), () => {
|
|
2919
2922
|
t = !1;
|
|
2920
2923
|
};
|
|
2921
|
-
}, [c,
|
|
2922
|
-
let
|
|
2923
|
-
...
|
|
2924
|
-
renderers:
|
|
2924
|
+
}, [c, W]);
|
|
2925
|
+
let le = C(() => ({
|
|
2926
|
+
...kn,
|
|
2927
|
+
renderers: B ? [B] : [],
|
|
2925
2928
|
rendererMode: "replace"
|
|
2926
|
-
}), [
|
|
2929
|
+
}), [B]), K = b((e) => {
|
|
2927
2930
|
l((t) => {
|
|
2928
2931
|
let n = typeof e == "function" ? e(t) : e;
|
|
2929
|
-
return
|
|
2932
|
+
return H && (n ? On.add(H) : On.delete(H)), n;
|
|
2930
2933
|
});
|
|
2931
|
-
}, [
|
|
2934
|
+
}, [H]);
|
|
2932
2935
|
x(() => {
|
|
2933
|
-
l(
|
|
2934
|
-
}, [
|
|
2935
|
-
let
|
|
2936
|
-
F.current = !0,
|
|
2937
|
-
window.scrollTo(0, ee.current), I.current && (I.current.scrollTop = te.current), F.current &&
|
|
2936
|
+
l(H ? On.has(H) : !1);
|
|
2937
|
+
}, [H]);
|
|
2938
|
+
let ue = b(() => {
|
|
2939
|
+
F.current = !0, K(!0), window.setTimeout(() => {
|
|
2940
|
+
window.scrollTo(0, ee.current), I.current && (I.current.scrollTop = te.current), F.current && K(!0), F.current = !1;
|
|
2938
2941
|
}, 0);
|
|
2939
|
-
}, [
|
|
2940
|
-
|
|
2941
|
-
}, [
|
|
2942
|
+
}, [K]), de = b(async () => {
|
|
2943
|
+
R === "web" ? (z("none"), document.body.style.overflow = "", ue()) : (R === "native" && document.fullscreenElement && await document.exitFullscreen(), ee.current = window.scrollY, te.current = I.current?.scrollTop ?? 0, document.body.style.overflow = "hidden", z("web"));
|
|
2944
|
+
}, [R]), fe = b(async () => {
|
|
2942
2945
|
let e = M.current;
|
|
2943
|
-
e && (
|
|
2944
|
-
}, [
|
|
2945
|
-
|
|
2946
|
-
}, [
|
|
2946
|
+
e && (R === "native" ? await document.exitFullscreen() : (R === "web" && (z("none"), document.body.style.overflow = ""), ee.current = window.scrollY, te.current = I.current?.scrollTop ?? 0, await e.requestFullscreen(), z("native")));
|
|
2947
|
+
}, [R, ue]), pe = b(() => {
|
|
2948
|
+
R === "none" && (F.current || K((e) => !e));
|
|
2949
|
+
}, [R]);
|
|
2947
2950
|
x(() => {
|
|
2948
2951
|
let e = () => {
|
|
2949
|
-
document.fullscreenElement || (
|
|
2952
|
+
document.fullscreenElement || (R === "native" && z("none"), ue());
|
|
2950
2953
|
}, t = (e) => {
|
|
2951
|
-
e.key === "Escape" &&
|
|
2954
|
+
e.key === "Escape" && R === "web" && (z("none"), document.body.style.overflow = "", ue());
|
|
2952
2955
|
};
|
|
2953
2956
|
return document.addEventListener("fullscreenchange", e), window.addEventListener("keydown", t), () => {
|
|
2954
2957
|
document.removeEventListener("fullscreenchange", e), window.removeEventListener("keydown", t);
|
|
2955
2958
|
};
|
|
2956
|
-
}, [
|
|
2959
|
+
}, [R, ue]), x(() => {
|
|
2957
2960
|
let e = (e) => {
|
|
2958
|
-
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !i ||
|
|
2961
|
+
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !i || yn()) return;
|
|
2959
2962
|
let t = a?.view?.dom, n = e.target;
|
|
2960
2963
|
if (a?.isFocused && n instanceof Node && t?.contains(n)) {
|
|
2961
2964
|
if (e.preventDefault(), e.stopPropagation(), a) {
|
|
2962
2965
|
let { from: e, to: t } = a.state.selection;
|
|
2963
|
-
|
|
2966
|
+
L.current = {
|
|
2964
2967
|
from: e,
|
|
2965
2968
|
to: t
|
|
2966
2969
|
};
|
|
2967
2970
|
}
|
|
2968
|
-
window.getSelection()?.removeAllRanges(), $(!0),
|
|
2971
|
+
window.getSelection()?.removeAllRanges(), $(!0), re(!0);
|
|
2969
2972
|
}
|
|
2970
2973
|
};
|
|
2971
2974
|
return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
|
|
@@ -2974,29 +2977,29 @@ function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2974
2977
|
a,
|
|
2975
2978
|
o
|
|
2976
2979
|
]), x(() => {
|
|
2977
|
-
if (!c || !
|
|
2980
|
+
if (!c || !In(H)) {
|
|
2978
2981
|
d(null), y(null), N.current = null;
|
|
2979
2982
|
return;
|
|
2980
2983
|
}
|
|
2981
|
-
if (N.current ===
|
|
2984
|
+
if (N.current === H) return;
|
|
2982
2985
|
let e = new AbortController(), r = !0;
|
|
2983
2986
|
return g(!0), y(null), (async () => {
|
|
2984
|
-
let i =
|
|
2985
|
-
if (!a && !i && (a = await
|
|
2986
|
-
let n = await t(
|
|
2987
|
-
n && (a = await
|
|
2987
|
+
let i = H.includes("?X-Amz-"), a = null, o = null;
|
|
2988
|
+
if (!a && !i && (a = await Rn(H, e.signal)), !a && !i) try {
|
|
2989
|
+
let n = await t(H);
|
|
2990
|
+
n && (a = await Rn(n, e.signal) || await zn(n, void 0, e.signal));
|
|
2988
2991
|
} catch (e) {
|
|
2989
2992
|
console.warn("[attachment] signPreviewUrl failed:", e);
|
|
2990
2993
|
}
|
|
2991
2994
|
if (!a && !i) try {
|
|
2992
|
-
let t = await n(
|
|
2995
|
+
let t = await n(H);
|
|
2993
2996
|
if (t) {
|
|
2994
2997
|
let n = { "X-Requested-With": "XMLHttpRequest" };
|
|
2995
2998
|
t.forEach((e, t) => {
|
|
2996
2999
|
n[t] = e;
|
|
2997
3000
|
});
|
|
2998
3001
|
try {
|
|
2999
|
-
a = await
|
|
3002
|
+
a = await zn(H, n, e.signal);
|
|
3000
3003
|
} catch (e) {
|
|
3001
3004
|
console.warn("[attachment] signed headers XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
3002
3005
|
}
|
|
@@ -3005,18 +3008,18 @@ function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3005
3008
|
console.warn("[attachment] signPreviewUrlHeaders failed:", e);
|
|
3006
3009
|
}
|
|
3007
3010
|
if (!a) try {
|
|
3008
|
-
a = await
|
|
3011
|
+
a = await zn(H, i ? void 0 : { "X-Requested-With": "XMLHttpRequest" }, e.signal);
|
|
3009
3012
|
} catch (e) {
|
|
3010
3013
|
console.warn("[attachment] plain XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
3011
3014
|
}
|
|
3012
3015
|
if (!a) throw o || /* @__PURE__ */ Error("所有 fetch 方法均失败");
|
|
3013
3016
|
if (!r) return;
|
|
3014
|
-
d(a), N.current =
|
|
3017
|
+
d(a), N.current = H;
|
|
3015
3018
|
let s = URL.createObjectURL(new Blob([a], { type: "application/octet-stream" }));
|
|
3016
3019
|
m(s), g(!1);
|
|
3017
3020
|
})().catch((e) => {
|
|
3018
3021
|
if (r && !(e instanceof DOMException && e.name === "AbortError")) {
|
|
3019
|
-
if (N.current ===
|
|
3022
|
+
if (N.current === H) {
|
|
3020
3023
|
g(!1);
|
|
3021
3024
|
return;
|
|
3022
3025
|
}
|
|
@@ -3025,46 +3028,46 @@ function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3025
3028
|
}), () => {
|
|
3026
3029
|
r = !1, e.abort();
|
|
3027
3030
|
};
|
|
3028
|
-
}, [c,
|
|
3031
|
+
}, [c, H]), x(() => () => {
|
|
3029
3032
|
p && URL.revokeObjectURL(p), d(null);
|
|
3030
3033
|
}, []), x(() => () => {
|
|
3031
3034
|
p && URL.revokeObjectURL(p), m(null), d(null), N.current = null;
|
|
3032
|
-
}, [
|
|
3035
|
+
}, [H]), x(() => {
|
|
3033
3036
|
if (k !== "success" && k !== "error") return;
|
|
3034
3037
|
let e = window.setTimeout(() => A(null), 2400);
|
|
3035
3038
|
return () => window.clearTimeout(e);
|
|
3036
3039
|
}, [k]);
|
|
3037
|
-
let
|
|
3040
|
+
let q = b(async () => {
|
|
3038
3041
|
E(!0), A("loading");
|
|
3039
3042
|
try {
|
|
3040
3043
|
if (p) {
|
|
3041
3044
|
let e = document.createElement("a");
|
|
3042
|
-
e.href = p, e.download =
|
|
3045
|
+
e.href = p, e.download = U, document.body.appendChild(e), e.click(), document.body.removeChild(e), A("success");
|
|
3043
3046
|
return;
|
|
3044
3047
|
}
|
|
3045
|
-
let e =
|
|
3048
|
+
let e = H.includes("?X-Amz-"), r = null;
|
|
3046
3049
|
if (!e) try {
|
|
3047
|
-
let e = await t(
|
|
3050
|
+
let e = await t(H);
|
|
3048
3051
|
e && (r = await fetch(e, { headers: { "X-Requested-With": "XMLHttpRequest" } }), r.ok || (r = null));
|
|
3049
3052
|
} catch {}
|
|
3050
3053
|
if (!r && !e) try {
|
|
3051
|
-
let e = await n(
|
|
3052
|
-
e && (r = await fetch(
|
|
3054
|
+
let e = await n(H);
|
|
3055
|
+
e && (r = await fetch(H, { headers: (() => {
|
|
3053
3056
|
let t = new Headers(e);
|
|
3054
3057
|
return t.set("X-Requested-With", "XMLHttpRequest"), t;
|
|
3055
3058
|
})() }), r.ok || (r = null));
|
|
3056
3059
|
} catch {}
|
|
3057
|
-
if (r ||= await fetch(
|
|
3060
|
+
if (r ||= await fetch(H, { headers: { "X-Requested-With": "XMLHttpRequest" } }), !r || !r.ok) throw Error("下载失败");
|
|
3058
3061
|
let i = await r.blob(), a = URL.createObjectURL(i), o = document.createElement("a");
|
|
3059
|
-
o.href = a, o.download =
|
|
3062
|
+
o.href = a, o.download = U, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(a), A("success");
|
|
3060
3063
|
} catch (e) {
|
|
3061
3064
|
console.error("[attachment] download failed:", e), A("error");
|
|
3062
3065
|
} finally {
|
|
3063
3066
|
E(!1);
|
|
3064
3067
|
}
|
|
3065
3068
|
}, [
|
|
3069
|
+
H,
|
|
3066
3070
|
U,
|
|
3067
|
-
W,
|
|
3068
3071
|
p
|
|
3069
3072
|
]);
|
|
3070
3073
|
return /* @__PURE__ */ O(P, {
|
|
@@ -3084,7 +3087,7 @@ function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3084
3087
|
className: "att-info",
|
|
3085
3088
|
children: [/* @__PURE__ */ D("span", {
|
|
3086
3089
|
className: "att-icon",
|
|
3087
|
-
children:
|
|
3090
|
+
children: G ? /* @__PURE__ */ O("svg", {
|
|
3088
3091
|
width: "22",
|
|
3089
3092
|
height: "22",
|
|
3090
3093
|
viewBox: "0 0 24 24",
|
|
@@ -3100,15 +3103,15 @@ function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3100
3103
|
/* @__PURE__ */ D("path", { d: "M12 9v4" }),
|
|
3101
3104
|
/* @__PURE__ */ D("path", { d: "M12 17h.01" })
|
|
3102
3105
|
]
|
|
3103
|
-
}) :
|
|
3106
|
+
}) : Nn(U)
|
|
3104
3107
|
}), /* @__PURE__ */ O("div", {
|
|
3105
3108
|
className: "att-meta",
|
|
3106
3109
|
children: [/* @__PURE__ */ D("span", {
|
|
3107
3110
|
className: "att-name",
|
|
3108
|
-
children:
|
|
3109
|
-
}),
|
|
3111
|
+
children: U
|
|
3112
|
+
}), ce > 0 && /* @__PURE__ */ D("span", {
|
|
3110
3113
|
className: "att-size",
|
|
3111
|
-
children:
|
|
3114
|
+
children: Mn(ce)
|
|
3112
3115
|
})]
|
|
3113
3116
|
})]
|
|
3114
3117
|
}), /* @__PURE__ */ O("div", {
|
|
@@ -3161,11 +3164,11 @@ function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3161
3164
|
}), /* @__PURE__ */ O("div", {
|
|
3162
3165
|
className: "att-actions",
|
|
3163
3166
|
children: [
|
|
3164
|
-
|
|
3167
|
+
H && Fn(U) && /* @__PURE__ */ D("button", {
|
|
3165
3168
|
type: "button",
|
|
3166
3169
|
className: "att-btn",
|
|
3167
3170
|
onMouseDown: (e) => {
|
|
3168
|
-
e.preventDefault(), e.stopPropagation(),
|
|
3171
|
+
e.preventDefault(), e.stopPropagation(), pe();
|
|
3169
3172
|
},
|
|
3170
3173
|
title: f("editor.attachment.preview"),
|
|
3171
3174
|
"aria-label": f("editor.attachment.preview"),
|
|
@@ -3191,8 +3194,8 @@ function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3191
3194
|
/* @__PURE__ */ D("button", {
|
|
3192
3195
|
type: "button",
|
|
3193
3196
|
className: "att-btn",
|
|
3194
|
-
onClick:
|
|
3195
|
-
disabled: S ||
|
|
3197
|
+
onClick: q,
|
|
3198
|
+
disabled: S || G,
|
|
3196
3199
|
title: S ? "正在准备下载" : f("editor.attachment.download"),
|
|
3197
3200
|
"aria-label": S ? "正在准备下载" : f("editor.attachment.download"),
|
|
3198
3201
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -3214,7 +3217,7 @@ function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3214
3217
|
type: "button",
|
|
3215
3218
|
className: "att-btn att-btn--del",
|
|
3216
3219
|
onClick: () => {
|
|
3217
|
-
!o ||
|
|
3220
|
+
!o || yn() || ($(!0), re(!0));
|
|
3218
3221
|
},
|
|
3219
3222
|
title: f("editor.attachment.delete"),
|
|
3220
3223
|
"aria-label": f("editor.attachment.delete"),
|
|
@@ -3238,7 +3241,7 @@ function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3238
3241
|
})]
|
|
3239
3242
|
}), c && /* @__PURE__ */ O("div", {
|
|
3240
3243
|
ref: M,
|
|
3241
|
-
className: `att-preview-wrap ${
|
|
3244
|
+
className: `att-preview-wrap ${R === "web" ? "is-web-fs" : ""}`,
|
|
3242
3245
|
style: {
|
|
3243
3246
|
position: "relative",
|
|
3244
3247
|
height: 500,
|
|
@@ -3255,7 +3258,7 @@ function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3255
3258
|
children: h && !u && !p ? /* @__PURE__ */ D("div", {
|
|
3256
3259
|
className: "flex items-center justify-center h-full text-default-400 text-sm",
|
|
3257
3260
|
children: f("editor.attachment.loadingPreview")
|
|
3258
|
-
}) : (_ ||
|
|
3261
|
+
}) : (_ || oe) && !u && !p ? /* @__PURE__ */ O("div", {
|
|
3259
3262
|
className: "flex h-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-default-500",
|
|
3260
3263
|
children: [/* @__PURE__ */ D("div", {
|
|
3261
3264
|
className: "font-medium text-default-700",
|
|
@@ -3270,15 +3273,15 @@ function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3270
3273
|
style: { background: "#fff" },
|
|
3271
3274
|
children: f("editor.attachment.loadingPreview")
|
|
3272
3275
|
}),
|
|
3273
|
-
children: u || p ||
|
|
3276
|
+
children: u || p || H ? B ? /* @__PURE__ */ D(Dn, {
|
|
3274
3277
|
buffer: u || void 0,
|
|
3275
|
-
url: p ||
|
|
3276
|
-
name:
|
|
3277
|
-
filename:
|
|
3278
|
-
type:
|
|
3279
|
-
size:
|
|
3280
|
-
options:
|
|
3281
|
-
}, `${
|
|
3278
|
+
url: p || H,
|
|
3279
|
+
name: U,
|
|
3280
|
+
filename: U,
|
|
3281
|
+
type: W,
|
|
3282
|
+
size: ce || u?.byteLength || 0,
|
|
3283
|
+
options: le
|
|
3284
|
+
}, `${H}-${ie}`) : /* @__PURE__ */ D("div", {
|
|
3282
3285
|
className: "flex h-full items-center justify-center text-sm text-default-400",
|
|
3283
3286
|
children: "正在加载预览引擎..."
|
|
3284
3287
|
}) : /* @__PURE__ */ D("div", {
|
|
@@ -3305,15 +3308,15 @@ function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3305
3308
|
},
|
|
3306
3309
|
children: [/* @__PURE__ */ D("button", {
|
|
3307
3310
|
type: "button",
|
|
3308
|
-
onClick:
|
|
3309
|
-
title:
|
|
3310
|
-
"aria-label":
|
|
3311
|
+
onClick: de,
|
|
3312
|
+
title: R === "web" ? "退出网页全屏" : "网页全屏",
|
|
3313
|
+
"aria-label": R === "web" ? "退出网页全屏" : "网页全屏",
|
|
3311
3314
|
style: {
|
|
3312
3315
|
width: 28,
|
|
3313
3316
|
height: 28,
|
|
3314
3317
|
borderRadius: 6,
|
|
3315
3318
|
border: "none",
|
|
3316
|
-
background:
|
|
3319
|
+
background: R === "web" ? "#e4e4e7" : "transparent",
|
|
3317
3320
|
cursor: "pointer",
|
|
3318
3321
|
display: "flex",
|
|
3319
3322
|
alignItems: "center",
|
|
@@ -3322,10 +3325,10 @@ function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3322
3325
|
transition: "background 0.12s"
|
|
3323
3326
|
},
|
|
3324
3327
|
onMouseEnter: (e) => {
|
|
3325
|
-
|
|
3328
|
+
R !== "web" && (e.currentTarget.style.background = "#f4f4f5");
|
|
3326
3329
|
},
|
|
3327
3330
|
onMouseLeave: (e) => {
|
|
3328
|
-
|
|
3331
|
+
R !== "web" && (e.currentTarget.style.background = "transparent");
|
|
3329
3332
|
},
|
|
3330
3333
|
children: /* @__PURE__ */ D("svg", {
|
|
3331
3334
|
width: "14",
|
|
@@ -3343,15 +3346,15 @@ function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3343
3346
|
})
|
|
3344
3347
|
}), /* @__PURE__ */ D("button", {
|
|
3345
3348
|
type: "button",
|
|
3346
|
-
onClick:
|
|
3347
|
-
title:
|
|
3348
|
-
"aria-label":
|
|
3349
|
+
onClick: fe,
|
|
3350
|
+
title: R === "native" ? "退出全屏" : "全屏",
|
|
3351
|
+
"aria-label": R === "native" ? "退出全屏" : "全屏",
|
|
3349
3352
|
style: {
|
|
3350
3353
|
width: 28,
|
|
3351
3354
|
height: 28,
|
|
3352
3355
|
borderRadius: 6,
|
|
3353
3356
|
border: "none",
|
|
3354
|
-
background:
|
|
3357
|
+
background: R === "native" ? "#e4e4e7" : "transparent",
|
|
3355
3358
|
cursor: "pointer",
|
|
3356
3359
|
display: "flex",
|
|
3357
3360
|
alignItems: "center",
|
|
@@ -3360,10 +3363,10 @@ function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3360
3363
|
transition: "background 0.12s"
|
|
3361
3364
|
},
|
|
3362
3365
|
onMouseEnter: (e) => {
|
|
3363
|
-
|
|
3366
|
+
R !== "native" && (e.currentTarget.style.background = "#f4f4f5");
|
|
3364
3367
|
},
|
|
3365
3368
|
onMouseLeave: (e) => {
|
|
3366
|
-
|
|
3369
|
+
R !== "native" && (e.currentTarget.style.background = "transparent");
|
|
3367
3370
|
},
|
|
3368
3371
|
children: /* @__PURE__ */ D("svg", {
|
|
3369
3372
|
width: "14",
|
|
@@ -3382,24 +3385,24 @@ function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3382
3385
|
})]
|
|
3383
3386
|
})]
|
|
3384
3387
|
})]
|
|
3385
|
-
}), /* @__PURE__ */ D(
|
|
3388
|
+
}), /* @__PURE__ */ D(wn, {
|
|
3386
3389
|
open: ne,
|
|
3387
3390
|
title: "确认删除附件",
|
|
3388
|
-
message:
|
|
3391
|
+
message: G ? "此操作将删除该附件节点,不可撤销。" : `此操作将同时删除对象存储中的文件(${U}),不可撤销。`,
|
|
3389
3392
|
onCancel: () => {
|
|
3390
|
-
$(!1),
|
|
3393
|
+
$(!1), re(!1);
|
|
3391
3394
|
},
|
|
3392
3395
|
onConfirm: async () => {
|
|
3393
3396
|
try {
|
|
3394
3397
|
if (a) {
|
|
3395
|
-
let e =
|
|
3398
|
+
let e = L.current, t = e?.from ?? a.state.selection.from, n = e?.to ?? a.state.selection.to, r = [];
|
|
3396
3399
|
a.state.doc.nodesBetween(t, n, (e) => {
|
|
3397
|
-
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(
|
|
3400
|
+
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(qt(e.attrs.src));
|
|
3398
3401
|
}), await Promise.all(r), $(!1), await new Promise((e) => setTimeout(e, 300)), a.chain().focus().setTextSelection({
|
|
3399
3402
|
from: t,
|
|
3400
3403
|
to: n
|
|
3401
3404
|
}).deleteSelection().run();
|
|
3402
|
-
} else await
|
|
3405
|
+
} else await qt(H), $(!1), await new Promise((e) => setTimeout(e, 300)), r();
|
|
3403
3406
|
} catch {
|
|
3404
3407
|
$(!1);
|
|
3405
3408
|
}
|
|
@@ -3409,13 +3412,13 @@ function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3409
3412
|
}
|
|
3410
3413
|
//#endregion
|
|
3411
3414
|
//#region src/editor/embeds/attachment.ts
|
|
3412
|
-
var
|
|
3415
|
+
var Vn = ae.create({
|
|
3413
3416
|
name: "attachmentEmbed",
|
|
3414
3417
|
group: "block",
|
|
3415
3418
|
atom: !0,
|
|
3416
3419
|
inline: !1,
|
|
3417
3420
|
addNodeView() {
|
|
3418
|
-
return F(
|
|
3421
|
+
return F(Bn);
|
|
3419
3422
|
},
|
|
3420
3423
|
addAttributes() {
|
|
3421
3424
|
return {
|
|
@@ -3464,7 +3467,7 @@ var Bn = ie.create({
|
|
|
3464
3467
|
});
|
|
3465
3468
|
//#endregion
|
|
3466
3469
|
//#region src/editor/embeds/audio-view.tsx
|
|
3467
|
-
function
|
|
3470
|
+
function Hn({ node: e, deleteNode: t, editor: r }) {
|
|
3468
3471
|
let i = e.attrs.src || "", a = e.attrs.name || i.split("/").pop()?.split("?")[0] || "audio", [o, s] = T(!1), c = r?.isEditable ?? !0;
|
|
3469
3472
|
x(() => () => {
|
|
3470
3473
|
i.startsWith("blob:") && URL.revokeObjectURL(i);
|
|
@@ -3530,7 +3533,7 @@ function Vn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3530
3533
|
type: "button",
|
|
3531
3534
|
className: "audio-embed-btn audio-embed-btn--del",
|
|
3532
3535
|
onClick: () => {
|
|
3533
|
-
|
|
3536
|
+
yn() || ($(!0), s(!0));
|
|
3534
3537
|
},
|
|
3535
3538
|
title: "删除",
|
|
3536
3539
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -3576,7 +3579,7 @@ function Vn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3576
3579
|
}), "音频文件缺失"]
|
|
3577
3580
|
})
|
|
3578
3581
|
})]
|
|
3579
|
-
}), /* @__PURE__ */ D(
|
|
3582
|
+
}), /* @__PURE__ */ D(wn, {
|
|
3580
3583
|
open: o,
|
|
3581
3584
|
title: "确认删除音频",
|
|
3582
3585
|
message: `此操作将同时删除对象存储中的文件(${a}),不可撤销。`,
|
|
@@ -3585,7 +3588,7 @@ function Vn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3585
3588
|
},
|
|
3586
3589
|
onConfirm: async () => {
|
|
3587
3590
|
try {
|
|
3588
|
-
await
|
|
3591
|
+
await qt(i);
|
|
3589
3592
|
} catch {}
|
|
3590
3593
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3591
3594
|
}
|
|
@@ -3594,25 +3597,25 @@ function Vn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3594
3597
|
}
|
|
3595
3598
|
//#endregion
|
|
3596
3599
|
//#region src/editor/embeds/audio.ts
|
|
3597
|
-
function
|
|
3600
|
+
function Un(e) {
|
|
3598
3601
|
return /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|$)/i.test(e) || /\/.*\.(mp3|wav|ogg|flac)/i.test(e);
|
|
3599
3602
|
}
|
|
3600
|
-
var
|
|
3603
|
+
var Wn = ae.create({
|
|
3601
3604
|
name: "audioEmbed",
|
|
3602
3605
|
group: "block",
|
|
3603
3606
|
atom: !0,
|
|
3604
3607
|
inline: !1,
|
|
3605
3608
|
addNodeView() {
|
|
3606
|
-
return F(
|
|
3609
|
+
return F(Hn);
|
|
3607
3610
|
},
|
|
3608
3611
|
addProseMirrorPlugins() {
|
|
3609
|
-
return [new
|
|
3612
|
+
return [new B({ props: { handlePaste(e, t) {
|
|
3610
3613
|
let n = t.clipboardData?.getData("text/plain");
|
|
3611
3614
|
if (!n) return !1;
|
|
3612
3615
|
let r = n.split(/\r?\n/);
|
|
3613
3616
|
for (let n of r) {
|
|
3614
3617
|
let r = n.trim();
|
|
3615
|
-
if (!r || r.includes(" ") || !
|
|
3618
|
+
if (!r || r.includes(" ") || !Un(r)) continue;
|
|
3616
3619
|
t.preventDefault();
|
|
3617
3620
|
let i = e.state.schema.nodes.audioEmbed.create({ src: r });
|
|
3618
3621
|
return e.dispatch(e.state.tr.replaceSelectionWith(i)), !0;
|
|
@@ -3659,17 +3662,17 @@ var Un = ie.create({
|
|
|
3659
3662
|
});
|
|
3660
3663
|
//#endregion
|
|
3661
3664
|
//#region src/editor/embeds/video-view.tsx
|
|
3662
|
-
function
|
|
3665
|
+
function Gn(e) {
|
|
3663
3666
|
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";
|
|
3664
3667
|
}
|
|
3665
|
-
function
|
|
3668
|
+
function Kn(e) {
|
|
3666
3669
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
3667
3670
|
if (t) return t[0];
|
|
3668
3671
|
let n = e.match(/av(\d+)/i);
|
|
3669
3672
|
return n ? n[0] : e;
|
|
3670
3673
|
}
|
|
3671
|
-
function
|
|
3672
|
-
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ?
|
|
3674
|
+
function qn({ node: e, deleteNode: t, editor: n }) {
|
|
3675
|
+
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ? Gn(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(wn, {
|
|
3673
3676
|
open: o,
|
|
3674
3677
|
title: "确认删除视频",
|
|
3675
3678
|
message: "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
@@ -3678,7 +3681,7 @@ function Kn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3678
3681
|
},
|
|
3679
3682
|
onConfirm: async () => {
|
|
3680
3683
|
try {
|
|
3681
|
-
await
|
|
3684
|
+
await qt(r);
|
|
3682
3685
|
} catch {}
|
|
3683
3686
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3684
3687
|
}
|
|
@@ -3781,7 +3784,7 @@ function Kn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3781
3784
|
}, [a, h]), x(() => {
|
|
3782
3785
|
u && (_.current?.destroy(), _.current = null);
|
|
3783
3786
|
}, [u]), a === "bilibili") {
|
|
3784
|
-
let e =
|
|
3787
|
+
let e = Kn(r);
|
|
3785
3788
|
return /* @__PURE__ */ O(P, {
|
|
3786
3789
|
as: "div",
|
|
3787
3790
|
className: "video-embed video-embed--bilibili group/video",
|
|
@@ -3858,7 +3861,7 @@ function Kn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3858
3861
|
className: "video-fs-btn video-fs-btn--del",
|
|
3859
3862
|
title: "删除",
|
|
3860
3863
|
onClick: () => {
|
|
3861
|
-
|
|
3864
|
+
yn() || ($(!0), s(!0));
|
|
3862
3865
|
},
|
|
3863
3866
|
children: /* @__PURE__ */ D("svg", {
|
|
3864
3867
|
width: "12",
|
|
@@ -3965,7 +3968,7 @@ function Kn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3965
3968
|
className: "video-fs-btn video-fs-btn--del",
|
|
3966
3969
|
title: "删除",
|
|
3967
3970
|
onClick: () => {
|
|
3968
|
-
|
|
3971
|
+
yn() || ($(!0), s(!0));
|
|
3969
3972
|
},
|
|
3970
3973
|
children: /* @__PURE__ */ D("svg", {
|
|
3971
3974
|
width: "12",
|
|
@@ -4122,33 +4125,33 @@ function Kn({ node: e, deleteNode: t, editor: n }) {
|
|
|
4122
4125
|
}
|
|
4123
4126
|
//#endregion
|
|
4124
4127
|
//#region src/editor/embeds/video.ts
|
|
4125
|
-
function
|
|
4128
|
+
function Jn(e) {
|
|
4126
4129
|
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";
|
|
4127
4130
|
}
|
|
4128
|
-
function
|
|
4131
|
+
function Yn(e) {
|
|
4129
4132
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
4130
4133
|
if (t) return t[0];
|
|
4131
4134
|
let n = e.match(/av(\d+)/i);
|
|
4132
4135
|
return n ? n[0] : e;
|
|
4133
4136
|
}
|
|
4134
|
-
function
|
|
4137
|
+
function Xn(e) {
|
|
4135
4138
|
let t = e.match(/explore\/([a-zA-Z0-9]+)/);
|
|
4136
4139
|
return t ? t[1] : e;
|
|
4137
4140
|
}
|
|
4138
|
-
var
|
|
4141
|
+
var Zn = ae.create({
|
|
4139
4142
|
name: "videoEmbed",
|
|
4140
4143
|
group: "block",
|
|
4141
4144
|
atom: !0,
|
|
4142
4145
|
inline: !1,
|
|
4143
4146
|
addNodeView() {
|
|
4144
|
-
return F(
|
|
4147
|
+
return F(qn);
|
|
4145
4148
|
},
|
|
4146
4149
|
addProseMirrorPlugins() {
|
|
4147
|
-
return [new
|
|
4150
|
+
return [new B({ props: {
|
|
4148
4151
|
handleKeyDown(e, t) {
|
|
4149
4152
|
if (t.key !== " ") return !1;
|
|
4150
4153
|
let n = e.state.selection;
|
|
4151
|
-
if (n instanceof
|
|
4154
|
+
if (n instanceof z && n.node.type.name === "videoEmbed") {
|
|
4152
4155
|
t.preventDefault();
|
|
4153
4156
|
let r = e.nodeDOM(n.from);
|
|
4154
4157
|
if (r) {
|
|
@@ -4166,7 +4169,7 @@ var Xn = ie.create({
|
|
|
4166
4169
|
for (let n of r) {
|
|
4167
4170
|
let r = n.trim();
|
|
4168
4171
|
if (!r || r.includes(" ")) continue;
|
|
4169
|
-
let i =
|
|
4172
|
+
let i = Jn(r);
|
|
4170
4173
|
if (i === "unknown") continue;
|
|
4171
4174
|
t.preventDefault();
|
|
4172
4175
|
let a = e.state.schema.nodes.videoEmbed.create({
|
|
@@ -4198,7 +4201,7 @@ var Xn = ie.create({
|
|
|
4198
4201
|
let t = e, n = t.getAttribute("src") || t.getAttribute("data-src") || "";
|
|
4199
4202
|
return {
|
|
4200
4203
|
src: n,
|
|
4201
|
-
source:
|
|
4204
|
+
source: Jn(n)
|
|
4202
4205
|
};
|
|
4203
4206
|
}
|
|
4204
4207
|
},
|
|
@@ -4207,9 +4210,9 @@ var Xn = ie.create({
|
|
|
4207
4210
|
];
|
|
4208
4211
|
},
|
|
4209
4212
|
renderHTML({ HTMLAttributes: e }) {
|
|
4210
|
-
let t = e.src || "", n =
|
|
4213
|
+
let t = e.src || "", n = Jn(t);
|
|
4211
4214
|
if (n === "bilibili") {
|
|
4212
|
-
let e =
|
|
4215
|
+
let e = Yn(t);
|
|
4213
4216
|
return [
|
|
4214
4217
|
"div",
|
|
4215
4218
|
{
|
|
@@ -4230,7 +4233,7 @@ var Xn = ie.create({
|
|
|
4230
4233
|
}]
|
|
4231
4234
|
];
|
|
4232
4235
|
}
|
|
4233
|
-
if (n === "xiaohongshu") return
|
|
4236
|
+
if (n === "xiaohongshu") return Xn(t), [
|
|
4234
4237
|
"div",
|
|
4235
4238
|
{
|
|
4236
4239
|
"data-video-embed": "xiaohongshu",
|
|
@@ -4282,7 +4285,7 @@ var Xn = ie.create({
|
|
|
4282
4285
|
},
|
|
4283
4286
|
addCommands() {
|
|
4284
4287
|
return { insertVideo: (e) => ({ chain: t }) => {
|
|
4285
|
-
let n =
|
|
4288
|
+
let n = Jn(e.src);
|
|
4286
4289
|
return t().insertContent({
|
|
4287
4290
|
type: this.name,
|
|
4288
4291
|
attrs: {
|
|
@@ -4292,20 +4295,14 @@ var Xn = ie.create({
|
|
|
4292
4295
|
}).focus().run();
|
|
4293
4296
|
} };
|
|
4294
4297
|
}
|
|
4295
|
-
}),
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
async function nr(e, t) {
|
|
4304
|
-
Zn ||= await import("beautiful-mermaid");
|
|
4305
|
-
let n = Zn.renderMermaidSVG;
|
|
4306
|
-
return n(e, t);
|
|
4307
|
-
}
|
|
4308
|
-
var rr = [
|
|
4298
|
+
}), Qn = null, $n = {
|
|
4299
|
+
fontFamily: "Inter, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', system-ui, sans-serif",
|
|
4300
|
+
padding: 24
|
|
4301
|
+
}, er = .25, tr = 4, nr = .25;
|
|
4302
|
+
async function rr(e) {
|
|
4303
|
+
return Qn ||= await import("pele"), Qn.render(e, $n).svg;
|
|
4304
|
+
}
|
|
4305
|
+
var ir = [
|
|
4309
4306
|
{
|
|
4310
4307
|
value: "javascript",
|
|
4311
4308
|
label: "JavaScript",
|
|
@@ -4466,7 +4463,7 @@ var rr = [
|
|
|
4466
4463
|
label: "Plain Text",
|
|
4467
4464
|
color: "#6b7280"
|
|
4468
4465
|
}
|
|
4469
|
-
],
|
|
4466
|
+
], ar = {
|
|
4470
4467
|
javascript: "js",
|
|
4471
4468
|
typescript: "ts",
|
|
4472
4469
|
python: "py",
|
|
@@ -4492,7 +4489,7 @@ var rr = [
|
|
|
4492
4489
|
txt: "txt",
|
|
4493
4490
|
vue: "vue",
|
|
4494
4491
|
react: "jsx"
|
|
4495
|
-
},
|
|
4492
|
+
}, or = {
|
|
4496
4493
|
js: "javascript",
|
|
4497
4494
|
ts: "typescript",
|
|
4498
4495
|
py: "python",
|
|
@@ -4508,51 +4505,51 @@ var rr = [
|
|
|
4508
4505
|
jsx: "javascript",
|
|
4509
4506
|
tsx: "typescript"
|
|
4510
4507
|
};
|
|
4511
|
-
function
|
|
4508
|
+
function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i, selected: a }) {
|
|
4512
4509
|
let o = n?.isEditable ?? !0, s = !o, [c, l] = T(!1), [u, d] = T(!1), [f, m] = T(!1), [h, g] = T(!1), [_, v] = T(220), [y, S] = T({
|
|
4513
4510
|
top: 0,
|
|
4514
4511
|
left: 0,
|
|
4515
4512
|
width: 210
|
|
4516
|
-
}), [k, A] = T(""), [j, M] = T(!1), [N, ee] = T(null), [P, F] = T(null), [I, te] = T(!1), [ne,
|
|
4513
|
+
}), [k, A] = T(""), [j, M] = T(!1), [N, ee] = T(null), [P, F] = T(null), [I, te] = T(!1), [ne, L] = T(!1), [ie, ae] = T(1), [R, z] = T({
|
|
4517
4514
|
x: 0,
|
|
4518
4515
|
y: 0
|
|
4519
|
-
}), [
|
|
4520
|
-
|
|
4516
|
+
}), [B, V] = T(!1), oe = w(null), se = w(null), H = w(null), U = w(null), ce = w(null), W = w(null), G = w(null), le = e.attrs.language || "", K = ir.find((e) => e.value === (or[le] ?? le)), ue = le === "mermaid", de = (e) => Math.min(tr, Math.max(er, e)), fe = (e) => ae((t) => Math.round(de(t + e) * 100) / 100), pe = () => {
|
|
4517
|
+
ae(1), z({
|
|
4521
4518
|
x: 0,
|
|
4522
4519
|
y: 0
|
|
4523
4520
|
});
|
|
4524
|
-
},
|
|
4525
|
-
|
|
4521
|
+
}, q = () => {
|
|
4522
|
+
pe(), L(!0);
|
|
4526
4523
|
};
|
|
4527
4524
|
x(() => {
|
|
4528
|
-
N ||
|
|
4525
|
+
N || L(!1);
|
|
4529
4526
|
}, [N]), x(() => {
|
|
4530
4527
|
if (!ne) return;
|
|
4531
4528
|
let e = document.body.style.overflow;
|
|
4532
4529
|
document.body.style.overflow = "hidden";
|
|
4533
4530
|
let t = (e) => {
|
|
4534
|
-
e.key === "Escape" &&
|
|
4531
|
+
e.key === "Escape" && L(!1);
|
|
4535
4532
|
};
|
|
4536
4533
|
return window.addEventListener("keydown", t), () => {
|
|
4537
4534
|
document.body.style.overflow = e, window.removeEventListener("keydown", t);
|
|
4538
4535
|
};
|
|
4539
4536
|
}, [ne]);
|
|
4540
|
-
let
|
|
4541
|
-
e.button === 0 && (e.currentTarget.setPointerCapture(e.pointerId),
|
|
4537
|
+
let me = (e) => {
|
|
4538
|
+
e.button === 0 && (e.currentTarget.setPointerCapture(e.pointerId), oe.current = {
|
|
4542
4539
|
x: e.clientX,
|
|
4543
4540
|
y: e.clientY,
|
|
4544
|
-
panX:
|
|
4545
|
-
panY:
|
|
4546
|
-
},
|
|
4547
|
-
},
|
|
4548
|
-
let t =
|
|
4549
|
-
t &&
|
|
4541
|
+
panX: R.x,
|
|
4542
|
+
panY: R.y
|
|
4543
|
+
}, V(!0));
|
|
4544
|
+
}, he = (e) => {
|
|
4545
|
+
let t = oe.current;
|
|
4546
|
+
t && z({
|
|
4550
4547
|
x: t.panX + e.clientX - t.x,
|
|
4551
4548
|
y: t.panY + e.clientY - t.y
|
|
4552
4549
|
});
|
|
4553
|
-
},
|
|
4554
|
-
|
|
4555
|
-
},
|
|
4550
|
+
}, ge = () => {
|
|
4551
|
+
oe.current = null, V(!1);
|
|
4552
|
+
}, _e = b(() => {
|
|
4556
4553
|
if (!n || typeof r != "function") return null;
|
|
4557
4554
|
let t = r();
|
|
4558
4555
|
return typeof t == "number" ? {
|
|
@@ -4563,19 +4560,19 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4563
4560
|
n,
|
|
4564
4561
|
r,
|
|
4565
4562
|
e.nodeSize
|
|
4566
|
-
]),
|
|
4567
|
-
o && (
|
|
4568
|
-
}, [
|
|
4563
|
+
]), ve = b(() => {
|
|
4564
|
+
o && (yn() || (G.current = _e(), window.getSelection()?.removeAllRanges(), $(!0), M(!0)));
|
|
4565
|
+
}, [_e, o]), ye = C(() => {
|
|
4569
4566
|
let e = k.trim().toLowerCase();
|
|
4570
|
-
return e ?
|
|
4567
|
+
return e ? ir.filter((t) => t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e)) : ir;
|
|
4571
4568
|
}, [k]);
|
|
4572
4569
|
x(() => {
|
|
4573
|
-
(
|
|
4570
|
+
(W.current?.closest(".code-block-node-view"))?.classList.toggle("code-block-node-view--collapsed", u);
|
|
4574
4571
|
}, [u]);
|
|
4575
|
-
let
|
|
4576
|
-
let e =
|
|
4572
|
+
let be = b(() => {
|
|
4573
|
+
let e = U.current;
|
|
4577
4574
|
if (!e) return;
|
|
4578
|
-
let t = e.getBoundingClientRect(), n = Math.min(t.left, window.innerWidth - 210 - 8), r = window.innerHeight - t.bottom - 12, i = t.top - 12, a =
|
|
4575
|
+
let t = e.getBoundingClientRect(), n = Math.min(t.left, window.innerWidth - 210 - 8), r = window.innerHeight - t.bottom - 12, i = t.top - 12, a = ir.length * 31 + 8, o = r - 52, s = i - 52;
|
|
4579
4576
|
o < 220 && s > o ? (g(!0), v(Math.max(120, Math.min(a, s))), S({
|
|
4580
4577
|
top: t.top,
|
|
4581
4578
|
left: n,
|
|
@@ -4588,16 +4585,16 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4588
4585
|
}, []);
|
|
4589
4586
|
x(() => {
|
|
4590
4587
|
if (!f) return;
|
|
4591
|
-
A(""),
|
|
4592
|
-
let e = setTimeout(() =>
|
|
4593
|
-
return window.addEventListener("resize",
|
|
4594
|
-
clearTimeout(e), window.removeEventListener("resize",
|
|
4588
|
+
A(""), be();
|
|
4589
|
+
let e = setTimeout(() => ce.current?.focus(), 50);
|
|
4590
|
+
return window.addEventListener("resize", be), window.addEventListener("scroll", be, !0), () => {
|
|
4591
|
+
clearTimeout(e), window.removeEventListener("resize", be), window.removeEventListener("scroll", be, !0);
|
|
4595
4592
|
};
|
|
4596
|
-
}, [f,
|
|
4593
|
+
}, [f, be]), x(() => {
|
|
4597
4594
|
if (!f) return;
|
|
4598
4595
|
let e = (e) => {
|
|
4599
4596
|
let t = e.target;
|
|
4600
|
-
t && (
|
|
4597
|
+
t && (U.current?.contains(t) || H.current?.contains(t) || m(!1));
|
|
4601
4598
|
};
|
|
4602
4599
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
4603
4600
|
}, [f]), x(() => {
|
|
@@ -4608,12 +4605,12 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4608
4605
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
4609
4606
|
}, [f]), x(() => {
|
|
4610
4607
|
let e = (e) => {
|
|
4611
|
-
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !a ||
|
|
4608
|
+
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !a || yn()) return;
|
|
4612
4609
|
let t = n?.view?.dom, r = e.target;
|
|
4613
4610
|
if (n?.isFocused && r instanceof Node && t?.contains(r)) {
|
|
4614
4611
|
if (e.preventDefault(), e.stopPropagation(), n) {
|
|
4615
4612
|
let { from: e, to: t } = n.state.selection;
|
|
4616
|
-
|
|
4613
|
+
G.current = {
|
|
4617
4614
|
from: e,
|
|
4618
4615
|
to: t
|
|
4619
4616
|
};
|
|
@@ -4627,9 +4624,9 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4627
4624
|
n,
|
|
4628
4625
|
o
|
|
4629
4626
|
]);
|
|
4630
|
-
let
|
|
4627
|
+
let xe = b((e) => {
|
|
4631
4628
|
t({ language: e || null }), m(!1);
|
|
4632
|
-
}, [t]),
|
|
4629
|
+
}, [t]), Se = b(() => {
|
|
4633
4630
|
if (o) {
|
|
4634
4631
|
if (n && r) {
|
|
4635
4632
|
let e = r();
|
|
@@ -4641,7 +4638,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4641
4638
|
n,
|
|
4642
4639
|
r,
|
|
4643
4640
|
o
|
|
4644
|
-
]),
|
|
4641
|
+
]), Ce = b(() => {
|
|
4645
4642
|
let t = e.textContent, n = (e) => {
|
|
4646
4643
|
let t = document.createElement("textarea");
|
|
4647
4644
|
t.value = e, t.style.position = "fixed", t.style.opacity = "0", document.body.appendChild(t), t.select();
|
|
@@ -4651,10 +4648,10 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4651
4648
|
document.body.removeChild(t);
|
|
4652
4649
|
};
|
|
4653
4650
|
navigator.clipboard?.writeText ? navigator.clipboard.writeText(t).catch(() => n(t)) : n(t), l(!0), setTimeout(() => l(!1), 1500);
|
|
4654
|
-
}, [e.textContent]),
|
|
4655
|
-
let t =
|
|
4651
|
+
}, [e.textContent]), we = b(() => {
|
|
4652
|
+
let t = ar[le] || "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");
|
|
4656
4653
|
a.href = i, a.download = n, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
4657
|
-
}, [e.textContent,
|
|
4654
|
+
}, [e.textContent, le]), Te = b(async () => {
|
|
4658
4655
|
if (N || I) {
|
|
4659
4656
|
ee(null), F(null), te(!1);
|
|
4660
4657
|
return;
|
|
@@ -4666,10 +4663,10 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4666
4663
|
F("代码块内容为空");
|
|
4667
4664
|
return;
|
|
4668
4665
|
}
|
|
4669
|
-
let n = p(await
|
|
4666
|
+
let n = p(await rr(t));
|
|
4670
4667
|
ee(n);
|
|
4671
4668
|
} catch (e) {
|
|
4672
|
-
F(e instanceof Error ? e.message : "
|
|
4669
|
+
F(e instanceof Error ? e.message : "图表渲染失败");
|
|
4673
4670
|
} finally {
|
|
4674
4671
|
te(!1);
|
|
4675
4672
|
}
|
|
@@ -4677,9 +4674,9 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4677
4674
|
e.textContent,
|
|
4678
4675
|
N,
|
|
4679
4676
|
I
|
|
4680
|
-
]),
|
|
4681
|
-
className: `${
|
|
4682
|
-
style: { color:
|
|
4677
|
+
]), Ee = /* @__PURE__ */ O(E, { children: [K ? K.deviconClass ? /* @__PURE__ */ D("i", {
|
|
4678
|
+
className: `${K.deviconClass} colored cb-lang-icon`,
|
|
4679
|
+
style: { color: K.color }
|
|
4683
4680
|
}) : /* @__PURE__ */ D("span", {
|
|
4684
4681
|
className: "cb-lang-icon cb-lang-icon--auto",
|
|
4685
4682
|
children: "Tx"
|
|
@@ -4688,10 +4685,10 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4688
4685
|
children: "?"
|
|
4689
4686
|
}), /* @__PURE__ */ D("span", {
|
|
4690
4687
|
className: "cb-lang-label",
|
|
4691
|
-
children:
|
|
4688
|
+
children: K?.label || "自动"
|
|
4692
4689
|
})] });
|
|
4693
4690
|
return /* @__PURE__ */ O("div", {
|
|
4694
|
-
ref:
|
|
4691
|
+
ref: W,
|
|
4695
4692
|
className: "cb-react-shell group/cb",
|
|
4696
4693
|
style: { display: "contents" },
|
|
4697
4694
|
children: [
|
|
@@ -4702,17 +4699,17 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4702
4699
|
children: [
|
|
4703
4700
|
/* @__PURE__ */ D("div", {
|
|
4704
4701
|
className: "cb-lang-wrap",
|
|
4705
|
-
ref:
|
|
4702
|
+
ref: se,
|
|
4706
4703
|
contentEditable: !1,
|
|
4707
4704
|
children: s ? /* @__PURE__ */ D("span", {
|
|
4708
4705
|
className: "cb-lang-trigger cb-lang-trigger--static",
|
|
4709
|
-
children:
|
|
4706
|
+
children: Ee
|
|
4710
4707
|
}) : /* @__PURE__ */ O("button", {
|
|
4711
|
-
ref:
|
|
4708
|
+
ref: U,
|
|
4712
4709
|
type: "button",
|
|
4713
4710
|
className: "cb-lang-trigger",
|
|
4714
4711
|
onClick: () => m(!f),
|
|
4715
|
-
children: [
|
|
4712
|
+
children: [Ee, /* @__PURE__ */ D("svg", {
|
|
4716
4713
|
className: `cb-lang-chevron${f ? " cb-lang-chevron--open" : ""}`,
|
|
4717
4714
|
width: "10",
|
|
4718
4715
|
height: "10",
|
|
@@ -4734,7 +4731,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4734
4731
|
contentEditable: !1,
|
|
4735
4732
|
onClick: () => d(!1),
|
|
4736
4733
|
title: "展开代码块",
|
|
4737
|
-
children: [
|
|
4734
|
+
children: [Ee, /* @__PURE__ */ D("svg", {
|
|
4738
4735
|
className: "cb-lang-chevron",
|
|
4739
4736
|
width: "12",
|
|
4740
4737
|
height: "12",
|
|
@@ -4749,8 +4746,8 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4749
4746
|
})
|
|
4750
4747
|
})]
|
|
4751
4748
|
}),
|
|
4752
|
-
o && f &&
|
|
4753
|
-
ref:
|
|
4749
|
+
o && f && re(/* @__PURE__ */ O("div", {
|
|
4750
|
+
ref: H,
|
|
4754
4751
|
className: `cb-lang-dropdown${h ? " cb-lang-dropdown--up" : ""}`,
|
|
4755
4752
|
style: {
|
|
4756
4753
|
position: "fixed",
|
|
@@ -4775,7 +4772,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4775
4772
|
d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
|
4776
4773
|
})
|
|
4777
4774
|
}), /* @__PURE__ */ D("input", {
|
|
4778
|
-
ref:
|
|
4775
|
+
ref: ce,
|
|
4779
4776
|
className: "cb-lang-search",
|
|
4780
4777
|
type: "text",
|
|
4781
4778
|
placeholder: "搜索语言...",
|
|
@@ -4789,17 +4786,17 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4789
4786
|
children: [
|
|
4790
4787
|
/* @__PURE__ */ O("button", {
|
|
4791
4788
|
type: "button",
|
|
4792
|
-
className: `cb-lang-option${
|
|
4793
|
-
onClick: () =>
|
|
4789
|
+
className: `cb-lang-option${le ? "" : " cb-lang-option--active"}`,
|
|
4790
|
+
onClick: () => xe(""),
|
|
4794
4791
|
children: [/* @__PURE__ */ D("span", {
|
|
4795
4792
|
className: "cb-lang-icon cb-lang-icon--auto",
|
|
4796
4793
|
children: "?"
|
|
4797
4794
|
}), /* @__PURE__ */ D("span", { children: "自动检测" })]
|
|
4798
4795
|
}),
|
|
4799
|
-
|
|
4796
|
+
ye.map((e) => /* @__PURE__ */ O("button", {
|
|
4800
4797
|
type: "button",
|
|
4801
|
-
className: `cb-lang-option${
|
|
4802
|
-
onClick: () =>
|
|
4798
|
+
className: `cb-lang-option${le === e.value ? " cb-lang-option--active" : ""}`,
|
|
4799
|
+
onClick: () => xe(e.value),
|
|
4803
4800
|
children: [e.deviconClass ? /* @__PURE__ */ D("i", {
|
|
4804
4801
|
className: `${e.deviconClass} colored cb-lang-icon`,
|
|
4805
4802
|
style: { color: e.color }
|
|
@@ -4808,7 +4805,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4808
4805
|
children: "Tx"
|
|
4809
4806
|
}), /* @__PURE__ */ D("span", { children: e.label })]
|
|
4810
4807
|
}, e.value)),
|
|
4811
|
-
|
|
4808
|
+
ye.length === 0 && /* @__PURE__ */ D("div", {
|
|
4812
4809
|
className: "cb-lang-empty",
|
|
4813
4810
|
children: "无匹配语言"
|
|
4814
4811
|
})
|
|
@@ -4844,7 +4841,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4844
4841
|
/* @__PURE__ */ D("button", {
|
|
4845
4842
|
type: "button",
|
|
4846
4843
|
className: "cb-btn",
|
|
4847
|
-
onClick:
|
|
4844
|
+
onClick: Ce,
|
|
4848
4845
|
contentEditable: !1,
|
|
4849
4846
|
title: "复制",
|
|
4850
4847
|
children: c ? /* @__PURE__ */ D("svg", {
|
|
@@ -4874,7 +4871,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4874
4871
|
/* @__PURE__ */ D("button", {
|
|
4875
4872
|
type: "button",
|
|
4876
4873
|
className: "cb-btn",
|
|
4877
|
-
onClick:
|
|
4874
|
+
onClick: we,
|
|
4878
4875
|
contentEditable: !1,
|
|
4879
4876
|
title: "下载",
|
|
4880
4877
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4893,7 +4890,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4893
4890
|
o && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("button", {
|
|
4894
4891
|
type: "button",
|
|
4895
4892
|
className: "cb-btn cb-btn--ai",
|
|
4896
|
-
onClick:
|
|
4893
|
+
onClick: Se,
|
|
4897
4894
|
contentEditable: !1,
|
|
4898
4895
|
title: "写作助手",
|
|
4899
4896
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4911,7 +4908,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4911
4908
|
}), /* @__PURE__ */ D("button", {
|
|
4912
4909
|
type: "button",
|
|
4913
4910
|
className: "cb-btn cb-btn--del",
|
|
4914
|
-
onClick:
|
|
4911
|
+
onClick: ve,
|
|
4915
4912
|
contentEditable: !1,
|
|
4916
4913
|
title: "删除代码块",
|
|
4917
4914
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4927,10 +4924,10 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4927
4924
|
})
|
|
4928
4925
|
})
|
|
4929
4926
|
})] }),
|
|
4930
|
-
|
|
4927
|
+
ue && /* @__PURE__ */ D("button", {
|
|
4931
4928
|
type: "button",
|
|
4932
4929
|
className: "cb-btn cb-btn--diagram",
|
|
4933
|
-
onClick:
|
|
4930
|
+
onClick: Te,
|
|
4934
4931
|
contentEditable: !1,
|
|
4935
4932
|
title: N || I ? "取消渲染" : "渲染图表",
|
|
4936
4933
|
disabled: I,
|
|
@@ -4971,9 +4968,9 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4971
4968
|
role: "button",
|
|
4972
4969
|
tabIndex: 0,
|
|
4973
4970
|
title: "点击放大查看",
|
|
4974
|
-
onClick:
|
|
4971
|
+
onClick: q,
|
|
4975
4972
|
onKeyDown: (e) => {
|
|
4976
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
4973
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), q());
|
|
4977
4974
|
},
|
|
4978
4975
|
children: [/* @__PURE__ */ D("div", {
|
|
4979
4976
|
className: "cb-diagram-svg-inner",
|
|
@@ -4985,7 +4982,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4985
4982
|
})
|
|
4986
4983
|
]
|
|
4987
4984
|
}),
|
|
4988
|
-
ne && N &&
|
|
4985
|
+
ne && N && re(/* @__PURE__ */ O("div", {
|
|
4989
4986
|
className: "fixed inset-0 z-[10002] flex flex-col bg-black/75 backdrop-blur-sm select-none",
|
|
4990
4987
|
role: "dialog",
|
|
4991
4988
|
"aria-modal": "true",
|
|
@@ -5001,7 +4998,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5001
4998
|
/* @__PURE__ */ D("button", {
|
|
5002
4999
|
type: "button",
|
|
5003
5000
|
className: "flex h-8 min-w-8 items-center justify-center rounded-lg bg-white/10 px-2 text-base text-white transition-colors hover:bg-white/20",
|
|
5004
|
-
onClick: () =>
|
|
5001
|
+
onClick: () => fe(-.25),
|
|
5005
5002
|
title: "缩小",
|
|
5006
5003
|
"aria-label": "缩小",
|
|
5007
5004
|
children: "−"
|
|
@@ -5009,15 +5006,15 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5009
5006
|
/* @__PURE__ */ O("button", {
|
|
5010
5007
|
type: "button",
|
|
5011
5008
|
className: "flex h-8 min-w-14 items-center justify-center rounded-lg bg-white/10 px-2 text-xs text-white transition-colors hover:bg-white/20",
|
|
5012
|
-
onClick:
|
|
5009
|
+
onClick: pe,
|
|
5013
5010
|
title: "重置为 100%",
|
|
5014
5011
|
"aria-label": "重置缩放",
|
|
5015
|
-
children: [Math.round(
|
|
5012
|
+
children: [Math.round(ie * 100), "%"]
|
|
5016
5013
|
}),
|
|
5017
5014
|
/* @__PURE__ */ D("button", {
|
|
5018
5015
|
type: "button",
|
|
5019
5016
|
className: "flex h-8 min-w-8 items-center justify-center rounded-lg bg-white/10 px-2 text-base text-white transition-colors hover:bg-white/20",
|
|
5020
|
-
onClick: () =>
|
|
5017
|
+
onClick: () => fe(nr),
|
|
5021
5018
|
title: "放大",
|
|
5022
5019
|
"aria-label": "放大",
|
|
5023
5020
|
children: "+"
|
|
@@ -5025,7 +5022,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5025
5022
|
/* @__PURE__ */ D("button", {
|
|
5026
5023
|
type: "button",
|
|
5027
5024
|
className: "flex h-8 min-w-8 items-center justify-center rounded-lg bg-white/10 px-2 text-sm text-white transition-colors hover:bg-white/20",
|
|
5028
|
-
onClick:
|
|
5025
|
+
onClick: pe,
|
|
5029
5026
|
title: "重置",
|
|
5030
5027
|
"aria-label": "重置",
|
|
5031
5028
|
children: "⟲"
|
|
@@ -5034,7 +5031,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5034
5031
|
/* @__PURE__ */ D("button", {
|
|
5035
5032
|
type: "button",
|
|
5036
5033
|
className: "flex h-8 min-w-8 items-center justify-center rounded-lg bg-white/10 px-2 text-lg text-white transition-colors hover:bg-white/20",
|
|
5037
|
-
onClick: () =>
|
|
5034
|
+
onClick: () => L(!1),
|
|
5038
5035
|
title: "关闭",
|
|
5039
5036
|
"aria-label": "关闭",
|
|
5040
5037
|
children: "×"
|
|
@@ -5043,14 +5040,14 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5043
5040
|
})]
|
|
5044
5041
|
}), /* @__PURE__ */ D("div", {
|
|
5045
5042
|
className: "flex flex-1 touch-none items-center justify-center overflow-hidden",
|
|
5046
|
-
style: { cursor:
|
|
5047
|
-
onWheel: (e) =>
|
|
5048
|
-
onPointerDown:
|
|
5049
|
-
onPointerMove:
|
|
5050
|
-
onPointerUp:
|
|
5051
|
-
onPointerCancel:
|
|
5043
|
+
style: { cursor: B ? "grabbing" : ie > 1 ? "grab" : "default" },
|
|
5044
|
+
onWheel: (e) => fe(e.deltaY > 0 ? -.25 : nr),
|
|
5045
|
+
onPointerDown: me,
|
|
5046
|
+
onPointerMove: he,
|
|
5047
|
+
onPointerUp: ge,
|
|
5048
|
+
onPointerCancel: ge,
|
|
5052
5049
|
onDoubleClick: () => {
|
|
5053
|
-
|
|
5050
|
+
ae((e) => e === 1 ? 2 : 1), z({
|
|
5054
5051
|
x: 0,
|
|
5055
5052
|
y: 0
|
|
5056
5053
|
});
|
|
@@ -5058,14 +5055,14 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5058
5055
|
children: /* @__PURE__ */ D("div", {
|
|
5059
5056
|
className: "cb-diagram-zoom-content",
|
|
5060
5057
|
style: {
|
|
5061
|
-
transform: `translate(${
|
|
5062
|
-
transition:
|
|
5058
|
+
transform: `translate(${R.x}px, ${R.y}px) scale(${ie})`,
|
|
5059
|
+
transition: B ? "none" : "transform 120ms ease-out"
|
|
5063
5060
|
},
|
|
5064
5061
|
dangerouslySetInnerHTML: { __html: N }
|
|
5065
5062
|
})
|
|
5066
5063
|
})]
|
|
5067
5064
|
}), document.body),
|
|
5068
|
-
/* @__PURE__ */ D(
|
|
5065
|
+
/* @__PURE__ */ D(wn, {
|
|
5069
5066
|
open: j,
|
|
5070
5067
|
title: "确认删除代码块",
|
|
5071
5068
|
message: "此操作不可撤销。",
|
|
@@ -5081,7 +5078,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5081
5078
|
}
|
|
5082
5079
|
//#endregion
|
|
5083
5080
|
//#region src/editor/extensions/code-block.ts
|
|
5084
|
-
var
|
|
5081
|
+
var cr = [
|
|
5085
5082
|
{
|
|
5086
5083
|
value: "javascript",
|
|
5087
5084
|
label: "JavaScript"
|
|
@@ -5182,12 +5179,12 @@ var sr = [
|
|
|
5182
5179
|
value: "mermaid",
|
|
5183
5180
|
label: "Mermaid"
|
|
5184
5181
|
}
|
|
5185
|
-
],
|
|
5186
|
-
|
|
5187
|
-
function
|
|
5182
|
+
], lr = Ce(Se);
|
|
5183
|
+
lr.register({ dockerfile: xe }), lr.registerAlias("xml", ["vue", "html"]), lr.registerAlias("javascript", ["react", "jsx"]), lr.registerAlias("typescript", ["tsx"]);
|
|
5184
|
+
function ur(e) {
|
|
5188
5185
|
return e ? e.split("\n") : [""];
|
|
5189
5186
|
}
|
|
5190
|
-
function
|
|
5187
|
+
function dr(e, t) {
|
|
5191
5188
|
if (e.childElementCount !== t) {
|
|
5192
5189
|
e.replaceChildren();
|
|
5193
5190
|
for (let n = 1; n <= t; n++) {
|
|
@@ -5196,14 +5193,14 @@ function ur(e, t) {
|
|
|
5196
5193
|
}
|
|
5197
5194
|
}
|
|
5198
5195
|
}
|
|
5199
|
-
function
|
|
5196
|
+
function fr(e, t) {
|
|
5200
5197
|
e.replaceChildren();
|
|
5201
5198
|
for (let n of t) {
|
|
5202
5199
|
let t = document.createElement("span");
|
|
5203
5200
|
t.className = "cb-mirror-line", t.textContent = n.length ? n : "\xA0", e.appendChild(t);
|
|
5204
5201
|
}
|
|
5205
5202
|
}
|
|
5206
|
-
function
|
|
5203
|
+
function pr(e, t, n) {
|
|
5207
5204
|
let r = getComputedStyle(e), i = parseFloat(r.paddingLeft), a = parseFloat(r.paddingRight);
|
|
5208
5205
|
t.style.boxSizing = "content-box", t.style.width = `${Math.max(0, e.clientWidth - i - a)}px`, t.style.padding = r.padding;
|
|
5209
5206
|
let o = getComputedStyle(n);
|
|
@@ -5250,7 +5247,7 @@ function fr(e, t, n) {
|
|
|
5250
5247
|
r = e + 1 < C.length ? C[e + 1] - C[e] : w - T, (!Number.isFinite(r) || r < 1) && (r = c), t.style.height = `${r}px`, T += r;
|
|
5251
5248
|
}
|
|
5252
5249
|
}
|
|
5253
|
-
var
|
|
5250
|
+
var mr = be.extend({
|
|
5254
5251
|
addNodeView() {
|
|
5255
5252
|
return (e) => {
|
|
5256
5253
|
let { node: t, editor: n, getPos: r } = e, i = t, a = (e) => {
|
|
@@ -5278,9 +5275,9 @@ var pr = ye.extend({
|
|
|
5278
5275
|
f.appendChild(p);
|
|
5279
5276
|
let m = document.createElement("div");
|
|
5280
5277
|
m.className = "cb-code-mirror", m.contentEditable = "false", m.setAttribute("aria-hidden", "true"), u.appendChild(d), u.appendChild(f), u.appendChild(m), l.appendChild(u), s.appendChild(l);
|
|
5281
|
-
let h =
|
|
5282
|
-
|
|
5283
|
-
let g = new I(
|
|
5278
|
+
let h = ur(t.textContent);
|
|
5279
|
+
dr(d, h.length), fr(m, h);
|
|
5280
|
+
let g = new I(sr, {
|
|
5284
5281
|
editor: n,
|
|
5285
5282
|
props: {
|
|
5286
5283
|
node: t,
|
|
@@ -5293,12 +5290,12 @@ var pr = ye.extend({
|
|
|
5293
5290
|
});
|
|
5294
5291
|
c.appendChild(g.element);
|
|
5295
5292
|
let _ = (e) => {
|
|
5296
|
-
let t =
|
|
5297
|
-
|
|
5293
|
+
let t = ur(e.textContent);
|
|
5294
|
+
dr(d, t.length), fr(m, t), requestAnimationFrame(() => pr(f, m, d));
|
|
5298
5295
|
};
|
|
5299
|
-
requestAnimationFrame(() =>
|
|
5300
|
-
let v = new ResizeObserver(() =>
|
|
5301
|
-
return v.observe(f), document.fonts?.ready?.then(() =>
|
|
5296
|
+
requestAnimationFrame(() => pr(f, m, d));
|
|
5297
|
+
let v = new ResizeObserver(() => pr(f, m, d));
|
|
5298
|
+
return v.observe(f), document.fonts?.ready?.then(() => pr(f, m, d)), {
|
|
5302
5299
|
dom: s,
|
|
5303
5300
|
contentDOM: p,
|
|
5304
5301
|
update(e) {
|
|
@@ -5358,10 +5355,10 @@ var pr = ye.extend({
|
|
|
5358
5355
|
}
|
|
5359
5356
|
}));
|
|
5360
5357
|
}
|
|
5361
|
-
}).configure({ lowlight:
|
|
5358
|
+
}).configure({ lowlight: lr });
|
|
5362
5359
|
//#endregion
|
|
5363
5360
|
//#region src/editor/utils/import-choice-dialog.ts
|
|
5364
|
-
function
|
|
5361
|
+
function hr(e) {
|
|
5365
5362
|
return new Promise((t) => {
|
|
5366
5363
|
let n = document.createElement("div");
|
|
5367
5364
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5391,16 +5388,16 @@ function mr(e) {
|
|
|
5391
5388
|
}
|
|
5392
5389
|
//#endregion
|
|
5393
5390
|
//#region src/editor/utils/local-media.ts
|
|
5394
|
-
var
|
|
5395
|
-
function
|
|
5391
|
+
var gr = /\.(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, _r = /^(?:mailto:|tel:|javascript:|about:|data:|blob:)/i;
|
|
5392
|
+
function vr(e) {
|
|
5396
5393
|
if (!e) return !1;
|
|
5397
5394
|
let t = e.trim();
|
|
5398
|
-
return !(!t || /^(?:https?:)?\/\//i.test(t) ||
|
|
5399
|
-
}
|
|
5400
|
-
function vr(e) {
|
|
5401
|
-
return hr.test(e);
|
|
5395
|
+
return !(!t || /^(?:https?:)?\/\//i.test(t) || _r.test(t) || t.startsWith("#"));
|
|
5402
5396
|
}
|
|
5403
5397
|
function yr(e) {
|
|
5398
|
+
return gr.test(e);
|
|
5399
|
+
}
|
|
5400
|
+
function br(e) {
|
|
5404
5401
|
let t = e.trim();
|
|
5405
5402
|
t = t.replace(/^(?:file|app):\/\/(?:localhost)?/i, "");
|
|
5406
5403
|
try {
|
|
@@ -5408,26 +5405,26 @@ function yr(e) {
|
|
|
5408
5405
|
} catch {}
|
|
5409
5406
|
return t = t.replace(/\\/g, "/"), t = t.replace(/^\.\//, ""), t = t.replace(/^\/+/, ""), t = t.replace(/^[a-zA-Z]:\//, ""), t;
|
|
5410
5407
|
}
|
|
5411
|
-
function
|
|
5412
|
-
let t =
|
|
5408
|
+
function xr(e) {
|
|
5409
|
+
let t = br(e), n = t.split("/").filter(Boolean);
|
|
5413
5410
|
return (n[n.length - 1] || t).toLowerCase();
|
|
5414
5411
|
}
|
|
5415
|
-
function
|
|
5412
|
+
function Sr() {
|
|
5416
5413
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showDirectoryPicker == "function";
|
|
5417
5414
|
}
|
|
5418
|
-
async function
|
|
5419
|
-
if (!
|
|
5415
|
+
async function Cr() {
|
|
5416
|
+
if (!Sr()) return null;
|
|
5420
5417
|
try {
|
|
5421
5418
|
return await window.showDirectoryPicker.call(window, { mode: "read" }) ?? null;
|
|
5422
5419
|
} catch {
|
|
5423
5420
|
return null;
|
|
5424
5421
|
}
|
|
5425
5422
|
}
|
|
5426
|
-
function
|
|
5423
|
+
function wr() {
|
|
5427
5424
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showOpenFilePicker == "function";
|
|
5428
5425
|
}
|
|
5429
|
-
async function
|
|
5430
|
-
if (!
|
|
5426
|
+
async function Tr() {
|
|
5427
|
+
if (!wr()) return null;
|
|
5431
5428
|
try {
|
|
5432
5429
|
let e = await window.showOpenFilePicker.call(window, { multiple: !0 });
|
|
5433
5430
|
return await Promise.all(e.map((e) => e.getFile()));
|
|
@@ -5435,7 +5432,7 @@ async function wr() {
|
|
|
5435
5432
|
return null;
|
|
5436
5433
|
}
|
|
5437
5434
|
}
|
|
5438
|
-
async function
|
|
5435
|
+
async function Er(e, t) {
|
|
5439
5436
|
if (t.length === 0) return { file: null };
|
|
5440
5437
|
let n = e;
|
|
5441
5438
|
for (let e = 0; e < t.length - 1; e++) try {
|
|
@@ -5457,7 +5454,7 @@ async function Tr(e, t) {
|
|
|
5457
5454
|
return { file: null };
|
|
5458
5455
|
}
|
|
5459
5456
|
}
|
|
5460
|
-
async function
|
|
5457
|
+
async function Dr(e, t, n = 5e3) {
|
|
5461
5458
|
let r = t.toLowerCase(), i = [e], a = 0, o;
|
|
5462
5459
|
for (; i.length > 0 && a < n;) {
|
|
5463
5460
|
let e = i.pop();
|
|
@@ -5479,37 +5476,37 @@ async function Er(e, t, n = 5e3) {
|
|
|
5479
5476
|
readError: o
|
|
5480
5477
|
};
|
|
5481
5478
|
}
|
|
5482
|
-
async function
|
|
5483
|
-
let n =
|
|
5479
|
+
async function Or(e, t) {
|
|
5480
|
+
let n = br(t).split("/").filter(Boolean);
|
|
5484
5481
|
if (n.length === 0) return { file: null };
|
|
5485
5482
|
let r;
|
|
5486
5483
|
for (let t = 0; t < n.length; t++) {
|
|
5487
|
-
let i = await
|
|
5484
|
+
let i = await Er(e, n.slice(t));
|
|
5488
5485
|
if (i.file) return i;
|
|
5489
5486
|
i.readError && (r = i.readError);
|
|
5490
5487
|
}
|
|
5491
|
-
let i = await
|
|
5488
|
+
let i = await Dr(e, n[n.length - 1]);
|
|
5492
5489
|
return i.file || i.readError ? i : {
|
|
5493
5490
|
file: null,
|
|
5494
5491
|
readError: r
|
|
5495
5492
|
};
|
|
5496
5493
|
}
|
|
5497
|
-
var
|
|
5494
|
+
var kr = {
|
|
5498
5495
|
image: "image",
|
|
5499
5496
|
videoEmbed: "video",
|
|
5500
5497
|
audioEmbed: "audio",
|
|
5501
5498
|
attachmentEmbed: "attachment"
|
|
5502
5499
|
};
|
|
5503
|
-
function
|
|
5500
|
+
function Ar(e, t) {
|
|
5504
5501
|
let n = /* @__PURE__ */ new Set(), r = [];
|
|
5505
5502
|
return e.descendants((e) => {
|
|
5506
|
-
let i =
|
|
5503
|
+
let i = kr[e.type?.name];
|
|
5507
5504
|
if (i) {
|
|
5508
5505
|
let a = e.attrs?.src, o = `node:${a}`;
|
|
5509
|
-
typeof a == "string" &&
|
|
5506
|
+
typeof a == "string" && vr(a) && !n.has(o) && !t?.(a) && (n.add(o), r.push({
|
|
5510
5507
|
src: a,
|
|
5511
|
-
normalized:
|
|
5512
|
-
basename:
|
|
5508
|
+
normalized: br(a),
|
|
5509
|
+
basename: xr(a),
|
|
5513
5510
|
kind: i,
|
|
5514
5511
|
isLink: !1
|
|
5515
5512
|
}));
|
|
@@ -5518,17 +5515,17 @@ function kr(e, t) {
|
|
|
5518
5515
|
if (e.isText && e.marks) for (let i of e.marks) {
|
|
5519
5516
|
if (i.type.name !== "link") continue;
|
|
5520
5517
|
let e = i.attrs?.href, a = `link:${e}`;
|
|
5521
|
-
typeof e == "string" &&
|
|
5518
|
+
typeof e == "string" && vr(e) && yr(e) && !n.has(a) && !t?.(e) && (n.add(a), r.push({
|
|
5522
5519
|
src: e,
|
|
5523
|
-
normalized:
|
|
5524
|
-
basename:
|
|
5520
|
+
normalized: br(e),
|
|
5521
|
+
basename: xr(e),
|
|
5525
5522
|
kind: "attachment",
|
|
5526
5523
|
isLink: !0
|
|
5527
5524
|
}));
|
|
5528
5525
|
}
|
|
5529
5526
|
}), r;
|
|
5530
5527
|
}
|
|
5531
|
-
function
|
|
5528
|
+
function jr(e, t, n) {
|
|
5532
5529
|
let r = t ? `${e}\n${t}` : e;
|
|
5533
5530
|
if (!r) return !1;
|
|
5534
5531
|
let i = [];
|
|
@@ -5536,28 +5533,28 @@ function Ar(e, t, n) {
|
|
|
5536
5533
|
for (let e of r.matchAll(/!?\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g)) i.push(e[1]);
|
|
5537
5534
|
for (let e of r.matchAll(/<(?:img|video|audio|source)[^>]*\bsrc=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5538
5535
|
for (let e of r.matchAll(/<a[^>]*\bhref=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5539
|
-
return i.some((e) =>
|
|
5536
|
+
return i.some((e) => yr(e) && vr(e) && !n?.(e));
|
|
5540
5537
|
}
|
|
5541
5538
|
//#endregion
|
|
5542
5539
|
//#region src/editor/extensions/image-upload.ts
|
|
5543
|
-
function
|
|
5540
|
+
function Mr(e) {
|
|
5544
5541
|
if (e.type.startsWith("image/")) return "image";
|
|
5545
5542
|
if (e.type.startsWith("video/")) return "video";
|
|
5546
5543
|
if (e.type.startsWith("audio/")) return "audio";
|
|
5547
5544
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5548
5545
|
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";
|
|
5549
5546
|
}
|
|
5550
|
-
function
|
|
5547
|
+
function Nr(e) {
|
|
5551
5548
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5552
5549
|
return t === "md" || t === "markdown";
|
|
5553
5550
|
}
|
|
5554
|
-
async function
|
|
5555
|
-
let i = n ?? e.state.selection.from, a = r ?
|
|
5556
|
-
o?.chooseMd ? o.chooseMd(t.name, e) :
|
|
5551
|
+
async function Pr(e, t, n, r) {
|
|
5552
|
+
let i = n ?? e.state.selection.from, a = r ? mn(r) : void 0, o = r?.storage?.qingwuUI, s = await new Promise((e) => {
|
|
5553
|
+
o?.chooseMd ? o.chooseMd(t.name, e) : hr(t.name).then(e);
|
|
5557
5554
|
});
|
|
5558
5555
|
if (s === null) return;
|
|
5559
5556
|
if (s === "attach") {
|
|
5560
|
-
let n = a ?
|
|
5557
|
+
let n = a ? hn(e.state.doc, t, a) : null;
|
|
5561
5558
|
if (n) {
|
|
5562
5559
|
Z(n);
|
|
5563
5560
|
return;
|
|
@@ -5588,8 +5585,8 @@ async function Nr(e, t, n, r) {
|
|
|
5588
5585
|
e.dispatch(e.state.tr.insert(i, t.from(u)));
|
|
5589
5586
|
}
|
|
5590
5587
|
}
|
|
5591
|
-
function
|
|
5592
|
-
switch (
|
|
5588
|
+
function Fr(e, t, n) {
|
|
5589
|
+
switch (Mr(t)) {
|
|
5593
5590
|
case "image": return e.nodes.image?.create({
|
|
5594
5591
|
src: n,
|
|
5595
5592
|
alt: t.name
|
|
@@ -5615,7 +5612,7 @@ function Pr(e, t, n) {
|
|
|
5615
5612
|
}
|
|
5616
5613
|
}
|
|
5617
5614
|
}
|
|
5618
|
-
async function
|
|
5615
|
+
async function Ir(e, t, n) {
|
|
5619
5616
|
let r;
|
|
5620
5617
|
try {
|
|
5621
5618
|
r = o();
|
|
@@ -5634,13 +5631,13 @@ async function Fr(e, t, n) {
|
|
|
5634
5631
|
return console.error(`${t.type} upload failed:`, e), URL.revokeObjectURL(n), null;
|
|
5635
5632
|
}
|
|
5636
5633
|
}
|
|
5637
|
-
async function
|
|
5638
|
-
let i = r ?
|
|
5634
|
+
async function Lr(e, t, n, r) {
|
|
5635
|
+
let i = r ? mn(r) : void 0, a = i ? hn(e.state.doc, t, i) : null;
|
|
5639
5636
|
if (a) {
|
|
5640
5637
|
Z(a);
|
|
5641
5638
|
return;
|
|
5642
5639
|
}
|
|
5643
|
-
let o = URL.createObjectURL(t), s =
|
|
5640
|
+
let o = URL.createObjectURL(t), s = Fr(e.state.schema, t, o);
|
|
5644
5641
|
if (!s) return;
|
|
5645
5642
|
let c = n ?? e.state.selection.from;
|
|
5646
5643
|
try {
|
|
@@ -5648,9 +5645,9 @@ async function Ir(e, t, n, r) {
|
|
|
5648
5645
|
} catch {
|
|
5649
5646
|
return;
|
|
5650
5647
|
}
|
|
5651
|
-
await
|
|
5648
|
+
await Ir(e, t, o);
|
|
5652
5649
|
}
|
|
5653
|
-
var
|
|
5650
|
+
var Rr = L.create({
|
|
5654
5651
|
name: "imageUpload",
|
|
5655
5652
|
addOptions() {
|
|
5656
5653
|
return {
|
|
@@ -5660,8 +5657,8 @@ var Lr = R.create({
|
|
|
5660
5657
|
},
|
|
5661
5658
|
addProseMirrorPlugins() {
|
|
5662
5659
|
let e = this.editor;
|
|
5663
|
-
return [new
|
|
5664
|
-
key: new
|
|
5660
|
+
return [new B({
|
|
5661
|
+
key: new V("imageUpload"),
|
|
5665
5662
|
props: {
|
|
5666
5663
|
handleDrop(t, n) {
|
|
5667
5664
|
let r = n.dataTransfer?.files;
|
|
@@ -5671,23 +5668,23 @@ var Lr = R.create({
|
|
|
5671
5668
|
left: n.clientX,
|
|
5672
5669
|
top: n.clientY
|
|
5673
5670
|
});
|
|
5674
|
-
for (let n of Array.from(r))
|
|
5671
|
+
for (let n of Array.from(r)) Nr(n) ? Pr(t, n, i?.pos, e) : Lr(t, n, i?.pos, e);
|
|
5675
5672
|
return !0;
|
|
5676
5673
|
},
|
|
5677
5674
|
handlePaste(t, n) {
|
|
5678
5675
|
let r = n.clipboardData?.items;
|
|
5679
5676
|
if (!r) return !1;
|
|
5680
5677
|
let i = n.clipboardData?.getData("text/plain") || "";
|
|
5681
|
-
if ((n.clipboardData?.files?.length ?? 0) > 0 &&
|
|
5678
|
+
if ((n.clipboardData?.files?.length ?? 0) > 0 && jr(i, void 0, a())) return !1;
|
|
5682
5679
|
for (let i of Array.from(r)) {
|
|
5683
5680
|
if (i.type.startsWith("image/") || i.type.startsWith("video/") || i.type.startsWith("audio/")) {
|
|
5684
5681
|
n.preventDefault();
|
|
5685
5682
|
let r = i.getAsFile();
|
|
5686
|
-
return r &&
|
|
5683
|
+
return r && Mr(r) !== "file" && Lr(t, r, void 0, e), !0;
|
|
5687
5684
|
}
|
|
5688
5685
|
if (i.kind === "file") {
|
|
5689
5686
|
let r = i.getAsFile();
|
|
5690
|
-
if (r &&
|
|
5687
|
+
if (r && Nr(r)) return n.preventDefault(), Pr(t, r, void 0, e), !0;
|
|
5691
5688
|
}
|
|
5692
5689
|
}
|
|
5693
5690
|
return !1;
|
|
@@ -5695,12 +5692,12 @@ var Lr = R.create({
|
|
|
5695
5692
|
}
|
|
5696
5693
|
})];
|
|
5697
5694
|
}
|
|
5698
|
-
}),
|
|
5695
|
+
}), zr = 100, Br = L.create({
|
|
5699
5696
|
name: "imeCommitSpaceGuard",
|
|
5700
5697
|
addProseMirrorPlugins() {
|
|
5701
5698
|
let e = 0;
|
|
5702
|
-
return [new
|
|
5703
|
-
key: new
|
|
5699
|
+
return [new B({
|
|
5700
|
+
key: new V("imeCommitSpaceGuard"),
|
|
5704
5701
|
props: { handleDOMEvents: {
|
|
5705
5702
|
compositionend() {
|
|
5706
5703
|
return e = performance.now(), !1;
|
|
@@ -5710,16 +5707,16 @@ var Lr = R.create({
|
|
|
5710
5707
|
},
|
|
5711
5708
|
beforeinput(t, n) {
|
|
5712
5709
|
let r = n;
|
|
5713
|
-
return r.inputType !== "insertText" || r.data !== " " || r.isComposing || performance.now() - e >
|
|
5710
|
+
return r.inputType !== "insertText" || r.data !== " " || r.isComposing || performance.now() - e > zr ? !1 : (r.preventDefault(), !0);
|
|
5714
5711
|
}
|
|
5715
5712
|
} }
|
|
5716
5713
|
})];
|
|
5717
5714
|
}
|
|
5718
|
-
}),
|
|
5715
|
+
}), Vr = L.create({
|
|
5719
5716
|
name: "inlineCodeEnd",
|
|
5720
5717
|
addInputRules() {
|
|
5721
5718
|
let e = this.editor.schema.marks.code;
|
|
5722
|
-
return e ? [
|
|
5719
|
+
return e ? [R({
|
|
5723
5720
|
find: /`([^`]+)`$/,
|
|
5724
5721
|
type: e
|
|
5725
5722
|
})] : [];
|
|
@@ -5727,17 +5724,17 @@ var Lr = R.create({
|
|
|
5727
5724
|
});
|
|
5728
5725
|
//#endregion
|
|
5729
5726
|
//#region src/editor/extensions/math-utils.ts
|
|
5730
|
-
function
|
|
5727
|
+
function Hr(e) {
|
|
5731
5728
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">").replace(/\n/g, " ");
|
|
5732
5729
|
}
|
|
5733
|
-
function
|
|
5730
|
+
function Ur(e) {
|
|
5734
5731
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
5735
5732
|
}
|
|
5736
|
-
function
|
|
5733
|
+
function Wr(e, t) {
|
|
5737
5734
|
let n = e ?? "";
|
|
5738
5735
|
if (!n.trim()) return "";
|
|
5739
5736
|
try {
|
|
5740
|
-
return
|
|
5737
|
+
return we.renderToString(n, {
|
|
5741
5738
|
displayMode: t,
|
|
5742
5739
|
throwOnError: !1,
|
|
5743
5740
|
strict: "ignore",
|
|
@@ -5745,59 +5742,72 @@ function Ur(e, t) {
|
|
|
5745
5742
|
output: "htmlAndMathml"
|
|
5746
5743
|
});
|
|
5747
5744
|
} catch {
|
|
5748
|
-
return `<span class="math-fallback">${
|
|
5745
|
+
return `<span class="math-fallback">${Ur(n)}</span>`;
|
|
5749
5746
|
}
|
|
5750
5747
|
}
|
|
5751
5748
|
//#endregion
|
|
5752
5749
|
//#region src/editor/extensions/math-view.tsx
|
|
5753
|
-
function
|
|
5754
|
-
let
|
|
5755
|
-
let e =
|
|
5750
|
+
function Gr({ node: e, updateAttributes: t, deleteNode: n, editor: r, getPos: i, selected: a }) {
|
|
5751
|
+
let o = e.type.name === "mathBlock", s = String(e.attrs.latex ?? ""), c = r?.isEditable ?? !0, [l, u] = T(!1), [d, p] = T(s), m = w(null), h = w(!1), g = w(() => {}), _ = w(() => {}), v = C(() => Wr(s, o), [s, o]), y = C(() => Wr(d, o), [d, o]), b = () => {
|
|
5752
|
+
let e = d.trim();
|
|
5756
5753
|
if (!e) {
|
|
5757
|
-
|
|
5754
|
+
u(!1), c && n?.();
|
|
5758
5755
|
return;
|
|
5759
5756
|
}
|
|
5760
|
-
t({ latex: e }),
|
|
5761
|
-
},
|
|
5762
|
-
|
|
5757
|
+
t({ latex: e }), u(!1);
|
|
5758
|
+
}, S = () => {
|
|
5759
|
+
u(!1), !s && c && n?.();
|
|
5763
5760
|
};
|
|
5764
|
-
|
|
5765
|
-
!
|
|
5766
|
-
}, [
|
|
5767
|
-
if (!
|
|
5768
|
-
|
|
5761
|
+
g.current = b, _.current = S, x(() => {
|
|
5762
|
+
!c || h.current || (h.current = !0, s || u(!0));
|
|
5763
|
+
}, [c, s]), x(() => {
|
|
5764
|
+
if (!l) return;
|
|
5765
|
+
p(s);
|
|
5769
5766
|
let e = window.setTimeout(() => {
|
|
5770
|
-
|
|
5767
|
+
m.current?.focus(), m.current?.select();
|
|
5771
5768
|
}, 30), t = (e) => {
|
|
5772
|
-
e.key === "Escape" ? (e.preventDefault(),
|
|
5769
|
+
e.key === "Escape" ? (e.preventDefault(), _.current()) : (e.metaKey || e.ctrlKey) && e.key === "Enter" && (e.preventDefault(), g.current());
|
|
5773
5770
|
};
|
|
5774
5771
|
return window.addEventListener("keydown", t, !0), () => {
|
|
5775
5772
|
window.clearTimeout(e), window.removeEventListener("keydown", t, !0);
|
|
5776
5773
|
};
|
|
5777
|
-
}, [
|
|
5778
|
-
let
|
|
5779
|
-
|
|
5774
|
+
}, [l, s]);
|
|
5775
|
+
let k = () => {
|
|
5776
|
+
c && u(!0);
|
|
5777
|
+
}, A = (t) => {
|
|
5778
|
+
if (!r || typeof i != "function") return;
|
|
5779
|
+
let n = i();
|
|
5780
|
+
if (n === void 0) return;
|
|
5781
|
+
let a = t.currentTarget.getBoundingClientRect(), o = t.clientX - a.left < a.width / 2 ? "before" : "after", s = o === "before" ? n : n + e.nodeSize, { state: c, view: l } = r, u = oe.near(c.doc.resolve(s), o === "before" ? -1 : 1);
|
|
5782
|
+
l.dispatch(c.tr.setSelection(u)), l.focus();
|
|
5780
5783
|
};
|
|
5781
5784
|
return /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D(P, {
|
|
5782
|
-
as:
|
|
5783
|
-
className: `math-node ${
|
|
5785
|
+
as: o ? "div" : "span",
|
|
5786
|
+
className: `math-node ${o ? "math-node--block" : "math-node--inline"}${a ? " is-selected" : ""}`,
|
|
5784
5787
|
contentEditable: !1,
|
|
5788
|
+
title: c && !o ? f("editor.math.inlineClickHint") : void 0,
|
|
5785
5789
|
onMouseDown: (e) => {
|
|
5786
|
-
|
|
5790
|
+
c && o && e.preventDefault();
|
|
5787
5791
|
},
|
|
5788
5792
|
onClick: (e) => {
|
|
5789
|
-
|
|
5793
|
+
if (c) {
|
|
5794
|
+
if (e.preventDefault(), e.stopPropagation(), o) {
|
|
5795
|
+
k();
|
|
5796
|
+
return;
|
|
5797
|
+
}
|
|
5798
|
+
e.detail >= 2 ? k() : A(e);
|
|
5799
|
+
}
|
|
5790
5800
|
},
|
|
5791
|
-
children:
|
|
5801
|
+
children: s ? /* @__PURE__ */ D("span", {
|
|
5792
5802
|
className: "math-render",
|
|
5793
|
-
dangerouslySetInnerHTML: { __html:
|
|
5803
|
+
dangerouslySetInnerHTML: { __html: v }
|
|
5794
5804
|
}) : /* @__PURE__ */ D("span", {
|
|
5795
5805
|
className: "math-placeholder",
|
|
5796
5806
|
children: f("editor.math.empty")
|
|
5797
5807
|
})
|
|
5798
|
-
}),
|
|
5808
|
+
}), l && re(/* @__PURE__ */ D("div", {
|
|
5799
5809
|
className: "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none",
|
|
5800
|
-
onClick:
|
|
5810
|
+
onClick: S,
|
|
5801
5811
|
onMouseDown: (e) => e.preventDefault(),
|
|
5802
5812
|
children: /* @__PURE__ */ O("div", {
|
|
5803
5813
|
className: "w-full max-w-lg mx-4 rounded-xl border border-default-200 dark:border-zinc-700 bg-white dark:bg-zinc-800 p-5 shadow-xl",
|
|
@@ -5805,20 +5815,20 @@ function Wr({ node: e, updateAttributes: t, deleteNode: n, editor: r, selected:
|
|
|
5805
5815
|
children: [
|
|
5806
5816
|
/* @__PURE__ */ D("div", {
|
|
5807
5817
|
className: "mb-3 text-sm font-medium text-default-800 dark:text-zinc-100",
|
|
5808
|
-
children: f(
|
|
5818
|
+
children: f(o ? "editor.math.blockTitle" : "editor.math.inlineTitle")
|
|
5809
5819
|
}),
|
|
5810
5820
|
/* @__PURE__ */ D("textarea", {
|
|
5811
|
-
ref:
|
|
5812
|
-
value:
|
|
5813
|
-
onChange: (e) =>
|
|
5814
|
-
rows:
|
|
5821
|
+
ref: m,
|
|
5822
|
+
value: d,
|
|
5823
|
+
onChange: (e) => p(e.target.value),
|
|
5824
|
+
rows: o ? 5 : 2,
|
|
5815
5825
|
spellCheck: !1,
|
|
5816
5826
|
placeholder: f("editor.math.placeholder"),
|
|
5817
5827
|
className: "w-full resize-y rounded-lg border border-default-200 dark:border-zinc-700 bg-default-50 dark:bg-zinc-900 px-3 py-2 font-mono text-sm text-default-800 dark:text-zinc-100 outline-none focus:ring-2 focus:ring-qingwu-500/40"
|
|
5818
5828
|
}),
|
|
5819
5829
|
/* @__PURE__ */ D("div", {
|
|
5820
5830
|
className: "math-dialog-preview",
|
|
5821
|
-
children:
|
|
5831
|
+
children: d.trim() ? /* @__PURE__ */ D("div", { dangerouslySetInnerHTML: { __html: y } }) : /* @__PURE__ */ D("span", {
|
|
5822
5832
|
className: "math-placeholder",
|
|
5823
5833
|
children: f("editor.math.emptyPreview")
|
|
5824
5834
|
})
|
|
@@ -5833,12 +5843,12 @@ function Wr({ node: e, updateAttributes: t, deleteNode: n, editor: r, selected:
|
|
|
5833
5843
|
children: [/* @__PURE__ */ D("button", {
|
|
5834
5844
|
type: "button",
|
|
5835
5845
|
className: "px-3 py-1.5 text-xs rounded-lg border border-default-200 dark:border-zinc-600 hover:bg-default-100 dark:hover:bg-zinc-700 transition-colors",
|
|
5836
|
-
onClick:
|
|
5846
|
+
onClick: S,
|
|
5837
5847
|
children: f("editor.math.cancel")
|
|
5838
5848
|
}), /* @__PURE__ */ D("button", {
|
|
5839
5849
|
type: "button",
|
|
5840
5850
|
className: "px-3 py-1.5 text-xs rounded-lg bg-qingwu-600 hover:bg-qingwu-700 text-white transition-colors",
|
|
5841
|
-
onClick:
|
|
5851
|
+
onClick: b,
|
|
5842
5852
|
children: f("editor.math.save")
|
|
5843
5853
|
})]
|
|
5844
5854
|
})]
|
|
@@ -5849,9 +5859,9 @@ function Wr({ node: e, updateAttributes: t, deleteNode: n, editor: r, selected:
|
|
|
5849
5859
|
}
|
|
5850
5860
|
//#endregion
|
|
5851
5861
|
//#region src/editor/extensions/math.ts
|
|
5852
|
-
var
|
|
5853
|
-
function
|
|
5854
|
-
return new
|
|
5862
|
+
var Kr = /(?:^|[^\\$])\$([^\s$](?:[^$\n]*[^\s$])?)\$$/, qr = /^\$\$([\s\S]+?)\$\$$/;
|
|
5863
|
+
function Jr(e) {
|
|
5864
|
+
return new B({ appendTransaction(t, n, r) {
|
|
5855
5865
|
if (!e.isEditable || e.view.composing || !t.some((e) => e.docChanged)) return null;
|
|
5856
5866
|
let i = r.schema.nodes.paragraph, a = r.schema.nodes.mathBlock;
|
|
5857
5867
|
if (!i || !a) return null;
|
|
@@ -5884,14 +5894,14 @@ function qr(e) {
|
|
|
5884
5894
|
let t = a.create({ latex: e.latex });
|
|
5885
5895
|
c.replaceWith(e.from, e.to, t);
|
|
5886
5896
|
let n = e.from + t.nodeSize, r = c.doc.resolve(n);
|
|
5887
|
-
(!r.nodeAfter || !r.nodeAfter.isTextblock) && c.insert(n, i.create()), c.setSelection(
|
|
5897
|
+
(!r.nodeAfter || !r.nodeAfter.isTextblock) && c.insert(n, i.create()), c.setSelection(oe.near(c.doc.resolve(n), 1));
|
|
5888
5898
|
}
|
|
5889
5899
|
return c;
|
|
5890
5900
|
} });
|
|
5891
5901
|
}
|
|
5892
|
-
function
|
|
5893
|
-
return new
|
|
5894
|
-
find:
|
|
5902
|
+
function Yr(e) {
|
|
5903
|
+
return new ie({
|
|
5904
|
+
find: Kr,
|
|
5895
5905
|
handler: ({ state: t, range: n, match: r }) => {
|
|
5896
5906
|
let i = r[1], a = r[0].indexOf("$");
|
|
5897
5907
|
if (a < 0) return;
|
|
@@ -5900,18 +5910,18 @@ function Jr(e) {
|
|
|
5900
5910
|
}
|
|
5901
5911
|
});
|
|
5902
5912
|
}
|
|
5903
|
-
function
|
|
5904
|
-
return new
|
|
5905
|
-
find:
|
|
5913
|
+
function Xr(e) {
|
|
5914
|
+
return new ie({
|
|
5915
|
+
find: qr,
|
|
5906
5916
|
handler: ({ state: t, range: n, match: r }) => {
|
|
5907
5917
|
let i = r[1].trim();
|
|
5908
5918
|
if (!i) return;
|
|
5909
5919
|
let a = t.doc.resolve(n.from), o = a.depth, s = a.before(o), c = a.after(o), l = e.create({ latex: i }), u = t.tr.replaceWith(s, c, l), d = s + l.nodeSize, f = u.doc.resolve(d);
|
|
5910
|
-
(!f.nodeAfter || !f.nodeAfter.isTextblock) && u.insert(d, t.schema.nodes.paragraph.create()), u.setSelection(
|
|
5920
|
+
(!f.nodeAfter || !f.nodeAfter.isTextblock) && u.insert(d, t.schema.nodes.paragraph.create()), u.setSelection(oe.near(u.doc.resolve(d), 1));
|
|
5911
5921
|
}
|
|
5912
5922
|
});
|
|
5913
5923
|
}
|
|
5914
|
-
function
|
|
5924
|
+
function Zr(e, t) {
|
|
5915
5925
|
let n = e.src, r = e.pos;
|
|
5916
5926
|
if (n.charCodeAt(r) !== 36 || n.charCodeAt(r + 1) === 36) return !1;
|
|
5917
5927
|
let i = r + 1;
|
|
@@ -5926,11 +5936,11 @@ function Xr(e, t) {
|
|
|
5926
5936
|
if (!a || /^\s|\s$/.test(a)) return !1;
|
|
5927
5937
|
if (!t) {
|
|
5928
5938
|
let t = e.push("html_inline", "", 0);
|
|
5929
|
-
t.content = `<span data-type="inline-math" data-latex="${
|
|
5939
|
+
t.content = `<span data-type="inline-math" data-latex="${Hr(a)}"></span>`;
|
|
5930
5940
|
}
|
|
5931
5941
|
return e.pos = i + 1, !0;
|
|
5932
5942
|
}
|
|
5933
|
-
function
|
|
5943
|
+
function Qr(e, t, n, r) {
|
|
5934
5944
|
let i = e.bMarks[t] + e.tShift[t], a = e.eMarks[t];
|
|
5935
5945
|
if (i + 1 >= a || e.src.charCodeAt(i) !== 36 || e.src.charCodeAt(i + 1) !== 36) return !1;
|
|
5936
5946
|
let o = e.src.slice(i, a).trim(), s = "", c = t + 1;
|
|
@@ -5953,12 +5963,12 @@ function Zr(e, t, n, r) {
|
|
|
5953
5963
|
}
|
|
5954
5964
|
if (r) return !0;
|
|
5955
5965
|
let l = e.push("html_block", "", 0);
|
|
5956
|
-
return l.content = `<div data-type="block-math" data-latex="${
|
|
5957
|
-
}
|
|
5958
|
-
function Qr(e) {
|
|
5959
|
-
e.__qingwuMathReg || (e.__qingwuMathReg = !0, e.inline.ruler.before("backticks", "qingwu_math_inline", Xr), e.block.ruler.before("fence", "qingwu_math_block", Zr, { alt: ["paragraph"] }));
|
|
5966
|
+
return l.content = `<div data-type="block-math" data-latex="${Hr(s.trim())}"></div>\n`, e.line = c, !0;
|
|
5960
5967
|
}
|
|
5961
5968
|
function $r(e) {
|
|
5969
|
+
e.__qingwuMathReg || (e.__qingwuMathReg = !0, e.inline.ruler.before("backticks", "qingwu_math_inline", Zr), e.block.ruler.before("fence", "qingwu_math_block", Qr, { alt: ["paragraph"] }));
|
|
5970
|
+
}
|
|
5971
|
+
function ei(e) {
|
|
5962
5972
|
return { markdown: {
|
|
5963
5973
|
serialize(t, n) {
|
|
5964
5974
|
let r = String(n.attrs.latex ?? "");
|
|
@@ -5971,11 +5981,11 @@ function $r(e) {
|
|
|
5971
5981
|
t.write("$$"), t.closeBlock(n);
|
|
5972
5982
|
},
|
|
5973
5983
|
parse: { setup(e) {
|
|
5974
|
-
|
|
5984
|
+
$r(e);
|
|
5975
5985
|
} }
|
|
5976
5986
|
} };
|
|
5977
5987
|
}
|
|
5978
|
-
var
|
|
5988
|
+
var ti = ae.create({
|
|
5979
5989
|
name: "mathInline",
|
|
5980
5990
|
group: "inline",
|
|
5981
5991
|
inline: !0,
|
|
@@ -6003,18 +6013,18 @@ var ei = ie.create({
|
|
|
6003
6013
|
];
|
|
6004
6014
|
let r = document.createElement("span");
|
|
6005
6015
|
for (let [e, t] of Object.entries(n)) r.setAttribute(e, t);
|
|
6006
|
-
return r.innerHTML =
|
|
6016
|
+
return r.innerHTML = Wr(t, !1), r;
|
|
6007
6017
|
},
|
|
6008
6018
|
addNodeView() {
|
|
6009
|
-
return F(
|
|
6019
|
+
return F(Gr);
|
|
6010
6020
|
},
|
|
6011
6021
|
addInputRules() {
|
|
6012
|
-
return [
|
|
6022
|
+
return [Yr(this.type)];
|
|
6013
6023
|
},
|
|
6014
6024
|
addStorage() {
|
|
6015
|
-
return
|
|
6025
|
+
return ei(!1);
|
|
6016
6026
|
}
|
|
6017
|
-
}),
|
|
6027
|
+
}), ni = ae.create({
|
|
6018
6028
|
name: "mathBlock",
|
|
6019
6029
|
group: "block",
|
|
6020
6030
|
atom: !0,
|
|
@@ -6041,39 +6051,39 @@ var ei = ie.create({
|
|
|
6041
6051
|
];
|
|
6042
6052
|
let r = document.createElement("div");
|
|
6043
6053
|
for (let [e, t] of Object.entries(n)) r.setAttribute(e, t);
|
|
6044
|
-
return r.innerHTML =
|
|
6054
|
+
return r.innerHTML = Wr(t, !0), r;
|
|
6045
6055
|
},
|
|
6046
6056
|
addNodeView() {
|
|
6047
|
-
return F(
|
|
6057
|
+
return F(Gr);
|
|
6048
6058
|
},
|
|
6049
6059
|
addInputRules() {
|
|
6050
|
-
return [
|
|
6060
|
+
return [Xr(this.type)];
|
|
6051
6061
|
},
|
|
6052
6062
|
addProseMirrorPlugins() {
|
|
6053
|
-
return [
|
|
6063
|
+
return [Jr(this.editor)];
|
|
6054
6064
|
},
|
|
6055
6065
|
addStorage() {
|
|
6056
|
-
return
|
|
6066
|
+
return ei(!0);
|
|
6057
6067
|
}
|
|
6058
|
-
}),
|
|
6059
|
-
function
|
|
6068
|
+
}), ri = /\.(png|jpe?g|gif|webp|bmp|svg|avif)(\?|#|$)/i, ii = /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|#|$)/i, ai = /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|#|$)/i;
|
|
6069
|
+
function oi(e) {
|
|
6060
6070
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
6061
6071
|
}
|
|
6062
|
-
function
|
|
6072
|
+
function si(e) {
|
|
6063
6073
|
let t = e.trim().replace(/\\/g, "/");
|
|
6064
6074
|
return t.split("/").pop() || t;
|
|
6065
6075
|
}
|
|
6066
|
-
function
|
|
6076
|
+
function ci(e, t) {
|
|
6067
6077
|
let n = e.src.slice(e.pos), r = /^!\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !0;
|
|
6068
6078
|
if (r || (r = /^\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !1), !r) return !1;
|
|
6069
6079
|
let a = r[1].trim(), o = r[2]?.trim();
|
|
6070
6080
|
if (!t) {
|
|
6071
|
-
let t = o ||
|
|
6081
|
+
let t = o || si(a);
|
|
6072
6082
|
if (i) {
|
|
6073
6083
|
let n = "";
|
|
6074
|
-
if (
|
|
6075
|
-
else if (
|
|
6076
|
-
else if (
|
|
6084
|
+
if (ri.test(a) || /^data:image\//i.test(a)) n = `<img src="${oi(a)}" alt="${oi(t)}">`;
|
|
6085
|
+
else if (ii.test(a) || /^data:video\//i.test(a)) n = `<div data-video-embed src="${oi(a)}"></div>`;
|
|
6086
|
+
else if (ai.test(a) || /^data:audio\//i.test(a)) n = `<audio src="${oi(a)}"></audio>`;
|
|
6077
6087
|
else {
|
|
6078
6088
|
let n = e.push("link_open", "a", 1);
|
|
6079
6089
|
n.attrs = [["href", a]];
|
|
@@ -6091,14 +6101,14 @@ function si(e, t) {
|
|
|
6091
6101
|
}
|
|
6092
6102
|
return e.pos += r[0].length, !0;
|
|
6093
6103
|
}
|
|
6094
|
-
var
|
|
6104
|
+
var li = L.create({
|
|
6095
6105
|
name: "obsidianMarkdown",
|
|
6096
6106
|
addStorage() {
|
|
6097
6107
|
return { markdown: { parse: { setup(e) {
|
|
6098
|
-
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed",
|
|
6108
|
+
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed", ci));
|
|
6099
6109
|
} } } };
|
|
6100
6110
|
}
|
|
6101
|
-
}),
|
|
6111
|
+
}), ui = L.create({
|
|
6102
6112
|
name: "qingwuUI",
|
|
6103
6113
|
addStorage() {
|
|
6104
6114
|
return {};
|
|
@@ -6106,7 +6116,7 @@ var ci = R.create({
|
|
|
6106
6116
|
});
|
|
6107
6117
|
//#endregion
|
|
6108
6118
|
//#region src/editor/utils/render-probe.ts
|
|
6109
|
-
function
|
|
6119
|
+
function di(e, t) {
|
|
6110
6120
|
return new Promise((n) => {
|
|
6111
6121
|
if (typeof Image != "function") return n(!0);
|
|
6112
6122
|
let r = new Image(), i = !1, a = setTimeout(() => o(!1), t), o = (e) => {
|
|
@@ -6115,14 +6125,14 @@ function ui(e, t) {
|
|
|
6115
6125
|
r.onload = () => o(!0), r.onerror = () => o(!1), r.src = e;
|
|
6116
6126
|
});
|
|
6117
6127
|
}
|
|
6118
|
-
async function
|
|
6119
|
-
if (await
|
|
6128
|
+
async function fi(e, t = 8e3) {
|
|
6129
|
+
if (await di(e, t)) return !0;
|
|
6120
6130
|
try {
|
|
6121
6131
|
let r = await n(e);
|
|
6122
6132
|
if (!r) return !1;
|
|
6123
6133
|
let i = await fetch(e, { headers: r });
|
|
6124
6134
|
if (!i.ok) return !1;
|
|
6125
|
-
let a = URL.createObjectURL(await i.blob()), o = await
|
|
6135
|
+
let a = URL.createObjectURL(await i.blob()), o = await di(a, t);
|
|
6126
6136
|
return URL.revokeObjectURL(a), o;
|
|
6127
6137
|
} catch {
|
|
6128
6138
|
return !1;
|
|
@@ -6130,7 +6140,7 @@ async function di(e, t = 8e3) {
|
|
|
6130
6140
|
}
|
|
6131
6141
|
//#endregion
|
|
6132
6142
|
//#region src/editor/utils/resolve-local-media.ts
|
|
6133
|
-
function
|
|
6143
|
+
function pi() {
|
|
6134
6144
|
return {
|
|
6135
6145
|
uploaded: 0,
|
|
6136
6146
|
sessionOnly: 0,
|
|
@@ -6140,10 +6150,10 @@ function fi() {
|
|
|
6140
6150
|
readFailed: []
|
|
6141
6151
|
};
|
|
6142
6152
|
}
|
|
6143
|
-
function
|
|
6153
|
+
function mi(e, t) {
|
|
6144
6154
|
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);
|
|
6145
6155
|
}
|
|
6146
|
-
function
|
|
6156
|
+
function hi(e, t, n, r) {
|
|
6147
6157
|
let { state: i } = e, a = [];
|
|
6148
6158
|
if (i.doc.descendants((e, n) => {
|
|
6149
6159
|
e.attrs?.src === t && a.push(n);
|
|
@@ -6159,7 +6169,7 @@ function mi(e, t, n, r) {
|
|
|
6159
6169
|
}
|
|
6160
6170
|
return e.dispatch(o), !0;
|
|
6161
6171
|
}
|
|
6162
|
-
function
|
|
6172
|
+
function gi(e, t, n) {
|
|
6163
6173
|
let { state: r } = e, i = r.schema.marks.link;
|
|
6164
6174
|
if (!i) return !1;
|
|
6165
6175
|
let a = [];
|
|
@@ -6177,7 +6187,7 @@ function hi(e, t, n) {
|
|
|
6177
6187
|
}));
|
|
6178
6188
|
return e.dispatch(o), !0;
|
|
6179
6189
|
}
|
|
6180
|
-
function
|
|
6190
|
+
function _i(e) {
|
|
6181
6191
|
let t = /* @__PURE__ */ new Map();
|
|
6182
6192
|
for (let n of e) {
|
|
6183
6193
|
let e = t.get(n.normalized);
|
|
@@ -6185,36 +6195,36 @@ function gi(e) {
|
|
|
6185
6195
|
}
|
|
6186
6196
|
return Array.from(t.values());
|
|
6187
6197
|
}
|
|
6188
|
-
async function
|
|
6198
|
+
async function vi(e, t, n, r) {
|
|
6189
6199
|
if (n.length === 0) return "sessionOnly";
|
|
6190
|
-
let i = n[0], a =
|
|
6200
|
+
let i = n[0], a = mn(t);
|
|
6191
6201
|
if (a) {
|
|
6192
|
-
let t =
|
|
6202
|
+
let t = hn(e.state.doc, r, a);
|
|
6193
6203
|
if (t) return Z(`${i.basename}:${t}`, "error"), "limitRejected";
|
|
6194
6204
|
}
|
|
6195
6205
|
let s = n.filter((e) => !e.isLink), c = n.filter((e) => e.isLink);
|
|
6196
6206
|
if (s.length === 0) try {
|
|
6197
6207
|
let t = await o().upload(r, "editor"), n = !1;
|
|
6198
|
-
for (let r of c)
|
|
6208
|
+
for (let r of c) gi(e, r.src, t) && (n = !0);
|
|
6199
6209
|
return n ? "uploaded" : "sessionOnly";
|
|
6200
6210
|
} catch (e) {
|
|
6201
6211
|
return console.error(`本地附件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), "sessionOnly";
|
|
6202
6212
|
}
|
|
6203
6213
|
let l = URL.createObjectURL(r), u = !1;
|
|
6204
|
-
for (let t of s)
|
|
6214
|
+
for (let t of s) hi(e, t.src, l, r.size) && (u = !0);
|
|
6205
6215
|
let d;
|
|
6206
6216
|
try {
|
|
6207
6217
|
d = await o().upload(r, "editor");
|
|
6208
6218
|
} catch (e) {
|
|
6209
6219
|
return console.error(`本地文件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), URL.revokeObjectURL(l), "sessionOnly";
|
|
6210
6220
|
}
|
|
6211
|
-
URL.revokeObjectURL(l), u &&
|
|
6212
|
-
for (let t of c)
|
|
6213
|
-
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await
|
|
6221
|
+
URL.revokeObjectURL(l), u && hi(e, l, d, r.size);
|
|
6222
|
+
for (let t of c) gi(e, t.src, d);
|
|
6223
|
+
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await fi(d) ? "uploaded" : "renderFailed" : "uploaded";
|
|
6214
6224
|
}
|
|
6215
|
-
function
|
|
6225
|
+
function yi(e, t) {
|
|
6216
6226
|
let n = [], r = [];
|
|
6217
|
-
for (let i of
|
|
6227
|
+
for (let i of _i(e)) {
|
|
6218
6228
|
let e = i[0], a = t.get(e.basename);
|
|
6219
6229
|
a ? (n.push({
|
|
6220
6230
|
refs: i,
|
|
@@ -6226,30 +6236,30 @@ function vi(e, t) {
|
|
|
6226
6236
|
unmatched: r
|
|
6227
6237
|
};
|
|
6228
6238
|
}
|
|
6229
|
-
async function
|
|
6230
|
-
let i =
|
|
6231
|
-
for (let a of
|
|
6232
|
-
let n = a[0], { file: o, readError: s } = await
|
|
6239
|
+
async function bi(e, t, n, r) {
|
|
6240
|
+
let i = pi();
|
|
6241
|
+
for (let a of _i(n)) {
|
|
6242
|
+
let n = a[0], { file: o, readError: s } = await Or(r, n.src);
|
|
6233
6243
|
if (!o) {
|
|
6234
6244
|
s ? (console.warn(`本地文件「${n.basename}」在所选文件夹中找到但读取失败:`, s), i.readFailed.push(n)) : (console.warn(`本地文件「${n.basename}」未在所选文件夹「${r.name}」中找到`), i.missing.push(n));
|
|
6235
6245
|
continue;
|
|
6236
6246
|
}
|
|
6237
|
-
let c = await
|
|
6247
|
+
let c = await vi(e, t, a, o);
|
|
6238
6248
|
i[c]++;
|
|
6239
6249
|
}
|
|
6240
6250
|
return i;
|
|
6241
6251
|
}
|
|
6242
|
-
function
|
|
6252
|
+
function xi(e) {
|
|
6243
6253
|
let t = e.map((e) => e.basename);
|
|
6244
6254
|
return t.length <= 3 ? t.join("、") : `${t.slice(0, 3).join("、")} 等 ${t.length} 个文件`;
|
|
6245
6255
|
}
|
|
6246
|
-
function
|
|
6256
|
+
function Si(e) {
|
|
6247
6257
|
let t = [];
|
|
6248
|
-
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} 个找到但读取失败:${
|
|
6258
|
+
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} 个找到但读取失败:${xi(e.readFailed)}(若在 OneDrive / WPS 云盘等同步目录,请右键文件选择「始终保留在此设备」后重试)`), e.missing.length > 0 && t.push(`${e.missing.length} 个未能获取:${xi(e.missing)}(可把文件直接拖进编辑器上传)`), t.length === 0) return;
|
|
6249
6259
|
let n = e.uploaded > 0 && e.renderFailed === 0 && e.missing.length === 0 && e.readFailed.length === 0;
|
|
6250
6260
|
Z(`本地文件解析完成:${t.join(";")}`, n ? "success" : "info");
|
|
6251
6261
|
}
|
|
6252
|
-
function
|
|
6262
|
+
function Ci(e) {
|
|
6253
6263
|
return new Promise((t) => {
|
|
6254
6264
|
let n = document.createElement("div");
|
|
6255
6265
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -6276,7 +6286,7 @@ function Si(e) {
|
|
|
6276
6286
|
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);
|
|
6277
6287
|
});
|
|
6278
6288
|
}
|
|
6279
|
-
function
|
|
6289
|
+
function wi(e) {
|
|
6280
6290
|
let t = document.createElement("div");
|
|
6281
6291
|
t.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
6282
6292
|
let n = document.createElement("div");
|
|
@@ -6298,7 +6308,7 @@ function Ci(e) {
|
|
|
6298
6308
|
let c = document.createElement("button");
|
|
6299
6309
|
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);
|
|
6300
6310
|
}
|
|
6301
|
-
function
|
|
6311
|
+
function Ti(e) {
|
|
6302
6312
|
return new Promise((t) => {
|
|
6303
6313
|
let n = document.createElement("div");
|
|
6304
6314
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -6324,8 +6334,8 @@ function wi(e) {
|
|
|
6324
6334
|
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);
|
|
6325
6335
|
});
|
|
6326
6336
|
}
|
|
6327
|
-
async function
|
|
6328
|
-
let r =
|
|
6337
|
+
async function Ei(e, t, n) {
|
|
6338
|
+
let r = pi(), i = _i(n), a = await Tr();
|
|
6329
6339
|
if (!a) {
|
|
6330
6340
|
for (let e of i) r.missing.push(e[0]);
|
|
6331
6341
|
return r;
|
|
@@ -6338,14 +6348,14 @@ async function Ti(e, t, n) {
|
|
|
6338
6348
|
continue;
|
|
6339
6349
|
}
|
|
6340
6350
|
o.delete(i.basename);
|
|
6341
|
-
let s = await
|
|
6351
|
+
let s = await vi(e, t, n, a);
|
|
6342
6352
|
r[s]++;
|
|
6343
6353
|
}
|
|
6344
6354
|
return r;
|
|
6345
6355
|
}
|
|
6346
6356
|
//#endregion
|
|
6347
6357
|
//#region src/editor/extensions/relative-media.ts
|
|
6348
|
-
var
|
|
6358
|
+
var Di = L.create({
|
|
6349
6359
|
name: "relativeMedia",
|
|
6350
6360
|
addStorage() {
|
|
6351
6361
|
return {
|
|
@@ -6355,42 +6365,42 @@ var Ei = R.create({
|
|
|
6355
6365
|
},
|
|
6356
6366
|
addProseMirrorPlugins() {
|
|
6357
6367
|
let e = this.editor, t = this.storage, n = !1, r = null, i = async (n, i) => {
|
|
6358
|
-
let a = e.view, o =
|
|
6368
|
+
let a = e.view, o = pi(), { matched: s, unmatched: c } = yi(n, t.clipboardFiles);
|
|
6359
6369
|
for (let { refs: t, file: n } of s) {
|
|
6360
|
-
let r = await
|
|
6370
|
+
let r = await vi(a, e, t, n);
|
|
6361
6371
|
o[r]++;
|
|
6362
6372
|
}
|
|
6363
6373
|
if (c.length > 0) {
|
|
6364
|
-
let t =
|
|
6365
|
-
if (
|
|
6374
|
+
let t = _i(c).length;
|
|
6375
|
+
if (Sr()) {
|
|
6366
6376
|
let n = i ?? null;
|
|
6367
|
-
if (n || (await
|
|
6368
|
-
r = n,
|
|
6377
|
+
if (n || (await Ci(t) === "pick" ? (n = await Cr(), n || Z("没有选择文件夹。本地文件暂以占位显示,稍后可直接把文件拖进编辑器上传", "info")) : Z("已选择稍后处理。本地文件暂以占位显示,可直接把文件拖进编辑器上传", "info")), n) {
|
|
6378
|
+
r = n, mi(o, await bi(a, e, c, n));
|
|
6369
6379
|
let t = [...o.missing, ...o.readFailed];
|
|
6370
|
-
if (t.length > 0 &&
|
|
6371
|
-
let n = await
|
|
6372
|
-
|
|
6380
|
+
if (t.length > 0 && wr() && await Ti(t.map((e) => e.basename)) === "pick") {
|
|
6381
|
+
let n = await Ei(a, e, t);
|
|
6382
|
+
mi(o, n), o.missing = n.missing, o.readFailed = [];
|
|
6373
6383
|
}
|
|
6374
6384
|
}
|
|
6375
|
-
} else
|
|
6385
|
+
} else wi(t);
|
|
6376
6386
|
}
|
|
6377
|
-
|
|
6387
|
+
Si(o);
|
|
6378
6388
|
}, o = () => {
|
|
6379
6389
|
if (!e || e.isDestroyed || t.pausedUntilPaste) return;
|
|
6380
|
-
let o = a(), s =
|
|
6390
|
+
let o = a(), s = Ar(e.state.doc, o);
|
|
6381
6391
|
if (s.length === 0 || n) return;
|
|
6382
6392
|
n = !0;
|
|
6383
6393
|
let c = new Set(s.map((e) => e.src));
|
|
6384
6394
|
i(s).then(() => {
|
|
6385
6395
|
if (e.isDestroyed) return;
|
|
6386
|
-
let t =
|
|
6396
|
+
let t = Ar(e.state.doc, o).filter((e) => !c.has(e.src));
|
|
6387
6397
|
if (t.length !== 0) return i(t, r);
|
|
6388
6398
|
}).finally(() => {
|
|
6389
|
-
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste =
|
|
6399
|
+
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste = Ar(e.state.doc, o).length > 0);
|
|
6390
6400
|
});
|
|
6391
6401
|
};
|
|
6392
|
-
return [new
|
|
6393
|
-
key: new
|
|
6402
|
+
return [new B({
|
|
6403
|
+
key: new V("relativeMedia"),
|
|
6394
6404
|
props: { handlePaste(e, n) {
|
|
6395
6405
|
let r = n.clipboardData?.files;
|
|
6396
6406
|
return t.clipboardFiles = new Map(Array.from(r ?? []).map((e) => [e.name.toLowerCase(), e])), t.pausedUntilPaste = !1, !1;
|
|
@@ -6400,18 +6410,18 @@ var Ei = R.create({
|
|
|
6400
6410
|
}
|
|
6401
6411
|
})];
|
|
6402
6412
|
}
|
|
6403
|
-
}),
|
|
6404
|
-
function
|
|
6405
|
-
return
|
|
6413
|
+
}), Oi = new V("slashCommand");
|
|
6414
|
+
function ki(e) {
|
|
6415
|
+
return L.create({
|
|
6406
6416
|
name: "slashCommand",
|
|
6407
6417
|
addProseMirrorPlugins() {
|
|
6408
6418
|
let t = {
|
|
6409
6419
|
char: "/",
|
|
6410
|
-
pluginKey:
|
|
6420
|
+
pluginKey: Oi,
|
|
6411
6421
|
findSuggestionMatch: (e) => {
|
|
6412
6422
|
let { $position: t } = e;
|
|
6413
6423
|
for (let e = t.depth; e >= 0; e--) if (t.node(e).type.name === "codeBlock") return null;
|
|
6414
|
-
return t.marks().some((e) => e.type.name === "code") ? null :
|
|
6424
|
+
return t.marks().some((e) => e.type.name === "code") ? null : De(e);
|
|
6415
6425
|
},
|
|
6416
6426
|
allow: ({ editor: e, state: t }) => {
|
|
6417
6427
|
if (!e.isEditable) return !1;
|
|
@@ -6493,7 +6503,7 @@ function Oi(e) {
|
|
|
6493
6503
|
if (e.key === "Escape") {
|
|
6494
6504
|
e.preventDefault();
|
|
6495
6505
|
let t = a?.view;
|
|
6496
|
-
t &&
|
|
6506
|
+
t && Ee(t, Oi);
|
|
6497
6507
|
}
|
|
6498
6508
|
});
|
|
6499
6509
|
}
|
|
@@ -6511,7 +6521,7 @@ function Oi(e) {
|
|
|
6511
6521
|
if (!e || e.style.display === "none" || n.target instanceof Node && e.contains(n.target) || t) return;
|
|
6512
6522
|
let r = a?.view;
|
|
6513
6523
|
r && (t = !0, window.setTimeout(() => {
|
|
6514
|
-
t = !1, e?.style.display !== "none" &&
|
|
6524
|
+
t = !1, e?.style.display !== "none" && Ee(r, Oi);
|
|
6515
6525
|
}, 0));
|
|
6516
6526
|
}, document.addEventListener("mousedown", o, !0), document.addEventListener("touchstart", o, !0);
|
|
6517
6527
|
}
|
|
@@ -6535,11 +6545,11 @@ function Oi(e) {
|
|
|
6535
6545
|
};
|
|
6536
6546
|
}
|
|
6537
6547
|
};
|
|
6538
|
-
return [
|
|
6548
|
+
return [Te({
|
|
6539
6549
|
editor: this.editor,
|
|
6540
6550
|
...t
|
|
6541
|
-
}), new
|
|
6542
|
-
key: new
|
|
6551
|
+
}), new B({
|
|
6552
|
+
key: new V("slashCodeBlockGuard"),
|
|
6543
6553
|
appendTransaction: (e, t, n) => {
|
|
6544
6554
|
let { $from: r } = n.selection, i = !1;
|
|
6545
6555
|
for (let e = r.depth; e >= 0; e--) if (r.node(e).type.name === "codeBlock") {
|
|
@@ -6547,14 +6557,14 @@ function Oi(e) {
|
|
|
6547
6557
|
break;
|
|
6548
6558
|
}
|
|
6549
6559
|
if (!i && !r.marks().some((e) => e.type.name === "code")) return null;
|
|
6550
|
-
let a =
|
|
6551
|
-
return a && a.active ? n.tr.setMeta(
|
|
6560
|
+
let a = Oi.getState(n);
|
|
6561
|
+
return a && a.active ? n.tr.setMeta(Oi, { exit: !0 }) : null;
|
|
6552
6562
|
}
|
|
6553
6563
|
})];
|
|
6554
6564
|
}
|
|
6555
6565
|
});
|
|
6556
6566
|
}
|
|
6557
|
-
function
|
|
6567
|
+
function Ai(e, t) {
|
|
6558
6568
|
return [
|
|
6559
6569
|
{
|
|
6560
6570
|
title: e("editor.slash.heading1"),
|
|
@@ -6671,7 +6681,7 @@ function ki(e, t) {
|
|
|
6671
6681
|
n.type = "file", n.accept = "audio/*", n.onchange = async () => {
|
|
6672
6682
|
let r = n.files?.[0];
|
|
6673
6683
|
if (!r) return;
|
|
6674
|
-
let i =
|
|
6684
|
+
let i = mn(e) ?? t, a = i ? hn(e.state.doc, r, i) : null;
|
|
6675
6685
|
if (a) {
|
|
6676
6686
|
Z(a);
|
|
6677
6687
|
return;
|
|
@@ -6681,7 +6691,7 @@ function ki(e, t) {
|
|
|
6681
6691
|
name: r.name,
|
|
6682
6692
|
size: r.size
|
|
6683
6693
|
});
|
|
6684
|
-
s && (e.chain().focus().insertContent(s).run(), await
|
|
6694
|
+
s && (e.chain().focus().insertContent(s).run(), await Ir(e.view, r, o));
|
|
6685
6695
|
}, n.click();
|
|
6686
6696
|
}
|
|
6687
6697
|
},
|
|
@@ -6694,7 +6704,7 @@ function ki(e, t) {
|
|
|
6694
6704
|
n.type = "file", n.accept = "*/*", n.multiple = !0, n.onchange = async () => {
|
|
6695
6705
|
let r = n.files;
|
|
6696
6706
|
if (!(!r || r.length === 0)) for (let n of Array.from(r)) {
|
|
6697
|
-
let r =
|
|
6707
|
+
let r = mn(e) ?? t, i = r ? hn(e.state.doc, n, r) : null;
|
|
6698
6708
|
if (i) {
|
|
6699
6709
|
Z(i);
|
|
6700
6710
|
continue;
|
|
@@ -6711,7 +6721,7 @@ function ki(e, t) {
|
|
|
6711
6721
|
} catch {
|
|
6712
6722
|
continue;
|
|
6713
6723
|
}
|
|
6714
|
-
await
|
|
6724
|
+
await Ir(e.view, n, a);
|
|
6715
6725
|
}
|
|
6716
6726
|
}
|
|
6717
6727
|
}, n.click();
|
|
@@ -6721,9 +6731,9 @@ function ki(e, t) {
|
|
|
6721
6731
|
}
|
|
6722
6732
|
//#endregion
|
|
6723
6733
|
//#region src/editor/extensions/index.ts
|
|
6724
|
-
var
|
|
6734
|
+
var ji = U.extend({
|
|
6725
6735
|
addNodeView() {
|
|
6726
|
-
return F(
|
|
6736
|
+
return F(En);
|
|
6727
6737
|
},
|
|
6728
6738
|
addAttributes() {
|
|
6729
6739
|
return {
|
|
@@ -6746,75 +6756,85 @@ var Ai = W.extend({
|
|
|
6746
6756
|
};
|
|
6747
6757
|
}
|
|
6748
6758
|
});
|
|
6749
|
-
function
|
|
6759
|
+
function Mi(e = {}) {
|
|
6750
6760
|
return [
|
|
6751
|
-
|
|
6761
|
+
G.configure({
|
|
6752
6762
|
codeBlock: !1,
|
|
6753
6763
|
horizontalRule: !1,
|
|
6754
6764
|
underline: !1,
|
|
6755
6765
|
link: !1
|
|
6756
6766
|
}),
|
|
6757
|
-
|
|
6758
|
-
|
|
6767
|
+
W,
|
|
6768
|
+
ce.configure({
|
|
6759
6769
|
openOnClick: !0,
|
|
6760
6770
|
HTMLAttributes: {
|
|
6761
6771
|
rel: "noopener noreferrer",
|
|
6762
6772
|
target: "_blank"
|
|
6763
6773
|
}
|
|
6764
6774
|
}),
|
|
6765
|
-
|
|
6775
|
+
ji.configure({
|
|
6766
6776
|
inline: !1,
|
|
6767
6777
|
allowBase64: !0
|
|
6768
6778
|
}),
|
|
6769
|
-
ge,
|
|
6770
|
-
he.configure({ nested: !0 }),
|
|
6771
|
-
le.configure({ multicolor: !0 }),
|
|
6772
6779
|
_e,
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6780
|
+
ge.configure({ nested: !0 }),
|
|
6781
|
+
ue.configure({ multicolor: !0 }),
|
|
6782
|
+
ve,
|
|
6783
|
+
K,
|
|
6784
|
+
le.configure(e.maxLength ? { limit: e.maxLength } : {}),
|
|
6785
|
+
de,
|
|
6786
|
+
Vr,
|
|
6778
6787
|
ti,
|
|
6779
|
-
|
|
6780
|
-
|
|
6788
|
+
ni,
|
|
6789
|
+
mr,
|
|
6790
|
+
pe.configure({ resizable: !0 }),
|
|
6791
|
+
he,
|
|
6792
|
+
q,
|
|
6781
6793
|
me,
|
|
6782
|
-
|
|
6783
|
-
pe,
|
|
6784
|
-
ve.configure({
|
|
6794
|
+
ye.configure({
|
|
6785
6795
|
html: !0,
|
|
6786
6796
|
transformPastedText: !0,
|
|
6787
6797
|
transformCopiedText: !1
|
|
6788
6798
|
}),
|
|
6789
|
-
|
|
6790
|
-
|
|
6799
|
+
fe.configure({ placeholder: e.placeholder || "输入 '/' 打开菜单…" }),
|
|
6800
|
+
ki(() => Ai((e) => f(e), {
|
|
6791
6801
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6792
6802
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6793
6803
|
})),
|
|
6794
|
-
|
|
6804
|
+
Rr.configure({
|
|
6795
6805
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6796
6806
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6797
6807
|
}),
|
|
6798
|
-
|
|
6799
|
-
ci,
|
|
6800
|
-
At,
|
|
6801
|
-
zr,
|
|
6808
|
+
Di,
|
|
6802
6809
|
li,
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6810
|
+
At,
|
|
6811
|
+
Br,
|
|
6812
|
+
ui,
|
|
6813
|
+
Zn,
|
|
6814
|
+
Wn,
|
|
6815
|
+
Vn
|
|
6806
6816
|
];
|
|
6807
6817
|
}
|
|
6808
6818
|
//#endregion
|
|
6809
6819
|
//#region src/editor/extensions/bubble-menu.tsx
|
|
6810
|
-
var Mi = "https://www.bing.com/search?q={query}";
|
|
6811
6820
|
function Ni(e) {
|
|
6812
|
-
|
|
6821
|
+
let t = e.trim(), n = /^\$([^$]+?)\$$/.exec(t);
|
|
6822
|
+
if (n) return n[1].trim();
|
|
6823
|
+
let r = /^\$\$([\s\S]+?)\$\$$/.exec(t);
|
|
6824
|
+
return r ? r[1].trim() : t;
|
|
6813
6825
|
}
|
|
6814
|
-
function Pi() {
|
|
6815
|
-
|
|
6826
|
+
function Pi(e) {
|
|
6827
|
+
let t = e.trim();
|
|
6828
|
+
return t ? /^\${1,2}[\s\S]*\${1,2}$/.test(t) ? !0 : /[0-9=]/.test(t) && /[+\-*/^=(){}_\\]/.test(t) : !1;
|
|
6829
|
+
}
|
|
6830
|
+
var Fi = "https://www.bing.com/search?q={query}";
|
|
6831
|
+
function Ii(e) {
|
|
6832
|
+
Fi = e;
|
|
6833
|
+
}
|
|
6834
|
+
function Li() {
|
|
6835
|
+
return Fi;
|
|
6816
6836
|
}
|
|
6817
|
-
function
|
|
6837
|
+
function Ri(e) {
|
|
6818
6838
|
return [
|
|
6819
6839
|
{
|
|
6820
6840
|
key: "bold",
|
|
@@ -6851,6 +6871,25 @@ function Fi(e) {
|
|
|
6851
6871
|
isActive: (e) => e.isActive("code"),
|
|
6852
6872
|
command: (e) => e.isEditable && e.chain().focus().toggleCode().run()
|
|
6853
6873
|
},
|
|
6874
|
+
{
|
|
6875
|
+
key: "mathInline",
|
|
6876
|
+
label: e("editor.bubble.mathInline"),
|
|
6877
|
+
icon: /* @__PURE__ */ D(Wt, {}),
|
|
6878
|
+
isActive: (e) => e.isActive("mathInline"),
|
|
6879
|
+
command: (e) => {
|
|
6880
|
+
if (!e.isEditable) return;
|
|
6881
|
+
let { from: t, to: n } = e.state.selection;
|
|
6882
|
+
if (t === n) return;
|
|
6883
|
+
let r = Ni(e.state.doc.textBetween(t, n, "\n"));
|
|
6884
|
+
r && e.chain().focus().insertContentAt({
|
|
6885
|
+
from: t,
|
|
6886
|
+
to: n
|
|
6887
|
+
}, {
|
|
6888
|
+
type: "mathInline",
|
|
6889
|
+
attrs: { latex: r }
|
|
6890
|
+
}).run();
|
|
6891
|
+
}
|
|
6892
|
+
},
|
|
6854
6893
|
{
|
|
6855
6894
|
key: "highlight",
|
|
6856
6895
|
label: e("editor.bubble.highlight"),
|
|
@@ -6888,7 +6927,7 @@ function Fi(e) {
|
|
|
6888
6927
|
if (e.isActive("table")) return;
|
|
6889
6928
|
let { from: t, to: n } = e.state.selection, r = e.state.doc.textBetween(t, n, " ").trim();
|
|
6890
6929
|
if (!r) return;
|
|
6891
|
-
let i =
|
|
6930
|
+
let i = Fi.replace("{query}", encodeURIComponent(r));
|
|
6892
6931
|
window.open(i, "_blank", "noopener,noreferrer");
|
|
6893
6932
|
}
|
|
6894
6933
|
},
|
|
@@ -6919,10 +6958,10 @@ function Fi(e) {
|
|
|
6919
6958
|
}
|
|
6920
6959
|
];
|
|
6921
6960
|
}
|
|
6922
|
-
|
|
6961
|
+
L.create({ name: "bubbleMenu" });
|
|
6923
6962
|
//#endregion
|
|
6924
6963
|
//#region src/editor/extensions/table-toolbar.tsx
|
|
6925
|
-
function
|
|
6964
|
+
function zi(e) {
|
|
6926
6965
|
let { $from: t } = e.state.selection;
|
|
6927
6966
|
for (let e = t.depth; e > 0; e--) {
|
|
6928
6967
|
let n = t.node(e);
|
|
@@ -6933,7 +6972,7 @@ function Ii(e) {
|
|
|
6933
6972
|
}
|
|
6934
6973
|
return null;
|
|
6935
6974
|
}
|
|
6936
|
-
function
|
|
6975
|
+
function Bi(e) {
|
|
6937
6976
|
let t = [];
|
|
6938
6977
|
return e.forEach((e) => {
|
|
6939
6978
|
let n = [];
|
|
@@ -6942,7 +6981,7 @@ function Li(e) {
|
|
|
6942
6981
|
}), t.push(n);
|
|
6943
6982
|
}), t;
|
|
6944
6983
|
}
|
|
6945
|
-
function
|
|
6984
|
+
function Vi(e) {
|
|
6946
6985
|
if (e.length === 0) return "";
|
|
6947
6986
|
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(" | ")} |`;
|
|
6948
6987
|
return [
|
|
@@ -6951,11 +6990,11 @@ function Ri(e) {
|
|
|
6951
6990
|
...i.map(a)
|
|
6952
6991
|
].join("\n");
|
|
6953
6992
|
}
|
|
6954
|
-
function
|
|
6993
|
+
function Hi(e) {
|
|
6955
6994
|
let t = (e) => /[",\n]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e;
|
|
6956
6995
|
return e.map((e) => e.map(t).join(",")).join("\n");
|
|
6957
6996
|
}
|
|
6958
|
-
function
|
|
6997
|
+
function Ui(e) {
|
|
6959
6998
|
let t = e.trim();
|
|
6960
6999
|
if (!t) return null;
|
|
6961
7000
|
let n = t.split(/\r?\n/);
|
|
@@ -6969,7 +7008,7 @@ function Bi(e) {
|
|
|
6969
7008
|
}
|
|
6970
7009
|
return null;
|
|
6971
7010
|
}
|
|
6972
|
-
function
|
|
7011
|
+
function Wi({ editor: e }) {
|
|
6973
7012
|
let [t, n] = T(null), [r, i] = T(!1), [a, o] = T(!1), s = w(null), c = w(null), l = e.isEditable, u = b(() => {
|
|
6974
7013
|
c.current != null && cancelAnimationFrame(c.current), c.current = requestAnimationFrame(() => {
|
|
6975
7014
|
c.current = null;
|
|
@@ -6985,7 +7024,7 @@ function Vi({ editor: e }) {
|
|
|
6985
7024
|
n(null);
|
|
6986
7025
|
return;
|
|
6987
7026
|
}
|
|
6988
|
-
let t =
|
|
7027
|
+
let t = zi(e);
|
|
6989
7028
|
if (!t) {
|
|
6990
7029
|
n(null);
|
|
6991
7030
|
return;
|
|
@@ -7014,24 +7053,24 @@ function Vi({ editor: e }) {
|
|
|
7014
7053
|
});
|
|
7015
7054
|
return n.nodes.table.create(null, i);
|
|
7016
7055
|
}, p = () => {
|
|
7017
|
-
let t =
|
|
7056
|
+
let t = zi(e);
|
|
7018
7057
|
if (!t) return;
|
|
7019
|
-
let n =
|
|
7058
|
+
let n = Vi(Bi(t.node));
|
|
7020
7059
|
navigator.clipboard?.writeText(n), i(!0), setTimeout(() => i(!1), 1500);
|
|
7021
7060
|
}, m = () => {
|
|
7022
|
-
let t =
|
|
7061
|
+
let t = zi(e);
|
|
7023
7062
|
if (!t) return;
|
|
7024
|
-
let n =
|
|
7063
|
+
let n = Hi(Bi(t.node)), r = new Blob([`\ufeff${n}`], { type: "text/csv;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
7025
7064
|
a.href = i, a.download = "table.csv", document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
7026
7065
|
}, h = async () => {
|
|
7027
7066
|
if (l) try {
|
|
7028
7067
|
let t = await navigator.clipboard?.readText();
|
|
7029
7068
|
if (!t) return;
|
|
7030
|
-
let n =
|
|
7069
|
+
let n = Ui(t);
|
|
7031
7070
|
if (!n || n.length === 0) return;
|
|
7032
7071
|
let r = f(n);
|
|
7033
7072
|
if (!r) return;
|
|
7034
|
-
let i =
|
|
7073
|
+
let i = zi(e), a = e.chain().focus();
|
|
7035
7074
|
if (i) {
|
|
7036
7075
|
let t = Math.min(i.pos + i.node.nodeSize, e.state.doc.content.size);
|
|
7037
7076
|
a.setTextSelection(t);
|
|
@@ -7151,7 +7190,7 @@ function Vi({ editor: e }) {
|
|
|
7151
7190
|
type: "button",
|
|
7152
7191
|
className: "tbl-btn tbl-btn--del",
|
|
7153
7192
|
onClick: () => {
|
|
7154
|
-
!l ||
|
|
7193
|
+
!l || yn() || ($(!0), o(!0));
|
|
7155
7194
|
},
|
|
7156
7195
|
title: "删除",
|
|
7157
7196
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -7169,7 +7208,7 @@ function Vi({ editor: e }) {
|
|
|
7169
7208
|
})
|
|
7170
7209
|
})
|
|
7171
7210
|
}),
|
|
7172
|
-
/* @__PURE__ */ D(
|
|
7211
|
+
/* @__PURE__ */ D(wn, {
|
|
7173
7212
|
open: a,
|
|
7174
7213
|
title: "确认删除表格",
|
|
7175
7214
|
message: "此操作不可撤销。",
|
|
@@ -7185,7 +7224,7 @@ function Vi({ editor: e }) {
|
|
|
7185
7224
|
}
|
|
7186
7225
|
//#endregion
|
|
7187
7226
|
//#region src/editor/ai-editor.tsx
|
|
7188
|
-
var
|
|
7227
|
+
var Gi = [
|
|
7189
7228
|
{
|
|
7190
7229
|
color: "#fef08a",
|
|
7191
7230
|
name: "黄"
|
|
@@ -7210,9 +7249,9 @@ var Hi = [
|
|
|
7210
7249
|
color: "#ddd6fe",
|
|
7211
7250
|
name: "紫"
|
|
7212
7251
|
}
|
|
7213
|
-
],
|
|
7214
|
-
function
|
|
7215
|
-
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth ||
|
|
7252
|
+
], Ki = 288, qi = 480, Ji = 320;
|
|
7253
|
+
function Yi(e, t, n = {}) {
|
|
7254
|
+
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth || Ki, qi, r - 32), o = Math.max(t || Ji, 160);
|
|
7216
7255
|
if (r < 640) {
|
|
7217
7256
|
let t = Math.max(8, Math.min(e.top + 10, i - 420));
|
|
7218
7257
|
return {
|
|
@@ -7253,10 +7292,10 @@ function Ki(e, t, n = {}) {
|
|
|
7253
7292
|
arrowLeft: p
|
|
7254
7293
|
};
|
|
7255
7294
|
}
|
|
7256
|
-
function
|
|
7295
|
+
function Xi(e) {
|
|
7257
7296
|
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*\|.+\||(^|\n)\s*\$\$[\s\S]*?\$\$|(^|[^\\$])\$[^\s$\n](?:[^$\n]*[^\s$\n])?\$/i.test(e);
|
|
7258
7297
|
}
|
|
7259
|
-
function
|
|
7298
|
+
function Zi(e, t) {
|
|
7260
7299
|
try {
|
|
7261
7300
|
let n = e.storage?.markdown?.parser;
|
|
7262
7301
|
if (!n) return null;
|
|
@@ -7266,20 +7305,20 @@ function Ji(e, t) {
|
|
|
7266
7305
|
return null;
|
|
7267
7306
|
}
|
|
7268
7307
|
}
|
|
7269
|
-
var
|
|
7308
|
+
var Qi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.ImageUploadDialog }))), $i = y(() => import("./storage-settings-dialog-DnWNQWjN.js").then((e) => ({ default: e.StorageSettingsDialog }))), ea = y(() => import("./export-dialog-BwVrBASi.js").then((e) => ({ default: e.ExportDialog }))), ta = y(() => import("./video-embed-dialog-B0_pc5xe.js").then((e) => ({ default: e.VideoEmbedDialog }))), na = y(() => import("./md-import-dialog-DbC-NCH_.js").then((e) => ({ default: e.MdImportDialog }))), ra = () => /* @__PURE__ */ O("div", {
|
|
7270
7309
|
className: "fixed inset-0 z-[9999] flex items-center justify-center",
|
|
7271
7310
|
children: [/* @__PURE__ */ D("div", { className: "absolute inset-0 bg-black/40 backdrop-blur-sm" }), /* @__PURE__ */ D("div", {
|
|
7272
7311
|
className: "relative bg-background rounded-2xl border border-default-200 p-8 flex items-center justify-center",
|
|
7273
7312
|
children: /* @__PURE__ */ D("div", { className: "w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin" })
|
|
7274
7313
|
})]
|
|
7275
|
-
}),
|
|
7276
|
-
let k = r === "view" || i, A = C(() => typeof e == "object" && e ||
|
|
7314
|
+
}), ia = ({ 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 }) => {
|
|
7315
|
+
let k = r === "view" || i, A = C(() => typeof e == "object" && e || Xi(e) ? e : d(e), [e]), [j, M] = T(!1), [P, F] = T({}), [I, L] = T("below"), [ie, ae] = T(50), R = w(null), [z, B] = T(!1), [V, oe] = T(!1), [se, H] = T(!1), [U, ce] = T(!1), [W, G] = T("none"), [le, K] = T({}), ue = w(null), de = w(null), [fe, pe] = T(""), [q, me] = T(null), [he, ge] = T(m), [_e, ve] = T(!1);
|
|
7277
7316
|
x(() => {
|
|
7278
|
-
|
|
7317
|
+
ge(m);
|
|
7279
7318
|
}, [m]);
|
|
7280
|
-
let [
|
|
7281
|
-
let e =
|
|
7282
|
-
e && (
|
|
7319
|
+
let [ye, be] = T(!1), [xe, Se] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 80rem)").matches : !0), [Ce, we] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 64rem)").matches : !0), Te = w(null), Ee = w(null), De = w(null), Oe = w(0), ke = w(null), Ae = w(null), je = w(null), Me = w(null), [Ne, Pe] = T(!1), [Fe, Ie] = T(!1), [J, Le] = T(!1), [Re, ze] = T(!1), Be = w(null), Ve = b(() => {
|
|
7320
|
+
let e = Ee.current, t = De.current;
|
|
7321
|
+
e && (J ? (document.body.style.overflow = "", Object.assign(e.style, {
|
|
7283
7322
|
position: "",
|
|
7284
7323
|
top: "",
|
|
7285
7324
|
left: "",
|
|
@@ -7295,9 +7334,9 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7295
7334
|
flex: "",
|
|
7296
7335
|
overflow: "",
|
|
7297
7336
|
minHeight: ""
|
|
7298
|
-
}),
|
|
7299
|
-
window.scrollTo(0,
|
|
7300
|
-
})) : (document.fullscreenElement && document.exitFullscreen(),
|
|
7337
|
+
}), Le(!1), requestAnimationFrame(() => {
|
|
7338
|
+
window.scrollTo(0, Oe.current);
|
|
7339
|
+
})) : (document.fullscreenElement && document.exitFullscreen(), Oe.current = window.scrollY, Object.assign(e.style, {
|
|
7301
7340
|
position: "fixed",
|
|
7302
7341
|
top: "0",
|
|
7303
7342
|
left: "0",
|
|
@@ -7312,42 +7351,42 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7312
7351
|
flex: "1",
|
|
7313
7352
|
overflow: "auto",
|
|
7314
7353
|
minHeight: "0"
|
|
7315
|
-
}), document.body.style.overflow = "hidden",
|
|
7316
|
-
}, [
|
|
7317
|
-
let e =
|
|
7318
|
-
e && (document.fullscreenElement ? document.exitFullscreen() : (
|
|
7319
|
-
}, [
|
|
7354
|
+
}), document.body.style.overflow = "hidden", Le(!0)));
|
|
7355
|
+
}, [J]), He = b(() => {
|
|
7356
|
+
let e = Ee.current;
|
|
7357
|
+
e && (document.fullscreenElement ? document.exitFullscreen() : (J && Ve(), Oe.current = window.scrollY, e.requestFullscreen()));
|
|
7358
|
+
}, [J, Ve]);
|
|
7320
7359
|
x(() => {
|
|
7321
7360
|
let e = (e) => {
|
|
7322
|
-
e.key === "Escape" &&
|
|
7361
|
+
e.key === "Escape" && J && Ve();
|
|
7323
7362
|
}, t = () => {
|
|
7324
|
-
document.fullscreenElement ?
|
|
7325
|
-
window.scrollTo(0,
|
|
7363
|
+
document.fullscreenElement ? ze(!0) : (ze(!1), requestAnimationFrame(() => {
|
|
7364
|
+
window.scrollTo(0, Oe.current);
|
|
7326
7365
|
}));
|
|
7327
7366
|
};
|
|
7328
7367
|
return window.addEventListener("keydown", e), document.addEventListener("fullscreenchange", t), () => {
|
|
7329
7368
|
window.removeEventListener("keydown", e), document.removeEventListener("fullscreenchange", t);
|
|
7330
7369
|
};
|
|
7331
|
-
}, [
|
|
7370
|
+
}, [J, Ve]), x(() => {
|
|
7332
7371
|
if (!h) return;
|
|
7333
7372
|
let e = (e) => {
|
|
7334
7373
|
if ((e.ctrlKey || e.metaKey) && (e.key === "f" || e.key === "F")) {
|
|
7335
|
-
if (!
|
|
7336
|
-
e.preventDefault(), e.stopPropagation(),
|
|
7374
|
+
if (!Ee.current) return;
|
|
7375
|
+
e.preventDefault(), e.stopPropagation(), be(!0);
|
|
7337
7376
|
}
|
|
7338
7377
|
};
|
|
7339
7378
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
7340
7379
|
}, [h]), x(() => {
|
|
7341
7380
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
7342
|
-
let e = window.matchMedia("(min-width: 80rem)"), t = (e) =>
|
|
7343
|
-
return
|
|
7381
|
+
let e = window.matchMedia("(min-width: 80rem)"), t = (e) => Se(e.matches);
|
|
7382
|
+
return Se(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
7344
7383
|
}, []), x(() => {
|
|
7345
7384
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
7346
|
-
let e = window.matchMedia("(min-width: 64rem)"), t = (e) =>
|
|
7347
|
-
return
|
|
7385
|
+
let e = window.matchMedia("(min-width: 64rem)"), t = (e) => we(e.matches);
|
|
7386
|
+
return we(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
7348
7387
|
}, []);
|
|
7349
|
-
let
|
|
7350
|
-
extensions:
|
|
7388
|
+
let Y = te({
|
|
7389
|
+
extensions: Mi({
|
|
7351
7390
|
placeholder: n || f("editor.placeholder"),
|
|
7352
7391
|
maxLength: a,
|
|
7353
7392
|
maxAttachmentSize: o,
|
|
@@ -7357,11 +7396,15 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7357
7396
|
editable: !k,
|
|
7358
7397
|
immediatelyRender: _,
|
|
7359
7398
|
onUpdate: ({ editor: e }) => {
|
|
7360
|
-
t && (
|
|
7399
|
+
t && (Te.current && clearTimeout(Te.current), Te.current = setTimeout(() => {
|
|
7361
7400
|
t?.(e.getHTML(), e.getJSON());
|
|
7362
7401
|
}, 300));
|
|
7363
7402
|
},
|
|
7364
7403
|
onCreate: () => {},
|
|
7404
|
+
onSelectionUpdate: ({ editor: e }) => {
|
|
7405
|
+
let { from: t, to: n } = e.state.selection, r = t === n ? "" : e.state.doc.textBetween(t, n, "\n");
|
|
7406
|
+
Ie(Pi(r));
|
|
7407
|
+
},
|
|
7365
7408
|
editorProps: {
|
|
7366
7409
|
attributes: {
|
|
7367
7410
|
class: "prose prose-neutral dark:prose-invert max-w-none focus:outline-none min-h-[200px] px-4 sm:px-8 py-4",
|
|
@@ -7373,9 +7416,9 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7373
7416
|
let r = n.getData("text/plain");
|
|
7374
7417
|
if (!r || !r.includes("[[")) return !1;
|
|
7375
7418
|
t.preventDefault();
|
|
7376
|
-
let i =
|
|
7419
|
+
let i = Ae.current?.storage?.relativeMedia;
|
|
7377
7420
|
i && (i.clipboardFiles = new Map(Array.from(n.files ?? []).map((e) => [e.name.toLowerCase(), e])), i.pausedUntilPaste = !1);
|
|
7378
|
-
let a =
|
|
7421
|
+
let a = Ae.current ? Zi(Ae.current, r) : null;
|
|
7379
7422
|
if (a) {
|
|
7380
7423
|
let t = new N(a, 0, 0);
|
|
7381
7424
|
e.dispatch(e.state.tr.replaceSelection(t).scrollIntoView());
|
|
@@ -7385,21 +7428,21 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7385
7428
|
}
|
|
7386
7429
|
});
|
|
7387
7430
|
x(() => {
|
|
7388
|
-
|
|
7389
|
-
}, [
|
|
7390
|
-
if (
|
|
7391
|
-
}, [
|
|
7392
|
-
!
|
|
7393
|
-
}, [
|
|
7394
|
-
if (!
|
|
7431
|
+
Ae.current = Y, window.__editor = Y;
|
|
7432
|
+
}, [Y]), x(() => {
|
|
7433
|
+
if (Y) return () => en(Y);
|
|
7434
|
+
}, [Y]), x(() => {
|
|
7435
|
+
!Y || !g || g(Y);
|
|
7436
|
+
}, [Y, g]), x(() => {
|
|
7437
|
+
if (!Y) return;
|
|
7395
7438
|
let e = () => {
|
|
7396
|
-
|
|
7439
|
+
Y.state.selection.empty && (G("none"), Pe(!1));
|
|
7397
7440
|
};
|
|
7398
|
-
return
|
|
7399
|
-
|
|
7441
|
+
return Y.on("selectionUpdate", e), () => {
|
|
7442
|
+
Y.off("selectionUpdate", e);
|
|
7400
7443
|
};
|
|
7401
|
-
}, [
|
|
7402
|
-
|
|
7444
|
+
}, [Y]), x(() => {
|
|
7445
|
+
Y && Y.setOptions({ extensions: Mi({
|
|
7403
7446
|
placeholder: n || f("editor.placeholder"),
|
|
7404
7447
|
maxLength: a,
|
|
7405
7448
|
maxAttachmentSize: o,
|
|
@@ -7411,33 +7454,33 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7411
7454
|
o,
|
|
7412
7455
|
s
|
|
7413
7456
|
]);
|
|
7414
|
-
let
|
|
7457
|
+
let Ue = w(e);
|
|
7415
7458
|
x(() => {
|
|
7416
|
-
if (!
|
|
7417
|
-
|
|
7418
|
-
let t = typeof e == "object" && e ||
|
|
7419
|
-
|
|
7420
|
-
}, [
|
|
7421
|
-
|
|
7422
|
-
}, [
|
|
7459
|
+
if (!Y || e === Ue.current) return;
|
|
7460
|
+
Ue.current = e;
|
|
7461
|
+
let t = typeof e == "object" && e || Xi(e) ? e : d(e);
|
|
7462
|
+
Y.commands.setContent(t, { emitUpdate: !1 });
|
|
7463
|
+
}, [Y, e]), x(() => {
|
|
7464
|
+
Y && Y.setEditable(!k, !1);
|
|
7465
|
+
}, [Y, k]), x(() => {
|
|
7423
7466
|
if (y) return tt(y);
|
|
7424
7467
|
}, [y]), x(() => {
|
|
7425
|
-
if (!
|
|
7426
|
-
let e =
|
|
7427
|
-
e > s && Z(`文档内附件总大小 ${
|
|
7428
|
-
}, [
|
|
7429
|
-
if (!
|
|
7430
|
-
let e =
|
|
7468
|
+
if (!Y) return;
|
|
7469
|
+
let e = fn(Y.state.doc);
|
|
7470
|
+
e > s && Z(`文档内附件总大小 ${pn(e)} 已超过限制 ${pn(s)}`, "info");
|
|
7471
|
+
}, [Y, s]), x(() => {
|
|
7472
|
+
if (!Y) return;
|
|
7473
|
+
let e = Y.storage.qingwuUI;
|
|
7431
7474
|
e && (e.limits = {
|
|
7432
7475
|
maxAttachmentSize: o,
|
|
7433
7476
|
maxTotalAttachmentSize: s
|
|
7434
7477
|
});
|
|
7435
7478
|
}, [
|
|
7436
|
-
|
|
7479
|
+
Y,
|
|
7437
7480
|
o,
|
|
7438
7481
|
s
|
|
7439
7482
|
]);
|
|
7440
|
-
let
|
|
7483
|
+
let X = b((e, t) => {
|
|
7441
7484
|
let n = e ? Math.max(8, Math.min(e.left, window.innerWidth - 240 - 8)) : 8, r;
|
|
7442
7485
|
return r = e ? t && e.bottom + 8 + t > window.innerHeight ? Math.max(8, e.top - t - 8) : e.bottom + 8 : 8, {
|
|
7443
7486
|
position: "fixed",
|
|
@@ -7445,66 +7488,66 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7445
7488
|
left: n,
|
|
7446
7489
|
zIndex: 9999
|
|
7447
7490
|
};
|
|
7448
|
-
}, []),
|
|
7449
|
-
let t =
|
|
7450
|
-
|
|
7451
|
-
}, [
|
|
7491
|
+
}, []), We = b((e) => {
|
|
7492
|
+
let t = Me.current?.getBoundingClientRect() ?? null;
|
|
7493
|
+
de.current = t, G(e), Pe(!1), K(X(t, void 0));
|
|
7494
|
+
}, [X]);
|
|
7452
7495
|
S(() => {
|
|
7453
|
-
if (
|
|
7454
|
-
let e =
|
|
7455
|
-
|
|
7456
|
-
}, [
|
|
7457
|
-
if (
|
|
7458
|
-
let e = () =>
|
|
7459
|
-
let e =
|
|
7460
|
-
|
|
7496
|
+
if (W === "none") return;
|
|
7497
|
+
let e = ue.current;
|
|
7498
|
+
K(X(de.current, e?.offsetHeight || void 0));
|
|
7499
|
+
}, [W, X]), x(() => {
|
|
7500
|
+
if (W === "none") return;
|
|
7501
|
+
let e = () => G("none"), t = () => {
|
|
7502
|
+
let e = ue.current;
|
|
7503
|
+
K(X(de.current, e?.offsetHeight || void 0));
|
|
7461
7504
|
};
|
|
7462
7505
|
return window.addEventListener("scroll", e, !0), window.addEventListener("resize", t), () => {
|
|
7463
7506
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", t);
|
|
7464
7507
|
};
|
|
7465
|
-
}, [
|
|
7466
|
-
|
|
7467
|
-
}, [
|
|
7468
|
-
let
|
|
7469
|
-
if (
|
|
7508
|
+
}, [W, X]), x(() => {
|
|
7509
|
+
W === "none" && (de.current = null);
|
|
7510
|
+
}, [W]);
|
|
7511
|
+
let Ge = Ri((e) => f(e)), Ke = Ge.filter((e) => !e.more), qe = Ge.filter((e) => e.more), Je = Ke.filter((e) => e.key !== "ai" && (e.key !== "mathInline" || Fe)), Ye = Ke.find((e) => e.key === "ai"), Xe = b((e) => {
|
|
7512
|
+
if (Y) if (Pe(!1), e.key === "link") if (Y.isActive("link")) Y.chain().focus().unsetLink().run();
|
|
7470
7513
|
else {
|
|
7471
|
-
let e =
|
|
7472
|
-
|
|
7514
|
+
let e = Y.getAttributes("link").href || "";
|
|
7515
|
+
pe(e), We("link");
|
|
7473
7516
|
}
|
|
7474
|
-
else e.key === "highlight" ?
|
|
7517
|
+
else e.key === "highlight" ? W === "highlight" ? G("none") : We("highlight") : e.command(Y);
|
|
7475
7518
|
}, [
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
]),
|
|
7519
|
+
Y,
|
|
7520
|
+
W,
|
|
7521
|
+
We
|
|
7522
|
+
]), Ze = b((e) => Y ? e.key === "highlight" ? W === "highlight" : e.key === "link" ? Y.isActive("link") : e.isActive(Y) : !1, [Y, W]), [Qe, $e] = T(0);
|
|
7480
7523
|
x(() => {
|
|
7481
|
-
if (!
|
|
7482
|
-
let e = () =>
|
|
7483
|
-
return
|
|
7484
|
-
|
|
7524
|
+
if (!Y) return;
|
|
7525
|
+
let e = () => $e((e) => (e + 1) % 1e6);
|
|
7526
|
+
return Y.on("update", e), () => {
|
|
7527
|
+
Y.off("update", e);
|
|
7485
7528
|
};
|
|
7486
|
-
}, [
|
|
7487
|
-
let [
|
|
7529
|
+
}, [Y]);
|
|
7530
|
+
let [et, nt] = T(!1);
|
|
7488
7531
|
x(() => {
|
|
7489
|
-
if (!
|
|
7532
|
+
if (!Y) return;
|
|
7490
7533
|
let e = () => {
|
|
7491
7534
|
let e = !1;
|
|
7492
|
-
|
|
7535
|
+
Y.state.doc.descendants((t) => {
|
|
7493
7536
|
t.type.name === "heading" && (e = !0);
|
|
7494
|
-
}),
|
|
7537
|
+
}), nt(e);
|
|
7495
7538
|
};
|
|
7496
|
-
return e(),
|
|
7497
|
-
|
|
7539
|
+
return e(), Y.on("update", e), () => {
|
|
7540
|
+
Y.off("update", e);
|
|
7498
7541
|
};
|
|
7499
|
-
}, [
|
|
7500
|
-
let
|
|
7542
|
+
}, [Y]);
|
|
7543
|
+
let rt = C(() => Y?.storage?.characterCount?.characters?.() ?? 0, [Y, Qe]), it = a ? rt > a : !1;
|
|
7501
7544
|
x(() => () => {
|
|
7502
|
-
|
|
7545
|
+
Te.current && clearTimeout(Te.current);
|
|
7503
7546
|
}, []), x(() => () => {
|
|
7504
|
-
|
|
7547
|
+
q && q.resolve(null);
|
|
7505
7548
|
}, []);
|
|
7506
|
-
let
|
|
7507
|
-
if (!
|
|
7549
|
+
let at = b((e) => {
|
|
7550
|
+
if (!Y?.isEditable) return;
|
|
7508
7551
|
let t = window.getSelection(), n;
|
|
7509
7552
|
if (e) {
|
|
7510
7553
|
let t = e.getBoundingClientRect();
|
|
@@ -7521,76 +7564,76 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7521
7564
|
width: e.width
|
|
7522
7565
|
};
|
|
7523
7566
|
} else {
|
|
7524
|
-
let e =
|
|
7567
|
+
let e = Y.view.coordsAtPos(Y.state.selection.from);
|
|
7525
7568
|
n = {
|
|
7526
7569
|
top: e.bottom,
|
|
7527
7570
|
left: e.left,
|
|
7528
7571
|
width: 0
|
|
7529
7572
|
};
|
|
7530
7573
|
}
|
|
7531
|
-
|
|
7532
|
-
let r =
|
|
7574
|
+
ke.current = n;
|
|
7575
|
+
let r = Ee.current?.getBoundingClientRect(), i = Yi(n, void 0, {
|
|
7533
7576
|
panelWidth: r?.width,
|
|
7534
7577
|
editorLeft: r?.left
|
|
7535
7578
|
});
|
|
7536
|
-
M(!0), F(i.style),
|
|
7537
|
-
}, [
|
|
7579
|
+
M(!0), F(i.style), L(i.placement), ae(i.arrowLeft);
|
|
7580
|
+
}, [Y]);
|
|
7538
7581
|
x(() => {
|
|
7539
|
-
if (!
|
|
7540
|
-
let e =
|
|
7541
|
-
if (e) return e.openImageDialog = () =>
|
|
7542
|
-
|
|
7582
|
+
if (!Y) return;
|
|
7583
|
+
let e = Y.storage.qingwuUI;
|
|
7584
|
+
if (e) return e.openImageDialog = () => B(!0), e.openVideoDialog = () => oe(!0), e.chooseMd = (e, t) => {
|
|
7585
|
+
me({
|
|
7543
7586
|
filename: e,
|
|
7544
7587
|
resolve: t
|
|
7545
7588
|
});
|
|
7546
|
-
}, e.openAI =
|
|
7589
|
+
}, e.openAI = at, e.parseMd = (e, t) => Y ? Zi(Y, t) : null, () => {
|
|
7547
7590
|
delete e.openImageDialog, delete e.openVideoDialog, delete e.openAI, delete e.parseMd, delete e.chooseMd;
|
|
7548
7591
|
};
|
|
7549
|
-
}, [
|
|
7550
|
-
if (!j || !
|
|
7551
|
-
let e =
|
|
7592
|
+
}, [Y, at]), S(() => {
|
|
7593
|
+
if (!j || !Y) return;
|
|
7594
|
+
let e = ke.current;
|
|
7552
7595
|
if (!e) return;
|
|
7553
|
-
let t =
|
|
7596
|
+
let t = R.current, n = Ee.current?.getBoundingClientRect(), r = Yi(e, t?.offsetHeight || void 0, {
|
|
7554
7597
|
panelWidth: n?.width,
|
|
7555
7598
|
editorLeft: n?.left
|
|
7556
7599
|
});
|
|
7557
|
-
|
|
7558
|
-
}, [j,
|
|
7559
|
-
if (!j || !
|
|
7600
|
+
L(r.placement), ae(r.arrowLeft), F(r.style);
|
|
7601
|
+
}, [j, Y]), x(() => {
|
|
7602
|
+
if (!j || !Y) return;
|
|
7560
7603
|
let e = () => {
|
|
7561
|
-
let e =
|
|
7604
|
+
let e = ke.current;
|
|
7562
7605
|
if (!e) return;
|
|
7563
|
-
let t =
|
|
7606
|
+
let t = R.current, n = Ee.current?.getBoundingClientRect(), r = Yi(e, t?.offsetHeight || void 0, {
|
|
7564
7607
|
panelWidth: n?.width,
|
|
7565
7608
|
editorLeft: n?.left
|
|
7566
7609
|
});
|
|
7567
|
-
|
|
7610
|
+
L(r.placement), ae(r.arrowLeft), F(r.style);
|
|
7568
7611
|
};
|
|
7569
7612
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
7570
|
-
}, [j,
|
|
7571
|
-
j || (
|
|
7613
|
+
}, [j, Y]), x(() => {
|
|
7614
|
+
j || (ke.current = null);
|
|
7572
7615
|
}, [j]);
|
|
7573
|
-
let
|
|
7574
|
-
|
|
7575
|
-
}, [
|
|
7576
|
-
(
|
|
7577
|
-
}, [
|
|
7616
|
+
let ot = b((e) => {
|
|
7617
|
+
Y?.chain().focus().setImage({ src: e }).run();
|
|
7618
|
+
}, [Y]), st = b((e) => {
|
|
7619
|
+
(Y?.commands).insertVideo?.({ src: e });
|
|
7620
|
+
}, [Y]), ct = he && xe && !J && !Re, dt = !ct && !_e && (he || et && !(!k && Ce)), ft = w(!1);
|
|
7578
7621
|
return x(() => {
|
|
7579
|
-
|
|
7580
|
-
}, [
|
|
7581
|
-
if (!
|
|
7622
|
+
ft.current || (ft.current = !0, he && !ct && ve(!0));
|
|
7623
|
+
}, [he, ct]), x(() => {
|
|
7624
|
+
if (!_e) return;
|
|
7582
7625
|
let e = (e) => {
|
|
7583
7626
|
let t = e.target;
|
|
7584
|
-
|
|
7627
|
+
Be.current?.contains(t) || ve(!1);
|
|
7585
7628
|
}, t = (e) => {
|
|
7586
|
-
e.key === "Escape" &&
|
|
7629
|
+
e.key === "Escape" && ve(!1);
|
|
7587
7630
|
};
|
|
7588
7631
|
return document.addEventListener("mousedown", e), document.addEventListener("touchstart", e, { passive: !0 }), document.addEventListener("keydown", t), () => {
|
|
7589
7632
|
document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e), document.removeEventListener("keydown", t);
|
|
7590
7633
|
};
|
|
7591
|
-
}, [
|
|
7592
|
-
if (!
|
|
7593
|
-
let e =
|
|
7634
|
+
}, [_e]), x(() => {
|
|
7635
|
+
if (!Y || !ct) return;
|
|
7636
|
+
let e = je.current;
|
|
7594
7637
|
if (!(e instanceof HTMLElement)) return;
|
|
7595
7638
|
let t = (t) => {
|
|
7596
7639
|
let n = t.deltaY;
|
|
@@ -7600,17 +7643,17 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7600
7643
|
e.scrollTop += n, t.preventDefault(), t.stopPropagation();
|
|
7601
7644
|
return;
|
|
7602
7645
|
}
|
|
7603
|
-
let a = ut(
|
|
7646
|
+
let a = ut(Y), o = a ? lt(a) : null;
|
|
7604
7647
|
if (o) {
|
|
7605
7648
|
o.scrollTop += n, t.preventDefault(), t.stopPropagation();
|
|
7606
7649
|
return;
|
|
7607
7650
|
}
|
|
7608
7651
|
};
|
|
7609
7652
|
return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
|
|
7610
|
-
}, [
|
|
7653
|
+
}, [Y, ct]), Y ? /* @__PURE__ */ O("div", {
|
|
7611
7654
|
className: "qingwu-editor-row",
|
|
7612
7655
|
children: [/* @__PURE__ */ O("div", {
|
|
7613
|
-
ref:
|
|
7656
|
+
ref: Ee,
|
|
7614
7657
|
className: `qingwu-editor relative flex-1 min-w-0 bg-background ${k ? "qingwu-editor--readonly" : ""} ${l ? "" : "rounded-xl border border-default-200"} ${c}`,
|
|
7615
7658
|
style: u,
|
|
7616
7659
|
children: [
|
|
@@ -7621,13 +7664,13 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7621
7664
|
children: [
|
|
7622
7665
|
/* @__PURE__ */ D("button", {
|
|
7623
7666
|
type: "button",
|
|
7624
|
-
className: `qed-tb-btn qed-tb-btn--desktop-only${
|
|
7667
|
+
className: `qed-tb-btn qed-tb-btn--desktop-only${he ? " is-active" : ""}`,
|
|
7625
7668
|
onClick: () => {
|
|
7626
|
-
|
|
7669
|
+
he ? (ge(!1), ve(!1)) : (ge(!0), xe && !J && !Re || ve(!0));
|
|
7627
7670
|
},
|
|
7628
|
-
title:
|
|
7629
|
-
"aria-label":
|
|
7630
|
-
"aria-pressed":
|
|
7671
|
+
title: he ? "隐藏目录" : "显示目录",
|
|
7672
|
+
"aria-label": he ? "隐藏目录" : "显示目录",
|
|
7673
|
+
"aria-pressed": he,
|
|
7631
7674
|
children: /* @__PURE__ */ D("svg", {
|
|
7632
7675
|
fill: "none",
|
|
7633
7676
|
viewBox: "0 0 24 24",
|
|
@@ -7643,11 +7686,11 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7643
7686
|
}),
|
|
7644
7687
|
h && /* @__PURE__ */ D("button", {
|
|
7645
7688
|
type: "button",
|
|
7646
|
-
className: `qed-tb-btn${
|
|
7647
|
-
onClick: () =>
|
|
7689
|
+
className: `qed-tb-btn${ye ? " is-active" : ""}`,
|
|
7690
|
+
onClick: () => be(!ye),
|
|
7648
7691
|
title: "查找 (Ctrl+F)",
|
|
7649
7692
|
"aria-label": "查找",
|
|
7650
|
-
"aria-pressed":
|
|
7693
|
+
"aria-pressed": ye,
|
|
7651
7694
|
children: /* @__PURE__ */ D("svg", {
|
|
7652
7695
|
fill: "none",
|
|
7653
7696
|
viewBox: "0 0 24 24",
|
|
@@ -7664,7 +7707,7 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7664
7707
|
!k && /* @__PURE__ */ D("button", {
|
|
7665
7708
|
type: "button",
|
|
7666
7709
|
className: `qed-tb-btn qed-tb-btn--ai${j ? " is-active" : ""}`,
|
|
7667
|
-
onClick: (e) => j ? M(!1) :
|
|
7710
|
+
onClick: (e) => j ? M(!1) : at(e.currentTarget),
|
|
7668
7711
|
title: f("editor.toolbar.aiTitle"),
|
|
7669
7712
|
"aria-label": f("editor.toolbar.ai"),
|
|
7670
7713
|
"aria-pressed": j,
|
|
@@ -7692,7 +7735,7 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7692
7735
|
/* @__PURE__ */ O("button", {
|
|
7693
7736
|
type: "button",
|
|
7694
7737
|
className: "qed-tb-btn qed-tb-btn--solid",
|
|
7695
|
-
onClick: () =>
|
|
7738
|
+
onClick: () => ce(!0),
|
|
7696
7739
|
title: f("editor.toolbar.exportTitle"),
|
|
7697
7740
|
children: [/* @__PURE__ */ D("svg", {
|
|
7698
7741
|
fill: "none",
|
|
@@ -7712,11 +7755,11 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7712
7755
|
}),
|
|
7713
7756
|
/* @__PURE__ */ D("button", {
|
|
7714
7757
|
type: "button",
|
|
7715
|
-
className: `qed-tb-btn${
|
|
7716
|
-
onClick:
|
|
7717
|
-
title:
|
|
7718
|
-
"aria-label":
|
|
7719
|
-
"aria-pressed":
|
|
7758
|
+
className: `qed-tb-btn${J ? " is-active" : ""}`,
|
|
7759
|
+
onClick: Ve,
|
|
7760
|
+
title: J ? "退出网页全屏" : "网页全屏",
|
|
7761
|
+
"aria-label": J ? "退出网页全屏" : "网页全屏",
|
|
7762
|
+
"aria-pressed": J,
|
|
7720
7763
|
children: /* @__PURE__ */ D("svg", {
|
|
7721
7764
|
fill: "none",
|
|
7722
7765
|
viewBox: "0 0 24 24",
|
|
@@ -7732,11 +7775,11 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7732
7775
|
}),
|
|
7733
7776
|
/* @__PURE__ */ D("button", {
|
|
7734
7777
|
type: "button",
|
|
7735
|
-
className: `qed-tb-btn${
|
|
7736
|
-
onClick:
|
|
7737
|
-
title:
|
|
7738
|
-
"aria-label":
|
|
7739
|
-
"aria-pressed":
|
|
7778
|
+
className: `qed-tb-btn${Re ? " is-active" : ""}`,
|
|
7779
|
+
onClick: He,
|
|
7780
|
+
title: Re ? "退出全屏" : "全屏",
|
|
7781
|
+
"aria-label": Re ? "退出全屏" : "全屏",
|
|
7782
|
+
"aria-pressed": Re,
|
|
7740
7783
|
children: /* @__PURE__ */ D("svg", {
|
|
7741
7784
|
fill: "none",
|
|
7742
7785
|
viewBox: "0 0 24 24",
|
|
@@ -7753,8 +7796,8 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7753
7796
|
]
|
|
7754
7797
|
})]
|
|
7755
7798
|
}),
|
|
7756
|
-
|
|
7757
|
-
editor:
|
|
7799
|
+
Y && !k && Y.isEditable && /* @__PURE__ */ D(ne, {
|
|
7800
|
+
editor: Y,
|
|
7758
7801
|
shouldShow: ({ editor: e, state: t }) => !(e.isActive("image") || e.isActive("videoEmbed") || e.isActive("codeBlock") || e.isActive("audioEmbed") || e.isActive("attachmentEmbed") || t.selection.empty),
|
|
7759
7802
|
options: {
|
|
7760
7803
|
placement: "bottom",
|
|
@@ -7763,17 +7806,17 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7763
7806
|
},
|
|
7764
7807
|
className: "bubble-menu-pop bg-background border border-default-200 rounded-xl p-1 shadow-lg",
|
|
7765
7808
|
children: /* @__PURE__ */ O("div", {
|
|
7766
|
-
ref:
|
|
7809
|
+
ref: Me,
|
|
7767
7810
|
className: "bubble-menu-items relative flex items-center gap-0.5",
|
|
7768
7811
|
onPointerDown: (e) => {
|
|
7769
7812
|
e.target.closest("button") && e.preventDefault();
|
|
7770
7813
|
},
|
|
7771
7814
|
children: [
|
|
7772
|
-
|
|
7815
|
+
Je.map((e) => /* @__PURE__ */ D("button", {
|
|
7773
7816
|
type: "button",
|
|
7774
|
-
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${e.isActive(
|
|
7817
|
+
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"}`,
|
|
7775
7818
|
onClick: (t) => {
|
|
7776
|
-
t.preventDefault(),
|
|
7819
|
+
t.preventDefault(), Xe(e);
|
|
7777
7820
|
},
|
|
7778
7821
|
title: e.label,
|
|
7779
7822
|
"aria-label": e.label,
|
|
@@ -7787,10 +7830,10 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7787
7830
|
type: "button",
|
|
7788
7831
|
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"}`,
|
|
7789
7832
|
onClick: (e) => {
|
|
7790
|
-
e.preventDefault(),
|
|
7833
|
+
e.preventDefault(), Pe(!1), Ye?.command(Y);
|
|
7791
7834
|
},
|
|
7792
|
-
title:
|
|
7793
|
-
"aria-label":
|
|
7835
|
+
title: Ye?.label,
|
|
7836
|
+
"aria-label": Ye?.label,
|
|
7794
7837
|
children: /* @__PURE__ */ D(Ut, {})
|
|
7795
7838
|
}),
|
|
7796
7839
|
/* @__PURE__ */ D("span", {
|
|
@@ -7799,27 +7842,27 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7799
7842
|
}),
|
|
7800
7843
|
/* @__PURE__ */ D("button", {
|
|
7801
7844
|
type: "button",
|
|
7802
|
-
"aria-expanded":
|
|
7803
|
-
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${
|
|
7845
|
+
"aria-expanded": Ne,
|
|
7846
|
+
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${Ne ? "bg-default-100 text-default-900" : "text-default-600 hover:bg-default-100"}`,
|
|
7804
7847
|
onClick: (e) => {
|
|
7805
|
-
e.preventDefault(),
|
|
7848
|
+
e.preventDefault(), Pe((e) => !e);
|
|
7806
7849
|
},
|
|
7807
7850
|
title: f("editor.bubble.more"),
|
|
7808
7851
|
"aria-label": f("editor.bubble.more"),
|
|
7809
|
-
children: /* @__PURE__ */ D(
|
|
7852
|
+
children: /* @__PURE__ */ D(Gt, {})
|
|
7810
7853
|
}),
|
|
7811
|
-
|
|
7854
|
+
Ne && /* @__PURE__ */ D("div", {
|
|
7812
7855
|
role: "menu",
|
|
7813
7856
|
className: "bubble-more-menu absolute right-0 top-full z-[9999] mt-1 w-max max-h-[70dvh] overflow-y-auto flex-col gap-1 rounded-xl border border-default-200 bg-background p-1.5 shadow-xl",
|
|
7814
7857
|
onPointerDown: (e) => {
|
|
7815
7858
|
e.target.closest("button") && e.preventDefault();
|
|
7816
7859
|
},
|
|
7817
|
-
children:
|
|
7860
|
+
children: qe.map((e) => /* @__PURE__ */ O("button", {
|
|
7818
7861
|
type: "button",
|
|
7819
7862
|
role: "menuitem",
|
|
7820
|
-
className: `flex items-center gap-2 w-full whitespace-nowrap px-3 py-1.5 text-xs rounded-md transition-colors ${
|
|
7863
|
+
className: `flex items-center gap-2 w-full whitespace-nowrap px-3 py-1.5 text-xs rounded-md transition-colors ${Ze(e) ? "bg-primary/10 text-primary" : "text-default-600 hover:bg-default-100"}`,
|
|
7821
7864
|
onClick: (t) => {
|
|
7822
|
-
t.preventDefault(),
|
|
7865
|
+
t.preventDefault(), Xe(e);
|
|
7823
7866
|
},
|
|
7824
7867
|
title: e.label,
|
|
7825
7868
|
children: [/* @__PURE__ */ D("span", {
|
|
@@ -7834,30 +7877,30 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7834
7877
|
]
|
|
7835
7878
|
})
|
|
7836
7879
|
}),
|
|
7837
|
-
|
|
7880
|
+
Y && W !== "none" && re(/* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
7838
7881
|
className: "fixed inset-0 z-[9998]",
|
|
7839
|
-
onClick: () =>
|
|
7882
|
+
onClick: () => G("none")
|
|
7840
7883
|
}), /* @__PURE__ */ D("div", {
|
|
7841
|
-
ref:
|
|
7842
|
-
style:
|
|
7884
|
+
ref: ue,
|
|
7885
|
+
style: le,
|
|
7843
7886
|
className: "bg-background border border-default-200 rounded-xl shadow-xl",
|
|
7844
7887
|
onClick: (e) => e.stopPropagation(),
|
|
7845
|
-
children:
|
|
7888
|
+
children: W === "highlight" ? /* @__PURE__ */ O("div", {
|
|
7846
7889
|
className: "flex items-center gap-1 p-1.5 flex-wrap",
|
|
7847
|
-
children: [
|
|
7890
|
+
children: [Gi.map((e) => /* @__PURE__ */ D("button", {
|
|
7848
7891
|
type: "button",
|
|
7849
7892
|
className: "w-5 h-5 rounded-full border border-default-200 hover:scale-110 transition-transform",
|
|
7850
7893
|
style: { background: e.color },
|
|
7851
7894
|
title: e.name,
|
|
7852
7895
|
onClick: () => {
|
|
7853
|
-
|
|
7896
|
+
Y.chain().focus().setHighlight({ color: e.color }).run(), G("none");
|
|
7854
7897
|
}
|
|
7855
7898
|
}, e.color)), /* @__PURE__ */ O("button", {
|
|
7856
7899
|
type: "button",
|
|
7857
7900
|
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]",
|
|
7858
7901
|
title: "清除高亮",
|
|
7859
7902
|
onClick: () => {
|
|
7860
|
-
|
|
7903
|
+
Y.chain().focus().unsetHighlight().run(), G("none");
|
|
7861
7904
|
},
|
|
7862
7905
|
children: ["✕", " "]
|
|
7863
7906
|
})]
|
|
@@ -7867,104 +7910,104 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7867
7910
|
type: "url",
|
|
7868
7911
|
className: "flex-1 px-2 py-1 text-xs rounded-md border border-default-200 bg-background focus:outline-none focus:border-primary",
|
|
7869
7912
|
placeholder: "https://...",
|
|
7870
|
-
value:
|
|
7871
|
-
onChange: (e) =>
|
|
7913
|
+
value: fe,
|
|
7914
|
+
onChange: (e) => pe(e.target.value),
|
|
7872
7915
|
onKeyDown: (e) => {
|
|
7873
|
-
e.key === "Enter" ? (
|
|
7916
|
+
e.key === "Enter" ? (fe.trim() && Y.chain().focus().setLink({ href: fe.trim() }).run(), G("none")) : e.key === "Escape" && G("none");
|
|
7874
7917
|
}
|
|
7875
7918
|
}), /* @__PURE__ */ D("button", {
|
|
7876
7919
|
type: "button",
|
|
7877
7920
|
className: "px-2 py-1 text-xs rounded-md bg-primary text-white hover:opacity-90",
|
|
7878
7921
|
onClick: () => {
|
|
7879
|
-
|
|
7922
|
+
fe.trim() && Y.chain().focus().setLink({ href: fe.trim() }).run(), G("none");
|
|
7880
7923
|
},
|
|
7881
7924
|
children: "确定"
|
|
7882
7925
|
})]
|
|
7883
7926
|
})
|
|
7884
7927
|
})] }), document.body),
|
|
7885
|
-
!k && j &&
|
|
7928
|
+
!k && j && re(/* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
7886
7929
|
className: "fixed inset-0 z-[9998]",
|
|
7887
7930
|
onClick: () => M(!1)
|
|
7888
7931
|
}), /* @__PURE__ */ O("div", {
|
|
7889
|
-
ref:
|
|
7932
|
+
ref: R,
|
|
7890
7933
|
"data-lenis-prevent": !0,
|
|
7891
7934
|
style: P,
|
|
7892
7935
|
className: `ai-panel relative flex flex-col bg-background border border-default-200 rounded-xl shadow-xl${I === "above" ? " ai-panel--above" : ""}`,
|
|
7893
7936
|
onClick: (e) => e.stopPropagation(),
|
|
7894
7937
|
children: [/* @__PURE__ */ D("span", {
|
|
7895
7938
|
className: "ai-panel__arrow",
|
|
7896
|
-
style: { left: `${
|
|
7939
|
+
style: { left: `${ie}%` },
|
|
7897
7940
|
"aria-hidden": "true"
|
|
7898
|
-
}), /* @__PURE__ */ D(
|
|
7899
|
-
editor:
|
|
7941
|
+
}), /* @__PURE__ */ D(un, {
|
|
7942
|
+
editor: Y,
|
|
7900
7943
|
onClose: () => M(!1)
|
|
7901
7944
|
})]
|
|
7902
7945
|
})] }), document.body),
|
|
7903
|
-
|
|
7904
|
-
fallback: /* @__PURE__ */ D(
|
|
7905
|
-
children: /* @__PURE__ */ D(
|
|
7906
|
-
open:
|
|
7907
|
-
onClose: () =>
|
|
7908
|
-
onInsert:
|
|
7909
|
-
validate: (e) =>
|
|
7946
|
+
z && /* @__PURE__ */ D(v, {
|
|
7947
|
+
fallback: /* @__PURE__ */ D(ra, {}),
|
|
7948
|
+
children: /* @__PURE__ */ D(Qi, {
|
|
7949
|
+
open: z,
|
|
7950
|
+
onClose: () => B(!1),
|
|
7951
|
+
onInsert: ot,
|
|
7952
|
+
validate: (e) => Y ? hn(Y.state.doc, e, {
|
|
7910
7953
|
maxAttachmentSize: o,
|
|
7911
7954
|
maxTotalAttachmentSize: s
|
|
7912
7955
|
}) : null
|
|
7913
7956
|
})
|
|
7914
7957
|
}),
|
|
7915
|
-
|
|
7916
|
-
fallback: /* @__PURE__ */ D(
|
|
7917
|
-
children: /* @__PURE__ */ D(
|
|
7918
|
-
open:
|
|
7919
|
-
onClose: () =>
|
|
7920
|
-
onInsert:
|
|
7958
|
+
V && /* @__PURE__ */ D(v, {
|
|
7959
|
+
fallback: /* @__PURE__ */ D(ra, {}),
|
|
7960
|
+
children: /* @__PURE__ */ D(ta, {
|
|
7961
|
+
open: V,
|
|
7962
|
+
onClose: () => oe(!1),
|
|
7963
|
+
onInsert: st
|
|
7921
7964
|
})
|
|
7922
7965
|
}),
|
|
7923
|
-
|
|
7924
|
-
fallback: /* @__PURE__ */ D(
|
|
7925
|
-
children: /* @__PURE__ */ D(
|
|
7926
|
-
open:
|
|
7927
|
-
onClose: () =>
|
|
7966
|
+
se && /* @__PURE__ */ D(v, {
|
|
7967
|
+
fallback: /* @__PURE__ */ D(ra, {}),
|
|
7968
|
+
children: /* @__PURE__ */ D($i, {
|
|
7969
|
+
open: se,
|
|
7970
|
+
onClose: () => H(!1)
|
|
7928
7971
|
})
|
|
7929
7972
|
}),
|
|
7930
|
-
|
|
7931
|
-
fallback: /* @__PURE__ */ D(
|
|
7932
|
-
children: /* @__PURE__ */ D(
|
|
7933
|
-
open:
|
|
7934
|
-
onClose: () =>
|
|
7935
|
-
editor:
|
|
7973
|
+
U && /* @__PURE__ */ D(v, {
|
|
7974
|
+
fallback: /* @__PURE__ */ D(ra, {}),
|
|
7975
|
+
children: /* @__PURE__ */ D(ea, {
|
|
7976
|
+
open: U,
|
|
7977
|
+
onClose: () => ce(!1),
|
|
7978
|
+
editor: Y
|
|
7936
7979
|
})
|
|
7937
7980
|
}),
|
|
7938
|
-
|
|
7939
|
-
fallback: /* @__PURE__ */ D(
|
|
7940
|
-
children: /* @__PURE__ */ D(
|
|
7941
|
-
open: !!
|
|
7942
|
-
filename:
|
|
7981
|
+
q && /* @__PURE__ */ D(v, {
|
|
7982
|
+
fallback: /* @__PURE__ */ D(ra, {}),
|
|
7983
|
+
children: /* @__PURE__ */ D(na, {
|
|
7984
|
+
open: !!q,
|
|
7985
|
+
filename: q.filename,
|
|
7943
7986
|
onRender: () => {
|
|
7944
|
-
|
|
7987
|
+
q.resolve("render"), me(null);
|
|
7945
7988
|
},
|
|
7946
7989
|
onAttach: () => {
|
|
7947
|
-
|
|
7990
|
+
q.resolve("attach"), me(null);
|
|
7948
7991
|
},
|
|
7949
7992
|
onClose: () => {
|
|
7950
|
-
|
|
7993
|
+
q.resolve(null), me(null);
|
|
7951
7994
|
}
|
|
7952
7995
|
})
|
|
7953
7996
|
}),
|
|
7954
7997
|
/* @__PURE__ */ D("div", {
|
|
7955
|
-
ref:
|
|
7998
|
+
ref: De,
|
|
7956
7999
|
className: "flex editor-body",
|
|
7957
8000
|
children: /* @__PURE__ */ O("div", {
|
|
7958
8001
|
className: "relative min-w-0 flex-1",
|
|
7959
8002
|
children: [
|
|
7960
|
-
/* @__PURE__ */ D(ee, { editor:
|
|
7961
|
-
!k && /* @__PURE__ */ D(
|
|
8003
|
+
/* @__PURE__ */ D(ee, { editor: Y }),
|
|
8004
|
+
!k && /* @__PURE__ */ D(Wi, { editor: Y }),
|
|
7962
8005
|
/* @__PURE__ */ D("div", {
|
|
7963
|
-
className: `${
|
|
8006
|
+
className: `${J || Re ? "fixed" : "absolute"} bottom-2 right-4 z-10 pointer-events-none select-none`,
|
|
7964
8007
|
children: /* @__PURE__ */ O("span", {
|
|
7965
|
-
className: `text-xs ${
|
|
8008
|
+
className: `text-xs ${it ? "bg-danger/10 text-danger font-medium px-2 py-0.5 rounded" : a && rt > a * .9 ? "bg-warning/10 text-warning px-2 py-0.5 rounded" : "text-default-300"}`,
|
|
7966
8009
|
children: [
|
|
7967
|
-
|
|
8010
|
+
rt,
|
|
7968
8011
|
a ? ` / ${a}` : "",
|
|
7969
8012
|
" 字"
|
|
7970
8013
|
]
|
|
@@ -7973,14 +8016,14 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7973
8016
|
]
|
|
7974
8017
|
})
|
|
7975
8018
|
}),
|
|
7976
|
-
h &&
|
|
7977
|
-
editor:
|
|
7978
|
-
onClose: () =>
|
|
8019
|
+
h && ye && /* @__PURE__ */ D(Mt, {
|
|
8020
|
+
editor: Y,
|
|
8021
|
+
onClose: () => be(!1)
|
|
7979
8022
|
}),
|
|
7980
|
-
|
|
8023
|
+
dt && /* @__PURE__ */ D("button", {
|
|
7981
8024
|
type: "button",
|
|
7982
8025
|
className: "qingwu-toc-fab",
|
|
7983
|
-
onClick: () =>
|
|
8026
|
+
onClick: () => ve(!0),
|
|
7984
8027
|
title: "目录",
|
|
7985
8028
|
"aria-label": "打开目录",
|
|
7986
8029
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -7996,8 +8039,8 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7996
8039
|
})
|
|
7997
8040
|
})
|
|
7998
8041
|
}),
|
|
7999
|
-
|
|
8000
|
-
ref:
|
|
8042
|
+
_e && re(/* @__PURE__ */ O("div", {
|
|
8043
|
+
ref: Be,
|
|
8001
8044
|
className: "qingwu-toc-drawer toc-scroll",
|
|
8002
8045
|
"data-lenis-prevent": !0,
|
|
8003
8046
|
children: [/* @__PURE__ */ O("div", {
|
|
@@ -8008,7 +8051,7 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
8008
8051
|
}), /* @__PURE__ */ D("button", {
|
|
8009
8052
|
type: "button",
|
|
8010
8053
|
className: "qed-drawer-head__close",
|
|
8011
|
-
onClick: () =>
|
|
8054
|
+
onClick: () => ve(!1),
|
|
8012
8055
|
"aria-label": "关闭目录",
|
|
8013
8056
|
children: /* @__PURE__ */ D("svg", {
|
|
8014
8057
|
fill: "none",
|
|
@@ -8024,20 +8067,20 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
8024
8067
|
})
|
|
8025
8068
|
})]
|
|
8026
8069
|
}), /* @__PURE__ */ D(mt, {
|
|
8027
|
-
editor:
|
|
8070
|
+
editor: Y,
|
|
8028
8071
|
className: "!p-3",
|
|
8029
8072
|
onClose: () => {
|
|
8030
|
-
|
|
8073
|
+
ve(!1), ge(!1);
|
|
8031
8074
|
}
|
|
8032
8075
|
})]
|
|
8033
8076
|
}), document.body)
|
|
8034
8077
|
]
|
|
8035
|
-
}),
|
|
8036
|
-
ref:
|
|
8078
|
+
}), ct && re(/* @__PURE__ */ D("aside", {
|
|
8079
|
+
ref: je,
|
|
8037
8080
|
className: "qingwu-toc-desktop toc-scroll",
|
|
8038
8081
|
children: /* @__PURE__ */ D(mt, {
|
|
8039
|
-
editor:
|
|
8040
|
-
onClose: () =>
|
|
8082
|
+
editor: Y,
|
|
8083
|
+
onClose: () => ge(!1)
|
|
8041
8084
|
})
|
|
8042
8085
|
}), document.body)]
|
|
8043
8086
|
}) : /* @__PURE__ */ D("div", {
|
|
@@ -8047,7 +8090,7 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
8047
8090
|
};
|
|
8048
8091
|
//#endregion
|
|
8049
8092
|
//#region src/editor/clipper/receiver-browser.ts
|
|
8050
|
-
function
|
|
8093
|
+
function aa(e) {
|
|
8051
8094
|
let t = async (t) => {
|
|
8052
8095
|
let n = t.data;
|
|
8053
8096
|
if (!n || typeof n != "object" || n.kind !== "qingwu-clip") return;
|
|
@@ -8064,7 +8107,7 @@ function na(e) {
|
|
|
8064
8107
|
}
|
|
8065
8108
|
//#endregion
|
|
8066
8109
|
//#region src/editor/storage/providers/cos.ts
|
|
8067
|
-
function
|
|
8110
|
+
function oa(e) {
|
|
8068
8111
|
return g({
|
|
8069
8112
|
endpoint: `https://cos.${e.region}.myqcloud.com`,
|
|
8070
8113
|
bucket: e.bucket,
|
|
@@ -8078,7 +8121,7 @@ function ra(e) {
|
|
|
8078
8121
|
}
|
|
8079
8122
|
//#endregion
|
|
8080
8123
|
//#region src/editor/storage/providers/oss.ts
|
|
8081
|
-
function
|
|
8124
|
+
function sa(e) {
|
|
8082
8125
|
return g({
|
|
8083
8126
|
endpoint: `https://${e.bucket}.${e.region}.aliyuncs.com`,
|
|
8084
8127
|
bucket: e.bucket,
|
|
@@ -8091,4 +8134,4 @@ function ia(e) {
|
|
|
8091
8134
|
});
|
|
8092
8135
|
}
|
|
8093
8136
|
//#endregion
|
|
8094
|
-
export {
|
|
8137
|
+
export { cr as CODE_LANGUAGES, mr as CodeBlock, Rr as ImageUpload, rt as ImageUploadDialog, ni as MathBlock, ti as MathInline, ia as QingWuAIEditor, Di as RelativeMedia, At as SearchHighlight, mt as TocPanel, Zn as VideoEmbed, ht as buildSystemPrompt, _t as createAILanguageModelProvider, oa as createCOSStorage, xt as createDeepSeekProvider, _ as createLocalStorage, sa as createOSSStorage, bt as createOpenAICompatProvider, St as createOpenAIProvider, Ct as createQwenProvider, g as createS3Storage, ki as createSlashCommandExtension, h as escapeHtml, pn as formatBytes, yt as getAIProvider, Ri as getBubbleMenuActions, Ai as getDefaultSlashCommands, fn as getDocAttachmentTotal, Mi as getEditorExtensions, u as getLocale, Li as getSearchEngine, jt as getSearchState, c as getStorageInfo, o as getStorageProvider, s as loadStorageConfig, r as registerS3PreviewConfig, d as sanitizeHtml, p as sanitizeSvg, vt as setAIProvider, xn as setConfirmProvider, l as setLocale, Ii as setSearchEngine, i as setStorageProvider, et as setToastProvider, n as signPreviewUrlHeaders, aa as startBrowserClipperReceiver, tt as subscribeToast, f as t, m as tf, Z as toast, hn as validateAttachmentFile };
|