feat: keep line breaks in the field description

This commit is contained in:
chenos 2022-04-12 23:28:49 +08:00
parent 5d9976b35e
commit 4c2df15da2

View File

@ -7,11 +7,24 @@ import { useCompile, useDesignable } from '../..';
import { useCollection, useCollectionManager } from '../../../collection-manager'; import { useCollection, useCollectionManager } from '../../../collection-manager';
import { GeneralSchemaDesigner, SchemaSettings } from '../../../schema-settings'; import { GeneralSchemaDesigner, SchemaSettings } from '../../../schema-settings';
import { BlockItem } from '../block-item'; import { BlockItem } from '../block-item';
import { HTMLEncode } from '../input/shared';
export const FormItem: any = (props) => { export const FormItem: any = (props) => {
const field = useField();
return ( return (
<BlockItem className={'nb-form-item'}> <BlockItem className={'nb-form-item'}>
<Item {...props} /> <Item
{...props}
extra={
field.description ? (
<div
dangerouslySetInnerHTML={{
__html: HTMLEncode(field.description).split('\n').join('<br/>'),
}}
/>
) : null
}
/>
</BlockItem> </BlockItem>
); );
}; };