patent-editor 0.2.7 → 0.2.9
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.d.ts +4 -0
- package/dist/lib.js +683 -691
- package/dist/lib.js.map +1 -1
- package/package.json +1 -1
package/dist/lib.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Sn = Object.defineProperty;
|
|
2
2
|
var En = (e, t, n) => t in e ? Sn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var Se = (e, t, n) => En(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import { jsx as
|
|
4
|
+
import { jsx as g, jsxs as L, Fragment as je } from "react/jsx-runtime";
|
|
5
5
|
import Ee, { forwardRef as It, useState as $, 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";
|
|
@@ -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 qt, Box as Mr, Workflow as Fr, FunctionSquare as $r, Sigma as zr, GitGraph as Or, Square as mt, ChevronDown as Ut,
|
|
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 qt, Box as Mr, Workflow as Fr, FunctionSquare as $r, Sigma as zr, GitGraph as Or, Square as mt, ChevronDown as Ut, Highlighter as Br, Sparkles as Hr, CaseSensitive as qr, ChevronUp as Ur, 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 qe } 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,
|
|
@@ -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 }),
|
|
@@ -177,26 +177,26 @@ const Qr = new we("slashCommand"), ea = Oe.create({
|
|
|
177
177
|
);
|
|
178
178
|
return Nt(n, () => ({
|
|
179
179
|
onKeyDown: ({ event: o }) => o.key === "ArrowUp" ? (a((c) => (c + e.length - 1) % e.length), !0) : o.key === "ArrowDown" ? (a((c) => (c + 1) % e.length), !0) : o.key === "Enter" ? (i(r), !0) : !1
|
|
180
|
-
})), e.length ? /* @__PURE__ */
|
|
180
|
+
})), e.length ? /* @__PURE__ */ g("div", { className: "slash-menu", children: e.map((o, c) => /* @__PURE__ */ L(
|
|
181
181
|
"button",
|
|
182
182
|
{
|
|
183
183
|
className: `slash-menu-item ${c === r ? "slash-menu-item--active" : ""}`,
|
|
184
184
|
onClick: () => i(c),
|
|
185
185
|
onMouseEnter: () => a(c),
|
|
186
186
|
children: [
|
|
187
|
-
/* @__PURE__ */
|
|
187
|
+
/* @__PURE__ */ g("span", { className: "slash-menu-icon", children: o.icon }),
|
|
188
188
|
/* @__PURE__ */ L("div", { className: "slash-menu-text", children: [
|
|
189
|
-
/* @__PURE__ */
|
|
190
|
-
/* @__PURE__ */
|
|
189
|
+
/* @__PURE__ */ g("span", { className: "slash-menu-title", children: o.title }),
|
|
190
|
+
/* @__PURE__ */ g("span", { className: "slash-menu-desc", children: o.description })
|
|
191
191
|
] })
|
|
192
192
|
]
|
|
193
193
|
},
|
|
194
194
|
o.title
|
|
195
|
-
)) }) : /* @__PURE__ */
|
|
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 = I.getState().editorLanguage, n =
|
|
305
|
+
const t = I.getState().editorLanguage, n = ta(t);
|
|
306
306
|
if (!e) return n;
|
|
307
307
|
const r = e.toLowerCase();
|
|
308
308
|
return n.filter(
|
|
@@ -343,7 +343,7 @@ 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, `
|
|
@@ -352,24 +352,24 @@ function ke(e, t, n) {
|
|
|
352
352
|
for (; c < o.length; ) {
|
|
353
353
|
const s = o.indexOf(i, c);
|
|
354
354
|
if (s === -1) break;
|
|
355
|
-
let l = 0, d = -1,
|
|
355
|
+
let l = 0, d = -1, m = -1;
|
|
356
356
|
e.descendants((u, f) => {
|
|
357
|
-
if (d !== -1 &&
|
|
357
|
+
if (d !== -1 && m !== -1) return !1;
|
|
358
358
|
if (u.isText) {
|
|
359
359
|
const p = u.text || "";
|
|
360
|
-
for (let
|
|
361
|
-
if (l === s && (d = f +
|
|
362
|
-
return
|
|
360
|
+
for (let y = 0; y < p.length; y++) {
|
|
361
|
+
if (l === s && (d = f + y), l === s + i.length)
|
|
362
|
+
return m = f + y, !1;
|
|
363
363
|
l++;
|
|
364
364
|
}
|
|
365
|
-
l === s + i.length &&
|
|
365
|
+
l === s + i.length && m === -1 && (m = f + p.length);
|
|
366
366
|
} else u.isBlock && l > 0 && (l === s && (d = f), l++);
|
|
367
367
|
return !0;
|
|
368
|
-
}), d !== -1 &&
|
|
368
|
+
}), d !== -1 && m !== -1 && r.push({ from: d, to: m }), c = s + 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 {
|
|
@@ -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,13 +458,13 @@ 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
|
}
|
|
@@ -473,8 +473,8 @@ function Gt(e, t, n) {
|
|
|
473
473
|
let a = "", i = !0;
|
|
474
474
|
return e.state.doc.nodesBetween(t, n, (o, c) => {
|
|
475
475
|
if (o.isText) {
|
|
476
|
-
const s = c, l = Math.max(t, s) - s, d = Math.min(n, s + o.nodeSize) - s,
|
|
477
|
-
r.push({ textIdx: a.length, docPos: s + l, len:
|
|
476
|
+
const s = c, l = Math.max(t, s) - s, d = Math.min(n, s + o.nodeSize) - s, m = o.text.slice(l, d);
|
|
477
|
+
r.push({ textIdx: a.length, docPos: s + l, len: m.length }), a += m, i = !1;
|
|
478
478
|
} else o.isLeaf ? (a += "\0", i = !1) : !i && o.isBlock && (a += "\0", i = !0);
|
|
479
479
|
}), { text: a, segments: r };
|
|
480
480
|
}
|
|
@@ -504,7 +504,7 @@ function ht(e, t, n, r, a) {
|
|
|
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
509
|
let o = null;
|
|
510
510
|
const c = /* @__PURE__ */ new Set();
|
|
@@ -514,7 +514,7 @@ function Rs(e, t, n, r, a) {
|
|
|
514
514
|
if (!i)
|
|
515
515
|
t.from != null && t.to != null && (o = { from: t.from, to: t.to });
|
|
516
516
|
else if (i.type === "section" && i.sectionType)
|
|
517
|
-
o =
|
|
517
|
+
o = ca(e, i.sectionType);
|
|
518
518
|
else if (i.type === "ref" && i.refIndex != null) {
|
|
519
519
|
const d = n[i.refIndex];
|
|
520
520
|
(d == null ? void 0 : d.from) != null && (d == null ? void 0 : d.to) != null && (o = { from: d.from, to: d.to });
|
|
@@ -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,16 +547,16 @@ 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
|
|
559
|
+
function zs(e, t, n = "default") {
|
|
560
560
|
const r = j.get(n) || [], a = r.find((c) => c.id === t);
|
|
561
561
|
if (!a || a.status !== "pending") return !1;
|
|
562
562
|
a.status = "accepted";
|
|
@@ -579,11 +579,11 @@ function Os(e, t, n = "default") {
|
|
|
579
579
|
}
|
|
580
580
|
return j.set(n, r.filter((c) => c.id !== t && c.status === "pending")), Ue(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
584
|
return !a || a.status !== "pending" ? !1 : (a.status = "rejected", j.set(n, r.filter((i) => i.id !== t)), Ue(e), ue(), !0);
|
|
585
585
|
}
|
|
586
|
-
function
|
|
586
|
+
function Bs(e, t = "default") {
|
|
587
587
|
const a = [...(j.get(t) || []).filter((o) => o.status === "pending")].sort((o, c) => c.from - o.from), { tr: i } = e.state;
|
|
588
588
|
for (const o of a)
|
|
589
589
|
if (o.type === "delete")
|
|
@@ -597,13 +597,13 @@ function Hs(e, t = "default") {
|
|
|
597
597
|
i.insertText(o.content, o.from, o.to);
|
|
598
598
|
e.view.dispatch(i), j.delete(t), Ue(e), ue();
|
|
599
599
|
}
|
|
600
|
-
function
|
|
600
|
+
function Hs(e, t = "default") {
|
|
601
601
|
j.delete(t), Ue(e), ue();
|
|
602
602
|
}
|
|
603
603
|
function Ue(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) {
|
|
@@ -613,7 +613,7 @@ function da(e, t, n) {
|
|
|
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
619
|
const c = e.resolve(t.from), s = e.resolve(t.to);
|
|
@@ -621,7 +621,7 @@ function ua(e, t) {
|
|
|
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
626
|
const a = r.filter(([c]) => c === pt).reduce((c, [, s]) => c + s.length, 0);
|
|
627
627
|
if (t.originalText.length > 0 && a / t.originalText.length < 0.3) return null;
|
|
@@ -630,7 +630,7 @@ function ua(e, t) {
|
|
|
630
630
|
for (const [c, s] of r)
|
|
631
631
|
if (c === pt)
|
|
632
632
|
o += s.length;
|
|
633
|
-
else if (c ===
|
|
633
|
+
else if (c === ia) {
|
|
634
634
|
const l = o + s.length;
|
|
635
635
|
i.push(
|
|
636
636
|
re.inline(o, l, {
|
|
@@ -638,7 +638,7 @@ function ua(e, t) {
|
|
|
638
638
|
"data-patch-id": t.id
|
|
639
639
|
})
|
|
640
640
|
), o = l;
|
|
641
|
-
} else c ===
|
|
641
|
+
} else c === sa && i.push(
|
|
642
642
|
re.widget(o, () => {
|
|
643
643
|
const l = document.createElement("span");
|
|
644
644
|
return l.className = "patch-diff-insert-inline", l.textContent = s, l.setAttribute("data-patch-id", t.id), l;
|
|
@@ -646,7 +646,7 @@ function ua(e, t) {
|
|
|
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,14 +656,14 @@ 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 =
|
|
666
|
+
const i = la(t.doc, a.from, a.to);
|
|
667
667
|
for (const o of i)
|
|
668
668
|
r.push(
|
|
669
669
|
re.inline(o.from, o.to, {
|
|
@@ -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,16 +741,19 @@ const ga = Z.create({
|
|
|
741
741
|
Xn()
|
|
742
742
|
];
|
|
743
743
|
}
|
|
744
|
-
}),
|
|
744
|
+
}), fa = Oe.create({
|
|
745
745
|
name: "patchDiff",
|
|
746
|
+
addOptions() {
|
|
747
|
+
return { editorId: "default" };
|
|
748
|
+
},
|
|
746
749
|
addProseMirrorPlugins() {
|
|
747
|
-
return [
|
|
750
|
+
return [ua(this.options.editorId)];
|
|
748
751
|
}
|
|
749
|
-
}),
|
|
752
|
+
}), pa = [
|
|
750
753
|
An,
|
|
751
754
|
Ln,
|
|
752
755
|
Pn,
|
|
753
|
-
|
|
756
|
+
ga,
|
|
754
757
|
Dn.configure({
|
|
755
758
|
levels: [1, 2, 3, 4, 5, 6]
|
|
756
759
|
}),
|
|
@@ -759,7 +762,7 @@ const ga = Z.create({
|
|
|
759
762
|
Fn,
|
|
760
763
|
$n,
|
|
761
764
|
zn,
|
|
762
|
-
|
|
765
|
+
ma,
|
|
763
766
|
On,
|
|
764
767
|
Bn,
|
|
765
768
|
Hn.configure({ nested: !0 }),
|
|
@@ -789,16 +792,15 @@ const ga = Z.create({
|
|
|
789
792
|
placeholder: ({ node: e }) => e.type.name === "heading" ? "Heading" : "Type / for commands..."
|
|
790
793
|
}),
|
|
791
794
|
Jn,
|
|
792
|
-
|
|
793
|
-
suggestion:
|
|
795
|
+
Qr.configure({
|
|
796
|
+
suggestion: na()
|
|
794
797
|
}),
|
|
795
|
-
|
|
798
|
+
aa,
|
|
796
799
|
Yn.configure({
|
|
797
800
|
types: ["heading", "paragraph"],
|
|
798
801
|
defaultAlignment: "left"
|
|
799
|
-
})
|
|
800
|
-
|
|
801
|
-
], ya = [
|
|
802
|
+
})
|
|
803
|
+
], ha = [
|
|
802
804
|
nr,
|
|
803
805
|
rr,
|
|
804
806
|
ar,
|
|
@@ -812,11 +814,11 @@ const ga = Z.create({
|
|
|
812
814
|
dr,
|
|
813
815
|
ur,
|
|
814
816
|
mr.configure({ multicolor: !0 })
|
|
815
|
-
],
|
|
816
|
-
...
|
|
817
|
-
...
|
|
817
|
+
], ya = [
|
|
818
|
+
...pa,
|
|
819
|
+
...ha
|
|
818
820
|
];
|
|
819
|
-
class
|
|
821
|
+
class ba {
|
|
820
822
|
constructor() {
|
|
821
823
|
Se(this, "commands", /* @__PURE__ */ new Map());
|
|
822
824
|
}
|
|
@@ -841,7 +843,7 @@ class va {
|
|
|
841
843
|
return !r || !r.isActive ? !1 : r.isActive(n);
|
|
842
844
|
}
|
|
843
845
|
async execute(t, n, r, a = {}) {
|
|
844
|
-
var d,
|
|
846
|
+
var d, m, u, f;
|
|
845
847
|
const i = Date.now(), o = a.transaction ?? !0, c = a.rollbackOnFail ?? !0, s = o ? n.editor.getJSON() : null, l = this.commands.get(t);
|
|
846
848
|
if (!l)
|
|
847
849
|
return console.warn(`Command "${t}" not found.`), (d = a.onComplete) == null || d.call(a, {
|
|
@@ -850,29 +852,29 @@ class va {
|
|
|
850
852
|
durationMs: Date.now() - i
|
|
851
853
|
}), !1;
|
|
852
854
|
if (!this.canExecute(t, n, r))
|
|
853
|
-
return (
|
|
855
|
+
return (m = a.onComplete) == null || m.call(a, {
|
|
854
856
|
name: t,
|
|
855
857
|
success: !1,
|
|
856
858
|
durationMs: Date.now() - i
|
|
857
859
|
}), !1;
|
|
858
860
|
try {
|
|
859
|
-
const
|
|
860
|
-
!
|
|
861
|
-
const
|
|
861
|
+
const y = !!await l.execute(n, r);
|
|
862
|
+
!y && s && c && n.editor.commands.setContent(s);
|
|
863
|
+
const b = {
|
|
862
864
|
name: t,
|
|
863
|
-
success:
|
|
865
|
+
success: y,
|
|
864
866
|
durationMs: Date.now() - i
|
|
865
867
|
};
|
|
866
|
-
return (u = a.onComplete) == null || u.call(a,
|
|
868
|
+
return (u = a.onComplete) == null || u.call(a, b), y;
|
|
867
869
|
} catch (p) {
|
|
868
870
|
s && c && n.editor.commands.setContent(s);
|
|
869
|
-
const
|
|
871
|
+
const y = {
|
|
870
872
|
name: t,
|
|
871
873
|
success: !1,
|
|
872
874
|
durationMs: Date.now() - i,
|
|
873
875
|
error: p
|
|
874
876
|
};
|
|
875
|
-
return (f = a.onComplete) == null || f.call(a,
|
|
877
|
+
return (f = a.onComplete) == null || f.call(a, y), !1;
|
|
876
878
|
}
|
|
877
879
|
}
|
|
878
880
|
getCommand(t) {
|
|
@@ -882,8 +884,8 @@ class va {
|
|
|
882
884
|
return Array.from(this.commands.keys()).sort();
|
|
883
885
|
}
|
|
884
886
|
}
|
|
885
|
-
const le = new
|
|
886
|
-
class
|
|
887
|
+
const le = new ba();
|
|
888
|
+
class va {
|
|
887
889
|
constructor() {
|
|
888
890
|
Se(this, "plugins", /* @__PURE__ */ new Map());
|
|
889
891
|
Se(this, "lifecycleOrder", ["register", "init", "stateSync", "destroy"]);
|
|
@@ -968,7 +970,7 @@ class wa {
|
|
|
968
970
|
});
|
|
969
971
|
}
|
|
970
972
|
}
|
|
971
|
-
const B = new
|
|
973
|
+
const B = new va(), yt = {
|
|
972
974
|
zh: {
|
|
973
975
|
language: "语言",
|
|
974
976
|
bold: "加粗",
|
|
@@ -1221,7 +1223,7 @@ const Ie = () => {
|
|
|
1221
1223
|
document.querySelectorAll('body > svg[id^="standalone-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
|
|
1222
1224
|
(e.id.startsWith("dmermaid") || e.id.startsWith("dstandalone")) && e.remove();
|
|
1223
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());
|
|
1224
|
-
},
|
|
1226
|
+
}, wa = Z.create({
|
|
1225
1227
|
name: "mermaid",
|
|
1226
1228
|
group: "block",
|
|
1227
1229
|
atom: !0,
|
|
@@ -1251,94 +1253,94 @@ const Ie = () => {
|
|
|
1251
1253
|
l.className = "mermaid-edit";
|
|
1252
1254
|
const d = document.createElement("textarea");
|
|
1253
1255
|
d.className = "mermaid-editor-textarea", d.spellcheck = !1;
|
|
1254
|
-
const
|
|
1255
|
-
|
|
1256
|
+
const m = document.createElement("div");
|
|
1257
|
+
m.className = "mermaid-edit-toolbar";
|
|
1256
1258
|
const u = document.createElement("span");
|
|
1257
1259
|
u.className = "mermaid-error-msg";
|
|
1258
1260
|
const f = document.createElement("button");
|
|
1259
1261
|
f.className = "mermaid-cancel-btn", f.type = "button";
|
|
1260
1262
|
const p = document.createElement("button");
|
|
1261
|
-
p.className = "mermaid-save-btn", p.type = "button",
|
|
1262
|
-
const
|
|
1263
|
+
p.className = "mermaid-save-btn", p.type = "button", m.append(u, f, p), l.append(d, m), i.append(o, l);
|
|
1264
|
+
const y = (T) => {
|
|
1263
1265
|
const N = typeof n == "function" ? n() : null;
|
|
1264
|
-
typeof N == "number" && e.commands.command(({ tr: A, dispatch: D }) => (A.setNodeMarkup(N, void 0, { ...r.attrs, ...
|
|
1266
|
+
typeof N == "number" && e.commands.command(({ tr: A, dispatch: D }) => (A.setNodeMarkup(N, void 0, { ...r.attrs, ...T }), D && D(A), !0));
|
|
1265
1267
|
};
|
|
1266
|
-
let
|
|
1267
|
-
const
|
|
1268
|
-
const N =
|
|
1269
|
-
if (N !==
|
|
1268
|
+
let b = "";
|
|
1269
|
+
const w = async (T) => {
|
|
1270
|
+
const N = T.trim();
|
|
1271
|
+
if (N !== b) {
|
|
1270
1272
|
if (!N) {
|
|
1271
|
-
c.innerHTML = "",
|
|
1273
|
+
c.innerHTML = "", b = "";
|
|
1272
1274
|
return;
|
|
1273
1275
|
}
|
|
1274
1276
|
try {
|
|
1275
1277
|
const A = await import("mermaid");
|
|
1276
1278
|
A.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
|
|
1277
1279
|
const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, N);
|
|
1278
|
-
c.innerHTML = z,
|
|
1280
|
+
c.innerHTML = z, b = N;
|
|
1279
1281
|
} catch {
|
|
1280
|
-
c.innerHTML = "",
|
|
1282
|
+
c.innerHTML = "", b = "";
|
|
1281
1283
|
} finally {
|
|
1282
1284
|
Ie();
|
|
1283
1285
|
}
|
|
1284
1286
|
}
|
|
1285
|
-
}, E = () => {
|
|
1286
|
-
a || (a = !0, d.value = typeof r.attrs.code == "string" ? r.attrs.code : "", u.textContent = "", u.style.display = "none", T(), requestAnimationFrame(() => d.focus()));
|
|
1287
1287
|
}, x = () => {
|
|
1288
|
-
a = !
|
|
1289
|
-
},
|
|
1290
|
-
|
|
1288
|
+
a || (a = !0, d.value = typeof r.attrs.code == "string" ? r.attrs.code : "", u.textContent = "", u.style.display = "none", E(), requestAnimationFrame(() => d.focus()));
|
|
1289
|
+
}, C = () => {
|
|
1290
|
+
a = !1, E();
|
|
1291
|
+
}, v = async () => {
|
|
1292
|
+
const T = d.value;
|
|
1291
1293
|
u.textContent = "", u.style.display = "none";
|
|
1292
|
-
const N =
|
|
1294
|
+
const N = T.trim();
|
|
1293
1295
|
if (N)
|
|
1294
1296
|
try {
|
|
1295
1297
|
const A = await import("mermaid");
|
|
1296
1298
|
A.default.initialize({ startOnLoad: !1, theme: "default" }), _e += 1;
|
|
1297
1299
|
const D = `standalone-mermaid-${_e}`, { svg: z } = await A.default.render(D, N);
|
|
1298
|
-
c.innerHTML = z,
|
|
1300
|
+
c.innerHTML = z, b = N, Ie();
|
|
1299
1301
|
} catch {
|
|
1300
1302
|
Ie();
|
|
1301
1303
|
const A = I.getState().editorLanguage;
|
|
1302
1304
|
u.textContent = A === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", u.style.display = "inline";
|
|
1303
1305
|
return;
|
|
1304
1306
|
}
|
|
1305
|
-
|
|
1307
|
+
y({ code: T }), a = !1, E();
|
|
1306
1308
|
};
|
|
1307
|
-
o.addEventListener("dblclick", (
|
|
1308
|
-
|
|
1309
|
-
}), p.addEventListener("click", (
|
|
1310
|
-
|
|
1311
|
-
}), f.addEventListener("click", (
|
|
1312
|
-
|
|
1313
|
-
}), d.addEventListener("mousedown", (
|
|
1314
|
-
const
|
|
1315
|
-
const
|
|
1309
|
+
o.addEventListener("dblclick", (T) => {
|
|
1310
|
+
T.preventDefault(), T.stopPropagation(), x();
|
|
1311
|
+
}), p.addEventListener("click", (T) => {
|
|
1312
|
+
T.stopPropagation(), v();
|
|
1313
|
+
}), f.addEventListener("click", (T) => {
|
|
1314
|
+
T.stopPropagation(), C();
|
|
1315
|
+
}), d.addEventListener("mousedown", (T) => T.stopPropagation()), d.addEventListener("keydown", (T) => T.stopPropagation()), d.addEventListener("keypress", (T) => T.stopPropagation());
|
|
1316
|
+
const E = () => {
|
|
1317
|
+
const T = I.getState().editorLanguage, N = H(T), A = typeof r.attrs.code == "string" ? r.attrs.code : "";
|
|
1316
1318
|
o.style.display = a ? "none" : "block", l.style.display = a ? "block" : "none", p.textContent = N.mermaidSaveAndRender || "保存并渲染", f.textContent = N.mermaidCancel || "取消";
|
|
1317
1319
|
const D = A.trim().length > 0, z = c.querySelector("svg") !== null;
|
|
1318
|
-
a || (D && z ? (s.textContent = N.mermaidDoubleClickToEdit || "双击编辑", s.className = "mermaid-view-hint mermaid-view-hint--subtle") : (s.textContent = N.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", s.className = "mermaid-view-hint mermaid-view-hint--empty")), !a && A.trim() !==
|
|
1320
|
+
a || (D && z ? (s.textContent = N.mermaidDoubleClickToEdit || "双击编辑", s.className = "mermaid-view-hint mermaid-view-hint--subtle") : (s.textContent = N.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", s.className = "mermaid-view-hint mermaid-view-hint--empty")), !a && A.trim() !== b && w(A);
|
|
1319
1321
|
};
|
|
1320
|
-
let
|
|
1321
|
-
const _ = I.subscribe((
|
|
1322
|
-
|
|
1322
|
+
let h = I.getState().editorLanguage;
|
|
1323
|
+
const _ = I.subscribe((T) => {
|
|
1324
|
+
T.editorLanguage !== h && (h = T.editorLanguage, E());
|
|
1323
1325
|
});
|
|
1324
|
-
return
|
|
1326
|
+
return E(), {
|
|
1325
1327
|
dom: i,
|
|
1326
|
-
stopEvent: (
|
|
1327
|
-
const N =
|
|
1328
|
+
stopEvent: (T) => {
|
|
1329
|
+
const N = T.target;
|
|
1328
1330
|
return !!(N === d || l.contains(N));
|
|
1329
1331
|
},
|
|
1330
1332
|
ignoreMutation: () => !0,
|
|
1331
|
-
update: (
|
|
1333
|
+
update: (T) => T.type.name !== "mermaid" ? !1 : (r = T, E(), !0),
|
|
1332
1334
|
destroy: () => {
|
|
1333
1335
|
_(), Ie();
|
|
1334
1336
|
}
|
|
1335
1337
|
};
|
|
1336
1338
|
};
|
|
1337
1339
|
}
|
|
1338
|
-
}),
|
|
1340
|
+
}), xa = {
|
|
1339
1341
|
name: "mermaid",
|
|
1340
1342
|
version: "1.0.0",
|
|
1341
|
-
extensions: [
|
|
1343
|
+
extensions: [wa],
|
|
1342
1344
|
toolbarItems: [
|
|
1343
1345
|
{
|
|
1344
1346
|
id: "mermaid-insert",
|
|
@@ -1363,7 +1365,7 @@ const Ie = () => {
|
|
|
1363
1365
|
}
|
|
1364
1366
|
}
|
|
1365
1367
|
}
|
|
1366
|
-
}, Ve = "https://draw.goatpatent.com",
|
|
1368
|
+
}, Ve = "https://draw.goatpatent.com", Ca = Z.create({
|
|
1367
1369
|
name: "drawio",
|
|
1368
1370
|
group: "block",
|
|
1369
1371
|
atom: !0,
|
|
@@ -1390,28 +1392,28 @@ const Ie = () => {
|
|
|
1390
1392
|
c.className = "drawio-preview-img", c.style.display = "none";
|
|
1391
1393
|
const s = document.createElement("div");
|
|
1392
1394
|
s.className = "drawio-view-hint", o.append(c, s), i.append(o);
|
|
1393
|
-
const l = (
|
|
1394
|
-
const
|
|
1395
|
-
typeof
|
|
1395
|
+
const l = (x) => {
|
|
1396
|
+
const C = typeof n == "function" ? n() : null;
|
|
1397
|
+
typeof C == "number" && e.commands.command(({ tr: v, dispatch: E }) => (v.setNodeMarkup(C, void 0, { ...r.attrs, ...x }), E && E(v), !0));
|
|
1396
1398
|
};
|
|
1397
|
-
let d = null,
|
|
1399
|
+
let d = null, m = null, u = null;
|
|
1398
1400
|
const f = () => {
|
|
1399
1401
|
if (a) return;
|
|
1400
|
-
a = !0,
|
|
1401
|
-
const E = document.createElement("div");
|
|
1402
|
-
E.className = "drawio-modal-content";
|
|
1402
|
+
a = !0, m = document.createElement("div"), m.className = "drawio-modal-overlay";
|
|
1403
1403
|
const x = document.createElement("div");
|
|
1404
|
-
x.className = "drawio-modal-
|
|
1405
|
-
const
|
|
1406
|
-
|
|
1407
|
-
const v = document.createElement("
|
|
1408
|
-
|
|
1409
|
-
const
|
|
1404
|
+
x.className = "drawio-modal-content";
|
|
1405
|
+
const C = document.createElement("div");
|
|
1406
|
+
C.className = "drawio-modal-header";
|
|
1407
|
+
const v = I.getState().editorLanguage, E = document.createElement("span");
|
|
1408
|
+
E.textContent = v === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", E.className = "drawio-modal-title";
|
|
1409
|
+
const h = document.createElement("button");
|
|
1410
|
+
h.className = "drawio-modal-close-btn", h.textContent = "✕", h.type = "button", h.addEventListener("click", () => p()), C.append(E, h), u = document.createElement("iframe"), u.className = "drawio-modal-iframe", u.setAttribute("frameborder", "0"), x.append(C, u), m.appendChild(x), document.body.appendChild(m);
|
|
1411
|
+
const _ = v === "en" ? "en" : "zh";
|
|
1410
1412
|
u.src = `${Ve}/?embed=1&proto=json&spin=1&lang=${_}`;
|
|
1411
|
-
const
|
|
1413
|
+
const T = u;
|
|
1412
1414
|
d = (N) => {
|
|
1413
1415
|
var D, z;
|
|
1414
|
-
if (!
|
|
1416
|
+
if (!T || N.source !== T.contentWindow) return;
|
|
1415
1417
|
let A;
|
|
1416
1418
|
try {
|
|
1417
1419
|
A = typeof N.data == "string" ? JSON.parse(N.data) : N.data;
|
|
@@ -1420,13 +1422,13 @@ const Ie = () => {
|
|
|
1420
1422
|
}
|
|
1421
1423
|
if (A.event === "init") {
|
|
1422
1424
|
const Q = typeof r.attrs.xml == "string" ? r.attrs.xml : "";
|
|
1423
|
-
(D =
|
|
1425
|
+
(D = T.contentWindow) == null || D.postMessage(
|
|
1424
1426
|
JSON.stringify({ action: "load", autosave: 0, xml: Q || "" }),
|
|
1425
1427
|
Ve
|
|
1426
1428
|
);
|
|
1427
1429
|
} else if (A.event === "save") {
|
|
1428
1430
|
const Q = A.xml || "";
|
|
1429
|
-
(z =
|
|
1431
|
+
(z = T.contentWindow) == null || z.postMessage(
|
|
1430
1432
|
JSON.stringify({ action: "export", format: "svg" }),
|
|
1431
1433
|
Ve
|
|
1432
1434
|
), l({ xml: Q });
|
|
@@ -1436,33 +1438,33 @@ const Ie = () => {
|
|
|
1436
1438
|
} else A.event === "exit" && p();
|
|
1437
1439
|
}, window.addEventListener("message", d);
|
|
1438
1440
|
}, p = () => {
|
|
1439
|
-
a = !1, d && (window.removeEventListener("message", d), d = null), u && (u.src = "about:blank", u = null),
|
|
1441
|
+
a = !1, d && (window.removeEventListener("message", d), d = null), u && (u.src = "about:blank", u = null), m && (m.remove(), m = null), y();
|
|
1440
1442
|
};
|
|
1441
|
-
o.addEventListener("dblclick", (
|
|
1442
|
-
|
|
1443
|
+
o.addEventListener("dblclick", (x) => {
|
|
1444
|
+
x.preventDefault(), x.stopPropagation(), f();
|
|
1443
1445
|
});
|
|
1444
|
-
const
|
|
1445
|
-
const
|
|
1446
|
-
|
|
1446
|
+
const y = () => {
|
|
1447
|
+
const x = I.getState().editorLanguage, C = H(x), v = typeof r.attrs.svg == "string" ? r.attrs.svg : "";
|
|
1448
|
+
v ? (c.src = v, c.style.display = "block") : (c.src = "", c.style.display = "none"), v ? (s.textContent = C.mermaidDoubleClickToEdit || "双击编辑", s.className = "drawio-view-hint drawio-view-hint--subtle") : (s.textContent = C.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", s.className = "drawio-view-hint drawio-view-hint--empty");
|
|
1447
1449
|
};
|
|
1448
|
-
let
|
|
1449
|
-
const
|
|
1450
|
-
|
|
1450
|
+
let b = I.getState().editorLanguage;
|
|
1451
|
+
const w = I.subscribe((x) => {
|
|
1452
|
+
x.editorLanguage !== b && (b = x.editorLanguage, y());
|
|
1451
1453
|
});
|
|
1452
|
-
return
|
|
1454
|
+
return y(), {
|
|
1453
1455
|
dom: i,
|
|
1454
1456
|
ignoreMutation: () => !0,
|
|
1455
|
-
update: (
|
|
1457
|
+
update: (x) => x.type.name !== "drawio" ? !1 : (r = x, y(), !0),
|
|
1456
1458
|
destroy: () => {
|
|
1457
|
-
|
|
1459
|
+
w(), d && (window.removeEventListener("message", d), d = null), u && (u.src = "about:blank", u = null), m && (m.remove(), m = null);
|
|
1458
1460
|
}
|
|
1459
1461
|
};
|
|
1460
1462
|
};
|
|
1461
1463
|
}
|
|
1462
|
-
}),
|
|
1464
|
+
}), Ta = {
|
|
1463
1465
|
name: "drawio",
|
|
1464
1466
|
version: "1.0.0",
|
|
1465
|
-
extensions: [
|
|
1467
|
+
extensions: [Ca],
|
|
1466
1468
|
toolbarItems: [
|
|
1467
1469
|
{
|
|
1468
1470
|
id: "drawio-insert",
|
|
@@ -1499,41 +1501,41 @@ const Ie = () => {
|
|
|
1499
1501
|
}, [t]), M(() => {
|
|
1500
1502
|
d.current = e.attrs.latex ?? "";
|
|
1501
1503
|
}, [e.attrs.latex]);
|
|
1502
|
-
const
|
|
1504
|
+
const m = ae(() => {
|
|
1503
1505
|
s.current || (s.current = !0, o(!0));
|
|
1504
1506
|
}, []), u = ae(() => {
|
|
1505
|
-
var
|
|
1507
|
+
var y, b;
|
|
1506
1508
|
if (!s.current) return;
|
|
1507
1509
|
s.current = !1;
|
|
1508
|
-
const p = ((
|
|
1509
|
-
l.current({ latex: p }), o(!1), (
|
|
1510
|
+
const p = ((y = a.current) == null ? void 0 : y.value) ?? d.current;
|
|
1511
|
+
l.current({ latex: p }), o(!1), (b = globalThis.mathVirtualKeyboard) == null || b.hide({ animate: !0 });
|
|
1510
1512
|
}, []);
|
|
1511
1513
|
M(() => {
|
|
1512
|
-
var
|
|
1513
|
-
const p = !!((
|
|
1514
|
-
n && p &&
|
|
1515
|
-
}, [n,
|
|
1514
|
+
var y, b, w;
|
|
1515
|
+
const p = !!((w = (b = (y = r == null ? void 0 : r.view) == null ? void 0 : y.state) == null ? void 0 : b.selection) != null && w.empty);
|
|
1516
|
+
n && p && m();
|
|
1517
|
+
}, [n, m]), M(() => {
|
|
1516
1518
|
i && requestAnimationFrame(() => {
|
|
1517
|
-
var
|
|
1519
|
+
var y;
|
|
1518
1520
|
const p = a.current;
|
|
1519
|
-
p && (p.virtualKeyboardMode = "onfocus", (
|
|
1521
|
+
p && (p.virtualKeyboardMode = "onfocus", (y = p.focus) == null || y.call(p));
|
|
1520
1522
|
});
|
|
1521
1523
|
}, [i]), M(() => {
|
|
1522
1524
|
if (!i) return;
|
|
1523
1525
|
const p = a.current;
|
|
1524
1526
|
if (!p) return;
|
|
1525
|
-
const
|
|
1527
|
+
const y = () => {
|
|
1526
1528
|
setTimeout(() => {
|
|
1527
|
-
var
|
|
1529
|
+
var x, C, v;
|
|
1528
1530
|
if (!s.current) return;
|
|
1529
|
-
const
|
|
1530
|
-
(
|
|
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") || (C = w == null ? void 0 : w.closest) != null && C.call(w, ".ML__keyboard") || (v = document.querySelector(".ML__keyboard")) != null && v.contains(w) || u();
|
|
1531
1533
|
}, 300);
|
|
1532
|
-
},
|
|
1533
|
-
|
|
1534
|
+
}, b = (w) => {
|
|
1535
|
+
w.key === "Escape" && u();
|
|
1534
1536
|
};
|
|
1535
|
-
return p.addEventListener("focusout",
|
|
1536
|
-
p.removeEventListener("focusout",
|
|
1537
|
+
return p.addEventListener("focusout", y), p.addEventListener("keydown", b), () => {
|
|
1538
|
+
p.removeEventListener("focusout", y), p.removeEventListener("keydown", b);
|
|
1537
1539
|
};
|
|
1538
1540
|
}, [i, u]), M(() => {
|
|
1539
1541
|
!i && a.current && a.current.value !== e.attrs.latex && (a.current.value = e.attrs.latex ?? "");
|
|
@@ -1547,25 +1549,25 @@ const Ie = () => {
|
|
|
1547
1549
|
} catch {
|
|
1548
1550
|
f = e.attrs.latex || "";
|
|
1549
1551
|
}
|
|
1550
|
-
return /* @__PURE__ */
|
|
1552
|
+
return /* @__PURE__ */ g(
|
|
1551
1553
|
_n,
|
|
1552
1554
|
{
|
|
1553
1555
|
as: c ? "div" : "span",
|
|
1554
1556
|
className: c ? "math-block" : "math-inline",
|
|
1555
|
-
children: i ? /* @__PURE__ */
|
|
1557
|
+
children: i ? /* @__PURE__ */ g(
|
|
1556
1558
|
"math-field",
|
|
1557
1559
|
{
|
|
1558
1560
|
ref: a,
|
|
1559
1561
|
className: c ? "math-live-field math-live-field--block" : "math-live-field",
|
|
1560
1562
|
children: e.attrs.latex
|
|
1561
1563
|
}
|
|
1562
|
-
) : /* @__PURE__ */ L("span", { className: "math-preview", onClick:
|
|
1563
|
-
/* @__PURE__ */
|
|
1564
|
-
/* @__PURE__ */
|
|
1564
|
+
) : /* @__PURE__ */ L("span", { className: "math-preview", onClick: m, children: [
|
|
1565
|
+
/* @__PURE__ */ g("span", { dangerouslySetInnerHTML: { __html: f } }),
|
|
1566
|
+
/* @__PURE__ */ g("span", { className: "math-tooltip", children: "点击编辑" })
|
|
1565
1567
|
] })
|
|
1566
1568
|
}
|
|
1567
1569
|
);
|
|
1568
|
-
},
|
|
1570
|
+
}, Sa = Z.create({
|
|
1569
1571
|
name: "math_inline",
|
|
1570
1572
|
group: "inline",
|
|
1571
1573
|
inline: !0,
|
|
@@ -1598,7 +1600,7 @@ const Ie = () => {
|
|
|
1598
1600
|
}
|
|
1599
1601
|
});
|
|
1600
1602
|
}
|
|
1601
|
-
}),
|
|
1603
|
+
}), Ea = Z.create({
|
|
1602
1604
|
name: "math_block",
|
|
1603
1605
|
group: "block",
|
|
1604
1606
|
atom: !0,
|
|
@@ -1621,10 +1623,10 @@ const Ie = () => {
|
|
|
1621
1623
|
}
|
|
1622
1624
|
});
|
|
1623
1625
|
}
|
|
1624
|
-
}),
|
|
1626
|
+
}), ka = {
|
|
1625
1627
|
name: "math",
|
|
1626
1628
|
version: "1.0.0",
|
|
1627
|
-
extensions: [
|
|
1629
|
+
extensions: [Sa, Ea],
|
|
1628
1630
|
toolbarItems: [
|
|
1629
1631
|
{
|
|
1630
1632
|
id: "math-inline-insert",
|
|
@@ -1687,7 +1689,7 @@ const Ie = () => {
|
|
|
1687
1689
|
};
|
|
1688
1690
|
}
|
|
1689
1691
|
return null;
|
|
1690
|
-
},
|
|
1692
|
+
}, _a = (e) => {
|
|
1691
1693
|
const { $from: t } = e.state.selection;
|
|
1692
1694
|
for (let n = t.depth; n >= 0; n -= 1) {
|
|
1693
1695
|
const r = t.node(n);
|
|
@@ -1698,7 +1700,7 @@ const Ie = () => {
|
|
|
1698
1700
|
};
|
|
1699
1701
|
}
|
|
1700
1702
|
return null;
|
|
1701
|
-
},
|
|
1703
|
+
}, Ia = (e, t) => e.state.schema.nodes[t] || null, Na = (e) => {
|
|
1702
1704
|
const t = Array.isArray(e.content) ? e.content : e.content ? [e.content] : void 0;
|
|
1703
1705
|
return {
|
|
1704
1706
|
type: e.type,
|
|
@@ -1706,7 +1708,7 @@ const Ie = () => {
|
|
|
1706
1708
|
content: t
|
|
1707
1709
|
};
|
|
1708
1710
|
}, Yt = (e, t) => {
|
|
1709
|
-
const n =
|
|
1711
|
+
const n = Na(t);
|
|
1710
1712
|
return typeof t.position == "number" ? e.chain().focus().insertContentAt(t.position, n).run() : e.chain().focus().insertContent(n).run();
|
|
1711
1713
|
}, ze = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
|
|
1712
1714
|
var s;
|
|
@@ -1726,7 +1728,7 @@ const Ie = () => {
|
|
|
1726
1728
|
const o = r.doc.nodeAt(i);
|
|
1727
1729
|
return !o || t.type && o.type.name !== t.type ? !1 : (n.delete(i, i + o.nodeSize), a && a(n), !0);
|
|
1728
1730
|
}), Qt = (e, t) => {
|
|
1729
|
-
const n =
|
|
1731
|
+
const n = Ia(e, t.type);
|
|
1730
1732
|
return n ? e.commands.command(({ tr: r, state: a, dispatch: i }) => {
|
|
1731
1733
|
const { from: o, to: c } = a.selection, s = a.selection.$from.blockRange(a.selection.$to);
|
|
1732
1734
|
if (!s)
|
|
@@ -1734,7 +1736,7 @@ const Ie = () => {
|
|
|
1734
1736
|
const l = fr(s, n, t.attrs);
|
|
1735
1737
|
return l ? (r.wrap(s, l), i && i(r.scrollIntoView()), o <= c) : !1;
|
|
1736
1738
|
}) : !1;
|
|
1737
|
-
},
|
|
1739
|
+
}, Aa = (e, t) => {
|
|
1738
1740
|
if (t.length === 0)
|
|
1739
1741
|
return !1;
|
|
1740
1742
|
const n = e.getJSON();
|
|
@@ -1746,13 +1748,13 @@ const Ie = () => {
|
|
|
1746
1748
|
let Ne = 0;
|
|
1747
1749
|
const Qe = [];
|
|
1748
1750
|
let Ae = !1;
|
|
1749
|
-
const
|
|
1751
|
+
const La = 2e4, bt = 6e4;
|
|
1750
1752
|
let F = null, Me = !1, ne = null, pe = null;
|
|
1751
1753
|
const et = /* @__PURE__ */ new Map();
|
|
1752
1754
|
function vt() {
|
|
1753
1755
|
ne && (window.removeEventListener("message", ne), ne = null), F && (F.src = "about:blank", F.remove(), F = null), Me = !1;
|
|
1754
1756
|
}
|
|
1755
|
-
function
|
|
1757
|
+
function Pa(e, t) {
|
|
1756
1758
|
const n = et.get(e);
|
|
1757
1759
|
if (n) {
|
|
1758
1760
|
t(n);
|
|
@@ -1794,13 +1796,13 @@ function tt() {
|
|
|
1794
1796
|
de
|
|
1795
1797
|
);
|
|
1796
1798
|
}, 1500) : c.event === "export" && a(c.data || "");
|
|
1797
|
-
}, window.addEventListener("message", ne), r = setTimeout(() => a(""),
|
|
1799
|
+
}, window.addEventListener("message", ne), r = setTimeout(() => a(""), La), F ? Me && i() : (F = document.createElement("iframe"), F.style.cssText = "position:fixed;left:-9999px;top:-9999px;width:1920px;height:1080px;opacity:0;pointer-events:none;", document.body.appendChild(F), Me = !1, F.src = `${de}/?embed=1&proto=json&spin=0&chrome=0`);
|
|
1798
1800
|
}
|
|
1799
1801
|
const Le = () => {
|
|
1800
1802
|
document.querySelectorAll('body > svg[id^="fig-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
|
|
1801
1803
|
(e.id.startsWith("dmermaid") || e.id.startsWith("dfi")) && e.remove();
|
|
1802
1804
|
}), document.querySelectorAll("body > #dmermaid-svg").forEach((e) => e.remove()), document.querySelectorAll("body > style[data-mermaid-style]").forEach((e) => e.remove());
|
|
1803
|
-
},
|
|
1805
|
+
}, Da = Z.create({
|
|
1804
1806
|
name: "figure",
|
|
1805
1807
|
group: "block",
|
|
1806
1808
|
content: "inline*",
|
|
@@ -1839,34 +1841,34 @@ const Le = () => {
|
|
|
1839
1841
|
l.className = "figure-upload-area";
|
|
1840
1842
|
const d = document.createElement("span");
|
|
1841
1843
|
d.className = "figure-upload-hint";
|
|
1842
|
-
const
|
|
1843
|
-
|
|
1844
|
+
const m = document.createElement("input");
|
|
1845
|
+
m.type = "file", m.accept = "image/*", m.style.display = "none";
|
|
1844
1846
|
const u = document.createElement("button");
|
|
1845
|
-
u.className = "figure-replace-btn", l.append(d,
|
|
1847
|
+
u.className = "figure-replace-btn", l.append(d, m);
|
|
1846
1848
|
const f = document.createElement("div");
|
|
1847
1849
|
f.className = "figure-mermaid-view", f.contentEditable = "false", f.setAttribute("spellcheck", "false");
|
|
1848
1850
|
const p = document.createElement("div");
|
|
1849
1851
|
p.className = "figure-mermaid-preview", p.contentEditable = "false";
|
|
1852
|
+
const y = document.createElement("div");
|
|
1853
|
+
y.className = "figure-mermaid-view-hint", f.append(p, y);
|
|
1850
1854
|
const b = document.createElement("div");
|
|
1851
|
-
b.className = "figure-mermaid-
|
|
1855
|
+
b.className = "figure-mermaid-edit";
|
|
1856
|
+
const w = document.createElement("textarea");
|
|
1857
|
+
w.className = "figure-mermaid-editor", w.spellcheck = !1;
|
|
1858
|
+
const x = document.createElement("div");
|
|
1859
|
+
x.className = "figure-mermaid-toolbar";
|
|
1860
|
+
const C = document.createElement("button");
|
|
1861
|
+
C.className = "figure-mermaid-save-btn", C.type = "button";
|
|
1862
|
+
const v = document.createElement("button");
|
|
1863
|
+
v.className = "figure-mermaid-cancel-btn", v.type = "button";
|
|
1864
|
+
const E = document.createElement("span");
|
|
1865
|
+
E.className = "figure-mermaid-error-inline", x.append(E, v, C), b.append(w, x);
|
|
1852
1866
|
const h = document.createElement("div");
|
|
1853
|
-
h.className = "figure-
|
|
1854
|
-
const y = document.createElement("textarea");
|
|
1855
|
-
y.className = "figure-mermaid-editor", y.spellcheck = !1;
|
|
1856
|
-
const E = document.createElement("div");
|
|
1857
|
-
E.className = "figure-mermaid-toolbar";
|
|
1858
|
-
const x = document.createElement("button");
|
|
1859
|
-
x.className = "figure-mermaid-save-btn", x.type = "button";
|
|
1860
|
-
const w = document.createElement("button");
|
|
1861
|
-
w.className = "figure-mermaid-cancel-btn", w.type = "button";
|
|
1862
|
-
const T = document.createElement("span");
|
|
1863
|
-
T.className = "figure-mermaid-error-inline", E.append(T, w, x), h.append(y, E);
|
|
1864
|
-
const v = document.createElement("div");
|
|
1865
|
-
v.className = "figure-drawio-view", v.contentEditable = "false";
|
|
1867
|
+
h.className = "figure-drawio-view", h.contentEditable = "false";
|
|
1866
1868
|
const _ = document.createElement("img");
|
|
1867
1869
|
_.className = "figure-drawio-preview-img", _.style.display = "none";
|
|
1868
|
-
const
|
|
1869
|
-
|
|
1870
|
+
const T = document.createElement("div");
|
|
1871
|
+
T.className = "figure-drawio-view-hint", h.append(_, T), c.append(s, l, u), c.append(f, b), c.append(h);
|
|
1870
1872
|
const N = document.createElement("figcaption");
|
|
1871
1873
|
N.className = "figure-caption";
|
|
1872
1874
|
const A = document.createElement("span");
|
|
@@ -1885,8 +1887,8 @@ const Le = () => {
|
|
|
1885
1887
|
typeof P.result == "string" && z({ imageSrc: P.result });
|
|
1886
1888
|
}, P.readAsDataURL(k);
|
|
1887
1889
|
};
|
|
1888
|
-
|
|
1889
|
-
S.stopPropagation(),
|
|
1890
|
+
m.addEventListener("change", () => Q(m.files)), l.addEventListener("click", () => m.click()), u.addEventListener("click", (S) => {
|
|
1891
|
+
S.stopPropagation(), m.click();
|
|
1890
1892
|
}), c.addEventListener("dragover", (S) => {
|
|
1891
1893
|
r.attrs.contentType === "image" && (S.preventDefault(), S.stopPropagation(), l.classList.add("figure-upload-area--dragover"));
|
|
1892
1894
|
}), c.addEventListener("dragleave", () => {
|
|
@@ -1896,12 +1898,12 @@ const Le = () => {
|
|
|
1896
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));
|
|
1897
1899
|
});
|
|
1898
1900
|
const gn = () => {
|
|
1899
|
-
a || (a = !0,
|
|
1901
|
+
a || (a = !0, w.value = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "", E.textContent = "", E.style.display = "none", J(), requestAnimationFrame(() => w.focus()));
|
|
1900
1902
|
}, fn = () => {
|
|
1901
1903
|
a = !1, J();
|
|
1902
1904
|
}, pn = async () => {
|
|
1903
|
-
const S =
|
|
1904
|
-
|
|
1905
|
+
const S = w.value;
|
|
1906
|
+
E.textContent = "", E.style.display = "none";
|
|
1905
1907
|
const k = S.trim();
|
|
1906
1908
|
if (k)
|
|
1907
1909
|
try {
|
|
@@ -1912,18 +1914,18 @@ const Le = () => {
|
|
|
1912
1914
|
} catch {
|
|
1913
1915
|
Le();
|
|
1914
1916
|
const P = I.getState().editorLanguage;
|
|
1915
|
-
|
|
1917
|
+
E.textContent = P === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", E.style.display = "inline";
|
|
1916
1918
|
return;
|
|
1917
1919
|
}
|
|
1918
1920
|
z({ mermaidCode: S }), a = !1, J();
|
|
1919
1921
|
};
|
|
1920
1922
|
f.addEventListener("dblclick", (S) => {
|
|
1921
1923
|
S.preventDefault(), S.stopPropagation(), gn();
|
|
1922
|
-
}),
|
|
1924
|
+
}), C.addEventListener("click", (S) => {
|
|
1923
1925
|
S.stopPropagation(), pn();
|
|
1924
|
-
}),
|
|
1926
|
+
}), v.addEventListener("click", (S) => {
|
|
1925
1927
|
S.stopPropagation(), fn();
|
|
1926
|
-
}),
|
|
1928
|
+
}), w.addEventListener("mousedown", (S) => S.stopPropagation()), w.addEventListener("keydown", (S) => S.stopPropagation()), w.addEventListener("keypress", (S) => S.stopPropagation());
|
|
1927
1929
|
let ee = null, G = null, q = null;
|
|
1928
1930
|
const hn = () => {
|
|
1929
1931
|
if (i) return;
|
|
@@ -1968,11 +1970,11 @@ const Le = () => {
|
|
|
1968
1970
|
}, We = () => {
|
|
1969
1971
|
i = !1, ee && (window.removeEventListener("message", ee), ee = null), q && (q.src = "about:blank", q = null), G && (G.remove(), G = null), J();
|
|
1970
1972
|
};
|
|
1971
|
-
|
|
1973
|
+
h.addEventListener("dblclick", (S) => {
|
|
1972
1974
|
S.preventDefault(), S.stopPropagation(), hn();
|
|
1973
1975
|
}), o.addEventListener("mousedown", (S) => {
|
|
1974
1976
|
const k = S.target;
|
|
1975
|
-
if (!(k instanceof HTMLElement) || k === D || D.contains(k) || k ===
|
|
1977
|
+
if (!(k instanceof HTMLElement) || k === D || D.contains(k) || k === w || b.contains(k) || k === l || l.contains(k) || k === u || k === m || f.contains(k) || h.contains(k)) return;
|
|
1976
1978
|
const P = typeof n == "function" ? n() : null;
|
|
1977
1979
|
if (typeof P != "number") return;
|
|
1978
1980
|
const O = P + r.nodeSize - 1, R = Zn.create(e.state.doc, O);
|
|
@@ -2003,16 +2005,16 @@ const Le = () => {
|
|
|
2003
2005
|
const S = I.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 : "";
|
|
2004
2006
|
O ? (A.textContent = `[${O}] `, A.style.display = "inline") : (A.textContent = "", A.style.display = "none");
|
|
2005
2007
|
const K = P === "image", X = P === "mermaid", U = P === "drawio";
|
|
2006
|
-
s.style.display = K && R ? "block" : "none", l.style.display = K && !R ? "flex" : "none", u.style.display = K && R ? "block" : "none", f.style.display = X && !a ? "block" : "none",
|
|
2008
|
+
s.style.display = K && R ? "block" : "none", l.style.display = K && !R ? "flex" : "none", u.style.display = K && R ? "block" : "none", f.style.display = X && !a ? "block" : "none", b.style.display = X && a ? "block" : "none", h.style.display = U ? "flex" : "none", K && R && (s.src = R);
|
|
2007
2009
|
const oe = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
|
|
2008
|
-
U && (oe ? (_.src = oe, _.style.display = "block") : (_.src = "", _.style.display = "none")), d.textContent = k.figureUploadHint || "点击上传或拖拽图片", u.textContent = k.figureReplaceImage || "更换图片",
|
|
2010
|
+
U && (oe ? (_.src = oe, _.style.display = "block") : (_.src = "", _.style.display = "none")), d.textContent = k.figureUploadHint || "点击上传或拖拽图片", u.textContent = k.figureReplaceImage || "更换图片", C.textContent = k.mermaidSaveAndRender || "保存并渲染", v.textContent = k.mermaidCancel || "取消";
|
|
2009
2011
|
const Te = fe.trim().length > 0, ce = p.querySelector("svg") !== null;
|
|
2010
|
-
X && !a && (Te && ce ? (
|
|
2012
|
+
X && !a && (Te && ce ? (y.textContent = k.mermaidDoubleClickToEdit || "双击编辑", y.className = "figure-mermaid-view-hint figure-mermaid-view-hint--subtle") : (y.textContent = k.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", y.className = "figure-mermaid-view-hint figure-mermaid-view-hint--empty")), U && !i && (oe ? (T.textContent = k.mermaidDoubleClickToEdit || "双击编辑", T.className = "figure-drawio-view-hint figure-mermaid-view-hint--subtle") : (T.textContent = k.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", T.className = "figure-drawio-view-hint figure-mermaid-view-hint--empty")), X && !a && fe.trim() !== ge && wn(fe);
|
|
2011
2013
|
const Cn = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "";
|
|
2012
2014
|
U && Cn && !oe && !xe && !i && (se && clearTimeout(se), se = setTimeout(() => {
|
|
2013
2015
|
se = null;
|
|
2014
2016
|
const dt = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "", Tn = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
|
|
2015
|
-
!dt || Tn || xe || (xe = !0,
|
|
2017
|
+
!dt || Tn || xe || (xe = !0, Pa(dt, (ut) => {
|
|
2016
2018
|
xe = !1, ut ? (Ce = 0, z({ drawioSvg: ut })) : Ce < yn && (Ce++, me = setTimeout(() => {
|
|
2017
2019
|
me = null, J();
|
|
2018
2020
|
}, vn * Ce));
|
|
@@ -2028,7 +2030,7 @@ const Le = () => {
|
|
|
2028
2030
|
contentDOM: D,
|
|
2029
2031
|
stopEvent: (S) => {
|
|
2030
2032
|
const k = S.target;
|
|
2031
|
-
return !!(k ===
|
|
2033
|
+
return !!(k === w || b.contains(k) || k === m);
|
|
2032
2034
|
},
|
|
2033
2035
|
ignoreMutation: (S) => {
|
|
2034
2036
|
const k = S.target;
|
|
@@ -2041,7 +2043,7 @@ const Le = () => {
|
|
|
2041
2043
|
};
|
|
2042
2044
|
};
|
|
2043
2045
|
}
|
|
2044
|
-
}),
|
|
2046
|
+
}), Ra = Z.create({
|
|
2045
2047
|
name: "reference",
|
|
2046
2048
|
group: "inline",
|
|
2047
2049
|
inline: !0,
|
|
@@ -2102,8 +2104,8 @@ const Le = () => {
|
|
|
2102
2104
|
return ({ node: e, editor: t }) => {
|
|
2103
2105
|
let n = e;
|
|
2104
2106
|
const r = document.createElement("span"), a = () => {
|
|
2105
|
-
const i = n.attrs.lang === "en" ? "en" : "zh", o = H(i), c = n.attrs.targetType === "figure" ? "figure" : "claim", s = Number(n.attrs.resolvedNumber), l = typeof n.attrs.resolvedFigureId == "string" && n.attrs.resolvedFigureId ? n.attrs.resolvedFigureId : null, d = c === "figure" ? l || (i === "en" ? "Figure ?" : "附图?") : Number.isFinite(s) ? o.claimLabel(s) : i === "en" ? "Claim ?" : "权利要求?",
|
|
2106
|
-
r.textContent =
|
|
2107
|
+
const i = n.attrs.lang === "en" ? "en" : "zh", o = H(i), c = n.attrs.targetType === "figure" ? "figure" : "claim", s = Number(n.attrs.resolvedNumber), l = typeof n.attrs.resolvedFigureId == "string" && n.attrs.resolvedFigureId ? n.attrs.resolvedFigureId : null, d = c === "figure" ? l || (i === "en" ? "Figure ?" : "附图?") : Number.isFinite(s) ? o.claimLabel(s) : i === "en" ? "Claim ?" : "权利要求?", m = n.attrs.displayText || d;
|
|
2108
|
+
r.textContent = m, r.className = `reference-link${n.attrs.invalid ? " reference-link-invalid" : ""}`, r.setAttribute("data-type", "reference"), r.setAttribute("data-highlight", n.attrs.highlight ? "true" : "false"), r.title = n.attrs.invalid ? o.referenceNavigateDisabledTitle : c === "figure" ? o.figureReferenceNavigateTitle : o.referenceNavigateTitle;
|
|
2107
2109
|
};
|
|
2108
2110
|
return a(), r.addEventListener("click", () => {
|
|
2109
2111
|
const i = n.attrs.targetType === "figure" ? "figure" : "claim";
|
|
@@ -2142,7 +2144,7 @@ const Le = () => {
|
|
|
2142
2144
|
design_description: "sectionTitle_design_description",
|
|
2143
2145
|
design_views: "sectionTitle_design_views",
|
|
2144
2146
|
design_brief: "sectionTitle_design_brief"
|
|
2145
|
-
},
|
|
2147
|
+
}, Ma = /* @__PURE__ */ new Set([
|
|
2146
2148
|
"abstract",
|
|
2147
2149
|
"abstract_drawing",
|
|
2148
2150
|
"claims",
|
|
@@ -2153,7 +2155,7 @@ const Le = () => {
|
|
|
2153
2155
|
"design_description",
|
|
2154
2156
|
"design_views",
|
|
2155
2157
|
"design_brief"
|
|
2156
|
-
]),
|
|
2158
|
+
]), Fa = /* @__PURE__ */ new Set([
|
|
2157
2159
|
"technical_field",
|
|
2158
2160
|
"background_art",
|
|
2159
2161
|
"summary",
|
|
@@ -2168,7 +2170,7 @@ const Le = () => {
|
|
|
2168
2170
|
return e.forEach((n) => {
|
|
2169
2171
|
!t && ot(n) && (t = !0);
|
|
2170
2172
|
}), t;
|
|
2171
|
-
},
|
|
2173
|
+
}, $a = Z.create({
|
|
2172
2174
|
name: "patent_title",
|
|
2173
2175
|
group: "block",
|
|
2174
2176
|
content: "inline*",
|
|
@@ -2200,38 +2202,38 @@ const Le = () => {
|
|
|
2200
2202
|
const c = document.createElement("h1");
|
|
2201
2203
|
c.className = "pt-title-content", a.append(i, o, c);
|
|
2202
2204
|
const s = () => {
|
|
2203
|
-
const
|
|
2204
|
-
return typeof
|
|
2205
|
+
const y = typeof n == "function" ? n() : null;
|
|
2206
|
+
return typeof y == "number" ? y : null;
|
|
2205
2207
|
}, l = () => {
|
|
2206
|
-
const
|
|
2207
|
-
|
|
2208
|
+
const y = s();
|
|
2209
|
+
y !== null && I.getState().setActiveSection("patent_title", y);
|
|
2208
2210
|
}, d = () => {
|
|
2209
|
-
const
|
|
2210
|
-
|
|
2211
|
+
const y = s();
|
|
2212
|
+
y !== null && (I.getState().openDraftingPanel("patent_title", y), e.commands.focus(y + 1));
|
|
2211
2213
|
};
|
|
2212
2214
|
o.addEventListener("click", d), c.addEventListener("focusin", l), c.addEventListener("click", l);
|
|
2213
|
-
const
|
|
2214
|
-
const
|
|
2215
|
-
i.textContent =
|
|
2216
|
-
const
|
|
2217
|
-
o.textContent = `[${
|
|
2215
|
+
const m = () => {
|
|
2216
|
+
const y = I.getState(), b = H(y.editorLanguage), w = typeof b.bookTitle_description == "string" ? b.bookTitle_description : "说明书", x = typeof b.patentTitlePlaceholder == "string" ? b.patentTitlePlaceholder : "专利名称";
|
|
2217
|
+
i.textContent = w;
|
|
2218
|
+
const C = ot(r), v = y.rightPanel.activeSectionPos === s();
|
|
2219
|
+
o.textContent = `[${x}]`, o.style.display = C ? "none" : "", o.classList.toggle("ps-placeholder--active", v && !C), c.classList.toggle("pt-title-content--has-content", C);
|
|
2218
2220
|
};
|
|
2219
2221
|
let u = I.getState().editorLanguage, f = I.getState().rightPanel.activeSectionPos;
|
|
2220
|
-
const p = I.subscribe((
|
|
2221
|
-
const
|
|
2222
|
-
u =
|
|
2222
|
+
const p = I.subscribe((y) => {
|
|
2223
|
+
const b = y.editorLanguage !== u, w = y.rightPanel.activeSectionPos !== f;
|
|
2224
|
+
u = y.editorLanguage, f = y.rightPanel.activeSectionPos, (b || w) && m();
|
|
2223
2225
|
});
|
|
2224
|
-
return
|
|
2226
|
+
return m(), {
|
|
2225
2227
|
dom: a,
|
|
2226
2228
|
contentDOM: c,
|
|
2227
|
-
update: (
|
|
2229
|
+
update: (y) => y.type.name !== "patent_title" ? !1 : (r = y, m(), !0),
|
|
2228
2230
|
destroy: () => {
|
|
2229
2231
|
p(), o.removeEventListener("click", d), c.removeEventListener("focusin", l), c.removeEventListener("click", l);
|
|
2230
2232
|
}
|
|
2231
2233
|
};
|
|
2232
2234
|
};
|
|
2233
2235
|
}
|
|
2234
|
-
}),
|
|
2236
|
+
}), za = Z.create({
|
|
2235
2237
|
name: "patent_section",
|
|
2236
2238
|
group: "block",
|
|
2237
2239
|
content: "block+",
|
|
@@ -2303,52 +2305,52 @@ const Le = () => {
|
|
|
2303
2305
|
const s = document.createElement("div");
|
|
2304
2306
|
s.className = "ps-content", o.append(c, s), a.append(i, o);
|
|
2305
2307
|
const l = () => {
|
|
2306
|
-
const
|
|
2307
|
-
return typeof
|
|
2308
|
+
const b = typeof n == "function" ? n() : null;
|
|
2309
|
+
return typeof b == "number" ? b : null;
|
|
2308
2310
|
}, d = () => {
|
|
2309
|
-
const
|
|
2310
|
-
if (
|
|
2311
|
-
I.getState().setActiveSection(r.attrs.sectionType,
|
|
2312
|
-
},
|
|
2313
|
-
const
|
|
2314
|
-
if (
|
|
2315
|
-
I.getState().openDraftingPanel(r.attrs.sectionType,
|
|
2311
|
+
const b = l();
|
|
2312
|
+
if (b === null) return;
|
|
2313
|
+
I.getState().setActiveSection(r.attrs.sectionType, b);
|
|
2314
|
+
}, m = () => {
|
|
2315
|
+
const b = l();
|
|
2316
|
+
if (b === null) return;
|
|
2317
|
+
I.getState().openDraftingPanel(r.attrs.sectionType, b), e.commands.focus(b + 1);
|
|
2316
2318
|
};
|
|
2317
|
-
c.addEventListener("click",
|
|
2319
|
+
c.addEventListener("click", m), s.addEventListener("focusin", d), s.addEventListener("click", d);
|
|
2318
2320
|
const u = () => {
|
|
2319
|
-
const
|
|
2320
|
-
a.className = `ps${_ ? "" : " ps--empty"}${
|
|
2321
|
+
const b = I.getState(), w = H(b.editorLanguage), x = Object.keys(wt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", C = Ma.has(x), v = Fa.has(x), E = wt[x], h = typeof w[E] == "string" ? w[E] : x, _ = ot(r), T = b.rightPanel.activeSectionPos === l();
|
|
2322
|
+
a.className = `ps${_ ? "" : " ps--empty"}${v ? " ps--sub" : ""}`, a.setAttribute("data-section-type", x), i.className = C ? "pb-heading" : "ps-heading ps-heading--sub", i.textContent = h, c.textContent = `[${h}]`, c.style.display = _ ? "none" : "", c.classList.toggle("ps-placeholder--active", T && !_), s.classList.toggle("ps-content--has-content", _);
|
|
2321
2323
|
};
|
|
2322
2324
|
let f = I.getState().editorLanguage, p = I.getState().rightPanel.activeSectionPos;
|
|
2323
|
-
const
|
|
2324
|
-
const
|
|
2325
|
-
f =
|
|
2325
|
+
const y = I.subscribe((b) => {
|
|
2326
|
+
const w = b.editorLanguage !== f, x = b.rightPanel.activeSectionPos !== p;
|
|
2327
|
+
f = b.editorLanguage, p = b.rightPanel.activeSectionPos, (w || x) && u();
|
|
2326
2328
|
});
|
|
2327
2329
|
return u(), {
|
|
2328
2330
|
dom: a,
|
|
2329
2331
|
contentDOM: s,
|
|
2330
|
-
update: (
|
|
2332
|
+
update: (b) => b.type.name !== "patent_section" ? !1 : (r = b, u(), !0),
|
|
2331
2333
|
destroy: () => {
|
|
2332
|
-
|
|
2334
|
+
y(), c.removeEventListener("click", m), s.removeEventListener("focusin", d), s.removeEventListener("click", d);
|
|
2333
2335
|
}
|
|
2334
2336
|
};
|
|
2335
2337
|
};
|
|
2336
2338
|
}
|
|
2337
|
-
}),
|
|
2339
|
+
}), Oa = [
|
|
2338
2340
|
"abstract",
|
|
2339
2341
|
// 说明书摘要
|
|
2340
2342
|
"abstract_drawing"
|
|
2341
2343
|
// 摘要附图
|
|
2342
|
-
],
|
|
2344
|
+
], Ba = [
|
|
2343
2345
|
"technical_field",
|
|
2344
2346
|
"background_art",
|
|
2345
2347
|
"summary",
|
|
2346
2348
|
"drawing_description",
|
|
2347
2349
|
"detailed_description"
|
|
2348
|
-
],
|
|
2350
|
+
], Ha = [
|
|
2349
2351
|
"drawing_figures"
|
|
2350
2352
|
// 说明书附图
|
|
2351
|
-
],
|
|
2353
|
+
], qa = [
|
|
2352
2354
|
"design_product_name",
|
|
2353
2355
|
"design_usage",
|
|
2354
2356
|
"design_description",
|
|
@@ -2368,15 +2370,15 @@ const Le = () => {
|
|
|
2368
2370
|
}), en = () => ({
|
|
2369
2371
|
type: "patent_title",
|
|
2370
2372
|
content: []
|
|
2371
|
-
}),
|
|
2373
|
+
}), Ua = () => [
|
|
2374
|
+
...Oa.map(Fe),
|
|
2375
|
+
en(),
|
|
2372
2376
|
...Ba.map(Fe),
|
|
2377
|
+
...Ha.map(Fe)
|
|
2378
|
+
], Wa = () => [
|
|
2373
2379
|
en(),
|
|
2374
|
-
...Ha.map(Fe),
|
|
2375
2380
|
...qa.map(Fe)
|
|
2376
|
-
],
|
|
2377
|
-
en(),
|
|
2378
|
-
...Ua.map(Fe)
|
|
2379
|
-
], tn = (e = "invention") => ({ type: "doc", content: e === "design" ? ja() : Wa() }), ve = (e) => Xt(e, (t) => t.type.name === "figure"), V = (e) => typeof e != "string" ? "" : e.trim(), xt = (e) => {
|
|
2381
|
+
], tn = (e = "invention") => ({ type: "doc", content: e === "design" ? Wa() : Ua() }), ve = (e) => Xt(e, (t) => t.type.name === "figure"), V = (e) => typeof e != "string" ? "" : e.trim(), xt = (e) => {
|
|
2380
2382
|
const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = /* @__PURE__ */ new Set();
|
|
2381
2383
|
ve(e).forEach((i) => {
|
|
2382
2384
|
const o = V(i.node.attrs.id);
|
|
@@ -2386,14 +2388,14 @@ const Le = () => {
|
|
|
2386
2388
|
for (; r.has(`${n}${a}`); )
|
|
2387
2389
|
a += 1;
|
|
2388
2390
|
return `${n}${a}`;
|
|
2389
|
-
},
|
|
2391
|
+
}, ja = /^(Fig\.|图)(\d+)$/, Ga = (e) => {
|
|
2390
2392
|
const n = I.getState().editorLanguage === "en" ? "Fig." : "图", r = ve(e);
|
|
2391
2393
|
if (r.length === 0) return;
|
|
2392
2394
|
const a = [];
|
|
2393
2395
|
let i = 1;
|
|
2394
2396
|
for (const c of r) {
|
|
2395
2397
|
const s = V(c.node.attrs.id);
|
|
2396
|
-
if (!
|
|
2398
|
+
if (!ja.exec(s)) continue;
|
|
2397
2399
|
const d = `${n}${i}`;
|
|
2398
2400
|
s !== d && a.push({ pos: c.pos, expectedId: d, currentId: s }), i++;
|
|
2399
2401
|
}
|
|
@@ -2423,25 +2425,25 @@ const Le = () => {
|
|
|
2423
2425
|
return a.doc.descendants((c, s) => {
|
|
2424
2426
|
if (c.type.name !== "reference" || c.attrs.targetType !== "figure")
|
|
2425
2427
|
return !0;
|
|
2426
|
-
const l = typeof c.attrs.targetFigureId == "string" && c.attrs.targetFigureId ? V(c.attrs.targetFigureId) : null, d = l ? t.get(l) : void 0,
|
|
2428
|
+
const l = typeof c.attrs.targetFigureId == "string" && c.attrs.targetFigureId ? V(c.attrs.targetFigureId) : null, d = l ? t.get(l) : void 0, m = d ? d.id : null, u = !d, f = an(n, m, u), p = {
|
|
2427
2429
|
...c.attrs,
|
|
2428
2430
|
targetType: "figure",
|
|
2429
2431
|
targetFigureId: l,
|
|
2430
|
-
resolvedFigureId:
|
|
2432
|
+
resolvedFigureId: m,
|
|
2431
2433
|
invalid: u,
|
|
2432
2434
|
lang: n,
|
|
2433
2435
|
displayText: f,
|
|
2434
|
-
target:
|
|
2436
|
+
target: m || c.attrs.target || l || null
|
|
2435
2437
|
};
|
|
2436
2438
|
return Object.keys(p).some(
|
|
2437
|
-
(
|
|
2439
|
+
(b) => p[b] !== c.attrs[b]
|
|
2438
2440
|
) && (r.setNodeMarkup(s, void 0, p), o = !0), !0;
|
|
2439
|
-
}), o && i && i(r), !0;
|
|
2441
|
+
}), o && i && (r.setMeta("addToHistory", !1), i(r)), !0;
|
|
2440
2442
|
});
|
|
2441
|
-
},
|
|
2443
|
+
}, Va = {
|
|
2442
2444
|
name: "patent",
|
|
2443
2445
|
version: "1.0.0",
|
|
2444
|
-
extensions: [Ra,
|
|
2446
|
+
extensions: [Da, Ra, $a, za],
|
|
2445
2447
|
toolbarItems: [
|
|
2446
2448
|
{
|
|
2447
2449
|
id: "patent-figure-insert",
|
|
@@ -2467,10 +2469,10 @@ const Le = () => {
|
|
|
2467
2469
|
const i = (n.scope || "all") === "current" ? Re(e, "reference") : null;
|
|
2468
2470
|
return e.commands.command(({ tr: c, state: s, dispatch: l }) => {
|
|
2469
2471
|
let d = !1;
|
|
2470
|
-
return s.doc.descendants((
|
|
2471
|
-
...
|
|
2472
|
+
return s.doc.descendants((m, u) => (m.type.name !== "reference" || i && u !== i.pos || m.attrs.lang !== r && (c.setNodeMarkup(u, void 0, {
|
|
2473
|
+
...m.attrs,
|
|
2472
2474
|
lang: r
|
|
2473
|
-
}), d = !0), !0)), d && l && l(c), !0;
|
|
2475
|
+
}), d = !0), !0)), d && l && (c.setMeta("addToHistory", !1), l(c)), !0;
|
|
2474
2476
|
}) ? (Je(e), !0) : !1;
|
|
2475
2477
|
}
|
|
2476
2478
|
},
|
|
@@ -2587,13 +2589,13 @@ const Le = () => {
|
|
|
2587
2589
|
}
|
|
2588
2590
|
},
|
|
2589
2591
|
onStateChange: (e) => {
|
|
2590
|
-
|
|
2592
|
+
Ga(e), Je(e);
|
|
2591
2593
|
}
|
|
2592
|
-
},
|
|
2593
|
-
|
|
2594
|
-
const
|
|
2594
|
+
}, Ja = [xa, Ta, ka, Va];
|
|
2595
|
+
Ja.forEach((e) => B.register(e));
|
|
2596
|
+
const Ka = (e = {}) => {
|
|
2595
2597
|
const t = [
|
|
2596
|
-
...
|
|
2598
|
+
...ya,
|
|
2597
2599
|
...B.getExtensions(),
|
|
2598
2600
|
...e.extensions || []
|
|
2599
2601
|
];
|
|
@@ -2617,12 +2619,12 @@ const Xa = (e = {}) => {
|
|
|
2617
2619
|
updateNodeAttrs: (t) => ze(e, t),
|
|
2618
2620
|
removeNode: (t) => Zt(e, t),
|
|
2619
2621
|
wrapSelection: (t) => Qt(e, t),
|
|
2620
|
-
applyTransactionBatch: (t) =>
|
|
2622
|
+
applyTransactionBatch: (t) => Aa(e, t),
|
|
2621
2623
|
findNodeByType: (t, n) => st(e, t, n),
|
|
2622
2624
|
findAncestorNode: (t) => Re(e, t),
|
|
2623
|
-
findCurrentBlock: () =>
|
|
2625
|
+
findCurrentBlock: () => _a(e),
|
|
2624
2626
|
findNodesByPredicate: (t, n) => Xt(e, t, n)
|
|
2625
|
-
}),
|
|
2627
|
+
}), Xa = ["history", "text", "structure", "format", "technical", "patent"], Ya = {
|
|
2626
2628
|
history: "groupHistory",
|
|
2627
2629
|
text: "groupText",
|
|
2628
2630
|
structure: "groupStructure",
|
|
@@ -2631,7 +2633,7 @@ const Xa = (e = {}) => {
|
|
|
2631
2633
|
patent: "groupPatent"
|
|
2632
2634
|
}, Xe = (e, t) => {
|
|
2633
2635
|
if (t) {
|
|
2634
|
-
const n =
|
|
2636
|
+
const n = Ya[e];
|
|
2635
2637
|
if (n && typeof t[n] == "string") return t[n];
|
|
2636
2638
|
}
|
|
2637
2639
|
return e.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join(" ");
|
|
@@ -2644,16 +2646,16 @@ const Xa = (e = {}) => {
|
|
|
2644
2646
|
return M(() => {
|
|
2645
2647
|
if (!n) return;
|
|
2646
2648
|
s();
|
|
2647
|
-
const l = (
|
|
2649
|
+
const l = (m) => {
|
|
2648
2650
|
var f, p;
|
|
2649
|
-
const u =
|
|
2651
|
+
const u = m.target;
|
|
2650
2652
|
(f = a.current) != null && f.contains(u) || (p = i.current) != null && p.contains(u) || r(!1);
|
|
2651
2653
|
}, d = () => s();
|
|
2652
2654
|
return document.addEventListener("mousedown", l), window.addEventListener("scroll", d, !0), () => {
|
|
2653
2655
|
document.removeEventListener("mousedown", l), window.removeEventListener("scroll", d, !0);
|
|
2654
2656
|
};
|
|
2655
2657
|
}, [n, s]), /* @__PURE__ */ L("div", { className: "flex items-center", children: [
|
|
2656
|
-
/* @__PURE__ */
|
|
2658
|
+
/* @__PURE__ */ g(
|
|
2657
2659
|
"button",
|
|
2658
2660
|
{
|
|
2659
2661
|
onClick: e.run,
|
|
@@ -2664,10 +2666,10 @@ const Xa = (e = {}) => {
|
|
|
2664
2666
|
e.isActive ? "bg-gray-300 text-blue-600" : "text-gray-700"
|
|
2665
2667
|
),
|
|
2666
2668
|
title: e.tooltip,
|
|
2667
|
-
children: /* @__PURE__ */
|
|
2669
|
+
children: /* @__PURE__ */ g(e.icon, { size: 18 })
|
|
2668
2670
|
}
|
|
2669
2671
|
),
|
|
2670
|
-
/* @__PURE__ */
|
|
2672
|
+
/* @__PURE__ */ g(
|
|
2671
2673
|
"button",
|
|
2672
2674
|
{
|
|
2673
2675
|
ref: a,
|
|
@@ -2677,17 +2679,17 @@ const Xa = (e = {}) => {
|
|
|
2677
2679
|
e.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200 text-gray-500"
|
|
2678
2680
|
),
|
|
2679
2681
|
disabled: e.disabled,
|
|
2680
|
-
children: /* @__PURE__ */
|
|
2682
|
+
children: /* @__PURE__ */ g(Ut, { size: 12 })
|
|
2681
2683
|
}
|
|
2682
2684
|
),
|
|
2683
2685
|
n && yr(
|
|
2684
|
-
/* @__PURE__ */
|
|
2686
|
+
/* @__PURE__ */ g(
|
|
2685
2687
|
"div",
|
|
2686
2688
|
{
|
|
2687
2689
|
ref: i,
|
|
2688
2690
|
className: "bg-white border border-gray-200 rounded shadow-lg min-w-[160px] py-1",
|
|
2689
2691
|
style: { position: "fixed", top: o.top, left: o.left, zIndex: 9999 },
|
|
2690
|
-
children: t.map((l, d) => /* @__PURE__ */
|
|
2692
|
+
children: t.map((l, d) => /* @__PURE__ */ g(
|
|
2691
2693
|
"button",
|
|
2692
2694
|
{
|
|
2693
2695
|
onClick: () => {
|
|
@@ -2703,16 +2705,16 @@ const Xa = (e = {}) => {
|
|
|
2703
2705
|
document.body
|
|
2704
2706
|
)
|
|
2705
2707
|
] });
|
|
2706
|
-
},
|
|
2708
|
+
}, Za = ({
|
|
2707
2709
|
editor: e,
|
|
2708
|
-
groupOrder: t =
|
|
2710
|
+
groupOrder: t = Xa,
|
|
2709
2711
|
collapsibleGroups: n = !0,
|
|
2710
2712
|
defaultCollapsedGroups: r = []
|
|
2711
2713
|
}) => {
|
|
2712
2714
|
const [a, i] = $(() => new Set(r)), { editorLanguage: o, setEditorLanguage: c } = I(), s = H(o);
|
|
2713
2715
|
if (!e)
|
|
2714
2716
|
return null;
|
|
2715
|
-
const l = ct(e), d = o === "zh",
|
|
2717
|
+
const l = ct(e), d = o === "zh", m = [
|
|
2716
2718
|
{
|
|
2717
2719
|
id: "core-undo",
|
|
2718
2720
|
label: s.undo,
|
|
@@ -3010,29 +3012,29 @@ const Xa = (e = {}) => {
|
|
|
3010
3012
|
FileText: qt,
|
|
3011
3013
|
Link2: Ht,
|
|
3012
3014
|
Image: Bt
|
|
3013
|
-
}, f = B.getToolbarItems().map((
|
|
3014
|
-
const _ = B.getCommandMeta(
|
|
3015
|
+
}, f = B.getToolbarItems().map((h) => {
|
|
3016
|
+
const _ = B.getCommandMeta(h.command), T = d && h.tooltipZh ? h.tooltipZh : h.tooltip || (_ == null ? void 0 : _.description) || h.label, N = h.shortcut || (_ == null ? void 0 : _.shortcut), A = N ? `${T} (${N})` : T;
|
|
3015
3017
|
return {
|
|
3016
|
-
id:
|
|
3017
|
-
label:
|
|
3018
|
-
group:
|
|
3019
|
-
icon:
|
|
3020
|
-
isActive: l.isCommandActive(
|
|
3021
|
-
disabled: !l.canExecCommand(
|
|
3018
|
+
id: h.id,
|
|
3019
|
+
label: h.label,
|
|
3020
|
+
group: h.group || "technical",
|
|
3021
|
+
icon: h.icon ? u[h.icon] || mt : mt,
|
|
3022
|
+
isActive: l.isCommandActive(h.command),
|
|
3023
|
+
disabled: !l.canExecCommand(h.command),
|
|
3022
3024
|
tooltip: A,
|
|
3023
3025
|
run: () => {
|
|
3024
|
-
l.execCommand(
|
|
3026
|
+
l.execCommand(h.command);
|
|
3025
3027
|
}
|
|
3026
3028
|
};
|
|
3027
|
-
}), p = [...
|
|
3028
|
-
group:
|
|
3029
|
-
items: p.filter((_) => _.group ===
|
|
3030
|
-
})).filter((
|
|
3029
|
+
}), p = [...m, ...f], y = p.map((h) => h.group).filter((h, _, T) => T.indexOf(h) === _ && !t.includes(h)), w = [...t, ...y].map((h) => ({
|
|
3030
|
+
group: h,
|
|
3031
|
+
items: p.filter((_) => _.group === h)
|
|
3032
|
+
})).filter((h) => h.items.length > 0), x = (h) => {
|
|
3031
3033
|
i((_) => {
|
|
3032
|
-
const
|
|
3033
|
-
return
|
|
3034
|
+
const T = new Set(_);
|
|
3035
|
+
return T.has(h) ? T.delete(h) : T.add(h), T;
|
|
3034
3036
|
});
|
|
3035
|
-
},
|
|
3037
|
+
}, C = [
|
|
3036
3038
|
{ label: d ? "插入表格 3×3" : "Insert Table 3×3", onClick: () => e.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run() },
|
|
3037
3039
|
{ label: d ? "上方插入行" : "Add Row Before", onClick: () => e.chain().focus().addRowBefore().run() },
|
|
3038
3040
|
{ label: d ? "下方插入行" : "Add Row After", onClick: () => e.chain().focus().addRowAfter().run() },
|
|
@@ -3044,107 +3046,107 @@ const Xa = (e = {}) => {
|
|
|
3044
3046
|
{ label: d ? "拆分单元格" : "Split Cell", onClick: () => e.chain().focus().splitCell().run() },
|
|
3045
3047
|
{ label: d ? "切换表头" : "Toggle Header Row", onClick: () => e.chain().focus().toggleHeaderRow().run() },
|
|
3046
3048
|
{ label: d ? "删除表格" : "Delete Table", onClick: () => e.chain().focus().deleteTable().run() }
|
|
3047
|
-
],
|
|
3049
|
+
], v = [
|
|
3048
3050
|
{ label: s.insertImageFigure, onClick: () => void l.execCommand("patent.insertFigure", { contentType: "image" }) },
|
|
3049
3051
|
{ label: s.insertMermaidFigure, onClick: () => void l.execCommand("patent.insertFigure", { contentType: "mermaid" }) },
|
|
3050
3052
|
{ label: s.insertDrawioFigure, onClick: () => void l.execCommand("patent.insertFigure", { contentType: "drawio" }) }
|
|
3051
|
-
],
|
|
3053
|
+
], E = (h) => h.id === "core-table" ? /* @__PURE__ */ g(Ct, { btn: h, items: C }, h.id) : h.id === "patent-figure-insert" ? /* @__PURE__ */ g(Ct, { btn: h, items: v }, h.id) : /* @__PURE__ */ g(
|
|
3052
3054
|
"button",
|
|
3053
3055
|
{
|
|
3054
|
-
onClick:
|
|
3055
|
-
disabled:
|
|
3056
|
+
onClick: h.run,
|
|
3057
|
+
disabled: h.disabled,
|
|
3056
3058
|
className: Y(
|
|
3057
3059
|
"p-2 rounded transition-colors",
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
+
h.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200",
|
|
3061
|
+
h.isActive ? "bg-gray-300 text-blue-600" : "text-gray-700"
|
|
3060
3062
|
),
|
|
3061
|
-
title:
|
|
3062
|
-
children: /* @__PURE__ */
|
|
3063
|
+
title: h.tooltip,
|
|
3064
|
+
children: /* @__PURE__ */ g(h.icon, { size: 18 })
|
|
3063
3065
|
},
|
|
3064
|
-
|
|
3066
|
+
h.id
|
|
3065
3067
|
);
|
|
3066
|
-
return /* @__PURE__ */
|
|
3068
|
+
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: [
|
|
3067
3069
|
/* @__PURE__ */ L("div", { className: "flex items-center gap-1 pr-2 mr-2 border-r border-gray-200", children: [
|
|
3068
|
-
/* @__PURE__ */
|
|
3070
|
+
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: s.language }),
|
|
3069
3071
|
/* @__PURE__ */ L(
|
|
3070
3072
|
"select",
|
|
3071
3073
|
{
|
|
3072
3074
|
value: o,
|
|
3073
|
-
onChange: (
|
|
3074
|
-
c(
|
|
3075
|
+
onChange: (h) => {
|
|
3076
|
+
c(h.target.value === "en" ? "en" : "zh");
|
|
3075
3077
|
},
|
|
3076
3078
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white text-gray-700",
|
|
3077
3079
|
children: [
|
|
3078
|
-
/* @__PURE__ */
|
|
3079
|
-
/* @__PURE__ */
|
|
3080
|
+
/* @__PURE__ */ g("option", { value: "zh", children: "中文" }),
|
|
3081
|
+
/* @__PURE__ */ g("option", { value: "en", children: "English" })
|
|
3080
3082
|
]
|
|
3081
3083
|
}
|
|
3082
3084
|
)
|
|
3083
3085
|
] }),
|
|
3084
|
-
|
|
3085
|
-
const _ = a.has(
|
|
3086
|
+
w.map((h) => {
|
|
3087
|
+
const _ = a.has(h.group);
|
|
3086
3088
|
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: [
|
|
3087
|
-
n && /* @__PURE__ */
|
|
3089
|
+
n && /* @__PURE__ */ g(
|
|
3088
3090
|
"button",
|
|
3089
3091
|
{
|
|
3090
3092
|
onClick: () => {
|
|
3091
|
-
|
|
3093
|
+
x(h.group);
|
|
3092
3094
|
},
|
|
3093
3095
|
className: "px-2 py-1 text-xs rounded bg-gray-200 text-gray-700 hover:bg-gray-300",
|
|
3094
|
-
title: _ ? `${s.expand} ${Xe(
|
|
3095
|
-
children: Xe(
|
|
3096
|
+
title: _ ? `${s.expand} ${Xe(h.group, s)}` : `${s.collapse} ${Xe(h.group, s)}`,
|
|
3097
|
+
children: Xe(h.group, s)
|
|
3096
3098
|
}
|
|
3097
3099
|
),
|
|
3098
|
-
(!n || !_) &&
|
|
3099
|
-
] },
|
|
3100
|
+
(!n || !_) && h.items.map(E)
|
|
3101
|
+
] }, h.group);
|
|
3100
3102
|
})
|
|
3101
3103
|
] }) });
|
|
3102
|
-
},
|
|
3103
|
-
const [t, n] = $(0), [r, a] = $(""), i = I((
|
|
3104
|
+
}, Qa = ({ editor: e }) => {
|
|
3105
|
+
const [t, n] = $(0), [r, a] = $(""), i = I((v) => v.editorLanguage), o = H(i);
|
|
3104
3106
|
if (M(() => {
|
|
3105
3107
|
if (!e) return;
|
|
3106
|
-
const
|
|
3107
|
-
return e.on("selectionUpdate",
|
|
3108
|
-
e.off("selectionUpdate",
|
|
3108
|
+
const v = () => n((E) => E + 1);
|
|
3109
|
+
return e.on("selectionUpdate", v), e.on("update", v), () => {
|
|
3110
|
+
e.off("selectionUpdate", v), e.off("update", v);
|
|
3109
3111
|
};
|
|
3110
3112
|
}, [e]), !e) return null;
|
|
3111
3113
|
const c = ct(e), s = [];
|
|
3112
|
-
e.state.doc.descendants((
|
|
3113
|
-
if (
|
|
3114
|
-
const
|
|
3115
|
-
return
|
|
3114
|
+
e.state.doc.descendants((v) => {
|
|
3115
|
+
if (v.type.name !== "figure") return !0;
|
|
3116
|
+
const E = typeof v.attrs.id == "string" ? v.attrs.id.trim() : "";
|
|
3117
|
+
return E && s.push({ id: E, label: E }), !0;
|
|
3116
3118
|
});
|
|
3117
|
-
const l = c.findAncestorNode("figure"), d = !!l,
|
|
3118
|
-
|
|
3119
|
-
const
|
|
3119
|
+
const l = c.findAncestorNode("figure"), d = !!l, m = l && typeof l.node.attrs.id == "string" ? l.node.attrs.id.trim() : "", u = l && typeof l.node.attrs.contentType == "string" ? l.node.attrs.contentType : "image", [f, p] = $(""), y = W(null), b = W(null), w = (l == null ? void 0 : l.pos) ?? null;
|
|
3120
|
+
w !== b.current && (b.current = w, d && m !== f && p(m));
|
|
3121
|
+
const x = (v) => {
|
|
3120
3122
|
l && c.execCommand("patent.updateFigure", {
|
|
3121
3123
|
position: l.pos,
|
|
3122
|
-
contentType:
|
|
3124
|
+
contentType: v
|
|
3123
3125
|
});
|
|
3124
|
-
},
|
|
3126
|
+
}, C = () => {
|
|
3125
3127
|
if (!l) return;
|
|
3126
|
-
const
|
|
3127
|
-
|
|
3128
|
+
const v = f.trim();
|
|
3129
|
+
v !== m && c.execCommand("patent.updateFigure", {
|
|
3128
3130
|
position: l.pos,
|
|
3129
|
-
id:
|
|
3131
|
+
id: v
|
|
3130
3132
|
});
|
|
3131
3133
|
};
|
|
3132
|
-
return /* @__PURE__ */
|
|
3134
|
+
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: [
|
|
3133
3135
|
s.length > 0 && /* @__PURE__ */ L(je, { children: [
|
|
3134
|
-
/* @__PURE__ */
|
|
3136
|
+
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: o.figureReferenceTarget }),
|
|
3135
3137
|
/* @__PURE__ */ L(
|
|
3136
3138
|
"select",
|
|
3137
3139
|
{
|
|
3138
3140
|
value: r || "__none__",
|
|
3139
|
-
onChange: (
|
|
3141
|
+
onChange: (v) => a(v.target.value === "__none__" ? "" : v.target.value),
|
|
3140
3142
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
|
|
3141
3143
|
children: [
|
|
3142
|
-
/* @__PURE__ */
|
|
3143
|
-
s.map((
|
|
3144
|
+
/* @__PURE__ */ g("option", { value: "__none__", children: o.figureReferenceTargetPlaceholder }),
|
|
3145
|
+
s.map((v) => /* @__PURE__ */ g("option", { value: v.id, children: v.label }, v.id))
|
|
3144
3146
|
]
|
|
3145
3147
|
}
|
|
3146
3148
|
),
|
|
3147
|
-
/* @__PURE__ */
|
|
3149
|
+
/* @__PURE__ */ g(
|
|
3148
3150
|
"button",
|
|
3149
3151
|
{
|
|
3150
3152
|
onClick: () => {
|
|
@@ -3155,74 +3157,61 @@ const Xa = (e = {}) => {
|
|
|
3155
3157
|
},
|
|
3156
3158
|
className: "p-2 hover:bg-blue-50 text-blue-600 rounded",
|
|
3157
3159
|
title: o.insertFigureReference,
|
|
3158
|
-
children: /* @__PURE__ */
|
|
3160
|
+
children: /* @__PURE__ */ g(Bt, { size: 16 })
|
|
3159
3161
|
}
|
|
3160
3162
|
)
|
|
3161
3163
|
] }),
|
|
3162
|
-
/* @__PURE__ */
|
|
3164
|
+
/* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" }),
|
|
3163
3165
|
d && /* @__PURE__ */ L(je, { children: [
|
|
3164
|
-
/* @__PURE__ */
|
|
3165
|
-
/* @__PURE__ */
|
|
3166
|
-
/* @__PURE__ */
|
|
3166
|
+
/* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: o.currentFigure }),
|
|
3167
|
+
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: o.figureId }),
|
|
3168
|
+
/* @__PURE__ */ g(
|
|
3167
3169
|
"input",
|
|
3168
3170
|
{
|
|
3169
|
-
ref:
|
|
3171
|
+
ref: y,
|
|
3170
3172
|
type: "text",
|
|
3171
3173
|
value: f,
|
|
3172
|
-
onChange: (
|
|
3173
|
-
onBlur:
|
|
3174
|
-
onKeyDown: (
|
|
3175
|
-
|
|
3174
|
+
onChange: (v) => p(v.target.value),
|
|
3175
|
+
onBlur: C,
|
|
3176
|
+
onKeyDown: (v) => {
|
|
3177
|
+
v.key === "Enter" && (C(), v.target.blur());
|
|
3176
3178
|
},
|
|
3177
3179
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white w-20",
|
|
3178
3180
|
placeholder: i === "en" ? "Fig.1" : "图1"
|
|
3179
3181
|
}
|
|
3180
3182
|
),
|
|
3181
|
-
/* @__PURE__ */
|
|
3183
|
+
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: o.switchFigureType }),
|
|
3182
3184
|
/* @__PURE__ */ L(
|
|
3183
3185
|
"select",
|
|
3184
3186
|
{
|
|
3185
3187
|
value: u,
|
|
3186
|
-
onChange: (
|
|
3188
|
+
onChange: (v) => x(v.target.value),
|
|
3187
3189
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
|
|
3188
3190
|
children: [
|
|
3189
|
-
/* @__PURE__ */
|
|
3190
|
-
/* @__PURE__ */
|
|
3191
|
-
/* @__PURE__ */
|
|
3191
|
+
/* @__PURE__ */ g("option", { value: "image", children: o.figureContentTypeImage }),
|
|
3192
|
+
/* @__PURE__ */ g("option", { value: "mermaid", children: o.figureContentTypeMermaid }),
|
|
3193
|
+
/* @__PURE__ */ g("option", { value: "drawio", children: o.figureContentTypeDrawio })
|
|
3192
3194
|
]
|
|
3193
3195
|
}
|
|
3194
3196
|
),
|
|
3195
|
-
/* @__PURE__ */
|
|
3197
|
+
/* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" })
|
|
3196
3198
|
] }),
|
|
3197
3199
|
e.isActive("image") && (() => {
|
|
3198
|
-
const
|
|
3200
|
+
const E = e.getAttributes("image").width || "";
|
|
3199
3201
|
return /* @__PURE__ */ L(je, { children: [
|
|
3200
|
-
/* @__PURE__ */
|
|
3201
|
-
["25%", "50%", "75%", "100%"].map((_) => /* @__PURE__ */
|
|
3202
|
+
/* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: i === "zh" ? "图片" : "Image" }),
|
|
3203
|
+
["25%", "50%", "75%", "100%"].map((_) => /* @__PURE__ */ g(
|
|
3202
3204
|
"button",
|
|
3203
3205
|
{
|
|
3204
3206
|
onClick: () => e.chain().focus().updateAttributes("image", { width: _ }).run(),
|
|
3205
|
-
className: `text-xs px-2 py-0.5 rounded border ${
|
|
3207
|
+
className: `text-xs px-2 py-0.5 rounded border ${E === _ ? "bg-blue-50 text-blue-700 border-blue-200" : "bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,
|
|
3206
3208
|
children: _
|
|
3207
3209
|
},
|
|
3208
3210
|
_
|
|
3209
3211
|
)),
|
|
3210
|
-
/* @__PURE__ */
|
|
3212
|
+
/* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" })
|
|
3211
3213
|
] });
|
|
3212
|
-
})()
|
|
3213
|
-
/* @__PURE__ */ m(
|
|
3214
|
-
"button",
|
|
3215
|
-
{
|
|
3216
|
-
onClick: async () => {
|
|
3217
|
-
if (e.chain().focus().deleteSelection().run()) return;
|
|
3218
|
-
const { from: w } = e.state.selection;
|
|
3219
|
-
w > 1 && e.chain().focus().deleteRange({ from: w - 1, to: w }).run();
|
|
3220
|
-
},
|
|
3221
|
-
className: "p-2 hover:bg-red-50 text-red-600 rounded",
|
|
3222
|
-
title: o.deleteSelection,
|
|
3223
|
-
children: /* @__PURE__ */ m(Br, { size: 16 })
|
|
3224
|
-
}
|
|
3225
|
-
)
|
|
3214
|
+
})()
|
|
3226
3215
|
] }) });
|
|
3227
3216
|
}, sn = {
|
|
3228
3217
|
// Invention & Utility Model
|
|
@@ -3242,10 +3231,10 @@ const Xa = (e = {}) => {
|
|
|
3242
3231
|
design_views: ["design_description"],
|
|
3243
3232
|
design_brief: ["design_description", "design_views"]
|
|
3244
3233
|
};
|
|
3245
|
-
function
|
|
3234
|
+
function qs(e, t) {
|
|
3246
3235
|
return (sn[e] || []).filter((r) => !t.has(r));
|
|
3247
3236
|
}
|
|
3248
|
-
function
|
|
3237
|
+
function ei(e) {
|
|
3249
3238
|
const t = [];
|
|
3250
3239
|
return e.state.doc.descendants((n, r) => n.type.name === "patent_title" ? (t.push({
|
|
3251
3240
|
sectionType: "patent_title",
|
|
@@ -3276,10 +3265,10 @@ function on(e) {
|
|
|
3276
3265
|
}
|
|
3277
3266
|
return null;
|
|
3278
3267
|
}
|
|
3279
|
-
function
|
|
3268
|
+
function ti(e, t) {
|
|
3280
3269
|
const n = sn[t];
|
|
3281
3270
|
if (!n || n.length === 0) return [];
|
|
3282
|
-
const r =
|
|
3271
|
+
const r = ei(e), a = new Map(r.map((i) => [i.sectionType, i]));
|
|
3283
3272
|
return n.map((i) => {
|
|
3284
3273
|
const o = a.get(i);
|
|
3285
3274
|
return !o || o.content.trim().length === 0 ? null : {
|
|
@@ -3288,18 +3277,18 @@ function ni(e, t) {
|
|
|
3288
3277
|
};
|
|
3289
3278
|
}).filter((i) => i !== null && i.content.length > 0);
|
|
3290
3279
|
}
|
|
3291
|
-
function
|
|
3280
|
+
function Us(e, t = {}) {
|
|
3292
3281
|
const n = I.getState().editorLanguage, { from: r, to: a } = e.state.selection, i = r !== a ? e.state.doc.textBetween(r, a, " ", "\0") : void 0;
|
|
3293
3282
|
let o = t.sectionType, c = t.targetSectionPos;
|
|
3294
3283
|
if (!o) {
|
|
3295
|
-
const
|
|
3296
|
-
|
|
3284
|
+
const m = on(e);
|
|
3285
|
+
m && (o = m.sectionType, c = m.pos);
|
|
3297
3286
|
}
|
|
3298
|
-
const s = t.scope || (o ? "section" : i ? "selection" : "document"), l = o ?
|
|
3287
|
+
const s = t.scope || (o ? "section" : i ? "selection" : "document"), l = o ? ti(e, o) : void 0;
|
|
3299
3288
|
let d;
|
|
3300
3289
|
if (s === "selection" && r !== a) {
|
|
3301
|
-
const u = Math.max(0, r - 200), f = Math.min(e.state.doc.content.size, a + 200), p = e.state.doc.textBetween(u, r, " ", "\0"),
|
|
3302
|
-
d = `...${p}[SELECTED]${
|
|
3290
|
+
const u = Math.max(0, r - 200), f = Math.min(e.state.doc.content.size, a + 200), p = e.state.doc.textBetween(u, r, " ", "\0"), y = e.state.doc.textBetween(a, f, " ", "\0");
|
|
3291
|
+
d = `...${p}[SELECTED]${y}...`;
|
|
3303
3292
|
}
|
|
3304
3293
|
return {
|
|
3305
3294
|
scope: s,
|
|
@@ -3312,221 +3301,221 @@ function Ws(e, t = {}) {
|
|
|
3312
3301
|
language: n
|
|
3313
3302
|
};
|
|
3314
3303
|
}
|
|
3315
|
-
const
|
|
3304
|
+
const ni = ({ editor: e, onSelectionOptimize: t }) => {
|
|
3316
3305
|
const { addChatReference: n, openChatPanel: r, editorLanguage: a } = I(), i = a === "zh", o = (l) => Y(
|
|
3317
3306
|
"p-1.5 rounded transition-colors",
|
|
3318
3307
|
l ? "bg-blue-100 text-blue-600" : "text-gray-600 hover:bg-gray-100"
|
|
3319
3308
|
), c = () => {
|
|
3320
3309
|
const { from: l, to: d } = e.state.selection;
|
|
3321
3310
|
if (l === d) return;
|
|
3322
|
-
const
|
|
3311
|
+
const m = e.state.doc.textBetween(l, d, " "), u = on(e);
|
|
3323
3312
|
if (t) {
|
|
3324
|
-
t({ text:
|
|
3313
|
+
t({ text: m, from: l, to: d, sectionType: u == null ? void 0 : u.sectionType });
|
|
3325
3314
|
return;
|
|
3326
3315
|
}
|
|
3327
|
-
n({ text:
|
|
3316
|
+
n({ text: m, from: l, to: d, sectionType: u == null ? void 0 : u.sectionType }), r();
|
|
3328
3317
|
}, s = () => {
|
|
3329
3318
|
const l = e.getAttributes("link").href, d = window.prompt("URL", l || "https://");
|
|
3330
3319
|
d !== null && (d === "" ? e.chain().focus().extendMarkRange("link").unsetLink().run() : e.chain().focus().extendMarkRange("link").setLink({ href: d }).run());
|
|
3331
3320
|
};
|
|
3332
|
-
return /* @__PURE__ */
|
|
3333
|
-
|
|
3321
|
+
return /* @__PURE__ */ g(
|
|
3322
|
+
Jr,
|
|
3334
3323
|
{
|
|
3335
3324
|
editor: e,
|
|
3336
3325
|
shouldShow: ({ editor: l, state: d }) => {
|
|
3337
|
-
const { from:
|
|
3338
|
-
return !(
|
|
3326
|
+
const { from: m, to: u } = d.selection;
|
|
3327
|
+
return !(m === u || l.isActive("codeBlock"));
|
|
3339
3328
|
},
|
|
3340
3329
|
children: /* @__PURE__ */ L("div", { className: "bubble-menu", children: [
|
|
3341
|
-
/* @__PURE__ */
|
|
3330
|
+
/* @__PURE__ */ g(
|
|
3342
3331
|
"button",
|
|
3343
3332
|
{
|
|
3344
3333
|
onClick: () => e.chain().focus().toggleBold().run(),
|
|
3345
3334
|
className: o(e.isActive("bold")),
|
|
3346
3335
|
title: "Bold",
|
|
3347
|
-
children: /* @__PURE__ */
|
|
3336
|
+
children: /* @__PURE__ */ g(Dt, { size: 15 })
|
|
3348
3337
|
}
|
|
3349
3338
|
),
|
|
3350
|
-
/* @__PURE__ */
|
|
3339
|
+
/* @__PURE__ */ g(
|
|
3351
3340
|
"button",
|
|
3352
3341
|
{
|
|
3353
3342
|
onClick: () => e.chain().focus().toggleItalic().run(),
|
|
3354
3343
|
className: o(e.isActive("italic")),
|
|
3355
3344
|
title: "Italic",
|
|
3356
|
-
children: /* @__PURE__ */
|
|
3345
|
+
children: /* @__PURE__ */ g(Rt, { size: 15 })
|
|
3357
3346
|
}
|
|
3358
3347
|
),
|
|
3359
|
-
/* @__PURE__ */
|
|
3348
|
+
/* @__PURE__ */ g(
|
|
3360
3349
|
"button",
|
|
3361
3350
|
{
|
|
3362
3351
|
onClick: () => e.chain().focus().toggleUnderline().run(),
|
|
3363
3352
|
className: o(e.isActive("underline")),
|
|
3364
3353
|
title: "Underline",
|
|
3365
|
-
children: /* @__PURE__ */
|
|
3354
|
+
children: /* @__PURE__ */ g(Mt, { size: 15 })
|
|
3366
3355
|
}
|
|
3367
3356
|
),
|
|
3368
|
-
/* @__PURE__ */
|
|
3357
|
+
/* @__PURE__ */ g(
|
|
3369
3358
|
"button",
|
|
3370
3359
|
{
|
|
3371
3360
|
onClick: () => e.chain().focus().toggleStrike().run(),
|
|
3372
3361
|
className: o(e.isActive("strike")),
|
|
3373
3362
|
title: "Strikethrough",
|
|
3374
|
-
children: /* @__PURE__ */
|
|
3363
|
+
children: /* @__PURE__ */ g(Ft, { size: 15 })
|
|
3375
3364
|
}
|
|
3376
3365
|
),
|
|
3377
|
-
/* @__PURE__ */
|
|
3366
|
+
/* @__PURE__ */ g(
|
|
3378
3367
|
"button",
|
|
3379
3368
|
{
|
|
3380
3369
|
onClick: () => e.chain().focus().toggleCode().run(),
|
|
3381
3370
|
className: o(e.isActive("code")),
|
|
3382
3371
|
title: "Code",
|
|
3383
|
-
children: /* @__PURE__ */
|
|
3372
|
+
children: /* @__PURE__ */ g($t, { size: 15 })
|
|
3384
3373
|
}
|
|
3385
3374
|
),
|
|
3386
|
-
/* @__PURE__ */
|
|
3375
|
+
/* @__PURE__ */ g(
|
|
3387
3376
|
"button",
|
|
3388
3377
|
{
|
|
3389
3378
|
onClick: () => e.chain().focus().toggleSuperscript().run(),
|
|
3390
3379
|
className: o(e.isActive("superscript")),
|
|
3391
3380
|
title: "Superscript",
|
|
3392
|
-
children: /* @__PURE__ */
|
|
3381
|
+
children: /* @__PURE__ */ g(zt, { size: 15 })
|
|
3393
3382
|
}
|
|
3394
3383
|
),
|
|
3395
|
-
/* @__PURE__ */
|
|
3384
|
+
/* @__PURE__ */ g(
|
|
3396
3385
|
"button",
|
|
3397
3386
|
{
|
|
3398
3387
|
onClick: () => e.chain().focus().toggleSubscript().run(),
|
|
3399
3388
|
className: o(e.isActive("subscript")),
|
|
3400
3389
|
title: "Subscript",
|
|
3401
|
-
children: /* @__PURE__ */
|
|
3390
|
+
children: /* @__PURE__ */ g(Ot, { size: 15 })
|
|
3402
3391
|
}
|
|
3403
3392
|
),
|
|
3404
|
-
/* @__PURE__ */
|
|
3405
|
-
/* @__PURE__ */
|
|
3393
|
+
/* @__PURE__ */ g("div", { className: "bubble-menu-divider" }),
|
|
3394
|
+
/* @__PURE__ */ g(
|
|
3406
3395
|
"button",
|
|
3407
3396
|
{
|
|
3408
3397
|
onClick: () => e.chain().focus().toggleHighlight().run(),
|
|
3409
3398
|
className: o(e.isActive("highlight")),
|
|
3410
3399
|
title: "Highlight",
|
|
3411
|
-
children: /* @__PURE__ */
|
|
3400
|
+
children: /* @__PURE__ */ g(Br, { size: 15 })
|
|
3412
3401
|
}
|
|
3413
3402
|
),
|
|
3414
|
-
/* @__PURE__ */
|
|
3403
|
+
/* @__PURE__ */ g(
|
|
3415
3404
|
"button",
|
|
3416
3405
|
{
|
|
3417
3406
|
onClick: s,
|
|
3418
3407
|
className: o(e.isActive("link")),
|
|
3419
3408
|
title: "Link",
|
|
3420
|
-
children: /* @__PURE__ */
|
|
3409
|
+
children: /* @__PURE__ */ g(Ht, { size: 15 })
|
|
3421
3410
|
}
|
|
3422
3411
|
),
|
|
3423
|
-
/* @__PURE__ */
|
|
3424
|
-
/* @__PURE__ */
|
|
3412
|
+
/* @__PURE__ */ g("div", { className: "bubble-menu-divider" }),
|
|
3413
|
+
/* @__PURE__ */ g(
|
|
3425
3414
|
"button",
|
|
3426
3415
|
{
|
|
3427
3416
|
onClick: c,
|
|
3428
3417
|
className: "p-1.5 rounded transition-colors text-purple-500 hover:bg-purple-50",
|
|
3429
3418
|
title: i ? "AI 优化" : "AI Optimize",
|
|
3430
|
-
children: /* @__PURE__ */
|
|
3419
|
+
children: /* @__PURE__ */ g(Hr, { size: 15 })
|
|
3431
3420
|
}
|
|
3432
3421
|
)
|
|
3433
3422
|
] })
|
|
3434
3423
|
}
|
|
3435
3424
|
);
|
|
3436
|
-
},
|
|
3437
|
-
var
|
|
3438
|
-
const [t, n] = $(!1), [r, a] = $(!1), [i, o] = $(""), [c, s] = $(""), [l, d] = $(!1),
|
|
3425
|
+
}, ri = ({ editor: e }) => {
|
|
3426
|
+
var x;
|
|
3427
|
+
const [t, n] = $(!1), [r, a] = $(!1), [i, o] = $(""), [c, s] = $(""), [l, d] = $(!1), m = W(null), u = e.extensionStorage.searchReplace, f = ((x = u == null ? void 0 : u.results) == null ? void 0 : x.length) ?? 0, p = (u == null ? void 0 : u.currentIndex) ?? -1;
|
|
3439
3428
|
M(() => {
|
|
3440
|
-
const
|
|
3429
|
+
const C = (v) => {
|
|
3441
3430
|
n(!0);
|
|
3442
|
-
const
|
|
3443
|
-
|
|
3444
|
-
var
|
|
3445
|
-
return (
|
|
3431
|
+
const E = v.detail;
|
|
3432
|
+
E != null && E.replace && a(!0), requestAnimationFrame(() => {
|
|
3433
|
+
var h;
|
|
3434
|
+
return (h = m.current) == null ? void 0 : h.focus();
|
|
3446
3435
|
});
|
|
3447
3436
|
};
|
|
3448
|
-
return window.addEventListener("editor:toggleSearch",
|
|
3437
|
+
return window.addEventListener("editor:toggleSearch", C), () => window.removeEventListener("editor:toggleSearch", C);
|
|
3449
3438
|
}, []);
|
|
3450
|
-
const
|
|
3451
|
-
(
|
|
3452
|
-
o(
|
|
3439
|
+
const y = ae(
|
|
3440
|
+
(C) => {
|
|
3441
|
+
o(C), e.commands.setSearchTerm(C);
|
|
3453
3442
|
},
|
|
3454
3443
|
[e]
|
|
3455
|
-
),
|
|
3444
|
+
), b = ae(() => {
|
|
3456
3445
|
n(!1), e.commands.clearSearch(), e.commands.focus();
|
|
3457
3446
|
}, [e]);
|
|
3458
3447
|
M(() => {
|
|
3459
|
-
const
|
|
3460
|
-
|
|
3448
|
+
const C = (v) => {
|
|
3449
|
+
v.key === "Escape" && t && b();
|
|
3461
3450
|
};
|
|
3462
|
-
return window.addEventListener("keydown",
|
|
3463
|
-
}, [t,
|
|
3464
|
-
const
|
|
3465
|
-
const
|
|
3466
|
-
d(
|
|
3451
|
+
return window.addEventListener("keydown", C), () => window.removeEventListener("keydown", C);
|
|
3452
|
+
}, [t, b]);
|
|
3453
|
+
const w = () => {
|
|
3454
|
+
const C = !l;
|
|
3455
|
+
d(C), e.commands.setCaseSensitive(C);
|
|
3467
3456
|
};
|
|
3468
3457
|
return t ? /* @__PURE__ */ L("div", { className: "find-replace-bar", children: [
|
|
3469
3458
|
/* @__PURE__ */ L("div", { className: "find-replace-row", children: [
|
|
3470
3459
|
/* @__PURE__ */ L("div", { className: "find-replace-input-group", children: [
|
|
3471
|
-
/* @__PURE__ */
|
|
3460
|
+
/* @__PURE__ */ g(
|
|
3472
3461
|
"input",
|
|
3473
3462
|
{
|
|
3474
|
-
ref:
|
|
3463
|
+
ref: m,
|
|
3475
3464
|
type: "text",
|
|
3476
3465
|
value: i,
|
|
3477
|
-
onChange: (
|
|
3478
|
-
onKeyDown: (
|
|
3479
|
-
|
|
3466
|
+
onChange: (C) => y(C.target.value),
|
|
3467
|
+
onKeyDown: (C) => {
|
|
3468
|
+
C.key === "Enter" && (C.shiftKey ? e.commands.previousSearchResult() : e.commands.nextSearchResult());
|
|
3480
3469
|
},
|
|
3481
3470
|
placeholder: "Find...",
|
|
3482
3471
|
className: "find-replace-input"
|
|
3483
3472
|
}
|
|
3484
3473
|
),
|
|
3485
|
-
/* @__PURE__ */
|
|
3474
|
+
/* @__PURE__ */ g("span", { className: "find-replace-count", children: f > 0 ? `${p + 1}/${f}` : i ? "0" : "" })
|
|
3486
3475
|
] }),
|
|
3487
|
-
/* @__PURE__ */
|
|
3476
|
+
/* @__PURE__ */ g(
|
|
3488
3477
|
"button",
|
|
3489
3478
|
{
|
|
3490
|
-
onClick:
|
|
3479
|
+
onClick: w,
|
|
3491
3480
|
className: Y("find-replace-btn", l && "find-replace-btn--active"),
|
|
3492
3481
|
title: "Case Sensitive",
|
|
3493
|
-
children: /* @__PURE__ */
|
|
3482
|
+
children: /* @__PURE__ */ g(qr, { size: 15 })
|
|
3494
3483
|
}
|
|
3495
3484
|
),
|
|
3496
|
-
/* @__PURE__ */
|
|
3497
|
-
/* @__PURE__ */
|
|
3498
|
-
/* @__PURE__ */
|
|
3485
|
+
/* @__PURE__ */ g("button", { onClick: () => e.commands.previousSearchResult(), className: "find-replace-btn", title: "Previous", children: /* @__PURE__ */ g(Ur, { size: 15 }) }),
|
|
3486
|
+
/* @__PURE__ */ g("button", { onClick: () => e.commands.nextSearchResult(), className: "find-replace-btn", title: "Next", children: /* @__PURE__ */ g(Ut, { size: 15 }) }),
|
|
3487
|
+
/* @__PURE__ */ g(
|
|
3499
3488
|
"button",
|
|
3500
3489
|
{
|
|
3501
|
-
onClick: () => a((
|
|
3490
|
+
onClick: () => a((C) => !C),
|
|
3502
3491
|
className: Y("find-replace-btn", r && "find-replace-btn--active"),
|
|
3503
3492
|
title: "Toggle Replace",
|
|
3504
|
-
children: /* @__PURE__ */
|
|
3493
|
+
children: /* @__PURE__ */ g(gt, { size: 15 })
|
|
3505
3494
|
}
|
|
3506
3495
|
),
|
|
3507
|
-
/* @__PURE__ */
|
|
3496
|
+
/* @__PURE__ */ g("button", { onClick: b, className: "find-replace-btn", title: "Close (Esc)", children: /* @__PURE__ */ g(Wr, { size: 15 }) })
|
|
3508
3497
|
] }),
|
|
3509
3498
|
r && /* @__PURE__ */ L("div", { className: "find-replace-row", children: [
|
|
3510
|
-
/* @__PURE__ */
|
|
3499
|
+
/* @__PURE__ */ g(
|
|
3511
3500
|
"input",
|
|
3512
3501
|
{
|
|
3513
3502
|
type: "text",
|
|
3514
3503
|
value: c,
|
|
3515
|
-
onChange: (
|
|
3516
|
-
s(
|
|
3504
|
+
onChange: (C) => {
|
|
3505
|
+
s(C.target.value), e.commands.setReplaceTerm(C.target.value);
|
|
3517
3506
|
},
|
|
3518
|
-
onKeyDown: (
|
|
3519
|
-
|
|
3507
|
+
onKeyDown: (C) => {
|
|
3508
|
+
C.key === "Enter" && e.commands.replaceCurrent();
|
|
3520
3509
|
},
|
|
3521
3510
|
placeholder: "Replace...",
|
|
3522
3511
|
className: "find-replace-input"
|
|
3523
3512
|
}
|
|
3524
3513
|
),
|
|
3525
|
-
/* @__PURE__ */
|
|
3526
|
-
/* @__PURE__ */
|
|
3514
|
+
/* @__PURE__ */ g("button", { onClick: () => e.commands.replaceCurrent(), className: "find-replace-btn", title: "Replace", children: /* @__PURE__ */ g(gt, { size: 15 }) }),
|
|
3515
|
+
/* @__PURE__ */ g("button", { onClick: () => e.commands.replaceAll(), className: "find-replace-btn", title: "Replace All", children: /* @__PURE__ */ g(jr, { size: 15 }) })
|
|
3527
3516
|
] })
|
|
3528
3517
|
] }) : null;
|
|
3529
|
-
},
|
|
3518
|
+
}, ai = ({ editor: e }) => {
|
|
3530
3519
|
const { editorLanguage: t } = I(), n = t === "zh", r = At(() => {
|
|
3531
3520
|
const a = e.state, o = a.doc.textBetween(0, a.doc.content.size, " ", "\0").replace(/\s/g, "").length, { from: c, to: s } = a.selection;
|
|
3532
3521
|
let l = 0;
|
|
@@ -3544,19 +3533,19 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3544
3533
|
r.selectionCount
|
|
3545
3534
|
] })
|
|
3546
3535
|
] });
|
|
3547
|
-
},
|
|
3536
|
+
}, ii = {
|
|
3548
3537
|
empty: "○",
|
|
3549
3538
|
filled: "●"
|
|
3550
|
-
},
|
|
3539
|
+
}, si = {
|
|
3551
3540
|
empty: "text-gray-400",
|
|
3552
3541
|
filled: "text-green-500"
|
|
3553
|
-
},
|
|
3542
|
+
}, oi = /* @__PURE__ */ new Set([
|
|
3554
3543
|
"technical_field",
|
|
3555
3544
|
"background_art",
|
|
3556
3545
|
"summary",
|
|
3557
3546
|
"drawing_description",
|
|
3558
3547
|
"detailed_description"
|
|
3559
|
-
]),
|
|
3548
|
+
]), ci = ({ editor: e }) => {
|
|
3560
3549
|
const { editorLanguage: t } = I(), n = H(t), [r, a] = $(!1), [i, o] = $(0);
|
|
3561
3550
|
M(() => {
|
|
3562
3551
|
const s = () => o((l) => l + 1);
|
|
@@ -3567,21 +3556,21 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3567
3556
|
const c = At(() => {
|
|
3568
3557
|
const s = [];
|
|
3569
3558
|
let l = !1;
|
|
3570
|
-
return e.state.doc.descendants((d,
|
|
3559
|
+
return e.state.doc.descendants((d, m) => {
|
|
3571
3560
|
if (d.type.name === "patent_title") {
|
|
3572
3561
|
if (!l) {
|
|
3573
|
-
const
|
|
3562
|
+
const y = typeof n.bookTitle_description == "string" ? n.bookTitle_description : "说明书";
|
|
3574
3563
|
s.push({
|
|
3575
3564
|
type: "book-group",
|
|
3576
|
-
pos:
|
|
3577
|
-
title:
|
|
3565
|
+
pos: m,
|
|
3566
|
+
title: y,
|
|
3578
3567
|
charCount: 0
|
|
3579
3568
|
}), l = !0;
|
|
3580
3569
|
}
|
|
3581
3570
|
const u = d.textContent || "", f = u.trim().length > 0, p = typeof n.patentTitlePlaceholder == "string" ? n.patentTitlePlaceholder : "Patent Title";
|
|
3582
3571
|
return s.push({
|
|
3583
3572
|
type: "section",
|
|
3584
|
-
pos:
|
|
3573
|
+
pos: m,
|
|
3585
3574
|
title: f ? u.trim() : p,
|
|
3586
3575
|
state: f ? "filled" : "empty",
|
|
3587
3576
|
charCount: u.replace(/\s/g, "").length,
|
|
@@ -3589,13 +3578,13 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3589
3578
|
}), !1;
|
|
3590
3579
|
}
|
|
3591
3580
|
if (d.type.name === "patent_section") {
|
|
3592
|
-
const u = d.attrs.sectionType, f =
|
|
3581
|
+
const u = d.attrs.sectionType, f = oi.has(u), p = `sectionTitle_${u}`, y = typeof n[p] == "string" ? n[p] : u, b = d.textContent || "", w = b.trim().length > 0;
|
|
3593
3582
|
return s.push({
|
|
3594
3583
|
type: "section",
|
|
3595
|
-
pos:
|
|
3596
|
-
title:
|
|
3597
|
-
state:
|
|
3598
|
-
charCount:
|
|
3584
|
+
pos: m,
|
|
3585
|
+
title: y,
|
|
3586
|
+
state: w ? "filled" : "empty",
|
|
3587
|
+
charCount: b.replace(/\s/g, "").length,
|
|
3599
3588
|
indent: f
|
|
3600
3589
|
}), !1;
|
|
3601
3590
|
}
|
|
@@ -3603,7 +3592,7 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3603
3592
|
const u = d.attrs.level, f = d.textContent || "";
|
|
3604
3593
|
return f.trim() && s.push({
|
|
3605
3594
|
type: "heading",
|
|
3606
|
-
pos:
|
|
3595
|
+
pos: m,
|
|
3607
3596
|
title: f,
|
|
3608
3597
|
level: u,
|
|
3609
3598
|
charCount: f.replace(/\s/g, "").length
|
|
@@ -3612,30 +3601,30 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3612
3601
|
return !0;
|
|
3613
3602
|
}), s;
|
|
3614
3603
|
}, [e, i, n]);
|
|
3615
|
-
return r ? /* @__PURE__ */
|
|
3604
|
+
return r ? /* @__PURE__ */ g("div", { className: "outline-panel outline-panel--collapsed", children: /* @__PURE__ */ g(
|
|
3616
3605
|
"button",
|
|
3617
3606
|
{
|
|
3618
3607
|
onClick: () => a(!1),
|
|
3619
3608
|
className: "outline-panel-toggle",
|
|
3620
3609
|
title: t === "zh" ? "展开大纲" : "Expand Outline",
|
|
3621
|
-
children: /* @__PURE__ */
|
|
3610
|
+
children: /* @__PURE__ */ g(Gr, { size: 16 })
|
|
3622
3611
|
}
|
|
3623
3612
|
) }) : /* @__PURE__ */ L("div", { className: "outline-panel", children: [
|
|
3624
3613
|
/* @__PURE__ */ L("div", { className: "outline-panel-header", children: [
|
|
3625
|
-
/* @__PURE__ */
|
|
3626
|
-
/* @__PURE__ */
|
|
3627
|
-
/* @__PURE__ */
|
|
3614
|
+
/* @__PURE__ */ g(qt, { size: 14 }),
|
|
3615
|
+
/* @__PURE__ */ g("span", { children: t === "zh" ? "文档大纲" : "Outline" }),
|
|
3616
|
+
/* @__PURE__ */ g(
|
|
3628
3617
|
"button",
|
|
3629
3618
|
{
|
|
3630
3619
|
onClick: () => a(!0),
|
|
3631
3620
|
className: "outline-panel-toggle ml-auto",
|
|
3632
3621
|
title: t === "zh" ? "收起大纲" : "Collapse Outline",
|
|
3633
|
-
children: /* @__PURE__ */
|
|
3622
|
+
children: /* @__PURE__ */ g(Vr, { size: 14 })
|
|
3634
3623
|
}
|
|
3635
3624
|
)
|
|
3636
3625
|
] }),
|
|
3637
3626
|
/* @__PURE__ */ L("div", { className: "outline-panel-list", children: [
|
|
3638
|
-
c.length === 0 && /* @__PURE__ */
|
|
3627
|
+
c.length === 0 && /* @__PURE__ */ g("div", { className: "outline-panel-empty", children: t === "zh" ? "暂无章节" : "No sections yet" }),
|
|
3639
3628
|
c.map((s, l) => /* @__PURE__ */ L(
|
|
3640
3629
|
"button",
|
|
3641
3630
|
{
|
|
@@ -3652,22 +3641,22 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3652
3641
|
}));
|
|
3653
3642
|
},
|
|
3654
3643
|
children: [
|
|
3655
|
-
s.type === "section" && s.state && /* @__PURE__ */
|
|
3656
|
-
/* @__PURE__ */
|
|
3657
|
-
s.type !== "book-group" && /* @__PURE__ */
|
|
3644
|
+
s.type === "section" && s.state && /* @__PURE__ */ g("span", { className: Y("outline-item-state", si[s.state]), children: ii[s.state] || "○" }),
|
|
3645
|
+
/* @__PURE__ */ g("span", { className: "outline-item-title", children: s.title }),
|
|
3646
|
+
s.type !== "book-group" && /* @__PURE__ */ g("span", { className: "outline-item-count", children: s.charCount })
|
|
3658
3647
|
]
|
|
3659
3648
|
},
|
|
3660
3649
|
`${s.pos}-${l}`
|
|
3661
3650
|
))
|
|
3662
3651
|
] })
|
|
3663
3652
|
] });
|
|
3664
|
-
},
|
|
3653
|
+
}, li = ({
|
|
3665
3654
|
editor: e,
|
|
3666
3655
|
mode: t = "edit",
|
|
3667
3656
|
className: n
|
|
3668
3657
|
}) => (M(() => {
|
|
3669
3658
|
e.setEditable(t === "edit");
|
|
3670
|
-
}, [e, t]), /* @__PURE__ */
|
|
3659
|
+
}, [e, t]), /* @__PURE__ */ g(
|
|
3671
3660
|
"div",
|
|
3672
3661
|
{
|
|
3673
3662
|
className: Y(
|
|
@@ -3675,25 +3664,26 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3675
3664
|
t === "readonly" ? "cursor-default" : "cursor-text",
|
|
3676
3665
|
n
|
|
3677
3666
|
),
|
|
3678
|
-
children: /* @__PURE__ */
|
|
3667
|
+
children: /* @__PURE__ */ g(In, { editor: e, className: "h-full" })
|
|
3679
3668
|
}
|
|
3680
|
-
)), cn = "patent-editor-draft",
|
|
3669
|
+
)), cn = "patent-editor-draft", di = 1500, ui = () => {
|
|
3681
3670
|
try {
|
|
3682
3671
|
const e = localStorage.getItem(cn);
|
|
3683
3672
|
return e ? JSON.parse(e) : null;
|
|
3684
3673
|
} catch {
|
|
3685
3674
|
return null;
|
|
3686
3675
|
}
|
|
3687
|
-
},
|
|
3676
|
+
}, mi = ({
|
|
3688
3677
|
initialContent: e,
|
|
3689
3678
|
onChange: t,
|
|
3690
3679
|
className: n,
|
|
3691
3680
|
readOnly: r = !1,
|
|
3692
3681
|
editable: a = !0,
|
|
3693
3682
|
onEditorReady: i,
|
|
3694
|
-
onSelectionOptimize: o
|
|
3683
|
+
onSelectionOptimize: o,
|
|
3684
|
+
patchEditorId: c = "default"
|
|
3695
3685
|
}) => {
|
|
3696
|
-
const { setEditor:
|
|
3686
|
+
const { setEditor: s, setDocument: l, editorLanguage: d, autoSaveStatus: m, ai: u } = I(), { setAutoSaveStatus: f, setLastSavedAt: p } = I(), y = W(null), b = e || (t ? null : ui()) || {
|
|
3697
3687
|
type: "doc",
|
|
3698
3688
|
content: [
|
|
3699
3689
|
{
|
|
@@ -3701,26 +3691,27 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3701
3691
|
content: [{ type: "text", text: "" }]
|
|
3702
3692
|
}
|
|
3703
3693
|
]
|
|
3704
|
-
},
|
|
3694
|
+
}, w = ae((h) => {
|
|
3705
3695
|
try {
|
|
3706
|
-
|
|
3696
|
+
f("saving"), localStorage.setItem(cn, JSON.stringify(h)), f("saved"), p(/* @__PURE__ */ new Date());
|
|
3707
3697
|
} catch {
|
|
3708
|
-
|
|
3698
|
+
f("error");
|
|
3709
3699
|
}
|
|
3710
|
-
}, [
|
|
3711
|
-
|
|
3700
|
+
}, [f, p]), x = Nn(
|
|
3701
|
+
Ka({
|
|
3702
|
+
extensions: [fa.configure({ editorId: c })],
|
|
3712
3703
|
content: b,
|
|
3713
|
-
onUpdate: ({ editor:
|
|
3714
|
-
const
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
},
|
|
3704
|
+
onUpdate: ({ editor: h }) => {
|
|
3705
|
+
const _ = h.getJSON();
|
|
3706
|
+
l(_), B.notifyStateChange(h), t && t(_), t || (y.current && clearTimeout(y.current), y.current = setTimeout(() => {
|
|
3707
|
+
w(_);
|
|
3708
|
+
}, di));
|
|
3718
3709
|
},
|
|
3719
|
-
onCreate: ({ editor:
|
|
3720
|
-
|
|
3710
|
+
onCreate: ({ editor: h }) => {
|
|
3711
|
+
s(h), i == null || i(h), B.initializePlugins(h), B.notifyStateChange(h);
|
|
3721
3712
|
},
|
|
3722
|
-
onSelectionUpdate: ({ editor:
|
|
3723
|
-
B.notifySelectionChange(
|
|
3713
|
+
onSelectionUpdate: ({ editor: h }) => {
|
|
3714
|
+
B.notifySelectionChange(h);
|
|
3724
3715
|
},
|
|
3725
3716
|
editorProps: {
|
|
3726
3717
|
attributes: {
|
|
@@ -3728,41 +3719,41 @@ const ri = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3728
3719
|
}
|
|
3729
3720
|
}
|
|
3730
3721
|
})
|
|
3731
|
-
),
|
|
3722
|
+
), C = W(!1);
|
|
3732
3723
|
if (M(() => {
|
|
3733
|
-
if (!(!
|
|
3734
|
-
if (!
|
|
3735
|
-
|
|
3724
|
+
if (!(!x || !e)) {
|
|
3725
|
+
if (!C.current) {
|
|
3726
|
+
C.current = !0;
|
|
3736
3727
|
return;
|
|
3737
3728
|
}
|
|
3738
|
-
|
|
3729
|
+
x.commands.setContent(e);
|
|
3739
3730
|
}
|
|
3740
|
-
}, [
|
|
3741
|
-
|
|
3742
|
-
}, [
|
|
3743
|
-
|
|
3744
|
-
}, [
|
|
3731
|
+
}, [x, e]), M(() => () => {
|
|
3732
|
+
y.current && clearTimeout(y.current), x && (B.destroyPlugins(x), x.destroy());
|
|
3733
|
+
}, [x]), M(() => {
|
|
3734
|
+
x && B.notifyStateChange(x);
|
|
3735
|
+
}, [x, d]), !x)
|
|
3745
3736
|
return null;
|
|
3746
|
-
const
|
|
3737
|
+
const v = H(d), E = m === "saving" ? v.autoSaveSaving : m === "saved" ? v.autoSaveSaved : m === "error" ? v.autoSaveError : "";
|
|
3747
3738
|
return /* @__PURE__ */ L("div", { className: `editor-container flex flex-col h-full ${n}`, children: [
|
|
3748
3739
|
!r && /* @__PURE__ */ L("div", { className: "flex items-center", children: [
|
|
3749
|
-
/* @__PURE__ */
|
|
3750
|
-
|
|
3740
|
+
/* @__PURE__ */ g(Za, { editor: x }),
|
|
3741
|
+
E && /* @__PURE__ */ g("span", { className: `auto-save-indicator auto-save-indicator--${m} ml-2`, children: E })
|
|
3751
3742
|
] }),
|
|
3752
|
-
!r &&
|
|
3753
|
-
!r &&
|
|
3754
|
-
!r &&
|
|
3743
|
+
!r && x && /* @__PURE__ */ g(Qa, { editor: x }),
|
|
3744
|
+
!r && x && /* @__PURE__ */ g(ni, { editor: x, onSelectionOptimize: o }),
|
|
3745
|
+
!r && x && /* @__PURE__ */ g(ri, { editor: x }),
|
|
3755
3746
|
/* @__PURE__ */ L("div", { className: "flex flex-1 overflow-hidden", children: [
|
|
3756
|
-
!r &&
|
|
3757
|
-
/* @__PURE__ */
|
|
3758
|
-
|
|
3747
|
+
!r && x && /* @__PURE__ */ g(ci, { editor: x }),
|
|
3748
|
+
/* @__PURE__ */ g("div", { className: "flex-1 overflow-y-auto bg-white p-4 relative", children: /* @__PURE__ */ g(
|
|
3749
|
+
li,
|
|
3759
3750
|
{
|
|
3760
|
-
editor:
|
|
3761
|
-
mode: r || !a ||
|
|
3751
|
+
editor: x,
|
|
3752
|
+
mode: r || !a || u.status === "streaming" && u.activeSectionType === "claims" ? "readonly" : "edit"
|
|
3762
3753
|
}
|
|
3763
3754
|
) })
|
|
3764
3755
|
] }),
|
|
3765
|
-
!r && /* @__PURE__ */
|
|
3756
|
+
!r && /* @__PURE__ */ g(ai, { editor: x })
|
|
3766
3757
|
] });
|
|
3767
3758
|
};
|
|
3768
3759
|
function ln(e) {
|
|
@@ -3788,13 +3779,13 @@ function ln(e) {
|
|
|
3788
3779
|
continue;
|
|
3789
3780
|
}
|
|
3790
3781
|
if (!d.startsWith("data: ")) continue;
|
|
3791
|
-
const
|
|
3792
|
-
if (
|
|
3782
|
+
const m = d.slice(6).trim();
|
|
3783
|
+
if (m === "[DONE]") {
|
|
3793
3784
|
a.enqueue({ type: "done" }), a.close();
|
|
3794
3785
|
return;
|
|
3795
3786
|
}
|
|
3796
3787
|
try {
|
|
3797
|
-
const u = JSON.parse(
|
|
3788
|
+
const u = JSON.parse(m), f = l || u.type;
|
|
3798
3789
|
if (f === "delta" || !f && u.content != null)
|
|
3799
3790
|
a.enqueue({
|
|
3800
3791
|
type: "delta",
|
|
@@ -3817,7 +3808,7 @@ function ln(e) {
|
|
|
3817
3808
|
}
|
|
3818
3809
|
});
|
|
3819
3810
|
}
|
|
3820
|
-
function
|
|
3811
|
+
function gi(e, t) {
|
|
3821
3812
|
let n = null;
|
|
3822
3813
|
return {
|
|
3823
3814
|
async request(r) {
|
|
@@ -3839,7 +3830,7 @@ function fi(e, t) {
|
|
|
3839
3830
|
}
|
|
3840
3831
|
};
|
|
3841
3832
|
}
|
|
3842
|
-
function
|
|
3833
|
+
function fi(e, t) {
|
|
3843
3834
|
let n = null;
|
|
3844
3835
|
const r = e.replace(/\/+$/, "");
|
|
3845
3836
|
async function a(i, o) {
|
|
@@ -3893,51 +3884,52 @@ function pi(e, t) {
|
|
|
3893
3884
|
}
|
|
3894
3885
|
};
|
|
3895
3886
|
}
|
|
3896
|
-
const
|
|
3897
|
-
({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, editable: i = !0, language: o, aiService: c, chatSessionAPI: s, aiBaseUrl: l, aiHeaders: d, onSelectionOptimize:
|
|
3898
|
-
const { setEditorLanguage:
|
|
3899
|
-
|
|
3900
|
-
}, []),
|
|
3887
|
+
const pi = It(
|
|
3888
|
+
({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, editable: i = !0, language: o, aiService: c, chatSessionAPI: s, aiBaseUrl: l, aiHeaders: d, onSelectionOptimize: m, patchEditorId: u }, f) => {
|
|
3889
|
+
const { setEditorLanguage: p, setAIService: y, setChatSessionAPI: b } = I(), w = W(null), x = ae((v) => {
|
|
3890
|
+
w.current = v;
|
|
3891
|
+
}, []), C = Ee.useMemo(() => {
|
|
3901
3892
|
if (e) return e;
|
|
3902
3893
|
if (t) return tn(t);
|
|
3903
3894
|
}, [e, t]);
|
|
3904
3895
|
return Ee.useEffect(() => {
|
|
3905
|
-
o &&
|
|
3906
|
-
}, [o,
|
|
3907
|
-
c ?
|
|
3908
|
-
}, [c, l, d,
|
|
3909
|
-
s ? b(s) : l && b(
|
|
3910
|
-
}, [s, l, d, b]), Nt(
|
|
3896
|
+
o && p(o);
|
|
3897
|
+
}, [o, p]), Ee.useEffect(() => {
|
|
3898
|
+
c ? y(c) : l && y(gi(l, d));
|
|
3899
|
+
}, [c, l, d, y]), Ee.useEffect(() => {
|
|
3900
|
+
s ? b(s) : l && b(fi(l, d));
|
|
3901
|
+
}, [s, l, d, b]), Nt(f, () => ({
|
|
3911
3902
|
getContent: () => {
|
|
3912
|
-
var
|
|
3913
|
-
return ((
|
|
3903
|
+
var v;
|
|
3904
|
+
return ((v = w.current) == null ? void 0 : v.getJSON()) ?? null;
|
|
3914
3905
|
},
|
|
3915
|
-
setContent: (
|
|
3916
|
-
var
|
|
3917
|
-
(
|
|
3906
|
+
setContent: (v) => {
|
|
3907
|
+
var E;
|
|
3908
|
+
(E = w.current) == null || E.commands.setContent(v);
|
|
3918
3909
|
},
|
|
3919
|
-
getEditor: () =>
|
|
3920
|
-
execCommand: async (
|
|
3910
|
+
getEditor: () => w.current,
|
|
3911
|
+
execCommand: async (v, E) => w.current ? ct(w.current).execCommand(v, E) : null,
|
|
3921
3912
|
focus: () => {
|
|
3922
|
-
var
|
|
3923
|
-
(
|
|
3913
|
+
var v;
|
|
3914
|
+
(v = w.current) == null || v.commands.focus();
|
|
3924
3915
|
}
|
|
3925
|
-
})), /* @__PURE__ */
|
|
3926
|
-
|
|
3916
|
+
})), /* @__PURE__ */ g(
|
|
3917
|
+
mi,
|
|
3927
3918
|
{
|
|
3928
|
-
initialContent:
|
|
3919
|
+
initialContent: C,
|
|
3929
3920
|
onChange: n,
|
|
3930
|
-
onEditorReady:
|
|
3921
|
+
onEditorReady: x,
|
|
3931
3922
|
className: r,
|
|
3932
3923
|
readOnly: a,
|
|
3933
3924
|
editable: i,
|
|
3934
|
-
onSelectionOptimize:
|
|
3925
|
+
onSelectionOptimize: m,
|
|
3926
|
+
patchEditorId: u
|
|
3935
3927
|
}
|
|
3936
3928
|
);
|
|
3937
3929
|
}
|
|
3938
3930
|
);
|
|
3939
|
-
|
|
3940
|
-
async function
|
|
3931
|
+
pi.displayName = "PatentEditor";
|
|
3932
|
+
async function Ws(e, t, n) {
|
|
3941
3933
|
var a, i, o, c;
|
|
3942
3934
|
let r = !1;
|
|
3943
3935
|
(a = n.onStart) == null || a.call(n), n.mode === "section" && typeof n.targetSectionPos == "number" && un(e, n.targetSectionPos);
|
|
@@ -3948,16 +3940,16 @@ async function js(e, t, n) {
|
|
|
3948
3940
|
if (l) break;
|
|
3949
3941
|
if (!d) continue;
|
|
3950
3942
|
(i = n.onChunk) == null || i.call(n, d);
|
|
3951
|
-
const
|
|
3952
|
-
e.view.dispatch(
|
|
3943
|
+
const m = e.state.tr.insertText(d, s);
|
|
3944
|
+
e.view.dispatch(m), s = m.mapping.map(s, 1);
|
|
3953
3945
|
}
|
|
3954
3946
|
n.mode === "section" && typeof n.targetSectionPos == "number" && nt(e, n.targetSectionPos), (o = n.onComplete) == null || o.call(n);
|
|
3955
3947
|
} catch (s) {
|
|
3956
3948
|
(c = n.onError) == null || c.call(n, s instanceof Error ? s : new Error(String(s)));
|
|
3957
3949
|
}
|
|
3958
3950
|
}
|
|
3959
|
-
async function
|
|
3960
|
-
var i, o, c, s, l, d,
|
|
3951
|
+
async function js(e, t, n, r) {
|
|
3952
|
+
var i, o, c, s, l, d, m, u;
|
|
3961
3953
|
const a = new AbortController();
|
|
3962
3954
|
(i = r.onStart) == null || i.call(r), r.mode === "section" && typeof r.targetSectionPos == "number" && un(e, r.targetSectionPos);
|
|
3963
3955
|
try {
|
|
@@ -3971,33 +3963,33 @@ async function Gs(e, t, n, r) {
|
|
|
3971
3963
|
throw new Error(`HTTP ${f.status}: ${f.statusText}`);
|
|
3972
3964
|
const p = (o = f.body) == null ? void 0 : o.getReader();
|
|
3973
3965
|
if (!p) throw new Error("No response body");
|
|
3974
|
-
const
|
|
3975
|
-
let
|
|
3966
|
+
const y = new TextDecoder();
|
|
3967
|
+
let b = dn(e, r), w = "";
|
|
3976
3968
|
for (; ; ) {
|
|
3977
|
-
const { done:
|
|
3978
|
-
if (
|
|
3979
|
-
|
|
3980
|
-
const
|
|
3969
|
+
const { done: x, value: C } = await p.read();
|
|
3970
|
+
if (x) break;
|
|
3971
|
+
w += y.decode(C, { stream: !0 });
|
|
3972
|
+
const v = w.split(`
|
|
3981
3973
|
`);
|
|
3982
|
-
|
|
3983
|
-
for (const
|
|
3984
|
-
if (!
|
|
3985
|
-
const
|
|
3986
|
-
if (
|
|
3974
|
+
w = v.pop() || "";
|
|
3975
|
+
for (const E of v) {
|
|
3976
|
+
if (!E.startsWith("data: ")) continue;
|
|
3977
|
+
const h = E.slice(6).trim();
|
|
3978
|
+
if (h === "[DONE]")
|
|
3987
3979
|
return r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (c = r.onComplete) == null || c.call(r), { abort: () => a.abort() };
|
|
3988
3980
|
try {
|
|
3989
|
-
const _ = JSON.parse(
|
|
3990
|
-
if (!
|
|
3991
|
-
(l = r.onChunk) == null || l.call(r,
|
|
3992
|
-
const N = e.state.tr.insertText(
|
|
3993
|
-
e.view.dispatch(N),
|
|
3981
|
+
const _ = JSON.parse(h), T = _.content || _.text || ((s = _.delta) == null ? void 0 : s.content) || "";
|
|
3982
|
+
if (!T) continue;
|
|
3983
|
+
(l = r.onChunk) == null || l.call(r, T);
|
|
3984
|
+
const N = e.state.tr.insertText(T, b);
|
|
3985
|
+
e.view.dispatch(N), b = N.mapping.map(b, 1);
|
|
3994
3986
|
} catch {
|
|
3995
3987
|
}
|
|
3996
3988
|
}
|
|
3997
3989
|
}
|
|
3998
3990
|
r.mode === "section" && typeof r.targetSectionPos == "number" && nt(e, r.targetSectionPos), (d = r.onComplete) == null || d.call(r);
|
|
3999
3991
|
} catch (f) {
|
|
4000
|
-
f.name === "AbortError" ? (
|
|
3992
|
+
f.name === "AbortError" ? (m = r.onAbort) == null || m.call(r) : (u = r.onError) == null || u.call(r, f instanceof Error ? f : new Error(String(f)));
|
|
4001
3993
|
}
|
|
4002
3994
|
return { abort: () => a.abort() };
|
|
4003
3995
|
}
|
|
@@ -4186,7 +4178,7 @@ function rt(e, t = 30) {
|
|
|
4186
4178
|
}
|
|
4187
4179
|
});
|
|
4188
4180
|
}
|
|
4189
|
-
function
|
|
4181
|
+
function hi(e) {
|
|
4190
4182
|
const t = [], n = $e(e, 3);
|
|
4191
4183
|
for (const r of n)
|
|
4192
4184
|
t.push({ type: "delta", content: r });
|
|
@@ -4198,7 +4190,7 @@ function $e(e, t) {
|
|
|
4198
4190
|
n.push(e.slice(r, r + t));
|
|
4199
4191
|
return n;
|
|
4200
4192
|
}
|
|
4201
|
-
function
|
|
4193
|
+
function yi(e, t, n) {
|
|
4202
4194
|
const r = n === "zh", a = [];
|
|
4203
4195
|
let i;
|
|
4204
4196
|
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) {
|
|
@@ -4246,7 +4238,7 @@ function bi(e, t, n) {
|
|
|
4246
4238
|
a.push({ type: "delta", content: o });
|
|
4247
4239
|
return a.push({ type: "done", usage: { tokens: i.length * 2 } }), a;
|
|
4248
4240
|
}
|
|
4249
|
-
function
|
|
4241
|
+
function Gs() {
|
|
4250
4242
|
let e = null;
|
|
4251
4243
|
return {
|
|
4252
4244
|
async request(t) {
|
|
@@ -4260,7 +4252,7 @@ function Vs() {
|
|
|
4260
4252
|
` : `[Generated based on instruction "${t.instruction}"]
|
|
4261
4253
|
|
|
4262
4254
|
`) + a);
|
|
4263
|
-
const o =
|
|
4255
|
+
const o = hi(i);
|
|
4264
4256
|
return rt(o, 25);
|
|
4265
4257
|
},
|
|
4266
4258
|
abort() {
|
|
@@ -4268,7 +4260,7 @@ function Vs() {
|
|
|
4268
4260
|
}
|
|
4269
4261
|
};
|
|
4270
4262
|
}
|
|
4271
|
-
function
|
|
4263
|
+
function Vs() {
|
|
4272
4264
|
const e = /* @__PURE__ */ new Map();
|
|
4273
4265
|
let t = null, n = null;
|
|
4274
4266
|
return {
|
|
@@ -4311,7 +4303,7 @@ function Js() {
|
|
|
4311
4303
|
status: "done",
|
|
4312
4304
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4313
4305
|
}), i.session.messageCount = i.messages.length, i.session.lastMessage = a.content, i.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
4314
|
-
const c =
|
|
4306
|
+
const c = yi(
|
|
4315
4307
|
a.content,
|
|
4316
4308
|
a.references || [],
|
|
4317
4309
|
a.language
|
|
@@ -4343,7 +4335,7 @@ function Js() {
|
|
|
4343
4335
|
}
|
|
4344
4336
|
};
|
|
4345
4337
|
}
|
|
4346
|
-
function
|
|
4338
|
+
function bi(e) {
|
|
4347
4339
|
const t = [], n = e.replace(/\r\n/g, `
|
|
4348
4340
|
`).trim();
|
|
4349
4341
|
if (!n) return t;
|
|
@@ -4358,12 +4350,12 @@ function vi(e) {
|
|
|
4358
4350
|
if (a.length === 0)
|
|
4359
4351
|
return t.push({ number: 1, text: n, dependsOn: [] }), t;
|
|
4360
4352
|
for (let o = 0; o < a.length; o++) {
|
|
4361
|
-
const c = a[o].index + a[o].matchLength, s = o + 1 < a.length ? a[o + 1].index : n.length, l = n.slice(c, s).trim(), d = a[o].number,
|
|
4362
|
-
t.push({ number: d, text: l, dependsOn:
|
|
4353
|
+
const c = a[o].index + a[o].matchLength, s = o + 1 < a.length ? a[o + 1].index : n.length, l = n.slice(c, s).trim(), d = a[o].number, m = vi(l, d);
|
|
4354
|
+
t.push({ number: d, text: l, dependsOn: m });
|
|
4363
4355
|
}
|
|
4364
4356
|
return t;
|
|
4365
4357
|
}
|
|
4366
|
-
function
|
|
4358
|
+
function vi(e, t) {
|
|
4367
4359
|
const n = [], r = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g;
|
|
4368
4360
|
let a;
|
|
4369
4361
|
for (; (a = r.exec(e)) !== null; ) {
|
|
@@ -4379,18 +4371,18 @@ function wi(e, t) {
|
|
|
4379
4371
|
}
|
|
4380
4372
|
return [...new Set(n)].sort((o, c) => o - c);
|
|
4381
4373
|
}
|
|
4382
|
-
function
|
|
4383
|
-
return
|
|
4374
|
+
function Js(e) {
|
|
4375
|
+
return bi(e).map((n) => ({
|
|
4384
4376
|
type: "paragraph",
|
|
4385
4377
|
content: n.text ? [{ type: "text", text: `${n.number}. ${n.text}` }] : [{ type: "text", text: `${n.number}. ` }]
|
|
4386
4378
|
}));
|
|
4387
4379
|
}
|
|
4388
|
-
const
|
|
4380
|
+
const wi = -1, xi = 1, Ci = 0, at = new we("docDiff");
|
|
4389
4381
|
let Ye = null;
|
|
4390
|
-
function
|
|
4382
|
+
function Ti() {
|
|
4391
4383
|
return Ye || (Ye = new Pt()), Ye;
|
|
4392
4384
|
}
|
|
4393
|
-
function
|
|
4385
|
+
function Si(e, t, n) {
|
|
4394
4386
|
const r = [];
|
|
4395
4387
|
return e.nodesBetween(t, n, (a, i) => {
|
|
4396
4388
|
if (a.isTextblock) {
|
|
@@ -4400,46 +4392,46 @@ function Ei(e, t, n) {
|
|
|
4400
4392
|
return !0;
|
|
4401
4393
|
}), r;
|
|
4402
4394
|
}
|
|
4403
|
-
function
|
|
4404
|
-
const n = e.state.doc, r = n.content.size, { text: a, segments: i } = Gt(e, 0, r), o =
|
|
4395
|
+
function Ks(e, t) {
|
|
4396
|
+
const n = e.state.doc, r = n.content.size, { text: a, segments: i } = Gt(e, 0, r), o = Ti(), c = o.diff_main(t, a);
|
|
4405
4397
|
o.diff_cleanupSemantic(c);
|
|
4406
4398
|
const s = [];
|
|
4407
4399
|
let l = 0;
|
|
4408
4400
|
for (const [u, f] of c)
|
|
4409
|
-
if (u ===
|
|
4401
|
+
if (u === Ci)
|
|
4410
4402
|
l += f.length;
|
|
4411
|
-
else if (u ===
|
|
4403
|
+
else if (u === xi) {
|
|
4412
4404
|
let p = 0;
|
|
4413
4405
|
for (; p < f.length; ) {
|
|
4414
4406
|
for (; p < f.length && f[p] === "\0"; ) p++;
|
|
4415
4407
|
if (p >= f.length) break;
|
|
4416
|
-
const
|
|
4408
|
+
const y = p;
|
|
4417
4409
|
for (; p < f.length && f[p] !== "\0"; ) p++;
|
|
4418
|
-
const
|
|
4419
|
-
if (
|
|
4420
|
-
for (const
|
|
4410
|
+
const b = ye(i, l + y), w = ye(i, l + p);
|
|
4411
|
+
if (b >= 0 && w >= 0 && w > b)
|
|
4412
|
+
for (const x of Si(n, b, w))
|
|
4421
4413
|
s.push(
|
|
4422
|
-
re.inline(
|
|
4414
|
+
re.inline(x.from, x.to, { class: "patch-diff-insert-inline" })
|
|
4423
4415
|
);
|
|
4424
4416
|
}
|
|
4425
4417
|
l += f.length;
|
|
4426
|
-
} else if (u ===
|
|
4418
|
+
} else if (u === wi) {
|
|
4427
4419
|
const p = ye(i, l);
|
|
4428
4420
|
if (p >= 0) {
|
|
4429
|
-
const
|
|
4421
|
+
const y = f.replace(/\0/g, " ");
|
|
4430
4422
|
s.push(
|
|
4431
4423
|
re.widget(
|
|
4432
4424
|
p,
|
|
4433
4425
|
() => {
|
|
4434
|
-
const
|
|
4435
|
-
return
|
|
4426
|
+
const b = document.createElement("span");
|
|
4427
|
+
return b.className = "patch-diff-delete", b.textContent = y, b;
|
|
4436
4428
|
},
|
|
4437
4429
|
{ side: -1 }
|
|
4438
4430
|
)
|
|
4439
4431
|
);
|
|
4440
4432
|
}
|
|
4441
4433
|
}
|
|
4442
|
-
const d = be.create(n, s),
|
|
4434
|
+
const d = be.create(n, s), m = new Be({
|
|
4443
4435
|
key: at,
|
|
4444
4436
|
state: {
|
|
4445
4437
|
init: () => d,
|
|
@@ -4451,24 +4443,24 @@ function Xs(e, t) {
|
|
|
4451
4443
|
}
|
|
4452
4444
|
}
|
|
4453
4445
|
});
|
|
4454
|
-
e.registerPlugin(
|
|
4446
|
+
e.registerPlugin(m);
|
|
4455
4447
|
}
|
|
4456
|
-
function
|
|
4448
|
+
function Xs(e) {
|
|
4457
4449
|
e.unregisterPlugin(at);
|
|
4458
4450
|
}
|
|
4459
|
-
const
|
|
4451
|
+
const Ei = /* @__PURE__ */ new Set([
|
|
4460
4452
|
"abstract",
|
|
4461
4453
|
"abstract_drawing",
|
|
4462
4454
|
"claims",
|
|
4463
4455
|
"drawing_figures"
|
|
4464
|
-
]),
|
|
4456
|
+
]), ki = /* @__PURE__ */ new Set([
|
|
4465
4457
|
"technical_field",
|
|
4466
4458
|
"background_art",
|
|
4467
4459
|
"summary",
|
|
4468
4460
|
"drawing_description",
|
|
4469
4461
|
"detailed_description"
|
|
4470
4462
|
]);
|
|
4471
|
-
function
|
|
4463
|
+
function _i(e, t) {
|
|
4472
4464
|
const n = H(t), r = [];
|
|
4473
4465
|
return e.state.doc.descendants((a) => {
|
|
4474
4466
|
if (a.type.name === "patent_title") {
|
|
@@ -4504,7 +4496,7 @@ function Et(e) {
|
|
|
4504
4496
|
spacing: { before: 240, after: 120 }
|
|
4505
4497
|
});
|
|
4506
4498
|
}
|
|
4507
|
-
function
|
|
4499
|
+
function Ii(e) {
|
|
4508
4500
|
return new He({
|
|
4509
4501
|
children: [new qe({ text: e, bold: !0, size: 36, font: "宋体" })],
|
|
4510
4502
|
alignment: it.CENTER,
|
|
@@ -4518,11 +4510,11 @@ function Ze(e) {
|
|
|
4518
4510
|
indent: { firstLine: he(7) }
|
|
4519
4511
|
});
|
|
4520
4512
|
}
|
|
4521
|
-
function
|
|
4513
|
+
function Ni(e, t) {
|
|
4522
4514
|
const n = H(t), r = [];
|
|
4523
4515
|
let a = !1;
|
|
4524
4516
|
for (const i of e) {
|
|
4525
|
-
if (
|
|
4517
|
+
if (Ei.has(i.sectionType)) {
|
|
4526
4518
|
r.push(St(i.title));
|
|
4527
4519
|
for (const o of i.paragraphs)
|
|
4528
4520
|
r.push(Ze(o));
|
|
@@ -4534,10 +4526,10 @@ function Ai(e, t) {
|
|
|
4534
4526
|
r.push(St(o)), a = !0;
|
|
4535
4527
|
}
|
|
4536
4528
|
for (const o of i.paragraphs)
|
|
4537
|
-
r.push(
|
|
4529
|
+
r.push(Ii(o));
|
|
4538
4530
|
continue;
|
|
4539
4531
|
}
|
|
4540
|
-
if (
|
|
4532
|
+
if (ki.has(i.sectionType)) {
|
|
4541
4533
|
r.push(Et(i.title));
|
|
4542
4534
|
for (const o of i.paragraphs)
|
|
4543
4535
|
r.push(Ze(o));
|
|
@@ -4549,8 +4541,8 @@ function Ai(e, t) {
|
|
|
4549
4541
|
}
|
|
4550
4542
|
return r;
|
|
4551
4543
|
}
|
|
4552
|
-
async function
|
|
4553
|
-
const n =
|
|
4544
|
+
async function Ys(e, t) {
|
|
4545
|
+
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", o = {
|
|
4554
4546
|
properties: {
|
|
4555
4547
|
page: {
|
|
4556
4548
|
margin: {
|
|
@@ -4562,15 +4554,15 @@ async function Zs(e, t) {
|
|
|
4562
4554
|
}
|
|
4563
4555
|
},
|
|
4564
4556
|
children: r
|
|
4565
|
-
}, c = new
|
|
4557
|
+
}, c = new Kr({
|
|
4566
4558
|
sections: [o]
|
|
4567
|
-
}), s = await
|
|
4568
|
-
|
|
4559
|
+
}), s = await Xr.toBlob(c);
|
|
4560
|
+
Yr(s, i);
|
|
4569
4561
|
}
|
|
4570
|
-
async function
|
|
4562
|
+
async function Zs(e) {
|
|
4571
4563
|
window.print();
|
|
4572
4564
|
}
|
|
4573
|
-
function
|
|
4565
|
+
function Qs(e, t) {
|
|
4574
4566
|
const n = [], r = t === "zh";
|
|
4575
4567
|
let a = 0;
|
|
4576
4568
|
const i = () => `v_${++a}`;
|
|
@@ -4623,15 +4615,15 @@ function eo(e, t) {
|
|
|
4623
4615
|
}
|
|
4624
4616
|
if (s === "claims") {
|
|
4625
4617
|
const d = /^(\d+)\s*[.、]/;
|
|
4626
|
-
o.forEach((
|
|
4627
|
-
if (
|
|
4628
|
-
const f =
|
|
4618
|
+
o.forEach((m, u) => {
|
|
4619
|
+
if (m.type.name !== "paragraph") return;
|
|
4620
|
+
const f = m.textContent.trim(), p = d.exec(f);
|
|
4629
4621
|
if (!p) return;
|
|
4630
|
-
const
|
|
4622
|
+
const y = p[1];
|
|
4631
4623
|
f.length > 0 && !f.endsWith("。") && !f.endsWith(".") && n.push({
|
|
4632
4624
|
id: i(),
|
|
4633
4625
|
severity: "warning",
|
|
4634
|
-
message: r ? `权利要求${
|
|
4626
|
+
message: r ? `权利要求${y}末尾应以句号结束` : `Claim ${y} should end with a period`,
|
|
4635
4627
|
pos: c + 1 + u
|
|
4636
4628
|
});
|
|
4637
4629
|
});
|
|
@@ -4641,8 +4633,8 @@ function eo(e, t) {
|
|
|
4641
4633
|
return !0;
|
|
4642
4634
|
}), n;
|
|
4643
4635
|
}
|
|
4644
|
-
const
|
|
4645
|
-
function
|
|
4636
|
+
const Ai = /^(\d+)\s*[.、]\s*/, kt = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g, _t = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
|
|
4637
|
+
function Li(e, t) {
|
|
4646
4638
|
const n = [];
|
|
4647
4639
|
let r;
|
|
4648
4640
|
for (kt.lastIndex = 0; (r = kt.exec(e)) !== null; ) {
|
|
@@ -4659,7 +4651,7 @@ function Pi(e, t) {
|
|
|
4659
4651
|
}
|
|
4660
4652
|
const mn = (e) => {
|
|
4661
4653
|
if (e.type.name === "reference")
|
|
4662
|
-
return
|
|
4654
|
+
return Pi(e);
|
|
4663
4655
|
if (e.type.name === "hardBreak")
|
|
4664
4656
|
return `
|
|
4665
4657
|
`;
|
|
@@ -4669,7 +4661,7 @@ const mn = (e) => {
|
|
|
4669
4661
|
return e.forEach((n) => {
|
|
4670
4662
|
t += mn(n);
|
|
4671
4663
|
}), t;
|
|
4672
|
-
},
|
|
4664
|
+
}, Pi = (e) => {
|
|
4673
4665
|
const t = e.attrs.lang === "en" ? "en" : "zh", n = e.attrs.targetType === "figure" ? "figure" : "claim", r = typeof e.attrs.displayText == "string" ? e.attrs.displayText.trim() : "";
|
|
4674
4666
|
if (r)
|
|
4675
4667
|
return r;
|
|
@@ -4679,17 +4671,17 @@ const mn = (e) => {
|
|
|
4679
4671
|
}
|
|
4680
4672
|
const a = Number(e.attrs.resolvedNumber);
|
|
4681
4673
|
return Number.isFinite(a) ? t === "en" ? `Claim ${a}` : `权利要求${a}` : t === "en" ? "Claim ?" : "权利要求?";
|
|
4682
|
-
},
|
|
4674
|
+
}, eo = (e) => {
|
|
4683
4675
|
const t = [];
|
|
4684
4676
|
return e.state.doc.descendants((n, r) => {
|
|
4685
4677
|
if (n.type.name === "patent_section")
|
|
4686
4678
|
return n.attrs.sectionType === "claims";
|
|
4687
4679
|
if (n.type.name !== "paragraph") return !0;
|
|
4688
|
-
const a = mn(n).trim(), i =
|
|
4680
|
+
const a = mn(n).trim(), i = Ai.exec(a);
|
|
4689
4681
|
if (!i) return !0;
|
|
4690
4682
|
const o = parseInt(i[1], 10);
|
|
4691
4683
|
if (!Number.isFinite(o) || o <= 0) return !0;
|
|
4692
|
-
const c = a.slice(i[0].length).trim(), s =
|
|
4684
|
+
const c = a.slice(i[0].length).trim(), s = Li(c, o);
|
|
4693
4685
|
return t.push({
|
|
4694
4686
|
claimId: `claim_${o}`,
|
|
4695
4687
|
number: o,
|
|
@@ -4701,40 +4693,40 @@ const mn = (e) => {
|
|
|
4701
4693
|
}), t;
|
|
4702
4694
|
};
|
|
4703
4695
|
export {
|
|
4704
|
-
|
|
4696
|
+
mi as EditorView,
|
|
4705
4697
|
jt as PatchDiffPluginKey,
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4698
|
+
pi as PatentEditor,
|
|
4699
|
+
Bs as acceptAllPatches,
|
|
4700
|
+
zs as acceptPatch,
|
|
4701
|
+
Ks as applyDocDiffDecorations,
|
|
4702
|
+
Us as buildAIContext,
|
|
4703
|
+
Js as buildClaimsJSONContent,
|
|
4712
4704
|
tn as buildPatentDocument,
|
|
4713
|
-
|
|
4714
|
-
|
|
4705
|
+
$s as clearPatches,
|
|
4706
|
+
fi as createChatSessionAPI,
|
|
4715
4707
|
ct as createCommandExecutor,
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4708
|
+
Ka as createEditorConfig,
|
|
4709
|
+
Gs as createMockAIService,
|
|
4710
|
+
Vs as createMockChatSessionAPI,
|
|
4711
|
+
gi as createSSEAdapter,
|
|
4712
|
+
Zs as exportToPdf,
|
|
4713
|
+
Ys as exportToWord,
|
|
4714
|
+
eo as extractClaimsFromEditor,
|
|
4723
4715
|
on as findSectionAtCursor,
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4716
|
+
ei as getAllSections,
|
|
4717
|
+
qs as getMissingSectionDeps,
|
|
4718
|
+
Ms as getPatches,
|
|
4719
|
+
Rs as onPatchChange,
|
|
4728
4720
|
B as pluginManager,
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4721
|
+
Hs as rejectAllPatches,
|
|
4722
|
+
Os as rejectPatch,
|
|
4723
|
+
Xs as removeDocDiffDecorations,
|
|
4724
|
+
Ds as resolvePatchTarget,
|
|
4733
4725
|
sn as sectionContextDeps,
|
|
4734
|
-
|
|
4726
|
+
Fs as setPatches,
|
|
4735
4727
|
I as useEditorStore,
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4728
|
+
Qs as validatePatentDocument,
|
|
4729
|
+
Ws as writeStream,
|
|
4730
|
+
js as writeStreamFromSSE
|
|
4739
4731
|
};
|
|
4740
4732
|
//# sourceMappingURL=lib.js.map
|