@antv/g6 5.0.44 → 5.0.46
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/g6.min.js +11 -11
- package/dist/lib/behaviors/zoom-canvas.d.ts +9 -1
- package/dist/lib/elements/nodes/image.d.ts +1 -0
- package/dist/lib/plugins/edge-filter-lens/index.d.ts +2 -2
- package/dist/lib/plugins/grid-line.d.ts +19 -1
- package/dist/lib/plugins/hull/hull/format.d.ts +9 -0
- package/dist/lib/plugins/hull/hull/grid_handle.d.ts +15 -0
- package/dist/lib/plugins/hull/hull/index.d.ts +3 -0
- package/dist/lib/plugins/hull/hull/monotone-convex-hull-2d.d.ts +2 -0
- package/dist/lib/plugins/hull/hull/robust-orientation.d.ts +2 -0
- package/dist/lib/plugins/hull/hull/robust-scale.d.ts +1 -0
- package/dist/lib/plugins/hull/hull/robust-segment-intersect.d.ts +2 -0
- package/dist/lib/plugins/hull/hull/robust-subtract.d.ts +1 -0
- package/dist/lib/plugins/hull/hull/robust-sum.d.ts +1 -0
- package/dist/lib/plugins/hull/hull/two-product.d.ts +1 -0
- package/dist/lib/plugins/hull/hull/two-sum.d.ts +1 -0
- package/dist/lib/plugins/toolbar/util.d.ts +4 -0
- package/dist/lib/registry/register.d.ts +1 -5
- package/dist/lib/transforms/process-parallel-edges.d.ts +14 -2
- package/dist/lib/utils/element.d.ts +9 -9
- package/dist/lib/version.d.ts +1 -1
- package/esm/behaviors/brush-select.js +3 -1
- package/esm/behaviors/brush-select.js.map +1 -1
- package/esm/behaviors/drag-element.js +2 -0
- package/esm/behaviors/drag-element.js.map +1 -1
- package/esm/behaviors/zoom-canvas.d.ts +9 -1
- package/esm/behaviors/zoom-canvas.js +2 -2
- package/esm/behaviors/zoom-canvas.js.map +1 -1
- package/esm/elements/nodes/image.d.ts +1 -0
- package/esm/elements/nodes/image.js +13 -2
- package/esm/elements/nodes/image.js.map +1 -1
- package/esm/plugins/edge-filter-lens/index.d.ts +2 -2
- package/esm/plugins/edge-filter-lens/index.js +2 -0
- package/esm/plugins/edge-filter-lens/index.js.map +1 -1
- package/esm/plugins/fisheye/index.js +3 -0
- package/esm/plugins/fisheye/index.js.map +1 -1
- package/esm/plugins/grid-line.d.ts +19 -1
- package/esm/plugins/grid-line.js +42 -5
- package/esm/plugins/grid-line.js.map +1 -1
- package/esm/plugins/hull/hull/format.d.ts +9 -0
- package/esm/plugins/hull/hull/format.js +20 -0
- package/esm/plugins/hull/hull/format.js.map +1 -0
- package/esm/plugins/hull/hull/grid_handle.d.ts +15 -0
- package/esm/plugins/hull/hull/grid_handle.js +66 -0
- package/esm/plugins/hull/hull/grid_handle.js.map +1 -0
- package/esm/plugins/hull/hull/index.d.ts +3 -0
- package/esm/plugins/hull/hull/index.js +150 -0
- package/esm/plugins/hull/hull/index.js.map +1 -0
- package/esm/plugins/hull/hull/monotone-convex-hull-2d.d.ts +2 -0
- package/esm/plugins/hull/hull/monotone-convex-hull-2d.js +63 -0
- package/esm/plugins/hull/hull/monotone-convex-hull-2d.js.map +1 -0
- package/esm/plugins/hull/hull/robust-orientation.d.ts +2 -0
- package/esm/plugins/hull/hull/robust-orientation.js +145 -0
- package/esm/plugins/hull/hull/robust-orientation.js.map +1 -0
- package/esm/plugins/hull/hull/robust-scale.d.ts +1 -0
- package/esm/plugins/hull/hull/robust-scale.js +47 -0
- package/esm/plugins/hull/hull/robust-scale.js.map +1 -0
- package/esm/plugins/hull/hull/robust-segment-intersect.d.ts +2 -0
- package/esm/plugins/hull/hull/robust-segment-intersect.js +29 -0
- package/esm/plugins/hull/hull/robust-segment-intersect.js.map +1 -0
- package/esm/plugins/hull/hull/robust-subtract.d.ts +1 -0
- package/esm/plugins/hull/hull/robust-subtract.js +161 -0
- package/esm/plugins/hull/hull/robust-subtract.js.map +1 -0
- package/esm/plugins/hull/hull/robust-sum.d.ts +1 -0
- package/esm/plugins/hull/hull/robust-sum.js +155 -0
- package/esm/plugins/hull/hull/robust-sum.js.map +1 -0
- package/esm/plugins/hull/hull/two-product.d.ts +1 -0
- package/esm/plugins/hull/hull/two-product.js +24 -0
- package/esm/plugins/hull/hull/two-product.js.map +1 -0
- package/esm/plugins/hull/hull/two-sum.d.ts +1 -0
- package/esm/plugins/hull/hull/two-sum.js +15 -0
- package/esm/plugins/hull/hull/two-sum.js.map +1 -0
- package/esm/plugins/hull/index.js +1 -1
- package/esm/plugins/hull/index.js.map +1 -1
- package/esm/plugins/minimap/index.js +3 -1
- package/esm/plugins/minimap/index.js.map +1 -1
- package/esm/plugins/toolbar/index.js +6 -3
- package/esm/plugins/toolbar/index.js.map +1 -1
- package/esm/plugins/toolbar/util.d.ts +4 -0
- package/esm/plugins/toolbar/util.js.map +1 -1
- package/esm/registry/register.d.ts +1 -5
- package/esm/registry/register.js +4 -10
- package/esm/registry/register.js.map +1 -1
- package/esm/runtime/graph.js +1 -1
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/layout.js +4 -4
- package/esm/runtime/layout.js.map +1 -1
- package/esm/transforms/process-parallel-edges.d.ts +14 -2
- package/esm/transforms/process-parallel-edges.js +35 -10
- package/esm/transforms/process-parallel-edges.js.map +1 -1
- package/esm/utils/edge.js +5 -4
- package/esm/utils/edge.js.map +1 -1
- package/esm/utils/element.d.ts +9 -9
- package/esm/utils/element.js +30 -20
- package/esm/utils/element.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/behaviors/brush-select.js +3 -1
- package/lib/behaviors/brush-select.js.map +1 -1
- package/lib/behaviors/drag-element.js +2 -0
- package/lib/behaviors/drag-element.js.map +1 -1
- package/lib/behaviors/zoom-canvas.d.ts +9 -1
- package/lib/behaviors/zoom-canvas.js +2 -2
- package/lib/behaviors/zoom-canvas.js.map +1 -1
- package/lib/elements/nodes/image.d.ts +1 -0
- package/lib/elements/nodes/image.js +13 -2
- package/lib/elements/nodes/image.js.map +1 -1
- package/lib/plugins/edge-filter-lens/index.d.ts +2 -2
- package/lib/plugins/edge-filter-lens/index.js +2 -0
- package/lib/plugins/edge-filter-lens/index.js.map +1 -1
- package/lib/plugins/fisheye/index.js +3 -0
- package/lib/plugins/fisheye/index.js.map +1 -1
- package/lib/plugins/grid-line.d.ts +19 -1
- package/lib/plugins/grid-line.js +41 -4
- package/lib/plugins/grid-line.js.map +1 -1
- package/lib/plugins/hull/hull/format.d.ts +9 -0
- package/lib/plugins/hull/hull/format.js +23 -0
- package/lib/plugins/hull/hull/format.js.map +1 -0
- package/lib/plugins/hull/hull/grid_handle.d.ts +15 -0
- package/lib/plugins/hull/hull/grid_handle.js +71 -0
- package/lib/plugins/hull/hull/grid_handle.js.map +1 -0
- package/lib/plugins/hull/hull/index.d.ts +3 -0
- package/lib/plugins/hull/hull/index.js +153 -0
- package/lib/plugins/hull/hull/index.js.map +1 -0
- package/lib/plugins/hull/hull/monotone-convex-hull-2d.d.ts +2 -0
- package/lib/plugins/hull/hull/monotone-convex-hull-2d.js +68 -0
- package/lib/plugins/hull/hull/monotone-convex-hull-2d.js.map +1 -0
- package/lib/plugins/hull/hull/robust-orientation.d.ts +2 -0
- package/lib/plugins/hull/hull/robust-orientation.js +146 -0
- package/lib/plugins/hull/hull/robust-orientation.js.map +1 -0
- package/lib/plugins/hull/hull/robust-scale.d.ts +1 -0
- package/lib/plugins/hull/hull/robust-scale.js +49 -0
- package/lib/plugins/hull/hull/robust-scale.js.map +1 -0
- package/lib/plugins/hull/hull/robust-segment-intersect.d.ts +2 -0
- package/lib/plugins/hull/hull/robust-segment-intersect.js +35 -0
- package/lib/plugins/hull/hull/robust-segment-intersect.js.map +1 -0
- package/lib/plugins/hull/hull/robust-subtract.d.ts +1 -0
- package/lib/plugins/hull/hull/robust-subtract.js +163 -0
- package/lib/plugins/hull/hull/robust-subtract.js.map +1 -0
- package/lib/plugins/hull/hull/robust-sum.d.ts +1 -0
- package/lib/plugins/hull/hull/robust-sum.js +157 -0
- package/lib/plugins/hull/hull/robust-sum.js.map +1 -0
- package/lib/plugins/hull/hull/two-product.d.ts +1 -0
- package/lib/plugins/hull/hull/two-product.js +26 -0
- package/lib/plugins/hull/hull/two-product.js.map +1 -0
- package/lib/plugins/hull/hull/two-sum.d.ts +1 -0
- package/lib/plugins/hull/hull/two-sum.js +17 -0
- package/lib/plugins/hull/hull/two-sum.js.map +1 -0
- package/lib/plugins/hull/index.js +2 -5
- package/lib/plugins/hull/index.js.map +1 -1
- package/lib/plugins/minimap/index.js +3 -1
- package/lib/plugins/minimap/index.js.map +1 -1
- package/lib/plugins/toolbar/index.js +6 -3
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/util.d.ts +4 -0
- package/lib/plugins/toolbar/util.js.map +1 -1
- package/lib/registry/register.d.ts +1 -5
- package/lib/registry/register.js +4 -10
- package/lib/registry/register.js.map +1 -1
- package/lib/runtime/graph.js +1 -1
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/layout.js +4 -4
- package/lib/runtime/layout.js.map +1 -1
- package/lib/transforms/process-parallel-edges.d.ts +14 -2
- package/lib/transforms/process-parallel-edges.js +35 -10
- package/lib/transforms/process-parallel-edges.js.map +1 -1
- package/lib/utils/edge.js +5 -4
- package/lib/utils/edge.js.map +1 -1
- package/lib/utils/element.d.ts +9 -9
- package/lib/utils/element.js +30 -20
- package/lib/utils/element.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +9 -10
- package/src/behaviors/brush-select.ts +3 -2
- package/src/behaviors/drag-element.ts +1 -0
- package/src/behaviors/zoom-canvas.ts +10 -2
- package/src/elements/nodes/image.ts +14 -2
- package/src/plugins/edge-filter-lens/index.ts +4 -4
- package/src/plugins/fisheye/index.ts +2 -0
- package/src/plugins/grid-line.ts +72 -8
- package/src/plugins/hull/hull/README.md +1 -0
- package/src/plugins/hull/hull/format.ts +29 -0
- package/src/plugins/hull/hull/grid_handle.ts +73 -0
- package/src/plugins/hull/hull/index.ts +203 -0
- package/src/plugins/hull/hull/monotone-convex-hull-2d.ts +76 -0
- package/src/plugins/hull/hull/robust-orientation.ts +443 -0
- package/src/plugins/hull/hull/robust-scale.ts +53 -0
- package/src/plugins/hull/hull/robust-segment-intersect.ts +29 -0
- package/src/plugins/hull/hull/robust-subtract.ts +187 -0
- package/src/plugins/hull/hull/robust-sum.ts +175 -0
- package/src/plugins/hull/hull/two-product.ts +31 -0
- package/src/plugins/hull/hull/two-sum.ts +17 -0
- package/src/plugins/hull/index.ts +1 -1
- package/src/plugins/minimap/index.ts +6 -8
- package/src/plugins/toolbar/index.ts +1 -1
- package/src/plugins/toolbar/util.ts +4 -0
- package/src/registry/register.ts +5 -8
- package/src/runtime/graph.ts +1 -1
- package/src/runtime/layout.ts +4 -4
- package/src/transforms/process-parallel-edges.ts +41 -10
- package/src/utils/edge.ts +5 -4
- package/src/utils/element.ts +33 -22
- package/src/version.ts +1 -1
|
@@ -78,6 +78,12 @@ export class ProcessParallelEdges extends BaseTransform<ProcessParallelEdgesOpti
|
|
|
78
78
|
super(context, Object.assign({}, ProcessParallelEdges.defaultOptions, options));
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* <zh/> 在每次绘制前处理平行边
|
|
83
|
+
*
|
|
84
|
+
* <en/> Process parallel edges before each drawing
|
|
85
|
+
* @param input
|
|
86
|
+
*/
|
|
81
87
|
public beforeDraw(input: DrawData): DrawData {
|
|
82
88
|
const edges = this.getAffectedParallelEdges(input);
|
|
83
89
|
|
|
@@ -90,6 +96,12 @@ export class ProcessParallelEdges extends BaseTransform<ProcessParallelEdgesOpti
|
|
|
90
96
|
return input;
|
|
91
97
|
}
|
|
92
98
|
|
|
99
|
+
/**
|
|
100
|
+
* <zh/> 获取受影响的平行边
|
|
101
|
+
*
|
|
102
|
+
* <en/> Get affected parallel edges
|
|
103
|
+
* @param input
|
|
104
|
+
*/
|
|
93
105
|
private getAffectedParallelEdges = (input: DrawData): Map<ID, EdgeData> => {
|
|
94
106
|
const {
|
|
95
107
|
add: { edges: edgesToAdd },
|
|
@@ -240,9 +252,9 @@ export class ProcessParallelEdges extends BaseTransform<ProcessParallelEdgesOpti
|
|
|
240
252
|
}
|
|
241
253
|
|
|
242
254
|
/**
|
|
243
|
-
* <zh/>
|
|
255
|
+
* <zh/> 优化的按照端点分组方法,时间复杂度O(n)
|
|
244
256
|
*
|
|
245
|
-
* <en/>
|
|
257
|
+
* <en/> Optimized method to group by endpoints, time complexity O(n)
|
|
246
258
|
* @param edges - <zh/> 边集合 | <en/> Edges
|
|
247
259
|
* @returns <zh/> 端点分组后的边集合 | <en/> Edges grouped by endpoints
|
|
248
260
|
*/
|
|
@@ -250,6 +262,7 @@ export const groupByEndpoints = (edges: Map<ID, EdgeData>) => {
|
|
|
250
262
|
const edgeMap = new Map<string, EdgeData[]>();
|
|
251
263
|
const processedEdgesSet = new Set<ID>();
|
|
252
264
|
const reverses: Record<string, boolean> = {};
|
|
265
|
+
const includedEdgesInGroup = new Map<string, Set<ID>>();
|
|
253
266
|
|
|
254
267
|
for (const [id, edge] of edges) {
|
|
255
268
|
if (processedEdgesSet.has(id)) continue;
|
|
@@ -257,18 +270,36 @@ export const groupByEndpoints = (edges: Map<ID, EdgeData>) => {
|
|
|
257
270
|
const { source, target } = edge;
|
|
258
271
|
const sourceTarget = `${source}-${target}`;
|
|
259
272
|
|
|
260
|
-
if (!edgeMap.has(sourceTarget))
|
|
261
|
-
|
|
262
|
-
|
|
273
|
+
if (!edgeMap.has(sourceTarget)) {
|
|
274
|
+
edgeMap.set(sourceTarget, []);
|
|
275
|
+
includedEdgesInGroup.set(sourceTarget, new Set<ID>());
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const sourceTargetEdges = edgeMap.get(sourceTarget);
|
|
279
|
+
const includedEdges = includedEdgesInGroup.get(sourceTarget);
|
|
280
|
+
|
|
281
|
+
if (sourceTargetEdges && includedEdges && !includedEdges.has(id)) {
|
|
282
|
+
sourceTargetEdges.push(edge);
|
|
283
|
+
includedEdges.add(id);
|
|
284
|
+
processedEdgesSet.add(id);
|
|
285
|
+
}
|
|
263
286
|
|
|
264
287
|
for (const [otherId, sedge] of edges) {
|
|
265
|
-
if (processedEdgesSet.has(otherId)) continue;
|
|
288
|
+
if (processedEdgesSet.has(otherId) || otherId === id) continue;
|
|
266
289
|
|
|
267
290
|
if (isParallelEdges(edge, sedge)) {
|
|
268
|
-
edgeMap.get(sourceTarget)
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
291
|
+
const groupEdges = edgeMap.get(sourceTarget);
|
|
292
|
+
const includedGroupEdges = includedEdgesInGroup.get(sourceTarget);
|
|
293
|
+
|
|
294
|
+
if (groupEdges && includedGroupEdges && !includedGroupEdges.has(otherId)) {
|
|
295
|
+
groupEdges.push(sedge);
|
|
296
|
+
includedGroupEdges.add(otherId);
|
|
297
|
+
|
|
298
|
+
if (source === sedge.target && target === sedge.source) {
|
|
299
|
+
reverses[`${sedge.source}|${sedge.target}|${groupEdges.length - 1}`] = true;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
processedEdgesSet.add(otherId);
|
|
272
303
|
}
|
|
273
304
|
}
|
|
274
305
|
}
|
package/src/utils/edge.ts
CHANGED
|
@@ -241,9 +241,10 @@ export function getCubicPath(sourcePoint: Point, targetPoint: Point, controlPoin
|
|
|
241
241
|
* @returns <zh/> 返回绘制折线的路径 | <en/> Returns the path for drawing a polyline
|
|
242
242
|
*/
|
|
243
243
|
export function getPolylinePath(points: Point[], radius = 0, z = false): PathArray {
|
|
244
|
+
const targetIndex = points.length - 1;
|
|
244
245
|
const sourcePoint = points[0];
|
|
245
|
-
const targetPoint = points[
|
|
246
|
-
const controlPoints = points.slice(1,
|
|
246
|
+
const targetPoint = points[targetIndex];
|
|
247
|
+
const controlPoints = points.slice(1, targetIndex);
|
|
247
248
|
const pathArray: PathArray = [['M', sourcePoint[0], sourcePoint[1]]];
|
|
248
249
|
controlPoints.forEach((midPoint, i) => {
|
|
249
250
|
const prevPoint = controlPoints[i - 1] || sourcePoint;
|
|
@@ -390,7 +391,7 @@ export function getCubicLoopPath(
|
|
|
390
391
|
|
|
391
392
|
// 3. 如果定义了连接桩,调整端点以与连接桩边界相交 | If the port is defined, adjust the endpoint to intersect with the port boundary
|
|
392
393
|
if (sourcePort) sourcePoint = getPortConnectionPoint(sourcePort, controlPoints[0]);
|
|
393
|
-
if (targetPort) targetPoint = getPortConnectionPoint(targetPort, controlPoints
|
|
394
|
+
if (targetPort) targetPoint = getPortConnectionPoint(targetPort, controlPoints.at(-1) as Point);
|
|
394
395
|
|
|
395
396
|
return getCubicPath(sourcePoint, targetPoint, controlPoints);
|
|
396
397
|
}
|
|
@@ -463,7 +464,7 @@ export function getPolylineLoopPath(
|
|
|
463
464
|
|
|
464
465
|
// 3. 如果定义了连接桩,调整端点以与连接桩边界相交 | If the port is defined, adjust the endpoint to intersect with the port boundary
|
|
465
466
|
if (sourcePort) sourcePoint = getPortConnectionPoint(sourcePort, controlPoints[0]);
|
|
466
|
-
if (targetPort) targetPoint = getPortConnectionPoint(targetPort, controlPoints
|
|
467
|
+
if (targetPort) targetPoint = getPortConnectionPoint(targetPort, controlPoints.at(-1) as Point);
|
|
467
468
|
|
|
468
469
|
return getPolylinePath([sourcePoint, ...controlPoints, targetPoint], radius);
|
|
469
470
|
}
|
package/src/utils/element.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AABB, DisplayObject, TextStyleProps } from '@antv/g';
|
|
2
2
|
import { get, isNumber, isString, set } from '@antv/util';
|
|
3
3
|
import { BaseCombo, BaseEdge, BaseNode } from '../elements';
|
|
4
|
-
import type { BaseShape } from '../elements/shapes';
|
|
4
|
+
import type { BaseShape, BaseShapeStyleProps } from '../elements/shapes';
|
|
5
5
|
import type { Combo, Edge, Element, Node, NodePortStyleProps, Placement, Point, TriangleDirection } from '../types';
|
|
6
6
|
import type { NodeLabelStyleProps, Port } from '../types/node';
|
|
7
7
|
import { getBBoxHeight, getBBoxWidth } from './bbox';
|
|
@@ -71,6 +71,14 @@ const PORT_MAP: Record<string, Point> = {
|
|
|
71
71
|
right: [1, 0.5],
|
|
72
72
|
bottom: [0.5, 1],
|
|
73
73
|
left: [0, 0.5],
|
|
74
|
+
'left-top': [0, 0],
|
|
75
|
+
'top-left': [0, 0],
|
|
76
|
+
'left-bottom': [0, 1],
|
|
77
|
+
'bottom-left': [0, 1],
|
|
78
|
+
'right-top': [1, 0],
|
|
79
|
+
'top-right': [1, 0],
|
|
80
|
+
'right-bottom': [1, 1],
|
|
81
|
+
'bottom-right': [1, 1],
|
|
74
82
|
default: [0.5, 0.5],
|
|
75
83
|
};
|
|
76
84
|
|
|
@@ -78,18 +86,18 @@ const PORT_MAP: Record<string, Point> = {
|
|
|
78
86
|
* Get the Port x, y by `position`.
|
|
79
87
|
* @param bbox - BBox of element.
|
|
80
88
|
* @param placement - The position relative with element.
|
|
81
|
-
* @param
|
|
89
|
+
* @param portMap - The map of position.
|
|
82
90
|
* @param isRelative - Whether the position in MAP is relative.
|
|
83
91
|
* @returns [x, y]
|
|
84
92
|
*/
|
|
85
93
|
export function getPortXYByPlacement(
|
|
86
94
|
bbox: AABB,
|
|
87
95
|
placement?: Placement,
|
|
88
|
-
|
|
96
|
+
portMap: Record<string, Point> = PORT_MAP,
|
|
89
97
|
isRelative = true,
|
|
90
98
|
): Point {
|
|
91
99
|
const DEFAULT = [0.5, 0.5];
|
|
92
|
-
const p: [number, number] = isString(placement) ? get(
|
|
100
|
+
const p: [number, number] = isString(placement) ? get(portMap, placement.toLocaleLowerCase(), DEFAULT) : placement;
|
|
93
101
|
|
|
94
102
|
if (!isRelative && isString(placement)) return p;
|
|
95
103
|
|
|
@@ -174,7 +182,7 @@ export function findPorts(
|
|
|
174
182
|
* 3. If the node has no ports, return undefined.
|
|
175
183
|
* @param node - <zh/> 节点 | <en/> Node
|
|
176
184
|
* @param oppositeNode - <zh/> 对端节点 | <en/> Opposite Node
|
|
177
|
-
* @param portKey - <zh/>
|
|
185
|
+
* @param portKey - <zh/> 连接桩的键值(key) | <en/> Port Key
|
|
178
186
|
* @param oppositePortKey - <zh/> 对端连接桩的 key | <en/> Opposite Port Key
|
|
179
187
|
* @returns <zh/> 连接桩 | <en/> Port
|
|
180
188
|
*/
|
|
@@ -200,7 +208,7 @@ export function findPort(node: Node, oppositeNode: Node, portKey?: string, oppos
|
|
|
200
208
|
* 2. If `portKey` is not specified, return positions of all ports.
|
|
201
209
|
* 3. If the node has no ports, return the center of the node.
|
|
202
210
|
* @param node - <zh/> 节点 | <en/> Node
|
|
203
|
-
* @param portKey
|
|
211
|
+
* @param portKey - <zh/> 连接桩的键值(key),如不指定则返回所有 | <en/> Port Key, return all if not specified
|
|
204
212
|
* @returns <zh/> 连接点 | <en/> Connection Point
|
|
205
213
|
*/
|
|
206
214
|
function findConnectionPoints(node: Node, portKey?: string): Point[] {
|
|
@@ -230,7 +238,7 @@ export function getConnectionPoint(node: Port | Node | Combo, opposite: Node | P
|
|
|
230
238
|
* <en/> Get the connection point of the port
|
|
231
239
|
* @param port - <zh/> 连接桩 | <en/> Port
|
|
232
240
|
* @param opposite - <zh/> 对端的具体点或节点 | <en/> Opposite Point or Node
|
|
233
|
-
* @param oppositePort - <zh/> 对端连接桩 | <en/> Opposite Port
|
|
241
|
+
* // @param oppositePort - <zh/> 对端连接桩 | <en/> Opposite Port
|
|
234
242
|
* @returns <zh/> 连接桩的连接点 | <en/> Port Point
|
|
235
243
|
*/
|
|
236
244
|
export function getPortConnectionPoint(port: Port, opposite: Node | Port): Point {
|
|
@@ -240,8 +248,8 @@ export function getPortConnectionPoint(port: Port, opposite: Node | Port): Point
|
|
|
240
248
|
// 1. linkToCenter 为 true,则返回连接桩的中心 | If linkToCenter is true, return the center of the port
|
|
241
249
|
if (port.attributes.linkToCenter) return port.getPosition();
|
|
242
250
|
|
|
243
|
-
// 2.
|
|
244
|
-
// 2.
|
|
251
|
+
// 2. 推导对端的具体点:如果是连接桩或节点,则返回它的中心;如果是具体点,则直接返回
|
|
252
|
+
// 2. Get a specific opposite point: if it is a port or a node, return its center; if it is a specific point, return directly
|
|
245
253
|
const oppositePosition = isPoint(opposite)
|
|
246
254
|
? opposite
|
|
247
255
|
: isNode(opposite)
|
|
@@ -256,19 +264,19 @@ export function getPortConnectionPoint(port: Port, opposite: Node | Port): Point
|
|
|
256
264
|
* <zh/> 获取节点的连接点
|
|
257
265
|
*
|
|
258
266
|
* <en/> Get the Node Connection Point
|
|
259
|
-
* @param
|
|
267
|
+
* @param nodeLike - <zh/> 节点或组合 | <en/> Node or Combo
|
|
260
268
|
* @param opposite - <zh/> 对端的具体点或节点 | <en/> Opposite Point or Node
|
|
261
|
-
* @param oppositePort - <zh/> 对端连接桩 | <en/> Opposite Port
|
|
269
|
+
* // @param oppositePort - <zh/> 对端连接桩 | <en/> Opposite Port
|
|
262
270
|
* @returns <zh/> 节点的连接点 | <en/> Node Point
|
|
263
271
|
*/
|
|
264
|
-
export function getNodeConnectionPoint(
|
|
265
|
-
if (!
|
|
272
|
+
export function getNodeConnectionPoint(nodeLike: Node | Combo, opposite: Node | Port): Point {
|
|
273
|
+
if (!nodeLike || !opposite) return [0, 0, 0];
|
|
266
274
|
const oppositePosition = isPoint(opposite)
|
|
267
275
|
? opposite
|
|
268
276
|
: isNode(opposite)
|
|
269
277
|
? opposite.getCenter()
|
|
270
278
|
: opposite.getPosition();
|
|
271
|
-
return
|
|
279
|
+
return nodeLike.getIntersectPoint(oppositePosition) || nodeLike.getCenter();
|
|
272
280
|
}
|
|
273
281
|
|
|
274
282
|
/**
|
|
@@ -290,16 +298,19 @@ export function getTextStyleByPlacement(
|
|
|
290
298
|
const direction = placement.split('-');
|
|
291
299
|
const [x, y] = getXYByPlacement(bbox, placement);
|
|
292
300
|
|
|
293
|
-
const
|
|
301
|
+
const [top, bottom]: TextStyleProps['textBaseline'][] = isReverseBaseline ? ['bottom', 'top'] : ['top', 'bottom'];
|
|
294
302
|
|
|
295
|
-
|
|
296
|
-
?
|
|
303
|
+
const textBaseline: TextStyleProps['textBaseline'] = direction.includes('top')
|
|
304
|
+
? bottom
|
|
297
305
|
: direction.includes('bottom')
|
|
298
|
-
?
|
|
306
|
+
? top
|
|
299
307
|
: 'middle';
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
308
|
+
|
|
309
|
+
const textAlign: TextStyleProps['textAlign'] = direction.includes('left')
|
|
310
|
+
? 'right'
|
|
311
|
+
: direction.includes('right')
|
|
312
|
+
? 'left'
|
|
313
|
+
: 'center';
|
|
303
314
|
|
|
304
315
|
return {
|
|
305
316
|
transform: [['translate', x + offsetX, y + offsetY]],
|
|
@@ -475,7 +486,7 @@ export function isVisible(element: DisplayObject) {
|
|
|
475
486
|
* @param element - <zh/> 元素 | <en/> element
|
|
476
487
|
* @param style - <zh/> 样式 | <en/> style
|
|
477
488
|
*/
|
|
478
|
-
export function setAttributes(element: BaseShape<any>, style: Record<string, any>) {
|
|
489
|
+
export function setAttributes(element: BaseShape<any>, style: Partial<BaseShapeStyleProps> & Record<string, any>) {
|
|
479
490
|
const { zIndex, transform, transformOrigin, visibility, cursor, clipPath, component, ...rest } = style;
|
|
480
491
|
Object.assign(element.attributes, rest);
|
|
481
492
|
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.0.
|
|
1
|
+
export const version = '5.0.46';
|