@blueking/flow-canvas 0.0.2 → 0.0.4
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 +183 -123
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +68 -12
- package/dist/index.esm.js +2185 -1548
- package/dist/style.css +1 -1
- package/package.json +2 -5
package/dist/index.d.ts
CHANGED
|
@@ -207,6 +207,8 @@ type CanvasUiEvent = {
|
|
|
207
207
|
type: 'node.action.quick-insert';
|
|
208
208
|
sourceNodeId: string;
|
|
209
209
|
newNodeId: string;
|
|
210
|
+
} | {
|
|
211
|
+
type: 'toolbar.auto-layout';
|
|
210
212
|
};
|
|
211
213
|
|
|
212
214
|
interface CanvasHistory {
|
|
@@ -229,17 +231,23 @@ interface OverlayManager {
|
|
|
229
231
|
getNodeScreenRect(nodeId: string): DOMRect | null;
|
|
230
232
|
}
|
|
231
233
|
|
|
234
|
+
declare function generateId(): string;
|
|
235
|
+
type IdGenerator = (type: 'node' | 'edge') => string;
|
|
236
|
+
|
|
232
237
|
interface EditorPluginContext {
|
|
233
238
|
flowModel: Readonly<Ref<FlowModel>>;
|
|
234
239
|
history: CanvasHistory;
|
|
235
240
|
schema: CanvasSchema;
|
|
236
241
|
mode: Ref<CanvasMode>;
|
|
242
|
+
idGenerator: IdGenerator;
|
|
237
243
|
executeCommand(envelope: CommandEnvelope): CommandExecutionResult;
|
|
238
244
|
}
|
|
239
245
|
interface RuntimePluginContext extends EditorPluginContext {
|
|
240
246
|
api: CanvasApi;
|
|
241
247
|
overlay: OverlayManager;
|
|
242
248
|
graph: Graph;
|
|
249
|
+
/** 框选模式是否激活(由 editor.selectionMode 驱动) */
|
|
250
|
+
selectionMode: Readonly<Ref<boolean>>;
|
|
243
251
|
}
|
|
244
252
|
interface CanvasSelection {
|
|
245
253
|
nodeIds: string[];
|
|
@@ -284,7 +292,12 @@ interface CanvasPlugin {
|
|
|
284
292
|
extendApi?(api: CanvasApi, ctx: RuntimePluginContext): Record<string, Function>;
|
|
285
293
|
}
|
|
286
294
|
|
|
287
|
-
type
|
|
295
|
+
type CoreToolbarType = 'undo' | 'redo' | 'select' | 'auto-layout' | 'export' | 'zoom-in' | 'zoom-out' | 'zoom-display' | 'fit' | 'reset';
|
|
296
|
+
/**
|
|
297
|
+
* 这类工具项默认由内置插件提供入口与行为,toolbar 壳层只负责渲染与隐藏控制。
|
|
298
|
+
*/
|
|
299
|
+
type PluginManagedToolbarType = 'search' | 'minimap';
|
|
300
|
+
type BuiltinToolbarType = CoreToolbarType | PluginManagedToolbarType;
|
|
288
301
|
interface CanvasToolbarItem {
|
|
289
302
|
id: string;
|
|
290
303
|
type: BuiltinToolbarType | 'custom';
|
|
@@ -300,12 +313,21 @@ interface CanvasToolbarItem {
|
|
|
300
313
|
order?: number;
|
|
301
314
|
visible?: boolean | ((ctx: CanvasCallbackContext) => boolean);
|
|
302
315
|
disabled?: boolean | ((ctx: CanvasCallbackContext) => boolean);
|
|
316
|
+
active?: boolean | ((ctx: CanvasCallbackContext) => boolean);
|
|
303
317
|
onClick?: (ctx: CanvasCallbackContext) => void;
|
|
304
318
|
}
|
|
305
319
|
interface ExportOptions {
|
|
306
320
|
backgroundColor?: string;
|
|
307
321
|
padding?: number;
|
|
308
322
|
quality?: number;
|
|
323
|
+
/** 输出图片的缩放倍率,默认跟随 devicePixelRatio */
|
|
324
|
+
scale?: number;
|
|
325
|
+
}
|
|
326
|
+
interface DeleteSelectionOptions {
|
|
327
|
+
selection?: CanvasSelection;
|
|
328
|
+
source?: CommandSource;
|
|
329
|
+
label?: string;
|
|
330
|
+
clearSelectionAfterApply?: boolean;
|
|
309
331
|
}
|
|
310
332
|
interface NodeActionsConfig {
|
|
311
333
|
showDebug?: boolean;
|
|
@@ -332,13 +354,14 @@ interface CanvasApi {
|
|
|
332
354
|
scrollToOrigin(): void;
|
|
333
355
|
scrollToNode(nodeId: string): void;
|
|
334
356
|
getSelection(): CanvasSelection;
|
|
357
|
+
getSelectionBounds(selection?: CanvasSelection): DOMRect | null;
|
|
335
358
|
selectNodes(ids: string[]): void;
|
|
336
359
|
selectEdges(ids: string[]): void;
|
|
337
360
|
clearSelection(): void;
|
|
361
|
+
deleteSelection(options?: DeleteSelectionOptions): CommandExecutionResult | null;
|
|
338
362
|
registerDndSource(el: HTMLElement, factory: () => FlowNodeModel): () => void;
|
|
339
363
|
startConnection(nodeId: string, portId?: string): void;
|
|
340
364
|
exportAsImage(options?: ExportOptions): Promise<Blob>;
|
|
341
|
-
exportAsSVG(): Promise<string>;
|
|
342
365
|
highlightNodes(nodeIds: string[]): void;
|
|
343
366
|
highlightEdges(edgeIds: string[]): void;
|
|
344
367
|
clearHighlight(): void;
|
|
@@ -377,8 +400,6 @@ type QuickAddInsertDirectionResolver = (node: FlowNodeModel, port: FlowPortModel
|
|
|
377
400
|
interface QuickAddConfig {
|
|
378
401
|
/** 全局开关,默认 true */
|
|
379
402
|
enabled?: boolean;
|
|
380
|
-
/** "+"按钮 hover 时的 tooltip 文案 */
|
|
381
|
-
tooltipText?: string;
|
|
382
403
|
/** quick-add 绑定的端口分组,默认 'right';节点不存在该分组端口时将不显示 quick-add */
|
|
383
404
|
portGroup?: string;
|
|
384
405
|
/** 精确指定 quick-add 使用哪个端口;优先级高于 portGroup */
|
|
@@ -404,7 +425,10 @@ interface NodeBehaviorConfig {
|
|
|
404
425
|
draggable?: boolean;
|
|
405
426
|
selectable?: boolean;
|
|
406
427
|
deletable?: boolean;
|
|
428
|
+
/** 是否允许从此节点发起连线(控制端口 magnet 属性) */
|
|
407
429
|
connectable?: boolean;
|
|
430
|
+
/** 是否允许将连线连入此节点;为 false 时拖拽连线期间不显示该节点端口 */
|
|
431
|
+
targetable?: boolean;
|
|
408
432
|
copyable?: boolean;
|
|
409
433
|
disconnectable?: boolean;
|
|
410
434
|
debuggable?: boolean;
|
|
@@ -415,6 +439,10 @@ interface NodeBehaviorConfig {
|
|
|
415
439
|
debugDisabled?: boolean;
|
|
416
440
|
/** 逐节点控制右侧"+"快捷添加按钮是否显示,默认跟随全局配置 */
|
|
417
441
|
quickAddEnabled?: boolean;
|
|
442
|
+
/** 拖拽时是否临时置顶节点(z-index),默认 true */
|
|
443
|
+
bringToFrontOnDrag?: boolean;
|
|
444
|
+
/** quick-add 激活时是否隐藏对应方向的连接端口,默认 true */
|
|
445
|
+
hidePortForQuickAdd?: boolean;
|
|
418
446
|
/** 快捷操作工具栏的位置偏移(px),相对于默认位置(节点右下角) */
|
|
419
447
|
actionsOffset?: {
|
|
420
448
|
x?: number;
|
|
@@ -468,6 +496,13 @@ interface CanvasCallbackContext {
|
|
|
468
496
|
mode: CanvasMode;
|
|
469
497
|
}
|
|
470
498
|
|
|
499
|
+
/**
|
|
500
|
+
* @antv/x6-plugin-selection 在运行时向 Graph 原型注入的方法。
|
|
501
|
+
* 仅在 selectionPlugin 已通过 graph.use() 注册后可用。
|
|
502
|
+
* 当前 X6 类型声明已包含这些方法,因此这里保留别名供运行时语义标注使用。
|
|
503
|
+
*/
|
|
504
|
+
type GraphWithSelection = Graph;
|
|
505
|
+
|
|
471
506
|
/**
|
|
472
507
|
* 纯函数 reducer:将一条原子命令应用到 FlowModel 上,返回新 FlowModel(不可变)。
|
|
473
508
|
* 所有 FlowModel 不变量在此处保证:
|
|
@@ -559,6 +594,7 @@ interface CanvasEditorOptions {
|
|
|
559
594
|
plugins?: CanvasPlugin[];
|
|
560
595
|
mode?: CanvasMode;
|
|
561
596
|
historyOptions?: CanvasHistoryOptions;
|
|
597
|
+
idGenerator?: IdGenerator;
|
|
562
598
|
onCommandResult?(result: CommandExecutionResult): void;
|
|
563
599
|
onFlowModelChange?(event: FlowModelChangeEvent): void;
|
|
564
600
|
}
|
|
@@ -567,6 +603,7 @@ interface CanvasEditorContext {
|
|
|
567
603
|
history: CanvasHistory;
|
|
568
604
|
schema: CanvasSchema;
|
|
569
605
|
mode: Ref<CanvasMode>;
|
|
606
|
+
idGenerator: IdGenerator;
|
|
570
607
|
executeCommand(envelope: CommandEnvelope): CommandExecutionResult;
|
|
571
608
|
replaceFlowModel(model: FlowModel): void;
|
|
572
609
|
setMode(mode: CanvasMode): void;
|
|
@@ -578,6 +615,11 @@ interface CanvasEditorContext {
|
|
|
578
615
|
extendedApi: Record<string, Function>;
|
|
579
616
|
/** @internal used by CanvasRuntime */
|
|
580
617
|
_pluginManager: PluginManager;
|
|
618
|
+
/**
|
|
619
|
+
* @internal 发出 UI 事件。Runtime mount 前仅分发到插件;mount 后同时触发 Vue emit('ui-event')。
|
|
620
|
+
* 由 CanvasRuntime 在挂载时注入完整实现。
|
|
621
|
+
*/
|
|
622
|
+
_emitUiEvent: (event: CanvasUiEvent) => void;
|
|
581
623
|
}
|
|
582
624
|
/**
|
|
583
625
|
* 画布编辑引擎的核心 composable。
|
|
@@ -601,6 +643,8 @@ type __VLS_Props$5 = {
|
|
|
601
643
|
graphOptions?: Record<string, unknown>;
|
|
602
644
|
nodeActions?: NodeActionsConfig;
|
|
603
645
|
quickAdd?: QuickAddConfig;
|
|
646
|
+
/** 拖拽连线时,根据源节点 ID 返回不应显示端口的节点 ID 集合(如自身、上游、不可作为目标的节点) */
|
|
647
|
+
getConnectionExcludedNodeIds?: (sourceNodeId: string) => Iterable<string>;
|
|
604
648
|
};
|
|
605
649
|
type __VLS_Slots$2 = {
|
|
606
650
|
'quick-add-panel'?: (props: {
|
|
@@ -696,7 +740,6 @@ declare const _default$1: typeof __VLS_export$1;
|
|
|
696
740
|
type __VLS_Props = {
|
|
697
741
|
node: FlowNodeModel;
|
|
698
742
|
portPosition: ScreenPosition;
|
|
699
|
-
tooltipText?: string;
|
|
700
743
|
};
|
|
701
744
|
declare function closePopover(): void;
|
|
702
745
|
declare var __VLS_7: {};
|
|
@@ -728,17 +771,18 @@ type __VLS_WithSlots<T, S> = T & {
|
|
|
728
771
|
};
|
|
729
772
|
|
|
730
773
|
interface DefaultToolbarItemsOptions {
|
|
731
|
-
/** 要排除的操作项类型(仅对可隐藏的组生效,zoom 和 reset 组固定不可排除) */
|
|
732
|
-
exclude?: BuiltinToolbarType[];
|
|
733
774
|
/** 要恢复显示的默认隐藏项(默认隐藏:undo、redo) */
|
|
734
775
|
include?: BuiltinToolbarType[];
|
|
735
776
|
}
|
|
736
777
|
/**
|
|
737
778
|
* 工具栏默认项分为四组(从左到右):
|
|
738
779
|
* 1. history: 撤销、重做 — 默认隐藏,通过 include: ['undo', 'redo'] 恢复显示
|
|
739
|
-
* 2. tools:
|
|
780
|
+
* 2. tools: 框选、自动排版、下载
|
|
781
|
+
* search / minimap 由内置插件默认提供,不在 core 默认项中声明
|
|
740
782
|
* 3. zoom: 缩小、放大 — 固定
|
|
741
783
|
* 4. reset: 重置 — 固定
|
|
784
|
+
*
|
|
785
|
+
* exclude 过滤统一由 CanvasToolbar 组件在合并 plugin items 后执行,此函数不处理。
|
|
742
786
|
*/
|
|
743
787
|
declare function createDefaultToolbarItems(options?: DefaultToolbarItemsOptions): CanvasToolbarItem[];
|
|
744
788
|
|
|
@@ -797,7 +841,21 @@ interface SnaplinePluginOptions {
|
|
|
797
841
|
}
|
|
798
842
|
declare function snaplinePlugin(options?: SnaplinePluginOptions): CanvasPlugin;
|
|
799
843
|
|
|
844
|
+
interface SearchNodeMeta {
|
|
845
|
+
label?: string;
|
|
846
|
+
subtitle?: string;
|
|
847
|
+
keywords?: string[];
|
|
848
|
+
}
|
|
849
|
+
interface SearchPluginOptions {
|
|
850
|
+
placeholder?: string;
|
|
851
|
+
emptyText?: string;
|
|
852
|
+
maxResults?: number;
|
|
853
|
+
getNodeMeta?: (node: FlowNodeModel) => SearchNodeMeta | null | undefined;
|
|
854
|
+
}
|
|
855
|
+
declare function searchPlugin(options?: SearchPluginOptions): CanvasPlugin;
|
|
856
|
+
|
|
800
857
|
interface MinimapPluginOptions {
|
|
858
|
+
/** 外部容器(传入后使用外部容器渲染,不创建浮动面板) */
|
|
801
859
|
container?: HTMLElement;
|
|
802
860
|
width?: number;
|
|
803
861
|
height?: number;
|
|
@@ -813,7 +871,5 @@ declare function minimapPlugin(options?: MinimapPluginOptions): CanvasPlugin;
|
|
|
813
871
|
*/
|
|
814
872
|
declare function clipboardPlugin(): CanvasPlugin;
|
|
815
873
|
|
|
816
|
-
|
|
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 };
|
|
874
|
+
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, searchPlugin, selectionPlugin, snaplinePlugin, useCanvasEditor };
|
|
875
|
+
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, CoreToolbarType, DefaultNodeTypeConfig, DefaultSchemaOptions, DefaultSchemaResult, DefaultToolbarItemsOptions, DeleteSelectionOptions, EdgeDecoration, EdgeRenderState, EdgeStyle, EditorPluginContext, ExportOptions, FlowEdgeLabelModel, FlowEdgeModel, FlowModel, FlowModelChangeEvent, FlowNodeModel, FlowPortModel, GraphWithSelection, IdGenerator, InsertDirection, InsertNodeOptions, MinimapPluginOptions, NodeActionsConfig, NodeBehaviorConfig, NodeDecoration, NodePaletteItem, OverlayManager, PluginManagedToolbarType, QuickAddConfig, QuickAddInsertDirectionResolver, QuickAddPortResolver, RuntimePluginContext, ScreenPosition, SearchNodeMeta, SearchPluginOptions, SelectionPluginOptions, SnaplinePluginOptions };
|