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

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
@@ -20,45 +20,45 @@ import { CharacterCount as K } from "@tiptap/extension-character-count";
20
20
  import { Color as q } from "@tiptap/extension-color";
21
21
  import { Highlight as se } from "@tiptap/extension-highlight";
22
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";
23
+ import { Placeholder as le } from "@tiptap/extension-placeholder";
24
+ import { Table as ue } from "@tiptap/extension-table";
25
+ import { TableCell as de } from "@tiptap/extension-table-cell";
26
+ import { TableHeader as fe } from "@tiptap/extension-table-header";
27
+ import { TableRow as pe } from "@tiptap/extension-table-row";
28
+ import { TaskItem as me } from "@tiptap/extension-task-item";
29
+ import { TaskList as he } from "@tiptap/extension-task-list";
30
+ import { TextStyle as ge } from "@tiptap/extension-text-style";
31
+ import { Markdown as _e } from "tiptap-markdown";
32
+ import { CodeBlockLowlight as ve } from "@tiptap/extension-code-block-lowlight";
33
+ import ye from "highlight.js/lib/languages/dockerfile";
34
+ import { common as be, createLowlight as xe } from "lowlight";
35
+ import Se, { exitSuggestion as Ce, findSuggestionMatch as we } from "@tiptap/suggestion";
36
36
  //#region ../text-layout/dist/index.mjs
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));
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));
45
45
  let r = n.get(e);
46
46
  if (r !== void 0) return 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;
47
+ let i = De();
48
+ return i ? (i.font = t, r = i.measureText(e).width) : r = Ae(e, t), n.set(e, r), r;
49
49
  }
