@logicflow/core 2.2.1 → 2.2.3

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.
Files changed (127) hide show
  1. package/README.md +32 -0
  2. package/dist/docs/api/logicflow-constructor/index.en.md +106 -0
  3. package/dist/docs/api/logicflow-constructor/index.zh.md +106 -0
  4. package/dist/docs/api/logicflow-constructor/use.en.md +61 -0
  5. package/dist/docs/api/logicflow-constructor/use.zh.md +61 -0
  6. package/dist/docs/api/logicflow-instance/canvas.en.md +197 -0
  7. package/dist/docs/api/logicflow-instance/canvas.zh.md +199 -0
  8. package/dist/docs/api/logicflow-instance/edge.en.md +273 -0
  9. package/dist/docs/api/logicflow-instance/edge.zh.md +273 -0
  10. package/dist/docs/api/logicflow-instance/edit-config.en.md +59 -0
  11. package/dist/docs/api/logicflow-instance/edit-config.zh.md +59 -0
  12. package/dist/docs/api/logicflow-instance/element.en.md +375 -0
  13. package/dist/docs/api/logicflow-instance/element.zh.md +379 -0
  14. package/dist/docs/api/logicflow-instance/event.en.md +326 -0
  15. package/dist/docs/api/logicflow-instance/event.zh.md +406 -0
  16. package/dist/docs/api/logicflow-instance/history.en.md +38 -0
  17. package/dist/docs/api/logicflow-instance/history.zh.md +38 -0
  18. package/dist/docs/api/logicflow-instance/index.en.md +41 -0
  19. package/dist/docs/api/logicflow-instance/index.zh.md +41 -0
  20. package/dist/docs/api/logicflow-instance/node.en.md +308 -0
  21. package/dist/docs/api/logicflow-instance/node.zh.md +308 -0
  22. package/dist/docs/api/logicflow-instance/register.en.md +76 -0
  23. package/dist/docs/api/logicflow-instance/register.zh.md +76 -0
  24. package/dist/docs/api/logicflow-instance/render-and-data.en.md +179 -0
  25. package/dist/docs/api/logicflow-instance/render-and-data.zh.md +181 -0
  26. package/dist/docs/api/logicflow-instance/text.en.md +60 -0
  27. package/dist/docs/api/logicflow-instance/text.zh.md +60 -0
  28. package/dist/docs/api/logicflow-instance/theme.en.md +179 -0
  29. package/dist/docs/api/logicflow-instance/theme.zh.md +179 -0
  30. package/dist/docs/api/runtime-model/edgeModel.en.md +29 -0
  31. package/dist/docs/api/runtime-model/edgeModel.zh.md +325 -0
  32. package/dist/docs/api/runtime-model/graphModel.en.md +275 -0
  33. package/dist/docs/api/runtime-model/graphModel.zh.md +1153 -0
  34. package/dist/docs/api/runtime-model/nodeModel.en.md +37 -0
  35. package/dist/docs/api/runtime-model/nodeModel.zh.md +644 -0
  36. package/dist/docs/api/type/MainTypes.en.md +598 -0
  37. package/dist/docs/api/type/MainTypes.zh.md +867 -0
  38. package/dist/docs/api/type/Theme.en.md +187 -0
  39. package/dist/docs/api/type/Theme.zh.md +187 -0
  40. package/dist/docs/api/type/canvas-types.en.md +25 -0
  41. package/dist/docs/api/type/canvas-types.zh.md +25 -0
  42. package/dist/docs/api/type/index.en.md +96 -0
  43. package/dist/docs/api/type/index.zh.md +99 -0
  44. package/dist/docs/api/type/node-types.en.md +21 -0
  45. package/dist/docs/api/type/node-types.zh.md +21 -0
  46. package/dist/docs/api/type/plugin-types.en.md +24 -0
  47. package/dist/docs/api/type/plugin-types.zh.md +24 -0
  48. package/dist/docs/index.md +11 -0
  49. package/dist/docs/tutorial/about.en.md +38 -0
  50. package/dist/docs/tutorial/about.zh.md +65 -0
  51. package/dist/docs/tutorial/advanced/dnd.en.md +62 -0
  52. package/dist/docs/tutorial/advanced/dnd.zh.md +52 -0
  53. package/dist/docs/tutorial/advanced/edge.en.md +64 -0
  54. package/dist/docs/tutorial/advanced/edge.zh.md +66 -0
  55. package/dist/docs/tutorial/advanced/keyboard.en.md +70 -0
  56. package/dist/docs/tutorial/advanced/keyboard.zh.md +67 -0
  57. package/dist/docs/tutorial/advanced/node.en.md +338 -0
  58. package/dist/docs/tutorial/advanced/node.zh.md +338 -0
  59. package/dist/docs/tutorial/advanced/react.en.md +106 -0
  60. package/dist/docs/tutorial/advanced/react.zh.md +114 -0
  61. package/dist/docs/tutorial/advanced/silent-mode.en.md +75 -0
  62. package/dist/docs/tutorial/advanced/silent-mode.zh.md +71 -0
  63. package/dist/docs/tutorial/advanced/snapline.en.md +54 -0
  64. package/dist/docs/tutorial/advanced/vue.en.md +249 -0
  65. package/dist/docs/tutorial/advanced/vue.zh.md +248 -0
  66. package/dist/docs/tutorial/ai.en.md +64 -0
  67. package/dist/docs/tutorial/ai.zh.md +64 -0
  68. package/dist/docs/tutorial/basic/background.en.md +50 -0
  69. package/dist/docs/tutorial/basic/canvas.en.md +164 -0
  70. package/dist/docs/tutorial/basic/canvas.zh.md +183 -0
  71. package/dist/docs/tutorial/basic/class.en.md +106 -0
  72. package/dist/docs/tutorial/basic/class.zh.md +103 -0
  73. package/dist/docs/tutorial/basic/edge.en.md +151 -0
  74. package/dist/docs/tutorial/basic/edge.zh.md +152 -0
  75. package/dist/docs/tutorial/basic/event.en.md +70 -0
  76. package/dist/docs/tutorial/basic/event.zh.md +66 -0
  77. package/dist/docs/tutorial/basic/grid.en.md +77 -0
  78. package/dist/docs/tutorial/basic/node.en.md +358 -0
  79. package/dist/docs/tutorial/basic/node.zh.md +318 -0
  80. package/dist/docs/tutorial/basic/theme.en.md +154 -0
  81. package/dist/docs/tutorial/basic/theme.zh.md +157 -0
  82. package/dist/docs/tutorial/extension/adapter.en.md +446 -0
  83. package/dist/docs/tutorial/extension/adapter.zh.md +429 -0
  84. package/dist/docs/tutorial/extension/bpmn-element.en.md +1427 -0
  85. package/dist/docs/tutorial/extension/bpmn-element.zh.md +1472 -0
  86. package/dist/docs/tutorial/extension/control.en.md +117 -0
  87. package/dist/docs/tutorial/extension/control.zh.md +118 -0
  88. package/dist/docs/tutorial/extension/curved-edge.en.md +46 -0
  89. package/dist/docs/tutorial/extension/curved-edge.zh.md +46 -0
  90. package/dist/docs/tutorial/extension/custom.en.md +142 -0
  91. package/dist/docs/tutorial/extension/custom.zh.md +138 -0
  92. package/dist/docs/tutorial/extension/dnd-panel.en.md +109 -0
  93. package/dist/docs/tutorial/extension/dnd-panel.zh.md +109 -0
  94. package/dist/docs/tutorial/extension/dynamic-group.en.md +606 -0
  95. package/dist/docs/tutorial/extension/dynamic-group.zh.md +606 -0
  96. package/dist/docs/tutorial/extension/group.en.md +217 -0
  97. package/dist/docs/tutorial/extension/group.zh.md +209 -0
  98. package/dist/docs/tutorial/extension/highlight.en.md +50 -0
  99. package/dist/docs/tutorial/extension/highlight.zh.md +50 -0
  100. package/dist/docs/tutorial/extension/insert-node-in-polyline.en.md +52 -0
  101. package/dist/docs/tutorial/extension/insert-node-in-polyline.zh.md +47 -0
  102. package/dist/docs/tutorial/extension/intro.en.md +72 -0
  103. package/dist/docs/tutorial/extension/intro.zh.md +95 -0
  104. package/dist/docs/tutorial/extension/label.en.md +136 -0
  105. package/dist/docs/tutorial/extension/label.zh.md +135 -0
  106. package/dist/docs/tutorial/extension/layout.en.md +156 -0
  107. package/dist/docs/tutorial/extension/layout.zh.md +156 -0
  108. package/dist/docs/tutorial/extension/menu.en.md +319 -0
  109. package/dist/docs/tutorial/extension/menu.zh.md +377 -0
  110. package/dist/docs/tutorial/extension/minimap.en.md +164 -0
  111. package/dist/docs/tutorial/extension/minimap.zh.md +180 -0
  112. package/dist/docs/tutorial/extension/node-resize.en.md +199 -0
  113. package/dist/docs/tutorial/extension/node-resize.zh.md +221 -0
  114. package/dist/docs/tutorial/extension/pool.en.md +227 -0
  115. package/dist/docs/tutorial/extension/pool.zh.md +227 -0
  116. package/dist/docs/tutorial/extension/proximity-connect.en.md +104 -0
  117. package/dist/docs/tutorial/extension/proximity-connect.zh.md +107 -0
  118. package/dist/docs/tutorial/extension/selection.en.md +166 -0
  119. package/dist/docs/tutorial/extension/selection.zh.md +150 -0
  120. package/dist/docs/tutorial/extension/snapshot.en.md +276 -0
  121. package/dist/docs/tutorial/extension/snapshot.zh.md +276 -0
  122. package/dist/docs/tutorial/get-started.en.md +501 -0
  123. package/dist/docs/tutorial/get-started.zh.md +139 -0
  124. package/dist/docs/tutorial/update.en.md +213 -0
  125. package/dist/docs/tutorial/update.zh.md +212 -0
  126. package/package.json +5 -3
  127. package/scripts/postinstall-ai-prompt.js +67 -0
