@flowgram.ai/renderer 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +46 -28
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +23 -10
- package/dist/index.d.ts +23 -10
- package/dist/index.js +46 -28
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/esm/index.js
CHANGED
|
@@ -2360,6 +2360,7 @@ var DEFAULT_DRAG_OFFSET_Y = 8;
|
|
|
2360
2360
|
var FlowDragLayer = class extends Layer7 {
|
|
2361
2361
|
constructor() {
|
|
2362
2362
|
super(...arguments);
|
|
2363
|
+
this.disableDragScroll = false;
|
|
2363
2364
|
this.dragOffset = {
|
|
2364
2365
|
x: DEFAULT_DRAG_OFFSET_X,
|
|
2365
2366
|
y: DEFAULT_DRAG_OFFSET_Y
|
|
@@ -2400,19 +2401,20 @@ var FlowDragLayer = class extends Layer7 {
|
|
|
2400
2401
|
return currentState === EditorState.STATE_GRAB;
|
|
2401
2402
|
}
|
|
2402
2403
|
setDraggingStatus(status) {
|
|
2403
|
-
if (this.
|
|
2404
|
-
this.
|
|
2404
|
+
if (this.flowDragService.nodeDragIdsWithChildren.length) {
|
|
2405
|
+
this.flowDragService.nodeDragIdsWithChildren.forEach((_id) => {
|
|
2405
2406
|
const node = this.entityManager.getEntityById(_id);
|
|
2406
2407
|
const data = node?.getData(FlowNodeRenderData5);
|
|
2407
2408
|
data.dragging = status;
|
|
2408
2409
|
});
|
|
2409
2410
|
}
|
|
2411
|
+
this.flowRenderStateEntity.setDragging(status);
|
|
2410
2412
|
}
|
|
2411
2413
|
dragEnable(e) {
|
|
2412
2414
|
return Math.abs(e.clientX - this.initialPosition.x) > DRAG_OFFSET || Math.abs(e.clientY - this.initialPosition.y) > DRAG_OFFSET;
|
|
2413
2415
|
}
|
|
2414
2416
|
handleMouseMove(event) {
|
|
2415
|
-
if (this.dragStartEntity && this.dragEnable(event)) {
|
|
2417
|
+
if ((this.dragJSON || this.dragStartEntity) && this.dragEnable(event)) {
|
|
2416
2418
|
this.setDraggingStatus(true);
|
|
2417
2419
|
const scale = this.playgroundConfigEntity.finalScale;
|
|
2418
2420
|
if (this.containerRef.current) {
|
|
@@ -2420,7 +2422,7 @@ var FlowDragLayer = class extends Layer7 {
|
|
|
2420
2422
|
const clientBounds = this.playgroundConfigEntity.getClientBounds();
|
|
2421
2423
|
const dragBlockX = event.clientX - (this.pipelineNode.offsetLeft || 0) - clientBounds.x - (dragNode.clientWidth - this.dragOffset.x) * scale;
|
|
2422
2424
|
const dragBlockY = event.clientY - (this.pipelineNode.offsetTop || 0) - clientBounds.y - (dragNode.clientHeight - this.dragOffset.y) * scale;
|
|
2423
|
-
const isBranch = this.
|
|
2425
|
+
const isBranch = this.flowDragService.isDragBranch;
|
|
2424
2426
|
const draggingRect = new Rectangle8(
|
|
2425
2427
|
dragBlockX,
|
|
2426
2428
|
dragBlockY,
|
|
@@ -2440,7 +2442,7 @@ var FlowDragLayer = class extends Layer7 {
|
|
|
2440
2442
|
side = labelOffsetType;
|
|
2441
2443
|
return hasCollision;
|
|
2442
2444
|
});
|
|
2443
|
-
if (collisionTransition && (isBranch ? this.
|
|
2445
|
+
if (collisionTransition && (isBranch ? this.flowDragService.isDroppableBranch(collisionTransition.entity, side) : this.flowDragService.isDroppableNode(collisionTransition.entity)) && (!this.options.canDrop || this.options.canDrop({
|
|
2444
2446
|
dragNodes: this.dragEntities,
|
|
2445
2447
|
dropNode: collisionTransition.entity,
|
|
2446
2448
|
isBranch
|
|
@@ -2456,24 +2458,30 @@ var FlowDragLayer = class extends Layer7 {
|
|
|
2456
2458
|
this.containerRef.current.style.top = `${dragBlockY}px`;
|
|
2457
2459
|
this.containerRef.current.style.transformOrigin = "top left";
|
|
2458
2460
|
this.containerRef.current.style.transform = `scale(${scale})`;
|
|
2459
|
-
this.
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2461
|
+
if (!this.disableDragScroll) {
|
|
2462
|
+
this.flowDragConfigEntity.scrollDirection(
|
|
2463
|
+
event,
|
|
2464
|
+
this.containerRef.current,
|
|
2465
|
+
dragBlockX,
|
|
2466
|
+
dragBlockY
|
|
2467
|
+
);
|
|
2468
|
+
}
|
|
2465
2469
|
}
|
|
2466
2470
|
}
|
|
2467
2471
|
}
|
|
2468
|
-
handleMouseUp() {
|
|
2472
|
+
async handleMouseUp() {
|
|
2469
2473
|
this.setDraggingStatus(false);
|
|
2470
|
-
if (this.dragStartEntity) {
|
|
2471
|
-
const activatedNodeId = this.
|
|
2474
|
+
if (this.dragStartEntity || this.dragJSON) {
|
|
2475
|
+
const activatedNodeId = this.flowDragService.dropNodeId;
|
|
2472
2476
|
if (activatedNodeId) {
|
|
2473
|
-
if (this.
|
|
2474
|
-
this.
|
|
2477
|
+
if (this.flowDragService.isDragBranch) {
|
|
2478
|
+
this.flowDragService.dropBranch();
|
|
2475
2479
|
} else {
|
|
2476
|
-
this.
|
|
2480
|
+
if (this.dragJSON) {
|
|
2481
|
+
await this.flowDragService.dropCreateNode(this.dragJSON, this.onCreateNode);
|
|
2482
|
+
} else {
|
|
2483
|
+
this.flowDragService.dropNode();
|
|
2484
|
+
}
|
|
2477
2485
|
this.selectConfigEntity.clearSelectedNodes();
|
|
2478
2486
|
}
|
|
2479
2487
|
}
|
|
@@ -2483,6 +2491,8 @@ var FlowDragLayer = class extends Layer7 {
|
|
|
2483
2491
|
this.dragEntities = [];
|
|
2484
2492
|
this.flowDragConfigEntity.stopAllScroll();
|
|
2485
2493
|
}
|
|
2494
|
+
this.disableDragScroll = false;
|
|
2495
|
+
this.dragJSON = void 0;
|
|
2486
2496
|
if (this.containerRef.current) {
|
|
2487
2497
|
this.containerRef.current.style.visibility = "hidden";
|
|
2488
2498
|
if (this.pipelineNode.parentElement.contains(this.draggingNodeMask)) {
|
|
@@ -2494,19 +2504,20 @@ var FlowDragLayer = class extends Layer7 {
|
|
|
2494
2504
|
* 开始拖拽事件
|
|
2495
2505
|
* @param e
|
|
2496
2506
|
*/
|
|
2497
|
-
async startDrag(e, {
|
|
2498
|
-
dragStartEntity: startEntityFromProps,
|
|
2499
|
-
dragEntities
|
|
2500
|
-
}, options) {
|
|
2507
|
+
async startDrag(e, { dragStartEntity: startEntityFromProps, dragEntities, dragJSON, onCreateNode }, options) {
|
|
2501
2508
|
if (this.isGrab() || this.config.disabled || this.config.readonly) {
|
|
2502
2509
|
return;
|
|
2503
2510
|
}
|
|
2511
|
+
this.disableDragScroll = Boolean(options?.disableDragScroll);
|
|
2512
|
+
this.dragJSON = dragJSON;
|
|
2513
|
+
this.onCreateNode = onCreateNode;
|
|
2504
2514
|
this.dragOffset.x = options?.dragOffsetX || DEFAULT_DRAG_OFFSET_X;
|
|
2505
2515
|
this.dragOffset.y = options?.dragOffsetY || DEFAULT_DRAG_OFFSET_Y;
|
|
2506
|
-
const
|
|
2507
|
-
const
|
|
2516
|
+
const type = startEntityFromProps?.flowNodeType || dragJSON?.type;
|
|
2517
|
+
const isIcon = type === FlowNodeBaseType.BLOCK_ICON;
|
|
2518
|
+
const isOrderIcon = type === FlowNodeBaseType.BLOCK_ORDER_ICON;
|
|
2508
2519
|
const dragStartEntity = isIcon || isOrderIcon ? startEntityFromProps.parent : startEntityFromProps;
|
|
2509
|
-
if (!dragStartEntity.getData(FlowNodeRenderData5).draggable) {
|
|
2520
|
+
if (dragStartEntity && !dragStartEntity.getData(FlowNodeRenderData5).draggable) {
|
|
2510
2521
|
return;
|
|
2511
2522
|
}
|
|
2512
2523
|
this.initialPosition = {
|
|
@@ -2514,7 +2525,7 @@ var FlowDragLayer = class extends Layer7 {
|
|
|
2514
2525
|
y: e.clientY
|
|
2515
2526
|
};
|
|
2516
2527
|
this.dragStartEntity = dragStartEntity;
|
|
2517
|
-
this.dragEntities = dragEntities || [this.dragStartEntity];
|
|
2528
|
+
this.dragEntities = dragEntities || (this.dragStartEntity ? [this.dragStartEntity] : []);
|
|
2518
2529
|
return this._dragger.start(e.clientX, e.clientY);
|
|
2519
2530
|
}
|
|
2520
2531
|
onReady() {
|
|
@@ -2526,7 +2537,7 @@ var FlowDragLayer = class extends Layer7 {
|
|
|
2526
2537
|
this.draggingNodeMask.style.cursor = "pointer";
|
|
2527
2538
|
this.dragNodeComp = this.rendererRegistry.getRendererComponent("drag-node" /* DRAG_NODE */);
|
|
2528
2539
|
if (this.options.onDrop) {
|
|
2529
|
-
this.toDispose.push(this.
|
|
2540
|
+
this.toDispose.push(this.flowDragService.onDrop(this.options.onDrop));
|
|
2530
2541
|
}
|
|
2531
2542
|
}
|
|
2532
2543
|
render() {
|
|
@@ -2538,7 +2549,14 @@ var FlowDragLayer = class extends Layer7 {
|
|
|
2538
2549
|
style: { position: "absolute", zIndex: 99999, visibility: "hidden" },
|
|
2539
2550
|
onMouseEnter: (e) => e.stopPropagation()
|
|
2540
2551
|
},
|
|
2541
|
-
/* @__PURE__ */ React15.createElement(
|
|
2552
|
+
/* @__PURE__ */ React15.createElement(
|
|
2553
|
+
DragComp,
|
|
2554
|
+
{
|
|
2555
|
+
dragJSON: this.dragJSON,
|
|
2556
|
+
dragStart: this.dragStartEntity,
|
|
2557
|
+
dragNodes: this.dragEntities
|
|
2558
|
+
}
|
|
2559
|
+
)
|
|
2542
2560
|
);
|
|
2543
2561
|
}
|
|
2544
2562
|
};
|
|
@@ -2547,7 +2565,7 @@ __decorateClass([
|
|
|
2547
2565
|
], FlowDragLayer.prototype, "document", 2);
|
|
2548
2566
|
__decorateClass([
|
|
2549
2567
|
inject8(FlowDragService5)
|
|
2550
|
-
], FlowDragLayer.prototype, "
|
|
2568
|
+
], FlowDragLayer.prototype, "flowDragService", 2);
|
|
2551
2569
|
__decorateClass([
|
|
2552
2570
|
observeEntityDatas6(FlowNodeEntity6, FlowNodeTransformData7)
|
|
2553
2571
|
], FlowDragLayer.prototype, "transforms", 2);
|