patent-editor 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib.css +1 -1
- package/dist/lib.js +1235 -1175
- package/dist/lib.js.map +1 -1
- package/package.json +1 -1
package/dist/lib.js
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var Nn = Object.defineProperty;
|
|
2
|
+
var kn = (e, t, n) => t in e ? Nn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var Re = (e, t, n) => kn(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { jsx as g, jsxs as A, Fragment as we } from "react/jsx-runtime";
|
|
5
|
-
import
|
|
6
|
-
import { Extension as
|
|
7
|
-
import
|
|
5
|
+
import De, { forwardRef as jt, useState as z, useEffect as B, useCallback as de, useImperativeHandle as Wt, useRef as X, useMemo as Te } from "react";
|
|
6
|
+
import { Extension as Je, ReactRenderer as _n, Node as ee, mergeAttributes as ae, NodeViewWrapper as An, ReactNodeViewRenderer as qt, useEditorState as Ln, EditorContent as Pn, useEditor as Rn } from "@tiptap/react";
|
|
7
|
+
import Dn from "@tiptap/extension-document";
|
|
8
8
|
import Mn from "@tiptap/extension-paragraph";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import { Table as
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import { dropCursor as
|
|
27
|
-
import { gapCursor as
|
|
28
|
-
import
|
|
29
|
-
import { PluginKey as
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import { create as
|
|
33
|
-
import { DecorationSet as
|
|
34
|
-
import { diff_match_patch as
|
|
35
|
-
import
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import { TextStyle as
|
|
44
|
-
import
|
|
45
|
-
import
|
|
46
|
-
import
|
|
9
|
+
import $n from "@tiptap/extension-text";
|
|
10
|
+
import On from "@tiptap/extension-heading";
|
|
11
|
+
import Fn from "@tiptap/extension-bullet-list";
|
|
12
|
+
import zn from "@tiptap/extension-ordered-list";
|
|
13
|
+
import Bn from "@tiptap/extension-list-item";
|
|
14
|
+
import Hn from "@tiptap/extension-blockquote";
|
|
15
|
+
import Un from "@tiptap/extension-code-block";
|
|
16
|
+
import jn from "@tiptap/extension-horizontal-rule";
|
|
17
|
+
import Wn from "@tiptap/extension-task-list";
|
|
18
|
+
import qn from "@tiptap/extension-task-item";
|
|
19
|
+
import Gn from "@tiptap/extension-image";
|
|
20
|
+
import { Table as Vn } from "@tiptap/extension-table";
|
|
21
|
+
import Kn from "@tiptap/extension-table-row";
|
|
22
|
+
import Jn from "@tiptap/extension-table-cell";
|
|
23
|
+
import Xn from "@tiptap/extension-table-header";
|
|
24
|
+
import Qn from "@tiptap/extension-placeholder";
|
|
25
|
+
import Yn from "@tiptap/extension-history";
|
|
26
|
+
import { dropCursor as Zn } from "prosemirror-dropcursor";
|
|
27
|
+
import { gapCursor as er } from "prosemirror-gapcursor";
|
|
28
|
+
import tr from "@tiptap/extension-text-align";
|
|
29
|
+
import { PluginKey as _e, Plugin as Xe, TextSelection as Ie } from "@tiptap/pm/state";
|
|
30
|
+
import nr from "@tiptap/suggestion";
|
|
31
|
+
import rr from "tippy.js";
|
|
32
|
+
import { create as ar } from "zustand";
|
|
33
|
+
import { DecorationSet as Ne, Decoration as le } from "@tiptap/pm/view";
|
|
34
|
+
import { diff_match_patch as Gt } from "diff-match-patch";
|
|
35
|
+
import sr from "@tiptap/extension-bold";
|
|
36
|
+
import ir from "@tiptap/extension-italic";
|
|
37
|
+
import or from "@tiptap/extension-underline";
|
|
38
|
+
import cr from "@tiptap/extension-strike";
|
|
39
|
+
import lr from "@tiptap/extension-code";
|
|
40
|
+
import dr from "@tiptap/extension-superscript";
|
|
41
|
+
import ur from "@tiptap/extension-subscript";
|
|
42
|
+
import mr from "@tiptap/extension-link";
|
|
43
|
+
import { TextStyle as fr } from "@tiptap/extension-text-style";
|
|
44
|
+
import gr from "@tiptap/extension-color";
|
|
45
|
+
import pr from "@tiptap/extension-highlight";
|
|
46
|
+
import hr from "katex";
|
|
47
47
|
import "katex/dist/katex.min.css";
|
|
48
48
|
import "mathlive";
|
|
49
|
-
import { findWrapping as
|
|
50
|
-
import { Slice as
|
|
51
|
-
import { createPortal as
|
|
52
|
-
import { Undo2 as
|
|
49
|
+
import { findWrapping as br } from "@tiptap/pm/transform";
|
|
50
|
+
import { Slice as yr, Fragment as vr } from "@tiptap/pm/model";
|
|
51
|
+
import { createPortal as Cr } from "react-dom";
|
|
52
|
+
import { Undo2 as wr, Redo2 as xr, Bold as Vt, Italic as Kt, Underline as Jt, Strikethrough as Xt, Code as Qt, Superscript as Yt, Subscript as Zt, Pilcrow as Sr, Heading1 as Tr, Heading2 as Ir, Heading3 as Er, AlignLeft as Nr, AlignCenter as kr, AlignRight as _r, AlignJustify as Ar, List as Lr, ListOrdered as Pr, Quote as Rr, FileCode2 as Dr, Table as Mr, Minus as $r, CheckSquare as Or, Image as en, Link2 as pt, FileText as tn, Box as Fr, Workflow as zr, FunctionSquare as Br, Sigma as Hr, GitGraph as Ur, Square as Tt, Download as jr, ChevronDown as nn, Trash2 as Wr, Highlighter as qr, Sparkles as Gr, CaseSensitive as Vr, ChevronUp as Kr, Replace as It, X as Jr, ReplaceAll as Xr, PanelLeft as Qr, PanelLeftClose as Yr } from "lucide-react";
|
|
53
53
|
import re from "clsx";
|
|
54
|
-
import { convertMillimetersToTwip as Se, Document as
|
|
55
|
-
import { saveAs as
|
|
56
|
-
import { BubbleMenu as
|
|
57
|
-
const
|
|
54
|
+
import { convertMillimetersToTwip as Se, Document as Zr, Packer as ea, Paragraph as Qe, AlignmentType as ht, TextRun as Ye } from "docx";
|
|
55
|
+
import { saveAs as ta } from "file-saver";
|
|
56
|
+
import { BubbleMenu as na } from "@tiptap/react/menus";
|
|
57
|
+
const ra = new _e("slashCommand"), aa = Je.create({
|
|
58
58
|
name: "slashCommand",
|
|
59
59
|
addOptions() {
|
|
60
60
|
return {
|
|
@@ -68,14 +68,14 @@ const na = new ke("slashCommand"), ra = Ve.create({
|
|
|
68
68
|
},
|
|
69
69
|
addProseMirrorPlugins() {
|
|
70
70
|
return [
|
|
71
|
-
|
|
71
|
+
nr({
|
|
72
72
|
editor: this.editor,
|
|
73
73
|
...this.options.suggestion,
|
|
74
|
-
pluginKey:
|
|
74
|
+
pluginKey: ra
|
|
75
75
|
})
|
|
76
76
|
];
|
|
77
77
|
}
|
|
78
|
-
}),
|
|
78
|
+
}), sa = {
|
|
79
79
|
visible: !0,
|
|
80
80
|
activeTab: "chat",
|
|
81
81
|
activeSectionType: null,
|
|
@@ -83,7 +83,7 @@ const na = new ke("slashCommand"), ra = Ve.create({
|
|
|
83
83
|
regenerate: !1,
|
|
84
84
|
chatReferences: [],
|
|
85
85
|
pendingChatMessage: null
|
|
86
|
-
},
|
|
86
|
+
}, k = ar((e) => ({
|
|
87
87
|
editor: null,
|
|
88
88
|
document: null,
|
|
89
89
|
selection: null,
|
|
@@ -94,7 +94,7 @@ const na = new ke("slashCommand"), ra = Ve.create({
|
|
|
94
94
|
aiService: null,
|
|
95
95
|
chatSessionAPI: null,
|
|
96
96
|
chatSessionId: null,
|
|
97
|
-
rightPanel: { ...
|
|
97
|
+
rightPanel: { ...sa },
|
|
98
98
|
setEditor: (t) => e({ editor: t }),
|
|
99
99
|
setDocument: (t) => e({ document: t }),
|
|
100
100
|
setSelection: (t) => e({ selection: t }),
|
|
@@ -162,7 +162,7 @@ const na = new ke("slashCommand"), ra = Ve.create({
|
|
|
162
162
|
setPendingChatMessage: (t) => e((n) => ({
|
|
163
163
|
rightPanel: { ...n.rightPanel, pendingChatMessage: t }
|
|
164
164
|
}))
|
|
165
|
-
})),
|
|
165
|
+
})), rn = jt(
|
|
166
166
|
({ items: e, command: t }, n) => {
|
|
167
167
|
const [r, a] = z(0);
|
|
168
168
|
B(() => {
|
|
@@ -170,19 +170,19 @@ const na = new ke("slashCommand"), ra = Ve.create({
|
|
|
170
170
|
}, [e]);
|
|
171
171
|
const s = de(
|
|
172
172
|
(i) => {
|
|
173
|
-
const
|
|
174
|
-
|
|
173
|
+
const c = e[i];
|
|
174
|
+
c && t(c);
|
|
175
175
|
},
|
|
176
176
|
[e, t]
|
|
177
177
|
);
|
|
178
|
-
return
|
|
179
|
-
onKeyDown: ({ event: i }) => i.key === "ArrowUp" ? (a((
|
|
180
|
-
})), e.length ? /* @__PURE__ */ g("div", { className: "slash-menu", children: e.map((i,
|
|
178
|
+
return Wt(n, () => ({
|
|
179
|
+
onKeyDown: ({ event: i }) => i.key === "ArrowUp" ? (a((c) => (c + e.length - 1) % e.length), !0) : i.key === "ArrowDown" ? (a((c) => (c + 1) % e.length), !0) : i.key === "Enter" ? (s(r), !0) : !1
|
|
180
|
+
})), e.length ? /* @__PURE__ */ g("div", { className: "slash-menu", children: e.map((i, c) => /* @__PURE__ */ A(
|
|
181
181
|
"button",
|
|
182
182
|
{
|
|
183
|
-
className: `slash-menu-item ${
|
|
184
|
-
onClick: () => s(
|
|
185
|
-
onMouseEnter: () => a(
|
|
183
|
+
className: `slash-menu-item ${c === r ? "slash-menu-item--active" : ""}`,
|
|
184
|
+
onClick: () => s(c),
|
|
185
|
+
onMouseEnter: () => a(c),
|
|
186
186
|
children: [
|
|
187
187
|
/* @__PURE__ */ g("span", { className: "slash-menu-icon", children: i.icon }),
|
|
188
188
|
/* @__PURE__ */ A("div", { className: "slash-menu-text", children: [
|
|
@@ -195,8 +195,8 @@ const na = new ke("slashCommand"), ra = Ve.create({
|
|
|
195
195
|
)) }) : /* @__PURE__ */ g("div", { className: "slash-menu", children: /* @__PURE__ */ g("div", { className: "slash-menu-empty", children: "No results" }) });
|
|
196
196
|
}
|
|
197
197
|
);
|
|
198
|
-
|
|
199
|
-
function
|
|
198
|
+
rn.displayName = "SlashMenuList";
|
|
199
|
+
function ia(e) {
|
|
200
200
|
const t = e === "zh";
|
|
201
201
|
return [
|
|
202
202
|
{
|
|
@@ -295,14 +295,22 @@ function sa(e) {
|
|
|
295
295
|
const a = window.prompt(t ? "请输入图片 URL" : "Enter image URL");
|
|
296
296
|
a && n.chain().focus().deleteRange(r).setImage({ src: a }).run();
|
|
297
297
|
}
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
title: t ? "权利要求" : "Claim",
|
|
301
|
+
description: t ? "插入权利要求条目 (Ctrl+Shift+C)" : "Insert a patent claim block (Ctrl+Shift+C)",
|
|
302
|
+
icon: "§",
|
|
303
|
+
command: ({ editor: n, range: r }) => {
|
|
304
|
+
n.chain().focus().deleteRange(r).run(), Ae(n).execCommand("insertClaim");
|
|
305
|
+
}
|
|
298
306
|
}
|
|
299
307
|
];
|
|
300
308
|
}
|
|
301
|
-
function
|
|
309
|
+
function oa() {
|
|
302
310
|
return {
|
|
303
311
|
char: "/",
|
|
304
312
|
items: ({ query: e }) => {
|
|
305
|
-
const t =
|
|
313
|
+
const t = k.getState().editorLanguage, n = ia(t);
|
|
306
314
|
if (!e) return n;
|
|
307
315
|
const r = e.toLowerCase();
|
|
308
316
|
return n.filter(
|
|
@@ -313,10 +321,10 @@ function ia() {
|
|
|
313
321
|
let e = null, t = null;
|
|
314
322
|
return {
|
|
315
323
|
onStart: (n) => {
|
|
316
|
-
e = new
|
|
324
|
+
e = new _n(rn, {
|
|
317
325
|
props: n,
|
|
318
326
|
editor: n.editor
|
|
319
|
-
}), n.clientRect && (t =
|
|
327
|
+
}), n.clientRect && (t = rr("body", {
|
|
320
328
|
getReferenceClientRect: n.clientRect,
|
|
321
329
|
appendTo: () => document.body,
|
|
322
330
|
content: e.element,
|
|
@@ -343,33 +351,33 @@ function ia() {
|
|
|
343
351
|
}
|
|
344
352
|
};
|
|
345
353
|
}
|
|
346
|
-
const
|
|
347
|
-
function
|
|
354
|
+
const ca = new _e("searchReplace");
|
|
355
|
+
function Me(e, t, n) {
|
|
348
356
|
if (!t) return [];
|
|
349
357
|
const r = [], a = e.textBetween(0, e.content.size, `
|
|
350
358
|
`, "\0"), s = n ? t : t.toLowerCase(), i = n ? a : a.toLowerCase();
|
|
351
|
-
let
|
|
352
|
-
for (;
|
|
353
|
-
const
|
|
354
|
-
if (
|
|
359
|
+
let c = 0;
|
|
360
|
+
for (; c < i.length; ) {
|
|
361
|
+
const l = i.indexOf(s, c);
|
|
362
|
+
if (l === -1) break;
|
|
355
363
|
let d = 0, o = -1, u = -1;
|
|
356
364
|
e.descendants((m, h) => {
|
|
357
365
|
if (o !== -1 && u !== -1) return !1;
|
|
358
366
|
if (m.isText) {
|
|
359
367
|
const p = m.text || "";
|
|
360
368
|
for (let f = 0; f < p.length; f++) {
|
|
361
|
-
if (d ===
|
|
369
|
+
if (d === l && (o = h + f), d === l + s.length)
|
|
362
370
|
return u = h + f, !1;
|
|
363
371
|
d++;
|
|
364
372
|
}
|
|
365
|
-
d ===
|
|
366
|
-
} else m.isBlock && d > 0 && (d ===
|
|
373
|
+
d === l + s.length && u === -1 && (u = h + p.length);
|
|
374
|
+
} else m.isBlock && d > 0 && (d === l && (o = h), d++);
|
|
367
375
|
return !0;
|
|
368
|
-
}), o !== -1 && u !== -1 && r.push({ from: o, to: u }),
|
|
376
|
+
}), o !== -1 && u !== -1 && r.push({ from: o, to: u }), c = l + 1;
|
|
369
377
|
}
|
|
370
378
|
return r;
|
|
371
379
|
}
|
|
372
|
-
const
|
|
380
|
+
const la = Je.create({
|
|
373
381
|
name: "searchReplace",
|
|
374
382
|
addStorage() {
|
|
375
383
|
return {
|
|
@@ -382,35 +390,35 @@ const ca = Ve.create({
|
|
|
382
390
|
},
|
|
383
391
|
addCommands() {
|
|
384
392
|
return {
|
|
385
|
-
setSearchTerm: (e) => ({ editor: t }) => (this.storage.searchTerm = e, this.storage.results =
|
|
393
|
+
setSearchTerm: (e) => ({ editor: t }) => (this.storage.searchTerm = e, this.storage.results = Me(t.state.doc, e, this.storage.caseSensitive), this.storage.currentIndex = this.storage.results.length > 0 ? 0 : -1, t.view.dispatch(t.state.tr), !0),
|
|
386
394
|
setReplaceTerm: (e) => () => (this.storage.replaceTerm = e, !0),
|
|
387
|
-
setCaseSensitive: (e) => ({ editor: t }) => (this.storage.caseSensitive = e, this.storage.results =
|
|
395
|
+
setCaseSensitive: (e) => ({ editor: t }) => (this.storage.caseSensitive = e, this.storage.results = Me(t.state.doc, this.storage.searchTerm, e), this.storage.currentIndex = this.storage.results.length > 0 ? 0 : -1, t.view.dispatch(t.state.tr), !0),
|
|
388
396
|
nextSearchResult: () => ({ editor: e }) => {
|
|
389
397
|
if (this.storage.results.length === 0) return !1;
|
|
390
398
|
this.storage.currentIndex = (this.storage.currentIndex + 1) % this.storage.results.length;
|
|
391
399
|
const t = this.storage.results[this.storage.currentIndex];
|
|
392
|
-
return t && (e.commands.setTextSelection(t),
|
|
400
|
+
return t && (e.commands.setTextSelection(t), Et(e)), e.view.dispatch(e.state.tr), !0;
|
|
393
401
|
},
|
|
394
402
|
previousSearchResult: () => ({ editor: e }) => {
|
|
395
403
|
if (this.storage.results.length === 0) return !1;
|
|
396
404
|
this.storage.currentIndex = (this.storage.currentIndex - 1 + this.storage.results.length) % this.storage.results.length;
|
|
397
405
|
const t = this.storage.results[this.storage.currentIndex];
|
|
398
|
-
return t && (e.commands.setTextSelection(t),
|
|
406
|
+
return t && (e.commands.setTextSelection(t), Et(e)), e.view.dispatch(e.state.tr), !0;
|
|
399
407
|
},
|
|
400
408
|
replaceCurrent: () => ({ editor: e }) => {
|
|
401
409
|
if (this.storage.results.length === 0 || this.storage.currentIndex < 0) return !1;
|
|
402
410
|
const t = this.storage.results[this.storage.currentIndex];
|
|
403
|
-
return t ? (e.chain().focus().insertContentAt(t, this.storage.replaceTerm).run(), this.storage.results =
|
|
411
|
+
return t ? (e.chain().focus().insertContentAt(t, this.storage.replaceTerm).run(), this.storage.results = Me(e.state.doc, this.storage.searchTerm, this.storage.caseSensitive), this.storage.currentIndex >= this.storage.results.length && (this.storage.currentIndex = 0), e.view.dispatch(e.state.tr), !0) : !1;
|
|
404
412
|
},
|
|
405
413
|
replaceAll: () => ({ editor: e }) => {
|
|
406
414
|
if (this.storage.results.length === 0) return !1;
|
|
407
415
|
const { searchTerm: t, replaceTerm: n, caseSensitive: r } = this.storage;
|
|
408
|
-
let a =
|
|
416
|
+
let a = Me(e.state.doc, t, r);
|
|
409
417
|
const s = e.state.tr;
|
|
410
418
|
let i = 0;
|
|
411
|
-
for (const
|
|
412
|
-
const
|
|
413
|
-
s.insertText(n,
|
|
419
|
+
for (const c of a) {
|
|
420
|
+
const l = c.from + i, d = c.to + i;
|
|
421
|
+
s.insertText(n, l, d), i += n.length - (c.to - c.from);
|
|
414
422
|
}
|
|
415
423
|
return e.view.dispatch(s), this.storage.results = [], this.storage.currentIndex = -1, !0;
|
|
416
424
|
},
|
|
@@ -432,24 +440,24 @@ const ca = Ve.create({
|
|
|
432
440
|
addProseMirrorPlugins() {
|
|
433
441
|
const e = this.storage;
|
|
434
442
|
return [
|
|
435
|
-
new
|
|
436
|
-
key:
|
|
443
|
+
new Xe({
|
|
444
|
+
key: ca,
|
|
437
445
|
props: {
|
|
438
446
|
decorations: (t) => {
|
|
439
447
|
if (!e.searchTerm || e.results.length === 0)
|
|
440
|
-
return
|
|
448
|
+
return Ne.empty;
|
|
441
449
|
const n = e.results.map((r, a) => {
|
|
442
450
|
const s = a === e.currentIndex ? "search-highlight search-highlight--current" : "search-highlight";
|
|
443
451
|
return le.inline(r.from, r.to, { class: s });
|
|
444
452
|
});
|
|
445
|
-
return
|
|
453
|
+
return Ne.create(t.doc, n);
|
|
446
454
|
}
|
|
447
455
|
}
|
|
448
456
|
})
|
|
449
457
|
];
|
|
450
458
|
}
|
|
451
459
|
});
|
|
452
|
-
function
|
|
460
|
+
function Et(e) {
|
|
453
461
|
requestAnimationFrame(() => {
|
|
454
462
|
const t = e.view.domAtPos(e.state.selection.from);
|
|
455
463
|
if (t != null && t.node) {
|
|
@@ -458,97 +466,97 @@ function It(e) {
|
|
|
458
466
|
}
|
|
459
467
|
});
|
|
460
468
|
}
|
|
461
|
-
const
|
|
462
|
-
let
|
|
463
|
-
function
|
|
464
|
-
return
|
|
469
|
+
const da = -1, ua = 1, Nt = 0;
|
|
470
|
+
let nt = null;
|
|
471
|
+
function ma() {
|
|
472
|
+
return nt || (nt = new Gt()), nt;
|
|
465
473
|
}
|
|
466
|
-
const
|
|
467
|
-
function
|
|
474
|
+
const an = new _e("patchDiff");
|
|
475
|
+
function fa(e, t) {
|
|
468
476
|
let n = null;
|
|
469
477
|
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
478
|
}
|
|
471
|
-
function
|
|
479
|
+
function sn(e, t, n) {
|
|
472
480
|
const r = [];
|
|
473
481
|
let a = "", s = !0;
|
|
474
|
-
return e.state.doc.nodesBetween(t, n, (i,
|
|
482
|
+
return e.state.doc.nodesBetween(t, n, (i, c) => {
|
|
475
483
|
if (i.isText) {
|
|
476
|
-
const
|
|
477
|
-
r.push({ textIdx: a.length, docPos:
|
|
484
|
+
const l = c, d = Math.max(t, l) - l, o = Math.min(n, l + i.nodeSize) - l, u = i.text.slice(d, o);
|
|
485
|
+
r.push({ textIdx: a.length, docPos: l + d, len: u.length }), a += u, s = !1;
|
|
478
486
|
} else i.isLeaf ? (a += "\0", s = !1) : !s && i.isBlock && (a += "\0", s = !0);
|
|
479
487
|
}), { text: a, segments: r };
|
|
480
488
|
}
|
|
481
|
-
function
|
|
489
|
+
function Ee(e, t) {
|
|
482
490
|
for (const n of e)
|
|
483
491
|
if (t >= n.textIdx && t <= n.textIdx + n.len)
|
|
484
492
|
return n.docPos + (t - n.textIdx);
|
|
485
493
|
return -1;
|
|
486
494
|
}
|
|
487
|
-
function
|
|
488
|
-
const { text: s, segments: i } =
|
|
489
|
-
let
|
|
490
|
-
for (;
|
|
491
|
-
const
|
|
492
|
-
if (
|
|
493
|
-
const d =
|
|
495
|
+
function kt(e, t, n, r, a) {
|
|
496
|
+
const { text: s, segments: i } = sn(e, n, r);
|
|
497
|
+
let c = 0;
|
|
498
|
+
for (; c <= s.length - t.length; ) {
|
|
499
|
+
const l = s.indexOf(t, c);
|
|
500
|
+
if (l === -1) return null;
|
|
501
|
+
const d = Ee(i, l), o = Ee(i, l + t.length);
|
|
494
502
|
if (d >= 0 && o >= 0 && !(a && a.has(d)))
|
|
495
503
|
return { from: d, to: o };
|
|
496
|
-
|
|
504
|
+
c = l + 1;
|
|
497
505
|
}
|
|
498
506
|
return null;
|
|
499
507
|
}
|
|
500
|
-
function
|
|
508
|
+
function Qi(e, t, n, r, a) {
|
|
501
509
|
const s = t.target;
|
|
502
510
|
let i = null;
|
|
503
|
-
const
|
|
511
|
+
const c = /* @__PURE__ */ new Set();
|
|
504
512
|
if (a)
|
|
505
513
|
for (const o of a)
|
|
506
|
-
|
|
514
|
+
c.add(o.from);
|
|
507
515
|
if (!s)
|
|
508
516
|
t.from != null && t.to != null && (i = { from: t.from, to: t.to });
|
|
509
517
|
else if (s.type === "section" && s.sectionType)
|
|
510
|
-
i =
|
|
518
|
+
i = fa(e, s.sectionType);
|
|
511
519
|
else if (s.type === "ref" && s.refIndex != null) {
|
|
512
520
|
const o = n[s.refIndex];
|
|
513
521
|
(o == null ? void 0 : o.from) != null && (o == null ? void 0 : o.to) != null && (i = { from: o.from, to: o.to });
|
|
514
|
-
} else s.type === "search" && s.searchText && (i =
|
|
522
|
+
} else s.type === "search" && s.searchText && (i = kt(e, s.searchText, 0, e.state.doc.content.size, c));
|
|
515
523
|
if (!i) return null;
|
|
516
|
-
let
|
|
524
|
+
let l = i;
|
|
517
525
|
if (t.search) {
|
|
518
|
-
const o =
|
|
519
|
-
o && (
|
|
526
|
+
const o = kt(e, t.search, i.from, i.to, c);
|
|
527
|
+
o && (l = o);
|
|
520
528
|
}
|
|
521
|
-
const d =
|
|
529
|
+
const d = l.from < l.to ? e.state.doc.textBetween(l.from, l.to, " ", "\0") : "";
|
|
522
530
|
return {
|
|
523
531
|
id: `patch_${Date.now()}_${r}`,
|
|
524
532
|
type: t.op === "delete" ? "delete" : t.op === "insert" ? "insert" : "replace",
|
|
525
|
-
from:
|
|
526
|
-
to: t.op === "insert" ?
|
|
533
|
+
from: l.from,
|
|
534
|
+
to: t.op === "insert" ? l.from : l.to,
|
|
527
535
|
content: t.content || "",
|
|
528
536
|
originalText: d,
|
|
529
537
|
reason: t.reason,
|
|
530
538
|
status: "pending"
|
|
531
539
|
};
|
|
532
540
|
}
|
|
533
|
-
let q = [],
|
|
534
|
-
function
|
|
535
|
-
return
|
|
536
|
-
|
|
541
|
+
let q = [], Ue = [];
|
|
542
|
+
function Yi(e) {
|
|
543
|
+
return Ue.push(e), () => {
|
|
544
|
+
Ue = Ue.filter((t) => t !== e);
|
|
537
545
|
};
|
|
538
546
|
}
|
|
539
547
|
function ye() {
|
|
540
|
-
|
|
548
|
+
Ue.forEach((e) => e());
|
|
541
549
|
}
|
|
542
|
-
function
|
|
550
|
+
function Zi() {
|
|
543
551
|
return [...q];
|
|
544
552
|
}
|
|
545
|
-
function
|
|
553
|
+
function eo(e) {
|
|
546
554
|
q = e, ye();
|
|
547
555
|
}
|
|
548
|
-
function
|
|
556
|
+
function to() {
|
|
549
557
|
q = [], ye();
|
|
550
558
|
}
|
|
551
|
-
function
|
|
559
|
+
function no(e, t) {
|
|
552
560
|
const n = q.find((s) => s.id === t);
|
|
553
561
|
if (!n || n.status !== "pending") return !1;
|
|
554
562
|
n.status = "accepted";
|
|
@@ -557,8 +565,8 @@ function eo(e, t) {
|
|
|
557
565
|
r.delete(n.from, n.to);
|
|
558
566
|
else if (n.type === "insert")
|
|
559
567
|
r.insertText(n.content, n.from);
|
|
560
|
-
else if (
|
|
561
|
-
const i =
|
|
568
|
+
else if (on(e, n.from, n.to)) {
|
|
569
|
+
const i = cn(e, n.content);
|
|
562
570
|
r.replaceWith(n.from, n.to, i);
|
|
563
571
|
} else
|
|
564
572
|
r.insertText(n.content, n.from, n.to);
|
|
@@ -566,96 +574,96 @@ function eo(e, t) {
|
|
|
566
574
|
const a = r.mapping;
|
|
567
575
|
for (const s of q) {
|
|
568
576
|
if (s.id === t || s.status !== "pending") continue;
|
|
569
|
-
const i = a.map(s.from, 1),
|
|
570
|
-
i >=
|
|
577
|
+
const i = a.map(s.from, 1), c = a.map(s.to, -1);
|
|
578
|
+
i >= c && s.type !== "insert" ? s.status = "rejected" : (s.from = i, s.to = s.type === "insert" ? i : c);
|
|
571
579
|
}
|
|
572
|
-
return q = q.filter((s) => s.id !== t && s.status === "pending"),
|
|
580
|
+
return q = q.filter((s) => s.id !== t && s.status === "pending"), Ze(e), ye(), !0;
|
|
573
581
|
}
|
|
574
|
-
function
|
|
582
|
+
function ro(e, t) {
|
|
575
583
|
const n = q.find((r) => r.id === t);
|
|
576
|
-
return !n || n.status !== "pending" ? !1 : (n.status = "rejected", q = q.filter((r) => r.id !== t),
|
|
584
|
+
return !n || n.status !== "pending" ? !1 : (n.status = "rejected", q = q.filter((r) => r.id !== t), Ze(e), ye(), !0);
|
|
577
585
|
}
|
|
578
|
-
function
|
|
586
|
+
function ao(e) {
|
|
579
587
|
const n = [...q.filter((a) => a.status === "pending")].sort((a, s) => s.from - a.from), { tr: r } = e.state;
|
|
580
588
|
for (const a of n)
|
|
581
589
|
if (a.type === "delete")
|
|
582
590
|
r.delete(a.from, a.to);
|
|
583
591
|
else if (a.type === "insert")
|
|
584
592
|
r.insertText(a.content, a.from);
|
|
585
|
-
else if (
|
|
586
|
-
const i =
|
|
593
|
+
else if (on(e, a.from, a.to)) {
|
|
594
|
+
const i = cn(e, a.content);
|
|
587
595
|
r.replaceWith(a.from, a.to, i);
|
|
588
596
|
} else
|
|
589
597
|
r.insertText(a.content, a.from, a.to);
|
|
590
|
-
e.view.dispatch(r), q = [],
|
|
598
|
+
e.view.dispatch(r), q = [], Ze(e), ye();
|
|
591
599
|
}
|
|
592
|
-
function
|
|
593
|
-
q = [],
|
|
600
|
+
function so(e) {
|
|
601
|
+
q = [], Ze(e), ye();
|
|
594
602
|
}
|
|
595
|
-
function
|
|
596
|
-
e.view.dispatch(e.state.tr.setMeta(
|
|
603
|
+
function Ze(e) {
|
|
604
|
+
e.view.dispatch(e.state.tr.setMeta(an, !0));
|
|
597
605
|
}
|
|
598
|
-
function
|
|
606
|
+
function ga(e, t, n) {
|
|
599
607
|
const r = [];
|
|
600
608
|
return e.nodesBetween(t, n, (a, s) => {
|
|
601
609
|
if (a.isTextblock) {
|
|
602
|
-
const i = s + 1,
|
|
603
|
-
return d >
|
|
610
|
+
const i = s + 1, c = s + a.nodeSize - 1, l = Math.max(i, t), d = Math.min(c, n);
|
|
611
|
+
return d > l && r.push({ from: l, to: d }), !1;
|
|
604
612
|
}
|
|
605
613
|
return !0;
|
|
606
614
|
}), r;
|
|
607
615
|
}
|
|
608
|
-
function
|
|
616
|
+
function pa(e, t) {
|
|
609
617
|
if (!t.originalText || !t.content) return null;
|
|
610
618
|
try {
|
|
611
|
-
const
|
|
612
|
-
if (
|
|
619
|
+
const c = e.resolve(t.from), l = e.resolve(t.to);
|
|
620
|
+
if (c.parent !== l.parent || !c.parent.isTextblock) return null;
|
|
613
621
|
} catch {
|
|
614
622
|
return null;
|
|
615
623
|
}
|
|
616
|
-
const n =
|
|
624
|
+
const n = ma(), r = n.diff_main(t.originalText, t.content);
|
|
617
625
|
n.diff_cleanupSemantic(r);
|
|
618
|
-
const a = r.filter(([
|
|
626
|
+
const a = r.filter(([c]) => c === Nt).reduce((c, [, l]) => c + l.length, 0);
|
|
619
627
|
if (t.originalText.length > 0 && a / t.originalText.length < 0.3) return null;
|
|
620
628
|
const s = [];
|
|
621
629
|
let i = t.from;
|
|
622
|
-
for (const [
|
|
623
|
-
if (
|
|
624
|
-
i +=
|
|
625
|
-
else if (
|
|
626
|
-
const d = i +
|
|
630
|
+
for (const [c, l] of r)
|
|
631
|
+
if (c === Nt)
|
|
632
|
+
i += l.length;
|
|
633
|
+
else if (c === da) {
|
|
634
|
+
const d = i + l.length;
|
|
627
635
|
s.push(
|
|
628
636
|
le.inline(i, d, {
|
|
629
637
|
class: "patch-diff-delete",
|
|
630
638
|
"data-patch-id": t.id
|
|
631
639
|
})
|
|
632
640
|
), i = d;
|
|
633
|
-
} else
|
|
641
|
+
} else c === ua && s.push(
|
|
634
642
|
le.widget(i, () => {
|
|
635
643
|
const d = document.createElement("span");
|
|
636
|
-
return d.className = "patch-diff-insert-inline", d.textContent =
|
|
644
|
+
return d.className = "patch-diff-insert-inline", d.textContent = l, d.setAttribute("data-patch-id", t.id), d;
|
|
637
645
|
}, { side: 1 })
|
|
638
646
|
);
|
|
639
647
|
return s;
|
|
640
648
|
}
|
|
641
|
-
function
|
|
642
|
-
return new
|
|
643
|
-
key:
|
|
649
|
+
function ha() {
|
|
650
|
+
return new Xe({
|
|
651
|
+
key: an,
|
|
644
652
|
props: {
|
|
645
653
|
decorations(e) {
|
|
646
654
|
const t = q.filter((r) => r.status === "pending");
|
|
647
|
-
if (t.length === 0) return
|
|
655
|
+
if (t.length === 0) return Ne.empty;
|
|
648
656
|
const n = [];
|
|
649
657
|
for (const r of t) {
|
|
650
658
|
if (r.type === "replace") {
|
|
651
|
-
const a =
|
|
659
|
+
const a = pa(e.doc, r);
|
|
652
660
|
if (a) {
|
|
653
661
|
n.push(...a);
|
|
654
662
|
continue;
|
|
655
663
|
}
|
|
656
664
|
}
|
|
657
665
|
if (r.type === "delete" || r.type === "replace") {
|
|
658
|
-
const a =
|
|
666
|
+
const a = ga(e.doc, r.from, r.to);
|
|
659
667
|
for (const s of a)
|
|
660
668
|
n.push(
|
|
661
669
|
le.inline(s.from, s.to, {
|
|
@@ -668,8 +676,8 @@ function pa() {
|
|
|
668
676
|
`);
|
|
669
677
|
n.push(
|
|
670
678
|
le.widget(s, () => {
|
|
671
|
-
const
|
|
672
|
-
return
|
|
679
|
+
const c = document.createElement(i ? "div" : "span");
|
|
680
|
+
return c.className = i ? "patch-diff-insert-inline patch-diff-insert-block" : "patch-diff-insert-inline", c.textContent = r.content, c.setAttribute("data-patch-id", r.id), c;
|
|
673
681
|
}, { side: 1 })
|
|
674
682
|
);
|
|
675
683
|
}
|
|
@@ -681,17 +689,17 @@ function pa() {
|
|
|
681
689
|
})
|
|
682
690
|
);
|
|
683
691
|
}
|
|
684
|
-
return
|
|
692
|
+
return Ne.create(e.doc, n);
|
|
685
693
|
}
|
|
686
694
|
}
|
|
687
695
|
});
|
|
688
696
|
}
|
|
689
|
-
function
|
|
697
|
+
function on(e, t, n) {
|
|
690
698
|
var s;
|
|
691
699
|
const r = e.state.doc.resolve(t);
|
|
692
700
|
return !!((s = r.parent.type.spec.content) != null && s.includes("block") && t === r.start() && n === r.end());
|
|
693
701
|
}
|
|
694
|
-
function
|
|
702
|
+
function cn(e, t) {
|
|
695
703
|
const n = e.state.schema;
|
|
696
704
|
return t.split(/\n\n+/).filter((a) => a.trim().length > 0).map((a) => {
|
|
697
705
|
const s = a.replace(/\n/g, " ").trim();
|
|
@@ -701,7 +709,7 @@ function on(e, t) {
|
|
|
701
709
|
);
|
|
702
710
|
});
|
|
703
711
|
}
|
|
704
|
-
const
|
|
712
|
+
const ba = ee.create({
|
|
705
713
|
name: "hardBreak",
|
|
706
714
|
inline: !0,
|
|
707
715
|
group: "inline",
|
|
@@ -714,51 +722,48 @@ const ha = ee.create({
|
|
|
714
722
|
},
|
|
715
723
|
addKeyboardShortcuts() {
|
|
716
724
|
return {
|
|
717
|
-
"Shift-Enter": () =>
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
() => e.exitCode(),
|
|
724
|
-
() => e.command(({ tr: t, dispatch: n }) => (n && t.replaceSelectionWith(this.type.create()).scrollIntoView(), !0))
|
|
725
|
-
])
|
|
725
|
+
"Shift-Enter": () => {
|
|
726
|
+
const e = this.editor.schema.nodes.hardBreak;
|
|
727
|
+
if (!e) return !1;
|
|
728
|
+
const t = this.editor.state.tr.replaceSelectionWith(e.create()).scrollIntoView();
|
|
729
|
+
return this.editor.view.dispatch(t), !0;
|
|
730
|
+
}
|
|
726
731
|
};
|
|
727
732
|
}
|
|
728
|
-
}),
|
|
733
|
+
}), ya = Je.create({
|
|
729
734
|
name: "dragDropUX",
|
|
730
735
|
addProseMirrorPlugins() {
|
|
731
736
|
return [
|
|
732
|
-
|
|
737
|
+
Zn({
|
|
733
738
|
width: 3,
|
|
734
739
|
color: "#2563eb"
|
|
735
740
|
}),
|
|
736
|
-
|
|
741
|
+
er()
|
|
737
742
|
];
|
|
738
743
|
}
|
|
739
|
-
}),
|
|
744
|
+
}), va = Je.create({
|
|
740
745
|
name: "patchDiff",
|
|
741
746
|
addProseMirrorPlugins() {
|
|
742
|
-
return [
|
|
747
|
+
return [ha()];
|
|
743
748
|
}
|
|
744
|
-
}),
|
|
745
|
-
Rn,
|
|
746
|
-
Mn,
|
|
749
|
+
}), Ca = [
|
|
747
750
|
Dn,
|
|
748
|
-
|
|
749
|
-
$n
|
|
751
|
+
Mn,
|
|
752
|
+
$n,
|
|
753
|
+
ya,
|
|
754
|
+
On.configure({
|
|
750
755
|
levels: [1, 2, 3, 4, 5, 6]
|
|
751
756
|
}),
|
|
752
|
-
On,
|
|
753
757
|
Fn,
|
|
754
758
|
zn,
|
|
755
759
|
Bn,
|
|
756
760
|
Hn,
|
|
757
|
-
ha,
|
|
758
761
|
Un,
|
|
762
|
+
ba,
|
|
759
763
|
jn,
|
|
760
|
-
Wn
|
|
761
|
-
qn.
|
|
764
|
+
Wn,
|
|
765
|
+
qn.configure({ nested: !0 }),
|
|
766
|
+
Gn.extend({
|
|
762
767
|
addAttributes() {
|
|
763
768
|
var e;
|
|
764
769
|
return {
|
|
@@ -774,46 +779,46 @@ const ha = ee.create({
|
|
|
774
779
|
inline: !0,
|
|
775
780
|
allowBase64: !0
|
|
776
781
|
}),
|
|
777
|
-
|
|
782
|
+
Vn.configure({
|
|
778
783
|
resizable: !0
|
|
779
784
|
}),
|
|
780
|
-
Vn,
|
|
781
785
|
Kn,
|
|
782
786
|
Jn,
|
|
783
|
-
Xn
|
|
787
|
+
Xn,
|
|
788
|
+
Qn.configure({
|
|
784
789
|
placeholder: ({ node: e }) => e.type.name === "heading" ? "Heading" : "Type / for commands..."
|
|
785
790
|
}),
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
suggestion:
|
|
791
|
+
Yn,
|
|
792
|
+
aa.configure({
|
|
793
|
+
suggestion: oa()
|
|
789
794
|
}),
|
|
790
|
-
|
|
791
|
-
|
|
795
|
+
la,
|
|
796
|
+
tr.configure({
|
|
792
797
|
types: ["heading", "paragraph"],
|
|
793
798
|
defaultAlignment: "left"
|
|
794
799
|
}),
|
|
795
|
-
|
|
796
|
-
],
|
|
797
|
-
ar,
|
|
800
|
+
va
|
|
801
|
+
], wa = [
|
|
798
802
|
sr,
|
|
799
803
|
ir,
|
|
800
804
|
or,
|
|
801
805
|
cr,
|
|
802
806
|
lr,
|
|
803
807
|
dr,
|
|
804
|
-
ur
|
|
808
|
+
ur,
|
|
809
|
+
mr.configure({
|
|
805
810
|
openOnClick: !1
|
|
806
811
|
}),
|
|
807
|
-
mr,
|
|
808
812
|
fr,
|
|
809
|
-
gr
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
...Ca
|
|
813
|
+
gr,
|
|
814
|
+
pr.configure({ multicolor: !0 })
|
|
815
|
+
], xa = [
|
|
816
|
+
...Ca,
|
|
817
|
+
...wa
|
|
813
818
|
];
|
|
814
|
-
class
|
|
819
|
+
class Sa {
|
|
815
820
|
constructor() {
|
|
816
|
-
|
|
821
|
+
Re(this, "commands", /* @__PURE__ */ new Map());
|
|
817
822
|
}
|
|
818
823
|
normalizeCommand(t) {
|
|
819
824
|
return typeof t == "function" ? {
|
|
@@ -837,7 +842,7 @@ class xa {
|
|
|
837
842
|
}
|
|
838
843
|
async execute(t, n, r, a = {}) {
|
|
839
844
|
var o, u, m, h;
|
|
840
|
-
const s = Date.now(), i = a.transaction ?? !0,
|
|
845
|
+
const s = Date.now(), i = a.transaction ?? !0, c = a.rollbackOnFail ?? !0, l = i ? n.editor.getJSON() : null, d = this.commands.get(t);
|
|
841
846
|
if (!d)
|
|
842
847
|
return console.warn(`Command "${t}" not found.`), (o = a.onComplete) == null || o.call(a, {
|
|
843
848
|
name: t,
|
|
@@ -852,15 +857,15 @@ class xa {
|
|
|
852
857
|
}), !1;
|
|
853
858
|
try {
|
|
854
859
|
const f = !!await d.execute(n, r);
|
|
855
|
-
!f &&
|
|
856
|
-
const
|
|
860
|
+
!f && l && c && n.editor.commands.setContent(l);
|
|
861
|
+
const C = {
|
|
857
862
|
name: t,
|
|
858
863
|
success: f,
|
|
859
864
|
durationMs: Date.now() - s
|
|
860
865
|
};
|
|
861
|
-
return (m = a.onComplete) == null || m.call(a,
|
|
866
|
+
return (m = a.onComplete) == null || m.call(a, C), f;
|
|
862
867
|
} catch (p) {
|
|
863
|
-
|
|
868
|
+
l && c && n.editor.commands.setContent(l);
|
|
864
869
|
const f = {
|
|
865
870
|
name: t,
|
|
866
871
|
success: !1,
|
|
@@ -877,11 +882,11 @@ class xa {
|
|
|
877
882
|
return Array.from(this.commands.keys()).sort();
|
|
878
883
|
}
|
|
879
884
|
}
|
|
880
|
-
const ge = new
|
|
881
|
-
class
|
|
885
|
+
const ge = new Sa();
|
|
886
|
+
class Ta {
|
|
882
887
|
constructor() {
|
|
883
|
-
|
|
884
|
-
|
|
888
|
+
Re(this, "plugins", /* @__PURE__ */ new Map());
|
|
889
|
+
Re(this, "lifecycleOrder", ["register", "init", "stateSync", "destroy"]);
|
|
885
890
|
}
|
|
886
891
|
logLifecycle(t, n) {
|
|
887
892
|
t !== "stateSync" && console.info(`[PluginManager:${t}] ${n}`);
|
|
@@ -963,7 +968,7 @@ class Sa {
|
|
|
963
968
|
});
|
|
964
969
|
}
|
|
965
970
|
}
|
|
966
|
-
const W = new
|
|
971
|
+
const W = new Ta(), _t = {
|
|
967
972
|
zh: {
|
|
968
973
|
language: "语言",
|
|
969
974
|
bold: "加粗",
|
|
@@ -1130,13 +1135,13 @@ const W = new Sa(), kt = {
|
|
|
1130
1135
|
autoSaveSaved: "Saved",
|
|
1131
1136
|
autoSaveError: "Save failed"
|
|
1132
1137
|
}
|
|
1133
|
-
}, U = (e) => e === "en" ?
|
|
1134
|
-
let
|
|
1135
|
-
const
|
|
1138
|
+
}, U = (e) => e === "en" ? _t.en : _t.zh, he = (e, t, n, r) => e === "en" ? t === "forward_reference" ? `Claim ${n} references later claim ${r}.` : t === "self_reference" ? `Claim ${n} references itself.` : `Claim ${n} has circular dependency.` : t === "forward_reference" ? `权利要求${n}引用了后置项权利要求${r}。` : t === "self_reference" ? `权利要求${n}引用了自身。` : `权利要求${n}存在循环依赖。`;
|
|
1139
|
+
let $e = 0;
|
|
1140
|
+
const Oe = () => {
|
|
1136
1141
|
document.querySelectorAll('body > svg[id^="standalone-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
|
|
1137
1142
|
(e.id.startsWith("dmermaid") || e.id.startsWith("dstandalone")) && e.remove();
|
|
1138
1143
|
}), 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());
|
|
1139
|
-
},
|
|
1144
|
+
}, Ia = ee.create({
|
|
1140
1145
|
name: "mermaid",
|
|
1141
1146
|
group: "block",
|
|
1142
1147
|
atom: !0,
|
|
@@ -1158,10 +1163,10 @@ const De = () => {
|
|
|
1158
1163
|
s.classList.add("mermaid-node");
|
|
1159
1164
|
const i = document.createElement("div");
|
|
1160
1165
|
i.className = "mermaid-view", i.contentEditable = "false";
|
|
1161
|
-
const l = document.createElement("div");
|
|
1162
|
-
l.className = "mermaid-preview", l.contentEditable = "false";
|
|
1163
1166
|
const c = document.createElement("div");
|
|
1164
|
-
c.className = "mermaid-
|
|
1167
|
+
c.className = "mermaid-preview", c.contentEditable = "false";
|
|
1168
|
+
const l = document.createElement("div");
|
|
1169
|
+
l.className = "mermaid-view-hint", i.append(c, l);
|
|
1165
1170
|
const d = document.createElement("div");
|
|
1166
1171
|
d.className = "mermaid-edit";
|
|
1167
1172
|
const o = document.createElement("textarea");
|
|
@@ -1176,64 +1181,64 @@ const De = () => {
|
|
|
1176
1181
|
p.className = "mermaid-save-btn", p.type = "button", u.append(m, h, p), d.append(o, u), s.append(i, d);
|
|
1177
1182
|
const f = (b) => {
|
|
1178
1183
|
const T = typeof n == "function" ? n() : null;
|
|
1179
|
-
typeof T == "number" && e.commands.command(({ tr:
|
|
1184
|
+
typeof T == "number" && e.commands.command(({ tr: E, dispatch: D }) => (E.setNodeMarkup(T, void 0, { ...r.attrs, ...b }), D && D(E), !0));
|
|
1180
1185
|
};
|
|
1181
|
-
let
|
|
1186
|
+
let C = "";
|
|
1182
1187
|
const w = async (b) => {
|
|
1183
1188
|
const T = b.trim();
|
|
1184
|
-
if (T !==
|
|
1189
|
+
if (T !== C) {
|
|
1185
1190
|
if (!T) {
|
|
1186
|
-
|
|
1191
|
+
c.innerHTML = "", C = "";
|
|
1187
1192
|
return;
|
|
1188
1193
|
}
|
|
1189
1194
|
try {
|
|
1190
|
-
const
|
|
1191
|
-
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1195
|
+
const E = await import("mermaid");
|
|
1196
|
+
E.default.initialize({ startOnLoad: !1, theme: "default" }), $e += 1;
|
|
1197
|
+
const D = `standalone-mermaid-${$e}`, { svg: M } = await E.default.render(D, T);
|
|
1198
|
+
c.innerHTML = M, C = T;
|
|
1194
1199
|
} catch {
|
|
1195
|
-
|
|
1200
|
+
c.innerHTML = "", C = "";
|
|
1196
1201
|
} finally {
|
|
1197
|
-
|
|
1202
|
+
Oe();
|
|
1198
1203
|
}
|
|
1199
1204
|
}
|
|
1200
|
-
},
|
|
1205
|
+
}, y = () => {
|
|
1201
1206
|
a || (a = !0, o.value = typeof r.attrs.code == "string" ? r.attrs.code : "", m.textContent = "", m.style.display = "none", _(), requestAnimationFrame(() => o.focus()));
|
|
1202
1207
|
}, v = () => {
|
|
1203
1208
|
a = !1, _();
|
|
1204
|
-
},
|
|
1209
|
+
}, x = async () => {
|
|
1205
1210
|
const b = o.value;
|
|
1206
1211
|
m.textContent = "", m.style.display = "none";
|
|
1207
1212
|
const T = b.trim();
|
|
1208
1213
|
if (T)
|
|
1209
1214
|
try {
|
|
1210
|
-
const
|
|
1211
|
-
|
|
1212
|
-
const
|
|
1213
|
-
|
|
1215
|
+
const E = await import("mermaid");
|
|
1216
|
+
E.default.initialize({ startOnLoad: !1, theme: "default" }), $e += 1;
|
|
1217
|
+
const D = `standalone-mermaid-${$e}`, { svg: M } = await E.default.render(D, T);
|
|
1218
|
+
c.innerHTML = M, C = T, Oe();
|
|
1214
1219
|
} catch {
|
|
1215
|
-
|
|
1216
|
-
const
|
|
1217
|
-
m.textContent =
|
|
1220
|
+
Oe();
|
|
1221
|
+
const E = k.getState().editorLanguage;
|
|
1222
|
+
m.textContent = E === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", m.style.display = "inline";
|
|
1218
1223
|
return;
|
|
1219
1224
|
}
|
|
1220
1225
|
f({ code: b }), a = !1, _();
|
|
1221
1226
|
};
|
|
1222
1227
|
i.addEventListener("dblclick", (b) => {
|
|
1223
|
-
b.preventDefault(), b.stopPropagation(),
|
|
1228
|
+
b.preventDefault(), b.stopPropagation(), y();
|
|
1224
1229
|
}), p.addEventListener("click", (b) => {
|
|
1225
|
-
b.stopPropagation(),
|
|
1230
|
+
b.stopPropagation(), x();
|
|
1226
1231
|
}), h.addEventListener("click", (b) => {
|
|
1227
1232
|
b.stopPropagation(), v();
|
|
1228
1233
|
}), o.addEventListener("mousedown", (b) => b.stopPropagation()), o.addEventListener("keydown", (b) => b.stopPropagation()), o.addEventListener("keypress", (b) => b.stopPropagation());
|
|
1229
1234
|
const _ = () => {
|
|
1230
|
-
const b =
|
|
1235
|
+
const b = k.getState().editorLanguage, T = U(b), E = typeof r.attrs.code == "string" ? r.attrs.code : "";
|
|
1231
1236
|
i.style.display = a ? "none" : "block", d.style.display = a ? "block" : "none", p.textContent = T.mermaidSaveAndRender || "保存并渲染", h.textContent = T.mermaidCancel || "取消";
|
|
1232
|
-
const
|
|
1233
|
-
a || (
|
|
1237
|
+
const D = E.trim().length > 0, M = c.querySelector("svg") !== null;
|
|
1238
|
+
a || (D && M ? (l.textContent = T.mermaidDoubleClickToEdit || "双击编辑", l.className = "mermaid-view-hint mermaid-view-hint--subtle") : (l.textContent = T.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", l.className = "mermaid-view-hint mermaid-view-hint--empty")), !a && E.trim() !== C && w(E);
|
|
1234
1239
|
};
|
|
1235
|
-
let L =
|
|
1236
|
-
const P =
|
|
1240
|
+
let L = k.getState().editorLanguage;
|
|
1241
|
+
const P = k.subscribe((b) => {
|
|
1237
1242
|
b.editorLanguage !== L && (L = b.editorLanguage, _());
|
|
1238
1243
|
});
|
|
1239
1244
|
return _(), {
|
|
@@ -1245,15 +1250,15 @@ const De = () => {
|
|
|
1245
1250
|
ignoreMutation: () => !0,
|
|
1246
1251
|
update: (b) => b.type.name !== "mermaid" ? !1 : (r = b, _(), !0),
|
|
1247
1252
|
destroy: () => {
|
|
1248
|
-
P(),
|
|
1253
|
+
P(), Oe();
|
|
1249
1254
|
}
|
|
1250
1255
|
};
|
|
1251
1256
|
};
|
|
1252
1257
|
}
|
|
1253
|
-
}),
|
|
1258
|
+
}), Ea = {
|
|
1254
1259
|
name: "mermaid",
|
|
1255
1260
|
version: "1.0.0",
|
|
1256
|
-
extensions: [
|
|
1261
|
+
extensions: [Ia],
|
|
1257
1262
|
toolbarItems: [
|
|
1258
1263
|
{
|
|
1259
1264
|
id: "mermaid-insert",
|
|
@@ -1277,7 +1282,7 @@ const De = () => {
|
|
|
1277
1282
|
}
|
|
1278
1283
|
}
|
|
1279
1284
|
}
|
|
1280
|
-
},
|
|
1285
|
+
}, Na = ee.create({
|
|
1281
1286
|
name: "drawio",
|
|
1282
1287
|
group: "block",
|
|
1283
1288
|
atom: !0,
|
|
@@ -1300,83 +1305,83 @@ const De = () => {
|
|
|
1300
1305
|
s.classList.add("drawio-node");
|
|
1301
1306
|
const i = document.createElement("div");
|
|
1302
1307
|
i.className = "drawio-view", i.contentEditable = "false";
|
|
1303
|
-
const
|
|
1304
|
-
|
|
1305
|
-
const
|
|
1306
|
-
|
|
1307
|
-
const d = (
|
|
1308
|
+
const c = document.createElement("img");
|
|
1309
|
+
c.className = "drawio-preview-img", c.style.display = "none";
|
|
1310
|
+
const l = document.createElement("div");
|
|
1311
|
+
l.className = "drawio-view-hint", i.append(c, l), s.append(i);
|
|
1312
|
+
const d = (y) => {
|
|
1308
1313
|
const v = typeof n == "function" ? n() : null;
|
|
1309
|
-
typeof v == "number" && e.commands.command(({ tr:
|
|
1314
|
+
typeof v == "number" && e.commands.command(({ tr: x, dispatch: _ }) => (x.setNodeMarkup(v, void 0, { ...r.attrs, ...y }), _ && _(x), !0));
|
|
1310
1315
|
};
|
|
1311
1316
|
let o = null, u = null, m = null;
|
|
1312
1317
|
const h = () => {
|
|
1313
1318
|
if (a) return;
|
|
1314
1319
|
a = !0, u = document.createElement("div"), u.className = "drawio-modal-overlay";
|
|
1315
|
-
const
|
|
1316
|
-
|
|
1320
|
+
const y = document.createElement("div");
|
|
1321
|
+
y.className = "drawio-modal-content";
|
|
1317
1322
|
const v = document.createElement("div");
|
|
1318
1323
|
v.className = "drawio-modal-header";
|
|
1319
|
-
const
|
|
1320
|
-
_.textContent =
|
|
1324
|
+
const x = k.getState().editorLanguage, _ = document.createElement("span");
|
|
1325
|
+
_.textContent = x === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", _.className = "drawio-modal-title";
|
|
1321
1326
|
const L = document.createElement("button");
|
|
1322
|
-
L.className = "drawio-modal-close-btn", L.textContent = "✕", L.type = "button", L.addEventListener("click", () => p()), v.append(_, L), m = document.createElement("iframe"), m.className = "drawio-modal-iframe", m.setAttribute("frameborder", "0"),
|
|
1323
|
-
const P =
|
|
1327
|
+
L.className = "drawio-modal-close-btn", L.textContent = "✕", L.type = "button", L.addEventListener("click", () => p()), v.append(_, L), m = document.createElement("iframe"), m.className = "drawio-modal-iframe", m.setAttribute("frameborder", "0"), y.append(v, m), u.appendChild(y), document.body.appendChild(u);
|
|
1328
|
+
const P = x === "en" ? "en" : "zh";
|
|
1324
1329
|
m.src = `https://embed.diagrams.net/?embed=1&proto=json&spin=1&lang=${P}`;
|
|
1325
1330
|
const b = m;
|
|
1326
1331
|
o = (T) => {
|
|
1327
|
-
var
|
|
1332
|
+
var D, M;
|
|
1328
1333
|
if (!b || T.source !== b.contentWindow) return;
|
|
1329
|
-
let
|
|
1334
|
+
let E;
|
|
1330
1335
|
try {
|
|
1331
|
-
|
|
1336
|
+
E = typeof T.data == "string" ? JSON.parse(T.data) : T.data;
|
|
1332
1337
|
} catch {
|
|
1333
1338
|
return;
|
|
1334
1339
|
}
|
|
1335
|
-
if (
|
|
1340
|
+
if (E.event === "init") {
|
|
1336
1341
|
const Y = typeof r.attrs.xml == "string" ? r.attrs.xml : "";
|
|
1337
|
-
(
|
|
1342
|
+
(D = b.contentWindow) == null || D.postMessage(
|
|
1338
1343
|
JSON.stringify({ action: "load", autosave: 0, xml: Y || "" }),
|
|
1339
1344
|
"*"
|
|
1340
1345
|
);
|
|
1341
|
-
} else if (
|
|
1342
|
-
const Y =
|
|
1343
|
-
(
|
|
1346
|
+
} else if (E.event === "save") {
|
|
1347
|
+
const Y = E.xml || "";
|
|
1348
|
+
(M = b.contentWindow) == null || M.postMessage(
|
|
1344
1349
|
JSON.stringify({ action: "export", format: "svg" }),
|
|
1345
1350
|
"*"
|
|
1346
1351
|
), d({ xml: Y });
|
|
1347
|
-
} else if (
|
|
1348
|
-
const Y =
|
|
1352
|
+
} else if (E.event === "export") {
|
|
1353
|
+
const Y = E.data || "";
|
|
1349
1354
|
d({ svg: Y }), p();
|
|
1350
|
-
} else
|
|
1355
|
+
} else E.event === "exit" && p();
|
|
1351
1356
|
}, window.addEventListener("message", o);
|
|
1352
1357
|
}, p = () => {
|
|
1353
1358
|
a = !1, o && (window.removeEventListener("message", o), o = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null), f();
|
|
1354
1359
|
};
|
|
1355
|
-
i.addEventListener("dblclick", (
|
|
1356
|
-
|
|
1360
|
+
i.addEventListener("dblclick", (y) => {
|
|
1361
|
+
y.preventDefault(), y.stopPropagation(), h();
|
|
1357
1362
|
});
|
|
1358
1363
|
const f = () => {
|
|
1359
|
-
const
|
|
1360
|
-
|
|
1364
|
+
const y = k.getState().editorLanguage, v = U(y), x = typeof r.attrs.svg == "string" ? r.attrs.svg : "";
|
|
1365
|
+
x ? (c.src = x, c.style.display = "block") : (c.src = "", c.style.display = "none"), x ? (l.textContent = v.mermaidDoubleClickToEdit || "双击编辑", l.className = "drawio-view-hint drawio-view-hint--subtle") : (l.textContent = v.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", l.className = "drawio-view-hint drawio-view-hint--empty");
|
|
1361
1366
|
};
|
|
1362
|
-
let
|
|
1363
|
-
const w =
|
|
1364
|
-
|
|
1367
|
+
let C = k.getState().editorLanguage;
|
|
1368
|
+
const w = k.subscribe((y) => {
|
|
1369
|
+
y.editorLanguage !== C && (C = y.editorLanguage, f());
|
|
1365
1370
|
});
|
|
1366
1371
|
return f(), {
|
|
1367
1372
|
dom: s,
|
|
1368
1373
|
ignoreMutation: () => !0,
|
|
1369
|
-
update: (
|
|
1374
|
+
update: (y) => y.type.name !== "drawio" ? !1 : (r = y, f(), !0),
|
|
1370
1375
|
destroy: () => {
|
|
1371
1376
|
w(), o && (window.removeEventListener("message", o), o = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null);
|
|
1372
1377
|
}
|
|
1373
1378
|
};
|
|
1374
1379
|
};
|
|
1375
1380
|
}
|
|
1376
|
-
}),
|
|
1381
|
+
}), ka = {
|
|
1377
1382
|
name: "drawio",
|
|
1378
1383
|
version: "1.0.0",
|
|
1379
|
-
extensions: [
|
|
1384
|
+
extensions: [Na],
|
|
1380
1385
|
toolbarItems: [
|
|
1381
1386
|
{
|
|
1382
1387
|
id: "drawio-insert",
|
|
@@ -1400,30 +1405,30 @@ const De = () => {
|
|
|
1400
1405
|
}
|
|
1401
1406
|
}
|
|
1402
1407
|
}
|
|
1403
|
-
},
|
|
1408
|
+
}, ln = ({
|
|
1404
1409
|
node: e,
|
|
1405
1410
|
updateAttributes: t,
|
|
1406
1411
|
selected: n,
|
|
1407
1412
|
editor: r
|
|
1408
1413
|
}) => {
|
|
1409
|
-
const a = X(null), [s, i] = z(!1),
|
|
1414
|
+
const a = X(null), [s, i] = z(!1), c = e.type.name === "math_block", l = X(!1), d = X(t), o = X(e.attrs.latex ?? "");
|
|
1410
1415
|
B(() => {
|
|
1411
1416
|
d.current = t;
|
|
1412
1417
|
}, [t]), B(() => {
|
|
1413
1418
|
o.current = e.attrs.latex ?? "";
|
|
1414
1419
|
}, [e.attrs.latex]);
|
|
1415
1420
|
const u = de(() => {
|
|
1416
|
-
|
|
1421
|
+
l.current || (l.current = !0, i(!0));
|
|
1417
1422
|
}, []), m = de(() => {
|
|
1418
|
-
var f,
|
|
1419
|
-
if (!
|
|
1420
|
-
|
|
1423
|
+
var f, C;
|
|
1424
|
+
if (!l.current) return;
|
|
1425
|
+
l.current = !1;
|
|
1421
1426
|
const p = ((f = a.current) == null ? void 0 : f.value) ?? o.current;
|
|
1422
|
-
d.current({ latex: p }), i(!1), (
|
|
1427
|
+
d.current({ latex: p }), i(!1), (C = globalThis.mathVirtualKeyboard) == null || C.hide({ animate: !0 });
|
|
1423
1428
|
}, []);
|
|
1424
1429
|
B(() => {
|
|
1425
|
-
var f,
|
|
1426
|
-
const p = !!((w = (
|
|
1430
|
+
var f, C, w;
|
|
1431
|
+
const p = !!((w = (C = (f = r == null ? void 0 : r.view) == null ? void 0 : f.state) == null ? void 0 : C.selection) != null && w.empty);
|
|
1427
1432
|
n && p && u();
|
|
1428
1433
|
}, [n, u]), B(() => {
|
|
1429
1434
|
s && requestAnimationFrame(() => {
|
|
@@ -1437,39 +1442,39 @@ const De = () => {
|
|
|
1437
1442
|
if (!p) return;
|
|
1438
1443
|
const f = () => {
|
|
1439
1444
|
setTimeout(() => {
|
|
1440
|
-
var
|
|
1441
|
-
if (!
|
|
1445
|
+
var y, v, x;
|
|
1446
|
+
if (!l.current) return;
|
|
1442
1447
|
const w = document.activeElement;
|
|
1443
|
-
(w == null ? void 0 : w.tagName) === "MATH-FIELD" || (
|
|
1448
|
+
(w == null ? void 0 : w.tagName) === "MATH-FIELD" || (y = w == null ? void 0 : w.closest) != null && y.call(w, "math-field") || (v = w == null ? void 0 : w.closest) != null && v.call(w, ".ML__keyboard") || (x = document.querySelector(".ML__keyboard")) != null && x.contains(w) || m();
|
|
1444
1449
|
}, 300);
|
|
1445
|
-
},
|
|
1450
|
+
}, C = (w) => {
|
|
1446
1451
|
w.key === "Escape" && m();
|
|
1447
1452
|
};
|
|
1448
|
-
return p.addEventListener("focusout", f), p.addEventListener("keydown",
|
|
1449
|
-
p.removeEventListener("focusout", f), p.removeEventListener("keydown",
|
|
1453
|
+
return p.addEventListener("focusout", f), p.addEventListener("keydown", C), () => {
|
|
1454
|
+
p.removeEventListener("focusout", f), p.removeEventListener("keydown", C);
|
|
1450
1455
|
};
|
|
1451
1456
|
}, [s, m]), B(() => {
|
|
1452
1457
|
!s && a.current && a.current.value !== e.attrs.latex && (a.current.value = e.attrs.latex ?? "");
|
|
1453
1458
|
}, [e.attrs.latex, s]);
|
|
1454
1459
|
let h = "";
|
|
1455
1460
|
try {
|
|
1456
|
-
h =
|
|
1461
|
+
h = hr.renderToString(e.attrs.latex || "", {
|
|
1457
1462
|
throwOnError: !1,
|
|
1458
|
-
displayMode:
|
|
1463
|
+
displayMode: c
|
|
1459
1464
|
});
|
|
1460
1465
|
} catch {
|
|
1461
1466
|
h = e.attrs.latex || "";
|
|
1462
1467
|
}
|
|
1463
1468
|
return /* @__PURE__ */ g(
|
|
1464
|
-
|
|
1469
|
+
An,
|
|
1465
1470
|
{
|
|
1466
|
-
as:
|
|
1467
|
-
className:
|
|
1471
|
+
as: c ? "div" : "span",
|
|
1472
|
+
className: c ? "math-block" : "math-inline",
|
|
1468
1473
|
children: s ? /* @__PURE__ */ g(
|
|
1469
1474
|
"math-field",
|
|
1470
1475
|
{
|
|
1471
1476
|
ref: a,
|
|
1472
|
-
className:
|
|
1477
|
+
className: c ? "math-live-field math-live-field--block" : "math-live-field",
|
|
1473
1478
|
children: e.attrs.latex
|
|
1474
1479
|
}
|
|
1475
1480
|
) : /* @__PURE__ */ A("span", { className: "math-preview", onClick: u, children: [
|
|
@@ -1478,7 +1483,7 @@ const De = () => {
|
|
|
1478
1483
|
] })
|
|
1479
1484
|
}
|
|
1480
1485
|
);
|
|
1481
|
-
},
|
|
1486
|
+
}, _a = ee.create({
|
|
1482
1487
|
name: "math_inline",
|
|
1483
1488
|
group: "inline",
|
|
1484
1489
|
inline: !0,
|
|
@@ -1504,14 +1509,14 @@ const De = () => {
|
|
|
1504
1509
|
return ["span", ae(e, { "data-type": "math_inline" })];
|
|
1505
1510
|
},
|
|
1506
1511
|
addNodeView() {
|
|
1507
|
-
return
|
|
1512
|
+
return qt(ln, {
|
|
1508
1513
|
stopEvent: ({ event: e }) => {
|
|
1509
1514
|
const t = e.target;
|
|
1510
1515
|
return t.tagName.toLowerCase() === "math-field" || t.closest("math-field") !== null;
|
|
1511
1516
|
}
|
|
1512
1517
|
});
|
|
1513
1518
|
}
|
|
1514
|
-
}),
|
|
1519
|
+
}), Aa = ee.create({
|
|
1515
1520
|
name: "math_block",
|
|
1516
1521
|
group: "block",
|
|
1517
1522
|
atom: !0,
|
|
@@ -1527,17 +1532,17 @@ const De = () => {
|
|
|
1527
1532
|
return ["div", ae(e, { "data-type": "math_block" })];
|
|
1528
1533
|
},
|
|
1529
1534
|
addNodeView() {
|
|
1530
|
-
return
|
|
1535
|
+
return qt(ln, {
|
|
1531
1536
|
stopEvent: ({ event: e }) => {
|
|
1532
1537
|
const t = e.target;
|
|
1533
1538
|
return t.tagName.toLowerCase() === "math-field" || t.closest("math-field") !== null;
|
|
1534
1539
|
}
|
|
1535
1540
|
});
|
|
1536
1541
|
}
|
|
1537
|
-
}),
|
|
1542
|
+
}), La = {
|
|
1538
1543
|
name: "math",
|
|
1539
1544
|
version: "1.0.0",
|
|
1540
|
-
extensions: [
|
|
1545
|
+
extensions: [_a, Aa],
|
|
1541
1546
|
toolbarItems: [
|
|
1542
1547
|
{
|
|
1543
1548
|
id: "math-inline-insert",
|
|
@@ -1580,13 +1585,13 @@ const De = () => {
|
|
|
1580
1585
|
}
|
|
1581
1586
|
}
|
|
1582
1587
|
}
|
|
1583
|
-
},
|
|
1588
|
+
}, bt = (e, t, n = {}) => {
|
|
1584
1589
|
const r = n.from ?? 0, a = n.to ?? e.state.doc.content.size;
|
|
1585
1590
|
let s = null;
|
|
1586
|
-
return e.state.doc.nodesBetween(r, a, (i,
|
|
1587
|
-
},
|
|
1591
|
+
return e.state.doc.nodesBetween(r, a, (i, c) => s ? !1 : i.type.name === t ? (s = { node: i, pos: c }, !1) : !0), s;
|
|
1592
|
+
}, yt = (e, t, n = {}) => {
|
|
1588
1593
|
const r = n.from ?? 0, a = n.to ?? e.state.doc.content.size, s = [];
|
|
1589
|
-
return e.state.doc.nodesBetween(r, a, (i,
|
|
1594
|
+
return e.state.doc.nodesBetween(r, a, (i, c) => (t(i, c) && s.push({ node: i, pos: c }), !0)), s;
|
|
1590
1595
|
}, be = (e, t) => {
|
|
1591
1596
|
const { $from: n } = e.state.selection;
|
|
1592
1597
|
for (let r = n.depth; r >= 0; r -= 1) {
|
|
@@ -1598,7 +1603,7 @@ const De = () => {
|
|
|
1598
1603
|
};
|
|
1599
1604
|
}
|
|
1600
1605
|
return null;
|
|
1601
|
-
},
|
|
1606
|
+
}, Pa = (e) => {
|
|
1602
1607
|
const { $from: t } = e.state.selection;
|
|
1603
1608
|
for (let n = t.depth; n >= 0; n -= 1) {
|
|
1604
1609
|
const r = t.node(n);
|
|
@@ -1609,51 +1614,51 @@ const De = () => {
|
|
|
1609
1614
|
};
|
|
1610
1615
|
}
|
|
1611
1616
|
return null;
|
|
1612
|
-
},
|
|
1617
|
+
}, Ra = (e, t) => e.state.schema.nodes[t] || null, Da = (e) => {
|
|
1613
1618
|
const t = Array.isArray(e.content) ? e.content : e.content ? [e.content] : void 0;
|
|
1614
1619
|
return {
|
|
1615
1620
|
type: e.type,
|
|
1616
1621
|
attrs: e.attrs,
|
|
1617
1622
|
content: t
|
|
1618
1623
|
};
|
|
1619
|
-
},
|
|
1620
|
-
const n =
|
|
1624
|
+
}, Ve = (e, t) => {
|
|
1625
|
+
const n = Da(t);
|
|
1621
1626
|
return typeof t.position == "number" ? e.chain().focus().insertContentAt(t.position, n).run() : e.chain().focus().insertContent(n).run();
|
|
1622
1627
|
}, pe = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
|
|
1623
|
-
var
|
|
1624
|
-
const s = typeof t.position == "number" ? t.position : (
|
|
1628
|
+
var l;
|
|
1629
|
+
const s = typeof t.position == "number" ? t.position : (l = bt(e, t.type || "")) == null ? void 0 : l.pos;
|
|
1625
1630
|
if (typeof s != "number")
|
|
1626
1631
|
return !1;
|
|
1627
1632
|
const i = r.doc.nodeAt(s);
|
|
1628
1633
|
if (!i || t.type && i.type.name !== t.type)
|
|
1629
1634
|
return !1;
|
|
1630
|
-
const
|
|
1631
|
-
return n.setNodeMarkup(s, void 0,
|
|
1632
|
-
}),
|
|
1633
|
-
var
|
|
1634
|
-
const s = typeof t.position == "number" ? t.position : (
|
|
1635
|
+
const c = { ...i.attrs, ...t.attrs };
|
|
1636
|
+
return n.setNodeMarkup(s, void 0, c), a && a(n), !0;
|
|
1637
|
+
}), vt = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
|
|
1638
|
+
var c;
|
|
1639
|
+
const s = typeof t.position == "number" ? t.position : (c = bt(e, t.type || "")) == null ? void 0 : c.pos;
|
|
1635
1640
|
if (typeof s != "number")
|
|
1636
1641
|
return !1;
|
|
1637
1642
|
const i = r.doc.nodeAt(s);
|
|
1638
1643
|
return !i || t.type && i.type.name !== t.type ? !1 : (n.delete(s, s + i.nodeSize), a && a(n), !0);
|
|
1639
|
-
}),
|
|
1640
|
-
const n =
|
|
1644
|
+
}), dn = (e, t) => {
|
|
1645
|
+
const n = Ra(e, t.type);
|
|
1641
1646
|
return n ? e.commands.command(({ tr: r, state: a, dispatch: s }) => {
|
|
1642
|
-
const { from: i, to:
|
|
1643
|
-
if (!
|
|
1647
|
+
const { from: i, to: c } = a.selection, l = a.selection.$from.blockRange(a.selection.$to);
|
|
1648
|
+
if (!l)
|
|
1644
1649
|
return !1;
|
|
1645
|
-
const d =
|
|
1646
|
-
return d ? (r.wrap(
|
|
1650
|
+
const d = br(l, n, t.attrs);
|
|
1651
|
+
return d ? (r.wrap(l, d), s && s(r.scrollIntoView()), i <= c) : !1;
|
|
1647
1652
|
}) : !1;
|
|
1648
1653
|
}, Ma = (e, t) => {
|
|
1649
1654
|
if (t.length === 0)
|
|
1650
1655
|
return !1;
|
|
1651
1656
|
const n = e.getJSON();
|
|
1652
1657
|
for (const r of t)
|
|
1653
|
-
if (!(r.type === "insertNode" ?
|
|
1658
|
+
if (!(r.type === "insertNode" ? Ve(e, r.payload) : r.type === "updateNodeAttrs" ? pe(e, r.payload) : r.type === "removeNode" ? vt(e, r.payload) : dn(e, r.payload)))
|
|
1654
1659
|
return e.commands.setContent(n), !1;
|
|
1655
1660
|
return !0;
|
|
1656
|
-
},
|
|
1661
|
+
}, $a = () => `claim_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`, Oa = ee.create({
|
|
1657
1662
|
name: "claim",
|
|
1658
1663
|
group: "block",
|
|
1659
1664
|
content: "inline*",
|
|
@@ -1676,6 +1681,40 @@ const De = () => {
|
|
|
1676
1681
|
0
|
|
1677
1682
|
];
|
|
1678
1683
|
},
|
|
1684
|
+
addKeyboardShortcuts() {
|
|
1685
|
+
return {
|
|
1686
|
+
Enter: () => {
|
|
1687
|
+
const { state: e, dispatch: t } = this.editor.view, { $from: n, empty: r } = e.selection, a = At(n);
|
|
1688
|
+
if (a === null) return !1;
|
|
1689
|
+
const s = n.node(a), c = n.before(a) + s.nodeSize;
|
|
1690
|
+
if (!r || n.pos !== c - 1) return !1;
|
|
1691
|
+
const l = c;
|
|
1692
|
+
let d = 0;
|
|
1693
|
+
e.doc.descendants((h) => (h.type.name === "claim" && d++, !0));
|
|
1694
|
+
const o = e.schema.nodes.claim.create(
|
|
1695
|
+
{
|
|
1696
|
+
number: d + 1,
|
|
1697
|
+
claimId: $a(),
|
|
1698
|
+
dependsOn: [],
|
|
1699
|
+
dependsOnClaimIds: []
|
|
1700
|
+
}
|
|
1701
|
+
), u = e.tr.insert(l, o), m = l + 1;
|
|
1702
|
+
return u.setSelection(Ie.create(u.doc, m)), t(u), !0;
|
|
1703
|
+
},
|
|
1704
|
+
Backspace: () => {
|
|
1705
|
+
const { state: e, dispatch: t } = this.editor.view, { $from: n, empty: r } = e.selection;
|
|
1706
|
+
if (!r) return !1;
|
|
1707
|
+
const a = At(n);
|
|
1708
|
+
if (a === null) return !1;
|
|
1709
|
+
const s = n.node(a);
|
|
1710
|
+
if (s.content.size > 0) return !1;
|
|
1711
|
+
let i = 0;
|
|
1712
|
+
if (e.doc.descendants((m) => (m.type.name === "claim" && i++, !0)), i <= 1) return !1;
|
|
1713
|
+
const c = n.before(a), l = c + s.nodeSize, d = e.tr.delete(c, l), o = Math.min(c, d.doc.content.size), u = d.doc.resolve(o);
|
|
1714
|
+
return d.setSelection(Ie.near(u)), t(d), !0;
|
|
1715
|
+
}
|
|
1716
|
+
};
|
|
1717
|
+
},
|
|
1679
1718
|
addNodeView() {
|
|
1680
1719
|
return ({ editor: e, node: t, getPos: n }) => {
|
|
1681
1720
|
let r = t;
|
|
@@ -1685,59 +1724,64 @@ const De = () => {
|
|
|
1685
1724
|
s.className = "claim-label", s.contentEditable = "false";
|
|
1686
1725
|
const i = document.createElement("span");
|
|
1687
1726
|
i.className = "claim-body";
|
|
1688
|
-
const
|
|
1689
|
-
const o =
|
|
1690
|
-
s.textContent = `${u.claimLabel(m)}.
|
|
1727
|
+
const c = () => {
|
|
1728
|
+
const o = k.getState().editorLanguage, u = U(o), m = Number(r.attrs.number || 1);
|
|
1729
|
+
s.textContent = `${u.claimLabel(m)}. `, r.content.size > 0 ? (i.removeAttribute("data-placeholder"), a.classList.remove("claim-line--empty")) : (i.setAttribute("data-placeholder", o === "en" ? "Type claim content... (Enter to add next)" : "输入权利要求内容… (Enter 添加下一条)"), a.classList.add("claim-line--empty"));
|
|
1691
1730
|
};
|
|
1692
|
-
let
|
|
1693
|
-
const d =
|
|
1694
|
-
o.editorLanguage !==
|
|
1731
|
+
let l = k.getState().editorLanguage;
|
|
1732
|
+
const d = k.subscribe((o) => {
|
|
1733
|
+
o.editorLanguage !== l && (l = o.editorLanguage, c());
|
|
1695
1734
|
});
|
|
1696
1735
|
return a.addEventListener("mousedown", (o) => {
|
|
1697
1736
|
const u = o.target;
|
|
1698
1737
|
if (!(u instanceof HTMLElement) || u === i || i.contains(u)) return;
|
|
1699
1738
|
const m = typeof n == "function" ? n() : null;
|
|
1700
1739
|
if (typeof m != "number") return;
|
|
1701
|
-
const h = m + r.nodeSize - 1, p =
|
|
1740
|
+
const h = m + r.nodeSize - 1, p = Ie.create(e.state.doc, h);
|
|
1702
1741
|
e.view.dispatch(e.state.tr.setSelection(p));
|
|
1703
|
-
}), a.append(s, i),
|
|
1742
|
+
}), a.append(s, i), c(), {
|
|
1704
1743
|
dom: a,
|
|
1705
1744
|
contentDOM: i,
|
|
1706
|
-
update: (o) => o.type.name !== "claim" ? !1 : (r = o,
|
|
1745
|
+
update: (o) => o.type.name !== "claim" ? !1 : (r = o, c(), !0),
|
|
1707
1746
|
destroy: () => d()
|
|
1708
1747
|
};
|
|
1709
1748
|
};
|
|
1710
1749
|
}
|
|
1711
1750
|
});
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1751
|
+
function At(e) {
|
|
1752
|
+
for (let t = e.depth; t >= 0; t--)
|
|
1753
|
+
if (e.node(t).type.name === "claim") return t;
|
|
1754
|
+
return null;
|
|
1755
|
+
}
|
|
1756
|
+
let Fe = 0;
|
|
1757
|
+
const dt = [];
|
|
1758
|
+
let ze = !1;
|
|
1759
|
+
const Fa = 2e4, Lt = 6e4;
|
|
1760
|
+
let G = null, je = !1, ce = null, xe = null;
|
|
1761
|
+
const ut = /* @__PURE__ */ new Map();
|
|
1762
|
+
function Pt() {
|
|
1763
|
+
ce && (window.removeEventListener("message", ce), ce = null), G && (G.src = "about:blank", G.remove(), G = null), je = !1;
|
|
1720
1764
|
}
|
|
1721
|
-
function
|
|
1722
|
-
const n =
|
|
1765
|
+
function za(e, t) {
|
|
1766
|
+
const n = ut.get(e);
|
|
1723
1767
|
if (n) {
|
|
1724
1768
|
t(n);
|
|
1725
1769
|
return;
|
|
1726
1770
|
}
|
|
1727
|
-
|
|
1771
|
+
dt.push({ xml: e, callback: t }), mt();
|
|
1728
1772
|
}
|
|
1729
|
-
function
|
|
1730
|
-
if (
|
|
1731
|
-
|
|
1732
|
-
const { xml: e, callback: t } =
|
|
1773
|
+
function mt() {
|
|
1774
|
+
if (ze || dt.length === 0) return;
|
|
1775
|
+
ze = !0, xe && (clearTimeout(xe), xe = null);
|
|
1776
|
+
const { xml: e, callback: t } = dt.shift(), n = ut.get(e);
|
|
1733
1777
|
if (n) {
|
|
1734
|
-
t(n),
|
|
1778
|
+
t(n), ze = !1, xe = setTimeout(Pt, Lt), mt();
|
|
1735
1779
|
return;
|
|
1736
1780
|
}
|
|
1737
1781
|
ce && (window.removeEventListener("message", ce), ce = null);
|
|
1738
1782
|
let r = null;
|
|
1739
1783
|
const a = (i) => {
|
|
1740
|
-
r && (clearTimeout(r), r = null), i &&
|
|
1784
|
+
r && (clearTimeout(r), r = null), i && ut.set(e, i), t(i), ze = !1, xe = setTimeout(Pt, Lt), mt();
|
|
1741
1785
|
}, s = () => {
|
|
1742
1786
|
var i;
|
|
1743
1787
|
(i = G.contentWindow) == null || i.postMessage(
|
|
@@ -1746,25 +1790,25 @@ function ut() {
|
|
|
1746
1790
|
);
|
|
1747
1791
|
};
|
|
1748
1792
|
ce = (i) => {
|
|
1749
|
-
var
|
|
1793
|
+
var l;
|
|
1750
1794
|
if (!G || i.source !== G.contentWindow) return;
|
|
1751
|
-
let
|
|
1795
|
+
let c;
|
|
1752
1796
|
try {
|
|
1753
|
-
|
|
1797
|
+
c = typeof i.data == "string" ? JSON.parse(i.data) : i.data;
|
|
1754
1798
|
} catch {
|
|
1755
1799
|
return;
|
|
1756
1800
|
}
|
|
1757
|
-
|
|
1801
|
+
c.event === "init" ? (je = !0, s()) : c.event === "load" ? (l = G.contentWindow) == null || l.postMessage(
|
|
1758
1802
|
JSON.stringify({ action: "export", format: "svg" }),
|
|
1759
1803
|
"*"
|
|
1760
|
-
) :
|
|
1761
|
-
}, window.addEventListener("message", ce), r = setTimeout(() => a(""),
|
|
1804
|
+
) : c.event === "export" && a(c.data || "");
|
|
1805
|
+
}, window.addEventListener("message", ce), r = setTimeout(() => a(""), Fa), G ? je && s() : (G = document.createElement("iframe"), G.style.cssText = "position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;opacity:0;pointer-events:none;", document.body.appendChild(G), je = !1, G.src = "https://embed.diagrams.net/?embed=1&proto=json&spin=0&chrome=0");
|
|
1762
1806
|
}
|
|
1763
|
-
const
|
|
1807
|
+
const Be = () => {
|
|
1764
1808
|
document.querySelectorAll('body > svg[id^="fig-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
|
|
1765
1809
|
(e.id.startsWith("dmermaid") || e.id.startsWith("dfi")) && e.remove();
|
|
1766
1810
|
}), document.querySelectorAll("body > #dmermaid-svg").forEach((e) => e.remove()), document.querySelectorAll("body > style[data-mermaid-style]").forEach((e) => e.remove());
|
|
1767
|
-
},
|
|
1811
|
+
}, Ba = ee.create({
|
|
1768
1812
|
name: "figure",
|
|
1769
1813
|
group: "block",
|
|
1770
1814
|
content: "inline*",
|
|
@@ -1795,10 +1839,10 @@ const Fe = () => {
|
|
|
1795
1839
|
let r = t, a = !1, s = !1;
|
|
1796
1840
|
const i = document.createElement("figure");
|
|
1797
1841
|
i.setAttribute("data-type", "figure"), i.className = "figure-block";
|
|
1798
|
-
const
|
|
1799
|
-
|
|
1800
|
-
const
|
|
1801
|
-
|
|
1842
|
+
const c = document.createElement("div");
|
|
1843
|
+
c.className = "figure-visual", c.contentEditable = "false", c.setAttribute("spellcheck", "false");
|
|
1844
|
+
const l = document.createElement("img");
|
|
1845
|
+
l.className = "figure-img-preview";
|
|
1802
1846
|
const d = document.createElement("div");
|
|
1803
1847
|
d.className = "figure-upload-area";
|
|
1804
1848
|
const o = document.createElement("span");
|
|
@@ -1813,98 +1857,98 @@ const Fe = () => {
|
|
|
1813
1857
|
p.className = "figure-mermaid-preview", p.contentEditable = "false";
|
|
1814
1858
|
const f = document.createElement("div");
|
|
1815
1859
|
f.className = "figure-mermaid-view-hint", h.append(p, f);
|
|
1816
|
-
const
|
|
1817
|
-
|
|
1860
|
+
const C = document.createElement("div");
|
|
1861
|
+
C.className = "figure-mermaid-edit";
|
|
1818
1862
|
const w = document.createElement("textarea");
|
|
1819
1863
|
w.className = "figure-mermaid-editor", w.spellcheck = !1;
|
|
1820
|
-
const
|
|
1821
|
-
|
|
1864
|
+
const y = document.createElement("div");
|
|
1865
|
+
y.className = "figure-mermaid-toolbar";
|
|
1822
1866
|
const v = document.createElement("button");
|
|
1823
1867
|
v.className = "figure-mermaid-save-btn", v.type = "button";
|
|
1824
|
-
const
|
|
1825
|
-
|
|
1868
|
+
const x = document.createElement("button");
|
|
1869
|
+
x.className = "figure-mermaid-cancel-btn", x.type = "button";
|
|
1826
1870
|
const _ = document.createElement("span");
|
|
1827
|
-
_.className = "figure-mermaid-error-inline",
|
|
1871
|
+
_.className = "figure-mermaid-error-inline", y.append(_, x, v), C.append(w, y);
|
|
1828
1872
|
const L = document.createElement("div");
|
|
1829
1873
|
L.className = "figure-drawio-view", L.contentEditable = "false";
|
|
1830
1874
|
const P = document.createElement("img");
|
|
1831
1875
|
P.className = "figure-drawio-preview-img", P.style.display = "none";
|
|
1832
1876
|
const b = document.createElement("div");
|
|
1833
|
-
b.className = "figure-drawio-view-hint", L.append(P, b),
|
|
1877
|
+
b.className = "figure-drawio-view-hint", L.append(P, b), c.append(l, d, m), c.append(h, C), c.append(L);
|
|
1834
1878
|
const T = document.createElement("figcaption");
|
|
1835
1879
|
T.className = "figure-caption";
|
|
1836
|
-
const
|
|
1837
|
-
|
|
1838
|
-
const
|
|
1839
|
-
|
|
1840
|
-
const
|
|
1841
|
-
const
|
|
1842
|
-
typeof
|
|
1880
|
+
const E = document.createElement("span");
|
|
1881
|
+
E.className = "figure-id-label", E.contentEditable = "false";
|
|
1882
|
+
const D = document.createElement("span");
|
|
1883
|
+
D.className = "figure-caption-content", T.append(E, D), i.append(c, T);
|
|
1884
|
+
const M = (I) => {
|
|
1885
|
+
const N = typeof n == "function" ? n() : null;
|
|
1886
|
+
typeof N == "number" && e.commands.command(({ tr: R, dispatch: j }) => (R.setNodeMarkup(N, void 0, { ...r.attrs, ...I }), j && j(R), !0));
|
|
1843
1887
|
}, Y = (I) => {
|
|
1844
1888
|
if (!I || I.length === 0) return;
|
|
1845
|
-
const
|
|
1846
|
-
if (!
|
|
1889
|
+
const N = I[0];
|
|
1890
|
+
if (!N.type.startsWith("image/")) return;
|
|
1847
1891
|
const R = new FileReader();
|
|
1848
1892
|
R.onload = () => {
|
|
1849
|
-
typeof R.result == "string" &&
|
|
1850
|
-
}, R.readAsDataURL(
|
|
1893
|
+
typeof R.result == "string" && M({ imageSrc: R.result });
|
|
1894
|
+
}, R.readAsDataURL(N);
|
|
1851
1895
|
};
|
|
1852
1896
|
u.addEventListener("change", () => Y(u.files)), d.addEventListener("click", () => u.click()), m.addEventListener("click", (I) => {
|
|
1853
1897
|
I.stopPropagation(), u.click();
|
|
1854
|
-
}),
|
|
1898
|
+
}), c.addEventListener("dragover", (I) => {
|
|
1855
1899
|
r.attrs.contentType === "image" && (I.preventDefault(), I.stopPropagation(), d.classList.add("figure-upload-area--dragover"));
|
|
1856
|
-
}),
|
|
1900
|
+
}), c.addEventListener("dragleave", () => {
|
|
1857
1901
|
d.classList.remove("figure-upload-area--dragover");
|
|
1858
|
-
}),
|
|
1859
|
-
var
|
|
1860
|
-
d.classList.remove("figure-upload-area--dragover"), r.attrs.contentType === "image" && (I.preventDefault(), I.stopPropagation(), Y(((
|
|
1902
|
+
}), c.addEventListener("drop", (I) => {
|
|
1903
|
+
var N;
|
|
1904
|
+
d.classList.remove("figure-upload-area--dragover"), r.attrs.contentType === "image" && (I.preventDefault(), I.stopPropagation(), Y(((N = I.dataTransfer) == null ? void 0 : N.files) ?? null));
|
|
1861
1905
|
});
|
|
1862
|
-
const
|
|
1906
|
+
const Le = () => {
|
|
1863
1907
|
a || (a = !0, w.value = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "", _.textContent = "", _.style.display = "none", se(), requestAnimationFrame(() => w.focus()));
|
|
1864
|
-
},
|
|
1908
|
+
}, S = () => {
|
|
1865
1909
|
a = !1, se();
|
|
1866
1910
|
}, H = async () => {
|
|
1867
1911
|
const I = w.value;
|
|
1868
1912
|
_.textContent = "", _.style.display = "none";
|
|
1869
|
-
const
|
|
1870
|
-
if (
|
|
1913
|
+
const N = I.trim();
|
|
1914
|
+
if (N)
|
|
1871
1915
|
try {
|
|
1872
1916
|
const R = await import("mermaid");
|
|
1873
|
-
R.default.initialize({ startOnLoad: !1, theme: "default" }),
|
|
1874
|
-
const j = `fig-mermaid-${
|
|
1875
|
-
p.innerHTML = F,
|
|
1917
|
+
R.default.initialize({ startOnLoad: !1, theme: "default" }), Fe += 1;
|
|
1918
|
+
const j = `fig-mermaid-${Fe}`, { svg: F } = await R.default.render(j, N);
|
|
1919
|
+
p.innerHTML = F, Be();
|
|
1876
1920
|
} catch {
|
|
1877
|
-
|
|
1878
|
-
const R =
|
|
1921
|
+
Be();
|
|
1922
|
+
const R = k.getState().editorLanguage;
|
|
1879
1923
|
_.textContent = R === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", _.style.display = "inline";
|
|
1880
1924
|
return;
|
|
1881
1925
|
}
|
|
1882
|
-
|
|
1926
|
+
M({ mermaidCode: I }), a = !1, se();
|
|
1883
1927
|
};
|
|
1884
1928
|
h.addEventListener("dblclick", (I) => {
|
|
1885
|
-
I.preventDefault(), I.stopPropagation(),
|
|
1929
|
+
I.preventDefault(), I.stopPropagation(), Le();
|
|
1886
1930
|
}), v.addEventListener("click", (I) => {
|
|
1887
1931
|
I.stopPropagation(), H();
|
|
1888
|
-
}),
|
|
1889
|
-
I.stopPropagation(),
|
|
1932
|
+
}), x.addEventListener("click", (I) => {
|
|
1933
|
+
I.stopPropagation(), S();
|
|
1890
1934
|
}), w.addEventListener("mousedown", (I) => I.stopPropagation()), w.addEventListener("keydown", (I) => I.stopPropagation()), w.addEventListener("keypress", (I) => I.stopPropagation());
|
|
1891
1935
|
let $ = null, O = null, K = null;
|
|
1892
|
-
const
|
|
1936
|
+
const Tn = () => {
|
|
1893
1937
|
if (s) return;
|
|
1894
1938
|
s = !0, se(), O = document.createElement("div"), O.className = "drawio-modal-overlay";
|
|
1895
1939
|
const I = document.createElement("div");
|
|
1896
1940
|
I.className = "drawio-modal-content";
|
|
1897
|
-
const
|
|
1898
|
-
|
|
1899
|
-
const R = document.createElement("span"), j =
|
|
1941
|
+
const N = document.createElement("div");
|
|
1942
|
+
N.className = "drawio-modal-header";
|
|
1943
|
+
const R = document.createElement("span"), j = k.getState().editorLanguage;
|
|
1900
1944
|
R.textContent = j === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", R.className = "drawio-modal-title";
|
|
1901
1945
|
const F = document.createElement("button");
|
|
1902
|
-
F.className = "drawio-modal-close-btn", F.textContent = "✕", F.type = "button", F.addEventListener("click", () =>
|
|
1946
|
+
F.className = "drawio-modal-close-btn", F.textContent = "✕", F.type = "button", F.addEventListener("click", () => et()), N.append(R, F), K = document.createElement("iframe"), K.className = "drawio-modal-iframe", K.setAttribute("frameborder", "0"), I.append(N, K), O.appendChild(I), document.body.appendChild(O);
|
|
1903
1947
|
const Ce = j === "en" ? "en" : "zh";
|
|
1904
1948
|
K.src = `https://embed.diagrams.net/?embed=1&proto=json&spin=1&lang=${Ce}`;
|
|
1905
1949
|
const te = K;
|
|
1906
1950
|
$ = (ne) => {
|
|
1907
|
-
var ue,
|
|
1951
|
+
var ue, Pe;
|
|
1908
1952
|
if (!te || ne.source !== te.contentWindow) return;
|
|
1909
1953
|
let J;
|
|
1910
1954
|
try {
|
|
@@ -1920,84 +1964,84 @@ const Fe = () => {
|
|
|
1920
1964
|
);
|
|
1921
1965
|
} else if (J.event === "save") {
|
|
1922
1966
|
const me = J.xml || "";
|
|
1923
|
-
(
|
|
1967
|
+
(Pe = te.contentWindow) == null || Pe.postMessage(
|
|
1924
1968
|
JSON.stringify({ action: "export", format: "svg" }),
|
|
1925
1969
|
"*"
|
|
1926
|
-
),
|
|
1970
|
+
), M({ drawioXml: me });
|
|
1927
1971
|
} else if (J.event === "export") {
|
|
1928
1972
|
const me = J.data || "";
|
|
1929
|
-
|
|
1930
|
-
} else J.event === "exit" &&
|
|
1973
|
+
M({ drawioSvg: me }), et();
|
|
1974
|
+
} else J.event === "exit" && et();
|
|
1931
1975
|
}, window.addEventListener("message", $);
|
|
1932
|
-
},
|
|
1976
|
+
}, et = () => {
|
|
1933
1977
|
s = !1, $ && (window.removeEventListener("message", $), $ = null), K && (K.src = "about:blank", K = null), O && (O.remove(), O = null), se();
|
|
1934
1978
|
};
|
|
1935
1979
|
L.addEventListener("dblclick", (I) => {
|
|
1936
|
-
I.preventDefault(), I.stopPropagation(),
|
|
1980
|
+
I.preventDefault(), I.stopPropagation(), Tn();
|
|
1937
1981
|
}), i.addEventListener("mousedown", (I) => {
|
|
1938
|
-
const
|
|
1939
|
-
if (!(
|
|
1982
|
+
const N = I.target;
|
|
1983
|
+
if (!(N instanceof HTMLElement) || N === D || D.contains(N) || N === w || C.contains(N) || N === d || d.contains(N) || N === m || N === u || h.contains(N) || L.contains(N)) return;
|
|
1940
1984
|
const R = typeof n == "function" ? n() : null;
|
|
1941
1985
|
if (typeof R != "number") return;
|
|
1942
|
-
const j = R + r.nodeSize - 1, F =
|
|
1986
|
+
const j = R + r.nodeSize - 1, F = Ie.create(e.state.doc, j);
|
|
1943
1987
|
e.view.dispatch(e.state.tr.setSelection(F));
|
|
1944
1988
|
});
|
|
1945
|
-
let
|
|
1946
|
-
const
|
|
1947
|
-
const
|
|
1948
|
-
if (
|
|
1949
|
-
if (!
|
|
1989
|
+
let tt = !1, ve = "";
|
|
1990
|
+
const In = async (I) => {
|
|
1991
|
+
const N = I.trim();
|
|
1992
|
+
if (N !== ve) {
|
|
1993
|
+
if (!N) {
|
|
1950
1994
|
p.innerHTML = "", ve = "";
|
|
1951
1995
|
return;
|
|
1952
1996
|
}
|
|
1953
1997
|
try {
|
|
1954
1998
|
const R = await import("mermaid");
|
|
1955
|
-
R.default.initialize({ startOnLoad: !1, theme: "default" }),
|
|
1956
|
-
const j = `fig-mermaid-${
|
|
1957
|
-
p.innerHTML = F, ve =
|
|
1999
|
+
R.default.initialize({ startOnLoad: !1, theme: "default" }), Fe += 1;
|
|
2000
|
+
const j = `fig-mermaid-${Fe}`, { svg: F } = await R.default.render(j, N);
|
|
2001
|
+
p.innerHTML = F, ve = N;
|
|
1958
2002
|
} catch {
|
|
1959
2003
|
p.innerHTML = "", ve = "";
|
|
1960
2004
|
} finally {
|
|
1961
|
-
|
|
2005
|
+
Be();
|
|
1962
2006
|
}
|
|
1963
2007
|
}
|
|
1964
2008
|
}, se = () => {
|
|
1965
|
-
const I =
|
|
1966
|
-
j ? (
|
|
2009
|
+
const I = k.getState().editorLanguage, N = U(I), R = ["image", "mermaid", "drawio"].includes(r.attrs.contentType) ? r.attrs.contentType : "image", j = typeof r.attrs.id == "string" ? r.attrs.id.trim() : "", F = typeof r.attrs.imageSrc == "string" ? r.attrs.imageSrc : "", Ce = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "";
|
|
2010
|
+
j ? (E.textContent = `[${j}] `, E.style.display = "inline") : (E.textContent = "", E.style.display = "none");
|
|
1967
2011
|
const te = R === "image", ne = R === "mermaid", J = R === "drawio";
|
|
1968
|
-
|
|
2012
|
+
l.style.display = te && F ? "block" : "none", d.style.display = te && !F ? "flex" : "none", m.style.display = te && F ? "block" : "none", h.style.display = ne && !a ? "block" : "none", C.style.display = ne && a ? "block" : "none", L.style.display = J ? "flex" : "none", te && F && (l.src = F);
|
|
1969
2013
|
const ue = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
|
|
1970
|
-
J && (ue ? (P.src = ue, P.style.display = "block") : (P.src = "", P.style.display = "none")), o.textContent =
|
|
1971
|
-
const
|
|
1972
|
-
ne && !a && (
|
|
1973
|
-
const
|
|
1974
|
-
J &&
|
|
1975
|
-
|
|
2014
|
+
J && (ue ? (P.src = ue, P.style.display = "block") : (P.src = "", P.style.display = "none")), o.textContent = N.figureUploadHint || "点击上传或拖拽图片", m.textContent = N.figureReplaceImage || "更换图片", v.textContent = N.mermaidSaveAndRender || "保存并渲染", x.textContent = N.mermaidCancel || "取消";
|
|
2015
|
+
const Pe = Ce.trim().length > 0, me = p.querySelector("svg") !== null;
|
|
2016
|
+
ne && !a && (Pe && me ? (f.textContent = N.mermaidDoubleClickToEdit || "双击编辑", f.className = "figure-mermaid-view-hint figure-mermaid-view-hint--subtle") : (f.textContent = N.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", f.className = "figure-mermaid-view-hint figure-mermaid-view-hint--empty")), J && !s && (ue ? (b.textContent = N.mermaidDoubleClickToEdit || "双击编辑", b.className = "figure-drawio-view-hint figure-mermaid-view-hint--subtle") : (b.textContent = N.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", b.className = "figure-drawio-view-hint figure-mermaid-view-hint--empty")), ne && !a && Ce.trim() !== ve && In(Ce);
|
|
2017
|
+
const xt = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "";
|
|
2018
|
+
J && xt && !ue && !tt && !s && (tt = !0, za(xt, (St) => {
|
|
2019
|
+
St && M({ drawioSvg: St }), tt = !1;
|
|
1976
2020
|
}));
|
|
1977
2021
|
};
|
|
1978
|
-
let
|
|
1979
|
-
const
|
|
1980
|
-
I.editorLanguage !==
|
|
2022
|
+
let wt = k.getState().editorLanguage;
|
|
2023
|
+
const En = k.subscribe((I) => {
|
|
2024
|
+
I.editorLanguage !== wt && (wt = I.editorLanguage, se());
|
|
1981
2025
|
});
|
|
1982
2026
|
return se(), {
|
|
1983
2027
|
dom: i,
|
|
1984
|
-
contentDOM:
|
|
2028
|
+
contentDOM: D,
|
|
1985
2029
|
stopEvent: (I) => {
|
|
1986
|
-
const
|
|
1987
|
-
return !!(
|
|
2030
|
+
const N = I.target;
|
|
2031
|
+
return !!(N === w || C.contains(N) || N === u);
|
|
1988
2032
|
},
|
|
1989
2033
|
ignoreMutation: (I) => {
|
|
1990
|
-
const
|
|
1991
|
-
return !!(
|
|
2034
|
+
const N = I.target;
|
|
2035
|
+
return !!(c.contains(N) || E.contains(N));
|
|
1992
2036
|
},
|
|
1993
2037
|
update: (I) => I.type.name !== "figure" ? !1 : (r = I, se(), !0),
|
|
1994
2038
|
destroy: () => {
|
|
1995
|
-
|
|
2039
|
+
En(), Be(), $ && (window.removeEventListener("message", $), $ = null), K && (K.src = "about:blank", K = null), O && (O.remove(), O = null);
|
|
1996
2040
|
}
|
|
1997
2041
|
};
|
|
1998
2042
|
};
|
|
1999
2043
|
}
|
|
2000
|
-
}),
|
|
2044
|
+
}), Ha = ee.create({
|
|
2001
2045
|
name: "reference",
|
|
2002
2046
|
group: "inline",
|
|
2003
2047
|
inline: !0,
|
|
@@ -2058,7 +2102,7 @@ const Fe = () => {
|
|
|
2058
2102
|
return ({ node: e, editor: t }) => {
|
|
2059
2103
|
let n = e;
|
|
2060
2104
|
const r = document.createElement("span"), a = () => {
|
|
2061
|
-
const s = n.attrs.lang === "en" ? "en" : "zh", i = U(s),
|
|
2105
|
+
const s = n.attrs.lang === "en" ? "en" : "zh", i = U(s), c = n.attrs.targetType === "figure" ? "figure" : "claim", l = Number(n.attrs.resolvedNumber), d = typeof n.attrs.resolvedFigureId == "string" && n.attrs.resolvedFigureId ? n.attrs.resolvedFigureId : null, o = c === "figure" ? d || (s === "en" ? "Figure ?" : "附图?") : Number.isFinite(l) ? i.claimLabel(l) : s === "en" ? "Claim ?" : "权利要求?", u = n.attrs.displayText || o;
|
|
2062
2106
|
r.textContent = u, r.className = `reference-link${n.attrs.invalid ? " reference-link-invalid" : ""}`, r.setAttribute("data-type", "reference"), r.setAttribute("data-highlight", n.attrs.highlight ? "true" : "false"), r.title = n.attrs.invalid ? i.referenceNavigateDisabledTitle : i.referenceNavigateTitle;
|
|
2063
2107
|
};
|
|
2064
2108
|
return a(), r.addEventListener("click", () => {
|
|
@@ -2067,20 +2111,20 @@ const Fe = () => {
|
|
|
2067
2111
|
return;
|
|
2068
2112
|
let i = null;
|
|
2069
2113
|
if (s === "figure") {
|
|
2070
|
-
const
|
|
2071
|
-
if (!
|
|
2114
|
+
const c = typeof n.attrs.targetFigureId == "string" ? n.attrs.targetFigureId : "";
|
|
2115
|
+
if (!c)
|
|
2072
2116
|
return;
|
|
2073
|
-
t.state.doc.descendants((
|
|
2117
|
+
t.state.doc.descendants((l, d) => l.type.name !== "figure" ? !0 : l.attrs.id === c ? (i = d, !1) : !0), typeof i == "number" && t.chain().focus().setTextSelection(i + 1).run();
|
|
2074
2118
|
return;
|
|
2075
2119
|
}
|
|
2076
|
-
n.attrs.targetClaimId && (t.state.doc.descendants((
|
|
2120
|
+
n.attrs.targetClaimId && (t.state.doc.descendants((c, l) => c.type.name !== "claim" ? !0 : c.attrs.claimId === n.attrs.targetClaimId ? (i = l, !1) : !0), typeof i == "number" && t.chain().focus().setTextSelection(i + 1).run());
|
|
2077
2121
|
}), {
|
|
2078
2122
|
dom: r,
|
|
2079
2123
|
update: (s) => s.type.name !== this.name ? !1 : (n = s, a(), !0)
|
|
2080
2124
|
};
|
|
2081
2125
|
};
|
|
2082
2126
|
}
|
|
2083
|
-
}),
|
|
2127
|
+
}), Rt = {
|
|
2084
2128
|
technical_field: "sectionTitle_technical_field",
|
|
2085
2129
|
background_art: "sectionTitle_background_art",
|
|
2086
2130
|
summary: "sectionTitle_summary",
|
|
@@ -2095,7 +2139,7 @@ const Fe = () => {
|
|
|
2095
2139
|
design_description: "sectionTitle_design_description",
|
|
2096
2140
|
design_views: "sectionTitle_design_views",
|
|
2097
2141
|
design_brief: "sectionTitle_design_brief"
|
|
2098
|
-
},
|
|
2142
|
+
}, Ua = /* @__PURE__ */ new Set([
|
|
2099
2143
|
"abstract",
|
|
2100
2144
|
"abstract_drawing",
|
|
2101
2145
|
"claims",
|
|
@@ -2106,22 +2150,22 @@ const Fe = () => {
|
|
|
2106
2150
|
"design_description",
|
|
2107
2151
|
"design_views",
|
|
2108
2152
|
"design_brief"
|
|
2109
|
-
]),
|
|
2153
|
+
]), ja = /* @__PURE__ */ new Set([
|
|
2110
2154
|
"technical_field",
|
|
2111
2155
|
"background_art",
|
|
2112
2156
|
"summary",
|
|
2113
2157
|
"drawing_description",
|
|
2114
2158
|
"detailed_description"
|
|
2115
|
-
]),
|
|
2159
|
+
]), Ct = (e) => {
|
|
2116
2160
|
if (e.isText)
|
|
2117
2161
|
return (e.text ?? "").trim().length > 0;
|
|
2118
2162
|
if (e.isAtom || e.isLeaf || !["patent_section", "patent_title", "paragraph"].includes(e.type.name))
|
|
2119
2163
|
return !0;
|
|
2120
2164
|
let t = !1;
|
|
2121
2165
|
return e.forEach((n) => {
|
|
2122
|
-
!t &&
|
|
2166
|
+
!t && Ct(n) && (t = !0);
|
|
2123
2167
|
}), t;
|
|
2124
|
-
},
|
|
2168
|
+
}, Wa = ee.create({
|
|
2125
2169
|
name: "patent_title",
|
|
2126
2170
|
group: "block",
|
|
2127
2171
|
content: "inline*",
|
|
@@ -2150,41 +2194,41 @@ const Fe = () => {
|
|
|
2150
2194
|
s.className = "pb-heading", s.contentEditable = "false";
|
|
2151
2195
|
const i = document.createElement("div");
|
|
2152
2196
|
i.className = "ps-placeholder", i.contentEditable = "false";
|
|
2153
|
-
const
|
|
2154
|
-
|
|
2155
|
-
const
|
|
2197
|
+
const c = document.createElement("h1");
|
|
2198
|
+
c.className = "pt-title-content", a.append(s, i, c);
|
|
2199
|
+
const l = () => {
|
|
2156
2200
|
const f = typeof n == "function" ? n() : null;
|
|
2157
2201
|
return typeof f == "number" ? f : null;
|
|
2158
2202
|
}, d = () => {
|
|
2159
|
-
const f =
|
|
2160
|
-
f !== null &&
|
|
2203
|
+
const f = l();
|
|
2204
|
+
f !== null && k.getState().setActiveSection("patent_title", f);
|
|
2161
2205
|
}, o = () => {
|
|
2162
|
-
const f =
|
|
2163
|
-
f !== null && (
|
|
2206
|
+
const f = l();
|
|
2207
|
+
f !== null && (k.getState().openDraftingPanel("patent_title", f), e.commands.focus(f + 1));
|
|
2164
2208
|
};
|
|
2165
|
-
i.addEventListener("click", o),
|
|
2209
|
+
i.addEventListener("click", o), c.addEventListener("focusin", d), c.addEventListener("click", d);
|
|
2166
2210
|
const u = () => {
|
|
2167
|
-
const f =
|
|
2211
|
+
const f = k.getState(), C = U(f.editorLanguage), w = typeof C.bookTitle_description == "string" ? C.bookTitle_description : "说明书", y = typeof C.patentTitlePlaceholder == "string" ? C.patentTitlePlaceholder : "专利名称";
|
|
2168
2212
|
s.textContent = w;
|
|
2169
|
-
const v =
|
|
2170
|
-
i.textContent = `[${
|
|
2213
|
+
const v = Ct(r), x = f.rightPanel.activeSectionPos === l();
|
|
2214
|
+
i.textContent = `[${y}]`, i.style.display = v ? "none" : "", i.classList.toggle("ps-placeholder--active", x && !v), c.classList.toggle("pt-title-content--has-content", v);
|
|
2171
2215
|
};
|
|
2172
|
-
let m =
|
|
2173
|
-
const p =
|
|
2174
|
-
const
|
|
2175
|
-
m = f.editorLanguage, h = f.rightPanel.activeSectionPos, (
|
|
2216
|
+
let m = k.getState().editorLanguage, h = k.getState().rightPanel.activeSectionPos;
|
|
2217
|
+
const p = k.subscribe((f) => {
|
|
2218
|
+
const C = f.editorLanguage !== m, w = f.rightPanel.activeSectionPos !== h;
|
|
2219
|
+
m = f.editorLanguage, h = f.rightPanel.activeSectionPos, (C || w) && u();
|
|
2176
2220
|
});
|
|
2177
2221
|
return u(), {
|
|
2178
2222
|
dom: a,
|
|
2179
|
-
contentDOM:
|
|
2223
|
+
contentDOM: c,
|
|
2180
2224
|
update: (f) => f.type.name !== "patent_title" ? !1 : (r = f, u(), !0),
|
|
2181
2225
|
destroy: () => {
|
|
2182
|
-
p(), i.removeEventListener("click", o),
|
|
2226
|
+
p(), i.removeEventListener("click", o), c.removeEventListener("focusin", d), c.removeEventListener("click", d);
|
|
2183
2227
|
}
|
|
2184
2228
|
};
|
|
2185
2229
|
};
|
|
2186
2230
|
}
|
|
2187
|
-
}),
|
|
2231
|
+
}), qa = ee.create({
|
|
2188
2232
|
name: "patent_section",
|
|
2189
2233
|
group: "block",
|
|
2190
2234
|
content: "block+",
|
|
@@ -2216,15 +2260,15 @@ const Fe = () => {
|
|
|
2216
2260
|
const n = [];
|
|
2217
2261
|
return t.forEach((r) => {
|
|
2218
2262
|
r.type.name === "patent_section" || r.type.name === "patent_title" ? e(r.content).forEach((s) => n.push(s)) : r.isBlock && r.content.size > 0 ? n.push(r.copy(e(r.content))) : n.push(r);
|
|
2219
|
-
}),
|
|
2263
|
+
}), vr.from(n);
|
|
2220
2264
|
};
|
|
2221
2265
|
return [
|
|
2222
|
-
new
|
|
2223
|
-
key: new
|
|
2266
|
+
new Xe({
|
|
2267
|
+
key: new _e("patentSectionLock"),
|
|
2224
2268
|
props: {
|
|
2225
2269
|
transformPasted: (t) => {
|
|
2226
2270
|
const n = e(t.content);
|
|
2227
|
-
return new
|
|
2271
|
+
return new yr(n, t.openStart, t.openEnd);
|
|
2228
2272
|
}
|
|
2229
2273
|
},
|
|
2230
2274
|
filterTransaction: (t, n) => {
|
|
@@ -2251,63 +2295,79 @@ const Fe = () => {
|
|
|
2251
2295
|
s.contentEditable = "false";
|
|
2252
2296
|
const i = document.createElement("div");
|
|
2253
2297
|
i.className = "ps-body";
|
|
2254
|
-
const l = document.createElement("div");
|
|
2255
|
-
l.className = "ps-placeholder", l.contentEditable = "false";
|
|
2256
2298
|
const c = document.createElement("div");
|
|
2257
|
-
c.className = "ps-
|
|
2258
|
-
const
|
|
2299
|
+
c.className = "ps-placeholder", c.contentEditable = "false";
|
|
2300
|
+
const l = document.createElement("div");
|
|
2301
|
+
l.className = "ps-content";
|
|
2302
|
+
const d = document.createElement("button");
|
|
2303
|
+
d.type = "button", d.className = "claim-add-btn", d.contentEditable = "false", i.append(c, l, d), a.append(s, i);
|
|
2304
|
+
const o = () => {
|
|
2259
2305
|
const y = typeof n == "function" ? n() : null;
|
|
2260
2306
|
return typeof y == "number" ? y : null;
|
|
2261
|
-
}, o = () => {
|
|
2262
|
-
const y = d();
|
|
2263
|
-
if (y === null) return;
|
|
2264
|
-
N.getState().setActiveSection(r.attrs.sectionType, y);
|
|
2265
2307
|
}, u = () => {
|
|
2266
|
-
const y =
|
|
2308
|
+
const y = o();
|
|
2267
2309
|
if (y === null) return;
|
|
2268
|
-
|
|
2310
|
+
k.getState().setActiveSection(r.attrs.sectionType, y);
|
|
2311
|
+
}, m = () => {
|
|
2312
|
+
const y = o();
|
|
2313
|
+
if (y === null) return;
|
|
2314
|
+
k.getState().openDraftingPanel(r.attrs.sectionType, y), e.commands.focus(y + 1);
|
|
2315
|
+
}, h = (y) => {
|
|
2316
|
+
y.preventDefault(), y.stopPropagation();
|
|
2317
|
+
const v = `claim_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
2318
|
+
let x = 0;
|
|
2319
|
+
e.state.doc.descendants((E) => (E.type.name === "claim" && x++, !0));
|
|
2320
|
+
const _ = o();
|
|
2321
|
+
if (_ === null) return;
|
|
2322
|
+
const L = _ + r.nodeSize - 1, P = e.state.schema.nodes.claim.create({
|
|
2323
|
+
number: x + 1,
|
|
2324
|
+
claimId: v,
|
|
2325
|
+
dependsOn: [],
|
|
2326
|
+
dependsOnClaimIds: []
|
|
2327
|
+
}), b = e.state.tr.insert(L, P), T = L + 1;
|
|
2328
|
+
b.setSelection(Ie.create(b.doc, T)), e.view.dispatch(b), e.view.focus();
|
|
2269
2329
|
};
|
|
2270
|
-
|
|
2271
|
-
const
|
|
2272
|
-
const y =
|
|
2273
|
-
a.className = `ps${
|
|
2330
|
+
c.addEventListener("click", m), l.addEventListener("focusin", u), l.addEventListener("click", u), d.addEventListener("mousedown", h);
|
|
2331
|
+
const p = () => {
|
|
2332
|
+
const y = k.getState(), v = U(y.editorLanguage), x = Object.keys(Rt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", _ = Ua.has(x), L = ja.has(x), P = x === "claims", b = Rt[x], T = typeof v[b] == "string" ? v[b] : x, E = Ct(r), D = y.rightPanel.activeSectionPos === o();
|
|
2333
|
+
a.className = `ps${E ? "" : " ps--empty"}${L ? " ps--sub" : ""}`, a.setAttribute("data-section-type", x), s.className = _ ? "pb-heading" : "ps-heading ps-heading--sub", s.textContent = T, c.textContent = `[${T}]`, c.style.display = E ? "none" : "", c.classList.toggle("ps-placeholder--active", D && !E), l.classList.toggle("ps-content--has-content", E), P ? (d.style.display = "", d.textContent = y.editorLanguage === "en" ? "+ Add Claim" : "+ 添加权利要求") : d.style.display = "none";
|
|
2274
2334
|
};
|
|
2275
|
-
let
|
|
2276
|
-
const
|
|
2277
|
-
const
|
|
2278
|
-
|
|
2335
|
+
let f = k.getState().editorLanguage, C = k.getState().rightPanel.activeSectionPos;
|
|
2336
|
+
const w = k.subscribe((y) => {
|
|
2337
|
+
const v = y.editorLanguage !== f, x = y.rightPanel.activeSectionPos !== C;
|
|
2338
|
+
f = y.editorLanguage, C = y.rightPanel.activeSectionPos, (v || x) && p();
|
|
2279
2339
|
});
|
|
2280
|
-
return
|
|
2340
|
+
return p(), {
|
|
2281
2341
|
dom: a,
|
|
2282
|
-
contentDOM:
|
|
2283
|
-
update: (y) => y.type.name !== "patent_section" ? !1 : (r = y,
|
|
2342
|
+
contentDOM: l,
|
|
2343
|
+
update: (y) => y.type.name !== "patent_section" ? !1 : (r = y, p(), !0),
|
|
2284
2344
|
destroy: () => {
|
|
2285
|
-
|
|
2345
|
+
w(), c.removeEventListener("click", m), l.removeEventListener("focusin", u), l.removeEventListener("click", u), d.removeEventListener("mousedown", h);
|
|
2286
2346
|
}
|
|
2287
2347
|
};
|
|
2288
2348
|
};
|
|
2289
2349
|
}
|
|
2290
|
-
}),
|
|
2350
|
+
}), Ga = [
|
|
2291
2351
|
"abstract",
|
|
2292
2352
|
// 说明书摘要
|
|
2293
2353
|
"abstract_drawing"
|
|
2294
2354
|
// 摘要附图
|
|
2295
|
-
],
|
|
2355
|
+
], Va = [
|
|
2296
2356
|
"technical_field",
|
|
2297
2357
|
"background_art",
|
|
2298
2358
|
"summary",
|
|
2299
2359
|
"drawing_description",
|
|
2300
2360
|
"detailed_description"
|
|
2301
|
-
],
|
|
2361
|
+
], Ka = [
|
|
2302
2362
|
"drawing_figures"
|
|
2303
2363
|
// 说明书附图
|
|
2304
|
-
],
|
|
2364
|
+
], Ja = [
|
|
2305
2365
|
"design_product_name",
|
|
2306
2366
|
"design_usage",
|
|
2307
2367
|
"design_description",
|
|
2308
2368
|
"design_views",
|
|
2309
2369
|
"design_brief"
|
|
2310
|
-
],
|
|
2370
|
+
], We = (e) => ({
|
|
2311
2371
|
type: "patent_section",
|
|
2312
2372
|
attrs: {
|
|
2313
2373
|
sectionType: e,
|
|
@@ -2318,26 +2378,26 @@ const Fe = () => {
|
|
|
2318
2378
|
type: "paragraph"
|
|
2319
2379
|
}
|
|
2320
2380
|
]
|
|
2321
|
-
}),
|
|
2381
|
+
}), un = () => ({
|
|
2322
2382
|
type: "patent_title",
|
|
2323
2383
|
content: []
|
|
2324
|
-
}),
|
|
2325
|
-
...
|
|
2326
|
-
|
|
2327
|
-
...
|
|
2328
|
-
...
|
|
2329
|
-
],
|
|
2330
|
-
|
|
2331
|
-
...
|
|
2332
|
-
],
|
|
2384
|
+
}), Xa = () => [
|
|
2385
|
+
...Ga.map(We),
|
|
2386
|
+
un(),
|
|
2387
|
+
...Va.map(We),
|
|
2388
|
+
...Ka.map(We)
|
|
2389
|
+
], Qa = () => [
|
|
2390
|
+
un(),
|
|
2391
|
+
...Ja.map(We)
|
|
2392
|
+
], mn = (e = "invention") => ({ type: "doc", content: e === "design" ? Qa() : Xa() }), Dt = 400, V = {
|
|
2333
2393
|
lastClaimWarningSignature: "",
|
|
2334
2394
|
lastInvalidReferenceSignature: "",
|
|
2335
2395
|
lastClaimGraphSignature: "",
|
|
2336
2396
|
invalidReferenceHandler: null,
|
|
2337
2397
|
claimGraphHandler: null
|
|
2338
|
-
}, fe = (e) =>
|
|
2339
|
-
const n =
|
|
2340
|
-
|
|
2398
|
+
}, fe = (e) => yt(e, (t) => t.type.name === "claim"), ke = (e) => yt(e, (t) => t.type.name === "figure"), fn = () => `claim_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`, Z = (e) => typeof e != "string" ? "" : e.trim(), Mt = (e) => {
|
|
2399
|
+
const n = k.getState().editorLanguage === "en" ? "Fig." : "图", r = /* @__PURE__ */ new Set();
|
|
2400
|
+
ke(e).forEach((s) => {
|
|
2341
2401
|
const i = Z(s.node.attrs.id);
|
|
2342
2402
|
i && r.add(i);
|
|
2343
2403
|
});
|
|
@@ -2345,46 +2405,46 @@ const Fe = () => {
|
|
|
2345
2405
|
for (; r.has(`${n}${a}`); )
|
|
2346
2406
|
a += 1;
|
|
2347
2407
|
return `${n}${a}`;
|
|
2348
|
-
},
|
|
2349
|
-
const n =
|
|
2408
|
+
}, Ya = /^(Fig\.|图)(\d+)$/, Za = (e) => {
|
|
2409
|
+
const n = k.getState().editorLanguage === "en" ? "Fig." : "图", r = ke(e);
|
|
2350
2410
|
if (r.length === 0) return;
|
|
2351
2411
|
const a = [];
|
|
2352
2412
|
let s = 1;
|
|
2353
|
-
for (const
|
|
2354
|
-
const
|
|
2355
|
-
if (!
|
|
2413
|
+
for (const c of r) {
|
|
2414
|
+
const l = Z(c.node.attrs.id);
|
|
2415
|
+
if (!Ya.exec(l)) continue;
|
|
2356
2416
|
const o = `${n}${s}`;
|
|
2357
|
-
|
|
2417
|
+
l !== o && a.push({ pos: c.pos, expectedId: o, currentId: l }), s++;
|
|
2358
2418
|
}
|
|
2359
2419
|
if (a.length === 0) return;
|
|
2360
2420
|
const { tr: i } = e.state;
|
|
2361
|
-
for (const
|
|
2362
|
-
const
|
|
2363
|
-
!
|
|
2421
|
+
for (const c of a) {
|
|
2422
|
+
const l = i.doc.nodeAt(c.pos);
|
|
2423
|
+
!l || l.type.name !== "figure" || i.setNodeMarkup(c.pos, void 0, { ...l.attrs, id: c.expectedId });
|
|
2364
2424
|
}
|
|
2365
2425
|
i.steps.length > 0 && (i.setMeta("addToHistory", !1), e.view.dispatch(i));
|
|
2366
|
-
},
|
|
2426
|
+
}, qe = (e) => {
|
|
2367
2427
|
if (!Array.isArray(e))
|
|
2368
2428
|
return [];
|
|
2369
2429
|
const t = e.map((n) => Number(n)).filter((n) => Number.isFinite(n) && n > 0);
|
|
2370
2430
|
return Array.from(new Set(t)).sort((n, r) => n - r);
|
|
2371
|
-
},
|
|
2431
|
+
}, rt = (e) => {
|
|
2372
2432
|
if (!Array.isArray(e))
|
|
2373
2433
|
return [];
|
|
2374
2434
|
const t = e.map((n) => typeof n == "string" ? n.trim() : "").filter(Boolean);
|
|
2375
2435
|
return Array.from(new Set(t));
|
|
2376
|
-
},
|
|
2436
|
+
}, $t = (e, t) => {
|
|
2377
2437
|
if (e.length !== t.length)
|
|
2378
2438
|
return !1;
|
|
2379
2439
|
for (let n = 0; n < e.length; n += 1)
|
|
2380
2440
|
if (e[n] !== t[n])
|
|
2381
2441
|
return !1;
|
|
2382
2442
|
return !0;
|
|
2383
|
-
},
|
|
2443
|
+
}, ft = (e, t, n, r, a) => {
|
|
2384
2444
|
const s = U(e);
|
|
2385
2445
|
return a ? t === "figure" ? s.invalidFigureReference : s.invalidClaimReference : t === "figure" ? r || (e === "en" ? "Figure ?" : "附图?") : typeof n != "number" ? s.invalidClaimReference : s.claimLabel(n);
|
|
2386
|
-
},
|
|
2387
|
-
const t = [], n =
|
|
2446
|
+
}, Ke = () => k.getState().editorLanguage === "en" ? "en" : "zh", es = (e) => {
|
|
2447
|
+
const t = [], n = Ke(), r = new Map(e.map((d) => [d.claimId, d.number]));
|
|
2388
2448
|
e.forEach((d) => {
|
|
2389
2449
|
d.dependsOnClaimIds.forEach((o) => {
|
|
2390
2450
|
const u = r.get(o);
|
|
@@ -2402,16 +2462,16 @@ const Fe = () => {
|
|
|
2402
2462
|
});
|
|
2403
2463
|
});
|
|
2404
2464
|
});
|
|
2405
|
-
const a = new Map(e.map((d) => [d.claimId, d.dependsOnClaimIds])), s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(),
|
|
2465
|
+
const a = new Map(e.map((d) => [d.claimId, d.dependsOnClaimIds])), s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), l = (d) => {
|
|
2406
2466
|
if (i.has(d)) {
|
|
2407
|
-
|
|
2467
|
+
c.add(d);
|
|
2408
2468
|
return;
|
|
2409
2469
|
}
|
|
2410
2470
|
if (s.has(d))
|
|
2411
2471
|
return;
|
|
2412
|
-
s.add(d), i.add(d), (a.get(d) || []).forEach((u) =>
|
|
2472
|
+
s.add(d), i.add(d), (a.get(d) || []).forEach((u) => l(u)), i.delete(d);
|
|
2413
2473
|
};
|
|
2414
|
-
return e.forEach((d) =>
|
|
2474
|
+
return e.forEach((d) => l(d.claimId)), c.forEach((d) => {
|
|
2415
2475
|
const o = e.find((u) => u.claimId === d);
|
|
2416
2476
|
o && t.push({
|
|
2417
2477
|
claimId: d,
|
|
@@ -2422,36 +2482,36 @@ const Fe = () => {
|
|
|
2422
2482
|
}), t;
|
|
2423
2483
|
}, ie = (e) => {
|
|
2424
2484
|
const t = fe(e), n = /* @__PURE__ */ new Set(), r = t.map((o, u) => {
|
|
2425
|
-
const m = typeof o.node.attrs.claimId == "string" ? o.node.attrs.claimId : "", h = m && !n.has(m) ? m :
|
|
2485
|
+
const m = typeof o.node.attrs.claimId == "string" ? o.node.attrs.claimId : "", h = m && !n.has(m) ? m : fn();
|
|
2426
2486
|
return n.add(h), { pos: o.pos, node: o.node, claimId: h, number: u + 1 };
|
|
2427
2487
|
}), a = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
2428
2488
|
r.forEach((o) => {
|
|
2429
2489
|
a.set(o.number, o.claimId), s.set(o.claimId, o.number);
|
|
2430
2490
|
});
|
|
2431
2491
|
const i = r.map((o) => {
|
|
2432
|
-
const u =
|
|
2492
|
+
const u = rt(o.node.attrs.dependsOnClaimIds), h = qe(o.node.attrs.dependsOn).map((y) => a.get(y)).filter((y) => typeof y == "string"), f = (u.length > 0 ? u : h).filter((y, v, x) => x.indexOf(y) === v).filter((y) => y !== o.claimId && s.has(y)), C = f.map((y) => s.get(y)).filter((y) => typeof y == "number").sort((y, v) => y - v), w = {
|
|
2433
2493
|
...o.node.attrs,
|
|
2434
2494
|
claimId: o.claimId,
|
|
2435
2495
|
number: o.number,
|
|
2436
|
-
dependsOn:
|
|
2496
|
+
dependsOn: C,
|
|
2437
2497
|
dependsOnClaimIds: f
|
|
2438
2498
|
};
|
|
2439
2499
|
return { claimId: o.claimId, number: o.number, dependsOnClaimIds: f, pos: o.pos, attrs: w };
|
|
2440
|
-
}),
|
|
2500
|
+
}), c = es(i), l = e.commands.command(({ tr: o, dispatch: u }) => {
|
|
2441
2501
|
let m = !1;
|
|
2442
2502
|
return i.forEach((h) => {
|
|
2443
2503
|
const p = e.state.doc.nodeAt(h.pos);
|
|
2444
2504
|
if (!p || p.type.name !== "claim")
|
|
2445
2505
|
return;
|
|
2446
2506
|
const f = { ...h.attrs };
|
|
2447
|
-
(p.attrs.number !== f.number || p.attrs.claimId !== f.claimId ||
|
|
2448
|
-
|
|
2449
|
-
|
|
2507
|
+
(p.attrs.number !== f.number || p.attrs.claimId !== f.claimId || !$t(qe(p.attrs.dependsOn), qe(f.dependsOn)) || !$t(
|
|
2508
|
+
rt(p.attrs.dependsOnClaimIds),
|
|
2509
|
+
rt(f.dependsOnClaimIds)
|
|
2450
2510
|
)) && (o.setNodeMarkup(h.pos, void 0, f), m = !0);
|
|
2451
2511
|
}), m && u && u(o), !0;
|
|
2452
|
-
}), d =
|
|
2453
|
-
return d !== V.lastClaimGraphSignature && (V.lastClaimGraphSignature = d, V.claimGraphHandler && V.claimGraphHandler({ issues:
|
|
2454
|
-
},
|
|
2512
|
+
}), d = c.map((o) => `${o.claimId}:${o.code}`).join("|");
|
|
2513
|
+
return d !== V.lastClaimGraphSignature && (V.lastClaimGraphSignature = d, V.claimGraphHandler && V.claimGraphHandler({ issues: c }), c.length > 0 && console.warn(`Claim graph validation found ${c.length} issue(s).`)), l;
|
|
2514
|
+
}, gn = (e) => {
|
|
2455
2515
|
const t = /* @__PURE__ */ new Map();
|
|
2456
2516
|
return fe(e).forEach((n) => {
|
|
2457
2517
|
const r = typeof n.node.attrs.claimId == "string" ? n.node.attrs.claimId : "", a = Number(n.node.attrs.number);
|
|
@@ -2461,9 +2521,9 @@ const Fe = () => {
|
|
|
2461
2521
|
pos: n.pos
|
|
2462
2522
|
});
|
|
2463
2523
|
}), t;
|
|
2464
|
-
},
|
|
2524
|
+
}, pn = (e) => {
|
|
2465
2525
|
const t = /* @__PURE__ */ new Map();
|
|
2466
|
-
return
|
|
2526
|
+
return ke(e).forEach((n) => {
|
|
2467
2527
|
const r = Z(n.node.attrs.id);
|
|
2468
2528
|
r && t.set(r, {
|
|
2469
2529
|
id: r,
|
|
@@ -2471,49 +2531,49 @@ const Fe = () => {
|
|
|
2471
2531
|
});
|
|
2472
2532
|
}), t;
|
|
2473
2533
|
}, Q = (e) => {
|
|
2474
|
-
const t =
|
|
2475
|
-
if (!e.commands.command(({ tr:
|
|
2534
|
+
const t = gn(e), n = pn(e), r = [], a = Ke();
|
|
2535
|
+
if (!e.commands.command(({ tr: c, state: l, dispatch: d }) => {
|
|
2476
2536
|
let o = !1;
|
|
2477
|
-
return
|
|
2537
|
+
return l.doc.descendants((u, m) => {
|
|
2478
2538
|
if (u.type.name !== "reference")
|
|
2479
2539
|
return !0;
|
|
2480
|
-
const h = u.attrs.targetType === "figure" ? "figure" : "claim", p = typeof u.attrs.targetClaimId == "string" && u.attrs.targetClaimId ? u.attrs.targetClaimId : null, f = typeof u.attrs.targetFigureId == "string" && u.attrs.targetFigureId ? Z(u.attrs.targetFigureId) : null,
|
|
2540
|
+
const h = u.attrs.targetType === "figure" ? "figure" : "claim", p = typeof u.attrs.targetClaimId == "string" && u.attrs.targetClaimId ? u.attrs.targetClaimId : null, f = typeof u.attrs.targetFigureId == "string" && u.attrs.targetFigureId ? Z(u.attrs.targetFigureId) : null, C = h === "claim" && p ? t.get(p) : void 0, w = h === "figure" && f ? n.get(f) : void 0, y = C ? C.number : null, v = w ? w.id : null, x = h === "figure" ? !w : !C, _ = ft(a, h, y, v, x), L = h === "figure" ? v || u.attrs.target || f || null : C ? String(C.number) : u.attrs.target || p || null, P = {
|
|
2481
2541
|
...u.attrs,
|
|
2482
2542
|
targetType: h,
|
|
2483
2543
|
targetClaimId: p,
|
|
2484
2544
|
targetFigureId: f,
|
|
2485
|
-
resolvedNumber:
|
|
2545
|
+
resolvedNumber: y,
|
|
2486
2546
|
resolvedFigureId: v,
|
|
2487
|
-
invalid:
|
|
2547
|
+
invalid: x,
|
|
2488
2548
|
lang: a,
|
|
2489
2549
|
displayText: _,
|
|
2490
2550
|
target: L
|
|
2491
2551
|
};
|
|
2492
2552
|
return Object.keys(P).some(
|
|
2493
2553
|
(T) => P[T] !== u.attrs[T]
|
|
2494
|
-
) && (
|
|
2495
|
-
}), o && d && d(
|
|
2554
|
+
) && (c.setNodeMarkup(m, void 0, P), o = !0), x && r.push({ targetType: h, targetClaimId: p, targetFigureId: f, position: m }), !0;
|
|
2555
|
+
}), o && d && d(c), !0;
|
|
2496
2556
|
}))
|
|
2497
2557
|
return !1;
|
|
2498
|
-
const i = r.map((
|
|
2499
|
-
return i !== V.lastInvalidReferenceSignature && (V.lastInvalidReferenceSignature = i, r.forEach((
|
|
2500
|
-
V.invalidReferenceHandler && V.invalidReferenceHandler(
|
|
2558
|
+
const i = r.map((c) => `${c.position}:${c.targetType}:${c.targetClaimId || c.targetFigureId || "null"}`).join("|");
|
|
2559
|
+
return i !== V.lastInvalidReferenceSignature && (V.lastInvalidReferenceSignature = i, r.forEach((c) => {
|
|
2560
|
+
V.invalidReferenceHandler && V.invalidReferenceHandler(c);
|
|
2501
2561
|
})), !0;
|
|
2502
|
-
},
|
|
2562
|
+
}, Ot = (e) => {
|
|
2503
2563
|
const t = be(e, "claim"), n = t && typeof t.node.attrs.claimId == "string" ? t.node.attrs.claimId : null;
|
|
2504
2564
|
return e.commands.command(({ tr: r, state: a, dispatch: s }) => {
|
|
2505
2565
|
let i = !1;
|
|
2506
|
-
return a.doc.descendants((
|
|
2507
|
-
if (
|
|
2566
|
+
return a.doc.descendants((c, l) => {
|
|
2567
|
+
if (c.type.name !== "reference")
|
|
2508
2568
|
return !0;
|
|
2509
|
-
const d =
|
|
2510
|
-
return
|
|
2569
|
+
const d = c.attrs.targetType !== "figure" && !!n && c.attrs.targetClaimId === n && !c.attrs.invalid;
|
|
2570
|
+
return c.attrs.highlight !== d && (r.setNodeMarkup(l, void 0, { ...c.attrs, highlight: d }), i = !0), !0;
|
|
2511
2571
|
}), i && s && s(r), !0;
|
|
2512
2572
|
});
|
|
2513
|
-
},
|
|
2514
|
-
const t = fe(e).map((r) => ({ pos: r.pos, length: r.node.textContent.length })).filter((r) => r.length >
|
|
2515
|
-
n !== V.lastClaimWarningSignature && (V.lastClaimWarningSignature = n, t.length !== 0 && console.warn(`Claim content is too long for ${t.length} block(s). Suggested max: ${
|
|
2516
|
-
},
|
|
2573
|
+
}, ts = (e) => {
|
|
2574
|
+
const t = fe(e).map((r) => ({ pos: r.pos, length: r.node.textContent.length })).filter((r) => r.length > Dt), n = t.map((r) => `${r.pos}:${r.length}`).join("|");
|
|
2575
|
+
n !== V.lastClaimWarningSignature && (V.lastClaimWarningSignature = n, t.length !== 0 && console.warn(`Claim content is too long for ${t.length} block(s). Suggested max: ${Dt}.`));
|
|
2576
|
+
}, at = (e, t) => {
|
|
2517
2577
|
if (typeof t == "number")
|
|
2518
2578
|
return t;
|
|
2519
2579
|
const n = be(e, "claim");
|
|
@@ -2521,16 +2581,16 @@ const Fe = () => {
|
|
|
2521
2581
|
return n.pos;
|
|
2522
2582
|
const r = fe(e)[0];
|
|
2523
2583
|
return r ? r.pos : null;
|
|
2524
|
-
},
|
|
2584
|
+
}, ns = (e, t, n) => e.commands.command(({ tr: r, state: a, dispatch: s }) => {
|
|
2525
2585
|
const i = a.doc.nodeAt(t);
|
|
2526
2586
|
if (!i || i.type.name !== "claim")
|
|
2527
2587
|
return !1;
|
|
2528
|
-
const
|
|
2529
|
-
return n.trim().length === 0 ? r.delete(
|
|
2530
|
-
}),
|
|
2588
|
+
const c = t + 1, l = t + i.nodeSize - 1;
|
|
2589
|
+
return n.trim().length === 0 ? r.delete(c, l) : r.replaceWith(c, l, a.schema.text(n)), s && s(r), !0;
|
|
2590
|
+
}), rs = {
|
|
2531
2591
|
name: "patent",
|
|
2532
2592
|
version: "1.0.0",
|
|
2533
|
-
extensions: [
|
|
2593
|
+
extensions: [Oa, Ba, Ha, Wa, qa],
|
|
2534
2594
|
toolbarItems: [
|
|
2535
2595
|
{
|
|
2536
2596
|
id: "patent-claim-insert",
|
|
@@ -2560,52 +2620,52 @@ const Fe = () => {
|
|
|
2560
2620
|
execute: ({ editor: e }, t) => {
|
|
2561
2621
|
const n = typeof t == "object" && t ? t : {}, r = n.placement || "current", a = typeof n.text == "string" ? n.text : "", s = fe(e).length, i = {
|
|
2562
2622
|
number: n.number || s + 1,
|
|
2563
|
-
claimId:
|
|
2623
|
+
claimId: fn(),
|
|
2564
2624
|
dependsOn: [],
|
|
2565
2625
|
dependsOnClaimIds: []
|
|
2566
|
-
},
|
|
2567
|
-
let
|
|
2626
|
+
}, c = a ? [{ type: "text", text: a }] : [];
|
|
2627
|
+
let l;
|
|
2568
2628
|
if (r === "end") {
|
|
2569
2629
|
const o = fe(e).at(-1), u = o ? o.pos + o.node.nodeSize : e.state.doc.content.size;
|
|
2570
|
-
|
|
2630
|
+
l = Ve(e, { type: "claim", position: u, attrs: i, content: c });
|
|
2571
2631
|
} else
|
|
2572
|
-
|
|
2573
|
-
return !
|
|
2632
|
+
l = Ve(e, { type: "claim", attrs: i, content: c });
|
|
2633
|
+
return !l || !ie(e) ? !1 : Q(e);
|
|
2574
2634
|
}
|
|
2575
2635
|
},
|
|
2576
2636
|
updateClaim: {
|
|
2577
2637
|
description: "Update claim attrs and content",
|
|
2578
2638
|
category: "patent",
|
|
2579
2639
|
execute: ({ editor: e }, t) => {
|
|
2580
|
-
const n = typeof t == "object" && t ? t : {}, r =
|
|
2640
|
+
const n = typeof t == "object" && t ? t : {}, r = at(e, n.position);
|
|
2581
2641
|
if (typeof r != "number")
|
|
2582
2642
|
return !1;
|
|
2583
2643
|
const a = {};
|
|
2584
|
-
return typeof n.number == "number" && (a.number = n.number), !(Object.keys(a).length === 0 ? !0 : pe(e, { type: "claim", position: r, attrs: a })) || !(typeof n.text == "string" ?
|
|
2644
|
+
return typeof n.number == "number" && (a.number = n.number), !(Object.keys(a).length === 0 ? !0 : pe(e, { type: "claim", position: r, attrs: a })) || !(typeof n.text == "string" ? ns(e, r, n.text) : !0) || !ie(e) ? !1 : Q(e);
|
|
2585
2645
|
}
|
|
2586
2646
|
},
|
|
2587
2647
|
setClaimDependency: {
|
|
2588
2648
|
description: "Set claim dependency and regenerate prefix",
|
|
2589
2649
|
category: "patent",
|
|
2590
2650
|
execute: ({ editor: e }, t) => {
|
|
2591
|
-
const n = typeof t == "object" && t ? t : {}, r =
|
|
2651
|
+
const n = typeof t == "object" && t ? t : {}, r = at(e, n.position);
|
|
2592
2652
|
if (typeof r != "number")
|
|
2593
2653
|
return !1;
|
|
2594
2654
|
const a = e.state.doc.nodeAt(r);
|
|
2595
2655
|
if (!a || a.type.name !== "claim")
|
|
2596
2656
|
return !1;
|
|
2597
|
-
const s = Number(a.attrs.number), i = typeof a.attrs.claimId == "string" ? a.attrs.claimId : "",
|
|
2657
|
+
const s = Number(a.attrs.number), i = typeof a.attrs.claimId == "string" ? a.attrs.claimId : "", c = /* @__PURE__ */ new Map();
|
|
2598
2658
|
fe(e).forEach((m) => {
|
|
2599
2659
|
const h = Number(m.node.attrs.number), p = typeof m.node.attrs.claimId == "string" ? m.node.attrs.claimId : "";
|
|
2600
|
-
Number.isFinite(h) && h > 0 && p &&
|
|
2660
|
+
Number.isFinite(h) && h > 0 && p && c.set(h, p);
|
|
2601
2661
|
});
|
|
2602
|
-
const
|
|
2662
|
+
const l = qe(n.dependsOn).filter(
|
|
2603
2663
|
(m) => Number.isFinite(s) && m > 0 && m < s
|
|
2604
|
-
), d =
|
|
2664
|
+
), d = l.map((m) => c.get(m)).filter((m) => typeof m == "string" && m.length > 0 && m !== i);
|
|
2605
2665
|
return !pe(e, {
|
|
2606
2666
|
type: "claim",
|
|
2607
2667
|
position: r,
|
|
2608
|
-
attrs: { dependsOn:
|
|
2668
|
+
attrs: { dependsOn: l, dependsOnClaimIds: d }
|
|
2609
2669
|
}) || !ie(e) ? !1 : Q(e);
|
|
2610
2670
|
}
|
|
2611
2671
|
},
|
|
@@ -2617,14 +2677,14 @@ const Fe = () => {
|
|
|
2617
2677
|
if (!(n != null && n.lang))
|
|
2618
2678
|
return !1;
|
|
2619
2679
|
const r = n.lang === "en" ? "en" : "zh";
|
|
2620
|
-
|
|
2680
|
+
k.getState().setEditorLanguage(r);
|
|
2621
2681
|
const s = (n.scope || "all") === "current" ? be(e, "reference") : null;
|
|
2622
|
-
return e.commands.command(({ tr:
|
|
2682
|
+
return e.commands.command(({ tr: c, state: l, dispatch: d }) => {
|
|
2623
2683
|
let o = !1;
|
|
2624
|
-
return
|
|
2684
|
+
return l.doc.descendants((u, m) => (u.type.name !== "reference" || s && m !== s.pos || u.attrs.lang !== r && (c.setNodeMarkup(m, void 0, {
|
|
2625
2685
|
...u.attrs,
|
|
2626
2686
|
lang: r
|
|
2627
|
-
}), o = !0), !0)), o && d && d(
|
|
2687
|
+
}), o = !0), !0)), o && d && d(c), !0;
|
|
2628
2688
|
}) ? Q(e) : !1;
|
|
2629
2689
|
}
|
|
2630
2690
|
},
|
|
@@ -2637,8 +2697,8 @@ const Fe = () => {
|
|
|
2637
2697
|
description: "Delete claim node and reorder numbers",
|
|
2638
2698
|
category: "patent",
|
|
2639
2699
|
execute: ({ editor: e }, t) => {
|
|
2640
|
-
const r =
|
|
2641
|
-
return typeof r != "number" || !
|
|
2700
|
+
const r = at(e, (typeof t == "object" && t ? t : {}).position);
|
|
2701
|
+
return typeof r != "number" || !vt(e, { type: "claim", position: r }) || !ie(e) ? !1 : Q(e);
|
|
2642
2702
|
}
|
|
2643
2703
|
},
|
|
2644
2704
|
reorderClaims: {
|
|
@@ -2657,7 +2717,7 @@ const Fe = () => {
|
|
|
2657
2717
|
shortcut: "Ctrl+Shift+F",
|
|
2658
2718
|
isActive: ({ editor: e }) => e.isActive("figure"),
|
|
2659
2719
|
execute: ({ editor: e }, t) => {
|
|
2660
|
-
const n = typeof t == "object" && t ? t : {}, r = Z(n.id) ||
|
|
2720
|
+
const n = typeof t == "object" && t ? t : {}, r = Z(n.id) || Mt(e), a = n.contentType && ["image", "mermaid", "drawio"].includes(n.contentType) ? n.contentType : "image";
|
|
2661
2721
|
return e.chain().focus().insertContent({
|
|
2662
2722
|
type: "figure",
|
|
2663
2723
|
attrs: { id: r, contentType: a, imageSrc: "", mermaidCode: "", drawioXml: "" },
|
|
@@ -2675,10 +2735,10 @@ const Fe = () => {
|
|
|
2675
2735
|
const s = e.state.doc.nodeAt(a);
|
|
2676
2736
|
if (!s || s.type.name !== "figure")
|
|
2677
2737
|
return !1;
|
|
2678
|
-
const
|
|
2679
|
-
if (
|
|
2738
|
+
const c = (typeof n.id == "string" ? Z(n.id) : Z(s.attrs.id)) || Mt(e);
|
|
2739
|
+
if (ke(e).some((o) => o.pos === a ? !1 : Z(o.node.attrs.id) === c))
|
|
2680
2740
|
return !1;
|
|
2681
|
-
const d = { id:
|
|
2741
|
+
const d = { id: c };
|
|
2682
2742
|
return typeof n.contentType == "string" && ["image", "mermaid", "drawio"].includes(n.contentType) && (d.contentType = n.contentType), typeof n.imageSrc == "string" && (d.imageSrc = n.imageSrc), typeof n.mermaidCode == "string" && (d.mermaidCode = n.mermaidCode), typeof n.drawioXml == "string" && (d.drawioXml = n.drawioXml), pe(e, {
|
|
2683
2743
|
type: "figure",
|
|
2684
2744
|
position: a,
|
|
@@ -2692,7 +2752,7 @@ const Fe = () => {
|
|
|
2692
2752
|
execute: ({ editor: e }) => {
|
|
2693
2753
|
const t = /* @__PURE__ */ new Set();
|
|
2694
2754
|
let n = !1;
|
|
2695
|
-
return
|
|
2755
|
+
return ke(e).forEach((r) => {
|
|
2696
2756
|
const a = Z(r.node.attrs.id);
|
|
2697
2757
|
if (a) {
|
|
2698
2758
|
if (t.has(a)) {
|
|
@@ -2716,13 +2776,13 @@ const Fe = () => {
|
|
|
2716
2776
|
return typeof n.targetClaimId == "string" && n.targetClaimId.trim().length > 0;
|
|
2717
2777
|
},
|
|
2718
2778
|
execute: ({ editor: e }, t) => {
|
|
2719
|
-
const n = typeof t == "object" && t ? t : {}, r =
|
|
2779
|
+
const n = typeof t == "object" && t ? t : {}, r = gn(e), a = typeof n.targetClaimId == "string" ? n.targetClaimId.trim() : "";
|
|
2720
2780
|
if (!a)
|
|
2721
2781
|
return !1;
|
|
2722
2782
|
const s = r.get(a);
|
|
2723
2783
|
if (!s)
|
|
2724
2784
|
return !1;
|
|
2725
|
-
const i = s.number,
|
|
2785
|
+
const i = s.number, c = n.lang || Ke(), l = n.displayText || ft(c, "claim", i, null, !1);
|
|
2726
2786
|
return e.chain().focus().insertContent({
|
|
2727
2787
|
type: "reference",
|
|
2728
2788
|
attrs: {
|
|
@@ -2731,9 +2791,9 @@ const Fe = () => {
|
|
|
2731
2791
|
targetFigureId: null,
|
|
2732
2792
|
resolvedNumber: i,
|
|
2733
2793
|
resolvedFigureId: null,
|
|
2734
|
-
lang:
|
|
2794
|
+
lang: c,
|
|
2735
2795
|
invalid: !1,
|
|
2736
|
-
displayText:
|
|
2796
|
+
displayText: l,
|
|
2737
2797
|
target: n.target || String(i),
|
|
2738
2798
|
highlight: !1
|
|
2739
2799
|
}
|
|
@@ -2752,13 +2812,13 @@ const Fe = () => {
|
|
|
2752
2812
|
return typeof n.targetFigureId == "string" && n.targetFigureId.trim().length > 0;
|
|
2753
2813
|
},
|
|
2754
2814
|
execute: ({ editor: e }, t) => {
|
|
2755
|
-
const n = typeof t == "object" && t ? t : {}, r =
|
|
2815
|
+
const n = typeof t == "object" && t ? t : {}, r = pn(e), a = typeof n.targetFigureId == "string" ? Z(n.targetFigureId) : "";
|
|
2756
2816
|
if (!a)
|
|
2757
2817
|
return !1;
|
|
2758
2818
|
const s = r.get(a);
|
|
2759
2819
|
if (!s)
|
|
2760
2820
|
return !1;
|
|
2761
|
-
const i = n.lang ||
|
|
2821
|
+
const i = n.lang || Ke(), c = n.displayText || ft(i, "figure", null, s.id, !1);
|
|
2762
2822
|
return e.chain().focus().insertContent({
|
|
2763
2823
|
type: "reference",
|
|
2764
2824
|
attrs: {
|
|
@@ -2769,7 +2829,7 @@ const Fe = () => {
|
|
|
2769
2829
|
resolvedFigureId: s.id,
|
|
2770
2830
|
lang: i,
|
|
2771
2831
|
invalid: !1,
|
|
2772
|
-
displayText:
|
|
2832
|
+
displayText: c,
|
|
2773
2833
|
target: n.target || s.id,
|
|
2774
2834
|
highlight: !1
|
|
2775
2835
|
}
|
|
@@ -2782,14 +2842,14 @@ const Fe = () => {
|
|
|
2782
2842
|
execute: ({ editor: e }, t) => {
|
|
2783
2843
|
const n = typeof t == "object" && t ? t : null;
|
|
2784
2844
|
return !(n != null && n.targetClaimId) || !e.commands.command(({ tr: a, state: s, dispatch: i }) => {
|
|
2785
|
-
let
|
|
2786
|
-
return s.doc.descendants((
|
|
2787
|
-
...
|
|
2845
|
+
let c = !1;
|
|
2846
|
+
return s.doc.descendants((l, d) => (l.type.name !== "reference" || !l.attrs.invalid || (a.setNodeMarkup(d, void 0, {
|
|
2847
|
+
...l.attrs,
|
|
2788
2848
|
targetType: "claim",
|
|
2789
2849
|
targetClaimId: n.targetClaimId,
|
|
2790
2850
|
targetFigureId: null,
|
|
2791
2851
|
invalid: !1
|
|
2792
|
-
}),
|
|
2852
|
+
}), c = !0), !0)), c && i && i(a), c;
|
|
2793
2853
|
}) ? !1 : Q(e);
|
|
2794
2854
|
}
|
|
2795
2855
|
},
|
|
@@ -2807,7 +2867,7 @@ const Fe = () => {
|
|
|
2807
2867
|
description: "Insert patent document skeleton with all sections",
|
|
2808
2868
|
category: "patent",
|
|
2809
2869
|
execute: ({ editor: e }, t) => {
|
|
2810
|
-
const n = typeof t == "object" && t ? t : {}, r = n.patentType === "utility_model" ? "utility_model" : n.patentType === "design" ? "design" : "invention", a =
|
|
2870
|
+
const n = typeof t == "object" && t ? t : {}, r = n.patentType === "utility_model" ? "utility_model" : n.patentType === "design" ? "design" : "invention", a = mn(r);
|
|
2811
2871
|
return e.commands.setContent(a);
|
|
2812
2872
|
}
|
|
2813
2873
|
},
|
|
@@ -2827,16 +2887,16 @@ const Fe = () => {
|
|
|
2827
2887
|
}
|
|
2828
2888
|
},
|
|
2829
2889
|
onStateChange: (e) => {
|
|
2830
|
-
ie(e) && (Q(e),
|
|
2890
|
+
ie(e) && (Q(e), Ot(e), ts(e), Za(e));
|
|
2831
2891
|
},
|
|
2832
2892
|
onSelectionChange: (e) => {
|
|
2833
|
-
|
|
2893
|
+
Ot(e);
|
|
2834
2894
|
}
|
|
2835
|
-
},
|
|
2836
|
-
|
|
2837
|
-
const
|
|
2895
|
+
}, as = [Ea, ka, La, rs];
|
|
2896
|
+
as.forEach((e) => W.register(e));
|
|
2897
|
+
const ss = (e = {}) => {
|
|
2838
2898
|
const t = [
|
|
2839
|
-
...
|
|
2899
|
+
...xa,
|
|
2840
2900
|
...W.getExtensions(),
|
|
2841
2901
|
...e.extensions || []
|
|
2842
2902
|
];
|
|
@@ -2844,40 +2904,40 @@ const rs = (e = {}) => {
|
|
|
2844
2904
|
...e,
|
|
2845
2905
|
extensions: t
|
|
2846
2906
|
};
|
|
2847
|
-
},
|
|
2907
|
+
}, st = (e) => {
|
|
2848
2908
|
const { from: t, to: n } = e.state.selection;
|
|
2849
2909
|
return {
|
|
2850
2910
|
editor: e,
|
|
2851
2911
|
selection: { from: t, to: n },
|
|
2852
|
-
store:
|
|
2912
|
+
store: k.getState()
|
|
2853
2913
|
};
|
|
2854
|
-
},
|
|
2855
|
-
execCommand: (t, n, r) => W.executeCommand(t,
|
|
2856
|
-
canExecCommand: (t, n) => W.canExecuteCommand(t,
|
|
2857
|
-
isCommandActive: (t) => W.isCommandActive(t,
|
|
2914
|
+
}, Ae = (e) => ({
|
|
2915
|
+
execCommand: (t, n, r) => W.executeCommand(t, st(e), n, r),
|
|
2916
|
+
canExecCommand: (t, n) => W.canExecuteCommand(t, st(e), n),
|
|
2917
|
+
isCommandActive: (t) => W.isCommandActive(t, st(e)),
|
|
2858
2918
|
listCommands: () => W.getCommandNames(),
|
|
2859
|
-
insertNode: (t) =>
|
|
2919
|
+
insertNode: (t) => Ve(e, t),
|
|
2860
2920
|
updateNodeAttrs: (t) => pe(e, t),
|
|
2861
|
-
removeNode: (t) =>
|
|
2862
|
-
wrapSelection: (t) =>
|
|
2921
|
+
removeNode: (t) => vt(e, t),
|
|
2922
|
+
wrapSelection: (t) => dn(e, t),
|
|
2863
2923
|
applyTransactionBatch: (t) => Ma(e, t),
|
|
2864
|
-
findNodeByType: (t, n) =>
|
|
2924
|
+
findNodeByType: (t, n) => bt(e, t, n),
|
|
2865
2925
|
findAncestorNode: (t) => be(e, t),
|
|
2866
|
-
findCurrentBlock: () =>
|
|
2867
|
-
findNodesByPredicate: (t, n) =>
|
|
2868
|
-
}),
|
|
2926
|
+
findCurrentBlock: () => Pa(e),
|
|
2927
|
+
findNodesByPredicate: (t, n) => yt(e, t, n)
|
|
2928
|
+
}), is = /* @__PURE__ */ new Set([
|
|
2869
2929
|
"abstract",
|
|
2870
2930
|
"abstract_drawing",
|
|
2871
2931
|
"claims",
|
|
2872
2932
|
"drawing_figures"
|
|
2873
|
-
]),
|
|
2933
|
+
]), os = /* @__PURE__ */ new Set([
|
|
2874
2934
|
"technical_field",
|
|
2875
2935
|
"background_art",
|
|
2876
2936
|
"summary",
|
|
2877
2937
|
"drawing_description",
|
|
2878
2938
|
"detailed_description"
|
|
2879
2939
|
]);
|
|
2880
|
-
function
|
|
2940
|
+
function cs(e, t) {
|
|
2881
2941
|
const n = U(t), r = [];
|
|
2882
2942
|
return e.state.doc.descendants((a) => {
|
|
2883
2943
|
if (a.type.name === "patent_title") {
|
|
@@ -2890,76 +2950,76 @@ function is(e, t) {
|
|
|
2890
2950
|
}), !1;
|
|
2891
2951
|
}
|
|
2892
2952
|
if (a.type.name === "patent_section") {
|
|
2893
|
-
const s = a.attrs.sectionType, i = `sectionTitle_${s}`,
|
|
2953
|
+
const s = a.attrs.sectionType, i = `sectionTitle_${s}`, c = typeof n[i] == "string" ? n[i] : s, l = [];
|
|
2894
2954
|
return a.forEach((d) => {
|
|
2895
2955
|
const o = d.textContent.trim();
|
|
2896
|
-
o &&
|
|
2897
|
-
}), r.push({ type: "patent_section", sectionType: s, title:
|
|
2956
|
+
o && l.push(o);
|
|
2957
|
+
}), r.push({ type: "patent_section", sectionType: s, title: c, paragraphs: l }), !1;
|
|
2898
2958
|
}
|
|
2899
2959
|
return !0;
|
|
2900
2960
|
}), r;
|
|
2901
2961
|
}
|
|
2902
|
-
function
|
|
2903
|
-
return new
|
|
2904
|
-
children: [new
|
|
2905
|
-
alignment:
|
|
2962
|
+
function Ft(e) {
|
|
2963
|
+
return new Qe({
|
|
2964
|
+
children: [new Ye({ text: e, bold: !0, size: 32, font: "黑体" })],
|
|
2965
|
+
alignment: ht.CENTER,
|
|
2906
2966
|
spacing: { before: 400, after: 200 }
|
|
2907
2967
|
});
|
|
2908
2968
|
}
|
|
2909
|
-
function
|
|
2910
|
-
return new
|
|
2911
|
-
children: [new
|
|
2912
|
-
alignment:
|
|
2969
|
+
function zt(e) {
|
|
2970
|
+
return new Qe({
|
|
2971
|
+
children: [new Ye({ text: e, bold: !0, size: 28, font: "黑体" })],
|
|
2972
|
+
alignment: ht.CENTER,
|
|
2913
2973
|
spacing: { before: 240, after: 120 }
|
|
2914
2974
|
});
|
|
2915
2975
|
}
|
|
2916
|
-
function
|
|
2917
|
-
return new
|
|
2918
|
-
children: [new
|
|
2919
|
-
alignment:
|
|
2976
|
+
function ls(e) {
|
|
2977
|
+
return new Qe({
|
|
2978
|
+
children: [new Ye({ text: e, bold: !0, size: 36, font: "宋体" })],
|
|
2979
|
+
alignment: ht.CENTER,
|
|
2920
2980
|
spacing: { before: 200, after: 200 }
|
|
2921
2981
|
});
|
|
2922
2982
|
}
|
|
2923
|
-
function
|
|
2924
|
-
return new
|
|
2925
|
-
children: [new
|
|
2983
|
+
function it(e) {
|
|
2984
|
+
return new Qe({
|
|
2985
|
+
children: [new Ye({ text: e, size: 24, font: "宋体" })],
|
|
2926
2986
|
spacing: { line: 360 },
|
|
2927
2987
|
indent: { firstLine: Se(7) }
|
|
2928
2988
|
});
|
|
2929
2989
|
}
|
|
2930
|
-
function
|
|
2990
|
+
function ds(e, t) {
|
|
2931
2991
|
const n = U(t), r = [];
|
|
2932
2992
|
let a = !1;
|
|
2933
2993
|
for (const s of e) {
|
|
2934
|
-
if (
|
|
2935
|
-
r.push(
|
|
2994
|
+
if (is.has(s.sectionType)) {
|
|
2995
|
+
r.push(Ft(s.title));
|
|
2936
2996
|
for (const i of s.paragraphs)
|
|
2937
|
-
r.push(
|
|
2997
|
+
r.push(it(i));
|
|
2938
2998
|
continue;
|
|
2939
2999
|
}
|
|
2940
3000
|
if (s.type === "patent_title") {
|
|
2941
3001
|
if (!a) {
|
|
2942
3002
|
const i = typeof n.bookTitle_description == "string" ? n.bookTitle_description : "说明书";
|
|
2943
|
-
r.push(
|
|
3003
|
+
r.push(Ft(i)), a = !0;
|
|
2944
3004
|
}
|
|
2945
3005
|
for (const i of s.paragraphs)
|
|
2946
|
-
r.push(
|
|
3006
|
+
r.push(ls(i));
|
|
2947
3007
|
continue;
|
|
2948
3008
|
}
|
|
2949
|
-
if (
|
|
2950
|
-
r.push(
|
|
3009
|
+
if (os.has(s.sectionType)) {
|
|
3010
|
+
r.push(zt(s.title));
|
|
2951
3011
|
for (const i of s.paragraphs)
|
|
2952
|
-
r.push(
|
|
3012
|
+
r.push(it(i));
|
|
2953
3013
|
continue;
|
|
2954
3014
|
}
|
|
2955
|
-
r.push(
|
|
3015
|
+
r.push(zt(s.title));
|
|
2956
3016
|
for (const i of s.paragraphs)
|
|
2957
|
-
r.push(
|
|
3017
|
+
r.push(it(i));
|
|
2958
3018
|
}
|
|
2959
3019
|
return r;
|
|
2960
3020
|
}
|
|
2961
|
-
async function
|
|
2962
|
-
const n =
|
|
3021
|
+
async function Bt(e, t) {
|
|
3022
|
+
const n = cs(e, t), r = ds(n, t), a = n.find((d) => d.type === "patent_title"), s = a != null && a.paragraphs[0] ? `${a.paragraphs[0]}.docx` : "patent-document.docx", i = {
|
|
2963
3023
|
properties: {
|
|
2964
3024
|
page: {
|
|
2965
3025
|
margin: {
|
|
@@ -2971,32 +3031,32 @@ async function Ft(e, t) {
|
|
|
2971
3031
|
}
|
|
2972
3032
|
},
|
|
2973
3033
|
children: r
|
|
2974
|
-
},
|
|
3034
|
+
}, c = new Zr({
|
|
2975
3035
|
sections: [i]
|
|
2976
|
-
}),
|
|
2977
|
-
|
|
3036
|
+
}), l = await ea.toBlob(c);
|
|
3037
|
+
ta(l, s);
|
|
2978
3038
|
}
|
|
2979
|
-
async function
|
|
3039
|
+
async function us(e) {
|
|
2980
3040
|
window.print();
|
|
2981
3041
|
}
|
|
2982
|
-
const
|
|
2983
|
-
const [n, r] = z(!1), a = X(null), s = X(null), [i,
|
|
3042
|
+
const ms = ["history", "text", "structure", "format", "technical", "patent"], ot = (e) => e.split("_").map((t) => t.charAt(0).toUpperCase() + t.slice(1)).join(" "), ct = ({ btn: e, items: t }) => {
|
|
3043
|
+
const [n, r] = z(!1), a = X(null), s = X(null), [i, c] = z({ top: 0, left: 0 }), l = de(() => {
|
|
2984
3044
|
if (!a.current) return;
|
|
2985
3045
|
const d = a.current.getBoundingClientRect();
|
|
2986
|
-
|
|
3046
|
+
c({ top: d.bottom + 4, left: d.left });
|
|
2987
3047
|
}, []);
|
|
2988
3048
|
return B(() => {
|
|
2989
3049
|
if (!n) return;
|
|
2990
|
-
|
|
3050
|
+
l();
|
|
2991
3051
|
const d = (u) => {
|
|
2992
3052
|
var h, p;
|
|
2993
3053
|
const m = u.target;
|
|
2994
3054
|
(h = a.current) != null && h.contains(m) || (p = s.current) != null && p.contains(m) || r(!1);
|
|
2995
|
-
}, o = () =>
|
|
3055
|
+
}, o = () => l();
|
|
2996
3056
|
return document.addEventListener("mousedown", d), window.addEventListener("scroll", o, !0), () => {
|
|
2997
3057
|
document.removeEventListener("mousedown", d), window.removeEventListener("scroll", o, !0);
|
|
2998
3058
|
};
|
|
2999
|
-
}, [n,
|
|
3059
|
+
}, [n, l]), /* @__PURE__ */ A("div", { className: "flex items-center", children: [
|
|
3000
3060
|
/* @__PURE__ */ g(
|
|
3001
3061
|
"button",
|
|
3002
3062
|
{
|
|
@@ -3021,10 +3081,10 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3021
3081
|
e.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200 text-gray-500"
|
|
3022
3082
|
),
|
|
3023
3083
|
disabled: e.disabled,
|
|
3024
|
-
children: /* @__PURE__ */ g(
|
|
3084
|
+
children: /* @__PURE__ */ g(nn, { size: 12 })
|
|
3025
3085
|
}
|
|
3026
3086
|
),
|
|
3027
|
-
n &&
|
|
3087
|
+
n && Cr(
|
|
3028
3088
|
/* @__PURE__ */ g(
|
|
3029
3089
|
"div",
|
|
3030
3090
|
{
|
|
@@ -3047,21 +3107,21 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3047
3107
|
document.body
|
|
3048
3108
|
)
|
|
3049
3109
|
] });
|
|
3050
|
-
},
|
|
3110
|
+
}, fs = ({
|
|
3051
3111
|
editor: e,
|
|
3052
|
-
groupOrder: t =
|
|
3112
|
+
groupOrder: t = ms,
|
|
3053
3113
|
collapsibleGroups: n = !0,
|
|
3054
3114
|
defaultCollapsedGroups: r = []
|
|
3055
3115
|
}) => {
|
|
3056
|
-
const [a, s] = z(() => new Set(r)), { editorLanguage: i, setEditorLanguage:
|
|
3116
|
+
const [a, s] = z(() => new Set(r)), { editorLanguage: i, setEditorLanguage: c } = k(), l = U(i);
|
|
3057
3117
|
if (!e)
|
|
3058
3118
|
return null;
|
|
3059
|
-
const d =
|
|
3119
|
+
const d = Ae(e), o = i === "zh", u = [
|
|
3060
3120
|
{
|
|
3061
3121
|
id: "core-undo",
|
|
3062
3122
|
label: "Undo",
|
|
3063
3123
|
group: "history",
|
|
3064
|
-
icon:
|
|
3124
|
+
icon: wr,
|
|
3065
3125
|
tooltip: "Undo (Ctrl+Z)",
|
|
3066
3126
|
isActive: !1,
|
|
3067
3127
|
disabled: !e.can().chain().focus().undo().run(),
|
|
@@ -3073,7 +3133,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3073
3133
|
id: "core-redo",
|
|
3074
3134
|
label: "Redo",
|
|
3075
3135
|
group: "history",
|
|
3076
|
-
icon:
|
|
3136
|
+
icon: xr,
|
|
3077
3137
|
tooltip: "Redo (Ctrl+Y)",
|
|
3078
3138
|
isActive: !1,
|
|
3079
3139
|
disabled: !e.can().chain().focus().redo().run(),
|
|
@@ -3085,7 +3145,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3085
3145
|
id: "core-bold",
|
|
3086
3146
|
label: "Bold",
|
|
3087
3147
|
group: "text",
|
|
3088
|
-
icon:
|
|
3148
|
+
icon: Vt,
|
|
3089
3149
|
tooltip: "Bold",
|
|
3090
3150
|
isActive: e.isActive("bold"),
|
|
3091
3151
|
disabled: !1,
|
|
@@ -3097,7 +3157,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3097
3157
|
id: "core-italic",
|
|
3098
3158
|
label: "Italic",
|
|
3099
3159
|
group: "text",
|
|
3100
|
-
icon:
|
|
3160
|
+
icon: Kt,
|
|
3101
3161
|
tooltip: "Italic",
|
|
3102
3162
|
isActive: e.isActive("italic"),
|
|
3103
3163
|
disabled: !1,
|
|
@@ -3109,7 +3169,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3109
3169
|
id: "core-underline",
|
|
3110
3170
|
label: "Underline",
|
|
3111
3171
|
group: "text",
|
|
3112
|
-
icon:
|
|
3172
|
+
icon: Jt,
|
|
3113
3173
|
tooltip: "Underline",
|
|
3114
3174
|
isActive: e.isActive("underline"),
|
|
3115
3175
|
disabled: !1,
|
|
@@ -3121,7 +3181,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3121
3181
|
id: "core-strike",
|
|
3122
3182
|
label: "Strike",
|
|
3123
3183
|
group: "text",
|
|
3124
|
-
icon:
|
|
3184
|
+
icon: Xt,
|
|
3125
3185
|
tooltip: "Strike",
|
|
3126
3186
|
isActive: e.isActive("strike"),
|
|
3127
3187
|
disabled: !1,
|
|
@@ -3133,7 +3193,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3133
3193
|
id: "core-code",
|
|
3134
3194
|
label: "Code",
|
|
3135
3195
|
group: "text",
|
|
3136
|
-
icon:
|
|
3196
|
+
icon: Qt,
|
|
3137
3197
|
tooltip: "Code",
|
|
3138
3198
|
isActive: e.isActive("code"),
|
|
3139
3199
|
disabled: !1,
|
|
@@ -3145,7 +3205,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3145
3205
|
id: "core-superscript",
|
|
3146
3206
|
label: "Superscript",
|
|
3147
3207
|
group: "text",
|
|
3148
|
-
icon:
|
|
3208
|
+
icon: Yt,
|
|
3149
3209
|
tooltip: "Superscript (Ctrl+.)",
|
|
3150
3210
|
isActive: e.isActive("superscript"),
|
|
3151
3211
|
disabled: !1,
|
|
@@ -3157,7 +3217,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3157
3217
|
id: "core-subscript",
|
|
3158
3218
|
label: "Subscript",
|
|
3159
3219
|
group: "text",
|
|
3160
|
-
icon:
|
|
3220
|
+
icon: Zt,
|
|
3161
3221
|
tooltip: "Subscript (Ctrl+,)",
|
|
3162
3222
|
isActive: e.isActive("subscript"),
|
|
3163
3223
|
disabled: !1,
|
|
@@ -3169,7 +3229,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3169
3229
|
id: "core-paragraph",
|
|
3170
3230
|
label: "Paragraph",
|
|
3171
3231
|
group: "structure",
|
|
3172
|
-
icon:
|
|
3232
|
+
icon: Sr,
|
|
3173
3233
|
tooltip: "Paragraph",
|
|
3174
3234
|
isActive: e.isActive("paragraph"),
|
|
3175
3235
|
disabled: !1,
|
|
@@ -3181,7 +3241,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3181
3241
|
id: "core-heading1",
|
|
3182
3242
|
label: "H1",
|
|
3183
3243
|
group: "structure",
|
|
3184
|
-
icon:
|
|
3244
|
+
icon: Tr,
|
|
3185
3245
|
tooltip: "Heading 1",
|
|
3186
3246
|
isActive: e.isActive("heading", { level: 1 }),
|
|
3187
3247
|
disabled: !1,
|
|
@@ -3193,7 +3253,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3193
3253
|
id: "core-heading2",
|
|
3194
3254
|
label: "H2",
|
|
3195
3255
|
group: "structure",
|
|
3196
|
-
icon:
|
|
3256
|
+
icon: Ir,
|
|
3197
3257
|
tooltip: "Heading 2",
|
|
3198
3258
|
isActive: e.isActive("heading", { level: 2 }),
|
|
3199
3259
|
disabled: !1,
|
|
@@ -3205,7 +3265,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3205
3265
|
id: "core-heading3",
|
|
3206
3266
|
label: "H3",
|
|
3207
3267
|
group: "structure",
|
|
3208
|
-
icon:
|
|
3268
|
+
icon: Er,
|
|
3209
3269
|
tooltip: "Heading 3",
|
|
3210
3270
|
isActive: e.isActive("heading", { level: 3 }),
|
|
3211
3271
|
disabled: !1,
|
|
@@ -3217,7 +3277,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3217
3277
|
id: "core-align-left",
|
|
3218
3278
|
label: o ? "左对齐" : "Align Left",
|
|
3219
3279
|
group: "format",
|
|
3220
|
-
icon:
|
|
3280
|
+
icon: Nr,
|
|
3221
3281
|
tooltip: o ? "左对齐" : "Align Left",
|
|
3222
3282
|
isActive: e.isActive({ textAlign: "left" }),
|
|
3223
3283
|
disabled: !1,
|
|
@@ -3229,7 +3289,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3229
3289
|
id: "core-align-center",
|
|
3230
3290
|
label: o ? "居中" : "Center",
|
|
3231
3291
|
group: "format",
|
|
3232
|
-
icon:
|
|
3292
|
+
icon: kr,
|
|
3233
3293
|
tooltip: o ? "居中对齐" : "Align Center",
|
|
3234
3294
|
isActive: e.isActive({ textAlign: "center" }),
|
|
3235
3295
|
disabled: !1,
|
|
@@ -3241,7 +3301,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3241
3301
|
id: "core-align-right",
|
|
3242
3302
|
label: o ? "右对齐" : "Align Right",
|
|
3243
3303
|
group: "format",
|
|
3244
|
-
icon:
|
|
3304
|
+
icon: _r,
|
|
3245
3305
|
tooltip: o ? "右对齐" : "Align Right",
|
|
3246
3306
|
isActive: e.isActive({ textAlign: "right" }),
|
|
3247
3307
|
disabled: !1,
|
|
@@ -3253,7 +3313,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3253
3313
|
id: "core-align-justify",
|
|
3254
3314
|
label: o ? "两端对齐" : "Justify",
|
|
3255
3315
|
group: "format",
|
|
3256
|
-
icon:
|
|
3316
|
+
icon: Ar,
|
|
3257
3317
|
tooltip: o ? "两端对齐" : "Justify",
|
|
3258
3318
|
isActive: e.isActive({ textAlign: "justify" }),
|
|
3259
3319
|
disabled: !1,
|
|
@@ -3265,7 +3325,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3265
3325
|
id: "core-bullet-list",
|
|
3266
3326
|
label: "Bullet List",
|
|
3267
3327
|
group: "structure",
|
|
3268
|
-
icon:
|
|
3328
|
+
icon: Lr,
|
|
3269
3329
|
tooltip: "Bullet List",
|
|
3270
3330
|
isActive: e.isActive("bulletList"),
|
|
3271
3331
|
disabled: !1,
|
|
@@ -3277,7 +3337,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3277
3337
|
id: "core-ordered-list",
|
|
3278
3338
|
label: "Ordered List",
|
|
3279
3339
|
group: "structure",
|
|
3280
|
-
icon:
|
|
3340
|
+
icon: Pr,
|
|
3281
3341
|
tooltip: "Ordered List",
|
|
3282
3342
|
isActive: e.isActive("orderedList"),
|
|
3283
3343
|
disabled: !1,
|
|
@@ -3289,7 +3349,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3289
3349
|
id: "core-blockquote",
|
|
3290
3350
|
label: "Blockquote",
|
|
3291
3351
|
group: "structure",
|
|
3292
|
-
icon:
|
|
3352
|
+
icon: Rr,
|
|
3293
3353
|
tooltip: "Blockquote",
|
|
3294
3354
|
isActive: e.isActive("blockquote"),
|
|
3295
3355
|
disabled: !1,
|
|
@@ -3301,7 +3361,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3301
3361
|
id: "core-code-block",
|
|
3302
3362
|
label: "Code Block",
|
|
3303
3363
|
group: "structure",
|
|
3304
|
-
icon:
|
|
3364
|
+
icon: Dr,
|
|
3305
3365
|
tooltip: "Code Block",
|
|
3306
3366
|
isActive: e.isActive("codeBlock"),
|
|
3307
3367
|
disabled: !1,
|
|
@@ -3325,7 +3385,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3325
3385
|
id: "core-horizontal-rule",
|
|
3326
3386
|
label: "Horizontal Rule",
|
|
3327
3387
|
group: "structure",
|
|
3328
|
-
icon:
|
|
3388
|
+
icon: $r,
|
|
3329
3389
|
tooltip: "Horizontal Rule",
|
|
3330
3390
|
isActive: !1,
|
|
3331
3391
|
disabled: !1,
|
|
@@ -3337,7 +3397,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3337
3397
|
id: "core-task-list",
|
|
3338
3398
|
label: "Task List",
|
|
3339
3399
|
group: "structure",
|
|
3340
|
-
icon:
|
|
3400
|
+
icon: Or,
|
|
3341
3401
|
tooltip: "Task List",
|
|
3342
3402
|
isActive: e.isActive("taskList"),
|
|
3343
3403
|
disabled: !1,
|
|
@@ -3346,24 +3406,24 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3346
3406
|
}
|
|
3347
3407
|
}
|
|
3348
3408
|
], m = {
|
|
3349
|
-
GitGraph:
|
|
3350
|
-
Sigma:
|
|
3351
|
-
FunctionSquare:
|
|
3352
|
-
Workflow:
|
|
3353
|
-
Box:
|
|
3354
|
-
FileText:
|
|
3355
|
-
Link2:
|
|
3356
|
-
Image:
|
|
3409
|
+
GitGraph: Ur,
|
|
3410
|
+
Sigma: Hr,
|
|
3411
|
+
FunctionSquare: Br,
|
|
3412
|
+
Workflow: zr,
|
|
3413
|
+
Box: Fr,
|
|
3414
|
+
FileText: tn,
|
|
3415
|
+
Link2: pt,
|
|
3416
|
+
Image: en
|
|
3357
3417
|
}, h = W.getToolbarItems().map((b) => {
|
|
3358
|
-
const T = W.getCommandMeta(b.command),
|
|
3418
|
+
const T = W.getCommandMeta(b.command), E = b.tooltip || (T == null ? void 0 : T.description) || b.label, D = b.shortcut || (T == null ? void 0 : T.shortcut), M = D ? `${E} (${D})` : E;
|
|
3359
3419
|
return {
|
|
3360
3420
|
id: b.id,
|
|
3361
3421
|
label: b.label,
|
|
3362
3422
|
group: b.group || "technical",
|
|
3363
|
-
icon: b.icon ? m[b.icon] ||
|
|
3423
|
+
icon: b.icon ? m[b.icon] || Tt : Tt,
|
|
3364
3424
|
isActive: d.isCommandActive(b.command),
|
|
3365
3425
|
disabled: !d.canExecCommand(b.command),
|
|
3366
|
-
tooltip:
|
|
3426
|
+
tooltip: M,
|
|
3367
3427
|
run: () => {
|
|
3368
3428
|
d.execCommand(b.command);
|
|
3369
3429
|
}
|
|
@@ -3372,21 +3432,21 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3372
3432
|
id: "core-export",
|
|
3373
3433
|
label: o ? "导出" : "Export",
|
|
3374
3434
|
group: "patent",
|
|
3375
|
-
icon:
|
|
3435
|
+
icon: jr,
|
|
3376
3436
|
tooltip: o ? "导出文档" : "Export Document",
|
|
3377
3437
|
isActive: !1,
|
|
3378
3438
|
disabled: !1,
|
|
3379
|
-
run: () => void
|
|
3439
|
+
run: () => void Bt(e, i)
|
|
3380
3440
|
}, f = [
|
|
3381
|
-
{ label: o ? "导出 Word (.docx)" : "Export Word (.docx)", onClick: () => void
|
|
3382
|
-
{ label: o ? "导出 PDF (打印)" : "Export PDF (Print)", onClick: () => void
|
|
3383
|
-
],
|
|
3441
|
+
{ label: o ? "导出 Word (.docx)" : "Export Word (.docx)", onClick: () => void Bt(e, i) },
|
|
3442
|
+
{ label: o ? "导出 PDF (打印)" : "Export PDF (Print)", onClick: () => void us() }
|
|
3443
|
+
], C = [...u, ...h, p], w = C.map((b) => b.group).filter((b, T, E) => E.indexOf(b) === T && !t.includes(b)), v = [...t, ...w].map((b) => ({
|
|
3384
3444
|
group: b,
|
|
3385
|
-
items:
|
|
3386
|
-
})).filter((b) => b.items.length > 0),
|
|
3445
|
+
items: C.filter((T) => T.group === b)
|
|
3446
|
+
})).filter((b) => b.items.length > 0), x = (b) => {
|
|
3387
3447
|
s((T) => {
|
|
3388
|
-
const
|
|
3389
|
-
return
|
|
3448
|
+
const E = new Set(T);
|
|
3449
|
+
return E.has(b) ? E.delete(b) : E.add(b), E;
|
|
3390
3450
|
});
|
|
3391
3451
|
}, _ = [
|
|
3392
3452
|
{ label: o ? "插入表格 3×3" : "Insert Table 3×3", onClick: () => e.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run() },
|
|
@@ -3401,10 +3461,10 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3401
3461
|
{ label: o ? "切换表头" : "Toggle Header Row", onClick: () => e.chain().focus().toggleHeaderRow().run() },
|
|
3402
3462
|
{ label: o ? "删除表格" : "Delete Table", onClick: () => e.chain().focus().deleteTable().run() }
|
|
3403
3463
|
], L = [
|
|
3404
|
-
{ label:
|
|
3405
|
-
{ label:
|
|
3406
|
-
{ label:
|
|
3407
|
-
], P = (b) => b.id === "core-table" ? /* @__PURE__ */ g(
|
|
3464
|
+
{ label: l.insertImageFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "image" }) },
|
|
3465
|
+
{ label: l.insertMermaidFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "mermaid" }) },
|
|
3466
|
+
{ label: l.insertDrawioFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "drawio" }) }
|
|
3467
|
+
], P = (b) => b.id === "core-table" ? /* @__PURE__ */ g(ct, { btn: b, items: _ }, b.id) : b.id === "core-export" ? /* @__PURE__ */ g(ct, { btn: b, items: f }, b.id) : b.id === "patent-figure-insert" ? /* @__PURE__ */ g(ct, { btn: b, items: L }, b.id) : /* @__PURE__ */ g(
|
|
3408
3468
|
"button",
|
|
3409
3469
|
{
|
|
3410
3470
|
onClick: b.run,
|
|
@@ -3421,13 +3481,13 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3421
3481
|
);
|
|
3422
3482
|
return /* @__PURE__ */ g("div", { className: "border-b border-gray-200 bg-gray-50 sticky top-0 z-10 overflow-x-auto", children: /* @__PURE__ */ A("div", { className: "flex flex-nowrap md:flex-wrap gap-2 p-2 min-w-max md:min-w-0", children: [
|
|
3423
3483
|
/* @__PURE__ */ A("div", { className: "flex items-center gap-1 pr-2 mr-2 border-r border-gray-200", children: [
|
|
3424
|
-
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children:
|
|
3484
|
+
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: l.language }),
|
|
3425
3485
|
/* @__PURE__ */ A(
|
|
3426
3486
|
"select",
|
|
3427
3487
|
{
|
|
3428
3488
|
value: i,
|
|
3429
3489
|
onChange: (b) => {
|
|
3430
|
-
|
|
3490
|
+
c(b.target.value === "en" ? "en" : "zh");
|
|
3431
3491
|
},
|
|
3432
3492
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white text-gray-700",
|
|
3433
3493
|
children: [
|
|
@@ -3444,75 +3504,75 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3444
3504
|
"button",
|
|
3445
3505
|
{
|
|
3446
3506
|
onClick: () => {
|
|
3447
|
-
|
|
3507
|
+
x(b.group);
|
|
3448
3508
|
},
|
|
3449
3509
|
className: "px-2 py-1 text-xs rounded bg-gray-200 text-gray-700 hover:bg-gray-300",
|
|
3450
|
-
title: T ? `Expand ${
|
|
3451
|
-
children:
|
|
3510
|
+
title: T ? `Expand ${ot(b.group)}` : `Collapse ${ot(b.group)}`,
|
|
3511
|
+
children: ot(b.group)
|
|
3452
3512
|
}
|
|
3453
3513
|
),
|
|
3454
3514
|
(!n || !T) && b.items.map(P)
|
|
3455
3515
|
] }, b.group);
|
|
3456
3516
|
})
|
|
3457
3517
|
] }) });
|
|
3458
|
-
},
|
|
3459
|
-
const [t, n] = z(0), [r, a] = z(""), [s, i] = z(""),
|
|
3518
|
+
}, gs = ({ editor: e }) => {
|
|
3519
|
+
const [t, n] = z(0), [r, a] = z(""), [s, i] = z(""), c = k((S) => S.editorLanguage), l = U(c);
|
|
3460
3520
|
if (B(() => {
|
|
3461
3521
|
if (!e) return;
|
|
3462
|
-
const
|
|
3463
|
-
return e.on("selectionUpdate",
|
|
3464
|
-
e.off("selectionUpdate",
|
|
3522
|
+
const S = () => n((H) => H + 1);
|
|
3523
|
+
return e.on("selectionUpdate", S), e.on("update", S), () => {
|
|
3524
|
+
e.off("selectionUpdate", S), e.off("update", S);
|
|
3465
3525
|
};
|
|
3466
3526
|
}, [e]), !e) return null;
|
|
3467
|
-
const d =
|
|
3468
|
-
e.state.doc.descendants((
|
|
3469
|
-
if (
|
|
3470
|
-
const H = typeof
|
|
3527
|
+
const d = Ae(e), o = [];
|
|
3528
|
+
e.state.doc.descendants((S) => {
|
|
3529
|
+
if (S.type.name !== "claim") return !0;
|
|
3530
|
+
const H = typeof S.attrs.claimId == "string" ? S.attrs.claimId : "", $ = Number(S.attrs.number);
|
|
3471
3531
|
return !H || !Number.isFinite($) || o.push({
|
|
3472
3532
|
id: H,
|
|
3473
3533
|
number: $,
|
|
3474
|
-
label:
|
|
3534
|
+
label: c === "en" ? `Claim ${$}` : `权利要求${$}`
|
|
3475
3535
|
}), !0;
|
|
3476
3536
|
});
|
|
3477
3537
|
const u = [];
|
|
3478
|
-
e.state.doc.descendants((
|
|
3479
|
-
if (
|
|
3480
|
-
const H = typeof
|
|
3538
|
+
e.state.doc.descendants((S) => {
|
|
3539
|
+
if (S.type.name !== "figure") return !0;
|
|
3540
|
+
const H = typeof S.attrs.id == "string" ? S.attrs.id.trim() : "";
|
|
3481
3541
|
return H && u.push({ id: H, label: H }), !0;
|
|
3482
3542
|
});
|
|
3483
|
-
const m = d.findAncestorNode("claim"), h = m && typeof m.node.attrs.claimId == "string" ? m.node.attrs.claimId : "", p = Number(m == null ? void 0 : m.node.attrs.number), f = Array.isArray(m == null ? void 0 : m.node.attrs.dependsOn) ? m.node.attrs.dependsOn.map((
|
|
3484
|
-
(
|
|
3485
|
-
), w = new Set(f),
|
|
3486
|
-
if (!
|
|
3487
|
-
const H = w.has(
|
|
3543
|
+
const m = d.findAncestorNode("claim"), h = m && typeof m.node.attrs.claimId == "string" ? m.node.attrs.claimId : "", p = Number(m == null ? void 0 : m.node.attrs.number), f = Array.isArray(m == null ? void 0 : m.node.attrs.dependsOn) ? m.node.attrs.dependsOn.map((S) => Number(S)).filter((S) => Number.isFinite(S)) : [], C = o.filter(
|
|
3544
|
+
(S) => Number.isFinite(p) && S.number < p
|
|
3545
|
+
), w = new Set(f), y = !!h, v = (S) => {
|
|
3546
|
+
if (!y) return;
|
|
3547
|
+
const H = w.has(S) ? f.filter(($) => $ !== S) : [...f, S].sort(($, O) => $ - O);
|
|
3488
3548
|
d.execCommand("patent.setClaimDependency", { dependsOn: H });
|
|
3489
|
-
},
|
|
3490
|
-
|
|
3491
|
-
const Y = (
|
|
3492
|
-
|
|
3493
|
-
position:
|
|
3494
|
-
contentType:
|
|
3549
|
+
}, x = d.findAncestorNode("figure"), _ = !!x, L = x && typeof x.node.attrs.id == "string" ? x.node.attrs.id.trim() : "", P = x && typeof x.node.attrs.contentType == "string" ? x.node.attrs.contentType : "image", [b, T] = z(""), E = X(null), D = X(null), M = (x == null ? void 0 : x.pos) ?? null;
|
|
3550
|
+
M !== D.current && (D.current = M, _ && L !== b && T(L));
|
|
3551
|
+
const Y = (S) => {
|
|
3552
|
+
x && d.execCommand("patent.updateFigure", {
|
|
3553
|
+
position: x.pos,
|
|
3554
|
+
contentType: S
|
|
3495
3555
|
});
|
|
3496
|
-
},
|
|
3497
|
-
if (!
|
|
3498
|
-
const
|
|
3499
|
-
|
|
3500
|
-
position:
|
|
3501
|
-
id:
|
|
3556
|
+
}, Le = () => {
|
|
3557
|
+
if (!x) return;
|
|
3558
|
+
const S = b.trim();
|
|
3559
|
+
S !== L && d.execCommand("patent.updateFigure", {
|
|
3560
|
+
position: x.pos,
|
|
3561
|
+
id: S
|
|
3502
3562
|
});
|
|
3503
3563
|
};
|
|
3504
3564
|
return /* @__PURE__ */ g("div", { className: "border-b border-gray-200 bg-gray-50 p-2", children: /* @__PURE__ */ A("div", { className: "bg-white border border-gray-200 rounded-md px-2 py-2 flex flex-wrap items-center gap-2", children: [
|
|
3505
3565
|
o.length > 0 && /* @__PURE__ */ A(we, { children: [
|
|
3506
|
-
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children:
|
|
3566
|
+
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: l.referenceTarget }),
|
|
3507
3567
|
/* @__PURE__ */ A(
|
|
3508
3568
|
"select",
|
|
3509
3569
|
{
|
|
3510
3570
|
value: r || "__none__",
|
|
3511
|
-
onChange: (
|
|
3571
|
+
onChange: (S) => a(S.target.value === "__none__" ? "" : S.target.value),
|
|
3512
3572
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
|
|
3513
3573
|
children: [
|
|
3514
|
-
/* @__PURE__ */ g("option", { value: "__none__", children:
|
|
3515
|
-
o.map((
|
|
3574
|
+
/* @__PURE__ */ g("option", { value: "__none__", children: l.referenceTargetPlaceholder }),
|
|
3575
|
+
o.map((S) => /* @__PURE__ */ g("option", { value: S.id, children: S.label }, S.id))
|
|
3516
3576
|
]
|
|
3517
3577
|
}
|
|
3518
3578
|
),
|
|
@@ -3526,22 +3586,22 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3526
3586
|
});
|
|
3527
3587
|
},
|
|
3528
3588
|
className: "p-2 hover:bg-blue-50 text-blue-600 rounded",
|
|
3529
|
-
title:
|
|
3530
|
-
children: /* @__PURE__ */ g(
|
|
3589
|
+
title: l.insertReference,
|
|
3590
|
+
children: /* @__PURE__ */ g(pt, { size: 16 })
|
|
3531
3591
|
}
|
|
3532
3592
|
)
|
|
3533
3593
|
] }),
|
|
3534
3594
|
u.length > 0 && /* @__PURE__ */ A(we, { children: [
|
|
3535
|
-
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children:
|
|
3595
|
+
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: l.figureReferenceTarget }),
|
|
3536
3596
|
/* @__PURE__ */ A(
|
|
3537
3597
|
"select",
|
|
3538
3598
|
{
|
|
3539
3599
|
value: s || "__none__",
|
|
3540
|
-
onChange: (
|
|
3600
|
+
onChange: (S) => i(S.target.value === "__none__" ? "" : S.target.value),
|
|
3541
3601
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
|
|
3542
3602
|
children: [
|
|
3543
|
-
/* @__PURE__ */ g("option", { value: "__none__", children:
|
|
3544
|
-
u.map((
|
|
3603
|
+
/* @__PURE__ */ g("option", { value: "__none__", children: l.figureReferenceTargetPlaceholder }),
|
|
3604
|
+
u.map((S) => /* @__PURE__ */ g("option", { value: S.id, children: S.label }, S.id))
|
|
3545
3605
|
]
|
|
3546
3606
|
}
|
|
3547
3607
|
),
|
|
@@ -3555,41 +3615,41 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3555
3615
|
});
|
|
3556
3616
|
},
|
|
3557
3617
|
className: "p-2 hover:bg-blue-50 text-blue-600 rounded",
|
|
3558
|
-
title:
|
|
3559
|
-
children: /* @__PURE__ */ g(
|
|
3618
|
+
title: l.insertFigureReference,
|
|
3619
|
+
children: /* @__PURE__ */ g(en, { size: 16 })
|
|
3560
3620
|
}
|
|
3561
3621
|
)
|
|
3562
3622
|
] }),
|
|
3563
3623
|
/* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" }),
|
|
3564
3624
|
_ && /* @__PURE__ */ A(we, { children: [
|
|
3565
|
-
/* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children:
|
|
3566
|
-
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children:
|
|
3625
|
+
/* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: l.currentFigure }),
|
|
3626
|
+
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: l.figureId }),
|
|
3567
3627
|
/* @__PURE__ */ g(
|
|
3568
3628
|
"input",
|
|
3569
3629
|
{
|
|
3570
|
-
ref:
|
|
3630
|
+
ref: E,
|
|
3571
3631
|
type: "text",
|
|
3572
3632
|
value: b,
|
|
3573
|
-
onChange: (
|
|
3574
|
-
onBlur:
|
|
3575
|
-
onKeyDown: (
|
|
3576
|
-
|
|
3633
|
+
onChange: (S) => T(S.target.value),
|
|
3634
|
+
onBlur: Le,
|
|
3635
|
+
onKeyDown: (S) => {
|
|
3636
|
+
S.key === "Enter" && (Le(), S.target.blur());
|
|
3577
3637
|
},
|
|
3578
3638
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white w-20",
|
|
3579
|
-
placeholder:
|
|
3639
|
+
placeholder: c === "en" ? "Fig.1" : "图1"
|
|
3580
3640
|
}
|
|
3581
3641
|
),
|
|
3582
|
-
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children:
|
|
3642
|
+
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: l.switchFigureType }),
|
|
3583
3643
|
/* @__PURE__ */ A(
|
|
3584
3644
|
"select",
|
|
3585
3645
|
{
|
|
3586
3646
|
value: P,
|
|
3587
|
-
onChange: (
|
|
3647
|
+
onChange: (S) => Y(S.target.value),
|
|
3588
3648
|
className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
|
|
3589
3649
|
children: [
|
|
3590
|
-
/* @__PURE__ */ g("option", { value: "image", children:
|
|
3591
|
-
/* @__PURE__ */ g("option", { value: "mermaid", children:
|
|
3592
|
-
/* @__PURE__ */ g("option", { value: "drawio", children:
|
|
3650
|
+
/* @__PURE__ */ g("option", { value: "image", children: l.figureContentTypeImage }),
|
|
3651
|
+
/* @__PURE__ */ g("option", { value: "mermaid", children: l.figureContentTypeMermaid }),
|
|
3652
|
+
/* @__PURE__ */ g("option", { value: "drawio", children: l.figureContentTypeDrawio })
|
|
3593
3653
|
]
|
|
3594
3654
|
}
|
|
3595
3655
|
),
|
|
@@ -3598,7 +3658,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3598
3658
|
e.isActive("image") && (() => {
|
|
3599
3659
|
const H = e.getAttributes("image").width || "";
|
|
3600
3660
|
return /* @__PURE__ */ A(we, { children: [
|
|
3601
|
-
/* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children:
|
|
3661
|
+
/* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: c === "zh" ? "图片" : "Image" }),
|
|
3602
3662
|
["25%", "50%", "75%", "100%"].map((O) => /* @__PURE__ */ g(
|
|
3603
3663
|
"button",
|
|
3604
3664
|
{
|
|
@@ -3611,47 +3671,47 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3611
3671
|
/* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" })
|
|
3612
3672
|
] });
|
|
3613
3673
|
})(),
|
|
3614
|
-
|
|
3615
|
-
/* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children:
|
|
3616
|
-
|
|
3617
|
-
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children:
|
|
3618
|
-
|
|
3674
|
+
y ? /* @__PURE__ */ A(we, { children: [
|
|
3675
|
+
/* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: l.currentClaim(p) }),
|
|
3676
|
+
C.length > 0 && /* @__PURE__ */ A("div", { className: "flex flex-wrap gap-1 items-center", children: [
|
|
3677
|
+
/* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: l.dependsOn }),
|
|
3678
|
+
C.map((S) => /* @__PURE__ */ g(
|
|
3619
3679
|
"button",
|
|
3620
3680
|
{
|
|
3621
|
-
onClick: () => v(
|
|
3622
|
-
className: `text-xs px-2 py-0.5 rounded border ${w.has(
|
|
3623
|
-
children:
|
|
3681
|
+
onClick: () => v(S.number),
|
|
3682
|
+
className: `text-xs px-2 py-0.5 rounded border ${w.has(S.number) ? "bg-blue-50 text-blue-700 border-blue-200" : "bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,
|
|
3683
|
+
children: S.number
|
|
3624
3684
|
},
|
|
3625
|
-
|
|
3685
|
+
S.id
|
|
3626
3686
|
))
|
|
3627
3687
|
] })
|
|
3628
|
-
] }) : _ ? null : /* @__PURE__ */ g("span", { className: "text-xs text-gray-400", children:
|
|
3688
|
+
] }) : _ ? null : /* @__PURE__ */ g("span", { className: "text-xs text-gray-400", children: l.placeCursorToEditDependencies }),
|
|
3629
3689
|
/* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" }),
|
|
3630
3690
|
/* @__PURE__ */ g(
|
|
3631
3691
|
"button",
|
|
3632
3692
|
{
|
|
3633
3693
|
onClick: async () => {
|
|
3634
|
-
if (
|
|
3635
|
-
const { from:
|
|
3636
|
-
|
|
3694
|
+
if (y && await d.execCommand("patent.deleteClaim") || e.chain().focus().deleteSelection().run()) return;
|
|
3695
|
+
const { from: S } = e.state.selection;
|
|
3696
|
+
S > 1 && e.chain().focus().deleteRange({ from: S - 1, to: S }).run();
|
|
3637
3697
|
},
|
|
3638
3698
|
className: "p-2 hover:bg-red-50 text-red-600 rounded",
|
|
3639
|
-
title:
|
|
3640
|
-
children: /* @__PURE__ */ g(
|
|
3699
|
+
title: l.deleteSelection,
|
|
3700
|
+
children: /* @__PURE__ */ g(Wr, { size: 16 })
|
|
3641
3701
|
}
|
|
3642
3702
|
)
|
|
3643
3703
|
] }) });
|
|
3644
|
-
},
|
|
3704
|
+
}, ps = (e) => {
|
|
3645
3705
|
if (!Array.isArray(e))
|
|
3646
3706
|
return [];
|
|
3647
3707
|
const t = e.map((n) => Number(n)).filter((n) => Number.isFinite(n) && n > 0);
|
|
3648
3708
|
return Array.from(new Set(t)).sort((n, r) => n - r);
|
|
3649
|
-
},
|
|
3709
|
+
}, hs = (e) => {
|
|
3650
3710
|
if (!Array.isArray(e))
|
|
3651
3711
|
return [];
|
|
3652
3712
|
const t = e.map((n) => typeof n == "string" ? n.trim() : "").filter(Boolean);
|
|
3653
3713
|
return Array.from(new Set(t));
|
|
3654
|
-
},
|
|
3714
|
+
}, bs = (e) => {
|
|
3655
3715
|
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() : "";
|
|
3656
3716
|
if (r)
|
|
3657
3717
|
return r;
|
|
@@ -3661,9 +3721,9 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3661
3721
|
}
|
|
3662
3722
|
const a = Number(e.attrs.resolvedNumber);
|
|
3663
3723
|
return Number.isFinite(a) ? t === "en" ? `Claim ${a}` : `权利要求${a}` : t === "en" ? "Claim ?" : "权利要求?";
|
|
3664
|
-
},
|
|
3724
|
+
}, hn = (e) => {
|
|
3665
3725
|
if (e.type.name === "reference")
|
|
3666
|
-
return
|
|
3726
|
+
return bs(e);
|
|
3667
3727
|
if (e.type.name === "hardBreak")
|
|
3668
3728
|
return `
|
|
3669
3729
|
`;
|
|
@@ -3671,9 +3731,9 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3671
3731
|
return e.text || "";
|
|
3672
3732
|
let t = "";
|
|
3673
3733
|
return e.forEach((n) => {
|
|
3674
|
-
t +=
|
|
3734
|
+
t += hn(n);
|
|
3675
3735
|
}), t;
|
|
3676
|
-
},
|
|
3736
|
+
}, ys = (e) => {
|
|
3677
3737
|
const t = [];
|
|
3678
3738
|
e.state.doc.descendants((r, a) => {
|
|
3679
3739
|
if (r.type.name !== "claim")
|
|
@@ -3682,9 +3742,9 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3682
3742
|
return !Number.isFinite(i) || i <= 0 || t.push({
|
|
3683
3743
|
claimId: s,
|
|
3684
3744
|
number: i,
|
|
3685
|
-
dependsOn:
|
|
3686
|
-
dependsOnClaimIds:
|
|
3687
|
-
body:
|
|
3745
|
+
dependsOn: ps(r.attrs.dependsOn),
|
|
3746
|
+
dependsOnClaimIds: hs(r.attrs.dependsOnClaimIds),
|
|
3747
|
+
body: hn(r).trim(),
|
|
3688
3748
|
pos: a
|
|
3689
3749
|
}), !0;
|
|
3690
3750
|
});
|
|
@@ -3696,7 +3756,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3696
3756
|
dependsOnClaimIds: Array.from(new Set(s))
|
|
3697
3757
|
};
|
|
3698
3758
|
});
|
|
3699
|
-
},
|
|
3759
|
+
}, vs = (e, t = "zh") => {
|
|
3700
3760
|
const n = [], r = new Map(e.map((o) => [o.claimId, o.number]));
|
|
3701
3761
|
e.forEach((o) => {
|
|
3702
3762
|
o.dependsOnClaimIds.forEach((u) => {
|
|
@@ -3712,14 +3772,14 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3712
3772
|
});
|
|
3713
3773
|
});
|
|
3714
3774
|
});
|
|
3715
|
-
const a = new Map(e.map((o) => [o.claimId, o.dependsOnClaimIds])), s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(),
|
|
3775
|
+
const a = new Map(e.map((o) => [o.claimId, o.dependsOnClaimIds])), s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), l = (o) => {
|
|
3716
3776
|
if (i.has(o)) {
|
|
3717
|
-
|
|
3777
|
+
c.add(o);
|
|
3718
3778
|
return;
|
|
3719
3779
|
}
|
|
3720
|
-
s.has(o) || (s.add(o), i.add(o), (a.get(o) || []).forEach((u) =>
|
|
3780
|
+
s.has(o) || (s.add(o), i.add(o), (a.get(o) || []).forEach((u) => l(u)), i.delete(o));
|
|
3721
3781
|
};
|
|
3722
|
-
e.forEach((o) =>
|
|
3782
|
+
e.forEach((o) => l(o.claimId)), c.forEach((o) => {
|
|
3723
3783
|
const u = e.find((m) => m.claimId === o);
|
|
3724
3784
|
u && n.push({
|
|
3725
3785
|
claimId: o,
|
|
@@ -3735,10 +3795,10 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3735
3795
|
}), e.forEach((o) => {
|
|
3736
3796
|
if (o.dependsOn.length > 1) {
|
|
3737
3797
|
const u = o.dependsOn, m = u.some((p) => {
|
|
3738
|
-
const f = e.find((
|
|
3798
|
+
const f = e.find((C) => C.number === p);
|
|
3739
3799
|
return f && f.dependsOn.length === 0;
|
|
3740
3800
|
}), h = u.some((p) => {
|
|
3741
|
-
const f = e.find((
|
|
3801
|
+
const f = e.find((C) => C.number === p);
|
|
3742
3802
|
return f && f.dependsOn.length > 0;
|
|
3743
3803
|
});
|
|
3744
3804
|
m && h && n.push({
|
|
@@ -3748,7 +3808,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3748
3808
|
});
|
|
3749
3809
|
}
|
|
3750
3810
|
}), n;
|
|
3751
|
-
},
|
|
3811
|
+
}, Cs = (e) => {
|
|
3752
3812
|
const t = new Map(e.map((o) => [o.claimId, o.dependsOnClaimIds])), n = /* @__PURE__ */ new Map();
|
|
3753
3813
|
e.forEach((o) => {
|
|
3754
3814
|
o.dependsOnClaimIds.forEach((u) => {
|
|
@@ -3756,36 +3816,36 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3756
3816
|
m.includes(o.claimId) || m.push(o.claimId), n.set(u, m);
|
|
3757
3817
|
});
|
|
3758
3818
|
});
|
|
3759
|
-
const r = e.filter((o) => (t.get(o.claimId) || []).length === 0).sort((o, u) => o.number - u.number).map((o) => o.claimId), a = e.map((o) => o.claimId), s = [...r, ...a.filter((o) => !r.includes(o))], i = new Map(e.map((o) => [o.claimId, o])),
|
|
3760
|
-
if (
|
|
3819
|
+
const r = e.filter((o) => (t.get(o.claimId) || []).length === 0).sort((o, u) => o.number - u.number).map((o) => o.claimId), a = e.map((o) => o.claimId), s = [...r, ...a.filter((o) => !r.includes(o))], i = new Map(e.map((o) => [o.claimId, o])), c = [], l = /* @__PURE__ */ new Set(), d = (o, u) => {
|
|
3820
|
+
if (l.has(o))
|
|
3761
3821
|
return;
|
|
3762
|
-
|
|
3822
|
+
l.add(o);
|
|
3763
3823
|
const m = i.get(o);
|
|
3764
3824
|
if (!m)
|
|
3765
3825
|
return;
|
|
3766
|
-
|
|
3826
|
+
c.push({
|
|
3767
3827
|
claimId: o,
|
|
3768
3828
|
number: m.number,
|
|
3769
3829
|
depth: u
|
|
3770
3830
|
}), (n.get(o) || []).map((p) => i.get(p)).filter((p) => !!p).sort((p, f) => p.number - f.number).map((p) => p.claimId).forEach((p) => d(p, u + 1));
|
|
3771
3831
|
};
|
|
3772
|
-
return s.forEach((o) => d(o, 0)),
|
|
3773
|
-
},
|
|
3774
|
-
`),
|
|
3832
|
+
return s.forEach((o) => d(o, 0)), c;
|
|
3833
|
+
}, ws = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), xs = (e) => `<claims>${e.sort((n, r) => n.number - r.number).map((n) => `<claim id="${n.number}"><claim-text>${ws(n.body)}</claim-text></claim>`).join("")}</claims>`, Ss = (e) => ["Claims", "", ...e.sort((n, r) => n.number - r.number).map((n) => `${n.number}. ${n.body}`)].join(`
|
|
3834
|
+
`), Ht = (e, t, n) => {
|
|
3775
3835
|
const r = new Blob([t], { type: n }), a = URL.createObjectURL(r), s = document.createElement("a");
|
|
3776
3836
|
s.href = a, s.download = e, s.click(), URL.revokeObjectURL(a);
|
|
3777
|
-
},
|
|
3778
|
-
const [t, n] = z(!1), r =
|
|
3837
|
+
}, Ts = ({ editor: e }) => {
|
|
3838
|
+
const [t, n] = z(!1), r = k((o) => o.editorLanguage), a = U(r), s = Ln({
|
|
3779
3839
|
editor: e,
|
|
3780
|
-
selector: (o) =>
|
|
3840
|
+
selector: (o) => ys(o.editor)
|
|
3781
3841
|
}), i = Te(
|
|
3782
|
-
() =>
|
|
3842
|
+
() => vs(s, r),
|
|
3783
3843
|
[s, r]
|
|
3784
|
-
),
|
|
3844
|
+
), c = Te(() => Cs(s), [s]), l = Te(
|
|
3785
3845
|
() => new Map(s.map((o) => [o.claimId, o.pos])),
|
|
3786
3846
|
[s]
|
|
3787
3847
|
), d = (o) => {
|
|
3788
|
-
const u =
|
|
3848
|
+
const u = l.get(o);
|
|
3789
3849
|
typeof u == "number" && e.chain().focus().setTextSelection(u + 1).run();
|
|
3790
3850
|
};
|
|
3791
3851
|
return /* @__PURE__ */ A("div", { className: "border-b border-gray-200 bg-white px-3 py-2", children: [
|
|
@@ -3799,7 +3859,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3799
3859
|
/* @__PURE__ */ g(
|
|
3800
3860
|
"button",
|
|
3801
3861
|
{
|
|
3802
|
-
onClick: () =>
|
|
3862
|
+
onClick: () => Ht("claims-cnipa.xml", xs(s), "application/xml;charset=utf-8"),
|
|
3803
3863
|
className: "px-3 py-2 text-left text-xs hover:bg-gray-50 text-gray-700",
|
|
3804
3864
|
children: a.exportCnipaXml
|
|
3805
3865
|
}
|
|
@@ -3807,14 +3867,14 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3807
3867
|
/* @__PURE__ */ g(
|
|
3808
3868
|
"button",
|
|
3809
3869
|
{
|
|
3810
|
-
onClick: () =>
|
|
3870
|
+
onClick: () => Ht("claims-word-mapping.txt", Ss(s), "text/plain;charset=utf-8"),
|
|
3811
3871
|
className: "px-3 py-2 text-left text-xs hover:bg-gray-50 text-gray-700",
|
|
3812
3872
|
children: a.exportWordMapping
|
|
3813
3873
|
}
|
|
3814
3874
|
)
|
|
3815
3875
|
] })
|
|
3816
3876
|
] }),
|
|
3817
|
-
|
|
3877
|
+
c.length > 0 && /* @__PURE__ */ g(
|
|
3818
3878
|
"button",
|
|
3819
3879
|
{
|
|
3820
3880
|
onClick: () => n((o) => !o),
|
|
@@ -3832,9 +3892,9 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3832
3892
|
},
|
|
3833
3893
|
`${o.claimId}-${o.code}-${u}`
|
|
3834
3894
|
)) }),
|
|
3835
|
-
t &&
|
|
3895
|
+
t && c.length > 0 && /* @__PURE__ */ A("div", { className: "mt-2 border border-gray-200 rounded p-2 bg-gray-50", children: [
|
|
3836
3896
|
/* @__PURE__ */ g("div", { className: "text-xs font-medium text-gray-600 mb-1", children: a.claimDependencyTree }),
|
|
3837
|
-
/* @__PURE__ */ g("div", { className: "space-y-0.5", children:
|
|
3897
|
+
/* @__PURE__ */ g("div", { className: "space-y-0.5", children: c.map((o) => /* @__PURE__ */ g(
|
|
3838
3898
|
"button",
|
|
3839
3899
|
{
|
|
3840
3900
|
onClick: () => d(o.claimId),
|
|
@@ -3846,7 +3906,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3846
3906
|
)) })
|
|
3847
3907
|
] })
|
|
3848
3908
|
] });
|
|
3849
|
-
},
|
|
3909
|
+
}, bn = {
|
|
3850
3910
|
// Invention & Utility Model
|
|
3851
3911
|
technical_field: [],
|
|
3852
3912
|
background_art: ["technical_field"],
|
|
@@ -3864,10 +3924,10 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
|
|
|
3864
3924
|
design_views: ["design_description"],
|
|
3865
3925
|
design_brief: ["design_description", "design_views"]
|
|
3866
3926
|
};
|
|
3867
|
-
function
|
|
3868
|
-
return (
|
|
3927
|
+
function io(e, t) {
|
|
3928
|
+
return (bn[e] || []).filter((r) => !t.has(r));
|
|
3869
3929
|
}
|
|
3870
|
-
function
|
|
3930
|
+
function Is(e) {
|
|
3871
3931
|
const t = [];
|
|
3872
3932
|
return e.state.doc.descendants((n, r) => n.type.name === "patent_title" ? (t.push({
|
|
3873
3933
|
sectionType: "patent_title",
|
|
@@ -3879,7 +3939,7 @@ function Ss(e) {
|
|
|
3879
3939
|
content: n.textContent || ""
|
|
3880
3940
|
}), !1) : !0), t;
|
|
3881
3941
|
}
|
|
3882
|
-
function
|
|
3942
|
+
function yn(e) {
|
|
3883
3943
|
const { from: t } = e.state.selection, n = e.state.doc.resolve(t);
|
|
3884
3944
|
for (let r = n.depth; r >= 0; r--) {
|
|
3885
3945
|
const a = n.node(r);
|
|
@@ -3898,10 +3958,10 @@ function bn(e) {
|
|
|
3898
3958
|
}
|
|
3899
3959
|
return null;
|
|
3900
3960
|
}
|
|
3901
|
-
function
|
|
3902
|
-
const n =
|
|
3961
|
+
function Es(e, t) {
|
|
3962
|
+
const n = bn[t];
|
|
3903
3963
|
if (!n || n.length === 0) return [];
|
|
3904
|
-
const r =
|
|
3964
|
+
const r = Is(e), a = new Map(r.map((s) => [s.sectionType, s]));
|
|
3905
3965
|
return n.map((s) => {
|
|
3906
3966
|
const i = a.get(s);
|
|
3907
3967
|
return !i || i.content.trim().length === 0 ? null : {
|
|
@@ -3910,23 +3970,23 @@ function Ts(e, t) {
|
|
|
3910
3970
|
};
|
|
3911
3971
|
}).filter((s) => s !== null && s.content.length > 0);
|
|
3912
3972
|
}
|
|
3913
|
-
function
|
|
3914
|
-
const n =
|
|
3915
|
-
let i = t.sectionType,
|
|
3973
|
+
function oo(e, t = {}) {
|
|
3974
|
+
const n = k.getState().editorLanguage, { from: r, to: a } = e.state.selection, s = r !== a ? e.state.doc.textBetween(r, a, " ", "\0") : void 0;
|
|
3975
|
+
let i = t.sectionType, c = t.targetSectionPos;
|
|
3916
3976
|
if (!i) {
|
|
3917
|
-
const u =
|
|
3918
|
-
u && (i = u.sectionType,
|
|
3977
|
+
const u = yn(e);
|
|
3978
|
+
u && (i = u.sectionType, c = u.pos);
|
|
3919
3979
|
}
|
|
3920
|
-
const
|
|
3980
|
+
const l = t.scope || (i ? "section" : s ? "selection" : "document"), d = i ? Es(e, i) : void 0;
|
|
3921
3981
|
let o;
|
|
3922
|
-
if (
|
|
3982
|
+
if (l === "selection" && r !== a) {
|
|
3923
3983
|
const m = Math.max(0, r - 200), h = Math.min(e.state.doc.content.size, a + 200), p = e.state.doc.textBetween(m, r, " ", "\0"), f = e.state.doc.textBetween(a, h, " ", "\0");
|
|
3924
3984
|
o = `...${p}[SELECTED]${f}...`;
|
|
3925
3985
|
}
|
|
3926
3986
|
return {
|
|
3927
|
-
scope:
|
|
3987
|
+
scope: l,
|
|
3928
3988
|
sectionType: i,
|
|
3929
|
-
targetSectionPos:
|
|
3989
|
+
targetSectionPos: c,
|
|
3930
3990
|
userInput: t.userInput,
|
|
3931
3991
|
selectedText: s,
|
|
3932
3992
|
dependencyContext: d,
|
|
@@ -3934,25 +3994,25 @@ function so(e, t = {}) {
|
|
|
3934
3994
|
language: n
|
|
3935
3995
|
};
|
|
3936
3996
|
}
|
|
3937
|
-
const
|
|
3938
|
-
const { addChatReference: n, openChatPanel: r, editorLanguage: a } =
|
|
3997
|
+
const Ns = ({ editor: e, onSelectionOptimize: t }) => {
|
|
3998
|
+
const { addChatReference: n, openChatPanel: r, editorLanguage: a } = k(), s = a === "zh", i = (d) => re(
|
|
3939
3999
|
"p-1.5 rounded transition-colors",
|
|
3940
4000
|
d ? "bg-blue-100 text-blue-600" : "text-gray-600 hover:bg-gray-100"
|
|
3941
|
-
),
|
|
4001
|
+
), c = () => {
|
|
3942
4002
|
const { from: d, to: o } = e.state.selection;
|
|
3943
4003
|
if (d === o) return;
|
|
3944
|
-
const u = e.state.doc.textBetween(d, o, " "), m =
|
|
4004
|
+
const u = e.state.doc.textBetween(d, o, " "), m = yn(e);
|
|
3945
4005
|
if (t) {
|
|
3946
4006
|
t({ text: u, from: d, to: o, sectionType: m == null ? void 0 : m.sectionType });
|
|
3947
4007
|
return;
|
|
3948
4008
|
}
|
|
3949
4009
|
n({ text: u, from: d, to: o, sectionType: m == null ? void 0 : m.sectionType }), r();
|
|
3950
|
-
},
|
|
4010
|
+
}, l = () => {
|
|
3951
4011
|
const d = e.getAttributes("link").href, o = window.prompt("URL", d || "https://");
|
|
3952
4012
|
o !== null && (o === "" ? e.chain().focus().extendMarkRange("link").unsetLink().run() : e.chain().focus().extendMarkRange("link").setLink({ href: o }).run());
|
|
3953
4013
|
};
|
|
3954
4014
|
return /* @__PURE__ */ g(
|
|
3955
|
-
|
|
4015
|
+
na,
|
|
3956
4016
|
{
|
|
3957
4017
|
editor: e,
|
|
3958
4018
|
shouldShow: ({ editor: d, state: o }) => {
|
|
@@ -3966,7 +4026,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3966
4026
|
onClick: () => e.chain().focus().toggleBold().run(),
|
|
3967
4027
|
className: i(e.isActive("bold")),
|
|
3968
4028
|
title: "Bold",
|
|
3969
|
-
children: /* @__PURE__ */ g(
|
|
4029
|
+
children: /* @__PURE__ */ g(Vt, { size: 15 })
|
|
3970
4030
|
}
|
|
3971
4031
|
),
|
|
3972
4032
|
/* @__PURE__ */ g(
|
|
@@ -3975,7 +4035,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3975
4035
|
onClick: () => e.chain().focus().toggleItalic().run(),
|
|
3976
4036
|
className: i(e.isActive("italic")),
|
|
3977
4037
|
title: "Italic",
|
|
3978
|
-
children: /* @__PURE__ */ g(
|
|
4038
|
+
children: /* @__PURE__ */ g(Kt, { size: 15 })
|
|
3979
4039
|
}
|
|
3980
4040
|
),
|
|
3981
4041
|
/* @__PURE__ */ g(
|
|
@@ -3984,7 +4044,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3984
4044
|
onClick: () => e.chain().focus().toggleUnderline().run(),
|
|
3985
4045
|
className: i(e.isActive("underline")),
|
|
3986
4046
|
title: "Underline",
|
|
3987
|
-
children: /* @__PURE__ */ g(
|
|
4047
|
+
children: /* @__PURE__ */ g(Jt, { size: 15 })
|
|
3988
4048
|
}
|
|
3989
4049
|
),
|
|
3990
4050
|
/* @__PURE__ */ g(
|
|
@@ -3993,7 +4053,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
3993
4053
|
onClick: () => e.chain().focus().toggleStrike().run(),
|
|
3994
4054
|
className: i(e.isActive("strike")),
|
|
3995
4055
|
title: "Strikethrough",
|
|
3996
|
-
children: /* @__PURE__ */ g(
|
|
4056
|
+
children: /* @__PURE__ */ g(Xt, { size: 15 })
|
|
3997
4057
|
}
|
|
3998
4058
|
),
|
|
3999
4059
|
/* @__PURE__ */ g(
|
|
@@ -4002,7 +4062,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4002
4062
|
onClick: () => e.chain().focus().toggleCode().run(),
|
|
4003
4063
|
className: i(e.isActive("code")),
|
|
4004
4064
|
title: "Code",
|
|
4005
|
-
children: /* @__PURE__ */ g(
|
|
4065
|
+
children: /* @__PURE__ */ g(Qt, { size: 15 })
|
|
4006
4066
|
}
|
|
4007
4067
|
),
|
|
4008
4068
|
/* @__PURE__ */ g(
|
|
@@ -4011,7 +4071,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4011
4071
|
onClick: () => e.chain().focus().toggleSuperscript().run(),
|
|
4012
4072
|
className: i(e.isActive("superscript")),
|
|
4013
4073
|
title: "Superscript",
|
|
4014
|
-
children: /* @__PURE__ */ g(
|
|
4074
|
+
children: /* @__PURE__ */ g(Yt, { size: 15 })
|
|
4015
4075
|
}
|
|
4016
4076
|
),
|
|
4017
4077
|
/* @__PURE__ */ g(
|
|
@@ -4020,7 +4080,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4020
4080
|
onClick: () => e.chain().focus().toggleSubscript().run(),
|
|
4021
4081
|
className: i(e.isActive("subscript")),
|
|
4022
4082
|
title: "Subscript",
|
|
4023
|
-
children: /* @__PURE__ */ g(
|
|
4083
|
+
children: /* @__PURE__ */ g(Zt, { size: 15 })
|
|
4024
4084
|
}
|
|
4025
4085
|
),
|
|
4026
4086
|
/* @__PURE__ */ g("div", { className: "bubble-menu-divider" }),
|
|
@@ -4030,38 +4090,38 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4030
4090
|
onClick: () => e.chain().focus().toggleHighlight().run(),
|
|
4031
4091
|
className: i(e.isActive("highlight")),
|
|
4032
4092
|
title: "Highlight",
|
|
4033
|
-
children: /* @__PURE__ */ g(
|
|
4093
|
+
children: /* @__PURE__ */ g(qr, { size: 15 })
|
|
4034
4094
|
}
|
|
4035
4095
|
),
|
|
4036
4096
|
/* @__PURE__ */ g(
|
|
4037
4097
|
"button",
|
|
4038
4098
|
{
|
|
4039
|
-
onClick:
|
|
4099
|
+
onClick: l,
|
|
4040
4100
|
className: i(e.isActive("link")),
|
|
4041
4101
|
title: "Link",
|
|
4042
|
-
children: /* @__PURE__ */ g(
|
|
4102
|
+
children: /* @__PURE__ */ g(pt, { size: 15 })
|
|
4043
4103
|
}
|
|
4044
4104
|
),
|
|
4045
4105
|
/* @__PURE__ */ g("div", { className: "bubble-menu-divider" }),
|
|
4046
4106
|
/* @__PURE__ */ g(
|
|
4047
4107
|
"button",
|
|
4048
4108
|
{
|
|
4049
|
-
onClick:
|
|
4109
|
+
onClick: c,
|
|
4050
4110
|
className: "p-1.5 rounded transition-colors text-purple-500 hover:bg-purple-50",
|
|
4051
4111
|
title: s ? "AI 优化" : "AI Optimize",
|
|
4052
|
-
children: /* @__PURE__ */ g(
|
|
4112
|
+
children: /* @__PURE__ */ g(Gr, { size: 15 })
|
|
4053
4113
|
}
|
|
4054
4114
|
)
|
|
4055
4115
|
] })
|
|
4056
4116
|
}
|
|
4057
4117
|
);
|
|
4058
|
-
},
|
|
4059
|
-
var
|
|
4060
|
-
const [t, n] = z(!1), [r, a] = z(!1), [s, i] = z(""), [
|
|
4118
|
+
}, ks = ({ editor: e }) => {
|
|
4119
|
+
var y;
|
|
4120
|
+
const [t, n] = z(!1), [r, a] = z(!1), [s, i] = z(""), [c, l] = z(""), [d, o] = z(!1), u = X(null), m = e.extensionStorage.searchReplace, h = ((y = m == null ? void 0 : m.results) == null ? void 0 : y.length) ?? 0, p = (m == null ? void 0 : m.currentIndex) ?? -1;
|
|
4061
4121
|
B(() => {
|
|
4062
|
-
const v = (
|
|
4122
|
+
const v = (x) => {
|
|
4063
4123
|
n(!0);
|
|
4064
|
-
const _ =
|
|
4124
|
+
const _ = x.detail;
|
|
4065
4125
|
_ != null && _.replace && a(!0), requestAnimationFrame(() => {
|
|
4066
4126
|
var L;
|
|
4067
4127
|
return (L = u.current) == null ? void 0 : L.focus();
|
|
@@ -4074,15 +4134,15 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4074
4134
|
i(v), e.commands.setSearchTerm(v);
|
|
4075
4135
|
},
|
|
4076
4136
|
[e]
|
|
4077
|
-
),
|
|
4137
|
+
), C = de(() => {
|
|
4078
4138
|
n(!1), e.commands.clearSearch(), e.commands.focus();
|
|
4079
4139
|
}, [e]);
|
|
4080
4140
|
B(() => {
|
|
4081
|
-
const v = (
|
|
4082
|
-
|
|
4141
|
+
const v = (x) => {
|
|
4142
|
+
x.key === "Escape" && t && C();
|
|
4083
4143
|
};
|
|
4084
4144
|
return window.addEventListener("keydown", v), () => window.removeEventListener("keydown", v);
|
|
4085
|
-
}, [t,
|
|
4145
|
+
}, [t, C]);
|
|
4086
4146
|
const w = () => {
|
|
4087
4147
|
const v = !d;
|
|
4088
4148
|
o(v), e.commands.setCaseSensitive(v);
|
|
@@ -4112,30 +4172,30 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4112
4172
|
onClick: w,
|
|
4113
4173
|
className: re("find-replace-btn", d && "find-replace-btn--active"),
|
|
4114
4174
|
title: "Case Sensitive",
|
|
4115
|
-
children: /* @__PURE__ */ g(
|
|
4175
|
+
children: /* @__PURE__ */ g(Vr, { size: 15 })
|
|
4116
4176
|
}
|
|
4117
4177
|
),
|
|
4118
|
-
/* @__PURE__ */ g("button", { onClick: () => e.commands.previousSearchResult(), className: "find-replace-btn", title: "Previous", children: /* @__PURE__ */ g(
|
|
4119
|
-
/* @__PURE__ */ g("button", { onClick: () => e.commands.nextSearchResult(), className: "find-replace-btn", title: "Next", children: /* @__PURE__ */ g(
|
|
4178
|
+
/* @__PURE__ */ g("button", { onClick: () => e.commands.previousSearchResult(), className: "find-replace-btn", title: "Previous", children: /* @__PURE__ */ g(Kr, { size: 15 }) }),
|
|
4179
|
+
/* @__PURE__ */ g("button", { onClick: () => e.commands.nextSearchResult(), className: "find-replace-btn", title: "Next", children: /* @__PURE__ */ g(nn, { size: 15 }) }),
|
|
4120
4180
|
/* @__PURE__ */ g(
|
|
4121
4181
|
"button",
|
|
4122
4182
|
{
|
|
4123
4183
|
onClick: () => a((v) => !v),
|
|
4124
4184
|
className: re("find-replace-btn", r && "find-replace-btn--active"),
|
|
4125
4185
|
title: "Toggle Replace",
|
|
4126
|
-
children: /* @__PURE__ */ g(
|
|
4186
|
+
children: /* @__PURE__ */ g(It, { size: 15 })
|
|
4127
4187
|
}
|
|
4128
4188
|
),
|
|
4129
|
-
/* @__PURE__ */ g("button", { onClick:
|
|
4189
|
+
/* @__PURE__ */ g("button", { onClick: C, className: "find-replace-btn", title: "Close (Esc)", children: /* @__PURE__ */ g(Jr, { size: 15 }) })
|
|
4130
4190
|
] }),
|
|
4131
4191
|
r && /* @__PURE__ */ A("div", { className: "find-replace-row", children: [
|
|
4132
4192
|
/* @__PURE__ */ g(
|
|
4133
4193
|
"input",
|
|
4134
4194
|
{
|
|
4135
4195
|
type: "text",
|
|
4136
|
-
value:
|
|
4196
|
+
value: c,
|
|
4137
4197
|
onChange: (v) => {
|
|
4138
|
-
|
|
4198
|
+
l(v.target.value), e.commands.setReplaceTerm(v.target.value);
|
|
4139
4199
|
},
|
|
4140
4200
|
onKeyDown: (v) => {
|
|
4141
4201
|
v.key === "Enter" && e.commands.replaceCurrent();
|
|
@@ -4144,15 +4204,15 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4144
4204
|
className: "find-replace-input"
|
|
4145
4205
|
}
|
|
4146
4206
|
),
|
|
4147
|
-
/* @__PURE__ */ g("button", { onClick: () => e.commands.replaceCurrent(), className: "find-replace-btn", title: "Replace", children: /* @__PURE__ */ g(
|
|
4148
|
-
/* @__PURE__ */ g("button", { onClick: () => e.commands.replaceAll(), className: "find-replace-btn", title: "Replace All", children: /* @__PURE__ */ g(
|
|
4207
|
+
/* @__PURE__ */ g("button", { onClick: () => e.commands.replaceCurrent(), className: "find-replace-btn", title: "Replace", children: /* @__PURE__ */ g(It, { size: 15 }) }),
|
|
4208
|
+
/* @__PURE__ */ g("button", { onClick: () => e.commands.replaceAll(), className: "find-replace-btn", title: "Replace All", children: /* @__PURE__ */ g(Xr, { size: 15 }) })
|
|
4149
4209
|
] })
|
|
4150
4210
|
] }) : null;
|
|
4151
|
-
},
|
|
4152
|
-
const { editorLanguage: t } =
|
|
4153
|
-
const a = e.state, i = a.doc.textBetween(0, a.doc.content.size, " ", "\0").replace(/\s/g, "").length, { from:
|
|
4211
|
+
}, _s = ({ editor: e }) => {
|
|
4212
|
+
const { editorLanguage: t } = k(), n = t === "zh", r = Te(() => {
|
|
4213
|
+
const a = e.state, i = a.doc.textBetween(0, a.doc.content.size, " ", "\0").replace(/\s/g, "").length, { from: c, to: l } = a.selection;
|
|
4154
4214
|
let d = 0;
|
|
4155
|
-
return
|
|
4215
|
+
return c !== l && (d = a.doc.textBetween(c, l, " ", "\0").replace(/\s/g, "").length), { charCount: i, selectionCount: d };
|
|
4156
4216
|
}, [e.state.doc, e.state.selection]);
|
|
4157
4217
|
return /* @__PURE__ */ A("div", { className: "word-count-bar", children: [
|
|
4158
4218
|
/* @__PURE__ */ A("span", { children: [
|
|
@@ -4166,34 +4226,34 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4166
4226
|
r.selectionCount
|
|
4167
4227
|
] })
|
|
4168
4228
|
] });
|
|
4169
|
-
},
|
|
4229
|
+
}, As = {
|
|
4170
4230
|
empty: "○",
|
|
4171
4231
|
filled: "●"
|
|
4172
|
-
},
|
|
4232
|
+
}, Ls = {
|
|
4173
4233
|
empty: "text-gray-400",
|
|
4174
4234
|
filled: "text-green-500"
|
|
4175
|
-
},
|
|
4235
|
+
}, Ps = /* @__PURE__ */ new Set([
|
|
4176
4236
|
"technical_field",
|
|
4177
4237
|
"background_art",
|
|
4178
4238
|
"summary",
|
|
4179
4239
|
"drawing_description",
|
|
4180
4240
|
"detailed_description"
|
|
4181
|
-
]),
|
|
4182
|
-
const { editorLanguage: t } =
|
|
4241
|
+
]), Rs = ({ editor: e }) => {
|
|
4242
|
+
const { editorLanguage: t } = k(), n = U(t), [r, a] = z(!1), [s, i] = z(0);
|
|
4183
4243
|
B(() => {
|
|
4184
|
-
const
|
|
4185
|
-
return e.on("update",
|
|
4186
|
-
e.off("update",
|
|
4244
|
+
const l = () => i((d) => d + 1);
|
|
4245
|
+
return e.on("update", l), () => {
|
|
4246
|
+
e.off("update", l);
|
|
4187
4247
|
};
|
|
4188
4248
|
}, [e]);
|
|
4189
|
-
const
|
|
4190
|
-
const
|
|
4249
|
+
const c = Te(() => {
|
|
4250
|
+
const l = [];
|
|
4191
4251
|
let d = !1;
|
|
4192
4252
|
return e.state.doc.descendants((o, u) => {
|
|
4193
4253
|
if (o.type.name === "patent_title") {
|
|
4194
4254
|
if (!d) {
|
|
4195
4255
|
const f = typeof n.bookTitle_description == "string" ? n.bookTitle_description : "说明书";
|
|
4196
|
-
|
|
4256
|
+
l.push({
|
|
4197
4257
|
type: "book-group",
|
|
4198
4258
|
pos: u,
|
|
4199
4259
|
title: f,
|
|
@@ -4201,7 +4261,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4201
4261
|
}), d = !0;
|
|
4202
4262
|
}
|
|
4203
4263
|
const m = o.textContent || "", h = m.trim().length > 0, p = typeof n.patentTitlePlaceholder == "string" ? n.patentTitlePlaceholder : "Patent Title";
|
|
4204
|
-
return
|
|
4264
|
+
return l.push({
|
|
4205
4265
|
type: "section",
|
|
4206
4266
|
pos: u,
|
|
4207
4267
|
title: h ? m.trim() : p,
|
|
@@ -4211,19 +4271,19 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4211
4271
|
}), !1;
|
|
4212
4272
|
}
|
|
4213
4273
|
if (o.type.name === "patent_section") {
|
|
4214
|
-
const m = o.attrs.sectionType, h =
|
|
4215
|
-
return
|
|
4274
|
+
const m = o.attrs.sectionType, h = Ps.has(m), p = `sectionTitle_${m}`, f = typeof n[p] == "string" ? n[p] : m, C = o.textContent || "", w = C.trim().length > 0;
|
|
4275
|
+
return l.push({
|
|
4216
4276
|
type: "section",
|
|
4217
4277
|
pos: u,
|
|
4218
4278
|
title: f,
|
|
4219
4279
|
state: w ? "filled" : "empty",
|
|
4220
|
-
charCount:
|
|
4280
|
+
charCount: C.replace(/\s/g, "").length,
|
|
4221
4281
|
indent: h
|
|
4222
4282
|
}), !1;
|
|
4223
4283
|
}
|
|
4224
4284
|
if (o.type.name === "heading") {
|
|
4225
4285
|
const m = o.attrs.level, h = o.textContent || "";
|
|
4226
|
-
return h.trim() &&
|
|
4286
|
+
return h.trim() && l.push({
|
|
4227
4287
|
type: "heading",
|
|
4228
4288
|
pos: u,
|
|
4229
4289
|
title: h,
|
|
@@ -4232,7 +4292,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4232
4292
|
}), !1;
|
|
4233
4293
|
}
|
|
4234
4294
|
return !0;
|
|
4235
|
-
}),
|
|
4295
|
+
}), l;
|
|
4236
4296
|
}, [e, s, n]);
|
|
4237
4297
|
return r ? /* @__PURE__ */ g("div", { className: "outline-panel outline-panel--collapsed", children: /* @__PURE__ */ g(
|
|
4238
4298
|
"button",
|
|
@@ -4240,11 +4300,11 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4240
4300
|
onClick: () => a(!1),
|
|
4241
4301
|
className: "outline-panel-toggle",
|
|
4242
4302
|
title: t === "zh" ? "展开大纲" : "Expand Outline",
|
|
4243
|
-
children: /* @__PURE__ */ g(
|
|
4303
|
+
children: /* @__PURE__ */ g(Qr, { size: 16 })
|
|
4244
4304
|
}
|
|
4245
4305
|
) }) : /* @__PURE__ */ A("div", { className: "outline-panel", children: [
|
|
4246
4306
|
/* @__PURE__ */ A("div", { className: "outline-panel-header", children: [
|
|
4247
|
-
/* @__PURE__ */ g(
|
|
4307
|
+
/* @__PURE__ */ g(tn, { size: 14 }),
|
|
4248
4308
|
/* @__PURE__ */ g("span", { children: t === "zh" ? "文档大纲" : "Outline" }),
|
|
4249
4309
|
/* @__PURE__ */ g(
|
|
4250
4310
|
"button",
|
|
@@ -4252,38 +4312,38 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4252
4312
|
onClick: () => a(!0),
|
|
4253
4313
|
className: "outline-panel-toggle ml-auto",
|
|
4254
4314
|
title: t === "zh" ? "收起大纲" : "Collapse Outline",
|
|
4255
|
-
children: /* @__PURE__ */ g(
|
|
4315
|
+
children: /* @__PURE__ */ g(Yr, { size: 14 })
|
|
4256
4316
|
}
|
|
4257
4317
|
)
|
|
4258
4318
|
] }),
|
|
4259
4319
|
/* @__PURE__ */ A("div", { className: "outline-panel-list", children: [
|
|
4260
|
-
|
|
4261
|
-
|
|
4320
|
+
c.length === 0 && /* @__PURE__ */ g("div", { className: "outline-panel-empty", children: t === "zh" ? "暂无章节" : "No sections yet" }),
|
|
4321
|
+
c.map((l, d) => /* @__PURE__ */ A(
|
|
4262
4322
|
"button",
|
|
4263
4323
|
{
|
|
4264
4324
|
className: re(
|
|
4265
4325
|
"outline-panel-item",
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4326
|
+
l.type === "heading" && `outline-panel-item--h${l.level}`,
|
|
4327
|
+
l.type === "book-group" && "outline-panel-item--book",
|
|
4328
|
+
l.indent && "outline-panel-item--indent"
|
|
4269
4329
|
),
|
|
4270
4330
|
onClick: () => {
|
|
4271
|
-
|
|
4272
|
-
const o = e.view.nodeDOM(
|
|
4331
|
+
l.type !== "book-group" && (e.chain().setTextSelection(l.pos + 1).focus().run(), requestAnimationFrame(() => {
|
|
4332
|
+
const o = e.view.nodeDOM(l.pos);
|
|
4273
4333
|
o == null || o.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
4274
4334
|
}));
|
|
4275
4335
|
},
|
|
4276
4336
|
children: [
|
|
4277
|
-
|
|
4278
|
-
/* @__PURE__ */ g("span", { className: "outline-item-title", children:
|
|
4279
|
-
|
|
4337
|
+
l.type === "section" && l.state && /* @__PURE__ */ g("span", { className: re("outline-item-state", Ls[l.state]), children: As[l.state] || "○" }),
|
|
4338
|
+
/* @__PURE__ */ g("span", { className: "outline-item-title", children: l.title }),
|
|
4339
|
+
l.type !== "book-group" && /* @__PURE__ */ g("span", { className: "outline-item-count", children: l.charCount })
|
|
4280
4340
|
]
|
|
4281
4341
|
},
|
|
4282
|
-
`${
|
|
4342
|
+
`${l.pos}-${d}`
|
|
4283
4343
|
))
|
|
4284
4344
|
] })
|
|
4285
4345
|
] });
|
|
4286
|
-
},
|
|
4346
|
+
}, Ds = ({
|
|
4287
4347
|
editor: e,
|
|
4288
4348
|
mode: t = "edit",
|
|
4289
4349
|
className: n
|
|
@@ -4297,16 +4357,16 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4297
4357
|
t === "readonly" ? "cursor-default" : "cursor-text",
|
|
4298
4358
|
n
|
|
4299
4359
|
),
|
|
4300
|
-
children: /* @__PURE__ */ g(
|
|
4360
|
+
children: /* @__PURE__ */ g(Pn, { editor: e, className: "h-full" })
|
|
4301
4361
|
}
|
|
4302
|
-
)),
|
|
4362
|
+
)), vn = "patent-editor-draft", Ms = 1500, $s = () => {
|
|
4303
4363
|
try {
|
|
4304
|
-
const e = localStorage.getItem(
|
|
4364
|
+
const e = localStorage.getItem(vn);
|
|
4305
4365
|
return e ? JSON.parse(e) : null;
|
|
4306
4366
|
} catch {
|
|
4307
4367
|
return null;
|
|
4308
4368
|
}
|
|
4309
|
-
},
|
|
4369
|
+
}, Os = ({
|
|
4310
4370
|
initialContent: e,
|
|
4311
4371
|
onChange: t,
|
|
4312
4372
|
className: n,
|
|
@@ -4314,7 +4374,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4314
4374
|
onEditorReady: a,
|
|
4315
4375
|
onSelectionOptimize: s
|
|
4316
4376
|
}) => {
|
|
4317
|
-
const { setEditor: i, setDocument:
|
|
4377
|
+
const { setEditor: i, setDocument: c, editorLanguage: l, autoSaveStatus: d } = k(), { setAutoSaveStatus: o, setLastSavedAt: u } = k(), m = X(null), h = e || (t ? null : $s()) || {
|
|
4318
4378
|
type: "doc",
|
|
4319
4379
|
content: [
|
|
4320
4380
|
{
|
|
@@ -4324,21 +4384,21 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4324
4384
|
]
|
|
4325
4385
|
}, p = de((v) => {
|
|
4326
4386
|
try {
|
|
4327
|
-
o("saving"), localStorage.setItem(
|
|
4387
|
+
o("saving"), localStorage.setItem(vn, JSON.stringify(v)), o("saved"), u(/* @__PURE__ */ new Date());
|
|
4328
4388
|
} catch {
|
|
4329
4389
|
o("error");
|
|
4330
4390
|
}
|
|
4331
|
-
}, [o, u]), f =
|
|
4332
|
-
|
|
4391
|
+
}, [o, u]), f = Rn(
|
|
4392
|
+
ss({
|
|
4333
4393
|
content: h,
|
|
4334
4394
|
onUpdate: ({ editor: v }) => {
|
|
4335
|
-
const
|
|
4336
|
-
|
|
4337
|
-
p(
|
|
4338
|
-
},
|
|
4395
|
+
const x = v.getJSON();
|
|
4396
|
+
c(x), W.notifyStateChange(v), t && t(x), t || (m.current && clearTimeout(m.current), m.current = setTimeout(() => {
|
|
4397
|
+
p(x);
|
|
4398
|
+
}, Ms));
|
|
4339
4399
|
},
|
|
4340
4400
|
onCreate: ({ editor: v }) => {
|
|
4341
|
-
i(v), a == null || a(v), W.initializePlugins(v),
|
|
4401
|
+
i(v), a == null || a(v), W.initializePlugins(v), Ae(v).execCommand("patent.normalizeClaims"), W.notifyStateChange(v);
|
|
4342
4402
|
},
|
|
4343
4403
|
onSelectionUpdate: ({ editor: v }) => {
|
|
4344
4404
|
W.notifySelectionChange(v);
|
|
@@ -4349,11 +4409,11 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4349
4409
|
}
|
|
4350
4410
|
}
|
|
4351
4411
|
})
|
|
4352
|
-
),
|
|
4412
|
+
), C = X(!1);
|
|
4353
4413
|
if (B(() => {
|
|
4354
4414
|
if (!(!f || !e)) {
|
|
4355
|
-
if (!
|
|
4356
|
-
|
|
4415
|
+
if (!C.current) {
|
|
4416
|
+
C.current = !0;
|
|
4357
4417
|
return;
|
|
4358
4418
|
}
|
|
4359
4419
|
f.commands.setContent(e);
|
|
@@ -4362,43 +4422,43 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
|
|
|
4362
4422
|
m.current && clearTimeout(m.current), f && (W.destroyPlugins(f), f.destroy());
|
|
4363
4423
|
}, [f]), B(() => {
|
|
4364
4424
|
f && W.notifyStateChange(f);
|
|
4365
|
-
}, [f,
|
|
4425
|
+
}, [f, l]), !f)
|
|
4366
4426
|
return null;
|
|
4367
|
-
const w = U(
|
|
4427
|
+
const w = U(l), y = d === "saving" ? w.autoSaveSaving : d === "saved" ? w.autoSaveSaved : d === "error" ? w.autoSaveError : "";
|
|
4368
4428
|
return /* @__PURE__ */ A("div", { className: `editor-container flex flex-col h-full ${n}`, children: [
|
|
4369
4429
|
!r && /* @__PURE__ */ A("div", { className: "flex items-center", children: [
|
|
4370
|
-
/* @__PURE__ */ g(
|
|
4371
|
-
|
|
4430
|
+
/* @__PURE__ */ g(fs, { editor: f }),
|
|
4431
|
+
y && /* @__PURE__ */ g("span", { className: `auto-save-indicator auto-save-indicator--${d} ml-2`, children: y })
|
|
4372
4432
|
] }),
|
|
4373
|
-
!r && f && /* @__PURE__ */ g(
|
|
4374
|
-
!r && f && /* @__PURE__ */ g(
|
|
4375
|
-
!r && f && /* @__PURE__ */ g(
|
|
4376
|
-
!r && f && /* @__PURE__ */ g(
|
|
4433
|
+
!r && f && /* @__PURE__ */ g(gs, { editor: f }),
|
|
4434
|
+
!r && f && /* @__PURE__ */ g(Ts, { editor: f }),
|
|
4435
|
+
!r && f && /* @__PURE__ */ g(Ns, { editor: f, onSelectionOptimize: s }),
|
|
4436
|
+
!r && f && /* @__PURE__ */ g(ks, { editor: f }),
|
|
4377
4437
|
/* @__PURE__ */ A("div", { className: "flex flex-1 overflow-hidden", children: [
|
|
4378
|
-
!r && f && /* @__PURE__ */ g(
|
|
4379
|
-
/* @__PURE__ */ g("div", { className: "flex-1 overflow-y-auto bg-white p-4 relative", children: /* @__PURE__ */ g(
|
|
4438
|
+
!r && f && /* @__PURE__ */ g(Rs, { editor: f }),
|
|
4439
|
+
/* @__PURE__ */ g("div", { className: "flex-1 overflow-y-auto bg-white p-4 relative", children: /* @__PURE__ */ g(Ds, { editor: f, mode: r ? "readonly" : "edit" }) })
|
|
4380
4440
|
] }),
|
|
4381
|
-
!r && /* @__PURE__ */ g(
|
|
4441
|
+
!r && /* @__PURE__ */ g(_s, { editor: f })
|
|
4382
4442
|
] });
|
|
4383
4443
|
};
|
|
4384
|
-
function
|
|
4444
|
+
function Cn(e) {
|
|
4385
4445
|
const t = e.getReader(), n = new TextDecoder();
|
|
4386
4446
|
let r = "";
|
|
4387
4447
|
return new ReadableStream({
|
|
4388
4448
|
async pull(a) {
|
|
4389
4449
|
var s;
|
|
4390
4450
|
for (; ; ) {
|
|
4391
|
-
const { done: i, value:
|
|
4451
|
+
const { done: i, value: c } = await t.read();
|
|
4392
4452
|
if (i) {
|
|
4393
4453
|
a.close();
|
|
4394
4454
|
return;
|
|
4395
4455
|
}
|
|
4396
|
-
r += n.decode(
|
|
4397
|
-
const
|
|
4456
|
+
r += n.decode(c, { stream: !0 });
|
|
4457
|
+
const l = r.split(`
|
|
4398
4458
|
`);
|
|
4399
|
-
r =
|
|
4459
|
+
r = l.pop() || "";
|
|
4400
4460
|
let d = "";
|
|
4401
|
-
for (const o of
|
|
4461
|
+
for (const o of l) {
|
|
4402
4462
|
if (o.startsWith("event: ")) {
|
|
4403
4463
|
d = o.slice(7).trim();
|
|
4404
4464
|
continue;
|
|
@@ -4433,7 +4493,7 @@ function vn(e) {
|
|
|
4433
4493
|
}
|
|
4434
4494
|
});
|
|
4435
4495
|
}
|
|
4436
|
-
function
|
|
4496
|
+
function Fs(e, t) {
|
|
4437
4497
|
let n = null;
|
|
4438
4498
|
return {
|
|
4439
4499
|
async request(r) {
|
|
@@ -4448,39 +4508,39 @@ function $s(e, t) {
|
|
|
4448
4508
|
throw new Error(`AI service error: ${s.status} ${s.statusText}`);
|
|
4449
4509
|
if (!s.body)
|
|
4450
4510
|
throw new Error("AI service returned no body");
|
|
4451
|
-
return
|
|
4511
|
+
return Cn(s.body);
|
|
4452
4512
|
},
|
|
4453
4513
|
abort() {
|
|
4454
4514
|
n == null || n.abort(), n = null;
|
|
4455
4515
|
}
|
|
4456
4516
|
};
|
|
4457
4517
|
}
|
|
4458
|
-
function
|
|
4518
|
+
function zs(e, t) {
|
|
4459
4519
|
let n = null;
|
|
4460
4520
|
const r = e.replace(/\/+$/, "");
|
|
4461
4521
|
async function a(s, i) {
|
|
4462
|
-
const
|
|
4522
|
+
const c = await fetch(s, {
|
|
4463
4523
|
...i,
|
|
4464
4524
|
headers: { "Content-Type": "application/json", ...t, ...i == null ? void 0 : i.headers }
|
|
4465
4525
|
});
|
|
4466
|
-
if (!
|
|
4467
|
-
const
|
|
4468
|
-
return
|
|
4526
|
+
if (!c.ok) throw new Error(`Chat API error: ${c.status} ${c.statusText}`);
|
|
4527
|
+
const l = await c.json();
|
|
4528
|
+
return l.data ?? l;
|
|
4469
4529
|
}
|
|
4470
4530
|
return {
|
|
4471
|
-
async createSession(s, i,
|
|
4531
|
+
async createSession(s, i, c) {
|
|
4472
4532
|
return a(`${r}/api/v1/chat/sessions`, {
|
|
4473
4533
|
method: "POST",
|
|
4474
|
-
body: JSON.stringify({ patentId: s, title: i, language:
|
|
4534
|
+
body: JSON.stringify({ patentId: s, title: i, language: c })
|
|
4475
4535
|
});
|
|
4476
4536
|
},
|
|
4477
|
-
async listSessions(s, i = 1,
|
|
4478
|
-
const
|
|
4479
|
-
return s &&
|
|
4537
|
+
async listSessions(s, i = 1, c = 20) {
|
|
4538
|
+
const l = new URLSearchParams({ page: String(i), pageSize: String(c) });
|
|
4539
|
+
return s && l.set("patentId", s), a(`${r}/api/v1/chat/sessions?${l}`);
|
|
4480
4540
|
},
|
|
4481
|
-
async getMessages(s, i = 1,
|
|
4482
|
-
const
|
|
4483
|
-
return a(`${r}/api/v1/chat/sessions/${s}/messages?${
|
|
4541
|
+
async getMessages(s, i = 1, c = 50) {
|
|
4542
|
+
const l = new URLSearchParams({ page: String(i), pageSize: String(c) });
|
|
4543
|
+
return a(`${r}/api/v1/chat/sessions/${s}/messages?${l}`);
|
|
4484
4544
|
},
|
|
4485
4545
|
async deleteSession(s) {
|
|
4486
4546
|
await fetch(`${r}/api/v1/chat/sessions/${s}`, {
|
|
@@ -4496,54 +4556,54 @@ function Os(e, t) {
|
|
|
4496
4556
|
},
|
|
4497
4557
|
async subscribeStream(s, i) {
|
|
4498
4558
|
n = new AbortController();
|
|
4499
|
-
const
|
|
4559
|
+
const c = `${r}/api/v1/chat/sessions/${s}/stream?messageId=${i}`, l = await fetch(c, {
|
|
4500
4560
|
headers: { Accept: "text/event-stream", ...t },
|
|
4501
4561
|
signal: n.signal
|
|
4502
4562
|
});
|
|
4503
|
-
if (!
|
|
4504
|
-
if (!
|
|
4505
|
-
return
|
|
4563
|
+
if (!l.ok) throw new Error(`Chat stream error: ${l.status} ${l.statusText}`);
|
|
4564
|
+
if (!l.body) throw new Error("Chat stream returned no body");
|
|
4565
|
+
return Cn(l.body);
|
|
4506
4566
|
},
|
|
4507
4567
|
abort() {
|
|
4508
4568
|
n == null || n.abort(), n = null;
|
|
4509
4569
|
}
|
|
4510
4570
|
};
|
|
4511
4571
|
}
|
|
4512
|
-
const
|
|
4513
|
-
({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, language: s, aiService: i, chatSessionAPI:
|
|
4514
|
-
const { setEditorLanguage: m, setAIService: h, setChatSessionAPI: p } =
|
|
4515
|
-
f.current =
|
|
4516
|
-
}, []), w =
|
|
4572
|
+
const Bs = jt(
|
|
4573
|
+
({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, language: s, aiService: i, chatSessionAPI: c, aiBaseUrl: l, aiHeaders: d, onSelectionOptimize: o }, u) => {
|
|
4574
|
+
const { setEditorLanguage: m, setAIService: h, setChatSessionAPI: p } = k(), f = X(null), C = de((y) => {
|
|
4575
|
+
f.current = y;
|
|
4576
|
+
}, []), w = De.useMemo(() => {
|
|
4517
4577
|
if (e) return e;
|
|
4518
|
-
if (t) return
|
|
4578
|
+
if (t) return mn(t);
|
|
4519
4579
|
}, [e, t]);
|
|
4520
|
-
return
|
|
4580
|
+
return De.useEffect(() => {
|
|
4521
4581
|
s && m(s);
|
|
4522
|
-
}, [s, m]),
|
|
4523
|
-
i ? h(i) :
|
|
4524
|
-
}, [i,
|
|
4525
|
-
|
|
4526
|
-
}, [
|
|
4582
|
+
}, [s, m]), De.useEffect(() => {
|
|
4583
|
+
i ? h(i) : l && h(Fs(l, d));
|
|
4584
|
+
}, [i, l, d, h]), De.useEffect(() => {
|
|
4585
|
+
c ? p(c) : l && p(zs(l, d));
|
|
4586
|
+
}, [c, l, d, p]), Wt(u, () => ({
|
|
4527
4587
|
getContent: () => {
|
|
4528
|
-
var
|
|
4529
|
-
return ((
|
|
4588
|
+
var y;
|
|
4589
|
+
return ((y = f.current) == null ? void 0 : y.getJSON()) ?? null;
|
|
4530
4590
|
},
|
|
4531
|
-
setContent: (
|
|
4591
|
+
setContent: (y) => {
|
|
4532
4592
|
var v;
|
|
4533
|
-
(v = f.current) == null || v.commands.setContent(
|
|
4593
|
+
(v = f.current) == null || v.commands.setContent(y);
|
|
4534
4594
|
},
|
|
4535
4595
|
getEditor: () => f.current,
|
|
4536
|
-
execCommand: async (
|
|
4596
|
+
execCommand: async (y, v) => f.current ? Ae(f.current).execCommand(y, v) : null,
|
|
4537
4597
|
focus: () => {
|
|
4538
|
-
var
|
|
4539
|
-
(
|
|
4598
|
+
var y;
|
|
4599
|
+
(y = f.current) == null || y.commands.focus();
|
|
4540
4600
|
}
|
|
4541
4601
|
})), /* @__PURE__ */ g(
|
|
4542
|
-
|
|
4602
|
+
Os,
|
|
4543
4603
|
{
|
|
4544
4604
|
initialContent: w,
|
|
4545
4605
|
onChange: n,
|
|
4546
|
-
onEditorReady:
|
|
4606
|
+
onEditorReady: C,
|
|
4547
4607
|
className: r,
|
|
4548
4608
|
readOnly: a,
|
|
4549
4609
|
onSelectionOptimize: o
|
|
@@ -4551,30 +4611,30 @@ const Fs = Ht(
|
|
|
4551
4611
|
);
|
|
4552
4612
|
}
|
|
4553
4613
|
);
|
|
4554
|
-
|
|
4555
|
-
async function
|
|
4556
|
-
var a, s, i,
|
|
4614
|
+
Bs.displayName = "PatentEditor";
|
|
4615
|
+
async function co(e, t, n) {
|
|
4616
|
+
var a, s, i, c;
|
|
4557
4617
|
let r = !1;
|
|
4558
|
-
(a = n.onStart) == null || a.call(n), n.mode === "section" && typeof n.targetSectionPos == "number" &&
|
|
4618
|
+
(a = n.onStart) == null || a.call(n), n.mode === "section" && typeof n.targetSectionPos == "number" && xn(e, n.targetSectionPos);
|
|
4559
4619
|
try {
|
|
4560
|
-
let
|
|
4620
|
+
let l = wn(e, n);
|
|
4561
4621
|
for (; ; ) {
|
|
4562
4622
|
const { done: d, value: o } = await t.read();
|
|
4563
4623
|
if (d) break;
|
|
4564
4624
|
if (!o) continue;
|
|
4565
4625
|
(s = n.onChunk) == null || s.call(n, o);
|
|
4566
|
-
const u = e.state.tr.insertText(o,
|
|
4567
|
-
e.view.dispatch(u),
|
|
4626
|
+
const u = e.state.tr.insertText(o, l);
|
|
4627
|
+
e.view.dispatch(u), l = u.mapping.map(l, 1);
|
|
4568
4628
|
}
|
|
4569
4629
|
(i = n.onComplete) == null || i.call(n);
|
|
4570
|
-
} catch (
|
|
4571
|
-
(
|
|
4630
|
+
} catch (l) {
|
|
4631
|
+
(c = n.onError) == null || c.call(n, l instanceof Error ? l : new Error(String(l)));
|
|
4572
4632
|
}
|
|
4573
4633
|
}
|
|
4574
|
-
async function
|
|
4575
|
-
var s, i,
|
|
4634
|
+
async function lo(e, t, n, r) {
|
|
4635
|
+
var s, i, c, l, d, o, u, m;
|
|
4576
4636
|
const a = new AbortController();
|
|
4577
|
-
(s = r.onStart) == null || s.call(r), r.mode === "section" && typeof r.targetSectionPos == "number" &&
|
|
4637
|
+
(s = r.onStart) == null || s.call(r), r.mode === "section" && typeof r.targetSectionPos == "number" && xn(e, r.targetSectionPos);
|
|
4578
4638
|
try {
|
|
4579
4639
|
const h = await fetch(t, {
|
|
4580
4640
|
method: "POST",
|
|
@@ -4587,25 +4647,25 @@ async function oo(e, t, n, r) {
|
|
|
4587
4647
|
const p = (i = h.body) == null ? void 0 : i.getReader();
|
|
4588
4648
|
if (!p) throw new Error("No response body");
|
|
4589
4649
|
const f = new TextDecoder();
|
|
4590
|
-
let
|
|
4650
|
+
let C = wn(e, r), w = "";
|
|
4591
4651
|
for (; ; ) {
|
|
4592
|
-
const { done:
|
|
4593
|
-
if (
|
|
4652
|
+
const { done: y, value: v } = await p.read();
|
|
4653
|
+
if (y) break;
|
|
4594
4654
|
w += f.decode(v, { stream: !0 });
|
|
4595
|
-
const
|
|
4655
|
+
const x = w.split(`
|
|
4596
4656
|
`);
|
|
4597
|
-
w =
|
|
4598
|
-
for (const _ of
|
|
4657
|
+
w = x.pop() || "";
|
|
4658
|
+
for (const _ of x) {
|
|
4599
4659
|
if (!_.startsWith("data: ")) continue;
|
|
4600
4660
|
const L = _.slice(6).trim();
|
|
4601
4661
|
if (L === "[DONE]")
|
|
4602
|
-
return (
|
|
4662
|
+
return (c = r.onComplete) == null || c.call(r), { abort: () => a.abort() };
|
|
4603
4663
|
try {
|
|
4604
|
-
const P = JSON.parse(L), b = P.content || P.text || ((
|
|
4664
|
+
const P = JSON.parse(L), b = P.content || P.text || ((l = P.delta) == null ? void 0 : l.content) || "";
|
|
4605
4665
|
if (!b) continue;
|
|
4606
4666
|
(d = r.onChunk) == null || d.call(r, b);
|
|
4607
|
-
const T = e.state.tr.insertText(b,
|
|
4608
|
-
e.view.dispatch(T),
|
|
4667
|
+
const T = e.state.tr.insertText(b, C);
|
|
4668
|
+
e.view.dispatch(T), C = T.mapping.map(C, 1);
|
|
4609
4669
|
} catch {
|
|
4610
4670
|
}
|
|
4611
4671
|
}
|
|
@@ -4616,7 +4676,7 @@ async function oo(e, t, n, r) {
|
|
|
4616
4676
|
}
|
|
4617
4677
|
return { abort: () => a.abort() };
|
|
4618
4678
|
}
|
|
4619
|
-
function
|
|
4679
|
+
function wn(e, t) {
|
|
4620
4680
|
if (t.mode === "section" && typeof t.targetSectionPos == "number") {
|
|
4621
4681
|
const n = e.state.doc.nodeAt(t.targetSectionPos);
|
|
4622
4682
|
if (n && n.type.name === "patent_section")
|
|
@@ -4624,7 +4684,7 @@ function Cn(e, t) {
|
|
|
4624
4684
|
}
|
|
4625
4685
|
return e.state.selection.from;
|
|
4626
4686
|
}
|
|
4627
|
-
function
|
|
4687
|
+
function xn(e, t) {
|
|
4628
4688
|
const n = e.state.doc.nodeAt(t);
|
|
4629
4689
|
if (!n || n.type.name !== "patent_section") return;
|
|
4630
4690
|
const r = t + 1, a = t + n.nodeSize - 1;
|
|
@@ -4633,7 +4693,7 @@ function wn(e, t) {
|
|
|
4633
4693
|
s.replaceWith(r, a, i), s.setMeta("addToHistory", !1), e.view.dispatch(s);
|
|
4634
4694
|
}
|
|
4635
4695
|
}
|
|
4636
|
-
const
|
|
4696
|
+
const Ut = {
|
|
4637
4697
|
technical_field: {
|
|
4638
4698
|
zh: "本发明涉及航天器自主导航与控制技术领域,具体涉及一种基于多传感器融合的航天器自主避障控制方法、系统、电子设备及计算机可读存储介质。该方法综合利用激光雷达、红外传感器和星敏感器的探测数据,通过实时环境感知与路径规划算法,实现航天器在复杂空间环境中的自主安全避障机动。",
|
|
4639
4699
|
en: "The present invention relates to the field of autonomous navigation and control technology for spacecraft, and specifically to a method, system, electronic device, and computer-readable storage medium for autonomous obstacle avoidance control of spacecraft based on multi-sensor fusion."
|
|
@@ -4703,7 +4763,7 @@ S103:局部实时避障控制。采用模型预测控制(MPC)策略,以
|
|
|
4703
4763
|
S104:安全验证。对计算得到的控制指令进行轨迹传播仿真,验证机动后轨迹在未来72小时内不会与TLE目录中的已知空间目标产生碰撞风险(miss distance > 1km)。`,
|
|
4704
4764
|
en: "The technical solution of the embodiments of the present invention will be described clearly and completely below with reference to the drawings."
|
|
4705
4765
|
}
|
|
4706
|
-
},
|
|
4766
|
+
}, He = {
|
|
4707
4767
|
"help-draft": {
|
|
4708
4768
|
zh: `当然可以帮你撰写技术方案!请先描述以下信息:
|
|
4709
4769
|
|
|
@@ -4763,7 +4823,7 @@ S104:安全验证。对计算得到的控制指令进行轨迹传播仿真,
|
|
|
4763
4823
|
en: "That is a great question. As an AI patent writing assistant, I can help you with..."
|
|
4764
4824
|
}
|
|
4765
4825
|
}, oe = (e) => new Promise((t) => setTimeout(t, e));
|
|
4766
|
-
function
|
|
4826
|
+
function gt(e, t = 30) {
|
|
4767
4827
|
let n = !1;
|
|
4768
4828
|
return new ReadableStream({
|
|
4769
4829
|
async pull(r) {
|
|
@@ -4781,47 +4841,47 @@ function ft(e, t = 30) {
|
|
|
4781
4841
|
}
|
|
4782
4842
|
});
|
|
4783
4843
|
}
|
|
4784
|
-
function
|
|
4785
|
-
const t = [], n =
|
|
4844
|
+
function Hs(e) {
|
|
4845
|
+
const t = [], n = Ge(e, 3);
|
|
4786
4846
|
for (const r of n)
|
|
4787
4847
|
t.push({ type: "delta", content: r });
|
|
4788
4848
|
return t.push({ type: "done", usage: { tokens: e.length * 2 } }), t;
|
|
4789
4849
|
}
|
|
4790
|
-
function
|
|
4850
|
+
function Ge(e, t) {
|
|
4791
4851
|
const n = [];
|
|
4792
4852
|
for (let r = 0; r < e.length; r += t)
|
|
4793
4853
|
n.push(e.slice(r, r + t));
|
|
4794
4854
|
return n;
|
|
4795
4855
|
}
|
|
4796
|
-
function
|
|
4856
|
+
function Us(e, t, n) {
|
|
4797
4857
|
const r = n === "zh", a = [];
|
|
4798
4858
|
let s;
|
|
4799
|
-
if (e.includes("技术方案") || e.includes("draft") ? s =
|
|
4859
|
+
if (e.includes("技术方案") || e.includes("draft") ? s = He["help-draft"][r ? "zh" : "en"] : e.includes("审查") || e.includes("review") || e.includes("Review") ? s = He.review[r ? "zh" : "en"] : e.includes("权利要求") || e.includes("claims") || e.includes("Optimize") ? s = He.claims[r ? "zh" : "en"] : s = He.default[r ? "zh" : "en"], t.length > 0) {
|
|
4800
4860
|
const i = r ? `正在分析引用的 ${t.length} 段文本并生成优化建议...
|
|
4801
4861
|
|
|
4802
4862
|
` : `Analyzing ${t.length} referenced text(s) and generating suggestions...
|
|
4803
4863
|
|
|
4804
4864
|
`;
|
|
4805
|
-
for (const
|
|
4806
|
-
a.push({ type: "delta", content:
|
|
4807
|
-
for (const
|
|
4808
|
-
a.push({ type: "delta", content:
|
|
4809
|
-
for (let
|
|
4810
|
-
const
|
|
4865
|
+
for (const c of Ge(i, 4))
|
|
4866
|
+
a.push({ type: "delta", content: c });
|
|
4867
|
+
for (const c of Ge(s, 4))
|
|
4868
|
+
a.push({ type: "delta", content: c });
|
|
4869
|
+
for (let c = 0; c < t.length; c++) {
|
|
4870
|
+
const l = t[c], d = l.text;
|
|
4811
4871
|
let o;
|
|
4812
|
-
r ? (o = d.replace(/一种/g, "一种基于本发明的").replace(/方法/g, "技术方案").replace(/包括/g, "具体包括"), o === d && (o = `根据本发明优选实施例,${d}`)) : o = `According to a preferred embodiment, ${d.charAt(0).toLowerCase()}${d.slice(1)}`,
|
|
4872
|
+
r ? (o = d.replace(/一种/g, "一种基于本发明的").replace(/方法/g, "技术方案").replace(/包括/g, "具体包括"), o === d && (o = `根据本发明优选实施例,${d}`)) : o = `According to a preferred embodiment, ${d.charAt(0).toLowerCase()}${d.slice(1)}`, l.from != null && l.to != null ? a.push({
|
|
4813
4873
|
type: "patch",
|
|
4814
4874
|
patch: {
|
|
4815
4875
|
op: "replace",
|
|
4816
|
-
target: { type: "ref", refIndex:
|
|
4876
|
+
target: { type: "ref", refIndex: c },
|
|
4817
4877
|
content: o,
|
|
4818
4878
|
reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
|
|
4819
4879
|
}
|
|
4820
|
-
}) :
|
|
4880
|
+
}) : l.source ? a.push({
|
|
4821
4881
|
type: "patch",
|
|
4822
4882
|
patch: {
|
|
4823
4883
|
op: "replace",
|
|
4824
|
-
target: { type: "section", sectionType:
|
|
4884
|
+
target: { type: "section", sectionType: l.source },
|
|
4825
4885
|
search: d,
|
|
4826
4886
|
content: o,
|
|
4827
4887
|
reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
|
|
@@ -4837,39 +4897,39 @@ function Bs(e, t, n) {
|
|
|
4837
4897
|
});
|
|
4838
4898
|
}
|
|
4839
4899
|
} else
|
|
4840
|
-
for (const i of
|
|
4900
|
+
for (const i of Ge(s, 4))
|
|
4841
4901
|
a.push({ type: "delta", content: i });
|
|
4842
4902
|
return a.push({ type: "done", usage: { tokens: s.length * 2 } }), a;
|
|
4843
4903
|
}
|
|
4844
|
-
function
|
|
4904
|
+
function uo() {
|
|
4845
4905
|
let e = null;
|
|
4846
4906
|
return {
|
|
4847
4907
|
async request(t) {
|
|
4848
|
-
var
|
|
4908
|
+
var c;
|
|
4849
4909
|
if (e = new AbortController(), await oe(300), e.signal.aborted)
|
|
4850
4910
|
throw new DOMException("Aborted", "AbortError");
|
|
4851
|
-
const n = t.language === "zh" ? "zh" : "en", r = t.sectionType || "technical_field", a = ((
|
|
4911
|
+
const n = t.language === "zh" ? "zh" : "en", r = t.sectionType || "technical_field", a = ((c = Ut[r]) == null ? void 0 : c[n]) || Ut.technical_field[n];
|
|
4852
4912
|
let s = a;
|
|
4853
4913
|
t.instruction && (s = (n === "zh" ? `[基于指令"${t.instruction}"生成]
|
|
4854
4914
|
|
|
4855
4915
|
` : `[Generated based on instruction "${t.instruction}"]
|
|
4856
4916
|
|
|
4857
4917
|
`) + a);
|
|
4858
|
-
const i =
|
|
4859
|
-
return
|
|
4918
|
+
const i = Hs(s);
|
|
4919
|
+
return gt(i, 25);
|
|
4860
4920
|
},
|
|
4861
4921
|
abort() {
|
|
4862
4922
|
e == null || e.abort(), e = null;
|
|
4863
4923
|
}
|
|
4864
4924
|
};
|
|
4865
4925
|
}
|
|
4866
|
-
function
|
|
4926
|
+
function mo() {
|
|
4867
4927
|
const e = /* @__PURE__ */ new Map();
|
|
4868
4928
|
let t = null, n = null;
|
|
4869
4929
|
return {
|
|
4870
4930
|
async createSession(r, a, s) {
|
|
4871
4931
|
await oe(100);
|
|
4872
|
-
const i = `sess_${Date.now()}`,
|
|
4932
|
+
const i = `sess_${Date.now()}`, c = {
|
|
4873
4933
|
sessionId: i,
|
|
4874
4934
|
patentId: r || void 0,
|
|
4875
4935
|
title: a || (s === "zh" ? "新对话" : "New Chat"),
|
|
@@ -4877,7 +4937,7 @@ function lo() {
|
|
|
4877
4937
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4878
4938
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4879
4939
|
};
|
|
4880
|
-
return e.set(i, { session:
|
|
4940
|
+
return e.set(i, { session: c, messages: [] }), c;
|
|
4881
4941
|
},
|
|
4882
4942
|
async listSessions() {
|
|
4883
4943
|
await oe(50);
|
|
@@ -4906,39 +4966,39 @@ function lo() {
|
|
|
4906
4966
|
status: "done",
|
|
4907
4967
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4908
4968
|
}), s.session.messageCount = s.messages.length, s.session.lastMessage = a.content, s.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
4909
|
-
const
|
|
4969
|
+
const c = Us(
|
|
4910
4970
|
a.content,
|
|
4911
4971
|
a.references || [],
|
|
4912
4972
|
a.language
|
|
4913
4973
|
);
|
|
4914
|
-
return n = { messageId: i, events:
|
|
4974
|
+
return n = { messageId: i, events: c }, { messageId: i, sessionId: r, status: "processing" };
|
|
4915
4975
|
},
|
|
4916
4976
|
async subscribeStream(r, a) {
|
|
4917
4977
|
t = new AbortController(), await oe(100);
|
|
4918
4978
|
const s = e.get(r);
|
|
4919
4979
|
if (!s) throw new Error("Session not found");
|
|
4920
4980
|
if (!n || n.messageId !== a)
|
|
4921
|
-
return
|
|
4981
|
+
return gt([{ type: "done" }]);
|
|
4922
4982
|
const i = n.events;
|
|
4923
4983
|
n = null;
|
|
4924
|
-
const
|
|
4984
|
+
const c = gt(i, 18), l = `${a}_a`;
|
|
4925
4985
|
let d = "";
|
|
4926
4986
|
for (const o of i)
|
|
4927
4987
|
o.type === "delta" && (d += o.content);
|
|
4928
4988
|
return s.messages.push({
|
|
4929
|
-
messageId:
|
|
4989
|
+
messageId: l,
|
|
4930
4990
|
role: "assistant",
|
|
4931
4991
|
content: d,
|
|
4932
4992
|
status: "done",
|
|
4933
4993
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4934
|
-
}), s.session.messageCount = s.messages.length, s.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString(),
|
|
4994
|
+
}), s.session.messageCount = s.messages.length, s.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), c;
|
|
4935
4995
|
},
|
|
4936
4996
|
abort() {
|
|
4937
4997
|
t == null || t.abort(), t = null;
|
|
4938
4998
|
}
|
|
4939
4999
|
};
|
|
4940
5000
|
}
|
|
4941
|
-
function
|
|
5001
|
+
function js(e) {
|
|
4942
5002
|
const t = [], n = e.replace(/\r\n/g, `
|
|
4943
5003
|
`).trim();
|
|
4944
5004
|
if (!n) return t;
|
|
@@ -4953,98 +5013,98 @@ function Hs(e) {
|
|
|
4953
5013
|
if (a.length === 0)
|
|
4954
5014
|
return t.push({ number: 1, text: n, dependsOn: [] }), t;
|
|
4955
5015
|
for (let i = 0; i < a.length; i++) {
|
|
4956
|
-
const
|
|
5016
|
+
const c = a[i].index + a[i].matchLength, l = i + 1 < a.length ? a[i + 1].index : n.length, d = n.slice(c, l).trim(), o = a[i].number, u = Ws(d, o);
|
|
4957
5017
|
t.push({ number: o, text: d, dependsOn: u });
|
|
4958
5018
|
}
|
|
4959
5019
|
return t;
|
|
4960
5020
|
}
|
|
4961
|
-
function
|
|
5021
|
+
function Ws(e, t) {
|
|
4962
5022
|
const n = [], r = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g;
|
|
4963
5023
|
let a;
|
|
4964
5024
|
for (; (a = r.exec(e)) !== null; ) {
|
|
4965
|
-
const i = parseInt(a[1], 10),
|
|
4966
|
-
for (let
|
|
4967
|
-
|
|
5025
|
+
const i = parseInt(a[1], 10), c = a[2] ? parseInt(a[2], 10) : i;
|
|
5026
|
+
for (let l = i; l <= c; l++)
|
|
5027
|
+
l !== t && l > 0 && n.push(l);
|
|
4968
5028
|
}
|
|
4969
5029
|
const s = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
|
|
4970
5030
|
for (; (a = s.exec(e)) !== null; ) {
|
|
4971
|
-
const i = parseInt(a[1], 10),
|
|
4972
|
-
for (let
|
|
4973
|
-
|
|
5031
|
+
const i = parseInt(a[1], 10), c = a[2] ? parseInt(a[2], 10) : i;
|
|
5032
|
+
for (let l = i; l <= c; l++)
|
|
5033
|
+
l !== t && l > 0 && n.push(l);
|
|
4974
5034
|
}
|
|
4975
|
-
return [...new Set(n)].sort((i,
|
|
5035
|
+
return [...new Set(n)].sort((i, c) => i - c);
|
|
4976
5036
|
}
|
|
4977
|
-
function
|
|
5037
|
+
function qs() {
|
|
4978
5038
|
return `claim_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
4979
5039
|
}
|
|
4980
|
-
function
|
|
4981
|
-
return
|
|
5040
|
+
function fo(e) {
|
|
5041
|
+
return js(e).map((n) => ({
|
|
4982
5042
|
type: "claim",
|
|
4983
5043
|
attrs: {
|
|
4984
5044
|
number: n.number,
|
|
4985
|
-
claimId:
|
|
5045
|
+
claimId: qs(),
|
|
4986
5046
|
dependsOn: n.dependsOn,
|
|
4987
5047
|
dependsOnClaimIds: []
|
|
4988
5048
|
},
|
|
4989
5049
|
content: n.text ? [{ type: "text", text: n.text }] : void 0
|
|
4990
5050
|
}));
|
|
4991
5051
|
}
|
|
4992
|
-
const
|
|
4993
|
-
let
|
|
4994
|
-
function
|
|
4995
|
-
return
|
|
5052
|
+
const Gs = -1, Vs = 1, Ks = 0, Sn = new _e("docDiff");
|
|
5053
|
+
let lt = null;
|
|
5054
|
+
function Js() {
|
|
5055
|
+
return lt || (lt = new Gt()), lt;
|
|
4996
5056
|
}
|
|
4997
|
-
function
|
|
5057
|
+
function Xs(e, t, n) {
|
|
4998
5058
|
const r = [];
|
|
4999
5059
|
return e.nodesBetween(t, n, (a, s) => {
|
|
5000
5060
|
if (a.isTextblock) {
|
|
5001
|
-
const i = s + 1,
|
|
5002
|
-
return d >
|
|
5061
|
+
const i = s + 1, c = s + a.nodeSize - 1, l = Math.max(i, t), d = Math.min(c, n);
|
|
5062
|
+
return d > l && r.push({ from: l, to: d }), !1;
|
|
5003
5063
|
}
|
|
5004
5064
|
return !0;
|
|
5005
5065
|
}), r;
|
|
5006
5066
|
}
|
|
5007
|
-
function
|
|
5008
|
-
const n = e.state.doc, r = n.content.size, { text: a, segments: s } =
|
|
5009
|
-
i.diff_cleanupSemantic(
|
|
5010
|
-
const
|
|
5067
|
+
function go(e, t) {
|
|
5068
|
+
const n = e.state.doc, r = n.content.size, { text: a, segments: s } = sn(e, 0, r), i = Js(), c = i.diff_main(t, a);
|
|
5069
|
+
i.diff_cleanupSemantic(c);
|
|
5070
|
+
const l = [];
|
|
5011
5071
|
let d = 0;
|
|
5012
|
-
for (const [m, h] of
|
|
5013
|
-
if (m ===
|
|
5072
|
+
for (const [m, h] of c)
|
|
5073
|
+
if (m === Ks)
|
|
5014
5074
|
d += h.length;
|
|
5015
|
-
else if (m ===
|
|
5075
|
+
else if (m === Vs) {
|
|
5016
5076
|
let p = 0;
|
|
5017
5077
|
for (; p < h.length; ) {
|
|
5018
5078
|
for (; p < h.length && h[p] === "\0"; ) p++;
|
|
5019
5079
|
if (p >= h.length) break;
|
|
5020
5080
|
const f = p;
|
|
5021
5081
|
for (; p < h.length && h[p] !== "\0"; ) p++;
|
|
5022
|
-
const
|
|
5023
|
-
if (
|
|
5024
|
-
for (const
|
|
5025
|
-
|
|
5026
|
-
le.inline(
|
|
5082
|
+
const C = Ee(s, d + f), w = Ee(s, d + p);
|
|
5083
|
+
if (C >= 0 && w >= 0 && w > C)
|
|
5084
|
+
for (const y of Xs(n, C, w))
|
|
5085
|
+
l.push(
|
|
5086
|
+
le.inline(y.from, y.to, { class: "patch-diff-insert-inline" })
|
|
5027
5087
|
);
|
|
5028
5088
|
}
|
|
5029
5089
|
d += h.length;
|
|
5030
|
-
} else if (m ===
|
|
5031
|
-
const p =
|
|
5090
|
+
} else if (m === Gs) {
|
|
5091
|
+
const p = Ee(s, d);
|
|
5032
5092
|
if (p >= 0) {
|
|
5033
5093
|
const f = h.replace(/\0/g, " ");
|
|
5034
|
-
|
|
5094
|
+
l.push(
|
|
5035
5095
|
le.widget(
|
|
5036
5096
|
p,
|
|
5037
5097
|
() => {
|
|
5038
|
-
const
|
|
5039
|
-
return
|
|
5098
|
+
const C = document.createElement("span");
|
|
5099
|
+
return C.className = "patch-diff-delete", C.textContent = f, C;
|
|
5040
5100
|
},
|
|
5041
5101
|
{ side: -1 }
|
|
5042
5102
|
)
|
|
5043
5103
|
);
|
|
5044
5104
|
}
|
|
5045
5105
|
}
|
|
5046
|
-
const o =
|
|
5047
|
-
key:
|
|
5106
|
+
const o = Ne.create(n, l), u = new Xe({
|
|
5107
|
+
key: Sn,
|
|
5048
5108
|
props: {
|
|
5049
5109
|
decorations() {
|
|
5050
5110
|
return o;
|
|
@@ -5053,109 +5113,109 @@ function mo(e, t) {
|
|
|
5053
5113
|
});
|
|
5054
5114
|
e.registerPlugin(u);
|
|
5055
5115
|
}
|
|
5056
|
-
function
|
|
5057
|
-
e.unregisterPlugin(
|
|
5116
|
+
function po(e) {
|
|
5117
|
+
e.unregisterPlugin(Sn);
|
|
5058
5118
|
}
|
|
5059
|
-
function
|
|
5119
|
+
function ho(e, t) {
|
|
5060
5120
|
const n = [], r = t === "zh";
|
|
5061
5121
|
let a = 0;
|
|
5062
5122
|
const s = () => `v_${++a}`;
|
|
5063
|
-
return e.state.doc.descendants((i,
|
|
5123
|
+
return e.state.doc.descendants((i, c) => {
|
|
5064
5124
|
if (i.type.name === "patent_title") {
|
|
5065
|
-
const
|
|
5066
|
-
if (
|
|
5125
|
+
const l = i.textContent.trim();
|
|
5126
|
+
if (l.length === 0)
|
|
5067
5127
|
n.push({
|
|
5068
5128
|
id: s(),
|
|
5069
5129
|
severity: "warning",
|
|
5070
5130
|
message: r ? "专利名称为空" : "Patent title is empty",
|
|
5071
5131
|
sectionType: "patent_title",
|
|
5072
|
-
pos:
|
|
5132
|
+
pos: c
|
|
5073
5133
|
});
|
|
5074
5134
|
else {
|
|
5075
|
-
const d =
|
|
5135
|
+
const d = l.replace(/\s/g, "").length;
|
|
5076
5136
|
d > 25 && r && n.push({
|
|
5077
5137
|
id: s(),
|
|
5078
5138
|
severity: "error",
|
|
5079
5139
|
message: `专利名称超过25个汉字(当前${d}字)`,
|
|
5080
5140
|
sectionType: "patent_title",
|
|
5081
|
-
pos:
|
|
5141
|
+
pos: c
|
|
5082
5142
|
});
|
|
5083
5143
|
}
|
|
5084
5144
|
return !1;
|
|
5085
5145
|
}
|
|
5086
5146
|
if (i.type.name === "patent_section") {
|
|
5087
|
-
const
|
|
5147
|
+
const l = i.attrs.sectionType, d = i.textContent.trim();
|
|
5088
5148
|
if (d.length === 0 && n.push({
|
|
5089
5149
|
id: s(),
|
|
5090
5150
|
severity: "warning",
|
|
5091
|
-
message: r ? `章节"${
|
|
5092
|
-
sectionType:
|
|
5093
|
-
pos:
|
|
5094
|
-
}),
|
|
5151
|
+
message: r ? `章节"${l}"内容为空` : `Section "${l}" is empty`,
|
|
5152
|
+
sectionType: l,
|
|
5153
|
+
pos: c
|
|
5154
|
+
}), l === "abstract") {
|
|
5095
5155
|
const o = d.replace(/\s/g, "").length;
|
|
5096
5156
|
o > 0 && o < 50 && n.push({
|
|
5097
5157
|
id: s(),
|
|
5098
5158
|
severity: "warning",
|
|
5099
5159
|
message: r ? `摘要字数过少(${o}字),建议50~300字` : `Abstract too short (${o} chars), recommend 50-300`,
|
|
5100
|
-
sectionType:
|
|
5101
|
-
pos:
|
|
5160
|
+
sectionType: l,
|
|
5161
|
+
pos: c
|
|
5102
5162
|
}), o > 300 && n.push({
|
|
5103
5163
|
id: s(),
|
|
5104
5164
|
severity: "warning",
|
|
5105
5165
|
message: r ? `摘要字数过多(${o}字),建议不超过300字` : `Abstract too long (${o} chars), recommend ≤300`,
|
|
5106
|
-
sectionType:
|
|
5107
|
-
pos:
|
|
5166
|
+
sectionType: l,
|
|
5167
|
+
pos: c
|
|
5108
5168
|
});
|
|
5109
5169
|
}
|
|
5110
5170
|
return !1;
|
|
5111
5171
|
}
|
|
5112
5172
|
if (i.type.name === "claim") {
|
|
5113
|
-
const
|
|
5114
|
-
|
|
5173
|
+
const l = i.textContent.trim();
|
|
5174
|
+
l.length > 0 && !l.endsWith("。") && !l.endsWith(".") && n.push({
|
|
5115
5175
|
id: s(),
|
|
5116
5176
|
severity: "warning",
|
|
5117
5177
|
message: r ? `权利要求${i.attrs.number}末尾应以句号结束` : `Claim ${i.attrs.number} should end with a period`,
|
|
5118
|
-
pos:
|
|
5178
|
+
pos: c
|
|
5119
5179
|
});
|
|
5120
5180
|
}
|
|
5121
5181
|
return !0;
|
|
5122
5182
|
}), n;
|
|
5123
5183
|
}
|
|
5124
5184
|
export {
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5185
|
+
Os as EditorView,
|
|
5186
|
+
an as PatchDiffPluginKey,
|
|
5187
|
+
Bs as PatentEditor,
|
|
5188
|
+
ao as acceptAllPatches,
|
|
5189
|
+
no as acceptPatch,
|
|
5190
|
+
go as applyDocDiffDecorations,
|
|
5191
|
+
oo as buildAIContext,
|
|
5192
|
+
fo as buildClaimsJSONContent,
|
|
5193
|
+
mn as buildPatentDocument,
|
|
5194
|
+
to as clearPatches,
|
|
5195
|
+
zs as createChatSessionAPI,
|
|
5196
|
+
Ae as createCommandExecutor,
|
|
5197
|
+
ss as createEditorConfig,
|
|
5198
|
+
uo as createMockAIService,
|
|
5199
|
+
mo as createMockChatSessionAPI,
|
|
5200
|
+
Fs as createSSEAdapter,
|
|
5201
|
+
us as exportToPdf,
|
|
5202
|
+
Bt as exportToWord,
|
|
5203
|
+
ys as extractClaimsFromEditor,
|
|
5204
|
+
yn as findSectionAtCursor,
|
|
5205
|
+
Is as getAllSections,
|
|
5206
|
+
io as getMissingSectionDeps,
|
|
5207
|
+
Zi as getPatches,
|
|
5208
|
+
Yi as onPatchChange,
|
|
5149
5209
|
W as pluginManager,
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5210
|
+
so as rejectAllPatches,
|
|
5211
|
+
ro as rejectPatch,
|
|
5212
|
+
po as removeDocDiffDecorations,
|
|
5213
|
+
Qi as resolvePatchTarget,
|
|
5214
|
+
bn as sectionContextDeps,
|
|
5215
|
+
eo as setPatches,
|
|
5216
|
+
k as useEditorStore,
|
|
5217
|
+
ho as validatePatentDocument,
|
|
5218
|
+
co as writeStream,
|
|
5219
|
+
lo as writeStreamFromSSE
|
|
5160
5220
|
};
|
|
5161
5221
|
//# sourceMappingURL=lib.js.map
|