patent-editor 0.2.8 → 0.2.10
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.css +1 -1
- package/dist/lib.js +1085 -1092
- package/dist/lib.js.map +1 -1
- package/package.json +126 -126
package/dist/lib.js
CHANGED
|
@@ -2,7 +2,7 @@ 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
4
|
import { jsx as g, jsxs as L, Fragment as je } from "react/jsx-runtime";
|
|
5
|
-
import Ee, { forwardRef as It, useState as
|
|
5
|
+
import Ee, { forwardRef as It, useState as F, useEffect as M, useCallback as ae, useImperativeHandle as Nt, useRef as W, useMemo as At } from "react";
|
|
6
6
|
import { Extension as Oe, ReactRenderer as kn, Node as Z, mergeAttributes as ie, NodeViewWrapper as _n, ReactNodeViewRenderer as Lt, EditorContent as In, useEditor as Nn } from "@tiptap/react";
|
|
7
7
|
import An from "@tiptap/extension-document";
|
|
8
8
|
import Ln from "@tiptap/extension-paragraph";
|
|
@@ -16,8 +16,8 @@ import zn from "@tiptap/extension-code-block";
|
|
|
16
16
|
import On from "@tiptap/extension-horizontal-rule";
|
|
17
17
|
import Bn from "@tiptap/extension-task-list";
|
|
18
18
|
import Hn from "@tiptap/extension-task-item";
|
|
19
|
-
import
|
|
20
|
-
import { Table as
|
|
19
|
+
import Un from "@tiptap/extension-image";
|
|
20
|
+
import { Table as qn } from "@tiptap/extension-table";
|
|
21
21
|
import Wn from "@tiptap/extension-table-row";
|
|
22
22
|
import jn from "@tiptap/extension-table-cell";
|
|
23
23
|
import Gn from "@tiptap/extension-table-header";
|
|
@@ -49,12 +49,12 @@ 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 Lr, Table as Pr, Minus as Dr, CheckSquare as Rr, Image as Bt, Link2 as Ht, FileText as
|
|
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 Lr, Table as Pr, 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
53
|
import Y from "clsx";
|
|
54
|
-
import { BubbleMenu as
|
|
55
|
-
import { convertMillimetersToTwip as he, Document as
|
|
56
|
-
import { saveAs as
|
|
57
|
-
const
|
|
54
|
+
import { BubbleMenu as Jr } from "@tiptap/react/menus";
|
|
55
|
+
import { convertMillimetersToTwip as he, Document as Kr, Packer as Xr, Paragraph as He, AlignmentType as it, TextRun as Ue } from "docx";
|
|
56
|
+
import { saveAs as Yr } from "file-saver";
|
|
57
|
+
const Zr = new we("slashCommand"), Qr = Oe.create({
|
|
58
58
|
name: "slashCommand",
|
|
59
59
|
addOptions() {
|
|
60
60
|
return {
|
|
@@ -71,11 +71,11 @@ const Qr = new we("slashCommand"), ea = Oe.create({
|
|
|
71
71
|
Qn({
|
|
72
72
|
editor: this.editor,
|
|
73
73
|
...this.options.suggestion,
|
|
74
|
-
pluginKey:
|
|
74
|
+
pluginKey: Zr
|
|
75
75
|
})
|
|
76
76
|
];
|
|
77
77
|
}
|
|
78
|
-
}),
|
|
78
|
+
}), ea = {
|
|
79
79
|
visible: !0,
|
|
80
80
|
activeTab: "chat",
|
|
81
81
|
activeSectionType: null,
|
|
@@ -83,7 +83,7 @@ const Qr = new we("slashCommand"), ea = Oe.create({
|
|
|
83
83
|
regenerate: !1,
|
|
84
84
|
chatReferences: [],
|
|
85
85
|
pendingChatMessage: null
|
|
86
|
-
},
|
|
86
|
+
}, N = tr((e) => ({
|
|
87
87
|
editor: null,
|
|
88
88
|
document: null,
|
|
89
89
|
selection: null,
|
|
@@ -94,7 +94,7 @@ const Qr = new we("slashCommand"), ea = Oe.create({
|
|
|
94
94
|
aiService: null,
|
|
95
95
|
chatSessionAPI: null,
|
|
96
96
|
chatSessionId: null,
|
|
97
|
-
rightPanel: { ...
|
|
97
|
+
rightPanel: { ...ea },
|
|
98
98
|
setEditor: (t) => e({ editor: t }),
|
|
99
99
|
setDocument: (t) => e({ document: t }),
|
|
100
100
|
setSelection: (t) => e({ selection: t }),
|
|
@@ -164,39 +164,39 @@ const Qr = new we("slashCommand"), ea = Oe.create({
|
|
|
164
164
|
}))
|
|
165
165
|
})), Wt = It(
|
|
166
166
|
({ items: e, command: t }, n) => {
|
|
167
|
-
const [r, a] =
|
|
167
|
+
const [r, a] = F(0);
|
|
168
168
|
M(() => {
|
|
169
169
|
a(0);
|
|
170
170
|
}, [e]);
|
|
171
171
|
const i = ae(
|
|
172
|
-
(
|
|
173
|
-
const
|
|
174
|
-
|
|
172
|
+
(s) => {
|
|
173
|
+
const o = e[s];
|
|
174
|
+
o && t(o);
|
|
175
175
|
},
|
|
176
176
|
[e, t]
|
|
177
177
|
);
|
|
178
178
|
return Nt(n, () => ({
|
|
179
|
-
onKeyDown: ({ event:
|
|
180
|
-
})), e.length ? /* @__PURE__ */ g("div", { className: "slash-menu", children: e.map((
|
|
179
|
+
onKeyDown: ({ event: s }) => s.key === "ArrowUp" ? (a((o) => (o + e.length - 1) % e.length), !0) : s.key === "ArrowDown" ? (a((o) => (o + 1) % e.length), !0) : s.key === "Enter" ? (i(r), !0) : !1
|
|
180
|
+
})), e.length ? /* @__PURE__ */ g("div", { className: "slash-menu", children: e.map((s, o) => /* @__PURE__ */ L(
|
|
181
181
|
"button",
|
|
182
182
|
{
|
|
183
|
-
className: `slash-menu-item ${
|
|
184
|
-
onClick: () => i(
|
|
185
|
-
onMouseEnter: () => a(
|
|
183
|
+
className: `slash-menu-item ${o === r ? "slash-menu-item--active" : ""}`,
|
|
184
|
+
onClick: () => i(o),
|
|
185
|
+
onMouseEnter: () => a(o),
|
|
186
186
|
children: [
|
|
187
|
-
/* @__PURE__ */ g("span", { className: "slash-menu-icon", children:
|
|
187
|
+
/* @__PURE__ */ g("span", { className: "slash-menu-icon", children: s.icon }),
|
|
188
188
|
/* @__PURE__ */ L("div", { className: "slash-menu-text", children: [
|
|
189
|
-
/* @__PURE__ */ g("span", { className: "slash-menu-title", children:
|
|
190
|
-
/* @__PURE__ */ g("span", { className: "slash-menu-desc", children:
|
|
189
|
+
/* @__PURE__ */ g("span", { className: "slash-menu-title", children: s.title }),
|
|
190
|
+
/* @__PURE__ */ g("span", { className: "slash-menu-desc", children: s.description })
|
|
191
191
|
] })
|
|
192
192
|
]
|
|
193
193
|
},
|
|
194
|
-
|
|
194
|
+
s.title
|
|
195
195
|
)) }) : /* @__PURE__ */ g("div", { className: "slash-menu", children: /* @__PURE__ */ g("div", { className: "slash-menu-empty", children: "No results" }) });
|
|
196
196
|
}
|
|
197
197
|
);
|
|
198
198
|
Wt.displayName = "SlashMenuList";
|
|
199
|
-
function
|
|
199
|
+
function ta(e) {
|
|
200
200
|
const t = e === "zh";
|
|
201
201
|
return [
|
|
202
202
|
{
|
|
@@ -298,11 +298,11 @@ function na(e) {
|
|
|
298
298
|
}
|
|
299
299
|
];
|
|
300
300
|
}
|
|
301
|
-
function
|
|
301
|
+
function na() {
|
|
302
302
|
return {
|
|
303
303
|
char: "/",
|
|
304
304
|
items: ({ query: e }) => {
|
|
305
|
-
const t =
|
|
305
|
+
const t = N.getState().editorLanguage, n = ta(t);
|
|
306
306
|
if (!e) return n;
|
|
307
307
|
const r = e.toLowerCase();
|
|
308
308
|
return n.filter(
|
|
@@ -343,33 +343,33 @@ function ra() {
|
|
|
343
343
|
}
|
|
344
344
|
};
|
|
345
345
|
}
|
|
346
|
-
const
|
|
346
|
+
const ra = new we("searchReplace");
|
|
347
347
|
function ke(e, t, n) {
|
|
348
348
|
if (!t) return [];
|
|
349
349
|
const r = [], a = e.textBetween(0, e.content.size, `
|
|
350
|
-
`, "\0"), i = n ? t : t.toLowerCase(),
|
|
351
|
-
let
|
|
352
|
-
for (;
|
|
353
|
-
const
|
|
354
|
-
if (
|
|
355
|
-
let l = 0, d = -1,
|
|
356
|
-
e.descendants((
|
|
357
|
-
if (d !== -1 &&
|
|
358
|
-
if (
|
|
359
|
-
const p =
|
|
360
|
-
for (let
|
|
361
|
-
if (l ===
|
|
362
|
-
return
|
|
350
|
+
`, "\0"), i = n ? t : t.toLowerCase(), s = n ? a : a.toLowerCase();
|
|
351
|
+
let o = 0;
|
|
352
|
+
for (; o < s.length; ) {
|
|
353
|
+
const c = s.indexOf(i, o);
|
|
354
|
+
if (c === -1) break;
|
|
355
|
+
let l = 0, d = -1, u = -1;
|
|
356
|
+
e.descendants((m, f) => {
|
|
357
|
+
if (d !== -1 && u !== -1) return !1;
|
|
358
|
+
if (m.isText) {
|
|
359
|
+
const p = m.text || "";
|
|
360
|
+
for (let h = 0; h < p.length; h++) {
|
|
361
|
+
if (l === c && (d = f + h), l === c + i.length)
|
|
362
|
+
return u = f + h, !1;
|
|
363
363
|
l++;
|
|
364
364
|
}
|
|
365
|
-
l ===
|
|
366
|
-
} else
|
|
365
|
+
l === c + i.length && u === -1 && (u = f + p.length);
|
|
366
|
+
} else m.isBlock && l > 0 && (l === c && (d = f), l++);
|
|
367
367
|
return !0;
|
|
368
|
-
}), d !== -1 &&
|
|
368
|
+
}), d !== -1 && u !== -1 && r.push({ from: d, to: u }), o = c + 1;
|
|
369
369
|
}
|
|
370
370
|
return r;
|
|
371
371
|
}
|
|
372
|
-
const
|
|
372
|
+
const aa = Oe.create({
|
|
373
373
|
name: "searchReplace",
|
|
374
374
|
addStorage() {
|
|
375
375
|
return {
|
|
@@ -407,10 +407,10 @@ const ia = Oe.create({
|
|
|
407
407
|
const { searchTerm: t, replaceTerm: n, caseSensitive: r } = this.storage;
|
|
408
408
|
let a = ke(e.state.doc, t, r);
|
|
409
409
|
const i = e.state.tr;
|
|
410
|
-
let
|
|
411
|
-
for (const
|
|
412
|
-
const
|
|
413
|
-
i.insertText(n,
|
|
410
|
+
let s = 0;
|
|
411
|
+
for (const o of a) {
|
|
412
|
+
const c = o.from + s, l = o.to + s;
|
|
413
|
+
i.insertText(n, c, l), s += n.length - (o.to - o.from);
|
|
414
414
|
}
|
|
415
415
|
return e.view.dispatch(i), this.storage.results = [], this.storage.currentIndex = -1, !0;
|
|
416
416
|
},
|
|
@@ -433,7 +433,7 @@ const ia = Oe.create({
|
|
|
433
433
|
const e = this.storage;
|
|
434
434
|
return [
|
|
435
435
|
new Be({
|
|
436
|
-
key:
|
|
436
|
+
key: ra,
|
|
437
437
|
props: {
|
|
438
438
|
decorations: (t) => {
|
|
439
439
|
if (!e.searchTerm || e.results.length === 0)
|
|
@@ -458,24 +458,24 @@ function ft(e) {
|
|
|
458
458
|
}
|
|
459
459
|
});
|
|
460
460
|
}
|
|
461
|
-
const
|
|
461
|
+
const ia = -1, sa = 1, pt = 0;
|
|
462
462
|
let Ge = null;
|
|
463
|
-
function
|
|
463
|
+
function oa() {
|
|
464
464
|
return Ge || (Ge = new Pt()), Ge;
|
|
465
465
|
}
|
|
466
466
|
const jt = new we("patchDiff");
|
|
467
|
-
function
|
|
467
|
+
function ca(e, t) {
|
|
468
468
|
let n = null;
|
|
469
469
|
return e.state.doc.descendants((r, a) => n ? !1 : r.type.name === "patent_section" && r.attrs.sectionType === t ? (n = { from: a + 1, to: a + r.nodeSize - 1 }, !1) : !0), n;
|
|
470
470
|
}
|
|
471
471
|
function Gt(e, t, n) {
|
|
472
472
|
const r = [];
|
|
473
473
|
let a = "", i = !0;
|
|
474
|
-
return e.state.doc.nodesBetween(t, n, (
|
|
475
|
-
if (
|
|
476
|
-
const
|
|
477
|
-
r.push({ textIdx: a.length, docPos:
|
|
478
|
-
} else
|
|
474
|
+
return e.state.doc.nodesBetween(t, n, (s, o) => {
|
|
475
|
+
if (s.isText) {
|
|
476
|
+
const c = o, l = Math.max(t, c) - c, d = Math.min(n, c + s.nodeSize) - c, u = s.text.slice(l, d);
|
|
477
|
+
r.push({ textIdx: a.length, docPos: c + l, len: u.length }), a += u, i = !1;
|
|
478
|
+
} else s.isLeaf ? (a += "\0", i = !1) : !i && s.isBlock && (a += "\0", i = !0);
|
|
479
479
|
}), { text: a, segments: r };
|
|
480
480
|
}
|
|
481
481
|
function ye(e, t) {
|
|
@@ -492,45 +492,45 @@ function ye(e, t) {
|
|
|
492
492
|
return -1;
|
|
493
493
|
}
|
|
494
494
|
function ht(e, t, n, r, a) {
|
|
495
|
-
const { text: i, segments:
|
|
496
|
-
let
|
|
497
|
-
for (;
|
|
498
|
-
const
|
|
499
|
-
if (
|
|
500
|
-
const l = ye(
|
|
495
|
+
const { text: i, segments: s } = Gt(e, n, r);
|
|
496
|
+
let o = 0;
|
|
497
|
+
for (; o <= i.length - t.length; ) {
|
|
498
|
+
const c = i.indexOf(t, o);
|
|
499
|
+
if (c === -1) return null;
|
|
500
|
+
const l = ye(s, c), d = ye(s, c + t.length);
|
|
501
501
|
if (l >= 0 && d >= 0 && !(a && a.has(l)))
|
|
502
502
|
return { from: l, to: d };
|
|
503
|
-
|
|
503
|
+
o = c + 1;
|
|
504
504
|
}
|
|
505
505
|
return null;
|
|
506
506
|
}
|
|
507
|
-
function
|
|
507
|
+
function Ds(e, t, n, r, a) {
|
|
508
508
|
const i = t.target;
|
|
509
|
-
let
|
|
510
|
-
const
|
|
509
|
+
let s = null;
|
|
510
|
+
const o = /* @__PURE__ */ new Set();
|
|
511
511
|
if (a)
|
|
512
512
|
for (const d of a)
|
|
513
|
-
|
|
513
|
+
o.add(d.from);
|
|
514
514
|
if (!i)
|
|
515
|
-
t.from != null && t.to != null && (
|
|
515
|
+
t.from != null && t.to != null && (s = { from: t.from, to: t.to });
|
|
516
516
|
else if (i.type === "section" && i.sectionType)
|
|
517
|
-
|
|
517
|
+
s = ca(e, i.sectionType);
|
|
518
518
|
else if (i.type === "ref" && i.refIndex != null) {
|
|
519
519
|
const d = n[i.refIndex];
|
|
520
|
-
(d == null ? void 0 : d.from) != null && (d == null ? void 0 : d.to) != null && (
|
|
521
|
-
} else i.type === "search" && i.searchText && (
|
|
522
|
-
if (!
|
|
523
|
-
let
|
|
520
|
+
(d == null ? void 0 : d.from) != null && (d == null ? void 0 : d.to) != null && (s = { from: d.from, to: d.to });
|
|
521
|
+
} else i.type === "search" && i.searchText && (s = ht(e, i.searchText, 0, e.state.doc.content.size, o));
|
|
522
|
+
if (!s) return null;
|
|
523
|
+
let c = s;
|
|
524
524
|
if (t.search) {
|
|
525
|
-
const d = ht(e, t.search,
|
|
526
|
-
d && (
|
|
525
|
+
const d = ht(e, t.search, s.from, s.to, o);
|
|
526
|
+
d && (c = d);
|
|
527
527
|
}
|
|
528
|
-
const l =
|
|
528
|
+
const l = c.from < c.to ? e.state.doc.textBetween(c.from, c.to, " ", "\0") : "";
|
|
529
529
|
return {
|
|
530
530
|
id: `patch_${Date.now()}_${r}`,
|
|
531
531
|
type: t.op === "delete" ? "delete" : t.op === "insert" ? "insert" : "replace",
|
|
532
|
-
from:
|
|
533
|
-
to: t.op === "insert" ?
|
|
532
|
+
from: c.from,
|
|
533
|
+
to: t.op === "insert" ? c.from : c.to,
|
|
534
534
|
content: t.content || "",
|
|
535
535
|
originalText: l,
|
|
536
536
|
reason: t.reason,
|
|
@@ -539,7 +539,7 @@ function Rs(e, t, n, r, a) {
|
|
|
539
539
|
}
|
|
540
540
|
const j = /* @__PURE__ */ new Map();
|
|
541
541
|
let De = [];
|
|
542
|
-
function
|
|
542
|
+
function Rs(e) {
|
|
543
543
|
return De.push(e), () => {
|
|
544
544
|
De = De.filter((t) => t !== e);
|
|
545
545
|
};
|
|
@@ -547,17 +547,17 @@ function Ms(e) {
|
|
|
547
547
|
function ue() {
|
|
548
548
|
De.forEach((e) => e());
|
|
549
549
|
}
|
|
550
|
-
function
|
|
550
|
+
function Ms(e = "default") {
|
|
551
551
|
return [...j.get(e) || []];
|
|
552
552
|
}
|
|
553
|
-
function
|
|
553
|
+
function Fs(e, t = "default") {
|
|
554
554
|
j.set(t, e), ue();
|
|
555
555
|
}
|
|
556
|
-
function
|
|
556
|
+
function $s(e = "default") {
|
|
557
557
|
j.delete(e), ue();
|
|
558
558
|
}
|
|
559
|
-
function
|
|
560
|
-
const r = j.get(n) || [], a = r.find((
|
|
559
|
+
function zs(e, t, n = "default") {
|
|
560
|
+
const r = j.get(n) || [], a = r.find((o) => o.id === t);
|
|
561
561
|
if (!a || a.status !== "pending") return !1;
|
|
562
562
|
a.status = "accepted";
|
|
563
563
|
const { tr: i } = e.state;
|
|
@@ -566,87 +566,87 @@ function Os(e, t, n = "default") {
|
|
|
566
566
|
else if (a.type === "insert")
|
|
567
567
|
i.insertText(a.content, a.from);
|
|
568
568
|
else if (Vt(e, a.from, a.to)) {
|
|
569
|
-
const
|
|
570
|
-
i.replaceWith(a.from, a.to,
|
|
569
|
+
const c = Jt(e, a.content);
|
|
570
|
+
i.replaceWith(a.from, a.to, c);
|
|
571
571
|
} else
|
|
572
572
|
i.insertText(a.content, a.from, a.to);
|
|
573
573
|
e.view.dispatch(i);
|
|
574
|
-
const
|
|
575
|
-
for (const
|
|
576
|
-
if (
|
|
577
|
-
const
|
|
578
|
-
|
|
574
|
+
const s = i.mapping;
|
|
575
|
+
for (const o of r) {
|
|
576
|
+
if (o.id === t || o.status !== "pending") continue;
|
|
577
|
+
const c = s.map(o.from, 1), l = s.map(o.to, -1);
|
|
578
|
+
c >= l && o.type !== "insert" ? o.status = "rejected" : (o.from = c, o.to = o.type === "insert" ? c : l);
|
|
579
579
|
}
|
|
580
|
-
return j.set(n, r.filter((
|
|
580
|
+
return j.set(n, r.filter((o) => o.id !== t && o.status === "pending")), qe(e), ue(), !0;
|
|
581
581
|
}
|
|
582
|
-
function
|
|
582
|
+
function Os(e, t, n = "default") {
|
|
583
583
|
const r = j.get(n) || [], a = r.find((i) => i.id === t);
|
|
584
|
-
return !a || a.status !== "pending" ? !1 : (a.status = "rejected", j.set(n, r.filter((i) => i.id !== t)),
|
|
584
|
+
return !a || a.status !== "pending" ? !1 : (a.status = "rejected", j.set(n, r.filter((i) => i.id !== t)), qe(e), ue(), !0);
|
|
585
585
|
}
|
|
586
|
-
function
|
|
587
|
-
const a = [...(j.get(t) || []).filter((
|
|
588
|
-
for (const
|
|
589
|
-
if (
|
|
590
|
-
i.delete(
|
|
591
|
-
else if (
|
|
592
|
-
i.insertText(
|
|
593
|
-
else if (Vt(e,
|
|
594
|
-
const
|
|
595
|
-
i.replaceWith(
|
|
586
|
+
function Bs(e, t = "default") {
|
|
587
|
+
const a = [...(j.get(t) || []).filter((s) => s.status === "pending")].sort((s, o) => o.from - s.from), { tr: i } = e.state;
|
|
588
|
+
for (const s of a)
|
|
589
|
+
if (s.type === "delete")
|
|
590
|
+
i.delete(s.from, s.to);
|
|
591
|
+
else if (s.type === "insert")
|
|
592
|
+
i.insertText(s.content, s.from);
|
|
593
|
+
else if (Vt(e, s.from, s.to)) {
|
|
594
|
+
const c = Jt(e, s.content);
|
|
595
|
+
i.replaceWith(s.from, s.to, c);
|
|
596
596
|
} else
|
|
597
|
-
i.insertText(
|
|
598
|
-
e.view.dispatch(i), j.delete(t),
|
|
597
|
+
i.insertText(s.content, s.from, s.to);
|
|
598
|
+
e.view.dispatch(i), j.delete(t), qe(e), ue();
|
|
599
599
|
}
|
|
600
|
-
function
|
|
601
|
-
j.delete(t),
|
|
600
|
+
function Hs(e, t = "default") {
|
|
601
|
+
j.delete(t), qe(e), ue();
|
|
602
602
|
}
|
|
603
|
-
function
|
|
603
|
+
function qe(e) {
|
|
604
604
|
e.view.dispatch(e.state.tr.setMeta(jt, !0));
|
|
605
605
|
}
|
|
606
|
-
function
|
|
606
|
+
function la(e, t, n) {
|
|
607
607
|
const r = [];
|
|
608
608
|
return e.nodesBetween(t, n, (a, i) => {
|
|
609
609
|
if (a.isTextblock) {
|
|
610
|
-
const
|
|
611
|
-
return l >
|
|
610
|
+
const s = i + 1, o = i + a.nodeSize - 1, c = Math.max(s, t), l = Math.min(o, n);
|
|
611
|
+
return l > c && r.push({ from: c, to: l }), !1;
|
|
612
612
|
}
|
|
613
613
|
return !0;
|
|
614
614
|
}), r;
|
|
615
615
|
}
|
|
616
|
-
function
|
|
616
|
+
function da(e, t) {
|
|
617
617
|
if (!t.originalText || !t.content) return null;
|
|
618
618
|
try {
|
|
619
|
-
const
|
|
620
|
-
if (
|
|
619
|
+
const o = e.resolve(t.from), c = e.resolve(t.to);
|
|
620
|
+
if (o.parent !== c.parent || !o.parent.isTextblock) return null;
|
|
621
621
|
} catch {
|
|
622
622
|
return null;
|
|
623
623
|
}
|
|
624
|
-
const n =
|
|
624
|
+
const n = oa(), r = n.diff_main(t.originalText, t.content);
|
|
625
625
|
n.diff_cleanupSemantic(r);
|
|
626
|
-
const a = r.filter(([
|
|
626
|
+
const a = r.filter(([o]) => o === pt).reduce((o, [, c]) => o + c.length, 0);
|
|
627
627
|
if (t.originalText.length > 0 && a / t.originalText.length < 0.3) return null;
|
|
628
628
|
const i = [];
|
|
629
|
-
let
|
|
630
|
-
for (const [
|
|
631
|
-
if (
|
|
632
|
-
|
|
633
|
-
else if (
|
|
634
|
-
const l =
|
|
629
|
+
let s = t.from;
|
|
630
|
+
for (const [o, c] of r)
|
|
631
|
+
if (o === pt)
|
|
632
|
+
s += c.length;
|
|
633
|
+
else if (o === ia) {
|
|
634
|
+
const l = s + c.length;
|
|
635
635
|
i.push(
|
|
636
|
-
re.inline(
|
|
636
|
+
re.inline(s, l, {
|
|
637
637
|
class: "patch-diff-delete",
|
|
638
638
|
"data-patch-id": t.id
|
|
639
639
|
})
|
|
640
|
-
),
|
|
641
|
-
} else
|
|
642
|
-
re.widget(
|
|
640
|
+
), s = l;
|
|
641
|
+
} else o === sa && i.push(
|
|
642
|
+
re.widget(s, () => {
|
|
643
643
|
const l = document.createElement("span");
|
|
644
|
-
return l.className = "patch-diff-insert-inline", l.textContent =
|
|
644
|
+
return l.className = "patch-diff-insert-inline", l.textContent = c, l.setAttribute("data-patch-id", t.id), l;
|
|
645
645
|
}, { side: 1 })
|
|
646
646
|
);
|
|
647
647
|
return i;
|
|
648
648
|
}
|
|
649
|
-
function
|
|
649
|
+
function ua(e = "default") {
|
|
650
650
|
return new Be({
|
|
651
651
|
key: jt,
|
|
652
652
|
props: {
|
|
@@ -656,28 +656,28 @@ function ma(e = "default") {
|
|
|
656
656
|
const r = [];
|
|
657
657
|
for (const a of n) {
|
|
658
658
|
if (a.type === "replace") {
|
|
659
|
-
const i =
|
|
659
|
+
const i = da(t.doc, a);
|
|
660
660
|
if (i) {
|
|
661
661
|
r.push(...i);
|
|
662
662
|
continue;
|
|
663
663
|
}
|
|
664
664
|
}
|
|
665
665
|
if (a.type === "delete" || a.type === "replace") {
|
|
666
|
-
const i =
|
|
667
|
-
for (const
|
|
666
|
+
const i = la(t.doc, a.from, a.to);
|
|
667
|
+
for (const s of i)
|
|
668
668
|
r.push(
|
|
669
|
-
re.inline(
|
|
669
|
+
re.inline(s.from, s.to, {
|
|
670
670
|
class: "patch-diff-delete",
|
|
671
671
|
"data-patch-id": a.id
|
|
672
672
|
})
|
|
673
673
|
);
|
|
674
674
|
if (a.type === "replace") {
|
|
675
|
-
const
|
|
675
|
+
const s = i.length > 0 ? i[i.length - 1].to : a.to, o = a.content.length > 120 || a.content.includes(`
|
|
676
676
|
`);
|
|
677
677
|
r.push(
|
|
678
|
-
re.widget(
|
|
679
|
-
const
|
|
680
|
-
return
|
|
678
|
+
re.widget(s, () => {
|
|
679
|
+
const c = document.createElement(o ? "div" : "span");
|
|
680
|
+
return c.className = o ? "patch-diff-insert-inline patch-diff-insert-block" : "patch-diff-insert-inline", c.textContent = a.content, c.setAttribute("data-patch-id", a.id), c;
|
|
681
681
|
}, { side: 1 })
|
|
682
682
|
);
|
|
683
683
|
}
|
|
@@ -709,7 +709,7 @@ function Jt(e, t) {
|
|
|
709
709
|
);
|
|
710
710
|
});
|
|
711
711
|
}
|
|
712
|
-
const
|
|
712
|
+
const ma = Z.create({
|
|
713
713
|
name: "hardBreak",
|
|
714
714
|
inline: !0,
|
|
715
715
|
group: "inline",
|
|
@@ -730,7 +730,7 @@ const ga = Z.create({
|
|
|
730
730
|
}
|
|
731
731
|
};
|
|
732
732
|
}
|
|
733
|
-
}),
|
|
733
|
+
}), ga = Oe.create({
|
|
734
734
|
name: "dragDropUX",
|
|
735
735
|
addProseMirrorPlugins() {
|
|
736
736
|
return [
|
|
@@ -741,19 +741,19 @@ const ga = Z.create({
|
|
|
741
741
|
Xn()
|
|
742
742
|
];
|
|
743
743
|
}
|
|
744
|
-
}),
|
|
744
|
+
}), fa = Oe.create({
|
|
745
745
|
name: "patchDiff",
|
|
746
746
|
addOptions() {
|
|
747
747
|
return { editorId: "default" };
|
|
748
748
|
},
|
|
749
749
|
addProseMirrorPlugins() {
|
|
750
|
-
return [
|
|
750
|
+
return [ua(this.options.editorId)];
|
|
751
751
|
}
|
|
752
|
-
}),
|
|
752
|
+
}), pa = [
|
|
753
753
|
An,
|
|
754
754
|
Ln,
|
|
755
755
|
Pn,
|
|
756
|
-
|
|
756
|
+
ga,
|
|
757
757
|
Dn.configure({
|
|
758
758
|
levels: [1, 2, 3, 4, 5, 6]
|
|
759
759
|
}),
|
|
@@ -762,11 +762,11 @@ const ga = Z.create({
|
|
|
762
762
|
Fn,
|
|
763
763
|
$n,
|
|
764
764
|
zn,
|
|
765
|
-
|
|
765
|
+
ma,
|
|
766
766
|
On,
|
|
767
767
|
Bn,
|
|
768
768
|
Hn.configure({ nested: !0 }),
|
|
769
|
-
|
|
769
|
+
Un.extend({
|
|
770
770
|
addAttributes() {
|
|
771
771
|
var e;
|
|
772
772
|
return {
|
|
@@ -782,7 +782,7 @@ const ga = Z.create({
|
|
|
782
782
|
inline: !0,
|
|
783
783
|
allowBase64: !0
|
|
784
784
|
}),
|
|
785
|
-
|
|
785
|
+
qn.configure({
|
|
786
786
|
resizable: !0
|
|
787
787
|
}),
|
|
788
788
|
Wn,
|
|
@@ -792,15 +792,15 @@ const ga = Z.create({
|
|
|
792
792
|
placeholder: ({ node: e }) => e.type.name === "heading" ? "Heading" : "Type / for commands..."
|
|
793
793
|
}),
|
|
794
794
|
Jn,
|
|
795
|
-
|
|
796
|
-
suggestion:
|
|
795
|
+
Qr.configure({
|
|
796
|
+
suggestion: na()
|
|
797
797
|
}),
|
|
798
|
-
|
|
798
|
+
aa,
|
|
799
799
|
Yn.configure({
|
|
800
800
|
types: ["heading", "paragraph"],
|
|
801
801
|
defaultAlignment: "left"
|
|
802
802
|
})
|
|
803
|
-
],
|
|
803
|
+
], ha = [
|
|
804
804
|
nr,
|
|
805
805
|
rr,
|
|
806
806
|
ar,
|
|
@@ -814,11 +814,11 @@ const ga = Z.create({
|
|
|
814
814
|
dr,
|
|
815
815
|
ur,
|
|
816
816
|
mr.configure({ multicolor: !0 })
|
|
817
|
-
],
|
|
818
|
-
...
|
|
819
|
-
...
|
|
817
|
+
], ya = [
|
|
818
|
+
...pa,
|
|
819
|
+
...ha
|
|
820
820
|
];
|
|
821
|
-
class
|
|
821
|
+
class ba {
|
|
822
822
|
constructor() {
|
|
823
823
|
Se(this, "commands", /* @__PURE__ */ new Map());
|
|
824
824
|
}
|
|
@@ -843,8 +843,8 @@ class va {
|
|
|
843
843
|
return !r || !r.isActive ? !1 : r.isActive(n);
|
|
844
844
|
}
|
|
845
845
|
async execute(t, n, r, a = {}) {
|
|
846
|
-
var d,
|
|
847
|
-
const i = Date.now(),
|
|
846
|
+
var d, u, m, f;
|
|
847
|
+
const i = Date.now(), s = a.transaction ?? !0, o = a.rollbackOnFail ?? !0, c = s ? n.editor.getJSON() : null, l = this.commands.get(t);
|
|
848
848
|
if (!l)
|
|
849
849
|
return console.warn(`Command "${t}" not found.`), (d = a.onComplete) == null || d.call(a, {
|
|
850
850
|
name: t,
|
|
@@ -852,29 +852,29 @@ class va {
|
|
|
852
852
|
durationMs: Date.now() - i
|
|
853
853
|
}), !1;
|
|
854
854
|
if (!this.canExecute(t, n, r))
|
|
855
|
-
return (
|
|
855
|
+
return (u = a.onComplete) == null || u.call(a, {
|
|
856
856
|
name: t,
|
|
857
857
|
success: !1,
|
|
858
858
|
durationMs: Date.now() - i
|
|
859
859
|
}), !1;
|
|
860
860
|
try {
|
|
861
|
-
const
|
|
862
|
-
!
|
|
863
|
-
const
|
|
861
|
+
const h = !!await l.execute(n, r);
|
|
862
|
+
!h && c && o && n.editor.commands.setContent(c);
|
|
863
|
+
const y = {
|
|
864
864
|
name: t,
|
|
865
|
-
success:
|
|
865
|
+
success: h,
|
|
866
866
|
durationMs: Date.now() - i
|
|
867
867
|
};
|
|
868
|
-
return (
|
|
868
|
+
return (m = a.onComplete) == null || m.call(a, y), h;
|
|
869
869
|
} catch (p) {
|
|
870
|
-
|
|
871
|
-
const
|
|
870
|
+
c && o && n.editor.commands.setContent(c);
|
|
871
|
+
const h = {
|
|
872
872
|
name: t,
|
|
873
873
|
success: !1,
|
|
874
874
|
durationMs: Date.now() - i,
|
|
875
875
|
error: p
|
|
876
876
|
};
|
|
877
|
-
return (f = a.onComplete) == null || f.call(a,
|
|
877
|
+
return (f = a.onComplete) == null || f.call(a, h), !1;
|
|
878
878
|
}
|
|
879
879
|
}
|
|
880
880
|
getCommand(t) {
|
|
@@ -884,8 +884,8 @@ class va {
|
|
|
884
884
|
return Array.from(this.commands.keys()).sort();
|
|
885
885
|
}
|
|
886
886
|
}
|
|
887
|
-
const le = new
|
|
888
|
-
class
|
|
887
|
+
const le = new ba();
|
|
888
|
+
class va {
|
|
889
889
|
constructor() {
|
|
890
890
|
Se(this, "plugins", /* @__PURE__ */ new Map());
|
|
891
891
|
Se(this, "lifecycleOrder", ["register", "init", "stateSync", "destroy"]);
|
|
@@ -970,7 +970,7 @@ class wa {
|
|
|
970
970
|
});
|
|
971
971
|
}
|
|
972
972
|
}
|
|
973
|
-
const B = new
|
|
973
|
+
const B = new va(), yt = {
|
|
974
974
|
zh: {
|
|
975
975
|
language: "语言",
|
|
976
976
|
bold: "加粗",
|
|
@@ -1223,7 +1223,7 @@ const Ie = () => {
|
|
|
1223
1223
|
document.querySelectorAll('body > svg[id^="standalone-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
|
|
1224
1224
|
(e.id.startsWith("dmermaid") || e.id.startsWith("dstandalone")) && e.remove();
|
|
1225
1225
|
}), document.querySelectorAll('body > div[id^="dstandalone-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > div[id^="dmermaid"]').forEach((e) => e.remove()), document.querySelectorAll('body > div[id^="standalone-mermaid-"]').forEach((e) => e.remove());
|
|
1226
|
-
},
|
|
1226
|
+
}, wa = Z.create({
|
|
1227
1227
|
name: "mermaid",
|
|
1228
1228
|
group: "block",
|
|
1229
1229
|
atom: !0,
|
|
@@ -1243,104 +1243,104 @@ const Ie = () => {
|
|
|
1243
1243
|
let r = t, a = !1;
|
|
1244
1244
|
const i = document.createElement("div");
|
|
1245
1245
|
i.classList.add("mermaid-node");
|
|
1246
|
+
const s = document.createElement("div");
|
|
1247
|
+
s.className = "mermaid-view", s.contentEditable = "false";
|
|
1246
1248
|
const o = document.createElement("div");
|
|
1247
|
-
o.className = "mermaid-
|
|
1249
|
+
o.className = "mermaid-preview", o.contentEditable = "false";
|
|
1248
1250
|
const c = document.createElement("div");
|
|
1249
|
-
c.className = "mermaid-
|
|
1250
|
-
const s = document.createElement("div");
|
|
1251
|
-
s.className = "mermaid-view-hint", o.append(c, s);
|
|
1251
|
+
c.className = "mermaid-view-hint", s.append(o, c);
|
|
1252
1252
|
const l = document.createElement("div");
|
|
1253
1253
|
l.className = "mermaid-edit";
|
|
1254
1254
|
const d = document.createElement("textarea");
|
|
1255
1255
|
d.className = "mermaid-editor-textarea", d.spellcheck = !1;
|
|
1256
|
-
const
|
|
1257
|
-
|
|
1258
|
-
const
|
|
1259
|
-
|
|
1256
|
+
const u = document.createElement("div");
|
|
1257
|
+
u.className = "mermaid-edit-toolbar";
|
|
1258
|
+
const m = document.createElement("span");
|
|
1259
|
+
m.className = "mermaid-error-msg";
|
|
1260
1260
|
const f = document.createElement("button");
|
|
1261
1261
|
f.className = "mermaid-cancel-btn", f.type = "button";
|
|
1262
1262
|
const p = document.createElement("button");
|
|
1263
|
-
p.className = "mermaid-save-btn", p.type = "button",
|
|
1264
|
-
const
|
|
1265
|
-
const
|
|
1266
|
-
typeof
|
|
1263
|
+
p.className = "mermaid-save-btn", p.type = "button", u.append(m, f, p), l.append(d, u), i.append(s, l);
|
|
1264
|
+
const h = (C) => {
|
|
1265
|
+
const I = typeof n == "function" ? n() : null;
|
|
1266
|
+
typeof I == "number" && e.commands.command(({ tr: A, dispatch: D }) => (A.setNodeMarkup(I, void 0, { ...r.attrs, ...C }), D && D(A), !0));
|
|
1267
1267
|
};
|
|
1268
|
-
let
|
|
1269
|
-
const w = async (
|
|
1270
|
-
const
|
|
1271
|
-
if (
|
|
1272
|
-
if (!
|
|
1273
|
-
|
|
1268
|
+
let y = "";
|
|
1269
|
+
const w = async (C) => {
|
|
1270
|
+
const I = C.trim();
|
|
1271
|
+
if (I !== y) {
|
|
1272
|
+
if (!I) {
|
|
1273
|
+
o.innerHTML = "", y = "";
|
|
1274
1274
|
return;
|
|
1275
1275
|
}
|
|
1276
1276
|
try {
|
|
1277
1277
|
const A = await import("mermaid");
|
|
1278
1278
|
A.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
|
|
1279
|
-
const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D,
|
|
1280
|
-
|
|
1279
|
+
const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, I);
|
|
1280
|
+
o.innerHTML = z, y = I;
|
|
1281
1281
|
} catch {
|
|
1282
|
-
|
|
1282
|
+
o.innerHTML = "", y = "";
|
|
1283
1283
|
} finally {
|
|
1284
1284
|
Ie();
|
|
1285
1285
|
}
|
|
1286
1286
|
}
|
|
1287
1287
|
}, x = () => {
|
|
1288
|
-
a || (a = !0, d.value = typeof r.attrs.code == "string" ? r.attrs.code : "",
|
|
1289
|
-
},
|
|
1288
|
+
a || (a = !0, d.value = typeof r.attrs.code == "string" ? r.attrs.code : "", m.textContent = "", m.style.display = "none", E(), requestAnimationFrame(() => d.focus()));
|
|
1289
|
+
}, T = () => {
|
|
1290
1290
|
a = !1, E();
|
|
1291
1291
|
}, v = async () => {
|
|
1292
|
-
const
|
|
1293
|
-
|
|
1294
|
-
const
|
|
1295
|
-
if (
|
|
1292
|
+
const C = d.value;
|
|
1293
|
+
m.textContent = "", m.style.display = "none";
|
|
1294
|
+
const I = C.trim();
|
|
1295
|
+
if (I)
|
|
1296
1296
|
try {
|
|
1297
1297
|
const A = await import("mermaid");
|
|
1298
1298
|
A.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
|
|
1299
|
-
const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D,
|
|
1300
|
-
|
|
1299
|
+
const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, I);
|
|
1300
|
+
o.innerHTML = z, y = I, Ie();
|
|
1301
1301
|
} catch {
|
|
1302
1302
|
Ie();
|
|
1303
|
-
const A =
|
|
1304
|
-
|
|
1303
|
+
const A = N.getState().editorLanguage;
|
|
1304
|
+
m.textContent = A === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", m.style.display = "inline";
|
|
1305
1305
|
return;
|
|
1306
1306
|
}
|
|
1307
|
-
|
|
1307
|
+
h({ code: C }), a = !1, E();
|
|
1308
1308
|
};
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
}), p.addEventListener("click", (
|
|
1312
|
-
|
|
1313
|
-
}), f.addEventListener("click", (
|
|
1314
|
-
|
|
1315
|
-
}), d.addEventListener("mousedown", (
|
|
1309
|
+
s.addEventListener("dblclick", (C) => {
|
|
1310
|
+
C.preventDefault(), C.stopPropagation(), x();
|
|
1311
|
+
}), p.addEventListener("click", (C) => {
|
|
1312
|
+
C.stopPropagation(), v();
|
|
1313
|
+
}), f.addEventListener("click", (C) => {
|
|
1314
|
+
C.stopPropagation(), T();
|
|
1315
|
+
}), d.addEventListener("mousedown", (C) => C.stopPropagation()), d.addEventListener("keydown", (C) => C.stopPropagation()), d.addEventListener("keypress", (C) => C.stopPropagation());
|
|
1316
1316
|
const E = () => {
|
|
1317
|
-
const
|
|
1318
|
-
|
|
1319
|
-
const D = A.trim().length > 0, z =
|
|
1320
|
-
a || (D && z ? (
|
|
1317
|
+
const C = N.getState().editorLanguage, I = H(C), A = typeof r.attrs.code == "string" ? r.attrs.code : "";
|
|
1318
|
+
s.style.display = a ? "none" : "block", l.style.display = a ? "block" : "none", p.textContent = I.mermaidSaveAndRender || "保存并渲染", f.textContent = I.mermaidCancel || "取消";
|
|
1319
|
+
const D = A.trim().length > 0, z = o.querySelector("svg") !== null;
|
|
1320
|
+
a || (D && z ? (c.textContent = I.mermaidDoubleClickToEdit || "双击编辑", c.className = "mermaid-view-hint mermaid-view-hint--subtle") : (c.textContent = I.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", c.className = "mermaid-view-hint mermaid-view-hint--empty")), !a && A.trim() !== y && w(A);
|
|
1321
1321
|
};
|
|
1322
|
-
let
|
|
1323
|
-
const
|
|
1324
|
-
|
|
1322
|
+
let _ = N.getState().editorLanguage;
|
|
1323
|
+
const b = N.subscribe((C) => {
|
|
1324
|
+
C.editorLanguage !== _ && (_ = C.editorLanguage, E());
|
|
1325
1325
|
});
|
|
1326
1326
|
return E(), {
|
|
1327
1327
|
dom: i,
|
|
1328
|
-
stopEvent: (
|
|
1329
|
-
const
|
|
1330
|
-
return !!(
|
|
1328
|
+
stopEvent: (C) => {
|
|
1329
|
+
const I = C.target;
|
|
1330
|
+
return !!(I === d || l.contains(I));
|
|
1331
1331
|
},
|
|
1332
1332
|
ignoreMutation: () => !0,
|
|
1333
|
-
update: (
|
|
1333
|
+
update: (C) => C.type.name !== "mermaid" ? !1 : (r = C, E(), !0),
|
|
1334
1334
|
destroy: () => {
|
|
1335
|
-
|
|
1335
|
+
b(), Ie();
|
|
1336
1336
|
}
|
|
1337
1337
|
};
|
|
1338
1338
|
};
|
|
1339
1339
|
}
|
|
1340
|
-
}),
|
|
1340
|
+
}), xa = {
|
|
1341
1341
|
name: "mermaid",
|
|
1342
1342
|
version: "1.0.0",
|
|
1343
|
-
extensions: [
|
|
1343
|
+
extensions: [wa],
|
|
1344
1344
|
toolbarItems: [
|
|
1345
1345
|
{
|
|
1346
1346
|
id: "mermaid-insert",
|
|
@@ -1365,7 +1365,7 @@ const Ie = () => {
|
|
|
1365
1365
|
}
|
|
1366
1366
|
}
|
|
1367
1367
|
}
|
|
1368
|
-
}, Ve = "https://draw.goatpatent.com",
|
|
1368
|
+
}, Ve = "https://draw.goatpatent.com", Ca = Z.create({
|
|
1369
1369
|
name: "drawio",
|
|
1370
1370
|
group: "block",
|
|
1371
1371
|
atom: !0,
|
|
@@ -1386,49 +1386,49 @@ const Ie = () => {
|
|
|
1386
1386
|
let r = t, a = !1;
|
|
1387
1387
|
const i = document.createElement("div");
|
|
1388
1388
|
i.classList.add("drawio-node");
|
|
1389
|
-
const o = document.createElement("div");
|
|
1390
|
-
o.className = "drawio-view", o.contentEditable = "false";
|
|
1391
|
-
const c = document.createElement("img");
|
|
1392
|
-
c.className = "drawio-preview-img", c.style.display = "none";
|
|
1393
1389
|
const s = document.createElement("div");
|
|
1394
|
-
s.className = "drawio-view
|
|
1390
|
+
s.className = "drawio-view", s.contentEditable = "false";
|
|
1391
|
+
const o = document.createElement("img");
|
|
1392
|
+
o.className = "drawio-preview-img", o.style.display = "none";
|
|
1393
|
+
const c = document.createElement("div");
|
|
1394
|
+
c.className = "drawio-view-hint", s.append(o, c), i.append(s);
|
|
1395
1395
|
const l = (x) => {
|
|
1396
|
-
const
|
|
1397
|
-
typeof
|
|
1396
|
+
const T = typeof n == "function" ? n() : null;
|
|
1397
|
+
typeof T == "number" && e.commands.command(({ tr: v, dispatch: E }) => (v.setNodeMarkup(T, void 0, { ...r.attrs, ...x }), E && E(v), !0));
|
|
1398
1398
|
};
|
|
1399
|
-
let d = null,
|
|
1399
|
+
let d = null, u = null, m = null;
|
|
1400
1400
|
const f = () => {
|
|
1401
1401
|
if (a) return;
|
|
1402
|
-
a = !0,
|
|
1402
|
+
a = !0, u = document.createElement("div"), u.className = "drawio-modal-overlay";
|
|
1403
1403
|
const x = document.createElement("div");
|
|
1404
1404
|
x.className = "drawio-modal-content";
|
|
1405
|
-
const
|
|
1406
|
-
|
|
1407
|
-
const v =
|
|
1405
|
+
const T = document.createElement("div");
|
|
1406
|
+
T.className = "drawio-modal-header";
|
|
1407
|
+
const v = N.getState().editorLanguage, E = document.createElement("span");
|
|
1408
1408
|
E.textContent = v === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", E.className = "drawio-modal-title";
|
|
1409
|
-
const
|
|
1410
|
-
|
|
1411
|
-
const
|
|
1412
|
-
|
|
1413
|
-
const
|
|
1414
|
-
d = (
|
|
1409
|
+
const _ = document.createElement("button");
|
|
1410
|
+
_.className = "drawio-modal-close-btn", _.textContent = "✕", _.type = "button", _.addEventListener("click", () => p()), T.append(E, _), m = document.createElement("iframe"), m.className = "drawio-modal-iframe", m.setAttribute("frameborder", "0"), x.append(T, m), u.appendChild(x), document.body.appendChild(u);
|
|
1411
|
+
const b = v === "en" ? "en" : "zh";
|
|
1412
|
+
m.src = `${Ve}/?embed=1&proto=json&spin=1&lang=${b}`;
|
|
1413
|
+
const C = m;
|
|
1414
|
+
d = (I) => {
|
|
1415
1415
|
var D, z;
|
|
1416
|
-
if (!
|
|
1416
|
+
if (!C || I.source !== C.contentWindow) return;
|
|
1417
1417
|
let A;
|
|
1418
1418
|
try {
|
|
1419
|
-
A = typeof
|
|
1419
|
+
A = typeof I.data == "string" ? JSON.parse(I.data) : I.data;
|
|
1420
1420
|
} catch {
|
|
1421
1421
|
return;
|
|
1422
1422
|
}
|
|
1423
1423
|
if (A.event === "init") {
|
|
1424
1424
|
const Q = typeof r.attrs.xml == "string" ? r.attrs.xml : "";
|
|
1425
|
-
(D =
|
|
1425
|
+
(D = C.contentWindow) == null || D.postMessage(
|
|
1426
1426
|
JSON.stringify({ action: "load", autosave: 0, xml: Q || "" }),
|
|
1427
1427
|
Ve
|
|
1428
1428
|
);
|
|
1429
1429
|
} else if (A.event === "save") {
|
|
1430
1430
|
const Q = A.xml || "";
|
|
1431
|
-
(z =
|
|
1431
|
+
(z = C.contentWindow) == null || z.postMessage(
|
|
1432
1432
|
JSON.stringify({ action: "export", format: "svg" }),
|
|
1433
1433
|
Ve
|
|
1434
1434
|
), l({ xml: Q });
|
|
@@ -1438,33 +1438,33 @@ const Ie = () => {
|
|
|
1438
1438
|
} else A.event === "exit" && p();
|
|
1439
1439
|
}, window.addEventListener("message", d);
|
|
1440
1440
|
}, p = () => {
|
|
1441
|
-
a = !1, d && (window.removeEventListener("message", d), d = null),
|
|
1441
|
+
a = !1, d && (window.removeEventListener("message", d), d = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null), h();
|
|
1442
1442
|
};
|
|
1443
|
-
|
|
1443
|
+
s.addEventListener("dblclick", (x) => {
|
|
1444
1444
|
x.preventDefault(), x.stopPropagation(), f();
|
|
1445
1445
|
});
|
|
1446
|
-
const
|
|
1447
|
-
const x =
|
|
1448
|
-
v ? (
|
|
1446
|
+
const h = () => {
|
|
1447
|
+
const x = N.getState().editorLanguage, T = H(x), v = typeof r.attrs.svg == "string" ? r.attrs.svg : "";
|
|
1448
|
+
v ? (o.src = v, o.style.display = "block") : (o.src = "", o.style.display = "none"), v ? (c.textContent = T.mermaidDoubleClickToEdit || "双击编辑", c.className = "drawio-view-hint drawio-view-hint--subtle") : (c.textContent = T.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", c.className = "drawio-view-hint drawio-view-hint--empty");
|
|
1449
1449
|
};
|
|
1450
|
-
let
|
|
1451
|
-
const w =
|
|
1452
|
-
x.editorLanguage !==
|
|
1450
|
+
let y = N.getState().editorLanguage;
|
|
1451
|
+
const w = N.subscribe((x) => {
|
|
1452
|
+
x.editorLanguage !== y && (y = x.editorLanguage, h());
|
|
1453
1453
|
});
|
|
1454
|
-
return
|
|
1454
|
+
return h(), {
|
|
1455
1455
|
dom: i,
|
|
1456
1456
|
ignoreMutation: () => !0,
|
|
1457
|
-
update: (x) => x.type.name !== "drawio" ? !1 : (r = x,
|
|
1457
|
+
update: (x) => x.type.name !== "drawio" ? !1 : (r = x, h(), !0),
|
|
1458
1458
|
destroy: () => {
|
|
1459
|
-
w(), d && (window.removeEventListener("message", d), d = null),
|
|
1459
|
+
w(), d && (window.removeEventListener("message", d), d = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null);
|
|
1460
1460
|
}
|
|
1461
1461
|
};
|
|
1462
1462
|
};
|
|
1463
1463
|
}
|
|
1464
|
-
}),
|
|
1464
|
+
}), Ta = {
|
|
1465
1465
|
name: "drawio",
|
|
1466
1466
|
version: "1.0.0",
|
|
1467
|
-
extensions: [
|
|
1467
|
+
extensions: [Ca],
|
|
1468
1468
|
toolbarItems: [
|
|
1469
1469
|
{
|
|
1470
1470
|
id: "drawio-insert",
|
|
@@ -1495,56 +1495,56 @@ const Ie = () => {
|
|
|
1495
1495
|
selected: n,
|
|
1496
1496
|
editor: r
|
|
1497
1497
|
}) => {
|
|
1498
|
-
const a = W(null), [i,
|
|
1498
|
+
const a = W(null), [i, s] = F(!1), o = e.type.name === "math_block", c = W(!1), l = W(t), d = W(e.attrs.latex ?? "");
|
|
1499
1499
|
M(() => {
|
|
1500
1500
|
l.current = t;
|
|
1501
1501
|
}, [t]), M(() => {
|
|
1502
1502
|
d.current = e.attrs.latex ?? "";
|
|
1503
1503
|
}, [e.attrs.latex]);
|
|
1504
|
-
const
|
|
1505
|
-
|
|
1506
|
-
}, []),
|
|
1507
|
-
var
|
|
1508
|
-
if (!
|
|
1509
|
-
|
|
1510
|
-
const p = ((
|
|
1511
|
-
l.current({ latex: p }),
|
|
1504
|
+
const u = ae(() => {
|
|
1505
|
+
c.current || (c.current = !0, s(!0));
|
|
1506
|
+
}, []), m = ae(() => {
|
|
1507
|
+
var h, y;
|
|
1508
|
+
if (!c.current) return;
|
|
1509
|
+
c.current = !1;
|
|
1510
|
+
const p = ((h = a.current) == null ? void 0 : h.value) ?? d.current;
|
|
1511
|
+
l.current({ latex: p }), s(!1), (y = globalThis.mathVirtualKeyboard) == null || y.hide({ animate: !0 });
|
|
1512
1512
|
}, []);
|
|
1513
1513
|
M(() => {
|
|
1514
|
-
var
|
|
1515
|
-
const p = !!((w = (
|
|
1516
|
-
n && p &&
|
|
1517
|
-
}, [n,
|
|
1514
|
+
var h, y, w;
|
|
1515
|
+
const p = !!((w = (y = (h = r == null ? void 0 : r.view) == null ? void 0 : h.state) == null ? void 0 : y.selection) != null && w.empty);
|
|
1516
|
+
n && p && u();
|
|
1517
|
+
}, [n, u]), M(() => {
|
|
1518
1518
|
i && requestAnimationFrame(() => {
|
|
1519
|
-
var
|
|
1519
|
+
var h;
|
|
1520
1520
|
const p = a.current;
|
|
1521
|
-
p && (p.virtualKeyboardMode = "onfocus", (
|
|
1521
|
+
p && (p.virtualKeyboardMode = "onfocus", (h = p.focus) == null || h.call(p));
|
|
1522
1522
|
});
|
|
1523
1523
|
}, [i]), M(() => {
|
|
1524
1524
|
if (!i) return;
|
|
1525
1525
|
const p = a.current;
|
|
1526
1526
|
if (!p) return;
|
|
1527
|
-
const
|
|
1527
|
+
const h = () => {
|
|
1528
1528
|
setTimeout(() => {
|
|
1529
|
-
var x,
|
|
1530
|
-
if (!
|
|
1529
|
+
var x, T, v;
|
|
1530
|
+
if (!c.current) return;
|
|
1531
1531
|
const w = document.activeElement;
|
|
1532
|
-
(w == null ? void 0 : w.tagName) === "MATH-FIELD" || (x = w == null ? void 0 : w.closest) != null && x.call(w, "math-field") || (
|
|
1532
|
+
(w == null ? void 0 : w.tagName) === "MATH-FIELD" || (x = w == null ? void 0 : w.closest) != null && x.call(w, "math-field") || (T = w == null ? void 0 : w.closest) != null && T.call(w, ".ML__keyboard") || (v = document.querySelector(".ML__keyboard")) != null && v.contains(w) || m();
|
|
1533
1533
|
}, 300);
|
|
1534
|
-
},
|
|
1535
|
-
w.key === "Escape" &&
|
|
1534
|
+
}, y = (w) => {
|
|
1535
|
+
w.key === "Escape" && m();
|
|
1536
1536
|
};
|
|
1537
|
-
return p.addEventListener("focusout",
|
|
1538
|
-
p.removeEventListener("focusout",
|
|
1537
|
+
return p.addEventListener("focusout", h), p.addEventListener("keydown", y), () => {
|
|
1538
|
+
p.removeEventListener("focusout", h), p.removeEventListener("keydown", y);
|
|
1539
1539
|
};
|
|
1540
|
-
}, [i,
|
|
1540
|
+
}, [i, m]), M(() => {
|
|
1541
1541
|
!i && a.current && a.current.value !== e.attrs.latex && (a.current.value = e.attrs.latex ?? "");
|
|
1542
1542
|
}, [e.attrs.latex, i]);
|
|
1543
1543
|
let f = "";
|
|
1544
1544
|
try {
|
|
1545
1545
|
f = gr.renderToString(e.attrs.latex || "", {
|
|
1546
1546
|
throwOnError: !1,
|
|
1547
|
-
displayMode:
|
|
1547
|
+
displayMode: o
|
|
1548
1548
|
});
|
|
1549
1549
|
} catch {
|
|
1550
1550
|
f = e.attrs.latex || "";
|
|
@@ -1552,22 +1552,22 @@ const Ie = () => {
|
|
|
1552
1552
|
return /* @__PURE__ */ g(
|
|
1553
1553
|
_n,
|
|
1554
1554
|
{
|
|
1555
|
-
as:
|
|
1556
|
-
className:
|
|
1555
|
+
as: o ? "div" : "span",
|
|
1556
|
+
className: o ? "math-block" : "math-inline",
|
|
1557
1557
|
children: i ? /* @__PURE__ */ g(
|
|
1558
1558
|
"math-field",
|
|
1559
1559
|
{
|
|
1560
1560
|
ref: a,
|
|
1561
|
-
className:
|
|
1561
|
+
className: o ? "math-live-field math-live-field--block" : "math-live-field",
|
|
1562
1562
|
children: e.attrs.latex
|
|
1563
1563
|
}
|
|
1564
|
-
) : /* @__PURE__ */ L("span", { className: "math-preview", onClick:
|
|
1564
|
+
) : /* @__PURE__ */ L("span", { className: "math-preview", onClick: u, children: [
|
|
1565
1565
|
/* @__PURE__ */ g("span", { dangerouslySetInnerHTML: { __html: f } }),
|
|
1566
1566
|
/* @__PURE__ */ g("span", { className: "math-tooltip", children: "点击编辑" })
|
|
1567
1567
|
] })
|
|
1568
1568
|
}
|
|
1569
1569
|
);
|
|
1570
|
-
},
|
|
1570
|
+
}, Sa = Z.create({
|
|
1571
1571
|
name: "math_inline",
|
|
1572
1572
|
group: "inline",
|
|
1573
1573
|
inline: !0,
|
|
@@ -1600,7 +1600,7 @@ const Ie = () => {
|
|
|
1600
1600
|
}
|
|
1601
1601
|
});
|
|
1602
1602
|
}
|
|
1603
|
-
}),
|
|
1603
|
+
}), Ea = Z.create({
|
|
1604
1604
|
name: "math_block",
|
|
1605
1605
|
group: "block",
|
|
1606
1606
|
atom: !0,
|
|
@@ -1623,10 +1623,10 @@ const Ie = () => {
|
|
|
1623
1623
|
}
|
|
1624
1624
|
});
|
|
1625
1625
|
}
|
|
1626
|
-
}),
|
|
1626
|
+
}), ka = {
|
|
1627
1627
|
name: "math",
|
|
1628
1628
|
version: "1.0.0",
|
|
1629
|
-
extensions: [
|
|
1629
|
+
extensions: [Sa, Ea],
|
|
1630
1630
|
toolbarItems: [
|
|
1631
1631
|
{
|
|
1632
1632
|
id: "math-inline-insert",
|
|
@@ -1674,10 +1674,10 @@ const Ie = () => {
|
|
|
1674
1674
|
}, st = (e, t, n = {}) => {
|
|
1675
1675
|
const r = n.from ?? 0, a = n.to ?? e.state.doc.content.size;
|
|
1676
1676
|
let i = null;
|
|
1677
|
-
return e.state.doc.nodesBetween(r, a, (
|
|
1677
|
+
return e.state.doc.nodesBetween(r, a, (s, o) => i ? !1 : s.type.name === t ? (i = { node: s, pos: o }, !1) : !0), i;
|
|
1678
1678
|
}, Xt = (e, t, n = {}) => {
|
|
1679
1679
|
const r = n.from ?? 0, a = n.to ?? e.state.doc.content.size, i = [];
|
|
1680
|
-
return e.state.doc.nodesBetween(r, a, (
|
|
1680
|
+
return e.state.doc.nodesBetween(r, a, (s, o) => (t(s, o) && i.push({ node: s, pos: o }), !0)), i;
|
|
1681
1681
|
}, Re = (e, t) => {
|
|
1682
1682
|
const { $from: n } = e.state.selection;
|
|
1683
1683
|
for (let r = n.depth; r >= 0; r -= 1) {
|
|
@@ -1689,7 +1689,7 @@ const Ie = () => {
|
|
|
1689
1689
|
};
|
|
1690
1690
|
}
|
|
1691
1691
|
return null;
|
|
1692
|
-
},
|
|
1692
|
+
}, _a = (e) => {
|
|
1693
1693
|
const { $from: t } = e.state.selection;
|
|
1694
1694
|
for (let n = t.depth; n >= 0; n -= 1) {
|
|
1695
1695
|
const r = t.node(n);
|
|
@@ -1700,7 +1700,7 @@ const Ie = () => {
|
|
|
1700
1700
|
};
|
|
1701
1701
|
}
|
|
1702
1702
|
return null;
|
|
1703
|
-
},
|
|
1703
|
+
}, Ia = (e, t) => e.state.schema.nodes[t] || null, Na = (e) => {
|
|
1704
1704
|
const t = Array.isArray(e.content) ? e.content : e.content ? [e.content] : void 0;
|
|
1705
1705
|
return {
|
|
1706
1706
|
type: e.type,
|
|
@@ -1708,35 +1708,35 @@ const Ie = () => {
|
|
|
1708
1708
|
content: t
|
|
1709
1709
|
};
|
|
1710
1710
|
}, Yt = (e, t) => {
|
|
1711
|
-
const n =
|
|
1711
|
+
const n = Na(t);
|
|
1712
1712
|
return typeof t.position == "number" ? e.chain().focus().insertContentAt(t.position, n).run() : e.chain().focus().insertContent(n).run();
|
|
1713
1713
|
}, ze = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
|
|
1714
|
-
var
|
|
1715
|
-
const i = typeof t.position == "number" ? t.position : (
|
|
1714
|
+
var c;
|
|
1715
|
+
const i = typeof t.position == "number" ? t.position : (c = st(e, t.type || "")) == null ? void 0 : c.pos;
|
|
1716
1716
|
if (typeof i != "number")
|
|
1717
1717
|
return !1;
|
|
1718
|
-
const
|
|
1719
|
-
if (!
|
|
1718
|
+
const s = r.doc.nodeAt(i);
|
|
1719
|
+
if (!s || t.type && s.type.name !== t.type)
|
|
1720
1720
|
return !1;
|
|
1721
|
-
const
|
|
1722
|
-
return n.setNodeMarkup(i, void 0,
|
|
1721
|
+
const o = { ...s.attrs, ...t.attrs };
|
|
1722
|
+
return n.setNodeMarkup(i, void 0, o), a && a(n), !0;
|
|
1723
1723
|
}), Zt = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
|
|
1724
|
-
var
|
|
1725
|
-
const i = typeof t.position == "number" ? t.position : (
|
|
1724
|
+
var o;
|
|
1725
|
+
const i = typeof t.position == "number" ? t.position : (o = st(e, t.type || "")) == null ? void 0 : o.pos;
|
|
1726
1726
|
if (typeof i != "number")
|
|
1727
1727
|
return !1;
|
|
1728
|
-
const
|
|
1729
|
-
return !
|
|
1728
|
+
const s = r.doc.nodeAt(i);
|
|
1729
|
+
return !s || t.type && s.type.name !== t.type ? !1 : (n.delete(i, i + s.nodeSize), a && a(n), !0);
|
|
1730
1730
|
}), Qt = (e, t) => {
|
|
1731
|
-
const n =
|
|
1731
|
+
const n = Ia(e, t.type);
|
|
1732
1732
|
return n ? e.commands.command(({ tr: r, state: a, dispatch: i }) => {
|
|
1733
|
-
const { from:
|
|
1734
|
-
if (!
|
|
1733
|
+
const { from: s, to: o } = a.selection, c = a.selection.$from.blockRange(a.selection.$to);
|
|
1734
|
+
if (!c)
|
|
1735
1735
|
return !1;
|
|
1736
|
-
const l = fr(
|
|
1737
|
-
return l ? (r.wrap(
|
|
1736
|
+
const l = fr(c, n, t.attrs);
|
|
1737
|
+
return l ? (r.wrap(c, l), i && i(r.scrollIntoView()), s <= o) : !1;
|
|
1738
1738
|
}) : !1;
|
|
1739
|
-
},
|
|
1739
|
+
}, Aa = (e, t) => {
|
|
1740
1740
|
if (t.length === 0)
|
|
1741
1741
|
return !1;
|
|
1742
1742
|
const n = e.getJSON();
|
|
@@ -1748,13 +1748,13 @@ const Ie = () => {
|
|
|
1748
1748
|
let Ne = 0;
|
|
1749
1749
|
const Qe = [];
|
|
1750
1750
|
let Ae = !1;
|
|
1751
|
-
const
|
|
1752
|
-
let
|
|
1751
|
+
const La = 2e4, bt = 6e4;
|
|
1752
|
+
let $ = null, Me = !1, ne = null, pe = null;
|
|
1753
1753
|
const et = /* @__PURE__ */ new Map();
|
|
1754
1754
|
function vt() {
|
|
1755
|
-
ne && (window.removeEventListener("message", ne), ne = null),
|
|
1755
|
+
ne && (window.removeEventListener("message", ne), ne = null), $ && ($.src = "about:blank", $.remove(), $ = null), Me = !1;
|
|
1756
1756
|
}
|
|
1757
|
-
function
|
|
1757
|
+
function Pa(e, t) {
|
|
1758
1758
|
const n = et.get(e);
|
|
1759
1759
|
if (n) {
|
|
1760
1760
|
t(n);
|
|
@@ -1772,37 +1772,37 @@ function tt() {
|
|
|
1772
1772
|
}
|
|
1773
1773
|
ne && (window.removeEventListener("message", ne), ne = null);
|
|
1774
1774
|
let r = null;
|
|
1775
|
-
const a = (
|
|
1776
|
-
r && (clearTimeout(r), r = null),
|
|
1775
|
+
const a = (s) => {
|
|
1776
|
+
r && (clearTimeout(r), r = null), s && et.set(e, s), t(s), Ae = !1, pe = setTimeout(vt, bt), tt();
|
|
1777
1777
|
}, i = () => {
|
|
1778
|
-
var
|
|
1779
|
-
(
|
|
1778
|
+
var s;
|
|
1779
|
+
(s = $.contentWindow) == null || s.postMessage(
|
|
1780
1780
|
JSON.stringify({ action: "load", autosave: 0, xml: e || "" }),
|
|
1781
1781
|
de
|
|
1782
1782
|
);
|
|
1783
1783
|
};
|
|
1784
|
-
ne = (
|
|
1785
|
-
if (
|
|
1786
|
-
let
|
|
1784
|
+
ne = (s) => {
|
|
1785
|
+
if (!$ || s.source !== $.contentWindow) return;
|
|
1786
|
+
let o;
|
|
1787
1787
|
try {
|
|
1788
|
-
|
|
1788
|
+
o = typeof s.data == "string" ? JSON.parse(s.data) : s.data;
|
|
1789
1789
|
} catch {
|
|
1790
1790
|
return;
|
|
1791
1791
|
}
|
|
1792
|
-
|
|
1793
|
-
var
|
|
1794
|
-
(
|
|
1792
|
+
o.event === "init" ? (Me = !0, i()) : o.event === "load" ? setTimeout(() => {
|
|
1793
|
+
var c;
|
|
1794
|
+
(c = $ == null ? void 0 : $.contentWindow) == null || c.postMessage(
|
|
1795
1795
|
JSON.stringify({ action: "export", format: "svg" }),
|
|
1796
1796
|
de
|
|
1797
1797
|
);
|
|
1798
|
-
}, 1500) :
|
|
1799
|
-
}, window.addEventListener("message", ne), r = setTimeout(() => a(""),
|
|
1798
|
+
}, 1500) : o.event === "export" && a(o.data || "");
|
|
1799
|
+
}, window.addEventListener("message", ne), r = setTimeout(() => a(""), La), $ ? Me && i() : ($ = document.createElement("iframe"), $.style.cssText = "position:fixed;left:-9999px;top:-9999px;width:1920px;height:1080px;opacity:0;pointer-events:none;", document.body.appendChild($), Me = !1, $.src = `${de}/?embed=1&proto=json&spin=0&chrome=0`);
|
|
1800
1800
|
}
|
|
1801
1801
|
const Le = () => {
|
|
1802
1802
|
document.querySelectorAll('body > svg[id^="fig-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
|
|
1803
1803
|
(e.id.startsWith("dmermaid") || e.id.startsWith("dfi")) && e.remove();
|
|
1804
1804
|
}), document.querySelectorAll("body > #dmermaid-svg").forEach((e) => e.remove()), document.querySelectorAll("body > style[data-mermaid-style]").forEach((e) => e.remove());
|
|
1805
|
-
},
|
|
1805
|
+
}, Da = Z.create({
|
|
1806
1806
|
name: "figure",
|
|
1807
1807
|
group: "block",
|
|
1808
1808
|
content: "inline*",
|
|
@@ -1831,50 +1831,50 @@ const Le = () => {
|
|
|
1831
1831
|
addNodeView() {
|
|
1832
1832
|
return ({ editor: e, node: t, getPos: n }) => {
|
|
1833
1833
|
let r = t, a = !1, i = !1;
|
|
1834
|
-
const
|
|
1835
|
-
|
|
1836
|
-
const
|
|
1837
|
-
|
|
1838
|
-
const
|
|
1839
|
-
|
|
1834
|
+
const s = document.createElement("figure");
|
|
1835
|
+
s.setAttribute("data-type", "figure"), s.className = "figure-block";
|
|
1836
|
+
const o = document.createElement("div");
|
|
1837
|
+
o.className = "figure-visual", o.contentEditable = "false", o.setAttribute("spellcheck", "false");
|
|
1838
|
+
const c = document.createElement("img");
|
|
1839
|
+
c.className = "figure-img-preview";
|
|
1840
1840
|
const l = document.createElement("div");
|
|
1841
1841
|
l.className = "figure-upload-area";
|
|
1842
1842
|
const d = document.createElement("span");
|
|
1843
1843
|
d.className = "figure-upload-hint";
|
|
1844
|
-
const
|
|
1845
|
-
|
|
1846
|
-
const
|
|
1847
|
-
|
|
1844
|
+
const u = document.createElement("input");
|
|
1845
|
+
u.type = "file", u.accept = "image/*", u.style.display = "none";
|
|
1846
|
+
const m = document.createElement("button");
|
|
1847
|
+
m.className = "figure-replace-btn", l.append(d, u);
|
|
1848
1848
|
const f = document.createElement("div");
|
|
1849
1849
|
f.className = "figure-mermaid-view", f.contentEditable = "false", f.setAttribute("spellcheck", "false");
|
|
1850
1850
|
const p = document.createElement("div");
|
|
1851
1851
|
p.className = "figure-mermaid-preview", p.contentEditable = "false";
|
|
1852
|
+
const h = document.createElement("div");
|
|
1853
|
+
h.className = "figure-mermaid-view-hint", f.append(p, h);
|
|
1852
1854
|
const y = document.createElement("div");
|
|
1853
|
-
y.className = "figure-mermaid-
|
|
1854
|
-
const b = document.createElement("div");
|
|
1855
|
-
b.className = "figure-mermaid-edit";
|
|
1855
|
+
y.className = "figure-mermaid-edit";
|
|
1856
1856
|
const w = document.createElement("textarea");
|
|
1857
1857
|
w.className = "figure-mermaid-editor", w.spellcheck = !1;
|
|
1858
1858
|
const x = document.createElement("div");
|
|
1859
1859
|
x.className = "figure-mermaid-toolbar";
|
|
1860
|
-
const
|
|
1861
|
-
|
|
1860
|
+
const T = document.createElement("button");
|
|
1861
|
+
T.className = "figure-mermaid-save-btn", T.type = "button";
|
|
1862
1862
|
const v = document.createElement("button");
|
|
1863
1863
|
v.className = "figure-mermaid-cancel-btn", v.type = "button";
|
|
1864
1864
|
const E = document.createElement("span");
|
|
1865
|
-
E.className = "figure-mermaid-error-inline", x.append(E, v,
|
|
1866
|
-
const
|
|
1867
|
-
|
|
1868
|
-
const
|
|
1869
|
-
|
|
1870
|
-
const
|
|
1871
|
-
|
|
1872
|
-
const
|
|
1873
|
-
|
|
1865
|
+
E.className = "figure-mermaid-error-inline", x.append(E, v, T), y.append(w, x);
|
|
1866
|
+
const _ = document.createElement("div");
|
|
1867
|
+
_.className = "figure-drawio-view", _.contentEditable = "false";
|
|
1868
|
+
const b = document.createElement("img");
|
|
1869
|
+
b.className = "figure-drawio-preview-img", b.style.display = "none";
|
|
1870
|
+
const C = document.createElement("div");
|
|
1871
|
+
C.className = "figure-drawio-view-hint", _.append(b, C), o.append(c, l, m), o.append(f, y), o.append(_);
|
|
1872
|
+
const I = document.createElement("figcaption");
|
|
1873
|
+
I.className = "figure-caption";
|
|
1874
1874
|
const A = document.createElement("span");
|
|
1875
1875
|
A.className = "figure-id-label", A.contentEditable = "false";
|
|
1876
1876
|
const D = document.createElement("span");
|
|
1877
|
-
D.className = "figure-caption-content",
|
|
1877
|
+
D.className = "figure-caption-content", I.append(A, D), s.append(o, I);
|
|
1878
1878
|
const z = (S) => {
|
|
1879
1879
|
const k = typeof n == "function" ? n() : null;
|
|
1880
1880
|
typeof k == "number" && e.commands.command(({ tr: P, dispatch: O }) => (P.setNodeMarkup(k, void 0, { ...r.attrs, ...S }), O && O(P), !0));
|
|
@@ -1887,13 +1887,13 @@ const Le = () => {
|
|
|
1887
1887
|
typeof P.result == "string" && z({ imageSrc: P.result });
|
|
1888
1888
|
}, P.readAsDataURL(k);
|
|
1889
1889
|
};
|
|
1890
|
-
|
|
1891
|
-
S.stopPropagation(),
|
|
1892
|
-
}),
|
|
1890
|
+
u.addEventListener("change", () => Q(u.files)), l.addEventListener("click", () => u.click()), m.addEventListener("click", (S) => {
|
|
1891
|
+
S.stopPropagation(), u.click();
|
|
1892
|
+
}), o.addEventListener("dragover", (S) => {
|
|
1893
1893
|
r.attrs.contentType === "image" && (S.preventDefault(), S.stopPropagation(), l.classList.add("figure-upload-area--dragover"));
|
|
1894
|
-
}),
|
|
1894
|
+
}), o.addEventListener("dragleave", () => {
|
|
1895
1895
|
l.classList.remove("figure-upload-area--dragover");
|
|
1896
|
-
}),
|
|
1896
|
+
}), o.addEventListener("drop", (S) => {
|
|
1897
1897
|
var k;
|
|
1898
1898
|
l.classList.remove("figure-upload-area--dragover"), r.attrs.contentType === "image" && (S.preventDefault(), S.stopPropagation(), Q(((k = S.dataTransfer) == null ? void 0 : k.files) ?? null));
|
|
1899
1899
|
});
|
|
@@ -1913,7 +1913,7 @@ const Le = () => {
|
|
|
1913
1913
|
p.innerHTML = R, Le();
|
|
1914
1914
|
} catch {
|
|
1915
1915
|
Le();
|
|
1916
|
-
const P =
|
|
1916
|
+
const P = N.getState().editorLanguage;
|
|
1917
1917
|
E.textContent = P === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", E.style.display = "inline";
|
|
1918
1918
|
return;
|
|
1919
1919
|
}
|
|
@@ -1921,12 +1921,12 @@ const Le = () => {
|
|
|
1921
1921
|
};
|
|
1922
1922
|
f.addEventListener("dblclick", (S) => {
|
|
1923
1923
|
S.preventDefault(), S.stopPropagation(), gn();
|
|
1924
|
-
}),
|
|
1924
|
+
}), T.addEventListener("click", (S) => {
|
|
1925
1925
|
S.stopPropagation(), pn();
|
|
1926
1926
|
}), v.addEventListener("click", (S) => {
|
|
1927
1927
|
S.stopPropagation(), fn();
|
|
1928
1928
|
}), w.addEventListener("mousedown", (S) => S.stopPropagation()), w.addEventListener("keydown", (S) => S.stopPropagation()), w.addEventListener("keypress", (S) => S.stopPropagation());
|
|
1929
|
-
let ee = null, G = null,
|
|
1929
|
+
let ee = null, G = null, U = null;
|
|
1930
1930
|
const hn = () => {
|
|
1931
1931
|
if (i) return;
|
|
1932
1932
|
i = !0, J(), G = document.createElement("div"), G.className = "drawio-modal-overlay";
|
|
@@ -1934,47 +1934,47 @@ const Le = () => {
|
|
|
1934
1934
|
S.className = "drawio-modal-content";
|
|
1935
1935
|
const k = document.createElement("div");
|
|
1936
1936
|
k.className = "drawio-modal-header";
|
|
1937
|
-
const P = document.createElement("span"), O =
|
|
1937
|
+
const P = document.createElement("span"), O = N.getState().editorLanguage;
|
|
1938
1938
|
P.textContent = O === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", P.className = "drawio-modal-title";
|
|
1939
1939
|
const R = document.createElement("button");
|
|
1940
|
-
R.className = "drawio-modal-close-btn", R.textContent = "✕", R.type = "button", R.addEventListener("click", () => We()), k.append(P, R),
|
|
1940
|
+
R.className = "drawio-modal-close-btn", R.textContent = "✕", R.type = "button", R.addEventListener("click", () => We()), k.append(P, R), U = document.createElement("iframe"), U.className = "drawio-modal-iframe", U.setAttribute("frameborder", "0"), S.append(k, U), G.appendChild(S), document.body.appendChild(G);
|
|
1941
1941
|
const fe = O === "en" ? "en" : "zh";
|
|
1942
|
-
|
|
1943
|
-
const K =
|
|
1942
|
+
U.src = `${de}/?embed=1&proto=json&spin=1&lang=${fe}`;
|
|
1943
|
+
const K = U;
|
|
1944
1944
|
ee = (X) => {
|
|
1945
1945
|
var oe, Te;
|
|
1946
1946
|
if (!K || X.source !== K.contentWindow) return;
|
|
1947
|
-
let
|
|
1947
|
+
let q;
|
|
1948
1948
|
try {
|
|
1949
|
-
|
|
1949
|
+
q = typeof X.data == "string" ? JSON.parse(X.data) : X.data;
|
|
1950
1950
|
} catch {
|
|
1951
1951
|
return;
|
|
1952
1952
|
}
|
|
1953
|
-
if (
|
|
1953
|
+
if (q.event === "init") {
|
|
1954
1954
|
const ce = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "";
|
|
1955
1955
|
(oe = K.contentWindow) == null || oe.postMessage(
|
|
1956
1956
|
JSON.stringify({ action: "load", autosave: 0, xml: ce || "" }),
|
|
1957
1957
|
de
|
|
1958
1958
|
);
|
|
1959
|
-
} else if (
|
|
1960
|
-
const ce =
|
|
1959
|
+
} else if (q.event === "save") {
|
|
1960
|
+
const ce = q.xml || "";
|
|
1961
1961
|
(Te = K.contentWindow) == null || Te.postMessage(
|
|
1962
1962
|
JSON.stringify({ action: "export", format: "svg" }),
|
|
1963
1963
|
de
|
|
1964
1964
|
), z({ drawioXml: ce });
|
|
1965
|
-
} else if (
|
|
1966
|
-
const ce =
|
|
1965
|
+
} else if (q.event === "export") {
|
|
1966
|
+
const ce = q.data || "";
|
|
1967
1967
|
z({ drawioSvg: ce }), We();
|
|
1968
|
-
} else
|
|
1968
|
+
} else q.event === "exit" && We();
|
|
1969
1969
|
}, window.addEventListener("message", ee);
|
|
1970
1970
|
}, We = () => {
|
|
1971
|
-
i = !1, ee && (window.removeEventListener("message", ee), ee = null),
|
|
1971
|
+
i = !1, ee && (window.removeEventListener("message", ee), ee = null), U && (U.src = "about:blank", U = null), G && (G.remove(), G = null), J();
|
|
1972
1972
|
};
|
|
1973
|
-
|
|
1973
|
+
_.addEventListener("dblclick", (S) => {
|
|
1974
1974
|
S.preventDefault(), S.stopPropagation(), hn();
|
|
1975
|
-
}),
|
|
1975
|
+
}), s.addEventListener("mousedown", (S) => {
|
|
1976
1976
|
const k = S.target;
|
|
1977
|
-
if (!(k instanceof HTMLElement) || k === D || D.contains(k) || k === w ||
|
|
1977
|
+
if (!(k instanceof HTMLElement) || k === D || D.contains(k) || k === w || y.contains(k) || k === l || l.contains(k) || k === m || k === u || f.contains(k) || _.contains(k)) return;
|
|
1978
1978
|
const P = typeof n == "function" ? n() : null;
|
|
1979
1979
|
if (typeof P != "number") return;
|
|
1980
1980
|
const O = P + r.nodeSize - 1, R = Zn.create(e.state.doc, O);
|
|
@@ -2002,48 +2002,48 @@ const Le = () => {
|
|
|
2002
2002
|
}
|
|
2003
2003
|
}
|
|
2004
2004
|
}, J = () => {
|
|
2005
|
-
const S =
|
|
2005
|
+
const S = N.getState().editorLanguage, k = H(S), P = ["image", "mermaid", "drawio"].includes(r.attrs.contentType) ? r.attrs.contentType : "image", O = typeof r.attrs.id == "string" ? r.attrs.id.trim() : "", R = typeof r.attrs.imageSrc == "string" ? r.attrs.imageSrc : "", fe = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "";
|
|
2006
2006
|
O ? (A.textContent = `[${O}] `, A.style.display = "inline") : (A.textContent = "", A.style.display = "none");
|
|
2007
|
-
const K = P === "image", X = P === "mermaid",
|
|
2008
|
-
|
|
2007
|
+
const K = P === "image", X = P === "mermaid", q = P === "drawio";
|
|
2008
|
+
c.style.display = K && R ? "block" : "none", l.style.display = K && !R ? "flex" : "none", m.style.display = K && R ? "block" : "none", f.style.display = X && !a ? "block" : "none", y.style.display = X && a ? "block" : "none", _.style.display = q ? "flex" : "none", K && R && (c.src = R);
|
|
2009
2009
|
const oe = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
|
|
2010
|
-
|
|
2010
|
+
q && (oe ? (b.src = oe, b.style.display = "block") : (b.src = "", b.style.display = "none")), d.textContent = k.figureUploadHint || "点击上传或拖拽图片", m.textContent = k.figureReplaceImage || "更换图片", T.textContent = k.mermaidSaveAndRender || "保存并渲染", v.textContent = k.mermaidCancel || "取消";
|
|
2011
2011
|
const Te = fe.trim().length > 0, ce = p.querySelector("svg") !== null;
|
|
2012
|
-
X && !a && (Te && ce ? (
|
|
2012
|
+
X && !a && (Te && ce ? (h.textContent = k.mermaidDoubleClickToEdit || "双击编辑", h.className = "figure-mermaid-view-hint figure-mermaid-view-hint--subtle") : (h.textContent = k.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", h.className = "figure-mermaid-view-hint figure-mermaid-view-hint--empty")), q && !i && (oe ? (C.textContent = k.mermaidDoubleClickToEdit || "双击编辑", C.className = "figure-drawio-view-hint figure-mermaid-view-hint--subtle") : (C.textContent = k.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", C.className = "figure-drawio-view-hint figure-mermaid-view-hint--empty")), X && !a && fe.trim() !== ge && wn(fe);
|
|
2013
2013
|
const Cn = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "";
|
|
2014
|
-
|
|
2014
|
+
q && Cn && !oe && !xe && !i && (se && clearTimeout(se), se = setTimeout(() => {
|
|
2015
2015
|
se = null;
|
|
2016
2016
|
const dt = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "", Tn = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
|
|
2017
|
-
!dt || Tn || xe || (xe = !0,
|
|
2017
|
+
!dt || Tn || xe || (xe = !0, Pa(dt, (ut) => {
|
|
2018
2018
|
xe = !1, ut ? (Ce = 0, z({ drawioSvg: ut })) : Ce < yn && (Ce++, me = setTimeout(() => {
|
|
2019
2019
|
me = null, J();
|
|
2020
2020
|
}, vn * Ce));
|
|
2021
2021
|
}));
|
|
2022
2022
|
}, bn));
|
|
2023
2023
|
};
|
|
2024
|
-
let lt =
|
|
2025
|
-
const xn =
|
|
2024
|
+
let lt = N.getState().editorLanguage;
|
|
2025
|
+
const xn = N.subscribe((S) => {
|
|
2026
2026
|
S.editorLanguage !== lt && (lt = S.editorLanguage, J());
|
|
2027
2027
|
});
|
|
2028
2028
|
return J(), {
|
|
2029
|
-
dom:
|
|
2029
|
+
dom: s,
|
|
2030
2030
|
contentDOM: D,
|
|
2031
2031
|
stopEvent: (S) => {
|
|
2032
2032
|
const k = S.target;
|
|
2033
|
-
return !!(k === w ||
|
|
2033
|
+
return !!(k === w || y.contains(k) || k === u);
|
|
2034
2034
|
},
|
|
2035
2035
|
ignoreMutation: (S) => {
|
|
2036
2036
|
const k = S.target;
|
|
2037
|
-
return !!(
|
|
2037
|
+
return !!(o.contains(k) || A.contains(k));
|
|
2038
2038
|
},
|
|
2039
2039
|
update: (S) => S.type.name !== "figure" ? !1 : (r = S, J(), !0),
|
|
2040
2040
|
destroy: () => {
|
|
2041
|
-
se && (clearTimeout(se), se = null), me && (clearTimeout(me), me = null), xn(), Le(), ee && (window.removeEventListener("message", ee), ee = null),
|
|
2041
|
+
se && (clearTimeout(se), se = null), me && (clearTimeout(me), me = null), xn(), Le(), ee && (window.removeEventListener("message", ee), ee = null), U && (U.src = "about:blank", U = null), G && (G.remove(), G = null);
|
|
2042
2042
|
}
|
|
2043
2043
|
};
|
|
2044
2044
|
};
|
|
2045
2045
|
}
|
|
2046
|
-
}),
|
|
2046
|
+
}), Ra = Z.create({
|
|
2047
2047
|
name: "reference",
|
|
2048
2048
|
group: "inline",
|
|
2049
2049
|
inline: !0,
|
|
@@ -2104,24 +2104,24 @@ const Le = () => {
|
|
|
2104
2104
|
return ({ node: e, editor: t }) => {
|
|
2105
2105
|
let n = e;
|
|
2106
2106
|
const r = document.createElement("span"), a = () => {
|
|
2107
|
-
const i = n.attrs.lang === "en" ? "en" : "zh",
|
|
2108
|
-
r.textContent =
|
|
2107
|
+
const i = n.attrs.lang === "en" ? "en" : "zh", s = H(i), o = n.attrs.targetType === "figure" ? "figure" : "claim", c = Number(n.attrs.resolvedNumber), l = typeof n.attrs.resolvedFigureId == "string" && n.attrs.resolvedFigureId ? n.attrs.resolvedFigureId : null, d = o === "figure" ? l || (i === "en" ? "Figure ?" : "附图?") : Number.isFinite(c) ? s.claimLabel(c) : i === "en" ? "Claim ?" : "权利要求?", u = n.attrs.displayText || d;
|
|
2108
|
+
r.textContent = u, r.className = `reference-link${n.attrs.invalid ? " reference-link-invalid" : ""}`, r.setAttribute("data-type", "reference"), r.setAttribute("data-highlight", n.attrs.highlight ? "true" : "false"), r.title = n.attrs.invalid ? s.referenceNavigateDisabledTitle : o === "figure" ? s.figureReferenceNavigateTitle : s.referenceNavigateTitle;
|
|
2109
2109
|
};
|
|
2110
2110
|
return a(), r.addEventListener("click", () => {
|
|
2111
2111
|
const i = n.attrs.targetType === "figure" ? "figure" : "claim";
|
|
2112
2112
|
n.attrs.invalid || setTimeout(() => {
|
|
2113
|
-
let
|
|
2113
|
+
let s = null;
|
|
2114
2114
|
if (i === "figure") {
|
|
2115
|
-
const
|
|
2116
|
-
if (!
|
|
2115
|
+
const o = typeof n.attrs.targetFigureId == "string" ? n.attrs.targetFigureId : "";
|
|
2116
|
+
if (!o)
|
|
2117
2117
|
return;
|
|
2118
|
-
t.state.doc.descendants((
|
|
2118
|
+
t.state.doc.descendants((c, l) => s !== null ? !1 : c.type.name === "figure" && c.attrs.id === o ? (s = l, !1) : !0);
|
|
2119
2119
|
} else {
|
|
2120
2120
|
if (!n.attrs.targetClaimId)
|
|
2121
2121
|
return;
|
|
2122
|
-
t.state.doc.descendants((
|
|
2122
|
+
t.state.doc.descendants((o, c) => s !== null ? !1 : o.type.name === "claim" && o.attrs.claimId === n.attrs.targetClaimId ? (s = c, !1) : !0);
|
|
2123
2123
|
}
|
|
2124
|
-
typeof
|
|
2124
|
+
typeof s == "number" && t.chain().focus().setTextSelection(s + 1).scrollIntoView().run();
|
|
2125
2125
|
}, 0);
|
|
2126
2126
|
}), {
|
|
2127
2127
|
dom: r,
|
|
@@ -2144,7 +2144,7 @@ const Le = () => {
|
|
|
2144
2144
|
design_description: "sectionTitle_design_description",
|
|
2145
2145
|
design_views: "sectionTitle_design_views",
|
|
2146
2146
|
design_brief: "sectionTitle_design_brief"
|
|
2147
|
-
},
|
|
2147
|
+
}, Ma = /* @__PURE__ */ new Set([
|
|
2148
2148
|
"abstract",
|
|
2149
2149
|
"abstract_drawing",
|
|
2150
2150
|
"claims",
|
|
@@ -2155,7 +2155,7 @@ const Le = () => {
|
|
|
2155
2155
|
"design_description",
|
|
2156
2156
|
"design_views",
|
|
2157
2157
|
"design_brief"
|
|
2158
|
-
]),
|
|
2158
|
+
]), Fa = /* @__PURE__ */ new Set([
|
|
2159
2159
|
"technical_field",
|
|
2160
2160
|
"background_art",
|
|
2161
2161
|
"summary",
|
|
@@ -2170,7 +2170,7 @@ const Le = () => {
|
|
|
2170
2170
|
return e.forEach((n) => {
|
|
2171
2171
|
!t && ot(n) && (t = !0);
|
|
2172
2172
|
}), t;
|
|
2173
|
-
},
|
|
2173
|
+
}, $a = Z.create({
|
|
2174
2174
|
name: "patent_title",
|
|
2175
2175
|
group: "block",
|
|
2176
2176
|
content: "inline*",
|
|
@@ -2197,43 +2197,43 @@ const Le = () => {
|
|
|
2197
2197
|
a.className = "pt-title", a.setAttribute("data-type", "patent-title");
|
|
2198
2198
|
const i = document.createElement("div");
|
|
2199
2199
|
i.className = "pb-heading", i.contentEditable = "false";
|
|
2200
|
-
const
|
|
2201
|
-
|
|
2202
|
-
const
|
|
2203
|
-
|
|
2204
|
-
const
|
|
2205
|
-
const
|
|
2206
|
-
return typeof
|
|
2200
|
+
const s = document.createElement("div");
|
|
2201
|
+
s.className = "ps-placeholder", s.contentEditable = "false";
|
|
2202
|
+
const o = document.createElement("h1");
|
|
2203
|
+
o.className = "pt-title-content", a.append(i, s, o);
|
|
2204
|
+
const c = () => {
|
|
2205
|
+
const h = typeof n == "function" ? n() : null;
|
|
2206
|
+
return typeof h == "number" ? h : null;
|
|
2207
2207
|
}, l = () => {
|
|
2208
|
-
const
|
|
2209
|
-
|
|
2208
|
+
const h = c();
|
|
2209
|
+
h !== null && N.getState().setActiveSection("patent_title", h);
|
|
2210
2210
|
}, d = () => {
|
|
2211
|
-
const
|
|
2212
|
-
|
|
2211
|
+
const h = c();
|
|
2212
|
+
h !== null && (N.getState().openDraftingPanel("patent_title", h), e.commands.focus(h + 1));
|
|
2213
2213
|
};
|
|
2214
|
-
|
|
2215
|
-
const
|
|
2216
|
-
const
|
|
2214
|
+
s.addEventListener("click", d), o.addEventListener("focusin", l), o.addEventListener("click", l);
|
|
2215
|
+
const u = () => {
|
|
2216
|
+
const h = N.getState(), y = H(h.editorLanguage), w = typeof y.bookTitle_description == "string" ? y.bookTitle_description : "说明书", x = typeof y.patentTitlePlaceholder == "string" ? y.patentTitlePlaceholder : "专利名称";
|
|
2217
2217
|
i.textContent = w;
|
|
2218
|
-
const
|
|
2219
|
-
|
|
2218
|
+
const T = ot(r), v = h.rightPanel.activeSectionPos === c();
|
|
2219
|
+
s.textContent = `[${x}]`, s.style.display = T ? "none" : "", s.classList.toggle("ps-placeholder--active", v && !T), o.classList.toggle("pt-title-content--has-content", T);
|
|
2220
2220
|
};
|
|
2221
|
-
let
|
|
2222
|
-
const p =
|
|
2223
|
-
const
|
|
2224
|
-
|
|
2221
|
+
let m = N.getState().editorLanguage, f = N.getState().rightPanel.activeSectionPos;
|
|
2222
|
+
const p = N.subscribe((h) => {
|
|
2223
|
+
const y = h.editorLanguage !== m, w = h.rightPanel.activeSectionPos !== f;
|
|
2224
|
+
m = h.editorLanguage, f = h.rightPanel.activeSectionPos, (y || w) && u();
|
|
2225
2225
|
});
|
|
2226
|
-
return
|
|
2226
|
+
return u(), {
|
|
2227
2227
|
dom: a,
|
|
2228
|
-
contentDOM:
|
|
2229
|
-
update: (
|
|
2228
|
+
contentDOM: o,
|
|
2229
|
+
update: (h) => h.type.name !== "patent_title" ? !1 : (r = h, u(), !0),
|
|
2230
2230
|
destroy: () => {
|
|
2231
|
-
p(),
|
|
2231
|
+
p(), s.removeEventListener("click", d), o.removeEventListener("focusin", l), o.removeEventListener("click", l);
|
|
2232
2232
|
}
|
|
2233
2233
|
};
|
|
2234
2234
|
};
|
|
2235
2235
|
}
|
|
2236
|
-
}),
|
|
2236
|
+
}), za = Z.create({
|
|
2237
2237
|
name: "patent_section",
|
|
2238
2238
|
group: "block",
|
|
2239
2239
|
content: "block+",
|
|
@@ -2298,56 +2298,56 @@ const Le = () => {
|
|
|
2298
2298
|
a.setAttribute("data-type", "patent-section");
|
|
2299
2299
|
const i = document.createElement("div");
|
|
2300
2300
|
i.contentEditable = "false";
|
|
2301
|
+
const s = document.createElement("div");
|
|
2302
|
+
s.className = "ps-body";
|
|
2301
2303
|
const o = document.createElement("div");
|
|
2302
|
-
o.className = "ps-
|
|
2304
|
+
o.className = "ps-placeholder", o.contentEditable = "false";
|
|
2303
2305
|
const c = document.createElement("div");
|
|
2304
|
-
c.className = "ps-
|
|
2305
|
-
const s = document.createElement("div");
|
|
2306
|
-
s.className = "ps-content", o.append(c, s), a.append(i, o);
|
|
2306
|
+
c.className = "ps-content", s.append(o, c), a.append(i, s);
|
|
2307
2307
|
const l = () => {
|
|
2308
|
-
const
|
|
2309
|
-
return typeof
|
|
2308
|
+
const y = typeof n == "function" ? n() : null;
|
|
2309
|
+
return typeof y == "number" ? y : null;
|
|
2310
2310
|
}, d = () => {
|
|
2311
|
-
const
|
|
2312
|
-
if (
|
|
2313
|
-
|
|
2314
|
-
},
|
|
2315
|
-
const
|
|
2316
|
-
if (
|
|
2317
|
-
|
|
2311
|
+
const y = l();
|
|
2312
|
+
if (y === null) return;
|
|
2313
|
+
N.getState().setActiveSection(r.attrs.sectionType, y);
|
|
2314
|
+
}, u = () => {
|
|
2315
|
+
const y = l();
|
|
2316
|
+
if (y === null) return;
|
|
2317
|
+
N.getState().openDraftingPanel(r.attrs.sectionType, y), e.commands.focus(y + 1);
|
|
2318
2318
|
};
|
|
2319
|
-
|
|
2320
|
-
const
|
|
2321
|
-
const
|
|
2322
|
-
a.className = `ps${
|
|
2319
|
+
o.addEventListener("click", u), c.addEventListener("focusin", d), c.addEventListener("click", d);
|
|
2320
|
+
const m = () => {
|
|
2321
|
+
const y = N.getState(), w = H(y.editorLanguage), x = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", T = Ma.has(x), v = Fa.has(x), E = wt[x], _ = typeof w[E] == "string" ? w[E] : x, b = ot(r), C = y.rightPanel.activeSectionPos === l();
|
|
2322
|
+
a.className = `ps${b ? "" : " ps--empty"}${v ? " ps--sub" : ""}`, a.setAttribute("data-section-type", x), i.className = T ? "pb-heading" : "ps-heading ps-heading--sub", i.textContent = _, o.textContent = `[${_}]`, o.style.display = b ? "none" : "", o.classList.toggle("ps-placeholder--active", C && !b), c.classList.toggle("ps-content--has-content", b);
|
|
2323
2323
|
};
|
|
2324
|
-
let f =
|
|
2325
|
-
const
|
|
2326
|
-
const w =
|
|
2327
|
-
f =
|
|
2324
|
+
let f = N.getState().editorLanguage, p = N.getState().rightPanel.activeSectionPos;
|
|
2325
|
+
const h = N.subscribe((y) => {
|
|
2326
|
+
const w = y.editorLanguage !== f, x = y.rightPanel.activeSectionPos !== p;
|
|
2327
|
+
f = y.editorLanguage, p = y.rightPanel.activeSectionPos, (w || x) && m();
|
|
2328
2328
|
});
|
|
2329
|
-
return
|
|
2329
|
+
return m(), {
|
|
2330
2330
|
dom: a,
|
|
2331
|
-
contentDOM:
|
|
2332
|
-
update: (
|
|
2331
|
+
contentDOM: c,
|
|
2332
|
+
update: (y) => y.type.name !== "patent_section" ? !1 : (r = y, m(), !0),
|
|
2333
2333
|
destroy: () => {
|
|
2334
|
-
|
|
2334
|
+
h(), o.removeEventListener("click", u), c.removeEventListener("focusin", d), c.removeEventListener("click", d);
|
|
2335
2335
|
}
|
|
2336
2336
|
};
|
|
2337
2337
|
};
|
|
2338
2338
|
}
|
|
2339
|
-
}),
|
|
2339
|
+
}), Oa = [
|
|
2340
2340
|
"abstract",
|
|
2341
2341
|
// 说明书摘要
|
|
2342
2342
|
"abstract_drawing"
|
|
2343
2343
|
// 摘要附图
|
|
2344
|
-
],
|
|
2344
|
+
], Ba = [
|
|
2345
2345
|
"technical_field",
|
|
2346
2346
|
"background_art",
|
|
2347
2347
|
"summary",
|
|
2348
2348
|
"drawing_description",
|
|
2349
2349
|
"detailed_description"
|
|
2350
|
-
],
|
|
2350
|
+
], Ha = [
|
|
2351
2351
|
"drawing_figures"
|
|
2352
2352
|
// 说明书附图
|
|
2353
2353
|
], Ua = [
|
|
@@ -2370,42 +2370,42 @@ const Le = () => {
|
|
|
2370
2370
|
}), en = () => ({
|
|
2371
2371
|
type: "patent_title",
|
|
2372
2372
|
content: []
|
|
2373
|
-
}),
|
|
2374
|
-
...
|
|
2373
|
+
}), qa = () => [
|
|
2374
|
+
...Oa.map(Fe),
|
|
2375
2375
|
en(),
|
|
2376
|
-
...
|
|
2377
|
-
...
|
|
2378
|
-
],
|
|
2376
|
+
...Ba.map(Fe),
|
|
2377
|
+
...Ha.map(Fe)
|
|
2378
|
+
], Wa = () => [
|
|
2379
2379
|
en(),
|
|
2380
2380
|
...Ua.map(Fe)
|
|
2381
|
-
], tn = (e = "invention") => ({ type: "doc", content: e === "design" ?
|
|
2382
|
-
const n =
|
|
2381
|
+
], tn = (e = "invention") => ({ type: "doc", content: e === "design" ? Wa() : qa() }), ve = (e) => Xt(e, (t) => t.type.name === "figure"), V = (e) => typeof e != "string" ? "" : e.trim(), xt = (e) => {
|
|
2382
|
+
const n = N.getState().editorLanguage === "en" ? "Fig." : "图", r = /* @__PURE__ */ new Set();
|
|
2383
2383
|
ve(e).forEach((i) => {
|
|
2384
|
-
const
|
|
2385
|
-
|
|
2384
|
+
const s = V(i.node.attrs.id);
|
|
2385
|
+
s && r.add(s);
|
|
2386
2386
|
});
|
|
2387
2387
|
let a = 1;
|
|
2388
2388
|
for (; r.has(`${n}${a}`); )
|
|
2389
2389
|
a += 1;
|
|
2390
2390
|
return `${n}${a}`;
|
|
2391
|
-
},
|
|
2392
|
-
const n =
|
|
2391
|
+
}, ja = /^(Fig\.|图)(\d+)$/, Ga = (e) => {
|
|
2392
|
+
const n = N.getState().editorLanguage === "en" ? "Fig." : "图", r = ve(e);
|
|
2393
2393
|
if (r.length === 0) return;
|
|
2394
2394
|
const a = [];
|
|
2395
2395
|
let i = 1;
|
|
2396
|
-
for (const
|
|
2397
|
-
const
|
|
2398
|
-
if (!
|
|
2396
|
+
for (const o of r) {
|
|
2397
|
+
const c = V(o.node.attrs.id);
|
|
2398
|
+
if (!ja.exec(c)) continue;
|
|
2399
2399
|
const d = `${n}${i}`;
|
|
2400
|
-
|
|
2400
|
+
c !== d && a.push({ pos: o.pos, expectedId: d, currentId: c }), i++;
|
|
2401
2401
|
}
|
|
2402
2402
|
if (a.length === 0) return;
|
|
2403
|
-
const { tr:
|
|
2404
|
-
for (const
|
|
2405
|
-
const
|
|
2406
|
-
!
|
|
2403
|
+
const { tr: s } = e.state;
|
|
2404
|
+
for (const o of a) {
|
|
2405
|
+
const c = s.doc.nodeAt(o.pos);
|
|
2406
|
+
!c || c.type.name !== "figure" || s.setNodeMarkup(o.pos, void 0, { ...c.attrs, id: o.expectedId });
|
|
2407
2407
|
}
|
|
2408
|
-
|
|
2408
|
+
s.steps.length > 0 && (s.setMeta("addToHistory", !1), e.view.dispatch(s));
|
|
2409
2409
|
}, nn = (e) => {
|
|
2410
2410
|
const t = /* @__PURE__ */ new Map();
|
|
2411
2411
|
return ve(e).forEach((n) => {
|
|
@@ -2415,35 +2415,35 @@ const Le = () => {
|
|
|
2415
2415
|
pos: n.pos
|
|
2416
2416
|
});
|
|
2417
2417
|
}), t;
|
|
2418
|
-
}, rn = () =>
|
|
2418
|
+
}, rn = () => N.getState().editorLanguage === "en" ? "en" : "zh", an = (e, t, n) => {
|
|
2419
2419
|
const r = H(e);
|
|
2420
2420
|
return n ? r.invalidFigureReference : t || (e === "en" ? "Figure ?" : "附图?");
|
|
2421
2421
|
}, Je = (e) => {
|
|
2422
2422
|
const t = nn(e), n = rn();
|
|
2423
2423
|
e.commands.command(({ tr: r, state: a, dispatch: i }) => {
|
|
2424
|
-
let
|
|
2425
|
-
return a.doc.descendants((
|
|
2426
|
-
if (
|
|
2424
|
+
let s = !1;
|
|
2425
|
+
return a.doc.descendants((o, c) => {
|
|
2426
|
+
if (o.type.name !== "reference" || o.attrs.targetType !== "figure")
|
|
2427
2427
|
return !0;
|
|
2428
|
-
const l = typeof
|
|
2429
|
-
...
|
|
2428
|
+
const l = typeof o.attrs.targetFigureId == "string" && o.attrs.targetFigureId ? V(o.attrs.targetFigureId) : null, d = l ? t.get(l) : void 0, u = d ? d.id : null, m = !d, f = an(n, u, m), p = {
|
|
2429
|
+
...o.attrs,
|
|
2430
2430
|
targetType: "figure",
|
|
2431
2431
|
targetFigureId: l,
|
|
2432
|
-
resolvedFigureId:
|
|
2433
|
-
invalid:
|
|
2432
|
+
resolvedFigureId: u,
|
|
2433
|
+
invalid: m,
|
|
2434
2434
|
lang: n,
|
|
2435
2435
|
displayText: f,
|
|
2436
|
-
target:
|
|
2436
|
+
target: u || o.attrs.target || l || null
|
|
2437
2437
|
};
|
|
2438
2438
|
return Object.keys(p).some(
|
|
2439
|
-
(
|
|
2440
|
-
) && (r.setNodeMarkup(
|
|
2441
|
-
}),
|
|
2439
|
+
(y) => p[y] !== o.attrs[y]
|
|
2440
|
+
) && (r.setNodeMarkup(c, void 0, p), s = !0), !0;
|
|
2441
|
+
}), s && i && (r.setMeta("addToHistory", !1), i(r)), !0;
|
|
2442
2442
|
});
|
|
2443
|
-
},
|
|
2443
|
+
}, Va = {
|
|
2444
2444
|
name: "patent",
|
|
2445
2445
|
version: "1.0.0",
|
|
2446
|
-
extensions: [Ra,
|
|
2446
|
+
extensions: [Da, Ra, $a, za],
|
|
2447
2447
|
toolbarItems: [
|
|
2448
2448
|
{
|
|
2449
2449
|
id: "patent-figure-insert",
|
|
@@ -2465,14 +2465,14 @@ const Le = () => {
|
|
|
2465
2465
|
if (!(n != null && n.lang))
|
|
2466
2466
|
return !1;
|
|
2467
2467
|
const r = n.lang === "en" ? "en" : "zh";
|
|
2468
|
-
|
|
2468
|
+
N.getState().setEditorLanguage(r);
|
|
2469
2469
|
const i = (n.scope || "all") === "current" ? Re(e, "reference") : null;
|
|
2470
|
-
return e.commands.command(({ tr:
|
|
2470
|
+
return e.commands.command(({ tr: o, state: c, dispatch: l }) => {
|
|
2471
2471
|
let d = !1;
|
|
2472
|
-
return
|
|
2473
|
-
...
|
|
2472
|
+
return c.doc.descendants((u, m) => (u.type.name !== "reference" || i && m !== i.pos || u.attrs.lang !== r && (o.setNodeMarkup(m, void 0, {
|
|
2473
|
+
...u.attrs,
|
|
2474
2474
|
lang: r
|
|
2475
|
-
}), d = !0), !0)), d && l && l(
|
|
2475
|
+
}), d = !0), !0)), d && l && (o.setMeta("addToHistory", !1), l(o)), !0;
|
|
2476
2476
|
}) ? (Je(e), !0) : !1;
|
|
2477
2477
|
}
|
|
2478
2478
|
},
|
|
@@ -2500,10 +2500,10 @@ const Le = () => {
|
|
|
2500
2500
|
const i = e.state.doc.nodeAt(a);
|
|
2501
2501
|
if (!i || i.type.name !== "figure")
|
|
2502
2502
|
return !1;
|
|
2503
|
-
const
|
|
2504
|
-
if (ve(e).some((d) => d.pos === a ? !1 : V(d.node.attrs.id) ===
|
|
2503
|
+
const o = (typeof n.id == "string" ? V(n.id) : V(i.attrs.id)) || xt(e);
|
|
2504
|
+
if (ve(e).some((d) => d.pos === a ? !1 : V(d.node.attrs.id) === o))
|
|
2505
2505
|
return !1;
|
|
2506
|
-
const l = { id:
|
|
2506
|
+
const l = { id: o };
|
|
2507
2507
|
return typeof n.contentType == "string" && ["image", "mermaid", "drawio"].includes(n.contentType) && (l.contentType = n.contentType), typeof n.imageSrc == "string" && (l.imageSrc = n.imageSrc), typeof n.mermaidCode == "string" && (l.mermaidCode = n.mermaidCode), typeof n.drawioXml == "string" && (l.drawioXml = n.drawioXml), ze(e, {
|
|
2508
2508
|
type: "figure",
|
|
2509
2509
|
position: a,
|
|
@@ -2547,7 +2547,7 @@ const Le = () => {
|
|
|
2547
2547
|
const i = r.get(a);
|
|
2548
2548
|
if (!i)
|
|
2549
2549
|
return !1;
|
|
2550
|
-
const
|
|
2550
|
+
const s = n.lang || rn(), o = n.displayText || an(s, i.id, !1);
|
|
2551
2551
|
return e.chain().focus().insertContent({
|
|
2552
2552
|
type: "reference",
|
|
2553
2553
|
attrs: {
|
|
@@ -2556,9 +2556,9 @@ const Le = () => {
|
|
|
2556
2556
|
targetFigureId: i.id,
|
|
2557
2557
|
resolvedNumber: null,
|
|
2558
2558
|
resolvedFigureId: i.id,
|
|
2559
|
-
lang:
|
|
2559
|
+
lang: s,
|
|
2560
2560
|
invalid: !1,
|
|
2561
|
-
displayText:
|
|
2561
|
+
displayText: o,
|
|
2562
2562
|
target: n.target || i.id,
|
|
2563
2563
|
highlight: !1
|
|
2564
2564
|
}
|
|
@@ -2589,13 +2589,13 @@ const Le = () => {
|
|
|
2589
2589
|
}
|
|
2590
2590
|
},
|
|
2591
2591
|
onStateChange: (e) => {
|
|
2592
|
-
|
|
2592
|
+
Ga(e), Je(e);
|
|
2593
2593
|
}
|
|
2594
|
-
},
|
|
2595
|
-
|
|
2596
|
-
const
|
|
2594
|
+
}, Ja = [xa, Ta, ka, Va];
|
|
2595
|
+
Ja.forEach((e) => B.register(e));
|
|
2596
|
+
const Ka = (e = {}) => {
|
|
2597
2597
|
const t = [
|
|
2598
|
-
...
|
|
2598
|
+
...ya,
|
|
2599
2599
|
...B.getExtensions(),
|
|
2600
2600
|
...e.extensions || []
|
|
2601
2601
|
];
|
|
@@ -2608,7 +2608,7 @@ const Xa = (e = {}) => {
|
|
|
2608
2608
|
return {
|
|
2609
2609
|
editor: e,
|
|
2610
2610
|
selection: { from: t, to: n },
|
|
2611
|
-
store:
|
|
2611
|
+
store: N.getState()
|
|
2612
2612
|
};
|
|
2613
2613
|
}, ct = (e) => ({
|
|
2614
2614
|
execCommand: (t, n, r) => B.executeCommand(t, Ke(e), n, r),
|
|
@@ -2619,12 +2619,12 @@ const Xa = (e = {}) => {
|
|
|
2619
2619
|
updateNodeAttrs: (t) => ze(e, t),
|
|
2620
2620
|
removeNode: (t) => Zt(e, t),
|
|
2621
2621
|
wrapSelection: (t) => Qt(e, t),
|
|
2622
|
-
applyTransactionBatch: (t) =>
|
|
2622
|
+
applyTransactionBatch: (t) => Aa(e, t),
|
|
2623
2623
|
findNodeByType: (t, n) => st(e, t, n),
|
|
2624
2624
|
findAncestorNode: (t) => Re(e, t),
|
|
2625
|
-
findCurrentBlock: () =>
|
|
2625
|
+
findCurrentBlock: () => _a(e),
|
|
2626
2626
|
findNodesByPredicate: (t, n) => Xt(e, t, n)
|
|
2627
|
-
}),
|
|
2627
|
+
}), Xa = ["history", "text", "structure", "format", "technical", "patent"], Ya = {
|
|
2628
2628
|
history: "groupHistory",
|
|
2629
2629
|
text: "groupText",
|
|
2630
2630
|
structure: "groupStructure",
|
|
@@ -2633,28 +2633,28 @@ const Xa = (e = {}) => {
|
|
|
2633
2633
|
patent: "groupPatent"
|
|
2634
2634
|
}, Xe = (e, t) => {
|
|
2635
2635
|
if (t) {
|
|
2636
|
-
const n =
|
|
2636
|
+
const n = Ya[e];
|
|
2637
2637
|
if (n && typeof t[n] == "string") return t[n];
|
|
2638
2638
|
}
|
|
2639
2639
|
return e.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join(" ");
|
|
2640
2640
|
}, Ct = ({ btn: e, items: t }) => {
|
|
2641
|
-
const [n, r] =
|
|
2641
|
+
const [n, r] = F(!1), a = W(null), i = W(null), [s, o] = F({ top: 0, left: 0 }), c = ae(() => {
|
|
2642
2642
|
if (!a.current) return;
|
|
2643
2643
|
const l = a.current.getBoundingClientRect();
|
|
2644
|
-
|
|
2644
|
+
o({ top: l.bottom + 4, left: l.left });
|
|
2645
2645
|
}, []);
|
|
2646
2646
|
return M(() => {
|
|
2647
2647
|
if (!n) return;
|
|
2648
|
-
|
|
2649
|
-
const l = (
|
|
2648
|
+
c();
|
|
2649
|
+
const l = (u) => {
|
|
2650
2650
|
var f, p;
|
|
2651
|
-
const
|
|
2652
|
-
(f = a.current) != null && f.contains(
|
|
2653
|
-
}, d = () =>
|
|
2651
|
+
const m = u.target;
|
|
2652
|
+
(f = a.current) != null && f.contains(m) || (p = i.current) != null && p.contains(m) || r(!1);
|
|
2653
|
+
}, d = () => c();
|
|
2654
2654
|
return document.addEventListener("mousedown", l), window.addEventListener("scroll", d, !0), () => {
|
|
2655
2655
|
document.removeEventListener("mousedown", l), window.removeEventListener("scroll", d, !0);
|
|
2656
2656
|
};
|
|
2657
|
-
}, [n,
|
|
2657
|
+
}, [n, c]), /* @__PURE__ */ L("div", { className: "flex items-center", children: [
|
|
2658
2658
|
/* @__PURE__ */ g(
|
|
2659
2659
|
"button",
|
|
2660
2660
|
{
|
|
@@ -2679,7 +2679,7 @@ const Xa = (e = {}) => {
|
|
|
2679
2679
|
e.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200 text-gray-500"
|
|
2680
2680
|
),
|
|
2681
2681
|
disabled: e.disabled,
|
|
2682
|
-
children: /* @__PURE__ */ g(
|
|
2682
|
+
children: /* @__PURE__ */ g(qt, { size: 12 })
|
|
2683
2683
|
}
|
|
2684
2684
|
),
|
|
2685
2685
|
n && yr(
|
|
@@ -2688,7 +2688,7 @@ const Xa = (e = {}) => {
|
|
|
2688
2688
|
{
|
|
2689
2689
|
ref: i,
|
|
2690
2690
|
className: "bg-white border border-gray-200 rounded shadow-lg min-w-[160px] py-1",
|
|
2691
|
-
style: { position: "fixed", top:
|
|
2691
|
+
style: { position: "fixed", top: s.top, left: s.left, zIndex: 9999 },
|
|
2692
2692
|
children: t.map((l, d) => /* @__PURE__ */ g(
|
|
2693
2693
|
"button",
|
|
2694
2694
|
{
|
|
@@ -2705,22 +2705,28 @@ const Xa = (e = {}) => {
|
|
|
2705
2705
|
document.body
|
|
2706
2706
|
)
|
|
2707
2707
|
] });
|
|
2708
|
-
},
|
|
2708
|
+
}, Za = ({
|
|
2709
2709
|
editor: e,
|
|
2710
|
-
groupOrder: t =
|
|
2710
|
+
groupOrder: t = Xa,
|
|
2711
2711
|
collapsibleGroups: n = !0,
|
|
2712
2712
|
defaultCollapsedGroups: r = []
|
|
2713
2713
|
}) => {
|
|
2714
|
-
const [a, i] =
|
|
2715
|
-
if (
|
|
2714
|
+
const [a, i] = F(() => new Set(r)), [, s] = F(0), { editorLanguage: o, setEditorLanguage: c } = N(), l = H(o);
|
|
2715
|
+
if (M(() => {
|
|
2716
|
+
if (!e) return;
|
|
2717
|
+
const b = () => s((C) => C + 1);
|
|
2718
|
+
return e.on("selectionUpdate", b), e.on("update", b), () => {
|
|
2719
|
+
e.off("selectionUpdate", b), e.off("update", b);
|
|
2720
|
+
};
|
|
2721
|
+
}, [e]), !e)
|
|
2716
2722
|
return null;
|
|
2717
|
-
const
|
|
2723
|
+
const d = ct(e), u = o === "zh", m = [
|
|
2718
2724
|
{
|
|
2719
2725
|
id: "core-undo",
|
|
2720
|
-
label:
|
|
2726
|
+
label: l.undo,
|
|
2721
2727
|
group: "history",
|
|
2722
2728
|
icon: br,
|
|
2723
|
-
tooltip: `${
|
|
2729
|
+
tooltip: `${l.undo} (Ctrl+Z)`,
|
|
2724
2730
|
isActive: !1,
|
|
2725
2731
|
disabled: !e.can().chain().focus().undo().run(),
|
|
2726
2732
|
run: () => {
|
|
@@ -2729,10 +2735,10 @@ const Xa = (e = {}) => {
|
|
|
2729
2735
|
},
|
|
2730
2736
|
{
|
|
2731
2737
|
id: "core-redo",
|
|
2732
|
-
label:
|
|
2738
|
+
label: l.redo,
|
|
2733
2739
|
group: "history",
|
|
2734
2740
|
icon: vr,
|
|
2735
|
-
tooltip: `${
|
|
2741
|
+
tooltip: `${l.redo} (Ctrl+Y)`,
|
|
2736
2742
|
isActive: !1,
|
|
2737
2743
|
disabled: !e.can().chain().focus().redo().run(),
|
|
2738
2744
|
run: () => {
|
|
@@ -2741,10 +2747,10 @@ const Xa = (e = {}) => {
|
|
|
2741
2747
|
},
|
|
2742
2748
|
{
|
|
2743
2749
|
id: "core-bold",
|
|
2744
|
-
label:
|
|
2750
|
+
label: l.bold,
|
|
2745
2751
|
group: "text",
|
|
2746
2752
|
icon: Dt,
|
|
2747
|
-
tooltip:
|
|
2753
|
+
tooltip: l.bold,
|
|
2748
2754
|
isActive: e.isActive("bold"),
|
|
2749
2755
|
disabled: !1,
|
|
2750
2756
|
run: () => {
|
|
@@ -2753,10 +2759,10 @@ const Xa = (e = {}) => {
|
|
|
2753
2759
|
},
|
|
2754
2760
|
{
|
|
2755
2761
|
id: "core-italic",
|
|
2756
|
-
label:
|
|
2762
|
+
label: l.italic,
|
|
2757
2763
|
group: "text",
|
|
2758
2764
|
icon: Rt,
|
|
2759
|
-
tooltip:
|
|
2765
|
+
tooltip: l.italic,
|
|
2760
2766
|
isActive: e.isActive("italic"),
|
|
2761
2767
|
disabled: !1,
|
|
2762
2768
|
run: () => {
|
|
@@ -2765,10 +2771,10 @@ const Xa = (e = {}) => {
|
|
|
2765
2771
|
},
|
|
2766
2772
|
{
|
|
2767
2773
|
id: "core-underline",
|
|
2768
|
-
label:
|
|
2774
|
+
label: l.underline,
|
|
2769
2775
|
group: "text",
|
|
2770
2776
|
icon: Mt,
|
|
2771
|
-
tooltip:
|
|
2777
|
+
tooltip: l.underline,
|
|
2772
2778
|
isActive: e.isActive("underline"),
|
|
2773
2779
|
disabled: !1,
|
|
2774
2780
|
run: () => {
|
|
@@ -2777,10 +2783,10 @@ const Xa = (e = {}) => {
|
|
|
2777
2783
|
},
|
|
2778
2784
|
{
|
|
2779
2785
|
id: "core-strike",
|
|
2780
|
-
label:
|
|
2786
|
+
label: l.strike,
|
|
2781
2787
|
group: "text",
|
|
2782
2788
|
icon: Ft,
|
|
2783
|
-
tooltip:
|
|
2789
|
+
tooltip: l.strike,
|
|
2784
2790
|
isActive: e.isActive("strike"),
|
|
2785
2791
|
disabled: !1,
|
|
2786
2792
|
run: () => {
|
|
@@ -2789,10 +2795,10 @@ const Xa = (e = {}) => {
|
|
|
2789
2795
|
},
|
|
2790
2796
|
{
|
|
2791
2797
|
id: "core-code",
|
|
2792
|
-
label:
|
|
2798
|
+
label: l.code,
|
|
2793
2799
|
group: "text",
|
|
2794
2800
|
icon: $t,
|
|
2795
|
-
tooltip:
|
|
2801
|
+
tooltip: l.code,
|
|
2796
2802
|
isActive: e.isActive("code"),
|
|
2797
2803
|
disabled: !1,
|
|
2798
2804
|
run: () => {
|
|
@@ -2801,10 +2807,10 @@ const Xa = (e = {}) => {
|
|
|
2801
2807
|
},
|
|
2802
2808
|
{
|
|
2803
2809
|
id: "core-superscript",
|
|
2804
|
-
label:
|
|
2810
|
+
label: l.superscript,
|
|
2805
2811
|
group: "text",
|
|
2806
2812
|
icon: zt,
|
|
2807
|
-
tooltip: `${
|
|
2813
|
+
tooltip: `${l.superscript} (Ctrl+.)`,
|
|
2808
2814
|
isActive: e.isActive("superscript"),
|
|
2809
2815
|
disabled: !1,
|
|
2810
2816
|
run: () => {
|
|
@@ -2813,10 +2819,10 @@ const Xa = (e = {}) => {
|
|
|
2813
2819
|
},
|
|
2814
2820
|
{
|
|
2815
2821
|
id: "core-subscript",
|
|
2816
|
-
label:
|
|
2822
|
+
label: l.subscript,
|
|
2817
2823
|
group: "text",
|
|
2818
2824
|
icon: Ot,
|
|
2819
|
-
tooltip: `${
|
|
2825
|
+
tooltip: `${l.subscript} (Ctrl+,)`,
|
|
2820
2826
|
isActive: e.isActive("subscript"),
|
|
2821
2827
|
disabled: !1,
|
|
2822
2828
|
run: () => {
|
|
@@ -2825,10 +2831,10 @@ const Xa = (e = {}) => {
|
|
|
2825
2831
|
},
|
|
2826
2832
|
{
|
|
2827
2833
|
id: "core-paragraph",
|
|
2828
|
-
label:
|
|
2834
|
+
label: l.paragraph,
|
|
2829
2835
|
group: "structure",
|
|
2830
2836
|
icon: wr,
|
|
2831
|
-
tooltip:
|
|
2837
|
+
tooltip: l.paragraph,
|
|
2832
2838
|
isActive: e.isActive("paragraph"),
|
|
2833
2839
|
disabled: !1,
|
|
2834
2840
|
run: () => {
|
|
@@ -2840,7 +2846,7 @@ const Xa = (e = {}) => {
|
|
|
2840
2846
|
label: "H1",
|
|
2841
2847
|
group: "structure",
|
|
2842
2848
|
icon: xr,
|
|
2843
|
-
tooltip:
|
|
2849
|
+
tooltip: l.heading1,
|
|
2844
2850
|
isActive: e.isActive("heading", { level: 1 }),
|
|
2845
2851
|
disabled: !1,
|
|
2846
2852
|
run: () => {
|
|
@@ -2852,7 +2858,7 @@ const Xa = (e = {}) => {
|
|
|
2852
2858
|
label: "H2",
|
|
2853
2859
|
group: "structure",
|
|
2854
2860
|
icon: Cr,
|
|
2855
|
-
tooltip:
|
|
2861
|
+
tooltip: l.heading2,
|
|
2856
2862
|
isActive: e.isActive("heading", { level: 2 }),
|
|
2857
2863
|
disabled: !1,
|
|
2858
2864
|
run: () => {
|
|
@@ -2864,7 +2870,7 @@ const Xa = (e = {}) => {
|
|
|
2864
2870
|
label: "H3",
|
|
2865
2871
|
group: "structure",
|
|
2866
2872
|
icon: Tr,
|
|
2867
|
-
tooltip:
|
|
2873
|
+
tooltip: l.heading3,
|
|
2868
2874
|
isActive: e.isActive("heading", { level: 3 }),
|
|
2869
2875
|
disabled: !1,
|
|
2870
2876
|
run: () => {
|
|
@@ -2873,10 +2879,10 @@ const Xa = (e = {}) => {
|
|
|
2873
2879
|
},
|
|
2874
2880
|
{
|
|
2875
2881
|
id: "core-align-left",
|
|
2876
|
-
label:
|
|
2882
|
+
label: l.alignLeft,
|
|
2877
2883
|
group: "format",
|
|
2878
2884
|
icon: Sr,
|
|
2879
|
-
tooltip:
|
|
2885
|
+
tooltip: l.alignLeft,
|
|
2880
2886
|
isActive: e.isActive({ textAlign: "left" }),
|
|
2881
2887
|
disabled: !1,
|
|
2882
2888
|
run: () => {
|
|
@@ -2885,10 +2891,10 @@ const Xa = (e = {}) => {
|
|
|
2885
2891
|
},
|
|
2886
2892
|
{
|
|
2887
2893
|
id: "core-align-center",
|
|
2888
|
-
label:
|
|
2894
|
+
label: l.alignCenter,
|
|
2889
2895
|
group: "format",
|
|
2890
2896
|
icon: Er,
|
|
2891
|
-
tooltip:
|
|
2897
|
+
tooltip: l.alignCenter,
|
|
2892
2898
|
isActive: e.isActive({ textAlign: "center" }),
|
|
2893
2899
|
disabled: !1,
|
|
2894
2900
|
run: () => {
|
|
@@ -2897,10 +2903,10 @@ const Xa = (e = {}) => {
|
|
|
2897
2903
|
},
|
|
2898
2904
|
{
|
|
2899
2905
|
id: "core-align-right",
|
|
2900
|
-
label:
|
|
2906
|
+
label: l.alignRight,
|
|
2901
2907
|
group: "format",
|
|
2902
2908
|
icon: kr,
|
|
2903
|
-
tooltip:
|
|
2909
|
+
tooltip: l.alignRight,
|
|
2904
2910
|
isActive: e.isActive({ textAlign: "right" }),
|
|
2905
2911
|
disabled: !1,
|
|
2906
2912
|
run: () => {
|
|
@@ -2909,10 +2915,10 @@ const Xa = (e = {}) => {
|
|
|
2909
2915
|
},
|
|
2910
2916
|
{
|
|
2911
2917
|
id: "core-align-justify",
|
|
2912
|
-
label:
|
|
2918
|
+
label: l.alignJustify,
|
|
2913
2919
|
group: "format",
|
|
2914
2920
|
icon: _r,
|
|
2915
|
-
tooltip:
|
|
2921
|
+
tooltip: l.alignJustify,
|
|
2916
2922
|
isActive: e.isActive({ textAlign: "justify" }),
|
|
2917
2923
|
disabled: !1,
|
|
2918
2924
|
run: () => {
|
|
@@ -2921,10 +2927,10 @@ const Xa = (e = {}) => {
|
|
|
2921
2927
|
},
|
|
2922
2928
|
{
|
|
2923
2929
|
id: "core-bullet-list",
|
|
2924
|
-
label:
|
|
2930
|
+
label: l.bulletList,
|
|
2925
2931
|
group: "structure",
|
|
2926
2932
|
icon: Ir,
|
|
2927
|
-
tooltip:
|
|
2933
|
+
tooltip: l.bulletList,
|
|
2928
2934
|
isActive: e.isActive("bulletList"),
|
|
2929
2935
|
disabled: !1,
|
|
2930
2936
|
run: () => {
|
|
@@ -2933,10 +2939,10 @@ const Xa = (e = {}) => {
|
|
|
2933
2939
|
},
|
|
2934
2940
|
{
|
|
2935
2941
|
id: "core-ordered-list",
|
|
2936
|
-
label:
|
|
2942
|
+
label: l.orderedList,
|
|
2937
2943
|
group: "structure",
|
|
2938
2944
|
icon: Nr,
|
|
2939
|
-
tooltip:
|
|
2945
|
+
tooltip: l.orderedList,
|
|
2940
2946
|
isActive: e.isActive("orderedList"),
|
|
2941
2947
|
disabled: !1,
|
|
2942
2948
|
run: () => {
|
|
@@ -2945,10 +2951,10 @@ const Xa = (e = {}) => {
|
|
|
2945
2951
|
},
|
|
2946
2952
|
{
|
|
2947
2953
|
id: "core-blockquote",
|
|
2948
|
-
label:
|
|
2954
|
+
label: l.blockquote,
|
|
2949
2955
|
group: "structure",
|
|
2950
2956
|
icon: Ar,
|
|
2951
|
-
tooltip:
|
|
2957
|
+
tooltip: l.blockquote,
|
|
2952
2958
|
isActive: e.isActive("blockquote"),
|
|
2953
2959
|
disabled: !1,
|
|
2954
2960
|
run: () => {
|
|
@@ -2957,10 +2963,10 @@ const Xa = (e = {}) => {
|
|
|
2957
2963
|
},
|
|
2958
2964
|
{
|
|
2959
2965
|
id: "core-code-block",
|
|
2960
|
-
label:
|
|
2966
|
+
label: l.codeBlock,
|
|
2961
2967
|
group: "structure",
|
|
2962
2968
|
icon: Lr,
|
|
2963
|
-
tooltip:
|
|
2969
|
+
tooltip: l.codeBlock,
|
|
2964
2970
|
isActive: e.isActive("codeBlock"),
|
|
2965
2971
|
disabled: !1,
|
|
2966
2972
|
run: () => {
|
|
@@ -2969,10 +2975,10 @@ const Xa = (e = {}) => {
|
|
|
2969
2975
|
},
|
|
2970
2976
|
{
|
|
2971
2977
|
id: "core-table",
|
|
2972
|
-
label:
|
|
2978
|
+
label: l.insertTable,
|
|
2973
2979
|
group: "structure",
|
|
2974
2980
|
icon: Pr,
|
|
2975
|
-
tooltip:
|
|
2981
|
+
tooltip: l.insertTable,
|
|
2976
2982
|
isActive: !1,
|
|
2977
2983
|
disabled: !1,
|
|
2978
2984
|
run: () => {
|
|
@@ -2981,10 +2987,10 @@ const Xa = (e = {}) => {
|
|
|
2981
2987
|
},
|
|
2982
2988
|
{
|
|
2983
2989
|
id: "core-horizontal-rule",
|
|
2984
|
-
label:
|
|
2990
|
+
label: l.horizontalRule,
|
|
2985
2991
|
group: "structure",
|
|
2986
2992
|
icon: Dr,
|
|
2987
|
-
tooltip:
|
|
2993
|
+
tooltip: l.horizontalRule,
|
|
2988
2994
|
isActive: !1,
|
|
2989
2995
|
disabled: !1,
|
|
2990
2996
|
run: () => {
|
|
@@ -2993,87 +2999,87 @@ const Xa = (e = {}) => {
|
|
|
2993
2999
|
},
|
|
2994
3000
|
{
|
|
2995
3001
|
id: "core-task-list",
|
|
2996
|
-
label:
|
|
3002
|
+
label: l.taskList,
|
|
2997
3003
|
group: "structure",
|
|
2998
3004
|
icon: Rr,
|
|
2999
|
-
tooltip:
|
|
3005
|
+
tooltip: l.taskList,
|
|
3000
3006
|
isActive: e.isActive("taskList"),
|
|
3001
3007
|
disabled: !1,
|
|
3002
3008
|
run: () => {
|
|
3003
3009
|
e.chain().focus().toggleTaskList().run();
|
|
3004
3010
|
}
|
|
3005
3011
|
}
|
|
3006
|
-
],
|
|
3012
|
+
], f = {
|
|
3007
3013
|
GitGraph: Or,
|
|
3008
3014
|
Sigma: zr,
|
|
3009
3015
|
FunctionSquare: $r,
|
|
3010
3016
|
Workflow: Fr,
|
|
3011
3017
|
Box: Mr,
|
|
3012
|
-
FileText:
|
|
3018
|
+
FileText: Ut,
|
|
3013
3019
|
Link2: Ht,
|
|
3014
3020
|
Image: Bt
|
|
3015
|
-
},
|
|
3016
|
-
const
|
|
3021
|
+
}, p = B.getToolbarItems().map((b) => {
|
|
3022
|
+
const C = B.getCommandMeta(b.command), I = u && b.tooltipZh ? b.tooltipZh : b.tooltip || (C == null ? void 0 : C.description) || b.label, A = b.shortcut || (C == null ? void 0 : C.shortcut), D = A ? `${I} (${A})` : I;
|
|
3017
3023
|
return {
|
|
3018
|
-
id:
|
|
3019
|
-
label:
|
|
3020
|
-
group:
|
|
3021
|
-
icon:
|
|
3022
|
-
isActive:
|
|
3023
|
-
disabled: !
|
|
3024
|
-
tooltip:
|
|
3024
|
+
id: b.id,
|
|
3025
|
+
label: b.label,
|
|
3026
|
+
group: b.group || "technical",
|
|
3027
|
+
icon: b.icon ? f[b.icon] || mt : mt,
|
|
3028
|
+
isActive: d.isCommandActive(b.command),
|
|
3029
|
+
disabled: !d.canExecCommand(b.command),
|
|
3030
|
+
tooltip: D,
|
|
3025
3031
|
run: () => {
|
|
3026
|
-
|
|
3032
|
+
d.execCommand(b.command);
|
|
3027
3033
|
}
|
|
3028
3034
|
};
|
|
3029
|
-
}),
|
|
3030
|
-
group:
|
|
3031
|
-
items:
|
|
3032
|
-
})).filter((
|
|
3033
|
-
i((
|
|
3034
|
-
const
|
|
3035
|
-
return
|
|
3035
|
+
}), h = [...m, ...p], y = h.map((b) => b.group).filter((b, C, I) => I.indexOf(b) === C && !t.includes(b)), x = [...t, ...y].map((b) => ({
|
|
3036
|
+
group: b,
|
|
3037
|
+
items: h.filter((C) => C.group === b)
|
|
3038
|
+
})).filter((b) => b.items.length > 0), T = (b) => {
|
|
3039
|
+
i((C) => {
|
|
3040
|
+
const I = new Set(C);
|
|
3041
|
+
return I.has(b) ? I.delete(b) : I.add(b), I;
|
|
3036
3042
|
});
|
|
3037
|
-
},
|
|
3038
|
-
{ label:
|
|
3039
|
-
{ label:
|
|
3040
|
-
{ label:
|
|
3041
|
-
{ label:
|
|
3042
|
-
{ label:
|
|
3043
|
-
{ label:
|
|
3044
|
-
{ label:
|
|
3045
|
-
{ label:
|
|
3046
|
-
{ label:
|
|
3047
|
-
{ label:
|
|
3048
|
-
{ label:
|
|
3049
|
-
],
|
|
3050
|
-
{ label:
|
|
3051
|
-
{ label:
|
|
3052
|
-
{ label:
|
|
3053
|
-
],
|
|
3043
|
+
}, v = [
|
|
3044
|
+
{ label: u ? "插入表格 3×3" : "Insert Table 3×3", onClick: () => e.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run() },
|
|
3045
|
+
{ label: u ? "上方插入行" : "Add Row Before", onClick: () => e.chain().focus().addRowBefore().run() },
|
|
3046
|
+
{ label: u ? "下方插入行" : "Add Row After", onClick: () => e.chain().focus().addRowAfter().run() },
|
|
3047
|
+
{ label: u ? "左侧插入列" : "Add Column Before", onClick: () => e.chain().focus().addColumnBefore().run() },
|
|
3048
|
+
{ label: u ? "右侧插入列" : "Add Column After", onClick: () => e.chain().focus().addColumnAfter().run() },
|
|
3049
|
+
{ label: u ? "删除行" : "Delete Row", onClick: () => e.chain().focus().deleteRow().run() },
|
|
3050
|
+
{ label: u ? "删除列" : "Delete Column", onClick: () => e.chain().focus().deleteColumn().run() },
|
|
3051
|
+
{ label: u ? "合并单元格" : "Merge Cells", onClick: () => e.chain().focus().mergeCells().run() },
|
|
3052
|
+
{ label: u ? "拆分单元格" : "Split Cell", onClick: () => e.chain().focus().splitCell().run() },
|
|
3053
|
+
{ label: u ? "切换表头" : "Toggle Header Row", onClick: () => e.chain().focus().toggleHeaderRow().run() },
|
|
3054
|
+
{ label: u ? "删除表格" : "Delete Table", onClick: () => e.chain().focus().deleteTable().run() }
|
|
3055
|
+
], E = [
|
|
3056
|
+
{ label: l.insertImageFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "image" }) },
|
|
3057
|
+
{ label: l.insertMermaidFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "mermaid" }) },
|
|
3058
|
+
{ label: l.insertDrawioFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "drawio" }) }
|
|
3059
|
+
], _ = (b) => b.id === "core-table" ? /* @__PURE__ */ g(Ct, { btn: b, items: v }, b.id) : b.id === "patent-figure-insert" ? /* @__PURE__ */ g(Ct, { btn: b, items: E }, b.id) : /* @__PURE__ */ g(
|
|
3054
3060
|
"button",
|
|
3055
3061
|
{
|
|
3056
|
-
onClick:
|
|
3057
|
-
disabled:
|
|
3062
|
+
onClick: b.run,
|
|
3063
|
+
disabled: b.disabled,
|
|
3058
3064
|
className: Y(
|
|
3059
3065
|
"p-2 rounded transition-colors",
|
|
3060
|
-
|
|
3061
|
-
|
|
3066
|
+
b.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200",
|
|
3067
|
+
b.isActive ? "bg-gray-300 text-blue-600" : "text-gray-700"
|
|
3062
3068
|
),
|
|
3063
|
-
title:
|
|
3064
|
-
children: /* @__PURE__ */ g(
|
|
3069
|
+
title: b.tooltip,
|
|
3070
|
+
children: /* @__PURE__ */ g(b.icon, { size: 18 })
|
|
3065
3071
|
},
|
|
3066
|
-
|
|
3072
|
+
b.id
|
|
3067
3073
|
);
|
|
3068
3074
|
return /* @__PURE__ */ g("div", { className: "border-b border-gray-200 bg-gray-50 sticky top-0 z-10 overflow-x-auto", children: /* @__PURE__ */ L("div", { className: "flex flex-nowrap md:flex-wrap gap-2 p-2 min-w-max md:min-w-0", children: [
|
|
3069
3075
|
/* @__PURE__ */ L("div", { className: "flex items-center gap-1 pr-2 mr-2 border-r border-gray-200", children: [
|
|
3070
|
-
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children:
|
|
3076
|
+
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: l.language }),
|
|
3071
3077
|
/* @__PURE__ */ L(
|
|
3072
3078
|
"select",
|
|
3073
3079
|
{
|
|
3074
3080
|
value: o,
|
|
3075
|
-
onChange: (
|
|
3076
|
-
c(
|
|
3081
|
+
onChange: (b) => {
|
|
3082
|
+
c(b.target.value === "en" ? "en" : "zh");
|
|
3077
3083
|
},
|
|
3078
3084
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white text-gray-700",
|
|
3079
3085
|
children: [
|
|
@@ -3083,26 +3089,26 @@ const Xa = (e = {}) => {
|
|
|
3083
3089
|
}
|
|
3084
3090
|
)
|
|
3085
3091
|
] }),
|
|
3086
|
-
|
|
3087
|
-
const
|
|
3092
|
+
x.map((b) => {
|
|
3093
|
+
const C = a.has(b.group);
|
|
3088
3094
|
return /* @__PURE__ */ L("div", { className: "flex items-center gap-1 pr-2 mr-2 border-r border-gray-200 last:border-r-0 last:mr-0 last:pr-0", children: [
|
|
3089
3095
|
n && /* @__PURE__ */ g(
|
|
3090
3096
|
"button",
|
|
3091
3097
|
{
|
|
3092
3098
|
onClick: () => {
|
|
3093
|
-
|
|
3099
|
+
T(b.group);
|
|
3094
3100
|
},
|
|
3095
3101
|
className: "px-2 py-1 text-xs rounded bg-gray-200 text-gray-700 hover:bg-gray-300",
|
|
3096
|
-
title:
|
|
3097
|
-
children: Xe(
|
|
3102
|
+
title: C ? `${l.expand} ${Xe(b.group, l)}` : `${l.collapse} ${Xe(b.group, l)}`,
|
|
3103
|
+
children: Xe(b.group, l)
|
|
3098
3104
|
}
|
|
3099
3105
|
),
|
|
3100
|
-
(!n || !
|
|
3101
|
-
] },
|
|
3106
|
+
(!n || !C) && b.items.map(_)
|
|
3107
|
+
] }, b.group);
|
|
3102
3108
|
})
|
|
3103
3109
|
] }) });
|
|
3104
|
-
},
|
|
3105
|
-
const [t, n] =
|
|
3110
|
+
}, Qa = ({ editor: e }) => {
|
|
3111
|
+
const [t, n] = F(0), [r, a] = F(""), i = N((v) => v.editorLanguage), s = H(i);
|
|
3106
3112
|
if (M(() => {
|
|
3107
3113
|
if (!e) return;
|
|
3108
3114
|
const v = () => n((E) => E + 1);
|
|
@@ -3110,30 +3116,30 @@ const Xa = (e = {}) => {
|
|
|
3110
3116
|
e.off("selectionUpdate", v), e.off("update", v);
|
|
3111
3117
|
};
|
|
3112
3118
|
}, [e]), !e) return null;
|
|
3113
|
-
const
|
|
3119
|
+
const o = ct(e), c = [];
|
|
3114
3120
|
e.state.doc.descendants((v) => {
|
|
3115
3121
|
if (v.type.name !== "figure") return !0;
|
|
3116
3122
|
const E = typeof v.attrs.id == "string" ? v.attrs.id.trim() : "";
|
|
3117
|
-
return E &&
|
|
3123
|
+
return E && c.push({ id: E, label: E }), !0;
|
|
3118
3124
|
});
|
|
3119
|
-
const l =
|
|
3120
|
-
w !==
|
|
3125
|
+
const l = o.findAncestorNode("figure"), d = !!l, u = l && typeof l.node.attrs.id == "string" ? l.node.attrs.id.trim() : "", m = l && typeof l.node.attrs.contentType == "string" ? l.node.attrs.contentType : "image", [f, p] = F(""), h = W(null), y = W(null), w = (l == null ? void 0 : l.pos) ?? null;
|
|
3126
|
+
w !== y.current && (y.current = w, d && u !== f && p(u));
|
|
3121
3127
|
const x = (v) => {
|
|
3122
|
-
l &&
|
|
3128
|
+
l && o.execCommand("patent.updateFigure", {
|
|
3123
3129
|
position: l.pos,
|
|
3124
3130
|
contentType: v
|
|
3125
3131
|
});
|
|
3126
|
-
},
|
|
3132
|
+
}, T = () => {
|
|
3127
3133
|
if (!l) return;
|
|
3128
3134
|
const v = f.trim();
|
|
3129
|
-
v !==
|
|
3135
|
+
v !== u && o.execCommand("patent.updateFigure", {
|
|
3130
3136
|
position: l.pos,
|
|
3131
3137
|
id: v
|
|
3132
3138
|
});
|
|
3133
3139
|
};
|
|
3134
3140
|
return /* @__PURE__ */ g("div", { className: "border-b border-gray-200 bg-gray-50 p-2", children: /* @__PURE__ */ L("div", { className: "bg-white border border-gray-200 rounded-md px-2 py-2 flex flex-wrap items-center gap-2", children: [
|
|
3135
|
-
|
|
3136
|
-
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children:
|
|
3141
|
+
c.length > 0 && /* @__PURE__ */ L(je, { children: [
|
|
3142
|
+
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: s.figureReferenceTarget }),
|
|
3137
3143
|
/* @__PURE__ */ L(
|
|
3138
3144
|
"select",
|
|
3139
3145
|
{
|
|
@@ -3141,8 +3147,8 @@ const Xa = (e = {}) => {
|
|
|
3141
3147
|
onChange: (v) => a(v.target.value === "__none__" ? "" : v.target.value),
|
|
3142
3148
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
|
|
3143
3149
|
children: [
|
|
3144
|
-
/* @__PURE__ */ g("option", { value: "__none__", children:
|
|
3145
|
-
|
|
3150
|
+
/* @__PURE__ */ g("option", { value: "__none__", children: s.figureReferenceTargetPlaceholder }),
|
|
3151
|
+
c.map((v) => /* @__PURE__ */ g("option", { value: v.id, children: v.label }, v.id))
|
|
3146
3152
|
]
|
|
3147
3153
|
}
|
|
3148
3154
|
),
|
|
@@ -3150,47 +3156,47 @@ const Xa = (e = {}) => {
|
|
|
3150
3156
|
"button",
|
|
3151
3157
|
{
|
|
3152
3158
|
onClick: () => {
|
|
3153
|
-
r &&
|
|
3159
|
+
r && o.execCommand("patent.insertFigureReference", {
|
|
3154
3160
|
targetType: "figure",
|
|
3155
3161
|
targetFigureId: r
|
|
3156
3162
|
});
|
|
3157
3163
|
},
|
|
3158
3164
|
className: "p-2 hover:bg-blue-50 text-blue-600 rounded",
|
|
3159
|
-
title:
|
|
3165
|
+
title: s.insertFigureReference,
|
|
3160
3166
|
children: /* @__PURE__ */ g(Bt, { size: 16 })
|
|
3161
3167
|
}
|
|
3162
3168
|
)
|
|
3163
3169
|
] }),
|
|
3164
3170
|
/* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" }),
|
|
3165
3171
|
d && /* @__PURE__ */ L(je, { children: [
|
|
3166
|
-
/* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children:
|
|
3167
|
-
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children:
|
|
3172
|
+
/* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: s.currentFigure }),
|
|
3173
|
+
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: s.figureId }),
|
|
3168
3174
|
/* @__PURE__ */ g(
|
|
3169
3175
|
"input",
|
|
3170
3176
|
{
|
|
3171
|
-
ref:
|
|
3177
|
+
ref: h,
|
|
3172
3178
|
type: "text",
|
|
3173
3179
|
value: f,
|
|
3174
3180
|
onChange: (v) => p(v.target.value),
|
|
3175
|
-
onBlur:
|
|
3181
|
+
onBlur: T,
|
|
3176
3182
|
onKeyDown: (v) => {
|
|
3177
|
-
v.key === "Enter" && (
|
|
3183
|
+
v.key === "Enter" && (T(), v.target.blur());
|
|
3178
3184
|
},
|
|
3179
3185
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white w-20",
|
|
3180
3186
|
placeholder: i === "en" ? "Fig.1" : "图1"
|
|
3181
3187
|
}
|
|
3182
3188
|
),
|
|
3183
|
-
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children:
|
|
3189
|
+
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: s.switchFigureType }),
|
|
3184
3190
|
/* @__PURE__ */ L(
|
|
3185
3191
|
"select",
|
|
3186
3192
|
{
|
|
3187
|
-
value:
|
|
3193
|
+
value: m,
|
|
3188
3194
|
onChange: (v) => x(v.target.value),
|
|
3189
3195
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
|
|
3190
3196
|
children: [
|
|
3191
|
-
/* @__PURE__ */ g("option", { value: "image", children:
|
|
3192
|
-
/* @__PURE__ */ g("option", { value: "mermaid", children:
|
|
3193
|
-
/* @__PURE__ */ g("option", { value: "drawio", children:
|
|
3197
|
+
/* @__PURE__ */ g("option", { value: "image", children: s.figureContentTypeImage }),
|
|
3198
|
+
/* @__PURE__ */ g("option", { value: "mermaid", children: s.figureContentTypeMermaid }),
|
|
3199
|
+
/* @__PURE__ */ g("option", { value: "drawio", children: s.figureContentTypeDrawio })
|
|
3194
3200
|
]
|
|
3195
3201
|
}
|
|
3196
3202
|
),
|
|
@@ -3200,31 +3206,18 @@ const Xa = (e = {}) => {
|
|
|
3200
3206
|
const E = e.getAttributes("image").width || "";
|
|
3201
3207
|
return /* @__PURE__ */ L(je, { children: [
|
|
3202
3208
|
/* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: i === "zh" ? "图片" : "Image" }),
|
|
3203
|
-
["25%", "50%", "75%", "100%"].map((
|
|
3209
|
+
["25%", "50%", "75%", "100%"].map((b) => /* @__PURE__ */ g(
|
|
3204
3210
|
"button",
|
|
3205
3211
|
{
|
|
3206
|
-
onClick: () => e.chain().focus().updateAttributes("image", { width:
|
|
3207
|
-
className: `text-xs px-2 py-0.5 rounded border ${E ===
|
|
3208
|
-
children:
|
|
3212
|
+
onClick: () => e.chain().focus().updateAttributes("image", { width: b }).run(),
|
|
3213
|
+
className: `text-xs px-2 py-0.5 rounded border ${E === b ? "bg-blue-50 text-blue-700 border-blue-200" : "bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,
|
|
3214
|
+
children: b
|
|
3209
3215
|
},
|
|
3210
|
-
|
|
3216
|
+
b
|
|
3211
3217
|
)),
|
|
3212
3218
|
/* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" })
|
|
3213
3219
|
] });
|
|
3214
|
-
})()
|
|
3215
|
-
/* @__PURE__ */ g(
|
|
3216
|
-
"button",
|
|
3217
|
-
{
|
|
3218
|
-
onClick: async () => {
|
|
3219
|
-
if (e.chain().focus().deleteSelection().run()) return;
|
|
3220
|
-
const { from: v } = e.state.selection;
|
|
3221
|
-
v > 1 && e.chain().focus().deleteRange({ from: v - 1, to: v }).run();
|
|
3222
|
-
},
|
|
3223
|
-
className: "p-2 hover:bg-red-50 text-red-600 rounded",
|
|
3224
|
-
title: o.deleteSelection,
|
|
3225
|
-
children: /* @__PURE__ */ g(Br, { size: 16 })
|
|
3226
|
-
}
|
|
3227
|
-
)
|
|
3220
|
+
})()
|
|
3228
3221
|
] }) });
|
|
3229
3222
|
}, sn = {
|
|
3230
3223
|
// Invention & Utility Model
|
|
@@ -3247,7 +3240,7 @@ const Xa = (e = {}) => {
|
|
|
3247
3240
|
function Us(e, t) {
|
|
3248
3241
|
return (sn[e] || []).filter((r) => !t.has(r));
|
|
3249
3242
|
}
|
|
3250
|
-
function
|
|
3243
|
+
function ei(e) {
|
|
3251
3244
|
const t = [];
|
|
3252
3245
|
return e.state.doc.descendants((n, r) => n.type.name === "patent_title" ? (t.push({
|
|
3253
3246
|
sectionType: "patent_title",
|
|
@@ -3278,35 +3271,35 @@ function on(e) {
|
|
|
3278
3271
|
}
|
|
3279
3272
|
return null;
|
|
3280
3273
|
}
|
|
3281
|
-
function
|
|
3274
|
+
function ti(e, t) {
|
|
3282
3275
|
const n = sn[t];
|
|
3283
3276
|
if (!n || n.length === 0) return [];
|
|
3284
|
-
const r =
|
|
3277
|
+
const r = ei(e), a = new Map(r.map((i) => [i.sectionType, i]));
|
|
3285
3278
|
return n.map((i) => {
|
|
3286
|
-
const
|
|
3287
|
-
return !
|
|
3279
|
+
const s = a.get(i);
|
|
3280
|
+
return !s || s.content.trim().length === 0 ? null : {
|
|
3288
3281
|
sectionType: i,
|
|
3289
|
-
content:
|
|
3282
|
+
content: s.content.trim()
|
|
3290
3283
|
};
|
|
3291
3284
|
}).filter((i) => i !== null && i.content.length > 0);
|
|
3292
3285
|
}
|
|
3293
|
-
function
|
|
3294
|
-
const n =
|
|
3295
|
-
let
|
|
3296
|
-
if (!
|
|
3297
|
-
const
|
|
3298
|
-
|
|
3286
|
+
function qs(e, t = {}) {
|
|
3287
|
+
const n = N.getState().editorLanguage, { from: r, to: a } = e.state.selection, i = r !== a ? e.state.doc.textBetween(r, a, " ", "\0") : void 0;
|
|
3288
|
+
let s = t.sectionType, o = t.targetSectionPos;
|
|
3289
|
+
if (!s) {
|
|
3290
|
+
const u = on(e);
|
|
3291
|
+
u && (s = u.sectionType, o = u.pos);
|
|
3299
3292
|
}
|
|
3300
|
-
const
|
|
3293
|
+
const c = t.scope || (s ? "section" : i ? "selection" : "document"), l = s ? ti(e, s) : void 0;
|
|
3301
3294
|
let d;
|
|
3302
|
-
if (
|
|
3303
|
-
const
|
|
3304
|
-
d = `...${p}[SELECTED]${
|
|
3295
|
+
if (c === "selection" && r !== a) {
|
|
3296
|
+
const m = Math.max(0, r - 200), f = Math.min(e.state.doc.content.size, a + 200), p = e.state.doc.textBetween(m, r, " ", "\0"), h = e.state.doc.textBetween(a, f, " ", "\0");
|
|
3297
|
+
d = `...${p}[SELECTED]${h}...`;
|
|
3305
3298
|
}
|
|
3306
3299
|
return {
|
|
3307
|
-
scope:
|
|
3308
|
-
sectionType:
|
|
3309
|
-
targetSectionPos:
|
|
3300
|
+
scope: c,
|
|
3301
|
+
sectionType: s,
|
|
3302
|
+
targetSectionPos: o,
|
|
3310
3303
|
userInput: t.userInput,
|
|
3311
3304
|
selectedText: i,
|
|
3312
3305
|
dependencyContext: l,
|
|
@@ -3314,37 +3307,37 @@ function Ws(e, t = {}) {
|
|
|
3314
3307
|
language: n
|
|
3315
3308
|
};
|
|
3316
3309
|
}
|
|
3317
|
-
const
|
|
3318
|
-
const { addChatReference: n, openChatPanel: r, editorLanguage: a } =
|
|
3310
|
+
const ni = ({ editor: e, onSelectionOptimize: t }) => {
|
|
3311
|
+
const { addChatReference: n, openChatPanel: r, editorLanguage: a } = N(), i = a === "zh", s = (l) => Y(
|
|
3319
3312
|
"p-1.5 rounded transition-colors",
|
|
3320
3313
|
l ? "bg-blue-100 text-blue-600" : "text-gray-600 hover:bg-gray-100"
|
|
3321
|
-
),
|
|
3314
|
+
), o = () => {
|
|
3322
3315
|
const { from: l, to: d } = e.state.selection;
|
|
3323
3316
|
if (l === d) return;
|
|
3324
|
-
const
|
|
3317
|
+
const u = e.state.doc.textBetween(l, d, " "), m = on(e);
|
|
3325
3318
|
if (t) {
|
|
3326
|
-
t({ text:
|
|
3319
|
+
t({ text: u, from: l, to: d, sectionType: m == null ? void 0 : m.sectionType });
|
|
3327
3320
|
return;
|
|
3328
3321
|
}
|
|
3329
|
-
n({ text:
|
|
3330
|
-
},
|
|
3322
|
+
n({ text: u, from: l, to: d, sectionType: m == null ? void 0 : m.sectionType }), r();
|
|
3323
|
+
}, c = () => {
|
|
3331
3324
|
const l = e.getAttributes("link").href, d = window.prompt("URL", l || "https://");
|
|
3332
3325
|
d !== null && (d === "" ? e.chain().focus().extendMarkRange("link").unsetLink().run() : e.chain().focus().extendMarkRange("link").setLink({ href: d }).run());
|
|
3333
3326
|
};
|
|
3334
3327
|
return /* @__PURE__ */ g(
|
|
3335
|
-
|
|
3328
|
+
Jr,
|
|
3336
3329
|
{
|
|
3337
3330
|
editor: e,
|
|
3338
3331
|
shouldShow: ({ editor: l, state: d }) => {
|
|
3339
|
-
const { from:
|
|
3340
|
-
return !(
|
|
3332
|
+
const { from: u, to: m } = d.selection;
|
|
3333
|
+
return !(u === m || l.isActive("codeBlock"));
|
|
3341
3334
|
},
|
|
3342
3335
|
children: /* @__PURE__ */ L("div", { className: "bubble-menu", children: [
|
|
3343
3336
|
/* @__PURE__ */ g(
|
|
3344
3337
|
"button",
|
|
3345
3338
|
{
|
|
3346
3339
|
onClick: () => e.chain().focus().toggleBold().run(),
|
|
3347
|
-
className:
|
|
3340
|
+
className: s(e.isActive("bold")),
|
|
3348
3341
|
title: "Bold",
|
|
3349
3342
|
children: /* @__PURE__ */ g(Dt, { size: 15 })
|
|
3350
3343
|
}
|
|
@@ -3353,7 +3346,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3353
3346
|
"button",
|
|
3354
3347
|
{
|
|
3355
3348
|
onClick: () => e.chain().focus().toggleItalic().run(),
|
|
3356
|
-
className:
|
|
3349
|
+
className: s(e.isActive("italic")),
|
|
3357
3350
|
title: "Italic",
|
|
3358
3351
|
children: /* @__PURE__ */ g(Rt, { size: 15 })
|
|
3359
3352
|
}
|
|
@@ -3362,7 +3355,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3362
3355
|
"button",
|
|
3363
3356
|
{
|
|
3364
3357
|
onClick: () => e.chain().focus().toggleUnderline().run(),
|
|
3365
|
-
className:
|
|
3358
|
+
className: s(e.isActive("underline")),
|
|
3366
3359
|
title: "Underline",
|
|
3367
3360
|
children: /* @__PURE__ */ g(Mt, { size: 15 })
|
|
3368
3361
|
}
|
|
@@ -3371,7 +3364,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3371
3364
|
"button",
|
|
3372
3365
|
{
|
|
3373
3366
|
onClick: () => e.chain().focus().toggleStrike().run(),
|
|
3374
|
-
className:
|
|
3367
|
+
className: s(e.isActive("strike")),
|
|
3375
3368
|
title: "Strikethrough",
|
|
3376
3369
|
children: /* @__PURE__ */ g(Ft, { size: 15 })
|
|
3377
3370
|
}
|
|
@@ -3380,7 +3373,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3380
3373
|
"button",
|
|
3381
3374
|
{
|
|
3382
3375
|
onClick: () => e.chain().focus().toggleCode().run(),
|
|
3383
|
-
className:
|
|
3376
|
+
className: s(e.isActive("code")),
|
|
3384
3377
|
title: "Code",
|
|
3385
3378
|
children: /* @__PURE__ */ g($t, { size: 15 })
|
|
3386
3379
|
}
|
|
@@ -3389,7 +3382,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3389
3382
|
"button",
|
|
3390
3383
|
{
|
|
3391
3384
|
onClick: () => e.chain().focus().toggleSuperscript().run(),
|
|
3392
|
-
className:
|
|
3385
|
+
className: s(e.isActive("superscript")),
|
|
3393
3386
|
title: "Superscript",
|
|
3394
3387
|
children: /* @__PURE__ */ g(zt, { size: 15 })
|
|
3395
3388
|
}
|
|
@@ -3398,7 +3391,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3398
3391
|
"button",
|
|
3399
3392
|
{
|
|
3400
3393
|
onClick: () => e.chain().focus().toggleSubscript().run(),
|
|
3401
|
-
className:
|
|
3394
|
+
className: s(e.isActive("subscript")),
|
|
3402
3395
|
title: "Subscript",
|
|
3403
3396
|
children: /* @__PURE__ */ g(Ot, { size: 15 })
|
|
3404
3397
|
}
|
|
@@ -3408,16 +3401,16 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3408
3401
|
"button",
|
|
3409
3402
|
{
|
|
3410
3403
|
onClick: () => e.chain().focus().toggleHighlight().run(),
|
|
3411
|
-
className:
|
|
3404
|
+
className: s(e.isActive("highlight")),
|
|
3412
3405
|
title: "Highlight",
|
|
3413
|
-
children: /* @__PURE__ */ g(
|
|
3406
|
+
children: /* @__PURE__ */ g(Br, { size: 15 })
|
|
3414
3407
|
}
|
|
3415
3408
|
),
|
|
3416
3409
|
/* @__PURE__ */ g(
|
|
3417
3410
|
"button",
|
|
3418
3411
|
{
|
|
3419
|
-
onClick:
|
|
3420
|
-
className:
|
|
3412
|
+
onClick: c,
|
|
3413
|
+
className: s(e.isActive("link")),
|
|
3421
3414
|
title: "Link",
|
|
3422
3415
|
children: /* @__PURE__ */ g(Ht, { size: 15 })
|
|
3423
3416
|
}
|
|
@@ -3426,46 +3419,46 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3426
3419
|
/* @__PURE__ */ g(
|
|
3427
3420
|
"button",
|
|
3428
3421
|
{
|
|
3429
|
-
onClick:
|
|
3422
|
+
onClick: o,
|
|
3430
3423
|
className: "p-1.5 rounded transition-colors text-purple-500 hover:bg-purple-50",
|
|
3431
3424
|
title: i ? "AI 优化" : "AI Optimize",
|
|
3432
|
-
children: /* @__PURE__ */ g(
|
|
3425
|
+
children: /* @__PURE__ */ g(Hr, { size: 15 })
|
|
3433
3426
|
}
|
|
3434
3427
|
)
|
|
3435
3428
|
] })
|
|
3436
3429
|
}
|
|
3437
3430
|
);
|
|
3438
|
-
},
|
|
3431
|
+
}, ri = ({ editor: e }) => {
|
|
3439
3432
|
var x;
|
|
3440
|
-
const [t, n] =
|
|
3433
|
+
const [t, n] = F(!1), [r, a] = F(!1), [i, s] = F(""), [o, c] = F(""), [l, d] = F(!1), u = W(null), m = e.extensionStorage.searchReplace, f = ((x = m == null ? void 0 : m.results) == null ? void 0 : x.length) ?? 0, p = (m == null ? void 0 : m.currentIndex) ?? -1;
|
|
3441
3434
|
M(() => {
|
|
3442
|
-
const
|
|
3435
|
+
const T = (v) => {
|
|
3443
3436
|
n(!0);
|
|
3444
3437
|
const E = v.detail;
|
|
3445
3438
|
E != null && E.replace && a(!0), requestAnimationFrame(() => {
|
|
3446
|
-
var
|
|
3447
|
-
return (
|
|
3439
|
+
var _;
|
|
3440
|
+
return (_ = u.current) == null ? void 0 : _.focus();
|
|
3448
3441
|
});
|
|
3449
3442
|
};
|
|
3450
|
-
return window.addEventListener("editor:toggleSearch",
|
|
3443
|
+
return window.addEventListener("editor:toggleSearch", T), () => window.removeEventListener("editor:toggleSearch", T);
|
|
3451
3444
|
}, []);
|
|
3452
|
-
const
|
|
3453
|
-
(
|
|
3454
|
-
|
|
3445
|
+
const h = ae(
|
|
3446
|
+
(T) => {
|
|
3447
|
+
s(T), e.commands.setSearchTerm(T);
|
|
3455
3448
|
},
|
|
3456
3449
|
[e]
|
|
3457
|
-
),
|
|
3450
|
+
), y = ae(() => {
|
|
3458
3451
|
n(!1), e.commands.clearSearch(), e.commands.focus();
|
|
3459
3452
|
}, [e]);
|
|
3460
3453
|
M(() => {
|
|
3461
|
-
const
|
|
3462
|
-
v.key === "Escape" && t &&
|
|
3454
|
+
const T = (v) => {
|
|
3455
|
+
v.key === "Escape" && t && y();
|
|
3463
3456
|
};
|
|
3464
|
-
return window.addEventListener("keydown",
|
|
3465
|
-
}, [t,
|
|
3457
|
+
return window.addEventListener("keydown", T), () => window.removeEventListener("keydown", T);
|
|
3458
|
+
}, [t, y]);
|
|
3466
3459
|
const w = () => {
|
|
3467
|
-
const
|
|
3468
|
-
d(
|
|
3460
|
+
const T = !l;
|
|
3461
|
+
d(T), e.commands.setCaseSensitive(T);
|
|
3469
3462
|
};
|
|
3470
3463
|
return t ? /* @__PURE__ */ L("div", { className: "find-replace-bar", children: [
|
|
3471
3464
|
/* @__PURE__ */ L("div", { className: "find-replace-row", children: [
|
|
@@ -3473,12 +3466,12 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3473
3466
|
/* @__PURE__ */ g(
|
|
3474
3467
|
"input",
|
|
3475
3468
|
{
|
|
3476
|
-
ref:
|
|
3469
|
+
ref: u,
|
|
3477
3470
|
type: "text",
|
|
3478
3471
|
value: i,
|
|
3479
|
-
onChange: (
|
|
3480
|
-
onKeyDown: (
|
|
3481
|
-
|
|
3472
|
+
onChange: (T) => h(T.target.value),
|
|
3473
|
+
onKeyDown: (T) => {
|
|
3474
|
+
T.key === "Enter" && (T.shiftKey ? e.commands.previousSearchResult() : e.commands.nextSearchResult());
|
|
3482
3475
|
},
|
|
3483
3476
|
placeholder: "Find...",
|
|
3484
3477
|
className: "find-replace-input"
|
|
@@ -3495,44 +3488,44 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3495
3488
|
children: /* @__PURE__ */ g(Ur, { size: 15 })
|
|
3496
3489
|
}
|
|
3497
3490
|
),
|
|
3498
|
-
/* @__PURE__ */ g("button", { onClick: () => e.commands.previousSearchResult(), className: "find-replace-btn", title: "Previous", children: /* @__PURE__ */ g(
|
|
3499
|
-
/* @__PURE__ */ g("button", { onClick: () => e.commands.nextSearchResult(), className: "find-replace-btn", title: "Next", children: /* @__PURE__ */ g(
|
|
3491
|
+
/* @__PURE__ */ g("button", { onClick: () => e.commands.previousSearchResult(), className: "find-replace-btn", title: "Previous", children: /* @__PURE__ */ g(qr, { size: 15 }) }),
|
|
3492
|
+
/* @__PURE__ */ g("button", { onClick: () => e.commands.nextSearchResult(), className: "find-replace-btn", title: "Next", children: /* @__PURE__ */ g(qt, { size: 15 }) }),
|
|
3500
3493
|
/* @__PURE__ */ g(
|
|
3501
3494
|
"button",
|
|
3502
3495
|
{
|
|
3503
|
-
onClick: () => a((
|
|
3496
|
+
onClick: () => a((T) => !T),
|
|
3504
3497
|
className: Y("find-replace-btn", r && "find-replace-btn--active"),
|
|
3505
3498
|
title: "Toggle Replace",
|
|
3506
3499
|
children: /* @__PURE__ */ g(gt, { size: 15 })
|
|
3507
3500
|
}
|
|
3508
3501
|
),
|
|
3509
|
-
/* @__PURE__ */ g("button", { onClick:
|
|
3502
|
+
/* @__PURE__ */ g("button", { onClick: y, className: "find-replace-btn", title: "Close (Esc)", children: /* @__PURE__ */ g(Wr, { size: 15 }) })
|
|
3510
3503
|
] }),
|
|
3511
3504
|
r && /* @__PURE__ */ L("div", { className: "find-replace-row", children: [
|
|
3512
3505
|
/* @__PURE__ */ g(
|
|
3513
3506
|
"input",
|
|
3514
3507
|
{
|
|
3515
3508
|
type: "text",
|
|
3516
|
-
value:
|
|
3517
|
-
onChange: (
|
|
3518
|
-
|
|
3509
|
+
value: o,
|
|
3510
|
+
onChange: (T) => {
|
|
3511
|
+
c(T.target.value), e.commands.setReplaceTerm(T.target.value);
|
|
3519
3512
|
},
|
|
3520
|
-
onKeyDown: (
|
|
3521
|
-
|
|
3513
|
+
onKeyDown: (T) => {
|
|
3514
|
+
T.key === "Enter" && e.commands.replaceCurrent();
|
|
3522
3515
|
},
|
|
3523
3516
|
placeholder: "Replace...",
|
|
3524
3517
|
className: "find-replace-input"
|
|
3525
3518
|
}
|
|
3526
3519
|
),
|
|
3527
3520
|
/* @__PURE__ */ g("button", { onClick: () => e.commands.replaceCurrent(), className: "find-replace-btn", title: "Replace", children: /* @__PURE__ */ g(gt, { size: 15 }) }),
|
|
3528
|
-
/* @__PURE__ */ g("button", { onClick: () => e.commands.replaceAll(), className: "find-replace-btn", title: "Replace All", children: /* @__PURE__ */ g(
|
|
3521
|
+
/* @__PURE__ */ g("button", { onClick: () => e.commands.replaceAll(), className: "find-replace-btn", title: "Replace All", children: /* @__PURE__ */ g(jr, { size: 15 }) })
|
|
3529
3522
|
] })
|
|
3530
3523
|
] }) : null;
|
|
3531
|
-
},
|
|
3532
|
-
const { editorLanguage: t } =
|
|
3533
|
-
const a = e.state,
|
|
3524
|
+
}, ai = ({ editor: e }) => {
|
|
3525
|
+
const { editorLanguage: t } = N(), n = t === "zh", r = At(() => {
|
|
3526
|
+
const a = e.state, s = a.doc.textBetween(0, a.doc.content.size, " ", "\0").replace(/\s/g, "").length, { from: o, to: c } = a.selection;
|
|
3534
3527
|
let l = 0;
|
|
3535
|
-
return
|
|
3528
|
+
return o !== c && (l = a.doc.textBetween(o, c, " ", "\0").replace(/\s/g, "").length), { charCount: s, selectionCount: l };
|
|
3536
3529
|
}, [e.state.doc, e.state.selection]);
|
|
3537
3530
|
return /* @__PURE__ */ L("div", { className: "word-count-bar", children: [
|
|
3538
3531
|
/* @__PURE__ */ L("span", { children: [
|
|
@@ -3546,73 +3539,73 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3546
3539
|
r.selectionCount
|
|
3547
3540
|
] })
|
|
3548
3541
|
] });
|
|
3549
|
-
},
|
|
3542
|
+
}, ii = {
|
|
3550
3543
|
empty: "○",
|
|
3551
3544
|
filled: "●"
|
|
3552
|
-
},
|
|
3545
|
+
}, si = {
|
|
3553
3546
|
empty: "text-gray-400",
|
|
3554
3547
|
filled: "text-green-500"
|
|
3555
|
-
},
|
|
3548
|
+
}, oi = /* @__PURE__ */ new Set([
|
|
3556
3549
|
"technical_field",
|
|
3557
3550
|
"background_art",
|
|
3558
3551
|
"summary",
|
|
3559
3552
|
"drawing_description",
|
|
3560
3553
|
"detailed_description"
|
|
3561
|
-
]),
|
|
3562
|
-
const { editorLanguage: t } =
|
|
3554
|
+
]), ci = ({ editor: e }) => {
|
|
3555
|
+
const { editorLanguage: t } = N(), n = H(t), [r, a] = F(!1), [i, s] = F(0);
|
|
3563
3556
|
M(() => {
|
|
3564
|
-
const
|
|
3565
|
-
return e.on("update",
|
|
3566
|
-
e.off("update",
|
|
3557
|
+
const c = () => s((l) => l + 1);
|
|
3558
|
+
return e.on("update", c), () => {
|
|
3559
|
+
e.off("update", c);
|
|
3567
3560
|
};
|
|
3568
3561
|
}, [e]);
|
|
3569
|
-
const
|
|
3570
|
-
const
|
|
3562
|
+
const o = At(() => {
|
|
3563
|
+
const c = [];
|
|
3571
3564
|
let l = !1;
|
|
3572
|
-
return e.state.doc.descendants((d,
|
|
3565
|
+
return e.state.doc.descendants((d, u) => {
|
|
3573
3566
|
if (d.type.name === "patent_title") {
|
|
3574
3567
|
if (!l) {
|
|
3575
|
-
const
|
|
3576
|
-
|
|
3568
|
+
const h = typeof n.bookTitle_description == "string" ? n.bookTitle_description : "说明书";
|
|
3569
|
+
c.push({
|
|
3577
3570
|
type: "book-group",
|
|
3578
|
-
pos:
|
|
3579
|
-
title:
|
|
3571
|
+
pos: u,
|
|
3572
|
+
title: h,
|
|
3580
3573
|
charCount: 0
|
|
3581
3574
|
}), l = !0;
|
|
3582
3575
|
}
|
|
3583
|
-
const
|
|
3584
|
-
return
|
|
3576
|
+
const m = d.textContent || "", f = m.trim().length > 0, p = typeof n.patentTitlePlaceholder == "string" ? n.patentTitlePlaceholder : "Patent Title";
|
|
3577
|
+
return c.push({
|
|
3585
3578
|
type: "section",
|
|
3586
|
-
pos:
|
|
3587
|
-
title: f ?
|
|
3579
|
+
pos: u,
|
|
3580
|
+
title: f ? m.trim() : p,
|
|
3588
3581
|
state: f ? "filled" : "empty",
|
|
3589
|
-
charCount:
|
|
3582
|
+
charCount: m.replace(/\s/g, "").length,
|
|
3590
3583
|
indent: !0
|
|
3591
3584
|
}), !1;
|
|
3592
3585
|
}
|
|
3593
3586
|
if (d.type.name === "patent_section") {
|
|
3594
|
-
const
|
|
3595
|
-
return
|
|
3587
|
+
const m = d.attrs.sectionType, f = oi.has(m), p = `sectionTitle_${m}`, h = typeof n[p] == "string" ? n[p] : m, y = d.textContent || "", w = y.trim().length > 0;
|
|
3588
|
+
return c.push({
|
|
3596
3589
|
type: "section",
|
|
3597
|
-
pos:
|
|
3598
|
-
title:
|
|
3590
|
+
pos: u,
|
|
3591
|
+
title: h,
|
|
3599
3592
|
state: w ? "filled" : "empty",
|
|
3600
|
-
charCount:
|
|
3593
|
+
charCount: y.replace(/\s/g, "").length,
|
|
3601
3594
|
indent: f
|
|
3602
3595
|
}), !1;
|
|
3603
3596
|
}
|
|
3604
3597
|
if (d.type.name === "heading") {
|
|
3605
|
-
const
|
|
3606
|
-
return f.trim() &&
|
|
3598
|
+
const m = d.attrs.level, f = d.textContent || "";
|
|
3599
|
+
return f.trim() && c.push({
|
|
3607
3600
|
type: "heading",
|
|
3608
|
-
pos:
|
|
3601
|
+
pos: u,
|
|
3609
3602
|
title: f,
|
|
3610
|
-
level:
|
|
3603
|
+
level: m,
|
|
3611
3604
|
charCount: f.replace(/\s/g, "").length
|
|
3612
3605
|
}), !1;
|
|
3613
3606
|
}
|
|
3614
3607
|
return !0;
|
|
3615
|
-
}),
|
|
3608
|
+
}), c;
|
|
3616
3609
|
}, [e, i, n]);
|
|
3617
3610
|
return r ? /* @__PURE__ */ g("div", { className: "outline-panel outline-panel--collapsed", children: /* @__PURE__ */ g(
|
|
3618
3611
|
"button",
|
|
@@ -3620,11 +3613,11 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3620
3613
|
onClick: () => a(!1),
|
|
3621
3614
|
className: "outline-panel-toggle",
|
|
3622
3615
|
title: t === "zh" ? "展开大纲" : "Expand Outline",
|
|
3623
|
-
children: /* @__PURE__ */ g(
|
|
3616
|
+
children: /* @__PURE__ */ g(Gr, { size: 16 })
|
|
3624
3617
|
}
|
|
3625
3618
|
) }) : /* @__PURE__ */ L("div", { className: "outline-panel", children: [
|
|
3626
3619
|
/* @__PURE__ */ L("div", { className: "outline-panel-header", children: [
|
|
3627
|
-
/* @__PURE__ */ g(
|
|
3620
|
+
/* @__PURE__ */ g(Ut, { size: 14 }),
|
|
3628
3621
|
/* @__PURE__ */ g("span", { children: t === "zh" ? "文档大纲" : "Outline" }),
|
|
3629
3622
|
/* @__PURE__ */ g(
|
|
3630
3623
|
"button",
|
|
@@ -3632,38 +3625,38 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3632
3625
|
onClick: () => a(!0),
|
|
3633
3626
|
className: "outline-panel-toggle ml-auto",
|
|
3634
3627
|
title: t === "zh" ? "收起大纲" : "Collapse Outline",
|
|
3635
|
-
children: /* @__PURE__ */ g(
|
|
3628
|
+
children: /* @__PURE__ */ g(Vr, { size: 14 })
|
|
3636
3629
|
}
|
|
3637
3630
|
)
|
|
3638
3631
|
] }),
|
|
3639
3632
|
/* @__PURE__ */ L("div", { className: "outline-panel-list", children: [
|
|
3640
|
-
|
|
3641
|
-
|
|
3633
|
+
o.length === 0 && /* @__PURE__ */ g("div", { className: "outline-panel-empty", children: t === "zh" ? "暂无章节" : "No sections yet" }),
|
|
3634
|
+
o.map((c, l) => /* @__PURE__ */ L(
|
|
3642
3635
|
"button",
|
|
3643
3636
|
{
|
|
3644
3637
|
className: Y(
|
|
3645
3638
|
"outline-panel-item",
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3639
|
+
c.type === "heading" && `outline-panel-item--h${c.level}`,
|
|
3640
|
+
c.type === "book-group" && "outline-panel-item--book",
|
|
3641
|
+
c.indent && "outline-panel-item--indent"
|
|
3649
3642
|
),
|
|
3650
3643
|
onClick: () => {
|
|
3651
|
-
|
|
3652
|
-
const d = e.view.nodeDOM(
|
|
3644
|
+
c.type !== "book-group" && (e.chain().setTextSelection(c.pos + 1).focus().run(), requestAnimationFrame(() => {
|
|
3645
|
+
const d = e.view.nodeDOM(c.pos);
|
|
3653
3646
|
d == null || d.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
3654
3647
|
}));
|
|
3655
3648
|
},
|
|
3656
3649
|
children: [
|
|
3657
|
-
|
|
3658
|
-
/* @__PURE__ */ g("span", { className: "outline-item-title", children:
|
|
3659
|
-
|
|
3650
|
+
c.type === "section" && c.state && /* @__PURE__ */ g("span", { className: Y("outline-item-state", si[c.state]), children: ii[c.state] || "○" }),
|
|
3651
|
+
/* @__PURE__ */ g("span", { className: "outline-item-title", children: c.title }),
|
|
3652
|
+
c.type !== "book-group" && /* @__PURE__ */ g("span", { className: "outline-item-count", children: c.charCount })
|
|
3660
3653
|
]
|
|
3661
3654
|
},
|
|
3662
|
-
`${
|
|
3655
|
+
`${c.pos}-${l}`
|
|
3663
3656
|
))
|
|
3664
3657
|
] })
|
|
3665
3658
|
] });
|
|
3666
|
-
},
|
|
3659
|
+
}, li = ({
|
|
3667
3660
|
editor: e,
|
|
3668
3661
|
mode: t = "edit",
|
|
3669
3662
|
className: n
|
|
@@ -3679,24 +3672,24 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3679
3672
|
),
|
|
3680
3673
|
children: /* @__PURE__ */ g(In, { editor: e, className: "h-full" })
|
|
3681
3674
|
}
|
|
3682
|
-
)), cn = "patent-editor-draft",
|
|
3675
|
+
)), cn = "patent-editor-draft", di = 1500, ui = () => {
|
|
3683
3676
|
try {
|
|
3684
3677
|
const e = localStorage.getItem(cn);
|
|
3685
3678
|
return e ? JSON.parse(e) : null;
|
|
3686
3679
|
} catch {
|
|
3687
3680
|
return null;
|
|
3688
3681
|
}
|
|
3689
|
-
},
|
|
3682
|
+
}, mi = ({
|
|
3690
3683
|
initialContent: e,
|
|
3691
3684
|
onChange: t,
|
|
3692
3685
|
className: n,
|
|
3693
3686
|
readOnly: r = !1,
|
|
3694
3687
|
editable: a = !0,
|
|
3695
3688
|
onEditorReady: i,
|
|
3696
|
-
onSelectionOptimize:
|
|
3697
|
-
patchEditorId:
|
|
3689
|
+
onSelectionOptimize: s,
|
|
3690
|
+
patchEditorId: o = "default"
|
|
3698
3691
|
}) => {
|
|
3699
|
-
const { setEditor:
|
|
3692
|
+
const { setEditor: c, setDocument: l, editorLanguage: d, autoSaveStatus: u, ai: m } = N(), { setAutoSaveStatus: f, setLastSavedAt: p } = N(), h = W(null), y = e || (t ? null : ui()) || {
|
|
3700
3693
|
type: "doc",
|
|
3701
3694
|
content: [
|
|
3702
3695
|
{
|
|
@@ -3704,27 +3697,27 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3704
3697
|
content: [{ type: "text", text: "" }]
|
|
3705
3698
|
}
|
|
3706
3699
|
]
|
|
3707
|
-
}, w = ae((
|
|
3700
|
+
}, w = ae((_) => {
|
|
3708
3701
|
try {
|
|
3709
|
-
f("saving"), localStorage.setItem(cn, JSON.stringify(
|
|
3702
|
+
f("saving"), localStorage.setItem(cn, JSON.stringify(_)), f("saved"), p(/* @__PURE__ */ new Date());
|
|
3710
3703
|
} catch {
|
|
3711
3704
|
f("error");
|
|
3712
3705
|
}
|
|
3713
3706
|
}, [f, p]), x = Nn(
|
|
3714
|
-
|
|
3715
|
-
extensions: [
|
|
3716
|
-
content:
|
|
3717
|
-
onUpdate: ({ editor:
|
|
3718
|
-
const
|
|
3719
|
-
l(
|
|
3720
|
-
w(
|
|
3721
|
-
},
|
|
3707
|
+
Ka({
|
|
3708
|
+
extensions: [fa.configure({ editorId: o })],
|
|
3709
|
+
content: y,
|
|
3710
|
+
onUpdate: ({ editor: _ }) => {
|
|
3711
|
+
const b = _.getJSON();
|
|
3712
|
+
l(b), B.notifyStateChange(_), t && t(b), t || (h.current && clearTimeout(h.current), h.current = setTimeout(() => {
|
|
3713
|
+
w(b);
|
|
3714
|
+
}, di));
|
|
3722
3715
|
},
|
|
3723
|
-
onCreate: ({ editor:
|
|
3724
|
-
|
|
3716
|
+
onCreate: ({ editor: _ }) => {
|
|
3717
|
+
c(_), i == null || i(_), B.initializePlugins(_), B.notifyStateChange(_);
|
|
3725
3718
|
},
|
|
3726
|
-
onSelectionUpdate: ({ editor:
|
|
3727
|
-
B.notifySelectionChange(
|
|
3719
|
+
onSelectionUpdate: ({ editor: _ }) => {
|
|
3720
|
+
B.notifySelectionChange(_);
|
|
3728
3721
|
},
|
|
3729
3722
|
editorProps: {
|
|
3730
3723
|
attributes: {
|
|
@@ -3732,41 +3725,41 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3732
3725
|
}
|
|
3733
3726
|
}
|
|
3734
3727
|
})
|
|
3735
|
-
),
|
|
3728
|
+
), T = W(!1);
|
|
3736
3729
|
if (M(() => {
|
|
3737
3730
|
if (!(!x || !e)) {
|
|
3738
|
-
if (!
|
|
3739
|
-
|
|
3731
|
+
if (!T.current) {
|
|
3732
|
+
T.current = !0;
|
|
3740
3733
|
return;
|
|
3741
3734
|
}
|
|
3742
3735
|
x.commands.setContent(e);
|
|
3743
3736
|
}
|
|
3744
3737
|
}, [x, e]), M(() => () => {
|
|
3745
|
-
|
|
3738
|
+
h.current && clearTimeout(h.current), x && (B.destroyPlugins(x), x.destroy());
|
|
3746
3739
|
}, [x]), M(() => {
|
|
3747
3740
|
x && B.notifyStateChange(x);
|
|
3748
3741
|
}, [x, d]), !x)
|
|
3749
3742
|
return null;
|
|
3750
|
-
const v = H(d), E =
|
|
3743
|
+
const v = H(d), E = u === "saving" ? v.autoSaveSaving : u === "saved" ? v.autoSaveSaved : u === "error" ? v.autoSaveError : "";
|
|
3751
3744
|
return /* @__PURE__ */ L("div", { className: `editor-container flex flex-col h-full ${n}`, children: [
|
|
3752
3745
|
!r && /* @__PURE__ */ L("div", { className: "flex items-center", children: [
|
|
3753
|
-
/* @__PURE__ */ g(
|
|
3754
|
-
E && /* @__PURE__ */ g("span", { className: `auto-save-indicator auto-save-indicator--${
|
|
3746
|
+
/* @__PURE__ */ g(Za, { editor: x }),
|
|
3747
|
+
E && /* @__PURE__ */ g("span", { className: `auto-save-indicator auto-save-indicator--${u} ml-2`, children: E })
|
|
3755
3748
|
] }),
|
|
3756
|
-
!r && x && /* @__PURE__ */ g(
|
|
3757
|
-
!r && x && /* @__PURE__ */ g(
|
|
3758
|
-
!r && x && /* @__PURE__ */ g(
|
|
3749
|
+
!r && x && /* @__PURE__ */ g(Qa, { editor: x }),
|
|
3750
|
+
!r && x && /* @__PURE__ */ g(ni, { editor: x, onSelectionOptimize: s }),
|
|
3751
|
+
!r && x && /* @__PURE__ */ g(ri, { editor: x }),
|
|
3759
3752
|
/* @__PURE__ */ L("div", { className: "flex flex-1 overflow-hidden", children: [
|
|
3760
|
-
!r && x && /* @__PURE__ */ g(
|
|
3753
|
+
!r && x && /* @__PURE__ */ g(ci, { editor: x }),
|
|
3761
3754
|
/* @__PURE__ */ g("div", { className: "flex-1 overflow-y-auto bg-white p-4 relative", children: /* @__PURE__ */ g(
|
|
3762
|
-
|
|
3755
|
+
li,
|
|
3763
3756
|
{
|
|
3764
3757
|
editor: x,
|
|
3765
|
-
mode: r || !a ||
|
|
3758
|
+
mode: r || !a || m.status === "streaming" && m.activeSectionType === "claims" ? "readonly" : "edit"
|
|
3766
3759
|
}
|
|
3767
3760
|
) })
|
|
3768
3761
|
] }),
|
|
3769
|
-
!r && /* @__PURE__ */ g(
|
|
3762
|
+
!r && /* @__PURE__ */ g(ai, { editor: x })
|
|
3770
3763
|
] });
|
|
3771
3764
|
};
|
|
3772
3765
|
function ln(e) {
|
|
@@ -3776,40 +3769,40 @@ function ln(e) {
|
|
|
3776
3769
|
async pull(a) {
|
|
3777
3770
|
var i;
|
|
3778
3771
|
for (; ; ) {
|
|
3779
|
-
const { done:
|
|
3780
|
-
if (
|
|
3772
|
+
const { done: s, value: o } = await t.read();
|
|
3773
|
+
if (s) {
|
|
3781
3774
|
a.close();
|
|
3782
3775
|
return;
|
|
3783
3776
|
}
|
|
3784
|
-
r += n.decode(
|
|
3785
|
-
const
|
|
3777
|
+
r += n.decode(o, { stream: !0 });
|
|
3778
|
+
const c = r.split(`
|
|
3786
3779
|
`);
|
|
3787
|
-
r =
|
|
3780
|
+
r = c.pop() || "";
|
|
3788
3781
|
let l = "";
|
|
3789
|
-
for (const d of
|
|
3782
|
+
for (const d of c) {
|
|
3790
3783
|
if (d.startsWith("event: ")) {
|
|
3791
3784
|
l = d.slice(7).trim();
|
|
3792
3785
|
continue;
|
|
3793
3786
|
}
|
|
3794
3787
|
if (!d.startsWith("data: ")) continue;
|
|
3795
|
-
const
|
|
3796
|
-
if (
|
|
3788
|
+
const u = d.slice(6).trim();
|
|
3789
|
+
if (u === "[DONE]") {
|
|
3797
3790
|
a.enqueue({ type: "done" }), a.close();
|
|
3798
3791
|
return;
|
|
3799
3792
|
}
|
|
3800
3793
|
try {
|
|
3801
|
-
const
|
|
3802
|
-
if (f === "delta" || !f &&
|
|
3794
|
+
const m = JSON.parse(u), f = l || m.type;
|
|
3795
|
+
if (f === "delta" || !f && m.content != null)
|
|
3803
3796
|
a.enqueue({
|
|
3804
3797
|
type: "delta",
|
|
3805
|
-
content:
|
|
3798
|
+
content: m.content ?? m.text ?? ((i = m.delta) == null ? void 0 : i.content) ?? ""
|
|
3806
3799
|
});
|
|
3807
3800
|
else if (f === "patch")
|
|
3808
|
-
a.enqueue({ type: "patch", patch:
|
|
3801
|
+
a.enqueue({ type: "patch", patch: m });
|
|
3809
3802
|
else if (f === "done") {
|
|
3810
|
-
a.enqueue({ type: "done", usage:
|
|
3803
|
+
a.enqueue({ type: "done", usage: m.usage }), a.close();
|
|
3811
3804
|
return;
|
|
3812
|
-
} else f === "error" && a.enqueue({ type: "error", message:
|
|
3805
|
+
} else f === "error" && a.enqueue({ type: "error", message: m.message || "Unknown error" });
|
|
3813
3806
|
} catch {
|
|
3814
3807
|
}
|
|
3815
3808
|
l = "";
|
|
@@ -3821,7 +3814,7 @@ function ln(e) {
|
|
|
3821
3814
|
}
|
|
3822
3815
|
});
|
|
3823
3816
|
}
|
|
3824
|
-
function
|
|
3817
|
+
function gi(e, t) {
|
|
3825
3818
|
let n = null;
|
|
3826
3819
|
return {
|
|
3827
3820
|
async request(r) {
|
|
@@ -3843,32 +3836,32 @@ function fi(e, t) {
|
|
|
3843
3836
|
}
|
|
3844
3837
|
};
|
|
3845
3838
|
}
|
|
3846
|
-
function
|
|
3839
|
+
function fi(e, t) {
|
|
3847
3840
|
let n = null;
|
|
3848
3841
|
const r = e.replace(/\/+$/, "");
|
|
3849
|
-
async function a(i,
|
|
3850
|
-
const
|
|
3851
|
-
...
|
|
3852
|
-
headers: { "Content-Type": "application/json", ...t, ...
|
|
3842
|
+
async function a(i, s) {
|
|
3843
|
+
const o = await fetch(i, {
|
|
3844
|
+
...s,
|
|
3845
|
+
headers: { "Content-Type": "application/json", ...t, ...s == null ? void 0 : s.headers }
|
|
3853
3846
|
});
|
|
3854
|
-
if (!
|
|
3855
|
-
const
|
|
3856
|
-
return
|
|
3847
|
+
if (!o.ok) throw new Error(`Chat API error: ${o.status} ${o.statusText}`);
|
|
3848
|
+
const c = await o.json();
|
|
3849
|
+
return c.data ?? c;
|
|
3857
3850
|
}
|
|
3858
3851
|
return {
|
|
3859
|
-
async createSession(i,
|
|
3852
|
+
async createSession(i, s, o) {
|
|
3860
3853
|
return a(`${r}/api/v1/chat/sessions`, {
|
|
3861
3854
|
method: "POST",
|
|
3862
|
-
body: JSON.stringify({ patentId: i, title:
|
|
3855
|
+
body: JSON.stringify({ patentId: i, title: s, language: o })
|
|
3863
3856
|
});
|
|
3864
3857
|
},
|
|
3865
|
-
async listSessions(i,
|
|
3866
|
-
const
|
|
3867
|
-
return i &&
|
|
3858
|
+
async listSessions(i, s = 1, o = 20) {
|
|
3859
|
+
const c = new URLSearchParams({ page: String(s), pageSize: String(o) });
|
|
3860
|
+
return i && c.set("patentId", i), a(`${r}/api/v1/chat/sessions?${c}`);
|
|
3868
3861
|
},
|
|
3869
|
-
async getMessages(i,
|
|
3870
|
-
const
|
|
3871
|
-
return a(`${r}/api/v1/chat/sessions/${i}/messages?${
|
|
3862
|
+
async getMessages(i, s = 1, o = 50) {
|
|
3863
|
+
const c = new URLSearchParams({ page: String(s), pageSize: String(o) });
|
|
3864
|
+
return a(`${r}/api/v1/chat/sessions/${i}/messages?${c}`);
|
|
3872
3865
|
},
|
|
3873
3866
|
async deleteSession(i) {
|
|
3874
3867
|
await fetch(`${r}/api/v1/chat/sessions/${i}`, {
|
|
@@ -3876,42 +3869,42 @@ function pi(e, t) {
|
|
|
3876
3869
|
headers: { ...t }
|
|
3877
3870
|
});
|
|
3878
3871
|
},
|
|
3879
|
-
async sendMessage(i,
|
|
3872
|
+
async sendMessage(i, s) {
|
|
3880
3873
|
return a(`${r}/api/v1/chat/sessions/${i}/messages`, {
|
|
3881
3874
|
method: "POST",
|
|
3882
|
-
body: JSON.stringify(
|
|
3875
|
+
body: JSON.stringify(s)
|
|
3883
3876
|
});
|
|
3884
3877
|
},
|
|
3885
|
-
async subscribeStream(i,
|
|
3878
|
+
async subscribeStream(i, s) {
|
|
3886
3879
|
n = new AbortController();
|
|
3887
|
-
const
|
|
3880
|
+
const o = `${r}/api/v1/chat/sessions/${i}/stream?messageId=${s}`, c = await fetch(o, {
|
|
3888
3881
|
headers: { Accept: "text/event-stream", ...t },
|
|
3889
3882
|
signal: n.signal
|
|
3890
3883
|
});
|
|
3891
|
-
if (!
|
|
3892
|
-
if (!
|
|
3893
|
-
return ln(
|
|
3884
|
+
if (!c.ok) throw new Error(`Chat stream error: ${c.status} ${c.statusText}`);
|
|
3885
|
+
if (!c.body) throw new Error("Chat stream returned no body");
|
|
3886
|
+
return ln(c.body);
|
|
3894
3887
|
},
|
|
3895
3888
|
abort() {
|
|
3896
3889
|
n == null || n.abort(), n = null;
|
|
3897
3890
|
}
|
|
3898
3891
|
};
|
|
3899
3892
|
}
|
|
3900
|
-
const
|
|
3901
|
-
({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, editable: i = !0, language:
|
|
3902
|
-
const { setEditorLanguage: p, setAIService:
|
|
3893
|
+
const pi = It(
|
|
3894
|
+
({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, editable: i = !0, language: s, aiService: o, chatSessionAPI: c, aiBaseUrl: l, aiHeaders: d, onSelectionOptimize: u, patchEditorId: m }, f) => {
|
|
3895
|
+
const { setEditorLanguage: p, setAIService: h, setChatSessionAPI: y } = N(), w = W(null), x = ae((v) => {
|
|
3903
3896
|
w.current = v;
|
|
3904
|
-
}, []),
|
|
3897
|
+
}, []), T = Ee.useMemo(() => {
|
|
3905
3898
|
if (e) return e;
|
|
3906
3899
|
if (t) return tn(t);
|
|
3907
3900
|
}, [e, t]);
|
|
3908
3901
|
return Ee.useEffect(() => {
|
|
3909
|
-
|
|
3910
|
-
}, [
|
|
3902
|
+
s && p(s);
|
|
3903
|
+
}, [s, p]), Ee.useEffect(() => {
|
|
3904
|
+
o ? h(o) : l && h(gi(l, d));
|
|
3905
|
+
}, [o, l, d, h]), Ee.useEffect(() => {
|
|
3911
3906
|
c ? y(c) : l && y(fi(l, d));
|
|
3912
|
-
}, [c, l, d, y]),
|
|
3913
|
-
s ? b(s) : l && b(pi(l, d));
|
|
3914
|
-
}, [s, l, d, b]), Nt(f, () => ({
|
|
3907
|
+
}, [c, l, d, y]), Nt(f, () => ({
|
|
3915
3908
|
getContent: () => {
|
|
3916
3909
|
var v;
|
|
3917
3910
|
return ((v = w.current) == null ? void 0 : v.getJSON()) ?? null;
|
|
@@ -3927,42 +3920,42 @@ const hi = It(
|
|
|
3927
3920
|
(v = w.current) == null || v.commands.focus();
|
|
3928
3921
|
}
|
|
3929
3922
|
})), /* @__PURE__ */ g(
|
|
3930
|
-
|
|
3923
|
+
mi,
|
|
3931
3924
|
{
|
|
3932
|
-
initialContent:
|
|
3925
|
+
initialContent: T,
|
|
3933
3926
|
onChange: n,
|
|
3934
3927
|
onEditorReady: x,
|
|
3935
3928
|
className: r,
|
|
3936
3929
|
readOnly: a,
|
|
3937
3930
|
editable: i,
|
|
3938
|
-
onSelectionOptimize:
|
|
3939
|
-
patchEditorId:
|
|
3931
|
+
onSelectionOptimize: u,
|
|
3932
|
+
patchEditorId: m
|
|
3940
3933
|
}
|
|
3941
3934
|
);
|
|
3942
3935
|
}
|
|
3943
3936
|
);
|
|
3944
|
-
|
|
3945
|
-
async function
|
|
3946
|
-
var a, i,
|
|
3937
|
+
pi.displayName = "PatentEditor";
|
|
3938
|
+
async function Ws(e, t, n) {
|
|
3939
|
+
var a, i, s, o;
|
|
3947
3940
|
let r = !1;
|
|
3948
3941
|
(a = n.onStart) == null || a.call(n), n.mode === "section" && typeof n.targetSectionPos == "number" && un(e, n.targetSectionPos);
|
|
3949
3942
|
try {
|
|
3950
|
-
let
|
|
3943
|
+
let c = dn(e, n);
|
|
3951
3944
|
for (; ; ) {
|
|
3952
3945
|
const { done: l, value: d } = await t.read();
|
|
3953
3946
|
if (l) break;
|
|
3954
3947
|
if (!d) continue;
|
|
3955
3948
|
(i = n.onChunk) == null || i.call(n, d);
|
|
3956
|
-
const
|
|
3957
|
-
e.view.dispatch(
|
|
3949
|
+
const u = e.state.tr.insertText(d, c);
|
|
3950
|
+
e.view.dispatch(u), c = u.mapping.map(c, 1);
|
|
3958
3951
|
}
|
|
3959
|
-
n.mode === "section" && typeof n.targetSectionPos == "number" && nt(e, n.targetSectionPos), (
|
|
3960
|
-
} catch (
|
|
3961
|
-
(
|
|
3952
|
+
n.mode === "section" && typeof n.targetSectionPos == "number" && nt(e, n.targetSectionPos), (s = n.onComplete) == null || s.call(n);
|
|
3953
|
+
} catch (c) {
|
|
3954
|
+
(o = n.onError) == null || o.call(n, c instanceof Error ? c : new Error(String(c)));
|
|
3962
3955
|
}
|
|
3963
3956
|
}
|
|
3964
|
-
async function
|
|
3965
|
-
var i, o, c,
|
|
3957
|
+
async function js(e, t, n, r) {
|
|
3958
|
+
var i, s, o, c, l, d, u, m;
|
|
3966
3959
|
const a = new AbortController();
|
|
3967
3960
|
(i = r.onStart) == null || i.call(r), r.mode === "section" && typeof r.targetSectionPos == "number" && un(e, r.targetSectionPos);
|
|
3968
3961
|
try {
|
|
@@ -3974,35 +3967,35 @@ async function Gs(e, t, n, r) {
|
|
|
3974
3967
|
});
|
|
3975
3968
|
if (!f.ok)
|
|
3976
3969
|
throw new Error(`HTTP ${f.status}: ${f.statusText}`);
|
|
3977
|
-
const p = (
|
|
3970
|
+
const p = (s = f.body) == null ? void 0 : s.getReader();
|
|
3978
3971
|
if (!p) throw new Error("No response body");
|
|
3979
|
-
const
|
|
3980
|
-
let
|
|
3972
|
+
const h = new TextDecoder();
|
|
3973
|
+
let y = dn(e, r), w = "";
|
|
3981
3974
|
for (; ; ) {
|
|
3982
|
-
const { done: x, value:
|
|
3975
|
+
const { done: x, value: T } = await p.read();
|
|
3983
3976
|
if (x) break;
|
|
3984
|
-
w +=
|
|
3977
|
+
w += h.decode(T, { stream: !0 });
|
|
3985
3978
|
const v = w.split(`
|
|
3986
3979
|
`);
|
|
3987
3980
|
w = v.pop() || "";
|
|
3988
3981
|
for (const E of v) {
|
|
3989
3982
|
if (!E.startsWith("data: ")) continue;
|
|
3990
|
-
const
|
|
3991
|
-
if (
|
|
3992
|
-
return r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (
|
|
3983
|
+
const _ = E.slice(6).trim();
|
|
3984
|
+
if (_ === "[DONE]")
|
|
3985
|
+
return r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (o = r.onComplete) == null || o.call(r), { abort: () => a.abort() };
|
|
3993
3986
|
try {
|
|
3994
|
-
const
|
|
3995
|
-
if (!
|
|
3996
|
-
(l = r.onChunk) == null || l.call(r,
|
|
3997
|
-
const
|
|
3998
|
-
e.view.dispatch(
|
|
3987
|
+
const b = JSON.parse(_), C = b.content || b.text || ((c = b.delta) == null ? void 0 : c.content) || "";
|
|
3988
|
+
if (!C) continue;
|
|
3989
|
+
(l = r.onChunk) == null || l.call(r, C);
|
|
3990
|
+
const I = e.state.tr.insertText(C, y);
|
|
3991
|
+
e.view.dispatch(I), y = I.mapping.map(y, 1);
|
|
3999
3992
|
} catch {
|
|
4000
3993
|
}
|
|
4001
3994
|
}
|
|
4002
3995
|
}
|
|
4003
3996
|
r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (d = r.onComplete) == null || d.call(r);
|
|
4004
3997
|
} catch (f) {
|
|
4005
|
-
f.name === "AbortError" ? (
|
|
3998
|
+
f.name === "AbortError" ? (u = r.onAbort) == null || u.call(r) : (m = r.onError) == null || m.call(r, f instanceof Error ? f : new Error(String(f)));
|
|
4006
3999
|
}
|
|
4007
4000
|
return { abort: () => a.abort() };
|
|
4008
4001
|
}
|
|
@@ -4019,27 +4012,27 @@ function un(e, t) {
|
|
|
4019
4012
|
if (!n || n.type.name !== "patent_section") return;
|
|
4020
4013
|
const r = t + 1, a = t + n.nodeSize - 1;
|
|
4021
4014
|
if (a > r + 2) {
|
|
4022
|
-
const i = e.state.tr,
|
|
4023
|
-
i.replaceWith(r, a,
|
|
4015
|
+
const i = e.state.tr, s = e.state.schema.nodes.paragraph.create();
|
|
4016
|
+
i.replaceWith(r, a, s), i.setMeta("addToHistory", !1), e.view.dispatch(i);
|
|
4024
4017
|
}
|
|
4025
4018
|
}
|
|
4026
4019
|
function nt(e, t) {
|
|
4027
4020
|
const n = e.state.doc.nodeAt(t);
|
|
4028
4021
|
if (!n || n.type.name !== "patent_section") return;
|
|
4029
4022
|
const r = e.state.tr, a = [];
|
|
4030
|
-
let i = t + 1,
|
|
4031
|
-
n.forEach((
|
|
4032
|
-
|
|
4023
|
+
let i = t + 1, s = 0;
|
|
4024
|
+
n.forEach((c) => {
|
|
4025
|
+
s++;
|
|
4033
4026
|
});
|
|
4034
|
-
let
|
|
4035
|
-
if (n.forEach((
|
|
4036
|
-
|
|
4037
|
-
}), i = t + 1, n.forEach((
|
|
4038
|
-
const l = i, d = i +
|
|
4039
|
-
|
|
4027
|
+
let o = 0;
|
|
4028
|
+
if (n.forEach((c) => {
|
|
4029
|
+
c.type.name === "paragraph" && c.textContent.trim().length > 0 && o++;
|
|
4030
|
+
}), i = t + 1, n.forEach((c) => {
|
|
4031
|
+
const l = i, d = i + c.nodeSize;
|
|
4032
|
+
c.type.name === "paragraph" && c.textContent.trim().length === 0 && (o > 0 || a.length < s - 1) && a.push({ from: l, to: d }), i = d;
|
|
4040
4033
|
}), a.length !== 0) {
|
|
4041
|
-
for (let
|
|
4042
|
-
r.delete(a[
|
|
4034
|
+
for (let c = a.length - 1; c >= 0; c--)
|
|
4035
|
+
r.delete(a[c].from, a[c].to);
|
|
4043
4036
|
r.setMeta("addToHistory", !1), e.view.dispatch(r);
|
|
4044
4037
|
}
|
|
4045
4038
|
}
|
|
@@ -4191,7 +4184,7 @@ function rt(e, t = 30) {
|
|
|
4191
4184
|
}
|
|
4192
4185
|
});
|
|
4193
4186
|
}
|
|
4194
|
-
function
|
|
4187
|
+
function hi(e) {
|
|
4195
4188
|
const t = [], n = $e(e, 3);
|
|
4196
4189
|
for (const r of n)
|
|
4197
4190
|
t.push({ type: "delta", content: r });
|
|
@@ -4203,35 +4196,35 @@ function $e(e, t) {
|
|
|
4203
4196
|
n.push(e.slice(r, r + t));
|
|
4204
4197
|
return n;
|
|
4205
4198
|
}
|
|
4206
|
-
function
|
|
4199
|
+
function yi(e, t, n) {
|
|
4207
4200
|
const r = n === "zh", a = [];
|
|
4208
4201
|
let i;
|
|
4209
4202
|
if (e.includes("技术方案") || e.includes("draft") ? i = Pe["help-draft"][r ? "zh" : "en"] : e.includes("审查") || e.includes("review") || e.includes("Review") ? i = Pe.review[r ? "zh" : "en"] : e.includes("权利要求") || e.includes("claims") || e.includes("Optimize") ? i = Pe.claims[r ? "zh" : "en"] : i = Pe.default[r ? "zh" : "en"], t.length > 0) {
|
|
4210
|
-
const
|
|
4203
|
+
const s = r ? `正在分析引用的 ${t.length} 段文本并生成优化建议...
|
|
4211
4204
|
|
|
4212
4205
|
` : `Analyzing ${t.length} referenced text(s) and generating suggestions...
|
|
4213
4206
|
|
|
4214
4207
|
`;
|
|
4215
|
-
for (const
|
|
4216
|
-
a.push({ type: "delta", content:
|
|
4217
|
-
for (const
|
|
4218
|
-
a.push({ type: "delta", content:
|
|
4219
|
-
for (let
|
|
4220
|
-
const
|
|
4208
|
+
for (const o of $e(s, 4))
|
|
4209
|
+
a.push({ type: "delta", content: o });
|
|
4210
|
+
for (const o of $e(i, 4))
|
|
4211
|
+
a.push({ type: "delta", content: o });
|
|
4212
|
+
for (let o = 0; o < t.length; o++) {
|
|
4213
|
+
const c = t[o], l = c.text;
|
|
4221
4214
|
let d;
|
|
4222
|
-
r ? (d = l.replace(/一种/g, "一种基于本发明的").replace(/方法/g, "技术方案").replace(/包括/g, "具体包括"), d === l && (d = `根据本发明优选实施例,${l}`)) : d = `According to a preferred embodiment, ${l.charAt(0).toLowerCase()}${l.slice(1)}`,
|
|
4215
|
+
r ? (d = l.replace(/一种/g, "一种基于本发明的").replace(/方法/g, "技术方案").replace(/包括/g, "具体包括"), d === l && (d = `根据本发明优选实施例,${l}`)) : d = `According to a preferred embodiment, ${l.charAt(0).toLowerCase()}${l.slice(1)}`, c.from != null && c.to != null ? a.push({
|
|
4223
4216
|
type: "patch",
|
|
4224
4217
|
patch: {
|
|
4225
4218
|
op: "replace",
|
|
4226
|
-
target: { type: "ref", refIndex:
|
|
4219
|
+
target: { type: "ref", refIndex: o },
|
|
4227
4220
|
content: d,
|
|
4228
4221
|
reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
|
|
4229
4222
|
}
|
|
4230
|
-
}) :
|
|
4223
|
+
}) : c.source ? a.push({
|
|
4231
4224
|
type: "patch",
|
|
4232
4225
|
patch: {
|
|
4233
4226
|
op: "replace",
|
|
4234
|
-
target: { type: "section", sectionType:
|
|
4227
|
+
target: { type: "section", sectionType: c.source },
|
|
4235
4228
|
search: l,
|
|
4236
4229
|
content: d,
|
|
4237
4230
|
reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
|
|
@@ -4247,47 +4240,47 @@ function bi(e, t, n) {
|
|
|
4247
4240
|
});
|
|
4248
4241
|
}
|
|
4249
4242
|
} else
|
|
4250
|
-
for (const
|
|
4251
|
-
a.push({ type: "delta", content:
|
|
4243
|
+
for (const s of $e(i, 4))
|
|
4244
|
+
a.push({ type: "delta", content: s });
|
|
4252
4245
|
return a.push({ type: "done", usage: { tokens: i.length * 2 } }), a;
|
|
4253
4246
|
}
|
|
4254
|
-
function
|
|
4247
|
+
function Gs() {
|
|
4255
4248
|
let e = null;
|
|
4256
4249
|
return {
|
|
4257
4250
|
async request(t) {
|
|
4258
|
-
var
|
|
4251
|
+
var o;
|
|
4259
4252
|
if (e = new AbortController(), await te(300), e.signal.aborted)
|
|
4260
4253
|
throw new DOMException("Aborted", "AbortError");
|
|
4261
|
-
const n = t.language === "zh" ? "zh" : "en", r = t.sectionType || "technical_field", a = ((
|
|
4254
|
+
const n = t.language === "zh" ? "zh" : "en", r = t.sectionType || "technical_field", a = ((o = Tt[r]) == null ? void 0 : o[n]) || Tt.technical_field[n];
|
|
4262
4255
|
let i = a;
|
|
4263
4256
|
t.instruction && (i = (n === "zh" ? `[基于指令"${t.instruction}"生成]
|
|
4264
4257
|
|
|
4265
4258
|
` : `[Generated based on instruction "${t.instruction}"]
|
|
4266
4259
|
|
|
4267
4260
|
`) + a);
|
|
4268
|
-
const
|
|
4269
|
-
return rt(
|
|
4261
|
+
const s = hi(i);
|
|
4262
|
+
return rt(s, 25);
|
|
4270
4263
|
},
|
|
4271
4264
|
abort() {
|
|
4272
4265
|
e == null || e.abort(), e = null;
|
|
4273
4266
|
}
|
|
4274
4267
|
};
|
|
4275
4268
|
}
|
|
4276
|
-
function
|
|
4269
|
+
function Vs() {
|
|
4277
4270
|
const e = /* @__PURE__ */ new Map();
|
|
4278
4271
|
let t = null, n = null;
|
|
4279
4272
|
return {
|
|
4280
4273
|
async createSession(r, a, i) {
|
|
4281
4274
|
await te(100);
|
|
4282
|
-
const
|
|
4283
|
-
sessionId:
|
|
4275
|
+
const s = `sess_${Date.now()}`, o = {
|
|
4276
|
+
sessionId: s,
|
|
4284
4277
|
patentId: r || void 0,
|
|
4285
4278
|
title: a || (i === "zh" ? "新对话" : "New Chat"),
|
|
4286
4279
|
messageCount: 0,
|
|
4287
4280
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4288
4281
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4289
4282
|
};
|
|
4290
|
-
return e.set(
|
|
4283
|
+
return e.set(s, { session: o, messages: [] }), o;
|
|
4291
4284
|
},
|
|
4292
4285
|
async listSessions() {
|
|
4293
4286
|
await te(50);
|
|
@@ -4307,21 +4300,21 @@ function Js() {
|
|
|
4307
4300
|
await te(150);
|
|
4308
4301
|
const i = e.get(r);
|
|
4309
4302
|
if (!i) throw new Error("Session not found");
|
|
4310
|
-
const
|
|
4303
|
+
const s = `msg_${Date.now()}`;
|
|
4311
4304
|
i.messages.push({
|
|
4312
|
-
messageId:
|
|
4305
|
+
messageId: s,
|
|
4313
4306
|
role: "user",
|
|
4314
4307
|
content: a.content,
|
|
4315
4308
|
references: a.references,
|
|
4316
4309
|
status: "done",
|
|
4317
4310
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4318
4311
|
}), i.session.messageCount = i.messages.length, i.session.lastMessage = a.content, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
4319
|
-
const
|
|
4312
|
+
const o = yi(
|
|
4320
4313
|
a.content,
|
|
4321
4314
|
a.references || [],
|
|
4322
4315
|
a.language
|
|
4323
4316
|
);
|
|
4324
|
-
return n = { messageId:
|
|
4317
|
+
return n = { messageId: s, events: o }, { messageId: s, sessionId: r, status: "processing" };
|
|
4325
4318
|
},
|
|
4326
4319
|
async subscribeStream(r, a) {
|
|
4327
4320
|
t = new AbortController(), await te(100);
|
|
@@ -4329,26 +4322,26 @@ function Js() {
|
|
|
4329
4322
|
if (!i) throw new Error("Session not found");
|
|
4330
4323
|
if (!n || n.messageId !== a)
|
|
4331
4324
|
return rt([{ type: "done" }]);
|
|
4332
|
-
const
|
|
4325
|
+
const s = n.events;
|
|
4333
4326
|
n = null;
|
|
4334
|
-
const
|
|
4327
|
+
const o = rt(s, 18), c = `${a}_a`;
|
|
4335
4328
|
let l = "";
|
|
4336
|
-
for (const d of
|
|
4329
|
+
for (const d of s)
|
|
4337
4330
|
d.type === "delta" && (l += d.content);
|
|
4338
4331
|
return i.messages.push({
|
|
4339
|
-
messageId:
|
|
4332
|
+
messageId: c,
|
|
4340
4333
|
role: "assistant",
|
|
4341
4334
|
content: l,
|
|
4342
4335
|
status: "done",
|
|
4343
4336
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4344
|
-
}), i.session.messageCount = i.messages.length, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString(),
|
|
4337
|
+
}), i.session.messageCount = i.messages.length, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), o;
|
|
4345
4338
|
},
|
|
4346
4339
|
abort() {
|
|
4347
4340
|
t == null || t.abort(), t = null;
|
|
4348
4341
|
}
|
|
4349
4342
|
};
|
|
4350
4343
|
}
|
|
4351
|
-
function
|
|
4344
|
+
function bi(e) {
|
|
4352
4345
|
const t = [], n = e.replace(/\r\n/g, `
|
|
4353
4346
|
`).trim();
|
|
4354
4347
|
if (!n) return t;
|
|
@@ -4362,118 +4355,118 @@ function vi(e) {
|
|
|
4362
4355
|
});
|
|
4363
4356
|
if (a.length === 0)
|
|
4364
4357
|
return t.push({ number: 1, text: n, dependsOn: [] }), t;
|
|
4365
|
-
for (let
|
|
4366
|
-
const
|
|
4367
|
-
t.push({ number: d, text: l, dependsOn:
|
|
4358
|
+
for (let s = 0; s < a.length; s++) {
|
|
4359
|
+
const o = a[s].index + a[s].matchLength, c = s + 1 < a.length ? a[s + 1].index : n.length, l = n.slice(o, c).trim(), d = a[s].number, u = vi(l, d);
|
|
4360
|
+
t.push({ number: d, text: l, dependsOn: u });
|
|
4368
4361
|
}
|
|
4369
4362
|
return t;
|
|
4370
4363
|
}
|
|
4371
|
-
function
|
|
4364
|
+
function vi(e, t) {
|
|
4372
4365
|
const n = [], r = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g;
|
|
4373
4366
|
let a;
|
|
4374
4367
|
for (; (a = r.exec(e)) !== null; ) {
|
|
4375
|
-
const
|
|
4376
|
-
for (let
|
|
4377
|
-
|
|
4368
|
+
const s = parseInt(a[1], 10), o = a[2] ? parseInt(a[2], 10) : s;
|
|
4369
|
+
for (let c = s; c <= o; c++)
|
|
4370
|
+
c !== t && c > 0 && n.push(c);
|
|
4378
4371
|
}
|
|
4379
4372
|
const i = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
|
|
4380
4373
|
for (; (a = i.exec(e)) !== null; ) {
|
|
4381
|
-
const
|
|
4382
|
-
for (let
|
|
4383
|
-
|
|
4374
|
+
const s = parseInt(a[1], 10), o = a[2] ? parseInt(a[2], 10) : s;
|
|
4375
|
+
for (let c = s; c <= o; c++)
|
|
4376
|
+
c !== t && c > 0 && n.push(c);
|
|
4384
4377
|
}
|
|
4385
|
-
return [...new Set(n)].sort((
|
|
4378
|
+
return [...new Set(n)].sort((s, o) => s - o);
|
|
4386
4379
|
}
|
|
4387
|
-
function
|
|
4388
|
-
return
|
|
4380
|
+
function Js(e) {
|
|
4381
|
+
return bi(e).map((n) => ({
|
|
4389
4382
|
type: "paragraph",
|
|
4390
4383
|
content: n.text ? [{ type: "text", text: `${n.number}. ${n.text}` }] : [{ type: "text", text: `${n.number}. ` }]
|
|
4391
4384
|
}));
|
|
4392
4385
|
}
|
|
4393
|
-
const
|
|
4386
|
+
const wi = -1, xi = 1, Ci = 0, at = new we("docDiff");
|
|
4394
4387
|
let Ye = null;
|
|
4395
|
-
function
|
|
4388
|
+
function Ti() {
|
|
4396
4389
|
return Ye || (Ye = new Pt()), Ye;
|
|
4397
4390
|
}
|
|
4398
|
-
function
|
|
4391
|
+
function Si(e, t, n) {
|
|
4399
4392
|
const r = [];
|
|
4400
4393
|
return e.nodesBetween(t, n, (a, i) => {
|
|
4401
4394
|
if (a.isTextblock) {
|
|
4402
|
-
const
|
|
4403
|
-
return l >
|
|
4395
|
+
const s = i + 1, o = i + a.nodeSize - 1, c = Math.max(s, t), l = Math.min(o, n);
|
|
4396
|
+
return l > c && r.push({ from: c, to: l }), !1;
|
|
4404
4397
|
}
|
|
4405
4398
|
return !0;
|
|
4406
4399
|
}), r;
|
|
4407
4400
|
}
|
|
4408
|
-
function
|
|
4409
|
-
const n = e.state.doc, r = n.content.size, { text: a, segments: i } = Gt(e, 0, r),
|
|
4410
|
-
|
|
4411
|
-
const
|
|
4401
|
+
function Ks(e, t) {
|
|
4402
|
+
const n = e.state.doc, r = n.content.size, { text: a, segments: i } = Gt(e, 0, r), s = Ti(), o = s.diff_main(t, a);
|
|
4403
|
+
s.diff_cleanupSemantic(o);
|
|
4404
|
+
const c = [];
|
|
4412
4405
|
let l = 0;
|
|
4413
|
-
for (const [
|
|
4414
|
-
if (
|
|
4406
|
+
for (const [m, f] of o)
|
|
4407
|
+
if (m === Ci)
|
|
4415
4408
|
l += f.length;
|
|
4416
|
-
else if (
|
|
4409
|
+
else if (m === xi) {
|
|
4417
4410
|
let p = 0;
|
|
4418
4411
|
for (; p < f.length; ) {
|
|
4419
4412
|
for (; p < f.length && f[p] === "\0"; ) p++;
|
|
4420
4413
|
if (p >= f.length) break;
|
|
4421
|
-
const
|
|
4414
|
+
const h = p;
|
|
4422
4415
|
for (; p < f.length && f[p] !== "\0"; ) p++;
|
|
4423
|
-
const
|
|
4424
|
-
if (
|
|
4425
|
-
for (const x of
|
|
4426
|
-
|
|
4416
|
+
const y = ye(i, l + h), w = ye(i, l + p);
|
|
4417
|
+
if (y >= 0 && w >= 0 && w > y)
|
|
4418
|
+
for (const x of Si(n, y, w))
|
|
4419
|
+
c.push(
|
|
4427
4420
|
re.inline(x.from, x.to, { class: "patch-diff-insert-inline" })
|
|
4428
4421
|
);
|
|
4429
4422
|
}
|
|
4430
4423
|
l += f.length;
|
|
4431
|
-
} else if (
|
|
4424
|
+
} else if (m === wi) {
|
|
4432
4425
|
const p = ye(i, l);
|
|
4433
4426
|
if (p >= 0) {
|
|
4434
|
-
const
|
|
4435
|
-
|
|
4427
|
+
const h = f.replace(/\0/g, " ");
|
|
4428
|
+
c.push(
|
|
4436
4429
|
re.widget(
|
|
4437
4430
|
p,
|
|
4438
4431
|
() => {
|
|
4439
|
-
const
|
|
4440
|
-
return
|
|
4432
|
+
const y = document.createElement("span");
|
|
4433
|
+
return y.className = "patch-diff-delete", y.textContent = h, y;
|
|
4441
4434
|
},
|
|
4442
4435
|
{ side: -1 }
|
|
4443
4436
|
)
|
|
4444
4437
|
);
|
|
4445
4438
|
}
|
|
4446
4439
|
}
|
|
4447
|
-
const d = be.create(n,
|
|
4440
|
+
const d = be.create(n, c), u = new Be({
|
|
4448
4441
|
key: at,
|
|
4449
4442
|
state: {
|
|
4450
4443
|
init: () => d,
|
|
4451
|
-
apply: (
|
|
4444
|
+
apply: (m, f) => m.docChanged ? f.map(m.mapping, m.doc) : f
|
|
4452
4445
|
},
|
|
4453
4446
|
props: {
|
|
4454
|
-
decorations(
|
|
4455
|
-
return at.getState(
|
|
4447
|
+
decorations(m) {
|
|
4448
|
+
return at.getState(m);
|
|
4456
4449
|
}
|
|
4457
4450
|
}
|
|
4458
4451
|
});
|
|
4459
|
-
e.registerPlugin(
|
|
4452
|
+
e.registerPlugin(u);
|
|
4460
4453
|
}
|
|
4461
|
-
function
|
|
4454
|
+
function Xs(e) {
|
|
4462
4455
|
e.unregisterPlugin(at);
|
|
4463
4456
|
}
|
|
4464
|
-
const
|
|
4457
|
+
const Ei = /* @__PURE__ */ new Set([
|
|
4465
4458
|
"abstract",
|
|
4466
4459
|
"abstract_drawing",
|
|
4467
4460
|
"claims",
|
|
4468
4461
|
"drawing_figures"
|
|
4469
|
-
]),
|
|
4462
|
+
]), ki = /* @__PURE__ */ new Set([
|
|
4470
4463
|
"technical_field",
|
|
4471
4464
|
"background_art",
|
|
4472
4465
|
"summary",
|
|
4473
4466
|
"drawing_description",
|
|
4474
4467
|
"detailed_description"
|
|
4475
4468
|
]);
|
|
4476
|
-
function
|
|
4469
|
+
function _i(e, t) {
|
|
4477
4470
|
const n = H(t), r = [];
|
|
4478
4471
|
return e.state.doc.descendants((a) => {
|
|
4479
4472
|
if (a.type.name === "patent_title") {
|
|
@@ -4486,76 +4479,76 @@ function Ii(e, t) {
|
|
|
4486
4479
|
}), !1;
|
|
4487
4480
|
}
|
|
4488
4481
|
if (a.type.name === "patent_section") {
|
|
4489
|
-
const i = a.attrs.sectionType,
|
|
4482
|
+
const i = a.attrs.sectionType, s = `sectionTitle_${i}`, o = typeof n[s] == "string" ? n[s] : i, c = [];
|
|
4490
4483
|
return a.forEach((l) => {
|
|
4491
4484
|
const d = l.textContent.trim();
|
|
4492
|
-
d &&
|
|
4493
|
-
}), r.push({ type: "patent_section", sectionType: i, title:
|
|
4485
|
+
d && c.push(d);
|
|
4486
|
+
}), r.push({ type: "patent_section", sectionType: i, title: o, paragraphs: c }), !1;
|
|
4494
4487
|
}
|
|
4495
4488
|
return !0;
|
|
4496
4489
|
}), r;
|
|
4497
4490
|
}
|
|
4498
4491
|
function St(e) {
|
|
4499
4492
|
return new He({
|
|
4500
|
-
children: [new
|
|
4493
|
+
children: [new Ue({ text: e, bold: !0, size: 32, font: "黑体" })],
|
|
4501
4494
|
alignment: it.CENTER,
|
|
4502
4495
|
spacing: { before: 400, after: 200 }
|
|
4503
4496
|
});
|
|
4504
4497
|
}
|
|
4505
4498
|
function Et(e) {
|
|
4506
4499
|
return new He({
|
|
4507
|
-
children: [new
|
|
4500
|
+
children: [new Ue({ text: e, bold: !0, size: 28, font: "黑体" })],
|
|
4508
4501
|
alignment: it.CENTER,
|
|
4509
4502
|
spacing: { before: 240, after: 120 }
|
|
4510
4503
|
});
|
|
4511
4504
|
}
|
|
4512
|
-
function
|
|
4505
|
+
function Ii(e) {
|
|
4513
4506
|
return new He({
|
|
4514
|
-
children: [new
|
|
4507
|
+
children: [new Ue({ text: e, bold: !0, size: 36, font: "宋体" })],
|
|
4515
4508
|
alignment: it.CENTER,
|
|
4516
4509
|
spacing: { before: 200, after: 200 }
|
|
4517
4510
|
});
|
|
4518
4511
|
}
|
|
4519
4512
|
function Ze(e) {
|
|
4520
4513
|
return new He({
|
|
4521
|
-
children: [new
|
|
4514
|
+
children: [new Ue({ text: e, size: 24, font: "宋体" })],
|
|
4522
4515
|
spacing: { line: 360 },
|
|
4523
4516
|
indent: { firstLine: he(7) }
|
|
4524
4517
|
});
|
|
4525
4518
|
}
|
|
4526
|
-
function
|
|
4519
|
+
function Ni(e, t) {
|
|
4527
4520
|
const n = H(t), r = [];
|
|
4528
4521
|
let a = !1;
|
|
4529
4522
|
for (const i of e) {
|
|
4530
|
-
if (
|
|
4523
|
+
if (Ei.has(i.sectionType)) {
|
|
4531
4524
|
r.push(St(i.title));
|
|
4532
|
-
for (const
|
|
4533
|
-
r.push(Ze(
|
|
4525
|
+
for (const s of i.paragraphs)
|
|
4526
|
+
r.push(Ze(s));
|
|
4534
4527
|
continue;
|
|
4535
4528
|
}
|
|
4536
4529
|
if (i.type === "patent_title") {
|
|
4537
4530
|
if (!a) {
|
|
4538
|
-
const
|
|
4539
|
-
r.push(St(
|
|
4531
|
+
const s = typeof n.bookTitle_description == "string" ? n.bookTitle_description : "说明书";
|
|
4532
|
+
r.push(St(s)), a = !0;
|
|
4540
4533
|
}
|
|
4541
|
-
for (const
|
|
4542
|
-
r.push(
|
|
4534
|
+
for (const s of i.paragraphs)
|
|
4535
|
+
r.push(Ii(s));
|
|
4543
4536
|
continue;
|
|
4544
4537
|
}
|
|
4545
|
-
if (
|
|
4538
|
+
if (ki.has(i.sectionType)) {
|
|
4546
4539
|
r.push(Et(i.title));
|
|
4547
|
-
for (const
|
|
4548
|
-
r.push(Ze(
|
|
4540
|
+
for (const s of i.paragraphs)
|
|
4541
|
+
r.push(Ze(s));
|
|
4549
4542
|
continue;
|
|
4550
4543
|
}
|
|
4551
4544
|
r.push(Et(i.title));
|
|
4552
|
-
for (const
|
|
4553
|
-
r.push(Ze(
|
|
4545
|
+
for (const s of i.paragraphs)
|
|
4546
|
+
r.push(Ze(s));
|
|
4554
4547
|
}
|
|
4555
4548
|
return r;
|
|
4556
4549
|
}
|
|
4557
|
-
async function
|
|
4558
|
-
const n =
|
|
4550
|
+
async function Ys(e, t) {
|
|
4551
|
+
const n = _i(e, t), r = Ni(n, t), a = n.find((l) => l.type === "patent_title"), i = a != null && a.paragraphs[0] ? `${a.paragraphs[0]}.docx` : "patent-document.docx", s = {
|
|
4559
4552
|
properties: {
|
|
4560
4553
|
page: {
|
|
4561
4554
|
margin: {
|
|
@@ -4567,77 +4560,77 @@ async function Zs(e, t) {
|
|
|
4567
4560
|
}
|
|
4568
4561
|
},
|
|
4569
4562
|
children: r
|
|
4570
|
-
},
|
|
4571
|
-
sections: [
|
|
4572
|
-
}),
|
|
4573
|
-
|
|
4563
|
+
}, o = new Kr({
|
|
4564
|
+
sections: [s]
|
|
4565
|
+
}), c = await Xr.toBlob(o);
|
|
4566
|
+
Yr(c, i);
|
|
4574
4567
|
}
|
|
4575
|
-
async function
|
|
4568
|
+
async function Zs(e) {
|
|
4576
4569
|
window.print();
|
|
4577
4570
|
}
|
|
4578
|
-
function
|
|
4571
|
+
function Qs(e, t) {
|
|
4579
4572
|
const n = [], r = t === "zh";
|
|
4580
4573
|
let a = 0;
|
|
4581
4574
|
const i = () => `v_${++a}`;
|
|
4582
|
-
return e.state.doc.descendants((
|
|
4583
|
-
if (
|
|
4584
|
-
const
|
|
4585
|
-
if (
|
|
4575
|
+
return e.state.doc.descendants((s, o) => {
|
|
4576
|
+
if (s.type.name === "patent_title") {
|
|
4577
|
+
const c = s.textContent.trim();
|
|
4578
|
+
if (c.length === 0)
|
|
4586
4579
|
n.push({
|
|
4587
4580
|
id: i(),
|
|
4588
4581
|
severity: "warning",
|
|
4589
4582
|
message: r ? "专利名称为空" : "Patent title is empty",
|
|
4590
4583
|
sectionType: "patent_title",
|
|
4591
|
-
pos:
|
|
4584
|
+
pos: o
|
|
4592
4585
|
});
|
|
4593
4586
|
else {
|
|
4594
|
-
const l =
|
|
4587
|
+
const l = c.replace(/\s/g, "").length;
|
|
4595
4588
|
l > 25 && r && n.push({
|
|
4596
4589
|
id: i(),
|
|
4597
4590
|
severity: "error",
|
|
4598
4591
|
message: `专利名称超过25个汉字(当前${l}字)`,
|
|
4599
4592
|
sectionType: "patent_title",
|
|
4600
|
-
pos:
|
|
4593
|
+
pos: o
|
|
4601
4594
|
});
|
|
4602
4595
|
}
|
|
4603
4596
|
return !1;
|
|
4604
4597
|
}
|
|
4605
|
-
if (
|
|
4606
|
-
const
|
|
4598
|
+
if (s.type.name === "patent_section") {
|
|
4599
|
+
const c = s.attrs.sectionType, l = s.textContent.trim();
|
|
4607
4600
|
if (l.length === 0 && n.push({
|
|
4608
4601
|
id: i(),
|
|
4609
4602
|
severity: "warning",
|
|
4610
|
-
message: r ? `章节"${
|
|
4611
|
-
sectionType:
|
|
4612
|
-
pos:
|
|
4613
|
-
}),
|
|
4603
|
+
message: r ? `章节"${c}"内容为空` : `Section "${c}" is empty`,
|
|
4604
|
+
sectionType: c,
|
|
4605
|
+
pos: o
|
|
4606
|
+
}), c === "abstract") {
|
|
4614
4607
|
const d = l.replace(/\s/g, "").length;
|
|
4615
4608
|
d > 0 && d < 50 && n.push({
|
|
4616
4609
|
id: i(),
|
|
4617
4610
|
severity: "warning",
|
|
4618
4611
|
message: r ? `摘要字数过少(${d}字),建议50~300字` : `Abstract too short (${d} chars), recommend 50-300`,
|
|
4619
|
-
sectionType:
|
|
4620
|
-
pos:
|
|
4612
|
+
sectionType: c,
|
|
4613
|
+
pos: o
|
|
4621
4614
|
}), d > 300 && n.push({
|
|
4622
4615
|
id: i(),
|
|
4623
4616
|
severity: "warning",
|
|
4624
4617
|
message: r ? `摘要字数过多(${d}字),建议不超过300字` : `Abstract too long (${d} chars), recommend ≤300`,
|
|
4625
|
-
sectionType:
|
|
4626
|
-
pos:
|
|
4618
|
+
sectionType: c,
|
|
4619
|
+
pos: o
|
|
4627
4620
|
});
|
|
4628
4621
|
}
|
|
4629
|
-
if (
|
|
4622
|
+
if (c === "claims") {
|
|
4630
4623
|
const d = /^(\d+)\s*[.、]/;
|
|
4631
|
-
|
|
4632
|
-
if (
|
|
4633
|
-
const f =
|
|
4624
|
+
s.forEach((u, m) => {
|
|
4625
|
+
if (u.type.name !== "paragraph") return;
|
|
4626
|
+
const f = u.textContent.trim(), p = d.exec(f);
|
|
4634
4627
|
if (!p) return;
|
|
4635
|
-
const
|
|
4628
|
+
const h = p[1];
|
|
4636
4629
|
f.length > 0 && !f.endsWith("。") && !f.endsWith(".") && n.push({
|
|
4637
4630
|
id: i(),
|
|
4638
4631
|
severity: "warning",
|
|
4639
|
-
message: r ? `权利要求${
|
|
4640
|
-
pos:
|
|
4632
|
+
message: r ? `权利要求${h}末尾应以句号结束` : `Claim ${h} should end with a period`,
|
|
4633
|
+
pos: o + 1 + m
|
|
4641
4634
|
});
|
|
4642
4635
|
});
|
|
4643
4636
|
}
|
|
@@ -4646,25 +4639,25 @@ function eo(e, t) {
|
|
|
4646
4639
|
return !0;
|
|
4647
4640
|
}), n;
|
|
4648
4641
|
}
|
|
4649
|
-
const
|
|
4650
|
-
function
|
|
4642
|
+
const Ai = /^(\d+)\s*[.、]\s*/, kt = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g, _t = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
|
|
4643
|
+
function Li(e, t) {
|
|
4651
4644
|
const n = [];
|
|
4652
4645
|
let r;
|
|
4653
4646
|
for (kt.lastIndex = 0; (r = kt.exec(e)) !== null; ) {
|
|
4654
4647
|
const a = parseInt(r[1], 10), i = r[2] ? parseInt(r[2], 10) : a;
|
|
4655
|
-
for (let
|
|
4656
|
-
|
|
4648
|
+
for (let s = a; s <= i; s++)
|
|
4649
|
+
s !== t && s > 0 && n.push(s);
|
|
4657
4650
|
}
|
|
4658
4651
|
for (_t.lastIndex = 0; (r = _t.exec(e)) !== null; ) {
|
|
4659
4652
|
const a = parseInt(r[1], 10), i = r[2] ? parseInt(r[2], 10) : a;
|
|
4660
|
-
for (let
|
|
4661
|
-
|
|
4653
|
+
for (let s = a; s <= i; s++)
|
|
4654
|
+
s !== t && s > 0 && n.push(s);
|
|
4662
4655
|
}
|
|
4663
4656
|
return [...new Set(n)].sort((a, i) => a - i);
|
|
4664
4657
|
}
|
|
4665
4658
|
const mn = (e) => {
|
|
4666
4659
|
if (e.type.name === "reference")
|
|
4667
|
-
return
|
|
4660
|
+
return Pi(e);
|
|
4668
4661
|
if (e.type.name === "hardBreak")
|
|
4669
4662
|
return `
|
|
4670
4663
|
`;
|
|
@@ -4674,7 +4667,7 @@ const mn = (e) => {
|
|
|
4674
4667
|
return e.forEach((n) => {
|
|
4675
4668
|
t += mn(n);
|
|
4676
4669
|
}), t;
|
|
4677
|
-
},
|
|
4670
|
+
}, Pi = (e) => {
|
|
4678
4671
|
const t = e.attrs.lang === "en" ? "en" : "zh", n = e.attrs.targetType === "figure" ? "figure" : "claim", r = typeof e.attrs.displayText == "string" ? e.attrs.displayText.trim() : "";
|
|
4679
4672
|
if (r)
|
|
4680
4673
|
return r;
|
|
@@ -4684,62 +4677,62 @@ const mn = (e) => {
|
|
|
4684
4677
|
}
|
|
4685
4678
|
const a = Number(e.attrs.resolvedNumber);
|
|
4686
4679
|
return Number.isFinite(a) ? t === "en" ? `Claim ${a}` : `权利要求${a}` : t === "en" ? "Claim ?" : "权利要求?";
|
|
4687
|
-
},
|
|
4680
|
+
}, eo = (e) => {
|
|
4688
4681
|
const t = [];
|
|
4689
4682
|
return e.state.doc.descendants((n, r) => {
|
|
4690
4683
|
if (n.type.name === "patent_section")
|
|
4691
4684
|
return n.attrs.sectionType === "claims";
|
|
4692
4685
|
if (n.type.name !== "paragraph") return !0;
|
|
4693
|
-
const a = mn(n).trim(), i =
|
|
4686
|
+
const a = mn(n).trim(), i = Ai.exec(a);
|
|
4694
4687
|
if (!i) return !0;
|
|
4695
|
-
const
|
|
4696
|
-
if (!Number.isFinite(
|
|
4697
|
-
const
|
|
4688
|
+
const s = parseInt(i[1], 10);
|
|
4689
|
+
if (!Number.isFinite(s) || s <= 0) return !0;
|
|
4690
|
+
const o = a.slice(i[0].length).trim(), c = Li(o, s);
|
|
4698
4691
|
return t.push({
|
|
4699
|
-
claimId: `claim_${
|
|
4700
|
-
number:
|
|
4701
|
-
dependsOn:
|
|
4702
|
-
dependsOnClaimIds:
|
|
4703
|
-
body:
|
|
4692
|
+
claimId: `claim_${s}`,
|
|
4693
|
+
number: s,
|
|
4694
|
+
dependsOn: c,
|
|
4695
|
+
dependsOnClaimIds: c.map((l) => `claim_${l}`),
|
|
4696
|
+
body: o,
|
|
4704
4697
|
pos: r
|
|
4705
4698
|
}), !0;
|
|
4706
4699
|
}), t;
|
|
4707
4700
|
};
|
|
4708
4701
|
export {
|
|
4709
|
-
|
|
4702
|
+
mi as EditorView,
|
|
4710
4703
|
jt as PatchDiffPluginKey,
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4704
|
+
pi as PatentEditor,
|
|
4705
|
+
Bs as acceptAllPatches,
|
|
4706
|
+
zs as acceptPatch,
|
|
4707
|
+
Ks as applyDocDiffDecorations,
|
|
4708
|
+
qs as buildAIContext,
|
|
4709
|
+
Js as buildClaimsJSONContent,
|
|
4717
4710
|
tn as buildPatentDocument,
|
|
4718
|
-
|
|
4719
|
-
|
|
4711
|
+
$s as clearPatches,
|
|
4712
|
+
fi as createChatSessionAPI,
|
|
4720
4713
|
ct as createCommandExecutor,
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4714
|
+
Ka as createEditorConfig,
|
|
4715
|
+
Gs as createMockAIService,
|
|
4716
|
+
Vs as createMockChatSessionAPI,
|
|
4717
|
+
gi as createSSEAdapter,
|
|
4718
|
+
Zs as exportToPdf,
|
|
4719
|
+
Ys as exportToWord,
|
|
4720
|
+
eo as extractClaimsFromEditor,
|
|
4728
4721
|
on as findSectionAtCursor,
|
|
4729
|
-
|
|
4722
|
+
ei as getAllSections,
|
|
4730
4723
|
Us as getMissingSectionDeps,
|
|
4731
|
-
|
|
4732
|
-
|
|
4724
|
+
Ms as getPatches,
|
|
4725
|
+
Rs as onPatchChange,
|
|
4733
4726
|
B as pluginManager,
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4727
|
+
Hs as rejectAllPatches,
|
|
4728
|
+
Os as rejectPatch,
|
|
4729
|
+
Xs as removeDocDiffDecorations,
|
|
4730
|
+
Ds as resolvePatchTarget,
|
|
4738
4731
|
sn as sectionContextDeps,
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4732
|
+
Fs as setPatches,
|
|
4733
|
+
N as useEditorStore,
|
|
4734
|
+
Qs as validatePatentDocument,
|
|
4735
|
+
Ws as writeStream,
|
|
4736
|
+
js as writeStreamFromSSE
|
|
4744
4737
|
};
|
|
4745
4738
|
//# sourceMappingURL=lib.js.map
|