diff --git a/web/components/comment-input.tsx b/web/components/comment-input.tsx index 65a697fe..34553ca6 100644 --- a/web/components/comment-input.tsx +++ b/web/components/comment-input.tsx @@ -17,13 +17,21 @@ export function CommentInput(props: { // Reply to another comment parentCommentId?: string onSubmitComment?: (editor: Editor) => void + // unique id for autosave + pageId: string className?: string }) { - const { parentAnswerOutcome, parentCommentId, replyTo, onSubmitComment } = - props + const { + parentAnswerOutcome, + parentCommentId, + replyTo, + onSubmitComment, + pageId, + } = props const user = useUser() const { editor, upload } = useTextEditor({ + key: `comment ${pageId} ${parentCommentId ?? parentAnswerOutcome ?? ''}`, simple: true, max: MAX_COMMENT_LENGTH, placeholder: @@ -107,7 +115,7 @@ export function CommentInputTextArea(props: { }, }) // insert at mention and focus - if (replyTo) { + if (replyTo && editor.isEmpty) { editor .chain() .setContent({ diff --git a/web/components/editor.tsx b/web/components/editor.tsx index 3491bb2a..36978dc4 100644 --- a/web/components/editor.tsx +++ b/web/components/editor.tsx @@ -105,7 +105,9 @@ export function useTextEditor(props: { ) const editor = useEditor({ - editorProps: { attributes: { class: editorClass, spellcheck: 'false' } }, + editorProps: { + attributes: { class: editorClass, spellcheck: simple ? 'true' : 'false' }, + }, onUpdate: key ? ({ editor }) => save(editor.getJSON()) : undefined, extensions: [ StarterKit.configure({ diff --git a/web/components/feed/feed-comments.tsx b/web/components/feed/feed-comments.tsx index 7111e88f..ad5d0e7d 100644 --- a/web/components/feed/feed-comments.tsx +++ b/web/components/feed/feed-comments.tsx @@ -262,6 +262,7 @@ export function ContractCommentInput(props: { parentAnswerOutcome={parentAnswerOutcome} parentCommentId={parentCommentId} onSubmitComment={onSubmitComment} + pageId={contract.id} className={className} /> ) diff --git a/web/posts/post-comments.tsx b/web/posts/post-comments.tsx index 62f69074..722c16c6 100644 --- a/web/posts/post-comments.tsx +++ b/web/posts/post-comments.tsx @@ -94,6 +94,7 @@ export function PostCommentInput(props: { replyTo={replyToUser} parentCommentId={parentCommentId} onSubmitComment={onSubmitComment} + pageId={post.id} /> ) }