@logicflow/core 2.2.1 → 2.2.3
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 +32 -0
- package/dist/docs/api/logicflow-constructor/index.en.md +106 -0
- package/dist/docs/api/logicflow-constructor/index.zh.md +106 -0
- package/dist/docs/api/logicflow-constructor/use.en.md +61 -0
- package/dist/docs/api/logicflow-constructor/use.zh.md +61 -0
- package/dist/docs/api/logicflow-instance/canvas.en.md +197 -0
- package/dist/docs/api/logicflow-instance/canvas.zh.md +199 -0
- package/dist/docs/api/logicflow-instance/edge.en.md +273 -0
- package/dist/docs/api/logicflow-instance/edge.zh.md +273 -0
- package/dist/docs/api/logicflow-instance/edit-config.en.md +59 -0
- package/dist/docs/api/logicflow-instance/edit-config.zh.md +59 -0
- package/dist/docs/api/logicflow-instance/element.en.md +375 -0
- package/dist/docs/api/logicflow-instance/element.zh.md +379 -0
- package/dist/docs/api/logicflow-instance/event.en.md +326 -0
- package/dist/docs/api/logicflow-instance/event.zh.md +406 -0
- package/dist/docs/api/logicflow-instance/history.en.md +38 -0
- package/dist/docs/api/logicflow-instance/history.zh.md +38 -0
- package/dist/docs/api/logicflow-instance/index.en.md +41 -0
- package/dist/docs/api/logicflow-instance/index.zh.md +41 -0
- package/dist/docs/api/logicflow-instance/node.en.md +308 -0
- package/dist/docs/api/logicflow-instance/node.zh.md +308 -0
- package/dist/docs/api/logicflow-instance/register.en.md +76 -0
- package/dist/docs/api/logicflow-instance/register.zh.md +76 -0
- package/dist/docs/api/logicflow-instance/render-and-data.en.md +179 -0
- package/dist/docs/api/logicflow-instance/render-and-data.zh.md +181 -0
- package/dist/docs/api/logicflow-instance/text.en.md +60 -0
- package/dist/docs/api/logicflow-instance/text.zh.md +60 -0
- package/dist/docs/api/logicflow-instance/theme.en.md +179 -0
- package/dist/docs/api/logicflow-instance/theme.zh.md +179 -0
- package/dist/docs/api/runtime-model/edgeModel.en.md +29 -0
- package/dist/docs/api/runtime-model/edgeModel.zh.md +325 -0
- package/dist/docs/api/runtime-model/graphModel.en.md +275 -0
- package/dist/docs/api/runtime-model/graphModel.zh.md +1153 -0
- package/dist/docs/api/runtime-model/nodeModel.en.md +37 -0
- package/dist/docs/api/runtime-model/nodeModel.zh.md +644 -0
- package/dist/docs/api/type/MainTypes.en.md +598 -0
- package/dist/docs/api/type/MainTypes.zh.md +867 -0
- package/dist/docs/api/type/Theme.en.md +187 -0
- package/dist/docs/api/type/Theme.zh.md +187 -0
- package/dist/docs/api/type/canvas-types.en.md +25 -0
- package/dist/docs/api/type/canvas-types.zh.md +25 -0
- package/dist/docs/api/type/index.en.md +96 -0
- package/dist/docs/api/type/index.zh.md +99 -0
- package/dist/docs/api/type/node-types.en.md +21 -0
- package/dist/docs/api/type/node-types.zh.md +21 -0
- package/dist/docs/api/type/plugin-types.en.md +24 -0
- package/dist/docs/api/type/plugin-types.zh.md +24 -0
- package/dist/docs/index.md +11 -0
- package/dist/docs/tutorial/about.en.md +38 -0
- package/dist/docs/tutorial/about.zh.md +65 -0
- package/dist/docs/tutorial/advanced/dnd.en.md +62 -0
- package/dist/docs/tutorial/advanced/dnd.zh.md +52 -0
- package/dist/docs/tutorial/advanced/edge.en.md +64 -0
- package/dist/docs/tutorial/advanced/edge.zh.md +66 -0
- package/dist/docs/tutorial/advanced/keyboard.en.md +70 -0
- package/dist/docs/tutorial/advanced/keyboard.zh.md +67 -0
- package/dist/docs/tutorial/advanced/node.en.md +338 -0
- package/dist/docs/tutorial/advanced/node.zh.md +338 -0
- package/dist/docs/tutorial/advanced/react.en.md +106 -0
- package/dist/docs/tutorial/advanced/react.zh.md +114 -0
- package/dist/docs/tutorial/advanced/silent-mode.en.md +75 -0
- package/dist/docs/tutorial/advanced/silent-mode.zh.md +71 -0
- package/dist/docs/tutorial/advanced/snapline.en.md +54 -0
- package/dist/docs/tutorial/advanced/vue.en.md +249 -0
- package/dist/docs/tutorial/advanced/vue.zh.md +248 -0
- package/dist/docs/tutorial/ai.en.md +64 -0
- package/dist/docs/tutorial/ai.zh.md +64 -0
- package/dist/docs/tutorial/basic/background.en.md +50 -0
- package/dist/docs/tutorial/basic/canvas.en.md +164 -0
- package/dist/docs/tutorial/basic/canvas.zh.md +183 -0
- package/dist/docs/tutorial/basic/class.en.md +106 -0
- package/dist/docs/tutorial/basic/class.zh.md +103 -0
- package/dist/docs/tutorial/basic/edge.en.md +151 -0
- package/dist/docs/tutorial/basic/edge.zh.md +152 -0
- package/dist/docs/tutorial/basic/event.en.md +70 -0
- package/dist/docs/tutorial/basic/event.zh.md +66 -0
- package/dist/docs/tutorial/basic/grid.en.md +77 -0
- package/dist/docs/tutorial/basic/node.en.md +358 -0
- package/dist/docs/tutorial/basic/node.zh.md +318 -0
- package/dist/docs/tutorial/basic/theme.en.md +154 -0
- package/dist/docs/tutorial/basic/theme.zh.md +157 -0
- package/dist/docs/tutorial/extension/adapter.en.md +446 -0
- package/dist/docs/tutorial/extension/adapter.zh.md +429 -0
- package/dist/docs/tutorial/extension/bpmn-element.en.md +1427 -0
- package/dist/docs/tutorial/extension/bpmn-element.zh.md +1472 -0
- package/dist/docs/tutorial/extension/control.en.md +117 -0
- package/dist/docs/tutorial/extension/control.zh.md +118 -0
- package/dist/docs/tutorial/extension/curved-edge.en.md +46 -0
- package/dist/docs/tutorial/extension/curved-edge.zh.md +46 -0
- package/dist/docs/tutorial/extension/custom.en.md +142 -0
- package/dist/docs/tutorial/extension/custom.zh.md +138 -0
- package/dist/docs/tutorial/extension/dnd-panel.en.md +109 -0
- package/dist/docs/tutorial/extension/dnd-panel.zh.md +109 -0
- package/dist/docs/tutorial/extension/dynamic-group.en.md +606 -0
- package/dist/docs/tutorial/extension/dynamic-group.zh.md +606 -0
- package/dist/docs/tutorial/extension/group.en.md +217 -0
- package/dist/docs/tutorial/extension/group.zh.md +209 -0
- package/dist/docs/tutorial/extension/highlight.en.md +50 -0
- package/dist/docs/tutorial/extension/highlight.zh.md +50 -0
- package/dist/docs/tutorial/extension/insert-node-in-polyline.en.md +52 -0
- package/dist/docs/tutorial/extension/insert-node-in-polyline.zh.md +47 -0
- package/dist/docs/tutorial/extension/intro.en.md +72 -0
- package/dist/docs/tutorial/extension/intro.zh.md +95 -0
- package/dist/docs/tutorial/extension/label.en.md +136 -0
- package/dist/docs/tutorial/extension/label.zh.md +135 -0
- package/dist/docs/tutorial/extension/layout.en.md +156 -0
- package/dist/docs/tutorial/extension/layout.zh.md +156 -0
- package/dist/docs/tutorial/extension/menu.en.md +319 -0
- package/dist/docs/tutorial/extension/menu.zh.md +377 -0
- package/dist/docs/tutorial/extension/minimap.en.md +164 -0
- package/dist/docs/tutorial/extension/minimap.zh.md +180 -0
- package/dist/docs/tutorial/extension/node-resize.en.md +199 -0
- package/dist/docs/tutorial/extension/node-resize.zh.md +221 -0
- package/dist/docs/tutorial/extension/pool.en.md +227 -0
- package/dist/docs/tutorial/extension/pool.zh.md +227 -0
- package/dist/docs/tutorial/extension/proximity-connect.en.md +104 -0
- package/dist/docs/tutorial/extension/proximity-connect.zh.md +107 -0
- package/dist/docs/tutorial/extension/selection.en.md +166 -0
- package/dist/docs/tutorial/extension/selection.zh.md +150 -0
- package/dist/docs/tutorial/extension/snapshot.en.md +276 -0
- package/dist/docs/tutorial/extension/snapshot.zh.md +276 -0
- package/dist/docs/tutorial/get-started.en.md +501 -0
- package/dist/docs/tutorial/get-started.zh.md +139 -0
- package/dist/docs/tutorial/update.en.md +213 -0
- package/dist/docs/tutorial/update.zh.md +212 -0
- package/package.json +5 -3
- package/scripts/postinstall-ai-prompt.js +67 -0
package/README.md
CHANGED
|
@@ -102,6 +102,38 @@ const lf = new LogicFlow({
|
|
|
102
102
|
lf.render(data);
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
+
## AI 编程支持
|
|
106
|
+
|
|
107
|
+
LogicFlow 为 AI 编程工具提供了随 npm 包发布的本地文档。`@logicflow/core@2.2.2` 及以上版本会包含这些文档。安装或升级后,可以把下面这段提示词复制给你的 AI Agent,让它在实现 LogicFlow 功能前先查官方文档。
|
|
108
|
+
|
|
109
|
+
更多说明请查看 [AI 编程支持](https://site.logic-flow.cn/tutorial/ai)。
|
|
110
|
+
|
|
111
|
+
升级 `@logicflow/core` 后,请将最新版提示词再次提供给 Agent。
|
|
112
|
+
|
|
113
|
+
```md
|
|
114
|
+
<!-- BEGIN:logicflow-agent-rules -->
|
|
115
|
+
# LogicFlow Agent Rules
|
|
116
|
+
|
|
117
|
+
LogicFlow documentation is available at:
|
|
118
|
+
|
|
119
|
+
- `node_modules/@logicflow/core/dist/docs/`
|
|
120
|
+
|
|
121
|
+
Package roles:
|
|
122
|
+
|
|
123
|
+
- `@logicflow/core`: core graph editor runtime, including canvas, nodes, edges, models, events, rendering, themes, and basic interactions.
|
|
124
|
+
- `@logicflow/extension`: official plugins for common product features.
|
|
125
|
+
- `@logicflow/layout`: official layout plugins for automatic graph layout.
|
|
126
|
+
|
|
127
|
+
The docs for `@logicflow/extension` and `@logicflow/layout` are included under:
|
|
128
|
+
|
|
129
|
+
- `node_modules/@logicflow/core/dist/docs/tutorial/extension/`
|
|
130
|
+
|
|
131
|
+
Before implementing any LogicFlow feature, check the local docs first to see whether LogicFlow already provides a built-in, extension, or layout capability. If it does, prefer the documented official capability instead of reimplementing it from scratch.
|
|
132
|
+
|
|
133
|
+
If an official package is needed but not installed, ask the user before installing it.
|
|
134
|
+
<!-- END:logicflow-agent-rules -->
|
|
135
|
+
```
|
|
136
|
+
|
|
105
137
|
## 文档
|
|
106
138
|
|
|
107
139
|
[官方文档](https://docs.logic-flow.cn)
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav: API
|
|
3
|
+
group:
|
|
4
|
+
title: LogicFlow
|
|
5
|
+
order: 1
|
|
6
|
+
title: Constructor
|
|
7
|
+
toc: content
|
|
8
|
+
order: 0
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Calling the constructor
|
|
12
|
+
|
|
13
|
+
```tsx | pure
|
|
14
|
+
import LogicFlow from '@logicflow/core'
|
|
15
|
+
|
|
16
|
+
const options: LogicFlow.Options = {
|
|
17
|
+
// ...
|
|
18
|
+
}
|
|
19
|
+
new LogicFlow(options)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Basic options
|
|
23
|
+
|
|
24
|
+
| Option | Type | Required | Default | Description |
|
|
25
|
+
| :--------- | :---------- | :------- | :------ | :---------- |
|
|
26
|
+
| container | `HTMLElement` | Yes | - | DOM container for the diagram. |
|
|
27
|
+
| width | number | No | - | Canvas width in `px`; defaults to container width. |
|
|
28
|
+
| height | number | No | - | Canvas height in `px`; defaults to container height. |
|
|
29
|
+
| autoExpand | boolean | No | false | Expand the canvas when nodes are dragged near the edge. |
|
|
30
|
+
|
|
31
|
+
## Canvas options
|
|
32
|
+
|
|
33
|
+
| Option | Type | Required | Default | Description |
|
|
34
|
+
| :--------------- | :--- | :------- | :------ | :---------- |
|
|
35
|
+
| background | false \| [`BackgroundConfig`](../type/MainTypes.en.md#backgroundconfig) | No | false | Background layer; `false` disables it. |
|
|
36
|
+
| grid | number / boolean / [`GridOptions`](../type/MainTypes.en.md#gridoptions) | No | false | Grid configuration. |
|
|
37
|
+
| snapGrid | boolean | No | false | Snap dragging to the grid. |
|
|
38
|
+
| partial | boolean | No | false | Enable partial rendering for large graphs. |
|
|
39
|
+
| animation | boolean \| `Partial<AnimationConfig>`([`AnimationConfig`](../type/MainTypes.en.md#animationconfig)) | No | - | Animation toggles and per-kind settings. |
|
|
40
|
+
| overlapMode | [`OverlapMode`](../type/MainTypes.en.md#common) | No | - | Z-ordering when elements overlap. |
|
|
41
|
+
| snapline | boolean | No | true | Show snaplines while dragging nodes. |
|
|
42
|
+
| stopScrollGraph | boolean | No | false | Disable wheel panning. |
|
|
43
|
+
| stopZoomGraph | boolean | No | false | Disable zoom. |
|
|
44
|
+
| stopMoveGraph | boolean \| 'vertical' \| 'horizontal' \| [number, number, number, number] | No | false | Constrain or disable canvas panning. |
|
|
45
|
+
|
|
46
|
+
## Edit control
|
|
47
|
+
|
|
48
|
+
| Option | Type | Required | Default | Description |
|
|
49
|
+
| :--------------------- | :--- | :------- | :------ | :---------- |
|
|
50
|
+
| isSilentMode | boolean | No | false | Read-only / presentation mode. |
|
|
51
|
+
| guards | [`GuardsConfig`](../type/MainTypes.en.md#guardsconfig) | No | - | Guard callbacks (`beforeClone`, `beforeDelete`, …). |
|
|
52
|
+
| disabledTools | `string[]` | No | - | Built-in tools to disable. |
|
|
53
|
+
| adjustEdge | boolean | No | true | Allow edge adjustment. |
|
|
54
|
+
| adjustEdgeStartAndEnd | boolean | No | false | Allow dragging edge endpoints. |
|
|
55
|
+
| adjustNodePosition | boolean | No | true | Allow moving nodes. |
|
|
56
|
+
| hideAnchors | boolean | No | false | Hide node anchors. |
|
|
57
|
+
| outline | boolean | No | false | Outer selection box for nodes. |
|
|
58
|
+
| hoverOutline | boolean | No | true | Outline on hover. |
|
|
59
|
+
| nodeSelectedOutline | boolean | No | true | Outline when a node is selected. |
|
|
60
|
+
| edgeSelectedOutline | boolean | No | true | Outline when an edge is selected. |
|
|
61
|
+
| nodeTextEdit | boolean | No | true | Allow editing node text. |
|
|
62
|
+
| edgeTextEdit | boolean | No | true | Allow editing edge text. |
|
|
63
|
+
| textEdit | boolean | No | true | Master text-edit switch. |
|
|
64
|
+
| nodeTextDraggable | boolean | No | false | Allow dragging node text. |
|
|
65
|
+
| edgeTextDraggable | boolean | No | false | Allow dragging edge text. |
|
|
66
|
+
| multipleSelectKey | string | No | - | Multi-select modifier (`meta` / `shift` / `alt`). |
|
|
67
|
+
| idGenerator | function | No | - | Custom id generator for new nodes/edges. |
|
|
68
|
+
| customTargetAnchor | [`customTargetAnchorType`](../type/MainTypes.en.md#customtargetanchortype) | No | - | Custom anchor picking when connecting. |
|
|
69
|
+
| edgeGenerator | [`EdgeGeneratorType`](../type/MainTypes.en.md#edgegeneratortype) | No | - | Rule for edge type when connecting. |
|
|
70
|
+
| customTrajectory | function | No | - | Custom anchor line rendering. |
|
|
71
|
+
|
|
72
|
+
## Keyboard
|
|
73
|
+
|
|
74
|
+
| Option | Type | Required | Default | Description |
|
|
75
|
+
| :------- | :--- | :------- | :------ | :---------- |
|
|
76
|
+
| keyboard | [`KeyboardDef`](../type/MainTypes.en.md#keyboarddef) | No | - | Keyboard shortcuts configuration. |
|
|
77
|
+
|
|
78
|
+
Built-in shortcuts (when `keyboard.enabled = true`):
|
|
79
|
+
|
|
80
|
+
- `cmd + c` / `ctrl + c`: copy
|
|
81
|
+
- `cmd + v` / `ctrl + v`: paste
|
|
82
|
+
- `cmd + z` / `ctrl + z`: undo
|
|
83
|
+
- `cmd + y` / `ctrl + y`: redo
|
|
84
|
+
- `backspace`: delete
|
|
85
|
+
|
|
86
|
+
## Theme
|
|
87
|
+
|
|
88
|
+
| Option | Type | Required | Default | Description |
|
|
89
|
+
| :-------- | :--- | :------- | :------ | :---------- |
|
|
90
|
+
| style | [`Theme`](../type/Theme.en.md#theme) | No | - | Visual theme for nodes, edges, text, anchors, etc. |
|
|
91
|
+
| themeMode | string | No | - | Built-in presets: `default`, `dark`, `colorful`, `radius`. |
|
|
92
|
+
| edgeType | [`EdgeType`](../type/MainTypes.en.md#edgetype) | No | `polyline` | Default edge type created from the UI. |
|
|
93
|
+
|
|
94
|
+
## Plugins
|
|
95
|
+
|
|
96
|
+
| Option | Type | Required | Default | Description |
|
|
97
|
+
| :-------------- | :--- | :------- | :------ | :---------- |
|
|
98
|
+
| disabledPlugins | `string[]` | No | - | Plugins not to load at init. |
|
|
99
|
+
| plugins | [`ExtensionConstructor`](../type/MainTypes.en.md#extensionconstructor)`[]` | No | - | Plugins for this instance; falls back to global list. |
|
|
100
|
+
| pluginsOptions | any | No | - | Options passed to plugins. |
|
|
101
|
+
|
|
102
|
+
## History
|
|
103
|
+
|
|
104
|
+
| Option | Type | Required | Default | Description |
|
|
105
|
+
| :------ | :--- | :------- | :------ | :---------- |
|
|
106
|
+
| history | boolean | No | true | Enable undo/redo stack. |
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav: API
|
|
3
|
+
group:
|
|
4
|
+
title: LogicFlow
|
|
5
|
+
order: 1
|
|
6
|
+
title: 构造方法
|
|
7
|
+
toc: content
|
|
8
|
+
order: 0
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 构造方法调用
|
|
12
|
+
|
|
13
|
+
```tsx | pure
|
|
14
|
+
import LogicFlow from '@logicflow/core'
|
|
15
|
+
|
|
16
|
+
const options: LogicFlow.Options = {
|
|
17
|
+
// ...
|
|
18
|
+
}
|
|
19
|
+
new LogicFlow(options)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 基础配置
|
|
23
|
+
|
|
24
|
+
| 选项 | 类型 | 必选 | 默认值 | 描述 |
|
|
25
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
26
|
+
| container | `HTMLElement` | ✅ | - | 图的 DOM 容器。 |
|
|
27
|
+
| width | number | - | - | 指定画布宽度,单位为 `px`,默认使用容器宽度。 |
|
|
28
|
+
| height | number | - | - | 指定画布高度,单位为 `px`,默认使用容器高度。 |
|
|
29
|
+
| autoExpand | boolean | - | false | 节点拖动靠近画布边缘时是否自动扩充画布。 |
|
|
30
|
+
|
|
31
|
+
## 画布配置
|
|
32
|
+
|
|
33
|
+
| 选项 | 类型 | 必选 | 默认值 | 描述 |
|
|
34
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
35
|
+
| background | false \| [`BackgroundConfig`](../type/MainTypes.zh.md#backgroundconfig背景配置) | - | false | 画布背景,默认无背景,支持传入参数配置。 |
|
|
36
|
+
| grid | number / boolean / [`GridOptions`](../type/MainTypes.zh.md#gridoptions网格配置) | - | false | 网格配置,支持关闭、默认点状网格或自定义参数。 |
|
|
37
|
+
| snapGrid | boolean | - | false | 是否开启网格吸附。 |
|
|
38
|
+
| partial | boolean | - | false | 是否开启局部渲染功能。 |
|
|
39
|
+
| animation | boolean \| `Partial<AnimationConfig>`([`AnimationConfig`](../type/MainTypes.zh.md#animationconfig动画配置)) | - | - | 是否开启动画功能,可统一开关和单独配置。 |
|
|
40
|
+
| overlapMode | [`OverlapMode`](../type/MainTypes.zh.md#common实例基础配置项) | - | - | 元素重合堆叠模式。 |
|
|
41
|
+
| snapline | boolean | - | true | 是否启用节点辅助对齐线。 |
|
|
42
|
+
| stopScrollGraph | boolean | - | false | 禁止鼠标滚动移动画布。 |
|
|
43
|
+
| stopZoomGraph | boolean | - | false | 禁止缩放画布。 |
|
|
44
|
+
| stopMoveGraph | boolean \| 'vertical' \| 'horizontal' \| [number, number, number, number] | - | false | 禁止拖动画布。 |
|
|
45
|
+
|
|
46
|
+
## 编辑控制
|
|
47
|
+
|
|
48
|
+
| 选项 | 类型 | 必选 | 默认值 | 描述 |
|
|
49
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
50
|
+
| isSilentMode | boolean | - | false | 仅浏览不可编辑模式,默认不开启。 |
|
|
51
|
+
| guards | [`GuardsConfig`](../type/MainTypes.zh.md#guardsconfig守卫函数类型) | - | - | 守卫函数配置(`beforeClone`、`beforeDelete`)。 |
|
|
52
|
+
| disabledTools | `string[]` | - | - | 禁止启用的内置工具。 |
|
|
53
|
+
| adjustEdge | boolean | - | true | 允许调整边。 |
|
|
54
|
+
| adjustEdgeStartAndEnd | boolean | - | false | 是否允许拖动边端点调整连线。 |
|
|
55
|
+
| adjustNodePosition | boolean | - | true | 是否允许拖动节点。 |
|
|
56
|
+
| hideAnchors | boolean | - | false | 是否隐藏节点锚点。 |
|
|
57
|
+
| outline | boolean | - | false | 节点选择外侧选框是否展示。 |
|
|
58
|
+
| hoverOutline | boolean | - | true | 鼠标悬停时是否显示节点外框。 |
|
|
59
|
+
| nodeSelectedOutline | boolean | - | true | 节点选中时是否显示节点外框。 |
|
|
60
|
+
| edgeSelectedOutline | boolean | - | true | 边选中时是否显示边外框。 |
|
|
61
|
+
| nodeTextEdit | boolean | - | true | 允许节点文本编辑。 |
|
|
62
|
+
| edgeTextEdit | boolean | - | true | 允许边文本编辑。 |
|
|
63
|
+
| textEdit | boolean | - | true | 是否开启文本编辑。 |
|
|
64
|
+
| nodeTextDraggable | boolean | - | false | 允许节点文本拖拽。 |
|
|
65
|
+
| edgeTextDraggable | boolean | - | false | 允许边文本拖拽。 |
|
|
66
|
+
| multipleSelectKey | string | - | - | 多选按键(`meta` / `shift` / `alt`)。 |
|
|
67
|
+
| idGenerator | function | - | - | 自定义创建节点、连线时的 ID 生成规则。 |
|
|
68
|
+
| customTargetAnchor | [`customTargetAnchorType`](../type/MainTypes.zh.md#customtargetanchortype自定义锚点连接规则) | - | - | 自定义锚点连接规则。 |
|
|
69
|
+
| edgeGenerator | [`EdgeGeneratorType`](../type/MainTypes.zh.md#edgegeneratortype自定义边生成函数) | - | - | 连接节点及移动边时边的生成规则。 |
|
|
70
|
+
| customTrajectory | function | - | - | 自定义连线轨迹。 |
|
|
71
|
+
|
|
72
|
+
## 快捷键配置
|
|
73
|
+
|
|
74
|
+
| 选项 | 类型 | 必选 | 默认值 | 描述 |
|
|
75
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
76
|
+
| keyboard | [`KeyboardDef`](../type/MainTypes.zh.md#keyboarddef快捷键参数类型) | - | - | 自定义键盘相关配置。 |
|
|
77
|
+
|
|
78
|
+
内置快捷键(启用 `keyboard.enabled = true` 后可用):
|
|
79
|
+
|
|
80
|
+
- `cmd + c` / `ctrl + c`:复制
|
|
81
|
+
- `cmd + v` / `ctrl + v`:粘贴
|
|
82
|
+
- `cmd + z` / `ctrl + z`:撤销
|
|
83
|
+
- `cmd + y` / `ctrl + y`:重做
|
|
84
|
+
- `backspace`:删除
|
|
85
|
+
|
|
86
|
+
## 主题配置
|
|
87
|
+
|
|
88
|
+
| 选项 | 类型 | 必选 | 默认值 | 描述 |
|
|
89
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
90
|
+
| style | [`Theme`](../type/Theme.zh.md#theme主题配置) | - | - | 样式配置,用于定义节点、边、文本、锚点等视觉效果。 |
|
|
91
|
+
| themeMode | string | - | - | 主题类型,内置支持 `default` / `dark` / `colorful` / `radius`。 |
|
|
92
|
+
| edgeType | [`EdgeType`](../type/MainTypes.zh.md#edgetype边类型) | - | `polyline` | 在图上编辑创建边的默认类型。 |
|
|
93
|
+
|
|
94
|
+
## 插件控制
|
|
95
|
+
|
|
96
|
+
| 选项 | 类型 | 必选 | 默认值 | 描述 |
|
|
97
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
98
|
+
| disabledPlugins | `string[]` | - | - | 初始化时禁用加载的插件。 |
|
|
99
|
+
| plugins | [`ExtensionConstructor`](../type/MainTypes.zh.md#extensionconstructor插件构造函数)`[]` | - | - | 当前实例加载的插件,不传则采用全局插件。 |
|
|
100
|
+
| pluginsOptions | any | - | - | 插件初始化选项。 |
|
|
101
|
+
|
|
102
|
+
## 历史记录
|
|
103
|
+
|
|
104
|
+
| 选项 | 类型 | 必选 | 默认值 | 描述 |
|
|
105
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
106
|
+
| history | boolean | - | true | 是否开启历史记录功能。 |
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav: API
|
|
3
|
+
group:
|
|
4
|
+
title: LogicFlow
|
|
5
|
+
order: 1
|
|
6
|
+
title: LogicFlow.use
|
|
7
|
+
toc: content
|
|
8
|
+
order: 1
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
Register a plugin globally.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
LogicFlow.use(
|
|
15
|
+
extension: ExtensionConstructor | ExtensionDefinition,
|
|
16
|
+
props?: Record<string, unknown>,
|
|
17
|
+
): void
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Parameters:
|
|
21
|
+
|
|
22
|
+
| Name | Type | Required | Description |
|
|
23
|
+
| :--- | :--- | :--- | :--- |
|
|
24
|
+
| `extension` | [`ExtensionConstructor`](../type/MainTypes.en.md#extensionconstructor) \| [`ExtensionDefinition`](../type/MainTypes.en.md#extensiondefinition) | Yes | Plugin constructor or definition object. |
|
|
25
|
+
| `props` | `Record<string, unknown>` | No | Options passed to the plugin at registration time. |
|
|
26
|
+
|
|
27
|
+
Example:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import LogicFlow from '@logicflow/core'
|
|
31
|
+
|
|
32
|
+
class CustomPlugin {
|
|
33
|
+
static pluginName = 'CustomPlugin'
|
|
34
|
+
|
|
35
|
+
constructor({ lf, LogicFlow, props }) {
|
|
36
|
+
this.lf = lf
|
|
37
|
+
this.LogicFlow = LogicFlow
|
|
38
|
+
this.props = props
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
render(lf, container) {
|
|
42
|
+
const el = document.createElement('div')
|
|
43
|
+
el.textContent = 'Custom plugin'
|
|
44
|
+
container.appendChild(el)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
destroy() {
|
|
48
|
+
// Clean up listeners, timers, etc.
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
LogicFlow.use(CustomPlugin, {
|
|
53
|
+
featureFlag: true,
|
|
54
|
+
})
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Notes:
|
|
58
|
+
|
|
59
|
+
- `use` is static: call `LogicFlow.use(...)`.
|
|
60
|
+
- Plugins should expose a unique `pluginName` to avoid collisions.
|
|
61
|
+
- Whether a plugin runs for a given instance also depends on instance options (for example disabled lists).
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav: API
|
|
3
|
+
group:
|
|
4
|
+
title: LogicFlow
|
|
5
|
+
order: 1
|
|
6
|
+
title: LogicFlow.use
|
|
7
|
+
toc: content
|
|
8
|
+
order: 1
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
全局注册插件。
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
LogicFlow.use(
|
|
15
|
+
extension: ExtensionConstructor | ExtensionDefinition,
|
|
16
|
+
props?: Record<string, unknown>,
|
|
17
|
+
): void
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
参数说明:
|
|
21
|
+
|
|
22
|
+
| 名称 | 类型 | 必传 | 描述 |
|
|
23
|
+
| :--- | :--- | :--- | :--- |
|
|
24
|
+
| `extension` | [`ExtensionConstructor`](../type/MainTypes.zh.md#extensionconstructor插件构造函数) \| [`ExtensionDefinition`](../type/MainTypes.zh.md#extensiondefinition插件定义) | 是 | 插件构造器或插件定义对象 |
|
|
25
|
+
| `props` | `Record<string, unknown>` | 否 | 注册时传入的插件配置 |
|
|
26
|
+
|
|
27
|
+
示例:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import LogicFlow from '@logicflow/core'
|
|
31
|
+
|
|
32
|
+
class CustomPlugin {
|
|
33
|
+
static pluginName = 'CustomPlugin'
|
|
34
|
+
|
|
35
|
+
constructor({ lf, LogicFlow, props }) {
|
|
36
|
+
this.lf = lf
|
|
37
|
+
this.LogicFlow = LogicFlow
|
|
38
|
+
this.props = props
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
render(lf, container) {
|
|
42
|
+
const el = document.createElement('div')
|
|
43
|
+
el.textContent = 'Custom plugin'
|
|
44
|
+
container.appendChild(el)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
destroy() {
|
|
48
|
+
// 清理监听、定时器等资源
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
LogicFlow.use(CustomPlugin, {
|
|
53
|
+
featureFlag: true,
|
|
54
|
+
})
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
说明:
|
|
58
|
+
|
|
59
|
+
- `use` 是静态方法,需通过 `LogicFlow.use(...)` 调用。
|
|
60
|
+
- 插件应提供唯一的 `pluginName`,避免同名冲突。
|
|
61
|
+
- 插件是否在某个实例内生效,还受实例配置(如禁用列表)影响。
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav: API
|
|
3
|
+
group:
|
|
4
|
+
title: LogicFlow Instance
|
|
5
|
+
order: 2
|
|
6
|
+
title: Canvas
|
|
7
|
+
toc: content
|
|
8
|
+
order: 8
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
This page documents instance APIs for canvas size, viewport transforms, coordinate conversion, and edge animation.
|
|
12
|
+
|
|
13
|
+
### resize
|
|
14
|
+
|
|
15
|
+
Resize the canvas; when omitted, width and height are recomputed from the container.
|
|
16
|
+
|
|
17
|
+
**Signature**
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
resize(width?: number, height?: number): void
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Parameters**
|
|
24
|
+
|
|
25
|
+
| Name | Type | Required | Description |
|
|
26
|
+
| :--- | :--- | :--- | :--- |
|
|
27
|
+
| `width` | `number` | No | Target width. |
|
|
28
|
+
| `height` | `number` | No | Target height. |
|
|
29
|
+
|
|
30
|
+
### focusOn
|
|
31
|
+
|
|
32
|
+
Center the viewport on a node id or a canvas coordinate.
|
|
33
|
+
|
|
34
|
+
**Signature**
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
focusOn(focusOnArgs: { id?: string; coordinate?: { x: number; y: number } }): void
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Parameters**
|
|
41
|
+
|
|
42
|
+
| Name | Type | Required | Description |
|
|
43
|
+
| :--- | :--- | :--- | :--- |
|
|
44
|
+
| `focusOnArgs` | `object` | Yes | Provide either `id` or `coordinate`. |
|
|
45
|
+
|
|
46
|
+
### zoom
|
|
47
|
+
|
|
48
|
+
Zoom by step or explicit ratio, optionally around a point.
|
|
49
|
+
|
|
50
|
+
**Signature**
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
zoom(zoomSize?: boolean | number, point?: [number, number]): string
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Returns**
|
|
57
|
+
|
|
58
|
+
- `string`: current zoom as a percentage string.
|
|
59
|
+
|
|
60
|
+
### resetZoom
|
|
61
|
+
|
|
62
|
+
Reset zoom to `1`.
|
|
63
|
+
|
|
64
|
+
**Signature**
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
resetZoom(): void
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### setZoomMiniSize
|
|
71
|
+
|
|
72
|
+
Set the minimum allowed zoom factor.
|
|
73
|
+
|
|
74
|
+
**Signature**
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
setZoomMiniSize(size: number): void
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### setZoomMaxSize
|
|
81
|
+
|
|
82
|
+
Set the maximum allowed zoom factor.
|
|
83
|
+
|
|
84
|
+
**Signature**
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
setZoomMaxSize(size: number): void
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### getTransform
|
|
91
|
+
|
|
92
|
+
Read the current transform (scale and translation).
|
|
93
|
+
|
|
94
|
+
**Signature**
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
getTransform(): {
|
|
98
|
+
SCALE_X: number;
|
|
99
|
+
SCALE_Y: number;
|
|
100
|
+
TRANSLATE_X: number;
|
|
101
|
+
TRANSLATE_Y: number;
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### translate
|
|
106
|
+
|
|
107
|
+
Translate the canvas by a relative offset.
|
|
108
|
+
|
|
109
|
+
**Signature**
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
translate(x: number, y: number): void
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### resetTranslate
|
|
116
|
+
|
|
117
|
+
Reset translation to the initial state.
|
|
118
|
+
|
|
119
|
+
**Signature**
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
resetTranslate(): void
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### translateCenter
|
|
126
|
+
|
|
127
|
+
Center the graph content inside the viewport.
|
|
128
|
+
|
|
129
|
+
**Signature**
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
translateCenter(): void
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### fitView
|
|
136
|
+
|
|
137
|
+
Adjust zoom and translation so the graph fits the viewport.
|
|
138
|
+
|
|
139
|
+
**Signature**
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
fitView(verticalOffset?: number, horizontalOffset?: number): void
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### getPointByClient
|
|
146
|
+
|
|
147
|
+
Convert page coordinates to overlay positions (DOM and canvas layers).
|
|
148
|
+
|
|
149
|
+
**Signature**
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
getPointByClient(x: number, y: number): {
|
|
153
|
+
domOverlayPosition: { x: number; y: number };
|
|
154
|
+
canvasOverlayPosition: { x: number; y: number };
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### toFront
|
|
159
|
+
|
|
160
|
+
Raise the z-order of a node or edge.
|
|
161
|
+
|
|
162
|
+
**Signature**
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
toFront(id: string): void
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### openEdgeAnimation
|
|
169
|
+
|
|
170
|
+
Enable animation for an edge.
|
|
171
|
+
|
|
172
|
+
**Signature**
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
openEdgeAnimation(edgeId: string): void
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### closeEdgeAnimation
|
|
179
|
+
|
|
180
|
+
Disable animation for an edge.
|
|
181
|
+
|
|
182
|
+
**Signature**
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
closeEdgeAnimation(edgeId: string): void
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Common recipes
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
lf.resize();
|
|
192
|
+
lf.translateCenter();
|
|
193
|
+
lf.zoom(1.2);
|
|
194
|
+
|
|
195
|
+
const point = lf.getPointByClient(300, 200);
|
|
196
|
+
lf.focusOn({ coordinate: point.canvasOverlayPosition });
|
|
197
|
+
```
|