@fgbg/mdocs 1.2.1 → 1.2.2
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/agent-skills/changelog/SKILL.md +14 -2
- package/agent-skills/index/SKILL.md +1 -0
- package/agent-skills/index.json +8 -1
- package/agent-skills/usage-html-documents/SKILL.md +40 -0
- package/dist/server/documents/document.service.js +45 -48
- package/dist/server/documents/document.service.js.map +1 -1
- package/dist/server/documents/graph.service.js +11 -4
- package/dist/server/documents/graph.service.js.map +1 -1
- package/dist/server/documents/tree-and-folders.test.js +16 -0
- package/dist/server/documents/tree-and-folders.test.js.map +1 -1
- package/dist/server/documents/tree.service.js +12 -7
- package/dist/server/documents/tree.service.js.map +1 -1
- package/dist/shared/file-type-policy.js +12 -14
- package/dist/shared/file-type-policy.js.map +1 -1
- package/dist/shared/file-type-policy.test.js +37 -0
- package/dist/shared/file-type-policy.test.js.map +1 -0
- package/dist/shared/file-types.js +3 -4
- package/dist/shared/file-types.js.map +1 -1
- package/dist/web/assets/{AgentChatPanel-B7IcnUpo.js → AgentChatPanel-dADh_kOG.js} +1 -1
- package/dist/web/assets/{AgentSkillFormCard-BvGtfSYA.js → AgentSkillFormCard-DEKBKWH-.js} +1 -1
- package/dist/web/assets/{AiWriteWorkbench-CiCbou2k.js → AiWriteWorkbench-DezZBKI2.js} +1 -1
- package/dist/web/assets/{DiagramEditor-NtNY3sZL-D8pO8wBI.js → DiagramEditor-NtNY3sZL-5TyWJGgH.js} +1 -1
- package/dist/web/assets/{DocumentEditor-DO_AX4v-.js → DocumentEditor-D39RTLYE.js} +1 -1
- package/dist/web/assets/HtmlEditor-Bmpi_p2t.js +1 -0
- package/dist/web/assets/MergeView-WUR136do.js +10 -0
- package/dist/web/assets/{PlaygroundPage-C7glsS72.js → PlaygroundPage-CPzJG_Wk.js} +1 -1
- package/dist/web/assets/{SettingsPage-CMbhjz76.js → SettingsPage-CuwYAiJh.js} +1 -1
- package/dist/web/assets/{Toolbar-CsA1tpSD.js → Toolbar-JoV5KtuT.js} +1 -1
- package/dist/web/assets/{VisitorPickerModal-D53YaNbf.js → VisitorPickerModal-ImaQvyyf.js} +1 -1
- package/dist/web/assets/{code-xml-6zfU0nfd.js → code-xml-DX89c1sd.js} +1 -1
- package/dist/web/assets/{copy-CkzT-0Cs.js → copy-yWKSE1g1.js} +1 -1
- package/dist/web/assets/{index-DGnp1IRN.js → index-CwzlBu2W.js} +30 -30
- package/dist/web/assets/index-uw_8eaPv.css +1 -0
- package/dist/web/assets/{meta2dEngine-BD2XbzaV-BMzVEEHU.js → meta2dEngine-BD2XbzaV-DUaWTg_P.js} +1 -1
- package/dist/web/assets/{plus-CmYtaPfl.js → plus-B0mmDuSt.js} +1 -1
- package/dist/web/assets/{react-Dy2okueo.js → react-BJcufYxR.js} +3 -3
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/HtmlEditor-CneI2y4w.js +0 -1
- package/dist/web/assets/MergeView-BiLf0JJw.js +0 -10
- package/dist/web/assets/index-DTZrHyAu.css +0 -1
|
@@ -5,6 +5,7 @@ import { resolveDomainAccess, canEnterDomainTree } from "../access/domain-access
|
|
|
5
5
|
import { canReadDocument, DocumentError } from "../access/access-control.js";
|
|
6
6
|
import { getConfig } from "../config/index.js";
|
|
7
7
|
import { FOLDER_DESC_FILENAME } from "../../shared/folderDesc.js";
|
|
8
|
+
import { getPolicy } from "../../shared/file-type-policy.js";
|
|
8
9
|
/**
|
|
9
10
|
* 构建指定域的文档目录树。
|
|
10
11
|
*/
|
|
@@ -98,7 +99,7 @@ function projectSubtree(nodes) {
|
|
|
98
99
|
*
|
|
99
100
|
* 步骤:
|
|
100
101
|
* 1. 为所有 dir 创建文件夹节点,document_id → TreeFolderNode 映射
|
|
101
|
-
* 2.
|
|
102
|
+
* 2. 处理文章叶子:folder_desc 挂到父文件夹;md/html 等 treeVisible 类型挂到树上
|
|
102
103
|
* 3. 将文件夹挂在各自的父文件夹下
|
|
103
104
|
* 4. 对根节点和子节点递归排序
|
|
104
105
|
*/
|
|
@@ -149,13 +150,17 @@ function buildTreeFromRows(rows, visitorId) {
|
|
|
149
150
|
addedToRoots.add(row.document_id);
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
|
-
//
|
|
153
|
+
// 第三步:处理叶子(md / html / folder_desc …),读政策 treeInclude
|
|
153
154
|
for (const row of rows) {
|
|
154
|
-
if (row.file_type
|
|
155
|
+
if (row.file_type === "dir")
|
|
156
|
+
continue;
|
|
157
|
+
const policy = getPolicy(row.file_type);
|
|
158
|
+
if (!policy?.treeInclude)
|
|
155
159
|
continue;
|
|
156
160
|
const leafName = row.relative_path.split("/").pop();
|
|
157
|
-
if (
|
|
158
|
-
|
|
161
|
+
if (row.file_type === "folder_desc" ||
|
|
162
|
+
leafName.toLowerCase() === FOLDER_DESC_FILENAME.toLowerCase()) {
|
|
163
|
+
// 描述文档:挂载到父文件夹(不作为独立树节点)
|
|
159
164
|
if (row.parent_id) {
|
|
160
165
|
const parent = folderById.get(row.parent_id);
|
|
161
166
|
if (parent) {
|
|
@@ -166,8 +171,8 @@ function buildTreeFromRows(rows, visitorId) {
|
|
|
166
171
|
}
|
|
167
172
|
}
|
|
168
173
|
}
|
|
169
|
-
else {
|
|
170
|
-
//
|
|
174
|
+
else if (policy.treeVisible) {
|
|
175
|
+
// 普通文档(md / html 等)
|
|
171
176
|
const node = {
|
|
172
177
|
type: "document",
|
|
173
178
|
name: leafName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.service.js","sourceRoot":"","sources":["../../../src/server/documents/tree.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,GAEtB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnF,OAAO,EAAE,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中定义,避免硬编码分散在各处。
|
|
5
|
-
* 前后端共用一份表。
|
|
6
|
-
*/
|
|
7
|
-
import { FILE_TYPE } from './file-types.js';
|
|
8
|
-
/* ── 政策表 ── */
|
|
1
|
+
/* ── 政策表(键与 FILE_TYPE 字面量一致) ── */
|
|
9
2
|
const POLICY_TABLE = {
|
|
10
|
-
|
|
3
|
+
md: {
|
|
11
4
|
treeVisible: true,
|
|
12
5
|
treeInclude: true,
|
|
13
6
|
movable: true,
|
|
@@ -21,7 +14,7 @@ const POLICY_TABLE = {
|
|
|
21
14
|
mergePipeline: 'lexical-md-bridge',
|
|
22
15
|
editor: 'lobe',
|
|
23
16
|
},
|
|
24
|
-
|
|
17
|
+
html: {
|
|
25
18
|
treeVisible: true,
|
|
26
19
|
treeInclude: true,
|
|
27
20
|
movable: true,
|
|
@@ -35,7 +28,7 @@ const POLICY_TABLE = {
|
|
|
35
28
|
mergePipeline: 'raw-text',
|
|
36
29
|
editor: 'html',
|
|
37
30
|
},
|
|
38
|
-
|
|
31
|
+
dir: {
|
|
39
32
|
treeVisible: true,
|
|
40
33
|
treeInclude: true,
|
|
41
34
|
movable: false,
|
|
@@ -49,7 +42,7 @@ const POLICY_TABLE = {
|
|
|
49
42
|
mergePipeline: 'none',
|
|
50
43
|
editor: 'none',
|
|
51
44
|
},
|
|
52
|
-
|
|
45
|
+
folder_desc: {
|
|
53
46
|
treeVisible: false,
|
|
54
47
|
treeInclude: true,
|
|
55
48
|
movable: false,
|
|
@@ -63,7 +56,7 @@ const POLICY_TABLE = {
|
|
|
63
56
|
mergePipeline: 'none',
|
|
64
57
|
editor: 'none',
|
|
65
58
|
},
|
|
66
|
-
|
|
59
|
+
graph_file: {
|
|
67
60
|
treeVisible: false,
|
|
68
61
|
treeInclude: false,
|
|
69
62
|
movable: false,
|
|
@@ -77,7 +70,7 @@ const POLICY_TABLE = {
|
|
|
77
70
|
mergePipeline: 'none',
|
|
78
71
|
editor: 'none',
|
|
79
72
|
},
|
|
80
|
-
|
|
73
|
+
graph_dir: {
|
|
81
74
|
treeVisible: false,
|
|
82
75
|
treeInclude: false,
|
|
83
76
|
movable: false,
|
|
@@ -117,4 +110,9 @@ export function movableDocTypes() {
|
|
|
117
110
|
export function canOverwrite(fileType) {
|
|
118
111
|
return POLICY_TABLE[fileType]?.writeNormalize !== 'none';
|
|
119
112
|
}
|
|
113
|
+
/** 侧栏树是否可见(treeVisible) */
|
|
114
|
+
export function isVisibleFileType(fileType) {
|
|
115
|
+
const policy = POLICY_TABLE[fileType];
|
|
116
|
+
return policy?.treeVisible === true;
|
|
117
|
+
}
|
|
120
118
|
//# sourceMappingURL=file-type-policy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-type-policy.js","sourceRoot":"","sources":["../../src/shared/file-type-policy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-type-policy.js","sourceRoot":"","sources":["../../src/shared/file-type-policy.ts"],"names":[],"mappings":"AAwCA,mCAAmC;AAEnC,MAAM,YAAY,GAAqC;IACrD,EAAE,EAAE;QACF,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,IAAI;QACjB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;QACd,YAAY,EAAE,IAAI;QAClB,eAAe,EAAE,KAAK;QACtB,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,SAAS;QACtB,cAAc,EAAE,YAAY;QAC5B,SAAS,EAAE,SAAS;QACpB,aAAa,EAAE,mBAAmB;QAClC,MAAM,EAAE,MAAM;KACf;IACD,IAAI,EAAE;QACJ,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,IAAI;QACjB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,KAAK;QACf,YAAY,EAAE,KAAK;QACnB,eAAe,EAAE,KAAK;QACtB,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,KAAK;QAClB,cAAc,EAAE,KAAK;QACrB,SAAS,EAAE,MAAM;QACjB,aAAa,EAAE,UA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CAAC,CAAC;IAClD,OAAO,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { FILE_TYPE } from "./file-types.js";
|
|
3
|
+
import { ftsIndexTypes, getPolicy, graphWalkIncludeTypes, isVisibleFileType, movableDocTypes, treeIncludeTypes, } from "./file-type-policy.js";
|
|
4
|
+
describe("file-type-policy", () => {
|
|
5
|
+
it("html:可见、可移动、不进 FTS/图谱抽取,草稿/merge/编辑器为 html/raw", () => {
|
|
6
|
+
const p = getPolicy(FILE_TYPE.HTML);
|
|
7
|
+
expect(p.treeVisible).toBe(true);
|
|
8
|
+
expect(p.treeInclude).toBe(true);
|
|
9
|
+
expect(p.movable).toBe(true);
|
|
10
|
+
expect(p.ftsIndex).toBe(false);
|
|
11
|
+
expect(p.graphExtract).toBe(false);
|
|
12
|
+
expect(p.pathExt).toBe(".html");
|
|
13
|
+
expect(p.textExtract).toBe("raw");
|
|
14
|
+
expect(p.writeNormalize).toBe("raw");
|
|
15
|
+
expect(p.draftKind).toBe("html");
|
|
16
|
+
expect(p.mergePipeline).toBe("raw-text");
|
|
17
|
+
expect(p.editor).toBe("html");
|
|
18
|
+
});
|
|
19
|
+
it("派生查询不含 html 进 FTS / graph walk", () => {
|
|
20
|
+
expect(ftsIndexTypes()).toEqual([FILE_TYPE.DOCUMENT]);
|
|
21
|
+
expect(graphWalkIncludeTypes()).toEqual([
|
|
22
|
+
FILE_TYPE.DOCUMENT,
|
|
23
|
+
FILE_TYPE.FOLDER,
|
|
24
|
+
FILE_TYPE.FOLDER_DESC,
|
|
25
|
+
]);
|
|
26
|
+
expect(treeIncludeTypes()).toContain(FILE_TYPE.HTML);
|
|
27
|
+
expect(movableDocTypes()).toEqual([FILE_TYPE.DOCUMENT, FILE_TYPE.HTML]);
|
|
28
|
+
});
|
|
29
|
+
it("isVisibleFileType 读 treeVisible", () => {
|
|
30
|
+
expect(isVisibleFileType(FILE_TYPE.DOCUMENT)).toBe(true);
|
|
31
|
+
expect(isVisibleFileType(FILE_TYPE.HTML)).toBe(true);
|
|
32
|
+
expect(isVisibleFileType(FILE_TYPE.FOLDER)).toBe(true);
|
|
33
|
+
expect(isVisibleFileType(FILE_TYPE.FOLDER_DESC)).toBe(false);
|
|
34
|
+
expect(isVisibleFileType(FILE_TYPE.GRAPH_FILE)).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=file-type-policy.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-type-policy.test.js","sourceRoot":"","sources":["../../src/shared/file-type-policy.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,aAAa,EACb,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAE/B,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/B,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,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C,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrD,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvD,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7D,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* - graph_file / graph_dir:图谱相关文件(文档树中不可见)
|
|
8
8
|
*
|
|
9
9
|
* 新增文件类型在这里统一定义,不要散落在各处。
|
|
10
|
+
* 能力开关见 `file-type-policy.ts`。
|
|
10
11
|
*/
|
|
11
12
|
export const FILE_TYPE = {
|
|
12
13
|
/** 普通 Markdown 文章(文档树中可见) */
|
|
@@ -22,10 +23,8 @@ export const FILE_TYPE = {
|
|
|
22
23
|
/** 图谱缓存目录 __graph__(文档树中不可见) */
|
|
23
24
|
GRAPH_DIR: 'graph_dir',
|
|
24
25
|
};
|
|
25
|
-
/**
|
|
26
|
-
export
|
|
27
|
-
return fileType === FILE_TYPE.DOCUMENT || fileType === FILE_TYPE.HTML || fileType === FILE_TYPE.FOLDER;
|
|
28
|
-
}
|
|
26
|
+
/** 判断是否是文档树中可见的类型(委托政策表 treeVisible) */
|
|
27
|
+
export { isVisibleFileType } from './file-type-policy.js';
|
|
29
28
|
/** 判断是否是目录类型(普通目录或特殊目录) */
|
|
30
29
|
export function isFolderFileType(fileType) {
|
|
31
30
|
return fileType === FILE_TYPE.FOLDER || fileType === FILE_TYPE.GRAPH_DIR;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-types.js","sourceRoot":"","sources":["../../src/shared/file-types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"file-types.js","sourceRoot":"","sources":["../../src/shared/file-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,6BAA6B;IAC7B,QAAQ,EAAE,IAAI;IACd,sBAAsB;IACtB,IAAI,EAAE,MAAM;IACZ,mBAAmB;IACnB,MAAM,EAAE,KAAK;IACb,6CAA6C;IAC7C,WAAW,EAAE,aAAa;IAC1B,0BAA0B;IAC1B,UAAU,EAAE,YAAY;IACxB,gCAAgC;IAChC,SAAS,EAAE,WAAW;CACd,CAAC;AAIX,wCAAwC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,2BAA2B;AAC3B,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,OAAO,QAAQ,KAAK,SAAS,CAAC,MAAM,IAAI,QAAQ,KAAK,SAAS,CAAC,SAAS,CAAC;AAC3E,CAAC;AAED,qBAAqB;AACrB,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,QAAQ,KAAK,SAAS,CAAC,UAAU,IAAI,QAAQ,KAAK,SAAS,CAAC,SAAS,CAAC;AAC/E,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diagram-Bk84WZto.js","assets/ui-CvA4pq3d.js","assets/react-vendor-BuABiQkA.js","assets/motion-DFABYlwt.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as l,j as e,_ as tt,b as st}from"./react-vendor-BuABiQkA.js";import{c as te,N as Pe,ag as ee,ah as Ee,ai as nt,i as $e,aj as ze,ak as at,al as rt,am as it,an as ot,ao as lt,ap as ct,aq as Le,ar as dt,as as ut,at as mt}from"./index-
|
|
2
|
+
import{r as l,j as e,_ as tt,b as st}from"./react-vendor-BuABiQkA.js";import{c as te,N as Pe,ag as ee,ah as Ee,ai as nt,i as $e,aj as ze,ak as at,al as rt,am as it,an as ot,ao as lt,ap as ct,aq as Le,ar as dt,as as ut,at as mt}from"./index-CwzlBu2W.js";import{H as pt,S as ft,A as ht}from"./AgentSkillFormCard-DEKBKWH-.js";import{C as gt}from"./code-xml-DX89c1sd.js";import{C as Be,a as Oe}from"./copy-yWKSE1g1.js";import{P as xt}from"./plus-B0mmDuSt.js";import{ae as yt,af as jt}from"./ui-CvA4pq3d.js";import"./diagram-Bk84WZto.js";import"./motion-DFABYlwt.js";/**
|
|
3
3
|
* @license lucide-react v0.562.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as q,a2 as L,av as D,ar as F,aw as _}from"./index-
|
|
1
|
+
import{c as q,a2 as L,av as D,ar as F,aw as _}from"./index-CwzlBu2W.js";import{r as a,j as e}from"./react-vendor-BuABiQkA.js";/**
|
|
2
2
|
* @license lucide-react v0.562.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as d,j as n}from"./react-vendor-BuABiQkA.js";import{ah as ne,ai as de,i as ue,aj as te,am as me,au as he,an as fe,ao as ge,ap as xe}from"./index-
|
|
1
|
+
import{r as d,j as n}from"./react-vendor-BuABiQkA.js";import{ah as ne,ai as de,i as ue,aj as te,am as me,au as he,an as fe,ao as ge,ap as xe}from"./index-CwzlBu2W.js";import{H as ke,S as ye,A as we}from"./AgentSkillFormCard-DEKBKWH-.js";import{P as pe}from"./plus-B0mmDuSt.js";import{ae as je,af as Ne}from"./ui-CvA4pq3d.js";import"./diagram-Bk84WZto.js";import"./motion-DFABYlwt.js";function X(e){return e===""?[]:e.split(`
|
|
2
2
|
`)}function be(e){return e.join(`
|
|
3
3
|
`)}function Z(e,i){const s=X(e),l=X(i),m=s.length,k=l.length,y=Array.from({length:m+1},()=>Array.from({length:k+1},()=>0));for(let N=m-1;N>=0;N--)for(let v=k-1;v>=0;v--)s[N]===l[v]?y[N][v]=y[N+1][v+1]+1:y[N][v]=Math.max(y[N+1][v],y[N][v+1]);const C=[];let g=0,x=0;for(;g<m||x<k;)if(g<m&&x<k&&s[g]===l[x])C.push({kind:"eq",oi:g,ni:x}),g++,x++;else if(x<k&&(g===m||y[g][x+1]>=y[g+1][x]))C.push({kind:"ins",oi:g,ni:x}),x++;else if(g<m)C.push({kind:"del",oi:g,ni:x}),g++;else break;const j=[];let f=0,P=0;for(;f<C.length;){if(C[f].kind==="eq"){f++;continue}const N=C[f].oi,v=C[f].ni,R=[],b=[];let A=N,D=v;for(;f<C.length&&C[f].kind!=="eq";){const $=C[f];$.kind==="del"?(R.push(s[$.oi]),A=$.oi+1):(b.push(l[$.ni]),D=$.ni+1),f++}j.push({id:`h${P++}`,oldStart:N,oldEnd:A,newStart:v,newEnd:D,oldLines:R,newLines:b})}return j}function Se(e,i){const s=X(e);return be([...s.slice(0,i.oldStart),...i.newLines,...s.slice(i.oldEnd)])}function Y(e){return e===""?[]:e.split(`
|
|
4
4
|
`)}function K(e){return e.join(`
|
package/dist/web/assets/{DiagramEditor-NtNY3sZL-D8pO8wBI.js → DiagramEditor-NtNY3sZL-5TyWJGgH.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Q as I,S as H,T as F,U as O,V as G}from"./react-
|
|
1
|
+
import{Q as I,S as H,T as F,U as O,V as G}from"./react-BJcufYxR.js";import{r as c,j as e}from"./react-vendor-BuABiQkA.js";import{ensureMeta2dShapes as X,generateSvgFromMeta2d as Q,generateSvgFromDiagram as Y}from"./meta2dEngine-BD2XbzaV-DUaWTg_P.js";import{M as _}from"./meta2d-1-g23JOU.js";import"./editor-CL03se2B.js";import"./ui-CvA4pq3d.js";import"./motion-DFABYlwt.js";import"./diagram-Bk84WZto.js";import"./index-CwzlBu2W.js";import"./plus-B0mmDuSt.js";import"./copy-yWKSE1g1.js";let q=0;const P=new Set;function $(n){return P.add(n),()=>{P.delete(n)}}function M(){return q}function J(){q++,P.forEach(n=>n())}function z(n){let t=null;try{const[r]=I();t=r}catch{}const i=t;if(!i)throw new Error("[useEditorLocale] No editor found. Pass an editor instance or use this hook inside an <Editor> tree.");return c.useSyncExternalStore($,M,M),{setLocale:c.useCallback(r=>{i.setLocale(r),J()},[i]),t:c.useCallback((r,u)=>i.t(r,u),[i])}}const K={Activity:"meta2d.palette.groups.activity",Basic:"meta2d.palette.groups.basic","Fault tree":"meta2d.palette.groups.faultTree",Flow:"meta2d.palette.groups.flow","Sequence & class":"meta2d.palette.groups.sequenceClass"};function W(n){return`meta2d.palette.${n}`}const s={background:"#fff",color:"#1f1f1f",height:60,lineWidth:1,textColor:"#1f1f1f",width:120};function U(){return[{group:"Basic",key:"square",label:"Square",pen:{...s,height:100,name:"square",text:"",width:100}},{group:"Basic",key:"rect",label:"Rectangle",pen:{...s,name:"rectangle",text:"Rectangle"}},{group:"Basic",key:"roundRect",label:"Rounded",pen:{...s,borderRadius:.2,name:"rectangle",text:"Rounded"}},{group:"Basic",key:"circle",label:"Circle",pen:{...s,height:80,name:"circle",text:"Circle",width:80}},{group:"Basic",key:"triangle",label:"Triangle",pen:{...s,height:90,name:"triangle",text:"Triangle",width:100}},{group:"Basic",key:"diamond",label:"Diamond",pen:{...s,height:100,name:"diamond",text:"Decision",width:100}},{group:"Basic",key:"pentagon",label:"Pentagon",pen:{...s,height:100,name:"pentagon",text:"Pentagon",width:100}},{group:"Basic",key:"hexagon",label:"Hexagon",pen:{...s,height:100,name:"hexagon",text:"Hexagon",width:100}},{group:"Basic",key:"pentagram",label:"Star",pen:{...s,height:100,name:"pentagram",text:"",width:100}},{group:"Basic",key:"leftArrow",label:"Left arrow",pen:{height:60,name:"leftArrow",width:120}},{group:"Basic",key:"rightArrow",label:"Right arrow",pen:{height:60,name:"rightArrow",width:120}},{group:"Basic",key:"twowayArrow",label:"Two-way",pen:{height:60,name:"twowayArrow",width:150}},{group:"Basic",key:"cloud",label:"Cloud",pen:{height:100,name:"cloud",width:100}},{group:"Basic",key:"message",label:"Message",pen:{height:100,name:"message",textTop:-.1,width:100}},{group:"Basic",key:"file",label:"File",pen:{height:100,name:"file",width:80}},{group:"Basic",key:"cube",label:"Cube",pen:{height:100,name:"cube",width:60,z:.25}},{group:"Basic",key:"people",label:"Actor",pen:{height:100,name:"people",width:70}},{group:"Basic",key:"text",label:"Text",pen:{...s,background:"transparent",color:"transparent",height:32,name:"text",text:"text",width:120}},{group:"Basic",key:"line",label:"Line",pen:{color:"#1f1f1f",height:1,lineWidth:1,name:"line",width:160}},{group:"Flow",key:"flowTerminal",label:"Terminal",pen:{...s,borderRadius:.5,height:40,name:"rectangle",text:"Start / End",width:120}},{group:"Flow",key:"flowProcess",label:"Process",pen:{...s,height:40,name:"rectangle",text:"Process",width:120}},{group:"Flow",key:"flowDecision",label:"Decision",pen:{...s,height:60,name:"diamond",text:"Decision",width:120}},{group:"Flow",key:"flowData",label:"Data",pen:{...s,name:"flowData",offsetX:.14,text:"Data"}},{group:"Flow",key:"flowPrepare",label:"Prepare",pen:{...s,height:50,name:"hexagon",text:"Prepare",width:120}},{group:"Flow",key:"flowSubprocess",label:"Subprocess",pen:{...s,height:50,name:"flowSubprocess",text:"Subprocess",width:120}},{group:"Flow",key:"flowDb",label:"Database",pen:{...s,height:100,name:"flowDb",text:"DB",width:80}},{group:"Flow",key:"flowDocument",label:"Document",pen:{...s,height:100,name:"flowDocument",text:"Document",width:120}},{group:"Flow",key:"flowInternalStorage",label:"Int. storage",pen:{...s,height:80,name:"flowInternalStorage",text:"Internal",width:120}},{group:"Flow",key:"flowExternStorage",label:"Ext. storage",pen:{...s,height:80,name:"flowExternStorage",text:"External",width:120}},{group:"Flow",key:"flowQueue",label:"Queue",pen:{...s,height:100,name:"flowQueue",text:"Queue",width:100}},{group:"Flow",key:"flowManually",label:"Manual input",pen:{...s,height:80,name:"flowManually",text:"Manual",width:120}},{group:"Flow",key:"flowDisplay",label:"Display",pen:{...s,height:80,name:"flowDisplay",text:"Display",width:120}},{group:"Flow",key:"flowParallel",label:"Parallel",pen:{...s,height:50,name:"flowParallel",text:"Parallel",width:120}},{group:"Flow",key:"flowComment",label:"Comment",pen:{...s,height:100,name:"flowComment",text:"Note",width:100}},{group:"Activity",key:"actStart",label:"Start",pen:{background:"#555",height:30,lineWidth:0,name:"circle",text:"",width:30}},{group:"Activity",key:"actFinal",label:"Final",pen:{height:30,name:"activityFinal",width:30}},{group:"Activity",key:"actStep",label:"Action",pen:{...s,borderRadius:.25,height:50,name:"rectangle",text:"Action",width:120}},{group:"Activity",key:"actMerge",label:"Merge",pen:{...s,height:50,name:"diamond",text:"Merge",width:120}},{group:"Activity",key:"swimlaneV",label:"Swimlane V",pen:{height:500,lineTop:.08,name:"swimlaneV",text:"Swimlane",textBaseline:"top",textTop:20,width:200}},{group:"Activity",key:"swimlaneH",label:"Swimlane H",pen:{height:200,lineLeft:.08,name:"swimlaneH",text:"Swimlane",textAlign:"left",textLeft:.04,textWidth:.01,width:500}},{group:"Activity",key:"forkV",label:"Fork V",pen:{fillStyle:"#555",height:150,name:"forkV",strokeStyle:"transparent",text:"",width:10}},{group:"Activity",key:"forkH",label:"Fork H",pen:{fillStyle:"#555",height:10,name:"forkH",strokeStyle:"transparent",text:"",width:150}},{group:"Sequence & class",key:"lifeline",label:"Lifeline",pen:{height:400,name:"lifeline",text:"Object",textHeight:50,width:150}},{group:"Sequence & class",key:"sequenceFocus",label:"Activation",pen:{height:200,name:"sequenceFocus",text:"",width:12}},{group:"Sequence & class",key:"simpleClass",label:"Simple class",pen:{height:200,list:[{text:`- name: string
|
|
2
2
|
+ setName(name: string): void`}],name:"simpleClass",text:"ClassName",textAlign:"center",textBaseline:"top",textHeight:200,textTop:10,width:270}},{group:"Sequence & class",key:"interfaceClass",label:"Class",pen:{height:200,list:[{text:"- name: string"},{text:"+ setName(name: string): void"}],name:"interfaceClass",text:"ClassName",textAlign:"center",textBaseline:"top",textHeight:200,textTop:10,width:270}},{group:"Fault tree",key:"andGate",label:"AND gate",pen:{height:150,name:"andGate",width:100}},{group:"Fault tree",key:"orGate",label:"OR gate",pen:{height:150,name:"orGate",width:100}},{group:"Fault tree",key:"basicEvent",label:"Basic event",pen:{height:150,name:"basicEvent",width:100}},{group:"Fault tree",key:"xorGate",label:"XOR gate",pen:{height:150,name:"xorGate",width:100}},{group:"Fault tree",key:"votingGate",label:"Voting gate",pen:{height:150,name:"votingGate",width:100}}]}function V(n){return G(structuredClone(n))}function Z(n){const t=new Map;for(const i of n){const r=t.get(i.group)??[];r.push(i),t.set(i.group,r)}return Array.from(t.entries())}function ee({name:n}){const t={fill:"#fff",stroke:"#1f1f1f",strokeWidth:1.2};return n==="circle"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("circle",{cx:"14",cy:"14",r:"10",...t})}):n==="diamond"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,3 25,14 14,25 3,14",...t})}):n==="triangle"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,4 25,24 3,24",...t})}):n==="pentagon"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,3 25,12 21,25 7,25 3,12",...t})}):n==="hexagon"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"8,4 20,4 25,14 20,24 8,24 3,14",...t})}):n==="pentagram"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("polygon",{points:"14,3 17,11 26,11 18,16 21,25 14,20 7,25 10,16 2,11 11,11",...t})}):n==="line"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("line",{x1:"4",x2:"24",y1:"14",y2:"14",...t})}):n==="text"?e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("text",{dominantBaseline:"middle",fill:"#1f1f1f",fontSize:"14",textAnchor:"middle",x:"14",y:"15",children:"T"})}):e.jsx("svg",{height:"24",viewBox:"0 0 28 28",width:"24",children:e.jsx("rect",{height:"14",rx:"2",width:"20",x:"4",y:"7",...t})})}function te({disabled:n,engineRef:t,item:i,t:r}){const u=()=>{const a=t.current;if(!(!a||n))try{a.canvas.addCaches=[V(i.pen)]}catch{}};return e.jsxs("div",{draggable:!n,onClick:a=>{a.stopPropagation(),u()},onDragStart:a=>{if(n){a.preventDefault();return}const f=JSON.stringify(V(i.pen));a.dataTransfer.setData("Meta2d",f),a.dataTransfer.setData("Text",f),a.dataTransfer.effectAllowed="copy"},onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),u())},role:"button",style:{alignItems:"center",border:"1px solid #efefef",borderRadius:6,cursor:n?"not-allowed":"grab",display:"flex",flexDirection:"column",gap:4,justifyContent:"center",minHeight:56,opacity:n?.5:1,outline:"none",padding:6},tabIndex:n?-1:0,title:`${r(W(i.key))||i.label} — drag or click to add`,children:[e.jsx(ee,{name:String(i.pen.name??"rectangle")}),e.jsx("span",{style:{fontSize:11},children:r(W(i.key))||i.label})]})}function ne({disabled:n,engineRef:t}){const{t:i}=z(),r=c.useMemo(()=>Z(U()),[]);return e.jsxs("aside",{style:{borderRight:"1px solid #f0f0f0",flexShrink:0,maxHeight:"100%",overflowX:"hidden",overflowY:"auto",overscrollBehavior:"contain",padding:12,touchAction:"pan-y",width:240},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,marginBottom:4},children:i("meta2d.palette.title")}),e.jsx("div",{style:{color:"#8c8c8c",fontSize:12,marginBottom:12},children:i("meta2d.palette.hint")}),r.map(([u,a])=>e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:{color:"#8c8c8c",fontSize:12,marginBottom:6},children:i(K[u]||u)}),e.jsx("div",{style:{display:"grid",gap:8,gridTemplateColumns:"repeat(2, minmax(0, 1fr))"},children:a.map(f=>e.jsx(te,{disabled:n,engineRef:t,item:f,t:i},f.key))})]},u))]})}const N={borderLeft:"1px solid #f0f0f0",flexShrink:0,maxHeight:"100%",overflowX:"hidden",overflowY:"auto",overscrollBehavior:"contain",touchAction:"pan-y",width:220},A={color:"#8c8c8c",fontSize:12,marginBottom:4},D={borderBottom:"1px solid #f0f0f0",padding:"10px 12px"},y={alignItems:"center",display:"flex",gap:6,marginBottom:6},w={background:"#fafafa",border:"1px solid #e5e5e5",borderRadius:4,fontSize:12,height:28,outline:"none",padding:"0 6px"},b={color:"#8c8c8c",fontSize:11,minWidth:22},T={background:"#fff",border:"1px solid #d9d9d9",borderRadius:4,cursor:"pointer",fontSize:11,minWidth:48,padding:"4px 8px"},le=120;function ie({engine:n}){const{t}=z(),[i,r]=c.useState(null),[u,a]=c.useState(null),[f,v]=c.useState(""),p=c.useRef(null),j=c.useRef(null),B=c.useCallback((l,d)=>{!n||l===null||l===void 0||n.setValue({id:l,text:d},{render:!0})},[n]),k=c.useCallback(l=>{if(!l||l.length!==1){p.current&&(clearTimeout(p.current),p.current=null),r(null),a(null),v(""),j.current=null;return}const d=l[0];if((d.globalAlpha===null||d.globalAlpha===void 0)&&(d.globalAlpha=1),d.id!==j.current&&(p.current&&(clearTimeout(p.current),p.current=null),j.current=d.id,v(d.text??"")),r(d),n)try{a(n.getPenRect(d))}catch{a(null)}},[n]),C=c.useCallback(()=>{p.current&&(clearTimeout(p.current),p.current=null),r(null),a(null),v(""),j.current=null},[]);if(c.useEffect(()=>{if(n)return n.on("active",k),n.on("inactive",C),()=>{n.off("active",k),n.off("inactive",C),p.current&&(clearTimeout(p.current),p.current=null)}},[n,k,C]),!i||!n)return e.jsx("aside",{style:N,children:e.jsx("div",{style:{color:"#bbb",fontSize:12,padding:16,textAlign:"center"},children:t("meta2d.props.empty")})});const h=(l,d)=>{const m={id:i.id};m[l]=d,l==="dash"&&(m.lineDash=[void 0,[5,5]][d]),l!=="text"&&r(S=>S&&{...S,...m}),n.setValue(m,{render:!0})},o=l=>{v(l);const d=i.id;p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{p.current=null,B(d,l)},le)},x=()=>{p.current&&(clearTimeout(p.current),p.current=null),B(i.id,f)},g=(l,d)=>{if(!u)return;const m={id:i.id};m[l]=d,n.setValue(m,{render:!0}),a(S=>S?{...S,[l]:d}:null)},R=l=>{l(n),n.render(!0)};return e.jsxs("aside",{style:N,children:[e.jsxs("div",{style:D,children:[e.jsx("div",{style:A,children:t("meta2d.props.text")}),e.jsx("div",{style:y,children:e.jsx("input",{onBlur:x,onChange:l=>o(l.target.value),onKeyDown:l=>{l.stopPropagation(),l.key==="Enter"&&(l.preventDefault(),l.target.blur())},style:{...w,flex:1,width:"100%"},type:"text",value:f})})]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:{...A,marginBottom:6},children:t("meta2d.props.appearance")}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.color")}),e.jsx("input",{onChange:l=>h("color",l.target.value),style:{...w,flex:1},type:"color",value:i.color||"#1f1f1f"})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.bg")}),e.jsx("input",{onChange:l=>h("background",l.target.value),style:{...w,flex:1},type:"color",value:i.background||"#ffffff"})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.dash")}),e.jsxs("select",{onChange:l=>h("dash",Number(l.target.value)),style:{...w,flex:1},value:String(i.dash??0),children:[e.jsx("option",{value:"0",children:t("meta2d.props.solid")}),e.jsx("option",{value:"1",children:t("meta2d.props.dashLine")})]})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.radius")}),e.jsx("input",{max:1,min:0,onChange:l=>h("borderRadius",Number(l.target.value)),step:.01,style:{...w,flex:1},type:"range",value:String(i.borderRadius??0)}),e.jsx("span",{style:{color:"#8c8c8c",fontSize:11,width:32},children:i.borderRadius??0})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.alpha")}),e.jsx("input",{max:1,min:0,onChange:l=>h("globalAlpha",Number(l.target.value)),step:.01,style:{...w,flex:1},type:"range",value:String(i.globalAlpha??1)}),e.jsx("span",{style:{color:"#8c8c8c",fontSize:11,width:32},children:(i.globalAlpha??1).toFixed(2)})]})]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:{...A,marginBottom:6},children:t("meta2d.props.position")}),[["X","x"],["Y","y"],["W","width"],["H","height"]].map(([l,d])=>e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:l}),e.jsx("input",{onChange:m=>g(d,Number(m.target.value)),style:{...w,flex:1},type:"number",value:u?u[d]:0})]},d))]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:{...A,marginBottom:6},children:t("meta2d.props.textAlign")}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.h")}),e.jsxs("select",{onChange:l=>h("textAlign",l.target.value),style:{...w,flex:1},value:i.textAlign||"center",children:[e.jsx("option",{value:"left",children:t("meta2d.props.left")}),e.jsx("option",{value:"center",children:t("meta2d.props.center")}),e.jsx("option",{value:"right",children:t("meta2d.props.right")})]})]}),e.jsxs("div",{style:y,children:[e.jsx("span",{style:b,children:t("meta2d.props.v")}),e.jsxs("select",{onChange:l=>h("textBaseline",l.target.value),style:{...w,flex:1},value:i.textBaseline||"middle",children:[e.jsx("option",{value:"top",children:t("meta2d.props.topAlign")}),e.jsx("option",{value:"middle",children:t("meta2d.props.middle")}),e.jsx("option",{value:"bottom",children:t("meta2d.props.bottomAlign")})]})]})]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:{...A,marginBottom:6},children:t("meta2d.props.layer")}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[e.jsx("button",{onClick:()=>R(l=>l.top()),style:T,type:"button",children:t("meta2d.props.top")}),e.jsx("button",{onClick:()=>R(l=>l.up()),style:T,type:"button",children:t("meta2d.props.up")}),e.jsx("button",{onClick:()=>R(l=>l.down()),style:T,type:"button",children:t("meta2d.props.down")}),e.jsx("button",{onClick:()=>R(l=>l.bottom()),style:T,type:"button",children:t("meta2d.props.bottom")})]})]})]})}const L={background:"#fff",border:"1px solid #d9d9d9",borderRadius:6,cursor:"pointer",minWidth:68,padding:"6px 12px"},E={...L,fontSize:12,minWidth:52,padding:"4px 10px"};function re(n){c.useEffect(()=>{const t=document.documentElement,i=document.body,r=t.style.overflow,u=i.style.overflow;return t.style.overflow="hidden",i.style.overflow="hidden",()=>{t.style.overflow=r,i.style.overflow=u}},[n])}function me({diagram:n,onClose:t,onSave:i}){const{t:r}=z(),u=c.useRef(null),a=c.useRef(null),f=c.useRef(n),v=c.useRef(t),[p,j]=c.useState(null),[B,k]=c.useState(!1);re(!0),c.useLayoutEffect(()=>{v.current=t}),c.useEffect(()=>{if(!u.current)return;X();const o=new _(u.current,{grid:!0,rule:!1});a.current=o,j(o);try{const g=f.current;g!=null&&g.trim()?o.open(JSON.parse(g)):o.open(H()),F(o.data()),o.render(!0)}catch{o.open(H()),F(o.data()),o.render(!0)}const x=g=>{g.key==="Escape"&&v.current()};return window.addEventListener("keydown",x),()=>{window.removeEventListener("keydown",x);try{o.destroy()}catch{}a.current=null}},[]);const C=async()=>{const o=a.current;if(o){k(!0);try{F(o.data()),o.render(!0);const x=O(o.data()),g=JSON.stringify(x);i(g,await Q(o)||await Y(g)||'<svg xmlns="http://www.w3.org/2000/svg" width="320" height="180" viewBox="0 0 320 180"><rect width="100%" height="100%" fill="#fafafa" stroke="#eee"/></svg>')}finally{k(!1)}}},h=o=>{const x=a.current;x&&o(x)};return e.jsx("div",{onClick:t,style:{alignItems:"center",background:"rgb(0 0 0 / 35%)",display:"flex",inset:0,justifyContent:"center",overflow:"hidden",position:"fixed",zIndex:1e3},children:e.jsxs("div",{onClick:o=>o.stopPropagation(),onWheel:o=>o.stopPropagation(),style:{background:"#fff",borderRadius:10,boxShadow:"0 12px 30px rgb(0 0 0 / 20%)",display:"flex",flexDirection:"column",height:"86vh",maxHeight:"100%",maxWidth:"1200px",overflow:"hidden",width:"92vw"},children:[e.jsxs("div",{style:{alignItems:"center",borderBottom:"1px solid #f0f0f0",display:"flex",flexWrap:"wrap",gap:8,justifyContent:"space-between",padding:"10px 14px"},children:[e.jsx("span",{style:{fontWeight:600},children:r("meta2d.editor.title")}),e.jsxs("div",{style:{alignItems:"center",display:"flex",flexWrap:"wrap",gap:8},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:[e.jsx("button",{onClick:()=>h(o=>o.undo()),style:E,title:`${r("meta2d.editor.undo")} (Ctrl+Z)`,type:"button",children:r("meta2d.editor.undo")}),e.jsx("button",{onClick:()=>h(o=>o.redo()),style:E,title:`${r("meta2d.editor.redo")} (Ctrl+Y)`,type:"button",children:r("meta2d.editor.redo")}),e.jsx("button",{onClick:()=>h(o=>o.delete()),style:E,title:r("meta2d.editor.delete"),type:"button",children:r("meta2d.editor.delete")}),e.jsx("button",{onClick:()=>h(o=>o.fitView(!0)),style:E,title:r("meta2d.editor.fit"),type:"button",children:r("meta2d.editor.fit")}),e.jsx("button",{onClick:()=>h(o=>{o.scale(1),o.centerView()}),style:E,title:r("meta2d.editor.zoom100"),type:"button",children:r("meta2d.editor.zoom100")})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:t,style:L,type:"button",children:r("meta2d.editor.close")}),e.jsx("button",{disabled:B,onClick:()=>void C(),style:{...L,background:"#1677ff",border:"none",color:"#fff"},type:"button",children:r(B?"meta2d.editor.saving":"meta2d.editor.save")})]})]})]}),e.jsxs("div",{style:{display:"flex",flex:1,minHeight:0,overflow:"hidden"},children:[e.jsx(ne,{engineRef:a}),e.jsx("div",{ref:u,style:{flex:1,minHeight:0,minWidth:0}}),e.jsx(ie,{engine:p})]})]})})}export{me as DiagramEditor};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as i,j as n}from"./react-vendor-BuABiQkA.js";import{ad as ke}from"./ui-CvA4pq3d.js";import{c as Y,g as Re,u as Ae,a as Ie,d as $e,b as Ye,f as Je,e as Ge,h as Ke,N as Xe,P as Qe,D as je,F as Ce,l as le,S as Se,i as Ze,M as pe,r as et,j as tt,k as nt,m as X,n as at,o as it,p as we}from"./index-
|
|
1
|
+
import{r as i,j as n}from"./react-vendor-BuABiQkA.js";import{ad as ke}from"./ui-CvA4pq3d.js";import{c as Y,g as Re,u as Ae,a as Ie,d as $e,b as Ye,f as Je,e as Ge,h as Ke,N as Xe,P as Qe,D as je,F as Ce,l as le,S as Se,i as Ze,M as pe,r as et,j as tt,k as nt,m as X,n as at,o as it,p as we}from"./index-CwzlBu2W.js";import{z as ot,A as st,m as de,n as rt,o as ct,p as lt,r as dt,s as ut,t as mt,v as ft,x as ht,B as yt,R as gt,a as xt,b as Me,c as vt,d as bt,e as kt,f as It,g as jt,h as Ct,i as St,w as ue,j as wt,O as Mt,E as Et,q as Nt,l as Dt,C as Rt,D as At}from"./react-BJcufYxR.js";import{H as Pt,a as Tt,b as Lt,M as Bt,T as _t,S as Ot,W as zt,o as Ht,c as Ee}from"./Toolbar-JoV5KtuT.js";import{V as Ft}from"./VisitorPickerModal-ImaQvyyf.js";import"./motion-DFABYlwt.js";import"./diagram-Bk84WZto.js";import"./editor-CL03se2B.js";import"./plus-B0mmDuSt.js";import"./copy-yWKSE1g1.js";import"./code-xml-DX89c1sd.js";/**
|
|
2
2
|
* @license lucide-react v0.562.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,j as e}from"./react-vendor-BuABiQkA.js";import{b as I,g,u as P}from"./index-CwzlBu2W.js";import"./ui-CvA4pq3d.js";import"./motion-DFABYlwt.js";import"./diagram-Bk84WZto.js";function Q(a){const{documentId:n,initialContent:m,displayName:r,canEdit:u,localBaseCommitIdAtEditStart:x,snapshotMeta:p,contentRevision:N=0,onContentChange:o,onPublish:j,onDraftExistsChange:i,readerChrome:T}=a,{t:h}=I(),[c,f]=t.useState(m),[l,b]=t.useState(!0),M=t.useRef(null),s=t.useRef(null),y=t.useRef(c),C=t.useRef(r),R=t.useRef(x),w=t.useRef(p);y.current=c,C.current=r,R.current=x,w.current=p,t.useEffect(()=>{f(m),b(!0)},[n]),t.useEffect(()=>{N!==0&&f(m)},[N]);const v=t.useCallback(async()=>{await g(n).execute(()=>P({documentId:n,content:y.current,displayName:C.current,contentKind:"html",localBaseCommitIdAtEditStart:R.current,snapshotMeta:w.current})),i==null||i(!0)},[n,i]),k=t.useCallback(()=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{v()},1e3)},[v]);t.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]);const S=t.useCallback(d=>{const E=d.target.value;f(E),o==null||o(E),k()},[o,k]),D=`<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"></head><body>${c}</body></html>`;return e.jsx("div",{className:"mdocs-editor-with-comments",children:e.jsxs("div",{className:"mdocs-editor-container",children:[T?e.jsxs("div",{className:"mdocs-reader-chrome",children:[e.jsx("button",{type:"button",className:"mdocs-reader-back",onClick:()=>{var d;return(d=a.onOpenMobileNav)==null?void 0:d.call(a)},children:"← 返回"}),e.jsx("h1",{className:"mdocs-reader-title",children:r})]}):e.jsxs("div",{className:"mdocs-editor-toolbar",children:[e.jsx("h1",{className:"mdocs-editor-doc-title",children:r}),u&&e.jsxs("div",{className:"mdocs-editor-toolbar-actions",children:[e.jsx("button",{type:"button",className:l?"secondary":"primary",onClick:()=>b(!1),children:h("edit")}),e.jsx("button",{type:"button",className:l?"primary":"secondary",onClick:()=>b(!0),children:h("preview")}),j&&e.jsx("button",{type:"button",className:"primary",onClick:()=>{s.current&&(clearTimeout(s.current),s.current=null),v().then(()=>j(c))},children:h("publish")})]})]}),e.jsxs("div",{className:"mdocs-html-editor-body",children:[!l&&u?e.jsx("textarea",{className:"mdocs-html-editor-textarea",value:c,onChange:S,spellCheck:!1}):null,e.jsx("div",{className:"mdocs-html-editor-preview",style:!l&&u?{width:"50%"}:{width:"100%"},children:e.jsx("iframe",{ref:M,className:"mdocs-html-editor-iframe",srcDoc:D,sandbox:"",title:r})})]})]})})}export{Q as HtmlEditor};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{r as b,j as s}from"./react-vendor-BuABiQkA.js";import{b as H,ax as z,ay as X,az as Z,aA as ee}from"./index-CwzlBu2W.js";import{E as te,B as ne}from"./react-BJcufYxR.js";import"./ui-CvA4pq3d.js";import"./motion-DFABYlwt.js";import"./diagram-Bk84WZto.js";import"./editor-CL03se2B.js";import"./plus-B0mmDuSt.js";import"./copy-yWKSE1g1.js";function U({lexicalJson:e,onMarkdown:n,onError:o}){const[i,l]=b.useState(null),a=b.useRef(!1);return b.useEffect(()=>{a.current=!1},[e]),b.useEffect(()=>{if(!(!i||a.current))try{i.setDocument("json",e);const r=i.getDocument("markdown");typeof r=="string"&&(a.current=!0,n(r))}catch{o==null||o()}},[i,e,n,o]),s.jsx("div",{className:"mdocs-lexical-md-bridge","aria-hidden":!0,children:s.jsx(te,{content:e,type:"json",editable:!1,onInit:l,plugins:[ne]})})}function le(e){const{t:n}=H(),[o,i]=b.useState(0),l=e.segments.filter(t=>t.kind==="conflict"),a=e.unresolvedCount>0;b.useEffect(()=>{if(l.length===0){i(0);return}i(t=>Math.min(t,l.length-1))},[l.length]);function r(t){l.length!==0&&i(u=>{var m;const d=(u+t+l.length)%l.length;return(m=document.getElementById(`mdocs-merge-hunk-${d}`))==null||m.scrollIntoView({block:"center",behavior:"smooth"}),d})}let c=-1;return s.jsxs("div",{className:"mdocs-merge-inline-pane",children:[s.jsxs("div",{className:"mdocs-merge-inline-toolbar",children:[s.jsx("span",{className:"mdocs-merge-inline-hint",children:a?n("mergeReviewHint"):l.length===0?n("mergeNoConflicts"):n("mergeEditAfterResolve")}),l.length>0?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:e.onUseAllMine,children:n("mergeUseAllMine")}),s.jsx("button",{type:"button",onClick:e.onUseAllTheirs,children:n("mergeUseAllTheirs")})]}):null]}),a?s.jsxs("div",{className:"mdocs-merge-inline",role:"document",children:[e.segments.map((t,u)=>{if(t.kind==="unchanged")return s.jsx("pre",{className:"mdocs-merge-inline-same",children:t.lines.map((g,C)=>s.jsxs("div",{className:"mdocs-ai-write-line ctx",children:[s.jsx("span",{className:"mdocs-ai-write-rail","aria-hidden":!0}),s.jsx("span",{className:"mdocs-ai-write-code",children:g||" "})]},C))},`u-${u}`);c+=1;const d=c,m=t.resolution!=="unresolved",f=d===o;return s.jsxs("div",{id:`mdocs-merge-hunk-${d}`,className:"mdocs-merge-inline-hunk"+(f?" is-active":"")+(m?" is-resolved":""),onClick:()=>i(d),children:[m?s.jsx("div",{className:"mdocs-merge-hunk-resolved-tag",children:t.resolution==="remote"?n("mergeReceive"):n("mergeReject")}):s.jsxs("div",{className:"mdocs-merge-hunk-actions",children:[s.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-reject",onClick:g=>{g.stopPropagation(),e.onReject(t.id)},children:n("mergeReject")}),s.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-accept",onClick:g=>{g.stopPropagation(),e.onReceive(t.id)},children:n("mergeReceive")})]}),s.jsxs("pre",{className:"mdocs-ai-write-hunk-pre",children:[t.localLines.map((g,C)=>s.jsxs("div",{className:"mdocs-ai-write-line del",children:[s.jsx("span",{className:"mdocs-ai-write-rail","aria-hidden":!0}),s.jsx("span",{className:"mdocs-ai-write-code",children:g||" "})]},`l${C}`)),t.remoteLines.map((g,C)=>s.jsxs("div",{className:"mdocs-ai-write-line add",children:[s.jsx("span",{className:"mdocs-ai-write-rail","aria-hidden":!0}),s.jsx("span",{className:"mdocs-ai-write-code",children:g||" "})]},`r${C}`))]})]},t.id)}),l.length>0?s.jsxs("div",{className:"mdocs-ai-write-float-nav",role:"toolbar","aria-label":"冲突导航",children:[s.jsx("button",{type:"button","aria-label":"上一段",onClick:()=>r(-1),children:"↑"}),s.jsxs("span",{children:[o+1," / ",l.length]}),s.jsx("button",{type:"button","aria-label":"下一段",onClick:()=>r(1),children:"↓"}),l[o]&&l[o].resolution==="unresolved"?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-reject",onClick:()=>e.onReject(l[o].id),children:n("mergeReject")}),s.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-accept",onClick:()=>e.onReceive(l[o].id),children:n("mergeReceive")})]}):null]}):null]}):s.jsx("textarea",{className:"mdocs-merge-inline-editor",value:e.editableMarkdown,onChange:t=>e.onEditableChange(t.target.value),spellCheck:!1})]})}function ie(e,n){let o={};for(let a=0;a<n.length;a++){const r=n[a];o[r]?o[r].push(a):o[r]=[a]}let l=[{buffer1index:-1,buffer2index:-1,chain:null}];for(let a=0;a<e.length;a++){const r=e[a],c=o[r]||[];let t=0,u=l[0];for(let d=0;d<c.length;d++){const m=c[d];let f;for(f=t;f<l.length&&!(l[f].buffer2index<m&&(f===l.length-1||l[f+1].buffer2index>m));f++);if(f<l.length){const g={buffer1index:a,buffer2index:m,chain:l[f]};if(t===l.length?l.push(u):l[t]=u,t=f+1,u=g,t===l.length)break}}l[t]=u}return l[l.length-1]}function D(e,n){const o=ie(e,n);let i=[],l=e.length,a=n.length;for(let r=o;r!==null;r=r.chain){const c=l-r.buffer1index-1,t=a-r.buffer2index-1;l=r.buffer1index,a=r.buffer2index,(c||t)&&i.push({buffer1:[l+1,c],buffer1Content:e.slice(l+1,l+1+c),buffer2:[a+1,t],buffer2Content:n.slice(a+1,a+1+t)})}return i.reverse(),i}function se(e,n,o){let i=[];function l(t,u){i.push({ab:u,oStart:t.buffer1[0],oLength:t.buffer1[1],abStart:t.buffer2[0],abLength:t.buffer2[1]})}D(n,e).forEach(t=>l(t,"a")),D(n,o).forEach(t=>l(t,"b")),i.sort((t,u)=>t.oStart-u.oStart);let a=[],r=0;function c(t){t>r&&(a.push({stable:!0,buffer:"o",bufferStart:r,bufferLength:t-r,bufferContent:n.slice(r,t)}),r=t)}for(;i.length;){let t=i.shift(),u=t.oStart,d=t.oStart+t.oLength,m=[t];for(c(u);i.length;){const f=i[0],g=f.oStart;if(g>d)break;d=Math.max(d,g+f.oLength),m.push(i.shift())}if(m.length===1){if(t.abLength>0){const f=t.ab==="a"?e:o;a.push({stable:!0,buffer:t.ab,bufferStart:t.abStart,bufferLength:t.abLength,bufferContent:f.slice(t.abStart,t.abStart+t.abLength)})}}else{let f={a:[e.length,-1,n.length,-1],b:[o.length,-1,n.length,-1]};for(;m.length;){t=m.shift();const x=t.oStart,y=x+t.oLength,E=t.abStart,v=E+t.abLength;let S=f[t.ab];S[0]=Math.min(E,S[0]),S[1]=Math.max(v,S[1]),S[2]=Math.min(x,S[2]),S[3]=Math.max(y,S[3])}const g=f.a[0]+(u-f.a[2]),C=f.a[1]+(d-f.a[3]),j=f.b[0]+(u-f.b[2]),h=f.b[1]+(d-f.b[3]);let w={stable:!1,aStart:g,aLength:C-g,aContent:e.slice(g,C),oStart:u,oLength:d-u,oContent:n.slice(u,d),bStart:j,bLength:h-j,bContent:o.slice(j,h)};a.push(w)}r=d}return c(n.length),a}function ae(e,n,o,i){i=Object.assign({excludeFalseConflicts:!0,stringSeparator:/\s+/},i),typeof e=="string"&&(e=e.split(i.stringSeparator)),typeof n=="string"&&(n=n.split(i.stringSeparator)),typeof o=="string"&&(o=o.split(i.stringSeparator));let a=[];const r=se(e,n,o);let c=[];function t(){c.length&&a.push({ok:c}),c=[]}function u(d,m){if(d.length!==m.length)return!1;for(let f=0;f<d.length;f++)if(d[f]!==m[f])return!1;return!0}return r.forEach(d=>{d.stable?c.push(...d.bufferContent):i.excludeFalseConflicts&&u(d.aContent,d.bContent)?c.push(...d.aContent):(t(),a.push({conflict:{a:d.aContent,aIndex:d.aStart,o:d.oContent,oIndex:d.oStart,b:d.bContent,bIndex:d.bStart}}))}),t(),a}const oe=/^<!--\s*mdocs-merge-conflict:([^\s]+)\s*-->$/;function re(e){return`<!-- mdocs-merge-conflict:${e} -->`}function ce(e){const n=e.trim().match(oe);return(n==null?void 0:n[1])??null}function N(e){return e===""?[]:e.split(`
|
|
2
|
+
`)}function K(e,n){return e.length===n.length&&e.every((o,i)=>o===n[i])}function de(e,n,o){const i=N(e),l=N(n),a=N(o);if(l.length===0&&n==="")return fe(e,o);const r=ae(i,l,a),c=[];let t=0,u=0,d=0,m=0;const f=(C,j,h,w)=>{c.push({kind:"conflict",id:`conflict-${t}`,conflictKind:w,baseLines:C,localLines:j,remoteLines:h,resolution:"unresolved"}),t+=1},g=(C,j,h)=>{if(j.length===0&&C.length===0&&h.length===0)return;if(K(C,j)&&K(h,j)){j.length>0&&c.push({kind:"unchanged",lines:[...j]});return}if(C.length===j.length&&h.length===j.length){let x=[];const y=()=>{x.length>0&&(c.push({kind:"unchanged",lines:x}),x=[])};for(let E=0;E<j.length;E+=1){const v=j[E],S=C[E],L=h[E];S===v&&L===v?x.push(v):(y(),f([v],[S],[L],S!==v&&L!==v&&S!==L?"true_conflict":"change"))}y();return}const w=C.join(`
|
|
3
|
+
`)!==j.join(`
|
|
4
|
+
`)&&h.join(`
|
|
5
|
+
`)!==j.join(`
|
|
6
|
+
`)&&C.join(`
|
|
7
|
+
`)!==h.join(`
|
|
8
|
+
`)?"true_conflict":"change";f(j,C,h,w)};for(let C=0;C<r.length;C+=1){const j=r[C],h=j.conflict;if(h){g(i.slice(u,h.aIndex),l.slice(d,h.oIndex),a.slice(m,h.bIndex)),f(h.o,h.a,h.b,"true_conflict"),u=h.aIndex+h.a.length,d=h.oIndex+h.o.length,m=h.bIndex+h.b.length;continue}if(j.ok){const w=r[C+1],x=w==null?void 0:w.conflict;x?(g(i.slice(u,x.aIndex),l.slice(d,x.oIndex),a.slice(m,x.bIndex)),u=x.aIndex,d=x.oIndex,m=x.bIndex):(g(i.slice(u),l.slice(d),a.slice(m)),u=i.length,d=l.length,m=a.length)}}return c}function ue(e,n){const o=e.length,i=n.length,l=Array.from({length:o+1},()=>new Array(i+1).fill(0));for(let t=1;t<=o;t+=1)for(let u=1;u<=i;u+=1)e[t-1]===n[u-1]?l[t][u]=l[t-1][u-1]+1:l[t][u]=Math.max(l[t-1][u],l[t][u-1]);const a=[];let r=o,c=i;for(;r>0||c>0;)r>0&&c>0&&e[r-1]===n[c-1]?(a.push({type:"equal",line:e[r-1]}),r-=1,c-=1):c>0&&(r===0||l[r][c-1]>=l[r-1][c])?(a.push({type:"add",line:n[c-1]}),c-=1):(a.push({type:"del",line:e[r-1]}),r-=1);return a.reverse()}function fe(e,n){const o=N(e),i=N(n),l=ue(o,i),a=[];let r=0,c=0;for(;c<l.length;){if(l[c].type==="equal"){const m=[];for(;c<l.length&&l[c].type==="equal";)m.push(l[c].line),c+=1;a.push({kind:"unchanged",lines:m});continue}const u=[],d=[];for(;c<l.length&&l[c].type!=="equal";){const m=l[c];m.type==="del"&&u.push(m.line),m.type==="add"&&d.push(m.line),c+=1}a.push({kind:"conflict",id:`conflict-${r}`,conflictKind:"true_conflict",baseLines:[],localLines:u,remoteLines:d,resolution:"unresolved"}),r+=1}return a}function me(e){return e.filter(n=>n.kind==="conflict").length}function he(e){return e.filter(n=>n.kind==="conflict"&&n.resolution==="unresolved").length}function ge(e){switch(e.resolution){case"local":return e.localLines;case"remote":return e.remoteLines;case"both":return[...e.localLines,...e.remoteLines];case"manual":return e.manualLines??[];default:return[]}}function xe(e){const n=[];for(const o of e)o.kind==="unchanged"?n.push(...o.lines):o.resolution==="unresolved"?n.push(re(o.id)):n.push(...ge(o));return n.join(`
|
|
9
|
+
`)}function q(e){return N(e).filter(n=>!ce(n)).join(`
|
|
10
|
+
`)}function F(e,n,o,i){return e.map(l=>l.kind!=="conflict"||l.id!==n?l:{...l,resolution:o,manualLines:o==="manual"?l.manualLines??[]:void 0})}const be={md:{treeVisible:!0,treeInclude:!0,movable:!0,ftsIndex:!0,graphExtract:!0,graphWalkStruct:!1,pathExt:".md",textExtract:"lexical",writeNormalize:"md-lexical",draftKind:"lexical",mergePipeline:"lexical-md-bridge",editor:"lobe"},html:{treeVisible:!0,treeInclude:!0,movable:!0,ftsIndex:!1,graphExtract:!1,graphWalkStruct:!1,pathExt:".html",textExtract:"raw",writeNormalize:"raw",draftKind:"html",mergePipeline:"raw-text",editor:"html"},dir:{treeVisible:!0,treeInclude:!0,movable:!1,ftsIndex:!1,graphExtract:!1,graphWalkStruct:!0,pathExt:null,textExtract:"none",writeNormalize:"none",draftKind:"none",mergePipeline:"none",editor:"none"},folder_desc:{treeVisible:!1,treeInclude:!0,movable:!1,ftsIndex:!1,graphExtract:!1,graphWalkStruct:!0,pathExt:".md",textExtract:"lexical",writeNormalize:"md-lexical",draftKind:"none",mergePipeline:"none",editor:"none"},graph_file:{treeVisible:!1,treeInclude:!1,movable:!1,ftsIndex:!1,graphExtract:!1,graphWalkStruct:!1,pathExt:".json",textExtract:"none",writeNormalize:"none",draftKind:"none",mergePipeline:"none",editor:"none"},graph_dir:{treeVisible:!1,treeInclude:!1,movable:!1,ftsIndex:!1,graphExtract:!1,graphWalkStruct:!1,pathExt:null,textExtract:"none",writeNormalize:"none",draftKind:"none",mergePipeline:"none",editor:"none"}};function Ce(e){return be[e]}function Le(e){var V;const{t:n}=H(),i=(((V=Ce(e.fileType??"md"))==null?void 0:V.mergePipeline)??"lexical-md-bridge")==="raw-text",[l,a]=b.useState(""),[r,c]=b.useState(""),[t,u]=b.useState(null),[d,m]=b.useState(!1),[f,g]=b.useState(!1),[C,j]=b.useState(null),[h,w]=b.useState(""),[x,y]=b.useState(null),[E,v]=b.useState(null),[S,L]=b.useState(!1),[P,M]=b.useState(!0);b.useEffect(()=>{let k=!1;return M(!0),j(null),w(""),y(null),v(null),(async()=>{try{const p=await z(e.documentId);if(k)return;i?(w(p.content),M(!1)):j(p.content)}catch{k||e.onError(n("mergeLoadRemoteFailed")),k||M(!1)}})(),()=>{k=!0}},[e.documentId,e.onError,n,i]),b.useEffect(()=>{let k=!1;return u(null),c(""),m(!1),g(!1),(async()=>{try{const p=await X(e.documentId,e.conflict.localBaseCommitId,e.conflict.remoteCommitId);if(k)return;if(p.mode==="three_way"&&p.mergeBaseContent){i?(c(p.mergeBaseContent),g(!0)):u(p.mergeBaseContent);return}m(!0),g(!0)}catch{if(k)return;m(!0),g(!0)}})(),()=>{k=!0}},[e.documentId,e.conflict.localBaseCommitId,e.conflict.remoteCommitId,i]),b.useEffect(()=>{i&&a(e.conflict.localSnapshotContent)},[i,e.conflict.localSnapshotContent]);const O=b.useCallback(k=>{w(k),M(!1)},[]),Y=b.useCallback(k=>{a(k)},[]),G=b.useCallback(k=>{c(k),g(!0)},[]),J=b.useCallback(()=>{m(!0),c(""),g(!0)},[]);b.useEffect(()=>{!l||!h||P||!f||(y(de(l,r,h)),v(null))},[l,h,r,f,P,e.conflict.remoteCommitId]);const A=b.useMemo(()=>x?q(xe(x)):"",[x]),T=x?me(x):0,I=x?he(x):0,_=E??A;b.useEffect(()=>{I===0&&x&&E===null&&v(A)},[I,x,A,E]);function $(k){y(p=>{if(!p)return p;let R=p;for(const W of p)W.kind==="conflict"&&(R=F(R,W.id,k));return R}),v(null)}async function Q(){if(I>0){e.onError(n("mergeConflictsUnresolved",{count:String(I)}));return}const k=q(_);L(!0);try{const p=i?k:(await Z({content:k,from:"markdown",to:"lexical"})).content;await ee(e.documentId,{content:p,displayName:e.displayName,version:{localBaseCommitId:e.conflict.localBaseCommitId,merge:{remoteCommitId:e.conflict.remoteCommitId,localSnapshotContent:e.conflict.localSnapshotContent}}});const R=await z(e.documentId);e.onSuccess(R)}catch(p){e.onError(p instanceof Error?p.message:String(p))}finally{L(!1)}}const B=!!(l&&h&&x&&!P&&f);return s.jsxs("div",{className:"mdocs-merge-overlay",children:[i?null:s.jsxs(s.Fragment,{children:[s.jsx(U,{lexicalJson:e.conflict.localSnapshotContent,onMarkdown:Y,onError:()=>e.onError(n("mergeLoadLocalFailed"))}),t?s.jsx(U,{lexicalJson:t,onMarkdown:G,onError:J}):null,C?s.jsx(U,{lexicalJson:C,onMarkdown:O,onError:()=>{M(!1),e.onError(n("mergeLoadRemoteFailed"))}}):null]}),s.jsxs("header",{className:"mdocs-merge-toolbar",children:[s.jsxs("div",{className:"mdocs-merge-toolbar-title",children:[s.jsx("h2",{children:n("mergeTitle")}),B&&T>0?s.jsx("span",{className:`mdocs-merge-conflict-pill ${I>0?"pending":"resolved"}`,children:I>0?n("mergeConflictsPending",{unresolved:String(I),total:String(T)}):n("mergeConflictsResolved",{total:String(T)})}):null,d?s.jsx("span",{className:"mdocs-merge-base-warning",children:n("mergeBaseMissing")}):null]}),s.jsxs("div",{className:"mdocs-merge-toolbar-actions",children:[s.jsx("button",{type:"button",className:"secondary",disabled:S,onClick:e.onClose,children:n("cancel")}),s.jsx("button",{type:"button",className:"primary",disabled:S||!B||I>0,onClick:()=>void Q(),children:n(S?"publishing":"mergeComplete")})]})]}),s.jsx("div",{className:"mdocs-merge-body mdocs-merge-body--inline",children:B?s.jsx(le,{segments:x,unresolvedCount:I,onReceive:k=>{y(p=>p&&F(p,k,"remote")),v(null)},onReject:k=>{y(p=>p&&F(p,k,"local")),v(null)},onUseAllMine:()=>$("local"),onUseAllTheirs:()=>$("remote"),editableMarkdown:_,onEditableChange:v}):s.jsx("p",{className:"mdocs-merge-loading",children:n("mergeLoadingRemote")})})]})}export{Le as MergeView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as n,j as o,ad as C}from"./react-vendor-BuABiQkA.js";import{u as N,E as T,R as I,a as E,b as M,c as j,d as O,e as P,f as A,g as _,h as D,i as L,w as f,j as H,k as F,l as q,I as U,m as b,n as V,o as J,p as W,q as z,r as B,s as $,t as K,v as Y,x as G,y as Z}from"./react-
|
|
1
|
+
import{r as n,j as o,ad as C}from"./react-vendor-BuABiQkA.js";import{u as N,E as T,R as I,a as E,b as M,c as j,d as O,e as P,f as A,g as _,h as D,i as L,w as f,j as H,k as F,l as q,I as U,m as b,n as V,o as J,p as W,q as z,r as B,s as $,t as K,v as Y,x as G,y as Z}from"./react-BJcufYxR.js";import{a7 as Q,a8 as X,a9 as ee,aa as te,ab as k,ac as oe}from"./ui-CvA4pq3d.js";import{H as re,a as ae,b as ne,M as le,T as ie,S as se,W as de,c as R,o as ce}from"./Toolbar-JoV5KtuT.js";import{N as me}from"./index-CwzlBu2W.js";import"./editor-CL03se2B.js";import"./diagram-Bk84WZto.js";import"./plus-B0mmDuSt.js";import"./copy-yWKSE1g1.js";import"./motion-DFABYlwt.js";import"./code-xml-DX89c1sd.js";const ue=({children:h,json:r,markdown:a,collapsible:m=!1,defaultActiveKey:y=["editor","text","json"],onJSONChange:p})=>{const[g,c]=n.useState(r),s=n.useRef(r);n.useEffect(()=>{r!==s.current&&(c(r),s.current=r)},[r]);const x=n.useCallback(d=>{s.current=d,c(d)},[]);return o.jsxs(o.Fragment,{children:[o.jsx(Q,{}),o.jsx(X,{collapsible:m,defaultActiveKey:y,items:[{children:h,key:"editor",label:"Playground"},{children:o.jsx(ee,{language:"markdown",style:{fontSize:12,padding:16},variant:"borderless",children:a}),key:"text",label:"Text Output"},{children:o.jsx(te,{language:"json",onBlur:()=>{if(r!==s.current)try{const d=JSON.parse(s.current||"");p==null||p(d)}catch(d){console.error("Invalid JSON:",d)}},onValueChange:x,value:g,variant:"borderless"}),key:"json",label:"JSON Output"}],padding:{body:0},style:{border:"none",borderRadius:0,width:"100%"},variant:"outlined"})]})},he={children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"Welcome to the Lobe Editor Demo!",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"heading",version:1,tag:"h1"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"In case you were wondering what the black box at the bottom is – it's the debug view, showing the current state of the editor. You can disable it by pressing on the settings control in the bottom-left of your screen and toggling the debug view setting.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"quote",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"The playground is a demo environment built with ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:"@lobehub/editor",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"codeInline",version:1},{detail:0,format:0,mode:"normal",style:"",text:"\uFEFF",type:"cursor",version:1},{detail:0,format:0,mode:"normal",style:"",text:". Try typing in ",type:"text",version:1},{detail:0,format:1,mode:"normal",style:"",text:"some text",type:"text",version:1},{detail:0,format:0,mode:"normal",style:"",text:" with ",type:"text",version:1},{detail:0,format:2,mode:"normal",style:"",text:"different formats",type:"text",version:1},{detail:0,format:0,mode:"normal",style:"",text:".",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:""},{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"Visit the ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Lobe Editor website",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:"noreferrer",target:null,title:null,url:"https://editor.lobehub.com"},{detail:0,format:0,mode:"normal",style:"",text:" for documentation and more information.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Check out the code on our ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"GitHub repository",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:null,target:null,title:"https://github.com/lobehub/lobe-editor",url:"https://github.com/lobehub/lobe-editor"},{detail:0,format:0,mode:"normal",style:"",text:".",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:2},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Playground code ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Playground code",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:"noreferrer",target:null,title:null,url:"https://github.com/lobehub/lobe-editor/blob/master/src/react/Editor/demos/index.tsx"},{detail:0,format:0,mode:"normal",style:"",text:" can be found here.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:3},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Join our ",type:"text",version:1},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Discover Server",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"link",version:1,rel:null,target:null,title:"https://discord.gg/AYFPHvv2jT",url:"https://discord.gg/AYFPHvv2jT"},{detail:0,format:0,mode:"normal",style:"",text:" and chat with the team.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"listitem",version:1,value:4}],direction:"ltr",format:"",indent:0,type:"list",version:1,listType:"bullet",start:1,tag:"ul"},{children:[{detail:0,format:0,mode:"normal",style:"",text:"Lastly, we're constantly adding cool new features to this playground. So make sure you check back here when you next get a chance 🙂.",type:"text",version:1}],direction:"ltr",format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:""},{children:[{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"import",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"{",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-error);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:"Editor",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-error);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"}",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"from",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-text);",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"'",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-success);",text:"@lobehub/editor",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:"'",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"color: var(--ant-color-info);",text:";",type:"code-highlight",version:1}],direction:null,format:"",indent:0,type:"code",version:1,language:"typescript",theme:"lobe-theme"},{children:[],direction:null,format:"",indent:0,type:"paragraph",version:1,textFormat:0,textStyle:""}],direction:"ltr",format:"",indent:0,type:"root",version:1},ye={root:he};function S(h,r){let a;const m=(...y)=>{a!==void 0&&clearTimeout(a),a=setTimeout(()=>h(...y),r)};return m.cancel=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},m}window.__scrollIntoView=Z;const pe=h=>{const r=N(),a=n.useRef([]),[m,y]=n.useState(""),[p,g]=n.useState(""),c=n.useMemo(()=>S(t=>{const e=t.getDocument("markdown"),l=t.getDocument("json");g(e||""),y(JSON.stringify(l||{},null,2))},200),[]),s=n.useMemo(()=>S(t=>{r&&(console.info("handleJSONChange",t),r.setDocument("json",t))},200),[r]),x=t=>{window.editor=t,c(t)};n.useEffect(()=>()=>{for(const t of a.current)URL.revokeObjectURL(t);a.current=[],c.cancel(),s.cancel(),delete window.editor,delete window.__scrollIntoView},[c,s]);const d=n.useMemo(()=>[{icon:o.jsx(k,{avatar:"💻",size:24}),key:"bot1",label:"前端研发专家",metadata:{id:"bot1"}},{icon:o.jsx(k,{avatar:"🌍",size:24}),key:"bot2",label:"中英文互译助手",metadata:{id:"bot2"}},{icon:o.jsx(k,{avatar:"📖",size:24}),key:"bot3",label:"学术写作增强专家",metadata:{id:"bot3"}}],[]),w=n.useMemo(()=>[{icon:re,key:"h1",label:"Heading 1",onSelect:e=>{e.dispatchCommand(b,{tag:"h1"})}},{icon:ae,key:"h2",label:"Heading 2",onSelect:e=>{e.dispatchCommand(b,{tag:"h2"})}},{icon:ne,key:"h3",label:"Heading 3",onSelect:e=>{e.dispatchCommand(b,{tag:"h3"})}},{type:"divider"},{icon:le,key:"hr",label:"Hr",onSelect:e=>{e.dispatchCommand(V,{})}},{icon:ie,key:"table",label:"Table",onSelect:e=>{e.dispatchCommand(J,{columns:"3",rows:"3"})}},{icon:se,key:"tex",label:"Tex",onSelect:e=>{e.dispatchCommand(W,{code:"x^2 + y^2 = z^2"}),queueMicrotask(()=>{e.focus()})}},{type:"divider"},{key:"file",label:"File",onSelect:e=>{ce(l=>{for(const u of l)e.dispatchCommand(z,{file:u})})}},{key:"set-text-content",label:"SetTextContent",onSelect:e=>{e.setDocument("text",`123
|
|
2
2
|
123`),queueMicrotask(()=>{e.focus()})}},{key:"insert-link",label:"InsertLink",onSelect:e=>{e.dispatchCommand(B,{url:"https://example.com"}),queueMicrotask(()=>{e.focus()})}},{key:"insert-codeInline",label:"InsertCodeInline",onSelect:e=>{e.dispatchCommand($,void 0),queueMicrotask(()=>{e.focus()})}},{key:"insert-codeBlock",label:"InsertCodeBlock",onSelect:e=>{e.dispatchCommand(K,void 0),queueMicrotask(()=>{e.focus()})}},{icon:de,key:"meta2d",label:"Meta2d",onSelect:e=>{e.dispatchCommand(Y,void 0),queueMicrotask(()=>{e.focus()})}},{icon:me,key:"markmap",label:"Markmap",onSelect:e=>{e.dispatchCommand(G,void 0),queueMicrotask(()=>{e.focus()})}}].map(e=>e.type==="divider"?e:{...e,extra:o.jsx(oe,{code:!0,fontSize:12,type:"secondary",children:e.key})}),[]);return o.jsxs(ue,{json:m,markdown:p,onJSONChange:s,...h,children:[o.jsx(R,{editor:r}),o.jsx(T,{className:"mdocs-playground-editor",content:ye,editor:r,lineEmptyPlaceholder:"Start typing here...",mentionOption:{items:d,markdownWriter:t=>{var e;return`
|
|
3
3
|
<mention>${t.label}[${((e=t.metadata)==null?void 0:e.id)||t.label}]</mention>
|
|
4
4
|
`},onSelect:(t,e)=>{t.dispatchCommand(U,{label:String(e.label),metadata:{id:e.key}})},searchKeys:["label"]},onInit:x,onTextChange:c,pasteVSCodeAsCodeBlock:!0,placeholder:"Type something...",plugins:[I,E,M,j,O,P,A,_,D,L,f(H,{children:o.jsx(R,{editor:r,floating:!0})}),f(F,{delay:1e3,onAutoComplete:async({input:t,afterText:e,selectionType:l,abortSignal:u})=>{console.log("Auto-complete triggered:",{afterText:e,input:t,selectionType:l});try{const v=await fetch(`${location.origin}/nodeserver/completion`,{body:JSON.stringify({prompt:`Please complete the following text:
|