Skip to content

Commit d673be6

Browse files
author
昔梦
committed
fix:将用户自定义className放到节点最顶层
1 parent ee04fa1 commit d673be6

File tree

7 files changed

+11
-15
lines changed

7 files changed

+11
-15
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.node-llm-style {
2-
background-color: rgba(97, 113, 243,0.3);
3-
border:1px solid rgba(97, 113, 243, 0.5)
2+
.custom-node-container{
3+
background-color: rgba(97, 113, 243,0.3);
4+
}
45
}

packages/x-flow/src/components/CustomNode/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ export default memo((props: any) => {
5959
const isEnd = type === 'End';
6060
const isSwitchNode = type === 'Switch' || type === 'Parallel' || isNote; // 判断是否为条件节点/并行节点/注释节点
6161
const connectable = readOnly ? false : isConnectable;
62+
const nodeSetting = settingMap[type] || {};
63+
const nodeClassName = nodeSetting?.className || '';
6264

6365
// 增加节点并进行联系
6466
const handleAddNode = (data: any, sourceHandle?: string) => {
@@ -253,6 +255,7 @@ export default memo((props: any) => {
253255
['xflow-node-container-tb']: layout === 'TB',
254256
['xflow-node-container-note']: isNote,
255257
[`xflow-node-container-status-${status}`]: isTruthy(status),
258+
[nodeClassName]: !!nodeClassName
256259
})}
257260
onMouseEnter={() => setIsHovered(true)}
258261
onMouseLeave={() => setIsHovered(false)}

packages/x-flow/src/nodes/node-common/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ export default memo((props: any) => {
1212
const hideDesc = nodeSetting?.nodePanel?.hideDesc ?? globalConfig?.nodePanel?.hideDesc ?? false;
1313
const hideTitleTips = globalConfig?.nodeView?.hideTitleTips ?? false;
1414
const SVGWidget = widgets[nodeSetting?.iconSvg]; // 自定义面板配置组件
15-
const nodeClassName = nodeSetting?.className || '';
1615

1716
return (
1817
<NodeContainer
19-
className={`custom-node-code ${nodeClassName}`}
18+
className={`custom-node-code`}
2019
title={data?.title || nodeSetting.title}
2120
icon={{
2221
type: nodeSetting?.icon?.type,

packages/x-flow/src/nodes/node-end/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ export default memo((props: any) => {
1111
const hideDesc = nodeSetting?.nodePanel?.hideDesc ?? globalConfig?.nodePanel?.hideDesc ?? false;
1212
const hideTitleTips = globalConfig?.nodeView?.hideTitleTips ?? false;
1313
const SVGWidget = widgets[nodeSetting?.iconSvg]; // 自定义面板配置组件
14-
const nodeClassName = nodeSetting?.className || '';
1514

1615
return (
1716
<NodeContainer
18-
className={`custom-node-code ${nodeClassName}`}
17+
className={`custom-node-code`}
1918
title={data?.title || nodeSetting?.title || '结束'}
2019
icon={{
2120
type: nodeSetting?.icon?.type || 'icon-end',

packages/x-flow/src/nodes/node-parallel/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@ export default memo((props: any) => {
2828
const hideTitleTips = globalConfig?.nodeView?.hideTitleTips ?? false;
2929
const isSwitchBottom = position === Position.Bottom;
3030
const SVGWidget = widgets[nodeSetting?.iconSvg]; // 自定义面板配置组件
31-
const nodeClassName = nodeSetting?.className || '';
3231

3332
return (
3433
<NodeContainer
3534
className={classNames('custom-node-code', {
36-
'switch-node-code-bottom': isSwitchBottom,
37-
[nodeClassName]: !!nodeClassName,
35+
'switch-node-code-bottom': isSwitchBottom
3836
})}
3937
title={data?.title || nodeSetting?.title || 'parallel'}
4038
icon={{

packages/x-flow/src/nodes/node-start/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ export default memo((props: any) => {
1515
false;
1616
const hideTitleTips = globalConfig?.nodeView?.hideTitleTips ?? false;
1717
const SVGWidget = widgets[nodeSetting?.iconSvg]; // 自定义面板配置组件
18-
const nodeClassName = nodeSetting?.className || '';
1918

2019
return (
2120
<NodeContainer
22-
className={`custom-node-code ${nodeClassName}`}
21+
className={`custom-node-code`}
2322
title={data?.title || nodeSetting?.title || '开始'}
2423
icon={{
2524
type: nodeSetting?.icon?.type || 'icon-start',

packages/x-flow/src/nodes/node-switch/index.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,11 @@ export default memo((props: any) => {
2929
const hideTitleTips = globalConfig?.nodeView?.hideTitleTips ?? false;
3030
const isSwitchBottom = position === Position.Bottom;
3131
const SVGWidget = widgets[nodeSetting?.iconSvg]; // 自定义面板配置组件
32-
const nodeClassName = nodeSetting?.className || '';
33-
3432

3533
return (
3634
<NodeContainer
3735
className={classNames('custom-node-code', {
38-
'switch-node-code-bottom': isSwitchBottom,
39-
[nodeClassName]: !!nodeClassName,
36+
'switch-node-code-bottom': isSwitchBottom
4037
})}
4138
title={data?.title || nodeSetting?.title || 'Switch'}
4239
icon={{

0 commit comments

Comments
 (0)