patent-editor 0.2.13 → 0.2.14
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 +725 -723
- package/dist/lib.js.map +1 -1
- package/package.json +1 -1
package/dist/lib.js
CHANGED
|
@@ -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
|
|
174
|
-
|
|
173
|
+
const o = e[s];
|
|
174
|
+
o && t(o);
|
|
175
175
|
},
|
|
176
176
|
[e, t]
|
|
177
177
|
);
|
|
178
178
|
return Nt(n, () => ({
|
|
179
|
-
onKeyDown: ({ event: s }) => s.key === "ArrowUp" ? (a((
|
|
180
|
-
})), e.length ? /* @__PURE__ */ g("div", { className: "slash-menu", children: e.map((s,
|
|
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(
|
|
181
181
|
"button",
|
|
182
182
|
{
|
|
183
|
-
className: `slash-menu-item ${
|
|
184
|
-
onClick: () => i(
|
|
185
|
-
onMouseEnter: () => a(
|
|
183
|
+
className: `slash-menu-item ${o === r ? "slash-menu-item--active" : ""}`,
|
|
184
|
+
onClick: () => i(o),
|
|
185
|
+
onMouseEnter: () => a(o),
|
|
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: [
|
|
@@ -344,32 +344,34 @@ function na() {
|
|
|
344
344
|
};
|
|
345
345
|
}
|
|
346
346
|
const ra = new we("searchReplace");
|
|
347
|
+
function aa(e) {
|
|
348
|
+
const t = [];
|
|
349
|
+
let n = null, r = -1;
|
|
350
|
+
return e.descendants((a, i) => {
|
|
351
|
+
if (a.isText) {
|
|
352
|
+
const s = a.text || "";
|
|
353
|
+
n && i === r ? n.text += s : (n = { text: s, pos: i }, t.push(n)), r = i + a.nodeSize;
|
|
354
|
+
} else
|
|
355
|
+
n = null, r = -1;
|
|
356
|
+
return !0;
|
|
357
|
+
}), t;
|
|
358
|
+
}
|
|
347
359
|
function ke(e, t, n) {
|
|
348
360
|
if (!t) return [];
|
|
349
|
-
const r = [], a =
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
const p = m.text || "";
|
|
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
|
-
}
|
|
365
|
-
o === l + i.length && u === -1 && (u = f + p.length);
|
|
366
|
-
} else m.isBlock && o > 0 && (o === l && (d = f), o++);
|
|
367
|
-
return !0;
|
|
368
|
-
}), d !== -1 && u !== -1 && r.push({ from: d, to: u }), c = l + 1;
|
|
361
|
+
const r = [], a = n ? t : t.toLowerCase();
|
|
362
|
+
if (!a) return r;
|
|
363
|
+
for (const i of aa(e)) {
|
|
364
|
+
const s = n ? i.text : i.text.toLowerCase();
|
|
365
|
+
let o = 0;
|
|
366
|
+
for (; o <= s.length; ) {
|
|
367
|
+
const l = s.indexOf(a, o);
|
|
368
|
+
if (l === -1) break;
|
|
369
|
+
r.push({ from: i.pos + l, to: i.pos + l + a.length }), o = l + a.length;
|
|
370
|
+
}
|
|
369
371
|
}
|
|
370
372
|
return r;
|
|
371
373
|
}
|
|
372
|
-
const
|
|
374
|
+
const ia = Oe.create({
|
|
373
375
|
name: "searchReplace",
|
|
374
376
|
addStorage() {
|
|
375
377
|
return {
|
|
@@ -408,9 +410,9 @@ const aa = Oe.create({
|
|
|
408
410
|
let a = ke(e.state.doc, t, r);
|
|
409
411
|
const i = e.state.tr;
|
|
410
412
|
let s = 0;
|
|
411
|
-
for (const
|
|
412
|
-
const l =
|
|
413
|
-
i.insertText(n, l,
|
|
413
|
+
for (const o of a) {
|
|
414
|
+
const l = o.from + s, c = o.to + s;
|
|
415
|
+
i.insertText(n, l, c), s += n.length - (o.to - o.from);
|
|
414
416
|
}
|
|
415
417
|
return e.view.dispatch(i), this.storage.results = [], this.storage.currentIndex = -1, !0;
|
|
416
418
|
},
|
|
@@ -458,23 +460,23 @@ function ft(e) {
|
|
|
458
460
|
}
|
|
459
461
|
});
|
|
460
462
|
}
|
|
461
|
-
const
|
|
463
|
+
const sa = -1, oa = 1, pt = 0;
|
|
462
464
|
let Ge = null;
|
|
463
|
-
function
|
|
465
|
+
function ca() {
|
|
464
466
|
return Ge || (Ge = new Pt()), Ge;
|
|
465
467
|
}
|
|
466
468
|
const jt = new we("patchDiff");
|
|
467
|
-
function
|
|
469
|
+
function la(e, t) {
|
|
468
470
|
let n = null;
|
|
469
471
|
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;
|
|
470
472
|
}
|
|
471
473
|
function Gt(e, t, n) {
|
|
472
474
|
const r = [];
|
|
473
475
|
let a = "", i = !0;
|
|
474
|
-
return e.state.doc.nodesBetween(t, n, (s,
|
|
476
|
+
return e.state.doc.nodesBetween(t, n, (s, o) => {
|
|
475
477
|
if (s.isText) {
|
|
476
|
-
const l =
|
|
477
|
-
r.push({ textIdx: a.length, docPos: l +
|
|
478
|
+
const l = o, c = Math.max(t, l) - l, d = Math.min(n, l + s.nodeSize) - l, u = s.text.slice(c, d);
|
|
479
|
+
r.push({ textIdx: a.length, docPos: l + c, len: u.length }), a += u, i = !1;
|
|
478
480
|
} else s.isLeaf ? (a += "\0", i = !1) : !i && s.isBlock && (a += "\0", i = !0);
|
|
479
481
|
}), { text: a, segments: r };
|
|
480
482
|
}
|
|
@@ -493,53 +495,53 @@ function ye(e, t) {
|
|
|
493
495
|
}
|
|
494
496
|
function ht(e, t, n, r, a) {
|
|
495
497
|
const { text: i, segments: s } = Gt(e, n, r);
|
|
496
|
-
let
|
|
497
|
-
for (;
|
|
498
|
-
const l = i.indexOf(t,
|
|
498
|
+
let o = 0;
|
|
499
|
+
for (; o <= i.length - t.length; ) {
|
|
500
|
+
const l = i.indexOf(t, o);
|
|
499
501
|
if (l === -1) return null;
|
|
500
|
-
const
|
|
501
|
-
if (
|
|
502
|
-
return { from:
|
|
503
|
-
|
|
502
|
+
const c = ye(s, l), d = ye(s, l + t.length);
|
|
503
|
+
if (c >= 0 && d >= 0 && !(a && a.has(c)))
|
|
504
|
+
return { from: c, to: d };
|
|
505
|
+
o = l + 1;
|
|
504
506
|
}
|
|
505
507
|
return null;
|
|
506
508
|
}
|
|
507
|
-
function
|
|
509
|
+
function Rs(e, t, n, r, a) {
|
|
508
510
|
const i = t.target;
|
|
509
511
|
let s = null;
|
|
510
|
-
const
|
|
512
|
+
const o = /* @__PURE__ */ new Set();
|
|
511
513
|
if (a)
|
|
512
514
|
for (const d of a)
|
|
513
|
-
|
|
515
|
+
o.add(d.from);
|
|
514
516
|
if (!i)
|
|
515
517
|
t.from != null && t.to != null && (s = { from: t.from, to: t.to });
|
|
516
518
|
else if (i.type === "section" && i.sectionType)
|
|
517
|
-
s =
|
|
519
|
+
s = la(e, i.sectionType);
|
|
518
520
|
else if (i.type === "ref" && i.refIndex != null) {
|
|
519
521
|
const d = n[i.refIndex];
|
|
520
522
|
(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,
|
|
523
|
+
} else i.type === "search" && i.searchText && (s = ht(e, i.searchText, 0, e.state.doc.content.size, o));
|
|
522
524
|
if (!s) return null;
|
|
523
525
|
let l = s;
|
|
524
526
|
if (t.search) {
|
|
525
|
-
const d = ht(e, t.search, s.from, s.to,
|
|
527
|
+
const d = ht(e, t.search, s.from, s.to, o);
|
|
526
528
|
d && (l = d);
|
|
527
529
|
}
|
|
528
|
-
const
|
|
530
|
+
const c = l.from < l.to ? e.state.doc.textBetween(l.from, l.to, " ", "\0") : "";
|
|
529
531
|
return {
|
|
530
532
|
id: `patch_${Date.now()}_${r}`,
|
|
531
533
|
type: t.op === "delete" ? "delete" : t.op === "insert" ? "insert" : "replace",
|
|
532
534
|
from: l.from,
|
|
533
535
|
to: t.op === "insert" ? l.from : l.to,
|
|
534
536
|
content: t.content || "",
|
|
535
|
-
originalText:
|
|
537
|
+
originalText: c,
|
|
536
538
|
reason: t.reason,
|
|
537
539
|
status: "pending"
|
|
538
540
|
};
|
|
539
541
|
}
|
|
540
542
|
const j = /* @__PURE__ */ new Map();
|
|
541
543
|
let De = [];
|
|
542
|
-
function
|
|
544
|
+
function Ms(e) {
|
|
543
545
|
return De.push(e), () => {
|
|
544
546
|
De = De.filter((t) => t !== e);
|
|
545
547
|
};
|
|
@@ -547,17 +549,17 @@ function Rs(e) {
|
|
|
547
549
|
function ue() {
|
|
548
550
|
De.forEach((e) => e());
|
|
549
551
|
}
|
|
550
|
-
function
|
|
552
|
+
function Fs(e = "default") {
|
|
551
553
|
return [...j.get(e) || []];
|
|
552
554
|
}
|
|
553
|
-
function
|
|
555
|
+
function $s(e, t = "default") {
|
|
554
556
|
j.set(t, e), ue();
|
|
555
557
|
}
|
|
556
|
-
function
|
|
558
|
+
function zs(e = "default") {
|
|
557
559
|
j.delete(e), ue();
|
|
558
560
|
}
|
|
559
|
-
function
|
|
560
|
-
const r = j.get(n) || [], a = r.find((
|
|
561
|
+
function Os(e, t, n = "default") {
|
|
562
|
+
const r = j.get(n) || [], a = r.find((o) => o.id === t);
|
|
561
563
|
if (!a || a.status !== "pending") return !1;
|
|
562
564
|
a.status = "accepted";
|
|
563
565
|
const { tr: i } = e.state;
|
|
@@ -572,19 +574,19 @@ function zs(e, t, n = "default") {
|
|
|
572
574
|
i.insertText(a.content, a.from, a.to);
|
|
573
575
|
e.view.dispatch(i);
|
|
574
576
|
const s = i.mapping;
|
|
575
|
-
for (const
|
|
576
|
-
if (
|
|
577
|
-
const l = s.map(
|
|
578
|
-
l >=
|
|
577
|
+
for (const o of r) {
|
|
578
|
+
if (o.id === t || o.status !== "pending") continue;
|
|
579
|
+
const l = s.map(o.from, 1), c = s.map(o.to, -1);
|
|
580
|
+
l >= c && o.type !== "insert" ? o.status = "rejected" : (o.from = l, o.to = o.type === "insert" ? l : c);
|
|
579
581
|
}
|
|
580
|
-
return j.set(n, r.filter((
|
|
582
|
+
return j.set(n, r.filter((o) => o.id !== t && o.status === "pending")), qe(e), ue(), !0;
|
|
581
583
|
}
|
|
582
|
-
function
|
|
584
|
+
function Bs(e, t, n = "default") {
|
|
583
585
|
const r = j.get(n) || [], a = r.find((i) => i.id === t);
|
|
584
586
|
return !a || a.status !== "pending" ? !1 : (a.status = "rejected", j.set(n, r.filter((i) => i.id !== t)), qe(e), ue(), !0);
|
|
585
587
|
}
|
|
586
|
-
function
|
|
587
|
-
const a = [...(j.get(t) || []).filter((s) => s.status === "pending")].sort((s,
|
|
588
|
+
function Hs(e, t = "default") {
|
|
589
|
+
const a = [...(j.get(t) || []).filter((s) => s.status === "pending")].sort((s, o) => o.from - s.from), { tr: i } = e.state;
|
|
588
590
|
for (const s of a)
|
|
589
591
|
if (s.type === "delete")
|
|
590
592
|
i.delete(s.from, s.to);
|
|
@@ -597,56 +599,56 @@ function Bs(e, t = "default") {
|
|
|
597
599
|
i.insertText(s.content, s.from, s.to);
|
|
598
600
|
e.view.dispatch(i), j.delete(t), qe(e), ue();
|
|
599
601
|
}
|
|
600
|
-
function
|
|
602
|
+
function Us(e, t = "default") {
|
|
601
603
|
j.delete(t), qe(e), ue();
|
|
602
604
|
}
|
|
603
605
|
function qe(e) {
|
|
604
606
|
e.view.dispatch(e.state.tr.setMeta(jt, !0));
|
|
605
607
|
}
|
|
606
|
-
function
|
|
608
|
+
function da(e, t, n) {
|
|
607
609
|
const r = [];
|
|
608
610
|
return e.nodesBetween(t, n, (a, i) => {
|
|
609
611
|
if (a.isTextblock) {
|
|
610
|
-
const s = i + 1,
|
|
611
|
-
return
|
|
612
|
+
const s = i + 1, o = i + a.nodeSize - 1, l = Math.max(s, t), c = Math.min(o, n);
|
|
613
|
+
return c > l && r.push({ from: l, to: c }), !1;
|
|
612
614
|
}
|
|
613
615
|
return !0;
|
|
614
616
|
}), r;
|
|
615
617
|
}
|
|
616
|
-
function
|
|
618
|
+
function ua(e, t) {
|
|
617
619
|
if (!t.originalText || !t.content) return null;
|
|
618
620
|
try {
|
|
619
|
-
const
|
|
620
|
-
if (
|
|
621
|
+
const o = e.resolve(t.from), l = e.resolve(t.to);
|
|
622
|
+
if (o.parent !== l.parent || !o.parent.isTextblock) return null;
|
|
621
623
|
} catch {
|
|
622
624
|
return null;
|
|
623
625
|
}
|
|
624
|
-
const n =
|
|
626
|
+
const n = ca(), r = n.diff_main(t.originalText, t.content);
|
|
625
627
|
n.diff_cleanupSemantic(r);
|
|
626
|
-
const a = r.filter(([
|
|
628
|
+
const a = r.filter(([o]) => o === pt).reduce((o, [, l]) => o + l.length, 0);
|
|
627
629
|
if (t.originalText.length > 0 && a / t.originalText.length < 0.3) return null;
|
|
628
630
|
const i = [];
|
|
629
631
|
let s = t.from;
|
|
630
|
-
for (const [
|
|
631
|
-
if (
|
|
632
|
+
for (const [o, l] of r)
|
|
633
|
+
if (o === pt)
|
|
632
634
|
s += l.length;
|
|
633
|
-
else if (
|
|
634
|
-
const
|
|
635
|
+
else if (o === sa) {
|
|
636
|
+
const c = s + l.length;
|
|
635
637
|
i.push(
|
|
636
|
-
re.inline(s,
|
|
638
|
+
re.inline(s, c, {
|
|
637
639
|
class: "patch-diff-delete",
|
|
638
640
|
"data-patch-id": t.id
|
|
639
641
|
})
|
|
640
|
-
), s =
|
|
641
|
-
} else
|
|
642
|
+
), s = c;
|
|
643
|
+
} else o === oa && i.push(
|
|
642
644
|
re.widget(s, () => {
|
|
643
|
-
const
|
|
644
|
-
return
|
|
645
|
+
const c = document.createElement("span");
|
|
646
|
+
return c.className = "patch-diff-insert-inline", c.textContent = l, c.setAttribute("data-patch-id", t.id), c;
|
|
645
647
|
}, { side: 1 })
|
|
646
648
|
);
|
|
647
649
|
return i;
|
|
648
650
|
}
|
|
649
|
-
function
|
|
651
|
+
function ma(e = "default") {
|
|
650
652
|
return new Be({
|
|
651
653
|
key: jt,
|
|
652
654
|
props: {
|
|
@@ -656,14 +658,14 @@ function ua(e = "default") {
|
|
|
656
658
|
const r = [];
|
|
657
659
|
for (const a of n) {
|
|
658
660
|
if (a.type === "replace") {
|
|
659
|
-
const i =
|
|
661
|
+
const i = ua(t.doc, a);
|
|
660
662
|
if (i) {
|
|
661
663
|
r.push(...i);
|
|
662
664
|
continue;
|
|
663
665
|
}
|
|
664
666
|
}
|
|
665
667
|
if (a.type === "delete" || a.type === "replace") {
|
|
666
|
-
const i =
|
|
668
|
+
const i = da(t.doc, a.from, a.to);
|
|
667
669
|
for (const s of i)
|
|
668
670
|
r.push(
|
|
669
671
|
re.inline(s.from, s.to, {
|
|
@@ -672,12 +674,12 @@ function ua(e = "default") {
|
|
|
672
674
|
})
|
|
673
675
|
);
|
|
674
676
|
if (a.type === "replace") {
|
|
675
|
-
const s = i.length > 0 ? i[i.length - 1].to : a.to,
|
|
677
|
+
const s = i.length > 0 ? i[i.length - 1].to : a.to, o = a.content.length > 120 || a.content.includes(`
|
|
676
678
|
`);
|
|
677
679
|
r.push(
|
|
678
680
|
re.widget(s, () => {
|
|
679
|
-
const l = document.createElement(
|
|
680
|
-
return l.className =
|
|
681
|
+
const l = document.createElement(o ? "div" : "span");
|
|
682
|
+
return l.className = o ? "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
683
|
}, { side: 1 })
|
|
682
684
|
);
|
|
683
685
|
}
|
|
@@ -709,7 +711,7 @@ function Jt(e, t) {
|
|
|
709
711
|
);
|
|
710
712
|
});
|
|
711
713
|
}
|
|
712
|
-
const
|
|
714
|
+
const ga = Z.create({
|
|
713
715
|
name: "hardBreak",
|
|
714
716
|
inline: !0,
|
|
715
717
|
group: "inline",
|
|
@@ -730,7 +732,7 @@ const ma = Z.create({
|
|
|
730
732
|
}
|
|
731
733
|
};
|
|
732
734
|
}
|
|
733
|
-
}),
|
|
735
|
+
}), fa = Oe.create({
|
|
734
736
|
name: "dragDropUX",
|
|
735
737
|
addProseMirrorPlugins() {
|
|
736
738
|
return [
|
|
@@ -741,19 +743,19 @@ const ma = Z.create({
|
|
|
741
743
|
Xn()
|
|
742
744
|
];
|
|
743
745
|
}
|
|
744
|
-
}),
|
|
746
|
+
}), pa = Oe.create({
|
|
745
747
|
name: "patchDiff",
|
|
746
748
|
addOptions() {
|
|
747
749
|
return { editorId: "default" };
|
|
748
750
|
},
|
|
749
751
|
addProseMirrorPlugins() {
|
|
750
|
-
return [
|
|
752
|
+
return [ma(this.options.editorId)];
|
|
751
753
|
}
|
|
752
|
-
}),
|
|
754
|
+
}), ha = [
|
|
753
755
|
An,
|
|
754
756
|
Ln,
|
|
755
757
|
Pn,
|
|
756
|
-
|
|
758
|
+
fa,
|
|
757
759
|
Dn.configure({
|
|
758
760
|
levels: [1, 2, 3, 4, 5, 6]
|
|
759
761
|
}),
|
|
@@ -762,7 +764,7 @@ const ma = Z.create({
|
|
|
762
764
|
Fn,
|
|
763
765
|
$n,
|
|
764
766
|
zn,
|
|
765
|
-
|
|
767
|
+
ga,
|
|
766
768
|
On,
|
|
767
769
|
Bn,
|
|
768
770
|
Hn.configure({ nested: !0 }),
|
|
@@ -795,12 +797,12 @@ const ma = Z.create({
|
|
|
795
797
|
Qr.configure({
|
|
796
798
|
suggestion: na()
|
|
797
799
|
}),
|
|
798
|
-
|
|
800
|
+
ia,
|
|
799
801
|
Yn.configure({
|
|
800
802
|
types: ["heading", "paragraph"],
|
|
801
803
|
defaultAlignment: "left"
|
|
802
804
|
})
|
|
803
|
-
],
|
|
805
|
+
], ya = [
|
|
804
806
|
nr,
|
|
805
807
|
rr,
|
|
806
808
|
ar,
|
|
@@ -814,11 +816,11 @@ const ma = Z.create({
|
|
|
814
816
|
dr,
|
|
815
817
|
ur,
|
|
816
818
|
mr.configure({ multicolor: !0 })
|
|
817
|
-
],
|
|
818
|
-
...
|
|
819
|
-
...
|
|
819
|
+
], ba = [
|
|
820
|
+
...ha,
|
|
821
|
+
...ya
|
|
820
822
|
];
|
|
821
|
-
class
|
|
823
|
+
class va {
|
|
822
824
|
constructor() {
|
|
823
825
|
Se(this, "commands", /* @__PURE__ */ new Map());
|
|
824
826
|
}
|
|
@@ -843,9 +845,9 @@ class ba {
|
|
|
843
845
|
return !r || !r.isActive ? !1 : r.isActive(n);
|
|
844
846
|
}
|
|
845
847
|
async execute(t, n, r, a = {}) {
|
|
846
|
-
var d, u, m,
|
|
847
|
-
const i = Date.now(), s = a.transaction ?? !0,
|
|
848
|
-
if (!
|
|
848
|
+
var d, u, m, p;
|
|
849
|
+
const i = Date.now(), s = a.transaction ?? !0, o = a.rollbackOnFail ?? !0, l = s ? n.editor.getJSON() : null, c = this.commands.get(t);
|
|
850
|
+
if (!c)
|
|
849
851
|
return console.warn(`Command "${t}" not found.`), (d = a.onComplete) == null || d.call(a, {
|
|
850
852
|
name: t,
|
|
851
853
|
success: !1,
|
|
@@ -858,23 +860,23 @@ class ba {
|
|
|
858
860
|
durationMs: Date.now() - i
|
|
859
861
|
}), !1;
|
|
860
862
|
try {
|
|
861
|
-
const b = !!await
|
|
862
|
-
!b && l &&
|
|
863
|
+
const b = !!await c.execute(n, r);
|
|
864
|
+
!b && l && o && n.editor.commands.setContent(l);
|
|
863
865
|
const y = {
|
|
864
866
|
name: t,
|
|
865
867
|
success: b,
|
|
866
868
|
durationMs: Date.now() - i
|
|
867
869
|
};
|
|
868
870
|
return (m = a.onComplete) == null || m.call(a, y), b;
|
|
869
|
-
} catch (
|
|
870
|
-
l &&
|
|
871
|
+
} catch (h) {
|
|
872
|
+
l && o && n.editor.commands.setContent(l);
|
|
871
873
|
const b = {
|
|
872
874
|
name: t,
|
|
873
875
|
success: !1,
|
|
874
876
|
durationMs: Date.now() - i,
|
|
875
|
-
error:
|
|
877
|
+
error: h
|
|
876
878
|
};
|
|
877
|
-
return (
|
|
879
|
+
return (p = a.onComplete) == null || p.call(a, b), !1;
|
|
878
880
|
}
|
|
879
881
|
}
|
|
880
882
|
getCommand(t) {
|
|
@@ -884,8 +886,8 @@ class ba {
|
|
|
884
886
|
return Array.from(this.commands.keys()).sort();
|
|
885
887
|
}
|
|
886
888
|
}
|
|
887
|
-
const le = new
|
|
888
|
-
class
|
|
889
|
+
const le = new va();
|
|
890
|
+
class wa {
|
|
889
891
|
constructor() {
|
|
890
892
|
Se(this, "plugins", /* @__PURE__ */ new Map());
|
|
891
893
|
Se(this, "lifecycleOrder", ["register", "init", "stateSync", "destroy"]);
|
|
@@ -970,7 +972,7 @@ class va {
|
|
|
970
972
|
});
|
|
971
973
|
}
|
|
972
974
|
}
|
|
973
|
-
const B = new
|
|
975
|
+
const B = new wa(), yt = {
|
|
974
976
|
zh: {
|
|
975
977
|
language: "语言",
|
|
976
978
|
bold: "加粗",
|
|
@@ -1223,7 +1225,7 @@ const Ie = () => {
|
|
|
1223
1225
|
document.querySelectorAll('body > svg[id^="standalone-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
|
|
1224
1226
|
(e.id.startsWith("dmermaid") || e.id.startsWith("dstandalone")) && e.remove();
|
|
1225
1227
|
}), 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());
|
|
1226
|
-
},
|
|
1228
|
+
}, xa = Z.create({
|
|
1227
1229
|
name: "mermaid",
|
|
1228
1230
|
group: "block",
|
|
1229
1231
|
atom: !0,
|
|
@@ -1245,22 +1247,22 @@ const Ie = () => {
|
|
|
1245
1247
|
i.classList.add("mermaid-node");
|
|
1246
1248
|
const s = document.createElement("div");
|
|
1247
1249
|
s.className = "mermaid-view", s.contentEditable = "false";
|
|
1248
|
-
const c = document.createElement("div");
|
|
1249
|
-
c.className = "mermaid-preview", c.contentEditable = "false";
|
|
1250
|
-
const l = document.createElement("div");
|
|
1251
|
-
l.className = "mermaid-view-hint", s.append(c, l);
|
|
1252
1250
|
const o = document.createElement("div");
|
|
1253
|
-
o.className = "mermaid-
|
|
1251
|
+
o.className = "mermaid-preview", o.contentEditable = "false";
|
|
1252
|
+
const l = document.createElement("div");
|
|
1253
|
+
l.className = "mermaid-view-hint", s.append(o, l);
|
|
1254
|
+
const c = document.createElement("div");
|
|
1255
|
+
c.className = "mermaid-edit";
|
|
1254
1256
|
const d = document.createElement("textarea");
|
|
1255
1257
|
d.className = "mermaid-editor-textarea", d.spellcheck = !1;
|
|
1256
1258
|
const u = document.createElement("div");
|
|
1257
1259
|
u.className = "mermaid-edit-toolbar";
|
|
1258
1260
|
const m = document.createElement("span");
|
|
1259
1261
|
m.className = "mermaid-error-msg";
|
|
1260
|
-
const f = document.createElement("button");
|
|
1261
|
-
f.className = "mermaid-cancel-btn", f.type = "button";
|
|
1262
1262
|
const p = document.createElement("button");
|
|
1263
|
-
p.className = "mermaid-
|
|
1263
|
+
p.className = "mermaid-cancel-btn", p.type = "button";
|
|
1264
|
+
const h = document.createElement("button");
|
|
1265
|
+
h.className = "mermaid-save-btn", h.type = "button", u.append(m, p, h), c.append(d, u), i.append(s, c);
|
|
1264
1266
|
const b = (C) => {
|
|
1265
1267
|
const _ = typeof n == "function" ? n() : null;
|
|
1266
1268
|
typeof _ == "number" && e.commands.command(({ tr: A, dispatch: D }) => (A.setNodeMarkup(_, void 0, { ...r.attrs, ...C }), D && D(A), !0));
|
|
@@ -1270,16 +1272,16 @@ const Ie = () => {
|
|
|
1270
1272
|
const _ = C.trim();
|
|
1271
1273
|
if (_ !== y) {
|
|
1272
1274
|
if (!_) {
|
|
1273
|
-
|
|
1275
|
+
o.innerHTML = "", y = "";
|
|
1274
1276
|
return;
|
|
1275
1277
|
}
|
|
1276
1278
|
try {
|
|
1277
1279
|
const A = await import("mermaid");
|
|
1278
1280
|
A.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
|
|
1279
1281
|
const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, _);
|
|
1280
|
-
|
|
1282
|
+
o.innerHTML = z, y = _;
|
|
1281
1283
|
} catch {
|
|
1282
|
-
|
|
1284
|
+
o.innerHTML = "", y = "";
|
|
1283
1285
|
} finally {
|
|
1284
1286
|
Ie();
|
|
1285
1287
|
}
|
|
@@ -1297,7 +1299,7 @@ const Ie = () => {
|
|
|
1297
1299
|
const A = await import("mermaid");
|
|
1298
1300
|
A.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
|
|
1299
1301
|
const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, _);
|
|
1300
|
-
|
|
1302
|
+
o.innerHTML = z, y = _, Ie();
|
|
1301
1303
|
} catch {
|
|
1302
1304
|
Ie();
|
|
1303
1305
|
const A = I.getState().editorLanguage;
|
|
@@ -1308,39 +1310,39 @@ const Ie = () => {
|
|
|
1308
1310
|
};
|
|
1309
1311
|
s.addEventListener("dblclick", (C) => {
|
|
1310
1312
|
C.preventDefault(), C.stopPropagation(), T();
|
|
1311
|
-
}),
|
|
1313
|
+
}), h.addEventListener("click", (C) => {
|
|
1312
1314
|
C.stopPropagation(), x();
|
|
1313
|
-
}),
|
|
1315
|
+
}), p.addEventListener("click", (C) => {
|
|
1314
1316
|
C.stopPropagation(), v();
|
|
1315
1317
|
}), d.addEventListener("mousedown", (C) => C.stopPropagation()), d.addEventListener("keydown", (C) => C.stopPropagation()), d.addEventListener("keypress", (C) => C.stopPropagation());
|
|
1316
1318
|
const S = () => {
|
|
1317
1319
|
const C = I.getState().editorLanguage, _ = H(C), A = typeof r.attrs.code == "string" ? r.attrs.code : "";
|
|
1318
|
-
s.style.display = a ? "none" : "block",
|
|
1319
|
-
const D = A.trim().length > 0, z =
|
|
1320
|
+
s.style.display = a ? "none" : "block", c.style.display = a ? "block" : "none", h.textContent = _.mermaidSaveAndRender || "保存并渲染", p.textContent = _.mermaidCancel || "取消";
|
|
1321
|
+
const D = A.trim().length > 0, z = o.querySelector("svg") !== null;
|
|
1320
1322
|
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
1323
|
};
|
|
1322
1324
|
let N = I.getState().editorLanguage;
|
|
1323
|
-
const
|
|
1325
|
+
const f = I.subscribe((C) => {
|
|
1324
1326
|
C.editorLanguage !== N && (N = C.editorLanguage, S());
|
|
1325
1327
|
});
|
|
1326
1328
|
return S(), {
|
|
1327
1329
|
dom: i,
|
|
1328
1330
|
stopEvent: (C) => {
|
|
1329
1331
|
const _ = C.target;
|
|
1330
|
-
return !!(_ === d ||
|
|
1332
|
+
return !!(_ === d || c.contains(_));
|
|
1331
1333
|
},
|
|
1332
1334
|
ignoreMutation: () => !0,
|
|
1333
1335
|
update: (C) => C.type.name !== "mermaid" ? !1 : (r = C, S(), !0),
|
|
1334
1336
|
destroy: () => {
|
|
1335
|
-
|
|
1337
|
+
f(), Ie();
|
|
1336
1338
|
}
|
|
1337
1339
|
};
|
|
1338
1340
|
};
|
|
1339
1341
|
}
|
|
1340
|
-
}),
|
|
1342
|
+
}), Ca = {
|
|
1341
1343
|
name: "mermaid",
|
|
1342
1344
|
version: "1.0.0",
|
|
1343
|
-
extensions: [
|
|
1345
|
+
extensions: [xa],
|
|
1344
1346
|
toolbarItems: [
|
|
1345
1347
|
{
|
|
1346
1348
|
id: "mermaid-insert",
|
|
@@ -1365,7 +1367,7 @@ const Ie = () => {
|
|
|
1365
1367
|
}
|
|
1366
1368
|
}
|
|
1367
1369
|
}
|
|
1368
|
-
}, Ve = "https://draw.goatpatent.com",
|
|
1370
|
+
}, Ve = "https://draw.goatpatent.com", Ta = Z.create({
|
|
1369
1371
|
name: "drawio",
|
|
1370
1372
|
group: "block",
|
|
1371
1373
|
atom: !0,
|
|
@@ -1388,16 +1390,16 @@ const Ie = () => {
|
|
|
1388
1390
|
i.classList.add("drawio-node");
|
|
1389
1391
|
const s = document.createElement("div");
|
|
1390
1392
|
s.className = "drawio-view", s.contentEditable = "false";
|
|
1391
|
-
const
|
|
1392
|
-
|
|
1393
|
+
const o = document.createElement("img");
|
|
1394
|
+
o.className = "drawio-preview-img", o.style.display = "none";
|
|
1393
1395
|
const l = document.createElement("div");
|
|
1394
|
-
l.className = "drawio-view-hint", s.append(
|
|
1395
|
-
const
|
|
1396
|
+
l.className = "drawio-view-hint", s.append(o, l), i.append(s);
|
|
1397
|
+
const c = (T) => {
|
|
1396
1398
|
const v = typeof n == "function" ? n() : null;
|
|
1397
1399
|
typeof v == "number" && e.commands.command(({ tr: x, dispatch: S }) => (x.setNodeMarkup(v, void 0, { ...r.attrs, ...T }), S && S(x), !0));
|
|
1398
1400
|
};
|
|
1399
1401
|
let d = null, u = null, m = null;
|
|
1400
|
-
const
|
|
1402
|
+
const p = () => {
|
|
1401
1403
|
if (a) return;
|
|
1402
1404
|
a = !0, u = document.createElement("div"), u.className = "drawio-modal-overlay";
|
|
1403
1405
|
const T = document.createElement("div");
|
|
@@ -1407,9 +1409,9 @@ const Ie = () => {
|
|
|
1407
1409
|
const x = I.getState().editorLanguage, S = document.createElement("span");
|
|
1408
1410
|
S.textContent = x === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", S.className = "drawio-modal-title";
|
|
1409
1411
|
const N = document.createElement("button");
|
|
1410
|
-
N.className = "drawio-modal-close-btn", N.textContent = "✕", N.type = "button", N.addEventListener("click", () =>
|
|
1411
|
-
const
|
|
1412
|
-
m.src = `${Ve}/?embed=1&proto=json&spin=1&lang=${
|
|
1412
|
+
N.className = "drawio-modal-close-btn", N.textContent = "✕", N.type = "button", N.addEventListener("click", () => h()), 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);
|
|
1413
|
+
const f = x === "en" ? "en" : "zh";
|
|
1414
|
+
m.src = `${Ve}/?embed=1&proto=json&spin=1&lang=${f}`;
|
|
1413
1415
|
const C = m;
|
|
1414
1416
|
d = (_) => {
|
|
1415
1417
|
var D, z;
|
|
@@ -1431,21 +1433,21 @@ const Ie = () => {
|
|
|
1431
1433
|
(z = C.contentWindow) == null || z.postMessage(
|
|
1432
1434
|
JSON.stringify({ action: "export", format: "svg" }),
|
|
1433
1435
|
Ve
|
|
1434
|
-
),
|
|
1436
|
+
), c({ xml: Q });
|
|
1435
1437
|
} else if (A.event === "export") {
|
|
1436
1438
|
const Q = A.data || "";
|
|
1437
|
-
|
|
1438
|
-
} else A.event === "exit" &&
|
|
1439
|
+
c({ svg: Q }), h();
|
|
1440
|
+
} else A.event === "exit" && h();
|
|
1439
1441
|
}, window.addEventListener("message", d);
|
|
1440
|
-
},
|
|
1442
|
+
}, h = () => {
|
|
1441
1443
|
a = !1, d && (window.removeEventListener("message", d), d = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null), b();
|
|
1442
1444
|
};
|
|
1443
1445
|
s.addEventListener("dblclick", (T) => {
|
|
1444
|
-
T.preventDefault(), T.stopPropagation(),
|
|
1446
|
+
T.preventDefault(), T.stopPropagation(), p();
|
|
1445
1447
|
});
|
|
1446
1448
|
const b = () => {
|
|
1447
1449
|
const T = I.getState().editorLanguage, v = H(T), x = typeof r.attrs.svg == "string" ? r.attrs.svg : "";
|
|
1448
|
-
x ? (
|
|
1450
|
+
x ? (o.src = x, o.style.display = "block") : (o.src = "", o.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
1451
|
};
|
|
1450
1452
|
let y = I.getState().editorLanguage;
|
|
1451
1453
|
const w = I.subscribe((T) => {
|
|
@@ -1461,10 +1463,10 @@ const Ie = () => {
|
|
|
1461
1463
|
};
|
|
1462
1464
|
};
|
|
1463
1465
|
}
|
|
1464
|
-
}),
|
|
1466
|
+
}), Sa = {
|
|
1465
1467
|
name: "drawio",
|
|
1466
1468
|
version: "1.0.0",
|
|
1467
|
-
extensions: [
|
|
1469
|
+
extensions: [Ta],
|
|
1468
1470
|
toolbarItems: [
|
|
1469
1471
|
{
|
|
1470
1472
|
id: "drawio-insert",
|
|
@@ -1495,9 +1497,9 @@ const Ie = () => {
|
|
|
1495
1497
|
selected: n,
|
|
1496
1498
|
editor: r
|
|
1497
1499
|
}) => {
|
|
1498
|
-
const a = W(null), [i, s] = F(!1),
|
|
1500
|
+
const a = W(null), [i, s] = F(!1), o = e.type.name === "math_block", l = W(!1), c = W(t), d = W(e.attrs.latex ?? "");
|
|
1499
1501
|
M(() => {
|
|
1500
|
-
|
|
1502
|
+
c.current = t;
|
|
1501
1503
|
}, [t]), M(() => {
|
|
1502
1504
|
d.current = e.attrs.latex ?? "";
|
|
1503
1505
|
}, [e.attrs.latex]);
|
|
@@ -1507,23 +1509,23 @@ const Ie = () => {
|
|
|
1507
1509
|
var b, y;
|
|
1508
1510
|
if (!l.current) return;
|
|
1509
1511
|
l.current = !1;
|
|
1510
|
-
const
|
|
1511
|
-
|
|
1512
|
+
const h = ((b = a.current) == null ? void 0 : b.value) ?? d.current;
|
|
1513
|
+
c.current({ latex: h }), s(!1), (y = globalThis.mathVirtualKeyboard) == null || y.hide({ animate: !0 });
|
|
1512
1514
|
}, []);
|
|
1513
1515
|
M(() => {
|
|
1514
1516
|
var b, y, w;
|
|
1515
|
-
const
|
|
1516
|
-
n &&
|
|
1517
|
+
const h = !!((w = (y = (b = r == null ? void 0 : r.view) == null ? void 0 : b.state) == null ? void 0 : y.selection) != null && w.empty);
|
|
1518
|
+
n && h && u();
|
|
1517
1519
|
}, [n, u]), M(() => {
|
|
1518
1520
|
i && requestAnimationFrame(() => {
|
|
1519
1521
|
var b;
|
|
1520
|
-
const
|
|
1521
|
-
|
|
1522
|
+
const h = a.current;
|
|
1523
|
+
h && (h.virtualKeyboardMode = "onfocus", (b = h.focus) == null || b.call(h));
|
|
1522
1524
|
});
|
|
1523
1525
|
}, [i]), M(() => {
|
|
1524
1526
|
if (!i) return;
|
|
1525
|
-
const
|
|
1526
|
-
if (!
|
|
1527
|
+
const h = a.current;
|
|
1528
|
+
if (!h) return;
|
|
1527
1529
|
const b = () => {
|
|
1528
1530
|
setTimeout(() => {
|
|
1529
1531
|
var T, v, x;
|
|
@@ -1534,40 +1536,40 @@ const Ie = () => {
|
|
|
1534
1536
|
}, y = (w) => {
|
|
1535
1537
|
w.key === "Escape" && m();
|
|
1536
1538
|
};
|
|
1537
|
-
return
|
|
1538
|
-
|
|
1539
|
+
return h.addEventListener("focusout", b), h.addEventListener("keydown", y), () => {
|
|
1540
|
+
h.removeEventListener("focusout", b), h.removeEventListener("keydown", y);
|
|
1539
1541
|
};
|
|
1540
1542
|
}, [i, m]), M(() => {
|
|
1541
1543
|
!i && a.current && a.current.value !== e.attrs.latex && (a.current.value = e.attrs.latex ?? "");
|
|
1542
1544
|
}, [e.attrs.latex, i]);
|
|
1543
|
-
let
|
|
1545
|
+
let p = "";
|
|
1544
1546
|
try {
|
|
1545
|
-
|
|
1547
|
+
p = gr.renderToString(e.attrs.latex || "", {
|
|
1546
1548
|
throwOnError: !1,
|
|
1547
|
-
displayMode:
|
|
1549
|
+
displayMode: o
|
|
1548
1550
|
});
|
|
1549
1551
|
} catch {
|
|
1550
|
-
|
|
1552
|
+
p = e.attrs.latex || "";
|
|
1551
1553
|
}
|
|
1552
1554
|
return /* @__PURE__ */ g(
|
|
1553
1555
|
_n,
|
|
1554
1556
|
{
|
|
1555
|
-
as:
|
|
1556
|
-
className:
|
|
1557
|
+
as: o ? "div" : "span",
|
|
1558
|
+
className: o ? "math-block" : "math-inline",
|
|
1557
1559
|
children: i ? /* @__PURE__ */ g(
|
|
1558
1560
|
"math-field",
|
|
1559
1561
|
{
|
|
1560
1562
|
ref: a,
|
|
1561
|
-
className:
|
|
1563
|
+
className: o ? "math-live-field math-live-field--block" : "math-live-field",
|
|
1562
1564
|
children: e.attrs.latex
|
|
1563
1565
|
}
|
|
1564
1566
|
) : /* @__PURE__ */ L("span", { className: "math-preview", onClick: u, children: [
|
|
1565
|
-
/* @__PURE__ */ g("span", { dangerouslySetInnerHTML: { __html:
|
|
1567
|
+
/* @__PURE__ */ g("span", { dangerouslySetInnerHTML: { __html: p } }),
|
|
1566
1568
|
/* @__PURE__ */ g("span", { className: "math-tooltip", children: "点击编辑" })
|
|
1567
1569
|
] })
|
|
1568
1570
|
}
|
|
1569
1571
|
);
|
|
1570
|
-
},
|
|
1572
|
+
}, Ea = Z.create({
|
|
1571
1573
|
name: "math_inline",
|
|
1572
1574
|
group: "inline",
|
|
1573
1575
|
inline: !0,
|
|
@@ -1600,7 +1602,7 @@ const Ie = () => {
|
|
|
1600
1602
|
}
|
|
1601
1603
|
});
|
|
1602
1604
|
}
|
|
1603
|
-
}),
|
|
1605
|
+
}), ka = Z.create({
|
|
1604
1606
|
name: "math_block",
|
|
1605
1607
|
group: "block",
|
|
1606
1608
|
atom: !0,
|
|
@@ -1623,10 +1625,10 @@ const Ie = () => {
|
|
|
1623
1625
|
}
|
|
1624
1626
|
});
|
|
1625
1627
|
}
|
|
1626
|
-
}),
|
|
1628
|
+
}), _a = {
|
|
1627
1629
|
name: "math",
|
|
1628
1630
|
version: "1.0.0",
|
|
1629
|
-
extensions: [
|
|
1631
|
+
extensions: [Ea, ka],
|
|
1630
1632
|
toolbarItems: [
|
|
1631
1633
|
{
|
|
1632
1634
|
id: "math-inline-insert",
|
|
@@ -1674,10 +1676,10 @@ const Ie = () => {
|
|
|
1674
1676
|
}, st = (e, t, n = {}) => {
|
|
1675
1677
|
const r = n.from ?? 0, a = n.to ?? e.state.doc.content.size;
|
|
1676
1678
|
let i = null;
|
|
1677
|
-
return e.state.doc.nodesBetween(r, a, (s,
|
|
1679
|
+
return e.state.doc.nodesBetween(r, a, (s, o) => i ? !1 : s.type.name === t ? (i = { node: s, pos: o }, !1) : !0), i;
|
|
1678
1680
|
}, Xt = (e, t, n = {}) => {
|
|
1679
1681
|
const r = n.from ?? 0, a = n.to ?? e.state.doc.content.size, i = [];
|
|
1680
|
-
return e.state.doc.nodesBetween(r, a, (s,
|
|
1682
|
+
return e.state.doc.nodesBetween(r, a, (s, o) => (t(s, o) && i.push({ node: s, pos: o }), !0)), i;
|
|
1681
1683
|
}, Re = (e, t) => {
|
|
1682
1684
|
const { $from: n } = e.state.selection;
|
|
1683
1685
|
for (let r = n.depth; r >= 0; r -= 1) {
|
|
@@ -1689,7 +1691,7 @@ const Ie = () => {
|
|
|
1689
1691
|
};
|
|
1690
1692
|
}
|
|
1691
1693
|
return null;
|
|
1692
|
-
},
|
|
1694
|
+
}, Ia = (e) => {
|
|
1693
1695
|
const { $from: t } = e.state.selection;
|
|
1694
1696
|
for (let n = t.depth; n >= 0; n -= 1) {
|
|
1695
1697
|
const r = t.node(n);
|
|
@@ -1700,7 +1702,7 @@ const Ie = () => {
|
|
|
1700
1702
|
};
|
|
1701
1703
|
}
|
|
1702
1704
|
return null;
|
|
1703
|
-
},
|
|
1705
|
+
}, Na = (e, t) => e.state.schema.nodes[t] || null, Aa = (e) => {
|
|
1704
1706
|
const t = Array.isArray(e.content) ? e.content : e.content ? [e.content] : void 0;
|
|
1705
1707
|
return {
|
|
1706
1708
|
type: e.type,
|
|
@@ -1708,7 +1710,7 @@ const Ie = () => {
|
|
|
1708
1710
|
content: t
|
|
1709
1711
|
};
|
|
1710
1712
|
}, Yt = (e, t) => {
|
|
1711
|
-
const n =
|
|
1713
|
+
const n = Aa(t);
|
|
1712
1714
|
return typeof t.position == "number" ? e.chain().focus().insertContentAt(t.position, n).run() : e.chain().focus().insertContent(n).run();
|
|
1713
1715
|
}, ze = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
|
|
1714
1716
|
var l;
|
|
@@ -1718,25 +1720,25 @@ const Ie = () => {
|
|
|
1718
1720
|
const s = r.doc.nodeAt(i);
|
|
1719
1721
|
if (!s || t.type && s.type.name !== t.type)
|
|
1720
1722
|
return !1;
|
|
1721
|
-
const
|
|
1722
|
-
return n.setNodeMarkup(i, void 0,
|
|
1723
|
+
const o = { ...s.attrs, ...t.attrs };
|
|
1724
|
+
return n.setNodeMarkup(i, void 0, o), a && a(n), !0;
|
|
1723
1725
|
}), Zt = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
|
|
1724
|
-
var
|
|
1725
|
-
const i = typeof t.position == "number" ? t.position : (
|
|
1726
|
+
var o;
|
|
1727
|
+
const i = typeof t.position == "number" ? t.position : (o = st(e, t.type || "")) == null ? void 0 : o.pos;
|
|
1726
1728
|
if (typeof i != "number")
|
|
1727
1729
|
return !1;
|
|
1728
1730
|
const s = r.doc.nodeAt(i);
|
|
1729
1731
|
return !s || t.type && s.type.name !== t.type ? !1 : (n.delete(i, i + s.nodeSize), a && a(n), !0);
|
|
1730
1732
|
}), Qt = (e, t) => {
|
|
1731
|
-
const n =
|
|
1733
|
+
const n = Na(e, t.type);
|
|
1732
1734
|
return n ? e.commands.command(({ tr: r, state: a, dispatch: i }) => {
|
|
1733
|
-
const { from: s, to:
|
|
1735
|
+
const { from: s, to: o } = a.selection, l = a.selection.$from.blockRange(a.selection.$to);
|
|
1734
1736
|
if (!l)
|
|
1735
1737
|
return !1;
|
|
1736
|
-
const
|
|
1737
|
-
return
|
|
1738
|
+
const c = fr(l, n, t.attrs);
|
|
1739
|
+
return c ? (r.wrap(l, c), i && i(r.scrollIntoView()), s <= o) : !1;
|
|
1738
1740
|
}) : !1;
|
|
1739
|
-
},
|
|
1741
|
+
}, La = (e, t) => {
|
|
1740
1742
|
if (t.length === 0)
|
|
1741
1743
|
return !1;
|
|
1742
1744
|
const n = e.getJSON();
|
|
@@ -1748,13 +1750,13 @@ const Ie = () => {
|
|
|
1748
1750
|
let Ne = 0;
|
|
1749
1751
|
const Qe = [];
|
|
1750
1752
|
let Ae = !1;
|
|
1751
|
-
const
|
|
1753
|
+
const Pa = 2e4, bt = 6e4;
|
|
1752
1754
|
let $ = null, Me = !1, ne = null, pe = null;
|
|
1753
1755
|
const et = /* @__PURE__ */ new Map();
|
|
1754
1756
|
function vt() {
|
|
1755
1757
|
ne && (window.removeEventListener("message", ne), ne = null), $ && ($.src = "about:blank", $.remove(), $ = null), Me = !1;
|
|
1756
1758
|
}
|
|
1757
|
-
function
|
|
1759
|
+
function Da(e, t) {
|
|
1758
1760
|
const n = et.get(e);
|
|
1759
1761
|
if (n) {
|
|
1760
1762
|
t(n);
|
|
@@ -1783,26 +1785,26 @@ function tt() {
|
|
|
1783
1785
|
};
|
|
1784
1786
|
ne = (s) => {
|
|
1785
1787
|
if (!$ || s.source !== $.contentWindow) return;
|
|
1786
|
-
let
|
|
1788
|
+
let o;
|
|
1787
1789
|
try {
|
|
1788
|
-
|
|
1790
|
+
o = typeof s.data == "string" ? JSON.parse(s.data) : s.data;
|
|
1789
1791
|
} catch {
|
|
1790
1792
|
return;
|
|
1791
1793
|
}
|
|
1792
|
-
|
|
1794
|
+
o.event === "init" ? (Me = !0, i()) : o.event === "load" ? setTimeout(() => {
|
|
1793
1795
|
var l;
|
|
1794
1796
|
(l = $ == null ? void 0 : $.contentWindow) == null || l.postMessage(
|
|
1795
1797
|
JSON.stringify({ action: "export", format: "svg" }),
|
|
1796
1798
|
de
|
|
1797
1799
|
);
|
|
1798
|
-
}, 1500) :
|
|
1799
|
-
}, window.addEventListener("message", ne), r = setTimeout(() => a(""),
|
|
1800
|
+
}, 1500) : o.event === "export" && a(o.data || "");
|
|
1801
|
+
}, window.addEventListener("message", ne), r = setTimeout(() => a(""), Pa), $ ? 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
1802
|
}
|
|
1801
1803
|
const Le = () => {
|
|
1802
1804
|
document.querySelectorAll('body > svg[id^="fig-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
|
|
1803
1805
|
(e.id.startsWith("dmermaid") || e.id.startsWith("dfi")) && e.remove();
|
|
1804
1806
|
}), document.querySelectorAll("body > #dmermaid-svg").forEach((e) => e.remove()), document.querySelectorAll("body > style[data-mermaid-style]").forEach((e) => e.remove());
|
|
1805
|
-
},
|
|
1807
|
+
}, Ra = Z.create({
|
|
1806
1808
|
name: "figure",
|
|
1807
1809
|
group: "block",
|
|
1808
1810
|
content: "inline*",
|
|
@@ -1833,24 +1835,24 @@ const Le = () => {
|
|
|
1833
1835
|
let r = t, a = !1, i = !1;
|
|
1834
1836
|
const s = document.createElement("figure");
|
|
1835
1837
|
s.setAttribute("data-type", "figure"), s.className = "figure-block";
|
|
1836
|
-
const
|
|
1837
|
-
|
|
1838
|
+
const o = document.createElement("div");
|
|
1839
|
+
o.className = "figure-visual", o.contentEditable = "false", o.setAttribute("spellcheck", "false");
|
|
1838
1840
|
const l = document.createElement("img");
|
|
1839
1841
|
l.className = "figure-img-preview";
|
|
1840
|
-
const
|
|
1841
|
-
|
|
1842
|
+
const c = document.createElement("div");
|
|
1843
|
+
c.className = "figure-upload-area";
|
|
1842
1844
|
const d = document.createElement("span");
|
|
1843
1845
|
d.className = "figure-upload-hint";
|
|
1844
1846
|
const u = document.createElement("input");
|
|
1845
1847
|
u.type = "file", u.accept = "image/*", u.style.display = "none";
|
|
1846
1848
|
const m = document.createElement("button");
|
|
1847
|
-
m.className = "figure-replace-btn",
|
|
1848
|
-
const f = document.createElement("div");
|
|
1849
|
-
f.className = "figure-mermaid-view", f.contentEditable = "false", f.setAttribute("spellcheck", "false");
|
|
1849
|
+
m.className = "figure-replace-btn", c.append(d, u);
|
|
1850
1850
|
const p = document.createElement("div");
|
|
1851
|
-
p.className = "figure-mermaid-
|
|
1851
|
+
p.className = "figure-mermaid-view", p.contentEditable = "false", p.setAttribute("spellcheck", "false");
|
|
1852
|
+
const h = document.createElement("div");
|
|
1853
|
+
h.className = "figure-mermaid-preview", h.contentEditable = "false";
|
|
1852
1854
|
const b = document.createElement("div");
|
|
1853
|
-
b.className = "figure-mermaid-view-hint",
|
|
1855
|
+
b.className = "figure-mermaid-view-hint", p.append(h, b);
|
|
1854
1856
|
const y = document.createElement("div");
|
|
1855
1857
|
y.className = "figure-mermaid-edit";
|
|
1856
1858
|
const w = document.createElement("textarea");
|
|
@@ -1865,16 +1867,16 @@ const Le = () => {
|
|
|
1865
1867
|
S.className = "figure-mermaid-error-inline", T.append(S, x, v), y.append(w, T);
|
|
1866
1868
|
const N = document.createElement("div");
|
|
1867
1869
|
N.className = "figure-drawio-view", N.contentEditable = "false";
|
|
1868
|
-
const
|
|
1869
|
-
|
|
1870
|
+
const f = document.createElement("img");
|
|
1871
|
+
f.className = "figure-drawio-preview-img", f.style.display = "none";
|
|
1870
1872
|
const C = document.createElement("div");
|
|
1871
|
-
C.className = "figure-drawio-view-hint", N.append(
|
|
1873
|
+
C.className = "figure-drawio-view-hint", N.append(f, C), o.append(l, c, m), o.append(p, y), o.append(N);
|
|
1872
1874
|
const _ = document.createElement("figcaption");
|
|
1873
1875
|
_.className = "figure-caption";
|
|
1874
1876
|
const A = document.createElement("span");
|
|
1875
1877
|
A.className = "figure-id-label", A.contentEditable = "false";
|
|
1876
1878
|
const D = document.createElement("span");
|
|
1877
|
-
D.className = "figure-caption-content", _.append(A, D), s.append(
|
|
1879
|
+
D.className = "figure-caption-content", _.append(A, D), s.append(o, _);
|
|
1878
1880
|
const z = (E) => {
|
|
1879
1881
|
const k = typeof n == "function" ? n() : null;
|
|
1880
1882
|
typeof k == "number" && e.commands.command(({ tr: P, dispatch: O }) => (P.setNodeMarkup(k, void 0, { ...r.attrs, ...E }), O && O(P), !0));
|
|
@@ -1887,15 +1889,15 @@ const Le = () => {
|
|
|
1887
1889
|
typeof P.result == "string" && z({ imageSrc: P.result });
|
|
1888
1890
|
}, P.readAsDataURL(k);
|
|
1889
1891
|
};
|
|
1890
|
-
u.addEventListener("change", () => Q(u.files)),
|
|
1892
|
+
u.addEventListener("change", () => Q(u.files)), c.addEventListener("click", () => u.click()), m.addEventListener("click", (E) => {
|
|
1891
1893
|
E.stopPropagation(), u.click();
|
|
1892
|
-
}),
|
|
1893
|
-
r.attrs.contentType === "image" && (E.preventDefault(), E.stopPropagation(),
|
|
1894
|
-
}),
|
|
1895
|
-
|
|
1896
|
-
}),
|
|
1894
|
+
}), o.addEventListener("dragover", (E) => {
|
|
1895
|
+
r.attrs.contentType === "image" && (E.preventDefault(), E.stopPropagation(), c.classList.add("figure-upload-area--dragover"));
|
|
1896
|
+
}), o.addEventListener("dragleave", () => {
|
|
1897
|
+
c.classList.remove("figure-upload-area--dragover");
|
|
1898
|
+
}), o.addEventListener("drop", (E) => {
|
|
1897
1899
|
var k;
|
|
1898
|
-
|
|
1900
|
+
c.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
1901
|
});
|
|
1900
1902
|
const gn = () => {
|
|
1901
1903
|
a || (a = !0, w.value = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "", S.textContent = "", S.style.display = "none", J(), requestAnimationFrame(() => w.focus()));
|
|
@@ -1910,7 +1912,7 @@ const Le = () => {
|
|
|
1910
1912
|
const P = await import("mermaid");
|
|
1911
1913
|
P.default.initialize({ startOnLoad: !1, theme: "default" }), Ne += 1;
|
|
1912
1914
|
const O = `fig-mermaid-${Ne}`, { svg: R } = await P.default.render(O, k);
|
|
1913
|
-
|
|
1915
|
+
h.innerHTML = R, Le();
|
|
1914
1916
|
} catch {
|
|
1915
1917
|
Le();
|
|
1916
1918
|
const P = I.getState().editorLanguage;
|
|
@@ -1919,7 +1921,7 @@ const Le = () => {
|
|
|
1919
1921
|
}
|
|
1920
1922
|
z({ mermaidCode: E }), a = !1, J();
|
|
1921
1923
|
};
|
|
1922
|
-
|
|
1924
|
+
p.addEventListener("dblclick", (E) => {
|
|
1923
1925
|
E.preventDefault(), E.stopPropagation(), gn();
|
|
1924
1926
|
}), v.addEventListener("click", (E) => {
|
|
1925
1927
|
E.stopPropagation(), pn();
|
|
@@ -1974,7 +1976,7 @@ const Le = () => {
|
|
|
1974
1976
|
E.preventDefault(), E.stopPropagation(), hn();
|
|
1975
1977
|
}), s.addEventListener("mousedown", (E) => {
|
|
1976
1978
|
const k = E.target;
|
|
1977
|
-
if (!(k instanceof HTMLElement) || k === D || D.contains(k) || k === w || y.contains(k) || k ===
|
|
1979
|
+
if (!(k instanceof HTMLElement) || k === D || D.contains(k) || k === w || y.contains(k) || k === c || c.contains(k) || k === m || k === u || p.contains(k) || N.contains(k)) return;
|
|
1978
1980
|
const P = typeof n == "function" ? n() : null;
|
|
1979
1981
|
if (typeof P != "number") return;
|
|
1980
1982
|
const O = P + r.nodeSize - 1, R = Zn.create(e.state.doc, O);
|
|
@@ -1987,16 +1989,16 @@ const Le = () => {
|
|
|
1987
1989
|
const k = E.trim();
|
|
1988
1990
|
if (k !== ge) {
|
|
1989
1991
|
if (!k) {
|
|
1990
|
-
|
|
1992
|
+
h.innerHTML = "", ge = "";
|
|
1991
1993
|
return;
|
|
1992
1994
|
}
|
|
1993
1995
|
try {
|
|
1994
1996
|
const P = await import("mermaid");
|
|
1995
1997
|
P.default.initialize({ startOnLoad: !1, theme: "default" }), Ne += 1;
|
|
1996
1998
|
const O = `fig-mermaid-${Ne}`, { svg: R } = await P.default.render(O, k);
|
|
1997
|
-
|
|
1999
|
+
h.innerHTML = R, ge = k;
|
|
1998
2000
|
} catch {
|
|
1999
|
-
|
|
2001
|
+
h.innerHTML = "", ge = "";
|
|
2000
2002
|
} finally {
|
|
2001
2003
|
Le();
|
|
2002
2004
|
}
|
|
@@ -2005,16 +2007,16 @@ const Le = () => {
|
|
|
2005
2007
|
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
2008
|
O ? (A.textContent = `[${O}] `, A.style.display = "inline") : (A.textContent = "", A.style.display = "none");
|
|
2007
2009
|
const K = P === "image", X = P === "mermaid", q = P === "drawio";
|
|
2008
|
-
l.style.display = K && R ? "block" : "none",
|
|
2010
|
+
l.style.display = K && R ? "block" : "none", c.style.display = K && !R ? "flex" : "none", m.style.display = K && R ? "block" : "none", p.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
2011
|
const oe = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
|
|
2010
|
-
q && (oe ? (
|
|
2011
|
-
const Te = fe.trim().length > 0, ce =
|
|
2012
|
+
q && (oe ? (f.src = oe, f.style.display = "block") : (f.src = "", f.style.display = "none")), d.textContent = k.figureUploadHint || "点击上传或拖拽图片", m.textContent = k.figureReplaceImage || "更换图片", v.textContent = k.mermaidSaveAndRender || "保存并渲染", x.textContent = k.mermaidCancel || "取消";
|
|
2013
|
+
const Te = fe.trim().length > 0, ce = h.querySelector("svg") !== null;
|
|
2012
2014
|
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
2015
|
const Cn = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "";
|
|
2014
2016
|
q && Cn && !oe && !xe && !i && (se && clearTimeout(se), se = setTimeout(() => {
|
|
2015
2017
|
se = null;
|
|
2016
2018
|
const dt = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "", Tn = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
|
|
2017
|
-
!dt || Tn || xe || (xe = !0,
|
|
2019
|
+
!dt || Tn || xe || (xe = !0, Da(dt, (ut) => {
|
|
2018
2020
|
xe = !1, ut ? (Ce = 0, z({ drawioSvg: ut })) : Ce < yn && (Ce++, me = setTimeout(() => {
|
|
2019
2021
|
me = null, J();
|
|
2020
2022
|
}, vn * Ce));
|
|
@@ -2034,7 +2036,7 @@ const Le = () => {
|
|
|
2034
2036
|
},
|
|
2035
2037
|
ignoreMutation: (E) => {
|
|
2036
2038
|
const k = E.target;
|
|
2037
|
-
return !!(
|
|
2039
|
+
return !!(o.contains(k) || A.contains(k));
|
|
2038
2040
|
},
|
|
2039
2041
|
update: (E) => E.type.name !== "figure" ? !1 : (r = E, J(), !0),
|
|
2040
2042
|
destroy: () => {
|
|
@@ -2043,7 +2045,7 @@ const Le = () => {
|
|
|
2043
2045
|
};
|
|
2044
2046
|
};
|
|
2045
2047
|
}
|
|
2046
|
-
}),
|
|
2048
|
+
}), Ma = Z.create({
|
|
2047
2049
|
name: "reference",
|
|
2048
2050
|
group: "inline",
|
|
2049
2051
|
inline: !0,
|
|
@@ -2104,22 +2106,22 @@ const Le = () => {
|
|
|
2104
2106
|
return ({ node: e, editor: t }) => {
|
|
2105
2107
|
let n = e;
|
|
2106
2108
|
const r = document.createElement("span"), a = () => {
|
|
2107
|
-
const i = n.attrs.lang === "en" ? "en" : "zh", s = H(i),
|
|
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 :
|
|
2109
|
+
const i = n.attrs.lang === "en" ? "en" : "zh", s = H(i), o = n.attrs.targetType === "figure" ? "figure" : "claim", l = Number(n.attrs.resolvedNumber), c = typeof n.attrs.resolvedFigureId == "string" && n.attrs.resolvedFigureId ? n.attrs.resolvedFigureId : null, d = o === "figure" ? c || (i === "en" ? "Figure ?" : "附图?") : Number.isFinite(l) ? s.claimLabel(l) : i === "en" ? "Claim ?" : "权利要求?", u = n.attrs.displayText || d;
|
|
2110
|
+
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;
|
|
2109
2111
|
};
|
|
2110
2112
|
return a(), r.addEventListener("click", () => {
|
|
2111
2113
|
const i = n.attrs.targetType === "figure" ? "figure" : "claim";
|
|
2112
2114
|
n.attrs.invalid || setTimeout(() => {
|
|
2113
2115
|
let s = null;
|
|
2114
2116
|
if (i === "figure") {
|
|
2115
|
-
const
|
|
2116
|
-
if (!
|
|
2117
|
+
const o = typeof n.attrs.targetFigureId == "string" ? n.attrs.targetFigureId : "";
|
|
2118
|
+
if (!o)
|
|
2117
2119
|
return;
|
|
2118
|
-
t.state.doc.descendants((l,
|
|
2120
|
+
t.state.doc.descendants((l, c) => s !== null ? !1 : l.type.name === "figure" && l.attrs.id === o ? (s = c, !1) : !0);
|
|
2119
2121
|
} else {
|
|
2120
2122
|
if (!n.attrs.targetClaimId)
|
|
2121
2123
|
return;
|
|
2122
|
-
t.state.doc.descendants((
|
|
2124
|
+
t.state.doc.descendants((o, l) => s !== null ? !1 : o.type.name === "claim" && o.attrs.claimId === n.attrs.targetClaimId ? (s = l, !1) : !0);
|
|
2123
2125
|
}
|
|
2124
2126
|
typeof s == "number" && t.chain().focus().setTextSelection(s + 1).scrollIntoView().run();
|
|
2125
2127
|
}, 0);
|
|
@@ -2144,7 +2146,7 @@ const Le = () => {
|
|
|
2144
2146
|
design_description: "sectionTitle_design_description",
|
|
2145
2147
|
design_views: "sectionTitle_design_views",
|
|
2146
2148
|
design_brief: "sectionTitle_design_brief"
|
|
2147
|
-
},
|
|
2149
|
+
}, Fa = /* @__PURE__ */ new Set([
|
|
2148
2150
|
"abstract",
|
|
2149
2151
|
"abstract_drawing",
|
|
2150
2152
|
"claims",
|
|
@@ -2155,7 +2157,7 @@ const Le = () => {
|
|
|
2155
2157
|
"design_description",
|
|
2156
2158
|
"design_views",
|
|
2157
2159
|
"design_brief"
|
|
2158
|
-
]),
|
|
2160
|
+
]), $a = /* @__PURE__ */ new Set([
|
|
2159
2161
|
"technical_field",
|
|
2160
2162
|
"background_art",
|
|
2161
2163
|
"summary",
|
|
@@ -2170,7 +2172,7 @@ const Le = () => {
|
|
|
2170
2172
|
return e.forEach((n) => {
|
|
2171
2173
|
!t && ot(n) && (t = !0);
|
|
2172
2174
|
}), t;
|
|
2173
|
-
},
|
|
2175
|
+
}, za = Z.create({
|
|
2174
2176
|
name: "patent_title",
|
|
2175
2177
|
group: "block",
|
|
2176
2178
|
content: "inline*",
|
|
@@ -2199,41 +2201,41 @@ const Le = () => {
|
|
|
2199
2201
|
i.className = "pb-heading", i.contentEditable = "false";
|
|
2200
2202
|
const s = document.createElement("div");
|
|
2201
2203
|
s.className = "ps-placeholder", s.contentEditable = "false";
|
|
2202
|
-
const
|
|
2203
|
-
|
|
2204
|
+
const o = document.createElement("h1");
|
|
2205
|
+
o.className = "pt-title-content", a.append(i, s, o);
|
|
2204
2206
|
const l = () => {
|
|
2205
2207
|
const b = typeof n == "function" ? n() : null;
|
|
2206
2208
|
return typeof b == "number" ? b : null;
|
|
2207
|
-
},
|
|
2209
|
+
}, c = () => {
|
|
2208
2210
|
const b = l();
|
|
2209
2211
|
b !== null && I.getState().setActiveSection("patent_title", b);
|
|
2210
2212
|
}, d = () => {
|
|
2211
2213
|
const b = l();
|
|
2212
2214
|
b !== null && (I.getState().openDraftingPanel("patent_title", b), e.commands.focus(b + 1));
|
|
2213
2215
|
};
|
|
2214
|
-
s.addEventListener("click", d),
|
|
2216
|
+
s.addEventListener("click", d), o.addEventListener("focusin", c), o.addEventListener("click", c);
|
|
2215
2217
|
const u = () => {
|
|
2216
2218
|
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
2219
|
i.textContent = w;
|
|
2218
2220
|
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),
|
|
2221
|
+
s.textContent = `[${T}]`, s.style.display = v ? "none" : "", s.classList.toggle("ps-placeholder--active", x && !v), o.classList.toggle("pt-title-content--has-content", v);
|
|
2220
2222
|
};
|
|
2221
|
-
let m = I.getState().editorLanguage,
|
|
2222
|
-
const
|
|
2223
|
-
const y = b.editorLanguage !== m, w = b.rightPanel.activeSectionPos !==
|
|
2224
|
-
m = b.editorLanguage,
|
|
2223
|
+
let m = I.getState().editorLanguage, p = I.getState().rightPanel.activeSectionPos;
|
|
2224
|
+
const h = I.subscribe((b) => {
|
|
2225
|
+
const y = b.editorLanguage !== m, w = b.rightPanel.activeSectionPos !== p;
|
|
2226
|
+
m = b.editorLanguage, p = b.rightPanel.activeSectionPos, (y || w) && u();
|
|
2225
2227
|
});
|
|
2226
2228
|
return u(), {
|
|
2227
2229
|
dom: a,
|
|
2228
|
-
contentDOM:
|
|
2230
|
+
contentDOM: o,
|
|
2229
2231
|
update: (b) => b.type.name !== "patent_title" ? !1 : (r = b, u(), !0),
|
|
2230
2232
|
destroy: () => {
|
|
2231
|
-
|
|
2233
|
+
h(), s.removeEventListener("click", d), o.removeEventListener("focusin", c), o.removeEventListener("click", c);
|
|
2232
2234
|
}
|
|
2233
2235
|
};
|
|
2234
2236
|
};
|
|
2235
2237
|
}
|
|
2236
|
-
}),
|
|
2238
|
+
}), Oa = Z.create({
|
|
2237
2239
|
name: "patent_section",
|
|
2238
2240
|
group: "block",
|
|
2239
2241
|
content: "block+",
|
|
@@ -2300,57 +2302,57 @@ const Le = () => {
|
|
|
2300
2302
|
i.contentEditable = "false";
|
|
2301
2303
|
const s = document.createElement("div");
|
|
2302
2304
|
s.className = "ps-body";
|
|
2303
|
-
const
|
|
2304
|
-
|
|
2305
|
+
const o = document.createElement("div");
|
|
2306
|
+
o.className = "ps-placeholder", o.contentEditable = "false";
|
|
2305
2307
|
const l = document.createElement("div");
|
|
2306
|
-
l.className = "ps-content", s.append(
|
|
2307
|
-
const
|
|
2308
|
+
l.className = "ps-content", s.append(o, l), a.append(i, s);
|
|
2309
|
+
const c = () => {
|
|
2308
2310
|
const y = typeof n == "function" ? n() : null;
|
|
2309
2311
|
return typeof y == "number" ? y : null;
|
|
2310
2312
|
}, d = () => {
|
|
2311
|
-
const y =
|
|
2313
|
+
const y = c();
|
|
2312
2314
|
if (y === null) return;
|
|
2313
2315
|
I.getState().setActiveSection(r.attrs.sectionType, y);
|
|
2314
2316
|
}, u = () => {
|
|
2315
|
-
const y =
|
|
2317
|
+
const y = c();
|
|
2316
2318
|
if (y === null) return;
|
|
2317
2319
|
I.getState().openDraftingPanel(r.attrs.sectionType, y), e.commands.focus(y + 1);
|
|
2318
2320
|
};
|
|
2319
|
-
|
|
2321
|
+
o.addEventListener("click", u), l.addEventListener("focusin", d), l.addEventListener("click", d);
|
|
2320
2322
|
const m = () => {
|
|
2321
|
-
const y = I.getState(), w = H(y.editorLanguage), T = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", v =
|
|
2322
|
-
a.className = `ps${
|
|
2323
|
+
const y = I.getState(), w = H(y.editorLanguage), T = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", v = Fa.has(T), x = $a.has(T), S = wt[T], N = typeof w[S] == "string" ? w[S] : T, f = ot(r), C = y.rightPanel.activeSectionPos === c();
|
|
2324
|
+
a.className = `ps${f ? "" : " ps--empty"}${x ? " ps--sub" : ""}`, a.setAttribute("data-section-type", T), i.className = v ? "pb-heading" : "ps-heading ps-heading--sub", i.textContent = N, o.textContent = `[${N}]`, o.style.display = f ? "none" : "", o.classList.toggle("ps-placeholder--active", C && !f), l.classList.toggle("ps-content--has-content", f);
|
|
2323
2325
|
};
|
|
2324
|
-
let
|
|
2326
|
+
let p = I.getState().editorLanguage, h = I.getState().rightPanel.activeSectionPos;
|
|
2325
2327
|
const b = I.subscribe((y) => {
|
|
2326
|
-
const w = y.editorLanguage !==
|
|
2327
|
-
|
|
2328
|
+
const w = y.editorLanguage !== p, T = y.rightPanel.activeSectionPos !== h;
|
|
2329
|
+
p = y.editorLanguage, h = y.rightPanel.activeSectionPos, (w || T) && m();
|
|
2328
2330
|
});
|
|
2329
2331
|
return m(), {
|
|
2330
2332
|
dom: a,
|
|
2331
2333
|
contentDOM: l,
|
|
2332
2334
|
update: (y) => y.type.name !== "patent_section" ? !1 : (r = y, m(), !0),
|
|
2333
2335
|
destroy: () => {
|
|
2334
|
-
b(),
|
|
2336
|
+
b(), o.removeEventListener("click", u), l.removeEventListener("focusin", d), l.removeEventListener("click", d);
|
|
2335
2337
|
}
|
|
2336
2338
|
};
|
|
2337
2339
|
};
|
|
2338
2340
|
}
|
|
2339
|
-
}),
|
|
2341
|
+
}), Ba = [
|
|
2340
2342
|
"abstract",
|
|
2341
2343
|
// 说明书摘要
|
|
2342
2344
|
"abstract_drawing"
|
|
2343
2345
|
// 摘要附图
|
|
2344
|
-
],
|
|
2346
|
+
], Ha = [
|
|
2345
2347
|
"technical_field",
|
|
2346
2348
|
"background_art",
|
|
2347
2349
|
"summary",
|
|
2348
2350
|
"drawing_description",
|
|
2349
2351
|
"detailed_description"
|
|
2350
|
-
],
|
|
2352
|
+
], Ua = [
|
|
2351
2353
|
"drawing_figures"
|
|
2352
2354
|
// 说明书附图
|
|
2353
|
-
],
|
|
2355
|
+
], qa = [
|
|
2354
2356
|
"design_product_name",
|
|
2355
2357
|
"design_usage",
|
|
2356
2358
|
"design_description",
|
|
@@ -2370,15 +2372,15 @@ const Le = () => {
|
|
|
2370
2372
|
}), en = () => ({
|
|
2371
2373
|
type: "patent_title",
|
|
2372
2374
|
content: []
|
|
2373
|
-
}),
|
|
2374
|
-
...Oa.map(Fe),
|
|
2375
|
-
en(),
|
|
2375
|
+
}), Wa = () => [
|
|
2376
2376
|
...Ba.map(Fe),
|
|
2377
|
-
...Ha.map(Fe)
|
|
2378
|
-
], Wa = () => [
|
|
2379
2377
|
en(),
|
|
2378
|
+
...Ha.map(Fe),
|
|
2380
2379
|
...Ua.map(Fe)
|
|
2381
|
-
],
|
|
2380
|
+
], ja = () => [
|
|
2381
|
+
en(),
|
|
2382
|
+
...qa.map(Fe)
|
|
2383
|
+
], tn = (e = "invention") => ({ type: "doc", content: e === "design" ? ja() : Wa() }), ve = (e) => Xt(e, (t) => t.type.name === "figure"), V = (e) => typeof e != "string" ? "" : e.trim(), xt = (e) => {
|
|
2382
2384
|
const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = /* @__PURE__ */ new Set();
|
|
2383
2385
|
ve(e).forEach((i) => {
|
|
2384
2386
|
const s = V(i.node.attrs.id);
|
|
@@ -2388,22 +2390,22 @@ const Le = () => {
|
|
|
2388
2390
|
for (; r.has(`${n}${a}`); )
|
|
2389
2391
|
a += 1;
|
|
2390
2392
|
return `${n}${a}`;
|
|
2391
|
-
},
|
|
2393
|
+
}, Ga = /^(Fig\.|图)(\d+)$/, Va = (e) => {
|
|
2392
2394
|
const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = ve(e);
|
|
2393
2395
|
if (r.length === 0) return;
|
|
2394
2396
|
const a = [];
|
|
2395
2397
|
let i = 1;
|
|
2396
|
-
for (const
|
|
2397
|
-
const l = V(
|
|
2398
|
-
if (!
|
|
2398
|
+
for (const o of r) {
|
|
2399
|
+
const l = V(o.node.attrs.id);
|
|
2400
|
+
if (!Ga.exec(l)) continue;
|
|
2399
2401
|
const d = `${n}${i}`;
|
|
2400
|
-
l !== d && a.push({ pos:
|
|
2402
|
+
l !== d && a.push({ pos: o.pos, expectedId: d, currentId: l }), i++;
|
|
2401
2403
|
}
|
|
2402
2404
|
if (a.length === 0) return;
|
|
2403
2405
|
const { tr: s } = e.state;
|
|
2404
|
-
for (const
|
|
2405
|
-
const l = s.doc.nodeAt(
|
|
2406
|
-
!l || l.type.name !== "figure" || s.setNodeMarkup(
|
|
2406
|
+
for (const o of a) {
|
|
2407
|
+
const l = s.doc.nodeAt(o.pos);
|
|
2408
|
+
!l || l.type.name !== "figure" || s.setNodeMarkup(o.pos, void 0, { ...l.attrs, id: o.expectedId });
|
|
2407
2409
|
}
|
|
2408
2410
|
s.steps.length > 0 && (s.setMeta("addToHistory", !1), e.view.dispatch(s));
|
|
2409
2411
|
}, nn = (e) => {
|
|
@@ -2422,28 +2424,28 @@ const Le = () => {
|
|
|
2422
2424
|
const t = nn(e), n = rn();
|
|
2423
2425
|
e.commands.command(({ tr: r, state: a, dispatch: i }) => {
|
|
2424
2426
|
let s = !1;
|
|
2425
|
-
return a.doc.descendants((
|
|
2426
|
-
if (
|
|
2427
|
+
return a.doc.descendants((o, l) => {
|
|
2428
|
+
if (o.type.name !== "reference" || o.attrs.targetType !== "figure")
|
|
2427
2429
|
return !0;
|
|
2428
|
-
const
|
|
2429
|
-
...
|
|
2430
|
+
const c = typeof o.attrs.targetFigureId == "string" && o.attrs.targetFigureId ? V(o.attrs.targetFigureId) : null, d = c ? t.get(c) : void 0, u = d ? d.id : null, m = !d, p = an(n, u, m), h = {
|
|
2431
|
+
...o.attrs,
|
|
2430
2432
|
targetType: "figure",
|
|
2431
|
-
targetFigureId:
|
|
2433
|
+
targetFigureId: c,
|
|
2432
2434
|
resolvedFigureId: u,
|
|
2433
2435
|
invalid: m,
|
|
2434
2436
|
lang: n,
|
|
2435
|
-
displayText:
|
|
2436
|
-
target: u ||
|
|
2437
|
+
displayText: p,
|
|
2438
|
+
target: u || o.attrs.target || c || null
|
|
2437
2439
|
};
|
|
2438
|
-
return Object.keys(
|
|
2439
|
-
(y) =>
|
|
2440
|
-
) && (r.setNodeMarkup(l, void 0,
|
|
2440
|
+
return Object.keys(h).some(
|
|
2441
|
+
(y) => h[y] !== o.attrs[y]
|
|
2442
|
+
) && (r.setNodeMarkup(l, void 0, h), s = !0), !0;
|
|
2441
2443
|
}), s && i && (r.setMeta("addToHistory", !1), i(r)), !0;
|
|
2442
2444
|
});
|
|
2443
|
-
},
|
|
2445
|
+
}, Ja = {
|
|
2444
2446
|
name: "patent",
|
|
2445
2447
|
version: "1.0.0",
|
|
2446
|
-
extensions: [
|
|
2448
|
+
extensions: [Ra, Ma, za, Oa],
|
|
2447
2449
|
toolbarItems: [
|
|
2448
2450
|
{
|
|
2449
2451
|
id: "patent-figure-insert",
|
|
@@ -2467,12 +2469,12 @@ const Le = () => {
|
|
|
2467
2469
|
const r = n.lang === "en" ? "en" : "zh";
|
|
2468
2470
|
I.getState().setEditorLanguage(r);
|
|
2469
2471
|
const i = (n.scope || "all") === "current" ? Re(e, "reference") : null;
|
|
2470
|
-
return e.commands.command(({ tr:
|
|
2472
|
+
return e.commands.command(({ tr: o, state: l, dispatch: c }) => {
|
|
2471
2473
|
let d = !1;
|
|
2472
|
-
return l.doc.descendants((u, m) => (u.type.name !== "reference" || i && m !== i.pos || u.attrs.lang !== r && (
|
|
2474
|
+
return l.doc.descendants((u, m) => (u.type.name !== "reference" || i && m !== i.pos || u.attrs.lang !== r && (o.setNodeMarkup(m, void 0, {
|
|
2473
2475
|
...u.attrs,
|
|
2474
2476
|
lang: r
|
|
2475
|
-
}), d = !0), !0)), d &&
|
|
2477
|
+
}), d = !0), !0)), d && c && (o.setMeta("addToHistory", !1), c(o)), !0;
|
|
2476
2478
|
}) ? (Je(e), !0) : !1;
|
|
2477
2479
|
}
|
|
2478
2480
|
},
|
|
@@ -2500,14 +2502,14 @@ const Le = () => {
|
|
|
2500
2502
|
const i = e.state.doc.nodeAt(a);
|
|
2501
2503
|
if (!i || i.type.name !== "figure")
|
|
2502
2504
|
return !1;
|
|
2503
|
-
const
|
|
2504
|
-
if (ve(e).some((d) => d.pos === a ? !1 : V(d.node.attrs.id) ===
|
|
2505
|
+
const o = (typeof n.id == "string" ? V(n.id) : V(i.attrs.id)) || xt(e);
|
|
2506
|
+
if (ve(e).some((d) => d.pos === a ? !1 : V(d.node.attrs.id) === o))
|
|
2505
2507
|
return !1;
|
|
2506
|
-
const
|
|
2507
|
-
return typeof n.contentType == "string" && ["image", "mermaid", "drawio"].includes(n.contentType) && (
|
|
2508
|
+
const c = { id: o };
|
|
2509
|
+
return typeof n.contentType == "string" && ["image", "mermaid", "drawio"].includes(n.contentType) && (c.contentType = n.contentType), typeof n.imageSrc == "string" && (c.imageSrc = n.imageSrc), typeof n.mermaidCode == "string" && (c.mermaidCode = n.mermaidCode), typeof n.drawioXml == "string" && (c.drawioXml = n.drawioXml), ze(e, {
|
|
2508
2510
|
type: "figure",
|
|
2509
2511
|
position: a,
|
|
2510
|
-
attrs:
|
|
2512
|
+
attrs: c
|
|
2511
2513
|
});
|
|
2512
2514
|
}
|
|
2513
2515
|
},
|
|
@@ -2547,7 +2549,7 @@ const Le = () => {
|
|
|
2547
2549
|
const i = r.get(a);
|
|
2548
2550
|
if (!i)
|
|
2549
2551
|
return !1;
|
|
2550
|
-
const s = n.lang || rn(),
|
|
2552
|
+
const s = n.lang || rn(), o = n.displayText || an(s, i.id, !1);
|
|
2551
2553
|
return e.chain().focus().insertContent({
|
|
2552
2554
|
type: "reference",
|
|
2553
2555
|
attrs: {
|
|
@@ -2558,7 +2560,7 @@ const Le = () => {
|
|
|
2558
2560
|
resolvedFigureId: i.id,
|
|
2559
2561
|
lang: s,
|
|
2560
2562
|
invalid: !1,
|
|
2561
|
-
displayText:
|
|
2563
|
+
displayText: o,
|
|
2562
2564
|
target: n.target || i.id,
|
|
2563
2565
|
highlight: !1
|
|
2564
2566
|
}
|
|
@@ -2589,13 +2591,13 @@ const Le = () => {
|
|
|
2589
2591
|
}
|
|
2590
2592
|
},
|
|
2591
2593
|
onStateChange: (e) => {
|
|
2592
|
-
e.isDestroyed || (
|
|
2594
|
+
e.isDestroyed || (Va(e), Je(e));
|
|
2593
2595
|
}
|
|
2594
|
-
},
|
|
2595
|
-
|
|
2596
|
-
const
|
|
2596
|
+
}, Ka = [Ca, Sa, _a, Ja];
|
|
2597
|
+
Ka.forEach((e) => B.register(e));
|
|
2598
|
+
const Xa = (e = {}) => {
|
|
2597
2599
|
const t = [
|
|
2598
|
-
...
|
|
2600
|
+
...ba,
|
|
2599
2601
|
...B.getExtensions(),
|
|
2600
2602
|
...e.extensions || []
|
|
2601
2603
|
];
|
|
@@ -2619,12 +2621,12 @@ const Ka = (e = {}) => {
|
|
|
2619
2621
|
updateNodeAttrs: (t) => ze(e, t),
|
|
2620
2622
|
removeNode: (t) => Zt(e, t),
|
|
2621
2623
|
wrapSelection: (t) => Qt(e, t),
|
|
2622
|
-
applyTransactionBatch: (t) =>
|
|
2624
|
+
applyTransactionBatch: (t) => La(e, t),
|
|
2623
2625
|
findNodeByType: (t, n) => st(e, t, n),
|
|
2624
2626
|
findAncestorNode: (t) => Re(e, t),
|
|
2625
|
-
findCurrentBlock: () =>
|
|
2627
|
+
findCurrentBlock: () => Ia(e),
|
|
2626
2628
|
findNodesByPredicate: (t, n) => Xt(e, t, n)
|
|
2627
|
-
}),
|
|
2629
|
+
}), Ya = ["history", "text", "structure", "format", "technical", "patent"], Za = {
|
|
2628
2630
|
history: "groupHistory",
|
|
2629
2631
|
text: "groupText",
|
|
2630
2632
|
structure: "groupStructure",
|
|
@@ -2633,26 +2635,26 @@ const Ka = (e = {}) => {
|
|
|
2633
2635
|
patent: "groupPatent"
|
|
2634
2636
|
}, Xe = (e, t) => {
|
|
2635
2637
|
if (t) {
|
|
2636
|
-
const n =
|
|
2638
|
+
const n = Za[e];
|
|
2637
2639
|
if (n && typeof t[n] == "string") return t[n];
|
|
2638
2640
|
}
|
|
2639
2641
|
return e.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join(" ");
|
|
2640
2642
|
}, Ct = ({ btn: e, items: t }) => {
|
|
2641
|
-
const [n, r] = F(!1), a = W(null), i = W(null), [s,
|
|
2643
|
+
const [n, r] = F(!1), a = W(null), i = W(null), [s, o] = F({ top: 0, left: 0 }), l = ae(() => {
|
|
2642
2644
|
if (!a.current) return;
|
|
2643
|
-
const
|
|
2644
|
-
|
|
2645
|
+
const c = a.current.getBoundingClientRect();
|
|
2646
|
+
o({ top: c.bottom + 4, left: c.left });
|
|
2645
2647
|
}, []);
|
|
2646
2648
|
return M(() => {
|
|
2647
2649
|
if (!n) return;
|
|
2648
2650
|
l();
|
|
2649
|
-
const
|
|
2650
|
-
var
|
|
2651
|
+
const c = (u) => {
|
|
2652
|
+
var p, h;
|
|
2651
2653
|
const m = u.target;
|
|
2652
|
-
(
|
|
2654
|
+
(p = a.current) != null && p.contains(m) || (h = i.current) != null && h.contains(m) || r(!1);
|
|
2653
2655
|
}, d = () => l();
|
|
2654
|
-
return document.addEventListener("mousedown",
|
|
2655
|
-
document.removeEventListener("mousedown",
|
|
2656
|
+
return document.addEventListener("mousedown", c), window.addEventListener("scroll", d, !0), () => {
|
|
2657
|
+
document.removeEventListener("mousedown", c), window.removeEventListener("scroll", d, !0);
|
|
2656
2658
|
};
|
|
2657
2659
|
}, [n, l]), /* @__PURE__ */ L("div", { className: "flex items-center", children: [
|
|
2658
2660
|
/* @__PURE__ */ g(
|
|
@@ -2673,7 +2675,7 @@ const Ka = (e = {}) => {
|
|
|
2673
2675
|
"button",
|
|
2674
2676
|
{
|
|
2675
2677
|
ref: a,
|
|
2676
|
-
onClick: () => r((
|
|
2678
|
+
onClick: () => r((c) => !c),
|
|
2677
2679
|
className: Y(
|
|
2678
2680
|
"px-1 py-2 rounded-r transition-colors border-l border-gray-200",
|
|
2679
2681
|
e.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200 text-gray-500"
|
|
@@ -2689,14 +2691,14 @@ const Ka = (e = {}) => {
|
|
|
2689
2691
|
ref: i,
|
|
2690
2692
|
className: "bg-white border border-gray-200 rounded shadow-lg min-w-[160px] py-1",
|
|
2691
2693
|
style: { position: "fixed", top: s.top, left: s.left, zIndex: 9999 },
|
|
2692
|
-
children: t.map((
|
|
2694
|
+
children: t.map((c, d) => /* @__PURE__ */ g(
|
|
2693
2695
|
"button",
|
|
2694
2696
|
{
|
|
2695
2697
|
onClick: () => {
|
|
2696
|
-
|
|
2698
|
+
c.onClick(), r(!1);
|
|
2697
2699
|
},
|
|
2698
2700
|
className: "block w-full text-left px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100",
|
|
2699
|
-
children:
|
|
2701
|
+
children: c.label
|
|
2700
2702
|
},
|
|
2701
2703
|
d
|
|
2702
2704
|
))
|
|
@@ -2705,28 +2707,28 @@ const Ka = (e = {}) => {
|
|
|
2705
2707
|
document.body
|
|
2706
2708
|
)
|
|
2707
2709
|
] });
|
|
2708
|
-
},
|
|
2710
|
+
}, Qa = ({
|
|
2709
2711
|
editor: e,
|
|
2710
|
-
groupOrder: t =
|
|
2712
|
+
groupOrder: t = Ya,
|
|
2711
2713
|
collapsibleGroups: n = !0,
|
|
2712
2714
|
defaultCollapsedGroups: r = []
|
|
2713
2715
|
}) => {
|
|
2714
|
-
const [a, i] = F(() => new Set(r)), [, s] = F(0), { editorLanguage:
|
|
2716
|
+
const [a, i] = F(() => new Set(r)), [, s] = F(0), { editorLanguage: o, setEditorLanguage: l } = I(), c = H(o);
|
|
2715
2717
|
if (M(() => {
|
|
2716
2718
|
if (!e) return;
|
|
2717
|
-
const
|
|
2718
|
-
return e.on("selectionUpdate",
|
|
2719
|
-
e.off("selectionUpdate",
|
|
2719
|
+
const f = () => s((C) => C + 1);
|
|
2720
|
+
return e.on("selectionUpdate", f), e.on("update", f), () => {
|
|
2721
|
+
e.off("selectionUpdate", f), e.off("update", f);
|
|
2720
2722
|
};
|
|
2721
2723
|
}, [e]), !e)
|
|
2722
2724
|
return null;
|
|
2723
|
-
const d = ct(e), u =
|
|
2725
|
+
const d = ct(e), u = o === "zh", m = [
|
|
2724
2726
|
{
|
|
2725
2727
|
id: "core-undo",
|
|
2726
|
-
label:
|
|
2728
|
+
label: c.undo,
|
|
2727
2729
|
group: "history",
|
|
2728
2730
|
icon: br,
|
|
2729
|
-
tooltip: `${
|
|
2731
|
+
tooltip: `${c.undo} (Ctrl+Z)`,
|
|
2730
2732
|
isActive: !1,
|
|
2731
2733
|
disabled: !e.can().chain().focus().undo().run(),
|
|
2732
2734
|
run: () => {
|
|
@@ -2735,10 +2737,10 @@ const Ka = (e = {}) => {
|
|
|
2735
2737
|
},
|
|
2736
2738
|
{
|
|
2737
2739
|
id: "core-redo",
|
|
2738
|
-
label:
|
|
2740
|
+
label: c.redo,
|
|
2739
2741
|
group: "history",
|
|
2740
2742
|
icon: vr,
|
|
2741
|
-
tooltip: `${
|
|
2743
|
+
tooltip: `${c.redo} (Ctrl+Y)`,
|
|
2742
2744
|
isActive: !1,
|
|
2743
2745
|
disabled: !e.can().chain().focus().redo().run(),
|
|
2744
2746
|
run: () => {
|
|
@@ -2747,10 +2749,10 @@ const Ka = (e = {}) => {
|
|
|
2747
2749
|
},
|
|
2748
2750
|
{
|
|
2749
2751
|
id: "core-bold",
|
|
2750
|
-
label:
|
|
2752
|
+
label: c.bold,
|
|
2751
2753
|
group: "text",
|
|
2752
2754
|
icon: Dt,
|
|
2753
|
-
tooltip:
|
|
2755
|
+
tooltip: c.bold,
|
|
2754
2756
|
isActive: e.isActive("bold"),
|
|
2755
2757
|
disabled: !1,
|
|
2756
2758
|
run: () => {
|
|
@@ -2759,10 +2761,10 @@ const Ka = (e = {}) => {
|
|
|
2759
2761
|
},
|
|
2760
2762
|
{
|
|
2761
2763
|
id: "core-italic",
|
|
2762
|
-
label:
|
|
2764
|
+
label: c.italic,
|
|
2763
2765
|
group: "text",
|
|
2764
2766
|
icon: Rt,
|
|
2765
|
-
tooltip:
|
|
2767
|
+
tooltip: c.italic,
|
|
2766
2768
|
isActive: e.isActive("italic"),
|
|
2767
2769
|
disabled: !1,
|
|
2768
2770
|
run: () => {
|
|
@@ -2771,10 +2773,10 @@ const Ka = (e = {}) => {
|
|
|
2771
2773
|
},
|
|
2772
2774
|
{
|
|
2773
2775
|
id: "core-underline",
|
|
2774
|
-
label:
|
|
2776
|
+
label: c.underline,
|
|
2775
2777
|
group: "text",
|
|
2776
2778
|
icon: Mt,
|
|
2777
|
-
tooltip:
|
|
2779
|
+
tooltip: c.underline,
|
|
2778
2780
|
isActive: e.isActive("underline"),
|
|
2779
2781
|
disabled: !1,
|
|
2780
2782
|
run: () => {
|
|
@@ -2783,10 +2785,10 @@ const Ka = (e = {}) => {
|
|
|
2783
2785
|
},
|
|
2784
2786
|
{
|
|
2785
2787
|
id: "core-strike",
|
|
2786
|
-
label:
|
|
2788
|
+
label: c.strike,
|
|
2787
2789
|
group: "text",
|
|
2788
2790
|
icon: Ft,
|
|
2789
|
-
tooltip:
|
|
2791
|
+
tooltip: c.strike,
|
|
2790
2792
|
isActive: e.isActive("strike"),
|
|
2791
2793
|
disabled: !1,
|
|
2792
2794
|
run: () => {
|
|
@@ -2795,10 +2797,10 @@ const Ka = (e = {}) => {
|
|
|
2795
2797
|
},
|
|
2796
2798
|
{
|
|
2797
2799
|
id: "core-code",
|
|
2798
|
-
label:
|
|
2800
|
+
label: c.code,
|
|
2799
2801
|
group: "text",
|
|
2800
2802
|
icon: $t,
|
|
2801
|
-
tooltip:
|
|
2803
|
+
tooltip: c.code,
|
|
2802
2804
|
isActive: e.isActive("code"),
|
|
2803
2805
|
disabled: !1,
|
|
2804
2806
|
run: () => {
|
|
@@ -2807,10 +2809,10 @@ const Ka = (e = {}) => {
|
|
|
2807
2809
|
},
|
|
2808
2810
|
{
|
|
2809
2811
|
id: "core-superscript",
|
|
2810
|
-
label:
|
|
2812
|
+
label: c.superscript,
|
|
2811
2813
|
group: "text",
|
|
2812
2814
|
icon: zt,
|
|
2813
|
-
tooltip: `${
|
|
2815
|
+
tooltip: `${c.superscript} (Ctrl+.)`,
|
|
2814
2816
|
isActive: e.isActive("superscript"),
|
|
2815
2817
|
disabled: !1,
|
|
2816
2818
|
run: () => {
|
|
@@ -2819,10 +2821,10 @@ const Ka = (e = {}) => {
|
|
|
2819
2821
|
},
|
|
2820
2822
|
{
|
|
2821
2823
|
id: "core-subscript",
|
|
2822
|
-
label:
|
|
2824
|
+
label: c.subscript,
|
|
2823
2825
|
group: "text",
|
|
2824
2826
|
icon: Ot,
|
|
2825
|
-
tooltip: `${
|
|
2827
|
+
tooltip: `${c.subscript} (Ctrl+,)`,
|
|
2826
2828
|
isActive: e.isActive("subscript"),
|
|
2827
2829
|
disabled: !1,
|
|
2828
2830
|
run: () => {
|
|
@@ -2831,10 +2833,10 @@ const Ka = (e = {}) => {
|
|
|
2831
2833
|
},
|
|
2832
2834
|
{
|
|
2833
2835
|
id: "core-paragraph",
|
|
2834
|
-
label:
|
|
2836
|
+
label: c.paragraph,
|
|
2835
2837
|
group: "structure",
|
|
2836
2838
|
icon: wr,
|
|
2837
|
-
tooltip:
|
|
2839
|
+
tooltip: c.paragraph,
|
|
2838
2840
|
isActive: e.isActive("paragraph"),
|
|
2839
2841
|
disabled: !1,
|
|
2840
2842
|
run: () => {
|
|
@@ -2846,7 +2848,7 @@ const Ka = (e = {}) => {
|
|
|
2846
2848
|
label: "H1",
|
|
2847
2849
|
group: "structure",
|
|
2848
2850
|
icon: xr,
|
|
2849
|
-
tooltip:
|
|
2851
|
+
tooltip: c.heading1,
|
|
2850
2852
|
isActive: e.isActive("heading", { level: 1 }),
|
|
2851
2853
|
disabled: !1,
|
|
2852
2854
|
run: () => {
|
|
@@ -2858,7 +2860,7 @@ const Ka = (e = {}) => {
|
|
|
2858
2860
|
label: "H2",
|
|
2859
2861
|
group: "structure",
|
|
2860
2862
|
icon: Cr,
|
|
2861
|
-
tooltip:
|
|
2863
|
+
tooltip: c.heading2,
|
|
2862
2864
|
isActive: e.isActive("heading", { level: 2 }),
|
|
2863
2865
|
disabled: !1,
|
|
2864
2866
|
run: () => {
|
|
@@ -2870,7 +2872,7 @@ const Ka = (e = {}) => {
|
|
|
2870
2872
|
label: "H3",
|
|
2871
2873
|
group: "structure",
|
|
2872
2874
|
icon: Tr,
|
|
2873
|
-
tooltip:
|
|
2875
|
+
tooltip: c.heading3,
|
|
2874
2876
|
isActive: e.isActive("heading", { level: 3 }),
|
|
2875
2877
|
disabled: !1,
|
|
2876
2878
|
run: () => {
|
|
@@ -2879,10 +2881,10 @@ const Ka = (e = {}) => {
|
|
|
2879
2881
|
},
|
|
2880
2882
|
{
|
|
2881
2883
|
id: "core-align-left",
|
|
2882
|
-
label:
|
|
2884
|
+
label: c.alignLeft,
|
|
2883
2885
|
group: "format",
|
|
2884
2886
|
icon: Sr,
|
|
2885
|
-
tooltip:
|
|
2887
|
+
tooltip: c.alignLeft,
|
|
2886
2888
|
isActive: e.isActive({ textAlign: "left" }),
|
|
2887
2889
|
disabled: !1,
|
|
2888
2890
|
run: () => {
|
|
@@ -2891,10 +2893,10 @@ const Ka = (e = {}) => {
|
|
|
2891
2893
|
},
|
|
2892
2894
|
{
|
|
2893
2895
|
id: "core-align-center",
|
|
2894
|
-
label:
|
|
2896
|
+
label: c.alignCenter,
|
|
2895
2897
|
group: "format",
|
|
2896
2898
|
icon: Er,
|
|
2897
|
-
tooltip:
|
|
2899
|
+
tooltip: c.alignCenter,
|
|
2898
2900
|
isActive: e.isActive({ textAlign: "center" }),
|
|
2899
2901
|
disabled: !1,
|
|
2900
2902
|
run: () => {
|
|
@@ -2903,10 +2905,10 @@ const Ka = (e = {}) => {
|
|
|
2903
2905
|
},
|
|
2904
2906
|
{
|
|
2905
2907
|
id: "core-align-right",
|
|
2906
|
-
label:
|
|
2908
|
+
label: c.alignRight,
|
|
2907
2909
|
group: "format",
|
|
2908
2910
|
icon: kr,
|
|
2909
|
-
tooltip:
|
|
2911
|
+
tooltip: c.alignRight,
|
|
2910
2912
|
isActive: e.isActive({ textAlign: "right" }),
|
|
2911
2913
|
disabled: !1,
|
|
2912
2914
|
run: () => {
|
|
@@ -2915,10 +2917,10 @@ const Ka = (e = {}) => {
|
|
|
2915
2917
|
},
|
|
2916
2918
|
{
|
|
2917
2919
|
id: "core-align-justify",
|
|
2918
|
-
label:
|
|
2920
|
+
label: c.alignJustify,
|
|
2919
2921
|
group: "format",
|
|
2920
2922
|
icon: _r,
|
|
2921
|
-
tooltip:
|
|
2923
|
+
tooltip: c.alignJustify,
|
|
2922
2924
|
isActive: e.isActive({ textAlign: "justify" }),
|
|
2923
2925
|
disabled: !1,
|
|
2924
2926
|
run: () => {
|
|
@@ -2927,10 +2929,10 @@ const Ka = (e = {}) => {
|
|
|
2927
2929
|
},
|
|
2928
2930
|
{
|
|
2929
2931
|
id: "core-bullet-list",
|
|
2930
|
-
label:
|
|
2932
|
+
label: c.bulletList,
|
|
2931
2933
|
group: "structure",
|
|
2932
2934
|
icon: Ir,
|
|
2933
|
-
tooltip:
|
|
2935
|
+
tooltip: c.bulletList,
|
|
2934
2936
|
isActive: e.isActive("bulletList"),
|
|
2935
2937
|
disabled: !1,
|
|
2936
2938
|
run: () => {
|
|
@@ -2939,10 +2941,10 @@ const Ka = (e = {}) => {
|
|
|
2939
2941
|
},
|
|
2940
2942
|
{
|
|
2941
2943
|
id: "core-ordered-list",
|
|
2942
|
-
label:
|
|
2944
|
+
label: c.orderedList,
|
|
2943
2945
|
group: "structure",
|
|
2944
2946
|
icon: Nr,
|
|
2945
|
-
tooltip:
|
|
2947
|
+
tooltip: c.orderedList,
|
|
2946
2948
|
isActive: e.isActive("orderedList"),
|
|
2947
2949
|
disabled: !1,
|
|
2948
2950
|
run: () => {
|
|
@@ -2951,10 +2953,10 @@ const Ka = (e = {}) => {
|
|
|
2951
2953
|
},
|
|
2952
2954
|
{
|
|
2953
2955
|
id: "core-blockquote",
|
|
2954
|
-
label:
|
|
2956
|
+
label: c.blockquote,
|
|
2955
2957
|
group: "structure",
|
|
2956
2958
|
icon: Ar,
|
|
2957
|
-
tooltip:
|
|
2959
|
+
tooltip: c.blockquote,
|
|
2958
2960
|
isActive: e.isActive("blockquote"),
|
|
2959
2961
|
disabled: !1,
|
|
2960
2962
|
run: () => {
|
|
@@ -2963,10 +2965,10 @@ const Ka = (e = {}) => {
|
|
|
2963
2965
|
},
|
|
2964
2966
|
{
|
|
2965
2967
|
id: "core-code-block",
|
|
2966
|
-
label:
|
|
2968
|
+
label: c.codeBlock,
|
|
2967
2969
|
group: "structure",
|
|
2968
2970
|
icon: Lr,
|
|
2969
|
-
tooltip:
|
|
2971
|
+
tooltip: c.codeBlock,
|
|
2970
2972
|
isActive: e.isActive("codeBlock"),
|
|
2971
2973
|
disabled: !1,
|
|
2972
2974
|
run: () => {
|
|
@@ -2975,10 +2977,10 @@ const Ka = (e = {}) => {
|
|
|
2975
2977
|
},
|
|
2976
2978
|
{
|
|
2977
2979
|
id: "core-table",
|
|
2978
|
-
label:
|
|
2980
|
+
label: c.insertTable,
|
|
2979
2981
|
group: "structure",
|
|
2980
2982
|
icon: Pr,
|
|
2981
|
-
tooltip:
|
|
2983
|
+
tooltip: c.insertTable,
|
|
2982
2984
|
isActive: !1,
|
|
2983
2985
|
disabled: !1,
|
|
2984
2986
|
run: () => {
|
|
@@ -2987,10 +2989,10 @@ const Ka = (e = {}) => {
|
|
|
2987
2989
|
},
|
|
2988
2990
|
{
|
|
2989
2991
|
id: "core-horizontal-rule",
|
|
2990
|
-
label:
|
|
2992
|
+
label: c.horizontalRule,
|
|
2991
2993
|
group: "structure",
|
|
2992
2994
|
icon: Dr,
|
|
2993
|
-
tooltip:
|
|
2995
|
+
tooltip: c.horizontalRule,
|
|
2994
2996
|
isActive: !1,
|
|
2995
2997
|
disabled: !1,
|
|
2996
2998
|
run: () => {
|
|
@@ -2999,17 +3001,17 @@ const Ka = (e = {}) => {
|
|
|
2999
3001
|
},
|
|
3000
3002
|
{
|
|
3001
3003
|
id: "core-task-list",
|
|
3002
|
-
label:
|
|
3004
|
+
label: c.taskList,
|
|
3003
3005
|
group: "structure",
|
|
3004
3006
|
icon: Rr,
|
|
3005
|
-
tooltip:
|
|
3007
|
+
tooltip: c.taskList,
|
|
3006
3008
|
isActive: e.isActive("taskList"),
|
|
3007
3009
|
disabled: !1,
|
|
3008
3010
|
run: () => {
|
|
3009
3011
|
e.chain().focus().toggleTaskList().run();
|
|
3010
3012
|
}
|
|
3011
3013
|
}
|
|
3012
|
-
],
|
|
3014
|
+
], p = {
|
|
3013
3015
|
GitGraph: Or,
|
|
3014
3016
|
Sigma: zr,
|
|
3015
3017
|
FunctionSquare: $r,
|
|
@@ -3018,27 +3020,27 @@ const Ka = (e = {}) => {
|
|
|
3018
3020
|
FileText: Ut,
|
|
3019
3021
|
Link2: Ht,
|
|
3020
3022
|
Image: Bt
|
|
3021
|
-
},
|
|
3022
|
-
const C = B.getCommandMeta(
|
|
3023
|
+
}, h = B.getToolbarItems().map((f) => {
|
|
3024
|
+
const C = B.getCommandMeta(f.command), _ = u && f.tooltipZh ? f.tooltipZh : f.tooltip || (C == null ? void 0 : C.description) || f.label, A = f.shortcut || (C == null ? void 0 : C.shortcut), D = A ? `${_} (${A})` : _;
|
|
3023
3025
|
return {
|
|
3024
|
-
id:
|
|
3025
|
-
label:
|
|
3026
|
-
group:
|
|
3027
|
-
icon:
|
|
3028
|
-
isActive: d.isCommandActive(
|
|
3029
|
-
disabled: !d.canExecCommand(
|
|
3026
|
+
id: f.id,
|
|
3027
|
+
label: f.label,
|
|
3028
|
+
group: f.group || "technical",
|
|
3029
|
+
icon: f.icon ? p[f.icon] || mt : mt,
|
|
3030
|
+
isActive: d.isCommandActive(f.command),
|
|
3031
|
+
disabled: !d.canExecCommand(f.command),
|
|
3030
3032
|
tooltip: D,
|
|
3031
3033
|
run: () => {
|
|
3032
|
-
d.execCommand(
|
|
3034
|
+
d.execCommand(f.command);
|
|
3033
3035
|
}
|
|
3034
3036
|
};
|
|
3035
|
-
}), b = [...m, ...
|
|
3036
|
-
group:
|
|
3037
|
-
items: b.filter((C) => C.group ===
|
|
3038
|
-
})).filter((
|
|
3037
|
+
}), b = [...m, ...h], y = b.map((f) => f.group).filter((f, C, _) => _.indexOf(f) === C && !t.includes(f)), T = [...t, ...y].map((f) => ({
|
|
3038
|
+
group: f,
|
|
3039
|
+
items: b.filter((C) => C.group === f)
|
|
3040
|
+
})).filter((f) => f.items.length > 0), v = (f) => {
|
|
3039
3041
|
i((C) => {
|
|
3040
3042
|
const _ = new Set(C);
|
|
3041
|
-
return _.has(
|
|
3043
|
+
return _.has(f) ? _.delete(f) : _.add(f), _;
|
|
3042
3044
|
});
|
|
3043
3045
|
}, x = [
|
|
3044
3046
|
{ label: u ? "插入表格 3×3" : "Insert Table 3×3", onClick: () => e.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run() },
|
|
@@ -3053,33 +3055,33 @@ const Ka = (e = {}) => {
|
|
|
3053
3055
|
{ label: u ? "切换表头" : "Toggle Header Row", onClick: () => e.chain().focus().toggleHeaderRow().run() },
|
|
3054
3056
|
{ label: u ? "删除表格" : "Delete Table", onClick: () => e.chain().focus().deleteTable().run() }
|
|
3055
3057
|
], S = [
|
|
3056
|
-
{ label:
|
|
3057
|
-
{ label:
|
|
3058
|
-
{ label:
|
|
3059
|
-
], N = (
|
|
3058
|
+
{ label: c.insertImageFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "image" }) },
|
|
3059
|
+
{ label: c.insertMermaidFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "mermaid" }) },
|
|
3060
|
+
{ label: c.insertDrawioFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "drawio" }) }
|
|
3061
|
+
], N = (f) => f.id === "core-table" ? /* @__PURE__ */ g(Ct, { btn: f, items: x }, f.id) : f.id === "patent-figure-insert" ? /* @__PURE__ */ g(Ct, { btn: f, items: S }, f.id) : /* @__PURE__ */ g(
|
|
3060
3062
|
"button",
|
|
3061
3063
|
{
|
|
3062
|
-
onClick:
|
|
3063
|
-
disabled:
|
|
3064
|
+
onClick: f.run,
|
|
3065
|
+
disabled: f.disabled,
|
|
3064
3066
|
className: Y(
|
|
3065
3067
|
"p-2 rounded transition-colors",
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
+
f.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200",
|
|
3069
|
+
f.isActive ? "bg-gray-300 text-blue-600" : "text-gray-700"
|
|
3068
3070
|
),
|
|
3069
|
-
title:
|
|
3070
|
-
children: /* @__PURE__ */ g(
|
|
3071
|
+
title: f.tooltip,
|
|
3072
|
+
children: /* @__PURE__ */ g(f.icon, { size: 18 })
|
|
3071
3073
|
},
|
|
3072
|
-
|
|
3074
|
+
f.id
|
|
3073
3075
|
);
|
|
3074
3076
|
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
3077
|
/* @__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:
|
|
3078
|
+
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: c.language }),
|
|
3077
3079
|
/* @__PURE__ */ L(
|
|
3078
3080
|
"select",
|
|
3079
3081
|
{
|
|
3080
|
-
value:
|
|
3081
|
-
onChange: (
|
|
3082
|
-
l(
|
|
3082
|
+
value: o,
|
|
3083
|
+
onChange: (f) => {
|
|
3084
|
+
l(f.target.value === "en" ? "en" : "zh");
|
|
3083
3085
|
},
|
|
3084
3086
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white text-gray-700",
|
|
3085
3087
|
children: [
|
|
@@ -3089,25 +3091,25 @@ const Ka = (e = {}) => {
|
|
|
3089
3091
|
}
|
|
3090
3092
|
)
|
|
3091
3093
|
] }),
|
|
3092
|
-
T.map((
|
|
3093
|
-
const C = a.has(
|
|
3094
|
+
T.map((f) => {
|
|
3095
|
+
const C = a.has(f.group);
|
|
3094
3096
|
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
3097
|
n && /* @__PURE__ */ g(
|
|
3096
3098
|
"button",
|
|
3097
3099
|
{
|
|
3098
3100
|
onClick: () => {
|
|
3099
|
-
v(
|
|
3101
|
+
v(f.group);
|
|
3100
3102
|
},
|
|
3101
3103
|
className: "px-2 py-1 text-xs rounded bg-gray-200 text-gray-700 hover:bg-gray-300",
|
|
3102
|
-
title: C ? `${
|
|
3103
|
-
children: Xe(
|
|
3104
|
+
title: C ? `${c.expand} ${Xe(f.group, c)}` : `${c.collapse} ${Xe(f.group, c)}`,
|
|
3105
|
+
children: Xe(f.group, c)
|
|
3104
3106
|
}
|
|
3105
3107
|
),
|
|
3106
|
-
(!n || !C) &&
|
|
3107
|
-
] },
|
|
3108
|
+
(!n || !C) && f.items.map(N)
|
|
3109
|
+
] }, f.group);
|
|
3108
3110
|
})
|
|
3109
3111
|
] }) });
|
|
3110
|
-
},
|
|
3112
|
+
}, ei = ({ editor: e }) => {
|
|
3111
3113
|
const [t, n] = F(0), [r, a] = F(""), i = I((x) => x.editorLanguage), s = H(i);
|
|
3112
3114
|
if (M(() => {
|
|
3113
3115
|
if (!e) return;
|
|
@@ -3116,24 +3118,24 @@ const Ka = (e = {}) => {
|
|
|
3116
3118
|
e.off("selectionUpdate", x), e.off("update", x);
|
|
3117
3119
|
};
|
|
3118
3120
|
}, [e]), !e) return null;
|
|
3119
|
-
const
|
|
3121
|
+
const o = ct(e), l = [];
|
|
3120
3122
|
e.state.doc.descendants((x) => {
|
|
3121
3123
|
if (x.type.name !== "figure") return !0;
|
|
3122
3124
|
const S = typeof x.attrs.id == "string" ? x.attrs.id.trim() : "";
|
|
3123
3125
|
return S && l.push({ id: S, label: S }), !0;
|
|
3124
3126
|
});
|
|
3125
|
-
const
|
|
3126
|
-
w !== y.current && (y.current = w, d && u !==
|
|
3127
|
+
const c = o.findAncestorNode("figure"), d = !!c, u = c && typeof c.node.attrs.id == "string" ? c.node.attrs.id.trim() : "", m = c && typeof c.node.attrs.contentType == "string" ? c.node.attrs.contentType : "image", [p, h] = F(""), b = W(null), y = W(null), w = (c == null ? void 0 : c.pos) ?? null;
|
|
3128
|
+
w !== y.current && (y.current = w, d && u !== p && h(u));
|
|
3127
3129
|
const T = (x) => {
|
|
3128
|
-
|
|
3129
|
-
position:
|
|
3130
|
+
c && o.execCommand("patent.updateFigure", {
|
|
3131
|
+
position: c.pos,
|
|
3130
3132
|
contentType: x
|
|
3131
3133
|
});
|
|
3132
3134
|
}, v = () => {
|
|
3133
|
-
if (!
|
|
3134
|
-
const x =
|
|
3135
|
-
x !== u &&
|
|
3136
|
-
position:
|
|
3135
|
+
if (!c) return;
|
|
3136
|
+
const x = p.trim();
|
|
3137
|
+
x !== u && o.execCommand("patent.updateFigure", {
|
|
3138
|
+
position: c.pos,
|
|
3137
3139
|
id: x
|
|
3138
3140
|
});
|
|
3139
3141
|
};
|
|
@@ -3156,7 +3158,7 @@ const Ka = (e = {}) => {
|
|
|
3156
3158
|
"button",
|
|
3157
3159
|
{
|
|
3158
3160
|
onClick: () => {
|
|
3159
|
-
r &&
|
|
3161
|
+
r && o.execCommand("patent.insertFigureReference", {
|
|
3160
3162
|
targetType: "figure",
|
|
3161
3163
|
targetFigureId: r
|
|
3162
3164
|
});
|
|
@@ -3176,8 +3178,8 @@ const Ka = (e = {}) => {
|
|
|
3176
3178
|
{
|
|
3177
3179
|
ref: b,
|
|
3178
3180
|
type: "text",
|
|
3179
|
-
value:
|
|
3180
|
-
onChange: (x) =>
|
|
3181
|
+
value: p,
|
|
3182
|
+
onChange: (x) => h(x.target.value),
|
|
3181
3183
|
onBlur: v,
|
|
3182
3184
|
onKeyDown: (x) => {
|
|
3183
3185
|
x.key === "Enter" && (v(), x.target.blur());
|
|
@@ -3206,14 +3208,14 @@ const Ka = (e = {}) => {
|
|
|
3206
3208
|
const S = e.getAttributes("image").width || "";
|
|
3207
3209
|
return /* @__PURE__ */ L(je, { children: [
|
|
3208
3210
|
/* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: i === "zh" ? "图片" : "Image" }),
|
|
3209
|
-
["25%", "50%", "75%", "100%"].map((
|
|
3211
|
+
["25%", "50%", "75%", "100%"].map((f) => /* @__PURE__ */ g(
|
|
3210
3212
|
"button",
|
|
3211
3213
|
{
|
|
3212
|
-
onClick: () => e.chain().focus().updateAttributes("image", { width:
|
|
3213
|
-
className: `text-xs px-2 py-0.5 rounded border ${S ===
|
|
3214
|
-
children:
|
|
3214
|
+
onClick: () => e.chain().focus().updateAttributes("image", { width: f }).run(),
|
|
3215
|
+
className: `text-xs px-2 py-0.5 rounded border ${S === f ? "bg-blue-50 text-blue-700 border-blue-200" : "bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,
|
|
3216
|
+
children: f
|
|
3215
3217
|
},
|
|
3216
|
-
|
|
3218
|
+
f
|
|
3217
3219
|
)),
|
|
3218
3220
|
/* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" })
|
|
3219
3221
|
] });
|
|
@@ -3237,10 +3239,10 @@ const Ka = (e = {}) => {
|
|
|
3237
3239
|
design_views: ["design_description"],
|
|
3238
3240
|
design_brief: ["design_description", "design_views"]
|
|
3239
3241
|
};
|
|
3240
|
-
function
|
|
3242
|
+
function qs(e, t) {
|
|
3241
3243
|
return (sn[e] || []).filter((r) => !t.has(r));
|
|
3242
3244
|
}
|
|
3243
|
-
function
|
|
3245
|
+
function ti(e) {
|
|
3244
3246
|
const t = [];
|
|
3245
3247
|
return e.state.doc.descendants((n, r) => n.type.name === "patent_title" ? (t.push({
|
|
3246
3248
|
sectionType: "patent_title",
|
|
@@ -3271,10 +3273,10 @@ function on(e) {
|
|
|
3271
3273
|
}
|
|
3272
3274
|
return null;
|
|
3273
3275
|
}
|
|
3274
|
-
function
|
|
3276
|
+
function ni(e, t) {
|
|
3275
3277
|
const n = sn[t];
|
|
3276
3278
|
if (!n || n.length === 0) return [];
|
|
3277
|
-
const r =
|
|
3279
|
+
const r = ti(e), a = new Map(r.map((i) => [i.sectionType, i]));
|
|
3278
3280
|
return n.map((i) => {
|
|
3279
3281
|
const s = a.get(i);
|
|
3280
3282
|
return !s || s.content.trim().length === 0 ? null : {
|
|
@@ -3283,54 +3285,54 @@ function ti(e, t) {
|
|
|
3283
3285
|
};
|
|
3284
3286
|
}).filter((i) => i !== null && i.content.length > 0);
|
|
3285
3287
|
}
|
|
3286
|
-
function
|
|
3288
|
+
function Ws(e, t = {}) {
|
|
3287
3289
|
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,
|
|
3290
|
+
let s = t.sectionType, o = t.targetSectionPos;
|
|
3289
3291
|
if (!s) {
|
|
3290
3292
|
const u = on(e);
|
|
3291
|
-
u && (s = u.sectionType,
|
|
3293
|
+
u && (s = u.sectionType, o = u.pos);
|
|
3292
3294
|
}
|
|
3293
|
-
const l = t.scope || (s ? "section" : i ? "selection" : "document"),
|
|
3295
|
+
const l = t.scope || (s ? "section" : i ? "selection" : "document"), c = s ? ni(e, s) : void 0;
|
|
3294
3296
|
let d;
|
|
3295
3297
|
if (l === "selection" && r !== a) {
|
|
3296
|
-
const m = Math.max(0, r - 200),
|
|
3297
|
-
d = `...${
|
|
3298
|
+
const m = Math.max(0, r - 200), p = Math.min(e.state.doc.content.size, a + 200), h = e.state.doc.textBetween(m, r, " ", "\0"), b = e.state.doc.textBetween(a, p, " ", "\0");
|
|
3299
|
+
d = `...${h}[SELECTED]${b}...`;
|
|
3298
3300
|
}
|
|
3299
3301
|
return {
|
|
3300
3302
|
scope: l,
|
|
3301
3303
|
sectionType: s,
|
|
3302
|
-
targetSectionPos:
|
|
3304
|
+
targetSectionPos: o,
|
|
3303
3305
|
userInput: t.userInput,
|
|
3304
3306
|
selectedText: i,
|
|
3305
|
-
dependencyContext:
|
|
3307
|
+
dependencyContext: c,
|
|
3306
3308
|
surroundingText: d,
|
|
3307
3309
|
language: n
|
|
3308
3310
|
};
|
|
3309
3311
|
}
|
|
3310
|
-
const
|
|
3311
|
-
const { addChatReference: n, openChatPanel: r, editorLanguage: a } = I(), i = a === "zh", s = (
|
|
3312
|
+
const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
3313
|
+
const { addChatReference: n, openChatPanel: r, editorLanguage: a } = I(), i = a === "zh", s = (c) => Y(
|
|
3312
3314
|
"p-1.5 rounded transition-colors",
|
|
3313
|
-
|
|
3314
|
-
),
|
|
3315
|
-
const { from:
|
|
3316
|
-
if (
|
|
3317
|
-
const u = e.state.doc.textBetween(
|
|
3315
|
+
c ? "bg-blue-100 text-blue-600" : "text-gray-600 hover:bg-gray-100"
|
|
3316
|
+
), o = () => {
|
|
3317
|
+
const { from: c, to: d } = e.state.selection;
|
|
3318
|
+
if (c === d) return;
|
|
3319
|
+
const u = e.state.doc.textBetween(c, d, " "), m = on(e);
|
|
3318
3320
|
if (t) {
|
|
3319
|
-
t({ text: u, from:
|
|
3321
|
+
t({ text: u, from: c, to: d, sectionType: m == null ? void 0 : m.sectionType });
|
|
3320
3322
|
return;
|
|
3321
3323
|
}
|
|
3322
|
-
n({ text: u, from:
|
|
3324
|
+
n({ text: u, from: c, to: d, sectionType: m == null ? void 0 : m.sectionType }), r();
|
|
3323
3325
|
}, l = () => {
|
|
3324
|
-
const
|
|
3326
|
+
const c = e.getAttributes("link").href, d = window.prompt("URL", c || "https://");
|
|
3325
3327
|
d !== null && (d === "" ? e.chain().focus().extendMarkRange("link").unsetLink().run() : e.chain().focus().extendMarkRange("link").setLink({ href: d }).run());
|
|
3326
3328
|
};
|
|
3327
3329
|
return /* @__PURE__ */ g(
|
|
3328
3330
|
Jr,
|
|
3329
3331
|
{
|
|
3330
3332
|
editor: e,
|
|
3331
|
-
shouldShow: ({ editor:
|
|
3333
|
+
shouldShow: ({ editor: c, state: d }) => {
|
|
3332
3334
|
const { from: u, to: m } = d.selection;
|
|
3333
|
-
return !(u === m ||
|
|
3335
|
+
return !(u === m || c.isActive("codeBlock"));
|
|
3334
3336
|
},
|
|
3335
3337
|
children: /* @__PURE__ */ L("div", { className: "bubble-menu", children: [
|
|
3336
3338
|
/* @__PURE__ */ g(
|
|
@@ -3419,7 +3421,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3419
3421
|
/* @__PURE__ */ g(
|
|
3420
3422
|
"button",
|
|
3421
3423
|
{
|
|
3422
|
-
onClick:
|
|
3424
|
+
onClick: o,
|
|
3423
3425
|
className: "p-1.5 rounded transition-colors text-purple-500 hover:bg-purple-50",
|
|
3424
3426
|
title: i ? "AI 优化" : "AI Optimize",
|
|
3425
3427
|
children: /* @__PURE__ */ g(Hr, { size: 15 })
|
|
@@ -3428,9 +3430,9 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3428
3430
|
] })
|
|
3429
3431
|
}
|
|
3430
3432
|
);
|
|
3431
|
-
},
|
|
3433
|
+
}, ai = ({ editor: e }) => {
|
|
3432
3434
|
var T;
|
|
3433
|
-
const [t, n] = F(!1), [r, a] = F(!1), [i, s] = F(""), [
|
|
3435
|
+
const [t, n] = F(!1), [r, a] = F(!1), [i, s] = F(""), [o, l] = F(""), [c, d] = F(!1), u = W(null), m = e.extensionStorage.searchReplace, p = ((T = m == null ? void 0 : m.results) == null ? void 0 : T.length) ?? 0, h = (m == null ? void 0 : m.currentIndex) ?? -1;
|
|
3434
3436
|
M(() => {
|
|
3435
3437
|
const v = (x) => {
|
|
3436
3438
|
n(!0);
|
|
@@ -3457,7 +3459,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3457
3459
|
return window.addEventListener("keydown", v), () => window.removeEventListener("keydown", v);
|
|
3458
3460
|
}, [t, y]);
|
|
3459
3461
|
const w = () => {
|
|
3460
|
-
const v = !
|
|
3462
|
+
const v = !c;
|
|
3461
3463
|
d(v), e.commands.setCaseSensitive(v);
|
|
3462
3464
|
};
|
|
3463
3465
|
return t ? /* @__PURE__ */ L("div", { className: "find-replace-bar", children: [
|
|
@@ -3477,13 +3479,13 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3477
3479
|
className: "find-replace-input"
|
|
3478
3480
|
}
|
|
3479
3481
|
),
|
|
3480
|
-
/* @__PURE__ */ g("span", { className: "find-replace-count", children:
|
|
3482
|
+
/* @__PURE__ */ g("span", { className: "find-replace-count", children: p > 0 ? `${h + 1}/${p}` : i ? "0" : "" })
|
|
3481
3483
|
] }),
|
|
3482
3484
|
/* @__PURE__ */ g(
|
|
3483
3485
|
"button",
|
|
3484
3486
|
{
|
|
3485
3487
|
onClick: w,
|
|
3486
|
-
className: Y("find-replace-btn",
|
|
3488
|
+
className: Y("find-replace-btn", c && "find-replace-btn--active"),
|
|
3487
3489
|
title: "Case Sensitive",
|
|
3488
3490
|
children: /* @__PURE__ */ g(Ur, { size: 15 })
|
|
3489
3491
|
}
|
|
@@ -3506,7 +3508,7 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3506
3508
|
"input",
|
|
3507
3509
|
{
|
|
3508
3510
|
type: "text",
|
|
3509
|
-
value:
|
|
3511
|
+
value: o,
|
|
3510
3512
|
onChange: (v) => {
|
|
3511
3513
|
l(v.target.value), e.commands.setReplaceTerm(v.target.value);
|
|
3512
3514
|
},
|
|
@@ -3521,11 +3523,11 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3521
3523
|
/* @__PURE__ */ g("button", { onClick: () => e.commands.replaceAll(), className: "find-replace-btn", title: "Replace All", children: /* @__PURE__ */ g(jr, { size: 15 }) })
|
|
3522
3524
|
] })
|
|
3523
3525
|
] }) : null;
|
|
3524
|
-
},
|
|
3526
|
+
}, ii = ({ editor: e }) => {
|
|
3525
3527
|
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:
|
|
3527
|
-
let
|
|
3528
|
-
return
|
|
3528
|
+
const a = e.state, s = a.doc.textBetween(0, a.doc.content.size, " ", "\0").replace(/\s/g, "").length, { from: o, to: l } = a.selection;
|
|
3529
|
+
let c = 0;
|
|
3530
|
+
return o !== l && (c = a.doc.textBetween(o, l, " ", "\0").replace(/\s/g, "").length), { charCount: s, selectionCount: c };
|
|
3529
3531
|
}, [e.state.doc, e.state.selection]);
|
|
3530
3532
|
return /* @__PURE__ */ L("div", { className: "word-count-bar", children: [
|
|
3531
3533
|
/* @__PURE__ */ L("span", { children: [
|
|
@@ -3539,73 +3541,73 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3539
3541
|
r.selectionCount
|
|
3540
3542
|
] })
|
|
3541
3543
|
] });
|
|
3542
|
-
},
|
|
3544
|
+
}, si = {
|
|
3543
3545
|
empty: "○",
|
|
3544
3546
|
filled: "●"
|
|
3545
|
-
},
|
|
3547
|
+
}, oi = {
|
|
3546
3548
|
empty: "text-gray-400",
|
|
3547
3549
|
filled: "text-green-500"
|
|
3548
|
-
},
|
|
3550
|
+
}, ci = /* @__PURE__ */ new Set([
|
|
3549
3551
|
"technical_field",
|
|
3550
3552
|
"background_art",
|
|
3551
3553
|
"summary",
|
|
3552
3554
|
"drawing_description",
|
|
3553
3555
|
"detailed_description"
|
|
3554
|
-
]),
|
|
3555
|
-
const { editorLanguage: n } = I(), r = H(n), [a, i] = F(t), [s,
|
|
3556
|
+
]), li = ({ editor: e, defaultCollapsed: t = !1 }) => {
|
|
3557
|
+
const { editorLanguage: n } = I(), r = H(n), [a, i] = F(t), [s, o] = F(0);
|
|
3556
3558
|
M(() => {
|
|
3557
|
-
const
|
|
3558
|
-
return e.on("update",
|
|
3559
|
-
e.off("update",
|
|
3559
|
+
const c = () => o((d) => d + 1);
|
|
3560
|
+
return e.on("update", c), () => {
|
|
3561
|
+
e.off("update", c);
|
|
3560
3562
|
};
|
|
3561
3563
|
}, [e]);
|
|
3562
3564
|
const l = At(() => {
|
|
3563
|
-
const
|
|
3565
|
+
const c = [];
|
|
3564
3566
|
let d = !1;
|
|
3565
3567
|
return e.state.doc.descendants((u, m) => {
|
|
3566
3568
|
if (u.type.name === "patent_title") {
|
|
3567
3569
|
if (!d) {
|
|
3568
3570
|
const y = typeof r.bookTitle_description == "string" ? r.bookTitle_description : "说明书";
|
|
3569
|
-
|
|
3571
|
+
c.push({
|
|
3570
3572
|
type: "book-group",
|
|
3571
3573
|
pos: m,
|
|
3572
3574
|
title: y,
|
|
3573
3575
|
charCount: 0
|
|
3574
3576
|
}), d = !0;
|
|
3575
3577
|
}
|
|
3576
|
-
const
|
|
3577
|
-
return
|
|
3578
|
+
const p = u.textContent || "", h = p.trim().length > 0, b = typeof r.patentTitlePlaceholder == "string" ? r.patentTitlePlaceholder : "Patent Title";
|
|
3579
|
+
return c.push({
|
|
3578
3580
|
type: "section",
|
|
3579
3581
|
pos: m,
|
|
3580
|
-
title:
|
|
3581
|
-
state:
|
|
3582
|
-
charCount:
|
|
3582
|
+
title: h ? p.trim() : b,
|
|
3583
|
+
state: h ? "filled" : "empty",
|
|
3584
|
+
charCount: p.replace(/\s/g, "").length,
|
|
3583
3585
|
indent: !0
|
|
3584
3586
|
}), !1;
|
|
3585
3587
|
}
|
|
3586
3588
|
if (u.type.name === "patent_section") {
|
|
3587
|
-
const
|
|
3588
|
-
return
|
|
3589
|
+
const p = u.attrs.sectionType, h = ci.has(p), b = `sectionTitle_${p}`, y = typeof r[b] == "string" ? r[b] : p, w = u.textContent || "", T = w.trim().length > 0;
|
|
3590
|
+
return c.push({
|
|
3589
3591
|
type: "section",
|
|
3590
3592
|
pos: m,
|
|
3591
3593
|
title: y,
|
|
3592
3594
|
state: T ? "filled" : "empty",
|
|
3593
3595
|
charCount: w.replace(/\s/g, "").length,
|
|
3594
|
-
indent:
|
|
3596
|
+
indent: h
|
|
3595
3597
|
}), !1;
|
|
3596
3598
|
}
|
|
3597
3599
|
if (u.type.name === "heading") {
|
|
3598
|
-
const
|
|
3599
|
-
return
|
|
3600
|
+
const p = u.attrs.level, h = u.textContent || "";
|
|
3601
|
+
return h.trim() && c.push({
|
|
3600
3602
|
type: "heading",
|
|
3601
3603
|
pos: m,
|
|
3602
|
-
title:
|
|
3603
|
-
level:
|
|
3604
|
-
charCount:
|
|
3604
|
+
title: h,
|
|
3605
|
+
level: p,
|
|
3606
|
+
charCount: h.replace(/\s/g, "").length
|
|
3605
3607
|
}), !1;
|
|
3606
3608
|
}
|
|
3607
3609
|
return !0;
|
|
3608
|
-
}),
|
|
3610
|
+
}), c;
|
|
3609
3611
|
}, [e, s, r]);
|
|
3610
3612
|
return a ? /* @__PURE__ */ g("div", { className: "outline-panel outline-panel--collapsed", children: /* @__PURE__ */ g(
|
|
3611
3613
|
"button",
|
|
@@ -3631,32 +3633,32 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3631
3633
|
] }),
|
|
3632
3634
|
/* @__PURE__ */ L("div", { className: "outline-panel-list", children: [
|
|
3633
3635
|
l.length === 0 && /* @__PURE__ */ g("div", { className: "outline-panel-empty", children: n === "zh" ? "暂无章节" : "No sections yet" }),
|
|
3634
|
-
l.map((
|
|
3636
|
+
l.map((c, d) => /* @__PURE__ */ L(
|
|
3635
3637
|
"button",
|
|
3636
3638
|
{
|
|
3637
3639
|
className: Y(
|
|
3638
3640
|
"outline-panel-item",
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3641
|
+
c.type === "heading" && `outline-panel-item--h${c.level}`,
|
|
3642
|
+
c.type === "book-group" && "outline-panel-item--book",
|
|
3643
|
+
c.indent && "outline-panel-item--indent"
|
|
3642
3644
|
),
|
|
3643
3645
|
onClick: () => {
|
|
3644
|
-
|
|
3645
|
-
const u = e.view.nodeDOM(
|
|
3646
|
+
c.type !== "book-group" && (e.chain().setTextSelection(c.pos + 1).focus().run(), requestAnimationFrame(() => {
|
|
3647
|
+
const u = e.view.nodeDOM(c.pos);
|
|
3646
3648
|
u == null || u.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
3647
3649
|
}));
|
|
3648
3650
|
},
|
|
3649
3651
|
children: [
|
|
3650
|
-
|
|
3651
|
-
/* @__PURE__ */ g("span", { className: "outline-item-title", children:
|
|
3652
|
-
|
|
3652
|
+
c.type === "section" && c.state && /* @__PURE__ */ g("span", { className: Y("outline-item-state", oi[c.state]), children: si[c.state] || "○" }),
|
|
3653
|
+
/* @__PURE__ */ g("span", { className: "outline-item-title", children: c.title }),
|
|
3654
|
+
c.type !== "book-group" && /* @__PURE__ */ g("span", { className: "outline-item-count", children: c.charCount })
|
|
3653
3655
|
]
|
|
3654
3656
|
},
|
|
3655
|
-
`${
|
|
3657
|
+
`${c.pos}-${d}`
|
|
3656
3658
|
))
|
|
3657
3659
|
] })
|
|
3658
3660
|
] });
|
|
3659
|
-
},
|
|
3661
|
+
}, di = ({
|
|
3660
3662
|
editor: e,
|
|
3661
3663
|
mode: t = "edit",
|
|
3662
3664
|
className: n
|
|
@@ -3672,14 +3674,14 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3672
3674
|
),
|
|
3673
3675
|
children: /* @__PURE__ */ g(In, { editor: e, className: "h-full" })
|
|
3674
3676
|
}
|
|
3675
|
-
)), cn = "patent-editor-draft",
|
|
3677
|
+
)), cn = "patent-editor-draft", ui = 1500, mi = () => {
|
|
3676
3678
|
try {
|
|
3677
3679
|
const e = localStorage.getItem(cn);
|
|
3678
3680
|
return e ? JSON.parse(e) : null;
|
|
3679
3681
|
} catch {
|
|
3680
3682
|
return null;
|
|
3681
3683
|
}
|
|
3682
|
-
},
|
|
3684
|
+
}, gi = ({
|
|
3683
3685
|
initialContent: e,
|
|
3684
3686
|
onChange: t,
|
|
3685
3687
|
className: n,
|
|
@@ -3687,10 +3689,10 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3687
3689
|
editable: a = !0,
|
|
3688
3690
|
onEditorReady: i,
|
|
3689
3691
|
onSelectionOptimize: s,
|
|
3690
|
-
patchEditorId:
|
|
3692
|
+
patchEditorId: o = "default",
|
|
3691
3693
|
defaultOutlineCollapsed: l = !1
|
|
3692
3694
|
}) => {
|
|
3693
|
-
const { setEditor:
|
|
3695
|
+
const { setEditor: c, setDocument: d, editorLanguage: u, autoSaveStatus: m, ai: p } = I(), { setAutoSaveStatus: h, setLastSavedAt: b } = I(), y = W(null), w = e || (t ? null : mi()) || {
|
|
3694
3696
|
type: "doc",
|
|
3695
3697
|
content: [
|
|
3696
3698
|
{
|
|
@@ -3698,27 +3700,27 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3698
3700
|
content: [{ type: "text", text: "" }]
|
|
3699
3701
|
}
|
|
3700
3702
|
]
|
|
3701
|
-
}, T = ae((
|
|
3703
|
+
}, T = ae((f) => {
|
|
3702
3704
|
try {
|
|
3703
|
-
|
|
3705
|
+
h("saving"), localStorage.setItem(cn, JSON.stringify(f)), h("saved"), b(/* @__PURE__ */ new Date());
|
|
3704
3706
|
} catch {
|
|
3705
|
-
|
|
3707
|
+
h("error");
|
|
3706
3708
|
}
|
|
3707
|
-
}, [
|
|
3708
|
-
|
|
3709
|
-
extensions: [
|
|
3709
|
+
}, [h, b]), v = Nn(
|
|
3710
|
+
Xa({
|
|
3711
|
+
extensions: [pa.configure({ editorId: o })],
|
|
3710
3712
|
content: w,
|
|
3711
|
-
onUpdate: ({ editor:
|
|
3712
|
-
const C =
|
|
3713
|
-
d(C), B.notifyStateChange(
|
|
3713
|
+
onUpdate: ({ editor: f }) => {
|
|
3714
|
+
const C = f.getJSON();
|
|
3715
|
+
d(C), B.notifyStateChange(f), t && t(C), t || (y.current && clearTimeout(y.current), y.current = setTimeout(() => {
|
|
3714
3716
|
T(C);
|
|
3715
|
-
},
|
|
3717
|
+
}, ui));
|
|
3716
3718
|
},
|
|
3717
|
-
onCreate: ({ editor:
|
|
3718
|
-
|
|
3719
|
+
onCreate: ({ editor: f }) => {
|
|
3720
|
+
c(f), i == null || i(f), B.initializePlugins(f), B.notifyStateChange(f);
|
|
3719
3721
|
},
|
|
3720
|
-
onSelectionUpdate: ({ editor:
|
|
3721
|
-
B.notifySelectionChange(
|
|
3722
|
+
onSelectionUpdate: ({ editor: f }) => {
|
|
3723
|
+
B.notifySelectionChange(f);
|
|
3722
3724
|
},
|
|
3723
3725
|
editorProps: {
|
|
3724
3726
|
attributes: {
|
|
@@ -3736,31 +3738,31 @@ const ni = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3736
3738
|
v.commands.setContent(e);
|
|
3737
3739
|
}
|
|
3738
3740
|
}, [v, e]), M(() => () => {
|
|
3739
|
-
y.current && clearTimeout(y.current), v && (
|
|
3740
|
-
}, [v,
|
|
3741
|
+
y.current && clearTimeout(y.current), v && (c(null), B.destroyPlugins(v), v.destroy());
|
|
3742
|
+
}, [v, c]), M(() => {
|
|
3741
3743
|
!v || v.isDestroyed || B.notifyStateChange(v);
|
|
3742
3744
|
}, [v, u]), !v)
|
|
3743
3745
|
return null;
|
|
3744
3746
|
const S = H(u), N = m === "saving" ? S.autoSaveSaving : m === "saved" ? S.autoSaveSaved : m === "error" ? S.autoSaveError : "";
|
|
3745
3747
|
return /* @__PURE__ */ L("div", { className: `editor-container flex flex-col h-full ${n}`, children: [
|
|
3746
3748
|
!r && /* @__PURE__ */ L("div", { className: "flex items-center", children: [
|
|
3747
|
-
/* @__PURE__ */ g(
|
|
3749
|
+
/* @__PURE__ */ g(Qa, { editor: v }),
|
|
3748
3750
|
N && /* @__PURE__ */ g("span", { className: `auto-save-indicator auto-save-indicator--${m} ml-2`, children: N })
|
|
3749
3751
|
] }),
|
|
3750
|
-
!r && v && /* @__PURE__ */ g(
|
|
3751
|
-
!r && v && /* @__PURE__ */ g(
|
|
3752
|
-
!r && v && /* @__PURE__ */ g(
|
|
3752
|
+
!r && v && /* @__PURE__ */ g(ei, { editor: v }),
|
|
3753
|
+
!r && v && /* @__PURE__ */ g(ri, { editor: v, onSelectionOptimize: s }),
|
|
3754
|
+
!r && v && /* @__PURE__ */ g(ai, { editor: v }),
|
|
3753
3755
|
/* @__PURE__ */ L("div", { className: "flex flex-1 overflow-hidden", children: [
|
|
3754
|
-
!r && v && /* @__PURE__ */ g(
|
|
3756
|
+
!r && v && /* @__PURE__ */ g(li, { editor: v, defaultCollapsed: l }),
|
|
3755
3757
|
/* @__PURE__ */ g("div", { className: "flex-1 overflow-y-auto bg-white p-4 relative", children: /* @__PURE__ */ g(
|
|
3756
|
-
|
|
3758
|
+
di,
|
|
3757
3759
|
{
|
|
3758
3760
|
editor: v,
|
|
3759
|
-
mode: r || !a ||
|
|
3761
|
+
mode: r || !a || p.status === "streaming" && p.activeSectionType === "claims" ? "readonly" : "edit"
|
|
3760
3762
|
}
|
|
3761
3763
|
) })
|
|
3762
3764
|
] }),
|
|
3763
|
-
!r && /* @__PURE__ */ g(
|
|
3765
|
+
!r && /* @__PURE__ */ g(ii, { editor: v })
|
|
3764
3766
|
] });
|
|
3765
3767
|
};
|
|
3766
3768
|
function ln(e) {
|
|
@@ -3770,19 +3772,19 @@ function ln(e) {
|
|
|
3770
3772
|
async pull(a) {
|
|
3771
3773
|
var i;
|
|
3772
3774
|
for (; ; ) {
|
|
3773
|
-
const { done: s, value:
|
|
3775
|
+
const { done: s, value: o } = await t.read();
|
|
3774
3776
|
if (s) {
|
|
3775
3777
|
a.close();
|
|
3776
3778
|
return;
|
|
3777
3779
|
}
|
|
3778
|
-
r += n.decode(
|
|
3780
|
+
r += n.decode(o, { stream: !0 });
|
|
3779
3781
|
const l = r.split(`
|
|
3780
3782
|
`);
|
|
3781
3783
|
r = l.pop() || "";
|
|
3782
|
-
let
|
|
3784
|
+
let c = "";
|
|
3783
3785
|
for (const d of l) {
|
|
3784
3786
|
if (d.startsWith("event: ")) {
|
|
3785
|
-
|
|
3787
|
+
c = d.slice(7).trim();
|
|
3786
3788
|
continue;
|
|
3787
3789
|
}
|
|
3788
3790
|
if (!d.startsWith("data: ")) continue;
|
|
@@ -3792,21 +3794,21 @@ function ln(e) {
|
|
|
3792
3794
|
return;
|
|
3793
3795
|
}
|
|
3794
3796
|
try {
|
|
3795
|
-
const m = JSON.parse(u),
|
|
3796
|
-
if (
|
|
3797
|
+
const m = JSON.parse(u), p = c || m.type;
|
|
3798
|
+
if (p === "delta" || !p && m.content != null)
|
|
3797
3799
|
a.enqueue({
|
|
3798
3800
|
type: "delta",
|
|
3799
3801
|
content: m.content ?? m.text ?? ((i = m.delta) == null ? void 0 : i.content) ?? ""
|
|
3800
3802
|
});
|
|
3801
|
-
else if (
|
|
3803
|
+
else if (p === "patch")
|
|
3802
3804
|
a.enqueue({ type: "patch", patch: m });
|
|
3803
|
-
else if (
|
|
3805
|
+
else if (p === "done") {
|
|
3804
3806
|
a.enqueue({ type: "done", usage: m.usage }), a.close();
|
|
3805
3807
|
return;
|
|
3806
|
-
} else
|
|
3808
|
+
} else p === "error" && a.enqueue({ type: "error", message: m.message || "Unknown error" });
|
|
3807
3809
|
} catch {
|
|
3808
3810
|
}
|
|
3809
|
-
|
|
3811
|
+
c = "";
|
|
3810
3812
|
}
|
|
3811
3813
|
}
|
|
3812
3814
|
},
|
|
@@ -3815,7 +3817,7 @@ function ln(e) {
|
|
|
3815
3817
|
}
|
|
3816
3818
|
});
|
|
3817
3819
|
}
|
|
3818
|
-
function
|
|
3820
|
+
function fi(e, t) {
|
|
3819
3821
|
let n = null;
|
|
3820
3822
|
return {
|
|
3821
3823
|
async request(r) {
|
|
@@ -3837,31 +3839,31 @@ function gi(e, t) {
|
|
|
3837
3839
|
}
|
|
3838
3840
|
};
|
|
3839
3841
|
}
|
|
3840
|
-
function
|
|
3842
|
+
function pi(e, t) {
|
|
3841
3843
|
let n = null;
|
|
3842
3844
|
const r = e.replace(/\/+$/, "");
|
|
3843
3845
|
async function a(i, s) {
|
|
3844
|
-
const
|
|
3846
|
+
const o = await fetch(i, {
|
|
3845
3847
|
...s,
|
|
3846
3848
|
headers: { "Content-Type": "application/json", ...t, ...s == null ? void 0 : s.headers }
|
|
3847
3849
|
});
|
|
3848
|
-
if (!
|
|
3849
|
-
const l = await
|
|
3850
|
+
if (!o.ok) throw new Error(`Chat API error: ${o.status} ${o.statusText}`);
|
|
3851
|
+
const l = await o.json();
|
|
3850
3852
|
return l.data ?? l;
|
|
3851
3853
|
}
|
|
3852
3854
|
return {
|
|
3853
|
-
async createSession(i, s,
|
|
3855
|
+
async createSession(i, s, o) {
|
|
3854
3856
|
return a(`${r}/api/v1/chat/sessions`, {
|
|
3855
3857
|
method: "POST",
|
|
3856
|
-
body: JSON.stringify({ patentId: i, title: s, language:
|
|
3858
|
+
body: JSON.stringify({ patentId: i, title: s, language: o })
|
|
3857
3859
|
});
|
|
3858
3860
|
},
|
|
3859
|
-
async listSessions(i, s = 1,
|
|
3860
|
-
const l = new URLSearchParams({ page: String(s), pageSize: String(
|
|
3861
|
+
async listSessions(i, s = 1, o = 20) {
|
|
3862
|
+
const l = new URLSearchParams({ page: String(s), pageSize: String(o) });
|
|
3861
3863
|
return i && l.set("patentId", i), a(`${r}/api/v1/chat/sessions?${l}`);
|
|
3862
3864
|
},
|
|
3863
|
-
async getMessages(i, s = 1,
|
|
3864
|
-
const l = new URLSearchParams({ page: String(s), pageSize: String(
|
|
3865
|
+
async getMessages(i, s = 1, o = 50) {
|
|
3866
|
+
const l = new URLSearchParams({ page: String(s), pageSize: String(o) });
|
|
3865
3867
|
return a(`${r}/api/v1/chat/sessions/${i}/messages?${l}`);
|
|
3866
3868
|
},
|
|
3867
3869
|
async deleteSession(i) {
|
|
@@ -3878,7 +3880,7 @@ function fi(e, t) {
|
|
|
3878
3880
|
},
|
|
3879
3881
|
async subscribeStream(i, s) {
|
|
3880
3882
|
n = new AbortController();
|
|
3881
|
-
const
|
|
3883
|
+
const o = `${r}/api/v1/chat/sessions/${i}/stream?messageId=${s}`, l = await fetch(o, {
|
|
3882
3884
|
headers: { Accept: "text/event-stream", ...t },
|
|
3883
3885
|
signal: n.signal
|
|
3884
3886
|
});
|
|
@@ -3891,8 +3893,8 @@ function fi(e, t) {
|
|
|
3891
3893
|
}
|
|
3892
3894
|
};
|
|
3893
3895
|
}
|
|
3894
|
-
const
|
|
3895
|
-
({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, editable: i = !0, language: s, aiService:
|
|
3896
|
+
const hi = It(
|
|
3897
|
+
({ 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: u, patchEditorId: m, defaultOutlineCollapsed: p }, h) => {
|
|
3896
3898
|
const { setEditorLanguage: b, setAIService: y, setChatSessionAPI: w } = I(), T = W(null), v = ae((S) => {
|
|
3897
3899
|
T.current = S;
|
|
3898
3900
|
}, []), x = Ee.useMemo(() => {
|
|
@@ -3902,10 +3904,10 @@ const pi = It(
|
|
|
3902
3904
|
return Ee.useEffect(() => {
|
|
3903
3905
|
s && b(s);
|
|
3904
3906
|
}, [s, b]), Ee.useEffect(() => {
|
|
3905
|
-
|
|
3906
|
-
}, [
|
|
3907
|
-
l ? w(l) :
|
|
3908
|
-
}, [l,
|
|
3907
|
+
o ? y(o) : c && y(fi(c, d));
|
|
3908
|
+
}, [o, c, d, y]), Ee.useEffect(() => {
|
|
3909
|
+
l ? w(l) : c && w(pi(c, d));
|
|
3910
|
+
}, [l, c, d, w]), Nt(h, () => ({
|
|
3909
3911
|
getContent: () => {
|
|
3910
3912
|
var S;
|
|
3911
3913
|
return ((S = T.current) == null ? void 0 : S.getJSON()) ?? null;
|
|
@@ -3921,7 +3923,7 @@ const pi = It(
|
|
|
3921
3923
|
(S = T.current) == null || S.commands.focus();
|
|
3922
3924
|
}
|
|
3923
3925
|
})), /* @__PURE__ */ g(
|
|
3924
|
-
|
|
3926
|
+
gi,
|
|
3925
3927
|
{
|
|
3926
3928
|
initialContent: x,
|
|
3927
3929
|
onChange: n,
|
|
@@ -3931,21 +3933,21 @@ const pi = It(
|
|
|
3931
3933
|
editable: i,
|
|
3932
3934
|
onSelectionOptimize: u,
|
|
3933
3935
|
patchEditorId: m,
|
|
3934
|
-
defaultOutlineCollapsed:
|
|
3936
|
+
defaultOutlineCollapsed: p
|
|
3935
3937
|
}
|
|
3936
3938
|
);
|
|
3937
3939
|
}
|
|
3938
3940
|
);
|
|
3939
|
-
|
|
3940
|
-
async function
|
|
3941
|
-
var a, i, s,
|
|
3941
|
+
hi.displayName = "PatentEditor";
|
|
3942
|
+
async function js(e, t, n) {
|
|
3943
|
+
var a, i, s, o;
|
|
3942
3944
|
let r = !1;
|
|
3943
3945
|
(a = n.onStart) == null || a.call(n), n.mode === "section" && typeof n.targetSectionPos == "number" && un(e, n.targetSectionPos);
|
|
3944
3946
|
try {
|
|
3945
3947
|
let l = dn(e, n);
|
|
3946
3948
|
for (; ; ) {
|
|
3947
|
-
const { done:
|
|
3948
|
-
if (
|
|
3949
|
+
const { done: c, value: d } = await t.read();
|
|
3950
|
+
if (c) break;
|
|
3949
3951
|
if (!d) continue;
|
|
3950
3952
|
(i = n.onChunk) == null || i.call(n, d);
|
|
3951
3953
|
const u = e.state.tr.insertText(d, l);
|
|
@@ -3953,28 +3955,28 @@ async function Ws(e, t, n) {
|
|
|
3953
3955
|
}
|
|
3954
3956
|
n.mode === "section" && typeof n.targetSectionPos == "number" && nt(e, n.targetSectionPos), (s = n.onComplete) == null || s.call(n);
|
|
3955
3957
|
} catch (l) {
|
|
3956
|
-
(
|
|
3958
|
+
(o = n.onError) == null || o.call(n, l instanceof Error ? l : new Error(String(l)));
|
|
3957
3959
|
}
|
|
3958
3960
|
}
|
|
3959
|
-
async function
|
|
3960
|
-
var i, s,
|
|
3961
|
+
async function Gs(e, t, n, r) {
|
|
3962
|
+
var i, s, o, l, c, d, u, m;
|
|
3961
3963
|
const a = new AbortController();
|
|
3962
3964
|
(i = r.onStart) == null || i.call(r), r.mode === "section" && typeof r.targetSectionPos == "number" && un(e, r.targetSectionPos);
|
|
3963
3965
|
try {
|
|
3964
|
-
const
|
|
3966
|
+
const p = await fetch(t, {
|
|
3965
3967
|
method: "POST",
|
|
3966
3968
|
headers: { "Content-Type": "application/json" },
|
|
3967
3969
|
body: JSON.stringify(n),
|
|
3968
3970
|
signal: a.signal
|
|
3969
3971
|
});
|
|
3970
|
-
if (!
|
|
3971
|
-
throw new Error(`HTTP ${
|
|
3972
|
-
const
|
|
3973
|
-
if (!
|
|
3972
|
+
if (!p.ok)
|
|
3973
|
+
throw new Error(`HTTP ${p.status}: ${p.statusText}`);
|
|
3974
|
+
const h = (s = p.body) == null ? void 0 : s.getReader();
|
|
3975
|
+
if (!h) throw new Error("No response body");
|
|
3974
3976
|
const b = new TextDecoder();
|
|
3975
3977
|
let y = dn(e, r), w = "";
|
|
3976
3978
|
for (; ; ) {
|
|
3977
|
-
const { done: T, value: v } = await
|
|
3979
|
+
const { done: T, value: v } = await h.read();
|
|
3978
3980
|
if (T) break;
|
|
3979
3981
|
w += b.decode(v, { stream: !0 });
|
|
3980
3982
|
const x = w.split(`
|
|
@@ -3984,11 +3986,11 @@ async function js(e, t, n, r) {
|
|
|
3984
3986
|
if (!S.startsWith("data: ")) continue;
|
|
3985
3987
|
const N = S.slice(6).trim();
|
|
3986
3988
|
if (N === "[DONE]")
|
|
3987
|
-
return r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (
|
|
3989
|
+
return r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (o = r.onComplete) == null || o.call(r), { abort: () => a.abort() };
|
|
3988
3990
|
try {
|
|
3989
|
-
const
|
|
3991
|
+
const f = JSON.parse(N), C = f.content || f.text || ((l = f.delta) == null ? void 0 : l.content) || "";
|
|
3990
3992
|
if (!C) continue;
|
|
3991
|
-
(
|
|
3993
|
+
(c = r.onChunk) == null || c.call(r, C);
|
|
3992
3994
|
const _ = e.state.tr.insertText(C, y);
|
|
3993
3995
|
e.view.dispatch(_), y = _.mapping.map(y, 1);
|
|
3994
3996
|
} catch {
|
|
@@ -3996,8 +3998,8 @@ async function js(e, t, n, r) {
|
|
|
3996
3998
|
}
|
|
3997
3999
|
}
|
|
3998
4000
|
r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (d = r.onComplete) == null || d.call(r);
|
|
3999
|
-
} catch (
|
|
4000
|
-
|
|
4001
|
+
} catch (p) {
|
|
4002
|
+
p.name === "AbortError" ? (u = r.onAbort) == null || u.call(r) : (m = r.onError) == null || m.call(r, p instanceof Error ? p : new Error(String(p)));
|
|
4001
4003
|
}
|
|
4002
4004
|
return { abort: () => a.abort() };
|
|
4003
4005
|
}
|
|
@@ -4026,12 +4028,12 @@ function nt(e, t) {
|
|
|
4026
4028
|
n.forEach((l) => {
|
|
4027
4029
|
s++;
|
|
4028
4030
|
});
|
|
4029
|
-
let
|
|
4031
|
+
let o = 0;
|
|
4030
4032
|
if (n.forEach((l) => {
|
|
4031
|
-
l.type.name === "paragraph" && l.textContent.trim().length > 0 &&
|
|
4033
|
+
l.type.name === "paragraph" && l.textContent.trim().length > 0 && o++;
|
|
4032
4034
|
}), i = t + 1, n.forEach((l) => {
|
|
4033
|
-
const
|
|
4034
|
-
l.type.name === "paragraph" && l.textContent.trim().length === 0 && (
|
|
4035
|
+
const c = i, d = i + l.nodeSize;
|
|
4036
|
+
l.type.name === "paragraph" && l.textContent.trim().length === 0 && (o > 0 || a.length < s - 1) && a.push({ from: c, to: d }), i = d;
|
|
4035
4037
|
}), a.length !== 0) {
|
|
4036
4038
|
for (let l = a.length - 1; l >= 0; l--)
|
|
4037
4039
|
r.delete(a[l].from, a[l].to);
|
|
@@ -4186,7 +4188,7 @@ function rt(e, t = 30) {
|
|
|
4186
4188
|
}
|
|
4187
4189
|
});
|
|
4188
4190
|
}
|
|
4189
|
-
function
|
|
4191
|
+
function yi(e) {
|
|
4190
4192
|
const t = [], n = $e(e, 3);
|
|
4191
4193
|
for (const r of n)
|
|
4192
4194
|
t.push({ type: "delta", content: r });
|
|
@@ -4198,7 +4200,7 @@ function $e(e, t) {
|
|
|
4198
4200
|
n.push(e.slice(r, r + t));
|
|
4199
4201
|
return n;
|
|
4200
4202
|
}
|
|
4201
|
-
function
|
|
4203
|
+
function bi(e, t, n) {
|
|
4202
4204
|
const r = n === "zh", a = [];
|
|
4203
4205
|
let i;
|
|
4204
4206
|
if (e.includes("技术方案") || e.includes("draft") ? i = Pe["help-draft"][r ? "zh" : "en"] : e.includes("审查") || e.includes("review") || e.includes("Review") ? i = Pe.review[r ? "zh" : "en"] : e.includes("权利要求") || e.includes("claims") || e.includes("Optimize") ? i = Pe.claims[r ? "zh" : "en"] : i = Pe.default[r ? "zh" : "en"], t.length > 0) {
|
|
@@ -4207,18 +4209,18 @@ function yi(e, t, n) {
|
|
|
4207
4209
|
` : `Analyzing ${t.length} referenced text(s) and generating suggestions...
|
|
4208
4210
|
|
|
4209
4211
|
`;
|
|
4210
|
-
for (const
|
|
4211
|
-
a.push({ type: "delta", content:
|
|
4212
|
-
for (const
|
|
4213
|
-
a.push({ type: "delta", content:
|
|
4214
|
-
for (let
|
|
4215
|
-
const l = t[
|
|
4212
|
+
for (const o of $e(s, 4))
|
|
4213
|
+
a.push({ type: "delta", content: o });
|
|
4214
|
+
for (const o of $e(i, 4))
|
|
4215
|
+
a.push({ type: "delta", content: o });
|
|
4216
|
+
for (let o = 0; o < t.length; o++) {
|
|
4217
|
+
const l = t[o], c = l.text;
|
|
4216
4218
|
let d;
|
|
4217
|
-
r ? (d =
|
|
4219
|
+
r ? (d = c.replace(/一种/g, "一种基于本发明的").replace(/方法/g, "技术方案").replace(/包括/g, "具体包括"), d === c && (d = `根据本发明优选实施例,${c}`)) : d = `According to a preferred embodiment, ${c.charAt(0).toLowerCase()}${c.slice(1)}`, l.from != null && l.to != null ? a.push({
|
|
4218
4220
|
type: "patch",
|
|
4219
4221
|
patch: {
|
|
4220
4222
|
op: "replace",
|
|
4221
|
-
target: { type: "ref", refIndex:
|
|
4223
|
+
target: { type: "ref", refIndex: o },
|
|
4222
4224
|
content: d,
|
|
4223
4225
|
reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
|
|
4224
4226
|
}
|
|
@@ -4227,7 +4229,7 @@ function yi(e, t, n) {
|
|
|
4227
4229
|
patch: {
|
|
4228
4230
|
op: "replace",
|
|
4229
4231
|
target: { type: "section", sectionType: l.source },
|
|
4230
|
-
search:
|
|
4232
|
+
search: c,
|
|
4231
4233
|
content: d,
|
|
4232
4234
|
reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
|
|
4233
4235
|
}
|
|
@@ -4235,7 +4237,7 @@ function yi(e, t, n) {
|
|
|
4235
4237
|
type: "patch",
|
|
4236
4238
|
patch: {
|
|
4237
4239
|
op: "replace",
|
|
4238
|
-
target: { type: "search", searchText:
|
|
4240
|
+
target: { type: "search", searchText: c },
|
|
4239
4241
|
content: d,
|
|
4240
4242
|
reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
|
|
4241
4243
|
}
|
|
@@ -4246,21 +4248,21 @@ function yi(e, t, n) {
|
|
|
4246
4248
|
a.push({ type: "delta", content: s });
|
|
4247
4249
|
return a.push({ type: "done", usage: { tokens: i.length * 2 } }), a;
|
|
4248
4250
|
}
|
|
4249
|
-
function
|
|
4251
|
+
function Vs() {
|
|
4250
4252
|
let e = null;
|
|
4251
4253
|
return {
|
|
4252
4254
|
async request(t) {
|
|
4253
|
-
var
|
|
4255
|
+
var o;
|
|
4254
4256
|
if (e = new AbortController(), await te(300), e.signal.aborted)
|
|
4255
4257
|
throw new DOMException("Aborted", "AbortError");
|
|
4256
|
-
const n = t.language === "zh" ? "zh" : "en", r = t.sectionType || "technical_field", a = ((
|
|
4258
|
+
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];
|
|
4257
4259
|
let i = a;
|
|
4258
4260
|
t.instruction && (i = (n === "zh" ? `[基于指令"${t.instruction}"生成]
|
|
4259
4261
|
|
|
4260
4262
|
` : `[Generated based on instruction "${t.instruction}"]
|
|
4261
4263
|
|
|
4262
4264
|
`) + a);
|
|
4263
|
-
const s =
|
|
4265
|
+
const s = yi(i);
|
|
4264
4266
|
return rt(s, 25);
|
|
4265
4267
|
},
|
|
4266
4268
|
abort() {
|
|
@@ -4268,13 +4270,13 @@ function Gs() {
|
|
|
4268
4270
|
}
|
|
4269
4271
|
};
|
|
4270
4272
|
}
|
|
4271
|
-
function
|
|
4273
|
+
function Js() {
|
|
4272
4274
|
const e = /* @__PURE__ */ new Map();
|
|
4273
4275
|
let t = null, n = null;
|
|
4274
4276
|
return {
|
|
4275
4277
|
async createSession(r, a, i) {
|
|
4276
4278
|
await te(100);
|
|
4277
|
-
const s = `sess_${Date.now()}`,
|
|
4279
|
+
const s = `sess_${Date.now()}`, o = {
|
|
4278
4280
|
sessionId: s,
|
|
4279
4281
|
patentId: r || void 0,
|
|
4280
4282
|
title: a || (i === "zh" ? "新对话" : "New Chat"),
|
|
@@ -4282,7 +4284,7 @@ function Vs() {
|
|
|
4282
4284
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4283
4285
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4284
4286
|
};
|
|
4285
|
-
return e.set(s, { session:
|
|
4287
|
+
return e.set(s, { session: o, messages: [] }), o;
|
|
4286
4288
|
},
|
|
4287
4289
|
async listSessions() {
|
|
4288
4290
|
await te(50);
|
|
@@ -4311,12 +4313,12 @@ function Vs() {
|
|
|
4311
4313
|
status: "done",
|
|
4312
4314
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4313
4315
|
}), i.session.messageCount = i.messages.length, i.session.lastMessage = a.content, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
4314
|
-
const
|
|
4316
|
+
const o = bi(
|
|
4315
4317
|
a.content,
|
|
4316
4318
|
a.references || [],
|
|
4317
4319
|
a.language
|
|
4318
4320
|
);
|
|
4319
|
-
return n = { messageId: s, events:
|
|
4321
|
+
return n = { messageId: s, events: o }, { messageId: s, sessionId: r, status: "processing" };
|
|
4320
4322
|
},
|
|
4321
4323
|
async subscribeStream(r, a) {
|
|
4322
4324
|
t = new AbortController(), await te(100);
|
|
@@ -4326,24 +4328,24 @@ function Vs() {
|
|
|
4326
4328
|
return rt([{ type: "done" }]);
|
|
4327
4329
|
const s = n.events;
|
|
4328
4330
|
n = null;
|
|
4329
|
-
const
|
|
4330
|
-
let
|
|
4331
|
+
const o = rt(s, 18), l = `${a}_a`;
|
|
4332
|
+
let c = "";
|
|
4331
4333
|
for (const d of s)
|
|
4332
|
-
d.type === "delta" && (
|
|
4334
|
+
d.type === "delta" && (c += d.content);
|
|
4333
4335
|
return i.messages.push({
|
|
4334
4336
|
messageId: l,
|
|
4335
4337
|
role: "assistant",
|
|
4336
|
-
content:
|
|
4338
|
+
content: c,
|
|
4337
4339
|
status: "done",
|
|
4338
4340
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4339
|
-
}), i.session.messageCount = i.messages.length, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString(),
|
|
4341
|
+
}), i.session.messageCount = i.messages.length, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), o;
|
|
4340
4342
|
},
|
|
4341
4343
|
abort() {
|
|
4342
4344
|
t == null || t.abort(), t = null;
|
|
4343
4345
|
}
|
|
4344
4346
|
};
|
|
4345
4347
|
}
|
|
4346
|
-
function
|
|
4348
|
+
function vi(e) {
|
|
4347
4349
|
const t = [], n = e.replace(/\r\n/g, `
|
|
4348
4350
|
`).trim();
|
|
4349
4351
|
if (!n) return t;
|
|
@@ -4358,78 +4360,78 @@ function bi(e) {
|
|
|
4358
4360
|
if (a.length === 0)
|
|
4359
4361
|
return t.push({ number: 1, text: n, dependsOn: [] }), t;
|
|
4360
4362
|
for (let s = 0; s < a.length; s++) {
|
|
4361
|
-
const
|
|
4362
|
-
t.push({ number: d, text:
|
|
4363
|
+
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, u = wi(c, d);
|
|
4364
|
+
t.push({ number: d, text: c, dependsOn: u });
|
|
4363
4365
|
}
|
|
4364
4366
|
return t;
|
|
4365
4367
|
}
|
|
4366
|
-
function
|
|
4368
|
+
function wi(e, t) {
|
|
4367
4369
|
const n = [], r = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g;
|
|
4368
4370
|
let a;
|
|
4369
4371
|
for (; (a = r.exec(e)) !== null; ) {
|
|
4370
|
-
const s = parseInt(a[1], 10),
|
|
4371
|
-
for (let l = s; l <=
|
|
4372
|
+
const s = parseInt(a[1], 10), o = a[2] ? parseInt(a[2], 10) : s;
|
|
4373
|
+
for (let l = s; l <= o; l++)
|
|
4372
4374
|
l !== t && l > 0 && n.push(l);
|
|
4373
4375
|
}
|
|
4374
4376
|
const i = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
|
|
4375
4377
|
for (; (a = i.exec(e)) !== null; ) {
|
|
4376
|
-
const s = parseInt(a[1], 10),
|
|
4377
|
-
for (let l = s; l <=
|
|
4378
|
+
const s = parseInt(a[1], 10), o = a[2] ? parseInt(a[2], 10) : s;
|
|
4379
|
+
for (let l = s; l <= o; l++)
|
|
4378
4380
|
l !== t && l > 0 && n.push(l);
|
|
4379
4381
|
}
|
|
4380
|
-
return [...new Set(n)].sort((s,
|
|
4382
|
+
return [...new Set(n)].sort((s, o) => s - o);
|
|
4381
4383
|
}
|
|
4382
|
-
function
|
|
4383
|
-
return
|
|
4384
|
+
function Ks(e) {
|
|
4385
|
+
return vi(e).map((n) => ({
|
|
4384
4386
|
type: "paragraph",
|
|
4385
4387
|
content: n.text ? [{ type: "text", text: `${n.number}. ${n.text}` }] : [{ type: "text", text: `${n.number}. ` }]
|
|
4386
4388
|
}));
|
|
4387
4389
|
}
|
|
4388
|
-
const
|
|
4390
|
+
const xi = -1, Ci = 1, Ti = 0, at = new we("docDiff");
|
|
4389
4391
|
let Ye = null;
|
|
4390
|
-
function
|
|
4392
|
+
function Si() {
|
|
4391
4393
|
return Ye || (Ye = new Pt()), Ye;
|
|
4392
4394
|
}
|
|
4393
|
-
function
|
|
4395
|
+
function Ei(e, t, n) {
|
|
4394
4396
|
const r = [];
|
|
4395
4397
|
return e.nodesBetween(t, n, (a, i) => {
|
|
4396
4398
|
if (a.isTextblock) {
|
|
4397
|
-
const s = i + 1,
|
|
4398
|
-
return
|
|
4399
|
+
const s = i + 1, o = i + a.nodeSize - 1, l = Math.max(s, t), c = Math.min(o, n);
|
|
4400
|
+
return c > l && r.push({ from: l, to: c }), !1;
|
|
4399
4401
|
}
|
|
4400
4402
|
return !0;
|
|
4401
4403
|
}), r;
|
|
4402
4404
|
}
|
|
4403
|
-
function
|
|
4404
|
-
const n = e.state.doc, r = n.content.size, { text: a, segments: i } = Gt(e, 0, r), s =
|
|
4405
|
-
s.diff_cleanupSemantic(
|
|
4405
|
+
function Xs(e, t) {
|
|
4406
|
+
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);
|
|
4407
|
+
s.diff_cleanupSemantic(o);
|
|
4406
4408
|
const l = [];
|
|
4407
|
-
let
|
|
4408
|
-
for (const [m,
|
|
4409
|
-
if (m ===
|
|
4410
|
-
|
|
4411
|
-
else if (m ===
|
|
4412
|
-
let
|
|
4413
|
-
for (;
|
|
4414
|
-
for (;
|
|
4415
|
-
if (
|
|
4416
|
-
const b =
|
|
4417
|
-
for (;
|
|
4418
|
-
const y = ye(i,
|
|
4409
|
+
let c = 0;
|
|
4410
|
+
for (const [m, p] of o)
|
|
4411
|
+
if (m === Ti)
|
|
4412
|
+
c += p.length;
|
|
4413
|
+
else if (m === Ci) {
|
|
4414
|
+
let h = 0;
|
|
4415
|
+
for (; h < p.length; ) {
|
|
4416
|
+
for (; h < p.length && p[h] === "\0"; ) h++;
|
|
4417
|
+
if (h >= p.length) break;
|
|
4418
|
+
const b = h;
|
|
4419
|
+
for (; h < p.length && p[h] !== "\0"; ) h++;
|
|
4420
|
+
const y = ye(i, c + b), w = ye(i, c + h);
|
|
4419
4421
|
if (y >= 0 && w >= 0 && w > y)
|
|
4420
|
-
for (const T of
|
|
4422
|
+
for (const T of Ei(n, y, w))
|
|
4421
4423
|
l.push(
|
|
4422
4424
|
re.inline(T.from, T.to, { class: "patch-diff-insert-inline" })
|
|
4423
4425
|
);
|
|
4424
4426
|
}
|
|
4425
|
-
|
|
4426
|
-
} else if (m ===
|
|
4427
|
-
const
|
|
4428
|
-
if (
|
|
4429
|
-
const b =
|
|
4427
|
+
c += p.length;
|
|
4428
|
+
} else if (m === xi) {
|
|
4429
|
+
const h = ye(i, c);
|
|
4430
|
+
if (h >= 0) {
|
|
4431
|
+
const b = p.replace(/\0/g, " ");
|
|
4430
4432
|
l.push(
|
|
4431
4433
|
re.widget(
|
|
4432
|
-
|
|
4434
|
+
h,
|
|
4433
4435
|
() => {
|
|
4434
4436
|
const y = document.createElement("span");
|
|
4435
4437
|
return y.className = "patch-diff-delete", y.textContent = b, y;
|
|
@@ -4443,7 +4445,7 @@ function Ks(e, t) {
|
|
|
4443
4445
|
key: at,
|
|
4444
4446
|
state: {
|
|
4445
4447
|
init: () => d,
|
|
4446
|
-
apply: (m,
|
|
4448
|
+
apply: (m, p) => m.docChanged ? p.map(m.mapping, m.doc) : p
|
|
4447
4449
|
},
|
|
4448
4450
|
props: {
|
|
4449
4451
|
decorations(m) {
|
|
@@ -4453,22 +4455,22 @@ function Ks(e, t) {
|
|
|
4453
4455
|
});
|
|
4454
4456
|
e.registerPlugin(u);
|
|
4455
4457
|
}
|
|
4456
|
-
function
|
|
4458
|
+
function Ys(e) {
|
|
4457
4459
|
e.unregisterPlugin(at);
|
|
4458
4460
|
}
|
|
4459
|
-
const
|
|
4461
|
+
const ki = /* @__PURE__ */ new Set([
|
|
4460
4462
|
"abstract",
|
|
4461
4463
|
"abstract_drawing",
|
|
4462
4464
|
"claims",
|
|
4463
4465
|
"drawing_figures"
|
|
4464
|
-
]),
|
|
4466
|
+
]), _i = /* @__PURE__ */ new Set([
|
|
4465
4467
|
"technical_field",
|
|
4466
4468
|
"background_art",
|
|
4467
4469
|
"summary",
|
|
4468
4470
|
"drawing_description",
|
|
4469
4471
|
"detailed_description"
|
|
4470
4472
|
]);
|
|
4471
|
-
function
|
|
4473
|
+
function Ii(e, t) {
|
|
4472
4474
|
const n = H(t), r = [];
|
|
4473
4475
|
return e.state.doc.descendants((a) => {
|
|
4474
4476
|
if (a.type.name === "patent_title") {
|
|
@@ -4481,11 +4483,11 @@ function _i(e, t) {
|
|
|
4481
4483
|
}), !1;
|
|
4482
4484
|
}
|
|
4483
4485
|
if (a.type.name === "patent_section") {
|
|
4484
|
-
const i = a.attrs.sectionType, s = `sectionTitle_${i}`,
|
|
4485
|
-
return a.forEach((
|
|
4486
|
-
const d =
|
|
4486
|
+
const i = a.attrs.sectionType, s = `sectionTitle_${i}`, o = typeof n[s] == "string" ? n[s] : i, l = [];
|
|
4487
|
+
return a.forEach((c) => {
|
|
4488
|
+
const d = c.textContent.trim();
|
|
4487
4489
|
d && l.push(d);
|
|
4488
|
-
}), r.push({ type: "patent_section", sectionType: i, title:
|
|
4490
|
+
}), r.push({ type: "patent_section", sectionType: i, title: o, paragraphs: l }), !1;
|
|
4489
4491
|
}
|
|
4490
4492
|
return !0;
|
|
4491
4493
|
}), r;
|
|
@@ -4504,7 +4506,7 @@ function Et(e) {
|
|
|
4504
4506
|
spacing: { before: 240, after: 120 }
|
|
4505
4507
|
});
|
|
4506
4508
|
}
|
|
4507
|
-
function
|
|
4509
|
+
function Ni(e) {
|
|
4508
4510
|
return new He({
|
|
4509
4511
|
children: [new Ue({ text: e, bold: !0, size: 36, font: "宋体" })],
|
|
4510
4512
|
alignment: it.CENTER,
|
|
@@ -4518,11 +4520,11 @@ function Ze(e) {
|
|
|
4518
4520
|
indent: { firstLine: he(7) }
|
|
4519
4521
|
});
|
|
4520
4522
|
}
|
|
4521
|
-
function
|
|
4523
|
+
function Ai(e, t) {
|
|
4522
4524
|
const n = H(t), r = [];
|
|
4523
4525
|
let a = !1;
|
|
4524
4526
|
for (const i of e) {
|
|
4525
|
-
if (
|
|
4527
|
+
if (ki.has(i.sectionType)) {
|
|
4526
4528
|
r.push(St(i.title));
|
|
4527
4529
|
for (const s of i.paragraphs)
|
|
4528
4530
|
r.push(Ze(s));
|
|
@@ -4534,10 +4536,10 @@ function Ni(e, t) {
|
|
|
4534
4536
|
r.push(St(s)), a = !0;
|
|
4535
4537
|
}
|
|
4536
4538
|
for (const s of i.paragraphs)
|
|
4537
|
-
r.push(
|
|
4539
|
+
r.push(Ni(s));
|
|
4538
4540
|
continue;
|
|
4539
4541
|
}
|
|
4540
|
-
if (
|
|
4542
|
+
if (_i.has(i.sectionType)) {
|
|
4541
4543
|
r.push(Et(i.title));
|
|
4542
4544
|
for (const s of i.paragraphs)
|
|
4543
4545
|
r.push(Ze(s));
|
|
@@ -4549,8 +4551,8 @@ function Ni(e, t) {
|
|
|
4549
4551
|
}
|
|
4550
4552
|
return r;
|
|
4551
4553
|
}
|
|
4552
|
-
async function
|
|
4553
|
-
const n =
|
|
4554
|
+
async function Zs(e, t) {
|
|
4555
|
+
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 = {
|
|
4554
4556
|
properties: {
|
|
4555
4557
|
page: {
|
|
4556
4558
|
margin: {
|
|
@@ -4562,19 +4564,19 @@ async function Ys(e, t) {
|
|
|
4562
4564
|
}
|
|
4563
4565
|
},
|
|
4564
4566
|
children: r
|
|
4565
|
-
},
|
|
4567
|
+
}, o = new Kr({
|
|
4566
4568
|
sections: [s]
|
|
4567
|
-
}), l = await Xr.toBlob(
|
|
4569
|
+
}), l = await Xr.toBlob(o);
|
|
4568
4570
|
Yr(l, i);
|
|
4569
4571
|
}
|
|
4570
|
-
async function
|
|
4572
|
+
async function Qs(e) {
|
|
4571
4573
|
window.print();
|
|
4572
4574
|
}
|
|
4573
|
-
function
|
|
4575
|
+
function eo(e, t) {
|
|
4574
4576
|
const n = [], r = t === "zh";
|
|
4575
4577
|
let a = 0;
|
|
4576
4578
|
const i = () => `v_${++a}`;
|
|
4577
|
-
return e.state.doc.descendants((s,
|
|
4579
|
+
return e.state.doc.descendants((s, o) => {
|
|
4578
4580
|
if (s.type.name === "patent_title") {
|
|
4579
4581
|
const l = s.textContent.trim();
|
|
4580
4582
|
if (l.length === 0)
|
|
@@ -4583,56 +4585,56 @@ function Qs(e, t) {
|
|
|
4583
4585
|
severity: "warning",
|
|
4584
4586
|
message: r ? "专利名称为空" : "Patent title is empty",
|
|
4585
4587
|
sectionType: "patent_title",
|
|
4586
|
-
pos:
|
|
4588
|
+
pos: o
|
|
4587
4589
|
});
|
|
4588
4590
|
else {
|
|
4589
|
-
const
|
|
4590
|
-
|
|
4591
|
+
const c = l.replace(/\s/g, "").length;
|
|
4592
|
+
c > 25 && r && n.push({
|
|
4591
4593
|
id: i(),
|
|
4592
4594
|
severity: "error",
|
|
4593
|
-
message: `专利名称超过25个汉字(当前${
|
|
4595
|
+
message: `专利名称超过25个汉字(当前${c}字)`,
|
|
4594
4596
|
sectionType: "patent_title",
|
|
4595
|
-
pos:
|
|
4597
|
+
pos: o
|
|
4596
4598
|
});
|
|
4597
4599
|
}
|
|
4598
4600
|
return !1;
|
|
4599
4601
|
}
|
|
4600
4602
|
if (s.type.name === "patent_section") {
|
|
4601
|
-
const l = s.attrs.sectionType,
|
|
4602
|
-
if (
|
|
4603
|
+
const l = s.attrs.sectionType, c = s.textContent.trim();
|
|
4604
|
+
if (c.length === 0 && n.push({
|
|
4603
4605
|
id: i(),
|
|
4604
4606
|
severity: "warning",
|
|
4605
4607
|
message: r ? `章节"${l}"内容为空` : `Section "${l}" is empty`,
|
|
4606
4608
|
sectionType: l,
|
|
4607
|
-
pos:
|
|
4609
|
+
pos: o
|
|
4608
4610
|
}), l === "abstract") {
|
|
4609
|
-
const d =
|
|
4611
|
+
const d = c.replace(/\s/g, "").length;
|
|
4610
4612
|
d > 0 && d < 50 && n.push({
|
|
4611
4613
|
id: i(),
|
|
4612
4614
|
severity: "warning",
|
|
4613
4615
|
message: r ? `摘要字数过少(${d}字),建议50~300字` : `Abstract too short (${d} chars), recommend 50-300`,
|
|
4614
4616
|
sectionType: l,
|
|
4615
|
-
pos:
|
|
4617
|
+
pos: o
|
|
4616
4618
|
}), d > 300 && n.push({
|
|
4617
4619
|
id: i(),
|
|
4618
4620
|
severity: "warning",
|
|
4619
4621
|
message: r ? `摘要字数过多(${d}字),建议不超过300字` : `Abstract too long (${d} chars), recommend ≤300`,
|
|
4620
4622
|
sectionType: l,
|
|
4621
|
-
pos:
|
|
4623
|
+
pos: o
|
|
4622
4624
|
});
|
|
4623
4625
|
}
|
|
4624
4626
|
if (l === "claims") {
|
|
4625
4627
|
const d = /^(\d+)\s*[.、]/;
|
|
4626
4628
|
s.forEach((u, m) => {
|
|
4627
4629
|
if (u.type.name !== "paragraph") return;
|
|
4628
|
-
const
|
|
4629
|
-
if (!
|
|
4630
|
-
const b =
|
|
4631
|
-
|
|
4630
|
+
const p = u.textContent.trim(), h = d.exec(p);
|
|
4631
|
+
if (!h) return;
|
|
4632
|
+
const b = h[1];
|
|
4633
|
+
p.length > 0 && !p.endsWith("。") && !p.endsWith(".") && n.push({
|
|
4632
4634
|
id: i(),
|
|
4633
4635
|
severity: "warning",
|
|
4634
4636
|
message: r ? `权利要求${b}末尾应以句号结束` : `Claim ${b} should end with a period`,
|
|
4635
|
-
pos:
|
|
4637
|
+
pos: o + 1 + m
|
|
4636
4638
|
});
|
|
4637
4639
|
});
|
|
4638
4640
|
}
|
|
@@ -4641,8 +4643,8 @@ function Qs(e, t) {
|
|
|
4641
4643
|
return !0;
|
|
4642
4644
|
}), n;
|
|
4643
4645
|
}
|
|
4644
|
-
const
|
|
4645
|
-
function
|
|
4646
|
+
const Li = /^(\d+)\s*[.、]\s*/, kt = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g, _t = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
|
|
4647
|
+
function Pi(e, t) {
|
|
4646
4648
|
const n = [];
|
|
4647
4649
|
let r;
|
|
4648
4650
|
for (kt.lastIndex = 0; (r = kt.exec(e)) !== null; ) {
|
|
@@ -4659,7 +4661,7 @@ function Li(e, t) {
|
|
|
4659
4661
|
}
|
|
4660
4662
|
const mn = (e) => {
|
|
4661
4663
|
if (e.type.name === "reference")
|
|
4662
|
-
return
|
|
4664
|
+
return Di(e);
|
|
4663
4665
|
if (e.type.name === "hardBreak")
|
|
4664
4666
|
return `
|
|
4665
4667
|
`;
|
|
@@ -4669,7 +4671,7 @@ const mn = (e) => {
|
|
|
4669
4671
|
return e.forEach((n) => {
|
|
4670
4672
|
t += mn(n);
|
|
4671
4673
|
}), t;
|
|
4672
|
-
},
|
|
4674
|
+
}, Di = (e) => {
|
|
4673
4675
|
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() : "";
|
|
4674
4676
|
if (r)
|
|
4675
4677
|
return r;
|
|
@@ -4679,62 +4681,62 @@ const mn = (e) => {
|
|
|
4679
4681
|
}
|
|
4680
4682
|
const a = Number(e.attrs.resolvedNumber);
|
|
4681
4683
|
return Number.isFinite(a) ? t === "en" ? `Claim ${a}` : `权利要求${a}` : t === "en" ? "Claim ?" : "权利要求?";
|
|
4682
|
-
},
|
|
4684
|
+
}, to = (e) => {
|
|
4683
4685
|
const t = [];
|
|
4684
4686
|
return e.state.doc.descendants((n, r) => {
|
|
4685
4687
|
if (n.type.name === "patent_section")
|
|
4686
4688
|
return n.attrs.sectionType === "claims";
|
|
4687
4689
|
if (n.type.name !== "paragraph") return !0;
|
|
4688
|
-
const a = mn(n).trim(), i =
|
|
4690
|
+
const a = mn(n).trim(), i = Li.exec(a);
|
|
4689
4691
|
if (!i) return !0;
|
|
4690
4692
|
const s = parseInt(i[1], 10);
|
|
4691
4693
|
if (!Number.isFinite(s) || s <= 0) return !0;
|
|
4692
|
-
const
|
|
4694
|
+
const o = a.slice(i[0].length).trim(), l = Pi(o, s);
|
|
4693
4695
|
return t.push({
|
|
4694
4696
|
claimId: `claim_${s}`,
|
|
4695
4697
|
number: s,
|
|
4696
4698
|
dependsOn: l,
|
|
4697
|
-
dependsOnClaimIds: l.map((
|
|
4698
|
-
body:
|
|
4699
|
+
dependsOnClaimIds: l.map((c) => `claim_${c}`),
|
|
4700
|
+
body: o,
|
|
4699
4701
|
pos: r
|
|
4700
4702
|
}), !0;
|
|
4701
4703
|
}), t;
|
|
4702
4704
|
};
|
|
4703
4705
|
export {
|
|
4704
|
-
|
|
4706
|
+
gi as EditorView,
|
|
4705
4707
|
jt as PatchDiffPluginKey,
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4708
|
+
hi as PatentEditor,
|
|
4709
|
+
Hs as acceptAllPatches,
|
|
4710
|
+
Os as acceptPatch,
|
|
4711
|
+
Xs as applyDocDiffDecorations,
|
|
4712
|
+
Ws as buildAIContext,
|
|
4713
|
+
Ks as buildClaimsJSONContent,
|
|
4712
4714
|
tn as buildPatentDocument,
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
+
zs as clearPatches,
|
|
4716
|
+
pi as createChatSessionAPI,
|
|
4715
4717
|
ct as createCommandExecutor,
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4718
|
+
Xa as createEditorConfig,
|
|
4719
|
+
Vs as createMockAIService,
|
|
4720
|
+
Js as createMockChatSessionAPI,
|
|
4721
|
+
fi as createSSEAdapter,
|
|
4722
|
+
Qs as exportToPdf,
|
|
4723
|
+
Zs as exportToWord,
|
|
4724
|
+
to as extractClaimsFromEditor,
|
|
4723
4725
|
on as findSectionAtCursor,
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4726
|
+
ti as getAllSections,
|
|
4727
|
+
qs as getMissingSectionDeps,
|
|
4728
|
+
Fs as getPatches,
|
|
4729
|
+
Ms as onPatchChange,
|
|
4728
4730
|
B as pluginManager,
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4731
|
+
Us as rejectAllPatches,
|
|
4732
|
+
Bs as rejectPatch,
|
|
4733
|
+
Ys as removeDocDiffDecorations,
|
|
4734
|
+
Rs as resolvePatchTarget,
|
|
4733
4735
|
sn as sectionContextDeps,
|
|
4734
|
-
|
|
4736
|
+
$s as setPatches,
|
|
4735
4737
|
I as useEditorStore,
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4738
|
+
eo as validatePatentDocument,
|
|
4739
|
+
js as writeStream,
|
|
4740
|
+
Gs as writeStreamFromSSE
|
|
4739
4741
|
};
|
|
4740
4742
|
//# sourceMappingURL=lib.js.map
|