@qingwu-ui/ai-editor 1.1.6 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/clipper.cjs +1 -1
- package/dist/clipper.js +48 -30
- package/dist/components/export-dialog.d.ts.map +1 -1
- package/dist/components/release-notes-dialog.d.ts.map +1 -1
- package/dist/editor/ai-editor.d.ts +2 -0
- package/dist/editor/ai-editor.d.ts.map +1 -1
- package/dist/editor/clipper/receiver-browser.d.ts.map +1 -1
- package/dist/editor/clipper/receiver-node.d.ts.map +1 -1
- package/dist/editor/clipper/types.d.ts +3 -1
- package/dist/editor/clipper/types.d.ts.map +1 -1
- package/dist/editor/embeds/audio-view.d.ts.map +1 -1
- package/dist/editor/embeds/audio.d.ts.map +1 -1
- package/dist/editor/embeds/video-view.d.ts.map +1 -1
- package/dist/editor/embeds/video.d.ts.map +1 -1
- package/dist/editor/extensions/chinese-emphasis.d.ts +29 -0
- package/dist/editor/extensions/chinese-emphasis.d.ts.map +1 -0
- package/dist/editor/extensions/image-upload.d.ts.map +1 -1
- package/dist/editor/extensions/index.d.ts.map +1 -1
- package/dist/editor/extensions/list-quote-highlight.d.ts +4 -0
- package/dist/editor/extensions/list-quote-highlight.d.ts.map +1 -0
- package/dist/editor/extensions/qingwu-ui.d.ts.map +1 -1
- package/dist/editor/extensions/slash-command.d.ts.map +1 -1
- package/dist/editor/i18n/en-US.d.ts +7 -3
- package/dist/editor/i18n/en-US.d.ts.map +1 -1
- package/dist/editor/i18n/zh-CN.d.ts +7 -3
- package/dist/editor/i18n/zh-CN.d.ts.map +1 -1
- package/dist/editor/storage/providers/s3.d.ts +6 -0
- package/dist/editor/storage/providers/s3.d.ts.map +1 -1
- package/dist/editor/storage/signed-fetch.d.ts +1 -1
- package/dist/editor/storage/signed-fetch.d.ts.map +1 -1
- package/dist/editor/utils/document-export.d.ts +12 -0
- package/dist/editor/utils/document-export.d.ts.map +1 -0
- package/dist/editor/utils/insert-media.d.ts +7 -0
- package/dist/editor/utils/insert-media.d.ts.map +1 -0
- package/dist/editor/utils/sanitize.d.ts +1 -5
- package/dist/editor/utils/sanitize.d.ts.map +1 -1
- package/dist/export-dialog-Bnbjhxoc.js +3349 -0
- package/dist/export-dialog-Co3pPwTl.cjs +16 -0
- package/dist/index.cjs +16 -16
- package/dist/index.js +1054 -1093
- package/dist/local-A1ZU5Y6C.js +15 -0
- package/dist/local-a2ROEKrE.cjs +1 -0
- package/dist/{md-import-dialog-DbC-NCH_.js → md-import-dialog-WLWQ4INh.js} +1 -2
- package/dist/sanitize-BebkUITX.cjs +1 -0
- package/dist/{sanitize-Cm8YOT1D.js → sanitize-ths-sP-x.js} +40 -26
- package/dist/signed-fetch-BuPD4Q0V.cjs +7 -0
- package/dist/signed-fetch-iBM0Zozv.js +191 -0
- package/dist/{storage-DUcmM2Ex.js → storage-D68X3FCl.js} +1 -2
- package/dist/storage-settings-dialog-BPlrjhQc.cjs +1 -0
- package/dist/{storage-settings-dialog-DnWNQWjN.js → storage-settings-dialog-DfJuUAkg.js} +27 -26
- package/dist/styles.css +1 -1
- package/dist/video-embed-dialog-DwcFWipC.cjs +1 -0
- package/dist/{video-embed-dialog-B0_pc5xe.js → video-embed-dialog-eCCrqLDP.js} +3 -8
- package/package.json +28 -27
- package/scripts/cli.mjs +0 -0
- package/dist/export-dialog-BwVrBASi.js +0 -162
- package/dist/export-dialog-wG4oZtsB.cjs +0 -13
- package/dist/local-B20eAPCo.js +0 -93
- package/dist/local-D4481lUa.cjs +0 -3
- package/dist/sanitize-DfFeo1bZ.cjs +0 -1
- package/dist/signed-fetch-BO5NjYGN.cjs +0 -5
- package/dist/signed-fetch-CPPWCUUS.js +0 -102
- package/dist/storage-settings-dialog-LY_-VFA4.cjs +0 -1
- package/dist/video-embed-dialog-f5HKKPzg.cjs +0 -1
package/dist/index.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { a as e, n as t, r as n,
|
|
2
|
-
import { a
|
|
3
|
-
import { a as
|
|
4
|
-
import {
|
|
1
|
+
import { a as e, n as t, r as n, s as r, t as i } from "./signed-fetch-iBM0Zozv.js";
|
|
2
|
+
import { a, i as o, n as s, r as c, t as l } from "./storage-D68X3FCl.js";
|
|
3
|
+
import { a as u, i as d, n as f, o as p, r as m, s as h, t as g } from "./sanitize-ths-sP-x.js";
|
|
4
|
+
import { t as _ } from "./local-A1ZU5Y6C.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
9
|
import { EditorContent as ee, NodeViewWrapper as P, ReactNodeViewRenderer as F, ReactRenderer as I, useEditor as te } from "@tiptap/react";
|
|
10
10
|
import { BubbleMenu as ne } from "@tiptap/react/menus";
|
|
11
|
-
import { createPortal as
|
|
12
|
-
import { Extension as
|
|
13
|
-
import { NodeSelection as
|
|
14
|
-
import { Decoration as
|
|
15
|
-
import { Image as
|
|
16
|
-
import { Link as
|
|
17
|
-
import { Underline as
|
|
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
|
+
import { Underline as ce } from "@tiptap/extension-underline";
|
|
18
18
|
import G from "@tiptap/starter-kit";
|
|
19
|
-
import { CharacterCount as
|
|
20
|
-
import { Color as
|
|
19
|
+
import { CharacterCount as K } from "@tiptap/extension-character-count";
|
|
20
|
+
import { Color as le } from "@tiptap/extension-color";
|
|
21
21
|
import { Highlight as ue } from "@tiptap/extension-highlight";
|
|
22
22
|
import { HorizontalRule as de } from "@tiptap/extension-horizontal-rule";
|
|
23
23
|
import { Placeholder as fe } from "@tiptap/extension-placeholder";
|
|
24
24
|
import { Table as pe } from "@tiptap/extension-table";
|
|
25
|
-
import { TableCell as
|
|
26
|
-
import { TableHeader as
|
|
27
|
-
import { TableRow as
|
|
28
|
-
import { TaskItem as
|
|
25
|
+
import { TableCell as me } from "@tiptap/extension-table-cell";
|
|
26
|
+
import { TableHeader as he } from "@tiptap/extension-table-header";
|
|
27
|
+
import { TableRow as ge } from "@tiptap/extension-table-row";
|
|
28
|
+
import { TaskItem as q } from "@tiptap/extension-task-item";
|
|
29
29
|
import { TaskList as _e } from "@tiptap/extension-task-list";
|
|
30
30
|
import { TextStyle as ve } from "@tiptap/extension-text-style";
|
|
31
31
|
import { Markdown as ye } from "tiptap-markdown";
|
|
@@ -34,7 +34,7 @@ import xe from "highlight.js/lib/languages/dockerfile";
|
|
|
34
34
|
import { common as Se, createLowlight as Ce } from "lowlight";
|
|
35
35
|
import we from "katex";
|
|
36
36
|
import Te, { exitSuggestion as Ee, findSuggestionMatch as De } from "@tiptap/suggestion";
|
|
37
|
-
|
|
37
|
+
// ../text-layout/dist/index.mjs
|
|
38
38
|
var Oe = null, ke = null;
|
|
39
39
|
function Ae() {
|
|
40
40
|
return ke || (typeof document > "u" ? null : (Oe = document.createElement("canvas"), ke = Oe.getContext("2d"), ke));
|
|
@@ -50,7 +50,7 @@ function Me(e, t) {
|
|
|
50
50
|
}
|
|
51
51
|
function Ne(e, t) {
|
|
52
52
|
let n = parseFloat(t) || 16, r = 0;
|
|
53
|
-
for (let t of e) Pe(t.codePointAt(0) ?? 0) ? r += n : t === " " ?
|
|
53
|
+
for (let t of e) Pe(t.codePointAt(0) ?? 0) ? r += n : r += t === " " ? n * .3 : n * .55;
|
|
54
54
|
return r;
|
|
55
55
|
}
|
|
56
56
|
function Pe(e) {
|
|
@@ -78,18 +78,18 @@ function Ie(e, t) {
|
|
|
78
78
|
}
|
|
79
79
|
return n;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function Le(e, t, n) {
|
|
82
82
|
let r = 0, i = Math.min(n, e.length);
|
|
83
83
|
for (let n = t; n < i; n++) r += e[n].width;
|
|
84
84
|
return r;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function Re(e, t, n, r) {
|
|
87
87
|
return {
|
|
88
88
|
text: e.slice(t, Math.min(n, e.length)).map((e) => e.text).join(""),
|
|
89
89
|
width: r
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function J(e, t, n = "16px system-ui") {
|
|
93
93
|
let { maxWidth: r, lineHeight: i, maxLines: a, overflowWrap: o = "break-word" } = t, s = Ie(e, n), c = [], l = {
|
|
94
94
|
lineStart: 0,
|
|
95
95
|
lineWidth: 0,
|
|
@@ -99,28 +99,22 @@ function Re(e, t, n = "16px system-ui") {
|
|
|
99
99
|
for (let e = 0; e < s.length; e++) {
|
|
100
100
|
let t = s[e];
|
|
101
101
|
if (t.type === "break") {
|
|
102
|
-
c.push(
|
|
102
|
+
c.push(Re(s, l.lineStart, e, l.lineWidth)), l.lineStart = e + 1, l.lineWidth = 0, l.lastBreakIdx = -1;
|
|
103
103
|
continue;
|
|
104
104
|
}
|
|
105
105
|
let n = l.lineWidth + t.width;
|
|
106
106
|
if (t.type === "space") {
|
|
107
|
-
if (n > r && l.lineWidth > 0 ? (l.lastBreakIdx >= 0 ? (c.push(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (t.type === "
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
if (t.type === "punct") {
|
|
115
|
-
if (l.lineWidth === 0 && c.length > 0 ? c[c.length - 1].text.length > 0 && (l.lineWidth = t.width) : n > r ? (l.lastBreakIdx >= 0 ? (c.push(Le(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = J(s, l.lineStart, e + 1)) : l.lineWidth = n, l.lastBreakIdx = -1) : l.lineWidth = n, a && c.length >= a) break;
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
if (n > r && l.lineWidth > 0 ? l.lastBreakIdx >= 0 ? (c.push(Le(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = J(s, l.lineStart, e + 1), l.lastBreakIdx = -1) : o === "break-word" ? (c.push(Le(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width) : l.lineWidth = n : l.lineWidth = n, a && c.length >= a) break;
|
|
107
|
+
if (n > r && l.lineWidth > 0 ? (l.lastBreakIdx >= 0 ? (c.push(Re(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Le(s, l.lineStart, e + 1)) : (c.push(Re(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width), l.lastBreakIdx = -1) : (l.lineWidth = n, l.lastBreakIdx = e, l.lastBreakWidth = l.lineWidth), a && c.length >= a) break;
|
|
108
|
+
} else if (t.type === "cjk") {
|
|
109
|
+
if (n > r && l.lineWidth > 0 ? (c.push(Re(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;
|
|
110
|
+
} else if (t.type === "punct") {
|
|
111
|
+
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(Re(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Le(s, l.lineStart, e + 1)) : l.lineWidth = n, l.lastBreakIdx = -1) : l.lineWidth = n, a && c.length >= a) break;
|
|
112
|
+
} else if (n > r && l.lineWidth > 0 ? l.lastBreakIdx >= 0 ? (c.push(Re(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Le(s, l.lineStart, e + 1), l.lastBreakIdx = -1) : o === "break-word" ? (c.push(Re(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width) : l.lineWidth = n : l.lineWidth = n, a && c.length >= a) break;
|
|
119
113
|
}
|
|
120
114
|
let u = l.lineStart < s.length;
|
|
121
115
|
if (u && (!a || c.length < a)) {
|
|
122
|
-
let e =
|
|
123
|
-
c.push(
|
|
116
|
+
let e = Le(s, l.lineStart, s.length);
|
|
117
|
+
c.push(Re(s, l.lineStart, s.length, e));
|
|
124
118
|
}
|
|
125
119
|
return {
|
|
126
120
|
lines: c,
|
|
@@ -129,8 +123,7 @@ function Re(e, t, n = "16px system-ui") {
|
|
|
129
123
|
truncated: u && a ? c.length >= a : !1
|
|
130
124
|
};
|
|
131
125
|
}
|
|
132
|
-
|
|
133
|
-
//#region ../toast/dist/index.mjs
|
|
126
|
+
// ../toast/dist/index.mjs
|
|
134
127
|
var ze = typeof window < "u" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, Be = "13.5px -apple-system, BlinkMacSystemFont, \"SF Pro Text\", \"PingFang SC\", \"Microsoft YaHei\", system-ui, sans-serif";
|
|
135
128
|
function Ve() {
|
|
136
129
|
if (typeof window > "u") return 290;
|
|
@@ -142,25 +135,27 @@ var He = {
|
|
|
142
135
|
success: "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"M9 12l2 2 4-4\"/></svg>",
|
|
143
136
|
warning: "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z\"/><line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\"/><line x1=\"12\" y1=\"17\" x2=\"12.01\" y2=\"17\"/></svg>",
|
|
144
137
|
error: "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"15\" y1=\"9\" x2=\"9\" y2=\"15\"/><line x1=\"9\" y1=\"9\" x2=\"15\" y2=\"15\"/></svg>"
|
|
145
|
-
},
|
|
146
|
-
function
|
|
147
|
-
return `qt${
|
|
138
|
+
}, Ue = 1;
|
|
139
|
+
function We() {
|
|
140
|
+
return `qt${Ue++}${Date.now().toString(36)}`;
|
|
148
141
|
}
|
|
149
|
-
function
|
|
142
|
+
function Y(e, t, n) {
|
|
150
143
|
let r = document.createElement(e);
|
|
151
144
|
return t && (r.className = t), n != null && (r.innerHTML = n), r;
|
|
152
145
|
}
|
|
153
|
-
function
|
|
146
|
+
function Ge(e, t) {
|
|
154
147
|
let n = t.split(/\*\*(.+?)\*\*/g);
|
|
155
148
|
for (let t = 0; t < n.length; t++) {
|
|
156
149
|
let r = n[t];
|
|
157
|
-
if (r)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
150
|
+
if (r) {
|
|
151
|
+
if (t % 2 == 1) {
|
|
152
|
+
let t = Y("em", "qt-mark");
|
|
153
|
+
t.textContent = r, e.appendChild(t);
|
|
154
|
+
} else e.appendChild(document.createTextNode(r));
|
|
155
|
+
}
|
|
161
156
|
}
|
|
162
157
|
}
|
|
163
|
-
var
|
|
158
|
+
var Ke = {
|
|
164
159
|
type: "info",
|
|
165
160
|
position: "top-center",
|
|
166
161
|
duration: 4e3,
|
|
@@ -169,19 +164,19 @@ var Ge = {
|
|
|
169
164
|
persistMaxVisible: 3,
|
|
170
165
|
maxLines: void 0,
|
|
171
166
|
vibrate: !0
|
|
172
|
-
},
|
|
167
|
+
}, qe = [
|
|
173
168
|
80,
|
|
174
169
|
40,
|
|
175
170
|
80
|
|
176
171
|
];
|
|
177
|
-
function
|
|
178
|
-
if (
|
|
179
|
-
navigator.vibrate(
|
|
172
|
+
function X() {
|
|
173
|
+
if (typeof navigator < "u" && "vibrate" in navigator) try {
|
|
174
|
+
navigator.vibrate(qe);
|
|
180
175
|
} catch {}
|
|
181
176
|
}
|
|
182
177
|
var Je = class {
|
|
183
178
|
containers = /* @__PURE__ */ new Map();
|
|
184
|
-
opts = { ...
|
|
179
|
+
opts = { ...Ke };
|
|
185
180
|
toasts = /* @__PURE__ */ new Map();
|
|
186
181
|
queue = [];
|
|
187
182
|
_seq = 0;
|
|
@@ -190,10 +185,10 @@ var Je = class {
|
|
|
190
185
|
}
|
|
191
186
|
ensureContainer(e) {
|
|
192
187
|
let t = this.containers.get(e);
|
|
193
|
-
return t || (t =
|
|
188
|
+
return t || (t = Y("div", "qt-container"), t.setAttribute("data-qt-pos", e), t.setAttribute("role", "status"), t.setAttribute("aria-live", "polite"), t.setAttribute("aria-atomic", "false"), document.body.appendChild(t), this.containers.set(e, t)), t;
|
|
194
189
|
}
|
|
195
190
|
show(e, t) {
|
|
196
|
-
let n = t?.type ?? this.opts.type, r = t?.position ?? this.opts.position, i = t?.persist ?? this.opts.persist ? 0 : t?.duration ?? this.opts.duration, a = t?.dismissible ?? !0, o = t?.maxLines ?? this.opts.maxLines, s = t?.description, c = t?.action, l =
|
|
191
|
+
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 = We(), u = {
|
|
197
192
|
id: l,
|
|
198
193
|
type: n,
|
|
199
194
|
dismissible: a,
|
|
@@ -276,30 +271,30 @@ var Je = class {
|
|
|
276
271
|
this.containers.clear();
|
|
277
272
|
}
|
|
278
273
|
buildElement(e, t, n, r, i, a, o) {
|
|
279
|
-
let s =
|
|
274
|
+
let s = Y("div", `qt-toast qt-${n}${i == null ? "" : " qt-truncate"}${a || o ? " qt-rich" : ""}`);
|
|
280
275
|
s.setAttribute("data-qt-id", e);
|
|
281
|
-
let c =
|
|
276
|
+
let c = Y("span", "qt-icon");
|
|
282
277
|
c.innerHTML = He[n], s.appendChild(c);
|
|
283
|
-
let l =
|
|
278
|
+
let l = Y("div", "qt-body"), u = Y("span", "qt-msg"), d = J(t, {
|
|
284
279
|
maxWidth: Ve(),
|
|
285
280
|
lineHeight: 1,
|
|
286
281
|
maxLines: i
|
|
287
282
|
}, Be);
|
|
288
|
-
if (d.lineCount <= 1 ?
|
|
289
|
-
let n =
|
|
290
|
-
t === d.lines.length - 1 && d.truncated && !r.endsWith("…") && (r += "…"),
|
|
283
|
+
if (d.lineCount <= 1 ? Ge(u, t) : d.lines.forEach((e, t) => {
|
|
284
|
+
let n = Y("span", "qt-line"), r = e.text;
|
|
285
|
+
t === d.lines.length - 1 && d.truncated && !r.endsWith("…") && (r += "…"), Ge(n, r), u.appendChild(n);
|
|
291
286
|
}), l.appendChild(u), a) {
|
|
292
|
-
let e =
|
|
287
|
+
let e = Y("div", "qt-desc");
|
|
293
288
|
e.textContent = a, l.appendChild(e);
|
|
294
289
|
}
|
|
295
290
|
if (s.appendChild(l), o) {
|
|
296
|
-
let t =
|
|
291
|
+
let t = Y("button", "qt-action");
|
|
297
292
|
t.type = "button", t.textContent = o.label, t.addEventListener("click", (t) => {
|
|
298
293
|
t.stopPropagation(), this.dismiss(e), o.onClick();
|
|
299
294
|
}), s.appendChild(t);
|
|
300
295
|
}
|
|
301
296
|
if (r) {
|
|
302
|
-
let t =
|
|
297
|
+
let t = Y("button", "qt-close", "<svg width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"><path d=\"M18 6 6 18M6 6l12 12\"/></svg>");
|
|
303
298
|
t.type = "button", t.setAttribute("aria-label", "关闭通知"), t.addEventListener("click", (t) => {
|
|
304
299
|
t.stopPropagation(), this.dismiss(e);
|
|
305
300
|
}), s.appendChild(t);
|
|
@@ -311,7 +306,7 @@ var Je = class {
|
|
|
311
306
|
mount(e) {
|
|
312
307
|
e.duration === 0 && this.evictPersistIfNeeded(e);
|
|
313
308
|
let t = this.ensureContainer(e.position);
|
|
314
|
-
this.toasts.set(e.id, e), t.appendChild(e.element), e.type === "error" && this.opts.vibrate &&
|
|
309
|
+
this.toasts.set(e.id, e), t.appendChild(e.element), e.type === "error" && this.opts.vibrate && X(), requestAnimationFrame(() => {
|
|
315
310
|
requestAnimationFrame(() => {
|
|
316
311
|
e.element.classList.add("qt-enter");
|
|
317
312
|
});
|
|
@@ -368,27 +363,19 @@ function Z(e, t = "error", n) {
|
|
|
368
363
|
persist: !0,
|
|
369
364
|
...n
|
|
370
365
|
};
|
|
371
|
-
if (Qe.size > 0)
|
|
372
|
-
|
|
373
|
-
return;
|
|
374
|
-
}
|
|
375
|
-
if ($e) {
|
|
376
|
-
$e(e, t, r);
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
t === "success" ? Ze.success(e, r) : t === "info" ? Ze.info(e, r) : Ze.error(e, r);
|
|
366
|
+
if (Qe.size > 0) for (let n of Qe) n(e, t, r);
|
|
367
|
+
else $e ? $e(e, t, r) : t === "success" ? Ze.success(e, r) : t === "info" ? Ze.info(e, r) : Ze.error(e, r);
|
|
380
368
|
}
|
|
381
369
|
function tt(e) {
|
|
382
370
|
return Qe.add(e), () => {
|
|
383
371
|
Qe.delete(e);
|
|
384
372
|
};
|
|
385
373
|
}
|
|
386
|
-
|
|
387
|
-
|
|
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 = (() => {
|
|
374
|
+
// src/components/image-upload-dialog.tsx
|
|
375
|
+
var nt = /* @__PURE__ */ r({ ImageUploadDialog: () => rt }), rt = ({ open: e, onClose: t, onInsert: n, validate: r }) => {
|
|
376
|
+
let [i, a] = T("upload"), [o, 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 = (() => {
|
|
390
377
|
try {
|
|
391
|
-
let e =
|
|
378
|
+
let e = s();
|
|
392
379
|
return {
|
|
393
380
|
name: e.name,
|
|
394
381
|
type: e.type
|
|
@@ -418,7 +405,7 @@ var nt = /* @__PURE__ */ e({ ImageUploadDialog: () => rt }), rt = ({ open: e, on
|
|
|
418
405
|
f(`不支持的图片格式: ${t || "未知"}`);
|
|
419
406
|
return;
|
|
420
407
|
}
|
|
421
|
-
let n = r ? r(e) : e.size >
|
|
408
|
+
let n = r ? r(e) : e.size > 20971520 ? "图片大小不能超过 20MB" : null;
|
|
422
409
|
if (n) {
|
|
423
410
|
f(n), Z(n);
|
|
424
411
|
return;
|
|
@@ -427,7 +414,7 @@ var nt = /* @__PURE__ */ e({ ImageUploadDialog: () => rt }), rt = ({ open: e, on
|
|
|
427
414
|
let i = URL.createObjectURL(e);
|
|
428
415
|
m(i);
|
|
429
416
|
try {
|
|
430
|
-
let t = await
|
|
417
|
+
let t = await s().upload(e, "editor");
|
|
431
418
|
URL.revokeObjectURL(i), v(t), m(t);
|
|
432
419
|
} catch (e) {
|
|
433
420
|
f(e instanceof Error ? e.message : "上传失败"), URL.revokeObjectURL(i), m(null);
|
|
@@ -508,7 +495,7 @@ var nt = /* @__PURE__ */ e({ ImageUploadDialog: () => rt }), rt = ({ open: e, on
|
|
|
508
495
|
]
|
|
509
496
|
}),
|
|
510
497
|
!p && /* @__PURE__ */ O("div", {
|
|
511
|
-
className: `relative flex flex-col items-center justify-center gap-3 py-10 px-4 rounded-xl border-2 border-dashed transition-all cursor-pointer ${
|
|
498
|
+
className: `relative flex flex-col items-center justify-center gap-3 py-10 px-4 rounded-xl border-2 border-dashed transition-all cursor-pointer ${o ? "border-primary bg-primary/5 scale-[1.01]" : "border-default-200 hover:border-default-300 hover:bg-default-50"}`,
|
|
512
499
|
onDragOver: (e) => {
|
|
513
500
|
e.preventDefault(), c(!0);
|
|
514
501
|
},
|
|
@@ -536,7 +523,7 @@ var nt = /* @__PURE__ */ e({ ImageUploadDialog: () => rt }), rt = ({ open: e, on
|
|
|
536
523
|
children: [
|
|
537
524
|
/* @__PURE__ */ D("p", {
|
|
538
525
|
className: "text-sm font-medium text-default-700",
|
|
539
|
-
children:
|
|
526
|
+
children: o ? "松开放入" : "拖拽图片到此处"
|
|
540
527
|
}),
|
|
541
528
|
/* @__PURE__ */ D("p", {
|
|
542
529
|
className: "text-xs text-default-400 mt-1",
|
|
@@ -675,8 +662,7 @@ var nt = /* @__PURE__ */ e({ ImageUploadDialog: () => rt }), rt = ({ open: e, on
|
|
|
675
662
|
})]
|
|
676
663
|
}) : null;
|
|
677
664
|
};
|
|
678
|
-
|
|
679
|
-
//#region src/components/toc.tsx
|
|
665
|
+
// src/components/toc.tsx
|
|
680
666
|
function it(e, t) {
|
|
681
667
|
return `${e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu, "").replace(/\s+/g, "-").slice(0, 40) || "heading"}-${t}`;
|
|
682
668
|
}
|
|
@@ -816,7 +802,7 @@ var ft = 84, pt = 3e3, mt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
816
802
|
let n = ut(e);
|
|
817
803
|
if (!n) return;
|
|
818
804
|
let r = t.el;
|
|
819
|
-
if (
|
|
805
|
+
if (r && n.contains(r) || (r = n.querySelector(`[id="${CSS.escape(t.id)}"]`)), !r) {
|
|
820
806
|
let e = `h${t.level}`, i = n.querySelectorAll(e);
|
|
821
807
|
for (let e of i) if (e.textContent?.trim() === t.text) {
|
|
822
808
|
r = e;
|
|
@@ -878,7 +864,7 @@ var ft = 84, pt = 3e3, mt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
878
864
|
});
|
|
879
865
|
}, []), ne = b(() => {
|
|
880
866
|
c(new Set(j));
|
|
881
|
-
}, [j]),
|
|
867
|
+
}, [j]), L = b(() => {
|
|
882
868
|
c(/* @__PURE__ */ new Set());
|
|
883
869
|
}, []);
|
|
884
870
|
return r.length ? /* @__PURE__ */ O("nav", {
|
|
@@ -970,7 +956,7 @@ var ft = 84, pt = 3e3, mt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
970
956
|
}), /* @__PURE__ */ D("button", {
|
|
971
957
|
type: "button",
|
|
972
958
|
className: "toc-action-btn",
|
|
973
|
-
onClick:
|
|
959
|
+
onClick: L,
|
|
974
960
|
title: "全部展开",
|
|
975
961
|
"aria-label": "全部展开",
|
|
976
962
|
disabled: N,
|
|
@@ -1101,8 +1087,7 @@ var ft = 84, pt = 3e3, mt = ({ editor: e, className: t = "", onClose: n }) => {
|
|
|
1101
1087
|
})]
|
|
1102
1088
|
});
|
|
1103
1089
|
};
|
|
1104
|
-
|
|
1105
|
-
//#region src/editor/ai/index.ts
|
|
1090
|
+
// src/editor/ai/index.ts
|
|
1106
1091
|
function ht(e, t) {
|
|
1107
1092
|
return {
|
|
1108
1093
|
continue: "你是一个写作助手。请从下文尾部自然流畅地续写内容,保持风格一致。只输出续写的内容,不要加任何前缀说明。",
|
|
@@ -1155,8 +1140,7 @@ function yt() {
|
|
|
1155
1140
|
if (!gt) throw Error("未配置 AI 服务。请调用 createAILanguageModelProvider() 创建并通过 setAIProvider() 注册。");
|
|
1156
1141
|
return gt;
|
|
1157
1142
|
}
|
|
1158
|
-
|
|
1159
|
-
//#region src/editor/ai/providers/openai-compat.ts
|
|
1143
|
+
// src/editor/ai/providers/openai-compat.ts
|
|
1160
1144
|
function bt(e) {
|
|
1161
1145
|
let { apiKey: t, baseURL: n, model: r, headers: i } = e;
|
|
1162
1146
|
async function* a(e, a) {
|
|
@@ -1217,8 +1201,7 @@ function bt(e) {
|
|
|
1217
1201
|
}
|
|
1218
1202
|
};
|
|
1219
1203
|
}
|
|
1220
|
-
|
|
1221
|
-
//#region src/editor/ai/providers/deepseek.ts
|
|
1204
|
+
// src/editor/ai/providers/deepseek.ts
|
|
1222
1205
|
function xt(e) {
|
|
1223
1206
|
return bt({
|
|
1224
1207
|
apiKey: e.apiKey,
|
|
@@ -1227,8 +1210,7 @@ function xt(e) {
|
|
|
1227
1210
|
headers: e.headers
|
|
1228
1211
|
});
|
|
1229
1212
|
}
|
|
1230
|
-
|
|
1231
|
-
//#region src/editor/ai/providers/openai.ts
|
|
1213
|
+
// src/editor/ai/providers/openai.ts
|
|
1232
1214
|
function St(e) {
|
|
1233
1215
|
return bt({
|
|
1234
1216
|
apiKey: e.apiKey,
|
|
@@ -1237,8 +1219,7 @@ function St(e) {
|
|
|
1237
1219
|
headers: e.headers
|
|
1238
1220
|
});
|
|
1239
1221
|
}
|
|
1240
|
-
|
|
1241
|
-
//#region src/editor/ai/providers/qwen.ts
|
|
1222
|
+
// src/editor/ai/providers/qwen.ts
|
|
1242
1223
|
function Ct(e) {
|
|
1243
1224
|
return bt({
|
|
1244
1225
|
apiKey: e.apiKey,
|
|
@@ -1247,15 +1228,14 @@ function Ct(e) {
|
|
|
1247
1228
|
headers: e.headers
|
|
1248
1229
|
});
|
|
1249
1230
|
}
|
|
1250
|
-
|
|
1251
|
-
//#region src/editor/extensions/search-highlight.ts
|
|
1231
|
+
// src/editor/extensions/search-highlight.ts
|
|
1252
1232
|
var wt = {
|
|
1253
1233
|
keyword: "",
|
|
1254
1234
|
caseSensitive: !1,
|
|
1255
1235
|
wholeWord: !1,
|
|
1256
1236
|
matches: [],
|
|
1257
1237
|
currentIndex: -1
|
|
1258
|
-
}, Tt = new
|
|
1238
|
+
}, Tt = new H("search-highlight");
|
|
1259
1239
|
function Et(e) {
|
|
1260
1240
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1261
1241
|
}
|
|
@@ -1277,9 +1257,9 @@ function Dt(e, t) {
|
|
|
1277
1257
|
}), c;
|
|
1278
1258
|
}
|
|
1279
1259
|
function Ot(e, t) {
|
|
1280
|
-
if (t.matches.length === 0) return
|
|
1281
|
-
let n = t.matches.map((e, n) =>
|
|
1282
|
-
return
|
|
1260
|
+
if (t.matches.length === 0) return U.empty;
|
|
1261
|
+
let n = t.matches.map((e, n) => oe.inline(e.from, e.to, { class: n === t.currentIndex ? "search-highlight search-highlight--active" : "search-highlight" }));
|
|
1262
|
+
return U.create(e, n);
|
|
1283
1263
|
}
|
|
1284
1264
|
function kt(e, t) {
|
|
1285
1265
|
if (t.currentIndex < 0 || t.currentIndex >= t.matches.length) return;
|
|
@@ -1306,10 +1286,10 @@ function kt(e, t) {
|
|
|
1306
1286
|
} catch {}
|
|
1307
1287
|
});
|
|
1308
1288
|
}
|
|
1309
|
-
var At =
|
|
1289
|
+
var At = R.create({
|
|
1310
1290
|
name: "searchHighlight",
|
|
1311
1291
|
addProseMirrorPlugins() {
|
|
1312
|
-
return [new
|
|
1292
|
+
return [new V({
|
|
1313
1293
|
key: Tt,
|
|
1314
1294
|
state: {
|
|
1315
1295
|
init: () => wt,
|
|
@@ -1334,7 +1314,7 @@ var At = L.create({
|
|
|
1334
1314
|
},
|
|
1335
1315
|
props: { decorations(e) {
|
|
1336
1316
|
let t = Tt.getState(e);
|
|
1337
|
-
return t ? Ot(e.doc, t) :
|
|
1317
|
+
return t ? Ot(e.doc, t) : U.empty;
|
|
1338
1318
|
} }
|
|
1339
1319
|
})];
|
|
1340
1320
|
},
|
|
@@ -1376,8 +1356,7 @@ function jt(e) {
|
|
|
1376
1356
|
let t = e.state;
|
|
1377
1357
|
return Tt.getState(t) || wt;
|
|
1378
1358
|
}
|
|
1379
|
-
|
|
1380
|
-
//#region src/components/search-bar.tsx
|
|
1359
|
+
// src/components/search-bar.tsx
|
|
1381
1360
|
var Mt = ({ editor: e, onClose: t }) => {
|
|
1382
1361
|
let [n, r] = T(""), [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(0), u = w(null), d = w({
|
|
1383
1362
|
keyword: n,
|
|
@@ -1578,8 +1557,7 @@ var Mt = ({ editor: e, onClose: t }) => {
|
|
|
1578
1557
|
})
|
|
1579
1558
|
});
|
|
1580
1559
|
};
|
|
1581
|
-
|
|
1582
|
-
//#region src/editor/icons.tsx
|
|
1560
|
+
// src/editor/icons.tsx
|
|
1583
1561
|
function Q({ children: e, ...t }) {
|
|
1584
1562
|
return /* @__PURE__ */ D("svg", {
|
|
1585
1563
|
width: 16,
|
|
@@ -1680,23 +1658,18 @@ var Nt = (e) => /* @__PURE__ */ O(Q, {
|
|
|
1680
1658
|
...e,
|
|
1681
1659
|
children: [/* @__PURE__ */ D("path", { d: "M18 6 6 18" }), /* @__PURE__ */ D("path", { d: "m6 6 12 12" })]
|
|
1682
1660
|
});
|
|
1683
|
-
|
|
1684
|
-
//#region src/editor/storage/remove-resource.ts
|
|
1661
|
+
// src/editor/storage/remove-resource.ts
|
|
1685
1662
|
async function qt(e) {
|
|
1686
1663
|
if (e) {
|
|
1687
|
-
if (e.startsWith("blob:"))
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
}
|
|
1691
|
-
try {
|
|
1692
|
-
await o().remove(e);
|
|
1664
|
+
if (e.startsWith("blob:")) URL.revokeObjectURL(e);
|
|
1665
|
+
else try {
|
|
1666
|
+
await s().remove(e);
|
|
1693
1667
|
} catch (e) {
|
|
1694
1668
|
console.warn("删除存储资源失败:", e);
|
|
1695
1669
|
}
|
|
1696
1670
|
}
|
|
1697
1671
|
}
|
|
1698
|
-
|
|
1699
|
-
//#region src/editor/ai/pending-removal.ts
|
|
1672
|
+
// src/editor/ai/pending-removal.ts
|
|
1700
1673
|
var Jt = 3e4, Yt = /* @__PURE__ */ new Set([
|
|
1701
1674
|
"image",
|
|
1702
1675
|
"attachmentEmbed",
|
|
@@ -1749,8 +1722,7 @@ function en(e) {
|
|
|
1749
1722
|
Xt.delete(e);
|
|
1750
1723
|
}
|
|
1751
1724
|
}
|
|
1752
|
-
|
|
1753
|
-
//#region src/editor/ai/components/ai-selector.tsx
|
|
1725
|
+
// src/editor/ai/components/ai-selector.tsx
|
|
1754
1726
|
var tn = [
|
|
1755
1727
|
{
|
|
1756
1728
|
mode: "continue",
|
|
@@ -1835,10 +1807,8 @@ function cn(e, t) {
|
|
|
1835
1807
|
let n = an(e, t);
|
|
1836
1808
|
if (n && n.size > 0) {
|
|
1837
1809
|
let t = e.state.tr;
|
|
1838
|
-
t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(
|
|
1839
|
-
|
|
1840
|
-
}
|
|
1841
|
-
e.commands.setContent(t), e.commands.focus();
|
|
1810
|
+
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();
|
|
1811
|
+
} else e.commands.setContent(t), e.commands.focus();
|
|
1842
1812
|
}
|
|
1843
1813
|
function ln(e, t, n, r) {
|
|
1844
1814
|
let i = an(e, t);
|
|
@@ -1854,16 +1824,12 @@ function ln(e, t, n, r) {
|
|
|
1854
1824
|
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());
|
|
1855
1825
|
}
|
|
1856
1826
|
function un({ editor: e, onClose: t }) {
|
|
1857
|
-
let [n, r] = T(null), [i, a] = T(""), [o, s] = T(""), [c, l] = T(!1), [u, d] = T(null), [
|
|
1827
|
+
let [n, r] = T(null), [i, a] = T(""), [o, s] = T(""), [c, l] = T(!1), [u, d] = T(null), [f, m] = T(null), h = w({
|
|
1858
1828
|
from: 0,
|
|
1859
1829
|
to: 0,
|
|
1860
1830
|
empty: !0
|
|
1861
1831
|
}), g = w(null), _ = w(null), v = w(!0), y = b(async (e) => {
|
|
1862
|
-
|
|
1863
|
-
await C(e);
|
|
1864
|
-
return;
|
|
1865
|
-
}
|
|
1866
|
-
setTimeout(() => g.current?.focus(), 100);
|
|
1832
|
+
r(e), d(null), e === "zap" ? setTimeout(() => g.current?.focus(), 100) : await C(e);
|
|
1867
1833
|
}, [e]), C = b(async (t) => {
|
|
1868
1834
|
let n = e.state.selection;
|
|
1869
1835
|
h.current = {
|
|
@@ -1879,7 +1845,7 @@ function un({ editor: e, onClose: t }) {
|
|
|
1879
1845
|
instruction: t === "zap" ? i : void 0
|
|
1880
1846
|
})) o.push(e), s(o.join(""));
|
|
1881
1847
|
} catch (e) {
|
|
1882
|
-
d(e instanceof Error ? e.message :
|
|
1848
|
+
d(e instanceof Error ? e.message : p("editor.ai.error"));
|
|
1883
1849
|
} finally {
|
|
1884
1850
|
l(!1);
|
|
1885
1851
|
}
|
|
@@ -1894,7 +1860,7 @@ function un({ editor: e, onClose: t }) {
|
|
|
1894
1860
|
return e.addEventListener("scroll", t, { passive: !0 }), () => e.removeEventListener("scroll", t);
|
|
1895
1861
|
}, [!!o]), S(() => {
|
|
1896
1862
|
let e = _.current;
|
|
1897
|
-
|
|
1863
|
+
e && v.current && (e.scrollTop = e.scrollHeight);
|
|
1898
1864
|
}, [o]);
|
|
1899
1865
|
let k = b((t, n, r) => {
|
|
1900
1866
|
let i = new Set(on(e, r.from, r.to).map((e) => e.src));
|
|
@@ -1913,22 +1879,18 @@ function un({ editor: e, onClose: t }) {
|
|
|
1913
1879
|
from: r.from,
|
|
1914
1880
|
to: r.to
|
|
1915
1881
|
}, a = on(e, i.from, i.to);
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
});
|
|
1921
|
-
return;
|
|
1922
|
-
}
|
|
1923
|
-
k(n, o, i), t();
|
|
1882
|
+
a.length > 0 ? m({
|
|
1883
|
+
position: n,
|
|
1884
|
+
willRemove: a
|
|
1885
|
+
}) : (k(n, o, i), t());
|
|
1924
1886
|
}, [
|
|
1925
1887
|
e,
|
|
1926
1888
|
o,
|
|
1927
1889
|
k,
|
|
1928
1890
|
t
|
|
1929
1891
|
]), j = b(() => {
|
|
1930
|
-
if (!
|
|
1931
|
-
let { position: n } =
|
|
1892
|
+
if (!f) return;
|
|
1893
|
+
let { position: n } = f, r = n === "replaceAll" ? {
|
|
1932
1894
|
from: 0,
|
|
1933
1895
|
to: e.state.doc.content.size
|
|
1934
1896
|
} : {
|
|
@@ -1937,7 +1899,7 @@ function un({ editor: e, onClose: t }) {
|
|
|
1937
1899
|
};
|
|
1938
1900
|
k(n, o, r), m(null), t();
|
|
1939
1901
|
}, [
|
|
1940
|
-
|
|
1902
|
+
f,
|
|
1941
1903
|
e,
|
|
1942
1904
|
o,
|
|
1943
1905
|
k,
|
|
@@ -1945,7 +1907,7 @@ function un({ editor: e, onClose: t }) {
|
|
|
1945
1907
|
]), M = b(() => {
|
|
1946
1908
|
s(""), r(null), d(null);
|
|
1947
1909
|
}, []), N = {};
|
|
1948
|
-
for (let e of
|
|
1910
|
+
for (let e of f?.willRemove ?? []) N[e.type] = (N[e.type] ?? 0) + 1;
|
|
1949
1911
|
return /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ O("div", {
|
|
1950
1912
|
className: "ai-selector w-full flex-1 min-h-0 flex flex-col",
|
|
1951
1913
|
children: [
|
|
@@ -1953,12 +1915,12 @@ function un({ editor: e, onClose: t }) {
|
|
|
1953
1915
|
className: "flex items-center justify-between pl-3 pr-1.5 py-1.5 border-b border-default-100 shrink-0",
|
|
1954
1916
|
children: [/* @__PURE__ */ O("span", {
|
|
1955
1917
|
className: "flex items-center gap-1.5 text-xs font-medium text-default-500",
|
|
1956
|
-
children: [/* @__PURE__ */ D(Ut, { className: "text-primary" }),
|
|
1918
|
+
children: [/* @__PURE__ */ D(Ut, { className: "text-primary" }), p("editor.ai.trigger")]
|
|
1957
1919
|
}), /* @__PURE__ */ D("button", {
|
|
1958
1920
|
type: "button",
|
|
1959
1921
|
onClick: t,
|
|
1960
|
-
"aria-label":
|
|
1961
|
-
title:
|
|
1922
|
+
"aria-label": p("editor.ai.close"),
|
|
1923
|
+
title: p("editor.ai.close"),
|
|
1962
1924
|
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",
|
|
1963
1925
|
children: /* @__PURE__ */ D(Kt, {})
|
|
1964
1926
|
})]
|
|
@@ -1969,13 +1931,13 @@ function un({ editor: e, onClose: t }) {
|
|
|
1969
1931
|
type: "button",
|
|
1970
1932
|
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"}`,
|
|
1971
1933
|
onClick: () => y(e),
|
|
1972
|
-
title:
|
|
1934
|
+
title: p(r),
|
|
1973
1935
|
children: [/* @__PURE__ */ D("span", {
|
|
1974
1936
|
className: "text-base leading-none",
|
|
1975
1937
|
children: i
|
|
1976
1938
|
}), /* @__PURE__ */ D("span", {
|
|
1977
1939
|
className: "text-[11px] leading-none truncate",
|
|
1978
|
-
children:
|
|
1940
|
+
children: p(t)
|
|
1979
1941
|
})]
|
|
1980
1942
|
}, e))
|
|
1981
1943
|
}),
|
|
@@ -1984,12 +1946,12 @@ function un({ editor: e, onClose: t }) {
|
|
|
1984
1946
|
children: [
|
|
1985
1947
|
!n && /* @__PURE__ */ D("p", {
|
|
1986
1948
|
className: "text-[11px] text-default-400 leading-relaxed",
|
|
1987
|
-
children:
|
|
1949
|
+
children: p("editor.ai.triggerDesc")
|
|
1988
1950
|
}),
|
|
1989
1951
|
n === "zap" && !c && !o && !u && /* @__PURE__ */ O("div", { children: [/* @__PURE__ */ D("input", {
|
|
1990
1952
|
ref: g,
|
|
1991
1953
|
className: "w-full px-3 py-2 text-sm border border-default-200 rounded-lg focus:outline-none focus:border-primary bg-background",
|
|
1992
|
-
placeholder:
|
|
1954
|
+
placeholder: p("editor.ai.customPlaceholder"),
|
|
1993
1955
|
value: i,
|
|
1994
1956
|
onChange: (e) => a(e.target.value),
|
|
1995
1957
|
onKeyDown: (e) => {
|
|
@@ -2002,12 +1964,12 @@ function un({ editor: e, onClose: t }) {
|
|
|
2002
1964
|
className: "px-3 py-1.5 text-xs bg-primary text-white rounded-lg disabled:opacity-50",
|
|
2003
1965
|
disabled: !i.trim(),
|
|
2004
1966
|
onClick: () => C("zap"),
|
|
2005
|
-
children:
|
|
1967
|
+
children: p("editor.ai.confirm")
|
|
2006
1968
|
}), /* @__PURE__ */ D("button", {
|
|
2007
1969
|
type: "button",
|
|
2008
1970
|
className: "px-3 py-1.5 text-xs border border-default-200 rounded-lg hover:bg-default-100",
|
|
2009
1971
|
onClick: () => r(null),
|
|
2010
|
-
children:
|
|
1972
|
+
children: p("editor.ai.back")
|
|
2011
1973
|
})]
|
|
2012
1974
|
})] }),
|
|
2013
1975
|
(c || o || u) && /* @__PURE__ */ O("div", {
|
|
@@ -2018,7 +1980,7 @@ function un({ editor: e, onClose: t }) {
|
|
|
2018
1980
|
children: [/* @__PURE__ */ D("span", {
|
|
2019
1981
|
className: "animate-spin",
|
|
2020
1982
|
children: "⏳"
|
|
2021
|
-
}),
|
|
1983
|
+
}), p("editor.ai.thinking")]
|
|
2022
1984
|
}),
|
|
2023
1985
|
o && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ O("div", {
|
|
2024
1986
|
ref: _,
|
|
@@ -2034,24 +1996,24 @@ function un({ editor: e, onClose: t }) {
|
|
|
2034
1996
|
type: "button",
|
|
2035
1997
|
className: "px-3 py-1.5 text-xs bg-primary text-white rounded-lg",
|
|
2036
1998
|
onClick: () => A("replaceAll"),
|
|
2037
|
-
children:
|
|
1999
|
+
children: p("editor.ai.replaceAll")
|
|
2038
2000
|
}) : /* @__PURE__ */ D("button", {
|
|
2039
2001
|
type: "button",
|
|
2040
2002
|
className: "px-3 py-1.5 text-xs bg-primary text-white rounded-lg",
|
|
2041
2003
|
onClick: () => A("replace"),
|
|
2042
|
-
children:
|
|
2004
|
+
children: p("editor.ai.replace")
|
|
2043
2005
|
}),
|
|
2044
2006
|
/* @__PURE__ */ D("button", {
|
|
2045
2007
|
type: "button",
|
|
2046
2008
|
className: "px-3 py-1.5 text-xs border border-default-200 rounded-lg hover:bg-default-100",
|
|
2047
2009
|
onClick: () => A("below"),
|
|
2048
|
-
children:
|
|
2010
|
+
children: p("editor.ai.insert")
|
|
2049
2011
|
}),
|
|
2050
2012
|
/* @__PURE__ */ D("button", {
|
|
2051
2013
|
type: "button",
|
|
2052
2014
|
className: "px-3 py-1.5 text-xs text-danger",
|
|
2053
2015
|
onClick: M,
|
|
2054
|
-
children:
|
|
2016
|
+
children: p("editor.ai.discard")
|
|
2055
2017
|
})
|
|
2056
2018
|
]
|
|
2057
2019
|
})] }),
|
|
@@ -2063,7 +2025,7 @@ function un({ editor: e, onClose: t }) {
|
|
|
2063
2025
|
onClick: () => {
|
|
2064
2026
|
d(null), r(null);
|
|
2065
2027
|
},
|
|
2066
|
-
children:
|
|
2028
|
+
children: p("editor.ai.back")
|
|
2067
2029
|
})]
|
|
2068
2030
|
})
|
|
2069
2031
|
]
|
|
@@ -2071,7 +2033,7 @@ function un({ editor: e, onClose: t }) {
|
|
|
2071
2033
|
]
|
|
2072
2034
|
})
|
|
2073
2035
|
]
|
|
2074
|
-
}),
|
|
2036
|
+
}), f && /* @__PURE__ */ O("div", {
|
|
2075
2037
|
className: "qed-root",
|
|
2076
2038
|
style: { zIndex: 1e4 },
|
|
2077
2039
|
onClick: () => m(null),
|
|
@@ -2086,12 +2048,12 @@ function un({ editor: e, onClose: t }) {
|
|
|
2086
2048
|
className: "qed-header",
|
|
2087
2049
|
children: [/* @__PURE__ */ D("h2", {
|
|
2088
2050
|
className: "qed-title",
|
|
2089
|
-
children:
|
|
2051
|
+
children: f.position === "replaceAll" ? p("editor.ai.replaceAllTitle") : p("editor.ai.replaceTitle")
|
|
2090
2052
|
}), /* @__PURE__ */ D("button", {
|
|
2091
2053
|
type: "button",
|
|
2092
2054
|
className: "qed-close",
|
|
2093
2055
|
onClick: () => m(null),
|
|
2094
|
-
"aria-label":
|
|
2056
|
+
"aria-label": p("editor.ai.close"),
|
|
2095
2057
|
children: "✕"
|
|
2096
2058
|
})]
|
|
2097
2059
|
}),
|
|
@@ -2099,16 +2061,16 @@ function un({ editor: e, onClose: t }) {
|
|
|
2099
2061
|
className: "qed-body",
|
|
2100
2062
|
children: [/* @__PURE__ */ D("p", {
|
|
2101
2063
|
className: "mb-2",
|
|
2102
|
-
children:
|
|
2064
|
+
children: f.position === "replaceAll" ? p("editor.ai.replaceAllText") : p("editor.ai.replaceText")
|
|
2103
2065
|
}), Object.keys(N).length > 0 && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("p", {
|
|
2104
2066
|
className: "text-xs text-default-500",
|
|
2105
|
-
children:
|
|
2067
|
+
children: p("editor.ai.removeNodes")
|
|
2106
2068
|
}), /* @__PURE__ */ D("ul", {
|
|
2107
2069
|
className: "mt-1 space-y-0.5",
|
|
2108
2070
|
children: Object.entries(N).map(([e, t]) => /* @__PURE__ */ O("li", {
|
|
2109
2071
|
className: "text-sm text-default-700",
|
|
2110
2072
|
children: [
|
|
2111
|
-
|
|
2073
|
+
p(rn[e] ?? e),
|
|
2112
2074
|
" ×",
|
|
2113
2075
|
t
|
|
2114
2076
|
]
|
|
@@ -2126,20 +2088,19 @@ function un({ editor: e, onClose: t }) {
|
|
|
2126
2088
|
type: "button",
|
|
2127
2089
|
className: "qed-btn qed-btn--ghost",
|
|
2128
2090
|
onClick: () => m(null),
|
|
2129
|
-
children:
|
|
2091
|
+
children: p("editor.ai.cancel")
|
|
2130
2092
|
}), /* @__PURE__ */ D("button", {
|
|
2131
2093
|
type: "button",
|
|
2132
2094
|
className: "qed-btn qed-btn--primary",
|
|
2133
2095
|
onClick: j,
|
|
2134
|
-
children:
|
|
2096
|
+
children: p("editor.ai.confirmReplace")
|
|
2135
2097
|
})]
|
|
2136
2098
|
})
|
|
2137
2099
|
]
|
|
2138
2100
|
})]
|
|
2139
2101
|
})] });
|
|
2140
2102
|
}
|
|
2141
|
-
|
|
2142
|
-
//#region src/editor/attachment-limits.ts
|
|
2103
|
+
// src/editor/attachment-limits.ts
|
|
2143
2104
|
var dn = /* @__PURE__ */ new Set([
|
|
2144
2105
|
"attachmentEmbed",
|
|
2145
2106
|
"videoEmbed",
|
|
@@ -2175,8 +2136,7 @@ function hn(e, t, n) {
|
|
|
2175
2136
|
}
|
|
2176
2137
|
return null;
|
|
2177
2138
|
}
|
|
2178
|
-
|
|
2179
|
-
//#region src/editor/utils/delete-confirm.ts
|
|
2139
|
+
// src/editor/utils/delete-confirm.ts
|
|
2180
2140
|
var gn = !1, _n = null, vn = 5e3;
|
|
2181
2141
|
function yn() {
|
|
2182
2142
|
return gn;
|
|
@@ -2193,17 +2153,12 @@ function xn(e) {
|
|
|
2193
2153
|
function Sn() {
|
|
2194
2154
|
return bn;
|
|
2195
2155
|
}
|
|
2196
|
-
|
|
2197
|
-
//#region src/editor/utils/delete-confirm-dialog.tsx
|
|
2156
|
+
// src/editor/utils/delete-confirm-dialog.tsx
|
|
2198
2157
|
var Cn = 300;
|
|
2199
2158
|
function wn({ open: e, title: t, message: n, confirmText: r = "删除", cancelText: i = "取消", onConfirm: a, onCancel: o }) {
|
|
2200
2159
|
let [s, c] = T(!1), l = w(!1), u = Sn();
|
|
2201
2160
|
return x(() => {
|
|
2202
|
-
|
|
2203
|
-
l.current = !1;
|
|
2204
|
-
return;
|
|
2205
|
-
}
|
|
2206
|
-
!u || l.current || (l.current = !0, u({
|
|
2161
|
+
e ? u && !l.current && (l.current = !0, u({
|
|
2207
2162
|
open: e,
|
|
2208
2163
|
title: t,
|
|
2209
2164
|
message: n,
|
|
@@ -2211,7 +2166,7 @@ function wn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2211
2166
|
cancelText: i,
|
|
2212
2167
|
onConfirm: a,
|
|
2213
2168
|
onCancel: o
|
|
2214
|
-
}));
|
|
2169
|
+
})) : l.current = !1;
|
|
2215
2170
|
}, [
|
|
2216
2171
|
e,
|
|
2217
2172
|
u,
|
|
@@ -2223,7 +2178,7 @@ function wn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2223
2178
|
o
|
|
2224
2179
|
]), x(() => {
|
|
2225
2180
|
e || c(!1);
|
|
2226
|
-
}, [e]), u || !e ? null :
|
|
2181
|
+
}, [e]), u || !e ? null : L(/* @__PURE__ */ D("div", {
|
|
2227
2182
|
className: "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none",
|
|
2228
2183
|
onClick: () => {
|
|
2229
2184
|
s || o();
|
|
@@ -2278,8 +2233,7 @@ function wn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
|
|
|
2278
2233
|
})
|
|
2279
2234
|
}), document.body);
|
|
2280
2235
|
}
|
|
2281
|
-
|
|
2282
|
-
//#region src/editor/extensions/image-view.tsx
|
|
2236
|
+
// src/editor/extensions/image-view.tsx
|
|
2283
2237
|
function Tn(e) {
|
|
2284
2238
|
return /^(\.\.?\/|[a-zA-Z]:\\|file:\/\/)/.test(e) ? !0 : !(/^[a-z]+:\/\//i.test(e) || e.startsWith("/") || e.startsWith("data:") || e.startsWith("blob:"));
|
|
2285
2239
|
}
|
|
@@ -2302,7 +2256,7 @@ function En({ node: e, deleteNode: t, editor: r }) {
|
|
|
2302
2256
|
let e = !1;
|
|
2303
2257
|
return (async () => {
|
|
2304
2258
|
try {
|
|
2305
|
-
let { signPreviewUrlHeaders: t } = await import("./signed-fetch-
|
|
2259
|
+
let { signPreviewUrlHeaders: t } = await import("./signed-fetch-iBM0Zozv.js").then((e) => e.i), n = await t(p);
|
|
2306
2260
|
if (!n) return;
|
|
2307
2261
|
let r = await fetch(p, { headers: n });
|
|
2308
2262
|
if (!r.ok) return;
|
|
@@ -2531,21 +2485,15 @@ function En({ node: e, deleteNode: t, editor: r }) {
|
|
|
2531
2485
|
className: "image-lightbox-img",
|
|
2532
2486
|
onClick: (e) => e.stopPropagation(),
|
|
2533
2487
|
onError: () => {
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
let e = await t.blob(), n = URL.createObjectURL(e);
|
|
2544
|
-
C.current && URL.revokeObjectURL(C.current), C.current = n, v.current && (v.current.src = n);
|
|
2545
|
-
}
|
|
2546
|
-
} catch {}
|
|
2547
|
-
})();
|
|
2548
|
-
}
|
|
2488
|
+
k.current || (k.current = !0, S.current && v.current ? v.current.src = S.current : (async () => {
|
|
2489
|
+
try {
|
|
2490
|
+
let e = await n(p), t = await fetch(p, e ? { headers: e } : {});
|
|
2491
|
+
if (t.ok) {
|
|
2492
|
+
let e = await t.blob(), n = URL.createObjectURL(e);
|
|
2493
|
+
C.current && URL.revokeObjectURL(C.current), C.current = n, v.current && (v.current.src = n);
|
|
2494
|
+
}
|
|
2495
|
+
} catch {}
|
|
2496
|
+
})());
|
|
2549
2497
|
}
|
|
2550
2498
|
})]
|
|
2551
2499
|
}),
|
|
@@ -2566,8 +2514,7 @@ function En({ node: e, deleteNode: t, editor: r }) {
|
|
|
2566
2514
|
]
|
|
2567
2515
|
});
|
|
2568
2516
|
}
|
|
2569
|
-
|
|
2570
|
-
//#region src/editor/embeds/attachment-view.tsx
|
|
2517
|
+
// src/editor/embeds/attachment-view.tsx
|
|
2571
2518
|
var Dn = y(() => import("@file-viewer/react")), On = /* @__PURE__ */ new Set(), kn = {
|
|
2572
2519
|
rendererMode: "replace",
|
|
2573
2520
|
autoRenderers: !0,
|
|
@@ -2902,73 +2849,73 @@ function zn(e, t, n) {
|
|
|
2902
2849
|
});
|
|
2903
2850
|
}
|
|
2904
2851
|
function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
2905
|
-
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() => On.has(s)), [u, d] = T(null), [
|
|
2852
|
+
let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() => On.has(s)), [u, d] = T(null), [f, 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" : p("editor.attachment.lost")), se = e.attrs.size || 0, ce = Pn(W), G = !U;
|
|
2906
2853
|
x(() => {
|
|
2907
2854
|
if (!c) {
|
|
2908
|
-
|
|
2855
|
+
H(void 0), oe(!1);
|
|
2909
2856
|
return;
|
|
2910
2857
|
}
|
|
2911
|
-
let e = An[
|
|
2858
|
+
let e = An[ce];
|
|
2912
2859
|
if (!e) {
|
|
2913
|
-
|
|
2860
|
+
H(void 0), oe(!1);
|
|
2914
2861
|
return;
|
|
2915
2862
|
}
|
|
2916
2863
|
let t = !0;
|
|
2917
|
-
return
|
|
2918
|
-
t &&
|
|
2864
|
+
return H(void 0), oe(!1), jn[e]().then((e) => {
|
|
2865
|
+
t && H(e);
|
|
2919
2866
|
}).catch((n) => {
|
|
2920
|
-
console.error(`[attachment] renderer "${e}" load failed:`, n), t &&
|
|
2867
|
+
console.error(`[attachment] renderer "${e}" load failed:`, n), t && oe(!0);
|
|
2921
2868
|
}), () => {
|
|
2922
2869
|
t = !1;
|
|
2923
2870
|
};
|
|
2924
|
-
}, [c,
|
|
2925
|
-
let
|
|
2871
|
+
}, [c, ce]);
|
|
2872
|
+
let K = C(() => ({
|
|
2926
2873
|
...kn,
|
|
2927
|
-
renderers:
|
|
2874
|
+
renderers: V ? [V] : [],
|
|
2928
2875
|
rendererMode: "replace"
|
|
2929
|
-
}), [
|
|
2876
|
+
}), [V]), le = b((e) => {
|
|
2930
2877
|
l((t) => {
|
|
2931
2878
|
let n = typeof e == "function" ? e(t) : e;
|
|
2932
|
-
return
|
|
2879
|
+
return U && (n ? On.add(U) : On.delete(U)), n;
|
|
2933
2880
|
});
|
|
2934
|
-
}, [
|
|
2881
|
+
}, [U]);
|
|
2935
2882
|
x(() => {
|
|
2936
|
-
l(
|
|
2937
|
-
}, [
|
|
2883
|
+
l(U ? On.has(U) : !1);
|
|
2884
|
+
}, [U]);
|
|
2938
2885
|
let ue = b(() => {
|
|
2939
|
-
F.current = !0,
|
|
2940
|
-
window.scrollTo(0, ee.current), I.current && (I.current.scrollTop = te.current), F.current &&
|
|
2886
|
+
F.current = !0, le(!0), window.setTimeout(() => {
|
|
2887
|
+
window.scrollTo(0, ee.current), I.current && (I.current.scrollTop = te.current), F.current && le(!0), F.current = !1;
|
|
2941
2888
|
}, 0);
|
|
2942
|
-
}, [
|
|
2943
|
-
|
|
2944
|
-
}, [
|
|
2889
|
+
}, [le]), de = b(async () => {
|
|
2890
|
+
z === "web" ? (B("none"), document.body.style.overflow = "", ue()) : (z === "native" && document.fullscreenElement && await document.exitFullscreen(), ee.current = window.scrollY, te.current = I.current?.scrollTop ?? 0, document.body.style.overflow = "hidden", B("web"));
|
|
2891
|
+
}, [z]), fe = b(async () => {
|
|
2945
2892
|
let e = M.current;
|
|
2946
|
-
e && (
|
|
2947
|
-
}, [
|
|
2948
|
-
|
|
2949
|
-
}, [
|
|
2893
|
+
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")));
|
|
2894
|
+
}, [z, ue]), pe = b(() => {
|
|
2895
|
+
z === "none" && (F.current || le((e) => !e));
|
|
2896
|
+
}, [z]);
|
|
2950
2897
|
x(() => {
|
|
2951
2898
|
let e = () => {
|
|
2952
|
-
document.fullscreenElement || (
|
|
2899
|
+
document.fullscreenElement || (z === "native" && B("none"), ue());
|
|
2953
2900
|
}, t = (e) => {
|
|
2954
|
-
e.key === "Escape" &&
|
|
2901
|
+
e.key === "Escape" && z === "web" && (B("none"), document.body.style.overflow = "", ue());
|
|
2955
2902
|
};
|
|
2956
2903
|
return document.addEventListener("fullscreenchange", e), window.addEventListener("keydown", t), () => {
|
|
2957
2904
|
document.removeEventListener("fullscreenchange", e), window.removeEventListener("keydown", t);
|
|
2958
2905
|
};
|
|
2959
|
-
}, [
|
|
2906
|
+
}, [z, ue]), x(() => {
|
|
2960
2907
|
let e = (e) => {
|
|
2961
2908
|
if (e.key !== "Backspace" && e.key !== "Delete" || !o || !i || yn()) return;
|
|
2962
2909
|
let t = a?.view?.dom, n = e.target;
|
|
2963
2910
|
if (a?.isFocused && n instanceof Node && t?.contains(n)) {
|
|
2964
2911
|
if (e.preventDefault(), e.stopPropagation(), a) {
|
|
2965
2912
|
let { from: e, to: t } = a.state.selection;
|
|
2966
|
-
|
|
2913
|
+
R.current = {
|
|
2967
2914
|
from: e,
|
|
2968
2915
|
to: t
|
|
2969
2916
|
};
|
|
2970
2917
|
}
|
|
2971
|
-
window.getSelection()?.removeAllRanges(), $(!0),
|
|
2918
|
+
window.getSelection()?.removeAllRanges(), $(!0), L(!0);
|
|
2972
2919
|
}
|
|
2973
2920
|
};
|
|
2974
2921
|
return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
|
|
@@ -2977,29 +2924,29 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
2977
2924
|
a,
|
|
2978
2925
|
o
|
|
2979
2926
|
]), x(() => {
|
|
2980
|
-
if (!c || !In(
|
|
2927
|
+
if (!c || !In(U)) {
|
|
2981
2928
|
d(null), y(null), N.current = null;
|
|
2982
2929
|
return;
|
|
2983
2930
|
}
|
|
2984
|
-
if (N.current ===
|
|
2931
|
+
if (N.current === U) return;
|
|
2985
2932
|
let e = new AbortController(), r = !0;
|
|
2986
2933
|
return g(!0), y(null), (async () => {
|
|
2987
|
-
let i =
|
|
2988
|
-
if (!a && !i && (a = await Rn(
|
|
2989
|
-
let n = await t(
|
|
2934
|
+
let i = U.includes("?X-Amz-"), a = null, o = null;
|
|
2935
|
+
if (!a && !i && (a = await Rn(U, e.signal)), !a && !i) try {
|
|
2936
|
+
let n = await t(U);
|
|
2990
2937
|
n && (a = await Rn(n, e.signal) || await zn(n, void 0, e.signal));
|
|
2991
2938
|
} catch (e) {
|
|
2992
2939
|
console.warn("[attachment] signPreviewUrl failed:", e);
|
|
2993
2940
|
}
|
|
2994
2941
|
if (!a && !i) try {
|
|
2995
|
-
let t = await n(
|
|
2942
|
+
let t = await n(U);
|
|
2996
2943
|
if (t) {
|
|
2997
2944
|
let n = { "X-Requested-With": "XMLHttpRequest" };
|
|
2998
2945
|
t.forEach((e, t) => {
|
|
2999
2946
|
n[t] = e;
|
|
3000
2947
|
});
|
|
3001
2948
|
try {
|
|
3002
|
-
a = await zn(
|
|
2949
|
+
a = await zn(U, n, e.signal);
|
|
3003
2950
|
} catch (e) {
|
|
3004
2951
|
console.warn("[attachment] signed headers XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
3005
2952
|
}
|
|
@@ -3008,67 +2955,61 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3008
2955
|
console.warn("[attachment] signPreviewUrlHeaders failed:", e);
|
|
3009
2956
|
}
|
|
3010
2957
|
if (!a) try {
|
|
3011
|
-
a = await zn(
|
|
2958
|
+
a = await zn(U, i ? void 0 : { "X-Requested-With": "XMLHttpRequest" }, e.signal);
|
|
3012
2959
|
} catch (e) {
|
|
3013
2960
|
console.warn("[attachment] plain XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
|
|
3014
2961
|
}
|
|
3015
2962
|
if (!a) throw o || /* @__PURE__ */ Error("所有 fetch 方法均失败");
|
|
3016
2963
|
if (!r) return;
|
|
3017
|
-
d(a), N.current =
|
|
2964
|
+
d(a), N.current = U;
|
|
3018
2965
|
let s = URL.createObjectURL(new Blob([a], { type: "application/octet-stream" }));
|
|
3019
2966
|
m(s), g(!1);
|
|
3020
2967
|
})().catch((e) => {
|
|
3021
|
-
|
|
3022
|
-
if (N.current === H) {
|
|
3023
|
-
g(!1);
|
|
3024
|
-
return;
|
|
3025
|
-
}
|
|
3026
|
-
y(e instanceof Error ? e.message : "附件读取失败,请检查对象存储 CORS 和公开访问权限");
|
|
3027
|
-
}
|
|
2968
|
+
r && (e instanceof DOMException && e.name === "AbortError" || (N.current === U ? g(!1) : y(e instanceof Error ? e.message : "附件读取失败,请检查对象存储 CORS 和公开访问权限")));
|
|
3028
2969
|
}), () => {
|
|
3029
2970
|
r = !1, e.abort();
|
|
3030
2971
|
};
|
|
3031
|
-
}, [c,
|
|
3032
|
-
|
|
2972
|
+
}, [c, U]), x(() => () => {
|
|
2973
|
+
f && URL.revokeObjectURL(f), d(null);
|
|
3033
2974
|
}, []), x(() => () => {
|
|
3034
|
-
|
|
3035
|
-
}, [
|
|
2975
|
+
f && URL.revokeObjectURL(f), m(null), d(null), N.current = null;
|
|
2976
|
+
}, [U]), x(() => {
|
|
3036
2977
|
if (k !== "success" && k !== "error") return;
|
|
3037
2978
|
let e = window.setTimeout(() => A(null), 2400);
|
|
3038
2979
|
return () => window.clearTimeout(e);
|
|
3039
2980
|
}, [k]);
|
|
3040
|
-
let
|
|
2981
|
+
let me = b(async () => {
|
|
3041
2982
|
E(!0), A("loading");
|
|
3042
2983
|
try {
|
|
3043
|
-
if (
|
|
2984
|
+
if (f) {
|
|
3044
2985
|
let e = document.createElement("a");
|
|
3045
|
-
e.href =
|
|
2986
|
+
e.href = f, e.download = W, document.body.appendChild(e), e.click(), document.body.removeChild(e), A("success");
|
|
3046
2987
|
return;
|
|
3047
2988
|
}
|
|
3048
|
-
let e =
|
|
2989
|
+
let e = U.includes("?X-Amz-"), r = null;
|
|
3049
2990
|
if (!e) try {
|
|
3050
|
-
let e = await t(
|
|
2991
|
+
let e = await t(U);
|
|
3051
2992
|
e && (r = await fetch(e, { headers: { "X-Requested-With": "XMLHttpRequest" } }), r.ok || (r = null));
|
|
3052
2993
|
} catch {}
|
|
3053
2994
|
if (!r && !e) try {
|
|
3054
|
-
let e = await n(
|
|
3055
|
-
e && (r = await fetch(
|
|
2995
|
+
let e = await n(U);
|
|
2996
|
+
e && (r = await fetch(U, { headers: (() => {
|
|
3056
2997
|
let t = new Headers(e);
|
|
3057
2998
|
return t.set("X-Requested-With", "XMLHttpRequest"), t;
|
|
3058
2999
|
})() }), r.ok || (r = null));
|
|
3059
3000
|
} catch {}
|
|
3060
|
-
if (r ||= await fetch(
|
|
3001
|
+
if (r ||= await fetch(U, { headers: { "X-Requested-With": "XMLHttpRequest" } }), !r || !r.ok) throw Error("下载失败");
|
|
3061
3002
|
let i = await r.blob(), a = URL.createObjectURL(i), o = document.createElement("a");
|
|
3062
|
-
o.href = a, o.download =
|
|
3003
|
+
o.href = a, o.download = W, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(a), A("success");
|
|
3063
3004
|
} catch (e) {
|
|
3064
3005
|
console.error("[attachment] download failed:", e), A("error");
|
|
3065
3006
|
} finally {
|
|
3066
3007
|
E(!1);
|
|
3067
3008
|
}
|
|
3068
3009
|
}, [
|
|
3069
|
-
H,
|
|
3070
3010
|
U,
|
|
3071
|
-
|
|
3011
|
+
W,
|
|
3012
|
+
f
|
|
3072
3013
|
]);
|
|
3073
3014
|
return /* @__PURE__ */ O(P, {
|
|
3074
3015
|
ref: j,
|
|
@@ -3103,15 +3044,15 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3103
3044
|
/* @__PURE__ */ D("path", { d: "M12 9v4" }),
|
|
3104
3045
|
/* @__PURE__ */ D("path", { d: "M12 17h.01" })
|
|
3105
3046
|
]
|
|
3106
|
-
}) : Nn(
|
|
3047
|
+
}) : Nn(W)
|
|
3107
3048
|
}), /* @__PURE__ */ O("div", {
|
|
3108
3049
|
className: "att-meta",
|
|
3109
3050
|
children: [/* @__PURE__ */ D("span", {
|
|
3110
3051
|
className: "att-name",
|
|
3111
|
-
children:
|
|
3112
|
-
}),
|
|
3052
|
+
children: W
|
|
3053
|
+
}), se > 0 && /* @__PURE__ */ D("span", {
|
|
3113
3054
|
className: "att-size",
|
|
3114
|
-
children: Mn(
|
|
3055
|
+
children: Mn(se)
|
|
3115
3056
|
})]
|
|
3116
3057
|
})]
|
|
3117
3058
|
}), /* @__PURE__ */ O("div", {
|
|
@@ -3164,14 +3105,14 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3164
3105
|
}), /* @__PURE__ */ O("div", {
|
|
3165
3106
|
className: "att-actions",
|
|
3166
3107
|
children: [
|
|
3167
|
-
|
|
3108
|
+
U && Fn(W) && /* @__PURE__ */ D("button", {
|
|
3168
3109
|
type: "button",
|
|
3169
3110
|
className: "att-btn",
|
|
3170
3111
|
onMouseDown: (e) => {
|
|
3171
3112
|
e.preventDefault(), e.stopPropagation(), pe();
|
|
3172
3113
|
},
|
|
3173
|
-
title:
|
|
3174
|
-
"aria-label":
|
|
3114
|
+
title: p("editor.attachment.preview"),
|
|
3115
|
+
"aria-label": p("editor.attachment.preview"),
|
|
3175
3116
|
children: /* @__PURE__ */ O("svg", {
|
|
3176
3117
|
width: "14",
|
|
3177
3118
|
height: "14",
|
|
@@ -3194,10 +3135,10 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3194
3135
|
/* @__PURE__ */ D("button", {
|
|
3195
3136
|
type: "button",
|
|
3196
3137
|
className: "att-btn",
|
|
3197
|
-
onClick:
|
|
3138
|
+
onClick: me,
|
|
3198
3139
|
disabled: S || G,
|
|
3199
|
-
title: S ? "正在准备下载" :
|
|
3200
|
-
"aria-label": S ? "正在准备下载" :
|
|
3140
|
+
title: S ? "正在准备下载" : p("editor.attachment.download"),
|
|
3141
|
+
"aria-label": S ? "正在准备下载" : p("editor.attachment.download"),
|
|
3201
3142
|
children: /* @__PURE__ */ D("svg", {
|
|
3202
3143
|
width: "14",
|
|
3203
3144
|
height: "14",
|
|
@@ -3217,10 +3158,10 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3217
3158
|
type: "button",
|
|
3218
3159
|
className: "att-btn att-btn--del",
|
|
3219
3160
|
onClick: () => {
|
|
3220
|
-
|
|
3161
|
+
o && !yn() && ($(!0), L(!0));
|
|
3221
3162
|
},
|
|
3222
|
-
title:
|
|
3223
|
-
"aria-label":
|
|
3163
|
+
title: p("editor.attachment.delete"),
|
|
3164
|
+
"aria-label": p("editor.attachment.delete"),
|
|
3224
3165
|
children: /* @__PURE__ */ D("svg", {
|
|
3225
3166
|
width: "14",
|
|
3226
3167
|
height: "14",
|
|
@@ -3241,7 +3182,7 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3241
3182
|
})]
|
|
3242
3183
|
}), c && /* @__PURE__ */ O("div", {
|
|
3243
3184
|
ref: M,
|
|
3244
|
-
className: `att-preview-wrap ${
|
|
3185
|
+
className: `att-preview-wrap ${z === "web" ? "is-web-fs" : ""}`,
|
|
3245
3186
|
style: {
|
|
3246
3187
|
position: "relative",
|
|
3247
3188
|
height: 500,
|
|
@@ -3255,10 +3196,10 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3255
3196
|
height: "100%",
|
|
3256
3197
|
overflow: "auto"
|
|
3257
3198
|
},
|
|
3258
|
-
children: h && !u && !
|
|
3199
|
+
children: h && !u && !f ? /* @__PURE__ */ D("div", {
|
|
3259
3200
|
className: "flex items-center justify-center h-full text-default-400 text-sm",
|
|
3260
|
-
children:
|
|
3261
|
-
}) : (_ ||
|
|
3201
|
+
children: p("editor.attachment.loadingPreview")
|
|
3202
|
+
}) : (_ || ae) && !u && !f ? /* @__PURE__ */ O("div", {
|
|
3262
3203
|
className: "flex h-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-default-500",
|
|
3263
3204
|
children: [/* @__PURE__ */ D("div", {
|
|
3264
3205
|
className: "font-medium text-default-700",
|
|
@@ -3271,17 +3212,17 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3271
3212
|
fallback: /* @__PURE__ */ D("div", {
|
|
3272
3213
|
className: "flex items-center justify-center h-full text-default-400 text-sm",
|
|
3273
3214
|
style: { background: "#fff" },
|
|
3274
|
-
children:
|
|
3215
|
+
children: p("editor.attachment.loadingPreview")
|
|
3275
3216
|
}),
|
|
3276
|
-
children: u ||
|
|
3217
|
+
children: u || f || U ? V ? /* @__PURE__ */ D(Dn, {
|
|
3277
3218
|
buffer: u || void 0,
|
|
3278
|
-
url:
|
|
3279
|
-
name:
|
|
3280
|
-
filename:
|
|
3281
|
-
type:
|
|
3282
|
-
size:
|
|
3283
|
-
options:
|
|
3284
|
-
}, `${
|
|
3219
|
+
url: f || U,
|
|
3220
|
+
name: W,
|
|
3221
|
+
filename: W,
|
|
3222
|
+
type: ce,
|
|
3223
|
+
size: se || u?.byteLength || 0,
|
|
3224
|
+
options: K
|
|
3225
|
+
}, `${U}-${re}`) : /* @__PURE__ */ D("div", {
|
|
3285
3226
|
className: "flex h-full items-center justify-center text-sm text-default-400",
|
|
3286
3227
|
children: "正在加载预览引擎..."
|
|
3287
3228
|
}) : /* @__PURE__ */ D("div", {
|
|
@@ -3309,14 +3250,14 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3309
3250
|
children: [/* @__PURE__ */ D("button", {
|
|
3310
3251
|
type: "button",
|
|
3311
3252
|
onClick: de,
|
|
3312
|
-
title:
|
|
3313
|
-
"aria-label":
|
|
3253
|
+
title: z === "web" ? "退出网页全屏" : "网页全屏",
|
|
3254
|
+
"aria-label": z === "web" ? "退出网页全屏" : "网页全屏",
|
|
3314
3255
|
style: {
|
|
3315
3256
|
width: 28,
|
|
3316
3257
|
height: 28,
|
|
3317
3258
|
borderRadius: 6,
|
|
3318
3259
|
border: "none",
|
|
3319
|
-
background:
|
|
3260
|
+
background: z === "web" ? "#e4e4e7" : "transparent",
|
|
3320
3261
|
cursor: "pointer",
|
|
3321
3262
|
display: "flex",
|
|
3322
3263
|
alignItems: "center",
|
|
@@ -3325,10 +3266,10 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3325
3266
|
transition: "background 0.12s"
|
|
3326
3267
|
},
|
|
3327
3268
|
onMouseEnter: (e) => {
|
|
3328
|
-
|
|
3269
|
+
z !== "web" && (e.currentTarget.style.background = "#f4f4f5");
|
|
3329
3270
|
},
|
|
3330
3271
|
onMouseLeave: (e) => {
|
|
3331
|
-
|
|
3272
|
+
z !== "web" && (e.currentTarget.style.background = "transparent");
|
|
3332
3273
|
},
|
|
3333
3274
|
children: /* @__PURE__ */ D("svg", {
|
|
3334
3275
|
width: "14",
|
|
@@ -3347,14 +3288,14 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3347
3288
|
}), /* @__PURE__ */ D("button", {
|
|
3348
3289
|
type: "button",
|
|
3349
3290
|
onClick: fe,
|
|
3350
|
-
title:
|
|
3351
|
-
"aria-label":
|
|
3291
|
+
title: z === "native" ? "退出全屏" : "全屏",
|
|
3292
|
+
"aria-label": z === "native" ? "退出全屏" : "全屏",
|
|
3352
3293
|
style: {
|
|
3353
3294
|
width: 28,
|
|
3354
3295
|
height: 28,
|
|
3355
3296
|
borderRadius: 6,
|
|
3356
3297
|
border: "none",
|
|
3357
|
-
background:
|
|
3298
|
+
background: z === "native" ? "#e4e4e7" : "transparent",
|
|
3358
3299
|
cursor: "pointer",
|
|
3359
3300
|
display: "flex",
|
|
3360
3301
|
alignItems: "center",
|
|
@@ -3363,10 +3304,10 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3363
3304
|
transition: "background 0.12s"
|
|
3364
3305
|
},
|
|
3365
3306
|
onMouseEnter: (e) => {
|
|
3366
|
-
|
|
3307
|
+
z !== "native" && (e.currentTarget.style.background = "#f4f4f5");
|
|
3367
3308
|
},
|
|
3368
3309
|
onMouseLeave: (e) => {
|
|
3369
|
-
|
|
3310
|
+
z !== "native" && (e.currentTarget.style.background = "transparent");
|
|
3370
3311
|
},
|
|
3371
3312
|
children: /* @__PURE__ */ D("svg", {
|
|
3372
3313
|
width: "14",
|
|
@@ -3388,21 +3329,21 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3388
3329
|
}), /* @__PURE__ */ D(wn, {
|
|
3389
3330
|
open: ne,
|
|
3390
3331
|
title: "确认删除附件",
|
|
3391
|
-
message: G ? "此操作将删除该附件节点,不可撤销。" : `此操作将同时删除对象存储中的文件(${
|
|
3332
|
+
message: G ? "此操作将删除该附件节点,不可撤销。" : `此操作将同时删除对象存储中的文件(${W}),不可撤销。`,
|
|
3392
3333
|
onCancel: () => {
|
|
3393
|
-
$(!1),
|
|
3334
|
+
$(!1), L(!1);
|
|
3394
3335
|
},
|
|
3395
3336
|
onConfirm: async () => {
|
|
3396
3337
|
try {
|
|
3397
3338
|
if (a) {
|
|
3398
|
-
let e =
|
|
3339
|
+
let e = R.current, t = e?.from ?? a.state.selection.from, n = e?.to ?? a.state.selection.to, r = [];
|
|
3399
3340
|
a.state.doc.nodesBetween(t, n, (e) => {
|
|
3400
3341
|
e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(qt(e.attrs.src));
|
|
3401
3342
|
}), await Promise.all(r), $(!1), await new Promise((e) => setTimeout(e, 300)), a.chain().focus().setTextSelection({
|
|
3402
3343
|
from: t,
|
|
3403
3344
|
to: n
|
|
3404
3345
|
}).deleteSelection().run();
|
|
3405
|
-
} else await qt(
|
|
3346
|
+
} else await qt(U), $(!1), await new Promise((e) => setTimeout(e, 300)), r();
|
|
3406
3347
|
} catch {
|
|
3407
3348
|
$(!1);
|
|
3408
3349
|
}
|
|
@@ -3410,9 +3351,8 @@ function Bn({ node: e, deleteNode: r, selected: i, editor: a }) {
|
|
|
3410
3351
|
})]
|
|
3411
3352
|
});
|
|
3412
3353
|
}
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
var Vn = ae.create({
|
|
3354
|
+
// src/editor/embeds/attachment.ts
|
|
3355
|
+
var Vn = ie.create({
|
|
3416
3356
|
name: "attachmentEmbed",
|
|
3417
3357
|
group: "block",
|
|
3418
3358
|
atom: !0,
|
|
@@ -3465,9 +3405,22 @@ var Vn = ae.create({
|
|
|
3465
3405
|
];
|
|
3466
3406
|
}
|
|
3467
3407
|
});
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3408
|
+
// src/editor/utils/insert-media.ts
|
|
3409
|
+
function Hn(e, t, n) {
|
|
3410
|
+
n === void 0 ? e.replaceSelectionWith(t) : e.insert(n, t);
|
|
3411
|
+
let r = 0;
|
|
3412
|
+
if (e.doc.descendants((e, n) => {
|
|
3413
|
+
e === t && (r = n + e.nodeSize);
|
|
3414
|
+
}), !r) return !1;
|
|
3415
|
+
let i = e.doc.nodeAt(r);
|
|
3416
|
+
return (i?.type.name !== "paragraph" || i.content.size !== 0) && e.insert(r, e.doc.type.schema.nodes.paragraph.create()), e.setSelection(ae.create(e.doc, r + 1)), !0;
|
|
3417
|
+
}
|
|
3418
|
+
function Un(e, t, n) {
|
|
3419
|
+
let r = e.state.tr;
|
|
3420
|
+
return Hn(r, t, n) ? (e.dispatch(r.scrollIntoView()), e.focus(), !0) : !1;
|
|
3421
|
+
}
|
|
3422
|
+
// src/editor/embeds/audio-view.tsx
|
|
3423
|
+
function Wn({ node: e, deleteNode: t, editor: r }) {
|
|
3471
3424
|
let i = e.attrs.src || "", a = e.attrs.name || i.split("/").pop()?.split("?")[0] || "audio", [o, s] = T(!1), c = r?.isEditable ?? !0;
|
|
3472
3425
|
x(() => () => {
|
|
3473
3426
|
i.startsWith("blob:") && URL.revokeObjectURL(i);
|
|
@@ -3502,7 +3455,6 @@ function Hn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3502
3455
|
}, [i]), /* @__PURE__ */ O(P, {
|
|
3503
3456
|
as: "div",
|
|
3504
3457
|
className: "audio-embed group/audio",
|
|
3505
|
-
style: { margin: "1rem 0" },
|
|
3506
3458
|
contentEditable: !1,
|
|
3507
3459
|
children: [/* @__PURE__ */ O("div", {
|
|
3508
3460
|
className: "audio-embed-inner",
|
|
@@ -3595,30 +3547,26 @@ function Hn({ node: e, deleteNode: t, editor: r }) {
|
|
|
3595
3547
|
})]
|
|
3596
3548
|
});
|
|
3597
3549
|
}
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
function Un(e) {
|
|
3550
|
+
// src/editor/embeds/audio.ts
|
|
3551
|
+
function Gn(e) {
|
|
3601
3552
|
return /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|$)/i.test(e) || /\/.*\.(mp3|wav|ogg|flac)/i.test(e);
|
|
3602
3553
|
}
|
|
3603
|
-
var
|
|
3554
|
+
var Kn = ie.create({
|
|
3604
3555
|
name: "audioEmbed",
|
|
3605
3556
|
group: "block",
|
|
3606
3557
|
atom: !0,
|
|
3607
3558
|
inline: !1,
|
|
3608
3559
|
addNodeView() {
|
|
3609
|
-
return F(
|
|
3560
|
+
return F(Wn);
|
|
3610
3561
|
},
|
|
3611
3562
|
addProseMirrorPlugins() {
|
|
3612
|
-
return [new
|
|
3563
|
+
return [new V({ props: { handlePaste(e, t) {
|
|
3613
3564
|
let n = t.clipboardData?.getData("text/plain");
|
|
3614
3565
|
if (!n) return !1;
|
|
3615
3566
|
let r = n.split(/\r?\n/);
|
|
3616
3567
|
for (let n of r) {
|
|
3617
3568
|
let r = n.trim();
|
|
3618
|
-
if (
|
|
3619
|
-
t.preventDefault();
|
|
3620
|
-
let i = e.state.schema.nodes.audioEmbed.create({ src: r });
|
|
3621
|
-
return e.dispatch(e.state.tr.replaceSelectionWith(i)), !0;
|
|
3569
|
+
if (r && !r.includes(" ") && Gn(r)) return t.preventDefault(), Un(e, e.state.schema.nodes.audioEmbed.create({ src: r })), !0;
|
|
3622
3570
|
}
|
|
3623
3571
|
return !1;
|
|
3624
3572
|
} } })];
|
|
@@ -3660,19 +3608,18 @@ var Wn = ae.create({
|
|
|
3660
3608
|
];
|
|
3661
3609
|
}
|
|
3662
3610
|
});
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
function Gn(e) {
|
|
3611
|
+
// src/editor/embeds/video-view.tsx
|
|
3612
|
+
function qn(e) {
|
|
3666
3613
|
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";
|
|
3667
3614
|
}
|
|
3668
|
-
function
|
|
3615
|
+
function Jn(e) {
|
|
3669
3616
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
3670
3617
|
if (t) return t[0];
|
|
3671
3618
|
let n = e.match(/av(\d+)/i);
|
|
3672
3619
|
return n ? n[0] : e;
|
|
3673
3620
|
}
|
|
3674
|
-
function
|
|
3675
|
-
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ?
|
|
3621
|
+
function Yn({ node: e, deleteNode: t, editor: n }) {
|
|
3622
|
+
let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ? qn(r) : i, [o, s] = T(!1), [c, l] = T(!1), [u, d] = T(!1), f = n?.isEditable ?? !0, p = !f && r.startsWith("blob:"), m = /* @__PURE__ */ D(wn, {
|
|
3676
3623
|
open: o,
|
|
3677
3624
|
title: "确认删除视频",
|
|
3678
3625
|
message: "此操作将同时删除对象存储中的文件,不可撤销。",
|
|
@@ -3716,7 +3663,7 @@ function qn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3716
3663
|
g(r);
|
|
3717
3664
|
return;
|
|
3718
3665
|
}
|
|
3719
|
-
let { signPreviewUrlHeaders: t } = await import("./signed-fetch-
|
|
3666
|
+
let { signPreviewUrlHeaders: t } = await import("./signed-fetch-iBM0Zozv.js").then((e) => e.i), n = await t(r);
|
|
3720
3667
|
if (!n) {
|
|
3721
3668
|
g(r);
|
|
3722
3669
|
return;
|
|
@@ -3784,11 +3731,10 @@ function qn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3784
3731
|
}, [a, h]), x(() => {
|
|
3785
3732
|
u && (_.current?.destroy(), _.current = null);
|
|
3786
3733
|
}, [u]), a === "bilibili") {
|
|
3787
|
-
let e =
|
|
3734
|
+
let e = Jn(r);
|
|
3788
3735
|
return /* @__PURE__ */ O(P, {
|
|
3789
3736
|
as: "div",
|
|
3790
3737
|
className: "video-embed video-embed--bilibili group/video",
|
|
3791
|
-
style: { margin: "1rem 0" },
|
|
3792
3738
|
contentEditable: !1,
|
|
3793
3739
|
children: [/* @__PURE__ */ O("div", {
|
|
3794
3740
|
ref: y,
|
|
@@ -3913,8 +3859,7 @@ function qn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3913
3859
|
display: "flex",
|
|
3914
3860
|
alignItems: "center",
|
|
3915
3861
|
gap: 12,
|
|
3916
|
-
maxWidth: 480
|
|
3917
|
-
margin: "1rem 0"
|
|
3862
|
+
maxWidth: 480
|
|
3918
3863
|
},
|
|
3919
3864
|
contentEditable: !1,
|
|
3920
3865
|
children: [/* @__PURE__ */ D("div", {
|
|
@@ -3953,7 +3898,6 @@ function qn({ node: e, deleteNode: t, editor: n }) {
|
|
|
3953
3898
|
as: "div",
|
|
3954
3899
|
className: "video-embed video-embed--direct group/video",
|
|
3955
3900
|
style: {
|
|
3956
|
-
margin: "1rem 0",
|
|
3957
3901
|
borderRadius: 12,
|
|
3958
3902
|
overflow: "hidden",
|
|
3959
3903
|
background: "#000"
|
|
@@ -4123,35 +4067,34 @@ function qn({ node: e, deleteNode: t, editor: n }) {
|
|
|
4123
4067
|
]
|
|
4124
4068
|
});
|
|
4125
4069
|
}
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
function Jn(e) {
|
|
4070
|
+
// src/editor/embeds/video.ts
|
|
4071
|
+
function Xn(e) {
|
|
4129
4072
|
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";
|
|
4130
4073
|
}
|
|
4131
|
-
function
|
|
4074
|
+
function Zn(e) {
|
|
4132
4075
|
let t = e.match(/BV[a-zA-Z0-9]{10}/);
|
|
4133
4076
|
if (t) return t[0];
|
|
4134
4077
|
let n = e.match(/av(\d+)/i);
|
|
4135
4078
|
return n ? n[0] : e;
|
|
4136
4079
|
}
|
|
4137
|
-
function
|
|
4080
|
+
function Qn(e) {
|
|
4138
4081
|
let t = e.match(/explore\/([a-zA-Z0-9]+)/);
|
|
4139
4082
|
return t ? t[1] : e;
|
|
4140
4083
|
}
|
|
4141
|
-
var
|
|
4084
|
+
var $n = ie.create({
|
|
4142
4085
|
name: "videoEmbed",
|
|
4143
4086
|
group: "block",
|
|
4144
4087
|
atom: !0,
|
|
4145
4088
|
inline: !1,
|
|
4146
4089
|
addNodeView() {
|
|
4147
|
-
return F(
|
|
4090
|
+
return F(Yn);
|
|
4148
4091
|
},
|
|
4149
4092
|
addProseMirrorPlugins() {
|
|
4150
|
-
return [new
|
|
4093
|
+
return [new V({ props: {
|
|
4151
4094
|
handleKeyDown(e, t) {
|
|
4152
4095
|
if (t.key !== " ") return !1;
|
|
4153
4096
|
let n = e.state.selection;
|
|
4154
|
-
if (n instanceof
|
|
4097
|
+
if (n instanceof B && n.node.type.name === "videoEmbed") {
|
|
4155
4098
|
t.preventDefault();
|
|
4156
4099
|
let r = e.nodeDOM(n.from);
|
|
4157
4100
|
if (r) {
|
|
@@ -4169,14 +4112,11 @@ var Zn = ae.create({
|
|
|
4169
4112
|
for (let n of r) {
|
|
4170
4113
|
let r = n.trim();
|
|
4171
4114
|
if (!r || r.includes(" ")) continue;
|
|
4172
|
-
let i =
|
|
4173
|
-
if (i
|
|
4174
|
-
t.preventDefault();
|
|
4175
|
-
let a = e.state.schema.nodes.videoEmbed.create({
|
|
4115
|
+
let i = Xn(r);
|
|
4116
|
+
if (i !== "unknown") return t.preventDefault(), Un(e, e.state.schema.nodes.videoEmbed.create({
|
|
4176
4117
|
src: r,
|
|
4177
4118
|
source: i
|
|
4178
|
-
}),
|
|
4179
|
-
return e.dispatch(o), !0;
|
|
4119
|
+
})), !0;
|
|
4180
4120
|
}
|
|
4181
4121
|
return !1;
|
|
4182
4122
|
}
|
|
@@ -4201,7 +4141,7 @@ var Zn = ae.create({
|
|
|
4201
4141
|
let t = e, n = t.getAttribute("src") || t.getAttribute("data-src") || "";
|
|
4202
4142
|
return {
|
|
4203
4143
|
src: n,
|
|
4204
|
-
source:
|
|
4144
|
+
source: Xn(n)
|
|
4205
4145
|
};
|
|
4206
4146
|
}
|
|
4207
4147
|
},
|
|
@@ -4210,9 +4150,9 @@ var Zn = ae.create({
|
|
|
4210
4150
|
];
|
|
4211
4151
|
},
|
|
4212
4152
|
renderHTML({ HTMLAttributes: e }) {
|
|
4213
|
-
let t = e.src || "", n =
|
|
4153
|
+
let t = e.src || "", n = Xn(t);
|
|
4214
4154
|
if (n === "bilibili") {
|
|
4215
|
-
let e =
|
|
4155
|
+
let e = Zn(t);
|
|
4216
4156
|
return [
|
|
4217
4157
|
"div",
|
|
4218
4158
|
{
|
|
@@ -4233,7 +4173,7 @@ var Zn = ae.create({
|
|
|
4233
4173
|
}]
|
|
4234
4174
|
];
|
|
4235
4175
|
}
|
|
4236
|
-
if (n === "xiaohongshu") return
|
|
4176
|
+
if (n === "xiaohongshu") return Qn(t), [
|
|
4237
4177
|
"div",
|
|
4238
4178
|
{
|
|
4239
4179
|
"data-video-embed": "xiaohongshu",
|
|
@@ -4285,24 +4225,41 @@ var Zn = ae.create({
|
|
|
4285
4225
|
},
|
|
4286
4226
|
addCommands() {
|
|
4287
4227
|
return { insertVideo: (e) => ({ chain: t }) => {
|
|
4288
|
-
let n =
|
|
4289
|
-
return t().
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
source: n
|
|
4294
|
-
}
|
|
4295
|
-
}).focus().run();
|
|
4228
|
+
let n = Xn(e.src);
|
|
4229
|
+
return t().command(({ tr: t }) => Hn(t, this.type.create({
|
|
4230
|
+
...e,
|
|
4231
|
+
source: n
|
|
4232
|
+
}))).focus().scrollIntoView().run();
|
|
4296
4233
|
} };
|
|
4297
4234
|
}
|
|
4298
|
-
})
|
|
4235
|
+
});
|
|
4236
|
+
// src/editor/extensions/chinese-emphasis.ts
|
|
4237
|
+
function er(e) {
|
|
4238
|
+
e.__qingwuChineseEmphasis || (e.__qingwuChineseEmphasis = !0, e.inline.ruler.before("emphasis", "qingwu_chinese_emphasis", (e) => {
|
|
4239
|
+
if (e.__qingwuChineseEmphasis) return !1;
|
|
4240
|
+
e.__qingwuChineseEmphasis = !0;
|
|
4241
|
+
let t = e.scanDelims;
|
|
4242
|
+
return e.scanDelims = function(e, n) {
|
|
4243
|
+
let r = t.call(this, e, n);
|
|
4244
|
+
if (this.src[e] !== "*" || r.length !== 2) return r;
|
|
4245
|
+
let i = this.src[e - 1] ?? "", a = this.src[e + 2] ?? "", o = /\p{Script=Han}/u, s = /[\u3001-\u303f\uff01-\uff65]/u;
|
|
4246
|
+
return o.test(i) && s.test(a) && (r.can_open = !0), s.test(i) && o.test(a) && (r.can_close = !0), r;
|
|
4247
|
+
}, !1;
|
|
4248
|
+
}));
|
|
4249
|
+
}
|
|
4250
|
+
var tr = R.create({
|
|
4251
|
+
name: "chineseEmphasis",
|
|
4252
|
+
addStorage() {
|
|
4253
|
+
return { markdown: { parse: { setup: er } } };
|
|
4254
|
+
}
|
|
4255
|
+
}), nr = null, rr = {
|
|
4299
4256
|
fontFamily: "Inter, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', system-ui, sans-serif",
|
|
4300
4257
|
padding: 24
|
|
4301
|
-
},
|
|
4302
|
-
async function
|
|
4303
|
-
return
|
|
4258
|
+
}, ir = .25, ar = 4, or = .25;
|
|
4259
|
+
async function sr(e) {
|
|
4260
|
+
return nr ||= await import("pele"), nr.render(e, rr).svg;
|
|
4304
4261
|
}
|
|
4305
|
-
var
|
|
4262
|
+
var cr = [
|
|
4306
4263
|
{
|
|
4307
4264
|
value: "javascript",
|
|
4308
4265
|
label: "JavaScript",
|
|
@@ -4463,7 +4420,7 @@ var ir = [
|
|
|
4463
4420
|
label: "Plain Text",
|
|
4464
4421
|
color: "#6b7280"
|
|
4465
4422
|
}
|
|
4466
|
-
],
|
|
4423
|
+
], lr = {
|
|
4467
4424
|
javascript: "js",
|
|
4468
4425
|
typescript: "ts",
|
|
4469
4426
|
python: "py",
|
|
@@ -4489,7 +4446,7 @@ var ir = [
|
|
|
4489
4446
|
txt: "txt",
|
|
4490
4447
|
vue: "vue",
|
|
4491
4448
|
react: "jsx"
|
|
4492
|
-
},
|
|
4449
|
+
}, ur = {
|
|
4493
4450
|
js: "javascript",
|
|
4494
4451
|
ts: "typescript",
|
|
4495
4452
|
py: "python",
|
|
@@ -4505,50 +4462,50 @@ var ir = [
|
|
|
4505
4462
|
jsx: "javascript",
|
|
4506
4463
|
tsx: "typescript"
|
|
4507
4464
|
};
|
|
4508
|
-
function
|
|
4509
|
-
let o = n?.isEditable ?? !0, s = !o, [c, l] = T(!1), [u, d] = T(!1), [f,
|
|
4465
|
+
function dr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i, selected: a }) {
|
|
4466
|
+
let o = n?.isEditable ?? !0, s = !o, [c, l] = T(!1), [u, d] = T(!1), [f, p] = T(!1), [h, g] = T(!1), [_, v] = T(220), [y, S] = T({
|
|
4510
4467
|
top: 0,
|
|
4511
4468
|
left: 0,
|
|
4512
4469
|
width: 210
|
|
4513
|
-
}), [k, A] = T(""), [j, M] = T(!1), [N, ee] = T(null), [P, F] = T(null), [I, te] = T(!1), [ne,
|
|
4470
|
+
}), [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({
|
|
4514
4471
|
x: 0,
|
|
4515
4472
|
y: 0
|
|
4516
|
-
}), [
|
|
4517
|
-
|
|
4473
|
+
}), [V, H] = T(!1), ae = w(null), oe = w(null), U = w(null), W = w(null), se = w(null), ce = w(null), G = w(null), K = e.attrs.language || "", le = cr.find((e) => e.value === (ur[K] ?? K)), ue = K === "mermaid", de = (e) => Math.min(ar, Math.max(ir, e)), fe = (e) => ie((t) => Math.round(de(t + e) * 100) / 100), pe = () => {
|
|
4474
|
+
ie(1), B({
|
|
4518
4475
|
x: 0,
|
|
4519
4476
|
y: 0
|
|
4520
4477
|
});
|
|
4521
|
-
},
|
|
4522
|
-
pe(),
|
|
4478
|
+
}, me = () => {
|
|
4479
|
+
pe(), R(!0);
|
|
4523
4480
|
};
|
|
4524
4481
|
x(() => {
|
|
4525
|
-
N ||
|
|
4482
|
+
N || R(!1);
|
|
4526
4483
|
}, [N]), x(() => {
|
|
4527
4484
|
if (!ne) return;
|
|
4528
4485
|
let e = document.body.style.overflow;
|
|
4529
4486
|
document.body.style.overflow = "hidden";
|
|
4530
4487
|
let t = (e) => {
|
|
4531
|
-
e.key === "Escape" &&
|
|
4488
|
+
e.key === "Escape" && R(!1);
|
|
4532
4489
|
};
|
|
4533
4490
|
return window.addEventListener("keydown", t), () => {
|
|
4534
4491
|
document.body.style.overflow = e, window.removeEventListener("keydown", t);
|
|
4535
4492
|
};
|
|
4536
4493
|
}, [ne]);
|
|
4537
|
-
let
|
|
4538
|
-
e.button === 0 && (e.currentTarget.setPointerCapture(e.pointerId),
|
|
4494
|
+
let he = (e) => {
|
|
4495
|
+
e.button === 0 && (e.currentTarget.setPointerCapture(e.pointerId), ae.current = {
|
|
4539
4496
|
x: e.clientX,
|
|
4540
4497
|
y: e.clientY,
|
|
4541
|
-
panX:
|
|
4542
|
-
panY:
|
|
4543
|
-
},
|
|
4544
|
-
},
|
|
4545
|
-
let t =
|
|
4546
|
-
t &&
|
|
4498
|
+
panX: z.x,
|
|
4499
|
+
panY: z.y
|
|
4500
|
+
}, H(!0));
|
|
4501
|
+
}, ge = (e) => {
|
|
4502
|
+
let t = ae.current;
|
|
4503
|
+
t && B({
|
|
4547
4504
|
x: t.panX + e.clientX - t.x,
|
|
4548
4505
|
y: t.panY + e.clientY - t.y
|
|
4549
4506
|
});
|
|
4550
|
-
},
|
|
4551
|
-
|
|
4507
|
+
}, q = () => {
|
|
4508
|
+
ae.current = null, H(!1);
|
|
4552
4509
|
}, _e = b(() => {
|
|
4553
4510
|
if (!n || typeof r != "function") return null;
|
|
4554
4511
|
let t = r();
|
|
@@ -4564,15 +4521,15 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4564
4521
|
o && (yn() || (G.current = _e(), window.getSelection()?.removeAllRanges(), $(!0), M(!0)));
|
|
4565
4522
|
}, [_e, o]), ye = C(() => {
|
|
4566
4523
|
let e = k.trim().toLowerCase();
|
|
4567
|
-
return e ?
|
|
4524
|
+
return e ? cr.filter((t) => t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e)) : cr;
|
|
4568
4525
|
}, [k]);
|
|
4569
4526
|
x(() => {
|
|
4570
|
-
(
|
|
4527
|
+
(ce.current?.closest(".code-block-node-view"))?.classList.toggle("code-block-node-view--collapsed", u);
|
|
4571
4528
|
}, [u]);
|
|
4572
4529
|
let be = b(() => {
|
|
4573
|
-
let e =
|
|
4530
|
+
let e = W.current;
|
|
4574
4531
|
if (!e) return;
|
|
4575
|
-
let t = e.getBoundingClientRect(), n = Math.min(t.left, window.innerWidth - 210 - 8), r = window.innerHeight - t.bottom - 12, i = t.top - 12, a =
|
|
4532
|
+
let t = e.getBoundingClientRect(), n = Math.min(t.left, window.innerWidth - 210 - 8), r = window.innerHeight - t.bottom - 12, i = t.top - 12, a = cr.length * 31 + 8, o = r - 52, s = i - 52;
|
|
4576
4533
|
o < 220 && s > o ? (g(!0), v(Math.max(120, Math.min(a, s))), S({
|
|
4577
4534
|
top: t.top,
|
|
4578
4535
|
left: n,
|
|
@@ -4586,7 +4543,7 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4586
4543
|
x(() => {
|
|
4587
4544
|
if (!f) return;
|
|
4588
4545
|
A(""), be();
|
|
4589
|
-
let e = setTimeout(() =>
|
|
4546
|
+
let e = setTimeout(() => se.current?.focus(), 50);
|
|
4590
4547
|
return window.addEventListener("resize", be), window.addEventListener("scroll", be, !0), () => {
|
|
4591
4548
|
clearTimeout(e), window.removeEventListener("resize", be), window.removeEventListener("scroll", be, !0);
|
|
4592
4549
|
};
|
|
@@ -4594,13 +4551,13 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4594
4551
|
if (!f) return;
|
|
4595
4552
|
let e = (e) => {
|
|
4596
4553
|
let t = e.target;
|
|
4597
|
-
t && (
|
|
4554
|
+
t && (W.current?.contains(t) || U.current?.contains(t) || p(!1));
|
|
4598
4555
|
};
|
|
4599
4556
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
4600
4557
|
}, [f]), x(() => {
|
|
4601
4558
|
if (!f) return;
|
|
4602
4559
|
let e = (e) => {
|
|
4603
|
-
e.key === "Escape" &&
|
|
4560
|
+
e.key === "Escape" && p(!1);
|
|
4604
4561
|
};
|
|
4605
4562
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
4606
4563
|
}, [f]), x(() => {
|
|
@@ -4625,14 +4582,14 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4625
4582
|
o
|
|
4626
4583
|
]);
|
|
4627
4584
|
let xe = b((e) => {
|
|
4628
|
-
t({ language: e || null }),
|
|
4585
|
+
t({ language: e || null }), p(!1);
|
|
4629
4586
|
}, [t]), Se = b(() => {
|
|
4630
4587
|
if (o) {
|
|
4631
4588
|
if (n && r) {
|
|
4632
4589
|
let e = r();
|
|
4633
4590
|
n.chain().focus().setNodeSelection(e).run();
|
|
4634
4591
|
}
|
|
4635
|
-
|
|
4592
|
+
p(!1), (n?.storage?.qingwuUI)?.openAI?.();
|
|
4636
4593
|
}
|
|
4637
4594
|
}, [
|
|
4638
4595
|
n,
|
|
@@ -4649,34 +4606,33 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4649
4606
|
};
|
|
4650
4607
|
navigator.clipboard?.writeText ? navigator.clipboard.writeText(t).catch(() => n(t)) : n(t), l(!0), setTimeout(() => l(!1), 1500);
|
|
4651
4608
|
}, [e.textContent]), we = b(() => {
|
|
4652
|
-
let t =
|
|
4609
|
+
let t = lr[K] || "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");
|
|
4653
4610
|
a.href = i, a.download = n, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
4654
|
-
}, [e.textContent,
|
|
4655
|
-
if (N || I)
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4611
|
+
}, [e.textContent, K]), Te = b(async () => {
|
|
4612
|
+
if (N || I) ee(null), F(null), te(!1);
|
|
4613
|
+
else {
|
|
4614
|
+
te(!0), F(null), ee(null);
|
|
4615
|
+
try {
|
|
4616
|
+
let t = (e.textContent || "").trim();
|
|
4617
|
+
if (!t) {
|
|
4618
|
+
F("代码块内容为空");
|
|
4619
|
+
return;
|
|
4620
|
+
}
|
|
4621
|
+
let n = await sr(t), r = m(n);
|
|
4622
|
+
ee(r);
|
|
4623
|
+
} catch (e) {
|
|
4624
|
+
F(e instanceof Error ? e.message : "图表渲染失败");
|
|
4625
|
+
} finally {
|
|
4626
|
+
te(!1);
|
|
4665
4627
|
}
|
|
4666
|
-
let n = p(await rr(t));
|
|
4667
|
-
ee(n);
|
|
4668
|
-
} catch (e) {
|
|
4669
|
-
F(e instanceof Error ? e.message : "图表渲染失败");
|
|
4670
|
-
} finally {
|
|
4671
|
-
te(!1);
|
|
4672
4628
|
}
|
|
4673
4629
|
}, [
|
|
4674
4630
|
e.textContent,
|
|
4675
4631
|
N,
|
|
4676
4632
|
I
|
|
4677
|
-
]), Ee = /* @__PURE__ */ O(E, { children: [
|
|
4678
|
-
className: `${
|
|
4679
|
-
style: { color:
|
|
4633
|
+
]), Ee = /* @__PURE__ */ O(E, { children: [le ? le.deviconClass ? /* @__PURE__ */ D("i", {
|
|
4634
|
+
className: `${le.deviconClass} colored cb-lang-icon`,
|
|
4635
|
+
style: { color: le.color }
|
|
4680
4636
|
}) : /* @__PURE__ */ D("span", {
|
|
4681
4637
|
className: "cb-lang-icon cb-lang-icon--auto",
|
|
4682
4638
|
children: "Tx"
|
|
@@ -4685,10 +4641,10 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4685
4641
|
children: "?"
|
|
4686
4642
|
}), /* @__PURE__ */ D("span", {
|
|
4687
4643
|
className: "cb-lang-label",
|
|
4688
|
-
children:
|
|
4644
|
+
children: le?.label || "自动"
|
|
4689
4645
|
})] });
|
|
4690
4646
|
return /* @__PURE__ */ O("div", {
|
|
4691
|
-
ref:
|
|
4647
|
+
ref: ce,
|
|
4692
4648
|
className: "cb-react-shell group/cb",
|
|
4693
4649
|
style: { display: "contents" },
|
|
4694
4650
|
children: [
|
|
@@ -4699,16 +4655,16 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4699
4655
|
children: [
|
|
4700
4656
|
/* @__PURE__ */ D("div", {
|
|
4701
4657
|
className: "cb-lang-wrap",
|
|
4702
|
-
ref:
|
|
4658
|
+
ref: oe,
|
|
4703
4659
|
contentEditable: !1,
|
|
4704
4660
|
children: s ? /* @__PURE__ */ D("span", {
|
|
4705
4661
|
className: "cb-lang-trigger cb-lang-trigger--static",
|
|
4706
4662
|
children: Ee
|
|
4707
4663
|
}) : /* @__PURE__ */ O("button", {
|
|
4708
|
-
ref:
|
|
4664
|
+
ref: W,
|
|
4709
4665
|
type: "button",
|
|
4710
4666
|
className: "cb-lang-trigger",
|
|
4711
|
-
onClick: () =>
|
|
4667
|
+
onClick: () => p(!f),
|
|
4712
4668
|
children: [Ee, /* @__PURE__ */ D("svg", {
|
|
4713
4669
|
className: `cb-lang-chevron${f ? " cb-lang-chevron--open" : ""}`,
|
|
4714
4670
|
width: "10",
|
|
@@ -4746,8 +4702,8 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4746
4702
|
})
|
|
4747
4703
|
})]
|
|
4748
4704
|
}),
|
|
4749
|
-
o && f &&
|
|
4750
|
-
ref:
|
|
4705
|
+
o && f && L(/* @__PURE__ */ O("div", {
|
|
4706
|
+
ref: U,
|
|
4751
4707
|
className: `cb-lang-dropdown${h ? " cb-lang-dropdown--up" : ""}`,
|
|
4752
4708
|
style: {
|
|
4753
4709
|
position: "fixed",
|
|
@@ -4772,7 +4728,7 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4772
4728
|
d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
|
4773
4729
|
})
|
|
4774
4730
|
}), /* @__PURE__ */ D("input", {
|
|
4775
|
-
ref:
|
|
4731
|
+
ref: se,
|
|
4776
4732
|
className: "cb-lang-search",
|
|
4777
4733
|
type: "text",
|
|
4778
4734
|
placeholder: "搜索语言...",
|
|
@@ -4786,7 +4742,7 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4786
4742
|
children: [
|
|
4787
4743
|
/* @__PURE__ */ O("button", {
|
|
4788
4744
|
type: "button",
|
|
4789
|
-
className: `cb-lang-option${
|
|
4745
|
+
className: `cb-lang-option${K ? "" : " cb-lang-option--active"}`,
|
|
4790
4746
|
onClick: () => xe(""),
|
|
4791
4747
|
children: [/* @__PURE__ */ D("span", {
|
|
4792
4748
|
className: "cb-lang-icon cb-lang-icon--auto",
|
|
@@ -4795,7 +4751,7 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4795
4751
|
}),
|
|
4796
4752
|
ye.map((e) => /* @__PURE__ */ O("button", {
|
|
4797
4753
|
type: "button",
|
|
4798
|
-
className: `cb-lang-option${
|
|
4754
|
+
className: `cb-lang-option${K === e.value ? " cb-lang-option--active" : ""}`,
|
|
4799
4755
|
onClick: () => xe(e.value),
|
|
4800
4756
|
children: [e.deviconClass ? /* @__PURE__ */ D("i", {
|
|
4801
4757
|
className: `${e.deviconClass} colored cb-lang-icon`,
|
|
@@ -4968,9 +4924,9 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4968
4924
|
role: "button",
|
|
4969
4925
|
tabIndex: 0,
|
|
4970
4926
|
title: "点击放大查看",
|
|
4971
|
-
onClick:
|
|
4927
|
+
onClick: me,
|
|
4972
4928
|
onKeyDown: (e) => {
|
|
4973
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
4929
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), me());
|
|
4974
4930
|
},
|
|
4975
4931
|
children: [/* @__PURE__ */ D("div", {
|
|
4976
4932
|
className: "cb-diagram-svg-inner",
|
|
@@ -4982,7 +4938,7 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
4982
4938
|
})
|
|
4983
4939
|
]
|
|
4984
4940
|
}),
|
|
4985
|
-
ne && N &&
|
|
4941
|
+
ne && N && L(/* @__PURE__ */ O("div", {
|
|
4986
4942
|
className: "fixed inset-0 z-[10002] flex flex-col bg-black/75 backdrop-blur-sm select-none",
|
|
4987
4943
|
role: "dialog",
|
|
4988
4944
|
"aria-modal": "true",
|
|
@@ -5009,12 +4965,12 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5009
4965
|
onClick: pe,
|
|
5010
4966
|
title: "重置为 100%",
|
|
5011
4967
|
"aria-label": "重置缩放",
|
|
5012
|
-
children: [Math.round(
|
|
4968
|
+
children: [Math.round(re * 100), "%"]
|
|
5013
4969
|
}),
|
|
5014
4970
|
/* @__PURE__ */ D("button", {
|
|
5015
4971
|
type: "button",
|
|
5016
4972
|
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",
|
|
5017
|
-
onClick: () => fe(
|
|
4973
|
+
onClick: () => fe(or),
|
|
5018
4974
|
title: "放大",
|
|
5019
4975
|
"aria-label": "放大",
|
|
5020
4976
|
children: "+"
|
|
@@ -5031,7 +4987,7 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5031
4987
|
/* @__PURE__ */ D("button", {
|
|
5032
4988
|
type: "button",
|
|
5033
4989
|
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",
|
|
5034
|
-
onClick: () =>
|
|
4990
|
+
onClick: () => R(!1),
|
|
5035
4991
|
title: "关闭",
|
|
5036
4992
|
"aria-label": "关闭",
|
|
5037
4993
|
children: "×"
|
|
@@ -5040,14 +4996,14 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5040
4996
|
})]
|
|
5041
4997
|
}), /* @__PURE__ */ D("div", {
|
|
5042
4998
|
className: "flex flex-1 touch-none items-center justify-center overflow-hidden",
|
|
5043
|
-
style: { cursor:
|
|
5044
|
-
onWheel: (e) => fe(e.deltaY > 0 ? -.25 :
|
|
5045
|
-
onPointerDown:
|
|
5046
|
-
onPointerMove:
|
|
5047
|
-
onPointerUp:
|
|
5048
|
-
onPointerCancel:
|
|
4999
|
+
style: { cursor: V ? "grabbing" : re > 1 ? "grab" : "default" },
|
|
5000
|
+
onWheel: (e) => fe(e.deltaY > 0 ? -.25 : or),
|
|
5001
|
+
onPointerDown: he,
|
|
5002
|
+
onPointerMove: ge,
|
|
5003
|
+
onPointerUp: q,
|
|
5004
|
+
onPointerCancel: q,
|
|
5049
5005
|
onDoubleClick: () => {
|
|
5050
|
-
|
|
5006
|
+
ie((e) => e === 1 ? 2 : 1), B({
|
|
5051
5007
|
x: 0,
|
|
5052
5008
|
y: 0
|
|
5053
5009
|
});
|
|
@@ -5055,8 +5011,8 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5055
5011
|
children: /* @__PURE__ */ D("div", {
|
|
5056
5012
|
className: "cb-diagram-zoom-content",
|
|
5057
5013
|
style: {
|
|
5058
|
-
transform: `translate(${
|
|
5059
|
-
transition:
|
|
5014
|
+
transform: `translate(${z.x}px, ${z.y}px) scale(${re})`,
|
|
5015
|
+
transition: V ? "none" : "transform 120ms ease-out"
|
|
5060
5016
|
},
|
|
5061
5017
|
dangerouslySetInnerHTML: { __html: N }
|
|
5062
5018
|
})
|
|
@@ -5076,9 +5032,8 @@ function sr({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
|
|
|
5076
5032
|
]
|
|
5077
5033
|
});
|
|
5078
5034
|
}
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
var cr = [
|
|
5035
|
+
// src/editor/extensions/code-block.ts
|
|
5036
|
+
var fr = [
|
|
5082
5037
|
{
|
|
5083
5038
|
value: "javascript",
|
|
5084
5039
|
label: "JavaScript"
|
|
@@ -5179,12 +5134,12 @@ var cr = [
|
|
|
5179
5134
|
value: "mermaid",
|
|
5180
5135
|
label: "Mermaid"
|
|
5181
5136
|
}
|
|
5182
|
-
],
|
|
5183
|
-
|
|
5184
|
-
function
|
|
5137
|
+
], pr = Ce(Se);
|
|
5138
|
+
pr.register({ dockerfile: xe }), pr.registerAlias("xml", ["vue", "html"]), pr.registerAlias("javascript", ["react", "jsx"]), pr.registerAlias("typescript", ["tsx"]);
|
|
5139
|
+
function mr(e) {
|
|
5185
5140
|
return e ? e.split("\n") : [""];
|
|
5186
5141
|
}
|
|
5187
|
-
function
|
|
5142
|
+
function hr(e, t) {
|
|
5188
5143
|
if (e.childElementCount !== t) {
|
|
5189
5144
|
e.replaceChildren();
|
|
5190
5145
|
for (let n = 1; n <= t; n++) {
|
|
@@ -5193,14 +5148,14 @@ function dr(e, t) {
|
|
|
5193
5148
|
}
|
|
5194
5149
|
}
|
|
5195
5150
|
}
|
|
5196
|
-
function
|
|
5151
|
+
function gr(e, t) {
|
|
5197
5152
|
e.replaceChildren();
|
|
5198
5153
|
for (let n of t) {
|
|
5199
5154
|
let t = document.createElement("span");
|
|
5200
5155
|
t.className = "cb-mirror-line", t.textContent = n.length ? n : "\xA0", e.appendChild(t);
|
|
5201
5156
|
}
|
|
5202
5157
|
}
|
|
5203
|
-
function
|
|
5158
|
+
function _r(e, t, n) {
|
|
5204
5159
|
let r = getComputedStyle(e), i = parseFloat(r.paddingLeft), a = parseFloat(r.paddingRight);
|
|
5205
5160
|
t.style.boxSizing = "content-box", t.style.width = `${Math.max(0, e.clientWidth - i - a)}px`, t.style.padding = r.padding;
|
|
5206
5161
|
let o = getComputedStyle(n);
|
|
@@ -5247,7 +5202,7 @@ function pr(e, t, n) {
|
|
|
5247
5202
|
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;
|
|
5248
5203
|
}
|
|
5249
5204
|
}
|
|
5250
|
-
var
|
|
5205
|
+
var vr = be.extend({
|
|
5251
5206
|
addNodeView() {
|
|
5252
5207
|
return (e) => {
|
|
5253
5208
|
let { node: t, editor: n, getPos: r } = e, i = t, a = (e) => {
|
|
@@ -5275,9 +5230,9 @@ var mr = be.extend({
|
|
|
5275
5230
|
f.appendChild(p);
|
|
5276
5231
|
let m = document.createElement("div");
|
|
5277
5232
|
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);
|
|
5278
|
-
let h =
|
|
5279
|
-
|
|
5280
|
-
let g = new I(
|
|
5233
|
+
let h = mr(t.textContent);
|
|
5234
|
+
hr(d, h.length), gr(m, h);
|
|
5235
|
+
let g = new I(dr, {
|
|
5281
5236
|
editor: n,
|
|
5282
5237
|
props: {
|
|
5283
5238
|
node: t,
|
|
@@ -5290,12 +5245,12 @@ var mr = be.extend({
|
|
|
5290
5245
|
});
|
|
5291
5246
|
c.appendChild(g.element);
|
|
5292
5247
|
let _ = (e) => {
|
|
5293
|
-
let t =
|
|
5294
|
-
|
|
5248
|
+
let t = mr(e.textContent);
|
|
5249
|
+
hr(d, t.length), gr(m, t), requestAnimationFrame(() => _r(f, m, d));
|
|
5295
5250
|
};
|
|
5296
|
-
requestAnimationFrame(() =>
|
|
5297
|
-
let v = new ResizeObserver(() =>
|
|
5298
|
-
return v.observe(f), document.fonts?.ready?.then(() =>
|
|
5251
|
+
requestAnimationFrame(() => _r(f, m, d));
|
|
5252
|
+
let v = new ResizeObserver(() => _r(f, m, d));
|
|
5253
|
+
return v.observe(f), document.fonts?.ready?.then(() => _r(f, m, d)), {
|
|
5299
5254
|
dom: s,
|
|
5300
5255
|
contentDOM: p,
|
|
5301
5256
|
update(e) {
|
|
@@ -5355,10 +5310,9 @@ var mr = be.extend({
|
|
|
5355
5310
|
}
|
|
5356
5311
|
}));
|
|
5357
5312
|
}
|
|
5358
|
-
}).configure({ lowlight:
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
function hr(e) {
|
|
5313
|
+
}).configure({ lowlight: pr });
|
|
5314
|
+
// src/editor/utils/import-choice-dialog.ts
|
|
5315
|
+
function yr(e) {
|
|
5362
5316
|
return new Promise((t) => {
|
|
5363
5317
|
let n = document.createElement("div");
|
|
5364
5318
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -5386,18 +5340,17 @@ function hr(e) {
|
|
|
5386
5340
|
d.type = "button", d.className = "px-3 py-1.5 text-xs rounded-lg bg-blue-500 hover:bg-blue-600 text-white transition-colors", d.textContent = "渲染", d.addEventListener("click", () => s("render")), o.append(l, u, d), r.append(i, a, o), n.appendChild(r), document.addEventListener("keydown", c), document.body.appendChild(n);
|
|
5387
5341
|
});
|
|
5388
5342
|
}
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
function vr(e) {
|
|
5343
|
+
// src/editor/utils/local-media.ts
|
|
5344
|
+
var br = /\.(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, xr = /^(?:mailto:|tel:|javascript:|about:|data:|blob:)/i;
|
|
5345
|
+
function Sr(e) {
|
|
5393
5346
|
if (!e) return !1;
|
|
5394
5347
|
let t = e.trim();
|
|
5395
|
-
return !(!t || /^(?:https?:)?\/\//i.test(t) ||
|
|
5348
|
+
return !(!t || /^(?:https?:)?\/\//i.test(t) || xr.test(t) || t.startsWith("#"));
|
|
5396
5349
|
}
|
|
5397
|
-
function
|
|
5398
|
-
return
|
|
5350
|
+
function Cr(e) {
|
|
5351
|
+
return br.test(e);
|
|
5399
5352
|
}
|
|
5400
|
-
function
|
|
5353
|
+
function wr(e) {
|
|
5401
5354
|
let t = e.trim();
|
|
5402
5355
|
t = t.replace(/^(?:file|app):\/\/(?:localhost)?/i, "");
|
|
5403
5356
|
try {
|
|
@@ -5405,26 +5358,26 @@ function br(e) {
|
|
|
5405
5358
|
} catch {}
|
|
5406
5359
|
return t = t.replace(/\\/g, "/"), t = t.replace(/^\.\//, ""), t = t.replace(/^\/+/, ""), t = t.replace(/^[a-zA-Z]:\//, ""), t;
|
|
5407
5360
|
}
|
|
5408
|
-
function
|
|
5409
|
-
let t =
|
|
5361
|
+
function Tr(e) {
|
|
5362
|
+
let t = wr(e), n = t.split("/").filter(Boolean);
|
|
5410
5363
|
return (n[n.length - 1] || t).toLowerCase();
|
|
5411
5364
|
}
|
|
5412
|
-
function
|
|
5365
|
+
function Er() {
|
|
5413
5366
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showDirectoryPicker == "function";
|
|
5414
5367
|
}
|
|
5415
|
-
async function
|
|
5416
|
-
if (!
|
|
5368
|
+
async function Dr() {
|
|
5369
|
+
if (!Er()) return null;
|
|
5417
5370
|
try {
|
|
5418
5371
|
return await window.showDirectoryPicker.call(window, { mode: "read" }) ?? null;
|
|
5419
5372
|
} catch {
|
|
5420
5373
|
return null;
|
|
5421
5374
|
}
|
|
5422
5375
|
}
|
|
5423
|
-
function
|
|
5376
|
+
function Or() {
|
|
5424
5377
|
return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showOpenFilePicker == "function";
|
|
5425
5378
|
}
|
|
5426
|
-
async function
|
|
5427
|
-
if (!
|
|
5379
|
+
async function kr() {
|
|
5380
|
+
if (!Or()) return null;
|
|
5428
5381
|
try {
|
|
5429
5382
|
let e = await window.showOpenFilePicker.call(window, { multiple: !0 });
|
|
5430
5383
|
return await Promise.all(e.map((e) => e.getFile()));
|
|
@@ -5432,7 +5385,7 @@ async function Tr() {
|
|
|
5432
5385
|
return null;
|
|
5433
5386
|
}
|
|
5434
5387
|
}
|
|
5435
|
-
async function
|
|
5388
|
+
async function Ar(e, t) {
|
|
5436
5389
|
if (t.length === 0) return { file: null };
|
|
5437
5390
|
let n = e;
|
|
5438
5391
|
for (let e = 0; e < t.length - 1; e++) try {
|
|
@@ -5454,7 +5407,7 @@ async function Er(e, t) {
|
|
|
5454
5407
|
return { file: null };
|
|
5455
5408
|
}
|
|
5456
5409
|
}
|
|
5457
|
-
async function
|
|
5410
|
+
async function jr(e, t, n = 5e3) {
|
|
5458
5411
|
let r = t.toLowerCase(), i = [e], a = 0, o;
|
|
5459
5412
|
for (; i.length > 0 && a < n;) {
|
|
5460
5413
|
let e = i.pop();
|
|
@@ -5476,56 +5429,54 @@ async function Dr(e, t, n = 5e3) {
|
|
|
5476
5429
|
readError: o
|
|
5477
5430
|
};
|
|
5478
5431
|
}
|
|
5479
|
-
async function
|
|
5480
|
-
let n =
|
|
5432
|
+
async function Mr(e, t) {
|
|
5433
|
+
let n = wr(t).split("/").filter(Boolean);
|
|
5481
5434
|
if (n.length === 0) return { file: null };
|
|
5482
5435
|
let r;
|
|
5483
5436
|
for (let t = 0; t < n.length; t++) {
|
|
5484
|
-
let i = await
|
|
5437
|
+
let i = await Ar(e, n.slice(t));
|
|
5485
5438
|
if (i.file) return i;
|
|
5486
5439
|
i.readError && (r = i.readError);
|
|
5487
5440
|
}
|
|
5488
|
-
let i = await
|
|
5441
|
+
let i = await jr(e, n[n.length - 1]);
|
|
5489
5442
|
return i.file || i.readError ? i : {
|
|
5490
5443
|
file: null,
|
|
5491
5444
|
readError: r
|
|
5492
5445
|
};
|
|
5493
5446
|
}
|
|
5494
|
-
var
|
|
5447
|
+
var Nr = {
|
|
5495
5448
|
image: "image",
|
|
5496
5449
|
videoEmbed: "video",
|
|
5497
5450
|
audioEmbed: "audio",
|
|
5498
5451
|
attachmentEmbed: "attachment"
|
|
5499
5452
|
};
|
|
5500
|
-
function
|
|
5453
|
+
function Pr(e, t) {
|
|
5501
5454
|
let n = /* @__PURE__ */ new Set(), r = [];
|
|
5502
5455
|
return e.descendants((e) => {
|
|
5503
|
-
let i =
|
|
5456
|
+
let i = Nr[e.type?.name];
|
|
5504
5457
|
if (i) {
|
|
5505
5458
|
let a = e.attrs?.src, o = `node:${a}`;
|
|
5506
|
-
typeof a == "string" &&
|
|
5459
|
+
typeof a == "string" && Sr(a) && !n.has(o) && !t?.(a) && (n.add(o), r.push({
|
|
5507
5460
|
src: a,
|
|
5508
|
-
normalized:
|
|
5509
|
-
basename:
|
|
5461
|
+
normalized: wr(a),
|
|
5462
|
+
basename: Tr(a),
|
|
5510
5463
|
kind: i,
|
|
5511
5464
|
isLink: !1
|
|
5512
5465
|
}));
|
|
5513
|
-
|
|
5514
|
-
}
|
|
5515
|
-
if (e.isText && e.marks) for (let i of e.marks) {
|
|
5466
|
+
} else if (e.isText && e.marks) for (let i of e.marks) {
|
|
5516
5467
|
if (i.type.name !== "link") continue;
|
|
5517
5468
|
let e = i.attrs?.href, a = `link:${e}`;
|
|
5518
|
-
typeof e == "string" &&
|
|
5469
|
+
typeof e == "string" && Sr(e) && Cr(e) && !n.has(a) && !t?.(e) && (n.add(a), r.push({
|
|
5519
5470
|
src: e,
|
|
5520
|
-
normalized:
|
|
5521
|
-
basename:
|
|
5471
|
+
normalized: wr(e),
|
|
5472
|
+
basename: Tr(e),
|
|
5522
5473
|
kind: "attachment",
|
|
5523
5474
|
isLink: !0
|
|
5524
5475
|
}));
|
|
5525
5476
|
}
|
|
5526
5477
|
}), r;
|
|
5527
5478
|
}
|
|
5528
|
-
function
|
|
5479
|
+
function Fr(e, t, n) {
|
|
5529
5480
|
let r = t ? `${e}\n${t}` : e;
|
|
5530
5481
|
if (!r) return !1;
|
|
5531
5482
|
let i = [];
|
|
@@ -5533,40 +5484,39 @@ function jr(e, t, n) {
|
|
|
5533
5484
|
for (let e of r.matchAll(/!?\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g)) i.push(e[1]);
|
|
5534
5485
|
for (let e of r.matchAll(/<(?:img|video|audio|source)[^>]*\bsrc=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5535
5486
|
for (let e of r.matchAll(/<a[^>]*\bhref=["']([^"']+)["']/gi)) i.push(e[1]);
|
|
5536
|
-
return i.some((e) =>
|
|
5487
|
+
return i.some((e) => Cr(e) && Sr(e) && !n?.(e));
|
|
5537
5488
|
}
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
function Mr(e) {
|
|
5489
|
+
// src/editor/extensions/image-upload.ts
|
|
5490
|
+
function Ir(e) {
|
|
5541
5491
|
if (e.type.startsWith("image/")) return "image";
|
|
5542
5492
|
if (e.type.startsWith("video/")) return "video";
|
|
5543
5493
|
if (e.type.startsWith("audio/")) return "audio";
|
|
5544
5494
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5545
5495
|
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";
|
|
5546
5496
|
}
|
|
5547
|
-
function
|
|
5497
|
+
function Lr(e) {
|
|
5548
5498
|
let t = e.name.split(".").pop()?.toLowerCase() || "";
|
|
5549
5499
|
return t === "md" || t === "markdown";
|
|
5550
5500
|
}
|
|
5551
|
-
async function
|
|
5501
|
+
async function Rr(e, t, n, r) {
|
|
5552
5502
|
let i = n ?? e.state.selection.from, a = r ? mn(r) : void 0, o = r?.storage?.qingwuUI, s = await new Promise((e) => {
|
|
5553
|
-
o?.chooseMd ? o.chooseMd(t.name, e) :
|
|
5503
|
+
o?.chooseMd ? o.chooseMd(t.name, e) : yr(t.name).then(e);
|
|
5554
5504
|
});
|
|
5555
5505
|
if (s === null) return;
|
|
5556
5506
|
if (s === "attach") {
|
|
5557
|
-
let
|
|
5558
|
-
if (
|
|
5559
|
-
Z(
|
|
5507
|
+
let r = a ? hn(e.state.doc, t, a) : null;
|
|
5508
|
+
if (r) {
|
|
5509
|
+
Z(r);
|
|
5560
5510
|
return;
|
|
5561
5511
|
}
|
|
5562
|
-
let
|
|
5563
|
-
src:
|
|
5512
|
+
let i = URL.createObjectURL(t), o = e.state.schema.nodes.attachmentEmbed?.create({
|
|
5513
|
+
src: i,
|
|
5564
5514
|
name: t.name,
|
|
5565
5515
|
size: t.size,
|
|
5566
5516
|
type: t.type
|
|
5567
5517
|
});
|
|
5568
5518
|
if (o) try {
|
|
5569
|
-
|
|
5519
|
+
Un(e, o, n);
|
|
5570
5520
|
} catch {}
|
|
5571
5521
|
return;
|
|
5572
5522
|
}
|
|
@@ -5585,8 +5535,8 @@ async function Pr(e, t, n, r) {
|
|
|
5585
5535
|
e.dispatch(e.state.tr.insert(i, t.from(u)));
|
|
5586
5536
|
}
|
|
5587
5537
|
}
|
|
5588
|
-
function
|
|
5589
|
-
switch (
|
|
5538
|
+
function zr(e, t, n) {
|
|
5539
|
+
switch (Ir(t)) {
|
|
5590
5540
|
case "image": return e.nodes.image?.create({
|
|
5591
5541
|
src: n,
|
|
5592
5542
|
alt: t.name
|
|
@@ -5612,10 +5562,10 @@ function Fr(e, t, n) {
|
|
|
5612
5562
|
}
|
|
5613
5563
|
}
|
|
5614
5564
|
}
|
|
5615
|
-
async function
|
|
5565
|
+
async function Br(e, t, n) {
|
|
5616
5566
|
let r;
|
|
5617
5567
|
try {
|
|
5618
|
-
r =
|
|
5568
|
+
r = s();
|
|
5619
5569
|
} catch {
|
|
5620
5570
|
return null;
|
|
5621
5571
|
}
|
|
@@ -5623,31 +5573,31 @@ async function Ir(e, t, n) {
|
|
|
5623
5573
|
let i = await r.upload(t, "editor");
|
|
5624
5574
|
URL.revokeObjectURL(n);
|
|
5625
5575
|
let a = !1;
|
|
5626
|
-
return e.state.doc.descendants((t, r) => t.attrs?.src
|
|
5576
|
+
return e.state.doc.descendants((t, r) => t.attrs?.src !== n || (e.dispatch(e.state.tr.setNodeMarkup(r, void 0, {
|
|
5627
5577
|
...t.attrs,
|
|
5628
5578
|
src: i
|
|
5629
|
-
})), a = !0, !1)
|
|
5579
|
+
})), a = !0, !1)), a ? i : null;
|
|
5630
5580
|
} catch (e) {
|
|
5631
5581
|
return console.error(`${t.type} upload failed:`, e), URL.revokeObjectURL(n), null;
|
|
5632
5582
|
}
|
|
5633
5583
|
}
|
|
5634
|
-
async function
|
|
5584
|
+
async function Vr(e, t, n, r) {
|
|
5635
5585
|
let i = r ? mn(r) : void 0, a = i ? hn(e.state.doc, t, i) : null;
|
|
5636
5586
|
if (a) {
|
|
5637
5587
|
Z(a);
|
|
5638
5588
|
return;
|
|
5639
5589
|
}
|
|
5640
|
-
let o = URL.createObjectURL(t), s =
|
|
5641
|
-
if (
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5590
|
+
let o = URL.createObjectURL(t), s = zr(e.state.schema, t, o);
|
|
5591
|
+
if (s) {
|
|
5592
|
+
try {
|
|
5593
|
+
Un(e, s, n);
|
|
5594
|
+
} catch {
|
|
5595
|
+
return;
|
|
5596
|
+
}
|
|
5597
|
+
await Br(e, t, o);
|
|
5647
5598
|
}
|
|
5648
|
-
await Ir(e, t, o);
|
|
5649
5599
|
}
|
|
5650
|
-
var
|
|
5600
|
+
var Hr = R.create({
|
|
5651
5601
|
name: "imageUpload",
|
|
5652
5602
|
addOptions() {
|
|
5653
5603
|
return {
|
|
@@ -5657,8 +5607,8 @@ var Rr = L.create({
|
|
|
5657
5607
|
},
|
|
5658
5608
|
addProseMirrorPlugins() {
|
|
5659
5609
|
let e = this.editor;
|
|
5660
|
-
return [new
|
|
5661
|
-
key: new
|
|
5610
|
+
return [new V({
|
|
5611
|
+
key: new H("imageUpload"),
|
|
5662
5612
|
props: {
|
|
5663
5613
|
handleDrop(t, n) {
|
|
5664
5614
|
let r = n.dataTransfer?.files;
|
|
@@ -5667,24 +5617,24 @@ var Rr = L.create({
|
|
|
5667
5617
|
let i = t.posAtCoords({
|
|
5668
5618
|
left: n.clientX,
|
|
5669
5619
|
top: n.clientY
|
|
5670
|
-
});
|
|
5671
|
-
for (let n of Array.from(r))
|
|
5620
|
+
})?.pos;
|
|
5621
|
+
for (let n of Array.from(r)) Lr(n) ? Rr(t, n, i, e) : Vr(t, n, i, e), i = void 0;
|
|
5672
5622
|
return !0;
|
|
5673
5623
|
},
|
|
5674
5624
|
handlePaste(t, n) {
|
|
5675
5625
|
let r = n.clipboardData?.items;
|
|
5676
5626
|
if (!r) return !1;
|
|
5677
5627
|
let i = n.clipboardData?.getData("text/plain") || "";
|
|
5678
|
-
if ((n.clipboardData?.files?.length ?? 0) > 0 &&
|
|
5628
|
+
if ((n.clipboardData?.files?.length ?? 0) > 0 && Fr(i, void 0, o())) return !1;
|
|
5679
5629
|
for (let i of Array.from(r)) {
|
|
5680
5630
|
if (i.type.startsWith("image/") || i.type.startsWith("video/") || i.type.startsWith("audio/")) {
|
|
5681
5631
|
n.preventDefault();
|
|
5682
5632
|
let r = i.getAsFile();
|
|
5683
|
-
return r &&
|
|
5633
|
+
return r && Ir(r) !== "file" && Vr(t, r, void 0, e), !0;
|
|
5684
5634
|
}
|
|
5685
5635
|
if (i.kind === "file") {
|
|
5686
5636
|
let r = i.getAsFile();
|
|
5687
|
-
if (r &&
|
|
5637
|
+
if (r && Lr(r)) return n.preventDefault(), Rr(t, r, void 0, e), !0;
|
|
5688
5638
|
}
|
|
5689
5639
|
}
|
|
5690
5640
|
return !1;
|
|
@@ -5692,12 +5642,12 @@ var Rr = L.create({
|
|
|
5692
5642
|
}
|
|
5693
5643
|
})];
|
|
5694
5644
|
}
|
|
5695
|
-
}),
|
|
5645
|
+
}), Ur = 100, Wr = R.create({
|
|
5696
5646
|
name: "imeCommitSpaceGuard",
|
|
5697
5647
|
addProseMirrorPlugins() {
|
|
5698
5648
|
let e = 0;
|
|
5699
|
-
return [new
|
|
5700
|
-
key: new
|
|
5649
|
+
return [new V({
|
|
5650
|
+
key: new H("imeCommitSpaceGuard"),
|
|
5701
5651
|
props: { handleDOMEvents: {
|
|
5702
5652
|
compositionend() {
|
|
5703
5653
|
return e = performance.now(), !1;
|
|
@@ -5707,30 +5657,46 @@ var Rr = L.create({
|
|
|
5707
5657
|
},
|
|
5708
5658
|
beforeinput(t, n) {
|
|
5709
5659
|
let r = n;
|
|
5710
|
-
return r.inputType !== "insertText" || r.data !== " " || r.isComposing || performance.now() - e >
|
|
5660
|
+
return r.inputType !== "insertText" || r.data !== " " || r.isComposing || performance.now() - e > Ur ? !1 : (r.preventDefault(), !0);
|
|
5711
5661
|
}
|
|
5712
5662
|
} }
|
|
5713
5663
|
})];
|
|
5714
5664
|
}
|
|
5715
|
-
}),
|
|
5665
|
+
}), Gr = R.create({
|
|
5716
5666
|
name: "inlineCodeEnd",
|
|
5717
5667
|
addInputRules() {
|
|
5718
5668
|
let e = this.editor.schema.marks.code;
|
|
5719
|
-
return e ? [
|
|
5669
|
+
return e ? [z({
|
|
5720
5670
|
find: /`([^`]+)`$/,
|
|
5721
5671
|
type: e
|
|
5722
5672
|
})] : [];
|
|
5723
5673
|
}
|
|
5674
|
+
}), Kr = R.create({
|
|
5675
|
+
name: "listQuoteHighlight",
|
|
5676
|
+
addProseMirrorPlugins() {
|
|
5677
|
+
return [new V({ props: { decorations: (e) => {
|
|
5678
|
+
let { $head: t, empty: n } = e.selection;
|
|
5679
|
+
if (!this.editor.isFocused || !n || !["paragraph", "heading"].includes(t.parent.type.name)) return U.empty;
|
|
5680
|
+
let r = [], i = !1;
|
|
5681
|
+
for (let e = t.depth - 1; e > 0; e--) {
|
|
5682
|
+
let n = t.node(e).type.name;
|
|
5683
|
+
if (n === "listItem" && !i && (i = !0, r.push(oe.node(t.before(), t.after(), { class: "qw-active-row" }), oe.node(t.before(e), t.after(e), { class: "qw-active-list-item" }))), n === "blockquote") {
|
|
5684
|
+
r.push(oe.node(t.before(e), t.after(e), { class: "qw-active-quote" }));
|
|
5685
|
+
break;
|
|
5686
|
+
}
|
|
5687
|
+
}
|
|
5688
|
+
return U.create(e.doc, r);
|
|
5689
|
+
} } })];
|
|
5690
|
+
}
|
|
5724
5691
|
});
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
function Hr(e) {
|
|
5692
|
+
// src/editor/extensions/math-utils.ts
|
|
5693
|
+
function qr(e) {
|
|
5728
5694
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">").replace(/\n/g, " ");
|
|
5729
5695
|
}
|
|
5730
|
-
function
|
|
5696
|
+
function Jr(e) {
|
|
5731
5697
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
5732
5698
|
}
|
|
5733
|
-
function
|
|
5699
|
+
function Yr(e, t) {
|
|
5734
5700
|
let n = e ?? "";
|
|
5735
5701
|
if (!n.trim()) return "";
|
|
5736
5702
|
try {
|
|
@@ -5742,27 +5708,22 @@ function Wr(e, t) {
|
|
|
5742
5708
|
output: "htmlAndMathml"
|
|
5743
5709
|
});
|
|
5744
5710
|
} catch {
|
|
5745
|
-
return `<span class="math-fallback">${
|
|
5711
|
+
return `<span class="math-fallback">${Jr(n)}</span>`;
|
|
5746
5712
|
}
|
|
5747
5713
|
}
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
let o = e.type.name === "mathBlock", s = String(e.attrs.latex ?? ""), c = r?.isEditable ?? !0, [l, u] = T(!1), [d, p] = T(s), m = w(null), h = w(!1), g = w(() => {}), _ = w(() => {}), v = C(() => Wr(s, o), [s, o]), y = C(() => Wr(d, o), [d, o]), b = () => {
|
|
5714
|
+
// src/editor/extensions/math-view.tsx
|
|
5715
|
+
function Xr({ node: e, updateAttributes: t, deleteNode: n, editor: r, getPos: i, selected: a }) {
|
|
5716
|
+
let o = e.type.name === "mathBlock", s = String(e.attrs.latex ?? ""), c = r?.isEditable ?? !0, [l, u] = T(!1), [d, f] = T(s), m = w(null), h = w(!1), g = w(() => {}), _ = w(() => {}), v = C(() => Yr(s, o), [s, o]), y = C(() => Yr(d, o), [d, o]), b = () => {
|
|
5752
5717
|
let e = d.trim();
|
|
5753
|
-
|
|
5754
|
-
u(!1), c && n?.();
|
|
5755
|
-
return;
|
|
5756
|
-
}
|
|
5757
|
-
t({ latex: e }), u(!1);
|
|
5718
|
+
e ? (t({ latex: e }), u(!1)) : (u(!1), c && n?.());
|
|
5758
5719
|
}, S = () => {
|
|
5759
5720
|
u(!1), !s && c && n?.();
|
|
5760
5721
|
};
|
|
5761
5722
|
g.current = b, _.current = S, x(() => {
|
|
5762
|
-
|
|
5723
|
+
c && !h.current && (h.current = !0, s || u(!0));
|
|
5763
5724
|
}, [c, s]), x(() => {
|
|
5764
5725
|
if (!l) return;
|
|
5765
|
-
|
|
5726
|
+
f(s);
|
|
5766
5727
|
let e = window.setTimeout(() => {
|
|
5767
5728
|
m.current?.focus(), m.current?.select();
|
|
5768
5729
|
}, 30), t = (e) => {
|
|
@@ -5778,34 +5739,28 @@ function Gr({ node: e, updateAttributes: t, deleteNode: n, editor: r, getPos: i,
|
|
|
5778
5739
|
if (!r || typeof i != "function") return;
|
|
5779
5740
|
let n = i();
|
|
5780
5741
|
if (n === void 0) return;
|
|
5781
|
-
let a = t.currentTarget.getBoundingClientRect(), o = t.clientX - a.left < a.width / 2 ? "before" : "after", s = o === "before" ? n : n + e.nodeSize, { state: c, view: l } = r, u =
|
|
5742
|
+
let a = t.currentTarget.getBoundingClientRect(), o = t.clientX - a.left < a.width / 2 ? "before" : "after", s = o === "before" ? n : n + e.nodeSize, { state: c, view: l } = r, u = ae.near(c.doc.resolve(s), o === "before" ? -1 : 1);
|
|
5782
5743
|
l.dispatch(c.tr.setSelection(u)), l.focus();
|
|
5783
5744
|
};
|
|
5784
5745
|
return /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D(P, {
|
|
5785
5746
|
as: o ? "div" : "span",
|
|
5786
5747
|
className: `math-node ${o ? "math-node--block" : "math-node--inline"}${a ? " is-selected" : ""}`,
|
|
5787
5748
|
contentEditable: !1,
|
|
5788
|
-
title: c && !o ?
|
|
5749
|
+
title: c && !o ? p("editor.math.inlineClickHint") : void 0,
|
|
5789
5750
|
onMouseDown: (e) => {
|
|
5790
5751
|
c && o && e.preventDefault();
|
|
5791
5752
|
},
|
|
5792
5753
|
onClick: (e) => {
|
|
5793
|
-
|
|
5794
|
-
if (e.preventDefault(), e.stopPropagation(), o) {
|
|
5795
|
-
k();
|
|
5796
|
-
return;
|
|
5797
|
-
}
|
|
5798
|
-
e.detail >= 2 ? k() : A(e);
|
|
5799
|
-
}
|
|
5754
|
+
c && (e.preventDefault(), e.stopPropagation(), o || e.detail >= 2 ? k() : A(e));
|
|
5800
5755
|
},
|
|
5801
5756
|
children: s ? /* @__PURE__ */ D("span", {
|
|
5802
5757
|
className: "math-render",
|
|
5803
5758
|
dangerouslySetInnerHTML: { __html: v }
|
|
5804
5759
|
}) : /* @__PURE__ */ D("span", {
|
|
5805
5760
|
className: "math-placeholder",
|
|
5806
|
-
children:
|
|
5761
|
+
children: p("editor.math.empty")
|
|
5807
5762
|
})
|
|
5808
|
-
}), l &&
|
|
5763
|
+
}), l && L(/* @__PURE__ */ D("div", {
|
|
5809
5764
|
className: "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none",
|
|
5810
5765
|
onClick: S,
|
|
5811
5766
|
onMouseDown: (e) => e.preventDefault(),
|
|
@@ -5815,41 +5770,41 @@ function Gr({ node: e, updateAttributes: t, deleteNode: n, editor: r, getPos: i,
|
|
|
5815
5770
|
children: [
|
|
5816
5771
|
/* @__PURE__ */ D("div", {
|
|
5817
5772
|
className: "mb-3 text-sm font-medium text-default-800 dark:text-zinc-100",
|
|
5818
|
-
children:
|
|
5773
|
+
children: p(o ? "editor.math.blockTitle" : "editor.math.inlineTitle")
|
|
5819
5774
|
}),
|
|
5820
5775
|
/* @__PURE__ */ D("textarea", {
|
|
5821
5776
|
ref: m,
|
|
5822
5777
|
value: d,
|
|
5823
|
-
onChange: (e) =>
|
|
5778
|
+
onChange: (e) => f(e.target.value),
|
|
5824
5779
|
rows: o ? 5 : 2,
|
|
5825
5780
|
spellCheck: !1,
|
|
5826
|
-
placeholder:
|
|
5781
|
+
placeholder: p("editor.math.placeholder"),
|
|
5827
5782
|
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"
|
|
5828
5783
|
}),
|
|
5829
5784
|
/* @__PURE__ */ D("div", {
|
|
5830
5785
|
className: "math-dialog-preview",
|
|
5831
5786
|
children: d.trim() ? /* @__PURE__ */ D("div", { dangerouslySetInnerHTML: { __html: y } }) : /* @__PURE__ */ D("span", {
|
|
5832
5787
|
className: "math-placeholder",
|
|
5833
|
-
children:
|
|
5788
|
+
children: p("editor.math.emptyPreview")
|
|
5834
5789
|
})
|
|
5835
5790
|
}),
|
|
5836
5791
|
/* @__PURE__ */ O("div", {
|
|
5837
5792
|
className: "mt-4 flex items-center justify-between gap-3",
|
|
5838
5793
|
children: [/* @__PURE__ */ D("span", {
|
|
5839
5794
|
className: "text-[11px] text-default-400 dark:text-zinc-500",
|
|
5840
|
-
children:
|
|
5795
|
+
children: p("editor.math.hint")
|
|
5841
5796
|
}), /* @__PURE__ */ O("div", {
|
|
5842
5797
|
className: "flex shrink-0 gap-2",
|
|
5843
5798
|
children: [/* @__PURE__ */ D("button", {
|
|
5844
5799
|
type: "button",
|
|
5845
5800
|
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",
|
|
5846
5801
|
onClick: S,
|
|
5847
|
-
children:
|
|
5802
|
+
children: p("editor.math.cancel")
|
|
5848
5803
|
}), /* @__PURE__ */ D("button", {
|
|
5849
5804
|
type: "button",
|
|
5850
5805
|
className: "px-3 py-1.5 text-xs rounded-lg bg-qingwu-600 hover:bg-qingwu-700 text-white transition-colors",
|
|
5851
5806
|
onClick: b,
|
|
5852
|
-
children:
|
|
5807
|
+
children: p("editor.math.save")
|
|
5853
5808
|
})]
|
|
5854
5809
|
})]
|
|
5855
5810
|
})
|
|
@@ -5857,11 +5812,10 @@ function Gr({ node: e, updateAttributes: t, deleteNode: n, editor: r, getPos: i,
|
|
|
5857
5812
|
})
|
|
5858
5813
|
}), document.body)] });
|
|
5859
5814
|
}
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
return new B({ appendTransaction(t, n, r) {
|
|
5815
|
+
// src/editor/extensions/math.ts
|
|
5816
|
+
var Zr = /(?:^|[^\\$])\$([^\s$](?:[^$\n]*[^\s$])?)\$$/, Qr = /^\$\$([\s\S]+?)\$\$$/;
|
|
5817
|
+
function $r(e) {
|
|
5818
|
+
return new V({ appendTransaction(t, n, r) {
|
|
5865
5819
|
if (!e.isEditable || e.view.composing || !t.some((e) => e.docChanged)) return null;
|
|
5866
5820
|
let i = r.schema.nodes.paragraph, a = r.schema.nodes.mathBlock;
|
|
5867
5821
|
if (!i || !a) return null;
|
|
@@ -5872,36 +5826,28 @@ function Jr(e) {
|
|
|
5872
5826
|
return;
|
|
5873
5827
|
}
|
|
5874
5828
|
let n = e.textContent.trim(), r = s;
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
o.push({
|
|
5884
|
-
from: r.from,
|
|
5885
|
-
to: t + e.nodeSize,
|
|
5886
|
-
latex: r.lines.join("\n")
|
|
5887
|
-
}), s = null;
|
|
5888
|
-
return;
|
|
5889
|
-
}
|
|
5890
|
-
r.lines.push(e.textContent);
|
|
5829
|
+
r ? n === "$$" ? (o.push({
|
|
5830
|
+
from: r.from,
|
|
5831
|
+
to: t + e.nodeSize,
|
|
5832
|
+
latex: r.lines.join("\n")
|
|
5833
|
+
}), s = null) : r.lines.push(e.textContent) : n === "$$" && (s = {
|
|
5834
|
+
from: t,
|
|
5835
|
+
lines: []
|
|
5836
|
+
});
|
|
5891
5837
|
}), !o.length) return null;
|
|
5892
5838
|
let c = r.tr;
|
|
5893
5839
|
for (let e of o.reverse()) {
|
|
5894
5840
|
let t = a.create({ latex: e.latex });
|
|
5895
5841
|
c.replaceWith(e.from, e.to, t);
|
|
5896
5842
|
let n = e.from + t.nodeSize, r = c.doc.resolve(n);
|
|
5897
|
-
|
|
5843
|
+
r.nodeAfter && r.nodeAfter.isTextblock || c.insert(n, i.create()), c.setSelection(ae.near(c.doc.resolve(n), 1));
|
|
5898
5844
|
}
|
|
5899
5845
|
return c;
|
|
5900
5846
|
} });
|
|
5901
5847
|
}
|
|
5902
|
-
function
|
|
5903
|
-
return new
|
|
5904
|
-
find:
|
|
5848
|
+
function ei(e) {
|
|
5849
|
+
return new re({
|
|
5850
|
+
find: Zr,
|
|
5905
5851
|
handler: ({ state: t, range: n, match: r }) => {
|
|
5906
5852
|
let i = r[1], a = r[0].indexOf("$");
|
|
5907
5853
|
if (a < 0) return;
|
|
@@ -5910,18 +5856,18 @@ function Yr(e) {
|
|
|
5910
5856
|
}
|
|
5911
5857
|
});
|
|
5912
5858
|
}
|
|
5913
|
-
function
|
|
5914
|
-
return new
|
|
5915
|
-
find:
|
|
5859
|
+
function ti(e) {
|
|
5860
|
+
return new re({
|
|
5861
|
+
find: Qr,
|
|
5916
5862
|
handler: ({ state: t, range: n, match: r }) => {
|
|
5917
5863
|
let i = r[1].trim();
|
|
5918
5864
|
if (!i) return;
|
|
5919
5865
|
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);
|
|
5920
|
-
|
|
5866
|
+
f.nodeAfter && f.nodeAfter.isTextblock || u.insert(d, t.schema.nodes.paragraph.create()), u.setSelection(ae.near(u.doc.resolve(d), 1));
|
|
5921
5867
|
}
|
|
5922
5868
|
});
|
|
5923
5869
|
}
|
|
5924
|
-
function
|
|
5870
|
+
function ni(e, t) {
|
|
5925
5871
|
let n = e.src, r = e.pos;
|
|
5926
5872
|
if (n.charCodeAt(r) !== 36 || n.charCodeAt(r + 1) === 36) return !1;
|
|
5927
5873
|
let i = r + 1;
|
|
@@ -5936,11 +5882,11 @@ function Zr(e, t) {
|
|
|
5936
5882
|
if (!a || /^\s|\s$/.test(a)) return !1;
|
|
5937
5883
|
if (!t) {
|
|
5938
5884
|
let t = e.push("html_inline", "", 0);
|
|
5939
|
-
t.content = `<span data-type="inline-math" data-latex="${
|
|
5885
|
+
t.content = `<span data-type="inline-math" data-latex="${qr(a)}"></span>`;
|
|
5940
5886
|
}
|
|
5941
5887
|
return e.pos = i + 1, !0;
|
|
5942
5888
|
}
|
|
5943
|
-
function
|
|
5889
|
+
function ri(e, t, n, r) {
|
|
5944
5890
|
let i = e.bMarks[t] + e.tShift[t], a = e.eMarks[t];
|
|
5945
5891
|
if (i + 1 >= a || e.src.charCodeAt(i) !== 36 || e.src.charCodeAt(i + 1) !== 36) return !1;
|
|
5946
5892
|
let o = e.src.slice(i, a).trim(), s = "", c = t + 1;
|
|
@@ -5963,29 +5909,28 @@ function Qr(e, t, n, r) {
|
|
|
5963
5909
|
}
|
|
5964
5910
|
if (r) return !0;
|
|
5965
5911
|
let l = e.push("html_block", "", 0);
|
|
5966
|
-
return l.content = `<div data-type="block-math" data-latex="${
|
|
5912
|
+
return l.content = `<div data-type="block-math" data-latex="${qr(s.trim())}"></div>\n`, e.line = c, !0;
|
|
5967
5913
|
}
|
|
5968
|
-
function
|
|
5969
|
-
e.__qingwuMathReg || (e.__qingwuMathReg = !0, e.inline.ruler.before("backticks", "qingwu_math_inline",
|
|
5914
|
+
function ii(e) {
|
|
5915
|
+
e.__qingwuMathReg || (e.__qingwuMathReg = !0, e.inline.ruler.before("backticks", "qingwu_math_inline", ni), e.block.ruler.before("fence", "qingwu_math_block", ri, { alt: ["paragraph"] }));
|
|
5970
5916
|
}
|
|
5971
|
-
function
|
|
5917
|
+
function ai(e) {
|
|
5972
5918
|
return { markdown: {
|
|
5973
5919
|
serialize(t, n) {
|
|
5974
5920
|
let r = String(n.attrs.latex ?? "");
|
|
5975
|
-
if (!e) {
|
|
5976
|
-
|
|
5977
|
-
|
|
5921
|
+
if (!e) t.write(`$${r}$`);
|
|
5922
|
+
else {
|
|
5923
|
+
t.ensureNewLine(), t.write("$$"), t.ensureNewLine();
|
|
5924
|
+
for (let e of r.split("\n")) t.write(e), t.ensureNewLine();
|
|
5925
|
+
t.write("$$"), t.closeBlock(n);
|
|
5978
5926
|
}
|
|
5979
|
-
t.ensureNewLine(), t.write("$$"), t.ensureNewLine();
|
|
5980
|
-
for (let e of r.split("\n")) t.write(e), t.ensureNewLine();
|
|
5981
|
-
t.write("$$"), t.closeBlock(n);
|
|
5982
5927
|
},
|
|
5983
5928
|
parse: { setup(e) {
|
|
5984
|
-
|
|
5929
|
+
ii(e);
|
|
5985
5930
|
} }
|
|
5986
5931
|
} };
|
|
5987
5932
|
}
|
|
5988
|
-
var
|
|
5933
|
+
var oi = ie.create({
|
|
5989
5934
|
name: "mathInline",
|
|
5990
5935
|
group: "inline",
|
|
5991
5936
|
inline: !0,
|
|
@@ -6013,18 +5958,18 @@ var ti = ae.create({
|
|
|
6013
5958
|
];
|
|
6014
5959
|
let r = document.createElement("span");
|
|
6015
5960
|
for (let [e, t] of Object.entries(n)) r.setAttribute(e, t);
|
|
6016
|
-
return r.innerHTML =
|
|
5961
|
+
return r.innerHTML = Yr(t, !1), r;
|
|
6017
5962
|
},
|
|
6018
5963
|
addNodeView() {
|
|
6019
|
-
return F(
|
|
5964
|
+
return F(Xr);
|
|
6020
5965
|
},
|
|
6021
5966
|
addInputRules() {
|
|
6022
|
-
return [
|
|
5967
|
+
return [ei(this.type)];
|
|
6023
5968
|
},
|
|
6024
5969
|
addStorage() {
|
|
6025
|
-
return
|
|
5970
|
+
return ai(!1);
|
|
6026
5971
|
}
|
|
6027
|
-
}),
|
|
5972
|
+
}), si = ie.create({
|
|
6028
5973
|
name: "mathBlock",
|
|
6029
5974
|
group: "block",
|
|
6030
5975
|
atom: !0,
|
|
@@ -6051,39 +5996,39 @@ var ti = ae.create({
|
|
|
6051
5996
|
];
|
|
6052
5997
|
let r = document.createElement("div");
|
|
6053
5998
|
for (let [e, t] of Object.entries(n)) r.setAttribute(e, t);
|
|
6054
|
-
return r.innerHTML =
|
|
5999
|
+
return r.innerHTML = Yr(t, !0), r;
|
|
6055
6000
|
},
|
|
6056
6001
|
addNodeView() {
|
|
6057
|
-
return F(
|
|
6002
|
+
return F(Xr);
|
|
6058
6003
|
},
|
|
6059
6004
|
addInputRules() {
|
|
6060
|
-
return [
|
|
6005
|
+
return [ti(this.type)];
|
|
6061
6006
|
},
|
|
6062
6007
|
addProseMirrorPlugins() {
|
|
6063
|
-
return [
|
|
6008
|
+
return [$r(this.editor)];
|
|
6064
6009
|
},
|
|
6065
6010
|
addStorage() {
|
|
6066
|
-
return
|
|
6011
|
+
return ai(!0);
|
|
6067
6012
|
}
|
|
6068
|
-
}),
|
|
6069
|
-
function
|
|
6013
|
+
}), ci = /\.(png|jpe?g|gif|webp|bmp|svg|avif)(\?|#|$)/i, li = /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|#|$)/i, ui = /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|#|$)/i;
|
|
6014
|
+
function di(e) {
|
|
6070
6015
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
6071
6016
|
}
|
|
6072
|
-
function
|
|
6017
|
+
function fi(e) {
|
|
6073
6018
|
let t = e.trim().replace(/\\/g, "/");
|
|
6074
6019
|
return t.split("/").pop() || t;
|
|
6075
6020
|
}
|
|
6076
|
-
function
|
|
6021
|
+
function pi(e, t) {
|
|
6077
6022
|
let n = e.src.slice(e.pos), r = /^!\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !0;
|
|
6078
6023
|
if (r || (r = /^\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !1), !r) return !1;
|
|
6079
6024
|
let a = r[1].trim(), o = r[2]?.trim();
|
|
6080
6025
|
if (!t) {
|
|
6081
|
-
let t = o ||
|
|
6026
|
+
let t = o || fi(a);
|
|
6082
6027
|
if (i) {
|
|
6083
6028
|
let n = "";
|
|
6084
|
-
if (
|
|
6085
|
-
else if (
|
|
6086
|
-
else if (
|
|
6029
|
+
if (ci.test(a) || /^data:image\//i.test(a)) n = `<img src="${di(a)}" alt="${di(t)}">`;
|
|
6030
|
+
else if (li.test(a) || /^data:video\//i.test(a)) n = `<div data-video-embed src="${di(a)}"></div>`;
|
|
6031
|
+
else if (ui.test(a) || /^data:audio\//i.test(a)) n = `<audio src="${di(a)}"></audio>`;
|
|
6087
6032
|
else {
|
|
6088
6033
|
let n = e.push("link_open", "a", 1);
|
|
6089
6034
|
n.attrs = [["href", a]];
|
|
@@ -6101,22 +6046,25 @@ function ci(e, t) {
|
|
|
6101
6046
|
}
|
|
6102
6047
|
return e.pos += r[0].length, !0;
|
|
6103
6048
|
}
|
|
6104
|
-
var
|
|
6049
|
+
var mi = R.create({
|
|
6105
6050
|
name: "obsidianMarkdown",
|
|
6106
6051
|
addStorage() {
|
|
6107
6052
|
return { markdown: { parse: { setup(e) {
|
|
6108
|
-
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed",
|
|
6053
|
+
e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed", pi));
|
|
6109
6054
|
} } } };
|
|
6110
6055
|
}
|
|
6111
|
-
}),
|
|
6056
|
+
}), hi = R.create({
|
|
6112
6057
|
name: "qingwuUI",
|
|
6058
|
+
priority: 1e3,
|
|
6059
|
+
addKeyboardShortcuts() {
|
|
6060
|
+
return { "Ctrl-Enter": () => this.editor.isEditable && this.editor.isActive("heading") && this.editor.commands.setParagraph() };
|
|
6061
|
+
},
|
|
6113
6062
|
addStorage() {
|
|
6114
6063
|
return {};
|
|
6115
6064
|
}
|
|
6116
6065
|
});
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
function di(e, t) {
|
|
6066
|
+
// src/editor/utils/render-probe.ts
|
|
6067
|
+
function gi(e, t) {
|
|
6120
6068
|
return new Promise((n) => {
|
|
6121
6069
|
if (typeof Image != "function") return n(!0);
|
|
6122
6070
|
let r = new Image(), i = !1, a = setTimeout(() => o(!1), t), o = (e) => {
|
|
@@ -6125,22 +6073,21 @@ function di(e, t) {
|
|
|
6125
6073
|
r.onload = () => o(!0), r.onerror = () => o(!1), r.src = e;
|
|
6126
6074
|
});
|
|
6127
6075
|
}
|
|
6128
|
-
async function
|
|
6129
|
-
if (await
|
|
6076
|
+
async function _i(e, t = 8e3) {
|
|
6077
|
+
if (await gi(e, t)) return !0;
|
|
6130
6078
|
try {
|
|
6131
6079
|
let r = await n(e);
|
|
6132
6080
|
if (!r) return !1;
|
|
6133
6081
|
let i = await fetch(e, { headers: r });
|
|
6134
6082
|
if (!i.ok) return !1;
|
|
6135
|
-
let a = URL.createObjectURL(await i.blob()), o = await
|
|
6083
|
+
let a = URL.createObjectURL(await i.blob()), o = await gi(a, t);
|
|
6136
6084
|
return URL.revokeObjectURL(a), o;
|
|
6137
6085
|
} catch {
|
|
6138
6086
|
return !1;
|
|
6139
6087
|
}
|
|
6140
6088
|
}
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
function pi() {
|
|
6089
|
+
// src/editor/utils/resolve-local-media.ts
|
|
6090
|
+
function vi() {
|
|
6144
6091
|
return {
|
|
6145
6092
|
uploaded: 0,
|
|
6146
6093
|
sessionOnly: 0,
|
|
@@ -6150,10 +6097,10 @@ function pi() {
|
|
|
6150
6097
|
readFailed: []
|
|
6151
6098
|
};
|
|
6152
6099
|
}
|
|
6153
|
-
function
|
|
6100
|
+
function yi(e, t) {
|
|
6154
6101
|
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);
|
|
6155
6102
|
}
|
|
6156
|
-
function
|
|
6103
|
+
function bi(e, t, n, r) {
|
|
6157
6104
|
let { state: i } = e, a = [];
|
|
6158
6105
|
if (i.doc.descendants((e, n) => {
|
|
6159
6106
|
e.attrs?.src === t && a.push(n);
|
|
@@ -6169,7 +6116,7 @@ function hi(e, t, n, r) {
|
|
|
6169
6116
|
}
|
|
6170
6117
|
return e.dispatch(o), !0;
|
|
6171
6118
|
}
|
|
6172
|
-
function
|
|
6119
|
+
function xi(e, t, n) {
|
|
6173
6120
|
let { state: r } = e, i = r.schema.marks.link;
|
|
6174
6121
|
if (!i) return !1;
|
|
6175
6122
|
let a = [];
|
|
@@ -6187,7 +6134,7 @@ function gi(e, t, n) {
|
|
|
6187
6134
|
}));
|
|
6188
6135
|
return e.dispatch(o), !0;
|
|
6189
6136
|
}
|
|
6190
|
-
function
|
|
6137
|
+
function Si(e) {
|
|
6191
6138
|
let t = /* @__PURE__ */ new Map();
|
|
6192
6139
|
for (let n of e) {
|
|
6193
6140
|
let e = t.get(n.normalized);
|
|
@@ -6195,36 +6142,36 @@ function _i(e) {
|
|
|
6195
6142
|
}
|
|
6196
6143
|
return Array.from(t.values());
|
|
6197
6144
|
}
|
|
6198
|
-
async function
|
|
6145
|
+
async function Ci(e, t, n, r) {
|
|
6199
6146
|
if (n.length === 0) return "sessionOnly";
|
|
6200
6147
|
let i = n[0], a = mn(t);
|
|
6201
6148
|
if (a) {
|
|
6202
6149
|
let t = hn(e.state.doc, r, a);
|
|
6203
6150
|
if (t) return Z(`${i.basename}:${t}`, "error"), "limitRejected";
|
|
6204
6151
|
}
|
|
6205
|
-
let
|
|
6206
|
-
if (
|
|
6207
|
-
let t = await
|
|
6208
|
-
for (let r of c)
|
|
6152
|
+
let o = n.filter((e) => !e.isLink), c = n.filter((e) => e.isLink);
|
|
6153
|
+
if (o.length === 0) try {
|
|
6154
|
+
let t = await s().upload(r, "editor"), n = !1;
|
|
6155
|
+
for (let r of c) xi(e, r.src, t) && (n = !0);
|
|
6209
6156
|
return n ? "uploaded" : "sessionOnly";
|
|
6210
6157
|
} catch (e) {
|
|
6211
6158
|
return console.error(`本地附件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), "sessionOnly";
|
|
6212
6159
|
}
|
|
6213
6160
|
let l = URL.createObjectURL(r), u = !1;
|
|
6214
|
-
for (let t of
|
|
6161
|
+
for (let t of o) bi(e, t.src, l, r.size) && (u = !0);
|
|
6215
6162
|
let d;
|
|
6216
6163
|
try {
|
|
6217
|
-
d = await
|
|
6164
|
+
d = await s().upload(r, "editor");
|
|
6218
6165
|
} catch (e) {
|
|
6219
6166
|
return console.error(`本地文件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), URL.revokeObjectURL(l), "sessionOnly";
|
|
6220
6167
|
}
|
|
6221
|
-
URL.revokeObjectURL(l), u &&
|
|
6222
|
-
for (let t of c)
|
|
6223
|
-
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await
|
|
6168
|
+
URL.revokeObjectURL(l), u && bi(e, l, d, r.size);
|
|
6169
|
+
for (let t of c) xi(e, t.src, d);
|
|
6170
|
+
return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await _i(d) ? "uploaded" : "renderFailed" : "uploaded";
|
|
6224
6171
|
}
|
|
6225
|
-
function
|
|
6172
|
+
function wi(e, t) {
|
|
6226
6173
|
let n = [], r = [];
|
|
6227
|
-
for (let i of
|
|
6174
|
+
for (let i of Si(e)) {
|
|
6228
6175
|
let e = i[0], a = t.get(e.basename);
|
|
6229
6176
|
a ? (n.push({
|
|
6230
6177
|
refs: i,
|
|
@@ -6236,30 +6183,30 @@ function yi(e, t) {
|
|
|
6236
6183
|
unmatched: r
|
|
6237
6184
|
};
|
|
6238
6185
|
}
|
|
6239
|
-
async function
|
|
6240
|
-
let i =
|
|
6241
|
-
for (let a of
|
|
6242
|
-
let n = a[0], { file: o, readError: s } = await
|
|
6186
|
+
async function Ti(e, t, n, r) {
|
|
6187
|
+
let i = vi();
|
|
6188
|
+
for (let a of Si(n)) {
|
|
6189
|
+
let n = a[0], { file: o, readError: s } = await Mr(r, n.src);
|
|
6243
6190
|
if (!o) {
|
|
6244
6191
|
s ? (console.warn(`本地文件「${n.basename}」在所选文件夹中找到但读取失败:`, s), i.readFailed.push(n)) : (console.warn(`本地文件「${n.basename}」未在所选文件夹「${r.name}」中找到`), i.missing.push(n));
|
|
6245
6192
|
continue;
|
|
6246
6193
|
}
|
|
6247
|
-
let c = await
|
|
6194
|
+
let c = await Ci(e, t, a, o);
|
|
6248
6195
|
i[c]++;
|
|
6249
6196
|
}
|
|
6250
6197
|
return i;
|
|
6251
6198
|
}
|
|
6252
|
-
function
|
|
6199
|
+
function Ei(e) {
|
|
6253
6200
|
let t = e.map((e) => e.basename);
|
|
6254
6201
|
return t.length <= 3 ? t.join("、") : `${t.slice(0, 3).join("、")} 等 ${t.length} 个文件`;
|
|
6255
6202
|
}
|
|
6256
|
-
function
|
|
6203
|
+
function Di(e) {
|
|
6257
6204
|
let t = [];
|
|
6258
|
-
if (e.uploaded > 0 && t.push(`${e.uploaded} 个已上传至存储`), e.sessionOnly > 0 && t.push(`${e.sessionOnly} 个仅本次会话可见(未配置存储或上传失败)`), e.limitRejected > 0 && t.push(`${e.limitRejected} 个超出大小限制`), e.renderFailed > 0 && t.push(`${e.renderFailed} 个上传成功但页面渲染失败(存储 URL 无法在浏览器访问/解码)`), e.readFailed.length > 0 && t.push(`${e.readFailed.length} 个找到但读取失败:${
|
|
6205
|
+
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} 个找到但读取失败:${Ei(e.readFailed)}(若在 OneDrive / WPS 云盘等同步目录,请右键文件选择「始终保留在此设备」后重试)`), e.missing.length > 0 && t.push(`${e.missing.length} 个未能获取:${Ei(e.missing)}(可把文件直接拖进编辑器上传)`), t.length === 0) return;
|
|
6259
6206
|
let n = e.uploaded > 0 && e.renderFailed === 0 && e.missing.length === 0 && e.readFailed.length === 0;
|
|
6260
6207
|
Z(`本地文件解析完成:${t.join(";")}`, n ? "success" : "info");
|
|
6261
6208
|
}
|
|
6262
|
-
function
|
|
6209
|
+
function Oi(e) {
|
|
6263
6210
|
return new Promise((t) => {
|
|
6264
6211
|
let n = document.createElement("div");
|
|
6265
6212
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -6286,7 +6233,7 @@ function Ci(e) {
|
|
|
6286
6233
|
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);
|
|
6287
6234
|
});
|
|
6288
6235
|
}
|
|
6289
|
-
function
|
|
6236
|
+
function ki(e) {
|
|
6290
6237
|
let t = document.createElement("div");
|
|
6291
6238
|
t.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
6292
6239
|
let n = document.createElement("div");
|
|
@@ -6308,7 +6255,7 @@ function wi(e) {
|
|
|
6308
6255
|
let c = document.createElement("button");
|
|
6309
6256
|
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);
|
|
6310
6257
|
}
|
|
6311
|
-
function
|
|
6258
|
+
function Ai(e) {
|
|
6312
6259
|
return new Promise((t) => {
|
|
6313
6260
|
let n = document.createElement("div");
|
|
6314
6261
|
n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
|
|
@@ -6334,8 +6281,8 @@ function Ti(e) {
|
|
|
6334
6281
|
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);
|
|
6335
6282
|
});
|
|
6336
6283
|
}
|
|
6337
|
-
async function
|
|
6338
|
-
let r =
|
|
6284
|
+
async function ji(e, t, n) {
|
|
6285
|
+
let r = vi(), i = Si(n), a = await kr();
|
|
6339
6286
|
if (!a) {
|
|
6340
6287
|
for (let e of i) r.missing.push(e[0]);
|
|
6341
6288
|
return r;
|
|
@@ -6348,14 +6295,13 @@ async function Ei(e, t, n) {
|
|
|
6348
6295
|
continue;
|
|
6349
6296
|
}
|
|
6350
6297
|
o.delete(i.basename);
|
|
6351
|
-
let s = await
|
|
6298
|
+
let s = await Ci(e, t, n, a);
|
|
6352
6299
|
r[s]++;
|
|
6353
6300
|
}
|
|
6354
6301
|
return r;
|
|
6355
6302
|
}
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
var Di = L.create({
|
|
6303
|
+
// src/editor/extensions/relative-media.ts
|
|
6304
|
+
var Mi = R.create({
|
|
6359
6305
|
name: "relativeMedia",
|
|
6360
6306
|
addStorage() {
|
|
6361
6307
|
return {
|
|
@@ -6365,59 +6311,59 @@ var Di = L.create({
|
|
|
6365
6311
|
},
|
|
6366
6312
|
addProseMirrorPlugins() {
|
|
6367
6313
|
let e = this.editor, t = this.storage, n = !1, r = null, i = async (n, i) => {
|
|
6368
|
-
let a = e.view, o =
|
|
6314
|
+
let a = e.view, o = vi(), { matched: s, unmatched: c } = wi(n, t.clipboardFiles);
|
|
6369
6315
|
for (let { refs: t, file: n } of s) {
|
|
6370
|
-
let r = await
|
|
6316
|
+
let r = await Ci(a, e, t, n);
|
|
6371
6317
|
o[r]++;
|
|
6372
6318
|
}
|
|
6373
6319
|
if (c.length > 0) {
|
|
6374
|
-
let t =
|
|
6375
|
-
if (
|
|
6320
|
+
let t = Si(c).length;
|
|
6321
|
+
if (Er()) {
|
|
6376
6322
|
let n = i ?? null;
|
|
6377
|
-
if (n || (await
|
|
6378
|
-
r = n,
|
|
6323
|
+
if (n || (await Oi(t) === "pick" ? (n = await Dr(), n || Z("没有选择文件夹。本地文件暂以占位显示,稍后可直接把文件拖进编辑器上传", "info")) : Z("已选择稍后处理。本地文件暂以占位显示,可直接把文件拖进编辑器上传", "info")), n) {
|
|
6324
|
+
r = n, yi(o, await Ti(a, e, c, n));
|
|
6379
6325
|
let t = [...o.missing, ...o.readFailed];
|
|
6380
|
-
if (t.length > 0 &&
|
|
6381
|
-
let n = await
|
|
6382
|
-
|
|
6326
|
+
if (t.length > 0 && Or() && await Ai(t.map((e) => e.basename)) === "pick") {
|
|
6327
|
+
let n = await ji(a, e, t);
|
|
6328
|
+
yi(o, n), o.missing = n.missing, o.readFailed = [];
|
|
6383
6329
|
}
|
|
6384
6330
|
}
|
|
6385
|
-
} else
|
|
6331
|
+
} else ki(t);
|
|
6386
6332
|
}
|
|
6387
|
-
|
|
6388
|
-
},
|
|
6333
|
+
Di(o);
|
|
6334
|
+
}, a = () => {
|
|
6389
6335
|
if (!e || e.isDestroyed || t.pausedUntilPaste) return;
|
|
6390
|
-
let
|
|
6336
|
+
let a = o(), s = Pr(e.state.doc, a);
|
|
6391
6337
|
if (s.length === 0 || n) return;
|
|
6392
6338
|
n = !0;
|
|
6393
6339
|
let c = new Set(s.map((e) => e.src));
|
|
6394
6340
|
i(s).then(() => {
|
|
6395
6341
|
if (e.isDestroyed) return;
|
|
6396
|
-
let t =
|
|
6342
|
+
let t = Pr(e.state.doc, a).filter((e) => !c.has(e.src));
|
|
6397
6343
|
if (t.length !== 0) return i(t, r);
|
|
6398
6344
|
}).finally(() => {
|
|
6399
|
-
n = !1,
|
|
6345
|
+
n = !1, e && !e.isDestroyed && (t.pausedUntilPaste = Pr(e.state.doc, a).length > 0);
|
|
6400
6346
|
});
|
|
6401
6347
|
};
|
|
6402
|
-
return [new
|
|
6403
|
-
key: new
|
|
6348
|
+
return [new V({
|
|
6349
|
+
key: new H("relativeMedia"),
|
|
6404
6350
|
props: { handlePaste(e, n) {
|
|
6405
6351
|
let r = n.clipboardData?.files;
|
|
6406
6352
|
return t.clipboardFiles = new Map(Array.from(r ?? []).map((e) => [e.name.toLowerCase(), e])), t.pausedUntilPaste = !1, !1;
|
|
6407
6353
|
} },
|
|
6408
6354
|
appendTransaction(e) {
|
|
6409
|
-
return e.some((e) => e.docChanged) && queueMicrotask(
|
|
6355
|
+
return e.some((e) => e.docChanged) && queueMicrotask(a), null;
|
|
6410
6356
|
}
|
|
6411
6357
|
})];
|
|
6412
6358
|
}
|
|
6413
|
-
}),
|
|
6414
|
-
function
|
|
6415
|
-
return
|
|
6359
|
+
}), Ni = new H("slashCommand");
|
|
6360
|
+
function Pi(e) {
|
|
6361
|
+
return R.create({
|
|
6416
6362
|
name: "slashCommand",
|
|
6417
6363
|
addProseMirrorPlugins() {
|
|
6418
6364
|
let t = {
|
|
6419
6365
|
char: "/",
|
|
6420
|
-
pluginKey:
|
|
6366
|
+
pluginKey: Ni,
|
|
6421
6367
|
findSuggestionMatch: (e) => {
|
|
6422
6368
|
let { $position: t } = e;
|
|
6423
6369
|
for (let e = t.depth; e >= 0; e--) if (t.node(e).type.name === "codeBlock") return null;
|
|
@@ -6490,20 +6436,15 @@ function ki(e) {
|
|
|
6490
6436
|
t && (n = Number(t.dataset.index ?? 0), f(t));
|
|
6491
6437
|
}), c.addEventListener("keydown", (e) => {
|
|
6492
6438
|
let t = d();
|
|
6493
|
-
if (e.key === "Enter")
|
|
6494
|
-
|
|
6495
|
-
return;
|
|
6496
|
-
}
|
|
6497
|
-
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
6439
|
+
if (e.key === "Enter") e.preventDefault(), (t.find((e) => e.classList.contains("slash-item--selected")) ?? t[0])?.click();
|
|
6440
|
+
else if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
6498
6441
|
if (e.preventDefault(), t.length === 0) return;
|
|
6499
6442
|
let r = t.findIndex((e) => e.classList.contains("slash-item--selected")), i = t[e.key === "ArrowDown" ? (r + 1) % t.length : (r - 1 + t.length) % t.length];
|
|
6500
6443
|
n = Number(i.dataset.index ?? 0), f(i);
|
|
6501
|
-
|
|
6502
|
-
}
|
|
6503
|
-
if (e.key === "Escape") {
|
|
6444
|
+
} else if (e.key === "Escape") {
|
|
6504
6445
|
e.preventDefault();
|
|
6505
6446
|
let t = a?.view;
|
|
6506
|
-
t && Ee(t,
|
|
6447
|
+
t && Ee(t, Ni);
|
|
6507
6448
|
}
|
|
6508
6449
|
});
|
|
6509
6450
|
}
|
|
@@ -6521,7 +6462,7 @@ function ki(e) {
|
|
|
6521
6462
|
if (!e || e.style.display === "none" || n.target instanceof Node && e.contains(n.target) || t) return;
|
|
6522
6463
|
let r = a?.view;
|
|
6523
6464
|
r && (t = !0, window.setTimeout(() => {
|
|
6524
|
-
t = !1, e?.style.display !== "none" && Ee(r,
|
|
6465
|
+
t = !1, e?.style.display !== "none" && Ee(r, Ni);
|
|
6525
6466
|
}, 0));
|
|
6526
6467
|
}, document.addEventListener("mousedown", o, !0), document.addEventListener("touchstart", o, !0);
|
|
6527
6468
|
}
|
|
@@ -6548,8 +6489,8 @@ function ki(e) {
|
|
|
6548
6489
|
return [Te({
|
|
6549
6490
|
editor: this.editor,
|
|
6550
6491
|
...t
|
|
6551
|
-
}), new
|
|
6552
|
-
key: new
|
|
6492
|
+
}), new V({
|
|
6493
|
+
key: new H("slashCodeBlockGuard"),
|
|
6553
6494
|
appendTransaction: (e, t, n) => {
|
|
6554
6495
|
let { $from: r } = n.selection, i = !1;
|
|
6555
6496
|
for (let e = r.depth; e >= 0; e--) if (r.node(e).type.name === "codeBlock") {
|
|
@@ -6557,14 +6498,14 @@ function ki(e) {
|
|
|
6557
6498
|
break;
|
|
6558
6499
|
}
|
|
6559
6500
|
if (!i && !r.marks().some((e) => e.type.name === "code")) return null;
|
|
6560
|
-
let a =
|
|
6561
|
-
return a && a.active ? n.tr.setMeta(
|
|
6501
|
+
let a = Ni.getState(n);
|
|
6502
|
+
return a && a.active ? n.tr.setMeta(Ni, { exit: !0 }) : null;
|
|
6562
6503
|
}
|
|
6563
6504
|
})];
|
|
6564
6505
|
}
|
|
6565
6506
|
});
|
|
6566
6507
|
}
|
|
6567
|
-
function
|
|
6508
|
+
function Fi(e, t) {
|
|
6568
6509
|
return [
|
|
6569
6510
|
{
|
|
6570
6511
|
title: e("editor.slash.heading1"),
|
|
@@ -6691,7 +6632,7 @@ function Ai(e, t) {
|
|
|
6691
6632
|
name: r.name,
|
|
6692
6633
|
size: r.size
|
|
6693
6634
|
});
|
|
6694
|
-
s && (e.
|
|
6635
|
+
s && (Un(e.view, s), await Br(e.view, r, o));
|
|
6695
6636
|
}, n.click();
|
|
6696
6637
|
}
|
|
6697
6638
|
},
|
|
@@ -6703,7 +6644,7 @@ function Ai(e, t) {
|
|
|
6703
6644
|
let n = document.createElement("input");
|
|
6704
6645
|
n.type = "file", n.accept = "*/*", n.multiple = !0, n.onchange = async () => {
|
|
6705
6646
|
let r = n.files;
|
|
6706
|
-
if (
|
|
6647
|
+
if (r && r.length !== 0) for (let n of Array.from(r)) {
|
|
6707
6648
|
let r = mn(e) ?? t, i = r ? hn(e.state.doc, n, r) : null;
|
|
6708
6649
|
if (i) {
|
|
6709
6650
|
Z(i);
|
|
@@ -6712,16 +6653,16 @@ function Ai(e, t) {
|
|
|
6712
6653
|
let a = URL.createObjectURL(n), o = e.schema.nodes.attachmentEmbed;
|
|
6713
6654
|
if (o) {
|
|
6714
6655
|
try {
|
|
6715
|
-
e.
|
|
6656
|
+
Un(e.view, o.create({
|
|
6716
6657
|
src: a,
|
|
6717
6658
|
name: n.name,
|
|
6718
6659
|
size: n.size,
|
|
6719
6660
|
type: n.type
|
|
6720
|
-
}))
|
|
6661
|
+
}));
|
|
6721
6662
|
} catch {
|
|
6722
6663
|
continue;
|
|
6723
6664
|
}
|
|
6724
|
-
await
|
|
6665
|
+
await Br(e.view, n, a);
|
|
6725
6666
|
}
|
|
6726
6667
|
}
|
|
6727
6668
|
}, n.click();
|
|
@@ -6729,9 +6670,8 @@ function Ai(e, t) {
|
|
|
6729
6670
|
}
|
|
6730
6671
|
];
|
|
6731
6672
|
}
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
var ji = U.extend({
|
|
6673
|
+
// src/editor/extensions/index.ts
|
|
6674
|
+
var Ii = W.extend({
|
|
6735
6675
|
addNodeView() {
|
|
6736
6676
|
return F(En);
|
|
6737
6677
|
},
|
|
@@ -6756,7 +6696,7 @@ var ji = U.extend({
|
|
|
6756
6696
|
};
|
|
6757
6697
|
}
|
|
6758
6698
|
});
|
|
6759
|
-
function
|
|
6699
|
+
function Li(e = {}) {
|
|
6760
6700
|
return [
|
|
6761
6701
|
G.configure({
|
|
6762
6702
|
codeBlock: !1,
|
|
@@ -6764,77 +6704,78 @@ function Mi(e = {}) {
|
|
|
6764
6704
|
underline: !1,
|
|
6765
6705
|
link: !1
|
|
6766
6706
|
}),
|
|
6767
|
-
|
|
6768
|
-
|
|
6707
|
+
ce,
|
|
6708
|
+
se.configure({
|
|
6769
6709
|
openOnClick: !0,
|
|
6770
6710
|
HTMLAttributes: {
|
|
6771
6711
|
rel: "noopener noreferrer",
|
|
6772
6712
|
target: "_blank"
|
|
6773
6713
|
}
|
|
6774
6714
|
}),
|
|
6775
|
-
|
|
6715
|
+
Ii.configure({
|
|
6776
6716
|
inline: !1,
|
|
6777
6717
|
allowBase64: !0
|
|
6778
6718
|
}),
|
|
6779
6719
|
_e,
|
|
6780
|
-
|
|
6720
|
+
q.configure({ nested: !0 }),
|
|
6781
6721
|
ue.configure({ multicolor: !0 }),
|
|
6782
6722
|
ve,
|
|
6783
|
-
|
|
6784
|
-
|
|
6723
|
+
le,
|
|
6724
|
+
K.configure(e.maxLength ? { limit: e.maxLength } : {}),
|
|
6785
6725
|
de,
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6726
|
+
Gr,
|
|
6727
|
+
oi,
|
|
6728
|
+
si,
|
|
6729
|
+
vr,
|
|
6790
6730
|
pe.configure({ resizable: !0 }),
|
|
6791
|
-
|
|
6792
|
-
q,
|
|
6731
|
+
ge,
|
|
6793
6732
|
me,
|
|
6733
|
+
he,
|
|
6794
6734
|
ye.configure({
|
|
6795
6735
|
html: !0,
|
|
6796
6736
|
transformPastedText: !0,
|
|
6797
6737
|
transformCopiedText: !1
|
|
6798
6738
|
}),
|
|
6799
6739
|
fe.configure({ placeholder: e.placeholder || "输入 '/' 打开菜单…" }),
|
|
6800
|
-
|
|
6740
|
+
Pi(() => Fi((e) => p(e), {
|
|
6801
6741
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6802
6742
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6803
6743
|
})),
|
|
6804
|
-
|
|
6744
|
+
Hr.configure({
|
|
6805
6745
|
maxAttachmentSize: e.maxAttachmentSize,
|
|
6806
6746
|
maxTotalAttachmentSize: e.maxTotalAttachmentSize
|
|
6807
6747
|
}),
|
|
6808
|
-
|
|
6809
|
-
|
|
6748
|
+
Mi,
|
|
6749
|
+
mi,
|
|
6750
|
+
tr,
|
|
6810
6751
|
At,
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6752
|
+
Kr,
|
|
6753
|
+
Wr,
|
|
6754
|
+
hi,
|
|
6755
|
+
$n,
|
|
6756
|
+
Kn,
|
|
6815
6757
|
Vn
|
|
6816
6758
|
];
|
|
6817
6759
|
}
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
function Ni(e) {
|
|
6760
|
+
// src/editor/extensions/bubble-menu.tsx
|
|
6761
|
+
function Ri(e) {
|
|
6821
6762
|
let t = e.trim(), n = /^\$([^$]+?)\$$/.exec(t);
|
|
6822
6763
|
if (n) return n[1].trim();
|
|
6823
6764
|
let r = /^\$\$([\s\S]+?)\$\$$/.exec(t);
|
|
6824
6765
|
return r ? r[1].trim() : t;
|
|
6825
6766
|
}
|
|
6826
|
-
function
|
|
6767
|
+
function zi(e) {
|
|
6827
6768
|
let t = e.trim();
|
|
6828
6769
|
return t ? /^\${1,2}[\s\S]*\${1,2}$/.test(t) ? !0 : /[0-9=]/.test(t) && /[+\-*/^=(){}_\\]/.test(t) : !1;
|
|
6829
6770
|
}
|
|
6830
|
-
var
|
|
6831
|
-
function
|
|
6832
|
-
|
|
6771
|
+
var Bi = "https://www.bing.com/search?q={query}";
|
|
6772
|
+
function Vi(e) {
|
|
6773
|
+
Bi = e;
|
|
6833
6774
|
}
|
|
6834
|
-
function
|
|
6835
|
-
return
|
|
6775
|
+
function Hi() {
|
|
6776
|
+
return Bi;
|
|
6836
6777
|
}
|
|
6837
|
-
function
|
|
6778
|
+
function Ui(e) {
|
|
6838
6779
|
return [
|
|
6839
6780
|
{
|
|
6840
6781
|
key: "bold",
|
|
@@ -6880,7 +6821,7 @@ function Ri(e) {
|
|
|
6880
6821
|
if (!e.isEditable) return;
|
|
6881
6822
|
let { from: t, to: n } = e.state.selection;
|
|
6882
6823
|
if (t === n) return;
|
|
6883
|
-
let r =
|
|
6824
|
+
let r = Ri(e.state.doc.textBetween(t, n, "\n"));
|
|
6884
6825
|
r && e.chain().focus().insertContentAt({
|
|
6885
6826
|
from: t,
|
|
6886
6827
|
to: n
|
|
@@ -6927,7 +6868,7 @@ function Ri(e) {
|
|
|
6927
6868
|
if (e.isActive("table")) return;
|
|
6928
6869
|
let { from: t, to: n } = e.state.selection, r = e.state.doc.textBetween(t, n, " ").trim();
|
|
6929
6870
|
if (!r) return;
|
|
6930
|
-
let i =
|
|
6871
|
+
let i = Bi.replace("{query}", encodeURIComponent(r));
|
|
6931
6872
|
window.open(i, "_blank", "noopener,noreferrer");
|
|
6932
6873
|
}
|
|
6933
6874
|
},
|
|
@@ -6958,10 +6899,9 @@ function Ri(e) {
|
|
|
6958
6899
|
}
|
|
6959
6900
|
];
|
|
6960
6901
|
}
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
function zi(e) {
|
|
6902
|
+
R.create({ name: "bubbleMenu" });
|
|
6903
|
+
// src/editor/extensions/table-toolbar.tsx
|
|
6904
|
+
function Wi(e) {
|
|
6965
6905
|
let { $from: t } = e.state.selection;
|
|
6966
6906
|
for (let e = t.depth; e > 0; e--) {
|
|
6967
6907
|
let n = t.node(e);
|
|
@@ -6972,7 +6912,7 @@ function zi(e) {
|
|
|
6972
6912
|
}
|
|
6973
6913
|
return null;
|
|
6974
6914
|
}
|
|
6975
|
-
function
|
|
6915
|
+
function Gi(e) {
|
|
6976
6916
|
let t = [];
|
|
6977
6917
|
return e.forEach((e) => {
|
|
6978
6918
|
let n = [];
|
|
@@ -6981,7 +6921,7 @@ function Bi(e) {
|
|
|
6981
6921
|
}), t.push(n);
|
|
6982
6922
|
}), t;
|
|
6983
6923
|
}
|
|
6984
|
-
function
|
|
6924
|
+
function Ki(e) {
|
|
6985
6925
|
if (e.length === 0) return "";
|
|
6986
6926
|
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(" | ")} |`;
|
|
6987
6927
|
return [
|
|
@@ -6990,11 +6930,11 @@ function Vi(e) {
|
|
|
6990
6930
|
...i.map(a)
|
|
6991
6931
|
].join("\n");
|
|
6992
6932
|
}
|
|
6993
|
-
function
|
|
6933
|
+
function qi(e) {
|
|
6994
6934
|
let t = (e) => /[",\n]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e;
|
|
6995
6935
|
return e.map((e) => e.map(t).join(",")).join("\n");
|
|
6996
6936
|
}
|
|
6997
|
-
function
|
|
6937
|
+
function Ji(e) {
|
|
6998
6938
|
let t = e.trim();
|
|
6999
6939
|
if (!t) return null;
|
|
7000
6940
|
let n = t.split(/\r?\n/);
|
|
@@ -7008,7 +6948,7 @@ function Ui(e) {
|
|
|
7008
6948
|
}
|
|
7009
6949
|
return null;
|
|
7010
6950
|
}
|
|
7011
|
-
function
|
|
6951
|
+
function Yi({ editor: e }) {
|
|
7012
6952
|
let [t, n] = T(null), [r, i] = T(!1), [a, o] = T(!1), s = w(null), c = w(null), l = e.isEditable, u = b(() => {
|
|
7013
6953
|
c.current != null && cancelAnimationFrame(c.current), c.current = requestAnimationFrame(() => {
|
|
7014
6954
|
c.current = null;
|
|
@@ -7024,12 +6964,8 @@ function Wi({ editor: e }) {
|
|
|
7024
6964
|
n(null);
|
|
7025
6965
|
return;
|
|
7026
6966
|
}
|
|
7027
|
-
let t =
|
|
7028
|
-
|
|
7029
|
-
n(null);
|
|
7030
|
-
return;
|
|
7031
|
-
}
|
|
7032
|
-
n((e) => e === t.pos ? e : t.pos);
|
|
6967
|
+
let t = Wi(e);
|
|
6968
|
+
n(t ? (e) => e === t.pos ? e : t.pos : null);
|
|
7033
6969
|
}, [e]);
|
|
7034
6970
|
x(() => (d(), e.on("selectionUpdate", d), e.on("focus", d), window.addEventListener("scroll", u, !0), window.addEventListener("resize", u), () => {
|
|
7035
6971
|
e.off("selectionUpdate", d), e.off("focus", d), window.removeEventListener("scroll", u, !0), window.removeEventListener("resize", u), c.current != null && cancelAnimationFrame(c.current);
|
|
@@ -7053,24 +6989,24 @@ function Wi({ editor: e }) {
|
|
|
7053
6989
|
});
|
|
7054
6990
|
return n.nodes.table.create(null, i);
|
|
7055
6991
|
}, p = () => {
|
|
7056
|
-
let t =
|
|
6992
|
+
let t = Wi(e);
|
|
7057
6993
|
if (!t) return;
|
|
7058
|
-
let n =
|
|
6994
|
+
let n = Ki(Gi(t.node));
|
|
7059
6995
|
navigator.clipboard?.writeText(n), i(!0), setTimeout(() => i(!1), 1500);
|
|
7060
6996
|
}, m = () => {
|
|
7061
|
-
let t =
|
|
6997
|
+
let t = Wi(e);
|
|
7062
6998
|
if (!t) return;
|
|
7063
|
-
let n =
|
|
6999
|
+
let n = qi(Gi(t.node)), r = new Blob([`\ufeff${n}`], { type: "text/csv;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
7064
7000
|
a.href = i, a.download = "table.csv", document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
7065
7001
|
}, h = async () => {
|
|
7066
7002
|
if (l) try {
|
|
7067
7003
|
let t = await navigator.clipboard?.readText();
|
|
7068
7004
|
if (!t) return;
|
|
7069
|
-
let n =
|
|
7005
|
+
let n = Ji(t);
|
|
7070
7006
|
if (!n || n.length === 0) return;
|
|
7071
7007
|
let r = f(n);
|
|
7072
7008
|
if (!r) return;
|
|
7073
|
-
let i =
|
|
7009
|
+
let i = Wi(e), a = e.chain().focus();
|
|
7074
7010
|
if (i) {
|
|
7075
7011
|
let t = Math.min(i.pos + i.node.nodeSize, e.state.doc.content.size);
|
|
7076
7012
|
a.setTextSelection(t);
|
|
@@ -7190,7 +7126,7 @@ function Wi({ editor: e }) {
|
|
|
7190
7126
|
type: "button",
|
|
7191
7127
|
className: "tbl-btn tbl-btn--del",
|
|
7192
7128
|
onClick: () => {
|
|
7193
|
-
|
|
7129
|
+
l && !yn() && ($(!0), o(!0));
|
|
7194
7130
|
},
|
|
7195
7131
|
title: "删除",
|
|
7196
7132
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -7222,9 +7158,8 @@ function Wi({ editor: e }) {
|
|
|
7222
7158
|
]
|
|
7223
7159
|
});
|
|
7224
7160
|
}
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
var Gi = [
|
|
7161
|
+
// src/editor/ai-editor.tsx
|
|
7162
|
+
var Xi = [
|
|
7228
7163
|
{
|
|
7229
7164
|
color: "#fef08a",
|
|
7230
7165
|
name: "黄"
|
|
@@ -7249,9 +7184,9 @@ var Gi = [
|
|
|
7249
7184
|
color: "#ddd6fe",
|
|
7250
7185
|
name: "紫"
|
|
7251
7186
|
}
|
|
7252
|
-
],
|
|
7253
|
-
function
|
|
7254
|
-
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth ||
|
|
7187
|
+
], Zi = 288, Qi = 480, $i = 320;
|
|
7188
|
+
function ea(e, t, n = {}) {
|
|
7189
|
+
let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth || Zi, Qi, r - 32), o = Math.max(t || $i, 160);
|
|
7255
7190
|
if (r < 640) {
|
|
7256
7191
|
let t = Math.max(8, Math.min(e.top + 10, i - 420));
|
|
7257
7192
|
return {
|
|
@@ -7292,10 +7227,10 @@ function Yi(e, t, n = {}) {
|
|
|
7292
7227
|
arrowLeft: p
|
|
7293
7228
|
};
|
|
7294
7229
|
}
|
|
7295
|
-
function
|
|
7230
|
+
function ta(e) {
|
|
7296
7231
|
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);
|
|
7297
7232
|
}
|
|
7298
|
-
function
|
|
7233
|
+
function na(e, t) {
|
|
7299
7234
|
try {
|
|
7300
7235
|
let n = e.storage?.markdown?.parser;
|
|
7301
7236
|
if (!n) return null;
|
|
@@ -7305,19 +7240,19 @@ function Zi(e, t) {
|
|
|
7305
7240
|
return null;
|
|
7306
7241
|
}
|
|
7307
7242
|
}
|
|
7308
|
-
var
|
|
7243
|
+
var ra = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.ImageUploadDialog }))), ia = y(() => import("./storage-settings-dialog-DfJuUAkg.js").then((e) => ({ default: e.StorageSettingsDialog }))), aa = y(() => import("./export-dialog-Bnbjhxoc.js").then((e) => ({ default: e.ExportDialog }))), oa = y(() => import("./video-embed-dialog-eCCrqLDP.js").then((e) => ({ default: e.VideoEmbedDialog }))), sa = y(() => import("./md-import-dialog-WLWQ4INh.js").then((e) => ({ default: e.MdImportDialog }))), ca = () => /* @__PURE__ */ O("div", {
|
|
7309
7244
|
className: "fixed inset-0 z-[9999] flex items-center justify-center",
|
|
7310
7245
|
children: [/* @__PURE__ */ D("div", { className: "absolute inset-0 bg-black/40 backdrop-blur-sm" }), /* @__PURE__ */ D("div", {
|
|
7311
7246
|
className: "relative bg-background rounded-2xl border border-default-200 p-8 flex items-center justify-center",
|
|
7312
7247
|
children: /* @__PURE__ */ D("div", { className: "w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin" })
|
|
7313
7248
|
})]
|
|
7314
|
-
}),
|
|
7315
|
-
let
|
|
7249
|
+
}), la = ({ initialContent: e = "", onChange: t, placeholder: n, mode: r, readonly: i = !1, maxLength: a, wordCounter: o, maxAttachmentSize: s, maxTotalAttachmentSize: c, className: l = "", borderless: u = !1, style: d, showToolbar: m = !0, showToc: h = !0, showSearch: g = !0, onEditorReady: _, immediatelyRender: y, onToast: k }) => {
|
|
7250
|
+
let A = r === "view" || i, j = C(() => typeof e == "object" && e || ta(e) ? e : f(e), [e]), [M, P] = T(!1), [F, I] = T({}), [R, re] = T("below"), [ie, z] = T(50), B = w(null), [V, H] = T(!1), [ae, oe] = T(!1), [U, W] = T(!1), [se, ce] = T(!1), [G, K] = T("none"), [le, ue] = T({}), de = w(null), fe = w(null), [pe, me] = T(""), [he, ge] = T(null), [q, _e] = T(h), [ve, ye] = T(!1);
|
|
7316
7251
|
x(() => {
|
|
7317
|
-
|
|
7318
|
-
}, [
|
|
7319
|
-
let [
|
|
7320
|
-
let e =
|
|
7252
|
+
_e(h);
|
|
7253
|
+
}, [h]);
|
|
7254
|
+
let [be, xe] = T(!1), [Se, Ce] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 80rem)").matches : !0), [we, Te] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 64rem)").matches : !0), Ee = w(null), De = w(null), Oe = w(null), ke = w(0), Ae = w(null), je = w(null), Me = w(null), Ne = w(null), Pe = w(null), [Fe, Ie] = T(!1), [Le, Re] = T(!1), [J, ze] = T(!1), [Be, Ve] = T(!1), He = w(null), Ue = b(() => {
|
|
7255
|
+
let e = De.current, t = Oe.current;
|
|
7321
7256
|
e && (J ? (document.body.style.overflow = "", Object.assign(e.style, {
|
|
7322
7257
|
position: "",
|
|
7323
7258
|
top: "",
|
|
@@ -7334,9 +7269,9 @@ var Qi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7334
7269
|
flex: "",
|
|
7335
7270
|
overflow: "",
|
|
7336
7271
|
minHeight: ""
|
|
7337
|
-
}),
|
|
7338
|
-
window.scrollTo(0,
|
|
7339
|
-
})) : (document.fullscreenElement && document.exitFullscreen(),
|
|
7272
|
+
}), ze(!1), requestAnimationFrame(() => {
|
|
7273
|
+
window.scrollTo(0, ke.current);
|
|
7274
|
+
})) : (document.fullscreenElement && document.exitFullscreen(), ke.current = window.scrollY, Object.assign(e.style, {
|
|
7340
7275
|
position: "fixed",
|
|
7341
7276
|
top: "0",
|
|
7342
7277
|
left: "0",
|
|
@@ -7351,64 +7286,64 @@ var Qi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7351
7286
|
flex: "1",
|
|
7352
7287
|
overflow: "auto",
|
|
7353
7288
|
minHeight: "0"
|
|
7354
|
-
}), document.body.style.overflow = "hidden",
|
|
7355
|
-
}, [J]),
|
|
7356
|
-
let e =
|
|
7357
|
-
e && (document.fullscreenElement ? document.exitFullscreen() : (J &&
|
|
7358
|
-
}, [J,
|
|
7289
|
+
}), document.body.style.overflow = "hidden", ze(!0)));
|
|
7290
|
+
}, [J]), We = b(() => {
|
|
7291
|
+
let e = De.current;
|
|
7292
|
+
e && (document.fullscreenElement ? document.exitFullscreen() : (J && Ue(), ke.current = window.scrollY, e.requestFullscreen()));
|
|
7293
|
+
}, [J, Ue]);
|
|
7359
7294
|
x(() => {
|
|
7360
7295
|
let e = (e) => {
|
|
7361
|
-
e.key === "Escape" && J &&
|
|
7296
|
+
e.key === "Escape" && J && Ue();
|
|
7362
7297
|
}, t = () => {
|
|
7363
|
-
document.fullscreenElement ?
|
|
7364
|
-
window.scrollTo(0,
|
|
7298
|
+
document.fullscreenElement ? Ve(!0) : (Ve(!1), requestAnimationFrame(() => {
|
|
7299
|
+
window.scrollTo(0, ke.current);
|
|
7365
7300
|
}));
|
|
7366
7301
|
};
|
|
7367
7302
|
return window.addEventListener("keydown", e), document.addEventListener("fullscreenchange", t), () => {
|
|
7368
7303
|
window.removeEventListener("keydown", e), document.removeEventListener("fullscreenchange", t);
|
|
7369
7304
|
};
|
|
7370
|
-
}, [J,
|
|
7371
|
-
if (!
|
|
7305
|
+
}, [J, Ue]), x(() => {
|
|
7306
|
+
if (!g) return;
|
|
7372
7307
|
let e = (e) => {
|
|
7373
7308
|
if ((e.ctrlKey || e.metaKey) && (e.key === "f" || e.key === "F")) {
|
|
7374
|
-
if (!
|
|
7375
|
-
e.preventDefault(), e.stopPropagation(),
|
|
7309
|
+
if (!De.current) return;
|
|
7310
|
+
e.preventDefault(), e.stopPropagation(), xe(!0);
|
|
7376
7311
|
}
|
|
7377
7312
|
};
|
|
7378
7313
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
7379
|
-
}, [
|
|
7314
|
+
}, [g]), x(() => {
|
|
7380
7315
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
7381
|
-
let e = window.matchMedia("(min-width: 80rem)"), t = (e) =>
|
|
7382
|
-
return
|
|
7316
|
+
let e = window.matchMedia("(min-width: 80rem)"), t = (e) => Ce(e.matches);
|
|
7317
|
+
return Ce(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
7383
7318
|
}, []), x(() => {
|
|
7384
7319
|
if (typeof window > "u" || typeof window.matchMedia != "function") return;
|
|
7385
|
-
let e = window.matchMedia("(min-width: 64rem)"), t = (e) =>
|
|
7386
|
-
return
|
|
7320
|
+
let e = window.matchMedia("(min-width: 64rem)"), t = (e) => Te(e.matches);
|
|
7321
|
+
return Te(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
7387
7322
|
}, []);
|
|
7388
7323
|
let Y = te({
|
|
7389
|
-
extensions:
|
|
7390
|
-
placeholder: n ||
|
|
7324
|
+
extensions: Li({
|
|
7325
|
+
placeholder: n || p("editor.placeholder"),
|
|
7391
7326
|
maxLength: a,
|
|
7392
|
-
maxAttachmentSize:
|
|
7393
|
-
maxTotalAttachmentSize:
|
|
7327
|
+
maxAttachmentSize: s,
|
|
7328
|
+
maxTotalAttachmentSize: c
|
|
7394
7329
|
}),
|
|
7395
|
-
content:
|
|
7396
|
-
editable: !
|
|
7397
|
-
immediatelyRender:
|
|
7330
|
+
content: j,
|
|
7331
|
+
editable: !A,
|
|
7332
|
+
immediatelyRender: y,
|
|
7398
7333
|
onUpdate: ({ editor: e }) => {
|
|
7399
|
-
t && (
|
|
7334
|
+
t && (Ee.current && clearTimeout(Ee.current), Ee.current = setTimeout(() => {
|
|
7400
7335
|
t?.(e.getHTML(), e.getJSON());
|
|
7401
7336
|
}, 300));
|
|
7402
7337
|
},
|
|
7403
7338
|
onCreate: () => {},
|
|
7404
7339
|
onSelectionUpdate: ({ editor: e }) => {
|
|
7405
7340
|
let { from: t, to: n } = e.state.selection, r = t === n ? "" : e.state.doc.textBetween(t, n, "\n");
|
|
7406
|
-
|
|
7341
|
+
Re(zi(r));
|
|
7407
7342
|
},
|
|
7408
7343
|
editorProps: {
|
|
7409
7344
|
attributes: {
|
|
7410
7345
|
class: "prose prose-neutral dark:prose-invert max-w-none focus:outline-none min-h-[200px] px-4 sm:px-8 py-4",
|
|
7411
|
-
...
|
|
7346
|
+
...A ? {} : { style: "padding-left: 2.75rem" }
|
|
7412
7347
|
},
|
|
7413
7348
|
handlePaste(e, t) {
|
|
7414
7349
|
let n = t.clipboardData;
|
|
@@ -7416,9 +7351,9 @@ var Qi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7416
7351
|
let r = n.getData("text/plain");
|
|
7417
7352
|
if (!r || !r.includes("[[")) return !1;
|
|
7418
7353
|
t.preventDefault();
|
|
7419
|
-
let i =
|
|
7354
|
+
let i = je.current?.storage?.relativeMedia;
|
|
7420
7355
|
i && (i.clipboardFiles = new Map(Array.from(n.files ?? []).map((e) => [e.name.toLowerCase(), e])), i.pausedUntilPaste = !1);
|
|
7421
|
-
let a =
|
|
7356
|
+
let a = je.current ? na(je.current, r) : null;
|
|
7422
7357
|
if (a) {
|
|
7423
7358
|
let t = new N(a, 0, 0);
|
|
7424
7359
|
e.dispatch(e.state.tr.replaceSelection(t).scrollIntoView());
|
|
@@ -7428,125 +7363,149 @@ var Qi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7428
7363
|
}
|
|
7429
7364
|
});
|
|
7430
7365
|
x(() => {
|
|
7431
|
-
|
|
7366
|
+
je.current = Y, window.__editor = Y;
|
|
7432
7367
|
}, [Y]), x(() => {
|
|
7433
7368
|
if (Y) return () => en(Y);
|
|
7434
7369
|
}, [Y]), x(() => {
|
|
7435
|
-
|
|
7436
|
-
}, [Y,
|
|
7370
|
+
Y && _ && _(Y);
|
|
7371
|
+
}, [Y, _]), x(() => {
|
|
7437
7372
|
if (!Y) return;
|
|
7438
7373
|
let e = () => {
|
|
7439
|
-
Y.state.selection.empty && (
|
|
7374
|
+
Y.state.selection.empty && (K("none"), Ie(!1));
|
|
7440
7375
|
};
|
|
7441
7376
|
return Y.on("selectionUpdate", e), () => {
|
|
7442
7377
|
Y.off("selectionUpdate", e);
|
|
7443
7378
|
};
|
|
7444
7379
|
}, [Y]), x(() => {
|
|
7445
|
-
Y && Y.setOptions({ extensions:
|
|
7446
|
-
placeholder: n ||
|
|
7380
|
+
Y && Y.setOptions({ extensions: Li({
|
|
7381
|
+
placeholder: n || p("editor.placeholder"),
|
|
7447
7382
|
maxLength: a,
|
|
7448
|
-
maxAttachmentSize:
|
|
7449
|
-
maxTotalAttachmentSize:
|
|
7383
|
+
maxAttachmentSize: s,
|
|
7384
|
+
maxTotalAttachmentSize: c
|
|
7450
7385
|
}) });
|
|
7451
7386
|
}, [
|
|
7452
7387
|
n,
|
|
7453
7388
|
a,
|
|
7454
|
-
|
|
7455
|
-
|
|
7389
|
+
s,
|
|
7390
|
+
c
|
|
7456
7391
|
]);
|
|
7457
|
-
let
|
|
7392
|
+
let Ge = w(e);
|
|
7458
7393
|
x(() => {
|
|
7459
|
-
if (!Y || e ===
|
|
7460
|
-
|
|
7461
|
-
let t = typeof e == "object" && e ||
|
|
7394
|
+
if (!Y || e === Ge.current) return;
|
|
7395
|
+
Ge.current = e;
|
|
7396
|
+
let t = typeof e == "object" && e || ta(e) ? e : f(e);
|
|
7462
7397
|
Y.commands.setContent(t, { emitUpdate: !1 });
|
|
7463
7398
|
}, [Y, e]), x(() => {
|
|
7464
|
-
Y && Y.setEditable(!
|
|
7465
|
-
}, [Y,
|
|
7466
|
-
if (
|
|
7467
|
-
}, [
|
|
7399
|
+
Y && Y.setEditable(!A, !1);
|
|
7400
|
+
}, [Y, A]), x(() => {
|
|
7401
|
+
if (k) return tt(k);
|
|
7402
|
+
}, [k]), x(() => {
|
|
7468
7403
|
if (!Y) return;
|
|
7469
7404
|
let e = fn(Y.state.doc);
|
|
7470
|
-
e >
|
|
7471
|
-
}, [Y,
|
|
7405
|
+
e > c && Z(`文档内附件总大小 ${pn(e)} 已超过限制 ${pn(c)}`, "info");
|
|
7406
|
+
}, [Y, c]), x(() => {
|
|
7472
7407
|
if (!Y) return;
|
|
7473
7408
|
let e = Y.storage.qingwuUI;
|
|
7474
7409
|
e && (e.limits = {
|
|
7475
|
-
maxAttachmentSize:
|
|
7476
|
-
maxTotalAttachmentSize:
|
|
7410
|
+
maxAttachmentSize: s,
|
|
7411
|
+
maxTotalAttachmentSize: c
|
|
7477
7412
|
});
|
|
7478
7413
|
}, [
|
|
7479
7414
|
Y,
|
|
7480
|
-
|
|
7481
|
-
|
|
7415
|
+
s,
|
|
7416
|
+
c
|
|
7482
7417
|
]);
|
|
7483
|
-
let
|
|
7484
|
-
let n = e ? Math.max(8, Math.min(e.left,
|
|
7485
|
-
return
|
|
7418
|
+
let Ke = b((e, t) => {
|
|
7419
|
+
let n = window.visualViewport, r = n?.offsetLeft ?? 0, i = n?.offsetTop ?? 0, a = n?.width ?? window.innerWidth, o = n?.height ?? window.innerHeight, s = Math.min(252, a - 16), c = e ? Math.max(r + 8, Math.min(e.left, r + a - s - 8)) : r + 8, l;
|
|
7420
|
+
return l = e ? t && e.bottom + 8 + t > i + o - 8 ? e.top - t - 8 : e.bottom + 8 : i + 8, l = Math.max(i + 8, Math.min(l, i + o - (t ?? 0) - 8)), {
|
|
7486
7421
|
position: "fixed",
|
|
7487
|
-
top:
|
|
7488
|
-
left:
|
|
7422
|
+
top: l,
|
|
7423
|
+
left: c,
|
|
7424
|
+
width: s,
|
|
7425
|
+
maxHeight: o - 16,
|
|
7426
|
+
overflowY: "auto",
|
|
7489
7427
|
zIndex: 9999
|
|
7490
7428
|
};
|
|
7491
|
-
}, []),
|
|
7492
|
-
let t =
|
|
7493
|
-
|
|
7494
|
-
}, [
|
|
7429
|
+
}, []), qe = b((e) => {
|
|
7430
|
+
let t = Ne.current?.getBoundingClientRect() ?? null;
|
|
7431
|
+
fe.current = t, K(e), Ie(!1), ue(Ke(t, void 0));
|
|
7432
|
+
}, [Ke]);
|
|
7495
7433
|
S(() => {
|
|
7496
|
-
if (
|
|
7497
|
-
let e =
|
|
7498
|
-
|
|
7499
|
-
}, [
|
|
7500
|
-
|
|
7501
|
-
let e =
|
|
7502
|
-
|
|
7503
|
-
|
|
7434
|
+
if (G === "none") return;
|
|
7435
|
+
let e = de.current;
|
|
7436
|
+
ue(Ke(fe.current, e?.offsetHeight || void 0));
|
|
7437
|
+
}, [G, Ke]);
|
|
7438
|
+
let X = b(() => {
|
|
7439
|
+
let e = Pe.current, t = Ne.current;
|
|
7440
|
+
if (!e || !t) return;
|
|
7441
|
+
let n = t.getBoundingClientRect(), r = window.visualViewport, i = r?.offsetTop ?? 0, a = r?.height ?? window.innerHeight, o = i + a - n.bottom - 16, s = n.top - i - 16, c = o < e.scrollHeight + 2 && s > o;
|
|
7442
|
+
e.dataset.placement = c ? "above" : "below", e.style.maxHeight = `${Math.max(40, Math.min(a - 16, c ? s : o))}px`;
|
|
7443
|
+
}, []);
|
|
7444
|
+
S(() => {
|
|
7445
|
+
if (!Fe) return;
|
|
7446
|
+
X();
|
|
7447
|
+
let e = window.visualViewport;
|
|
7448
|
+
return window.addEventListener("resize", X), window.addEventListener("scroll", X, !0), e?.addEventListener("resize", X), e?.addEventListener("scroll", X), () => {
|
|
7449
|
+
window.removeEventListener("resize", X), window.removeEventListener("scroll", X, !0), e?.removeEventListener("resize", X), e?.removeEventListener("scroll", X);
|
|
7504
7450
|
};
|
|
7505
|
-
|
|
7506
|
-
|
|
7451
|
+
}, [Fe, X]), x(() => {
|
|
7452
|
+
if (G === "none") return;
|
|
7453
|
+
let e = () => K("none"), t = () => {
|
|
7454
|
+
let e = de.current;
|
|
7455
|
+
ue(Ke(Ne.current?.getBoundingClientRect() ?? fe.current, e?.offsetHeight || void 0));
|
|
7456
|
+
}, n = window.visualViewport;
|
|
7457
|
+
return window.addEventListener("scroll", e, !0), window.addEventListener("resize", t), n?.addEventListener("resize", t), n?.addEventListener("scroll", t), () => {
|
|
7458
|
+
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", t), n?.removeEventListener("resize", t), n?.removeEventListener("scroll", t);
|
|
7507
7459
|
};
|
|
7508
|
-
}, [
|
|
7509
|
-
|
|
7510
|
-
}, [
|
|
7511
|
-
let
|
|
7512
|
-
if (Y)
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7460
|
+
}, [G, Ke]), x(() => {
|
|
7461
|
+
G === "none" && (fe.current = null);
|
|
7462
|
+
}, [G]);
|
|
7463
|
+
let Je = Ui((e) => p(e)), Ye = Je.filter((e) => !e.more), Xe = Je.filter((e) => e.more), Ze = Ye.filter((e) => e.key !== "ai" && (e.key !== "mathInline" || Le)), Qe = Ye.find((e) => e.key === "ai"), $e = b((e) => {
|
|
7464
|
+
if (Y) {
|
|
7465
|
+
if (Ie(!1), e.key === "link") {
|
|
7466
|
+
if (Y.isActive("link")) Y.chain().focus().unsetLink().run();
|
|
7467
|
+
else {
|
|
7468
|
+
let e = Y.getAttributes("link").href || "";
|
|
7469
|
+
me(e), qe("link");
|
|
7470
|
+
}
|
|
7471
|
+
} else e.key === "highlight" ? G === "highlight" ? K("none") : qe("highlight") : e.command(Y);
|
|
7516
7472
|
}
|
|
7517
|
-
else e.key === "highlight" ? W === "highlight" ? G("none") : We("highlight") : e.command(Y);
|
|
7518
7473
|
}, [
|
|
7519
7474
|
Y,
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
]),
|
|
7475
|
+
G,
|
|
7476
|
+
qe
|
|
7477
|
+
]), et = b((e) => Y ? e.key === "highlight" ? G === "highlight" : e.key === "link" ? Y.isActive("link") : e.isActive(Y) : !1, [Y, G]), [nt, rt] = T(0);
|
|
7523
7478
|
x(() => {
|
|
7524
7479
|
if (!Y) return;
|
|
7525
|
-
let e = () =>
|
|
7480
|
+
let e = () => rt((e) => (e + 1) % 1e6);
|
|
7526
7481
|
return Y.on("update", e), () => {
|
|
7527
7482
|
Y.off("update", e);
|
|
7528
7483
|
};
|
|
7529
7484
|
}, [Y]);
|
|
7530
|
-
let [
|
|
7485
|
+
let [it, at] = T(!1);
|
|
7531
7486
|
x(() => {
|
|
7532
7487
|
if (!Y) return;
|
|
7533
7488
|
let e = () => {
|
|
7534
7489
|
let e = !1;
|
|
7535
7490
|
Y.state.doc.descendants((t) => {
|
|
7536
7491
|
t.type.name === "heading" && (e = !0);
|
|
7537
|
-
}),
|
|
7492
|
+
}), at(e);
|
|
7538
7493
|
};
|
|
7539
7494
|
return e(), Y.on("update", e), () => {
|
|
7540
7495
|
Y.off("update", e);
|
|
7541
7496
|
};
|
|
7542
7497
|
}, [Y]);
|
|
7543
|
-
let
|
|
7498
|
+
let ot = C(() => Y?.storage?.characterCount?.characters?.() ?? 0, [Y, nt]), st = a ? ot > a : !1, ct = C(() => o && Y ? o(Y.getText({ blockSeparator: "" })) : null, [
|
|
7499
|
+
Y,
|
|
7500
|
+
o,
|
|
7501
|
+
nt
|
|
7502
|
+
]);
|
|
7544
7503
|
x(() => () => {
|
|
7545
|
-
|
|
7504
|
+
Ee.current && clearTimeout(Ee.current);
|
|
7546
7505
|
}, []), x(() => () => {
|
|
7547
|
-
|
|
7506
|
+
he && he.resolve(null);
|
|
7548
7507
|
}, []);
|
|
7549
|
-
let
|
|
7508
|
+
let dt = b((e) => {
|
|
7550
7509
|
if (!Y?.isEditable) return;
|
|
7551
7510
|
let t = window.getSelection(), n;
|
|
7552
7511
|
if (e) {
|
|
@@ -7571,69 +7530,69 @@ var Qi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7571
7530
|
width: 0
|
|
7572
7531
|
};
|
|
7573
7532
|
}
|
|
7574
|
-
|
|
7575
|
-
let r =
|
|
7533
|
+
Ae.current = n;
|
|
7534
|
+
let r = De.current?.getBoundingClientRect(), i = ea(n, void 0, {
|
|
7576
7535
|
panelWidth: r?.width,
|
|
7577
7536
|
editorLeft: r?.left
|
|
7578
7537
|
});
|
|
7579
|
-
|
|
7538
|
+
P(!0), I(i.style), re(i.placement), z(i.arrowLeft);
|
|
7580
7539
|
}, [Y]);
|
|
7581
7540
|
x(() => {
|
|
7582
7541
|
if (!Y) return;
|
|
7583
7542
|
let e = Y.storage.qingwuUI;
|
|
7584
|
-
if (e) return e.openImageDialog = () =>
|
|
7585
|
-
|
|
7543
|
+
if (e) return e.openImageDialog = () => H(!0), e.openVideoDialog = () => oe(!0), e.chooseMd = (e, t) => {
|
|
7544
|
+
ge({
|
|
7586
7545
|
filename: e,
|
|
7587
7546
|
resolve: t
|
|
7588
7547
|
});
|
|
7589
|
-
}, e.openAI =
|
|
7548
|
+
}, e.openAI = dt, e.parseMd = (e, t) => Y ? na(Y, t) : null, () => {
|
|
7590
7549
|
delete e.openImageDialog, delete e.openVideoDialog, delete e.openAI, delete e.parseMd, delete e.chooseMd;
|
|
7591
7550
|
};
|
|
7592
|
-
}, [Y,
|
|
7593
|
-
if (!
|
|
7594
|
-
let e =
|
|
7551
|
+
}, [Y, dt]), S(() => {
|
|
7552
|
+
if (!M || !Y) return;
|
|
7553
|
+
let e = Ae.current;
|
|
7595
7554
|
if (!e) return;
|
|
7596
|
-
let t =
|
|
7555
|
+
let t = B.current, n = De.current?.getBoundingClientRect(), r = ea(e, t?.offsetHeight || void 0, {
|
|
7597
7556
|
panelWidth: n?.width,
|
|
7598
7557
|
editorLeft: n?.left
|
|
7599
7558
|
});
|
|
7600
|
-
|
|
7601
|
-
}, [
|
|
7602
|
-
if (!
|
|
7559
|
+
re(r.placement), z(r.arrowLeft), I(r.style);
|
|
7560
|
+
}, [M, Y]), x(() => {
|
|
7561
|
+
if (!M || !Y) return;
|
|
7603
7562
|
let e = () => {
|
|
7604
|
-
let e =
|
|
7563
|
+
let e = Ae.current;
|
|
7605
7564
|
if (!e) return;
|
|
7606
|
-
let t =
|
|
7565
|
+
let t = B.current, n = De.current?.getBoundingClientRect(), r = ea(e, t?.offsetHeight || void 0, {
|
|
7607
7566
|
panelWidth: n?.width,
|
|
7608
7567
|
editorLeft: n?.left
|
|
7609
7568
|
});
|
|
7610
|
-
|
|
7569
|
+
re(r.placement), z(r.arrowLeft), I(r.style);
|
|
7611
7570
|
};
|
|
7612
7571
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
7613
|
-
}, [
|
|
7614
|
-
|
|
7615
|
-
}, [
|
|
7616
|
-
let
|
|
7617
|
-
Y
|
|
7618
|
-
}, [Y]),
|
|
7572
|
+
}, [M, Y]), x(() => {
|
|
7573
|
+
M || (Ae.current = null);
|
|
7574
|
+
}, [M]);
|
|
7575
|
+
let ft = b((e) => {
|
|
7576
|
+
Y && Un(Y.view, Y.schema.nodes.image.create({ src: e }));
|
|
7577
|
+
}, [Y]), pt = b((e) => {
|
|
7619
7578
|
(Y?.commands).insertVideo?.({ src: e });
|
|
7620
|
-
}, [Y]),
|
|
7579
|
+
}, [Y]), ht = q && Se && !J && !Be, gt = !ht && !ve && (q || it && !(!A && we)), _t = w(!1);
|
|
7621
7580
|
return x(() => {
|
|
7622
|
-
|
|
7623
|
-
}, [
|
|
7624
|
-
if (!
|
|
7581
|
+
_t.current || (_t.current = !0, q && !ht && ye(!0));
|
|
7582
|
+
}, [q, ht]), x(() => {
|
|
7583
|
+
if (!ve) return;
|
|
7625
7584
|
let e = (e) => {
|
|
7626
7585
|
let t = e.target;
|
|
7627
|
-
|
|
7586
|
+
He.current?.contains(t) || ye(!1);
|
|
7628
7587
|
}, t = (e) => {
|
|
7629
|
-
e.key === "Escape" &&
|
|
7588
|
+
e.key === "Escape" && ye(!1);
|
|
7630
7589
|
};
|
|
7631
7590
|
return document.addEventListener("mousedown", e), document.addEventListener("touchstart", e, { passive: !0 }), document.addEventListener("keydown", t), () => {
|
|
7632
7591
|
document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e), document.removeEventListener("keydown", t);
|
|
7633
7592
|
};
|
|
7634
|
-
}, [
|
|
7635
|
-
if (!Y || !
|
|
7636
|
-
let e =
|
|
7593
|
+
}, [ve]), x(() => {
|
|
7594
|
+
if (!Y || !ht) return;
|
|
7595
|
+
let e = Me.current;
|
|
7637
7596
|
if (!(e instanceof HTMLElement)) return;
|
|
7638
7597
|
let t = (t) => {
|
|
7639
7598
|
let n = t.deltaY;
|
|
@@ -7644,33 +7603,30 @@ var Qi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7644
7603
|
return;
|
|
7645
7604
|
}
|
|
7646
7605
|
let a = ut(Y), o = a ? lt(a) : null;
|
|
7647
|
-
|
|
7648
|
-
o.scrollTop += n, t.preventDefault(), t.stopPropagation();
|
|
7649
|
-
return;
|
|
7650
|
-
}
|
|
7606
|
+
o && (o.scrollTop += n, t.preventDefault(), t.stopPropagation());
|
|
7651
7607
|
};
|
|
7652
7608
|
return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
|
|
7653
|
-
}, [Y,
|
|
7609
|
+
}, [Y, ht]), Y ? /* @__PURE__ */ O("div", {
|
|
7654
7610
|
className: "qingwu-editor-row",
|
|
7655
7611
|
children: [/* @__PURE__ */ O("div", {
|
|
7656
|
-
ref:
|
|
7657
|
-
className: `qingwu-editor relative flex-1 min-w-0 bg-background ${
|
|
7658
|
-
style:
|
|
7612
|
+
ref: De,
|
|
7613
|
+
className: `qingwu-editor relative flex-1 min-w-0 bg-background ${A ? "qingwu-editor--readonly" : ""} ${u ? "" : "rounded-xl border border-default-200"} ${l}`,
|
|
7614
|
+
style: d,
|
|
7659
7615
|
children: [
|
|
7660
|
-
|
|
7616
|
+
m && /* @__PURE__ */ O("div", {
|
|
7661
7617
|
className: "qed-toolbar",
|
|
7662
7618
|
children: [/* @__PURE__ */ O("div", {
|
|
7663
7619
|
className: "qed-toolbar__group",
|
|
7664
7620
|
children: [
|
|
7665
7621
|
/* @__PURE__ */ D("button", {
|
|
7666
7622
|
type: "button",
|
|
7667
|
-
className: `qed-tb-btn qed-tb-btn--desktop-only${
|
|
7623
|
+
className: `qed-tb-btn qed-tb-btn--desktop-only${q ? " is-active" : ""}`,
|
|
7668
7624
|
onClick: () => {
|
|
7669
|
-
|
|
7625
|
+
q ? (_e(!1), ye(!1)) : (_e(!0), (!Se || J || Be) && ye(!0));
|
|
7670
7626
|
},
|
|
7671
|
-
title:
|
|
7672
|
-
"aria-label":
|
|
7673
|
-
"aria-pressed":
|
|
7627
|
+
title: q ? "隐藏目录" : "显示目录",
|
|
7628
|
+
"aria-label": q ? "隐藏目录" : "显示目录",
|
|
7629
|
+
"aria-pressed": q,
|
|
7674
7630
|
children: /* @__PURE__ */ D("svg", {
|
|
7675
7631
|
fill: "none",
|
|
7676
7632
|
viewBox: "0 0 24 24",
|
|
@@ -7684,13 +7640,13 @@ var Qi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7684
7640
|
})
|
|
7685
7641
|
})
|
|
7686
7642
|
}),
|
|
7687
|
-
|
|
7643
|
+
g && /* @__PURE__ */ D("button", {
|
|
7688
7644
|
type: "button",
|
|
7689
|
-
className: `qed-tb-btn${
|
|
7690
|
-
onClick: () =>
|
|
7645
|
+
className: `qed-tb-btn${be ? " is-active" : ""}`,
|
|
7646
|
+
onClick: () => xe(!be),
|
|
7691
7647
|
title: "查找 (Ctrl+F)",
|
|
7692
7648
|
"aria-label": "查找",
|
|
7693
|
-
"aria-pressed":
|
|
7649
|
+
"aria-pressed": be,
|
|
7694
7650
|
children: /* @__PURE__ */ D("svg", {
|
|
7695
7651
|
fill: "none",
|
|
7696
7652
|
viewBox: "0 0 24 24",
|
|
@@ -7704,13 +7660,13 @@ var Qi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7704
7660
|
})
|
|
7705
7661
|
})
|
|
7706
7662
|
}),
|
|
7707
|
-
!
|
|
7663
|
+
!A && /* @__PURE__ */ D("button", {
|
|
7708
7664
|
type: "button",
|
|
7709
|
-
className: `qed-tb-btn qed-tb-btn--ai${
|
|
7710
|
-
onClick: (e) =>
|
|
7711
|
-
title:
|
|
7712
|
-
"aria-label":
|
|
7713
|
-
"aria-pressed":
|
|
7665
|
+
className: `qed-tb-btn qed-tb-btn--ai${M ? " is-active" : ""}`,
|
|
7666
|
+
onClick: (e) => M ? P(!1) : dt(e.currentTarget),
|
|
7667
|
+
title: p("editor.toolbar.aiTitle"),
|
|
7668
|
+
"aria-label": p("editor.toolbar.ai"),
|
|
7669
|
+
"aria-pressed": M,
|
|
7714
7670
|
children: /* @__PURE__ */ O("svg", {
|
|
7715
7671
|
fill: "none",
|
|
7716
7672
|
viewBox: "0 0 24 24",
|
|
@@ -7736,7 +7692,7 @@ var Qi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7736
7692
|
type: "button",
|
|
7737
7693
|
className: "qed-tb-btn qed-tb-btn--solid",
|
|
7738
7694
|
onClick: () => ce(!0),
|
|
7739
|
-
title:
|
|
7695
|
+
title: p("editor.toolbar.exportTitle"),
|
|
7740
7696
|
children: [/* @__PURE__ */ D("svg", {
|
|
7741
7697
|
fill: "none",
|
|
7742
7698
|
viewBox: "0 0 24 24",
|
|
@@ -7750,13 +7706,13 @@ var Qi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7750
7706
|
})
|
|
7751
7707
|
}), /* @__PURE__ */ D("span", {
|
|
7752
7708
|
className: "qed-tb-btn__label",
|
|
7753
|
-
children:
|
|
7709
|
+
children: p("editor.toolbar.export")
|
|
7754
7710
|
})]
|
|
7755
7711
|
}),
|
|
7756
7712
|
/* @__PURE__ */ D("button", {
|
|
7757
7713
|
type: "button",
|
|
7758
7714
|
className: `qed-tb-btn${J ? " is-active" : ""}`,
|
|
7759
|
-
onClick:
|
|
7715
|
+
onClick: Ue,
|
|
7760
7716
|
title: J ? "退出网页全屏" : "网页全屏",
|
|
7761
7717
|
"aria-label": J ? "退出网页全屏" : "网页全屏",
|
|
7762
7718
|
"aria-pressed": J,
|
|
@@ -7775,11 +7731,11 @@ var Qi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7775
7731
|
}),
|
|
7776
7732
|
/* @__PURE__ */ D("button", {
|
|
7777
7733
|
type: "button",
|
|
7778
|
-
className: `qed-tb-btn${
|
|
7779
|
-
onClick:
|
|
7780
|
-
title:
|
|
7781
|
-
"aria-label":
|
|
7782
|
-
"aria-pressed":
|
|
7734
|
+
className: `qed-tb-btn${Be ? " is-active" : ""}`,
|
|
7735
|
+
onClick: We,
|
|
7736
|
+
title: Be ? "退出全屏" : "全屏",
|
|
7737
|
+
"aria-label": Be ? "退出全屏" : "全屏",
|
|
7738
|
+
"aria-pressed": Be,
|
|
7783
7739
|
children: /* @__PURE__ */ D("svg", {
|
|
7784
7740
|
fill: "none",
|
|
7785
7741
|
viewBox: "0 0 24 24",
|
|
@@ -7796,143 +7752,158 @@ var Qi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7796
7752
|
]
|
|
7797
7753
|
})]
|
|
7798
7754
|
}),
|
|
7799
|
-
Y && !
|
|
7755
|
+
Y && !A && Y.isEditable && /* @__PURE__ */ D(ne, {
|
|
7800
7756
|
editor: Y,
|
|
7801
7757
|
shouldShow: ({ editor: e, state: t }) => !(e.isActive("image") || e.isActive("videoEmbed") || e.isActive("codeBlock") || e.isActive("audioEmbed") || e.isActive("attachmentEmbed") || t.selection.empty),
|
|
7802
7758
|
options: {
|
|
7803
7759
|
placement: "bottom",
|
|
7804
7760
|
offset: 8,
|
|
7805
|
-
flip:
|
|
7761
|
+
flip: { padding: 8 },
|
|
7762
|
+
shift: { padding: 8 },
|
|
7763
|
+
size: {
|
|
7764
|
+
padding: 8,
|
|
7765
|
+
apply: ({ availableWidth: e, elements: t }) => {
|
|
7766
|
+
t.floating.style.maxWidth = `${e}px`;
|
|
7767
|
+
}
|
|
7768
|
+
},
|
|
7769
|
+
onUpdate: X
|
|
7806
7770
|
},
|
|
7807
|
-
className: "bubble-menu-pop
|
|
7771
|
+
className: "qw-bubble bubble-menu-pop",
|
|
7808
7772
|
children: /* @__PURE__ */ O("div", {
|
|
7809
|
-
ref:
|
|
7810
|
-
className: "bubble-menu-items
|
|
7773
|
+
ref: Ne,
|
|
7774
|
+
className: "bubble-menu-items",
|
|
7811
7775
|
onPointerDown: (e) => {
|
|
7812
7776
|
e.target.closest("button") && e.preventDefault();
|
|
7813
7777
|
},
|
|
7814
7778
|
children: [
|
|
7815
|
-
|
|
7779
|
+
Ze.map((e) => /* @__PURE__ */ D("button", {
|
|
7816
7780
|
type: "button",
|
|
7817
|
-
className:
|
|
7781
|
+
className: "qw-bubble-button",
|
|
7782
|
+
"data-active": e.isActive(Y),
|
|
7783
|
+
"aria-pressed": e.isActive(Y),
|
|
7818
7784
|
onClick: (t) => {
|
|
7819
|
-
t.preventDefault(),
|
|
7785
|
+
t.preventDefault(), $e(e);
|
|
7820
7786
|
},
|
|
7821
7787
|
title: e.label,
|
|
7822
7788
|
"aria-label": e.label,
|
|
7823
7789
|
children: e.icon
|
|
7824
7790
|
}, e.key)),
|
|
7825
7791
|
/* @__PURE__ */ D("span", {
|
|
7826
|
-
className: "
|
|
7792
|
+
className: "qw-bubble-divider",
|
|
7827
7793
|
"aria-hidden": "true"
|
|
7828
7794
|
}),
|
|
7829
7795
|
/* @__PURE__ */ D("button", {
|
|
7830
7796
|
type: "button",
|
|
7831
|
-
className:
|
|
7797
|
+
className: "qw-bubble-button qw-bubble-button--ai",
|
|
7798
|
+
"data-active": M,
|
|
7832
7799
|
onClick: (e) => {
|
|
7833
|
-
e.preventDefault(),
|
|
7800
|
+
e.preventDefault(), Ie(!1), Qe?.command(Y);
|
|
7834
7801
|
},
|
|
7835
|
-
title:
|
|
7836
|
-
"aria-label":
|
|
7802
|
+
title: Qe?.label,
|
|
7803
|
+
"aria-label": Qe?.label,
|
|
7837
7804
|
children: /* @__PURE__ */ D(Ut, {})
|
|
7838
7805
|
}),
|
|
7839
7806
|
/* @__PURE__ */ D("span", {
|
|
7840
|
-
className: "
|
|
7807
|
+
className: "qw-bubble-divider",
|
|
7841
7808
|
"aria-hidden": "true"
|
|
7842
7809
|
}),
|
|
7843
7810
|
/* @__PURE__ */ D("button", {
|
|
7844
7811
|
type: "button",
|
|
7845
|
-
"aria-expanded":
|
|
7846
|
-
|
|
7812
|
+
"aria-expanded": Fe,
|
|
7813
|
+
"aria-haspopup": "menu",
|
|
7814
|
+
className: "qw-bubble-button",
|
|
7815
|
+
"data-active": Fe,
|
|
7847
7816
|
onClick: (e) => {
|
|
7848
|
-
e.preventDefault(),
|
|
7817
|
+
e.preventDefault(), Ie((e) => !e);
|
|
7849
7818
|
},
|
|
7850
|
-
title:
|
|
7851
|
-
"aria-label":
|
|
7819
|
+
title: p("editor.bubble.more"),
|
|
7820
|
+
"aria-label": p("editor.bubble.more"),
|
|
7852
7821
|
children: /* @__PURE__ */ D(Gt, {})
|
|
7853
7822
|
}),
|
|
7854
|
-
|
|
7823
|
+
Fe && /* @__PURE__ */ D("div", {
|
|
7824
|
+
ref: Pe,
|
|
7855
7825
|
role: "menu",
|
|
7856
|
-
className: "bubble-more-menu
|
|
7826
|
+
className: "bubble-more-menu",
|
|
7857
7827
|
onPointerDown: (e) => {
|
|
7858
7828
|
e.target.closest("button") && e.preventDefault();
|
|
7859
7829
|
},
|
|
7860
|
-
children:
|
|
7830
|
+
children: Xe.map((e) => /* @__PURE__ */ O("button", {
|
|
7861
7831
|
type: "button",
|
|
7862
7832
|
role: "menuitem",
|
|
7863
|
-
className:
|
|
7833
|
+
className: "qw-bubble-menu-item",
|
|
7834
|
+
"data-active": et(e),
|
|
7864
7835
|
onClick: (t) => {
|
|
7865
|
-
t.preventDefault(),
|
|
7836
|
+
t.preventDefault(), $e(e);
|
|
7866
7837
|
},
|
|
7867
7838
|
title: e.label,
|
|
7868
7839
|
children: [/* @__PURE__ */ D("span", {
|
|
7869
|
-
className: "
|
|
7840
|
+
className: "qw-bubble-menu-icon",
|
|
7870
7841
|
children: e.icon
|
|
7871
|
-
}), /* @__PURE__ */ D("span", {
|
|
7872
|
-
className: "tracking-wide",
|
|
7873
|
-
children: e.label
|
|
7874
|
-
})]
|
|
7842
|
+
}), /* @__PURE__ */ D("span", { children: e.label })]
|
|
7875
7843
|
}, e.key))
|
|
7876
7844
|
})
|
|
7877
7845
|
]
|
|
7878
7846
|
})
|
|
7879
7847
|
}),
|
|
7880
|
-
Y &&
|
|
7848
|
+
Y && G !== "none" && L(/* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
7881
7849
|
className: "fixed inset-0 z-[9998]",
|
|
7882
|
-
onClick: () =>
|
|
7850
|
+
onClick: () => K("none")
|
|
7883
7851
|
}), /* @__PURE__ */ D("div", {
|
|
7884
|
-
ref:
|
|
7852
|
+
ref: de,
|
|
7885
7853
|
style: le,
|
|
7886
|
-
className: "
|
|
7854
|
+
className: "qw-bubble-panel",
|
|
7887
7855
|
onClick: (e) => e.stopPropagation(),
|
|
7888
|
-
children:
|
|
7889
|
-
className: "
|
|
7890
|
-
children: [
|
|
7856
|
+
children: G === "highlight" ? /* @__PURE__ */ O("div", {
|
|
7857
|
+
className: "qw-bubble-colors",
|
|
7858
|
+
children: [Xi.map((e) => /* @__PURE__ */ D("button", {
|
|
7891
7859
|
type: "button",
|
|
7892
|
-
className: "
|
|
7860
|
+
className: "qw-bubble-swatch",
|
|
7893
7861
|
style: { background: e.color },
|
|
7894
7862
|
title: e.name,
|
|
7863
|
+
"aria-label": e.name,
|
|
7895
7864
|
onClick: () => {
|
|
7896
|
-
Y.chain().focus().setHighlight({ color: e.color }).run(),
|
|
7865
|
+
Y.chain().focus().setHighlight({ color: e.color }).run(), K("none");
|
|
7897
7866
|
}
|
|
7898
7867
|
}, e.color)), /* @__PURE__ */ O("button", {
|
|
7899
7868
|
type: "button",
|
|
7900
|
-
className: "
|
|
7869
|
+
className: "qw-bubble-swatch qw-bubble-clear",
|
|
7901
7870
|
title: "清除高亮",
|
|
7871
|
+
"aria-label": "清除高亮",
|
|
7902
7872
|
onClick: () => {
|
|
7903
|
-
Y.chain().focus().unsetHighlight().run(),
|
|
7873
|
+
Y.chain().focus().unsetHighlight().run(), K("none");
|
|
7904
7874
|
},
|
|
7905
7875
|
children: ["✕", " "]
|
|
7906
7876
|
})]
|
|
7907
7877
|
}) : /* @__PURE__ */ O("div", {
|
|
7908
|
-
className: "
|
|
7878
|
+
className: "qw-bubble-link",
|
|
7909
7879
|
children: [/* @__PURE__ */ D("input", {
|
|
7910
7880
|
type: "url",
|
|
7911
|
-
className: "
|
|
7881
|
+
className: "qw-bubble-link-input",
|
|
7912
7882
|
placeholder: "https://...",
|
|
7913
|
-
|
|
7914
|
-
|
|
7883
|
+
"aria-label": "链接地址",
|
|
7884
|
+
value: pe,
|
|
7885
|
+
onChange: (e) => me(e.target.value),
|
|
7915
7886
|
onKeyDown: (e) => {
|
|
7916
|
-
e.key === "Enter" ? (
|
|
7887
|
+
e.key === "Enter" ? (pe.trim() && Y.chain().focus().setLink({ href: pe.trim() }).run(), K("none")) : e.key === "Escape" && K("none");
|
|
7917
7888
|
}
|
|
7918
7889
|
}), /* @__PURE__ */ D("button", {
|
|
7919
7890
|
type: "button",
|
|
7920
|
-
className: "
|
|
7891
|
+
className: "qw-bubble-link-apply",
|
|
7921
7892
|
onClick: () => {
|
|
7922
|
-
|
|
7893
|
+
pe.trim() && Y.chain().focus().setLink({ href: pe.trim() }).run(), K("none");
|
|
7923
7894
|
},
|
|
7924
7895
|
children: "确定"
|
|
7925
7896
|
})]
|
|
7926
7897
|
})
|
|
7927
7898
|
})] }), document.body),
|
|
7928
|
-
!
|
|
7899
|
+
!A && M && L(/* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
|
|
7929
7900
|
className: "fixed inset-0 z-[9998]",
|
|
7930
|
-
onClick: () =>
|
|
7901
|
+
onClick: () => P(!1)
|
|
7931
7902
|
}), /* @__PURE__ */ O("div", {
|
|
7932
|
-
ref:
|
|
7903
|
+
ref: B,
|
|
7933
7904
|
"data-lenis-prevent": !0,
|
|
7934
|
-
style:
|
|
7935
|
-
className: `ai-panel relative flex flex-col bg-background border border-default-200 rounded-xl shadow-xl${
|
|
7905
|
+
style: F,
|
|
7906
|
+
className: `ai-panel relative flex flex-col bg-background border border-default-200 rounded-xl shadow-xl${R === "above" ? " ai-panel--above" : ""}`,
|
|
7936
7907
|
onClick: (e) => e.stopPropagation(),
|
|
7937
7908
|
children: [/* @__PURE__ */ D("span", {
|
|
7938
7909
|
className: "ai-panel__arrow",
|
|
@@ -7940,90 +7911,86 @@ var Qi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
7940
7911
|
"aria-hidden": "true"
|
|
7941
7912
|
}), /* @__PURE__ */ D(un, {
|
|
7942
7913
|
editor: Y,
|
|
7943
|
-
onClose: () =>
|
|
7914
|
+
onClose: () => P(!1)
|
|
7944
7915
|
})]
|
|
7945
7916
|
})] }), document.body),
|
|
7946
|
-
|
|
7947
|
-
fallback: /* @__PURE__ */ D(
|
|
7948
|
-
children: /* @__PURE__ */ D(
|
|
7949
|
-
open:
|
|
7950
|
-
onClose: () =>
|
|
7951
|
-
onInsert:
|
|
7917
|
+
V && /* @__PURE__ */ D(v, {
|
|
7918
|
+
fallback: /* @__PURE__ */ D(ca, {}),
|
|
7919
|
+
children: /* @__PURE__ */ D(ra, {
|
|
7920
|
+
open: V,
|
|
7921
|
+
onClose: () => H(!1),
|
|
7922
|
+
onInsert: ft,
|
|
7952
7923
|
validate: (e) => Y ? hn(Y.state.doc, e, {
|
|
7953
|
-
maxAttachmentSize:
|
|
7954
|
-
maxTotalAttachmentSize:
|
|
7924
|
+
maxAttachmentSize: s,
|
|
7925
|
+
maxTotalAttachmentSize: c
|
|
7955
7926
|
}) : null
|
|
7956
7927
|
})
|
|
7957
7928
|
}),
|
|
7958
|
-
|
|
7959
|
-
fallback: /* @__PURE__ */ D(
|
|
7960
|
-
children: /* @__PURE__ */ D(
|
|
7961
|
-
open:
|
|
7929
|
+
ae && /* @__PURE__ */ D(v, {
|
|
7930
|
+
fallback: /* @__PURE__ */ D(ca, {}),
|
|
7931
|
+
children: /* @__PURE__ */ D(oa, {
|
|
7932
|
+
open: ae,
|
|
7962
7933
|
onClose: () => oe(!1),
|
|
7963
|
-
onInsert:
|
|
7964
|
-
})
|
|
7965
|
-
}),
|
|
7966
|
-
se && /* @__PURE__ */ D(v, {
|
|
7967
|
-
fallback: /* @__PURE__ */ D(ra, {}),
|
|
7968
|
-
children: /* @__PURE__ */ D($i, {
|
|
7969
|
-
open: se,
|
|
7970
|
-
onClose: () => H(!1)
|
|
7934
|
+
onInsert: pt
|
|
7971
7935
|
})
|
|
7972
7936
|
}),
|
|
7973
7937
|
U && /* @__PURE__ */ D(v, {
|
|
7974
|
-
fallback: /* @__PURE__ */ D(
|
|
7975
|
-
children: /* @__PURE__ */ D(
|
|
7938
|
+
fallback: /* @__PURE__ */ D(ca, {}),
|
|
7939
|
+
children: /* @__PURE__ */ D(ia, {
|
|
7976
7940
|
open: U,
|
|
7941
|
+
onClose: () => W(!1)
|
|
7942
|
+
})
|
|
7943
|
+
}),
|
|
7944
|
+
se && /* @__PURE__ */ D(v, {
|
|
7945
|
+
fallback: /* @__PURE__ */ D(ca, {}),
|
|
7946
|
+
children: /* @__PURE__ */ D(aa, {
|
|
7947
|
+
open: se,
|
|
7977
7948
|
onClose: () => ce(!1),
|
|
7978
7949
|
editor: Y
|
|
7979
7950
|
})
|
|
7980
7951
|
}),
|
|
7981
|
-
|
|
7982
|
-
fallback: /* @__PURE__ */ D(
|
|
7983
|
-
children: /* @__PURE__ */ D(
|
|
7984
|
-
open: !!
|
|
7985
|
-
filename:
|
|
7952
|
+
he && /* @__PURE__ */ D(v, {
|
|
7953
|
+
fallback: /* @__PURE__ */ D(ca, {}),
|
|
7954
|
+
children: /* @__PURE__ */ D(sa, {
|
|
7955
|
+
open: !!he,
|
|
7956
|
+
filename: he.filename,
|
|
7986
7957
|
onRender: () => {
|
|
7987
|
-
|
|
7958
|
+
he.resolve("render"), ge(null);
|
|
7988
7959
|
},
|
|
7989
7960
|
onAttach: () => {
|
|
7990
|
-
|
|
7961
|
+
he.resolve("attach"), ge(null);
|
|
7991
7962
|
},
|
|
7992
7963
|
onClose: () => {
|
|
7993
|
-
|
|
7964
|
+
he.resolve(null), ge(null);
|
|
7994
7965
|
}
|
|
7995
7966
|
})
|
|
7996
7967
|
}),
|
|
7997
7968
|
/* @__PURE__ */ D("div", {
|
|
7998
|
-
ref:
|
|
7969
|
+
ref: Oe,
|
|
7999
7970
|
className: "flex editor-body",
|
|
8000
7971
|
children: /* @__PURE__ */ O("div", {
|
|
8001
7972
|
className: "relative min-w-0 flex-1",
|
|
8002
7973
|
children: [
|
|
8003
7974
|
/* @__PURE__ */ D(ee, { editor: Y }),
|
|
8004
|
-
!
|
|
7975
|
+
!A && /* @__PURE__ */ D(Yi, { editor: Y }),
|
|
8005
7976
|
/* @__PURE__ */ D("div", {
|
|
8006
|
-
className: `${J ||
|
|
7977
|
+
className: `${J || Be ? "fixed" : "absolute"} bottom-2 right-4 z-10 pointer-events-none select-none`,
|
|
8007
7978
|
children: /* @__PURE__ */ O("span", {
|
|
8008
|
-
className: `text-xs ${
|
|
8009
|
-
children: [
|
|
8010
|
-
rt,
|
|
8011
|
-
a ? ` / ${a}` : "",
|
|
8012
|
-
" 字"
|
|
8013
|
-
]
|
|
7979
|
+
className: `text-xs ${st ? "bg-danger/10 text-danger font-medium px-2 py-0.5 rounded" : a && ot > a * .9 ? "bg-warning/10 text-warning px-2 py-0.5 rounded" : "text-default-300"}`,
|
|
7980
|
+
children: [ct === null ? `${ot} 字符` : `${ct} 字`, a ? `(${ot} / ${a} 字符)` : ""]
|
|
8014
7981
|
})
|
|
8015
7982
|
})
|
|
8016
7983
|
]
|
|
8017
7984
|
})
|
|
8018
7985
|
}),
|
|
8019
|
-
|
|
7986
|
+
g && be && /* @__PURE__ */ D(Mt, {
|
|
8020
7987
|
editor: Y,
|
|
8021
|
-
onClose: () =>
|
|
7988
|
+
onClose: () => xe(!1)
|
|
8022
7989
|
}),
|
|
8023
|
-
|
|
7990
|
+
gt && /* @__PURE__ */ D("button", {
|
|
8024
7991
|
type: "button",
|
|
8025
7992
|
className: "qingwu-toc-fab",
|
|
8026
|
-
onClick: () =>
|
|
7993
|
+
onClick: () => ye(!0),
|
|
8027
7994
|
title: "目录",
|
|
8028
7995
|
"aria-label": "打开目录",
|
|
8029
7996
|
children: /* @__PURE__ */ D("svg", {
|
|
@@ -8039,8 +8006,8 @@ var Qi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
8039
8006
|
})
|
|
8040
8007
|
})
|
|
8041
8008
|
}),
|
|
8042
|
-
|
|
8043
|
-
ref:
|
|
8009
|
+
ve && L(/* @__PURE__ */ O("div", {
|
|
8010
|
+
ref: He,
|
|
8044
8011
|
className: "qingwu-toc-drawer toc-scroll",
|
|
8045
8012
|
"data-lenis-prevent": !0,
|
|
8046
8013
|
children: [/* @__PURE__ */ O("div", {
|
|
@@ -8051,7 +8018,7 @@ var Qi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
8051
8018
|
}), /* @__PURE__ */ D("button", {
|
|
8052
8019
|
type: "button",
|
|
8053
8020
|
className: "qed-drawer-head__close",
|
|
8054
|
-
onClick: () =>
|
|
8021
|
+
onClick: () => ye(!1),
|
|
8055
8022
|
"aria-label": "关闭目录",
|
|
8056
8023
|
children: /* @__PURE__ */ D("svg", {
|
|
8057
8024
|
fill: "none",
|
|
@@ -8070,68 +8037,62 @@ var Qi = y(() => Promise.resolve().then(() => nt).then((e) => ({ default: e.Imag
|
|
|
8070
8037
|
editor: Y,
|
|
8071
8038
|
className: "!p-3",
|
|
8072
8039
|
onClose: () => {
|
|
8073
|
-
|
|
8040
|
+
ye(!1), _e(!1);
|
|
8074
8041
|
}
|
|
8075
8042
|
})]
|
|
8076
8043
|
}), document.body)
|
|
8077
8044
|
]
|
|
8078
|
-
}),
|
|
8079
|
-
ref:
|
|
8045
|
+
}), ht && L(/* @__PURE__ */ D("aside", {
|
|
8046
|
+
ref: Me,
|
|
8080
8047
|
className: "qingwu-toc-desktop toc-scroll",
|
|
8081
8048
|
children: /* @__PURE__ */ D(mt, {
|
|
8082
8049
|
editor: Y,
|
|
8083
|
-
onClose: () =>
|
|
8050
|
+
onClose: () => _e(!1)
|
|
8084
8051
|
})
|
|
8085
8052
|
}), document.body)]
|
|
8086
8053
|
}) : /* @__PURE__ */ D("div", {
|
|
8087
8054
|
className: "flex items-center justify-center h-32 text-default-400",
|
|
8088
|
-
children:
|
|
8055
|
+
children: p("editor.loading")
|
|
8089
8056
|
});
|
|
8090
8057
|
};
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
function aa(e) {
|
|
8058
|
+
// src/editor/clipper/receiver-browser.ts
|
|
8059
|
+
function ua(e) {
|
|
8094
8060
|
let t = async (t) => {
|
|
8095
8061
|
let n = t.data;
|
|
8096
|
-
if (!n || typeof n != "object" || n.kind !== "qingwu-clip") return;
|
|
8097
|
-
let r =
|
|
8098
|
-
if (
|
|
8099
|
-
|
|
8100
|
-
if (i?.markdown) try {
|
|
8101
|
-
await e.onClip(i, t);
|
|
8062
|
+
if (!n || typeof n != "object" || n.kind !== "qingwu-clip" || t.origin !== window.location.origin || t.origin === "null" || t.source !== window) return;
|
|
8063
|
+
let r = n.clip;
|
|
8064
|
+
if (typeof r?.markdown == "string" && r.markdown.trim()) try {
|
|
8065
|
+
await e.onClip(r, t);
|
|
8102
8066
|
} catch (e) {
|
|
8103
8067
|
console.warn("[qingwu-clipper] 处理剪藏失败:", e);
|
|
8104
8068
|
}
|
|
8105
8069
|
};
|
|
8106
8070
|
return window.addEventListener("message", t), { close: () => window.removeEventListener("message", t) };
|
|
8107
8071
|
}
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
nameTemplate: e.nameTemplate
|
|
8072
|
+
// src/editor/storage/providers/cos.ts
|
|
8073
|
+
function da(t) {
|
|
8074
|
+
return e({
|
|
8075
|
+
endpoint: `https://cos.${t.region}.myqcloud.com`,
|
|
8076
|
+
bucket: t.bucket,
|
|
8077
|
+
region: t.region,
|
|
8078
|
+
accessKeyId: t.secretId,
|
|
8079
|
+
secretAccessKey: t.secretKey,
|
|
8080
|
+
customDomain: t.customDomain,
|
|
8081
|
+
uploadPrefix: t.uploadPrefix,
|
|
8082
|
+
nameTemplate: t.nameTemplate
|
|
8120
8083
|
});
|
|
8121
8084
|
}
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
nameTemplate: e.nameTemplate
|
|
8085
|
+
// src/editor/storage/providers/oss.ts
|
|
8086
|
+
function fa(t) {
|
|
8087
|
+
return e({
|
|
8088
|
+
endpoint: `https://${t.bucket}.${t.region}.aliyuncs.com`,
|
|
8089
|
+
bucket: t.bucket,
|
|
8090
|
+
region: t.region,
|
|
8091
|
+
accessKeyId: t.accessKeyId,
|
|
8092
|
+
secretAccessKey: t.accessKeySecret,
|
|
8093
|
+
customDomain: t.customDomain,
|
|
8094
|
+
uploadPrefix: t.uploadPrefix,
|
|
8095
|
+
nameTemplate: t.nameTemplate
|
|
8134
8096
|
});
|
|
8135
8097
|
}
|
|
8136
|
-
|
|
8137
|
-
export { cr as CODE_LANGUAGES, mr as CodeBlock, Rr as ImageUpload, rt as ImageUploadDialog, ni as MathBlock, ti as MathInline, ia as QingWuAIEditor, Di as RelativeMedia, At as SearchHighlight, mt as TocPanel, Zn as VideoEmbed, ht as buildSystemPrompt, _t as createAILanguageModelProvider, oa as createCOSStorage, xt as createDeepSeekProvider, _ as createLocalStorage, sa as createOSSStorage, bt as createOpenAICompatProvider, St as createOpenAIProvider, Ct as createQwenProvider, g as createS3Storage, ki as createSlashCommandExtension, h as escapeHtml, pn as formatBytes, yt as getAIProvider, Ri as getBubbleMenuActions, Ai as getDefaultSlashCommands, fn as getDocAttachmentTotal, Mi as getEditorExtensions, u as getLocale, Li as getSearchEngine, jt as getSearchState, c as getStorageInfo, o as getStorageProvider, s as loadStorageConfig, r as registerS3PreviewConfig, d as sanitizeHtml, p as sanitizeSvg, vt as setAIProvider, xn as setConfirmProvider, l as setLocale, Ii as setSearchEngine, i as setStorageProvider, et as setToastProvider, n as signPreviewUrlHeaders, aa as startBrowserClipperReceiver, tt as subscribeToast, f as t, m as tf, Z as toast, hn as validateAttachmentFile };
|
|
8098
|
+
export { fr as CODE_LANGUAGES, vr as CodeBlock, Hr as ImageUpload, rt as ImageUploadDialog, si as MathBlock, oi as MathInline, la as QingWuAIEditor, Mi as RelativeMedia, At as SearchHighlight, mt as TocPanel, $n as VideoEmbed, ht as buildSystemPrompt, _t as createAILanguageModelProvider, da as createCOSStorage, xt as createDeepSeekProvider, _ as createLocalStorage, fa as createOSSStorage, bt as createOpenAICompatProvider, St as createOpenAIProvider, Ct as createQwenProvider, e as createS3Storage, Pi as createSlashCommandExtension, g as escapeHtml, pn as formatBytes, yt as getAIProvider, Ui as getBubbleMenuActions, Fi as getDefaultSlashCommands, fn as getDocAttachmentTotal, Li as getEditorExtensions, d as getLocale, Hi as getSearchEngine, jt as getSearchState, l as getStorageInfo, s as getStorageProvider, c as loadStorageConfig, i as registerS3PreviewConfig, f as sanitizeHtml, m as sanitizeSvg, vt as setAIProvider, xn as setConfirmProvider, u as setLocale, Vi as setSearchEngine, a as setStorageProvider, et as setToastProvider, n as signPreviewUrlHeaders, ua as startBrowserClipperReceiver, tt as subscribeToast, p as t, h as tf, Z as toast, hn as validateAttachmentFile };
|