|
1 | 1 | import React, { useState, useMemo, useRef } from 'react'; |
2 | | -import { Button, Space } from 'antd'; |
| 2 | +import { Form, Button, Space } from 'antd'; |
3 | 3 | import { EditOutlined } from '@ant-design/icons'; |
4 | 4 | import { Field, FieldRenderProps } from '@flowgram.ai/fixed-layout-editor'; |
5 | 5 | import { GroovyVariableService } from '@/services/groovy-variable-service'; |
@@ -64,47 +64,50 @@ export const NodeTitleStrategy: React.FC = () => { |
64 | 64 |
|
65 | 65 | return ( |
66 | 66 | <> |
67 | | - <div style={{ width: '100%' }}> |
68 | | - <Field |
69 | | - name="NodeTitleStrategy.script" |
70 | | - render={({ field: { value, onChange } }: FieldRenderProps<any>) => { |
71 | | - // 保存 onChange 回调到 ref |
72 | | - onChangeRef.current = onChange; |
| 67 | + <Form style={{ width: '100%' }} layout="vertical"> |
| 68 | + <Form.Item label="节点标题"> |
| 69 | + <Field |
| 70 | + name="NodeTitleStrategy.script" |
| 71 | + render={(props: FieldRenderProps<any>) => { |
| 72 | + const { value, onChange } = props.field; |
| 73 | + // 保存 onChange 回调到 ref |
| 74 | + onChangeRef.current = onChange; |
73 | 75 |
|
74 | | - // 更新显示的脚本值(当编辑器状态改变时) |
75 | | - if (value !== displayScript) { |
76 | | - setDisplayScript(value || ''); |
77 | | - } |
| 76 | + // 更新显示的脚本值(当编辑器状态改变时) |
| 77 | + if (value !== displayScript) { |
| 78 | + setDisplayScript(value || ''); |
| 79 | + } |
78 | 80 |
|
79 | | - return ( |
80 | | - <Space.Compact style={{ width: '100%' }}> |
81 | | - <div |
82 | | - style={{ |
83 | | - flex: 1, |
84 | | - padding: '4px 11px', |
85 | | - backgroundColor: value ? '#fff' : '#fafafa', |
86 | | - border: '1px solid #d9d9d9', |
87 | | - borderRadius: '6px 0 0 6px', |
88 | | - color: value ? 'rgba(0,0,0,0.88)' : 'rgba(0,0,0,0.25)', |
89 | | - whiteSpace: 'nowrap', |
90 | | - overflow: 'hidden', |
91 | | - textOverflow: 'ellipsis', |
92 | | - }} |
93 | | - > |
94 | | - {renderPreview(value)} |
95 | | - </div> |
96 | | - <Button |
97 | | - icon={<EditOutlined />} |
98 | | - onClick={handleOpenConfig} |
99 | | - style={{ borderRadius: '0 6px 6px 0' }} |
100 | | - > |
101 | | - 编辑 |
102 | | - </Button> |
103 | | - </Space.Compact> |
104 | | - ); |
105 | | - }} |
106 | | - /> |
107 | | - </div> |
| 81 | + return ( |
| 82 | + <Space.Compact style={{ width: '100%' }}> |
| 83 | + <div |
| 84 | + style={{ |
| 85 | + flex: 1, |
| 86 | + padding: '4px 11px', |
| 87 | + backgroundColor: value ? '#fff' : '#fafafa', |
| 88 | + border: '1px solid #d9d9d9', |
| 89 | + borderRadius: '6px 0 0 6px', |
| 90 | + color: value ? 'rgba(0,0,0,0.88)' : 'rgba(0,0,0,0.25)', |
| 91 | + whiteSpace: 'nowrap', |
| 92 | + overflow: 'hidden', |
| 93 | + textOverflow: 'ellipsis', |
| 94 | + }} |
| 95 | + > |
| 96 | + {renderPreview(value)} |
| 97 | + </div> |
| 98 | + <Button |
| 99 | + icon={<EditOutlined />} |
| 100 | + onClick={handleOpenConfig} |
| 101 | + style={{ borderRadius: '0 6px 6px 0' }} |
| 102 | + > |
| 103 | + 编辑 |
| 104 | + </Button> |
| 105 | + </Space.Compact> |
| 106 | + ); |
| 107 | + }} |
| 108 | + /> |
| 109 | + </Form.Item> |
| 110 | + </Form> |
108 | 111 |
|
109 | 112 | {showConfigModal && ( |
110 | 113 | <TitleConfigModal |
|
0 commit comments