50
- function ke(e, t) {
50
+ function Ae(e, t) {
51
51
  let n = parseFloat(t) || 16, r = 0;
52
- for (let t of e) Ae(t.codePointAt(0) ?? 0) ? r += n : t === " " ? r += n * .3 : r += n * .55;
52
+ for (let t of e) je(t.codePointAt(0) ?? 0) ? r += n : t === " " ? r += n * .3 : r += n * .55;
53
53
  return r;
54
54
  }
55
- function Ae(e) {
55
+ function je(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 Y(e) {
58
+ function Me(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 je(e, t) {
61
+ function J(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 je(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" : Ae(r) && (i = Y(r) ? "punct" : "cjk"), n.push({
72
+ e === "\n" ? i = "break" : e === " " || e === " " ? i = "space" : je(r) && (i = Me(r) ? "punct" : "cjk"), n.push({
73
73
  text: e,
74
- width: Oe(e, t),
74
+ width: ke(e, t),
75
75
  type: i
76
76
  });
77
77
  }
78
78
  return n;
79
79
  }
80
- function Me(e, t, n) {
80
+ function Ne(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 Ne(e, t, n, r) {
85
+ function Y(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 = je(e, n), c = [], l = {
92
+ let { maxWidth: r, lineHeight: i, maxLines: a, overflowWrap: o = "break-word" } = t, s = J(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(Ne(s, l.lineStart, e, l.lineWidth)), l.lineStart = e + 1, l.lineWidth = 0, l.lastBreakIdx = -1;
101
+ c.push(Y(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(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;
106
+ if (n > r && l.lineWidth > 0 ? (l.lastBreakIdx >= 0 ? (c.push(Y(s, l.lineStart, l.lastBreakIdx + 1, l.lastBreakWidth)), l.lineStart = l.lastBreakIdx + 1, l.lineWidth = Ne(s, l.lineStart, e + 1)) : (c.push(Y(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(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;
110
+ if (n > r && l.lineWidth > 0 ? (c.push(Y(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(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;
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(Y(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;
115
115
  continue;
116
116
  }
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;
117
+ if (n > r && l.lineWidth > 0 ? l.lastBreakIdx >= 0 ? (c.push(Y(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(Y(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 = Me(s, l.lineStart, s.length);
122
- c.push(Ne(s, l.lineStart, s.length, e));
121
+ let e = Ne(s, l.lineStart, s.length);
122
+ c.push(Y(s, l.lineStart, s.length, e));
123
123
  }
124
124
  return {
125
125
  lines: c,
@@ -130,13 +130,13 @@ 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, X = "13.5px -apple-system, BlinkMacSystemFont, \"SF Pro Text\", \"PingFang SC\", \"Microsoft YaHei\", system-ui, sans-serif";
134
- function Ie() {
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 Le() {
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;
138
138
  }
139
- var Le = {
139
+ var X = {
140
140
  info: "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"12\" y1=\"16\" x2=\"12\" y2=\"12\"/><line x1=\"12\" y1=\"8\" x2=\"12.01\" y2=\"8\"/></svg>",
141
141
  success: "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"M9 12l2 2 4-4\"/></svg>",
142
142
  warning: "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z\"/><line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\"/><line x1=\"12\" y1=\"17\" x2=\"12.01\" y2=\"17\"/></svg>",
@@ -278,12 +278,12 @@ var Ge = class {
278
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
280
  let c = Be("span", "qt-icon");
281
- c.innerHTML = Le[n], s.appendChild(c);
281
+ c.innerHTML = X[n], s.appendChild(c);
282
282
  let l = Be("div", "qt-body"), u = Be("span", "qt-msg"), d = Pe(t, {
283
- maxWidth: Ie(),
283
+ maxWidth: Le(),
284
284
  lineHeight: 1,
285
285
  maxLines: i
286
- }, X);
286
+ }, Ie);
287
287
  if (d.lineCount <= 1 ? Ve(u, t) : d.lines.forEach((e, t) => {
288
288
  let n = Be("span", "qt-line"), r = e.text;
289
289
  t === d.lines.length - 1 && d.truncated && !r.endsWith("…") && (r += "…"), Ve(n, r), u.appendChild(n);
@@ -720,7 +720,7 @@ function ot(e) {
720
720
  let t = e.parentElement;
721
721
  for (; t && t !== document.documentElement;) {
722
722
  let e = getComputedStyle(t).overflowY;
723
- if (e === "auto" || e === "scroll" || e === "overlay") return t;
723
+ if ((e === "auto" || e === "scroll" || e === "overlay") && t.scrollHeight > t.clientHeight) return t;
724
724
  t = t.parentElement;
725
725
  }
726
726
  return null;
@@ -809,13 +809,22 @@ var ct = 84, lt = 3e3, ut = ({ editor: e, className: t = "", onClose: n }) => {
809
809
  break;
810
810
  }
811
811
  }
812
- n && (_(), h.current = {
812
+ if (!n) return;
813
+ _(), h.current = {
813
814
  id: t.id,
814
815
  timer: setTimeout(_, lt)
815
- }, o(t.id), n.scrollIntoView({
816
- behavior: "smooth",
817
- block: "start"
818
- }));
816
+ }, o(t.id);
817
+ let r = m.current, i = n.getBoundingClientRect().top;
818
+ if (r) {
819
+ let e = r.getBoundingClientRect().top;
820
+ r.scrollTo({
821
+ top: r.scrollTop + i - e - ct,
822
+ behavior: "smooth"
823
+ });
824
+ } else window.scrollTo({
825
+ top: window.scrollY + i - ct,
826
+ behavior: "smooth"
827
+ });
819
828
  }, [e, _]), A = C(() => nt(r), [r]), j = C(() => rt(A), [A]), M = C(() => {
820
829
  let e = /* @__PURE__ */ new Map(), t = (n, r) => {
821
830
  for (let i of n) r && e.set(i.id, r), t(i.children, i.id);
@@ -2909,28 +2918,28 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
2909
2918
  x(() => {
2910
2919
  l(U ? Cn.has(U) : !1);
2911
2920
  }, [U]);
2912
- let J = b(() => {
2921
+ let le = b(() => {
2913
2922
  I.current = !0, ce(!0), window.setTimeout(() => {
2914
2923
  window.scrollTo(0, P.current), L.current && (L.current.scrollTop = ee.current), I.current && ce(!0), I.current = !1;
2915
2924
  }, 0);
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 () => {
2925
+ }, [ce]), ue = b(async () => {
2926
+ z === "web" ? (B("none"), document.body.style.overflow = "", le()) : (z === "native" && document.fullscreenElement && await document.exitFullscreen(), P.current = window.scrollY, ee.current = L.current?.scrollTop ?? 0, document.body.style.overflow = "hidden", B("web"));
2927
+ }, [z]), de = b(async () => {
2919
2928
  let e = M.current;
2920
2929
  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, J]), de = b(() => {
2930
+ }, [z, le]), fe = b(() => {
2922
2931
  z === "none" && (I.current || ce((e) => !e));
2923
2932
  }, [z]);
2924
2933
  x(() => {
2925
2934
  let e = () => {
2926
- document.fullscreenElement || (z === "native" && B("none"), J());
2935
+ document.fullscreenElement || (z === "native" && B("none"), le());
2927
2936
  }, t = (e) => {
2928
- e.key === "Escape" && z === "web" && (B("none"), document.body.style.overflow = "", J());
2937
+ e.key === "Escape" && z === "web" && (B("none"), document.body.style.overflow = "", le());
2929
2938
  };
2930
2939
  return document.addEventListener("fullscreenchange", e), window.addEventListener("keydown", t), () => {
2931
2940
  document.removeEventListener("fullscreenchange", e), window.removeEventListener("keydown", t);
2932
2941
  };
2933
- }, [z, J]), x(() => {
2942
+ }, [z, le]), x(() => {
2934
2943
  let e = (e) => {
2935
2944
  if (!(e.key !== "Backspace" && e.key !== "Delete") && o && i && !mn()) {
2936
2945
  if (e.preventDefault(), e.stopPropagation(), a) {
@@ -3009,7 +3018,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
3009
3018
  let e = window.setTimeout(() => A(null), 2400);
3010
3019
  return () => window.clearTimeout(e);
3011
3020
  }, [k]);
3012
- let fe = b(async () => {
3021
+ let pe = b(async () => {
3013
3022
  E(!0), A("loading");
3014
3023
  try {
3015
3024
  if (p) {
@@ -3140,7 +3149,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
3140
3149
  type: "button",
3141
3150
  className: "att-btn",
3142
3151
  onMouseDown: (e) => {
3143
- e.preventDefault(), e.stopPropagation(), de();
3152
+ e.preventDefault(), e.stopPropagation(), fe();
3144
3153
  },
3145
3154
  title: f("editor.attachment.preview"),
3146
3155
  "aria-label": f("editor.attachment.preview"),
@@ -3166,7 +3175,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
3166
3175
  /* @__PURE__ */ D("button", {
3167
3176
  type: "button",
3168
3177
  className: "att-btn",
3169
- onClick: fe,
3178
+ onClick: pe,
3170
3179
  disabled: S || q,
3171
3180
  title: S ? "正在准备下载" : f("editor.attachment.download"),
3172
3181
  "aria-label": S ? "正在准备下载" : f("editor.attachment.download"),
@@ -3280,7 +3289,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
3280
3289
  },
3281
3290
  children: [/* @__PURE__ */ D("button", {
3282
3291
  type: "button",
3283
- onClick: le,
3292
+ onClick: ue,
3284
3293
  title: z === "web" ? "退出网页全屏" : "网页全屏",
3285
3294
  "aria-label": z === "web" ? "退出网页全屏" : "网页全屏",
3286
3295
  style: {
@@ -3318,7 +3327,7 @@ function Fn({ node: e, deleteNode: r, selected: i, editor: a }) {
3318
3327
  })
3319
3328
  }), /* @__PURE__ */ D("button", {
3320
3329
  type: "button",
3321
- onClick: ue,
3330
+ onClick: de,
3322
3331
  title: z === "native" ? "退出全屏" : "全屏",
3323
3332
  "aria-label": z === "native" ? "退出全屏" : "全屏",
3324
3333
  style: {
@@ -4581,7 +4590,7 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
4581
4590
  }, [e.textContent]), ce = b(() => {
4582
4591
  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");
4583
4592
  a.href = i, a.download = n, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
4584
- }, [e.textContent, V]), J = b(async () => {
4593
+ }, [e.textContent, V]), le = b(async () => {
4585
4594
  if (N || L) {
4586
4595
  P(null), I(null), ee(!1);
4587
4596
  return;
@@ -4604,7 +4613,7 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
4604
4613
  e.textContent,
4605
4614
  N,
4606
4615
  L
4607
- ]), le = /* @__PURE__ */ O(E, { children: [H ? H.deviconClass ? /* @__PURE__ */ D("i", {
4616
+ ]), ue = /* @__PURE__ */ O(E, { children: [H ? H.deviconClass ? /* @__PURE__ */ D("i", {
4608
4617
  className: `${H.deviconClass} colored cb-lang-icon`,
4609
4618
  style: { color: H.color }
4610
4619
  }) : /* @__PURE__ */ D("span", {
@@ -4632,13 +4641,13 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
4632
4641
  contentEditable: !1,
4633
4642
  children: s ? /* @__PURE__ */ D("span", {
4634
4643
  className: "cb-lang-trigger cb-lang-trigger--static",
4635
- children: le
4644
+ children: ue
4636
4645
  }) : /* @__PURE__ */ O("button", {
4637
4646
  ref: re,
4638
4647
  type: "button",
4639
4648
  className: "cb-lang-trigger",
4640
4649
  onClick: () => m(!f),
4641
- children: [le, /* @__PURE__ */ D("svg", {
4650
+ children: [ue, /* @__PURE__ */ D("svg", {
4642
4651
  className: `cb-lang-chevron${f ? " cb-lang-chevron--open" : ""}`,
4643
4652
  width: "10",
4644
4653
  height: "10",
@@ -4835,7 +4844,7 @@ function Qn({ node: e, updateAttributes: t, editor: n, getPos: r, deleteNode: i,
4835
4844
  ae && /* @__PURE__ */ D("button", {
4836
4845
  type: "button",
4837
4846
  className: "cb-btn cb-btn--diagram",
4838
- onClick: J,
4847
+ onClick: le,
4839
4848
  contentEditable: !1,
4840
4849
  title: N || L ? "取消渲染" : "渲染图表",
4841
4850
  disabled: L,
@@ -4994,8 +5003,8 @@ var $n = [
4994
5003
  value: "mermaid",
4995
5004
  label: "Mermaid"
4996
5005
  }
4997
- ], er = be(ye);
4998
- er.register({ dockerfile: ve }), er.registerAlias("xml", ["vue", "html"]), er.registerAlias("javascript", ["react", "jsx"]), er.registerAlias("typescript", ["tsx"]);
5006
+ ], er = xe(be);
5007
+ er.register({ dockerfile: ye }), er.registerAlias("xml", ["vue", "html"]), er.registerAlias("javascript", ["react", "jsx"]), er.registerAlias("typescript", ["tsx"]);
4999
5008
  function tr(e) {
5000
5009
  return e ? e.split("\n") : [""];
5001
5010
  }
@@ -5062,7 +5071,7 @@ function ir(e, t, n) {
5062
5071
  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
5072
  }
5064
5073
  }
5065
- var ar = _e.extend({
5074
+ var ar = ve.extend({
5066
5075
  addNodeView() {
5067
5076
  return (e) => {
5068
5077
  let { node: t, editor: n, getPos: r } = e, i = t, a = (e) => {
@@ -5861,7 +5870,7 @@ function ni(e) {
5861
5870
  findSuggestionMatch: (e) => {
5862
5871
  let { $position: t } = e;
5863
5872
  for (let e = t.depth; e >= 0; e--) if (t.node(e).type.name === "codeBlock") return null;
5864
- return t.marks().some((e) => e.type.name === "code") ? null : Ce(e);
5873
+ return t.marks().some((e) => e.type.name === "code") ? null : we(e);
5865
5874
  },
5866
5875
  allow: ({ editor: e, state: t }) => {
5867
5876
  if (!e.isEditable) return !1;
@@ -5943,7 +5952,7 @@ function ni(e) {
5943
5952
  if (e.key === "Escape") {
5944
5953
  e.preventDefault();
5945
5954
  let t = a?.view;
5946
- t && Se(t, ti);
5955
+ t && Ce(t, ti);
5947
5956
  }
5948
5957
  });
5949
5958
  }
@@ -5961,7 +5970,7 @@ function ni(e) {
5961
5970
  if (!e || e.style.display === "none" || n.target instanceof Node && e.contains(n.target) || t) return;
5962
5971
  let r = a?.view;
5963
5972
  r && (t = !0, window.setTimeout(() => {
5964
- t = !1, e?.style.display !== "none" && Se(r, ti);
5973
+ t = !1, e?.style.display !== "none" && Ce(r, ti);
5965
5974
  }, 0));
5966
5975
  }, document.addEventListener("mousedown", o, !0), document.addEventListener("touchstart", o, !0);
5967
5976
  }
@@ -5985,7 +5994,7 @@ function ni(e) {
5985
5994
  };
5986
5995
  }
5987
5996
  };
5988
- return [xe({
5997
+ return [Se({
5989
5998
  editor: this.editor,
5990
5999
  ...t
5991
6000
  }), new z({
@@ -6198,24 +6207,24 @@ function ai(e = {}) {
6198
6207
  inline: !1,
6199
6208
  allowBase64: !0
6200
6209
  }),
6201
- me,
6202
- pe.configure({ nested: !0 }),
6203
- se.configure({ multicolor: !0 }),
6204
6210
  he,
6211
+ me.configure({ nested: !0 }),
6212
+ se.configure({ multicolor: !0 }),
6213
+ ge,
6205
6214
  q,
6206
6215
  K.configure(e.maxLength ? { limit: e.maxLength } : {}),
6207
6216
  ce,
6208
6217
  ar,
6209
- le.configure({ resizable: !0 }),
6210
- fe,
6211
- ue,
6218
+ ue.configure({ resizable: !0 }),
6219
+ pe,
6212
6220
  de,
6213
- ge.configure({
6221
+ fe,
6222
+ _e.configure({
6214
6223
  html: !0,
6215
6224
  transformPastedText: !0,
6216
6225
  transformCopiedText: !1
6217
6226
  }),
6218
- J.configure({ placeholder: e.placeholder || "输入 '/' 打开菜单…" }),
6227
+ le.configure({ placeholder: e.placeholder || "输入 '/' 打开菜单…" }),
6219
6228
  ni(() => ri((e) => f(e), {
6220
6229
  maxAttachmentSize: e.maxAttachmentSize,
6221
6230
  maxTotalAttachmentSize: e.maxTotalAttachmentSize
@@ -6701,13 +6710,13 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
6701
6710
  children: /* @__PURE__ */ D("div", { className: "w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin" })
6702
6711
  })]
6703
6712
  }), 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);
6713
+ 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({}), [le, ue] = T(""), [de, fe] = T(null), [pe, me] = T(m), [he, ge] = T(!1);
6705
6714
  x(() => {
6706
- pe(m);
6715
+ me(m);
6707
6716
  }, [m]);
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, {
6717
+ let [_e, ve] = T(!1), [ye, be] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 80rem)").matches : !0), [xe, Se] = T(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(min-width: 64rem)").matches : !0), Ce = w(null), we = w(null), Te = w(null), Ee = w(0), De = w(null), Oe = w(null), ke = w(null), Ae = w(null), [je, Me] = T(!1), [J, Ne] = T(!1), [Y, Pe] = T(!1), Fe = w(null), Ie = b(() => {
6718
+ let e = we.current, t = Te.current;
6719
+ e && (J ? (document.body.style.overflow = "", Object.assign(e.style, {
6711
6720
  position: "",
6712
6721
  top: "",
6713
6722
  left: "",
@@ -6723,9 +6732,9 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
6723
6732
  flex: "",
6724
6733
  overflow: "",
6725
6734
  minHeight: ""
6726
- }), je(!1), requestAnimationFrame(() => {
6727
- window.scrollTo(0, Te.current);
6728
- })) : (document.fullscreenElement && document.exitFullscreen(), Te.current = window.scrollY, Object.assign(e.style, {
6735
+ }), Ne(!1), requestAnimationFrame(() => {
6736
+ window.scrollTo(0, Ee.current);
6737
+ })) : (document.fullscreenElement && document.exitFullscreen(), Ee.current = window.scrollY, Object.assign(e.style, {
6729
6738
  position: "fixed",
6730
6739
  top: "0",
6731
6740
  left: "0",
@@ -6741,39 +6750,39 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
6741
6750
  flex: "1",
6742
6751
  overflow: "auto",
6743
6752
  minHeight: "0"
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]);
6753
+ }), document.body.style.overflow = "hidden", Ne(!0)));
6754
+ }, [J]), Le = b(() => {
6755
+ let e = we.current;
6756
+ e && (document.fullscreenElement ? document.exitFullscreen() : (J && Ie(), Ee.current = window.scrollY, e.requestFullscreen()));
6757
+ }, [J, Ie]);
6749
6758
  x(() => {
6750
6759
  let e = (e) => {
6751
- e.key === "Escape" && Y && Pe();
6760
+ e.key === "Escape" && J && Ie();
6752
6761
  }, t = () => {
6753
- document.fullscreenElement ? Ne(!0) : (Ne(!1), requestAnimationFrame(() => {
6754
- window.scrollTo(0, Te.current);
6762
+ document.fullscreenElement ? Pe(!0) : (Pe(!1), requestAnimationFrame(() => {
6763
+ window.scrollTo(0, Ee.current);
6755
6764
  }));
6756
6765
  };
6757
6766
  return window.addEventListener("keydown", e), document.addEventListener("fullscreenchange", t), () => {
6758
6767
  window.removeEventListener("keydown", e), document.removeEventListener("fullscreenchange", t);
6759
6768
  };
6760
- }, [Y, Pe]), x(() => {
6769
+ }, [J, Ie]), x(() => {
6761
6770
  if (!h) return;
6762
6771
  let e = (e) => {
6763
6772
  if ((e.ctrlKey || e.metaKey) && (e.key === "f" || e.key === "F")) {
6764
- if (!Ce.current) return;
6765
- e.preventDefault(), e.stopPropagation(), _e(!0);
6773
+ if (!we.current) return;
6774
+ e.preventDefault(), e.stopPropagation(), ve(!0);
6766
6775
  }
6767
6776
  };
6768
6777
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
6769
6778
  }, [h]), x(() => {
6770
6779
  if (typeof window > "u" || typeof window.matchMedia != "function") return;
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);
6780
+ let e = window.matchMedia("(min-width: 80rem)"), t = (e) => be(e.matches);
6781
+ return be(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
6773
6782
  }, []), x(() => {
6774
6783
  if (typeof window > "u" || typeof window.matchMedia != "function") return;
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);
6784
+ let e = window.matchMedia("(min-width: 64rem)"), t = (e) => Se(e.matches);
6785
+ return Se(e.matches), e.addEventListener("change", t), () => e.removeEventListener("change", t);
6777
6786
  }, []);
6778
6787
  let X = ee({
6779
6788
  extensions: ai({
@@ -6786,7 +6795,7 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
6786
6795
  editable: !k,
6787
6796
  immediatelyRender: _,
6788
6797
  onUpdate: ({ editor: e }) => {
6789
- t && (Se.current && clearTimeout(Se.current), Se.current = setTimeout(() => {
6798
+ t && (Ce.current && clearTimeout(Ce.current), Ce.current = setTimeout(() => {
6790
6799
  t?.(e.getHTML(), e.getJSON());
6791
6800
  }, 300));
6792
6801
  },
@@ -6802,9 +6811,9 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
6802
6811
  let r = n.getData("text/plain");
6803
6812
  if (!r || !r.includes("[[")) return !1;
6804
6813
  t.preventDefault();
6805
- let i = De.current?.storage?.relativeMedia;
6814
+ let i = Oe.current?.storage?.relativeMedia;
6806
6815
  i && (i.clipboardFiles = new Map(Array.from(n.files ?? []).map((e) => [e.name.toLowerCase(), e])), i.pausedUntilPaste = !1);
6807
- let a = De.current ? Si(De.current, r) : null;
6816
+ let a = Oe.current ? Si(Oe.current, r) : null;
6808
6817
  if (a) {
6809
6818
  let t = new N(a, 0, 0);
6810
6819
  e.dispatch(e.state.tr.replaceSelection(t).scrollIntoView());
@@ -6814,7 +6823,7 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
6814
6823
  }
6815
6824
  });
6816
6825
  x(() => {
6817
- De.current = X, window.__editor = X;
6826
+ Oe.current = X, window.__editor = X;
6818
6827
  }, [X]), x(() => {
6819
6828
  if (X) return () => Yt(X);
6820
6829
  }, [X]), x(() => {
@@ -6822,7 +6831,7 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
6822
6831
  }, [X, g]), x(() => {
6823
6832
  if (!X) return;
6824
6833
  let e = () => {
6825
- X.state.selection.empty && (q("none"), Ae(!1));
6834
+ X.state.selection.empty && (q("none"), Me(!1));
6826
6835
  };
6827
6836
  return X.on("selectionUpdate", e), () => {
6828
6837
  X.off("selectionUpdate", e);
@@ -6840,10 +6849,10 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
6840
6849
  o,
6841
6850
  s
6842
6851
  ]);
6843
- let Ie = w(e);
6852
+ let Re = w(e);
6844
6853
  x(() => {
6845
- if (!X || e === Ie.current) return;
6846
- Ie.current = e;
6854
+ if (!X || e === Re.current) return;
6855
+ Re.current = e;
6847
6856
  let t = typeof e == "object" && e || xi(e) ? e : d(e);
6848
6857
  X.commands.setContent(t, { emitUpdate: !1 });
6849
6858
  }, [X, e]), x(() => {
@@ -6866,53 +6875,53 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
6866
6875
  o,
6867
6876
  s
6868
6877
  ]);
6869
- let Le = b((e) => {
6870
- let t = Oe.current?.getBoundingClientRect();
6871
- q(e), Ae(!1), ce({
6878
+ let ze = b((e) => {
6879
+ let t = Ae.current?.getBoundingClientRect();
6880
+ q(e), Me(!1), ce({
6872
6881
  position: "fixed",
6873
6882
  top: t ? t.bottom + 8 : void 0,
6874
6883
  left: t ? Math.max(8, Math.min(t.left, window.innerWidth - 240)) : 8,
6875
6884
  zIndex: 9999
6876
6885
  });
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();
6886
+ }, []), Be = li((e) => f(e)), Ve = Be.filter((e) => !e.more), He = Be.filter((e) => e.more), Ue = Ve.filter((e) => e.key !== "ai"), We = Ve.find((e) => e.key === "ai"), Ge = b((e) => {
6887
+ if (X) if (Me(!1), e.key === "link") if (X.isActive("link")) X.chain().focus().unsetLink().run();
6879
6888
  else {
6880
6889
  let e = X.getAttributes("link").href || "";
6881
- le(e), Le("link");
6890
+ ue(e), ze("link");
6882
6891
  }
6883
- else e.key === "highlight" ? K === "highlight" ? q("none") : Le("highlight") : e.command(X);
6892
+ else e.key === "highlight" ? K === "highlight" ? q("none") : ze("highlight") : e.command(X);
6884
6893
  }, [
6885
6894
  X,
6886
6895
  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);
6896
+ ze
6897
+ ]), Ke = b((e) => X ? e.key === "highlight" ? K === "highlight" : e.key === "link" ? X.isActive("link") : e.isActive(X) : !1, [X, K]), [qe, Je] = T(0);
6889
6898
  x(() => {
6890
6899
  if (!X) return;
6891
- let e = () => Ke((e) => (e + 1) % 1e6);
6900
+ let e = () => Je((e) => (e + 1) % 1e6);
6892
6901
  return X.on("update", e), () => {
6893
6902
  X.off("update", e);
6894
6903
  };
6895
6904
  }, [X]);
6896
- let [qe, Je] = T(!1);
6905
+ let [Ye, Xe] = T(!1);
6897
6906
  x(() => {
6898
6907
  if (!X) return;
6899
6908
  let e = () => {
6900
6909
  let e = !1;
6901
6910
  X.state.doc.descendants((t) => {
6902
6911
  t.type.name === "heading" && (e = !0);
6903
- }), Je(e);
6912
+ }), Xe(e);
6904
6913
  };
6905
6914
  return e(), X.on("update", e), () => {
6906
6915
  X.off("update", e);
6907
6916
  };
6908
6917
  }, [X]);
6909
- let Ye = C(() => X?.storage?.characterCount?.characters?.() ?? 0, [X, Ge]), Xe = a ? Ye > a : !1;
6918
+ let Ze = C(() => X?.storage?.characterCount?.characters?.() ?? 0, [X, qe]), $e = a ? Ze > a : !1;
6910
6919
  x(() => () => {
6911
- Se.current && clearTimeout(Se.current);
6920
+ Ce.current && clearTimeout(Ce.current);
6912
6921
  }, []), x(() => () => {
6913
- ue && ue.resolve(null);
6922
+ de && de.resolve(null);
6914
6923
  }, []);
6915
- let Ze = b((e) => {
6924
+ let et = b((e) => {
6916
6925
  if (!X?.isEditable) return;
6917
6926
  let t = window.getSelection(), n;
6918
6927
  if (e) {
@@ -6937,8 +6946,8 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
6937
6946
  width: 0
6938
6947
  };
6939
6948
  }
6940
- Ee.current = n;
6941
- let r = Ce.current?.getBoundingClientRect(), i = bi(n, void 0, {
6949
+ De.current = n;
6950
+ let r = we.current?.getBoundingClientRect(), i = bi(n, void 0, {
6942
6951
  panelWidth: r?.width,
6943
6952
  editorLeft: r?.left
6944
6953
  });
@@ -6948,18 +6957,18 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
6948
6957
  if (!X) return;
6949
6958
  let e = X.storage.qingwuUI;
6950
6959
  if (e) return e.openImageDialog = () => V(!0), e.openVideoDialog = () => ae(!0), e.chooseMd = (e, t) => {
6951
- de({
6960
+ fe({
6952
6961
  filename: e,
6953
6962
  resolve: t
6954
6963
  });
6955
- }, e.openAI = Ze, e.parseMd = (e, t) => X ? Si(X, t) : null, () => {
6964
+ }, e.openAI = et, e.parseMd = (e, t) => X ? Si(X, t) : null, () => {
6956
6965
  delete e.openImageDialog, delete e.openVideoDialog, delete e.openAI, delete e.parseMd, delete e.chooseMd;
6957
6966
  };
6958
- }, [X, Ze]), S(() => {
6967
+ }, [X, et]), S(() => {
6959
6968
  if (!j || !X) return;
6960
- let e = Ee.current;
6969
+ let e = De.current;
6961
6970
  if (!e) return;
6962
- let t = z.current, n = Ce.current?.getBoundingClientRect(), r = bi(e, t?.offsetHeight || void 0, {
6971
+ let t = z.current, n = we.current?.getBoundingClientRect(), r = bi(e, t?.offsetHeight || void 0, {
6963
6972
  panelWidth: n?.width,
6964
6973
  editorLeft: n?.left
6965
6974
  });
@@ -6967,9 +6976,9 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
6967
6976
  }, [j, X]), x(() => {
6968
6977
  if (!j || !X) return;
6969
6978
  let e = () => {
6970
- let e = Ee.current;
6979
+ let e = De.current;
6971
6980
  if (!e) return;
6972
- let t = z.current, n = Ce.current?.getBoundingClientRect(), r = bi(e, t?.offsetHeight || void 0, {
6981
+ let t = z.current, n = we.current?.getBoundingClientRect(), r = bi(e, t?.offsetHeight || void 0, {
6973
6982
  panelWidth: n?.width,
6974
6983
  editorLeft: n?.left
6975
6984
  });
@@ -6977,19 +6986,49 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
6977
6986
  };
6978
6987
  return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
6979
6988
  }, [j, X]), x(() => {
6980
- j || (Ee.current = null);
6989
+ j || (De.current = null);
6981
6990
  }, [j]);
6982
- let $e = b((e) => {
6991
+ let tt = b((e) => {
6983
6992
  X?.chain().focus().setImage({ src: e }).run();
6984
- }, [X]), et = b((e) => {
6993
+ }, [X]), nt = b((e) => {
6985
6994
  (X?.commands).insertVideo?.({ src: e });
6986
- }, [X]), tt = fe && ve && !Y && !Me, nt = !tt && !me && (fe || qe && !(!k && be)), rt = w(!1);
6995
+ }, [X]), rt = pe && ye && !J && !Y, it = !rt && !he && (pe || Ye && !(!k && xe)), at = w(!1);
6987
6996
  return x(() => {
6988
- rt.current || (rt.current = !0, fe && !tt && he(!0));
6989
- }, [fe, tt]), X ? /* @__PURE__ */ O("div", {
6997
+ at.current || (at.current = !0, pe && !rt && ge(!0));
6998
+ }, [pe, rt]), x(() => {
6999
+ if (!he) return;
7000
+ let e = (e) => {
7001
+ let t = e.target;
7002
+ Fe.current?.contains(t) || ge(!1);
7003
+ }, t = (e) => {
7004
+ e.key === "Escape" && ge(!1);
7005
+ };
7006
+ return document.addEventListener("mousedown", e), document.addEventListener("touchstart", e, { passive: !0 }), document.addEventListener("keydown", t), () => {
7007
+ document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e), document.removeEventListener("keydown", t);
7008
+ };
7009
+ }, [he]), x(() => {
7010
+ if (!X || !rt) return;
7011
+ let e = ke.current;
7012
+ if (!(e instanceof HTMLElement)) return;
7013
+ let t = (t) => {
7014
+ let n = t.deltaY;
7015
+ if (n === 0) return;
7016
+ let r = e.scrollTop <= 0, i = !(e.scrollTop + e.clientHeight >= e.scrollHeight - 1);
7017
+ if (n > 0 && i || n < 0 && !r) {
7018
+ e.scrollTop += n, t.preventDefault(), t.stopPropagation();
7019
+ return;
7020
+ }
7021
+ let a = ot(X.view.dom);
7022
+ if (a) {
7023
+ a.scrollTop += n, t.preventDefault(), t.stopPropagation();
7024
+ return;
7025
+ }
7026
+ };
7027
+ return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
7028
+ }, [X, rt]), X ? /* @__PURE__ */ O("div", {
6990
7029
  className: "qingwu-editor-row",
6991
7030
  children: [/* @__PURE__ */ O("div", {
6992
- ref: Ce,
7031
+ ref: we,
6993
7032
  className: `qingwu-editor relative flex-1 min-w-0 bg-background ${k ? "qingwu-editor--readonly" : ""} ${l ? "" : "rounded-xl border border-default-200"} ${c}`,
6994
7033
  style: u,
6995
7034
  children: [
@@ -7000,13 +7039,13 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
7000
7039
  children: [
7001
7040
  /* @__PURE__ */ D("button", {
7002
7041
  type: "button",
7003
- className: `qed-tb-btn qed-tb-btn--desktop-only${fe ? " is-active" : ""}`,
7042
+ className: `qed-tb-btn qed-tb-btn--desktop-only${pe ? " is-active" : ""}`,
7004
7043
  onClick: () => {
7005
- fe ? (pe(!1), he(!1)) : (pe(!0), ve && !Y && !Me || he(!0));
7044
+ pe ? (me(!1), ge(!1)) : (me(!0), ye && !J && !Y || ge(!0));
7006
7045
  },
7007
- title: fe ? "隐藏目录" : "显示目录",
7008
- "aria-label": fe ? "隐藏目录" : "显示目录",
7009
- "aria-pressed": fe,
7046
+ title: pe ? "隐藏目录" : "显示目录",
7047
+ "aria-label": pe ? "隐藏目录" : "显示目录",
7048
+ "aria-pressed": pe,
7010
7049
  children: /* @__PURE__ */ D("svg", {
7011
7050
  fill: "none",
7012
7051
  viewBox: "0 0 24 24",
@@ -7022,11 +7061,11 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
7022
7061
  }),
7023
7062
  h && /* @__PURE__ */ D("button", {
7024
7063
  type: "button",
7025
- className: `qed-tb-btn${ge ? " is-active" : ""}`,
7026
- onClick: () => _e(!ge),
7064
+ className: `qed-tb-btn${_e ? " is-active" : ""}`,
7065
+ onClick: () => ve(!_e),
7027
7066
  title: "查找 (Ctrl+F)",
7028
7067
  "aria-label": "查找",
7029
- "aria-pressed": ge,
7068
+ "aria-pressed": _e,
7030
7069
  children: /* @__PURE__ */ D("svg", {
7031
7070
  fill: "none",
7032
7071
  viewBox: "0 0 24 24",
@@ -7043,7 +7082,7 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
7043
7082
  !k && /* @__PURE__ */ D("button", {
7044
7083
  type: "button",
7045
7084
  className: `qed-tb-btn qed-tb-btn--ai${j ? " is-active" : ""}`,
7046
- onClick: (e) => j ? M(!1) : Ze(e.currentTarget),
7085
+ onClick: (e) => j ? M(!1) : et(e.currentTarget),
7047
7086
  title: f("editor.toolbar.aiTitle"),
7048
7087
  "aria-label": f("editor.toolbar.ai"),
7049
7088
  "aria-pressed": j,
@@ -7091,11 +7130,11 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
7091
7130
  }),
7092
7131
  /* @__PURE__ */ D("button", {
7093
7132
  type: "button",
7094
- className: `qed-tb-btn${Y ? " is-active" : ""}`,
7095
- onClick: Pe,
7096
- title: Y ? "退出网页全屏" : "网页全屏",
7097
- "aria-label": Y ? "退出网页全屏" : "网页全屏",
7098
- "aria-pressed": Y,
7133
+ className: `qed-tb-btn${J ? " is-active" : ""}`,
7134
+ onClick: Ie,
7135
+ title: J ? "退出网页全屏" : "网页全屏",
7136
+ "aria-label": J ? "退出网页全屏" : "网页全屏",
7137
+ "aria-pressed": J,
7099
7138
  children: /* @__PURE__ */ D("svg", {
7100
7139
  fill: "none",
7101
7140
  viewBox: "0 0 24 24",
@@ -7111,11 +7150,11 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
7111
7150
  }),
7112
7151
  /* @__PURE__ */ D("button", {
7113
7152
  type: "button",
7114
- className: `qed-tb-btn${Me ? " is-active" : ""}`,
7115
- onClick: Fe,
7116
- title: Me ? "退出全屏" : "全屏",
7117
- "aria-label": Me ? "退出全屏" : "全屏",
7118
- "aria-pressed": Me,
7153
+ className: `qed-tb-btn${Y ? " is-active" : ""}`,
7154
+ onClick: Le,
7155
+ title: Y ? "退出全屏" : "全屏",
7156
+ "aria-label": Y ? "退出全屏" : "全屏",
7157
+ "aria-pressed": Y,
7119
7158
  children: /* @__PURE__ */ D("svg", {
7120
7159
  fill: "none",
7121
7160
  viewBox: "0 0 24 24",
@@ -7142,17 +7181,17 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
7142
7181
  },
7143
7182
  className: "bubble-menu-pop bg-background border border-default-200 rounded-xl p-1 shadow-lg",
7144
7183
  children: /* @__PURE__ */ O("div", {
7145
- ref: Oe,
7184
+ ref: Ae,
7146
7185
  className: "bubble-menu-items relative flex items-center gap-0.5",
7147
7186
  onPointerDown: (e) => {
7148
7187
  e.target.closest("button") && e.preventDefault();
7149
7188
  },
7150
7189
  children: [
7151
- Ve.map((e) => /* @__PURE__ */ D("button", {
7190
+ Ue.map((e) => /* @__PURE__ */ D("button", {
7152
7191
  type: "button",
7153
7192
  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"}`,
7154
7193
  onClick: (t) => {
7155
- t.preventDefault(), Ue(e);
7194
+ t.preventDefault(), Ge(e);
7156
7195
  },
7157
7196
  title: e.label,
7158
7197
  "aria-label": e.label,
@@ -7166,10 +7205,10 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
7166
7205
  type: "button",
7167
7206
  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"}`,
7168
7207
  onClick: (e) => {
7169
- e.preventDefault(), Ae(!1), He?.command(X);
7208
+ e.preventDefault(), Me(!1), We?.command(X);
7170
7209
  },
7171
- title: He?.label,
7172
- "aria-label": He?.label,
7210
+ title: We?.label,
7211
+ "aria-label": We?.label,
7173
7212
  children: /* @__PURE__ */ D(zt, {})
7174
7213
  }),
7175
7214
  /* @__PURE__ */ D("span", {
@@ -7178,27 +7217,27 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
7178
7217
  }),
7179
7218
  /* @__PURE__ */ D("button", {
7180
7219
  type: "button",
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"}`,
7220
+ "aria-expanded": je,
7221
+ 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"}`,
7183
7222
  onClick: (e) => {
7184
- e.preventDefault(), Ae((e) => !e);
7223
+ e.preventDefault(), Me((e) => !e);
7185
7224
  },
7186
7225
  title: f("editor.bubble.more"),
7187
7226
  "aria-label": f("editor.bubble.more"),
7188
7227
  children: /* @__PURE__ */ D(Bt, {})
7189
7228
  }),
7190
- ke && /* @__PURE__ */ D("div", {
7229
+ je && /* @__PURE__ */ D("div", {
7191
7230
  role: "menu",
7192
7231
  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",
7193
7232
  onPointerDown: (e) => {
7194
7233
  e.target.closest("button") && e.preventDefault();
7195
7234
  },
7196
- children: Be.map((e) => /* @__PURE__ */ O("button", {
7235
+ children: He.map((e) => /* @__PURE__ */ O("button", {
7197
7236
  type: "button",
7198
7237
  role: "menuitem",
7199
- className: `flex items-center gap-2 w-full whitespace-nowrap px-3 py-1.5 text-xs rounded-md transition-colors ${We(e) ? "bg-primary/10 text-primary" : "text-default-600 hover:bg-default-100"}`,
7238
+ className: `flex items-center gap-2 w-full whitespace-nowrap px-3 py-1.5 text-xs rounded-md transition-colors ${Ke(e) ? "bg-primary/10 text-primary" : "text-default-600 hover:bg-default-100"}`,
7200
7239
  onClick: (t) => {
7201
- t.preventDefault(), Ue(e);
7240
+ t.preventDefault(), Ge(e);
7202
7241
  },
7203
7242
  title: e.label,
7204
7243
  children: [/* @__PURE__ */ D("span", {
@@ -7245,16 +7284,16 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
7245
7284
  type: "url",
7246
7285
  className: "flex-1 px-2 py-1 text-xs rounded-md border border-default-200 bg-background focus:outline-none focus:border-primary",
7247
7286
  placeholder: "https://...",
7248
- value: J,
7249
- onChange: (e) => le(e.target.value),
7287
+ value: le,
7288
+ onChange: (e) => ue(e.target.value),
7250
7289
  onKeyDown: (e) => {
7251
- e.key === "Enter" ? (J.trim() && X.chain().focus().setLink({ href: J.trim() }).run(), q("none")) : e.key === "Escape" && q("none");
7290
+ e.key === "Enter" ? (le.trim() && X.chain().focus().setLink({ href: le.trim() }).run(), q("none")) : e.key === "Escape" && q("none");
7252
7291
  }
7253
7292
  }), /* @__PURE__ */ D("button", {
7254
7293
  type: "button",
7255
7294
  className: "px-2 py-1 text-xs rounded-md bg-primary text-white hover:opacity-90",
7256
7295
  onClick: () => {
7257
- J.trim() && X.chain().focus().setLink({ href: J.trim() }).run(), q("none");
7296
+ le.trim() && X.chain().focus().setLink({ href: le.trim() }).run(), q("none");
7258
7297
  },
7259
7298
  children: "确定"
7260
7299
  })]
@@ -7283,7 +7322,7 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
7283
7322
  children: /* @__PURE__ */ D(Ci, {
7284
7323
  open: B,
7285
7324
  onClose: () => V(!1),
7286
- onInsert: $e,
7325
+ onInsert: tt,
7287
7326
  validate: (e) => X ? un(X.state.doc, e, {
7288
7327
  maxAttachmentSize: o,
7289
7328
  maxTotalAttachmentSize: s
@@ -7295,7 +7334,7 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
7295
7334
  children: /* @__PURE__ */ D(Ei, {
7296
7335
  open: H,
7297
7336
  onClose: () => ae(!1),
7298
- onInsert: et
7337
+ onInsert: nt
7299
7338
  })
7300
7339
  }),
7301
7340
  oe && /* @__PURE__ */ D(v, {
@@ -7313,24 +7352,24 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
7313
7352
  editor: X
7314
7353
  })
7315
7354
  }),
7316
- ue && /* @__PURE__ */ D(v, {
7355
+ de && /* @__PURE__ */ D(v, {
7317
7356
  fallback: /* @__PURE__ */ D(Oi, {}),
7318
7357
  children: /* @__PURE__ */ D(Di, {
7319
- open: !!ue,
7320
- filename: ue.filename,
7358
+ open: !!de,
7359
+ filename: de.filename,
7321
7360
  onRender: () => {
7322
- ue.resolve("render"), de(null);
7361
+ de.resolve("render"), fe(null);
7323
7362
  },
7324
7363
  onAttach: () => {
7325
- ue.resolve("attach"), de(null);
7364
+ de.resolve("attach"), fe(null);
7326
7365
  },
7327
7366
  onClose: () => {
7328
- ue.resolve(null), de(null);
7367
+ de.resolve(null), fe(null);
7329
7368
  }
7330
7369
  })
7331
7370
  }),
7332
7371
  /* @__PURE__ */ D("div", {
7333
- ref: we,
7372
+ ref: Te,
7334
7373
  className: "flex editor-body",
7335
7374
  children: /* @__PURE__ */ O("div", {
7336
7375
  className: "relative min-w-0 flex-1",
@@ -7338,11 +7377,11 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
7338
7377
  /* @__PURE__ */ D(P, { editor: X }),
7339
7378
  !k && /* @__PURE__ */ D(hi, { editor: X }),
7340
7379
  /* @__PURE__ */ D("div", {
7341
- className: `${Y || Me ? "fixed" : "absolute"} bottom-2 right-4 z-10 pointer-events-none select-none`,
7380
+ className: `${J || Y ? "fixed" : "absolute"} bottom-2 right-4 z-10 pointer-events-none select-none`,
7342
7381
  children: /* @__PURE__ */ O("span", {
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"}`,
7382
+ className: `text-xs ${$e ? "bg-danger/10 text-danger font-medium px-2 py-0.5 rounded" : a && Ze > a * .9 ? "bg-warning/10 text-warning px-2 py-0.5 rounded" : "text-default-300"}`,
7344
7383
  children: [
7345
- Ye,
7384
+ Ze,
7346
7385
  a ? ` / ${a}` : "",
7347
7386
  " 字"
7348
7387
  ]
@@ -7351,14 +7390,14 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
7351
7390
  ]
7352
7391
  })
7353
7392
  }),
7354
- h && ge && /* @__PURE__ */ D(Ot, {
7393
+ h && _e && /* @__PURE__ */ D(Ot, {
7355
7394
  editor: X,
7356
- onClose: () => _e(!1)
7395
+ onClose: () => ve(!1)
7357
7396
  }),
7358
- nt && /* @__PURE__ */ D("button", {
7397
+ it && /* @__PURE__ */ D("button", {
7359
7398
  type: "button",
7360
7399
  className: "qingwu-toc-fab",
7361
- onClick: () => he(!0),
7400
+ onClick: () => ge(!0),
7362
7401
  title: "目录",
7363
7402
  "aria-label": "打开目录",
7364
7403
  children: /* @__PURE__ */ D("svg", {
@@ -7374,8 +7413,10 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
7374
7413
  })
7375
7414
  })
7376
7415
  }),
7377
- me && /* @__PURE__ */ O("div", {
7416
+ he && ne(/* @__PURE__ */ O("div", {
7417
+ ref: Fe,
7378
7418
  className: "qingwu-toc-drawer toc-scroll",
7419
+ "data-lenis-prevent": !0,
7379
7420
  children: [/* @__PURE__ */ O("div", {
7380
7421
  className: "qed-drawer-head",
7381
7422
  children: [/* @__PURE__ */ D("span", {
@@ -7384,7 +7425,7 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
7384
7425
  }), /* @__PURE__ */ D("button", {
7385
7426
  type: "button",
7386
7427
  className: "qed-drawer-head__close",
7387
- onClick: () => he(!1),
7428
+ onClick: () => ge(!1),
7388
7429
  "aria-label": "关闭目录",
7389
7430
  children: /* @__PURE__ */ D("svg", {
7390
7431
  fill: "none",
@@ -7403,16 +7444,17 @@ var Ci = y(() => Promise.resolve().then(() => $e).then((e) => ({ default: e.Imag
7403
7444
  editor: X,
7404
7445
  className: "!p-3",
7405
7446
  onClose: () => {
7406
- he(!1), pe(!1);
7447
+ ge(!1), me(!1);
7407
7448
  }
7408
7449
  })]
7409
- })
7450
+ }), document.body)
7410
7451
  ]
7411
- }), tt && /* @__PURE__ */ D("aside", {
7452
+ }), rt && /* @__PURE__ */ D("aside", {
7453
+ ref: ke,
7412
7454
  className: "qingwu-toc-desktop toc-scroll",
7413
7455
  children: /* @__PURE__ */ D(ut, {
7414
7456
  editor: X,
7415
- onClose: () => pe(!1)
7457
+ onClose: () => me(!1)
7416
7458
  })
7417
7459
  })]
7418
7460
  }) : /* @__PURE__ */ D("div", {