Skip to content

Commit

Permalink
fix: richtext设计态死循环问题 (#5489)
Browse files Browse the repository at this point in the history
* fix:修复富文本编辑器死循环问题

* fix:修复富文本编辑器死循环问题
  • Loading branch information
hsm-lv authored Sep 30, 2022
1 parent 0784488 commit 84909c6
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions packages/amis/src/renderers/Form/InputRichText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,23 @@ export default class RichTextControl extends React.Component<
this.handleFocus = this.handleFocus.bind(this);
this.handleBlur = this.handleBlur.bind(this);
this.handleChange = this.handleChange.bind(this);
const api = buildApi(props.receiver, props.data, {
const imageReceiver = normalizeApi(
props.receiver,
props.receiver.method || 'post'
);
imageReceiver.data = imageReceiver.data || {};
const imageApi = buildApi(imageReceiver, props.data, {
method: props.receiver.method || 'post'
});
if (finnalVendor === 'froala') {
const videoReceiver = normalizeApi(
props.videoReceiver,
props.videoReceiver.method || 'post'
);
videoReceiver.data = videoReceiver.data || {};
const videoApi = buildApi(videoReceiver, props.data, {
method: props.videoReceiver.method || 'post'
});
this.config = {
imageAllowedTypes: ['jpeg', 'jpg', 'png', 'gif'],
imageDefaultAlign: 'left',
Expand All @@ -143,14 +156,15 @@ export default class RichTextControl extends React.Component<
...props.options,
editorClass: props.editorClass,
placeholderText: props.translate(props.placeholder),
imageUploadURL: api.url,
imageUploadURL: imageApi.url,
imageUploadParams: {
from: 'rich-text',
...api.data
...imageApi.data
},
videoUploadURL: tokenize(props.videoReceiver, props.data),
videoUploadURL: videoApi.url,
videoUploadParams: {
from: 'rich-text'
from: 'rich-text',
...videoApi.data
},
events: {
...(props.options && props.options.events),
Expand All @@ -172,8 +186,8 @@ export default class RichTextControl extends React.Component<
new Promise(async (resolve, reject) => {
const formData = new FormData();

if (api.data) {
qsstringify(api.data)
if (imageApi.data) {
qsstringify(imageApi.data)
.split('&')
.filter(item => item !== '')
.forEach(item => {
Expand All @@ -196,7 +210,7 @@ export default class RichTextControl extends React.Component<
data: payload
};
},
...api
...imageApi
};

const response = await fetcher(receiver, formData, {
Expand Down

0 comments on commit 84909c6

Please sign in to comment.