v3: added user profile description
This commit is contained in:
@@ -69,8 +69,8 @@ function CommentNode({
|
||||
|
||||
const children = tree.get(comment.id) ?? [];
|
||||
|
||||
async function handleReply(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
async function handleReply(e?: React.FormEvent) {
|
||||
e?.preventDefault();
|
||||
if (!replyBody.trim() || !token) return;
|
||||
setSubmitting(true);
|
||||
setReplyError(null);
|
||||
@@ -109,8 +109,8 @@ function CommentNode({
|
||||
}
|
||||
}
|
||||
|
||||
async function handleEditSave(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
async function handleEditSave(e?: React.FormEvent) {
|
||||
e?.preventDefault();
|
||||
if (!editBody.trim() || !token) return;
|
||||
setEditSubmitting(true);
|
||||
setEditError(null);
|
||||
@@ -226,11 +226,7 @@ function CommentNode({
|
||||
className="comment-reply-textarea"
|
||||
value={editBody}
|
||||
onChange={setEditBody}
|
||||
onKeyDown={(e) => {
|
||||
if (
|
||||
e.key === "Enter" && (e.ctrlKey || e.metaKey)
|
||||
) handleEditSave(e);
|
||||
}}
|
||||
onSubmit={handleEditSave}
|
||||
autoResize
|
||||
rows={1}
|
||||
/>
|
||||
@@ -314,11 +310,7 @@ function CommentNode({
|
||||
className="comment-reply-textarea"
|
||||
value={replyBody}
|
||||
onChange={setReplyBody}
|
||||
onKeyDown={(e) => {
|
||||
if (
|
||||
e.key === "Enter" && (e.ctrlKey || e.metaKey)
|
||||
) handleReply(e);
|
||||
}}
|
||||
onSubmit={handleReply}
|
||||
placeholder="Write a reply…"
|
||||
autoResize
|
||||
rows={1}
|
||||
@@ -391,8 +383,8 @@ export function CommentThread({
|
||||
const tree = buildTree(comments);
|
||||
const roots = tree.get("root") ?? [];
|
||||
|
||||
async function handleTopLevelSubmit(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
async function handleTopLevelSubmit(e?: React.FormEvent) {
|
||||
e?.preventDefault();
|
||||
if (!topLevelBody.trim() || !token) return;
|
||||
setSubmitting(true);
|
||||
setTopLevelError(null);
|
||||
@@ -444,11 +436,7 @@ export function CommentThread({
|
||||
className="comment-reply-textarea"
|
||||
value={topLevelBody}
|
||||
onChange={setTopLevelBody}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
||||
handleTopLevelSubmit(e);
|
||||
}
|
||||
}}
|
||||
onSubmit={handleTopLevelSubmit}
|
||||
placeholder="Add a comment…"
|
||||
autoResize
|
||||
rows={1}
|
||||
|
||||
@@ -17,6 +17,7 @@ interface TextEditorProps {
|
||||
id?: string;
|
||||
className?: string;
|
||||
autoResize?: boolean;
|
||||
onSubmit?: () => void;
|
||||
onKeyDown?: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
||||
}
|
||||
|
||||
@@ -31,6 +32,7 @@ export const TextEditor = forwardRef<TextEditorHandle, TextEditorProps>(
|
||||
id,
|
||||
className,
|
||||
autoResize = false,
|
||||
onSubmit,
|
||||
onKeyDown,
|
||||
},
|
||||
ref,
|
||||
@@ -84,6 +86,11 @@ export const TextEditor = forwardRef<TextEditorHandle, TextEditorProps>(
|
||||
detectEmojiTrigger(e.target.value, e.target.selectionStart ?? 0);
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
||||
e.preventDefault();
|
||||
onSubmit?.();
|
||||
return;
|
||||
}
|
||||
handleMentionKeyDown(e);
|
||||
if (!e.defaultPrevented) onKeyDown?.(e);
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user