fix: form expression scope

This commit is contained in:
chenos 2021-03-26 10:05:55 +08:00
parent 122f6bfdb7
commit 07af1ca08d
2 changed files with 5 additions and 14 deletions

View File

@ -22,6 +22,7 @@ import set from 'lodash/set';
import cloneDeep from 'lodash/cloneDeep' import cloneDeep from 'lodash/cloneDeep'
import { Spin } from '@nocobase/client'; import { Spin } from '@nocobase/client';
import { markdown } from '@/components/views/Field'; import { markdown } from '@/components/views/Field';
import scopes from '@/components/views/Form/scopes';
export function fields2properties(fields = [], options: any = {}) { export function fields2properties(fields = [], options: any = {}) {
const { mode } = options; const { mode } = options;
@ -161,20 +162,7 @@ export function Form(props: any) {
} }
onFinish && await onFinish(values); onFinish && await onFinish(values);
}} }}
expressionScope={{ expressionScope={scopes}
text(...args: any[]) {
return React.createElement('span', {}, ...args)
},
tooltip(title: string, offset = 3) {
return (
<Tooltip title={title}>
<QuestionCircleOutlined
style={{ margin: '0 3px', cursor: 'default', marginLeft: offset }}
/>
</Tooltip>
);
},
}}
> >
<FormButtonGroup className={'form-button-group'} align={'end'}> <FormButtonGroup className={'form-button-group'} align={'end'}>
<Reset></Reset> <Reset></Reset>

View File

@ -11,6 +11,9 @@ export default {
const text = decodeURIComponent(html); const text = decodeURIComponent(html);
return <div dangerouslySetInnerHTML={{__html: markdown(text)}}></div> return <div dangerouslySetInnerHTML={{__html: markdown(text)}}></div>
}, },
markdown(text: string) {
return <span dangerouslySetInnerHTML={{__html: markdown(text)}}></span>
},
tooltip(title: string, offset = 3) { tooltip(title: string, offset = 3) {
return ( return (
<Tooltip title={<div dangerouslySetInnerHTML={{__html: title}}></div>}> <Tooltip title={<div dangerouslySetInnerHTML={{__html: title}}></div>}>