From 7bd4b4021762b24aac83f43cc39ee0d5c888380d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=BA=E4=BF=A1?= Date: Thu, 4 May 2023 16:49:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E7=BE=A4=E7=BB=84?= =?UTF-8?q?=E6=A1=86=E6=A0=B9=E6=8D=AE=E5=AD=90=E8=8A=82=E7=82=B9=E8=BE=B9?= =?UTF-8?q?=E7=95=8C=E4=BD=8D=E7=BD=AE=E8=87=AA=E5=8A=A8=E7=BC=A9=E5=B0=8F?= =?UTF-8?q?=E6=94=BE=E5=A4=A7=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command-contribution.ts | 45 +++++-------------- 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/packages/xflow-core/src/command-contributions/command-contribution.ts b/packages/xflow-core/src/command-contributions/command-contribution.ts index 1972491c..7cac799d 100644 --- a/packages/xflow-core/src/command-contributions/command-contribution.ts +++ b/packages/xflow-core/src/command-contributions/command-contribution.ts @@ -27,6 +27,7 @@ import { CommandConfig } from './config' import type { ICmdHooks } from './interface' import type { IEvent } from '../hooks/interface' import type { NsGraph } from '../interface' +import { NsAddGroup } from './group/group-add' /** Commands 配置项目*/ const hookhubList = [...nodeHooks, ...edgeHooks, ...groupHooks, ...graphHooks, ...observablesHooks] @@ -86,7 +87,6 @@ export class XFlowCommandContribution const isCollapsed = group.getProp('isCollapsed') let originSize = group.getProp('originSize') - let hasChange = false if (originSize == null) { originSize = group.size() @@ -98,52 +98,27 @@ export class XFlowCommandContribution group.prop('originPosition', originPosition) } - let x = originPosition.x - let y = originPosition.y - let cornerX = originPosition.x + originSize.width - let cornerY = originPosition.y + originSize.height const childs = group.getChildren() if (childs) { - childs.forEach(child => { - const bbox = child.getBBox().inflate(12) - const corner = bbox.getCorner() - - if (bbox.x < x) { - x = bbox.x - hasChange = true - } - - if (bbox.y < y) { - y = bbox.y - hasChange = true - } - - if (corner.x > cornerX) { - cornerX = corner.x - hasChange = true - } - - if (corner.y > cornerY) { - cornerY = corner.y - hasChange = true - } - }) - } + const bbox = graph.getCellsBBox(childs).inflate(NsAddGroup.GROUP_PADDING) + const x = bbox.x + const y = bbox.y - NsAddGroup.GROUP_HEADER_HEIGHT + const width = bbox!.width + const height = bbox!.height + NsAddGroup.GROUP_HEADER_HEIGHT - if (hasChange) { group.prop({ position: { x, y }, - size: { width: cornerX - x, height: cornerY - y }, + size: { width, height }, }) const groupData: NsGraph.INodeConfig = { ...group.getData(), x, y, - width: cornerX - x, - height: cornerY - y, + width, + height, } if (isCollapsed !== true) { - groupData.groupChildrenSize = { width: cornerX - x, height: cornerY - y } + groupData.groupChildrenSize = { width, height } } group.setData(groupData) } From 2be488ceec74047f4a991447d24c33a1cf270301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=BA=E4=BF=A1?= Date: Tue, 9 May 2023 17:00:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=AB=98=E4=BA=AE?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E8=81=94=E5=8A=A8=E9=AB=98=E4=BA=AE=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E7=9A=84=E5=85=B3=E8=81=94=E8=BE=B9=E4=B8=8D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command-contributions/node/node-highlight.ts | 16 ++++++++-------- .../api/commands/nodes/node-highlight/index.md | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/xflow-core/src/command-contributions/node/node-highlight.ts b/packages/xflow-core/src/command-contributions/node/node-highlight.ts index 46caecd1..e2a2994f 100644 --- a/packages/xflow-core/src/command-contributions/node/node-highlight.ts +++ b/packages/xflow-core/src/command-contributions/node/node-highlight.ts @@ -77,14 +77,14 @@ export class HighlightNodeCommand implements ICommand { /** 节点关联的连线, 联动高亮 */ if (handlerArgs?.isHighlightRelatedLines) { const { edgeStroke, edgeStrokeWidth } = handlerArgs - const allEdges = x6Graph?.getEdges() - allEdges.forEach((x6Edge: X6Edge) => { - const x6EdgeData = x6Edge?.getData() - handlerArgs?.commandService.executeCommand(XFlowEdgeCommands.HIGHLIGHT_EDGE.id, { - edgeId: x6EdgeData?.id, - strokeColor: edgeStroke, - strokeWidth: edgeStrokeWidth, - } as NsEdgeCmd.HighlightEdge.IArgs) + const connectedEdges = x6Graph?.getConnectedEdges(x6Node) + connectedEdges.forEach((x6Edge: X6Edge) => { + x6Edge.setAttrs({ + line: { + stroke: edgeStroke, + strokeWidth: edgeStrokeWidth, + } + }) }) } } diff --git a/packages/xflow-docs/docs/api/commands/nodes/node-highlight/index.md b/packages/xflow-docs/docs/api/commands/nodes/node-highlight/index.md index d37b6808..dec3455a 100644 --- a/packages/xflow-docs/docs/api/commands/nodes/node-highlight/index.md +++ b/packages/xflow-docs/docs/api/commands/nodes/node-highlight/index.md @@ -28,6 +28,7 @@ XFlow 提供节点添加的命令 `XFlowNodeCommands.HIGHLIGHT_NODE`, 通过该 | strokeWidth | number | | - | 节点高亮边框宽度 | | isHighlightRelatedLines | boolean | | - | 是否联动高亮节点的关联边 | | edgeStroke | string | | - | 边高亮颜色 | +| edgeStrokeWidth | number | | - | 边高亮宽度 | | edgeStrokeWidth?: number | number | | - | 边高亮宽度 |