@qingwu-ui/ai-editor 1.1.3 → 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/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/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 +966 -917
- 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/package.json +1 -1
- 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,14 +4295,14 @@ var Xn = ie.create({
|
|
|
4292
4295
|
}).focus().run();
|
|
4293
4296
|
} };
|
|
4294
4297
|
}
|
|
4295
|
-
}),
|
|
4298
|
+
}), Qn = null, $n = {
|
|
4296
4299
|
fontFamily: "Inter, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', system-ui, sans-serif",
|
|
4297
4300
|
padding: 24
|
|
4298
|
-
},
|
|
4299
|
-
async function
|
|
4300
|
-
return
|
|
4301
|
+
}, er = .25, tr = 4, nr = .25;
|
|
4302
|
+
async function rr(e) {
|
|
4303
|
+
return Qn ||= await import("pele"), Qn.render(e, $n).svg;
|
|
4301
4304
|
}
|
|
4302
|
-
var
|
|
4305
|
+
var ir = [
|
|
4303
4306
|
{
|
|
4304
4307
|
value: "javascript",
|
|
4305
4308
|
label: "JavaScript",
|
|
@@ -4460,7 +4463,7 @@ var rr = [
|
|
|
4460
4463
|
label: "Plain Text",
|
|
4461
4464
|
color: "#6b7280"
|
|
4462
4465
|
}
|
|
4463
|
-
],
|
|
4466
|
+
], ar = {
|
|
4464
4467
|
javascript: "js",
|
|
4465
4468
|
typescript: "ts",
|
|
4466
4469
|
python: "py",
|
|
@@ -4486,7 +4489,7 @@ var rr = [
|
|
|
4486
4489
|
txt: "txt",
|
|
4487
4490
|
vue: "vue",
|
|
4488
4491
|
react: "jsx"
|
|
4489
|
-
},
|
|
4492
|
+
}, or = {
|
|
4490
4493
|
js: "javascript",
|
|
4491
4494
|
ts: "typescript",
|
|
4492
4495
|
py: "python",
|
|
@@ -4502,51 +4505,51 @@ var rr = [
|
|
|
4502
4505
|
jsx: "javascript",
|
|
4503
4506
|
tsx: "typescript"
|
|
4504
4507
|
};
|
|
4505
|
-
function
|
|
4508
|
+
function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i, selected: a }) {
|
|
4506
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({
|
|
4507
4510
|
top: 0,
|
|
4508
4511
|
left: 0,
|
|
4509
4512
|
width: 210
|
|
4510
|
-
}), [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({
|
|
4511
4514
|
x: 0,
|
|
4512
4515
|
y: 0
|
|
4513
|
-
}), [
|
|
4514
|
-
|
|
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({
|
|
4515
4518
|
x: 0,
|
|
4516
4519
|
y: 0
|
|
4517
4520
|
});
|
|
4518
|
-
},
|
|
4519
|
-
|
|
4521
|
+
}, q = () => {
|
|
4522
|
+
pe(), L(!0);
|
|
4520
4523
|
};
|
|
4521
4524
|
x(() => {
|
|
4522
|
-
N ||
|
|
4525
|
+
N || L(!1);
|
|
4523
4526
|
}, [N]), x(() => {
|
|
4524
4527
|
if (!ne) return;
|
|
4525
4528
|
let e = document.body.style.overflow;
|
|
4526
4529
|
document.body.style.overflow = "hidden";
|
|
4527
4530
|
let t = (e) => {
|
|
4528
|
-
e.key === "Escape" &&
|
|
4531
|
+
e.key === "Escape" && L(!1);
|
|
4529
4532
|
};
|
|
4530
4533
|
return window.addEventListener("keydown", t), () => {
|
|
4531
4534
|
document.body.style.overflow = e, window.removeEventListener("keydown", t);
|
|
4532
4535
|
};
|
|
4533
4536
|
}, [ne]);
|
|
4534
|
-
let
|
|
4535
|
-
e.button === 0 && (e.currentTarget.setPointerCapture(e.pointerId),
|
|
4537
|
+
let me = (e) => {
|
|
4538
|
+
e.button === 0 && (e.currentTarget.setPointerCapture(e.pointerId), oe.current = {
|
|
4536
4539
|
x: e.clientX,
|
|
4537
4540
|
y: e.clientY,
|
|
4538
|
-
panX:
|
|
4539
|
-
panY:
|
|
4540
|
-
},
|
|
4541
|
-
},
|
|
4542
|
-
let t =
|
|
4543
|
-
t &&
|
|
4541
|
+
panX: R.x,
|
|
4542
|
+
panY: R.y
|
|
4543
|
+
}, V(!0));
|
|
4544
|
+
}, he = (e) => {
|
|
4545
|
+
let t = oe.current;
|
|
4546
|
+
t && z({
|
|
4544
4547
|
x: t.panX + e.clientX - t.x,
|
|
4545
4548
|
y: t.panY + e.clientY - t.y
|
|
4546
4549
|
});
|
|
4547
|
-
},
|
|
4548
|
-
|
|
4549
|
-
},
|
|
4550
|
+
}, ge = () => {
|
|
4551
|
+
oe.current = null, V(!1);
|
|
4552
|
+
}, _e = b(() => {
|
|
4550
4553
|
if (!n || typeof r != "function") return null;
|
|
4551
4554
|
let t = r();
|
|
4552
4555
|
return typeof t == "number" ? {
|
|
@@ -4557,19 +4560,19 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4557
4560
|
n,
|
|
4558
4561
|
r,
|
|
4559
4562
|
e.nodeSize
|
|
4560
|
-
]),
|
|
4561
|
-
o && (
|
|
4562
|
-
}, [
|
|
4563
|
+
]), ve = b(() => {
|
|
4564
|
+
o && (yn() || (G.current = _e(), window.getSelection()?.removeAllRanges(), $(!0), M(!0)));
|
|
4565
|
+
}, [_e, o]), ye = C(() => {
|
|
4563
4566
|
let e = k.trim().toLowerCase();
|
|
4564
|
-
return e ?
|
|
4567
|
+
return e ? ir.filter((t) => t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e)) : ir;
|
|
4565
4568
|
}, [k]);
|
|
4566
4569
|
x(() => {
|
|
4567
|
-
(
|
|
4570
|
+
(W.current?.closest(".code-block-node-view"))?.classList.toggle("code-block-node-view--collapsed", u);
|
|
4568
4571
|
}, [u]);
|
|
4569
|
-
let
|
|
4570
|
-
let e =
|
|
4572
|
+
let be = b(() => {
|
|
4573
|
+
let e = U.current;
|
|
4571
4574
|
if (!e) return;
|
|
4572
|
-
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;
|
|
4573
4576
|
o < 220 && s > o ? (g(!0), v(Math.max(120, Math.min(a, s))), S({
|
|
4574
4577
|
top: t.top,
|
|
4575
4578
|
left: n,
|
|
@@ -4582,16 +4585,16 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4582
4585
|
}, []);
|
|
4583
4586
|
x(() => {
|
|
4584
4587
|
if (!f) return;
|
|
4585
|
-
A(""),
|
|
4586
|
-
let e = setTimeout(() =>
|
|
4587
|
-
return window.addEventListener("resize",
|
|
4588
|
-
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);
|
|
4589
4592
|
};
|
|
4590
|
-
}, [f,
|
|
4593
|
+
}, [f, be]), x(() => {
|
|
4591
4594
|
if (!f) return;
|
|
4592
4595
|
let e = (e) => {
|
|
4593
4596
|
let t = e.target;
|
|
4594
|
-
t && (
|
|
4597
|
+
t && (U.current?.contains(t) || H.current?.contains(t) || m(!1));
|
|
4595
4598
|
};
|
|
4596
4599
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
4597
4600
|
}, [f]), x(() => {
|
|
@@ -4602,12 +4605,12 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4602
4605
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
4603
4606
|
}, [f]), x(() => {
|
|
4604
4607
|
let e = (e) => {
|
|
4605
|
-
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !a ||
|
|
4608
|
+
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !a || yn()) return;
|
|
4606
4609
|
let t = n?.view?.dom, r = e.target;
|
|
4607
4610
|
if (n?.isFocused && r instanceof Node && t?.contains(r)) {
|
|
4608
4611
|
if (e.preventDefault(), e.stopPropagation(), n) {
|
|
4609
4612
|
let { from: e, to: t } = n.state.selection;
|
|
4610
|
-
|
|
4613
|
+
G.current = {
|
|
4611
4614
|
from: e,
|
|
4612
4615
|
to: t
|
|
4613
4616
|
};
|
|
@@ -4621,9 +4624,9 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4621
4624
|
n,
|
|
4622
4625
|
o
|
|
4623
4626
|
]);
|
|
4624
|
-
let
|
|
4627
|
+
let xe = b((e) => {
|
|
4625
4628
|
t({ language: e || null }), m(!1);
|
|
4626
|
-
}, [t]),
|
|
4629
|
+
}, [t]), Se = b(() => {
|
|
4627
4630
|
if (o) {
|
|
4628
4631
|
if (n && r) {
|
|
4629
4632
|
let e = r();
|
|
@@ -4635,7 +4638,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4635
4638
|
n,
|
|
4636
4639
|
r,
|
|
4637
4640
|
o
|
|
4638
|
-
]),
|
|
4641
|
+
]), Ce = b(() => {
|
|
4639
4642
|
let t = e.textContent, n = (e) => {
|
|
4640
4643
|
let t = document.createElement("textarea");
|
|
4641
4644
|
t.value = e, t.style.position = "fixed", t.style.opacity = "0", document.body.appendChild(t), t.select();
|
|
@@ -4645,10 +4648,10 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4645
4648
|
document.body.removeChild(t);
|
|
4646
4649
|
};
|
|
4647
4650
|
navigator.clipboard?.writeText ? navigator.clipboard.writeText(t).catch(() => n(t)) : n(t), l(!0), setTimeout(() => l(!1), 1500);
|
|
4648
|
-
}, [e.textContent]),
|
|
4649
|
-
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");
|
|
4650
4653
|
a.href = i, a.download = n, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
4651
|
-
}, [e.textContent,
|
|
4654
|
+
}, [e.textContent, le]), Te = b(async () => {
|
|
4652
4655
|
if (N || I) {
|
|
4653
4656
|
ee(null), F(null), te(!1);
|
|
4654
4657
|
return;
|
|
@@ -4660,7 +4663,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4660
4663
|
F("代码块内容为空");
|
|
4661
4664
|
return;
|
|
4662
4665
|
}
|
|
4663
|
-
let n = p(await
|
|
4666
|
+
let n = p(await rr(t));
|
|
4664
4667
|
ee(n);
|
|
4665
4668
|
} catch (e) {
|
|
4666
4669
|
F(e instanceof Error ? e.message : "图表渲染失败");
|
|
@@ -4671,9 +4674,9 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4671
4674
|
e.textContent,
|
|
4672
4675
|
N,
|
|
4673
4676
|
I
|
|
4674
|
-
]),
|
|
4675
|
-
className: `${
|
|
4676
|
-
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 }
|
|
4677
4680
|
}) : /* @__PURE__ */ D("span", {
|
|
4678
4681
|
className: "cb-lang-icon cb-lang-icon--auto",
|
|
4679
4682
|
children: "Tx"
|
|
@@ -4682,10 +4685,10 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4682
4685
|
children: "?"
|
|
4683
4686
|
}), /* @__PURE__ */ D("span", {
|
|
4684
4687
|
className: "cb-lang-label",
|
|
4685
|
-
children:
|
|
4688
|
+
children: K?.label || "自动"
|
|
4686
4689
|
})] });
|
|
4687
4690
|
return /* @__PURE__ */ O("div", {
|
|
4688
|
-
ref:
|
|
4691
|
+
ref: W,
|
|
4689
4692
|
className: "cb-react-shell group/cb",
|
|
4690
4693
|
style: { display: "contents" },
|
|
4691
4694
|
children: [
|
|
@@ -4696,17 +4699,17 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4696
4699
|
children: [
|
|
4697
4700
|
/* @__PURE__ */ D("div", {
|
|
4698
4701
|
className: "cb-lang-wrap",
|
|
4699
|
-
ref:
|
|
4702
|
+
ref: se,
|
|
4700
4703
|
contentEditable: !1,
|
|
4701
4704
|
children: s ? /* @__PURE__ */ D("span", {
|
|
4702
4705
|
className: "cb-lang-trigger cb-lang-trigger--static",
|
|
4703
|
-
children:
|
|
4706
|
+
children: Ee
|
|
4704
4707
|
}) : /* @__PURE__ */ O("button", {
|
|
4705
|
-
ref:
|
|
4708
|
+
ref: U,
|
|
4706
4709
|
type: "button",
|
|
4707
4710
|
className: "cb-lang-trigger",
|
|
4708
4711
|
onClick: () => m(!f),
|
|
4709
|
-
children: [
|
|
4712
|
+
children: [Ee, /* @__PURE__ */ D("svg", {
|
|
4710
4713
|
className: `cb-lang-chevron${f ? " cb-lang-chevron--open" : ""}`,
|
|
4711
4714
|
width: "10",
|
|
4712
4715
|
height: "10",
|
|
@@ -4728,7 +4731,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4728
4731
|
contentEditable: !1,
|
|
4729
4732
|
onClick: () => d(!1),
|
|
4730
4733
|
title: "展开代码块",
|
|
4731
|
-
children: [
|
|
4734
|
+
children: [Ee, /* @__PURE__ */ D("svg", {
|
|
4732
4735
|
className: "cb-lang-chevron",
|
|
4733
4736
|
width: "12",
|
|
4734
4737
|
height: "12",
|
|
@@ -4743,8 +4746,8 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4743
4746
|
})
|
|
4744
4747
|
})]
|
|
4745
4748
|
}),
|
|
4746
|
-
o && f &&
|
|
4747
|
-
ref:
|
|
4749
|
+
o && f && re(/* @__PURE__ */ O("div", {
|
|
4750
|
+
ref: H,
|
|
4748
4751
|
className: `cb-lang-dropdown${h ? " cb-lang-dropdown--up" : ""}`,
|
|
4749
4752
|
style: {
|
|
4750
4753
|
position: "fixed",
|
|
@@ -4769,7 +4772,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4769
4772
|
d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
|
4770
4773
|
})
|
|
4771
4774
|
}), /* @__PURE__ */ D("input", {
|
|
4772
|
-
ref:
|
|
4775
|
+
ref: ce,
|
|
4773
4776
|
className: "cb-lang-search",
|
|
4774
4777
|
type: "text",
|
|
4775
4778
|
placeholder: "搜索语言...",
|
|
@@ -4783,17 +4786,17 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4783
4786
|
children: [
|
|
4784
4787
|
/* @__PURE__ */ O("button", {
|
|
4785
4788
|
type: "button",
|
|
4786
|
-
className: `cb-lang-option${
|
|
4787
|
-
onClick: () =>
|
|
4789
|
+
className: `cb-lang-option${le ? "" : " cb-lang-option--active"}`,
|
|
4790
|
+
onClick: () => xe(""),
|
|
4788
4791
|
children: [/* @__PURE__ */ D("span", {
|
|
4789
4792
|
className: "cb-lang-icon cb-lang-icon--auto",
|
|
4790
4793
|
children: "?"
|
|
4791
4794
|
}), /* @__PURE__ */ D("span", { children: "自动检测" })]
|
|
4792
4795
|
}),
|
|
4793
|
-
|
|
4796
|
+
ye.map((e) => /* @__PURE__ */ O("button", {
|
|
4794
4797
|
type: "button",
|
|
4795
|
-
className: `cb-lang-option${
|
|
4796
|
-
onClick: () =>
|
|
4798
|
+
className: `cb-lang-option${le === e.value ? " cb-lang-option--active" : ""}`,
|
|
4799
|
+
onClick: () => xe(e.value),
|
|
4797
4800
|
children: [e.deviconClass ? /* @__PURE__ */ D("i", {
|
|
4798
4801
|
className: `${e.deviconClass} colored cb-lang-icon`,
|
|
4799
4802
|
style: { color: e.color }
|
|
@@ -4802,7 +4805,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4802
4805
|
children: "Tx"
|
|
4803
4806
|
}), /* @__PURE__ */ D("span", { children: e.label })]
|
|
4804
4807
|
}, e.value)),
|
|
4805
|
-
|
|
4808
|
+
ye.length === 0 && /* @__PURE__ */ D("div", {
|
|
4806
4809
|
className: "cb-lang-empty",
|
|
4807
4810
|
children: "无匹配语言"
|
|
4808
4811
|
})
|
|
@@ -4838,7 +4841,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4838
4841
|
/* @__PURE__ */ D("button", {
|
|
4839
4842
|
type: "button",
|
|
4840
4843
|
className: "cb-btn",
|
|
4841
|
-
onClick:
|
|
4844
|
+
onClick: Ce,
|
|
4842
4845
|
contentEditable: !1,
|
|
4843
4846
|
title: "复制",
|
|
4844
4847
|
children: c ? /* @__PURE__ */ D("svg", {
|
|
@@ -4868,7 +4871,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4868
4871
|
/* @__PURE__ */ D("button", {
|
|
4869
4872
|
type: "button",
|
|
4870
4873
|
className: "cb-btn",
|
|
4871
|
-
onClick:
|
|
4874
|
+
onClick: we,
|
|
4872
4875
|
contentEditable: !1,
|
|
4873
4876
|
title: "下载",
|
|
4874
4877
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4887,7 +4890,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4887
4890
|
o && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("button", {
|
|
4888
4891
|
type: "button",
|
|
4889
4892
|
className: "cb-btn cb-btn--ai",
|
|
4890
|
-
onClick:
|
|
4893
|
+
onClick: Se,
|
|
4891
4894
|
contentEditable: !1,
|
|
4892
4895
|
title: "写作助手",
|
|
4893
4896
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4905,7 +4908,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4905
4908
|
}), /* @__PURE__ */ D("button", {
|
|
4906
4909
|
type: "button",
|
|
4907
4910
|
className: "cb-btn cb-btn--del",
|
|
4908
|
-
onClick:
|
|
4911
|
+
onClick: ve,
|
|
4909
4912
|
contentEditable: !1,
|
|
4910
4913
|
title: "删除代码块",
|
|
4911
4914
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4921,10 +4924,10 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4921
4924
|
})
|
|
4922
4925
|
})
|
|
4923
4926
|
})] }),
|
|
4924
|
-
|
|
4927
|
+
ue && /* @__PURE__ */ D("button", {
|
|
4925
4928
|
type: "button",
|
|
4926
4929
|
className: "cb-btn cb-btn--diagram",
|
|
4927
|
-
onClick:
|
|
4930
|
+
onClick: Te,
|
|
4928
4931
|
contentEditable: !1,
|
|
4929
4932
|
title: N || I ? "取消渲染" : "渲染图表",
|
|
4930
4933
|
disabled: I,
|
|
@@ -4965,9 +4968,9 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4965
4968
|
role: "button",
|
|
4966
4969
|
tabIndex: 0,
|
|
4967
4970
|
title: "点击放大查看",
|
|
4968
|
-
onClick:
|
|
4971
|
+
onClick: q,
|
|
4969
4972
|
onKeyDown: (e) => {
|
|
4970
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
4973
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), q());
|
|
4971
4974
|
},
|
|
4972
4975
|
children: [/* @__PURE__ */ D("div", {
|
|
4973
4976
|
className: "cb-diagram-svg-inner",
|
|
@@ -4979,7 +4982,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4979
4982
|
})
|
|
4980
4983
|
]
|
|
4981
4984
|
}),
|
|
4982
|
-
ne && N &&
|
|
4985
|
+
ne && N && re(/* @__PURE__ */ O("div", {
|
|
4983
4986
|
className: "fixed inset-0 z-[10002] flex flex-col bg-black/75 backdrop-blur-sm select-none",
|
|
4984
4987
|
role: "dialog",
|
|
4985
4988
|
"aria-modal": "true",
|
|
@@ -4995,7 +4998,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4995
4998
|
/* @__PURE__ */ D("button", {
|
|
4996
4999
|
type: "button",
|
|
4997
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",
|
|
4998
|
-
onClick: () =>
|
|
5001
|
+
onClick: () => fe(-.25),
|
|
4999
5002
|
title: "缩小",
|
|
5000
5003
|
"aria-label": "缩小",
|
|
5001
5004
|
children: "−"
|
|
@@ -5003,15 +5006,15 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5003
5006
|
/* @__PURE__ */ O("button", {
|
|
5004
5007
|
type: "button",
|
|
5005
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",
|
|
5006
|
-
onClick:
|
|
5009
|
+
onClick: pe,
|
|
5007
5010
|
title: "重置为 100%",
|
|
5008
5011
|
"aria-label": "重置缩放",
|
|
5009
|
-
children: [Math.round(
|
|
5012
|
+
children: [Math.round(ie * 100), "%"]
|
|
5010
5013
|
}),
|
|
5011
5014
|
/* @__PURE__ */ D("button", {
|
|
5012
5015
|
type: "button",
|
|
5013
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",
|
|
5014
|
-
onClick: () =>
|
|
5017
|
+
onClick: () => fe(nr),
|
|
5015
5018
|
title: "放大",
|
|
5016
5019
|
"aria-label": "放大",
|
|
5017
5020
|
children: "+"
|
|
@@ -5019,7 +5022,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5019
5022
|
/* @__PURE__ */ D("button", {
|
|
5020
5023
|
type: "button",
|
|
5021
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",
|
|
5022
|
-
onClick:
|
|
5025
|
+
onClick: pe,
|
|
5023
5026
|
title: "重置",
|
|
5024
5027
|
"aria-label": "重置",
|
|
5025
5028
|
children: "⟲"
|
|
@@ -5028,7 +5031,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5028
5031
|
/* @__PURE__ */ D("button", {
|
|
5029
5032
|
type: "button",
|
|
5030
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",
|
|
5031
|
-
onClick: () =>
|
|
5034
|
+
onClick: () => L(!1),
|
|
5032
5035
|
title: "关闭",
|
|
5033
5036
|
"aria-label": "关闭",
|
|
5034
5037
|
children: "×"
|
|
@@ -5037,14 +5040,14 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5037
5040
|
})]
|
|
5038
5041
|
}), /* @__PURE__ */ D("div", {
|
|
5039
5042
|
className: "flex flex-1 touch-none items-center justify-center overflow-hidden",
|
|
5040
|
-
style: { cursor:
|
|
5041
|
-
onWheel: (e) =>
|
|
5042
|
-
onPointerDown:
|
|
5043
|
-
onPointerMove:
|
|
5044
|
-
onPointerUp:
|
|
5045
|
-
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,
|
|
5046
5049
|
onDoubleClick: () => {
|
|
5047
|
-
|
|
5050
|
+
ae((e) => e === 1 ? 2 : 1), z({
|
|
5048
5051
|
x: 0,
|
|
5049
5052
|
y: 0
|
|
5050
5053
|
});
|
|
@@ -5052,14 +5055,14 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5052
5055
|
children: /* @__PURE__ */ D("div", {
|
|
5053
5056
|
className: "cb-diagram-zoom-content",
|
|
5054
5057
|
style: {
|
|
5055
|
-
transform: `translate(${
|
|
5056
|
-
transition:
|
|
5058
|
+
transform: `translate(${R.x}px, ${R.y}px) scale(${ie})`,
|
|
5059
|
+
transition: B ? "none" : "transform 120ms ease-out"
|
|
5057
5060
|
},
|
|
5058
5061
|
dangerouslySetInnerHTML: { __html: N }
|
|
5059
5062
|
})
|
|
5060
5063
|
})]
|
|
5061
5064
|
}), document.body),
|
|
5062
|
-
/* @__PURE__ */ D(
|
|
5065
|
+
/* @__PURE__ */ D(wn, {
|
|
5063
5066
|
open: j,
|
|
5064
5067
|
title: "确认删除代码块",
|
|
5065
5068
|
message: "此操作不可撤销。",
|
|
@@ -5075,7 +5078,7 @@ function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5075
5078
|
}
|
|
5076
5079
|
//#endregion
|
|
5077
5080
|
//#region src/editor/extensions/code-block.ts
|
|
5078
|
-
var
|
|
5081
|
+
var cr = [
|
|
5079
5082
|
{
|
|
5080
5083
|
value: "javascript",
|
|
5081
5084
|
label: "JavaScript"
|
|
@@ -5176,12 +5179,12 @@ var sr = [
|
|
|
5176
5179
|
value: "mermaid",
|
|
5177
5180
|
label: "Mermaid"
|
|
5178
5181
|
}
|
|
5179
|
-
],
|
|
5180
|
-
|
|
5181
|
-
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) {
|
|
5182
5185
|
return e ? e.split("\n") : [""];
|
|
5183
5186
|
}
|
|
5184
|
-
function
|
|
5187
|
+
function dr(e, t) {
|
|
5185
5188
|
if (e.childElementCount !== t) {
|
|
5186
5189
|
e.replaceChildren();
|
|
5187
5190
|
for (let n = 1; n <= t; n++) {
|
|
@@ -5190,14 +5193,14 @@ function ur(e, t) {
|
|
|
5190
5193
|
}
|
|
5191
5194
|
}
|
|
5192
5195
|
}
|
|
5193
|
-
function
|
|
5196
|
+
function fr(e, t) {
|
|
5194
5197
|
e.replaceChildren();
|
|
5195
5198
|
for (let n of t) {
|
|
5196
5199
|
let t = document.createElement("span");
|
|
5197
5200
|
t.className = "cb-mirror-line", t.textContent = n.length ? n : "\xA0", e.appendChild(t);
|
|
5198
5201
|
}
|
|
5199
5202
|
}
|
|
5200
|
-
function
|
|
5203
|
+
function pr(e, t, n) {
|
|
5201
5204
|
let r = getComputedStyle(e), i = parseFloat(r.paddingLeft), a = parseFloat(r.paddingRight);
|
|
5202
5205
|
t.style.boxSizing = "content-box", t.style.width = `${Math.max(0, e.clientWidth - i - a)}px`, t.style.padding = r.padding;
|
|
5203
5206
|
let o = getComputedStyle(n);
|
|
@@ -5244,7 +5247,7 @@ function fr(e, t, n) {
|
|
|
5244
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;
|
|
5245
5248
|
}
|
|
5246
5249
|
}
|
|
5247
|
-
var
|
|
5250
|
+
var mr = be.extend({
|
|
5248
5251
|
addNodeView() {
|
|
5249
5252
|
return (e) => {
|
|
5250
5253
|
let { node: t, editor: n, getPos: r } = e, i = t, a = (e) => {
|
|
@@ -5272,9 +5275,9 @@ var pr = ye.extend({
|
|
|
5272
5275
|
f.appendChild(p);
|
|
5273
5276
|
let m = document.createElement("div");
|
|
5274
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);
|
|
5275
|
-
let h =
|
|
5276
|
-
|
|
5277
|
-
let g = new I(
|
|
5278
|
+
let h = ur(t.textContent);
|
|
5279
|
+
dr(d, h.length), fr(m, h);
|
|
5280
|
+
let g = new I(sr, {
|
|
5278
5281
|
editor: n,
|
|
5279
5282
|
props: {
|
|
5280
5283
|
node: t,
|
|
@@ -5287,12 +5290,12 @@ var pr = ye.extend({
|
|
|
5287
5290
|
});
|
|
5288
5291
|
c.appendChild(g.element);
|
|
5289
5292
|
let _ = (e) => {
|
|
5290
|
-
let t =
|
|
5291
|
-
|
|
5293
|
+
let t = ur(e.textContent);
|
|
5294
|
+
dr(d, t.length), fr(m, t), requestAnimationFrame(() => pr(f, m, d));
|
|
5292
5295
|
};
|
|
5293
|
-
requestAnimationFrame(() =>
|
|
5294
|
-
let v = new ResizeObserver(() =>
|
|
5295
|
-
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)), {
|
|
5296
5299
|
dom: s,
|
|
5297
5300
|
contentDOM: p,
|
|
5298
5301
|
update(e) {
|
|
@@ -5352,10 +5355,10 @@ var pr = ye.extend({
|
|
|
5352
5355
|
}
|
|
5353
5356
|
}));
|
|
5354
5357
|
}
|
|
5355
|
-
}).configure({ lowlight:
|
|
5358
|
+
}).configure({ lowlight: lr });
|
|
5356
5359
|
//#endregion
|
|
5357
5360
|
//#region src/editor/utils/import-choice-dialog.ts
|
|
5358
|
-
function
|
|
5361
|
+
function hr(e) {
|
|
5359
5362
|
return new Promise((t) => {
|
|
5360
5363
|
let n = document.createElement("div");
|
|
5361
5364
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5385,16 +5388,16 @@ function mr(e) {
|
|
|
5385
5388
|
}
|
|
5386
5389
|
//#endregion
|
|
5387
5390
|
//#region src/editor/utils/local-media.ts
|
|
5388
|
-
var
|
|
5389
|
-
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) {
|
|
5390
5393
|
if (!e) return !1;
|
|
5391
5394
|
let t = e.trim();
|
|
5392
|
-
return !(!t || /^(?:https?:)?\/\//i.test(t) ||
|
|
5393
|
-
}
|
|
5394
|
-
function vr(e) {
|
|
5395
|
-
return hr.test(e);
|
|
5395
|
+
return !(!t || /^(?:https?:)?\/\//i.test(t) || _r.test(t) || t.startsWith("#"));
|
|
5396
5396
|
}
|
|
5397
5397
|
function yr(e) {
|
|
5398
|
+
return gr.test(e);
|
|
5399
|
+
}
|
|
5400
|
+
function br(e) {
|
|
5398
5401
|
let t = e.trim();
|
|
5399
5402
|
t = t.replace(/^(?:file|app):\/\/(?:localhost)?/i, "");
|
|
5400
5403
|
try {
|
|
@@ -5402,26 +5405,26 @@ function yr(e) {
|
|
|
5402
5405
|
} catch {}
|
|
5403
5406
|
return t = t.replace(/\\/g, "/"), t = t.replace(/^\.\//, ""), t = t.replace(/^\/+/, ""), t = t.replace(/^[a-zA-Z]:\//, ""), t;
|
|
5404
5407
|
}
|
|
5405
|
-
function
|
|
5406
|
-
let t =
|
|
5408
|
+
function xr(e) {
|
|
5409
|
+
let t = br(e), n = t.split("/").filter(Boolean);
|
|
5407
5410
|
return (n[n.length - 1] || t).toLowerCase();
|
|
5408
5411
|
}
|
|
5409
|
-
function
|
|
5412
|
+
function Sr() {
|
|
5410
5413
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showDirectoryPicker == "function";
|
|
5411
5414
|
}
|
|
5412
|
-
async function
|
|
5413
|
-
if (!
|
|
5415
|
+
async function Cr() {
|
|
5416
|
+
if (!Sr()) return null;
|
|
5414
5417
|
try {
|
|
5415
5418
|
return await window.showDirectoryPicker.call(window, { mode: "read" }) ?? null;
|
|
5416
5419
|
} catch {
|
|
5417
5420
|
return null;
|
|
5418
5421
|
}
|
|
5419
5422
|
}
|
|
5420
|
-
function
|
|
5423
|
+
function wr() {
|
|
5421
5424
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showOpenFilePicker == "function";
|
|
5422
5425
|
}
|
|
5423
|
-
async function
|
|
5424
|
-
if (!
|
|
5426
|
+
async function Tr() {
|
|
5427
|
+
if (!wr()) return null;
|
|
5425
5428
|
try {
|
|
5426
5429
|
let e = await window.showOpenFilePicker.call(window, { multiple: !0 });
|
|
5427
5430
|
return await Promise.all(e.map((e) => e.getFile()));
|
|
@@ -5429,7 +5432,7 @@ async function wr() {
|
|
|
5429
5432
|
return null;
|
|
5430
5433
|
}
|
|
5431
5434
|
}
|
|
5432
|
-
async function
|
|
5435
|
+
async function Er(e, t) {
|
|
5433
5436
|
if (t.length === 0) return { file: null };
|
|
5434
5437
|
let n = e;
|
|
5435
5438
|
for (let e = 0; e < t.length - 1; e++) try {
|
|
@@ -5451,7 +5454,7 @@ async function Tr(e, t) {
|
|
|
5451
5454
|
return { file: null };
|
|
5452
5455
|
}
|
|
5453
5456
|
}
|
|
5454
|
-
async function
|
|
5457
|
+
async function Dr(e, t, n = 5e3) {
|
|
5455
5458
|
let r = t.toLowerCase(), i = [e], a = 0, o;
|
|
5456
5459
|
for (; i.length > 0 && a < n;) {
|
|
5457
5460
|
let e = i.pop();
|
|
@@ -5473,37 +5476,37 @@ async function Er(e, t, n = 5e3) {
|
|
|
5473
5476
|
readError: o
|
|
5474
5477
|
};
|
|
5475
5478
|
}
|
|
5476
|
-
async function
|
|
5477
|
-
let n =
|
|
5479
|
+
async function Or(e, t) {
|
|
5480
|
+
let n = br(t).split("/").filter(Boolean);
|
|
5478
5481
|
if (n.length === 0) return { file: null };
|
|
5479
5482
|
let r;
|
|
5480
5483
|
for (let t = 0; t < n.length; t++) {
|
|
5481
|
-
let i = await
|
|
5484
|
+
let i = await Er(e, n.slice(t));
|
|
5482
5485
|
if (i.file) return i;
|
|
5483
5486
|
i.readError && (r = i.readError);
|
|
5484
5487
|
}
|
|
5485
|
-
let i = await
|
|
5488
|
+
let i = await Dr(e, n[n.length - 1]);
|
|
5486
5489
|
return i.file || i.readError ? i : {
|
|
5487
5490
|
file: null,
|
|
5488
5491
|
readError: r
|
|
5489
5492
|
};
|
|
5490
5493
|
}
|
|
5491
|
-
var
|
|
5494
|
+
var kr = {
|
|
5492
5495
|
image: "image",
|
|
5493
5496
|
videoEmbed: "video",
|
|
5494
5497
|
audioEmbed: "audio",
|
|
5495
5498
|
attachmentEmbed: "attachment"
|
|
5496
5499
|
};
|
|
5497
|
-
function
|
|
5500
|
+
function Ar(e, t) {
|
|
5498
5501
|
let n = /* @__PURE__ */ new Set(), r = [];
|
|
5499
5502
|
return e.descendants((e) => {
|
|
5500
|
-
let i =
|
|
5503
|
+
let i = kr[e.type?.name];
|
|
5501
5504
|
if (i) {
|
|
5502
5505
|
let a = e.attrs?.src, o = `node:${a}`;
|
|
5503
|
-
typeof a == "string" &&
|
|
5506
|
+
typeof a == "string" && vr(a) && !n.has(o) && !t?.(a) && (n.add(o), r.push({
|
|
5504
5507
|
src: a,
|
|
5505
|
-
normalized:
|
|
5506
|
-
basename:
|
|
5508
|
+
normalized: br(a),
|
|
5509
|
+
basename: xr(a),
|
|
5507
5510
|
kind: i,
|
|
5508
5511
|
isLink: !1
|
|
5509
5512
|
}));
|
|
@@ -5512,17 +5515,17 @@ function kr(e, t) {
|
|
|
5512
5515
|
if (e.isText && e.marks) for (let i of e.marks) {
|
|
5513
5516
|
if (i.type.name !== "link") continue;
|
|
5514
5517
|
let e = i.attrs?.href, a = `link:${e}`;
|
|
5515
|
-
typeof e == "string" &&
|
|
5518
|
+
typeof e == "string" && vr(e) && yr(e) && !n.has(a) && !t?.(e) && (n.add(a), r.push({
|
|
5516
5519
|
src: e,
|
|
5517
|
-
normalized:
|
|
5518
|
-
basename:
|
|
5520
|
+
normalized: br(e),
|
|
5521
|
+
basename: xr(e),
|
|
5519
5522
|
kind: "attachment",
|
|
5520
5523
|
isLink: !0
|
|
5521
5524
|
}));
|
|
5522
5525
|
}
|
|
5523
5526
|
}), r;
|
|
5524
5527
|
}
|
|
5525
|
-
function
|
|
5528
|
+
function jr(e, t, n) {
|
|
5526
5529
|
let r = t ? `${e}\n${t}` : e;
|
|
5527
5530
|
if (!r) return !1;
|
|
5528
5531
|
let i = [];
|
|
@@ -5530,28 +5533,28 @@ function Ar(e, t, n) {
|
|
|
5530
5533
|
for (let e of r.matchAll(/!?\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g)) i.push(e[1]);
|
|
5531
5534
|
for (let e of r.matchAll(/<(?:img|video|audio|source)[^>]*\bsrc=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5532
5535
|
for (let e of r.matchAll(/<a[^>]*\bhref=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5533
|
-
return i.some((e) =>
|
|
5536
|
+
return i.some((e) => yr(e) && vr(e) && !n?.(e));
|
|
5534
5537
|
}
|
|
5535
5538
|
//#endregion
|
|
5536
5539
|
//#region src/editor/extensions/image-upload.ts
|
|
5537
|
-
function
|
|
5540
|
+
function Mr(e) {
|
|
5538
5541
|
if (e.type.startsWith("image/")) return "image";
|
|
5539
5542
|
if (e.type.startsWith("video/")) return "video";
|
|
5540
5543
|
if (e.type.startsWith("audio/")) return "audio";
|
|
5541
5544
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5542
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";
|
|
5543
5546
|
}
|
|
5544
|
-
function
|
|
5547
|
+
function Nr(e) {
|
|
5545
5548
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5546
5549
|
return t === "md" || t === "markdown";
|
|
5547
5550
|
}
|
|
5548
|
-
async function
|
|
5549
|
-
let i = n ?? e.state.selection.from, a = r ?
|
|
5550
|
-
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);
|
|
5551
5554
|
});
|
|
5552
5555
|
if (s === null) return;
|
|
5553
5556
|
if (s === "attach") {
|
|
5554
|
-
let n = a ?
|
|
5557
|
+
let n = a ? hn(e.state.doc, t, a) : null;
|
|
5555
5558
|
if (n) {
|
|
5556
5559
|
Z(n);
|
|
5557
5560
|
return;
|
|
@@ -5582,8 +5585,8 @@ async function Nr(e, t, n, r) {
|
|
|
5582
5585
|
e.dispatch(e.state.tr.insert(i, t.from(u)));
|
|
5583
5586
|
}
|
|
5584
5587
|
}
|
|
5585
|
-
function
|
|
5586
|
-
switch (
|
|
5588
|
+
function Fr(e, t, n) {
|
|
5589
|
+
switch (Mr(t)) {
|
|
5587
5590
|
case "image": return e.nodes.image?.create({
|
|
5588
5591
|
src: n,
|
|
5589
5592
|
alt: t.name
|
|
@@ -5609,7 +5612,7 @@ function Pr(e, t, n) {
|
|
|
5609
5612
|
}
|
|
5610
5613
|
}
|
|
5611
5614
|
}
|
|
5612
|
-
async function
|
|
5615
|
+
async function Ir(e, t, n) {
|
|
5613
5616
|
let r;
|
|
5614
5617
|
try {
|
|
5615
5618
|
r = o();
|
|
@@ -5628,13 +5631,13 @@ async function Fr(e, t, n) {
|
|
|
5628
5631
|
return console.error(`${t.type} upload failed:`, e), URL.revokeObjectURL(n), null;
|
|
5629
5632
|
}
|
|
5630
5633
|
}
|
|
5631
|
-
async function
|
|
5632
|
-
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;
|
|
5633
5636
|
if (a) {
|
|
5634
5637
|
Z(a);
|
|
5635
5638
|
return;
|
|
5636
5639
|
}
|
|
5637
|
-
let o = URL.createObjectURL(t), s =
|
|
5640
|
+
let o = URL.createObjectURL(t), s = Fr(e.state.schema, t, o);
|
|
5638
5641
|
if (!s) return;
|
|
5639
5642
|
let c = n ?? e.state.selection.from;
|
|
5640
5643
|
try {
|
|
@@ -5642,9 +5645,9 @@ async function Ir(e, t, n, r) {
|
|
|
5642
5645
|
} catch {
|
|
5643
5646
|
return;
|
|
5644
5647
|
}
|
|
5645
|
-
await
|
|
5648
|
+
await Ir(e, t, o);
|
|
5646
5649
|
}
|
|
5647
|
-
var
|
|
5650
|
+
var Rr = L.create({
|
|
5648
5651
|
name: "imageUpload",
|
|
5649
5652
|
addOptions() {
|
|
5650
5653
|
return {
|
|
@@ -5654,8 +5657,8 @@ var Lr = R.create({
|
|
|
5654
5657
|
},
|
|
5655
5658
|
addProseMirrorPlugins() {
|
|
5656
5659
|
let e = this.editor;
|
|
5657
|
-
return [new
|
|
5658
|
-
key: new
|
|
5660
|
+
return [new B({
|
|
5661
|
+
key: new V("imageUpload"),
|
|
5659
5662
|
props: {
|
|
5660
5663
|
handleDrop(t, n) {
|
|
5661
5664
|
let r = n.dataTransfer?.files;
|
|
@@ -5665,23 +5668,23 @@ var Lr = R.create({
|
|
|
5665
5668
|
left: n.clientX,
|
|
5666
5669
|
top: n.clientY
|
|
5667
5670
|
});
|
|
5668
|
-
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);
|
|
5669
5672
|
return !0;
|
|
5670
5673
|
},
|
|
5671
5674
|
handlePaste(t, n) {
|
|
5672
5675
|
let r = n.clipboardData?.items;
|
|
5673
5676
|
if (!r) return !1;
|
|
5674
5677
|
let i = n.clipboardData?.getData("text/plain") || "";
|
|
5675
|
-
if ((n.clipboardData?.files?.length ?? 0) > 0 &&
|
|
5678
|
+
if ((n.clipboardData?.files?.length ?? 0) > 0 && jr(i, void 0, a())) return !1;
|
|
5676
5679
|
for (let i of Array.from(r)) {
|
|
5677
5680
|
if (i.type.startsWith("image/") || i.type.startsWith("video/") || i.type.startsWith("audio/")) {
|
|
5678
5681
|
n.preventDefault();
|
|
5679
5682
|
let r = i.getAsFile();
|
|
5680
|
-
return r &&
|
|
5683
|
+
return r && Mr(r) !== "file" && Lr(t, r, void 0, e), !0;
|
|
5681
5684
|
}
|
|
5682
5685
|
if (i.kind === "file") {
|
|
5683
5686
|
let r = i.getAsFile();
|
|
5684
|
-
if (r &&
|
|
5687
|
+
if (r && Nr(r)) return n.preventDefault(), Pr(t, r, void 0, e), !0;
|
|
5685
5688
|
}
|
|
5686
5689
|
}
|
|
5687
5690
|
return !1;
|
|
@@ -5689,12 +5692,12 @@ var Lr = R.create({
|
|
|
5689
5692
|
}
|
|
5690
5693
|
})];
|
|
5691
5694
|
}
|
|
5692
|
-
}),
|
|
5695
|
+
}), zr = 100, Br = L.create({
|
|
5693
5696
|
name: "imeCommitSpaceGuard",
|
|
5694
5697
|
addProseMirrorPlugins() {
|
|
5695
5698
|
let e = 0;
|
|
5696
|
-
return [new
|
|
5697
|
-
key: new
|
|
5699
|
+
return [new B({
|
|
5700
|
+
key: new V("imeCommitSpaceGuard"),
|
|
5698
5701
|
props: { handleDOMEvents: {
|
|
5699
5702
|
compositionend() {
|
|
5700
5703
|
return e = performance.now(), !1;
|
|
@@ -5704,16 +5707,16 @@ var Lr = R.create({
|
|
|
5704
5707
|
},
|
|
5705
5708
|
beforeinput(t, n) {
|
|
5706
5709
|
let r = n;
|
|
5707
|
-
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);
|
|
5708
5711
|
}
|
|
5709
5712
|
} }
|
|
5710
5713
|
})];
|
|
5711
5714
|
}
|
|
5712
|
-
}),
|
|
5715
|
+
}), Vr = L.create({
|
|
5713
5716
|
name: "inlineCodeEnd",
|
|
5714
5717
|
addInputRules() {
|
|
5715
5718
|
let e = this.editor.schema.marks.code;
|
|
5716
|
-
return e ? [
|
|
5719
|
+
return e ? [R({
|
|
5717
5720
|
find: /`([^`]+)`$/,
|
|
5718
5721
|
type: e
|
|
5719
5722
|
})] : [];
|
|
@@ -5721,17 +5724,17 @@ var Lr = R.create({
|
|
|
5721
5724
|
});
|
|
5722
5725
|
//#endregion
|
|
5723
5726
|
//#region src/editor/extensions/math-utils.ts
|
|
5724
|
-
function
|
|
5727
|
+
function Hr(e) {
|
|
5725
5728
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">").replace(/\n/g, " ");
|
|
5726
5729
|
}
|
|
5727
|
-
function
|
|
5730
|
+
function Ur(e) {
|
|
5728
5731
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
5729
5732
|
}
|
|
5730
|
-
function
|
|
5733
|
+
function Wr(e, t) {
|
|
5731
5734
|
let n = e ?? "";
|
|
5732
5735
|
if (!n.trim()) return "";
|
|
5733
5736
|
try {
|
|
5734
|
-
return
|
|
5737
|
+
return we.renderToString(n, {
|
|
5735
5738
|
displayMode: t,
|
|
5736
5739
|
throwOnError: !1,
|
|
5737
5740
|
strict: "ignore",
|
|
@@ -5739,59 +5742,72 @@ function Ur(e, t) {
|
|
|
5739
5742
|
output: "htmlAndMathml"
|
|
5740
5743
|
});
|
|
5741
5744
|
} catch {
|
|
5742
|
-
return `<span class="math-fallback">${
|
|
5745
|
+
return `<span class="math-fallback">${Ur(n)}</span>`;
|
|
5743
5746
|
}
|
|
5744
5747
|
}
|
|
5745
5748
|
//#endregion
|
|
5746
5749
|
//#region src/editor/extensions/math-view.tsx
|
|
5747
|
-
function
|
|
5748
|
-
let
|
|
5749
|
-
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();
|
|
5750
5753
|
if (!e) {
|
|
5751
|
-
|
|
5754
|
+
u(!1), c && n?.();
|
|
5752
5755
|
return;
|
|
5753
5756
|
}
|
|
5754
|
-
t({ latex: e }),
|
|
5755
|
-
},
|
|
5756
|
-
|
|
5757
|
+
t({ latex: e }), u(!1);
|
|
5758
|
+
}, S = () => {
|
|
5759
|
+
u(!1), !s && c && n?.();
|
|
5757
5760
|
};
|
|
5758
|
-
|
|
5759
|
-
!
|
|
5760
|
-
}, [
|
|
5761
|
-
if (!
|
|
5762
|
-
|
|
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);
|
|
5763
5766
|
let e = window.setTimeout(() => {
|
|
5764
|
-
|
|
5767
|
+
m.current?.focus(), m.current?.select();
|
|
5765
5768
|
}, 30), t = (e) => {
|
|
5766
|
-
e.key === "Escape" ? (e.preventDefault(),
|
|
5769
|
+
e.key === "Escape" ? (e.preventDefault(), _.current()) : (e.metaKey || e.ctrlKey) && e.key === "Enter" && (e.preventDefault(), g.current());
|
|
5767
5770
|
};
|
|
5768
5771
|
return window.addEventListener("keydown", t, !0), () => {
|
|
5769
5772
|
window.clearTimeout(e), window.removeEventListener("keydown", t, !0);
|
|
5770
5773
|
};
|
|
5771
|
-
}, [
|
|
5772
|
-
let
|
|
5773
|
-
|
|
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();
|
|
5774
5783
|
};
|
|
5775
5784
|
return /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D(P, {
|
|
5776
|
-
as:
|
|
5777
|
-
className: `math-node ${
|
|
5785
|
+
as: o ? "div" : "span",
|
|
5786
|
+
className: `math-node ${o ? "math-node--block" : "math-node--inline"}${a ? " is-selected" : ""}`,
|
|
5778
5787
|
contentEditable: !1,
|
|
5788
|
+
title: c && !o ? f("editor.math.inlineClickHint") : void 0,
|
|
5779
5789
|
onMouseDown: (e) => {
|
|
5780
|
-
|
|
5790
|
+
c && o && e.preventDefault();
|
|
5781
5791
|
},
|
|
5782
5792
|
onClick: (e) => {
|
|
5783
|
-
|
|
5793
|
+
if (c) {
|
|
5794
|
+
if (e.preventDefault(), e.stopPropagation(), o) {
|
|
5795
|
+
k();
|
|
5796
|
+
return;
|
|
5797
|
+
}
|
|
5798
|
+
e.detail >= 2 ? k() : A(e);
|
|
5799
|
+
}
|
|
5784
5800
|
},
|
|
5785
|
-
children:
|
|
5801
|
+
children: s ? /* @__PURE__ */ D("span", {
|
|
5786
5802
|
className: "math-render",
|
|
5787
|
-
dangerouslySetInnerHTML: { __html:
|
|
5803
|
+
dangerouslySetInnerHTML: { __html: v }
|
|
5788
5804
|
}) : /* @__PURE__ */ D("span", {
|
|
5789
5805
|
className: "math-placeholder",
|
|
5790
5806
|
children: f("editor.math.empty")
|
|
5791
5807
|
})
|
|
5792
|
-
}),
|
|
5808
|
+
}), l && re(/* @__PURE__ */ D("div", {
|
|
5793
5809
|
className: "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none",
|
|
5794
|
-
onClick:
|
|
5810
|
+
onClick: S,
|
|
5795
5811
|
onMouseDown: (e) => e.preventDefault(),
|
|
5796
5812
|
children: /* @__PURE__ */ O("div", {
|
|
5797
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",
|
|
@@ -5799,20 +5815,20 @@ function Wr({ node: e, updateAttributes: t, deleteNode: n, editor: r, selected:
|
|
|
5799
5815
|
children: [
|
|
5800
5816
|
/* @__PURE__ */ D("div", {
|
|
5801
5817
|
className: "mb-3 text-sm font-medium text-default-800 dark:text-zinc-100",
|
|
5802
|
-
children: f(
|
|
5818
|
+
children: f(o ? "editor.math.blockTitle" : "editor.math.inlineTitle")
|
|
5803
5819
|
}),
|
|
5804
5820
|
/* @__PURE__ */ D("textarea", {
|
|
5805
|
-
ref:
|
|
5806
|
-
value:
|
|
5807
|
-
onChange: (e) =>
|
|
5808
|
-
rows:
|
|
5821
|
+
ref: m,
|
|
5822
|
+
value: d,
|
|
5823
|
+
onChange: (e) => p(e.target.value),
|
|
5824
|
+
rows: o ? 5 : 2,
|
|
5809
5825
|
spellCheck: !1,
|
|
5810
5826
|
placeholder: f("editor.math.placeholder"),
|
|
5811
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"
|
|
5812
5828
|
}),
|
|
5813
5829
|
/* @__PURE__ */ D("div", {
|
|
5814
5830
|
className: "math-dialog-preview",
|
|
5815
|
-
children:
|
|
5831
|
+
children: d.trim() ? /* @__PURE__ */ D("div", { dangerouslySetInnerHTML: { __html: y } }) : /* @__PURE__ */ D("span", {
|
|
5816
5832
|
className: "math-placeholder",
|
|
5817
5833
|
children: f("editor.math.emptyPreview")
|
|
5818
5834
|
})
|
|
@@ -5827,12 +5843,12 @@ function Wr({ node: e, updateAttributes: t, deleteNode: n, editor: r, selected:
|
|
|
5827
5843
|
children: [/* @__PURE__ */ D("button", {
|
|
5828
5844
|
type: "button",
|
|
5829
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",
|
|
5830
|
-
onClick:
|
|
5846
|
+
onClick: S,
|
|
5831
5847
|
children: f("editor.math.cancel")
|
|
5832
5848
|
}), /* @__PURE__ */ D("button", {
|
|
5833
5849
|
type: "button",
|
|
5834
5850
|
className: "px-3 py-1.5 text-xs rounded-lg bg-qingwu-600 hover:bg-qingwu-700 text-white transition-colors",
|
|
5835
|
-
onClick:
|
|
5851
|
+
onClick: b,
|
|
5836
5852
|
children: f("editor.math.save")
|
|
5837
5853
|
})]
|
|
5838
5854
|
})]
|
|
@@ -5843,9 +5859,9 @@ function Wr({ node: e, updateAttributes: t, deleteNode: n, editor: r, selected:
|
|
|
5843
5859
|
}
|
|
5844
5860
|
//#endregion
|
|
5845
5861
|
//#region src/editor/extensions/math.ts
|
|
5846
|
-
var
|
|
5847
|
-
function
|
|
5848
|
-
return new
|
|
5862
|
+
var Kr = /(?:^|[^\\$])\$([^\s$](?:[^$\n]*[^\s$])?)\$$/, qr = /^\$\$([\s\S]+?)\$\$$/;
|
|
5863
|
+
function Jr(e) {
|
|
5864
|
+
return new B({ appendTransaction(t, n, r) {
|
|
5849
5865
|
if (!e.isEditable || e.view.composing || !t.some((e) => e.docChanged)) return null;
|
|
5850
5866
|
let i = r.schema.nodes.paragraph, a = r.schema.nodes.mathBlock;
|
|
5851
5867
|
if (!i || !a) return null;
|
|
@@ -5878,14 +5894,14 @@ function qr(e) {
|
|
|
5878
5894
|
let t = a.create({ latex: e.latex });
|
|
5879
5895
|
c.replaceWith(e.from, e.to, t);
|
|
5880
5896
|
let n = e.from + t.nodeSize, r = c.doc.resolve(n);
|
|
5881
|
-
(!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));
|
|
5882
5898
|
}
|
|
5883
5899
|
return c;
|
|
5884
5900
|
} });
|
|
5885
5901
|
}
|
|
5886
|
-
function
|
|
5887
|
-
return new
|
|
5888
|
-
find:
|
|
5902
|
+
function Yr(e) {
|
|
5903
|
+
return new ie({
|
|
5904
|
+
find: Kr,
|
|
5889
5905
|
handler: ({ state: t, range: n, match: r }) => {
|
|
5890
5906
|
let i = r[1], a = r[0].indexOf("$");
|
|
5891
5907
|
if (a < 0) return;
|
|
@@ -5894,18 +5910,18 @@ function Jr(e) {
|
|
|
5894
5910
|
}
|
|
5895
5911
|
});
|
|
5896
5912
|
}
|
|
5897
|
-
function
|
|
5898
|
-
return new
|
|
5899
|
-
find:
|
|
5913
|
+
function Xr(e) {
|
|
5914
|
+
return new ie({
|
|
5915
|
+
find: qr,
|
|
5900
5916
|
handler: ({ state: t, range: n, match: r }) => {
|
|
5901
5917
|
let i = r[1].trim();
|
|
5902
5918
|
if (!i) return;
|
|
5903
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);
|
|
5904
|
-
(!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));
|
|
5905
5921
|
}
|
|
5906
5922
|
});
|
|
5907
5923
|
}
|
|
5908
|
-
function
|
|
5924
|
+
function Zr(e, t) {
|
|
5909
5925
|
let n = e.src, r = e.pos;
|
|
5910
5926
|
if (n.charCodeAt(r) !== 36 || n.charCodeAt(r + 1) === 36) return !1;
|
|
5911
5927
|
let i = r + 1;
|
|
@@ -5920,11 +5936,11 @@ function Xr(e, t) {
|
|
|
5920
5936
|
if (!a || /^\s|\s$/.test(a)) return !1;
|
|
5921
5937
|
if (!t) {
|
|
5922
5938
|
let t = e.push("html_inline", "", 0);
|
|
5923
|
-
t.content = `<span data-type="inline-math" data-latex="${
|
|
5939
|
+
t.content = `<span data-type="inline-math" data-latex="${Hr(a)}"></span>`;
|
|
5924
5940
|
}
|
|
5925
5941
|
return e.pos = i + 1, !0;
|
|
5926
5942
|
}
|
|
5927
|
-
function
|
|
5943
|
+
function Qr(e, t, n, r) {
|
|
5928
5944
|
let i = e.bMarks[t] + e.tShift[t], a = e.eMarks[t];
|
|
5929
5945
|
if (i + 1 >= a || e.src.charCodeAt(i) !== 36 || e.src.charCodeAt(i + 1) !== 36) return !1;
|
|
5930
5946
|
let o = e.src.slice(i, a).trim(), s = "", c = t + 1;
|
|
@@ -5947,12 +5963,12 @@ function Zr(e, t, n, r) {
|
|
|
5947
5963
|
}
|
|
5948
5964
|
if (r) return !0;
|
|
5949
5965
|
let l = e.push("html_block", "", 0);
|
|
5950
|
-
return l.content = `<div data-type="block-math" data-latex="${
|
|
5951
|
-
}
|
|
5952
|
-
function Qr(e) {
|
|
5953
|
-
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;
|
|
5954
5967
|
}
|
|
5955
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) {
|
|
5956
5972
|
return { markdown: {
|
|
5957
5973
|
serialize(t, n) {
|
|
5958
5974
|
let r = String(n.attrs.latex ?? "");
|
|
@@ -5965,11 +5981,11 @@ function $r(e) {
|
|
|
5965
5981
|
t.write("$$"), t.closeBlock(n);
|
|
5966
5982
|
},
|
|
5967
5983
|
parse: { setup(e) {
|
|
5968
|
-
|
|
5984
|
+
$r(e);
|
|
5969
5985
|
} }
|
|
5970
5986
|
} };
|
|
5971
5987
|
}
|
|
5972
|
-
var
|
|
5988
|
+
var ti = ae.create({
|
|
5973
5989
|
name: "mathInline",
|
|
5974
5990
|
group: "inline",
|
|
5975
5991
|
inline: !0,
|
|
@@ -5997,18 +6013,18 @@ var ei = ie.create({
|
|
|
5997
6013
|
];
|
|
5998
6014
|
let r = document.createElement("span");
|
|
5999
6015
|
for (let [e, t] of Object.entries(n)) r.setAttribute(e, t);
|
|
6000
|
-
return r.innerHTML =
|
|
6016
|
+
return r.innerHTML = Wr(t, !1), r;
|
|
6001
6017
|
},
|
|
6002
6018
|
addNodeView() {
|
|
6003
|
-
return F(
|
|
6019
|
+
return F(Gr);
|
|
6004
6020
|
},
|
|
6005
6021
|
addInputRules() {
|
|
6006
|
-
return [
|
|
6022
|
+
return [Yr(this.type)];
|
|
6007
6023
|
},
|
|
6008
6024
|
addStorage() {
|
|
6009
|
-
return
|
|
6025
|
+
return ei(!1);
|
|
6010
6026
|
}
|
|
6011
|
-
}),
|
|
6027
|
+
}), ni = ae.create({
|
|
6012
6028
|
name: "mathBlock",
|
|
6013
6029
|
group: "block",
|
|
6014
6030
|
atom: !0,
|
|
@@ -6035,39 +6051,39 @@ var ei = ie.create({
|
|
|
6035
6051
|
];
|
|
6036
6052
|
let r = document.createElement("div");
|
|
6037
6053
|
for (let [e, t] of Object.entries(n)) r.setAttribute(e, t);
|
|
6038
|
-
return r.innerHTML =
|
|
6054
|
+
return r.innerHTML = Wr(t, !0), r;
|
|
6039
6055
|
},
|
|
6040
6056
|
addNodeView() {
|
|
6041
|
-
return F(
|
|
6057
|
+
return F(Gr);
|
|
6042
6058
|
},
|
|
6043
6059
|
addInputRules() {
|
|
6044
|
-
return [
|
|
6060
|
+
return [Xr(this.type)];
|
|
6045
6061
|
},
|
|
6046
6062
|
addProseMirrorPlugins() {
|
|
6047
|
-
return [
|
|
6063
|
+
return [Jr(this.editor)];
|
|
6048
6064
|
},
|
|
6049
6065
|
addStorage() {
|
|
6050
|
-
return
|
|
6066
|
+
return ei(!0);
|
|
6051
6067
|
}
|
|
6052
|
-
}),
|
|
6053
|
-
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) {
|
|
6054
6070
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
6055
6071
|
}
|
|
6056
|
-
function
|
|
6072
|
+
function si(e) {
|
|
6057
6073
|
let t = e.trim().replace(/\\/g, "/");
|
|
6058
6074
|
return t.split("/").pop() || t;
|
|
6059
6075
|
}
|
|
6060
|
-
function
|
|
6076
|
+
function ci(e, t) {
|
|
6061
6077
|
let n = e.src.slice(e.pos), r = /^!\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !0;
|
|
6062
6078
|
if (r || (r = /^\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !1), !r) return !1;
|
|
6063
6079
|
let a = r[1].trim(), o = r[2]?.trim();
|
|
6064
6080
|
if (!t) {
|
|
6065
|
-
let t = o ||
|
|
6081
|
+
let t = o || si(a);
|
|
6066
6082
|
if (i) {
|
|
6067
6083
|
let n = "";
|
|
6068
|
-
if (
|
|
6069
|
-
else if (
|
|
6070
|
-
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>`;
|
|
6071
6087
|
else {
|
|
6072
6088
|
let n = e.push("link_open", "a", 1);
|
|
6073
6089
|
n.attrs = [["href", a]];
|
|
@@ -6085,14 +6101,14 @@ function si(e, t) {
|
|
|
6085
6101
|
}
|
|
6086
6102
|
return e.pos += r[0].length, !0;
|
|
6087
6103
|
}
|
|
6088
|
-
var
|
|
6104
|
+
var li = L.create({
|
|
6089
6105
|
name: "obsidianMarkdown",
|
|
6090
6106
|
addStorage() {
|
|
6091
6107
|
return { markdown: { parse: { setup(e) {
|
|
6092
|
-
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));
|
|
6093
6109
|
} } } };
|
|
6094
6110
|
}
|
|
6095
|
-
}),
|
|
6111
|
+
}), ui = L.create({
|
|
6096
6112
|
name: "qingwuUI",
|
|
6097
6113
|
addStorage() {
|
|
6098
6114
|
return {};
|
|
@@ -6100,7 +6116,7 @@ var ci = R.create({
|
|
|
6100
6116
|
});
|
|
6101
6117
|
//#endregion
|
|
6102
6118
|
//#region src/editor/utils/render-probe.ts
|
|
6103
|
-
function
|
|
6119
|
+
function di(e, t) {
|
|
6104
6120
|
return new Promise((n) => {
|
|
6105
6121
|
if (typeof Image != "function") return n(!0);
|
|
6106
6122
|
let r = new Image(), i = !1, a = setTimeout(() => o(!1), t), o = (e) => {
|
|
@@ -6109,14 +6125,14 @@ function ui(e, t) {
|
|
|
6109
6125
|
r.onload = () => o(!0), r.onerror = () => o(!1), r.src = e;
|
|
6110
6126
|
});
|
|
6111
6127
|
}
|
|
6112
|
-
async function
|
|
6113
|
-
if (await
|
|
6128
|
+
async function fi(e, t = 8e3) {
|
|
6129
|
+
if (await di(e, t)) return !0;
|
|
6114
6130
|
try {
|
|
6115
6131
|
let r = await n(e);
|
|
6116
6132
|
if (!r) return !1;
|
|
6117
6133
|
let i = await fetch(e, { headers: r });
|
|
6118
6134
|
if (!i.ok) return !1;
|
|
6119
|
-
let a = URL.createObjectURL(await i.blob()), o = await
|
|
6135
|
+
let a = URL.createObjectURL(await i.blob()), o = await di(a, t);
|
|
6120
6136
|
return URL.revokeObjectURL(a), o;
|
|
6121
6137
|
} catch {
|
|
6122
6138
|
return !1;
|
|
@@ -6124,7 +6140,7 @@ async function di(e, t = 8e3) {
|
|
|
6124
6140
|
}
|
|
6125
6141
|
//#endregion
|
|
6126
6142
|
//#region src/editor/utils/resolve-local-media.ts
|
|
6127
|
-
function
|
|
6143
|
+
function pi() {
|
|
6128
6144
|
return {
|
|
6129
6145
|
uploaded: 0,
|
|
6130
6146
|
sessionOnly: 0,
|
|
@@ -6134,10 +6150,10 @@ function fi() {
|
|
|
6134
6150
|
readFailed: []
|
|
6135
6151
|
};
|
|
6136
6152
|
}
|
|
6137
|
-
function
|
|
6153
|
+
function mi(e, t) {
|
|
6138
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);
|
|
6139
6155
|
}
|
|
6140
|
-
function
|
|
6156
|
+
function hi(e, t, n, r) {
|
|
6141
6157
|
let { state: i } = e, a = [];
|
|
6142
6158
|
if (i.doc.descendants((e, n) => {
|
|
6143
6159
|
e.attrs?.src === t && a.push(n);
|
|
@@ -6153,7 +6169,7 @@ function mi(e, t, n, r) {
|
|
|
6153
6169
|
}
|
|
6154
6170
|
return e.dispatch(o), !0;
|
|
6155
6171
|
}
|
|
6156
|
-
function
|
|
6172
|
+
function gi(e, t, n) {
|
|
6157
6173
|
let { state: r } = e, i = r.schema.marks.link;
|
|
6158
6174
|
if (!i) return !1;
|
|
6159
6175
|
let a = [];
|
|
@@ -6171,7 +6187,7 @@ function hi(e, t, n) {
|
|
|
6171
6187
|
}));
|
|
6172
6188
|
return e.dispatch(o), !0;
|
|
6173
6189
|
}
|
|
6174
|
-
function
|
|
6190
|
+
function _i(e) {
|
|
6175
6191
|
let t = /* @__PURE__ */ new Map();
|
|
6176
6192
|
for (let n of e) {
|
|
6177
6193
|
let e = t.get(n.normalized);
|
|
@@ -6179,36 +6195,36 @@ function gi(e) {
|
|
|
6179
6195
|
}
|
|
6180
6196
|
return Array.from(t.values());
|
|
6181
6197
|
}
|
|
6182
|
-
async function
|
|
6198
|
+
async function vi(e, t, n, r) {
|
|
6183
6199
|
if (n.length === 0) return "sessionOnly";
|
|
6184
|
-
let i = n[0], a =
|
|
6200
|
+
let i = n[0], a = mn(t);
|
|
6185
6201
|
if (a) {
|
|
6186
|
-
let t =
|
|
6202
|
+
let t = hn(e.state.doc, r, a);
|
|
6187
6203
|
if (t) return Z(`${i.basename}:${t}`, "error"), "limitRejected";
|
|
6188
6204
|
}
|
|
6189
6205
|
let s = n.filter((e) => !e.isLink), c = n.filter((e) => e.isLink);
|
|
6190
6206
|
if (s.length === 0) try {
|
|
6191
6207
|
let t = await o().upload(r, "editor"), n = !1;
|
|
6192
|
-
for (let r of c)
|
|
6208
|
+
for (let r of c) gi(e, r.src, t) && (n = !0);
|
|
6193
6209
|
return n ? "uploaded" : "sessionOnly";
|
|
6194
6210
|
} catch (e) {
|
|
6195
6211
|
return console.error(`本地附件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), "sessionOnly";
|
|
6196
6212
|
}
|
|
6197
6213
|
let l = URL.createObjectURL(r), u = !1;
|
|
6198
|
-
for (let t of s)
|
|
6214
|
+
for (let t of s) hi(e, t.src, l, r.size) && (u = !0);
|
|
6199
6215
|
let d;
|
|
6200
6216
|
try {
|
|
6201
6217
|
d = await o().upload(r, "editor");
|
|
6202
6218
|
} catch (e) {
|
|
6203
6219
|
return console.error(`本地文件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), URL.revokeObjectURL(l), "sessionOnly";
|
|
6204
6220
|
}
|
|
6205
|
-
URL.revokeObjectURL(l), u &&
|
|
6206
|
-
for (let t of c)
|
|
6207
|
-
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";
|
|
6208
6224
|
}
|
|
6209
|
-
function
|
|
6225
|
+
function yi(e, t) {
|
|
6210
6226
|
let n = [], r = [];
|
|
6211
|
-
for (let i of
|
|
6227
|
+
for (let i of _i(e)) {
|
|
6212
6228
|
let e = i[0], a = t.get(e.basename);
|
|
6213
6229
|
a ? (n.push({
|
|
6214
6230
|
refs: i,
|
|
@@ -6220,30 +6236,30 @@ function vi(e, t) {
|
|
|
6220
6236
|
unmatched: r
|
|
6221
6237
|
};
|
|
6222
6238
|
}
|
|
6223
|
-
async function
|
|
6224
|
-
let i =
|
|
6225
|
-
for (let a of
|
|
6226
|
-
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);
|
|
6227
6243
|
if (!o) {
|
|
6228
6244
|
s ? (console.warn(`本地文件「${n.basename}」在所选文件夹中找到但读取失败:`, s), i.readFailed.push(n)) : (console.warn(`本地文件「${n.basename}」未在所选文件夹「${r.name}」中找到`), i.missing.push(n));
|
|
6229
6245
|
continue;
|
|
6230
6246
|
}
|
|
6231
|
-
let c = await
|
|
6247
|
+
let c = await vi(e, t, a, o);
|
|
6232
6248
|
i[c]++;
|
|
6233
6249
|
}
|
|
6234
6250
|
return i;
|
|
6235
6251
|
}
|
|
6236
|
-
function
|
|
6252
|
+
function xi(e) {
|
|
6237
6253
|
let t = e.map((e) => e.basename);
|
|
6238
6254
|
return t.length <= 3 ? t.join("、") : `${t.slice(0, 3).join("、")} 等 ${t.length} 个文件`;
|
|
6239
6255
|
}
|
|
6240
|
-
function
|
|
6256
|
+
function Si(e) {
|
|
6241
6257
|
let t = [];
|
|
6242
|
-
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;
|
|
6243
6259
|
let n = e.uploaded > 0 && e.renderFailed === 0 && e.missing.length === 0 && e.readFailed.length === 0;
|
|
6244
6260
|
Z(`本地文件解析完成:${t.join(";")}`, n ? "success" : "info");
|
|
6245
6261
|
}
|
|
6246
|
-
function
|
|
6262
|
+
function Ci(e) {
|
|
6247
6263
|
return new Promise((t) => {
|
|
6248
6264
|
let n = document.createElement("div");
|
|
6249
6265
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -6270,7 +6286,7 @@ function Si(e) {
|
|
|
6270
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);
|
|
6271
6287
|
});
|
|
6272
6288
|
}
|
|
6273
|
-
function
|
|
6289
|
+
function wi(e) {
|
|
6274
6290
|
let t = document.createElement("div");
|
|
6275
6291
|
t.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
6276
6292
|
let n = document.createElement("div");
|
|
@@ -6292,7 +6308,7 @@ function Ci(e) {
|
|
|
6292
6308
|
let c = document.createElement("button");
|
|
6293
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);
|
|
6294
6310
|
}
|
|
6295
|
-
function
|
|
6311
|
+
function Ti(e) {
|
|
6296
6312
|
return new Promise((t) => {
|
|
6297
6313
|
let n = document.createElement("div");
|
|
6298
6314
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -6318,8 +6334,8 @@ function wi(e) {
|
|
|
6318
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);
|
|
6319
6335
|
});
|
|
6320
6336
|
}
|
|
6321
|
-
async function
|
|
6322
|
-
let r =
|
|
6337
|
+
async function Ei(e, t, n) {
|
|
6338
|
+
let r = pi(), i = _i(n), a = await Tr();
|
|
6323
6339
|
if (!a) {
|
|
6324
6340
|
for (let e of i) r.missing.push(e[0]);
|
|
6325
6341
|
return r;
|
|
@@ -6332,14 +6348,14 @@ async function Ti(e, t, n) {
|
|
|
6332
6348
|
continue;
|
|
6333
6349
|
}
|
|
6334
6350
|
o.delete(i.basename);
|
|
6335
|
-
let s = await
|
|
6351
|
+
let s = await vi(e, t, n, a);
|
|
6336
6352
|
r[s]++;
|
|
6337
6353
|
}
|
|
6338
6354
|
return r;
|
|
6339
6355
|
}
|
|
6340
6356
|
//#endregion
|
|
6341
6357
|
//#region src/editor/extensions/relative-media.ts
|
|
6342
|
-
var
|
|
6358
|
+
var Di = L.create({
|
|
6343
6359
|
name: "relativeMedia",
|
|
6344
6360
|
addStorage() {
|
|
6345
6361
|
return {
|
|
@@ -6349,42 +6365,42 @@ var Ei = R.create({
|
|
|
6349
6365
|
},
|
|
6350
6366
|
addProseMirrorPlugins() {
|
|
6351
6367
|
let e = this.editor, t = this.storage, n = !1, r = null, i = async (n, i) => {
|
|
6352
|
-
let a = e.view, o =
|
|
6368
|
+
let a = e.view, o = pi(), { matched: s, unmatched: c } = yi(n, t.clipboardFiles);
|
|
6353
6369
|
for (let { refs: t, file: n } of s) {
|
|
6354
|
-
let r = await
|
|
6370
|
+
let r = await vi(a, e, t, n);
|
|
6355
6371
|
o[r]++;
|
|
6356
6372
|
}
|
|
6357
6373
|
if (c.length > 0) {
|
|
6358
|
-
let t =
|
|
6359
|
-
if (
|
|
6374
|
+
let t = _i(c).length;
|
|
6375
|
+
if (Sr()) {
|
|
6360
6376
|
let n = i ?? null;
|
|
6361
|
-
if (n || (await
|
|
6362
|
-
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));
|
|
6363
6379
|
let t = [...o.missing, ...o.readFailed];
|
|
6364
|
-
if (t.length > 0 &&
|
|
6365
|
-
let n = await
|
|
6366
|
-
|
|
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 = [];
|
|
6367
6383
|
}
|
|
6368
6384
|
}
|
|
6369
|
-
} else
|
|
6385
|
+
} else wi(t);
|
|
6370
6386
|
}
|
|
6371
|
-
|
|
6387
|
+
Si(o);
|
|
6372
6388
|
}, o = () => {
|
|
6373
6389
|
if (!e || e.isDestroyed || t.pausedUntilPaste) return;
|
|
6374
|
-
let o = a(), s =
|
|
6390
|
+
let o = a(), s = Ar(e.state.doc, o);
|
|
6375
6391
|
if (s.length === 0 || n) return;
|
|
6376
6392
|
n = !0;
|
|
6377
6393
|
let c = new Set(s.map((e) => e.src));
|
|
6378
6394
|
i(s).then(() => {
|
|
6379
6395
|
if (e.isDestroyed) return;
|
|
6380
|
-
let t =
|
|
6396
|
+
let t = Ar(e.state.doc, o).filter((e) => !c.has(e.src));
|
|
6381
6397
|
if (t.length !== 0) return i(t, r);
|
|
6382
6398
|
}).finally(() => {
|
|
6383
|
-
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste =
|
|
6399
|
+
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste = Ar(e.state.doc, o).length > 0);
|
|
6384
6400
|
});
|
|
6385
6401
|
};
|
|
6386
|
-
return [new
|
|
6387
|
-
key: new
|
|
6402
|
+
return [new B({
|
|
6403
|
+
key: new V("relativeMedia"),
|
|
6388
6404
|
props: { handlePaste(e, n) {
|
|
6389
6405
|
let r = n.clipboardData?.files;
|
|
6390
6406
|
return t.clipboardFiles = new Map(Array.from(r ?? []).map((e) => [e.name.toLowerCase(), e])), t.pausedUntilPaste = !1, !1;
|
|
@@ -6394,18 +6410,18 @@ var Ei = R.create({
|
|
|
6394
6410
|
}
|
|
6395
6411
|
})];
|
|
6396
6412
|
}
|
|
6397
|
-
}),
|
|
6398
|
-
function
|
|
6399
|
-
return
|
|
6413
|
+
}), Oi = new V("slashCommand");
|
|
6414
|
+
function ki(e) {
|
|
6415
|
+
return L.create({
|
|
6400
6416
|
name: "slashCommand",
|
|
6401
6417
|
addProseMirrorPlugins() {
|
|
6402
6418
|
let t = {
|
|
6403
6419
|
char: "/",
|
|
6404
|
-
pluginKey:
|
|
6420
|
+
pluginKey: Oi,
|
|
6405
6421
|
findSuggestionMatch: (e) => {
|
|
6406
6422
|
let { $position: t } = e;
|
|
6407
6423
|
for (let e = t.depth; e >= 0; e--) if (t.node(e).type.name === "codeBlock") return null;
|
|
6408
|
-
return t.marks().some((e) => e.type.name === "code") ? null :
|
|
6424
|
+
return t.marks().some((e) => e.type.name === "code") ? null : De(e);
|
|
6409
6425
|
},
|
|
6410
6426
|
allow: ({ editor: e, state: t }) => {
|
|
6411
6427
|
if (!e.isEditable) return !1;
|
|
@@ -6487,7 +6503,7 @@ function Oi(e) {
|
|
|
6487
6503
|
if (e.key === "Escape") {
|
|
6488
6504
|
e.preventDefault();
|
|
6489
6505
|
let t = a?.view;
|
|
6490
|
-
t &&
|
|
6506
|
+
t && Ee(t, Oi);
|
|
6491
6507
|
}
|
|
6492
6508
|
});
|
|
6493
6509
|
}
|
|
@@ -6505,7 +6521,7 @@ function Oi(e) {
|
|
|
6505
6521
|
if (!e || e.style.display === "none" || n.target instanceof Node && e.contains(n.target) || t) return;
|
|
6506
6522
|
let r = a?.view;
|
|
6507
6523
|
r && (t = !0, window.setTimeout(() => {
|
|
6508
|
-
t = !1, e?.style.display !== "none" &&
|
|
6524
|
+
t = !1, e?.style.display !== "none" && Ee(r, Oi);
|
|
6509
6525
|
}, 0));
|
|
6510
6526
|
}, document.addEventListener("mousedown", o, !0), document.addEventListener("touchstart", o, !0);
|
|
6511
6527
|
}
|
|
@@ -6529,11 +6545,11 @@ function Oi(e) {
|
|
|
6529
6545
|
};
|
|
6530
6546
|
}
|
|
6531
6547
|
};
|
|
6532
|
-
return [
|
|
6548
|
+
return [Te({
|
|
6533
6549
|
editor: this.editor,
|
|
6534
6550
|
...t
|
|
6535
|
-
}), new
|
|
6536
|
-
key: new
|
|
6551
|
+
}), new B({
|
|
6552
|
+
key: new V("slashCodeBlockGuard"),
|
|
6537
6553
|
appendTransaction: (e, t, n) => {
|
|
6538
6554
|
let { $from: r } = n.selection, i = !1;
|
|
6539
6555
|
for (let e = r.depth; e >= 0; e--) if (r.node(e).type.name === "codeBlock") {
|
|
@@ -6541,14 +6557,14 @@ function Oi(e) {
|
|
|
6541
6557
|
break;
|
|
6542
6558
|
}
|
|
6543
6559
|
if (!i && !r.marks().some((e) => e.type.name === "code")) return null;
|
|
6544
|
-
let a =
|
|
6545
|
-
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;
|
|
6546
6562
|
}
|
|
6547
6563
|
})];
|
|
6548
6564
|
}
|
|
6549
6565
|
});
|
|
6550
6566
|
}
|
|
6551
|
-
function
|
|
6567
|
+
function Ai(e, t) {
|
|
6552
6568
|
return [
|
|
6553
6569
|
{
|
|
6554
6570
|
title: e("editor.slash.heading1"),
|
|
@@ -6665,7 +6681,7 @@ function ki(e, t) {
|
|
|
6665
6681
|
n.type = "file", n.accept = "audio/*", n.onchange = async () => {
|
|
6666
6682
|
let r = n.files?.[0];
|
|
6667
6683
|
if (!r) return;
|
|
6668
|
-
let i =
|
|
6684
|
+
let i = mn(e) ?? t, a = i ? hn(e.state.doc, r, i) : null;
|
|
6669
6685
|
if (a) {
|
|
6670
6686
|
Z(a);
|
|
6671
6687
|
return;
|
|
@@ -6675,7 +6691,7 @@ function ki(e, t) {
|
|
|
6675
6691
|
name: r.name,
|
|
6676
6692
|
size: r.size
|
|
6677
6693
|
});
|
|
6678
|
-
s && (e.chain().focus().insertContent(s).run(), await
|
|
6694
|
+
s && (e.chain().focus().insertContent(s).run(), await Ir(e.view, r, o));
|
|
6679
6695
|
}, n.click();
|
|
6680
6696
|
}
|
|
6681
6697
|
},
|
|
@@ -6688,7 +6704,7 @@ function ki(e, t) {
|
|
|
6688
6704
|
n.type = "file", n.accept = "*/*", n.multiple = !0, n.onchange = async () => {
|
|
6689
6705
|
let r = n.files;
|
|
6690
6706
|
if (!(!r || r.length === 0)) for (let n of Array.from(r)) {
|
|
6691
|
-
let r =
|
|
6707
|
+
let r = mn(e) ?? t, i = r ? hn(e.state.doc, n, r) : null;
|
|
6692
6708
|
if (i) {
|
|
6693
6709
|
Z(i);
|
|
6694
6710
|
continue;
|
|
@@ -6705,7 +6721,7 @@ function ki(e, t) {
|
|
|
6705
6721
|
} catch {
|
|
6706
6722
|
continue;
|
|
6707
6723
|
}
|
|
6708
|
-
await
|
|
6724
|
+
await Ir(e.view, n, a);
|
|
6709
6725
|
}
|
|
6710
6726
|
}
|
|
6711
6727
|
}, n.click();
|
|
@@ -6715,9 +6731,9 @@ function ki(e, t) {
|
|
|
6715
6731
|
}
|
|
6716
6732
|
//#endregion
|
|
6717
6733
|
//#region src/editor/extensions/index.ts
|
|
6718
|
-
var
|
|
6734
|
+
var ji = U.extend({
|
|
6719
6735
|
addNodeView() {
|
|
6720
|
-
return F(
|
|
6736
|
+
return F(En);
|
|
6721
6737
|
},
|
|
6722
6738
|
addAttributes() {
|
|
6723
6739
|
return {
|
|
@@ -6740,75 +6756,85 @@ var Ai = W.extend({
|
|
|
6740
6756
|
};
|
|
6741
6757
|
}
|
|
6742
6758
|
});
|
|
6743
|
-
function
|
|
6759
|
+
function Mi(e = {}) {
|
|
6744
6760
|
return [
|
|
6745
|
-
|
|
6761
|
+
G.configure({
|
|
6746
6762
|
codeBlock: !1,
|
|
6747
6763
|
horizontalRule: !1,
|
|
6748
6764
|
underline: !1,
|
|
6749
6765
|
link: !1
|
|
6750
6766
|
}),
|
|
6751
|
-
|
|
6752
|
-
|
|
6767
|
+
W,
|
|
6768
|
+
ce.configure({
|
|
6753
6769
|
openOnClick: !0,
|
|
6754
6770
|
HTMLAttributes: {
|
|
6755
6771
|
rel: "noopener noreferrer",
|
|
6756
6772
|
target: "_blank"
|
|
6757
6773
|
}
|
|
6758
6774
|
}),
|
|
6759
|
-
|
|
6775
|
+
ji.configure({
|
|
6760
6776
|
inline: !1,
|
|
6761
6777
|
allowBase64: !0
|
|
6762
6778
|
}),
|
|
6763
|
-
ge,
|
|
6764
|
-
he.configure({ nested: !0 }),
|
|
6765
|
-
le.configure({ multicolor: !0 }),
|
|
6766
6779
|
_e,
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
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,
|
|
6772
6787
|
ti,
|
|
6773
|
-
|
|
6774
|
-
|
|
6788
|
+
ni,
|
|
6789
|
+
mr,
|
|
6790
|
+
pe.configure({ resizable: !0 }),
|
|
6791
|
+
he,
|
|
6792
|
+
q,
|
|
6775
6793
|
me,
|
|
6776
|
-
|
|
6777
|
-
pe,
|
|
6778
|
-
ve.configure({
|
|
6794
|
+
ye.configure({
|
|
6779
6795
|
html: !0,
|
|
6780
6796
|
transformPastedText: !0,
|
|
6781
6797
|
transformCopiedText: !1
|
|
6782
6798
|
}),
|
|
6783
|
-
|
|
6784
|
-
|
|
6799
|
+
fe.configure({ placeholder: e.placeholder || "输入 '/' 打开菜单…" }),
|
|
6800
|
+
ki(() => Ai((e) => f(e), {
|
|
6785
6801
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6786
6802
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6787
6803
|
})),
|
|
6788
|
-
|
|
6804
|
+
Rr.configure({
|
|
6789
6805
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6790
6806
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6791
6807
|
}),
|
|
6792
|
-
|
|
6793
|
-
ci,
|
|
6794
|
-
At,
|
|
6795
|
-
zr,
|
|
6808
|
+
Di,
|
|
6796
6809
|
li,
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6810
|
+
At,
|
|
6811
|
+
Br,
|
|
6812
|
+
ui,
|
|
6813
|
+
Zn,
|
|
6814
|
+
Wn,
|
|
6815
|
+
Vn
|
|
6800
6816
|
];
|
|
6801
6817
|
}
|
|
6802
6818
|
//#endregion
|
|
6803
6819
|
//#region src/editor/extensions/bubble-menu.tsx
|
|
6804
|
-
var Mi = "https://www.bing.com/search?q={query}";
|
|
6805
6820
|
function Ni(e) {
|
|
6806
|
-
|
|
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;
|
|
6807
6825
|
}
|
|
6808
|
-
function Pi() {
|
|
6809
|
-
|
|
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;
|
|
6810
6836
|
}
|
|
6811
|
-
function
|
|
6837
|
+
function Ri(e) {
|
|
6812
6838
|
return [
|
|
6813
6839
|
{
|
|
6814
6840
|
key: "bold",
|
|
@@ -6845,6 +6871,25 @@ function Fi(e) {
|
|
|
6845
6871
|
isActive: (e) => e.isActive("code"),
|
|
6846
6872
|
command: (e) => e.isEditable && e.chain().focus().toggleCode().run()
|
|
6847
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
|
+
},
|
|
6848
6893
|
{
|
|
6849
6894
|
key: "highlight",
|
|
6850
6895
|
label: e("editor.bubble.highlight"),
|
|
@@ -6882,7 +6927,7 @@ function Fi(e) {
|
|
|
6882
6927
|
if (e.isActive("table")) return;
|
|
6883
6928
|
let { from: t, to: n } = e.state.selection, r = e.state.doc.textBetween(t, n, " ").trim();
|
|
6884
6929
|
if (!r) return;
|
|
6885
|
-
let i =
|
|
6930
|
+
let i = Fi.replace("{query}", encodeURIComponent(r));
|
|
6886
6931
|
window.open(i, "_blank", "noopener,noreferrer");
|
|
6887
6932
|
}
|
|
6888
6933
|
},
|
|
@@ -6913,10 +6958,10 @@ function Fi(e) {
|
|
|
6913
6958
|
}
|
|
6914
6959
|
];
|
|
6915
6960
|
}
|
|
6916
|
-
|
|
6961
|
+
L.create({ name: "bubbleMenu" });
|
|
6917
6962
|
//#endregion
|
|
6918
6963
|
//#region src/editor/extensions/table-toolbar.tsx
|
|
6919
|
-
function
|
|
6964
|
+
function zi(e) {
|
|
6920
6965
|
let { $from: t } = e.state.selection;
|
|
6921
6966
|
for (let e = t.depth; e > 0; e--) {
|
|
6922
6967
|
let n = t.node(e);
|
|
@@ -6927,7 +6972,7 @@ function Ii(e) {
|
|
|
6927
6972
|
}
|
|
6928
6973
|
return null;
|
|
6929
6974
|
}
|
|
6930
|
-
function
|
|
6975
|
+
function Bi(e) {
|
|
6931
6976
|
let t = [];
|
|
6932
6977
|
return e.forEach((e) => {
|
|
6933
6978
|
let n = [];
|
|
@@ -6936,7 +6981,7 @@ function Li(e) {
|
|
|
6936
6981
|
}), t.push(n);
|
|
6937
6982
|
}), t;
|
|
6938
6983
|
}
|
|
6939
|
-
function
|
|
6984
|
+
function Vi(e) {
|
|
6940
6985
|
if (e.length === 0) return "";
|
|
6941
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(" | ")} |`;
|
|
6942
6987
|
return [
|
|
@@ -6945,11 +6990,11 @@ function Ri(e) {
|
|
|
6945
6990
|
...i.map(a)
|
|
6946
6991
|
].join("\n");
|
|
6947
6992
|
}
|
|
6948
|
-
function
|
|
6993
|
+
function Hi(e) {
|
|
6949
6994
|
let t = (e) => /[",\n]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e;
|
|
6950
6995
|
return e.map((e) => e.map(t).join(",")).join("\n");
|
|
6951
6996
|
}
|
|
6952
|
-
function
|
|
6997
|
+
function Ui(e) {
|
|
6953
6998
|
let t = e.trim();
|
|
6954
6999
|
if (!t) return null;
|
|
6955
7000
|
let n = t.split(/\r?\n/);
|
|
@@ -6963,7 +7008,7 @@ function Bi(e) {
|
|
|
6963
7008
|
}
|
|
6964
7009
|
return null;
|
|
6965
7010
|
}
|
|
6966
|
-
function
|
|
7011
|
+
function Wi({ editor: e }) {
|
|
6967
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(() => {
|
|
6968
7013
|
c.current != null && cancelAnimationFrame(c.current), c.current = requestAnimationFrame(() => {
|
|
6969
7014
|
c.current = null;
|
|
@@ -6979,7 +7024,7 @@ function Vi({ editor: e }) {
|
|
|
6979
7024
|
n(null);
|
|
6980
7025
|
return;
|
|
6981
7026
|
}
|
|
6982
|
-
let t =
|
|
7027
|
+
let t = zi(e);
|
|
6983
7028
|
if (!t) {
|
|
6984
7029
|
n(null);
|
|
6985
7030
|
return;
|
|
@@ -7008,24 +7053,24 @@ function Vi({ editor: e }) {
|
|
|
7008
7053
|
});
|
|
7009
7054
|
return n.nodes.table.create(null, i);
|
|
7010
7055
|
}, p = () => {
|
|
7011
|
-
let t =
|
|
7056
|
+
let t = zi(e);
|
|
7012
7057
|
if (!t) return;
|
|
7013
|
-
let n =
|
|
7058
|
+
let n = Vi(Bi(t.node));
|
|
7014
7059
|
navigator.clipboard?.writeText(n), i(!0), setTimeout(() => i(!1), 1500);
|
|
7015
7060
|
}, m = () => {
|
|
7016
|
-
let t =
|
|
7061
|
+
let t = zi(e);
|
|
7017
7062
|
if (!t) return;
|
|
7018
|
-
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");
|
|
7019
7064
|
a.href = i, a.download = "table.csv", document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
7020
7065
|
}, h = async () => {
|
|
7021
7066
|
if (l) try {
|
|
7022
7067
|
let t = await navigator.clipboard?.readText();
|
|
7023
7068
|
if (!t) return;
|
|
7024
|
-
let n =
|
|
7069
|
+
let n = Ui(t);
|
|
7025
7070
|
if (!n || n.length === 0) return;
|
|
7026
7071
|
let r = f(n);
|
|
7027
7072
|
if (!r) return;
|
|
7028
|
-
let i =
|
|
7073
|
+
let i = zi(e), a = e.chain().focus();
|
|
7029
7074
|
if (i) {
|
|
7030
7075
|
let t = Math.min(i.pos + i.node.nodeSize, e.state.doc.content.size);
|
|
7031
7076
|
a.setTextSelection(t);
|
|
@@ -7145,7 +7190,7 @@ function Vi({ editor: e }) {
|
|
|
7145
7190
|
type: "button",
|
|
7146
7191
|
className: "tbl-btn tbl-btn--del",
|
|
7147
7192
|
onClick: () => {
|
|
7148
|
-
!l ||
|
|
7193
|
+
!l || yn() || ($(!0), o(!0));
|
|
7149
7194
|
},
|
|
7150
7195
|
title: "删除",
|
|
7151
7196
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -7163,7 +7208,7 @@ function Vi({ editor: e }) {
|
|
|
7163
7208
|
})
|
|
7164
7209
|
})
|
|
7165
7210
|
}),
|
|
7166
|
-
/* @__PURE__ */ D(
|
|
7211
|
+
/* @__PURE__ */ D(wn, {
|
|
7167
7212
|
open: a,
|
|
7168
7213
|
title: "确认删除表格",
|
|
7169
7214
|
message: "此操作不可撤销。",
|
|
@@ -7179,7 +7224,7 @@ function Vi({ editor: e }) {
|
|
|
7179
7224
|
}
|
|
7180
7225
|
//#endregion
|
|
7181
7226
|
//#region src/editor/ai-editor.tsx
|
|
7182
|
-
var
|
|
7227
|
+
var Gi = [
|
|
7183
7228
|
{
|
|
7184
7229
|
color: "#fef08a",
|
|
7185
7230
|
name: "黄"
|
|
@@ -7204,9 +7249,9 @@ var Hi = [
|
|
|
7204
7249
|
color: "#ddd6fe",
|
|
7205
7250
|
name: "紫"
|
|
7206
7251
|
}
|
|
7207
|
-
],
|
|
7208
|
-
function
|
|
7209
|
-
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);
|
|
7210
7255
|
if (r < 640) {
|
|
7211
7256
|
let t = Math.max(8, Math.min(e.top + 10, i - 420));
|
|
7212
7257
|
return {
|
|
@@ -7247,10 +7292,10 @@ function Ki(e, t, n = {}) {
|
|
|
7247
7292
|
arrowLeft: p
|
|
7248
7293
|
};
|
|
7249
7294
|
}
|
|
7250
|
-
function
|
|
7295
|
+
function Xi(e) {
|
|
7251
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);
|
|
7252
7297
|
}
|
|
7253
|
-
function
|
|
7298
|
+
function Zi(e, t) {
|
|
7254
7299
|
try {
|
|
7255
7300
|
let n = e.storage?.markdown?.parser;
|
|
7256
7301
|
if (!n) return null;
|
|
@@ -7260,20 +7305,20 @@ function Ji(e, t) {
|
|
|
7260
7305
|
return null;
|
|
7261
7306
|
}
|
|
7262
7307
|
}
|
|
7263
|
-
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", {
|
|
7264
7309
|
className: "fixed inset-0 z-[9999] flex items-center justify-center",
|
|
7265
7310
|
children: [/* @__PURE__ */ D("div", { className: "absolute inset-0 bg-black/40 backdrop-blur-sm" }), /* @__PURE__ */ D("div", {
|
|
7266
7311
|
className: "relative bg-background rounded-2xl border border-default-200 p-8 flex items-center justify-center",
|
|
7267
7312
|
children: /* @__PURE__ */ D("div", { className: "w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin" })
|
|
7268
7313
|
})]
|
|
7269
|
-
}),
|
|
7270
|
-
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);
|
|
7271
7316
|
x(() => {
|
|
7272
|
-
|
|
7317
|
+
ge(m);
|
|
7273
7318
|
}, [m]);
|
|
7274
|
-
let [
|
|
7275
|
-
let e =
|
|
7276
|
-
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, {
|
|
7277
7322
|
position: "",
|
|
7278
7323
|
top: "",
|
|
7279
7324
|
left: "",
|
|
@@ -7289,9 +7334,9 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7289
7334
|
flex: "",
|
|
7290
7335
|
overflow: "",
|
|
7291
7336
|
minHeight: ""
|
|
7292
|
-
}),
|
|
7293
|
-
window.scrollTo(0,
|
|
7294
|
-
})) : (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, {
|
|
7295
7340
|
position: "fixed",
|
|
7296
7341
|
top: "0",
|
|
7297
7342
|
left: "0",
|
|
@@ -7306,42 +7351,42 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7306
7351
|
flex: "1",
|
|
7307
7352
|
overflow: "auto",
|
|
7308
7353
|
minHeight: "0"
|
|
7309
|
-
}), document.body.style.overflow = "hidden",
|
|
7310
|
-
}, [
|
|
7311
|
-
let e =
|
|
7312
|
-
e && (document.fullscreenElement ? document.exitFullscreen() : (
|
|
7313
|
-
}, [
|
|
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]);
|
|
7314
7359
|
x(() => {
|
|
7315
7360
|
let e = (e) => {
|
|
7316
|
-
e.key === "Escape" &&
|
|
7361
|
+
e.key === "Escape" && J && Ve();
|
|
7317
7362
|
}, t = () => {
|
|
7318
|
-
document.fullscreenElement ?
|
|
7319
|
-
window.scrollTo(0,
|
|
7363
|
+
document.fullscreenElement ? ze(!0) : (ze(!1), requestAnimationFrame(() => {
|
|
7364
|
+
window.scrollTo(0, Oe.current);
|
|
7320
7365
|
}));
|
|
7321
7366
|
};
|
|
7322
7367
|
return window.addEventListener("keydown", e), document.addEventListener("fullscreenchange", t), () => {
|
|
7323
7368
|
window.removeEventListener("keydown", e), document.removeEventListener("fullscreenchange", t);
|
|
7324
7369
|
};
|
|
7325
|
-
}, [
|
|
7370
|
+
}, [J, Ve]), x(() => {
|
|
7326
7371
|
if (!h) return;
|
|
7327
7372
|
let e = (e) => {
|
|
7328
7373
|
if ((e.ctrlKey || e.metaKey) && (e.key === "f" || e.key === "F")) {
|
|
7329
|
-
if (!
|
|
7330
|
-
e.preventDefault(), e.stopPropagation(),
|
|
7374
|
+
if (!Ee.current) return;
|
|
7375
|
+
e.preventDefault(), e.stopPropagation(), be(!0);
|
|
7331
7376
|
}
|
|
7332
7377
|
};
|
|
7333
7378
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
7334
7379
|
}, [h]), x(() => {
|
|
7335
7380
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
7336
|
-
let e = window.matchMedia("(min-width: 80rem)"), t = (e) =>
|
|
7337
|
-
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);
|
|
7338
7383
|
}, []), x(() => {
|
|
7339
7384
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
7340
|
-
let e = window.matchMedia("(min-width: 64rem)"), t = (e) =>
|
|
7341
|
-
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);
|
|
7342
7387
|
}, []);
|
|
7343
|
-
let
|
|
7344
|
-
extensions:
|
|
7388
|
+
let Y = te({
|
|
7389
|
+
extensions: Mi({
|
|
7345
7390
|
placeholder: n || f("editor.placeholder"),
|
|
7346
7391
|
maxLength: a,
|
|
7347
7392
|
maxAttachmentSize: o,
|
|
@@ -7351,11 +7396,15 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7351
7396
|
editable: !k,
|
|
7352
7397
|
immediatelyRender: _,
|
|
7353
7398
|
onUpdate: ({ editor: e }) => {
|
|
7354
|
-
t && (
|
|
7399
|
+
t && (Te.current && clearTimeout(Te.current), Te.current = setTimeout(() => {
|
|
7355
7400
|
t?.(e.getHTML(), e.getJSON());
|
|
7356
7401
|
}, 300));
|
|
7357
7402
|
},
|
|
7358
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
|
+
},
|
|
7359
7408
|
editorProps: {
|
|
7360
7409
|
attributes: {
|
|
7361
7410
|
class: "prose prose-neutral dark:prose-invert max-w-none focus:outline-none min-h-[200px] px-4 sm:px-8 py-4",
|
|
@@ -7367,9 +7416,9 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7367
7416
|
let r = n.getData("text/plain");
|
|
7368
7417
|
if (!r || !r.includes("[[")) return !1;
|
|
7369
7418
|
t.preventDefault();
|
|
7370
|
-
let i =
|
|
7419
|
+
let i = Ae.current?.storage?.relativeMedia;
|
|
7371
7420
|
i && (i.clipboardFiles = new Map(Array.from(n.files ?? []).map((e) => [e.name.toLowerCase(), e])), i.pausedUntilPaste = !1);
|
|
7372
|
-
let a =
|
|
7421
|
+
let a = Ae.current ? Zi(Ae.current, r) : null;
|
|
7373
7422
|
if (a) {
|
|
7374
7423
|
let t = new N(a, 0, 0);
|
|
7375
7424
|
e.dispatch(e.state.tr.replaceSelection(t).scrollIntoView());
|
|
@@ -7379,21 +7428,21 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7379
7428
|
}
|
|
7380
7429
|
});
|
|
7381
7430
|
x(() => {
|
|
7382
|
-
|
|
7383
|
-
}, [
|
|
7384
|
-
if (
|
|
7385
|
-
}, [
|
|
7386
|
-
!
|
|
7387
|
-
}, [
|
|
7388
|
-
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;
|
|
7389
7438
|
let e = () => {
|
|
7390
|
-
|
|
7439
|
+
Y.state.selection.empty && (G("none"), Pe(!1));
|
|
7391
7440
|
};
|
|
7392
|
-
return
|
|
7393
|
-
|
|
7441
|
+
return Y.on("selectionUpdate", e), () => {
|
|
7442
|
+
Y.off("selectionUpdate", e);
|
|
7394
7443
|
};
|
|
7395
|
-
}, [
|
|
7396
|
-
|
|
7444
|
+
}, [Y]), x(() => {
|
|
7445
|
+
Y && Y.setOptions({ extensions: Mi({
|
|
7397
7446
|
placeholder: n || f("editor.placeholder"),
|
|
7398
7447
|
maxLength: a,
|
|
7399
7448
|
maxAttachmentSize: o,
|
|
@@ -7405,33 +7454,33 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7405
7454
|
o,
|
|
7406
7455
|
s
|
|
7407
7456
|
]);
|
|
7408
|
-
let
|
|
7457
|
+
let Ue = w(e);
|
|
7409
7458
|
x(() => {
|
|
7410
|
-
if (!
|
|
7411
|
-
|
|
7412
|
-
let t = typeof e == "object" && e ||
|
|
7413
|
-
|
|
7414
|
-
}, [
|
|
7415
|
-
|
|
7416
|
-
}, [
|
|
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(() => {
|
|
7417
7466
|
if (y) return tt(y);
|
|
7418
7467
|
}, [y]), x(() => {
|
|
7419
|
-
if (!
|
|
7420
|
-
let e =
|
|
7421
|
-
e > s && Z(`文档内附件总大小 ${
|
|
7422
|
-
}, [
|
|
7423
|
-
if (!
|
|
7424
|
-
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;
|
|
7425
7474
|
e && (e.limits = {
|
|
7426
7475
|
maxAttachmentSize: o,
|
|
7427
7476
|
maxTotalAttachmentSize: s
|
|
7428
7477
|
});
|
|
7429
7478
|
}, [
|
|
7430
|
-
|
|
7479
|
+
Y,
|
|
7431
7480
|
o,
|
|
7432
7481
|
s
|
|
7433
7482
|
]);
|
|
7434
|
-
let
|
|
7483
|
+
let X = b((e, t) => {
|
|
7435
7484
|
let n = e ? Math.max(8, Math.min(e.left, window.innerWidth - 240 - 8)) : 8, r;
|
|
7436
7485
|
return r = e ? t && e.bottom + 8 + t > window.innerHeight ? Math.max(8, e.top - t - 8) : e.bottom + 8 : 8, {
|
|
7437
7486
|
position: "fixed",
|
|
@@ -7439,66 +7488,66 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7439
7488
|
left: n,
|
|
7440
7489
|
zIndex: 9999
|
|
7441
7490
|
};
|
|
7442
|
-
}, []),
|
|
7443
|
-
let t =
|
|
7444
|
-
|
|
7445
|
-
}, [
|
|
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]);
|
|
7446
7495
|
S(() => {
|
|
7447
|
-
if (
|
|
7448
|
-
let e =
|
|
7449
|
-
|
|
7450
|
-
}, [
|
|
7451
|
-
if (
|
|
7452
|
-
let e = () =>
|
|
7453
|
-
let e =
|
|
7454
|
-
|
|
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));
|
|
7455
7504
|
};
|
|
7456
7505
|
return window.addEventListener("scroll", e, !0), window.addEventListener("resize", t), () => {
|
|
7457
7506
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", t);
|
|
7458
7507
|
};
|
|
7459
|
-
}, [
|
|
7460
|
-
|
|
7461
|
-
}, [
|
|
7462
|
-
let
|
|
7463
|
-
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();
|
|
7464
7513
|
else {
|
|
7465
|
-
let e =
|
|
7466
|
-
|
|
7514
|
+
let e = Y.getAttributes("link").href || "";
|
|
7515
|
+
pe(e), We("link");
|
|
7467
7516
|
}
|
|
7468
|
-
else e.key === "highlight" ?
|
|
7517
|
+
else e.key === "highlight" ? W === "highlight" ? G("none") : We("highlight") : e.command(Y);
|
|
7469
7518
|
}, [
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
]),
|
|
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);
|
|
7474
7523
|
x(() => {
|
|
7475
|
-
if (!
|
|
7476
|
-
let e = () =>
|
|
7477
|
-
return
|
|
7478
|
-
|
|
7524
|
+
if (!Y) return;
|
|
7525
|
+
let e = () => $e((e) => (e + 1) % 1e6);
|
|
7526
|
+
return Y.on("update", e), () => {
|
|
7527
|
+
Y.off("update", e);
|
|
7479
7528
|
};
|
|
7480
|
-
}, [
|
|
7481
|
-
let [
|
|
7529
|
+
}, [Y]);
|
|
7530
|
+
let [et, nt] = T(!1);
|
|
7482
7531
|
x(() => {
|
|
7483
|
-
if (!
|
|
7532
|
+
if (!Y) return;
|
|
7484
7533
|
let e = () => {
|
|
7485
7534
|
let e = !1;
|
|
7486
|
-
|
|
7535
|
+
Y.state.doc.descendants((t) => {
|
|
7487
7536
|
t.type.name === "heading" && (e = !0);
|
|
7488
|
-
}),
|
|
7537
|
+
}), nt(e);
|
|
7489
7538
|
};
|
|
7490
|
-
return e(),
|
|
7491
|
-
|
|
7539
|
+
return e(), Y.on("update", e), () => {
|
|
7540
|
+
Y.off("update", e);
|
|
7492
7541
|
};
|
|
7493
|
-
}, [
|
|
7494
|
-
let
|
|
7542
|
+
}, [Y]);
|
|
7543
|
+
let rt = C(() => Y?.storage?.characterCount?.characters?.() ?? 0, [Y, Qe]), it = a ? rt > a : !1;
|
|
7495
7544
|
x(() => () => {
|
|
7496
|
-
|
|
7545
|
+
Te.current && clearTimeout(Te.current);
|
|
7497
7546
|
}, []), x(() => () => {
|
|
7498
|
-
|
|
7547
|
+
q && q.resolve(null);
|
|
7499
7548
|
}, []);
|
|
7500
|
-
let
|
|
7501
|
-
if (!
|
|
7549
|
+
let at = b((e) => {
|
|
7550
|
+
if (!Y?.isEditable) return;
|
|
7502
7551
|
let t = window.getSelection(), n;
|
|
7503
7552
|
if (e) {
|
|
7504
7553
|
let t = e.getBoundingClientRect();
|
|
@@ -7515,76 +7564,76 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7515
7564
|
width: e.width
|
|
7516
7565
|
};
|
|
7517
7566
|
} else {
|
|
7518
|
-
let e =
|
|
7567
|
+
let e = Y.view.coordsAtPos(Y.state.selection.from);
|
|
7519
7568
|
n = {
|
|
7520
7569
|
top: e.bottom,
|
|
7521
7570
|
left: e.left,
|
|
7522
7571
|
width: 0
|
|
7523
7572
|
};
|
|
7524
7573
|
}
|
|
7525
|
-
|
|
7526
|
-
let r =
|
|
7574
|
+
ke.current = n;
|
|
7575
|
+
let r = Ee.current?.getBoundingClientRect(), i = Yi(n, void 0, {
|
|
7527
7576
|
panelWidth: r?.width,
|
|
7528
7577
|
editorLeft: r?.left
|
|
7529
7578
|
});
|
|
7530
|
-
M(!0), F(i.style),
|
|
7531
|
-
}, [
|
|
7579
|
+
M(!0), F(i.style), L(i.placement), ae(i.arrowLeft);
|
|
7580
|
+
}, [Y]);
|
|
7532
7581
|
x(() => {
|
|
7533
|
-
if (!
|
|
7534
|
-
let e =
|
|
7535
|
-
if (e) return e.openImageDialog = () =>
|
|
7536
|
-
|
|
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({
|
|
7537
7586
|
filename: e,
|
|
7538
7587
|
resolve: t
|
|
7539
7588
|
});
|
|
7540
|
-
}, e.openAI =
|
|
7589
|
+
}, e.openAI = at, e.parseMd = (e, t) => Y ? Zi(Y, t) : null, () => {
|
|
7541
7590
|
delete e.openImageDialog, delete e.openVideoDialog, delete e.openAI, delete e.parseMd, delete e.chooseMd;
|
|
7542
7591
|
};
|
|
7543
|
-
}, [
|
|
7544
|
-
if (!j || !
|
|
7545
|
-
let e =
|
|
7592
|
+
}, [Y, at]), S(() => {
|
|
7593
|
+
if (!j || !Y) return;
|
|
7594
|
+
let e = ke.current;
|
|
7546
7595
|
if (!e) return;
|
|
7547
|
-
let t =
|
|
7596
|
+
let t = R.current, n = Ee.current?.getBoundingClientRect(), r = Yi(e, t?.offsetHeight || void 0, {
|
|
7548
7597
|
panelWidth: n?.width,
|
|
7549
7598
|
editorLeft: n?.left
|
|
7550
7599
|
});
|
|
7551
|
-
|
|
7552
|
-
}, [j,
|
|
7553
|
-
if (!j || !
|
|
7600
|
+
L(r.placement), ae(r.arrowLeft), F(r.style);
|
|
7601
|
+
}, [j, Y]), x(() => {
|
|
7602
|
+
if (!j || !Y) return;
|
|
7554
7603
|
let e = () => {
|
|
7555
|
-
let e =
|
|
7604
|
+
let e = ke.current;
|
|
7556
7605
|
if (!e) return;
|
|
7557
|
-
let t =
|
|
7606
|
+
let t = R.current, n = Ee.current?.getBoundingClientRect(), r = Yi(e, t?.offsetHeight || void 0, {
|
|
7558
7607
|
panelWidth: n?.width,
|
|
7559
7608
|
editorLeft: n?.left
|
|
7560
7609
|
});
|
|
7561
|
-
|
|
7610
|
+
L(r.placement), ae(r.arrowLeft), F(r.style);
|
|
7562
7611
|
};
|
|
7563
7612
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
7564
|
-
}, [j,
|
|
7565
|
-
j || (
|
|
7613
|
+
}, [j, Y]), x(() => {
|
|
7614
|
+
j || (ke.current = null);
|
|
7566
7615
|
}, [j]);
|
|
7567
|
-
let
|
|
7568
|
-
|
|
7569
|
-
}, [
|
|
7570
|
-
(
|
|
7571
|
-
}, [
|
|
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);
|
|
7572
7621
|
return x(() => {
|
|
7573
|
-
|
|
7574
|
-
}, [
|
|
7575
|
-
if (!
|
|
7622
|
+
ft.current || (ft.current = !0, he && !ct && ve(!0));
|
|
7623
|
+
}, [he, ct]), x(() => {
|
|
7624
|
+
if (!_e) return;
|
|
7576
7625
|
let e = (e) => {
|
|
7577
7626
|
let t = e.target;
|
|
7578
|
-
|
|
7627
|
+
Be.current?.contains(t) || ve(!1);
|
|
7579
7628
|
}, t = (e) => {
|
|
7580
|
-
e.key === "Escape" &&
|
|
7629
|
+
e.key === "Escape" && ve(!1);
|
|
7581
7630
|
};
|
|
7582
7631
|
return document.addEventListener("mousedown", e), document.addEventListener("touchstart", e, { passive: !0 }), document.addEventListener("keydown", t), () => {
|
|
7583
7632
|
document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e), document.removeEventListener("keydown", t);
|
|
7584
7633
|
};
|
|
7585
|
-
}, [
|
|
7586
|
-
if (!
|
|
7587
|
-
let e =
|
|
7634
|
+
}, [_e]), x(() => {
|
|
7635
|
+
if (!Y || !ct) return;
|
|
7636
|
+
let e = je.current;
|
|
7588
7637
|
if (!(e instanceof HTMLElement)) return;
|
|
7589
7638
|
let t = (t) => {
|
|
7590
7639
|
let n = t.deltaY;
|
|
@@ -7594,17 +7643,17 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7594
7643
|
e.scrollTop += n, t.preventDefault(), t.stopPropagation();
|
|
7595
7644
|
return;
|
|
7596
7645
|
}
|
|
7597
|
-
let a = ut(
|
|
7646
|
+
let a = ut(Y), o = a ? lt(a) : null;
|
|
7598
7647
|
if (o) {
|
|
7599
7648
|
o.scrollTop += n, t.preventDefault(), t.stopPropagation();
|
|
7600
7649
|
return;
|
|
7601
7650
|
}
|
|
7602
7651
|
};
|
|
7603
7652
|
return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
|
|
7604
|
-
}, [
|
|
7653
|
+
}, [Y, ct]), Y ? /* @__PURE__ */ O("div", {
|
|
7605
7654
|
className: "qingwu-editor-row",
|
|
7606
7655
|
children: [/* @__PURE__ */ O("div", {
|
|
7607
|
-
ref:
|
|
7656
|
+
ref: Ee,
|
|
7608
7657
|
className: `qingwu-editor relative flex-1 min-w-0 bg-background ${k ? "qingwu-editor--readonly" : ""} ${l ? "" : "rounded-xl border border-default-200"} ${c}`,
|
|
7609
7658
|
style: u,
|
|
7610
7659
|
children: [
|
|
@@ -7615,13 +7664,13 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7615
7664
|
children: [
|
|
7616
7665
|
/* @__PURE__ */ D("button", {
|
|
7617
7666
|
type: "button",
|
|
7618
|
-
className: `qed-tb-btn qed-tb-btn--desktop-only${
|
|
7667
|
+
className: `qed-tb-btn qed-tb-btn--desktop-only${he ? " is-active" : ""}`,
|
|
7619
7668
|
onClick: () => {
|
|
7620
|
-
|
|
7669
|
+
he ? (ge(!1), ve(!1)) : (ge(!0), xe && !J && !Re || ve(!0));
|
|
7621
7670
|
},
|
|
7622
|
-
title:
|
|
7623
|
-
"aria-label":
|
|
7624
|
-
"aria-pressed":
|
|
7671
|
+
title: he ? "隐藏目录" : "显示目录",
|
|
7672
|
+
"aria-label": he ? "隐藏目录" : "显示目录",
|
|
7673
|
+
"aria-pressed": he,
|
|
7625
7674
|
children: /* @__PURE__ */ D("svg", {
|
|
7626
7675
|
fill: "none",
|
|
7627
7676
|
viewBox: "0 0 24 24",
|
|
@@ -7637,11 +7686,11 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7637
7686
|
}),
|
|
7638
7687
|
h && /* @__PURE__ */ D("button", {
|
|
7639
7688
|
type: "button",
|
|
7640
|
-
className: `qed-tb-btn${
|
|
7641
|
-
onClick: () =>
|
|
7689
|
+
className: `qed-tb-btn${ye ? " is-active" : ""}`,
|
|
7690
|
+
onClick: () => be(!ye),
|
|
7642
7691
|
title: "查找 (Ctrl+F)",
|
|
7643
7692
|
"aria-label": "查找",
|
|
7644
|
-
"aria-pressed":
|
|
7693
|
+
"aria-pressed": ye,
|
|
7645
7694
|
children: /* @__PURE__ */ D("svg", {
|
|
7646
7695
|
fill: "none",
|
|
7647
7696
|
viewBox: "0 0 24 24",
|
|
@@ -7658,7 +7707,7 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7658
7707
|
!k && /* @__PURE__ */ D("button", {
|
|
7659
7708
|
type: "button",
|
|
7660
7709
|
className: `qed-tb-btn qed-tb-btn--ai${j ? " is-active" : ""}`,
|
|
7661
|
-
onClick: (e) => j ? M(!1) :
|
|
7710
|
+
onClick: (e) => j ? M(!1) : at(e.currentTarget),
|
|
7662
7711
|
title: f("editor.toolbar.aiTitle"),
|
|
7663
7712
|
"aria-label": f("editor.toolbar.ai"),
|
|
7664
7713
|
"aria-pressed": j,
|
|
@@ -7686,7 +7735,7 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7686
7735
|
/* @__PURE__ */ O("button", {
|
|
7687
7736
|
type: "button",
|
|
7688
7737
|
className: "qed-tb-btn qed-tb-btn--solid",
|
|
7689
|
-
onClick: () =>
|
|
7738
|
+
onClick: () => ce(!0),
|
|
7690
7739
|
title: f("editor.toolbar.exportTitle"),
|
|
7691
7740
|
children: [/* @__PURE__ */ D("svg", {
|
|
7692
7741
|
fill: "none",
|
|
@@ -7706,11 +7755,11 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7706
7755
|
}),
|
|
7707
7756
|
/* @__PURE__ */ D("button", {
|
|
7708
7757
|
type: "button",
|
|
7709
|
-
className: `qed-tb-btn${
|
|
7710
|
-
onClick:
|
|
7711
|
-
title:
|
|
7712
|
-
"aria-label":
|
|
7713
|
-
"aria-pressed":
|
|
7758
|
+
className: `qed-tb-btn${J ? " is-active" : ""}`,
|
|
7759
|
+
onClick: Ve,
|
|
7760
|
+
title: J ? "退出网页全屏" : "网页全屏",
|
|
7761
|
+
"aria-label": J ? "退出网页全屏" : "网页全屏",
|
|
7762
|
+
"aria-pressed": J,
|
|
7714
7763
|
children: /* @__PURE__ */ D("svg", {
|
|
7715
7764
|
fill: "none",
|
|
7716
7765
|
viewBox: "0 0 24 24",
|
|
@@ -7726,11 +7775,11 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7726
7775
|
}),
|
|
7727
7776
|
/* @__PURE__ */ D("button", {
|
|
7728
7777
|
type: "button",
|
|
7729
|
-
className: `qed-tb-btn${
|
|
7730
|
-
onClick:
|
|
7731
|
-
title:
|
|
7732
|
-
"aria-label":
|
|
7733
|
-
"aria-pressed":
|
|
7778
|
+
className: `qed-tb-btn${Re ? " is-active" : ""}`,
|
|
7779
|
+
onClick: He,
|
|
7780
|
+
title: Re ? "退出全屏" : "全屏",
|
|
7781
|
+
"aria-label": Re ? "退出全屏" : "全屏",
|
|
7782
|
+
"aria-pressed": Re,
|
|
7734
7783
|
children: /* @__PURE__ */ D("svg", {
|
|
7735
7784
|
fill: "none",
|
|
7736
7785
|
viewBox: "0 0 24 24",
|
|
@@ -7747,8 +7796,8 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7747
7796
|
]
|
|
7748
7797
|
})]
|
|
7749
7798
|
}),
|
|
7750
|
-
|
|
7751
|
-
editor:
|
|
7799
|
+
Y && !k && Y.isEditable && /* @__PURE__ */ D(ne, {
|
|
7800
|
+
editor: Y,
|
|
7752
7801
|
shouldShow: ({ editor: e, state: t }) => !(e.isActive("image") || e.isActive("videoEmbed") || e.isActive("codeBlock") || e.isActive("audioEmbed") || e.isActive("attachmentEmbed") || t.selection.empty),
|
|
7753
7802
|
options: {
|
|
7754
7803
|
placement: "bottom",
|
|
@@ -7757,17 +7806,17 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7757
7806
|
},
|
|
7758
7807
|
className: "bubble-menu-pop bg-background border border-default-200 rounded-xl p-1 shadow-lg",
|
|
7759
7808
|
children: /* @__PURE__ */ O("div", {
|
|
7760
|
-
ref:
|
|
7809
|
+
ref: Me,
|
|
7761
7810
|
className: "bubble-menu-items relative flex items-center gap-0.5",
|
|
7762
7811
|
onPointerDown: (e) => {
|
|
7763
7812
|
e.target.closest("button") && e.preventDefault();
|
|
7764
7813
|
},
|
|
7765
7814
|
children: [
|
|
7766
|
-
|
|
7815
|
+
Je.map((e) => /* @__PURE__ */ D("button", {
|
|
7767
7816
|
type: "button",
|
|
7768
|
-
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"}`,
|
|
7769
7818
|
onClick: (t) => {
|
|
7770
|
-
t.preventDefault(),
|
|
7819
|
+
t.preventDefault(), Xe(e);
|
|
7771
7820
|
},
|
|
7772
7821
|
title: e.label,
|
|
7773
7822
|
"aria-label": e.label,
|
|
@@ -7781,10 +7830,10 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7781
7830
|
type: "button",
|
|
7782
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"}`,
|
|
7783
7832
|
onClick: (e) => {
|
|
7784
|
-
e.preventDefault(),
|
|
7833
|
+
e.preventDefault(), Pe(!1), Ye?.command(Y);
|
|
7785
7834
|
},
|
|
7786
|
-
title:
|
|
7787
|
-
"aria-label":
|
|
7835
|
+
title: Ye?.label,
|
|
7836
|
+
"aria-label": Ye?.label,
|
|
7788
7837
|
children: /* @__PURE__ */ D(Ut, {})
|
|
7789
7838
|
}),
|
|
7790
7839
|
/* @__PURE__ */ D("span", {
|
|
@@ -7793,27 +7842,27 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7793
7842
|
}),
|
|
7794
7843
|
/* @__PURE__ */ D("button", {
|
|
7795
7844
|
type: "button",
|
|
7796
|
-
"aria-expanded":
|
|
7797
|
-
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"}`,
|
|
7798
7847
|
onClick: (e) => {
|
|
7799
|
-
e.preventDefault(),
|
|
7848
|
+
e.preventDefault(), Pe((e) => !e);
|
|
7800
7849
|
},
|
|
7801
7850
|
title: f("editor.bubble.more"),
|
|
7802
7851
|
"aria-label": f("editor.bubble.more"),
|
|
7803
|
-
children: /* @__PURE__ */ D(
|
|
7852
|
+
children: /* @__PURE__ */ D(Gt, {})
|
|
7804
7853
|
}),
|
|
7805
|
-
|
|
7854
|
+
Ne && /* @__PURE__ */ D("div", {
|
|
7806
7855
|
role: "menu",
|
|
7807
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",
|
|
7808
7857
|
onPointerDown: (e) => {
|
|
7809
7858
|
e.target.closest("button") && e.preventDefault();
|
|
7810
7859
|
},
|
|
7811
|
-
children:
|
|
7860
|
+
children: qe.map((e) => /* @__PURE__ */ O("button", {
|
|
7812
7861
|
type: "button",
|
|
7813
7862
|
role: "menuitem",
|
|
7814
|
-
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"}`,
|
|
7815
7864
|
onClick: (t) => {
|
|
7816
|
-
t.preventDefault(),
|
|
7865
|
+
t.preventDefault(), Xe(e);
|
|
7817
7866
|
},
|
|
7818
7867
|
title: e.label,
|
|
7819
7868
|
children: [/* @__PURE__ */ D("span", {
|
|
@@ -7828,30 +7877,30 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7828
7877
|
]
|
|
7829
7878
|
})
|
|
7830
7879
|
}),
|
|
7831
|
-
|
|
7880
|
+
Y && W !== "none" && re(/* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
7832
7881
|
className: "fixed inset-0 z-[9998]",
|
|
7833
|
-
onClick: () =>
|
|
7882
|
+
onClick: () => G("none")
|
|
7834
7883
|
}), /* @__PURE__ */ D("div", {
|
|
7835
|
-
ref:
|
|
7836
|
-
style:
|
|
7884
|
+
ref: ue,
|
|
7885
|
+
style: le,
|
|
7837
7886
|
className: "bg-background border border-default-200 rounded-xl shadow-xl",
|
|
7838
7887
|
onClick: (e) => e.stopPropagation(),
|
|
7839
|
-
children:
|
|
7888
|
+
children: W === "highlight" ? /* @__PURE__ */ O("div", {
|
|
7840
7889
|
className: "flex items-center gap-1 p-1.5 flex-wrap",
|
|
7841
|
-
children: [
|
|
7890
|
+
children: [Gi.map((e) => /* @__PURE__ */ D("button", {
|
|
7842
7891
|
type: "button",
|
|
7843
7892
|
className: "w-5 h-5 rounded-full border border-default-200 hover:scale-110 transition-transform",
|
|
7844
7893
|
style: { background: e.color },
|
|
7845
7894
|
title: e.name,
|
|
7846
7895
|
onClick: () => {
|
|
7847
|
-
|
|
7896
|
+
Y.chain().focus().setHighlight({ color: e.color }).run(), G("none");
|
|
7848
7897
|
}
|
|
7849
7898
|
}, e.color)), /* @__PURE__ */ O("button", {
|
|
7850
7899
|
type: "button",
|
|
7851
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]",
|
|
7852
7901
|
title: "清除高亮",
|
|
7853
7902
|
onClick: () => {
|
|
7854
|
-
|
|
7903
|
+
Y.chain().focus().unsetHighlight().run(), G("none");
|
|
7855
7904
|
},
|
|
7856
7905
|
children: ["✕", " "]
|
|
7857
7906
|
})]
|
|
@@ -7861,104 +7910,104 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7861
7910
|
type: "url",
|
|
7862
7911
|
className: "flex-1 px-2 py-1 text-xs rounded-md border border-default-200 bg-background focus:outline-none focus:border-primary",
|
|
7863
7912
|
placeholder: "https://...",
|
|
7864
|
-
value:
|
|
7865
|
-
onChange: (e) =>
|
|
7913
|
+
value: fe,
|
|
7914
|
+
onChange: (e) => pe(e.target.value),
|
|
7866
7915
|
onKeyDown: (e) => {
|
|
7867
|
-
e.key === "Enter" ? (
|
|
7916
|
+
e.key === "Enter" ? (fe.trim() && Y.chain().focus().setLink({ href: fe.trim() }).run(), G("none")) : e.key === "Escape" && G("none");
|
|
7868
7917
|
}
|
|
7869
7918
|
}), /* @__PURE__ */ D("button", {
|
|
7870
7919
|
type: "button",
|
|
7871
7920
|
className: "px-2 py-1 text-xs rounded-md bg-primary text-white hover:opacity-90",
|
|
7872
7921
|
onClick: () => {
|
|
7873
|
-
|
|
7922
|
+
fe.trim() && Y.chain().focus().setLink({ href: fe.trim() }).run(), G("none");
|
|
7874
7923
|
},
|
|
7875
7924
|
children: "确定"
|
|
7876
7925
|
})]
|
|
7877
7926
|
})
|
|
7878
7927
|
})] }), document.body),
|
|
7879
|
-
!k && j &&
|
|
7928
|
+
!k && j && re(/* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
7880
7929
|
className: "fixed inset-0 z-[9998]",
|
|
7881
7930
|
onClick: () => M(!1)
|
|
7882
7931
|
}), /* @__PURE__ */ O("div", {
|
|
7883
|
-
ref:
|
|
7932
|
+
ref: R,
|
|
7884
7933
|
"data-lenis-prevent": !0,
|
|
7885
7934
|
style: P,
|
|
7886
7935
|
className: `ai-panel relative flex flex-col bg-background border border-default-200 rounded-xl shadow-xl${I === "above" ? " ai-panel--above" : ""}`,
|
|
7887
7936
|
onClick: (e) => e.stopPropagation(),
|
|
7888
7937
|
children: [/* @__PURE__ */ D("span", {
|
|
7889
7938
|
className: "ai-panel__arrow",
|
|
7890
|
-
style: { left: `${
|
|
7939
|
+
style: { left: `${ie}%` },
|
|
7891
7940
|
"aria-hidden": "true"
|
|
7892
|
-
}), /* @__PURE__ */ D(
|
|
7893
|
-
editor:
|
|
7941
|
+
}), /* @__PURE__ */ D(un, {
|
|
7942
|
+
editor: Y,
|
|
7894
7943
|
onClose: () => M(!1)
|
|
7895
7944
|
})]
|
|
7896
7945
|
})] }), document.body),
|
|
7897
|
-
|
|
7898
|
-
fallback: /* @__PURE__ */ D(
|
|
7899
|
-
children: /* @__PURE__ */ D(
|
|
7900
|
-
open:
|
|
7901
|
-
onClose: () =>
|
|
7902
|
-
onInsert:
|
|
7903
|
-
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, {
|
|
7904
7953
|
maxAttachmentSize: o,
|
|
7905
7954
|
maxTotalAttachmentSize: s
|
|
7906
7955
|
}) : null
|
|
7907
7956
|
})
|
|
7908
7957
|
}),
|
|
7909
|
-
|
|
7910
|
-
fallback: /* @__PURE__ */ D(
|
|
7911
|
-
children: /* @__PURE__ */ D(
|
|
7912
|
-
open:
|
|
7913
|
-
onClose: () =>
|
|
7914
|
-
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
|
|
7915
7964
|
})
|
|
7916
7965
|
}),
|
|
7917
|
-
|
|
7918
|
-
fallback: /* @__PURE__ */ D(
|
|
7919
|
-
children: /* @__PURE__ */ D(
|
|
7920
|
-
open:
|
|
7921
|
-
onClose: () =>
|
|
7966
|
+
se && /* @__PURE__ */ D(v, {
|
|
7967
|
+
fallback: /* @__PURE__ */ D(ra, {}),
|
|
7968
|
+
children: /* @__PURE__ */ D($i, {
|
|
7969
|
+
open: se,
|
|
7970
|
+
onClose: () => H(!1)
|
|
7922
7971
|
})
|
|
7923
7972
|
}),
|
|
7924
|
-
|
|
7925
|
-
fallback: /* @__PURE__ */ D(
|
|
7926
|
-
children: /* @__PURE__ */ D(
|
|
7927
|
-
open:
|
|
7928
|
-
onClose: () =>
|
|
7929
|
-
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
|
|
7930
7979
|
})
|
|
7931
7980
|
}),
|
|
7932
|
-
|
|
7933
|
-
fallback: /* @__PURE__ */ D(
|
|
7934
|
-
children: /* @__PURE__ */ D(
|
|
7935
|
-
open: !!
|
|
7936
|
-
filename:
|
|
7981
|
+
q && /* @__PURE__ */ D(v, {
|
|
7982
|
+
fallback: /* @__PURE__ */ D(ra, {}),
|
|
7983
|
+
children: /* @__PURE__ */ D(na, {
|
|
7984
|
+
open: !!q,
|
|
7985
|
+
filename: q.filename,
|
|
7937
7986
|
onRender: () => {
|
|
7938
|
-
|
|
7987
|
+
q.resolve("render"), me(null);
|
|
7939
7988
|
},
|
|
7940
7989
|
onAttach: () => {
|
|
7941
|
-
|
|
7990
|
+
q.resolve("attach"), me(null);
|
|
7942
7991
|
},
|
|
7943
7992
|
onClose: () => {
|
|
7944
|
-
|
|
7993
|
+
q.resolve(null), me(null);
|
|
7945
7994
|
}
|
|
7946
7995
|
})
|
|
7947
7996
|
}),
|
|
7948
7997
|
/* @__PURE__ */ D("div", {
|
|
7949
|
-
ref:
|
|
7998
|
+
ref: De,
|
|
7950
7999
|
className: "flex editor-body",
|
|
7951
8000
|
children: /* @__PURE__ */ O("div", {
|
|
7952
8001
|
className: "relative min-w-0 flex-1",
|
|
7953
8002
|
children: [
|
|
7954
|
-
/* @__PURE__ */ D(ee, { editor:
|
|
7955
|
-
!k && /* @__PURE__ */ D(
|
|
8003
|
+
/* @__PURE__ */ D(ee, { editor: Y }),
|
|
8004
|
+
!k && /* @__PURE__ */ D(Wi, { editor: Y }),
|
|
7956
8005
|
/* @__PURE__ */ D("div", {
|
|
7957
|
-
className: `${
|
|
8006
|
+
className: `${J || Re ? "fixed" : "absolute"} bottom-2 right-4 z-10 pointer-events-none select-none`,
|
|
7958
8007
|
children: /* @__PURE__ */ O("span", {
|
|
7959
|
-
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"}`,
|
|
7960
8009
|
children: [
|
|
7961
|
-
|
|
8010
|
+
rt,
|
|
7962
8011
|
a ? ` / ${a}` : "",
|
|
7963
8012
|
" 字"
|
|
7964
8013
|
]
|
|
@@ -7967,14 +8016,14 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7967
8016
|
]
|
|
7968
8017
|
})
|
|
7969
8018
|
}),
|
|
7970
|
-
h &&
|
|
7971
|
-
editor:
|
|
7972
|
-
onClose: () =>
|
|
8019
|
+
h && ye && /* @__PURE__ */ D(Mt, {
|
|
8020
|
+
editor: Y,
|
|
8021
|
+
onClose: () => be(!1)
|
|
7973
8022
|
}),
|
|
7974
|
-
|
|
8023
|
+
dt && /* @__PURE__ */ D("button", {
|
|
7975
8024
|
type: "button",
|
|
7976
8025
|
className: "qingwu-toc-fab",
|
|
7977
|
-
onClick: () =>
|
|
8026
|
+
onClick: () => ve(!0),
|
|
7978
8027
|
title: "目录",
|
|
7979
8028
|
"aria-label": "打开目录",
|
|
7980
8029
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -7990,8 +8039,8 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7990
8039
|
})
|
|
7991
8040
|
})
|
|
7992
8041
|
}),
|
|
7993
|
-
|
|
7994
|
-
ref:
|
|
8042
|
+
_e && re(/* @__PURE__ */ O("div", {
|
|
8043
|
+
ref: Be,
|
|
7995
8044
|
className: "qingwu-toc-drawer toc-scroll",
|
|
7996
8045
|
"data-lenis-prevent": !0,
|
|
7997
8046
|
children: [/* @__PURE__ */ O("div", {
|
|
@@ -8002,7 +8051,7 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
8002
8051
|
}), /* @__PURE__ */ D("button", {
|
|
8003
8052
|
type: "button",
|
|
8004
8053
|
className: "qed-drawer-head__close",
|
|
8005
|
-
onClick: () =>
|
|
8054
|
+
onClick: () => ve(!1),
|
|
8006
8055
|
"aria-label": "关闭目录",
|
|
8007
8056
|
children: /* @__PURE__ */ D("svg", {
|
|
8008
8057
|
fill: "none",
|
|
@@ -8018,20 +8067,20 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
8018
8067
|
})
|
|
8019
8068
|
})]
|
|
8020
8069
|
}), /* @__PURE__ */ D(mt, {
|
|
8021
|
-
editor:
|
|
8070
|
+
editor: Y,
|
|
8022
8071
|
className: "!p-3",
|
|
8023
8072
|
onClose: () => {
|
|
8024
|
-
|
|
8073
|
+
ve(!1), ge(!1);
|
|
8025
8074
|
}
|
|
8026
8075
|
})]
|
|
8027
8076
|
}), document.body)
|
|
8028
8077
|
]
|
|
8029
|
-
}),
|
|
8030
|
-
ref:
|
|
8078
|
+
}), ct && re(/* @__PURE__ */ D("aside", {
|
|
8079
|
+
ref: je,
|
|
8031
8080
|
className: "qingwu-toc-desktop toc-scroll",
|
|
8032
8081
|
children: /* @__PURE__ */ D(mt, {
|
|
8033
|
-
editor:
|
|
8034
|
-
onClose: () =>
|
|
8082
|
+
editor: Y,
|
|
8083
|
+
onClose: () => ge(!1)
|
|
8035
8084
|
})
|
|
8036
8085
|
}), document.body)]
|
|
8037
8086
|
}) : /* @__PURE__ */ D("div", {
|
|
@@ -8041,7 +8090,7 @@ var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
8041
8090
|
};
|
|
8042
8091
|
//#endregion
|
|
8043
8092
|
//#region src/editor/clipper/receiver-browser.ts
|
|
8044
|
-
function
|
|
8093
|
+
function aa(e) {
|
|
8045
8094
|
let t = async (t) => {
|
|
8046
8095
|
let n = t.data;
|
|
8047
8096
|
if (!n || typeof n != "object" || n.kind !== "qingwu-clip") return;
|
|
@@ -8058,7 +8107,7 @@ function na(e) {
|
|
|
8058
8107
|
}
|
|
8059
8108
|
//#endregion
|
|
8060
8109
|
//#region src/editor/storage/providers/cos.ts
|
|
8061
|
-
function
|
|
8110
|
+
function oa(e) {
|
|
8062
8111
|
return g({
|
|
8063
8112
|
endpoint: `https://cos.${e.region}.myqcloud.com`,
|
|
8064
8113
|
bucket: e.bucket,
|
|
@@ -8072,7 +8121,7 @@ function ra(e) {
|
|
|
8072
8121
|
}
|
|
8073
8122
|
//#endregion
|
|
8074
8123
|
//#region src/editor/storage/providers/oss.ts
|
|
8075
|
-
function
|
|
8124
|
+
function sa(e) {
|
|
8076
8125
|
return g({
|
|
8077
8126
|
endpoint: `https://${e.bucket}.${e.region}.aliyuncs.com`,
|
|
8078
8127
|
bucket: e.bucket,
|
|
@@ -8085,4 +8134,4 @@ function ia(e) {
|
|
|
8085
8134
|
});
|
|
8086
8135
|
}
|
|
8087
8136
|
//#endregion
|
|
8088
|
-
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 };
|