@flowgram.ai/renderer 0.5.2 → 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 +39 -31
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +39 -31
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/esm/index.js
CHANGED
|
@@ -339,7 +339,6 @@ var FlowDragEntity = class extends ConfigEntity {
|
|
|
339
339
|
} else {
|
|
340
340
|
this.containerX -= SCROLL_DELTA;
|
|
341
341
|
}
|
|
342
|
-
this.setDomStyle();
|
|
343
342
|
}
|
|
344
343
|
}, SCROLL_INTERVAL);
|
|
345
344
|
this._scrollXInterval = { interval, origin };
|
|
@@ -368,7 +367,6 @@ var FlowDragEntity = class extends ConfigEntity {
|
|
|
368
367
|
} else {
|
|
369
368
|
this.containerY -= SCROLL_DELTA;
|
|
370
369
|
}
|
|
371
|
-
this.setDomStyle();
|
|
372
370
|
}
|
|
373
371
|
}, SCROLL_INTERVAL);
|
|
374
372
|
this._scrollYInterval = { interval, origin };
|
|
@@ -383,15 +381,10 @@ var FlowDragEntity = class extends ConfigEntity {
|
|
|
383
381
|
this._stopScrollX();
|
|
384
382
|
this._stopScrollY();
|
|
385
383
|
}
|
|
386
|
-
|
|
387
|
-
this.containerDom.style.left = `${this.containerX}px`;
|
|
388
|
-
this.containerDom.style.top = `${this.containerY}px`;
|
|
389
|
-
}
|
|
390
|
-
scrollDirection(e, containerDom, x, y) {
|
|
384
|
+
scrollDirection(e, x, y) {
|
|
391
385
|
const playgroundConfig = this.playgroundConfigEntity.config;
|
|
392
386
|
const currentScrollX = playgroundConfig.scrollX;
|
|
393
387
|
const currentScrollY = playgroundConfig.scrollY;
|
|
394
|
-
this.containerDom = containerDom;
|
|
395
388
|
this.containerX = x;
|
|
396
389
|
this.containerY = y;
|
|
397
390
|
const clientRect = this.playgroundConfigEntity.playgroundDomNode.getBoundingClientRect();
|
|
@@ -2332,6 +2325,7 @@ FlowScrollBarLayer = __decorateClass([
|
|
|
2332
2325
|
], FlowScrollBarLayer);
|
|
2333
2326
|
|
|
2334
2327
|
// src/layers/flow-drag-layer.tsx
|
|
2328
|
+
import ReactDOM2 from "react-dom";
|
|
2335
2329
|
import React15 from "react";
|
|
2336
2330
|
import { inject as inject8, injectable as injectable9 } from "inversify";
|
|
2337
2331
|
import { Rectangle as Rectangle8 } from "@flowgram.ai/utils";
|
|
@@ -2454,17 +2448,12 @@ var FlowDragLayer = class extends Layer7 {
|
|
|
2454
2448
|
this.flowRenderStateEntity.setDragLabelSide(side);
|
|
2455
2449
|
this.containerRef.current.style.visibility = "visible";
|
|
2456
2450
|
this.pipelineNode.parentElement.appendChild(this.draggingNodeMask);
|
|
2457
|
-
this.containerRef.current.style.left = `${dragBlockX}px`;
|
|
2458
|
-
this.containerRef.current.style.top = `${dragBlockY}px`;
|
|
2451
|
+
this.containerRef.current.style.left = `${dragBlockX + this.pipelineNode.offsetLeft + clientBounds.x + window.scrollX}px`;
|
|
2452
|
+
this.containerRef.current.style.top = `${dragBlockY + this.pipelineNode.offsetTop + clientBounds.y + window.scrollY}px`;
|
|
2459
2453
|
this.containerRef.current.style.transformOrigin = "top left";
|
|
2460
2454
|
this.containerRef.current.style.transform = `scale(${scale})`;
|
|
2461
2455
|
if (!this.disableDragScroll) {
|
|
2462
|
-
this.flowDragConfigEntity.scrollDirection(
|
|
2463
|
-
event,
|
|
2464
|
-
this.containerRef.current,
|
|
2465
|
-
dragBlockX,
|
|
2466
|
-
dragBlockY
|
|
2467
|
-
);
|
|
2456
|
+
this.flowDragConfigEntity.scrollDirection(event, dragBlockX, dragBlockY);
|
|
2468
2457
|
}
|
|
2469
2458
|
}
|
|
2470
2459
|
}
|
|
@@ -2475,7 +2464,11 @@ var FlowDragLayer = class extends Layer7 {
|
|
|
2475
2464
|
const activatedNodeId = this.flowDragService.dropNodeId;
|
|
2476
2465
|
if (activatedNodeId) {
|
|
2477
2466
|
if (this.flowDragService.isDragBranch) {
|
|
2478
|
-
this.
|
|
2467
|
+
if (this.dragJSON) {
|
|
2468
|
+
await this.flowDragService.dropCreateNode(this.dragJSON, this.onCreateNode);
|
|
2469
|
+
} else {
|
|
2470
|
+
this.flowDragService.dropBranch();
|
|
2471
|
+
}
|
|
2479
2472
|
} else {
|
|
2480
2473
|
if (this.dragJSON) {
|
|
2481
2474
|
await this.flowDragService.dropCreateNode(this.dragJSON, this.onCreateNode);
|
|
@@ -2487,6 +2480,7 @@ var FlowDragLayer = class extends Layer7 {
|
|
|
2487
2480
|
}
|
|
2488
2481
|
this.flowRenderStateEntity.setNodeDroppingId("");
|
|
2489
2482
|
this.flowRenderStateEntity.setDragLabelSide();
|
|
2483
|
+
this.flowRenderStateEntity.setIsBranch(false);
|
|
2490
2484
|
this.dragStartEntity = void 0;
|
|
2491
2485
|
this.dragEntities = [];
|
|
2492
2486
|
this.flowDragConfigEntity.stopAllScroll();
|
|
@@ -2504,13 +2498,20 @@ var FlowDragLayer = class extends Layer7 {
|
|
|
2504
2498
|
* 开始拖拽事件
|
|
2505
2499
|
* @param e
|
|
2506
2500
|
*/
|
|
2507
|
-
async startDrag(e, {
|
|
2501
|
+
async startDrag(e, {
|
|
2502
|
+
dragStartEntity: startEntityFromProps,
|
|
2503
|
+
dragEntities,
|
|
2504
|
+
dragJSON,
|
|
2505
|
+
isBranch,
|
|
2506
|
+
onCreateNode
|
|
2507
|
+
}, options) {
|
|
2508
2508
|
if (this.isGrab() || this.config.disabled || this.config.readonly) {
|
|
2509
2509
|
return;
|
|
2510
2510
|
}
|
|
2511
2511
|
this.disableDragScroll = Boolean(options?.disableDragScroll);
|
|
2512
2512
|
this.dragJSON = dragJSON;
|
|
2513
2513
|
this.onCreateNode = onCreateNode;
|
|
2514
|
+
this.flowRenderStateEntity.setIsBranch(Boolean(isBranch));
|
|
2514
2515
|
this.dragOffset.x = options?.dragOffsetX || DEFAULT_DRAG_OFFSET_X;
|
|
2515
2516
|
this.dragOffset.y = options?.dragOffsetY || DEFAULT_DRAG_OFFSET_Y;
|
|
2516
2517
|
const type = startEntityFromProps?.flowNodeType || dragJSON?.type;
|
|
@@ -2540,23 +2541,30 @@ var FlowDragLayer = class extends Layer7 {
|
|
|
2540
2541
|
this.toDispose.push(this.flowDragService.onDrop(this.options.onDrop));
|
|
2541
2542
|
}
|
|
2542
2543
|
}
|
|
2544
|
+
dispose() {
|
|
2545
|
+
this._dragger.dispose();
|
|
2546
|
+
super.dispose();
|
|
2547
|
+
}
|
|
2543
2548
|
render() {
|
|
2544
2549
|
const DragComp = this.dragNodeComp.renderer;
|
|
2545
|
-
return
|
|
2546
|
-
"div",
|
|
2547
|
-
{
|
|
2548
|
-
ref: this.containerRef,
|
|
2549
|
-
style: { position: "absolute", zIndex: 99999, visibility: "hidden" },
|
|
2550
|
-
onMouseEnter: (e) => e.stopPropagation()
|
|
2551
|
-
},
|
|
2550
|
+
return ReactDOM2.createPortal(
|
|
2552
2551
|
/* @__PURE__ */ React15.createElement(
|
|
2553
|
-
|
|
2552
|
+
"div",
|
|
2554
2553
|
{
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
}
|
|
2559
|
-
|
|
2554
|
+
ref: this.containerRef,
|
|
2555
|
+
style: { position: "absolute", zIndex: 99999, visibility: "hidden" },
|
|
2556
|
+
onMouseEnter: (e) => e.stopPropagation()
|
|
2557
|
+
},
|
|
2558
|
+
/* @__PURE__ */ React15.createElement(
|
|
2559
|
+
DragComp,
|
|
2560
|
+
{
|
|
2561
|
+
dragJSON: this.dragJSON,
|
|
2562
|
+
dragStart: this.dragStartEntity,
|
|
2563
|
+
dragNodes: this.dragEntities
|
|
2564
|
+
}
|
|
2565
|
+
)
|
|
2566
|
+
),
|
|
2567
|
+
document.body
|
|
2560
2568
|
);
|
|
2561
2569
|
}
|
|
2562
2570
|
};
|