fix: fix autosaving
This commit is contained in:
@@ -82,7 +82,6 @@ export default function TinyMCEEditor(props) {
|
||||
a11y_advanced_options: true,
|
||||
autosave_interval: '1s',
|
||||
autosave_restore_when_empty: true,
|
||||
autosave_prefix: 'tinymce-autosave-{path}{query}',
|
||||
plugins: 'autosave codesample link lists image imagetools code',
|
||||
toolbar: 'formatselect | bold italic underline'
|
||||
+ ' | link blockquote openedx_code image'
|
||||
|
||||
@@ -27,6 +27,9 @@ function CommentEditor({
|
||||
}
|
||||
onCloseEditor();
|
||||
};
|
||||
// The editorId is used to autosave contents to localstorage. This format means that the autosave is scoped to
|
||||
// the current comment id, or the current comment parent or the curren thread.
|
||||
const editorId = `comment-editor-${comment.id || comment.parentId || comment.threadId}`;
|
||||
return (
|
||||
<Formik
|
||||
initialValues={{ comment: comment.rawBody }}
|
||||
@@ -48,6 +51,7 @@ function CommentEditor({
|
||||
<>
|
||||
<Form onSubmit={handleSubmit}>
|
||||
<TinyMCEEditor
|
||||
id={editorId}
|
||||
value={values.comment}
|
||||
onEditorChange={formikCompatibleHandler(handleChange, 'comment')}
|
||||
onBlur={formikCompatibleHandler(handleBlur, 'comment')}
|
||||
|
||||
@@ -171,6 +171,8 @@ function PostEditor({
|
||||
};
|
||||
}
|
||||
|
||||
const postEditorId = `post-editor-${editExisting ? postId : 'new'}`;
|
||||
|
||||
return (
|
||||
<Formik
|
||||
enableReinitialize
|
||||
@@ -302,6 +304,7 @@ function PostEditor({
|
||||
</Form.Group>
|
||||
<div className="py-2">
|
||||
<TinyMCEEditor
|
||||
id={postEditorId}
|
||||
value={values.comment}
|
||||
onEditorChange={formikCompatibleHandler(handleChange, 'comment')}
|
||||
onBlur={formikCompatibleHandler(handleBlur, 'comment')}
|
||||
|
||||
Reference in New Issue
Block a user