@logicflow/core 2.2.1 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav: Guide
|
|
3
|
+
group:
|
|
4
|
+
title: Plug-in functionality
|
|
5
|
+
order: 3
|
|
6
|
+
title: Progressive Connection
|
|
7
|
+
order: 6
|
|
8
|
+
toc: content
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
Progressive Connection is a dynamic interaction method in flowchart tools. Through dynamic interaction and intelligent adsorption, it helps users achieve accurate connection between nodes during the dragging process. It simplifies the operation and improves the efficiency and experience of complex process design.
|
|
12
|
+
|
|
13
|
+
## Demo
|
|
14
|
+
|
|
15
|
+
<code id="react-portal" src="@/src/tutorial/extension/proximity-connect"></code>
|
|
16
|
+
|
|
17
|
+
## Functional introduction
|
|
18
|
+
This plugin supports progressive connection in two scenarios:
|
|
19
|
+
- Drag node connection: When the mouse drags the node to move, find the nearest connectable anchor point connection according to the current node position
|
|
20
|
+
- Drag anchor point connection: When the mouse drags the node anchor point, find the nearest connectable anchor point connection according to the current mouse position
|
|
21
|
+
|
|
22
|
+
The plugin will listen to the following events and take some actions
|
|
23
|
+
| Event | Plugin Behavior |
|
|
24
|
+
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
25
|
+
| node:dragstart | Store the currently dragged node data in the plugin |
|
|
26
|
+
| node:drag | 1. Traverse all nodes on the canvas, calculate the distance between each anchor point on each node and each anchor point on the currently dragged node, find the shortest distance and a group of connectable anchor points and store them<br/>2. Determine whether the current shortest distance is less than the threshold. If so, create a virtual edge to show the final connection effect |
|
|
27
|
+
| node:drop | Delete the virtual edge and create a real edge |
|
|
28
|
+
| anchor:dragstart | Store the data of the currently dragged node and the trigger anchor point in the plug-in |
|
|
29
|
+
| anchor:drag | 1. Traverse all nodes on the canvas, find an anchor point that is the shortest distance from the current mouse position and can be connected and store it in the plug-in<br/>2. Determine whether the current shortest distance is less than the threshold. If so, create a virtual edge to show the final connection effect |
|
|
30
|
+
| anchor:dragend | Delete the virtual edge and create the real edge |
|
|
31
|
+
|
|
32
|
+
> Some Tips:
|
|
33
|
+
> 1. Before finding the anchor point, it will first determine whether there is a connection with the same anchor point and direction on the current canvas. If so, no connection will be created;
|
|
34
|
+
> 2. During the process of finding the anchor point, the anchor point data will be first obtained to determine whether the current set of anchor points can be connected. If not, no virtual edge will be generated;
|
|
35
|
+
|
|
36
|
+
## Use plug-ins
|
|
37
|
+
|
|
38
|
+
```tsx | pure
|
|
39
|
+
import LogicFlow from "@logicflow/core";
|
|
40
|
+
import { ProximityConnect } from "@logicflow/extension";
|
|
41
|
+
import "@logicflow/core/es/index.css";
|
|
42
|
+
import "@logicflow/extension/lib/style/index.css";
|
|
43
|
+
|
|
44
|
+
// Two ways of using
|
|
45
|
+
// Import the plugin through the use method
|
|
46
|
+
LogicFlow.use(ProximityConnect);
|
|
47
|
+
|
|
48
|
+
// Or enable the plugin through the configuration item (you can configure the plugin properties)
|
|
49
|
+
const lf = new LogicFlow({
|
|
50
|
+
container: document.querySelector('#app'),
|
|
51
|
+
plugins: [ProximityConnect],
|
|
52
|
+
pluginsOptions: {
|
|
53
|
+
proximityConnect: {
|
|
54
|
+
// enable, // Whether the plugin is enabled
|
|
55
|
+
// distance, // Progressive connection threshold
|
|
56
|
+
// reverseDirection, // Connection direction
|
|
57
|
+
// type, // Working mode: 'default' | 'node' | 'anchor'
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Configuration items
|
|
64
|
+
|
|
65
|
+
Each function in the menu can be represented by a configuration item. The specific fields are as follows:
|
|
66
|
+
|
|
67
|
+
| Field | Type | Default value | Required | Description |
|
|
68
|
+
| ---------------- | ------- | ----------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
69
|
+
| enable | boolean | `true` | | Enable the plugin |
|
|
70
|
+
| distance | number | 100 | | Gradual connection threshold |
|
|
71
|
+
| reverseDirection | boolean | false | | Whether to create a reverse connection<br/>The default connection direction is that the currently dragged node points to the nearest node<br/>When set to true, the nearest node will point to the currently dragged node |
|
|
72
|
+
| virtualEdgeStyle | object | { strokeDasharray: '10,10', stroke: '#acacac' } | | Virtual line style |
|
|
73
|
+
| type | string | 'default' | | Plugin working mode: `'default'`, `'node'`, or `'anchor'`. `default` supports both node drag and anchor drag; `node` works only during node dragging; `anchor` works only during anchor dragging. |
|
|
74
|
+
|
|
75
|
+
## API
|
|
76
|
+
### setThresholdDistance(distance)
|
|
77
|
+
Used to modify the connection threshold
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
setThresholdDistance = (distance: number): void => {}
|
|
81
|
+
```
|
|
82
|
+
### setReverseDirection(reverse)
|
|
83
|
+
Used to modify the direction of creating a connection
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
setReverseDirection = (reverse: boolean): void => {}
|
|
87
|
+
```
|
|
88
|
+
### setEnable(enable)
|
|
89
|
+
Used to set the plug-in enable status
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
setEnable = (enable: boolean): void => {}
|
|
93
|
+
```
|
|
94
|
+
### setVirtualEdgeStyle(style)
|
|
95
|
+
Set the virtual edge style
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
setVirtualEdgeStyle = (style: Record<string, unknown>): void => {}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Notes
|
|
102
|
+
|
|
103
|
+
- Deduplication: If a real edge with the same configuration (same source/target nodes and anchors, same direction) already exists on the canvas, the plugin will not create another virtual edge.
|
|
104
|
+
- Anchor drag end special case: When anchor dragging ends, if the release position falls within a node’s anchor area, the plugin will not trigger progressive connection creation to avoid duplicate connections with built-in anchor linking (see issue 2140).
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav: 指南
|
|
3
|
+
group:
|
|
4
|
+
title: 插件功能
|
|
5
|
+
order: 3
|
|
6
|
+
title: 渐进连线
|
|
7
|
+
order: 6
|
|
8
|
+
toc: content
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
渐进连线 是流程图工具中一种动态交互方式,通过动态交互和智能吸附,帮助用户在拖拽过程中实现节点之间的精准连接。简化了操作的同时还提升了复杂流程设计的效率和体验。
|
|
12
|
+
|
|
13
|
+
## 演示
|
|
14
|
+
|
|
15
|
+
<code id="react-portal" src="@/src/tutorial/extension/proximity-connect"></code>
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## 功能介绍
|
|
19
|
+
本插件支持两种场景下的渐进连线:
|
|
20
|
+
- 拖拽节点连线:鼠标拖拽节点移动过程中,根据当前节点的位置找距离最近的可连接的锚点连线
|
|
21
|
+
- 拖拽锚点连线:鼠标拖拽节点锚点过程中,根据鼠标当前所在位置找到距离最近的可连接的锚点连线
|
|
22
|
+
|
|
23
|
+
插件内部会监听以下几个事件,做一些动作
|
|
24
|
+
| 事件 | 插件行为 |
|
|
25
|
+
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
26
|
+
| node:dragstart | 将当前拖拽的节点数据存储到插件中 |
|
|
27
|
+
| node:drag | 1. 遍历画布上所有节点,计算每个节点上每个锚点与当前拖拽节点上每个锚点的距离,找出距离最短且可以连线的一组锚点存储下来<br/>2. 判断当前最短距离是否小于阈值,是的话就创建一条虚拟边,展示最终连线效果 |
|
|
28
|
+
| node:drop | 删除虚拟边,创建真实边 |
|
|
29
|
+
| anchor:dragstart | 将当前拖拽的节点和触发锚点的数据存储到插件中 |
|
|
30
|
+
| anchor:drag | 1. 遍历画布上所有节点,找出距离当前鼠标所在位置最短且可以连线的一个锚点存储到插件中<br/>2. 判断当前最短距离是否小于阈值,是的话就创建一条虚拟边,展示最终连线效果 |
|
|
31
|
+
| anchor:dragend | 删除虚拟边,创建真实边 |
|
|
32
|
+
|
|
33
|
+
> 一些Tip:
|
|
34
|
+
> 1. 找锚点前会先判断目前画布上是否已有同锚点同方向的连线,如果有,不会再创建连线;
|
|
35
|
+
> 2. 找锚点过程中会先取锚点数据判断当前的一组锚点是否可连线,如果不可连线不会生成虚拟边;
|
|
36
|
+
|
|
37
|
+
## 使用插件
|
|
38
|
+
|
|
39
|
+
```tsx | pure
|
|
40
|
+
import LogicFlow from "@logicflow/core";
|
|
41
|
+
import { ProximityConnect } from "@logicflow/extension";
|
|
42
|
+
import "@logicflow/core/es/index.css";
|
|
43
|
+
import "@logicflow/extension/lib/style/index.css";
|
|
44
|
+
|
|
45
|
+
// 两种使用方式
|
|
46
|
+
// 通过 use 方法引入插件
|
|
47
|
+
LogicFlow.use(ProximityConnect);
|
|
48
|
+
|
|
49
|
+
// 或者通过配置项启用插件(可以配置插件属性)
|
|
50
|
+
const lf = new LogicFlow({
|
|
51
|
+
container: document.querySelector('#app'),
|
|
52
|
+
plugins: [ProximityConnect],
|
|
53
|
+
pluginsOptions: {
|
|
54
|
+
proximityConnect: {
|
|
55
|
+
// enable, // 插件是否启用
|
|
56
|
+
// distance, // 渐进连线阈值
|
|
57
|
+
// reverseDirection, // 连线方向
|
|
58
|
+
// type, // 插件工作模式:'default' | 'node' | 'anchor'
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 配置项
|
|
65
|
+
|
|
66
|
+
菜单中的每一项功能,可以用一条配置进行表示。具体字段如下:
|
|
67
|
+
|
|
68
|
+
| 字段 | 类型 | 默认值 | 是否必须 | 描述 |
|
|
69
|
+
| ---------------- | ------- | ----------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
70
|
+
| enable | boolean | `true` | | 是否启用插件 |
|
|
71
|
+
| distance | number | 100 | | 渐进连线阈值 |
|
|
72
|
+
| reverseDirection | boolean | false | | 是否创建反向连线<br/>默认连线方向是当前拖拽的节点指向最近的节点<br/>设置为true后会变为最近的节点指向当前拖拽节点 |
|
|
73
|
+
| virtualEdgeStyle | object | { strokeDasharray: '10,10', stroke: '#acacac' } | | 虚拟线样式 |
|
|
74
|
+
| type | string | 'default' | | 插件工作模式:可选 `'default'`、`'node'`、`'anchor'`。`default` 同时支持节点拖拽与锚点拖拽;`node` 仅在节点拖拽时生效;`anchor` 仅在锚点拖拽时生效 |
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
## API
|
|
79
|
+
### setThresholdDistance(distance)
|
|
80
|
+
用于修改连线阈值
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
setThresholdDistance = (distance: number): void => {}
|
|
84
|
+
```
|
|
85
|
+
### setReverseDirection(reverse)
|
|
86
|
+
用于修改创建连线的方向
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
setReverseDirection = (reverse: boolean): void => {}
|
|
90
|
+
```
|
|
91
|
+
### setEnable(enable)
|
|
92
|
+
用于设置插件启用状态
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
setEnable = (enable: boolean): void => {}
|
|
96
|
+
```
|
|
97
|
+
### setVirtualEdgeStyle(style)
|
|
98
|
+
设置虚拟边样式
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
setVirtualEdgeStyle = (style: Record<string, unknown>): void => {}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 注意事项
|
|
105
|
+
|
|
106
|
+
- 去重逻辑:当画布上已存在同配置的真实边(同起止节点与锚点、同方向)时,插件不会再创建虚拟边,避免重复连线。
|
|
107
|
+
- 锚点拖拽结束的特殊处理:在锚点拖拽结束时,如果释放位置落在某个节点的锚点区域,将不触发插件的连线创建,以避免与内置锚点连线重复(参考 issue 2140)。
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav: Guide
|
|
3
|
+
group:
|
|
4
|
+
title: Plug-in functionality
|
|
5
|
+
order: 3
|
|
6
|
+
title: SelectionSelect
|
|
7
|
+
order: 5
|
|
8
|
+
toc: content
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<style>
|
|
12
|
+
table td:first-of-type {
|
|
13
|
+
word-break: normal;
|
|
14
|
+
}
|
|
15
|
+
</style>
|
|
16
|
+
|
|
17
|
+
The SelectionSelect plugin in LogicFlow allows users to select multiple graphical elements by dragging the mouse to draw a rectangular box, facilitating batch operations or editing.
|
|
18
|
+
|
|
19
|
+
## Demonstration
|
|
20
|
+
|
|
21
|
+
<code id="react-portal" src="@/src/tutorial/extension/selection-select"></code>
|
|
22
|
+
|
|
23
|
+
## Updates
|
|
24
|
+
|
|
25
|
+
### Exclusive Selection Mode
|
|
26
|
+
In version <Badge>2.0.13</Badge>, an exclusive selection mode was added. When enabled, users can only perform selection actions, and in turn, users can select multiple elements in batches. Already selected elements will be deselected when selected again.
|
|
27
|
+
Users can set whether to enable exclusive selection mode by default by passing the `exclusiveMode` parameter when creating an instance:
|
|
28
|
+
``` ts
|
|
29
|
+
const lf = new LogicFlow({
|
|
30
|
+
// ...config, // other configurations
|
|
31
|
+
plugins: [SelectionSelect],
|
|
32
|
+
pluginsOptions: {
|
|
33
|
+
selectionSelect: {
|
|
34
|
+
exclusiveMode: false,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
You can also dynamically modify the exclusive mode status by calling the [`setExclusiveMode`](#setexclusivemode) method below.
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
### Registration
|
|
44
|
+
|
|
45
|
+
There are two registration methods: global registration and local registration. The difference is that global registration allows every `lf` instance to use it.
|
|
46
|
+
|
|
47
|
+
```tsx | pure
|
|
48
|
+
import LogicFlow from "@logicflow/core";
|
|
49
|
+
import { SelectionSelect } from "@logicflow/extension";
|
|
50
|
+
|
|
51
|
+
// Global registration
|
|
52
|
+
LogicFlow.use(SelectionSelect);
|
|
53
|
+
|
|
54
|
+
// Local registration
|
|
55
|
+
const lf = new LogicFlow({
|
|
56
|
+
...config,
|
|
57
|
+
plugins: [SelectionSelect]
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
After registering the plugin, the following methods will be added during initialization:
|
|
62
|
+
|
|
63
|
+
## API
|
|
64
|
+
|
|
65
|
+
### openSelectionSelect
|
|
66
|
+
|
|
67
|
+
Enable selection selection.
|
|
68
|
+
|
|
69
|
+
```tsx | pure
|
|
70
|
+
lf.openSelectionSelect();
|
|
71
|
+
|
|
72
|
+
// Added in 1.1.0
|
|
73
|
+
lf.extension.selectionSelect.openSelectionSelect();
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### closeSelectionSelect
|
|
77
|
+
|
|
78
|
+
Disable selection selection.
|
|
79
|
+
|
|
80
|
+
```tsx | pure
|
|
81
|
+
lf.closeSelectionSelect();
|
|
82
|
+
|
|
83
|
+
// Added in 1.1.0
|
|
84
|
+
lf.extension.selectionSelect.closeSelectionSelect();
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### setSelectionSense
|
|
88
|
+
|
|
89
|
+
Set selection sensitivity.
|
|
90
|
+
|
|
91
|
+
- By default, the entire node must be within the selection box to be selected.
|
|
92
|
+
- By default, both the start and end points of the edge must be within the selection box to be selected.
|
|
93
|
+
|
|
94
|
+
You can call the `setSelectionSense` method to reconfigure this.
|
|
95
|
+
|
|
96
|
+
| Parameter | Default Value | Description |
|
|
97
|
+
| ----------- | ------------- | -------------------------------------------------------------------------------------------------- |
|
|
98
|
+
| isWholeEdge | true | Whether both the start and end points of the edge must be within the selection area to be selected |
|
|
99
|
+
| isWholeNode | true | Whether the entire node must be within the selection area to be selected |
|
|
100
|
+
|
|
101
|
+
Usage:
|
|
102
|
+
|
|
103
|
+
```tsx | pure
|
|
104
|
+
lf.extension.selectionSelect.setSelectionSense(false, true);
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### setExclusiveMode
|
|
108
|
+
|
|
109
|
+
Set the status of exclusive selection mode.
|
|
110
|
+
|
|
111
|
+
- Exclusive mode is disabled by default
|
|
112
|
+
|
|
113
|
+
You can call the plugin method `setExclusiveMode` to reconfigure
|
|
114
|
+
|
|
115
|
+
| Parameter | Default Value | Description |
|
|
116
|
+
| --------- | ------------- | -------------------------------- |
|
|
117
|
+
| status | false | Whether to enable exclusive mode |
|
|
118
|
+
|
|
119
|
+
Usage:
|
|
120
|
+
|
|
121
|
+
```tsx | pure
|
|
122
|
+
lf.extension.selectionSelect.setExclusiveMode(true);
|
|
123
|
+
|
|
124
|
+
// You can also use the runtime shortcut mounted on the lf instance.
|
|
125
|
+
// Note: this method is not typed in the current public types, so TypeScript projects should prefer the plugin instance method above.
|
|
126
|
+
lf.setSelectionSelectMode(true);
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Events
|
|
130
|
+
|
|
131
|
+
The selection plugin provides several events that you can listen to:
|
|
132
|
+
|
|
133
|
+
| Event Name | Description | Event Object |
|
|
134
|
+
| :-------------------- | :-------------------------------------- | :-------------------- |
|
|
135
|
+
| selection:selected | Triggered after selection box selection | All selected elements |
|
|
136
|
+
| selection:mousedown | Mouse pressed on selection area | e |
|
|
137
|
+
| selection:dragstart | Start dragging selection area | e |
|
|
138
|
+
| selection:drag | Selection area being dragged | e |
|
|
139
|
+
| selection:drop | Selection area drag released | e |
|
|
140
|
+
| selection:mousemove | Mouse moving in selection area | e, position |
|
|
141
|
+
| selection:mouseup | Mouse released in selection area | e |
|
|
142
|
+
| selection:contextmenu | Right-click in selection area | e |
|
|
143
|
+
|
|
144
|
+
The event object contains:
|
|
145
|
+
|
|
146
|
+
| Property | Type | Description |
|
|
147
|
+
| :------- | :--------- | :--------------------------------------------------------------------------------------------------------------------- |
|
|
148
|
+
| e | MouseEvent | Native mouse event object |
|
|
149
|
+
| position | Object | Mouse trigger point coordinates in canvas (See [getPointByClient](./detail/index.en.md#getpointbyclient) return value) |
|
|
150
|
+
|
|
151
|
+
## Default State
|
|
152
|
+
|
|
153
|
+
The default state of the selection functionality is influenced by whether the canvas dragging is allowed on the page. The canvas can either be dragged or have the selection box, but not both simultaneously.
|
|
154
|
+
|
|
155
|
+
```tsx | pure
|
|
156
|
+
const lf = new LogicFlow({
|
|
157
|
+
container: document.querySelector("#app"),
|
|
158
|
+
stopMoveGraph: true,
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
If `stopMoveGraph` is true, meaning canvas dragging is not allowed, then selection is enabled by default.
|
|
163
|
+
|
|
164
|
+
If `stopMoveGraph` is false, meaning canvas dragging is allowed, then selection is disabled by default.
|
|
165
|
+
|
|
166
|
+
In most cases, we expect to allow canvas dragging and only enable selection when the user clicks and drags the panel. Please refer to the [Drag-and-Drop Panel Plugin](dnd-panel.en.md).
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav: 指南
|
|
3
|
+
group:
|
|
4
|
+
title: 插件功能
|
|
5
|
+
order: 3
|
|
6
|
+
title: 框选 (SelectionSelect)
|
|
7
|
+
order: 5
|
|
8
|
+
toc: content
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<style>
|
|
12
|
+
table td:first-of-type {
|
|
13
|
+
word-break: normal;
|
|
14
|
+
}
|
|
15
|
+
</style>
|
|
16
|
+
|
|
17
|
+
LogicFlow 的框选插件允许用户通过拖动鼠标绘制矩形框来选择多个图形元素,方便进行批量操作或编辑。
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## 演示
|
|
21
|
+
|
|
22
|
+
<code id="react-portal" src="@/src/tutorial/extension/selection-select"></code>
|
|
23
|
+
|
|
24
|
+
## 更新
|
|
25
|
+
|
|
26
|
+
### 框选独占模式
|
|
27
|
+
在<Badge>2.0.13</Badge>版本新增了框选独占模式,开启后用户只能做框选动作,相对的用户可以分批框选多个元素,已框选的元素二次框选会被取消选中。
|
|
28
|
+
用户可以通过在创建实例时通过传入`exclusiveMode`参数用来设置是否默认开启独占框选模式
|
|
29
|
+
``` ts
|
|
30
|
+
const lf = new LogicFlow({
|
|
31
|
+
// ...config, // 其他配置
|
|
32
|
+
plugins: [SelectionSelect],
|
|
33
|
+
pluginsOptions: {
|
|
34
|
+
selectionSelect: {
|
|
35
|
+
exclusiveMode: false,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
也可以通过调用下方的[`setExclusiveMode`](#setexclusivemode)方法动态修改独占模式的启用状态。
|
|
41
|
+
|
|
42
|
+
## 使用
|
|
43
|
+
|
|
44
|
+
### 注册
|
|
45
|
+
|
|
46
|
+
两种注册方式,全局注册和局部注册,区别是全局注册每一个 `lf` 实例都可以使用。
|
|
47
|
+
|
|
48
|
+
```tsx | pure
|
|
49
|
+
import LogicFlow from "@logicflow/core";
|
|
50
|
+
import { SelectionSelect } from "@logicflow/extension";
|
|
51
|
+
|
|
52
|
+
// 全局注册
|
|
53
|
+
LogicFlow.use(SelectionSelect);
|
|
54
|
+
|
|
55
|
+
// 局部注册
|
|
56
|
+
const lf = new LogicFlow({
|
|
57
|
+
...config,
|
|
58
|
+
plugins: [SelectionSelect]
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
注册插件后,插件会在初始化时增加下述方法:
|
|
64
|
+
|
|
65
|
+
## API
|
|
66
|
+
|
|
67
|
+
### openSelectionSelect
|
|
68
|
+
|
|
69
|
+
开启框选。
|
|
70
|
+
|
|
71
|
+
```tsx | pure
|
|
72
|
+
|
|
73
|
+
lf.openSelectionSelect();
|
|
74
|
+
|
|
75
|
+
// 1.1.0新增用法
|
|
76
|
+
lf.extension.selectionSelect.openSelectionSelect();
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### closeSelectionSelect
|
|
81
|
+
|
|
82
|
+
关闭框选。
|
|
83
|
+
|
|
84
|
+
```tsx | pure
|
|
85
|
+
|
|
86
|
+
lf.closeSelectionSelect()
|
|
87
|
+
|
|
88
|
+
// 1.1.0新增用法
|
|
89
|
+
lf.extension.selectionSelect.closeSelectionSelect()
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### setSelectionSense
|
|
94
|
+
|
|
95
|
+
设置选区灵敏度。
|
|
96
|
+
|
|
97
|
+
- 默认需要框选整个节点才选中节点
|
|
98
|
+
- 默认需要框选边的起点、终点才选中边
|
|
99
|
+
|
|
100
|
+
可以调用插件方法`setSelectionSense`来重新设置
|
|
101
|
+
|
|
102
|
+
| 参数 | 默认值 | 描述 |
|
|
103
|
+
| ----------- | ------ | -------------------------------------- |
|
|
104
|
+
| isWholeEdge | true | 是否要边的起点终点都在选区范围才算选中 |
|
|
105
|
+
| isWholeNode | true | 是否要节点的全部点都在选区范围才算选中 |
|
|
106
|
+
|
|
107
|
+
用法:
|
|
108
|
+
|
|
109
|
+
```tsx | pure
|
|
110
|
+
lf.extension.selectionSelect.setSelectionSense(false, true);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### setExclusiveMode
|
|
114
|
+
|
|
115
|
+
设置框选独占模式的启用状态
|
|
116
|
+
|
|
117
|
+
- 默认不启用独占模式
|
|
118
|
+
|
|
119
|
+
可以调用插件实例方法 `setExclusiveMode` 来重新设置。
|
|
120
|
+
|
|
121
|
+
| 参数 | 默认值 | 描述 |
|
|
122
|
+
| ------ | ------ | ---------------- |
|
|
123
|
+
| status | false | 是否启用独占模式 |
|
|
124
|
+
|
|
125
|
+
用法:
|
|
126
|
+
|
|
127
|
+
```tsx | pure
|
|
128
|
+
lf.extension.selectionSelect.setExclusiveMode(true);
|
|
129
|
+
|
|
130
|
+
// 也可以使用运行时挂载在 lf 实例上的快捷方法。
|
|
131
|
+
// 注意:该方法当前公开类型里没有类型提示,TypeScript 项目中更推荐使用上面的插件实例方法。
|
|
132
|
+
lf.setSelectionSelectMode(true);
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## 默认状态
|
|
136
|
+
|
|
137
|
+
默认是否开启框选功能,受到页面是否允许拖动画布影响。画布可以拖动与选区不能同时存在。
|
|
138
|
+
|
|
139
|
+
```tsx | pure
|
|
140
|
+
const lf = new LogicFlow({
|
|
141
|
+
container: document.querySelector("#app"),
|
|
142
|
+
stopMoveGraph: true,
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
如果`stopMoveGraph`为 true,也就是不允许拖动画布,那么默认则可以进行框选。
|
|
147
|
+
|
|
148
|
+
如果`stopMoveGraph`不为 true, 也就是允许拖动画布,那么默认则不可以进行框选。
|
|
149
|
+
|
|
150
|
+
大多数情况下,我们期望允许拖动画布,当用户点击拖拽面板后才开启选区。请参考[拖拽面板插件](dnd-panel.zh.md)
|