patent-editor 0.2.11 → 0.2.13

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/lib.js CHANGED
@@ -83,7 +83,7 @@ const Zr = new we("slashCommand"), Qr = Oe.create({
83
83
  regenerate: !1,
84
84
  chatReferences: [],
85
85
  pendingChatMessage: null
86
- }, N = tr((e) => ({
86
+ }, I = tr((e) => ({
87
87
  editor: null,
88
88
  document: null,
89
89
  selection: null,
@@ -170,19 +170,19 @@ const Zr = new we("slashCommand"), Qr = Oe.create({
170
170
  }, [e]);
171
171
  const i = ae(
172
172
  (s) => {
173
- const o = e[s];
174
- o && t(o);
173
+ const c = e[s];
174
+ c && t(c);
175
175
  },
176
176
  [e, t]
177
177
  );
178
178
  return Nt(n, () => ({
179
- onKeyDown: ({ event: s }) => s.key === "ArrowUp" ? (a((o) => (o + e.length - 1) % e.length), !0) : s.key === "ArrowDown" ? (a((o) => (o + 1) % e.length), !0) : s.key === "Enter" ? (i(r), !0) : !1
180
- })), e.length ? /* @__PURE__ */ g("div", { className: "slash-menu", children: e.map((s, o) => /* @__PURE__ */ L(
179
+ onKeyDown: ({ event: s }) => s.key === "ArrowUp" ? (a((c) => (c + e.length - 1) % e.length), !0) : s.key === "ArrowDown" ? (a((c) => (c + 1) % e.length), !0) : s.key === "Enter" ? (i(r), !0) : !1
180
+ })), e.length ? /* @__PURE__ */ g("div", { className: "slash-menu", children: e.map((s, c) => /* @__PURE__ */ L(
181
181
  "button",
182
182
  {
183
- className: `slash-menu-item ${o === r ? "slash-menu-item--active" : ""}`,
184
- onClick: () => i(o),
185
- onMouseEnter: () => a(o),
183
+ className: `slash-menu-item ${c === r ? "slash-menu-item--active" : ""}`,
184
+ onClick: () => i(c),
185
+ onMouseEnter: () => a(c),
186
186
  children: [
187
187
  /* @__PURE__ */ g("span", { className: "slash-menu-icon", children: s.icon }),
188
188
  /* @__PURE__ */ L("div", { className: "slash-menu-text", children: [
@@ -302,7 +302,7 @@ function na() {
302
302
  return {
303
303
  char: "/",
304
304
  items: ({ query: e }) => {
305
- const t = N.getState().editorLanguage, n = ta(t);
305
+ const t = I.getState().editorLanguage, n = ta(t);
306
306
  if (!e) return n;
307
307
  const r = e.toLowerCase();
308
308
  return n.filter(
@@ -348,24 +348,24 @@ function ke(e, t, n) {
348
348
  if (!t) return [];
349
349
  const r = [], a = e.textBetween(0, e.content.size, `
350
350
  `, "\0"), i = n ? t : t.toLowerCase(), s = n ? a : a.toLowerCase();
351
- let o = 0;
352
- for (; o < s.length; ) {
353
- const c = s.indexOf(i, o);
354
- if (c === -1) break;
355
- let l = 0, d = -1, u = -1;
351
+ let c = 0;
352
+ for (; c < s.length; ) {
353
+ const l = s.indexOf(i, c);
354
+ if (l === -1) break;
355
+ let o = 0, d = -1, u = -1;
356
356
  e.descendants((m, f) => {
357
357
  if (d !== -1 && u !== -1) return !1;
358
358
  if (m.isText) {
359
359
  const p = m.text || "";
360
- for (let h = 0; h < p.length; h++) {
361
- if (l === c && (d = f + h), l === c + i.length)
362
- return u = f + h, !1;
363
- l++;
360
+ for (let b = 0; b < p.length; b++) {
361
+ if (o === l && (d = f + b), o === l + i.length)
362
+ return u = f + b, !1;
363
+ o++;
364
364
  }
365
- l === c + i.length && u === -1 && (u = f + p.length);
366
- } else m.isBlock && l > 0 && (l === c && (d = f), l++);
365
+ o === l + i.length && u === -1 && (u = f + p.length);
366
+ } else m.isBlock && o > 0 && (o === l && (d = f), o++);
367
367
  return !0;
368
- }), d !== -1 && u !== -1 && r.push({ from: d, to: u }), o = c + 1;
368
+ }), d !== -1 && u !== -1 && r.push({ from: d, to: u }), c = l + 1;
369
369
  }
370
370
  return r;
371
371
  }
@@ -408,9 +408,9 @@ const aa = Oe.create({
408
408
  let a = ke(e.state.doc, t, r);
409
409
  const i = e.state.tr;
410
410
  let s = 0;
411
- for (const o of a) {
412
- const c = o.from + s, l = o.to + s;
413
- i.insertText(n, c, l), s += n.length - (o.to - o.from);
411
+ for (const c of a) {
412
+ const l = c.from + s, o = c.to + s;
413
+ i.insertText(n, l, o), s += n.length - (c.to - c.from);
414
414
  }
415
415
  return e.view.dispatch(i), this.storage.results = [], this.storage.currentIndex = -1, !0;
416
416
  },
@@ -471,10 +471,10 @@ function ca(e, t) {
471
471
  function Gt(e, t, n) {
472
472
  const r = [];
473
473
  let a = "", i = !0;
474
- return e.state.doc.nodesBetween(t, n, (s, o) => {
474
+ return e.state.doc.nodesBetween(t, n, (s, c) => {
475
475
  if (s.isText) {
476
- const c = o, l = Math.max(t, c) - c, d = Math.min(n, c + s.nodeSize) - c, u = s.text.slice(l, d);
477
- r.push({ textIdx: a.length, docPos: c + l, len: u.length }), a += u, i = !1;
476
+ const l = c, o = Math.max(t, l) - l, d = Math.min(n, l + s.nodeSize) - l, u = s.text.slice(o, d);
477
+ r.push({ textIdx: a.length, docPos: l + o, len: u.length }), a += u, i = !1;
478
478
  } else s.isLeaf ? (a += "\0", i = !1) : !i && s.isBlock && (a += "\0", i = !0);
479
479
  }), { text: a, segments: r };
480
480
  }
@@ -493,24 +493,24 @@ function ye(e, t) {
493
493
  }
494
494
  function ht(e, t, n, r, a) {
495
495
  const { text: i, segments: s } = Gt(e, n, r);
496
- let o = 0;
497
- for (; o <= i.length - t.length; ) {
498
- const c = i.indexOf(t, o);
499
- if (c === -1) return null;
500
- const l = ye(s, c), d = ye(s, c + t.length);
501
- if (l >= 0 && d >= 0 && !(a && a.has(l)))
502
- return { from: l, to: d };
503
- o = c + 1;
496
+ let c = 0;
497
+ for (; c <= i.length - t.length; ) {
498
+ const l = i.indexOf(t, c);
499
+ if (l === -1) return null;
500
+ const o = ye(s, l), d = ye(s, l + t.length);
501
+ if (o >= 0 && d >= 0 && !(a && a.has(o)))
502
+ return { from: o, to: d };
503
+ c = l + 1;
504
504
  }
505
505
  return null;
506
506
  }
507
507
  function Ds(e, t, n, r, a) {
508
508
  const i = t.target;
509
509
  let s = null;
510
- const o = /* @__PURE__ */ new Set();
510
+ const c = /* @__PURE__ */ new Set();
511
511
  if (a)
512
512
  for (const d of a)
513
- o.add(d.from);
513
+ c.add(d.from);
514
514
  if (!i)
515
515
  t.from != null && t.to != null && (s = { from: t.from, to: t.to });
516
516
  else if (i.type === "section" && i.sectionType)
@@ -518,21 +518,21 @@ function Ds(e, t, n, r, a) {
518
518
  else if (i.type === "ref" && i.refIndex != null) {
519
519
  const d = n[i.refIndex];
520
520
  (d == null ? void 0 : d.from) != null && (d == null ? void 0 : d.to) != null && (s = { from: d.from, to: d.to });
521
- } else i.type === "search" && i.searchText && (s = ht(e, i.searchText, 0, e.state.doc.content.size, o));
521
+ } else i.type === "search" && i.searchText && (s = ht(e, i.searchText, 0, e.state.doc.content.size, c));
522
522
  if (!s) return null;
523
- let c = s;
523
+ let l = s;
524
524
  if (t.search) {
525
- const d = ht(e, t.search, s.from, s.to, o);
526
- d && (c = d);
525
+ const d = ht(e, t.search, s.from, s.to, c);
526
+ d && (l = d);
527
527
  }
528
- const l = c.from < c.to ? e.state.doc.textBetween(c.from, c.to, " ", "\0") : "";
528
+ const o = l.from < l.to ? e.state.doc.textBetween(l.from, l.to, " ", "\0") : "";
529
529
  return {
530
530
  id: `patch_${Date.now()}_${r}`,
531
531
  type: t.op === "delete" ? "delete" : t.op === "insert" ? "insert" : "replace",
532
- from: c.from,
533
- to: t.op === "insert" ? c.from : c.to,
532
+ from: l.from,
533
+ to: t.op === "insert" ? l.from : l.to,
534
534
  content: t.content || "",
535
- originalText: l,
535
+ originalText: o,
536
536
  reason: t.reason,
537
537
  status: "pending"
538
538
  };
@@ -557,7 +557,7 @@ function $s(e = "default") {
557
557
  j.delete(e), ue();
558
558
  }
559
559
  function zs(e, t, n = "default") {
560
- const r = j.get(n) || [], a = r.find((o) => o.id === t);
560
+ const r = j.get(n) || [], a = r.find((c) => c.id === t);
561
561
  if (!a || a.status !== "pending") return !1;
562
562
  a.status = "accepted";
563
563
  const { tr: i } = e.state;
@@ -566,33 +566,33 @@ function zs(e, t, n = "default") {
566
566
  else if (a.type === "insert")
567
567
  i.insertText(a.content, a.from);
568
568
  else if (Vt(e, a.from, a.to)) {
569
- const c = Jt(e, a.content);
570
- i.replaceWith(a.from, a.to, c);
569
+ const l = Jt(e, a.content);
570
+ i.replaceWith(a.from, a.to, l);
571
571
  } else
572
572
  i.insertText(a.content, a.from, a.to);
573
573
  e.view.dispatch(i);
574
574
  const s = i.mapping;
575
- for (const o of r) {
576
- if (o.id === t || o.status !== "pending") continue;
577
- const c = s.map(o.from, 1), l = s.map(o.to, -1);
578
- c >= l && o.type !== "insert" ? o.status = "rejected" : (o.from = c, o.to = o.type === "insert" ? c : l);
575
+ for (const c of r) {
576
+ if (c.id === t || c.status !== "pending") continue;
577
+ const l = s.map(c.from, 1), o = s.map(c.to, -1);
578
+ l >= o && c.type !== "insert" ? c.status = "rejected" : (c.from = l, c.to = c.type === "insert" ? l : o);
579
579
  }
580
- return j.set(n, r.filter((o) => o.id !== t && o.status === "pending")), qe(e), ue(), !0;
580
+ return j.set(n, r.filter((c) => c.id !== t && c.status === "pending")), qe(e), ue(), !0;
581
581
  }
582
582
  function Os(e, t, n = "default") {
583
583
  const r = j.get(n) || [], a = r.find((i) => i.id === t);
584
584
  return !a || a.status !== "pending" ? !1 : (a.status = "rejected", j.set(n, r.filter((i) => i.id !== t)), qe(e), ue(), !0);
585
585
  }
586
586
  function Bs(e, t = "default") {
587
- const a = [...(j.get(t) || []).filter((s) => s.status === "pending")].sort((s, o) => o.from - s.from), { tr: i } = e.state;
587
+ const a = [...(j.get(t) || []).filter((s) => s.status === "pending")].sort((s, c) => c.from - s.from), { tr: i } = e.state;
588
588
  for (const s of a)
589
589
  if (s.type === "delete")
590
590
  i.delete(s.from, s.to);
591
591
  else if (s.type === "insert")
592
592
  i.insertText(s.content, s.from);
593
593
  else if (Vt(e, s.from, s.to)) {
594
- const c = Jt(e, s.content);
595
- i.replaceWith(s.from, s.to, c);
594
+ const l = Jt(e, s.content);
595
+ i.replaceWith(s.from, s.to, l);
596
596
  } else
597
597
  i.insertText(s.content, s.from, s.to);
598
598
  e.view.dispatch(i), j.delete(t), qe(e), ue();
@@ -607,8 +607,8 @@ function la(e, t, n) {
607
607
  const r = [];
608
608
  return e.nodesBetween(t, n, (a, i) => {
609
609
  if (a.isTextblock) {
610
- const s = i + 1, o = i + a.nodeSize - 1, c = Math.max(s, t), l = Math.min(o, n);
611
- return l > c && r.push({ from: c, to: l }), !1;
610
+ const s = i + 1, c = i + a.nodeSize - 1, l = Math.max(s, t), o = Math.min(c, n);
611
+ return o > l && r.push({ from: l, to: o }), !1;
612
612
  }
613
613
  return !0;
614
614
  }), r;
@@ -616,32 +616,32 @@ function la(e, t, n) {
616
616
  function da(e, t) {
617
617
  if (!t.originalText || !t.content) return null;
618
618
  try {
619
- const o = e.resolve(t.from), c = e.resolve(t.to);
620
- if (o.parent !== c.parent || !o.parent.isTextblock) return null;
619
+ const c = e.resolve(t.from), l = e.resolve(t.to);
620
+ if (c.parent !== l.parent || !c.parent.isTextblock) return null;
621
621
  } catch {
622
622
  return null;
623
623
  }
624
624
  const n = oa(), r = n.diff_main(t.originalText, t.content);
625
625
  n.diff_cleanupSemantic(r);
626
- const a = r.filter(([o]) => o === pt).reduce((o, [, c]) => o + c.length, 0);
626
+ const a = r.filter(([c]) => c === pt).reduce((c, [, l]) => c + l.length, 0);
627
627
  if (t.originalText.length > 0 && a / t.originalText.length < 0.3) return null;
628
628
  const i = [];
629
629
  let s = t.from;
630
- for (const [o, c] of r)
631
- if (o === pt)
632
- s += c.length;
633
- else if (o === ia) {
634
- const l = s + c.length;
630
+ for (const [c, l] of r)
631
+ if (c === pt)
632
+ s += l.length;
633
+ else if (c === ia) {
634
+ const o = s + l.length;
635
635
  i.push(
636
- re.inline(s, l, {
636
+ re.inline(s, o, {
637
637
  class: "patch-diff-delete",
638
638
  "data-patch-id": t.id
639
639
  })
640
- ), s = l;
641
- } else o === sa && i.push(
640
+ ), s = o;
641
+ } else c === sa && i.push(
642
642
  re.widget(s, () => {
643
- const l = document.createElement("span");
644
- return l.className = "patch-diff-insert-inline", l.textContent = c, l.setAttribute("data-patch-id", t.id), l;
643
+ const o = document.createElement("span");
644
+ return o.className = "patch-diff-insert-inline", o.textContent = l, o.setAttribute("data-patch-id", t.id), o;
645
645
  }, { side: 1 })
646
646
  );
647
647
  return i;
@@ -672,12 +672,12 @@ function ua(e = "default") {
672
672
  })
673
673
  );
674
674
  if (a.type === "replace") {
675
- const s = i.length > 0 ? i[i.length - 1].to : a.to, o = a.content.length > 120 || a.content.includes(`
675
+ const s = i.length > 0 ? i[i.length - 1].to : a.to, c = a.content.length > 120 || a.content.includes(`
676
676
  `);
677
677
  r.push(
678
678
  re.widget(s, () => {
679
- const c = document.createElement(o ? "div" : "span");
680
- return c.className = o ? "patch-diff-insert-inline patch-diff-insert-block" : "patch-diff-insert-inline", c.textContent = a.content, c.setAttribute("data-patch-id", a.id), c;
679
+ const l = document.createElement(c ? "div" : "span");
680
+ return l.className = c ? "patch-diff-insert-inline patch-diff-insert-block" : "patch-diff-insert-inline", l.textContent = a.content, l.setAttribute("data-patch-id", a.id), l;
681
681
  }, { side: 1 })
682
682
  );
683
683
  }
@@ -844,8 +844,8 @@ class ba {
844
844
  }
845
845
  async execute(t, n, r, a = {}) {
846
846
  var d, u, m, f;
847
- const i = Date.now(), s = a.transaction ?? !0, o = a.rollbackOnFail ?? !0, c = s ? n.editor.getJSON() : null, l = this.commands.get(t);
848
- if (!l)
847
+ const i = Date.now(), s = a.transaction ?? !0, c = a.rollbackOnFail ?? !0, l = s ? n.editor.getJSON() : null, o = this.commands.get(t);
848
+ if (!o)
849
849
  return console.warn(`Command "${t}" not found.`), (d = a.onComplete) == null || d.call(a, {
850
850
  name: t,
851
851
  success: !1,
@@ -858,23 +858,23 @@ class ba {
858
858
  durationMs: Date.now() - i
859
859
  }), !1;
860
860
  try {
861
- const h = !!await l.execute(n, r);
862
- !h && c && o && n.editor.commands.setContent(c);
861
+ const b = !!await o.execute(n, r);
862
+ !b && l && c && n.editor.commands.setContent(l);
863
863
  const y = {
864
864
  name: t,
865
- success: h,
865
+ success: b,
866
866
  durationMs: Date.now() - i
867
867
  };
868
- return (m = a.onComplete) == null || m.call(a, y), h;
868
+ return (m = a.onComplete) == null || m.call(a, y), b;
869
869
  } catch (p) {
870
- c && o && n.editor.commands.setContent(c);
871
- const h = {
870
+ l && c && n.editor.commands.setContent(l);
871
+ const b = {
872
872
  name: t,
873
873
  success: !1,
874
874
  durationMs: Date.now() - i,
875
875
  error: p
876
876
  };
877
- return (f = a.onComplete) == null || f.call(a, h), !1;
877
+ return (f = a.onComplete) == null || f.call(a, b), !1;
878
878
  }
879
879
  }
880
880
  getCommand(t) {
@@ -1245,12 +1245,12 @@ const Ie = () => {
1245
1245
  i.classList.add("mermaid-node");
1246
1246
  const s = document.createElement("div");
1247
1247
  s.className = "mermaid-view", s.contentEditable = "false";
1248
- const o = document.createElement("div");
1249
- o.className = "mermaid-preview", o.contentEditable = "false";
1250
1248
  const c = document.createElement("div");
1251
- c.className = "mermaid-view-hint", s.append(o, c);
1249
+ c.className = "mermaid-preview", c.contentEditable = "false";
1252
1250
  const l = document.createElement("div");
1253
- l.className = "mermaid-edit";
1251
+ l.className = "mermaid-view-hint", s.append(c, l);
1252
+ const o = document.createElement("div");
1253
+ o.className = "mermaid-edit";
1254
1254
  const d = document.createElement("textarea");
1255
1255
  d.className = "mermaid-editor-textarea", d.spellcheck = !1;
1256
1256
  const u = document.createElement("div");
@@ -1260,79 +1260,79 @@ const Ie = () => {
1260
1260
  const f = document.createElement("button");
1261
1261
  f.className = "mermaid-cancel-btn", f.type = "button";
1262
1262
  const p = document.createElement("button");
1263
- p.className = "mermaid-save-btn", p.type = "button", u.append(m, f, p), l.append(d, u), i.append(s, l);
1264
- const h = (C) => {
1265
- const I = typeof n == "function" ? n() : null;
1266
- typeof I == "number" && e.commands.command(({ tr: A, dispatch: D }) => (A.setNodeMarkup(I, void 0, { ...r.attrs, ...C }), D && D(A), !0));
1263
+ p.className = "mermaid-save-btn", p.type = "button", u.append(m, f, p), o.append(d, u), i.append(s, o);
1264
+ const b = (C) => {
1265
+ const _ = typeof n == "function" ? n() : null;
1266
+ typeof _ == "number" && e.commands.command(({ tr: A, dispatch: D }) => (A.setNodeMarkup(_, void 0, { ...r.attrs, ...C }), D && D(A), !0));
1267
1267
  };
1268
1268
  let y = "";
1269
- const x = async (C) => {
1270
- const I = C.trim();
1271
- if (I !== y) {
1272
- if (!I) {
1273
- o.innerHTML = "", y = "";
1269
+ const w = async (C) => {
1270
+ const _ = C.trim();
1271
+ if (_ !== y) {
1272
+ if (!_) {
1273
+ c.innerHTML = "", y = "";
1274
1274
  return;
1275
1275
  }
1276
1276
  try {
1277
1277
  const A = await import("mermaid");
1278
1278
  A.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
1279
- const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, I);
1280
- o.innerHTML = z, y = I;
1279
+ const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, _);
1280
+ c.innerHTML = z, y = _;
1281
1281
  } catch {
1282
- o.innerHTML = "", y = "";
1282
+ c.innerHTML = "", y = "";
1283
1283
  } finally {
1284
1284
  Ie();
1285
1285
  }
1286
1286
  }
1287
- }, w = () => {
1288
- a || (a = !0, d.value = typeof r.attrs.code == "string" ? r.attrs.code : "", m.textContent = "", m.style.display = "none", E(), requestAnimationFrame(() => d.focus()));
1289
1287
  }, T = () => {
1290
- a = !1, E();
1291
- }, v = async () => {
1288
+ a || (a = !0, d.value = typeof r.attrs.code == "string" ? r.attrs.code : "", m.textContent = "", m.style.display = "none", S(), requestAnimationFrame(() => d.focus()));
1289
+ }, v = () => {
1290
+ a = !1, S();
1291
+ }, x = async () => {
1292
1292
  const C = d.value;
1293
1293
  m.textContent = "", m.style.display = "none";
1294
- const I = C.trim();
1295
- if (I)
1294
+ const _ = C.trim();
1295
+ if (_)
1296
1296
  try {
1297
1297
  const A = await import("mermaid");
1298
1298
  A.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
1299
- const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, I);
1300
- o.innerHTML = z, y = I, Ie();
1299
+ const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, _);
1300
+ c.innerHTML = z, y = _, Ie();
1301
1301
  } catch {
1302
1302
  Ie();
1303
- const A = N.getState().editorLanguage;
1303
+ const A = I.getState().editorLanguage;
1304
1304
  m.textContent = A === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", m.style.display = "inline";
1305
1305
  return;
1306
1306
  }
1307
- h({ code: C }), a = !1, E();
1307
+ b({ code: C }), a = !1, S();
1308
1308
  };
1309
1309
  s.addEventListener("dblclick", (C) => {
1310
- C.preventDefault(), C.stopPropagation(), w();
1310
+ C.preventDefault(), C.stopPropagation(), T();
1311
1311
  }), p.addEventListener("click", (C) => {
1312
- C.stopPropagation(), v();
1312
+ C.stopPropagation(), x();
1313
1313
  }), f.addEventListener("click", (C) => {
1314
- C.stopPropagation(), T();
1314
+ C.stopPropagation(), v();
1315
1315
  }), d.addEventListener("mousedown", (C) => C.stopPropagation()), d.addEventListener("keydown", (C) => C.stopPropagation()), d.addEventListener("keypress", (C) => C.stopPropagation());
1316
- const E = () => {
1317
- const C = N.getState().editorLanguage, I = H(C), A = typeof r.attrs.code == "string" ? r.attrs.code : "";
1318
- s.style.display = a ? "none" : "block", l.style.display = a ? "block" : "none", p.textContent = I.mermaidSaveAndRender || "保存并渲染", f.textContent = I.mermaidCancel || "取消";
1319
- const D = A.trim().length > 0, z = o.querySelector("svg") !== null;
1320
- a || (D && z ? (c.textContent = I.mermaidDoubleClickToEdit || "双击编辑", c.className = "mermaid-view-hint mermaid-view-hint--subtle") : (c.textContent = I.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", c.className = "mermaid-view-hint mermaid-view-hint--empty")), !a && A.trim() !== y && x(A);
1316
+ const S = () => {
1317
+ const C = I.getState().editorLanguage, _ = H(C), A = typeof r.attrs.code == "string" ? r.attrs.code : "";
1318
+ s.style.display = a ? "none" : "block", o.style.display = a ? "block" : "none", p.textContent = _.mermaidSaveAndRender || "保存并渲染", f.textContent = _.mermaidCancel || "取消";
1319
+ const D = A.trim().length > 0, z = c.querySelector("svg") !== null;
1320
+ a || (D && z ? (l.textContent = _.mermaidDoubleClickToEdit || "双击编辑", l.className = "mermaid-view-hint mermaid-view-hint--subtle") : (l.textContent = _.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", l.className = "mermaid-view-hint mermaid-view-hint--empty")), !a && A.trim() !== y && w(A);
1321
1321
  };
1322
- let _ = N.getState().editorLanguage;
1323
- const b = N.subscribe((C) => {
1324
- C.editorLanguage !== _ && (_ = C.editorLanguage, E());
1322
+ let N = I.getState().editorLanguage;
1323
+ const h = I.subscribe((C) => {
1324
+ C.editorLanguage !== N && (N = C.editorLanguage, S());
1325
1325
  });
1326
- return E(), {
1326
+ return S(), {
1327
1327
  dom: i,
1328
1328
  stopEvent: (C) => {
1329
- const I = C.target;
1330
- return !!(I === d || l.contains(I));
1329
+ const _ = C.target;
1330
+ return !!(_ === d || o.contains(_));
1331
1331
  },
1332
1332
  ignoreMutation: () => !0,
1333
- update: (C) => C.type.name !== "mermaid" ? !1 : (r = C, E(), !0),
1333
+ update: (C) => C.type.name !== "mermaid" ? !1 : (r = C, S(), !0),
1334
1334
  destroy: () => {
1335
- b(), Ie();
1335
+ h(), Ie();
1336
1336
  }
1337
1337
  };
1338
1338
  };
@@ -1388,35 +1388,35 @@ const Ie = () => {
1388
1388
  i.classList.add("drawio-node");
1389
1389
  const s = document.createElement("div");
1390
1390
  s.className = "drawio-view", s.contentEditable = "false";
1391
- const o = document.createElement("img");
1392
- o.className = "drawio-preview-img", o.style.display = "none";
1393
- const c = document.createElement("div");
1394
- c.className = "drawio-view-hint", s.append(o, c), i.append(s);
1395
- const l = (w) => {
1396
- const T = typeof n == "function" ? n() : null;
1397
- typeof T == "number" && e.commands.command(({ tr: v, dispatch: E }) => (v.setNodeMarkup(T, void 0, { ...r.attrs, ...w }), E && E(v), !0));
1391
+ const c = document.createElement("img");
1392
+ c.className = "drawio-preview-img", c.style.display = "none";
1393
+ const l = document.createElement("div");
1394
+ l.className = "drawio-view-hint", s.append(c, l), i.append(s);
1395
+ const o = (T) => {
1396
+ const v = typeof n == "function" ? n() : null;
1397
+ typeof v == "number" && e.commands.command(({ tr: x, dispatch: S }) => (x.setNodeMarkup(v, void 0, { ...r.attrs, ...T }), S && S(x), !0));
1398
1398
  };
1399
1399
  let d = null, u = null, m = null;
1400
1400
  const f = () => {
1401
1401
  if (a) return;
1402
1402
  a = !0, u = document.createElement("div"), u.className = "drawio-modal-overlay";
1403
- const w = document.createElement("div");
1404
- w.className = "drawio-modal-content";
1405
1403
  const T = document.createElement("div");
1406
- T.className = "drawio-modal-header";
1407
- const v = N.getState().editorLanguage, E = document.createElement("span");
1408
- E.textContent = v === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", E.className = "drawio-modal-title";
1409
- const _ = document.createElement("button");
1410
- _.className = "drawio-modal-close-btn", _.textContent = "", _.type = "button", _.addEventListener("click", () => p()), T.append(E, _), m = document.createElement("iframe"), m.className = "drawio-modal-iframe", m.setAttribute("frameborder", "0"), w.append(T, m), u.appendChild(w), document.body.appendChild(u);
1411
- const b = v === "en" ? "en" : "zh";
1412
- m.src = `${Ve}/?embed=1&proto=json&spin=1&lang=${b}`;
1404
+ T.className = "drawio-modal-content";
1405
+ const v = document.createElement("div");
1406
+ v.className = "drawio-modal-header";
1407
+ const x = I.getState().editorLanguage, S = document.createElement("span");
1408
+ S.textContent = x === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", S.className = "drawio-modal-title";
1409
+ const N = document.createElement("button");
1410
+ N.className = "drawio-modal-close-btn", N.textContent = "✕", N.type = "button", N.addEventListener("click", () => p()), v.append(S, N), m = document.createElement("iframe"), m.className = "drawio-modal-iframe", m.setAttribute("frameborder", "0"), T.append(v, m), u.appendChild(T), document.body.appendChild(u);
1411
+ const h = x === "en" ? "en" : "zh";
1412
+ m.src = `${Ve}/?embed=1&proto=json&spin=1&lang=${h}`;
1413
1413
  const C = m;
1414
- d = (I) => {
1414
+ d = (_) => {
1415
1415
  var D, z;
1416
- if (!C || I.source !== C.contentWindow) return;
1416
+ if (!C || _.source !== C.contentWindow) return;
1417
1417
  let A;
1418
1418
  try {
1419
- A = typeof I.data == "string" ? JSON.parse(I.data) : I.data;
1419
+ A = typeof _.data == "string" ? JSON.parse(_.data) : _.data;
1420
1420
  } catch {
1421
1421
  return;
1422
1422
  }
@@ -1431,32 +1431,32 @@ const Ie = () => {
1431
1431
  (z = C.contentWindow) == null || z.postMessage(
1432
1432
  JSON.stringify({ action: "export", format: "svg" }),
1433
1433
  Ve
1434
- ), l({ xml: Q });
1434
+ ), o({ xml: Q });
1435
1435
  } else if (A.event === "export") {
1436
1436
  const Q = A.data || "";
1437
- l({ svg: Q }), p();
1437
+ o({ svg: Q }), p();
1438
1438
  } else A.event === "exit" && p();
1439
1439
  }, window.addEventListener("message", d);
1440
1440
  }, p = () => {
1441
- a = !1, d && (window.removeEventListener("message", d), d = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null), h();
1441
+ a = !1, d && (window.removeEventListener("message", d), d = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null), b();
1442
1442
  };
1443
- s.addEventListener("dblclick", (w) => {
1444
- w.preventDefault(), w.stopPropagation(), f();
1443
+ s.addEventListener("dblclick", (T) => {
1444
+ T.preventDefault(), T.stopPropagation(), f();
1445
1445
  });
1446
- const h = () => {
1447
- const w = N.getState().editorLanguage, T = H(w), v = typeof r.attrs.svg == "string" ? r.attrs.svg : "";
1448
- v ? (o.src = v, o.style.display = "block") : (o.src = "", o.style.display = "none"), v ? (c.textContent = T.mermaidDoubleClickToEdit || "双击编辑", c.className = "drawio-view-hint drawio-view-hint--subtle") : (c.textContent = T.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", c.className = "drawio-view-hint drawio-view-hint--empty");
1446
+ const b = () => {
1447
+ const T = I.getState().editorLanguage, v = H(T), x = typeof r.attrs.svg == "string" ? r.attrs.svg : "";
1448
+ x ? (c.src = x, c.style.display = "block") : (c.src = "", c.style.display = "none"), x ? (l.textContent = v.mermaidDoubleClickToEdit || "双击编辑", l.className = "drawio-view-hint drawio-view-hint--subtle") : (l.textContent = v.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", l.className = "drawio-view-hint drawio-view-hint--empty");
1449
1449
  };
1450
- let y = N.getState().editorLanguage;
1451
- const x = N.subscribe((w) => {
1452
- w.editorLanguage !== y && (y = w.editorLanguage, h());
1450
+ let y = I.getState().editorLanguage;
1451
+ const w = I.subscribe((T) => {
1452
+ T.editorLanguage !== y && (y = T.editorLanguage, b());
1453
1453
  });
1454
- return h(), {
1454
+ return b(), {
1455
1455
  dom: i,
1456
1456
  ignoreMutation: () => !0,
1457
- update: (w) => w.type.name !== "drawio" ? !1 : (r = w, h(), !0),
1457
+ update: (T) => T.type.name !== "drawio" ? !1 : (r = T, b(), !0),
1458
1458
  destroy: () => {
1459
- x(), d && (window.removeEventListener("message", d), d = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null);
1459
+ w(), d && (window.removeEventListener("message", d), d = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null);
1460
1460
  }
1461
1461
  };
1462
1462
  };
@@ -1495,47 +1495,47 @@ const Ie = () => {
1495
1495
  selected: n,
1496
1496
  editor: r
1497
1497
  }) => {
1498
- const a = W(null), [i, s] = F(!1), o = e.type.name === "math_block", c = W(!1), l = W(t), d = W(e.attrs.latex ?? "");
1498
+ const a = W(null), [i, s] = F(!1), c = e.type.name === "math_block", l = W(!1), o = W(t), d = W(e.attrs.latex ?? "");
1499
1499
  M(() => {
1500
- l.current = t;
1500
+ o.current = t;
1501
1501
  }, [t]), M(() => {
1502
1502
  d.current = e.attrs.latex ?? "";
1503
1503
  }, [e.attrs.latex]);
1504
1504
  const u = ae(() => {
1505
- c.current || (c.current = !0, s(!0));
1505
+ l.current || (l.current = !0, s(!0));
1506
1506
  }, []), m = ae(() => {
1507
- var h, y;
1508
- if (!c.current) return;
1509
- c.current = !1;
1510
- const p = ((h = a.current) == null ? void 0 : h.value) ?? d.current;
1511
- l.current({ latex: p }), s(!1), (y = globalThis.mathVirtualKeyboard) == null || y.hide({ animate: !0 });
1507
+ var b, y;
1508
+ if (!l.current) return;
1509
+ l.current = !1;
1510
+ const p = ((b = a.current) == null ? void 0 : b.value) ?? d.current;
1511
+ o.current({ latex: p }), s(!1), (y = globalThis.mathVirtualKeyboard) == null || y.hide({ animate: !0 });
1512
1512
  }, []);
1513
1513
  M(() => {
1514
- var h, y, x;
1515
- const p = !!((x = (y = (h = r == null ? void 0 : r.view) == null ? void 0 : h.state) == null ? void 0 : y.selection) != null && x.empty);
1514
+ var b, y, w;
1515
+ const p = !!((w = (y = (b = r == null ? void 0 : r.view) == null ? void 0 : b.state) == null ? void 0 : y.selection) != null && w.empty);
1516
1516
  n && p && u();
1517
1517
  }, [n, u]), M(() => {
1518
1518
  i && requestAnimationFrame(() => {
1519
- var h;
1519
+ var b;
1520
1520
  const p = a.current;
1521
- p && (p.virtualKeyboardMode = "onfocus", (h = p.focus) == null || h.call(p));
1521
+ p && (p.virtualKeyboardMode = "onfocus", (b = p.focus) == null || b.call(p));
1522
1522
  });
1523
1523
  }, [i]), M(() => {
1524
1524
  if (!i) return;
1525
1525
  const p = a.current;
1526
1526
  if (!p) return;
1527
- const h = () => {
1527
+ const b = () => {
1528
1528
  setTimeout(() => {
1529
- var w, T, v;
1530
- if (!c.current) return;
1531
- const x = document.activeElement;
1532
- (x == null ? void 0 : x.tagName) === "MATH-FIELD" || (w = x == null ? void 0 : x.closest) != null && w.call(x, "math-field") || (T = x == null ? void 0 : x.closest) != null && T.call(x, ".ML__keyboard") || (v = document.querySelector(".ML__keyboard")) != null && v.contains(x) || m();
1529
+ var T, v, x;
1530
+ if (!l.current) return;
1531
+ const w = document.activeElement;
1532
+ (w == null ? void 0 : w.tagName) === "MATH-FIELD" || (T = w == null ? void 0 : w.closest) != null && T.call(w, "math-field") || (v = w == null ? void 0 : w.closest) != null && v.call(w, ".ML__keyboard") || (x = document.querySelector(".ML__keyboard")) != null && x.contains(w) || m();
1533
1533
  }, 300);
1534
- }, y = (x) => {
1535
- x.key === "Escape" && m();
1534
+ }, y = (w) => {
1535
+ w.key === "Escape" && m();
1536
1536
  };
1537
- return p.addEventListener("focusout", h), p.addEventListener("keydown", y), () => {
1538
- p.removeEventListener("focusout", h), p.removeEventListener("keydown", y);
1537
+ return p.addEventListener("focusout", b), p.addEventListener("keydown", y), () => {
1538
+ p.removeEventListener("focusout", b), p.removeEventListener("keydown", y);
1539
1539
  };
1540
1540
  }, [i, m]), M(() => {
1541
1541
  !i && a.current && a.current.value !== e.attrs.latex && (a.current.value = e.attrs.latex ?? "");
@@ -1544,7 +1544,7 @@ const Ie = () => {
1544
1544
  try {
1545
1545
  f = gr.renderToString(e.attrs.latex || "", {
1546
1546
  throwOnError: !1,
1547
- displayMode: o
1547
+ displayMode: c
1548
1548
  });
1549
1549
  } catch {
1550
1550
  f = e.attrs.latex || "";
@@ -1552,13 +1552,13 @@ const Ie = () => {
1552
1552
  return /* @__PURE__ */ g(
1553
1553
  _n,
1554
1554
  {
1555
- as: o ? "div" : "span",
1556
- className: o ? "math-block" : "math-inline",
1555
+ as: c ? "div" : "span",
1556
+ className: c ? "math-block" : "math-inline",
1557
1557
  children: i ? /* @__PURE__ */ g(
1558
1558
  "math-field",
1559
1559
  {
1560
1560
  ref: a,
1561
- className: o ? "math-live-field math-live-field--block" : "math-live-field",
1561
+ className: c ? "math-live-field math-live-field--block" : "math-live-field",
1562
1562
  children: e.attrs.latex
1563
1563
  }
1564
1564
  ) : /* @__PURE__ */ L("span", { className: "math-preview", onClick: u, children: [
@@ -1674,10 +1674,10 @@ const Ie = () => {
1674
1674
  }, st = (e, t, n = {}) => {
1675
1675
  const r = n.from ?? 0, a = n.to ?? e.state.doc.content.size;
1676
1676
  let i = null;
1677
- return e.state.doc.nodesBetween(r, a, (s, o) => i ? !1 : s.type.name === t ? (i = { node: s, pos: o }, !1) : !0), i;
1677
+ return e.state.doc.nodesBetween(r, a, (s, c) => i ? !1 : s.type.name === t ? (i = { node: s, pos: c }, !1) : !0), i;
1678
1678
  }, Xt = (e, t, n = {}) => {
1679
1679
  const r = n.from ?? 0, a = n.to ?? e.state.doc.content.size, i = [];
1680
- return e.state.doc.nodesBetween(r, a, (s, o) => (t(s, o) && i.push({ node: s, pos: o }), !0)), i;
1680
+ return e.state.doc.nodesBetween(r, a, (s, c) => (t(s, c) && i.push({ node: s, pos: c }), !0)), i;
1681
1681
  }, Re = (e, t) => {
1682
1682
  const { $from: n } = e.state.selection;
1683
1683
  for (let r = n.depth; r >= 0; r -= 1) {
@@ -1711,18 +1711,18 @@ const Ie = () => {
1711
1711
  const n = Na(t);
1712
1712
  return typeof t.position == "number" ? e.chain().focus().insertContentAt(t.position, n).run() : e.chain().focus().insertContent(n).run();
1713
1713
  }, ze = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
1714
- var c;
1715
- const i = typeof t.position == "number" ? t.position : (c = st(e, t.type || "")) == null ? void 0 : c.pos;
1714
+ var l;
1715
+ const i = typeof t.position == "number" ? t.position : (l = st(e, t.type || "")) == null ? void 0 : l.pos;
1716
1716
  if (typeof i != "number")
1717
1717
  return !1;
1718
1718
  const s = r.doc.nodeAt(i);
1719
1719
  if (!s || t.type && s.type.name !== t.type)
1720
1720
  return !1;
1721
- const o = { ...s.attrs, ...t.attrs };
1722
- return n.setNodeMarkup(i, void 0, o), a && a(n), !0;
1721
+ const c = { ...s.attrs, ...t.attrs };
1722
+ return n.setNodeMarkup(i, void 0, c), a && a(n), !0;
1723
1723
  }), Zt = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
1724
- var o;
1725
- const i = typeof t.position == "number" ? t.position : (o = st(e, t.type || "")) == null ? void 0 : o.pos;
1724
+ var c;
1725
+ const i = typeof t.position == "number" ? t.position : (c = st(e, t.type || "")) == null ? void 0 : c.pos;
1726
1726
  if (typeof i != "number")
1727
1727
  return !1;
1728
1728
  const s = r.doc.nodeAt(i);
@@ -1730,11 +1730,11 @@ const Ie = () => {
1730
1730
  }), Qt = (e, t) => {
1731
1731
  const n = Ia(e, t.type);
1732
1732
  return n ? e.commands.command(({ tr: r, state: a, dispatch: i }) => {
1733
- const { from: s, to: o } = a.selection, c = a.selection.$from.blockRange(a.selection.$to);
1734
- if (!c)
1733
+ const { from: s, to: c } = a.selection, l = a.selection.$from.blockRange(a.selection.$to);
1734
+ if (!l)
1735
1735
  return !1;
1736
- const l = fr(c, n, t.attrs);
1737
- return l ? (r.wrap(c, l), i && i(r.scrollIntoView()), s <= o) : !1;
1736
+ const o = fr(l, n, t.attrs);
1737
+ return o ? (r.wrap(l, o), i && i(r.scrollIntoView()), s <= c) : !1;
1738
1738
  }) : !1;
1739
1739
  }, Aa = (e, t) => {
1740
1740
  if (t.length === 0)
@@ -1783,19 +1783,19 @@ function tt() {
1783
1783
  };
1784
1784
  ne = (s) => {
1785
1785
  if (!$ || s.source !== $.contentWindow) return;
1786
- let o;
1786
+ let c;
1787
1787
  try {
1788
- o = typeof s.data == "string" ? JSON.parse(s.data) : s.data;
1788
+ c = typeof s.data == "string" ? JSON.parse(s.data) : s.data;
1789
1789
  } catch {
1790
1790
  return;
1791
1791
  }
1792
- o.event === "init" ? (Me = !0, i()) : o.event === "load" ? setTimeout(() => {
1793
- var c;
1794
- (c = $ == null ? void 0 : $.contentWindow) == null || c.postMessage(
1792
+ c.event === "init" ? (Me = !0, i()) : c.event === "load" ? setTimeout(() => {
1793
+ var l;
1794
+ (l = $ == null ? void 0 : $.contentWindow) == null || l.postMessage(
1795
1795
  JSON.stringify({ action: "export", format: "svg" }),
1796
1796
  de
1797
1797
  );
1798
- }, 1500) : o.event === "export" && a(o.data || "");
1798
+ }, 1500) : c.event === "export" && a(c.data || "");
1799
1799
  }, window.addEventListener("message", ne), r = setTimeout(() => a(""), La), $ ? Me && i() : ($ = document.createElement("iframe"), $.style.cssText = "position:fixed;left:-9999px;top:-9999px;width:1920px;height:1080px;opacity:0;pointer-events:none;", document.body.appendChild($), Me = !1, $.src = `${de}/?embed=1&proto=json&spin=0&chrome=0`);
1800
1800
  }
1801
1801
  const Le = () => {
@@ -1833,78 +1833,78 @@ const Le = () => {
1833
1833
  let r = t, a = !1, i = !1;
1834
1834
  const s = document.createElement("figure");
1835
1835
  s.setAttribute("data-type", "figure"), s.className = "figure-block";
1836
+ const c = document.createElement("div");
1837
+ c.className = "figure-visual", c.contentEditable = "false", c.setAttribute("spellcheck", "false");
1838
+ const l = document.createElement("img");
1839
+ l.className = "figure-img-preview";
1836
1840
  const o = document.createElement("div");
1837
- o.className = "figure-visual", o.contentEditable = "false", o.setAttribute("spellcheck", "false");
1838
- const c = document.createElement("img");
1839
- c.className = "figure-img-preview";
1840
- const l = document.createElement("div");
1841
- l.className = "figure-upload-area";
1841
+ o.className = "figure-upload-area";
1842
1842
  const d = document.createElement("span");
1843
1843
  d.className = "figure-upload-hint";
1844
1844
  const u = document.createElement("input");
1845
1845
  u.type = "file", u.accept = "image/*", u.style.display = "none";
1846
1846
  const m = document.createElement("button");
1847
- m.className = "figure-replace-btn", l.append(d, u);
1847
+ m.className = "figure-replace-btn", o.append(d, u);
1848
1848
  const f = document.createElement("div");
1849
1849
  f.className = "figure-mermaid-view", f.contentEditable = "false", f.setAttribute("spellcheck", "false");
1850
1850
  const p = document.createElement("div");
1851
1851
  p.className = "figure-mermaid-preview", p.contentEditable = "false";
1852
- const h = document.createElement("div");
1853
- h.className = "figure-mermaid-view-hint", f.append(p, h);
1852
+ const b = document.createElement("div");
1853
+ b.className = "figure-mermaid-view-hint", f.append(p, b);
1854
1854
  const y = document.createElement("div");
1855
1855
  y.className = "figure-mermaid-edit";
1856
- const x = document.createElement("textarea");
1857
- x.className = "figure-mermaid-editor", x.spellcheck = !1;
1858
- const w = document.createElement("div");
1859
- w.className = "figure-mermaid-toolbar";
1860
- const T = document.createElement("button");
1861
- T.className = "figure-mermaid-save-btn", T.type = "button";
1856
+ const w = document.createElement("textarea");
1857
+ w.className = "figure-mermaid-editor", w.spellcheck = !1;
1858
+ const T = document.createElement("div");
1859
+ T.className = "figure-mermaid-toolbar";
1862
1860
  const v = document.createElement("button");
1863
- v.className = "figure-mermaid-cancel-btn", v.type = "button";
1864
- const E = document.createElement("span");
1865
- E.className = "figure-mermaid-error-inline", w.append(E, v, T), y.append(x, w);
1866
- const _ = document.createElement("div");
1867
- _.className = "figure-drawio-view", _.contentEditable = "false";
1868
- const b = document.createElement("img");
1869
- b.className = "figure-drawio-preview-img", b.style.display = "none";
1861
+ v.className = "figure-mermaid-save-btn", v.type = "button";
1862
+ const x = document.createElement("button");
1863
+ x.className = "figure-mermaid-cancel-btn", x.type = "button";
1864
+ const S = document.createElement("span");
1865
+ S.className = "figure-mermaid-error-inline", T.append(S, x, v), y.append(w, T);
1866
+ const N = document.createElement("div");
1867
+ N.className = "figure-drawio-view", N.contentEditable = "false";
1868
+ const h = document.createElement("img");
1869
+ h.className = "figure-drawio-preview-img", h.style.display = "none";
1870
1870
  const C = document.createElement("div");
1871
- C.className = "figure-drawio-view-hint", _.append(b, C), o.append(c, l, m), o.append(f, y), o.append(_);
1872
- const I = document.createElement("figcaption");
1873
- I.className = "figure-caption";
1871
+ C.className = "figure-drawio-view-hint", N.append(h, C), c.append(l, o, m), c.append(f, y), c.append(N);
1872
+ const _ = document.createElement("figcaption");
1873
+ _.className = "figure-caption";
1874
1874
  const A = document.createElement("span");
1875
1875
  A.className = "figure-id-label", A.contentEditable = "false";
1876
1876
  const D = document.createElement("span");
1877
- D.className = "figure-caption-content", I.append(A, D), s.append(o, I);
1878
- const z = (S) => {
1877
+ D.className = "figure-caption-content", _.append(A, D), s.append(c, _);
1878
+ const z = (E) => {
1879
1879
  const k = typeof n == "function" ? n() : null;
1880
- typeof k == "number" && e.commands.command(({ tr: P, dispatch: O }) => (P.setNodeMarkup(k, void 0, { ...r.attrs, ...S }), O && O(P), !0));
1881
- }, Q = (S) => {
1882
- if (!S || S.length === 0) return;
1883
- const k = S[0];
1880
+ typeof k == "number" && e.commands.command(({ tr: P, dispatch: O }) => (P.setNodeMarkup(k, void 0, { ...r.attrs, ...E }), O && O(P), !0));
1881
+ }, Q = (E) => {
1882
+ if (!E || E.length === 0) return;
1883
+ const k = E[0];
1884
1884
  if (!k.type.startsWith("image/")) return;
1885
1885
  const P = new FileReader();
1886
1886
  P.onload = () => {
1887
1887
  typeof P.result == "string" && z({ imageSrc: P.result });
1888
1888
  }, P.readAsDataURL(k);
1889
1889
  };
1890
- u.addEventListener("change", () => Q(u.files)), l.addEventListener("click", () => u.click()), m.addEventListener("click", (S) => {
1891
- S.stopPropagation(), u.click();
1892
- }), o.addEventListener("dragover", (S) => {
1893
- r.attrs.contentType === "image" && (S.preventDefault(), S.stopPropagation(), l.classList.add("figure-upload-area--dragover"));
1894
- }), o.addEventListener("dragleave", () => {
1895
- l.classList.remove("figure-upload-area--dragover");
1896
- }), o.addEventListener("drop", (S) => {
1890
+ u.addEventListener("change", () => Q(u.files)), o.addEventListener("click", () => u.click()), m.addEventListener("click", (E) => {
1891
+ E.stopPropagation(), u.click();
1892
+ }), c.addEventListener("dragover", (E) => {
1893
+ r.attrs.contentType === "image" && (E.preventDefault(), E.stopPropagation(), o.classList.add("figure-upload-area--dragover"));
1894
+ }), c.addEventListener("dragleave", () => {
1895
+ o.classList.remove("figure-upload-area--dragover");
1896
+ }), c.addEventListener("drop", (E) => {
1897
1897
  var k;
1898
- l.classList.remove("figure-upload-area--dragover"), r.attrs.contentType === "image" && (S.preventDefault(), S.stopPropagation(), Q(((k = S.dataTransfer) == null ? void 0 : k.files) ?? null));
1898
+ o.classList.remove("figure-upload-area--dragover"), r.attrs.contentType === "image" && (E.preventDefault(), E.stopPropagation(), Q(((k = E.dataTransfer) == null ? void 0 : k.files) ?? null));
1899
1899
  });
1900
1900
  const gn = () => {
1901
- a || (a = !0, x.value = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "", E.textContent = "", E.style.display = "none", J(), requestAnimationFrame(() => x.focus()));
1901
+ a || (a = !0, w.value = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "", S.textContent = "", S.style.display = "none", J(), requestAnimationFrame(() => w.focus()));
1902
1902
  }, fn = () => {
1903
1903
  a = !1, J();
1904
1904
  }, pn = async () => {
1905
- const S = x.value;
1906
- E.textContent = "", E.style.display = "none";
1907
- const k = S.trim();
1905
+ const E = w.value;
1906
+ S.textContent = "", S.style.display = "none";
1907
+ const k = E.trim();
1908
1908
  if (k)
1909
1909
  try {
1910
1910
  const P = await import("mermaid");
@@ -1913,31 +1913,31 @@ const Le = () => {
1913
1913
  p.innerHTML = R, Le();
1914
1914
  } catch {
1915
1915
  Le();
1916
- const P = N.getState().editorLanguage;
1917
- E.textContent = P === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", E.style.display = "inline";
1916
+ const P = I.getState().editorLanguage;
1917
+ S.textContent = P === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", S.style.display = "inline";
1918
1918
  return;
1919
1919
  }
1920
- z({ mermaidCode: S }), a = !1, J();
1920
+ z({ mermaidCode: E }), a = !1, J();
1921
1921
  };
1922
- f.addEventListener("dblclick", (S) => {
1923
- S.preventDefault(), S.stopPropagation(), gn();
1924
- }), T.addEventListener("click", (S) => {
1925
- S.stopPropagation(), pn();
1926
- }), v.addEventListener("click", (S) => {
1927
- S.stopPropagation(), fn();
1928
- }), x.addEventListener("mousedown", (S) => S.stopPropagation()), x.addEventListener("keydown", (S) => S.stopPropagation()), x.addEventListener("keypress", (S) => S.stopPropagation());
1922
+ f.addEventListener("dblclick", (E) => {
1923
+ E.preventDefault(), E.stopPropagation(), gn();
1924
+ }), v.addEventListener("click", (E) => {
1925
+ E.stopPropagation(), pn();
1926
+ }), x.addEventListener("click", (E) => {
1927
+ E.stopPropagation(), fn();
1928
+ }), w.addEventListener("mousedown", (E) => E.stopPropagation()), w.addEventListener("keydown", (E) => E.stopPropagation()), w.addEventListener("keypress", (E) => E.stopPropagation());
1929
1929
  let ee = null, G = null, U = null;
1930
1930
  const hn = () => {
1931
1931
  if (i) return;
1932
1932
  i = !0, J(), G = document.createElement("div"), G.className = "drawio-modal-overlay";
1933
- const S = document.createElement("div");
1934
- S.className = "drawio-modal-content";
1933
+ const E = document.createElement("div");
1934
+ E.className = "drawio-modal-content";
1935
1935
  const k = document.createElement("div");
1936
1936
  k.className = "drawio-modal-header";
1937
- const P = document.createElement("span"), O = N.getState().editorLanguage;
1937
+ const P = document.createElement("span"), O = I.getState().editorLanguage;
1938
1938
  P.textContent = O === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", P.className = "drawio-modal-title";
1939
1939
  const R = document.createElement("button");
1940
- R.className = "drawio-modal-close-btn", R.textContent = "✕", R.type = "button", R.addEventListener("click", () => We()), k.append(P, R), U = document.createElement("iframe"), U.className = "drawio-modal-iframe", U.setAttribute("frameborder", "0"), S.append(k, U), G.appendChild(S), document.body.appendChild(G);
1940
+ R.className = "drawio-modal-close-btn", R.textContent = "✕", R.type = "button", R.addEventListener("click", () => We()), k.append(P, R), U = document.createElement("iframe"), U.className = "drawio-modal-iframe", U.setAttribute("frameborder", "0"), E.append(k, U), G.appendChild(E), document.body.appendChild(G);
1941
1941
  const fe = O === "en" ? "en" : "zh";
1942
1942
  U.src = `${de}/?embed=1&proto=json&spin=1&lang=${fe}`;
1943
1943
  const K = U;
@@ -1970,11 +1970,11 @@ const Le = () => {
1970
1970
  }, We = () => {
1971
1971
  i = !1, ee && (window.removeEventListener("message", ee), ee = null), U && (U.src = "about:blank", U = null), G && (G.remove(), G = null), J();
1972
1972
  };
1973
- _.addEventListener("dblclick", (S) => {
1974
- S.preventDefault(), S.stopPropagation(), hn();
1975
- }), s.addEventListener("mousedown", (S) => {
1976
- const k = S.target;
1977
- if (!(k instanceof HTMLElement) || k === D || D.contains(k) || k === x || y.contains(k) || k === l || l.contains(k) || k === m || k === u || f.contains(k) || _.contains(k)) return;
1973
+ N.addEventListener("dblclick", (E) => {
1974
+ E.preventDefault(), E.stopPropagation(), hn();
1975
+ }), s.addEventListener("mousedown", (E) => {
1976
+ const k = E.target;
1977
+ if (!(k instanceof HTMLElement) || k === D || D.contains(k) || k === w || y.contains(k) || k === o || o.contains(k) || k === m || k === u || f.contains(k) || N.contains(k)) return;
1978
1978
  const P = typeof n == "function" ? n() : null;
1979
1979
  if (typeof P != "number") return;
1980
1980
  const O = P + r.nodeSize - 1, R = Zn.create(e.state.doc, O);
@@ -1983,8 +1983,8 @@ const Le = () => {
1983
1983
  let xe = !1, se = null, me = null, Ce = 0;
1984
1984
  const yn = 2, bn = 1500, vn = 3e3;
1985
1985
  let ge = "";
1986
- const wn = async (S) => {
1987
- const k = S.trim();
1986
+ const wn = async (E) => {
1987
+ const k = E.trim();
1988
1988
  if (k !== ge) {
1989
1989
  if (!k) {
1990
1990
  p.innerHTML = "", ge = "";
@@ -2002,14 +2002,14 @@ const Le = () => {
2002
2002
  }
2003
2003
  }
2004
2004
  }, J = () => {
2005
- const S = N.getState().editorLanguage, k = H(S), P = ["image", "mermaid", "drawio"].includes(r.attrs.contentType) ? r.attrs.contentType : "image", O = typeof r.attrs.id == "string" ? r.attrs.id.trim() : "", R = typeof r.attrs.imageSrc == "string" ? r.attrs.imageSrc : "", fe = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "";
2005
+ const E = I.getState().editorLanguage, k = H(E), P = ["image", "mermaid", "drawio"].includes(r.attrs.contentType) ? r.attrs.contentType : "image", O = typeof r.attrs.id == "string" ? r.attrs.id.trim() : "", R = typeof r.attrs.imageSrc == "string" ? r.attrs.imageSrc : "", fe = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "";
2006
2006
  O ? (A.textContent = `[${O}] `, A.style.display = "inline") : (A.textContent = "", A.style.display = "none");
2007
2007
  const K = P === "image", X = P === "mermaid", q = P === "drawio";
2008
- c.style.display = K && R ? "block" : "none", l.style.display = K && !R ? "flex" : "none", m.style.display = K && R ? "block" : "none", f.style.display = X && !a ? "block" : "none", y.style.display = X && a ? "block" : "none", _.style.display = q ? "flex" : "none", K && R && (c.src = R);
2008
+ l.style.display = K && R ? "block" : "none", o.style.display = K && !R ? "flex" : "none", m.style.display = K && R ? "block" : "none", f.style.display = X && !a ? "block" : "none", y.style.display = X && a ? "block" : "none", N.style.display = q ? "flex" : "none", K && R && (l.src = R);
2009
2009
  const oe = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
2010
- q && (oe ? (b.src = oe, b.style.display = "block") : (b.src = "", b.style.display = "none")), d.textContent = k.figureUploadHint || "点击上传或拖拽图片", m.textContent = k.figureReplaceImage || "更换图片", T.textContent = k.mermaidSaveAndRender || "保存并渲染", v.textContent = k.mermaidCancel || "取消";
2010
+ q && (oe ? (h.src = oe, h.style.display = "block") : (h.src = "", h.style.display = "none")), d.textContent = k.figureUploadHint || "点击上传或拖拽图片", m.textContent = k.figureReplaceImage || "更换图片", v.textContent = k.mermaidSaveAndRender || "保存并渲染", x.textContent = k.mermaidCancel || "取消";
2011
2011
  const Te = fe.trim().length > 0, ce = p.querySelector("svg") !== null;
2012
- X && !a && (Te && ce ? (h.textContent = k.mermaidDoubleClickToEdit || "双击编辑", h.className = "figure-mermaid-view-hint figure-mermaid-view-hint--subtle") : (h.textContent = k.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", h.className = "figure-mermaid-view-hint figure-mermaid-view-hint--empty")), q && !i && (oe ? (C.textContent = k.mermaidDoubleClickToEdit || "双击编辑", C.className = "figure-drawio-view-hint figure-mermaid-view-hint--subtle") : (C.textContent = k.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", C.className = "figure-drawio-view-hint figure-mermaid-view-hint--empty")), X && !a && fe.trim() !== ge && wn(fe);
2012
+ X && !a && (Te && ce ? (b.textContent = k.mermaidDoubleClickToEdit || "双击编辑", b.className = "figure-mermaid-view-hint figure-mermaid-view-hint--subtle") : (b.textContent = k.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", b.className = "figure-mermaid-view-hint figure-mermaid-view-hint--empty")), q && !i && (oe ? (C.textContent = k.mermaidDoubleClickToEdit || "双击编辑", C.className = "figure-drawio-view-hint figure-mermaid-view-hint--subtle") : (C.textContent = k.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", C.className = "figure-drawio-view-hint figure-mermaid-view-hint--empty")), X && !a && fe.trim() !== ge && wn(fe);
2013
2013
  const Cn = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "";
2014
2014
  q && Cn && !oe && !xe && !i && (se && clearTimeout(se), se = setTimeout(() => {
2015
2015
  se = null;
@@ -2021,22 +2021,22 @@ const Le = () => {
2021
2021
  }));
2022
2022
  }, bn));
2023
2023
  };
2024
- let lt = N.getState().editorLanguage;
2025
- const xn = N.subscribe((S) => {
2026
- S.editorLanguage !== lt && (lt = S.editorLanguage, J());
2024
+ let lt = I.getState().editorLanguage;
2025
+ const xn = I.subscribe((E) => {
2026
+ E.editorLanguage !== lt && (lt = E.editorLanguage, J());
2027
2027
  });
2028
2028
  return J(), {
2029
2029
  dom: s,
2030
2030
  contentDOM: D,
2031
- stopEvent: (S) => {
2032
- const k = S.target;
2033
- return !!(k === x || y.contains(k) || k === u);
2031
+ stopEvent: (E) => {
2032
+ const k = E.target;
2033
+ return !!(k === w || y.contains(k) || k === u);
2034
2034
  },
2035
- ignoreMutation: (S) => {
2036
- const k = S.target;
2037
- return !!(o.contains(k) || A.contains(k));
2035
+ ignoreMutation: (E) => {
2036
+ const k = E.target;
2037
+ return !!(c.contains(k) || A.contains(k));
2038
2038
  },
2039
- update: (S) => S.type.name !== "figure" ? !1 : (r = S, J(), !0),
2039
+ update: (E) => E.type.name !== "figure" ? !1 : (r = E, J(), !0),
2040
2040
  destroy: () => {
2041
2041
  se && (clearTimeout(se), se = null), me && (clearTimeout(me), me = null), xn(), Le(), ee && (window.removeEventListener("message", ee), ee = null), U && (U.src = "about:blank", U = null), G && (G.remove(), G = null);
2042
2042
  }
@@ -2104,22 +2104,22 @@ const Le = () => {
2104
2104
  return ({ node: e, editor: t }) => {
2105
2105
  let n = e;
2106
2106
  const r = document.createElement("span"), a = () => {
2107
- const i = n.attrs.lang === "en" ? "en" : "zh", s = H(i), o = n.attrs.targetType === "figure" ? "figure" : "claim", c = Number(n.attrs.resolvedNumber), l = typeof n.attrs.resolvedFigureId == "string" && n.attrs.resolvedFigureId ? n.attrs.resolvedFigureId : null, d = o === "figure" ? l || (i === "en" ? "Figure ?" : "附图?") : Number.isFinite(c) ? s.claimLabel(c) : i === "en" ? "Claim ?" : "权利要求?", u = n.attrs.displayText || d;
2108
- r.textContent = u, r.className = `reference-link${n.attrs.invalid ? " reference-link-invalid" : ""}`, r.setAttribute("data-type", "reference"), r.setAttribute("data-highlight", n.attrs.highlight ? "true" : "false"), r.title = n.attrs.invalid ? s.referenceNavigateDisabledTitle : o === "figure" ? s.figureReferenceNavigateTitle : s.referenceNavigateTitle;
2107
+ const i = n.attrs.lang === "en" ? "en" : "zh", s = H(i), c = n.attrs.targetType === "figure" ? "figure" : "claim", l = Number(n.attrs.resolvedNumber), o = typeof n.attrs.resolvedFigureId == "string" && n.attrs.resolvedFigureId ? n.attrs.resolvedFigureId : null, d = c === "figure" ? o || (i === "en" ? "Figure ?" : "附图?") : Number.isFinite(l) ? s.claimLabel(l) : i === "en" ? "Claim ?" : "权利要求?", u = n.attrs.displayText || d;
2108
+ r.textContent = u, r.className = `reference-link${n.attrs.invalid ? " reference-link-invalid" : ""}`, r.setAttribute("data-type", "reference"), r.setAttribute("data-highlight", n.attrs.highlight ? "true" : "false"), r.title = n.attrs.invalid ? s.referenceNavigateDisabledTitle : c === "figure" ? s.figureReferenceNavigateTitle : s.referenceNavigateTitle;
2109
2109
  };
2110
2110
  return a(), r.addEventListener("click", () => {
2111
2111
  const i = n.attrs.targetType === "figure" ? "figure" : "claim";
2112
2112
  n.attrs.invalid || setTimeout(() => {
2113
2113
  let s = null;
2114
2114
  if (i === "figure") {
2115
- const o = typeof n.attrs.targetFigureId == "string" ? n.attrs.targetFigureId : "";
2116
- if (!o)
2115
+ const c = typeof n.attrs.targetFigureId == "string" ? n.attrs.targetFigureId : "";
2116
+ if (!c)
2117
2117
  return;
2118
- t.state.doc.descendants((c, l) => s !== null ? !1 : c.type.name === "figure" && c.attrs.id === o ? (s = l, !1) : !0);
2118
+ t.state.doc.descendants((l, o) => s !== null ? !1 : l.type.name === "figure" && l.attrs.id === c ? (s = o, !1) : !0);
2119
2119
  } else {
2120
2120
  if (!n.attrs.targetClaimId)
2121
2121
  return;
2122
- t.state.doc.descendants((o, c) => s !== null ? !1 : o.type.name === "claim" && o.attrs.claimId === n.attrs.targetClaimId ? (s = c, !1) : !0);
2122
+ t.state.doc.descendants((c, l) => s !== null ? !1 : c.type.name === "claim" && c.attrs.claimId === n.attrs.targetClaimId ? (s = l, !1) : !0);
2123
2123
  }
2124
2124
  typeof s == "number" && t.chain().focus().setTextSelection(s + 1).scrollIntoView().run();
2125
2125
  }, 0);
@@ -2199,36 +2199,36 @@ const Le = () => {
2199
2199
  i.className = "pb-heading", i.contentEditable = "false";
2200
2200
  const s = document.createElement("div");
2201
2201
  s.className = "ps-placeholder", s.contentEditable = "false";
2202
- const o = document.createElement("h1");
2203
- o.className = "pt-title-content", a.append(i, s, o);
2204
- const c = () => {
2205
- const h = typeof n == "function" ? n() : null;
2206
- return typeof h == "number" ? h : null;
2207
- }, l = () => {
2208
- const h = c();
2209
- h !== null && N.getState().setActiveSection("patent_title", h);
2202
+ const c = document.createElement("h1");
2203
+ c.className = "pt-title-content", a.append(i, s, c);
2204
+ const l = () => {
2205
+ const b = typeof n == "function" ? n() : null;
2206
+ return typeof b == "number" ? b : null;
2207
+ }, o = () => {
2208
+ const b = l();
2209
+ b !== null && I.getState().setActiveSection("patent_title", b);
2210
2210
  }, d = () => {
2211
- const h = c();
2212
- h !== null && (N.getState().openDraftingPanel("patent_title", h), e.commands.focus(h + 1));
2211
+ const b = l();
2212
+ b !== null && (I.getState().openDraftingPanel("patent_title", b), e.commands.focus(b + 1));
2213
2213
  };
2214
- s.addEventListener("click", d), o.addEventListener("focusin", l), o.addEventListener("click", l);
2214
+ s.addEventListener("click", d), c.addEventListener("focusin", o), c.addEventListener("click", o);
2215
2215
  const u = () => {
2216
- const h = N.getState(), y = H(h.editorLanguage), x = typeof y.bookTitle_description == "string" ? y.bookTitle_description : "说明书", w = typeof y.patentTitlePlaceholder == "string" ? y.patentTitlePlaceholder : "专利名称";
2217
- i.textContent = x;
2218
- const T = ot(r), v = h.rightPanel.activeSectionPos === c();
2219
- s.textContent = `[${w}]`, s.style.display = T ? "none" : "", s.classList.toggle("ps-placeholder--active", v && !T), o.classList.toggle("pt-title-content--has-content", T);
2216
+ const b = I.getState(), y = H(b.editorLanguage), w = typeof y.bookTitle_description == "string" ? y.bookTitle_description : "说明书", T = typeof y.patentTitlePlaceholder == "string" ? y.patentTitlePlaceholder : "专利名称";
2217
+ i.textContent = w;
2218
+ const v = ot(r), x = b.rightPanel.activeSectionPos === l();
2219
+ s.textContent = `[${T}]`, s.style.display = v ? "none" : "", s.classList.toggle("ps-placeholder--active", x && !v), c.classList.toggle("pt-title-content--has-content", v);
2220
2220
  };
2221
- let m = N.getState().editorLanguage, f = N.getState().rightPanel.activeSectionPos;
2222
- const p = N.subscribe((h) => {
2223
- const y = h.editorLanguage !== m, x = h.rightPanel.activeSectionPos !== f;
2224
- m = h.editorLanguage, f = h.rightPanel.activeSectionPos, (y || x) && u();
2221
+ let m = I.getState().editorLanguage, f = I.getState().rightPanel.activeSectionPos;
2222
+ const p = I.subscribe((b) => {
2223
+ const y = b.editorLanguage !== m, w = b.rightPanel.activeSectionPos !== f;
2224
+ m = b.editorLanguage, f = b.rightPanel.activeSectionPos, (y || w) && u();
2225
2225
  });
2226
2226
  return u(), {
2227
2227
  dom: a,
2228
- contentDOM: o,
2229
- update: (h) => h.type.name !== "patent_title" ? !1 : (r = h, u(), !0),
2228
+ contentDOM: c,
2229
+ update: (b) => b.type.name !== "patent_title" ? !1 : (r = b, u(), !0),
2230
2230
  destroy: () => {
2231
- p(), s.removeEventListener("click", d), o.removeEventListener("focusin", l), o.removeEventListener("click", l);
2231
+ p(), s.removeEventListener("click", d), c.removeEventListener("focusin", o), c.removeEventListener("click", o);
2232
2232
  }
2233
2233
  };
2234
2234
  };
@@ -2300,38 +2300,38 @@ const Le = () => {
2300
2300
  i.contentEditable = "false";
2301
2301
  const s = document.createElement("div");
2302
2302
  s.className = "ps-body";
2303
- const o = document.createElement("div");
2304
- o.className = "ps-placeholder", o.contentEditable = "false";
2305
2303
  const c = document.createElement("div");
2306
- c.className = "ps-content", s.append(o, c), a.append(i, s);
2307
- const l = () => {
2304
+ c.className = "ps-placeholder", c.contentEditable = "false";
2305
+ const l = document.createElement("div");
2306
+ l.className = "ps-content", s.append(c, l), a.append(i, s);
2307
+ const o = () => {
2308
2308
  const y = typeof n == "function" ? n() : null;
2309
2309
  return typeof y == "number" ? y : null;
2310
2310
  }, d = () => {
2311
- const y = l();
2311
+ const y = o();
2312
2312
  if (y === null) return;
2313
- N.getState().setActiveSection(r.attrs.sectionType, y);
2313
+ I.getState().setActiveSection(r.attrs.sectionType, y);
2314
2314
  }, u = () => {
2315
- const y = l();
2315
+ const y = o();
2316
2316
  if (y === null) return;
2317
- N.getState().openDraftingPanel(r.attrs.sectionType, y), e.commands.focus(y + 1);
2317
+ I.getState().openDraftingPanel(r.attrs.sectionType, y), e.commands.focus(y + 1);
2318
2318
  };
2319
- o.addEventListener("click", u), c.addEventListener("focusin", d), c.addEventListener("click", d);
2319
+ c.addEventListener("click", u), l.addEventListener("focusin", d), l.addEventListener("click", d);
2320
2320
  const m = () => {
2321
- const y = N.getState(), x = H(y.editorLanguage), w = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", T = Ma.has(w), v = Fa.has(w), E = wt[w], _ = typeof x[E] == "string" ? x[E] : w, b = ot(r), C = y.rightPanel.activeSectionPos === l();
2322
- a.className = `ps${b ? "" : " ps--empty"}${v ? " ps--sub" : ""}`, a.setAttribute("data-section-type", w), i.className = T ? "pb-heading" : "ps-heading ps-heading--sub", i.textContent = _, o.textContent = `[${_}]`, o.style.display = b ? "none" : "", o.classList.toggle("ps-placeholder--active", C && !b), c.classList.toggle("ps-content--has-content", b);
2321
+ const y = I.getState(), w = H(y.editorLanguage), T = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", v = Ma.has(T), x = Fa.has(T), S = wt[T], N = typeof w[S] == "string" ? w[S] : T, h = ot(r), C = y.rightPanel.activeSectionPos === o();
2322
+ a.className = `ps${h ? "" : " ps--empty"}${x ? " ps--sub" : ""}`, a.setAttribute("data-section-type", T), i.className = v ? "pb-heading" : "ps-heading ps-heading--sub", i.textContent = N, c.textContent = `[${N}]`, c.style.display = h ? "none" : "", c.classList.toggle("ps-placeholder--active", C && !h), l.classList.toggle("ps-content--has-content", h);
2323
2323
  };
2324
- let f = N.getState().editorLanguage, p = N.getState().rightPanel.activeSectionPos;
2325
- const h = N.subscribe((y) => {
2326
- const x = y.editorLanguage !== f, w = y.rightPanel.activeSectionPos !== p;
2327
- f = y.editorLanguage, p = y.rightPanel.activeSectionPos, (x || w) && m();
2324
+ let f = I.getState().editorLanguage, p = I.getState().rightPanel.activeSectionPos;
2325
+ const b = I.subscribe((y) => {
2326
+ const w = y.editorLanguage !== f, T = y.rightPanel.activeSectionPos !== p;
2327
+ f = y.editorLanguage, p = y.rightPanel.activeSectionPos, (w || T) && m();
2328
2328
  });
2329
2329
  return m(), {
2330
2330
  dom: a,
2331
- contentDOM: c,
2331
+ contentDOM: l,
2332
2332
  update: (y) => y.type.name !== "patent_section" ? !1 : (r = y, m(), !0),
2333
2333
  destroy: () => {
2334
- h(), o.removeEventListener("click", u), c.removeEventListener("focusin", d), c.removeEventListener("click", d);
2334
+ b(), c.removeEventListener("click", u), l.removeEventListener("focusin", d), l.removeEventListener("click", d);
2335
2335
  }
2336
2336
  };
2337
2337
  };
@@ -2379,7 +2379,7 @@ const Le = () => {
2379
2379
  en(),
2380
2380
  ...Ua.map(Fe)
2381
2381
  ], tn = (e = "invention") => ({ type: "doc", content: e === "design" ? Wa() : qa() }), ve = (e) => Xt(e, (t) => t.type.name === "figure"), V = (e) => typeof e != "string" ? "" : e.trim(), xt = (e) => {
2382
- const n = N.getState().editorLanguage === "en" ? "Fig." : "图", r = /* @__PURE__ */ new Set();
2382
+ const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = /* @__PURE__ */ new Set();
2383
2383
  ve(e).forEach((i) => {
2384
2384
  const s = V(i.node.attrs.id);
2385
2385
  s && r.add(s);
@@ -2389,21 +2389,21 @@ const Le = () => {
2389
2389
  a += 1;
2390
2390
  return `${n}${a}`;
2391
2391
  }, ja = /^(Fig\.|图)(\d+)$/, Ga = (e) => {
2392
- const n = N.getState().editorLanguage === "en" ? "Fig." : "图", r = ve(e);
2392
+ const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = ve(e);
2393
2393
  if (r.length === 0) return;
2394
2394
  const a = [];
2395
2395
  let i = 1;
2396
- for (const o of r) {
2397
- const c = V(o.node.attrs.id);
2398
- if (!ja.exec(c)) continue;
2396
+ for (const c of r) {
2397
+ const l = V(c.node.attrs.id);
2398
+ if (!ja.exec(l)) continue;
2399
2399
  const d = `${n}${i}`;
2400
- c !== d && a.push({ pos: o.pos, expectedId: d, currentId: c }), i++;
2400
+ l !== d && a.push({ pos: c.pos, expectedId: d, currentId: l }), i++;
2401
2401
  }
2402
2402
  if (a.length === 0) return;
2403
2403
  const { tr: s } = e.state;
2404
- for (const o of a) {
2405
- const c = s.doc.nodeAt(o.pos);
2406
- !c || c.type.name !== "figure" || s.setNodeMarkup(o.pos, void 0, { ...c.attrs, id: o.expectedId });
2404
+ for (const c of a) {
2405
+ const l = s.doc.nodeAt(c.pos);
2406
+ !l || l.type.name !== "figure" || s.setNodeMarkup(c.pos, void 0, { ...l.attrs, id: c.expectedId });
2407
2407
  }
2408
2408
  s.steps.length > 0 && (s.setMeta("addToHistory", !1), e.view.dispatch(s));
2409
2409
  }, nn = (e) => {
@@ -2415,29 +2415,29 @@ const Le = () => {
2415
2415
  pos: n.pos
2416
2416
  });
2417
2417
  }), t;
2418
- }, rn = () => N.getState().editorLanguage === "en" ? "en" : "zh", an = (e, t, n) => {
2418
+ }, rn = () => I.getState().editorLanguage === "en" ? "en" : "zh", an = (e, t, n) => {
2419
2419
  const r = H(e);
2420
2420
  return n ? r.invalidFigureReference : t || (e === "en" ? "Figure ?" : "附图?");
2421
2421
  }, Je = (e) => {
2422
2422
  const t = nn(e), n = rn();
2423
2423
  e.commands.command(({ tr: r, state: a, dispatch: i }) => {
2424
2424
  let s = !1;
2425
- return a.doc.descendants((o, c) => {
2426
- if (o.type.name !== "reference" || o.attrs.targetType !== "figure")
2425
+ return a.doc.descendants((c, l) => {
2426
+ if (c.type.name !== "reference" || c.attrs.targetType !== "figure")
2427
2427
  return !0;
2428
- const l = typeof o.attrs.targetFigureId == "string" && o.attrs.targetFigureId ? V(o.attrs.targetFigureId) : null, d = l ? t.get(l) : void 0, u = d ? d.id : null, m = !d, f = an(n, u, m), p = {
2429
- ...o.attrs,
2428
+ const o = typeof c.attrs.targetFigureId == "string" && c.attrs.targetFigureId ? V(c.attrs.targetFigureId) : null, d = o ? t.get(o) : void 0, u = d ? d.id : null, m = !d, f = an(n, u, m), p = {
2429
+ ...c.attrs,
2430
2430
  targetType: "figure",
2431
- targetFigureId: l,
2431
+ targetFigureId: o,
2432
2432
  resolvedFigureId: u,
2433
2433
  invalid: m,
2434
2434
  lang: n,
2435
2435
  displayText: f,
2436
- target: u || o.attrs.target || l || null
2436
+ target: u || c.attrs.target || o || null
2437
2437
  };
2438
2438
  return Object.keys(p).some(
2439
- (y) => p[y] !== o.attrs[y]
2440
- ) && (r.setNodeMarkup(c, void 0, p), s = !0), !0;
2439
+ (y) => p[y] !== c.attrs[y]
2440
+ ) && (r.setNodeMarkup(l, void 0, p), s = !0), !0;
2441
2441
  }), s && i && (r.setMeta("addToHistory", !1), i(r)), !0;
2442
2442
  });
2443
2443
  }, Va = {
@@ -2465,14 +2465,14 @@ const Le = () => {
2465
2465
  if (!(n != null && n.lang))
2466
2466
  return !1;
2467
2467
  const r = n.lang === "en" ? "en" : "zh";
2468
- N.getState().setEditorLanguage(r);
2468
+ I.getState().setEditorLanguage(r);
2469
2469
  const i = (n.scope || "all") === "current" ? Re(e, "reference") : null;
2470
- return e.commands.command(({ tr: o, state: c, dispatch: l }) => {
2470
+ return e.commands.command(({ tr: c, state: l, dispatch: o }) => {
2471
2471
  let d = !1;
2472
- return c.doc.descendants((u, m) => (u.type.name !== "reference" || i && m !== i.pos || u.attrs.lang !== r && (o.setNodeMarkup(m, void 0, {
2472
+ return l.doc.descendants((u, m) => (u.type.name !== "reference" || i && m !== i.pos || u.attrs.lang !== r && (c.setNodeMarkup(m, void 0, {
2473
2473
  ...u.attrs,
2474
2474
  lang: r
2475
- }), d = !0), !0)), d && l && (o.setMeta("addToHistory", !1), l(o)), !0;
2475
+ }), d = !0), !0)), d && o && (c.setMeta("addToHistory", !1), o(c)), !0;
2476
2476
  }) ? (Je(e), !0) : !1;
2477
2477
  }
2478
2478
  },
@@ -2500,14 +2500,14 @@ const Le = () => {
2500
2500
  const i = e.state.doc.nodeAt(a);
2501
2501
  if (!i || i.type.name !== "figure")
2502
2502
  return !1;
2503
- const o = (typeof n.id == "string" ? V(n.id) : V(i.attrs.id)) || xt(e);
2504
- if (ve(e).some((d) => d.pos === a ? !1 : V(d.node.attrs.id) === o))
2503
+ const c = (typeof n.id == "string" ? V(n.id) : V(i.attrs.id)) || xt(e);
2504
+ if (ve(e).some((d) => d.pos === a ? !1 : V(d.node.attrs.id) === c))
2505
2505
  return !1;
2506
- const l = { id: o };
2507
- return typeof n.contentType == "string" && ["image", "mermaid", "drawio"].includes(n.contentType) && (l.contentType = n.contentType), typeof n.imageSrc == "string" && (l.imageSrc = n.imageSrc), typeof n.mermaidCode == "string" && (l.mermaidCode = n.mermaidCode), typeof n.drawioXml == "string" && (l.drawioXml = n.drawioXml), ze(e, {
2506
+ const o = { id: c };
2507
+ return typeof n.contentType == "string" && ["image", "mermaid", "drawio"].includes(n.contentType) && (o.contentType = n.contentType), typeof n.imageSrc == "string" && (o.imageSrc = n.imageSrc), typeof n.mermaidCode == "string" && (o.mermaidCode = n.mermaidCode), typeof n.drawioXml == "string" && (o.drawioXml = n.drawioXml), ze(e, {
2508
2508
  type: "figure",
2509
2509
  position: a,
2510
- attrs: l
2510
+ attrs: o
2511
2511
  });
2512
2512
  }
2513
2513
  },
@@ -2547,7 +2547,7 @@ const Le = () => {
2547
2547
  const i = r.get(a);
2548
2548
  if (!i)
2549
2549
  return !1;
2550
- const s = n.lang || rn(), o = n.displayText || an(s, i.id, !1);
2550
+ const s = n.lang || rn(), c = n.displayText || an(s, i.id, !1);
2551
2551
  return e.chain().focus().insertContent({
2552
2552
  type: "reference",
2553
2553
  attrs: {
@@ -2558,7 +2558,7 @@ const Le = () => {
2558
2558
  resolvedFigureId: i.id,
2559
2559
  lang: s,
2560
2560
  invalid: !1,
2561
- displayText: o,
2561
+ displayText: c,
2562
2562
  target: n.target || i.id,
2563
2563
  highlight: !1
2564
2564
  }
@@ -2608,7 +2608,7 @@ const Ka = (e = {}) => {
2608
2608
  return {
2609
2609
  editor: e,
2610
2610
  selection: { from: t, to: n },
2611
- store: N.getState()
2611
+ store: I.getState()
2612
2612
  };
2613
2613
  }, ct = (e) => ({
2614
2614
  execCommand: (t, n, r) => B.executeCommand(t, Ke(e), n, r),
@@ -2638,23 +2638,23 @@ const Ka = (e = {}) => {
2638
2638
  }
2639
2639
  return e.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join(" ");
2640
2640
  }, Ct = ({ btn: e, items: t }) => {
2641
- const [n, r] = F(!1), a = W(null), i = W(null), [s, o] = F({ top: 0, left: 0 }), c = ae(() => {
2641
+ const [n, r] = F(!1), a = W(null), i = W(null), [s, c] = F({ top: 0, left: 0 }), l = ae(() => {
2642
2642
  if (!a.current) return;
2643
- const l = a.current.getBoundingClientRect();
2644
- o({ top: l.bottom + 4, left: l.left });
2643
+ const o = a.current.getBoundingClientRect();
2644
+ c({ top: o.bottom + 4, left: o.left });
2645
2645
  }, []);
2646
2646
  return M(() => {
2647
2647
  if (!n) return;
2648
- c();
2649
- const l = (u) => {
2648
+ l();
2649
+ const o = (u) => {
2650
2650
  var f, p;
2651
2651
  const m = u.target;
2652
2652
  (f = a.current) != null && f.contains(m) || (p = i.current) != null && p.contains(m) || r(!1);
2653
- }, d = () => c();
2654
- return document.addEventListener("mousedown", l), window.addEventListener("scroll", d, !0), () => {
2655
- document.removeEventListener("mousedown", l), window.removeEventListener("scroll", d, !0);
2653
+ }, d = () => l();
2654
+ return document.addEventListener("mousedown", o), window.addEventListener("scroll", d, !0), () => {
2655
+ document.removeEventListener("mousedown", o), window.removeEventListener("scroll", d, !0);
2656
2656
  };
2657
- }, [n, c]), /* @__PURE__ */ L("div", { className: "flex items-center", children: [
2657
+ }, [n, l]), /* @__PURE__ */ L("div", { className: "flex items-center", children: [
2658
2658
  /* @__PURE__ */ g(
2659
2659
  "button",
2660
2660
  {
@@ -2673,7 +2673,7 @@ const Ka = (e = {}) => {
2673
2673
  "button",
2674
2674
  {
2675
2675
  ref: a,
2676
- onClick: () => r((l) => !l),
2676
+ onClick: () => r((o) => !o),
2677
2677
  className: Y(
2678
2678
  "px-1 py-2 rounded-r transition-colors border-l border-gray-200",
2679
2679
  e.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200 text-gray-500"
@@ -2689,14 +2689,14 @@ const Ka = (e = {}) => {
2689
2689
  ref: i,
2690
2690
  className: "bg-white border border-gray-200 rounded shadow-lg min-w-[160px] py-1",
2691
2691
  style: { position: "fixed", top: s.top, left: s.left, zIndex: 9999 },
2692
- children: t.map((l, d) => /* @__PURE__ */ g(
2692
+ children: t.map((o, d) => /* @__PURE__ */ g(
2693
2693
  "button",
2694
2694
  {
2695
2695
  onClick: () => {
2696
- l.onClick(), r(!1);
2696
+ o.onClick(), r(!1);
2697
2697
  },
2698
2698
  className: "block w-full text-left px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100",
2699
- children: l.label
2699
+ children: o.label
2700
2700
  },
2701
2701
  d
2702
2702
  ))
@@ -2711,22 +2711,22 @@ const Ka = (e = {}) => {
2711
2711
  collapsibleGroups: n = !0,
2712
2712
  defaultCollapsedGroups: r = []
2713
2713
  }) => {
2714
- const [a, i] = F(() => new Set(r)), [, s] = F(0), { editorLanguage: o, setEditorLanguage: c } = N(), l = H(o);
2714
+ const [a, i] = F(() => new Set(r)), [, s] = F(0), { editorLanguage: c, setEditorLanguage: l } = I(), o = H(c);
2715
2715
  if (M(() => {
2716
2716
  if (!e) return;
2717
- const b = () => s((C) => C + 1);
2718
- return e.on("selectionUpdate", b), e.on("update", b), () => {
2719
- e.off("selectionUpdate", b), e.off("update", b);
2717
+ const h = () => s((C) => C + 1);
2718
+ return e.on("selectionUpdate", h), e.on("update", h), () => {
2719
+ e.off("selectionUpdate", h), e.off("update", h);
2720
2720
  };
2721
2721
  }, [e]), !e)
2722
2722
  return null;
2723
- const d = ct(e), u = o === "zh", m = [
2723
+ const d = ct(e), u = c === "zh", m = [
2724
2724
  {
2725
2725
  id: "core-undo",
2726
- label: l.undo,
2726
+ label: o.undo,
2727
2727
  group: "history",
2728
2728
  icon: br,
2729
- tooltip: `${l.undo} (Ctrl+Z)`,
2729
+ tooltip: `${o.undo} (Ctrl+Z)`,
2730
2730
  isActive: !1,
2731
2731
  disabled: !e.can().chain().focus().undo().run(),
2732
2732
  run: () => {
@@ -2735,10 +2735,10 @@ const Ka = (e = {}) => {
2735
2735
  },
2736
2736
  {
2737
2737
  id: "core-redo",
2738
- label: l.redo,
2738
+ label: o.redo,
2739
2739
  group: "history",
2740
2740
  icon: vr,
2741
- tooltip: `${l.redo} (Ctrl+Y)`,
2741
+ tooltip: `${o.redo} (Ctrl+Y)`,
2742
2742
  isActive: !1,
2743
2743
  disabled: !e.can().chain().focus().redo().run(),
2744
2744
  run: () => {
@@ -2747,10 +2747,10 @@ const Ka = (e = {}) => {
2747
2747
  },
2748
2748
  {
2749
2749
  id: "core-bold",
2750
- label: l.bold,
2750
+ label: o.bold,
2751
2751
  group: "text",
2752
2752
  icon: Dt,
2753
- tooltip: l.bold,
2753
+ tooltip: o.bold,
2754
2754
  isActive: e.isActive("bold"),
2755
2755
  disabled: !1,
2756
2756
  run: () => {
@@ -2759,10 +2759,10 @@ const Ka = (e = {}) => {
2759
2759
  },
2760
2760
  {
2761
2761
  id: "core-italic",
2762
- label: l.italic,
2762
+ label: o.italic,
2763
2763
  group: "text",
2764
2764
  icon: Rt,
2765
- tooltip: l.italic,
2765
+ tooltip: o.italic,
2766
2766
  isActive: e.isActive("italic"),
2767
2767
  disabled: !1,
2768
2768
  run: () => {
@@ -2771,10 +2771,10 @@ const Ka = (e = {}) => {
2771
2771
  },
2772
2772
  {
2773
2773
  id: "core-underline",
2774
- label: l.underline,
2774
+ label: o.underline,
2775
2775
  group: "text",
2776
2776
  icon: Mt,
2777
- tooltip: l.underline,
2777
+ tooltip: o.underline,
2778
2778
  isActive: e.isActive("underline"),
2779
2779
  disabled: !1,
2780
2780
  run: () => {
@@ -2783,10 +2783,10 @@ const Ka = (e = {}) => {
2783
2783
  },
2784
2784
  {
2785
2785
  id: "core-strike",
2786
- label: l.strike,
2786
+ label: o.strike,
2787
2787
  group: "text",
2788
2788
  icon: Ft,
2789
- tooltip: l.strike,
2789
+ tooltip: o.strike,
2790
2790
  isActive: e.isActive("strike"),
2791
2791
  disabled: !1,
2792
2792
  run: () => {
@@ -2795,10 +2795,10 @@ const Ka = (e = {}) => {
2795
2795
  },
2796
2796
  {
2797
2797
  id: "core-code",
2798
- label: l.code,
2798
+ label: o.code,
2799
2799
  group: "text",
2800
2800
  icon: $t,
2801
- tooltip: l.code,
2801
+ tooltip: o.code,
2802
2802
  isActive: e.isActive("code"),
2803
2803
  disabled: !1,
2804
2804
  run: () => {
@@ -2807,10 +2807,10 @@ const Ka = (e = {}) => {
2807
2807
  },
2808
2808
  {
2809
2809
  id: "core-superscript",
2810
- label: l.superscript,
2810
+ label: o.superscript,
2811
2811
  group: "text",
2812
2812
  icon: zt,
2813
- tooltip: `${l.superscript} (Ctrl+.)`,
2813
+ tooltip: `${o.superscript} (Ctrl+.)`,
2814
2814
  isActive: e.isActive("superscript"),
2815
2815
  disabled: !1,
2816
2816
  run: () => {
@@ -2819,10 +2819,10 @@ const Ka = (e = {}) => {
2819
2819
  },
2820
2820
  {
2821
2821
  id: "core-subscript",
2822
- label: l.subscript,
2822
+ label: o.subscript,
2823
2823
  group: "text",
2824
2824
  icon: Ot,
2825
- tooltip: `${l.subscript} (Ctrl+,)`,
2825
+ tooltip: `${o.subscript} (Ctrl+,)`,
2826
2826
  isActive: e.isActive("subscript"),
2827
2827
  disabled: !1,
2828
2828
  run: () => {
@@ -2831,10 +2831,10 @@ const Ka = (e = {}) => {
2831
2831
  },
2832
2832
  {
2833
2833
  id: "core-paragraph",
2834
- label: l.paragraph,
2834
+ label: o.paragraph,
2835
2835
  group: "structure",
2836
2836
  icon: wr,
2837
- tooltip: l.paragraph,
2837
+ tooltip: o.paragraph,
2838
2838
  isActive: e.isActive("paragraph"),
2839
2839
  disabled: !1,
2840
2840
  run: () => {
@@ -2846,7 +2846,7 @@ const Ka = (e = {}) => {
2846
2846
  label: "H1",
2847
2847
  group: "structure",
2848
2848
  icon: xr,
2849
- tooltip: l.heading1,
2849
+ tooltip: o.heading1,
2850
2850
  isActive: e.isActive("heading", { level: 1 }),
2851
2851
  disabled: !1,
2852
2852
  run: () => {
@@ -2858,7 +2858,7 @@ const Ka = (e = {}) => {
2858
2858
  label: "H2",
2859
2859
  group: "structure",
2860
2860
  icon: Cr,
2861
- tooltip: l.heading2,
2861
+ tooltip: o.heading2,
2862
2862
  isActive: e.isActive("heading", { level: 2 }),
2863
2863
  disabled: !1,
2864
2864
  run: () => {
@@ -2870,7 +2870,7 @@ const Ka = (e = {}) => {
2870
2870
  label: "H3",
2871
2871
  group: "structure",
2872
2872
  icon: Tr,
2873
- tooltip: l.heading3,
2873
+ tooltip: o.heading3,
2874
2874
  isActive: e.isActive("heading", { level: 3 }),
2875
2875
  disabled: !1,
2876
2876
  run: () => {
@@ -2879,10 +2879,10 @@ const Ka = (e = {}) => {
2879
2879
  },
2880
2880
  {
2881
2881
  id: "core-align-left",
2882
- label: l.alignLeft,
2882
+ label: o.alignLeft,
2883
2883
  group: "format",
2884
2884
  icon: Sr,
2885
- tooltip: l.alignLeft,
2885
+ tooltip: o.alignLeft,
2886
2886
  isActive: e.isActive({ textAlign: "left" }),
2887
2887
  disabled: !1,
2888
2888
  run: () => {
@@ -2891,10 +2891,10 @@ const Ka = (e = {}) => {
2891
2891
  },
2892
2892
  {
2893
2893
  id: "core-align-center",
2894
- label: l.alignCenter,
2894
+ label: o.alignCenter,
2895
2895
  group: "format",
2896
2896
  icon: Er,
2897
- tooltip: l.alignCenter,
2897
+ tooltip: o.alignCenter,
2898
2898
  isActive: e.isActive({ textAlign: "center" }),
2899
2899
  disabled: !1,
2900
2900
  run: () => {
@@ -2903,10 +2903,10 @@ const Ka = (e = {}) => {
2903
2903
  },
2904
2904
  {
2905
2905
  id: "core-align-right",
2906
- label: l.alignRight,
2906
+ label: o.alignRight,
2907
2907
  group: "format",
2908
2908
  icon: kr,
2909
- tooltip: l.alignRight,
2909
+ tooltip: o.alignRight,
2910
2910
  isActive: e.isActive({ textAlign: "right" }),
2911
2911
  disabled: !1,
2912
2912
  run: () => {
@@ -2915,10 +2915,10 @@ const Ka = (e = {}) => {
2915
2915
  },
2916
2916
  {
2917
2917
  id: "core-align-justify",
2918
- label: l.alignJustify,
2918
+ label: o.alignJustify,
2919
2919
  group: "format",
2920
2920
  icon: _r,
2921
- tooltip: l.alignJustify,
2921
+ tooltip: o.alignJustify,
2922
2922
  isActive: e.isActive({ textAlign: "justify" }),
2923
2923
  disabled: !1,
2924
2924
  run: () => {
@@ -2927,10 +2927,10 @@ const Ka = (e = {}) => {
2927
2927
  },
2928
2928
  {
2929
2929
  id: "core-bullet-list",
2930
- label: l.bulletList,
2930
+ label: o.bulletList,
2931
2931
  group: "structure",
2932
2932
  icon: Ir,
2933
- tooltip: l.bulletList,
2933
+ tooltip: o.bulletList,
2934
2934
  isActive: e.isActive("bulletList"),
2935
2935
  disabled: !1,
2936
2936
  run: () => {
@@ -2939,10 +2939,10 @@ const Ka = (e = {}) => {
2939
2939
  },
2940
2940
  {
2941
2941
  id: "core-ordered-list",
2942
- label: l.orderedList,
2942
+ label: o.orderedList,
2943
2943
  group: "structure",
2944
2944
  icon: Nr,
2945
- tooltip: l.orderedList,
2945
+ tooltip: o.orderedList,
2946
2946
  isActive: e.isActive("orderedList"),
2947
2947
  disabled: !1,
2948
2948
  run: () => {
@@ -2951,10 +2951,10 @@ const Ka = (e = {}) => {
2951
2951
  },
2952
2952
  {
2953
2953
  id: "core-blockquote",
2954
- label: l.blockquote,
2954
+ label: o.blockquote,
2955
2955
  group: "structure",
2956
2956
  icon: Ar,
2957
- tooltip: l.blockquote,
2957
+ tooltip: o.blockquote,
2958
2958
  isActive: e.isActive("blockquote"),
2959
2959
  disabled: !1,
2960
2960
  run: () => {
@@ -2963,10 +2963,10 @@ const Ka = (e = {}) => {
2963
2963
  },
2964
2964
  {
2965
2965
  id: "core-code-block",
2966
- label: l.codeBlock,
2966
+ label: o.codeBlock,
2967
2967
  group: "structure",
2968
2968
  icon: Lr,
2969
- tooltip: l.codeBlock,
2969
+ tooltip: o.codeBlock,
2970
2970
  isActive: e.isActive("codeBlock"),
2971
2971
  disabled: !1,
2972
2972
  run: () => {
@@ -2975,10 +2975,10 @@ const Ka = (e = {}) => {
2975
2975
  },
2976
2976
  {
2977
2977
  id: "core-table",
2978
- label: l.insertTable,
2978
+ label: o.insertTable,
2979
2979
  group: "structure",
2980
2980
  icon: Pr,
2981
- tooltip: l.insertTable,
2981
+ tooltip: o.insertTable,
2982
2982
  isActive: !1,
2983
2983
  disabled: !1,
2984
2984
  run: () => {
@@ -2987,10 +2987,10 @@ const Ka = (e = {}) => {
2987
2987
  },
2988
2988
  {
2989
2989
  id: "core-horizontal-rule",
2990
- label: l.horizontalRule,
2990
+ label: o.horizontalRule,
2991
2991
  group: "structure",
2992
2992
  icon: Dr,
2993
- tooltip: l.horizontalRule,
2993
+ tooltip: o.horizontalRule,
2994
2994
  isActive: !1,
2995
2995
  disabled: !1,
2996
2996
  run: () => {
@@ -2999,10 +2999,10 @@ const Ka = (e = {}) => {
2999
2999
  },
3000
3000
  {
3001
3001
  id: "core-task-list",
3002
- label: l.taskList,
3002
+ label: o.taskList,
3003
3003
  group: "structure",
3004
3004
  icon: Rr,
3005
- tooltip: l.taskList,
3005
+ tooltip: o.taskList,
3006
3006
  isActive: e.isActive("taskList"),
3007
3007
  disabled: !1,
3008
3008
  run: () => {
@@ -3018,29 +3018,29 @@ const Ka = (e = {}) => {
3018
3018
  FileText: Ut,
3019
3019
  Link2: Ht,
3020
3020
  Image: Bt
3021
- }, p = B.getToolbarItems().map((b) => {
3022
- const C = B.getCommandMeta(b.command), I = u && b.tooltipZh ? b.tooltipZh : b.tooltip || (C == null ? void 0 : C.description) || b.label, A = b.shortcut || (C == null ? void 0 : C.shortcut), D = A ? `${I} (${A})` : I;
3021
+ }, p = B.getToolbarItems().map((h) => {
3022
+ const C = B.getCommandMeta(h.command), _ = u && h.tooltipZh ? h.tooltipZh : h.tooltip || (C == null ? void 0 : C.description) || h.label, A = h.shortcut || (C == null ? void 0 : C.shortcut), D = A ? `${_} (${A})` : _;
3023
3023
  return {
3024
- id: b.id,
3025
- label: b.label,
3026
- group: b.group || "technical",
3027
- icon: b.icon ? f[b.icon] || mt : mt,
3028
- isActive: d.isCommandActive(b.command),
3029
- disabled: !d.canExecCommand(b.command),
3024
+ id: h.id,
3025
+ label: h.label,
3026
+ group: h.group || "technical",
3027
+ icon: h.icon ? f[h.icon] || mt : mt,
3028
+ isActive: d.isCommandActive(h.command),
3029
+ disabled: !d.canExecCommand(h.command),
3030
3030
  tooltip: D,
3031
3031
  run: () => {
3032
- d.execCommand(b.command);
3032
+ d.execCommand(h.command);
3033
3033
  }
3034
3034
  };
3035
- }), h = [...m, ...p], y = h.map((b) => b.group).filter((b, C, I) => I.indexOf(b) === C && !t.includes(b)), w = [...t, ...y].map((b) => ({
3036
- group: b,
3037
- items: h.filter((C) => C.group === b)
3038
- })).filter((b) => b.items.length > 0), T = (b) => {
3035
+ }), b = [...m, ...p], y = b.map((h) => h.group).filter((h, C, _) => _.indexOf(h) === C && !t.includes(h)), T = [...t, ...y].map((h) => ({
3036
+ group: h,
3037
+ items: b.filter((C) => C.group === h)
3038
+ })).filter((h) => h.items.length > 0), v = (h) => {
3039
3039
  i((C) => {
3040
- const I = new Set(C);
3041
- return I.has(b) ? I.delete(b) : I.add(b), I;
3040
+ const _ = new Set(C);
3041
+ return _.has(h) ? _.delete(h) : _.add(h), _;
3042
3042
  });
3043
- }, v = [
3043
+ }, x = [
3044
3044
  { label: u ? "插入表格 3×3" : "Insert Table 3×3", onClick: () => e.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run() },
3045
3045
  { label: u ? "上方插入行" : "Add Row Before", onClick: () => e.chain().focus().addRowBefore().run() },
3046
3046
  { label: u ? "下方插入行" : "Add Row After", onClick: () => e.chain().focus().addRowAfter().run() },
@@ -3052,34 +3052,34 @@ const Ka = (e = {}) => {
3052
3052
  { label: u ? "拆分单元格" : "Split Cell", onClick: () => e.chain().focus().splitCell().run() },
3053
3053
  { label: u ? "切换表头" : "Toggle Header Row", onClick: () => e.chain().focus().toggleHeaderRow().run() },
3054
3054
  { label: u ? "删除表格" : "Delete Table", onClick: () => e.chain().focus().deleteTable().run() }
3055
- ], E = [
3056
- { label: l.insertImageFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "image" }) },
3057
- { label: l.insertMermaidFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "mermaid" }) },
3058
- { label: l.insertDrawioFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "drawio" }) }
3059
- ], _ = (b) => b.id === "core-table" ? /* @__PURE__ */ g(Ct, { btn: b, items: v }, b.id) : b.id === "patent-figure-insert" ? /* @__PURE__ */ g(Ct, { btn: b, items: E }, b.id) : /* @__PURE__ */ g(
3055
+ ], S = [
3056
+ { label: o.insertImageFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "image" }) },
3057
+ { label: o.insertMermaidFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "mermaid" }) },
3058
+ { label: o.insertDrawioFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "drawio" }) }
3059
+ ], N = (h) => h.id === "core-table" ? /* @__PURE__ */ g(Ct, { btn: h, items: x }, h.id) : h.id === "patent-figure-insert" ? /* @__PURE__ */ g(Ct, { btn: h, items: S }, h.id) : /* @__PURE__ */ g(
3060
3060
  "button",
3061
3061
  {
3062
- onClick: b.run,
3063
- disabled: b.disabled,
3062
+ onClick: h.run,
3063
+ disabled: h.disabled,
3064
3064
  className: Y(
3065
3065
  "p-2 rounded transition-colors",
3066
- b.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200",
3067
- b.isActive ? "bg-gray-300 text-blue-600" : "text-gray-700"
3066
+ h.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200",
3067
+ h.isActive ? "bg-gray-300 text-blue-600" : "text-gray-700"
3068
3068
  ),
3069
- title: b.tooltip,
3070
- children: /* @__PURE__ */ g(b.icon, { size: 18 })
3069
+ title: h.tooltip,
3070
+ children: /* @__PURE__ */ g(h.icon, { size: 18 })
3071
3071
  },
3072
- b.id
3072
+ h.id
3073
3073
  );
3074
3074
  return /* @__PURE__ */ g("div", { className: "border-b border-gray-200 bg-gray-50 sticky top-0 z-10 overflow-x-auto", children: /* @__PURE__ */ L("div", { className: "flex flex-nowrap md:flex-wrap gap-2 p-2 min-w-max md:min-w-0", children: [
3075
3075
  /* @__PURE__ */ L("div", { className: "flex items-center gap-1 pr-2 mr-2 border-r border-gray-200", children: [
3076
- /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: l.language }),
3076
+ /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: o.language }),
3077
3077
  /* @__PURE__ */ L(
3078
3078
  "select",
3079
3079
  {
3080
- value: o,
3081
- onChange: (b) => {
3082
- c(b.target.value === "en" ? "en" : "zh");
3080
+ value: c,
3081
+ onChange: (h) => {
3082
+ l(h.target.value === "en" ? "en" : "zh");
3083
3083
  },
3084
3084
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white text-gray-700",
3085
3085
  children: [
@@ -3089,66 +3089,66 @@ const Ka = (e = {}) => {
3089
3089
  }
3090
3090
  )
3091
3091
  ] }),
3092
- w.map((b) => {
3093
- const C = a.has(b.group);
3092
+ T.map((h) => {
3093
+ const C = a.has(h.group);
3094
3094
  return /* @__PURE__ */ L("div", { className: "flex items-center gap-1 pr-2 mr-2 border-r border-gray-200 last:border-r-0 last:mr-0 last:pr-0", children: [
3095
3095
  n && /* @__PURE__ */ g(
3096
3096
  "button",
3097
3097
  {
3098
3098
  onClick: () => {
3099
- T(b.group);
3099
+ v(h.group);
3100
3100
  },
3101
3101
  className: "px-2 py-1 text-xs rounded bg-gray-200 text-gray-700 hover:bg-gray-300",
3102
- title: C ? `${l.expand} ${Xe(b.group, l)}` : `${l.collapse} ${Xe(b.group, l)}`,
3103
- children: Xe(b.group, l)
3102
+ title: C ? `${o.expand} ${Xe(h.group, o)}` : `${o.collapse} ${Xe(h.group, o)}`,
3103
+ children: Xe(h.group, o)
3104
3104
  }
3105
3105
  ),
3106
- (!n || !C) && b.items.map(_)
3107
- ] }, b.group);
3106
+ (!n || !C) && h.items.map(N)
3107
+ ] }, h.group);
3108
3108
  })
3109
3109
  ] }) });
3110
3110
  }, Qa = ({ editor: e }) => {
3111
- const [t, n] = F(0), [r, a] = F(""), i = N((v) => v.editorLanguage), s = H(i);
3111
+ const [t, n] = F(0), [r, a] = F(""), i = I((x) => x.editorLanguage), s = H(i);
3112
3112
  if (M(() => {
3113
3113
  if (!e) return;
3114
- const v = () => n((E) => E + 1);
3115
- return e.on("selectionUpdate", v), e.on("update", v), () => {
3116
- e.off("selectionUpdate", v), e.off("update", v);
3114
+ const x = () => n((S) => S + 1);
3115
+ return e.on("selectionUpdate", x), e.on("update", x), () => {
3116
+ e.off("selectionUpdate", x), e.off("update", x);
3117
3117
  };
3118
3118
  }, [e]), !e) return null;
3119
- const o = ct(e), c = [];
3120
- e.state.doc.descendants((v) => {
3121
- if (v.type.name !== "figure") return !0;
3122
- const E = typeof v.attrs.id == "string" ? v.attrs.id.trim() : "";
3123
- return E && c.push({ id: E, label: E }), !0;
3119
+ const c = ct(e), l = [];
3120
+ e.state.doc.descendants((x) => {
3121
+ if (x.type.name !== "figure") return !0;
3122
+ const S = typeof x.attrs.id == "string" ? x.attrs.id.trim() : "";
3123
+ return S && l.push({ id: S, label: S }), !0;
3124
3124
  });
3125
- const l = o.findAncestorNode("figure"), d = !!l, u = l && typeof l.node.attrs.id == "string" ? l.node.attrs.id.trim() : "", m = l && typeof l.node.attrs.contentType == "string" ? l.node.attrs.contentType : "image", [f, p] = F(""), h = W(null), y = W(null), x = (l == null ? void 0 : l.pos) ?? null;
3126
- x !== y.current && (y.current = x, d && u !== f && p(u));
3127
- const w = (v) => {
3128
- l && o.execCommand("patent.updateFigure", {
3129
- position: l.pos,
3130
- contentType: v
3125
+ const o = c.findAncestorNode("figure"), d = !!o, u = o && typeof o.node.attrs.id == "string" ? o.node.attrs.id.trim() : "", m = o && typeof o.node.attrs.contentType == "string" ? o.node.attrs.contentType : "image", [f, p] = F(""), b = W(null), y = W(null), w = (o == null ? void 0 : o.pos) ?? null;
3126
+ w !== y.current && (y.current = w, d && u !== f && p(u));
3127
+ const T = (x) => {
3128
+ o && c.execCommand("patent.updateFigure", {
3129
+ position: o.pos,
3130
+ contentType: x
3131
3131
  });
3132
- }, T = () => {
3133
- if (!l) return;
3134
- const v = f.trim();
3135
- v !== u && o.execCommand("patent.updateFigure", {
3136
- position: l.pos,
3137
- id: v
3132
+ }, v = () => {
3133
+ if (!o) return;
3134
+ const x = f.trim();
3135
+ x !== u && c.execCommand("patent.updateFigure", {
3136
+ position: o.pos,
3137
+ id: x
3138
3138
  });
3139
3139
  };
3140
3140
  return /* @__PURE__ */ g("div", { className: "border-b border-gray-200 bg-gray-50 p-2", children: /* @__PURE__ */ L("div", { className: "bg-white border border-gray-200 rounded-md px-2 py-2 flex flex-wrap items-center gap-2", children: [
3141
- c.length > 0 && /* @__PURE__ */ L(je, { children: [
3141
+ l.length > 0 && /* @__PURE__ */ L(je, { children: [
3142
3142
  /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: s.figureReferenceTarget }),
3143
3143
  /* @__PURE__ */ L(
3144
3144
  "select",
3145
3145
  {
3146
3146
  value: r || "__none__",
3147
- onChange: (v) => a(v.target.value === "__none__" ? "" : v.target.value),
3147
+ onChange: (x) => a(x.target.value === "__none__" ? "" : x.target.value),
3148
3148
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
3149
3149
  children: [
3150
3150
  /* @__PURE__ */ g("option", { value: "__none__", children: s.figureReferenceTargetPlaceholder }),
3151
- c.map((v) => /* @__PURE__ */ g("option", { value: v.id, children: v.label }, v.id))
3151
+ l.map((x) => /* @__PURE__ */ g("option", { value: x.id, children: x.label }, x.id))
3152
3152
  ]
3153
3153
  }
3154
3154
  ),
@@ -3156,7 +3156,7 @@ const Ka = (e = {}) => {
3156
3156
  "button",
3157
3157
  {
3158
3158
  onClick: () => {
3159
- r && o.execCommand("patent.insertFigureReference", {
3159
+ r && c.execCommand("patent.insertFigureReference", {
3160
3160
  targetType: "figure",
3161
3161
  targetFigureId: r
3162
3162
  });
@@ -3174,13 +3174,13 @@ const Ka = (e = {}) => {
3174
3174
  /* @__PURE__ */ g(
3175
3175
  "input",
3176
3176
  {
3177
- ref: h,
3177
+ ref: b,
3178
3178
  type: "text",
3179
3179
  value: f,
3180
- onChange: (v) => p(v.target.value),
3181
- onBlur: T,
3182
- onKeyDown: (v) => {
3183
- v.key === "Enter" && (T(), v.target.blur());
3180
+ onChange: (x) => p(x.target.value),
3181
+ onBlur: v,
3182
+ onKeyDown: (x) => {
3183
+ x.key === "Enter" && (v(), x.target.blur());
3184
3184
  },
3185
3185
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white w-20",
3186
3186
  placeholder: i === "en" ? "Fig.1" : "图1"
@@ -3191,7 +3191,7 @@ const Ka = (e = {}) => {
3191
3191
  "select",
3192
3192
  {
3193
3193
  value: m,
3194
- onChange: (v) => w(v.target.value),
3194
+ onChange: (x) => T(x.target.value),
3195
3195
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
3196
3196
  children: [
3197
3197
  /* @__PURE__ */ g("option", { value: "image", children: s.figureContentTypeImage }),
@@ -3203,17 +3203,17 @@ const Ka = (e = {}) => {
3203
3203
  /* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" })
3204
3204
  ] }),
3205
3205
  e.isActive("image") && (() => {
3206
- const E = e.getAttributes("image").width || "";
3206
+ const S = e.getAttributes("image").width || "";
3207
3207
  return /* @__PURE__ */ L(je, { children: [
3208
3208
  /* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: i === "zh" ? "图片" : "Image" }),
3209
- ["25%", "50%", "75%", "100%"].map((b) => /* @__PURE__ */ g(
3209
+ ["25%", "50%", "75%", "100%"].map((h) => /* @__PURE__ */ g(
3210
3210
  "button",
3211
3211
  {
3212
- onClick: () => e.chain().focus().updateAttributes("image", { width: b }).run(),
3213
- className: `text-xs px-2 py-0.5 rounded border ${E === b ? "bg-blue-50 text-blue-700 border-blue-200" : "bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,
3214
- children: b
3212
+ onClick: () => e.chain().focus().updateAttributes("image", { width: h }).run(),
3213
+ className: `text-xs px-2 py-0.5 rounded border ${S === h ? "bg-blue-50 text-blue-700 border-blue-200" : "bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,
3214
+ children: h
3215
3215
  },
3216
- b
3216
+ h
3217
3217
  )),
3218
3218
  /* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" })
3219
3219
  ] });
@@ -3284,53 +3284,53 @@ function ti(e, t) {
3284
3284
  }).filter((i) => i !== null && i.content.length > 0);
3285
3285
  }
3286
3286
  function qs(e, t = {}) {
3287
- const n = N.getState().editorLanguage, { from: r, to: a } = e.state.selection, i = r !== a ? e.state.doc.textBetween(r, a, " ", "\0") : void 0;
3288
- let s = t.sectionType, o = t.targetSectionPos;
3287
+ const n = I.getState().editorLanguage, { from: r, to: a } = e.state.selection, i = r !== a ? e.state.doc.textBetween(r, a, " ", "\0") : void 0;
3288
+ let s = t.sectionType, c = t.targetSectionPos;
3289
3289
  if (!s) {
3290
3290
  const u = on(e);
3291
- u && (s = u.sectionType, o = u.pos);
3291
+ u && (s = u.sectionType, c = u.pos);
3292
3292
  }
3293
- const c = t.scope || (s ? "section" : i ? "selection" : "document"), l = s ? ti(e, s) : void 0;
3293
+ const l = t.scope || (s ? "section" : i ? "selection" : "document"), o = s ? ti(e, s) : void 0;
3294
3294
  let d;
3295
- if (c === "selection" && r !== a) {
3296
- const m = Math.max(0, r - 200), f = Math.min(e.state.doc.content.size, a + 200), p = e.state.doc.textBetween(m, r, " ", "\0"), h = e.state.doc.textBetween(a, f, " ", "\0");
3297
- d = `...${p}[SELECTED]${h}...`;
3295
+ if (l === "selection" && r !== a) {
3296
+ const m = Math.max(0, r - 200), f = Math.min(e.state.doc.content.size, a + 200), p = e.state.doc.textBetween(m, r, " ", "\0"), b = e.state.doc.textBetween(a, f, " ", "\0");
3297
+ d = `...${p}[SELECTED]${b}...`;
3298
3298
  }
3299
3299
  return {
3300
- scope: c,
3300
+ scope: l,
3301
3301
  sectionType: s,
3302
- targetSectionPos: o,
3302
+ targetSectionPos: c,
3303
3303
  userInput: t.userInput,
3304
3304
  selectedText: i,
3305
- dependencyContext: l,
3305
+ dependencyContext: o,
3306
3306
  surroundingText: d,
3307
3307
  language: n
3308
3308
  };
3309
3309
  }
3310
3310
  const ni = ({ editor: e, onSelectionOptimize: t }) => {
3311
- const { addChatReference: n, openChatPanel: r, editorLanguage: a } = N(), i = a === "zh", s = (l) => Y(
3311
+ const { addChatReference: n, openChatPanel: r, editorLanguage: a } = I(), i = a === "zh", s = (o) => Y(
3312
3312
  "p-1.5 rounded transition-colors",
3313
- l ? "bg-blue-100 text-blue-600" : "text-gray-600 hover:bg-gray-100"
3314
- ), o = () => {
3315
- const { from: l, to: d } = e.state.selection;
3316
- if (l === d) return;
3317
- const u = e.state.doc.textBetween(l, d, " "), m = on(e);
3313
+ o ? "bg-blue-100 text-blue-600" : "text-gray-600 hover:bg-gray-100"
3314
+ ), c = () => {
3315
+ const { from: o, to: d } = e.state.selection;
3316
+ if (o === d) return;
3317
+ const u = e.state.doc.textBetween(o, d, " "), m = on(e);
3318
3318
  if (t) {
3319
- t({ text: u, from: l, to: d, sectionType: m == null ? void 0 : m.sectionType });
3319
+ t({ text: u, from: o, to: d, sectionType: m == null ? void 0 : m.sectionType });
3320
3320
  return;
3321
3321
  }
3322
- n({ text: u, from: l, to: d, sectionType: m == null ? void 0 : m.sectionType }), r();
3323
- }, c = () => {
3324
- const l = e.getAttributes("link").href, d = window.prompt("URL", l || "https://");
3322
+ n({ text: u, from: o, to: d, sectionType: m == null ? void 0 : m.sectionType }), r();
3323
+ }, l = () => {
3324
+ const o = e.getAttributes("link").href, d = window.prompt("URL", o || "https://");
3325
3325
  d !== null && (d === "" ? e.chain().focus().extendMarkRange("link").unsetLink().run() : e.chain().focus().extendMarkRange("link").setLink({ href: d }).run());
3326
3326
  };
3327
3327
  return /* @__PURE__ */ g(
3328
3328
  Jr,
3329
3329
  {
3330
3330
  editor: e,
3331
- shouldShow: ({ editor: l, state: d }) => {
3331
+ shouldShow: ({ editor: o, state: d }) => {
3332
3332
  const { from: u, to: m } = d.selection;
3333
- return !(u === m || l.isActive("codeBlock"));
3333
+ return !(u === m || o.isActive("codeBlock"));
3334
3334
  },
3335
3335
  children: /* @__PURE__ */ L("div", { className: "bubble-menu", children: [
3336
3336
  /* @__PURE__ */ g(
@@ -3409,7 +3409,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3409
3409
  /* @__PURE__ */ g(
3410
3410
  "button",
3411
3411
  {
3412
- onClick: c,
3412
+ onClick: l,
3413
3413
  className: s(e.isActive("link")),
3414
3414
  title: "Link",
3415
3415
  children: /* @__PURE__ */ g(Ht, { size: 15 })
@@ -3419,7 +3419,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3419
3419
  /* @__PURE__ */ g(
3420
3420
  "button",
3421
3421
  {
3422
- onClick: o,
3422
+ onClick: c,
3423
3423
  className: "p-1.5 rounded transition-colors text-purple-500 hover:bg-purple-50",
3424
3424
  title: i ? "AI 优化" : "AI Optimize",
3425
3425
  children: /* @__PURE__ */ g(Hr, { size: 15 })
@@ -3429,36 +3429,36 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3429
3429
  }
3430
3430
  );
3431
3431
  }, ri = ({ editor: e }) => {
3432
- var w;
3433
- const [t, n] = F(!1), [r, a] = F(!1), [i, s] = F(""), [o, c] = F(""), [l, d] = F(!1), u = W(null), m = e.extensionStorage.searchReplace, f = ((w = m == null ? void 0 : m.results) == null ? void 0 : w.length) ?? 0, p = (m == null ? void 0 : m.currentIndex) ?? -1;
3432
+ var T;
3433
+ const [t, n] = F(!1), [r, a] = F(!1), [i, s] = F(""), [c, l] = F(""), [o, d] = F(!1), u = W(null), m = e.extensionStorage.searchReplace, f = ((T = m == null ? void 0 : m.results) == null ? void 0 : T.length) ?? 0, p = (m == null ? void 0 : m.currentIndex) ?? -1;
3434
3434
  M(() => {
3435
- const T = (v) => {
3435
+ const v = (x) => {
3436
3436
  n(!0);
3437
- const E = v.detail;
3438
- E != null && E.replace && a(!0), requestAnimationFrame(() => {
3439
- var _;
3440
- return (_ = u.current) == null ? void 0 : _.focus();
3437
+ const S = x.detail;
3438
+ S != null && S.replace && a(!0), requestAnimationFrame(() => {
3439
+ var N;
3440
+ return (N = u.current) == null ? void 0 : N.focus();
3441
3441
  });
3442
3442
  };
3443
- return window.addEventListener("editor:toggleSearch", T), () => window.removeEventListener("editor:toggleSearch", T);
3443
+ return window.addEventListener("editor:toggleSearch", v), () => window.removeEventListener("editor:toggleSearch", v);
3444
3444
  }, []);
3445
- const h = ae(
3446
- (T) => {
3447
- s(T), e.commands.setSearchTerm(T);
3445
+ const b = ae(
3446
+ (v) => {
3447
+ s(v), e.commands.setSearchTerm(v);
3448
3448
  },
3449
3449
  [e]
3450
3450
  ), y = ae(() => {
3451
3451
  n(!1), e.commands.clearSearch(), e.commands.focus();
3452
3452
  }, [e]);
3453
3453
  M(() => {
3454
- const T = (v) => {
3455
- v.key === "Escape" && t && y();
3454
+ const v = (x) => {
3455
+ x.key === "Escape" && t && y();
3456
3456
  };
3457
- return window.addEventListener("keydown", T), () => window.removeEventListener("keydown", T);
3457
+ return window.addEventListener("keydown", v), () => window.removeEventListener("keydown", v);
3458
3458
  }, [t, y]);
3459
- const x = () => {
3460
- const T = !l;
3461
- d(T), e.commands.setCaseSensitive(T);
3459
+ const w = () => {
3460
+ const v = !o;
3461
+ d(v), e.commands.setCaseSensitive(v);
3462
3462
  };
3463
3463
  return t ? /* @__PURE__ */ L("div", { className: "find-replace-bar", children: [
3464
3464
  /* @__PURE__ */ L("div", { className: "find-replace-row", children: [
@@ -3469,9 +3469,9 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3469
3469
  ref: u,
3470
3470
  type: "text",
3471
3471
  value: i,
3472
- onChange: (T) => h(T.target.value),
3473
- onKeyDown: (T) => {
3474
- T.key === "Enter" && (T.shiftKey ? e.commands.previousSearchResult() : e.commands.nextSearchResult());
3472
+ onChange: (v) => b(v.target.value),
3473
+ onKeyDown: (v) => {
3474
+ v.key === "Enter" && (v.shiftKey ? e.commands.previousSearchResult() : e.commands.nextSearchResult());
3475
3475
  },
3476
3476
  placeholder: "Find...",
3477
3477
  className: "find-replace-input"
@@ -3482,8 +3482,8 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3482
3482
  /* @__PURE__ */ g(
3483
3483
  "button",
3484
3484
  {
3485
- onClick: x,
3486
- className: Y("find-replace-btn", l && "find-replace-btn--active"),
3485
+ onClick: w,
3486
+ className: Y("find-replace-btn", o && "find-replace-btn--active"),
3487
3487
  title: "Case Sensitive",
3488
3488
  children: /* @__PURE__ */ g(Ur, { size: 15 })
3489
3489
  }
@@ -3493,7 +3493,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3493
3493
  /* @__PURE__ */ g(
3494
3494
  "button",
3495
3495
  {
3496
- onClick: () => a((T) => !T),
3496
+ onClick: () => a((v) => !v),
3497
3497
  className: Y("find-replace-btn", r && "find-replace-btn--active"),
3498
3498
  title: "Toggle Replace",
3499
3499
  children: /* @__PURE__ */ g(gt, { size: 15 })
@@ -3506,12 +3506,12 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3506
3506
  "input",
3507
3507
  {
3508
3508
  type: "text",
3509
- value: o,
3510
- onChange: (T) => {
3511
- c(T.target.value), e.commands.setReplaceTerm(T.target.value);
3509
+ value: c,
3510
+ onChange: (v) => {
3511
+ l(v.target.value), e.commands.setReplaceTerm(v.target.value);
3512
3512
  },
3513
- onKeyDown: (T) => {
3514
- T.key === "Enter" && e.commands.replaceCurrent();
3513
+ onKeyDown: (v) => {
3514
+ v.key === "Enter" && e.commands.replaceCurrent();
3515
3515
  },
3516
3516
  placeholder: "Replace...",
3517
3517
  className: "find-replace-input"
@@ -3522,10 +3522,10 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3522
3522
  ] })
3523
3523
  ] }) : null;
3524
3524
  }, ai = ({ editor: e }) => {
3525
- const { editorLanguage: t } = N(), n = t === "zh", r = At(() => {
3526
- const a = e.state, s = a.doc.textBetween(0, a.doc.content.size, " ", "\0").replace(/\s/g, "").length, { from: o, to: c } = a.selection;
3527
- let l = 0;
3528
- return o !== c && (l = a.doc.textBetween(o, c, " ", "\0").replace(/\s/g, "").length), { charCount: s, selectionCount: l };
3525
+ const { editorLanguage: t } = I(), n = t === "zh", r = At(() => {
3526
+ const a = e.state, s = a.doc.textBetween(0, a.doc.content.size, " ", "\0").replace(/\s/g, "").length, { from: c, to: l } = a.selection;
3527
+ let o = 0;
3528
+ return c !== l && (o = a.doc.textBetween(c, l, " ", "\0").replace(/\s/g, "").length), { charCount: s, selectionCount: o };
3529
3529
  }, [e.state.doc, e.state.selection]);
3530
3530
  return /* @__PURE__ */ L("div", { className: "word-count-bar", children: [
3531
3531
  /* @__PURE__ */ L("span", { children: [
@@ -3551,108 +3551,108 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3551
3551
  "summary",
3552
3552
  "drawing_description",
3553
3553
  "detailed_description"
3554
- ]), ci = ({ editor: e }) => {
3555
- const { editorLanguage: t } = N(), n = H(t), [r, a] = F(!1), [i, s] = F(0);
3554
+ ]), ci = ({ editor: e, defaultCollapsed: t = !1 }) => {
3555
+ const { editorLanguage: n } = I(), r = H(n), [a, i] = F(t), [s, c] = F(0);
3556
3556
  M(() => {
3557
- const c = () => s((l) => l + 1);
3558
- return e.on("update", c), () => {
3559
- e.off("update", c);
3557
+ const o = () => c((d) => d + 1);
3558
+ return e.on("update", o), () => {
3559
+ e.off("update", o);
3560
3560
  };
3561
3561
  }, [e]);
3562
- const o = At(() => {
3563
- const c = [];
3564
- let l = !1;
3565
- return e.state.doc.descendants((d, u) => {
3566
- if (d.type.name === "patent_title") {
3567
- if (!l) {
3568
- const h = typeof n.bookTitle_description == "string" ? n.bookTitle_description : "说明书";
3569
- c.push({
3562
+ const l = At(() => {
3563
+ const o = [];
3564
+ let d = !1;
3565
+ return e.state.doc.descendants((u, m) => {
3566
+ if (u.type.name === "patent_title") {
3567
+ if (!d) {
3568
+ const y = typeof r.bookTitle_description == "string" ? r.bookTitle_description : "说明书";
3569
+ o.push({
3570
3570
  type: "book-group",
3571
- pos: u,
3572
- title: h,
3571
+ pos: m,
3572
+ title: y,
3573
3573
  charCount: 0
3574
- }), l = !0;
3574
+ }), d = !0;
3575
3575
  }
3576
- const m = d.textContent || "", f = m.trim().length > 0, p = typeof n.patentTitlePlaceholder == "string" ? n.patentTitlePlaceholder : "Patent Title";
3577
- return c.push({
3576
+ const f = u.textContent || "", p = f.trim().length > 0, b = typeof r.patentTitlePlaceholder == "string" ? r.patentTitlePlaceholder : "Patent Title";
3577
+ return o.push({
3578
3578
  type: "section",
3579
- pos: u,
3580
- title: f ? m.trim() : p,
3581
- state: f ? "filled" : "empty",
3582
- charCount: m.replace(/\s/g, "").length,
3579
+ pos: m,
3580
+ title: p ? f.trim() : b,
3581
+ state: p ? "filled" : "empty",
3582
+ charCount: f.replace(/\s/g, "").length,
3583
3583
  indent: !0
3584
3584
  }), !1;
3585
3585
  }
3586
- if (d.type.name === "patent_section") {
3587
- const m = d.attrs.sectionType, f = oi.has(m), p = `sectionTitle_${m}`, h = typeof n[p] == "string" ? n[p] : m, y = d.textContent || "", x = y.trim().length > 0;
3588
- return c.push({
3586
+ if (u.type.name === "patent_section") {
3587
+ const f = u.attrs.sectionType, p = oi.has(f), b = `sectionTitle_${f}`, y = typeof r[b] == "string" ? r[b] : f, w = u.textContent || "", T = w.trim().length > 0;
3588
+ return o.push({
3589
3589
  type: "section",
3590
- pos: u,
3591
- title: h,
3592
- state: x ? "filled" : "empty",
3593
- charCount: y.replace(/\s/g, "").length,
3594
- indent: f
3590
+ pos: m,
3591
+ title: y,
3592
+ state: T ? "filled" : "empty",
3593
+ charCount: w.replace(/\s/g, "").length,
3594
+ indent: p
3595
3595
  }), !1;
3596
3596
  }
3597
- if (d.type.name === "heading") {
3598
- const m = d.attrs.level, f = d.textContent || "";
3599
- return f.trim() && c.push({
3597
+ if (u.type.name === "heading") {
3598
+ const f = u.attrs.level, p = u.textContent || "";
3599
+ return p.trim() && o.push({
3600
3600
  type: "heading",
3601
- pos: u,
3602
- title: f,
3603
- level: m,
3604
- charCount: f.replace(/\s/g, "").length
3601
+ pos: m,
3602
+ title: p,
3603
+ level: f,
3604
+ charCount: p.replace(/\s/g, "").length
3605
3605
  }), !1;
3606
3606
  }
3607
3607
  return !0;
3608
- }), c;
3609
- }, [e, i, n]);
3610
- return r ? /* @__PURE__ */ g("div", { className: "outline-panel outline-panel--collapsed", children: /* @__PURE__ */ g(
3608
+ }), o;
3609
+ }, [e, s, r]);
3610
+ return a ? /* @__PURE__ */ g("div", { className: "outline-panel outline-panel--collapsed", children: /* @__PURE__ */ g(
3611
3611
  "button",
3612
3612
  {
3613
- onClick: () => a(!1),
3613
+ onClick: () => i(!1),
3614
3614
  className: "outline-panel-toggle",
3615
- title: t === "zh" ? "展开大纲" : "Expand Outline",
3615
+ title: n === "zh" ? "展开大纲" : "Expand Outline",
3616
3616
  children: /* @__PURE__ */ g(Gr, { size: 16 })
3617
3617
  }
3618
3618
  ) }) : /* @__PURE__ */ L("div", { className: "outline-panel", children: [
3619
3619
  /* @__PURE__ */ L("div", { className: "outline-panel-header", children: [
3620
3620
  /* @__PURE__ */ g(Ut, { size: 14 }),
3621
- /* @__PURE__ */ g("span", { children: t === "zh" ? "文档大纲" : "Outline" }),
3621
+ /* @__PURE__ */ g("span", { children: n === "zh" ? "文档大纲" : "Outline" }),
3622
3622
  /* @__PURE__ */ g(
3623
3623
  "button",
3624
3624
  {
3625
- onClick: () => a(!0),
3625
+ onClick: () => i(!0),
3626
3626
  className: "outline-panel-toggle ml-auto",
3627
- title: t === "zh" ? "收起大纲" : "Collapse Outline",
3627
+ title: n === "zh" ? "收起大纲" : "Collapse Outline",
3628
3628
  children: /* @__PURE__ */ g(Vr, { size: 14 })
3629
3629
  }
3630
3630
  )
3631
3631
  ] }),
3632
3632
  /* @__PURE__ */ L("div", { className: "outline-panel-list", children: [
3633
- o.length === 0 && /* @__PURE__ */ g("div", { className: "outline-panel-empty", children: t === "zh" ? "暂无章节" : "No sections yet" }),
3634
- o.map((c, l) => /* @__PURE__ */ L(
3633
+ l.length === 0 && /* @__PURE__ */ g("div", { className: "outline-panel-empty", children: n === "zh" ? "暂无章节" : "No sections yet" }),
3634
+ l.map((o, d) => /* @__PURE__ */ L(
3635
3635
  "button",
3636
3636
  {
3637
3637
  className: Y(
3638
3638
  "outline-panel-item",
3639
- c.type === "heading" && `outline-panel-item--h${c.level}`,
3640
- c.type === "book-group" && "outline-panel-item--book",
3641
- c.indent && "outline-panel-item--indent"
3639
+ o.type === "heading" && `outline-panel-item--h${o.level}`,
3640
+ o.type === "book-group" && "outline-panel-item--book",
3641
+ o.indent && "outline-panel-item--indent"
3642
3642
  ),
3643
3643
  onClick: () => {
3644
- c.type !== "book-group" && (e.chain().setTextSelection(c.pos + 1).focus().run(), requestAnimationFrame(() => {
3645
- const d = e.view.nodeDOM(c.pos);
3646
- d == null || d.scrollIntoView({ behavior: "smooth", block: "start" });
3644
+ o.type !== "book-group" && (e.chain().setTextSelection(o.pos + 1).focus().run(), requestAnimationFrame(() => {
3645
+ const u = e.view.nodeDOM(o.pos);
3646
+ u == null || u.scrollIntoView({ behavior: "smooth", block: "start" });
3647
3647
  }));
3648
3648
  },
3649
3649
  children: [
3650
- c.type === "section" && c.state && /* @__PURE__ */ g("span", { className: Y("outline-item-state", si[c.state]), children: ii[c.state] || "○" }),
3651
- /* @__PURE__ */ g("span", { className: "outline-item-title", children: c.title }),
3652
- c.type !== "book-group" && /* @__PURE__ */ g("span", { className: "outline-item-count", children: c.charCount })
3650
+ o.type === "section" && o.state && /* @__PURE__ */ g("span", { className: Y("outline-item-state", si[o.state]), children: ii[o.state] || "○" }),
3651
+ /* @__PURE__ */ g("span", { className: "outline-item-title", children: o.title }),
3652
+ o.type !== "book-group" && /* @__PURE__ */ g("span", { className: "outline-item-count", children: o.charCount })
3653
3653
  ]
3654
3654
  },
3655
- `${c.pos}-${l}`
3655
+ `${o.pos}-${d}`
3656
3656
  ))
3657
3657
  ] })
3658
3658
  ] });
@@ -3687,9 +3687,10 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3687
3687
  editable: a = !0,
3688
3688
  onEditorReady: i,
3689
3689
  onSelectionOptimize: s,
3690
- patchEditorId: o = "default"
3690
+ patchEditorId: c = "default",
3691
+ defaultOutlineCollapsed: l = !1
3691
3692
  }) => {
3692
- const { setEditor: c, setDocument: l, editorLanguage: d, autoSaveStatus: u, ai: m } = N(), { setAutoSaveStatus: f, setLastSavedAt: p } = N(), h = W(null), y = e || (t ? null : ui()) || {
3693
+ const { setEditor: o, setDocument: d, editorLanguage: u, autoSaveStatus: m, ai: f } = I(), { setAutoSaveStatus: p, setLastSavedAt: b } = I(), y = W(null), w = e || (t ? null : ui()) || {
3693
3694
  type: "doc",
3694
3695
  content: [
3695
3696
  {
@@ -3697,69 +3698,69 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
3697
3698
  content: [{ type: "text", text: "" }]
3698
3699
  }
3699
3700
  ]
3700
- }, x = ae((_) => {
3701
+ }, T = ae((h) => {
3701
3702
  try {
3702
- f("saving"), localStorage.setItem(cn, JSON.stringify(_)), f("saved"), p(/* @__PURE__ */ new Date());
3703
+ p("saving"), localStorage.setItem(cn, JSON.stringify(h)), p("saved"), b(/* @__PURE__ */ new Date());
3703
3704
  } catch {
3704
- f("error");
3705
+ p("error");
3705
3706
  }
3706
- }, [f, p]), w = Nn(
3707
+ }, [p, b]), v = Nn(
3707
3708
  Ka({
3708
- extensions: [fa.configure({ editorId: o })],
3709
- content: y,
3710
- onUpdate: ({ editor: _ }) => {
3711
- const b = _.getJSON();
3712
- l(b), B.notifyStateChange(_), t && t(b), t || (h.current && clearTimeout(h.current), h.current = setTimeout(() => {
3713
- x(b);
3709
+ extensions: [fa.configure({ editorId: c })],
3710
+ content: w,
3711
+ onUpdate: ({ editor: h }) => {
3712
+ const C = h.getJSON();
3713
+ d(C), B.notifyStateChange(h), t && t(C), t || (y.current && clearTimeout(y.current), y.current = setTimeout(() => {
3714
+ T(C);
3714
3715
  }, di));
3715
3716
  },
3716
- onCreate: ({ editor: _ }) => {
3717
- c(_), i == null || i(_), B.initializePlugins(_), B.notifyStateChange(_);
3717
+ onCreate: ({ editor: h }) => {
3718
+ o(h), i == null || i(h), B.initializePlugins(h), B.notifyStateChange(h);
3718
3719
  },
3719
- onSelectionUpdate: ({ editor: _ }) => {
3720
- B.notifySelectionChange(_);
3720
+ onSelectionUpdate: ({ editor: h }) => {
3721
+ B.notifySelectionChange(h);
3721
3722
  },
3722
3723
  editorProps: {
3723
3724
  attributes: {
3724
- class: "prose prose-sm sm:prose lg:prose-lg xl:prose-2xl mx-auto focus:outline-none"
3725
+ class: "prose prose-sm sm:prose lg:prose-lg xl:prose-2xl max-w-none focus:outline-none"
3725
3726
  }
3726
3727
  }
3727
3728
  })
3728
- ), T = W(!1);
3729
+ ), x = W(!1);
3729
3730
  if (M(() => {
3730
- if (!(!w || !e)) {
3731
- if (!T.current) {
3732
- T.current = !0;
3731
+ if (!(!v || !e)) {
3732
+ if (!x.current) {
3733
+ x.current = !0;
3733
3734
  return;
3734
3735
  }
3735
- w.commands.setContent(e);
3736
+ v.commands.setContent(e);
3736
3737
  }
3737
- }, [w, e]), M(() => () => {
3738
- h.current && clearTimeout(h.current), w && (c(null), B.destroyPlugins(w), w.destroy());
3739
- }, [w, c]), M(() => {
3740
- !w || w.isDestroyed || B.notifyStateChange(w);
3741
- }, [w, d]), !w)
3738
+ }, [v, e]), M(() => () => {
3739
+ y.current && clearTimeout(y.current), v && (o(null), B.destroyPlugins(v), v.destroy());
3740
+ }, [v, o]), M(() => {
3741
+ !v || v.isDestroyed || B.notifyStateChange(v);
3742
+ }, [v, u]), !v)
3742
3743
  return null;
3743
- const v = H(d), E = u === "saving" ? v.autoSaveSaving : u === "saved" ? v.autoSaveSaved : u === "error" ? v.autoSaveError : "";
3744
+ const S = H(u), N = m === "saving" ? S.autoSaveSaving : m === "saved" ? S.autoSaveSaved : m === "error" ? S.autoSaveError : "";
3744
3745
  return /* @__PURE__ */ L("div", { className: `editor-container flex flex-col h-full ${n}`, children: [
3745
3746
  !r && /* @__PURE__ */ L("div", { className: "flex items-center", children: [
3746
- /* @__PURE__ */ g(Za, { editor: w }),
3747
- E && /* @__PURE__ */ g("span", { className: `auto-save-indicator auto-save-indicator--${u} ml-2`, children: E })
3747
+ /* @__PURE__ */ g(Za, { editor: v }),
3748
+ N && /* @__PURE__ */ g("span", { className: `auto-save-indicator auto-save-indicator--${m} ml-2`, children: N })
3748
3749
  ] }),
3749
- !r && w && /* @__PURE__ */ g(Qa, { editor: w }),
3750
- !r && w && /* @__PURE__ */ g(ni, { editor: w, onSelectionOptimize: s }),
3751
- !r && w && /* @__PURE__ */ g(ri, { editor: w }),
3750
+ !r && v && /* @__PURE__ */ g(Qa, { editor: v }),
3751
+ !r && v && /* @__PURE__ */ g(ni, { editor: v, onSelectionOptimize: s }),
3752
+ !r && v && /* @__PURE__ */ g(ri, { editor: v }),
3752
3753
  /* @__PURE__ */ L("div", { className: "flex flex-1 overflow-hidden", children: [
3753
- !r && w && /* @__PURE__ */ g(ci, { editor: w }),
3754
+ !r && v && /* @__PURE__ */ g(ci, { editor: v, defaultCollapsed: l }),
3754
3755
  /* @__PURE__ */ g("div", { className: "flex-1 overflow-y-auto bg-white p-4 relative", children: /* @__PURE__ */ g(
3755
3756
  li,
3756
3757
  {
3757
- editor: w,
3758
- mode: r || !a || m.status === "streaming" && m.activeSectionType === "claims" ? "readonly" : "edit"
3758
+ editor: v,
3759
+ mode: r || !a || f.status === "streaming" && f.activeSectionType === "claims" ? "readonly" : "edit"
3759
3760
  }
3760
3761
  ) })
3761
3762
  ] }),
3762
- !r && /* @__PURE__ */ g(ai, { editor: w })
3763
+ !r && /* @__PURE__ */ g(ai, { editor: v })
3763
3764
  ] });
3764
3765
  };
3765
3766
  function ln(e) {
@@ -3769,19 +3770,19 @@ function ln(e) {
3769
3770
  async pull(a) {
3770
3771
  var i;
3771
3772
  for (; ; ) {
3772
- const { done: s, value: o } = await t.read();
3773
+ const { done: s, value: c } = await t.read();
3773
3774
  if (s) {
3774
3775
  a.close();
3775
3776
  return;
3776
3777
  }
3777
- r += n.decode(o, { stream: !0 });
3778
- const c = r.split(`
3778
+ r += n.decode(c, { stream: !0 });
3779
+ const l = r.split(`
3779
3780
  `);
3780
- r = c.pop() || "";
3781
- let l = "";
3782
- for (const d of c) {
3781
+ r = l.pop() || "";
3782
+ let o = "";
3783
+ for (const d of l) {
3783
3784
  if (d.startsWith("event: ")) {
3784
- l = d.slice(7).trim();
3785
+ o = d.slice(7).trim();
3785
3786
  continue;
3786
3787
  }
3787
3788
  if (!d.startsWith("data: ")) continue;
@@ -3791,7 +3792,7 @@ function ln(e) {
3791
3792
  return;
3792
3793
  }
3793
3794
  try {
3794
- const m = JSON.parse(u), f = l || m.type;
3795
+ const m = JSON.parse(u), f = o || m.type;
3795
3796
  if (f === "delta" || !f && m.content != null)
3796
3797
  a.enqueue({
3797
3798
  type: "delta",
@@ -3805,7 +3806,7 @@ function ln(e) {
3805
3806
  } else f === "error" && a.enqueue({ type: "error", message: m.message || "Unknown error" });
3806
3807
  } catch {
3807
3808
  }
3808
- l = "";
3809
+ o = "";
3809
3810
  }
3810
3811
  }
3811
3812
  },
@@ -3840,28 +3841,28 @@ function fi(e, t) {
3840
3841
  let n = null;
3841
3842
  const r = e.replace(/\/+$/, "");
3842
3843
  async function a(i, s) {
3843
- const o = await fetch(i, {
3844
+ const c = await fetch(i, {
3844
3845
  ...s,
3845
3846
  headers: { "Content-Type": "application/json", ...t, ...s == null ? void 0 : s.headers }
3846
3847
  });
3847
- if (!o.ok) throw new Error(`Chat API error: ${o.status} ${o.statusText}`);
3848
- const c = await o.json();
3849
- return c.data ?? c;
3848
+ if (!c.ok) throw new Error(`Chat API error: ${c.status} ${c.statusText}`);
3849
+ const l = await c.json();
3850
+ return l.data ?? l;
3850
3851
  }
3851
3852
  return {
3852
- async createSession(i, s, o) {
3853
+ async createSession(i, s, c) {
3853
3854
  return a(`${r}/api/v1/chat/sessions`, {
3854
3855
  method: "POST",
3855
- body: JSON.stringify({ patentId: i, title: s, language: o })
3856
+ body: JSON.stringify({ patentId: i, title: s, language: c })
3856
3857
  });
3857
3858
  },
3858
- async listSessions(i, s = 1, o = 20) {
3859
- const c = new URLSearchParams({ page: String(s), pageSize: String(o) });
3860
- return i && c.set("patentId", i), a(`${r}/api/v1/chat/sessions?${c}`);
3859
+ async listSessions(i, s = 1, c = 20) {
3860
+ const l = new URLSearchParams({ page: String(s), pageSize: String(c) });
3861
+ return i && l.set("patentId", i), a(`${r}/api/v1/chat/sessions?${l}`);
3861
3862
  },
3862
- async getMessages(i, s = 1, o = 50) {
3863
- const c = new URLSearchParams({ page: String(s), pageSize: String(o) });
3864
- return a(`${r}/api/v1/chat/sessions/${i}/messages?${c}`);
3863
+ async getMessages(i, s = 1, c = 50) {
3864
+ const l = new URLSearchParams({ page: String(s), pageSize: String(c) });
3865
+ return a(`${r}/api/v1/chat/sessions/${i}/messages?${l}`);
3865
3866
  },
3866
3867
  async deleteSession(i) {
3867
3868
  await fetch(`${r}/api/v1/chat/sessions/${i}`, {
@@ -3877,13 +3878,13 @@ function fi(e, t) {
3877
3878
  },
3878
3879
  async subscribeStream(i, s) {
3879
3880
  n = new AbortController();
3880
- const o = `${r}/api/v1/chat/sessions/${i}/stream?messageId=${s}`, c = await fetch(o, {
3881
+ const c = `${r}/api/v1/chat/sessions/${i}/stream?messageId=${s}`, l = await fetch(c, {
3881
3882
  headers: { Accept: "text/event-stream", ...t },
3882
3883
  signal: n.signal
3883
3884
  });
3884
- if (!c.ok) throw new Error(`Chat stream error: ${c.status} ${c.statusText}`);
3885
- if (!c.body) throw new Error("Chat stream returned no body");
3886
- return ln(c.body);
3885
+ if (!l.ok) throw new Error(`Chat stream error: ${l.status} ${l.statusText}`);
3886
+ if (!l.body) throw new Error("Chat stream returned no body");
3887
+ return ln(l.body);
3887
3888
  },
3888
3889
  abort() {
3889
3890
  n == null || n.abort(), n = null;
@@ -3891,71 +3892,72 @@ function fi(e, t) {
3891
3892
  };
3892
3893
  }
3893
3894
  const pi = It(
3894
- ({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, editable: i = !0, language: s, aiService: o, chatSessionAPI: c, aiBaseUrl: l, aiHeaders: d, onSelectionOptimize: u, patchEditorId: m }, f) => {
3895
- const { setEditorLanguage: p, setAIService: h, setChatSessionAPI: y } = N(), x = W(null), w = ae((v) => {
3896
- x.current = v;
3897
- }, []), T = Ee.useMemo(() => {
3895
+ ({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, editable: i = !0, language: s, aiService: c, chatSessionAPI: l, aiBaseUrl: o, aiHeaders: d, onSelectionOptimize: u, patchEditorId: m, defaultOutlineCollapsed: f }, p) => {
3896
+ const { setEditorLanguage: b, setAIService: y, setChatSessionAPI: w } = I(), T = W(null), v = ae((S) => {
3897
+ T.current = S;
3898
+ }, []), x = Ee.useMemo(() => {
3898
3899
  if (e) return e;
3899
3900
  if (t) return tn(t);
3900
3901
  }, [e, t]);
3901
3902
  return Ee.useEffect(() => {
3902
- s && p(s);
3903
- }, [s, p]), Ee.useEffect(() => {
3904
- o ? h(o) : l && h(gi(l, d));
3905
- }, [o, l, d, h]), Ee.useEffect(() => {
3906
- c ? y(c) : l && y(fi(l, d));
3907
- }, [c, l, d, y]), Nt(f, () => ({
3903
+ s && b(s);
3904
+ }, [s, b]), Ee.useEffect(() => {
3905
+ c ? y(c) : o && y(gi(o, d));
3906
+ }, [c, o, d, y]), Ee.useEffect(() => {
3907
+ l ? w(l) : o && w(fi(o, d));
3908
+ }, [l, o, d, w]), Nt(p, () => ({
3908
3909
  getContent: () => {
3909
- var v;
3910
- return ((v = x.current) == null ? void 0 : v.getJSON()) ?? null;
3910
+ var S;
3911
+ return ((S = T.current) == null ? void 0 : S.getJSON()) ?? null;
3911
3912
  },
3912
- setContent: (v) => {
3913
- var E;
3914
- (E = x.current) == null || E.commands.setContent(v);
3913
+ setContent: (S) => {
3914
+ var N;
3915
+ (N = T.current) == null || N.commands.setContent(S);
3915
3916
  },
3916
- getEditor: () => x.current,
3917
- execCommand: async (v, E) => x.current ? ct(x.current).execCommand(v, E) : null,
3917
+ getEditor: () => T.current,
3918
+ execCommand: async (S, N) => T.current ? ct(T.current).execCommand(S, N) : null,
3918
3919
  focus: () => {
3919
- var v;
3920
- (v = x.current) == null || v.commands.focus();
3920
+ var S;
3921
+ (S = T.current) == null || S.commands.focus();
3921
3922
  }
3922
3923
  })), /* @__PURE__ */ g(
3923
3924
  mi,
3924
3925
  {
3925
- initialContent: T,
3926
+ initialContent: x,
3926
3927
  onChange: n,
3927
- onEditorReady: w,
3928
+ onEditorReady: v,
3928
3929
  className: r,
3929
3930
  readOnly: a,
3930
3931
  editable: i,
3931
3932
  onSelectionOptimize: u,
3932
- patchEditorId: m
3933
+ patchEditorId: m,
3934
+ defaultOutlineCollapsed: f
3933
3935
  }
3934
3936
  );
3935
3937
  }
3936
3938
  );
3937
3939
  pi.displayName = "PatentEditor";
3938
3940
  async function Ws(e, t, n) {
3939
- var a, i, s, o;
3941
+ var a, i, s, c;
3940
3942
  let r = !1;
3941
3943
  (a = n.onStart) == null || a.call(n), n.mode === "section" && typeof n.targetSectionPos == "number" && un(e, n.targetSectionPos);
3942
3944
  try {
3943
- let c = dn(e, n);
3945
+ let l = dn(e, n);
3944
3946
  for (; ; ) {
3945
- const { done: l, value: d } = await t.read();
3946
- if (l) break;
3947
+ const { done: o, value: d } = await t.read();
3948
+ if (o) break;
3947
3949
  if (!d) continue;
3948
3950
  (i = n.onChunk) == null || i.call(n, d);
3949
- const u = e.state.tr.insertText(d, c);
3950
- e.view.dispatch(u), c = u.mapping.map(c, 1);
3951
+ const u = e.state.tr.insertText(d, l);
3952
+ e.view.dispatch(u), l = u.mapping.map(l, 1);
3951
3953
  }
3952
3954
  n.mode === "section" && typeof n.targetSectionPos == "number" && nt(e, n.targetSectionPos), (s = n.onComplete) == null || s.call(n);
3953
- } catch (c) {
3954
- (o = n.onError) == null || o.call(n, c instanceof Error ? c : new Error(String(c)));
3955
+ } catch (l) {
3956
+ (c = n.onError) == null || c.call(n, l instanceof Error ? l : new Error(String(l)));
3955
3957
  }
3956
3958
  }
3957
3959
  async function js(e, t, n, r) {
3958
- var i, s, o, c, l, d, u, m;
3960
+ var i, s, c, l, o, d, u, m;
3959
3961
  const a = new AbortController();
3960
3962
  (i = r.onStart) == null || i.call(r), r.mode === "section" && typeof r.targetSectionPos == "number" && un(e, r.targetSectionPos);
3961
3963
  try {
@@ -3969,26 +3971,26 @@ async function js(e, t, n, r) {
3969
3971
  throw new Error(`HTTP ${f.status}: ${f.statusText}`);
3970
3972
  const p = (s = f.body) == null ? void 0 : s.getReader();
3971
3973
  if (!p) throw new Error("No response body");
3972
- const h = new TextDecoder();
3973
- let y = dn(e, r), x = "";
3974
+ const b = new TextDecoder();
3975
+ let y = dn(e, r), w = "";
3974
3976
  for (; ; ) {
3975
- const { done: w, value: T } = await p.read();
3976
- if (w) break;
3977
- x += h.decode(T, { stream: !0 });
3978
- const v = x.split(`
3977
+ const { done: T, value: v } = await p.read();
3978
+ if (T) break;
3979
+ w += b.decode(v, { stream: !0 });
3980
+ const x = w.split(`
3979
3981
  `);
3980
- x = v.pop() || "";
3981
- for (const E of v) {
3982
- if (!E.startsWith("data: ")) continue;
3983
- const _ = E.slice(6).trim();
3984
- if (_ === "[DONE]")
3985
- return r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (o = r.onComplete) == null || o.call(r), { abort: () => a.abort() };
3982
+ w = x.pop() || "";
3983
+ for (const S of x) {
3984
+ if (!S.startsWith("data: ")) continue;
3985
+ const N = S.slice(6).trim();
3986
+ if (N === "[DONE]")
3987
+ return r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (c = r.onComplete) == null || c.call(r), { abort: () => a.abort() };
3986
3988
  try {
3987
- const b = JSON.parse(_), C = b.content || b.text || ((c = b.delta) == null ? void 0 : c.content) || "";
3989
+ const h = JSON.parse(N), C = h.content || h.text || ((l = h.delta) == null ? void 0 : l.content) || "";
3988
3990
  if (!C) continue;
3989
- (l = r.onChunk) == null || l.call(r, C);
3990
- const I = e.state.tr.insertText(C, y);
3991
- e.view.dispatch(I), y = I.mapping.map(y, 1);
3991
+ (o = r.onChunk) == null || o.call(r, C);
3992
+ const _ = e.state.tr.insertText(C, y);
3993
+ e.view.dispatch(_), y = _.mapping.map(y, 1);
3992
3994
  } catch {
3993
3995
  }
3994
3996
  }
@@ -4021,18 +4023,18 @@ function nt(e, t) {
4021
4023
  if (!n || n.type.name !== "patent_section") return;
4022
4024
  const r = e.state.tr, a = [];
4023
4025
  let i = t + 1, s = 0;
4024
- n.forEach((c) => {
4026
+ n.forEach((l) => {
4025
4027
  s++;
4026
4028
  });
4027
- let o = 0;
4028
- if (n.forEach((c) => {
4029
- c.type.name === "paragraph" && c.textContent.trim().length > 0 && o++;
4030
- }), i = t + 1, n.forEach((c) => {
4031
- const l = i, d = i + c.nodeSize;
4032
- c.type.name === "paragraph" && c.textContent.trim().length === 0 && (o > 0 || a.length < s - 1) && a.push({ from: l, to: d }), i = d;
4029
+ let c = 0;
4030
+ if (n.forEach((l) => {
4031
+ l.type.name === "paragraph" && l.textContent.trim().length > 0 && c++;
4032
+ }), i = t + 1, n.forEach((l) => {
4033
+ const o = i, d = i + l.nodeSize;
4034
+ l.type.name === "paragraph" && l.textContent.trim().length === 0 && (c > 0 || a.length < s - 1) && a.push({ from: o, to: d }), i = d;
4033
4035
  }), a.length !== 0) {
4034
- for (let c = a.length - 1; c >= 0; c--)
4035
- r.delete(a[c].from, a[c].to);
4036
+ for (let l = a.length - 1; l >= 0; l--)
4037
+ r.delete(a[l].from, a[l].to);
4036
4038
  r.setMeta("addToHistory", !1), e.view.dispatch(r);
4037
4039
  }
4038
4040
  }
@@ -4205,27 +4207,27 @@ function yi(e, t, n) {
4205
4207
  ` : `Analyzing ${t.length} referenced text(s) and generating suggestions...
4206
4208
 
4207
4209
  `;
4208
- for (const o of $e(s, 4))
4209
- a.push({ type: "delta", content: o });
4210
- for (const o of $e(i, 4))
4211
- a.push({ type: "delta", content: o });
4212
- for (let o = 0; o < t.length; o++) {
4213
- const c = t[o], l = c.text;
4210
+ for (const c of $e(s, 4))
4211
+ a.push({ type: "delta", content: c });
4212
+ for (const c of $e(i, 4))
4213
+ a.push({ type: "delta", content: c });
4214
+ for (let c = 0; c < t.length; c++) {
4215
+ const l = t[c], o = l.text;
4214
4216
  let d;
4215
- r ? (d = l.replace(/一种/g, "一种基于本发明的").replace(/方法/g, "技术方案").replace(/包括/g, "具体包括"), d === l && (d = `根据本发明优选实施例,${l}`)) : d = `According to a preferred embodiment, ${l.charAt(0).toLowerCase()}${l.slice(1)}`, c.from != null && c.to != null ? a.push({
4217
+ r ? (d = o.replace(/一种/g, "一种基于本发明的").replace(/方法/g, "技术方案").replace(/包括/g, "具体包括"), d === o && (d = `根据本发明优选实施例,${o}`)) : d = `According to a preferred embodiment, ${o.charAt(0).toLowerCase()}${o.slice(1)}`, l.from != null && l.to != null ? a.push({
4216
4218
  type: "patch",
4217
4219
  patch: {
4218
4220
  op: "replace",
4219
- target: { type: "ref", refIndex: o },
4221
+ target: { type: "ref", refIndex: c },
4220
4222
  content: d,
4221
4223
  reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
4222
4224
  }
4223
- }) : c.source ? a.push({
4225
+ }) : l.source ? a.push({
4224
4226
  type: "patch",
4225
4227
  patch: {
4226
4228
  op: "replace",
4227
- target: { type: "section", sectionType: c.source },
4228
- search: l,
4229
+ target: { type: "section", sectionType: l.source },
4230
+ search: o,
4229
4231
  content: d,
4230
4232
  reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
4231
4233
  }
@@ -4233,7 +4235,7 @@ function yi(e, t, n) {
4233
4235
  type: "patch",
4234
4236
  patch: {
4235
4237
  op: "replace",
4236
- target: { type: "search", searchText: l },
4238
+ target: { type: "search", searchText: o },
4237
4239
  content: d,
4238
4240
  reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
4239
4241
  }
@@ -4248,10 +4250,10 @@ function Gs() {
4248
4250
  let e = null;
4249
4251
  return {
4250
4252
  async request(t) {
4251
- var o;
4253
+ var c;
4252
4254
  if (e = new AbortController(), await te(300), e.signal.aborted)
4253
4255
  throw new DOMException("Aborted", "AbortError");
4254
- const n = t.language === "zh" ? "zh" : "en", r = t.sectionType || "technical_field", a = ((o = Tt[r]) == null ? void 0 : o[n]) || Tt.technical_field[n];
4256
+ const n = t.language === "zh" ? "zh" : "en", r = t.sectionType || "technical_field", a = ((c = Tt[r]) == null ? void 0 : c[n]) || Tt.technical_field[n];
4255
4257
  let i = a;
4256
4258
  t.instruction && (i = (n === "zh" ? `[基于指令"${t.instruction}"生成]
4257
4259
 
@@ -4272,7 +4274,7 @@ function Vs() {
4272
4274
  return {
4273
4275
  async createSession(r, a, i) {
4274
4276
  await te(100);
4275
- const s = `sess_${Date.now()}`, o = {
4277
+ const s = `sess_${Date.now()}`, c = {
4276
4278
  sessionId: s,
4277
4279
  patentId: r || void 0,
4278
4280
  title: a || (i === "zh" ? "新对话" : "New Chat"),
@@ -4280,7 +4282,7 @@ function Vs() {
4280
4282
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4281
4283
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
4282
4284
  };
4283
- return e.set(s, { session: o, messages: [] }), o;
4285
+ return e.set(s, { session: c, messages: [] }), c;
4284
4286
  },
4285
4287
  async listSessions() {
4286
4288
  await te(50);
@@ -4309,12 +4311,12 @@ function Vs() {
4309
4311
  status: "done",
4310
4312
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4311
4313
  }), i.session.messageCount = i.messages.length, i.session.lastMessage = a.content, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
4312
- const o = yi(
4314
+ const c = yi(
4313
4315
  a.content,
4314
4316
  a.references || [],
4315
4317
  a.language
4316
4318
  );
4317
- return n = { messageId: s, events: o }, { messageId: s, sessionId: r, status: "processing" };
4319
+ return n = { messageId: s, events: c }, { messageId: s, sessionId: r, status: "processing" };
4318
4320
  },
4319
4321
  async subscribeStream(r, a) {
4320
4322
  t = new AbortController(), await te(100);
@@ -4324,17 +4326,17 @@ function Vs() {
4324
4326
  return rt([{ type: "done" }]);
4325
4327
  const s = n.events;
4326
4328
  n = null;
4327
- const o = rt(s, 18), c = `${a}_a`;
4328
- let l = "";
4329
+ const c = rt(s, 18), l = `${a}_a`;
4330
+ let o = "";
4329
4331
  for (const d of s)
4330
- d.type === "delta" && (l += d.content);
4332
+ d.type === "delta" && (o += d.content);
4331
4333
  return i.messages.push({
4332
- messageId: c,
4334
+ messageId: l,
4333
4335
  role: "assistant",
4334
- content: l,
4336
+ content: o,
4335
4337
  status: "done",
4336
4338
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4337
- }), i.session.messageCount = i.messages.length, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), o;
4339
+ }), i.session.messageCount = i.messages.length, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), c;
4338
4340
  },
4339
4341
  abort() {
4340
4342
  t == null || t.abort(), t = null;
@@ -4356,8 +4358,8 @@ function bi(e) {
4356
4358
  if (a.length === 0)
4357
4359
  return t.push({ number: 1, text: n, dependsOn: [] }), t;
4358
4360
  for (let s = 0; s < a.length; s++) {
4359
- const o = a[s].index + a[s].matchLength, c = s + 1 < a.length ? a[s + 1].index : n.length, l = n.slice(o, c).trim(), d = a[s].number, u = vi(l, d);
4360
- t.push({ number: d, text: l, dependsOn: u });
4361
+ const c = a[s].index + a[s].matchLength, l = s + 1 < a.length ? a[s + 1].index : n.length, o = n.slice(c, l).trim(), d = a[s].number, u = vi(o, d);
4362
+ t.push({ number: d, text: o, dependsOn: u });
4361
4363
  }
4362
4364
  return t;
4363
4365
  }
@@ -4365,17 +4367,17 @@ function vi(e, t) {
4365
4367
  const n = [], r = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g;
4366
4368
  let a;
4367
4369
  for (; (a = r.exec(e)) !== null; ) {
4368
- const s = parseInt(a[1], 10), o = a[2] ? parseInt(a[2], 10) : s;
4369
- for (let c = s; c <= o; c++)
4370
- c !== t && c > 0 && n.push(c);
4370
+ const s = parseInt(a[1], 10), c = a[2] ? parseInt(a[2], 10) : s;
4371
+ for (let l = s; l <= c; l++)
4372
+ l !== t && l > 0 && n.push(l);
4371
4373
  }
4372
4374
  const i = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
4373
4375
  for (; (a = i.exec(e)) !== null; ) {
4374
- const s = parseInt(a[1], 10), o = a[2] ? parseInt(a[2], 10) : s;
4375
- for (let c = s; c <= o; c++)
4376
- c !== t && c > 0 && n.push(c);
4376
+ const s = parseInt(a[1], 10), c = a[2] ? parseInt(a[2], 10) : s;
4377
+ for (let l = s; l <= c; l++)
4378
+ l !== t && l > 0 && n.push(l);
4377
4379
  }
4378
- return [...new Set(n)].sort((s, o) => s - o);
4380
+ return [...new Set(n)].sort((s, c) => s - c);
4379
4381
  }
4380
4382
  function Js(e) {
4381
4383
  return bi(e).map((n) => ({
@@ -4392,52 +4394,52 @@ function Si(e, t, n) {
4392
4394
  const r = [];
4393
4395
  return e.nodesBetween(t, n, (a, i) => {
4394
4396
  if (a.isTextblock) {
4395
- const s = i + 1, o = i + a.nodeSize - 1, c = Math.max(s, t), l = Math.min(o, n);
4396
- return l > c && r.push({ from: c, to: l }), !1;
4397
+ const s = i + 1, c = i + a.nodeSize - 1, l = Math.max(s, t), o = Math.min(c, n);
4398
+ return o > l && r.push({ from: l, to: o }), !1;
4397
4399
  }
4398
4400
  return !0;
4399
4401
  }), r;
4400
4402
  }
4401
4403
  function Ks(e, t) {
4402
- const n = e.state.doc, r = n.content.size, { text: a, segments: i } = Gt(e, 0, r), s = Ti(), o = s.diff_main(t, a);
4403
- s.diff_cleanupSemantic(o);
4404
- const c = [];
4405
- let l = 0;
4406
- for (const [m, f] of o)
4404
+ const n = e.state.doc, r = n.content.size, { text: a, segments: i } = Gt(e, 0, r), s = Ti(), c = s.diff_main(t, a);
4405
+ s.diff_cleanupSemantic(c);
4406
+ const l = [];
4407
+ let o = 0;
4408
+ for (const [m, f] of c)
4407
4409
  if (m === Ci)
4408
- l += f.length;
4410
+ o += f.length;
4409
4411
  else if (m === xi) {
4410
4412
  let p = 0;
4411
4413
  for (; p < f.length; ) {
4412
4414
  for (; p < f.length && f[p] === "\0"; ) p++;
4413
4415
  if (p >= f.length) break;
4414
- const h = p;
4416
+ const b = p;
4415
4417
  for (; p < f.length && f[p] !== "\0"; ) p++;
4416
- const y = ye(i, l + h), x = ye(i, l + p);
4417
- if (y >= 0 && x >= 0 && x > y)
4418
- for (const w of Si(n, y, x))
4419
- c.push(
4420
- re.inline(w.from, w.to, { class: "patch-diff-insert-inline" })
4418
+ const y = ye(i, o + b), w = ye(i, o + p);
4419
+ if (y >= 0 && w >= 0 && w > y)
4420
+ for (const T of Si(n, y, w))
4421
+ l.push(
4422
+ re.inline(T.from, T.to, { class: "patch-diff-insert-inline" })
4421
4423
  );
4422
4424
  }
4423
- l += f.length;
4425
+ o += f.length;
4424
4426
  } else if (m === wi) {
4425
- const p = ye(i, l);
4427
+ const p = ye(i, o);
4426
4428
  if (p >= 0) {
4427
- const h = f.replace(/\0/g, " ");
4428
- c.push(
4429
+ const b = f.replace(/\0/g, " ");
4430
+ l.push(
4429
4431
  re.widget(
4430
4432
  p,
4431
4433
  () => {
4432
4434
  const y = document.createElement("span");
4433
- return y.className = "patch-diff-delete", y.textContent = h, y;
4435
+ return y.className = "patch-diff-delete", y.textContent = b, y;
4434
4436
  },
4435
4437
  { side: -1 }
4436
4438
  )
4437
4439
  );
4438
4440
  }
4439
4441
  }
4440
- const d = be.create(n, c), u = new Be({
4442
+ const d = be.create(n, l), u = new Be({
4441
4443
  key: at,
4442
4444
  state: {
4443
4445
  init: () => d,
@@ -4479,11 +4481,11 @@ function _i(e, t) {
4479
4481
  }), !1;
4480
4482
  }
4481
4483
  if (a.type.name === "patent_section") {
4482
- const i = a.attrs.sectionType, s = `sectionTitle_${i}`, o = typeof n[s] == "string" ? n[s] : i, c = [];
4483
- return a.forEach((l) => {
4484
- const d = l.textContent.trim();
4485
- d && c.push(d);
4486
- }), r.push({ type: "patent_section", sectionType: i, title: o, paragraphs: c }), !1;
4484
+ const i = a.attrs.sectionType, s = `sectionTitle_${i}`, c = typeof n[s] == "string" ? n[s] : i, l = [];
4485
+ return a.forEach((o) => {
4486
+ const d = o.textContent.trim();
4487
+ d && l.push(d);
4488
+ }), r.push({ type: "patent_section", sectionType: i, title: c, paragraphs: l }), !1;
4487
4489
  }
4488
4490
  return !0;
4489
4491
  }), r;
@@ -4548,7 +4550,7 @@ function Ni(e, t) {
4548
4550
  return r;
4549
4551
  }
4550
4552
  async function Ys(e, t) {
4551
- const n = _i(e, t), r = Ni(n, t), a = n.find((l) => l.type === "patent_title"), i = a != null && a.paragraphs[0] ? `${a.paragraphs[0]}.docx` : "patent-document.docx", s = {
4553
+ const n = _i(e, t), r = Ni(n, t), a = n.find((o) => o.type === "patent_title"), i = a != null && a.paragraphs[0] ? `${a.paragraphs[0]}.docx` : "patent-document.docx", s = {
4552
4554
  properties: {
4553
4555
  page: {
4554
4556
  margin: {
@@ -4560,10 +4562,10 @@ async function Ys(e, t) {
4560
4562
  }
4561
4563
  },
4562
4564
  children: r
4563
- }, o = new Kr({
4565
+ }, c = new Kr({
4564
4566
  sections: [s]
4565
- }), c = await Xr.toBlob(o);
4566
- Yr(c, i);
4567
+ }), l = await Xr.toBlob(c);
4568
+ Yr(l, i);
4567
4569
  }
4568
4570
  async function Zs(e) {
4569
4571
  window.print();
@@ -4572,65 +4574,65 @@ function Qs(e, t) {
4572
4574
  const n = [], r = t === "zh";
4573
4575
  let a = 0;
4574
4576
  const i = () => `v_${++a}`;
4575
- return e.state.doc.descendants((s, o) => {
4577
+ return e.state.doc.descendants((s, c) => {
4576
4578
  if (s.type.name === "patent_title") {
4577
- const c = s.textContent.trim();
4578
- if (c.length === 0)
4579
+ const l = s.textContent.trim();
4580
+ if (l.length === 0)
4579
4581
  n.push({
4580
4582
  id: i(),
4581
4583
  severity: "warning",
4582
4584
  message: r ? "专利名称为空" : "Patent title is empty",
4583
4585
  sectionType: "patent_title",
4584
- pos: o
4586
+ pos: c
4585
4587
  });
4586
4588
  else {
4587
- const l = c.replace(/\s/g, "").length;
4588
- l > 25 && r && n.push({
4589
+ const o = l.replace(/\s/g, "").length;
4590
+ o > 25 && r && n.push({
4589
4591
  id: i(),
4590
4592
  severity: "error",
4591
- message: `专利名称超过25个汉字(当前${l}字)`,
4593
+ message: `专利名称超过25个汉字(当前${o}字)`,
4592
4594
  sectionType: "patent_title",
4593
- pos: o
4595
+ pos: c
4594
4596
  });
4595
4597
  }
4596
4598
  return !1;
4597
4599
  }
4598
4600
  if (s.type.name === "patent_section") {
4599
- const c = s.attrs.sectionType, l = s.textContent.trim();
4600
- if (l.length === 0 && n.push({
4601
+ const l = s.attrs.sectionType, o = s.textContent.trim();
4602
+ if (o.length === 0 && n.push({
4601
4603
  id: i(),
4602
4604
  severity: "warning",
4603
- message: r ? `章节"${c}"内容为空` : `Section "${c}" is empty`,
4604
- sectionType: c,
4605
- pos: o
4606
- }), c === "abstract") {
4607
- const d = l.replace(/\s/g, "").length;
4605
+ message: r ? `章节"${l}"内容为空` : `Section "${l}" is empty`,
4606
+ sectionType: l,
4607
+ pos: c
4608
+ }), l === "abstract") {
4609
+ const d = o.replace(/\s/g, "").length;
4608
4610
  d > 0 && d < 50 && n.push({
4609
4611
  id: i(),
4610
4612
  severity: "warning",
4611
4613
  message: r ? `摘要字数过少(${d}字),建议50~300字` : `Abstract too short (${d} chars), recommend 50-300`,
4612
- sectionType: c,
4613
- pos: o
4614
+ sectionType: l,
4615
+ pos: c
4614
4616
  }), d > 300 && n.push({
4615
4617
  id: i(),
4616
4618
  severity: "warning",
4617
4619
  message: r ? `摘要字数过多(${d}字),建议不超过300字` : `Abstract too long (${d} chars), recommend ≤300`,
4618
- sectionType: c,
4619
- pos: o
4620
+ sectionType: l,
4621
+ pos: c
4620
4622
  });
4621
4623
  }
4622
- if (c === "claims") {
4624
+ if (l === "claims") {
4623
4625
  const d = /^(\d+)\s*[.、]/;
4624
4626
  s.forEach((u, m) => {
4625
4627
  if (u.type.name !== "paragraph") return;
4626
4628
  const f = u.textContent.trim(), p = d.exec(f);
4627
4629
  if (!p) return;
4628
- const h = p[1];
4630
+ const b = p[1];
4629
4631
  f.length > 0 && !f.endsWith("。") && !f.endsWith(".") && n.push({
4630
4632
  id: i(),
4631
4633
  severity: "warning",
4632
- message: r ? `权利要求${h}末尾应以句号结束` : `Claim ${h} should end with a period`,
4633
- pos: o + 1 + m
4634
+ message: r ? `权利要求${b}末尾应以句号结束` : `Claim ${b} should end with a period`,
4635
+ pos: c + 1 + m
4634
4636
  });
4635
4637
  });
4636
4638
  }
@@ -4687,13 +4689,13 @@ const mn = (e) => {
4687
4689
  if (!i) return !0;
4688
4690
  const s = parseInt(i[1], 10);
4689
4691
  if (!Number.isFinite(s) || s <= 0) return !0;
4690
- const o = a.slice(i[0].length).trim(), c = Li(o, s);
4692
+ const c = a.slice(i[0].length).trim(), l = Li(c, s);
4691
4693
  return t.push({
4692
4694
  claimId: `claim_${s}`,
4693
4695
  number: s,
4694
- dependsOn: c,
4695
- dependsOnClaimIds: c.map((l) => `claim_${l}`),
4696
- body: o,
4696
+ dependsOn: l,
4697
+ dependsOnClaimIds: l.map((o) => `claim_${o}`),
4698
+ body: c,
4697
4699
  pos: r
4698
4700
  }), !0;
4699
4701
  }), t;
@@ -4730,7 +4732,7 @@ export {
4730
4732
  Ds as resolvePatchTarget,
4731
4733
  sn as sectionContextDeps,
4732
4734
  Fs as setPatches,
4733
- N as useEditorStore,
4735
+ I as useEditorStore,
4734
4736
  Qs as validatePatentDocument,
4735
4737
  Ws as writeStream,
4736
4738
  js as writeStreamFromSSE