@logicflow/core 2.2.0 → 2.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.
Files changed (361) hide show
  1. package/dist/docs/api/logicflow-constructor/index.en.md +106 -0
  2. package/dist/docs/api/logicflow-constructor/index.zh.md +106 -0
  3. package/dist/docs/api/logicflow-constructor/use.en.md +61 -0
  4. package/dist/docs/api/logicflow-constructor/use.zh.md +61 -0
  5. package/dist/docs/api/logicflow-instance/canvas.en.md +197 -0
  6. package/dist/docs/api/logicflow-instance/canvas.zh.md +199 -0
  7. package/dist/docs/api/logicflow-instance/edge.en.md +273 -0
  8. package/dist/docs/api/logicflow-instance/edge.zh.md +273 -0
  9. package/dist/docs/api/logicflow-instance/edit-config.en.md +59 -0
  10. package/dist/docs/api/logicflow-instance/edit-config.zh.md +59 -0
  11. package/dist/docs/api/logicflow-instance/element.en.md +375 -0
  12. package/dist/docs/api/logicflow-instance/element.zh.md +379 -0
  13. package/dist/docs/api/logicflow-instance/event.en.md +326 -0
  14. package/dist/docs/api/logicflow-instance/event.zh.md +406 -0
  15. package/dist/docs/api/logicflow-instance/history.en.md +38 -0
  16. package/dist/docs/api/logicflow-instance/history.zh.md +38 -0
  17. package/dist/docs/api/logicflow-instance/index.en.md +41 -0
  18. package/dist/docs/api/logicflow-instance/index.zh.md +41 -0
  19. package/dist/docs/api/logicflow-instance/node.en.md +308 -0
  20. package/dist/docs/api/logicflow-instance/node.zh.md +308 -0
  21. package/dist/docs/api/logicflow-instance/register.en.md +76 -0
  22. package/dist/docs/api/logicflow-instance/register.zh.md +76 -0
  23. package/dist/docs/api/logicflow-instance/render-and-data.en.md +179 -0
  24. package/dist/docs/api/logicflow-instance/render-and-data.zh.md +181 -0
  25. package/dist/docs/api/logicflow-instance/text.en.md +60 -0
  26. package/dist/docs/api/logicflow-instance/text.zh.md +60 -0
  27. package/dist/docs/api/logicflow-instance/theme.en.md +179 -0
  28. package/dist/docs/api/logicflow-instance/theme.zh.md +179 -0
  29. package/dist/docs/api/runtime-model/edgeModel.en.md +29 -0
  30. package/dist/docs/api/runtime-model/edgeModel.zh.md +325 -0
  31. package/dist/docs/api/runtime-model/graphModel.en.md +275 -0
  32. package/dist/docs/api/runtime-model/graphModel.zh.md +1153 -0
  33. package/dist/docs/api/runtime-model/nodeModel.en.md +37 -0
  34. package/dist/docs/api/runtime-model/nodeModel.zh.md +644 -0
  35. package/dist/docs/api/type/MainTypes.en.md +598 -0
  36. package/dist/docs/api/type/MainTypes.zh.md +867 -0
  37. package/dist/docs/api/type/Theme.en.md +187 -0
  38. package/dist/docs/api/type/Theme.zh.md +187 -0
  39. package/dist/docs/api/type/canvas-types.en.md +25 -0
  40. package/dist/docs/api/type/canvas-types.zh.md +25 -0
  41. package/dist/docs/api/type/index.en.md +96 -0
  42. package/dist/docs/api/type/index.zh.md +99 -0
  43. package/dist/docs/api/type/node-types.en.md +21 -0
  44. package/dist/docs/api/type/node-types.zh.md +21 -0
  45. package/dist/docs/api/type/plugin-types.en.md +24 -0
  46. package/dist/docs/api/type/plugin-types.zh.md +24 -0
  47. package/dist/docs/index.md +11 -0
  48. package/dist/docs/tutorial/about.en.md +38 -0
  49. package/dist/docs/tutorial/about.zh.md +65 -0
  50. package/dist/docs/tutorial/advanced/dnd.en.md +62 -0
  51. package/dist/docs/tutorial/advanced/dnd.zh.md +52 -0
  52. package/dist/docs/tutorial/advanced/edge.en.md +64 -0
  53. package/dist/docs/tutorial/advanced/edge.zh.md +66 -0
  54. package/dist/docs/tutorial/advanced/keyboard.en.md +70 -0
  55. package/dist/docs/tutorial/advanced/keyboard.zh.md +67 -0
  56. package/dist/docs/tutorial/advanced/node.en.md +338 -0
  57. package/dist/docs/tutorial/advanced/node.zh.md +338 -0
  58. package/dist/docs/tutorial/advanced/react.en.md +106 -0
  59. package/dist/docs/tutorial/advanced/react.zh.md +114 -0
  60. package/dist/docs/tutorial/advanced/silent-mode.en.md +75 -0
  61. package/dist/docs/tutorial/advanced/silent-mode.zh.md +71 -0
  62. package/dist/docs/tutorial/advanced/snapline.en.md +54 -0
  63. package/dist/docs/tutorial/advanced/vue.en.md +249 -0
  64. package/dist/docs/tutorial/advanced/vue.zh.md +248 -0
  65. package/dist/docs/tutorial/ai.en.md +64 -0
  66. package/dist/docs/tutorial/ai.zh.md +64 -0
  67. package/dist/docs/tutorial/basic/background.en.md +50 -0
  68. package/dist/docs/tutorial/basic/canvas.en.md +164 -0
  69. package/dist/docs/tutorial/basic/canvas.zh.md +183 -0
  70. package/dist/docs/tutorial/basic/class.en.md +106 -0
  71. package/dist/docs/tutorial/basic/class.zh.md +103 -0
  72. package/dist/docs/tutorial/basic/edge.en.md +151 -0
  73. package/dist/docs/tutorial/basic/edge.zh.md +152 -0
  74. package/dist/docs/tutorial/basic/event.en.md +70 -0
  75. package/dist/docs/tutorial/basic/event.zh.md +66 -0
  76. package/dist/docs/tutorial/basic/grid.en.md +77 -0
  77. package/dist/docs/tutorial/basic/node.en.md +358 -0
  78. package/dist/docs/tutorial/basic/node.zh.md +318 -0
  79. package/dist/docs/tutorial/basic/theme.en.md +154 -0
  80. package/dist/docs/tutorial/basic/theme.zh.md +157 -0
  81. package/dist/docs/tutorial/extension/adapter.en.md +446 -0
  82. package/dist/docs/tutorial/extension/adapter.zh.md +429 -0
  83. package/dist/docs/tutorial/extension/bpmn-element.en.md +1427 -0
  84. package/dist/docs/tutorial/extension/bpmn-element.zh.md +1472 -0
  85. package/dist/docs/tutorial/extension/control.en.md +117 -0
  86. package/dist/docs/tutorial/extension/control.zh.md +118 -0
  87. package/dist/docs/tutorial/extension/curved-edge.en.md +46 -0
  88. package/dist/docs/tutorial/extension/curved-edge.zh.md +46 -0
  89. package/dist/docs/tutorial/extension/custom.en.md +142 -0
  90. package/dist/docs/tutorial/extension/custom.zh.md +138 -0
  91. package/dist/docs/tutorial/extension/dnd-panel.en.md +109 -0
  92. package/dist/docs/tutorial/extension/dnd-panel.zh.md +109 -0
  93. package/dist/docs/tutorial/extension/dynamic-group.en.md +606 -0
  94. package/dist/docs/tutorial/extension/dynamic-group.zh.md +606 -0
  95. package/dist/docs/tutorial/extension/group.en.md +217 -0
  96. package/dist/docs/tutorial/extension/group.zh.md +209 -0
  97. package/dist/docs/tutorial/extension/highlight.en.md +50 -0
  98. package/dist/docs/tutorial/extension/highlight.zh.md +50 -0
  99. package/dist/docs/tutorial/extension/insert-node-in-polyline.en.md +52 -0
  100. package/dist/docs/tutorial/extension/insert-node-in-polyline.zh.md +47 -0
  101. package/dist/docs/tutorial/extension/intro.en.md +72 -0
  102. package/dist/docs/tutorial/extension/intro.zh.md +95 -0
  103. package/dist/docs/tutorial/extension/label.en.md +136 -0
  104. package/dist/docs/tutorial/extension/label.zh.md +135 -0
  105. package/dist/docs/tutorial/extension/layout.en.md +156 -0
  106. package/dist/docs/tutorial/extension/layout.zh.md +156 -0
  107. package/dist/docs/tutorial/extension/menu.en.md +319 -0
  108. package/dist/docs/tutorial/extension/menu.zh.md +377 -0
  109. package/dist/docs/tutorial/extension/minimap.en.md +164 -0
  110. package/dist/docs/tutorial/extension/minimap.zh.md +180 -0
  111. package/dist/docs/tutorial/extension/node-resize.en.md +199 -0
  112. package/dist/docs/tutorial/extension/node-resize.zh.md +221 -0
  113. package/dist/docs/tutorial/extension/pool.en.md +227 -0
  114. package/dist/docs/tutorial/extension/pool.zh.md +227 -0
  115. package/dist/docs/tutorial/extension/proximity-connect.en.md +104 -0
  116. package/dist/docs/tutorial/extension/proximity-connect.zh.md +107 -0
  117. package/dist/docs/tutorial/extension/selection.en.md +166 -0
  118. package/dist/docs/tutorial/extension/selection.zh.md +150 -0
  119. package/dist/docs/tutorial/extension/snapshot.en.md +276 -0
  120. package/dist/docs/tutorial/extension/snapshot.zh.md +276 -0
  121. package/dist/docs/tutorial/get-started.en.md +501 -0
  122. package/dist/docs/tutorial/get-started.zh.md +139 -0
  123. package/dist/docs/tutorial/update.en.md +213 -0
  124. package/dist/docs/tutorial/update.zh.md +212 -0
  125. package/dist/index.css +3 -2
  126. package/dist/index.min.js +1 -1
  127. package/dist/index.min.js.map +1 -1
  128. package/es/LogicFlow.d.ts +9 -0
  129. package/es/LogicFlow.js +0 -1
  130. package/es/constant/index.d.ts +1 -1
  131. package/es/constant/index.js +1 -1
  132. package/es/constant/theme.d.ts +136 -0
  133. package/es/constant/theme.js +680 -0
  134. package/es/index.css +3 -2
  135. package/es/model/GraphModel.d.ts +10 -2
  136. package/es/model/GraphModel.js +48 -14
  137. package/es/model/TransformModel.js +9 -9
  138. package/es/model/edge/BaseEdgeModel.js +7 -2
  139. package/es/model/edge/PolylineEdgeModel.d.ts +7 -0
  140. package/es/model/edge/PolylineEdgeModel.js +136 -7
  141. package/es/model/node/BaseNodeModel.d.ts +12 -1
  142. package/es/model/node/BaseNodeModel.js +9 -2
  143. package/es/model/node/HtmlNodeModel.d.ts +12 -0
  144. package/es/model/node/HtmlNodeModel.js +19 -0
  145. package/es/model/node/PolygonNodeModel.js +3 -3
  146. package/es/options.d.ts +4 -2
  147. package/es/style/index.css +3 -2
  148. package/es/style/index.less +3 -2
  149. package/es/style/raw.d.ts +1 -1
  150. package/es/style/raw.js +1 -1
  151. package/es/tool/MultipleSelectTool.js +10 -5
  152. package/es/util/drag.js +0 -1
  153. package/es/util/edge.d.ts +40 -1
  154. package/es/util/edge.js +43 -9
  155. package/es/util/geometry.d.ts +8 -0
  156. package/es/util/geometry.js +79 -0
  157. package/es/util/theme.d.ts +2 -65
  158. package/es/util/theme.js +4 -281
  159. package/es/view/Anchor.d.ts +1 -0
  160. package/es/view/Anchor.js +24 -21
  161. package/es/view/Control.d.ts +5 -0
  162. package/es/view/Control.js +44 -57
  163. package/es/view/edge/BaseEdge.js +9 -0
  164. package/es/view/edge/PolylineEdge.js +13 -2
  165. package/es/view/node/BaseNode.d.ts +1 -0
  166. package/es/view/node/BaseNode.js +23 -11
  167. package/es/view/node/HtmlNode.js +2 -4
  168. package/es/view/overlay/CanvasOverlay.js +5 -2
  169. package/es/view/overlay/Grid.d.ts +12 -1
  170. package/es/view/overlay/Grid.js +85 -23
  171. package/es/view/overlay/OutlineOverlay.d.ts +1 -0
  172. package/es/view/overlay/OutlineOverlay.js +18 -17
  173. package/es/view/overlay/gridConfig.d.ts +46 -0
  174. package/es/view/overlay/gridConfig.js +99 -0
  175. package/es/view/shape/Polygon.d.ts +0 -7
  176. package/es/view/shape/Polygon.js +12 -43
  177. package/lib/LogicFlow.d.ts +9 -0
  178. package/lib/LogicFlow.js +0 -1
  179. package/lib/constant/index.d.ts +1 -1
  180. package/lib/constant/index.js +16 -2
  181. package/lib/constant/theme.d.ts +136 -0
  182. package/lib/constant/theme.js +683 -0
  183. package/lib/index.css +3 -2
  184. package/lib/model/GraphModel.d.ts +10 -2
  185. package/lib/model/GraphModel.js +49 -15
  186. package/lib/model/TransformModel.js +9 -9
  187. package/lib/model/edge/BaseEdgeModel.js +7 -2
  188. package/lib/model/edge/PolylineEdgeModel.d.ts +7 -0
  189. package/lib/model/edge/PolylineEdgeModel.js +136 -7
  190. package/lib/model/node/BaseNodeModel.d.ts +12 -1
  191. package/lib/model/node/BaseNodeModel.js +9 -2
  192. package/lib/model/node/HtmlNodeModel.d.ts +12 -0
  193. package/lib/model/node/HtmlNodeModel.js +19 -0
  194. package/lib/model/node/PolygonNodeModel.js +3 -3
  195. package/lib/options.d.ts +4 -2
  196. package/lib/style/index.css +3 -2
  197. package/lib/style/index.less +3 -2
  198. package/lib/style/raw.d.ts +1 -1
  199. package/lib/style/raw.js +1 -1
  200. package/lib/tool/MultipleSelectTool.js +10 -5
  201. package/lib/util/drag.js +0 -1
  202. package/lib/util/edge.d.ts +40 -1
  203. package/lib/util/edge.js +43 -9
  204. package/lib/util/geometry.d.ts +8 -0
  205. package/lib/util/geometry.js +81 -1
  206. package/lib/util/theme.d.ts +2 -65
  207. package/lib/util/theme.js +15 -292
  208. package/lib/view/Anchor.d.ts +1 -0
  209. package/lib/view/Anchor.js +24 -21
  210. package/lib/view/Control.d.ts +5 -0
  211. package/lib/view/Control.js +44 -57
  212. package/lib/view/edge/BaseEdge.js +9 -0
  213. package/lib/view/edge/PolylineEdge.js +13 -2
  214. package/lib/view/node/BaseNode.d.ts +1 -0
  215. package/lib/view/node/BaseNode.js +22 -10
  216. package/lib/view/node/HtmlNode.js +1 -3
  217. package/lib/view/overlay/CanvasOverlay.js +5 -2
  218. package/lib/view/overlay/Grid.d.ts +12 -1
  219. package/lib/view/overlay/Grid.js +83 -21
  220. package/lib/view/overlay/OutlineOverlay.d.ts +1 -0
  221. package/lib/view/overlay/OutlineOverlay.js +18 -17
  222. package/lib/view/overlay/gridConfig.d.ts +46 -0
  223. package/lib/view/overlay/gridConfig.js +104 -0
  224. package/lib/view/shape/Polygon.d.ts +0 -7
  225. package/lib/view/shape/Polygon.js +13 -45
  226. package/package.json +9 -2
  227. package/scripts/postinstall-ai-prompt.js +67 -0
  228. package/.turbo/turbo-build$colon$dev.log +0 -10
  229. package/.turbo/turbo-build.log +0 -33
  230. package/CHANGELOG.md +0 -1849
  231. package/__tests__/algorithm/egde.test.ts +0 -131
  232. package/__tests__/algorithm/index.test.ts +0 -74
  233. package/__tests__/algorithm/outline.test.ts +0 -43
  234. package/__tests__/bugs/1545-spec.test.ts +0 -42
  235. package/__tests__/event/event.test.ts +0 -22
  236. package/__tests__/history/history.test.ts +0 -28
  237. package/__tests__/logicflow.test.ts +0 -575
  238. package/__tests__/model/graphmodel.test.ts +0 -87
  239. package/__tests__/util/compatible.test.ts +0 -48
  240. package/__tests__/util/edge.test.ts +0 -224
  241. package/__tests__/util/geometry.test.ts +0 -14
  242. package/__tests__/util/graph.test.ts +0 -16
  243. package/__tests__/util/matrix.test.ts +0 -41
  244. package/__tests__/util/node.test.ts +0 -68
  245. package/__tests__/util/sampling.test.ts +0 -12
  246. package/__tests__/util/vector.test.ts +0 -50
  247. package/__tests__/util/zIndex.test.ts +0 -10
  248. package/src/LogicFlow.tsx +0 -2008
  249. package/src/algorithm/edge.ts +0 -67
  250. package/src/algorithm/index.ts +0 -70
  251. package/src/algorithm/outline.ts +0 -77
  252. package/src/algorithm/rotate.ts +0 -55
  253. package/src/common/drag.ts +0 -219
  254. package/src/common/history.ts +0 -108
  255. package/src/common/index.ts +0 -6
  256. package/src/common/keyboard.ts +0 -108
  257. package/src/common/matrix.ts +0 -122
  258. package/src/common/vector.ts +0 -93
  259. package/src/constant/index.ts +0 -179
  260. package/src/event/event.md +0 -66
  261. package/src/event/eventArgs.ts +0 -643
  262. package/src/event/eventEmitter.ts +0 -156
  263. package/src/history/index.ts +0 -119
  264. package/src/index.less +0 -1
  265. package/src/index.ts +0 -26
  266. package/src/keyboard/index.ts +0 -112
  267. package/src/keyboard/shortcut.ts +0 -200
  268. package/src/model/BaseModel.ts +0 -250
  269. package/src/model/EditConfigModel.ts +0 -334
  270. package/src/model/GraphModel.ts +0 -1788
  271. package/src/model/NestedTransformModel.ts +0 -121
  272. package/src/model/SnaplineModel.ts +0 -256
  273. package/src/model/TransformModel.ts +0 -258
  274. package/src/model/edge/BaseEdgeModel.ts +0 -777
  275. package/src/model/edge/BezierEdgeModel.ts +0 -197
  276. package/src/model/edge/LineEdgeModel.ts +0 -36
  277. package/src/model/edge/PolylineEdgeModel.ts +0 -672
  278. package/src/model/edge/index.ts +0 -4
  279. package/src/model/index.ts +0 -9
  280. package/src/model/node/BaseNodeModel.ts +0 -949
  281. package/src/model/node/CircleNodeModel.ts +0 -91
  282. package/src/model/node/DiamondNodeModel.ts +0 -132
  283. package/src/model/node/EllipseNodeModel.ts +0 -98
  284. package/src/model/node/HtmlNodeModel.ts +0 -50
  285. package/src/model/node/PolygonNodeModel.ts +0 -150
  286. package/src/model/node/RectNodeModel.ts +0 -69
  287. package/src/model/node/TextNodeModel.ts +0 -54
  288. package/src/model/node/index.ts +0 -8
  289. package/src/options.ts +0 -145
  290. package/src/style/index.less +0 -261
  291. package/src/style/raw.ts +0 -220
  292. package/src/tool/MultipleSelectTool.tsx +0 -132
  293. package/src/tool/TextEditTool.tsx +0 -193
  294. package/src/tool/index.ts +0 -101
  295. package/src/typings.d.ts +0 -5
  296. package/src/util/animation.ts +0 -29
  297. package/src/util/browser.ts +0 -4
  298. package/src/util/compatible.ts +0 -15
  299. package/src/util/drag.ts +0 -220
  300. package/src/util/edge.ts +0 -1060
  301. package/src/util/geometry.ts +0 -55
  302. package/src/util/graph.ts +0 -46
  303. package/src/util/index.ts +0 -17
  304. package/src/util/matrix.ts +0 -129
  305. package/src/util/mobx.ts +0 -23
  306. package/src/util/node.ts +0 -543
  307. package/src/util/raf.ts +0 -28
  308. package/src/util/resize.ts +0 -606
  309. package/src/util/sampling.ts +0 -85
  310. package/src/util/theme.ts +0 -375
  311. package/src/util/uuid.ts +0 -26
  312. package/src/util/vector.ts +0 -93
  313. package/src/util/zIndex.ts +0 -6
  314. package/src/view/Anchor.tsx +0 -445
  315. package/src/view/Control.tsx +0 -512
  316. package/src/view/Graph.tsx +0 -141
  317. package/src/view/Rotate.tsx +0 -113
  318. package/src/view/behavior/dnd.ts +0 -162
  319. package/src/view/behavior/index.ts +0 -2
  320. package/src/view/behavior/snapline.ts +0 -16
  321. package/src/view/edge/AdjustPoint.tsx +0 -425
  322. package/src/view/edge/Arrow.tsx +0 -54
  323. package/src/view/edge/BaseEdge.tsx +0 -650
  324. package/src/view/edge/BezierEdge.tsx +0 -101
  325. package/src/view/edge/LineEdge.tsx +0 -81
  326. package/src/view/edge/PolylineEdge.tsx +0 -299
  327. package/src/view/edge/index.ts +0 -6
  328. package/src/view/index.ts +0 -8
  329. package/src/view/node/BaseNode.tsx +0 -571
  330. package/src/view/node/CircleNode.tsx +0 -21
  331. package/src/view/node/DiamondNode.tsx +0 -24
  332. package/src/view/node/EllipseNode.tsx +0 -22
  333. package/src/view/node/HtmlNode.tsx +0 -95
  334. package/src/view/node/PolygonNode.tsx +0 -28
  335. package/src/view/node/RectNode.tsx +0 -30
  336. package/src/view/node/TextNode.tsx +0 -39
  337. package/src/view/node/index.ts +0 -8
  338. package/src/view/overlay/BackgroundOverlay.tsx +0 -34
  339. package/src/view/overlay/BezierAdjustOverlay.tsx +0 -150
  340. package/src/view/overlay/CanvasOverlay.tsx +0 -288
  341. package/src/view/overlay/Grid.tsx +0 -162
  342. package/src/view/overlay/ModificationOverlay.tsx +0 -31
  343. package/src/view/overlay/OutlineOverlay.tsx +0 -170
  344. package/src/view/overlay/SnaplineOverlay.tsx +0 -44
  345. package/src/view/overlay/ToolOverlay.tsx +0 -65
  346. package/src/view/overlay/getTransformHoc.tsx +0 -50
  347. package/src/view/overlay/index.ts +0 -8
  348. package/src/view/shape/Circle.tsx +0 -41
  349. package/src/view/shape/Ellipse.tsx +0 -42
  350. package/src/view/shape/Line.tsx +0 -39
  351. package/src/view/shape/Path.tsx +0 -22
  352. package/src/view/shape/Polygon.tsx +0 -91
  353. package/src/view/shape/Polyline.tsx +0 -31
  354. package/src/view/shape/Rect.tsx +0 -44
  355. package/src/view/shape/Text.tsx +0 -169
  356. package/src/view/shape/index.ts +0 -8
  357. package/src/view/text/BaseText.tsx +0 -134
  358. package/src/view/text/LineText.tsx +0 -168
  359. package/src/view/text/index.ts +0 -2
  360. package/stats.html +0 -4842
  361. package/tsconfig.json +0 -18
