patent-editor 0.2.14 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib.js +730 -691
- package/dist/lib.js.map +1 -1
- package/package.json +1 -1
package/dist/lib.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var Sn = Object.defineProperty;
|
|
2
2
|
var En = (e, t, n) => t in e ? Sn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var Se = (e, t, n) => En(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import { jsx as
|
|
5
|
-
import Ee, { forwardRef as It, useState as
|
|
6
|
-
import { Extension as Oe, ReactRenderer as kn, Node as
|
|
4
|
+
import { jsx as f, jsxs as P, Fragment as je } from "react/jsx-runtime";
|
|
5
|
+
import Ee, { forwardRef as It, useState as M, useEffect as F, useCallback as j, useImperativeHandle as Nt, useRef as W, useMemo as At } from "react";
|
|
6
|
+
import { Extension as Oe, ReactRenderer as kn, Node as Q, mergeAttributes as ie, NodeViewWrapper as _n, ReactNodeViewRenderer as Pt, EditorContent as In, useEditor as Nn } from "@tiptap/react";
|
|
7
7
|
import An from "@tiptap/extension-document";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import Pn from "@tiptap/extension-paragraph";
|
|
9
|
+
import Ln from "@tiptap/extension-text";
|
|
10
10
|
import Dn from "@tiptap/extension-heading";
|
|
11
11
|
import Rn from "@tiptap/extension-bullet-list";
|
|
12
12
|
import Mn from "@tiptap/extension-ordered-list";
|
|
@@ -30,8 +30,8 @@ import { PluginKey as we, Plugin as Be, TextSelection as Zn } from "@tiptap/pm/s
|
|
|
30
30
|
import Qn from "@tiptap/suggestion";
|
|
31
31
|
import er from "tippy.js";
|
|
32
32
|
import { create as tr } from "zustand";
|
|
33
|
-
import { DecorationSet as
|
|
34
|
-
import { diff_match_patch as
|
|
33
|
+
import { DecorationSet as de, Decoration as ae } from "@tiptap/pm/view";
|
|
34
|
+
import { diff_match_patch as Lt } from "diff-match-patch";
|
|
35
35
|
import nr from "@tiptap/extension-bold";
|
|
36
36
|
import rr from "@tiptap/extension-italic";
|
|
37
37
|
import ar from "@tiptap/extension-underline";
|
|
@@ -49,10 +49,10 @@ import "mathlive";
|
|
|
49
49
|
import { findWrapping as fr } from "@tiptap/pm/transform";
|
|
50
50
|
import { Slice as pr, Fragment as hr } from "@tiptap/pm/model";
|
|
51
51
|
import { createPortal as yr } from "react-dom";
|
|
52
|
-
import { Undo2 as br, Redo2 as vr, Bold as Dt, Italic as Rt, Underline as Mt, Strikethrough as Ft, Code as $t, Superscript as zt, Subscript as Ot, Pilcrow as wr, Heading1 as xr, Heading2 as Cr, Heading3 as Tr, AlignLeft as Sr, AlignCenter as Er, AlignRight as kr, AlignJustify as _r, List as Ir, ListOrdered as Nr, Quote as Ar, FileCode2 as
|
|
53
|
-
import
|
|
52
|
+
import { Undo2 as br, Redo2 as vr, Bold as Dt, Italic as Rt, Underline as Mt, Strikethrough as Ft, Code as $t, Superscript as zt, Subscript as Ot, Pilcrow as wr, Heading1 as xr, Heading2 as Cr, Heading3 as Tr, AlignLeft as Sr, AlignCenter as Er, AlignRight as kr, AlignJustify as _r, List as Ir, ListOrdered as Nr, Quote as Ar, FileCode2 as Pr, Table as Lr, Minus as Dr, CheckSquare as Rr, Image as Bt, Link2 as Ht, FileText as Ut, Box as Mr, Workflow as Fr, FunctionSquare as $r, Sigma as zr, GitGraph as Or, Square as mt, ChevronDown as qt, Highlighter as Br, Sparkles as Hr, CaseSensitive as Ur, ChevronUp as qr, Replace as gt, X as Wr, ReplaceAll as jr, PanelLeft as Gr, PanelLeftClose as Vr } from "lucide-react";
|
|
53
|
+
import Z from "clsx";
|
|
54
54
|
import { BubbleMenu as Jr } from "@tiptap/react/menus";
|
|
55
|
-
import { convertMillimetersToTwip as
|
|
55
|
+
import { convertMillimetersToTwip as ye, Document as Kr, Packer as Xr, Paragraph as He, AlignmentType as it, TextRun as Ue } from "docx";
|
|
56
56
|
import { saveAs as Yr } from "file-saver";
|
|
57
57
|
const Zr = new we("slashCommand"), Qr = Oe.create({
|
|
58
58
|
name: "slashCommand",
|
|
@@ -164,11 +164,11 @@ const Zr = new we("slashCommand"), Qr = Oe.create({
|
|
|
164
164
|
}))
|
|
165
165
|
})), Wt = It(
|
|
166
166
|
({ items: e, command: t }, n) => {
|
|
167
|
-
const [r, a] =
|
|
168
|
-
|
|
167
|
+
const [r, a] = M(0);
|
|
168
|
+
F(() => {
|
|
169
169
|
a(0);
|
|
170
170
|
}, [e]);
|
|
171
|
-
const i =
|
|
171
|
+
const i = j(
|
|
172
172
|
(s) => {
|
|
173
173
|
const o = e[s];
|
|
174
174
|
o && t(o);
|
|
@@ -177,22 +177,22 @@ const Zr = new we("slashCommand"), Qr = Oe.create({
|
|
|
177
177
|
);
|
|
178
178
|
return Nt(n, () => ({
|
|
179
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__ */
|
|
180
|
+
})), e.length ? /* @__PURE__ */ f("div", { className: "slash-menu", children: e.map((s, o) => /* @__PURE__ */ P(
|
|
181
181
|
"button",
|
|
182
182
|
{
|
|
183
183
|
className: `slash-menu-item ${o === r ? "slash-menu-item--active" : ""}`,
|
|
184
184
|
onClick: () => i(o),
|
|
185
185
|
onMouseEnter: () => a(o),
|
|
186
186
|
children: [
|
|
187
|
-
/* @__PURE__ */
|
|
188
|
-
/* @__PURE__ */
|
|
189
|
-
/* @__PURE__ */
|
|
190
|
-
/* @__PURE__ */
|
|
187
|
+
/* @__PURE__ */ f("span", { className: "slash-menu-icon", children: s.icon }),
|
|
188
|
+
/* @__PURE__ */ P("div", { className: "slash-menu-text", children: [
|
|
189
|
+
/* @__PURE__ */ f("span", { className: "slash-menu-title", children: s.title }),
|
|
190
|
+
/* @__PURE__ */ f("span", { className: "slash-menu-desc", children: s.description })
|
|
191
191
|
] })
|
|
192
192
|
]
|
|
193
193
|
},
|
|
194
194
|
s.title
|
|
195
|
-
)) }) : /* @__PURE__ */
|
|
195
|
+
)) }) : /* @__PURE__ */ f("div", { className: "slash-menu", children: /* @__PURE__ */ f("div", { className: "slash-menu-empty", children: "No results" }) });
|
|
196
196
|
}
|
|
197
197
|
);
|
|
198
198
|
Wt.displayName = "SlashMenuList";
|
|
@@ -382,6 +382,20 @@ const ia = Oe.create({
|
|
|
382
382
|
currentIndex: 0
|
|
383
383
|
};
|
|
384
384
|
},
|
|
385
|
+
// Keep stored match positions in sync with document edits. Without this the
|
|
386
|
+
// positions captured at search time go stale: when the document later shrinks
|
|
387
|
+
// (AI streaming, applying/accepting a diff, replacing content, etc.) a stale
|
|
388
|
+
// `to` can exceed the current doc size, and the decoration plugin would then
|
|
389
|
+
// build an out-of-range Decoration, crashing ProseMirror with
|
|
390
|
+
// "Cannot read properties of undefined (reading 'localsInner')".
|
|
391
|
+
onTransaction({ transaction: e }) {
|
|
392
|
+
if (!e.docChanged || this.storage.results.length === 0) return;
|
|
393
|
+
const t = e.doc.content.size, n = this.storage.results.map((r) => ({
|
|
394
|
+
from: e.mapping.map(r.from, 1),
|
|
395
|
+
to: e.mapping.map(r.to, -1)
|
|
396
|
+
})).filter((r) => r.from < r.to && r.from >= 0 && r.to <= t);
|
|
397
|
+
this.storage.results = n, n.length === 0 ? this.storage.currentIndex = -1 : this.storage.currentIndex >= n.length && (this.storage.currentIndex = n.length - 1);
|
|
398
|
+
},
|
|
385
399
|
addCommands() {
|
|
386
400
|
return {
|
|
387
401
|
setSearchTerm: (e) => ({ editor: t }) => (this.storage.searchTerm = e, this.storage.results = ke(t.state.doc, e, this.storage.caseSensitive), this.storage.currentIndex = this.storage.results.length > 0 ? 0 : -1, t.view.dispatch(t.state.tr), !0),
|
|
@@ -439,12 +453,13 @@ const ia = Oe.create({
|
|
|
439
453
|
props: {
|
|
440
454
|
decorations: (t) => {
|
|
441
455
|
if (!e.searchTerm || e.results.length === 0)
|
|
442
|
-
return
|
|
443
|
-
const n =
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
456
|
+
return de.empty;
|
|
457
|
+
const n = t.doc.content.size, r = [];
|
|
458
|
+
return e.results.forEach((a, i) => {
|
|
459
|
+
if (a.from < 0 || a.to > n || a.from >= a.to) return;
|
|
460
|
+
const s = i === e.currentIndex ? "search-highlight search-highlight--current" : "search-highlight";
|
|
461
|
+
r.push(ae.inline(a.from, a.to, { class: s }));
|
|
462
|
+
}), r.length === 0 ? de.empty : de.create(t.doc, r);
|
|
448
463
|
}
|
|
449
464
|
}
|
|
450
465
|
})
|
|
@@ -463,7 +478,7 @@ function ft(e) {
|
|
|
463
478
|
const sa = -1, oa = 1, pt = 0;
|
|
464
479
|
let Ge = null;
|
|
465
480
|
function ca() {
|
|
466
|
-
return Ge || (Ge = new
|
|
481
|
+
return Ge || (Ge = new Lt()), Ge;
|
|
467
482
|
}
|
|
468
483
|
const jt = new we("patchDiff");
|
|
469
484
|
function la(e, t) {
|
|
@@ -475,12 +490,12 @@ function Gt(e, t, n) {
|
|
|
475
490
|
let a = "", i = !0;
|
|
476
491
|
return e.state.doc.nodesBetween(t, n, (s, o) => {
|
|
477
492
|
if (s.isText) {
|
|
478
|
-
const l = o, c = Math.max(t, l) - l, d = Math.min(n, l + s.nodeSize) - l,
|
|
479
|
-
r.push({ textIdx: a.length, docPos: l + c, len:
|
|
493
|
+
const l = o, c = Math.max(t, l) - l, d = Math.min(n, l + s.nodeSize) - l, m = s.text.slice(c, d);
|
|
494
|
+
r.push({ textIdx: a.length, docPos: l + c, len: m.length }), a += m, i = !1;
|
|
480
495
|
} else s.isLeaf ? (a += "\0", i = !1) : !i && s.isBlock && (a += "\0", i = !0);
|
|
481
496
|
}), { text: a, segments: r };
|
|
482
497
|
}
|
|
483
|
-
function
|
|
498
|
+
function be(e, t) {
|
|
484
499
|
for (const n of e)
|
|
485
500
|
if (t >= n.textIdx && t <= n.textIdx + n.len)
|
|
486
501
|
return n.docPos + (t - n.textIdx);
|
|
@@ -499,7 +514,7 @@ function ht(e, t, n, r, a) {
|
|
|
499
514
|
for (; o <= i.length - t.length; ) {
|
|
500
515
|
const l = i.indexOf(t, o);
|
|
501
516
|
if (l === -1) return null;
|
|
502
|
-
const c =
|
|
517
|
+
const c = be(s, l), d = be(s, l + t.length);
|
|
503
518
|
if (c >= 0 && d >= 0 && !(a && a.has(c)))
|
|
504
519
|
return { from: c, to: d };
|
|
505
520
|
o = l + 1;
|
|
@@ -539,27 +554,27 @@ function Rs(e, t, n, r, a) {
|
|
|
539
554
|
status: "pending"
|
|
540
555
|
};
|
|
541
556
|
}
|
|
542
|
-
const
|
|
557
|
+
const G = /* @__PURE__ */ new Map();
|
|
543
558
|
let De = [];
|
|
544
559
|
function Ms(e) {
|
|
545
560
|
return De.push(e), () => {
|
|
546
561
|
De = De.filter((t) => t !== e);
|
|
547
562
|
};
|
|
548
563
|
}
|
|
549
|
-
function
|
|
564
|
+
function me() {
|
|
550
565
|
De.forEach((e) => e());
|
|
551
566
|
}
|
|
552
567
|
function Fs(e = "default") {
|
|
553
|
-
return [...
|
|
568
|
+
return [...G.get(e) || []];
|
|
554
569
|
}
|
|
555
570
|
function $s(e, t = "default") {
|
|
556
|
-
|
|
571
|
+
G.set(t, e), me();
|
|
557
572
|
}
|
|
558
573
|
function zs(e = "default") {
|
|
559
|
-
|
|
574
|
+
G.delete(e), me();
|
|
560
575
|
}
|
|
561
576
|
function Os(e, t, n = "default") {
|
|
562
|
-
const r =
|
|
577
|
+
const r = G.get(n) || [], a = r.find((o) => o.id === t);
|
|
563
578
|
if (!a || a.status !== "pending") return !1;
|
|
564
579
|
a.status = "accepted";
|
|
565
580
|
const { tr: i } = e.state;
|
|
@@ -579,14 +594,14 @@ function Os(e, t, n = "default") {
|
|
|
579
594
|
const l = s.map(o.from, 1), c = s.map(o.to, -1);
|
|
580
595
|
l >= c && o.type !== "insert" ? o.status = "rejected" : (o.from = l, o.to = o.type === "insert" ? l : c);
|
|
581
596
|
}
|
|
582
|
-
return
|
|
597
|
+
return G.set(n, r.filter((o) => o.id !== t && o.status === "pending")), qe(e), me(), !0;
|
|
583
598
|
}
|
|
584
599
|
function Bs(e, t, n = "default") {
|
|
585
|
-
const r =
|
|
586
|
-
return !a || a.status !== "pending" ? !1 : (a.status = "rejected",
|
|
600
|
+
const r = G.get(n) || [], a = r.find((i) => i.id === t);
|
|
601
|
+
return !a || a.status !== "pending" ? !1 : (a.status = "rejected", G.set(n, r.filter((i) => i.id !== t)), qe(e), me(), !0);
|
|
587
602
|
}
|
|
588
603
|
function Hs(e, t = "default") {
|
|
589
|
-
const a = [...(
|
|
604
|
+
const a = [...(G.get(t) || []).filter((s) => s.status === "pending")].sort((s, o) => o.from - s.from), { tr: i } = e.state;
|
|
590
605
|
for (const s of a)
|
|
591
606
|
if (s.type === "delete")
|
|
592
607
|
i.delete(s.from, s.to);
|
|
@@ -597,10 +612,10 @@ function Hs(e, t = "default") {
|
|
|
597
612
|
i.replaceWith(s.from, s.to, l);
|
|
598
613
|
} else
|
|
599
614
|
i.insertText(s.content, s.from, s.to);
|
|
600
|
-
e.view.dispatch(i),
|
|
615
|
+
e.view.dispatch(i), G.delete(t), qe(e), me();
|
|
601
616
|
}
|
|
602
617
|
function Us(e, t = "default") {
|
|
603
|
-
|
|
618
|
+
G.delete(t), qe(e), me();
|
|
604
619
|
}
|
|
605
620
|
function qe(e) {
|
|
606
621
|
e.view.dispatch(e.state.tr.setMeta(jt, !0));
|
|
@@ -635,13 +650,13 @@ function ua(e, t) {
|
|
|
635
650
|
else if (o === sa) {
|
|
636
651
|
const c = s + l.length;
|
|
637
652
|
i.push(
|
|
638
|
-
|
|
653
|
+
ae.inline(s, c, {
|
|
639
654
|
class: "patch-diff-delete",
|
|
640
655
|
"data-patch-id": t.id
|
|
641
656
|
})
|
|
642
657
|
), s = c;
|
|
643
658
|
} else o === oa && i.push(
|
|
644
|
-
|
|
659
|
+
ae.widget(s, () => {
|
|
645
660
|
const c = document.createElement("span");
|
|
646
661
|
return c.className = "patch-diff-insert-inline", c.textContent = l, c.setAttribute("data-patch-id", t.id), c;
|
|
647
662
|
}, { side: 1 })
|
|
@@ -653,8 +668,8 @@ function ma(e = "default") {
|
|
|
653
668
|
key: jt,
|
|
654
669
|
props: {
|
|
655
670
|
decorations(t) {
|
|
656
|
-
const n = (
|
|
657
|
-
if (n.length === 0) return
|
|
671
|
+
const n = (G.get(e) || []).filter((a) => a.status === "pending");
|
|
672
|
+
if (n.length === 0) return de.empty;
|
|
658
673
|
const r = [];
|
|
659
674
|
for (const a of n) {
|
|
660
675
|
if (a.type === "replace") {
|
|
@@ -668,7 +683,7 @@ function ma(e = "default") {
|
|
|
668
683
|
const i = da(t.doc, a.from, a.to);
|
|
669
684
|
for (const s of i)
|
|
670
685
|
r.push(
|
|
671
|
-
|
|
686
|
+
ae.inline(s.from, s.to, {
|
|
672
687
|
class: "patch-diff-delete",
|
|
673
688
|
"data-patch-id": a.id
|
|
674
689
|
})
|
|
@@ -677,7 +692,7 @@ function ma(e = "default") {
|
|
|
677
692
|
const s = i.length > 0 ? i[i.length - 1].to : a.to, o = a.content.length > 120 || a.content.includes(`
|
|
678
693
|
`);
|
|
679
694
|
r.push(
|
|
680
|
-
|
|
695
|
+
ae.widget(s, () => {
|
|
681
696
|
const l = document.createElement(o ? "div" : "span");
|
|
682
697
|
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;
|
|
683
698
|
}, { side: 1 })
|
|
@@ -685,13 +700,13 @@ function ma(e = "default") {
|
|
|
685
700
|
}
|
|
686
701
|
} else
|
|
687
702
|
r.push(
|
|
688
|
-
|
|
703
|
+
ae.widget(a.from, () => {
|
|
689
704
|
const i = document.createElement("span");
|
|
690
705
|
return i.className = "patch-diff-insert-inline", i.textContent = a.content, i.setAttribute("data-patch-id", a.id), i;
|
|
691
706
|
})
|
|
692
707
|
);
|
|
693
708
|
}
|
|
694
|
-
return
|
|
709
|
+
return de.create(t.doc, r);
|
|
695
710
|
}
|
|
696
711
|
}
|
|
697
712
|
});
|
|
@@ -711,7 +726,7 @@ function Jt(e, t) {
|
|
|
711
726
|
);
|
|
712
727
|
});
|
|
713
728
|
}
|
|
714
|
-
const ga =
|
|
729
|
+
const ga = Q.create({
|
|
715
730
|
name: "hardBreak",
|
|
716
731
|
inline: !0,
|
|
717
732
|
group: "inline",
|
|
@@ -753,8 +768,8 @@ const ga = Z.create({
|
|
|
753
768
|
}
|
|
754
769
|
}), ha = [
|
|
755
770
|
An,
|
|
756
|
-
Ln,
|
|
757
771
|
Pn,
|
|
772
|
+
Ln,
|
|
758
773
|
fa,
|
|
759
774
|
Dn.configure({
|
|
760
775
|
levels: [1, 2, 3, 4, 5, 6]
|
|
@@ -845,7 +860,7 @@ class va {
|
|
|
845
860
|
return !r || !r.isActive ? !1 : r.isActive(n);
|
|
846
861
|
}
|
|
847
862
|
async execute(t, n, r, a = {}) {
|
|
848
|
-
var d,
|
|
863
|
+
var d, m, g, h;
|
|
849
864
|
const i = Date.now(), s = a.transaction ?? !0, o = a.rollbackOnFail ?? !0, l = s ? n.editor.getJSON() : null, c = this.commands.get(t);
|
|
850
865
|
if (!c)
|
|
851
866
|
return console.warn(`Command "${t}" not found.`), (d = a.onComplete) == null || d.call(a, {
|
|
@@ -854,7 +869,7 @@ class va {
|
|
|
854
869
|
durationMs: Date.now() - i
|
|
855
870
|
}), !1;
|
|
856
871
|
if (!this.canExecute(t, n, r))
|
|
857
|
-
return (
|
|
872
|
+
return (m = a.onComplete) == null || m.call(a, {
|
|
858
873
|
name: t,
|
|
859
874
|
success: !1,
|
|
860
875
|
durationMs: Date.now() - i
|
|
@@ -867,16 +882,16 @@ class va {
|
|
|
867
882
|
success: b,
|
|
868
883
|
durationMs: Date.now() - i
|
|
869
884
|
};
|
|
870
|
-
return (
|
|
871
|
-
} catch (
|
|
885
|
+
return (g = a.onComplete) == null || g.call(a, y), b;
|
|
886
|
+
} catch (p) {
|
|
872
887
|
l && o && n.editor.commands.setContent(l);
|
|
873
888
|
const b = {
|
|
874
889
|
name: t,
|
|
875
890
|
success: !1,
|
|
876
891
|
durationMs: Date.now() - i,
|
|
877
|
-
error:
|
|
892
|
+
error: p
|
|
878
893
|
};
|
|
879
|
-
return (
|
|
894
|
+
return (h = a.onComplete) == null || h.call(a, b), !1;
|
|
880
895
|
}
|
|
881
896
|
}
|
|
882
897
|
getCommand(t) {
|
|
@@ -1225,7 +1240,7 @@ const Ie = () => {
|
|
|
1225
1240
|
document.querySelectorAll('body > svg[id^="standalone-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
|
|
1226
1241
|
(e.id.startsWith("dmermaid") || e.id.startsWith("dstandalone")) && e.remove();
|
|
1227
1242
|
}), 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());
|
|
1228
|
-
}, xa =
|
|
1243
|
+
}, xa = Q.create({
|
|
1229
1244
|
name: "mermaid",
|
|
1230
1245
|
group: "block",
|
|
1231
1246
|
atom: !0,
|
|
@@ -1255,30 +1270,30 @@ const Ie = () => {
|
|
|
1255
1270
|
c.className = "mermaid-edit";
|
|
1256
1271
|
const d = document.createElement("textarea");
|
|
1257
1272
|
d.className = "mermaid-editor-textarea", d.spellcheck = !1;
|
|
1258
|
-
const
|
|
1259
|
-
|
|
1260
|
-
const
|
|
1261
|
-
|
|
1262
|
-
const p = document.createElement("button");
|
|
1263
|
-
p.className = "mermaid-cancel-btn", p.type = "button";
|
|
1273
|
+
const m = document.createElement("div");
|
|
1274
|
+
m.className = "mermaid-edit-toolbar";
|
|
1275
|
+
const g = document.createElement("span");
|
|
1276
|
+
g.className = "mermaid-error-msg";
|
|
1264
1277
|
const h = document.createElement("button");
|
|
1265
|
-
h.className = "mermaid-
|
|
1266
|
-
const
|
|
1278
|
+
h.className = "mermaid-cancel-btn", h.type = "button";
|
|
1279
|
+
const p = document.createElement("button");
|
|
1280
|
+
p.className = "mermaid-save-btn", p.type = "button", m.append(g, h, p), c.append(d, m), i.append(s, c);
|
|
1281
|
+
const b = (v) => {
|
|
1267
1282
|
const _ = typeof n == "function" ? n() : null;
|
|
1268
|
-
typeof _ == "number" && e.commands.command(({ tr:
|
|
1283
|
+
typeof _ == "number" && e.commands.command(({ tr: N, dispatch: D }) => (N.setNodeMarkup(_, void 0, { ...r.attrs, ...v }), D && D(N), !0));
|
|
1269
1284
|
};
|
|
1270
1285
|
let y = "";
|
|
1271
|
-
const w = async (
|
|
1272
|
-
const _ =
|
|
1286
|
+
const w = async (v) => {
|
|
1287
|
+
const _ = v.trim();
|
|
1273
1288
|
if (_ !== y) {
|
|
1274
1289
|
if (!_) {
|
|
1275
1290
|
o.innerHTML = "", y = "";
|
|
1276
1291
|
return;
|
|
1277
1292
|
}
|
|
1278
1293
|
try {
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1281
|
-
const D = `standalone-mermaid-${_e}`, { svg: z } = await
|
|
1294
|
+
const N = await import("mermaid");
|
|
1295
|
+
N.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
|
|
1296
|
+
const D = `standalone-mermaid-${_e}`, { svg: z } = await N.default.render(D, _);
|
|
1282
1297
|
o.innerHTML = z, y = _;
|
|
1283
1298
|
} catch {
|
|
1284
1299
|
o.innerHTML = "", y = "";
|
|
@@ -1287,54 +1302,54 @@ const Ie = () => {
|
|
|
1287
1302
|
}
|
|
1288
1303
|
}
|
|
1289
1304
|
}, T = () => {
|
|
1290
|
-
a || (a = !0, d.value = typeof r.attrs.code == "string" ? r.attrs.code : "",
|
|
1291
|
-
},
|
|
1305
|
+
a || (a = !0, d.value = typeof r.attrs.code == "string" ? r.attrs.code : "", g.textContent = "", g.style.display = "none", S(), requestAnimationFrame(() => d.focus()));
|
|
1306
|
+
}, C = () => {
|
|
1292
1307
|
a = !1, S();
|
|
1293
1308
|
}, x = async () => {
|
|
1294
|
-
const
|
|
1295
|
-
|
|
1296
|
-
const _ =
|
|
1309
|
+
const v = d.value;
|
|
1310
|
+
g.textContent = "", g.style.display = "none";
|
|
1311
|
+
const _ = v.trim();
|
|
1297
1312
|
if (_)
|
|
1298
1313
|
try {
|
|
1299
|
-
const
|
|
1300
|
-
|
|
1301
|
-
const D = `standalone-mermaid-${_e}`, { svg: z } = await
|
|
1314
|
+
const N = await import("mermaid");
|
|
1315
|
+
N.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
|
|
1316
|
+
const D = `standalone-mermaid-${_e}`, { svg: z } = await N.default.render(D, _);
|
|
1302
1317
|
o.innerHTML = z, y = _, Ie();
|
|
1303
1318
|
} catch {
|
|
1304
1319
|
Ie();
|
|
1305
|
-
const
|
|
1306
|
-
|
|
1320
|
+
const N = I.getState().editorLanguage;
|
|
1321
|
+
g.textContent = N === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", g.style.display = "inline";
|
|
1307
1322
|
return;
|
|
1308
1323
|
}
|
|
1309
|
-
b({ code:
|
|
1324
|
+
b({ code: v }), a = !1, S();
|
|
1310
1325
|
};
|
|
1311
|
-
s.addEventListener("dblclick", (
|
|
1312
|
-
|
|
1313
|
-
}),
|
|
1314
|
-
|
|
1315
|
-
}),
|
|
1316
|
-
|
|
1317
|
-
}), d.addEventListener("mousedown", (
|
|
1326
|
+
s.addEventListener("dblclick", (v) => {
|
|
1327
|
+
v.preventDefault(), v.stopPropagation(), T();
|
|
1328
|
+
}), p.addEventListener("click", (v) => {
|
|
1329
|
+
v.stopPropagation(), x();
|
|
1330
|
+
}), h.addEventListener("click", (v) => {
|
|
1331
|
+
v.stopPropagation(), C();
|
|
1332
|
+
}), d.addEventListener("mousedown", (v) => v.stopPropagation()), d.addEventListener("keydown", (v) => v.stopPropagation()), d.addEventListener("keypress", (v) => v.stopPropagation());
|
|
1318
1333
|
const S = () => {
|
|
1319
|
-
const
|
|
1320
|
-
s.style.display = a ? "none" : "block", c.style.display = a ? "block" : "none",
|
|
1321
|
-
const D =
|
|
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 &&
|
|
1334
|
+
const v = I.getState().editorLanguage, _ = H(v), N = typeof r.attrs.code == "string" ? r.attrs.code : "";
|
|
1335
|
+
s.style.display = a ? "none" : "block", c.style.display = a ? "block" : "none", p.textContent = _.mermaidSaveAndRender || "保存并渲染", h.textContent = _.mermaidCancel || "取消";
|
|
1336
|
+
const D = N.trim().length > 0, z = o.querySelector("svg") !== null;
|
|
1337
|
+
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 && N.trim() !== y && w(N);
|
|
1323
1338
|
};
|
|
1324
|
-
let
|
|
1325
|
-
const
|
|
1326
|
-
|
|
1339
|
+
let A = I.getState().editorLanguage;
|
|
1340
|
+
const u = I.subscribe((v) => {
|
|
1341
|
+
v.editorLanguage !== A && (A = v.editorLanguage, S());
|
|
1327
1342
|
});
|
|
1328
1343
|
return S(), {
|
|
1329
1344
|
dom: i,
|
|
1330
|
-
stopEvent: (
|
|
1331
|
-
const _ =
|
|
1345
|
+
stopEvent: (v) => {
|
|
1346
|
+
const _ = v.target;
|
|
1332
1347
|
return !!(_ === d || c.contains(_));
|
|
1333
1348
|
},
|
|
1334
1349
|
ignoreMutation: () => !0,
|
|
1335
|
-
update: (
|
|
1350
|
+
update: (v) => v.type.name !== "mermaid" ? !1 : (r = v, S(), !0),
|
|
1336
1351
|
destroy: () => {
|
|
1337
|
-
|
|
1352
|
+
u(), Ie();
|
|
1338
1353
|
}
|
|
1339
1354
|
};
|
|
1340
1355
|
};
|
|
@@ -1367,7 +1382,7 @@ const Ie = () => {
|
|
|
1367
1382
|
}
|
|
1368
1383
|
}
|
|
1369
1384
|
}
|
|
1370
|
-
}, Ve = "https://draw.goatpatent.com", Ta =
|
|
1385
|
+
}, Ve = "https://draw.goatpatent.com", Ta = Q.create({
|
|
1371
1386
|
name: "drawio",
|
|
1372
1387
|
group: "block",
|
|
1373
1388
|
atom: !0,
|
|
@@ -1395,59 +1410,59 @@ const Ie = () => {
|
|
|
1395
1410
|
const l = document.createElement("div");
|
|
1396
1411
|
l.className = "drawio-view-hint", s.append(o, l), i.append(s);
|
|
1397
1412
|
const c = (T) => {
|
|
1398
|
-
const
|
|
1399
|
-
typeof
|
|
1413
|
+
const C = typeof n == "function" ? n() : null;
|
|
1414
|
+
typeof C == "number" && e.commands.command(({ tr: x, dispatch: S }) => (x.setNodeMarkup(C, void 0, { ...r.attrs, ...T }), S && S(x), !0));
|
|
1400
1415
|
};
|
|
1401
|
-
let d = null,
|
|
1402
|
-
const
|
|
1416
|
+
let d = null, m = null, g = null;
|
|
1417
|
+
const h = () => {
|
|
1403
1418
|
if (a) return;
|
|
1404
|
-
a = !0,
|
|
1419
|
+
a = !0, m = document.createElement("div"), m.className = "drawio-modal-overlay";
|
|
1405
1420
|
const T = document.createElement("div");
|
|
1406
1421
|
T.className = "drawio-modal-content";
|
|
1407
|
-
const
|
|
1408
|
-
|
|
1422
|
+
const C = document.createElement("div");
|
|
1423
|
+
C.className = "drawio-modal-header";
|
|
1409
1424
|
const x = I.getState().editorLanguage, S = document.createElement("span");
|
|
1410
1425
|
S.textContent = x === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", S.className = "drawio-modal-title";
|
|
1411
|
-
const
|
|
1412
|
-
|
|
1413
|
-
const
|
|
1414
|
-
|
|
1415
|
-
const
|
|
1426
|
+
const A = document.createElement("button");
|
|
1427
|
+
A.className = "drawio-modal-close-btn", A.textContent = "✕", A.type = "button", A.addEventListener("click", () => p()), C.append(S, A), g = document.createElement("iframe"), g.className = "drawio-modal-iframe", g.setAttribute("frameborder", "0"), T.append(C, g), m.appendChild(T), document.body.appendChild(m);
|
|
1428
|
+
const u = x === "en" ? "en" : "zh";
|
|
1429
|
+
g.src = `${Ve}/?embed=1&proto=json&spin=1&lang=${u}`;
|
|
1430
|
+
const v = g;
|
|
1416
1431
|
d = (_) => {
|
|
1417
1432
|
var D, z;
|
|
1418
|
-
if (!
|
|
1419
|
-
let
|
|
1433
|
+
if (!v || _.source !== v.contentWindow) return;
|
|
1434
|
+
let N;
|
|
1420
1435
|
try {
|
|
1421
|
-
|
|
1436
|
+
N = typeof _.data == "string" ? JSON.parse(_.data) : _.data;
|
|
1422
1437
|
} catch {
|
|
1423
1438
|
return;
|
|
1424
1439
|
}
|
|
1425
|
-
if (
|
|
1426
|
-
const
|
|
1427
|
-
(D =
|
|
1428
|
-
JSON.stringify({ action: "load", autosave: 0, xml:
|
|
1440
|
+
if (N.event === "init") {
|
|
1441
|
+
const ee = typeof r.attrs.xml == "string" ? r.attrs.xml : "";
|
|
1442
|
+
(D = v.contentWindow) == null || D.postMessage(
|
|
1443
|
+
JSON.stringify({ action: "load", autosave: 0, xml: ee || "" }),
|
|
1429
1444
|
Ve
|
|
1430
1445
|
);
|
|
1431
|
-
} else if (
|
|
1432
|
-
const
|
|
1433
|
-
(z =
|
|
1446
|
+
} else if (N.event === "save") {
|
|
1447
|
+
const ee = N.xml || "";
|
|
1448
|
+
(z = v.contentWindow) == null || z.postMessage(
|
|
1434
1449
|
JSON.stringify({ action: "export", format: "svg" }),
|
|
1435
1450
|
Ve
|
|
1436
|
-
), c({ xml:
|
|
1437
|
-
} else if (
|
|
1438
|
-
const
|
|
1439
|
-
c({ svg:
|
|
1440
|
-
} else
|
|
1451
|
+
), c({ xml: ee });
|
|
1452
|
+
} else if (N.event === "export") {
|
|
1453
|
+
const ee = N.data || "";
|
|
1454
|
+
c({ svg: ee }), p();
|
|
1455
|
+
} else N.event === "exit" && p();
|
|
1441
1456
|
}, window.addEventListener("message", d);
|
|
1442
|
-
},
|
|
1443
|
-
a = !1, d && (window.removeEventListener("message", d), d = null),
|
|
1457
|
+
}, p = () => {
|
|
1458
|
+
a = !1, d && (window.removeEventListener("message", d), d = null), g && (g.src = "about:blank", g = null), m && (m.remove(), m = null), b();
|
|
1444
1459
|
};
|
|
1445
1460
|
s.addEventListener("dblclick", (T) => {
|
|
1446
|
-
T.preventDefault(), T.stopPropagation(),
|
|
1461
|
+
T.preventDefault(), T.stopPropagation(), h();
|
|
1447
1462
|
});
|
|
1448
1463
|
const b = () => {
|
|
1449
|
-
const T = I.getState().editorLanguage,
|
|
1450
|
-
x ? (o.src = x, o.style.display = "block") : (o.src = "", o.style.display = "none"), x ? (l.textContent =
|
|
1464
|
+
const T = I.getState().editorLanguage, C = H(T), x = typeof r.attrs.svg == "string" ? r.attrs.svg : "";
|
|
1465
|
+
x ? (o.src = x, o.style.display = "block") : (o.src = "", o.style.display = "none"), x ? (l.textContent = C.mermaidDoubleClickToEdit || "双击编辑", l.className = "drawio-view-hint drawio-view-hint--subtle") : (l.textContent = C.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", l.className = "drawio-view-hint drawio-view-hint--empty");
|
|
1451
1466
|
};
|
|
1452
1467
|
let y = I.getState().editorLanguage;
|
|
1453
1468
|
const w = I.subscribe((T) => {
|
|
@@ -1458,7 +1473,7 @@ const Ie = () => {
|
|
|
1458
1473
|
ignoreMutation: () => !0,
|
|
1459
1474
|
update: (T) => T.type.name !== "drawio" ? !1 : (r = T, b(), !0),
|
|
1460
1475
|
destroy: () => {
|
|
1461
|
-
w(), d && (window.removeEventListener("message", d), d = null),
|
|
1476
|
+
w(), d && (window.removeEventListener("message", d), d = null), g && (g.src = "about:blank", g = null), m && (m.remove(), m = null);
|
|
1462
1477
|
}
|
|
1463
1478
|
};
|
|
1464
1479
|
};
|
|
@@ -1497,79 +1512,79 @@ const Ie = () => {
|
|
|
1497
1512
|
selected: n,
|
|
1498
1513
|
editor: r
|
|
1499
1514
|
}) => {
|
|
1500
|
-
const a = W(null), [i, s] =
|
|
1501
|
-
|
|
1515
|
+
const a = W(null), [i, s] = M(!1), o = e.type.name === "math_block", l = W(!1), c = W(t), d = W(e.attrs.latex ?? "");
|
|
1516
|
+
F(() => {
|
|
1502
1517
|
c.current = t;
|
|
1503
|
-
}, [t]),
|
|
1518
|
+
}, [t]), F(() => {
|
|
1504
1519
|
d.current = e.attrs.latex ?? "";
|
|
1505
1520
|
}, [e.attrs.latex]);
|
|
1506
|
-
const
|
|
1521
|
+
const m = j(() => {
|
|
1507
1522
|
l.current || (l.current = !0, s(!0));
|
|
1508
|
-
}, []),
|
|
1523
|
+
}, []), g = j(() => {
|
|
1509
1524
|
var b, y;
|
|
1510
1525
|
if (!l.current) return;
|
|
1511
1526
|
l.current = !1;
|
|
1512
|
-
const
|
|
1513
|
-
c.current({ latex:
|
|
1527
|
+
const p = ((b = a.current) == null ? void 0 : b.value) ?? d.current;
|
|
1528
|
+
c.current({ latex: p }), s(!1), (y = globalThis.mathVirtualKeyboard) == null || y.hide({ animate: !0 });
|
|
1514
1529
|
}, []);
|
|
1515
|
-
|
|
1530
|
+
F(() => {
|
|
1516
1531
|
var b, y, w;
|
|
1517
|
-
const
|
|
1518
|
-
n &&
|
|
1519
|
-
}, [n,
|
|
1532
|
+
const p = !!((w = (y = (b = r == null ? void 0 : r.view) == null ? void 0 : b.state) == null ? void 0 : y.selection) != null && w.empty);
|
|
1533
|
+
n && p && m();
|
|
1534
|
+
}, [n, m]), F(() => {
|
|
1520
1535
|
i && requestAnimationFrame(() => {
|
|
1521
1536
|
var b;
|
|
1522
|
-
const
|
|
1523
|
-
|
|
1537
|
+
const p = a.current;
|
|
1538
|
+
p && (p.virtualKeyboardMode = "onfocus", (b = p.focus) == null || b.call(p));
|
|
1524
1539
|
});
|
|
1525
|
-
}, [i]),
|
|
1540
|
+
}, [i]), F(() => {
|
|
1526
1541
|
if (!i) return;
|
|
1527
|
-
const
|
|
1528
|
-
if (!
|
|
1542
|
+
const p = a.current;
|
|
1543
|
+
if (!p) return;
|
|
1529
1544
|
const b = () => {
|
|
1530
1545
|
setTimeout(() => {
|
|
1531
|
-
var T,
|
|
1546
|
+
var T, C, x;
|
|
1532
1547
|
if (!l.current) return;
|
|
1533
1548
|
const w = document.activeElement;
|
|
1534
|
-
(w == null ? void 0 : w.tagName) === "MATH-FIELD" || (T = w == null ? void 0 : w.closest) != null && T.call(w, "math-field") || (
|
|
1549
|
+
(w == null ? void 0 : w.tagName) === "MATH-FIELD" || (T = w == null ? void 0 : w.closest) != null && T.call(w, "math-field") || (C = w == null ? void 0 : w.closest) != null && C.call(w, ".ML__keyboard") || (x = document.querySelector(".ML__keyboard")) != null && x.contains(w) || g();
|
|
1535
1550
|
}, 300);
|
|
1536
1551
|
}, y = (w) => {
|
|
1537
|
-
w.key === "Escape" &&
|
|
1552
|
+
w.key === "Escape" && g();
|
|
1538
1553
|
};
|
|
1539
|
-
return
|
|
1540
|
-
|
|
1554
|
+
return p.addEventListener("focusout", b), p.addEventListener("keydown", y), () => {
|
|
1555
|
+
p.removeEventListener("focusout", b), p.removeEventListener("keydown", y);
|
|
1541
1556
|
};
|
|
1542
|
-
}, [i,
|
|
1557
|
+
}, [i, g]), F(() => {
|
|
1543
1558
|
!i && a.current && a.current.value !== e.attrs.latex && (a.current.value = e.attrs.latex ?? "");
|
|
1544
1559
|
}, [e.attrs.latex, i]);
|
|
1545
|
-
let
|
|
1560
|
+
let h = "";
|
|
1546
1561
|
try {
|
|
1547
|
-
|
|
1562
|
+
h = gr.renderToString(e.attrs.latex || "", {
|
|
1548
1563
|
throwOnError: !1,
|
|
1549
1564
|
displayMode: o
|
|
1550
1565
|
});
|
|
1551
1566
|
} catch {
|
|
1552
|
-
|
|
1567
|
+
h = e.attrs.latex || "";
|
|
1553
1568
|
}
|
|
1554
|
-
return /* @__PURE__ */
|
|
1569
|
+
return /* @__PURE__ */ f(
|
|
1555
1570
|
_n,
|
|
1556
1571
|
{
|
|
1557
1572
|
as: o ? "div" : "span",
|
|
1558
1573
|
className: o ? "math-block" : "math-inline",
|
|
1559
|
-
children: i ? /* @__PURE__ */
|
|
1574
|
+
children: i ? /* @__PURE__ */ f(
|
|
1560
1575
|
"math-field",
|
|
1561
1576
|
{
|
|
1562
1577
|
ref: a,
|
|
1563
1578
|
className: o ? "math-live-field math-live-field--block" : "math-live-field",
|
|
1564
1579
|
children: e.attrs.latex
|
|
1565
1580
|
}
|
|
1566
|
-
) : /* @__PURE__ */
|
|
1567
|
-
/* @__PURE__ */
|
|
1568
|
-
/* @__PURE__ */
|
|
1581
|
+
) : /* @__PURE__ */ P("span", { className: "math-preview", onClick: m, children: [
|
|
1582
|
+
/* @__PURE__ */ f("span", { dangerouslySetInnerHTML: { __html: h } }),
|
|
1583
|
+
/* @__PURE__ */ f("span", { className: "math-tooltip", children: "点击编辑" })
|
|
1569
1584
|
] })
|
|
1570
1585
|
}
|
|
1571
1586
|
);
|
|
1572
|
-
}, Ea =
|
|
1587
|
+
}, Ea = Q.create({
|
|
1573
1588
|
name: "math_inline",
|
|
1574
1589
|
group: "inline",
|
|
1575
1590
|
inline: !0,
|
|
@@ -1595,14 +1610,14 @@ const Ie = () => {
|
|
|
1595
1610
|
return ["span", ie(e, { "data-type": "math_inline" })];
|
|
1596
1611
|
},
|
|
1597
1612
|
addNodeView() {
|
|
1598
|
-
return
|
|
1613
|
+
return Pt(Kt, {
|
|
1599
1614
|
stopEvent: ({ event: e }) => {
|
|
1600
1615
|
const t = e.target;
|
|
1601
1616
|
return t.tagName.toLowerCase() === "math-field" || t.closest("math-field") !== null;
|
|
1602
1617
|
}
|
|
1603
1618
|
});
|
|
1604
1619
|
}
|
|
1605
|
-
}), ka =
|
|
1620
|
+
}), ka = Q.create({
|
|
1606
1621
|
name: "math_block",
|
|
1607
1622
|
group: "block",
|
|
1608
1623
|
atom: !0,
|
|
@@ -1618,7 +1633,7 @@ const Ie = () => {
|
|
|
1618
1633
|
return ["div", ie(e, { "data-type": "math_block" })];
|
|
1619
1634
|
},
|
|
1620
1635
|
addNodeView() {
|
|
1621
|
-
return
|
|
1636
|
+
return Pt(Kt, {
|
|
1622
1637
|
stopEvent: ({ event: e }) => {
|
|
1623
1638
|
const t = e.target;
|
|
1624
1639
|
return t.tagName.toLowerCase() === "math-field" || t.closest("math-field") !== null;
|
|
@@ -1738,7 +1753,7 @@ const Ie = () => {
|
|
|
1738
1753
|
const c = fr(l, n, t.attrs);
|
|
1739
1754
|
return c ? (r.wrap(l, c), i && i(r.scrollIntoView()), s <= o) : !1;
|
|
1740
1755
|
}) : !1;
|
|
1741
|
-
},
|
|
1756
|
+
}, Pa = (e, t) => {
|
|
1742
1757
|
if (t.length === 0)
|
|
1743
1758
|
return !1;
|
|
1744
1759
|
const n = e.getJSON();
|
|
@@ -1746,15 +1761,15 @@ const Ie = () => {
|
|
|
1746
1761
|
if (!(r.type === "insertNode" ? Yt(e, r.payload) : r.type === "updateNodeAttrs" ? ze(e, r.payload) : r.type === "removeNode" ? Zt(e, r.payload) : Qt(e, r.payload)))
|
|
1747
1762
|
return e.commands.setContent(n), !1;
|
|
1748
1763
|
return !0;
|
|
1749
|
-
},
|
|
1764
|
+
}, ue = "https://draw.goatpatent.com";
|
|
1750
1765
|
let Ne = 0;
|
|
1751
1766
|
const Qe = [];
|
|
1752
1767
|
let Ae = !1;
|
|
1753
|
-
const
|
|
1754
|
-
let $ = null, Me = !1,
|
|
1768
|
+
const La = 2e4, bt = 6e4;
|
|
1769
|
+
let $ = null, Me = !1, re = null, he = null;
|
|
1755
1770
|
const et = /* @__PURE__ */ new Map();
|
|
1756
1771
|
function vt() {
|
|
1757
|
-
|
|
1772
|
+
re && (window.removeEventListener("message", re), re = null), $ && ($.src = "about:blank", $.remove(), $ = null), Me = !1;
|
|
1758
1773
|
}
|
|
1759
1774
|
function Da(e, t) {
|
|
1760
1775
|
const n = et.get(e);
|
|
@@ -1766,24 +1781,24 @@ function Da(e, t) {
|
|
|
1766
1781
|
}
|
|
1767
1782
|
function tt() {
|
|
1768
1783
|
if (Ae || Qe.length === 0) return;
|
|
1769
|
-
Ae = !0,
|
|
1784
|
+
Ae = !0, he && (clearTimeout(he), he = null);
|
|
1770
1785
|
const { xml: e, callback: t } = Qe.shift(), n = et.get(e);
|
|
1771
1786
|
if (n) {
|
|
1772
|
-
t(n), Ae = !1,
|
|
1787
|
+
t(n), Ae = !1, he = setTimeout(vt, bt), tt();
|
|
1773
1788
|
return;
|
|
1774
1789
|
}
|
|
1775
|
-
|
|
1790
|
+
re && (window.removeEventListener("message", re), re = null);
|
|
1776
1791
|
let r = null;
|
|
1777
1792
|
const a = (s) => {
|
|
1778
|
-
r && (clearTimeout(r), r = null), s && et.set(e, s), t(s), Ae = !1,
|
|
1793
|
+
r && (clearTimeout(r), r = null), s && et.set(e, s), t(s), Ae = !1, he = setTimeout(vt, bt), tt();
|
|
1779
1794
|
}, i = () => {
|
|
1780
1795
|
var s;
|
|
1781
1796
|
(s = $.contentWindow) == null || s.postMessage(
|
|
1782
1797
|
JSON.stringify({ action: "load", autosave: 0, xml: e || "" }),
|
|
1783
|
-
|
|
1798
|
+
ue
|
|
1784
1799
|
);
|
|
1785
1800
|
};
|
|
1786
|
-
|
|
1801
|
+
re = (s) => {
|
|
1787
1802
|
if (!$ || s.source !== $.contentWindow) return;
|
|
1788
1803
|
let o;
|
|
1789
1804
|
try {
|
|
@@ -1795,16 +1810,16 @@ function tt() {
|
|
|
1795
1810
|
var l;
|
|
1796
1811
|
(l = $ == null ? void 0 : $.contentWindow) == null || l.postMessage(
|
|
1797
1812
|
JSON.stringify({ action: "export", format: "svg" }),
|
|
1798
|
-
|
|
1813
|
+
ue
|
|
1799
1814
|
);
|
|
1800
1815
|
}, 1500) : o.event === "export" && a(o.data || "");
|
|
1801
|
-
}, window.addEventListener("message",
|
|
1816
|
+
}, window.addEventListener("message", re), r = setTimeout(() => a(""), La), $ ? Me && i() : ($ = document.createElement("iframe"), $.style.cssText = "position:fixed;left:-9999px;top:-9999px;width:1920px;height:1080px;opacity:0;pointer-events:none;", document.body.appendChild($), Me = !1, $.src = `${ue}/?embed=1&proto=json&spin=0&chrome=0`);
|
|
1802
1817
|
}
|
|
1803
|
-
const
|
|
1818
|
+
const Pe = () => {
|
|
1804
1819
|
document.querySelectorAll('body > svg[id^="fig-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
|
|
1805
1820
|
(e.id.startsWith("dmermaid") || e.id.startsWith("dfi")) && e.remove();
|
|
1806
1821
|
}), document.querySelectorAll("body > #dmermaid-svg").forEach((e) => e.remove()), document.querySelectorAll("body > style[data-mermaid-style]").forEach((e) => e.remove());
|
|
1807
|
-
}, Ra =
|
|
1822
|
+
}, Ra = Q.create({
|
|
1808
1823
|
name: "figure",
|
|
1809
1824
|
group: "block",
|
|
1810
1825
|
content: "inline*",
|
|
@@ -1843,209 +1858,209 @@ const Le = () => {
|
|
|
1843
1858
|
c.className = "figure-upload-area";
|
|
1844
1859
|
const d = document.createElement("span");
|
|
1845
1860
|
d.className = "figure-upload-hint";
|
|
1846
|
-
const
|
|
1847
|
-
|
|
1848
|
-
const
|
|
1849
|
-
|
|
1850
|
-
const p = document.createElement("div");
|
|
1851
|
-
p.className = "figure-mermaid-view", p.contentEditable = "false", p.setAttribute("spellcheck", "false");
|
|
1861
|
+
const m = document.createElement("input");
|
|
1862
|
+
m.type = "file", m.accept = "image/*", m.style.display = "none";
|
|
1863
|
+
const g = document.createElement("button");
|
|
1864
|
+
g.className = "figure-replace-btn", c.append(d, m);
|
|
1852
1865
|
const h = document.createElement("div");
|
|
1853
|
-
h.className = "figure-mermaid-
|
|
1866
|
+
h.className = "figure-mermaid-view", h.contentEditable = "false", h.setAttribute("spellcheck", "false");
|
|
1867
|
+
const p = document.createElement("div");
|
|
1868
|
+
p.className = "figure-mermaid-preview", p.contentEditable = "false";
|
|
1854
1869
|
const b = document.createElement("div");
|
|
1855
|
-
b.className = "figure-mermaid-view-hint",
|
|
1870
|
+
b.className = "figure-mermaid-view-hint", h.append(p, b);
|
|
1856
1871
|
const y = document.createElement("div");
|
|
1857
1872
|
y.className = "figure-mermaid-edit";
|
|
1858
1873
|
const w = document.createElement("textarea");
|
|
1859
1874
|
w.className = "figure-mermaid-editor", w.spellcheck = !1;
|
|
1860
1875
|
const T = document.createElement("div");
|
|
1861
1876
|
T.className = "figure-mermaid-toolbar";
|
|
1862
|
-
const
|
|
1863
|
-
|
|
1877
|
+
const C = document.createElement("button");
|
|
1878
|
+
C.className = "figure-mermaid-save-btn", C.type = "button";
|
|
1864
1879
|
const x = document.createElement("button");
|
|
1865
1880
|
x.className = "figure-mermaid-cancel-btn", x.type = "button";
|
|
1866
1881
|
const S = document.createElement("span");
|
|
1867
|
-
S.className = "figure-mermaid-error-inline", T.append(S, x,
|
|
1868
|
-
const
|
|
1869
|
-
|
|
1870
|
-
const
|
|
1871
|
-
|
|
1872
|
-
const
|
|
1873
|
-
|
|
1882
|
+
S.className = "figure-mermaid-error-inline", T.append(S, x, C), y.append(w, T);
|
|
1883
|
+
const A = document.createElement("div");
|
|
1884
|
+
A.className = "figure-drawio-view", A.contentEditable = "false";
|
|
1885
|
+
const u = document.createElement("img");
|
|
1886
|
+
u.className = "figure-drawio-preview-img", u.style.display = "none";
|
|
1887
|
+
const v = document.createElement("div");
|
|
1888
|
+
v.className = "figure-drawio-view-hint", A.append(u, v), o.append(l, c, g), o.append(h, y), o.append(A);
|
|
1874
1889
|
const _ = document.createElement("figcaption");
|
|
1875
1890
|
_.className = "figure-caption";
|
|
1876
|
-
const
|
|
1877
|
-
|
|
1891
|
+
const N = document.createElement("span");
|
|
1892
|
+
N.className = "figure-id-label", N.contentEditable = "false";
|
|
1878
1893
|
const D = document.createElement("span");
|
|
1879
|
-
D.className = "figure-caption-content", _.append(
|
|
1894
|
+
D.className = "figure-caption-content", _.append(N, D), s.append(o, _);
|
|
1880
1895
|
const z = (E) => {
|
|
1881
1896
|
const k = typeof n == "function" ? n() : null;
|
|
1882
|
-
typeof k == "number" && e.commands.command(({ tr:
|
|
1883
|
-
},
|
|
1897
|
+
typeof k == "number" && e.commands.command(({ tr: L, dispatch: O }) => (L.setNodeMarkup(k, void 0, { ...r.attrs, ...E }), O && O(L), !0));
|
|
1898
|
+
}, ee = (E) => {
|
|
1884
1899
|
if (!E || E.length === 0) return;
|
|
1885
1900
|
const k = E[0];
|
|
1886
1901
|
if (!k.type.startsWith("image/")) return;
|
|
1887
|
-
const
|
|
1888
|
-
|
|
1889
|
-
typeof
|
|
1890
|
-
},
|
|
1902
|
+
const L = new FileReader();
|
|
1903
|
+
L.onload = () => {
|
|
1904
|
+
typeof L.result == "string" && z({ imageSrc: L.result });
|
|
1905
|
+
}, L.readAsDataURL(k);
|
|
1891
1906
|
};
|
|
1892
|
-
|
|
1893
|
-
E.stopPropagation(),
|
|
1907
|
+
m.addEventListener("change", () => ee(m.files)), c.addEventListener("click", () => m.click()), g.addEventListener("click", (E) => {
|
|
1908
|
+
E.stopPropagation(), m.click();
|
|
1894
1909
|
}), o.addEventListener("dragover", (E) => {
|
|
1895
1910
|
r.attrs.contentType === "image" && (E.preventDefault(), E.stopPropagation(), c.classList.add("figure-upload-area--dragover"));
|
|
1896
1911
|
}), o.addEventListener("dragleave", () => {
|
|
1897
1912
|
c.classList.remove("figure-upload-area--dragover");
|
|
1898
1913
|
}), o.addEventListener("drop", (E) => {
|
|
1899
1914
|
var k;
|
|
1900
|
-
c.classList.remove("figure-upload-area--dragover"), r.attrs.contentType === "image" && (E.preventDefault(), E.stopPropagation(),
|
|
1915
|
+
c.classList.remove("figure-upload-area--dragover"), r.attrs.contentType === "image" && (E.preventDefault(), E.stopPropagation(), ee(((k = E.dataTransfer) == null ? void 0 : k.files) ?? null));
|
|
1901
1916
|
});
|
|
1902
1917
|
const gn = () => {
|
|
1903
|
-
a || (a = !0, w.value = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "", S.textContent = "", S.style.display = "none",
|
|
1918
|
+
a || (a = !0, w.value = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "", S.textContent = "", S.style.display = "none", K(), requestAnimationFrame(() => w.focus()));
|
|
1904
1919
|
}, fn = () => {
|
|
1905
|
-
a = !1,
|
|
1920
|
+
a = !1, K();
|
|
1906
1921
|
}, pn = async () => {
|
|
1907
1922
|
const E = w.value;
|
|
1908
1923
|
S.textContent = "", S.style.display = "none";
|
|
1909
1924
|
const k = E.trim();
|
|
1910
1925
|
if (k)
|
|
1911
1926
|
try {
|
|
1912
|
-
const
|
|
1913
|
-
|
|
1914
|
-
const O = `fig-mermaid-${Ne}`, { svg: R } = await
|
|
1915
|
-
|
|
1927
|
+
const L = await import("mermaid");
|
|
1928
|
+
L.default.initialize({ startOnLoad: !1, theme: "default" }), Ne += 1;
|
|
1929
|
+
const O = `fig-mermaid-${Ne}`, { svg: R } = await L.default.render(O, k);
|
|
1930
|
+
p.innerHTML = R, Pe();
|
|
1916
1931
|
} catch {
|
|
1917
|
-
|
|
1918
|
-
const
|
|
1919
|
-
S.textContent =
|
|
1932
|
+
Pe();
|
|
1933
|
+
const L = I.getState().editorLanguage;
|
|
1934
|
+
S.textContent = L === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", S.style.display = "inline";
|
|
1920
1935
|
return;
|
|
1921
1936
|
}
|
|
1922
|
-
z({ mermaidCode: E }), a = !1,
|
|
1937
|
+
z({ mermaidCode: E }), a = !1, K();
|
|
1923
1938
|
};
|
|
1924
|
-
|
|
1939
|
+
h.addEventListener("dblclick", (E) => {
|
|
1925
1940
|
E.preventDefault(), E.stopPropagation(), gn();
|
|
1926
|
-
}),
|
|
1941
|
+
}), C.addEventListener("click", (E) => {
|
|
1927
1942
|
E.stopPropagation(), pn();
|
|
1928
1943
|
}), x.addEventListener("click", (E) => {
|
|
1929
1944
|
E.stopPropagation(), fn();
|
|
1930
1945
|
}), w.addEventListener("mousedown", (E) => E.stopPropagation()), w.addEventListener("keydown", (E) => E.stopPropagation()), w.addEventListener("keypress", (E) => E.stopPropagation());
|
|
1931
|
-
let
|
|
1946
|
+
let te = null, V = null, U = null;
|
|
1932
1947
|
const hn = () => {
|
|
1933
1948
|
if (i) return;
|
|
1934
|
-
i = !0,
|
|
1949
|
+
i = !0, K(), V = document.createElement("div"), V.className = "drawio-modal-overlay";
|
|
1935
1950
|
const E = document.createElement("div");
|
|
1936
1951
|
E.className = "drawio-modal-content";
|
|
1937
1952
|
const k = document.createElement("div");
|
|
1938
1953
|
k.className = "drawio-modal-header";
|
|
1939
|
-
const
|
|
1940
|
-
|
|
1954
|
+
const L = document.createElement("span"), O = I.getState().editorLanguage;
|
|
1955
|
+
L.textContent = O === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", L.className = "drawio-modal-title";
|
|
1941
1956
|
const R = document.createElement("button");
|
|
1942
|
-
R.className = "drawio-modal-close-btn", R.textContent = "✕", R.type = "button", R.addEventListener("click", () => We()), k.append(
|
|
1943
|
-
const
|
|
1944
|
-
U.src = `${
|
|
1945
|
-
const
|
|
1946
|
-
|
|
1957
|
+
R.className = "drawio-modal-close-btn", R.textContent = "✕", R.type = "button", R.addEventListener("click", () => We()), k.append(L, R), U = document.createElement("iframe"), U.className = "drawio-modal-iframe", U.setAttribute("frameborder", "0"), E.append(k, U), V.appendChild(E), document.body.appendChild(V);
|
|
1958
|
+
const pe = O === "en" ? "en" : "zh";
|
|
1959
|
+
U.src = `${ue}/?embed=1&proto=json&spin=1&lang=${pe}`;
|
|
1960
|
+
const X = U;
|
|
1961
|
+
te = (Y) => {
|
|
1947
1962
|
var oe, Te;
|
|
1948
|
-
if (!
|
|
1963
|
+
if (!X || Y.source !== X.contentWindow) return;
|
|
1949
1964
|
let q;
|
|
1950
1965
|
try {
|
|
1951
|
-
q = typeof
|
|
1966
|
+
q = typeof Y.data == "string" ? JSON.parse(Y.data) : Y.data;
|
|
1952
1967
|
} catch {
|
|
1953
1968
|
return;
|
|
1954
1969
|
}
|
|
1955
1970
|
if (q.event === "init") {
|
|
1956
1971
|
const ce = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "";
|
|
1957
|
-
(oe =
|
|
1972
|
+
(oe = X.contentWindow) == null || oe.postMessage(
|
|
1958
1973
|
JSON.stringify({ action: "load", autosave: 0, xml: ce || "" }),
|
|
1959
|
-
|
|
1974
|
+
ue
|
|
1960
1975
|
);
|
|
1961
1976
|
} else if (q.event === "save") {
|
|
1962
1977
|
const ce = q.xml || "";
|
|
1963
|
-
(Te =
|
|
1978
|
+
(Te = X.contentWindow) == null || Te.postMessage(
|
|
1964
1979
|
JSON.stringify({ action: "export", format: "svg" }),
|
|
1965
|
-
|
|
1980
|
+
ue
|
|
1966
1981
|
), z({ drawioXml: ce });
|
|
1967
1982
|
} else if (q.event === "export") {
|
|
1968
1983
|
const ce = q.data || "";
|
|
1969
1984
|
z({ drawioSvg: ce }), We();
|
|
1970
1985
|
} else q.event === "exit" && We();
|
|
1971
|
-
}, window.addEventListener("message",
|
|
1986
|
+
}, window.addEventListener("message", te);
|
|
1972
1987
|
}, We = () => {
|
|
1973
|
-
i = !1,
|
|
1988
|
+
i = !1, te && (window.removeEventListener("message", te), te = null), U && (U.src = "about:blank", U = null), V && (V.remove(), V = null), K();
|
|
1974
1989
|
};
|
|
1975
|
-
|
|
1990
|
+
A.addEventListener("dblclick", (E) => {
|
|
1976
1991
|
E.preventDefault(), E.stopPropagation(), hn();
|
|
1977
1992
|
}), s.addEventListener("mousedown", (E) => {
|
|
1978
1993
|
const k = E.target;
|
|
1979
|
-
if (!(k instanceof HTMLElement) || k === D || D.contains(k) || k === w || y.contains(k) || k === c || c.contains(k) || k ===
|
|
1980
|
-
const
|
|
1981
|
-
if (typeof
|
|
1982
|
-
const O =
|
|
1994
|
+
if (!(k instanceof HTMLElement) || k === D || D.contains(k) || k === w || y.contains(k) || k === c || c.contains(k) || k === g || k === m || h.contains(k) || A.contains(k)) return;
|
|
1995
|
+
const L = typeof n == "function" ? n() : null;
|
|
1996
|
+
if (typeof L != "number") return;
|
|
1997
|
+
const O = L + r.nodeSize - 1, R = Zn.create(e.state.doc, O);
|
|
1983
1998
|
e.view.dispatch(e.state.tr.setSelection(R));
|
|
1984
1999
|
});
|
|
1985
|
-
let xe = !1, se = null,
|
|
2000
|
+
let xe = !1, se = null, ge = null, Ce = 0;
|
|
1986
2001
|
const yn = 2, bn = 1500, vn = 3e3;
|
|
1987
|
-
let
|
|
2002
|
+
let fe = "";
|
|
1988
2003
|
const wn = async (E) => {
|
|
1989
2004
|
const k = E.trim();
|
|
1990
|
-
if (k !==
|
|
2005
|
+
if (k !== fe) {
|
|
1991
2006
|
if (!k) {
|
|
1992
|
-
|
|
2007
|
+
p.innerHTML = "", fe = "";
|
|
1993
2008
|
return;
|
|
1994
2009
|
}
|
|
1995
2010
|
try {
|
|
1996
|
-
const
|
|
1997
|
-
|
|
1998
|
-
const O = `fig-mermaid-${Ne}`, { svg: R } = await
|
|
1999
|
-
|
|
2011
|
+
const L = await import("mermaid");
|
|
2012
|
+
L.default.initialize({ startOnLoad: !1, theme: "default" }), Ne += 1;
|
|
2013
|
+
const O = `fig-mermaid-${Ne}`, { svg: R } = await L.default.render(O, k);
|
|
2014
|
+
p.innerHTML = R, fe = k;
|
|
2000
2015
|
} catch {
|
|
2001
|
-
|
|
2016
|
+
p.innerHTML = "", fe = "";
|
|
2002
2017
|
} finally {
|
|
2003
|
-
|
|
2018
|
+
Pe();
|
|
2004
2019
|
}
|
|
2005
2020
|
}
|
|
2006
|
-
},
|
|
2007
|
-
const E = I.getState().editorLanguage, k = H(E),
|
|
2008
|
-
O ? (
|
|
2009
|
-
const
|
|
2010
|
-
l.style.display =
|
|
2021
|
+
}, K = () => {
|
|
2022
|
+
const E = I.getState().editorLanguage, k = H(E), L = ["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 : "", pe = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "";
|
|
2023
|
+
O ? (N.textContent = `[${O}] `, N.style.display = "inline") : (N.textContent = "", N.style.display = "none");
|
|
2024
|
+
const X = L === "image", Y = L === "mermaid", q = L === "drawio";
|
|
2025
|
+
l.style.display = X && R ? "block" : "none", c.style.display = X && !R ? "flex" : "none", g.style.display = X && R ? "block" : "none", h.style.display = Y && !a ? "block" : "none", y.style.display = Y && a ? "block" : "none", A.style.display = q ? "flex" : "none", X && R && (l.src = R);
|
|
2011
2026
|
const oe = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
|
|
2012
|
-
q && (oe ? (
|
|
2013
|
-
const Te =
|
|
2014
|
-
|
|
2027
|
+
q && (oe ? (u.src = oe, u.style.display = "block") : (u.src = "", u.style.display = "none")), d.textContent = k.figureUploadHint || "点击上传或拖拽图片", g.textContent = k.figureReplaceImage || "更换图片", C.textContent = k.mermaidSaveAndRender || "保存并渲染", x.textContent = k.mermaidCancel || "取消";
|
|
2028
|
+
const Te = pe.trim().length > 0, ce = p.querySelector("svg") !== null;
|
|
2029
|
+
Y && !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 ? (v.textContent = k.mermaidDoubleClickToEdit || "双击编辑", v.className = "figure-drawio-view-hint figure-mermaid-view-hint--subtle") : (v.textContent = k.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", v.className = "figure-drawio-view-hint figure-mermaid-view-hint--empty")), Y && !a && pe.trim() !== fe && wn(pe);
|
|
2015
2030
|
const Cn = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "";
|
|
2016
2031
|
q && Cn && !oe && !xe && !i && (se && clearTimeout(se), se = setTimeout(() => {
|
|
2017
2032
|
se = null;
|
|
2018
2033
|
const dt = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "", Tn = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
|
|
2019
2034
|
!dt || Tn || xe || (xe = !0, Da(dt, (ut) => {
|
|
2020
|
-
xe = !1, ut ? (Ce = 0, z({ drawioSvg: ut })) : Ce < yn && (Ce++,
|
|
2021
|
-
|
|
2035
|
+
xe = !1, ut ? (Ce = 0, z({ drawioSvg: ut })) : Ce < yn && (Ce++, ge = setTimeout(() => {
|
|
2036
|
+
ge = null, K();
|
|
2022
2037
|
}, vn * Ce));
|
|
2023
2038
|
}));
|
|
2024
2039
|
}, bn));
|
|
2025
2040
|
};
|
|
2026
2041
|
let lt = I.getState().editorLanguage;
|
|
2027
2042
|
const xn = I.subscribe((E) => {
|
|
2028
|
-
E.editorLanguage !== lt && (lt = E.editorLanguage,
|
|
2043
|
+
E.editorLanguage !== lt && (lt = E.editorLanguage, K());
|
|
2029
2044
|
});
|
|
2030
|
-
return
|
|
2045
|
+
return K(), {
|
|
2031
2046
|
dom: s,
|
|
2032
2047
|
contentDOM: D,
|
|
2033
2048
|
stopEvent: (E) => {
|
|
2034
2049
|
const k = E.target;
|
|
2035
|
-
return !!(k === w || y.contains(k) || k ===
|
|
2050
|
+
return !!(k === w || y.contains(k) || k === m);
|
|
2036
2051
|
},
|
|
2037
2052
|
ignoreMutation: (E) => {
|
|
2038
2053
|
const k = E.target;
|
|
2039
|
-
return !!(o.contains(k) ||
|
|
2054
|
+
return !!(o.contains(k) || N.contains(k));
|
|
2040
2055
|
},
|
|
2041
|
-
update: (E) => E.type.name !== "figure" ? !1 : (r = E,
|
|
2056
|
+
update: (E) => E.type.name !== "figure" ? !1 : (r = E, K(), !0),
|
|
2042
2057
|
destroy: () => {
|
|
2043
|
-
se && (clearTimeout(se), se = null),
|
|
2058
|
+
se && (clearTimeout(se), se = null), ge && (clearTimeout(ge), ge = null), xn(), Pe(), te && (window.removeEventListener("message", te), te = null), U && (U.src = "about:blank", U = null), V && (V.remove(), V = null);
|
|
2044
2059
|
}
|
|
2045
2060
|
};
|
|
2046
2061
|
};
|
|
2047
2062
|
}
|
|
2048
|
-
}), Ma =
|
|
2063
|
+
}), Ma = Q.create({
|
|
2049
2064
|
name: "reference",
|
|
2050
2065
|
group: "inline",
|
|
2051
2066
|
inline: !0,
|
|
@@ -2106,8 +2121,8 @@ const Le = () => {
|
|
|
2106
2121
|
return ({ node: e, editor: t }) => {
|
|
2107
2122
|
let n = e;
|
|
2108
2123
|
const r = document.createElement("span"), a = () => {
|
|
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 ?" : "权利要求?",
|
|
2110
|
-
r.textContent =
|
|
2124
|
+
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 ?" : "权利要求?", m = n.attrs.displayText || d;
|
|
2125
|
+
r.textContent = m, 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;
|
|
2111
2126
|
};
|
|
2112
2127
|
return a(), r.addEventListener("click", () => {
|
|
2113
2128
|
const i = n.attrs.targetType === "figure" ? "figure" : "claim";
|
|
@@ -2172,7 +2187,7 @@ const Le = () => {
|
|
|
2172
2187
|
return e.forEach((n) => {
|
|
2173
2188
|
!t && ot(n) && (t = !0);
|
|
2174
2189
|
}), t;
|
|
2175
|
-
}, za =
|
|
2190
|
+
}, za = Q.create({
|
|
2176
2191
|
name: "patent_title",
|
|
2177
2192
|
group: "block",
|
|
2178
2193
|
content: "inline*",
|
|
@@ -2214,28 +2229,28 @@ const Le = () => {
|
|
|
2214
2229
|
b !== null && (I.getState().openDraftingPanel("patent_title", b), e.commands.focus(b + 1));
|
|
2215
2230
|
};
|
|
2216
2231
|
s.addEventListener("click", d), o.addEventListener("focusin", c), o.addEventListener("click", c);
|
|
2217
|
-
const
|
|
2232
|
+
const m = () => {
|
|
2218
2233
|
const b = I.getState(), y = H(b.editorLanguage), w = typeof y.bookTitle_description == "string" ? y.bookTitle_description : "说明书", T = typeof y.patentTitlePlaceholder == "string" ? y.patentTitlePlaceholder : "专利名称";
|
|
2219
2234
|
i.textContent = w;
|
|
2220
|
-
const
|
|
2221
|
-
s.textContent = `[${T}]`, s.style.display =
|
|
2235
|
+
const C = ot(r), x = b.rightPanel.activeSectionPos === l();
|
|
2236
|
+
s.textContent = `[${T}]`, s.style.display = C ? "none" : "", s.classList.toggle("ps-placeholder--active", x && !C), o.classList.toggle("pt-title-content--has-content", C);
|
|
2222
2237
|
};
|
|
2223
|
-
let
|
|
2224
|
-
const
|
|
2225
|
-
const y = b.editorLanguage !==
|
|
2226
|
-
|
|
2238
|
+
let g = I.getState().editorLanguage, h = I.getState().rightPanel.activeSectionPos;
|
|
2239
|
+
const p = I.subscribe((b) => {
|
|
2240
|
+
const y = b.editorLanguage !== g, w = b.rightPanel.activeSectionPos !== h;
|
|
2241
|
+
g = b.editorLanguage, h = b.rightPanel.activeSectionPos, (y || w) && m();
|
|
2227
2242
|
});
|
|
2228
|
-
return
|
|
2243
|
+
return m(), {
|
|
2229
2244
|
dom: a,
|
|
2230
2245
|
contentDOM: o,
|
|
2231
|
-
update: (b) => b.type.name !== "patent_title" ? !1 : (r = b,
|
|
2246
|
+
update: (b) => b.type.name !== "patent_title" ? !1 : (r = b, m(), !0),
|
|
2232
2247
|
destroy: () => {
|
|
2233
|
-
|
|
2248
|
+
p(), s.removeEventListener("click", d), o.removeEventListener("focusin", c), o.removeEventListener("click", c);
|
|
2234
2249
|
}
|
|
2235
2250
|
};
|
|
2236
2251
|
};
|
|
2237
2252
|
}
|
|
2238
|
-
}), Oa =
|
|
2253
|
+
}), Oa = Q.create({
|
|
2239
2254
|
name: "patent_section",
|
|
2240
2255
|
group: "block",
|
|
2241
2256
|
content: "block+",
|
|
@@ -2313,27 +2328,27 @@ const Le = () => {
|
|
|
2313
2328
|
const y = c();
|
|
2314
2329
|
if (y === null) return;
|
|
2315
2330
|
I.getState().setActiveSection(r.attrs.sectionType, y);
|
|
2316
|
-
},
|
|
2331
|
+
}, m = () => {
|
|
2317
2332
|
const y = c();
|
|
2318
2333
|
if (y === null) return;
|
|
2319
2334
|
I.getState().openDraftingPanel(r.attrs.sectionType, y), e.commands.focus(y + 1);
|
|
2320
2335
|
};
|
|
2321
|
-
o.addEventListener("click",
|
|
2322
|
-
const
|
|
2323
|
-
const y = I.getState(), w = H(y.editorLanguage), T = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field",
|
|
2324
|
-
a.className = `ps${
|
|
2336
|
+
o.addEventListener("click", m), l.addEventListener("focusin", d), l.addEventListener("click", d);
|
|
2337
|
+
const g = () => {
|
|
2338
|
+
const y = I.getState(), w = H(y.editorLanguage), T = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", C = Fa.has(T), x = $a.has(T), S = wt[T], A = typeof w[S] == "string" ? w[S] : T, u = ot(r), v = y.rightPanel.activeSectionPos === c();
|
|
2339
|
+
a.className = `ps${u ? "" : " ps--empty"}${x ? " ps--sub" : ""}`, a.setAttribute("data-section-type", T), i.className = C ? "pb-heading" : "ps-heading ps-heading--sub", i.textContent = A, o.textContent = `[${A}]`, o.style.display = u ? "none" : "", o.classList.toggle("ps-placeholder--active", v && !u), l.classList.toggle("ps-content--has-content", u);
|
|
2325
2340
|
};
|
|
2326
|
-
let
|
|
2341
|
+
let h = I.getState().editorLanguage, p = I.getState().rightPanel.activeSectionPos;
|
|
2327
2342
|
const b = I.subscribe((y) => {
|
|
2328
|
-
const w = y.editorLanguage !==
|
|
2329
|
-
|
|
2343
|
+
const w = y.editorLanguage !== h, T = y.rightPanel.activeSectionPos !== p;
|
|
2344
|
+
h = y.editorLanguage, p = y.rightPanel.activeSectionPos, (w || T) && g();
|
|
2330
2345
|
});
|
|
2331
|
-
return
|
|
2346
|
+
return g(), {
|
|
2332
2347
|
dom: a,
|
|
2333
2348
|
contentDOM: l,
|
|
2334
|
-
update: (y) => y.type.name !== "patent_section" ? !1 : (r = y,
|
|
2349
|
+
update: (y) => y.type.name !== "patent_section" ? !1 : (r = y, g(), !0),
|
|
2335
2350
|
destroy: () => {
|
|
2336
|
-
b(), o.removeEventListener("click",
|
|
2351
|
+
b(), o.removeEventListener("click", m), l.removeEventListener("focusin", d), l.removeEventListener("click", d);
|
|
2337
2352
|
}
|
|
2338
2353
|
};
|
|
2339
2354
|
};
|
|
@@ -2380,10 +2395,10 @@ const Le = () => {
|
|
|
2380
2395
|
], ja = () => [
|
|
2381
2396
|
en(),
|
|
2382
2397
|
...qa.map(Fe)
|
|
2383
|
-
], tn = (e = "invention") => ({ type: "doc", content: e === "design" ? ja() : Wa() }), ve = (e) => Xt(e, (t) => t.type.name === "figure"),
|
|
2398
|
+
], tn = (e = "invention") => ({ type: "doc", content: e === "design" ? ja() : Wa() }), ve = (e) => Xt(e, (t) => t.type.name === "figure"), J = (e) => typeof e != "string" ? "" : e.trim(), xt = (e) => {
|
|
2384
2399
|
const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = /* @__PURE__ */ new Set();
|
|
2385
2400
|
ve(e).forEach((i) => {
|
|
2386
|
-
const s =
|
|
2401
|
+
const s = J(i.node.attrs.id);
|
|
2387
2402
|
s && r.add(s);
|
|
2388
2403
|
});
|
|
2389
2404
|
let a = 1;
|
|
@@ -2396,7 +2411,7 @@ const Le = () => {
|
|
|
2396
2411
|
const a = [];
|
|
2397
2412
|
let i = 1;
|
|
2398
2413
|
for (const o of r) {
|
|
2399
|
-
const l =
|
|
2414
|
+
const l = J(o.node.attrs.id);
|
|
2400
2415
|
if (!Ga.exec(l)) continue;
|
|
2401
2416
|
const d = `${n}${i}`;
|
|
2402
2417
|
l !== d && a.push({ pos: o.pos, expectedId: d, currentId: l }), i++;
|
|
@@ -2411,7 +2426,7 @@ const Le = () => {
|
|
|
2411
2426
|
}, nn = (e) => {
|
|
2412
2427
|
const t = /* @__PURE__ */ new Map();
|
|
2413
2428
|
return ve(e).forEach((n) => {
|
|
2414
|
-
const r =
|
|
2429
|
+
const r = J(n.node.attrs.id);
|
|
2415
2430
|
r && t.set(r, {
|
|
2416
2431
|
id: r,
|
|
2417
2432
|
pos: n.pos
|
|
@@ -2427,19 +2442,19 @@ const Le = () => {
|
|
|
2427
2442
|
return a.doc.descendants((o, l) => {
|
|
2428
2443
|
if (o.type.name !== "reference" || o.attrs.targetType !== "figure")
|
|
2429
2444
|
return !0;
|
|
2430
|
-
const c = typeof o.attrs.targetFigureId == "string" && o.attrs.targetFigureId ?
|
|
2445
|
+
const c = typeof o.attrs.targetFigureId == "string" && o.attrs.targetFigureId ? J(o.attrs.targetFigureId) : null, d = c ? t.get(c) : void 0, m = d ? d.id : null, g = !d, h = an(n, m, g), p = {
|
|
2431
2446
|
...o.attrs,
|
|
2432
2447
|
targetType: "figure",
|
|
2433
2448
|
targetFigureId: c,
|
|
2434
|
-
resolvedFigureId:
|
|
2435
|
-
invalid:
|
|
2449
|
+
resolvedFigureId: m,
|
|
2450
|
+
invalid: g,
|
|
2436
2451
|
lang: n,
|
|
2437
|
-
displayText:
|
|
2438
|
-
target:
|
|
2452
|
+
displayText: h,
|
|
2453
|
+
target: m || o.attrs.target || c || null
|
|
2439
2454
|
};
|
|
2440
|
-
return Object.keys(
|
|
2441
|
-
(y) =>
|
|
2442
|
-
) && (r.setNodeMarkup(l, void 0,
|
|
2455
|
+
return Object.keys(p).some(
|
|
2456
|
+
(y) => p[y] !== o.attrs[y]
|
|
2457
|
+
) && (r.setNodeMarkup(l, void 0, p), s = !0), !0;
|
|
2443
2458
|
}), s && i && (r.setMeta("addToHistory", !1), i(r)), !0;
|
|
2444
2459
|
});
|
|
2445
2460
|
}, Ja = {
|
|
@@ -2471,8 +2486,8 @@ const Le = () => {
|
|
|
2471
2486
|
const i = (n.scope || "all") === "current" ? Re(e, "reference") : null;
|
|
2472
2487
|
return e.commands.command(({ tr: o, state: l, dispatch: c }) => {
|
|
2473
2488
|
let d = !1;
|
|
2474
|
-
return l.doc.descendants((
|
|
2475
|
-
...
|
|
2489
|
+
return l.doc.descendants((m, g) => (m.type.name !== "reference" || i && g !== i.pos || m.attrs.lang !== r && (o.setNodeMarkup(g, void 0, {
|
|
2490
|
+
...m.attrs,
|
|
2476
2491
|
lang: r
|
|
2477
2492
|
}), d = !0), !0)), d && c && (o.setMeta("addToHistory", !1), c(o)), !0;
|
|
2478
2493
|
}) ? (Je(e), !0) : !1;
|
|
@@ -2484,7 +2499,7 @@ const Le = () => {
|
|
|
2484
2499
|
shortcut: "Ctrl+Shift+F",
|
|
2485
2500
|
isActive: ({ editor: e }) => e.isActive("figure"),
|
|
2486
2501
|
execute: ({ editor: e }, t) => {
|
|
2487
|
-
const n = typeof t == "object" && t ? t : {}, r =
|
|
2502
|
+
const n = typeof t == "object" && t ? t : {}, r = J(n.id) || xt(e), a = n.contentType && ["image", "mermaid", "drawio"].includes(n.contentType) ? n.contentType : "image";
|
|
2488
2503
|
return e.chain().focus().insertContent({
|
|
2489
2504
|
type: "figure",
|
|
2490
2505
|
attrs: { id: r, contentType: a, imageSrc: "", mermaidCode: "", drawioXml: "" },
|
|
@@ -2502,8 +2517,8 @@ const Le = () => {
|
|
|
2502
2517
|
const i = e.state.doc.nodeAt(a);
|
|
2503
2518
|
if (!i || i.type.name !== "figure")
|
|
2504
2519
|
return !1;
|
|
2505
|
-
const o = (typeof n.id == "string" ?
|
|
2506
|
-
if (ve(e).some((d) => d.pos === a ? !1 :
|
|
2520
|
+
const o = (typeof n.id == "string" ? J(n.id) : J(i.attrs.id)) || xt(e);
|
|
2521
|
+
if (ve(e).some((d) => d.pos === a ? !1 : J(d.node.attrs.id) === o))
|
|
2507
2522
|
return !1;
|
|
2508
2523
|
const c = { id: o };
|
|
2509
2524
|
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, {
|
|
@@ -2520,7 +2535,7 @@ const Le = () => {
|
|
|
2520
2535
|
const t = /* @__PURE__ */ new Set();
|
|
2521
2536
|
let n = !1;
|
|
2522
2537
|
return ve(e).forEach((r) => {
|
|
2523
|
-
const a =
|
|
2538
|
+
const a = J(r.node.attrs.id);
|
|
2524
2539
|
if (a) {
|
|
2525
2540
|
if (t.has(a)) {
|
|
2526
2541
|
n = !0;
|
|
@@ -2543,7 +2558,7 @@ const Le = () => {
|
|
|
2543
2558
|
return typeof n.targetFigureId == "string" && n.targetFigureId.trim().length > 0;
|
|
2544
2559
|
},
|
|
2545
2560
|
execute: ({ editor: e }, t) => {
|
|
2546
|
-
const n = typeof t == "object" && t ? t : {}, r = nn(e), a = typeof n.targetFigureId == "string" ?
|
|
2561
|
+
const n = typeof t == "object" && t ? t : {}, r = nn(e), a = typeof n.targetFigureId == "string" ? J(n.targetFigureId) : "";
|
|
2547
2562
|
if (!a)
|
|
2548
2563
|
return !1;
|
|
2549
2564
|
const i = r.get(a);
|
|
@@ -2621,7 +2636,7 @@ const Xa = (e = {}) => {
|
|
|
2621
2636
|
updateNodeAttrs: (t) => ze(e, t),
|
|
2622
2637
|
removeNode: (t) => Zt(e, t),
|
|
2623
2638
|
wrapSelection: (t) => Qt(e, t),
|
|
2624
|
-
applyTransactionBatch: (t) =>
|
|
2639
|
+
applyTransactionBatch: (t) => Pa(e, t),
|
|
2625
2640
|
findNodeByType: (t, n) => st(e, t, n),
|
|
2626
2641
|
findAncestorNode: (t) => Re(e, t),
|
|
2627
2642
|
findCurrentBlock: () => Ia(e),
|
|
@@ -2640,58 +2655,58 @@ const Xa = (e = {}) => {
|
|
|
2640
2655
|
}
|
|
2641
2656
|
return e.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join(" ");
|
|
2642
2657
|
}, Ct = ({ btn: e, items: t }) => {
|
|
2643
|
-
const [n, r] =
|
|
2658
|
+
const [n, r] = M(!1), a = W(null), i = W(null), [s, o] = M({ top: 0, left: 0 }), l = j(() => {
|
|
2644
2659
|
if (!a.current) return;
|
|
2645
2660
|
const c = a.current.getBoundingClientRect();
|
|
2646
2661
|
o({ top: c.bottom + 4, left: c.left });
|
|
2647
2662
|
}, []);
|
|
2648
|
-
return
|
|
2663
|
+
return F(() => {
|
|
2649
2664
|
if (!n) return;
|
|
2650
2665
|
l();
|
|
2651
|
-
const c = (
|
|
2652
|
-
var
|
|
2653
|
-
const
|
|
2654
|
-
(
|
|
2666
|
+
const c = (m) => {
|
|
2667
|
+
var h, p;
|
|
2668
|
+
const g = m.target;
|
|
2669
|
+
(h = a.current) != null && h.contains(g) || (p = i.current) != null && p.contains(g) || r(!1);
|
|
2655
2670
|
}, d = () => l();
|
|
2656
2671
|
return document.addEventListener("mousedown", c), window.addEventListener("scroll", d, !0), () => {
|
|
2657
2672
|
document.removeEventListener("mousedown", c), window.removeEventListener("scroll", d, !0);
|
|
2658
2673
|
};
|
|
2659
|
-
}, [n, l]), /* @__PURE__ */
|
|
2660
|
-
/* @__PURE__ */
|
|
2674
|
+
}, [n, l]), /* @__PURE__ */ P("div", { className: "flex items-center", children: [
|
|
2675
|
+
/* @__PURE__ */ f(
|
|
2661
2676
|
"button",
|
|
2662
2677
|
{
|
|
2663
2678
|
onClick: e.run,
|
|
2664
2679
|
disabled: e.disabled,
|
|
2665
|
-
className:
|
|
2680
|
+
className: Z(
|
|
2666
2681
|
"p-2 rounded-l transition-colors",
|
|
2667
2682
|
e.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200",
|
|
2668
2683
|
e.isActive ? "bg-gray-300 text-blue-600" : "text-gray-700"
|
|
2669
2684
|
),
|
|
2670
2685
|
title: e.tooltip,
|
|
2671
|
-
children: /* @__PURE__ */
|
|
2686
|
+
children: /* @__PURE__ */ f(e.icon, { size: 18 })
|
|
2672
2687
|
}
|
|
2673
2688
|
),
|
|
2674
|
-
/* @__PURE__ */
|
|
2689
|
+
/* @__PURE__ */ f(
|
|
2675
2690
|
"button",
|
|
2676
2691
|
{
|
|
2677
2692
|
ref: a,
|
|
2678
2693
|
onClick: () => r((c) => !c),
|
|
2679
|
-
className:
|
|
2694
|
+
className: Z(
|
|
2680
2695
|
"px-1 py-2 rounded-r transition-colors border-l border-gray-200",
|
|
2681
2696
|
e.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200 text-gray-500"
|
|
2682
2697
|
),
|
|
2683
2698
|
disabled: e.disabled,
|
|
2684
|
-
children: /* @__PURE__ */
|
|
2699
|
+
children: /* @__PURE__ */ f(qt, { size: 12 })
|
|
2685
2700
|
}
|
|
2686
2701
|
),
|
|
2687
2702
|
n && yr(
|
|
2688
|
-
/* @__PURE__ */
|
|
2703
|
+
/* @__PURE__ */ f(
|
|
2689
2704
|
"div",
|
|
2690
2705
|
{
|
|
2691
2706
|
ref: i,
|
|
2692
2707
|
className: "bg-white border border-gray-200 rounded shadow-lg min-w-[160px] py-1",
|
|
2693
2708
|
style: { position: "fixed", top: s.top, left: s.left, zIndex: 9999 },
|
|
2694
|
-
children: t.map((c, d) => /* @__PURE__ */
|
|
2709
|
+
children: t.map((c, d) => /* @__PURE__ */ f(
|
|
2695
2710
|
"button",
|
|
2696
2711
|
{
|
|
2697
2712
|
onClick: () => {
|
|
@@ -2713,16 +2728,16 @@ const Xa = (e = {}) => {
|
|
|
2713
2728
|
collapsibleGroups: n = !0,
|
|
2714
2729
|
defaultCollapsedGroups: r = []
|
|
2715
2730
|
}) => {
|
|
2716
|
-
const [a, i] =
|
|
2717
|
-
if (
|
|
2731
|
+
const [a, i] = M(() => new Set(r)), [, s] = M(0), { editorLanguage: o, setEditorLanguage: l } = I(), c = H(o);
|
|
2732
|
+
if (F(() => {
|
|
2718
2733
|
if (!e) return;
|
|
2719
|
-
const
|
|
2720
|
-
return e.on("selectionUpdate",
|
|
2721
|
-
e.off("selectionUpdate",
|
|
2734
|
+
const u = () => s((v) => v + 1);
|
|
2735
|
+
return e.on("selectionUpdate", u), e.on("update", u), () => {
|
|
2736
|
+
e.off("selectionUpdate", u), e.off("update", u);
|
|
2722
2737
|
};
|
|
2723
2738
|
}, [e]), !e)
|
|
2724
2739
|
return null;
|
|
2725
|
-
const d = ct(e),
|
|
2740
|
+
const d = ct(e), m = o === "zh", g = [
|
|
2726
2741
|
{
|
|
2727
2742
|
id: "core-undo",
|
|
2728
2743
|
label: c.undo,
|
|
@@ -2967,7 +2982,7 @@ const Xa = (e = {}) => {
|
|
|
2967
2982
|
id: "core-code-block",
|
|
2968
2983
|
label: c.codeBlock,
|
|
2969
2984
|
group: "structure",
|
|
2970
|
-
icon:
|
|
2985
|
+
icon: Pr,
|
|
2971
2986
|
tooltip: c.codeBlock,
|
|
2972
2987
|
isActive: e.isActive("codeBlock"),
|
|
2973
2988
|
disabled: !1,
|
|
@@ -2979,7 +2994,7 @@ const Xa = (e = {}) => {
|
|
|
2979
2994
|
id: "core-table",
|
|
2980
2995
|
label: c.insertTable,
|
|
2981
2996
|
group: "structure",
|
|
2982
|
-
icon:
|
|
2997
|
+
icon: Lr,
|
|
2983
2998
|
tooltip: c.insertTable,
|
|
2984
2999
|
isActive: !1,
|
|
2985
3000
|
disabled: !1,
|
|
@@ -3011,7 +3026,7 @@ const Xa = (e = {}) => {
|
|
|
3011
3026
|
e.chain().focus().toggleTaskList().run();
|
|
3012
3027
|
}
|
|
3013
3028
|
}
|
|
3014
|
-
],
|
|
3029
|
+
], h = {
|
|
3015
3030
|
GitGraph: Or,
|
|
3016
3031
|
Sigma: zr,
|
|
3017
3032
|
FunctionSquare: $r,
|
|
@@ -3020,98 +3035,98 @@ const Xa = (e = {}) => {
|
|
|
3020
3035
|
FileText: Ut,
|
|
3021
3036
|
Link2: Ht,
|
|
3022
3037
|
Image: Bt
|
|
3023
|
-
},
|
|
3024
|
-
const
|
|
3038
|
+
}, p = B.getToolbarItems().map((u) => {
|
|
3039
|
+
const v = B.getCommandMeta(u.command), _ = m && u.tooltipZh ? u.tooltipZh : u.tooltip || (v == null ? void 0 : v.description) || u.label, N = u.shortcut || (v == null ? void 0 : v.shortcut), D = N ? `${_} (${N})` : _;
|
|
3025
3040
|
return {
|
|
3026
|
-
id:
|
|
3027
|
-
label:
|
|
3028
|
-
group:
|
|
3029
|
-
icon:
|
|
3030
|
-
isActive: d.isCommandActive(
|
|
3031
|
-
disabled: !d.canExecCommand(
|
|
3041
|
+
id: u.id,
|
|
3042
|
+
label: u.label,
|
|
3043
|
+
group: u.group || "technical",
|
|
3044
|
+
icon: u.icon ? h[u.icon] || mt : mt,
|
|
3045
|
+
isActive: d.isCommandActive(u.command),
|
|
3046
|
+
disabled: !d.canExecCommand(u.command),
|
|
3032
3047
|
tooltip: D,
|
|
3033
3048
|
run: () => {
|
|
3034
|
-
d.execCommand(
|
|
3049
|
+
d.execCommand(u.command);
|
|
3035
3050
|
}
|
|
3036
3051
|
};
|
|
3037
|
-
}), b = [...
|
|
3038
|
-
group:
|
|
3039
|
-
items: b.filter((
|
|
3040
|
-
})).filter((
|
|
3041
|
-
i((
|
|
3042
|
-
const _ = new Set(
|
|
3043
|
-
return _.has(
|
|
3052
|
+
}), b = [...g, ...p], y = b.map((u) => u.group).filter((u, v, _) => _.indexOf(u) === v && !t.includes(u)), T = [...t, ...y].map((u) => ({
|
|
3053
|
+
group: u,
|
|
3054
|
+
items: b.filter((v) => v.group === u)
|
|
3055
|
+
})).filter((u) => u.items.length > 0), C = (u) => {
|
|
3056
|
+
i((v) => {
|
|
3057
|
+
const _ = new Set(v);
|
|
3058
|
+
return _.has(u) ? _.delete(u) : _.add(u), _;
|
|
3044
3059
|
});
|
|
3045
3060
|
}, x = [
|
|
3046
|
-
{ label:
|
|
3047
|
-
{ label:
|
|
3048
|
-
{ label:
|
|
3049
|
-
{ label:
|
|
3050
|
-
{ label:
|
|
3051
|
-
{ label:
|
|
3052
|
-
{ label:
|
|
3053
|
-
{ label:
|
|
3054
|
-
{ label:
|
|
3055
|
-
{ label:
|
|
3056
|
-
{ label:
|
|
3061
|
+
{ label: m ? "插入表格 3×3" : "Insert Table 3×3", onClick: () => e.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run() },
|
|
3062
|
+
{ label: m ? "上方插入行" : "Add Row Before", onClick: () => e.chain().focus().addRowBefore().run() },
|
|
3063
|
+
{ label: m ? "下方插入行" : "Add Row After", onClick: () => e.chain().focus().addRowAfter().run() },
|
|
3064
|
+
{ label: m ? "左侧插入列" : "Add Column Before", onClick: () => e.chain().focus().addColumnBefore().run() },
|
|
3065
|
+
{ label: m ? "右侧插入列" : "Add Column After", onClick: () => e.chain().focus().addColumnAfter().run() },
|
|
3066
|
+
{ label: m ? "删除行" : "Delete Row", onClick: () => e.chain().focus().deleteRow().run() },
|
|
3067
|
+
{ label: m ? "删除列" : "Delete Column", onClick: () => e.chain().focus().deleteColumn().run() },
|
|
3068
|
+
{ label: m ? "合并单元格" : "Merge Cells", onClick: () => e.chain().focus().mergeCells().run() },
|
|
3069
|
+
{ label: m ? "拆分单元格" : "Split Cell", onClick: () => e.chain().focus().splitCell().run() },
|
|
3070
|
+
{ label: m ? "切换表头" : "Toggle Header Row", onClick: () => e.chain().focus().toggleHeaderRow().run() },
|
|
3071
|
+
{ label: m ? "删除表格" : "Delete Table", onClick: () => e.chain().focus().deleteTable().run() }
|
|
3057
3072
|
], S = [
|
|
3058
3073
|
{ label: c.insertImageFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "image" }) },
|
|
3059
3074
|
{ label: c.insertMermaidFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "mermaid" }) },
|
|
3060
3075
|
{ label: c.insertDrawioFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "drawio" }) }
|
|
3061
|
-
],
|
|
3076
|
+
], A = (u) => u.id === "core-table" ? /* @__PURE__ */ f(Ct, { btn: u, items: x }, u.id) : u.id === "patent-figure-insert" ? /* @__PURE__ */ f(Ct, { btn: u, items: S }, u.id) : /* @__PURE__ */ f(
|
|
3062
3077
|
"button",
|
|
3063
3078
|
{
|
|
3064
|
-
onClick:
|
|
3065
|
-
disabled:
|
|
3066
|
-
className:
|
|
3079
|
+
onClick: u.run,
|
|
3080
|
+
disabled: u.disabled,
|
|
3081
|
+
className: Z(
|
|
3067
3082
|
"p-2 rounded transition-colors",
|
|
3068
|
-
|
|
3069
|
-
|
|
3083
|
+
u.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200",
|
|
3084
|
+
u.isActive ? "bg-gray-300 text-blue-600" : "text-gray-700"
|
|
3070
3085
|
),
|
|
3071
|
-
title:
|
|
3072
|
-
children: /* @__PURE__ */
|
|
3086
|
+
title: u.tooltip,
|
|
3087
|
+
children: /* @__PURE__ */ f(u.icon, { size: 18 })
|
|
3073
3088
|
},
|
|
3074
|
-
|
|
3089
|
+
u.id
|
|
3075
3090
|
);
|
|
3076
|
-
return /* @__PURE__ */
|
|
3077
|
-
/* @__PURE__ */
|
|
3078
|
-
/* @__PURE__ */
|
|
3079
|
-
/* @__PURE__ */
|
|
3091
|
+
return /* @__PURE__ */ f("div", { className: "border-b border-gray-200 bg-gray-50 sticky top-0 z-10 overflow-x-auto", children: /* @__PURE__ */ P("div", { className: "flex flex-nowrap md:flex-wrap gap-2 p-2 min-w-max md:min-w-0", children: [
|
|
3092
|
+
/* @__PURE__ */ P("div", { className: "flex items-center gap-1 pr-2 mr-2 border-r border-gray-200", children: [
|
|
3093
|
+
/* @__PURE__ */ f("span", { className: "text-xs text-gray-500", children: c.language }),
|
|
3094
|
+
/* @__PURE__ */ P(
|
|
3080
3095
|
"select",
|
|
3081
3096
|
{
|
|
3082
3097
|
value: o,
|
|
3083
|
-
onChange: (
|
|
3084
|
-
l(
|
|
3098
|
+
onChange: (u) => {
|
|
3099
|
+
l(u.target.value === "en" ? "en" : "zh");
|
|
3085
3100
|
},
|
|
3086
3101
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white text-gray-700",
|
|
3087
3102
|
children: [
|
|
3088
|
-
/* @__PURE__ */
|
|
3089
|
-
/* @__PURE__ */
|
|
3103
|
+
/* @__PURE__ */ f("option", { value: "zh", children: "中文" }),
|
|
3104
|
+
/* @__PURE__ */ f("option", { value: "en", children: "English" })
|
|
3090
3105
|
]
|
|
3091
3106
|
}
|
|
3092
3107
|
)
|
|
3093
3108
|
] }),
|
|
3094
|
-
T.map((
|
|
3095
|
-
const
|
|
3096
|
-
return /* @__PURE__ */
|
|
3097
|
-
n && /* @__PURE__ */
|
|
3109
|
+
T.map((u) => {
|
|
3110
|
+
const v = a.has(u.group);
|
|
3111
|
+
return /* @__PURE__ */ P("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: [
|
|
3112
|
+
n && /* @__PURE__ */ f(
|
|
3098
3113
|
"button",
|
|
3099
3114
|
{
|
|
3100
3115
|
onClick: () => {
|
|
3101
|
-
|
|
3116
|
+
C(u.group);
|
|
3102
3117
|
},
|
|
3103
3118
|
className: "px-2 py-1 text-xs rounded bg-gray-200 text-gray-700 hover:bg-gray-300",
|
|
3104
|
-
title:
|
|
3105
|
-
children: Xe(
|
|
3119
|
+
title: v ? `${c.expand} ${Xe(u.group, c)}` : `${c.collapse} ${Xe(u.group, c)}`,
|
|
3120
|
+
children: Xe(u.group, c)
|
|
3106
3121
|
}
|
|
3107
3122
|
),
|
|
3108
|
-
(!n || !
|
|
3109
|
-
] },
|
|
3123
|
+
(!n || !v) && u.items.map(A)
|
|
3124
|
+
] }, u.group);
|
|
3110
3125
|
})
|
|
3111
3126
|
] }) });
|
|
3112
3127
|
}, ei = ({ editor: e }) => {
|
|
3113
|
-
const [t, n] =
|
|
3114
|
-
if (
|
|
3128
|
+
const [t, n] = M(0), [r, a] = M(""), i = I((x) => x.editorLanguage), s = H(i);
|
|
3129
|
+
if (F(() => {
|
|
3115
3130
|
if (!e) return;
|
|
3116
3131
|
const x = () => n((S) => S + 1);
|
|
3117
3132
|
return e.on("selectionUpdate", x), e.on("update", x), () => {
|
|
@@ -3124,37 +3139,37 @@ const Xa = (e = {}) => {
|
|
|
3124
3139
|
const S = typeof x.attrs.id == "string" ? x.attrs.id.trim() : "";
|
|
3125
3140
|
return S && l.push({ id: S, label: S }), !0;
|
|
3126
3141
|
});
|
|
3127
|
-
const c = o.findAncestorNode("figure"), d = !!c,
|
|
3128
|
-
w !== y.current && (y.current = w, d &&
|
|
3142
|
+
const c = o.findAncestorNode("figure"), d = !!c, m = c && typeof c.node.attrs.id == "string" ? c.node.attrs.id.trim() : "", g = c && typeof c.node.attrs.contentType == "string" ? c.node.attrs.contentType : "image", [h, p] = M(""), b = W(null), y = W(null), w = (c == null ? void 0 : c.pos) ?? null;
|
|
3143
|
+
w !== y.current && (y.current = w, d && m !== h && p(m));
|
|
3129
3144
|
const T = (x) => {
|
|
3130
3145
|
c && o.execCommand("patent.updateFigure", {
|
|
3131
3146
|
position: c.pos,
|
|
3132
3147
|
contentType: x
|
|
3133
3148
|
});
|
|
3134
|
-
},
|
|
3149
|
+
}, C = () => {
|
|
3135
3150
|
if (!c) return;
|
|
3136
|
-
const x =
|
|
3137
|
-
x !==
|
|
3151
|
+
const x = h.trim();
|
|
3152
|
+
x !== m && o.execCommand("patent.updateFigure", {
|
|
3138
3153
|
position: c.pos,
|
|
3139
3154
|
id: x
|
|
3140
3155
|
});
|
|
3141
3156
|
};
|
|
3142
|
-
return /* @__PURE__ */
|
|
3143
|
-
l.length > 0 && /* @__PURE__ */
|
|
3144
|
-
/* @__PURE__ */
|
|
3145
|
-
/* @__PURE__ */
|
|
3157
|
+
return /* @__PURE__ */ f("div", { className: "border-b border-gray-200 bg-gray-50 p-2", children: /* @__PURE__ */ P("div", { className: "bg-white border border-gray-200 rounded-md px-2 py-2 flex flex-wrap items-center gap-2", children: [
|
|
3158
|
+
l.length > 0 && /* @__PURE__ */ P(je, { children: [
|
|
3159
|
+
/* @__PURE__ */ f("span", { className: "text-xs text-gray-500", children: s.figureReferenceTarget }),
|
|
3160
|
+
/* @__PURE__ */ P(
|
|
3146
3161
|
"select",
|
|
3147
3162
|
{
|
|
3148
3163
|
value: r || "__none__",
|
|
3149
3164
|
onChange: (x) => a(x.target.value === "__none__" ? "" : x.target.value),
|
|
3150
3165
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
|
|
3151
3166
|
children: [
|
|
3152
|
-
/* @__PURE__ */
|
|
3153
|
-
l.map((x) => /* @__PURE__ */
|
|
3167
|
+
/* @__PURE__ */ f("option", { value: "__none__", children: s.figureReferenceTargetPlaceholder }),
|
|
3168
|
+
l.map((x) => /* @__PURE__ */ f("option", { value: x.id, children: x.label }, x.id))
|
|
3154
3169
|
]
|
|
3155
3170
|
}
|
|
3156
3171
|
),
|
|
3157
|
-
/* @__PURE__ */
|
|
3172
|
+
/* @__PURE__ */ f(
|
|
3158
3173
|
"button",
|
|
3159
3174
|
{
|
|
3160
3175
|
onClick: () => {
|
|
@@ -3165,59 +3180,59 @@ const Xa = (e = {}) => {
|
|
|
3165
3180
|
},
|
|
3166
3181
|
className: "p-2 hover:bg-blue-50 text-blue-600 rounded",
|
|
3167
3182
|
title: s.insertFigureReference,
|
|
3168
|
-
children: /* @__PURE__ */
|
|
3183
|
+
children: /* @__PURE__ */ f(Bt, { size: 16 })
|
|
3169
3184
|
}
|
|
3170
3185
|
)
|
|
3171
3186
|
] }),
|
|
3172
|
-
/* @__PURE__ */
|
|
3173
|
-
d && /* @__PURE__ */
|
|
3174
|
-
/* @__PURE__ */
|
|
3175
|
-
/* @__PURE__ */
|
|
3176
|
-
/* @__PURE__ */
|
|
3187
|
+
/* @__PURE__ */ f("div", { className: "h-6 w-px bg-gray-200 mx-1" }),
|
|
3188
|
+
d && /* @__PURE__ */ P(je, { children: [
|
|
3189
|
+
/* @__PURE__ */ f("span", { className: "text-xs font-medium text-gray-700", children: s.currentFigure }),
|
|
3190
|
+
/* @__PURE__ */ f("span", { className: "text-xs text-gray-500", children: s.figureId }),
|
|
3191
|
+
/* @__PURE__ */ f(
|
|
3177
3192
|
"input",
|
|
3178
3193
|
{
|
|
3179
3194
|
ref: b,
|
|
3180
3195
|
type: "text",
|
|
3181
|
-
value:
|
|
3182
|
-
onChange: (x) =>
|
|
3183
|
-
onBlur:
|
|
3196
|
+
value: h,
|
|
3197
|
+
onChange: (x) => p(x.target.value),
|
|
3198
|
+
onBlur: C,
|
|
3184
3199
|
onKeyDown: (x) => {
|
|
3185
|
-
x.key === "Enter" && (
|
|
3200
|
+
x.key === "Enter" && (C(), x.target.blur());
|
|
3186
3201
|
},
|
|
3187
3202
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white w-20",
|
|
3188
3203
|
placeholder: i === "en" ? "Fig.1" : "图1"
|
|
3189
3204
|
}
|
|
3190
3205
|
),
|
|
3191
|
-
/* @__PURE__ */
|
|
3192
|
-
/* @__PURE__ */
|
|
3206
|
+
/* @__PURE__ */ f("span", { className: "text-xs text-gray-500", children: s.switchFigureType }),
|
|
3207
|
+
/* @__PURE__ */ P(
|
|
3193
3208
|
"select",
|
|
3194
3209
|
{
|
|
3195
|
-
value:
|
|
3210
|
+
value: g,
|
|
3196
3211
|
onChange: (x) => T(x.target.value),
|
|
3197
3212
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
|
|
3198
3213
|
children: [
|
|
3199
|
-
/* @__PURE__ */
|
|
3200
|
-
/* @__PURE__ */
|
|
3201
|
-
/* @__PURE__ */
|
|
3214
|
+
/* @__PURE__ */ f("option", { value: "image", children: s.figureContentTypeImage }),
|
|
3215
|
+
/* @__PURE__ */ f("option", { value: "mermaid", children: s.figureContentTypeMermaid }),
|
|
3216
|
+
/* @__PURE__ */ f("option", { value: "drawio", children: s.figureContentTypeDrawio })
|
|
3202
3217
|
]
|
|
3203
3218
|
}
|
|
3204
3219
|
),
|
|
3205
|
-
/* @__PURE__ */
|
|
3220
|
+
/* @__PURE__ */ f("div", { className: "h-6 w-px bg-gray-200 mx-1" })
|
|
3206
3221
|
] }),
|
|
3207
3222
|
e.isActive("image") && (() => {
|
|
3208
3223
|
const S = e.getAttributes("image").width || "";
|
|
3209
|
-
return /* @__PURE__ */
|
|
3210
|
-
/* @__PURE__ */
|
|
3211
|
-
["25%", "50%", "75%", "100%"].map((
|
|
3224
|
+
return /* @__PURE__ */ P(je, { children: [
|
|
3225
|
+
/* @__PURE__ */ f("span", { className: "text-xs font-medium text-gray-700", children: i === "zh" ? "图片" : "Image" }),
|
|
3226
|
+
["25%", "50%", "75%", "100%"].map((u) => /* @__PURE__ */ f(
|
|
3212
3227
|
"button",
|
|
3213
3228
|
{
|
|
3214
|
-
onClick: () => e.chain().focus().updateAttributes("image", { width:
|
|
3215
|
-
className: `text-xs px-2 py-0.5 rounded border ${S ===
|
|
3216
|
-
children:
|
|
3229
|
+
onClick: () => e.chain().focus().updateAttributes("image", { width: u }).run(),
|
|
3230
|
+
className: `text-xs px-2 py-0.5 rounded border ${S === u ? "bg-blue-50 text-blue-700 border-blue-200" : "bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,
|
|
3231
|
+
children: u
|
|
3217
3232
|
},
|
|
3218
|
-
|
|
3233
|
+
u
|
|
3219
3234
|
)),
|
|
3220
|
-
/* @__PURE__ */
|
|
3235
|
+
/* @__PURE__ */ f("div", { className: "h-6 w-px bg-gray-200 mx-1" })
|
|
3221
3236
|
] });
|
|
3222
3237
|
})()
|
|
3223
3238
|
] }) });
|
|
@@ -3289,14 +3304,14 @@ function Ws(e, t = {}) {
|
|
|
3289
3304
|
const n = I.getState().editorLanguage, { from: r, to: a } = e.state.selection, i = r !== a ? e.state.doc.textBetween(r, a, " ", "\0") : void 0;
|
|
3290
3305
|
let s = t.sectionType, o = t.targetSectionPos;
|
|
3291
3306
|
if (!s) {
|
|
3292
|
-
const
|
|
3293
|
-
|
|
3307
|
+
const m = on(e);
|
|
3308
|
+
m && (s = m.sectionType, o = m.pos);
|
|
3294
3309
|
}
|
|
3295
3310
|
const l = t.scope || (s ? "section" : i ? "selection" : "document"), c = s ? ni(e, s) : void 0;
|
|
3296
3311
|
let d;
|
|
3297
3312
|
if (l === "selection" && r !== a) {
|
|
3298
|
-
const
|
|
3299
|
-
d = `...${
|
|
3313
|
+
const g = Math.max(0, r - 200), h = Math.min(e.state.doc.content.size, a + 200), p = e.state.doc.textBetween(g, r, " ", "\0"), b = e.state.doc.textBetween(a, h, " ", "\0");
|
|
3314
|
+
d = `...${p}[SELECTED]${b}...`;
|
|
3300
3315
|
}
|
|
3301
3316
|
return {
|
|
3302
3317
|
scope: l,
|
|
@@ -3310,217 +3325,241 @@ function Ws(e, t = {}) {
|
|
|
3310
3325
|
};
|
|
3311
3326
|
}
|
|
3312
3327
|
const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
3313
|
-
const { addChatReference: n, openChatPanel: r, editorLanguage: a } = I(), i = a === "zh", s = (c) =>
|
|
3328
|
+
const { addChatReference: n, openChatPanel: r, editorLanguage: a } = I(), i = a === "zh", s = (c) => Z(
|
|
3314
3329
|
"p-1.5 rounded transition-colors",
|
|
3315
3330
|
c ? "bg-blue-100 text-blue-600" : "text-gray-600 hover:bg-gray-100"
|
|
3316
3331
|
), o = () => {
|
|
3317
3332
|
const { from: c, to: d } = e.state.selection;
|
|
3318
3333
|
if (c === d) return;
|
|
3319
|
-
const
|
|
3334
|
+
const m = e.state.doc.textBetween(c, d, " "), g = on(e);
|
|
3320
3335
|
if (t) {
|
|
3321
|
-
t({ text:
|
|
3336
|
+
t({ text: m, from: c, to: d, sectionType: g == null ? void 0 : g.sectionType });
|
|
3322
3337
|
return;
|
|
3323
3338
|
}
|
|
3324
|
-
n({ text:
|
|
3339
|
+
n({ text: m, from: c, to: d, sectionType: g == null ? void 0 : g.sectionType }), r();
|
|
3325
3340
|
}, l = () => {
|
|
3326
3341
|
const c = e.getAttributes("link").href, d = window.prompt("URL", c || "https://");
|
|
3327
3342
|
d !== null && (d === "" ? e.chain().focus().extendMarkRange("link").unsetLink().run() : e.chain().focus().extendMarkRange("link").setLink({ href: d }).run());
|
|
3328
3343
|
};
|
|
3329
|
-
return /* @__PURE__ */
|
|
3344
|
+
return /* @__PURE__ */ f(
|
|
3330
3345
|
Jr,
|
|
3331
3346
|
{
|
|
3332
3347
|
editor: e,
|
|
3333
3348
|
shouldShow: ({ editor: c, state: d }) => {
|
|
3334
|
-
const { from:
|
|
3335
|
-
return !(
|
|
3349
|
+
const { from: m, to: g } = d.selection;
|
|
3350
|
+
return !(m === g || c.isActive("codeBlock"));
|
|
3336
3351
|
},
|
|
3337
|
-
children: /* @__PURE__ */
|
|
3338
|
-
/* @__PURE__ */
|
|
3352
|
+
children: /* @__PURE__ */ P("div", { className: "bubble-menu", children: [
|
|
3353
|
+
/* @__PURE__ */ f(
|
|
3339
3354
|
"button",
|
|
3340
3355
|
{
|
|
3341
3356
|
onClick: () => e.chain().focus().toggleBold().run(),
|
|
3342
3357
|
className: s(e.isActive("bold")),
|
|
3343
3358
|
title: "Bold",
|
|
3344
|
-
children: /* @__PURE__ */
|
|
3359
|
+
children: /* @__PURE__ */ f(Dt, { size: 15 })
|
|
3345
3360
|
}
|
|
3346
3361
|
),
|
|
3347
|
-
/* @__PURE__ */
|
|
3362
|
+
/* @__PURE__ */ f(
|
|
3348
3363
|
"button",
|
|
3349
3364
|
{
|
|
3350
3365
|
onClick: () => e.chain().focus().toggleItalic().run(),
|
|
3351
3366
|
className: s(e.isActive("italic")),
|
|
3352
3367
|
title: "Italic",
|
|
3353
|
-
children: /* @__PURE__ */
|
|
3368
|
+
children: /* @__PURE__ */ f(Rt, { size: 15 })
|
|
3354
3369
|
}
|
|
3355
3370
|
),
|
|
3356
|
-
/* @__PURE__ */
|
|
3371
|
+
/* @__PURE__ */ f(
|
|
3357
3372
|
"button",
|
|
3358
3373
|
{
|
|
3359
3374
|
onClick: () => e.chain().focus().toggleUnderline().run(),
|
|
3360
3375
|
className: s(e.isActive("underline")),
|
|
3361
3376
|
title: "Underline",
|
|
3362
|
-
children: /* @__PURE__ */
|
|
3377
|
+
children: /* @__PURE__ */ f(Mt, { size: 15 })
|
|
3363
3378
|
}
|
|
3364
3379
|
),
|
|
3365
|
-
/* @__PURE__ */
|
|
3380
|
+
/* @__PURE__ */ f(
|
|
3366
3381
|
"button",
|
|
3367
3382
|
{
|
|
3368
3383
|
onClick: () => e.chain().focus().toggleStrike().run(),
|
|
3369
3384
|
className: s(e.isActive("strike")),
|
|
3370
3385
|
title: "Strikethrough",
|
|
3371
|
-
children: /* @__PURE__ */
|
|
3386
|
+
children: /* @__PURE__ */ f(Ft, { size: 15 })
|
|
3372
3387
|
}
|
|
3373
3388
|
),
|
|
3374
|
-
/* @__PURE__ */
|
|
3389
|
+
/* @__PURE__ */ f(
|
|
3375
3390
|
"button",
|
|
3376
3391
|
{
|
|
3377
3392
|
onClick: () => e.chain().focus().toggleCode().run(),
|
|
3378
3393
|
className: s(e.isActive("code")),
|
|
3379
3394
|
title: "Code",
|
|
3380
|
-
children: /* @__PURE__ */
|
|
3395
|
+
children: /* @__PURE__ */ f($t, { size: 15 })
|
|
3381
3396
|
}
|
|
3382
3397
|
),
|
|
3383
|
-
/* @__PURE__ */
|
|
3398
|
+
/* @__PURE__ */ f(
|
|
3384
3399
|
"button",
|
|
3385
3400
|
{
|
|
3386
3401
|
onClick: () => e.chain().focus().toggleSuperscript().run(),
|
|
3387
3402
|
className: s(e.isActive("superscript")),
|
|
3388
3403
|
title: "Superscript",
|
|
3389
|
-
children: /* @__PURE__ */
|
|
3404
|
+
children: /* @__PURE__ */ f(zt, { size: 15 })
|
|
3390
3405
|
}
|
|
3391
3406
|
),
|
|
3392
|
-
/* @__PURE__ */
|
|
3407
|
+
/* @__PURE__ */ f(
|
|
3393
3408
|
"button",
|
|
3394
3409
|
{
|
|
3395
3410
|
onClick: () => e.chain().focus().toggleSubscript().run(),
|
|
3396
3411
|
className: s(e.isActive("subscript")),
|
|
3397
3412
|
title: "Subscript",
|
|
3398
|
-
children: /* @__PURE__ */
|
|
3413
|
+
children: /* @__PURE__ */ f(Ot, { size: 15 })
|
|
3399
3414
|
}
|
|
3400
3415
|
),
|
|
3401
|
-
/* @__PURE__ */
|
|
3402
|
-
/* @__PURE__ */
|
|
3416
|
+
/* @__PURE__ */ f("div", { className: "bubble-menu-divider" }),
|
|
3417
|
+
/* @__PURE__ */ f(
|
|
3403
3418
|
"button",
|
|
3404
3419
|
{
|
|
3405
3420
|
onClick: () => e.chain().focus().toggleHighlight().run(),
|
|
3406
3421
|
className: s(e.isActive("highlight")),
|
|
3407
3422
|
title: "Highlight",
|
|
3408
|
-
children: /* @__PURE__ */
|
|
3423
|
+
children: /* @__PURE__ */ f(Br, { size: 15 })
|
|
3409
3424
|
}
|
|
3410
3425
|
),
|
|
3411
|
-
/* @__PURE__ */
|
|
3426
|
+
/* @__PURE__ */ f(
|
|
3412
3427
|
"button",
|
|
3413
3428
|
{
|
|
3414
3429
|
onClick: l,
|
|
3415
3430
|
className: s(e.isActive("link")),
|
|
3416
3431
|
title: "Link",
|
|
3417
|
-
children: /* @__PURE__ */
|
|
3432
|
+
children: /* @__PURE__ */ f(Ht, { size: 15 })
|
|
3418
3433
|
}
|
|
3419
3434
|
),
|
|
3420
|
-
/* @__PURE__ */
|
|
3421
|
-
/* @__PURE__ */
|
|
3435
|
+
/* @__PURE__ */ f("div", { className: "bubble-menu-divider" }),
|
|
3436
|
+
/* @__PURE__ */ f(
|
|
3422
3437
|
"button",
|
|
3423
3438
|
{
|
|
3424
3439
|
onClick: o,
|
|
3425
3440
|
className: "p-1.5 rounded transition-colors text-purple-500 hover:bg-purple-50",
|
|
3426
3441
|
title: i ? "AI 优化" : "AI Optimize",
|
|
3427
|
-
children: /* @__PURE__ */
|
|
3442
|
+
children: /* @__PURE__ */ f(Hr, { size: 15 })
|
|
3428
3443
|
}
|
|
3429
3444
|
)
|
|
3430
3445
|
] })
|
|
3431
3446
|
}
|
|
3432
3447
|
);
|
|
3433
3448
|
}, ai = ({ editor: e }) => {
|
|
3434
|
-
var
|
|
3435
|
-
const [t, n] =
|
|
3436
|
-
|
|
3437
|
-
|
|
3449
|
+
var A;
|
|
3450
|
+
const [t, n] = M(!1), [r, a] = M(!1), [i, s] = M(""), [o, l] = M(""), [c, d] = M(!1), [, m] = M(0), g = j(() => m((u) => u + 1), []), h = W(null), p = e.extensionStorage.searchReplace, b = ((A = p == null ? void 0 : p.results) == null ? void 0 : A.length) ?? 0, y = (p == null ? void 0 : p.currentIndex) ?? -1, w = j(() => {
|
|
3451
|
+
e.commands.nextSearchResult(), g();
|
|
3452
|
+
}, [e, g]), T = j(() => {
|
|
3453
|
+
e.commands.previousSearchResult(), g();
|
|
3454
|
+
}, [e, g]);
|
|
3455
|
+
F(() => {
|
|
3456
|
+
const u = (v) => {
|
|
3438
3457
|
n(!0);
|
|
3439
|
-
const
|
|
3440
|
-
|
|
3458
|
+
const _ = v.detail;
|
|
3459
|
+
_ != null && _.replace && a(!0), requestAnimationFrame(() => {
|
|
3441
3460
|
var N;
|
|
3442
|
-
return (N =
|
|
3461
|
+
return (N = h.current) == null ? void 0 : N.focus();
|
|
3443
3462
|
});
|
|
3444
3463
|
};
|
|
3445
|
-
return window.addEventListener("editor:toggleSearch",
|
|
3464
|
+
return window.addEventListener("editor:toggleSearch", u), () => window.removeEventListener("editor:toggleSearch", u);
|
|
3446
3465
|
}, []);
|
|
3447
|
-
const
|
|
3448
|
-
(
|
|
3449
|
-
s(
|
|
3466
|
+
const C = j(
|
|
3467
|
+
(u) => {
|
|
3468
|
+
s(u), e.commands.setSearchTerm(u);
|
|
3450
3469
|
},
|
|
3451
3470
|
[e]
|
|
3452
|
-
),
|
|
3471
|
+
), x = j(() => {
|
|
3453
3472
|
n(!1), e.commands.clearSearch(), e.commands.focus();
|
|
3454
3473
|
}, [e]);
|
|
3455
|
-
|
|
3456
|
-
const
|
|
3457
|
-
|
|
3474
|
+
F(() => {
|
|
3475
|
+
const u = (v) => {
|
|
3476
|
+
v.key === "Escape" && t && x();
|
|
3458
3477
|
};
|
|
3459
|
-
return window.addEventListener("keydown",
|
|
3460
|
-
}, [t,
|
|
3461
|
-
const
|
|
3462
|
-
const
|
|
3463
|
-
d(
|
|
3478
|
+
return window.addEventListener("keydown", u), () => window.removeEventListener("keydown", u);
|
|
3479
|
+
}, [t, x]);
|
|
3480
|
+
const S = () => {
|
|
3481
|
+
const u = !c;
|
|
3482
|
+
d(u), e.commands.setCaseSensitive(u);
|
|
3464
3483
|
};
|
|
3465
|
-
return t ? /* @__PURE__ */
|
|
3466
|
-
/* @__PURE__ */
|
|
3467
|
-
/* @__PURE__ */
|
|
3468
|
-
/* @__PURE__ */
|
|
3484
|
+
return t ? /* @__PURE__ */ P("div", { className: "find-replace-bar", children: [
|
|
3485
|
+
/* @__PURE__ */ P("div", { className: "find-replace-row", children: [
|
|
3486
|
+
/* @__PURE__ */ P("div", { className: "find-replace-input-group", children: [
|
|
3487
|
+
/* @__PURE__ */ f(
|
|
3469
3488
|
"input",
|
|
3470
3489
|
{
|
|
3471
|
-
ref:
|
|
3490
|
+
ref: h,
|
|
3472
3491
|
type: "text",
|
|
3473
3492
|
value: i,
|
|
3474
|
-
onChange: (
|
|
3475
|
-
onKeyDown: (
|
|
3476
|
-
|
|
3493
|
+
onChange: (u) => C(u.target.value),
|
|
3494
|
+
onKeyDown: (u) => {
|
|
3495
|
+
u.key === "Enter" && (u.shiftKey ? T() : w());
|
|
3477
3496
|
},
|
|
3478
3497
|
placeholder: "Find...",
|
|
3479
3498
|
className: "find-replace-input"
|
|
3480
3499
|
}
|
|
3481
3500
|
),
|
|
3482
|
-
/* @__PURE__ */
|
|
3501
|
+
/* @__PURE__ */ f("span", { className: "find-replace-count", children: b > 0 ? `${y + 1}/${b}` : i ? "0" : "" })
|
|
3483
3502
|
] }),
|
|
3484
|
-
/* @__PURE__ */
|
|
3503
|
+
/* @__PURE__ */ f(
|
|
3485
3504
|
"button",
|
|
3486
3505
|
{
|
|
3487
|
-
onClick:
|
|
3488
|
-
className:
|
|
3506
|
+
onClick: S,
|
|
3507
|
+
className: Z("find-replace-btn", c && "find-replace-btn--active"),
|
|
3489
3508
|
title: "Case Sensitive",
|
|
3490
|
-
children: /* @__PURE__ */
|
|
3509
|
+
children: /* @__PURE__ */ f(Ur, { size: 15 })
|
|
3491
3510
|
}
|
|
3492
3511
|
),
|
|
3493
|
-
/* @__PURE__ */
|
|
3494
|
-
/* @__PURE__ */
|
|
3495
|
-
/* @__PURE__ */
|
|
3512
|
+
/* @__PURE__ */ f("button", { onClick: T, className: "find-replace-btn", title: "Previous", children: /* @__PURE__ */ f(qr, { size: 15 }) }),
|
|
3513
|
+
/* @__PURE__ */ f("button", { onClick: w, className: "find-replace-btn", title: "Next", children: /* @__PURE__ */ f(qt, { size: 15 }) }),
|
|
3514
|
+
/* @__PURE__ */ f(
|
|
3496
3515
|
"button",
|
|
3497
3516
|
{
|
|
3498
|
-
onClick: () => a((
|
|
3499
|
-
className:
|
|
3517
|
+
onClick: () => a((u) => !u),
|
|
3518
|
+
className: Z("find-replace-btn", r && "find-replace-btn--active"),
|
|
3500
3519
|
title: "Toggle Replace",
|
|
3501
|
-
children: /* @__PURE__ */
|
|
3520
|
+
children: /* @__PURE__ */ f(gt, { size: 15 })
|
|
3502
3521
|
}
|
|
3503
3522
|
),
|
|
3504
|
-
/* @__PURE__ */
|
|
3523
|
+
/* @__PURE__ */ f("button", { onClick: x, className: "find-replace-btn", title: "Close (Esc)", children: /* @__PURE__ */ f(Wr, { size: 15 }) })
|
|
3505
3524
|
] }),
|
|
3506
|
-
r && /* @__PURE__ */
|
|
3507
|
-
/* @__PURE__ */
|
|
3525
|
+
r && /* @__PURE__ */ P("div", { className: "find-replace-row", children: [
|
|
3526
|
+
/* @__PURE__ */ f(
|
|
3508
3527
|
"input",
|
|
3509
3528
|
{
|
|
3510
3529
|
type: "text",
|
|
3511
3530
|
value: o,
|
|
3512
|
-
onChange: (
|
|
3513
|
-
l(
|
|
3531
|
+
onChange: (u) => {
|
|
3532
|
+
l(u.target.value), e.commands.setReplaceTerm(u.target.value);
|
|
3514
3533
|
},
|
|
3515
|
-
onKeyDown: (
|
|
3516
|
-
|
|
3534
|
+
onKeyDown: (u) => {
|
|
3535
|
+
u.key === "Enter" && (e.commands.replaceCurrent(), g());
|
|
3517
3536
|
},
|
|
3518
3537
|
placeholder: "Replace...",
|
|
3519
3538
|
className: "find-replace-input"
|
|
3520
3539
|
}
|
|
3521
3540
|
),
|
|
3522
|
-
/* @__PURE__ */
|
|
3523
|
-
|
|
3541
|
+
/* @__PURE__ */ f(
|
|
3542
|
+
"button",
|
|
3543
|
+
{
|
|
3544
|
+
onClick: () => {
|
|
3545
|
+
e.commands.replaceCurrent(), g();
|
|
3546
|
+
},
|
|
3547
|
+
className: "find-replace-btn",
|
|
3548
|
+
title: "Replace",
|
|
3549
|
+
children: /* @__PURE__ */ f(gt, { size: 15 })
|
|
3550
|
+
}
|
|
3551
|
+
),
|
|
3552
|
+
/* @__PURE__ */ f(
|
|
3553
|
+
"button",
|
|
3554
|
+
{
|
|
3555
|
+
onClick: () => {
|
|
3556
|
+
e.commands.replaceAll(), g();
|
|
3557
|
+
},
|
|
3558
|
+
className: "find-replace-btn",
|
|
3559
|
+
title: "Replace All",
|
|
3560
|
+
children: /* @__PURE__ */ f(jr, { size: 15 })
|
|
3561
|
+
}
|
|
3562
|
+
)
|
|
3524
3563
|
] })
|
|
3525
3564
|
] }) : null;
|
|
3526
3565
|
}, ii = ({ editor: e }) => {
|
|
@@ -3529,13 +3568,13 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3529
3568
|
let c = 0;
|
|
3530
3569
|
return o !== l && (c = a.doc.textBetween(o, l, " ", "\0").replace(/\s/g, "").length), { charCount: s, selectionCount: c };
|
|
3531
3570
|
}, [e.state.doc, e.state.selection]);
|
|
3532
|
-
return /* @__PURE__ */
|
|
3533
|
-
/* @__PURE__ */
|
|
3571
|
+
return /* @__PURE__ */ P("div", { className: "word-count-bar", children: [
|
|
3572
|
+
/* @__PURE__ */ P("span", { children: [
|
|
3534
3573
|
n ? "字数" : "Characters",
|
|
3535
3574
|
": ",
|
|
3536
3575
|
r.charCount
|
|
3537
3576
|
] }),
|
|
3538
|
-
r.selectionCount > 0 && /* @__PURE__ */
|
|
3577
|
+
r.selectionCount > 0 && /* @__PURE__ */ P("span", { children: [
|
|
3539
3578
|
n ? "选区" : "Selected",
|
|
3540
3579
|
": ",
|
|
3541
3580
|
r.selectionCount
|
|
@@ -3554,8 +3593,8 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3554
3593
|
"drawing_description",
|
|
3555
3594
|
"detailed_description"
|
|
3556
3595
|
]), li = ({ editor: e, defaultCollapsed: t = !1 }) => {
|
|
3557
|
-
const { editorLanguage: n } = I(), r = H(n), [a, i] =
|
|
3558
|
-
|
|
3596
|
+
const { editorLanguage: n } = I(), r = H(n), [a, i] = M(t), [s, o] = M(0);
|
|
3597
|
+
F(() => {
|
|
3559
3598
|
const c = () => o((d) => d + 1);
|
|
3560
3599
|
return e.on("update", c), () => {
|
|
3561
3600
|
e.off("update", c);
|
|
@@ -3564,79 +3603,79 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3564
3603
|
const l = At(() => {
|
|
3565
3604
|
const c = [];
|
|
3566
3605
|
let d = !1;
|
|
3567
|
-
return e.state.doc.descendants((
|
|
3568
|
-
if (
|
|
3606
|
+
return e.state.doc.descendants((m, g) => {
|
|
3607
|
+
if (m.type.name === "patent_title") {
|
|
3569
3608
|
if (!d) {
|
|
3570
3609
|
const y = typeof r.bookTitle_description == "string" ? r.bookTitle_description : "说明书";
|
|
3571
3610
|
c.push({
|
|
3572
3611
|
type: "book-group",
|
|
3573
|
-
pos:
|
|
3612
|
+
pos: g,
|
|
3574
3613
|
title: y,
|
|
3575
3614
|
charCount: 0
|
|
3576
3615
|
}), d = !0;
|
|
3577
3616
|
}
|
|
3578
|
-
const
|
|
3617
|
+
const h = m.textContent || "", p = h.trim().length > 0, b = typeof r.patentTitlePlaceholder == "string" ? r.patentTitlePlaceholder : "Patent Title";
|
|
3579
3618
|
return c.push({
|
|
3580
3619
|
type: "section",
|
|
3581
|
-
pos:
|
|
3582
|
-
title:
|
|
3583
|
-
state:
|
|
3584
|
-
charCount:
|
|
3620
|
+
pos: g,
|
|
3621
|
+
title: p ? h.trim() : b,
|
|
3622
|
+
state: p ? "filled" : "empty",
|
|
3623
|
+
charCount: h.replace(/\s/g, "").length,
|
|
3585
3624
|
indent: !0
|
|
3586
3625
|
}), !1;
|
|
3587
3626
|
}
|
|
3588
|
-
if (
|
|
3589
|
-
const
|
|
3627
|
+
if (m.type.name === "patent_section") {
|
|
3628
|
+
const h = m.attrs.sectionType, p = ci.has(h), b = `sectionTitle_${h}`, y = typeof r[b] == "string" ? r[b] : h, w = m.textContent || "", T = w.trim().length > 0;
|
|
3590
3629
|
return c.push({
|
|
3591
3630
|
type: "section",
|
|
3592
|
-
pos:
|
|
3631
|
+
pos: g,
|
|
3593
3632
|
title: y,
|
|
3594
3633
|
state: T ? "filled" : "empty",
|
|
3595
3634
|
charCount: w.replace(/\s/g, "").length,
|
|
3596
|
-
indent:
|
|
3635
|
+
indent: p
|
|
3597
3636
|
}), !1;
|
|
3598
3637
|
}
|
|
3599
|
-
if (
|
|
3600
|
-
const
|
|
3601
|
-
return
|
|
3638
|
+
if (m.type.name === "heading") {
|
|
3639
|
+
const h = m.attrs.level, p = m.textContent || "";
|
|
3640
|
+
return p.trim() && c.push({
|
|
3602
3641
|
type: "heading",
|
|
3603
|
-
pos:
|
|
3604
|
-
title:
|
|
3605
|
-
level:
|
|
3606
|
-
charCount:
|
|
3642
|
+
pos: g,
|
|
3643
|
+
title: p,
|
|
3644
|
+
level: h,
|
|
3645
|
+
charCount: p.replace(/\s/g, "").length
|
|
3607
3646
|
}), !1;
|
|
3608
3647
|
}
|
|
3609
3648
|
return !0;
|
|
3610
3649
|
}), c;
|
|
3611
3650
|
}, [e, s, r]);
|
|
3612
|
-
return a ? /* @__PURE__ */
|
|
3651
|
+
return a ? /* @__PURE__ */ f("div", { className: "outline-panel outline-panel--collapsed", children: /* @__PURE__ */ f(
|
|
3613
3652
|
"button",
|
|
3614
3653
|
{
|
|
3615
3654
|
onClick: () => i(!1),
|
|
3616
3655
|
className: "outline-panel-toggle",
|
|
3617
3656
|
title: n === "zh" ? "展开大纲" : "Expand Outline",
|
|
3618
|
-
children: /* @__PURE__ */
|
|
3657
|
+
children: /* @__PURE__ */ f(Gr, { size: 16 })
|
|
3619
3658
|
}
|
|
3620
|
-
) }) : /* @__PURE__ */
|
|
3621
|
-
/* @__PURE__ */
|
|
3622
|
-
/* @__PURE__ */
|
|
3623
|
-
/* @__PURE__ */
|
|
3624
|
-
/* @__PURE__ */
|
|
3659
|
+
) }) : /* @__PURE__ */ P("div", { className: "outline-panel", children: [
|
|
3660
|
+
/* @__PURE__ */ P("div", { className: "outline-panel-header", children: [
|
|
3661
|
+
/* @__PURE__ */ f(Ut, { size: 14 }),
|
|
3662
|
+
/* @__PURE__ */ f("span", { children: n === "zh" ? "文档大纲" : "Outline" }),
|
|
3663
|
+
/* @__PURE__ */ f(
|
|
3625
3664
|
"button",
|
|
3626
3665
|
{
|
|
3627
3666
|
onClick: () => i(!0),
|
|
3628
3667
|
className: "outline-panel-toggle ml-auto",
|
|
3629
3668
|
title: n === "zh" ? "收起大纲" : "Collapse Outline",
|
|
3630
|
-
children: /* @__PURE__ */
|
|
3669
|
+
children: /* @__PURE__ */ f(Vr, { size: 14 })
|
|
3631
3670
|
}
|
|
3632
3671
|
)
|
|
3633
3672
|
] }),
|
|
3634
|
-
/* @__PURE__ */
|
|
3635
|
-
l.length === 0 && /* @__PURE__ */
|
|
3636
|
-
l.map((c, d) => /* @__PURE__ */
|
|
3673
|
+
/* @__PURE__ */ P("div", { className: "outline-panel-list", children: [
|
|
3674
|
+
l.length === 0 && /* @__PURE__ */ f("div", { className: "outline-panel-empty", children: n === "zh" ? "暂无章节" : "No sections yet" }),
|
|
3675
|
+
l.map((c, d) => /* @__PURE__ */ P(
|
|
3637
3676
|
"button",
|
|
3638
3677
|
{
|
|
3639
|
-
className:
|
|
3678
|
+
className: Z(
|
|
3640
3679
|
"outline-panel-item",
|
|
3641
3680
|
c.type === "heading" && `outline-panel-item--h${c.level}`,
|
|
3642
3681
|
c.type === "book-group" && "outline-panel-item--book",
|
|
@@ -3644,14 +3683,14 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3644
3683
|
),
|
|
3645
3684
|
onClick: () => {
|
|
3646
3685
|
c.type !== "book-group" && (e.chain().setTextSelection(c.pos + 1).focus().run(), requestAnimationFrame(() => {
|
|
3647
|
-
const
|
|
3648
|
-
|
|
3686
|
+
const m = e.view.nodeDOM(c.pos);
|
|
3687
|
+
m == null || m.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
3649
3688
|
}));
|
|
3650
3689
|
},
|
|
3651
3690
|
children: [
|
|
3652
|
-
c.type === "section" && c.state && /* @__PURE__ */
|
|
3653
|
-
/* @__PURE__ */
|
|
3654
|
-
c.type !== "book-group" && /* @__PURE__ */
|
|
3691
|
+
c.type === "section" && c.state && /* @__PURE__ */ f("span", { className: Z("outline-item-state", oi[c.state]), children: si[c.state] || "○" }),
|
|
3692
|
+
/* @__PURE__ */ f("span", { className: "outline-item-title", children: c.title }),
|
|
3693
|
+
c.type !== "book-group" && /* @__PURE__ */ f("span", { className: "outline-item-count", children: c.charCount })
|
|
3655
3694
|
]
|
|
3656
3695
|
},
|
|
3657
3696
|
`${c.pos}-${d}`
|
|
@@ -3662,17 +3701,17 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3662
3701
|
editor: e,
|
|
3663
3702
|
mode: t = "edit",
|
|
3664
3703
|
className: n
|
|
3665
|
-
}) => (
|
|
3704
|
+
}) => (F(() => {
|
|
3666
3705
|
e.setEditable(t === "edit");
|
|
3667
|
-
}, [e, t]), /* @__PURE__ */
|
|
3706
|
+
}, [e, t]), /* @__PURE__ */ f(
|
|
3668
3707
|
"div",
|
|
3669
3708
|
{
|
|
3670
|
-
className:
|
|
3709
|
+
className: Z(
|
|
3671
3710
|
"h-full",
|
|
3672
3711
|
t === "readonly" ? "cursor-default" : "cursor-text",
|
|
3673
3712
|
n
|
|
3674
3713
|
),
|
|
3675
|
-
children: /* @__PURE__ */
|
|
3714
|
+
children: /* @__PURE__ */ f(In, { editor: e, className: "h-full" })
|
|
3676
3715
|
}
|
|
3677
3716
|
)), cn = "patent-editor-draft", ui = 1500, mi = () => {
|
|
3678
3717
|
try {
|
|
@@ -3692,7 +3731,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3692
3731
|
patchEditorId: o = "default",
|
|
3693
3732
|
defaultOutlineCollapsed: l = !1
|
|
3694
3733
|
}) => {
|
|
3695
|
-
const { setEditor: c, setDocument: d, editorLanguage:
|
|
3734
|
+
const { setEditor: c, setDocument: d, editorLanguage: m, autoSaveStatus: g, ai: h } = I(), { setAutoSaveStatus: p, setLastSavedAt: b } = I(), y = W(null), w = e || (t ? null : mi()) || {
|
|
3696
3735
|
type: "doc",
|
|
3697
3736
|
content: [
|
|
3698
3737
|
{
|
|
@@ -3700,27 +3739,27 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3700
3739
|
content: [{ type: "text", text: "" }]
|
|
3701
3740
|
}
|
|
3702
3741
|
]
|
|
3703
|
-
}, T =
|
|
3742
|
+
}, T = j((u) => {
|
|
3704
3743
|
try {
|
|
3705
|
-
|
|
3744
|
+
p("saving"), localStorage.setItem(cn, JSON.stringify(u)), p("saved"), b(/* @__PURE__ */ new Date());
|
|
3706
3745
|
} catch {
|
|
3707
|
-
|
|
3746
|
+
p("error");
|
|
3708
3747
|
}
|
|
3709
|
-
}, [
|
|
3748
|
+
}, [p, b]), C = Nn(
|
|
3710
3749
|
Xa({
|
|
3711
3750
|
extensions: [pa.configure({ editorId: o })],
|
|
3712
3751
|
content: w,
|
|
3713
|
-
onUpdate: ({ editor:
|
|
3714
|
-
const
|
|
3715
|
-
d(
|
|
3716
|
-
T(
|
|
3752
|
+
onUpdate: ({ editor: u }) => {
|
|
3753
|
+
const v = u.getJSON();
|
|
3754
|
+
d(v), B.notifyStateChange(u), t && t(v), t || (y.current && clearTimeout(y.current), y.current = setTimeout(() => {
|
|
3755
|
+
T(v);
|
|
3717
3756
|
}, ui));
|
|
3718
3757
|
},
|
|
3719
|
-
onCreate: ({ editor:
|
|
3720
|
-
c(
|
|
3758
|
+
onCreate: ({ editor: u }) => {
|
|
3759
|
+
c(u), i == null || i(u), B.initializePlugins(u), B.notifyStateChange(u);
|
|
3721
3760
|
},
|
|
3722
|
-
onSelectionUpdate: ({ editor:
|
|
3723
|
-
B.notifySelectionChange(
|
|
3761
|
+
onSelectionUpdate: ({ editor: u }) => {
|
|
3762
|
+
B.notifySelectionChange(u);
|
|
3724
3763
|
},
|
|
3725
3764
|
editorProps: {
|
|
3726
3765
|
attributes: {
|
|
@@ -3729,40 +3768,40 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3729
3768
|
}
|
|
3730
3769
|
})
|
|
3731
3770
|
), x = W(!1);
|
|
3732
|
-
if (
|
|
3733
|
-
if (!(!
|
|
3771
|
+
if (F(() => {
|
|
3772
|
+
if (!(!C || !e)) {
|
|
3734
3773
|
if (!x.current) {
|
|
3735
3774
|
x.current = !0;
|
|
3736
3775
|
return;
|
|
3737
3776
|
}
|
|
3738
|
-
|
|
3777
|
+
C.commands.setContent(e);
|
|
3739
3778
|
}
|
|
3740
|
-
}, [
|
|
3741
|
-
y.current && clearTimeout(y.current),
|
|
3742
|
-
}, [
|
|
3743
|
-
!
|
|
3744
|
-
}, [
|
|
3779
|
+
}, [C, e]), F(() => () => {
|
|
3780
|
+
y.current && clearTimeout(y.current), C && (c(null), B.destroyPlugins(C), C.destroy());
|
|
3781
|
+
}, [C, c]), F(() => {
|
|
3782
|
+
!C || C.isDestroyed || B.notifyStateChange(C);
|
|
3783
|
+
}, [C, m]), !C)
|
|
3745
3784
|
return null;
|
|
3746
|
-
const S = H(
|
|
3747
|
-
return /* @__PURE__ */
|
|
3748
|
-
!r && /* @__PURE__ */
|
|
3749
|
-
/* @__PURE__ */
|
|
3750
|
-
|
|
3785
|
+
const S = H(m), A = g === "saving" ? S.autoSaveSaving : g === "saved" ? S.autoSaveSaved : g === "error" ? S.autoSaveError : "";
|
|
3786
|
+
return /* @__PURE__ */ P("div", { className: `editor-container flex flex-col h-full ${n}`, children: [
|
|
3787
|
+
!r && /* @__PURE__ */ P("div", { className: "flex items-center", children: [
|
|
3788
|
+
/* @__PURE__ */ f(Qa, { editor: C }),
|
|
3789
|
+
A && /* @__PURE__ */ f("span", { className: `auto-save-indicator auto-save-indicator--${g} ml-2`, children: A })
|
|
3751
3790
|
] }),
|
|
3752
|
-
!r &&
|
|
3753
|
-
!r &&
|
|
3754
|
-
!r &&
|
|
3755
|
-
/* @__PURE__ */
|
|
3756
|
-
!r &&
|
|
3757
|
-
/* @__PURE__ */
|
|
3791
|
+
!r && C && /* @__PURE__ */ f(ei, { editor: C }),
|
|
3792
|
+
!r && C && /* @__PURE__ */ f(ri, { editor: C, onSelectionOptimize: s }),
|
|
3793
|
+
!r && C && /* @__PURE__ */ f(ai, { editor: C }),
|
|
3794
|
+
/* @__PURE__ */ P("div", { className: "flex flex-1 overflow-hidden", children: [
|
|
3795
|
+
!r && C && /* @__PURE__ */ f(li, { editor: C, defaultCollapsed: l }),
|
|
3796
|
+
/* @__PURE__ */ f("div", { className: "flex-1 overflow-y-auto bg-white p-4 relative", children: /* @__PURE__ */ f(
|
|
3758
3797
|
di,
|
|
3759
3798
|
{
|
|
3760
|
-
editor:
|
|
3761
|
-
mode: r || !a ||
|
|
3799
|
+
editor: C,
|
|
3800
|
+
mode: r || !a || h.status === "streaming" && h.activeSectionType === "claims" ? "readonly" : "edit"
|
|
3762
3801
|
}
|
|
3763
3802
|
) })
|
|
3764
3803
|
] }),
|
|
3765
|
-
!r && /* @__PURE__ */
|
|
3804
|
+
!r && /* @__PURE__ */ f(ii, { editor: C })
|
|
3766
3805
|
] });
|
|
3767
3806
|
};
|
|
3768
3807
|
function ln(e) {
|
|
@@ -3788,24 +3827,24 @@ function ln(e) {
|
|
|
3788
3827
|
continue;
|
|
3789
3828
|
}
|
|
3790
3829
|
if (!d.startsWith("data: ")) continue;
|
|
3791
|
-
const
|
|
3792
|
-
if (
|
|
3830
|
+
const m = d.slice(6).trim();
|
|
3831
|
+
if (m === "[DONE]") {
|
|
3793
3832
|
a.enqueue({ type: "done" }), a.close();
|
|
3794
3833
|
return;
|
|
3795
3834
|
}
|
|
3796
3835
|
try {
|
|
3797
|
-
const
|
|
3798
|
-
if (
|
|
3836
|
+
const g = JSON.parse(m), h = c || g.type;
|
|
3837
|
+
if (h === "delta" || !h && g.content != null)
|
|
3799
3838
|
a.enqueue({
|
|
3800
3839
|
type: "delta",
|
|
3801
|
-
content:
|
|
3840
|
+
content: g.content ?? g.text ?? ((i = g.delta) == null ? void 0 : i.content) ?? ""
|
|
3802
3841
|
});
|
|
3803
|
-
else if (
|
|
3804
|
-
a.enqueue({ type: "patch", patch:
|
|
3805
|
-
else if (
|
|
3806
|
-
a.enqueue({ type: "done", usage:
|
|
3842
|
+
else if (h === "patch")
|
|
3843
|
+
a.enqueue({ type: "patch", patch: g });
|
|
3844
|
+
else if (h === "done") {
|
|
3845
|
+
a.enqueue({ type: "done", usage: g.usage }), a.close();
|
|
3807
3846
|
return;
|
|
3808
|
-
} else
|
|
3847
|
+
} else h === "error" && a.enqueue({ type: "error", message: g.message || "Unknown error" });
|
|
3809
3848
|
} catch {
|
|
3810
3849
|
}
|
|
3811
3850
|
c = "";
|
|
@@ -3894,8 +3933,8 @@ function pi(e, t) {
|
|
|
3894
3933
|
};
|
|
3895
3934
|
}
|
|
3896
3935
|
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:
|
|
3898
|
-
const { setEditorLanguage: b, setAIService: y, setChatSessionAPI: w } = I(), T = W(null),
|
|
3936
|
+
({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, editable: i = !0, language: s, aiService: o, chatSessionAPI: l, aiBaseUrl: c, aiHeaders: d, onSelectionOptimize: m, patchEditorId: g, defaultOutlineCollapsed: h }, p) => {
|
|
3937
|
+
const { setEditorLanguage: b, setAIService: y, setChatSessionAPI: w } = I(), T = W(null), C = j((S) => {
|
|
3899
3938
|
T.current = S;
|
|
3900
3939
|
}, []), x = Ee.useMemo(() => {
|
|
3901
3940
|
if (e) return e;
|
|
@@ -3907,33 +3946,33 @@ const hi = It(
|
|
|
3907
3946
|
o ? y(o) : c && y(fi(c, d));
|
|
3908
3947
|
}, [o, c, d, y]), Ee.useEffect(() => {
|
|
3909
3948
|
l ? w(l) : c && w(pi(c, d));
|
|
3910
|
-
}, [l, c, d, w]), Nt(
|
|
3949
|
+
}, [l, c, d, w]), Nt(p, () => ({
|
|
3911
3950
|
getContent: () => {
|
|
3912
3951
|
var S;
|
|
3913
3952
|
return ((S = T.current) == null ? void 0 : S.getJSON()) ?? null;
|
|
3914
3953
|
},
|
|
3915
3954
|
setContent: (S) => {
|
|
3916
|
-
var
|
|
3917
|
-
(
|
|
3955
|
+
var A;
|
|
3956
|
+
(A = T.current) == null || A.commands.setContent(S);
|
|
3918
3957
|
},
|
|
3919
3958
|
getEditor: () => T.current,
|
|
3920
|
-
execCommand: async (S,
|
|
3959
|
+
execCommand: async (S, A) => T.current ? ct(T.current).execCommand(S, A) : null,
|
|
3921
3960
|
focus: () => {
|
|
3922
3961
|
var S;
|
|
3923
3962
|
(S = T.current) == null || S.commands.focus();
|
|
3924
3963
|
}
|
|
3925
|
-
})), /* @__PURE__ */
|
|
3964
|
+
})), /* @__PURE__ */ f(
|
|
3926
3965
|
gi,
|
|
3927
3966
|
{
|
|
3928
3967
|
initialContent: x,
|
|
3929
3968
|
onChange: n,
|
|
3930
|
-
onEditorReady:
|
|
3969
|
+
onEditorReady: C,
|
|
3931
3970
|
className: r,
|
|
3932
3971
|
readOnly: a,
|
|
3933
3972
|
editable: i,
|
|
3934
|
-
onSelectionOptimize:
|
|
3935
|
-
patchEditorId:
|
|
3936
|
-
defaultOutlineCollapsed:
|
|
3973
|
+
onSelectionOptimize: m,
|
|
3974
|
+
patchEditorId: g,
|
|
3975
|
+
defaultOutlineCollapsed: h
|
|
3937
3976
|
}
|
|
3938
3977
|
);
|
|
3939
3978
|
}
|
|
@@ -3950,8 +3989,8 @@ async function js(e, t, n) {
|
|
|
3950
3989
|
if (c) break;
|
|
3951
3990
|
if (!d) continue;
|
|
3952
3991
|
(i = n.onChunk) == null || i.call(n, d);
|
|
3953
|
-
const
|
|
3954
|
-
e.view.dispatch(
|
|
3992
|
+
const m = e.state.tr.insertText(d, l);
|
|
3993
|
+
e.view.dispatch(m), l = m.mapping.map(l, 1);
|
|
3955
3994
|
}
|
|
3956
3995
|
n.mode === "section" && typeof n.targetSectionPos == "number" && nt(e, n.targetSectionPos), (s = n.onComplete) == null || s.call(n);
|
|
3957
3996
|
} catch (l) {
|
|
@@ -3959,47 +3998,47 @@ async function js(e, t, n) {
|
|
|
3959
3998
|
}
|
|
3960
3999
|
}
|
|
3961
4000
|
async function Gs(e, t, n, r) {
|
|
3962
|
-
var i, s, o, l, c, d,
|
|
4001
|
+
var i, s, o, l, c, d, m, g;
|
|
3963
4002
|
const a = new AbortController();
|
|
3964
4003
|
(i = r.onStart) == null || i.call(r), r.mode === "section" && typeof r.targetSectionPos == "number" && un(e, r.targetSectionPos);
|
|
3965
4004
|
try {
|
|
3966
|
-
const
|
|
4005
|
+
const h = await fetch(t, {
|
|
3967
4006
|
method: "POST",
|
|
3968
4007
|
headers: { "Content-Type": "application/json" },
|
|
3969
4008
|
body: JSON.stringify(n),
|
|
3970
4009
|
signal: a.signal
|
|
3971
4010
|
});
|
|
3972
|
-
if (!
|
|
3973
|
-
throw new Error(`HTTP ${
|
|
3974
|
-
const
|
|
3975
|
-
if (!
|
|
4011
|
+
if (!h.ok)
|
|
4012
|
+
throw new Error(`HTTP ${h.status}: ${h.statusText}`);
|
|
4013
|
+
const p = (s = h.body) == null ? void 0 : s.getReader();
|
|
4014
|
+
if (!p) throw new Error("No response body");
|
|
3976
4015
|
const b = new TextDecoder();
|
|
3977
4016
|
let y = dn(e, r), w = "";
|
|
3978
4017
|
for (; ; ) {
|
|
3979
|
-
const { done: T, value:
|
|
4018
|
+
const { done: T, value: C } = await p.read();
|
|
3980
4019
|
if (T) break;
|
|
3981
|
-
w += b.decode(
|
|
4020
|
+
w += b.decode(C, { stream: !0 });
|
|
3982
4021
|
const x = w.split(`
|
|
3983
4022
|
`);
|
|
3984
4023
|
w = x.pop() || "";
|
|
3985
4024
|
for (const S of x) {
|
|
3986
4025
|
if (!S.startsWith("data: ")) continue;
|
|
3987
|
-
const
|
|
3988
|
-
if (
|
|
4026
|
+
const A = S.slice(6).trim();
|
|
4027
|
+
if (A === "[DONE]")
|
|
3989
4028
|
return r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (o = r.onComplete) == null || o.call(r), { abort: () => a.abort() };
|
|
3990
4029
|
try {
|
|
3991
|
-
const
|
|
3992
|
-
if (!
|
|
3993
|
-
(c = r.onChunk) == null || c.call(r,
|
|
3994
|
-
const _ = e.state.tr.insertText(
|
|
4030
|
+
const u = JSON.parse(A), v = u.content || u.text || ((l = u.delta) == null ? void 0 : l.content) || "";
|
|
4031
|
+
if (!v) continue;
|
|
4032
|
+
(c = r.onChunk) == null || c.call(r, v);
|
|
4033
|
+
const _ = e.state.tr.insertText(v, y);
|
|
3995
4034
|
e.view.dispatch(_), y = _.mapping.map(y, 1);
|
|
3996
4035
|
} catch {
|
|
3997
4036
|
}
|
|
3998
4037
|
}
|
|
3999
4038
|
}
|
|
4000
4039
|
r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (d = r.onComplete) == null || d.call(r);
|
|
4001
|
-
} catch (
|
|
4002
|
-
|
|
4040
|
+
} catch (h) {
|
|
4041
|
+
h.name === "AbortError" ? (m = r.onAbort) == null || m.call(r) : (g = r.onError) == null || g.call(r, h instanceof Error ? h : new Error(String(h)));
|
|
4003
4042
|
}
|
|
4004
4043
|
return { abort: () => a.abort() };
|
|
4005
4044
|
}
|
|
@@ -4110,7 +4149,7 @@ S103:局部实时避障控制。采用模型预测控制(MPC)策略,以
|
|
|
4110
4149
|
S104:安全验证。对计算得到的控制指令进行轨迹传播仿真,验证机动后轨迹在未来72小时内不会与TLE目录中的已知空间目标产生碰撞风险(miss distance > 1km)。`,
|
|
4111
4150
|
en: "The technical solution of the embodiments of the present invention will be described clearly and completely below with reference to the drawings."
|
|
4112
4151
|
}
|
|
4113
|
-
},
|
|
4152
|
+
}, Le = {
|
|
4114
4153
|
"help-draft": {
|
|
4115
4154
|
zh: `当然可以帮你撰写技术方案!请先描述以下信息:
|
|
4116
4155
|
|
|
@@ -4169,7 +4208,7 @@ S104:安全验证。对计算得到的控制指令进行轨迹传播仿真,
|
|
|
4169
4208
|
你可以选中文档中的文字使用浮动菜单的AI操作,或者在左侧面板点击章节的"AI生成"按钮来体验这些功能。`,
|
|
4170
4209
|
en: "That is a great question. As an AI patent writing assistant, I can help you with..."
|
|
4171
4210
|
}
|
|
4172
|
-
},
|
|
4211
|
+
}, ne = (e) => new Promise((t) => setTimeout(t, e));
|
|
4173
4212
|
function rt(e, t = 30) {
|
|
4174
4213
|
let n = !1;
|
|
4175
4214
|
return new ReadableStream({
|
|
@@ -4179,7 +4218,7 @@ function rt(e, t = 30) {
|
|
|
4179
4218
|
r.close();
|
|
4180
4219
|
return;
|
|
4181
4220
|
}
|
|
4182
|
-
r.enqueue(a), a.type === "delta" && await
|
|
4221
|
+
r.enqueue(a), a.type === "delta" && await ne(t);
|
|
4183
4222
|
}
|
|
4184
4223
|
r.close();
|
|
4185
4224
|
},
|
|
@@ -4203,7 +4242,7 @@ function $e(e, t) {
|
|
|
4203
4242
|
function bi(e, t, n) {
|
|
4204
4243
|
const r = n === "zh", a = [];
|
|
4205
4244
|
let i;
|
|
4206
|
-
if (e.includes("技术方案") || e.includes("draft") ? i =
|
|
4245
|
+
if (e.includes("技术方案") || e.includes("draft") ? i = Le["help-draft"][r ? "zh" : "en"] : e.includes("审查") || e.includes("review") || e.includes("Review") ? i = Le.review[r ? "zh" : "en"] : e.includes("权利要求") || e.includes("claims") || e.includes("Optimize") ? i = Le.claims[r ? "zh" : "en"] : i = Le.default[r ? "zh" : "en"], t.length > 0) {
|
|
4207
4246
|
const s = r ? `正在分析引用的 ${t.length} 段文本并生成优化建议...
|
|
4208
4247
|
|
|
4209
4248
|
` : `Analyzing ${t.length} referenced text(s) and generating suggestions...
|
|
@@ -4253,7 +4292,7 @@ function Vs() {
|
|
|
4253
4292
|
return {
|
|
4254
4293
|
async request(t) {
|
|
4255
4294
|
var o;
|
|
4256
|
-
if (e = new AbortController(), await
|
|
4295
|
+
if (e = new AbortController(), await ne(300), e.signal.aborted)
|
|
4257
4296
|
throw new DOMException("Aborted", "AbortError");
|
|
4258
4297
|
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];
|
|
4259
4298
|
let i = a;
|
|
@@ -4275,7 +4314,7 @@ function Js() {
|
|
|
4275
4314
|
let t = null, n = null;
|
|
4276
4315
|
return {
|
|
4277
4316
|
async createSession(r, a, i) {
|
|
4278
|
-
await
|
|
4317
|
+
await ne(100);
|
|
4279
4318
|
const s = `sess_${Date.now()}`, o = {
|
|
4280
4319
|
sessionId: s,
|
|
4281
4320
|
patentId: r || void 0,
|
|
@@ -4287,21 +4326,21 @@ function Js() {
|
|
|
4287
4326
|
return e.set(s, { session: o, messages: [] }), o;
|
|
4288
4327
|
},
|
|
4289
4328
|
async listSessions() {
|
|
4290
|
-
await
|
|
4329
|
+
await ne(50);
|
|
4291
4330
|
const r = Array.from(e.values()).map((a) => a.session);
|
|
4292
4331
|
return { total: r.length, items: r };
|
|
4293
4332
|
},
|
|
4294
4333
|
async getMessages(r) {
|
|
4295
|
-
await
|
|
4334
|
+
await ne(50);
|
|
4296
4335
|
const a = e.get(r);
|
|
4297
4336
|
if (!a) throw new Error("Session not found");
|
|
4298
4337
|
return { total: a.messages.length, items: a.messages };
|
|
4299
4338
|
},
|
|
4300
4339
|
async deleteSession(r) {
|
|
4301
|
-
await
|
|
4340
|
+
await ne(50), e.delete(r);
|
|
4302
4341
|
},
|
|
4303
4342
|
async sendMessage(r, a) {
|
|
4304
|
-
await
|
|
4343
|
+
await ne(150);
|
|
4305
4344
|
const i = e.get(r);
|
|
4306
4345
|
if (!i) throw new Error("Session not found");
|
|
4307
4346
|
const s = `msg_${Date.now()}`;
|
|
@@ -4321,7 +4360,7 @@ function Js() {
|
|
|
4321
4360
|
return n = { messageId: s, events: o }, { messageId: s, sessionId: r, status: "processing" };
|
|
4322
4361
|
},
|
|
4323
4362
|
async subscribeStream(r, a) {
|
|
4324
|
-
t = new AbortController(), await
|
|
4363
|
+
t = new AbortController(), await ne(100);
|
|
4325
4364
|
const i = e.get(r);
|
|
4326
4365
|
if (!i) throw new Error("Session not found");
|
|
4327
4366
|
if (!n || n.messageId !== a)
|
|
@@ -4360,8 +4399,8 @@ function vi(e) {
|
|
|
4360
4399
|
if (a.length === 0)
|
|
4361
4400
|
return t.push({ number: 1, text: n, dependsOn: [] }), t;
|
|
4362
4401
|
for (let s = 0; s < a.length; s++) {
|
|
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,
|
|
4364
|
-
t.push({ number: d, text: c, dependsOn:
|
|
4402
|
+
const o = a[s].index + a[s].matchLength, l = s + 1 < a.length ? a[s + 1].index : n.length, c = n.slice(o, l).trim(), d = a[s].number, m = wi(c, d);
|
|
4403
|
+
t.push({ number: d, text: c, dependsOn: m });
|
|
4365
4404
|
}
|
|
4366
4405
|
return t;
|
|
4367
4406
|
}
|
|
@@ -4390,7 +4429,7 @@ function Ks(e) {
|
|
|
4390
4429
|
const xi = -1, Ci = 1, Ti = 0, at = new we("docDiff");
|
|
4391
4430
|
let Ye = null;
|
|
4392
4431
|
function Si() {
|
|
4393
|
-
return Ye || (Ye = new
|
|
4432
|
+
return Ye || (Ye = new Lt()), Ye;
|
|
4394
4433
|
}
|
|
4395
4434
|
function Ei(e, t, n) {
|
|
4396
4435
|
const r = [];
|
|
@@ -4407,31 +4446,31 @@ function Xs(e, t) {
|
|
|
4407
4446
|
s.diff_cleanupSemantic(o);
|
|
4408
4447
|
const l = [];
|
|
4409
4448
|
let c = 0;
|
|
4410
|
-
for (const [
|
|
4411
|
-
if (
|
|
4412
|
-
c +=
|
|
4413
|
-
else if (
|
|
4414
|
-
let
|
|
4415
|
-
for (;
|
|
4416
|
-
for (;
|
|
4417
|
-
if (
|
|
4418
|
-
const b =
|
|
4419
|
-
for (;
|
|
4420
|
-
const y =
|
|
4449
|
+
for (const [g, h] of o)
|
|
4450
|
+
if (g === Ti)
|
|
4451
|
+
c += h.length;
|
|
4452
|
+
else if (g === Ci) {
|
|
4453
|
+
let p = 0;
|
|
4454
|
+
for (; p < h.length; ) {
|
|
4455
|
+
for (; p < h.length && h[p] === "\0"; ) p++;
|
|
4456
|
+
if (p >= h.length) break;
|
|
4457
|
+
const b = p;
|
|
4458
|
+
for (; p < h.length && h[p] !== "\0"; ) p++;
|
|
4459
|
+
const y = be(i, c + b), w = be(i, c + p);
|
|
4421
4460
|
if (y >= 0 && w >= 0 && w > y)
|
|
4422
4461
|
for (const T of Ei(n, y, w))
|
|
4423
4462
|
l.push(
|
|
4424
|
-
|
|
4463
|
+
ae.inline(T.from, T.to, { class: "patch-diff-insert-inline" })
|
|
4425
4464
|
);
|
|
4426
4465
|
}
|
|
4427
|
-
c +=
|
|
4428
|
-
} else if (
|
|
4429
|
-
const
|
|
4430
|
-
if (
|
|
4431
|
-
const b =
|
|
4466
|
+
c += h.length;
|
|
4467
|
+
} else if (g === xi) {
|
|
4468
|
+
const p = be(i, c);
|
|
4469
|
+
if (p >= 0) {
|
|
4470
|
+
const b = h.replace(/\0/g, " ");
|
|
4432
4471
|
l.push(
|
|
4433
|
-
|
|
4434
|
-
|
|
4472
|
+
ae.widget(
|
|
4473
|
+
p,
|
|
4435
4474
|
() => {
|
|
4436
4475
|
const y = document.createElement("span");
|
|
4437
4476
|
return y.className = "patch-diff-delete", y.textContent = b, y;
|
|
@@ -4441,19 +4480,19 @@ function Xs(e, t) {
|
|
|
4441
4480
|
);
|
|
4442
4481
|
}
|
|
4443
4482
|
}
|
|
4444
|
-
const d =
|
|
4483
|
+
const d = de.create(n, l), m = new Be({
|
|
4445
4484
|
key: at,
|
|
4446
4485
|
state: {
|
|
4447
4486
|
init: () => d,
|
|
4448
|
-
apply: (
|
|
4487
|
+
apply: (g, h) => g.docChanged ? h.map(g.mapping, g.doc) : h
|
|
4449
4488
|
},
|
|
4450
4489
|
props: {
|
|
4451
|
-
decorations(
|
|
4452
|
-
return at.getState(
|
|
4490
|
+
decorations(g) {
|
|
4491
|
+
return at.getState(g);
|
|
4453
4492
|
}
|
|
4454
4493
|
}
|
|
4455
4494
|
});
|
|
4456
|
-
e.registerPlugin(
|
|
4495
|
+
e.registerPlugin(m);
|
|
4457
4496
|
}
|
|
4458
4497
|
function Ys(e) {
|
|
4459
4498
|
e.unregisterPlugin(at);
|
|
@@ -4517,7 +4556,7 @@ function Ze(e) {
|
|
|
4517
4556
|
return new He({
|
|
4518
4557
|
children: [new Ue({ text: e, size: 24, font: "宋体" })],
|
|
4519
4558
|
spacing: { line: 360 },
|
|
4520
|
-
indent: { firstLine:
|
|
4559
|
+
indent: { firstLine: ye(7) }
|
|
4521
4560
|
});
|
|
4522
4561
|
}
|
|
4523
4562
|
function Ai(e, t) {
|
|
@@ -4556,10 +4595,10 @@ async function Zs(e, t) {
|
|
|
4556
4595
|
properties: {
|
|
4557
4596
|
page: {
|
|
4558
4597
|
margin: {
|
|
4559
|
-
top:
|
|
4560
|
-
bottom:
|
|
4561
|
-
left:
|
|
4562
|
-
right:
|
|
4598
|
+
top: ye(25),
|
|
4599
|
+
bottom: ye(25),
|
|
4600
|
+
left: ye(25),
|
|
4601
|
+
right: ye(20)
|
|
4563
4602
|
}
|
|
4564
4603
|
}
|
|
4565
4604
|
},
|
|
@@ -4625,16 +4664,16 @@ function eo(e, t) {
|
|
|
4625
4664
|
}
|
|
4626
4665
|
if (l === "claims") {
|
|
4627
4666
|
const d = /^(\d+)\s*[.、]/;
|
|
4628
|
-
s.forEach((
|
|
4629
|
-
if (
|
|
4630
|
-
const
|
|
4631
|
-
if (!
|
|
4632
|
-
const b =
|
|
4633
|
-
|
|
4667
|
+
s.forEach((m, g) => {
|
|
4668
|
+
if (m.type.name !== "paragraph") return;
|
|
4669
|
+
const h = m.textContent.trim(), p = d.exec(h);
|
|
4670
|
+
if (!p) return;
|
|
4671
|
+
const b = p[1];
|
|
4672
|
+
h.length > 0 && !h.endsWith("。") && !h.endsWith(".") && n.push({
|
|
4634
4673
|
id: i(),
|
|
4635
4674
|
severity: "warning",
|
|
4636
4675
|
message: r ? `权利要求${b}末尾应以句号结束` : `Claim ${b} should end with a period`,
|
|
4637
|
-
pos: o + 1 +
|
|
4676
|
+
pos: o + 1 + g
|
|
4638
4677
|
});
|
|
4639
4678
|
});
|
|
4640
4679
|
}
|
|
@@ -4643,8 +4682,8 @@ function eo(e, t) {
|
|
|
4643
4682
|
return !0;
|
|
4644
4683
|
}), n;
|
|
4645
4684
|
}
|
|
4646
|
-
const
|
|
4647
|
-
function
|
|
4685
|
+
const Pi = /^(\d+)\s*[.、]\s*/, kt = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g, _t = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
|
|
4686
|
+
function Li(e, t) {
|
|
4648
4687
|
const n = [];
|
|
4649
4688
|
let r;
|
|
4650
4689
|
for (kt.lastIndex = 0; (r = kt.exec(e)) !== null; ) {
|
|
@@ -4687,11 +4726,11 @@ const mn = (e) => {
|
|
|
4687
4726
|
if (n.type.name === "patent_section")
|
|
4688
4727
|
return n.attrs.sectionType === "claims";
|
|
4689
4728
|
if (n.type.name !== "paragraph") return !0;
|
|
4690
|
-
const a = mn(n).trim(), i =
|
|
4729
|
+
const a = mn(n).trim(), i = Pi.exec(a);
|
|
4691
4730
|
if (!i) return !0;
|
|
4692
4731
|
const s = parseInt(i[1], 10);
|
|
4693
4732
|
if (!Number.isFinite(s) || s <= 0) return !0;
|
|
4694
|
-
const o = a.slice(i[0].length).trim(), l =
|
|
4733
|
+
const o = a.slice(i[0].length).trim(), l = Li(o, s);
|
|
4695
4734
|
return t.push({
|
|
4696
4735
|
claimId: `claim_${s}`,
|
|
4697
4736
|
number: s,
|