Dynamic property saveParams in react-froala editor
andrew2558 opened this issue · 4 comments
Expected behavior
就是从外面动态的传递props给froala编辑器组件,需要这个props参数动态的更新到froala的saveParams中
Actual behavior
实际虽然每次传递进来的props在组件中更新了,但是在saveParams中一直是第一次创建froala组件实例的值
Steps to reproduce the behavior
export default function MyEdit(props) {
const config = {
quickInsertEnabled: false,
tabSpaces: 4,
language: 'zh_cn',
saveInterval: 6000 * 10,
saveMethod: 'POST',
saveURL: 'https://localhost:44343/FileNote',
saveParams: {
id: props.fileId, // 就是希望自动保存时,这个参数是根据传递进来的props的值,但实际它一直是第一次传递进来的值
name: props.name
},
saveParam: 'content',
}
return (
<Editor
config={config}
style={{ height: "100%" }}
/>);
}
望大神解答,谢谢
Hi @andrew2558, please translate your issue to English.
I think you want to custom the Froala component. This is the config file for it https://github.com/huynhsamha/dontpad/blob/master/client/src/utils/FroalaWysiwyg.js.
Froala options you can browse at here.
sorry @huynhsamha
In the froala-edit component, the autosave parameter can only get the props parameter when it is created for the first time, and the autosave parameter is not updated when the props are updated.
Do you have any good solutions?
thanks
export default function MyEdit(props) {
const config = {
quickInsertEnabled: false,
tabSpaces: 4,
language: 'zh_cn',
saveInterval: 6000 * 10,
saveMethod: 'POST',
saveURL: 'https://localhost:44343/FileNote',
saveParams: {
id: props.fileId, // Expect this parameter to be updated when the props of the component are updated
name: props.name
},
saveParam: 'content',
}
return (
<Editor
config={config}
style={{ height: "100%" }}
/>);
}
Hi @andrew2558, I've understood your problem.
I think you should create an issue at https://github.com/froala/react-froala-wysiwyg for your problem.
@huynhsamha ok thanks