@logicflow/extension 2.2.0-alpha.7 → 2.2.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 +16 -0
- package/package.json +10 -7
- package/.turbo/turbo-build.log +0 -38
- package/CHANGELOG.md +0 -1829
- package/__test__/bpmn-adapter.test.js +0 -227
- package/es/materials/curved-edge/__test__/curved-edge.test.d.ts +0 -1
- package/es/materials/curved-edge/__test__/curved-edge.test.js +0 -18
- package/jest.config.js +0 -198
- package/lib/materials/curved-edge/__test__/curved-edge.test.d.ts +0 -1
- package/lib/materials/curved-edge/__test__/curved-edge.test.js +0 -20
- package/rollup.config.js +0 -52
- package/src/NodeResize/BasicShape/Ellipse.tsx +0 -22
- package/src/NodeResize/BasicShape/Polygon.tsx +0 -24
- package/src/NodeResize/BasicShape/Rect.tsx +0 -44
- package/src/NodeResize/control/Control.tsx +0 -537
- package/src/NodeResize/control/ControlGroup.tsx +0 -76
- package/src/NodeResize/control/Util.ts +0 -206
- package/src/NodeResize/index.ts +0 -26
- package/src/NodeResize/node/DiamondResize.tsx +0 -149
- package/src/NodeResize/node/EllipseResize.tsx +0 -140
- package/src/NodeResize/node/HtmlResize.tsx +0 -125
- package/src/NodeResize/node/RectResize.tsx +0 -126
- package/src/NodeResize/node/index.ts +0 -4
- package/src/bpmn/constant.ts +0 -56
- package/src/bpmn/events/EndEvent.ts +0 -73
- package/src/bpmn/events/StartEvent.ts +0 -52
- package/src/bpmn/events/index.ts +0 -2
- package/src/bpmn/flow/SequenceFlow.ts +0 -25
- package/src/bpmn/flow/index.ts +0 -1
- package/src/bpmn/gateways/ExclusiveGateway.ts +0 -71
- package/src/bpmn/gateways/index.ts +0 -1
- package/src/bpmn/getBpmnId.ts +0 -31
- package/src/bpmn/index.ts +0 -60
- package/src/bpmn/tasks/ServiceTask.ts +0 -63
- package/src/bpmn/tasks/UserTask.ts +0 -64
- package/src/bpmn/tasks/index.ts +0 -2
- package/src/bpmn-adapter/bpmnIds.ts +0 -31
- package/src/bpmn-adapter/index.ts +0 -835
- package/src/bpmn-adapter/json2xml.ts +0 -127
- package/src/bpmn-adapter/xml2json.ts +0 -544
- package/src/bpmn-elements/README.md +0 -223
- package/src/bpmn-elements/__tests__/definition.test.js +0 -72
- package/src/bpmn-elements/index.d.ts +0 -26
- package/src/bpmn-elements/index.ts +0 -107
- package/src/bpmn-elements/presets/Event/EndEventFactory.ts +0 -114
- package/src/bpmn-elements/presets/Event/IntermediateCatchEvent.ts +0 -108
- package/src/bpmn-elements/presets/Event/IntermediateThrowEvent.ts +0 -109
- package/src/bpmn-elements/presets/Event/StartEventFactory.ts +0 -114
- package/src/bpmn-elements/presets/Event/boundaryEventFactory.ts +0 -117
- package/src/bpmn-elements/presets/Event/index.ts +0 -14
- package/src/bpmn-elements/presets/Flow/flow.d.ts +0 -6
- package/src/bpmn-elements/presets/Flow/index.ts +0 -8
- package/src/bpmn-elements/presets/Flow/manhattan.ts +0 -691
- package/src/bpmn-elements/presets/Flow/sequenceFlow.ts +0 -65
- package/src/bpmn-elements/presets/Gateway/gateway.ts +0 -107
- package/src/bpmn-elements/presets/Gateway/index.ts +0 -23
- package/src/bpmn-elements/presets/Pool/Lane.ts +0 -211
- package/src/bpmn-elements/presets/Pool/Pool.ts +0 -284
- package/src/bpmn-elements/presets/Pool/index.ts +0 -89
- package/src/bpmn-elements/presets/Task/index.ts +0 -122
- package/src/bpmn-elements/presets/Task/subProcess.ts +0 -189
- package/src/bpmn-elements/presets/Task/task.ts +0 -193
- package/src/bpmn-elements/presets/icons.ts +0 -155
- package/src/bpmn-elements/utils.ts +0 -52
- package/src/bpmn-elements-adapter/README.md +0 -293
- package/src/bpmn-elements-adapter/__tests__/adapter_in.test.js +0 -528
- package/src/bpmn-elements-adapter/__tests__/adapter_out.test.js +0 -569
- package/src/bpmn-elements-adapter/constant.ts +0 -76
- package/src/bpmn-elements-adapter/index.ts +0 -1134
- package/src/bpmn-elements-adapter/json2xml.ts +0 -105
- package/src/bpmn-elements-adapter/xml2json.ts +0 -542
- package/src/components/context-menu/index.ts +0 -253
- package/src/components/control/index.ts +0 -155
- package/src/components/dnd-panel/index.ts +0 -137
- package/src/components/highlight/index.ts +0 -227
- package/src/components/menu/index.ts +0 -748
- package/src/components/mini-map/index.ts +0 -686
- package/src/components/selection-select/index.ts +0 -387
- package/src/dynamic-group/index.ts +0 -774
- package/src/dynamic-group/model.ts +0 -580
- package/src/dynamic-group/node.ts +0 -288
- package/src/dynamic-group/utils.ts +0 -46
- package/src/index.less +0 -1
- package/src/index.ts +0 -47
- package/src/insert-node-in-polyline/edge.ts +0 -175
- package/src/insert-node-in-polyline/index.ts +0 -193
- package/src/materials/curved-edge/__test__/curved-edge.test.ts +0 -46
- package/src/materials/curved-edge/index.ts +0 -217
- package/src/materials/group/GroupNode.ts +0 -437
- package/src/materials/group/index.ts +0 -542
- package/src/materials/node-selection/index.ts +0 -380
- package/src/mindmap/fakerRoot.ts +0 -19
- package/src/mindmap/index.ts +0 -328
- package/src/mindmap/markContent.ts +0 -81
- package/src/mindmap/markContentOption.ts +0 -81
- package/src/mindmap/markEntity.ts +0 -82
- package/src/mindmap/markRoot.ts +0 -83
- package/src/mindmap/theme.ts +0 -11
- package/src/pool/LaneModel.ts +0 -226
- package/src/pool/LaneView.ts +0 -220
- package/src/pool/PoolModel.ts +0 -631
- package/src/pool/PoolView.ts +0 -75
- package/src/pool/constant.ts +0 -19
- package/src/pool/index.ts +0 -621
- package/src/pool/utils.ts +0 -46
- package/src/rect-label-node/RectLabelNodeView.ts +0 -33
- package/src/rect-label-node/index.ts +0 -15
- package/src/style/index.less +0 -381
- package/src/style/raw.ts +0 -328
- package/src/tools/auto-layout/index.ts +0 -282
- package/src/tools/flow-path/index.ts +0 -233
- package/src/tools/label/Label.tsx +0 -357
- package/src/tools/label/LabelModel.ts +0 -83
- package/src/tools/label/LabelOverlay.tsx +0 -162
- package/src/tools/label/algorithm.ts +0 -42
- package/src/tools/label/index.ts +0 -479
- package/src/tools/label/mediumEditor.ts +0 -121
- package/src/tools/label/utils.ts +0 -395
- package/src/tools/proximity-connect/index.ts +0 -435
- package/src/tools/snapshot/README.md +0 -145
- package/src/tools/snapshot/index.ts +0 -701
- package/src/tools/snapshot/utils.ts +0 -163
- package/src/turbo-adapter/index.ts +0 -212
- package/stats.html +0 -4842
- package/tsconfig.json +0 -18
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
import LogicFlow from '@logicflow/core'
|
|
2
|
-
import { cloneDeep } from 'lodash-es'
|
|
3
|
-
|
|
4
|
-
import Position = LogicFlow.Position
|
|
5
|
-
import PointTuple = LogicFlow.PointTuple
|
|
6
|
-
|
|
7
|
-
export interface SelectionConfig {
|
|
8
|
-
exclusiveMode?: boolean
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class SelectionSelect {
|
|
12
|
-
static pluginName = 'selectionSelect'
|
|
13
|
-
private container?: HTMLElement
|
|
14
|
-
private wrapper?: HTMLElement
|
|
15
|
-
private lf: LogicFlow
|
|
16
|
-
private startPoint?: Position
|
|
17
|
-
private endPoint?: Position
|
|
18
|
-
private disabled = true
|
|
19
|
-
private isWholeNode = true
|
|
20
|
-
private isWholeEdge = true
|
|
21
|
-
private originStatusSaved = false
|
|
22
|
-
exclusiveMode = false // 框选独占模式:true 表示只能进行框选操作,false 表示可以同时进行其他画布操作
|
|
23
|
-
// 用于区分选区和点击事件
|
|
24
|
-
private mouseDownInfo: {
|
|
25
|
-
x: number
|
|
26
|
-
y: number
|
|
27
|
-
time: number
|
|
28
|
-
} | null = null
|
|
29
|
-
// 记录原始的 stopMoveGraph 设置
|
|
30
|
-
private originalStopMoveGraph:
|
|
31
|
-
| boolean
|
|
32
|
-
| 'horizontal'
|
|
33
|
-
| 'vertical'
|
|
34
|
-
| [number, number, number, number] = false
|
|
35
|
-
|
|
36
|
-
constructor({ lf, options }: LogicFlow.IExtensionProps) {
|
|
37
|
-
this.lf = lf
|
|
38
|
-
|
|
39
|
-
this.exclusiveMode = (options?.exclusiveMode as boolean) ?? false
|
|
40
|
-
|
|
41
|
-
// TODO: 有没有既能将方法挂载到lf上,又能提供类型提示的方法?
|
|
42
|
-
lf.openSelectionSelect = () => {
|
|
43
|
-
this.openSelectionSelect()
|
|
44
|
-
}
|
|
45
|
-
lf.closeSelectionSelect = () => {
|
|
46
|
-
this.closeSelectionSelect()
|
|
47
|
-
}
|
|
48
|
-
// 新增切换独占模式的方法
|
|
49
|
-
lf.setSelectionSelectMode = (exclusive: boolean) => {
|
|
50
|
-
this.setExclusiveMode(exclusive)
|
|
51
|
-
}
|
|
52
|
-
// 绑定方法的 this 上下文
|
|
53
|
-
this.handleMouseDown = this.handleMouseDown.bind(this)
|
|
54
|
-
this.draw = this.draw.bind(this)
|
|
55
|
-
this.drawOff = this.drawOff.bind(this)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
render(_: LogicFlow, domContainer: HTMLElement) {
|
|
59
|
-
this.container = domContainer
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* 清理选区状态
|
|
64
|
-
*/
|
|
65
|
-
private cleanupSelectionState() {
|
|
66
|
-
// 清理当前的选区状态
|
|
67
|
-
if (this.wrapper) {
|
|
68
|
-
this.wrapper.oncontextmenu = null
|
|
69
|
-
if (this.container && this.wrapper.parentNode === this.container) {
|
|
70
|
-
this.container.removeChild(this.wrapper)
|
|
71
|
-
}
|
|
72
|
-
this.wrapper = undefined
|
|
73
|
-
}
|
|
74
|
-
this.startPoint = undefined
|
|
75
|
-
this.endPoint = undefined
|
|
76
|
-
this.mouseDownInfo = null
|
|
77
|
-
|
|
78
|
-
// 移除事件监听
|
|
79
|
-
document.removeEventListener('pointermove', this.draw)
|
|
80
|
-
document.removeEventListener('pointerup', this.drawOff)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* 切换框选模式
|
|
85
|
-
* @param exclusive 是否为独占模式。true 表示只能进行框选操作,false 表示可以同时进行其他画布操作
|
|
86
|
-
*/
|
|
87
|
-
setExclusiveMode(exclusive: boolean = false) {
|
|
88
|
-
if (this.exclusiveMode === exclusive) return
|
|
89
|
-
|
|
90
|
-
this.cleanupSelectionState()
|
|
91
|
-
this.exclusiveMode = exclusive
|
|
92
|
-
if (this.container && !this.disabled) {
|
|
93
|
-
// 切换事件监听方式
|
|
94
|
-
this.removeEventListeners()
|
|
95
|
-
this.addEventListeners()
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
private addEventListeners() {
|
|
100
|
-
if (!this.container) return
|
|
101
|
-
if (this.exclusiveMode) {
|
|
102
|
-
// 独占模式:监听 container 的 mousedown 事件
|
|
103
|
-
this.container.style.pointerEvents = 'auto'
|
|
104
|
-
this.container.style.touchAction = 'none'
|
|
105
|
-
this.container.addEventListener('pointerdown', this.handleMouseDown)
|
|
106
|
-
} else {
|
|
107
|
-
// 非独占模式:监听画布的 blank:mousedown 事件
|
|
108
|
-
this.container.style.pointerEvents = 'none'
|
|
109
|
-
// 使用实例方法而不是箭头函数,这样可以正确移除事件监听
|
|
110
|
-
this.lf.on('blank:mousedown', this.handleBlankMouseDown)
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
private removeEventListeners() {
|
|
115
|
-
if (this.container) {
|
|
116
|
-
this.container.style.pointerEvents = 'none'
|
|
117
|
-
this.container.removeEventListener('pointerdown', this.handleMouseDown)
|
|
118
|
-
}
|
|
119
|
-
// 移除 blank:mousedown 事件监听
|
|
120
|
-
this.lf.off('blank:mousedown', this.handleBlankMouseDown)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* 处理画布空白处鼠标按下事件(非独占模式)
|
|
125
|
-
*/
|
|
126
|
-
private handleBlankMouseDown = ({ e }: { e: MouseEvent | PointerEvent }) => {
|
|
127
|
-
this.handleMouseDown(e as PointerEvent)
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* 处理鼠标按下事件
|
|
132
|
-
*/
|
|
133
|
-
private handleMouseDown(e: PointerEvent) {
|
|
134
|
-
if (!this.container || this.disabled) return
|
|
135
|
-
if (this.lf.graphModel.editConfigModel.isPinching) return
|
|
136
|
-
|
|
137
|
-
// 禁用右键框选
|
|
138
|
-
const isRightClick = e.button === 2
|
|
139
|
-
if (isRightClick) return
|
|
140
|
-
// 清理之前可能存在的选区状态
|
|
141
|
-
this.cleanupSelectionState()
|
|
142
|
-
// 记录鼠标按下时的位置和时间
|
|
143
|
-
this.mouseDownInfo = {
|
|
144
|
-
x: e.clientX,
|
|
145
|
-
y: e.clientY,
|
|
146
|
-
time: Date.now(),
|
|
147
|
-
}
|
|
148
|
-
// 记录原始设置并临时禁止画布移动
|
|
149
|
-
if (!this.originStatusSaved) {
|
|
150
|
-
// 为了防止在开启框选时用户多次点击画布导致缓存的stopMoveGraph变化,所以只在第一次点击时记录原始的stopMoveGraph issue #2263
|
|
151
|
-
this.originalStopMoveGraph = this.lf.getEditConfig().stopMoveGraph!
|
|
152
|
-
this.originStatusSaved = true
|
|
153
|
-
}
|
|
154
|
-
this.lf.updateEditConfig({
|
|
155
|
-
stopMoveGraph: true,
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
const {
|
|
159
|
-
domOverlayPosition: { x, y },
|
|
160
|
-
} = this.lf.getPointByClient(e.clientX, e.clientY)
|
|
161
|
-
|
|
162
|
-
this.startPoint = { x, y }
|
|
163
|
-
this.endPoint = { x, y }
|
|
164
|
-
|
|
165
|
-
const wrapper = document.createElement('div')
|
|
166
|
-
wrapper.className = 'lf-selection-select'
|
|
167
|
-
wrapper.oncontextmenu = function prevent(ev: MouseEvent) {
|
|
168
|
-
ev.preventDefault()
|
|
169
|
-
}
|
|
170
|
-
wrapper.style.top = `${this.startPoint.y}px`
|
|
171
|
-
wrapper.style.left = `${this.startPoint.x}px`
|
|
172
|
-
this.container?.appendChild(wrapper)
|
|
173
|
-
this.wrapper = wrapper
|
|
174
|
-
|
|
175
|
-
document.addEventListener('pointermove', this.draw)
|
|
176
|
-
document.addEventListener('pointerup', this.drawOff)
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* 设置选中的灵敏度
|
|
181
|
-
* @param isWholeEdge 是否要边的起点终点都在选区范围才算选中。默认true
|
|
182
|
-
* @param isWholeNode 是否要节点的全部点都在选区范围才算选中。默认true
|
|
183
|
-
*/
|
|
184
|
-
setSelectionSense(isWholeEdge = true, isWholeNode = true) {
|
|
185
|
-
this.isWholeEdge = isWholeEdge
|
|
186
|
-
this.isWholeNode = isWholeNode
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* 开启选区
|
|
191
|
-
*/
|
|
192
|
-
openSelectionSelect() {
|
|
193
|
-
if (!this.disabled) {
|
|
194
|
-
this.closeSelectionSelect()
|
|
195
|
-
}
|
|
196
|
-
if (!this.container) {
|
|
197
|
-
return
|
|
198
|
-
}
|
|
199
|
-
this.cleanupSelectionState()
|
|
200
|
-
this.addEventListeners()
|
|
201
|
-
this.open()
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* 关闭选区
|
|
206
|
-
*/
|
|
207
|
-
closeSelectionSelect() {
|
|
208
|
-
if (!this.container) {
|
|
209
|
-
return
|
|
210
|
-
}
|
|
211
|
-
// 如果还有未完成的框选,先触发 drawOff 完成框选
|
|
212
|
-
if (this.wrapper && this.startPoint && this.endPoint) {
|
|
213
|
-
// 记录上一次的结束点,用于触发 mouseup 事件
|
|
214
|
-
const lastEndPoint = cloneDeep(this.endPoint)
|
|
215
|
-
const lastEvent = new PointerEvent('pointerup', {
|
|
216
|
-
clientX: lastEndPoint.x,
|
|
217
|
-
clientY: lastEndPoint.y,
|
|
218
|
-
})
|
|
219
|
-
this.drawOff(lastEvent)
|
|
220
|
-
}
|
|
221
|
-
this.cleanupSelectionState()
|
|
222
|
-
this.removeEventListeners()
|
|
223
|
-
this.close()
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
private draw = (ev: PointerEvent) => {
|
|
227
|
-
if (this.lf.graphModel.editConfigModel.isPinching) {
|
|
228
|
-
this.lf.updateEditConfig({ stopMoveGraph: this.originalStopMoveGraph })
|
|
229
|
-
this.originStatusSaved = false
|
|
230
|
-
this.cleanupSelectionState()
|
|
231
|
-
return
|
|
232
|
-
}
|
|
233
|
-
const {
|
|
234
|
-
domOverlayPosition: { x: x1, y: y1 },
|
|
235
|
-
} = this.lf.getPointByClient(ev.clientX, ev.clientY)
|
|
236
|
-
this.endPoint = {
|
|
237
|
-
x: x1,
|
|
238
|
-
y: y1,
|
|
239
|
-
}
|
|
240
|
-
if (this.startPoint) {
|
|
241
|
-
const { x, y } = this.startPoint
|
|
242
|
-
let left = x
|
|
243
|
-
let top = y
|
|
244
|
-
let width = x1 - x
|
|
245
|
-
let height = y1 - y
|
|
246
|
-
if (x1 < x) {
|
|
247
|
-
left = x1
|
|
248
|
-
width = x - x1
|
|
249
|
-
}
|
|
250
|
-
if (y1 < y) {
|
|
251
|
-
top = y1
|
|
252
|
-
height = y - y1
|
|
253
|
-
}
|
|
254
|
-
if (this.wrapper) {
|
|
255
|
-
this.wrapper.style.left = `${left}px`
|
|
256
|
-
this.wrapper.style.top = `${top}px`
|
|
257
|
-
this.wrapper.style.width = `${width}px`
|
|
258
|
-
this.wrapper.style.height = `${height}px`
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
private drawOff = (e: PointerEvent) => {
|
|
263
|
-
// 恢复原始的 stopMoveGraph 设置
|
|
264
|
-
this.lf.updateEditConfig({
|
|
265
|
-
stopMoveGraph: this.originalStopMoveGraph,
|
|
266
|
-
})
|
|
267
|
-
this.originStatusSaved = false
|
|
268
|
-
// 处理鼠标抬起事件
|
|
269
|
-
// 首先判断是否是点击,如果是,则清空框选
|
|
270
|
-
if (this.mouseDownInfo) {
|
|
271
|
-
const { x, y, time } = this.mouseDownInfo
|
|
272
|
-
const isClick =
|
|
273
|
-
Math.abs(e.clientX - x) < 5 &&
|
|
274
|
-
Math.abs(e.clientY - y) < 5 &&
|
|
275
|
-
Date.now() - time < 200
|
|
276
|
-
if (isClick) {
|
|
277
|
-
this.lf.clearSelectElements()
|
|
278
|
-
this.cleanupSelectionState()
|
|
279
|
-
return
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
const curStartPoint = cloneDeep(this.startPoint)
|
|
284
|
-
const curEndPoint = cloneDeep(this.endPoint)
|
|
285
|
-
document.removeEventListener('pointermove', this.draw)
|
|
286
|
-
if (!this.exclusiveMode) {
|
|
287
|
-
document.removeEventListener('pointerup', this.drawOff)
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (curStartPoint && curEndPoint) {
|
|
291
|
-
const { x, y } = curStartPoint
|
|
292
|
-
const { x: x1, y: y1 } = curEndPoint
|
|
293
|
-
// 返回框选范围,左上角和右下角的坐标
|
|
294
|
-
const lt: PointTuple = [Math.min(x, x1), Math.min(y, y1)]
|
|
295
|
-
const rb: PointTuple = [Math.max(x, x1), Math.max(y, y1)]
|
|
296
|
-
this.lf.emit('selection:selected-area', {
|
|
297
|
-
topLeft: lt,
|
|
298
|
-
bottomRight: rb,
|
|
299
|
-
})
|
|
300
|
-
// 选区太小的情况就忽略
|
|
301
|
-
if (Math.abs(x1 - x) < 10 && Math.abs(y1 - y) < 10) {
|
|
302
|
-
if (this.wrapper) {
|
|
303
|
-
this.wrapper.oncontextmenu = null
|
|
304
|
-
if (this.container && this.wrapper.parentNode === this.container) {
|
|
305
|
-
this.container.removeChild(this.wrapper)
|
|
306
|
-
}
|
|
307
|
-
this.wrapper = undefined
|
|
308
|
-
}
|
|
309
|
-
return
|
|
310
|
-
}
|
|
311
|
-
const elements = this.lf.graphModel.getAreaElement(
|
|
312
|
-
lt,
|
|
313
|
-
rb,
|
|
314
|
-
this.isWholeEdge,
|
|
315
|
-
this.isWholeNode,
|
|
316
|
-
true,
|
|
317
|
-
)
|
|
318
|
-
const { dynamicGroup, group } = this.lf.graphModel
|
|
319
|
-
const nonGroupedElements: typeof elements = []
|
|
320
|
-
const selectedElements = this.lf.getSelectElements()
|
|
321
|
-
// 同时记录节点和边的ID
|
|
322
|
-
const selectedIds = new Set([
|
|
323
|
-
...selectedElements.nodes.map((node) => node.id),
|
|
324
|
-
...selectedElements.edges.map((edge) => edge.id),
|
|
325
|
-
])
|
|
326
|
-
|
|
327
|
-
elements.forEach((element) => {
|
|
328
|
-
// 如果节点属于分组,则不选中节点,此处兼容旧版 Group 插件
|
|
329
|
-
if (group) {
|
|
330
|
-
const elementGroup = group.getNodeGroup(element.id)
|
|
331
|
-
if (elements.includes(elementGroup)) {
|
|
332
|
-
// 当被选中的元素的父分组被选中时,不选中该元素
|
|
333
|
-
return
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
if (dynamicGroup) {
|
|
337
|
-
const elementGroup = dynamicGroup.getGroupByNodeId(element.id)
|
|
338
|
-
if (elements.includes(elementGroup)) {
|
|
339
|
-
// 当被选中的元素的父分组被选中时,不选中该元素
|
|
340
|
-
return
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
// 在独占模式下,如果元素已经被选中,则取消选中
|
|
344
|
-
if (this.exclusiveMode && selectedIds.has(element.id)) {
|
|
345
|
-
this.lf.deselectElementById(element.id)
|
|
346
|
-
return
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// 非独占模式下,或者元素未被选中时,选中元素
|
|
350
|
-
this.lf.selectElementById(element.id, true)
|
|
351
|
-
nonGroupedElements.push(element)
|
|
352
|
-
})
|
|
353
|
-
// 重置起始点和终点
|
|
354
|
-
// 注意:这两个值必须在触发closeSelectionSelect方法前充值,否则会导致独占模式下元素无法选中的问题
|
|
355
|
-
this.startPoint = undefined
|
|
356
|
-
this.endPoint = undefined
|
|
357
|
-
// 如果有选中的元素,触发 selection:drop 事件
|
|
358
|
-
if (nonGroupedElements.length > 0) {
|
|
359
|
-
this.lf.emit('selection:drop', { e })
|
|
360
|
-
}
|
|
361
|
-
// 触发 selection:selected 事件
|
|
362
|
-
this.lf.emit('selection:selected', {
|
|
363
|
-
elements: nonGroupedElements,
|
|
364
|
-
leftTopPoint: lt,
|
|
365
|
-
rightBottomPoint: rb,
|
|
366
|
-
})
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
if (this.wrapper) {
|
|
370
|
-
this.wrapper.oncontextmenu = null
|
|
371
|
-
if (this.container && this.wrapper.parentNode === this.container) {
|
|
372
|
-
this.container.removeChild(this.wrapper)
|
|
373
|
-
}
|
|
374
|
-
this.wrapper = undefined
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
private open() {
|
|
379
|
-
this.disabled = false
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
private close() {
|
|
383
|
-
this.disabled = true
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
export default SelectionSelect
|