@qingwu-ui/ai-editor 0.9.0-beta.14 → 0.9.0-beta.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -6,59 +6,59 @@ import { Suspense as v, lazy as y, useCallback as b, useEffect as x, useLayoutEf
6
6
  import { Fragment as E, jsx as D, jsxs as O } from "react/jsx-runtime";
7
7
  import { generateText as k, streamText as A } from "ai";
8
8
  import { DOMParser as j, Fragment as M, Slice as N } from "@tiptap/pm/model";
9
- import { EditorContent as P, NodeViewContent as F, NodeViewWrapper as I, ReactNodeViewRenderer as L, useEditor as ee } from "@tiptap/react";
9
+ import { EditorContent as P, NodeViewWrapper as F, ReactNodeViewRenderer as I, ReactRenderer as L, useEditor as ee } from "@tiptap/react";
10
10
  import { BubbleMenu as te } from "@tiptap/react/menus";
11
11
  import { createPortal as ne } from "react-dom";
12
12
  import { Extension as R, Node as re } from "@tiptap/core";
13
- import { NodeSelection as ie, Plugin as z, PluginKey as B, TextSelection as ae } from "@tiptap/pm/state";
14
- import { Decoration as oe, DecorationSet as se } from "@tiptap/pm/view";
15
- import { Image as ce } from "@tiptap/extension-image";
16
- import { Link as V } from "@tiptap/extension-link";
17
- import { Underline as H } from "@tiptap/extension-underline";
18
- import le from "@tiptap/starter-kit";
19
- import { CharacterCount as U } from "@tiptap/extension-character-count";
20
- import { Color as W } from "@tiptap/extension-color";
21
- import { Highlight as ue } from "@tiptap/extension-highlight";
22
- import { HorizontalRule as de } from "@tiptap/extension-horizontal-rule";
23
- import { Placeholder as G } from "@tiptap/extension-placeholder";
24
- import { Table as fe } from "@tiptap/extension-table";
25
- import { TableCell as pe } from "@tiptap/extension-table-cell";
26
- import { TableHeader as me } from "@tiptap/extension-table-header";
27
- import { TableRow as K } from "@tiptap/extension-table-row";
28
- import { TaskItem as he } from "@tiptap/extension-task-item";
29
- import { TaskList as ge } from "@tiptap/extension-task-list";
30
- import { TextStyle as _e } from "@tiptap/extension-text-style";
31
- import { Markdown as ve } from "tiptap-markdown";
32
- import { CodeBlockLowlight as ye } from "@tiptap/extension-code-block-lowlight";
33
- import be from "highlight.js/lib/languages/dockerfile";
34
- import { common as xe, createLowlight as Se } from "lowlight";
35
- import Ce, { findSuggestionMatch as we } from "@tiptap/suggestion";
13
+ import { NodeSelection as ie, Plugin as z, PluginKey as B, TextSelection as V } from "@tiptap/pm/state";
14
+ import { Decoration as H, DecorationSet as ae } from "@tiptap/pm/view";
15
+ import { Image as oe } from "@tiptap/extension-image";
16
+ import { Link as U } from "@tiptap/extension-link";
17
+ import { Underline as W } from "@tiptap/extension-underline";
18
+ import G from "@tiptap/starter-kit";
19
+ import { CharacterCount as K } from "@tiptap/extension-character-count";
20
+ import { Color as q } from "@tiptap/extension-color";
21
+ import { Highlight as se } from "@tiptap/extension-highlight";
22
+ import { HorizontalRule as ce } from "@tiptap/extension-horizontal-rule";
23
+ import { Placeholder as J } from "@tiptap/extension-placeholder";
24
+ import { Table as le } from "@tiptap/extension-table";
25
+ import { TableCell as ue } from "@tiptap/extension-table-cell";
26
+ import { TableHeader as de } from "@tiptap/extension-table-header";
27
+ import { TableRow as fe } from "@tiptap/extension-table-row";
28
+ import { TaskItem as pe } from "@tiptap/extension-task-item";
29
+ import { TaskList as me } from "@tiptap/extension-task-list";
30
+ import { TextStyle as he } from "@tiptap/extension-text-style";
31
+ import { Markdown as ge } from "tiptap-markdown";
32
+ import { CodeBlockLowlight as _e } from "@tiptap/extension-code-block-lowlight";
33
+ import ve from "highlight.js/lib/languages/dockerfile";
34
+ import { common as ye, createLowlight as be } from "lowlight";
35
+ import xe, { exitSuggestion as Se, findSuggestionMatch as Ce } from "@tiptap/suggestion";
36
36
  //#region ../text-layout/dist/index.mjs
37
- var Te = null, Ee = null;
38
- function De() {
39
- return Ee || (typeof document > "u" ? null : (Te = document.createElement("canvas"), Ee = Te.getContext("2d"), Ee));
40
- }
41
- var Oe = /* @__PURE__ */ new Map();
42
- function ke(e, t) {
43
- let n = Oe.get(t);
44
- n || (n = /* @__PURE__ */ new Map(), Oe.set(t, n));
37
+ var we = null, Te = null;
38
+ function Ee() {
39
+ return Te || (typeof document > "u" ? null : (we = document.createElement("canvas"), Te = we.getContext("2d"), Te));
40
+ }
41
+ var De = /* @__PURE__ */ new Map();
42
+ function Oe(e, t) {
43
+ let n = De.get(t);
44
+ n || (n = /* @__PURE__ */ new Map(), De.set(t, n));
45
45
  let r = n.get(e);
46
46
  if (r !== void 0) return r;
47
- let i = De();
48
- return i ? (i.font = t, r = i.measureText(e).width) : r = Ae(e, t), n.set(e, r), r;
47
+ let i = Ee();
48
+ return i ? (i.font = t, r = i.measureText(e).width) : r = ke(e, t), n.set(e, r), r;
49
49
  }
50
- function Ae(e, t) {
50
+ function ke(e, t) {
51
51
  let n = parseFloat(t) || 16, r = 0;
52
- for (let t of e) je(t.codePointAt(0) ?? 0) ? r += n : t === " " ? r += n * .3 : r += n * .55;
52
+ for (let t of e) Ae(t.codePointAt(0) ?? 0) ? r += n : t === " " ? r += n * .3 : r += n * .55;
53
53
  return r;
54
54
  }
55
- function je(e) {
55
+ function Ae(e) {
56
56
  return e >= 19968 && e <= 40959 || e >= 13312 && e <= 19903 || e >= 131072 && e <= 173791 || e >= 63744 && e <= 64255 || e >= 194560 && e <= 195103 || e >= 12288 && e <= 12351 || e >= 65280 && e <= 65519 || e >= 11904 && e <= 12031 || e >= 12736 && e <= 12783 || e >= 44032 && e <= 55215;
57
57
  }
58
- function Me(e) {
58
+ function Y(e) {
59
59
  return e === 12289 || e === 12290 || e === 65292 || e === 65294 || e === 65306 || e === 65307 || e === 65311 || e === 65281 || e === 65289 || e === 65341 || e === 12301 || e === 12303 || e === 12299 || e === 12305;
60
60
  }
61
- function q(e, t) {
61
+ function je(e, t) {
62
62
  let n = [], r = [];
63
63
  if (typeof Intl < "u" && Intl.Segmenter) try {
64
64
  let t = new Intl.Segmenter("zh", { granularity: "grapheme" });
@@ -69,27 +69,27 @@ function q(e, t) {
69
69
  else r = [...e];
70
70
  for (let e of r) {
71
71
  let r = e.codePointAt(0) ?? 0, i = "latin";
72
- e === "\n" ? i = "break" : e === " " || e === " " ? i = "space" : je(r) && (i = Me(r) ? "punct" : "cjk"), n.push({
72
+ e === "\n" ? i = "break" : e === " " || e === " " ? i = "space" : Ae(r) && (i = Y(r) ? "punct" : "cjk"), n.push({
73
73
  text: e,
74
- width: ke(e, t),
74
+ width: Oe(e, t),
75
75
  type: i
76
76
  });
77
77
  }
78
78
  return n;
79
79
  }
80
- function Ne(e, t, n) {
80
+ function Me(e, t, n) {
81
81
  let r = 0, i = Math.min(n, e.length);
82
82
  for (let n = t; n < i; n++) r += e[n].width;
83
83
  return r;
84
84
  }
85
- function J(e, t, n, r) {
85
+ function Ne(e, t, n, r) {
86
86
  return {
87
87
  text: e.slice(t, Math.min(n, e.length)).map((e) => e.text).join(""),
88
88
  width: r
89
89
  };
90
90
  }
91
91
  function Pe(e, t, n = "16px system-ui") {
92
- let { maxWidth: r, lineHeight: i, maxLines: a, overflowWrap: o = "break-word" } = t, s = q(e, n), c = [], l = {
92
+ let { maxWidth: r, lineHeight: i, maxLines: a, overflowWrap: o = "break-word" } = t, s = je(e, n), c = [], l = {
93
93
  lineStart: 0,
94
94
  lineWidth: 0,
95
95
  lastBreakIdx: -1,
@@ -98,28 +98,28 @@ function Pe(e, t, n = "16px system-ui") {
98
98
  for (let e = 0; e < s.length; e++) {
99
99
  let t = s[e];
100
100
  if (t.type === "break") {
101
- c.push(J(s, l.lineStart, e, l.lineWidth)), l.lineStart = e + 1, l.lineWidth = 0, l.lastBreakIdx = -1;
101
+ c.push(Ne(s, l.lineStart, e, l.lineWidth)), l.lineStart = e + 1, l.lineWidth = 0, l.lastBreakIdx = -1;
102
102
  continue;
103
103
  }
104
104
  let n = l.lineWidth + t.width;
105
105
  if (t.type === "space") {
106
- if (n > r && l.lineWidth > 0 ? (l.lastBreakIdx >= 0 ? (c.push(J(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Ne(s, l.lineStart, e + 1)) : (c.push(J(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width), l.lastBreakIdx = -1) : (l.lineWidth = n, l.lastBreakIdx = e, l.lastBreakWidth = l.lineWidth), a && c.length >= a) break;
106
+ if (n > r && l.lineWidth > 0 ? (l.lastBreakIdx >= 0 ? (c.push(Ne(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Me(s, l.lineStart, e + 1)) : (c.push(Ne(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width), l.lastBreakIdx = -1) : (l.lineWidth = n, l.lastBreakIdx = e, l.lastBreakWidth = l.lineWidth), a && c.length >= a) break;
107
107
  continue;
108
108
  }
109
109
  if (t.type === "cjk") {
110
- if (n > r && l.lineWidth > 0 ? (c.push(J(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width, l.lastBreakIdx = -1) : (l.lineWidth = n, l.lastBreakIdx = e, l.lastBreakWidth = l.lineWidth), a && c.length >= a) break;
110
+ if (n > r && l.lineWidth > 0 ? (c.push(Ne(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width, l.lastBreakIdx = -1) : (l.lineWidth = n, l.lastBreakIdx = e, l.lastBreakWidth = l.lineWidth), a && c.length >= a) break;
111
111
  continue;
112
112
  }
113
113
  if (t.type === "punct") {
114
- if (l.lineWidth === 0 && c.length > 0 ? c[c.length - 1].text.length > 0 && (l.lineWidth = t.width) : n > r ? (l.lastBreakIdx >= 0 ? (c.push(J(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Ne(s, l.lineStart, e + 1)) : l.lineWidth = n, l.lastBreakIdx = -1) : l.lineWidth = n, a && c.length >= a) break;
114
+ if (l.lineWidth === 0 && c.length > 0 ? c[c.length - 1].text.length > 0 && (l.lineWidth = t.width) : n > r ? (l.lastBreakIdx >= 0 ? (c.push(Ne(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Me(s, l.lineStart, e + 1)) : l.lineWidth = n, l.lastBreakIdx = -1) : l.lineWidth = n, a && c.length >= a) break;
115
115
  continue;
116
116
  }
117
- if (n > r && l.lineWidth > 0 ? l.lastBreakIdx >= 0 ? (c.push(J(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Ne(s, l.lineStart, e + 1), l.lastBreakIdx = -1) : o === "break-word" ? (c.push(J(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width) : l.lineWidth = n : l.lineWidth = n, a && c.length >= a) break;
117
+ if (n > r && l.lineWidth > 0 ? l.lastBreakIdx >= 0 ? (c.push(Ne(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Me(s, l.lineStart, e + 1), l.lastBreakIdx = -1) : o === "break-word" ? (c.push(Ne(s, l.lineStart, e, l.lineWidth)), l.lineStart = e, l.lineWidth = t.width) : l.lineWidth = n : l.lineWidth = n, a && c.length >= a) break;
118
118
  }
119
119
  let u = l.lineStart < s.length;
120
120
  if (u && (!a || c.length < a)) {
121
- let e = Ne(s, l.lineStart, s.length);
122
- c.push(J(s, l.lineStart, s.length, e));
121
+ let e = Me(s, l.lineStart, s.length);
122
+ c.push(Ne(s, l.lineStart, s.length, e));
123
123
  }
124
124
  return {
125
125
  lines: c,
@@ -130,8 +130,8 @@ function Pe(e, t, n = "16px system-ui") {
130
130
  }
131
131
  //#endregion
132
132
  //#region ../toast/dist/index.mjs
133
- var Fe = typeof window < "u" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, Ie = "13.5px -apple-system, BlinkMacSystemFont, \"SF Pro Text\", \"PingFang SC\", \"Microsoft YaHei\", system-ui, sans-serif";
134
- function Y() {
133
+ var Fe = typeof window < "u" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, X = "13.5px -apple-system, BlinkMacSystemFont, \"SF Pro Text\", \"PingFang SC\", \"Microsoft YaHei\", system-ui, sans-serif";
134
+ function Ie() {
135
135
  if (typeof window > "u") return 290;
136
136
  let e = window.innerWidth;
137
137
  return e <= 480 ? Math.max(140, e - 98) : 290;
@@ -145,21 +145,21 @@ var Le = {
145
145
  function ze() {
146
146
  return `qt${Re++}${Date.now().toString(36)}`;
147
147
  }
148
- function X(e, t, n) {
148
+ function Be(e, t, n) {
149
149
  let r = document.createElement(e);
150
150
  return t && (r.className = t), n != null && (r.innerHTML = n), r;
151
151
  }
152
- function Be(e, t) {
152
+ function Ve(e, t) {
153
153
  let n = t.split(/\*\*(.+?)\*\*/g);
154
154
  for (let t = 0; t < n.length; t++) {
155
155
  let r = n[t];
156
156
  if (r) if (t % 2 == 1) {
157
- let t = X("em", "qt-mark");
157
+ let t = Be("em", "qt-mark");
158
158
  t.textContent = r, e.appendChild(t);
159
159
  } else e.appendChild(document.createTextNode(r));
160
160
  }
161
161
  }
162
- var Ve = {
162
+ var He = {
163
163
  type: "info",
164
164
  position: "top-center",
165
165
  duration: 4e3,
@@ -168,19 +168,19 @@ var Ve = {
168
168
  persistMaxVisible: 3,
169
169
  maxLines: void 0,
170
170
  vibrate: !0
171
- }, He = [
171
+ }, Ue = [
172
172
  80,
173
173
  40,
174
174
  80
175
175
  ];
176
- function Ue() {
176
+ function We() {
177
177
  if (!(typeof navigator > "u" || !("vibrate" in navigator))) try {
178
- navigator.vibrate(He);
178
+ navigator.vibrate(Ue);
179
179
  } catch {}
180
180
  }
181
- var We = class {
181
+ var Ge = class {
182
182
  containers = /* @__PURE__ */ new Map();
183
- opts = { ...Ve };
183
+ opts = { ...He };
184
184
  toasts = /* @__PURE__ */ new Map();
185
185
  queue = [];
186
186
  _seq = 0;
@@ -189,7 +189,7 @@ var We = class {
189
189
  }
190
190
  ensureContainer(e) {
191
191
  let t = this.containers.get(e);
192
- return t || (t = X("div", "qt-container"), t.setAttribute("data-qt-pos", e), t.setAttribute("role", "status"), t.setAttribute("aria-live", "polite"), t.setAttribute("aria-atomic", "false"), document.body.appendChild(t), this.containers.set(e, t)), t;
192
+ return t || (t = Be("div", "qt-container"), t.setAttribute("data-qt-pos", e), t.setAttribute("role", "status"), t.setAttribute("aria-live", "polite"), t.setAttribute("aria-atomic", "false"), document.body.appendChild(t), this.containers.set(e, t)), t;
193
193
  }
194
194
  show(e, t) {
195
195
  let n = t?.type ?? this.opts.type, r = t?.position ?? this.opts.position, i = t?.persist ?? this.opts.persist ? 0 : t?.duration ?? this.opts.duration, a = t?.dismissible ?? !0, o = t?.maxLines ?? this.opts.maxLines, s = t?.description, c = t?.action, l = ze(), u = {
@@ -275,30 +275,30 @@ var We = class {
275
275
  this.containers.clear();
276
276
  }
277
277
  buildElement(e, t, n, r, i, a, o) {
278
- let s = X("div", `qt-toast qt-${n}${i == null ? "" : " qt-truncate"}${a || o ? " qt-rich" : ""}`);
278
+ let s = Be("div", `qt-toast qt-${n}${i == null ? "" : " qt-truncate"}${a || o ? " qt-rich" : ""}`);
279
279
  s.setAttribute("data-qt-id", e);
280
- let c = X("span", "qt-icon");
280
+ let c = Be("span", "qt-icon");
281
281
  c.innerHTML = Le[n], s.appendChild(c);
282
- let l = X("div", "qt-body"), u = X("span", "qt-msg"), d = Pe(t, {
283
- maxWidth: Y(),
282
+ let l = Be("div", "qt-body"), u = Be("span", "qt-msg"), d = Pe(t, {
283
+ maxWidth: Ie(),
284
284
  lineHeight: 1,
285
285
  maxLines: i
286
- }, Ie);
287
- if (d.lineCount <= 1 ? Be(u, t) : d.lines.forEach((e, t) => {
288
- let n = X("span", "qt-line"), r = e.text;
289
- t === d.lines.length - 1 && d.truncated && !r.endsWith("…") && (r += "…"), Be(n, r), u.appendChild(n);
286
+ }, X);
287
+ if (d.lineCount <= 1 ? Ve(u, t) : d.lines.forEach((e, t) => {
288
+ let n = Be("span", "qt-line"), r = e.text;
289
+ t === d.lines.length - 1 && d.truncated && !r.endsWith("…") && (r += "…"), Ve(n, r), u.appendChild(n);
290
290
  }), l.appendChild(u), a) {
291
- let e = X("div", "qt-desc");
291
+ let e = Be("div", "qt-desc");
292
292
  e.textContent = a, l.appendChild(e);
293
293
  }
294
294
  if (s.appendChild(l), o) {
295
- let t = X("button", "qt-action");
295
+ let t = Be("button", "qt-action");
296
296
  t.type = "button", t.textContent = o.label, t.addEventListener("click", (t) => {
297
297
  t.stopPropagation(), this.dismiss(e), o.onClick();
298
298
  }), s.appendChild(t);
299
299
  }
300
300
  if (r) {
301
- let t = X("button", "qt-close", "<svg width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"><path d=\"M18 6 6 18M6 6l12 12\"/></svg>");
301
+ let t = Be("button", "qt-close", "<svg width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"><path d=\"M18 6 6 18M6 6l12 12\"/></svg>");
302
302
  t.type = "button", t.setAttribute("aria-label", "关闭通知"), t.addEventListener("click", (t) => {
303
303
  t.stopPropagation(), this.dismiss(e);
304
304
  }), s.appendChild(t);
@@ -310,7 +310,7 @@ var We = class {
310
310
  mount(e) {
311
311
  e.duration === 0 && this.evictPersistIfNeeded(e);
312
312
  let t = this.ensureContainer(e.position);
313
- this.toasts.set(e.id, e), t.appendChild(e.element), e.type === "error" && this.opts.vibrate && Ue(), requestAnimationFrame(() => {
313
+ this.toasts.set(e.id, e), t.appendChild(e.element), e.type === "error" && this.opts.vibrate && We(), requestAnimationFrame(() => {
314
314
  requestAnimationFrame(() => {
315
315
  e.element.classList.add("qt-enter");
316
316
  });
@@ -345,46 +345,46 @@ var We = class {
345
345
  let e = this.queue.shift();
346
346
  this.mount(e);
347
347
  }
348
- }, Ge = null;
349
- function Ke() {
350
- return Ge ||= new We(), Ge;
351
- }
352
- var qe = Object.assign((e, t) => Ke().show(e, t), {
353
- info: (e, t) => Ke().info(e, t),
354
- success: (e, t) => Ke().success(e, t),
355
- warn: (e, t) => Ke().warn(e, t),
356
- error: (e, t) => Ke().error(e, t),
357
- promise: (e, t, n) => Ke().promise(e, t, n),
358
- dismiss: (e) => Ke().dismiss(e),
359
- dismissAll: () => Ke().dismissAll(),
360
- configure: (e) => Ke().configure(e)
361
- }), Je = /* @__PURE__ */ new Set(), Ye = null;
362
- function Xe(e) {
363
- Ye = e;
348
+ }, Ke = null;
349
+ function qe() {
350
+ return Ke ||= new Ge(), Ke;
351
+ }
352
+ var Je = Object.assign((e, t) => qe().show(e, t), {
353
+ info: (e, t) => qe().info(e, t),
354
+ success: (e, t) => qe().success(e, t),
355
+ warn: (e, t) => qe().warn(e, t),
356
+ error: (e, t) => qe().error(e, t),
357
+ promise: (e, t, n) => qe().promise(e, t, n),
358
+ dismiss: (e) => qe().dismiss(e),
359
+ dismissAll: () => qe().dismissAll(),
360
+ configure: (e) => qe().configure(e)
361
+ }), Ye = /* @__PURE__ */ new Set(), Xe = null;
362
+ function Ze(e) {
363
+ Xe = e;
364
364
  }
365
365
  function Z(e, t = "error", n) {
366
366
  let r = {
367
367
  persist: !0,
368
368
  ...n
369
369
  };
370
- if (Je.size > 0) {
371
- for (let n of Je) n(e, t, r);
370
+ if (Ye.size > 0) {
371
+ for (let n of Ye) n(e, t, r);
372
372
  return;
373
373
  }
374
- if (Ye) {
375
- Ye(e, t, r);
374
+ if (Xe) {
375
+ Xe(e, t, r);
376
376
  return;
377
377
  }
378
- t === "success" ? qe.success(e, r) : t === "info" ? qe.info(e, r) : qe.error(e, r);
378
+ t === "success" ? Je.success(e, r) : t === "info" ? Je.info(e, r) : Je.error(e, r);
379
379
  }
380
- function Ze(e) {
381
- return Je.add(e), () => {
382
- Je.delete(e);
380
+ function Qe(e) {
381
+ return Ye.add(e), () => {
382
+ Ye.delete(e);
383
383
  };
384
384
  }
385
385
  //#endregion
386
386
  //#region src/components/image-upload-dialog.tsx
387
- var Qe = /* @__PURE__ */ e({ ImageUploadDialog: () => $e }), $e = ({ open: e, onClose: t, onInsert: n, validate: r }) => {
387
+ var $e = /* @__PURE__ */ e({ ImageUploadDialog: () => et }), et = ({ open: e, onClose: t, onInsert: n, validate: r }) => {
388
388
  let [i, a] = T("upload"), [s, c] = T(!1), [l, u] = T(!1), [d, f] = T(null), [p, m] = T(null), [h, g] = T(""), [_, v] = T(null), y = w(null), x = (() => {
389
389
  try {
390
390
  let e = o();
@@ -676,10 +676,10 @@ var Qe = /* @__PURE__ */ e({ ImageUploadDialog: () => $e }), $e = ({ open: e, on
676
676
  };
677
677
  //#endregion
678
678
  //#region src/components/toc.tsx
679
- function et(e, t) {
679
+ function tt(e, t) {
680
680
  return `${e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu, "").replace(/\s+/g, "-").slice(0, 40) || "heading"}-${t}`;
681
681
  }
682
- function tt(e) {
682
+ function nt(e) {
683
683
  let t = [], n = [];
684
684
  for (let r of e) {
685
685
  let e = {
@@ -691,18 +691,18 @@ function tt(e) {
691
691
  }
692
692
  return t;
693
693
  }
694
- function nt(e) {
694
+ function rt(e) {
695
695
  let t = /* @__PURE__ */ new Set(), n = (e) => {
696
696
  for (let r of e) r.children.length > 0 && (t.add(r.id), n(r.children));
697
697
  };
698
698
  return n(e), t;
699
699
  }
700
- function rt(e, t) {
700
+ function it(e, t) {
701
701
  let n = [];
702
- for (let r of e) n.push(r), r.children.length > 0 && !t.has(r.id) && n.push(...rt(r.children, t));
702
+ for (let r of e) n.push(r), r.children.length > 0 && !t.has(r.id) && n.push(...it(r.children, t));
703
703
  return n;
704
704
  }
705
- function it(e, t) {
705
+ function at(e, t) {
706
706
  let n = t.toLowerCase(), r = (e) => {
707
707
  let t = [];
708
708
  for (let i of e) {
@@ -716,7 +716,7 @@ function it(e, t) {
716
716
  };
717
717
  return r(e);
718
718
  }
719
- function at(e) {
719
+ function ot(e) {
720
720
  let t = e.parentElement;
721
721
  for (; t && t !== document.documentElement;) {
722
722
  let e = getComputedStyle(t).overflowY;
@@ -725,7 +725,7 @@ function at(e) {
725
725
  }
726
726
  return null;
727
727
  }
728
- function ot(e, t) {
728
+ function st(e, t) {
729
729
  if (!t) return e;
730
730
  let n = e.toLowerCase(), r = t.toLowerCase(), i = [], a = 0, o = 0;
731
731
  for (;;) {
@@ -738,10 +738,10 @@ function ot(e, t) {
738
738
  }
739
739
  return a < e.length && i.push(e.slice(a)), i.length ? i : e;
740
740
  }
741
- var st = 84, ct = 3e3, lt = ({ editor: e, className: t = "", onClose: n }) => {
741
+ var ct = 84, lt = 3e3, ut = ({ editor: e, className: t = "", onClose: n }) => {
742
742
  let [r, i] = T([]), [a, o] = T(""), [s, c] = T(/* @__PURE__ */ new Set()), [l, u] = T(""), d = w(""), f = w([]), p = w(null), m = w(null), h = w(null), g = w(0), _ = b(() => {
743
743
  h.current &&= (clearTimeout(h.current.timer), null);
744
- }, []), v = b(() => Array.from(e.view.dom.querySelectorAll("h1,h2,h3,h4,h5,h6")).map((e, t) => (e.id ||= et(e.textContent || "", t), {
744
+ }, []), v = b(() => Array.from(e.view.dom.querySelectorAll("h1,h2,h3,h4,h5,h6")).map((e, t) => (e.id ||= tt(e.textContent || "", t), {
745
745
  id: e.id,
746
746
  level: Number(e.tagName.slice(1)),
747
747
  text: e.textContent?.trim() || "(无标题)",
@@ -749,7 +749,7 @@ var st = 84, ct = 3e3, lt = ({ editor: e, className: t = "", onClose: n }) => {
749
749
  })), [e]), y = b(() => {
750
750
  let e = f.current;
751
751
  if ((!e.length || e.some((e) => !e.el.isConnected)) && (e = v(), f.current = e), !e.length) return;
752
- let t = m.current, n = (t ? t.getBoundingClientRect().top : 0) + st, r = t ? t.scrollHeight - t.scrollTop - t.clientHeight < 2 : document.documentElement.scrollHeight - window.scrollY - window.innerHeight < 2, i = "";
752
+ let t = m.current, n = (t ? t.getBoundingClientRect().top : 0) + ct, r = t ? t.scrollHeight - t.scrollTop - t.clientHeight < 2 : document.documentElement.scrollHeight - window.scrollY - window.innerHeight < 2, i = "";
753
753
  for (let t of e) t.el.isConnected && t.el.getBoundingClientRect().top <= n && (i = t.id);
754
754
  if (r) {
755
755
  for (let t = e.length - 1; t >= 0; t--) if (e[t].el.isConnected) {
@@ -773,7 +773,7 @@ var st = 84, ct = 3e3, lt = ({ editor: e, className: t = "", onClose: n }) => {
773
773
  t !== d.current && (d.current = t, f.current = e, i(e), S());
774
774
  }, [v, S]);
775
775
  x(() => {
776
- let t = at(e.view.dom);
776
+ let t = ot(e.view.dom);
777
777
  m.current = t;
778
778
  let n = t ?? window;
779
779
  return n.addEventListener("scroll", S, { passive: !0 }), window.addEventListener("resize", S), n.addEventListener("wheel", _, { passive: !0 }), n.addEventListener("touchstart", _, { passive: !0 }), () => {
@@ -811,21 +811,21 @@ var st = 84, ct = 3e3, lt = ({ editor: e, className: t = "", onClose: n }) => {
811
811
  }
812
812
  n && (_(), h.current = {
813
813
  id: t.id,
814
- timer: setTimeout(_, ct)
814
+ timer: setTimeout(_, lt)
815
815
  }, o(t.id), n.scrollIntoView({
816
816
  behavior: "smooth",
817
817
  block: "start"
818
818
  }));
819
- }, [e, _]), A = C(() => tt(r), [r]), j = C(() => nt(A), [A]), M = C(() => {
819
+ }, [e, _]), A = C(() => nt(r), [r]), j = C(() => rt(A), [A]), M = C(() => {
820
820
  let e = /* @__PURE__ */ new Map(), t = (n, r) => {
821
821
  for (let i of n) r && e.set(i.id, r), t(i.children, i.id);
822
822
  };
823
823
  return t(A, ""), e;
824
- }, [A]), N = l.trim().length > 0, P = C(() => N ? it(A, l.trim()) : A, [
824
+ }, [A]), N = l.trim().length > 0, P = C(() => N ? at(A, l.trim()) : A, [
825
825
  A,
826
826
  N,
827
827
  l
828
- ]), F = C(() => rt(P, N ? /* @__PURE__ */ new Set() : s), [
828
+ ]), F = C(() => it(P, N ? /* @__PURE__ */ new Set() : s), [
829
829
  P,
830
830
  s,
831
831
  N
@@ -1056,7 +1056,7 @@ var st = 84, ct = 3e3, lt = ({ editor: e, className: t = "", onClose: n }) => {
1056
1056
  title: e.text,
1057
1057
  children: /* @__PURE__ */ D("span", {
1058
1058
  className: "toc-text",
1059
- children: N ? ot(e.text, l.trim()) : e.text
1059
+ children: N ? st(e.text, l.trim()) : e.text
1060
1060
  })
1061
1061
  })]
1062
1062
  }, e.id);
@@ -1080,7 +1080,7 @@ var st = 84, ct = 3e3, lt = ({ editor: e, className: t = "", onClose: n }) => {
1080
1080
  };
1081
1081
  //#endregion
1082
1082
  //#region src/editor/ai/index.ts
1083
- function ut(e, t) {
1083
+ function dt(e, t) {
1084
1084
  return {
1085
1085
  continue: "你是一个写作助手。请从下文尾部自然流畅地续写内容,保持风格一致。只输出续写的内容,不要加任何前缀说明。",
1086
1086
  improve: "你是一个文字润色专家。请优化以下文本的表达,提升文采和流畅度,保持原意不变。只输出润色后的文本。",
@@ -1091,8 +1091,8 @@ function ut(e, t) {
1091
1091
  zap: t || "你是一个全能的 AI 写作助手。请根据用户的指令处理文本。"
1092
1092
  }[e];
1093
1093
  }
1094
- var dt = null;
1095
- async function ft(e) {
1094
+ var ft = null;
1095
+ async function pt(e) {
1096
1096
  let t;
1097
1097
  try {
1098
1098
  ({createOpenAI: t} = await import("@ai-sdk/openai"));
@@ -1107,7 +1107,7 @@ async function ft(e) {
1107
1107
  async *stream(e) {
1108
1108
  let t = await A({
1109
1109
  model: n,
1110
- system: ut(e.mode, e.instruction),
1110
+ system: dt(e.mode, e.instruction),
1111
1111
  prompt: e.context,
1112
1112
  temperature: .7,
1113
1113
  maxOutputTokens: 2048
@@ -1117,7 +1117,7 @@ async function ft(e) {
1117
1117
  async generate(e) {
1118
1118
  return (await k({
1119
1119
  model: n,
1120
- system: ut(e.mode, e.instruction),
1120
+ system: dt(e.mode, e.instruction),
1121
1121
  prompt: e.context,
1122
1122
  temperature: .7,
1123
1123
  maxOutputTokens: 2048
@@ -1125,16 +1125,16 @@ async function ft(e) {
1125
1125
  }
1126
1126
  };
1127
1127
  }
1128
- function pt(e) {
1129
- dt = e;
1128
+ function mt(e) {
1129
+ ft = e;
1130
1130
  }
1131
- function mt() {
1132
- if (!dt) throw Error("未配置 AI 服务。请调用 createAILanguageModelProvider() 创建并通过 setAIProvider() 注册。");
1133
- return dt;
1131
+ function ht() {
1132
+ if (!ft) throw Error("未配置 AI 服务。请调用 createAILanguageModelProvider() 创建并通过 setAIProvider() 注册。");
1133
+ return ft;
1134
1134
  }
1135
1135
  //#endregion
1136
1136
  //#region src/editor/ai/providers/openai-compat.ts
1137
- function ht(e) {
1137
+ function gt(e) {
1138
1138
  let { apiKey: t, baseURL: n, model: r, headers: i } = e;
1139
1139
  async function* a(e, a) {
1140
1140
  let o = await fetch(`${n}/chat/completions`, {
@@ -1185,10 +1185,10 @@ function ht(e) {
1185
1185
  }
1186
1186
  return {
1187
1187
  async *stream(e) {
1188
- yield* a(ut(e.mode, e.instruction), e.context);
1188
+ yield* a(dt(e.mode, e.instruction), e.context);
1189
1189
  },
1190
1190
  async generate(e) {
1191
- let t = ut(e.mode, e.instruction), n = "";
1191
+ let t = dt(e.mode, e.instruction), n = "";
1192
1192
  for await (let r of a(t, e.context)) n += r;
1193
1193
  return n;
1194
1194
  }
@@ -1196,8 +1196,8 @@ function ht(e) {
1196
1196
  }
1197
1197
  //#endregion
1198
1198
  //#region src/editor/ai/providers/deepseek.ts
1199
- function gt(e) {
1200
- return ht({
1199
+ function _t(e) {
1200
+ return gt({
1201
1201
  apiKey: e.apiKey,
1202
1202
  baseURL: e.baseURL || "https://api.deepseek.com/v1",
1203
1203
  model: e.model || "deepseek-v4-flash",
@@ -1206,8 +1206,8 @@ function gt(e) {
1206
1206
  }
1207
1207
  //#endregion
1208
1208
  //#region src/editor/ai/providers/openai.ts
1209
- function _t(e) {
1210
- return ht({
1209
+ function vt(e) {
1210
+ return gt({
1211
1211
  apiKey: e.apiKey,
1212
1212
  baseURL: e.baseURL || "https://api.openai.com/v1",
1213
1213
  model: e.model || "gpt-5.6-luna",
@@ -1216,8 +1216,8 @@ function _t(e) {
1216
1216
  }
1217
1217
  //#endregion
1218
1218
  //#region src/editor/ai/providers/qwen.ts
1219
- function vt(e) {
1220
- return ht({
1219
+ function yt(e) {
1220
+ return gt({
1221
1221
  apiKey: e.apiKey,
1222
1222
  baseURL: e.baseURL || "https://dashscope.aliyuncs.com/compatible-mode/v1",
1223
1223
  model: e.model || "qwen3.7-plus",
@@ -1226,20 +1226,20 @@ function vt(e) {
1226
1226
  }
1227
1227
  //#endregion
1228
1228
  //#region src/editor/extensions/search-highlight.ts
1229
- var yt = {
1229
+ var bt = {
1230
1230
  keyword: "",
1231
1231
  caseSensitive: !1,
1232
1232
  wholeWord: !1,
1233
1233
  matches: [],
1234
1234
  currentIndex: -1
1235
- }, bt = new B("search-highlight");
1236
- function xt(e) {
1235
+ }, xt = new B("search-highlight");
1236
+ function St(e) {
1237
1237
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1238
1238
  }
1239
- function St(e, t) {
1239
+ function Ct(e, t) {
1240
1240
  let { keyword: n, caseSensitive: r, wholeWord: i } = t;
1241
1241
  if (!n) return [];
1242
- let a = r ? "g" : "gi", o = i ? `\\b${xt(n)}\\b` : xt(n), s = new RegExp(o, a), c = [];
1242
+ let a = r ? "g" : "gi", o = i ? `\\b${St(n)}\\b` : St(n), s = new RegExp(o, a), c = [];
1243
1243
  return e.descendants((e, t) => {
1244
1244
  if (!e.isText || !e.text) return;
1245
1245
  s.lastIndex = 0;
@@ -1253,12 +1253,12 @@ function St(e, t) {
1253
1253
  }
1254
1254
  }), c;
1255
1255
  }
1256
- function Ct(e, t) {
1257
- if (t.matches.length === 0) return se.empty;
1258
- let n = t.matches.map((e, n) => oe.inline(e.from, e.to, { class: n === t.currentIndex ? "search-highlight search-highlight--active" : "search-highlight" }));
1259
- return se.create(e, n);
1260
- }
1261
1256
  function wt(e, t) {
1257
+ if (t.matches.length === 0) return ae.empty;
1258
+ let n = t.matches.map((e, n) => H.inline(e.from, e.to, { class: n === t.currentIndex ? "search-highlight search-highlight--active" : "search-highlight" }));
1259
+ return ae.create(e, n);
1260
+ }
1261
+ function Tt(e, t) {
1262
1262
  if (t.currentIndex < 0 || t.currentIndex >= t.matches.length) return;
1263
1263
  let n = t.matches[t.currentIndex];
1264
1264
  n && requestAnimationFrame(() => {
@@ -1283,15 +1283,15 @@ function wt(e, t) {
1283
1283
  } catch {}
1284
1284
  });
1285
1285
  }
1286
- var Tt = R.create({
1286
+ var Et = R.create({
1287
1287
  name: "searchHighlight",
1288
1288
  addProseMirrorPlugins() {
1289
1289
  return [new z({
1290
- key: bt,
1290
+ key: xt,
1291
1291
  state: {
1292
- init: () => yt,
1292
+ init: () => bt,
1293
1293
  apply(e, t) {
1294
- let n = e.getMeta(bt);
1294
+ let n = e.getMeta(xt);
1295
1295
  if (n) return {
1296
1296
  ...t,
1297
1297
  ...n,
@@ -1299,7 +1299,7 @@ var Tt = R.create({
1299
1299
  currentIndex: n.currentIndex === void 0 ? t.currentIndex : n.currentIndex
1300
1300
  };
1301
1301
  if (e.docChanged && t.keyword) {
1302
- let n = St(e.doc, t), r = t.currentIndex;
1302
+ let n = Ct(e.doc, t), r = t.currentIndex;
1303
1303
  return r >= n.length && (r = n.length - 1), r < 0 && (r = n.length > 0 ? 0 : -1), {
1304
1304
  ...t,
1305
1305
  matches: n,
@@ -1310,52 +1310,52 @@ var Tt = R.create({
1310
1310
  }
1311
1311
  },
1312
1312
  props: { decorations(e) {
1313
- let t = bt.getState(e);
1314
- return t ? Ct(e.doc, t) : se.empty;
1313
+ let t = xt.getState(e);
1314
+ return t ? wt(e.doc, t) : ae.empty;
1315
1315
  } }
1316
1316
  })];
1317
1317
  },
1318
1318
  addCommands() {
1319
1319
  return {
1320
1320
  setSearch: (e, t = {}) => ({ state: n, dispatch: r, view: i }) => {
1321
- let a = bt.getState(n) || yt, o = {
1321
+ let a = xt.getState(n) || bt, o = {
1322
1322
  keyword: e,
1323
1323
  caseSensitive: t.caseSensitive ?? a.caseSensitive,
1324
1324
  wholeWord: t.wholeWord ?? a.wholeWord,
1325
1325
  matches: [],
1326
1326
  currentIndex: -1
1327
1327
  };
1328
- return o.matches = St(n.doc, o), o.currentIndex = o.matches.length > 0 ? 0 : -1, r && (r(n.tr.setMeta(bt, o)), i && wt(i, o)), !0;
1328
+ return o.matches = Ct(n.doc, o), o.currentIndex = o.matches.length > 0 ? 0 : -1, r && (r(n.tr.setMeta(xt, o)), i && Tt(i, o)), !0;
1329
1329
  },
1330
1330
  nextMatch: () => ({ state: e, dispatch: t, view: n }) => {
1331
- let r = bt.getState(e) || yt;
1331
+ let r = xt.getState(e) || bt;
1332
1332
  if (r.matches.length === 0) return !1;
1333
1333
  let i = (r.currentIndex + 1) % r.matches.length;
1334
- return t && (t(e.tr.setMeta(bt, { currentIndex: i })), n && wt(n, {
1334
+ return t && (t(e.tr.setMeta(xt, { currentIndex: i })), n && Tt(n, {
1335
1335
  ...r,
1336
1336
  currentIndex: i
1337
1337
  })), !0;
1338
1338
  },
1339
1339
  prevMatch: () => ({ state: e, dispatch: t, view: n }) => {
1340
- let r = bt.getState(e) || yt;
1340
+ let r = xt.getState(e) || bt;
1341
1341
  if (r.matches.length === 0) return !1;
1342
1342
  let i = (r.currentIndex - 1 + r.matches.length) % r.matches.length;
1343
- return t && (t(e.tr.setMeta(bt, { currentIndex: i })), n && wt(n, {
1343
+ return t && (t(e.tr.setMeta(xt, { currentIndex: i })), n && Tt(n, {
1344
1344
  ...r,
1345
1345
  currentIndex: i
1346
1346
  })), !0;
1347
1347
  },
1348
- clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(bt, yt)), !0)
1348
+ clearSearch: () => ({ state: e, dispatch: t }) => (t && t(e.tr.setMeta(xt, bt)), !0)
1349
1349
  };
1350
1350
  }
1351
1351
  });
1352
- function Et(e) {
1352
+ function Dt(e) {
1353
1353
  let t = e.state;
1354
- return bt.getState(t) || yt;
1354
+ return xt.getState(t) || bt;
1355
1355
  }
1356
1356
  //#endregion
1357
1357
  //#region src/components/search-bar.tsx
1358
- var Dt = ({ editor: e, onClose: t }) => {
1358
+ var Ot = ({ editor: e, onClose: t }) => {
1359
1359
  let [n, r] = T(""), [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(0), u = w(null), d = w({
1360
1360
  keyword: n,
1361
1361
  caseSensitive: i,
@@ -1420,7 +1420,7 @@ var Dt = ({ editor: e, onClose: t }) => {
1420
1420
  }, [f, p]), h = C(() => {
1421
1421
  if (!e) return null;
1422
1422
  try {
1423
- return Et(e);
1423
+ return Dt(e);
1424
1424
  } catch {
1425
1425
  return null;
1426
1426
  }
@@ -1572,36 +1572,36 @@ function Q({ children: e, ...t }) {
1572
1572
  children: e
1573
1573
  });
1574
1574
  }
1575
- var Ot = (e) => /* @__PURE__ */ O(Q, {
1575
+ var kt = (e) => /* @__PURE__ */ O(Q, {
1576
1576
  ...e,
1577
1577
  children: [/* @__PURE__ */ D("path", { d: "M6 4h8a4 4 0 0 1 0 8H6z" }), /* @__PURE__ */ D("path", { d: "M6 12h9a4 4 0 0 1 0 8H6z" })]
1578
- }), kt = (e) => /* @__PURE__ */ O(Q, {
1578
+ }), At = (e) => /* @__PURE__ */ O(Q, {
1579
1579
  ...e,
1580
1580
  children: [
1581
1581
  /* @__PURE__ */ D("path", { d: "M19 4h-9" }),
1582
1582
  /* @__PURE__ */ D("path", { d: "M14 20H5" }),
1583
1583
  /* @__PURE__ */ D("path", { d: "M15 4 9 20" })
1584
1584
  ]
1585
- }), At = (e) => /* @__PURE__ */ O(Q, {
1585
+ }), jt = (e) => /* @__PURE__ */ O(Q, {
1586
1586
  ...e,
1587
1587
  children: [/* @__PURE__ */ D("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }), /* @__PURE__ */ D("path", { d: "M4 20h16" })]
1588
- }), jt = (e) => /* @__PURE__ */ O(Q, {
1588
+ }), Mt = (e) => /* @__PURE__ */ O(Q, {
1589
1589
  ...e,
1590
1590
  children: [
1591
1591
  /* @__PURE__ */ D("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
1592
1592
  /* @__PURE__ */ D("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
1593
1593
  /* @__PURE__ */ D("path", { d: "M4 12h16" })
1594
1594
  ]
1595
- }), Mt = (e) => /* @__PURE__ */ O(Q, {
1595
+ }), Nt = (e) => /* @__PURE__ */ O(Q, {
1596
1596
  ...e,
1597
1597
  children: [/* @__PURE__ */ D("path", { d: "m16 18 6-6-6-6" }), /* @__PURE__ */ D("path", { d: "m8 6-6 6 6 6" })]
1598
- }), Nt = (e) => /* @__PURE__ */ O(Q, {
1598
+ }), Pt = (e) => /* @__PURE__ */ O(Q, {
1599
1599
  ...e,
1600
1600
  children: [/* @__PURE__ */ D("path", { d: "m9 11-6 6v3h9l3-3" }), /* @__PURE__ */ D("path", { d: "m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4" })]
1601
- }), Pt = (e) => /* @__PURE__ */ O(Q, {
1601
+ }), Ft = (e) => /* @__PURE__ */ O(Q, {
1602
1602
  ...e,
1603
1603
  children: [/* @__PURE__ */ D("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }), /* @__PURE__ */ D("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })]
1604
- }), Ft = (e) => /* @__PURE__ */ O(Q, {
1604
+ }), It = (e) => /* @__PURE__ */ O(Q, {
1605
1605
  ...e,
1606
1606
  children: [/* @__PURE__ */ D("rect", {
1607
1607
  x: "3",
@@ -1611,7 +1611,7 @@ var Ot = (e) => /* @__PURE__ */ O(Q, {
1611
1611
  rx: "2",
1612
1612
  ry: "2"
1613
1613
  }), /* @__PURE__ */ D("path", { d: "M3 9h18M3 15h18M9 3v18M15 3v18" })]
1614
- }), It = (e) => /* @__PURE__ */ O(Q, {
1614
+ }), Lt = (e) => /* @__PURE__ */ O(Q, {
1615
1615
  ...e,
1616
1616
  children: [/* @__PURE__ */ D("rect", {
1617
1617
  x: "8",
@@ -1621,17 +1621,17 @@ var Ot = (e) => /* @__PURE__ */ O(Q, {
1621
1621
  rx: "2",
1622
1622
  ry: "2"
1623
1623
  }), /* @__PURE__ */ D("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })]
1624
- }), Lt = (e) => /* @__PURE__ */ O(Q, {
1624
+ }), Rt = (e) => /* @__PURE__ */ O(Q, {
1625
1625
  ...e,
1626
1626
  children: [/* @__PURE__ */ D("circle", {
1627
1627
  cx: "11",
1628
1628
  cy: "11",
1629
1629
  r: "8"
1630
1630
  }), /* @__PURE__ */ D("path", { d: "m21 21-4.3-4.3" })]
1631
- }), Rt = (e) => /* @__PURE__ */ O(Q, {
1631
+ }), zt = (e) => /* @__PURE__ */ O(Q, {
1632
1632
  ...e,
1633
1633
  children: [/* @__PURE__ */ D("path", { d: "M12 3l1.6 4.4L18 9l-4.4 1.6L12 15l-1.6-4.4L6 9l4.4-1.6L12 3z" }), /* @__PURE__ */ D("path", { d: "M18.5 14l.7 1.9 1.9.7-1.9.7-.7 1.9-.7-1.9-1.9-.7 1.9-.7.7-1.9z" })]
1634
- }), zt = (e) => /* @__PURE__ */ O(Q, {
1634
+ }), Bt = (e) => /* @__PURE__ */ O(Q, {
1635
1635
  ...e,
1636
1636
  children: [
1637
1637
  /* @__PURE__ */ D("circle", {
@@ -1650,13 +1650,13 @@ var Ot = (e) => /* @__PURE__ */ O(Q, {
1650
1650
  r: "1"
1651
1651
  })
1652
1652
  ]
1653
- }), Bt = (e) => /* @__PURE__ */ O(Q, {
1653
+ }), Vt = (e) => /* @__PURE__ */ O(Q, {
1654
1654
  ...e,
1655
1655
  children: [/* @__PURE__ */ D("path", { d: "M18 6 6 18" }), /* @__PURE__ */ D("path", { d: "m6 6 12 12" })]
1656
1656
  });
1657
1657
  //#endregion
1658
1658
  //#region src/editor/storage/remove-resource.ts
1659
- async function Vt(e) {
1659
+ async function Ht(e) {
1660
1660
  if (e) {
1661
1661
  if (e.startsWith("blob:")) {
1662
1662
  URL.revokeObjectURL(e);
@@ -1671,61 +1671,61 @@ async function Vt(e) {
1671
1671
  }
1672
1672
  //#endregion
1673
1673
  //#region src/editor/ai/pending-removal.ts
1674
- var Ht = 3e4, Ut = /* @__PURE__ */ new Set([
1674
+ var Ut = 3e4, Wt = /* @__PURE__ */ new Set([
1675
1675
  "image",
1676
1676
  "attachmentEmbed",
1677
1677
  "audioEmbed",
1678
1678
  "videoEmbed"
1679
- ]), Wt = /* @__PURE__ */ new WeakMap();
1680
- function Gt(e) {
1679
+ ]), Gt = /* @__PURE__ */ new WeakMap();
1680
+ function Kt(e) {
1681
1681
  let t = /* @__PURE__ */ new Set();
1682
1682
  return e.state.doc.descendants((e) => {
1683
- if (Ut.has(e.type.name)) {
1683
+ if (Wt.has(e.type.name)) {
1684
1684
  let n = e.attrs.src;
1685
1685
  n && t.add(n);
1686
1686
  }
1687
1687
  return !0;
1688
1688
  }), t;
1689
1689
  }
1690
- function Kt(e) {
1691
- let t = Wt.get(e);
1690
+ function qt(e) {
1691
+ let t = Gt.get(e);
1692
1692
  return t || (t = {
1693
1693
  timers: /* @__PURE__ */ new Map(),
1694
1694
  onTransaction: () => {},
1695
1695
  listening: !1
1696
- }, Wt.set(e, t)), t;
1696
+ }, Gt.set(e, t)), t;
1697
1697
  }
1698
- function qt(e, t) {
1698
+ function Jt(e, t) {
1699
1699
  let n = [...new Set(t.filter(Boolean))];
1700
1700
  if (n.length === 0) return;
1701
- let r = Kt(e);
1701
+ let r = qt(e);
1702
1702
  r.listening ||= (r.onTransaction = () => {
1703
1703
  if (r.timers.size === 0) return;
1704
- let t = Gt(e);
1704
+ let t = Kt(e);
1705
1705
  for (let [e, n] of r.timers) t.has(e) && (clearTimeout(n), r.timers.delete(e));
1706
1706
  }, e.on("transaction", r.onTransaction), !0);
1707
1707
  for (let t of n) {
1708
1708
  if (r.timers.has(t)) continue;
1709
1709
  let n = setTimeout(() => {
1710
- Gt(e).has(t) || Vt(t), r.timers.delete(t);
1711
- }, Ht);
1710
+ Kt(e).has(t) || Ht(t), r.timers.delete(t);
1711
+ }, Ut);
1712
1712
  r.timers.set(t, n);
1713
1713
  }
1714
1714
  }
1715
- function Jt(e) {
1716
- let t = Wt.get(e);
1715
+ function Yt(e) {
1716
+ let t = Gt.get(e);
1717
1717
  if (t) {
1718
1718
  if (t.listening &&= (e.off("transaction", t.onTransaction), !1), t.timers.size > 0) {
1719
- let n = Gt(e);
1720
- for (let [e, r] of t.timers) clearTimeout(r), n.has(e) || Vt(e);
1719
+ let n = Kt(e);
1720
+ for (let [e, r] of t.timers) clearTimeout(r), n.has(e) || Ht(e);
1721
1721
  t.timers.clear();
1722
1722
  }
1723
- Wt.delete(e);
1723
+ Gt.delete(e);
1724
1724
  }
1725
1725
  }
1726
1726
  //#endregion
1727
1727
  //#region src/editor/ai/components/ai-selector.tsx
1728
- var Yt = [
1728
+ var Xt = [
1729
1729
  {
1730
1730
  mode: "continue",
1731
1731
  labelKey: "editor.ai.continue",
@@ -1768,24 +1768,24 @@ var Yt = [
1768
1768
  descKey: "editor.ai.zapDesc",
1769
1769
  icon: "⚡"
1770
1770
  }
1771
- ], Xt = /* @__PURE__ */ new Set([
1771
+ ], Zt = /* @__PURE__ */ new Set([
1772
1772
  "image",
1773
1773
  "attachmentEmbed",
1774
1774
  "audioEmbed",
1775
1775
  "videoEmbed"
1776
- ]), Zt = {
1776
+ ]), Qt = {
1777
1777
  image: "editor.ai.nodeImage",
1778
1778
  attachmentEmbed: "editor.ai.nodeAttachment",
1779
1779
  videoEmbed: "editor.ai.nodeVideo",
1780
1780
  audioEmbed: "editor.ai.nodeAudio"
1781
1781
  };
1782
- function Qt(e, t) {
1782
+ function $t(e, t) {
1783
1783
  return e.storage.qingwuUI?.parseMd?.(e.schema, t) || null;
1784
1784
  }
1785
- function $t(e, t, n) {
1785
+ function en(e, t, n) {
1786
1786
  let r = [];
1787
1787
  return e.state.doc.nodesBetween(t, n, (e) => {
1788
- if (Xt.has(e.type.name)) {
1788
+ if (Zt.has(e.type.name)) {
1789
1789
  let t = e.attrs.src;
1790
1790
  t && r.push({
1791
1791
  type: e.type.name,
@@ -1795,27 +1795,27 @@ function $t(e, t, n) {
1795
1795
  return !0;
1796
1796
  }), r;
1797
1797
  }
1798
- function en(e) {
1798
+ function tn(e) {
1799
1799
  let t = /* @__PURE__ */ new Set();
1800
1800
  return e.state.doc.descendants((e) => {
1801
- if (Xt.has(e.type.name)) {
1801
+ if (Zt.has(e.type.name)) {
1802
1802
  let n = e.attrs.src;
1803
1803
  n && t.add(n);
1804
1804
  }
1805
1805
  return !0;
1806
1806
  }), t;
1807
1807
  }
1808
- function tn(e, t) {
1809
- let n = Qt(e, t);
1808
+ function nn(e, t) {
1809
+ let n = $t(e, t);
1810
1810
  if (n && n.size > 0) {
1811
1811
  let t = e.state.tr;
1812
- t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(ae.create(t.doc, t.doc.content.size)), e.view.dispatch(t.scrollIntoView()), e.commands.focus();
1812
+ t.replaceWith(0, e.state.doc.content.size, n), t.setSelection(V.create(t.doc, t.doc.content.size)), e.view.dispatch(t.scrollIntoView()), e.commands.focus();
1813
1813
  return;
1814
1814
  }
1815
1815
  e.commands.setContent(t), e.commands.focus();
1816
1816
  }
1817
- function nn(e, t, n, r) {
1818
- let i = Qt(e, t);
1817
+ function rn(e, t, n, r) {
1818
+ let i = $t(e, t);
1819
1819
  if (e.commands.focus(), !i) {
1820
1820
  let i = e.chain().focus();
1821
1821
  n === "replace" ? i.setTextSelection({
@@ -1827,7 +1827,7 @@ function nn(e, t, n, r) {
1827
1827
  let a = e.state.tr;
1828
1828
  n === "replace" ? a.replaceRange(r.from, r.to, new N(i, 0, 0)) : a.insert(Math.min(r.to, e.state.doc.content.size), i), e.view.dispatch(a.scrollIntoView());
1829
1829
  }
1830
- function rn({ editor: e, onClose: t }) {
1830
+ function an({ editor: e, onClose: t }) {
1831
1831
  let [n, r] = T(null), [i, a] = T(""), [o, s] = T(""), [c, l] = T(!1), [u, d] = T(null), [p, m] = T(null), h = w({
1832
1832
  from: 0,
1833
1833
  to: 0,
@@ -1846,7 +1846,7 @@ function rn({ editor: e, onClose: t }) {
1846
1846
  empty: n.empty
1847
1847
  }, l(!0), s(""), v.current = !0, d(null);
1848
1848
  try {
1849
- let r = mt(), a = n.empty ? e.state.doc.textContent : e.state.doc.textBetween(n.from, n.to), o = [];
1849
+ let r = ht(), a = n.empty ? e.state.doc.textContent : e.state.doc.textBetween(n.from, n.to), o = [];
1850
1850
  for await (let e of r.stream({
1851
1851
  mode: t,
1852
1852
  context: a,
@@ -1871,13 +1871,13 @@ function rn({ editor: e, onClose: t }) {
1871
1871
  !e || !v.current || (e.scrollTop = e.scrollHeight);
1872
1872
  }, [o]);
1873
1873
  let k = b((t, n, r) => {
1874
- let i = new Set($t(e, r.from, r.to).map((e) => e.src));
1875
- t === "replaceAll" ? tn(e, n) : nn(e, n, "replace", h.current);
1876
- let a = en(e);
1877
- qt(e, [...i].filter((e) => !a.has(e)));
1874
+ let i = new Set(en(e, r.from, r.to).map((e) => e.src));
1875
+ t === "replaceAll" ? nn(e, n) : rn(e, n, "replace", h.current);
1876
+ let a = tn(e);
1877
+ Jt(e, [...i].filter((e) => !a.has(e)));
1878
1878
  }, [e]), A = b((n) => {
1879
1879
  if (n === "below") {
1880
- nn(e, o, "below", h.current), t();
1880
+ rn(e, o, "below", h.current), t();
1881
1881
  return;
1882
1882
  }
1883
1883
  let r = h.current, i = n === "replaceAll" ? {
@@ -1886,7 +1886,7 @@ function rn({ editor: e, onClose: t }) {
1886
1886
  } : {
1887
1887
  from: r.from,
1888
1888
  to: r.to
1889
- }, a = $t(e, i.from, i.to);
1889
+ }, a = en(e, i.from, i.to);
1890
1890
  if (a.length > 0) {
1891
1891
  m({
1892
1892
  position: n,
@@ -1927,19 +1927,19 @@ function rn({ editor: e, onClose: t }) {
1927
1927
  className: "flex items-center justify-between pl-3 pr-1.5 py-1.5 border-b border-default-100 shrink-0",
1928
1928
  children: [/* @__PURE__ */ O("span", {
1929
1929
  className: "flex items-center gap-1.5 text-xs font-medium text-default-500",
1930
- children: [/* @__PURE__ */ D(Rt, { className: "text-primary" }), f("editor.ai.trigger")]
1930
+ children: [/* @__PURE__ */ D(zt, { className: "text-primary" }), f("editor.ai.trigger")]
1931
1931
  }), /* @__PURE__ */ D("button", {
1932
1932
  type: "button",
1933
1933
  onClick: t,
1934
1934
  "aria-label": f("editor.ai.close"),
1935
1935
  title: f("editor.ai.close"),
1936
1936
  className: "flex items-center justify-center w-6 h-6 rounded-md text-default-400 hover:bg-default-100 hover:text-default-700 transition-colors",
1937
- children: /* @__PURE__ */ D(Bt, {})
1937
+ children: /* @__PURE__ */ D(Vt, {})
1938
1938
  })]
1939
1939
  }),
1940
1940
  /* @__PURE__ */ D("div", {
1941
1941
  className: "grid grid-cols-[repeat(auto-fit,minmax(64px,1fr))] gap-1.5 p-2 shrink-0",
1942
- children: Yt.map(({ mode: e, labelKey: t, descKey: r, icon: i }) => /* @__PURE__ */ O("button", {
1942
+ children: Xt.map(({ mode: e, labelKey: t, descKey: r, icon: i }) => /* @__PURE__ */ O("button", {
1943
1943
  type: "button",
1944
1944
  className: `flex flex-col items-center gap-1 px-1 py-2 rounded-xl border transition-colors ${n === e ? "border-primary/40 bg-primary/10 text-primary" : "border-default-200 text-default-600 hover:bg-default-100 hover:text-default-900"}`,
1945
1945
  onClick: () => y(e),
@@ -2082,7 +2082,7 @@ function rn({ editor: e, onClose: t }) {
2082
2082
  children: Object.entries(N).map(([e, t]) => /* @__PURE__ */ O("li", {
2083
2083
  className: "text-sm text-default-700",
2084
2084
  children: [
2085
- f(Zt[e] ?? e),
2085
+ f(Qt[e] ?? e),
2086
2086
  " ×",
2087
2087
  t
2088
2088
  ]
@@ -2114,19 +2114,19 @@ function rn({ editor: e, onClose: t }) {
2114
2114
  }
2115
2115
  //#endregion
2116
2116
  //#region src/editor/attachment-limits.ts
2117
- var an = /* @__PURE__ */ new Set([
2117
+ var on = /* @__PURE__ */ new Set([
2118
2118
  "attachmentEmbed",
2119
2119
  "videoEmbed",
2120
2120
  "audioEmbed",
2121
2121
  "image"
2122
2122
  ]);
2123
- function on(e) {
2123
+ function sn(e) {
2124
2124
  let t = 0;
2125
2125
  return e.descendants((e) => {
2126
- an.has(e.type.name) && (t += Number(e.attrs?.size) || 0);
2126
+ on.has(e.type.name) && (t += Number(e.attrs?.size) || 0);
2127
2127
  }), t;
2128
2128
  }
2129
- function sn(e) {
2129
+ function cn(e) {
2130
2130
  if (!Number.isFinite(e) || e <= 0) return "0 B";
2131
2131
  let t = [
2132
2132
  "B",
@@ -2137,41 +2137,41 @@ function sn(e) {
2137
2137
  ], n = Math.min(t.length - 1, Math.floor(Math.log(e) / Math.log(1024))), r = e / 1024 ** n;
2138
2138
  return `${n === 0 || r >= 100 ? `${Math.round(r)}` : `${Math.round(r * 10) / 10}`} ${t[n]}`;
2139
2139
  }
2140
- function cn(e) {
2140
+ function ln(e) {
2141
2141
  return (e?.storage)?.qingwuUI?.limits;
2142
2142
  }
2143
- function ln(e, t, n) {
2143
+ function un(e, t, n) {
2144
2144
  let { maxAttachmentSize: r, maxTotalAttachmentSize: i } = n;
2145
- if (r && t.size > r) return `单文件大小不能超过 ${sn(r)}(当前 ${sn(t.size)})`;
2145
+ if (r && t.size > r) return `单文件大小不能超过 ${cn(r)}(当前 ${cn(t.size)})`;
2146
2146
  if (i) {
2147
- let n = on(e) + t.size;
2148
- if (n > i) return `附件总大小不能超过 ${sn(i)}(当前合计 ${sn(n)})`;
2147
+ let n = sn(e) + t.size;
2148
+ if (n > i) return `附件总大小不能超过 ${cn(i)}(当前合计 ${cn(n)})`;
2149
2149
  }
2150
2150
  return null;
2151
2151
  }
2152
2152
  //#endregion
2153
2153
  //#region src/editor/utils/delete-confirm.ts
2154
- var un = !1, dn = null, fn = 5e3;
2155
- function pn() {
2156
- return un;
2154
+ var dn = !1, fn = null, pn = 5e3;
2155
+ function mn() {
2156
+ return dn;
2157
2157
  }
2158
2158
  function $(e) {
2159
- un = e, dn &&= (clearTimeout(dn), null), e && (dn = setTimeout(() => {
2160
- un = !1, dn = null;
2161
- }, fn));
2159
+ dn = e, fn &&= (clearTimeout(fn), null), e && (fn = setTimeout(() => {
2160
+ dn = !1, fn = null;
2161
+ }, pn));
2162
2162
  }
2163
- var mn = null;
2164
- function hn(e) {
2165
- mn = e;
2163
+ var hn = null;
2164
+ function gn(e) {
2165
+ hn = e;
2166
2166
  }
2167
- function gn() {
2168
- return mn;
2167
+ function _n() {
2168
+ return hn;
2169
2169
  }
2170
2170
  //#endregion
2171
2171
  //#region src/editor/utils/delete-confirm-dialog.tsx
2172
- var _n = 300;
2173
- function vn({ open: e, title: t, message: n, confirmText: r = "删除", cancelText: i = "取消", onConfirm: a, onCancel: o }) {
2174
- let [s, c] = T(!1), l = w(!1), u = gn();
2172
+ var vn = 300;
2173
+ function yn({ open: e, title: t, message: n, confirmText: r = "删除", cancelText: i = "取消", onConfirm: a, onCancel: o }) {
2174
+ let [s, c] = T(!1), l = w(!1), u = _n();
2175
2175
  return x(() => {
2176
2176
  if (!e) {
2177
2177
  l.current = !1;
@@ -2241,7 +2241,7 @@ function vn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
2241
2241
  await a();
2242
2242
  } finally {
2243
2243
  let t = Date.now() - e;
2244
- t < _n && await new Promise((e) => setTimeout(e, _n - t)), c(!1), o();
2244
+ t < vn && await new Promise((e) => setTimeout(e, vn - t)), c(!1), o();
2245
2245
  }
2246
2246
  },
2247
2247
  disabled: s,
@@ -2254,13 +2254,13 @@ function vn({ open: e, title: t, message: n, confirmText: r = "删除", cancelTe
2254
2254
  }
2255
2255
  //#endregion
2256
2256
  //#region src/editor/extensions/image-view.tsx
2257
- function yn(e) {
2257
+ function bn(e) {
2258
2258
  return /^(\.\.?\/|[a-zA-Z]:\\|file:\/\/)/.test(e) ? !0 : !(/^[a-z]+:\/\//i.test(e) || e.startsWith("/") || e.startsWith("data:") || e.startsWith("blob:"));
2259
2259
  }
2260
- function bn({ node: e, deleteNode: t, editor: r }) {
2260
+ function xn({ node: e, deleteNode: t, editor: r }) {
2261
2261
  let [i, a] = T(!1), [o, s] = T(!1), [c, l] = T(!1), u = w(!1), [d, f] = T(!1), p = e.attrs.src || "", m = e.attrs.alt || "", h = e.attrs.width || null, g = e.attrs.height || null, _ = w(null), v = w(null), y = w(null), S = w(null), C = w(null), E = w(!1), k = w(!1), A = w(0), [j, M] = T(p), N = r?.isEditable ?? !0, P = b(() => {
2262
2262
  o || (A.current = window.scrollY, a(!0));
2263
- }, [o]), F = b(() => {
2263
+ }, [o]), I = b(() => {
2264
2264
  a(!1), requestAnimationFrame(() => window.scrollTo(0, A.current));
2265
2265
  }, []), L = b(() => {
2266
2266
  let e = _.current;
@@ -2310,8 +2310,8 @@ function bn({ node: e, deleteNode: t, editor: r }) {
2310
2310
  };
2311
2311
  return document.addEventListener("fullscreenchange", e), () => document.removeEventListener("fullscreenchange", e);
2312
2312
  }, []);
2313
- let te = o || yn(p);
2314
- return /* @__PURE__ */ O(I, {
2313
+ let te = o || bn(p);
2314
+ return /* @__PURE__ */ O(F, {
2315
2315
  as: "div",
2316
2316
  className: "image-node-view group/img",
2317
2317
  contentEditable: !1,
@@ -2323,7 +2323,7 @@ function bn({ node: e, deleteNode: t, editor: r }) {
2323
2323
  type: "button",
2324
2324
  className: "img-ctrl-btn img-ctrl-btn--del image-placeholder-del",
2325
2325
  onClick: () => {
2326
- pn() || ($(!0), f(!0));
2326
+ mn() || ($(!0), f(!0));
2327
2327
  },
2328
2328
  title: "删除",
2329
2329
  children: /* @__PURE__ */ D("svg", {
@@ -2355,7 +2355,7 @@ function bn({ node: e, deleteNode: t, editor: r }) {
2355
2355
  }),
2356
2356
  /* @__PURE__ */ D("span", {
2357
2357
  className: "image-placeholder-text",
2358
- children: yn(p) ? "本地图片无法加载" : "图片加载失败"
2358
+ children: bn(p) ? "本地图片无法加载" : "图片加载失败"
2359
2359
  }),
2360
2360
  /* @__PURE__ */ D("span", {
2361
2361
  className: "image-placeholder-path",
@@ -2436,7 +2436,7 @@ function bn({ node: e, deleteNode: t, editor: r }) {
2436
2436
  type: "button",
2437
2437
  className: "img-ctrl-btn img-ctrl-btn--del",
2438
2438
  onClick: () => {
2439
- pn() || ($(!0), f(!0));
2439
+ mn() || ($(!0), f(!0));
2440
2440
  },
2441
2441
  title: "删除",
2442
2442
  children: /* @__PURE__ */ D("svg", {
@@ -2458,7 +2458,7 @@ function bn({ node: e, deleteNode: t, editor: r }) {
2458
2458
  }),
2459
2459
  i && !te && /* @__PURE__ */ O("div", {
2460
2460
  className: "image-lightbox",
2461
- onClick: F,
2461
+ onClick: I,
2462
2462
  children: [/* @__PURE__ */ O("div", {
2463
2463
  className: "image-lightbox-bar",
2464
2464
  children: [/* @__PURE__ */ D("button", {
@@ -2482,7 +2482,7 @@ function bn({ node: e, deleteNode: t, editor: r }) {
2482
2482
  }), /* @__PURE__ */ D("button", {
2483
2483
  type: "button",
2484
2484
  className: "image-lightbox-bar-btn",
2485
- onClick: F,
2485
+ onClick: I,
2486
2486
  title: "关闭",
2487
2487
  children: /* @__PURE__ */ D("svg", {
2488
2488
  width: "18",
@@ -2523,7 +2523,7 @@ function bn({ node: e, deleteNode: t, editor: r }) {
2523
2523
  }
2524
2524
  })]
2525
2525
  }),
2526
- /* @__PURE__ */ D(vn, {
2526
+ /* @__PURE__ */ D(yn, {
2527
2527
  open: d,
2528
2528
  title: "确认删除图片",
2529
2529
  message: te ? "该图片无法在当前环境加载,仅从编辑器中移除该图片节点,不影响存储文件。" : "此操作将同时删除对象存储中的文件,不可撤销。",
@@ -2532,7 +2532,7 @@ function bn({ node: e, deleteNode: t, editor: r }) {
2532
2532
  },
2533
2533
  onConfirm: async () => {
2534
2534
  if (!te) try {
2535
- await Vt(p);
2535
+ await Ht(p);
2536
2536
  } catch {}
2537
2537
  $(!1), await new Promise((e) => setTimeout(e, 300)), t();
2538
2538
  }
@@ -2542,7 +2542,7 @@ function bn({ node: e, deleteNode: t, editor: r }) {
2542
2542
  }
2543
2543
  //#endregion
2544
2544
  //#region src/editor/embeds/attachment-view.tsx
2545
- var xn = y(() => import("@file-viewer/react")), Sn = /* @__PURE__ */ new Set(), Cn = {
2545
+ var Sn = y(() => import("@file-viewer/react")), Cn = /* @__PURE__ */ new Set(), wn = {
2546
2546
  rendererMode: "replace",
2547
2547
  autoRenderers: !0,
2548
2548
  theme: "light",
@@ -2571,7 +2571,7 @@ var xn = y(() => import("@file-viewer/react")), Sn = /* @__PURE__ */ new Set(),
2571
2571
  cache: !0,
2572
2572
  workerTimeoutMs: 3e4
2573
2573
  }
2574
- }, wn = {
2574
+ }, Tn = {
2575
2575
  pdf: "pdf",
2576
2576
  docx: "word",
2577
2577
  docm: "word",
@@ -2626,7 +2626,7 @@ var xn = y(() => import("@file-viewer/react")), Sn = /* @__PURE__ */ new Set(),
2626
2626
  xml: "text",
2627
2627
  yml: "text",
2628
2628
  yaml: "text"
2629
- }, Tn = {
2629
+ }, En = {
2630
2630
  pdf: () => import("@file-viewer/renderer-pdf").then((e) => e.pdfRenderer),
2631
2631
  word: () => import("@file-viewer/renderer-word").then((e) => e.wordRenderer),
2632
2632
  spreadsheet: () => import("@file-viewer/renderer-spreadsheet").then((e) => e.spreadsheetRenderer),
@@ -2634,10 +2634,10 @@ var xn = y(() => import("@file-viewer/react")), Sn = /* @__PURE__ */ new Set(),
2634
2634
  archive: () => import("@file-viewer/renderer-archive").then((e) => e.archiveRenderer),
2635
2635
  text: () => import("@file-viewer/renderer-text").then((e) => e.textRenderer)
2636
2636
  };
2637
- function En(e) {
2637
+ function Dn(e) {
2638
2638
  return e ? e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1048576).toFixed(1)} MB` : "";
2639
2639
  }
2640
- function Dn(e) {
2640
+ function On(e) {
2641
2641
  let t = e.split(".").pop()?.toLowerCase() || "", n = {
2642
2642
  pdf: {
2643
2643
  label: "PDF",
@@ -2810,22 +2810,22 @@ function Dn(e) {
2810
2810
  ]
2811
2811
  });
2812
2812
  }
2813
- function On(e) {
2813
+ function kn(e) {
2814
2814
  return e.split(".").pop()?.toLowerCase() || "";
2815
2815
  }
2816
- function kn(e) {
2816
+ function An(e) {
2817
2817
  let t = e.split(".").pop()?.toLowerCase() || "";
2818
2818
  return /^(pdf|docx?|dotx?|xlsx?|xltx?|pptx?|potx?|txt|md|html?|csv|json|xml|yml|yaml|log|zip|rar|7z|tar|gz|odt|ods|odp|rtf|xlsm|xlsb|ppsx|numbers|tgz|bz2|xz|zst|js|ts|tsx|py|sh|sql)$/.test(t);
2819
2819
  }
2820
- function An(e) {
2820
+ function jn(e) {
2821
2821
  return !!e && !e.startsWith("file:");
2822
2822
  }
2823
- function jn(e) {
2823
+ function Mn(e) {
2824
2824
  return btoa(encodeURIComponent(e)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
2825
2825
  }
2826
- async function Mn(e, t) {
2826
+ async function Nn(e, t) {
2827
2827
  try {
2828
- let n = jn(e), r = await fetch(`/api/preview/${n}`, {
2828
+ let n = Mn(e), r = await fetch(`/api/preview/${n}`, {
2829
2829
  signal: t,
2830
2830
  cache: "no-store"
2831
2831
  });
@@ -2837,7 +2837,7 @@ async function Mn(e, t) {
2837
2837
  return null;
2838
2838
  }
2839
2839
  }
2840
- function Nn(e, t, n) {
2840
+ function Pn(e, t, n) {
2841
2841
  return new Promise((r, i) => {
2842
2842
  let a = new XMLHttpRequest();
2843
2843
  if (a.open("GET", e, !0), a.responseType = "arraybuffer", t) {
@@ -2875,64 +2875,64 @@ function Nn(e, t, n) {
2875
2875
  a.send();
2876
2876
  });
2877
2877
  }
2878
- function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
2879
- let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() => Sn.has(s)), [u, d] = T(null), [p, m] = T(null), [h, g] = T(!1), [_, y] = T(null), [S, E] = T(!1), [k, A] = T(null), j = w(null), M = w(null), N = w(null), P = w(0), F = w(!1), L = w(null), ee = w(0), [te, ne] = T(!1), R = w(null), [re, ie] = T(0), [z, B] = T("none"), [ae, oe] = T(void 0), [se, ce] = T(!1), V = e.attrs.src || "", H = e.attrs.name || V && V.split("/").pop()?.split("?")[0] || (V ? "attachment" : f("editor.attachment.lost")), le = e.attrs.size || 0, U = On(H), W = !V;
2878
+ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
2879
+ let o = a?.isEditable ?? !0, s = e.attrs.src || "", [c, l] = T(() => Cn.has(s)), [u, d] = T(null), [p, m] = T(null), [h, g] = T(!1), [_, y] = T(null), [S, E] = T(!1), [k, A] = T(null), j = w(null), M = w(null), N = w(null), P = w(0), I = w(!1), L = w(null), ee = w(0), [te, ne] = T(!1), R = w(null), [re, ie] = T(0), [z, B] = T("none"), [V, H] = T(void 0), [ae, oe] = T(!1), U = e.attrs.src || "", W = e.attrs.name || U && U.split("/").pop()?.split("?")[0] || (U ? "attachment" : f("editor.attachment.lost")), G = e.attrs.size || 0, K = kn(W), q = !U;
2880
2880
  x(() => {
2881
2881
  if (!c) {
2882
- oe(void 0), ce(!1);
2882
+ H(void 0), oe(!1);
2883
2883
  return;
2884
2884
  }
2885
- let e = wn[U];
2885
+ let e = Tn[K];
2886
2886
  if (!e) {
2887
- oe(void 0), ce(!1);
2887
+ H(void 0), oe(!1);
2888
2888
  return;
2889
2889
  }
2890
2890
  let t = !0;
2891
- return oe(void 0), ce(!1), Tn[e]().then((e) => {
2892
- t && oe(e);
2891
+ return H(void 0), oe(!1), En[e]().then((e) => {
2892
+ t && H(e);
2893
2893
  }).catch((n) => {
2894
- console.error(`[attachment] renderer "${e}" load failed:`, n), t && ce(!0);
2894
+ console.error(`[attachment] renderer "${e}" load failed:`, n), t && oe(!0);
2895
2895
  }), () => {
2896
2896
  t = !1;
2897
2897
  };
2898
- }, [c, U]);
2899
- let ue = C(() => ({
2900
- ...Cn,
2901
- renderers: ae ? [ae] : [],
2898
+ }, [c, K]);
2899
+ let se = C(() => ({
2900
+ ...wn,
2901
+ renderers: V ? [V] : [],
2902
2902
  rendererMode: "replace"
2903
- }), [ae]), de = b((e) => {
2903
+ }), [V]), ce = b((e) => {
2904
2904
  l((t) => {
2905
2905
  let n = typeof e == "function" ? e(t) : e;
2906
- return V && (n ? Sn.add(V) : Sn.delete(V)), n;
2906
+ return U && (n ? Cn.add(U) : Cn.delete(U)), n;
2907
2907
  });
2908
- }, [V]);
2908
+ }, [U]);
2909
2909
  x(() => {
2910
- l(V ? Sn.has(V) : !1);
2911
- }, [V]);
2912
- let G = b(() => {
2913
- F.current = !0, de(!0), window.setTimeout(() => {
2914
- window.scrollTo(0, P.current), L.current && (L.current.scrollTop = ee.current), F.current && de(!0), F.current = !1;
2910
+ l(U ? Cn.has(U) : !1);
2911
+ }, [U]);
2912
+ let J = b(() => {
2913
+ I.current = !0, ce(!0), window.setTimeout(() => {
2914
+ window.scrollTo(0, P.current), L.current && (L.current.scrollTop = ee.current), I.current && ce(!0), I.current = !1;
2915
2915
  }, 0);
2916
- }, [de]), fe = b(async () => {
2917
- z === "web" ? (B("none"), document.body.style.overflow = "", G()) : (z === "native" && document.fullscreenElement && await document.exitFullscreen(), P.current = window.scrollY, ee.current = L.current?.scrollTop ?? 0, document.body.style.overflow = "hidden", B("web"));
2918
- }, [z]), pe = b(async () => {
2916
+ }, [ce]), le = b(async () => {
2917
+ z === "web" ? (B("none"), document.body.style.overflow = "", J()) : (z === "native" && document.fullscreenElement && await document.exitFullscreen(), P.current = window.scrollY, ee.current = L.current?.scrollTop ?? 0, document.body.style.overflow = "hidden", B("web"));
2918
+ }, [z]), ue = b(async () => {
2919
2919
  let e = M.current;
2920
2920
  e && (z === "native" ? await document.exitFullscreen() : (z === "web" && (B("none"), document.body.style.overflow = ""), P.current = window.scrollY, ee.current = L.current?.scrollTop ?? 0, await e.requestFullscreen(), B("native")));
2921
- }, [z, G]), me = b(() => {
2922
- z === "none" && (F.current || de((e) => !e));
2921
+ }, [z, J]), de = b(() => {
2922
+ z === "none" && (I.current || ce((e) => !e));
2923
2923
  }, [z]);
2924
2924
  x(() => {
2925
2925
  let e = () => {
2926
- document.fullscreenElement || (z === "native" && B("none"), G());
2926
+ document.fullscreenElement || (z === "native" && B("none"), J());
2927
2927
  }, t = (e) => {
2928
- e.key === "Escape" && z === "web" && (B("none"), document.body.style.overflow = "", G());
2928
+ e.key === "Escape" && z === "web" && (B("none"), document.body.style.overflow = "", J());
2929
2929
  };
2930
2930
  return document.addEventListener("fullscreenchange", e), window.addEventListener("keydown", t), () => {
2931
2931
  document.removeEventListener("fullscreenchange", e), window.removeEventListener("keydown", t);
2932
2932
  };
2933
- }, [z, G]), x(() => {
2933
+ }, [z, J]), x(() => {
2934
2934
  let e = (e) => {
2935
- if (!(e.key !== "Backspace" && e.key !== "Delete") && o && i && !pn()) {
2935
+ if (!(e.key !== "Backspace" && e.key !== "Delete") && o && i && !mn()) {
2936
2936
  if (e.preventDefault(), e.stopPropagation(), a) {
2937
2937
  let { from: e, to: t } = a.state.selection;
2938
2938
  R.current = {
@@ -2949,29 +2949,29 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
2949
2949
  a,
2950
2950
  o
2951
2951
  ]), x(() => {
2952
- if (!c || !An(V)) {
2952
+ if (!c || !jn(U)) {
2953
2953
  d(null), y(null), N.current = null;
2954
2954
  return;
2955
2955
  }
2956
- if (N.current === V) return;
2956
+ if (N.current === U) return;
2957
2957
  let e = new AbortController(), r = !0;
2958
2958
  return g(!0), y(null), (async () => {
2959
- let i = V.includes("?X-Amz-"), a = null, o = null;
2960
- if (!a && !i && (a = await Mn(V, e.signal)), !a && !i) try {
2961
- let n = await t(V);
2962
- n && (a = await Mn(n, e.signal) || await Nn(n, void 0, e.signal));
2959
+ let i = U.includes("?X-Amz-"), a = null, o = null;
2960
+ if (!a && !i && (a = await Nn(U, e.signal)), !a && !i) try {
2961
+ let n = await t(U);
2962
+ n && (a = await Nn(n, e.signal) || await Pn(n, void 0, e.signal));
2963
2963
  } catch (e) {
2964
2964
  console.warn("[attachment] signPreviewUrl failed:", e);
2965
2965
  }
2966
2966
  if (!a && !i) try {
2967
- let t = await n(V);
2967
+ let t = await n(U);
2968
2968
  if (t) {
2969
2969
  let n = { "X-Requested-With": "XMLHttpRequest" };
2970
2970
  t.forEach((e, t) => {
2971
2971
  n[t] = e;
2972
2972
  });
2973
2973
  try {
2974
- a = await Nn(V, n, e.signal);
2974
+ a = await Pn(U, n, e.signal);
2975
2975
  } catch (e) {
2976
2976
  console.warn("[attachment] signed headers XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
2977
2977
  }
@@ -2980,18 +2980,18 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
2980
2980
  console.warn("[attachment] signPreviewUrlHeaders failed:", e);
2981
2981
  }
2982
2982
  if (!a) try {
2983
- a = await Nn(V, i ? void 0 : { "X-Requested-With": "XMLHttpRequest" }, e.signal);
2983
+ a = await Pn(U, i ? void 0 : { "X-Requested-With": "XMLHttpRequest" }, e.signal);
2984
2984
  } catch (e) {
2985
2985
  console.warn("[attachment] plain XHR failed:", e), o = e instanceof Error ? e : Error(String(e));
2986
2986
  }
2987
2987
  if (!a) throw o || /* @__PURE__ */ Error("所有 fetch 方法均失败");
2988
2988
  if (!r) return;
2989
- d(a), N.current = V;
2989
+ d(a), N.current = U;
2990
2990
  let s = URL.createObjectURL(new Blob([a], { type: "application/octet-stream" }));
2991
2991
  m(s), g(!1);
2992
2992
  })().catch((e) => {
2993
2993
  if (r && !(e instanceof DOMException && e.name === "AbortError")) {
2994
- if (N.current === V) {
2994
+ if (N.current === U) {
2995
2995
  g(!1);
2996
2996
  return;
2997
2997
  }
@@ -3000,49 +3000,49 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
3000
3000
  }), () => {
3001
3001
  r = !1, e.abort();
3002
3002
  };
3003
- }, [c, V]), x(() => () => {
3003
+ }, [c, U]), x(() => () => {
3004
3004
  p && URL.revokeObjectURL(p), d(null);
3005
3005
  }, []), x(() => () => {
3006
3006
  p && URL.revokeObjectURL(p), m(null), d(null), N.current = null;
3007
- }, [V]), x(() => {
3007
+ }, [U]), x(() => {
3008
3008
  if (k !== "success" && k !== "error") return;
3009
3009
  let e = window.setTimeout(() => A(null), 2400);
3010
3010
  return () => window.clearTimeout(e);
3011
3011
  }, [k]);
3012
- let K = b(async () => {
3012
+ let fe = b(async () => {
3013
3013
  E(!0), A("loading");
3014
3014
  try {
3015
3015
  if (p) {
3016
3016
  let e = document.createElement("a");
3017
- e.href = p, e.download = H, document.body.appendChild(e), e.click(), document.body.removeChild(e), A("success");
3017
+ e.href = p, e.download = W, document.body.appendChild(e), e.click(), document.body.removeChild(e), A("success");
3018
3018
  return;
3019
3019
  }
3020
- let e = V.includes("?X-Amz-"), r = null;
3020
+ let e = U.includes("?X-Amz-"), r = null;
3021
3021
  if (!e) try {
3022
- let e = await t(V);
3022
+ let e = await t(U);
3023
3023
  e && (r = await fetch(e, { headers: { "X-Requested-With": "XMLHttpRequest" } }), r.ok || (r = null));
3024
3024
  } catch {}
3025
3025
  if (!r && !e) try {
3026
- let e = await n(V);
3027
- e && (r = await fetch(V, { headers: (() => {
3026
+ let e = await n(U);
3027
+ e && (r = await fetch(U, { headers: (() => {
3028
3028
  let t = new Headers(e);
3029
3029
  return t.set("X-Requested-With", "XMLHttpRequest"), t;
3030
3030
  })() }), r.ok || (r = null));
3031
3031
  } catch {}
3032
- if (r ||= await fetch(V, { headers: { "X-Requested-With": "XMLHttpRequest" } }), !r || !r.ok) throw Error("下载失败");
3032
+ if (r ||= await fetch(U, { headers: { "X-Requested-With": "XMLHttpRequest" } }), !r || !r.ok) throw Error("下载失败");
3033
3033
  let i = await r.blob(), a = URL.createObjectURL(i), o = document.createElement("a");
3034
- o.href = a, o.download = H, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(a), A("success");
3034
+ o.href = a, o.download = W, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(a), A("success");
3035
3035
  } catch (e) {
3036
3036
  console.error("[attachment] download failed:", e), A("error");
3037
3037
  } finally {
3038
3038
  E(!1);
3039
3039
  }
3040
3040
  }, [
3041
- V,
3042
- H,
3041
+ U,
3042
+ W,
3043
3043
  p
3044
3044
  ]);
3045
- return /* @__PURE__ */ O(I, {
3045
+ return /* @__PURE__ */ O(F, {
3046
3046
  ref: j,
3047
3047
  as: "div",
3048
3048
  className: `attachment-embed group/att ${i ? "is-selected" : ""}`,
@@ -3059,7 +3059,7 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
3059
3059
  className: "att-info",
3060
3060
  children: [/* @__PURE__ */ D("span", {
3061
3061
  className: "att-icon",
3062
- children: W ? /* @__PURE__ */ O("svg", {
3062
+ children: q ? /* @__PURE__ */ O("svg", {
3063
3063
  width: "22",
3064
3064
  height: "22",
3065
3065
  viewBox: "0 0 24 24",
@@ -3075,15 +3075,15 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
3075
3075
  /* @__PURE__ */ D("path", { d: "M12 9v4" }),
3076
3076
  /* @__PURE__ */ D("path", { d: "M12 17h.01" })
3077
3077
  ]
3078
- }) : Dn(H)
3078
+ }) : On(W)
3079
3079
  }), /* @__PURE__ */ O("div", {
3080
3080
  className: "att-meta",
3081
3081
  children: [/* @__PURE__ */ D("span", {
3082
3082
  className: "att-name",
3083
- children: H
3084
- }), le > 0 && /* @__PURE__ */ D("span", {
3083
+ children: W
3084
+ }), G > 0 && /* @__PURE__ */ D("span", {
3085
3085
  className: "att-size",
3086
- children: En(le)
3086
+ children: Dn(G)
3087
3087
  })]
3088
3088
  })]
3089
3089
  }), /* @__PURE__ */ O("div", {
@@ -3136,11 +3136,11 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
3136
3136
  }), /* @__PURE__ */ O("div", {
3137
3137
  className: "att-actions",
3138
3138
  children: [
3139
- V && kn(H) && /* @__PURE__ */ D("button", {
3139
+ U && An(W) && /* @__PURE__ */ D("button", {
3140
3140
  type: "button",
3141
3141
  className: "att-btn",
3142
3142
  onMouseDown: (e) => {
3143
- e.preventDefault(), e.stopPropagation(), me();
3143
+ e.preventDefault(), e.stopPropagation(), de();
3144
3144
  },
3145
3145
  title: f("editor.attachment.preview"),
3146
3146
  "aria-label": f("editor.attachment.preview"),
@@ -3166,8 +3166,8 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
3166
3166
  /* @__PURE__ */ D("button", {
3167
3167
  type: "button",
3168
3168
  className: "att-btn",
3169
- onClick: K,
3170
- disabled: S || W,
3169
+ onClick: fe,
3170
+ disabled: S || q,
3171
3171
  title: S ? "正在准备下载" : f("editor.attachment.download"),
3172
3172
  "aria-label": S ? "正在准备下载" : f("editor.attachment.download"),
3173
3173
  children: /* @__PURE__ */ D("svg", {
@@ -3189,7 +3189,7 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
3189
3189
  type: "button",
3190
3190
  className: "att-btn att-btn--del",
3191
3191
  onClick: () => {
3192
- !o || pn() || ($(!0), ne(!0));
3192
+ !o || mn() || ($(!0), ne(!0));
3193
3193
  },
3194
3194
  title: f("editor.attachment.delete"),
3195
3195
  "aria-label": f("editor.attachment.delete"),
@@ -3230,7 +3230,7 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
3230
3230
  children: h && !u && !p ? /* @__PURE__ */ D("div", {
3231
3231
  className: "flex items-center justify-center h-full text-default-400 text-sm",
3232
3232
  children: f("editor.attachment.loadingPreview")
3233
- }) : (_ || se) && !u && !p ? /* @__PURE__ */ O("div", {
3233
+ }) : (_ || ae) && !u && !p ? /* @__PURE__ */ O("div", {
3234
3234
  className: "flex h-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-default-500",
3235
3235
  children: [/* @__PURE__ */ D("div", {
3236
3236
  className: "font-medium text-default-700",
@@ -3245,15 +3245,15 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
3245
3245
  style: { background: "#fff" },
3246
3246
  children: f("editor.attachment.loadingPreview")
3247
3247
  }),
3248
- children: u || p || V ? ae ? /* @__PURE__ */ D(xn, {
3248
+ children: u || p || U ? V ? /* @__PURE__ */ D(Sn, {
3249
3249
  buffer: u || void 0,
3250
- url: p || V,
3251
- name: H,
3252
- filename: H,
3253
- type: U,
3254
- size: le || u?.byteLength || 0,
3255
- options: ue
3256
- }, `${V}-${re}`) : /* @__PURE__ */ D("div", {
3250
+ url: p || U,
3251
+ name: W,
3252
+ filename: W,
3253
+ type: K,
3254
+ size: G || u?.byteLength || 0,
3255
+ options: se
3256
+ }, `${U}-${re}`) : /* @__PURE__ */ D("div", {
3257
3257
  className: "flex h-full items-center justify-center text-sm text-default-400",
3258
3258
  children: "正在加载预览引擎..."
3259
3259
  }) : /* @__PURE__ */ D("div", {
@@ -3280,7 +3280,7 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
3280
3280
  },
3281
3281
  children: [/* @__PURE__ */ D("button", {
3282
3282
  type: "button",
3283
- onClick: fe,
3283
+ onClick: le,
3284
3284
  title: z === "web" ? "退出网页全屏" : "网页全屏",
3285
3285
  "aria-label": z === "web" ? "退出网页全屏" : "网页全屏",
3286
3286
  style: {
@@ -3318,7 +3318,7 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
3318
3318
  })
3319
3319
  }), /* @__PURE__ */ D("button", {
3320
3320
  type: "button",
3321
- onClick: pe,
3321
+ onClick: ue,
3322
3322
  title: z === "native" ? "退出全屏" : "全屏",
3323
3323
  "aria-label": z === "native" ? "退出全屏" : "全屏",
3324
3324
  style: {
@@ -3357,10 +3357,10 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
3357
3357
  })]
3358
3358
  })]
3359
3359
  })]
3360
- }), /* @__PURE__ */ D(vn, {
3360
+ }), /* @__PURE__ */ D(yn, {
3361
3361
  open: te,
3362
3362
  title: "确认删除附件",
3363
- message: W ? "此操作将删除该附件节点,不可撤销。" : `此操作将同时删除对象存储中的文件(${H}),不可撤销。`,
3363
+ message: q ? "此操作将删除该附件节点,不可撤销。" : `此操作将同时删除对象存储中的文件(${W}),不可撤销。`,
3364
3364
  onCancel: () => {
3365
3365
  $(!1), ne(!1);
3366
3366
  },
@@ -3369,12 +3369,12 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
3369
3369
  if (a) {
3370
3370
  let e = R.current, t = e?.from ?? a.state.selection.from, n = e?.to ?? a.state.selection.to, r = [];
3371
3371
  a.state.doc.nodesBetween(t, n, (e) => {
3372
- e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(Vt(e.attrs.src));
3372
+ e.type.name === "attachmentEmbed" && e.attrs?.src && r.push(Ht(e.attrs.src));
3373
3373
  }), await Promise.all(r), $(!1), await new Promise((e) => setTimeout(e, 300)), a.chain().focus().setTextSelection({
3374
3374
  from: t,
3375
3375
  to: n
3376
3376
  }).deleteSelection().run();
3377
- } else await Vt(V), $(!1), await new Promise((e) => setTimeout(e, 300)), r();
3377
+ } else await Ht(U), $(!1), await new Promise((e) => setTimeout(e, 300)), r();
3378
3378
  } catch {
3379
3379
  $(!1);
3380
3380
  }
@@ -3384,13 +3384,13 @@ function Pn({ node: e, deleteNode: r, selected: i, editor: a }) {
3384
3384
  }
3385
3385
  //#endregion
3386
3386
  //#region src/editor/embeds/attachment.ts
3387
- var Fn = re.create({
3387
+ var In = re.create({
3388
3388
  name: "attachmentEmbed",
3389
3389
  group: "block",
3390
3390
  atom: !0,
3391
3391
  inline: !1,
3392
3392
  addNodeView() {
3393
- return L(Pn);
3393
+ return I(Fn);
3394
3394
  },
3395
3395
  addAttributes() {
3396
3396
  return {
@@ -3439,7 +3439,7 @@ var Fn = re.create({
3439
3439
  });
3440
3440
  //#endregion
3441
3441
  //#region src/editor/embeds/audio-view.tsx
3442
- function In({ node: e, deleteNode: t, editor: r }) {
3442
+ function Ln({ node: e, deleteNode: t, editor: r }) {
3443
3443
  let i = e.attrs.src || "", a = e.attrs.name || i.split("/").pop()?.split("?")[0] || "audio", [o, s] = T(!1), c = r?.isEditable ?? !0;
3444
3444
  x(() => () => {
3445
3445
  i.startsWith("blob:") && URL.revokeObjectURL(i);
@@ -3471,7 +3471,7 @@ function In({ node: e, deleteNode: t, editor: r }) {
3471
3471
  })(), () => {
3472
3472
  e = !0, m.current &&= (URL.revokeObjectURL(m.current), null);
3473
3473
  };
3474
- }, [i]), /* @__PURE__ */ O(I, {
3474
+ }, [i]), /* @__PURE__ */ O(F, {
3475
3475
  as: "div",
3476
3476
  className: "audio-embed group/audio",
3477
3477
  style: { margin: "1rem 0" },
@@ -3505,7 +3505,7 @@ function In({ node: e, deleteNode: t, editor: r }) {
3505
3505
  type: "button",
3506
3506
  className: "audio-embed-btn audio-embed-btn--del",
3507
3507
  onClick: () => {
3508
- pn() || ($(!0), s(!0));
3508
+ mn() || ($(!0), s(!0));
3509
3509
  },
3510
3510
  title: "删除",
3511
3511
  children: /* @__PURE__ */ D("svg", {
@@ -3551,7 +3551,7 @@ function In({ node: e, deleteNode: t, editor: r }) {
3551
3551
  }), "音频文件缺失"]
3552
3552
  })
3553
3553
  })]
3554
- }), /* @__PURE__ */ D(vn, {
3554
+ }), /* @__PURE__ */ D(yn, {
3555
3555
  open: o,
3556
3556
  title: "确认删除音频",
3557
3557
  message: `此操作将同时删除对象存储中的文件(${a}),不可撤销。`,
@@ -3560,7 +3560,7 @@ function In({ node: e, deleteNode: t, editor: r }) {
3560
3560
  },
3561
3561
  onConfirm: async () => {
3562
3562
  try {
3563
- await Vt(i);
3563
+ await Ht(i);
3564
3564
  } catch {}
3565
3565
  $(!1), await new Promise((e) => setTimeout(e, 300)), t();
3566
3566
  }
@@ -3569,16 +3569,16 @@ function In({ node: e, deleteNode: t, editor: r }) {
3569
3569
  }
3570
3570
  //#endregion
3571
3571
  //#region src/editor/embeds/audio.ts
3572
- function Ln(e) {
3572
+ function Rn(e) {
3573
3573
  return /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|$)/i.test(e) || /\/.*\.(mp3|wav|ogg|flac)/i.test(e);
3574
3574
  }
3575
- var Rn = re.create({
3575
+ var zn = re.create({
3576
3576
  name: "audioEmbed",
3577
3577
  group: "block",
3578
3578
  atom: !0,
3579
3579
  inline: !1,
3580
3580
  addNodeView() {
3581
- return L(In);
3581
+ return I(Ln);
3582
3582
  },
3583
3583
  addProseMirrorPlugins() {
3584
3584
  return [new z({ props: { handlePaste(e, t) {
@@ -3587,7 +3587,7 @@ var Rn = re.create({
3587
3587
  let r = n.split(/\r?\n/);
3588
3588
  for (let n of r) {
3589
3589
  let r = n.trim();
3590
- if (!r || r.includes(" ") || !Ln(r)) continue;
3590
+ if (!r || r.includes(" ") || !Rn(r)) continue;
3591
3591
  t.preventDefault();
3592
3592
  let i = e.state.schema.nodes.audioEmbed.create({ src: r });
3593
3593
  return e.dispatch(e.state.tr.replaceSelectionWith(i)), !0;
@@ -3634,17 +3634,17 @@ var Rn = re.create({
3634
3634
  });
3635
3635
  //#endregion
3636
3636
  //#region src/editor/embeds/video-view.tsx
3637
- function zn(e) {
3637
+ function Bn(e) {
3638
3638
  return e ? /bilibili\.com|BV[a-zA-Z0-9]{10}|av\d+/i.test(e) ? "bilibili" : /xiaohongshu\.com|xhslink\.com/i.test(e) ? "xiaohongshu" : /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|$)/i.test(e) || /\/.*\.(mp4|m3u8|mov|webm|flv|mkv)/i.test(e) ? "direct" : "unknown" : "unknown";
3639
3639
  }
3640
- function Bn(e) {
3640
+ function Vn(e) {
3641
3641
  let t = e.match(/BV[a-zA-Z0-9]{10}/);
3642
3642
  if (t) return t[0];
3643
3643
  let n = e.match(/av(\d+)/i);
3644
3644
  return n ? n[0] : e;
3645
3645
  }
3646
- function Vn({ node: e, deleteNode: t, editor: n }) {
3647
- let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ? zn(r) : i, [o, s] = T(!1), [c, l] = T(!1), [u, d] = T(!1), f = n?.isEditable ?? !0, p = !f && r.startsWith("blob:"), m = /* @__PURE__ */ D(vn, {
3646
+ function Hn({ node: e, deleteNode: t, editor: n }) {
3647
+ let r = e.attrs.src || "", i = e.attrs.source || "unknown", a = i === "unknown" ? Bn(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(yn, {
3648
3648
  open: o,
3649
3649
  title: "确认删除视频",
3650
3650
  message: "此操作将同时删除对象存储中的文件,不可撤销。",
@@ -3653,7 +3653,7 @@ function Vn({ node: e, deleteNode: t, editor: n }) {
3653
3653
  },
3654
3654
  onConfirm: async () => {
3655
3655
  try {
3656
- await Vt(r);
3656
+ await Ht(r);
3657
3657
  } catch {}
3658
3658
  $(!1), await new Promise((e) => setTimeout(e, 300)), t();
3659
3659
  }
@@ -3756,8 +3756,8 @@ function Vn({ node: e, deleteNode: t, editor: n }) {
3756
3756
  }, [a, h]), x(() => {
3757
3757
  u && (_.current?.destroy(), _.current = null);
3758
3758
  }, [u]), a === "bilibili") {
3759
- let e = Bn(r);
3760
- return /* @__PURE__ */ O(I, {
3759
+ let e = Vn(r);
3760
+ return /* @__PURE__ */ O(F, {
3761
3761
  as: "div",
3762
3762
  className: "video-embed video-embed--bilibili group/video",
3763
3763
  style: { margin: "1rem 0" },
@@ -3833,7 +3833,7 @@ function Vn({ node: e, deleteNode: t, editor: n }) {
3833
3833
  className: "video-fs-btn video-fs-btn--del",
3834
3834
  title: "删除",
3835
3835
  onClick: () => {
3836
- pn() || ($(!0), s(!0));
3836
+ mn() || ($(!0), s(!0));
3837
3837
  },
3838
3838
  children: /* @__PURE__ */ D("svg", {
3839
3839
  width: "12",
@@ -3875,7 +3875,7 @@ function Vn({ node: e, deleteNode: t, editor: n }) {
3875
3875
  }), m]
3876
3876
  });
3877
3877
  }
3878
- return a === "xiaohongshu" ? /* @__PURE__ */ O(I, {
3878
+ return a === "xiaohongshu" ? /* @__PURE__ */ O(F, {
3879
3879
  as: "div",
3880
3880
  className: "video-embed video-embed--xiaohongshu",
3881
3881
  style: {
@@ -3921,7 +3921,7 @@ function Vn({ node: e, deleteNode: t, editor: n }) {
3921
3921
  },
3922
3922
  children: "在小红书中打开 →"
3923
3923
  })] })]
3924
- }) : /* @__PURE__ */ O(I, {
3924
+ }) : /* @__PURE__ */ O(F, {
3925
3925
  as: "div",
3926
3926
  className: "video-embed video-embed--direct group/video",
3927
3927
  style: {
@@ -3940,7 +3940,7 @@ function Vn({ node: e, deleteNode: t, editor: n }) {
3940
3940
  className: "video-fs-btn video-fs-btn--del",
3941
3941
  title: "删除",
3942
3942
  onClick: () => {
3943
- pn() || ($(!0), s(!0));
3943
+ mn() || ($(!0), s(!0));
3944
3944
  },
3945
3945
  children: /* @__PURE__ */ D("svg", {
3946
3946
  width: "12",
@@ -4097,26 +4097,26 @@ function Vn({ node: e, deleteNode: t, editor: n }) {
4097
4097
  }
4098
4098
  //#endregion
4099
4099
  //#region src/editor/embeds/video.ts
4100
- function Hn(e) {
4100
+ function Un(e) {
4101
4101
  return /bilibili\.com|BV[a-zA-Z0-9]{10}|av\d+/i.test(e) ? "bilibili" : /xiaohongshu\.com|xhslink\.com/i.test(e) ? "xiaohongshu" : /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|$)/i.test(e) || /\/.*\.(mp4|m3u8|mov|webm|flv|mkv)/i.test(e) ? "direct" : "unknown";
4102
4102
  }
4103
- function Un(e) {
4103
+ function Wn(e) {
4104
4104
  let t = e.match(/BV[a-zA-Z0-9]{10}/);
4105
4105
  if (t) return t[0];
4106
4106
  let n = e.match(/av(\d+)/i);
4107
4107
  return n ? n[0] : e;
4108
4108
  }
4109
- function Wn(e) {
4109
+ function Gn(e) {
4110
4110
  let t = e.match(/explore\/([a-zA-Z0-9]+)/);
4111
4111
  return t ? t[1] : e;
4112
4112
  }
4113
- var Gn = re.create({
4113
+ var Kn = re.create({
4114
4114
  name: "videoEmbed",
4115
4115
  group: "block",
4116
4116
  atom: !0,
4117
4117
  inline: !1,
4118
4118
  addNodeView() {
4119
- return L(Vn);
4119
+ return I(Hn);
4120
4120
  },
4121
4121
  addProseMirrorPlugins() {
4122
4122
  return [new z({ props: {
@@ -4141,7 +4141,7 @@ var Gn = re.create({
4141
4141
  for (let n of r) {
4142
4142
  let r = n.trim();
4143
4143
  if (!r || r.includes(" ")) continue;
4144
- let i = Hn(r);
4144
+ let i = Un(r);
4145
4145
  if (i === "unknown") continue;
4146
4146
  t.preventDefault();
4147
4147
  let a = e.state.schema.nodes.videoEmbed.create({
@@ -4173,7 +4173,7 @@ var Gn = re.create({
4173
4173
  let t = e, n = t.getAttribute("src") || t.getAttribute("data-src") || "";
4174
4174
  return {
4175
4175
  src: n,
4176
- source: Hn(n)
4176
+ source: Un(n)
4177
4177
  };
4178
4178
  }
4179
4179
  },
@@ -4182,9 +4182,9 @@ var Gn = re.create({
4182
4182
  ];
4183
4183
  },
4184
4184
  renderHTML({ HTMLAttributes: e }) {
4185
- let t = e.src || "", n = Hn(t);
4185
+ let t = e.src || "", n = Un(t);
4186
4186
  if (n === "bilibili") {
4187
- let e = Un(t);
4187
+ let e = Wn(t);
4188
4188
  return [
4189
4189
  "div",
4190
4190
  {
@@ -4205,7 +4205,7 @@ var Gn = re.create({
4205
4205
  }]
4206
4206
  ];
4207
4207
  }
4208
- if (n === "xiaohongshu") return Wn(t), [
4208
+ if (n === "xiaohongshu") return Gn(t), [
4209
4209
  "div",
4210
4210
  {
4211
4211
  "data-video-embed": "xiaohongshu",
@@ -4257,7 +4257,7 @@ var Gn = re.create({
4257
4257
  },
4258
4258
  addCommands() {
4259
4259
  return { insertVideo: (e) => ({ chain: t }) => {
4260
- let n = Hn(e.src);
4260
+ let n = Un(e.src);
4261
4261
  return t().insertContent({
4262
4262
  type: this.name,
4263
4263
  attrs: {
@@ -4267,13 +4267,13 @@ var Gn = re.create({
4267
4267
  }).focus().run();
4268
4268
  } };
4269
4269
  }
4270
- }), Kn = null;
4271
- async function qn(e) {
4272
- Kn ||= await import("beautiful-mermaid");
4273
- let t = Kn.renderMermaidSVG;
4270
+ }), qn = null;
4271
+ async function Jn(e) {
4272
+ qn ||= await import("beautiful-mermaid");
4273
+ let t = qn.renderMermaidSVG;
4274
4274
  return t(e);
4275
4275
  }
4276
- var Jn = [
4276
+ var Yn = [
4277
4277
  {
4278
4278
  value: "javascript",
4279
4279
  label: "JavaScript",
@@ -4434,7 +4434,7 @@ var Jn = [
4434
4434
  label: "Plain Text",
4435
4435
  color: "#6b7280"
4436
4436
  }
4437
- ], Yn = {
4437
+ ], Xn = {
4438
4438
  javascript: "js",
4439
4439
  typescript: "ts",
4440
4440
  python: "py",
@@ -4460,7 +4460,7 @@ var Jn = [
4460
4460
  txt: "txt",
4461
4461
  vue: "vue",
4462
4462
  react: "jsx"
4463
- }, Xn = {
4463
+ }, Zn = {
4464
4464
  js: "javascript",
4465
4465
  ts: "typescript",
4466
4466
  py: "python",
@@ -4476,13 +4476,12 @@ var Jn = [
4476
4476
  jsx: "javascript",
4477
4477
  tsx: "typescript"
4478
4478
  };
4479
- function Zn(e) {
4480
- return e instanceof Element && !!e.closest(".cb-code-area");
4481
- }
4482
4479
  function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i, selected: a }) {
4483
- let o = n?.isEditable ?? !0, s = !o, [c, l] = T(!1), [u, d] = T(!1), [f, m] = T(!1), [h, g] = T(""), [_, v] = T(!1), [y, k] = T(null), [A, j] = T(null), [M, N] = T(!1), [P, L] = T([]), ee = w(null), te = w(null), ne = w(null), R = w(null), re = w(null), ie = e.attrs.language || "", z = Jn.find((e) => e.value === (Xn[ie] ?? ie)), B = ie === "mermaid", ae = b((e) => {
4484
- Zn(e.target) || e.stopPropagation();
4485
- }, []), oe = b(() => {
4480
+ let o = n?.isEditable ?? !0, s = !o, [c, l] = T(!1), [u, d] = T(!1), [f, m] = T(!1), [h, g] = T(!1), [_, v] = T(220), [y, S] = T({
4481
+ top: 0,
4482
+ left: 0,
4483
+ width: 210
4484
+ }), [k, A] = T(""), [j, M] = T(!1), [N, P] = T(null), [F, I] = T(null), [L, ee] = T(!1), te = w(null), R = w(null), re = w(null), ie = w(null), z = w(null), B = w(null), V = e.attrs.language || "", H = Yn.find((e) => e.value === (Zn[V] ?? V)), ae = V === "mermaid", oe = b(() => {
4486
4485
  if (!n || typeof r != "function") return null;
4487
4486
  let t = r();
4488
4487
  return typeof t == "number" ? {
@@ -4493,18 +4492,41 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
4493
4492
  n,
4494
4493
  r,
4495
4494
  e.nodeSize
4496
- ]), se = b(() => {
4497
- o && (pn() || (re.current = oe(), window.getSelection()?.removeAllRanges(), $(!0), v(!0)));
4498
- }, [oe, o]), ce = C(() => e.textContent ? e.textContent.split("\n") : [""], [e.textContent]), V = ce.length, H = C(() => Array.from({ length: V }, (e, t) => t + 1), [V]), le = C(() => {
4499
- let e = h.trim().toLowerCase();
4500
- return e ? Jn.filter((t) => t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e)) : Jn;
4501
- }, [h]);
4495
+ ]), U = b(() => {
4496
+ o && (mn() || (B.current = oe(), window.getSelection()?.removeAllRanges(), $(!0), M(!0)));
4497
+ }, [oe, o]), W = C(() => {
4498
+ let e = k.trim().toLowerCase();
4499
+ return e ? Yn.filter((t) => t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e)) : Yn;
4500
+ }, [k]);
4501
+ x(() => {
4502
+ (z.current?.parentElement?.querySelector(".cb-code-area"))?.classList.toggle("cb-code-area--collapsed", u);
4503
+ }, [u]);
4504
+ let G = b(() => {
4505
+ let e = re.current;
4506
+ if (!e) return;
4507
+ let t = e.getBoundingClientRect(), n = Math.min(t.left, window.innerWidth - 210 - 8), r = window.innerHeight - t.bottom - 12, i = t.top - 12, a = Yn.length * 31 + 8, o = r - 52, s = i - 52;
4508
+ o < 220 && s > o ? (g(!0), v(Math.max(120, Math.min(a, s))), S({
4509
+ top: t.top,
4510
+ left: n,
4511
+ width: 210
4512
+ })) : (g(!1), v(Math.max(120, Math.min(a, o))), S({
4513
+ top: t.bottom + 4,
4514
+ left: n,
4515
+ width: 210
4516
+ }));
4517
+ }, []);
4502
4518
  x(() => {
4503
- f && (g(""), setTimeout(() => te.current?.focus(), 50));
4504
- }, [f]), x(() => {
4519
+ if (!f) return;
4520
+ A(""), G();
4521
+ let e = setTimeout(() => ie.current?.focus(), 50);
4522
+ return window.addEventListener("resize", G), window.addEventListener("scroll", G, !0), () => {
4523
+ clearTimeout(e), window.removeEventListener("resize", G), window.removeEventListener("scroll", G, !0);
4524
+ };
4525
+ }, [f, G]), x(() => {
4505
4526
  if (!f) return;
4506
4527
  let e = (e) => {
4507
- ee.current && !ee.current.contains(e.target) && m(!1);
4528
+ let t = e.target;
4529
+ t && (re.current?.contains(t) || R.current?.contains(t) || m(!1));
4508
4530
  };
4509
4531
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
4510
4532
  }, [f]), x(() => {
@@ -4515,15 +4537,15 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
4515
4537
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
4516
4538
  }, [f]), x(() => {
4517
4539
  let e = (e) => {
4518
- if (!(e.key !== "Backspace" && e.key !== "Delete") && o && a && !pn()) {
4540
+ if (!(e.key !== "Backspace" && e.key !== "Delete") && o && a && !mn()) {
4519
4541
  if (e.preventDefault(), e.stopPropagation(), n) {
4520
4542
  let { from: e, to: t } = n.state.selection;
4521
- re.current = {
4543
+ B.current = {
4522
4544
  from: e,
4523
4545
  to: t
4524
4546
  };
4525
4547
  }
4526
- window.getSelection()?.removeAllRanges(), $(!0), v(!0);
4548
+ window.getSelection()?.removeAllRanges(), $(!0), M(!0);
4527
4549
  }
4528
4550
  };
4529
4551
  return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
@@ -4532,29 +4554,9 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
4532
4554
  n,
4533
4555
  o
4534
4556
  ]);
4535
- let U = b((e) => {
4536
- L((t) => t.length === e.length && t.every((t, n) => t === e[n]) ? t : e);
4537
- }, []), W = b(() => {
4538
- let e = ne.current, t = R.current;
4539
- if (!e || !t) return;
4540
- t.style.width = `${e.clientWidth}px`;
4541
- let n = t.children, r = Array(n.length);
4542
- for (let e = 0; e < n.length; e++) r[e] = n[e].offsetHeight;
4543
- U(r);
4544
- }, [U]);
4545
- S(() => {
4546
- W();
4547
- }, [W, ce]), x(() => {
4548
- let e = ne.current;
4549
- if (!e) return;
4550
- let t = new ResizeObserver(() => W());
4551
- return t.observe(e), window.addEventListener("resize", W), document.fonts?.ready?.then(() => W()), () => {
4552
- t.disconnect(), window.removeEventListener("resize", W);
4553
- };
4554
- }, [W]);
4555
- let ue = b((e) => {
4557
+ let K = b((e) => {
4556
4558
  t({ language: e || null }), m(!1);
4557
- }, [t]), de = b(() => {
4559
+ }, [t]), q = b(() => {
4558
4560
  if (o) {
4559
4561
  if (n && r) {
4560
4562
  let e = r();
@@ -4566,37 +4568,45 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
4566
4568
  n,
4567
4569
  r,
4568
4570
  o
4569
- ]), G = b(() => {
4570
- navigator.clipboard.writeText(e.textContent), l(!0), setTimeout(() => l(!1), 1500);
4571
- }, [e.textContent]), fe = b(() => {
4572
- let t = Yn[ie] || "txt", n = t ? `code.${t}` : "code.txt", r = new Blob([e.textContent], { type: "text/plain;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
4571
+ ]), se = b(() => {
4572
+ let t = e.textContent, n = (e) => {
4573
+ let t = document.createElement("textarea");
4574
+ t.value = e, t.style.position = "fixed", t.style.opacity = "0", document.body.appendChild(t), t.select();
4575
+ try {
4576
+ document.execCommand("copy");
4577
+ } catch {}
4578
+ document.body.removeChild(t);
4579
+ };
4580
+ navigator.clipboard?.writeText ? navigator.clipboard.writeText(t).catch(() => n(t)) : n(t), l(!0), setTimeout(() => l(!1), 1500);
4581
+ }, [e.textContent]), ce = b(() => {
4582
+ let t = Xn[V] || "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");
4573
4583
  a.href = i, a.download = n, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
4574
- }, [e.textContent, ie]), pe = b(async () => {
4575
- if (y || M) {
4576
- k(null), j(null), N(!1);
4584
+ }, [e.textContent, V]), J = b(async () => {
4585
+ if (N || L) {
4586
+ P(null), I(null), ee(!1);
4577
4587
  return;
4578
4588
  }
4579
- N(!0), j(null), k(null);
4589
+ ee(!0), I(null), P(null);
4580
4590
  try {
4581
4591
  let t = (e.textContent || "").trim();
4582
4592
  if (!t) {
4583
- j("代码块内容为空");
4593
+ I("代码块内容为空");
4584
4594
  return;
4585
4595
  }
4586
- let n = p(await qn(t));
4587
- k(n);
4596
+ let n = p(await Jn(t));
4597
+ P(n);
4588
4598
  } catch (e) {
4589
- j(e instanceof Error ? e.message : "Mermaid 渲染失败");
4599
+ I(e instanceof Error ? e.message : "Mermaid 渲染失败");
4590
4600
  } finally {
4591
- N(!1);
4601
+ ee(!1);
4592
4602
  }
4593
4603
  }, [
4594
4604
  e.textContent,
4595
- y,
4596
- M
4597
- ]), me = /* @__PURE__ */ O(E, { children: [z ? z.deviconClass ? /* @__PURE__ */ D("i", {
4598
- className: `${z.deviconClass} colored cb-lang-icon`,
4599
- style: { color: z.color }
4605
+ N,
4606
+ L
4607
+ ]), le = /* @__PURE__ */ O(E, { children: [H ? H.deviconClass ? /* @__PURE__ */ D("i", {
4608
+ className: `${H.deviconClass} colored cb-lang-icon`,
4609
+ style: { color: H.color }
4600
4610
  }) : /* @__PURE__ */ D("span", {
4601
4611
  className: "cb-lang-icon cb-lang-icon--auto",
4602
4612
  children: "Tx"
@@ -4605,44 +4615,55 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
4605
4615
  children: "?"
4606
4616
  }), /* @__PURE__ */ D("span", {
4607
4617
  className: "cb-lang-label",
4608
- children: z?.label || "自动"
4618
+ children: H?.label || "自动"
4609
4619
  })] });
4610
- return /* @__PURE__ */ O(I, {
4611
- as: "div",
4612
- className: "code-block-node-view group/cb",
4613
- onMouseDown: ae,
4614
- onTouchStart: ae,
4620
+ return /* @__PURE__ */ O("div", {
4621
+ ref: z,
4622
+ className: "cb-react-shell group/cb",
4623
+ style: { display: "contents" },
4615
4624
  children: [
4616
4625
  /* @__PURE__ */ O("div", {
4617
4626
  className: "cb-header",
4618
4627
  contentEditable: !1,
4619
- children: [/* @__PURE__ */ O("div", {
4620
- className: "cb-lang-wrap",
4621
- ref: ee,
4622
- contentEditable: !1,
4623
- children: [s ? /* @__PURE__ */ D("span", {
4624
- className: "cb-lang-trigger cb-lang-trigger--static",
4625
- children: me
4626
- }) : /* @__PURE__ */ O("button", {
4627
- type: "button",
4628
- className: "cb-lang-trigger",
4629
- onClick: () => m(!f),
4630
- children: [me, /* @__PURE__ */ D("svg", {
4631
- className: `cb-lang-chevron${f ? " cb-lang-chevron--open" : ""}`,
4632
- width: "10",
4633
- height: "10",
4634
- viewBox: "0 0 24 24",
4635
- fill: "none",
4636
- stroke: "currentColor",
4637
- strokeWidth: "2.5",
4638
- children: /* @__PURE__ */ D("path", {
4639
- strokeLinecap: "round",
4640
- strokeLinejoin: "round",
4641
- d: "M6 9l6 6 6-6"
4642
- })
4643
- })]
4644
- }), o && f && /* @__PURE__ */ O("div", {
4645
- className: "cb-lang-dropdown",
4628
+ children: [
4629
+ /* @__PURE__ */ D("div", {
4630
+ className: "cb-lang-wrap",
4631
+ ref: te,
4632
+ contentEditable: !1,
4633
+ children: s ? /* @__PURE__ */ D("span", {
4634
+ className: "cb-lang-trigger cb-lang-trigger--static",
4635
+ children: le
4636
+ }) : /* @__PURE__ */ O("button", {
4637
+ ref: re,
4638
+ type: "button",
4639
+ className: "cb-lang-trigger",
4640
+ onClick: () => m(!f),
4641
+ children: [le, /* @__PURE__ */ D("svg", {
4642
+ className: `cb-lang-chevron${f ? " cb-lang-chevron--open" : ""}`,
4643
+ width: "10",
4644
+ height: "10",
4645
+ viewBox: "0 0 24 24",
4646
+ fill: "none",
4647
+ stroke: "currentColor",
4648
+ strokeWidth: "2.5",
4649
+ children: /* @__PURE__ */ D("path", {
4650
+ strokeLinecap: "round",
4651
+ strokeLinejoin: "round",
4652
+ d: "M6 9l6 6 6-6"
4653
+ })
4654
+ })]
4655
+ })
4656
+ }),
4657
+ o && f && ne(/* @__PURE__ */ O("div", {
4658
+ ref: R,
4659
+ className: `cb-lang-dropdown${h ? " cb-lang-dropdown--up" : ""}`,
4660
+ style: {
4661
+ position: "fixed",
4662
+ top: y.top,
4663
+ left: y.left,
4664
+ width: y.width,
4665
+ zIndex: 10002
4666
+ },
4646
4667
  children: [/* @__PURE__ */ O("div", {
4647
4668
  className: "cb-lang-search-wrap",
4648
4669
  children: [/* @__PURE__ */ D("svg", {
@@ -4659,30 +4680,31 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
4659
4680
  d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
4660
4681
  })
4661
4682
  }), /* @__PURE__ */ D("input", {
4662
- ref: te,
4683
+ ref: ie,
4663
4684
  className: "cb-lang-search",
4664
4685
  type: "text",
4665
4686
  placeholder: "搜索语言...",
4666
- value: h,
4667
- onChange: (e) => g(e.target.value),
4687
+ value: k,
4688
+ onChange: (e) => A(e.target.value),
4668
4689
  onKeyDown: (e) => e.stopPropagation()
4669
4690
  })]
4670
4691
  }), /* @__PURE__ */ O("div", {
4671
4692
  className: "cb-lang-list",
4693
+ style: { maxHeight: _ },
4672
4694
  children: [
4673
4695
  /* @__PURE__ */ O("button", {
4674
4696
  type: "button",
4675
- className: `cb-lang-option${ie ? "" : " cb-lang-option--active"}`,
4676
- onClick: () => ue(""),
4697
+ className: `cb-lang-option${V ? "" : " cb-lang-option--active"}`,
4698
+ onClick: () => K(""),
4677
4699
  children: [/* @__PURE__ */ D("span", {
4678
4700
  className: "cb-lang-icon cb-lang-icon--auto",
4679
4701
  children: "?"
4680
4702
  }), /* @__PURE__ */ D("span", { children: "自动检测" })]
4681
4703
  }),
4682
- le.map((e) => /* @__PURE__ */ O("button", {
4704
+ W.map((e) => /* @__PURE__ */ O("button", {
4683
4705
  type: "button",
4684
- className: `cb-lang-option${ie === e.value ? " cb-lang-option--active" : ""}`,
4685
- onClick: () => ue(e.value),
4706
+ className: `cb-lang-option${V === e.value ? " cb-lang-option--active" : ""}`,
4707
+ onClick: () => K(e.value),
4686
4708
  children: [e.deviconClass ? /* @__PURE__ */ D("i", {
4687
4709
  className: `${e.deviconClass} colored cb-lang-icon`,
4688
4710
  style: { color: e.color }
@@ -4691,211 +4713,179 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
4691
4713
  children: "Tx"
4692
4714
  }), /* @__PURE__ */ D("span", { children: e.label })]
4693
4715
  }, e.value)),
4694
- le.length === 0 && /* @__PURE__ */ D("div", {
4716
+ W.length === 0 && /* @__PURE__ */ D("div", {
4695
4717
  className: "cb-lang-empty",
4696
4718
  children: "无匹配语言"
4697
4719
  })
4698
4720
  ]
4699
4721
  })]
4700
- })]
4701
- }), /* @__PURE__ */ O("div", {
4702
- className: "cb-actions",
4703
- children: [
4704
- /* @__PURE__ */ D("button", {
4705
- type: "button",
4706
- className: "cb-btn",
4707
- onClick: () => d(!u),
4708
- contentEditable: !1,
4709
- title: u ? "展开" : "折叠",
4710
- children: /* @__PURE__ */ D("svg", {
4711
- className: "cb-btn-icon",
4712
- fill: "none",
4713
- viewBox: "0 0 24 24",
4714
- stroke: "currentColor",
4715
- strokeWidth: "2",
4716
- children: u ? /* @__PURE__ */ D("path", {
4717
- strokeLinecap: "round",
4718
- strokeLinejoin: "round",
4719
- d: "M6 9l6 6 6-6"
4720
- }) : /* @__PURE__ */ D("path", {
4721
- strokeLinecap: "round",
4722
- strokeLinejoin: "round",
4723
- d: "M6 15l6-6 6 6"
4724
- })
4725
- })
4726
- }),
4727
- /* @__PURE__ */ D("button", {
4728
- type: "button",
4729
- className: "cb-btn",
4730
- onClick: G,
4731
- contentEditable: !1,
4732
- title: "复制",
4733
- children: c ? /* @__PURE__ */ D("svg", {
4734
- className: "cb-btn-icon cb-btn-icon--check",
4735
- fill: "none",
4736
- viewBox: "0 0 24 24",
4737
- stroke: "currentColor",
4738
- strokeWidth: "2.5",
4739
- children: /* @__PURE__ */ D("path", {
4740
- strokeLinecap: "round",
4741
- strokeLinejoin: "round",
4742
- d: "M5 13l4 4L19 7"
4722
+ }), document.body),
4723
+ /* @__PURE__ */ O("div", {
4724
+ className: "cb-actions",
4725
+ children: [
4726
+ /* @__PURE__ */ D("button", {
4727
+ type: "button",
4728
+ className: "cb-btn",
4729
+ onClick: () => d(!u),
4730
+ contentEditable: !1,
4731
+ title: u ? "展开" : "折叠",
4732
+ children: /* @__PURE__ */ D("svg", {
4733
+ className: "cb-btn-icon",
4734
+ fill: "none",
4735
+ viewBox: "0 0 24 24",
4736
+ stroke: "currentColor",
4737
+ strokeWidth: "2",
4738
+ children: u ? /* @__PURE__ */ D("path", {
4739
+ strokeLinecap: "round",
4740
+ strokeLinejoin: "round",
4741
+ d: "M6 9l6 6 6-6"
4742
+ }) : /* @__PURE__ */ D("path", {
4743
+ strokeLinecap: "round",
4744
+ strokeLinejoin: "round",
4745
+ d: "M6 15l6-6 6 6"
4746
+ })
4743
4747
  })
4744
- }) : /* @__PURE__ */ D("svg", {
4745
- className: "cb-btn-icon",
4746
- fill: "none",
4747
- viewBox: "0 0 24 24",
4748
- stroke: "currentColor",
4749
- strokeWidth: "2",
4750
- children: /* @__PURE__ */ D("path", {
4751
- strokeLinecap: "round",
4752
- strokeLinejoin: "round",
4753
- d: "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"
4748
+ }),
4749
+ /* @__PURE__ */ D("button", {
4750
+ type: "button",
4751
+ className: "cb-btn",
4752
+ onClick: se,
4753
+ contentEditable: !1,
4754
+ title: "复制",
4755
+ children: c ? /* @__PURE__ */ D("svg", {
4756
+ className: "cb-btn-icon cb-btn-icon--check",
4757
+ fill: "none",
4758
+ viewBox: "0 0 24 24",
4759
+ stroke: "currentColor",
4760
+ strokeWidth: "2.5",
4761
+ children: /* @__PURE__ */ D("path", {
4762
+ strokeLinecap: "round",
4763
+ strokeLinejoin: "round",
4764
+ d: "M5 13l4 4L19 7"
4765
+ })
4766
+ }) : /* @__PURE__ */ D("svg", {
4767
+ className: "cb-btn-icon",
4768
+ fill: "none",
4769
+ viewBox: "0 0 24 24",
4770
+ stroke: "currentColor",
4771
+ strokeWidth: "2",
4772
+ children: /* @__PURE__ */ D("path", {
4773
+ strokeLinecap: "round",
4774
+ strokeLinejoin: "round",
4775
+ d: "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"
4776
+ })
4754
4777
  })
4755
- })
4756
- }),
4757
- /* @__PURE__ */ D("button", {
4758
- type: "button",
4759
- className: "cb-btn",
4760
- onClick: fe,
4761
- contentEditable: !1,
4762
- title: "下载",
4763
- children: /* @__PURE__ */ D("svg", {
4764
- className: "cb-btn-icon",
4765
- fill: "none",
4766
- viewBox: "0 0 24 24",
4767
- stroke: "currentColor",
4768
- strokeWidth: "2",
4769
- children: /* @__PURE__ */ D("path", {
4770
- strokeLinecap: "round",
4771
- strokeLinejoin: "round",
4772
- d: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"
4778
+ }),
4779
+ /* @__PURE__ */ D("button", {
4780
+ type: "button",
4781
+ className: "cb-btn",
4782
+ onClick: ce,
4783
+ contentEditable: !1,
4784
+ title: "下载",
4785
+ children: /* @__PURE__ */ D("svg", {
4786
+ className: "cb-btn-icon",
4787
+ fill: "none",
4788
+ viewBox: "0 0 24 24",
4789
+ stroke: "currentColor",
4790
+ strokeWidth: "2",
4791
+ children: /* @__PURE__ */ D("path", {
4792
+ strokeLinecap: "round",
4793
+ strokeLinejoin: "round",
4794
+ d: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"
4795
+ })
4773
4796
  })
4774
- })
4775
- }),
4776
- o && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("button", {
4777
- type: "button",
4778
- className: "cb-btn cb-btn--ai",
4779
- onClick: de,
4780
- contentEditable: !1,
4781
- title: "写作助手",
4782
- children: /* @__PURE__ */ D("svg", {
4783
- className: "cb-btn-icon",
4784
- fill: "none",
4785
- viewBox: "0 0 24 24",
4786
- stroke: "currentColor",
4787
- strokeWidth: "2",
4788
- children: /* @__PURE__ */ D("path", {
4789
- strokeLinecap: "round",
4790
- strokeLinejoin: "round",
4791
- d: "M13 10V3L4 14h7v7l9-11h-7z"
4797
+ }),
4798
+ o && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("button", {
4799
+ type: "button",
4800
+ className: "cb-btn cb-btn--ai",
4801
+ onClick: q,
4802
+ contentEditable: !1,
4803
+ title: "写作助手",
4804
+ children: /* @__PURE__ */ D("svg", {
4805
+ className: "cb-btn-icon",
4806
+ fill: "none",
4807
+ viewBox: "0 0 24 24",
4808
+ stroke: "currentColor",
4809
+ strokeWidth: "2",
4810
+ children: /* @__PURE__ */ D("path", {
4811
+ strokeLinecap: "round",
4812
+ strokeLinejoin: "round",
4813
+ d: "M13 10V3L4 14h7v7l9-11h-7z"
4814
+ })
4792
4815
  })
4793
- })
4794
- }), /* @__PURE__ */ D("button", {
4795
- type: "button",
4796
- className: "cb-btn cb-btn--del",
4797
- onClick: se,
4798
- contentEditable: !1,
4799
- title: "删除代码块",
4800
- children: /* @__PURE__ */ D("svg", {
4801
- className: "cb-btn-icon",
4802
- fill: "none",
4803
- viewBox: "0 0 24 24",
4804
- stroke: "currentColor",
4805
- strokeWidth: "2",
4806
- children: /* @__PURE__ */ D("path", {
4807
- strokeLinecap: "round",
4808
- strokeLinejoin: "round",
4809
- d: "M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
4816
+ }), /* @__PURE__ */ D("button", {
4817
+ type: "button",
4818
+ className: "cb-btn cb-btn--del",
4819
+ onClick: U,
4820
+ contentEditable: !1,
4821
+ title: "删除代码块",
4822
+ children: /* @__PURE__ */ D("svg", {
4823
+ className: "cb-btn-icon",
4824
+ fill: "none",
4825
+ viewBox: "0 0 24 24",
4826
+ stroke: "currentColor",
4827
+ strokeWidth: "2",
4828
+ children: /* @__PURE__ */ D("path", {
4829
+ strokeLinecap: "round",
4830
+ strokeLinejoin: "round",
4831
+ d: "M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
4832
+ })
4810
4833
  })
4811
- })
4812
- })] }),
4813
- B && /* @__PURE__ */ D("button", {
4814
- type: "button",
4815
- className: "cb-btn cb-btn--diagram",
4816
- onClick: pe,
4817
- contentEditable: !1,
4818
- title: y || M ? "取消渲染" : "渲染图表",
4819
- disabled: M,
4820
- children: /* @__PURE__ */ D("svg", {
4821
- className: "cb-btn-icon",
4822
- fill: "none",
4823
- viewBox: "0 0 24 24",
4824
- stroke: "currentColor",
4825
- strokeWidth: "2",
4826
- children: /* @__PURE__ */ D("path", {
4827
- strokeLinecap: "round",
4828
- strokeLinejoin: "round",
4829
- d: "M4 5a1 1 0 011-1h4a1 1 0 011 1v5a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM14 5a1 1 0 011-1h4a1 1 0 011 1v2a1 1 0 01-1 1h-4a1 1 0 01-1-1V5zM4 16a1 1 0 011-1h4a1 1 0 011 1v3a1 1 0 01-1 1H5a1 1 0 01-1-1v-3zM14 13a1 1 0 011-1h4a1 1 0 011 1v6a1 1 0 01-1 1h-4a1 1 0 01-1-1v-6z"
4834
+ })] }),
4835
+ ae && /* @__PURE__ */ D("button", {
4836
+ type: "button",
4837
+ className: "cb-btn cb-btn--diagram",
4838
+ onClick: J,
4839
+ contentEditable: !1,
4840
+ title: N || L ? "取消渲染" : "渲染图表",
4841
+ disabled: L,
4842
+ children: /* @__PURE__ */ D("svg", {
4843
+ className: "cb-btn-icon",
4844
+ fill: "none",
4845
+ viewBox: "0 0 24 24",
4846
+ stroke: "currentColor",
4847
+ strokeWidth: "2",
4848
+ children: /* @__PURE__ */ D("path", {
4849
+ strokeLinecap: "round",
4850
+ strokeLinejoin: "round",
4851
+ d: "M4 5a1 1 0 011-1h4a1 1 0 011 1v5a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM14 5a1 1 0 011-1h4a1 1 0 011 1v2a1 1 0 01-1 1h-4a1 1 0 01-1-1V5zM4 16a1 1 0 011-1h4a1 1 0 011 1v3a1 1 0 01-1 1H5a1 1 0 01-1-1v-3zM14 13a1 1 0 011-1h4a1 1 0 011 1v6a1 1 0 01-1 1h-4a1 1 0 01-1-1v-6z"
4852
+ })
4830
4853
  })
4831
4854
  })
4832
- })
4833
- ]
4834
- })]
4835
- }),
4836
- /* @__PURE__ */ O("div", {
4837
- className: `cb-code-area${u ? " cb-code-area--collapsed" : ""}`,
4838
- children: [
4839
- /* @__PURE__ */ D("div", {
4840
- className: "cb-line-numbers",
4841
- contentEditable: !1,
4842
- "aria-hidden": "true",
4843
- children: H.map((e, t) => /* @__PURE__ */ D("span", {
4844
- className: "cb-line-num",
4845
- style: P[t] ? { height: P[t] } : void 0,
4846
- children: e
4847
- }, e))
4848
- }),
4849
- /* @__PURE__ */ D("pre", {
4850
- className: "cb-code-pre",
4851
- ref: ne,
4852
- children: /* @__PURE__ */ D(F, { as: "code" })
4853
- }),
4854
- /* @__PURE__ */ D("div", {
4855
- ref: R,
4856
- className: "cb-code-mirror",
4857
- contentEditable: !1,
4858
- "aria-hidden": "true",
4859
- children: ce.map((e, t) => /* @__PURE__ */ D("span", {
4860
- className: "cb-mirror-line",
4861
- children: e.length ? e : "\xA0"
4862
- }, t))
4855
+ ]
4863
4856
  })
4864
4857
  ]
4865
4858
  }),
4866
- (y || A || M) && /* @__PURE__ */ O("div", {
4859
+ (N || F || L) && /* @__PURE__ */ O("div", {
4867
4860
  className: "cb-diagram-output",
4868
4861
  contentEditable: !1,
4869
4862
  children: [
4870
- M && /* @__PURE__ */ D("div", {
4863
+ L && /* @__PURE__ */ D("div", {
4871
4864
  className: "cb-diagram-loading",
4872
4865
  children: "渲染图表中…"
4873
4866
  }),
4874
- A && /* @__PURE__ */ O("div", {
4867
+ F && /* @__PURE__ */ O("div", {
4875
4868
  className: "cb-diagram-error",
4876
4869
  children: [/* @__PURE__ */ D("span", {
4877
4870
  className: "cb-diagram-error-icon",
4878
4871
  children: "!"
4879
- }), A]
4872
+ }), F]
4880
4873
  }),
4881
- y && /* @__PURE__ */ D("div", {
4874
+ N && /* @__PURE__ */ D("div", {
4882
4875
  className: "cb-diagram-svg",
4883
- dangerouslySetInnerHTML: { __html: y }
4876
+ dangerouslySetInnerHTML: { __html: N }
4884
4877
  })
4885
4878
  ]
4886
4879
  }),
4887
- /* @__PURE__ */ D(vn, {
4888
- open: _,
4880
+ /* @__PURE__ */ D(yn, {
4881
+ open: j,
4889
4882
  title: "确认删除代码块",
4890
4883
  message: "此操作不可撤销。",
4891
4884
  onCancel: () => {
4892
- $(!1), v(!1);
4885
+ $(!1), M(!1);
4893
4886
  },
4894
4887
  onConfirm: async () => {
4895
- if (await new Promise((e) => setTimeout(e, 300)), $(!1), n) {
4896
- let e = re.current ?? oe();
4897
- e ? n.chain().focus().setTextSelection(e).deleteSelection().run() : i();
4898
- } else i();
4888
+ await new Promise((e) => setTimeout(e, 300)), $(!1), i();
4899
4889
  }
4900
4890
  })
4901
4891
  ]
@@ -5004,11 +4994,165 @@ var $n = [
5004
4994
  value: "mermaid",
5005
4995
  label: "Mermaid"
5006
4996
  }
5007
- ], er = Se(xe);
5008
- er.register({ dockerfile: be }), er.registerAlias("xml", ["vue", "html"]), er.registerAlias("javascript", ["react", "jsx"]), er.registerAlias("typescript", ["tsx"]);
5009
- var tr = ye.extend({
4997
+ ], er = be(ye);
4998
+ er.register({ dockerfile: ve }), er.registerAlias("xml", ["vue", "html"]), er.registerAlias("javascript", ["react", "jsx"]), er.registerAlias("typescript", ["tsx"]);
4999
+ function tr(e) {
5000
+ return e ? e.split("\n") : [""];
5001
+ }
5002
+ function nr(e, t) {
5003
+ if (e.childElementCount !== t) {
5004
+ e.replaceChildren();
5005
+ for (let n = 1; n <= t; n++) {
5006
+ let t = document.createElement("span");
5007
+ t.className = "cb-line-num", t.textContent = String(n), e.appendChild(t);
5008
+ }
5009
+ }
5010
+ }
5011
+ function rr(e, t) {
5012
+ e.replaceChildren();
5013
+ for (let n of t) {
5014
+ let t = document.createElement("span");
5015
+ t.className = "cb-mirror-line", t.textContent = n.length ? n : "\xA0", e.appendChild(t);
5016
+ }
5017
+ }
5018
+ function ir(e, t, n) {
5019
+ let r = getComputedStyle(e), i = parseFloat(r.paddingLeft), a = parseFloat(r.paddingRight);
5020
+ t.style.boxSizing = "content-box", t.style.width = `${Math.max(0, e.clientWidth - i - a)}px`, t.style.padding = r.padding;
5021
+ let o = getComputedStyle(n);
5022
+ (o.paddingTop !== r.paddingTop || o.paddingBottom !== r.paddingBottom) && (n.style.paddingTop = r.paddingTop, n.style.paddingBottom = r.paddingBottom);
5023
+ let s = e.querySelector("code"), c = parseFloat(r.lineHeight) || 24;
5024
+ if (!s) {
5025
+ for (let e = 0; e < n.children.length; e++) n.children[e].style.height = `${c}px`;
5026
+ return;
5027
+ }
5028
+ let l = s.textContent ?? "", u = [], d = 0;
5029
+ for (let e = 0; e <= l.length; e++) (e === l.length || l[e] === "\n") && (u.push([d, e]), d = e + 1);
5030
+ let f = [], p = [], m = 0, h = document.createTreeWalker(s, NodeFilter.SHOW_TEXT), g;
5031
+ for (; g = h.nextNode();) f.push(g), p.push(m), m += g.textContent?.length ?? 0;
5032
+ let _ = (e) => {
5033
+ for (let t = 0; t < f.length; t++) {
5034
+ let n = p[t];
5035
+ if (e <= n + (f[t].textContent?.length ?? 0)) return {
5036
+ node: f[t],
5037
+ offset: e - n
5038
+ };
5039
+ }
5040
+ let t = f[f.length - 1];
5041
+ return t ? {
5042
+ node: t,
5043
+ offset: t.textContent?.length ?? 0
5044
+ } : null;
5045
+ }, v = e.getBoundingClientRect(), y = parseFloat(r.paddingTop), b = v.top + y, x = v.bottom - parseFloat(r.paddingBottom), S = document.createRange(), C = [];
5046
+ for (let e = 0; e < u.length; e++) {
5047
+ let [t, n] = u[e], r = NaN, i = _(t), a = _(n);
5048
+ if (i && a) {
5049
+ S.setStart(i.node, i.offset), S.setEnd(a.node, a.offset);
5050
+ let e = S.getClientRects(), t = Infinity;
5051
+ for (let n = 0; n < e.length; n++) e[n].height > 0 && e[n].top < t && (t = e[n].top);
5052
+ Number.isFinite(t) && (r = t - b);
5053
+ }
5054
+ C.push(r);
5055
+ }
5056
+ for (let e = 0; e < C.length; e++) Number.isFinite(C[e]) || (C[e] = e > 0 ? C[e - 1] + c : 0);
5057
+ let w = x - b, T = 0;
5058
+ for (let e = 0; e < u.length; e++) {
5059
+ let t = n.children[e];
5060
+ if (!t) continue;
5061
+ let r;
5062
+ 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;
5063
+ }
5064
+ }
5065
+ var ar = _e.extend({
5010
5066
  addNodeView() {
5011
- return L(Qn);
5067
+ return (e) => {
5068
+ let { node: t, editor: n, getPos: r } = e, i = t, a = (e) => {
5069
+ let t = typeof r == "function" ? r() : void 0;
5070
+ typeof t == "number" && n.chain().command(({ tr: n }) => (n.setNodeMarkup(t, void 0, {
5071
+ ...i.attrs,
5072
+ ...e
5073
+ }), !0)).run();
5074
+ }, o = () => {
5075
+ let e = typeof r == "function" ? r() : void 0;
5076
+ typeof e == "number" && n.chain().command(({ tr: t }) => (t.delete(e, e + i.nodeSize), !0)).run();
5077
+ }, s = document.createElement("div");
5078
+ s.className = "code-block-node-view group/cb";
5079
+ let c = document.createElement("div");
5080
+ c.contentEditable = "false", s.appendChild(c);
5081
+ let l = document.createElement("div");
5082
+ l.className = "cb-code-area";
5083
+ let u = document.createElement("div");
5084
+ u.className = "cb-line-numbers", u.contentEditable = "false", u.setAttribute("aria-hidden", "true");
5085
+ let d = document.createElement("pre");
5086
+ d.className = "cb-code-pre";
5087
+ let f = document.createElement("code");
5088
+ d.appendChild(f);
5089
+ let p = document.createElement("div");
5090
+ p.className = "cb-code-mirror", p.contentEditable = "false", p.setAttribute("aria-hidden", "true"), l.appendChild(u), l.appendChild(d), l.appendChild(p), s.appendChild(l);
5091
+ let m = tr(t.textContent);
5092
+ nr(u, m.length), rr(p, m);
5093
+ let h = new L(Qn, {
5094
+ editor: n,
5095
+ props: {
5096
+ node: t,
5097
+ editor: n,
5098
+ getPos: r,
5099
+ updateAttributes: a,
5100
+ deleteNode: o,
5101
+ selected: !1
5102
+ }
5103
+ });
5104
+ c.appendChild(h.element);
5105
+ let g = (e) => {
5106
+ let t = tr(e.textContent);
5107
+ nr(u, t.length), rr(p, t), requestAnimationFrame(() => ir(d, p, u));
5108
+ };
5109
+ requestAnimationFrame(() => ir(d, p, u));
5110
+ let _ = new ResizeObserver(() => ir(d, p, u));
5111
+ return _.observe(d), document.fonts?.ready?.then(() => ir(d, p, u)), {
5112
+ dom: s,
5113
+ contentDOM: f,
5114
+ update(e) {
5115
+ return e.type !== t.type || !e.sameMarkup(i) ? !1 : (i = e, h.updateProps({
5116
+ node: e,
5117
+ editor: n,
5118
+ getPos: r,
5119
+ updateAttributes: a,
5120
+ deleteNode: o,
5121
+ selected: s.classList.contains("ProseMirror-selectednode")
5122
+ }), g(e), !0);
5123
+ },
5124
+ selectNode() {
5125
+ s.classList.add("ProseMirror-selectednode"), h.updateProps({
5126
+ node: i,
5127
+ editor: n,
5128
+ getPos: r,
5129
+ updateAttributes: a,
5130
+ deleteNode: o,
5131
+ selected: !0
5132
+ });
5133
+ },
5134
+ deselectNode() {
5135
+ s.classList.remove("ProseMirror-selectednode"), h.updateProps({
5136
+ node: i,
5137
+ editor: n,
5138
+ getPos: r,
5139
+ updateAttributes: a,
5140
+ deleteNode: o,
5141
+ selected: !1
5142
+ });
5143
+ },
5144
+ stopEvent(e) {
5145
+ let t = e.target;
5146
+ return !!(t && c.contains(t));
5147
+ },
5148
+ ignoreMutation(e) {
5149
+ return !f.contains(e.target);
5150
+ },
5151
+ destroy() {
5152
+ _.disconnect(), h.destroy();
5153
+ }
5154
+ };
5155
+ };
5012
5156
  },
5013
5157
  parseHTML() {
5014
5158
  return (this.parent?.() ?? []).map((e) => ({
@@ -5027,7 +5171,7 @@ var tr = ye.extend({
5027
5171
  }).configure({ lowlight: er });
5028
5172
  //#endregion
5029
5173
  //#region src/editor/utils/import-choice-dialog.ts
5030
- function nr(e) {
5174
+ function or(e) {
5031
5175
  return new Promise((t) => {
5032
5176
  let n = document.createElement("div");
5033
5177
  n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
@@ -5057,16 +5201,16 @@ function nr(e) {
5057
5201
  }
5058
5202
  //#endregion
5059
5203
  //#region src/editor/utils/local-media.ts
5060
- var rr = /\.(png|jpe?g|gif|webp|bmp|svg|avif|mp4|m4v|webm|ogg|mov|avi|mkv|mp3|wav|flac|m4a|aac|opus|pdf|docx?|xlsx?|pptx?|odt|rtf|txt|md|csv|zip|rar|7z|json)(\?|#|$)/i, ir = /^(?:mailto:|tel:|javascript:|about:|data:|blob:)/i;
5061
- function ar(e) {
5204
+ var sr = /\.(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, cr = /^(?:mailto:|tel:|javascript:|about:|data:|blob:)/i;
5205
+ function lr(e) {
5062
5206
  if (!e) return !1;
5063
5207
  let t = e.trim();
5064
- return !(!t || /^(?:https?:)?\/\//i.test(t) || ir.test(t) || t.startsWith("#"));
5208
+ return !(!t || /^(?:https?:)?\/\//i.test(t) || cr.test(t) || t.startsWith("#"));
5065
5209
  }
5066
- function or(e) {
5067
- return rr.test(e);
5210
+ function ur(e) {
5211
+ return sr.test(e);
5068
5212
  }
5069
- function sr(e) {
5213
+ function dr(e) {
5070
5214
  let t = e.trim();
5071
5215
  t = t.replace(/^(?:file|app):\/\/(?:localhost)?/i, "");
5072
5216
  try {
@@ -5074,26 +5218,26 @@ function sr(e) {
5074
5218
  } catch {}
5075
5219
  return t = t.replace(/\\/g, "/"), t = t.replace(/^\.\//, ""), t = t.replace(/^\/+/, ""), t = t.replace(/^[a-zA-Z]:\//, ""), t;
5076
5220
  }
5077
- function cr(e) {
5078
- let t = sr(e), n = t.split("/").filter(Boolean);
5221
+ function fr(e) {
5222
+ let t = dr(e), n = t.split("/").filter(Boolean);
5079
5223
  return (n[n.length - 1] || t).toLowerCase();
5080
5224
  }
5081
- function lr() {
5225
+ function pr() {
5082
5226
  return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showDirectoryPicker == "function";
5083
5227
  }
5084
- async function ur() {
5085
- if (!lr()) return null;
5228
+ async function mr() {
5229
+ if (!pr()) return null;
5086
5230
  try {
5087
5231
  return await window.showDirectoryPicker.call(window, { mode: "read" }) ?? null;
5088
5232
  } catch {
5089
5233
  return null;
5090
5234
  }
5091
5235
  }
5092
- function dr() {
5236
+ function hr() {
5093
5237
  return typeof window > "u" || window.isSecureContext === !1 ? !1 : typeof window.showOpenFilePicker == "function";
5094
5238
  }
5095
- async function fr() {
5096
- if (!dr()) return null;
5239
+ async function gr() {
5240
+ if (!hr()) return null;
5097
5241
  try {
5098
5242
  let e = await window.showOpenFilePicker.call(window, { multiple: !0 });
5099
5243
  return await Promise.all(e.map((e) => e.getFile()));
@@ -5101,7 +5245,7 @@ async function fr() {
5101
5245
  return null;
5102
5246
  }
5103
5247
  }
5104
- async function pr(e, t) {
5248
+ async function _r(e, t) {
5105
5249
  if (t.length === 0) return { file: null };
5106
5250
  let n = e;
5107
5251
  for (let e = 0; e < t.length - 1; e++) try {
@@ -5123,7 +5267,7 @@ async function pr(e, t) {
5123
5267
  return { file: null };
5124
5268
  }
5125
5269
  }
5126
- async function mr(e, t, n = 5e3) {
5270
+ async function vr(e, t, n = 5e3) {
5127
5271
  let r = t.toLowerCase(), i = [e], a = 0, o;
5128
5272
  for (; i.length > 0 && a < n;) {
5129
5273
  let e = i.pop();
@@ -5145,37 +5289,37 @@ async function mr(e, t, n = 5e3) {
5145
5289
  readError: o
5146
5290
  };
5147
5291
  }
5148
- async function hr(e, t) {
5149
- let n = sr(t).split("/").filter(Boolean);
5292
+ async function yr(e, t) {
5293
+ let n = dr(t).split("/").filter(Boolean);
5150
5294
  if (n.length === 0) return { file: null };
5151
5295
  let r;
5152
5296
  for (let t = 0; t < n.length; t++) {
5153
- let i = await pr(e, n.slice(t));
5297
+ let i = await _r(e, n.slice(t));
5154
5298
  if (i.file) return i;
5155
5299
  i.readError && (r = i.readError);
5156
5300
  }
5157
- let i = await mr(e, n[n.length - 1]);
5301
+ let i = await vr(e, n[n.length - 1]);
5158
5302
  return i.file || i.readError ? i : {
5159
5303
  file: null,
5160
5304
  readError: r
5161
5305
  };
5162
5306
  }
5163
- var gr = {
5307
+ var br = {
5164
5308
  image: "image",
5165
5309
  videoEmbed: "video",
5166
5310
  audioEmbed: "audio",
5167
5311
  attachmentEmbed: "attachment"
5168
5312
  };
5169
- function _r(e, t) {
5313
+ function xr(e, t) {
5170
5314
  let n = /* @__PURE__ */ new Set(), r = [];
5171
5315
  return e.descendants((e) => {
5172
- let i = gr[e.type?.name];
5316
+ let i = br[e.type?.name];
5173
5317
  if (i) {
5174
5318
  let a = e.attrs?.src, o = `node:${a}`;
5175
- typeof a == "string" && ar(a) && !n.has(o) && !t?.(a) && (n.add(o), r.push({
5319
+ typeof a == "string" && lr(a) && !n.has(o) && !t?.(a) && (n.add(o), r.push({
5176
5320
  src: a,
5177
- normalized: sr(a),
5178
- basename: cr(a),
5321
+ normalized: dr(a),
5322
+ basename: fr(a),
5179
5323
  kind: i,
5180
5324
  isLink: !1
5181
5325
  }));
@@ -5184,17 +5328,17 @@ function _r(e, t) {
5184
5328
  if (e.isText && e.marks) for (let i of e.marks) {
5185
5329
  if (i.type.name !== "link") continue;
5186
5330
  let e = i.attrs?.href, a = `link:${e}`;
5187
- typeof e == "string" && ar(e) && or(e) && !n.has(a) && !t?.(e) && (n.add(a), r.push({
5331
+ typeof e == "string" && lr(e) && ur(e) && !n.has(a) && !t?.(e) && (n.add(a), r.push({
5188
5332
  src: e,
5189
- normalized: sr(e),
5190
- basename: cr(e),
5333
+ normalized: dr(e),
5334
+ basename: fr(e),
5191
5335
  kind: "attachment",
5192
5336
  isLink: !0
5193
5337
  }));
5194
5338
  }
5195
5339
  }), r;
5196
5340
  }
5197
- function vr(e, t, n) {
5341
+ function Sr(e, t, n) {
5198
5342
  let r = t ? `${e}\n${t}` : e;
5199
5343
  if (!r) return !1;
5200
5344
  let i = [];
@@ -5202,28 +5346,28 @@ function vr(e, t, n) {
5202
5346
  for (let e of r.matchAll(/!?\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g)) i.push(e[1]);
5203
5347
  for (let e of r.matchAll(/<(?:img|video|audio|source)[^>]*\bsrc=["']([^"']+)["']/gi)) i.push(e[1]);
5204
5348
  for (let e of r.matchAll(/<a[^>]*\bhref=["']([^"']+)["']/gi)) i.push(e[1]);
5205
- return i.some((e) => or(e) && ar(e) && !n?.(e));
5349
+ return i.some((e) => ur(e) && lr(e) && !n?.(e));
5206
5350
  }
5207
5351
  //#endregion
5208
5352
  //#region src/editor/extensions/image-upload.ts
5209
- function yr(e) {
5353
+ function Cr(e) {
5210
5354
  if (e.type.startsWith("image/")) return "image";
5211
5355
  if (e.type.startsWith("video/")) return "video";
5212
5356
  if (e.type.startsWith("audio/")) return "audio";
5213
5357
  let t = e.name.split(".").pop()?.toLowerCase() || "";
5214
5358
  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";
5215
5359
  }
5216
- function br(e) {
5360
+ function wr(e) {
5217
5361
  let t = e.name.split(".").pop()?.toLowerCase() || "";
5218
5362
  return t === "md" || t === "markdown";
5219
5363
  }
5220
- async function xr(e, t, n, r) {
5221
- let i = n ?? e.state.selection.from, a = r ? cn(r) : void 0, o = r?.storage?.qingwuUI, s = await new Promise((e) => {
5222
- o?.chooseMd ? o.chooseMd(t.name, e) : nr(t.name).then(e);
5364
+ async function Tr(e, t, n, r) {
5365
+ let i = n ?? e.state.selection.from, a = r ? ln(r) : void 0, o = r?.storage?.qingwuUI, s = await new Promise((e) => {
5366
+ o?.chooseMd ? o.chooseMd(t.name, e) : or(t.name).then(e);
5223
5367
  });
5224
5368
  if (s === null) return;
5225
5369
  if (s === "attach") {
5226
- let n = a ? ln(e.state.doc, t, a) : null;
5370
+ let n = a ? un(e.state.doc, t, a) : null;
5227
5371
  if (n) {
5228
5372
  Z(n);
5229
5373
  return;
@@ -5254,8 +5398,8 @@ async function xr(e, t, n, r) {
5254
5398
  e.dispatch(e.state.tr.insert(i, t.from(u)));
5255
5399
  }
5256
5400
  }
5257
- function Sr(e, t, n) {
5258
- switch (yr(t)) {
5401
+ function Er(e, t, n) {
5402
+ switch (Cr(t)) {
5259
5403
  case "image": return e.nodes.image?.create({
5260
5404
  src: n,
5261
5405
  alt: t.name
@@ -5281,7 +5425,7 @@ function Sr(e, t, n) {
5281
5425
  }
5282
5426
  }
5283
5427
  }
5284
- async function Cr(e, t, n) {
5428
+ async function Dr(e, t, n) {
5285
5429
  let r;
5286
5430
  try {
5287
5431
  r = o();
@@ -5300,13 +5444,13 @@ async function Cr(e, t, n) {
5300
5444
  return console.error(`${t.type} upload failed:`, e), URL.revokeObjectURL(n), null;
5301
5445
  }
5302
5446
  }
5303
- async function wr(e, t, n, r) {
5304
- let i = r ? cn(r) : void 0, a = i ? ln(e.state.doc, t, i) : null;
5447
+ async function Or(e, t, n, r) {
5448
+ let i = r ? ln(r) : void 0, a = i ? un(e.state.doc, t, i) : null;
5305
5449
  if (a) {
5306
5450
  Z(a);
5307
5451
  return;
5308
5452
  }
5309
- let o = URL.createObjectURL(t), s = Sr(e.state.schema, t, o);
5453
+ let o = URL.createObjectURL(t), s = Er(e.state.schema, t, o);
5310
5454
  if (!s) return;
5311
5455
  let c = n ?? e.state.selection.from;
5312
5456
  try {
@@ -5314,9 +5458,9 @@ async function wr(e, t, n, r) {
5314
5458
  } catch {
5315
5459
  return;
5316
5460
  }
5317
- await Cr(e, t, o);
5461
+ await Dr(e, t, o);
5318
5462
  }
5319
- var Tr = R.create({
5463
+ var kr = R.create({
5320
5464
  name: "imageUpload",
5321
5465
  addOptions() {
5322
5466
  return {
@@ -5337,23 +5481,23 @@ var Tr = R.create({
5337
5481
  left: n.clientX,
5338
5482
  top: n.clientY
5339
5483
  });
5340
- for (let n of Array.from(r)) br(n) ? xr(t, n, i?.pos, e) : wr(t, n, i?.pos, e);
5484
+ for (let n of Array.from(r)) wr(n) ? Tr(t, n, i?.pos, e) : Or(t, n, i?.pos, e);
5341
5485
  return !0;
5342
5486
  },
5343
5487
  handlePaste(t, n) {
5344
5488
  let r = n.clipboardData?.items;
5345
5489
  if (!r) return !1;
5346
5490
  let i = n.clipboardData?.getData("text/plain") || "";
5347
- if ((n.clipboardData?.files?.length ?? 0) > 0 && vr(i, void 0, a())) return !1;
5491
+ if ((n.clipboardData?.files?.length ?? 0) > 0 && Sr(i, void 0, a())) return !1;
5348
5492
  for (let i of Array.from(r)) {
5349
5493
  if (i.type.startsWith("image/") || i.type.startsWith("video/") || i.type.startsWith("audio/")) {
5350
5494
  n.preventDefault();
5351
5495
  let r = i.getAsFile();
5352
- return r && yr(r) !== "file" && wr(t, r, void 0, e), !0;
5496
+ return r && Cr(r) !== "file" && Or(t, r, void 0, e), !0;
5353
5497
  }
5354
5498
  if (i.kind === "file") {
5355
5499
  let r = i.getAsFile();
5356
- if (r && br(r)) return n.preventDefault(), xr(t, r, void 0, e), !0;
5500
+ if (r && wr(r)) return n.preventDefault(), Tr(t, r, void 0, e), !0;
5357
5501
  }
5358
5502
  }
5359
5503
  return !1;
@@ -5361,25 +5505,25 @@ var Tr = R.create({
5361
5505
  }
5362
5506
  })];
5363
5507
  }
5364
- }), Er = /\.(png|jpe?g|gif|webp|bmp|svg|avif)(\?|#|$)/i, Dr = /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|#|$)/i, Or = /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|#|$)/i;
5365
- function kr(e) {
5508
+ }), Ar = /\.(png|jpe?g|gif|webp|bmp|svg|avif)(\?|#|$)/i, jr = /\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|#|$)/i, Mr = /\.(mp3|wav|ogg|flac|aac|m4a|wma|opus)(\?|#|$)/i;
5509
+ function Nr(e) {
5366
5510
  return e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
5367
5511
  }
5368
- function Ar(e) {
5512
+ function Pr(e) {
5369
5513
  let t = e.trim().replace(/\\/g, "/");
5370
5514
  return t.split("/").pop() || t;
5371
5515
  }
5372
- function jr(e, t) {
5516
+ function Fr(e, t) {
5373
5517
  let n = e.src.slice(e.pos), r = /^!\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !0;
5374
5518
  if (r || (r = /^\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/.exec(n), i = !1), !r) return !1;
5375
5519
  let a = r[1].trim(), o = r[2]?.trim();
5376
5520
  if (!t) {
5377
- let t = o || Ar(a);
5521
+ let t = o || Pr(a);
5378
5522
  if (i) {
5379
5523
  let n = "";
5380
- if (Er.test(a) || /^data:image\//i.test(a)) n = `<img src="${kr(a)}" alt="${kr(t)}">`;
5381
- else if (Dr.test(a) || /^data:video\//i.test(a)) n = `<div data-video-embed src="${kr(a)}"></div>`;
5382
- else if (Or.test(a) || /^data:audio\//i.test(a)) n = `<audio src="${kr(a)}"></audio>`;
5524
+ if (Ar.test(a) || /^data:image\//i.test(a)) n = `<img src="${Nr(a)}" alt="${Nr(t)}">`;
5525
+ else if (jr.test(a) || /^data:video\//i.test(a)) n = `<div data-video-embed src="${Nr(a)}"></div>`;
5526
+ else if (Mr.test(a) || /^data:audio\//i.test(a)) n = `<audio src="${Nr(a)}"></audio>`;
5383
5527
  else {
5384
5528
  let n = e.push("link_open", "a", 1);
5385
5529
  n.attrs = [["href", a]];
@@ -5397,14 +5541,14 @@ function jr(e, t) {
5397
5541
  }
5398
5542
  return e.pos += r[0].length, !0;
5399
5543
  }
5400
- var Mr = R.create({
5544
+ var Ir = R.create({
5401
5545
  name: "obsidianMarkdown",
5402
5546
  addStorage() {
5403
5547
  return { markdown: { parse: { setup(e) {
5404
- e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed", jr));
5548
+ e.__obsidianReg || (e.__obsidianReg = !0, e.inline.ruler.before("link", "obsidian_embed", Fr));
5405
5549
  } } } };
5406
5550
  }
5407
- }), Nr = R.create({
5551
+ }), Lr = R.create({
5408
5552
  name: "qingwuUI",
5409
5553
  addStorage() {
5410
5554
  return {};
@@ -5412,7 +5556,7 @@ var Mr = R.create({
5412
5556
  });
5413
5557
  //#endregion
5414
5558
  //#region src/editor/utils/render-probe.ts
5415
- function Pr(e, t) {
5559
+ function Rr(e, t) {
5416
5560
  return new Promise((n) => {
5417
5561
  if (typeof Image != "function") return n(!0);
5418
5562
  let r = new Image(), i = !1, a = setTimeout(() => o(!1), t), o = (e) => {
@@ -5421,14 +5565,14 @@ function Pr(e, t) {
5421
5565
  r.onload = () => o(!0), r.onerror = () => o(!1), r.src = e;
5422
5566
  });
5423
5567
  }
5424
- async function Fr(e, t = 8e3) {
5425
- if (await Pr(e, t)) return !0;
5568
+ async function zr(e, t = 8e3) {
5569
+ if (await Rr(e, t)) return !0;
5426
5570
  try {
5427
5571
  let r = await n(e);
5428
5572
  if (!r) return !1;
5429
5573
  let i = await fetch(e, { headers: r });
5430
5574
  if (!i.ok) return !1;
5431
- let a = URL.createObjectURL(await i.blob()), o = await Pr(a, t);
5575
+ let a = URL.createObjectURL(await i.blob()), o = await Rr(a, t);
5432
5576
  return URL.revokeObjectURL(a), o;
5433
5577
  } catch {
5434
5578
  return !1;
@@ -5436,7 +5580,7 @@ async function Fr(e, t = 8e3) {
5436
5580
  }
5437
5581
  //#endregion
5438
5582
  //#region src/editor/utils/resolve-local-media.ts
5439
- function Ir() {
5583
+ function Br() {
5440
5584
  return {
5441
5585
  uploaded: 0,
5442
5586
  sessionOnly: 0,
@@ -5446,10 +5590,10 @@ function Ir() {
5446
5590
  readFailed: []
5447
5591
  };
5448
5592
  }
5449
- function Lr(e, t) {
5593
+ function Vr(e, t) {
5450
5594
  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);
5451
5595
  }
5452
- function Rr(e, t, n, r) {
5596
+ function Hr(e, t, n, r) {
5453
5597
  let { state: i } = e, a = [];
5454
5598
  if (i.doc.descendants((e, n) => {
5455
5599
  e.attrs?.src === t && a.push(n);
@@ -5465,7 +5609,7 @@ function Rr(e, t, n, r) {
5465
5609
  }
5466
5610
  return e.dispatch(o), !0;
5467
5611
  }
5468
- function zr(e, t, n) {
5612
+ function Ur(e, t, n) {
5469
5613
  let { state: r } = e, i = r.schema.marks.link;
5470
5614
  if (!i) return !1;
5471
5615
  let a = [];
@@ -5483,7 +5627,7 @@ function zr(e, t, n) {
5483
5627
  }));
5484
5628
  return e.dispatch(o), !0;
5485
5629
  }
5486
- function Br(e) {
5630
+ function Wr(e) {
5487
5631
  let t = /* @__PURE__ */ new Map();
5488
5632
  for (let n of e) {
5489
5633
  let e = t.get(n.normalized);
@@ -5491,36 +5635,36 @@ function Br(e) {
5491
5635
  }
5492
5636
  return Array.from(t.values());
5493
5637
  }
5494
- async function Vr(e, t, n, r) {
5638
+ async function Gr(e, t, n, r) {
5495
5639
  if (n.length === 0) return "sessionOnly";
5496
- let i = n[0], a = cn(t);
5640
+ let i = n[0], a = ln(t);
5497
5641
  if (a) {
5498
- let t = ln(e.state.doc, r, a);
5642
+ let t = un(e.state.doc, r, a);
5499
5643
  if (t) return Z(`${i.basename}:${t}`, "error"), "limitRejected";
5500
5644
  }
5501
5645
  let s = n.filter((e) => !e.isLink), c = n.filter((e) => e.isLink);
5502
5646
  if (s.length === 0) try {
5503
5647
  let t = await o().upload(r, "editor"), n = !1;
5504
- for (let r of c) zr(e, r.src, t) && (n = !0);
5648
+ for (let r of c) Ur(e, r.src, t) && (n = !0);
5505
5649
  return n ? "uploaded" : "sessionOnly";
5506
5650
  } catch (e) {
5507
5651
  return console.error(`本地附件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), "sessionOnly";
5508
5652
  }
5509
5653
  let l = URL.createObjectURL(r), u = !1;
5510
- for (let t of s) Rr(e, t.src, l, r.size) && (u = !0);
5654
+ for (let t of s) Hr(e, t.src, l, r.size) && (u = !0);
5511
5655
  let d;
5512
5656
  try {
5513
5657
  d = await o().upload(r, "editor");
5514
5658
  } catch (e) {
5515
5659
  return console.error(`本地文件 ${i.basename} 上传失败:`, e), Z(`「${i.basename}」上传失败`, "error"), URL.revokeObjectURL(l), "sessionOnly";
5516
5660
  }
5517
- URL.revokeObjectURL(l), u && Rr(e, l, d, r.size);
5518
- for (let t of c) zr(e, t.src, d);
5519
- return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await Fr(d) ? "uploaded" : "renderFailed" : "uploaded";
5661
+ URL.revokeObjectURL(l), u && Hr(e, l, d, r.size);
5662
+ for (let t of c) Ur(e, t.src, d);
5663
+ return !u && c.length === 0 ? "sessionOnly" : u && n.some((e) => e.kind === "image") ? await zr(d) ? "uploaded" : "renderFailed" : "uploaded";
5520
5664
  }
5521
- function Hr(e, t) {
5665
+ function Kr(e, t) {
5522
5666
  let n = [], r = [];
5523
- for (let i of Br(e)) {
5667
+ for (let i of Wr(e)) {
5524
5668
  let e = i[0], a = t.get(e.basename);
5525
5669
  a ? (n.push({
5526
5670
  refs: i,
@@ -5532,30 +5676,30 @@ function Hr(e, t) {
5532
5676
  unmatched: r
5533
5677
  };
5534
5678
  }
5535
- async function Ur(e, t, n, r) {
5536
- let i = Ir();
5537
- for (let a of Br(n)) {
5538
- let n = a[0], { file: o, readError: s } = await hr(r, n.src);
5679
+ async function qr(e, t, n, r) {
5680
+ let i = Br();
5681
+ for (let a of Wr(n)) {
5682
+ let n = a[0], { file: o, readError: s } = await yr(r, n.src);
5539
5683
  if (!o) {
5540
5684
  s ? (console.warn(`本地文件「${n.basename}」在所选文件夹中找到但读取失败:`, s), i.readFailed.push(n)) : (console.warn(`本地文件「${n.basename}」未在所选文件夹「${r.name}」中找到`), i.missing.push(n));
5541
5685
  continue;
5542
5686
  }
5543
- let c = await Vr(e, t, a, o);
5687
+ let c = await Gr(e, t, a, o);
5544
5688
  i[c]++;
5545
5689
  }
5546
5690
  return i;
5547
5691
  }
5548
- function Wr(e) {
5692
+ function Jr(e) {
5549
5693
  let t = e.map((e) => e.basename);
5550
5694
  return t.length <= 3 ? t.join("、") : `${t.slice(0, 3).join("、")} 等 ${t.length} 个文件`;
5551
5695
  }
5552
- function Gr(e) {
5696
+ function Yr(e) {
5553
5697
  let t = [];
5554
- if (e.uploaded > 0 && t.push(`${e.uploaded} 个已上传至存储`), e.sessionOnly > 0 && t.push(`${e.sessionOnly} 个仅本次会话可见(未配置存储或上传失败)`), e.limitRejected > 0 && t.push(`${e.limitRejected} 个超出大小限制`), e.renderFailed > 0 && t.push(`${e.renderFailed} 个上传成功但页面渲染失败(存储 URL 无法在浏览器访问/解码)`), e.readFailed.length > 0 && t.push(`${e.readFailed.length} 个找到但读取失败:${Wr(e.readFailed)}(若在 OneDrive / WPS 云盘等同步目录,请右键文件选择「始终保留在此设备」后重试)`), e.missing.length > 0 && t.push(`${e.missing.length} 个未能获取:${Wr(e.missing)}(可把文件直接拖进编辑器上传)`), t.length === 0) return;
5698
+ 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} 个找到但读取失败:${Jr(e.readFailed)}(若在 OneDrive / WPS 云盘等同步目录,请右键文件选择「始终保留在此设备」后重试)`), e.missing.length > 0 && t.push(`${e.missing.length} 个未能获取:${Jr(e.missing)}(可把文件直接拖进编辑器上传)`), t.length === 0) return;
5555
5699
  let n = e.uploaded > 0 && e.renderFailed === 0 && e.missing.length === 0 && e.readFailed.length === 0;
5556
5700
  Z(`本地文件解析完成:${t.join(";")}`, n ? "success" : "info");
5557
5701
  }
5558
- function Kr(e) {
5702
+ function Xr(e) {
5559
5703
  return new Promise((t) => {
5560
5704
  let n = document.createElement("div");
5561
5705
  n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
@@ -5582,7 +5726,7 @@ function Kr(e) {
5582
5726
  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);
5583
5727
  });
5584
5728
  }
5585
- function qr(e) {
5729
+ function Zr(e) {
5586
5730
  let t = document.createElement("div");
5587
5731
  t.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
5588
5732
  let n = document.createElement("div");
@@ -5604,7 +5748,7 @@ function qr(e) {
5604
5748
  let c = document.createElement("button");
5605
5749
  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);
5606
5750
  }
5607
- function Jr(e) {
5751
+ function Qr(e) {
5608
5752
  return new Promise((t) => {
5609
5753
  let n = document.createElement("div");
5610
5754
  n.className = "fixed inset-0 z-[10001] flex items-center justify-center bg-black/40 backdrop-blur-sm select-none";
@@ -5630,8 +5774,8 @@ function Jr(e) {
5630
5774
  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);
5631
5775
  });
5632
5776
  }
5633
- async function Yr(e, t, n) {
5634
- let r = Ir(), i = Br(n), a = await fr();
5777
+ async function $r(e, t, n) {
5778
+ let r = Br(), i = Wr(n), a = await gr();
5635
5779
  if (!a) {
5636
5780
  for (let e of i) r.missing.push(e[0]);
5637
5781
  return r;
@@ -5644,14 +5788,14 @@ async function Yr(e, t, n) {
5644
5788
  continue;
5645
5789
  }
5646
5790
  o.delete(i.basename);
5647
- let s = await Vr(e, t, n, a);
5791
+ let s = await Gr(e, t, n, a);
5648
5792
  r[s]++;
5649
5793
  }
5650
5794
  return r;
5651
5795
  }
5652
5796
  //#endregion
5653
5797
  //#region src/editor/extensions/relative-media.ts
5654
- var Xr = R.create({
5798
+ var ei = R.create({
5655
5799
  name: "relativeMedia",
5656
5800
  addStorage() {
5657
5801
  return {
@@ -5661,38 +5805,38 @@ var Xr = R.create({
5661
5805
  },
5662
5806
  addProseMirrorPlugins() {
5663
5807
  let e = this.editor, t = this.storage, n = !1, r = null, i = async (n, i) => {
5664
- let a = e.view, o = Ir(), { matched: s, unmatched: c } = Hr(n, t.clipboardFiles);
5808
+ let a = e.view, o = Br(), { matched: s, unmatched: c } = Kr(n, t.clipboardFiles);
5665
5809
  for (let { refs: t, file: n } of s) {
5666
- let r = await Vr(a, e, t, n);
5810
+ let r = await Gr(a, e, t, n);
5667
5811
  o[r]++;
5668
5812
  }
5669
5813
  if (c.length > 0) {
5670
- let t = Br(c).length;
5671
- if (lr()) {
5814
+ let t = Wr(c).length;
5815
+ if (pr()) {
5672
5816
  let n = i ?? null;
5673
- if (n || (await Kr(t) === "pick" ? (n = await ur(), n || Z("没有选择文件夹。本地文件暂以占位显示,稍后可直接把文件拖进编辑器上传", "info")) : Z("已选择稍后处理。本地文件暂以占位显示,可直接把文件拖进编辑器上传", "info")), n) {
5674
- r = n, Lr(o, await Ur(a, e, c, n));
5817
+ if (n || (await Xr(t) === "pick" ? (n = await mr(), n || Z("没有选择文件夹。本地文件暂以占位显示,稍后可直接把文件拖进编辑器上传", "info")) : Z("已选择稍后处理。本地文件暂以占位显示,可直接把文件拖进编辑器上传", "info")), n) {
5818
+ r = n, Vr(o, await qr(a, e, c, n));
5675
5819
  let t = [...o.missing, ...o.readFailed];
5676
- if (t.length > 0 && dr() && await Jr(t.map((e) => e.basename)) === "pick") {
5677
- let n = await Yr(a, e, t);
5678
- Lr(o, n), o.missing = n.missing, o.readFailed = [];
5820
+ if (t.length > 0 && hr() && await Qr(t.map((e) => e.basename)) === "pick") {
5821
+ let n = await $r(a, e, t);
5822
+ Vr(o, n), o.missing = n.missing, o.readFailed = [];
5679
5823
  }
5680
5824
  }
5681
- } else qr(t);
5825
+ } else Zr(t);
5682
5826
  }
5683
- Gr(o);
5827
+ Yr(o);
5684
5828
  }, o = () => {
5685
5829
  if (!e || e.isDestroyed || t.pausedUntilPaste) return;
5686
- let o = a(), s = _r(e.state.doc, o);
5830
+ let o = a(), s = xr(e.state.doc, o);
5687
5831
  if (s.length === 0 || n) return;
5688
5832
  n = !0;
5689
5833
  let c = new Set(s.map((e) => e.src));
5690
5834
  i(s).then(() => {
5691
5835
  if (e.isDestroyed) return;
5692
- let t = _r(e.state.doc, o).filter((e) => !c.has(e.src));
5836
+ let t = xr(e.state.doc, o).filter((e) => !c.has(e.src));
5693
5837
  if (t.length !== 0) return i(t, r);
5694
5838
  }).finally(() => {
5695
- n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste = _r(e.state.doc, o).length > 0);
5839
+ n = !1, !(!e || e.isDestroyed) && (t.pausedUntilPaste = xr(e.state.doc, o).length > 0);
5696
5840
  });
5697
5841
  };
5698
5842
  return [new z({
@@ -5706,18 +5850,18 @@ var Xr = R.create({
5706
5850
  }
5707
5851
  })];
5708
5852
  }
5709
- }), Zr = new B("slashCommand");
5710
- function Qr(e) {
5853
+ }), ti = new B("slashCommand");
5854
+ function ni(e) {
5711
5855
  return R.create({
5712
5856
  name: "slashCommand",
5713
5857
  addProseMirrorPlugins() {
5714
5858
  let t = {
5715
5859
  char: "/",
5716
- pluginKey: Zr,
5860
+ pluginKey: ti,
5717
5861
  findSuggestionMatch: (e) => {
5718
5862
  let { $position: t } = e;
5719
5863
  for (let e = t.depth; e >= 0; e--) if (t.node(e).type.name === "codeBlock") return null;
5720
- return t.marks().some((e) => e.type.name === "code") ? null : we(e);
5864
+ return t.marks().some((e) => e.type.name === "code") ? null : Ce(e);
5721
5865
  },
5722
5866
  allow: ({ editor: e, state: t }) => {
5723
5867
  if (!e.isEditable) return !1;
@@ -5735,69 +5879,113 @@ function Qr(e) {
5735
5879
  return n.filter((e) => e.title.toLowerCase().includes(r) || (e.description?.toLowerCase().includes(r) ?? !1));
5736
5880
  },
5737
5881
  render: () => {
5738
- let e = null, t = null, n = 0, r = [];
5739
- function i(e, i) {
5882
+ let e = null, t = null, n = 0, r = [], i = null, a = null, o = null;
5883
+ function s(e, o) {
5740
5884
  if (!t) return;
5741
- r = e, t.textContent = "";
5742
- let a = document.createElement("div");
5743
- a.style.cssText = "padding:6px 8px;border-bottom:1px solid #f4f4f5;";
5744
- let o = document.createElement("input");
5745
- o.type = "text", o.placeholder = "搜索命令…", o.style.cssText = "width:100%;padding:6px 8px;border:1px solid #e4e4e7;border-radius:8px;font-size:13px;outline:none;background:#fafafa;", a.appendChild(o), t.appendChild(a);
5885
+ r = e, i = o, t.textContent = "";
5746
5886
  let s = document.createElement("div");
5747
- if (s.className = "slash-item-list", s.style.cssText = "max-height:300px;overflow-y:auto;", e.length === 0) {
5887
+ s.style.cssText = "padding:6px 8px;border-bottom:1px solid #f4f4f5;";
5888
+ let c = document.createElement("input");
5889
+ c.type = "text", c.placeholder = "搜索命令…", c.style.cssText = "width:100%;padding:6px 8px;border:1px solid #e4e4e7;border-radius:8px;font-size:13px;outline:none;background:#fafafa;", s.appendChild(c), t.appendChild(s);
5890
+ let l = document.createElement("div");
5891
+ if (l.className = "slash-item-list", l.style.cssText = "max-height:300px;overflow-y:auto;", e.length === 0) {
5748
5892
  let e = document.createElement("div");
5749
- e.style.cssText = "padding:12px;text-align:center;color:#a1a1aa;font-size:13px;", e.textContent = "未找到匹配", s.appendChild(e);
5893
+ e.style.cssText = "padding:12px;text-align:center;color:#a1a1aa;font-size:13px;", e.textContent = "未找到匹配", l.appendChild(e);
5750
5894
  } else e.forEach((e, t) => {
5751
5895
  let r = document.createElement("button");
5752
5896
  r.type = "button", r.className = `slash-item${t === n ? " slash-item--selected" : ""}`, r.dataset.index = String(t), r.style.cssText = `display:flex;align-items:center;gap:12px;width:100%;padding:8px 12px;border:none;background:${t === n ? "#f4f4f5" : "transparent"};cursor:pointer;text-align:left;border-radius:8px;font-size:14px;transition:background 0.1s;`;
5753
- let a = document.createElement("span");
5754
- a.style.cssText = "font-size:16px;width:24px;text-align:center;flex-shrink:0;", a.textContent = e.icon || "", r.appendChild(a);
5755
- let o = document.createElement("div");
5756
- o.style.cssText = "min-width:0;";
5757
- let c = document.createElement("div");
5758
- if (c.style.cssText = "font-weight:500;color:#18181b;", c.textContent = e.title, o.appendChild(c), e.description) {
5897
+ let i = document.createElement("span");
5898
+ i.style.cssText = "font-size:16px;width:24px;text-align:center;flex-shrink:0;", i.textContent = e.icon || "", r.appendChild(i);
5899
+ let a = document.createElement("div");
5900
+ a.style.cssText = "min-width:0;";
5901
+ let s = document.createElement("div");
5902
+ if (s.style.cssText = "font-weight:500;color:#18181b;", s.textContent = e.title, a.appendChild(s), e.description) {
5759
5903
  let t = document.createElement("div");
5760
- t.style.cssText = "font-size:12px;color:#a1a1aa;margin-top:1px;", t.textContent = e.description, o.appendChild(t);
5904
+ t.style.cssText = "font-size:12px;color:#a1a1aa;margin-top:1px;", t.textContent = e.description, a.appendChild(t);
5761
5905
  }
5762
- r.appendChild(o), r.addEventListener("click", () => {
5763
- i(e);
5764
- }), s.appendChild(r);
5906
+ r.appendChild(a), r.addEventListener("click", () => {
5907
+ o(e);
5908
+ }), l.appendChild(r);
5765
5909
  });
5766
- t.appendChild(s);
5767
- let c = s.querySelector(".slash-item--selected");
5768
- if (c) {
5769
- let e = s.getBoundingClientRect(), t = c.getBoundingClientRect();
5770
- t.top < e.top ? s.scrollTop -= e.top - t.top : t.bottom > e.bottom && (s.scrollTop += t.bottom - e.bottom);
5910
+ t.appendChild(l);
5911
+ let u = l.querySelector(".slash-item--selected");
5912
+ if (u) {
5913
+ let e = l.getBoundingClientRect(), t = u.getBoundingClientRect();
5914
+ t.top < e.top ? l.scrollTop -= e.top - t.top : t.bottom > e.bottom && (l.scrollTop += t.bottom - e.bottom);
5771
5915
  }
5772
- o.addEventListener("input", () => {
5773
- let e = o.value.toLowerCase();
5774
- s.querySelectorAll(".slash-item").forEach((t) => {
5916
+ let d = () => Array.from(l.querySelectorAll(".slash-item")).filter((e) => e.style.display !== "none" && !e.disabled), f = (e) => {
5917
+ l.querySelectorAll(".slash-item").forEach((t) => {
5918
+ t.classList.toggle("slash-item--selected", t === e), t.style.background = t === e ? "#f4f4f5" : "transparent";
5919
+ });
5920
+ let t = l.getBoundingClientRect(), n = e.getBoundingClientRect();
5921
+ n.top < t.top ? l.scrollTop -= t.top - n.top : n.bottom > t.bottom && (l.scrollTop += n.bottom - t.bottom);
5922
+ };
5923
+ c.addEventListener("input", () => {
5924
+ let e = c.value.toLowerCase();
5925
+ l.querySelectorAll(".slash-item").forEach((t) => {
5775
5926
  let n = (t.textContent || "").toLowerCase();
5776
5927
  t.style.display = n.includes(e) ? "" : "none";
5777
5928
  });
5929
+ let t = d()[0];
5930
+ t && (n = Number(t.dataset.index ?? 0), f(t));
5931
+ }), c.addEventListener("keydown", (e) => {
5932
+ let t = d();
5933
+ if (e.key === "Enter") {
5934
+ e.preventDefault(), (t.find((e) => e.classList.contains("slash-item--selected")) ?? t[0])?.click();
5935
+ return;
5936
+ }
5937
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
5938
+ if (e.preventDefault(), t.length === 0) return;
5939
+ 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];
5940
+ n = Number(i.dataset.index ?? 0), f(i);
5941
+ return;
5942
+ }
5943
+ if (e.key === "Escape") {
5944
+ e.preventDefault();
5945
+ let t = a?.view;
5946
+ t && Se(t, ti);
5947
+ }
5778
5948
  });
5779
5949
  }
5780
- let a = null, o = null;
5781
- function s() {
5782
- if (!e || !a) return;
5783
- let t = a();
5950
+ let c = null, l = null;
5951
+ function u() {
5952
+ if (!e || !c) return;
5953
+ let t = c();
5784
5954
  t && (e.style.top = `${t.bottom + 4}px`, e.style.left = `${t.left}px`);
5785
5955
  }
5786
5956
  return {
5787
- onStart: (c) => {
5788
- n = 0, a = c.clientRect || null, e || (e = document.createElement("div"), e.style.position = "fixed", e.style.zIndex = "9999", document.body.appendChild(e)), t || (t = document.createElement("div"), t.className = "slash-command-popup", t.style.cssText = "background:#fff;border:1px solid #e4e4e7;border-radius:12px;box-shadow:0 4px 24px rgba(0,0,0,0.12);min-width:260px;max-width:340px;", t.setAttribute("data-lenis-prevent", ""), e.appendChild(t)), s(), r = c.items, i(c.items, c.command), e.style.display = "block", o = () => s(), window.addEventListener("scroll", o, !0);
5957
+ onStart: (i) => {
5958
+ if (n = 0, c = i.clientRect || null, a = { view: i.editor.view }, e || (e = document.createElement("div"), e.style.position = "fixed", e.style.zIndex = "9999", document.body.appendChild(e)), t || (t = document.createElement("div"), t.className = "slash-command-popup", t.style.cssText = "background:#fff;border:1px solid #e4e4e7;border-radius:12px;box-shadow:0 4px 24px rgba(0,0,0,0.12);min-width:260px;max-width:340px;", t.setAttribute("data-lenis-prevent", ""), e.appendChild(t)), u(), r = i.items, s(i.items, i.command), e.style.display = "block", l = () => u(), window.addEventListener("scroll", l, !0), !o) {
5959
+ let t = !1;
5960
+ o = (n) => {
5961
+ if (!e || e.style.display === "none" || n.target instanceof Node && e.contains(n.target) || t) return;
5962
+ let r = a?.view;
5963
+ r && (t = !0, window.setTimeout(() => {
5964
+ t = !1, e?.style.display !== "none" && Se(r, ti);
5965
+ }, 0));
5966
+ }, document.addEventListener("mousedown", o, !0), document.addEventListener("touchstart", o, !0);
5967
+ }
5789
5968
  },
5790
5969
  onUpdate: (e) => {
5791
- n = 0, a = e.clientRect || null, r = e.items, i(e.items, e.command), s();
5970
+ n = 0, c = e.clientRect || null, a = { view: e.editor.view }, r = e.items, s(e.items, e.command), u();
5971
+ },
5972
+ onKeyDown: (e) => {
5973
+ if (e.event.key === "ArrowDown") return e.event.preventDefault(), n = Math.min(n + 1, r.length - 1), i && s(r, i), !0;
5974
+ if (e.event.key === "ArrowUp") return e.event.preventDefault(), n = Math.max(n - 1, 0), i && s(r, i), !0;
5975
+ if (e.event.key === "Enter") {
5976
+ e.event.preventDefault();
5977
+ let t = r[n];
5978
+ return t && typeof t.command == "function" && i && i(t), !0;
5979
+ }
5980
+ return e.event.key === "Escape";
5792
5981
  },
5793
- onKeyDown: (e) => e.event.key === "ArrowDown" ? (e.event.preventDefault(), n = Math.min(n + 1, r.length - 1), i(r, e.command), !0) : e.event.key === "ArrowUp" ? (e.event.preventDefault(), n = Math.max(n - 1, 0), i(r, e.command), !0) : e.event.key === "Enter" ? (e.event.preventDefault(), r[n] && e.command(r[n]), !0) : e.event.key === "Escape",
5794
5982
  onExit: () => {
5795
- e && (e.style.display = "none"), n = 0, r = [], a = null, o &&= (window.removeEventListener("scroll", o, !0), null);
5983
+ e && (e.style.display = "none"), n = 0, r = [], i = null, c = null, a = null, l &&= (window.removeEventListener("scroll", l, !0), null), o &&= (document.removeEventListener("mousedown", o, !0), document.removeEventListener("touchstart", o, !0), null);
5796
5984
  }
5797
5985
  };
5798
5986
  }
5799
5987
  };
5800
- return [Ce({
5988
+ return [xe({
5801
5989
  editor: this.editor,
5802
5990
  ...t
5803
5991
  }), new z({
@@ -5809,14 +5997,14 @@ function Qr(e) {
5809
5997
  break;
5810
5998
  }
5811
5999
  if (!i && !r.marks().some((e) => e.type.name === "code")) return null;
5812
- let a = Zr.getState(n);
5813
- return a && a.active ? n.tr.setMeta(Zr, { exit: !0 }) : null;
6000
+ let a = ti.getState(n);
6001
+ return a && a.active ? n.tr.setMeta(ti, { exit: !0 }) : null;
5814
6002
  }
5815
6003
  })];
5816
6004
  }
5817
6005
  });
5818
6006
  }
5819
- function $r(e, t) {
6007
+ function ri(e, t) {
5820
6008
  return [
5821
6009
  {
5822
6010
  title: e("editor.slash.heading1"),
@@ -5915,7 +6103,7 @@ function $r(e, t) {
5915
6103
  n.type = "file", n.accept = "audio/*", n.onchange = async () => {
5916
6104
  let r = n.files?.[0];
5917
6105
  if (!r) return;
5918
- let i = cn(e) ?? t, a = i ? ln(e.state.doc, r, i) : null;
6106
+ let i = ln(e) ?? t, a = i ? un(e.state.doc, r, i) : null;
5919
6107
  if (a) {
5920
6108
  Z(a);
5921
6109
  return;
@@ -5925,7 +6113,7 @@ function $r(e, t) {
5925
6113
  name: r.name,
5926
6114
  size: r.size
5927
6115
  });
5928
- s && (e.chain().focus().insertContent(s).run(), await Cr(e.view, r, o));
6116
+ s && (e.chain().focus().insertContent(s).run(), await Dr(e.view, r, o));
5929
6117
  }, n.click();
5930
6118
  }
5931
6119
  },
@@ -5938,7 +6126,7 @@ function $r(e, t) {
5938
6126
  n.type = "file", n.accept = "*/*", n.multiple = !0, n.onchange = async () => {
5939
6127
  let r = n.files;
5940
6128
  if (!(!r || r.length === 0)) for (let n of Array.from(r)) {
5941
- let r = cn(e) ?? t, i = r ? ln(e.state.doc, n, r) : null;
6129
+ let r = ln(e) ?? t, i = r ? un(e.state.doc, n, r) : null;
5942
6130
  if (i) {
5943
6131
  Z(i);
5944
6132
  continue;
@@ -5955,7 +6143,7 @@ function $r(e, t) {
5955
6143
  } catch {
5956
6144
  continue;
5957
6145
  }
5958
- await Cr(e.view, n, a);
6146
+ await Dr(e.view, n, a);
5959
6147
  }
5960
6148
  }
5961
6149
  }, n.click();
@@ -5965,9 +6153,9 @@ function $r(e, t) {
5965
6153
  }
5966
6154
  //#endregion
5967
6155
  //#region src/editor/extensions/index.ts
5968
- var ei = ce.extend({
6156
+ var ii = oe.extend({
5969
6157
  addNodeView() {
5970
- return L(bn);
6158
+ return I(xn);
5971
6159
  },
5972
6160
  addAttributes() {
5973
6161
  return {
@@ -5990,111 +6178,111 @@ var ei = ce.extend({
5990
6178
  };
5991
6179
  }
5992
6180
  });
5993
- function ti(e = {}) {
6181
+ function ai(e = {}) {
5994
6182
  return [
5995
- le.configure({
6183
+ G.configure({
5996
6184
  codeBlock: !1,
5997
6185
  horizontalRule: !1,
5998
6186
  underline: !1,
5999
6187
  link: !1
6000
6188
  }),
6001
- H,
6002
- V.configure({
6189
+ W,
6190
+ U.configure({
6003
6191
  openOnClick: !0,
6004
6192
  HTMLAttributes: {
6005
6193
  rel: "noopener noreferrer",
6006
6194
  target: "_blank"
6007
6195
  }
6008
6196
  }),
6009
- ei.configure({
6197
+ ii.configure({
6010
6198
  inline: !1,
6011
6199
  allowBase64: !0
6012
6200
  }),
6013
- ge,
6014
- he.configure({ nested: !0 }),
6015
- ue.configure({ multicolor: !0 }),
6016
- _e,
6017
- W,
6018
- U.configure(e.maxLength ? { limit: e.maxLength } : {}),
6019
- de,
6020
- tr,
6021
- fe.configure({ resizable: !0 }),
6022
- K,
6023
- pe,
6024
6201
  me,
6025
- ve.configure({
6202
+ pe.configure({ nested: !0 }),
6203
+ se.configure({ multicolor: !0 }),
6204
+ he,
6205
+ q,
6206
+ K.configure(e.maxLength ? { limit: e.maxLength } : {}),
6207
+ ce,
6208
+ ar,
6209
+ le.configure({ resizable: !0 }),
6210
+ fe,
6211
+ ue,
6212
+ de,
6213
+ ge.configure({
6026
6214
  html: !0,
6027
6215
  transformPastedText: !0,
6028
6216
  transformCopiedText: !1
6029
6217
  }),
6030
- G.configure({ placeholder: e.placeholder || "输入 '/' 打开菜单…" }),
6031
- Qr(() => $r((e) => f(e), {
6218
+ J.configure({ placeholder: e.placeholder || "输入 '/' 打开菜单…" }),
6219
+ ni(() => ri((e) => f(e), {
6032
6220
  maxAttachmentSize: e.maxAttachmentSize,
6033
6221
  maxTotalAttachmentSize: e.maxTotalAttachmentSize
6034
6222
  })),
6035
- Tr.configure({
6223
+ kr.configure({
6036
6224
  maxAttachmentSize: e.maxAttachmentSize,
6037
6225
  maxTotalAttachmentSize: e.maxTotalAttachmentSize
6038
6226
  }),
6039
- Xr,
6040
- Mr,
6041
- Tt,
6042
- Nr,
6043
- Gn,
6044
- Rn,
6045
- Fn
6227
+ ei,
6228
+ Ir,
6229
+ Et,
6230
+ Lr,
6231
+ Kn,
6232
+ zn,
6233
+ In
6046
6234
  ];
6047
6235
  }
6048
6236
  //#endregion
6049
6237
  //#region src/editor/extensions/bubble-menu.tsx
6050
- var ni = "https://www.bing.com/search?q={query}";
6051
- function ri(e) {
6052
- ni = e;
6238
+ var oi = "https://www.bing.com/search?q={query}";
6239
+ function si(e) {
6240
+ oi = e;
6053
6241
  }
6054
- function ii() {
6055
- return ni;
6242
+ function ci() {
6243
+ return oi;
6056
6244
  }
6057
- function ai(e) {
6245
+ function li(e) {
6058
6246
  return [
6059
6247
  {
6060
6248
  key: "bold",
6061
6249
  label: e("editor.bubble.bold"),
6062
- icon: /* @__PURE__ */ D(Ot, {}),
6250
+ icon: /* @__PURE__ */ D(kt, {}),
6063
6251
  isActive: (e) => e.isActive("bold"),
6064
6252
  command: (e) => e.isEditable && e.chain().focus().toggleBold().run()
6065
6253
  },
6066
6254
  {
6067
6255
  key: "italic",
6068
6256
  label: e("editor.bubble.italic"),
6069
- icon: /* @__PURE__ */ D(kt, {}),
6257
+ icon: /* @__PURE__ */ D(At, {}),
6070
6258
  isActive: (e) => e.isActive("italic"),
6071
6259
  command: (e) => e.isEditable && e.chain().focus().toggleItalic().run()
6072
6260
  },
6073
6261
  {
6074
6262
  key: "underline",
6075
6263
  label: e("editor.bubble.underline"),
6076
- icon: /* @__PURE__ */ D(At, {}),
6264
+ icon: /* @__PURE__ */ D(jt, {}),
6077
6265
  isActive: (e) => e.isActive("underline"),
6078
6266
  command: (e) => e.isEditable && e.chain().focus().toggleUnderline().run()
6079
6267
  },
6080
6268
  {
6081
6269
  key: "strikethrough",
6082
6270
  label: e("editor.bubble.strikethrough"),
6083
- icon: /* @__PURE__ */ D(jt, {}),
6271
+ icon: /* @__PURE__ */ D(Mt, {}),
6084
6272
  isActive: (e) => e.isActive("strike"),
6085
6273
  command: (e) => e.isEditable && e.chain().focus().toggleStrike().run()
6086
6274
  },
6087
6275
  {
6088
6276
  key: "code",
6089
6277
  label: e("editor.bubble.emphasis"),
6090
- icon: /* @__PURE__ */ D(Mt, {}),
6278
+ icon: /* @__PURE__ */ D(Nt, {}),
6091
6279
  isActive: (e) => e.isActive("code"),
6092
6280
  command: (e) => e.isEditable && e.chain().focus().toggleCode().run()
6093
6281
  },
6094
6282
  {
6095
6283
  key: "highlight",
6096
6284
  label: e("editor.bubble.highlight"),
6097
- icon: /* @__PURE__ */ D(Nt, {}),
6285
+ icon: /* @__PURE__ */ D(Pt, {}),
6098
6286
  more: !0,
6099
6287
  isActive: (e) => e.isActive("highlight"),
6100
6288
  command: () => {}
@@ -6102,7 +6290,7 @@ function ai(e) {
6102
6290
  {
6103
6291
  key: "link",
6104
6292
  label: e("editor.bubble.link"),
6105
- icon: /* @__PURE__ */ D(Pt, {}),
6293
+ icon: /* @__PURE__ */ D(Ft, {}),
6106
6294
  more: !0,
6107
6295
  isActive: (e) => e.isActive("link"),
6108
6296
  command: () => {}
@@ -6110,7 +6298,7 @@ function ai(e) {
6110
6298
  {
6111
6299
  key: "copy",
6112
6300
  label: e("editor.bubble.copy"),
6113
- icon: /* @__PURE__ */ D(It, {}),
6301
+ icon: /* @__PURE__ */ D(Lt, {}),
6114
6302
  more: !0,
6115
6303
  isActive: () => !1,
6116
6304
  command: (e) => {
@@ -6121,21 +6309,21 @@ function ai(e) {
6121
6309
  {
6122
6310
  key: "search",
6123
6311
  label: e("editor.bubble.search"),
6124
- icon: /* @__PURE__ */ D(Lt, {}),
6312
+ icon: /* @__PURE__ */ D(Rt, {}),
6125
6313
  more: !0,
6126
6314
  isActive: () => !1,
6127
6315
  command: (e) => {
6128
6316
  if (e.isActive("table")) return;
6129
6317
  let { from: t, to: n } = e.state.selection, r = e.state.doc.textBetween(t, n, " ").trim();
6130
6318
  if (!r) return;
6131
- let i = ni.replace("{query}", encodeURIComponent(r));
6319
+ let i = oi.replace("{query}", encodeURIComponent(r));
6132
6320
  window.open(i, "_blank", "noopener,noreferrer");
6133
6321
  }
6134
6322
  },
6135
6323
  {
6136
6324
  key: "table",
6137
6325
  label: e("editor.bubble.table"),
6138
- icon: /* @__PURE__ */ D(Ft, {}),
6326
+ icon: /* @__PURE__ */ D(It, {}),
6139
6327
  more: !0,
6140
6328
  isActive: (e) => e.isActive("table"),
6141
6329
  command: (e) => {
@@ -6151,7 +6339,7 @@ function ai(e) {
6151
6339
  {
6152
6340
  key: "ai",
6153
6341
  label: e("editor.ai.trigger"),
6154
- icon: /* @__PURE__ */ D(Rt, {}),
6342
+ icon: /* @__PURE__ */ D(zt, {}),
6155
6343
  isActive: () => !1,
6156
6344
  command: (e) => {
6157
6345
  e.isEditable && e.storage.qingwuUI?.openAI?.();
@@ -6162,7 +6350,7 @@ function ai(e) {
6162
6350
  R.create({ name: "bubbleMenu" });
6163
6351
  //#endregion
6164
6352
  //#region src/editor/extensions/table-toolbar.tsx
6165
- function oi(e) {
6353
+ function ui(e) {
6166
6354
  let { $from: t } = e.state.selection;
6167
6355
  for (let e = t.depth; e > 0; e--) {
6168
6356
  let n = t.node(e);
@@ -6173,7 +6361,7 @@ function oi(e) {
6173
6361
  }
6174
6362
  return null;
6175
6363
  }
6176
- function si(e) {
6364
+ function di(e) {
6177
6365
  let t = [];
6178
6366
  return e.forEach((e) => {
6179
6367
  let n = [];
@@ -6182,7 +6370,7 @@ function si(e) {
6182
6370
  }), t.push(n);
6183
6371
  }), t;
6184
6372
  }
6185
- function ci(e) {
6373
+ function fi(e) {
6186
6374
  if (e.length === 0) return "";
6187
6375
  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(" | ")} |`;
6188
6376
  return [
@@ -6191,11 +6379,11 @@ function ci(e) {
6191
6379
  ...i.map(a)
6192
6380
  ].join("\n");
6193
6381
  }
6194
- function li(e) {
6382
+ function pi(e) {
6195
6383
  let t = (e) => /[",\n]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e;
6196
6384
  return e.map((e) => e.map(t).join(",")).join("\n");
6197
6385
  }
6198
- function ui(e) {
6386
+ function mi(e) {
6199
6387
  let t = e.trim();
6200
6388
  if (!t) return null;
6201
6389
  let n = t.split(/\r?\n/);
@@ -6209,7 +6397,7 @@ function ui(e) {
6209
6397
  }
6210
6398
  return null;
6211
6399
  }
6212
- function di({ editor: e }) {
6400
+ function hi({ editor: e }) {
6213
6401
  let [t, n] = T(null), [r, i] = T(!1), [a, o] = T(!1), s = w(null), c = w(null), l = e.isEditable, u = b(() => {
6214
6402
  c.current != null && cancelAnimationFrame(c.current), c.current = requestAnimationFrame(() => {
6215
6403
  c.current = null;
@@ -6225,7 +6413,7 @@ function di({ editor: e }) {
6225
6413
  n(null);
6226
6414
  return;
6227
6415
  }
6228
- let t = oi(e);
6416
+ let t = ui(e);
6229
6417
  if (!t) {
6230
6418
  n(null);
6231
6419
  return;
@@ -6254,24 +6442,24 @@ function di({ editor: e }) {
6254
6442
  });
6255
6443
  return n.nodes.table.create(null, i);
6256
6444
  }, p = () => {
6257
- let t = oi(e);
6445
+ let t = ui(e);
6258
6446
  if (!t) return;
6259
- let n = ci(si(t.node));
6447
+ let n = fi(di(t.node));
6260
6448
  navigator.clipboard?.writeText(n), i(!0), setTimeout(() => i(!1), 1500);
6261
6449
  }, m = () => {
6262
- let t = oi(e);
6450
+ let t = ui(e);
6263
6451
  if (!t) return;
6264
- let n = li(si(t.node)), r = new Blob([`\ufeff${n}`], { type: "text/csv;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
6452
+ let n = pi(di(t.node)), r = new Blob([`\ufeff${n}`], { type: "text/csv;charset=utf-8" }), i = URL.createObjectURL(r), a = document.createElement("a");
6265
6453
  a.href = i, a.download = "table.csv", document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
6266
6454
  }, h = async () => {
6267
6455
  if (l) try {
6268
6456
  let t = await navigator.clipboard?.readText();
6269
6457
  if (!t) return;
6270
- let n = ui(t);
6458
+ let n = mi(t);
6271
6459
  if (!n || n.length === 0) return;
6272
6460
  let r = f(n);
6273
6461
  if (!r) return;
6274
- let i = oi(e), a = e.chain().focus();
6462
+ let i = ui(e), a = e.chain().focus();
6275
6463
  if (i) {
6276
6464
  let t = Math.min(i.pos + i.node.nodeSize, e.state.doc.content.size);
6277
6465
  a.setTextSelection(t);
@@ -6391,7 +6579,7 @@ function di({ editor: e }) {
6391
6579
  type: "button",
6392
6580
  className: "tbl-btn tbl-btn--del",
6393
6581
  onClick: () => {
6394
- !l || pn() || ($(!0), o(!0));
6582
+ !l || mn() || ($(!0), o(!0));
6395
6583
  },
6396
6584
  title: "删除",
6397
6585
  children: /* @__PURE__ */ D("svg", {
@@ -6409,7 +6597,7 @@ function di({ editor: e }) {
6409
6597
  })
6410
6598
  })
6411
6599
  }),
6412
- /* @__PURE__ */ D(vn, {
6600
+ /* @__PURE__ */ D(yn, {
6413
6601
  open: a,
6414
6602
  title: "确认删除表格",
6415
6603
  message: "此操作不可撤销。",
@@ -6425,7 +6613,7 @@ function di({ editor: e }) {
6425
6613
  }
6426
6614
  //#endregion
6427
6615
  //#region src/editor/ai-editor.tsx
6428
- var fi = [
6616
+ var gi = [
6429
6617
  {
6430
6618
  color: "#fef08a",
6431
6619
  name: "黄"
@@ -6450,9 +6638,9 @@ var fi = [
6450
6638
  color: "#ddd6fe",
6451
6639
  name: "紫"
6452
6640
  }
6453
- ], pi = 288, mi = 480, hi = 320;
6454
- function gi(e, t, n = {}) {
6455
- let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth || pi, mi, r - 32), o = Math.max(t || hi, 160);
6641
+ ], _i = 288, vi = 480, yi = 320;
6642
+ function bi(e, t, n = {}) {
6643
+ let r = window.innerWidth, i = window.innerHeight, a = Math.min(n.panelWidth || _i, vi, r - 32), o = Math.max(t || yi, 160);
6456
6644
  if (r < 640) {
6457
6645
  let t = Math.max(8, Math.min(e.top + 10, i - 420));
6458
6646
  return {
@@ -6493,10 +6681,10 @@ function gi(e, t, n = {}) {
6493
6681
  arrowLeft: p
6494
6682
  };
6495
6683
  }
6496
- function _i(e) {
6684
+ function xi(e) {
6497
6685
  return /(^|\n)```|(^|\n)#{1,6}\s|(^|\n)>\s?|(^|\n)\s*([-*_])(?:\s*\4){2,}\s*(?=\n|$)|(^|\n)\s*[-*+]\s+|(^|\n)\s*\d+[.)]\s+|(^|\n)\s*<img\s+|(^|\n)\s*\|.+\|/i.test(e);
6498
6686
  }
6499
- function vi(e, t) {
6687
+ function Si(e, t) {
6500
6688
  try {
6501
6689
  let n = e.storage?.markdown?.parser;
6502
6690
  if (!n) return null;
@@ -6506,20 +6694,20 @@ function vi(e, t) {
6506
6694
  return null;
6507
6695
  }
6508
6696
  }
6509
- var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.ImageUploadDialog }))), bi = y(() => import("./storage-settings-dialog-DZqqDAiO.js").then((e) => ({ default: e.StorageSettingsDialog }))), xi = y(() => import("./export-dialog-CL7ie13Z.js").then((e) => ({ default: e.ExportDialog }))), Si = y(() => import("./video-embed-dialog-AeGcMb4X.js").then((e) => ({ default: e.VideoEmbedDialog }))), Ci = y(() => import("./md-import-dialog-Cf3ZOwA_.js").then((e) => ({ default: e.MdImportDialog }))), wi = () => /* @__PURE__ */ O("div", {
6697
+ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.ImageUploadDialog }))), wi = y(() => import("./storage-settings-dialog-DZqqDAiO.js").then((e) => ({ default: e.StorageSettingsDialog }))), Ti = y(() => import("./export-dialog-CL7ie13Z.js").then((e) => ({ default: e.ExportDialog }))), Ei = y(() => import("./video-embed-dialog-AeGcMb4X.js").then((e) => ({ default: e.VideoEmbedDialog }))), Di = y(() => import("./md-import-dialog-Cf3ZOwA_.js").then((e) => ({ default: e.MdImportDialog }))), Oi = () => /* @__PURE__ */ O("div", {
6510
6698
  className: "fixed inset-0 z-[9999] flex items-center justify-center",
6511
6699
  children: [/* @__PURE__ */ D("div", { className: "absolute inset-0 bg-black/40 backdrop-blur-sm" }), /* @__PURE__ */ D("div", {
6512
6700
  className: "relative bg-background rounded-2xl border border-default-200 p-8 flex items-center justify-center",
6513
6701
  children: /* @__PURE__ */ D("div", { className: "w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin" })
6514
6702
  })]
6515
- }), Ti = ({ initialContent: e = "", onChange: t, placeholder: n, mode: r, readonly: i = !1, maxLength: a, maxAttachmentSize: o, maxTotalAttachmentSize: s, className: c = "", borderless: l = !1, style: u, showToolbar: p = !0, showToc: m = !0, showSearch: h = !0, onEditorReady: g, immediatelyRender: _, onToast: y }) => {
6516
- let k = r === "view" || i, A = C(() => typeof e == "object" && e || _i(e) ? e : d(e), [e]), [j, M] = T(!1), [F, I] = T({}), [L, R] = T("below"), [re, ie] = T(50), z = w(null), [B, ae] = T(!1), [oe, se] = T(!1), [ce, V] = T(!1), [H, le] = T(!1), [U, W] = T("none"), [ue, de] = T({}), [G, fe] = T(""), [pe, me] = T(null), [K, he] = T(m), [ge, _e] = T(!1);
6703
+ }), ki = ({ initialContent: e = "", onChange: t, placeholder: n, mode: r, readonly: i = !1, maxLength: a, maxAttachmentSize: o, maxTotalAttachmentSize: s, className: c = "", borderless: l = !1, style: u, showToolbar: p = !0, showToc: m = !0, showSearch: h = !0, onEditorReady: g, immediatelyRender: _, onToast: y }) => {
6704
+ let k = r === "view" || i, A = C(() => typeof e == "object" && e || xi(e) ? e : d(e), [e]), [j, M] = T(!1), [F, I] = T({}), [L, R] = T("below"), [re, ie] = T(50), z = w(null), [B, V] = T(!1), [H, ae] = T(!1), [oe, U] = T(!1), [W, G] = T(!1), [K, q] = T("none"), [se, ce] = T({}), [J, le] = T(""), [ue, de] = T(null), [fe, pe] = T(m), [me, he] = T(!1);
6517
6705
  x(() => {
6518
- he(m);
6706
+ pe(m);
6519
6707
  }, [m]);
6520
- let [ve, ye] = T(!1), [be, xe] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 80rem)").matches : !0), [Se, Ce] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 64rem)").matches : !0), we = w(null), Te = w(null), Ee = w(null), De = w(0), Oe = w(null), ke = w(null), Ae = w(null), [je, Me] = T(!1), [q, Ne] = T(!1), [J, Pe] = T(!1), Fe = b(() => {
6521
- let e = Te.current, t = Ee.current;
6522
- e && (q ? (document.body.style.overflow = "", Object.assign(e.style, {
6708
+ let [ge, _e] = T(!1), [ve, ye] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 80rem)").matches : !0), [be, xe] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 64rem)").matches : !0), Se = w(null), Ce = w(null), we = w(null), Te = w(0), Ee = w(null), De = w(null), Oe = w(null), [ke, Ae] = T(!1), [Y, je] = T(!1), [Me, Ne] = T(!1), Pe = b(() => {
6709
+ let e = Ce.current, t = we.current;
6710
+ e && (Y ? (document.body.style.overflow = "", Object.assign(e.style, {
6523
6711
  position: "",
6524
6712
  top: "",
6525
6713
  left: "",
@@ -6535,9 +6723,9 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
6535
6723
  flex: "",
6536
6724
  overflow: "",
6537
6725
  minHeight: ""
6538
- }), Ne(!1), requestAnimationFrame(() => {
6539
- window.scrollTo(0, De.current);
6540
- })) : (document.fullscreenElement && document.exitFullscreen(), De.current = window.scrollY, Object.assign(e.style, {
6726
+ }), je(!1), requestAnimationFrame(() => {
6727
+ window.scrollTo(0, Te.current);
6728
+ })) : (document.fullscreenElement && document.exitFullscreen(), Te.current = window.scrollY, Object.assign(e.style, {
6541
6729
  position: "fixed",
6542
6730
  top: "0",
6543
6731
  left: "0",
@@ -6553,42 +6741,42 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
6553
6741
  flex: "1",
6554
6742
  overflow: "auto",
6555
6743
  minHeight: "0"
6556
- }), document.body.style.overflow = "hidden", Ne(!0)));
6557
- }, [q]), Ie = b(() => {
6558
- let e = Te.current;
6559
- e && (document.fullscreenElement ? document.exitFullscreen() : (q && Fe(), De.current = window.scrollY, e.requestFullscreen()));
6560
- }, [q, Fe]);
6744
+ }), document.body.style.overflow = "hidden", je(!0)));
6745
+ }, [Y]), Fe = b(() => {
6746
+ let e = Ce.current;
6747
+ e && (document.fullscreenElement ? document.exitFullscreen() : (Y && Pe(), Te.current = window.scrollY, e.requestFullscreen()));
6748
+ }, [Y, Pe]);
6561
6749
  x(() => {
6562
6750
  let e = (e) => {
6563
- e.key === "Escape" && q && Fe();
6751
+ e.key === "Escape" && Y && Pe();
6564
6752
  }, t = () => {
6565
- document.fullscreenElement ? Pe(!0) : (Pe(!1), requestAnimationFrame(() => {
6566
- window.scrollTo(0, De.current);
6753
+ document.fullscreenElement ? Ne(!0) : (Ne(!1), requestAnimationFrame(() => {
6754
+ window.scrollTo(0, Te.current);
6567
6755
  }));
6568
6756
  };
6569
6757
  return window.addEventListener("keydown", e), document.addEventListener("fullscreenchange", t), () => {
6570
6758
  window.removeEventListener("keydown", e), document.removeEventListener("fullscreenchange", t);
6571
6759
  };
6572
- }, [q, Fe]), x(() => {
6760
+ }, [Y, Pe]), x(() => {
6573
6761
  if (!h) return;
6574
6762
  let e = (e) => {
6575
6763
  if ((e.ctrlKey || e.metaKey) && (e.key === "f" || e.key === "F")) {
6576
- if (!Te.current) return;
6577
- e.preventDefault(), e.stopPropagation(), ye(!0);
6764
+ if (!Ce.current) return;
6765
+ e.preventDefault(), e.stopPropagation(), _e(!0);
6578
6766
  }
6579
6767
  };
6580
6768
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
6581
6769
  }, [h]), x(() => {
6582
6770
  if (typeof window > "u" || typeof window.matchMedia != "function") return;
6583
- let e = window.matchMedia("(min-width: 80rem)"), t = (e) => xe(e.matches);
6584
- return xe(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
6771
+ let e = window.matchMedia("(min-width: 80rem)"), t = (e) => ye(e.matches);
6772
+ return ye(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
6585
6773
  }, []), x(() => {
6586
6774
  if (typeof window > "u" || typeof window.matchMedia != "function") return;
6587
- let e = window.matchMedia("(min-width: 64rem)"), t = (e) => Ce(e.matches);
6588
- return Ce(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
6775
+ let e = window.matchMedia("(min-width: 64rem)"), t = (e) => xe(e.matches);
6776
+ return xe(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
6589
6777
  }, []);
6590
- let Y = ee({
6591
- extensions: ti({
6778
+ let X = ee({
6779
+ extensions: ai({
6592
6780
  placeholder: n || f("editor.placeholder"),
6593
6781
  maxLength: a,
6594
6782
  maxAttachmentSize: o,
@@ -6598,22 +6786,25 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
6598
6786
  editable: !k,
6599
6787
  immediatelyRender: _,
6600
6788
  onUpdate: ({ editor: e }) => {
6601
- t && (we.current && clearTimeout(we.current), we.current = setTimeout(() => {
6789
+ t && (Se.current && clearTimeout(Se.current), Se.current = setTimeout(() => {
6602
6790
  t?.(e.getHTML(), e.getJSON());
6603
6791
  }, 300));
6604
6792
  },
6605
6793
  onCreate: () => {},
6606
6794
  editorProps: {
6607
- attributes: { class: "prose prose-neutral dark:prose-invert max-w-none focus:outline-none min-h-[200px] px-4 sm:px-8 py-4" },
6795
+ attributes: {
6796
+ class: "prose prose-neutral dark:prose-invert max-w-none focus:outline-none min-h-[200px] px-4 sm:px-8 py-4",
6797
+ ...k ? {} : { style: "padding-left: 2.75rem" }
6798
+ },
6608
6799
  handlePaste(e, t) {
6609
6800
  let n = t.clipboardData;
6610
6801
  if (!n) return !1;
6611
6802
  let r = n.getData("text/plain");
6612
6803
  if (!r || !r.includes("[[")) return !1;
6613
6804
  t.preventDefault();
6614
- let i = ke.current?.storage?.relativeMedia;
6805
+ let i = De.current?.storage?.relativeMedia;
6615
6806
  i && (i.clipboardFiles = new Map(Array.from(n.files ?? []).map((e) => [e.name.toLowerCase(), e])), i.pausedUntilPaste = !1);
6616
- let a = ke.current ? vi(ke.current, r) : null;
6807
+ let a = De.current ? Si(De.current, r) : null;
6617
6808
  if (a) {
6618
6809
  let t = new N(a, 0, 0);
6619
6810
  e.dispatch(e.state.tr.replaceSelection(t).scrollIntoView());
@@ -6623,21 +6814,21 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
6623
6814
  }
6624
6815
  });
6625
6816
  x(() => {
6626
- ke.current = Y, window.__editor = Y;
6627
- }, [Y]), x(() => {
6628
- if (Y) return () => Jt(Y);
6629
- }, [Y]), x(() => {
6630
- !Y || !g || g(Y);
6631
- }, [Y, g]), x(() => {
6632
- if (!Y) return;
6817
+ De.current = X, window.__editor = X;
6818
+ }, [X]), x(() => {
6819
+ if (X) return () => Yt(X);
6820
+ }, [X]), x(() => {
6821
+ !X || !g || g(X);
6822
+ }, [X, g]), x(() => {
6823
+ if (!X) return;
6633
6824
  let e = () => {
6634
- Y.state.selection.empty && (W("none"), Me(!1));
6825
+ X.state.selection.empty && (q("none"), Ae(!1));
6635
6826
  };
6636
- return Y.on("selectionUpdate", e), () => {
6637
- Y.off("selectionUpdate", e);
6827
+ return X.on("selectionUpdate", e), () => {
6828
+ X.off("selectionUpdate", e);
6638
6829
  };
6639
- }, [Y]), x(() => {
6640
- Y && Y.setOptions({ extensions: ti({
6830
+ }, [X]), x(() => {
6831
+ X && X.setOptions({ extensions: ai({
6641
6832
  placeholder: n || f("editor.placeholder"),
6642
6833
  maxLength: a,
6643
6834
  maxAttachmentSize: o,
@@ -6649,80 +6840,80 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
6649
6840
  o,
6650
6841
  s
6651
6842
  ]);
6652
- let Le = w(e);
6843
+ let Ie = w(e);
6653
6844
  x(() => {
6654
- if (!Y || e === Le.current) return;
6655
- Le.current = e;
6656
- let t = typeof e == "object" && e || _i(e) ? e : d(e);
6657
- Y.commands.setContent(t, { emitUpdate: !1 });
6658
- }, [Y, e]), x(() => {
6659
- Y && Y.setEditable(!k, !1);
6660
- }, [Y, k]), x(() => {
6661
- if (y) return Ze(y);
6845
+ if (!X || e === Ie.current) return;
6846
+ Ie.current = e;
6847
+ let t = typeof e == "object" && e || xi(e) ? e : d(e);
6848
+ X.commands.setContent(t, { emitUpdate: !1 });
6849
+ }, [X, e]), x(() => {
6850
+ X && X.setEditable(!k, !1);
6851
+ }, [X, k]), x(() => {
6852
+ if (y) return Qe(y);
6662
6853
  }, [y]), x(() => {
6663
- if (!Y) return;
6664
- let e = on(Y.state.doc);
6665
- e > s && Z(`文档内附件总大小 ${sn(e)} 已超过限制 ${sn(s)}`, "info");
6666
- }, [Y, s]), x(() => {
6667
- if (!Y) return;
6668
- let e = Y.storage.qingwuUI;
6854
+ if (!X) return;
6855
+ let e = sn(X.state.doc);
6856
+ e > s && Z(`文档内附件总大小 ${cn(e)} 已超过限制 ${cn(s)}`, "info");
6857
+ }, [X, s]), x(() => {
6858
+ if (!X) return;
6859
+ let e = X.storage.qingwuUI;
6669
6860
  e && (e.limits = {
6670
6861
  maxAttachmentSize: o,
6671
6862
  maxTotalAttachmentSize: s
6672
6863
  });
6673
6864
  }, [
6674
- Y,
6865
+ X,
6675
6866
  o,
6676
6867
  s
6677
6868
  ]);
6678
- let Re = b((e) => {
6679
- let t = Ae.current?.getBoundingClientRect();
6680
- W(e), Me(!1), de({
6869
+ let Le = b((e) => {
6870
+ let t = Oe.current?.getBoundingClientRect();
6871
+ q(e), Ae(!1), ce({
6681
6872
  position: "fixed",
6682
6873
  top: t ? t.bottom + 8 : void 0,
6683
6874
  left: t ? Math.max(8, Math.min(t.left, window.innerWidth - 240)) : 8,
6684
6875
  zIndex: 9999
6685
6876
  });
6686
- }, []), ze = ai((e) => f(e)), X = ze.filter((e) => !e.more), Be = ze.filter((e) => e.more), Ve = X.filter((e) => e.key !== "ai"), He = X.find((e) => e.key === "ai"), Ue = b((e) => {
6687
- if (Y) if (Me(!1), e.key === "link") if (Y.isActive("link")) Y.chain().focus().unsetLink().run();
6877
+ }, []), Re = li((e) => f(e)), ze = Re.filter((e) => !e.more), Be = Re.filter((e) => e.more), Ve = ze.filter((e) => e.key !== "ai"), He = ze.find((e) => e.key === "ai"), Ue = b((e) => {
6878
+ if (X) if (Ae(!1), e.key === "link") if (X.isActive("link")) X.chain().focus().unsetLink().run();
6688
6879
  else {
6689
- let e = Y.getAttributes("link").href || "";
6690
- fe(e), Re("link");
6880
+ let e = X.getAttributes("link").href || "";
6881
+ le(e), Le("link");
6691
6882
  }
6692
- else e.key === "highlight" ? U === "highlight" ? W("none") : Re("highlight") : e.command(Y);
6883
+ else e.key === "highlight" ? K === "highlight" ? q("none") : Le("highlight") : e.command(X);
6693
6884
  }, [
6694
- Y,
6695
- U,
6696
- Re
6697
- ]), We = b((e) => Y ? e.key === "highlight" ? U === "highlight" : e.key === "link" ? Y.isActive("link") : e.isActive(Y) : !1, [Y, U]), [Ge, Ke] = T(0);
6885
+ X,
6886
+ K,
6887
+ Le
6888
+ ]), We = b((e) => X ? e.key === "highlight" ? K === "highlight" : e.key === "link" ? X.isActive("link") : e.isActive(X) : !1, [X, K]), [Ge, Ke] = T(0);
6698
6889
  x(() => {
6699
- if (!Y) return;
6890
+ if (!X) return;
6700
6891
  let e = () => Ke((e) => (e + 1) % 1e6);
6701
- return Y.on("update", e), () => {
6702
- Y.off("update", e);
6892
+ return X.on("update", e), () => {
6893
+ X.off("update", e);
6703
6894
  };
6704
- }, [Y]);
6895
+ }, [X]);
6705
6896
  let [qe, Je] = T(!1);
6706
6897
  x(() => {
6707
- if (!Y) return;
6898
+ if (!X) return;
6708
6899
  let e = () => {
6709
6900
  let e = !1;
6710
- Y.state.doc.descendants((t) => {
6901
+ X.state.doc.descendants((t) => {
6711
6902
  t.type.name === "heading" && (e = !0);
6712
6903
  }), Je(e);
6713
6904
  };
6714
- return e(), Y.on("update", e), () => {
6715
- Y.off("update", e);
6905
+ return e(), X.on("update", e), () => {
6906
+ X.off("update", e);
6716
6907
  };
6717
- }, [Y]);
6718
- let Ye = C(() => Y?.storage?.characterCount?.characters?.() ?? 0, [Y, Ge]), Xe = a ? Ye > a : !1;
6908
+ }, [X]);
6909
+ let Ye = C(() => X?.storage?.characterCount?.characters?.() ?? 0, [X, Ge]), Xe = a ? Ye > a : !1;
6719
6910
  x(() => () => {
6720
- we.current && clearTimeout(we.current);
6911
+ Se.current && clearTimeout(Se.current);
6721
6912
  }, []), x(() => () => {
6722
- pe && pe.resolve(null);
6913
+ ue && ue.resolve(null);
6723
6914
  }, []);
6724
- let Qe = b((e) => {
6725
- if (!Y?.isEditable) return;
6915
+ let Ze = b((e) => {
6916
+ if (!X?.isEditable) return;
6726
6917
  let t = window.getSelection(), n;
6727
6918
  if (e) {
6728
6919
  let t = e.getBoundingClientRect();
@@ -6739,66 +6930,66 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
6739
6930
  width: e.width
6740
6931
  };
6741
6932
  } else {
6742
- let e = Y.view.coordsAtPos(Y.state.selection.from);
6933
+ let e = X.view.coordsAtPos(X.state.selection.from);
6743
6934
  n = {
6744
6935
  top: e.bottom,
6745
6936
  left: e.left,
6746
6937
  width: 0
6747
6938
  };
6748
6939
  }
6749
- Oe.current = n;
6750
- let r = Te.current?.getBoundingClientRect(), i = gi(n, void 0, {
6940
+ Ee.current = n;
6941
+ let r = Ce.current?.getBoundingClientRect(), i = bi(n, void 0, {
6751
6942
  panelWidth: r?.width,
6752
6943
  editorLeft: r?.left
6753
6944
  });
6754
6945
  M(!0), I(i.style), R(i.placement), ie(i.arrowLeft);
6755
- }, [Y]);
6946
+ }, [X]);
6756
6947
  x(() => {
6757
- if (!Y) return;
6758
- let e = Y.storage.qingwuUI;
6759
- if (e) return e.openImageDialog = () => ae(!0), e.openVideoDialog = () => se(!0), e.chooseMd = (e, t) => {
6760
- me({
6948
+ if (!X) return;
6949
+ let e = X.storage.qingwuUI;
6950
+ if (e) return e.openImageDialog = () => V(!0), e.openVideoDialog = () => ae(!0), e.chooseMd = (e, t) => {
6951
+ de({
6761
6952
  filename: e,
6762
6953
  resolve: t
6763
6954
  });
6764
- }, e.openAI = Qe, e.parseMd = (e, t) => Y ? vi(Y, t) : null, () => {
6955
+ }, e.openAI = Ze, e.parseMd = (e, t) => X ? Si(X, t) : null, () => {
6765
6956
  delete e.openImageDialog, delete e.openVideoDialog, delete e.openAI, delete e.parseMd, delete e.chooseMd;
6766
6957
  };
6767
- }, [Y, Qe]), S(() => {
6768
- if (!j || !Y) return;
6769
- let e = Oe.current;
6958
+ }, [X, Ze]), S(() => {
6959
+ if (!j || !X) return;
6960
+ let e = Ee.current;
6770
6961
  if (!e) return;
6771
- let t = z.current, n = Te.current?.getBoundingClientRect(), r = gi(e, t?.offsetHeight || void 0, {
6962
+ let t = z.current, n = Ce.current?.getBoundingClientRect(), r = bi(e, t?.offsetHeight || void 0, {
6772
6963
  panelWidth: n?.width,
6773
6964
  editorLeft: n?.left
6774
6965
  });
6775
6966
  R(r.placement), ie(r.arrowLeft), I(r.style);
6776
- }, [j, Y]), x(() => {
6777
- if (!j || !Y) return;
6967
+ }, [j, X]), x(() => {
6968
+ if (!j || !X) return;
6778
6969
  let e = () => {
6779
- let e = Oe.current;
6970
+ let e = Ee.current;
6780
6971
  if (!e) return;
6781
- let t = z.current, n = Te.current?.getBoundingClientRect(), r = gi(e, t?.offsetHeight || void 0, {
6972
+ let t = z.current, n = Ce.current?.getBoundingClientRect(), r = bi(e, t?.offsetHeight || void 0, {
6782
6973
  panelWidth: n?.width,
6783
6974
  editorLeft: n?.left
6784
6975
  });
6785
6976
  R(r.placement), ie(r.arrowLeft), I(r.style);
6786
6977
  };
6787
6978
  return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
6788
- }, [j, Y]), x(() => {
6789
- j || (Oe.current = null);
6979
+ }, [j, X]), x(() => {
6980
+ j || (Ee.current = null);
6790
6981
  }, [j]);
6791
6982
  let $e = b((e) => {
6792
- Y?.chain().focus().setImage({ src: e }).run();
6793
- }, [Y]), et = b((e) => {
6794
- (Y?.commands).insertVideo?.({ src: e });
6795
- }, [Y]), tt = K && be && !q && !J, nt = !tt && !ge && (K || qe && !(!k && Se)), rt = w(!1);
6983
+ X?.chain().focus().setImage({ src: e }).run();
6984
+ }, [X]), et = b((e) => {
6985
+ (X?.commands).insertVideo?.({ src: e });
6986
+ }, [X]), tt = fe && ve && !Y && !Me, nt = !tt && !me && (fe || qe && !(!k && be)), rt = w(!1);
6796
6987
  return x(() => {
6797
- rt.current || (rt.current = !0, K && !tt && _e(!0));
6798
- }, [K, tt]), Y ? /* @__PURE__ */ O("div", {
6988
+ rt.current || (rt.current = !0, fe && !tt && he(!0));
6989
+ }, [fe, tt]), X ? /* @__PURE__ */ O("div", {
6799
6990
  className: "qingwu-editor-row",
6800
6991
  children: [/* @__PURE__ */ O("div", {
6801
- ref: Te,
6992
+ ref: Ce,
6802
6993
  className: `qingwu-editor relative flex-1 min-w-0 bg-background ${k ? "qingwu-editor--readonly" : ""} ${l ? "" : "rounded-xl border border-default-200"} ${c}`,
6803
6994
  style: u,
6804
6995
  children: [
@@ -6809,13 +7000,13 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
6809
7000
  children: [
6810
7001
  /* @__PURE__ */ D("button", {
6811
7002
  type: "button",
6812
- className: `qed-tb-btn qed-tb-btn--desktop-only${K ? " is-active" : ""}`,
7003
+ className: `qed-tb-btn qed-tb-btn--desktop-only${fe ? " is-active" : ""}`,
6813
7004
  onClick: () => {
6814
- K ? (he(!1), _e(!1)) : (he(!0), be && !q && !J || _e(!0));
7005
+ fe ? (pe(!1), he(!1)) : (pe(!0), ve && !Y && !Me || he(!0));
6815
7006
  },
6816
- title: K ? "隐藏目录" : "显示目录",
6817
- "aria-label": K ? "隐藏目录" : "显示目录",
6818
- "aria-pressed": K,
7007
+ title: fe ? "隐藏目录" : "显示目录",
7008
+ "aria-label": fe ? "隐藏目录" : "显示目录",
7009
+ "aria-pressed": fe,
6819
7010
  children: /* @__PURE__ */ D("svg", {
6820
7011
  fill: "none",
6821
7012
  viewBox: "0 0 24 24",
@@ -6831,11 +7022,11 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
6831
7022
  }),
6832
7023
  h && /* @__PURE__ */ D("button", {
6833
7024
  type: "button",
6834
- className: `qed-tb-btn${ve ? " is-active" : ""}`,
6835
- onClick: () => ye(!ve),
7025
+ className: `qed-tb-btn${ge ? " is-active" : ""}`,
7026
+ onClick: () => _e(!ge),
6836
7027
  title: "查找 (Ctrl+F)",
6837
7028
  "aria-label": "查找",
6838
- "aria-pressed": ve,
7029
+ "aria-pressed": ge,
6839
7030
  children: /* @__PURE__ */ D("svg", {
6840
7031
  fill: "none",
6841
7032
  viewBox: "0 0 24 24",
@@ -6852,7 +7043,7 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
6852
7043
  !k && /* @__PURE__ */ D("button", {
6853
7044
  type: "button",
6854
7045
  className: `qed-tb-btn qed-tb-btn--ai${j ? " is-active" : ""}`,
6855
- onClick: (e) => j ? M(!1) : Qe(e.currentTarget),
7046
+ onClick: (e) => j ? M(!1) : Ze(e.currentTarget),
6856
7047
  title: f("editor.toolbar.aiTitle"),
6857
7048
  "aria-label": f("editor.toolbar.ai"),
6858
7049
  "aria-pressed": j,
@@ -6880,7 +7071,7 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
6880
7071
  /* @__PURE__ */ O("button", {
6881
7072
  type: "button",
6882
7073
  className: "qed-tb-btn qed-tb-btn--solid",
6883
- onClick: () => le(!0),
7074
+ onClick: () => G(!0),
6884
7075
  title: f("editor.toolbar.exportTitle"),
6885
7076
  children: [/* @__PURE__ */ D("svg", {
6886
7077
  fill: "none",
@@ -6900,11 +7091,11 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
6900
7091
  }),
6901
7092
  /* @__PURE__ */ D("button", {
6902
7093
  type: "button",
6903
- className: `qed-tb-btn${q ? " is-active" : ""}`,
6904
- onClick: Fe,
6905
- title: q ? "退出网页全屏" : "网页全屏",
6906
- "aria-label": q ? "退出网页全屏" : "网页全屏",
6907
- "aria-pressed": q,
7094
+ className: `qed-tb-btn${Y ? " is-active" : ""}`,
7095
+ onClick: Pe,
7096
+ title: Y ? "退出网页全屏" : "网页全屏",
7097
+ "aria-label": Y ? "退出网页全屏" : "网页全屏",
7098
+ "aria-pressed": Y,
6908
7099
  children: /* @__PURE__ */ D("svg", {
6909
7100
  fill: "none",
6910
7101
  viewBox: "0 0 24 24",
@@ -6920,11 +7111,11 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
6920
7111
  }),
6921
7112
  /* @__PURE__ */ D("button", {
6922
7113
  type: "button",
6923
- className: `qed-tb-btn${J ? " is-active" : ""}`,
6924
- onClick: Ie,
6925
- title: J ? "退出全屏" : "全屏",
6926
- "aria-label": J ? "退出全屏" : "全屏",
6927
- "aria-pressed": J,
7114
+ className: `qed-tb-btn${Me ? " is-active" : ""}`,
7115
+ onClick: Fe,
7116
+ title: Me ? "退出全屏" : "全屏",
7117
+ "aria-label": Me ? "退出全屏" : "全屏",
7118
+ "aria-pressed": Me,
6928
7119
  children: /* @__PURE__ */ D("svg", {
6929
7120
  fill: "none",
6930
7121
  viewBox: "0 0 24 24",
@@ -6941,8 +7132,8 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
6941
7132
  ]
6942
7133
  })]
6943
7134
  }),
6944
- Y && !k && Y.isEditable && /* @__PURE__ */ D(te, {
6945
- editor: Y,
7135
+ X && !k && X.isEditable && /* @__PURE__ */ D(te, {
7136
+ editor: X,
6946
7137
  shouldShow: ({ editor: e, state: t }) => !(e.isActive("image") || e.isActive("videoEmbed") || e.isActive("codeBlock") || e.isActive("audioEmbed") || e.isActive("attachmentEmbed") || t.selection.empty),
6947
7138
  options: {
6948
7139
  placement: "bottom",
@@ -6951,7 +7142,7 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
6951
7142
  },
6952
7143
  className: "bubble-menu-pop bg-background border border-default-200 rounded-xl p-1 shadow-lg",
6953
7144
  children: /* @__PURE__ */ O("div", {
6954
- ref: Ae,
7145
+ ref: Oe,
6955
7146
  className: "bubble-menu-items relative flex items-center gap-0.5",
6956
7147
  onPointerDown: (e) => {
6957
7148
  e.target.closest("button") && e.preventDefault();
@@ -6959,7 +7150,7 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
6959
7150
  children: [
6960
7151
  Ve.map((e) => /* @__PURE__ */ D("button", {
6961
7152
  type: "button",
6962
- className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${e.isActive(Y) ? "bg-primary/10 text-primary" : "text-default-600 hover:bg-default-100"}`,
7153
+ className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${e.isActive(X) ? "bg-primary/10 text-primary" : "text-default-600 hover:bg-default-100"}`,
6963
7154
  onClick: (t) => {
6964
7155
  t.preventDefault(), Ue(e);
6965
7156
  },
@@ -6975,11 +7166,11 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
6975
7166
  type: "button",
6976
7167
  className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${j ? "bg-primary/15 text-primary" : "text-primary hover:bg-primary/10"}`,
6977
7168
  onClick: (e) => {
6978
- e.preventDefault(), Me(!1), He?.command(Y);
7169
+ e.preventDefault(), Ae(!1), He?.command(X);
6979
7170
  },
6980
7171
  title: He?.label,
6981
7172
  "aria-label": He?.label,
6982
- children: /* @__PURE__ */ D(Rt, {})
7173
+ children: /* @__PURE__ */ D(zt, {})
6983
7174
  }),
6984
7175
  /* @__PURE__ */ D("span", {
6985
7176
  className: "w-px h-4 bg-default-200 mx-0.5 shrink-0",
@@ -6987,16 +7178,16 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
6987
7178
  }),
6988
7179
  /* @__PURE__ */ D("button", {
6989
7180
  type: "button",
6990
- "aria-expanded": je,
6991
- className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${je ? "bg-default-100 text-default-900" : "text-default-600 hover:bg-default-100"}`,
7181
+ "aria-expanded": ke,
7182
+ className: `flex items-center justify-center w-7 h-7 rounded-lg transition-colors ${ke ? "bg-default-100 text-default-900" : "text-default-600 hover:bg-default-100"}`,
6992
7183
  onClick: (e) => {
6993
- e.preventDefault(), Me((e) => !e);
7184
+ e.preventDefault(), Ae((e) => !e);
6994
7185
  },
6995
7186
  title: f("editor.bubble.more"),
6996
7187
  "aria-label": f("editor.bubble.more"),
6997
- children: /* @__PURE__ */ D(zt, {})
7188
+ children: /* @__PURE__ */ D(Bt, {})
6998
7189
  }),
6999
- je && /* @__PURE__ */ D("div", {
7190
+ ke && /* @__PURE__ */ D("div", {
7000
7191
  role: "menu",
7001
7192
  className: "bubble-more-menu absolute right-0 top-full z-[9999] mt-1 w-max max-h-[70vh] overflow-y-auto flex-col gap-1 rounded-xl border border-default-200 bg-background p-1.5 shadow-xl",
7002
7193
  onPointerDown: (e) => {
@@ -7022,29 +7213,29 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
7022
7213
  ]
7023
7214
  })
7024
7215
  }),
7025
- Y && U !== "none" && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
7216
+ X && K !== "none" && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D("div", {
7026
7217
  className: "fixed inset-0 z-[9998]",
7027
- onClick: () => W("none")
7218
+ onClick: () => q("none")
7028
7219
  }), /* @__PURE__ */ D("div", {
7029
- style: ue,
7220
+ style: se,
7030
7221
  className: "bg-background border border-default-200 rounded-xl shadow-xl",
7031
7222
  onClick: (e) => e.stopPropagation(),
7032
- children: U === "highlight" ? /* @__PURE__ */ O("div", {
7223
+ children: K === "highlight" ? /* @__PURE__ */ O("div", {
7033
7224
  className: "flex items-center gap-1 p-1.5 flex-wrap",
7034
- children: [fi.map((e) => /* @__PURE__ */ D("button", {
7225
+ children: [gi.map((e) => /* @__PURE__ */ D("button", {
7035
7226
  type: "button",
7036
7227
  className: "w-5 h-5 rounded-full border border-default-200 hover:scale-110 transition-transform",
7037
7228
  style: { background: e.color },
7038
7229
  title: e.name,
7039
7230
  onClick: () => {
7040
- Y.chain().focus().setHighlight({ color: e.color }).run(), W("none");
7231
+ X.chain().focus().setHighlight({ color: e.color }).run(), q("none");
7041
7232
  }
7042
7233
  }, e.color)), /* @__PURE__ */ O("button", {
7043
7234
  type: "button",
7044
7235
  className: "w-5 h-5 rounded-full border border-default-200 text-default-500 hover:bg-default-100 flex items-center justify-center text-[10px]",
7045
7236
  title: "清除高亮",
7046
7237
  onClick: () => {
7047
- Y.chain().focus().unsetHighlight().run(), W("none");
7238
+ X.chain().focus().unsetHighlight().run(), q("none");
7048
7239
  },
7049
7240
  children: ["✕", " "]
7050
7241
  })]
@@ -7054,16 +7245,16 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
7054
7245
  type: "url",
7055
7246
  className: "flex-1 px-2 py-1 text-xs rounded-md border border-default-200 bg-background focus:outline-none focus:border-primary",
7056
7247
  placeholder: "https://...",
7057
- value: G,
7058
- onChange: (e) => fe(e.target.value),
7248
+ value: J,
7249
+ onChange: (e) => le(e.target.value),
7059
7250
  onKeyDown: (e) => {
7060
- e.key === "Enter" ? (G.trim() && Y.chain().focus().setLink({ href: G.trim() }).run(), W("none")) : e.key === "Escape" && W("none");
7251
+ e.key === "Enter" ? (J.trim() && X.chain().focus().setLink({ href: J.trim() }).run(), q("none")) : e.key === "Escape" && q("none");
7061
7252
  }
7062
7253
  }), /* @__PURE__ */ D("button", {
7063
7254
  type: "button",
7064
7255
  className: "px-2 py-1 text-xs rounded-md bg-primary text-white hover:opacity-90",
7065
7256
  onClick: () => {
7066
- G.trim() && Y.chain().focus().setLink({ href: G.trim() }).run(), W("none");
7257
+ J.trim() && X.chain().focus().setLink({ href: J.trim() }).run(), q("none");
7067
7258
  },
7068
7259
  children: "确定"
7069
7260
  })]
@@ -7082,72 +7273,72 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
7082
7273
  className: "ai-panel__arrow",
7083
7274
  style: { left: `${re}%` },
7084
7275
  "aria-hidden": "true"
7085
- }), /* @__PURE__ */ D(rn, {
7086
- editor: Y,
7276
+ }), /* @__PURE__ */ D(an, {
7277
+ editor: X,
7087
7278
  onClose: () => M(!1)
7088
7279
  })]
7089
7280
  })] }), document.body),
7090
7281
  B && /* @__PURE__ */ D(v, {
7091
- fallback: /* @__PURE__ */ D(wi, {}),
7092
- children: /* @__PURE__ */ D(yi, {
7282
+ fallback: /* @__PURE__ */ D(Oi, {}),
7283
+ children: /* @__PURE__ */ D(Ci, {
7093
7284
  open: B,
7094
- onClose: () => ae(!1),
7285
+ onClose: () => V(!1),
7095
7286
  onInsert: $e,
7096
- validate: (e) => Y ? ln(Y.state.doc, e, {
7287
+ validate: (e) => X ? un(X.state.doc, e, {
7097
7288
  maxAttachmentSize: o,
7098
7289
  maxTotalAttachmentSize: s
7099
7290
  }) : null
7100
7291
  })
7101
7292
  }),
7102
- oe && /* @__PURE__ */ D(v, {
7103
- fallback: /* @__PURE__ */ D(wi, {}),
7104
- children: /* @__PURE__ */ D(Si, {
7105
- open: oe,
7106
- onClose: () => se(!1),
7293
+ H && /* @__PURE__ */ D(v, {
7294
+ fallback: /* @__PURE__ */ D(Oi, {}),
7295
+ children: /* @__PURE__ */ D(Ei, {
7296
+ open: H,
7297
+ onClose: () => ae(!1),
7107
7298
  onInsert: et
7108
7299
  })
7109
7300
  }),
7110
- ce && /* @__PURE__ */ D(v, {
7111
- fallback: /* @__PURE__ */ D(wi, {}),
7112
- children: /* @__PURE__ */ D(bi, {
7113
- open: ce,
7114
- onClose: () => V(!1)
7301
+ oe && /* @__PURE__ */ D(v, {
7302
+ fallback: /* @__PURE__ */ D(Oi, {}),
7303
+ children: /* @__PURE__ */ D(wi, {
7304
+ open: oe,
7305
+ onClose: () => U(!1)
7115
7306
  })
7116
7307
  }),
7117
- H && /* @__PURE__ */ D(v, {
7118
- fallback: /* @__PURE__ */ D(wi, {}),
7119
- children: /* @__PURE__ */ D(xi, {
7120
- open: H,
7121
- onClose: () => le(!1),
7122
- editor: Y
7308
+ W && /* @__PURE__ */ D(v, {
7309
+ fallback: /* @__PURE__ */ D(Oi, {}),
7310
+ children: /* @__PURE__ */ D(Ti, {
7311
+ open: W,
7312
+ onClose: () => G(!1),
7313
+ editor: X
7123
7314
  })
7124
7315
  }),
7125
- pe && /* @__PURE__ */ D(v, {
7126
- fallback: /* @__PURE__ */ D(wi, {}),
7127
- children: /* @__PURE__ */ D(Ci, {
7128
- open: !!pe,
7129
- filename: pe.filename,
7316
+ ue && /* @__PURE__ */ D(v, {
7317
+ fallback: /* @__PURE__ */ D(Oi, {}),
7318
+ children: /* @__PURE__ */ D(Di, {
7319
+ open: !!ue,
7320
+ filename: ue.filename,
7130
7321
  onRender: () => {
7131
- pe.resolve("render"), me(null);
7322
+ ue.resolve("render"), de(null);
7132
7323
  },
7133
7324
  onAttach: () => {
7134
- pe.resolve("attach"), me(null);
7325
+ ue.resolve("attach"), de(null);
7135
7326
  },
7136
7327
  onClose: () => {
7137
- pe.resolve(null), me(null);
7328
+ ue.resolve(null), de(null);
7138
7329
  }
7139
7330
  })
7140
7331
  }),
7141
7332
  /* @__PURE__ */ D("div", {
7142
- ref: Ee,
7333
+ ref: we,
7143
7334
  className: "flex editor-body",
7144
7335
  children: /* @__PURE__ */ O("div", {
7145
7336
  className: "relative min-w-0 flex-1",
7146
7337
  children: [
7147
- /* @__PURE__ */ D(P, { editor: Y }),
7148
- !k && /* @__PURE__ */ D(di, { editor: Y }),
7338
+ /* @__PURE__ */ D(P, { editor: X }),
7339
+ !k && /* @__PURE__ */ D(hi, { editor: X }),
7149
7340
  /* @__PURE__ */ D("div", {
7150
- className: `${q || J ? "fixed" : "absolute"} bottom-2 right-4 z-10 pointer-events-none select-none`,
7341
+ className: `${Y || Me ? "fixed" : "absolute"} bottom-2 right-4 z-10 pointer-events-none select-none`,
7151
7342
  children: /* @__PURE__ */ O("span", {
7152
7343
  className: `text-xs ${Xe ? "bg-danger/10 text-danger font-medium px-2 py-0.5 rounded" : a && Ye > a * .9 ? "bg-warning/10 text-warning px-2 py-0.5 rounded" : "text-default-300"}`,
7153
7344
  children: [
@@ -7160,14 +7351,14 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
7160
7351
  ]
7161
7352
  })
7162
7353
  }),
7163
- h && ve && /* @__PURE__ */ D(Dt, {
7164
- editor: Y,
7165
- onClose: () => ye(!1)
7354
+ h && ge && /* @__PURE__ */ D(Ot, {
7355
+ editor: X,
7356
+ onClose: () => _e(!1)
7166
7357
  }),
7167
7358
  nt && /* @__PURE__ */ D("button", {
7168
7359
  type: "button",
7169
7360
  className: "qingwu-toc-fab",
7170
- onClick: () => _e(!0),
7361
+ onClick: () => he(!0),
7171
7362
  title: "目录",
7172
7363
  "aria-label": "打开目录",
7173
7364
  children: /* @__PURE__ */ D("svg", {
@@ -7183,7 +7374,7 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
7183
7374
  })
7184
7375
  })
7185
7376
  }),
7186
- ge && /* @__PURE__ */ O("div", {
7377
+ me && /* @__PURE__ */ O("div", {
7187
7378
  className: "qingwu-toc-drawer toc-scroll",
7188
7379
  children: [/* @__PURE__ */ O("div", {
7189
7380
  className: "qed-drawer-head",
@@ -7193,7 +7384,7 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
7193
7384
  }), /* @__PURE__ */ D("button", {
7194
7385
  type: "button",
7195
7386
  className: "qed-drawer-head__close",
7196
- onClick: () => _e(!1),
7387
+ onClick: () => he(!1),
7197
7388
  "aria-label": "关闭目录",
7198
7389
  children: /* @__PURE__ */ D("svg", {
7199
7390
  fill: "none",
@@ -7208,20 +7399,20 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
7208
7399
  })
7209
7400
  })
7210
7401
  })]
7211
- }), /* @__PURE__ */ D(lt, {
7212
- editor: Y,
7402
+ }), /* @__PURE__ */ D(ut, {
7403
+ editor: X,
7213
7404
  className: "!p-3",
7214
7405
  onClose: () => {
7215
- _e(!1), he(!1);
7406
+ he(!1), pe(!1);
7216
7407
  }
7217
7408
  })]
7218
7409
  })
7219
7410
  ]
7220
7411
  }), tt && /* @__PURE__ */ D("aside", {
7221
7412
  className: "qingwu-toc-desktop toc-scroll",
7222
- children: /* @__PURE__ */ D(lt, {
7223
- editor: Y,
7224
- onClose: () => he(!1)
7413
+ children: /* @__PURE__ */ D(ut, {
7414
+ editor: X,
7415
+ onClose: () => pe(!1)
7225
7416
  })
7226
7417
  })]
7227
7418
  }) : /* @__PURE__ */ D("div", {
@@ -7231,7 +7422,7 @@ var yi = y(() => Promise.resolve().then(() => Qe).then((e) => ({ default: e.Imag
7231
7422
  };
7232
7423
  //#endregion
7233
7424
  //#region src/editor/clipper/receiver-browser.ts
7234
- function Ei(e) {
7425
+ function Ai(e) {
7235
7426
  let t = async (t) => {
7236
7427
  let n = t.data;
7237
7428
  if (!n || typeof n != "object" || n.kind !== "qingwu-clip") return;
@@ -7248,7 +7439,7 @@ function Ei(e) {
7248
7439
  }
7249
7440
  //#endregion
7250
7441
  //#region src/editor/storage/providers/cos.ts
7251
- function Di(e) {
7442
+ function ji(e) {
7252
7443
  return g({
7253
7444
  endpoint: `https://cos.${e.region}.myqcloud.com`,
7254
7445
  bucket: e.bucket,
@@ -7262,7 +7453,7 @@ function Di(e) {
7262
7453
  }
7263
7454
  //#endregion
7264
7455
  //#region src/editor/storage/providers/oss.ts
7265
- function Oi(e) {
7456
+ function Mi(e) {
7266
7457
  return g({
7267
7458
  endpoint: `https://${e.bucket}.${e.region}.aliyuncs.com`,
7268
7459
  bucket: e.bucket,
@@ -7275,4 +7466,4 @@ function Oi(e) {
7275
7466
  });
7276
7467
  }
7277
7468
  //#endregion
7278
- export { $n as CODE_LANGUAGES, tr as CodeBlock, Tr as ImageUpload, $e as ImageUploadDialog, Ti as QingWuAIEditor, Xr as RelativeMedia, Tt as SearchHighlight, lt as TocPanel, Gn as VideoEmbed, ut as buildSystemPrompt, ft as createAILanguageModelProvider, Di as createCOSStorage, gt as createDeepSeekProvider, _ as createLocalStorage, Oi as createOSSStorage, ht as createOpenAICompatProvider, _t as createOpenAIProvider, vt as createQwenProvider, g as createS3Storage, Qr as createSlashCommandExtension, h as escapeHtml, sn as formatBytes, mt as getAIProvider, ai as getBubbleMenuActions, $r as getDefaultSlashCommands, on as getDocAttachmentTotal, ti as getEditorExtensions, u as getLocale, ii as getSearchEngine, Et as getSearchState, c as getStorageInfo, o as getStorageProvider, s as loadStorageConfig, r as registerS3PreviewConfig, d as sanitizeHtml, p as sanitizeSvg, pt as setAIProvider, hn as setConfirmProvider, l as setLocale, ri as setSearchEngine, i as setStorageProvider, Xe as setToastProvider, n as signPreviewUrlHeaders, Ei as startBrowserClipperReceiver, Ze as subscribeToast, f as t, m as tf, Z as toast, ln as validateAttachmentFile };
7469
+ export { $n as CODE_LANGUAGES, ar as CodeBlock, kr as ImageUpload, et as ImageUploadDialog, ki as QingWuAIEditor, ei as RelativeMedia, Et as SearchHighlight, ut as TocPanel, Kn as VideoEmbed, dt as buildSystemPrompt, pt as createAILanguageModelProvider, ji as createCOSStorage, _t as createDeepSeekProvider, _ as createLocalStorage, Mi as createOSSStorage, gt as createOpenAICompatProvider, vt as createOpenAIProvider, yt as createQwenProvider, g as createS3Storage, ni as createSlashCommandExtension, h as escapeHtml, cn as formatBytes, ht as getAIProvider, li as getBubbleMenuActions, ri as getDefaultSlashCommands, sn as getDocAttachmentTotal, ai as getEditorExtensions, u as getLocale, ci as getSearchEngine, Dt as getSearchState, c as getStorageInfo, o as getStorageProvider, s as loadStorageConfig, r as registerS3PreviewConfig, d as sanitizeHtml, p as sanitizeSvg, mt as setAIProvider, gn as setConfirmProvider, l as setLocale, si as setSearchEngine, i as setStorageProvider, Ze as setToastProvider, n as signPreviewUrlHeaders, Ai as startBrowserClipperReceiver, Qe as subscribeToast, f as t, m as tf, Z as toast, un as validateAttachmentFile };