@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,54 @@
1
+ ---
2
+ nav: Guide
3
+ group:
4
+ title: Intermediate
5
+ order: 2
6
+ title: Snapline
7
+ order: 2
8
+ toc: content
9
+ ---
10
+
11
+ Snap-lines assist in positional adjustment by comparing the position of a moving node with the
12
+ position of other nodes in the canvas as the node moves. The position comparison is done in two
13
+ ways.
14
+
15
+ - The center of the node
16
+ - The border of the node
17
+
18
+ ## Alignment Line Usage
19
+
20
+ Alignment lines are turned on by default in normal editing mode, and can also be turned off by
21
+ configuration.
22
+ In [silent mode](silent-mode.en.md#silent-mode), it is not possible to move the node, so the
23
+ alignment line function is turned off and cannot be turned on by configuration.
24
+
25
+ ```tsx | pure
26
+ const lf = new LogicFlow({
27
+ snapline: false,
28
+ });
29
+ ```
30
+
31
+ ## Alignment Line Style Settings
32
+
33
+ The style of the alignment line includes color and width, which can be modified by setting the
34
+ theme.
35
+
36
+ ```tsx | pure
37
+ // default configuration
38
+ // {
39
+ // stroke: '#1E90FF',
40
+ // strokeWidth: 1,
41
+ // }
42
+
43
+ // Modify the alignment line style
44
+ lf.setTheme({
45
+ snapline: {
46
+ stroke: '#1E90FF',
47
+ strokeWidth: 1,
48
+ },
49
+ })
50
+ ```
51
+
52
+ <example :height="400" ></example>
53
+
54
+ For more modifications to the styles see [Theme](../basic/theme.en.md)
@@ -0,0 +1,249 @@
1
+ ---
2
+ nav: Guide
3
+ group:
4
+ title: Intermediate
5
+ order: 2
6
+ title: Vue Node Registry
7
+ order: 7
8
+ toc: content
9
+ tag: New
10
+ ---
11
+
12
+ :::info{title=New-Features-Introduction}
13
+ * How to use Vue components to register node content
14
+ * How to synchronize node content updates when properties change
15
+ :::
16
+
17
+ ## Rendering Vue Components as Node Content
18
+
19
+ Similar to React, we provide a separate package `@logicflow/vue-node-registry` for rendering nodes with Vue components.
20
+
21
+ ### Vue 3
22
+
23
+ Here's an example of how to use Vue 3:
24
+
25
+ ```html
26
+ <template>
27
+ <div ref="containerRef" id="graph" class="viewport"></div>
28
+ <TeleportContainer :flow-id="flowId"/>
29
+ </template>
30
+
31
+ <script setup lang="ts">
32
+ import { onMounted, ref } from 'vue'
33
+ import { has } from 'lodash-es'
34
+ import LogicFlow from '@logicflow/core'
35
+ import { register, getTeleport } from '@logicflow/vue-node-registry'
36
+ import '@logicflow/core/es/index.css'
37
+
38
+ import ProgressNode from '@/components/LFElements/ProgressNode.vue'
39
+
40
+ const lfRef = ref<LogicFlow | null>(null)
41
+ const containerRef = ref<HTMLDivElement | null>(null)
42
+ const TeleportContainer = getTeleport()
43
+ const flowId = ref('')
44
+
45
+ onMounted(() => {
46
+ if (containerRef.value) {
47
+ const lf = new LogicFlow({
48
+ container: containerRef.value,
49
+ grid: true,
50
+ })
51
+
52
+ // 注册自定义 vue 节点
53
+ register({
54
+ type: 'custom-vue-node',
55
+ component: ProgressNode
56
+ }, lf)
57
+
58
+ lf.on('graph:rendered', ({ graphModel }) => {
59
+ flowId.value = graphModel.flowId!
60
+ })
61
+
62
+ // 注册事件
63
+ lf.render({})
64
+
65
+ const node1 = lf.addNode({
66
+ id: 'vue-node-1',
67
+ type: 'custom-vue-node',
68
+ x: 80,
69
+ y: 80,
70
+ properties: {
71
+ progress: 60,
72
+ width: 80,
73
+ height: 80
74
+ }
75
+ })
76
+ console.log('node1 --->>>', node1)
77
+
78
+ const node2 = lf.addNode({
79
+ id: 'vue-node-2',
80
+ type: 'custom-vue-node',
81
+ x: 360,
82
+ y: 80,
83
+ properties: {
84
+ progress: 60,
85
+ width: 80,
86
+ height: 80
87
+ }
88
+ })
89
+
90
+ setInterval(() => {
91
+ const { properties } = node2.getData()
92
+ console.log('properties.progress --->>>', properties?.progress)
93
+ if (has(properties, 'progress')) {
94
+ const progress = properties?.progress
95
+ node2.setProperty('progress', (progress + 10) % 100)
96
+ }
97
+ }, 2000)
98
+ }
99
+ })
100
+ </script>
101
+ ```
102
+
103
+ Node component content is as follows:
104
+
105
+ ```html
106
+ <template>
107
+ <el-progress type="dashboard" :percentage="percentage" :width="80">
108
+ <template #default="{ percentage }">
109
+ <span class="percentage-value">{{ percentage }}%</span>
110
+ </template>
111
+ </el-progress>
112
+ </template>
113
+
114
+ <script lang="ts">
115
+ import {
116
+ defineComponent
117
+ } from 'vue'
118
+ import {
119
+ EventType
120
+ } from '@logicflow/core'
121
+ import {
122
+ vueNodesMap
123
+ } from '@logicflow/vue-node-registry'
124
+
125
+ export default defineComponent({
126
+ name: 'ProgressNode',
127
+ inject: ['getNode', 'getGraph'],
128
+ data() {
129
+ return {
130
+ percentage: 80
131
+ }
132
+ },
133
+ mounted() {
134
+ const node = (this as any).getNode()
135
+ const graph = (this as any).getGraph()
136
+ graph.eventCenter.on(EventType.NODE_PROPERTIES_CHANGE, (eventData: any) => {
137
+ const keys = eventData.keys as string[]
138
+ const content = vueNodesMap[node.type]
139
+ if (content && eventData.id === node.id) {
140
+ const {
141
+ effect
142
+ } = content
143
+
144
+ // If effect is not defined, default to updating; if effect is defined, only update when properties in effect change
145
+ if (!effect || keys.some((key) => effect.includes(key))) {
146
+ console.log('eventData --->>>', eventData)
147
+ this.percentage = eventData.properties?.progress || 0
148
+ }
149
+ }
150
+ })
151
+ }
152
+ })
153
+ </script>
154
+ ```
155
+
156
+ Below is an animated image showing the effect. To experience the functionality, you can start the `examples/vue3-app` project.
157
+ <img src="/vue3-app.gif">
158
+
159
+ ## Updating Nodes
160
+
161
+ Similar to `HTMLNode`, when users update node properties using `setProperties` or `setProperty`, we need to listen to the `node:properties-change` event inside the component and update the component's state based on the properties value, as demonstrated in the example above.
162
+
163
+ ## Using Vue 2
164
+
165
+ In the example above, we used teleport, a feature of Vue 3. How can this be done in Vue 2?
166
+
167
+ ```html
168
+ <template>
169
+ <div id="app">
170
+ <div ref="containerRef" id="graph"></div>
171
+ </div>
172
+ </template>
173
+
174
+ <script>
175
+ import LogicFlow from '@logicflow/core'
176
+ import {
177
+ register
178
+ } from '@logicflow/vue-node-registry'
179
+
180
+ import ProgressNode from '@/components/ProgressNode'
181
+ import '@logicflow/core/dist/index.css'
182
+
183
+ export default {
184
+ name: 'App',
185
+ data() {
186
+ return {
187
+ lf: null,
188
+ }
189
+ },
190
+ mounted() {
191
+ this.lf = new LogicFlow({
192
+ container: this.$refs.containerRef,
193
+ grid: true,
194
+ })
195
+ register({
196
+ type: 'progress',
197
+ component: ProgressNode,
198
+ },
199
+ this.lf,
200
+ )
201
+
202
+ this.lf.render({})
203
+
204
+ const node1 = this.lf.addNode({
205
+ id: 'vue-node-1',
206
+ type: 'progress',
207
+ x: 80,
208
+ y: 80,
209
+ properties: {
210
+ progress: 60,
211
+ width: 80,
212
+ height: 80,
213
+ },
214
+ })
215
+ console.log('node1 --->>>', node1)
216
+ },
217
+ }
218
+ </script>
219
+
220
+ <style>
221
+ #graph {
222
+ height: 100vh;
223
+ }
224
+ </style>
225
+ ```
226
+
227
+ Node component content is as follows:
228
+
229
+ ```html
230
+ <template>
231
+ <div>vue2 node</div>
232
+ </template>
233
+
234
+ <script>
235
+ export default {
236
+ name: 'ProgressNode',
237
+ inject: ['getNode', 'getGraph'],
238
+ data() {
239
+ return {
240
+ percentage: 80,
241
+ }
242
+ },
243
+ }
244
+ </script>
245
+ ```
246
+
247
+ :::warning{title=Note}
248
+ Currently, there are some limitations with node component content in Vue 2, such as the inability to use Vuex, i18n, element-ui, etc. If you need these features, you can try using `vue2-teleport` to enhance the capabilities, and we welcome PRs (we will also gradually enhance this functionality in the future).
249
+ :::
@@ -0,0 +1,248 @@
1
+ ---
2
+ nav: 指南
3
+ group:
4
+ title: 进阶
5
+ order: 2
6
+ title: Vue 节点
7
+ order: 7
8
+ toc: content
9
+ tag: 新特性
10
+ ---
11
+
12
+ :::info{title=我们带来了新特性,本节内容主要介绍}
13
+ - 如何使用 Vue 组件来注册节点内容
14
+ - properties 更新后如何同步更新节点内容
15
+ ::::
16
+
17
+ ::::info{title=阅读提示}
18
+ - 适合已经理解 [节点](../basic/node.zh.md) 的 Vue 项目用户
19
+ - 当前推荐优先使用 `@logicflow/vue-node-registry`
20
+ - Vue3 和 Vue2 的使用方式不同,建议按自己的技术栈跳读,不要混在一起理解
21
+ - 本页不展开连接规则、锚点和边能力;这些内容请回到 [进阶节点](node.zh.md)
22
+ - 相关 API:[`nodeModel`](../../api/runtime-model/nodeModel.zh.md)、[`graphModel`](../../api/runtime-model/graphModel.zh.md)、[`事件`](../../api/logicflow-instance/event.zh.md)
23
+ ::::
24
+
25
+ ## 渲染 Vue 组件为节点内容
26
+ 同 React 一样我们提供了一个独立的包 `@logicflow/vue-node-registry` 来使用 Vue 组件渲染节点。
27
+
28
+ ### Vue3
29
+ 在 Vue3 中使用示例如下:
30
+
31
+ ```html
32
+ <template>
33
+ <div ref="containerRef" id="graph" class="viewport"></div>
34
+ <TeleportContainer :flow-id="flowId"/>
35
+ </template>
36
+
37
+ <script setup lang="ts">
38
+ import { onMounted, ref } from 'vue'
39
+ import { has } from 'lodash-es'
40
+ import LogicFlow from '@logicflow/core'
41
+ import { register, getTeleport } from '@logicflow/vue-node-registry'
42
+ import '@logicflow/core/es/index.css'
43
+
44
+ import ProgressNode from '@/components/LFElements/ProgressNode.vue'
45
+
46
+ const lfRef = ref<LogicFlow | null>(null)
47
+ const containerRef = ref<HTMLDivElement | null>(null)
48
+ const TeleportContainer = getTeleport()
49
+ const flowId = ref('')
50
+
51
+ onMounted(() => {
52
+ if (containerRef.value) {
53
+ const lf = new LogicFlow({
54
+ container: containerRef.value,
55
+ grid: true,
56
+ })
57
+
58
+ // 注册自定义 vue 节点
59
+ register({
60
+ type: 'custom-vue-node',
61
+ component: ProgressNode
62
+ }, lf)
63
+
64
+ lf.on('graph:rendered', ({ graphModel }) => {
65
+ flowId.value = graphModel.flowId!
66
+ })
67
+
68
+ // 注册事件
69
+ lf.render({})
70
+
71
+ const node1 = lf.addNode({
72
+ id: 'vue-node-1',
73
+ type: 'custom-vue-node',
74
+ x: 80,
75
+ y: 80,
76
+ properties: {
77
+ progress: 60,
78
+ width: 80,
79
+ height: 80
80
+ }
81
+ })
82
+ console.log('node1 --->>>', node1)
83
+
84
+ const node2 = lf.addNode({
85
+ id: 'vue-node-2',
86
+ type: 'custom-vue-node',
87
+ x: 360,
88
+ y: 80,
89
+ properties: {
90
+ progress: 60,
91
+ width: 80,
92
+ height: 80
93
+ }
94
+ })
95
+
96
+ setInterval(() => {
97
+ const { properties } = node2.getData()
98
+ console.log('properties.progress --->>>', properties?.progress)
99
+ if (has(properties, 'progress')) {
100
+ const progress = properties?.progress
101
+ node2.setProperty('progress', (progress + 10) % 100)
102
+ }
103
+ }, 2000)
104
+ }
105
+ })
106
+ </script>
107
+
108
+ ```
109
+
110
+ 节点组件内容如下:
111
+ ```html
112
+ <template>
113
+ <el-progress type="dashboard" :percentage="percentage" :width="80">
114
+ <template #default="{ percentage }">
115
+ <span class="percentage-value">{{ percentage }}%</span>
116
+ </template>
117
+ </el-progress>
118
+ </template>
119
+
120
+ <script lang="ts">
121
+ import { defineComponent } from 'vue'
122
+ import { EventType } from '@logicflow/core'
123
+ import { vueNodesMap } from '@logicflow/vue-node-registry'
124
+
125
+ export default defineComponent({
126
+ name: 'ProgressNode',
127
+ inject: ['getNode', 'getGraph'],
128
+ data() {
129
+ return {
130
+ percentage: 80
131
+ }
132
+ },
133
+ mounted() {
134
+ const node = (this as any).getNode()
135
+ const graph = (this as any).getGraph()
136
+ graph.eventCenter.on(EventType.NODE_PROPERTIES_CHANGE, (eventData: any) => {
137
+ const keys = eventData.keys as string[]
138
+ const content = vueNodesMap[node.type]
139
+ if (content && eventData.id === node.id) {
140
+ const { effect } = content
141
+
142
+ // 如果没有定义 effect,则默认更新;如果定义了 effect,则只有在 effect 中的属性发生变化时才更新
143
+ if (!effect || keys.some((key) => effect.includes(key))) {
144
+ console.log('eventData --->>>', eventData)
145
+ this.percentage = eventData.properties?.progress || 0
146
+ }
147
+ }
148
+ })
149
+ }
150
+ })
151
+ </script>
152
+
153
+ ```
154
+
155
+ 下面插入一张动图展示效果。如果想体验具体功能可以通过启动:examples/vue3-app 项目查看。
156
+ <img src="/vue3-app.gif">
157
+
158
+ ## 更新节点
159
+ 跟 `HTMLNode` 一样,当用户通过 `setProperties` 或 `setProperty` 等更新节点 properties 时,
160
+ 我们需要在组件内部监听 `node:properties-change` 事件,根据 properties 值更新组件状态。如上面 Demo 所示。
161
+
162
+ ## Vue2 使用
163
+ 上面我们使用到了 teleport,它是 Vue3 中的特性,如果在 Vue2 中,如何使用呢?
164
+
165
+ ```html
166
+ <template>
167
+ <div id="app">
168
+ <div ref="containerRef" id="graph"></div>
169
+ </div>
170
+ </template>
171
+
172
+ <script>
173
+ import LogicFlow from '@logicflow/core'
174
+ import { register } from '@logicflow/vue-node-registry'
175
+
176
+ import ProgressNode from '@/components/ProgressNode'
177
+ import '@logicflow/core/dist/index.css'
178
+
179
+ export default {
180
+ name: 'App',
181
+ data() {
182
+ return {
183
+ lf: null,
184
+ }
185
+ },
186
+ mounted() {
187
+ this.lf = new LogicFlow({
188
+ container: this.$refs.containerRef,
189
+ grid: true,
190
+ })
191
+ register(
192
+ {
193
+ type: 'progress',
194
+ component: ProgressNode,
195
+ },
196
+ this.lf,
197
+ )
198
+
199
+ this.lf.render({})
200
+
201
+ const node1 = this.lf.addNode({
202
+ id: 'vue-node-1',
203
+ type: 'progress',
204
+ x: 80,
205
+ y: 80,
206
+ properties: {
207
+ progress: 60,
208
+ width: 80,
209
+ height: 80,
210
+ },
211
+ })
212
+ console.log('node1 --->>>', node1)
213
+ },
214
+ }
215
+ </script>
216
+
217
+ <style>
218
+ #graph {
219
+ height: 100vh;
220
+ }
221
+ </style>
222
+ ```
223
+
224
+ 节点组件内容如下:
225
+ ```html
226
+ <template>
227
+ <div>vue2 node</div>
228
+ </template>
229
+
230
+ <script>
231
+ export default {
232
+ name: 'ProgressNode',
233
+ inject: ['getNode', 'getGraph'],
234
+ data() {
235
+ return {
236
+ percentage: 80,
237
+ }
238
+ },
239
+ }
240
+ </script>
241
+
242
+ ```
243
+
244
+ :::warning{title=注意}
245
+ 目前在 Vue2 中,节点组件内容有一些限制,比如无法使用 Vuex、i18n、element-ui 等。如果需要使用这些功能,可以尝试
246
+ 使用 vue2-teleport 来增强能力,欢迎给我们提 PR(我们后面也会逐步增强该功能)。
247
+ :::
248
+
@@ -0,0 +1,64 @@
1
+ ---
2
+ nav: Guide
3
+ group:
4
+ title: Introduction
5
+ title: AI Programming Support
6
+ order: 2
7
+ toc: content
8
+ ---
9
+
10
+ Starting from `@logicflow/core@2.3.0`, LogicFlow ships tutorial and API docs with the npm package. Copy the prompt on this page to your AI Agent so it can read local docs in your project instead of implementing LogicFlow features from general knowledge alone.
11
+
12
+ ## When to Copy the Prompt
13
+
14
+ Copy the prompt in these situations:
15
+
16
+ 1. After installing `@logicflow/core` for the first time
17
+ 2. After upgrading `@logicflow/core`
18
+ 3. Before asking an Agent to implement LogicFlow features
19
+
20
+ If your Agent already has an older prompt but still misses official plugin or layout capabilities, copy the latest prompt below again.
21
+
22
+ ## What the Agent Should Know
23
+
24
+ LogicFlow is organized around three main packages:
25
+
26
+ - `@logicflow/core`: the core graph editor runtime, including canvas, nodes, edges, models, events, rendering, themes, and basic interactions.
27
+ - `@logicflow/extension`: the official extension package for common product features.
28
+ - `@logicflow/layout`: the official layout plugin package for automatic graph layout.
29
+
30
+ The docs for these packages are shipped under `node_modules/@logicflow/core/dist/docs/`. The docs for `@logicflow/extension` and `@logicflow/layout` mainly live under `tutorial/extension/`.
31
+
32
+ ## Prompt to Copy
33
+
34
+ Copy the whole block below to your AI Agent:
35
+
36
+ ```md
37
+ <!-- BEGIN:logicflow-agent-rules -->
38
+ # LogicFlow Agent Rules
39
+
40
+ LogicFlow documentation is available at:
41
+
42
+ - `node_modules/@logicflow/core/dist/docs/`
43
+
44
+ Package roles:
45
+
46
+ - `@logicflow/core`: core graph editor runtime, including canvas, nodes, edges, models, events, rendering, themes, and basic interactions.
47
+ - `@logicflow/extension`: official plugins for common product features.
48
+ - `@logicflow/layout`: official layout plugins for automatic graph layout.
49
+
50
+ The docs for `@logicflow/extension` and `@logicflow/layout` are included under:
51
+
52
+ - `node_modules/@logicflow/core/dist/docs/tutorial/extension/`
53
+
54
+ Before implementing any LogicFlow feature, check the local docs first to see whether LogicFlow already provides a built-in, extension, or layout capability. If it does, prefer the documented official capability instead of reimplementing it from scratch.
55
+
56
+ If an official package is needed but not installed, ask the user before installing it.
57
+ <!-- END:logicflow-agent-rules -->
58
+ ```
59
+
60
+ ## Next Reading
61
+
62
+ - New to LogicFlow: read [Getting Started](get-started.en.md)
63
+ - Need plugins or layout: read [Plugin Introduction](extension/intro.en.md)
64
+ - Need exact API options: read [API Guide](../api/logicflow-instance/index.en.md)
@@ -0,0 +1,64 @@
1
+ ---
2
+ nav: 指南
3
+ group:
4
+ title: 介绍
5
+ title: AI 编程支持
6
+ order: 2
7
+ toc: content
8
+ ---
9
+
10
+ LogicFlow 会从 `@logicflow/core@2.3.0` 开始,把教程和 API 文档随 npm 包一起发布。你可以把本页的提示词复制给 AI Agent,让它在你的项目里直接读取本地文档,而不是只凭通用经验实现功能。
11
+
12
+ ## 什么时候复制给 Agent
13
+
14
+ 建议在这些场景复制:
15
+
16
+ 1. 首次安装 `@logicflow/core` 后
17
+ 2. 升级 `@logicflow/core` 后
18
+ 3. 准备让 Agent 实现 LogicFlow 相关功能前
19
+
20
+ 如果 Agent 已经拿到旧提示词,但仍然没有按官方插件或布局能力实现功能,也可以重新复制下面的最新提示词。
21
+
22
+ ## Agent 需要知道什么
23
+
24
+ LogicFlow 主要由三个包组成:
25
+
26
+ - `@logicflow/core`:核心画布运行时,包含画布、节点、边、模型、事件、渲染、主题和基础交互能力。
27
+ - `@logicflow/extension`:官方插件包,用于常见产品功能。
28
+ - `@logicflow/layout`:官方布局插件包,用于自动布局。
29
+
30
+ 这些包的使用文档都发布在 `node_modules/@logicflow/core/dist/docs/` 中。其中 `@logicflow/extension` 和 `@logicflow/layout` 的文档主要在 `tutorial/extension/` 目录下。
31
+
32
+ ## 复制给 Agent 的提示词
33
+
34
+ 将下面整段内容复制给你的 AI Agent:
35
+
36
+ ```md
37
+ <!-- BEGIN:logicflow-agent-rules -->
38
+ # LogicFlow Agent Rules
39
+
40
+ LogicFlow documentation is available at:
41
+
42
+ - `node_modules/@logicflow/core/dist/docs/`
43
+
44
+ Package roles:
45
+
46
+ - `@logicflow/core`: core graph editor runtime, including canvas, nodes, edges, models, events, rendering, themes, and basic interactions.
47
+ - `@logicflow/extension`: official plugins for common product features.
48
+ - `@logicflow/layout`: official layout plugins for automatic graph layout.
49
+
50
+ The docs for `@logicflow/extension` and `@logicflow/layout` are included under:
51
+
52
+ - `node_modules/@logicflow/core/dist/docs/tutorial/extension/`
53
+
54
+ Before implementing any LogicFlow feature, check the local docs first to see whether LogicFlow already provides a built-in, extension, or layout capability. If it does, prefer the documented official capability instead of reimplementing it from scratch.
55
+
56
+ If an official package is needed but not installed, ask the user before installing it.
57
+ <!-- END:logicflow-agent-rules -->
58
+ ```
59
+
60
+ ## 下一步阅读
61
+
62
+ - 第一次接入 LogicFlow:阅读 [快速上手](get-started.zh.md)
63
+ - 需要插件或布局能力:阅读 [插件简介](extension/intro.zh.md)
64
+ - 需要精确 API 参数:阅读 [API 导览](../api/logicflow-instance/index.zh.md)