w-flow-vue 1.0.19 → 1.0.21
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 +1 -1
- package/dist/w-flow-vue.umd.js +3 -3
- package/dist/w-flow-vue.umd.js.map +1 -1
- package/docs/components_WFlowVue.vue.html +1392 -1307
- package/docs/components_ui_Controls.vue.html +278 -0
- package/docs/examples/app.html +1 -1
- package/docs/examples/app.umd.js +5 -5
- package/docs/examples/app.umd.js.map +1 -1
- package/docs/examples/ex-AppBasic.html +1 -1
- package/docs/examples/ex-AppConnectivity.html +1 -1
- package/docs/global.html +87 -2
- package/docs/index.html +2 -2
- package/docs/js_defaults.mjs.html +2 -2
- package/docs/js_edgePath.mjs.html +2 -2
- package/docs/js_fixSvgNs.mjs.html +2 -2
- package/docs/js_geometry.mjs.html +2 -2
- package/docs/js_graph.mjs.html +2 -2
- package/docs/js_stepRouting.mjs.html +2 -2
- package/docs/module-WFlowVue.html +1236 -17
- package/package.json +6 -6
- package/src/components/WFlowVue.vue +1390 -1305
- package/src/components/ui/Controls.vue +206 -119
- package/test/unit-components-ui.test.mjs +248 -69
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
<nav >
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-WFlowVue.html">WFlowVue</a></li></ul><h3>Global</h3><ul><li><a href="global.html#NODE_DEFAULTS">NODE_DEFAULTS</a></li><li><a href="global.html#buildRoundedPath">buildRoundedPath</a></li><li><a href="global.html#clampPosition">clampPosition</a></li><li><a href="global.html#fixSvgNs">fixSvgNs</a></li><li><a href="global.html#generateId">generateId</a></li><li><a href="global.html#getBezierPath">getBezierPath</a></li><li><a href="global.html#getControlOffset">getControlOffset</a></li><li><a href="global.html#getDiamondEdgePoint">getDiamondEdgePoint</a></li><li><a href="global.html#getEllipseEdgePoint">getEllipseEdgePoint</a></li><li><a href="global.html#getHandlePosition">getHandlePosition</a></li><li><a href="global.html#getOverlappingNodes">getOverlappingNodes</a></li><li><a href="global.html#getSmoothStepPath">getSmoothStepPath</a></li><li><a href="global.html#getStepPath">getStepPath</a></li><li><a href="global.html#getStraightPath">getStraightPath</a></li><li><a href="global.html#getTriangleEdgePoint">getTriangleEdgePoint</a></li><li><a href="global.html#isValidConnection">isValidConnection</a></li><li><a href="global.html#labelAtHalfLength">labelAtHalfLength</a></li><li><a href="global.html#lookupRoute">lookupRoute</a></li><li><a href="global.html#normalizeConnPoints">normalizeConnPoints</a></li><li><a href="global.html#orthogonalizeThroughPoints">orthogonalizeThroughPoints</a></li><li><a href="global.html#rectsOverlap">rectsOverlap</a></li><li><a href="global.html#segmentFallback">segmentFallback</a></li><li><a href="global.html#snapPosition">snapPosition</a></li></ul>
|
|
32
|
+
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-WFlowVue.html">WFlowVue</a></li></ul><h3>Global</h3><ul><li><a href="global.html#NODE_DEFAULTS">NODE_DEFAULTS</a></li><li><a href="global.html#buildRoundedPath">buildRoundedPath</a></li><li><a href="global.html#clampPosition">clampPosition</a></li><li><a href="global.html#fixSvgNs">fixSvgNs</a></li><li><a href="global.html#generateId">generateId</a></li><li><a href="global.html#getBezierPath">getBezierPath</a></li><li><a href="global.html#getControlOffset">getControlOffset</a></li><li><a href="global.html#getDiamondEdgePoint">getDiamondEdgePoint</a></li><li><a href="global.html#getEllipseEdgePoint">getEllipseEdgePoint</a></li><li><a href="global.html#getHandlePosition">getHandlePosition</a></li><li><a href="global.html#getOverlappingNodes">getOverlappingNodes</a></li><li><a href="global.html#getSmoothStepPath">getSmoothStepPath</a></li><li><a href="global.html#getStepPath">getStepPath</a></li><li><a href="global.html#getStraightPath">getStraightPath</a></li><li><a href="global.html#getTriangleEdgePoint">getTriangleEdgePoint</a></li><li><a href="global.html#isValidConnection">isValidConnection</a></li><li><a href="global.html#labelAtHalfLength">labelAtHalfLength</a></li><li><a href="global.html#lookupRoute">lookupRoute</a></li><li><a href="global.html#normalizeConnPoints">normalizeConnPoints</a></li><li><a href="global.html#orthogonalizeThroughPoints">orthogonalizeThroughPoints</a></li><li><a href="global.html#pickMenuValue">pickMenuValue</a></li><li><a href="global.html#rectsOverlap">rectsOverlap</a></li><li><a href="global.html#segmentFallback">segmentFallback</a></li><li><a href="global.html#snapPosition">snapPosition</a></li></ul>
|
|
33
33
|
|
|
34
34
|
</nav>
|
|
35
35
|
|
|
@@ -45,1311 +45,1396 @@
|
|
|
45
45
|
|
|
46
46
|
<section>
|
|
47
47
|
<article>
|
|
48
|
-
<pre class="prettyprint source linenums"><code><template>
|
|
49
|
-
<div :style="`width:${widthInp}px; height:${heightInp}px;`">
|
|
50
|
-
<FlowCanvas
|
|
51
|
-
v-if="inited"
|
|
52
|
-
ref="canvas"
|
|
53
|
-
@canvas-mousedown="onCanvasMouseDown"
|
|
54
|
-
@canvas-mousemove="onCanvasMouseMove"
|
|
55
|
-
@canvas-mouseup="onCanvasMouseUp"
|
|
56
|
-
@canvas-wheel="onCanvasWheel"
|
|
57
|
-
@canvas-dblclick="onCanvasDblClick"
|
|
58
|
-
@canvas-click="onCanvasClick"
|
|
59
|
-
@canvas-contextmenu="onCanvasContextMenu"
|
|
60
|
-
>
|
|
61
|
-
<BackgroundLayer
|
|
62
|
-
:variant="platformBackgroundPatternType"
|
|
63
|
-
:gap="platformBackgroundPatternGap"
|
|
64
|
-
:size="platformBackgroundPatternSize"
|
|
65
|
-
:pattern-color="platformBackgroundPatternColor"
|
|
66
|
-
:bg-color="platformBackgroundColor"
|
|
67
|
-
:viewport="viewport"
|
|
68
|
-
/>
|
|
69
|
-
|
|
70
|
-
<ViewportTransform
|
|
71
|
-
:viewport="viewport"
|
|
72
|
-
>
|
|
73
|
-
<EdgeRenderer
|
|
74
|
-
ref="edgeRenderer"
|
|
75
|
-
:conns="conns"
|
|
76
|
-
:nodes="nodes"
|
|
77
|
-
:node-internals="nodeInternals"
|
|
78
|
-
:selected-conn-ids="selectedConns"
|
|
79
|
-
:interactive="elementsSelectable"
|
|
80
|
-
:locked="locked"
|
|
81
|
-
:settings-popup-background-color="settingsPopupBackgroundColor"
|
|
82
|
-
:settings-popup-text-color="settingsPopupTextColor"
|
|
83
|
-
:settings-popup-text-font-size="settingsPopupTextFontSize"
|
|
84
|
-
:infor-popup-background-color="inforPopupBackgroundColor"
|
|
85
|
-
:infor-popup-title-text-color="inforPopupTitleTextColor"
|
|
86
|
-
:infor-popup-title-text-font-size="inforPopupTitleTextFontSize"
|
|
87
|
-
:infor-popup-description-text-color="inforPopupDescriptionTextColor"
|
|
88
|
-
:infor-popup-description-text-font-size="inforPopupDescriptionTextFontSize"
|
|
89
|
-
:settings-enabled="connsSettingsEnabled"
|
|
90
|
-
:settings-excludes="connsSettingsExcludes"
|
|
91
|
-
@conn-click="onConnClick"
|
|
92
|
-
@conn-double-click="onConnDoubleClick"
|
|
93
|
-
@conn-context-menu="onConnContextMenu"
|
|
94
|
-
@conn-mouseenter="onConnMouseEnter"
|
|
95
|
-
@conn-mouseleave="onConnMouseLeave"
|
|
96
|
-
@conn-settings-click="onConnSettingsClick"
|
|
97
|
-
@conn-settings-update="onConnSettingsUpdate"
|
|
98
|
-
@conn-settings-delete="onConnSettingsDelete"
|
|
99
|
-
>
|
|
100
|
-
<template v-if="$scopedSlots['conn-popup']" v-slot:conn-popup="scope">
|
|
101
|
-
<slot name="conn-popup" v-bind="scope" />
|
|
102
|
-
</template>
|
|
103
|
-
</EdgeRenderer>
|
|
104
|
-
|
|
105
|
-
<NodeRenderer
|
|
106
|
-
ref="nodeRenderer"
|
|
107
|
-
:nodes="nodes"
|
|
108
|
-
:selected-node-ids="selectedNodes"
|
|
109
|
-
:nodes-draggable="nodesDraggable"
|
|
110
|
-
:nodes-connectable="nodesConnectable"
|
|
111
|
-
:locked="locked"
|
|
112
|
-
:nodes-resizable="nodesResizable"
|
|
113
|
-
:settings-popup-background-color="settingsPopupBackgroundColor"
|
|
114
|
-
:settings-popup-text-color="settingsPopupTextColor"
|
|
115
|
-
:settings-popup-text-font-size="settingsPopupTextFontSize"
|
|
116
|
-
:infor-popup-background-color="inforPopupBackgroundColor"
|
|
117
|
-
:infor-popup-title-text-color="inforPopupTitleTextColor"
|
|
118
|
-
:infor-popup-title-text-font-size="inforPopupTitleTextFontSize"
|
|
119
|
-
:infor-popup-description-text-color="inforPopupDescriptionTextColor"
|
|
120
|
-
:infor-popup-description-text-font-size="inforPopupDescriptionTextFontSize"
|
|
121
|
-
:snap-grid-size="snapToGrid ? snapGridSize : null"
|
|
122
|
-
:settings-enabled="nodesSettingsEnabled"
|
|
123
|
-
:settings-excludes="nodesSettingsExcludes"
|
|
124
|
-
@drag-start="onNodeDragStart"
|
|
125
|
-
@node-click="onNodeClick"
|
|
126
|
-
@node-double-click="onNodeDoubleClick"
|
|
127
|
-
@node-context-menu="onNodeContextMenu"
|
|
128
|
-
@node-settings-click="onNodeSettingsClick"
|
|
129
|
-
@node-settings-update="onNodeSettingsUpdate"
|
|
130
|
-
@node-settings-delete="onNodeSettingsDelete"
|
|
131
|
-
@node-mouseenter="onNodeMouseEnter"
|
|
132
|
-
@node-mouseleave="onNodeMouseLeave"
|
|
133
|
-
@connect-start="onConnectStart"
|
|
134
|
-
@dimensions="onNodeDimensions"
|
|
135
|
-
@node-resize="onNodeResize"
|
|
136
|
-
@node-resize-end="onNodeResizeEnd"
|
|
137
|
-
>
|
|
138
|
-
<template v-if="$scopedSlots['node-popup']" v-slot:node-popup="scope">
|
|
139
|
-
<slot name="node-popup" v-bind="scope" />
|
|
140
|
-
</template>
|
|
141
|
-
</NodeRenderer>
|
|
142
|
-
|
|
143
|
-
<ConnectionLine
|
|
144
|
-
:active="isConnecting"
|
|
145
|
-
:source-x="connLineFromX"
|
|
146
|
-
:source-y="connLineFromY"
|
|
147
|
-
:source-position="connLineFromPosition"
|
|
148
|
-
:target-x="connLineToX"
|
|
149
|
-
:target-y="connLineToY"
|
|
150
|
-
:type="defConnCreatingType"
|
|
151
|
-
:line-style="defConnCreatingStyle"
|
|
152
|
-
/>
|
|
153
|
-
|
|
154
|
-
<slot name="viewport-overlay" />
|
|
155
|
-
</ViewportTransform>
|
|
156
|
-
|
|
157
|
-
<SelectionBox :box="selectionBox" />
|
|
158
|
-
|
|
159
|
-
<Controls
|
|
160
|
-
:locked="locked"
|
|
161
|
-
:menu
|
|
162
|
-
|
|
163
|
-
@zoom-
|
|
164
|
-
@
|
|
165
|
-
@
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
</
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
import
|
|
175
|
-
import
|
|
176
|
-
import
|
|
177
|
-
import
|
|
178
|
-
import
|
|
179
|
-
import
|
|
180
|
-
import
|
|
181
|
-
import
|
|
182
|
-
import {
|
|
183
|
-
import {
|
|
184
|
-
import {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* @prop {number} [opt.
|
|
196
|
-
* @prop {
|
|
197
|
-
* @prop {Array} [opt.
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
* @prop {boolean} [opt.
|
|
202
|
-
* @prop {boolean} [opt.
|
|
203
|
-
* @prop {boolean} [opt.
|
|
204
|
-
* @prop {boolean} [opt.
|
|
205
|
-
* @prop {boolean} [opt.
|
|
206
|
-
* @prop {boolean} [opt.
|
|
207
|
-
* @prop {
|
|
208
|
-
* @prop {Array} [opt.
|
|
209
|
-
* @prop {
|
|
210
|
-
* @prop {boolean} [opt.
|
|
211
|
-
* @prop {
|
|
212
|
-
* @prop {
|
|
213
|
-
* @prop {
|
|
214
|
-
* @prop {string} [opt.
|
|
215
|
-
* @prop {
|
|
216
|
-
* @prop {
|
|
217
|
-
* @prop {number} [opt.zoomMin=0.5] Minimum zoom level (fitView may go below it; wheel zoom then keeps the current level as its lower bound instead of jumping back)
|
|
218
|
-
* @prop {number} [opt.zoomMax=2] Maximum zoom level
|
|
219
|
-
* @prop {
|
|
220
|
-
* @prop {
|
|
221
|
-
* @prop {
|
|
222
|
-
* @prop {
|
|
223
|
-
* @prop {
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
* @prop {
|
|
228
|
-
* @prop {number} [opt.
|
|
229
|
-
* @prop {
|
|
230
|
-
* @prop {string} [opt.
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
* @prop {
|
|
236
|
-
* @prop {string} [opt.
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
* @prop {string} [opt.
|
|
240
|
-
* @prop {string} [opt.
|
|
241
|
-
* @prop {
|
|
242
|
-
* @prop {string} [opt.
|
|
243
|
-
* @prop {string} [opt.
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
* @prop {string} [opt.
|
|
247
|
-
* @prop {
|
|
248
|
-
* @prop {
|
|
249
|
-
* @prop {
|
|
250
|
-
* @prop {
|
|
251
|
-
* @prop {
|
|
252
|
-
* @prop {
|
|
253
|
-
* @prop {string} [opt.
|
|
254
|
-
* @prop {string} [opt.
|
|
255
|
-
* @prop {string} [opt.
|
|
256
|
-
* @prop {
|
|
257
|
-
* @prop {string} [opt.
|
|
258
|
-
* @prop {
|
|
259
|
-
* @prop {string} [opt.
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
* @prop {string} [opt.
|
|
263
|
-
* @prop {
|
|
264
|
-
* @prop {
|
|
265
|
-
* @prop {string} [opt.
|
|
266
|
-
* @prop {
|
|
267
|
-
*
|
|
268
|
-
* ───
|
|
269
|
-
* @prop {string} [opt.
|
|
270
|
-
* @prop {
|
|
271
|
-
* @prop {
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
* @prop {string} [opt.
|
|
275
|
-
* @prop {
|
|
276
|
-
* @prop {string} [opt.
|
|
277
|
-
* @prop {string} [opt.
|
|
278
|
-
* @prop {
|
|
279
|
-
*
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
return this.opt.
|
|
441
|
-
},
|
|
442
|
-
|
|
443
|
-
return this.opt.
|
|
444
|
-
},
|
|
445
|
-
|
|
446
|
-
return this.opt.
|
|
447
|
-
},
|
|
448
|
-
|
|
449
|
-
return this.opt.
|
|
450
|
-
},
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
return
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
},
|
|
509
|
-
|
|
510
|
-
return this.opt.
|
|
511
|
-
},
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
return this.opt.
|
|
532
|
-
},
|
|
533
|
-
|
|
534
|
-
return this.opt.
|
|
535
|
-
},
|
|
536
|
-
|
|
537
|
-
return this.opt.
|
|
538
|
-
},
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
return
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
},
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
},
|
|
621
|
-
|
|
622
|
-
this.
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
let
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
},
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
if (
|
|
719
|
-
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
if (
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
this.
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
const
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
this
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
}
|
|
865
|
-
},
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
this.
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
this.
|
|
898
|
-
|
|
899
|
-
this.
|
|
900
|
-
this.
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
this.
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
const
|
|
931
|
-
const
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
const
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
this
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
if (
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
this
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
this
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
},
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
if (!
|
|
1009
|
-
|
|
1010
|
-
this
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
this
|
|
1054
|
-
|
|
1055
|
-
this
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
this
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
this
|
|
1076
|
-
this
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
this
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
this.$emit('
|
|
1084
|
-
},
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
})
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
this.$emit('
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
this.
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
const
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
})
|
|
1264
|
-
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
this.
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
let
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
let
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
48
|
+
<pre class="prettyprint source linenums"><code><template>
|
|
49
|
+
<div :style="`width:${widthInp}px; height:${heightInp}px;`">
|
|
50
|
+
<FlowCanvas
|
|
51
|
+
v-if="inited"
|
|
52
|
+
ref="canvas"
|
|
53
|
+
@canvas-mousedown="onCanvasMouseDown"
|
|
54
|
+
@canvas-mousemove="onCanvasMouseMove"
|
|
55
|
+
@canvas-mouseup="onCanvasMouseUp"
|
|
56
|
+
@canvas-wheel="onCanvasWheel"
|
|
57
|
+
@canvas-dblclick="onCanvasDblClick"
|
|
58
|
+
@canvas-click="onCanvasClick"
|
|
59
|
+
@canvas-contextmenu="onCanvasContextMenu"
|
|
60
|
+
>
|
|
61
|
+
<BackgroundLayer
|
|
62
|
+
:variant="platformBackgroundPatternType"
|
|
63
|
+
:gap="platformBackgroundPatternGap"
|
|
64
|
+
:size="platformBackgroundPatternSize"
|
|
65
|
+
:pattern-color="platformBackgroundPatternColor"
|
|
66
|
+
:bg-color="platformBackgroundColor"
|
|
67
|
+
:viewport="viewport"
|
|
68
|
+
/>
|
|
69
|
+
|
|
70
|
+
<ViewportTransform
|
|
71
|
+
:viewport="viewport"
|
|
72
|
+
>
|
|
73
|
+
<EdgeRenderer
|
|
74
|
+
ref="edgeRenderer"
|
|
75
|
+
:conns="conns"
|
|
76
|
+
:nodes="nodes"
|
|
77
|
+
:node-internals="nodeInternals"
|
|
78
|
+
:selected-conn-ids="selectedConns"
|
|
79
|
+
:interactive="elementsSelectable"
|
|
80
|
+
:locked="locked"
|
|
81
|
+
:settings-popup-background-color="settingsPopupBackgroundColor"
|
|
82
|
+
:settings-popup-text-color="settingsPopupTextColor"
|
|
83
|
+
:settings-popup-text-font-size="settingsPopupTextFontSize"
|
|
84
|
+
:infor-popup-background-color="inforPopupBackgroundColor"
|
|
85
|
+
:infor-popup-title-text-color="inforPopupTitleTextColor"
|
|
86
|
+
:infor-popup-title-text-font-size="inforPopupTitleTextFontSize"
|
|
87
|
+
:infor-popup-description-text-color="inforPopupDescriptionTextColor"
|
|
88
|
+
:infor-popup-description-text-font-size="inforPopupDescriptionTextFontSize"
|
|
89
|
+
:settings-enabled="connsSettingsEnabled"
|
|
90
|
+
:settings-excludes="connsSettingsExcludes"
|
|
91
|
+
@conn-click="onConnClick"
|
|
92
|
+
@conn-double-click="onConnDoubleClick"
|
|
93
|
+
@conn-context-menu="onConnContextMenu"
|
|
94
|
+
@conn-mouseenter="onConnMouseEnter"
|
|
95
|
+
@conn-mouseleave="onConnMouseLeave"
|
|
96
|
+
@conn-settings-click="onConnSettingsClick"
|
|
97
|
+
@conn-settings-update="onConnSettingsUpdate"
|
|
98
|
+
@conn-settings-delete="onConnSettingsDelete"
|
|
99
|
+
>
|
|
100
|
+
<template v-if="$scopedSlots['conn-popup']" v-slot:conn-popup="scope">
|
|
101
|
+
<slot name="conn-popup" v-bind="scope" />
|
|
102
|
+
</template>
|
|
103
|
+
</EdgeRenderer>
|
|
104
|
+
|
|
105
|
+
<NodeRenderer
|
|
106
|
+
ref="nodeRenderer"
|
|
107
|
+
:nodes="nodes"
|
|
108
|
+
:selected-node-ids="selectedNodes"
|
|
109
|
+
:nodes-draggable="nodesDraggable"
|
|
110
|
+
:nodes-connectable="nodesConnectable"
|
|
111
|
+
:locked="locked"
|
|
112
|
+
:nodes-resizable="nodesResizable"
|
|
113
|
+
:settings-popup-background-color="settingsPopupBackgroundColor"
|
|
114
|
+
:settings-popup-text-color="settingsPopupTextColor"
|
|
115
|
+
:settings-popup-text-font-size="settingsPopupTextFontSize"
|
|
116
|
+
:infor-popup-background-color="inforPopupBackgroundColor"
|
|
117
|
+
:infor-popup-title-text-color="inforPopupTitleTextColor"
|
|
118
|
+
:infor-popup-title-text-font-size="inforPopupTitleTextFontSize"
|
|
119
|
+
:infor-popup-description-text-color="inforPopupDescriptionTextColor"
|
|
120
|
+
:infor-popup-description-text-font-size="inforPopupDescriptionTextFontSize"
|
|
121
|
+
:snap-grid-size="snapToGrid ? snapGridSize : null"
|
|
122
|
+
:settings-enabled="nodesSettingsEnabled"
|
|
123
|
+
:settings-excludes="nodesSettingsExcludes"
|
|
124
|
+
@drag-start="onNodeDragStart"
|
|
125
|
+
@node-click="onNodeClick"
|
|
126
|
+
@node-double-click="onNodeDoubleClick"
|
|
127
|
+
@node-context-menu="onNodeContextMenu"
|
|
128
|
+
@node-settings-click="onNodeSettingsClick"
|
|
129
|
+
@node-settings-update="onNodeSettingsUpdate"
|
|
130
|
+
@node-settings-delete="onNodeSettingsDelete"
|
|
131
|
+
@node-mouseenter="onNodeMouseEnter"
|
|
132
|
+
@node-mouseleave="onNodeMouseLeave"
|
|
133
|
+
@connect-start="onConnectStart"
|
|
134
|
+
@dimensions="onNodeDimensions"
|
|
135
|
+
@node-resize="onNodeResize"
|
|
136
|
+
@node-resize-end="onNodeResizeEnd"
|
|
137
|
+
>
|
|
138
|
+
<template v-if="$scopedSlots['node-popup']" v-slot:node-popup="scope">
|
|
139
|
+
<slot name="node-popup" v-bind="scope" />
|
|
140
|
+
</template>
|
|
141
|
+
</NodeRenderer>
|
|
142
|
+
|
|
143
|
+
<ConnectionLine
|
|
144
|
+
:active="isConnecting"
|
|
145
|
+
:source-x="connLineFromX"
|
|
146
|
+
:source-y="connLineFromY"
|
|
147
|
+
:source-position="connLineFromPosition"
|
|
148
|
+
:target-x="connLineToX"
|
|
149
|
+
:target-y="connLineToY"
|
|
150
|
+
:type="defConnCreatingType"
|
|
151
|
+
:line-style="defConnCreatingStyle"
|
|
152
|
+
/>
|
|
153
|
+
|
|
154
|
+
<slot name="viewport-overlay" />
|
|
155
|
+
</ViewportTransform>
|
|
156
|
+
|
|
157
|
+
<SelectionBox :box="selectionBox" />
|
|
158
|
+
|
|
159
|
+
<Controls
|
|
160
|
+
:locked="locked"
|
|
161
|
+
:menu="menuInp"
|
|
162
|
+
@zoom-in="zoomIn"
|
|
163
|
+
@zoom-out="zoomOut"
|
|
164
|
+
@fit-view="fitView"
|
|
165
|
+
@toggle-interactive="toggleInteractive"
|
|
166
|
+
/>
|
|
167
|
+
|
|
168
|
+
</FlowCanvas>
|
|
169
|
+
</div>
|
|
170
|
+
</template>
|
|
171
|
+
|
|
172
|
+
<script>
|
|
173
|
+
import FlowCanvas from './canvas/FlowCanvas.vue'
|
|
174
|
+
import ViewportTransform from './canvas/ViewportTransform.vue'
|
|
175
|
+
import BackgroundLayer from './canvas/BackgroundLayer.vue'
|
|
176
|
+
import SelectionBox from './canvas/SelectionBox.vue'
|
|
177
|
+
import NodeRenderer from './nodes/NodeRenderer.vue'
|
|
178
|
+
import EdgeRenderer from './edges/EdgeRenderer.vue'
|
|
179
|
+
import ConnectionLine from './edges/ConnectionLine.vue'
|
|
180
|
+
import Controls from './ui/Controls.vue'
|
|
181
|
+
import { getHandlePosition, getOverlappingNodes, snapPosition, clampPosition } from '../js/geometry'
|
|
182
|
+
import { clearStepCache } from '../js/edgePath'
|
|
183
|
+
import { isValidConnection, generateId } from '../js/graph'
|
|
184
|
+
import { NODE_DEFAULTS, CONN_DEFAULTS } from '../js/defaults'
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* WFlowVue — Vue 2 flow/graph editor component.
|
|
188
|
+
*
|
|
189
|
+
* All configuration is passed via the `opt` prop object.
|
|
190
|
+
*
|
|
191
|
+
* @prop {Object} opt
|
|
192
|
+
*
|
|
193
|
+
* ─── Canvas ────────────────────────────────────────────────────────────
|
|
194
|
+
* @prop {number} [opt.width=800] Canvas width (px)
|
|
195
|
+
* @prop {number} [opt.height=600] Canvas height (px)
|
|
196
|
+
* @prop {Array} [opt.nodes=[]] Node data array
|
|
197
|
+
* @prop {Array} [opt.conns=[]] Connection data array
|
|
198
|
+
*
|
|
199
|
+
* ─── Interaction ───────────────────────────────────────────────────────
|
|
200
|
+
* @prop {boolean} [opt.nodesDraggable=true] Allow node dragging
|
|
201
|
+
* @prop {boolean} [opt.nodesConnectable=true] Allow creating connections
|
|
202
|
+
* @prop {boolean} [opt.nodesResizable=true] Allow resizing nodes (per-node override: node.resizable)
|
|
203
|
+
* @prop {boolean} [opt.elementsSelectable=true] Allow selecting nodes/conns
|
|
204
|
+
* @prop {boolean} [opt.locked=false] Initial interactive-lock state (afterwards toggled via Controls lock button, emits toggle-interactive)
|
|
205
|
+
* @prop {boolean} [opt.nodesSettingsEnabled=true] Show built-in node settings popup (gear icon)
|
|
206
|
+
* @prop {boolean} [opt.connsSettingsEnabled=true] Show built-in connection settings popup (gear icon)
|
|
207
|
+
* @prop {Array} [opt.nodesSettingsExcludes=[]] Field keys hidden in node settings form (e.g. ['name','description'])
|
|
208
|
+
* @prop {Array} [opt.connsSettingsExcludes=[]] Field keys hidden in connection settings form
|
|
209
|
+
* @prop {boolean} [opt.selectNodesOnDrag=true] Select node when drag starts
|
|
210
|
+
* @prop {boolean} [opt.deleteKeyEnabled=false] Enable keyboard deletion of selected elements
|
|
211
|
+
* @prop {string} [opt.deleteKeyCode='Backspace'] Key to delete selected elements (requires deleteKeyEnabled)
|
|
212
|
+
* @prop {boolean} [opt.multiSelectEnabled=true] Enable multi-selection (box select + Shift+Click)
|
|
213
|
+
* @prop {string} [opt.boxSelectionKeyCode='Shift'] Key to hold for box selection (drag on canvas)
|
|
214
|
+
* @prop {string} [opt.multiSelectionKeyCode='Shift'] Key to hold for Shift+Click add/remove selection
|
|
215
|
+
* @prop {boolean} [opt.zoomOnScroll=true] Zoom with mouse wheel
|
|
216
|
+
* @prop {number} [opt.zoom=1] Initial viewport zoom level
|
|
217
|
+
* @prop {number} [opt.zoomMin=0.5] Minimum zoom level (fitView may go below it; wheel zoom then keeps the current level as its lower bound instead of jumping back)
|
|
218
|
+
* @prop {number} [opt.zoomMax=2] Maximum zoom level
|
|
219
|
+
* @prop {Array} [opt.center=[0,0]] Initial viewport center [x, y]
|
|
220
|
+
* @prop {boolean} [opt.panOnDrag=true] Pan canvas by dragging background
|
|
221
|
+
* @prop {Array} [opt.panLimits=null] Pan limits [[minX,minY],[maxX,maxY]]
|
|
222
|
+
* @prop {boolean} [opt.snapToGrid=false] Snap node positions to grid
|
|
223
|
+
* @prop {number} [opt.snapGridSize=20] Grid cell size (px, used for both drag snap and resize snap)
|
|
224
|
+
*
|
|
225
|
+
* ─── Platform ────────────────────────────────────────────────────────
|
|
226
|
+
* @prop {string} [opt.platformBackgroundPatternType='dots'] Background pattern: 'dots' | 'lines' | 'cross'
|
|
227
|
+
* @prop {number} [opt.platformBackgroundPatternGap=20] Pattern spacing (px)
|
|
228
|
+
* @prop {number} [opt.platformBackgroundPatternSize=1] Pattern element size
|
|
229
|
+
* @prop {string} [opt.platformBackgroundPatternColor='#81818a'] Pattern color
|
|
230
|
+
* @prop {string} [opt.platformBackgroundColor='#fff'] Canvas background color
|
|
231
|
+
*
|
|
232
|
+
* ─── Menu ──────────────────────────────────────────────────────────────
|
|
233
|
+
* Top-left toolbar. Every option is opt-in: omit them all and the toolbar is identical to before.
|
|
234
|
+
* Any value of the wrong type (or an empty string) falls back to the default listed here.
|
|
235
|
+
* @prop {boolean} [opt.useMenu=true] Show the whole toolbar
|
|
236
|
+
* @prop {string} [opt.menuPosition='top-left'] Toolbar corner: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
|
|
237
|
+
* @prop {number} [opt.menuYShift=0] Toolbar vertical shift (px); positive moves it away from its anchored edge (down for top-*, up for bottom-*)
|
|
238
|
+
* @prop {boolean} [opt.useSetting=true] Initial expanded state (afterwards toggled via the gear button)
|
|
239
|
+
* @prop {string} [opt.menuSettingIcon=mdiCogOutline] Gear (collapse/expand) button icon, SVG path string
|
|
240
|
+
* @prop {string} [opt.menuSettingTooltip='Settings'] Gear button tooltip
|
|
241
|
+
* @prop {boolean} [opt.useMenuItemZoomIn=true] Show zoom-in button
|
|
242
|
+
* @prop {string} [opt.menuZoomInIcon=mdiMagnifyPlusOutline] Zoom-in icon, SVG path string
|
|
243
|
+
* @prop {string} [opt.menuZoomInTooltip='Zoom In'] Zoom-in tooltip
|
|
244
|
+
* @prop {boolean} [opt.useMenuItemZoomOut=true] Show zoom-out button
|
|
245
|
+
* @prop {string} [opt.menuZoomOutIcon=mdiMagnifyMinusOutline] Zoom-out icon, SVG path string
|
|
246
|
+
* @prop {string} [opt.menuZoomOutTooltip='Zoom Out'] Zoom-out tooltip
|
|
247
|
+
* @prop {boolean} [opt.useMenuItemFitView=true] Show fit-view button
|
|
248
|
+
* @prop {string} [opt.menuFitViewIcon=mdiFitToPageOutline] Fit-view icon, SVG path string
|
|
249
|
+
* @prop {string} [opt.menuFitViewTooltip='Fit View'] Fit-view tooltip
|
|
250
|
+
* @prop {boolean} [opt.useMenuItemLock=true] Show lock button
|
|
251
|
+
* @prop {string} [opt.menuLockIcon=mdiLockOpenVariantOutline] Lock button icon while unlocked
|
|
252
|
+
* @prop {string} [opt.menuLockTooltip='Lock'] Lock button tooltip while unlocked (names the action the click performs)
|
|
253
|
+
* @prop {string} [opt.menuLockIconLocked=mdiLockOutline] Lock button icon while locked
|
|
254
|
+
* @prop {string} [opt.menuLockTooltipLocked='Unlock'] Lock button tooltip while locked
|
|
255
|
+
* @prop {string} [opt.menuIconColor='#555'] Toolbar icon color
|
|
256
|
+
* @prop {string} [opt.menuIconColorHover='#222'] Toolbar icon color on hover
|
|
257
|
+
* @prop {string} [opt.menuIconColorFocus='#222'] Toolbar icon color on focus
|
|
258
|
+
* @prop {number} [opt.menuIconSize=22] Toolbar icon size (px)
|
|
259
|
+
* @prop {string} [opt.menuBackgroundColor='#fefefe'] Toolbar button background
|
|
260
|
+
* @prop {string} [opt.menuBackgroundColorHover='#f0f0f0'] Toolbar button background on hover
|
|
261
|
+
* @prop {string} [opt.menuBackgroundColorFocus='#f0f0f0'] Toolbar button background on focus
|
|
262
|
+
* @prop {string} [opt.menuSeparatorColor='#e6e6e6'] Toolbar separator line color
|
|
263
|
+
* @prop {boolean} [opt.menuShadow=true] Toolbar drop shadow
|
|
264
|
+
* @prop {string} [opt.menuTooltipTextColor='white'] Toolbar tooltip text color
|
|
265
|
+
* @prop {string} [opt.menuTooltipTextFontSize='0.7rem'] Toolbar tooltip font size
|
|
266
|
+
* @prop {string} [opt.menuTooltipBackgroundColor='rgba(60,60,60,0.75)'] Toolbar tooltip background
|
|
267
|
+
*
|
|
268
|
+
* ─── Settings Popup ────────────────────────────────────────────────────
|
|
269
|
+
* @prop {string} [opt.settingsPopupBackgroundColor='#fff'] Settings popup background
|
|
270
|
+
* @prop {string} [opt.settingsPopupTextColor='#333'] Settings popup text color
|
|
271
|
+
* @prop {string} [opt.settingsPopupTextFontSize='12px'] Settings popup font size
|
|
272
|
+
*
|
|
273
|
+
* ─── Infor Popup ────────────────────────────────────────────────────────
|
|
274
|
+
* @prop {string} [opt.inforPopupBackgroundColor='#fff'] Info popup background
|
|
275
|
+
* @prop {string} [opt.inforPopupTitleTextColor='#333'] Info popup title text color
|
|
276
|
+
* @prop {string} [opt.inforPopupTitleTextFontSize='12px'] Info popup title font size
|
|
277
|
+
* @prop {string} [opt.inforPopupDescriptionTextColor='#888'] Info popup description text color
|
|
278
|
+
* @prop {string} [opt.inforPopupDescriptionTextFontSize='10px'] Info popup description font size
|
|
279
|
+
*
|
|
280
|
+
* ─── Default Node ──────────────────────────────────────────
|
|
281
|
+
* @prop {string} [opt.defNodeType='basic'] Default node type: 'input' | 'basic' | 'output'
|
|
282
|
+
* @prop {string} [opt.defNodeShape='rectangle'] Default shape: 'rectangle' | 'diamond' | 'ellipse' | 'triangle' | ...
|
|
283
|
+
* @prop {number} [opt.defNodeWidth=100] Default node width (px)
|
|
284
|
+
* @prop {number} [opt.defNodeHeight=40] Default node height (px)
|
|
285
|
+
* @prop {number} [opt.defNodeFontSize=12] Default node font size (px)
|
|
286
|
+
* @prop {number} [opt.defNodeFontSizeMin=1] Min font size in settings
|
|
287
|
+
* @prop {number} [opt.defNodeFontSizeMax=72] Max font size in settings
|
|
288
|
+
* @prop {string} [opt.defNodeFontColor='#333333'] Default node text color
|
|
289
|
+
* @prop {string} [opt.defNodeFaceColor='#ffffff'] Default node fill color
|
|
290
|
+
* @prop {string} [opt.defNodeEdgeColor='#bbbbbb'] Default node border color
|
|
291
|
+
* @prop {number} [opt.defNodeEdgeWidth=1] Default node border width (px)
|
|
292
|
+
* @prop {string} [opt.defNodeToPosition='bottom'] Default outgoing handle position: 'top' | 'bottom' | 'left' | 'right'
|
|
293
|
+
* @prop {string} [opt.defNodeFromPosition='top'] Default incoming handle position
|
|
294
|
+
* @prop {string} [opt.defNodePopupDirection='right'] Default settings popup direction
|
|
295
|
+
*
|
|
296
|
+
* ─── Default Creating Connection ────────────────────────────────────────────────────────
|
|
297
|
+
* @prop {string} [opt.defConnCreatingType='bezier'] Drag-line type: 'bezier' | 'straight' | 'step' | 'smoothstep'
|
|
298
|
+
* @prop {string} [opt.defConnCreatingEdgeColor='#b1b1b7'] Drag-line color
|
|
299
|
+
* @prop {number} [opt.defConnCreatingEdgeWidth=1] Drag-line width (px)
|
|
300
|
+
* @prop {string} [opt.defConnCreatingEdgeDasharray='5 5'] Drag-line dash pattern ('' for solid)
|
|
301
|
+
* @prop {Function} [opt.funValidConnCreating=null] Custom connection validator fn(connection) → boolean
|
|
302
|
+
*
|
|
303
|
+
* ─── Default Connection ────────────────────────────────────
|
|
304
|
+
* @prop {string} [opt.defConnType='bezier'] Default conn type: 'bezier' | 'straight' | 'step' | 'smoothstep'
|
|
305
|
+
* @prop {number} [opt.defConnFontSize=10] Default conn label font size (px)
|
|
306
|
+
* @prop {number} [opt.defConnFontSizeMin=1] Min font size in settings
|
|
307
|
+
* @prop {number} [opt.defConnFontSizeMax=72] Max font size in settings
|
|
308
|
+
* @prop {string} [opt.defConnFontColor='#333333'] Default conn label text color
|
|
309
|
+
* @prop {string} [opt.defConnEdgeColor='#b1b1b7'] Default conn line color
|
|
310
|
+
* @prop {number} [opt.defConnEdgeWidth=1] Default conn line width (px)
|
|
311
|
+
* @prop {string} [opt.defConnEdgeDasharray=''] Default conn dash pattern ('' for solid, '5 5' for dashed)
|
|
312
|
+
* @prop {string} [opt.defConnMarkerEnd=''] Default arrow marker: '' | 'arrow' | 'arrowclosed'
|
|
313
|
+
* @prop {boolean} [opt.defConnAnimated=false] Default conn animation (dashed flow)
|
|
314
|
+
* @prop {number} [opt.defOffset=24] Step/smoothstep routing buffer (px)
|
|
315
|
+
*/
|
|
316
|
+
export default {
|
|
317
|
+
components: {
|
|
318
|
+
FlowCanvas,
|
|
319
|
+
ViewportTransform,
|
|
320
|
+
BackgroundLayer,
|
|
321
|
+
SelectionBox,
|
|
322
|
+
NodeRenderer,
|
|
323
|
+
EdgeRenderer,
|
|
324
|
+
ConnectionLine,
|
|
325
|
+
Controls,
|
|
326
|
+
},
|
|
327
|
+
props: {
|
|
328
|
+
opt: {
|
|
329
|
+
type: Object,
|
|
330
|
+
default: () => ({}),
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
provide() {
|
|
334
|
+
return {
|
|
335
|
+
getDefNode: () => this.defNode,
|
|
336
|
+
getDefConn: () => this.defConn,
|
|
337
|
+
getConns: () => this.conns, //供節點元件推導實際使用之連接點方位(conn層級錨點)
|
|
338
|
+
//拖曳/縮放ghost(細粒度): 回傳該節點進行中之暫時幾何({x,y}或{x,y,width,height}), 無則null
|
|
339
|
+
getDragGhost: (id) => {
|
|
340
|
+
return this.dragPositions[id] || null
|
|
341
|
+
},
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
data() {
|
|
345
|
+
return {
|
|
346
|
+
inited: false,
|
|
347
|
+
|
|
348
|
+
// Viewport
|
|
349
|
+
viewport: { x: 0, y: 0, zoom: 1 },
|
|
350
|
+
|
|
351
|
+
// Selection
|
|
352
|
+
selectedNodes: [],
|
|
353
|
+
selectedConns: [],
|
|
354
|
+
|
|
355
|
+
// UI state
|
|
356
|
+
selectionBox: null,
|
|
357
|
+
nodeInternals: {},
|
|
358
|
+
|
|
359
|
+
// Interactive lock state (opt.locked sets the initial value only;
|
|
360
|
+
// afterwards toggled via the Controls lock button)
|
|
361
|
+
locked: this.opt.locked === true,
|
|
362
|
+
|
|
363
|
+
// Drag state
|
|
364
|
+
isDraggingNode: false,
|
|
365
|
+
draggingNodeId: null,
|
|
366
|
+
dragStartPos: null,
|
|
367
|
+
dragNodeStartPositions: null,
|
|
368
|
+
//拖曳/縮放ghost容器: 鍵隨nodes預建(值null=無ghost), 永不整包替換——
|
|
369
|
+
//讀取端(Node/EdgeWrapper)依賴per-key, 拖曳開始/每步/結束皆僅通知被拖節點之讀者, 無全量重渲染
|
|
370
|
+
dragPositions: {},
|
|
371
|
+
|
|
372
|
+
// Pan state
|
|
373
|
+
isPanning: false,
|
|
374
|
+
panStartPos: null,
|
|
375
|
+
|
|
376
|
+
// Connection state
|
|
377
|
+
isConnecting: false,
|
|
378
|
+
connectingFrom: null,
|
|
379
|
+
connLineFromX: 0,
|
|
380
|
+
connLineFromY: 0,
|
|
381
|
+
connLineFromPosition: 'bottom',
|
|
382
|
+
connLineToX: 0,
|
|
383
|
+
connLineToY: 0,
|
|
384
|
+
|
|
385
|
+
// Selection state
|
|
386
|
+
isSelecting: false,
|
|
387
|
+
selectionStartPos: null,
|
|
388
|
+
|
|
389
|
+
// Key state
|
|
390
|
+
keysPressed: {},
|
|
391
|
+
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
watch: {
|
|
395
|
+
//ghost鍵預建: 於節點首次渲染前備妥per-key反應式插槽, 讀者才能建立細粒度依賴
|
|
396
|
+
nodes: {
|
|
397
|
+
immediate: true,
|
|
398
|
+
handler(ns) {
|
|
399
|
+
for (const n of (ns || [])) {
|
|
400
|
+
if (!(n.id in this.dragPositions)) {
|
|
401
|
+
this.$set(this.dragPositions, n.id, null)
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
opt: {
|
|
407
|
+
handler() {
|
|
408
|
+
if (!this.inited) {
|
|
409
|
+
this.inited = true
|
|
410
|
+
let vc = this.center
|
|
411
|
+
if (vc) {
|
|
412
|
+
this.viewport.x = vc[0] || 0
|
|
413
|
+
this.viewport.y = vc[1] || 0
|
|
414
|
+
}
|
|
415
|
+
this.viewport.zoom = this.zoom
|
|
416
|
+
this.$emit('init')
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
immediate: true,
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
mounted() {
|
|
423
|
+
document.addEventListener('keydown', this.onKeyDown)
|
|
424
|
+
document.addEventListener('keyup', this.onKeyUp)
|
|
425
|
+
document.addEventListener('mousemove', this.onDocMouseMove)
|
|
426
|
+
document.addEventListener('mouseup', this.onDocMouseUp)
|
|
427
|
+
},
|
|
428
|
+
beforeDestroy() {
|
|
429
|
+
if (this._panAnimId) {
|
|
430
|
+
cancelAnimationFrame(this._panAnimId)
|
|
431
|
+
this._panAnimId = null
|
|
432
|
+
}
|
|
433
|
+
document.removeEventListener('keydown', this.onKeyDown)
|
|
434
|
+
document.removeEventListener('keyup', this.onKeyUp)
|
|
435
|
+
document.removeEventListener('mousemove', this.onDocMouseMove)
|
|
436
|
+
document.removeEventListener('mouseup', this.onDocMouseUp)
|
|
437
|
+
},
|
|
438
|
+
computed: {
|
|
439
|
+
widthInp() {
|
|
440
|
+
return this.opt.width || 800
|
|
441
|
+
},
|
|
442
|
+
heightInp() {
|
|
443
|
+
return this.opt.height || 600
|
|
444
|
+
},
|
|
445
|
+
nodes() {
|
|
446
|
+
return this.opt.nodes || []
|
|
447
|
+
},
|
|
448
|
+
conns() {
|
|
449
|
+
return this.opt.conns || []
|
|
450
|
+
},
|
|
451
|
+
|
|
452
|
+
nodesDraggable() {
|
|
453
|
+
return this.opt.nodesDraggable !== undefined ? this.opt.nodesDraggable : true
|
|
454
|
+
},
|
|
455
|
+
menuInp() {
|
|
456
|
+
//垂直選單之全部設定, 自opt原樣取出後交Controls解析; 各項未給或型別不符即由Controls回退預設,
|
|
457
|
+
//故此處不套預設值, 預設值統一定義於Controls.vue之menuDef(icon預設需用到@mdi/js之常數)
|
|
458
|
+
let o = this.opt
|
|
459
|
+
return {
|
|
460
|
+
|
|
461
|
+
//整體
|
|
462
|
+
useMenu: o.useMenu,
|
|
463
|
+
menuPosition: o.menuPosition,
|
|
464
|
+
menuYShift: o.menuYShift,
|
|
465
|
+
useSetting: o.useSetting,
|
|
466
|
+
|
|
467
|
+
//設定鈕(收合/展開)
|
|
468
|
+
menuSettingIcon: o.menuSettingIcon,
|
|
469
|
+
menuSettingTooltip: o.menuSettingTooltip,
|
|
470
|
+
|
|
471
|
+
//放大
|
|
472
|
+
useMenuItemZoomIn: o.useMenuItemZoomIn,
|
|
473
|
+
menuZoomInIcon: o.menuZoomInIcon,
|
|
474
|
+
menuZoomInTooltip: o.menuZoomInTooltip,
|
|
475
|
+
|
|
476
|
+
//縮小
|
|
477
|
+
useMenuItemZoomOut: o.useMenuItemZoomOut,
|
|
478
|
+
menuZoomOutIcon: o.menuZoomOutIcon,
|
|
479
|
+
menuZoomOutTooltip: o.menuZoomOutTooltip,
|
|
480
|
+
|
|
481
|
+
//全圖
|
|
482
|
+
useMenuItemFitView: o.useMenuItemFitView,
|
|
483
|
+
menuFitViewIcon: o.menuFitViewIcon,
|
|
484
|
+
menuFitViewTooltip: o.menuFitViewTooltip,
|
|
485
|
+
|
|
486
|
+
//鎖定(雙態: 無後綴為未鎖態, Locked後綴為已鎖態)
|
|
487
|
+
useMenuItemLock: o.useMenuItemLock,
|
|
488
|
+
menuLockIcon: o.menuLockIcon,
|
|
489
|
+
menuLockTooltip: o.menuLockTooltip,
|
|
490
|
+
menuLockIconLocked: o.menuLockIconLocked,
|
|
491
|
+
menuLockTooltipLocked: o.menuLockTooltipLocked,
|
|
492
|
+
|
|
493
|
+
//樣式
|
|
494
|
+
menuIconColor: o.menuIconColor,
|
|
495
|
+
menuIconColorHover: o.menuIconColorHover,
|
|
496
|
+
menuIconColorFocus: o.menuIconColorFocus,
|
|
497
|
+
menuIconSize: o.menuIconSize,
|
|
498
|
+
menuBackgroundColor: o.menuBackgroundColor,
|
|
499
|
+
menuBackgroundColorHover: o.menuBackgroundColorHover,
|
|
500
|
+
menuBackgroundColorFocus: o.menuBackgroundColorFocus,
|
|
501
|
+
menuSeparatorColor: o.menuSeparatorColor,
|
|
502
|
+
menuShadow: o.menuShadow,
|
|
503
|
+
menuTooltipTextColor: o.menuTooltipTextColor,
|
|
504
|
+
menuTooltipTextFontSize: o.menuTooltipTextFontSize,
|
|
505
|
+
menuTooltipBackgroundColor: o.menuTooltipBackgroundColor,
|
|
506
|
+
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
nodesConnectable() {
|
|
510
|
+
return this.opt.nodesConnectable !== undefined ? this.opt.nodesConnectable : true
|
|
511
|
+
},
|
|
512
|
+
nodesResizable() {
|
|
513
|
+
return this.opt.nodesResizable !== undefined ? this.opt.nodesResizable : true
|
|
514
|
+
},
|
|
515
|
+
elementsSelectable() {
|
|
516
|
+
return this.opt.elementsSelectable !== undefined ? this.opt.elementsSelectable : true
|
|
517
|
+
},
|
|
518
|
+
nodesSettingsEnabled() {
|
|
519
|
+
return this.opt.nodesSettingsEnabled !== undefined ? this.opt.nodesSettingsEnabled : true
|
|
520
|
+
},
|
|
521
|
+
connsSettingsEnabled() {
|
|
522
|
+
return this.opt.connsSettingsEnabled !== undefined ? this.opt.connsSettingsEnabled : true
|
|
523
|
+
},
|
|
524
|
+
nodesSettingsExcludes() {
|
|
525
|
+
return this.opt.nodesSettingsExcludes || []
|
|
526
|
+
},
|
|
527
|
+
connsSettingsExcludes() {
|
|
528
|
+
return this.opt.connsSettingsExcludes || []
|
|
529
|
+
},
|
|
530
|
+
selectNodesOnDrag() {
|
|
531
|
+
return this.opt.selectNodesOnDrag !== undefined ? this.opt.selectNodesOnDrag : true
|
|
532
|
+
},
|
|
533
|
+
deleteKeyEnabled() {
|
|
534
|
+
return this.opt.deleteKeyEnabled !== undefined ? this.opt.deleteKeyEnabled : false
|
|
535
|
+
},
|
|
536
|
+
deleteKeyCode() {
|
|
537
|
+
return this.opt.deleteKeyCode || 'Backspace'
|
|
538
|
+
},
|
|
539
|
+
|
|
540
|
+
defConnCreatingType() {
|
|
541
|
+
return this.opt.defConnCreatingType || 'bezier'
|
|
542
|
+
},
|
|
543
|
+
defConnCreatingEdgeColor() {
|
|
544
|
+
return this.opt.defConnCreatingEdgeColor || '#b1b1b7'
|
|
545
|
+
},
|
|
546
|
+
defConnCreatingEdgeWidth() {
|
|
547
|
+
return this.opt.defConnCreatingEdgeWidth !== undefined ? this.opt.defConnCreatingEdgeWidth : 1
|
|
548
|
+
},
|
|
549
|
+
defConnCreatingEdgeDasharray() {
|
|
550
|
+
return this.opt.defConnCreatingEdgeDasharray || '5 5'
|
|
551
|
+
},
|
|
552
|
+
defConnCreatingStyle() {
|
|
553
|
+
return {
|
|
554
|
+
stroke: this.defConnCreatingEdgeColor,
|
|
555
|
+
strokeWidth: this.defConnCreatingEdgeWidth,
|
|
556
|
+
strokeDasharray: this.defConnCreatingEdgeDasharray,
|
|
557
|
+
}
|
|
558
|
+
},
|
|
559
|
+
zoomOnScroll() {
|
|
560
|
+
return this.opt.zoomOnScroll !== undefined ? this.opt.zoomOnScroll : true
|
|
561
|
+
},
|
|
562
|
+
panOnDrag() {
|
|
563
|
+
return this.opt.panOnDrag !== undefined ? this.opt.panOnDrag : true
|
|
564
|
+
},
|
|
565
|
+
zoomMin() {
|
|
566
|
+
return this.opt.zoomMin !== undefined ? this.opt.zoomMin : 0.5
|
|
567
|
+
},
|
|
568
|
+
zoomMax() {
|
|
569
|
+
return this.opt.zoomMax !== undefined ? this.opt.zoomMax : 2
|
|
570
|
+
},
|
|
571
|
+
center() {
|
|
572
|
+
return this.opt.center || [0, 0]
|
|
573
|
+
},
|
|
574
|
+
zoom() {
|
|
575
|
+
return this.opt.zoom !== undefined ? this.opt.zoom : 1
|
|
576
|
+
},
|
|
577
|
+
panLimits() {
|
|
578
|
+
return this.opt.panLimits || null
|
|
579
|
+
},
|
|
580
|
+
|
|
581
|
+
multiSelectEnabled() {
|
|
582
|
+
return this.opt.multiSelectEnabled !== undefined ? this.opt.multiSelectEnabled : true
|
|
583
|
+
},
|
|
584
|
+
boxSelectionKeyCode() {
|
|
585
|
+
return this.opt.boxSelectionKeyCode || 'Shift'
|
|
586
|
+
},
|
|
587
|
+
multiSelectionKeyCode() {
|
|
588
|
+
return this.opt.multiSelectionKeyCode || 'Shift'
|
|
589
|
+
},
|
|
590
|
+
|
|
591
|
+
snapToGrid() {
|
|
592
|
+
return this.opt.snapToGrid !== undefined ? this.opt.snapToGrid : false
|
|
593
|
+
},
|
|
594
|
+
snapGridSize() {
|
|
595
|
+
return this.opt.snapGridSize || 20
|
|
596
|
+
},
|
|
597
|
+
|
|
598
|
+
platformBackgroundPatternType() {
|
|
599
|
+
return this.opt.platformBackgroundPatternType || 'dots'
|
|
600
|
+
},
|
|
601
|
+
platformBackgroundPatternGap() {
|
|
602
|
+
return this.opt.platformBackgroundPatternGap !== undefined ? this.opt.platformBackgroundPatternGap : 20
|
|
603
|
+
},
|
|
604
|
+
platformBackgroundPatternSize() {
|
|
605
|
+
return this.opt.platformBackgroundPatternSize !== undefined ? this.opt.platformBackgroundPatternSize : 1
|
|
606
|
+
},
|
|
607
|
+
platformBackgroundPatternColor() {
|
|
608
|
+
return this.opt.platformBackgroundPatternColor || '#81818a'
|
|
609
|
+
},
|
|
610
|
+
platformBackgroundColor() {
|
|
611
|
+
return this.opt.platformBackgroundColor || '#fff'
|
|
612
|
+
},
|
|
613
|
+
|
|
614
|
+
// --- Settings popup styling ---
|
|
615
|
+
settingsPopupBackgroundColor() {
|
|
616
|
+
return this.opt.settingsPopupBackgroundColor || '#fff'
|
|
617
|
+
},
|
|
618
|
+
settingsPopupTextColor() {
|
|
619
|
+
return this.opt.settingsPopupTextColor || '#333'
|
|
620
|
+
},
|
|
621
|
+
settingsPopupTextFontSize() {
|
|
622
|
+
return this.opt.settingsPopupTextFontSize || '12px'
|
|
623
|
+
},
|
|
624
|
+
inforPopupBackgroundColor() {
|
|
625
|
+
return this.opt.inforPopupBackgroundColor || '#fff'
|
|
626
|
+
},
|
|
627
|
+
inforPopupTitleTextColor() {
|
|
628
|
+
return this.opt.inforPopupTitleTextColor || '#333'
|
|
629
|
+
},
|
|
630
|
+
inforPopupTitleTextFontSize() {
|
|
631
|
+
return this.opt.inforPopupTitleTextFontSize || '12px'
|
|
632
|
+
},
|
|
633
|
+
inforPopupDescriptionTextColor() {
|
|
634
|
+
return this.opt.inforPopupDescriptionTextColor || '#888'
|
|
635
|
+
},
|
|
636
|
+
inforPopupDescriptionTextFontSize() {
|
|
637
|
+
return this.opt.inforPopupDescriptionTextFontSize || '10px'
|
|
638
|
+
},
|
|
639
|
+
|
|
640
|
+
funValidConnCreating() {
|
|
641
|
+
return this.opt.funValidConnCreating || null
|
|
642
|
+
},
|
|
643
|
+
|
|
644
|
+
defNode() {
|
|
645
|
+
let o = this.opt
|
|
646
|
+
let d = NODE_DEFAULTS
|
|
647
|
+
return {
|
|
648
|
+
type: o.defNodeType || d.type,
|
|
649
|
+
shape: o.defNodeShape || d.shape,
|
|
650
|
+
width: o.defNodeWidth || d.width,
|
|
651
|
+
height: o.defNodeHeight || d.height,
|
|
652
|
+
fontSize: o.defNodeFontSize || d.fontSize,
|
|
653
|
+
fontSizeMin: o.defNodeFontSizeMin || d.fontSizeMin,
|
|
654
|
+
fontSizeMax: o.defNodeFontSizeMax || d.fontSizeMax,
|
|
655
|
+
fontColor: o.defNodeFontColor || d.fontColor,
|
|
656
|
+
faceColor: o.defNodeFaceColor || d.faceColor,
|
|
657
|
+
edgeColor: o.defNodeEdgeColor || d.edgeColor,
|
|
658
|
+
edgeWidth: o.defNodeEdgeWidth !== undefined ? o.defNodeEdgeWidth : d.edgeWidth,
|
|
659
|
+
toPosition: o.defNodeToPosition || d.toPosition,
|
|
660
|
+
fromPosition: o.defNodeFromPosition || d.fromPosition,
|
|
661
|
+
popupDirection: o.defNodePopupDirection || d.popupDirection,
|
|
662
|
+
}
|
|
663
|
+
},
|
|
664
|
+
defConn() {
|
|
665
|
+
let o = this.opt
|
|
666
|
+
let d = CONN_DEFAULTS
|
|
667
|
+
return {
|
|
668
|
+
type: o.defConnType || d.type,
|
|
669
|
+
fontSize: o.defConnFontSize || d.fontSize,
|
|
670
|
+
fontSizeMin: o.defConnFontSizeMin || d.fontSizeMin,
|
|
671
|
+
fontSizeMax: o.defConnFontSizeMax || d.fontSizeMax,
|
|
672
|
+
fontColor: o.defConnFontColor || d.fontColor,
|
|
673
|
+
edgeColor: o.defConnEdgeColor || d.edgeColor,
|
|
674
|
+
edgeWidth: o.defConnEdgeWidth !== undefined ? o.defConnEdgeWidth : d.edgeWidth,
|
|
675
|
+
edgeDasharray: o.defConnEdgeDasharray || '',
|
|
676
|
+
markerEnd: o.defConnMarkerEnd || d.markerEnd,
|
|
677
|
+
animated: o.defConnAnimated !== undefined ? o.defConnAnimated : d.animated,
|
|
678
|
+
defOffset: o.defOffset != null ? o.defOffset : d.defOffset,
|
|
679
|
+
}
|
|
680
|
+
},
|
|
681
|
+
|
|
682
|
+
//(效能重構)拖曳/縮放ghost改由getDragGhost細粒度提供(per-node反應式鍵), 不再整包重建nodes陣列
|
|
683
|
+
//why: 舊renderNodes每步mousemove產新陣列+新物件prop, 使兩Renderer與全部Node/EdgeWrapper(含WPopup/WTooltip子樹)
|
|
684
|
+
// 每步全量重渲染(84節點+95邊實測~128ms/步); 細粒度後僅被拖節點與其相連邊重渲染
|
|
685
|
+
isBoxSelectPressed() {
|
|
686
|
+
return this.multiSelectEnabled && !!this.keysPressed[this.boxSelectionKeyCode]
|
|
687
|
+
},
|
|
688
|
+
isMultiSelectPressed() {
|
|
689
|
+
return this.multiSelectEnabled && !!this.keysPressed[this.multiSelectionKeyCode]
|
|
690
|
+
},
|
|
691
|
+
},
|
|
692
|
+
methods: {
|
|
693
|
+
// --- Helpers (replace store methods) ---
|
|
694
|
+
nodeById(id) {
|
|
695
|
+
return this.nodes.find(n => n.id === id) || null
|
|
696
|
+
},
|
|
697
|
+
connById(id) {
|
|
698
|
+
return this.conns.find(c => c.id === id) || null
|
|
699
|
+
},
|
|
700
|
+
setSelectedNodes(ids) {
|
|
701
|
+
this.selectedNodes.splice(0, this.selectedNodes.length, ...ids)
|
|
702
|
+
},
|
|
703
|
+
setSelectedConns(ids) {
|
|
704
|
+
this.selectedConns.splice(0, this.selectedConns.length, ...ids)
|
|
705
|
+
},
|
|
706
|
+
clearSelection() {
|
|
707
|
+
this.selectedNodes.splice(0, this.selectedNodes.length)
|
|
708
|
+
this.selectedConns.splice(0, this.selectedConns.length)
|
|
709
|
+
},
|
|
710
|
+
removeNode(id) {
|
|
711
|
+
let nodes = this.nodes
|
|
712
|
+
let idx = nodes.findIndex(n => n.id === id)
|
|
713
|
+
if (idx === -1) return
|
|
714
|
+
nodes.splice(idx, 1)
|
|
715
|
+
// Remove connected conns
|
|
716
|
+
let conns = this.conns
|
|
717
|
+
for (let i = conns.length - 1; i >= 0; i--) {
|
|
718
|
+
if (conns[i].from === id || conns[i].to === id) {
|
|
719
|
+
conns.splice(i, 1)
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
let selIdx = this.selectedNodes.indexOf(id)
|
|
723
|
+
if (selIdx !== -1) this.selectedNodes.splice(selIdx, 1)
|
|
724
|
+
},
|
|
725
|
+
removeConn(id) {
|
|
726
|
+
let conns = this.conns
|
|
727
|
+
let idx = conns.findIndex(c => c.id === id)
|
|
728
|
+
if (idx === -1) return
|
|
729
|
+
conns.splice(idx, 1)
|
|
730
|
+
let selIdx = this.selectedConns.indexOf(id)
|
|
731
|
+
if (selIdx !== -1) this.selectedConns.splice(selIdx, 1)
|
|
732
|
+
},
|
|
733
|
+
addConn(conn) {
|
|
734
|
+
if (!conn.id || !conn.from || !conn.to) return
|
|
735
|
+
if (this.connById(conn.id)) return
|
|
736
|
+
if (!this.nodeById(conn.from) || !this.nodeById(conn.to)) return
|
|
737
|
+
this.conns.push(conn)
|
|
738
|
+
},
|
|
739
|
+
updateNodeInternals(id, internals) {
|
|
740
|
+
let existing = this.nodeInternals[id]
|
|
741
|
+
if (existing && existing.width === internals.width && existing.height === internals.height) return
|
|
742
|
+
this.$set(this.nodeInternals, id, internals)
|
|
743
|
+
},
|
|
744
|
+
setViewport({ x, y, zoom }) {
|
|
745
|
+
if (x !== undefined) this.viewport.x = x
|
|
746
|
+
if (y !== undefined) this.viewport.y = y
|
|
747
|
+
if (zoom !== undefined) this.viewport.zoom = zoom
|
|
748
|
+
},
|
|
749
|
+
|
|
750
|
+
// --- Key handling ---
|
|
751
|
+
onKeyDown(e) {
|
|
752
|
+
this.keysPressed = { ...this.keysPressed, [e.key]: true }
|
|
753
|
+
if (!this.locked && this.deleteKeyEnabled && (e.key === this.deleteKeyCode || e.key === 'Delete')) {
|
|
754
|
+
this.deleteSelectedElements()
|
|
755
|
+
}
|
|
756
|
+
},
|
|
757
|
+
onKeyUp(e) {
|
|
758
|
+
const copy = { ...this.keysPressed }
|
|
759
|
+
delete copy[e.key]
|
|
760
|
+
this.keysPressed = copy
|
|
761
|
+
},
|
|
762
|
+
|
|
763
|
+
// --- Canvas events ---
|
|
764
|
+
onCanvasClick(event) {
|
|
765
|
+
if (event.target.closest('.vue-flow__popup')) return
|
|
766
|
+
if (!event.target.closest('.vue-flow__node') && !event.target.closest('.vue-flow__edge')) {
|
|
767
|
+
this.clearSelection()
|
|
768
|
+
this.$emit('pane-click', event)
|
|
769
|
+
}
|
|
770
|
+
},
|
|
771
|
+
onCanvasContextMenu(event) {
|
|
772
|
+
this.$emit('pane-context-menu', event)
|
|
773
|
+
},
|
|
774
|
+
onCanvasDblClick(event) {
|
|
775
|
+
// Calculate flow-space position from the click
|
|
776
|
+
const rect = this.$refs.canvas.getContainerRect()
|
|
777
|
+
if (!rect) return
|
|
778
|
+
const vp = this.viewport
|
|
779
|
+
const flowX = (event.clientX - rect.left - vp.x) / vp.zoom
|
|
780
|
+
const flowY = (event.clientY - rect.top - vp.y) / vp.zoom
|
|
781
|
+
|
|
782
|
+
this.$emit('canvas-dblclick', {
|
|
783
|
+
event,
|
|
784
|
+
flowX,
|
|
785
|
+
flowY,
|
|
786
|
+
clientX: event.clientX,
|
|
787
|
+
clientY: event.clientY,
|
|
788
|
+
})
|
|
789
|
+
},
|
|
790
|
+
onCanvasMouseDown(event) {
|
|
791
|
+
if (event.target.closest && event.target.closest('.vue-flow__popup')) return
|
|
792
|
+
if (!this.locked && this.isBoxSelectPressed) {
|
|
793
|
+
this.startSelection(event)
|
|
794
|
+
return
|
|
795
|
+
}
|
|
796
|
+
if (this.panOnDrag && event.button === 0) {
|
|
797
|
+
const target = event.target
|
|
798
|
+
const isOnNode = target.closest && target.closest('.vue-flow__node')
|
|
799
|
+
const isOnHandle = target.closest && target.closest('.vue-flow__handle')
|
|
800
|
+
//齒輪等UI元素/左上角控制選單/連線轉折點之mousedown不啟動平移(取代其@mousedown.stop, 使mousedown仍能冒泡至window做popup互斥關閉;
|
|
801
|
+
// .vue-flow__panel=Controls垂直選單, .vue-flow__edge-waypoint=連線轉折點拖曳鈕, 否則按之再拖曳會誤觸發平移)
|
|
802
|
+
const isOnUi = target.closest && target.closest('.vue-flow__node-settings, .vue-flow__edge-settings, .vue-flow__panel, .vue-flow__edge-waypoint')
|
|
803
|
+
if (!isOnNode && !isOnHandle && !isOnUi) {
|
|
804
|
+
this.startPan(event)
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
},
|
|
808
|
+
onCanvasMouseMove(event) {
|
|
809
|
+
// Handled by document-level listener
|
|
810
|
+
},
|
|
811
|
+
onCanvasMouseUp(event) {
|
|
812
|
+
// Handled by document-level listener
|
|
813
|
+
},
|
|
814
|
+
onCanvasWheel(event) {
|
|
815
|
+
if (!this.zoomOnScroll) return
|
|
816
|
+
const delta = -event.deltaY * 0.001
|
|
817
|
+
const currentZoom = this.viewport.zoom
|
|
818
|
+
// fitView may set zoom below zoomMin; use the current level as the
|
|
819
|
+
// effective lower bound so wheel zoom does not jump the view back.
|
|
820
|
+
const zoomMinUse = Math.min(this.zoomMin, currentZoom)
|
|
821
|
+
const newZoom = Math.max(zoomMinUse, Math.min(this.zoomMax, currentZoom + delta * currentZoom))
|
|
822
|
+
|
|
823
|
+
const rect = this.$refs.canvas.getContainerRect()
|
|
824
|
+
if (!rect) return
|
|
825
|
+
const mouseX = event.clientX - rect.left
|
|
826
|
+
const mouseY = event.clientY - rect.top
|
|
827
|
+
|
|
828
|
+
const vp = this.viewport
|
|
829
|
+
const scale = newZoom / currentZoom
|
|
830
|
+
const newX = mouseX - (mouseX - vp.x) * scale
|
|
831
|
+
const newY = mouseY - (mouseY - vp.y) * scale
|
|
832
|
+
|
|
833
|
+
this.setViewport({ x: newX, y: newY, zoom: newZoom })
|
|
834
|
+
this.emitViewportChange()
|
|
835
|
+
},
|
|
836
|
+
|
|
837
|
+
// --- Document-level mouse ---
|
|
838
|
+
onDocMouseMove(event) {
|
|
839
|
+
if (this.isPanning) {
|
|
840
|
+
this.doPan(event)
|
|
841
|
+
}
|
|
842
|
+
else if (this.isDraggingNode) {
|
|
843
|
+
this.doDrag(event)
|
|
844
|
+
}
|
|
845
|
+
else if (this.isConnecting) {
|
|
846
|
+
this.doConnect(event)
|
|
847
|
+
}
|
|
848
|
+
else if (this.isSelecting) {
|
|
849
|
+
this.doSelection(event)
|
|
850
|
+
}
|
|
851
|
+
},
|
|
852
|
+
onDocMouseUp(event) {
|
|
853
|
+
if (this.isPanning) {
|
|
854
|
+
this.endPan()
|
|
855
|
+
}
|
|
856
|
+
if (this.isDraggingNode) {
|
|
857
|
+
this.endDrag(event)
|
|
858
|
+
}
|
|
859
|
+
if (this.isConnecting) {
|
|
860
|
+
this.endConnect(event)
|
|
861
|
+
}
|
|
862
|
+
if (this.isSelecting) {
|
|
863
|
+
this.endSelection(event)
|
|
864
|
+
}
|
|
865
|
+
},
|
|
866
|
+
|
|
867
|
+
// --- Pan ---
|
|
868
|
+
startPan(event) {
|
|
869
|
+
this.isPanning = true
|
|
870
|
+
this.panStartPos = { x: event.clientX, y: event.clientY }
|
|
871
|
+
},
|
|
872
|
+
doPan(event) {
|
|
873
|
+
const dx = event.clientX - this.panStartPos.x
|
|
874
|
+
const dy = event.clientY - this.panStartPos.y
|
|
875
|
+
this.panStartPos = { x: event.clientX, y: event.clientY }
|
|
876
|
+
|
|
877
|
+
let x = this.viewport.x + dx
|
|
878
|
+
let y = this.viewport.y + dy
|
|
879
|
+
|
|
880
|
+
if (this.panLimits) {
|
|
881
|
+
const clamped = clampPosition({ x, y }, this.panLimits)
|
|
882
|
+
x = clamped.x
|
|
883
|
+
y = clamped.y
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
this.viewport.x = x
|
|
887
|
+
this.viewport.y = y
|
|
888
|
+
},
|
|
889
|
+
endPan() {
|
|
890
|
+
this.isPanning = false
|
|
891
|
+
this.panStartPos = null
|
|
892
|
+
this.emitViewportChange()
|
|
893
|
+
},
|
|
894
|
+
|
|
895
|
+
// --- Node drag ---
|
|
896
|
+
onNodeDragStart({ node, event }) {
|
|
897
|
+
if (this.locked || !this.nodesDraggable) return
|
|
898
|
+
this.isDraggingNode = true
|
|
899
|
+
this.draggingNodeId = node.id
|
|
900
|
+
this.dragStartPos = { x: event.clientX, y: event.clientY }
|
|
901
|
+
|
|
902
|
+
if (this.selectNodesOnDrag && !this.isMultiSelectPressed) {
|
|
903
|
+
this.setSelectedNodes([node.id])
|
|
904
|
+
this.setSelectedConns([])
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// Cache start positions for drag
|
|
908
|
+
const starts = {}
|
|
909
|
+
this.selectedNodes.forEach(id => {
|
|
910
|
+
const n = this.nodeById(id)
|
|
911
|
+
if (n) starts[id] = { x: n.position.x, y: n.position.y }
|
|
912
|
+
})
|
|
913
|
+
if (!starts[node.id]) {
|
|
914
|
+
const n = this.nodeById(node.id)
|
|
915
|
+
if (n) starts[node.id] = { x: n.position.x, y: n.position.y }
|
|
916
|
+
}
|
|
917
|
+
this.dragNodeStartPositions = starts
|
|
918
|
+
|
|
919
|
+
//啟用被拖節點之ghost(per-key賦值, 僅通知讀該鍵之元件), 之後每步僅原地改x/y
|
|
920
|
+
for (let id in starts) {
|
|
921
|
+
if (!(id in this.dragPositions)) {
|
|
922
|
+
this.$set(this.dragPositions, id, null)
|
|
923
|
+
}
|
|
924
|
+
this.dragPositions[id] = { x: starts[id].x, y: starts[id].y }
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
this.$emit('node-drag-start', { node, event })
|
|
928
|
+
},
|
|
929
|
+
doDrag(event) {
|
|
930
|
+
const zoom = this.viewport.zoom
|
|
931
|
+
const dx = (event.clientX - this.dragStartPos.x) / zoom
|
|
932
|
+
const dy = (event.clientY - this.dragStartPos.y) / zoom
|
|
933
|
+
const snap = this.snapToGrid
|
|
934
|
+
|
|
935
|
+
for (let id in this.dragNodeStartPositions) {
|
|
936
|
+
const start = this.dragNodeStartPositions[id]
|
|
937
|
+
let x = start.x + dx
|
|
938
|
+
let y = start.y + dy
|
|
939
|
+
if (snap) {
|
|
940
|
+
const s = snapPosition({ x, y }, this.snapGridSize)
|
|
941
|
+
x = s.x
|
|
942
|
+
y = s.y
|
|
943
|
+
}
|
|
944
|
+
const gg = this.dragPositions && this.dragPositions[id]
|
|
945
|
+
if (gg) {
|
|
946
|
+
gg.x = x
|
|
947
|
+
gg.y = y
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
},
|
|
951
|
+
endDrag(event) {
|
|
952
|
+
// Write final positions back to opt.nodes, 並關閉ghost(per-key設回null)
|
|
953
|
+
if (this.dragNodeStartPositions) {
|
|
954
|
+
for (let id in this.dragNodeStartPositions) {
|
|
955
|
+
let pos = this.dragPositions[id]
|
|
956
|
+
let node = this.nodeById(id)
|
|
957
|
+
if (node && pos) {
|
|
958
|
+
node.position.x = pos.x
|
|
959
|
+
node.position.y = pos.y
|
|
960
|
+
}
|
|
961
|
+
this.dragPositions[id] = null
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
const dragNode = this.nodeById(this.draggingNodeId)
|
|
965
|
+
this.isDraggingNode = false
|
|
966
|
+
this.draggingNodeId = null
|
|
967
|
+
this.dragStartPos = null
|
|
968
|
+
this.dragNodeStartPositions = null
|
|
969
|
+
clearStepCache()
|
|
970
|
+
if (dragNode) {
|
|
971
|
+
this.$emit('node-drag-stop', { node: dragNode, event })
|
|
972
|
+
}
|
|
973
|
+
this.emitNodesUpdate()
|
|
974
|
+
},
|
|
975
|
+
|
|
976
|
+
// --- Connection ---
|
|
977
|
+
onConnectStart(payload) {
|
|
978
|
+
if (this.locked || !this.nodesConnectable) return
|
|
979
|
+
//建線只能自source(連出)型handle出發: target(連入)型handle拖曳不啟動建線, 維持方向語義
|
|
980
|
+
if (payload.handleType !== 'source') return
|
|
981
|
+
this.isConnecting = true
|
|
982
|
+
this.connectingFrom = payload
|
|
983
|
+
// Lock cursor to default during connecting, only handles show crosshair
|
|
984
|
+
this._connectCursorStyle = document.createElement('style')
|
|
985
|
+
this._connectCursorStyle.textContent = '* { cursor: default !important; } .vue-flow__handle { cursor: crosshair !important; } .vue-flow__node-settings, .vue-flow__edge-settings, .vue-flow__resize { opacity: 0 !important; pointer-events: none !important; }'
|
|
986
|
+
document.head.appendChild(this._connectCursorStyle)
|
|
987
|
+
|
|
988
|
+
const node = this.nodeById(payload.nodeId)
|
|
989
|
+
if (!node) return
|
|
990
|
+
const pos = getHandlePosition(
|
|
991
|
+
node, payload.handlePosition,
|
|
992
|
+
this.nodeInternals[payload.nodeId] || {}
|
|
993
|
+
)
|
|
994
|
+
this.connLineFromX = pos.x
|
|
995
|
+
this.connLineFromY = pos.y
|
|
996
|
+
this.connLineFromPosition = payload.handlePosition
|
|
997
|
+
this.connLineToX = pos.x
|
|
998
|
+
this.connLineToY = pos.y
|
|
999
|
+
|
|
1000
|
+
this.$emit('connect-start', {
|
|
1001
|
+
nodeId: payload.nodeId,
|
|
1002
|
+
handleId: payload.handleId,
|
|
1003
|
+
handleType: payload.handleType,
|
|
1004
|
+
})
|
|
1005
|
+
},
|
|
1006
|
+
doConnect(event) {
|
|
1007
|
+
const rect = this.$refs.canvas.getContainerRect()
|
|
1008
|
+
if (!rect) return
|
|
1009
|
+
const vp = this.viewport
|
|
1010
|
+
this.connLineToX = (event.clientX - rect.left - vp.x) / vp.zoom
|
|
1011
|
+
this.connLineToY = (event.clientY - rect.top - vp.y) / vp.zoom
|
|
1012
|
+
},
|
|
1013
|
+
endConnect(event) {
|
|
1014
|
+
// Find handle element under cursor
|
|
1015
|
+
const el = document.elementFromPoint(event.clientX, event.clientY)
|
|
1016
|
+
const handleEl = el && el.closest && el.closest('.vue-flow__handle')
|
|
1017
|
+
|
|
1018
|
+
if (handleEl && this.connectingFrom && handleEl.dataset.handleType === 'target') {
|
|
1019
|
+
//落點限target(連入)型handle: 連出點不可被當作輸入端(如input節點僅有連出點, 不可作為連線終點)
|
|
1020
|
+
const toNodeEl = handleEl.closest('.vue-flow__node')
|
|
1021
|
+
const toNodeId = toNodeEl ? toNodeEl.dataset.id : null
|
|
1022
|
+
|
|
1023
|
+
if (toNodeId) {
|
|
1024
|
+
const connection = {
|
|
1025
|
+
from: this.connectingFrom.nodeId,
|
|
1026
|
+
to: toNodeId,
|
|
1027
|
+
//逐邊錨點: 起點=實際拖曳出發之連接點方位, 迄點=落點handle之方位(缺則不設, 回退節點層級/預設)
|
|
1028
|
+
...(this.connectingFrom.handlePosition ? { fromPosition: this.connectingFrom.handlePosition } : {}),
|
|
1029
|
+
...(handleEl.dataset.handlePosition ? { toPosition: handleEl.dataset.handlePosition } : {}),
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
const valid = isValidConnection(
|
|
1033
|
+
connection,
|
|
1034
|
+
this.nodes,
|
|
1035
|
+
this.conns,
|
|
1036
|
+
this.funValidConnCreating
|
|
1037
|
+
)
|
|
1038
|
+
|
|
1039
|
+
if (valid) {
|
|
1040
|
+
const connId = `e${connection.from}-${connection.to}`
|
|
1041
|
+
const conn = {
|
|
1042
|
+
id: this.connById(connId) ? generateId() : connId,
|
|
1043
|
+
...connection,
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
this.addConn(conn)
|
|
1047
|
+
this.emitConnsUpdate()
|
|
1048
|
+
this.$emit('connect', connection)
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
this.$emit('connect-end', event)
|
|
1054
|
+
this.isConnecting = false
|
|
1055
|
+
this.connectingFrom = null
|
|
1056
|
+
if (this._connectCursorStyle) {
|
|
1057
|
+
document.head.removeChild(this._connectCursorStyle)
|
|
1058
|
+
this._connectCursorStyle = null
|
|
1059
|
+
}
|
|
1060
|
+
},
|
|
1061
|
+
|
|
1062
|
+
// --- Selection ---
|
|
1063
|
+
onNodeClick({ node, event }) {
|
|
1064
|
+
if (!this.elementsSelectable) return
|
|
1065
|
+
if (this.isMultiSelectPressed) {
|
|
1066
|
+
const idx = this.selectedNodes.indexOf(node.id)
|
|
1067
|
+
if (idx === -1) {
|
|
1068
|
+
this.selectedNodes.push(node.id)
|
|
1069
|
+
}
|
|
1070
|
+
else {
|
|
1071
|
+
this.selectedNodes.splice(idx, 1)
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
else {
|
|
1075
|
+
this.setSelectedNodes([node.id])
|
|
1076
|
+
this.setSelectedConns([])
|
|
1077
|
+
}
|
|
1078
|
+
this.emitSelectionChange()
|
|
1079
|
+
|
|
1080
|
+
this.$emit('node-click', { node, event })
|
|
1081
|
+
},
|
|
1082
|
+
onNodeDoubleClick(payload) {
|
|
1083
|
+
this.$emit('node-double-click', payload)
|
|
1084
|
+
},
|
|
1085
|
+
onNodeContextMenu(payload) {
|
|
1086
|
+
this.$emit('node-context-menu', payload)
|
|
1087
|
+
},
|
|
1088
|
+
onNodeSettingsClick(payload) {
|
|
1089
|
+
this.$emit('node-settings-click', payload)
|
|
1090
|
+
},
|
|
1091
|
+
onNodeSettingsUpdate({ node, key, value }) {
|
|
1092
|
+
let n = this.nodeById(node.id)
|
|
1093
|
+
if (!n) return
|
|
1094
|
+
let oldType = n.type
|
|
1095
|
+
this.$set(n, key, value)
|
|
1096
|
+
if (key === 'type' && oldType !== value) {
|
|
1097
|
+
let nodeId = n.id
|
|
1098
|
+
let hasTo = value === 'input' || value === 'basic'
|
|
1099
|
+
let hasFrom = value === 'output' || value === 'basic'
|
|
1100
|
+
let conns = this.conns
|
|
1101
|
+
for (let i = conns.length - 1; i >= 0; i--) {
|
|
1102
|
+
let c = conns[i]
|
|
1103
|
+
if ((!hasTo && c.from === nodeId) || (!hasFrom && c.to === nodeId)) {
|
|
1104
|
+
conns.splice(i, 1)
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
this.$emit('node-settings-update', { node: n, key, value })
|
|
1109
|
+
},
|
|
1110
|
+
onNodeSettingsDelete({ node }) {
|
|
1111
|
+
this.removeNode(node.id)
|
|
1112
|
+
clearStepCache()
|
|
1113
|
+
this.emitNodesUpdate()
|
|
1114
|
+
this.emitConnsUpdate()
|
|
1115
|
+
this.$emit('node-settings-delete', { node })
|
|
1116
|
+
},
|
|
1117
|
+
onNodeMouseEnter({ node, event }) {
|
|
1118
|
+
this.$emit('node-mouseenter', { node, event })
|
|
1119
|
+
},
|
|
1120
|
+
onNodeMouseLeave({ node, event }) {
|
|
1121
|
+
this.$emit('node-mouseleave', { node, event })
|
|
1122
|
+
},
|
|
1123
|
+
onConnClick({ conn, event }) {
|
|
1124
|
+
if (!this.elementsSelectable) return
|
|
1125
|
+
if (this.isMultiSelectPressed) {
|
|
1126
|
+
const idx = this.selectedConns.indexOf(conn.id)
|
|
1127
|
+
if (idx === -1) {
|
|
1128
|
+
this.selectedConns.push(conn.id)
|
|
1129
|
+
}
|
|
1130
|
+
else {
|
|
1131
|
+
this.selectedConns.splice(idx, 1)
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
else {
|
|
1135
|
+
this.setSelectedConns([conn.id])
|
|
1136
|
+
this.setSelectedNodes([])
|
|
1137
|
+
}
|
|
1138
|
+
this.emitSelectionChange()
|
|
1139
|
+
|
|
1140
|
+
this.$emit('conn-click', { conn, event })
|
|
1141
|
+
},
|
|
1142
|
+
onConnDoubleClick(payload) {
|
|
1143
|
+
this.$emit('conn-double-click', payload)
|
|
1144
|
+
},
|
|
1145
|
+
onConnContextMenu(payload) {
|
|
1146
|
+
this.$emit('conn-context-menu', payload)
|
|
1147
|
+
},
|
|
1148
|
+
onConnMouseEnter({ conn, event }) {
|
|
1149
|
+
this.$emit('conn-mouseenter', { conn, event })
|
|
1150
|
+
},
|
|
1151
|
+
onConnMouseLeave({ conn, event }) {
|
|
1152
|
+
this.$emit('conn-mouseleave', { conn, event })
|
|
1153
|
+
},
|
|
1154
|
+
onConnSettingsClick(payload) {
|
|
1155
|
+
this.$emit('conn-settings-click', payload)
|
|
1156
|
+
},
|
|
1157
|
+
onConnSettingsUpdate({ conn, key, value }) {
|
|
1158
|
+
let c = this.connById(conn.id)
|
|
1159
|
+
if (c) {
|
|
1160
|
+
this.$set(c, key, value)
|
|
1161
|
+
this.$emit('conn-settings-update', { conn: c, key, value })
|
|
1162
|
+
}
|
|
1163
|
+
},
|
|
1164
|
+
onConnSettingsDelete({ conn }) {
|
|
1165
|
+
this.removeConn(conn.id)
|
|
1166
|
+
clearStepCache()
|
|
1167
|
+
this.emitConnsUpdate()
|
|
1168
|
+
this.$emit('conn-settings-delete', { conn })
|
|
1169
|
+
},
|
|
1170
|
+
|
|
1171
|
+
startSelection(event) {
|
|
1172
|
+
this.isSelecting = true
|
|
1173
|
+
const rect = this.$refs.canvas.getContainerRect()
|
|
1174
|
+
if (!rect) return
|
|
1175
|
+
this.selectionStartPos = {
|
|
1176
|
+
x: event.clientX - rect.left,
|
|
1177
|
+
y: event.clientY - rect.top,
|
|
1178
|
+
}
|
|
1179
|
+
this.selectionBox = {
|
|
1180
|
+
x: this.selectionStartPos.x,
|
|
1181
|
+
y: this.selectionStartPos.y,
|
|
1182
|
+
width: 0,
|
|
1183
|
+
height: 0,
|
|
1184
|
+
}
|
|
1185
|
+
},
|
|
1186
|
+
doSelection(event) {
|
|
1187
|
+
const rect = this.$refs.canvas.getContainerRect()
|
|
1188
|
+
if (!rect) return
|
|
1189
|
+
const currentX = event.clientX - rect.left
|
|
1190
|
+
const currentY = event.clientY - rect.top
|
|
1191
|
+
const x = Math.min(this.selectionStartPos.x, currentX)
|
|
1192
|
+
const y = Math.min(this.selectionStartPos.y, currentY)
|
|
1193
|
+
const width = Math.abs(currentX - this.selectionStartPos.x)
|
|
1194
|
+
const height = Math.abs(currentY - this.selectionStartPos.y)
|
|
1195
|
+
this.selectionBox = { x, y, width, height }
|
|
1196
|
+
},
|
|
1197
|
+
endSelection() {
|
|
1198
|
+
if (this.selectionBox) {
|
|
1199
|
+
const box = this.selectionBox
|
|
1200
|
+
const vp = this.viewport
|
|
1201
|
+
// Convert screen-space box to graph-space
|
|
1202
|
+
const graphBox = {
|
|
1203
|
+
x: (box.x - vp.x) / vp.zoom,
|
|
1204
|
+
y: (box.y - vp.y) / vp.zoom,
|
|
1205
|
+
width: box.width / vp.zoom,
|
|
1206
|
+
height: box.height / vp.zoom,
|
|
1207
|
+
}
|
|
1208
|
+
const overlapping = getOverlappingNodes(graphBox, this.nodes, this.nodeInternals)
|
|
1209
|
+
const nodeIds = overlapping.map(n => n.id)
|
|
1210
|
+
this.setSelectedNodes(nodeIds)
|
|
1211
|
+
// Auto-select conns whose both ends are within selected nodes
|
|
1212
|
+
let nodeIdSet = new Set(nodeIds)
|
|
1213
|
+
let connIds = this.conns
|
|
1214
|
+
.filter(c => nodeIdSet.has(c.from) && nodeIdSet.has(c.to))
|
|
1215
|
+
.map(c => c.id)
|
|
1216
|
+
this.setSelectedConns(connIds)
|
|
1217
|
+
this.emitSelectionChange()
|
|
1218
|
+
}
|
|
1219
|
+
this.isSelecting = false
|
|
1220
|
+
this.selectionStartPos = null
|
|
1221
|
+
this.selectionBox = null
|
|
1222
|
+
},
|
|
1223
|
+
|
|
1224
|
+
// --- Delete ---
|
|
1225
|
+
deleteSelectedElements() {
|
|
1226
|
+
const { nodes, conns } = this.getSelectedElements()
|
|
1227
|
+
if (nodes.length === 0 && conns.length === 0) return
|
|
1228
|
+
|
|
1229
|
+
nodes.forEach(n => {
|
|
1230
|
+
if (n.deletable !== false) this.removeNode(n.id)
|
|
1231
|
+
})
|
|
1232
|
+
conns.forEach(e => {
|
|
1233
|
+
if (e.deletable !== false) this.removeConn(e.id)
|
|
1234
|
+
})
|
|
1235
|
+
this.clearSelection()
|
|
1236
|
+
|
|
1237
|
+
this.$emit('delete', { nodes, conns })
|
|
1238
|
+
this.emitNodesUpdate()
|
|
1239
|
+
this.emitConnsUpdate()
|
|
1240
|
+
},
|
|
1241
|
+
|
|
1242
|
+
// --- Node dimensions ---
|
|
1243
|
+
onNodeDimensions({ nodeId, width, height }) {
|
|
1244
|
+
this.updateNodeInternals(nodeId, { width, height })
|
|
1245
|
+
},
|
|
1246
|
+
|
|
1247
|
+
onNodeResize({ nodeId, width, height, x, y }) {
|
|
1248
|
+
if (this.locked) return
|
|
1249
|
+
//縮放ghost併入dragPositions同一per-key機制: 首步建物件, 之後原地改欄位
|
|
1250
|
+
if (!(nodeId in this.dragPositions)) {
|
|
1251
|
+
this.$set(this.dragPositions, nodeId, null)
|
|
1252
|
+
}
|
|
1253
|
+
const g = this.dragPositions[nodeId]
|
|
1254
|
+
if (!g) {
|
|
1255
|
+
this.dragPositions[nodeId] = { x, y, width, height }
|
|
1256
|
+
}
|
|
1257
|
+
else {
|
|
1258
|
+
g.x = x
|
|
1259
|
+
g.y = y
|
|
1260
|
+
g.width = width
|
|
1261
|
+
g.height = height
|
|
1262
|
+
}
|
|
1263
|
+
this.updateNodeInternals(nodeId, { width, height })
|
|
1264
|
+
},
|
|
1265
|
+
onNodeResizeEnd({ nodeId, width, height, x, y }) {
|
|
1266
|
+
let node = this.nodeById(nodeId)
|
|
1267
|
+
if (node) {
|
|
1268
|
+
node.width = width
|
|
1269
|
+
node.height = height
|
|
1270
|
+
node.position.x = x
|
|
1271
|
+
node.position.y = y
|
|
1272
|
+
}
|
|
1273
|
+
this.dragPositions[nodeId] = null
|
|
1274
|
+
clearStepCache()
|
|
1275
|
+
this.emitNodesUpdate()
|
|
1276
|
+
},
|
|
1277
|
+
|
|
1278
|
+
// --- Helpers ---
|
|
1279
|
+
updateNodePosition(id, position) {
|
|
1280
|
+
let node = this.nodeById(id)
|
|
1281
|
+
if (!node) return
|
|
1282
|
+
node.position.x = position.x
|
|
1283
|
+
node.position.y = position.y
|
|
1284
|
+
},
|
|
1285
|
+
getSelectedElements() {
|
|
1286
|
+
return {
|
|
1287
|
+
nodes: this.nodes.filter(n => this.selectedNodes.includes(n.id)),
|
|
1288
|
+
conns: this.conns.filter(c => this.selectedConns.includes(c.id)),
|
|
1289
|
+
}
|
|
1290
|
+
},
|
|
1291
|
+
|
|
1292
|
+
// --- Emit helpers ---
|
|
1293
|
+
emitNodesUpdate() {
|
|
1294
|
+
this.$emit('update:nodes', [...this.nodes])
|
|
1295
|
+
},
|
|
1296
|
+
emitConnsUpdate() {
|
|
1297
|
+
this.$emit('update:conns', [...this.conns])
|
|
1298
|
+
},
|
|
1299
|
+
emitViewportChange() {
|
|
1300
|
+
this.$emit('viewport-change', { ...this.viewport })
|
|
1301
|
+
},
|
|
1302
|
+
emitSelectionChange() {
|
|
1303
|
+
this.$emit('selection-change', this.getSelectedElements())
|
|
1304
|
+
},
|
|
1305
|
+
|
|
1306
|
+
// --- Public API ---
|
|
1307
|
+
fitView(padding) {
|
|
1308
|
+
padding = padding || 50
|
|
1309
|
+
let nodes = this.nodes.filter(n => !n.hidden)
|
|
1310
|
+
if (nodes.length === 0) return
|
|
1311
|
+
let internals = this.nodeInternals
|
|
1312
|
+
let minX = Infinity
|
|
1313
|
+
let minY = Infinity
|
|
1314
|
+
let maxX = -Infinity
|
|
1315
|
+
let maxY = -Infinity
|
|
1316
|
+
nodes.forEach(n => {
|
|
1317
|
+
let w = (internals[n.id] && internals[n.id].width) || n.width || 150
|
|
1318
|
+
let h = (internals[n.id] && internals[n.id].height) || n.height || 40
|
|
1319
|
+
minX = Math.min(minX, n.position.x)
|
|
1320
|
+
minY = Math.min(minY, n.position.y)
|
|
1321
|
+
maxX = Math.max(maxX, n.position.x + w)
|
|
1322
|
+
maxY = Math.max(maxY, n.position.y + h)
|
|
1323
|
+
})
|
|
1324
|
+
let rect = this.$refs.canvas ? this.$refs.canvas.getContainerRect() : null
|
|
1325
|
+
let cw = rect ? rect.width : this.widthInp
|
|
1326
|
+
let ch = rect ? rect.height : this.heightInp
|
|
1327
|
+
let gw = maxX - minX + padding * 2
|
|
1328
|
+
let gh = maxY - minY + padding * 2
|
|
1329
|
+
let zoom = Math.min(cw / gw, ch / gh, 2)
|
|
1330
|
+
this.viewport.zoom = zoom
|
|
1331
|
+
this.viewport.x = (cw - (maxX + minX) * zoom) / 2
|
|
1332
|
+
this.viewport.y = (ch - (maxY + minY) * zoom) / 2
|
|
1333
|
+
this.emitViewportChange()
|
|
1334
|
+
},
|
|
1335
|
+
zoomAtCenter(factor) {
|
|
1336
|
+
const currentZoom = this.viewport.zoom
|
|
1337
|
+
const zoomMinUse = Math.min(this.zoomMin, currentZoom)
|
|
1338
|
+
const newZoom = Math.max(zoomMinUse, Math.min(this.zoomMax, currentZoom * factor))
|
|
1339
|
+
const rect = this.$refs.canvas ? this.$refs.canvas.getContainerRect() : null
|
|
1340
|
+
const cx = rect ? rect.width / 2 : this.widthInp / 2
|
|
1341
|
+
const cy = rect ? rect.height / 2 : this.heightInp / 2
|
|
1342
|
+
const vp = this.viewport
|
|
1343
|
+
const scale = newZoom / currentZoom
|
|
1344
|
+
this.setViewport({
|
|
1345
|
+
x: cx - (cx - vp.x) * scale,
|
|
1346
|
+
y: cy - (cy - vp.y) * scale,
|
|
1347
|
+
zoom: newZoom,
|
|
1348
|
+
})
|
|
1349
|
+
this.emitViewportChange()
|
|
1350
|
+
},
|
|
1351
|
+
zoomIn() {
|
|
1352
|
+
this.zoomAtCenter(1.2)
|
|
1353
|
+
},
|
|
1354
|
+
zoomOut() {
|
|
1355
|
+
this.zoomAtCenter(1 / 1.2)
|
|
1356
|
+
},
|
|
1357
|
+
toggleInteractive() {
|
|
1358
|
+
this.locked = !this.locked
|
|
1359
|
+
this.$emit('toggle-interactive', this.locked)
|
|
1360
|
+
},
|
|
1361
|
+
panToNode(nodeId, opt) {
|
|
1362
|
+
opt = opt || {}
|
|
1363
|
+
let node = this.nodeById(nodeId)
|
|
1364
|
+
if (!node) return false
|
|
1365
|
+
let internals = this.nodeInternals[nodeId]
|
|
1366
|
+
let w = (internals && internals.width) || node.width || 150
|
|
1367
|
+
let h = (internals && internals.height) || node.height || 40
|
|
1368
|
+
let cx = node.position.x + w / 2
|
|
1369
|
+
let cy = node.position.y + h / 2
|
|
1370
|
+
let rect = this.$refs.canvas ? this.$refs.canvas.getContainerRect() : null
|
|
1371
|
+
let cw = (rect && rect.width) || this.widthInp
|
|
1372
|
+
let ch = (rect && rect.height) || this.heightInp
|
|
1373
|
+
let zoom = opt.zoom !== undefined ? opt.zoom : this.viewport.zoom
|
|
1374
|
+
let duration = opt.duration !== undefined ? opt.duration : 400
|
|
1375
|
+
let target = { x: cw / 2 - cx * zoom, y: ch / 2 - cy * zoom, zoom }
|
|
1376
|
+
if (this._panAnimId) {
|
|
1377
|
+
cancelAnimationFrame(this._panAnimId)
|
|
1378
|
+
this._panAnimId = null
|
|
1379
|
+
}
|
|
1380
|
+
let finish = () => {
|
|
1381
|
+
this.setViewport(target)
|
|
1382
|
+
this.emitViewportChange()
|
|
1383
|
+
if (opt.openPopup === true) {
|
|
1384
|
+
this.$nextTick(() => this.openNodeInfoPopup(nodeId))
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
if (!(duration > 0)) {
|
|
1388
|
+
finish()
|
|
1389
|
+
return true
|
|
1390
|
+
}
|
|
1391
|
+
let from = { x: this.viewport.x, y: this.viewport.y, zoom: this.viewport.zoom }
|
|
1392
|
+
let easeInOutCubic = (t) => t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2
|
|
1393
|
+
let startTs = null
|
|
1394
|
+
let stepFrame = (ts) => {
|
|
1395
|
+
if (startTs === null) startTs = ts
|
|
1396
|
+
let t = Math.min((ts - startTs) / duration, 1)
|
|
1397
|
+
let k = easeInOutCubic(t)
|
|
1398
|
+
this.setViewport({
|
|
1399
|
+
x: from.x + (target.x - from.x) * k,
|
|
1400
|
+
y: from.y + (target.y - from.y) * k,
|
|
1401
|
+
zoom: from.zoom + (target.zoom - from.zoom) * k,
|
|
1402
|
+
})
|
|
1403
|
+
if (t < 1) {
|
|
1404
|
+
this._panAnimId = requestAnimationFrame(stepFrame)
|
|
1405
|
+
}
|
|
1406
|
+
else {
|
|
1407
|
+
this._panAnimId = null
|
|
1408
|
+
finish()
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
this._panAnimId = requestAnimationFrame(stepFrame)
|
|
1412
|
+
return true
|
|
1413
|
+
},
|
|
1414
|
+
openNodeInfoPopup(nodeId) {
|
|
1415
|
+
let r = this.$refs.nodeRenderer
|
|
1416
|
+
if (!r) return false
|
|
1417
|
+
return r.openNodeInfoPopup(nodeId)
|
|
1418
|
+
},
|
|
1419
|
+
openConnInfoPopup(connId) {
|
|
1420
|
+
let r = this.$refs.edgeRenderer
|
|
1421
|
+
if (!r) return false
|
|
1422
|
+
return r.openConnInfoPopup(connId)
|
|
1423
|
+
},
|
|
1424
|
+
getFlowData() {
|
|
1425
|
+
return {
|
|
1426
|
+
nodes: JSON.parse(JSON.stringify(this.nodes)),
|
|
1427
|
+
conns: JSON.parse(JSON.stringify(this.conns)),
|
|
1428
|
+
}
|
|
1429
|
+
},
|
|
1430
|
+
},
|
|
1431
|
+
}
|
|
1432
|
+
</script>
|
|
1433
|
+
|
|
1434
|
+
<style scoped>
|
|
1435
|
+
|
|
1436
|
+
|
|
1437
|
+
</style>
|
|
1353
1438
|
</code></pre>
|
|
1354
1439
|
</article>
|
|
1355
1440
|
</section>
|
|
@@ -1364,7 +1449,7 @@ export default {
|
|
|
1364
1449
|
<br class="clear">
|
|
1365
1450
|
|
|
1366
1451
|
<footer>
|
|
1367
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on
|
|
1452
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sat Aug 22 2026 22:01:02 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1368
1453
|
</footer>
|
|
1369
1454
|
|
|
1370
1455
|
<script>prettyPrint();</script>
|