patent-editor 0.2.14 → 0.2.16
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 +739 -711
- 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,23 +382,27 @@ 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),
|
|
388
402
|
setReplaceTerm: (e) => () => (this.storage.replaceTerm = e, !0),
|
|
389
403
|
setCaseSensitive: (e) => ({ editor: t }) => (this.storage.caseSensitive = e, this.storage.results = ke(t.state.doc, this.storage.searchTerm, e), this.storage.currentIndex = this.storage.results.length > 0 ? 0 : -1, t.view.dispatch(t.state.tr), !0),
|
|
390
|
-
nextSearchResult: () => ({ editor: e }) =>
|
|
391
|
-
|
|
392
|
-
this.storage.currentIndex = (this.storage.currentIndex + 1) % this.storage.results.length;
|
|
393
|
-
const t = this.storage.results[this.storage.currentIndex];
|
|
394
|
-
return t && (e.commands.setTextSelection(t), ft(e)), e.view.dispatch(e.state.tr), !0;
|
|
395
|
-
},
|
|
396
|
-
previousSearchResult: () => ({ editor: e }) => {
|
|
397
|
-
if (this.storage.results.length === 0) return !1;
|
|
398
|
-
this.storage.currentIndex = (this.storage.currentIndex - 1 + this.storage.results.length) % this.storage.results.length;
|
|
399
|
-
const t = this.storage.results[this.storage.currentIndex];
|
|
400
|
-
return t && (e.commands.setTextSelection(t), ft(e)), e.view.dispatch(e.state.tr), !0;
|
|
401
|
-
},
|
|
404
|
+
nextSearchResult: () => ({ editor: e }) => this.storage.results.length === 0 ? !1 : (this.storage.currentIndex = (this.storage.currentIndex + 1) % this.storage.results.length, ft(e, this.storage.results[this.storage.currentIndex]), !0),
|
|
405
|
+
previousSearchResult: () => ({ editor: e }) => this.storage.results.length === 0 ? !1 : (this.storage.currentIndex = (this.storage.currentIndex - 1 + this.storage.results.length) % this.storage.results.length, ft(e, this.storage.results[this.storage.currentIndex]), !0),
|
|
402
406
|
replaceCurrent: () => ({ editor: e }) => {
|
|
403
407
|
if (this.storage.results.length === 0 || this.storage.currentIndex < 0) return !1;
|
|
404
408
|
const t = this.storage.results[this.storage.currentIndex];
|
|
@@ -439,31 +443,31 @@ const ia = Oe.create({
|
|
|
439
443
|
props: {
|
|
440
444
|
decorations: (t) => {
|
|
441
445
|
if (!e.searchTerm || e.results.length === 0)
|
|
442
|
-
return
|
|
443
|
-
const n =
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
446
|
+
return de.empty;
|
|
447
|
+
const n = t.doc.content.size, r = [];
|
|
448
|
+
return e.results.forEach((a, i) => {
|
|
449
|
+
if (a.from < 0 || a.to > n || a.from >= a.to) return;
|
|
450
|
+
const s = i === e.currentIndex ? "search-highlight search-highlight--current" : "search-highlight";
|
|
451
|
+
r.push(ae.inline(a.from, a.to, { class: s }));
|
|
452
|
+
}), r.length === 0 ? de.empty : de.create(t.doc, r);
|
|
448
453
|
}
|
|
449
454
|
}
|
|
450
455
|
})
|
|
451
456
|
];
|
|
452
457
|
}
|
|
453
458
|
});
|
|
454
|
-
function ft(e) {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
});
|
|
459
|
+
function ft(e, t) {
|
|
460
|
+
if (!t) {
|
|
461
|
+
e.view.dispatch(e.state.tr);
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
const n = e.state.doc.content.size, r = Math.min(Math.max(t.from, 0), n), a = Math.min(Math.max(t.to, r), n);
|
|
465
|
+
e.chain().setTextSelection({ from: r, to: a }).scrollIntoView().run();
|
|
462
466
|
}
|
|
463
467
|
const sa = -1, oa = 1, pt = 0;
|
|
464
468
|
let Ge = null;
|
|
465
469
|
function ca() {
|
|
466
|
-
return Ge || (Ge = new
|
|
470
|
+
return Ge || (Ge = new Lt()), Ge;
|
|
467
471
|
}
|
|
468
472
|
const jt = new we("patchDiff");
|
|
469
473
|
function la(e, t) {
|
|
@@ -475,12 +479,12 @@ function Gt(e, t, n) {
|
|
|
475
479
|
let a = "", i = !0;
|
|
476
480
|
return e.state.doc.nodesBetween(t, n, (s, o) => {
|
|
477
481
|
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:
|
|
482
|
+
const l = o, c = Math.max(t, l) - l, d = Math.min(n, l + s.nodeSize) - l, m = s.text.slice(c, d);
|
|
483
|
+
r.push({ textIdx: a.length, docPos: l + c, len: m.length }), a += m, i = !1;
|
|
480
484
|
} else s.isLeaf ? (a += "\0", i = !1) : !i && s.isBlock && (a += "\0", i = !0);
|
|
481
485
|
}), { text: a, segments: r };
|
|
482
486
|
}
|
|
483
|
-
function
|
|
487
|
+
function be(e, t) {
|
|
484
488
|
for (const n of e)
|
|
485
489
|
if (t >= n.textIdx && t <= n.textIdx + n.len)
|
|
486
490
|
return n.docPos + (t - n.textIdx);
|
|
@@ -499,7 +503,7 @@ function ht(e, t, n, r, a) {
|
|
|
499
503
|
for (; o <= i.length - t.length; ) {
|
|
500
504
|
const l = i.indexOf(t, o);
|
|
501
505
|
if (l === -1) return null;
|
|
502
|
-
const c =
|
|
506
|
+
const c = be(s, l), d = be(s, l + t.length);
|
|
503
507
|
if (c >= 0 && d >= 0 && !(a && a.has(c)))
|
|
504
508
|
return { from: c, to: d };
|
|
505
509
|
o = l + 1;
|
|
@@ -539,27 +543,27 @@ function Rs(e, t, n, r, a) {
|
|
|
539
543
|
status: "pending"
|
|
540
544
|
};
|
|
541
545
|
}
|
|
542
|
-
const
|
|
546
|
+
const G = /* @__PURE__ */ new Map();
|
|
543
547
|
let De = [];
|
|
544
548
|
function Ms(e) {
|
|
545
549
|
return De.push(e), () => {
|
|
546
550
|
De = De.filter((t) => t !== e);
|
|
547
551
|
};
|
|
548
552
|
}
|
|
549
|
-
function
|
|
553
|
+
function me() {
|
|
550
554
|
De.forEach((e) => e());
|
|
551
555
|
}
|
|
552
556
|
function Fs(e = "default") {
|
|
553
|
-
return [...
|
|
557
|
+
return [...G.get(e) || []];
|
|
554
558
|
}
|
|
555
559
|
function $s(e, t = "default") {
|
|
556
|
-
|
|
560
|
+
G.set(t, e), me();
|
|
557
561
|
}
|
|
558
562
|
function zs(e = "default") {
|
|
559
|
-
|
|
563
|
+
G.delete(e), me();
|
|
560
564
|
}
|
|
561
565
|
function Os(e, t, n = "default") {
|
|
562
|
-
const r =
|
|
566
|
+
const r = G.get(n) || [], a = r.find((o) => o.id === t);
|
|
563
567
|
if (!a || a.status !== "pending") return !1;
|
|
564
568
|
a.status = "accepted";
|
|
565
569
|
const { tr: i } = e.state;
|
|
@@ -579,14 +583,14 @@ function Os(e, t, n = "default") {
|
|
|
579
583
|
const l = s.map(o.from, 1), c = s.map(o.to, -1);
|
|
580
584
|
l >= c && o.type !== "insert" ? o.status = "rejected" : (o.from = l, o.to = o.type === "insert" ? l : c);
|
|
581
585
|
}
|
|
582
|
-
return
|
|
586
|
+
return G.set(n, r.filter((o) => o.id !== t && o.status === "pending")), qe(e), me(), !0;
|
|
583
587
|
}
|
|
584
588
|
function Bs(e, t, n = "default") {
|
|
585
|
-
const r =
|
|
586
|
-
return !a || a.status !== "pending" ? !1 : (a.status = "rejected",
|
|
589
|
+
const r = G.get(n) || [], a = r.find((i) => i.id === t);
|
|
590
|
+
return !a || a.status !== "pending" ? !1 : (a.status = "rejected", G.set(n, r.filter((i) => i.id !== t)), qe(e), me(), !0);
|
|
587
591
|
}
|
|
588
592
|
function Hs(e, t = "default") {
|
|
589
|
-
const a = [...(
|
|
593
|
+
const a = [...(G.get(t) || []).filter((s) => s.status === "pending")].sort((s, o) => o.from - s.from), { tr: i } = e.state;
|
|
590
594
|
for (const s of a)
|
|
591
595
|
if (s.type === "delete")
|
|
592
596
|
i.delete(s.from, s.to);
|
|
@@ -597,10 +601,10 @@ function Hs(e, t = "default") {
|
|
|
597
601
|
i.replaceWith(s.from, s.to, l);
|
|
598
602
|
} else
|
|
599
603
|
i.insertText(s.content, s.from, s.to);
|
|
600
|
-
e.view.dispatch(i),
|
|
604
|
+
e.view.dispatch(i), G.delete(t), qe(e), me();
|
|
601
605
|
}
|
|
602
606
|
function Us(e, t = "default") {
|
|
603
|
-
|
|
607
|
+
G.delete(t), qe(e), me();
|
|
604
608
|
}
|
|
605
609
|
function qe(e) {
|
|
606
610
|
e.view.dispatch(e.state.tr.setMeta(jt, !0));
|
|
@@ -635,13 +639,13 @@ function ua(e, t) {
|
|
|
635
639
|
else if (o === sa) {
|
|
636
640
|
const c = s + l.length;
|
|
637
641
|
i.push(
|
|
638
|
-
|
|
642
|
+
ae.inline(s, c, {
|
|
639
643
|
class: "patch-diff-delete",
|
|
640
644
|
"data-patch-id": t.id
|
|
641
645
|
})
|
|
642
646
|
), s = c;
|
|
643
647
|
} else o === oa && i.push(
|
|
644
|
-
|
|
648
|
+
ae.widget(s, () => {
|
|
645
649
|
const c = document.createElement("span");
|
|
646
650
|
return c.className = "patch-diff-insert-inline", c.textContent = l, c.setAttribute("data-patch-id", t.id), c;
|
|
647
651
|
}, { side: 1 })
|
|
@@ -653,8 +657,8 @@ function ma(e = "default") {
|
|
|
653
657
|
key: jt,
|
|
654
658
|
props: {
|
|
655
659
|
decorations(t) {
|
|
656
|
-
const n = (
|
|
657
|
-
if (n.length === 0) return
|
|
660
|
+
const n = (G.get(e) || []).filter((a) => a.status === "pending");
|
|
661
|
+
if (n.length === 0) return de.empty;
|
|
658
662
|
const r = [];
|
|
659
663
|
for (const a of n) {
|
|
660
664
|
if (a.type === "replace") {
|
|
@@ -668,7 +672,7 @@ function ma(e = "default") {
|
|
|
668
672
|
const i = da(t.doc, a.from, a.to);
|
|
669
673
|
for (const s of i)
|
|
670
674
|
r.push(
|
|
671
|
-
|
|
675
|
+
ae.inline(s.from, s.to, {
|
|
672
676
|
class: "patch-diff-delete",
|
|
673
677
|
"data-patch-id": a.id
|
|
674
678
|
})
|
|
@@ -677,7 +681,7 @@ function ma(e = "default") {
|
|
|
677
681
|
const s = i.length > 0 ? i[i.length - 1].to : a.to, o = a.content.length > 120 || a.content.includes(`
|
|
678
682
|
`);
|
|
679
683
|
r.push(
|
|
680
|
-
|
|
684
|
+
ae.widget(s, () => {
|
|
681
685
|
const l = document.createElement(o ? "div" : "span");
|
|
682
686
|
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
687
|
}, { side: 1 })
|
|
@@ -685,13 +689,13 @@ function ma(e = "default") {
|
|
|
685
689
|
}
|
|
686
690
|
} else
|
|
687
691
|
r.push(
|
|
688
|
-
|
|
692
|
+
ae.widget(a.from, () => {
|
|
689
693
|
const i = document.createElement("span");
|
|
690
694
|
return i.className = "patch-diff-insert-inline", i.textContent = a.content, i.setAttribute("data-patch-id", a.id), i;
|
|
691
695
|
})
|
|
692
696
|
);
|
|
693
697
|
}
|
|
694
|
-
return
|
|
698
|
+
return de.create(t.doc, r);
|
|
695
699
|
}
|
|
696
700
|
}
|
|
697
701
|
});
|
|
@@ -711,7 +715,7 @@ function Jt(e, t) {
|
|
|
711
715
|
);
|
|
712
716
|
});
|
|
713
717
|
}
|
|
714
|
-
const ga =
|
|
718
|
+
const ga = Q.create({
|
|
715
719
|
name: "hardBreak",
|
|
716
720
|
inline: !0,
|
|
717
721
|
group: "inline",
|
|
@@ -753,8 +757,8 @@ const ga = Z.create({
|
|
|
753
757
|
}
|
|
754
758
|
}), ha = [
|
|
755
759
|
An,
|
|
756
|
-
Ln,
|
|
757
760
|
Pn,
|
|
761
|
+
Ln,
|
|
758
762
|
fa,
|
|
759
763
|
Dn.configure({
|
|
760
764
|
levels: [1, 2, 3, 4, 5, 6]
|
|
@@ -845,7 +849,7 @@ class va {
|
|
|
845
849
|
return !r || !r.isActive ? !1 : r.isActive(n);
|
|
846
850
|
}
|
|
847
851
|
async execute(t, n, r, a = {}) {
|
|
848
|
-
var d,
|
|
852
|
+
var d, m, g, h;
|
|
849
853
|
const i = Date.now(), s = a.transaction ?? !0, o = a.rollbackOnFail ?? !0, l = s ? n.editor.getJSON() : null, c = this.commands.get(t);
|
|
850
854
|
if (!c)
|
|
851
855
|
return console.warn(`Command "${t}" not found.`), (d = a.onComplete) == null || d.call(a, {
|
|
@@ -854,7 +858,7 @@ class va {
|
|
|
854
858
|
durationMs: Date.now() - i
|
|
855
859
|
}), !1;
|
|
856
860
|
if (!this.canExecute(t, n, r))
|
|
857
|
-
return (
|
|
861
|
+
return (m = a.onComplete) == null || m.call(a, {
|
|
858
862
|
name: t,
|
|
859
863
|
success: !1,
|
|
860
864
|
durationMs: Date.now() - i
|
|
@@ -867,16 +871,16 @@ class va {
|
|
|
867
871
|
success: b,
|
|
868
872
|
durationMs: Date.now() - i
|
|
869
873
|
};
|
|
870
|
-
return (
|
|
871
|
-
} catch (
|
|
874
|
+
return (g = a.onComplete) == null || g.call(a, y), b;
|
|
875
|
+
} catch (p) {
|
|
872
876
|
l && o && n.editor.commands.setContent(l);
|
|
873
877
|
const b = {
|
|
874
878
|
name: t,
|
|
875
879
|
success: !1,
|
|
876
880
|
durationMs: Date.now() - i,
|
|
877
|
-
error:
|
|
881
|
+
error: p
|
|
878
882
|
};
|
|
879
|
-
return (
|
|
883
|
+
return (h = a.onComplete) == null || h.call(a, b), !1;
|
|
880
884
|
}
|
|
881
885
|
}
|
|
882
886
|
getCommand(t) {
|
|
@@ -1225,7 +1229,7 @@ const Ie = () => {
|
|
|
1225
1229
|
document.querySelectorAll('body > svg[id^="standalone-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
|
|
1226
1230
|
(e.id.startsWith("dmermaid") || e.id.startsWith("dstandalone")) && e.remove();
|
|
1227
1231
|
}), 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 =
|
|
1232
|
+
}, xa = Q.create({
|
|
1229
1233
|
name: "mermaid",
|
|
1230
1234
|
group: "block",
|
|
1231
1235
|
atom: !0,
|
|
@@ -1255,30 +1259,30 @@ const Ie = () => {
|
|
|
1255
1259
|
c.className = "mermaid-edit";
|
|
1256
1260
|
const d = document.createElement("textarea");
|
|
1257
1261
|
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";
|
|
1262
|
+
const m = document.createElement("div");
|
|
1263
|
+
m.className = "mermaid-edit-toolbar";
|
|
1264
|
+
const g = document.createElement("span");
|
|
1265
|
+
g.className = "mermaid-error-msg";
|
|
1264
1266
|
const h = document.createElement("button");
|
|
1265
|
-
h.className = "mermaid-
|
|
1266
|
-
const
|
|
1267
|
+
h.className = "mermaid-cancel-btn", h.type = "button";
|
|
1268
|
+
const p = document.createElement("button");
|
|
1269
|
+
p.className = "mermaid-save-btn", p.type = "button", m.append(g, h, p), c.append(d, m), i.append(s, c);
|
|
1270
|
+
const b = (v) => {
|
|
1267
1271
|
const _ = typeof n == "function" ? n() : null;
|
|
1268
|
-
typeof _ == "number" && e.commands.command(({ tr:
|
|
1272
|
+
typeof _ == "number" && e.commands.command(({ tr: N, dispatch: D }) => (N.setNodeMarkup(_, void 0, { ...r.attrs, ...v }), D && D(N), !0));
|
|
1269
1273
|
};
|
|
1270
1274
|
let y = "";
|
|
1271
|
-
const w = async (
|
|
1272
|
-
const _ =
|
|
1275
|
+
const w = async (v) => {
|
|
1276
|
+
const _ = v.trim();
|
|
1273
1277
|
if (_ !== y) {
|
|
1274
1278
|
if (!_) {
|
|
1275
1279
|
o.innerHTML = "", y = "";
|
|
1276
1280
|
return;
|
|
1277
1281
|
}
|
|
1278
1282
|
try {
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1281
|
-
const D = `standalone-mermaid-${_e}`, { svg: z } = await
|
|
1283
|
+
const N = await import("mermaid");
|
|
1284
|
+
N.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
|
|
1285
|
+
const D = `standalone-mermaid-${_e}`, { svg: z } = await N.default.render(D, _);
|
|
1282
1286
|
o.innerHTML = z, y = _;
|
|
1283
1287
|
} catch {
|
|
1284
1288
|
o.innerHTML = "", y = "";
|
|
@@ -1287,54 +1291,54 @@ const Ie = () => {
|
|
|
1287
1291
|
}
|
|
1288
1292
|
}
|
|
1289
1293
|
}, T = () => {
|
|
1290
|
-
a || (a = !0, d.value = typeof r.attrs.code == "string" ? r.attrs.code : "",
|
|
1291
|
-
},
|
|
1294
|
+
a || (a = !0, d.value = typeof r.attrs.code == "string" ? r.attrs.code : "", g.textContent = "", g.style.display = "none", S(), requestAnimationFrame(() => d.focus()));
|
|
1295
|
+
}, C = () => {
|
|
1292
1296
|
a = !1, S();
|
|
1293
1297
|
}, x = async () => {
|
|
1294
|
-
const
|
|
1295
|
-
|
|
1296
|
-
const _ =
|
|
1298
|
+
const v = d.value;
|
|
1299
|
+
g.textContent = "", g.style.display = "none";
|
|
1300
|
+
const _ = v.trim();
|
|
1297
1301
|
if (_)
|
|
1298
1302
|
try {
|
|
1299
|
-
const
|
|
1300
|
-
|
|
1301
|
-
const D = `standalone-mermaid-${_e}`, { svg: z } = await
|
|
1303
|
+
const N = await import("mermaid");
|
|
1304
|
+
N.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
|
|
1305
|
+
const D = `standalone-mermaid-${_e}`, { svg: z } = await N.default.render(D, _);
|
|
1302
1306
|
o.innerHTML = z, y = _, Ie();
|
|
1303
1307
|
} catch {
|
|
1304
1308
|
Ie();
|
|
1305
|
-
const
|
|
1306
|
-
|
|
1309
|
+
const N = I.getState().editorLanguage;
|
|
1310
|
+
g.textContent = N === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", g.style.display = "inline";
|
|
1307
1311
|
return;
|
|
1308
1312
|
}
|
|
1309
|
-
b({ code:
|
|
1313
|
+
b({ code: v }), a = !1, S();
|
|
1310
1314
|
};
|
|
1311
|
-
s.addEventListener("dblclick", (
|
|
1312
|
-
|
|
1313
|
-
}),
|
|
1314
|
-
|
|
1315
|
-
}),
|
|
1316
|
-
|
|
1317
|
-
}), d.addEventListener("mousedown", (
|
|
1315
|
+
s.addEventListener("dblclick", (v) => {
|
|
1316
|
+
v.preventDefault(), v.stopPropagation(), T();
|
|
1317
|
+
}), p.addEventListener("click", (v) => {
|
|
1318
|
+
v.stopPropagation(), x();
|
|
1319
|
+
}), h.addEventListener("click", (v) => {
|
|
1320
|
+
v.stopPropagation(), C();
|
|
1321
|
+
}), d.addEventListener("mousedown", (v) => v.stopPropagation()), d.addEventListener("keydown", (v) => v.stopPropagation()), d.addEventListener("keypress", (v) => v.stopPropagation());
|
|
1318
1322
|
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 &&
|
|
1323
|
+
const v = I.getState().editorLanguage, _ = H(v), N = typeof r.attrs.code == "string" ? r.attrs.code : "";
|
|
1324
|
+
s.style.display = a ? "none" : "block", c.style.display = a ? "block" : "none", p.textContent = _.mermaidSaveAndRender || "保存并渲染", h.textContent = _.mermaidCancel || "取消";
|
|
1325
|
+
const D = N.trim().length > 0, z = o.querySelector("svg") !== null;
|
|
1326
|
+
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
1327
|
};
|
|
1324
|
-
let
|
|
1325
|
-
const
|
|
1326
|
-
|
|
1328
|
+
let A = I.getState().editorLanguage;
|
|
1329
|
+
const u = I.subscribe((v) => {
|
|
1330
|
+
v.editorLanguage !== A && (A = v.editorLanguage, S());
|
|
1327
1331
|
});
|
|
1328
1332
|
return S(), {
|
|
1329
1333
|
dom: i,
|
|
1330
|
-
stopEvent: (
|
|
1331
|
-
const _ =
|
|
1334
|
+
stopEvent: (v) => {
|
|
1335
|
+
const _ = v.target;
|
|
1332
1336
|
return !!(_ === d || c.contains(_));
|
|
1333
1337
|
},
|
|
1334
1338
|
ignoreMutation: () => !0,
|
|
1335
|
-
update: (
|
|
1339
|
+
update: (v) => v.type.name !== "mermaid" ? !1 : (r = v, S(), !0),
|
|
1336
1340
|
destroy: () => {
|
|
1337
|
-
|
|
1341
|
+
u(), Ie();
|
|
1338
1342
|
}
|
|
1339
1343
|
};
|
|
1340
1344
|
};
|
|
@@ -1367,7 +1371,7 @@ const Ie = () => {
|
|
|
1367
1371
|
}
|
|
1368
1372
|
}
|
|
1369
1373
|
}
|
|
1370
|
-
}, Ve = "https://draw.goatpatent.com", Ta =
|
|
1374
|
+
}, Ve = "https://draw.goatpatent.com", Ta = Q.create({
|
|
1371
1375
|
name: "drawio",
|
|
1372
1376
|
group: "block",
|
|
1373
1377
|
atom: !0,
|
|
@@ -1395,59 +1399,59 @@ const Ie = () => {
|
|
|
1395
1399
|
const l = document.createElement("div");
|
|
1396
1400
|
l.className = "drawio-view-hint", s.append(o, l), i.append(s);
|
|
1397
1401
|
const c = (T) => {
|
|
1398
|
-
const
|
|
1399
|
-
typeof
|
|
1402
|
+
const C = typeof n == "function" ? n() : null;
|
|
1403
|
+
typeof C == "number" && e.commands.command(({ tr: x, dispatch: S }) => (x.setNodeMarkup(C, void 0, { ...r.attrs, ...T }), S && S(x), !0));
|
|
1400
1404
|
};
|
|
1401
|
-
let d = null,
|
|
1402
|
-
const
|
|
1405
|
+
let d = null, m = null, g = null;
|
|
1406
|
+
const h = () => {
|
|
1403
1407
|
if (a) return;
|
|
1404
|
-
a = !0,
|
|
1408
|
+
a = !0, m = document.createElement("div"), m.className = "drawio-modal-overlay";
|
|
1405
1409
|
const T = document.createElement("div");
|
|
1406
1410
|
T.className = "drawio-modal-content";
|
|
1407
|
-
const
|
|
1408
|
-
|
|
1411
|
+
const C = document.createElement("div");
|
|
1412
|
+
C.className = "drawio-modal-header";
|
|
1409
1413
|
const x = I.getState().editorLanguage, S = document.createElement("span");
|
|
1410
1414
|
S.textContent = x === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", S.className = "drawio-modal-title";
|
|
1411
|
-
const
|
|
1412
|
-
|
|
1413
|
-
const
|
|
1414
|
-
|
|
1415
|
-
const
|
|
1415
|
+
const A = document.createElement("button");
|
|
1416
|
+
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);
|
|
1417
|
+
const u = x === "en" ? "en" : "zh";
|
|
1418
|
+
g.src = `${Ve}/?embed=1&proto=json&spin=1&lang=${u}`;
|
|
1419
|
+
const v = g;
|
|
1416
1420
|
d = (_) => {
|
|
1417
1421
|
var D, z;
|
|
1418
|
-
if (!
|
|
1419
|
-
let
|
|
1422
|
+
if (!v || _.source !== v.contentWindow) return;
|
|
1423
|
+
let N;
|
|
1420
1424
|
try {
|
|
1421
|
-
|
|
1425
|
+
N = typeof _.data == "string" ? JSON.parse(_.data) : _.data;
|
|
1422
1426
|
} catch {
|
|
1423
1427
|
return;
|
|
1424
1428
|
}
|
|
1425
|
-
if (
|
|
1426
|
-
const
|
|
1427
|
-
(D =
|
|
1428
|
-
JSON.stringify({ action: "load", autosave: 0, xml:
|
|
1429
|
+
if (N.event === "init") {
|
|
1430
|
+
const ee = typeof r.attrs.xml == "string" ? r.attrs.xml : "";
|
|
1431
|
+
(D = v.contentWindow) == null || D.postMessage(
|
|
1432
|
+
JSON.stringify({ action: "load", autosave: 0, xml: ee || "" }),
|
|
1429
1433
|
Ve
|
|
1430
1434
|
);
|
|
1431
|
-
} else if (
|
|
1432
|
-
const
|
|
1433
|
-
(z =
|
|
1435
|
+
} else if (N.event === "save") {
|
|
1436
|
+
const ee = N.xml || "";
|
|
1437
|
+
(z = v.contentWindow) == null || z.postMessage(
|
|
1434
1438
|
JSON.stringify({ action: "export", format: "svg" }),
|
|
1435
1439
|
Ve
|
|
1436
|
-
), c({ xml:
|
|
1437
|
-
} else if (
|
|
1438
|
-
const
|
|
1439
|
-
c({ svg:
|
|
1440
|
-
} else
|
|
1440
|
+
), c({ xml: ee });
|
|
1441
|
+
} else if (N.event === "export") {
|
|
1442
|
+
const ee = N.data || "";
|
|
1443
|
+
c({ svg: ee }), p();
|
|
1444
|
+
} else N.event === "exit" && p();
|
|
1441
1445
|
}, window.addEventListener("message", d);
|
|
1442
|
-
},
|
|
1443
|
-
a = !1, d && (window.removeEventListener("message", d), d = null),
|
|
1446
|
+
}, p = () => {
|
|
1447
|
+
a = !1, d && (window.removeEventListener("message", d), d = null), g && (g.src = "about:blank", g = null), m && (m.remove(), m = null), b();
|
|
1444
1448
|
};
|
|
1445
1449
|
s.addEventListener("dblclick", (T) => {
|
|
1446
|
-
T.preventDefault(), T.stopPropagation(),
|
|
1450
|
+
T.preventDefault(), T.stopPropagation(), h();
|
|
1447
1451
|
});
|
|
1448
1452
|
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 =
|
|
1453
|
+
const T = I.getState().editorLanguage, C = H(T), x = typeof r.attrs.svg == "string" ? r.attrs.svg : "";
|
|
1454
|
+
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
1455
|
};
|
|
1452
1456
|
let y = I.getState().editorLanguage;
|
|
1453
1457
|
const w = I.subscribe((T) => {
|
|
@@ -1458,7 +1462,7 @@ const Ie = () => {
|
|
|
1458
1462
|
ignoreMutation: () => !0,
|
|
1459
1463
|
update: (T) => T.type.name !== "drawio" ? !1 : (r = T, b(), !0),
|
|
1460
1464
|
destroy: () => {
|
|
1461
|
-
w(), d && (window.removeEventListener("message", d), d = null),
|
|
1465
|
+
w(), d && (window.removeEventListener("message", d), d = null), g && (g.src = "about:blank", g = null), m && (m.remove(), m = null);
|
|
1462
1466
|
}
|
|
1463
1467
|
};
|
|
1464
1468
|
};
|
|
@@ -1497,79 +1501,79 @@ const Ie = () => {
|
|
|
1497
1501
|
selected: n,
|
|
1498
1502
|
editor: r
|
|
1499
1503
|
}) => {
|
|
1500
|
-
const a = W(null), [i, s] =
|
|
1501
|
-
|
|
1504
|
+
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 ?? "");
|
|
1505
|
+
F(() => {
|
|
1502
1506
|
c.current = t;
|
|
1503
|
-
}, [t]),
|
|
1507
|
+
}, [t]), F(() => {
|
|
1504
1508
|
d.current = e.attrs.latex ?? "";
|
|
1505
1509
|
}, [e.attrs.latex]);
|
|
1506
|
-
const
|
|
1510
|
+
const m = j(() => {
|
|
1507
1511
|
l.current || (l.current = !0, s(!0));
|
|
1508
|
-
}, []),
|
|
1512
|
+
}, []), g = j(() => {
|
|
1509
1513
|
var b, y;
|
|
1510
1514
|
if (!l.current) return;
|
|
1511
1515
|
l.current = !1;
|
|
1512
|
-
const
|
|
1513
|
-
c.current({ latex:
|
|
1516
|
+
const p = ((b = a.current) == null ? void 0 : b.value) ?? d.current;
|
|
1517
|
+
c.current({ latex: p }), s(!1), (y = globalThis.mathVirtualKeyboard) == null || y.hide({ animate: !0 });
|
|
1514
1518
|
}, []);
|
|
1515
|
-
|
|
1519
|
+
F(() => {
|
|
1516
1520
|
var b, y, w;
|
|
1517
|
-
const
|
|
1518
|
-
n &&
|
|
1519
|
-
}, [n,
|
|
1521
|
+
const p = !!((w = (y = (b = r == null ? void 0 : r.view) == null ? void 0 : b.state) == null ? void 0 : y.selection) != null && w.empty);
|
|
1522
|
+
n && p && m();
|
|
1523
|
+
}, [n, m]), F(() => {
|
|
1520
1524
|
i && requestAnimationFrame(() => {
|
|
1521
1525
|
var b;
|
|
1522
|
-
const
|
|
1523
|
-
|
|
1526
|
+
const p = a.current;
|
|
1527
|
+
p && (p.virtualKeyboardMode = "onfocus", (b = p.focus) == null || b.call(p));
|
|
1524
1528
|
});
|
|
1525
|
-
}, [i]),
|
|
1529
|
+
}, [i]), F(() => {
|
|
1526
1530
|
if (!i) return;
|
|
1527
|
-
const
|
|
1528
|
-
if (!
|
|
1531
|
+
const p = a.current;
|
|
1532
|
+
if (!p) return;
|
|
1529
1533
|
const b = () => {
|
|
1530
1534
|
setTimeout(() => {
|
|
1531
|
-
var T,
|
|
1535
|
+
var T, C, x;
|
|
1532
1536
|
if (!l.current) return;
|
|
1533
1537
|
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") || (
|
|
1538
|
+
(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
1539
|
}, 300);
|
|
1536
1540
|
}, y = (w) => {
|
|
1537
|
-
w.key === "Escape" &&
|
|
1541
|
+
w.key === "Escape" && g();
|
|
1538
1542
|
};
|
|
1539
|
-
return
|
|
1540
|
-
|
|
1543
|
+
return p.addEventListener("focusout", b), p.addEventListener("keydown", y), () => {
|
|
1544
|
+
p.removeEventListener("focusout", b), p.removeEventListener("keydown", y);
|
|
1541
1545
|
};
|
|
1542
|
-
}, [i,
|
|
1546
|
+
}, [i, g]), F(() => {
|
|
1543
1547
|
!i && a.current && a.current.value !== e.attrs.latex && (a.current.value = e.attrs.latex ?? "");
|
|
1544
1548
|
}, [e.attrs.latex, i]);
|
|
1545
|
-
let
|
|
1549
|
+
let h = "";
|
|
1546
1550
|
try {
|
|
1547
|
-
|
|
1551
|
+
h = gr.renderToString(e.attrs.latex || "", {
|
|
1548
1552
|
throwOnError: !1,
|
|
1549
1553
|
displayMode: o
|
|
1550
1554
|
});
|
|
1551
1555
|
} catch {
|
|
1552
|
-
|
|
1556
|
+
h = e.attrs.latex || "";
|
|
1553
1557
|
}
|
|
1554
|
-
return /* @__PURE__ */
|
|
1558
|
+
return /* @__PURE__ */ f(
|
|
1555
1559
|
_n,
|
|
1556
1560
|
{
|
|
1557
1561
|
as: o ? "div" : "span",
|
|
1558
1562
|
className: o ? "math-block" : "math-inline",
|
|
1559
|
-
children: i ? /* @__PURE__ */
|
|
1563
|
+
children: i ? /* @__PURE__ */ f(
|
|
1560
1564
|
"math-field",
|
|
1561
1565
|
{
|
|
1562
1566
|
ref: a,
|
|
1563
1567
|
className: o ? "math-live-field math-live-field--block" : "math-live-field",
|
|
1564
1568
|
children: e.attrs.latex
|
|
1565
1569
|
}
|
|
1566
|
-
) : /* @__PURE__ */
|
|
1567
|
-
/* @__PURE__ */
|
|
1568
|
-
/* @__PURE__ */
|
|
1570
|
+
) : /* @__PURE__ */ P("span", { className: "math-preview", onClick: m, children: [
|
|
1571
|
+
/* @__PURE__ */ f("span", { dangerouslySetInnerHTML: { __html: h } }),
|
|
1572
|
+
/* @__PURE__ */ f("span", { className: "math-tooltip", children: "点击编辑" })
|
|
1569
1573
|
] })
|
|
1570
1574
|
}
|
|
1571
1575
|
);
|
|
1572
|
-
}, Ea =
|
|
1576
|
+
}, Ea = Q.create({
|
|
1573
1577
|
name: "math_inline",
|
|
1574
1578
|
group: "inline",
|
|
1575
1579
|
inline: !0,
|
|
@@ -1595,14 +1599,14 @@ const Ie = () => {
|
|
|
1595
1599
|
return ["span", ie(e, { "data-type": "math_inline" })];
|
|
1596
1600
|
},
|
|
1597
1601
|
addNodeView() {
|
|
1598
|
-
return
|
|
1602
|
+
return Pt(Kt, {
|
|
1599
1603
|
stopEvent: ({ event: e }) => {
|
|
1600
1604
|
const t = e.target;
|
|
1601
1605
|
return t.tagName.toLowerCase() === "math-field" || t.closest("math-field") !== null;
|
|
1602
1606
|
}
|
|
1603
1607
|
});
|
|
1604
1608
|
}
|
|
1605
|
-
}), ka =
|
|
1609
|
+
}), ka = Q.create({
|
|
1606
1610
|
name: "math_block",
|
|
1607
1611
|
group: "block",
|
|
1608
1612
|
atom: !0,
|
|
@@ -1618,7 +1622,7 @@ const Ie = () => {
|
|
|
1618
1622
|
return ["div", ie(e, { "data-type": "math_block" })];
|
|
1619
1623
|
},
|
|
1620
1624
|
addNodeView() {
|
|
1621
|
-
return
|
|
1625
|
+
return Pt(Kt, {
|
|
1622
1626
|
stopEvent: ({ event: e }) => {
|
|
1623
1627
|
const t = e.target;
|
|
1624
1628
|
return t.tagName.toLowerCase() === "math-field" || t.closest("math-field") !== null;
|
|
@@ -1738,7 +1742,7 @@ const Ie = () => {
|
|
|
1738
1742
|
const c = fr(l, n, t.attrs);
|
|
1739
1743
|
return c ? (r.wrap(l, c), i && i(r.scrollIntoView()), s <= o) : !1;
|
|
1740
1744
|
}) : !1;
|
|
1741
|
-
},
|
|
1745
|
+
}, Pa = (e, t) => {
|
|
1742
1746
|
if (t.length === 0)
|
|
1743
1747
|
return !1;
|
|
1744
1748
|
const n = e.getJSON();
|
|
@@ -1746,15 +1750,15 @@ const Ie = () => {
|
|
|
1746
1750
|
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
1751
|
return e.commands.setContent(n), !1;
|
|
1748
1752
|
return !0;
|
|
1749
|
-
},
|
|
1753
|
+
}, ue = "https://draw.goatpatent.com";
|
|
1750
1754
|
let Ne = 0;
|
|
1751
1755
|
const Qe = [];
|
|
1752
1756
|
let Ae = !1;
|
|
1753
|
-
const
|
|
1754
|
-
let $ = null, Me = !1,
|
|
1757
|
+
const La = 2e4, bt = 6e4;
|
|
1758
|
+
let $ = null, Me = !1, re = null, he = null;
|
|
1755
1759
|
const et = /* @__PURE__ */ new Map();
|
|
1756
1760
|
function vt() {
|
|
1757
|
-
|
|
1761
|
+
re && (window.removeEventListener("message", re), re = null), $ && ($.src = "about:blank", $.remove(), $ = null), Me = !1;
|
|
1758
1762
|
}
|
|
1759
1763
|
function Da(e, t) {
|
|
1760
1764
|
const n = et.get(e);
|
|
@@ -1766,24 +1770,24 @@ function Da(e, t) {
|
|
|
1766
1770
|
}
|
|
1767
1771
|
function tt() {
|
|
1768
1772
|
if (Ae || Qe.length === 0) return;
|
|
1769
|
-
Ae = !0,
|
|
1773
|
+
Ae = !0, he && (clearTimeout(he), he = null);
|
|
1770
1774
|
const { xml: e, callback: t } = Qe.shift(), n = et.get(e);
|
|
1771
1775
|
if (n) {
|
|
1772
|
-
t(n), Ae = !1,
|
|
1776
|
+
t(n), Ae = !1, he = setTimeout(vt, bt), tt();
|
|
1773
1777
|
return;
|
|
1774
1778
|
}
|
|
1775
|
-
|
|
1779
|
+
re && (window.removeEventListener("message", re), re = null);
|
|
1776
1780
|
let r = null;
|
|
1777
1781
|
const a = (s) => {
|
|
1778
|
-
r && (clearTimeout(r), r = null), s && et.set(e, s), t(s), Ae = !1,
|
|
1782
|
+
r && (clearTimeout(r), r = null), s && et.set(e, s), t(s), Ae = !1, he = setTimeout(vt, bt), tt();
|
|
1779
1783
|
}, i = () => {
|
|
1780
1784
|
var s;
|
|
1781
1785
|
(s = $.contentWindow) == null || s.postMessage(
|
|
1782
1786
|
JSON.stringify({ action: "load", autosave: 0, xml: e || "" }),
|
|
1783
|
-
|
|
1787
|
+
ue
|
|
1784
1788
|
);
|
|
1785
1789
|
};
|
|
1786
|
-
|
|
1790
|
+
re = (s) => {
|
|
1787
1791
|
if (!$ || s.source !== $.contentWindow) return;
|
|
1788
1792
|
let o;
|
|
1789
1793
|
try {
|
|
@@ -1795,16 +1799,16 @@ function tt() {
|
|
|
1795
1799
|
var l;
|
|
1796
1800
|
(l = $ == null ? void 0 : $.contentWindow) == null || l.postMessage(
|
|
1797
1801
|
JSON.stringify({ action: "export", format: "svg" }),
|
|
1798
|
-
|
|
1802
|
+
ue
|
|
1799
1803
|
);
|
|
1800
1804
|
}, 1500) : o.event === "export" && a(o.data || "");
|
|
1801
|
-
}, window.addEventListener("message",
|
|
1805
|
+
}, window.addEventListener("message", re), r = setTimeout(() => a(""), La), $ ? Me && i() : ($ = document.createElement("iframe"), $.style.cssText = "position:fixed;left:-9999px;top:-9999px;width:1920px;height:1080px;opacity:0;pointer-events:none;", document.body.appendChild($), Me = !1, $.src = `${ue}/?embed=1&proto=json&spin=0&chrome=0`);
|
|
1802
1806
|
}
|
|
1803
|
-
const
|
|
1807
|
+
const Pe = () => {
|
|
1804
1808
|
document.querySelectorAll('body > svg[id^="fig-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
|
|
1805
1809
|
(e.id.startsWith("dmermaid") || e.id.startsWith("dfi")) && e.remove();
|
|
1806
1810
|
}), document.querySelectorAll("body > #dmermaid-svg").forEach((e) => e.remove()), document.querySelectorAll("body > style[data-mermaid-style]").forEach((e) => e.remove());
|
|
1807
|
-
}, Ra =
|
|
1811
|
+
}, Ra = Q.create({
|
|
1808
1812
|
name: "figure",
|
|
1809
1813
|
group: "block",
|
|
1810
1814
|
content: "inline*",
|
|
@@ -1843,209 +1847,209 @@ const Le = () => {
|
|
|
1843
1847
|
c.className = "figure-upload-area";
|
|
1844
1848
|
const d = document.createElement("span");
|
|
1845
1849
|
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");
|
|
1850
|
+
const m = document.createElement("input");
|
|
1851
|
+
m.type = "file", m.accept = "image/*", m.style.display = "none";
|
|
1852
|
+
const g = document.createElement("button");
|
|
1853
|
+
g.className = "figure-replace-btn", c.append(d, m);
|
|
1852
1854
|
const h = document.createElement("div");
|
|
1853
|
-
h.className = "figure-mermaid-
|
|
1855
|
+
h.className = "figure-mermaid-view", h.contentEditable = "false", h.setAttribute("spellcheck", "false");
|
|
1856
|
+
const p = document.createElement("div");
|
|
1857
|
+
p.className = "figure-mermaid-preview", p.contentEditable = "false";
|
|
1854
1858
|
const b = document.createElement("div");
|
|
1855
|
-
b.className = "figure-mermaid-view-hint",
|
|
1859
|
+
b.className = "figure-mermaid-view-hint", h.append(p, b);
|
|
1856
1860
|
const y = document.createElement("div");
|
|
1857
1861
|
y.className = "figure-mermaid-edit";
|
|
1858
1862
|
const w = document.createElement("textarea");
|
|
1859
1863
|
w.className = "figure-mermaid-editor", w.spellcheck = !1;
|
|
1860
1864
|
const T = document.createElement("div");
|
|
1861
1865
|
T.className = "figure-mermaid-toolbar";
|
|
1862
|
-
const
|
|
1863
|
-
|
|
1866
|
+
const C = document.createElement("button");
|
|
1867
|
+
C.className = "figure-mermaid-save-btn", C.type = "button";
|
|
1864
1868
|
const x = document.createElement("button");
|
|
1865
1869
|
x.className = "figure-mermaid-cancel-btn", x.type = "button";
|
|
1866
1870
|
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
|
-
|
|
1871
|
+
S.className = "figure-mermaid-error-inline", T.append(S, x, C), y.append(w, T);
|
|
1872
|
+
const A = document.createElement("div");
|
|
1873
|
+
A.className = "figure-drawio-view", A.contentEditable = "false";
|
|
1874
|
+
const u = document.createElement("img");
|
|
1875
|
+
u.className = "figure-drawio-preview-img", u.style.display = "none";
|
|
1876
|
+
const v = document.createElement("div");
|
|
1877
|
+
v.className = "figure-drawio-view-hint", A.append(u, v), o.append(l, c, g), o.append(h, y), o.append(A);
|
|
1874
1878
|
const _ = document.createElement("figcaption");
|
|
1875
1879
|
_.className = "figure-caption";
|
|
1876
|
-
const
|
|
1877
|
-
|
|
1880
|
+
const N = document.createElement("span");
|
|
1881
|
+
N.className = "figure-id-label", N.contentEditable = "false";
|
|
1878
1882
|
const D = document.createElement("span");
|
|
1879
|
-
D.className = "figure-caption-content", _.append(
|
|
1883
|
+
D.className = "figure-caption-content", _.append(N, D), s.append(o, _);
|
|
1880
1884
|
const z = (E) => {
|
|
1881
1885
|
const k = typeof n == "function" ? n() : null;
|
|
1882
|
-
typeof k == "number" && e.commands.command(({ tr:
|
|
1883
|
-
},
|
|
1886
|
+
typeof k == "number" && e.commands.command(({ tr: L, dispatch: O }) => (L.setNodeMarkup(k, void 0, { ...r.attrs, ...E }), O && O(L), !0));
|
|
1887
|
+
}, ee = (E) => {
|
|
1884
1888
|
if (!E || E.length === 0) return;
|
|
1885
1889
|
const k = E[0];
|
|
1886
1890
|
if (!k.type.startsWith("image/")) return;
|
|
1887
|
-
const
|
|
1888
|
-
|
|
1889
|
-
typeof
|
|
1890
|
-
},
|
|
1891
|
+
const L = new FileReader();
|
|
1892
|
+
L.onload = () => {
|
|
1893
|
+
typeof L.result == "string" && z({ imageSrc: L.result });
|
|
1894
|
+
}, L.readAsDataURL(k);
|
|
1891
1895
|
};
|
|
1892
|
-
|
|
1893
|
-
E.stopPropagation(),
|
|
1896
|
+
m.addEventListener("change", () => ee(m.files)), c.addEventListener("click", () => m.click()), g.addEventListener("click", (E) => {
|
|
1897
|
+
E.stopPropagation(), m.click();
|
|
1894
1898
|
}), o.addEventListener("dragover", (E) => {
|
|
1895
1899
|
r.attrs.contentType === "image" && (E.preventDefault(), E.stopPropagation(), c.classList.add("figure-upload-area--dragover"));
|
|
1896
1900
|
}), o.addEventListener("dragleave", () => {
|
|
1897
1901
|
c.classList.remove("figure-upload-area--dragover");
|
|
1898
1902
|
}), o.addEventListener("drop", (E) => {
|
|
1899
1903
|
var k;
|
|
1900
|
-
c.classList.remove("figure-upload-area--dragover"), r.attrs.contentType === "image" && (E.preventDefault(), E.stopPropagation(),
|
|
1904
|
+
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
1905
|
});
|
|
1902
1906
|
const gn = () => {
|
|
1903
|
-
a || (a = !0, w.value = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "", S.textContent = "", S.style.display = "none",
|
|
1907
|
+
a || (a = !0, w.value = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "", S.textContent = "", S.style.display = "none", K(), requestAnimationFrame(() => w.focus()));
|
|
1904
1908
|
}, fn = () => {
|
|
1905
|
-
a = !1,
|
|
1909
|
+
a = !1, K();
|
|
1906
1910
|
}, pn = async () => {
|
|
1907
1911
|
const E = w.value;
|
|
1908
1912
|
S.textContent = "", S.style.display = "none";
|
|
1909
1913
|
const k = E.trim();
|
|
1910
1914
|
if (k)
|
|
1911
1915
|
try {
|
|
1912
|
-
const
|
|
1913
|
-
|
|
1914
|
-
const O = `fig-mermaid-${Ne}`, { svg: R } = await
|
|
1915
|
-
|
|
1916
|
+
const L = await import("mermaid");
|
|
1917
|
+
L.default.initialize({ startOnLoad: !1, theme: "default" }), Ne += 1;
|
|
1918
|
+
const O = `fig-mermaid-${Ne}`, { svg: R } = await L.default.render(O, k);
|
|
1919
|
+
p.innerHTML = R, Pe();
|
|
1916
1920
|
} catch {
|
|
1917
|
-
|
|
1918
|
-
const
|
|
1919
|
-
S.textContent =
|
|
1921
|
+
Pe();
|
|
1922
|
+
const L = I.getState().editorLanguage;
|
|
1923
|
+
S.textContent = L === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", S.style.display = "inline";
|
|
1920
1924
|
return;
|
|
1921
1925
|
}
|
|
1922
|
-
z({ mermaidCode: E }), a = !1,
|
|
1926
|
+
z({ mermaidCode: E }), a = !1, K();
|
|
1923
1927
|
};
|
|
1924
|
-
|
|
1928
|
+
h.addEventListener("dblclick", (E) => {
|
|
1925
1929
|
E.preventDefault(), E.stopPropagation(), gn();
|
|
1926
|
-
}),
|
|
1930
|
+
}), C.addEventListener("click", (E) => {
|
|
1927
1931
|
E.stopPropagation(), pn();
|
|
1928
1932
|
}), x.addEventListener("click", (E) => {
|
|
1929
1933
|
E.stopPropagation(), fn();
|
|
1930
1934
|
}), w.addEventListener("mousedown", (E) => E.stopPropagation()), w.addEventListener("keydown", (E) => E.stopPropagation()), w.addEventListener("keypress", (E) => E.stopPropagation());
|
|
1931
|
-
let
|
|
1935
|
+
let te = null, V = null, U = null;
|
|
1932
1936
|
const hn = () => {
|
|
1933
1937
|
if (i) return;
|
|
1934
|
-
i = !0,
|
|
1938
|
+
i = !0, K(), V = document.createElement("div"), V.className = "drawio-modal-overlay";
|
|
1935
1939
|
const E = document.createElement("div");
|
|
1936
1940
|
E.className = "drawio-modal-content";
|
|
1937
1941
|
const k = document.createElement("div");
|
|
1938
1942
|
k.className = "drawio-modal-header";
|
|
1939
|
-
const
|
|
1940
|
-
|
|
1943
|
+
const L = document.createElement("span"), O = I.getState().editorLanguage;
|
|
1944
|
+
L.textContent = O === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", L.className = "drawio-modal-title";
|
|
1941
1945
|
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
|
-
|
|
1946
|
+
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);
|
|
1947
|
+
const pe = O === "en" ? "en" : "zh";
|
|
1948
|
+
U.src = `${ue}/?embed=1&proto=json&spin=1&lang=${pe}`;
|
|
1949
|
+
const X = U;
|
|
1950
|
+
te = (Y) => {
|
|
1947
1951
|
var oe, Te;
|
|
1948
|
-
if (!
|
|
1952
|
+
if (!X || Y.source !== X.contentWindow) return;
|
|
1949
1953
|
let q;
|
|
1950
1954
|
try {
|
|
1951
|
-
q = typeof
|
|
1955
|
+
q = typeof Y.data == "string" ? JSON.parse(Y.data) : Y.data;
|
|
1952
1956
|
} catch {
|
|
1953
1957
|
return;
|
|
1954
1958
|
}
|
|
1955
1959
|
if (q.event === "init") {
|
|
1956
1960
|
const ce = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "";
|
|
1957
|
-
(oe =
|
|
1961
|
+
(oe = X.contentWindow) == null || oe.postMessage(
|
|
1958
1962
|
JSON.stringify({ action: "load", autosave: 0, xml: ce || "" }),
|
|
1959
|
-
|
|
1963
|
+
ue
|
|
1960
1964
|
);
|
|
1961
1965
|
} else if (q.event === "save") {
|
|
1962
1966
|
const ce = q.xml || "";
|
|
1963
|
-
(Te =
|
|
1967
|
+
(Te = X.contentWindow) == null || Te.postMessage(
|
|
1964
1968
|
JSON.stringify({ action: "export", format: "svg" }),
|
|
1965
|
-
|
|
1969
|
+
ue
|
|
1966
1970
|
), z({ drawioXml: ce });
|
|
1967
1971
|
} else if (q.event === "export") {
|
|
1968
1972
|
const ce = q.data || "";
|
|
1969
1973
|
z({ drawioSvg: ce }), We();
|
|
1970
1974
|
} else q.event === "exit" && We();
|
|
1971
|
-
}, window.addEventListener("message",
|
|
1975
|
+
}, window.addEventListener("message", te);
|
|
1972
1976
|
}, We = () => {
|
|
1973
|
-
i = !1,
|
|
1977
|
+
i = !1, te && (window.removeEventListener("message", te), te = null), U && (U.src = "about:blank", U = null), V && (V.remove(), V = null), K();
|
|
1974
1978
|
};
|
|
1975
|
-
|
|
1979
|
+
A.addEventListener("dblclick", (E) => {
|
|
1976
1980
|
E.preventDefault(), E.stopPropagation(), hn();
|
|
1977
1981
|
}), s.addEventListener("mousedown", (E) => {
|
|
1978
1982
|
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 =
|
|
1983
|
+
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;
|
|
1984
|
+
const L = typeof n == "function" ? n() : null;
|
|
1985
|
+
if (typeof L != "number") return;
|
|
1986
|
+
const O = L + r.nodeSize - 1, R = Zn.create(e.state.doc, O);
|
|
1983
1987
|
e.view.dispatch(e.state.tr.setSelection(R));
|
|
1984
1988
|
});
|
|
1985
|
-
let xe = !1, se = null,
|
|
1989
|
+
let xe = !1, se = null, ge = null, Ce = 0;
|
|
1986
1990
|
const yn = 2, bn = 1500, vn = 3e3;
|
|
1987
|
-
let
|
|
1991
|
+
let fe = "";
|
|
1988
1992
|
const wn = async (E) => {
|
|
1989
1993
|
const k = E.trim();
|
|
1990
|
-
if (k !==
|
|
1994
|
+
if (k !== fe) {
|
|
1991
1995
|
if (!k) {
|
|
1992
|
-
|
|
1996
|
+
p.innerHTML = "", fe = "";
|
|
1993
1997
|
return;
|
|
1994
1998
|
}
|
|
1995
1999
|
try {
|
|
1996
|
-
const
|
|
1997
|
-
|
|
1998
|
-
const O = `fig-mermaid-${Ne}`, { svg: R } = await
|
|
1999
|
-
|
|
2000
|
+
const L = await import("mermaid");
|
|
2001
|
+
L.default.initialize({ startOnLoad: !1, theme: "default" }), Ne += 1;
|
|
2002
|
+
const O = `fig-mermaid-${Ne}`, { svg: R } = await L.default.render(O, k);
|
|
2003
|
+
p.innerHTML = R, fe = k;
|
|
2000
2004
|
} catch {
|
|
2001
|
-
|
|
2005
|
+
p.innerHTML = "", fe = "";
|
|
2002
2006
|
} finally {
|
|
2003
|
-
|
|
2007
|
+
Pe();
|
|
2004
2008
|
}
|
|
2005
2009
|
}
|
|
2006
|
-
},
|
|
2007
|
-
const E = I.getState().editorLanguage, k = H(E),
|
|
2008
|
-
O ? (
|
|
2009
|
-
const
|
|
2010
|
-
l.style.display =
|
|
2010
|
+
}, K = () => {
|
|
2011
|
+
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 : "";
|
|
2012
|
+
O ? (N.textContent = `[${O}] `, N.style.display = "inline") : (N.textContent = "", N.style.display = "none");
|
|
2013
|
+
const X = L === "image", Y = L === "mermaid", q = L === "drawio";
|
|
2014
|
+
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
2015
|
const oe = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
|
|
2012
|
-
q && (oe ? (
|
|
2013
|
-
const Te =
|
|
2014
|
-
|
|
2016
|
+
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 || "取消";
|
|
2017
|
+
const Te = pe.trim().length > 0, ce = p.querySelector("svg") !== null;
|
|
2018
|
+
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
2019
|
const Cn = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "";
|
|
2016
2020
|
q && Cn && !oe && !xe && !i && (se && clearTimeout(se), se = setTimeout(() => {
|
|
2017
2021
|
se = null;
|
|
2018
2022
|
const dt = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "", Tn = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
|
|
2019
2023
|
!dt || Tn || xe || (xe = !0, Da(dt, (ut) => {
|
|
2020
|
-
xe = !1, ut ? (Ce = 0, z({ drawioSvg: ut })) : Ce < yn && (Ce++,
|
|
2021
|
-
|
|
2024
|
+
xe = !1, ut ? (Ce = 0, z({ drawioSvg: ut })) : Ce < yn && (Ce++, ge = setTimeout(() => {
|
|
2025
|
+
ge = null, K();
|
|
2022
2026
|
}, vn * Ce));
|
|
2023
2027
|
}));
|
|
2024
2028
|
}, bn));
|
|
2025
2029
|
};
|
|
2026
2030
|
let lt = I.getState().editorLanguage;
|
|
2027
2031
|
const xn = I.subscribe((E) => {
|
|
2028
|
-
E.editorLanguage !== lt && (lt = E.editorLanguage,
|
|
2032
|
+
E.editorLanguage !== lt && (lt = E.editorLanguage, K());
|
|
2029
2033
|
});
|
|
2030
|
-
return
|
|
2034
|
+
return K(), {
|
|
2031
2035
|
dom: s,
|
|
2032
2036
|
contentDOM: D,
|
|
2033
2037
|
stopEvent: (E) => {
|
|
2034
2038
|
const k = E.target;
|
|
2035
|
-
return !!(k === w || y.contains(k) || k ===
|
|
2039
|
+
return !!(k === w || y.contains(k) || k === m);
|
|
2036
2040
|
},
|
|
2037
2041
|
ignoreMutation: (E) => {
|
|
2038
2042
|
const k = E.target;
|
|
2039
|
-
return !!(o.contains(k) ||
|
|
2043
|
+
return !!(o.contains(k) || N.contains(k));
|
|
2040
2044
|
},
|
|
2041
|
-
update: (E) => E.type.name !== "figure" ? !1 : (r = E,
|
|
2045
|
+
update: (E) => E.type.name !== "figure" ? !1 : (r = E, K(), !0),
|
|
2042
2046
|
destroy: () => {
|
|
2043
|
-
se && (clearTimeout(se), se = null),
|
|
2047
|
+
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
2048
|
}
|
|
2045
2049
|
};
|
|
2046
2050
|
};
|
|
2047
2051
|
}
|
|
2048
|
-
}), Ma =
|
|
2052
|
+
}), Ma = Q.create({
|
|
2049
2053
|
name: "reference",
|
|
2050
2054
|
group: "inline",
|
|
2051
2055
|
inline: !0,
|
|
@@ -2106,8 +2110,8 @@ const Le = () => {
|
|
|
2106
2110
|
return ({ node: e, editor: t }) => {
|
|
2107
2111
|
let n = e;
|
|
2108
2112
|
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 =
|
|
2113
|
+
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;
|
|
2114
|
+
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
2115
|
};
|
|
2112
2116
|
return a(), r.addEventListener("click", () => {
|
|
2113
2117
|
const i = n.attrs.targetType === "figure" ? "figure" : "claim";
|
|
@@ -2172,7 +2176,7 @@ const Le = () => {
|
|
|
2172
2176
|
return e.forEach((n) => {
|
|
2173
2177
|
!t && ot(n) && (t = !0);
|
|
2174
2178
|
}), t;
|
|
2175
|
-
}, za =
|
|
2179
|
+
}, za = Q.create({
|
|
2176
2180
|
name: "patent_title",
|
|
2177
2181
|
group: "block",
|
|
2178
2182
|
content: "inline*",
|
|
@@ -2214,28 +2218,28 @@ const Le = () => {
|
|
|
2214
2218
|
b !== null && (I.getState().openDraftingPanel("patent_title", b), e.commands.focus(b + 1));
|
|
2215
2219
|
};
|
|
2216
2220
|
s.addEventListener("click", d), o.addEventListener("focusin", c), o.addEventListener("click", c);
|
|
2217
|
-
const
|
|
2221
|
+
const m = () => {
|
|
2218
2222
|
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
2223
|
i.textContent = w;
|
|
2220
|
-
const
|
|
2221
|
-
s.textContent = `[${T}]`, s.style.display =
|
|
2224
|
+
const C = ot(r), x = b.rightPanel.activeSectionPos === l();
|
|
2225
|
+
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
2226
|
};
|
|
2223
|
-
let
|
|
2224
|
-
const
|
|
2225
|
-
const y = b.editorLanguage !==
|
|
2226
|
-
|
|
2227
|
+
let g = I.getState().editorLanguage, h = I.getState().rightPanel.activeSectionPos;
|
|
2228
|
+
const p = I.subscribe((b) => {
|
|
2229
|
+
const y = b.editorLanguage !== g, w = b.rightPanel.activeSectionPos !== h;
|
|
2230
|
+
g = b.editorLanguage, h = b.rightPanel.activeSectionPos, (y || w) && m();
|
|
2227
2231
|
});
|
|
2228
|
-
return
|
|
2232
|
+
return m(), {
|
|
2229
2233
|
dom: a,
|
|
2230
2234
|
contentDOM: o,
|
|
2231
|
-
update: (b) => b.type.name !== "patent_title" ? !1 : (r = b,
|
|
2235
|
+
update: (b) => b.type.name !== "patent_title" ? !1 : (r = b, m(), !0),
|
|
2232
2236
|
destroy: () => {
|
|
2233
|
-
|
|
2237
|
+
p(), s.removeEventListener("click", d), o.removeEventListener("focusin", c), o.removeEventListener("click", c);
|
|
2234
2238
|
}
|
|
2235
2239
|
};
|
|
2236
2240
|
};
|
|
2237
2241
|
}
|
|
2238
|
-
}), Oa =
|
|
2242
|
+
}), Oa = Q.create({
|
|
2239
2243
|
name: "patent_section",
|
|
2240
2244
|
group: "block",
|
|
2241
2245
|
content: "block+",
|
|
@@ -2313,27 +2317,27 @@ const Le = () => {
|
|
|
2313
2317
|
const y = c();
|
|
2314
2318
|
if (y === null) return;
|
|
2315
2319
|
I.getState().setActiveSection(r.attrs.sectionType, y);
|
|
2316
|
-
},
|
|
2320
|
+
}, m = () => {
|
|
2317
2321
|
const y = c();
|
|
2318
2322
|
if (y === null) return;
|
|
2319
2323
|
I.getState().openDraftingPanel(r.attrs.sectionType, y), e.commands.focus(y + 1);
|
|
2320
2324
|
};
|
|
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${
|
|
2325
|
+
o.addEventListener("click", m), l.addEventListener("focusin", d), l.addEventListener("click", d);
|
|
2326
|
+
const g = () => {
|
|
2327
|
+
const y = I.getState(), w = H(y.editorLanguage), T = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", C = Fa.has(T), x = $a.has(T), S = wt[T], A = typeof w[S] == "string" ? w[S] : T, u = ot(r), v = y.rightPanel.activeSectionPos === c();
|
|
2328
|
+
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
2329
|
};
|
|
2326
|
-
let
|
|
2330
|
+
let h = I.getState().editorLanguage, p = I.getState().rightPanel.activeSectionPos;
|
|
2327
2331
|
const b = I.subscribe((y) => {
|
|
2328
|
-
const w = y.editorLanguage !==
|
|
2329
|
-
|
|
2332
|
+
const w = y.editorLanguage !== h, T = y.rightPanel.activeSectionPos !== p;
|
|
2333
|
+
h = y.editorLanguage, p = y.rightPanel.activeSectionPos, (w || T) && g();
|
|
2330
2334
|
});
|
|
2331
|
-
return
|
|
2335
|
+
return g(), {
|
|
2332
2336
|
dom: a,
|
|
2333
2337
|
contentDOM: l,
|
|
2334
|
-
update: (y) => y.type.name !== "patent_section" ? !1 : (r = y,
|
|
2338
|
+
update: (y) => y.type.name !== "patent_section" ? !1 : (r = y, g(), !0),
|
|
2335
2339
|
destroy: () => {
|
|
2336
|
-
b(), o.removeEventListener("click",
|
|
2340
|
+
b(), o.removeEventListener("click", m), l.removeEventListener("focusin", d), l.removeEventListener("click", d);
|
|
2337
2341
|
}
|
|
2338
2342
|
};
|
|
2339
2343
|
};
|
|
@@ -2380,10 +2384,10 @@ const Le = () => {
|
|
|
2380
2384
|
], ja = () => [
|
|
2381
2385
|
en(),
|
|
2382
2386
|
...qa.map(Fe)
|
|
2383
|
-
], tn = (e = "invention") => ({ type: "doc", content: e === "design" ? ja() : Wa() }), ve = (e) => Xt(e, (t) => t.type.name === "figure"),
|
|
2387
|
+
], tn = (e = "invention") => ({ type: "doc", content: e === "design" ? ja() : Wa() }), ve = (e) => Xt(e, (t) => t.type.name === "figure"), J = (e) => typeof e != "string" ? "" : e.trim(), xt = (e) => {
|
|
2384
2388
|
const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = /* @__PURE__ */ new Set();
|
|
2385
2389
|
ve(e).forEach((i) => {
|
|
2386
|
-
const s =
|
|
2390
|
+
const s = J(i.node.attrs.id);
|
|
2387
2391
|
s && r.add(s);
|
|
2388
2392
|
});
|
|
2389
2393
|
let a = 1;
|
|
@@ -2396,7 +2400,7 @@ const Le = () => {
|
|
|
2396
2400
|
const a = [];
|
|
2397
2401
|
let i = 1;
|
|
2398
2402
|
for (const o of r) {
|
|
2399
|
-
const l =
|
|
2403
|
+
const l = J(o.node.attrs.id);
|
|
2400
2404
|
if (!Ga.exec(l)) continue;
|
|
2401
2405
|
const d = `${n}${i}`;
|
|
2402
2406
|
l !== d && a.push({ pos: o.pos, expectedId: d, currentId: l }), i++;
|
|
@@ -2411,7 +2415,7 @@ const Le = () => {
|
|
|
2411
2415
|
}, nn = (e) => {
|
|
2412
2416
|
const t = /* @__PURE__ */ new Map();
|
|
2413
2417
|
return ve(e).forEach((n) => {
|
|
2414
|
-
const r =
|
|
2418
|
+
const r = J(n.node.attrs.id);
|
|
2415
2419
|
r && t.set(r, {
|
|
2416
2420
|
id: r,
|
|
2417
2421
|
pos: n.pos
|
|
@@ -2427,19 +2431,19 @@ const Le = () => {
|
|
|
2427
2431
|
return a.doc.descendants((o, l) => {
|
|
2428
2432
|
if (o.type.name !== "reference" || o.attrs.targetType !== "figure")
|
|
2429
2433
|
return !0;
|
|
2430
|
-
const c = typeof o.attrs.targetFigureId == "string" && o.attrs.targetFigureId ?
|
|
2434
|
+
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
2435
|
...o.attrs,
|
|
2432
2436
|
targetType: "figure",
|
|
2433
2437
|
targetFigureId: c,
|
|
2434
|
-
resolvedFigureId:
|
|
2435
|
-
invalid:
|
|
2438
|
+
resolvedFigureId: m,
|
|
2439
|
+
invalid: g,
|
|
2436
2440
|
lang: n,
|
|
2437
|
-
displayText:
|
|
2438
|
-
target:
|
|
2441
|
+
displayText: h,
|
|
2442
|
+
target: m || o.attrs.target || c || null
|
|
2439
2443
|
};
|
|
2440
|
-
return Object.keys(
|
|
2441
|
-
(y) =>
|
|
2442
|
-
) && (r.setNodeMarkup(l, void 0,
|
|
2444
|
+
return Object.keys(p).some(
|
|
2445
|
+
(y) => p[y] !== o.attrs[y]
|
|
2446
|
+
) && (r.setNodeMarkup(l, void 0, p), s = !0), !0;
|
|
2443
2447
|
}), s && i && (r.setMeta("addToHistory", !1), i(r)), !0;
|
|
2444
2448
|
});
|
|
2445
2449
|
}, Ja = {
|
|
@@ -2471,8 +2475,8 @@ const Le = () => {
|
|
|
2471
2475
|
const i = (n.scope || "all") === "current" ? Re(e, "reference") : null;
|
|
2472
2476
|
return e.commands.command(({ tr: o, state: l, dispatch: c }) => {
|
|
2473
2477
|
let d = !1;
|
|
2474
|
-
return l.doc.descendants((
|
|
2475
|
-
...
|
|
2478
|
+
return l.doc.descendants((m, g) => (m.type.name !== "reference" || i && g !== i.pos || m.attrs.lang !== r && (o.setNodeMarkup(g, void 0, {
|
|
2479
|
+
...m.attrs,
|
|
2476
2480
|
lang: r
|
|
2477
2481
|
}), d = !0), !0)), d && c && (o.setMeta("addToHistory", !1), c(o)), !0;
|
|
2478
2482
|
}) ? (Je(e), !0) : !1;
|
|
@@ -2484,7 +2488,7 @@ const Le = () => {
|
|
|
2484
2488
|
shortcut: "Ctrl+Shift+F",
|
|
2485
2489
|
isActive: ({ editor: e }) => e.isActive("figure"),
|
|
2486
2490
|
execute: ({ editor: e }, t) => {
|
|
2487
|
-
const n = typeof t == "object" && t ? t : {}, r =
|
|
2491
|
+
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
2492
|
return e.chain().focus().insertContent({
|
|
2489
2493
|
type: "figure",
|
|
2490
2494
|
attrs: { id: r, contentType: a, imageSrc: "", mermaidCode: "", drawioXml: "" },
|
|
@@ -2502,8 +2506,8 @@ const Le = () => {
|
|
|
2502
2506
|
const i = e.state.doc.nodeAt(a);
|
|
2503
2507
|
if (!i || i.type.name !== "figure")
|
|
2504
2508
|
return !1;
|
|
2505
|
-
const o = (typeof n.id == "string" ?
|
|
2506
|
-
if (ve(e).some((d) => d.pos === a ? !1 :
|
|
2509
|
+
const o = (typeof n.id == "string" ? J(n.id) : J(i.attrs.id)) || xt(e);
|
|
2510
|
+
if (ve(e).some((d) => d.pos === a ? !1 : J(d.node.attrs.id) === o))
|
|
2507
2511
|
return !1;
|
|
2508
2512
|
const c = { id: o };
|
|
2509
2513
|
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 +2524,7 @@ const Le = () => {
|
|
|
2520
2524
|
const t = /* @__PURE__ */ new Set();
|
|
2521
2525
|
let n = !1;
|
|
2522
2526
|
return ve(e).forEach((r) => {
|
|
2523
|
-
const a =
|
|
2527
|
+
const a = J(r.node.attrs.id);
|
|
2524
2528
|
if (a) {
|
|
2525
2529
|
if (t.has(a)) {
|
|
2526
2530
|
n = !0;
|
|
@@ -2543,7 +2547,7 @@ const Le = () => {
|
|
|
2543
2547
|
return typeof n.targetFigureId == "string" && n.targetFigureId.trim().length > 0;
|
|
2544
2548
|
},
|
|
2545
2549
|
execute: ({ editor: e }, t) => {
|
|
2546
|
-
const n = typeof t == "object" && t ? t : {}, r = nn(e), a = typeof n.targetFigureId == "string" ?
|
|
2550
|
+
const n = typeof t == "object" && t ? t : {}, r = nn(e), a = typeof n.targetFigureId == "string" ? J(n.targetFigureId) : "";
|
|
2547
2551
|
if (!a)
|
|
2548
2552
|
return !1;
|
|
2549
2553
|
const i = r.get(a);
|
|
@@ -2621,7 +2625,7 @@ const Xa = (e = {}) => {
|
|
|
2621
2625
|
updateNodeAttrs: (t) => ze(e, t),
|
|
2622
2626
|
removeNode: (t) => Zt(e, t),
|
|
2623
2627
|
wrapSelection: (t) => Qt(e, t),
|
|
2624
|
-
applyTransactionBatch: (t) =>
|
|
2628
|
+
applyTransactionBatch: (t) => Pa(e, t),
|
|
2625
2629
|
findNodeByType: (t, n) => st(e, t, n),
|
|
2626
2630
|
findAncestorNode: (t) => Re(e, t),
|
|
2627
2631
|
findCurrentBlock: () => Ia(e),
|
|
@@ -2640,58 +2644,58 @@ const Xa = (e = {}) => {
|
|
|
2640
2644
|
}
|
|
2641
2645
|
return e.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join(" ");
|
|
2642
2646
|
}, Ct = ({ btn: e, items: t }) => {
|
|
2643
|
-
const [n, r] =
|
|
2647
|
+
const [n, r] = M(!1), a = W(null), i = W(null), [s, o] = M({ top: 0, left: 0 }), l = j(() => {
|
|
2644
2648
|
if (!a.current) return;
|
|
2645
2649
|
const c = a.current.getBoundingClientRect();
|
|
2646
2650
|
o({ top: c.bottom + 4, left: c.left });
|
|
2647
2651
|
}, []);
|
|
2648
|
-
return
|
|
2652
|
+
return F(() => {
|
|
2649
2653
|
if (!n) return;
|
|
2650
2654
|
l();
|
|
2651
|
-
const c = (
|
|
2652
|
-
var
|
|
2653
|
-
const
|
|
2654
|
-
(
|
|
2655
|
+
const c = (m) => {
|
|
2656
|
+
var h, p;
|
|
2657
|
+
const g = m.target;
|
|
2658
|
+
(h = a.current) != null && h.contains(g) || (p = i.current) != null && p.contains(g) || r(!1);
|
|
2655
2659
|
}, d = () => l();
|
|
2656
2660
|
return document.addEventListener("mousedown", c), window.addEventListener("scroll", d, !0), () => {
|
|
2657
2661
|
document.removeEventListener("mousedown", c), window.removeEventListener("scroll", d, !0);
|
|
2658
2662
|
};
|
|
2659
|
-
}, [n, l]), /* @__PURE__ */
|
|
2660
|
-
/* @__PURE__ */
|
|
2663
|
+
}, [n, l]), /* @__PURE__ */ P("div", { className: "flex items-center", children: [
|
|
2664
|
+
/* @__PURE__ */ f(
|
|
2661
2665
|
"button",
|
|
2662
2666
|
{
|
|
2663
2667
|
onClick: e.run,
|
|
2664
2668
|
disabled: e.disabled,
|
|
2665
|
-
className:
|
|
2669
|
+
className: Z(
|
|
2666
2670
|
"p-2 rounded-l transition-colors",
|
|
2667
2671
|
e.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200",
|
|
2668
2672
|
e.isActive ? "bg-gray-300 text-blue-600" : "text-gray-700"
|
|
2669
2673
|
),
|
|
2670
2674
|
title: e.tooltip,
|
|
2671
|
-
children: /* @__PURE__ */
|
|
2675
|
+
children: /* @__PURE__ */ f(e.icon, { size: 18 })
|
|
2672
2676
|
}
|
|
2673
2677
|
),
|
|
2674
|
-
/* @__PURE__ */
|
|
2678
|
+
/* @__PURE__ */ f(
|
|
2675
2679
|
"button",
|
|
2676
2680
|
{
|
|
2677
2681
|
ref: a,
|
|
2678
2682
|
onClick: () => r((c) => !c),
|
|
2679
|
-
className:
|
|
2683
|
+
className: Z(
|
|
2680
2684
|
"px-1 py-2 rounded-r transition-colors border-l border-gray-200",
|
|
2681
2685
|
e.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200 text-gray-500"
|
|
2682
2686
|
),
|
|
2683
2687
|
disabled: e.disabled,
|
|
2684
|
-
children: /* @__PURE__ */
|
|
2688
|
+
children: /* @__PURE__ */ f(qt, { size: 12 })
|
|
2685
2689
|
}
|
|
2686
2690
|
),
|
|
2687
2691
|
n && yr(
|
|
2688
|
-
/* @__PURE__ */
|
|
2692
|
+
/* @__PURE__ */ f(
|
|
2689
2693
|
"div",
|
|
2690
2694
|
{
|
|
2691
2695
|
ref: i,
|
|
2692
2696
|
className: "bg-white border border-gray-200 rounded shadow-lg min-w-[160px] py-1",
|
|
2693
2697
|
style: { position: "fixed", top: s.top, left: s.left, zIndex: 9999 },
|
|
2694
|
-
children: t.map((c, d) => /* @__PURE__ */
|
|
2698
|
+
children: t.map((c, d) => /* @__PURE__ */ f(
|
|
2695
2699
|
"button",
|
|
2696
2700
|
{
|
|
2697
2701
|
onClick: () => {
|
|
@@ -2713,16 +2717,16 @@ const Xa = (e = {}) => {
|
|
|
2713
2717
|
collapsibleGroups: n = !0,
|
|
2714
2718
|
defaultCollapsedGroups: r = []
|
|
2715
2719
|
}) => {
|
|
2716
|
-
const [a, i] =
|
|
2717
|
-
if (
|
|
2720
|
+
const [a, i] = M(() => new Set(r)), [, s] = M(0), { editorLanguage: o, setEditorLanguage: l } = I(), c = H(o);
|
|
2721
|
+
if (F(() => {
|
|
2718
2722
|
if (!e) return;
|
|
2719
|
-
const
|
|
2720
|
-
return e.on("selectionUpdate",
|
|
2721
|
-
e.off("selectionUpdate",
|
|
2723
|
+
const u = () => s((v) => v + 1);
|
|
2724
|
+
return e.on("selectionUpdate", u), e.on("update", u), () => {
|
|
2725
|
+
e.off("selectionUpdate", u), e.off("update", u);
|
|
2722
2726
|
};
|
|
2723
2727
|
}, [e]), !e)
|
|
2724
2728
|
return null;
|
|
2725
|
-
const d = ct(e),
|
|
2729
|
+
const d = ct(e), m = o === "zh", g = [
|
|
2726
2730
|
{
|
|
2727
2731
|
id: "core-undo",
|
|
2728
2732
|
label: c.undo,
|
|
@@ -2967,7 +2971,7 @@ const Xa = (e = {}) => {
|
|
|
2967
2971
|
id: "core-code-block",
|
|
2968
2972
|
label: c.codeBlock,
|
|
2969
2973
|
group: "structure",
|
|
2970
|
-
icon:
|
|
2974
|
+
icon: Pr,
|
|
2971
2975
|
tooltip: c.codeBlock,
|
|
2972
2976
|
isActive: e.isActive("codeBlock"),
|
|
2973
2977
|
disabled: !1,
|
|
@@ -2979,7 +2983,7 @@ const Xa = (e = {}) => {
|
|
|
2979
2983
|
id: "core-table",
|
|
2980
2984
|
label: c.insertTable,
|
|
2981
2985
|
group: "structure",
|
|
2982
|
-
icon:
|
|
2986
|
+
icon: Lr,
|
|
2983
2987
|
tooltip: c.insertTable,
|
|
2984
2988
|
isActive: !1,
|
|
2985
2989
|
disabled: !1,
|
|
@@ -3011,7 +3015,7 @@ const Xa = (e = {}) => {
|
|
|
3011
3015
|
e.chain().focus().toggleTaskList().run();
|
|
3012
3016
|
}
|
|
3013
3017
|
}
|
|
3014
|
-
],
|
|
3018
|
+
], h = {
|
|
3015
3019
|
GitGraph: Or,
|
|
3016
3020
|
Sigma: zr,
|
|
3017
3021
|
FunctionSquare: $r,
|
|
@@ -3020,98 +3024,98 @@ const Xa = (e = {}) => {
|
|
|
3020
3024
|
FileText: Ut,
|
|
3021
3025
|
Link2: Ht,
|
|
3022
3026
|
Image: Bt
|
|
3023
|
-
},
|
|
3024
|
-
const
|
|
3027
|
+
}, p = B.getToolbarItems().map((u) => {
|
|
3028
|
+
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
3029
|
return {
|
|
3026
|
-
id:
|
|
3027
|
-
label:
|
|
3028
|
-
group:
|
|
3029
|
-
icon:
|
|
3030
|
-
isActive: d.isCommandActive(
|
|
3031
|
-
disabled: !d.canExecCommand(
|
|
3030
|
+
id: u.id,
|
|
3031
|
+
label: u.label,
|
|
3032
|
+
group: u.group || "technical",
|
|
3033
|
+
icon: u.icon ? h[u.icon] || mt : mt,
|
|
3034
|
+
isActive: d.isCommandActive(u.command),
|
|
3035
|
+
disabled: !d.canExecCommand(u.command),
|
|
3032
3036
|
tooltip: D,
|
|
3033
3037
|
run: () => {
|
|
3034
|
-
d.execCommand(
|
|
3038
|
+
d.execCommand(u.command);
|
|
3035
3039
|
}
|
|
3036
3040
|
};
|
|
3037
|
-
}), b = [...
|
|
3038
|
-
group:
|
|
3039
|
-
items: b.filter((
|
|
3040
|
-
})).filter((
|
|
3041
|
-
i((
|
|
3042
|
-
const _ = new Set(
|
|
3043
|
-
return _.has(
|
|
3041
|
+
}), b = [...g, ...p], y = b.map((u) => u.group).filter((u, v, _) => _.indexOf(u) === v && !t.includes(u)), T = [...t, ...y].map((u) => ({
|
|
3042
|
+
group: u,
|
|
3043
|
+
items: b.filter((v) => v.group === u)
|
|
3044
|
+
})).filter((u) => u.items.length > 0), C = (u) => {
|
|
3045
|
+
i((v) => {
|
|
3046
|
+
const _ = new Set(v);
|
|
3047
|
+
return _.has(u) ? _.delete(u) : _.add(u), _;
|
|
3044
3048
|
});
|
|
3045
3049
|
}, x = [
|
|
3046
|
-
{ label:
|
|
3047
|
-
{ label:
|
|
3048
|
-
{ label:
|
|
3049
|
-
{ label:
|
|
3050
|
-
{ label:
|
|
3051
|
-
{ label:
|
|
3052
|
-
{ label:
|
|
3053
|
-
{ label:
|
|
3054
|
-
{ label:
|
|
3055
|
-
{ label:
|
|
3056
|
-
{ label:
|
|
3050
|
+
{ label: m ? "插入表格 3×3" : "Insert Table 3×3", onClick: () => e.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run() },
|
|
3051
|
+
{ label: m ? "上方插入行" : "Add Row Before", onClick: () => e.chain().focus().addRowBefore().run() },
|
|
3052
|
+
{ label: m ? "下方插入行" : "Add Row After", onClick: () => e.chain().focus().addRowAfter().run() },
|
|
3053
|
+
{ label: m ? "左侧插入列" : "Add Column Before", onClick: () => e.chain().focus().addColumnBefore().run() },
|
|
3054
|
+
{ label: m ? "右侧插入列" : "Add Column After", onClick: () => e.chain().focus().addColumnAfter().run() },
|
|
3055
|
+
{ label: m ? "删除行" : "Delete Row", onClick: () => e.chain().focus().deleteRow().run() },
|
|
3056
|
+
{ label: m ? "删除列" : "Delete Column", onClick: () => e.chain().focus().deleteColumn().run() },
|
|
3057
|
+
{ label: m ? "合并单元格" : "Merge Cells", onClick: () => e.chain().focus().mergeCells().run() },
|
|
3058
|
+
{ label: m ? "拆分单元格" : "Split Cell", onClick: () => e.chain().focus().splitCell().run() },
|
|
3059
|
+
{ label: m ? "切换表头" : "Toggle Header Row", onClick: () => e.chain().focus().toggleHeaderRow().run() },
|
|
3060
|
+
{ label: m ? "删除表格" : "Delete Table", onClick: () => e.chain().focus().deleteTable().run() }
|
|
3057
3061
|
], S = [
|
|
3058
3062
|
{ label: c.insertImageFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "image" }) },
|
|
3059
3063
|
{ label: c.insertMermaidFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "mermaid" }) },
|
|
3060
3064
|
{ label: c.insertDrawioFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "drawio" }) }
|
|
3061
|
-
],
|
|
3065
|
+
], 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
3066
|
"button",
|
|
3063
3067
|
{
|
|
3064
|
-
onClick:
|
|
3065
|
-
disabled:
|
|
3066
|
-
className:
|
|
3068
|
+
onClick: u.run,
|
|
3069
|
+
disabled: u.disabled,
|
|
3070
|
+
className: Z(
|
|
3067
3071
|
"p-2 rounded transition-colors",
|
|
3068
|
-
|
|
3069
|
-
|
|
3072
|
+
u.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200",
|
|
3073
|
+
u.isActive ? "bg-gray-300 text-blue-600" : "text-gray-700"
|
|
3070
3074
|
),
|
|
3071
|
-
title:
|
|
3072
|
-
children: /* @__PURE__ */
|
|
3075
|
+
title: u.tooltip,
|
|
3076
|
+
children: /* @__PURE__ */ f(u.icon, { size: 18 })
|
|
3073
3077
|
},
|
|
3074
|
-
|
|
3078
|
+
u.id
|
|
3075
3079
|
);
|
|
3076
|
-
return /* @__PURE__ */
|
|
3077
|
-
/* @__PURE__ */
|
|
3078
|
-
/* @__PURE__ */
|
|
3079
|
-
/* @__PURE__ */
|
|
3080
|
+
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: [
|
|
3081
|
+
/* @__PURE__ */ P("div", { className: "flex items-center gap-1 pr-2 mr-2 border-r border-gray-200", children: [
|
|
3082
|
+
/* @__PURE__ */ f("span", { className: "text-xs text-gray-500", children: c.language }),
|
|
3083
|
+
/* @__PURE__ */ P(
|
|
3080
3084
|
"select",
|
|
3081
3085
|
{
|
|
3082
3086
|
value: o,
|
|
3083
|
-
onChange: (
|
|
3084
|
-
l(
|
|
3087
|
+
onChange: (u) => {
|
|
3088
|
+
l(u.target.value === "en" ? "en" : "zh");
|
|
3085
3089
|
},
|
|
3086
3090
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white text-gray-700",
|
|
3087
3091
|
children: [
|
|
3088
|
-
/* @__PURE__ */
|
|
3089
|
-
/* @__PURE__ */
|
|
3092
|
+
/* @__PURE__ */ f("option", { value: "zh", children: "中文" }),
|
|
3093
|
+
/* @__PURE__ */ f("option", { value: "en", children: "English" })
|
|
3090
3094
|
]
|
|
3091
3095
|
}
|
|
3092
3096
|
)
|
|
3093
3097
|
] }),
|
|
3094
|
-
T.map((
|
|
3095
|
-
const
|
|
3096
|
-
return /* @__PURE__ */
|
|
3097
|
-
n && /* @__PURE__ */
|
|
3098
|
+
T.map((u) => {
|
|
3099
|
+
const v = a.has(u.group);
|
|
3100
|
+
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: [
|
|
3101
|
+
n && /* @__PURE__ */ f(
|
|
3098
3102
|
"button",
|
|
3099
3103
|
{
|
|
3100
3104
|
onClick: () => {
|
|
3101
|
-
|
|
3105
|
+
C(u.group);
|
|
3102
3106
|
},
|
|
3103
3107
|
className: "px-2 py-1 text-xs rounded bg-gray-200 text-gray-700 hover:bg-gray-300",
|
|
3104
|
-
title:
|
|
3105
|
-
children: Xe(
|
|
3108
|
+
title: v ? `${c.expand} ${Xe(u.group, c)}` : `${c.collapse} ${Xe(u.group, c)}`,
|
|
3109
|
+
children: Xe(u.group, c)
|
|
3106
3110
|
}
|
|
3107
3111
|
),
|
|
3108
|
-
(!n || !
|
|
3109
|
-
] },
|
|
3112
|
+
(!n || !v) && u.items.map(A)
|
|
3113
|
+
] }, u.group);
|
|
3110
3114
|
})
|
|
3111
3115
|
] }) });
|
|
3112
3116
|
}, ei = ({ editor: e }) => {
|
|
3113
|
-
const [t, n] =
|
|
3114
|
-
if (
|
|
3117
|
+
const [t, n] = M(0), [r, a] = M(""), i = I((x) => x.editorLanguage), s = H(i);
|
|
3118
|
+
if (F(() => {
|
|
3115
3119
|
if (!e) return;
|
|
3116
3120
|
const x = () => n((S) => S + 1);
|
|
3117
3121
|
return e.on("selectionUpdate", x), e.on("update", x), () => {
|
|
@@ -3124,37 +3128,37 @@ const Xa = (e = {}) => {
|
|
|
3124
3128
|
const S = typeof x.attrs.id == "string" ? x.attrs.id.trim() : "";
|
|
3125
3129
|
return S && l.push({ id: S, label: S }), !0;
|
|
3126
3130
|
});
|
|
3127
|
-
const c = o.findAncestorNode("figure"), d = !!c,
|
|
3128
|
-
w !== y.current && (y.current = w, d &&
|
|
3131
|
+
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;
|
|
3132
|
+
w !== y.current && (y.current = w, d && m !== h && p(m));
|
|
3129
3133
|
const T = (x) => {
|
|
3130
3134
|
c && o.execCommand("patent.updateFigure", {
|
|
3131
3135
|
position: c.pos,
|
|
3132
3136
|
contentType: x
|
|
3133
3137
|
});
|
|
3134
|
-
},
|
|
3138
|
+
}, C = () => {
|
|
3135
3139
|
if (!c) return;
|
|
3136
|
-
const x =
|
|
3137
|
-
x !==
|
|
3140
|
+
const x = h.trim();
|
|
3141
|
+
x !== m && o.execCommand("patent.updateFigure", {
|
|
3138
3142
|
position: c.pos,
|
|
3139
3143
|
id: x
|
|
3140
3144
|
});
|
|
3141
3145
|
};
|
|
3142
|
-
return /* @__PURE__ */
|
|
3143
|
-
l.length > 0 && /* @__PURE__ */
|
|
3144
|
-
/* @__PURE__ */
|
|
3145
|
-
/* @__PURE__ */
|
|
3146
|
+
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: [
|
|
3147
|
+
l.length > 0 && /* @__PURE__ */ P(je, { children: [
|
|
3148
|
+
/* @__PURE__ */ f("span", { className: "text-xs text-gray-500", children: s.figureReferenceTarget }),
|
|
3149
|
+
/* @__PURE__ */ P(
|
|
3146
3150
|
"select",
|
|
3147
3151
|
{
|
|
3148
3152
|
value: r || "__none__",
|
|
3149
3153
|
onChange: (x) => a(x.target.value === "__none__" ? "" : x.target.value),
|
|
3150
3154
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
|
|
3151
3155
|
children: [
|
|
3152
|
-
/* @__PURE__ */
|
|
3153
|
-
l.map((x) => /* @__PURE__ */
|
|
3156
|
+
/* @__PURE__ */ f("option", { value: "__none__", children: s.figureReferenceTargetPlaceholder }),
|
|
3157
|
+
l.map((x) => /* @__PURE__ */ f("option", { value: x.id, children: x.label }, x.id))
|
|
3154
3158
|
]
|
|
3155
3159
|
}
|
|
3156
3160
|
),
|
|
3157
|
-
/* @__PURE__ */
|
|
3161
|
+
/* @__PURE__ */ f(
|
|
3158
3162
|
"button",
|
|
3159
3163
|
{
|
|
3160
3164
|
onClick: () => {
|
|
@@ -3165,59 +3169,59 @@ const Xa = (e = {}) => {
|
|
|
3165
3169
|
},
|
|
3166
3170
|
className: "p-2 hover:bg-blue-50 text-blue-600 rounded",
|
|
3167
3171
|
title: s.insertFigureReference,
|
|
3168
|
-
children: /* @__PURE__ */
|
|
3172
|
+
children: /* @__PURE__ */ f(Bt, { size: 16 })
|
|
3169
3173
|
}
|
|
3170
3174
|
)
|
|
3171
3175
|
] }),
|
|
3172
|
-
/* @__PURE__ */
|
|
3173
|
-
d && /* @__PURE__ */
|
|
3174
|
-
/* @__PURE__ */
|
|
3175
|
-
/* @__PURE__ */
|
|
3176
|
-
/* @__PURE__ */
|
|
3176
|
+
/* @__PURE__ */ f("div", { className: "h-6 w-px bg-gray-200 mx-1" }),
|
|
3177
|
+
d && /* @__PURE__ */ P(je, { children: [
|
|
3178
|
+
/* @__PURE__ */ f("span", { className: "text-xs font-medium text-gray-700", children: s.currentFigure }),
|
|
3179
|
+
/* @__PURE__ */ f("span", { className: "text-xs text-gray-500", children: s.figureId }),
|
|
3180
|
+
/* @__PURE__ */ f(
|
|
3177
3181
|
"input",
|
|
3178
3182
|
{
|
|
3179
3183
|
ref: b,
|
|
3180
3184
|
type: "text",
|
|
3181
|
-
value:
|
|
3182
|
-
onChange: (x) =>
|
|
3183
|
-
onBlur:
|
|
3185
|
+
value: h,
|
|
3186
|
+
onChange: (x) => p(x.target.value),
|
|
3187
|
+
onBlur: C,
|
|
3184
3188
|
onKeyDown: (x) => {
|
|
3185
|
-
x.key === "Enter" && (
|
|
3189
|
+
x.key === "Enter" && (C(), x.target.blur());
|
|
3186
3190
|
},
|
|
3187
3191
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white w-20",
|
|
3188
3192
|
placeholder: i === "en" ? "Fig.1" : "图1"
|
|
3189
3193
|
}
|
|
3190
3194
|
),
|
|
3191
|
-
/* @__PURE__ */
|
|
3192
|
-
/* @__PURE__ */
|
|
3195
|
+
/* @__PURE__ */ f("span", { className: "text-xs text-gray-500", children: s.switchFigureType }),
|
|
3196
|
+
/* @__PURE__ */ P(
|
|
3193
3197
|
"select",
|
|
3194
3198
|
{
|
|
3195
|
-
value:
|
|
3199
|
+
value: g,
|
|
3196
3200
|
onChange: (x) => T(x.target.value),
|
|
3197
3201
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
|
|
3198
3202
|
children: [
|
|
3199
|
-
/* @__PURE__ */
|
|
3200
|
-
/* @__PURE__ */
|
|
3201
|
-
/* @__PURE__ */
|
|
3203
|
+
/* @__PURE__ */ f("option", { value: "image", children: s.figureContentTypeImage }),
|
|
3204
|
+
/* @__PURE__ */ f("option", { value: "mermaid", children: s.figureContentTypeMermaid }),
|
|
3205
|
+
/* @__PURE__ */ f("option", { value: "drawio", children: s.figureContentTypeDrawio })
|
|
3202
3206
|
]
|
|
3203
3207
|
}
|
|
3204
3208
|
),
|
|
3205
|
-
/* @__PURE__ */
|
|
3209
|
+
/* @__PURE__ */ f("div", { className: "h-6 w-px bg-gray-200 mx-1" })
|
|
3206
3210
|
] }),
|
|
3207
3211
|
e.isActive("image") && (() => {
|
|
3208
3212
|
const S = e.getAttributes("image").width || "";
|
|
3209
|
-
return /* @__PURE__ */
|
|
3210
|
-
/* @__PURE__ */
|
|
3211
|
-
["25%", "50%", "75%", "100%"].map((
|
|
3213
|
+
return /* @__PURE__ */ P(je, { children: [
|
|
3214
|
+
/* @__PURE__ */ f("span", { className: "text-xs font-medium text-gray-700", children: i === "zh" ? "图片" : "Image" }),
|
|
3215
|
+
["25%", "50%", "75%", "100%"].map((u) => /* @__PURE__ */ f(
|
|
3212
3216
|
"button",
|
|
3213
3217
|
{
|
|
3214
|
-
onClick: () => e.chain().focus().updateAttributes("image", { width:
|
|
3215
|
-
className: `text-xs px-2 py-0.5 rounded border ${S ===
|
|
3216
|
-
children:
|
|
3218
|
+
onClick: () => e.chain().focus().updateAttributes("image", { width: u }).run(),
|
|
3219
|
+
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"}`,
|
|
3220
|
+
children: u
|
|
3217
3221
|
},
|
|
3218
|
-
|
|
3222
|
+
u
|
|
3219
3223
|
)),
|
|
3220
|
-
/* @__PURE__ */
|
|
3224
|
+
/* @__PURE__ */ f("div", { className: "h-6 w-px bg-gray-200 mx-1" })
|
|
3221
3225
|
] });
|
|
3222
3226
|
})()
|
|
3223
3227
|
] }) });
|
|
@@ -3289,14 +3293,14 @@ function Ws(e, t = {}) {
|
|
|
3289
3293
|
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
3294
|
let s = t.sectionType, o = t.targetSectionPos;
|
|
3291
3295
|
if (!s) {
|
|
3292
|
-
const
|
|
3293
|
-
|
|
3296
|
+
const m = on(e);
|
|
3297
|
+
m && (s = m.sectionType, o = m.pos);
|
|
3294
3298
|
}
|
|
3295
3299
|
const l = t.scope || (s ? "section" : i ? "selection" : "document"), c = s ? ni(e, s) : void 0;
|
|
3296
3300
|
let d;
|
|
3297
3301
|
if (l === "selection" && r !== a) {
|
|
3298
|
-
const
|
|
3299
|
-
d = `...${
|
|
3302
|
+
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");
|
|
3303
|
+
d = `...${p}[SELECTED]${b}...`;
|
|
3300
3304
|
}
|
|
3301
3305
|
return {
|
|
3302
3306
|
scope: l,
|
|
@@ -3310,217 +3314,241 @@ function Ws(e, t = {}) {
|
|
|
3310
3314
|
};
|
|
3311
3315
|
}
|
|
3312
3316
|
const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
3313
|
-
const { addChatReference: n, openChatPanel: r, editorLanguage: a } = I(), i = a === "zh", s = (c) =>
|
|
3317
|
+
const { addChatReference: n, openChatPanel: r, editorLanguage: a } = I(), i = a === "zh", s = (c) => Z(
|
|
3314
3318
|
"p-1.5 rounded transition-colors",
|
|
3315
3319
|
c ? "bg-blue-100 text-blue-600" : "text-gray-600 hover:bg-gray-100"
|
|
3316
3320
|
), o = () => {
|
|
3317
3321
|
const { from: c, to: d } = e.state.selection;
|
|
3318
3322
|
if (c === d) return;
|
|
3319
|
-
const
|
|
3323
|
+
const m = e.state.doc.textBetween(c, d, " "), g = on(e);
|
|
3320
3324
|
if (t) {
|
|
3321
|
-
t({ text:
|
|
3325
|
+
t({ text: m, from: c, to: d, sectionType: g == null ? void 0 : g.sectionType });
|
|
3322
3326
|
return;
|
|
3323
3327
|
}
|
|
3324
|
-
n({ text:
|
|
3328
|
+
n({ text: m, from: c, to: d, sectionType: g == null ? void 0 : g.sectionType }), r();
|
|
3325
3329
|
}, l = () => {
|
|
3326
3330
|
const c = e.getAttributes("link").href, d = window.prompt("URL", c || "https://");
|
|
3327
3331
|
d !== null && (d === "" ? e.chain().focus().extendMarkRange("link").unsetLink().run() : e.chain().focus().extendMarkRange("link").setLink({ href: d }).run());
|
|
3328
3332
|
};
|
|
3329
|
-
return /* @__PURE__ */
|
|
3333
|
+
return /* @__PURE__ */ f(
|
|
3330
3334
|
Jr,
|
|
3331
3335
|
{
|
|
3332
3336
|
editor: e,
|
|
3333
3337
|
shouldShow: ({ editor: c, state: d }) => {
|
|
3334
|
-
const { from:
|
|
3335
|
-
return !(
|
|
3338
|
+
const { from: m, to: g } = d.selection;
|
|
3339
|
+
return !(m === g || c.isActive("codeBlock"));
|
|
3336
3340
|
},
|
|
3337
|
-
children: /* @__PURE__ */
|
|
3338
|
-
/* @__PURE__ */
|
|
3341
|
+
children: /* @__PURE__ */ P("div", { className: "bubble-menu", children: [
|
|
3342
|
+
/* @__PURE__ */ f(
|
|
3339
3343
|
"button",
|
|
3340
3344
|
{
|
|
3341
3345
|
onClick: () => e.chain().focus().toggleBold().run(),
|
|
3342
3346
|
className: s(e.isActive("bold")),
|
|
3343
3347
|
title: "Bold",
|
|
3344
|
-
children: /* @__PURE__ */
|
|
3348
|
+
children: /* @__PURE__ */ f(Dt, { size: 15 })
|
|
3345
3349
|
}
|
|
3346
3350
|
),
|
|
3347
|
-
/* @__PURE__ */
|
|
3351
|
+
/* @__PURE__ */ f(
|
|
3348
3352
|
"button",
|
|
3349
3353
|
{
|
|
3350
3354
|
onClick: () => e.chain().focus().toggleItalic().run(),
|
|
3351
3355
|
className: s(e.isActive("italic")),
|
|
3352
3356
|
title: "Italic",
|
|
3353
|
-
children: /* @__PURE__ */
|
|
3357
|
+
children: /* @__PURE__ */ f(Rt, { size: 15 })
|
|
3354
3358
|
}
|
|
3355
3359
|
),
|
|
3356
|
-
/* @__PURE__ */
|
|
3360
|
+
/* @__PURE__ */ f(
|
|
3357
3361
|
"button",
|
|
3358
3362
|
{
|
|
3359
3363
|
onClick: () => e.chain().focus().toggleUnderline().run(),
|
|
3360
3364
|
className: s(e.isActive("underline")),
|
|
3361
3365
|
title: "Underline",
|
|
3362
|
-
children: /* @__PURE__ */
|
|
3366
|
+
children: /* @__PURE__ */ f(Mt, { size: 15 })
|
|
3363
3367
|
}
|
|
3364
3368
|
),
|
|
3365
|
-
/* @__PURE__ */
|
|
3369
|
+
/* @__PURE__ */ f(
|
|
3366
3370
|
"button",
|
|
3367
3371
|
{
|
|
3368
3372
|
onClick: () => e.chain().focus().toggleStrike().run(),
|
|
3369
3373
|
className: s(e.isActive("strike")),
|
|
3370
3374
|
title: "Strikethrough",
|
|
3371
|
-
children: /* @__PURE__ */
|
|
3375
|
+
children: /* @__PURE__ */ f(Ft, { size: 15 })
|
|
3372
3376
|
}
|
|
3373
3377
|
),
|
|
3374
|
-
/* @__PURE__ */
|
|
3378
|
+
/* @__PURE__ */ f(
|
|
3375
3379
|
"button",
|
|
3376
3380
|
{
|
|
3377
3381
|
onClick: () => e.chain().focus().toggleCode().run(),
|
|
3378
3382
|
className: s(e.isActive("code")),
|
|
3379
3383
|
title: "Code",
|
|
3380
|
-
children: /* @__PURE__ */
|
|
3384
|
+
children: /* @__PURE__ */ f($t, { size: 15 })
|
|
3381
3385
|
}
|
|
3382
3386
|
),
|
|
3383
|
-
/* @__PURE__ */
|
|
3387
|
+
/* @__PURE__ */ f(
|
|
3384
3388
|
"button",
|
|
3385
3389
|
{
|
|
3386
3390
|
onClick: () => e.chain().focus().toggleSuperscript().run(),
|
|
3387
3391
|
className: s(e.isActive("superscript")),
|
|
3388
3392
|
title: "Superscript",
|
|
3389
|
-
children: /* @__PURE__ */
|
|
3393
|
+
children: /* @__PURE__ */ f(zt, { size: 15 })
|
|
3390
3394
|
}
|
|
3391
3395
|
),
|
|
3392
|
-
/* @__PURE__ */
|
|
3396
|
+
/* @__PURE__ */ f(
|
|
3393
3397
|
"button",
|
|
3394
3398
|
{
|
|
3395
3399
|
onClick: () => e.chain().focus().toggleSubscript().run(),
|
|
3396
3400
|
className: s(e.isActive("subscript")),
|
|
3397
3401
|
title: "Subscript",
|
|
3398
|
-
children: /* @__PURE__ */
|
|
3402
|
+
children: /* @__PURE__ */ f(Ot, { size: 15 })
|
|
3399
3403
|
}
|
|
3400
3404
|
),
|
|
3401
|
-
/* @__PURE__ */
|
|
3402
|
-
/* @__PURE__ */
|
|
3405
|
+
/* @__PURE__ */ f("div", { className: "bubble-menu-divider" }),
|
|
3406
|
+
/* @__PURE__ */ f(
|
|
3403
3407
|
"button",
|
|
3404
3408
|
{
|
|
3405
3409
|
onClick: () => e.chain().focus().toggleHighlight().run(),
|
|
3406
3410
|
className: s(e.isActive("highlight")),
|
|
3407
3411
|
title: "Highlight",
|
|
3408
|
-
children: /* @__PURE__ */
|
|
3412
|
+
children: /* @__PURE__ */ f(Br, { size: 15 })
|
|
3409
3413
|
}
|
|
3410
3414
|
),
|
|
3411
|
-
/* @__PURE__ */
|
|
3415
|
+
/* @__PURE__ */ f(
|
|
3412
3416
|
"button",
|
|
3413
3417
|
{
|
|
3414
3418
|
onClick: l,
|
|
3415
3419
|
className: s(e.isActive("link")),
|
|
3416
3420
|
title: "Link",
|
|
3417
|
-
children: /* @__PURE__ */
|
|
3421
|
+
children: /* @__PURE__ */ f(Ht, { size: 15 })
|
|
3418
3422
|
}
|
|
3419
3423
|
),
|
|
3420
|
-
/* @__PURE__ */
|
|
3421
|
-
/* @__PURE__ */
|
|
3424
|
+
/* @__PURE__ */ f("div", { className: "bubble-menu-divider" }),
|
|
3425
|
+
/* @__PURE__ */ f(
|
|
3422
3426
|
"button",
|
|
3423
3427
|
{
|
|
3424
3428
|
onClick: o,
|
|
3425
3429
|
className: "p-1.5 rounded transition-colors text-purple-500 hover:bg-purple-50",
|
|
3426
3430
|
title: i ? "AI 优化" : "AI Optimize",
|
|
3427
|
-
children: /* @__PURE__ */
|
|
3431
|
+
children: /* @__PURE__ */ f(Hr, { size: 15 })
|
|
3428
3432
|
}
|
|
3429
3433
|
)
|
|
3430
3434
|
] })
|
|
3431
3435
|
}
|
|
3432
3436
|
);
|
|
3433
3437
|
}, ai = ({ editor: e }) => {
|
|
3434
|
-
var
|
|
3435
|
-
const [t, n] =
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
+
var A;
|
|
3439
|
+
const [t, n] = M(!1), [r, a] = M(!1), [i, s] = M(""), [o, l] = M(""), [c, d] = M(!1), [, m] = M(0), g = j(() => m((u) => u + 1), []), h = W(null), p = e.extensionStorage.searchReplace, b = ((A = p == null ? void 0 : p.results) == null ? void 0 : A.length) ?? 0, y = (p == null ? void 0 : p.currentIndex) ?? -1, w = j(() => {
|
|
3440
|
+
e.commands.nextSearchResult(), g();
|
|
3441
|
+
}, [e, g]), T = j(() => {
|
|
3442
|
+
e.commands.previousSearchResult(), g();
|
|
3443
|
+
}, [e, g]);
|
|
3444
|
+
F(() => {
|
|
3445
|
+
const u = (v) => {
|
|
3438
3446
|
n(!0);
|
|
3439
|
-
const
|
|
3440
|
-
|
|
3447
|
+
const _ = v.detail;
|
|
3448
|
+
_ != null && _.replace && a(!0), requestAnimationFrame(() => {
|
|
3441
3449
|
var N;
|
|
3442
|
-
return (N =
|
|
3450
|
+
return (N = h.current) == null ? void 0 : N.focus();
|
|
3443
3451
|
});
|
|
3444
3452
|
};
|
|
3445
|
-
return window.addEventListener("editor:toggleSearch",
|
|
3453
|
+
return window.addEventListener("editor:toggleSearch", u), () => window.removeEventListener("editor:toggleSearch", u);
|
|
3446
3454
|
}, []);
|
|
3447
|
-
const
|
|
3448
|
-
(
|
|
3449
|
-
s(
|
|
3455
|
+
const C = j(
|
|
3456
|
+
(u) => {
|
|
3457
|
+
s(u), e.commands.setSearchTerm(u);
|
|
3450
3458
|
},
|
|
3451
3459
|
[e]
|
|
3452
|
-
),
|
|
3460
|
+
), x = j(() => {
|
|
3453
3461
|
n(!1), e.commands.clearSearch(), e.commands.focus();
|
|
3454
3462
|
}, [e]);
|
|
3455
|
-
|
|
3456
|
-
const
|
|
3457
|
-
|
|
3463
|
+
F(() => {
|
|
3464
|
+
const u = (v) => {
|
|
3465
|
+
v.key === "Escape" && t && x();
|
|
3458
3466
|
};
|
|
3459
|
-
return window.addEventListener("keydown",
|
|
3460
|
-
}, [t,
|
|
3461
|
-
const
|
|
3462
|
-
const
|
|
3463
|
-
d(
|
|
3467
|
+
return window.addEventListener("keydown", u), () => window.removeEventListener("keydown", u);
|
|
3468
|
+
}, [t, x]);
|
|
3469
|
+
const S = () => {
|
|
3470
|
+
const u = !c;
|
|
3471
|
+
d(u), e.commands.setCaseSensitive(u);
|
|
3464
3472
|
};
|
|
3465
|
-
return t ? /* @__PURE__ */
|
|
3466
|
-
/* @__PURE__ */
|
|
3467
|
-
/* @__PURE__ */
|
|
3468
|
-
/* @__PURE__ */
|
|
3473
|
+
return t ? /* @__PURE__ */ P("div", { className: "find-replace-bar", children: [
|
|
3474
|
+
/* @__PURE__ */ P("div", { className: "find-replace-row", children: [
|
|
3475
|
+
/* @__PURE__ */ P("div", { className: "find-replace-input-group", children: [
|
|
3476
|
+
/* @__PURE__ */ f(
|
|
3469
3477
|
"input",
|
|
3470
3478
|
{
|
|
3471
|
-
ref:
|
|
3479
|
+
ref: h,
|
|
3472
3480
|
type: "text",
|
|
3473
3481
|
value: i,
|
|
3474
|
-
onChange: (
|
|
3475
|
-
onKeyDown: (
|
|
3476
|
-
|
|
3482
|
+
onChange: (u) => C(u.target.value),
|
|
3483
|
+
onKeyDown: (u) => {
|
|
3484
|
+
u.key === "Enter" && (u.shiftKey ? T() : w());
|
|
3477
3485
|
},
|
|
3478
3486
|
placeholder: "Find...",
|
|
3479
3487
|
className: "find-replace-input"
|
|
3480
3488
|
}
|
|
3481
3489
|
),
|
|
3482
|
-
/* @__PURE__ */
|
|
3490
|
+
/* @__PURE__ */ f("span", { className: "find-replace-count", children: b > 0 ? `${y + 1}/${b}` : i ? "0" : "" })
|
|
3483
3491
|
] }),
|
|
3484
|
-
/* @__PURE__ */
|
|
3492
|
+
/* @__PURE__ */ f(
|
|
3485
3493
|
"button",
|
|
3486
3494
|
{
|
|
3487
|
-
onClick:
|
|
3488
|
-
className:
|
|
3495
|
+
onClick: S,
|
|
3496
|
+
className: Z("find-replace-btn", c && "find-replace-btn--active"),
|
|
3489
3497
|
title: "Case Sensitive",
|
|
3490
|
-
children: /* @__PURE__ */
|
|
3498
|
+
children: /* @__PURE__ */ f(Ur, { size: 15 })
|
|
3491
3499
|
}
|
|
3492
3500
|
),
|
|
3493
|
-
/* @__PURE__ */
|
|
3494
|
-
/* @__PURE__ */
|
|
3495
|
-
/* @__PURE__ */
|
|
3501
|
+
/* @__PURE__ */ f("button", { onClick: T, className: "find-replace-btn", title: "Previous", children: /* @__PURE__ */ f(qr, { size: 15 }) }),
|
|
3502
|
+
/* @__PURE__ */ f("button", { onClick: w, className: "find-replace-btn", title: "Next", children: /* @__PURE__ */ f(qt, { size: 15 }) }),
|
|
3503
|
+
/* @__PURE__ */ f(
|
|
3496
3504
|
"button",
|
|
3497
3505
|
{
|
|
3498
|
-
onClick: () => a((
|
|
3499
|
-
className:
|
|
3506
|
+
onClick: () => a((u) => !u),
|
|
3507
|
+
className: Z("find-replace-btn", r && "find-replace-btn--active"),
|
|
3500
3508
|
title: "Toggle Replace",
|
|
3501
|
-
children: /* @__PURE__ */
|
|
3509
|
+
children: /* @__PURE__ */ f(gt, { size: 15 })
|
|
3502
3510
|
}
|
|
3503
3511
|
),
|
|
3504
|
-
/* @__PURE__ */
|
|
3512
|
+
/* @__PURE__ */ f("button", { onClick: x, className: "find-replace-btn", title: "Close (Esc)", children: /* @__PURE__ */ f(Wr, { size: 15 }) })
|
|
3505
3513
|
] }),
|
|
3506
|
-
r && /* @__PURE__ */
|
|
3507
|
-
/* @__PURE__ */
|
|
3514
|
+
r && /* @__PURE__ */ P("div", { className: "find-replace-row", children: [
|
|
3515
|
+
/* @__PURE__ */ f(
|
|
3508
3516
|
"input",
|
|
3509
3517
|
{
|
|
3510
3518
|
type: "text",
|
|
3511
3519
|
value: o,
|
|
3512
|
-
onChange: (
|
|
3513
|
-
l(
|
|
3520
|
+
onChange: (u) => {
|
|
3521
|
+
l(u.target.value), e.commands.setReplaceTerm(u.target.value);
|
|
3514
3522
|
},
|
|
3515
|
-
onKeyDown: (
|
|
3516
|
-
|
|
3523
|
+
onKeyDown: (u) => {
|
|
3524
|
+
u.key === "Enter" && (e.commands.replaceCurrent(), g());
|
|
3517
3525
|
},
|
|
3518
3526
|
placeholder: "Replace...",
|
|
3519
3527
|
className: "find-replace-input"
|
|
3520
3528
|
}
|
|
3521
3529
|
),
|
|
3522
|
-
/* @__PURE__ */
|
|
3523
|
-
|
|
3530
|
+
/* @__PURE__ */ f(
|
|
3531
|
+
"button",
|
|
3532
|
+
{
|
|
3533
|
+
onClick: () => {
|
|
3534
|
+
e.commands.replaceCurrent(), g();
|
|
3535
|
+
},
|
|
3536
|
+
className: "find-replace-btn",
|
|
3537
|
+
title: "Replace",
|
|
3538
|
+
children: /* @__PURE__ */ f(gt, { size: 15 })
|
|
3539
|
+
}
|
|
3540
|
+
),
|
|
3541
|
+
/* @__PURE__ */ f(
|
|
3542
|
+
"button",
|
|
3543
|
+
{
|
|
3544
|
+
onClick: () => {
|
|
3545
|
+
e.commands.replaceAll(), g();
|
|
3546
|
+
},
|
|
3547
|
+
className: "find-replace-btn",
|
|
3548
|
+
title: "Replace All",
|
|
3549
|
+
children: /* @__PURE__ */ f(jr, { size: 15 })
|
|
3550
|
+
}
|
|
3551
|
+
)
|
|
3524
3552
|
] })
|
|
3525
3553
|
] }) : null;
|
|
3526
3554
|
}, ii = ({ editor: e }) => {
|
|
@@ -3529,13 +3557,13 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3529
3557
|
let c = 0;
|
|
3530
3558
|
return o !== l && (c = a.doc.textBetween(o, l, " ", "\0").replace(/\s/g, "").length), { charCount: s, selectionCount: c };
|
|
3531
3559
|
}, [e.state.doc, e.state.selection]);
|
|
3532
|
-
return /* @__PURE__ */
|
|
3533
|
-
/* @__PURE__ */
|
|
3560
|
+
return /* @__PURE__ */ P("div", { className: "word-count-bar", children: [
|
|
3561
|
+
/* @__PURE__ */ P("span", { children: [
|
|
3534
3562
|
n ? "字数" : "Characters",
|
|
3535
3563
|
": ",
|
|
3536
3564
|
r.charCount
|
|
3537
3565
|
] }),
|
|
3538
|
-
r.selectionCount > 0 && /* @__PURE__ */
|
|
3566
|
+
r.selectionCount > 0 && /* @__PURE__ */ P("span", { children: [
|
|
3539
3567
|
n ? "选区" : "Selected",
|
|
3540
3568
|
": ",
|
|
3541
3569
|
r.selectionCount
|
|
@@ -3554,8 +3582,8 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3554
3582
|
"drawing_description",
|
|
3555
3583
|
"detailed_description"
|
|
3556
3584
|
]), li = ({ editor: e, defaultCollapsed: t = !1 }) => {
|
|
3557
|
-
const { editorLanguage: n } = I(), r = H(n), [a, i] =
|
|
3558
|
-
|
|
3585
|
+
const { editorLanguage: n } = I(), r = H(n), [a, i] = M(t), [s, o] = M(0);
|
|
3586
|
+
F(() => {
|
|
3559
3587
|
const c = () => o((d) => d + 1);
|
|
3560
3588
|
return e.on("update", c), () => {
|
|
3561
3589
|
e.off("update", c);
|
|
@@ -3564,79 +3592,79 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3564
3592
|
const l = At(() => {
|
|
3565
3593
|
const c = [];
|
|
3566
3594
|
let d = !1;
|
|
3567
|
-
return e.state.doc.descendants((
|
|
3568
|
-
if (
|
|
3595
|
+
return e.state.doc.descendants((m, g) => {
|
|
3596
|
+
if (m.type.name === "patent_title") {
|
|
3569
3597
|
if (!d) {
|
|
3570
3598
|
const y = typeof r.bookTitle_description == "string" ? r.bookTitle_description : "说明书";
|
|
3571
3599
|
c.push({
|
|
3572
3600
|
type: "book-group",
|
|
3573
|
-
pos:
|
|
3601
|
+
pos: g,
|
|
3574
3602
|
title: y,
|
|
3575
3603
|
charCount: 0
|
|
3576
3604
|
}), d = !0;
|
|
3577
3605
|
}
|
|
3578
|
-
const
|
|
3606
|
+
const h = m.textContent || "", p = h.trim().length > 0, b = typeof r.patentTitlePlaceholder == "string" ? r.patentTitlePlaceholder : "Patent Title";
|
|
3579
3607
|
return c.push({
|
|
3580
3608
|
type: "section",
|
|
3581
|
-
pos:
|
|
3582
|
-
title:
|
|
3583
|
-
state:
|
|
3584
|
-
charCount:
|
|
3609
|
+
pos: g,
|
|
3610
|
+
title: p ? h.trim() : b,
|
|
3611
|
+
state: p ? "filled" : "empty",
|
|
3612
|
+
charCount: h.replace(/\s/g, "").length,
|
|
3585
3613
|
indent: !0
|
|
3586
3614
|
}), !1;
|
|
3587
3615
|
}
|
|
3588
|
-
if (
|
|
3589
|
-
const
|
|
3616
|
+
if (m.type.name === "patent_section") {
|
|
3617
|
+
const h = m.attrs.sectionType, p = ci.has(h), b = `sectionTitle_${h}`, y = typeof r[b] == "string" ? r[b] : h, w = m.textContent || "", T = w.trim().length > 0;
|
|
3590
3618
|
return c.push({
|
|
3591
3619
|
type: "section",
|
|
3592
|
-
pos:
|
|
3620
|
+
pos: g,
|
|
3593
3621
|
title: y,
|
|
3594
3622
|
state: T ? "filled" : "empty",
|
|
3595
3623
|
charCount: w.replace(/\s/g, "").length,
|
|
3596
|
-
indent:
|
|
3624
|
+
indent: p
|
|
3597
3625
|
}), !1;
|
|
3598
3626
|
}
|
|
3599
|
-
if (
|
|
3600
|
-
const
|
|
3601
|
-
return
|
|
3627
|
+
if (m.type.name === "heading") {
|
|
3628
|
+
const h = m.attrs.level, p = m.textContent || "";
|
|
3629
|
+
return p.trim() && c.push({
|
|
3602
3630
|
type: "heading",
|
|
3603
|
-
pos:
|
|
3604
|
-
title:
|
|
3605
|
-
level:
|
|
3606
|
-
charCount:
|
|
3631
|
+
pos: g,
|
|
3632
|
+
title: p,
|
|
3633
|
+
level: h,
|
|
3634
|
+
charCount: p.replace(/\s/g, "").length
|
|
3607
3635
|
}), !1;
|
|
3608
3636
|
}
|
|
3609
3637
|
return !0;
|
|
3610
3638
|
}), c;
|
|
3611
3639
|
}, [e, s, r]);
|
|
3612
|
-
return a ? /* @__PURE__ */
|
|
3640
|
+
return a ? /* @__PURE__ */ f("div", { className: "outline-panel outline-panel--collapsed", children: /* @__PURE__ */ f(
|
|
3613
3641
|
"button",
|
|
3614
3642
|
{
|
|
3615
3643
|
onClick: () => i(!1),
|
|
3616
3644
|
className: "outline-panel-toggle",
|
|
3617
3645
|
title: n === "zh" ? "展开大纲" : "Expand Outline",
|
|
3618
|
-
children: /* @__PURE__ */
|
|
3646
|
+
children: /* @__PURE__ */ f(Gr, { size: 16 })
|
|
3619
3647
|
}
|
|
3620
|
-
) }) : /* @__PURE__ */
|
|
3621
|
-
/* @__PURE__ */
|
|
3622
|
-
/* @__PURE__ */
|
|
3623
|
-
/* @__PURE__ */
|
|
3624
|
-
/* @__PURE__ */
|
|
3648
|
+
) }) : /* @__PURE__ */ P("div", { className: "outline-panel", children: [
|
|
3649
|
+
/* @__PURE__ */ P("div", { className: "outline-panel-header", children: [
|
|
3650
|
+
/* @__PURE__ */ f(Ut, { size: 14 }),
|
|
3651
|
+
/* @__PURE__ */ f("span", { children: n === "zh" ? "文档大纲" : "Outline" }),
|
|
3652
|
+
/* @__PURE__ */ f(
|
|
3625
3653
|
"button",
|
|
3626
3654
|
{
|
|
3627
3655
|
onClick: () => i(!0),
|
|
3628
3656
|
className: "outline-panel-toggle ml-auto",
|
|
3629
3657
|
title: n === "zh" ? "收起大纲" : "Collapse Outline",
|
|
3630
|
-
children: /* @__PURE__ */
|
|
3658
|
+
children: /* @__PURE__ */ f(Vr, { size: 14 })
|
|
3631
3659
|
}
|
|
3632
3660
|
)
|
|
3633
3661
|
] }),
|
|
3634
|
-
/* @__PURE__ */
|
|
3635
|
-
l.length === 0 && /* @__PURE__ */
|
|
3636
|
-
l.map((c, d) => /* @__PURE__ */
|
|
3662
|
+
/* @__PURE__ */ P("div", { className: "outline-panel-list", children: [
|
|
3663
|
+
l.length === 0 && /* @__PURE__ */ f("div", { className: "outline-panel-empty", children: n === "zh" ? "暂无章节" : "No sections yet" }),
|
|
3664
|
+
l.map((c, d) => /* @__PURE__ */ P(
|
|
3637
3665
|
"button",
|
|
3638
3666
|
{
|
|
3639
|
-
className:
|
|
3667
|
+
className: Z(
|
|
3640
3668
|
"outline-panel-item",
|
|
3641
3669
|
c.type === "heading" && `outline-panel-item--h${c.level}`,
|
|
3642
3670
|
c.type === "book-group" && "outline-panel-item--book",
|
|
@@ -3644,14 +3672,14 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3644
3672
|
),
|
|
3645
3673
|
onClick: () => {
|
|
3646
3674
|
c.type !== "book-group" && (e.chain().setTextSelection(c.pos + 1).focus().run(), requestAnimationFrame(() => {
|
|
3647
|
-
const
|
|
3648
|
-
|
|
3675
|
+
const m = e.view.nodeDOM(c.pos);
|
|
3676
|
+
m == null || m.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
3649
3677
|
}));
|
|
3650
3678
|
},
|
|
3651
3679
|
children: [
|
|
3652
|
-
c.type === "section" && c.state && /* @__PURE__ */
|
|
3653
|
-
/* @__PURE__ */
|
|
3654
|
-
c.type !== "book-group" && /* @__PURE__ */
|
|
3680
|
+
c.type === "section" && c.state && /* @__PURE__ */ f("span", { className: Z("outline-item-state", oi[c.state]), children: si[c.state] || "○" }),
|
|
3681
|
+
/* @__PURE__ */ f("span", { className: "outline-item-title", children: c.title }),
|
|
3682
|
+
c.type !== "book-group" && /* @__PURE__ */ f("span", { className: "outline-item-count", children: c.charCount })
|
|
3655
3683
|
]
|
|
3656
3684
|
},
|
|
3657
3685
|
`${c.pos}-${d}`
|
|
@@ -3662,17 +3690,17 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3662
3690
|
editor: e,
|
|
3663
3691
|
mode: t = "edit",
|
|
3664
3692
|
className: n
|
|
3665
|
-
}) => (
|
|
3693
|
+
}) => (F(() => {
|
|
3666
3694
|
e.setEditable(t === "edit");
|
|
3667
|
-
}, [e, t]), /* @__PURE__ */
|
|
3695
|
+
}, [e, t]), /* @__PURE__ */ f(
|
|
3668
3696
|
"div",
|
|
3669
3697
|
{
|
|
3670
|
-
className:
|
|
3698
|
+
className: Z(
|
|
3671
3699
|
"h-full",
|
|
3672
3700
|
t === "readonly" ? "cursor-default" : "cursor-text",
|
|
3673
3701
|
n
|
|
3674
3702
|
),
|
|
3675
|
-
children: /* @__PURE__ */
|
|
3703
|
+
children: /* @__PURE__ */ f(In, { editor: e, className: "h-full" })
|
|
3676
3704
|
}
|
|
3677
3705
|
)), cn = "patent-editor-draft", ui = 1500, mi = () => {
|
|
3678
3706
|
try {
|
|
@@ -3692,7 +3720,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3692
3720
|
patchEditorId: o = "default",
|
|
3693
3721
|
defaultOutlineCollapsed: l = !1
|
|
3694
3722
|
}) => {
|
|
3695
|
-
const { setEditor: c, setDocument: d, editorLanguage:
|
|
3723
|
+
const { setEditor: c, setDocument: d, editorLanguage: m, autoSaveStatus: g, ai: h } = I(), { setAutoSaveStatus: p, setLastSavedAt: b } = I(), y = W(null), w = e || (t ? null : mi()) || {
|
|
3696
3724
|
type: "doc",
|
|
3697
3725
|
content: [
|
|
3698
3726
|
{
|
|
@@ -3700,27 +3728,27 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3700
3728
|
content: [{ type: "text", text: "" }]
|
|
3701
3729
|
}
|
|
3702
3730
|
]
|
|
3703
|
-
}, T =
|
|
3731
|
+
}, T = j((u) => {
|
|
3704
3732
|
try {
|
|
3705
|
-
|
|
3733
|
+
p("saving"), localStorage.setItem(cn, JSON.stringify(u)), p("saved"), b(/* @__PURE__ */ new Date());
|
|
3706
3734
|
} catch {
|
|
3707
|
-
|
|
3735
|
+
p("error");
|
|
3708
3736
|
}
|
|
3709
|
-
}, [
|
|
3737
|
+
}, [p, b]), C = Nn(
|
|
3710
3738
|
Xa({
|
|
3711
3739
|
extensions: [pa.configure({ editorId: o })],
|
|
3712
3740
|
content: w,
|
|
3713
|
-
onUpdate: ({ editor:
|
|
3714
|
-
const
|
|
3715
|
-
d(
|
|
3716
|
-
T(
|
|
3741
|
+
onUpdate: ({ editor: u }) => {
|
|
3742
|
+
const v = u.getJSON();
|
|
3743
|
+
d(v), B.notifyStateChange(u), t && t(v), t || (y.current && clearTimeout(y.current), y.current = setTimeout(() => {
|
|
3744
|
+
T(v);
|
|
3717
3745
|
}, ui));
|
|
3718
3746
|
},
|
|
3719
|
-
onCreate: ({ editor:
|
|
3720
|
-
c(
|
|
3747
|
+
onCreate: ({ editor: u }) => {
|
|
3748
|
+
c(u), i == null || i(u), B.initializePlugins(u), B.notifyStateChange(u);
|
|
3721
3749
|
},
|
|
3722
|
-
onSelectionUpdate: ({ editor:
|
|
3723
|
-
B.notifySelectionChange(
|
|
3750
|
+
onSelectionUpdate: ({ editor: u }) => {
|
|
3751
|
+
B.notifySelectionChange(u);
|
|
3724
3752
|
},
|
|
3725
3753
|
editorProps: {
|
|
3726
3754
|
attributes: {
|
|
@@ -3729,40 +3757,40 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3729
3757
|
}
|
|
3730
3758
|
})
|
|
3731
3759
|
), x = W(!1);
|
|
3732
|
-
if (
|
|
3733
|
-
if (!(!
|
|
3760
|
+
if (F(() => {
|
|
3761
|
+
if (!(!C || !e)) {
|
|
3734
3762
|
if (!x.current) {
|
|
3735
3763
|
x.current = !0;
|
|
3736
3764
|
return;
|
|
3737
3765
|
}
|
|
3738
|
-
|
|
3766
|
+
C.commands.setContent(e);
|
|
3739
3767
|
}
|
|
3740
|
-
}, [
|
|
3741
|
-
y.current && clearTimeout(y.current),
|
|
3742
|
-
}, [
|
|
3743
|
-
!
|
|
3744
|
-
}, [
|
|
3768
|
+
}, [C, e]), F(() => () => {
|
|
3769
|
+
y.current && clearTimeout(y.current), C && (c(null), B.destroyPlugins(C), C.destroy());
|
|
3770
|
+
}, [C, c]), F(() => {
|
|
3771
|
+
!C || C.isDestroyed || B.notifyStateChange(C);
|
|
3772
|
+
}, [C, m]), !C)
|
|
3745
3773
|
return null;
|
|
3746
|
-
const S = H(
|
|
3747
|
-
return /* @__PURE__ */
|
|
3748
|
-
!r && /* @__PURE__ */
|
|
3749
|
-
/* @__PURE__ */
|
|
3750
|
-
|
|
3774
|
+
const S = H(m), A = g === "saving" ? S.autoSaveSaving : g === "saved" ? S.autoSaveSaved : g === "error" ? S.autoSaveError : "";
|
|
3775
|
+
return /* @__PURE__ */ P("div", { className: `editor-container flex flex-col h-full ${n}`, children: [
|
|
3776
|
+
!r && /* @__PURE__ */ P("div", { className: "flex items-center", children: [
|
|
3777
|
+
/* @__PURE__ */ f(Qa, { editor: C }),
|
|
3778
|
+
A && /* @__PURE__ */ f("span", { className: `auto-save-indicator auto-save-indicator--${g} ml-2`, children: A })
|
|
3751
3779
|
] }),
|
|
3752
|
-
!r &&
|
|
3753
|
-
!r &&
|
|
3754
|
-
!r &&
|
|
3755
|
-
/* @__PURE__ */
|
|
3756
|
-
!r &&
|
|
3757
|
-
/* @__PURE__ */
|
|
3780
|
+
!r && C && /* @__PURE__ */ f(ei, { editor: C }),
|
|
3781
|
+
!r && C && /* @__PURE__ */ f(ri, { editor: C, onSelectionOptimize: s }),
|
|
3782
|
+
!r && C && /* @__PURE__ */ f(ai, { editor: C }),
|
|
3783
|
+
/* @__PURE__ */ P("div", { className: "flex flex-1 overflow-hidden", children: [
|
|
3784
|
+
!r && C && /* @__PURE__ */ f(li, { editor: C, defaultCollapsed: l }),
|
|
3785
|
+
/* @__PURE__ */ f("div", { className: "flex-1 overflow-y-auto bg-white p-4 relative", children: /* @__PURE__ */ f(
|
|
3758
3786
|
di,
|
|
3759
3787
|
{
|
|
3760
|
-
editor:
|
|
3761
|
-
mode: r || !a ||
|
|
3788
|
+
editor: C,
|
|
3789
|
+
mode: r || !a || h.status === "streaming" && h.activeSectionType === "claims" ? "readonly" : "edit"
|
|
3762
3790
|
}
|
|
3763
3791
|
) })
|
|
3764
3792
|
] }),
|
|
3765
|
-
!r && /* @__PURE__ */
|
|
3793
|
+
!r && /* @__PURE__ */ f(ii, { editor: C })
|
|
3766
3794
|
] });
|
|
3767
3795
|
};
|
|
3768
3796
|
function ln(e) {
|
|
@@ -3788,24 +3816,24 @@ function ln(e) {
|
|
|
3788
3816
|
continue;
|
|
3789
3817
|
}
|
|
3790
3818
|
if (!d.startsWith("data: ")) continue;
|
|
3791
|
-
const
|
|
3792
|
-
if (
|
|
3819
|
+
const m = d.slice(6).trim();
|
|
3820
|
+
if (m === "[DONE]") {
|
|
3793
3821
|
a.enqueue({ type: "done" }), a.close();
|
|
3794
3822
|
return;
|
|
3795
3823
|
}
|
|
3796
3824
|
try {
|
|
3797
|
-
const
|
|
3798
|
-
if (
|
|
3825
|
+
const g = JSON.parse(m), h = c || g.type;
|
|
3826
|
+
if (h === "delta" || !h && g.content != null)
|
|
3799
3827
|
a.enqueue({
|
|
3800
3828
|
type: "delta",
|
|
3801
|
-
content:
|
|
3829
|
+
content: g.content ?? g.text ?? ((i = g.delta) == null ? void 0 : i.content) ?? ""
|
|
3802
3830
|
});
|
|
3803
|
-
else if (
|
|
3804
|
-
a.enqueue({ type: "patch", patch:
|
|
3805
|
-
else if (
|
|
3806
|
-
a.enqueue({ type: "done", usage:
|
|
3831
|
+
else if (h === "patch")
|
|
3832
|
+
a.enqueue({ type: "patch", patch: g });
|
|
3833
|
+
else if (h === "done") {
|
|
3834
|
+
a.enqueue({ type: "done", usage: g.usage }), a.close();
|
|
3807
3835
|
return;
|
|
3808
|
-
} else
|
|
3836
|
+
} else h === "error" && a.enqueue({ type: "error", message: g.message || "Unknown error" });
|
|
3809
3837
|
} catch {
|
|
3810
3838
|
}
|
|
3811
3839
|
c = "";
|
|
@@ -3894,8 +3922,8 @@ function pi(e, t) {
|
|
|
3894
3922
|
};
|
|
3895
3923
|
}
|
|
3896
3924
|
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),
|
|
3925
|
+
({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, editable: i = !0, language: s, aiService: o, chatSessionAPI: l, aiBaseUrl: c, aiHeaders: d, onSelectionOptimize: m, patchEditorId: g, defaultOutlineCollapsed: h }, p) => {
|
|
3926
|
+
const { setEditorLanguage: b, setAIService: y, setChatSessionAPI: w } = I(), T = W(null), C = j((S) => {
|
|
3899
3927
|
T.current = S;
|
|
3900
3928
|
}, []), x = Ee.useMemo(() => {
|
|
3901
3929
|
if (e) return e;
|
|
@@ -3907,33 +3935,33 @@ const hi = It(
|
|
|
3907
3935
|
o ? y(o) : c && y(fi(c, d));
|
|
3908
3936
|
}, [o, c, d, y]), Ee.useEffect(() => {
|
|
3909
3937
|
l ? w(l) : c && w(pi(c, d));
|
|
3910
|
-
}, [l, c, d, w]), Nt(
|
|
3938
|
+
}, [l, c, d, w]), Nt(p, () => ({
|
|
3911
3939
|
getContent: () => {
|
|
3912
3940
|
var S;
|
|
3913
3941
|
return ((S = T.current) == null ? void 0 : S.getJSON()) ?? null;
|
|
3914
3942
|
},
|
|
3915
3943
|
setContent: (S) => {
|
|
3916
|
-
var
|
|
3917
|
-
(
|
|
3944
|
+
var A;
|
|
3945
|
+
(A = T.current) == null || A.commands.setContent(S);
|
|
3918
3946
|
},
|
|
3919
3947
|
getEditor: () => T.current,
|
|
3920
|
-
execCommand: async (S,
|
|
3948
|
+
execCommand: async (S, A) => T.current ? ct(T.current).execCommand(S, A) : null,
|
|
3921
3949
|
focus: () => {
|
|
3922
3950
|
var S;
|
|
3923
3951
|
(S = T.current) == null || S.commands.focus();
|
|
3924
3952
|
}
|
|
3925
|
-
})), /* @__PURE__ */
|
|
3953
|
+
})), /* @__PURE__ */ f(
|
|
3926
3954
|
gi,
|
|
3927
3955
|
{
|
|
3928
3956
|
initialContent: x,
|
|
3929
3957
|
onChange: n,
|
|
3930
|
-
onEditorReady:
|
|
3958
|
+
onEditorReady: C,
|
|
3931
3959
|
className: r,
|
|
3932
3960
|
readOnly: a,
|
|
3933
3961
|
editable: i,
|
|
3934
|
-
onSelectionOptimize:
|
|
3935
|
-
patchEditorId:
|
|
3936
|
-
defaultOutlineCollapsed:
|
|
3962
|
+
onSelectionOptimize: m,
|
|
3963
|
+
patchEditorId: g,
|
|
3964
|
+
defaultOutlineCollapsed: h
|
|
3937
3965
|
}
|
|
3938
3966
|
);
|
|
3939
3967
|
}
|
|
@@ -3950,8 +3978,8 @@ async function js(e, t, n) {
|
|
|
3950
3978
|
if (c) break;
|
|
3951
3979
|
if (!d) continue;
|
|
3952
3980
|
(i = n.onChunk) == null || i.call(n, d);
|
|
3953
|
-
const
|
|
3954
|
-
e.view.dispatch(
|
|
3981
|
+
const m = e.state.tr.insertText(d, l);
|
|
3982
|
+
e.view.dispatch(m), l = m.mapping.map(l, 1);
|
|
3955
3983
|
}
|
|
3956
3984
|
n.mode === "section" && typeof n.targetSectionPos == "number" && nt(e, n.targetSectionPos), (s = n.onComplete) == null || s.call(n);
|
|
3957
3985
|
} catch (l) {
|
|
@@ -3959,47 +3987,47 @@ async function js(e, t, n) {
|
|
|
3959
3987
|
}
|
|
3960
3988
|
}
|
|
3961
3989
|
async function Gs(e, t, n, r) {
|
|
3962
|
-
var i, s, o, l, c, d,
|
|
3990
|
+
var i, s, o, l, c, d, m, g;
|
|
3963
3991
|
const a = new AbortController();
|
|
3964
3992
|
(i = r.onStart) == null || i.call(r), r.mode === "section" && typeof r.targetSectionPos == "number" && un(e, r.targetSectionPos);
|
|
3965
3993
|
try {
|
|
3966
|
-
const
|
|
3994
|
+
const h = await fetch(t, {
|
|
3967
3995
|
method: "POST",
|
|
3968
3996
|
headers: { "Content-Type": "application/json" },
|
|
3969
3997
|
body: JSON.stringify(n),
|
|
3970
3998
|
signal: a.signal
|
|
3971
3999
|
});
|
|
3972
|
-
if (!
|
|
3973
|
-
throw new Error(`HTTP ${
|
|
3974
|
-
const
|
|
3975
|
-
if (!
|
|
4000
|
+
if (!h.ok)
|
|
4001
|
+
throw new Error(`HTTP ${h.status}: ${h.statusText}`);
|
|
4002
|
+
const p = (s = h.body) == null ? void 0 : s.getReader();
|
|
4003
|
+
if (!p) throw new Error("No response body");
|
|
3976
4004
|
const b = new TextDecoder();
|
|
3977
4005
|
let y = dn(e, r), w = "";
|
|
3978
4006
|
for (; ; ) {
|
|
3979
|
-
const { done: T, value:
|
|
4007
|
+
const { done: T, value: C } = await p.read();
|
|
3980
4008
|
if (T) break;
|
|
3981
|
-
w += b.decode(
|
|
4009
|
+
w += b.decode(C, { stream: !0 });
|
|
3982
4010
|
const x = w.split(`
|
|
3983
4011
|
`);
|
|
3984
4012
|
w = x.pop() || "";
|
|
3985
4013
|
for (const S of x) {
|
|
3986
4014
|
if (!S.startsWith("data: ")) continue;
|
|
3987
|
-
const
|
|
3988
|
-
if (
|
|
4015
|
+
const A = S.slice(6).trim();
|
|
4016
|
+
if (A === "[DONE]")
|
|
3989
4017
|
return r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (o = r.onComplete) == null || o.call(r), { abort: () => a.abort() };
|
|
3990
4018
|
try {
|
|
3991
|
-
const
|
|
3992
|
-
if (!
|
|
3993
|
-
(c = r.onChunk) == null || c.call(r,
|
|
3994
|
-
const _ = e.state.tr.insertText(
|
|
4019
|
+
const u = JSON.parse(A), v = u.content || u.text || ((l = u.delta) == null ? void 0 : l.content) || "";
|
|
4020
|
+
if (!v) continue;
|
|
4021
|
+
(c = r.onChunk) == null || c.call(r, v);
|
|
4022
|
+
const _ = e.state.tr.insertText(v, y);
|
|
3995
4023
|
e.view.dispatch(_), y = _.mapping.map(y, 1);
|
|
3996
4024
|
} catch {
|
|
3997
4025
|
}
|
|
3998
4026
|
}
|
|
3999
4027
|
}
|
|
4000
4028
|
r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (d = r.onComplete) == null || d.call(r);
|
|
4001
|
-
} catch (
|
|
4002
|
-
|
|
4029
|
+
} catch (h) {
|
|
4030
|
+
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
4031
|
}
|
|
4004
4032
|
return { abort: () => a.abort() };
|
|
4005
4033
|
}
|
|
@@ -4110,7 +4138,7 @@ S103:局部实时避障控制。采用模型预测控制(MPC)策略,以
|
|
|
4110
4138
|
S104:安全验证。对计算得到的控制指令进行轨迹传播仿真,验证机动后轨迹在未来72小时内不会与TLE目录中的已知空间目标产生碰撞风险(miss distance > 1km)。`,
|
|
4111
4139
|
en: "The technical solution of the embodiments of the present invention will be described clearly and completely below with reference to the drawings."
|
|
4112
4140
|
}
|
|
4113
|
-
},
|
|
4141
|
+
}, Le = {
|
|
4114
4142
|
"help-draft": {
|
|
4115
4143
|
zh: `当然可以帮你撰写技术方案!请先描述以下信息:
|
|
4116
4144
|
|
|
@@ -4169,7 +4197,7 @@ S104:安全验证。对计算得到的控制指令进行轨迹传播仿真,
|
|
|
4169
4197
|
你可以选中文档中的文字使用浮动菜单的AI操作,或者在左侧面板点击章节的"AI生成"按钮来体验这些功能。`,
|
|
4170
4198
|
en: "That is a great question. As an AI patent writing assistant, I can help you with..."
|
|
4171
4199
|
}
|
|
4172
|
-
},
|
|
4200
|
+
}, ne = (e) => new Promise((t) => setTimeout(t, e));
|
|
4173
4201
|
function rt(e, t = 30) {
|
|
4174
4202
|
let n = !1;
|
|
4175
4203
|
return new ReadableStream({
|
|
@@ -4179,7 +4207,7 @@ function rt(e, t = 30) {
|
|
|
4179
4207
|
r.close();
|
|
4180
4208
|
return;
|
|
4181
4209
|
}
|
|
4182
|
-
r.enqueue(a), a.type === "delta" && await
|
|
4210
|
+
r.enqueue(a), a.type === "delta" && await ne(t);
|
|
4183
4211
|
}
|
|
4184
4212
|
r.close();
|
|
4185
4213
|
},
|
|
@@ -4203,7 +4231,7 @@ function $e(e, t) {
|
|
|
4203
4231
|
function bi(e, t, n) {
|
|
4204
4232
|
const r = n === "zh", a = [];
|
|
4205
4233
|
let i;
|
|
4206
|
-
if (e.includes("技术方案") || e.includes("draft") ? i =
|
|
4234
|
+
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
4235
|
const s = r ? `正在分析引用的 ${t.length} 段文本并生成优化建议...
|
|
4208
4236
|
|
|
4209
4237
|
` : `Analyzing ${t.length} referenced text(s) and generating suggestions...
|
|
@@ -4253,7 +4281,7 @@ function Vs() {
|
|
|
4253
4281
|
return {
|
|
4254
4282
|
async request(t) {
|
|
4255
4283
|
var o;
|
|
4256
|
-
if (e = new AbortController(), await
|
|
4284
|
+
if (e = new AbortController(), await ne(300), e.signal.aborted)
|
|
4257
4285
|
throw new DOMException("Aborted", "AbortError");
|
|
4258
4286
|
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
4287
|
let i = a;
|
|
@@ -4275,7 +4303,7 @@ function Js() {
|
|
|
4275
4303
|
let t = null, n = null;
|
|
4276
4304
|
return {
|
|
4277
4305
|
async createSession(r, a, i) {
|
|
4278
|
-
await
|
|
4306
|
+
await ne(100);
|
|
4279
4307
|
const s = `sess_${Date.now()}`, o = {
|
|
4280
4308
|
sessionId: s,
|
|
4281
4309
|
patentId: r || void 0,
|
|
@@ -4287,21 +4315,21 @@ function Js() {
|
|
|
4287
4315
|
return e.set(s, { session: o, messages: [] }), o;
|
|
4288
4316
|
},
|
|
4289
4317
|
async listSessions() {
|
|
4290
|
-
await
|
|
4318
|
+
await ne(50);
|
|
4291
4319
|
const r = Array.from(e.values()).map((a) => a.session);
|
|
4292
4320
|
return { total: r.length, items: r };
|
|
4293
4321
|
},
|
|
4294
4322
|
async getMessages(r) {
|
|
4295
|
-
await
|
|
4323
|
+
await ne(50);
|
|
4296
4324
|
const a = e.get(r);
|
|
4297
4325
|
if (!a) throw new Error("Session not found");
|
|
4298
4326
|
return { total: a.messages.length, items: a.messages };
|
|
4299
4327
|
},
|
|
4300
4328
|
async deleteSession(r) {
|
|
4301
|
-
await
|
|
4329
|
+
await ne(50), e.delete(r);
|
|
4302
4330
|
},
|
|
4303
4331
|
async sendMessage(r, a) {
|
|
4304
|
-
await
|
|
4332
|
+
await ne(150);
|
|
4305
4333
|
const i = e.get(r);
|
|
4306
4334
|
if (!i) throw new Error("Session not found");
|
|
4307
4335
|
const s = `msg_${Date.now()}`;
|
|
@@ -4321,7 +4349,7 @@ function Js() {
|
|
|
4321
4349
|
return n = { messageId: s, events: o }, { messageId: s, sessionId: r, status: "processing" };
|
|
4322
4350
|
},
|
|
4323
4351
|
async subscribeStream(r, a) {
|
|
4324
|
-
t = new AbortController(), await
|
|
4352
|
+
t = new AbortController(), await ne(100);
|
|
4325
4353
|
const i = e.get(r);
|
|
4326
4354
|
if (!i) throw new Error("Session not found");
|
|
4327
4355
|
if (!n || n.messageId !== a)
|
|
@@ -4360,8 +4388,8 @@ function vi(e) {
|
|
|
4360
4388
|
if (a.length === 0)
|
|
4361
4389
|
return t.push({ number: 1, text: n, dependsOn: [] }), t;
|
|
4362
4390
|
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:
|
|
4391
|
+
const o = a[s].index + a[s].matchLength, l = s + 1 < a.length ? a[s + 1].index : n.length, c = n.slice(o, l).trim(), d = a[s].number, m = wi(c, d);
|
|
4392
|
+
t.push({ number: d, text: c, dependsOn: m });
|
|
4365
4393
|
}
|
|
4366
4394
|
return t;
|
|
4367
4395
|
}
|
|
@@ -4390,7 +4418,7 @@ function Ks(e) {
|
|
|
4390
4418
|
const xi = -1, Ci = 1, Ti = 0, at = new we("docDiff");
|
|
4391
4419
|
let Ye = null;
|
|
4392
4420
|
function Si() {
|
|
4393
|
-
return Ye || (Ye = new
|
|
4421
|
+
return Ye || (Ye = new Lt()), Ye;
|
|
4394
4422
|
}
|
|
4395
4423
|
function Ei(e, t, n) {
|
|
4396
4424
|
const r = [];
|
|
@@ -4407,31 +4435,31 @@ function Xs(e, t) {
|
|
|
4407
4435
|
s.diff_cleanupSemantic(o);
|
|
4408
4436
|
const l = [];
|
|
4409
4437
|
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 =
|
|
4438
|
+
for (const [g, h] of o)
|
|
4439
|
+
if (g === Ti)
|
|
4440
|
+
c += h.length;
|
|
4441
|
+
else if (g === Ci) {
|
|
4442
|
+
let p = 0;
|
|
4443
|
+
for (; p < h.length; ) {
|
|
4444
|
+
for (; p < h.length && h[p] === "\0"; ) p++;
|
|
4445
|
+
if (p >= h.length) break;
|
|
4446
|
+
const b = p;
|
|
4447
|
+
for (; p < h.length && h[p] !== "\0"; ) p++;
|
|
4448
|
+
const y = be(i, c + b), w = be(i, c + p);
|
|
4421
4449
|
if (y >= 0 && w >= 0 && w > y)
|
|
4422
4450
|
for (const T of Ei(n, y, w))
|
|
4423
4451
|
l.push(
|
|
4424
|
-
|
|
4452
|
+
ae.inline(T.from, T.to, { class: "patch-diff-insert-inline" })
|
|
4425
4453
|
);
|
|
4426
4454
|
}
|
|
4427
|
-
c +=
|
|
4428
|
-
} else if (
|
|
4429
|
-
const
|
|
4430
|
-
if (
|
|
4431
|
-
const b =
|
|
4455
|
+
c += h.length;
|
|
4456
|
+
} else if (g === xi) {
|
|
4457
|
+
const p = be(i, c);
|
|
4458
|
+
if (p >= 0) {
|
|
4459
|
+
const b = h.replace(/\0/g, " ");
|
|
4432
4460
|
l.push(
|
|
4433
|
-
|
|
4434
|
-
|
|
4461
|
+
ae.widget(
|
|
4462
|
+
p,
|
|
4435
4463
|
() => {
|
|
4436
4464
|
const y = document.createElement("span");
|
|
4437
4465
|
return y.className = "patch-diff-delete", y.textContent = b, y;
|
|
@@ -4441,19 +4469,19 @@ function Xs(e, t) {
|
|
|
4441
4469
|
);
|
|
4442
4470
|
}
|
|
4443
4471
|
}
|
|
4444
|
-
const d =
|
|
4472
|
+
const d = de.create(n, l), m = new Be({
|
|
4445
4473
|
key: at,
|
|
4446
4474
|
state: {
|
|
4447
4475
|
init: () => d,
|
|
4448
|
-
apply: (
|
|
4476
|
+
apply: (g, h) => g.docChanged ? h.map(g.mapping, g.doc) : h
|
|
4449
4477
|
},
|
|
4450
4478
|
props: {
|
|
4451
|
-
decorations(
|
|
4452
|
-
return at.getState(
|
|
4479
|
+
decorations(g) {
|
|
4480
|
+
return at.getState(g);
|
|
4453
4481
|
}
|
|
4454
4482
|
}
|
|
4455
4483
|
});
|
|
4456
|
-
e.registerPlugin(
|
|
4484
|
+
e.registerPlugin(m);
|
|
4457
4485
|
}
|
|
4458
4486
|
function Ys(e) {
|
|
4459
4487
|
e.unregisterPlugin(at);
|
|
@@ -4517,7 +4545,7 @@ function Ze(e) {
|
|
|
4517
4545
|
return new He({
|
|
4518
4546
|
children: [new Ue({ text: e, size: 24, font: "宋体" })],
|
|
4519
4547
|
spacing: { line: 360 },
|
|
4520
|
-
indent: { firstLine:
|
|
4548
|
+
indent: { firstLine: ye(7) }
|
|
4521
4549
|
});
|
|
4522
4550
|
}
|
|
4523
4551
|
function Ai(e, t) {
|
|
@@ -4556,10 +4584,10 @@ async function Zs(e, t) {
|
|
|
4556
4584
|
properties: {
|
|
4557
4585
|
page: {
|
|
4558
4586
|
margin: {
|
|
4559
|
-
top:
|
|
4560
|
-
bottom:
|
|
4561
|
-
left:
|
|
4562
|
-
right:
|
|
4587
|
+
top: ye(25),
|
|
4588
|
+
bottom: ye(25),
|
|
4589
|
+
left: ye(25),
|
|
4590
|
+
right: ye(20)
|
|
4563
4591
|
}
|
|
4564
4592
|
}
|
|
4565
4593
|
},
|
|
@@ -4625,16 +4653,16 @@ function eo(e, t) {
|
|
|
4625
4653
|
}
|
|
4626
4654
|
if (l === "claims") {
|
|
4627
4655
|
const d = /^(\d+)\s*[.、]/;
|
|
4628
|
-
s.forEach((
|
|
4629
|
-
if (
|
|
4630
|
-
const
|
|
4631
|
-
if (!
|
|
4632
|
-
const b =
|
|
4633
|
-
|
|
4656
|
+
s.forEach((m, g) => {
|
|
4657
|
+
if (m.type.name !== "paragraph") return;
|
|
4658
|
+
const h = m.textContent.trim(), p = d.exec(h);
|
|
4659
|
+
if (!p) return;
|
|
4660
|
+
const b = p[1];
|
|
4661
|
+
h.length > 0 && !h.endsWith("。") && !h.endsWith(".") && n.push({
|
|
4634
4662
|
id: i(),
|
|
4635
4663
|
severity: "warning",
|
|
4636
4664
|
message: r ? `权利要求${b}末尾应以句号结束` : `Claim ${b} should end with a period`,
|
|
4637
|
-
pos: o + 1 +
|
|
4665
|
+
pos: o + 1 + g
|
|
4638
4666
|
});
|
|
4639
4667
|
});
|
|
4640
4668
|
}
|
|
@@ -4643,8 +4671,8 @@ function eo(e, t) {
|
|
|
4643
4671
|
return !0;
|
|
4644
4672
|
}), n;
|
|
4645
4673
|
}
|
|
4646
|
-
const
|
|
4647
|
-
function
|
|
4674
|
+
const Pi = /^(\d+)\s*[.、]\s*/, kt = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g, _t = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
|
|
4675
|
+
function Li(e, t) {
|
|
4648
4676
|
const n = [];
|
|
4649
4677
|
let r;
|
|
4650
4678
|
for (kt.lastIndex = 0; (r = kt.exec(e)) !== null; ) {
|
|
@@ -4687,11 +4715,11 @@ const mn = (e) => {
|
|
|
4687
4715
|
if (n.type.name === "patent_section")
|
|
4688
4716
|
return n.attrs.sectionType === "claims";
|
|
4689
4717
|
if (n.type.name !== "paragraph") return !0;
|
|
4690
|
-
const a = mn(n).trim(), i =
|
|
4718
|
+
const a = mn(n).trim(), i = Pi.exec(a);
|
|
4691
4719
|
if (!i) return !0;
|
|
4692
4720
|
const s = parseInt(i[1], 10);
|
|
4693
4721
|
if (!Number.isFinite(s) || s <= 0) return !0;
|
|
4694
|
-
const o = a.slice(i[0].length).trim(), l =
|
|
4722
|
+
const o = a.slice(i[0].length).trim(), l = Li(o, s);
|
|
4695
4723
|
return t.push({
|
|
4696
4724
|
claimId: `claim_${s}`,
|
|
4697
4725
|
number: s,
|