@blueking/flow-canvas 0.0.1-beta.3 → 0.0.1
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/README.md +141 -15
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +819 -33
- package/dist/index.esm.js +1067 -932
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/dist/core/apply-command.d.ts +0 -11
- package/dist/core/editor.d.ts +0 -50
- package/dist/core/errors.d.ts +0 -6
- package/dist/core/history.d.ts +0 -15
- package/dist/core/plugin-manager.d.ts +0 -58
- package/dist/plugins/clipboard.d.ts +0 -9
- package/dist/plugins/connection-validator.d.ts +0 -3
- package/dist/plugins/minimap.d.ts +0 -7
- package/dist/plugins/selection.d.ts +0 -7
- package/dist/plugins/snapline.d.ts +0 -6
- package/dist/runtime/canvas-api.d.ts +0 -25
- package/dist/runtime/canvas-runtime-core.vue.d.ts +0 -31
- package/dist/runtime/event-bridge.d.ts +0 -28
- package/dist/runtime/graph-bridge.d.ts +0 -127
- package/dist/runtime/overlay-manager.d.ts +0 -3
- package/dist/runtime/shape-registry.d.ts +0 -8
- package/dist/runtime/use-edge-delete-tool.d.ts +0 -11
- package/dist/runtime/use-node-hover.d.ts +0 -10
- package/dist/runtime/use-port-visibility.d.ts +0 -15
- package/dist/shell/canvas-layout.vue.d.ts +0 -35
- package/dist/shell/canvas-node-palette.vue.d.ts +0 -10
- package/dist/shell/canvas-toolbar.vue.d.ts +0 -11
- package/dist/shell/default-node.vue.d.ts +0 -4
- package/dist/shell/default-schema.d.ts +0 -39
- package/dist/shell/node-actions-toolbar.vue.d.ts +0 -22
- package/dist/shell/node-quick-add-popover.vue.d.ts +0 -36
- package/dist/shell/toolbar-items.d.ts +0 -15
- package/dist/types/api.d.ts +0 -104
- package/dist/types/command.d.ts +0 -160
- package/dist/types/flow-model.d.ts +0 -46
- package/dist/types/history.d.ts +0 -18
- package/dist/types/overlay.d.ts +0 -3
- package/dist/types/plugin.d.ts +0 -64
- package/dist/types/schema.d.ts +0 -80
- package/dist/utils/path.d.ts +0 -7
- package/dist/utils/uuid.d.ts +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,33 +1,819 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { Ref, Component } from 'vue';
|
|
3
|
+
import { Graph } from '@antv/x6';
|
|
4
|
+
|
|
5
|
+
interface FlowModel {
|
|
6
|
+
version?: '1.0';
|
|
7
|
+
nodes: Record<string, FlowNodeModel>;
|
|
8
|
+
edges: Record<string, FlowEdgeModel>;
|
|
9
|
+
meta?: Record<string, unknown>;
|
|
10
|
+
extensions?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
interface FlowNodeModel {
|
|
13
|
+
id: string;
|
|
14
|
+
type: string;
|
|
15
|
+
position: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
};
|
|
19
|
+
label?: string;
|
|
20
|
+
ports?: FlowPortModel[];
|
|
21
|
+
payload?: Record<string, unknown>;
|
|
22
|
+
extensions?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
interface FlowEdgeModel {
|
|
25
|
+
id: string;
|
|
26
|
+
type?: string;
|
|
27
|
+
source: {
|
|
28
|
+
nodeId: string;
|
|
29
|
+
portId?: string;
|
|
30
|
+
};
|
|
31
|
+
target: {
|
|
32
|
+
nodeId: string;
|
|
33
|
+
portId?: string;
|
|
34
|
+
};
|
|
35
|
+
labels?: FlowEdgeLabelModel[];
|
|
36
|
+
payload?: Record<string, unknown>;
|
|
37
|
+
extensions?: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
interface FlowPortModel {
|
|
40
|
+
id: string;
|
|
41
|
+
group: 'top' | 'right' | 'bottom' | 'left' | string;
|
|
42
|
+
x6PortConfig?: Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
interface FlowEdgeLabelModel {
|
|
45
|
+
id: string;
|
|
46
|
+
text?: string;
|
|
47
|
+
position?: number;
|
|
48
|
+
payload?: Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
declare function createEmptyFlowModel(): FlowModel;
|
|
51
|
+
|
|
52
|
+
type CanvasCommand = {
|
|
53
|
+
type: 'node.add';
|
|
54
|
+
node: FlowNodeModel;
|
|
55
|
+
} | {
|
|
56
|
+
type: 'node.move';
|
|
57
|
+
nodeId: string;
|
|
58
|
+
position: {
|
|
59
|
+
x: number;
|
|
60
|
+
y: number;
|
|
61
|
+
};
|
|
62
|
+
} | {
|
|
63
|
+
type: 'node.remove';
|
|
64
|
+
nodeId: string;
|
|
65
|
+
} | {
|
|
66
|
+
type: 'node.update';
|
|
67
|
+
nodeId: string;
|
|
68
|
+
patch: Partial<Omit<FlowNodeModel, 'id' | 'payload' | 'extensions'>>;
|
|
69
|
+
} | {
|
|
70
|
+
type: 'node.set-payload';
|
|
71
|
+
nodeId: string;
|
|
72
|
+
path: string[];
|
|
73
|
+
value: unknown;
|
|
74
|
+
} | {
|
|
75
|
+
type: 'node.set-extensions';
|
|
76
|
+
nodeId: string;
|
|
77
|
+
path: string[];
|
|
78
|
+
value: unknown;
|
|
79
|
+
} | {
|
|
80
|
+
type: 'edge.add';
|
|
81
|
+
edge: FlowEdgeModel;
|
|
82
|
+
} | {
|
|
83
|
+
type: 'edge.remove';
|
|
84
|
+
edgeId: string;
|
|
85
|
+
} | {
|
|
86
|
+
type: 'edge.reconnect';
|
|
87
|
+
edgeId: string;
|
|
88
|
+
source?: {
|
|
89
|
+
nodeId: string;
|
|
90
|
+
portId?: string;
|
|
91
|
+
};
|
|
92
|
+
target?: {
|
|
93
|
+
nodeId: string;
|
|
94
|
+
portId?: string;
|
|
95
|
+
};
|
|
96
|
+
} | {
|
|
97
|
+
type: 'edge.update';
|
|
98
|
+
edgeId: string;
|
|
99
|
+
patch: Partial<Omit<FlowEdgeModel, 'id' | 'payload' | 'extensions'>>;
|
|
100
|
+
} | {
|
|
101
|
+
type: 'edge.set-payload';
|
|
102
|
+
edgeId: string;
|
|
103
|
+
path: string[];
|
|
104
|
+
value: unknown;
|
|
105
|
+
} | {
|
|
106
|
+
type: 'edge.label.update';
|
|
107
|
+
edgeId: string;
|
|
108
|
+
labelId: string;
|
|
109
|
+
patch: Partial<FlowEdgeLabelModel>;
|
|
110
|
+
} | {
|
|
111
|
+
type: 'model.set-meta';
|
|
112
|
+
path: string[];
|
|
113
|
+
value: unknown;
|
|
114
|
+
};
|
|
115
|
+
type CommandSource = 'user:drag' | 'user:keyboard' | 'user:toolbar' | 'user:quick-add' | 'user:panel' | 'plugin' | 'system' | 'system:replace';
|
|
116
|
+
interface CommandEnvelope {
|
|
117
|
+
id: string;
|
|
118
|
+
label?: string;
|
|
119
|
+
source: CommandSource;
|
|
120
|
+
timestamp: number;
|
|
121
|
+
commands: CanvasCommand[];
|
|
122
|
+
}
|
|
123
|
+
interface CommandExecutionResult {
|
|
124
|
+
status: 'applied' | 'rejected' | 'invalid';
|
|
125
|
+
envelope: Readonly<CommandEnvelope>;
|
|
126
|
+
flowModel?: FlowModel;
|
|
127
|
+
error?: CommandExecutionError;
|
|
128
|
+
}
|
|
129
|
+
interface CommandExecutionError {
|
|
130
|
+
code: 'plugin_rejected' | 'validation_failed' | 'constraint_violated';
|
|
131
|
+
reason: string;
|
|
132
|
+
source: string;
|
|
133
|
+
details?: unknown;
|
|
134
|
+
}
|
|
135
|
+
interface CommandRejection {
|
|
136
|
+
rejected: true;
|
|
137
|
+
reason: string;
|
|
138
|
+
code?: string;
|
|
139
|
+
}
|
|
140
|
+
interface CommandPreview {
|
|
141
|
+
previewFlowModel(commands?: CanvasCommand[]): FlowModel;
|
|
142
|
+
}
|
|
143
|
+
interface FlowModelChangeEvent {
|
|
144
|
+
flowModel: Readonly<FlowModel>;
|
|
145
|
+
prevFlowModel: Readonly<FlowModel>;
|
|
146
|
+
envelope: Readonly<CommandEnvelope>;
|
|
147
|
+
source: CommandSource;
|
|
148
|
+
}
|
|
149
|
+
type ScreenPosition = {
|
|
150
|
+
x: number;
|
|
151
|
+
y: number;
|
|
152
|
+
};
|
|
153
|
+
type CanvasPosition = {
|
|
154
|
+
x: number;
|
|
155
|
+
y: number;
|
|
156
|
+
};
|
|
157
|
+
type CanvasUiEvent = {
|
|
158
|
+
type: 'node.click';
|
|
159
|
+
nodeId: string;
|
|
160
|
+
} | {
|
|
161
|
+
type: 'node.dblclick';
|
|
162
|
+
nodeId: string;
|
|
163
|
+
} | {
|
|
164
|
+
type: 'node.contextmenu';
|
|
165
|
+
nodeId: string;
|
|
166
|
+
position: ScreenPosition;
|
|
167
|
+
} | {
|
|
168
|
+
type: 'node.quick-add';
|
|
169
|
+
nodeId: string;
|
|
170
|
+
position: ScreenPosition;
|
|
171
|
+
} | {
|
|
172
|
+
type: 'edge.click';
|
|
173
|
+
edgeId: string;
|
|
174
|
+
} | {
|
|
175
|
+
type: 'edge.label.click';
|
|
176
|
+
edgeId: string;
|
|
177
|
+
labelId: string;
|
|
178
|
+
} | {
|
|
179
|
+
type: 'blank.click';
|
|
180
|
+
position: CanvasPosition;
|
|
181
|
+
} | {
|
|
182
|
+
type: 'blank.contextmenu';
|
|
183
|
+
position: ScreenPosition;
|
|
184
|
+
} | {
|
|
185
|
+
type: 'selection.change';
|
|
186
|
+
nodeIds: string[];
|
|
187
|
+
edgeIds: string[];
|
|
188
|
+
} | {
|
|
189
|
+
type: 'node.action.delete';
|
|
190
|
+
nodeId: string;
|
|
191
|
+
} | {
|
|
192
|
+
type: 'node.action.copy';
|
|
193
|
+
sourceNodeId: string;
|
|
194
|
+
newNodeId: string;
|
|
195
|
+
} | {
|
|
196
|
+
type: 'node.action.copy-insert';
|
|
197
|
+
sourceNodeId: string;
|
|
198
|
+
newNodeId: string;
|
|
199
|
+
} | {
|
|
200
|
+
type: 'node.action.disconnect';
|
|
201
|
+
nodeId: string;
|
|
202
|
+
edgeIds: string[];
|
|
203
|
+
} | {
|
|
204
|
+
type: 'node.action.debug';
|
|
205
|
+
nodeId: string;
|
|
206
|
+
} | {
|
|
207
|
+
type: 'node.action.quick-insert';
|
|
208
|
+
sourceNodeId: string;
|
|
209
|
+
newNodeId: string;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
interface CanvasHistory {
|
|
213
|
+
execute(envelope: CommandEnvelope): FlowModel;
|
|
214
|
+
undo(): FlowModel | null;
|
|
215
|
+
redo(): FlowModel | null;
|
|
216
|
+
readonly canUndo: Ref<boolean>;
|
|
217
|
+
readonly canRedo: Ref<boolean>;
|
|
218
|
+
readonly undoStack: readonly CommandEnvelope[];
|
|
219
|
+
readonly redoStack: readonly CommandEnvelope[];
|
|
220
|
+
clear(): void;
|
|
221
|
+
createSnapshot(): FlowModel;
|
|
222
|
+
replaceFlowModel(model: FlowModel): void;
|
|
223
|
+
}
|
|
224
|
+
interface CanvasHistoryOptions {
|
|
225
|
+
maxHistorySize?: number;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
interface OverlayManager {
|
|
229
|
+
getNodeScreenRect(nodeId: string): DOMRect | null;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
interface EditorPluginContext {
|
|
233
|
+
flowModel: Readonly<Ref<FlowModel>>;
|
|
234
|
+
history: CanvasHistory;
|
|
235
|
+
schema: CanvasSchema;
|
|
236
|
+
mode: Ref<CanvasMode>;
|
|
237
|
+
executeCommand(envelope: CommandEnvelope): CommandExecutionResult;
|
|
238
|
+
}
|
|
239
|
+
interface RuntimePluginContext extends EditorPluginContext {
|
|
240
|
+
api: CanvasApi;
|
|
241
|
+
overlay: OverlayManager;
|
|
242
|
+
graph: Graph;
|
|
243
|
+
}
|
|
244
|
+
interface CanvasSelection {
|
|
245
|
+
nodeIds: string[];
|
|
246
|
+
edgeIds: string[];
|
|
247
|
+
}
|
|
248
|
+
interface NodeDecoration {
|
|
249
|
+
className?: string;
|
|
250
|
+
badge?: {
|
|
251
|
+
text: string;
|
|
252
|
+
color: string;
|
|
253
|
+
};
|
|
254
|
+
borderColor?: string;
|
|
255
|
+
}
|
|
256
|
+
interface EdgeDecoration {
|
|
257
|
+
className?: string;
|
|
258
|
+
strokeColor?: string;
|
|
259
|
+
}
|
|
260
|
+
interface ContextMenuItem {
|
|
261
|
+
id: string;
|
|
262
|
+
label: string;
|
|
263
|
+
icon?: Component | string;
|
|
264
|
+
disabled?: boolean;
|
|
265
|
+
action: () => void;
|
|
266
|
+
children?: ContextMenuItem[];
|
|
267
|
+
}
|
|
268
|
+
interface CanvasPlugin {
|
|
269
|
+
name: string;
|
|
270
|
+
priority?: number;
|
|
271
|
+
install?(ctx: EditorPluginContext): void;
|
|
272
|
+
attachRuntime?(ctx: RuntimePluginContext): void;
|
|
273
|
+
detachRuntime?(): void;
|
|
274
|
+
dispose?(): void;
|
|
275
|
+
transformCommand?(envelope: Readonly<CommandEnvelope>, preview: CommandPreview, ctx: EditorPluginContext): CommandEnvelope | CommandRejection | null;
|
|
276
|
+
afterCommand?(envelope: Readonly<CommandEnvelope>, prevModel: Readonly<FlowModel>, newModel: Readonly<FlowModel>, ctx: EditorPluginContext): void;
|
|
277
|
+
onUiEvent?(event: CanvasUiEvent, ctx: RuntimePluginContext): void;
|
|
278
|
+
onSelectionChange?(selection: CanvasSelection, ctx: RuntimePluginContext): void;
|
|
279
|
+
onKeyboardShortcut?(event: KeyboardEvent, ctx: RuntimePluginContext): boolean;
|
|
280
|
+
onBlankContextMenu?(position: ScreenPosition, ctx: RuntimePluginContext): ContextMenuItem[] | void;
|
|
281
|
+
decorateNode?(node: FlowNodeModel, ctx: EditorPluginContext): NodeDecoration | void;
|
|
282
|
+
decorateEdge?(edge: FlowEdgeModel, ctx: EditorPluginContext): EdgeDecoration | void;
|
|
283
|
+
provideToolbarItems?(ctx: EditorPluginContext): CanvasToolbarItem[];
|
|
284
|
+
extendApi?(api: CanvasApi, ctx: RuntimePluginContext): Record<string, Function>;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
type BuiltinToolbarType = 'undo' | 'redo' | 'select' | 'auto-layout' | 'search' | 'minimap' | 'export' | 'zoom-in' | 'zoom-out' | 'zoom-display' | 'fit' | 'reset';
|
|
288
|
+
interface CanvasToolbarItem {
|
|
289
|
+
id: string;
|
|
290
|
+
type: BuiltinToolbarType | 'custom';
|
|
291
|
+
/** CSS 类名(字体图标) */
|
|
292
|
+
icon?: string;
|
|
293
|
+
/** Vue 组件,渲染在按钮内部作为图标/内容区域 */
|
|
294
|
+
component?: Component;
|
|
295
|
+
/** 无图标时的兜底显示文字 */
|
|
296
|
+
text?: string;
|
|
297
|
+
/** 操作说明文案,有值时 hover 按钮显示 CSS tooltip 气泡 */
|
|
298
|
+
description?: string;
|
|
299
|
+
group?: string;
|
|
300
|
+
order?: number;
|
|
301
|
+
visible?: boolean | ((ctx: CanvasCallbackContext) => boolean);
|
|
302
|
+
disabled?: boolean | ((ctx: CanvasCallbackContext) => boolean);
|
|
303
|
+
onClick?: (ctx: CanvasCallbackContext) => void;
|
|
304
|
+
}
|
|
305
|
+
interface ExportOptions {
|
|
306
|
+
backgroundColor?: string;
|
|
307
|
+
padding?: number;
|
|
308
|
+
quality?: number;
|
|
309
|
+
}
|
|
310
|
+
interface NodeActionsConfig {
|
|
311
|
+
showDebug?: boolean;
|
|
312
|
+
showDelete?: boolean;
|
|
313
|
+
showCopy?: boolean;
|
|
314
|
+
showCopyInsert?: boolean;
|
|
315
|
+
showDisconnect?: boolean;
|
|
316
|
+
insertGap?: number;
|
|
317
|
+
}
|
|
318
|
+
interface InsertNodeOptions {
|
|
319
|
+
autoWireEdges?: boolean;
|
|
320
|
+
gap?: number;
|
|
321
|
+
source?: CommandSource;
|
|
322
|
+
label?: string;
|
|
323
|
+
direction?: InsertDirection;
|
|
324
|
+
}
|
|
325
|
+
interface CanvasApi {
|
|
326
|
+
zoomIn(): void;
|
|
327
|
+
zoomOut(): void;
|
|
328
|
+
zoomTo(value: number): void;
|
|
329
|
+
zoomToFit(): void;
|
|
330
|
+
getZoom(): number;
|
|
331
|
+
centerContent(): void;
|
|
332
|
+
scrollToOrigin(): void;
|
|
333
|
+
scrollToNode(nodeId: string): void;
|
|
334
|
+
getSelection(): CanvasSelection;
|
|
335
|
+
selectNodes(ids: string[]): void;
|
|
336
|
+
selectEdges(ids: string[]): void;
|
|
337
|
+
clearSelection(): void;
|
|
338
|
+
registerDndSource(el: HTMLElement, factory: () => FlowNodeModel): () => void;
|
|
339
|
+
startConnection(nodeId: string, portId?: string): void;
|
|
340
|
+
exportAsImage(options?: ExportOptions): Promise<Blob>;
|
|
341
|
+
exportAsSVG(): Promise<string>;
|
|
342
|
+
highlightNodes(nodeIds: string[]): void;
|
|
343
|
+
highlightEdges(edgeIds: string[]): void;
|
|
344
|
+
clearHighlight(): void;
|
|
345
|
+
overlay: OverlayManager;
|
|
346
|
+
/** 收集所有插件为指定坐标提供的右键菜单项,由消费方自行渲染菜单 UI */
|
|
347
|
+
getContextMenuItems(position: ScreenPosition): ContextMenuItem[];
|
|
348
|
+
/**
|
|
349
|
+
* 默认在 sourceNode 右侧插入新节点,也可通过 options.direction 指定 top/right/bottom/left。
|
|
350
|
+
* - 位置:根据 direction 沿对应方向插入,并在垂直/水平方向居中对齐
|
|
351
|
+
* - autoWireEdges=true 时:优先使用 direction 对应的 source 端口与新节点的反向端口自动连线;
|
|
352
|
+
* 否则只创建 source→new 一条边
|
|
353
|
+
* - 所有命令打包在一个 CommandEnvelope 中原子执行
|
|
354
|
+
*/
|
|
355
|
+
insertNodeToRight(sourceNodeId: string, node: Omit<FlowNodeModel, 'position'>, options?: InsertNodeOptions): CommandExecutionResult;
|
|
356
|
+
onGraphEvent<K extends string>(event: K, handler: (...args: unknown[]) => void): () => void;
|
|
357
|
+
unsafeGetGraph(): unknown;
|
|
358
|
+
}
|
|
359
|
+
interface ConnectionValidateContext {
|
|
360
|
+
flowModel: FlowModel;
|
|
361
|
+
sourceNode: FlowNodeModel;
|
|
362
|
+
targetNode: FlowNodeModel;
|
|
363
|
+
sourcePort?: FlowPortModel;
|
|
364
|
+
targetPort?: FlowPortModel;
|
|
365
|
+
existingEdges: FlowEdgeModel[];
|
|
366
|
+
}
|
|
367
|
+
type ConnectionValidateResult = {
|
|
368
|
+
valid: true;
|
|
369
|
+
} | {
|
|
370
|
+
valid: false;
|
|
371
|
+
reason?: string;
|
|
372
|
+
};
|
|
373
|
+
type ConnectionValidator = (ctx: ConnectionValidateContext) => ConnectionValidateResult;
|
|
374
|
+
type InsertDirection = 'top' | 'right' | 'bottom' | 'left';
|
|
375
|
+
type QuickAddPortResolver = (node: FlowNodeModel, ports: FlowPortModel[]) => string | FlowPortModel | null | undefined;
|
|
376
|
+
type QuickAddInsertDirectionResolver = (node: FlowNodeModel, port: FlowPortModel | null) => InsertDirection | null | undefined;
|
|
377
|
+
interface QuickAddConfig {
|
|
378
|
+
/** 全局开关,默认 true */
|
|
379
|
+
enabled?: boolean;
|
|
380
|
+
/** "+"按钮 hover 时的 tooltip 文案 */
|
|
381
|
+
tooltipText?: string;
|
|
382
|
+
/** quick-add 绑定的端口分组,默认 'right';节点不存在该分组端口时将不显示 quick-add */
|
|
383
|
+
portGroup?: string;
|
|
384
|
+
/** 精确指定 quick-add 使用哪个端口;优先级高于 portGroup */
|
|
385
|
+
getPort?: QuickAddPortResolver;
|
|
386
|
+
/** 点击 quick-add 插入节点时使用的方向;默认跟随绑定 port 的标准方向,不可推断时回退为 'right' */
|
|
387
|
+
insertDirection?: InsertDirection | QuickAddInsertDirectionResolver;
|
|
388
|
+
}
|
|
389
|
+
interface NodePaletteItem {
|
|
390
|
+
type: string;
|
|
391
|
+
label: string;
|
|
392
|
+
icon?: string;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
type CanvasMode = 'edit' | 'readonly' | 'thumbnail';
|
|
396
|
+
interface CanvasSchema {
|
|
397
|
+
nodeTypes: Record<string, CanvasNodeDefinition>;
|
|
398
|
+
edgeTypes?: Record<string, CanvasEdgeDefinition>;
|
|
399
|
+
defaultEdgeType?: string;
|
|
400
|
+
}
|
|
401
|
+
interface NodeBehaviorConfig {
|
|
402
|
+
showActions?: boolean;
|
|
403
|
+
showPorts?: boolean;
|
|
404
|
+
draggable?: boolean;
|
|
405
|
+
selectable?: boolean;
|
|
406
|
+
deletable?: boolean;
|
|
407
|
+
connectable?: boolean;
|
|
408
|
+
copyable?: boolean;
|
|
409
|
+
disconnectable?: boolean;
|
|
410
|
+
debuggable?: boolean;
|
|
411
|
+
deleteDisabled?: boolean;
|
|
412
|
+
copyDisabled?: boolean;
|
|
413
|
+
copyInsertDisabled?: boolean;
|
|
414
|
+
disconnectDisabled?: boolean;
|
|
415
|
+
debugDisabled?: boolean;
|
|
416
|
+
/** 逐节点控制右侧"+"快捷添加按钮是否显示,默认跟随全局配置 */
|
|
417
|
+
quickAddEnabled?: boolean;
|
|
418
|
+
/** 快捷操作工具栏的位置偏移(px),相对于默认位置(节点右下角) */
|
|
419
|
+
actionsOffset?: {
|
|
420
|
+
x?: number;
|
|
421
|
+
y?: number;
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
interface CanvasNodeDefinition {
|
|
425
|
+
component: Component;
|
|
426
|
+
getSize: (node: FlowNodeModel) => {
|
|
427
|
+
width: number;
|
|
428
|
+
height: number;
|
|
429
|
+
};
|
|
430
|
+
getPorts?: (node: FlowNodeModel) => FlowPortModel[];
|
|
431
|
+
getBehavior?: (node: FlowNodeModel, ctx: CanvasCallbackContext) => NodeBehaviorConfig;
|
|
432
|
+
x6CellConfig?: Record<string, unknown>;
|
|
433
|
+
}
|
|
434
|
+
interface EdgeRenderState {
|
|
435
|
+
selected: boolean;
|
|
436
|
+
highlighted: boolean;
|
|
437
|
+
hovered: boolean;
|
|
438
|
+
}
|
|
439
|
+
interface EdgeStyle {
|
|
440
|
+
stroke?: string;
|
|
441
|
+
strokeWidth?: number;
|
|
442
|
+
strokeDasharray?: string;
|
|
443
|
+
}
|
|
444
|
+
interface CanvasEdgeDefinition {
|
|
445
|
+
router?: string | {
|
|
446
|
+
name: string;
|
|
447
|
+
args?: Record<string, unknown>;
|
|
448
|
+
};
|
|
449
|
+
connector?: string | {
|
|
450
|
+
name: string;
|
|
451
|
+
args?: Record<string, unknown>;
|
|
452
|
+
};
|
|
453
|
+
/** 根据边模型和渲染状态(selected/highlighted/hovered)返回边的视觉样式 */
|
|
454
|
+
style?: (edge: FlowEdgeModel, state: EdgeRenderState) => EdgeStyle;
|
|
455
|
+
/**
|
|
456
|
+
* @experimental 边标签的自定义渲染组件。
|
|
457
|
+
* 当前版本尚未完整实现(X6 边标签基于 SVG,集成 Vue 组件需要 HTML overlay 方案)。
|
|
458
|
+
* 如需自定义标签样式,建议通过 x6EdgeConfig.defaultLabel 配置 X6 原生标签 markup。
|
|
459
|
+
*/
|
|
460
|
+
labelRenderer?: Component;
|
|
461
|
+
labelDraggable?: boolean;
|
|
462
|
+
x6EdgeConfig?: Record<string, unknown>;
|
|
463
|
+
}
|
|
464
|
+
interface CanvasCallbackContext {
|
|
465
|
+
api: CanvasApi;
|
|
466
|
+
flowModel: FlowModel;
|
|
467
|
+
history: CanvasHistory;
|
|
468
|
+
mode: CanvasMode;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* 纯函数 reducer:将一条原子命令应用到 FlowModel 上,返回新 FlowModel(不可变)。
|
|
473
|
+
* 所有 FlowModel 不变量在此处保证:
|
|
474
|
+
* - 节点/边 id 唯一性
|
|
475
|
+
* - 边端点必须指向存在的节点(及可选的 port)
|
|
476
|
+
* - 删除节点时级联清理关联边
|
|
477
|
+
* - label id 在同一条边内唯一
|
|
478
|
+
*/
|
|
479
|
+
declare function applyCanvasCommand(model: FlowModel, cmd: CanvasCommand): FlowModel;
|
|
480
|
+
|
|
481
|
+
declare class CanvasConstraintError extends Error {
|
|
482
|
+
constructor(message: string);
|
|
483
|
+
}
|
|
484
|
+
declare class CanvasSchemaError extends Error {
|
|
485
|
+
constructor(message: string);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* 基于快照栈的历史系统。
|
|
490
|
+
*
|
|
491
|
+
* 每次 execute 时在 undo 栈中保存执行前的 FlowModel 快照,同时清空 redo 栈。
|
|
492
|
+
* undo 弹出上一个快照恢复 FlowModel;redo 重新执行对应 envelope 的命令序列。
|
|
493
|
+
*
|
|
494
|
+
* 注意:当前实现为完整快照,适用于中小规模 FlowModel。
|
|
495
|
+
* 若 payload 增长导致性能问题,后续可引入结构共享或 checkpoint + patch 混合模式。
|
|
496
|
+
*/
|
|
497
|
+
declare function createCanvasHistory(initialFlowModel: FlowModel, options?: CanvasHistoryOptions): CanvasHistory & {
|
|
498
|
+
currentFlowModel: Ref<FlowModel>;
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* 管理插件的安装、运行时挂载、命令管道和事件分发。
|
|
503
|
+
*
|
|
504
|
+
* 生命周期分两阶段:
|
|
505
|
+
* 1. install(editor 级):在 useCanvasEditor 初始化时调用,此时只有 flowModel/history/schema 可用
|
|
506
|
+
* 2. attachRuntime(runtime 级):在 CanvasRuntime mount 后调用,此时 api/graph/overlay 已就绪
|
|
507
|
+
*
|
|
508
|
+
* 命令管道(transformCommand)为不可变管道:
|
|
509
|
+
* - 插件按 priority 升序执行
|
|
510
|
+
* - 每个插件返回新 envelope 或 null(拒绝)或 CommandRejection
|
|
511
|
+
* - 前一个插件的输出是下一个插件的输入
|
|
512
|
+
*/
|
|
513
|
+
declare class PluginManager {
|
|
514
|
+
private plugins;
|
|
515
|
+
private editorContext;
|
|
516
|
+
private runtimeCtx;
|
|
517
|
+
/** 每次 attachRuntime 递增,detachRuntime 时旧 generation 的异步调用自动作废 */
|
|
518
|
+
private runtimeVersion;
|
|
519
|
+
install(plugins: CanvasPlugin[], ctx: EditorPluginContext): void;
|
|
520
|
+
/**
|
|
521
|
+
* 挂载运行时上下文并调用各插件的 attachRuntime。
|
|
522
|
+
* 异步插件(如动态 import X6 插件)在 await 返回后会检查 generation,
|
|
523
|
+
* 若 detachRuntime 已被调用(generation 已变),则跳过 graph.use() 等操作。
|
|
524
|
+
*/
|
|
525
|
+
attachRuntime(ctx: RuntimePluginContext): void;
|
|
526
|
+
/** 按安装的逆序 detach,保证后安装的插件先释放运行时资源 */
|
|
527
|
+
detachRuntime(): void;
|
|
528
|
+
/**
|
|
529
|
+
* 为 attachRuntime 创建保护代理:graph.use() 等可能在异步回调中调用,
|
|
530
|
+
* 如果在 await 期间 detachRuntime 已执行,代理会将 graph 操作变为 no-op。
|
|
531
|
+
*/
|
|
532
|
+
private createSafeRuntimeContext;
|
|
533
|
+
dispose(): void;
|
|
534
|
+
transformCommand(envelope: Readonly<CommandEnvelope>): {
|
|
535
|
+
envelope: CommandEnvelope;
|
|
536
|
+
} | {
|
|
537
|
+
rejected: true;
|
|
538
|
+
error: CommandExecutionError;
|
|
539
|
+
};
|
|
540
|
+
afterCommand(envelope: Readonly<CommandEnvelope>, prevModel: Readonly<FlowModel>, newModel: Readonly<FlowModel>): void;
|
|
541
|
+
dispatchUiEvent(event: CanvasUiEvent): void;
|
|
542
|
+
dispatchSelectionChange(selection: CanvasSelection): void;
|
|
543
|
+
dispatchKeyboardShortcut(event: KeyboardEvent): boolean;
|
|
544
|
+
collectContextMenuItems(position: ScreenPosition): ContextMenuItem[];
|
|
545
|
+
/** 汇聚所有插件的工具栏项,相同 id 的后注册覆盖先注册,最终按 order 排序 */
|
|
546
|
+
collectToolbarItems(): CanvasToolbarItem[];
|
|
547
|
+
/** 合并所有插件对某节点的装饰(className / borderColor / badge),后注册覆盖先注册 */
|
|
548
|
+
collectNodeDecorations(node: FlowNodeModel): NodeDecoration | undefined;
|
|
549
|
+
/** 合并所有插件对某边的装饰(className / strokeColor),后注册覆盖先注册 */
|
|
550
|
+
collectEdgeDecorations(edge: FlowEdgeModel): EdgeDecoration | undefined;
|
|
551
|
+
collectExtendedApi(): Record<string, Function>;
|
|
552
|
+
/** 基于当前 FlowModel 和待执行命令序列,生成预览 FlowModel 供 transformCommand 使用 */
|
|
553
|
+
private createPreview;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
interface CanvasEditorOptions {
|
|
557
|
+
initialFlowModel: FlowModel;
|
|
558
|
+
schema: CanvasSchema;
|
|
559
|
+
plugins?: CanvasPlugin[];
|
|
560
|
+
mode?: CanvasMode;
|
|
561
|
+
historyOptions?: CanvasHistoryOptions;
|
|
562
|
+
onCommandResult?(result: CommandExecutionResult): void;
|
|
563
|
+
onFlowModelChange?(event: FlowModelChangeEvent): void;
|
|
564
|
+
}
|
|
565
|
+
interface CanvasEditorContext {
|
|
566
|
+
flowModel: Readonly<Ref<FlowModel>>;
|
|
567
|
+
history: CanvasHistory;
|
|
568
|
+
schema: CanvasSchema;
|
|
569
|
+
mode: Ref<CanvasMode>;
|
|
570
|
+
executeCommand(envelope: CommandEnvelope): CommandExecutionResult;
|
|
571
|
+
replaceFlowModel(model: FlowModel): void;
|
|
572
|
+
setMode(mode: CanvasMode): void;
|
|
573
|
+
/** 框选模式:开启后左键拖拽画布空白区域为框选,关闭时为画布平移 */
|
|
574
|
+
selectionMode: Ref<boolean>;
|
|
575
|
+
setSelectionMode(enabled: boolean): void;
|
|
576
|
+
api: Ref<CanvasApi | null>;
|
|
577
|
+
toolbarItems: Readonly<Ref<CanvasToolbarItem[]>>;
|
|
578
|
+
extendedApi: Record<string, Function>;
|
|
579
|
+
/** @internal used by CanvasRuntime */
|
|
580
|
+
_pluginManager: PluginManager;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* 画布编辑引擎的核心 composable。
|
|
584
|
+
*
|
|
585
|
+
* 初始化时完成:
|
|
586
|
+
* 1. 创建 CanvasHistory(快照栈)
|
|
587
|
+
* 2. 安装插件(editor-stage)
|
|
588
|
+
* 3. 暴露 executeCommand / replaceFlowModel / setMode 等 API
|
|
589
|
+
*
|
|
590
|
+
* api(CanvasApi)在 CanvasRuntime mount 后才由 runtime 注入。
|
|
591
|
+
* 在此之前 api.value === null,工具栏等依赖 api 的功能默认禁用。
|
|
592
|
+
*
|
|
593
|
+
* executeCommand 的完整管道:
|
|
594
|
+
* pluginManager.transformCommand → history.execute → applyCanvasCommand
|
|
595
|
+
* → pluginManager.afterCommand → onCommandResult → onFlowModelChange
|
|
596
|
+
*/
|
|
597
|
+
declare function useCanvasEditor(options: CanvasEditorOptions): CanvasEditorContext;
|
|
598
|
+
|
|
599
|
+
type __VLS_Props$5 = {
|
|
600
|
+
editor: CanvasEditorContext;
|
|
601
|
+
graphOptions?: Record<string, unknown>;
|
|
602
|
+
nodeActions?: NodeActionsConfig;
|
|
603
|
+
quickAdd?: QuickAddConfig;
|
|
604
|
+
};
|
|
605
|
+
type __VLS_Slots$2 = {
|
|
606
|
+
'quick-add-panel'?: (props: {
|
|
607
|
+
node: FlowNodeModel;
|
|
608
|
+
api: CanvasApi;
|
|
609
|
+
insertNodeToRight: (node: Omit<FlowNodeModel, 'position'>) => void;
|
|
610
|
+
closePopover: () => void;
|
|
611
|
+
}) => unknown;
|
|
612
|
+
};
|
|
613
|
+
declare const __VLS_base$2: vue.DefineComponent<__VLS_Props$5, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
614
|
+
"ui-event": (event: CanvasUiEvent) => any;
|
|
615
|
+
}, string, vue.PublicProps, Readonly<__VLS_Props$5> & Readonly<{
|
|
616
|
+
"onUi-event"?: ((event: CanvasUiEvent) => any) | undefined;
|
|
617
|
+
}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
|
|
618
|
+
declare const __VLS_export$6: __VLS_WithSlots$2<typeof __VLS_base$2, __VLS_Slots$2>;
|
|
619
|
+
declare const _default$6: typeof __VLS_export$6;
|
|
620
|
+
|
|
621
|
+
type __VLS_WithSlots$2<T, S> = T & {
|
|
622
|
+
new (): {
|
|
623
|
+
$slots: S;
|
|
624
|
+
};
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
type __VLS_Props$4 = {
|
|
628
|
+
sidebarCollapsed?: boolean;
|
|
629
|
+
sidebarWidth?: number;
|
|
630
|
+
hideSidebar?: boolean;
|
|
631
|
+
hideFooter?: boolean;
|
|
632
|
+
editor?: CanvasEditorContext;
|
|
633
|
+
paletteItems?: NodePaletteItem[];
|
|
634
|
+
};
|
|
635
|
+
type __VLS_Slots$1 = {
|
|
636
|
+
sidebar?: () => unknown;
|
|
637
|
+
default?: () => unknown;
|
|
638
|
+
footer?: () => unknown;
|
|
639
|
+
};
|
|
640
|
+
declare const __VLS_base$1: vue.DefineComponent<__VLS_Props$4, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
641
|
+
"update:sidebarCollapsed": (value: boolean) => any;
|
|
642
|
+
}, string, vue.PublicProps, Readonly<__VLS_Props$4> & Readonly<{
|
|
643
|
+
"onUpdate:sidebarCollapsed"?: ((value: boolean) => any) | undefined;
|
|
644
|
+
}>, {
|
|
645
|
+
editor: CanvasEditorContext;
|
|
646
|
+
sidebarCollapsed: boolean;
|
|
647
|
+
sidebarWidth: number;
|
|
648
|
+
hideSidebar: boolean;
|
|
649
|
+
hideFooter: boolean;
|
|
650
|
+
paletteItems: NodePaletteItem[];
|
|
651
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
|
|
652
|
+
declare const __VLS_export$5: __VLS_WithSlots$1<typeof __VLS_base$1, __VLS_Slots$1>;
|
|
653
|
+
declare const _default$5: typeof __VLS_export$5;
|
|
654
|
+
|
|
655
|
+
type __VLS_WithSlots$1<T, S> = T & {
|
|
656
|
+
new (): {
|
|
657
|
+
$slots: S;
|
|
658
|
+
};
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
type __VLS_Props$3 = {
|
|
662
|
+
items?: CanvasToolbarItem[];
|
|
663
|
+
exclude?: BuiltinToolbarType[];
|
|
664
|
+
editor: CanvasEditorContext;
|
|
665
|
+
};
|
|
666
|
+
declare const __VLS_export$4: vue.DefineComponent<__VLS_Props$3, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<__VLS_Props$3> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
|
|
667
|
+
declare const _default$4: typeof __VLS_export$4;
|
|
668
|
+
|
|
669
|
+
type __VLS_Props$2 = {
|
|
670
|
+
editor: CanvasEditorContext;
|
|
671
|
+
items?: NodePaletteItem[];
|
|
672
|
+
};
|
|
673
|
+
declare const __VLS_export$3: vue.DefineComponent<__VLS_Props$2, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<__VLS_Props$2> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
|
|
674
|
+
declare const _default$3: typeof __VLS_export$3;
|
|
675
|
+
|
|
676
|
+
declare const __VLS_export$2: vue.DefineComponent<{}, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
677
|
+
declare const _default$2: typeof __VLS_export$2;
|
|
678
|
+
|
|
679
|
+
type __VLS_Props$1 = {
|
|
680
|
+
node: FlowNodeModel;
|
|
681
|
+
position: ScreenPosition;
|
|
682
|
+
config: Required<NodeActionsConfig>;
|
|
683
|
+
behavior: NodeBehaviorConfig;
|
|
684
|
+
actionsOffset?: {
|
|
685
|
+
x?: number;
|
|
686
|
+
y?: number;
|
|
687
|
+
};
|
|
688
|
+
};
|
|
689
|
+
declare const __VLS_export$1: vue.DefineComponent<__VLS_Props$1, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
690
|
+
action: (type: "delete" | "copy" | "copy-insert" | "disconnect" | "debug", nodeId: string) => any;
|
|
691
|
+
}, string, vue.PublicProps, Readonly<__VLS_Props$1> & Readonly<{
|
|
692
|
+
onAction?: ((type: "delete" | "copy" | "copy-insert" | "disconnect" | "debug", nodeId: string) => any) | undefined;
|
|
693
|
+
}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
|
|
694
|
+
declare const _default$1: typeof __VLS_export$1;
|
|
695
|
+
|
|
696
|
+
type __VLS_Props = {
|
|
697
|
+
node: FlowNodeModel;
|
|
698
|
+
portPosition: ScreenPosition;
|
|
699
|
+
tooltipText?: string;
|
|
700
|
+
};
|
|
701
|
+
declare function closePopover(): void;
|
|
702
|
+
declare var __VLS_7: {};
|
|
703
|
+
type __VLS_Slots = {} & {
|
|
704
|
+
default?: (props: typeof __VLS_7) => any;
|
|
705
|
+
};
|
|
706
|
+
declare const __VLS_base: vue.DefineComponent<__VLS_Props, {
|
|
707
|
+
closePopover: typeof closePopover;
|
|
708
|
+
}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
709
|
+
close: () => any;
|
|
710
|
+
mouseenter: () => any;
|
|
711
|
+
mouseleave: () => any;
|
|
712
|
+
open: (nodeId: string) => any;
|
|
713
|
+
"start-drag": (nodeId: string) => any;
|
|
714
|
+
}, string, vue.PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
715
|
+
onClose?: (() => any) | undefined;
|
|
716
|
+
onMouseenter?: (() => any) | undefined;
|
|
717
|
+
onMouseleave?: (() => any) | undefined;
|
|
718
|
+
onOpen?: ((nodeId: string) => any) | undefined;
|
|
719
|
+
"onStart-drag"?: ((nodeId: string) => any) | undefined;
|
|
720
|
+
}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
|
|
721
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
722
|
+
declare const _default: typeof __VLS_export;
|
|
723
|
+
|
|
724
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
725
|
+
new (): {
|
|
726
|
+
$slots: S;
|
|
727
|
+
};
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
interface DefaultToolbarItemsOptions {
|
|
731
|
+
/** 要排除的操作项类型(仅对可隐藏的组生效,zoom 和 reset 组固定不可排除) */
|
|
732
|
+
exclude?: BuiltinToolbarType[];
|
|
733
|
+
/** 要恢复显示的默认隐藏项(默认隐藏:undo、redo) */
|
|
734
|
+
include?: BuiltinToolbarType[];
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* 工具栏默认项分为四组(从左到右):
|
|
738
|
+
* 1. history: 撤销、重做 — 默认隐藏,通过 include: ['undo', 'redo'] 恢复显示
|
|
739
|
+
* 2. tools: 框选、自动排版、搜索、缩略图、下载 — 可隐藏
|
|
740
|
+
* 3. zoom: 缩小、放大 — 固定
|
|
741
|
+
* 4. reset: 重置 — 固定
|
|
742
|
+
*/
|
|
743
|
+
declare function createDefaultToolbarItems(options?: DefaultToolbarItemsOptions): CanvasToolbarItem[];
|
|
744
|
+
|
|
745
|
+
type BuiltinEdgeType = 'manhattan' | 'bezier';
|
|
746
|
+
interface DefaultNodeTypeConfig {
|
|
747
|
+
label?: string;
|
|
748
|
+
icon?: string;
|
|
749
|
+
width?: number;
|
|
750
|
+
height?: number;
|
|
751
|
+
}
|
|
752
|
+
interface DefaultSchemaOptions {
|
|
753
|
+
nodeTypes?: Record<string, DefaultNodeTypeConfig>;
|
|
754
|
+
/** 默认连线类型,内置 'manhattan' | 'bezier',也可指向自定义类型 key */
|
|
755
|
+
defaultEdgeType?: string;
|
|
756
|
+
/** 额外/覆盖的边类型定义,会与内置类型合并 */
|
|
757
|
+
edgeTypes?: Record<string, CanvasEdgeDefinition>;
|
|
758
|
+
}
|
|
759
|
+
interface DefaultSchemaResult {
|
|
760
|
+
schema: CanvasSchema;
|
|
761
|
+
paletteItems: NodePaletteItem[];
|
|
762
|
+
}
|
|
763
|
+
declare function createBuiltinEdgeTypes(): Record<BuiltinEdgeType, CanvasEdgeDefinition>;
|
|
764
|
+
/**
|
|
765
|
+
* 创建内置的默认 Schema,提供开箱即用的节点与边类型。
|
|
766
|
+
*
|
|
767
|
+
* 节点类型使用 DefaultNode 组件渲染,自带上/右/下/左四个连接端口。
|
|
768
|
+
* 不传参数时提供 7 种节点类型和 2 种内置边类型(manhattan / bezier)。
|
|
769
|
+
*
|
|
770
|
+
* @example
|
|
771
|
+
* // 默认 manhattan 直角连线
|
|
772
|
+
* const { schema, paletteItems } = createDefaultSchema();
|
|
773
|
+
*
|
|
774
|
+
* // 切换为贝塞尔曲线连线
|
|
775
|
+
* const { schema, paletteItems } = createDefaultSchema({ defaultEdgeType: 'bezier' });
|
|
776
|
+
*
|
|
777
|
+
* // 自定义边类型
|
|
778
|
+
* const { schema, paletteItems } = createDefaultSchema({
|
|
779
|
+
* defaultEdgeType: 'myEdge',
|
|
780
|
+
* edgeTypes: { myEdge: { connector: 'normal', style: ... } },
|
|
781
|
+
* });
|
|
782
|
+
*/
|
|
783
|
+
declare function createDefaultSchema(options?: DefaultSchemaOptions): DefaultSchemaResult;
|
|
784
|
+
|
|
785
|
+
declare function connectionValidatorPlugin(validator: ConnectionValidator): CanvasPlugin;
|
|
786
|
+
|
|
787
|
+
interface SelectionPluginOptions {
|
|
788
|
+
rubberband?: boolean;
|
|
789
|
+
multiple?: boolean;
|
|
790
|
+
movable?: boolean;
|
|
791
|
+
}
|
|
792
|
+
declare function selectionPlugin(options?: SelectionPluginOptions): CanvasPlugin;
|
|
793
|
+
|
|
794
|
+
interface SnaplinePluginOptions {
|
|
795
|
+
tolerance?: number;
|
|
796
|
+
color?: string;
|
|
797
|
+
}
|
|
798
|
+
declare function snaplinePlugin(options?: SnaplinePluginOptions): CanvasPlugin;
|
|
799
|
+
|
|
800
|
+
interface MinimapPluginOptions {
|
|
801
|
+
container?: HTMLElement;
|
|
802
|
+
width?: number;
|
|
803
|
+
height?: number;
|
|
804
|
+
}
|
|
805
|
+
declare function minimapPlugin(options?: MinimapPluginOptions): CanvasPlugin;
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* FlowModel 级剪贴板插件。
|
|
809
|
+
*
|
|
810
|
+
* 不依赖 @antv/x6-plugin-clipboard,直接从 FlowModel 读取选中内容,
|
|
811
|
+
* 粘贴时生成新 ID 并通过 executeCommand 走完整命令管道。
|
|
812
|
+
* 这保证了粘贴操作与 undo/redo、插件 transformCommand 等机制一致。
|
|
813
|
+
*/
|
|
814
|
+
declare function clipboardPlugin(): CanvasPlugin;
|
|
815
|
+
|
|
816
|
+
declare function generateId(): string;
|
|
817
|
+
|
|
818
|
+
export { CanvasConstraintError, _default$5 as CanvasLayout, _default$3 as CanvasNodePalette, _default$6 as CanvasRuntime, CanvasSchemaError, _default$4 as CanvasToolbar, _default$2 as DefaultNode, _default$1 as NodeActionsToolbar, _default as NodeQuickAddPopover, applyCanvasCommand, clipboardPlugin, connectionValidatorPlugin, createBuiltinEdgeTypes, createCanvasHistory, createDefaultSchema, createDefaultToolbarItems, createEmptyFlowModel, generateId, minimapPlugin, selectionPlugin, snaplinePlugin, useCanvasEditor };
|
|
819
|
+
export type { BuiltinEdgeType, BuiltinToolbarType, CanvasApi, CanvasCallbackContext, CanvasCommand, CanvasEdgeDefinition, CanvasEditorContext, CanvasEditorOptions, CanvasHistory, CanvasHistoryOptions, CanvasMode, CanvasNodeDefinition, CanvasPlugin, CanvasPosition, CanvasSchema, CanvasSelection, CanvasToolbarItem, CanvasUiEvent, CommandEnvelope, CommandExecutionError, CommandExecutionResult, CommandPreview, CommandRejection, CommandSource, ConnectionValidateContext, ConnectionValidateResult, ConnectionValidator, ContextMenuItem, DefaultNodeTypeConfig, DefaultSchemaOptions, DefaultSchemaResult, DefaultToolbarItemsOptions, EdgeDecoration, EdgeRenderState, EdgeStyle, EditorPluginContext, ExportOptions, FlowEdgeLabelModel, FlowEdgeModel, FlowModel, FlowModelChangeEvent, FlowNodeModel, FlowPortModel, InsertDirection, InsertNodeOptions, MinimapPluginOptions, NodeActionsConfig, NodeBehaviorConfig, NodeDecoration, NodePaletteItem, OverlayManager, QuickAddConfig, QuickAddInsertDirectionResolver, QuickAddPortResolver, RuntimePluginContext, ScreenPosition, SelectionPluginOptions, SnaplinePluginOptions };
|