add cancel button to markdown

This commit is contained in:
chenos 2021-08-27 11:30:12 +08:00
parent 52699b0302
commit 35cafad0ff

View File

@ -63,15 +63,23 @@ function MarkdownTextArea(props: any) {
setValue(e.target.value); setValue(e.target.value);
}} }}
/> />
<Button <Space style={{ position: 'absolute', bottom: 5, right: 5 }}>
style={{ position: 'absolute', bottom: 5, right: 5 }} <Button
type={'primary'} onClick={(e) => {
onClick={() => { props.onCancel && props.onCancel(e);
props.onSubmit && props.onSubmit(value); }}
}} >
>
</Button>
</Button> <Button
type={'primary'}
onClick={() => {
props.onSubmit && props.onSubmit(value);
}}
>
</Button>
</Space>
</div> </div>
); );
} }
@ -90,6 +98,9 @@ Markdown.Void = observer((props: any) => {
<MarkdownTextArea <MarkdownTextArea
{...props} {...props}
defaultValue={schema['default']} defaultValue={schema['default']}
onCancel={() => {
field.readPretty = true;
}}
onSubmit={async (value) => { onSubmit={async (value) => {
field.readPretty = true; field.readPretty = true;
schema['default'] = value; schema['default'] = value;