refactor: code improve

This commit is contained in:
katherinehhh 2025-07-01 09:59:51 +08:00
parent 7561db0fa0
commit 5f997963a0
2 changed files with 10 additions and 3 deletions

View File

@ -103,8 +103,7 @@ BlockModel.registerFlow({
};
},
handler(ctx, params) {
ctx.model.setProps('heightMode', params.heightMode);
ctx.model.setProps('height', params.height);
ctx.model.setDecoratorProps({ heightMode: params.heightMode, height: params.height });
},
},
},

View File

@ -14,10 +14,18 @@ import { useTranslation } from 'react-i18next';
import { NAMESPACE_UI_SCHEMA } from '../../../i18n/constant';
import { MarkdownReadPretty } from '../fields/EditableField/MarkdownEditableFieldModel';
const useBlockHeight = ({ height, heightMode }) => {
if (heightMode !== 'specifyValue') {
return null;
}
return height;
};
export const BlockItemCard = (props) => {
const { t } = useTranslation();
const { token } = theme.useToken();
const { title: blockTitle, description, children } = props;
const height = useBlockHeight(props);
const title = (blockTitle || description) && (
<div style={{ padding: '8px 0px 8px' }}>
<span> {t(blockTitle, { ns: NAMESPACE_UI_SCHEMA })}</span>
@ -38,7 +46,7 @@ export const BlockItemCard = (props) => {
return (
<Card
title={title}
style={{ display: 'flex', flexDirection: 'column', height: '100%' }}
style={{ display: 'flex', flexDirection: 'column', height: height }}
styles={{
body: { flex: 1, display: 'flex', flexDirection: 'column', overflow: 'hidden' },
}}