mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:48:55 +08:00
* feat: input-rich-text 的图片上传支持自定义字段 * 换成 fileField
This commit is contained in:
parent
1f6ece5586
commit
c5ab2d3e94
@ -28,7 +28,11 @@ order: 47
|
||||
|
||||
## 图片上传
|
||||
|
||||
通过设置 `receiver` 来支持文件上传,它的返回值类似如下:
|
||||
通过设置 `receiver` 来支持文件上传,如果是 tinymce,它会将图片放在 `file` 字段中
|
||||
|
||||
> 1.6.1 及以上版本可以通过 fileField 字段修改
|
||||
|
||||
它的返回值类似如下:
|
||||
|
||||
```json
|
||||
{
|
||||
@ -55,7 +59,7 @@ order: 47
|
||||
"body": [
|
||||
{
|
||||
"type": "input-rich-text",
|
||||
"receiver": "/api/mock2/sample/mirror?json={%22value%22:%22/amis/static/logo_c812f54.png%22}",
|
||||
"receiver": "/api/mock2/sample/mirror?json={%22link%22:%22/amis/static/logo_c812f54.png%22}",
|
||||
"name": "rich",
|
||||
"label": "Rich Text"
|
||||
}
|
||||
@ -146,6 +150,7 @@ froala 可以通过设置 buttons 参数来控制显示哪些按钮,默认是
|
||||
| saveAsUbb | `boolean` | | 是否保存为 ubb 格式 |
|
||||
| receiver | [API](../../../docs/types/api) | | 默认的图片保存 API |
|
||||
| videoReceiver | [API](../../../docs/types/api) | | 默认的视频保存 API |
|
||||
| fileField | string | | 上传文件时的字段名 |
|
||||
| size | `string` | | 框的大小,可设置为 `md` 或者 `lg` |
|
||||
| options | `object` | | 需要参考 [tinymce](https://www.tiny.cloud/docs/configure/integration-and-setup/) 或 [froala](https://www.froala.com/wysiwyg-editor/docs/options) 的文档 |
|
||||
| buttons | `Array<string>` | | froala 专用,配置显示的按钮,tinymce 可以通过前面的 options 设置 [toolbar](https://www.tiny.cloud/docs/demo/custom-toolbar-button/) 字符串 |
|
||||
|
@ -18,6 +18,11 @@ export interface RichTextControlSchema extends FormBaseControl {
|
||||
receiver?: string;
|
||||
videoReceiver?: string;
|
||||
|
||||
/**
|
||||
* 接收器的字段名
|
||||
*/
|
||||
fileField?: string;
|
||||
|
||||
/**
|
||||
* 边框模式,全边框,还是半边框,或者没边框。
|
||||
*/
|
||||
@ -48,6 +53,7 @@ export default class RichTextControl extends React.Component<
|
||||
imageEditable: true,
|
||||
receiver: '/api/upload/image',
|
||||
videoReceiver: '/api/upload/video',
|
||||
fileField: 'file',
|
||||
placeholder: 'placeholder.enter',
|
||||
options: {
|
||||
toolbarButtons: [
|
||||
@ -141,7 +147,11 @@ export default class RichTextControl extends React.Component<
|
||||
fail: (reason: string) => void
|
||||
) => {
|
||||
const formData = new FormData();
|
||||
formData.append('file', blobInfo.blob(), blobInfo.filename());
|
||||
formData.append(
|
||||
props.fileField,
|
||||
blobInfo.blob(),
|
||||
blobInfo.filename()
|
||||
);
|
||||
try {
|
||||
const receiver = {
|
||||
adaptor: (payload: object) => {
|
||||
|
Loading…
Reference in New Issue
Block a user