Add autosave for comments
This commit is contained in:
parent
881e480819
commit
8d945b4c55
|
@ -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({
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -262,6 +262,7 @@ export function ContractCommentInput(props: {
|
|||
parentAnswerOutcome={parentAnswerOutcome}
|
||||
parentCommentId={parentCommentId}
|
||||
onSubmitComment={onSubmitComment}
|
||||
pageId={contract.id}
|
||||
className={className}
|
||||
/>
|
||||
)
|
||||
|
|
|
@ -94,6 +94,7 @@ export function PostCommentInput(props: {
|
|||
replyTo={replyToUser}
|
||||
parentCommentId={parentCommentId}
|
||||
onSubmitComment={onSubmitComment}
|
||||
pageId={post.id}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user