feat(web): improve comment editing and mention rendering

This commit is contained in:
CREDO23 2026-01-19 14:37:45 +02:00
parent f008acecfc
commit 0b675dfc3b
4 changed files with 29 additions and 21 deletions

View file

@ -205,11 +205,11 @@ export function CommentComposer({
// Pre-populate insertedMentions from initialValue when members are loaded
useEffect(() => {
if (mentionsInitialized || !initialValue || members.length === 0) return;
const mentionPattern = /@([^\s@]+(?:\s+[^\s@]+)*?)(?=\s|$|[.,!?;:]|@)/g;
const foundMentions: InsertedMention[] = [];
let match: RegExpExecArray | null;
while ((match = mentionPattern.exec(initialValue)) !== null) {
const displayName = match[1];
const member = members.find(
@ -222,7 +222,7 @@ export function CommentComposer({
}
}
}
if (foundMentions.length > 0) {
setInsertedMentions(foundMentions);
}
@ -239,7 +239,11 @@ export function CommentComposer({
return (
<div className="flex flex-col gap-2">
<Popover open={mentionState.isActive} onOpenChange={(open) => !open && closeMentionPicker()} modal={false}>
<Popover
open={mentionState.isActive}
onOpenChange={(open) => !open && closeMentionPicker()}
modal={false}
>
<PopoverAnchor asChild>
<Textarea
ref={textareaRef}

View file

@ -116,7 +116,7 @@ export function CommentItem({
membersLoading = false,
}: CommentItemProps) {
const [{ data: currentUser }] = useAtom(currentUserAtom);
const isCurrentUser = currentUser?.id === comment.author?.id;
const displayName = isCurrentUser
? "Me"

View file

@ -27,7 +27,12 @@ export interface CommentItemProps {
isReply?: boolean;
isEditing?: boolean;
isSubmitting?: boolean;
members?: Array<{ id: string; displayName: string | null; email: string; avatarUrl?: string | null }>;
members?: Array<{
id: string;
displayName: string | null;
email: string;
avatarUrl?: string | null;
}>;
membersLoading?: boolean;
}

View file

@ -126,31 +126,30 @@ export function CommentThread({
)}
{/* Reply composer or button */}
{isReplyComposerOpen ? (
<>
<div className="pt-3">
<CommentComposer
members={members}
membersLoading={membersLoading}
placeholder="Write a reply..."
submitLabel="Reply"
isSubmitting={isSubmitting}
onSubmit={handleReplySubmit}
onCancel={handleReplyCancel}
autoFocus
/>
</div>
<div className="pt-3">
<CommentComposer
members={members}
membersLoading={membersLoading}
placeholder="Write a reply..."
submitLabel="Reply"
isSubmitting={isSubmitting}
onSubmit={handleReplySubmit}
onCancel={handleReplyCancel}
autoFocus
/>
</div>
</>
) : (
<Button variant="ghost" size="sm" className="h-7 px-2 text-xs" onClick={handleReply}>
<MessageSquare className="mr-1.5 size-3" />
Reply
</Button>
)}
</div>
</div>
</div>
)}
{/* Reply button when no replies yet */}