@@ -0,0 +1,446 @@
1
+ ---
2
+ nav: Guide
3
+ group:
4
+ title: Plug-in functionality
5
+ order: 3
6
+ title: Adapter
7
+ order: 10
8
+ toc: content
9
+ ---
10
+
11
+ ## Data format of LogicFlow
12
+
13
+ In LogicFlow, graph is composed of **nodes** and **edges**.
14
+
15
+ - For a node, we need to know the **id**, [type](adapter.en.md#type), **position**, **text**, [properties](adapter.en.md#properties) of the node.
16
+ - For an edge, we then need to know the **id**, [type](adapter.en.md#type), start node id (*
17
+ *sourceNodeId**), target node id (**targetNodeId**), **text
18
+ **, [properties](adapter.en.md#properties) and the start position of the edge (**startPoint**),
19
+ and the end position of the edge (**endPoint**).
20
+
21
+ - Extra data for the fold line `pointsList`, since the fold line can be manually adjusted by the
22
+ user, this field is added to record the exact path of this fold line.
23
+
24
+ ### Type
25
+
26
+ In LogicFlow, information about the appearance of a node such as its width, height, color, etc. is
27
+ not stored in the data, but is represented uniformly by the type of the node. For example, if we
28
+ define a node as "startNode" through LogicFlow's customization mechanism, then the current project
29
+ should know what the node with type startNode looks like.
30
+
31
+ ### properties
32
+
33
+ properties is an empty object reserved by LogicFlow for developers to bind any data to. As mentioned
34
+ above, the exact appearance of a node is determined by its type. However, when we need to adjust the
35
+ appearance of a node based on certain business conditions, we can put those conditions into
36
+ properties, and then when customizing the node, we can get the properties through
37
+ the `this.props.model` method, and then reset the style of the node based on the contents of the
38
+ properties. node based on the contents of the properties.
39
+
40
+ ### Usage
41
+
42
+ ```tsx | pure
43
+ lf.render({
44
+ nodes: [
45
+ {
46
+ id: '1',
47
+ type: 'rect',
48
+ x: 100,
49
+ y: 100,
50
+ },
51
+ {
52
+ id: '2',
53
+ type: 'circle',
54
+ x: 300,
55
+ y: 200,
56
+ },
57
+ ],
58
+ edges: [
59
+ {
60
+ id: 'edge1',
61
+ type: 'polyline',
62
+ sourceNodeId: '1',
63
+ targetNodeId: '2',
64
+ startPoint: { x: 150, y: 100 },
65
+ endPoint: { x: 250, y: 200 },
66
+ pointsList: [
67
+ { x: 150, y: 100 },
68
+ { x: 200, y: 100 },
69
+ { x: 200, y: 200 },
70
+ { x: 250, y: 200 },
71
+ ],
72
+ },
73
+ ],
74
+ })
75
+ ```
76
+
77
+ ## What is a Data Conversion Tool
78
+
79
+ In some cases, the data format generated by LogicFlow may not meet the format required by the
80
+ business. For example, if the back-end requires data in the format generated by bpmn-js, you can use
81
+ the data conversion tool to convert the data generated by LogicFlow to the data generated by
82
+ bpmn-js.
83
+
84
+ ## How to Customize Data Conversion Tools
85
+
86
+ A custom data conversion tool essentially takes the data passed in by the user and converts it to a
87
+ format that LogicFlow recognizes via an `lf.adapterIn` method. Then when generating the data, it
88
+ converts LogicFlow's data to the user's incoming data via the `lf.adapterOut` method. So to
89
+ customize the data conversion tool we just need to override these two methods again.
90
+
91
+ ```tsx | pure
92
+ const lf = new LogicFlow({
93
+ container: document.querySelector("#app"),
94
+ });
95
+ lf.adapterIn = function(userData) {
96
+ // Here the userData is converted to a format supported by LogicFlow
97
+ return logicFlowData;
98
+ };
99
+ lf.adapterOut = function(logicFlowData) {
100
+ // Here the data generated by LogicFlow is converted into the format required by the user.
101
+ return userData;
102
+ };
103
+ // If additional parameters are needed, you can also define them like this
104
+ lf.adapterOut = function(logicFlowData, params, ...rest) {
105
+ console.log(params, ...rest);
106
+ return userData;
107
+ };
108
+ ```
109
+
110
+ ## Use the built-in data conversion tools {#use-built-in-data-conversion-tool}
111
+
112
+ LogicFlow has a built-in generic bpmn-js compatible conversion tool. You can support to display the
113
+ graph drawn on LogicFlow on bpmn-js, and also support to display the graph drawn on bpmn-js on
114
+ LogicFlow.[LogicFlow2Bpmn](https://github.com/didi/LogicFlow/tree/master/packages/extension/src/bpmn-adapter)
115
+
116
+ ### bpmnAdapter
117
+
118
+ ```tsx | pure
119
+ import LogicFlow from "@logicflow/core";
120
+ import { BpmnAdapter } from "@logicflow/extension";
121
+
122
+ LogicFlow.use(BpmnAdapter);
123
+
124
+ const lf = new LogicFlow();
125
+ lf.render();
126
+
127
+ // Get the converted data via getGraphData.
128
+ // Since version 1.2.5, getGraphData has been added as an input parameter to ensure that certain adapterOut's are executed correctly, e.g. the adapterOut of the bpmn-adapter in this case has an optional input parameter "retainedFields".
129
+ // This means that a field that appears in this array will not be considered a node but a property when its value is an array or an object. We have defined some default property fields such as "properties", "startPoint", "endPoint", "pointsList", which are obviously not sufficient for data processing.
130
+ // So in order to ensure that certain node attributes are processed properly in the exported data, pass in an array of attribute reserved fields as needed. e.g. lf.getGraphData(['attribute-a', 'attribute-b'])
131
+
132
+ lf.getGraphData();
133
+ ```
134
+
135
+ ### Example of conversion results
136
+
137
+ <!-- TODO -->
138
+ <a href="https://examples.logic-flow.cn/demo/dist/examples/#/extension/adapter?from=doc" target="_blank"> Go to CodeSandbox for examples </a>
139
+
140
+ ## New BPMNAdapter
141
+
142
+ ### what's the difference?
143
+
144
+ The new bpmn-adapter has been upgraded somewhat from the previous `BpmnAdapter` by allowing an
145
+ additional object to be passed in as an input parameter when calling adapterIn and adapterOut
146
+
147
+ ```tsx | pure
148
+ type ExtraPropsType = {
149
+ /**
150
+ * retainedAttrsFields retainedAttrsFields will be merged with the default defaultRetainedProperties:.
151
+ * ["properties", "startPoint", "endPoint", "pointsList"].
152
+ * This means that a field that appears in this array will not be considered a node but a property when its value is an array or an object.
153
+ */
154
+ retainedAttrsFields?: string[];
155
+
156
+ /**
157
+ * excludeFields will be merged with the default defaultExcludeFields.
158
+ * Fields appearing in this array will be ignored in exports
159
+ */
160
+ excludeFields?: {
161
+ in?: Set<string>;
162
+ out?: Set<string>;
163
+ };
164
+
165
+ /**
166
+ * transformer is an array, each item in the array is an object, the object contains in and out two properties
167
+ * in function receives two parameters key and data, key is the key of the current processing object, that is, the node name, data for the current object, when the import will call this function, the imported data processing, to get the desired data
168
+ * out function receives one parameter data, data for the current processing node data, when the export will call this function, the need to export the data processing, to get our desired data
169
+ */
170
+ transformer?: {
171
+ [key: string]: {
172
+ in?: (key: string, data: any) => any;
173
+ out?: (data: any) => any;
174
+ }
175
+ };
176
+
177
+ mapping?: {
178
+ in?: {
179
+ [key: string]: string;
180
+ };
181
+ out?: {
182
+ [key: string]: string;
183
+ };
184
+ };
185
+ };
186
+ ```
187
+
188
+ ### Usage
189
+
190
+ ```tsx | pure
191
+ // step 1 Introducing the adapter plugin
192
+ import { BPMNAdapter } from '@logicflow/extension';
193
+ // step 2 Registration Plugin
194
+ LogicFlow.use(BPMNAdapter)
195
+
196
+ //...
197
+ // step 3-1 Calling the default export
198
+ const xmlResult = lf.adapterOut(lf.getGraphRawData())
199
+ ```
200
+
201
+ 很多时候,我们可能需要一些额外的参数帮助我们正确的进行导入导出,这时我们需要用到上面提到的adapterOut额外的入参ExtraPropsType
202
+
203
+ ```tsx | pure
204
+ // step 3-2 Use the second parameter ExtraPropsType of adapterOut to export the
205
+
206
+ // Suppose we have a panels property in our node attribute, which is an array, but we don't want it to be treated as a node, but as an attribute, then we can do this
207
+ const extraProps = {
208
+ retainedAttrsFields: ['panels']
209
+ }
210
+ // Suppose we have a runboost attribute in our node properties, but we want to export without it, then we can do something like this
211
+ extraProps.excludeFields = {
212
+ out: new Set(['runboost'])
213
+ }
214
+ ```
215
+
216
+ If we want to export a sequenceFlow containing judgment conditions in the correct XML format, and
217
+ import it with the correct processing to get the data we want, then we can do this:
218
+
219
+ ``` xml
220
+ <!-- Sequential Streaming XML Data Format: -->
221
+
222
+ <bpmn:sequenceFlow id="SequenceFlow_0j5q1qk" sourceRef="StartEvent_1" targetRef="Activity_0j5q1qk"/>
223
+
224
+ <!-- When judgment conditions are included -->
225
+
226
+ <bpmn:sequenceFlow id="SequenceFlow_0j5q1qk" sourceRef="StartEvent_1" targetRef="Activity_0j5q1qk">
227
+ <bpmn:conditionExpression xsi:type="bpmn2:tFormalExpression">
228
+ <![CDATA[${runboost === '1'}]]>
229
+ </bpmn:conditionExpression>
230
+ </bpmn:sequenceFlow>
231
+ <!-- or -->
232
+ <bpmn:sequenceFlow id="SequenceFlow_0j5q1qk" sourceRef="StartEvent_1" targetRef="Activity_0j5q1qk">
233
+ <bpmn:conditionExpression xsi:type="bpmn2:tFormalExpression">
234
+ runboost === '1'
235
+ </bpmn:conditionExpression>
236
+ </bpmn:sequenceFlow>
237
+ ```
238
+
239
+ ```tsx | pure
240
+ /**
241
+ * Taking the example of a sequence flow containing a judgment condition.
242
+ * When doing the import, we need to extract the properties within the <bpmn:sequenceFlow>'s child element, <bpmn:conditionExpression>, * and
243
+ * and eventually into the properties attribute of the parent element bpmn:sequenceFlow
244
+ * so the content within <bpmn:conditionExpression> that we actually need to process when importing.
245
+ * it is processed and the data is merged into the properties property of bpmn:sequenceFlow
246
+ */
247
+ extraProps.transformer = {
248
+ 'bpmn:sequenceFlow': {
249
+ out(data: any) {
250
+ const { properties: { expressionType, condition } } = data;
251
+ if (condition) {
252
+ if (expressionType === 'cdata') {
253
+ return {
254
+ json:
255
+ `<bpmn:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[\${${
256
+ condition
257
+ }}]]></bpmn:conditionExpression>`,
258
+ };
259
+ }
260
+ return {
261
+ json: `<bpmn:conditionExpression xsi:type="bpmn2:tFormalExpression">${condition}</bpmn:conditionExpression>`,
262
+ };
263
+ }
264
+ return {
265
+ json: '',
266
+ };
267
+ },
268
+ },
269
+ // The returned data is merged into the properties attribute of the parent element bpmn:sequenceFlow
270
+ 'bpmn:conditionExpression': {
271
+ in(_key: string, data: any) {
272
+ let condition = '';
273
+ let expressionType = '';
274
+ if (data['#cdata-section']) {
275
+ expressionType = 'cdata';
276
+ condition = /^\$\{(.*)\}$/g.exec(data['#cdata-section'])?.[1] || '';
277
+ } else if (data['#text']) {
278
+ expressionType = 'normal';
279
+ condition = data['#text'];
280
+ }
281
+ return {
282
+ '-condition': condition,
283
+ '-expressionType': expressionType,
284
+ };
285
+ },
286
+ },
287
+ }
288
+ ```
289
+
290
+ *** The principle of data import and export is that parent elements are handled when exporting;
291
+ child elements are handled when importing. ***
292
+
293
+ - When exporting, we need to get the data we need from the parent element's attributes and splice
294
+ out the child element.
295
+ - When importing, we need to extract the data we need from the child element and put it into the
296
+ attribute of the parent element.
297
+
298
+ After configuring the required extraProps, we need to register the plugin by passing in the
299
+
300
+ ```tsx | pure
301
+ LogicFlow.use(BPMNAdapter, extraProps)
302
+ ```
303
+
304
+ Currently, we have built-in transformers **(for reference only)**:
305
+
306
+ > Note: The built-in transformers are for reference only, these transformers are used to work with
307
+ > the bpmn node plugin in the process of writing, inside such
308
+ > as `timerType`, `timerValue`, `definitionId`, are configured through the bpmn node plugin's
309
+ > definitionConfig. When actually using the data transformation plugin, you can not use the bpmn node
310
+ > plugin, through your own way to add properties to the node, customize the transformer to achieve the
311
+ > data transformation that meets your needs.
312
+
313
+ ```tsx | pure
314
+
315
+ let defaultTransformer: TransformerType = {
316
+ 'bpmn:startEvent': {
317
+ out(data: any) {
318
+ const { properties } = data;
319
+ return defaultTransformer[properties.definitionType]?.out(data) || {};
320
+ },
321
+ },
322
+ 'bpmn:intermediateCatchEvent': {
323
+ out(data: any) {
324
+ const { properties } = data;
325
+ return defaultTransformer[properties.definitionType]?.out(data) || {};
326
+ },
327
+ },
328
+ 'bpmn:intermediateThrowEvent': {
329
+ out(data: any) {
330
+ const { properties } = data;
331
+ return defaultTransformer[properties.definitionType]?.out(data) || {};
332
+ },
333
+ },
334
+ 'bpmn:boundaryEvent': {
335
+ out(data: any) {
336
+ const { properties } = data;
337
+ return defaultTransformer[properties.definitionType]?.out(data) || {};
338
+ },
339
+ },
340
+ 'bpmn:sequenceFlow': {
341
+ out(data: any) {
342
+ const {
343
+ properties: { expressionType, condition },
344
+ } = data;
345
+ if (condition) {
346
+ if (expressionType === 'cdata') {
347
+ return {
348
+ json:
349
+ `<bpmn:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[\${${
350
+ condition
351
+ }}]]></bpmn:conditionExpression>`,
352
+ };
353
+ }
354
+ return {
355
+ json: `<bpmn:conditionExpression xsi:type="bpmn2:tFormalExpression">${condition}</bpmn:conditionExpression>`,
356
+ };
357
+ }
358
+ return {
359
+ json: '',
360
+ };
361
+
362
+ },
363
+ },
364
+ 'bpmn:timerEventDefinition': {
365
+ out(data: any) {
366
+ // Here timerType, timerValue, definitionId
367
+ // These are all properties configured in the definitionConfig when extending the node via the Bpmn node plugin, so you need to modify the out function according to your own settings when you use it.
368
+ const {
369
+ properties: { timerType, timerValue, definitionId },
370
+ } = data;
371
+
372
+ const typeFunc = () => `<bpmn:${timerType} xsi:type="bpmn:tFormalExpression">${timerValue}</bpmn:${timerType}>`;
373
+
374
+ return {
375
+ json:
376
+ `<bpmn:timerEventDefinition id="${definitionId}"${
377
+ timerType && timerValue
378
+ ? `>${typeFunc()}</bpmn:timerEventDefinition>`
379
+ : '/>'}`,
380
+ };
381
+ },
382
+ in(key: string, data: any) {
383
+ const definitionType = key;
384
+ const definitionId = data['-id'];
385
+ let timerType = '';
386
+ let timerValue = '';
387
+ for (const key of Object.keys(data)) {
388
+ if (key.includes('bpmn:')) {
389
+ [, timerType] = key.split(':');
390
+ timerValue = data[key]?.['#text'];
391
+ }
392
+ }
393
+ return {
394
+ '-definitionId': definitionId,
395
+ '-definitionType': definitionType,
396
+ '-timerType': timerType,
397
+ '-timerValue': timerValue,
398
+ };
399
+ },
400
+ },
401
+ 'bpmn:conditionExpression': {
402
+ in(_key: string, data: any) {
403
+ let condition = '';
404
+ let expressionType = '';
405
+ if (data['#cdata-section']) {
406
+ expressionType = 'cdata';
407
+ condition = /^\$\{(.*)\}$/g.exec(data['#cdata-section'])?.[1] || '';
408
+ } else if (data['#text']) {
409
+ expressionType = 'normal';
410
+ condition = data['#text'];
411
+ }
412
+
413
+ return {
414
+ '-condition': condition,
415
+ '-expressionType': expressionType,
416
+ };
417
+ },
418
+ },
419
+ };
420
+
421
+ ```
422
+
423
+ The incoming transformer and the default transformer are passed through the
424
+
425
+ ```tsx | pure
426
+
427
+ const mergeInNOutObject = (target: any, source: any): TransformerType => {
428
+ const sourceKeys = Object.keys(source);
429
+ sourceKeys.forEach((key) => {
430
+ if (target[key]) {
431
+ const { in: fnIn, out: fnOut } = source[key];
432
+ if (fnIn) {
433
+ target[key].in = fnIn;
434
+ }
435
+ if (fnOut) {
436
+ target[key].out = fnOut;
437
+ }
438
+ } else {
439
+ target[key] = source[key];
440
+ }
441
+ });
442
+ return target;
443
+ };
444
+ ```
445
+
446
+ carry out a merger