@blueking/flow-canvas 0.0.1-beta.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 +725 -0
- package/dist/core/apply-command.d.ts +11 -0
- package/dist/core/editor.d.ts +50 -0
- package/dist/core/errors.d.ts +6 -0
- package/dist/core/history.d.ts +15 -0
- package/dist/core/plugin-manager.d.ts +58 -0
- package/dist/index-BAAMFT_J.js +236 -0
- package/dist/index-CleU3x1v.cjs +1 -0
- package/dist/index-DD3pv5ZZ.cjs +21 -0
- package/dist/index-siYsjzl4.js +181 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.esm.js +2709 -0
- package/dist/plugins/clipboard.d.ts +9 -0
- package/dist/plugins/connection-validator.d.ts +3 -0
- package/dist/plugins/minimap.d.ts +7 -0
- package/dist/plugins/selection.d.ts +7 -0
- package/dist/plugins/snapline.d.ts +6 -0
- package/dist/runtime/canvas-api.d.ts +25 -0
- package/dist/runtime/canvas-runtime-core.vue.d.ts +36 -0
- package/dist/runtime/event-bridge.d.ts +28 -0
- package/dist/runtime/graph-bridge.d.ts +127 -0
- package/dist/runtime/overlay-manager.d.ts +4 -0
- package/dist/runtime/shape-registry.d.ts +8 -0
- package/dist/runtime/use-edge-delete-tool.d.ts +11 -0
- package/dist/runtime/use-node-hover.d.ts +8 -0
- package/dist/runtime/use-port-visibility.d.ts +15 -0
- package/dist/shell/canvas-layout.vue.d.ts +35 -0
- package/dist/shell/canvas-node-palette.vue.d.ts +10 -0
- package/dist/shell/canvas-toolbar.vue.d.ts +11 -0
- package/dist/shell/default-node.vue.d.ts +4 -0
- package/dist/shell/default-schema.d.ts +39 -0
- package/dist/shell/node-actions-toolbar.vue.d.ts +18 -0
- package/dist/shell/node-quick-add-popover.vue.d.ts +36 -0
- package/dist/shell/toolbar-items.d.ts +13 -0
- package/dist/style.css +1 -0
- package/dist/types/api.d.ts +104 -0
- package/dist/types/command.d.ts +160 -0
- package/dist/types/flow-model.d.ts +46 -0
- package/dist/types/history.d.ts +18 -0
- package/dist/types/overlay.d.ts +17 -0
- package/dist/types/plugin.d.ts +64 -0
- package/dist/types/schema.d.ts +77 -0
- package/dist/utils/path.d.ts +7 -0
- package/dist/utils/uuid.d.ts +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CanvasPlugin } from '../types/plugin';
|
|
2
|
+
/**
|
|
3
|
+
* FlowModel 级剪贴板插件。
|
|
4
|
+
*
|
|
5
|
+
* 不依赖 @antv/x6-plugin-clipboard,直接从 FlowModel 读取选中内容,
|
|
6
|
+
* 粘贴时生成新 ID 并通过 executeCommand 走完整命令管道。
|
|
7
|
+
* 这保证了粘贴操作与 undo/redo、插件 transformCommand 等机制一致。
|
|
8
|
+
*/
|
|
9
|
+
export declare function clipboardPlugin(): CanvasPlugin;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Graph } from '@antv/x6';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
import type { CanvasApi } from '../types/api';
|
|
4
|
+
import type { ContextMenuItem } from '../types/plugin';
|
|
5
|
+
import type { FlowModel } from '../types/flow-model';
|
|
6
|
+
import type { OverlayManager } from '../types/overlay';
|
|
7
|
+
import type { CanvasSchema } from '../types/schema';
|
|
8
|
+
import type { CommandEnvelope, CommandExecutionResult, ScreenPosition } from '../types/command';
|
|
9
|
+
export interface NodeShapeInfo {
|
|
10
|
+
shapeName: string;
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}
|
|
14
|
+
export interface CanvasApiOptions {
|
|
15
|
+
graph: Graph;
|
|
16
|
+
overlayManager: OverlayManager;
|
|
17
|
+
executeCommand: (envelope: CommandEnvelope) => CommandExecutionResult;
|
|
18
|
+
schema: CanvasSchema;
|
|
19
|
+
flowModel: Readonly<Ref<FlowModel>>;
|
|
20
|
+
defaultInsertGap?: number;
|
|
21
|
+
getContextMenuItems?: (position: ScreenPosition) => ContextMenuItem[];
|
|
22
|
+
onHighlightChange?: (nodeIds: string[], edgeIds: string[]) => void;
|
|
23
|
+
resolveNodeShape?: (nodeType: string) => NodeShapeInfo | null;
|
|
24
|
+
}
|
|
25
|
+
export declare function createCanvasApi({ graph, overlayManager, executeCommand, schema, flowModel, defaultInsertGap, getContextMenuItems: getContextMenuItemsFn, onHighlightChange, resolveNodeShape, }: CanvasApiOptions): CanvasApi;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { CanvasEditorContext } from '../core/editor';
|
|
2
|
+
import type { CanvasUiEvent, ScreenPosition } from '../types/command';
|
|
3
|
+
import type { FlowNodeModel } from '../types/flow-model';
|
|
4
|
+
import type { CanvasApi, NodeActionsConfig, QuickAddConfig } from '../types/api';
|
|
5
|
+
type __VLS_Props = {
|
|
6
|
+
editor: CanvasEditorContext;
|
|
7
|
+
graphOptions?: Record<string, unknown>;
|
|
8
|
+
nodeActions?: NodeActionsConfig;
|
|
9
|
+
quickAdd?: QuickAddConfig;
|
|
10
|
+
};
|
|
11
|
+
type __VLS_Slots = {
|
|
12
|
+
'node-overlay'?: (props: {
|
|
13
|
+
node: FlowNodeModel;
|
|
14
|
+
screenAnchors: Record<string, ScreenPosition>;
|
|
15
|
+
api: CanvasApi;
|
|
16
|
+
}) => unknown;
|
|
17
|
+
'quick-add-panel'?: (props: {
|
|
18
|
+
node: FlowNodeModel;
|
|
19
|
+
api: CanvasApi;
|
|
20
|
+
insertNodeToRight: (node: Omit<FlowNodeModel, 'position'>) => void;
|
|
21
|
+
closePopover: () => void;
|
|
22
|
+
}) => unknown;
|
|
23
|
+
};
|
|
24
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
25
|
+
"ui-event": (event: CanvasUiEvent) => any;
|
|
26
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
27
|
+
"onUi-event"?: ((event: CanvasUiEvent) => any) | undefined;
|
|
28
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
29
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
30
|
+
declare const _default: typeof __VLS_export;
|
|
31
|
+
export default _default;
|
|
32
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
33
|
+
new (): {
|
|
34
|
+
$slots: S;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Graph } from '@antv/x6';
|
|
2
|
+
import type { FlowModel } from '../types/flow-model';
|
|
3
|
+
import type { CanvasUiEvent, CommandEnvelope } from '../types/command';
|
|
4
|
+
import type { Ref } from 'vue';
|
|
5
|
+
type UiEventHandler = (event: CanvasUiEvent) => void;
|
|
6
|
+
type CommandHandler = (envelope: CommandEnvelope) => void;
|
|
7
|
+
/**
|
|
8
|
+
* X6 图交互事件 → CanvasUiEvent / CommandEnvelope 的桥接器。
|
|
9
|
+
*
|
|
10
|
+
* 事件分两类输出:
|
|
11
|
+
* - onUiEvent:不修改 FlowModel 的交互事件(click、contextmenu、selection.change)
|
|
12
|
+
* - onCommand:产生 FlowModel 变更的操作(node:moved → node.move、edge:connected → edge.add/reconnect)
|
|
13
|
+
*
|
|
14
|
+
* edge:connected 使用 X6 的 isNew 标志 + flowModelRef 双重判断区分新建连线和重连。
|
|
15
|
+
* edge:click 通过 DOM 层级查找 .x6-edge-label 来区分边体点击和标签点击。
|
|
16
|
+
*/
|
|
17
|
+
export declare class EventBridge {
|
|
18
|
+
private graph;
|
|
19
|
+
private onUiEvent;
|
|
20
|
+
private onCommand;
|
|
21
|
+
private flowModelRef;
|
|
22
|
+
private disposers;
|
|
23
|
+
constructor(graph: Graph, onUiEvent: UiEventHandler, onCommand: CommandHandler, flowModelRef: Readonly<Ref<FlowModel>>);
|
|
24
|
+
dispose(): void;
|
|
25
|
+
private bindEvents;
|
|
26
|
+
private on;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Graph } from '@antv/x6';
|
|
2
|
+
import type { FlowModel, FlowNodeModel, FlowEdgeModel } from '../types/flow-model';
|
|
3
|
+
import type { CanvasSchema, CanvasCallbackContext } from '../types/schema';
|
|
4
|
+
import type { NodeDecoration, EdgeDecoration } from '../types/plugin';
|
|
5
|
+
import { ShapeRegistry } from './shape-registry';
|
|
6
|
+
export type NodeDecorationResolver = (node: FlowNodeModel) => NodeDecoration | undefined;
|
|
7
|
+
export type EdgeDecorationResolver = (edge: FlowEdgeModel) => EdgeDecoration | undefined;
|
|
8
|
+
export type CanvasContextResolver = () => CanvasCallbackContext | null;
|
|
9
|
+
/**
|
|
10
|
+
* FlowModel → X6 Graph 的单向同步桥接器。
|
|
11
|
+
*
|
|
12
|
+
* 职责:将 FlowModel 的声明式状态增量同步到 X6 的命令式 API。
|
|
13
|
+
* knownNodeIds / knownEdgeIds 跟踪已渲染的元素,用于 diff:
|
|
14
|
+
* - FlowModel 中有、图中无 → addNode/addEdge
|
|
15
|
+
* - FlowModel 中有、图中有 → 更新 position/size/ports/source/target/labels
|
|
16
|
+
* - FlowModel 中无、图中有 → removeCell
|
|
17
|
+
*
|
|
18
|
+
* syncing 标志用于让 EventBridge 忽略同步引起的 X6 事件,防止循环:
|
|
19
|
+
* FlowModel 变更 → syncFlowModel → X6 事件 → executeCommand → FlowModel 变更 ...
|
|
20
|
+
*/
|
|
21
|
+
export declare class GraphBridge {
|
|
22
|
+
private graph;
|
|
23
|
+
private schema;
|
|
24
|
+
private shapeRegistry;
|
|
25
|
+
private resolveNodeDecoration?;
|
|
26
|
+
private resolveEdgeDecoration?;
|
|
27
|
+
private resolveCanvasContext?;
|
|
28
|
+
private knownNodeIds;
|
|
29
|
+
private knownEdgeIds;
|
|
30
|
+
private syncing;
|
|
31
|
+
private prevNodeDecorationClasses;
|
|
32
|
+
private prevNodeDecorationColors;
|
|
33
|
+
private prevEdgeDecorationClasses;
|
|
34
|
+
private prevEdgeDecorationColors;
|
|
35
|
+
private highlightedNodeIds;
|
|
36
|
+
private highlightedEdgeIds;
|
|
37
|
+
private hoveredEdgeId;
|
|
38
|
+
private defaultHighlightedNodeIds;
|
|
39
|
+
private defaultHighlightedEdgeIds;
|
|
40
|
+
private prevEdgeStyleIds;
|
|
41
|
+
/** x6CellConfig 中 attrs.body 的基线值,清理时恢复而非删除 */
|
|
42
|
+
private nodeDefaultAttrs;
|
|
43
|
+
/** x6EdgeConfig 中 attrs.line 的基线值,清理时恢复而非删除 */
|
|
44
|
+
private edgeDefaultAttrs;
|
|
45
|
+
private lastModel;
|
|
46
|
+
constructor(graph: Graph, schema: CanvasSchema, shapeRegistry: ShapeRegistry, resolveNodeDecoration?: NodeDecorationResolver, resolveEdgeDecoration?: EdgeDecorationResolver, resolveCanvasContext?: CanvasContextResolver);
|
|
47
|
+
syncFlowModel(flowModel: FlowModel): void;
|
|
48
|
+
get isSyncing(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* 从 x6CellConfig.attrs.body 中提取基线描边,用于管理层清理时恢复。
|
|
51
|
+
* 仅在节点首次创建时调用一次。
|
|
52
|
+
*/
|
|
53
|
+
private saveNodeDefaultAttrs;
|
|
54
|
+
/**
|
|
55
|
+
* 从 x6EdgeConfig.attrs.line 中提取基线描边,用于管理层清理时恢复。
|
|
56
|
+
*/
|
|
57
|
+
private saveEdgeDefaultAttrs;
|
|
58
|
+
/** 恢复节点 attr 到基线值;无基线时移除。 */
|
|
59
|
+
private restoreNodeAttr;
|
|
60
|
+
/** 恢复边 attr 到基线值;无基线时移除。 */
|
|
61
|
+
private restoreEdgeAttr;
|
|
62
|
+
/** 让正式边接管交互式预览边时,恢复 schema 定义的端点 marker。 */
|
|
63
|
+
private syncEdgeMarker;
|
|
64
|
+
dispose(): void;
|
|
65
|
+
private resolveNodes;
|
|
66
|
+
private resolveEdges;
|
|
67
|
+
private syncNodes;
|
|
68
|
+
private updateExistingNode;
|
|
69
|
+
private syncNodePorts;
|
|
70
|
+
private addNewNode;
|
|
71
|
+
/**
|
|
72
|
+
* 将 schema 定义的 getBehavior 映射到 X6 节点属性。
|
|
73
|
+
* NodeBehaviorConfig 的每个字段都映射到 X6 Cell 对应能力:
|
|
74
|
+
* - draggable → 是否可拖拽移动
|
|
75
|
+
* - selectable → 是否可被选中(注意:X6 Selection 插件也有全局控制)
|
|
76
|
+
* - connectable → ports 的 magnet 属性,控制是否可从该节点发起连线
|
|
77
|
+
* - showPorts → ports 的可见性
|
|
78
|
+
* - deletable → 存入 cell data,由删除操作(插件/快捷键)自行读取判断
|
|
79
|
+
*/
|
|
80
|
+
private applyNodeBehavior;
|
|
81
|
+
private syncEdges;
|
|
82
|
+
/**
|
|
83
|
+
* 增量更新已有边的 source/target/router/connector/labels。
|
|
84
|
+
* X6 Edge.getSource() 返回 { cell, port } 格式,与 FlowEdgeModel 的 { nodeId, portId } 不同,
|
|
85
|
+
* 需要用 (currentSource as any).cell 来比较。
|
|
86
|
+
*/
|
|
87
|
+
private updateExistingEdge;
|
|
88
|
+
private syncEdgeLabels;
|
|
89
|
+
private addNewEdge;
|
|
90
|
+
/**
|
|
91
|
+
* 外部通知选区、高亮或 hover 变化时,重算所有边的视觉样式。
|
|
92
|
+
* 每条边走统一分层管道 applyEdgeStyleAndDecoration,
|
|
93
|
+
* 保证 defaultHighlight → schema style() → plugin decoration 的覆盖顺序。
|
|
94
|
+
*/
|
|
95
|
+
refreshEdgeStyles(): void;
|
|
96
|
+
/**
|
|
97
|
+
* 重算所有节点的高亮 + 装饰视觉。
|
|
98
|
+
*/
|
|
99
|
+
refreshNodeHighlights(): void;
|
|
100
|
+
/**
|
|
101
|
+
* 单节点的高亮 + 装饰统一管道。
|
|
102
|
+
* 所有路径(FlowModel 同步更新/新增节点/显式刷新高亮)必须走此方法。
|
|
103
|
+
*
|
|
104
|
+
* body/stroke 的分层优先级(低 → 高):
|
|
105
|
+
* 1. 默认高亮 (#3a84ff) — 节点在 highlightedNodeIds 中时兜底
|
|
106
|
+
* 2. 插件装饰 (decorateNode().borderColor) — 始终覆盖高亮
|
|
107
|
+
*
|
|
108
|
+
* 最终值 = decorationColor ?? highlightColor ?? (清除)。
|
|
109
|
+
* 只在"曾经设过 → 现在无值"时执行 removeAttrByPath,避免误删 X6 原始样式。
|
|
110
|
+
*/
|
|
111
|
+
private applyNodeHighlightAndDecoration;
|
|
112
|
+
setHoveredEdge(edgeId: string | null): void;
|
|
113
|
+
setHighlightedNodes(nodeIds: string[]): void;
|
|
114
|
+
setHighlightedEdges(edgeIds: string[]): void;
|
|
115
|
+
/**
|
|
116
|
+
* 单条边的 style + highlight + decoration 统一管道。
|
|
117
|
+
*
|
|
118
|
+
* line/stroke 的分层优先级(低 → 高):
|
|
119
|
+
* 1. 默认高亮 (#3a84ff) — 无 style() 时的兜底
|
|
120
|
+
* 2. Schema style() — 接收完整 EdgeRenderState,完全控制视觉
|
|
121
|
+
* 3. 插件装饰 (decorateEdge().strokeColor) — 始终覆盖 style()
|
|
122
|
+
*
|
|
123
|
+
* strokeWidth / strokeDasharray 仅由 schema style() 控制,不受装饰影响。
|
|
124
|
+
* 最终值 = decorationStroke ?? styleStroke ?? defaultHighlightStroke ?? (清除)。
|
|
125
|
+
*/
|
|
126
|
+
private applyEdgeStyleAndDecoration;
|
|
127
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Graph } from '@antv/x6';
|
|
2
|
+
/**
|
|
3
|
+
* 管理边上的 SVG 删除按钮:跟随鼠标贴附在边路径上,
|
|
4
|
+
* 靠近端点时自动隐藏,点击时由外部处理删除命令。
|
|
5
|
+
*/
|
|
6
|
+
export declare function useEdgeDeleteTool(graph: Graph): {
|
|
7
|
+
show: (edgeId: string, e: MouseEvent) => void;
|
|
8
|
+
move: (e: MouseEvent) => void;
|
|
9
|
+
remove: () => void;
|
|
10
|
+
handleEdgeRemoved: (edgeId: string) => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function useNodeHover(): {
|
|
2
|
+
hoveredNodeId: import("vue").Ref<string | null, string | null>;
|
|
3
|
+
isDraggingNode: import("vue").Ref<boolean, boolean>;
|
|
4
|
+
enter: (nodeId: string) => void;
|
|
5
|
+
leave: () => void;
|
|
6
|
+
cancelLeave: () => void;
|
|
7
|
+
cleanup: () => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Graph, Node, Edge } from '@antv/x6';
|
|
2
|
+
/**
|
|
3
|
+
* 管理画布端口可见性:
|
|
4
|
+
* - 默认隐藏,hover 节点时显示该节点的端口
|
|
5
|
+
* - 拖拽连线时显示所有节点端口,连线完成后恢复隐藏
|
|
6
|
+
* - 连线完成后 300ms 内抑制边删除工具显示(避免 flash)
|
|
7
|
+
*/
|
|
8
|
+
export declare function usePortVisibility(graph: Graph): {
|
|
9
|
+
showNodePorts: (node: Node) => void;
|
|
10
|
+
hideNodePorts: (node: Node) => void;
|
|
11
|
+
handleEdgeAdded: (edge: Edge) => void;
|
|
12
|
+
handleEdgeConnected: () => void;
|
|
13
|
+
handleEdgeRemoved: (edgeId: string) => void;
|
|
14
|
+
canShowEdgeTool: () => boolean;
|
|
15
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CanvasEditorContext } from '../core/editor';
|
|
2
|
+
import type { NodePaletteItem } from '../types/api';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
sidebarCollapsed?: boolean;
|
|
5
|
+
sidebarWidth?: number;
|
|
6
|
+
hideSidebar?: boolean;
|
|
7
|
+
hideFooter?: boolean;
|
|
8
|
+
editor?: CanvasEditorContext;
|
|
9
|
+
paletteItems?: NodePaletteItem[];
|
|
10
|
+
};
|
|
11
|
+
type __VLS_Slots = {
|
|
12
|
+
sidebar?: () => unknown;
|
|
13
|
+
default?: () => unknown;
|
|
14
|
+
footer?: () => unknown;
|
|
15
|
+
};
|
|
16
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
|
+
"update:sidebarCollapsed": (value: boolean) => any;
|
|
18
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
19
|
+
"onUpdate:sidebarCollapsed"?: ((value: boolean) => any) | undefined;
|
|
20
|
+
}>, {
|
|
21
|
+
editor: CanvasEditorContext;
|
|
22
|
+
sidebarCollapsed: boolean;
|
|
23
|
+
sidebarWidth: number;
|
|
24
|
+
hideSidebar: boolean;
|
|
25
|
+
hideFooter: boolean;
|
|
26
|
+
paletteItems: NodePaletteItem[];
|
|
27
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
29
|
+
declare const _default: typeof __VLS_export;
|
|
30
|
+
export default _default;
|
|
31
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
32
|
+
new (): {
|
|
33
|
+
$slots: S;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CanvasEditorContext } from '../core/editor';
|
|
2
|
+
import type { NodePaletteItem } from '../types/api';
|
|
3
|
+
import '../assets/iconcool/style.css';
|
|
4
|
+
type __VLS_Props = {
|
|
5
|
+
editor: CanvasEditorContext;
|
|
6
|
+
items?: NodePaletteItem[];
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CanvasToolbarItem, BuiltinToolbarType } from '../types/api';
|
|
2
|
+
import type { CanvasEditorContext } from '../core/editor';
|
|
3
|
+
import '../assets/iconcool/style.css';
|
|
4
|
+
type __VLS_Props = {
|
|
5
|
+
items?: CanvasToolbarItem[];
|
|
6
|
+
exclude?: BuiltinToolbarType[];
|
|
7
|
+
editor: CanvasEditorContext;
|
|
8
|
+
};
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import '../assets/iconcool/style.css';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
3
|
+
declare const _default: typeof __VLS_export;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { CanvasSchema, CanvasEdgeDefinition } from '../types/schema';
|
|
2
|
+
import type { NodePaletteItem } from '../types/api';
|
|
3
|
+
export interface DefaultNodeTypeConfig {
|
|
4
|
+
label?: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
width?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface DefaultSchemaOptions {
|
|
10
|
+
nodeTypes?: Record<string, DefaultNodeTypeConfig>;
|
|
11
|
+
/** 默认连线类型,内置 'manhattan' | 'bezier',也可指向自定义类型 key */
|
|
12
|
+
defaultEdgeType?: string;
|
|
13
|
+
/** 额外/覆盖的边类型定义,会与内置类型合并 */
|
|
14
|
+
edgeTypes?: Record<string, CanvasEdgeDefinition>;
|
|
15
|
+
}
|
|
16
|
+
export interface DefaultSchemaResult {
|
|
17
|
+
schema: CanvasSchema;
|
|
18
|
+
paletteItems: NodePaletteItem[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 创建内置的默认 Schema,提供开箱即用的节点与边类型。
|
|
22
|
+
*
|
|
23
|
+
* 节点类型使用 DefaultNode 组件渲染,自带上/右/下/左四个连接端口。
|
|
24
|
+
* 不传参数时提供 7 种节点类型和 2 种内置边类型(manhattan / bezier)。
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // 默认 manhattan 直角连线
|
|
28
|
+
* const { schema, paletteItems } = createDefaultSchema();
|
|
29
|
+
*
|
|
30
|
+
* // 切换为贝塞尔曲线连线
|
|
31
|
+
* const { schema, paletteItems } = createDefaultSchema({ defaultEdgeType: 'bezier' });
|
|
32
|
+
*
|
|
33
|
+
* // 自定义边类型
|
|
34
|
+
* const { schema, paletteItems } = createDefaultSchema({
|
|
35
|
+
* defaultEdgeType: 'myEdge',
|
|
36
|
+
* edgeTypes: { myEdge: { connector: 'normal', style: ... } },
|
|
37
|
+
* });
|
|
38
|
+
*/
|
|
39
|
+
export declare function createDefaultSchema(options?: DefaultSchemaOptions): DefaultSchemaResult;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FlowNodeModel } from '../types/flow-model';
|
|
2
|
+
import type { ScreenPosition } from '../types/command';
|
|
3
|
+
import type { NodeActionsConfig } from '../types/api';
|
|
4
|
+
import type { NodeBehaviorConfig } from '../types/schema';
|
|
5
|
+
import '../assets/iconcool/style.css';
|
|
6
|
+
type __VLS_Props = {
|
|
7
|
+
node: FlowNodeModel;
|
|
8
|
+
position: ScreenPosition;
|
|
9
|
+
config: Required<NodeActionsConfig>;
|
|
10
|
+
behavior: NodeBehaviorConfig;
|
|
11
|
+
};
|
|
12
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
13
|
+
action: (type: "delete" | "copy" | "copy-insert" | "disconnect" | "debug", nodeId: string) => any;
|
|
14
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
15
|
+
onAction?: ((type: "delete" | "copy" | "copy-insert" | "disconnect" | "debug", nodeId: string) => any) | undefined;
|
|
16
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
17
|
+
declare const _default: typeof __VLS_export;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { FlowNodeModel } from '../types/flow-model';
|
|
2
|
+
import type { ScreenPosition } from '../types/command';
|
|
3
|
+
import '../assets/iconcool/style.css';
|
|
4
|
+
type __VLS_Props = {
|
|
5
|
+
node: FlowNodeModel;
|
|
6
|
+
portPosition: ScreenPosition;
|
|
7
|
+
tooltipText?: string;
|
|
8
|
+
};
|
|
9
|
+
declare function closePopover(): void;
|
|
10
|
+
declare var __VLS_7: {};
|
|
11
|
+
type __VLS_Slots = {} & {
|
|
12
|
+
default?: (props: typeof __VLS_7) => any;
|
|
13
|
+
};
|
|
14
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
15
|
+
closePopover: typeof closePopover;
|
|
16
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
|
+
close: () => any;
|
|
18
|
+
mouseenter: () => any;
|
|
19
|
+
mouseleave: () => any;
|
|
20
|
+
open: (nodeId: string) => any;
|
|
21
|
+
"start-drag": (nodeId: string) => any;
|
|
22
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
23
|
+
onClose?: (() => any) | undefined;
|
|
24
|
+
onMouseenter?: (() => any) | undefined;
|
|
25
|
+
onMouseleave?: (() => any) | undefined;
|
|
26
|
+
onOpen?: ((nodeId: string) => any) | undefined;
|
|
27
|
+
"onStart-drag"?: ((nodeId: string) => any) | undefined;
|
|
28
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
29
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
30
|
+
declare const _default: typeof __VLS_export;
|
|
31
|
+
export default _default;
|
|
32
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
33
|
+
new (): {
|
|
34
|
+
$slots: S;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CanvasToolbarItem, BuiltinToolbarType } from '../types/api';
|
|
2
|
+
export interface DefaultToolbarItemsOptions {
|
|
3
|
+
/** 要排除的操作项类型(仅对可隐藏的组生效,zoom 和 reset 组固定不可排除) */
|
|
4
|
+
exclude?: BuiltinToolbarType[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 工具栏默认项分为四组(从左到右):
|
|
8
|
+
* 1. history: 撤销、重做 — 可隐藏
|
|
9
|
+
* 2. tools: 框选、自动排版、搜索、缩略图、下载 — 可隐藏
|
|
10
|
+
* 3. zoom: 缩小、放大 — 固定
|
|
11
|
+
* 4. reset: 重置 — 固定
|
|
12
|
+
*/
|
|
13
|
+
export declare function createDefaultToolbarItems(options?: DefaultToolbarItemsOptions): CanvasToolbarItem[];
|