@@ -0,0 +1,76 @@
1
+ ---
2
+ nav: API
3
+ group:
4
+ title: LogicFlow 实例
5
+ order: 2
6
+ title: 注册
7
+ toc: content
8
+ order: 10
9
+ ---
10
+
11
+ 本页汇总 LogicFlow 实例中与自定义节点/边注册相关的方法。
12
+
13
+ ### register
14
+
15
+ 注册单个自定义节点或边。
16
+
17
+ **签名**
18
+
19
+ ```ts
20
+ register(config: RegisterConfig): void
21
+ ```
22
+
23
+ 参数类型见 [`RegisterConfig`](../type/MainTypes.zh.md#registerconfig注册配置)。
24
+
25
+ **示例**
26
+
27
+ ```ts
28
+ import { RectNode, RectNodeModel } from '@logicflow/core';
29
+
30
+ class CustomRectNode extends RectNode {}
31
+
32
+ class CustomRectModel extends RectNodeModel {
33
+ setAttributes() {
34
+ this.width = 200;
35
+ this.height = 80;
36
+ this.radius = 50;
37
+ }
38
+ }
39
+
40
+ lf.register({
41
+ type: 'custom-rect',
42
+ view: CustomRectNode,
43
+ model: CustomRectModel,
44
+ });
45
+ ```
46
+
47
+ ### batchRegister
48
+
49
+ 批量注册多个自定义节点或边。
50
+
51
+ **签名**
52
+
53
+ ```ts
54
+ batchRegister(configList: RegisterConfig[]): void
55
+ ```
56
+
57
+ 参数类型见 [`RegisterConfig`](../type/MainTypes.zh.md#registerconfig注册配置)。
58
+
59
+ **示例**
60
+
61
+ ```ts
62
+ lf.batchRegister([
63
+ {
64
+ type: 'user',
65
+ view: UserNode,
66
+ model: UserModel,
67
+ },
68
+ {
69
+ type: 'user1',
70
+ view: UserNode1,
71
+ model: UserModel1,
72
+ },
73
+ ]);
74
+ ```
75
+
76
+ 插件全局注册见 [LogicFlow.use](../logicflow-constructor/use.zh.md)。
@@ -0,0 +1,179 @@
1
+ ---
2
+ nav: API
3
+ group:
4
+ title: LogicFlow Instance
5
+ order: 2
6
+ title: Rendering and data
7
+ toc: content
8
+ order: 1
9
+ ---
10
+
11
+ This page covers rendering entry points, reading and writing graph data, and adapter hooks on the LogicFlow instance.
12
+
13
+ ### render
14
+
15
+ Render graph data. When `adapterIn` is configured, incoming data is converted to LogicFlow’s internal shape first.
16
+
17
+ **Signature**
18
+
19
+ ```ts
20
+ render(graphData: unknown): void
21
+ ```
22
+
23
+ **Parameters**
24
+
25
+ | Name | Type | Required | Description |
26
+ | :--- | :--- | :--- | :--- |
27
+ | `graphData` | `unknown` | Yes | Graph payload; shape depends on `adapterIn`. |
28
+
29
+ **Example**
30
+
31
+ ```ts
32
+ lf.render({
33
+ nodes: [{ id: 'node_1', type: 'rect', x: 120, y: 100 }],
34
+ edges: [],
35
+ });
36
+ ```
37
+
38
+ ### renderRawData
39
+
40
+ Render native LogicFlow graph data without running `adapterIn`.
41
+
42
+ **Signature**
43
+
44
+ ```ts
45
+ renderRawData(graphData: GraphData): void
46
+ ```
47
+
48
+ **Parameters**
49
+
50
+ | Name | Type | Required | Description |
51
+ | :--- | :--- | :--- | :--- |
52
+ | `graphData` | [`GraphData`](../type/MainTypes.en.md#graphdata) | Yes | Native LogicFlow graph data. |
53
+
54
+ **Example**
55
+
56
+ ```ts
57
+ lf.renderRawData({
58
+ nodes: [{ id: 'node_1', type: 'rect', x: 120, y: 100 }],
59
+ edges: [],
60
+ });
61
+ ```
62
+
63
+ ### getGraphData
64
+
65
+ Return the current graph. When `adapterOut` is set, the result is passed through that adapter.
66
+
67
+ **Signature**
68
+
69
+ ```ts
70
+ getGraphData(...params: any[]): GraphConfigData | unknown
71
+ ```
72
+
73
+ **Parameters**
74
+
75
+ | Name | Type | Required | Description |
76
+ | :--- | :--- | :--- | :--- |
77
+ | `...params` | `any[]` | No | Extra arguments forwarded to `adapterOut`. |
78
+
79
+ **Returns**
80
+
81
+ - Without `adapterOut`: [`GraphConfigData`](../type/MainTypes.en.md#graphconfigdata).
82
+ - With `adapterOut`: your business shape (`unknown`).
83
+
84
+ **Example**
85
+
86
+ ```ts
87
+ const data = lf.getGraphData(['property1', 'property2']);
88
+ ```
89
+
90
+ ### getGraphRawData
91
+
92
+ Return native LogicFlow data, ignoring `adapterOut`.
93
+
94
+ **Signature**
95
+
96
+ ```ts
97
+ getGraphRawData(): GraphData
98
+ ```
99
+
100
+ **Returns**
101
+
102
+ - [`GraphData`](../type/MainTypes.en.md#graphdata)
103
+
104
+ **Example**
105
+
106
+ ```ts
107
+ const rawData = lf.getGraphRawData();
108
+ console.log(rawData.nodes, rawData.edges);
109
+ ```
110
+
111
+ ### clearData
112
+
113
+ Remove every node and edge from the canvas.
114
+
115
+ **Signature**
116
+
117
+ ```ts
118
+ clearData(): void
119
+ ```
120
+
121
+ **Example**
122
+
123
+ ```ts
124
+ lf.clearData();
125
+ ```
126
+
127
+ ### adapterIn
128
+
129
+ Optional inbound adapter: convert business data to LogicFlow graph data before `render`.
130
+
131
+ **Signature**
132
+
133
+ ```ts
134
+ adapterIn?: (data: unknown) => GraphData
135
+ ```
136
+
137
+ **Returns**
138
+
139
+ - [`GraphData`](../type/MainTypes.en.md#graphdata)
140
+
141
+ **Example**
142
+
143
+ ```ts
144
+ lf.adapterIn = (bizData) => {
145
+ return {
146
+ nodes: [],
147
+ edges: [],
148
+ };
149
+ };
150
+ ```
151
+
152
+ ### adapterOut
153
+
154
+ Optional outbound adapter: convert LogicFlow graph data when `getGraphData` runs.
155
+
156
+ **Signature**
157
+
158
+ ```ts
159
+ adapterOut?: (data: GraphConfigData, ...params: any[]) => unknown
160
+ ```
161
+
162
+ **Parameters**
163
+
164
+ | Name | Type | Required | Description |
165
+ | :--- | :--- | :--- | :--- |
166
+ | `data` | [`GraphConfigData`](../type/MainTypes.en.md#graphconfigdata) | Yes | Current graph data. |
167
+ | `...params` | `any[]` | No | Same extras passed to `getGraphData`. |
168
+
169
+ **Example**
170
+
171
+ ```ts
172
+ lf.adapterOut = (data, reserveFields = []) => {
173
+ return {
174
+ processNodes: data.nodes,
175
+ processEdges: data.edges,
176
+ reserveFields,
177
+ };
178
+ };
179
+ ```
@@ -0,0 +1,181 @@
1
+ ---
2
+ nav: API
3
+ group:
4
+ title: LogicFlow 实例
5
+ order: 2
6
+ title: 渲染与数据
7
+ toc: content
8
+ order: 1
9
+ ---
10
+
11
+ 本页聚焦 LogicFlow 实例的渲染入口、图数据读写与数据适配器接口。
12
+
13
+ ### render
14
+
15
+ 渲染图数据;当配置了 `adapterIn` 时,会先转换为 LogicFlow 标准数据再渲染。
16
+
17
+ **签名**
18
+
19
+ ```ts
20
+ render(graphData: unknown): void
21
+ ```
22
+
23
+ **参数**
24
+
25
+ | 名称 | 类型 | 必传 | 说明 |
26
+ | :--- | :--- | :--- | :--- |
27
+ | `graphData` | `unknown` | 是 | 图数据,格式取决于是否配置了 `adapterIn`。 |
28
+
29
+ **示例**
30
+
31
+ ```ts
32
+ // 直接渲染 LogicFlow 标准格式
33
+ lf.render({
34
+ nodes: [{ id: 'node_1', type: 'rect', x: 120, y: 100 }],
35
+ edges: [],
36
+ });
37
+ ```
38
+
39
+ ### renderRawData
40
+
41
+ 渲染 LogicFlow 原生图数据,不经过 `adapterIn` 转换。
42
+
43
+ **签名**
44
+
45
+ ```ts
46
+ renderRawData(graphData: GraphData): void
47
+ ```
48
+
49
+ **参数**
50
+
51
+ | 名称 | 类型 | 必传 | 说明 |
52
+ | :--- | :--- | :--- | :--- |
53
+ | `graphData` | [`GraphData`](../type/MainTypes.zh.md#graphdata画布数据) | 是 | LogicFlow 原生图数据。 |
54
+
55
+ **示例**
56
+
57
+ ```ts
58
+ lf.renderRawData({
59
+ nodes: [{ id: 'node_1', type: 'rect', x: 120, y: 100 }],
60
+ edges: [],
61
+ });
62
+ ```
63
+
64
+ ### getGraphData
65
+
66
+ 获取当前图数据;当配置了 `adapterOut` 时,返回值会先经过适配器转换。
67
+
68
+ **签名**
69
+
70
+ ```ts
71
+ getGraphData(...params: any[]): GraphConfigData | unknown
72
+ ```
73
+
74
+ **参数**
75
+
76
+ | 名称 | 类型 | 必传 | 说明 |
77
+ | :--- | :--- | :--- | :--- |
78
+ | `...params` | `any[]` | 否 | 透传给 `adapterOut` 的额外参数。 |
79
+
80
+ **返回值**
81
+
82
+ - 未配置 `adapterOut`:返回 [`GraphConfigData`](../type/MainTypes.zh.md#graphconfigdata流程图渲染数据类型)。
83
+ - 已配置 `adapterOut`:返回适配后的业务数据(`unknown`)。
84
+
85
+ **示例**
86
+
87
+ ```ts
88
+ const data = lf.getGraphData(['property1', 'property2']);
89
+ ```
90
+
91
+ ### getGraphRawData
92
+
93
+ 获取当前图的 LogicFlow 原生数据,不受 `adapterOut` 影响。
94
+
95
+ **签名**
96
+
97
+ ```ts
98
+ getGraphRawData(): GraphData
99
+ ```
100
+
101
+ **返回值**
102
+
103
+ - [`GraphData`](../type/MainTypes.zh.md#graphdata画布数据)
104
+
105
+ **示例**
106
+
107
+ ```ts
108
+ const rawData = lf.getGraphRawData();
109
+ console.log(rawData.nodes, rawData.edges);
110
+ ```
111
+
112
+ ### clearData
113
+
114
+ 清空当前画布中的全部节点和边数据。
115
+
116
+ **签名**
117
+
118
+ ```ts
119
+ clearData(): void
120
+ ```
121
+
122
+ **示例**
123
+
124
+ ```ts
125
+ lf.clearData();
126
+ ```
127
+
128
+ ### adapterIn
129
+
130
+ 自定义输入数据适配函数,用于在 `render` 前把业务数据转换为 LogicFlow 原生数据。
131
+
132
+ **签名**
133
+
134
+ ```ts
135
+ adapterIn?: (data: unknown) => GraphData
136
+ ```
137
+
138
+ **返回值**
139
+
140
+ - [`GraphData`](../type/MainTypes.zh.md#graphdata画布数据)
141
+
142
+ **示例**
143
+
144
+ ```ts
145
+ lf.adapterIn = (bizData) => {
146
+ // 将业务结构转换成 nodes / edges
147
+ return {
148
+ nodes: [],
149
+ edges: [],
150
+ };
151
+ };
152
+ ```
153
+
154
+ ### adapterOut
155
+
156
+ 自定义输出数据适配函数,用于在 `getGraphData` 时把 LogicFlow 原生数据转换为业务数据。
157
+
158
+ **签名**
159
+
160
+ ```ts
161
+ adapterOut?: (data: GraphConfigData, ...params: any[]) => unknown
162
+ ```
163
+
164
+ **参数**
165
+
166
+ | 名称 | 类型 | 必传 | 说明 |
167
+ | :--- | :--- | :--- | :--- |
168
+ | `data` | [`GraphConfigData`](../type/MainTypes.zh.md#graphconfigdata流程图渲染数据类型) | 是 | 当前图数据。 |
169
+ | `...params` | `any[]` | 否 | 来自 `getGraphData(...params)` 的透传参数。 |
170
+
171
+ **示例**
172
+
173
+ ```ts
174
+ lf.adapterOut = (data, reserveFields = []) => {
175
+ return {
176
+ processNodes: data.nodes,
177
+ processEdges: data.edges,
178
+ reserveFields,
179
+ };
180
+ };
181
+ ```
@@ -0,0 +1,60 @@
1
+ ---
2
+ nav: API
3
+ group:
4
+ title: LogicFlow Instance
5
+ order: 2
6
+ title: Text editing
7
+ toc: content
8
+ order: 5
9
+ ---
10
+
11
+ This page documents instance APIs related to node and edge text editing.
12
+
13
+ ### editText
14
+
15
+ Open the text editor for a node or edge.
16
+
17
+ **Signature**
18
+
19
+ ```ts
20
+ editText(id: string): void
21
+ ```
22
+
23
+ **Parameters**
24
+
25
+ | Name | Type | Required | Description |
26
+ | :--- | :--- | :--- | :--- |
27
+ | `id` | `string` | Yes | Node or edge id. |
28
+
29
+ **Example**
30
+
31
+ ```ts
32
+ lf.editText('node_1');
33
+ ```
34
+
35
+ :::info{title=Note}
36
+ If text editing was disabled at initialization, LogicFlow does not automatically clear edit state. Listen for the relevant events and call `setElementState` yourself to leave edit mode.
37
+ :::
38
+
39
+ ### updateText
40
+
41
+ Update the text value of a node or edge.
42
+
43
+ **Signature**
44
+
45
+ ```ts
46
+ updateText(id: string, value: string): void
47
+ ```
48
+
49
+ **Parameters**
50
+
51
+ | Name | Type | Required | Description |
52
+ | :--- | :--- | :--- | :--- |
53
+ | `id` | `string` | Yes | Node or edge id. |
54
+ | `value` | `string` | Yes | New text content. |
55
+
56
+ **Example**
57
+
58
+ ```ts
59
+ lf.updateText('id', 'value');
60
+ ```
@@ -0,0 +1,60 @@
1
+ ---
2
+ nav: API
3
+ group:
4
+ title: LogicFlow 实例
5
+ order: 2
6
+ title: 文本编辑
7
+ toc: content
8
+ order: 5
9
+ ---
10
+
11
+ 本页汇总 LogicFlow 实例中与节点/边文本编辑相关的方法。
12
+
13
+ ### editText
14
+
15
+ 显示节点、连线文本编辑框,进入编辑状态。
16
+
17
+ **签名**
18
+
19
+ ```ts
20
+ editText(id: string): void
21
+ ```
22
+
23
+ **参数**
24
+
25
+ | 名称 | 类型 | 必传 | 说明 |
26
+ | :--- | :--- | :--- | :--- |
27
+ | `id` | `string` | 是 | 节点或边 ID。 |
28
+
29
+ **示例**
30
+
31
+ ```ts
32
+ lf.editText('node_1');
33
+ ```
34
+
35
+ :::info{title=注意}
36
+ 当初始化 `lf` 实例时设置了文本不可编辑,LogicFlow 内部不会自动监听并取消元素编辑状态。此时需要自行监听并通过 `setElementState` 取消文本编辑状态。
37
+ :::
38
+
39
+ ### updateText
40
+
41
+ 更新节点或边的文本内容。
42
+
43
+ **签名**
44
+
45
+ ```ts
46
+ updateText(id: string, value: string): void
47
+ ```
48
+
49
+ **参数**
50
+
51
+ | 名称 | 类型 | 必传 | 说明 |
52
+ | :--- | :--- | :--- | :--- |
53
+ | `id` | `string` | 是 | 节点或边 ID。 |
54
+ | `value` | `string` | 是 | 更新后的文本值。 |
55
+
56
+ **示例**
57
+
58
+ ```ts
59
+ lf.updateText('id', 'value');
60
+ ```