@flowgram.ai/renderer 0.5.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +68 -42
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +30 -15
- package/dist/index.d.ts +30 -15
- package/dist/index.js +68 -42
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _flowgram_ai_utils from '@flowgram.ai/utils';
|
|
2
|
-
import { Rectangle, Disposable, CacheOriginItem, ScrollSchema } from '@flowgram.ai/utils';
|
|
3
|
-
import { LABEL_SIDE_TYPE, FlowNodeTransitionData, FlowNodeEntity, FlowNodeTransformData, FlowDocument, FlowDocumentTransformerEntity, FlowNodeRenderData, FlowDragService, FlowRendererStateEntity } from '@flowgram.ai/document';
|
|
2
|
+
import { Rectangle, Disposable, CacheOriginItem, Xor, ScrollSchema } from '@flowgram.ai/utils';
|
|
3
|
+
import { LABEL_SIDE_TYPE, FlowNodeTransitionData, FlowNodeEntity, FlowNodeTransformData, FlowDocument, FlowDocumentTransformerEntity, FlowNodeRenderData, FlowDragService, FlowRendererStateEntity, FlowNodeJSON } from '@flowgram.ai/document';
|
|
4
4
|
import { ConfigEntity, EntityOpts, PlaygroundDragEvent, PositionSchema, SizeSchema, Layer, PipelineRegistry, LayerRegistry, PlaygroundConfigEntity, PlaygroundDrag, EditorStateConfigEntity, LayerOptions, ContextMenuService, SelectionService, PlaygroundConfig, CommandRegistry } from '@flowgram.ai/core';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { throttle } from 'lodash-es';
|
|
@@ -26,7 +26,6 @@ interface CollisionRetType {
|
|
|
26
26
|
declare class FlowDragEntity extends ConfigEntity<FlowDragEntityConfig> {
|
|
27
27
|
private playgroundConfigEntity;
|
|
28
28
|
static type: string;
|
|
29
|
-
private containerDom;
|
|
30
29
|
private containerX;
|
|
31
30
|
private containerY;
|
|
32
31
|
private _scrollXInterval;
|
|
@@ -41,8 +40,7 @@ declare class FlowDragEntity extends ConfigEntity<FlowDragEntityConfig> {
|
|
|
41
40
|
private _startScrollY;
|
|
42
41
|
private _stopScrollY;
|
|
43
42
|
stopAllScroll(): void;
|
|
44
|
-
|
|
45
|
-
scrollDirection(e: MouseEvent, containerDom: HTMLDivElement, x: number, y: number): ScrollDirection | undefined;
|
|
43
|
+
scrollDirection(e: MouseEvent, x: number, y: number): ScrollDirection | undefined;
|
|
46
44
|
dispose(): void;
|
|
47
45
|
}
|
|
48
46
|
|
|
@@ -455,23 +453,35 @@ declare class FlowScrollBarLayer extends Layer<ScrollBarOptions> {
|
|
|
455
453
|
* SPDX-License-Identifier: MIT
|
|
456
454
|
*/
|
|
457
455
|
|
|
456
|
+
type StartDragProps = {
|
|
457
|
+
dragEntities?: FlowNodeEntity[];
|
|
458
|
+
} & Xor<{
|
|
459
|
+
dragStartEntity: FlowNodeEntity;
|
|
460
|
+
}, {
|
|
461
|
+
dragJSON: FlowNodeJSON;
|
|
462
|
+
isBranch?: boolean;
|
|
463
|
+
onCreateNode: (json: FlowNodeJSON, dropEntity: FlowNodeEntity) => Promise<FlowNodeEntity>;
|
|
464
|
+
}>;
|
|
458
465
|
interface FlowDragOptions {
|
|
459
466
|
onDrop?: (opts: {
|
|
460
467
|
dragNodes: FlowNodeEntity[];
|
|
461
468
|
dropNode: FlowNodeEntity;
|
|
462
469
|
}) => void;
|
|
463
470
|
canDrop?: (opts: {
|
|
464
|
-
dragNodes: FlowNodeEntity[];
|
|
465
471
|
dropNode: FlowNodeEntity;
|
|
466
472
|
isBranch?: boolean;
|
|
467
|
-
}
|
|
473
|
+
} & Xor<{
|
|
474
|
+
dragNodes: FlowNodeEntity[];
|
|
475
|
+
}, {
|
|
476
|
+
dragJSON: FlowNodeJSON;
|
|
477
|
+
}>) => boolean;
|
|
468
478
|
}
|
|
469
479
|
/**
|
|
470
480
|
* 监听节点的激活状态
|
|
471
481
|
*/
|
|
472
482
|
declare class FlowDragLayer extends Layer<FlowDragOptions> {
|
|
473
483
|
readonly document: FlowDocument;
|
|
474
|
-
readonly
|
|
484
|
+
readonly flowDragService: FlowDragService;
|
|
475
485
|
transforms: FlowNodeTransformData[];
|
|
476
486
|
protected editorStateConfig: EditorStateConfigEntity;
|
|
477
487
|
protected playgroundConfigEntity: PlaygroundConfigEntity;
|
|
@@ -479,7 +489,13 @@ declare class FlowDragLayer extends Layer<FlowDragOptions> {
|
|
|
479
489
|
protected flowRenderStateEntity: FlowRendererStateEntity;
|
|
480
490
|
protected selectConfigEntity: FlowSelectConfigEntity;
|
|
481
491
|
private initialPosition;
|
|
482
|
-
private
|
|
492
|
+
private disableDragScroll;
|
|
493
|
+
private dragJSON?;
|
|
494
|
+
private onCreateNode?;
|
|
495
|
+
dragOffset: {
|
|
496
|
+
x: number;
|
|
497
|
+
y: number;
|
|
498
|
+
};
|
|
483
499
|
get transitions(): FlowNodeTransitionData[];
|
|
484
500
|
readonly rendererRegistry: FlowRendererRegistry;
|
|
485
501
|
get dragStartEntity(): FlowNodeEntity | undefined;
|
|
@@ -493,7 +509,7 @@ declare class FlowDragLayer extends Layer<FlowDragOptions> {
|
|
|
493
509
|
setDraggingStatus(status: boolean): void;
|
|
494
510
|
dragEnable(e: MouseEvent): boolean;
|
|
495
511
|
handleMouseMove(event: MouseEvent): void;
|
|
496
|
-
handleMouseUp(): void
|
|
512
|
+
handleMouseUp(): Promise<void>;
|
|
497
513
|
protected _dragger: PlaygroundDrag<undefined>;
|
|
498
514
|
/**
|
|
499
515
|
* 开始拖拽事件
|
|
@@ -502,15 +518,14 @@ declare class FlowDragLayer extends Layer<FlowDragOptions> {
|
|
|
502
518
|
startDrag(e: {
|
|
503
519
|
clientX: number;
|
|
504
520
|
clientY: number;
|
|
505
|
-
}, { dragStartEntity: startEntityFromProps, dragEntities, }: {
|
|
506
|
-
dragStartEntity: FlowNodeEntity;
|
|
507
|
-
dragEntities?: FlowNodeEntity[];
|
|
508
|
-
}, options?: {
|
|
521
|
+
}, { dragStartEntity: startEntityFromProps, dragEntities, dragJSON, isBranch, onCreateNode, }: StartDragProps, options?: {
|
|
509
522
|
dragOffsetX?: number;
|
|
510
523
|
dragOffsetY?: number;
|
|
524
|
+
disableDragScroll?: boolean;
|
|
511
525
|
}): Promise<void>;
|
|
512
526
|
onReady(): void;
|
|
513
|
-
|
|
527
|
+
dispose(): void;
|
|
528
|
+
render(): React.ReactPortal;
|
|
514
529
|
}
|
|
515
530
|
|
|
516
531
|
interface FlowSelectorBoxOptions extends LayerOptions {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _flowgram_ai_utils from '@flowgram.ai/utils';
|
|
2
|
-
import { Rectangle, Disposable, CacheOriginItem, ScrollSchema } from '@flowgram.ai/utils';
|
|
3
|
-
import { LABEL_SIDE_TYPE, FlowNodeTransitionData, FlowNodeEntity, FlowNodeTransformData, FlowDocument, FlowDocumentTransformerEntity, FlowNodeRenderData, FlowDragService, FlowRendererStateEntity } from '@flowgram.ai/document';
|
|
2
|
+
import { Rectangle, Disposable, CacheOriginItem, Xor, ScrollSchema } from '@flowgram.ai/utils';
|
|
3
|
+
import { LABEL_SIDE_TYPE, FlowNodeTransitionData, FlowNodeEntity, FlowNodeTransformData, FlowDocument, FlowDocumentTransformerEntity, FlowNodeRenderData, FlowDragService, FlowRendererStateEntity, FlowNodeJSON } from '@flowgram.ai/document';
|
|
4
4
|
import { ConfigEntity, EntityOpts, PlaygroundDragEvent, PositionSchema, SizeSchema, Layer, PipelineRegistry, LayerRegistry, PlaygroundConfigEntity, PlaygroundDrag, EditorStateConfigEntity, LayerOptions, ContextMenuService, SelectionService, PlaygroundConfig, CommandRegistry } from '@flowgram.ai/core';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { throttle } from 'lodash-es';
|
|
@@ -26,7 +26,6 @@ interface CollisionRetType {
|
|
|
26
26
|
declare class FlowDragEntity extends ConfigEntity<FlowDragEntityConfig> {
|
|
27
27
|
private playgroundConfigEntity;
|
|
28
28
|
static type: string;
|
|
29
|
-
private containerDom;
|
|
30
29
|
private containerX;
|
|
31
30
|
private containerY;
|
|
32
31
|
private _scrollXInterval;
|
|
@@ -41,8 +40,7 @@ declare class FlowDragEntity extends ConfigEntity<FlowDragEntityConfig> {
|
|
|
41
40
|
private _startScrollY;
|
|
42
41
|
private _stopScrollY;
|
|
43
42
|
stopAllScroll(): void;
|
|
44
|
-
|
|
45
|
-
scrollDirection(e: MouseEvent, containerDom: HTMLDivElement, x: number, y: number): ScrollDirection | undefined;
|
|
43
|
+
scrollDirection(e: MouseEvent, x: number, y: number): ScrollDirection | undefined;
|
|
46
44
|
dispose(): void;
|
|
47
45
|
}
|
|
48
46
|
|
|
@@ -455,23 +453,35 @@ declare class FlowScrollBarLayer extends Layer<ScrollBarOptions> {
|
|
|
455
453
|
* SPDX-License-Identifier: MIT
|
|
456
454
|
*/
|
|
457
455
|
|
|
456
|
+
type StartDragProps = {
|
|
457
|
+
dragEntities?: FlowNodeEntity[];
|
|
458
|
+
} & Xor<{
|
|
459
|
+
dragStartEntity: FlowNodeEntity;
|
|
460
|
+
}, {
|
|
461
|
+
dragJSON: FlowNodeJSON;
|
|
462
|
+
isBranch?: boolean;
|
|
463
|
+
onCreateNode: (json: FlowNodeJSON, dropEntity: FlowNodeEntity) => Promise<FlowNodeEntity>;
|
|
464
|
+
}>;
|
|
458
465
|
interface FlowDragOptions {
|
|
459
466
|
onDrop?: (opts: {
|
|
460
467
|
dragNodes: FlowNodeEntity[];
|
|
461
468
|
dropNode: FlowNodeEntity;
|
|
462
469
|
}) => void;
|
|
463
470
|
canDrop?: (opts: {
|
|
464
|
-
dragNodes: FlowNodeEntity[];
|
|
465
471
|
dropNode: FlowNodeEntity;
|
|
466
472
|
isBranch?: boolean;
|
|
467
|
-
}
|
|
473
|
+
} & Xor<{
|
|
474
|
+
dragNodes: FlowNodeEntity[];
|
|
475
|
+
}, {
|
|
476
|
+
dragJSON: FlowNodeJSON;
|
|
477
|
+
}>) => boolean;
|
|
468
478
|
}
|
|
469
479
|
/**
|
|
470
480
|
* 监听节点的激活状态
|
|
471
481
|
*/
|
|
472
482
|
declare class FlowDragLayer extends Layer<FlowDragOptions> {
|
|
473
483
|
readonly document: FlowDocument;
|
|
474
|
-
readonly
|
|
484
|
+
readonly flowDragService: FlowDragService;
|
|
475
485
|
transforms: FlowNodeTransformData[];
|
|
476
486
|
protected editorStateConfig: EditorStateConfigEntity;
|
|
477
487
|
protected playgroundConfigEntity: PlaygroundConfigEntity;
|
|
@@ -479,7 +489,13 @@ declare class FlowDragLayer extends Layer<FlowDragOptions> {
|
|
|
479
489
|
protected flowRenderStateEntity: FlowRendererStateEntity;
|
|
480
490
|
protected selectConfigEntity: FlowSelectConfigEntity;
|
|
481
491
|
private initialPosition;
|
|
482
|
-
private
|
|
492
|
+
private disableDragScroll;
|
|
493
|
+
private dragJSON?;
|
|
494
|
+
private onCreateNode?;
|
|
495
|
+
dragOffset: {
|
|
496
|
+
x: number;
|
|
497
|
+
y: number;
|
|
498
|
+
};
|
|
483
499
|
get transitions(): FlowNodeTransitionData[];
|
|
484
500
|
readonly rendererRegistry: FlowRendererRegistry;
|
|
485
501
|
get dragStartEntity(): FlowNodeEntity | undefined;
|
|
@@ -493,7 +509,7 @@ declare class FlowDragLayer extends Layer<FlowDragOptions> {
|
|
|
493
509
|
setDraggingStatus(status: boolean): void;
|
|
494
510
|
dragEnable(e: MouseEvent): boolean;
|
|
495
511
|
handleMouseMove(event: MouseEvent): void;
|
|
496
|
-
handleMouseUp(): void
|
|
512
|
+
handleMouseUp(): Promise<void>;
|
|
497
513
|
protected _dragger: PlaygroundDrag<undefined>;
|
|
498
514
|
/**
|
|
499
515
|
* 开始拖拽事件
|
|
@@ -502,15 +518,14 @@ declare class FlowDragLayer extends Layer<FlowDragOptions> {
|
|
|
502
518
|
startDrag(e: {
|
|
503
519
|
clientX: number;
|
|
504
520
|
clientY: number;
|
|
505
|
-
}, { dragStartEntity: startEntityFromProps, dragEntities, }: {
|
|
506
|
-
dragStartEntity: FlowNodeEntity;
|
|
507
|
-
dragEntities?: FlowNodeEntity[];
|
|
508
|
-
}, options?: {
|
|
521
|
+
}, { dragStartEntity: startEntityFromProps, dragEntities, dragJSON, isBranch, onCreateNode, }: StartDragProps, options?: {
|
|
509
522
|
dragOffsetX?: number;
|
|
510
523
|
dragOffsetY?: number;
|
|
524
|
+
disableDragScroll?: boolean;
|
|
511
525
|
}): Promise<void>;
|
|
512
526
|
onReady(): void;
|
|
513
|
-
|
|
527
|
+
dispose(): void;
|
|
528
|
+
render(): React.ReactPortal;
|
|
514
529
|
}
|
|
515
530
|
|
|
516
531
|
interface FlowSelectorBoxOptions extends LayerOptions {
|
package/dist/index.js
CHANGED
|
@@ -389,7 +389,6 @@ var FlowDragEntity = class extends import_core2.ConfigEntity {
|
|
|
389
389
|
} else {
|
|
390
390
|
this.containerX -= SCROLL_DELTA;
|
|
391
391
|
}
|
|
392
|
-
this.setDomStyle();
|
|
393
392
|
}
|
|
394
393
|
}, SCROLL_INTERVAL);
|
|
395
394
|
this._scrollXInterval = { interval, origin };
|
|
@@ -418,7 +417,6 @@ var FlowDragEntity = class extends import_core2.ConfigEntity {
|
|
|
418
417
|
} else {
|
|
419
418
|
this.containerY -= SCROLL_DELTA;
|
|
420
419
|
}
|
|
421
|
-
this.setDomStyle();
|
|
422
420
|
}
|
|
423
421
|
}, SCROLL_INTERVAL);
|
|
424
422
|
this._scrollYInterval = { interval, origin };
|
|
@@ -433,15 +431,10 @@ var FlowDragEntity = class extends import_core2.ConfigEntity {
|
|
|
433
431
|
this._stopScrollX();
|
|
434
432
|
this._stopScrollY();
|
|
435
433
|
}
|
|
436
|
-
|
|
437
|
-
this.containerDom.style.left = `${this.containerX}px`;
|
|
438
|
-
this.containerDom.style.top = `${this.containerY}px`;
|
|
439
|
-
}
|
|
440
|
-
scrollDirection(e, containerDom, x, y) {
|
|
434
|
+
scrollDirection(e, x, y) {
|
|
441
435
|
const playgroundConfig = this.playgroundConfigEntity.config;
|
|
442
436
|
const currentScrollX = playgroundConfig.scrollX;
|
|
443
437
|
const currentScrollY = playgroundConfig.scrollY;
|
|
444
|
-
this.containerDom = containerDom;
|
|
445
438
|
this.containerX = x;
|
|
446
439
|
this.containerY = y;
|
|
447
440
|
const clientRect = this.playgroundConfigEntity.playgroundDomNode.getBoundingClientRect();
|
|
@@ -2325,6 +2318,7 @@ FlowScrollBarLayer = __decorateClass([
|
|
|
2325
2318
|
], FlowScrollBarLayer);
|
|
2326
2319
|
|
|
2327
2320
|
// src/layers/flow-drag-layer.tsx
|
|
2321
|
+
var import_react_dom2 = __toESM(require("react-dom"));
|
|
2328
2322
|
var import_react15 = __toESM(require("react"));
|
|
2329
2323
|
var import_inversify9 = require("inversify");
|
|
2330
2324
|
var import_utils22 = require("@flowgram.ai/utils");
|
|
@@ -2337,6 +2331,7 @@ var DEFAULT_DRAG_OFFSET_Y = 8;
|
|
|
2337
2331
|
var FlowDragLayer = class extends import_core15.Layer {
|
|
2338
2332
|
constructor() {
|
|
2339
2333
|
super(...arguments);
|
|
2334
|
+
this.disableDragScroll = false;
|
|
2340
2335
|
this.dragOffset = {
|
|
2341
2336
|
x: DEFAULT_DRAG_OFFSET_X,
|
|
2342
2337
|
y: DEFAULT_DRAG_OFFSET_Y
|
|
@@ -2377,19 +2372,20 @@ var FlowDragLayer = class extends import_core15.Layer {
|
|
|
2377
2372
|
return currentState === import_core15.EditorState.STATE_GRAB;
|
|
2378
2373
|
}
|
|
2379
2374
|
setDraggingStatus(status) {
|
|
2380
|
-
if (this.
|
|
2381
|
-
this.
|
|
2375
|
+
if (this.flowDragService.nodeDragIdsWithChildren.length) {
|
|
2376
|
+
this.flowDragService.nodeDragIdsWithChildren.forEach((_id) => {
|
|
2382
2377
|
const node = this.entityManager.getEntityById(_id);
|
|
2383
2378
|
const data = node?.getData(import_document18.FlowNodeRenderData);
|
|
2384
2379
|
data.dragging = status;
|
|
2385
2380
|
});
|
|
2386
2381
|
}
|
|
2382
|
+
this.flowRenderStateEntity.setDragging(status);
|
|
2387
2383
|
}
|
|
2388
2384
|
dragEnable(e) {
|
|
2389
2385
|
return Math.abs(e.clientX - this.initialPosition.x) > DRAG_OFFSET || Math.abs(e.clientY - this.initialPosition.y) > DRAG_OFFSET;
|
|
2390
2386
|
}
|
|
2391
2387
|
handleMouseMove(event) {
|
|
2392
|
-
if (this.dragStartEntity && this.dragEnable(event)) {
|
|
2388
|
+
if ((this.dragJSON || this.dragStartEntity) && this.dragEnable(event)) {
|
|
2393
2389
|
this.setDraggingStatus(true);
|
|
2394
2390
|
const scale = this.playgroundConfigEntity.finalScale;
|
|
2395
2391
|
if (this.containerRef.current) {
|
|
@@ -2397,7 +2393,7 @@ var FlowDragLayer = class extends import_core15.Layer {
|
|
|
2397
2393
|
const clientBounds = this.playgroundConfigEntity.getClientBounds();
|
|
2398
2394
|
const dragBlockX = event.clientX - (this.pipelineNode.offsetLeft || 0) - clientBounds.x - (dragNode.clientWidth - this.dragOffset.x) * scale;
|
|
2399
2395
|
const dragBlockY = event.clientY - (this.pipelineNode.offsetTop || 0) - clientBounds.y - (dragNode.clientHeight - this.dragOffset.y) * scale;
|
|
2400
|
-
const isBranch = this.
|
|
2396
|
+
const isBranch = this.flowDragService.isDragBranch;
|
|
2401
2397
|
const draggingRect = new import_utils22.Rectangle(
|
|
2402
2398
|
dragBlockX,
|
|
2403
2399
|
dragBlockY,
|
|
@@ -2417,7 +2413,7 @@ var FlowDragLayer = class extends import_core15.Layer {
|
|
|
2417
2413
|
side = labelOffsetType;
|
|
2418
2414
|
return hasCollision;
|
|
2419
2415
|
});
|
|
2420
|
-
if (collisionTransition && (isBranch ? this.
|
|
2416
|
+
if (collisionTransition && (isBranch ? this.flowDragService.isDroppableBranch(collisionTransition.entity, side) : this.flowDragService.isDroppableNode(collisionTransition.entity)) && (!this.options.canDrop || this.options.canDrop({
|
|
2421
2417
|
dragNodes: this.dragEntities,
|
|
2422
2418
|
dropNode: collisionTransition.entity,
|
|
2423
2419
|
isBranch
|
|
@@ -2429,37 +2425,45 @@ var FlowDragLayer = class extends import_core15.Layer {
|
|
|
2429
2425
|
this.flowRenderStateEntity.setDragLabelSide(side);
|
|
2430
2426
|
this.containerRef.current.style.visibility = "visible";
|
|
2431
2427
|
this.pipelineNode.parentElement.appendChild(this.draggingNodeMask);
|
|
2432
|
-
this.containerRef.current.style.left = `${dragBlockX}px`;
|
|
2433
|
-
this.containerRef.current.style.top = `${dragBlockY}px`;
|
|
2428
|
+
this.containerRef.current.style.left = `${dragBlockX + this.pipelineNode.offsetLeft + clientBounds.x + window.scrollX}px`;
|
|
2429
|
+
this.containerRef.current.style.top = `${dragBlockY + this.pipelineNode.offsetTop + clientBounds.y + window.scrollY}px`;
|
|
2434
2430
|
this.containerRef.current.style.transformOrigin = "top left";
|
|
2435
2431
|
this.containerRef.current.style.transform = `scale(${scale})`;
|
|
2436
|
-
this.
|
|
2437
|
-
event,
|
|
2438
|
-
|
|
2439
|
-
dragBlockX,
|
|
2440
|
-
dragBlockY
|
|
2441
|
-
);
|
|
2432
|
+
if (!this.disableDragScroll) {
|
|
2433
|
+
this.flowDragConfigEntity.scrollDirection(event, dragBlockX, dragBlockY);
|
|
2434
|
+
}
|
|
2442
2435
|
}
|
|
2443
2436
|
}
|
|
2444
2437
|
}
|
|
2445
|
-
handleMouseUp() {
|
|
2438
|
+
async handleMouseUp() {
|
|
2446
2439
|
this.setDraggingStatus(false);
|
|
2447
|
-
if (this.dragStartEntity) {
|
|
2448
|
-
const activatedNodeId = this.
|
|
2440
|
+
if (this.dragStartEntity || this.dragJSON) {
|
|
2441
|
+
const activatedNodeId = this.flowDragService.dropNodeId;
|
|
2449
2442
|
if (activatedNodeId) {
|
|
2450
|
-
if (this.
|
|
2451
|
-
this.
|
|
2443
|
+
if (this.flowDragService.isDragBranch) {
|
|
2444
|
+
if (this.dragJSON) {
|
|
2445
|
+
await this.flowDragService.dropCreateNode(this.dragJSON, this.onCreateNode);
|
|
2446
|
+
} else {
|
|
2447
|
+
this.flowDragService.dropBranch();
|
|
2448
|
+
}
|
|
2452
2449
|
} else {
|
|
2453
|
-
this.
|
|
2450
|
+
if (this.dragJSON) {
|
|
2451
|
+
await this.flowDragService.dropCreateNode(this.dragJSON, this.onCreateNode);
|
|
2452
|
+
} else {
|
|
2453
|
+
this.flowDragService.dropNode();
|
|
2454
|
+
}
|
|
2454
2455
|
this.selectConfigEntity.clearSelectedNodes();
|
|
2455
2456
|
}
|
|
2456
2457
|
}
|
|
2457
2458
|
this.flowRenderStateEntity.setNodeDroppingId("");
|
|
2458
2459
|
this.flowRenderStateEntity.setDragLabelSide();
|
|
2460
|
+
this.flowRenderStateEntity.setIsBranch(false);
|
|
2459
2461
|
this.dragStartEntity = void 0;
|
|
2460
2462
|
this.dragEntities = [];
|
|
2461
2463
|
this.flowDragConfigEntity.stopAllScroll();
|
|
2462
2464
|
}
|
|
2465
|
+
this.disableDragScroll = false;
|
|
2466
|
+
this.dragJSON = void 0;
|
|
2463
2467
|
if (this.containerRef.current) {
|
|
2464
2468
|
this.containerRef.current.style.visibility = "hidden";
|
|
2465
2469
|
if (this.pipelineNode.parentElement.contains(this.draggingNodeMask)) {
|
|
@@ -2473,17 +2477,25 @@ var FlowDragLayer = class extends import_core15.Layer {
|
|
|
2473
2477
|
*/
|
|
2474
2478
|
async startDrag(e, {
|
|
2475
2479
|
dragStartEntity: startEntityFromProps,
|
|
2476
|
-
dragEntities
|
|
2480
|
+
dragEntities,
|
|
2481
|
+
dragJSON,
|
|
2482
|
+
isBranch,
|
|
2483
|
+
onCreateNode
|
|
2477
2484
|
}, options) {
|
|
2478
2485
|
if (this.isGrab() || this.config.disabled || this.config.readonly) {
|
|
2479
2486
|
return;
|
|
2480
2487
|
}
|
|
2488
|
+
this.disableDragScroll = Boolean(options?.disableDragScroll);
|
|
2489
|
+
this.dragJSON = dragJSON;
|
|
2490
|
+
this.onCreateNode = onCreateNode;
|
|
2491
|
+
this.flowRenderStateEntity.setIsBranch(Boolean(isBranch));
|
|
2481
2492
|
this.dragOffset.x = options?.dragOffsetX || DEFAULT_DRAG_OFFSET_X;
|
|
2482
2493
|
this.dragOffset.y = options?.dragOffsetY || DEFAULT_DRAG_OFFSET_Y;
|
|
2483
|
-
const
|
|
2484
|
-
const
|
|
2494
|
+
const type = startEntityFromProps?.flowNodeType || dragJSON?.type;
|
|
2495
|
+
const isIcon = type === import_document18.FlowNodeBaseType.BLOCK_ICON;
|
|
2496
|
+
const isOrderIcon = type === import_document18.FlowNodeBaseType.BLOCK_ORDER_ICON;
|
|
2485
2497
|
const dragStartEntity = isIcon || isOrderIcon ? startEntityFromProps.parent : startEntityFromProps;
|
|
2486
|
-
if (!dragStartEntity.getData(import_document18.FlowNodeRenderData).draggable) {
|
|
2498
|
+
if (dragStartEntity && !dragStartEntity.getData(import_document18.FlowNodeRenderData).draggable) {
|
|
2487
2499
|
return;
|
|
2488
2500
|
}
|
|
2489
2501
|
this.initialPosition = {
|
|
@@ -2491,7 +2503,7 @@ var FlowDragLayer = class extends import_core15.Layer {
|
|
|
2491
2503
|
y: e.clientY
|
|
2492
2504
|
};
|
|
2493
2505
|
this.dragStartEntity = dragStartEntity;
|
|
2494
|
-
this.dragEntities = dragEntities || [this.dragStartEntity];
|
|
2506
|
+
this.dragEntities = dragEntities || (this.dragStartEntity ? [this.dragStartEntity] : []);
|
|
2495
2507
|
return this._dragger.start(e.clientX, e.clientY);
|
|
2496
2508
|
}
|
|
2497
2509
|
onReady() {
|
|
@@ -2503,19 +2515,33 @@ var FlowDragLayer = class extends import_core15.Layer {
|
|
|
2503
2515
|
this.draggingNodeMask.style.cursor = "pointer";
|
|
2504
2516
|
this.dragNodeComp = this.rendererRegistry.getRendererComponent("drag-node" /* DRAG_NODE */);
|
|
2505
2517
|
if (this.options.onDrop) {
|
|
2506
|
-
this.toDispose.push(this.
|
|
2518
|
+
this.toDispose.push(this.flowDragService.onDrop(this.options.onDrop));
|
|
2507
2519
|
}
|
|
2508
2520
|
}
|
|
2521
|
+
dispose() {
|
|
2522
|
+
this._dragger.dispose();
|
|
2523
|
+
super.dispose();
|
|
2524
|
+
}
|
|
2509
2525
|
render() {
|
|
2510
2526
|
const DragComp = this.dragNodeComp.renderer;
|
|
2511
|
-
return
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2527
|
+
return import_react_dom2.default.createPortal(
|
|
2528
|
+
/* @__PURE__ */ import_react15.default.createElement(
|
|
2529
|
+
"div",
|
|
2530
|
+
{
|
|
2531
|
+
ref: this.containerRef,
|
|
2532
|
+
style: { position: "absolute", zIndex: 99999, visibility: "hidden" },
|
|
2533
|
+
onMouseEnter: (e) => e.stopPropagation()
|
|
2534
|
+
},
|
|
2535
|
+
/* @__PURE__ */ import_react15.default.createElement(
|
|
2536
|
+
DragComp,
|
|
2537
|
+
{
|
|
2538
|
+
dragJSON: this.dragJSON,
|
|
2539
|
+
dragStart: this.dragStartEntity,
|
|
2540
|
+
dragNodes: this.dragEntities
|
|
2541
|
+
}
|
|
2542
|
+
)
|
|
2543
|
+
),
|
|
2544
|
+
document.body
|
|
2519
2545
|
);
|
|
2520
2546
|
}
|
|
2521
2547
|
};
|
|
@@ -2524,7 +2550,7 @@ __decorateClass([
|
|
|
2524
2550
|
], FlowDragLayer.prototype, "document", 2);
|
|
2525
2551
|
__decorateClass([
|
|
2526
2552
|
(0, import_inversify9.inject)(import_document18.FlowDragService)
|
|
2527
|
-
], FlowDragLayer.prototype, "
|
|
2553
|
+
], FlowDragLayer.prototype, "flowDragService", 2);
|
|
2528
2554
|
__decorateClass([
|
|
2529
2555
|
(0, import_core15.observeEntityDatas)(import_document18.FlowNodeEntity, import_document18.FlowNodeTransformData)
|
|
2530
2556
|
], FlowDragLayer.prototype, "transforms", 2);
|