patent-editor 0.2.16 → 0.2.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib.js CHANGED
@@ -456,21 +456,47 @@ const ia = Oe.create({
456
456
  ];
457
457
  }
458
458
  });
459
+ function sa(e) {
460
+ let t = e;
461
+ for (; t && t !== document.body && t !== document.documentElement; ) {
462
+ const n = getComputedStyle(t).overflowY;
463
+ if ((n === "auto" || n === "scroll" || n === "overlay") && t.scrollHeight > t.clientHeight + 1)
464
+ return t;
465
+ t = t.parentElement;
466
+ }
467
+ return document.scrollingElement || document.documentElement;
468
+ }
459
469
  function ft(e, t) {
460
470
  if (!t) {
461
471
  e.view.dispatch(e.state.tr);
462
472
  return;
463
473
  }
464
474
  const n = e.state.doc.content.size, r = Math.min(Math.max(t.from, 0), n), a = Math.min(Math.max(t.to, r), n);
465
- e.chain().setTextSelection({ from: r, to: a }).scrollIntoView().run();
475
+ e.chain().setTextSelection({ from: r, to: a }).run(), requestAnimationFrame(() => {
476
+ const i = e.view;
477
+ let s;
478
+ try {
479
+ s = i.coordsAtPos(r);
480
+ } catch {
481
+ return;
482
+ }
483
+ const o = sa(i.dom), l = (s.top + s.bottom) / 2;
484
+ if (o === document.scrollingElement || o === document.documentElement) {
485
+ const g = window.scrollY + l - window.innerHeight / 2;
486
+ window.scrollTo({ top: Math.max(0, g), behavior: "smooth" });
487
+ return;
488
+ }
489
+ const c = o.getBoundingClientRect(), d = o.scrollTop + (l - c.top) - o.clientHeight / 2, m = o.scrollHeight - o.clientHeight;
490
+ o.scrollTo({ top: Math.max(0, Math.min(d, m)), behavior: "smooth" });
491
+ });
466
492
  }
467
- const sa = -1, oa = 1, pt = 0;
493
+ const oa = -1, ca = 1, pt = 0;
468
494
  let Ge = null;
