fix #4147: 富文本编辑器receiver无法数据映射问题 (#4155)

This commit is contained in:
RUNZE LU 2022-04-28 10:56:48 +08:00 committed by GitHub
parent d16eca6fdc
commit 4cf1ac1922
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ import LazyComponent from '../../components/LazyComponent';
import {tokenize} from '../../utils/tpl-builtin';
import {normalizeApi} from '../../utils/api';
import {ucFirst} from '../../utils/helper';
import type {SchemaApi} from '../../Schema';
/**
* RichText
@ -13,10 +14,24 @@ import {ucFirst} from '../../utils/helper';
export interface RichTextControlSchema extends FormBaseControl {
type: 'input-rich-text';
/**
*
*/
vendor?: 'froala' | 'tinymce';
receiver?: string;
videoReceiver?: string;
/**
* API
*
* @default /api/upload/image
*/
receiver?: SchemaApi;
/**
* API
*
* @default /api/upload/video
*/
videoReceiver?: SchemaApi;
/**
*
@ -28,6 +43,9 @@ export interface RichTextControlSchema extends FormBaseControl {
*/
borderMode?: 'full' | 'half' | 'none';
/**
* tinymce froala
*/
options?: any;
}
@ -152,6 +170,7 @@ export default class RichTextControl extends React.Component<
blobInfo.blob(),
blobInfo.filename()
);
try {
const receiver = {
adaptor: (payload: object) => {
@ -160,8 +179,9 @@ export default class RichTextControl extends React.Component<
data: payload
};
},
...normalizeApi(props.receiver, 'post')
...normalizeApi(tokenize(props.receiver, props.data), 'post')
};
const response = await fetcher(receiver, formData, {
method: 'post'
});