@blueking/flow-canvas 0.0.1 → 0.0.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 (2) hide show
  1. package/README.md +14 -21
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -81,6 +81,7 @@ npm install @antv/x6 @antv/x6-plugin-minimap @antv/x6-plugin-selection @antv/x6-
81
81
  CanvasRuntime,
82
82
  CanvasLayout,
83
83
  CanvasToolbar,
84
+ createBuiltinEdgeTypes,
84
85
  selectionPlugin,
85
86
  snaplinePlugin,
86
87
  connectionValidatorPlugin,
@@ -91,24 +92,19 @@ npm install @antv/x6 @antv/x6-plugin-minimap @antv/x6-plugin-selection @antv/x6-
91
92
  import '@blueking/flow-canvas/style';
92
93
  import MyTaskNode from './components/my-task-node.vue';
93
94
 
95
+ const builtinEdgeTypes = createBuiltinEdgeTypes();
96
+
94
97
  const schema: CanvasSchema = {
95
98
  nodeTypes: {
96
99
  task: {
97
100
  component: MyTaskNode,
98
101
  getSize: () => ({ width: 180, height: 60 }),
99
- getPorts: () => [
100
- { id: 'left', group: 'left' },
101
- { id: 'right', group: 'right' },
102
- ],
103
102
  },
104
103
  },
105
104
  edgeTypes: {
106
- default: {
107
- router: { name: 'manhattan', args: { padding: 10 } },
108
- connector: 'rounded',
109
- },
105
+ bezier: builtinEdgeTypes.bezier,
110
106
  },
111
- defaultEdgeType: 'default',
107
+ defaultEdgeType: 'bezier',
112
108
  };
113
109
 
114
110
  const initialFlowModel: FlowModel = {
@@ -152,6 +148,8 @@ npm install @antv/x6 @antv/x6-plugin-minimap @antv/x6-plugin-selection @antv/x6-
152
148
  </script>
153
149
  ```
154
150
 
151
+ 这个示例刻意省略了 `getPorts`,因为当前版本在未提供 `getPorts` / `node.ports` 时会自动补齐默认四向端口,普通自定义节点通常只需要关注 `component` 和 `getSize`。
152
+
155
153
  <br>
156
154
 
157
155
  ## 核心 API
@@ -1147,18 +1145,17 @@ const customItems = [
1147
1145
  ### 在 Schema 中注册节点组件
1148
1146
 
1149
1147
  ```typescript
1148
+ import { createBuiltinEdgeTypes } from '@blueking/flow-canvas';
1150
1149
  import MyTaskNode from './components/my-task-node.vue';
1151
1150
  import MyGatewayNode from './components/my-gateway-node.vue';
1152
1151
 
1152
+ const builtinEdgeTypes = createBuiltinEdgeTypes();
1153
+
1153
1154
  const schema: CanvasSchema = {
1154
1155
  nodeTypes: {
1155
1156
  task: {
1156
1157
  component: MyTaskNode,
1157
1158
  getSize: () => ({ width: 180, height: 60 }),
1158
- getPorts: () => [
1159
- { id: 'left', group: 'left' },
1160
- { id: 'right', group: 'right' },
1161
- ],
1162
1159
  getBehavior: (node, ctx) => ({
1163
1160
  deletable: true,
1164
1161
  copyable: true,
@@ -1181,18 +1178,14 @@ const schema: CanvasSchema = {
1181
1178
  },
1182
1179
  },
1183
1180
  edgeTypes: {
1184
- default: {
1185
- connector: { name: 'smooth' },
1186
- style: (_edge, state) => ({
1187
- stroke: state.hovered ? '#3a84ff' : '#abb5cc',
1188
- strokeWidth: 2,
1189
- }),
1190
- },
1181
+ bezier: builtinEdgeTypes.bezier,
1191
1182
  },
1192
- defaultEdgeType: 'default',
1183
+ defaultEdgeType: 'bezier',
1193
1184
  };
1194
1185
  ```
1195
1186
 
1187
+ 上面这个例子里,`task` 故意不写 `getPorts`,直接复用引擎默认四向端口;`gateway` 保留 `getPorts`,用于演示“当节点需要显式控制端口拓扑时再覆盖默认行为”。
1188
+
1196
1189
  <br>
1197
1190
 
1198
1191
  ## CanvasApi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueking/flow-canvas",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "通用流程画布编辑引擎",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs.js",