@qingwu-ui/ai-editor 1.0.3 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +2 -2
- package/README.md +2 -1
- package/dist/assets/katex-fonts/katex-0.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-1.woff +0 -0
- package/dist/assets/katex-fonts/katex-10.woff +0 -0
- package/dist/assets/katex-fonts/katex-11.ttf +0 -0
- package/dist/assets/katex-fonts/katex-12.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-13.woff +0 -0
- package/dist/assets/katex-fonts/katex-14.ttf +0 -0
- package/dist/assets/katex-fonts/katex-15.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-16.woff +0 -0
- package/dist/assets/katex-fonts/katex-17.ttf +0 -0
- package/dist/assets/katex-fonts/katex-18.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-19.woff +0 -0
- package/dist/assets/katex-fonts/katex-2.ttf +0 -0
- package/dist/assets/katex-fonts/katex-20.ttf +0 -0
- package/dist/assets/katex-fonts/katex-21.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-22.woff +0 -0
- package/dist/assets/katex-fonts/katex-23.ttf +0 -0
- package/dist/assets/katex-fonts/katex-24.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-25.woff +0 -0
- package/dist/assets/katex-fonts/katex-26.ttf +0 -0
- package/dist/assets/katex-fonts/katex-27.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-28.woff +0 -0
- package/dist/assets/katex-fonts/katex-29.ttf +0 -0
- package/dist/assets/katex-fonts/katex-3.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-30.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-31.woff +0 -0
- package/dist/assets/katex-fonts/katex-32.ttf +0 -0
- package/dist/assets/katex-fonts/katex-33.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-34.woff +0 -0
- package/dist/assets/katex-fonts/katex-35.ttf +0 -0
- package/dist/assets/katex-fonts/katex-36.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-37.woff +0 -0
- package/dist/assets/katex-fonts/katex-38.ttf +0 -0
- package/dist/assets/katex-fonts/katex-39.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-4.woff +0 -0
- package/dist/assets/katex-fonts/katex-40.woff +0 -0
- package/dist/assets/katex-fonts/katex-41.ttf +0 -0
- package/dist/assets/katex-fonts/katex-42.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-43.woff +0 -0
- package/dist/assets/katex-fonts/katex-44.ttf +0 -0
- package/dist/assets/katex-fonts/katex-45.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-46.woff +0 -0
- package/dist/assets/katex-fonts/katex-47.ttf +0 -0
- package/dist/assets/katex-fonts/katex-48.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-49.woff +0 -0
- package/dist/assets/katex-fonts/katex-5.ttf +0 -0
- package/dist/assets/katex-fonts/katex-50.ttf +0 -0
- package/dist/assets/katex-fonts/katex-51.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-52.woff +0 -0
- package/dist/assets/katex-fonts/katex-53.ttf +0 -0
- package/dist/assets/katex-fonts/katex-54.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-55.woff +0 -0
- package/dist/assets/katex-fonts/katex-56.ttf +0 -0
- package/dist/assets/katex-fonts/katex-57.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-58.woff +0 -0
- package/dist/assets/katex-fonts/katex-59.ttf +0 -0
- package/dist/assets/katex-fonts/katex-6.woff2 +0 -0
- package/dist/assets/katex-fonts/katex-7.woff +0 -0
- package/dist/assets/katex-fonts/katex-8.ttf +0 -0
- package/dist/assets/katex-fonts/katex-9.woff2 +0 -0
- package/dist/components/release-notes-dialog.d.ts.map +1 -1
- package/dist/editor/extensions/code-block-view.d.ts.map +1 -1
- package/dist/editor/extensions/index.d.ts +2 -1
- package/dist/editor/extensions/index.d.ts.map +1 -1
- package/dist/editor/extensions/math-utils.d.ts +9 -0
- package/dist/editor/extensions/math-utils.d.ts.map +1 -0
- package/dist/editor/extensions/math-view.d.ts +27 -0
- package/dist/editor/extensions/math-view.d.ts.map +1 -0
- package/dist/editor/extensions/math.d.ts +44 -0
- package/dist/editor/extensions/math.d.ts.map +1 -0
- package/dist/editor/extensions/slash-command.d.ts.map +1 -1
- package/dist/editor/i18n/en-US.d.ts +14 -0
- package/dist/editor/i18n/en-US.d.ts.map +1 -1
- package/dist/editor/i18n/zh-CN.d.ts +14 -0
- package/dist/editor/i18n/zh-CN.d.ts.map +1 -1
- package/dist/editor/index.d.ts +1 -1
- package/dist/editor/index.d.ts.map +1 -1
- package/dist/editor/utils/local-media.d.ts +1 -1
- package/dist/editor/utils/local-media.d.ts.map +1 -1
- package/dist/{export-dialog-BJReD1PN.cjs → export-dialog-BKShGPNv.cjs} +1 -1
- package/dist/{export-dialog-CJhm3uqR.js → export-dialog-DMY_QIVq.js} +1 -1
- package/dist/index.cjs +14 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1382 -891
- package/dist/sanitize-D4Bd9RtA.cjs +1 -0
- package/dist/{sanitize-wGLeVLFO.js → sanitize-DdIs-mcO.js} +28 -0
- package/dist/{signed-fetch-BiI-JlzZ.cjs → signed-fetch-ULpEJyn5.cjs} +1 -1
- package/dist/{storage-settings-dialog-zPgJahMO.cjs → storage-settings-dialog-WBHfAUak.cjs} +1 -1
- package/dist/styles.css +1 -2
- package/package.json +3 -1
- package/dist/sanitize-Bcj55kwd.cjs +0 -1
package/dist/index.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
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-DdIs-mcO.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";
|
|
7
7
|
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
|
-
import { EditorContent as
|
|
10
|
-
import { BubbleMenu as
|
|
11
|
-
import { createPortal as
|
|
12
|
-
import { Extension as R,
|
|
13
|
-
import { NodeSelection as
|
|
14
|
-
import { Decoration as
|
|
15
|
-
import { Image as
|
|
16
|
-
import { Link as
|
|
9
|
+
import { EditorContent as ee, NodeViewWrapper as P, ReactNodeViewRenderer as F, ReactRenderer as I, useEditor as te } from "@tiptap/react";
|
|
10
|
+
import { BubbleMenu as ne } from "@tiptap/react/menus";
|
|
11
|
+
import { createPortal as L } from "react-dom";
|
|
12
|
+
import { Extension as R, InputRule as re, Node as ie, markInputRule as z } from "@tiptap/core";
|
|
13
|
+
import { NodeSelection as B, Plugin as V, PluginKey as H, TextSelection as ae } from "@tiptap/pm/state";
|
|
14
|
+
import { Decoration as oe, DecorationSet as U } from "@tiptap/pm/view";
|
|
15
|
+
import { Image as W } from "@tiptap/extension-image";
|
|
16
|
+
import { Link as se } from "@tiptap/extension-link";
|
|
17
17
|
import { Underline as G } from "@tiptap/extension-underline";
|
|
18
18
|
import K from "@tiptap/starter-kit";
|
|
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
|
|
19
|
+
import { CharacterCount as ce } from "@tiptap/extension-character-count";
|
|
20
|
+
import { Color as q } from "@tiptap/extension-color";
|
|
21
|
+
import { Highlight as le } from "@tiptap/extension-highlight";
|
|
22
|
+
import { HorizontalRule as ue } from "@tiptap/extension-horizontal-rule";
|
|
23
|
+
import { Placeholder as de } from "@tiptap/extension-placeholder";
|
|
24
|
+
import { Table as fe } from "@tiptap/extension-table";
|
|
25
|
+
import { TableCell as J } from "@tiptap/extension-table-cell";
|
|
26
26
|
import { TableHeader as pe } from "@tiptap/extension-table-header";
|
|
27
27
|
import { TableRow as me } from "@tiptap/extension-table-row";
|
|
28
28
|
import { TaskItem as he } from "@tiptap/extension-task-item";
|
|
@@ -32,30 +32,31 @@ import { Markdown as ve } from "tiptap-markdown";
|
|
|
32
32
|
import { CodeBlockLowlight as ye } from "@tiptap/extension-code-block-lowlight";
|
|
33
33
|
import be from "highlight.js/lib/languages/dockerfile";
|
|
34
34
|
import { common as xe, createLowlight as Se } from "lowlight";
|
|
35
|
-
import Ce
|
|
35
|
+
import Ce from "katex";
|
|
36
|
+
import we, { exitSuggestion as Te, findSuggestionMatch as Ee } from "@tiptap/suggestion";
|
|
36
37
|
//#region ../text-layout/dist/index.mjs
|
|
37
|
-
var
|
|
38
|
-
function
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
var
|
|
42
|
-
function
|
|
43
|
-
let n =
|
|
44
|
-
n || (n = /* @__PURE__ */ new Map(),
|
|
38
|
+
var De = null, Oe = null;
|
|
39
|
+
function ke() {
|
|
40
|
+
return Oe || (typeof document > "u" ? null : (De = document.createElement("canvas"), Oe = De.getContext("2d"), Oe));
|
|
41
|
+
}
|
|
42
|
+
var Ae = /* @__PURE__ */ new Map();
|
|
43
|
+
function je(e, t) {
|
|
44
|
+
let n = Ae.get(t);
|
|
45
|
+
n || (n = /* @__PURE__ */ new Map(), Ae.set(t, n));
|
|
45
46
|
let r = n.get(e);
|
|
46
47
|
if (r !== void 0) return r;
|
|
47
|
-
let i =
|
|
48
|
-
return i ? (i.font = t, r = i.measureText(e).width) : r =
|
|
48
|
+
let i = ke();
|
|
49
|
+
return i ? (i.font = t, r = i.measureText(e).width) : r = Me(e, t), n.set(e, r), r;
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
+
function Me(e, t) {
|
|
51
52
|
let n = parseFloat(t) || 16, r = 0;
|
|
52
|
-
for (let t of e)
|
|
53
|
+
for (let t of e) Ne(t.codePointAt(0) ?? 0) ? r += n : t === " " ? r += n * .3 : r += n * .55;
|
|
53
54
|
return r;
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
+
function Ne(e) {
|
|
56
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;
|
|
57
58
|
}
|
|
58
|
-
function
|
|
59
|
+
function Y(e) {
|
|
59
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;
|
|
60
61
|
}
|
|
61
62
|
function Pe(e, t) {
|
|
@@ -69,26 +70,26 @@ function Pe(e, t) {
|
|
|
69
70
|
else r = [...e];
|
|
70
71
|
for (let e of r) {
|
|
71
72
|
let r = e.codePointAt(0) ?? 0, i = "latin";
|
|
72
|
-
e === "\n" ? i = "break" : e === " " || e === " " ? i = "space" :
|
|
73
|
+
e === "\n" ? i = "break" : e === " " || e === " " ? i = "space" : Ne(r) && (i = Y(r) ? "punct" : "cjk"), n.push({
|
|
73
74
|
text: e,
|
|
74
|
-
width:
|
|
75
|
+
width: je(e, t),
|
|
75
76
|
type: i
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
79
|
return n;
|
|
79
80
|
}
|
|
80
|
-
function
|
|
81
|
+
function Fe(e, t, n) {
|
|
81
82
|
let r = 0, i = Math.min(n, e.length);
|
|
82
83
|
for (let n = t; n < i; n++) r += e[n].width;
|
|
83
84
|
return r;
|
|
84
85
|
}
|
|
85
|
-
function
|
|
86
|
+
function Ie(e, t, n, r) {
|
|
86
87
|
return {
|
|
87
88
|
text: e.slice(t, Math.min(n, e.length)).map((e) => e.text).join(""),
|
|
88
89
|
width: r
|
|
89
90
|
};
|
|
90
91
|
}
|
|
91
|
-
function
|
|
92
|
+
function Le(e, t, n = "16px system-ui") {
|
|
92
93
|
let { maxWidth: r, lineHeight: i, maxLines: a, overflowWrap: o = "break-word" } = t, s = Pe(e, n), c = [], l = {
|
|
93
94
|
lineStart: 0,
|
|
94
95
|
lineWidth: 0,
|
|
@@ -98,28 +99,28 @@ function Ie(e, t, n = "16px system-ui") {
|
|
|
98
99
|
for (let e = 0; e < s.length; e++) {
|
|
99
100
|
let t = s[e];
|
|
100
101
|
if (t.type === "break") {
|
|
101
|
-
c.push(
|
|
102
|
+
c.push(Ie(s, l.lineStart, e, l.lineWidth)), l.lineStart = e + 1, l.lineWidth = 0, l.lastBreakIdx = -1;
|
|
102
103
|
continue;
|
|
103
104
|
}
|
|
104
105
|
let n = l.lineWidth + t.width;
|
|
105
106
|
if (t.type === "space") {
|
|
106
|
-
if (n > r && l.lineWidth > 0 ? (l.lastBreakIdx >= 0 ? (c.push(
|
|
107
|
+
if (n > r && l.lineWidth > 0 ? (l.lastBreakIdx >= 0 ? (c.push(Ie(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Fe(s, l.lineStart, e + 1)) : (c.push(Ie(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width), l.lastBreakIdx = -1) : (l.lineWidth = n, l.lastBreakIdx = e, l.lastBreakWidth = l.lineWidth), a && c.length >= a) break;
|
|
107
108
|
continue;
|
|
108
109
|
}
|
|
109
110
|
if (t.type === "cjk") {
|
|
110
|
-
if (n > r && l.lineWidth > 0 ? (c.push(
|
|
111
|
+
if (n > r && l.lineWidth > 0 ? (c.push(Ie(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width, l.lastBreakIdx = -1) : (l.lineWidth = n, l.lastBreakIdx = e, l.lastBreakWidth = l.lineWidth), a && c.length >= a) break;
|
|
111
112
|
continue;
|
|
112
113
|
}
|
|
113
114
|
if (t.type === "punct") {
|
|
114
|
-
if (l.lineWidth === 0 && c.length > 0 ? c[c.length - 1].text.length > 0 && (l.lineWidth = t.width) : n > r ? (l.lastBreakIdx >= 0 ? (c.push(
|
|
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(Ie(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Fe(s, l.lineStart, e + 1)) : l.lineWidth = n, l.lastBreakIdx = -1) : l.lineWidth = n, a && c.length >= a) break;
|
|
115
116
|
continue;
|
|
116
117
|
}
|
|
117
|
-
if (n > r && l.lineWidth > 0 ? l.lastBreakIdx >= 0 ? (c.push(
|
|
118
|
+
if (n > r && l.lineWidth > 0 ? l.lastBreakIdx >= 0 ? (c.push(Ie(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Fe(s, l.lineStart, e + 1), l.lastBreakIdx = -1) : o === "break-word" ? (c.push(Ie(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width) : l.lineWidth = n : l.lineWidth = n, a && c.length >= a) break;
|
|
118
119
|
}
|
|
119
120
|
let u = l.lineStart < s.length;
|
|
120
121
|
if (u && (!a || c.length < a)) {
|
|
121
|
-
let e =
|
|
122
|
-
c.push(
|
|
122
|
+
let e = Fe(s, l.lineStart, s.length);
|
|
123
|
+
c.push(Ie(s, l.lineStart, s.length, e));
|
|
123
124
|
}
|
|
124
125
|
return {
|
|
125
126
|
lines: c,
|
|
@@ -130,8 +131,8 @@ function Ie(e, t, n = "16px system-ui") {
|
|
|
130
131
|
}
|
|
131
132
|
//#endregion
|
|
132
133
|
//#region ../toast/dist/index.mjs
|
|
133
|
-
var
|
|
134
|
-
function
|
|
134
|
+
var Re = typeof window < "u" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, ze = "13.5px -apple-system, BlinkMacSystemFont, \"SF Pro Text\", \"PingFang SC\", \"Microsoft YaHei\", system-ui, sans-serif";
|
|
135
|
+
function X() {
|
|
135
136
|
if (typeof window > "u") return 290;
|
|
136
137
|
let e = window.innerWidth;
|
|
137
138
|
return e <= 480 ? Math.max(140, e - 98) : 290;
|
|
@@ -141,25 +142,25 @@ var Be = {
|
|
|
141
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>",
|
|
142
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>",
|
|
143
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>"
|
|
144
|
-
},
|
|
145
|
-
function
|
|
146
|
-
return `qt${
|
|
145
|
+
}, Ve = 1;
|
|
146
|
+
function He() {
|
|
147
|
+
return `qt${Ve++}${Date.now().toString(36)}`;
|
|
147
148
|
}
|
|
148
|
-
function
|
|
149
|
+
function Ue(e, t, n) {
|
|
149
150
|
let r = document.createElement(e);
|
|
150
151
|
return t && (r.className = t), n != null && (r.innerHTML = n), r;
|
|
151
152
|
}
|
|
152
|
-
function
|
|
153
|
+
function We(e, t) {
|
|
153
154
|
let n = t.split(/\*\*(.+?)\*\*/g);
|
|
154
155
|
for (let t = 0; t < n.length; t++) {
|
|
155
156
|
let r = n[t];
|
|
156
157
|
if (r) if (t % 2 == 1) {
|
|
157
|
-
let t =
|
|
158
|
+
let t = Ue("em", "qt-mark");
|
|
158
159
|
t.textContent = r, e.appendChild(t);
|
|
159
160
|
} else e.appendChild(document.createTextNode(r));
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
|
-
var
|
|
163
|
+
var Ge = {
|
|
163
164
|
type: "info",
|
|
164
165
|
position: "top-center",
|
|
165
166
|
duration: 4e3,
|
|
@@ -168,19 +169,19 @@ var Ue = {
|
|
|
168
169
|
persistMaxVisible: 3,
|
|
169
170
|
maxLines: void 0,
|
|
170
171
|
vibrate: !0
|
|
171
|
-
},
|
|
172
|
+
}, Ke = [
|
|
172
173
|
80,
|
|
173
174
|
40,
|
|
174
175
|
80
|
|
175
176
|
];
|
|
176
|
-
function
|
|
177
|
+
function qe() {
|
|
177
178
|
if (!(typeof navigator > "u" || !("vibrate" in navigator))) try {
|
|
178
|
-
navigator.vibrate(
|
|
179
|
+
navigator.vibrate(Ke);
|
|
179
180
|
} catch {}
|
|
180
181
|
}
|
|
181
|
-
var
|
|
182
|
+
var Je = class {
|
|
182
183
|
containers = /* @__PURE__ */ new Map();
|
|
183
|
-
opts = { ...
|
|
184
|
+
opts = { ...Ge };
|
|
184
185
|
toasts = /* @__PURE__ */ new Map();
|
|
185
186
|
queue = [];
|
|
186
187
|
_seq = 0;
|
|
@@ -189,10 +190,10 @@ var Ke = class {
|
|
|
189
190
|
}
|
|
190
191
|
ensureContainer(e) {
|
|
191
192
|
let t = this.containers.get(e);
|
|
192
|
-
return t || (t =
|
|
193
|
+
return t || (t = Ue("div", "qt-container"), t.setAttribute("data-qt-pos", e), t.setAttribute("role", "status"), t.setAttribute("aria-live", "polite"), t.setAttribute("aria-atomic", "false"), document.body.appendChild(t), this.containers.set(e, t)), t;
|
|
193
194
|
}
|
|
194
195
|
show(e, t) {
|
|
195
|
-
let n = t?.type ?? this.opts.type, r = t?.position ?? this.opts.position, i = t?.persist ?? this.opts.persist ? 0 : t?.duration ?? this.opts.duration, a = t?.dismissible ?? !0, o = t?.maxLines ?? this.opts.maxLines, s = t?.description, c = t?.action, l =
|
|
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 = He(), u = {
|
|
196
197
|
id: l,
|
|
197
198
|
type: n,
|
|
198
199
|
dismissible: a,
|
|
@@ -275,30 +276,30 @@ var Ke = class {
|
|
|
275
276
|
this.containers.clear();
|
|
276
277
|
}
|
|
277
278
|
buildElement(e, t, n, r, i, a, o) {
|
|
278
|
-
let s =
|
|
279
|
+
let s = Ue("div", `qt-toast qt-${n}${i == null ? "" : " qt-truncate"}${a || o ? " qt-rich" : ""}`);
|
|
279
280
|
s.setAttribute("data-qt-id", e);
|
|
280
|
-
let c =
|
|
281
|
+
let c = Ue("span", "qt-icon");
|
|
281
282
|
c.innerHTML = Be[n], s.appendChild(c);
|
|
282
|
-
let l =
|
|
283
|
-
maxWidth:
|
|
283
|
+
let l = Ue("div", "qt-body"), u = Ue("span", "qt-msg"), d = Le(t, {
|
|
284
|
+
maxWidth: X(),
|
|
284
285
|
lineHeight: 1,
|
|
285
286
|
maxLines: i
|
|
286
|
-
},
|
|
287
|
-
if (d.lineCount <= 1 ?
|
|
288
|
-
let n =
|
|
289
|
-
t === d.lines.length - 1 && d.truncated && !r.endsWith("…") && (r += "…"),
|
|
287
|
+
}, ze);
|
|
288
|
+
if (d.lineCount <= 1 ? We(u, t) : d.lines.forEach((e, t) => {
|
|
289
|
+
let n = Ue("span", "qt-line"), r = e.text;
|
|
290
|
+
t === d.lines.length - 1 && d.truncated && !r.endsWith("…") && (r += "…"), We(n, r), u.appendChild(n);
|
|
290
291
|
}), l.appendChild(u), a) {
|
|
291
|
-
let e =
|
|
292
|
+
let e = Ue("div", "qt-desc");
|
|
292
293
|
e.textContent = a, l.appendChild(e);
|
|
293
294
|
}
|
|
294
295
|
if (s.appendChild(l), o) {
|
|
295
|
-
let t =
|
|
296
|
+
let t = Ue("button", "qt-action");
|
|
296
297
|
t.type = "button", t.textContent = o.label, t.addEventListener("click", (t) => {
|
|
297
298
|
t.stopPropagation(), this.dismiss(e), o.onClick();
|
|
298
299
|
}), s.appendChild(t);
|
|
299
300
|
}
|
|
300
301
|
if (r) {
|
|
301
|
-
let t =
|
|
302
|
+
let t = Ue("button", "qt-close", "<svg width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"><path d=\"M18 6 6 18M6 6l12 12\"/></svg>");
|
|
302
303
|
t.type = "button", t.setAttribute("aria-label", "关闭通知"), t.addEventListener("click", (t) => {
|
|
303
304
|
t.stopPropagation(), this.dismiss(e);
|
|
304
305
|
}), s.appendChild(t);
|
|
@@ -310,7 +311,7 @@ var Ke = class {
|
|
|
310
311
|
mount(e) {
|
|
311
312
|
e.duration === 0 && this.evictPersistIfNeeded(e);
|
|
312
313
|
let t = this.ensureContainer(e.position);
|
|
313
|
-
this.toasts.set(e.id, e), t.appendChild(e.element), e.type === "error" && this.opts.vibrate &&
|
|
314
|
+
this.toasts.set(e.id, e), t.appendChild(e.element), e.type === "error" && this.opts.vibrate && qe(), requestAnimationFrame(() => {
|
|
314
315
|
requestAnimationFrame(() => {
|
|
315
316
|
e.element.classList.add("qt-enter");
|
|
316
317
|
});
|
|
@@ -332,7 +333,7 @@ var Ke = class {
|
|
|
332
333
|
let t = () => {
|
|
333
334
|
e.element.remove(), this.toasts.delete(e.id), this._dequeue();
|
|
334
335
|
};
|
|
335
|
-
if (
|
|
336
|
+
if (Re) t();
|
|
336
337
|
else {
|
|
337
338
|
let n = !1, r = () => {
|
|
338
339
|
n || (n = !0, t());
|
|
@@ -345,46 +346,46 @@ var Ke = class {
|
|
|
345
346
|
let e = this.queue.shift();
|
|
346
347
|
this.mount(e);
|
|
347
348
|
}
|
|
348
|
-
},
|
|
349
|
-
function
|
|
350
|
-
return
|
|
351
|
-
}
|
|
352
|
-
var
|
|
353
|
-
info: (e, t) =>
|
|
354
|
-
success: (e, t) =>
|
|
355
|
-
warn: (e, t) =>
|
|
356
|
-
error: (e, t) =>
|
|
357
|
-
promise: (e, t, n) =>
|
|
358
|
-
dismiss: (e) =>
|
|
359
|
-
dismissAll: () =>
|
|
360
|
-
configure: (e) =>
|
|
361
|
-
}),
|
|
362
|
-
function
|
|
363
|
-
|
|
349
|
+
}, Ye = null;
|
|
350
|
+
function Xe() {
|
|
351
|
+
return Ye ||= new Je(), Ye;
|
|
352
|
+
}
|
|
353
|
+
var Ze = Object.assign((e, t) => Xe().show(e, t), {
|
|
354
|
+
info: (e, t) => Xe().info(e, t),
|
|
355
|
+
success: (e, t) => Xe().success(e, t),
|
|
356
|
+
warn: (e, t) => Xe().warn(e, t),
|
|
357
|
+
error: (e, t) => Xe().error(e, t),
|
|
358
|
+
promise: (e, t, n) => Xe().promise(e, t, n),
|
|
359
|
+
dismiss: (e) => Xe().dismiss(e),
|
|
360
|
+
dismissAll: () => Xe().dismissAll(),
|
|
361
|
+
configure: (e) => Xe().configure(e)
|
|
362
|
+
}), Qe = /* @__PURE__ */ new Set(), $e = null;
|
|
363
|
+
function et(e) {
|
|
364
|
+
$e = e;
|
|
364
365
|
}
|
|
365
366
|
function Z(e, t = "error", n) {
|
|
366
367
|
let r = {
|
|
367
368
|
persist: !0,
|
|
368
369
|
...n
|
|
369
370
|
};
|
|
370
|
-
if (
|
|
371
|
-
for (let n of
|
|
371
|
+
if (Qe.size > 0) {
|
|
372
|
+
for (let n of Qe) n(e, t, r);
|
|
372
373
|
return;
|
|
373
374
|
}
|
|
374
|
-
if (
|
|
375
|
-
|
|
375
|
+
if ($e) {
|
|
376
|
+
$e(e, t, r);
|
|
376
377
|
return;
|
|
377
378
|
}
|
|
378
|
-
t === "success" ?
|
|
379
|
+
t === "success" ? Ze.success(e, r) : t === "info" ? Ze.info(e, r) : Ze.error(e, r);
|
|
379
380
|
}
|
|
380
|
-
function
|
|
381
|
-
return
|
|
382
|
-
|
|
381
|
+
function tt(e) {
|
|
382
|
+
return Qe.add(e), () => {
|
|
383
|
+
Qe.delete(e);
|
|
383
384
|
};
|
|
384
385
|
}
|
|
385
386
|
//#endregion
|
|
386
387
|
//#region src/components/image-upload-dialog.tsx
|
|
387
|
-
var
|
|
388
|
+
var nt = /* @__PURE__ */ e({ ImageUploadDialog: () => rt }), rt = ({ open: e, onClose: t, onInsert: n, validate: r }) => {
|
|
388
389
|
let [i, a] = T("upload"), [s, c] = T(!1), [l, u] = T(!1), [d, f] = T(null), [p, m] = T(null), [h, g] = T(""), [_, v] = T(null), y = w(null), x = (() => {
|
|
389
390
|
try {
|
|
390
391
|
let e = o();
|
|
@@ -676,10 +677,10 @@ var et = /* @__PURE__ */ e({ ImageUploadDialog: () => tt }), tt = ({ open: e, on
|
|
|
676
677
|
};
|
|
677
678
|
//#endregion
|
|
678
679
|
//#region src/components/toc.tsx
|
|
679
|
-
function
|
|
680
|
+
function it(e, t) {
|
|
680
681
|
return `${e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu, "").replace(/\s+/g, "-").slice(0, 40) || "heading"}-${t}`;
|
|
681
682
|
}
|
|
682
|
-
function
|
|
683
|
+
function at(e) {
|
|
683
684
|
let t = [], n = [];
|
|
684
685
|
for (let r of e) {
|
|
685
686
|
let e = {
|
|
@@ -691,18 +692,18 @@ function rt(e) {
|
|
|
691
692
|
}
|
|
692
693
|
return t;
|
|
693
694
|
}
|
|
694
|
-
function
|
|
695
|
+
function ot(e) {
|
|
695
696
|
let t = /* @__PURE__ */ new Set(), n = (e) => {
|
|
696
697
|
for (let r of e) r.children.length > 0 && (t.add(r.id), n(r.children));
|
|
697
698
|
};
|
|
698
699
|
return n(e), t;
|
|
699
700
|
}
|
|
700
|
-
function
|
|
701
|
+
function st(e, t) {
|
|
701
702
|
let n = [];
|
|
702
|
-
for (let r of e) n.push(r), r.children.length > 0 && !t.has(r.id) && n.push(...
|
|
703
|
+
for (let r of e) n.push(r), r.children.length > 0 && !t.has(r.id) && n.push(...st(r.children, t));
|
|
703
704
|
return n;
|
|
704
705
|
}
|
|
705
|
-
function
|
|
706
|
+
function ct(e, t) {
|
|
706
707
|
let n = t.toLowerCase(), r = (e) => {
|
|
707
708
|
let t = [];
|
|
708
709
|
for (let i of e) {
|
|
@@ -716,7 +717,7 @@ function ot(e, t) {
|
|
|
716
717
|
};
|
|
717
718
|
return r(e);
|
|
718
719
|
}
|
|
719
|
-
function
|
|
720
|
+
function lt(e) {
|
|
720
721
|
let t = e.parentElement;
|
|
721
722
|
for (; t && t !== document.documentElement;) {
|
|
722
723
|
let e = getComputedStyle(t).overflowY;
|
|
@@ -725,7 +726,7 @@ function st(e) {
|
|
|
725
726
|
}
|
|
726
727
|
return null;
|
|
727
728
|
}
|
|
728
|
-
function
|
|
729
|
+
function ut(e) {
|
|
729
730
|
if (e.isDestroyed) return null;
|
|
730
731
|
try {
|
|
731
732
|
return e.view.dom;
|
|
@@ -733,7 +734,7 @@ function ct(e) {
|
|
|
733
734
|
return null;
|
|
734
735
|
}
|
|
735
736
|
}
|
|
736
|
-
function
|
|
737
|
+
function dt(e, t) {
|
|
737
738
|
if (!t) return e;
|
|
738
739
|
let n = e.toLowerCase(), r = t.toLowerCase(), i = [], a = 0, o = 0;
|
|
739
740
|
for (;;) {
|
|
@@ -746,12 +747,12 @@ function lt(e, t) {
|
|
|
746
747
|
}
|
|
747
748
|
return a < e.length && i.push(e.slice(a)), i.length ? i : e;
|
|
748
749
|
}
|
|
749
|
-
var
|
|
750
|
+
var ft = 84, pt = 3e3, mt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
750
751
|
let [r, i] = T([]), [a, o] = T(""), [s, c] = T(/* @__PURE__ */ new Set()), [l, u] = T(""), d = w(""), f = w([]), p = w(null), m = w(null), h = w(null), g = w(0), _ = b(() => {
|
|
751
752
|
h.current &&= (clearTimeout(h.current.timer), null);
|
|
752
753
|
}, []), v = b(() => {
|
|
753
|
-
let t =
|
|
754
|
-
return t ? Array.from(t.querySelectorAll("h1,h2,h3,h4,h5,h6")).map((e, t) => (e.id ||=
|
|
754
|
+
let t = ut(e);
|
|
755
|
+
return t ? Array.from(t.querySelectorAll("h1,h2,h3,h4,h5,h6")).map((e, t) => (e.id ||= it(e.textContent || "", t), {
|
|
755
756
|
id: e.id,
|
|
756
757
|
level: Number(e.tagName.slice(1)),
|
|
757
758
|
text: e.textContent?.trim() || "(无标题)",
|
|
@@ -760,7 +761,7 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
760
761
|
}, [e]), y = b(() => {
|
|
761
762
|
let e = f.current;
|
|
762
763
|
if ((!e.length || e.some((e) => !e.el.isConnected)) && (e = v(), f.current = e), !e.length) return;
|
|
763
|
-
let t = m.current, n = (t ? t.getBoundingClientRect().top : 0) +
|
|
764
|
+
let t = m.current, n = (t ? t.getBoundingClientRect().top : 0) + ft, r = t ? t.scrollHeight - t.scrollTop - t.clientHeight < 2 : document.documentElement.scrollHeight - window.scrollY - window.innerHeight < 2, i = "";
|
|
764
765
|
for (let t of e) t.el.isConnected && t.el.getBoundingClientRect().top <= n && (i = t.id);
|
|
765
766
|
if (r) {
|
|
766
767
|
for (let t = e.length - 1; t >= 0; t--) if (e[t].el.isConnected) {
|
|
@@ -784,7 +785,7 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
784
785
|
t !== d.current && (d.current = t, f.current = e, i(e), S());
|
|
785
786
|
}, [v, S]);
|
|
786
787
|
x(() => {
|
|
787
|
-
let t =
|
|
788
|
+
let t = ut(e), n = t ? lt(t) : null;
|
|
788
789
|
m.current = n;
|
|
789
790
|
let r = n ?? window;
|
|
790
791
|
return r.addEventListener("scroll", S, { passive: !0 }), window.addEventListener("resize", S), r.addEventListener("wheel", _, { passive: !0 }), r.addEventListener("touchstart", _, { passive: !0 }), () => {
|
|
@@ -812,7 +813,7 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
812
813
|
_
|
|
813
814
|
]);
|
|
814
815
|
let k = b((t) => {
|
|
815
|
-
let n =
|
|
816
|
+
let n = ut(e);
|
|
816
817
|
if (!n) return;
|
|
817
818
|
let r = t.el;
|
|
818
819
|
if ((!r || !n.contains(r)) && (r = n.querySelector(`[id="${CSS.escape(t.id)}"]`)), !r) {
|
|
@@ -825,59 +826,59 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
825
826
|
if (!r) return;
|
|
826
827
|
_(), h.current = {
|
|
827
828
|
id: t.id,
|
|
828
|
-
timer: setTimeout(_,
|
|
829
|
+
timer: setTimeout(_, pt)
|
|
829
830
|
}, o(t.id);
|
|
830
831
|
let i = m.current, a = r.getBoundingClientRect().top;
|
|
831
832
|
if (i) {
|
|
832
833
|
let e = i.getBoundingClientRect().top;
|
|
833
834
|
i.scrollTo({
|
|
834
|
-
top: i.scrollTop + a - e -
|
|
835
|
+
top: i.scrollTop + a - e - ft,
|
|
835
836
|
behavior: "smooth"
|
|
836
837
|
});
|
|
837
838
|
} else window.scrollTo({
|
|
838
|
-
top: window.scrollY + a -
|
|
839
|
+
top: window.scrollY + a - ft,
|
|
839
840
|
behavior: "smooth"
|
|
840
841
|
});
|
|
841
|
-
}, [e, _]), A = C(() =>
|
|
842
|
+
}, [e, _]), A = C(() => at(r), [r]), j = C(() => ot(A), [A]), M = C(() => {
|
|
842
843
|
let e = /* @__PURE__ */ new Map(), t = (n, r) => {
|
|
843
844
|
for (let i of n) r && e.set(i.id, r), t(i.children, i.id);
|
|
844
845
|
};
|
|
845
846
|
return t(A, ""), e;
|
|
846
|
-
}, [A]), N = l.trim().length > 0,
|
|
847
|
+
}, [A]), N = l.trim().length > 0, ee = C(() => N ? ct(A, l.trim()) : A, [
|
|
847
848
|
A,
|
|
848
849
|
N,
|
|
849
850
|
l
|
|
850
|
-
]),
|
|
851
|
-
|
|
851
|
+
]), P = C(() => st(ee, N ? /* @__PURE__ */ new Set() : s), [
|
|
852
|
+
ee,
|
|
852
853
|
s,
|
|
853
854
|
N
|
|
854
|
-
]),
|
|
855
|
+
]), F = C(() => new Set(P.map((e) => e.id)), [P]), I = C(() => {
|
|
855
856
|
let e = a;
|
|
856
|
-
for (; e && !
|
|
857
|
+
for (; e && !F.has(e);) e = M.get(e) ?? "";
|
|
857
858
|
return e;
|
|
858
859
|
}, [
|
|
859
860
|
a,
|
|
860
|
-
|
|
861
|
+
F,
|
|
861
862
|
M
|
|
862
863
|
]);
|
|
863
864
|
x(() => {
|
|
864
865
|
let e = p.current;
|
|
865
|
-
if (!e || !
|
|
866
|
+
if (!e || !I) return;
|
|
866
867
|
let t = e.closest(".toc-scroll");
|
|
867
868
|
if (!(t instanceof HTMLElement)) return;
|
|
868
|
-
let n = e.querySelector(`[data-toc-id="${CSS.escape(
|
|
869
|
+
let n = e.querySelector(`[data-toc-id="${CSS.escape(I)}"]`);
|
|
869
870
|
if (!n) return;
|
|
870
871
|
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect();
|
|
871
872
|
i.top < r.top + 8 ? t.scrollTop -= r.top + 8 - i.top : i.bottom > r.bottom - 8 && (t.scrollTop += i.bottom - (r.bottom - 8));
|
|
872
|
-
}, [
|
|
873
|
-
let
|
|
873
|
+
}, [I]);
|
|
874
|
+
let te = b((e) => {
|
|
874
875
|
c((t) => {
|
|
875
876
|
let n = new Set(t);
|
|
876
877
|
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
877
878
|
});
|
|
878
|
-
}, []),
|
|
879
|
+
}, []), ne = b(() => {
|
|
879
880
|
c(new Set(j));
|
|
880
|
-
}, [j]),
|
|
881
|
+
}, [j]), L = b(() => {
|
|
881
882
|
c(/* @__PURE__ */ new Set());
|
|
882
883
|
}, []);
|
|
883
884
|
return r.length ? /* @__PURE__ */ O("nav", {
|
|
@@ -948,7 +949,7 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
948
949
|
children: [/* @__PURE__ */ D("button", {
|
|
949
950
|
type: "button",
|
|
950
951
|
className: "toc-action-btn",
|
|
951
|
-
onClick:
|
|
952
|
+
onClick: ne,
|
|
952
953
|
title: "全部折叠",
|
|
953
954
|
"aria-label": "全部折叠",
|
|
954
955
|
disabled: N,
|
|
@@ -969,7 +970,7 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
969
970
|
}), /* @__PURE__ */ D("button", {
|
|
970
971
|
type: "button",
|
|
971
972
|
className: "toc-action-btn",
|
|
972
|
-
onClick:
|
|
973
|
+
onClick: L,
|
|
973
974
|
title: "全部展开",
|
|
974
975
|
"aria-label": "全部展开",
|
|
975
976
|
disabled: N,
|
|
@@ -1040,22 +1041,22 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1040
1041
|
})
|
|
1041
1042
|
]
|
|
1042
1043
|
}),
|
|
1043
|
-
|
|
1044
|
+
P.length === 0 ? /* @__PURE__ */ D("div", {
|
|
1044
1045
|
className: "toc-search__empty",
|
|
1045
1046
|
children: N ? `未找到"${l.trim()}"相关标题` : "文档暂无标题"
|
|
1046
1047
|
}) : /* @__PURE__ */ D("ul", {
|
|
1047
1048
|
className: "toc-list",
|
|
1048
|
-
children:
|
|
1049
|
+
children: P.map((e) => {
|
|
1049
1050
|
let t = j.has(e.id), n = s.has(e.id);
|
|
1050
1051
|
return /* @__PURE__ */ O("li", {
|
|
1051
1052
|
"data-toc-id": e.id,
|
|
1052
|
-
className: `toc-item ${
|
|
1053
|
+
className: `toc-item ${I === e.id ? "is-active" : ""}`,
|
|
1053
1054
|
style: { paddingLeft: `${(e.level - 1) * 12 + 12}px` },
|
|
1054
1055
|
children: [t ? /* @__PURE__ */ D("button", {
|
|
1055
1056
|
type: "button",
|
|
1056
1057
|
className: `toc-toggle ${n ? "is-collapsed" : "is-expanded"}`,
|
|
1057
1058
|
onClick: (t) => {
|
|
1058
|
-
t.stopPropagation(),
|
|
1059
|
+
t.stopPropagation(), te(e.id);
|
|
1059
1060
|
},
|
|
1060
1061
|
title: n ? "展开子标题" : "折叠子标题",
|
|
1061
1062
|
"aria-label": n ? "展开子标题" : "折叠子标题",
|
|
@@ -1078,7 +1079,7 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1078
1079
|
title: e.text,
|
|
1079
1080
|
children: /* @__PURE__ */ D("span", {
|
|
1080
1081
|
className: "toc-text",
|
|
1081
|
-
children: N ?
|
|
1082
|
+
children: N ? dt(e.text, l.trim()) : e.text
|
|
1082
1083
|
})
|
|
1083
1084
|
})]
|
|
1084
1085
|
}, e.id);
|
|
@@ -1102,7 +1103,7 @@ var ut = 84, dt = 3e3, ft = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1102
1103
|
};
|
|
1103
1104
|
//#endregion
|
|
1104
1105
|
//#region src/editor/ai/index.ts
|
|
1105
|
-
function
|
|
1106
|
+
function ht(e, t) {
|
|
1106
1107
|
return {
|
|
1107
1108
|
continue: "你是一个写作助手。请从下文尾部自然流畅地续写内容,保持风格一致。只输出续写的内容,不要加任何前缀说明。",
|
|
1108
1109
|
improve: "你是一个文字润色专家。请优化以下文本的表达,提升文采和流畅度,保持原意不变。只输出润色后的文本。",
|
|
@@ -1113,8 +1114,8 @@ function pt(e, t) {
|
|
|
1113
1114
|
zap: t || "你是一个全能的 AI 写作助手。请根据用户的指令处理文本。"
|
|
1114
1115
|
}[e];
|
|
1115
1116
|
}
|
|
1116
|
-
var
|
|
1117
|
-
async function
|
|
1117
|
+
var gt = null;
|
|
1118
|
+
async function _t(e) {
|
|
1118
1119
|
let t;
|
|
1119
1120
|
try {
|
|
1120
1121
|
({createOpenAI: t} = await import("@ai-sdk/openai"));
|
|
@@ -1129,7 +1130,7 @@ async function ht(e) {
|
|
|
1129
1130
|
async *stream(e) {
|
|
1130
1131
|
let t = await A({
|
|
1131
1132
|
model: n,
|
|
1132
|
-
system:
|
|
1133
|
+
system: ht(e.mode, e.instruction),
|
|
1133
1134
|
prompt: e.context,
|
|
1134
1135
|
temperature: .7,
|
|
1135
1136
|
maxOutputTokens: 2048
|
|
@@ -1139,7 +1140,7 @@ async function ht(e) {
|
|
|
1139
1140
|
async generate(e) {
|
|
1140
1141
|
return (await k({
|
|
1141
1142
|
model: n,
|
|
1142
|
-
system:
|
|
1143
|
+
system: ht(e.mode, e.instruction),
|
|
1143
1144
|
prompt: e.context,
|
|
1144
1145
|
temperature: .7,
|
|
1145
1146
|
maxOutputTokens: 2048
|
|
@@ -1147,16 +1148,16 @@ async function ht(e) {
|
|
|
1147
1148
|
}
|
|
1148
1149
|
};
|
|
1149
1150
|
}
|
|
1150
|
-
function
|
|
1151
|
-
|
|
1151
|
+
function vt(e) {
|
|
1152
|
+
gt = e;
|
|
1152
1153
|
}
|
|
1153
|
-
function
|
|
1154
|
-
if (!
|
|
1155
|
-
return
|
|
1154
|
+
function yt() {
|
|
1155
|
+
if (!gt) throw Error("未配置 AI 服务。请调用 createAILanguageModelProvider() 创建并通过 setAIProvider() 注册。");
|
|
1156
|
+
return gt;
|
|
1156
1157
|
}
|
|
1157
1158
|
//#endregion
|
|
1158
1159
|
//#region src/editor/ai/providers/openai-compat.ts
|
|
1159
|
-
function
|
|
1160
|
+
function bt(e) {
|
|
1160
1161
|
let { apiKey: t, baseURL: n, model: r, headers: i } = e;
|
|
1161
1162
|
async function* a(e, a) {
|
|
1162
1163
|
let o = await fetch(`${n}/chat/completions`, {
|
|
@@ -1207,10 +1208,10 @@ function vt(e) {
|
|
|
1207
1208
|
}
|
|
1208
1209
|
return {
|
|
1209
1210
|
async *stream(e) {
|
|
1210
|
-
yield* a(
|
|
1211
|
+
yield* a(ht(e.mode, e.instruction), e.context);
|
|
1211
1212
|
},
|
|
1212
1213
|
async generate(e) {
|
|
1213
|
-
let t =
|
|
1214
|
+
let t = ht(e.mode, e.instruction), n = "";
|
|
1214
1215
|
for await (let r of a(t, e.context)) n += r;
|
|
1215
1216
|
return n;
|
|
1216
1217
|
}
|
|
@@ -1218,8 +1219,8 @@ function vt(e) {
|
|
|
1218
1219
|
}
|
|
1219
1220
|
//#endregion
|
|
1220
1221
|
//#region src/editor/ai/providers/deepseek.ts
|
|
1221
|
-
function
|
|
1222
|
-
return
|
|
1222
|
+
function xt(e) {
|
|
1223
|
+
return bt({
|
|
1223
1224
|
apiKey: e.apiKey,
|
|
1224
1225
|
baseURL: e.baseURL || "https://api.deepseek.com/v1",
|
|
1225
1226
|
model: e.model || "deepseek-v4-flash",
|
|
@@ -1228,8 +1229,8 @@ function yt(e) {
|
|
|
1228
1229
|
}
|
|
1229
1230
|
//#endregion
|
|
1230
1231
|
//#region src/editor/ai/providers/openai.ts
|
|
1231
|
-
function
|
|
1232
|
-
return
|
|
1232
|
+
function St(e) {
|
|
1233
|
+
return bt({
|
|
1233
1234
|
apiKey: e.apiKey,
|
|
1234
1235
|
baseURL: e.baseURL || "https://api.openai.com/v1",
|
|
1235
1236
|
model: e.model || "gpt-5.6-luna",
|
|
@@ -1238,8 +1239,8 @@ function bt(e) {
|
|
|
1238
1239
|
}
|
|
1239
1240
|
//#endregion
|
|
1240
1241
|
//#region src/editor/ai/providers/qwen.ts
|
|
1241
|
-
function
|
|
1242
|
-
return
|
|
1242
|
+
function Ct(e) {
|
|
1243
|
+
return bt({
|
|
1243
1244
|
apiKey: e.apiKey,
|
|
1244
1245
|
baseURL: e.baseURL || "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
1245
1246
|
model: e.model || "qwen3.7-plus",
|
|
@@ -1248,20 +1249,20 @@ function xt(e) {
|
|
|
1248
1249
|
}
|
|
1249
1250
|
//#endregion
|
|
1250
1251
|
//#region src/editor/extensions/search-highlight.ts
|
|
1251
|
-
var
|
|
1252
|
+
var wt = {
|
|
1252
1253
|
keyword: "",
|
|
1253
1254
|
caseSensitive: !1,
|
|
1254
1255
|
wholeWord: !1,
|
|
1255
1256
|
matches: [],
|
|
1256
1257
|
currentIndex: -1
|
|
1257
|
-
},
|
|
1258
|
-
function
|
|
1258
|
+
}, Tt = new H("search-highlight");
|
|
1259
|
+
function Et(e) {
|
|
1259
1260
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1260
1261
|
}
|
|
1261
|
-
function
|
|
1262
|
+
function Dt(e, t) {
|
|
1262
1263
|
let { keyword: n, caseSensitive: r, wholeWord: i } = t;
|
|
1263
1264
|
if (!n) return [];
|
|
1264
|
-
let a = r ? "g" : "gi", o = i ? `\\b${
|
|
1265
|
+
let a = r ? "g" : "gi", o = i ? `\\b${Et(n)}\\b` : Et(n), s = new RegExp(o, a), c = [];
|
|
1265
1266
|
return e.descendants((e, t) => {
|
|
1266
1267
|
if (!e.isText || !e.text) return;
|
|
1267
1268
|
s.lastIndex = 0;
|
|
@@ -1275,12 +1276,12 @@ function Tt(e, t) {
|
|
|
1275
1276
|
}
|
|
1276
1277
|
}), c;
|
|
1277
1278
|
}
|
|
1278
|
-
function
|
|
1279
|
-
if (t.matches.length === 0) return
|
|
1280
|
-
let n = t.matches.map((e, n) =>
|
|
1281
|
-
return
|
|
1279
|
+
function Ot(e, t) {
|
|
1280
|
+
if (t.matches.length === 0) return U.empty;
|
|
1281
|
+
let n = t.matches.map((e, n) => oe.inline(e.from, e.to, { class: n === t.currentIndex ? "search-highlight search-highlight--active" : "search-highlight" }));
|
|
1282
|
+
return U.create(e, n);
|
|
1282
1283
|
}
|
|
1283
|
-
function
|
|
1284
|
+
function kt(e, t) {
|
|
1284
1285
|
if (t.currentIndex < 0 || t.currentIndex >= t.matches.length) return;
|
|
1285
1286
|
let n = t.matches[t.currentIndex];
|
|
1286
1287
|
n && requestAnimationFrame(() => {
|
|
@@ -1305,15 +1306,15 @@ function Dt(e, t) {
|
|
|
1305
1306
|
} catch {}
|
|
1306
1307
|
});
|
|
1307
1308
|
}
|
|
1308
|
-
var
|
|
1309
|
+
var At = R.create({
|
|
1309
1310
|
name: "searchHighlight",
|
|
1310
1311
|
addProseMirrorPlugins() {
|
|
1311
|
-
return [new
|
|
1312
|
-
key:
|
|
1312
|
+
return [new V({
|
|
1313
|
+
key: Tt,
|
|
1313
1314
|
state: {
|
|
1314
|
-
init: () =>
|
|
1315
|
+
init: () => wt,
|
|
1315
1316
|
apply(e, t) {
|
|
1316
|
-
let n = e.getMeta(
|
|
1317
|
+
let n = e.getMeta(Tt);
|
|
1317
1318
|
if (n) return {
|
|
1318
1319
|
...t,
|
|
1319
1320
|
...n,
|
|
@@ -1321,7 +1322,7 @@ var Ot = R.create({
|
|
|
1321
1322
|
currentIndex: n.currentIndex === void 0 ? t.currentIndex : n.currentIndex
|
|
1322
1323
|
};
|
|
1323
1324
|
if (e.docChanged && t.keyword) {
|
|
1324
|
-
let n =
|
|
1325
|
+
let n = Dt(e.doc, t), r = t.currentIndex;
|
|
1325
1326
|
return r >= n.length && (r = n.length - 1), r < 0 && (r = n.length > 0 ? 0 : -1), {
|
|
1326
1327
|
...t,
|
|
1327
1328
|
matches: n,
|
|
@@ -1332,52 +1333,52 @@ var Ot = R.create({
|
|
|
1332
1333
|
}
|
|
1333
1334
|
},
|
|
1334
1335
|
props: { decorations(e) {
|
|
1335
|
-
let t =
|
|
1336
|
-
return t ?
|
|
1336
|
+
let t = Tt.getState(e);
|
|
1337
|
+
return t ? Ot(e.doc, t) : U.empty;
|
|
1337
1338
|
} }
|
|
1338
1339
|
})];
|
|
1339
1340
|
},
|
|
1340
1341
|
addCommands() {
|
|
1341
1342
|
return {
|
|
1342
1343
|
setSearch: (e, t = {}) => ({ state: n, dispatch: r, view: i }) => {
|
|
1343
|
-
let a =
|
|
1344
|
+
let a = Tt.getState(n) || wt, o = {
|
|
1344
1345
|
keyword: e,
|
|
1345
1346
|
caseSensitive: t.caseSensitive ?? a.caseSensitive,
|
|
1346
1347
|
wholeWord: t.wholeWord ?? a.wholeWord,
|
|
1347
1348
|
matches: [],
|
|
1348
1349
|
currentIndex: -1
|
|
1349
1350
|
};
|
|
1350
|
-
return o.matches =
|
|
1351
|
+
return o.matches = Dt(n.doc, o), o.currentIndex = o.matches.length > 0 ? 0 : -1, r && (r(n.tr.setMeta(Tt, o)), i && kt(i, o)), !0;
|
|
1351
1352
|
},
|
|
1352
1353
|
nextMatch: () => ({ state: e, dispatch: t, view: n }) => {
|
|
1353
|
-
let r =
|
|
1354
|
+
let r = Tt.getState(e) || wt;
|
|
1354
1355
|
if (r.matches.length === 0) return !1;
|
|
1355
1356
|
let i = (r.currentIndex + 1) % r.matches.length;
|
|
1356
|
-
return t && (t(e.tr.setMeta(
|
|
1357
|
+
return t && (t(e.tr.setMeta(Tt, { currentIndex: i })), n && kt(n, {
|
|
1357
1358
|
...r,
|
|
1358
1359
|
currentIndex: i
|
|
1359
1360
|
})), !0;
|
|
1360
1361
|
},
|
|
1361
1362
|
prevMatch: () => ({ state: e, dispatch: t, view: n }) => {
|
|
1362
|
-
let r =
|
|
1363
|
+
let r = Tt.getState(e) || wt;
|
|
1363
1364
|
if (r.matches.length === 0) return !1;
|
|
1364
1365
|
let i = (r.currentIndex - 1 + r.matches.length) % r.matches.length;
|
|
1365
|
-
return t && (t(e.tr.setMeta(
|
|
1366
|
+
return t && (t(e.tr.setMeta(Tt, { currentIndex: i })), n && kt(n, {
|
|
1366
1367
|
...r,
|
|
1367
1368
|
currentIndex: i
|
|
1368
1369
|
})), !0;
|
|
1369
1370
|
},
|
|
1370
|
-
clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(
|
|
1371
|
+
clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(Tt, wt)), !0)
|
|
1371
1372
|
};
|
|
1372
1373
|
}
|
|
1373
1374
|
});
|
|
1374
|
-
function
|
|
1375
|
+
function jt(e) {
|
|
1375
1376
|
let t = e.state;
|
|
1376
|
-
return
|
|
1377
|
+
return Tt.getState(t) || wt;
|
|
1377
1378
|
}
|
|
1378
1379
|
//#endregion
|
|
1379
1380
|
//#region src/components/search-bar.tsx
|
|
1380
|
-
var
|
|
1381
|
+
var Mt = ({ editor: e, onClose: t }) => {
|
|
1381
1382
|
let [n, r] = T(""), [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(0), u = w(null), d = w({
|
|
1382
1383
|
keyword: n,
|
|
1383
1384
|
caseSensitive: i,
|
|
@@ -1442,7 +1443,7 @@ var At = ({ editor: e, onClose: t }) => {
|
|
|
1442
1443
|
}, [f, p]), h = C(() => {
|
|
1443
1444
|
if (!e) return null;
|
|
1444
1445
|
try {
|
|
1445
|
-
return
|
|
1446
|
+
return jt(e);
|
|
1446
1447
|
} catch {
|
|
1447
1448
|
return null;
|
|
1448
1449
|
}
|
|
@@ -1594,36 +1595,36 @@ function Q({ children: e, ...t }) {
|
|
|
1594
1595
|
children: e
|
|
1595
1596
|
});
|
|
1596
1597
|
}
|
|
1597
|
-
var
|
|
1598
|
+
var Nt = (e) => /* @__PURE__ */ O(Q, {
|
|
1598
1599
|
...e,
|
|
1599
1600
|
children: [/* @__PURE__ */ D("path", { d: "M6 4h8a4 4 0 0 1 0 8H6z" }), /* @__PURE__ */ D("path", { d: "M6 12h9a4 4 0 0 1 0 8H6z" })]
|
|
1600
|
-
}),
|
|
1601
|
+
}), Pt = (e) => /* @__PURE__ */ O(Q, {
|
|
1601
1602
|
...e,
|
|
1602
1603
|
children: [
|
|
1603
1604
|
/* @__PURE__ */ D("path", { d: "M19 4h-9" }),
|
|
1604
1605
|
/* @__PURE__ */ D("path", { d: "M14 20H5" }),
|
|
1605
1606
|
/* @__PURE__ */ D("path", { d: "M15 4 9 20" })
|
|
1606
1607
|
]
|
|
1607
|
-
}),
|
|
1608
|
+
}), Ft = (e) => /* @__PURE__ */ O(Q, {
|
|
1608
1609
|
...e,
|
|
1609
1610
|
children: [/* @__PURE__ */ D("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }), /* @__PURE__ */ D("path", { d: "M4 20h16" })]
|
|
1610
|
-
}),
|
|
1611
|
+
}), It = (e) => /* @__PURE__ */ O(Q, {
|
|
1611
1612
|
...e,
|
|
1612
1613
|
children: [
|
|
1613
1614
|
/* @__PURE__ */ D("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
|
|
1614
1615
|
/* @__PURE__ */ D("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
|
|
1615
1616
|
/* @__PURE__ */ D("path", { d: "M4 12h16" })
|
|
1616
1617
|
]
|
|
1617
|
-
}),
|
|
1618
|
+
}), Lt = (e) => /* @__PURE__ */ O(Q, {
|
|
1618
1619
|
...e,
|
|
1619
1620
|
children: [/* @__PURE__ */ D("path", { d: "m16 18 6-6-6-6" }), /* @__PURE__ */ D("path", { d: "m8 6-6 6 6 6" })]
|
|
1620
|
-
}),
|
|
1621
|
+
}), Rt = (e) => /* @__PURE__ */ O(Q, {
|
|
1621
1622
|
...e,
|
|
1622
1623
|
children: [/* @__PURE__ */ D("path", { d: "m9 11-6 6v3h9l3-3" }), /* @__PURE__ */ D("path", { d: "m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4" })]
|
|
1623
|
-
}),
|
|
1624
|
+
}), zt = (e) => /* @__PURE__ */ O(Q, {
|
|
1624
1625
|
...e,
|
|
1625
1626
|
children: [/* @__PURE__ */ D("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }), /* @__PURE__ */ D("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })]
|
|
1626
|
-
}),
|
|
1627
|
+
}), Bt = (e) => /* @__PURE__ */ O(Q, {
|
|
1627
1628
|
...e,
|
|
1628
1629
|
children: [/* @__PURE__ */ D("rect", {
|
|
1629
1630
|
x: "3",
|
|
@@ -1633,7 +1634,7 @@ var jt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1633
1634
|
rx: "2",
|
|
1634
1635
|
ry: "2"
|
|
1635
1636
|
}), /* @__PURE__ */ D("path", { d: "M3 9h18M3 15h18M9 3v18M15 3v18" })]
|
|
1636
|
-
}),
|
|
1637
|
+
}), Vt = (e) => /* @__PURE__ */ O(Q, {
|
|
1637
1638
|
...e,
|
|
1638
1639
|
children: [/* @__PURE__ */ D("rect", {
|
|
1639
1640
|
x: "8",
|
|
@@ -1643,17 +1644,17 @@ var jt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1643
1644
|
rx: "2",
|
|
1644
1645
|
ry: "2"
|
|
1645
1646
|
}), /* @__PURE__ */ D("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })]
|
|
1646
|
-
}),
|
|
1647
|
+
}), Ht = (e) => /* @__PURE__ */ O(Q, {
|
|
1647
1648
|
...e,
|
|
1648
1649
|
children: [/* @__PURE__ */ D("circle", {
|
|
1649
1650
|
cx: "11",
|
|
1650
1651
|
cy: "11",
|
|
1651
1652
|
r: "8"
|
|
1652
1653
|
}), /* @__PURE__ */ D("path", { d: "m21 21-4.3-4.3" })]
|
|
1653
|
-
}),
|
|
1654
|
+
}), Ut = (e) => /* @__PURE__ */ O(Q, {
|
|
1654
1655
|
...e,
|
|
1655
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" })]
|
|
1656
|
-
}),
|
|
1657
|
+
}), Wt = (e) => /* @__PURE__ */ O(Q, {
|
|
1657
1658
|
...e,
|
|
1658
1659
|
children: [
|
|
1659
1660
|
/* @__PURE__ */ D("circle", {
|
|
@@ -1672,13 +1673,13 @@ var jt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1672
1673
|
r: "1"
|
|
1673
1674
|
})
|
|
1674
1675
|
]
|
|
1675
|
-
}),
|
|
1676
|
+
}), Gt = (e) => /* @__PURE__ */ O(Q, {
|
|
1676
1677
|
...e,
|
|
1677
1678
|
children: [/* @__PURE__ */ D("path", { d: "M18 6 6 18" }), /* @__PURE__ */ D("path", { d: "m6 6 12 12" })]
|
|
1678
1679
|
});
|
|
1679
1680
|
//#endregion
|
|
1680
1681
|
//#region src/editor/storage/remove-resource.ts
|
|
1681
|
-
async function
|
|
1682
|
+
async function Kt(e) {
|
|
1682
1683
|
if (e) {
|
|
1683
1684
|
if (e.startsWith("blob:")) {
|
|
1684
1685
|
URL.revokeObjectURL(e);
|
|
@@ -1693,61 +1694,61 @@ async function Wt(e) {
|
|
|
1693
1694
|
}
|
|
1694
1695
|
//#endregion
|
|
1695
1696
|
//#region src/editor/ai/pending-removal.ts
|
|
1696
|
-
var
|
|
1697
|
+
var qt = 3e4, Jt = /* @__PURE__ */ new Set([
|
|
1697
1698
|
"image",
|
|
1698
1699
|
"attachmentEmbed",
|
|
1699
1700
|
"audioEmbed",
|
|
1700
1701
|
"videoEmbed"
|
|
1701
|
-
]),
|
|
1702
|
-
function
|
|
1702
|
+
]), Yt = /* @__PURE__ */ new WeakMap();
|
|
1703
|
+
function Xt(e) {
|
|
1703
1704
|
let t = /* @__PURE__ */ new Set();
|
|
1704
1705
|
return e.state.doc.descendants((e) => {
|
|
1705
|
-
if (
|
|
1706
|
+
if (Jt.has(e.type.name)) {
|
|
1706
1707
|
let n = e.attrs.src;
|
|
1707
1708
|
n && t.add(n);
|
|
1708
1709
|
}
|
|
1709
1710
|
return !0;
|
|
1710
1711
|
}), t;
|
|
1711
1712
|
}
|
|
1712
|
-
function
|
|
1713
|
-
let t =
|
|
1713
|
+
function Zt(e) {
|
|
1714
|
+
let t = Yt.get(e);
|
|
1714
1715
|
return t || (t = {
|
|
1715
1716
|
timers: /* @__PURE__ */ new Map(),
|
|
1716
1717
|
onTransaction: () => {},
|
|
1717
1718
|
listening: !1
|
|
1718
|
-
},
|
|
1719
|
+
}, Yt.set(e, t)), t;
|
|
1719
1720
|
}
|
|
1720
|
-
function
|
|
1721
|
+
function Qt(e, t) {
|
|
1721
1722
|
let n = [...new Set(t.filter(Boolean))];
|
|
1722
1723
|
if (n.length === 0) return;
|
|
1723
|
-
let r =
|
|
1724
|
+
let r = Zt(e);
|
|
1724
1725
|
r.listening ||= (r.onTransaction = () => {
|
|
1725
1726
|
if (r.timers.size === 0) return;
|
|
1726
|
-
let t =
|
|
1727
|
+
let t = Xt(e);
|
|
1727
1728
|
for (let [e, n] of r.timers) t.has(e) && (clearTimeout(n), r.timers.delete(e));
|
|
1728
1729
|
}, e.on("transaction", r.onTransaction), !0);
|
|
1729
1730
|
for (let t of n) {
|
|
1730
1731
|
if (r.timers.has(t)) continue;
|
|
1731
1732
|
let n = setTimeout(() => {
|
|
1732
|
-
|
|
1733
|
-
},
|
|
1733
|
+
Xt(e).has(t) || Kt(t), r.timers.delete(t);
|
|
1734
|
+
}, qt);
|
|
1734
1735
|
r.timers.set(t, n);
|
|
1735
1736
|
}
|
|
1736
1737
|
}
|
|
1737
|
-
function
|
|
1738
|
-
let t =
|
|
1738
|
+
function $t(e) {
|
|
1739
|
+
let t = Yt.get(e);
|
|
1739
1740
|
if (t) {
|
|
1740
1741
|
if (t.listening &&= (e.off("transaction", t.onTransaction), !1), t.timers.size > 0) {
|
|
1741
|
-
let n =
|
|
1742
|
-
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) ||
|
|
1742
|
+
let n = Xt(e);
|
|
1743
|
+
for (let [e, r] of t.timers) clearTimeout(r), n.has(e) || Kt(e);
|
|
1743
1744
|
t.timers.clear();
|
|
1744
1745
|
}
|
|
1745
|
-
|
|
1746
|
+
Yt.delete(e);
|
|
1746
1747
|
}
|
|
1747
1748
|
}
|
|
1748
1749
|
//#endregion
|
|
1749
1750
|
//#region src/editor/ai/components/ai-selector.tsx
|
|
1750
|
-
var
|
|
1751
|
+
var en = [
|
|
1751
1752
|
{
|
|
1752
1753
|
mode: "continue",
|
|
1753
1754
|
labelKey: "editor.ai.continue",
|
|
@@ -1790,24 +1791,24 @@ var Qt = [
|
|
|
1790
1791
|
descKey: "editor.ai.zapDesc",
|
|
1791
1792
|
icon: "⚡"
|
|
1792
1793
|
}
|
|
1793
|
-
],
|
|
1794
|
+
], tn = /* @__PURE__ */ new Set([
|
|
1794
1795
|
"image",
|
|
1795
1796
|
"attachmentEmbed",
|
|
1796
1797
|
"audioEmbed",
|
|
1797
1798
|
"videoEmbed"
|
|
1798
|
-
]),
|
|
1799
|
+
]), nn = {
|
|
1799
1800
|
image: "editor.ai.nodeImage",
|
|
1800
1801
|
attachmentEmbed: "editor.ai.nodeAttachment",
|
|
1801
1802
|
videoEmbed: "editor.ai.nodeVideo",
|
|
1802
1803
|
audioEmbed: "editor.ai.nodeAudio"
|
|
1803
1804
|
};
|
|
1804
|
-
function
|
|
1805
|
+
function rn(e, t) {
|
|
1805
1806
|
return e.storage.qingwuUI?.parseMd?.(e.schema, t) || null;
|
|
1806
1807
|
}
|
|
1807
|
-
function
|
|
1808
|
+
function an(e, t, n) {
|
|
1808
1809
|
let r = [];
|
|
1809
1810
|
return e.state.doc.nodesBetween(t, n, (e) => {
|
|
1810
|
-
if (
|
|
1811
|
+
if (tn.has(e.type.name)) {
|
|
1811
1812
|
let t = e.attrs.src;
|
|
1812
1813
|
t && r.push({
|
|
1813
1814
|
type: e.type.name,
|
|
@@ -1817,27 +1818,27 @@ function nn(e, t, n) {
|
|
|
1817
1818
|
return !0;
|
|
1818
1819
|
}), r;
|
|
1819
1820
|
}
|
|
1820
|
-
function
|
|
1821
|
+
function on(e) {
|
|
1821
1822
|
let t = /* @__PURE__ */ new Set();
|
|
1822
1823
|
return e.state.doc.descendants((e) => {
|
|
1823
|
-
if (
|
|
1824
|
+
if (tn.has(e.type.name)) {
|
|
1824
1825
|
let n = e.attrs.src;
|
|
1825
1826
|
n && t.add(n);
|
|
1826
1827
|
}
|
|
1827
1828
|
return !0;
|
|
1828
1829
|
}), t;
|
|
1829
1830
|
}
|
|
1830
|
-
function
|
|
1831
|
-
let n =
|
|
1831
|
+
function sn(e, t) {
|
|
1832
|
+
let n = rn(e, t);
|
|
1832
1833
|
if (n && n.size > 0) {
|
|
1833
1834
|
let t = e.state.tr;
|
|
1834
|
-
t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(
|
|
1835
|
+
t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(ae.create(t.doc, t.doc.content.size)), e.view.dispatch(t.scrollIntoView()), e.commands.focus();
|
|
1835
1836
|
return;
|
|
1836
1837
|
}
|
|
1837
1838
|
e.commands.setContent(t), e.commands.focus();
|
|
1838
1839
|
}
|
|
1839
|
-
function
|
|
1840
|
-
let i =
|
|
1840
|
+
function cn(e, t, n, r) {
|
|
1841
|
+
let i = rn(e, t);
|
|
1841
1842
|
if (e.commands.focus(), !i) {
|
|
1842
1843
|
let i = e.chain().focus();
|
|
1843
1844
|
n === "replace" ? i.setTextSelection({
|
|
@@ -1849,7 +1850,7 @@ function on(e, t, n, r) {
|
|
|
1849
1850
|
let a = e.state.tr;
|
|
1850
1851
|
n === "replace" ? a.replaceRange(r.from, r.to, new N(i, 0, 0)) : a.insert(Math.min(r.to, e.state.doc.content.size), i), e.view.dispatch(a.scrollIntoView());
|
|
1851
1852
|
}
|
|
1852
|
-
function
|
|
1853
|
+
function ln({ editor: e, onClose: t }) {
|
|
1853
1854
|
let [n, r] = T(null), [i, a] = T(""), [o, s] = T(""), [c, l] = T(!1), [u, d] = T(null), [p, m] = T(null), h = w({
|
|
1854
1855
|
from: 0,
|
|
1855
1856
|
to: 0,
|
|
@@ -1868,7 +1869,7 @@ function sn({ editor: e, onClose: t }) {
|
|
|
1868
1869
|
empty: n.empty
|
|
1869
1870
|
}, l(!0), s(""), v.current = !0, d(null);
|
|
1870
1871
|
try {
|
|
1871
|
-
let r =
|
|
1872
|
+
let r = yt(), a = n.empty ? e.state.doc.textContent : e.state.doc.textBetween(n.from, n.to), o = [];
|
|
1872
1873
|
for await (let e of r.stream({
|
|
1873
1874
|
mode: t,
|
|
1874
1875
|
context: a,
|
|
@@ -1893,13 +1894,13 @@ function sn({ editor: e, onClose: t }) {
|
|
|
1893
1894
|
!e || !v.current || (e.scrollTop = e.scrollHeight);
|
|
1894
1895
|
}, [o]);
|
|
1895
1896
|
let k = b((t, n, r) => {
|
|
1896
|
-
let i = new Set(
|
|
1897
|
-
t === "replaceAll" ?
|
|
1898
|
-
let a =
|
|
1899
|
-
|
|
1897
|
+
let i = new Set(an(e, r.from, r.to).map((e) => e.src));
|
|
1898
|
+
t === "replaceAll" ? sn(e, n) : cn(e, n, "replace", h.current);
|
|
1899
|
+
let a = on(e);
|
|
1900
|
+
Qt(e, [...i].filter((e) => !a.has(e)));
|
|
1900
1901
|
}, [e]), A = b((n) => {
|
|
1901
1902
|
if (n === "below") {
|
|
1902
|
-
|
|
1903
|
+
cn(e, o, "below", h.current), t();
|
|
1903
1904
|
return;
|
|
1904
1905
|
}
|
|
1905
1906
|
let r = h.current, i = n === "replaceAll" ? {
|
|
@@ -1908,7 +1909,7 @@ function sn({ editor: e, onClose: t }) {
|
|
|
1908
1909
|
} : {
|
|
1909
1910
|
from: r.from,
|
|
1910
1911
|
to: r.to
|
|
1911
|
-
}, a =
|
|
1912
|
+
}, a = an(e, i.from, i.to);
|
|
1912
1913
|
if (a.length > 0) {
|
|
1913
1914
|
m({
|
|
1914
1915
|
position: n,
|
|
@@ -1949,19 +1950,19 @@ function sn({ editor: e, onClose: t }) {
|
|
|
1949
1950
|
className: "flex items-center justify-between pl-3 pr-1.5 py-1.5 border-b border-default-100 shrink-0",
|
|
1950
1951
|
children: [/* @__PURE__ */ O("span", {
|
|
1951
1952
|
className: "flex items-center gap-1.5 text-xs font-medium text-default-500",
|
|
1952
|
-
children: [/* @__PURE__ */ D(
|
|
1953
|
+
children: [/* @__PURE__ */ D(Ut, { className: "text-primary" }), f("editor.ai.trigger")]
|
|
1953
1954
|
}), /* @__PURE__ */ D("button", {
|
|
1954
1955
|
type: "button",
|
|
1955
1956
|
onClick: t,
|
|
1956
1957
|
"aria-label": f("editor.ai.close"),
|
|
1957
1958
|
title: f("editor.ai.close"),
|
|
1958
1959
|
className: "flex items-center justify-center w-6 h-6 rounded-md text-default-400 hover:bg-default-100 hover:text-default-700 transition-colors",
|
|
1959
|
-
children: /* @__PURE__ */ D(
|
|
1960
|
+
children: /* @__PURE__ */ D(Gt, {})
|
|
1960
1961
|
})]
|
|
1961
1962
|
}),
|
|
1962
1963
|
/* @__PURE__ */ D("div", {
|
|
1963
1964
|
className: "grid grid-cols-[repeat(auto-fit,minmax(64px,1fr))] gap-1.5 p-2 shrink-0",
|
|
1964
|
-
children:
|
|
1965
|
+
children: en.map(({ mode: e, labelKey: t, descKey: r, icon: i }) => /* @__PURE__ */ O("button", {
|
|
1965
1966
|
type: "button",
|
|
1966
1967
|
className: `flex flex-col items-center gap-1 px-1 py-2 rounded-xl border transition-colors ${n === e ? "border-primary/40 bg-primary/10 text-primary" : "border-default-200 text-default-600 hover:bg-default-100 hover:text-default-900"}`,
|
|
1967
1968
|
onClick: () => y(e),
|
|
@@ -2104,7 +2105,7 @@ function sn({ editor: e, onClose: t }) {
|
|
|
2104
2105
|
children: Object.entries(N).map(([e, t]) => /* @__PURE__ */ O("li", {
|
|
2105
2106
|
className: "text-sm text-default-700",
|
|
2106
2107
|
children: [
|
|
2107
|
-
f(
|
|
2108
|
+
f(nn[e] ?? e),
|
|
2108
2109
|
" ×",
|
|
2109
2110
|
t
|
|
2110
2111
|
]
|
|
@@ -2136,19 +2137,19 @@ function sn({ editor: e, onClose: t }) {
|
|
|
2136
2137
|
}
|
|
2137
2138
|
//#endregion
|
|
2138
2139
|
//#region src/editor/attachment-limits.ts
|
|
2139
|
-
var
|
|
2140
|
+
var un = /* @__PURE__ */ new Set([
|
|
2140
2141
|
"attachmentEmbed",
|
|
2141
2142
|
"videoEmbed",
|
|
2142
2143
|
"audioEmbed",
|
|
2143
2144
|
"image"
|
|
2144
2145
|
]);
|
|
2145
|
-
function
|
|
2146
|
+
function dn(e) {
|
|
2146
2147
|
let t = 0;
|
|
2147
2148
|
return e.descendants((e) => {
|
|
2148
|
-
|
|
2149
|
+
un.has(e.type.name) && (t += Number(e.attrs?.size) || 0);
|
|
2149
2150
|
}), t;
|
|
2150
2151
|
}
|
|
2151
|
-
function
|
|
2152
|
+
function fn(e) {
|
|
2152
2153
|
if (!Number.isFinite(e) || e <= 0) return "0 B";
|
|
2153
2154
|
let t = [
|
|
2154
2155
|
"B",
|
|
@@ -2159,41 +2160,41 @@ function un(e) {
|
|
|
2159
2160
|
], n = Math.min(t.length - 1, Math.floor(Math.log(e) / Math.log(1024))), r = e / 1024 ** n;
|
|
2160
2161
|
return `${n === 0 || r >= 100 ? `${Math.round(r)}` : `${Math.round(r * 10) / 10}`} ${t[n]}`;
|
|
2161
2162
|
}
|
|
2162
|
-
function
|
|
2163
|
+
function pn(e) {
|
|
2163
2164
|
return (e?.storage)?.qingwuUI?.limits;
|
|
2164
2165
|
}
|
|
2165
|
-
function
|
|
2166
|
+
function mn(e, t, n) {
|
|
2166
2167
|
let { maxAttachmentSize: r, maxTotalAttachmentSize: i } = n;
|
|
2167
|
-
if (r && t.size > r) return `单文件大小不能超过 ${
|
|
2168
|
+
if (r && t.size > r) return `单文件大小不能超过 ${fn(r)}(当前 ${fn(t.size)})`;
|
|
2168
2169
|
if (i) {
|
|
2169
|
-
let n =
|
|
2170
|
-
if (n > i) return `附件总大小不能超过 ${
|
|
2170
|
+
let n = dn(e) + t.size;
|
|
2171
|
+
if (n > i) return `附件总大小不能超过 ${fn(i)}(当前合计 ${fn(n)})`;
|
|
2171
2172
|
}
|
|
2172
2173
|
return null;
|
|
2173
2174
|
}
|
|
2174
2175
|
//#endregion
|
|
2175
2176
|
//#region src/editor/utils/delete-confirm.ts
|
|
2176
|
-
var
|
|
2177
|
-
function
|
|
2178
|
-
return
|
|
2177
|
+
var hn = !1, gn = null, _n = 5e3;
|
|
2178
|
+
function vn() {
|
|
2179
|
+
return hn;
|
|
2179
2180
|
}
|
|
2180
2181
|
function $(e) {
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
},
|
|
2182
|
+
hn = e, gn &&= (clearTimeout(gn), null), e && (gn = setTimeout(() => {
|
|
2183
|
+
hn = !1, gn = null;
|
|
2184
|
+
}, _n));
|
|
2184
2185
|
}
|
|
2185
|
-
var
|
|
2186
|
-
function
|
|
2187
|
-
|
|
2186
|
+
var yn = null;
|
|
2187
|
+
function bn(e) {
|
|
2188
|
+
yn = e;
|
|
2188
2189
|
}
|
|
2189
|
-
function
|
|
2190
|
-
return
|
|
2190
|
+
function xn() {
|
|
2191
|
+
return yn;
|
|
2191
2192
|
}
|
|
2192
2193
|
//#endregion
|
|
2193
2194
|
//#region src/editor/utils/delete-confirm-dialog.tsx
|
|
2194
|
-
var
|
|
2195
|
-
function
|
|
2196
|
-
let [s, c] = T(!1), l = w(!1), u =
|
|
2195
|
+
var Sn = 300;
|
|
2196
|
+
function Cn({ open: e, title: t, message: n, confirmText: r = "删除", cancelText: i = "取消", onConfirm: a, onCancel: o }) {
|
|
2197
|
+
let [s, c] = T(!1), l = w(!1), u = xn();
|
|
2197
2198
|
return x(() => {
|
|
2198
2199
|
if (!e) {
|
|
2199
2200
|
l.current = !1;
|
|
@@ -2219,7 +2220,7 @@ function xn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2219
2220
|
o
|
|
2220
2221
|
]), x(() => {
|
|
2221
2222
|
e || c(!1);
|
|
2222
|
-
}, [e]), u || !e ? null :
|
|
2223
|
+
}, [e]), u || !e ? null : L(/* @__PURE__ */ D("div", {
|
|
2223
2224
|
className: "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none",
|
|
2224
2225
|
onClick: () => {
|
|
2225
2226
|
s || o();
|
|
@@ -2263,7 +2264,7 @@ function xn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2263
2264
|
await a();
|
|
2264
2265
|
} finally {
|
|
2265
2266
|
let t = Date.now() - e;
|
|
2266
|
-
t <
|
|
2267
|
+
t < Sn && await new Promise((e) => setTimeout(e, Sn - t)), c(!1), o();
|
|
2267
2268
|
}
|
|
2268
2269
|
},
|
|
2269
2270
|
disabled: s,
|
|
@@ -2276,18 +2277,18 @@ function xn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2276
2277
|
}
|
|
2277
2278
|
//#endregion
|
|
2278
2279
|
//#region src/editor/extensions/image-view.tsx
|
|
2279
|
-
function
|
|
2280
|
+
function wn(e) {
|
|
2280
2281
|
return /^(\.\.?\/|[a-zA-Z]:\\|file:\/\/)/.test(e) ? !0 : !(/^[a-z]+:\/\//i.test(e) || e.startsWith("/") || e.startsWith("data:") || e.startsWith("blob:"));
|
|
2281
2282
|
}
|
|
2282
|
-
function
|
|
2283
|
-
let [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(!1), u = w(!1), [d, f] = T(!1), p = e.attrs.src || "", m = e.attrs.alt || "", h = e.attrs.width || null, g = e.attrs.height || null, _ = w(null), v = w(null), y = w(null), S = w(null), C = w(null), E = w(!1), k = w(!1), A = w(0), [j, M] = T(p), N = r?.isEditable ?? !0,
|
|
2283
|
+
function Tn({ node: e, deleteNode: t, editor: r }) {
|
|
2284
|
+
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(() => {
|
|
2284
2285
|
o || (A.current = window.scrollY, a(!0));
|
|
2285
|
-
}, [o]),
|
|
2286
|
+
}, [o]), F = b(() => {
|
|
2286
2287
|
a(!1), requestAnimationFrame(() => window.scrollTo(0, A.current));
|
|
2287
|
-
}, []),
|
|
2288
|
+
}, []), I = b(() => {
|
|
2288
2289
|
let e = _.current;
|
|
2289
2290
|
e && (A.current = window.scrollY, e.requestFullscreen ? e.requestFullscreen() : e.webkitRequestFullscreen && e.webkitRequestFullscreen());
|
|
2290
|
-
}, []),
|
|
2291
|
+
}, []), te = b(() => {
|
|
2291
2292
|
let e = v.current;
|
|
2292
2293
|
e && (A.current = window.scrollY, e.requestFullscreen ? e.requestFullscreen() : e.webkitRequestFullscreen && e.webkitRequestFullscreen());
|
|
2293
2294
|
}, []);
|
|
@@ -2332,20 +2333,20 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2332
2333
|
};
|
|
2333
2334
|
return document.addEventListener("fullscreenchange", e), () => document.removeEventListener("fullscreenchange", e);
|
|
2334
2335
|
}, []);
|
|
2335
|
-
let
|
|
2336
|
-
return /* @__PURE__ */ O(
|
|
2336
|
+
let ne = o || wn(p);
|
|
2337
|
+
return /* @__PURE__ */ O(P, {
|
|
2337
2338
|
as: "div",
|
|
2338
2339
|
className: "image-node-view group/img",
|
|
2339
2340
|
contentEditable: !1,
|
|
2340
2341
|
children: [
|
|
2341
|
-
|
|
2342
|
+
ne ? /* @__PURE__ */ O("div", {
|
|
2342
2343
|
className: "image-placeholder",
|
|
2343
2344
|
children: [
|
|
2344
2345
|
N && /* @__PURE__ */ D("button", {
|
|
2345
2346
|
type: "button",
|
|
2346
2347
|
className: "img-ctrl-btn img-ctrl-btn--del image-placeholder-del",
|
|
2347
2348
|
onClick: () => {
|
|
2348
|
-
|
|
2349
|
+
vn() || ($(!0), f(!0));
|
|
2349
2350
|
},
|
|
2350
2351
|
title: "删除",
|
|
2351
2352
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2377,7 +2378,7 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2377
2378
|
}),
|
|
2378
2379
|
/* @__PURE__ */ D("span", {
|
|
2379
2380
|
className: "image-placeholder-text",
|
|
2380
|
-
children:
|
|
2381
|
+
children: wn(p) ? "本地图片无法加载" : "图片加载失败"
|
|
2381
2382
|
}),
|
|
2382
2383
|
/* @__PURE__ */ D("span", {
|
|
2383
2384
|
className: "image-placeholder-path",
|
|
@@ -2393,7 +2394,7 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2393
2394
|
alt: m,
|
|
2394
2395
|
width: h || void 0,
|
|
2395
2396
|
height: g || void 0,
|
|
2396
|
-
onClick:
|
|
2397
|
+
onClick: ee,
|
|
2397
2398
|
onError: () => {
|
|
2398
2399
|
E.current || o || (E.current = !0, (async () => {
|
|
2399
2400
|
try {
|
|
@@ -2419,7 +2420,7 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2419
2420
|
/* @__PURE__ */ D("button", {
|
|
2420
2421
|
type: "button",
|
|
2421
2422
|
className: "img-ctrl-btn",
|
|
2422
|
-
onClick:
|
|
2423
|
+
onClick: ee,
|
|
2423
2424
|
title: "网页全屏",
|
|
2424
2425
|
children: /* @__PURE__ */ D("svg", {
|
|
2425
2426
|
width: "14",
|
|
@@ -2438,7 +2439,7 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2438
2439
|
/* @__PURE__ */ D("button", {
|
|
2439
2440
|
type: "button",
|
|
2440
2441
|
className: "img-ctrl-btn",
|
|
2441
|
-
onClick:
|
|
2442
|
+
onClick: I,
|
|
2442
2443
|
title: "全屏",
|
|
2443
2444
|
children: /* @__PURE__ */ D("svg", {
|
|
2444
2445
|
width: "14",
|
|
@@ -2458,7 +2459,7 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2458
2459
|
type: "button",
|
|
2459
2460
|
className: "img-ctrl-btn img-ctrl-btn--del",
|
|
2460
2461
|
onClick: () => {
|
|
2461
|
-
|
|
2462
|
+
vn() || ($(!0), f(!0));
|
|
2462
2463
|
},
|
|
2463
2464
|
title: "删除",
|
|
2464
2465
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -2478,15 +2479,15 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2478
2479
|
]
|
|
2479
2480
|
})]
|
|
2480
2481
|
}),
|
|
2481
|
-
i && !
|
|
2482
|
+
i && !ne && /* @__PURE__ */ O("div", {
|
|
2482
2483
|
className: "image-lightbox",
|
|
2483
|
-
onClick:
|
|
2484
|
+
onClick: F,
|
|
2484
2485
|
children: [/* @__PURE__ */ O("div", {
|
|
2485
2486
|
className: "image-lightbox-bar",
|
|
2486
2487
|
children: [/* @__PURE__ */ D("button", {
|
|
2487
2488
|
type: "button",
|
|
2488
2489
|
className: "image-lightbox-bar-btn",
|
|
2489
|
-
onClick:
|
|
2490
|
+
onClick: te,
|
|
2490
2491
|
title: "全屏",
|
|
2491
2492
|
children: /* @__PURE__ */ D("svg", {
|
|
2492
2493
|
width: "18",
|
|
@@ -2504,7 +2505,7 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2504
2505
|
}), /* @__PURE__ */ D("button", {
|
|
2505
2506
|
type: "button",
|
|
2506
2507
|
className: "image-lightbox-bar-btn",
|
|
2507
|
-
onClick:
|
|
2508
|
+
onClick: F,
|
|
2508
2509
|
title: "关闭",
|
|
2509
2510
|
children: /* @__PURE__ */ D("svg", {
|
|
2510
2511
|
width: "18",
|
|
@@ -2545,16 +2546,16 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2545
2546
|
}
|
|
2546
2547
|
})]
|
|
2547
2548
|
}),
|
|
2548
|
-
/* @__PURE__ */ D(
|
|
2549
|
+
/* @__PURE__ */ D(Cn, {
|
|
2549
2550
|
open: d,
|
|
2550
2551
|
title: "确认删除图片",
|
|
2551
|
-
message:
|
|
2552
|
+
message: ne ? "该图片无法在当前环境加载,仅从编辑器中移除该图片节点,不影响存储文件。" : "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
2552
2553
|
onCancel: () => {
|
|
2553
2554
|
$(!1), f(!1);
|
|
2554
2555
|
},
|
|
2555
2556
|
onConfirm: async () => {
|
|
2556
|
-
if (!
|
|
2557
|
-
await
|
|
2557
|
+
if (!ne) try {
|
|
2558
|
+
await Kt(p);
|
|
2558
2559
|
} catch {}
|
|
2559
2560
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
2560
2561
|
}
|
|
@@ -2564,7 +2565,7 @@ function Cn({ node: e, deleteNode: t, editor: r }) {
|
|
|
2564
2565
|
}
|
|
2565
2566
|
//#endregion
|
|
2566
2567
|
//#region src/editor/embeds/attachment-view.tsx
|
|
2567
|
-
var
|
|
2568
|
+
var En = y(() => import("@file-viewer/react")), Dn = /* @__PURE__ */ new Set(), On = {
|
|
2568
2569
|
rendererMode: "replace",
|
|
2569
2570
|
autoRenderers: !0,
|
|
2570
2571
|
theme: "light",
|
|
@@ -2593,7 +2594,7 @@ var wn = y(() => import("@file-viewer/react")), Tn = /* @__PURE__ */ new Set(),
|
|
|
2593
2594
|
cache: !0,
|
|
2594
2595
|
workerTimeoutMs: 3e4
|
|
2595
2596
|
}
|
|
2596
|
-
},
|
|
2597
|
+
}, kn = {
|
|
2597
2598
|
pdf: "pdf",
|
|
2598
2599
|
docx: "word",
|
|
2599
2600
|
docm: "word",
|
|
@@ -2648,7 +2649,7 @@ var wn = y(() => import("@file-viewer/react")), Tn = /* @__PURE__ */ new Set(),
|
|
|
2648
2649
|
xml: "text",
|
|
2649
2650
|
yml: "text",
|
|
2650
2651
|
yaml: "text"
|
|
2651
|
-
},
|
|
2652
|
+
}, An = {
|
|
2652
2653
|
pdf: () => import("@file-viewer/renderer-pdf").then((e) => e.pdfRenderer),
|
|
2653
2654
|
word: () => import("@file-viewer/renderer-word").then((e) => e.wordRenderer),
|
|
2654
2655
|
spreadsheet: () => import("@file-viewer/renderer-spreadsheet").then((e) => e.spreadsheetRenderer),
|
|
@@ -2656,10 +2657,10 @@ var wn = y(() => import("@file-viewer/react")), Tn = /* @__PURE__ */ new Set(),
|
|
|
2656
2657
|
archive: () => import("@file-viewer/renderer-archive").then((e) => e.archiveRenderer),
|
|
2657
2658
|
text: () => import("@file-viewer/renderer-text").then((e) => e.textRenderer)
|
|
2658
2659
|
};
|
|
2659
|
-
function
|
|
2660
|
+
function jn(e) {
|
|
2660
2661
|
return e ? e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1048576).toFixed(1)} MB` : "";
|
|
2661
2662
|
}
|
|
2662
|
-
function
|
|
2663
|
+
function Mn(e) {
|
|
2663
2664
|
let t = e.split(".").pop()?.toLowerCase() || "", n = {
|
|
2664
2665
|
pdf: {
|
|
2665
2666
|
label: "PDF",
|
|
@@ -2832,22 +2833,22 @@ function An(e) {
|
|
|
2832
2833
|
]
|
|
2833
2834
|
});
|
|
2834
2835
|
}
|
|
2835
|
-
function
|
|
2836
|
+
function Nn(e) {
|
|
2836
2837
|
return e.split(".").pop()?.toLowerCase() || "";
|
|
2837
2838
|
}
|
|
2838
|
-
function
|
|
2839
|
+
function Pn(e) {
|
|
2839
2840
|
let t = e.split(".").pop()?.toLowerCase() || "";
|
|
2840
2841
|
return /^(pdf|docx?|dotx?|xlsx?|xltx?|pptx?|potx?|txt|md|html?|csv|json|xml|yml|yaml|log|zip|rar|7z|tar|gz|odt|ods|odp|rtf|xlsm|xlsb|ppsx|numbers|tgz|bz2|xz|zst|js|ts|tsx|py|sh|sql)$/.test(t);
|
|
2841
2842
|
}
|
|
2842
|
-
function
|
|
2843
|
+
function Fn(e) {
|
|
2843
2844
|
return !!e && !e.startsWith("file:");
|
|
2844
2845
|
}
|
|
2845
|
-
function
|
|
2846
|
+
function In(e) {
|
|
2846
2847
|
return btoa(encodeURIComponent(e)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
2847
2848
|
}
|
|
2848
|
-
async function
|
|
2849
|
+
async function Ln(e, t) {
|
|
2849
2850
|
try {
|
|
2850
|
-
let n =
|
|
2851
|
+
let n = In(e), r = await fetch(`/api/preview/${n}`, {
|
|
2851
2852
|
signal: t,
|
|
2852
2853
|
cache: "no-store"
|
|
2853
2854
|
});
|
|
@@ -2859,7 +2860,7 @@ async function Fn(e, t) {
|
|
|
2859
2860
|
return null;
|
|
2860
2861
|
}
|
|
2861
2862
|
}
|
|
2862
|
-
function
|
|
2863
|
+
function Rn(e, t, n) {
|
|
2863
2864
|
return new Promise((r, i) => {
|
|
2864
2865
|
let a = new XMLHttpRequest();
|
|
2865
2866
|
if (a.open("GET", e, !0), a.responseType = "arraybuffer", t) {
|
|
@@ -2897,51 +2898,51 @@ function In(e, t, n) {
|
|
|
2897
2898
|
a.send();
|
|
2898
2899
|
});
|
|
2899
2900
|
}
|
|
2900
|
-
function
|
|
2901
|
-
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() =>
|
|
2901
|
+
function zn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
2902
|
+
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() => Dn.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, L] = T(!1), R = w(null), [re, ie] = T(0), [z, B] = T("none"), [V, H] = T(void 0), [ae, oe] = T(!1), U = e.attrs.src || "", W = e.attrs.name || U && U.split("/").pop()?.split("?")[0] || (U ? "attachment" : f("editor.attachment.lost")), se = e.attrs.size || 0, G = Nn(W), K = !U;
|
|
2902
2903
|
x(() => {
|
|
2903
2904
|
if (!c) {
|
|
2904
2905
|
H(void 0), oe(!1);
|
|
2905
2906
|
return;
|
|
2906
2907
|
}
|
|
2907
|
-
let e =
|
|
2908
|
+
let e = kn[G];
|
|
2908
2909
|
if (!e) {
|
|
2909
2910
|
H(void 0), oe(!1);
|
|
2910
2911
|
return;
|
|
2911
2912
|
}
|
|
2912
2913
|
let t = !0;
|
|
2913
|
-
return H(void 0), oe(!1),
|
|
2914
|
+
return H(void 0), oe(!1), An[e]().then((e) => {
|
|
2914
2915
|
t && H(e);
|
|
2915
2916
|
}).catch((n) => {
|
|
2916
2917
|
console.error(`[attachment] renderer "${e}" load failed:`, n), t && oe(!0);
|
|
2917
2918
|
}), () => {
|
|
2918
2919
|
t = !1;
|
|
2919
2920
|
};
|
|
2920
|
-
}, [c,
|
|
2921
|
-
let
|
|
2922
|
-
...
|
|
2921
|
+
}, [c, G]);
|
|
2922
|
+
let ce = C(() => ({
|
|
2923
|
+
...On,
|
|
2923
2924
|
renderers: V ? [V] : [],
|
|
2924
2925
|
rendererMode: "replace"
|
|
2925
|
-
}), [V]),
|
|
2926
|
+
}), [V]), q = b((e) => {
|
|
2926
2927
|
l((t) => {
|
|
2927
2928
|
let n = typeof e == "function" ? e(t) : e;
|
|
2928
|
-
return U && (n ?
|
|
2929
|
+
return U && (n ? Dn.add(U) : Dn.delete(U)), n;
|
|
2929
2930
|
});
|
|
2930
2931
|
}, [U]);
|
|
2931
2932
|
x(() => {
|
|
2932
|
-
l(U ?
|
|
2933
|
+
l(U ? Dn.has(U) : !1);
|
|
2933
2934
|
}, [U]);
|
|
2934
2935
|
let le = b(() => {
|
|
2935
|
-
|
|
2936
|
-
window.scrollTo(0,
|
|
2936
|
+
F.current = !0, q(!0), window.setTimeout(() => {
|
|
2937
|
+
window.scrollTo(0, ee.current), I.current && (I.current.scrollTop = te.current), F.current && q(!0), F.current = !1;
|
|
2937
2938
|
}, 0);
|
|
2938
|
-
}, [
|
|
2939
|
-
z === "web" ? (B("none"), document.body.style.overflow = "", le()) : (z === "native" && document.fullscreenElement && await document.exitFullscreen(),
|
|
2939
|
+
}, [q]), ue = b(async () => {
|
|
2940
|
+
z === "web" ? (B("none"), document.body.style.overflow = "", le()) : (z === "native" && document.fullscreenElement && await document.exitFullscreen(), ee.current = window.scrollY, te.current = I.current?.scrollTop ?? 0, document.body.style.overflow = "hidden", B("web"));
|
|
2940
2941
|
}, [z]), de = b(async () => {
|
|
2941
2942
|
let e = M.current;
|
|
2942
|
-
e && (z === "native" ? await document.exitFullscreen() : (z === "web" && (B("none"), document.body.style.overflow = ""),
|
|
2943
|
+
e && (z === "native" ? await document.exitFullscreen() : (z === "web" && (B("none"), document.body.style.overflow = ""), ee.current = window.scrollY, te.current = I.current?.scrollTop ?? 0, await e.requestFullscreen(), B("native")));
|
|
2943
2944
|
}, [z, le]), fe = b(() => {
|
|
2944
|
-
z === "none" && (
|
|
2945
|
+
z === "none" && (F.current || q((e) => !e));
|
|
2945
2946
|
}, [z]);
|
|
2946
2947
|
x(() => {
|
|
2947
2948
|
let e = () => {
|
|
@@ -2954,7 +2955,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2954
2955
|
};
|
|
2955
2956
|
}, [z, le]), x(() => {
|
|
2956
2957
|
let e = (e) => {
|
|
2957
|
-
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !i ||
|
|
2958
|
+
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !i || vn()) return;
|
|
2958
2959
|
let t = a?.view?.dom, n = e.target;
|
|
2959
2960
|
if (a?.isFocused && n instanceof Node && t?.contains(n)) {
|
|
2960
2961
|
if (e.preventDefault(), e.stopPropagation(), a) {
|
|
@@ -2964,7 +2965,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2964
2965
|
to: t
|
|
2965
2966
|
};
|
|
2966
2967
|
}
|
|
2967
|
-
window.getSelection()?.removeAllRanges(), $(!0),
|
|
2968
|
+
window.getSelection()?.removeAllRanges(), $(!0), L(!0);
|
|
2968
2969
|
}
|
|
2969
2970
|
};
|
|
2970
2971
|
return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
|
|
@@ -2973,7 +2974,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2973
2974
|
a,
|
|
2974
2975
|
o
|
|
2975
2976
|
]), x(() => {
|
|
2976
|
-
if (!c || !
|
|
2977
|
+
if (!c || !Fn(U)) {
|
|
2977
2978
|
d(null), y(null), N.current = null;
|
|
2978
2979
|
return;
|
|
2979
2980
|
}
|
|
@@ -2981,9 +2982,9 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2981
2982
|
let e = new AbortController(), r = !0;
|
|
2982
2983
|
return g(!0), y(null), (async () => {
|
|
2983
2984
|
let i = U.includes("?X-Amz-"), a = null, o = null;
|
|
2984
|
-
if (!a && !i && (a = await
|
|
2985
|
+
if (!a && !i && (a = await Ln(U, e.signal)), !a && !i) try {
|
|
2985
2986
|
let n = await t(U);
|
|
2986
|
-
n && (a = await
|
|
2987
|
+
n && (a = await Ln(n, e.signal) || await Rn(n, void 0, e.signal));
|
|
2987
2988
|
} catch (e) {
|
|
2988
2989
|
console.warn("[attachment] signPreviewUrl failed:", e);
|
|
2989
2990
|
}
|
|
@@ -2995,7 +2996,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2995
2996
|
n[t] = e;
|
|
2996
2997
|
});
|
|
2997
2998
|
try {
|
|
2998
|
-
a = await
|
|
2999
|
+
a = await Rn(U, n, e.signal);
|
|
2999
3000
|
} catch (e) {
|
|
3000
3001
|
console.warn("[attachment] signed headers XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
3001
3002
|
}
|
|
@@ -3004,7 +3005,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3004
3005
|
console.warn("[attachment] signPreviewUrlHeaders failed:", e);
|
|
3005
3006
|
}
|
|
3006
3007
|
if (!a) try {
|
|
3007
|
-
a = await
|
|
3008
|
+
a = await Rn(U, i ? void 0 : { "X-Requested-With": "XMLHttpRequest" }, e.signal);
|
|
3008
3009
|
} catch (e) {
|
|
3009
3010
|
console.warn("[attachment] plain XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
3010
3011
|
}
|
|
@@ -3033,7 +3034,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3033
3034
|
let e = window.setTimeout(() => A(null), 2400);
|
|
3034
3035
|
return () => window.clearTimeout(e);
|
|
3035
3036
|
}, [k]);
|
|
3036
|
-
let
|
|
3037
|
+
let J = b(async () => {
|
|
3037
3038
|
E(!0), A("loading");
|
|
3038
3039
|
try {
|
|
3039
3040
|
if (p) {
|
|
@@ -3066,7 +3067,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3066
3067
|
W,
|
|
3067
3068
|
p
|
|
3068
3069
|
]);
|
|
3069
|
-
return /* @__PURE__ */ O(
|
|
3070
|
+
return /* @__PURE__ */ O(P, {
|
|
3070
3071
|
ref: j,
|
|
3071
3072
|
as: "div",
|
|
3072
3073
|
className: `attachment-embed group/att ${i ? "is-selected" : ""}`,
|
|
@@ -3083,7 +3084,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3083
3084
|
className: "att-info",
|
|
3084
3085
|
children: [/* @__PURE__ */ D("span", {
|
|
3085
3086
|
className: "att-icon",
|
|
3086
|
-
children:
|
|
3087
|
+
children: K ? /* @__PURE__ */ O("svg", {
|
|
3087
3088
|
width: "22",
|
|
3088
3089
|
height: "22",
|
|
3089
3090
|
viewBox: "0 0 24 24",
|
|
@@ -3099,15 +3100,15 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3099
3100
|
/* @__PURE__ */ D("path", { d: "M12 9v4" }),
|
|
3100
3101
|
/* @__PURE__ */ D("path", { d: "M12 17h.01" })
|
|
3101
3102
|
]
|
|
3102
|
-
}) :
|
|
3103
|
+
}) : Mn(W)
|
|
3103
3104
|
}), /* @__PURE__ */ O("div", {
|
|
3104
3105
|
className: "att-meta",
|
|
3105
3106
|
children: [/* @__PURE__ */ D("span", {
|
|
3106
3107
|
className: "att-name",
|
|
3107
3108
|
children: W
|
|
3108
|
-
}),
|
|
3109
|
+
}), se > 0 && /* @__PURE__ */ D("span", {
|
|
3109
3110
|
className: "att-size",
|
|
3110
|
-
children:
|
|
3111
|
+
children: jn(se)
|
|
3111
3112
|
})]
|
|
3112
3113
|
})]
|
|
3113
3114
|
}), /* @__PURE__ */ O("div", {
|
|
@@ -3160,7 +3161,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3160
3161
|
}), /* @__PURE__ */ O("div", {
|
|
3161
3162
|
className: "att-actions",
|
|
3162
3163
|
children: [
|
|
3163
|
-
U &&
|
|
3164
|
+
U && Pn(W) && /* @__PURE__ */ D("button", {
|
|
3164
3165
|
type: "button",
|
|
3165
3166
|
className: "att-btn",
|
|
3166
3167
|
onMouseDown: (e) => {
|
|
@@ -3190,8 +3191,8 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3190
3191
|
/* @__PURE__ */ D("button", {
|
|
3191
3192
|
type: "button",
|
|
3192
3193
|
className: "att-btn",
|
|
3193
|
-
onClick:
|
|
3194
|
-
disabled: S ||
|
|
3194
|
+
onClick: J,
|
|
3195
|
+
disabled: S || K,
|
|
3195
3196
|
title: S ? "正在准备下载" : f("editor.attachment.download"),
|
|
3196
3197
|
"aria-label": S ? "正在准备下载" : f("editor.attachment.download"),
|
|
3197
3198
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -3213,7 +3214,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3213
3214
|
type: "button",
|
|
3214
3215
|
className: "att-btn att-btn--del",
|
|
3215
3216
|
onClick: () => {
|
|
3216
|
-
!o ||
|
|
3217
|
+
!o || vn() || ($(!0), L(!0));
|
|
3217
3218
|
},
|
|
3218
3219
|
title: f("editor.attachment.delete"),
|
|
3219
3220
|
"aria-label": f("editor.attachment.delete"),
|
|
@@ -3245,7 +3246,7 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3245
3246
|
background: "#fff"
|
|
3246
3247
|
},
|
|
3247
3248
|
children: [/* @__PURE__ */ D("div", {
|
|
3248
|
-
ref:
|
|
3249
|
+
ref: I,
|
|
3249
3250
|
className: "att-preview-scroll",
|
|
3250
3251
|
style: {
|
|
3251
3252
|
height: "100%",
|
|
@@ -3269,14 +3270,14 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3269
3270
|
style: { background: "#fff" },
|
|
3270
3271
|
children: f("editor.attachment.loadingPreview")
|
|
3271
3272
|
}),
|
|
3272
|
-
children: u || p || U ? V ? /* @__PURE__ */ D(
|
|
3273
|
+
children: u || p || U ? V ? /* @__PURE__ */ D(En, {
|
|
3273
3274
|
buffer: u || void 0,
|
|
3274
3275
|
url: p || U,
|
|
3275
3276
|
name: W,
|
|
3276
3277
|
filename: W,
|
|
3277
|
-
type:
|
|
3278
|
-
size:
|
|
3279
|
-
options:
|
|
3278
|
+
type: G,
|
|
3279
|
+
size: se || u?.byteLength || 0,
|
|
3280
|
+
options: ce
|
|
3280
3281
|
}, `${U}-${re}`) : /* @__PURE__ */ D("div", {
|
|
3281
3282
|
className: "flex h-full items-center justify-center text-sm text-default-400",
|
|
3282
3283
|
children: "正在加载预览引擎..."
|
|
@@ -3381,24 +3382,24 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3381
3382
|
})]
|
|
3382
3383
|
})]
|
|
3383
3384
|
})]
|
|
3384
|
-
}), /* @__PURE__ */ D(
|
|
3385
|
-
open:
|
|
3385
|
+
}), /* @__PURE__ */ D(Cn, {
|
|
3386
|
+
open: ne,
|
|
3386
3387
|
title: "确认删除附件",
|
|
3387
|
-
message:
|
|
3388
|
+
message: K ? "此操作将删除该附件节点,不可撤销。" : `此操作将同时删除对象存储中的文件(${W}),不可撤销。`,
|
|
3388
3389
|
onCancel: () => {
|
|
3389
|
-
$(!1),
|
|
3390
|
+
$(!1), L(!1);
|
|
3390
3391
|
},
|
|
3391
3392
|
onConfirm: async () => {
|
|
3392
3393
|
try {
|
|
3393
3394
|
if (a) {
|
|
3394
3395
|
let e = R.current, t = e?.from ?? a.state.selection.from, n = e?.to ?? a.state.selection.to, r = [];
|
|
3395
3396
|
a.state.doc.nodesBetween(t, n, (e) => {
|
|
3396
|
-
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(
|
|
3397
|
+
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(Kt(e.attrs.src));
|
|
3397
3398
|
}), await Promise.all(r), $(!1), await new Promise((e) => setTimeout(e, 300)), a.chain().focus().setTextSelection({
|
|
3398
3399
|
from: t,
|
|
3399
3400
|
to: n
|
|
3400
3401
|
}).deleteSelection().run();
|
|
3401
|
-
} else await
|
|
3402
|
+
} else await Kt(U), $(!1), await new Promise((e) => setTimeout(e, 300)), r();
|
|
3402
3403
|
} catch {
|
|
3403
3404
|
$(!1);
|
|
3404
3405
|
}
|
|
@@ -3408,13 +3409,13 @@ function Ln({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3408
3409
|
}
|
|
3409
3410
|
//#endregion
|
|
3410
3411
|
//#region src/editor/embeds/attachment.ts
|
|
3411
|
-
var
|
|
3412
|
+
var Bn = ie.create({
|
|
3412
3413
|
name: "attachmentEmbed",
|
|
3413
3414
|
group: "block",
|
|
3414
3415
|
atom: !0,
|
|
3415
3416
|
inline: !1,
|
|
3416
3417
|
addNodeView() {
|
|
3417
|
-
return
|
|
3418
|
+
return F(zn);
|
|
3418
3419
|
},
|
|
3419
3420
|
addAttributes() {
|
|
3420
3421
|
return {
|
|
@@ -3463,7 +3464,7 @@ var Rn = re.create({
|
|
|
3463
3464
|
});
|
|
3464
3465
|
//#endregion
|
|
3465
3466
|
//#region src/editor/embeds/audio-view.tsx
|
|
3466
|
-
function
|
|
3467
|
+
function Vn({ node: e, deleteNode: t, editor: r }) {
|
|
3467
3468
|
let i = e.attrs.src || "", a = e.attrs.name || i.split("/").pop()?.split("?")[0] || "audio", [o, s] = T(!1), c = r?.isEditable ?? !0;
|
|
3468
3469
|
x(() => () => {
|
|
3469
3470
|
i.startsWith("blob:") && URL.revokeObjectURL(i);
|
|
@@ -3495,7 +3496,7 @@ function zn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3495
3496
|
})(), () => {
|
|
3496
3497
|
e = !0, m.current &&= (URL.revokeObjectURL(m.current), null);
|
|
3497
3498
|
};
|
|
3498
|
-
}, [i]), /* @__PURE__ */ O(
|
|
3499
|
+
}, [i]), /* @__PURE__ */ O(P, {
|
|
3499
3500
|
as: "div",
|
|
3500
3501
|
className: "audio-embed group/audio",
|
|
3501
3502
|
style: { margin: "1rem 0" },
|
|
@@ -3529,7 +3530,7 @@ function zn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3529
3530
|
type: "button",
|
|
3530
3531
|
className: "audio-embed-btn audio-embed-btn--del",
|
|
3531
3532
|
onClick: () => {
|
|
3532
|
-
|
|
3533
|
+
vn() || ($(!0), s(!0));
|
|
3533
3534
|
},
|
|
3534
3535
|
title: "删除",
|
|
3535
3536
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -3575,7 +3576,7 @@ function zn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3575
3576
|
}), "音频文件缺失"]
|
|
3576
3577
|
})
|
|
3577
3578
|
})]
|
|
3578
|
-
}), /* @__PURE__ */ D(
|
|
3579
|
+
}), /* @__PURE__ */ D(Cn, {
|
|
3579
3580
|
open: o,
|
|
3580
3581
|
title: "确认删除音频",
|
|
3581
3582
|
message: `此操作将同时删除对象存储中的文件(${a}),不可撤销。`,
|
|
@@ -3584,7 +3585,7 @@ function zn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3584
3585
|
},
|
|
3585
3586
|
onConfirm: async () => {
|
|
3586
3587
|
try {
|
|
3587
|
-
await
|
|
3588
|
+
await Kt(i);
|
|
3588
3589
|
} catch {}
|
|
3589
3590
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3590
3591
|
}
|
|
@@ -3593,25 +3594,25 @@ function zn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3593
3594
|
}
|
|
3594
3595
|
//#endregion
|
|
3595
3596
|
//#region src/editor/embeds/audio.ts
|
|
3596
|
-
function
|
|
3597
|
+
function Hn(e) {
|
|
3597
3598
|
return /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|$)/i.test(e) || /\/.*\.(mp3|wav|ogg|flac)/i.test(e);
|
|
3598
3599
|
}
|
|
3599
|
-
var
|
|
3600
|
+
var Un = ie.create({
|
|
3600
3601
|
name: "audioEmbed",
|
|
3601
3602
|
group: "block",
|
|
3602
3603
|
atom: !0,
|
|
3603
3604
|
inline: !1,
|
|
3604
3605
|
addNodeView() {
|
|
3605
|
-
return
|
|
3606
|
+
return F(Vn);
|
|
3606
3607
|
},
|
|
3607
3608
|
addProseMirrorPlugins() {
|
|
3608
|
-
return [new
|
|
3609
|
+
return [new V({ props: { handlePaste(e, t) {
|
|
3609
3610
|
let n = t.clipboardData?.getData("text/plain");
|
|
3610
3611
|
if (!n) return !1;
|
|
3611
3612
|
let r = n.split(/\r?\n/);
|
|
3612
3613
|
for (let n of r) {
|
|
3613
3614
|
let r = n.trim();
|
|
3614
|
-
if (!r || r.includes(" ") || !
|
|
3615
|
+
if (!r || r.includes(" ") || !Hn(r)) continue;
|
|
3615
3616
|
t.preventDefault();
|
|
3616
3617
|
let i = e.state.schema.nodes.audioEmbed.create({ src: r });
|
|
3617
3618
|
return e.dispatch(e.state.tr.replaceSelectionWith(i)), !0;
|
|
@@ -3658,17 +3659,17 @@ var Vn = re.create({
|
|
|
3658
3659
|
});
|
|
3659
3660
|
//#endregion
|
|
3660
3661
|
//#region src/editor/embeds/video-view.tsx
|
|
3661
|
-
function
|
|
3662
|
+
function Wn(e) {
|
|
3662
3663
|
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";
|
|
3663
3664
|
}
|
|
3664
|
-
function
|
|
3665
|
+
function Gn(e) {
|
|
3665
3666
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
3666
3667
|
if (t) return t[0];
|
|
3667
3668
|
let n = e.match(/av(\d+)/i);
|
|
3668
3669
|
return n ? n[0] : e;
|
|
3669
3670
|
}
|
|
3670
|
-
function
|
|
3671
|
-
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ?
|
|
3671
|
+
function Kn({ node: e, deleteNode: t, editor: n }) {
|
|
3672
|
+
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ? Wn(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(Cn, {
|
|
3672
3673
|
open: o,
|
|
3673
3674
|
title: "确认删除视频",
|
|
3674
3675
|
message: "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
@@ -3677,7 +3678,7 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3677
3678
|
},
|
|
3678
3679
|
onConfirm: async () => {
|
|
3679
3680
|
try {
|
|
3680
|
-
await
|
|
3681
|
+
await Kt(r);
|
|
3681
3682
|
} catch {}
|
|
3682
3683
|
$(!1), await new Promise((e) => setTimeout(e, 300)), t();
|
|
3683
3684
|
}
|
|
@@ -3691,7 +3692,7 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3691
3692
|
e && (e.style.position === "fixed" ? A() : (e.style.position = "fixed", e.style.inset = "0", e.style.zIndex = "99999", e.style.borderRadius = "0", document.body.style.overflow = "hidden"));
|
|
3692
3693
|
}, [A]), N = b(() => {
|
|
3693
3694
|
k.current = window.scrollY, S.current?.requestFullscreen?.();
|
|
3694
|
-
}, []),
|
|
3695
|
+
}, []), ee = b(() => {
|
|
3695
3696
|
let e = v.current?.closest(".video-embed--direct") || v.current;
|
|
3696
3697
|
e && (k.current = window.scrollY, e.requestFullscreen?.());
|
|
3697
3698
|
}, []);
|
|
@@ -3780,8 +3781,8 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3780
3781
|
}, [a, h]), x(() => {
|
|
3781
3782
|
u && (_.current?.destroy(), _.current = null);
|
|
3782
3783
|
}, [u]), a === "bilibili") {
|
|
3783
|
-
let e =
|
|
3784
|
-
return /* @__PURE__ */ O(
|
|
3784
|
+
let e = Gn(r);
|
|
3785
|
+
return /* @__PURE__ */ O(P, {
|
|
3785
3786
|
as: "div",
|
|
3786
3787
|
className: "video-embed video-embed--bilibili group/video",
|
|
3787
3788
|
style: { margin: "1rem 0" },
|
|
@@ -3857,7 +3858,7 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3857
3858
|
className: "video-fs-btn video-fs-btn--del",
|
|
3858
3859
|
title: "删除",
|
|
3859
3860
|
onClick: () => {
|
|
3860
|
-
|
|
3861
|
+
vn() || ($(!0), s(!0));
|
|
3861
3862
|
},
|
|
3862
3863
|
children: /* @__PURE__ */ D("svg", {
|
|
3863
3864
|
width: "12",
|
|
@@ -3899,7 +3900,7 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3899
3900
|
}), m]
|
|
3900
3901
|
});
|
|
3901
3902
|
}
|
|
3902
|
-
return a === "xiaohongshu" ? /* @__PURE__ */ O(
|
|
3903
|
+
return a === "xiaohongshu" ? /* @__PURE__ */ O(P, {
|
|
3903
3904
|
as: "div",
|
|
3904
3905
|
className: "video-embed video-embed--xiaohongshu",
|
|
3905
3906
|
style: {
|
|
@@ -3945,7 +3946,7 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3945
3946
|
},
|
|
3946
3947
|
children: "在小红书中打开 →"
|
|
3947
3948
|
})] })]
|
|
3948
|
-
}) : /* @__PURE__ */ O(
|
|
3949
|
+
}) : /* @__PURE__ */ O(P, {
|
|
3949
3950
|
as: "div",
|
|
3950
3951
|
className: "video-embed video-embed--direct group/video",
|
|
3951
3952
|
style: {
|
|
@@ -3964,7 +3965,7 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3964
3965
|
className: "video-fs-btn video-fs-btn--del",
|
|
3965
3966
|
title: "删除",
|
|
3966
3967
|
onClick: () => {
|
|
3967
|
-
|
|
3968
|
+
vn() || ($(!0), s(!0));
|
|
3968
3969
|
},
|
|
3969
3970
|
children: /* @__PURE__ */ D("svg", {
|
|
3970
3971
|
width: "12",
|
|
@@ -3983,7 +3984,7 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3983
3984
|
type: "button",
|
|
3984
3985
|
className: "video-fs-btn",
|
|
3985
3986
|
title: "全屏",
|
|
3986
|
-
onClick:
|
|
3987
|
+
onClick: ee,
|
|
3987
3988
|
children: /* @__PURE__ */ D("svg", {
|
|
3988
3989
|
width: "12",
|
|
3989
3990
|
height: "12",
|
|
@@ -4121,33 +4122,33 @@ function Wn({ node: e, deleteNode: t, editor: n }) {
|
|
|
4121
4122
|
}
|
|
4122
4123
|
//#endregion
|
|
4123
4124
|
//#region src/editor/embeds/video.ts
|
|
4124
|
-
function
|
|
4125
|
+
function qn(e) {
|
|
4125
4126
|
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";
|
|
4126
4127
|
}
|
|
4127
|
-
function
|
|
4128
|
+
function Jn(e) {
|
|
4128
4129
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
4129
4130
|
if (t) return t[0];
|
|
4130
4131
|
let n = e.match(/av(\d+)/i);
|
|
4131
4132
|
return n ? n[0] : e;
|
|
4132
4133
|
}
|
|
4133
|
-
function
|
|
4134
|
+
function Yn(e) {
|
|
4134
4135
|
let t = e.match(/explore\/([a-zA-Z0-9]+)/);
|
|
4135
4136
|
return t ? t[1] : e;
|
|
4136
4137
|
}
|
|
4137
|
-
var
|
|
4138
|
+
var Xn = ie.create({
|
|
4138
4139
|
name: "videoEmbed",
|
|
4139
4140
|
group: "block",
|
|
4140
4141
|
atom: !0,
|
|
4141
4142
|
inline: !1,
|
|
4142
4143
|
addNodeView() {
|
|
4143
|
-
return
|
|
4144
|
+
return F(Kn);
|
|
4144
4145
|
},
|
|
4145
4146
|
addProseMirrorPlugins() {
|
|
4146
|
-
return [new
|
|
4147
|
+
return [new V({ props: {
|
|
4147
4148
|
handleKeyDown(e, t) {
|
|
4148
4149
|
if (t.key !== " ") return !1;
|
|
4149
4150
|
let n = e.state.selection;
|
|
4150
|
-
if (n instanceof
|
|
4151
|
+
if (n instanceof B && n.node.type.name === "videoEmbed") {
|
|
4151
4152
|
t.preventDefault();
|
|
4152
4153
|
let r = e.nodeDOM(n.from);
|
|
4153
4154
|
if (r) {
|
|
@@ -4165,7 +4166,7 @@ var Jn = re.create({
|
|
|
4165
4166
|
for (let n of r) {
|
|
4166
4167
|
let r = n.trim();
|
|
4167
4168
|
if (!r || r.includes(" ")) continue;
|
|
4168
|
-
let i =
|
|
4169
|
+
let i = qn(r);
|
|
4169
4170
|
if (i === "unknown") continue;
|
|
4170
4171
|
t.preventDefault();
|
|
4171
4172
|
let a = e.state.schema.nodes.videoEmbed.create({
|
|
@@ -4197,7 +4198,7 @@ var Jn = re.create({
|
|
|
4197
4198
|
let t = e, n = t.getAttribute("src") || t.getAttribute("data-src") || "";
|
|
4198
4199
|
return {
|
|
4199
4200
|
src: n,
|
|
4200
|
-
source:
|
|
4201
|
+
source: qn(n)
|
|
4201
4202
|
};
|
|
4202
4203
|
}
|
|
4203
4204
|
},
|
|
@@ -4206,9 +4207,9 @@ var Jn = re.create({
|
|
|
4206
4207
|
];
|
|
4207
4208
|
},
|
|
4208
4209
|
renderHTML({ HTMLAttributes: e }) {
|
|
4209
|
-
let t = e.src || "", n =
|
|
4210
|
+
let t = e.src || "", n = qn(t);
|
|
4210
4211
|
if (n === "bilibili") {
|
|
4211
|
-
let e =
|
|
4212
|
+
let e = Jn(t);
|
|
4212
4213
|
return [
|
|
4213
4214
|
"div",
|
|
4214
4215
|
{
|
|
@@ -4229,7 +4230,7 @@ var Jn = re.create({
|
|
|
4229
4230
|
}]
|
|
4230
4231
|
];
|
|
4231
4232
|
}
|
|
4232
|
-
if (n === "xiaohongshu") return
|
|
4233
|
+
if (n === "xiaohongshu") return Yn(t), [
|
|
4233
4234
|
"div",
|
|
4234
4235
|
{
|
|
4235
4236
|
"data-video-embed": "xiaohongshu",
|
|
@@ -4281,7 +4282,7 @@ var Jn = re.create({
|
|
|
4281
4282
|
},
|
|
4282
4283
|
addCommands() {
|
|
4283
4284
|
return { insertVideo: (e) => ({ chain: t }) => {
|
|
4284
|
-
let n =
|
|
4285
|
+
let n = qn(e.src);
|
|
4285
4286
|
return t().insertContent({
|
|
4286
4287
|
type: this.name,
|
|
4287
4288
|
attrs: {
|
|
@@ -4291,13 +4292,20 @@ var Jn = re.create({
|
|
|
4291
4292
|
}).focus().run();
|
|
4292
4293
|
} };
|
|
4293
4294
|
}
|
|
4294
|
-
}),
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4295
|
+
}), Zn = null, Qn = {
|
|
4296
|
+
bg: "var(--color-background, #ffffff)",
|
|
4297
|
+
fg: "var(--color-foreground, #11181c)",
|
|
4298
|
+
accent: "var(--color-qingwu-600, #0891b2)",
|
|
4299
|
+
transparent: !0,
|
|
4300
|
+
font: "Inter, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', system-ui, sans-serif",
|
|
4301
|
+
padding: 32
|
|
4302
|
+
}, $n = .25, er = 4, tr = .25;
|
|
4303
|
+
async function nr(e, t) {
|
|
4304
|
+
Zn ||= await import("beautiful-mermaid");
|
|
4305
|
+
let n = Zn.renderMermaidSVG;
|
|
4306
|
+
return n(e, t);
|
|
4307
|
+
}
|
|
4308
|
+
var rr = [
|
|
4301
4309
|
{
|
|
4302
4310
|
value: "javascript",
|
|
4303
4311
|
label: "JavaScript",
|
|
@@ -4458,7 +4466,7 @@ var Zn = [
|
|
|
4458
4466
|
label: "Plain Text",
|
|
4459
4467
|
color: "#6b7280"
|
|
4460
4468
|
}
|
|
4461
|
-
],
|
|
4469
|
+
], ir = {
|
|
4462
4470
|
javascript: "js",
|
|
4463
4471
|
typescript: "ts",
|
|
4464
4472
|
python: "py",
|
|
@@ -4484,7 +4492,7 @@ var Zn = [
|
|
|
4484
4492
|
txt: "txt",
|
|
4485
4493
|
vue: "vue",
|
|
4486
4494
|
react: "jsx"
|
|
4487
|
-
},
|
|
4495
|
+
}, ar = {
|
|
4488
4496
|
js: "javascript",
|
|
4489
4497
|
ts: "typescript",
|
|
4490
4498
|
py: "python",
|
|
@@ -4500,12 +4508,51 @@ var Zn = [
|
|
|
4500
4508
|
jsx: "javascript",
|
|
4501
4509
|
tsx: "typescript"
|
|
4502
4510
|
};
|
|
4503
|
-
function
|
|
4511
|
+
function or({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i, selected: a }) {
|
|
4504
4512
|
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({
|
|
4505
4513
|
top: 0,
|
|
4506
4514
|
left: 0,
|
|
4507
4515
|
width: 210
|
|
4508
|
-
}), [k, A] = T(""), [j, M] = T(!1), [N,
|
|
4516
|
+
}), [k, A] = T(""), [j, M] = T(!1), [N, ee] = T(null), [P, F] = T(null), [I, te] = T(!1), [ne, R] = T(!1), [re, ie] = T(1), [z, B] = T({
|
|
4517
|
+
x: 0,
|
|
4518
|
+
y: 0
|
|
4519
|
+
}), [V, H] = T(!1), ae = w(null), oe = w(null), U = w(null), W = w(null), se = w(null), G = w(null), K = w(null), ce = e.attrs.language || "", q = rr.find((e) => e.value === (ar[ce] ?? ce)), le = ce === "mermaid", ue = (e) => Math.min(er, Math.max($n, e)), de = (e) => ie((t) => Math.round(ue(t + e) * 100) / 100), fe = () => {
|
|
4520
|
+
ie(1), B({
|
|
4521
|
+
x: 0,
|
|
4522
|
+
y: 0
|
|
4523
|
+
});
|
|
4524
|
+
}, J = () => {
|
|
4525
|
+
fe(), R(!0);
|
|
4526
|
+
};
|
|
4527
|
+
x(() => {
|
|
4528
|
+
N || R(!1);
|
|
4529
|
+
}, [N]), x(() => {
|
|
4530
|
+
if (!ne) return;
|
|
4531
|
+
let e = document.body.style.overflow;
|
|
4532
|
+
document.body.style.overflow = "hidden";
|
|
4533
|
+
let t = (e) => {
|
|
4534
|
+
e.key === "Escape" && R(!1);
|
|
4535
|
+
};
|
|
4536
|
+
return window.addEventListener("keydown", t), () => {
|
|
4537
|
+
document.body.style.overflow = e, window.removeEventListener("keydown", t);
|
|
4538
|
+
};
|
|
4539
|
+
}, [ne]);
|
|
4540
|
+
let pe = (e) => {
|
|
4541
|
+
e.button === 0 && (e.currentTarget.setPointerCapture(e.pointerId), ae.current = {
|
|
4542
|
+
x: e.clientX,
|
|
4543
|
+
y: e.clientY,
|
|
4544
|
+
panX: z.x,
|
|
4545
|
+
panY: z.y
|
|
4546
|
+
}, H(!0));
|
|
4547
|
+
}, me = (e) => {
|
|
4548
|
+
let t = ae.current;
|
|
4549
|
+
t && B({
|
|
4550
|
+
x: t.panX + e.clientX - t.x,
|
|
4551
|
+
y: t.panY + e.clientY - t.y
|
|
4552
|
+
});
|
|
4553
|
+
}, he = () => {
|
|
4554
|
+
ae.current = null, H(!1);
|
|
4555
|
+
}, ge = b(() => {
|
|
4509
4556
|
if (!n || typeof r != "function") return null;
|
|
4510
4557
|
let t = r();
|
|
4511
4558
|
return typeof t == "number" ? {
|
|
@@ -4516,19 +4563,19 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4516
4563
|
n,
|
|
4517
4564
|
r,
|
|
4518
4565
|
e.nodeSize
|
|
4519
|
-
]),
|
|
4520
|
-
o && (
|
|
4521
|
-
}, [
|
|
4566
|
+
]), _e = b(() => {
|
|
4567
|
+
o && (vn() || (K.current = ge(), window.getSelection()?.removeAllRanges(), $(!0), M(!0)));
|
|
4568
|
+
}, [ge, o]), ve = C(() => {
|
|
4522
4569
|
let e = k.trim().toLowerCase();
|
|
4523
|
-
return e ?
|
|
4570
|
+
return e ? rr.filter((t) => t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e)) : rr;
|
|
4524
4571
|
}, [k]);
|
|
4525
4572
|
x(() => {
|
|
4526
|
-
(
|
|
4573
|
+
(G.current?.closest(".code-block-node-view"))?.classList.toggle("code-block-node-view--collapsed", u);
|
|
4527
4574
|
}, [u]);
|
|
4528
|
-
let
|
|
4529
|
-
let e =
|
|
4575
|
+
let ye = b(() => {
|
|
4576
|
+
let e = W.current;
|
|
4530
4577
|
if (!e) return;
|
|
4531
|
-
let t = e.getBoundingClientRect(), n = Math.min(t.left, window.innerWidth - 210 - 8), r = window.innerHeight - t.bottom - 12, i = t.top - 12, a =
|
|
4578
|
+
let t = e.getBoundingClientRect(), n = Math.min(t.left, window.innerWidth - 210 - 8), r = window.innerHeight - t.bottom - 12, i = t.top - 12, a = rr.length * 31 + 8, o = r - 52, s = i - 52;
|
|
4532
4579
|
o < 220 && s > o ? (g(!0), v(Math.max(120, Math.min(a, s))), S({
|
|
4533
4580
|
top: t.top,
|
|
4534
4581
|
left: n,
|
|
@@ -4541,16 +4588,16 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4541
4588
|
}, []);
|
|
4542
4589
|
x(() => {
|
|
4543
4590
|
if (!f) return;
|
|
4544
|
-
A(""),
|
|
4545
|
-
let e = setTimeout(() =>
|
|
4546
|
-
return window.addEventListener("resize",
|
|
4547
|
-
clearTimeout(e), window.removeEventListener("resize",
|
|
4591
|
+
A(""), ye();
|
|
4592
|
+
let e = setTimeout(() => se.current?.focus(), 50);
|
|
4593
|
+
return window.addEventListener("resize", ye), window.addEventListener("scroll", ye, !0), () => {
|
|
4594
|
+
clearTimeout(e), window.removeEventListener("resize", ye), window.removeEventListener("scroll", ye, !0);
|
|
4548
4595
|
};
|
|
4549
|
-
}, [f,
|
|
4596
|
+
}, [f, ye]), x(() => {
|
|
4550
4597
|
if (!f) return;
|
|
4551
4598
|
let e = (e) => {
|
|
4552
4599
|
let t = e.target;
|
|
4553
|
-
t && (
|
|
4600
|
+
t && (W.current?.contains(t) || U.current?.contains(t) || m(!1));
|
|
4554
4601
|
};
|
|
4555
4602
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
4556
4603
|
}, [f]), x(() => {
|
|
@@ -4561,12 +4608,12 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4561
4608
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
4562
4609
|
}, [f]), x(() => {
|
|
4563
4610
|
let e = (e) => {
|
|
4564
|
-
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !a ||
|
|
4611
|
+
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !a || vn()) return;
|
|
4565
4612
|
let t = n?.view?.dom, r = e.target;
|
|
4566
4613
|
if (n?.isFocused && r instanceof Node && t?.contains(r)) {
|
|
4567
4614
|
if (e.preventDefault(), e.stopPropagation(), n) {
|
|
4568
4615
|
let { from: e, to: t } = n.state.selection;
|
|
4569
|
-
|
|
4616
|
+
K.current = {
|
|
4570
4617
|
from: e,
|
|
4571
4618
|
to: t
|
|
4572
4619
|
};
|
|
@@ -4580,9 +4627,9 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4580
4627
|
n,
|
|
4581
4628
|
o
|
|
4582
4629
|
]);
|
|
4583
|
-
let
|
|
4630
|
+
let be = b((e) => {
|
|
4584
4631
|
t({ language: e || null }), m(!1);
|
|
4585
|
-
}, [t]),
|
|
4632
|
+
}, [t]), xe = b(() => {
|
|
4586
4633
|
if (o) {
|
|
4587
4634
|
if (n && r) {
|
|
4588
4635
|
let e = r();
|
|
@@ -4594,7 +4641,7 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4594
4641
|
n,
|
|
4595
4642
|
r,
|
|
4596
4643
|
o
|
|
4597
|
-
]),
|
|
4644
|
+
]), Se = b(() => {
|
|
4598
4645
|
let t = e.textContent, n = (e) => {
|
|
4599
4646
|
let t = document.createElement("textarea");
|
|
4600
4647
|
t.value = e, t.style.position = "fixed", t.style.opacity = "0", document.body.appendChild(t), t.select();
|
|
@@ -4604,35 +4651,35 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4604
4651
|
document.body.removeChild(t);
|
|
4605
4652
|
};
|
|
4606
4653
|
navigator.clipboard?.writeText ? navigator.clipboard.writeText(t).catch(() => n(t)) : n(t), l(!0), setTimeout(() => l(!1), 1500);
|
|
4607
|
-
}, [e.textContent]),
|
|
4608
|
-
let t =
|
|
4654
|
+
}, [e.textContent]), Ce = b(() => {
|
|
4655
|
+
let t = ir[ce] || "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");
|
|
4609
4656
|
a.href = i, a.download = n, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
4610
|
-
}, [e.textContent,
|
|
4611
|
-
if (N ||
|
|
4612
|
-
|
|
4657
|
+
}, [e.textContent, ce]), we = b(async () => {
|
|
4658
|
+
if (N || I) {
|
|
4659
|
+
ee(null), F(null), te(!1);
|
|
4613
4660
|
return;
|
|
4614
4661
|
}
|
|
4615
|
-
|
|
4662
|
+
te(!0), F(null), ee(null);
|
|
4616
4663
|
try {
|
|
4617
4664
|
let t = (e.textContent || "").trim();
|
|
4618
4665
|
if (!t) {
|
|
4619
|
-
|
|
4666
|
+
F("代码块内容为空");
|
|
4620
4667
|
return;
|
|
4621
4668
|
}
|
|
4622
|
-
let n = p(await
|
|
4623
|
-
|
|
4669
|
+
let n = p(await nr(t, Qn));
|
|
4670
|
+
ee(n);
|
|
4624
4671
|
} catch (e) {
|
|
4625
|
-
|
|
4672
|
+
F(e instanceof Error ? e.message : "Mermaid 渲染失败");
|
|
4626
4673
|
} finally {
|
|
4627
|
-
|
|
4674
|
+
te(!1);
|
|
4628
4675
|
}
|
|
4629
4676
|
}, [
|
|
4630
4677
|
e.textContent,
|
|
4631
4678
|
N,
|
|
4632
|
-
|
|
4633
|
-
]),
|
|
4634
|
-
className: `${
|
|
4635
|
-
style: { color:
|
|
4679
|
+
I
|
|
4680
|
+
]), Te = /* @__PURE__ */ O(E, { children: [q ? q.deviconClass ? /* @__PURE__ */ D("i", {
|
|
4681
|
+
className: `${q.deviconClass} colored cb-lang-icon`,
|
|
4682
|
+
style: { color: q.color }
|
|
4636
4683
|
}) : /* @__PURE__ */ D("span", {
|
|
4637
4684
|
className: "cb-lang-icon cb-lang-icon--auto",
|
|
4638
4685
|
children: "Tx"
|
|
@@ -4641,10 +4688,10 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4641
4688
|
children: "?"
|
|
4642
4689
|
}), /* @__PURE__ */ D("span", {
|
|
4643
4690
|
className: "cb-lang-label",
|
|
4644
|
-
children:
|
|
4691
|
+
children: q?.label || "自动"
|
|
4645
4692
|
})] });
|
|
4646
4693
|
return /* @__PURE__ */ O("div", {
|
|
4647
|
-
ref:
|
|
4694
|
+
ref: G,
|
|
4648
4695
|
className: "cb-react-shell group/cb",
|
|
4649
4696
|
style: { display: "contents" },
|
|
4650
4697
|
children: [
|
|
@@ -4655,17 +4702,17 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4655
4702
|
children: [
|
|
4656
4703
|
/* @__PURE__ */ D("div", {
|
|
4657
4704
|
className: "cb-lang-wrap",
|
|
4658
|
-
ref:
|
|
4705
|
+
ref: oe,
|
|
4659
4706
|
contentEditable: !1,
|
|
4660
4707
|
children: s ? /* @__PURE__ */ D("span", {
|
|
4661
4708
|
className: "cb-lang-trigger cb-lang-trigger--static",
|
|
4662
|
-
children:
|
|
4709
|
+
children: Te
|
|
4663
4710
|
}) : /* @__PURE__ */ O("button", {
|
|
4664
|
-
ref:
|
|
4711
|
+
ref: W,
|
|
4665
4712
|
type: "button",
|
|
4666
4713
|
className: "cb-lang-trigger",
|
|
4667
4714
|
onClick: () => m(!f),
|
|
4668
|
-
children: [
|
|
4715
|
+
children: [Te, /* @__PURE__ */ D("svg", {
|
|
4669
4716
|
className: `cb-lang-chevron${f ? " cb-lang-chevron--open" : ""}`,
|
|
4670
4717
|
width: "10",
|
|
4671
4718
|
height: "10",
|
|
@@ -4687,7 +4734,7 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4687
4734
|
contentEditable: !1,
|
|
4688
4735
|
onClick: () => d(!1),
|
|
4689
4736
|
title: "展开代码块",
|
|
4690
|
-
children: [
|
|
4737
|
+
children: [Te, /* @__PURE__ */ D("svg", {
|
|
4691
4738
|
className: "cb-lang-chevron",
|
|
4692
4739
|
width: "12",
|
|
4693
4740
|
height: "12",
|
|
@@ -4702,8 +4749,8 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4702
4749
|
})
|
|
4703
4750
|
})]
|
|
4704
4751
|
}),
|
|
4705
|
-
o && f &&
|
|
4706
|
-
ref:
|
|
4752
|
+
o && f && L(/* @__PURE__ */ O("div", {
|
|
4753
|
+
ref: U,
|
|
4707
4754
|
className: `cb-lang-dropdown${h ? " cb-lang-dropdown--up" : ""}`,
|
|
4708
4755
|
style: {
|
|
4709
4756
|
position: "fixed",
|
|
@@ -4728,7 +4775,7 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4728
4775
|
d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
|
4729
4776
|
})
|
|
4730
4777
|
}), /* @__PURE__ */ D("input", {
|
|
4731
|
-
ref:
|
|
4778
|
+
ref: se,
|
|
4732
4779
|
className: "cb-lang-search",
|
|
4733
4780
|
type: "text",
|
|
4734
4781
|
placeholder: "搜索语言...",
|
|
@@ -4742,17 +4789,17 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4742
4789
|
children: [
|
|
4743
4790
|
/* @__PURE__ */ O("button", {
|
|
4744
4791
|
type: "button",
|
|
4745
|
-
className: `cb-lang-option${
|
|
4746
|
-
onClick: () =>
|
|
4792
|
+
className: `cb-lang-option${ce ? "" : " cb-lang-option--active"}`,
|
|
4793
|
+
onClick: () => be(""),
|
|
4747
4794
|
children: [/* @__PURE__ */ D("span", {
|
|
4748
4795
|
className: "cb-lang-icon cb-lang-icon--auto",
|
|
4749
4796
|
children: "?"
|
|
4750
4797
|
}), /* @__PURE__ */ D("span", { children: "自动检测" })]
|
|
4751
4798
|
}),
|
|
4752
|
-
|
|
4799
|
+
ve.map((e) => /* @__PURE__ */ O("button", {
|
|
4753
4800
|
type: "button",
|
|
4754
|
-
className: `cb-lang-option${
|
|
4755
|
-
onClick: () =>
|
|
4801
|
+
className: `cb-lang-option${ce === e.value ? " cb-lang-option--active" : ""}`,
|
|
4802
|
+
onClick: () => be(e.value),
|
|
4756
4803
|
children: [e.deviconClass ? /* @__PURE__ */ D("i", {
|
|
4757
4804
|
className: `${e.deviconClass} colored cb-lang-icon`,
|
|
4758
4805
|
style: { color: e.color }
|
|
@@ -4761,7 +4808,7 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4761
4808
|
children: "Tx"
|
|
4762
4809
|
}), /* @__PURE__ */ D("span", { children: e.label })]
|
|
4763
4810
|
}, e.value)),
|
|
4764
|
-
|
|
4811
|
+
ve.length === 0 && /* @__PURE__ */ D("div", {
|
|
4765
4812
|
className: "cb-lang-empty",
|
|
4766
4813
|
children: "无匹配语言"
|
|
4767
4814
|
})
|
|
@@ -4797,7 +4844,7 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4797
4844
|
/* @__PURE__ */ D("button", {
|
|
4798
4845
|
type: "button",
|
|
4799
4846
|
className: "cb-btn",
|
|
4800
|
-
onClick:
|
|
4847
|
+
onClick: Se,
|
|
4801
4848
|
contentEditable: !1,
|
|
4802
4849
|
title: "复制",
|
|
4803
4850
|
children: c ? /* @__PURE__ */ D("svg", {
|
|
@@ -4827,7 +4874,7 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4827
4874
|
/* @__PURE__ */ D("button", {
|
|
4828
4875
|
type: "button",
|
|
4829
4876
|
className: "cb-btn",
|
|
4830
|
-
onClick:
|
|
4877
|
+
onClick: Ce,
|
|
4831
4878
|
contentEditable: !1,
|
|
4832
4879
|
title: "下载",
|
|
4833
4880
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4846,7 +4893,7 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4846
4893
|
o && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("button", {
|
|
4847
4894
|
type: "button",
|
|
4848
4895
|
className: "cb-btn cb-btn--ai",
|
|
4849
|
-
onClick:
|
|
4896
|
+
onClick: xe,
|
|
4850
4897
|
contentEditable: !1,
|
|
4851
4898
|
title: "写作助手",
|
|
4852
4899
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4864,7 +4911,7 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4864
4911
|
}), /* @__PURE__ */ D("button", {
|
|
4865
4912
|
type: "button",
|
|
4866
4913
|
className: "cb-btn cb-btn--del",
|
|
4867
|
-
onClick:
|
|
4914
|
+
onClick: _e,
|
|
4868
4915
|
contentEditable: !1,
|
|
4869
4916
|
title: "删除代码块",
|
|
4870
4917
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -4880,13 +4927,13 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4880
4927
|
})
|
|
4881
4928
|
})
|
|
4882
4929
|
})] }),
|
|
4883
|
-
|
|
4930
|
+
le && /* @__PURE__ */ D("button", {
|
|
4884
4931
|
type: "button",
|
|
4885
4932
|
className: "cb-btn cb-btn--diagram",
|
|
4886
|
-
onClick:
|
|
4933
|
+
onClick: we,
|
|
4887
4934
|
contentEditable: !1,
|
|
4888
|
-
title: N ||
|
|
4889
|
-
disabled:
|
|
4935
|
+
title: N || I ? "取消渲染" : "渲染图表",
|
|
4936
|
+
disabled: I,
|
|
4890
4937
|
children: /* @__PURE__ */ D("svg", {
|
|
4891
4938
|
className: "cb-btn-icon",
|
|
4892
4939
|
fill: "none",
|
|
@@ -4904,28 +4951,121 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4904
4951
|
})
|
|
4905
4952
|
]
|
|
4906
4953
|
}),
|
|
4907
|
-
(N ||
|
|
4954
|
+
(N || P || I) && /* @__PURE__ */ O("div", {
|
|
4908
4955
|
className: "cb-diagram-output",
|
|
4909
4956
|
contentEditable: !1,
|
|
4910
4957
|
children: [
|
|
4911
|
-
|
|
4958
|
+
I && /* @__PURE__ */ D("div", {
|
|
4912
4959
|
className: "cb-diagram-loading",
|
|
4913
4960
|
children: "渲染图表中…"
|
|
4914
4961
|
}),
|
|
4915
|
-
|
|
4962
|
+
P && /* @__PURE__ */ O("div", {
|
|
4916
4963
|
className: "cb-diagram-error",
|
|
4917
4964
|
children: [/* @__PURE__ */ D("span", {
|
|
4918
4965
|
className: "cb-diagram-error-icon",
|
|
4919
4966
|
children: "!"
|
|
4920
|
-
}),
|
|
4967
|
+
}), P]
|
|
4921
4968
|
}),
|
|
4922
|
-
N && /* @__PURE__ */
|
|
4969
|
+
N && /* @__PURE__ */ O("div", {
|
|
4923
4970
|
className: "cb-diagram-svg",
|
|
4924
|
-
|
|
4971
|
+
role: "button",
|
|
4972
|
+
tabIndex: 0,
|
|
4973
|
+
title: "点击放大查看",
|
|
4974
|
+
onClick: J,
|
|
4975
|
+
onKeyDown: (e) => {
|
|
4976
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), J());
|
|
4977
|
+
},
|
|
4978
|
+
children: [/* @__PURE__ */ D("div", {
|
|
4979
|
+
className: "cb-diagram-svg-inner",
|
|
4980
|
+
dangerouslySetInnerHTML: { __html: N }
|
|
4981
|
+
}), /* @__PURE__ */ D("span", {
|
|
4982
|
+
className: "cb-diagram-zoom-hint",
|
|
4983
|
+
children: "点击放大"
|
|
4984
|
+
})]
|
|
4925
4985
|
})
|
|
4926
4986
|
]
|
|
4927
4987
|
}),
|
|
4928
|
-
/* @__PURE__ */
|
|
4988
|
+
ne && N && L(/* @__PURE__ */ O("div", {
|
|
4989
|
+
className: "fixed inset-0 z-[10002] flex flex-col bg-black/75 backdrop-blur-sm select-none",
|
|
4990
|
+
role: "dialog",
|
|
4991
|
+
"aria-modal": "true",
|
|
4992
|
+
"aria-label": "Mermaid 图表预览",
|
|
4993
|
+
children: [/* @__PURE__ */ O("div", {
|
|
4994
|
+
className: "flex items-center justify-between gap-3 px-4 py-3 text-white",
|
|
4995
|
+
children: [/* @__PURE__ */ D("span", {
|
|
4996
|
+
className: "text-sm font-medium",
|
|
4997
|
+
children: "Mermaid 图表"
|
|
4998
|
+
}), /* @__PURE__ */ O("div", {
|
|
4999
|
+
className: "flex items-center gap-1.5",
|
|
5000
|
+
children: [
|
|
5001
|
+
/* @__PURE__ */ D("button", {
|
|
5002
|
+
type: "button",
|
|
5003
|
+
className: "flex h-8 min-w-8 items-center justify-center rounded-lg bg-white/10 px-2 text-base text-white transition-colors hover:bg-white/20",
|
|
5004
|
+
onClick: () => de(-.25),
|
|
5005
|
+
title: "缩小",
|
|
5006
|
+
"aria-label": "缩小",
|
|
5007
|
+
children: "−"
|
|
5008
|
+
}),
|
|
5009
|
+
/* @__PURE__ */ O("button", {
|
|
5010
|
+
type: "button",
|
|
5011
|
+
className: "flex h-8 min-w-14 items-center justify-center rounded-lg bg-white/10 px-2 text-xs text-white transition-colors hover:bg-white/20",
|
|
5012
|
+
onClick: fe,
|
|
5013
|
+
title: "重置为 100%",
|
|
5014
|
+
"aria-label": "重置缩放",
|
|
5015
|
+
children: [Math.round(re * 100), "%"]
|
|
5016
|
+
}),
|
|
5017
|
+
/* @__PURE__ */ D("button", {
|
|
5018
|
+
type: "button",
|
|
5019
|
+
className: "flex h-8 min-w-8 items-center justify-center rounded-lg bg-white/10 px-2 text-base text-white transition-colors hover:bg-white/20",
|
|
5020
|
+
onClick: () => de(tr),
|
|
5021
|
+
title: "放大",
|
|
5022
|
+
"aria-label": "放大",
|
|
5023
|
+
children: "+"
|
|
5024
|
+
}),
|
|
5025
|
+
/* @__PURE__ */ D("button", {
|
|
5026
|
+
type: "button",
|
|
5027
|
+
className: "flex h-8 min-w-8 items-center justify-center rounded-lg bg-white/10 px-2 text-sm text-white transition-colors hover:bg-white/20",
|
|
5028
|
+
onClick: fe,
|
|
5029
|
+
title: "重置",
|
|
5030
|
+
"aria-label": "重置",
|
|
5031
|
+
children: "⟲"
|
|
5032
|
+
}),
|
|
5033
|
+
/* @__PURE__ */ D("span", { className: "mx-1 h-5 w-px bg-white/20" }),
|
|
5034
|
+
/* @__PURE__ */ D("button", {
|
|
5035
|
+
type: "button",
|
|
5036
|
+
className: "flex h-8 min-w-8 items-center justify-center rounded-lg bg-white/10 px-2 text-lg text-white transition-colors hover:bg-white/20",
|
|
5037
|
+
onClick: () => R(!1),
|
|
5038
|
+
title: "关闭",
|
|
5039
|
+
"aria-label": "关闭",
|
|
5040
|
+
children: "×"
|
|
5041
|
+
})
|
|
5042
|
+
]
|
|
5043
|
+
})]
|
|
5044
|
+
}), /* @__PURE__ */ D("div", {
|
|
5045
|
+
className: "flex flex-1 touch-none items-center justify-center overflow-hidden",
|
|
5046
|
+
style: { cursor: V ? "grabbing" : re > 1 ? "grab" : "default" },
|
|
5047
|
+
onWheel: (e) => de(e.deltaY > 0 ? -.25 : tr),
|
|
5048
|
+
onPointerDown: pe,
|
|
5049
|
+
onPointerMove: me,
|
|
5050
|
+
onPointerUp: he,
|
|
5051
|
+
onPointerCancel: he,
|
|
5052
|
+
onDoubleClick: () => {
|
|
5053
|
+
ie((e) => e === 1 ? 2 : 1), B({
|
|
5054
|
+
x: 0,
|
|
5055
|
+
y: 0
|
|
5056
|
+
});
|
|
5057
|
+
},
|
|
5058
|
+
children: /* @__PURE__ */ D("div", {
|
|
5059
|
+
className: "cb-diagram-zoom-content",
|
|
5060
|
+
style: {
|
|
5061
|
+
transform: `translate(${z.x}px, ${z.y}px) scale(${re})`,
|
|
5062
|
+
transition: V ? "none" : "transform 120ms ease-out"
|
|
5063
|
+
},
|
|
5064
|
+
dangerouslySetInnerHTML: { __html: N }
|
|
5065
|
+
})
|
|
5066
|
+
})]
|
|
5067
|
+
}), document.body),
|
|
5068
|
+
/* @__PURE__ */ D(Cn, {
|
|
4929
5069
|
open: j,
|
|
4930
5070
|
title: "确认删除代码块",
|
|
4931
5071
|
message: "此操作不可撤销。",
|
|
@@ -4941,7 +5081,7 @@ function er({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4941
5081
|
}
|
|
4942
5082
|
//#endregion
|
|
4943
5083
|
//#region src/editor/extensions/code-block.ts
|
|
4944
|
-
var
|
|
5084
|
+
var sr = [
|
|
4945
5085
|
{
|
|
4946
5086
|
value: "javascript",
|
|
4947
5087
|
label: "JavaScript"
|
|
@@ -5042,12 +5182,12 @@ var tr = [
|
|
|
5042
5182
|
value: "mermaid",
|
|
5043
5183
|
label: "Mermaid"
|
|
5044
5184
|
}
|
|
5045
|
-
],
|
|
5046
|
-
|
|
5047
|
-
function
|
|
5185
|
+
], cr = Se(xe);
|
|
5186
|
+
cr.register({ dockerfile: be }), cr.registerAlias("xml", ["vue", "html"]), cr.registerAlias("javascript", ["react", "jsx"]), cr.registerAlias("typescript", ["tsx"]);
|
|
5187
|
+
function lr(e) {
|
|
5048
5188
|
return e ? e.split("\n") : [""];
|
|
5049
5189
|
}
|
|
5050
|
-
function
|
|
5190
|
+
function ur(e, t) {
|
|
5051
5191
|
if (e.childElementCount !== t) {
|
|
5052
5192
|
e.replaceChildren();
|
|
5053
5193
|
for (let n = 1; n <= t; n++) {
|
|
@@ -5056,14 +5196,14 @@ function ir(e, t) {
|
|
|
5056
5196
|
}
|
|
5057
5197
|
}
|
|
5058
5198
|
}
|
|
5059
|
-
function
|
|
5199
|
+
function dr(e, t) {
|
|
5060
5200
|
e.replaceChildren();
|
|
5061
5201
|
for (let n of t) {
|
|
5062
5202
|
let t = document.createElement("span");
|
|
5063
5203
|
t.className = "cb-mirror-line", t.textContent = n.length ? n : "\xA0", e.appendChild(t);
|
|
5064
5204
|
}
|
|
5065
5205
|
}
|
|
5066
|
-
function
|
|
5206
|
+
function fr(e, t, n) {
|
|
5067
5207
|
let r = getComputedStyle(e), i = parseFloat(r.paddingLeft), a = parseFloat(r.paddingRight);
|
|
5068
5208
|
t.style.boxSizing = "content-box", t.style.width = `${Math.max(0, e.clientWidth - i - a)}px`, t.style.padding = r.padding;
|
|
5069
5209
|
let o = getComputedStyle(n);
|
|
@@ -5110,7 +5250,7 @@ function or(e, t, n) {
|
|
|
5110
5250
|
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;
|
|
5111
5251
|
}
|
|
5112
5252
|
}
|
|
5113
|
-
var
|
|
5253
|
+
var pr = ye.extend({
|
|
5114
5254
|
addNodeView() {
|
|
5115
5255
|
return (e) => {
|
|
5116
5256
|
let { node: t, editor: n, getPos: r } = e, i = t, a = (e) => {
|
|
@@ -5138,9 +5278,9 @@ var sr = ye.extend({
|
|
|
5138
5278
|
f.appendChild(p);
|
|
5139
5279
|
let m = document.createElement("div");
|
|
5140
5280
|
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);
|
|
5141
|
-
let h =
|
|
5142
|
-
|
|
5143
|
-
let g = new
|
|
5281
|
+
let h = lr(t.textContent);
|
|
5282
|
+
ur(d, h.length), dr(m, h);
|
|
5283
|
+
let g = new I(or, {
|
|
5144
5284
|
editor: n,
|
|
5145
5285
|
props: {
|
|
5146
5286
|
node: t,
|
|
@@ -5153,12 +5293,12 @@ var sr = ye.extend({
|
|
|
5153
5293
|
});
|
|
5154
5294
|
c.appendChild(g.element);
|
|
5155
5295
|
let _ = (e) => {
|
|
5156
|
-
let t =
|
|
5157
|
-
|
|
5296
|
+
let t = lr(e.textContent);
|
|
5297
|
+
ur(d, t.length), dr(m, t), requestAnimationFrame(() => fr(f, m, d));
|
|
5158
5298
|
};
|
|
5159
|
-
requestAnimationFrame(() =>
|
|
5160
|
-
let v = new ResizeObserver(() =>
|
|
5161
|
-
return v.observe(f), document.fonts?.ready?.then(() =>
|
|
5299
|
+
requestAnimationFrame(() => fr(f, m, d));
|
|
5300
|
+
let v = new ResizeObserver(() => fr(f, m, d));
|
|
5301
|
+
return v.observe(f), document.fonts?.ready?.then(() => fr(f, m, d)), {
|
|
5162
5302
|
dom: s,
|
|
5163
5303
|
contentDOM: p,
|
|
5164
5304
|
update(e) {
|
|
@@ -5218,10 +5358,10 @@ var sr = ye.extend({
|
|
|
5218
5358
|
}
|
|
5219
5359
|
}));
|
|
5220
5360
|
}
|
|
5221
|
-
}).configure({ lowlight:
|
|
5361
|
+
}).configure({ lowlight: cr });
|
|
5222
5362
|
//#endregion
|
|
5223
5363
|
//#region src/editor/utils/import-choice-dialog.ts
|
|
5224
|
-
function
|
|
5364
|
+
function mr(e) {
|
|
5225
5365
|
return new Promise((t) => {
|
|
5226
5366
|
let n = document.createElement("div");
|
|
5227
5367
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5251,16 +5391,16 @@ function cr(e) {
|
|
|
5251
5391
|
}
|
|
5252
5392
|
//#endregion
|
|
5253
5393
|
//#region src/editor/utils/local-media.ts
|
|
5254
|
-
var
|
|
5255
|
-
function
|
|
5394
|
+
var hr = /\.(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, gr = /^(?:mailto:|tel:|javascript:|about:|data:|blob:)/i;
|
|
5395
|
+
function _r(e) {
|
|
5256
5396
|
if (!e) return !1;
|
|
5257
5397
|
let t = e.trim();
|
|
5258
|
-
return !(!t || /^(?:https?:)?\/\//i.test(t) ||
|
|
5398
|
+
return !(!t || /^(?:https?:)?\/\//i.test(t) || gr.test(t) || t.startsWith("#"));
|
|
5259
5399
|
}
|
|
5260
|
-
function
|
|
5261
|
-
return
|
|
5400
|
+
function vr(e) {
|
|
5401
|
+
return hr.test(e);
|
|
5262
5402
|
}
|
|
5263
|
-
function
|
|
5403
|
+
function yr(e) {
|
|
5264
5404
|
let t = e.trim();
|
|
5265
5405
|
t = t.replace(/^(?:file|app):\/\/(?:localhost)?/i, "");
|
|
5266
5406
|
try {
|
|
@@ -5268,26 +5408,26 @@ function pr(e) {
|
|
|
5268
5408
|
} catch {}
|
|
5269
5409
|
return t = t.replace(/\\/g, "/"), t = t.replace(/^\.\//, ""), t = t.replace(/^\/+/, ""), t = t.replace(/^[a-zA-Z]:\//, ""), t;
|
|
5270
5410
|
}
|
|
5271
|
-
function
|
|
5272
|
-
let t =
|
|
5411
|
+
function br(e) {
|
|
5412
|
+
let t = yr(e), n = t.split("/").filter(Boolean);
|
|
5273
5413
|
return (n[n.length - 1] || t).toLowerCase();
|
|
5274
5414
|
}
|
|
5275
|
-
function
|
|
5415
|
+
function xr() {
|
|
5276
5416
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showDirectoryPicker == "function";
|
|
5277
5417
|
}
|
|
5278
|
-
async function
|
|
5279
|
-
if (!
|
|
5418
|
+
async function Sr() {
|
|
5419
|
+
if (!xr()) return null;
|
|
5280
5420
|
try {
|
|
5281
5421
|
return await window.showDirectoryPicker.call(window, { mode: "read" }) ?? null;
|
|
5282
5422
|
} catch {
|
|
5283
5423
|
return null;
|
|
5284
5424
|
}
|
|
5285
5425
|
}
|
|
5286
|
-
function
|
|
5426
|
+
function Cr() {
|
|
5287
5427
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showOpenFilePicker == "function";
|
|
5288
5428
|
}
|
|
5289
|
-
async function
|
|
5290
|
-
if (!
|
|
5429
|
+
async function wr() {
|
|
5430
|
+
if (!Cr()) return null;
|
|
5291
5431
|
try {
|
|
5292
5432
|
let e = await window.showOpenFilePicker.call(window, { multiple: !0 });
|
|
5293
5433
|
return await Promise.all(e.map((e) => e.getFile()));
|
|
@@ -5295,7 +5435,7 @@ async function vr() {
|
|
|
5295
5435
|
return null;
|
|
5296
5436
|
}
|
|
5297
5437
|
}
|
|
5298
|
-
async function
|
|
5438
|
+
async function Tr(e, t) {
|
|
5299
5439
|
if (t.length === 0) return { file: null };
|
|
5300
5440
|
let n = e;
|
|
5301
5441
|
for (let e = 0; e < t.length - 1; e++) try {
|
|
@@ -5317,7 +5457,7 @@ async function yr(e, t) {
|
|
|
5317
5457
|
return { file: null };
|
|
5318
5458
|
}
|
|
5319
5459
|
}
|
|
5320
|
-
async function
|
|
5460
|
+
async function Er(e, t, n = 5e3) {
|
|
5321
5461
|
let r = t.toLowerCase(), i = [e], a = 0, o;
|
|
5322
5462
|
for (; i.length > 0 && a < n;) {
|
|
5323
5463
|
let e = i.pop();
|
|
@@ -5339,37 +5479,37 @@ async function br(e, t, n = 5e3) {
|
|
|
5339
5479
|
readError: o
|
|
5340
5480
|
};
|
|
5341
5481
|
}
|
|
5342
|
-
async function
|
|
5343
|
-
let n =
|
|
5482
|
+
async function Dr(e, t) {
|
|
5483
|
+
let n = yr(t).split("/").filter(Boolean);
|
|
5344
5484
|
if (n.length === 0) return { file: null };
|
|
5345
5485
|
let r;
|
|
5346
5486
|
for (let t = 0; t < n.length; t++) {
|
|
5347
|
-
let i = await
|
|
5487
|
+
let i = await Tr(e, n.slice(t));
|
|
5348
5488
|
if (i.file) return i;
|
|
5349
5489
|
i.readError && (r = i.readError);
|
|
5350
5490
|
}
|
|
5351
|
-
let i = await
|
|
5491
|
+
let i = await Er(e, n[n.length - 1]);
|
|
5352
5492
|
return i.file || i.readError ? i : {
|
|
5353
5493
|
file: null,
|
|
5354
5494
|
readError: r
|
|
5355
5495
|
};
|
|
5356
5496
|
}
|
|
5357
|
-
var
|
|
5497
|
+
var Or = {
|
|
5358
5498
|
image: "image",
|
|
5359
5499
|
videoEmbed: "video",
|
|
5360
5500
|
audioEmbed: "audio",
|
|
5361
5501
|
attachmentEmbed: "attachment"
|
|
5362
5502
|
};
|
|
5363
|
-
function
|
|
5503
|
+
function kr(e, t) {
|
|
5364
5504
|
let n = /* @__PURE__ */ new Set(), r = [];
|
|
5365
5505
|
return e.descendants((e) => {
|
|
5366
|
-
let i =
|
|
5506
|
+
let i = Or[e.type?.name];
|
|
5367
5507
|
if (i) {
|
|
5368
5508
|
let a = e.attrs?.src, o = `node:${a}`;
|
|
5369
|
-
typeof a == "string" &&
|
|
5509
|
+
typeof a == "string" && _r(a) && !n.has(o) && !t?.(a) && (n.add(o), r.push({
|
|
5370
5510
|
src: a,
|
|
5371
|
-
normalized:
|
|
5372
|
-
basename:
|
|
5511
|
+
normalized: yr(a),
|
|
5512
|
+
basename: br(a),
|
|
5373
5513
|
kind: i,
|
|
5374
5514
|
isLink: !1
|
|
5375
5515
|
}));
|
|
@@ -5378,17 +5518,17 @@ function Cr(e, t) {
|
|
|
5378
5518
|
if (e.isText && e.marks) for (let i of e.marks) {
|
|
5379
5519
|
if (i.type.name !== "link") continue;
|
|
5380
5520
|
let e = i.attrs?.href, a = `link:${e}`;
|
|
5381
|
-
typeof e == "string" &&
|
|
5521
|
+
typeof e == "string" && _r(e) && vr(e) && !n.has(a) && !t?.(e) && (n.add(a), r.push({
|
|
5382
5522
|
src: e,
|
|
5383
|
-
normalized:
|
|
5384
|
-
basename:
|
|
5523
|
+
normalized: yr(e),
|
|
5524
|
+
basename: br(e),
|
|
5385
5525
|
kind: "attachment",
|
|
5386
5526
|
isLink: !0
|
|
5387
5527
|
}));
|
|
5388
5528
|
}
|
|
5389
5529
|
}), r;
|
|
5390
5530
|
}
|
|
5391
|
-
function
|
|
5531
|
+
function Ar(e, t, n) {
|
|
5392
5532
|
let r = t ? `${e}\n${t}` : e;
|
|
5393
5533
|
if (!r) return !1;
|
|
5394
5534
|
let i = [];
|
|
@@ -5396,28 +5536,28 @@ function wr(e, t, n) {
|
|
|
5396
5536
|
for (let e of r.matchAll(/!?\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g)) i.push(e[1]);
|
|
5397
5537
|
for (let e of r.matchAll(/<(?:img|video|audio|source)[^>]*\bsrc=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5398
5538
|
for (let e of r.matchAll(/<a[^>]*\bhref=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5399
|
-
return i.some((e) =>
|
|
5539
|
+
return i.some((e) => vr(e) && _r(e) && !n?.(e));
|
|
5400
5540
|
}
|
|
5401
5541
|
//#endregion
|
|
5402
5542
|
//#region src/editor/extensions/image-upload.ts
|
|
5403
|
-
function
|
|
5543
|
+
function jr(e) {
|
|
5404
5544
|
if (e.type.startsWith("image/")) return "image";
|
|
5405
5545
|
if (e.type.startsWith("video/")) return "video";
|
|
5406
5546
|
if (e.type.startsWith("audio/")) return "audio";
|
|
5407
5547
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5408
5548
|
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";
|
|
5409
5549
|
}
|
|
5410
|
-
function
|
|
5550
|
+
function Mr(e) {
|
|
5411
5551
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5412
5552
|
return t === "md" || t === "markdown";
|
|
5413
5553
|
}
|
|
5414
|
-
async function
|
|
5415
|
-
let i = n ?? e.state.selection.from, a = r ?
|
|
5416
|
-
o?.chooseMd ? o.chooseMd(t.name, e) :
|
|
5554
|
+
async function Nr(e, t, n, r) {
|
|
5555
|
+
let i = n ?? e.state.selection.from, a = r ? pn(r) : void 0, o = r?.storage?.qingwuUI, s = await new Promise((e) => {
|
|
5556
|
+
o?.chooseMd ? o.chooseMd(t.name, e) : mr(t.name).then(e);
|
|
5417
5557
|
});
|
|
5418
5558
|
if (s === null) return;
|
|
5419
5559
|
if (s === "attach") {
|
|
5420
|
-
let n = a ?
|
|
5560
|
+
let n = a ? mn(e.state.doc, t, a) : null;
|
|
5421
5561
|
if (n) {
|
|
5422
5562
|
Z(n);
|
|
5423
5563
|
return;
|
|
@@ -5448,8 +5588,8 @@ async function Dr(e, t, n, r) {
|
|
|
5448
5588
|
e.dispatch(e.state.tr.insert(i, t.from(u)));
|
|
5449
5589
|
}
|
|
5450
5590
|
}
|
|
5451
|
-
function
|
|
5452
|
-
switch (
|
|
5591
|
+
function Pr(e, t, n) {
|
|
5592
|
+
switch (jr(t)) {
|
|
5453
5593
|
case "image": return e.nodes.image?.create({
|
|
5454
5594
|
src: n,
|
|
5455
5595
|
alt: t.name
|
|
@@ -5475,7 +5615,7 @@ function Or(e, t, n) {
|
|
|
5475
5615
|
}
|
|
5476
5616
|
}
|
|
5477
5617
|
}
|
|
5478
|
-
async function
|
|
5618
|
+
async function Fr(e, t, n) {
|
|
5479
5619
|
let r;
|
|
5480
5620
|
try {
|
|
5481
5621
|
r = o();
|
|
@@ -5494,13 +5634,13 @@ async function kr(e, t, n) {
|
|
|
5494
5634
|
return console.error(`${t.type} upload failed:`, e), URL.revokeObjectURL(n), null;
|
|
5495
5635
|
}
|
|
5496
5636
|
}
|
|
5497
|
-
async function
|
|
5498
|
-
let i = r ?
|
|
5637
|
+
async function Ir(e, t, n, r) {
|
|
5638
|
+
let i = r ? pn(r) : void 0, a = i ? mn(e.state.doc, t, i) : null;
|
|
5499
5639
|
if (a) {
|
|
5500
5640
|
Z(a);
|
|
5501
5641
|
return;
|
|
5502
5642
|
}
|
|
5503
|
-
let o = URL.createObjectURL(t), s =
|
|
5643
|
+
let o = URL.createObjectURL(t), s = Pr(e.state.schema, t, o);
|
|
5504
5644
|
if (!s) return;
|
|
5505
5645
|
let c = n ?? e.state.selection.from;
|
|
5506
5646
|
try {
|
|
@@ -5508,9 +5648,9 @@ async function Ar(e, t, n, r) {
|
|
|
5508
5648
|
} catch {
|
|
5509
5649
|
return;
|
|
5510
5650
|
}
|
|
5511
|
-
await
|
|
5651
|
+
await Fr(e, t, o);
|
|
5512
5652
|
}
|
|
5513
|
-
var
|
|
5653
|
+
var Lr = R.create({
|
|
5514
5654
|
name: "imageUpload",
|
|
5515
5655
|
addOptions() {
|
|
5516
5656
|
return {
|
|
@@ -5520,8 +5660,8 @@ var jr = R.create({
|
|
|
5520
5660
|
},
|
|
5521
5661
|
addProseMirrorPlugins() {
|
|
5522
5662
|
let e = this.editor;
|
|
5523
|
-
return [new
|
|
5524
|
-
key: new
|
|
5663
|
+
return [new V({
|
|
5664
|
+
key: new H("imageUpload"),
|
|
5525
5665
|
props: {
|
|
5526
5666
|
handleDrop(t, n) {
|
|
5527
5667
|
let r = n.dataTransfer?.files;
|
|
@@ -5531,23 +5671,23 @@ var jr = R.create({
|
|
|
5531
5671
|
left: n.clientX,
|
|
5532
5672
|
top: n.clientY
|
|
5533
5673
|
});
|
|
5534
|
-
for (let n of Array.from(r))
|
|
5674
|
+
for (let n of Array.from(r)) Mr(n) ? Nr(t, n, i?.pos, e) : Ir(t, n, i?.pos, e);
|
|
5535
5675
|
return !0;
|
|
5536
5676
|
},
|
|
5537
5677
|
handlePaste(t, n) {
|
|
5538
5678
|
let r = n.clipboardData?.items;
|
|
5539
5679
|
if (!r) return !1;
|
|
5540
5680
|
let i = n.clipboardData?.getData("text/plain") || "";
|
|
5541
|
-
if ((n.clipboardData?.files?.length ?? 0) > 0 &&
|
|
5681
|
+
if ((n.clipboardData?.files?.length ?? 0) > 0 && Ar(i, void 0, a())) return !1;
|
|
5542
5682
|
for (let i of Array.from(r)) {
|
|
5543
5683
|
if (i.type.startsWith("image/") || i.type.startsWith("video/") || i.type.startsWith("audio/")) {
|
|
5544
5684
|
n.preventDefault();
|
|
5545
5685
|
let r = i.getAsFile();
|
|
5546
|
-
return r &&
|
|
5686
|
+
return r && jr(r) !== "file" && Ir(t, r, void 0, e), !0;
|
|
5547
5687
|
}
|
|
5548
5688
|
if (i.kind === "file") {
|
|
5549
5689
|
let r = i.getAsFile();
|
|
5550
|
-
if (r &&
|
|
5690
|
+
if (r && Mr(r)) return n.preventDefault(), Nr(t, r, void 0, e), !0;
|
|
5551
5691
|
}
|
|
5552
5692
|
}
|
|
5553
5693
|
return !1;
|
|
@@ -5555,12 +5695,12 @@ var jr = R.create({
|
|
|
5555
5695
|
}
|
|
5556
5696
|
})];
|
|
5557
5697
|
}
|
|
5558
|
-
}),
|
|
5698
|
+
}), Rr = 100, zr = R.create({
|
|
5559
5699
|
name: "imeCommitSpaceGuard",
|
|
5560
5700
|
addProseMirrorPlugins() {
|
|
5561
5701
|
let e = 0;
|
|
5562
|
-
return [new
|
|
5563
|
-
key: new
|
|
5702
|
+
return [new V({
|
|
5703
|
+
key: new H("imeCommitSpaceGuard"),
|
|
5564
5704
|
props: { handleDOMEvents: {
|
|
5565
5705
|
compositionend() {
|
|
5566
5706
|
return e = performance.now(), !1;
|
|
@@ -5570,39 +5710,370 @@ var jr = R.create({
|
|
|
5570
5710
|
},
|
|
5571
5711
|
beforeinput(t, n) {
|
|
5572
5712
|
let r = n;
|
|
5573
|
-
return r.inputType !== "insertText" || r.data !== " " || r.isComposing || performance.now() - e >
|
|
5713
|
+
return r.inputType !== "insertText" || r.data !== " " || r.isComposing || performance.now() - e > Rr ? !1 : (r.preventDefault(), !0);
|
|
5574
5714
|
}
|
|
5575
5715
|
} }
|
|
5576
5716
|
})];
|
|
5577
5717
|
}
|
|
5578
|
-
}),
|
|
5718
|
+
}), Br = R.create({
|
|
5579
5719
|
name: "inlineCodeEnd",
|
|
5580
5720
|
addInputRules() {
|
|
5581
5721
|
let e = this.editor.schema.marks.code;
|
|
5582
|
-
return e ? [
|
|
5722
|
+
return e ? [z({
|
|
5583
5723
|
find: /`([^`]+)`$/,
|
|
5584
5724
|
type: e
|
|
5585
5725
|
})] : [];
|
|
5586
5726
|
}
|
|
5587
|
-
})
|
|
5588
|
-
|
|
5727
|
+
});
|
|
5728
|
+
//#endregion
|
|
5729
|
+
//#region src/editor/extensions/math-utils.ts
|
|
5730
|
+
function Vr(e) {
|
|
5731
|
+
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">").replace(/\n/g, " ");
|
|
5732
|
+
}
|
|
5733
|
+
function Hr(e) {
|
|
5734
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
5735
|
+
}
|
|
5736
|
+
function Ur(e, t) {
|
|
5737
|
+
let n = e ?? "";
|
|
5738
|
+
if (!n.trim()) return "";
|
|
5739
|
+
try {
|
|
5740
|
+
return Ce.renderToString(n, {
|
|
5741
|
+
displayMode: t,
|
|
5742
|
+
throwOnError: !1,
|
|
5743
|
+
strict: "ignore",
|
|
5744
|
+
trust: !1,
|
|
5745
|
+
output: "htmlAndMathml"
|
|
5746
|
+
});
|
|
5747
|
+
} catch {
|
|
5748
|
+
return `<span class="math-fallback">${Hr(n)}</span>`;
|
|
5749
|
+
}
|
|
5750
|
+
}
|
|
5751
|
+
//#endregion
|
|
5752
|
+
//#region src/editor/extensions/math-view.tsx
|
|
5753
|
+
function Wr({ node: e, updateAttributes: t, deleteNode: n, editor: r, selected: i }) {
|
|
5754
|
+
let a = e.type.name === "mathBlock", o = String(e.attrs.latex ?? ""), s = r?.isEditable ?? !0, [c, l] = T(!1), [u, d] = T(o), p = w(null), m = w(!1), h = w(() => {}), g = w(() => {}), _ = C(() => Ur(o, a), [o, a]), v = C(() => Ur(u, a), [u, a]), y = () => {
|
|
5755
|
+
let e = u.trim();
|
|
5756
|
+
if (!e) {
|
|
5757
|
+
l(!1), s && n?.();
|
|
5758
|
+
return;
|
|
5759
|
+
}
|
|
5760
|
+
t({ latex: e }), l(!1);
|
|
5761
|
+
}, b = () => {
|
|
5762
|
+
l(!1), !o && s && n?.();
|
|
5763
|
+
};
|
|
5764
|
+
h.current = y, g.current = b, x(() => {
|
|
5765
|
+
!s || m.current || (m.current = !0, o || l(!0));
|
|
5766
|
+
}, [s, o]), x(() => {
|
|
5767
|
+
if (!c) return;
|
|
5768
|
+
d(o);
|
|
5769
|
+
let e = window.setTimeout(() => {
|
|
5770
|
+
p.current?.focus(), p.current?.select();
|
|
5771
|
+
}, 30), t = (e) => {
|
|
5772
|
+
e.key === "Escape" ? (e.preventDefault(), g.current()) : (e.metaKey || e.ctrlKey) && e.key === "Enter" && (e.preventDefault(), h.current());
|
|
5773
|
+
};
|
|
5774
|
+
return window.addEventListener("keydown", t, !0), () => {
|
|
5775
|
+
window.clearTimeout(e), window.removeEventListener("keydown", t, !0);
|
|
5776
|
+
};
|
|
5777
|
+
}, [c, o]);
|
|
5778
|
+
let S = () => {
|
|
5779
|
+
s && l(!0);
|
|
5780
|
+
};
|
|
5781
|
+
return /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D(P, {
|
|
5782
|
+
as: a ? "div" : "span",
|
|
5783
|
+
className: `math-node ${a ? "math-node--block" : "math-node--inline"}${i ? " is-selected" : ""}`,
|
|
5784
|
+
contentEditable: !1,
|
|
5785
|
+
onMouseDown: (e) => {
|
|
5786
|
+
s && e.preventDefault();
|
|
5787
|
+
},
|
|
5788
|
+
onClick: (e) => {
|
|
5789
|
+
e.preventDefault(), e.stopPropagation(), S();
|
|
5790
|
+
},
|
|
5791
|
+
children: o ? /* @__PURE__ */ D("span", {
|
|
5792
|
+
className: "math-render",
|
|
5793
|
+
dangerouslySetInnerHTML: { __html: _ }
|
|
5794
|
+
}) : /* @__PURE__ */ D("span", {
|
|
5795
|
+
className: "math-placeholder",
|
|
5796
|
+
children: f("editor.math.empty")
|
|
5797
|
+
})
|
|
5798
|
+
}), c && L(/* @__PURE__ */ D("div", {
|
|
5799
|
+
className: "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none",
|
|
5800
|
+
onClick: b,
|
|
5801
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
5802
|
+
children: /* @__PURE__ */ O("div", {
|
|
5803
|
+
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",
|
|
5804
|
+
onClick: (e) => e.stopPropagation(),
|
|
5805
|
+
children: [
|
|
5806
|
+
/* @__PURE__ */ D("div", {
|
|
5807
|
+
className: "mb-3 text-sm font-medium text-default-800 dark:text-zinc-100",
|
|
5808
|
+
children: f(a ? "editor.math.blockTitle" : "editor.math.inlineTitle")
|
|
5809
|
+
}),
|
|
5810
|
+
/* @__PURE__ */ D("textarea", {
|
|
5811
|
+
ref: p,
|
|
5812
|
+
value: u,
|
|
5813
|
+
onChange: (e) => d(e.target.value),
|
|
5814
|
+
rows: a ? 5 : 2,
|
|
5815
|
+
spellCheck: !1,
|
|
5816
|
+
placeholder: f("editor.math.placeholder"),
|
|
5817
|
+
className: "w-full resize-y rounded-lg border border-default-200 dark:border-zinc-700 bg-default-50 dark:bg-zinc-900 px-3 py-2 font-mono text-sm text-default-800 dark:text-zinc-100 outline-none focus:ring-2 focus:ring-qingwu-500/40"
|
|
5818
|
+
}),
|
|
5819
|
+
/* @__PURE__ */ D("div", {
|
|
5820
|
+
className: "math-dialog-preview",
|
|
5821
|
+
children: u.trim() ? /* @__PURE__ */ D("div", { dangerouslySetInnerHTML: { __html: v } }) : /* @__PURE__ */ D("span", {
|
|
5822
|
+
className: "math-placeholder",
|
|
5823
|
+
children: f("editor.math.emptyPreview")
|
|
5824
|
+
})
|
|
5825
|
+
}),
|
|
5826
|
+
/* @__PURE__ */ O("div", {
|
|
5827
|
+
className: "mt-4 flex items-center justify-between gap-3",
|
|
5828
|
+
children: [/* @__PURE__ */ D("span", {
|
|
5829
|
+
className: "text-[11px] text-default-400 dark:text-zinc-500",
|
|
5830
|
+
children: f("editor.math.hint")
|
|
5831
|
+
}), /* @__PURE__ */ O("div", {
|
|
5832
|
+
className: "flex shrink-0 gap-2",
|
|
5833
|
+
children: [/* @__PURE__ */ D("button", {
|
|
5834
|
+
type: "button",
|
|
5835
|
+
className: "px-3 py-1.5 text-xs rounded-lg border border-default-200 dark:border-zinc-600 hover:bg-default-100 dark:hover:bg-zinc-700 transition-colors",
|
|
5836
|
+
onClick: b,
|
|
5837
|
+
children: f("editor.math.cancel")
|
|
5838
|
+
}), /* @__PURE__ */ D("button", {
|
|
5839
|
+
type: "button",
|
|
5840
|
+
className: "px-3 py-1.5 text-xs rounded-lg bg-qingwu-600 hover:bg-qingwu-700 text-white transition-colors",
|
|
5841
|
+
onClick: y,
|
|
5842
|
+
children: f("editor.math.save")
|
|
5843
|
+
})]
|
|
5844
|
+
})]
|
|
5845
|
+
})
|
|
5846
|
+
]
|
|
5847
|
+
})
|
|
5848
|
+
}), document.body)] });
|
|
5849
|
+
}
|
|
5850
|
+
//#endregion
|
|
5851
|
+
//#region src/editor/extensions/math.ts
|
|
5852
|
+
var Gr = /(?:^|[^\\$])\$([^\s$](?:[^$\n]*[^\s$])?)\$$/, Kr = /^\$\$([\s\S]+?)\$\$$/;
|
|
5853
|
+
function qr(e) {
|
|
5854
|
+
return new V({ appendTransaction(t, n, r) {
|
|
5855
|
+
if (!e.isEditable || e.view.composing || !t.some((e) => e.docChanged)) return null;
|
|
5856
|
+
let i = r.schema.nodes.paragraph, a = r.schema.nodes.mathBlock;
|
|
5857
|
+
if (!i || !a) return null;
|
|
5858
|
+
let o = [], s = null;
|
|
5859
|
+
if (r.doc.forEach((e, t) => {
|
|
5860
|
+
if (e.type !== i) {
|
|
5861
|
+
s = null;
|
|
5862
|
+
return;
|
|
5863
|
+
}
|
|
5864
|
+
let n = e.textContent.trim(), r = s;
|
|
5865
|
+
if (!r) {
|
|
5866
|
+
n === "$$" && (s = {
|
|
5867
|
+
from: t,
|
|
5868
|
+
lines: []
|
|
5869
|
+
});
|
|
5870
|
+
return;
|
|
5871
|
+
}
|
|
5872
|
+
if (n === "$$") {
|
|
5873
|
+
o.push({
|
|
5874
|
+
from: r.from,
|
|
5875
|
+
to: t + e.nodeSize,
|
|
5876
|
+
latex: r.lines.join("\n")
|
|
5877
|
+
}), s = null;
|
|
5878
|
+
return;
|
|
5879
|
+
}
|
|
5880
|
+
r.lines.push(e.textContent);
|
|
5881
|
+
}), !o.length) return null;
|
|
5882
|
+
let c = r.tr;
|
|
5883
|
+
for (let e of o.reverse()) {
|
|
5884
|
+
let t = a.create({ latex: e.latex });
|
|
5885
|
+
c.replaceWith(e.from, e.to, t);
|
|
5886
|
+
let n = e.from + t.nodeSize, r = c.doc.resolve(n);
|
|
5887
|
+
(!r.nodeAfter || !r.nodeAfter.isTextblock) && c.insert(n, i.create()), c.setSelection(ae.near(c.doc.resolve(n), 1));
|
|
5888
|
+
}
|
|
5889
|
+
return c;
|
|
5890
|
+
} });
|
|
5891
|
+
}
|
|
5892
|
+
function Jr(e) {
|
|
5893
|
+
return new re({
|
|
5894
|
+
find: Gr,
|
|
5895
|
+
handler: ({ state: t, range: n, match: r }) => {
|
|
5896
|
+
let i = r[1], a = r[0].indexOf("$");
|
|
5897
|
+
if (a < 0) return;
|
|
5898
|
+
let o = n.from + a, s = n.to;
|
|
5899
|
+
o >= s || t.tr.replaceWith(o, s, e.create({ latex: i }));
|
|
5900
|
+
}
|
|
5901
|
+
});
|
|
5902
|
+
}
|
|
5903
|
+
function Yr(e) {
|
|
5904
|
+
return new re({
|
|
5905
|
+
find: Kr,
|
|
5906
|
+
handler: ({ state: t, range: n, match: r }) => {
|
|
5907
|
+
let i = r[1].trim();
|
|
5908
|
+
if (!i) return;
|
|
5909
|
+
let a = t.doc.resolve(n.from), o = a.depth, s = a.before(o), c = a.after(o), l = e.create({ latex: i }), u = t.tr.replaceWith(s, c, l), d = s + l.nodeSize, f = u.doc.resolve(d);
|
|
5910
|
+
(!f.nodeAfter || !f.nodeAfter.isTextblock) && u.insert(d, t.schema.nodes.paragraph.create()), u.setSelection(ae.near(u.doc.resolve(d), 1));
|
|
5911
|
+
}
|
|
5912
|
+
});
|
|
5913
|
+
}
|
|
5914
|
+
function Xr(e, t) {
|
|
5915
|
+
let n = e.src, r = e.pos;
|
|
5916
|
+
if (n.charCodeAt(r) !== 36 || n.charCodeAt(r + 1) === 36) return !1;
|
|
5917
|
+
let i = r + 1;
|
|
5918
|
+
for (; i < n.length;) {
|
|
5919
|
+
let e = n.charCodeAt(i);
|
|
5920
|
+
if (e === 10) return !1;
|
|
5921
|
+
if (e === 36 && n.charCodeAt(i - 1) !== 92) break;
|
|
5922
|
+
i += 1;
|
|
5923
|
+
}
|
|
5924
|
+
if (i >= n.length) return !1;
|
|
5925
|
+
let a = n.slice(r + 1, i);
|
|
5926
|
+
if (!a || /^\s|\s$/.test(a)) return !1;
|
|
5927
|
+
if (!t) {
|
|
5928
|
+
let t = e.push("html_inline", "", 0);
|
|
5929
|
+
t.content = `<span data-type="inline-math" data-latex="${Vr(a)}"></span>`;
|
|
5930
|
+
}
|
|
5931
|
+
return e.pos = i + 1, !0;
|
|
5932
|
+
}
|
|
5933
|
+
function Zr(e, t, n, r) {
|
|
5934
|
+
let i = e.bMarks[t] + e.tShift[t], a = e.eMarks[t];
|
|
5935
|
+
if (i + 1 >= a || e.src.charCodeAt(i) !== 36 || e.src.charCodeAt(i + 1) !== 36) return !1;
|
|
5936
|
+
let o = e.src.slice(i, a).trim(), s = "", c = t + 1;
|
|
5937
|
+
if (o.length > 4 && o.endsWith("$$")) s = o.slice(2, -2);
|
|
5938
|
+
else {
|
|
5939
|
+
let t = [], r = o.slice(2), i = r.endsWith("$$");
|
|
5940
|
+
if (i) s = r.slice(0, -2);
|
|
5941
|
+
else {
|
|
5942
|
+
for (r && t.push(r); c < n; c += 1) {
|
|
5943
|
+
let n = e.bMarks[c] + e.tShift[c], r = e.eMarks[c], a = e.src.slice(n, r), o = a.trimEnd();
|
|
5944
|
+
if (o.endsWith("$$")) {
|
|
5945
|
+
t.push(o.slice(0, -2)), i = !0, c += 1;
|
|
5946
|
+
break;
|
|
5947
|
+
}
|
|
5948
|
+
t.push(a);
|
|
5949
|
+
}
|
|
5950
|
+
if (!i) return !1;
|
|
5951
|
+
s = t.join("\n");
|
|
5952
|
+
}
|
|
5953
|
+
}
|
|
5954
|
+
if (r) return !0;
|
|
5955
|
+
let l = e.push("html_block", "", 0);
|
|
5956
|
+
return l.content = `<div data-type="block-math" data-latex="${Vr(s.trim())}"></div>\n`, e.line = c, !0;
|
|
5957
|
+
}
|
|
5958
|
+
function Qr(e) {
|
|
5959
|
+
e.__qingwuMathReg || (e.__qingwuMathReg = !0, e.inline.ruler.before("backticks", "qingwu_math_inline", Xr), e.block.ruler.before("fence", "qingwu_math_block", Zr, { alt: ["paragraph"] }));
|
|
5960
|
+
}
|
|
5961
|
+
function $r(e) {
|
|
5962
|
+
return { markdown: {
|
|
5963
|
+
serialize(t, n) {
|
|
5964
|
+
let r = String(n.attrs.latex ?? "");
|
|
5965
|
+
if (!e) {
|
|
5966
|
+
t.write(`$${r}$`);
|
|
5967
|
+
return;
|
|
5968
|
+
}
|
|
5969
|
+
t.ensureNewLine(), t.write("$$"), t.ensureNewLine();
|
|
5970
|
+
for (let e of r.split("\n")) t.write(e), t.ensureNewLine();
|
|
5971
|
+
t.write("$$"), t.closeBlock(n);
|
|
5972
|
+
},
|
|
5973
|
+
parse: { setup(e) {
|
|
5974
|
+
Qr(e);
|
|
5975
|
+
} }
|
|
5976
|
+
} };
|
|
5977
|
+
}
|
|
5978
|
+
var ei = ie.create({
|
|
5979
|
+
name: "mathInline",
|
|
5980
|
+
group: "inline",
|
|
5981
|
+
inline: !0,
|
|
5982
|
+
atom: !0,
|
|
5983
|
+
selectable: !0,
|
|
5984
|
+
addAttributes() {
|
|
5985
|
+
return { latex: {
|
|
5986
|
+
default: "",
|
|
5987
|
+
parseHTML: (e) => e.getAttribute("data-latex") ?? e.textContent ?? ""
|
|
5988
|
+
} };
|
|
5989
|
+
},
|
|
5990
|
+
parseHTML() {
|
|
5991
|
+
return [{ tag: "span[data-type=\"inline-math\"]" }, { tag: "span.math-node--inline" }];
|
|
5992
|
+
},
|
|
5993
|
+
renderHTML({ node: e }) {
|
|
5994
|
+
let t = String(e.attrs.latex ?? ""), n = {
|
|
5995
|
+
"data-type": "inline-math",
|
|
5996
|
+
"data-latex": t,
|
|
5997
|
+
class: "math-node math-node--inline"
|
|
5998
|
+
};
|
|
5999
|
+
if (typeof document > "u") return [
|
|
6000
|
+
"span",
|
|
6001
|
+
n,
|
|
6002
|
+
t
|
|
6003
|
+
];
|
|
6004
|
+
let r = document.createElement("span");
|
|
6005
|
+
for (let [e, t] of Object.entries(n)) r.setAttribute(e, t);
|
|
6006
|
+
return r.innerHTML = Ur(t, !1), r;
|
|
6007
|
+
},
|
|
6008
|
+
addNodeView() {
|
|
6009
|
+
return F(Wr);
|
|
6010
|
+
},
|
|
6011
|
+
addInputRules() {
|
|
6012
|
+
return [Jr(this.type)];
|
|
6013
|
+
},
|
|
6014
|
+
addStorage() {
|
|
6015
|
+
return $r(!1);
|
|
6016
|
+
}
|
|
6017
|
+
}), ti = ie.create({
|
|
6018
|
+
name: "mathBlock",
|
|
6019
|
+
group: "block",
|
|
6020
|
+
atom: !0,
|
|
6021
|
+
selectable: !0,
|
|
6022
|
+
addAttributes() {
|
|
6023
|
+
return { latex: {
|
|
6024
|
+
default: "",
|
|
6025
|
+
parseHTML: (e) => e.getAttribute("data-latex") ?? e.textContent ?? ""
|
|
6026
|
+
} };
|
|
6027
|
+
},
|
|
6028
|
+
parseHTML() {
|
|
6029
|
+
return [{ tag: "div[data-type=\"block-math\"]" }, { tag: "div.math-node--block" }];
|
|
6030
|
+
},
|
|
6031
|
+
renderHTML({ node: e }) {
|
|
6032
|
+
let t = String(e.attrs.latex ?? ""), n = {
|
|
6033
|
+
"data-type": "block-math",
|
|
6034
|
+
"data-latex": t,
|
|
6035
|
+
class: "math-node math-node--block"
|
|
6036
|
+
};
|
|
6037
|
+
if (typeof document > "u") return [
|
|
6038
|
+
"div",
|
|
6039
|
+
n,
|
|
6040
|
+
t
|
|
6041
|
+
];
|
|
6042
|
+
let r = document.createElement("div");
|
|
6043
|
+
for (let [e, t] of Object.entries(n)) r.setAttribute(e, t);
|
|
6044
|
+
return r.innerHTML = Ur(t, !0), r;
|
|
6045
|
+
},
|
|
6046
|
+
addNodeView() {
|
|
6047
|
+
return F(Wr);
|
|
6048
|
+
},
|
|
6049
|
+
addInputRules() {
|
|
6050
|
+
return [Yr(this.type)];
|
|
6051
|
+
},
|
|
6052
|
+
addProseMirrorPlugins() {
|
|
6053
|
+
return [qr(this.editor)];
|
|
6054
|
+
},
|
|
6055
|
+
addStorage() {
|
|
6056
|
+
return $r(!0);
|
|
6057
|
+
}
|
|
6058
|
+
}), ni = /\.(png|jpe?g|gif|webp|bmp|svg|avif)(\?|#|$)/i, ri = /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|#|$)/i, ii = /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|#|$)/i;
|
|
6059
|
+
function ai(e) {
|
|
5589
6060
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
5590
6061
|
}
|
|
5591
|
-
function
|
|
6062
|
+
function oi(e) {
|
|
5592
6063
|
let t = e.trim().replace(/\\/g, "/");
|
|
5593
6064
|
return t.split("/").pop() || t;
|
|
5594
6065
|
}
|
|
5595
|
-
function
|
|
6066
|
+
function si(e, t) {
|
|
5596
6067
|
let n = e.src.slice(e.pos), r = /^!\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !0;
|
|
5597
6068
|
if (r || (r = /^\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !1), !r) return !1;
|
|
5598
6069
|
let a = r[1].trim(), o = r[2]?.trim();
|
|
5599
6070
|
if (!t) {
|
|
5600
|
-
let t = o ||
|
|
6071
|
+
let t = o || oi(a);
|
|
5601
6072
|
if (i) {
|
|
5602
6073
|
let n = "";
|
|
5603
|
-
if (
|
|
5604
|
-
else if (
|
|
5605
|
-
else if (
|
|
6074
|
+
if (ni.test(a) || /^data:image\//i.test(a)) n = `<img src="${ai(a)}" alt="${ai(t)}">`;
|
|
6075
|
+
else if (ri.test(a) || /^data:video\//i.test(a)) n = `<div data-video-embed src="${ai(a)}"></div>`;
|
|
6076
|
+
else if (ii.test(a) || /^data:audio\//i.test(a)) n = `<audio src="${ai(a)}"></audio>`;
|
|
5606
6077
|
else {
|
|
5607
6078
|
let n = e.push("link_open", "a", 1);
|
|
5608
6079
|
n.attrs = [["href", a]];
|
|
@@ -5620,14 +6091,14 @@ function Br(e, t) {
|
|
|
5620
6091
|
}
|
|
5621
6092
|
return e.pos += r[0].length, !0;
|
|
5622
6093
|
}
|
|
5623
|
-
var
|
|
6094
|
+
var ci = R.create({
|
|
5624
6095
|
name: "obsidianMarkdown",
|
|
5625
6096
|
addStorage() {
|
|
5626
6097
|
return { markdown: { parse: { setup(e) {
|
|
5627
|
-
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed",
|
|
6098
|
+
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed", si));
|
|
5628
6099
|
} } } };
|
|
5629
6100
|
}
|
|
5630
|
-
}),
|
|
6101
|
+
}), li = R.create({
|
|
5631
6102
|
name: "qingwuUI",
|
|
5632
6103
|
addStorage() {
|
|
5633
6104
|
return {};
|
|
@@ -5635,7 +6106,7 @@ var Vr = R.create({
|
|
|
5635
6106
|
});
|
|
5636
6107
|
//#endregion
|
|
5637
6108
|
//#region src/editor/utils/render-probe.ts
|
|
5638
|
-
function
|
|
6109
|
+
function ui(e, t) {
|
|
5639
6110
|
return new Promise((n) => {
|
|
5640
6111
|
if (typeof Image != "function") return n(!0);
|
|
5641
6112
|
let r = new Image(), i = !1, a = setTimeout(() => o(!1), t), o = (e) => {
|
|
@@ -5644,14 +6115,14 @@ function Ur(e, t) {
|
|
|
5644
6115
|
r.onload = () => o(!0), r.onerror = () => o(!1), r.src = e;
|
|
5645
6116
|
});
|
|
5646
6117
|
}
|
|
5647
|
-
async function
|
|
5648
|
-
if (await
|
|
6118
|
+
async function di(e, t = 8e3) {
|
|
6119
|
+
if (await ui(e, t)) return !0;
|
|
5649
6120
|
try {
|
|
5650
6121
|
let r = await n(e);
|
|
5651
6122
|
if (!r) return !1;
|
|
5652
6123
|
let i = await fetch(e, { headers: r });
|
|
5653
6124
|
if (!i.ok) return !1;
|
|
5654
|
-
let a = URL.createObjectURL(await i.blob()), o = await
|
|
6125
|
+
let a = URL.createObjectURL(await i.blob()), o = await ui(a, t);
|
|
5655
6126
|
return URL.revokeObjectURL(a), o;
|
|
5656
6127
|
} catch {
|
|
5657
6128
|
return !1;
|
|
@@ -5659,7 +6130,7 @@ async function Wr(e, t = 8e3) {
|
|
|
5659
6130
|
}
|
|
5660
6131
|
//#endregion
|
|
5661
6132
|
//#region src/editor/utils/resolve-local-media.ts
|
|
5662
|
-
function
|
|
6133
|
+
function fi() {
|
|
5663
6134
|
return {
|
|
5664
6135
|
uploaded: 0,
|
|
5665
6136
|
sessionOnly: 0,
|
|
@@ -5669,10 +6140,10 @@ function Gr() {
|
|
|
5669
6140
|
readFailed: []
|
|
5670
6141
|
};
|
|
5671
6142
|
}
|
|
5672
|
-
function
|
|
6143
|
+
function pi(e, t) {
|
|
5673
6144
|
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);
|
|
5674
6145
|
}
|
|
5675
|
-
function
|
|
6146
|
+
function mi(e, t, n, r) {
|
|
5676
6147
|
let { state: i } = e, a = [];
|
|
5677
6148
|
if (i.doc.descendants((e, n) => {
|
|
5678
6149
|
e.attrs?.src === t && a.push(n);
|
|
@@ -5688,7 +6159,7 @@ function qr(e, t, n, r) {
|
|
|
5688
6159
|
}
|
|
5689
6160
|
return e.dispatch(o), !0;
|
|
5690
6161
|
}
|
|
5691
|
-
function
|
|
6162
|
+
function hi(e, t, n) {
|
|
5692
6163
|
let { state: r } = e, i = r.schema.marks.link;
|
|
5693
6164
|
if (!i) return !1;
|
|
5694
6165
|
let a = [];
|
|
@@ -5706,7 +6177,7 @@ function Jr(e, t, n) {
|
|
|
5706
6177
|
}));
|
|
5707
6178
|
return e.dispatch(o), !0;
|
|
5708
6179
|
}
|
|
5709
|
-
function
|
|
6180
|
+
function gi(e) {
|
|
5710
6181
|
let t = /* @__PURE__ */ new Map();
|
|
5711
6182
|
for (let n of e) {
|
|
5712
6183
|
let e = t.get(n.normalized);
|
|
@@ -5714,36 +6185,36 @@ function Yr(e) {
|
|
|
5714
6185
|
}
|
|
5715
6186
|
return Array.from(t.values());
|
|
5716
6187
|
}
|
|
5717
|
-
async function
|
|
6188
|
+
async function _i(e, t, n, r) {
|
|
5718
6189
|
if (n.length === 0) return "sessionOnly";
|
|
5719
|
-
let i = n[0], a =
|
|
6190
|
+
let i = n[0], a = pn(t);
|
|
5720
6191
|
if (a) {
|
|
5721
|
-
let t =
|
|
6192
|
+
let t = mn(e.state.doc, r, a);
|
|
5722
6193
|
if (t) return Z(`${i.basename}:${t}`, "error"), "limitRejected";
|
|
5723
6194
|
}
|
|
5724
6195
|
let s = n.filter((e) => !e.isLink), c = n.filter((e) => e.isLink);
|
|
5725
6196
|
if (s.length === 0) try {
|
|
5726
6197
|
let t = await o().upload(r, "editor"), n = !1;
|
|
5727
|
-
for (let r of c)
|
|
6198
|
+
for (let r of c) hi(e, r.src, t) && (n = !0);
|
|
5728
6199
|
return n ? "uploaded" : "sessionOnly";
|
|
5729
6200
|
} catch (e) {
|
|
5730
6201
|
return console.error(`本地附件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), "sessionOnly";
|
|
5731
6202
|
}
|
|
5732
6203
|
let l = URL.createObjectURL(r), u = !1;
|
|
5733
|
-
for (let t of s)
|
|
6204
|
+
for (let t of s) mi(e, t.src, l, r.size) && (u = !0);
|
|
5734
6205
|
let d;
|
|
5735
6206
|
try {
|
|
5736
6207
|
d = await o().upload(r, "editor");
|
|
5737
6208
|
} catch (e) {
|
|
5738
6209
|
return console.error(`本地文件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), URL.revokeObjectURL(l), "sessionOnly";
|
|
5739
6210
|
}
|
|
5740
|
-
URL.revokeObjectURL(l), u &&
|
|
5741
|
-
for (let t of c)
|
|
5742
|
-
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await
|
|
6211
|
+
URL.revokeObjectURL(l), u && mi(e, l, d, r.size);
|
|
6212
|
+
for (let t of c) hi(e, t.src, d);
|
|
6213
|
+
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await di(d) ? "uploaded" : "renderFailed" : "uploaded";
|
|
5743
6214
|
}
|
|
5744
|
-
function
|
|
6215
|
+
function vi(e, t) {
|
|
5745
6216
|
let n = [], r = [];
|
|
5746
|
-
for (let i of
|
|
6217
|
+
for (let i of gi(e)) {
|
|
5747
6218
|
let e = i[0], a = t.get(e.basename);
|
|
5748
6219
|
a ? (n.push({
|
|
5749
6220
|
refs: i,
|
|
@@ -5755,30 +6226,30 @@ function Zr(e, t) {
|
|
|
5755
6226
|
unmatched: r
|
|
5756
6227
|
};
|
|
5757
6228
|
}
|
|
5758
|
-
async function
|
|
5759
|
-
let i =
|
|
5760
|
-
for (let a of
|
|
5761
|
-
let n = a[0], { file: o, readError: s } = await
|
|
6229
|
+
async function yi(e, t, n, r) {
|
|
6230
|
+
let i = fi();
|
|
6231
|
+
for (let a of gi(n)) {
|
|
6232
|
+
let n = a[0], { file: o, readError: s } = await Dr(r, n.src);
|
|
5762
6233
|
if (!o) {
|
|
5763
6234
|
s ? (console.warn(`本地文件「${n.basename}」在所选文件夹中找到但读取失败:`, s), i.readFailed.push(n)) : (console.warn(`本地文件「${n.basename}」未在所选文件夹「${r.name}」中找到`), i.missing.push(n));
|
|
5764
6235
|
continue;
|
|
5765
6236
|
}
|
|
5766
|
-
let c = await
|
|
6237
|
+
let c = await _i(e, t, a, o);
|
|
5767
6238
|
i[c]++;
|
|
5768
6239
|
}
|
|
5769
6240
|
return i;
|
|
5770
6241
|
}
|
|
5771
|
-
function
|
|
6242
|
+
function bi(e) {
|
|
5772
6243
|
let t = e.map((e) => e.basename);
|
|
5773
6244
|
return t.length <= 3 ? t.join("、") : `${t.slice(0, 3).join("、")} 等 ${t.length} 个文件`;
|
|
5774
6245
|
}
|
|
5775
|
-
function
|
|
6246
|
+
function xi(e) {
|
|
5776
6247
|
let t = [];
|
|
5777
|
-
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} 个找到但读取失败:${
|
|
6248
|
+
if (e.uploaded > 0 && t.push(`${e.uploaded} 个已上传至存储`), e.sessionOnly > 0 && t.push(`${e.sessionOnly} 个仅本次会话可见(未配置存储或上传失败)`), e.limitRejected > 0 && t.push(`${e.limitRejected} 个超出大小限制`), e.renderFailed > 0 && t.push(`${e.renderFailed} 个上传成功但页面渲染失败(存储 URL 无法在浏览器访问/解码)`), e.readFailed.length > 0 && t.push(`${e.readFailed.length} 个找到但读取失败:${bi(e.readFailed)}(若在 OneDrive / WPS 云盘等同步目录,请右键文件选择「始终保留在此设备」后重试)`), e.missing.length > 0 && t.push(`${e.missing.length} 个未能获取:${bi(e.missing)}(可把文件直接拖进编辑器上传)`), t.length === 0) return;
|
|
5778
6249
|
let n = e.uploaded > 0 && e.renderFailed === 0 && e.missing.length === 0 && e.readFailed.length === 0;
|
|
5779
6250
|
Z(`本地文件解析完成:${t.join(";")}`, n ? "success" : "info");
|
|
5780
6251
|
}
|
|
5781
|
-
function
|
|
6252
|
+
function Si(e) {
|
|
5782
6253
|
return new Promise((t) => {
|
|
5783
6254
|
let n = document.createElement("div");
|
|
5784
6255
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5805,7 +6276,7 @@ function ti(e) {
|
|
|
5805
6276
|
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);
|
|
5806
6277
|
});
|
|
5807
6278
|
}
|
|
5808
|
-
function
|
|
6279
|
+
function Ci(e) {
|
|
5809
6280
|
let t = document.createElement("div");
|
|
5810
6281
|
t.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
5811
6282
|
let n = document.createElement("div");
|
|
@@ -5827,7 +6298,7 @@ function ni(e) {
|
|
|
5827
6298
|
let c = document.createElement("button");
|
|
5828
6299
|
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);
|
|
5829
6300
|
}
|
|
5830
|
-
function
|
|
6301
|
+
function wi(e) {
|
|
5831
6302
|
return new Promise((t) => {
|
|
5832
6303
|
let n = document.createElement("div");
|
|
5833
6304
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5853,8 +6324,8 @@ function ri(e) {
|
|
|
5853
6324
|
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);
|
|
5854
6325
|
});
|
|
5855
6326
|
}
|
|
5856
|
-
async function
|
|
5857
|
-
let r =
|
|
6327
|
+
async function Ti(e, t, n) {
|
|
6328
|
+
let r = fi(), i = gi(n), a = await wr();
|
|
5858
6329
|
if (!a) {
|
|
5859
6330
|
for (let e of i) r.missing.push(e[0]);
|
|
5860
6331
|
return r;
|
|
@@ -5867,14 +6338,14 @@ async function ii(e, t, n) {
|
|
|
5867
6338
|
continue;
|
|
5868
6339
|
}
|
|
5869
6340
|
o.delete(i.basename);
|
|
5870
|
-
let s = await
|
|
6341
|
+
let s = await _i(e, t, n, a);
|
|
5871
6342
|
r[s]++;
|
|
5872
6343
|
}
|
|
5873
6344
|
return r;
|
|
5874
6345
|
}
|
|
5875
6346
|
//#endregion
|
|
5876
6347
|
//#region src/editor/extensions/relative-media.ts
|
|
5877
|
-
var
|
|
6348
|
+
var Ei = R.create({
|
|
5878
6349
|
name: "relativeMedia",
|
|
5879
6350
|
addStorage() {
|
|
5880
6351
|
return {
|
|
@@ -5884,42 +6355,42 @@ var ai = R.create({
|
|
|
5884
6355
|
},
|
|
5885
6356
|
addProseMirrorPlugins() {
|
|
5886
6357
|
let e = this.editor, t = this.storage, n = !1, r = null, i = async (n, i) => {
|
|
5887
|
-
let a = e.view, o =
|
|
6358
|
+
let a = e.view, o = fi(), { matched: s, unmatched: c } = vi(n, t.clipboardFiles);
|
|
5888
6359
|
for (let { refs: t, file: n } of s) {
|
|
5889
|
-
let r = await
|
|
6360
|
+
let r = await _i(a, e, t, n);
|
|
5890
6361
|
o[r]++;
|
|
5891
6362
|
}
|
|
5892
6363
|
if (c.length > 0) {
|
|
5893
|
-
let t =
|
|
5894
|
-
if (
|
|
6364
|
+
let t = gi(c).length;
|
|
6365
|
+
if (xr()) {
|
|
5895
6366
|
let n = i ?? null;
|
|
5896
|
-
if (n || (await
|
|
5897
|
-
r = n,
|
|
6367
|
+
if (n || (await Si(t) === "pick" ? (n = await Sr(), n || Z("没有选择文件夹。本地文件暂以占位显示,稍后可直接把文件拖进编辑器上传", "info")) : Z("已选择稍后处理。本地文件暂以占位显示,可直接把文件拖进编辑器上传", "info")), n) {
|
|
6368
|
+
r = n, pi(o, await yi(a, e, c, n));
|
|
5898
6369
|
let t = [...o.missing, ...o.readFailed];
|
|
5899
|
-
if (t.length > 0 &&
|
|
5900
|
-
let n = await
|
|
5901
|
-
|
|
6370
|
+
if (t.length > 0 && Cr() && await wi(t.map((e) => e.basename)) === "pick") {
|
|
6371
|
+
let n = await Ti(a, e, t);
|
|
6372
|
+
pi(o, n), o.missing = n.missing, o.readFailed = [];
|
|
5902
6373
|
}
|
|
5903
6374
|
}
|
|
5904
|
-
} else
|
|
6375
|
+
} else Ci(t);
|
|
5905
6376
|
}
|
|
5906
|
-
|
|
6377
|
+
xi(o);
|
|
5907
6378
|
}, o = () => {
|
|
5908
6379
|
if (!e || e.isDestroyed || t.pausedUntilPaste) return;
|
|
5909
|
-
let o = a(), s =
|
|
6380
|
+
let o = a(), s = kr(e.state.doc, o);
|
|
5910
6381
|
if (s.length === 0 || n) return;
|
|
5911
6382
|
n = !0;
|
|
5912
6383
|
let c = new Set(s.map((e) => e.src));
|
|
5913
6384
|
i(s).then(() => {
|
|
5914
6385
|
if (e.isDestroyed) return;
|
|
5915
|
-
let t =
|
|
6386
|
+
let t = kr(e.state.doc, o).filter((e) => !c.has(e.src));
|
|
5916
6387
|
if (t.length !== 0) return i(t, r);
|
|
5917
6388
|
}).finally(() => {
|
|
5918
|
-
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste =
|
|
6389
|
+
n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste = kr(e.state.doc, o).length > 0);
|
|
5919
6390
|
});
|
|
5920
6391
|
};
|
|
5921
|
-
return [new
|
|
5922
|
-
key: new
|
|
6392
|
+
return [new V({
|
|
6393
|
+
key: new H("relativeMedia"),
|
|
5923
6394
|
props: { handlePaste(e, n) {
|
|
5924
6395
|
let r = n.clipboardData?.files;
|
|
5925
6396
|
return t.clipboardFiles = new Map(Array.from(r ?? []).map((e) => [e.name.toLowerCase(), e])), t.pausedUntilPaste = !1, !1;
|
|
@@ -5929,18 +6400,18 @@ var ai = R.create({
|
|
|
5929
6400
|
}
|
|
5930
6401
|
})];
|
|
5931
6402
|
}
|
|
5932
|
-
}),
|
|
5933
|
-
function
|
|
6403
|
+
}), Di = new H("slashCommand");
|
|
6404
|
+
function Oi(e) {
|
|
5934
6405
|
return R.create({
|
|
5935
6406
|
name: "slashCommand",
|
|
5936
6407
|
addProseMirrorPlugins() {
|
|
5937
6408
|
let t = {
|
|
5938
6409
|
char: "/",
|
|
5939
|
-
pluginKey:
|
|
6410
|
+
pluginKey: Di,
|
|
5940
6411
|
findSuggestionMatch: (e) => {
|
|
5941
6412
|
let { $position: t } = e;
|
|
5942
6413
|
for (let e = t.depth; e >= 0; e--) if (t.node(e).type.name === "codeBlock") return null;
|
|
5943
|
-
return t.marks().some((e) => e.type.name === "code") ? null :
|
|
6414
|
+
return t.marks().some((e) => e.type.name === "code") ? null : Ee(e);
|
|
5944
6415
|
},
|
|
5945
6416
|
allow: ({ editor: e, state: t }) => {
|
|
5946
6417
|
if (!e.isEditable) return !1;
|
|
@@ -6022,7 +6493,7 @@ function si(e) {
|
|
|
6022
6493
|
if (e.key === "Escape") {
|
|
6023
6494
|
e.preventDefault();
|
|
6024
6495
|
let t = a?.view;
|
|
6025
|
-
t &&
|
|
6496
|
+
t && Te(t, Di);
|
|
6026
6497
|
}
|
|
6027
6498
|
});
|
|
6028
6499
|
}
|
|
@@ -6040,7 +6511,7 @@ function si(e) {
|
|
|
6040
6511
|
if (!e || e.style.display === "none" || n.target instanceof Node && e.contains(n.target) || t) return;
|
|
6041
6512
|
let r = a?.view;
|
|
6042
6513
|
r && (t = !0, window.setTimeout(() => {
|
|
6043
|
-
t = !1, e?.style.display !== "none" &&
|
|
6514
|
+
t = !1, e?.style.display !== "none" && Te(r, Di);
|
|
6044
6515
|
}, 0));
|
|
6045
6516
|
}, document.addEventListener("mousedown", o, !0), document.addEventListener("touchstart", o, !0);
|
|
6046
6517
|
}
|
|
@@ -6064,11 +6535,11 @@ function si(e) {
|
|
|
6064
6535
|
};
|
|
6065
6536
|
}
|
|
6066
6537
|
};
|
|
6067
|
-
return [
|
|
6538
|
+
return [we({
|
|
6068
6539
|
editor: this.editor,
|
|
6069
6540
|
...t
|
|
6070
|
-
}), new
|
|
6071
|
-
key: new
|
|
6541
|
+
}), new V({
|
|
6542
|
+
key: new H("slashCodeBlockGuard"),
|
|
6072
6543
|
appendTransaction: (e, t, n) => {
|
|
6073
6544
|
let { $from: r } = n.selection, i = !1;
|
|
6074
6545
|
for (let e = r.depth; e >= 0; e--) if (r.node(e).type.name === "codeBlock") {
|
|
@@ -6076,14 +6547,14 @@ function si(e) {
|
|
|
6076
6547
|
break;
|
|
6077
6548
|
}
|
|
6078
6549
|
if (!i && !r.marks().some((e) => e.type.name === "code")) return null;
|
|
6079
|
-
let a =
|
|
6080
|
-
return a && a.active ? n.tr.setMeta(
|
|
6550
|
+
let a = Di.getState(n);
|
|
6551
|
+
return a && a.active ? n.tr.setMeta(Di, { exit: !0 }) : null;
|
|
6081
6552
|
}
|
|
6082
6553
|
})];
|
|
6083
6554
|
}
|
|
6084
6555
|
});
|
|
6085
6556
|
}
|
|
6086
|
-
function
|
|
6557
|
+
function ki(e, t) {
|
|
6087
6558
|
return [
|
|
6088
6559
|
{
|
|
6089
6560
|
title: e("editor.slash.heading1"),
|
|
@@ -6157,6 +6628,24 @@ function ci(e, t) {
|
|
|
6157
6628
|
icon: "—",
|
|
6158
6629
|
command: ({ editor: e }) => e.chain().focus().setHorizontalRule().run()
|
|
6159
6630
|
},
|
|
6631
|
+
{
|
|
6632
|
+
title: e("editor.slash.mathInline"),
|
|
6633
|
+
description: e("editor.slash.mathInlineDesc"),
|
|
6634
|
+
icon: "∑",
|
|
6635
|
+
command: ({ editor: e }) => e.chain().focus().insertContent({
|
|
6636
|
+
type: "mathInline",
|
|
6637
|
+
attrs: { latex: "" }
|
|
6638
|
+
}).run()
|
|
6639
|
+
},
|
|
6640
|
+
{
|
|
6641
|
+
title: e("editor.slash.mathBlock"),
|
|
6642
|
+
description: e("editor.slash.mathBlockDesc"),
|
|
6643
|
+
icon: "∫",
|
|
6644
|
+
command: ({ editor: e }) => e.chain().focus().insertContent({
|
|
6645
|
+
type: "mathBlock",
|
|
6646
|
+
attrs: { latex: "" }
|
|
6647
|
+
}).run()
|
|
6648
|
+
},
|
|
6160
6649
|
{
|
|
6161
6650
|
title: e("editor.slash.image"),
|
|
6162
6651
|
description: e("editor.slash.imageDesc"),
|
|
@@ -6182,7 +6671,7 @@ function ci(e, t) {
|
|
|
6182
6671
|
n.type = "file", n.accept = "audio/*", n.onchange = async () => {
|
|
6183
6672
|
let r = n.files?.[0];
|
|
6184
6673
|
if (!r) return;
|
|
6185
|
-
let i =
|
|
6674
|
+
let i = pn(e) ?? t, a = i ? mn(e.state.doc, r, i) : null;
|
|
6186
6675
|
if (a) {
|
|
6187
6676
|
Z(a);
|
|
6188
6677
|
return;
|
|
@@ -6192,7 +6681,7 @@ function ci(e, t) {
|
|
|
6192
6681
|
name: r.name,
|
|
6193
6682
|
size: r.size
|
|
6194
6683
|
});
|
|
6195
|
-
s && (e.chain().focus().insertContent(s).run(), await
|
|
6684
|
+
s && (e.chain().focus().insertContent(s).run(), await Fr(e.view, r, o));
|
|
6196
6685
|
}, n.click();
|
|
6197
6686
|
}
|
|
6198
6687
|
},
|
|
@@ -6205,7 +6694,7 @@ function ci(e, t) {
|
|
|
6205
6694
|
n.type = "file", n.accept = "*/*", n.multiple = !0, n.onchange = async () => {
|
|
6206
6695
|
let r = n.files;
|
|
6207
6696
|
if (!(!r || r.length === 0)) for (let n of Array.from(r)) {
|
|
6208
|
-
let r =
|
|
6697
|
+
let r = pn(e) ?? t, i = r ? mn(e.state.doc, n, r) : null;
|
|
6209
6698
|
if (i) {
|
|
6210
6699
|
Z(i);
|
|
6211
6700
|
continue;
|
|
@@ -6222,7 +6711,7 @@ function ci(e, t) {
|
|
|
6222
6711
|
} catch {
|
|
6223
6712
|
continue;
|
|
6224
6713
|
}
|
|
6225
|
-
await
|
|
6714
|
+
await Fr(e.view, n, a);
|
|
6226
6715
|
}
|
|
6227
6716
|
}
|
|
6228
6717
|
}, n.click();
|
|
@@ -6232,9 +6721,9 @@ function ci(e, t) {
|
|
|
6232
6721
|
}
|
|
6233
6722
|
//#endregion
|
|
6234
6723
|
//#region src/editor/extensions/index.ts
|
|
6235
|
-
var
|
|
6724
|
+
var Ai = W.extend({
|
|
6236
6725
|
addNodeView() {
|
|
6237
|
-
return
|
|
6726
|
+
return F(Tn);
|
|
6238
6727
|
},
|
|
6239
6728
|
addAttributes() {
|
|
6240
6729
|
return {
|
|
@@ -6257,7 +6746,7 @@ var li = U.extend({
|
|
|
6257
6746
|
};
|
|
6258
6747
|
}
|
|
6259
6748
|
});
|
|
6260
|
-
function
|
|
6749
|
+
function ji(e = {}) {
|
|
6261
6750
|
return [
|
|
6262
6751
|
K.configure({
|
|
6263
6752
|
codeBlock: !1,
|
|
@@ -6266,104 +6755,106 @@ function ui(e = {}) {
|
|
|
6266
6755
|
link: !1
|
|
6267
6756
|
}),
|
|
6268
6757
|
G,
|
|
6269
|
-
|
|
6758
|
+
se.configure({
|
|
6270
6759
|
openOnClick: !0,
|
|
6271
6760
|
HTMLAttributes: {
|
|
6272
6761
|
rel: "noopener noreferrer",
|
|
6273
6762
|
target: "_blank"
|
|
6274
6763
|
}
|
|
6275
6764
|
}),
|
|
6276
|
-
|
|
6765
|
+
Ai.configure({
|
|
6277
6766
|
inline: !1,
|
|
6278
6767
|
allowBase64: !0
|
|
6279
6768
|
}),
|
|
6280
6769
|
ge,
|
|
6281
6770
|
he.configure({ nested: !0 }),
|
|
6282
|
-
|
|
6771
|
+
le.configure({ multicolor: !0 }),
|
|
6283
6772
|
_e,
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6773
|
+
q,
|
|
6774
|
+
ce.configure(e.maxLength ? { limit: e.maxLength } : {}),
|
|
6775
|
+
ue,
|
|
6776
|
+
Br,
|
|
6777
|
+
ei,
|
|
6778
|
+
ti,
|
|
6779
|
+
pr,
|
|
6780
|
+
fe.configure({ resizable: !0 }),
|
|
6290
6781
|
me,
|
|
6291
|
-
|
|
6782
|
+
J,
|
|
6292
6783
|
pe,
|
|
6293
6784
|
ve.configure({
|
|
6294
6785
|
html: !0,
|
|
6295
6786
|
transformPastedText: !0,
|
|
6296
6787
|
transformCopiedText: !1
|
|
6297
6788
|
}),
|
|
6298
|
-
|
|
6299
|
-
|
|
6789
|
+
de.configure({ placeholder: e.placeholder || "输入 '/' 打开菜单…" }),
|
|
6790
|
+
Oi(() => ki((e) => f(e), {
|
|
6300
6791
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6301
6792
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6302
6793
|
})),
|
|
6303
|
-
|
|
6794
|
+
Lr.configure({
|
|
6304
6795
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6305
6796
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6306
6797
|
}),
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6798
|
+
Ei,
|
|
6799
|
+
ci,
|
|
6800
|
+
At,
|
|
6801
|
+
zr,
|
|
6802
|
+
li,
|
|
6803
|
+
Xn,
|
|
6804
|
+
Un,
|
|
6805
|
+
Bn
|
|
6315
6806
|
];
|
|
6316
6807
|
}
|
|
6317
6808
|
//#endregion
|
|
6318
6809
|
//#region src/editor/extensions/bubble-menu.tsx
|
|
6319
|
-
var
|
|
6320
|
-
function
|
|
6321
|
-
|
|
6810
|
+
var Mi = "https://www.bing.com/search?q={query}";
|
|
6811
|
+
function Ni(e) {
|
|
6812
|
+
Mi = e;
|
|
6322
6813
|
}
|
|
6323
|
-
function
|
|
6324
|
-
return
|
|
6814
|
+
function Pi() {
|
|
6815
|
+
return Mi;
|
|
6325
6816
|
}
|
|
6326
|
-
function
|
|
6817
|
+
function Fi(e) {
|
|
6327
6818
|
return [
|
|
6328
6819
|
{
|
|
6329
6820
|
key: "bold",
|
|
6330
6821
|
label: e("editor.bubble.bold"),
|
|
6331
|
-
icon: /* @__PURE__ */ D(
|
|
6822
|
+
icon: /* @__PURE__ */ D(Nt, {}),
|
|
6332
6823
|
isActive: (e) => e.isActive("bold"),
|
|
6333
6824
|
command: (e) => e.isEditable && e.chain().focus().toggleBold().run()
|
|
6334
6825
|
},
|
|
6335
6826
|
{
|
|
6336
6827
|
key: "italic",
|
|
6337
6828
|
label: e("editor.bubble.italic"),
|
|
6338
|
-
icon: /* @__PURE__ */ D(
|
|
6829
|
+
icon: /* @__PURE__ */ D(Pt, {}),
|
|
6339
6830
|
isActive: (e) => e.isActive("italic"),
|
|
6340
6831
|
command: (e) => e.isEditable && e.chain().focus().toggleItalic().run()
|
|
6341
6832
|
},
|
|
6342
6833
|
{
|
|
6343
6834
|
key: "underline",
|
|
6344
6835
|
label: e("editor.bubble.underline"),
|
|
6345
|
-
icon: /* @__PURE__ */ D(
|
|
6836
|
+
icon: /* @__PURE__ */ D(Ft, {}),
|
|
6346
6837
|
isActive: (e) => e.isActive("underline"),
|
|
6347
6838
|
command: (e) => e.isEditable && e.chain().focus().toggleUnderline().run()
|
|
6348
6839
|
},
|
|
6349
6840
|
{
|
|
6350
6841
|
key: "strikethrough",
|
|
6351
6842
|
label: e("editor.bubble.strikethrough"),
|
|
6352
|
-
icon: /* @__PURE__ */ D(
|
|
6843
|
+
icon: /* @__PURE__ */ D(It, {}),
|
|
6353
6844
|
isActive: (e) => e.isActive("strike"),
|
|
6354
6845
|
command: (e) => e.isEditable && e.chain().focus().toggleStrike().run()
|
|
6355
6846
|
},
|
|
6356
6847
|
{
|
|
6357
6848
|
key: "code",
|
|
6358
6849
|
label: e("editor.bubble.emphasis"),
|
|
6359
|
-
icon: /* @__PURE__ */ D(
|
|
6850
|
+
icon: /* @__PURE__ */ D(Lt, {}),
|
|
6360
6851
|
isActive: (e) => e.isActive("code"),
|
|
6361
6852
|
command: (e) => e.isEditable && e.chain().focus().toggleCode().run()
|
|
6362
6853
|
},
|
|
6363
6854
|
{
|
|
6364
6855
|
key: "highlight",
|
|
6365
6856
|
label: e("editor.bubble.highlight"),
|
|
6366
|
-
icon: /* @__PURE__ */ D(
|
|
6857
|
+
icon: /* @__PURE__ */ D(Rt, {}),
|
|
6367
6858
|
more: !0,
|
|
6368
6859
|
isActive: (e) => e.isActive("highlight"),
|
|
6369
6860
|
command: () => {}
|
|
@@ -6371,7 +6862,7 @@ function mi(e) {
|
|
|
6371
6862
|
{
|
|
6372
6863
|
key: "link",
|
|
6373
6864
|
label: e("editor.bubble.link"),
|
|
6374
|
-
icon: /* @__PURE__ */ D(
|
|
6865
|
+
icon: /* @__PURE__ */ D(zt, {}),
|
|
6375
6866
|
more: !0,
|
|
6376
6867
|
isActive: (e) => e.isActive("link"),
|
|
6377
6868
|
command: () => {}
|
|
@@ -6379,7 +6870,7 @@ function mi(e) {
|
|
|
6379
6870
|
{
|
|
6380
6871
|
key: "copy",
|
|
6381
6872
|
label: e("editor.bubble.copy"),
|
|
6382
|
-
icon: /* @__PURE__ */ D(
|
|
6873
|
+
icon: /* @__PURE__ */ D(Vt, {}),
|
|
6383
6874
|
more: !0,
|
|
6384
6875
|
isActive: () => !1,
|
|
6385
6876
|
command: (e) => {
|
|
@@ -6390,21 +6881,21 @@ function mi(e) {
|
|
|
6390
6881
|
{
|
|
6391
6882
|
key: "search",
|
|
6392
6883
|
label: e("editor.bubble.search"),
|
|
6393
|
-
icon: /* @__PURE__ */ D(
|
|
6884
|
+
icon: /* @__PURE__ */ D(Ht, {}),
|
|
6394
6885
|
more: !0,
|
|
6395
6886
|
isActive: () => !1,
|
|
6396
6887
|
command: (e) => {
|
|
6397
6888
|
if (e.isActive("table")) return;
|
|
6398
6889
|
let { from: t, to: n } = e.state.selection, r = e.state.doc.textBetween(t, n, " ").trim();
|
|
6399
6890
|
if (!r) return;
|
|
6400
|
-
let i =
|
|
6891
|
+
let i = Mi.replace("{query}", encodeURIComponent(r));
|
|
6401
6892
|
window.open(i, "_blank", "noopener,noreferrer");
|
|
6402
6893
|
}
|
|
6403
6894
|
},
|
|
6404
6895
|
{
|
|
6405
6896
|
key: "table",
|
|
6406
6897
|
label: e("editor.bubble.table"),
|
|
6407
|
-
icon: /* @__PURE__ */ D(
|
|
6898
|
+
icon: /* @__PURE__ */ D(Bt, {}),
|
|
6408
6899
|
more: !0,
|
|
6409
6900
|
isActive: (e) => e.isActive("table"),
|
|
6410
6901
|
command: (e) => {
|
|
@@ -6420,7 +6911,7 @@ function mi(e) {
|
|
|
6420
6911
|
{
|
|
6421
6912
|
key: "ai",
|
|
6422
6913
|
label: e("editor.ai.trigger"),
|
|
6423
|
-
icon: /* @__PURE__ */ D(
|
|
6914
|
+
icon: /* @__PURE__ */ D(Ut, {}),
|
|
6424
6915
|
isActive: () => !1,
|
|
6425
6916
|
command: (e) => {
|
|
6426
6917
|
e.isEditable && e.storage.qingwuUI?.openAI?.();
|
|
@@ -6431,7 +6922,7 @@ function mi(e) {
|
|
|
6431
6922
|
R.create({ name: "bubbleMenu" });
|
|
6432
6923
|
//#endregion
|
|
6433
6924
|
//#region src/editor/extensions/table-toolbar.tsx
|
|
6434
|
-
function
|
|
6925
|
+
function Ii(e) {
|
|
6435
6926
|
let { $from: t } = e.state.selection;
|
|
6436
6927
|
for (let e = t.depth; e > 0; e--) {
|
|
6437
6928
|
let n = t.node(e);
|
|
@@ -6442,7 +6933,7 @@ function hi(e) {
|
|
|
6442
6933
|
}
|
|
6443
6934
|
return null;
|
|
6444
6935
|
}
|
|
6445
|
-
function
|
|
6936
|
+
function Li(e) {
|
|
6446
6937
|
let t = [];
|
|
6447
6938
|
return e.forEach((e) => {
|
|
6448
6939
|
let n = [];
|
|
@@ -6451,7 +6942,7 @@ function gi(e) {
|
|
|
6451
6942
|
}), t.push(n);
|
|
6452
6943
|
}), t;
|
|
6453
6944
|
}
|
|
6454
|
-
function
|
|
6945
|
+
function Ri(e) {
|
|
6455
6946
|
if (e.length === 0) return "";
|
|
6456
6947
|
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(" | ")} |`;
|
|
6457
6948
|
return [
|
|
@@ -6460,11 +6951,11 @@ function _i(e) {
|
|
|
6460
6951
|
...i.map(a)
|
|
6461
6952
|
].join("\n");
|
|
6462
6953
|
}
|
|
6463
|
-
function
|
|
6954
|
+
function zi(e) {
|
|
6464
6955
|
let t = (e) => /[",\n]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e;
|
|
6465
6956
|
return e.map((e) => e.map(t).join(",")).join("\n");
|
|
6466
6957
|
}
|
|
6467
|
-
function
|
|
6958
|
+
function Bi(e) {
|
|
6468
6959
|
let t = e.trim();
|
|
6469
6960
|
if (!t) return null;
|
|
6470
6961
|
let n = t.split(/\r?\n/);
|
|
@@ -6478,7 +6969,7 @@ function yi(e) {
|
|
|
6478
6969
|
}
|
|
6479
6970
|
return null;
|
|
6480
6971
|
}
|
|
6481
|
-
function
|
|
6972
|
+
function Vi({ editor: e }) {
|
|
6482
6973
|
let [t, n] = T(null), [r, i] = T(!1), [a, o] = T(!1), s = w(null), c = w(null), l = e.isEditable, u = b(() => {
|
|
6483
6974
|
c.current != null && cancelAnimationFrame(c.current), c.current = requestAnimationFrame(() => {
|
|
6484
6975
|
c.current = null;
|
|
@@ -6494,7 +6985,7 @@ function bi({ editor: e }) {
|
|
|
6494
6985
|
n(null);
|
|
6495
6986
|
return;
|
|
6496
6987
|
}
|
|
6497
|
-
let t =
|
|
6988
|
+
let t = Ii(e);
|
|
6498
6989
|
if (!t) {
|
|
6499
6990
|
n(null);
|
|
6500
6991
|
return;
|
|
@@ -6523,24 +7014,24 @@ function bi({ editor: e }) {
|
|
|
6523
7014
|
});
|
|
6524
7015
|
return n.nodes.table.create(null, i);
|
|
6525
7016
|
}, p = () => {
|
|
6526
|
-
let t =
|
|
7017
|
+
let t = Ii(e);
|
|
6527
7018
|
if (!t) return;
|
|
6528
|
-
let n =
|
|
7019
|
+
let n = Ri(Li(t.node));
|
|
6529
7020
|
navigator.clipboard?.writeText(n), i(!0), setTimeout(() => i(!1), 1500);
|
|
6530
7021
|
}, m = () => {
|
|
6531
|
-
let t =
|
|
7022
|
+
let t = Ii(e);
|
|
6532
7023
|
if (!t) return;
|
|
6533
|
-
let n =
|
|
7024
|
+
let n = zi(Li(t.node)), r = new Blob([`\ufeff${n}`], { type: "text/csv;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
6534
7025
|
a.href = i, a.download = "table.csv", document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
6535
7026
|
}, h = async () => {
|
|
6536
7027
|
if (l) try {
|
|
6537
7028
|
let t = await navigator.clipboard?.readText();
|
|
6538
7029
|
if (!t) return;
|
|
6539
|
-
let n =
|
|
7030
|
+
let n = Bi(t);
|
|
6540
7031
|
if (!n || n.length === 0) return;
|
|
6541
7032
|
let r = f(n);
|
|
6542
7033
|
if (!r) return;
|
|
6543
|
-
let i =
|
|
7034
|
+
let i = Ii(e), a = e.chain().focus();
|
|
6544
7035
|
if (i) {
|
|
6545
7036
|
let t = Math.min(i.pos + i.node.nodeSize, e.state.doc.content.size);
|
|
6546
7037
|
a.setTextSelection(t);
|
|
@@ -6660,7 +7151,7 @@ function bi({ editor: e }) {
|
|
|
6660
7151
|
type: "button",
|
|
6661
7152
|
className: "tbl-btn tbl-btn--del",
|
|
6662
7153
|
onClick: () => {
|
|
6663
|
-
!l ||
|
|
7154
|
+
!l || vn() || ($(!0), o(!0));
|
|
6664
7155
|
},
|
|
6665
7156
|
title: "删除",
|
|
6666
7157
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -6678,7 +7169,7 @@ function bi({ editor: e }) {
|
|
|
6678
7169
|
})
|
|
6679
7170
|
})
|
|
6680
7171
|
}),
|
|
6681
|
-
/* @__PURE__ */ D(
|
|
7172
|
+
/* @__PURE__ */ D(Cn, {
|
|
6682
7173
|
open: a,
|
|
6683
7174
|
title: "确认删除表格",
|
|
6684
7175
|
message: "此操作不可撤销。",
|
|
@@ -6694,7 +7185,7 @@ function bi({ editor: e }) {
|
|
|
6694
7185
|
}
|
|
6695
7186
|
//#endregion
|
|
6696
7187
|
//#region src/editor/ai-editor.tsx
|
|
6697
|
-
var
|
|
7188
|
+
var Hi = [
|
|
6698
7189
|
{
|
|
6699
7190
|
color: "#fef08a",
|
|
6700
7191
|
name: "黄"
|
|
@@ -6719,9 +7210,9 @@ var xi = [
|
|
|
6719
7210
|
color: "#ddd6fe",
|
|
6720
7211
|
name: "紫"
|
|
6721
7212
|
}
|
|
6722
|
-
],
|
|
6723
|
-
function
|
|
6724
|
-
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth ||
|
|
7213
|
+
], Ui = 288, Wi = 480, Gi = 320;
|
|
7214
|
+
function Ki(e, t, n = {}) {
|
|
7215
|
+
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth || Ui, Wi, r - 32), o = Math.max(t || Gi, 160);
|
|
6725
7216
|
if (r < 640) {
|
|
6726
7217
|
let t = Math.max(8, Math.min(e.top + 10, i - 420));
|
|
6727
7218
|
return {
|
|
@@ -6762,10 +7253,10 @@ function Ti(e, t, n = {}) {
|
|
|
6762
7253
|
arrowLeft: p
|
|
6763
7254
|
};
|
|
6764
7255
|
}
|
|
6765
|
-
function
|
|
6766
|
-
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
|
|
7256
|
+
function qi(e) {
|
|
7257
|
+
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);
|
|
6767
7258
|
}
|
|
6768
|
-
function
|
|
7259
|
+
function Ji(e, t) {
|
|
6769
7260
|
try {
|
|
6770
7261
|
let n = e.storage?.markdown?.parser;
|
|
6771
7262
|
if (!n) return null;
|
|
@@ -6775,20 +7266,20 @@ function Di(e, t) {
|
|
|
6775
7266
|
return null;
|
|
6776
7267
|
}
|
|
6777
7268
|
}
|
|
6778
|
-
var
|
|
7269
|
+
var Yi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.ImageUploadDialog }))), Xi = y(() => import("./storage-settings-dialog-DnWNQWjN.js").then((e) => ({ default: e.StorageSettingsDialog }))), Zi = y(() => import("./export-dialog-DMY_QIVq.js").then((e) => ({ default: e.ExportDialog }))), Qi = y(() => import("./video-embed-dialog-B0_pc5xe.js").then((e) => ({ default: e.VideoEmbedDialog }))), $i = y(() => import("./md-import-dialog-DbC-NCH_.js").then((e) => ({ default: e.MdImportDialog }))), ea = () => /* @__PURE__ */ O("div", {
|
|
6779
7270
|
className: "fixed inset-0 z-[9999] flex items-center justify-center",
|
|
6780
7271
|
children: [/* @__PURE__ */ D("div", { className: "absolute inset-0 bg-black/40 backdrop-blur-sm" }), /* @__PURE__ */ D("div", {
|
|
6781
7272
|
className: "relative bg-background rounded-2xl border border-default-200 p-8 flex items-center justify-center",
|
|
6782
7273
|
children: /* @__PURE__ */ D("div", { className: "w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin" })
|
|
6783
7274
|
})]
|
|
6784
|
-
}),
|
|
6785
|
-
let k = r === "view" || i, A = C(() => typeof e == "object" && e ||
|
|
7275
|
+
}), ta = ({ 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 }) => {
|
|
7276
|
+
let k = r === "view" || i, A = C(() => typeof e == "object" && e || qi(e) ? e : d(e), [e]), [j, M] = T(!1), [P, F] = T({}), [I, R] = T("below"), [re, ie] = T(50), z = w(null), [B, V] = T(!1), [H, ae] = T(!1), [oe, U] = T(!1), [W, se] = T(!1), [G, K] = T("none"), [ce, q] = T({}), le = w(null), ue = w(null), [de, fe] = T(""), [J, pe] = T(null), [me, he] = T(m), [ge, _e] = T(!1);
|
|
6786
7277
|
x(() => {
|
|
6787
|
-
|
|
7278
|
+
he(m);
|
|
6788
7279
|
}, [m]);
|
|
6789
|
-
let [
|
|
6790
|
-
let e =
|
|
6791
|
-
e && (
|
|
7280
|
+
let [ve, ye] = T(!1), [be, xe] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 80rem)").matches : !0), [Se, Ce] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 64rem)").matches : !0), we = w(null), Te = w(null), Ee = w(null), De = w(0), Oe = w(null), ke = w(null), Ae = w(null), je = w(null), [Me, Ne] = T(!1), [Y, Pe] = T(!1), [Fe, Ie] = T(!1), Le = w(null), Re = b(() => {
|
|
7281
|
+
let e = Te.current, t = Ee.current;
|
|
7282
|
+
e && (Y ? (document.body.style.overflow = "", Object.assign(e.style, {
|
|
6792
7283
|
position: "",
|
|
6793
7284
|
top: "",
|
|
6794
7285
|
left: "",
|
|
@@ -6804,9 +7295,9 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
6804
7295
|
flex: "",
|
|
6805
7296
|
overflow: "",
|
|
6806
7297
|
minHeight: ""
|
|
6807
|
-
}),
|
|
6808
|
-
window.scrollTo(0,
|
|
6809
|
-
})) : (document.fullscreenElement && document.exitFullscreen(),
|
|
7298
|
+
}), Pe(!1), requestAnimationFrame(() => {
|
|
7299
|
+
window.scrollTo(0, De.current);
|
|
7300
|
+
})) : (document.fullscreenElement && document.exitFullscreen(), De.current = window.scrollY, Object.assign(e.style, {
|
|
6810
7301
|
position: "fixed",
|
|
6811
7302
|
top: "0",
|
|
6812
7303
|
left: "0",
|
|
@@ -6821,42 +7312,42 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
6821
7312
|
flex: "1",
|
|
6822
7313
|
overflow: "auto",
|
|
6823
7314
|
minHeight: "0"
|
|
6824
|
-
}), document.body.style.overflow = "hidden",
|
|
6825
|
-
}, [
|
|
6826
|
-
let e =
|
|
6827
|
-
e && (document.fullscreenElement ? document.exitFullscreen() : (
|
|
6828
|
-
}, [
|
|
7315
|
+
}), document.body.style.overflow = "hidden", Pe(!0)));
|
|
7316
|
+
}, [Y]), ze = b(() => {
|
|
7317
|
+
let e = Te.current;
|
|
7318
|
+
e && (document.fullscreenElement ? document.exitFullscreen() : (Y && Re(), De.current = window.scrollY, e.requestFullscreen()));
|
|
7319
|
+
}, [Y, Re]);
|
|
6829
7320
|
x(() => {
|
|
6830
7321
|
let e = (e) => {
|
|
6831
|
-
e.key === "Escape" &&
|
|
7322
|
+
e.key === "Escape" && Y && Re();
|
|
6832
7323
|
}, t = () => {
|
|
6833
|
-
document.fullscreenElement ?
|
|
6834
|
-
window.scrollTo(0,
|
|
7324
|
+
document.fullscreenElement ? Ie(!0) : (Ie(!1), requestAnimationFrame(() => {
|
|
7325
|
+
window.scrollTo(0, De.current);
|
|
6835
7326
|
}));
|
|
6836
7327
|
};
|
|
6837
7328
|
return window.addEventListener("keydown", e), document.addEventListener("fullscreenchange", t), () => {
|
|
6838
7329
|
window.removeEventListener("keydown", e), document.removeEventListener("fullscreenchange", t);
|
|
6839
7330
|
};
|
|
6840
|
-
}, [
|
|
7331
|
+
}, [Y, Re]), x(() => {
|
|
6841
7332
|
if (!h) return;
|
|
6842
7333
|
let e = (e) => {
|
|
6843
7334
|
if ((e.ctrlKey || e.metaKey) && (e.key === "f" || e.key === "F")) {
|
|
6844
|
-
if (!
|
|
6845
|
-
e.preventDefault(), e.stopPropagation(),
|
|
7335
|
+
if (!Te.current) return;
|
|
7336
|
+
e.preventDefault(), e.stopPropagation(), ye(!0);
|
|
6846
7337
|
}
|
|
6847
7338
|
};
|
|
6848
7339
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
6849
7340
|
}, [h]), x(() => {
|
|
6850
7341
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
6851
|
-
let e = window.matchMedia("(min-width: 80rem)"), t = (e) =>
|
|
6852
|
-
return
|
|
7342
|
+
let e = window.matchMedia("(min-width: 80rem)"), t = (e) => xe(e.matches);
|
|
7343
|
+
return xe(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
6853
7344
|
}, []), x(() => {
|
|
6854
7345
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
6855
|
-
let e = window.matchMedia("(min-width: 64rem)"), t = (e) =>
|
|
6856
|
-
return
|
|
7346
|
+
let e = window.matchMedia("(min-width: 64rem)"), t = (e) => Ce(e.matches);
|
|
7347
|
+
return Ce(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
6857
7348
|
}, []);
|
|
6858
|
-
let
|
|
6859
|
-
extensions:
|
|
7349
|
+
let X = te({
|
|
7350
|
+
extensions: ji({
|
|
6860
7351
|
placeholder: n || f("editor.placeholder"),
|
|
6861
7352
|
maxLength: a,
|
|
6862
7353
|
maxAttachmentSize: o,
|
|
@@ -6866,7 +7357,7 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
6866
7357
|
editable: !k,
|
|
6867
7358
|
immediatelyRender: _,
|
|
6868
7359
|
onUpdate: ({ editor: e }) => {
|
|
6869
|
-
t && (
|
|
7360
|
+
t && (we.current && clearTimeout(we.current), we.current = setTimeout(() => {
|
|
6870
7361
|
t?.(e.getHTML(), e.getJSON());
|
|
6871
7362
|
}, 300));
|
|
6872
7363
|
},
|
|
@@ -6882,9 +7373,9 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
6882
7373
|
let r = n.getData("text/plain");
|
|
6883
7374
|
if (!r || !r.includes("[[")) return !1;
|
|
6884
7375
|
t.preventDefault();
|
|
6885
|
-
let i =
|
|
7376
|
+
let i = ke.current?.storage?.relativeMedia;
|
|
6886
7377
|
i && (i.clipboardFiles = new Map(Array.from(n.files ?? []).map((e) => [e.name.toLowerCase(), e])), i.pausedUntilPaste = !1);
|
|
6887
|
-
let a =
|
|
7378
|
+
let a = ke.current ? Ji(ke.current, r) : null;
|
|
6888
7379
|
if (a) {
|
|
6889
7380
|
let t = new N(a, 0, 0);
|
|
6890
7381
|
e.dispatch(e.state.tr.replaceSelection(t).scrollIntoView());
|
|
@@ -6894,21 +7385,21 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
6894
7385
|
}
|
|
6895
7386
|
});
|
|
6896
7387
|
x(() => {
|
|
6897
|
-
|
|
6898
|
-
}, [
|
|
6899
|
-
if (
|
|
6900
|
-
}, [
|
|
6901
|
-
!
|
|
6902
|
-
}, [
|
|
6903
|
-
if (!
|
|
7388
|
+
ke.current = X, window.__editor = X;
|
|
7389
|
+
}, [X]), x(() => {
|
|
7390
|
+
if (X) return () => $t(X);
|
|
7391
|
+
}, [X]), x(() => {
|
|
7392
|
+
!X || !g || g(X);
|
|
7393
|
+
}, [X, g]), x(() => {
|
|
7394
|
+
if (!X) return;
|
|
6904
7395
|
let e = () => {
|
|
6905
|
-
|
|
7396
|
+
X.state.selection.empty && (K("none"), Ne(!1));
|
|
6906
7397
|
};
|
|
6907
|
-
return
|
|
6908
|
-
|
|
7398
|
+
return X.on("selectionUpdate", e), () => {
|
|
7399
|
+
X.off("selectionUpdate", e);
|
|
6909
7400
|
};
|
|
6910
|
-
}, [
|
|
6911
|
-
|
|
7401
|
+
}, [X]), x(() => {
|
|
7402
|
+
X && X.setOptions({ extensions: ji({
|
|
6912
7403
|
placeholder: n || f("editor.placeholder"),
|
|
6913
7404
|
maxLength: a,
|
|
6914
7405
|
maxAttachmentSize: o,
|
|
@@ -6920,33 +7411,33 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
6920
7411
|
o,
|
|
6921
7412
|
s
|
|
6922
7413
|
]);
|
|
6923
|
-
let
|
|
7414
|
+
let Be = w(e);
|
|
6924
7415
|
x(() => {
|
|
6925
|
-
if (!
|
|
6926
|
-
|
|
6927
|
-
let t = typeof e == "object" && e ||
|
|
6928
|
-
|
|
6929
|
-
}, [
|
|
6930
|
-
|
|
6931
|
-
}, [
|
|
6932
|
-
if (y) return
|
|
7416
|
+
if (!X || e === Be.current) return;
|
|
7417
|
+
Be.current = e;
|
|
7418
|
+
let t = typeof e == "object" && e || qi(e) ? e : d(e);
|
|
7419
|
+
X.commands.setContent(t, { emitUpdate: !1 });
|
|
7420
|
+
}, [X, e]), x(() => {
|
|
7421
|
+
X && X.setEditable(!k, !1);
|
|
7422
|
+
}, [X, k]), x(() => {
|
|
7423
|
+
if (y) return tt(y);
|
|
6933
7424
|
}, [y]), x(() => {
|
|
6934
|
-
if (!
|
|
6935
|
-
let e =
|
|
6936
|
-
e > s && Z(`文档内附件总大小 ${
|
|
6937
|
-
}, [
|
|
6938
|
-
if (!
|
|
6939
|
-
let e =
|
|
7425
|
+
if (!X) return;
|
|
7426
|
+
let e = dn(X.state.doc);
|
|
7427
|
+
e > s && Z(`文档内附件总大小 ${fn(e)} 已超过限制 ${fn(s)}`, "info");
|
|
7428
|
+
}, [X, s]), x(() => {
|
|
7429
|
+
if (!X) return;
|
|
7430
|
+
let e = X.storage.qingwuUI;
|
|
6940
7431
|
e && (e.limits = {
|
|
6941
7432
|
maxAttachmentSize: o,
|
|
6942
7433
|
maxTotalAttachmentSize: s
|
|
6943
7434
|
});
|
|
6944
7435
|
}, [
|
|
6945
|
-
|
|
7436
|
+
X,
|
|
6946
7437
|
o,
|
|
6947
7438
|
s
|
|
6948
7439
|
]);
|
|
6949
|
-
let
|
|
7440
|
+
let Ve = b((e, t) => {
|
|
6950
7441
|
let n = e ? Math.max(8, Math.min(e.left, window.innerWidth - 240 - 8)) : 8, r;
|
|
6951
7442
|
return r = e ? t && e.bottom + 8 + t > window.innerHeight ? Math.max(8, e.top - t - 8) : e.bottom + 8 : 8, {
|
|
6952
7443
|
position: "fixed",
|
|
@@ -6955,65 +7446,65 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
6955
7446
|
zIndex: 9999
|
|
6956
7447
|
};
|
|
6957
7448
|
}, []), He = b((e) => {
|
|
6958
|
-
let t =
|
|
6959
|
-
ue.current = t,
|
|
6960
|
-
}, [
|
|
7449
|
+
let t = je.current?.getBoundingClientRect() ?? null;
|
|
7450
|
+
ue.current = t, K(e), Ne(!1), q(Ve(t, void 0));
|
|
7451
|
+
}, [Ve]);
|
|
6961
7452
|
S(() => {
|
|
6962
|
-
if (
|
|
7453
|
+
if (G === "none") return;
|
|
6963
7454
|
let e = le.current;
|
|
6964
|
-
|
|
6965
|
-
}, [
|
|
6966
|
-
if (
|
|
6967
|
-
let e = () =>
|
|
7455
|
+
q(Ve(ue.current, e?.offsetHeight || void 0));
|
|
7456
|
+
}, [G, Ve]), x(() => {
|
|
7457
|
+
if (G === "none") return;
|
|
7458
|
+
let e = () => K("none"), t = () => {
|
|
6968
7459
|
let e = le.current;
|
|
6969
|
-
|
|
7460
|
+
q(Ve(ue.current, e?.offsetHeight || void 0));
|
|
6970
7461
|
};
|
|
6971
7462
|
return window.addEventListener("scroll", e, !0), window.addEventListener("resize", t), () => {
|
|
6972
7463
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", t);
|
|
6973
7464
|
};
|
|
6974
|
-
}, [
|
|
6975
|
-
|
|
6976
|
-
}, [
|
|
6977
|
-
let Ue =
|
|
6978
|
-
if (
|
|
7465
|
+
}, [G, Ve]), x(() => {
|
|
7466
|
+
G === "none" && (ue.current = null);
|
|
7467
|
+
}, [G]);
|
|
7468
|
+
let Ue = Fi((e) => f(e)), We = Ue.filter((e) => !e.more), Ge = Ue.filter((e) => e.more), Ke = We.filter((e) => e.key !== "ai"), qe = We.find((e) => e.key === "ai"), Je = b((e) => {
|
|
7469
|
+
if (X) if (Ne(!1), e.key === "link") if (X.isActive("link")) X.chain().focus().unsetLink().run();
|
|
6979
7470
|
else {
|
|
6980
|
-
let e =
|
|
7471
|
+
let e = X.getAttributes("link").href || "";
|
|
6981
7472
|
fe(e), He("link");
|
|
6982
7473
|
}
|
|
6983
|
-
else e.key === "highlight" ?
|
|
7474
|
+
else e.key === "highlight" ? G === "highlight" ? K("none") : He("highlight") : e.command(X);
|
|
6984
7475
|
}, [
|
|
6985
|
-
|
|
6986
|
-
|
|
7476
|
+
X,
|
|
7477
|
+
G,
|
|
6987
7478
|
He
|
|
6988
|
-
]), Ye = b((e) =>
|
|
7479
|
+
]), Ye = b((e) => X ? e.key === "highlight" ? G === "highlight" : e.key === "link" ? X.isActive("link") : e.isActive(X) : !1, [X, G]), [Xe, Ze] = T(0);
|
|
6989
7480
|
x(() => {
|
|
6990
|
-
if (!
|
|
7481
|
+
if (!X) return;
|
|
6991
7482
|
let e = () => Ze((e) => (e + 1) % 1e6);
|
|
6992
|
-
return
|
|
6993
|
-
|
|
7483
|
+
return X.on("update", e), () => {
|
|
7484
|
+
X.off("update", e);
|
|
6994
7485
|
};
|
|
6995
|
-
}, [
|
|
6996
|
-
let [Qe,
|
|
7486
|
+
}, [X]);
|
|
7487
|
+
let [Qe, $e] = T(!1);
|
|
6997
7488
|
x(() => {
|
|
6998
|
-
if (!
|
|
7489
|
+
if (!X) return;
|
|
6999
7490
|
let e = () => {
|
|
7000
7491
|
let e = !1;
|
|
7001
|
-
|
|
7492
|
+
X.state.doc.descendants((t) => {
|
|
7002
7493
|
t.type.name === "heading" && (e = !0);
|
|
7003
|
-
}),
|
|
7494
|
+
}), $e(e);
|
|
7004
7495
|
};
|
|
7005
|
-
return e(),
|
|
7006
|
-
|
|
7496
|
+
return e(), X.on("update", e), () => {
|
|
7497
|
+
X.off("update", e);
|
|
7007
7498
|
};
|
|
7008
|
-
}, [
|
|
7009
|
-
let
|
|
7499
|
+
}, [X]);
|
|
7500
|
+
let et = C(() => X?.storage?.characterCount?.characters?.() ?? 0, [X, Xe]), nt = a ? et > a : !1;
|
|
7010
7501
|
x(() => () => {
|
|
7011
|
-
|
|
7502
|
+
we.current && clearTimeout(we.current);
|
|
7012
7503
|
}, []), x(() => () => {
|
|
7013
|
-
|
|
7504
|
+
J && J.resolve(null);
|
|
7014
7505
|
}, []);
|
|
7015
7506
|
let rt = b((e) => {
|
|
7016
|
-
if (!
|
|
7507
|
+
if (!X?.isEditable) return;
|
|
7017
7508
|
let t = window.getSelection(), n;
|
|
7018
7509
|
if (e) {
|
|
7019
7510
|
let t = e.getBoundingClientRect();
|
|
@@ -7030,76 +7521,76 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7030
7521
|
width: e.width
|
|
7031
7522
|
};
|
|
7032
7523
|
} else {
|
|
7033
|
-
let e =
|
|
7524
|
+
let e = X.view.coordsAtPos(X.state.selection.from);
|
|
7034
7525
|
n = {
|
|
7035
7526
|
top: e.bottom,
|
|
7036
7527
|
left: e.left,
|
|
7037
7528
|
width: 0
|
|
7038
7529
|
};
|
|
7039
7530
|
}
|
|
7040
|
-
|
|
7041
|
-
let r =
|
|
7531
|
+
Oe.current = n;
|
|
7532
|
+
let r = Te.current?.getBoundingClientRect(), i = Ki(n, void 0, {
|
|
7042
7533
|
panelWidth: r?.width,
|
|
7043
7534
|
editorLeft: r?.left
|
|
7044
7535
|
});
|
|
7045
|
-
M(!0),
|
|
7046
|
-
}, [
|
|
7536
|
+
M(!0), F(i.style), R(i.placement), ie(i.arrowLeft);
|
|
7537
|
+
}, [X]);
|
|
7047
7538
|
x(() => {
|
|
7048
|
-
if (!
|
|
7049
|
-
let e =
|
|
7539
|
+
if (!X) return;
|
|
7540
|
+
let e = X.storage.qingwuUI;
|
|
7050
7541
|
if (e) return e.openImageDialog = () => V(!0), e.openVideoDialog = () => ae(!0), e.chooseMd = (e, t) => {
|
|
7051
|
-
|
|
7542
|
+
pe({
|
|
7052
7543
|
filename: e,
|
|
7053
7544
|
resolve: t
|
|
7054
7545
|
});
|
|
7055
|
-
}, e.openAI = rt, e.parseMd = (e, t) =>
|
|
7546
|
+
}, e.openAI = rt, e.parseMd = (e, t) => X ? Ji(X, t) : null, () => {
|
|
7056
7547
|
delete e.openImageDialog, delete e.openVideoDialog, delete e.openAI, delete e.parseMd, delete e.chooseMd;
|
|
7057
7548
|
};
|
|
7058
|
-
}, [
|
|
7059
|
-
if (!j || !
|
|
7060
|
-
let e =
|
|
7549
|
+
}, [X, rt]), S(() => {
|
|
7550
|
+
if (!j || !X) return;
|
|
7551
|
+
let e = Oe.current;
|
|
7061
7552
|
if (!e) return;
|
|
7062
|
-
let t = z.current, n =
|
|
7553
|
+
let t = z.current, n = Te.current?.getBoundingClientRect(), r = Ki(e, t?.offsetHeight || void 0, {
|
|
7063
7554
|
panelWidth: n?.width,
|
|
7064
7555
|
editorLeft: n?.left
|
|
7065
7556
|
});
|
|
7066
|
-
R(r.placement), ie(r.arrowLeft),
|
|
7067
|
-
}, [j,
|
|
7068
|
-
if (!j || !
|
|
7557
|
+
R(r.placement), ie(r.arrowLeft), F(r.style);
|
|
7558
|
+
}, [j, X]), x(() => {
|
|
7559
|
+
if (!j || !X) return;
|
|
7069
7560
|
let e = () => {
|
|
7070
|
-
let e =
|
|
7561
|
+
let e = Oe.current;
|
|
7071
7562
|
if (!e) return;
|
|
7072
|
-
let t = z.current, n =
|
|
7563
|
+
let t = z.current, n = Te.current?.getBoundingClientRect(), r = Ki(e, t?.offsetHeight || void 0, {
|
|
7073
7564
|
panelWidth: n?.width,
|
|
7074
7565
|
editorLeft: n?.left
|
|
7075
7566
|
});
|
|
7076
|
-
R(r.placement), ie(r.arrowLeft),
|
|
7567
|
+
R(r.placement), ie(r.arrowLeft), F(r.style);
|
|
7077
7568
|
};
|
|
7078
7569
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
7079
|
-
}, [j,
|
|
7080
|
-
j || (
|
|
7570
|
+
}, [j, X]), x(() => {
|
|
7571
|
+
j || (Oe.current = null);
|
|
7081
7572
|
}, [j]);
|
|
7082
7573
|
let it = b((e) => {
|
|
7083
|
-
|
|
7084
|
-
}, [
|
|
7085
|
-
(
|
|
7086
|
-
}, [
|
|
7574
|
+
X?.chain().focus().setImage({ src: e }).run();
|
|
7575
|
+
}, [X]), at = b((e) => {
|
|
7576
|
+
(X?.commands).insertVideo?.({ src: e });
|
|
7577
|
+
}, [X]), ot = me && be && !Y && !Fe, st = !ot && !ge && (me || Qe && !(!k && Se)), ct = w(!1);
|
|
7087
7578
|
return x(() => {
|
|
7088
|
-
|
|
7089
|
-
}, [
|
|
7090
|
-
if (!
|
|
7579
|
+
ct.current || (ct.current = !0, me && !ot && _e(!0));
|
|
7580
|
+
}, [me, ot]), x(() => {
|
|
7581
|
+
if (!ge) return;
|
|
7091
7582
|
let e = (e) => {
|
|
7092
7583
|
let t = e.target;
|
|
7093
|
-
|
|
7584
|
+
Le.current?.contains(t) || _e(!1);
|
|
7094
7585
|
}, t = (e) => {
|
|
7095
|
-
e.key === "Escape" &&
|
|
7586
|
+
e.key === "Escape" && _e(!1);
|
|
7096
7587
|
};
|
|
7097
7588
|
return document.addEventListener("mousedown", e), document.addEventListener("touchstart", e, { passive: !0 }), document.addEventListener("keydown", t), () => {
|
|
7098
7589
|
document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e), document.removeEventListener("keydown", t);
|
|
7099
7590
|
};
|
|
7100
|
-
}, [
|
|
7101
|
-
if (!
|
|
7102
|
-
let e =
|
|
7591
|
+
}, [ge]), x(() => {
|
|
7592
|
+
if (!X || !ot) return;
|
|
7593
|
+
let e = Ae.current;
|
|
7103
7594
|
if (!(e instanceof HTMLElement)) return;
|
|
7104
7595
|
let t = (t) => {
|
|
7105
7596
|
let n = t.deltaY;
|
|
@@ -7109,17 +7600,17 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7109
7600
|
e.scrollTop += n, t.preventDefault(), t.stopPropagation();
|
|
7110
7601
|
return;
|
|
7111
7602
|
}
|
|
7112
|
-
let a =
|
|
7603
|
+
let a = ut(X), o = a ? lt(a) : null;
|
|
7113
7604
|
if (o) {
|
|
7114
7605
|
o.scrollTop += n, t.preventDefault(), t.stopPropagation();
|
|
7115
7606
|
return;
|
|
7116
7607
|
}
|
|
7117
7608
|
};
|
|
7118
7609
|
return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
|
|
7119
|
-
}, [
|
|
7610
|
+
}, [X, ot]), X ? /* @__PURE__ */ O("div", {
|
|
7120
7611
|
className: "qingwu-editor-row",
|
|
7121
7612
|
children: [/* @__PURE__ */ O("div", {
|
|
7122
|
-
ref:
|
|
7613
|
+
ref: Te,
|
|
7123
7614
|
className: `qingwu-editor relative flex-1 min-w-0 bg-background ${k ? "qingwu-editor--readonly" : ""} ${l ? "" : "rounded-xl border border-default-200"} ${c}`,
|
|
7124
7615
|
style: u,
|
|
7125
7616
|
children: [
|
|
@@ -7130,13 +7621,13 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7130
7621
|
children: [
|
|
7131
7622
|
/* @__PURE__ */ D("button", {
|
|
7132
7623
|
type: "button",
|
|
7133
|
-
className: `qed-tb-btn qed-tb-btn--desktop-only${
|
|
7624
|
+
className: `qed-tb-btn qed-tb-btn--desktop-only${me ? " is-active" : ""}`,
|
|
7134
7625
|
onClick: () => {
|
|
7135
|
-
|
|
7626
|
+
me ? (he(!1), _e(!1)) : (he(!0), be && !Y && !Fe || _e(!0));
|
|
7136
7627
|
},
|
|
7137
|
-
title:
|
|
7138
|
-
"aria-label":
|
|
7139
|
-
"aria-pressed":
|
|
7628
|
+
title: me ? "隐藏目录" : "显示目录",
|
|
7629
|
+
"aria-label": me ? "隐藏目录" : "显示目录",
|
|
7630
|
+
"aria-pressed": me,
|
|
7140
7631
|
children: /* @__PURE__ */ D("svg", {
|
|
7141
7632
|
fill: "none",
|
|
7142
7633
|
viewBox: "0 0 24 24",
|
|
@@ -7152,11 +7643,11 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7152
7643
|
}),
|
|
7153
7644
|
h && /* @__PURE__ */ D("button", {
|
|
7154
7645
|
type: "button",
|
|
7155
|
-
className: `qed-tb-btn${
|
|
7156
|
-
onClick: () =>
|
|
7646
|
+
className: `qed-tb-btn${ve ? " is-active" : ""}`,
|
|
7647
|
+
onClick: () => ye(!ve),
|
|
7157
7648
|
title: "查找 (Ctrl+F)",
|
|
7158
7649
|
"aria-label": "查找",
|
|
7159
|
-
"aria-pressed":
|
|
7650
|
+
"aria-pressed": ve,
|
|
7160
7651
|
children: /* @__PURE__ */ D("svg", {
|
|
7161
7652
|
fill: "none",
|
|
7162
7653
|
viewBox: "0 0 24 24",
|
|
@@ -7201,7 +7692,7 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7201
7692
|
/* @__PURE__ */ O("button", {
|
|
7202
7693
|
type: "button",
|
|
7203
7694
|
className: "qed-tb-btn qed-tb-btn--solid",
|
|
7204
|
-
onClick: () =>
|
|
7695
|
+
onClick: () => se(!0),
|
|
7205
7696
|
title: f("editor.toolbar.exportTitle"),
|
|
7206
7697
|
children: [/* @__PURE__ */ D("svg", {
|
|
7207
7698
|
fill: "none",
|
|
@@ -7221,11 +7712,11 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7221
7712
|
}),
|
|
7222
7713
|
/* @__PURE__ */ D("button", {
|
|
7223
7714
|
type: "button",
|
|
7224
|
-
className: `qed-tb-btn${
|
|
7225
|
-
onClick:
|
|
7226
|
-
title:
|
|
7227
|
-
"aria-label":
|
|
7228
|
-
"aria-pressed":
|
|
7715
|
+
className: `qed-tb-btn${Y ? " is-active" : ""}`,
|
|
7716
|
+
onClick: Re,
|
|
7717
|
+
title: Y ? "退出网页全屏" : "网页全屏",
|
|
7718
|
+
"aria-label": Y ? "退出网页全屏" : "网页全屏",
|
|
7719
|
+
"aria-pressed": Y,
|
|
7229
7720
|
children: /* @__PURE__ */ D("svg", {
|
|
7230
7721
|
fill: "none",
|
|
7231
7722
|
viewBox: "0 0 24 24",
|
|
@@ -7241,11 +7732,11 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7241
7732
|
}),
|
|
7242
7733
|
/* @__PURE__ */ D("button", {
|
|
7243
7734
|
type: "button",
|
|
7244
|
-
className: `qed-tb-btn${
|
|
7245
|
-
onClick:
|
|
7246
|
-
title:
|
|
7247
|
-
"aria-label":
|
|
7248
|
-
"aria-pressed":
|
|
7735
|
+
className: `qed-tb-btn${Fe ? " is-active" : ""}`,
|
|
7736
|
+
onClick: ze,
|
|
7737
|
+
title: Fe ? "退出全屏" : "全屏",
|
|
7738
|
+
"aria-label": Fe ? "退出全屏" : "全屏",
|
|
7739
|
+
"aria-pressed": Fe,
|
|
7249
7740
|
children: /* @__PURE__ */ D("svg", {
|
|
7250
7741
|
fill: "none",
|
|
7251
7742
|
viewBox: "0 0 24 24",
|
|
@@ -7262,8 +7753,8 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7262
7753
|
]
|
|
7263
7754
|
})]
|
|
7264
7755
|
}),
|
|
7265
|
-
|
|
7266
|
-
editor:
|
|
7756
|
+
X && !k && X.isEditable && /* @__PURE__ */ D(ne, {
|
|
7757
|
+
editor: X,
|
|
7267
7758
|
shouldShow: ({ editor: e, state: t }) => !(e.isActive("image") || e.isActive("videoEmbed") || e.isActive("codeBlock") || e.isActive("audioEmbed") || e.isActive("attachmentEmbed") || t.selection.empty),
|
|
7268
7759
|
options: {
|
|
7269
7760
|
placement: "bottom",
|
|
@@ -7272,7 +7763,7 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7272
7763
|
},
|
|
7273
7764
|
className: "bubble-menu-pop bg-background border border-default-200 rounded-xl p-1 shadow-lg",
|
|
7274
7765
|
children: /* @__PURE__ */ O("div", {
|
|
7275
|
-
ref:
|
|
7766
|
+
ref: je,
|
|
7276
7767
|
className: "bubble-menu-items relative flex items-center gap-0.5",
|
|
7277
7768
|
onPointerDown: (e) => {
|
|
7278
7769
|
e.target.closest("button") && e.preventDefault();
|
|
@@ -7280,7 +7771,7 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7280
7771
|
children: [
|
|
7281
7772
|
Ke.map((e) => /* @__PURE__ */ D("button", {
|
|
7282
7773
|
type: "button",
|
|
7283
|
-
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${e.isActive(
|
|
7774
|
+
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${e.isActive(X) ? "bg-primary/10 text-primary" : "text-default-600 hover:bg-default-100"}`,
|
|
7284
7775
|
onClick: (t) => {
|
|
7285
7776
|
t.preventDefault(), Je(e);
|
|
7286
7777
|
},
|
|
@@ -7296,11 +7787,11 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7296
7787
|
type: "button",
|
|
7297
7788
|
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"}`,
|
|
7298
7789
|
onClick: (e) => {
|
|
7299
|
-
e.preventDefault(),
|
|
7790
|
+
e.preventDefault(), Ne(!1), qe?.command(X);
|
|
7300
7791
|
},
|
|
7301
7792
|
title: qe?.label,
|
|
7302
7793
|
"aria-label": qe?.label,
|
|
7303
|
-
children: /* @__PURE__ */ D(
|
|
7794
|
+
children: /* @__PURE__ */ D(Ut, {})
|
|
7304
7795
|
}),
|
|
7305
7796
|
/* @__PURE__ */ D("span", {
|
|
7306
7797
|
className: "w-px h-4 bg-default-200 mx-0.5 shrink-0",
|
|
@@ -7308,16 +7799,16 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7308
7799
|
}),
|
|
7309
7800
|
/* @__PURE__ */ D("button", {
|
|
7310
7801
|
type: "button",
|
|
7311
|
-
"aria-expanded":
|
|
7312
|
-
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${
|
|
7802
|
+
"aria-expanded": Me,
|
|
7803
|
+
className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${Me ? "bg-default-100 text-default-900" : "text-default-600 hover:bg-default-100"}`,
|
|
7313
7804
|
onClick: (e) => {
|
|
7314
|
-
e.preventDefault(),
|
|
7805
|
+
e.preventDefault(), Ne((e) => !e);
|
|
7315
7806
|
},
|
|
7316
7807
|
title: f("editor.bubble.more"),
|
|
7317
7808
|
"aria-label": f("editor.bubble.more"),
|
|
7318
|
-
children: /* @__PURE__ */ D(
|
|
7809
|
+
children: /* @__PURE__ */ D(Wt, {})
|
|
7319
7810
|
}),
|
|
7320
|
-
|
|
7811
|
+
Me && /* @__PURE__ */ D("div", {
|
|
7321
7812
|
role: "menu",
|
|
7322
7813
|
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",
|
|
7323
7814
|
onPointerDown: (e) => {
|
|
@@ -7343,30 +7834,30 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7343
7834
|
]
|
|
7344
7835
|
})
|
|
7345
7836
|
}),
|
|
7346
|
-
|
|
7837
|
+
X && G !== "none" && L(/* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
7347
7838
|
className: "fixed inset-0 z-[9998]",
|
|
7348
|
-
onClick: () =>
|
|
7839
|
+
onClick: () => K("none")
|
|
7349
7840
|
}), /* @__PURE__ */ D("div", {
|
|
7350
7841
|
ref: le,
|
|
7351
|
-
style:
|
|
7842
|
+
style: ce,
|
|
7352
7843
|
className: "bg-background border border-default-200 rounded-xl shadow-xl",
|
|
7353
7844
|
onClick: (e) => e.stopPropagation(),
|
|
7354
|
-
children:
|
|
7845
|
+
children: G === "highlight" ? /* @__PURE__ */ O("div", {
|
|
7355
7846
|
className: "flex items-center gap-1 p-1.5 flex-wrap",
|
|
7356
|
-
children: [
|
|
7847
|
+
children: [Hi.map((e) => /* @__PURE__ */ D("button", {
|
|
7357
7848
|
type: "button",
|
|
7358
7849
|
className: "w-5 h-5 rounded-full border border-default-200 hover:scale-110 transition-transform",
|
|
7359
7850
|
style: { background: e.color },
|
|
7360
7851
|
title: e.name,
|
|
7361
7852
|
onClick: () => {
|
|
7362
|
-
|
|
7853
|
+
X.chain().focus().setHighlight({ color: e.color }).run(), K("none");
|
|
7363
7854
|
}
|
|
7364
7855
|
}, e.color)), /* @__PURE__ */ O("button", {
|
|
7365
7856
|
type: "button",
|
|
7366
7857
|
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]",
|
|
7367
7858
|
title: "清除高亮",
|
|
7368
7859
|
onClick: () => {
|
|
7369
|
-
|
|
7860
|
+
X.chain().focus().unsetHighlight().run(), K("none");
|
|
7370
7861
|
},
|
|
7371
7862
|
children: ["✕", " "]
|
|
7372
7863
|
})]
|
|
@@ -7379,101 +7870,101 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7379
7870
|
value: de,
|
|
7380
7871
|
onChange: (e) => fe(e.target.value),
|
|
7381
7872
|
onKeyDown: (e) => {
|
|
7382
|
-
e.key === "Enter" ? (de.trim() &&
|
|
7873
|
+
e.key === "Enter" ? (de.trim() && X.chain().focus().setLink({ href: de.trim() }).run(), K("none")) : e.key === "Escape" && K("none");
|
|
7383
7874
|
}
|
|
7384
7875
|
}), /* @__PURE__ */ D("button", {
|
|
7385
7876
|
type: "button",
|
|
7386
7877
|
className: "px-2 py-1 text-xs rounded-md bg-primary text-white hover:opacity-90",
|
|
7387
7878
|
onClick: () => {
|
|
7388
|
-
de.trim() &&
|
|
7879
|
+
de.trim() && X.chain().focus().setLink({ href: de.trim() }).run(), K("none");
|
|
7389
7880
|
},
|
|
7390
7881
|
children: "确定"
|
|
7391
7882
|
})]
|
|
7392
7883
|
})
|
|
7393
7884
|
})] }), document.body),
|
|
7394
|
-
!k && j &&
|
|
7885
|
+
!k && j && L(/* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
7395
7886
|
className: "fixed inset-0 z-[9998]",
|
|
7396
7887
|
onClick: () => M(!1)
|
|
7397
7888
|
}), /* @__PURE__ */ O("div", {
|
|
7398
7889
|
ref: z,
|
|
7399
7890
|
"data-lenis-prevent": !0,
|
|
7400
|
-
style:
|
|
7401
|
-
className: `ai-panel relative flex flex-col bg-background border border-default-200 rounded-xl shadow-xl${
|
|
7891
|
+
style: P,
|
|
7892
|
+
className: `ai-panel relative flex flex-col bg-background border border-default-200 rounded-xl shadow-xl${I === "above" ? " ai-panel--above" : ""}`,
|
|
7402
7893
|
onClick: (e) => e.stopPropagation(),
|
|
7403
7894
|
children: [/* @__PURE__ */ D("span", {
|
|
7404
7895
|
className: "ai-panel__arrow",
|
|
7405
7896
|
style: { left: `${re}%` },
|
|
7406
7897
|
"aria-hidden": "true"
|
|
7407
|
-
}), /* @__PURE__ */ D(
|
|
7408
|
-
editor:
|
|
7898
|
+
}), /* @__PURE__ */ D(ln, {
|
|
7899
|
+
editor: X,
|
|
7409
7900
|
onClose: () => M(!1)
|
|
7410
7901
|
})]
|
|
7411
7902
|
})] }), document.body),
|
|
7412
7903
|
B && /* @__PURE__ */ D(v, {
|
|
7413
|
-
fallback: /* @__PURE__ */ D(
|
|
7414
|
-
children: /* @__PURE__ */ D(
|
|
7904
|
+
fallback: /* @__PURE__ */ D(ea, {}),
|
|
7905
|
+
children: /* @__PURE__ */ D(Yi, {
|
|
7415
7906
|
open: B,
|
|
7416
7907
|
onClose: () => V(!1),
|
|
7417
7908
|
onInsert: it,
|
|
7418
|
-
validate: (e) =>
|
|
7909
|
+
validate: (e) => X ? mn(X.state.doc, e, {
|
|
7419
7910
|
maxAttachmentSize: o,
|
|
7420
7911
|
maxTotalAttachmentSize: s
|
|
7421
7912
|
}) : null
|
|
7422
7913
|
})
|
|
7423
7914
|
}),
|
|
7424
7915
|
H && /* @__PURE__ */ D(v, {
|
|
7425
|
-
fallback: /* @__PURE__ */ D(
|
|
7426
|
-
children: /* @__PURE__ */ D(
|
|
7916
|
+
fallback: /* @__PURE__ */ D(ea, {}),
|
|
7917
|
+
children: /* @__PURE__ */ D(Qi, {
|
|
7427
7918
|
open: H,
|
|
7428
7919
|
onClose: () => ae(!1),
|
|
7429
7920
|
onInsert: at
|
|
7430
7921
|
})
|
|
7431
7922
|
}),
|
|
7432
7923
|
oe && /* @__PURE__ */ D(v, {
|
|
7433
|
-
fallback: /* @__PURE__ */ D(
|
|
7434
|
-
children: /* @__PURE__ */ D(
|
|
7924
|
+
fallback: /* @__PURE__ */ D(ea, {}),
|
|
7925
|
+
children: /* @__PURE__ */ D(Xi, {
|
|
7435
7926
|
open: oe,
|
|
7436
7927
|
onClose: () => U(!1)
|
|
7437
7928
|
})
|
|
7438
7929
|
}),
|
|
7439
7930
|
W && /* @__PURE__ */ D(v, {
|
|
7440
|
-
fallback: /* @__PURE__ */ D(
|
|
7441
|
-
children: /* @__PURE__ */ D(
|
|
7931
|
+
fallback: /* @__PURE__ */ D(ea, {}),
|
|
7932
|
+
children: /* @__PURE__ */ D(Zi, {
|
|
7442
7933
|
open: W,
|
|
7443
|
-
onClose: () =>
|
|
7444
|
-
editor:
|
|
7934
|
+
onClose: () => se(!1),
|
|
7935
|
+
editor: X
|
|
7445
7936
|
})
|
|
7446
7937
|
}),
|
|
7447
|
-
|
|
7448
|
-
fallback: /* @__PURE__ */ D(
|
|
7449
|
-
children: /* @__PURE__ */ D(
|
|
7450
|
-
open: !!
|
|
7451
|
-
filename:
|
|
7938
|
+
J && /* @__PURE__ */ D(v, {
|
|
7939
|
+
fallback: /* @__PURE__ */ D(ea, {}),
|
|
7940
|
+
children: /* @__PURE__ */ D($i, {
|
|
7941
|
+
open: !!J,
|
|
7942
|
+
filename: J.filename,
|
|
7452
7943
|
onRender: () => {
|
|
7453
|
-
|
|
7944
|
+
J.resolve("render"), pe(null);
|
|
7454
7945
|
},
|
|
7455
7946
|
onAttach: () => {
|
|
7456
|
-
|
|
7947
|
+
J.resolve("attach"), pe(null);
|
|
7457
7948
|
},
|
|
7458
7949
|
onClose: () => {
|
|
7459
|
-
|
|
7950
|
+
J.resolve(null), pe(null);
|
|
7460
7951
|
}
|
|
7461
7952
|
})
|
|
7462
7953
|
}),
|
|
7463
7954
|
/* @__PURE__ */ D("div", {
|
|
7464
|
-
ref:
|
|
7955
|
+
ref: Ee,
|
|
7465
7956
|
className: "flex editor-body",
|
|
7466
7957
|
children: /* @__PURE__ */ O("div", {
|
|
7467
7958
|
className: "relative min-w-0 flex-1",
|
|
7468
7959
|
children: [
|
|
7469
|
-
/* @__PURE__ */ D(
|
|
7470
|
-
!k && /* @__PURE__ */ D(
|
|
7960
|
+
/* @__PURE__ */ D(ee, { editor: X }),
|
|
7961
|
+
!k && /* @__PURE__ */ D(Vi, { editor: X }),
|
|
7471
7962
|
/* @__PURE__ */ D("div", {
|
|
7472
|
-
className: `${
|
|
7963
|
+
className: `${Y || Fe ? "fixed" : "absolute"} bottom-2 right-4 z-10 pointer-events-none select-none`,
|
|
7473
7964
|
children: /* @__PURE__ */ O("span", {
|
|
7474
|
-
className: `text-xs ${nt ? "bg-danger/10 text-danger font-medium px-2 py-0.5 rounded" : a &&
|
|
7965
|
+
className: `text-xs ${nt ? "bg-danger/10 text-danger font-medium px-2 py-0.5 rounded" : a && et > a * .9 ? "bg-warning/10 text-warning px-2 py-0.5 rounded" : "text-default-300"}`,
|
|
7475
7966
|
children: [
|
|
7476
|
-
|
|
7967
|
+
et,
|
|
7477
7968
|
a ? ` / ${a}` : "",
|
|
7478
7969
|
" 字"
|
|
7479
7970
|
]
|
|
@@ -7482,14 +7973,14 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7482
7973
|
]
|
|
7483
7974
|
})
|
|
7484
7975
|
}),
|
|
7485
|
-
h &&
|
|
7486
|
-
editor:
|
|
7487
|
-
onClose: () =>
|
|
7976
|
+
h && ve && /* @__PURE__ */ D(Mt, {
|
|
7977
|
+
editor: X,
|
|
7978
|
+
onClose: () => ye(!1)
|
|
7488
7979
|
}),
|
|
7489
|
-
|
|
7980
|
+
st && /* @__PURE__ */ D("button", {
|
|
7490
7981
|
type: "button",
|
|
7491
7982
|
className: "qingwu-toc-fab",
|
|
7492
|
-
onClick: () =>
|
|
7983
|
+
onClick: () => _e(!0),
|
|
7493
7984
|
title: "目录",
|
|
7494
7985
|
"aria-label": "打开目录",
|
|
7495
7986
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -7505,8 +7996,8 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7505
7996
|
})
|
|
7506
7997
|
})
|
|
7507
7998
|
}),
|
|
7508
|
-
|
|
7509
|
-
ref:
|
|
7999
|
+
ge && L(/* @__PURE__ */ O("div", {
|
|
8000
|
+
ref: Le,
|
|
7510
8001
|
className: "qingwu-toc-drawer toc-scroll",
|
|
7511
8002
|
"data-lenis-prevent": !0,
|
|
7512
8003
|
children: [/* @__PURE__ */ O("div", {
|
|
@@ -7517,7 +8008,7 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7517
8008
|
}), /* @__PURE__ */ D("button", {
|
|
7518
8009
|
type: "button",
|
|
7519
8010
|
className: "qed-drawer-head__close",
|
|
7520
|
-
onClick: () =>
|
|
8011
|
+
onClick: () => _e(!1),
|
|
7521
8012
|
"aria-label": "关闭目录",
|
|
7522
8013
|
children: /* @__PURE__ */ D("svg", {
|
|
7523
8014
|
fill: "none",
|
|
@@ -7532,21 +8023,21 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7532
8023
|
})
|
|
7533
8024
|
})
|
|
7534
8025
|
})]
|
|
7535
|
-
}), /* @__PURE__ */ D(
|
|
7536
|
-
editor:
|
|
8026
|
+
}), /* @__PURE__ */ D(mt, {
|
|
8027
|
+
editor: X,
|
|
7537
8028
|
className: "!p-3",
|
|
7538
8029
|
onClose: () => {
|
|
7539
|
-
|
|
8030
|
+
_e(!1), he(!1);
|
|
7540
8031
|
}
|
|
7541
8032
|
})]
|
|
7542
8033
|
}), document.body)
|
|
7543
8034
|
]
|
|
7544
|
-
}), ot &&
|
|
7545
|
-
ref:
|
|
8035
|
+
}), ot && L(/* @__PURE__ */ D("aside", {
|
|
8036
|
+
ref: Ae,
|
|
7546
8037
|
className: "qingwu-toc-desktop toc-scroll",
|
|
7547
|
-
children: /* @__PURE__ */ D(
|
|
7548
|
-
editor:
|
|
7549
|
-
onClose: () =>
|
|
8038
|
+
children: /* @__PURE__ */ D(mt, {
|
|
8039
|
+
editor: X,
|
|
8040
|
+
onClose: () => he(!1)
|
|
7550
8041
|
})
|
|
7551
8042
|
}), document.body)]
|
|
7552
8043
|
}) : /* @__PURE__ */ D("div", {
|
|
@@ -7556,7 +8047,7 @@ var Oi = y(() => Promise.resolve().then(() => et).then((e) => ({ default: e.Imag
|
|
|
7556
8047
|
};
|
|
7557
8048
|
//#endregion
|
|
7558
8049
|
//#region src/editor/clipper/receiver-browser.ts
|
|
7559
|
-
function
|
|
8050
|
+
function na(e) {
|
|
7560
8051
|
let t = async (t) => {
|
|
7561
8052
|
let n = t.data;
|
|
7562
8053
|
if (!n || typeof n != "object" || n.kind !== "qingwu-clip") return;
|
|
@@ -7573,7 +8064,7 @@ function Fi(e) {
|
|
|
7573
8064
|
}
|
|
7574
8065
|
//#endregion
|
|
7575
8066
|
//#region src/editor/storage/providers/cos.ts
|
|
7576
|
-
function
|
|
8067
|
+
function ra(e) {
|
|
7577
8068
|
return g({
|
|
7578
8069
|
endpoint: `https://cos.${e.region}.myqcloud.com`,
|
|
7579
8070
|
bucket: e.bucket,
|
|
@@ -7587,7 +8078,7 @@ function Ii(e) {
|
|
|
7587
8078
|
}
|
|
7588
8079
|
//#endregion
|
|
7589
8080
|
//#region src/editor/storage/providers/oss.ts
|
|
7590
|
-
function
|
|
8081
|
+
function ia(e) {
|
|
7591
8082
|
return g({
|
|
7592
8083
|
endpoint: `https://${e.bucket}.${e.region}.aliyuncs.com`,
|
|
7593
8084
|
bucket: e.bucket,
|
|
@@ -7600,4 +8091,4 @@ function Li(e) {
|
|
|
7600
8091
|
});
|
|
7601
8092
|
}
|
|
7602
8093
|
//#endregion
|
|
7603
|
-
export {
|
|
8094
|
+
export { sr as CODE_LANGUAGES, pr as CodeBlock, Lr as ImageUpload, rt as ImageUploadDialog, ti as MathBlock, ei as MathInline, ta as QingWuAIEditor, Ei as RelativeMedia, At as SearchHighlight, mt as TocPanel, Xn as VideoEmbed, ht as buildSystemPrompt, _t as createAILanguageModelProvider, ra as createCOSStorage, xt as createDeepSeekProvider, _ as createLocalStorage, ia as createOSSStorage, bt as createOpenAICompatProvider, St as createOpenAIProvider, Ct as createQwenProvider, g as createS3Storage, Oi as createSlashCommandExtension, h as escapeHtml, fn as formatBytes, yt as getAIProvider, Fi as getBubbleMenuActions, ki as getDefaultSlashCommands, dn as getDocAttachmentTotal, ji as getEditorExtensions, u as getLocale, Pi 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, bn as setConfirmProvider, l as setLocale, Ni as setSearchEngine, i as setStorageProvider, et as setToastProvider, n as signPreviewUrlHeaders, na as startBrowserClipperReceiver, tt as subscribeToast, f as t, m as tf, Z as toast, mn as validateAttachmentFile };
|