469
- function ca() {
495
+ function la() {
470
496
  return Ge || (Ge = new Lt()), Ge;
471
497
  }
472
498
  const jt = new we("patchDiff");
473
- function la(e, t) {
499
+ function da(e, t) {
474
500
  let n = null;
475
501
  return e.state.doc.descendants((r, a) => n ? !1 : r.type.name === "patent_section" && r.attrs.sectionType === t ? (n = { from: a + 1, to: a + r.nodeSize - 1 }, !1) : !0), n;
476
502
  }
@@ -510,7 +536,7 @@ function ht(e, t, n, r, a) {
510
536
  }
511
537
  return null;
512
538
  }
513
- function Rs(e, t, n, r, a) {
539
+ function Ms(e, t, n, r, a) {
514
540
  const i = t.target;
515
541
  let s = null;
516
542
  const o = /* @__PURE__ */ new Set();
@@ -520,7 +546,7 @@ function Rs(e, t, n, r, a) {
520
546
  if (!i)
521
547
  t.from != null && t.to != null && (s = { from: t.from, to: t.to });
522
548
  else if (i.type === "section" && i.sectionType)
523
- s = la(e, i.sectionType);
549
+ s = da(e, i.sectionType);
524
550
  else if (i.type === "ref" && i.refIndex != null) {
525
551
  const d = n[i.refIndex];
526
552
  (d == null ? void 0 : d.from) != null && (d == null ? void 0 : d.to) != null && (s = { from: d.from, to: d.to });
@@ -545,7 +571,7 @@ function Rs(e, t, n, r, a) {
545
571
  }
546
572
  const G = /* @__PURE__ */ new Map();
547
573
  let De = [];
548
- function Ms(e) {
574
+ function Fs(e) {
549
575
  return De.push(e), () => {
550
576
  De = De.filter((t) => t !== e);
551
577
  };
@@ -553,16 +579,16 @@ function Ms(e) {
553
579
  function me() {
554
580
  De.forEach((e) => e());
555
581
  }
556
- function Fs(e = "default") {
582
+ function $s(e = "default") {
557
583
  return [...G.get(e) || []];
558
584
  }
559
- function $s(e, t = "default") {
585
+ function zs(e, t = "default") {
560
586
  G.set(t, e), me();
561
587
  }
562
- function zs(e = "default") {
588
+ function Os(e = "default") {
563
589
  G.delete(e), me();
564
590
  }
565
- function Os(e, t, n = "default") {
591
+ function Bs(e, t, n = "default") {
566
592
  const r = G.get(n) || [], a = r.find((o) => o.id === t);
567
593
  if (!a || a.status !== "pending") return !1;
568
594
  a.status = "accepted";
@@ -585,11 +611,11 @@ function Os(e, t, n = "default") {
585
611
  }
586
612
  return G.set(n, r.filter((o) => o.id !== t && o.status === "pending")), qe(e), me(), !0;
587
613
  }
588
- function Bs(e, t, n = "default") {
614
+ function Hs(e, t, n = "default") {
589
615
  const r = G.get(n) || [], a = r.find((i) => i.id === t);
590
616
  return !a || a.status !== "pending" ? !1 : (a.status = "rejected", G.set(n, r.filter((i) => i.id !== t)), qe(e), me(), !0);
591
617
  }
592
- function Hs(e, t = "default") {
618
+ function Us(e, t = "default") {
593
619
  const a = [...(G.get(t) || []).filter((s) => s.status === "pending")].sort((s, o) => o.from - s.from), { tr: i } = e.state;
594
620
  for (const s of a)
595
621
  if (s.type === "delete")
@@ -603,13 +629,13 @@ function Hs(e, t = "default") {
603
629
  i.insertText(s.content, s.from, s.to);
604
630
  e.view.dispatch(i), G.delete(t), qe(e), me();
605
631
  }
606
- function Us(e, t = "default") {
632
+ function qs(e, t = "default") {
607
633
  G.delete(t), qe(e), me();
608
634
  }
609
635
  function qe(e) {
610
636
  e.view.dispatch(e.state.tr.setMeta(jt, !0));
611
637
  }
612
- function da(e, t, n) {
638
+ function ua(e, t, n) {
613
639
  const r = [];
614
640
  return e.nodesBetween(t, n, (a, i) => {
615
641
  if (a.isTextblock) {
@@ -619,7 +645,7 @@ function da(e, t, n) {
619
645
  return !0;
620
646
  }), r;
621
647
  }
622
- function ua(e, t) {
648
+ function ma(e, t) {
623
649
  if (!t.originalText || !t.content) return null;
624
650
  try {
625
651
  const o = e.resolve(t.from), l = e.resolve(t.to);
@@ -627,7 +653,7 @@ function ua(e, t) {
627
653
  } catch {
628
654
  return null;
629
655
  }
630
- const n = ca(), r = n.diff_main(t.originalText, t.content);
656
+ const n = la(), r = n.diff_main(t.originalText, t.content);
631
657
  n.diff_cleanupSemantic(r);
632
658
  const a = r.filter(([o]) => o === pt).reduce((o, [, l]) => o + l.length, 0);
633
659
  if (t.originalText.length > 0 && a / t.originalText.length < 0.3) return null;
@@ -636,7 +662,7 @@ function ua(e, t) {
636
662
  for (const [o, l] of r)
637
663
  if (o === pt)
638
664
  s += l.length;
639
- else if (o === sa) {
665
+ else if (o === oa) {
640
666
  const c = s + l.length;
641
667
  i.push(
642
668
  ae.inline(s, c, {
@@ -644,7 +670,7 @@ function ua(e, t) {
644
670
  "data-patch-id": t.id
645
671
  })
646
672
  ), s = c;
647
- } else o === oa && i.push(
673
+ } else o === ca && i.push(
648
674
  ae.widget(s, () => {
649
675
  const c = document.createElement("span");
650
676
  return c.className = "patch-diff-insert-inline", c.textContent = l, c.setAttribute("data-patch-id", t.id), c;
@@ -652,7 +678,7 @@ function ua(e, t) {
652
678
  );
653
679
  return i;
654
680
  }
655
- function ma(e = "default") {
681
+ function ga(e = "default") {
656
682
  return new Be({
657
683
  key: jt,
658
684
  props: {
@@ -662,14 +688,14 @@ function ma(e = "default") {
662
688
  const r = [];
663
689
  for (const a of n) {
664
690
  if (a.type === "replace") {
665
- const i = ua(t.doc, a);
691
+ const i = ma(t.doc, a);
666
692
  if (i) {
667
693
  r.push(...i);
668
694
  continue;
669
695
  }
670
696
  }
671
697
  if (a.type === "delete" || a.type === "replace") {
672
- const i = da(t.doc, a.from, a.to);
698
+ const i = ua(t.doc, a.from, a.to);
673
699
  for (const s of i)
674
700
  r.push(
675
701
  ae.inline(s.from, s.to, {
@@ -715,7 +741,7 @@ function Jt(e, t) {
715
741
  );
716
742
  });
717
743
  }
718
- const ga = Q.create({
744
+ const fa = Q.create({
719
745
  name: "hardBreak",
720
746
  inline: !0,
721
747
  group: "inline",
@@ -736,7 +762,7 @@ const ga = Q.create({
736
762
  }
737
763
  };
738
764
  }
739
- }), fa = Oe.create({
765
+ }), pa = Oe.create({
740
766
  name: "dragDropUX",
741
767
  addProseMirrorPlugins() {
742
768
  return [
@@ -747,19 +773,19 @@ const ga = Q.create({
747
773
  Xn()
748
774
  ];
749
775
  }
750
- }), pa = Oe.create({
776
+ }), ha = Oe.create({
751
777
  name: "patchDiff",
752
778
  addOptions() {
753
779
  return { editorId: "default" };
754
780
  },
755
781
  addProseMirrorPlugins() {
756
- return [ma(this.options.editorId)];
782
+ return [ga(this.options.editorId)];
757
783
  }
758
- }), ha = [
784
+ }), ya = [
759
785
  An,
760
786
  Pn,
761
787
  Ln,
762
- fa,
788
+ pa,
763
789
  Dn.configure({
764
790
  levels: [1, 2, 3, 4, 5, 6]
765
791
  }),
@@ -768,7 +794,7 @@ const ga = Q.create({
768
794
  Fn,
769
795
  $n,
770
796
  zn,
771
- ga,
797
+ fa,
772
798
  On,
773
799
  Bn,
774
800
  Hn.configure({ nested: !0 }),
@@ -806,7 +832,7 @@ const ga = Q.create({
806
832
  types: ["heading", "paragraph"],
807
833
  defaultAlignment: "left"
808
834
  })
809
- ], ya = [
835
+ ], ba = [
810
836
  nr,
811
837
  rr,
812
838
  ar,
@@ -820,11 +846,11 @@ const ga = Q.create({
820
846
  dr,
821
847
  ur,
822
848
  mr.configure({ multicolor: !0 })
823
- ], ba = [
824
- ...ha,
825
- ...ya
849
+ ], va = [
850
+ ...ya,
851
+ ...ba
826
852
  ];
827
- class va {
853
+ class wa {
828
854
  constructor() {
829
855
  Se(this, "commands", /* @__PURE__ */ new Map());
830
856
  }
@@ -890,8 +916,8 @@ class va {
890
916
  return Array.from(this.commands.keys()).sort();
891
917
  }
892
918
  }
893
- const le = new va();
894
- class wa {
919
+ const le = new wa();
920
+ class xa {
895
921
  constructor() {
896
922
  Se(this, "plugins", /* @__PURE__ */ new Map());
897
923
  Se(this, "lifecycleOrder", ["register", "init", "stateSync", "destroy"]);
@@ -976,7 +1002,7 @@ class wa {
976
1002
  });
977
1003
  }
978
1004
  }
979
- const B = new wa(), yt = {
1005
+ const B = new xa(), yt = {
980
1006
  zh: {
981
1007
  language: "语言",
982
1008
  bold: "加粗",
@@ -1229,7 +1255,7 @@ const Ie = () => {
1229
1255
  document.querySelectorAll('body > svg[id^="standalone-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
1230
1256
  (e.id.startsWith("dmermaid") || e.id.startsWith("dstandalone")) && e.remove();
1231
1257
  }), document.querySelectorAll('body > div[id^="dstandalone-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > div[id^="dmermaid"]').forEach((e) => e.remove()), document.querySelectorAll('body > div[id^="standalone-mermaid-"]').forEach((e) => e.remove());
1232
- }, xa = Q.create({
1258
+ }, Ca = Q.create({
1233
1259
  name: "mermaid",
1234
1260
  group: "block",
1235
1261
  atom: !0,
@@ -1343,10 +1369,10 @@ const Ie = () => {
1343
1369
  };
1344
1370
  };
1345
1371
  }
1346
- }), Ca = {
1372
+ }), Ta = {
1347
1373
  name: "mermaid",
1348
1374
  version: "1.0.0",
1349
- extensions: [xa],
1375
+ extensions: [Ca],
1350
1376
  toolbarItems: [
1351
1377
  {
1352
1378
  id: "mermaid-insert",
@@ -1371,7 +1397,7 @@ const Ie = () => {
1371
1397
  }
1372
1398
  }
1373
1399
  }
1374
- }, Ve = "https://draw.goatpatent.com", Ta = Q.create({
1400
+ }, Ve = "https://draw.goatpatent.com", Sa = Q.create({
1375
1401
  name: "drawio",
1376
1402
  group: "block",
1377
1403
  atom: !0,
@@ -1467,10 +1493,10 @@ const Ie = () => {
1467
1493
  };
1468
1494
  };
1469
1495
  }
1470
- }), Sa = {
1496
+ }), Ea = {
1471
1497
  name: "drawio",
1472
1498
  version: "1.0.0",
1473
- extensions: [Ta],
1499
+ extensions: [Sa],
1474
1500
  toolbarItems: [
1475
1501
  {
1476
1502
  id: "drawio-insert",
@@ -1573,7 +1599,7 @@ const Ie = () => {
1573
1599
  ] })
1574
1600
  }
1575
1601
  );
1576
- }, Ea = Q.create({
1602
+ }, ka = Q.create({
1577
1603
  name: "math_inline",
1578
1604
  group: "inline",
1579
1605
  inline: !0,
@@ -1606,7 +1632,7 @@ const Ie = () => {
1606
1632
  }
1607
1633
  });
1608
1634
  }
1609
- }), ka = Q.create({
1635
+ }), _a = Q.create({
1610
1636
  name: "math_block",
1611
1637
  group: "block",
1612
1638
  atom: !0,
@@ -1629,10 +1655,10 @@ const Ie = () => {
1629
1655
  }
1630
1656
  });
1631
1657
  }
1632
- }), _a = {
1658
+ }), Ia = {
1633
1659
  name: "math",
1634
1660
  version: "1.0.0",
1635
- extensions: [Ea, ka],
1661
+ extensions: [ka, _a],
1636
1662
  toolbarItems: [
1637
1663
  {
1638
1664
  id: "math-inline-insert",
@@ -1695,7 +1721,7 @@ const Ie = () => {
1695
1721
  };
1696
1722
  }
1697
1723
  return null;
1698
- }, Ia = (e) => {
1724
+ }, Na = (e) => {
1699
1725
  const { $from: t } = e.state.selection;
1700
1726
  for (let n = t.depth; n >= 0; n -= 1) {
1701
1727
  const r = t.node(n);
@@ -1706,7 +1732,7 @@ const Ie = () => {
1706
1732
  };
1707
1733
  }
1708
1734
  return null;
1709
- }, Na = (e, t) => e.state.schema.nodes[t] || null, Aa = (e) => {
1735
+ }, Aa = (e, t) => e.state.schema.nodes[t] || null, Pa = (e) => {
1710
1736
  const t = Array.isArray(e.content) ? e.content : e.content ? [e.content] : void 0;
1711
1737
  return {
1712
1738
  type: e.type,
@@ -1714,7 +1740,7 @@ const Ie = () => {
1714
1740
  content: t
1715
1741
  };
1716
1742
  }, Yt = (e, t) => {
1717
- const n = Aa(t);
1743
+ const n = Pa(t);
1718
1744
  return typeof t.position == "number" ? e.chain().focus().insertContentAt(t.position, n).run() : e.chain().focus().insertContent(n).run();
1719
1745
  }, ze = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
1720
1746
  var l;
@@ -1734,7 +1760,7 @@ const Ie = () => {
1734
1760
  const s = r.doc.nodeAt(i);
1735
1761
  return !s || t.type && s.type.name !== t.type ? !1 : (n.delete(i, i + s.nodeSize), a && a(n), !0);
1736
1762
  }), Qt = (e, t) => {
1737
- const n = Na(e, t.type);
1763
+ const n = Aa(e, t.type);
1738
1764
  return n ? e.commands.command(({ tr: r, state: a, dispatch: i }) => {
1739
1765
  const { from: s, to: o } = a.selection, l = a.selection.$from.blockRange(a.selection.$to);
1740
1766
  if (!l)
@@ -1742,7 +1768,7 @@ const Ie = () => {
1742
1768
  const c = fr(l, n, t.attrs);
1743
1769
  return c ? (r.wrap(l, c), i && i(r.scrollIntoView()), s <= o) : !1;
1744
1770
  }) : !1;
1745
- }, Pa = (e, t) => {
1771
+ }, La = (e, t) => {
1746
1772
  if (t.length === 0)
1747
1773
  return !1;
1748
1774
  const n = e.getJSON();
@@ -1754,13 +1780,13 @@ const Ie = () => {
1754
1780
  let Ne = 0;
1755
1781
  const Qe = [];
1756
1782
  let Ae = !1;
1757
- const La = 2e4, bt = 6e4;
1783
+ const Da = 2e4, bt = 6e4;
1758
1784
  let $ = null, Me = !1, re = null, he = null;
1759
1785
  const et = /* @__PURE__ */ new Map();
1760
1786
  function vt() {
1761
1787
  re && (window.removeEventListener("message", re), re = null), $ && ($.src = "about:blank", $.remove(), $ = null), Me = !1;
1762
1788
  }
1763
- function Da(e, t) {
1789
+ function Ra(e, t) {
1764
1790
  const n = et.get(e);
1765
1791
  if (n) {
1766
1792
  t(n);
@@ -1802,13 +1828,13 @@ function tt() {
1802
1828
  ue
1803
1829
  );
1804
1830
  }, 1500) : o.event === "export" && a(o.data || "");
1805
- }, window.addEventListener("message", re), 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 = `${ue}/?embed=1&proto=json&spin=0&chrome=0`);
1831
+ }, window.addEventListener("message", re), r = setTimeout(() => a(""), Da), $ ? 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 = `${ue}/?embed=1&proto=json&spin=0&chrome=0`);
1806
1832
  }
1807
1833
  const Pe = () => {
1808
1834
  document.querySelectorAll('body > svg[id^="fig-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
1809
1835
  (e.id.startsWith("dmermaid") || e.id.startsWith("dfi")) && e.remove();
1810
1836
  }), document.querySelectorAll("body > #dmermaid-svg").forEach((e) => e.remove()), document.querySelectorAll("body > style[data-mermaid-style]").forEach((e) => e.remove());
1811
- }, Ra = Q.create({
1837
+ }, Ma = Q.create({
1812
1838
  name: "figure",
1813
1839
  group: "block",
1814
1840
  content: "inline*",
@@ -2020,7 +2046,7 @@ const Pe = () => {
2020
2046
  q && Cn && !oe && !xe && !i && (se && clearTimeout(se), se = setTimeout(() => {
2021
2047
  se = null;
2022
2048
  const dt = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "", Tn = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
2023
- !dt || Tn || xe || (xe = !0, Da(dt, (ut) => {
2049
+ !dt || Tn || xe || (xe = !0, Ra(dt, (ut) => {
2024
2050
  xe = !1, ut ? (Ce = 0, z({ drawioSvg: ut })) : Ce < yn && (Ce++, ge = setTimeout(() => {
2025
2051
  ge = null, K();
2026
2052
  }, vn * Ce));
@@ -2049,7 +2075,7 @@ const Pe = () => {
2049
2075
  };
2050
2076
  };
2051
2077
  }
2052
- }), Ma = Q.create({
2078
+ }), Fa = Q.create({
2053
2079
  name: "reference",
2054
2080
  group: "inline",
2055
2081
  inline: !0,
@@ -2150,7 +2176,7 @@ const Pe = () => {
2150
2176
  design_description: "sectionTitle_design_description",
2151
2177
  design_views: "sectionTitle_design_views",
2152
2178
  design_brief: "sectionTitle_design_brief"
2153
- }, Fa = /* @__PURE__ */ new Set([
2179
+ }, $a = /* @__PURE__ */ new Set([
2154
2180
  "abstract",
2155
2181
  "abstract_drawing",
2156
2182
  "claims",
@@ -2161,7 +2187,7 @@ const Pe = () => {
2161
2187
  "design_description",
2162
2188
  "design_views",
2163
2189
  "design_brief"
2164
- ]), $a = /* @__PURE__ */ new Set([
2190
+ ]), za = /* @__PURE__ */ new Set([
2165
2191
  "technical_field",
2166
2192
  "background_art",
2167
2193
  "summary",
@@ -2176,7 +2202,7 @@ const Pe = () => {
2176
2202
  return e.forEach((n) => {
2177
2203
  !t && ot(n) && (t = !0);
2178
2204
  }), t;
2179
- }, za = Q.create({
2205
+ }, Oa = Q.create({
2180
2206
  name: "patent_title",
2181
2207
  group: "block",
2182
2208
  content: "inline*",
@@ -2239,7 +2265,7 @@ const Pe = () => {
2239
2265
  };
2240
2266
  };
2241
2267
  }
2242
- }), Oa = Q.create({
2268
+ }), Ba = Q.create({
2243
2269
  name: "patent_section",
2244
2270
  group: "block",
2245
2271
  content: "block+",
@@ -2324,7 +2350,7 @@ const Pe = () => {
2324
2350
  };
2325
2351
  o.addEventListener("click", m), l.addEventListener("focusin", d), l.addEventListener("click", d);
2326
2352
  const g = () => {
2327
- const y = I.getState(), w = H(y.editorLanguage), T = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", C = Fa.has(T), x = $a.has(T), S = wt[T], A = typeof w[S] == "string" ? w[S] : T, u = ot(r), v = y.rightPanel.activeSectionPos === c();
2353
+ const y = I.getState(), w = H(y.editorLanguage), T = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", C = $a.has(T), x = za.has(T), S = wt[T], A = typeof w[S] == "string" ? w[S] : T, u = ot(r), v = y.rightPanel.activeSectionPos === c();
2328
2354
  a.className = `ps${u ? "" : " ps--empty"}${x ? " ps--sub" : ""}`, a.setAttribute("data-section-type", T), i.className = C ? "pb-heading" : "ps-heading ps-heading--sub", i.textContent = A, o.textContent = `[${A}]`, o.style.display = u ? "none" : "", o.classList.toggle("ps-placeholder--active", v && !u), l.classList.toggle("ps-content--has-content", u);
2329
2355
  };
2330
2356
  let h = I.getState().editorLanguage, p = I.getState().rightPanel.activeSectionPos;
@@ -2342,21 +2368,21 @@ const Pe = () => {
2342
2368
  };
2343
2369
  };
2344
2370
  }
2345
- }), Ba = [
2371
+ }), Ha = [
2346
2372
  "abstract",
2347
2373
  // 说明书摘要
2348
2374
  "abstract_drawing"
2349
2375
  // 摘要附图
2350
- ], Ha = [
2376
+ ], Ua = [
2351
2377
  "technical_field",
2352
2378
  "background_art",
2353
2379
  "summary",
2354
2380
  "drawing_description",
2355
2381
  "detailed_description"
2356
- ], Ua = [
2382
+ ], qa = [
2357
2383
  "drawing_figures"
2358
2384
  // 说明书附图
2359
- ], qa = [
2385
+ ], Wa = [
2360
2386
  "design_product_name",
2361
2387
  "design_usage",
2362
2388
  "design_description",
@@ -2376,15 +2402,15 @@ const Pe = () => {
2376
2402
  }), en = () => ({
2377
2403
  type: "patent_title",
2378
2404
  content: []
2379
- }), Wa = () => [
2380
- ...Ba.map(Fe),
2381
- en(),
2405
+ }), ja = () => [
2382
2406
  ...Ha.map(Fe),
2383
- ...Ua.map(Fe)
2384
- ], ja = () => [
2385
2407
  en(),
2408
+ ...Ua.map(Fe),
2386
2409
  ...qa.map(Fe)
2387
- ], tn = (e = "invention") => ({ type: "doc", content: e === "design" ? ja() : Wa() }), ve = (e) => Xt(e, (t) => t.type.name === "figure"), J = (e) => typeof e != "string" ? "" : e.trim(), xt = (e) => {
2410
+ ], Ga = () => [
2411
+ en(),
2412
+ ...Wa.map(Fe)
2413
+ ], tn = (e = "invention") => ({ type: "doc", content: e === "design" ? Ga() : ja() }), ve = (e) => Xt(e, (t) => t.type.name === "figure"), J = (e) => typeof e != "string" ? "" : e.trim(), xt = (e) => {
2388
2414
  const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = /* @__PURE__ */ new Set();
2389
2415
  ve(e).forEach((i) => {
2390
2416
  const s = J(i.node.attrs.id);
@@ -2394,14 +2420,14 @@ const Pe = () => {
2394
2420
  for (; r.has(`${n}${a}`); )
2395
2421
  a += 1;
2396
2422
  return `${n}${a}`;
2397
- }, Ga = /^(Fig\.|图)(\d+)$/, Va = (e) => {
2423
+ }, Va = /^(Fig\.|图)(\d+)$/, Ja = (e) => {
2398
2424
  const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = ve(e);
2399
2425
  if (r.length === 0) return;
2400
2426
  const a = [];
2401
2427
  let i = 1;
2402
2428
  for (const o of r) {
2403
2429
  const l = J(o.node.attrs.id);
2404
- if (!Ga.exec(l)) continue;
2430
+ if (!Va.exec(l)) continue;
2405
2431
  const d = `${n}${i}`;
2406
2432
  l !== d && a.push({ pos: o.pos, expectedId: d, currentId: l }), i++;
2407
2433
  }
@@ -2446,10 +2472,10 @@ const Pe = () => {
2446
2472
  ) && (r.setNodeMarkup(l, void 0, p), s = !0), !0;
2447
2473
  }), s && i && (r.setMeta("addToHistory", !1), i(r)), !0;
2448
2474
  });
2449
- }, Ja = {
2475
+ }, Ka = {
2450
2476
  name: "patent",
2451
2477
  version: "1.0.0",
2452
- extensions: [Ra, Ma, za, Oa],
2478
+ extensions: [Ma, Fa, Oa, Ba],
2453
2479
  toolbarItems: [
2454
2480
  {
2455
2481
  id: "patent-figure-insert",
@@ -2595,13 +2621,13 @@ const Pe = () => {
2595
2621
  }
2596
2622
  },
2597
2623
  onStateChange: (e) => {
2598
- e.isDestroyed || (Va(e), Je(e));
2624
+ e.isDestroyed || (Ja(e), Je(e));
2599
2625
  }
2600
- }, Ka = [Ca, Sa, _a, Ja];
2601
- Ka.forEach((e) => B.register(e));
2602
- const Xa = (e = {}) => {
2626
+ }, Xa = [Ta, Ea, Ia, Ka];
2627
+ Xa.forEach((e) => B.register(e));
2628
+ const Ya = (e = {}) => {
2603
2629
  const t = [
2604
- ...ba,
2630
+ ...va,
2605
2631
  ...B.getExtensions(),
2606
2632
  ...e.extensions || []
2607
2633
  ];
@@ -2625,12 +2651,12 @@ const Xa = (e = {}) => {
2625
2651
  updateNodeAttrs: (t) => ze(e, t),
2626
2652
  removeNode: (t) => Zt(e, t),
2627
2653
  wrapSelection: (t) => Qt(e, t),
2628
- applyTransactionBatch: (t) => Pa(e, t),
2654
+ applyTransactionBatch: (t) => La(e, t),
2629
2655
  findNodeByType: (t, n) => st(e, t, n),
2630
2656
  findAncestorNode: (t) => Re(e, t),
2631
- findCurrentBlock: () => Ia(e),
2657
+ findCurrentBlock: () => Na(e),
2632
2658
  findNodesByPredicate: (t, n) => Xt(e, t, n)
2633
- }), Ya = ["history", "text", "structure", "format", "technical", "patent"], Za = {
2659
+ }), Za = ["history", "text", "structure", "format", "technical", "patent"], Qa = {
2634
2660
  history: "groupHistory",
2635
2661
  text: "groupText",
2636
2662
  structure: "groupStructure",
@@ -2639,7 +2665,7 @@ const Xa = (e = {}) => {
2639
2665
  patent: "groupPatent"
2640
2666
  }, Xe = (e, t) => {
2641
2667
  if (t) {
2642
- const n = Za[e];
2668
+ const n = Qa[e];
2643
2669
  if (n && typeof t[n] == "string") return t[n];
2644
2670
  }
2645
2671
  return e.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join(" ");
@@ -2711,9 +2737,9 @@ const Xa = (e = {}) => {
2711
2737
  document.body
2712
2738
  )
2713
2739
  ] });
2714
- }, Qa = ({
2740
+ }, ei = ({
2715
2741
  editor: e,
2716
- groupOrder: t = Ya,
2742
+ groupOrder: t = Za,
2717
2743
  collapsibleGroups: n = !0,
2718
2744
  defaultCollapsedGroups: r = []
2719
2745
  }) => {
@@ -3113,7 +3139,7 @@ const Xa = (e = {}) => {
3113
3139
  ] }, u.group);
3114
3140
  })
3115
3141
  ] }) });
3116
- }, ei = ({ editor: e }) => {
3142
+ }, ti = ({ editor: e }) => {
3117
3143
  const [t, n] = M(0), [r, a] = M(""), i = I((x) => x.editorLanguage), s = H(i);
3118
3144
  if (F(() => {
3119
3145
  if (!e) return;
@@ -3243,10 +3269,10 @@ const Xa = (e = {}) => {
3243
3269
  design_views: ["design_description"],
3244
3270
  design_brief: ["design_description", "design_views"]
3245
3271
  };
3246
- function qs(e, t) {
3272
+ function Ws(e, t) {
3247
3273
  return (sn[e] || []).filter((r) => !t.has(r));
3248
3274
  }
3249
- function ti(e) {
3275
+ function ni(e) {
3250
3276
  const t = [];
3251
3277
  return e.state.doc.descendants((n, r) => n.type.name === "patent_title" ? (t.push({
3252
3278
  sectionType: "patent_title",
@@ -3277,10 +3303,10 @@ function on(e) {
3277
3303
  }
3278
3304
  return null;
3279
3305
  }
3280
- function ni(e, t) {
3306
+ function ri(e, t) {
3281
3307
  const n = sn[t];
3282
3308
  if (!n || n.length === 0) return [];
3283
- const r = ti(e), a = new Map(r.map((i) => [i.sectionType, i]));
3309
+ const r = ni(e), a = new Map(r.map((i) => [i.sectionType, i]));
3284
3310
  return n.map((i) => {
3285
3311
  const s = a.get(i);
3286
3312
  return !s || s.content.trim().length === 0 ? null : {
@@ -3289,14 +3315,14 @@ function ni(e, t) {
3289
3315
  };
3290
3316
  }).filter((i) => i !== null && i.content.length > 0);
3291
3317
  }
3292
- function Ws(e, t = {}) {
3318
+ function js(e, t = {}) {
3293
3319
  const n = I.getState().editorLanguage, { from: r, to: a } = e.state.selection, i = r !== a ? e.state.doc.textBetween(r, a, " ", "\0") : void 0;
3294
3320
  let s = t.sectionType, o = t.targetSectionPos;
3295
3321
  if (!s) {
3296
3322
  const m = on(e);
3297
3323
  m && (s = m.sectionType, o = m.pos);
3298
3324
  }
3299
- const l = t.scope || (s ? "section" : i ? "selection" : "document"), c = s ? ni(e, s) : void 0;
3325
+ const l = t.scope || (s ? "section" : i ? "selection" : "document"), c = s ? ri(e, s) : void 0;
3300
3326
  let d;
3301
3327
  if (l === "selection" && r !== a) {
3302
3328
  const g = Math.max(0, r - 200), h = Math.min(e.state.doc.content.size, a + 200), p = e.state.doc.textBetween(g, r, " ", "\0"), b = e.state.doc.textBetween(a, h, " ", "\0");
@@ -3313,7 +3339,7 @@ function Ws(e, t = {}) {
3313
3339
  language: n
3314
3340
  };
3315
3341
  }
3316
- const ri = ({ editor: e, onSelectionOptimize: t }) => {
3342
+ const ai = ({ editor: e, onSelectionOptimize: t }) => {
3317
3343
  const { addChatReference: n, openChatPanel: r, editorLanguage: a } = I(), i = a === "zh", s = (c) => Z(
3318
3344
  "p-1.5 rounded transition-colors",
3319
3345
  c ? "bg-blue-100 text-blue-600" : "text-gray-600 hover:bg-gray-100"
@@ -3434,7 +3460,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3434
3460
  ] })
3435
3461
  }
3436
3462
  );
3437
- }, ai = ({ editor: e }) => {
3463
+ }, ii = ({ editor: e }) => {
3438
3464
  var A;
3439
3465
  const [t, n] = M(!1), [r, a] = M(!1), [i, s] = M(""), [o, l] = M(""), [c, d] = M(!1), [, m] = M(0), g = j(() => m((u) => u + 1), []), h = W(null), p = e.extensionStorage.searchReplace, b = ((A = p == null ? void 0 : p.results) == null ? void 0 : A.length) ?? 0, y = (p == null ? void 0 : p.currentIndex) ?? -1, w = j(() => {
3440
3466
  e.commands.nextSearchResult(), g();
@@ -3551,7 +3577,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3551
3577
  )
3552
3578
  ] })
3553
3579
  ] }) : null;
3554
- }, ii = ({ editor: e }) => {
3580
+ }, si = ({ editor: e }) => {
3555
3581
  const { editorLanguage: t } = I(), n = t === "zh", r = At(() => {
3556
3582
  const a = e.state, s = a.doc.textBetween(0, a.doc.content.size, " ", "\0").replace(/\s/g, "").length, { from: o, to: l } = a.selection;
3557
3583
  let c = 0;
@@ -3569,19 +3595,19 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3569
3595
  r.selectionCount
3570
3596
  ] })
3571
3597
  ] });
3572
- }, si = {
3598
+ }, oi = {
3573
3599
  empty: "○",
3574
3600
  filled: "●"
3575
- }, oi = {
3601
+ }, ci = {
3576
3602
  empty: "text-gray-400",
3577
3603
  filled: "text-green-500"
3578
- }, ci = /* @__PURE__ */ new Set([
3604
+ }, li = /* @__PURE__ */ new Set([
3579
3605
  "technical_field",
3580
3606
  "background_art",
3581
3607
  "summary",
3582
3608
  "drawing_description",
3583
3609
  "detailed_description"
3584
- ]), li = ({ editor: e, defaultCollapsed: t = !1 }) => {
3610
+ ]), di = ({ editor: e, defaultCollapsed: t = !1 }) => {
3585
3611
  const { editorLanguage: n } = I(), r = H(n), [a, i] = M(t), [s, o] = M(0);
3586
3612
  F(() => {
3587
3613
  const c = () => o((d) => d + 1);
@@ -3614,7 +3640,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3614
3640
  }), !1;
3615
3641
  }
3616
3642
  if (m.type.name === "patent_section") {
3617
- const h = m.attrs.sectionType, p = ci.has(h), b = `sectionTitle_${h}`, y = typeof r[b] == "string" ? r[b] : h, w = m.textContent || "", T = w.trim().length > 0;
3643
+ const h = m.attrs.sectionType, p = li.has(h), b = `sectionTitle_${h}`, y = typeof r[b] == "string" ? r[b] : h, w = m.textContent || "", T = w.trim().length > 0;
3618
3644
  return c.push({
3619
3645
  type: "section",
3620
3646
  pos: g,
@@ -3677,7 +3703,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3677
3703
  }));
3678
3704
  },
3679
3705
  children: [
3680
- c.type === "section" && c.state && /* @__PURE__ */ f("span", { className: Z("outline-item-state", oi[c.state]), children: si[c.state] || "○" }),
3706
+ c.type === "section" && c.state && /* @__PURE__ */ f("span", { className: Z("outline-item-state", ci[c.state]), children: oi[c.state] || "○" }),
3681
3707
  /* @__PURE__ */ f("span", { className: "outline-item-title", children: c.title }),
3682
3708
  c.type !== "book-group" && /* @__PURE__ */ f("span", { className: "outline-item-count", children: c.charCount })
3683
3709
  ]
@@ -3686,7 +3712,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3686
3712
  ))
3687
3713
  ] })
3688
3714
  ] });
3689
- }, di = ({
3715
+ }, ui = ({
3690
3716
  editor: e,
3691
3717
  mode: t = "edit",
3692
3718
  className: n
@@ -3702,14 +3728,14 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3702
3728
  ),
3703
3729
  children: /* @__PURE__ */ f(In, { editor: e, className: "h-full" })
3704
3730
  }
3705
- )), cn = "patent-editor-draft", ui = 1500, mi = () => {
3731
+ )), cn = "patent-editor-draft", mi = 1500, gi = () => {
3706
3732
  try {
3707
3733
  const e = localStorage.getItem(cn);
3708
3734
  return e ? JSON.parse(e) : null;
3709
3735
  } catch {
3710
3736
  return null;
3711
3737
  }
3712
- }, gi = ({
3738
+ }, fi = ({
3713
3739
  initialContent: e,
3714
3740
  onChange: t,
3715
3741
  className: n,
@@ -3720,7 +3746,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3720
3746
  patchEditorId: o = "default",
3721
3747
  defaultOutlineCollapsed: l = !1
3722
3748
  }) => {
3723
- const { setEditor: c, setDocument: d, editorLanguage: m, autoSaveStatus: g, ai: h } = I(), { setAutoSaveStatus: p, setLastSavedAt: b } = I(), y = W(null), w = e || (t ? null : mi()) || {
3749
+ const { setEditor: c, setDocument: d, editorLanguage: m, autoSaveStatus: g, ai: h } = I(), { setAutoSaveStatus: p, setLastSavedAt: b } = I(), y = W(null), w = e || (t ? null : gi()) || {
3724
3750
  type: "doc",
3725
3751
  content: [
3726
3752
  {
@@ -3735,14 +3761,14 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3735
3761
  p("error");
3736
3762
  }
3737
3763
  }, [p, b]), C = Nn(
3738
- Xa({
3739
- extensions: [pa.configure({ editorId: o })],
3764
+ Ya({
3765
+ extensions: [ha.configure({ editorId: o })],
3740
3766
  content: w,
3741
3767
  onUpdate: ({ editor: u }) => {
3742
3768
  const v = u.getJSON();
3743
3769
  d(v), B.notifyStateChange(u), t && t(v), t || (y.current && clearTimeout(y.current), y.current = setTimeout(() => {
3744
3770
  T(v);
3745
- }, ui));
3771
+ }, mi));
3746
3772
  },
3747
3773
  onCreate: ({ editor: u }) => {
3748
3774
  c(u), i == null || i(u), B.initializePlugins(u), B.notifyStateChange(u);
@@ -3774,23 +3800,23 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
3774
3800
  const S = H(m), A = g === "saving" ? S.autoSaveSaving : g === "saved" ? S.autoSaveSaved : g === "error" ? S.autoSaveError : "";
3775
3801
  return /* @__PURE__ */ P("div", { className: `editor-container flex flex-col h-full ${n}`, children: [
3776
3802
  !r && /* @__PURE__ */ P("div", { className: "flex items-center", children: [
3777
- /* @__PURE__ */ f(Qa, { editor: C }),
3803
+ /* @__PURE__ */ f(ei, { editor: C }),
3778
3804
  A && /* @__PURE__ */ f("span", { className: `auto-save-indicator auto-save-indicator--${g} ml-2`, children: A })
3779
3805
  ] }),
3780
- !r && C && /* @__PURE__ */ f(ei, { editor: C }),
3781
- !r && C && /* @__PURE__ */ f(ri, { editor: C, onSelectionOptimize: s }),
3782
- !r && C && /* @__PURE__ */ f(ai, { editor: C }),
3806
+ !r && C && /* @__PURE__ */ f(ti, { editor: C }),
3807
+ !r && C && /* @__PURE__ */ f(ai, { editor: C, onSelectionOptimize: s }),
3808
+ !r && C && /* @__PURE__ */ f(ii, { editor: C }),
3783
3809
  /* @__PURE__ */ P("div", { className: "flex flex-1 overflow-hidden", children: [
3784
- !r && C && /* @__PURE__ */ f(li, { editor: C, defaultCollapsed: l }),
3810
+ !r && C && /* @__PURE__ */ f(di, { editor: C, defaultCollapsed: l }),
3785
3811
  /* @__PURE__ */ f("div", { className: "flex-1 overflow-y-auto bg-white p-4 relative", children: /* @__PURE__ */ f(
3786
- di,
3812
+ ui,
3787
3813
  {
3788
3814
  editor: C,
3789
3815
  mode: r || !a || h.status === "streaming" && h.activeSectionType === "claims" ? "readonly" : "edit"
3790
3816
  }
3791
3817
  ) })
3792
3818
  ] }),
3793
- !r && /* @__PURE__ */ f(ii, { editor: C })
3819
+ !r && /* @__PURE__ */ f(si, { editor: C })
3794
3820
  ] });
3795
3821
  };
3796
3822
  function ln(e) {
@@ -3845,7 +3871,7 @@ function ln(e) {
3845
3871
  }
3846
3872
  });
3847
3873
  }
3848
- function fi(e, t) {
3874
+ function pi(e, t) {
3849
3875
  let n = null;
3850
3876
  return {
3851
3877
  async request(r) {
@@ -3867,7 +3893,7 @@ function fi(e, t) {
3867
3893
  }
3868
3894
  };
3869
3895
  }
3870
- function pi(e, t) {
3896
+ function hi(e, t) {
3871
3897
  let n = null;
3872
3898
  const r = e.replace(/\/+$/, "");
3873
3899
  async function a(i, s) {
@@ -3921,7 +3947,7 @@ function pi(e, t) {
3921
3947
  }
3922
3948
  };
3923
3949
  }
3924
- const hi = It(
3950
+ const yi = It(
3925
3951
  ({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, editable: i = !0, language: s, aiService: o, chatSessionAPI: l, aiBaseUrl: c, aiHeaders: d, onSelectionOptimize: m, patchEditorId: g, defaultOutlineCollapsed: h }, p) => {
3926
3952
  const { setEditorLanguage: b, setAIService: y, setChatSessionAPI: w } = I(), T = W(null), C = j((S) => {
3927
3953
  T.current = S;
@@ -3932,9 +3958,9 @@ const hi = It(
3932
3958
  return Ee.useEffect(() => {
3933
3959
  s && b(s);
3934
3960
  }, [s, b]), Ee.useEffect(() => {
3935
- o ? y(o) : c && y(fi(c, d));
3961
+ o ? y(o) : c && y(pi(c, d));
3936
3962
  }, [o, c, d, y]), Ee.useEffect(() => {
3937
- l ? w(l) : c && w(pi(c, d));
3963
+ l ? w(l) : c && w(hi(c, d));
3938
3964
  }, [l, c, d, w]), Nt(p, () => ({
3939
3965
  getContent: () => {
3940
3966
  var S;
@@ -3951,7 +3977,7 @@ const hi = It(
3951
3977
  (S = T.current) == null || S.commands.focus();
3952
3978
  }
3953
3979
  })), /* @__PURE__ */ f(
3954
- gi,
3980
+ fi,
3955
3981
  {
3956
3982
  initialContent: x,
3957
3983
  onChange: n,
@@ -3966,8 +3992,8 @@ const hi = It(
3966
3992
  );
3967
3993
  }
3968
3994
  );
3969
- hi.displayName = "PatentEditor";
3970
- async function js(e, t, n) {
3995
+ yi.displayName = "PatentEditor";
3996
+ async function Gs(e, t, n) {
3971
3997
  var a, i, s, o;
3972
3998
  let r = !1;
3973
3999
  (a = n.onStart) == null || a.call(n), n.mode === "section" && typeof n.targetSectionPos == "number" && un(e, n.targetSectionPos);
@@ -3986,7 +4012,7 @@ async function js(e, t, n) {
3986
4012
  (o = n.onError) == null || o.call(n, l instanceof Error ? l : new Error(String(l)));
3987
4013
  }
3988
4014
  }
3989
- async function Gs(e, t, n, r) {
4015
+ async function Vs(e, t, n, r) {
3990
4016
  var i, s, o, l, c, d, m, g;
3991
4017
  const a = new AbortController();
3992
4018
  (i = r.onStart) == null || i.call(r), r.mode === "section" && typeof r.targetSectionPos == "number" && un(e, r.targetSectionPos);
@@ -4216,7 +4242,7 @@ function rt(e, t = 30) {
4216
4242
  }
4217
4243
  });
4218
4244
  }
4219
- function yi(e) {
4245
+ function bi(e) {
4220
4246
  const t = [], n = $e(e, 3);
4221
4247
  for (const r of n)
4222
4248
  t.push({ type: "delta", content: r });
@@ -4228,7 +4254,7 @@ function $e(e, t) {
4228
4254
  n.push(e.slice(r, r + t));
4229
4255
  return n;
4230
4256
  }
4231
- function bi(e, t, n) {
4257
+ function vi(e, t, n) {
4232
4258
  const r = n === "zh", a = [];
4233
4259
  let i;
4234
4260
  if (e.includes("技术方案") || e.includes("draft") ? i = Le["help-draft"][r ? "zh" : "en"] : e.includes("审查") || e.includes("review") || e.includes("Review") ? i = Le.review[r ? "zh" : "en"] : e.includes("权利要求") || e.includes("claims") || e.includes("Optimize") ? i = Le.claims[r ? "zh" : "en"] : i = Le.default[r ? "zh" : "en"], t.length > 0) {
@@ -4276,7 +4302,7 @@ function bi(e, t, n) {
4276
4302
  a.push({ type: "delta", content: s });
4277
4303
  return a.push({ type: "done", usage: { tokens: i.length * 2 } }), a;
4278
4304
  }
4279
- function Vs() {
4305
+ function Js() {
4280
4306
  let e = null;
4281
4307
  return {
4282
4308
  async request(t) {
@@ -4290,7 +4316,7 @@ function Vs() {
4290
4316
  ` : `[Generated based on instruction "${t.instruction}"]
4291
4317
 
4292
4318
  `) + a);
4293
- const s = yi(i);
4319
+ const s = bi(i);
4294
4320
  return rt(s, 25);
4295
4321
  },
4296
4322
  abort() {
@@ -4298,7 +4324,7 @@ function Vs() {
4298
4324
  }
4299
4325
  };
4300
4326
  }
4301
- function Js() {
4327
+ function Ks() {
4302
4328
  const e = /* @__PURE__ */ new Map();
4303
4329
  let t = null, n = null;
4304
4330
  return {
@@ -4341,7 +4367,7 @@ function Js() {
4341
4367
  status: "done",
4342
4368
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4343
4369
  }), i.session.messageCount = i.messages.length, i.session.lastMessage = a.content, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
4344
- const o = bi(
4370
+ const o = vi(
4345
4371
  a.content,
4346
4372
  a.references || [],
4347
4373
  a.language
@@ -4373,7 +4399,7 @@ function Js() {
4373
4399
  }
4374
4400
  };
4375
4401
  }
4376
- function vi(e) {
4402
+ function wi(e) {
4377
4403
  const t = [], n = e.replace(/\r\n/g, `
4378
4404
  `).trim();
4379
4405
  if (!n) return t;
@@ -4388,12 +4414,12 @@ function vi(e) {
4388
4414
  if (a.length === 0)
4389
4415
  return t.push({ number: 1, text: n, dependsOn: [] }), t;
4390
4416
  for (let s = 0; s < a.length; s++) {
4391
- const o = a[s].index + a[s].matchLength, l = s + 1 < a.length ? a[s + 1].index : n.length, c = n.slice(o, l).trim(), d = a[s].number, m = wi(c, d);
4417
+ const o = a[s].index + a[s].matchLength, l = s + 1 < a.length ? a[s + 1].index : n.length, c = n.slice(o, l).trim(), d = a[s].number, m = xi(c, d);
4392
4418
  t.push({ number: d, text: c, dependsOn: m });
4393
4419
  }
4394
4420
  return t;
4395
4421
  }
4396
- function wi(e, t) {
4422
+ function xi(e, t) {
4397
4423
  const n = [], r = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g;
4398
4424
  let a;
4399
4425
  for (; (a = r.exec(e)) !== null; ) {
@@ -4409,18 +4435,18 @@ function wi(e, t) {
4409
4435
  }
4410
4436
  return [...new Set(n)].sort((s, o) => s - o);
4411
4437
  }
4412
- function Ks(e) {
4413
- return vi(e).map((n) => ({
4438
+ function Xs(e) {
4439
+ return wi(e).map((n) => ({
4414
4440
  type: "paragraph",
4415
4441
  content: n.text ? [{ type: "text", text: `${n.number}. ${n.text}` }] : [{ type: "text", text: `${n.number}. ` }]
4416
4442
  }));
4417
4443
  }
4418
- const xi = -1, Ci = 1, Ti = 0, at = new we("docDiff");
4444
+ const Ci = -1, Ti = 1, Si = 0, at = new we("docDiff");
4419
4445
  let Ye = null;
4420
- function Si() {
4446
+ function Ei() {
4421
4447
  return Ye || (Ye = new Lt()), Ye;
4422
4448
  }
4423
- function Ei(e, t, n) {
4449
+ function ki(e, t, n) {
4424
4450
  const r = [];
4425
4451
  return e.nodesBetween(t, n, (a, i) => {
4426
4452
  if (a.isTextblock) {
@@ -4430,15 +4456,15 @@ function Ei(e, t, n) {
4430
4456
  return !0;
4431
4457
  }), r;
4432
4458
  }
4433
- function Xs(e, t) {
4434
- const n = e.state.doc, r = n.content.size, { text: a, segments: i } = Gt(e, 0, r), s = Si(), o = s.diff_main(t, a);
4459
+ function Ys(e, t) {
4460
+ const n = e.state.doc, r = n.content.size, { text: a, segments: i } = Gt(e, 0, r), s = Ei(), o = s.diff_main(t, a);
4435
4461
  s.diff_cleanupSemantic(o);
4436
4462
  const l = [];
4437
4463
  let c = 0;
4438
4464
  for (const [g, h] of o)
4439
- if (g === Ti)
4465
+ if (g === Si)
4440
4466
  c += h.length;
4441
- else if (g === Ci) {
4467
+ else if (g === Ti) {
4442
4468
  let p = 0;
4443
4469
  for (; p < h.length; ) {
4444
4470
  for (; p < h.length && h[p] === "\0"; ) p++;
@@ -4447,13 +4473,13 @@ function Xs(e, t) {
4447
4473
  for (; p < h.length && h[p] !== "\0"; ) p++;
4448
4474
  const y = be(i, c + b), w = be(i, c + p);
4449
4475
  if (y >= 0 && w >= 0 && w > y)
4450
- for (const T of Ei(n, y, w))
4476
+ for (const T of ki(n, y, w))
4451
4477
  l.push(
4452
4478
  ae.inline(T.from, T.to, { class: "patch-diff-insert-inline" })
4453
4479
  );
4454
4480
  }
4455
4481
  c += h.length;
4456
- } else if (g === xi) {
4482
+ } else if (g === Ci) {
4457
4483
  const p = be(i, c);
4458
4484
  if (p >= 0) {
4459
4485
  const b = h.replace(/\0/g, " ");
@@ -4483,22 +4509,22 @@ function Xs(e, t) {
4483
4509
  });
4484
4510
  e.registerPlugin(m);
4485
4511
  }
4486
- function Ys(e) {
4512
+ function Zs(e) {
4487
4513
  e.unregisterPlugin(at);
4488
4514
  }
4489
- const ki = /* @__PURE__ */ new Set([
4515
+ const _i = /* @__PURE__ */ new Set([
4490
4516
  "abstract",
4491
4517
  "abstract_drawing",
4492
4518
  "claims",
4493
4519
  "drawing_figures"
4494
- ]), _i = /* @__PURE__ */ new Set([
4520
+ ]), Ii = /* @__PURE__ */ new Set([
4495
4521
  "technical_field",
4496
4522
  "background_art",
4497
4523
  "summary",
4498
4524
  "drawing_description",
4499
4525
  "detailed_description"
4500
4526
  ]);
4501
- function Ii(e, t) {
4527
+ function Ni(e, t) {
4502
4528
  const n = H(t), r = [];
4503
4529
  return e.state.doc.descendants((a) => {
4504
4530
  if (a.type.name === "patent_title") {
@@ -4534,7 +4560,7 @@ function Et(e) {
4534
4560
  spacing: { before: 240, after: 120 }
4535
4561
  });
4536
4562
  }
4537
- function Ni(e) {
4563
+ function Ai(e) {
4538
4564
  return new He({
4539
4565
  children: [new Ue({ text: e, bold: !0, size: 36, font: "宋体" })],
4540
4566
  alignment: it.CENTER,
@@ -4548,11 +4574,11 @@ function Ze(e) {
4548
4574
  indent: { firstLine: ye(7) }
4549
4575
  });
4550
4576
  }
4551
- function Ai(e, t) {
4577
+ function Pi(e, t) {
4552
4578
  const n = H(t), r = [];
4553
4579
  let a = !1;
4554
4580
  for (const i of e) {
4555
- if (ki.has(i.sectionType)) {
4581
+ if (_i.has(i.sectionType)) {
4556
4582
  r.push(St(i.title));
4557
4583
  for (const s of i.paragraphs)
4558
4584
  r.push(Ze(s));
@@ -4564,10 +4590,10 @@ function Ai(e, t) {
4564
4590
  r.push(St(s)), a = !0;
4565
4591
  }
4566
4592
  for (const s of i.paragraphs)
4567
- r.push(Ni(s));
4593
+ r.push(Ai(s));
4568
4594
  continue;
4569
4595
  }
4570
- if (_i.has(i.sectionType)) {
4596
+ if (Ii.has(i.sectionType)) {
4571
4597
  r.push(Et(i.title));
4572
4598
  for (const s of i.paragraphs)
4573
4599
  r.push(Ze(s));
@@ -4579,8 +4605,8 @@ function Ai(e, t) {
4579
4605
  }
4580
4606
  return r;
4581
4607
  }
4582
- async function Zs(e, t) {
4583
- const n = Ii(e, t), r = Ai(n, t), a = n.find((c) => c.type === "patent_title"), i = a != null && a.paragraphs[0] ? `${a.paragraphs[0]}.docx` : "patent-document.docx", s = {
4608
+ async function Qs(e, t) {
4609
+ const n = Ni(e, t), r = Pi(n, t), a = n.find((c) => c.type === "patent_title"), i = a != null && a.paragraphs[0] ? `${a.paragraphs[0]}.docx` : "patent-document.docx", s = {
4584
4610
  properties: {
4585
4611
  page: {
4586
4612
  margin: {
@@ -4597,10 +4623,10 @@ async function Zs(e, t) {
4597
4623
  }), l = await Xr.toBlob(o);
4598
4624
  Yr(l, i);
4599
4625
  }
4600
- async function Qs(e) {
4626
+ async function eo(e) {
4601
4627
  window.print();
4602
4628
  }
4603
- function eo(e, t) {
4629
+ function to(e, t) {
4604
4630
  const n = [], r = t === "zh";
4605
4631
  let a = 0;
4606
4632
  const i = () => `v_${++a}`;
@@ -4671,8 +4697,8 @@ function eo(e, t) {
4671
4697
  return !0;
4672
4698
  }), n;
4673
4699
  }
4674
- const Pi = /^(\d+)\s*[.、]\s*/, kt = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g, _t = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
4675
- function Li(e, t) {
4700
+ const Li = /^(\d+)\s*[.、]\s*/, kt = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g, _t = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
4701
+ function Di(e, t) {
4676
4702
  const n = [];
4677
4703
  let r;
4678
4704
  for (kt.lastIndex = 0; (r = kt.exec(e)) !== null; ) {
@@ -4689,7 +4715,7 @@ function Li(e, t) {
4689
4715
  }
4690
4716
  const mn = (e) => {
4691
4717
  if (e.type.name === "reference")
4692
- return Di(e);
4718
+ return Ri(e);
4693
4719
  if (e.type.name === "hardBreak")
4694
4720
  return `
4695
4721
  `;
@@ -4699,7 +4725,7 @@ const mn = (e) => {
4699
4725
  return e.forEach((n) => {
4700
4726
  t += mn(n);
4701
4727
  }), t;
4702
- }, Di = (e) => {
4728
+ }, Ri = (e) => {
4703
4729
  const t = e.attrs.lang === "en" ? "en" : "zh", n = e.attrs.targetType === "figure" ? "figure" : "claim", r = typeof e.attrs.displayText == "string" ? e.attrs.displayText.trim() : "";
4704
4730
  if (r)
4705
4731
  return r;
@@ -4709,17 +4735,17 @@ const mn = (e) => {
4709
4735
  }
4710
4736
  const a = Number(e.attrs.resolvedNumber);
4711
4737
  return Number.isFinite(a) ? t === "en" ? `Claim ${a}` : `权利要求${a}` : t === "en" ? "Claim ?" : "权利要求?";
4712
- }, to = (e) => {
4738
+ }, no = (e) => {
4713
4739
  const t = [];
4714
4740
  return e.state.doc.descendants((n, r) => {
4715
4741
  if (n.type.name === "patent_section")
4716
4742
  return n.attrs.sectionType === "claims";
4717
4743
  if (n.type.name !== "paragraph") return !0;
4718
- const a = mn(n).trim(), i = Pi.exec(a);
4744
+ const a = mn(n).trim(), i = Li.exec(a);
4719
4745
  if (!i) return !0;
4720
4746
  const s = parseInt(i[1], 10);
4721
4747
  if (!Number.isFinite(s) || s <= 0) return !0;
4722
- const o = a.slice(i[0].length).trim(), l = Li(o, s);
4748
+ const o = a.slice(i[0].length).trim(), l = Di(o, s);
4723
4749
  return t.push({
4724
4750
  claimId: `claim_${s}`,
4725
4751
  number: s,
@@ -4731,40 +4757,40 @@ const mn = (e) => {
4731
4757
  }), t;
4732
4758
  };
4733
4759
  export {
4734
- gi as EditorView,
4760
+ fi as EditorView,
4735
4761
  jt as PatchDiffPluginKey,
4736
- hi as PatentEditor,
4737
- Hs as acceptAllPatches,
4738
- Os as acceptPatch,
4739
- Xs as applyDocDiffDecorations,
4740
- Ws as buildAIContext,
4741
- Ks as buildClaimsJSONContent,
4762
+ yi as PatentEditor,
4763
+ Us as acceptAllPatches,
4764
+ Bs as acceptPatch,
4765
+ Ys as applyDocDiffDecorations,
4766
+ js as buildAIContext,
4767
+ Xs as buildClaimsJSONContent,
4742
4768
  tn as buildPatentDocument,
4743
- zs as clearPatches,
4744
- pi as createChatSessionAPI,
4769
+ Os as clearPatches,
4770
+ hi as createChatSessionAPI,
4745
4771
  ct as createCommandExecutor,
4746
- Xa as createEditorConfig,
4747
- Vs as createMockAIService,
4748
- Js as createMockChatSessionAPI,
4749
- fi as createSSEAdapter,
4750
- Qs as exportToPdf,
4751
- Zs as exportToWord,
4752
- to as extractClaimsFromEditor,
4772
+ Ya as createEditorConfig,
4773
+ Js as createMockAIService,
4774
+ Ks as createMockChatSessionAPI,
4775
+ pi as createSSEAdapter,
4776
+ eo as exportToPdf,
4777
+ Qs as exportToWord,
4778
+ no as extractClaimsFromEditor,
4753
4779
  on as findSectionAtCursor,
4754
- ti as getAllSections,
4755
- qs as getMissingSectionDeps,
4756
- Fs as getPatches,
4757
- Ms as onPatchChange,
4780
+ ni as getAllSections,
4781
+ Ws as getMissingSectionDeps,
4782
+ $s as getPatches,
4783
+ Fs as onPatchChange,
4758
4784
  B as pluginManager,
4759
- Us as rejectAllPatches,
4760
- Bs as rejectPatch,
4761
- Ys as removeDocDiffDecorations,
4762
- Rs as resolvePatchTarget,
4785
+ qs as rejectAllPatches,
4786
+ Hs as rejectPatch,
4787
+ Zs as removeDocDiffDecorations,
4788
+ Ms as resolvePatchTarget,
4763
4789
  sn as sectionContextDeps,
4764
- $s as setPatches,
4790
+ zs as setPatches,
4765
4791
  I as useEditorStore,
4766
- eo as validatePatentDocument,
4767
- js as writeStream,
4768
- Gs as writeStreamFromSSE
4792
+ to as validatePatentDocument,
4793
+ Gs as writeStream,
4794
+ Vs as writeStreamFromSSE
4769
4795
  };
4770
4796
  //# sourceMappingURL=lib.js.map