From 972e147fdf39fc616a8c6cf9c3e7bd176ef1ef6f Mon Sep 17 00:00:00 2001 From: jialin Date: Tue, 10 Mar 2026 17:56:46 +0800 Subject: [PATCH] fix: yaml edior height --- src/pages/_components/yaml-editor/index.tsx | 10 ++++++---- src/pages/backends/components/add-modal.tsx | 13 ++++++++++++- src/pages/backends/components/import-yaml.tsx | 5 +++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/pages/_components/yaml-editor/index.tsx b/src/pages/_components/yaml-editor/index.tsx index fb613957..78671057 100644 --- a/src/pages/_components/yaml-editor/index.tsx +++ b/src/pages/_components/yaml-editor/index.tsx @@ -18,9 +18,7 @@ const { Text } = Typography; loader.config({ monaco }); -const Container = styled.div<{ $minHeight: string | number }>` - min-height: ${({ $minHeight }) => - typeof $minHeight === 'number' ? `${$minHeight}px` : $minHeight}; +const Container = styled.div` position: relative; border: 1px solid var(--ant-color-border); border-radius: var(--ant-border-radius); @@ -153,7 +151,11 @@ const YamlEditor: React.FC = forwardRef((props, ref) => { }, [value]); return ( - + = (props) => { const [activeKey, setActiveKey] = useState('form'); const [yamlContent, setYamlContent] = useState(''); const [formContent, setFormContent] = useState({} as FormData); + const alertRef = useRef(null); const showVersionCustomSuffix = currentData?.backend_source === BackendSourceValueMap.BUILTIN || @@ -193,6 +194,15 @@ const AddModal: React.FC = (props) => { } }, [action, currentData, open]); + const yamlHeight = useMemo(() => { + if (action !== PageAction.CREATE) { + return undefined; + } + const baseHeight = 260; + const alertHeight = alertRef.current?.offsetHeight || 0; + return `calc(100vh - ${baseHeight + alertHeight}px)`; + }, [action, activeKey]); + return ( = (props) => { footer={ <> {action === PageAction.CREATE && ( -
+
= (props) => { label: intl.formatMessage({ id: 'backend.mode.yaml' }), children: ( void; } const ImportYAML: React.FC = forwardRef( - ({ actionStatus, content = '' }, ref) => { + ({ actionStatus, content = '', height }, ref) => { const intl = useIntl(); const editorRef = useRef(null); const [fileContent, setFileContent] = useState( @@ -109,7 +110,7 @@ const ImportYAML: React.FC = forwardRef( { setError('');