@flowgram.ai/free-layout-core 0.1.0-alpha.13 → 0.1.0-alpha.15
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/{chunk-E7ZUQ7LV.js → chunk-5BT3ZR4D.js} +2 -1
- package/dist/esm/chunk-5BT3ZR4D.js.map +1 -0
- package/dist/esm/index.js +51 -80
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/typings/index.js +1 -1
- package/dist/esm/typings/workflow-line.js +1 -1
- package/dist/index.d.mts +15 -28
- package/dist/index.d.ts +15 -28
- package/dist/index.js +52 -80
- package/dist/index.js.map +1 -1
- package/dist/typings/index.d.mts +1 -1
- package/dist/typings/index.d.ts +1 -1
- package/dist/typings/index.js +1 -0
- package/dist/typings/index.js.map +1 -1
- package/dist/typings/workflow-drag.d.mts +1 -1
- package/dist/typings/workflow-drag.d.ts +1 -1
- package/dist/typings/workflow-json.d.mts +1 -1
- package/dist/typings/workflow-json.d.ts +1 -1
- package/dist/typings/workflow-line.d.mts +1 -1
- package/dist/typings/workflow-line.d.ts +1 -1
- package/dist/typings/workflow-line.js +1 -0
- package/dist/typings/workflow-line.js.map +1 -1
- package/dist/typings/workflow-node.d.mts +1 -1
- package/dist/typings/workflow-node.d.ts +1 -1
- package/dist/typings/workflow-registry.d.mts +1 -1
- package/dist/typings/workflow-registry.d.ts +1 -1
- package/dist/{workflow-line-entity-I_VrhJ_t.d.ts → workflow-line-entity-DcecHiNc.d.ts} +34 -10
- package/dist/{workflow-line-entity-DSC3qPV1.d.mts → workflow-line-entity-IbhMSbBs.d.mts} +34 -10
- package/package.json +9 -9
- package/dist/esm/chunk-E7ZUQ7LV.js.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -2,8 +2,8 @@ import { PlaygroundConfigEntity, CommandService, PlaygroundDragEvent, EntityData
|
|
|
2
2
|
export { bindConfigEntity, useConfigEntity, useEntities, useEntityDataFromContext, useEntityFromContext, useListenEvents, usePlayground, usePlaygroundContainer, usePlaygroundContext, usePlaygroundLatest, useRefresh, useService } from '@flowgram.ai/core';
|
|
3
3
|
import { NodeFormProps } from '@flowgram.ai/node';
|
|
4
4
|
import { FlowOperationBaseService, FlowNodeType, FlowOperationBaseServiceImpl, FlowNodeEntityOrId, FlowNodeEntity } from '@flowgram.ai/document';
|
|
5
|
-
import { W as WorkflowHoverService, a as WorkflowDocument, b as WorkflowLinesManager, c as WorkflowSelectService, d as WorkflowDocumentOptions, L as LineEventProps, N as NodesDragEvent, e as WorkflowNodeJSON, f as WorkflowPortEntity, g as WorkflowLineEntity, O as OnDragLineEnd, h as WorkflowJSON, i as
|
|
6
|
-
export {
|
|
5
|
+
import { W as WorkflowHoverService, a as WorkflowDocument, b as WorkflowLinesManager, c as WorkflowSelectService, d as WorkflowDocumentOptions, L as LineEventProps, N as NodesDragEvent, e as WorkflowNodeJSON, f as WorkflowPortEntity, g as WorkflowLineEntity, O as OnDragLineEnd, h as WorkflowJSON, i as LineCenterPoint, j as WorkflowPorts, k as WorkflowPortType, l as LinePoint, m as WorkflowPort, n as LineRenderType, o as WorkflowLineRenderContribution, p as LinePosition } from './workflow-line-entity-IbhMSbBs.mjs';
|
|
6
|
+
export { R as HoverPosition, F as LINE_HOVER_DISTANCE, y as LineColor, z as LineColors, x as LinePointLocation, w as LineType, C as NodesDragEndEvent, B as NodesDragStartEvent, D as NodesDraggingEvent, P as POINT_RADIUS, K as PORT_SIZE, r as WORKFLOW_LINE_ENTITY, S as WorkfloEntityHoverable, u as WorkflowContentChangeEvent, t as WorkflowContentChangeType, U as WorkflowDocumentOptionsDefault, T as WorkflowDocumentProvider, Q as WorkflowEntityHoverable, H as WorkflowLineEntityOpts, I as WorkflowLineInfo, G as WorkflowLinePortInfo, A as WorkflowLineRenderContributionFactory, J as WorkflowLineUIState, v as WorkflowNodeMeta, M as WorkflowPortEntityOpts, s as domReactToBounds, q as getPortEntityId, E as onDragLineEndParams } from './workflow-line-entity-IbhMSbBs.mjs';
|
|
7
7
|
import { W as WorkflowNodeEntity } from './workflow-sub-canvas-IQzlYvPD.mjs';
|
|
8
8
|
export { a as WorkflowSubCanvas } from './workflow-sub-canvas-IQzlYvPD.mjs';
|
|
9
9
|
import * as _flowgram_ai_utils from '@flowgram.ai/utils';
|
|
@@ -330,6 +330,13 @@ declare function usePlaygroundReadonlyState(listenChange?: boolean): boolean;
|
|
|
330
330
|
|
|
331
331
|
declare const buildGroupJSON: (json: WorkflowJSON) => WorkflowJSON;
|
|
332
332
|
|
|
333
|
+
/**
|
|
334
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
335
|
+
* SPDX-License-Identifier: MIT
|
|
336
|
+
*/
|
|
337
|
+
|
|
338
|
+
declare function getLineCenter(from: IPoint, to: IPoint, bbox: Rectangle, linePadding: number): LineCenterPoint;
|
|
339
|
+
|
|
333
340
|
/**
|
|
334
341
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
335
342
|
* SPDX-License-Identifier: MIT
|
|
@@ -487,6 +494,7 @@ declare class WorkflowNodeLinesData extends EntityData<WorkflowNodeLines> {
|
|
|
487
494
|
*/
|
|
488
495
|
get outputLines(): WorkflowLineEntity[];
|
|
489
496
|
get allLines(): WorkflowLineEntity[];
|
|
497
|
+
get availableLines(): WorkflowLineEntity[];
|
|
490
498
|
/**
|
|
491
499
|
* 输入节点
|
|
492
500
|
*/
|
|
@@ -533,6 +541,10 @@ declare class WorkflowLineRenderData extends EntityData<WorkflowLineRenderDataSc
|
|
|
533
541
|
*/
|
|
534
542
|
update(): void;
|
|
535
543
|
private get lineType();
|
|
544
|
+
/**
|
|
545
|
+
* 获取 center 位置
|
|
546
|
+
*/
|
|
547
|
+
get center(): LineCenterPoint;
|
|
536
548
|
/**
|
|
537
549
|
* 更新版本
|
|
538
550
|
* WARNING: 这个方法,必须在 requestAnimationFrame / useLayoutEffect 中调用,否则会引起浏览器强制重排
|
|
@@ -550,29 +562,4 @@ declare class WorkflowLineRenderData extends EntityData<WorkflowLineRenderDataSc
|
|
|
550
562
|
|
|
551
563
|
declare const WorkflowDocumentContainerModule: ContainerModule;
|
|
552
564
|
|
|
553
|
-
|
|
554
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
555
|
-
* SPDX-License-Identifier: MIT
|
|
556
|
-
*/
|
|
557
|
-
|
|
558
|
-
interface StraightData {
|
|
559
|
-
points: IPoint[];
|
|
560
|
-
path: string;
|
|
561
|
-
bbox: Rectangle;
|
|
562
|
-
}
|
|
563
|
-
declare class WorkflowSimpleLineContribution implements WorkflowLineRenderContribution {
|
|
564
|
-
static type: string;
|
|
565
|
-
entity: WorkflowLineEntity;
|
|
566
|
-
constructor(entity: WorkflowLineEntity);
|
|
567
|
-
private data?;
|
|
568
|
-
get path(): string;
|
|
569
|
-
calcDistance(pos: IPoint): number;
|
|
570
|
-
get bounds(): Rectangle;
|
|
571
|
-
update(params: {
|
|
572
|
-
fromPos: IPoint;
|
|
573
|
-
toPos: IPoint;
|
|
574
|
-
}): void;
|
|
575
|
-
private projectPointOnLine;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
export { EditorCursorState, InteractiveType, LineEventProps, LinePoint, LinePosition, LineRenderType, NodePostionUpdateEvent, type NodeRenderReturnType, NodesDragEvent, OnDragLineEnd, type PositionMap, type StraightData, WorkflowCommands, WorkflowDocument, WorkflowDocumentContainerModule, WorkflowDocumentOptions, WorkflowDragService, WorkflowHoverService, WorkflowJSON, WorkflowLineEntity, WorkflowLineRenderContribution, WorkflowLineRenderData, type WorkflowLineRenderDataSchema, WorkflowLinesManager, WorkflowNodeEntity, WorkflowNodeJSON, type WorkflowNodeLines, WorkflowNodeLinesData, WorkflowNodePortsData, WorkflowOperationBaseService, WorkflowOperationBaseServiceImpl, WorkflowPort, WorkflowPortEntity, WorkflowPortType, WorkflowPorts, WorkflowResetLayoutService, WorkflowSelectService, WorkflowSimpleLineContribution, buildGroupJSON, fitView, getAntiOverlapPosition, nanoid, useCurrentDomNode, useCurrentEntity, useNodeRender, usePlaygroundReadonlyState, useWorkflowDocument };
|
|
565
|
+
export { EditorCursorState, InteractiveType, LineCenterPoint, LineEventProps, LinePoint, LinePosition, LineRenderType, NodePostionUpdateEvent, type NodeRenderReturnType, NodesDragEvent, OnDragLineEnd, type PositionMap, WorkflowCommands, WorkflowDocument, WorkflowDocumentContainerModule, WorkflowDocumentOptions, WorkflowDragService, WorkflowHoverService, WorkflowJSON, WorkflowLineEntity, WorkflowLineRenderContribution, WorkflowLineRenderData, type WorkflowLineRenderDataSchema, WorkflowLinesManager, WorkflowNodeEntity, WorkflowNodeJSON, type WorkflowNodeLines, WorkflowNodeLinesData, WorkflowNodePortsData, WorkflowOperationBaseService, WorkflowOperationBaseServiceImpl, WorkflowPort, WorkflowPortEntity, WorkflowPortType, WorkflowPorts, WorkflowResetLayoutService, WorkflowSelectService, buildGroupJSON, fitView, getAntiOverlapPosition, getLineCenter, nanoid, useCurrentDomNode, useCurrentEntity, useNodeRender, usePlaygroundReadonlyState, useWorkflowDocument };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { PlaygroundConfigEntity, CommandService, PlaygroundDragEvent, EntityData
|
|
|
2
2
|
export { bindConfigEntity, useConfigEntity, useEntities, useEntityDataFromContext, useEntityFromContext, useListenEvents, usePlayground, usePlaygroundContainer, usePlaygroundContext, usePlaygroundLatest, useRefresh, useService } from '@flowgram.ai/core';
|
|
3
3
|
import { NodeFormProps } from '@flowgram.ai/node';
|
|
4
4
|
import { FlowOperationBaseService, FlowNodeType, FlowOperationBaseServiceImpl, FlowNodeEntityOrId, FlowNodeEntity } from '@flowgram.ai/document';
|
|
5
|
-
import { W as WorkflowHoverService, a as WorkflowDocument, b as WorkflowLinesManager, c as WorkflowSelectService, d as WorkflowDocumentOptions, L as LineEventProps, N as NodesDragEvent, e as WorkflowNodeJSON, f as WorkflowPortEntity, g as WorkflowLineEntity, O as OnDragLineEnd, h as WorkflowJSON, i as
|
|
6
|
-
export {
|
|
5
|
+
import { W as WorkflowHoverService, a as WorkflowDocument, b as WorkflowLinesManager, c as WorkflowSelectService, d as WorkflowDocumentOptions, L as LineEventProps, N as NodesDragEvent, e as WorkflowNodeJSON, f as WorkflowPortEntity, g as WorkflowLineEntity, O as OnDragLineEnd, h as WorkflowJSON, i as LineCenterPoint, j as WorkflowPorts, k as WorkflowPortType, l as LinePoint, m as WorkflowPort, n as LineRenderType, o as WorkflowLineRenderContribution, p as LinePosition } from './workflow-line-entity-DcecHiNc.js';
|
|
6
|
+
export { R as HoverPosition, F as LINE_HOVER_DISTANCE, y as LineColor, z as LineColors, x as LinePointLocation, w as LineType, C as NodesDragEndEvent, B as NodesDragStartEvent, D as NodesDraggingEvent, P as POINT_RADIUS, K as PORT_SIZE, r as WORKFLOW_LINE_ENTITY, S as WorkfloEntityHoverable, u as WorkflowContentChangeEvent, t as WorkflowContentChangeType, U as WorkflowDocumentOptionsDefault, T as WorkflowDocumentProvider, Q as WorkflowEntityHoverable, H as WorkflowLineEntityOpts, I as WorkflowLineInfo, G as WorkflowLinePortInfo, A as WorkflowLineRenderContributionFactory, J as WorkflowLineUIState, v as WorkflowNodeMeta, M as WorkflowPortEntityOpts, s as domReactToBounds, q as getPortEntityId, E as onDragLineEndParams } from './workflow-line-entity-DcecHiNc.js';
|
|
7
7
|
import { W as WorkflowNodeEntity } from './workflow-sub-canvas-IQzlYvPD.js';
|
|
8
8
|
export { a as WorkflowSubCanvas } from './workflow-sub-canvas-IQzlYvPD.js';
|
|
9
9
|
import * as _flowgram_ai_utils from '@flowgram.ai/utils';
|
|
@@ -330,6 +330,13 @@ declare function usePlaygroundReadonlyState(listenChange?: boolean): boolean;
|
|
|
330
330
|
|
|
331
331
|
declare const buildGroupJSON: (json: WorkflowJSON) => WorkflowJSON;
|
|
332
332
|
|
|
333
|
+
/**
|
|
334
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
335
|
+
* SPDX-License-Identifier: MIT
|
|
336
|
+
*/
|
|
337
|
+
|
|
338
|
+
declare function getLineCenter(from: IPoint, to: IPoint, bbox: Rectangle, linePadding: number): LineCenterPoint;
|
|
339
|
+
|
|
333
340
|
/**
|
|
334
341
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
335
342
|
* SPDX-License-Identifier: MIT
|
|
@@ -487,6 +494,7 @@ declare class WorkflowNodeLinesData extends EntityData<WorkflowNodeLines> {
|
|
|
487
494
|
*/
|
|
488
495
|
get outputLines(): WorkflowLineEntity[];
|
|
489
496
|
get allLines(): WorkflowLineEntity[];
|
|
497
|
+
get availableLines(): WorkflowLineEntity[];
|
|
490
498
|
/**
|
|
491
499
|
* 输入节点
|
|
492
500
|
*/
|
|
@@ -533,6 +541,10 @@ declare class WorkflowLineRenderData extends EntityData<WorkflowLineRenderDataSc
|
|
|
533
541
|
*/
|
|
534
542
|
update(): void;
|
|
535
543
|
private get lineType();
|
|
544
|
+
/**
|
|
545
|
+
* 获取 center 位置
|
|
546
|
+
*/
|
|
547
|
+
get center(): LineCenterPoint;
|
|
536
548
|
/**
|
|
537
549
|
* 更新版本
|
|
538
550
|
* WARNING: 这个方法,必须在 requestAnimationFrame / useLayoutEffect 中调用,否则会引起浏览器强制重排
|
|
@@ -550,29 +562,4 @@ declare class WorkflowLineRenderData extends EntityData<WorkflowLineRenderDataSc
|
|
|
550
562
|
|
|
551
563
|
declare const WorkflowDocumentContainerModule: ContainerModule;
|
|
552
564
|
|
|
553
|
-
|
|
554
|
-
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
555
|
-
* SPDX-License-Identifier: MIT
|
|
556
|
-
*/
|
|
557
|
-
|
|
558
|
-
interface StraightData {
|
|
559
|
-
points: IPoint[];
|
|
560
|
-
path: string;
|
|
561
|
-
bbox: Rectangle;
|
|
562
|
-
}
|
|
563
|
-
declare class WorkflowSimpleLineContribution implements WorkflowLineRenderContribution {
|
|
564
|
-
static type: string;
|
|
565
|
-
entity: WorkflowLineEntity;
|
|
566
|
-
constructor(entity: WorkflowLineEntity);
|
|
567
|
-
private data?;
|
|
568
|
-
get path(): string;
|
|
569
|
-
calcDistance(pos: IPoint): number;
|
|
570
|
-
get bounds(): Rectangle;
|
|
571
|
-
update(params: {
|
|
572
|
-
fromPos: IPoint;
|
|
573
|
-
toPos: IPoint;
|
|
574
|
-
}): void;
|
|
575
|
-
private projectPointOnLine;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
export { EditorCursorState, InteractiveType, LineEventProps, LinePoint, LinePosition, LineRenderType, NodePostionUpdateEvent, type NodeRenderReturnType, NodesDragEvent, OnDragLineEnd, type PositionMap, type StraightData, WorkflowCommands, WorkflowDocument, WorkflowDocumentContainerModule, WorkflowDocumentOptions, WorkflowDragService, WorkflowHoverService, WorkflowJSON, WorkflowLineEntity, WorkflowLineRenderContribution, WorkflowLineRenderData, type WorkflowLineRenderDataSchema, WorkflowLinesManager, WorkflowNodeEntity, WorkflowNodeJSON, type WorkflowNodeLines, WorkflowNodeLinesData, WorkflowNodePortsData, WorkflowOperationBaseService, WorkflowOperationBaseServiceImpl, WorkflowPort, WorkflowPortEntity, WorkflowPortType, WorkflowPorts, WorkflowResetLayoutService, WorkflowSelectService, WorkflowSimpleLineContribution, buildGroupJSON, fitView, getAntiOverlapPosition, nanoid, useCurrentDomNode, useCurrentEntity, useNodeRender, usePlaygroundReadonlyState, useWorkflowDocument };
|
|
565
|
+
export { EditorCursorState, InteractiveType, LineCenterPoint, LineEventProps, LinePoint, LinePosition, LineRenderType, NodePostionUpdateEvent, type NodeRenderReturnType, NodesDragEvent, OnDragLineEnd, type PositionMap, WorkflowCommands, WorkflowDocument, WorkflowDocumentContainerModule, WorkflowDocumentOptions, WorkflowDragService, WorkflowHoverService, WorkflowJSON, WorkflowLineEntity, WorkflowLineRenderContribution, WorkflowLineRenderData, type WorkflowLineRenderDataSchema, WorkflowLinesManager, WorkflowNodeEntity, WorkflowNodeJSON, type WorkflowNodeLines, WorkflowNodeLinesData, WorkflowNodePortsData, WorkflowOperationBaseService, WorkflowOperationBaseServiceImpl, WorkflowPort, WorkflowPortEntity, WorkflowPortType, WorkflowPorts, WorkflowResetLayoutService, WorkflowSelectService, buildGroupJSON, fitView, getAntiOverlapPosition, getLineCenter, nanoid, useCurrentDomNode, useCurrentEntity, useNodeRender, usePlaygroundReadonlyState, useWorkflowDocument };
|
package/dist/index.js
CHANGED
|
@@ -57,7 +57,6 @@ __export(src_exports, {
|
|
|
57
57
|
WorkflowPortEntity: () => WorkflowPortEntity,
|
|
58
58
|
WorkflowResetLayoutService: () => WorkflowResetLayoutService,
|
|
59
59
|
WorkflowSelectService: () => WorkflowSelectService,
|
|
60
|
-
WorkflowSimpleLineContribution: () => WorkflowSimpleLineContribution,
|
|
61
60
|
bindConfigEntity: () => import_core3.bindConfigEntity,
|
|
62
61
|
buildGroupJSON: () => buildGroupJSON,
|
|
63
62
|
compose: () => import_utils.compose,
|
|
@@ -66,6 +65,7 @@ __export(src_exports, {
|
|
|
66
65
|
domReactToBounds: () => domReactToBounds,
|
|
67
66
|
fitView: () => fitView,
|
|
68
67
|
getAntiOverlapPosition: () => getAntiOverlapPosition,
|
|
68
|
+
getLineCenter: () => getLineCenter,
|
|
69
69
|
getPortEntityId: () => getPortEntityId,
|
|
70
70
|
nanoid: () => nanoid,
|
|
71
71
|
useConfigEntity: () => import_core25.useConfigEntity,
|
|
@@ -146,6 +146,16 @@ var buildGroupJSON = (json) => {
|
|
|
146
146
|
};
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
+
// src/utils/get-line-center.ts
|
|
150
|
+
function getLineCenter(from, to, bbox, linePadding) {
|
|
151
|
+
return {
|
|
152
|
+
x: bbox.center.x,
|
|
153
|
+
y: bbox.center.y,
|
|
154
|
+
labelX: bbox.center.x - bbox.x + linePadding,
|
|
155
|
+
labelY: bbox.center.y - bbox.y + linePadding
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
149
159
|
// src/utils/nanoid.ts
|
|
150
160
|
var import_nanoid = require("nanoid");
|
|
151
161
|
function nanoid(n) {
|
|
@@ -487,6 +497,7 @@ var WorkflowNodePortsData = class extends import_core5.EntityData {
|
|
|
487
497
|
...Array.from(elements).map((element) => ({
|
|
488
498
|
portID: element.getAttribute("data-port-id"),
|
|
489
499
|
type: element.getAttribute("data-port-type"),
|
|
500
|
+
location: element.getAttribute("data-port-location"),
|
|
490
501
|
targetElement: element
|
|
491
502
|
}))
|
|
492
503
|
);
|
|
@@ -653,6 +664,9 @@ var _WorkflowNodeLinesData = class _WorkflowNodeLinesData extends import_core6.E
|
|
|
653
664
|
get allLines() {
|
|
654
665
|
return this.data.inputLines.concat(this.data.outputLines);
|
|
655
666
|
}
|
|
667
|
+
get availableLines() {
|
|
668
|
+
return this.allLines.filter((line) => !line.isDrawing && !line.isHidden);
|
|
669
|
+
}
|
|
656
670
|
/**
|
|
657
671
|
* 输入节点
|
|
658
672
|
*/
|
|
@@ -794,6 +808,12 @@ var WorkflowLineRenderData = class extends import_core7.EntityData {
|
|
|
794
808
|
get lineType() {
|
|
795
809
|
return this.entity.renderType ?? this.entity.linesManager.lineType;
|
|
796
810
|
}
|
|
811
|
+
/**
|
|
812
|
+
* 获取 center 位置
|
|
813
|
+
*/
|
|
814
|
+
get center() {
|
|
815
|
+
return this.currentLine?.center || { x: 0, y: 0, labelX: 0, labelY: 0 };
|
|
816
|
+
}
|
|
797
817
|
/**
|
|
798
818
|
* 更新版本
|
|
799
819
|
* WARNING: 这个方法,必须在 requestAnimationFrame / useLayoutEffect 中调用,否则会引起浏览器强制重排
|
|
@@ -1055,6 +1075,9 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends import_core8.Entity
|
|
|
1055
1075
|
get bounds() {
|
|
1056
1076
|
return this.getData(WorkflowLineRenderData).bounds;
|
|
1057
1077
|
}
|
|
1078
|
+
get center() {
|
|
1079
|
+
return this.getData(WorkflowLineRenderData).center;
|
|
1080
|
+
}
|
|
1058
1081
|
/**
|
|
1059
1082
|
* 获取点和线最接近的距离
|
|
1060
1083
|
*/
|
|
@@ -1098,7 +1121,9 @@ var _WorkflowLineEntity = class _WorkflowLineEntity extends import_core8.Entity
|
|
|
1098
1121
|
get disabled() {
|
|
1099
1122
|
return this.linesManager.isDisabledLine(this, this.uiState.disabled);
|
|
1100
1123
|
}
|
|
1101
|
-
/**
|
|
1124
|
+
/**
|
|
1125
|
+
* @deprecated
|
|
1126
|
+
*/
|
|
1102
1127
|
get vertical() {
|
|
1103
1128
|
const fromLocation = this.fromPort.location;
|
|
1104
1129
|
const toLocation = this.toPort?.location;
|
|
@@ -1394,6 +1419,7 @@ var WorkflowContentChangeType = /* @__PURE__ */ ((WorkflowContentChangeType2) =>
|
|
|
1394
1419
|
var LineType = /* @__PURE__ */ ((LineType2) => {
|
|
1395
1420
|
LineType2[LineType2["BEZIER"] = 0] = "BEZIER";
|
|
1396
1421
|
LineType2[LineType2["LINE_CHART"] = 1] = "LINE_CHART";
|
|
1422
|
+
LineType2[LineType2["STRAIGHT"] = 2] = "STRAIGHT";
|
|
1397
1423
|
return LineType2;
|
|
1398
1424
|
})(LineType || {});
|
|
1399
1425
|
var LineColors = /* @__PURE__ */ ((LineColors2) => {
|
|
@@ -2473,9 +2499,18 @@ var WorkflowDocument = class extends import_document8.FlowDocument {
|
|
|
2473
2499
|
this._onReloadEmitter.dispose();
|
|
2474
2500
|
}
|
|
2475
2501
|
/**
|
|
2476
|
-
*
|
|
2502
|
+
* 批量添加节点
|
|
2503
|
+
* @deprecated use 'batchAddFromJSON' instead
|
|
2504
|
+
* @param json
|
|
2505
|
+
* @param options
|
|
2477
2506
|
*/
|
|
2478
2507
|
renderJSON(json, options) {
|
|
2508
|
+
return this.batchAddFromJSON(json, options);
|
|
2509
|
+
}
|
|
2510
|
+
/**
|
|
2511
|
+
* 批量添加节点
|
|
2512
|
+
*/
|
|
2513
|
+
batchAddFromJSON(json, options) {
|
|
2479
2514
|
const { parent = this.root, isClone = false } = options ?? {};
|
|
2480
2515
|
const containerID = this.getNodeSubCanvas(parent)?.canvasNode.id ?? parent.id;
|
|
2481
2516
|
const processedJSON = buildGroupJSON(json);
|
|
@@ -2605,6 +2640,18 @@ function checkDragSuccess(time, e, originLine) {
|
|
|
2605
2640
|
}
|
|
2606
2641
|
return false;
|
|
2607
2642
|
}
|
|
2643
|
+
function reverseLocation(sourceLocation) {
|
|
2644
|
+
switch (sourceLocation) {
|
|
2645
|
+
case "bottom":
|
|
2646
|
+
return "top";
|
|
2647
|
+
case "left":
|
|
2648
|
+
return "right";
|
|
2649
|
+
case "top":
|
|
2650
|
+
return "bottom";
|
|
2651
|
+
case "right":
|
|
2652
|
+
return "left";
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2608
2655
|
var WorkflowDragService = class {
|
|
2609
2656
|
constructor() {
|
|
2610
2657
|
this._onDragLineEventEmitter = new import_utils16.Emitter();
|
|
@@ -3062,7 +3109,7 @@ var WorkflowDragService = class {
|
|
|
3062
3109
|
line.drawingTo = {
|
|
3063
3110
|
x: dragPos.x,
|
|
3064
3111
|
y: dragPos.y,
|
|
3065
|
-
location: line.fromPort.location
|
|
3112
|
+
location: reverseLocation(line.fromPort.location)
|
|
3066
3113
|
};
|
|
3067
3114
|
}
|
|
3068
3115
|
originLine?.validate();
|
|
@@ -3634,81 +3681,6 @@ var WorkflowDocumentContainerModule = new import_inversify10.ContainerModule(
|
|
|
3634
3681
|
bind(WorkflowDocumentProvider).toDynamicValue((ctx) => () => ctx.container.get(WorkflowDocument)).inSingletonScope();
|
|
3635
3682
|
}
|
|
3636
3683
|
);
|
|
3637
|
-
|
|
3638
|
-
// src/utils/simple-line.ts
|
|
3639
|
-
var import_utils21 = require("@flowgram.ai/utils");
|
|
3640
|
-
var LINE_PADDING = 12;
|
|
3641
|
-
var WorkflowSimpleLineContribution = class {
|
|
3642
|
-
constructor(entity) {
|
|
3643
|
-
this.entity = entity;
|
|
3644
|
-
}
|
|
3645
|
-
get path() {
|
|
3646
|
-
return this.data?.path ?? "";
|
|
3647
|
-
}
|
|
3648
|
-
calcDistance(pos) {
|
|
3649
|
-
if (!this.data) {
|
|
3650
|
-
return Number.MAX_SAFE_INTEGER;
|
|
3651
|
-
}
|
|
3652
|
-
const [start, end] = this.data.points;
|
|
3653
|
-
return import_utils21.Point.getDistance(pos, this.projectPointOnLine(pos, start, end));
|
|
3654
|
-
}
|
|
3655
|
-
get bounds() {
|
|
3656
|
-
if (!this.data) {
|
|
3657
|
-
return new import_utils21.Rectangle();
|
|
3658
|
-
}
|
|
3659
|
-
return this.data.bbox;
|
|
3660
|
-
}
|
|
3661
|
-
update(params) {
|
|
3662
|
-
const { fromPos, toPos } = params;
|
|
3663
|
-
const { vertical } = this.entity;
|
|
3664
|
-
const sourceOffset = {
|
|
3665
|
-
x: vertical ? 0 : POINT_RADIUS,
|
|
3666
|
-
y: vertical ? POINT_RADIUS : 0
|
|
3667
|
-
};
|
|
3668
|
-
const targetOffset = {
|
|
3669
|
-
x: vertical ? 0 : -POINT_RADIUS,
|
|
3670
|
-
y: vertical ? -POINT_RADIUS : 0
|
|
3671
|
-
};
|
|
3672
|
-
const points = [
|
|
3673
|
-
{
|
|
3674
|
-
x: fromPos.x + sourceOffset.x,
|
|
3675
|
-
y: fromPos.y + sourceOffset.y
|
|
3676
|
-
},
|
|
3677
|
-
{
|
|
3678
|
-
x: toPos.x + targetOffset.x,
|
|
3679
|
-
y: toPos.y + targetOffset.y
|
|
3680
|
-
}
|
|
3681
|
-
];
|
|
3682
|
-
const bbox = import_utils21.Rectangle.createRectangleWithTwoPoints(points[0], points[1]);
|
|
3683
|
-
const adjustedPoints = points.map((p) => ({
|
|
3684
|
-
x: p.x - bbox.x + LINE_PADDING,
|
|
3685
|
-
y: p.y - bbox.y + LINE_PADDING
|
|
3686
|
-
}));
|
|
3687
|
-
const path = `M ${adjustedPoints[0].x} ${adjustedPoints[0].y} L ${adjustedPoints[1].x} ${adjustedPoints[1].y}`;
|
|
3688
|
-
this.data = {
|
|
3689
|
-
points,
|
|
3690
|
-
path,
|
|
3691
|
-
bbox
|
|
3692
|
-
};
|
|
3693
|
-
}
|
|
3694
|
-
projectPointOnLine(point, lineStart, lineEnd) {
|
|
3695
|
-
const dx = lineEnd.x - lineStart.x;
|
|
3696
|
-
const dy = lineEnd.y - lineStart.y;
|
|
3697
|
-
if (dx === 0) {
|
|
3698
|
-
return { x: lineStart.x, y: point.y };
|
|
3699
|
-
}
|
|
3700
|
-
if (dy === 0) {
|
|
3701
|
-
return { x: point.x, y: lineStart.y };
|
|
3702
|
-
}
|
|
3703
|
-
const t = ((point.x - lineStart.x) * dx + (point.y - lineStart.y) * dy) / (dx * dx + dy * dy);
|
|
3704
|
-
const clampedT = Math.max(0, Math.min(1, t));
|
|
3705
|
-
return {
|
|
3706
|
-
x: lineStart.x + clampedT * dx,
|
|
3707
|
-
y: lineStart.y + clampedT * dy
|
|
3708
|
-
};
|
|
3709
|
-
}
|
|
3710
|
-
};
|
|
3711
|
-
WorkflowSimpleLineContribution.type = "WorkflowSimpleLineContribution";
|
|
3712
3684
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3713
3685
|
0 && (module.exports = {
|
|
3714
3686
|
EditorCursorState,
|
|
@@ -3740,7 +3712,6 @@ WorkflowSimpleLineContribution.type = "WorkflowSimpleLineContribution";
|
|
|
3740
3712
|
WorkflowPortEntity,
|
|
3741
3713
|
WorkflowResetLayoutService,
|
|
3742
3714
|
WorkflowSelectService,
|
|
3743
|
-
WorkflowSimpleLineContribution,
|
|
3744
3715
|
bindConfigEntity,
|
|
3745
3716
|
buildGroupJSON,
|
|
3746
3717
|
compose,
|
|
@@ -3749,6 +3720,7 @@ WorkflowSimpleLineContribution.type = "WorkflowSimpleLineContribution";
|
|
|
3749
3720
|
domReactToBounds,
|
|
3750
3721
|
fitView,
|
|
3751
3722
|
getAntiOverlapPosition,
|
|
3723
|
+
getLineCenter,
|
|
3752
3724
|
getPortEntityId,
|
|
3753
3725
|
nanoid,
|
|
3754
3726
|
useConfigEntity,
|