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