mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-22 22:38:43 +00:00
Merge pull request #26 from shumaiOne/feat/improve-drawing-annotations
feat(chat): improve annotation drawing, typing, and list badges
This commit is contained in:
@@ -3,11 +3,11 @@ import type { UserInfo } from '@/dtos/team'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { Button } from '@/ui/components/ui/button'
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/ui/components/ui/dialog'
|
||||
import { Separator } from '@/ui/components/ui/separator'
|
||||
import { formatTimeAgo } from '@/ui/lib/time'
|
||||
@@ -16,6 +16,7 @@ import { Download, File, Terminal } from 'lucide-react'
|
||||
import React from 'react'
|
||||
import Markdown from 'react-markdown'
|
||||
import { Avatar, AvatarFallback } from '../ui/avatar'
|
||||
import { DrawAnnotation } from '../ui/icons'
|
||||
import { Skeleton } from '../ui/skeleton'
|
||||
import { formatTimestamp } from '../viewers/utils'
|
||||
|
||||
@@ -81,6 +82,8 @@ export const MessageCard: React.FC<MessageCardProps> = ({
|
||||
})
|
||||
|
||||
const message = polledMessage || initialMessage
|
||||
const hasDrawInfo =
|
||||
!!message.annotations && Array.isArray(message.annotations) && message.annotations.length > 0
|
||||
const creator = message.creator
|
||||
const showSkeleton =
|
||||
!!message.sessionId && !!message.message && message.message in AI_PLACEHOLDERS
|
||||
@@ -182,6 +185,15 @@ export const MessageCard: React.FC<MessageCardProps> = ({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{hasDrawInfo && (
|
||||
<div
|
||||
className="float-left select-none bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-300 px-1 py-1 mt-[2px] mr-2 rounded-sm text-xs leading-none font-bold flex items-center gap-1"
|
||||
title="Contains drawing annotations"
|
||||
>
|
||||
<DrawAnnotation className="w-3.5 h-3.5" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{showSkeleton ? (
|
||||
<div className="space-y-2">
|
||||
<Skeleton className="h-4 w-3/4" />
|
||||
|
||||
@@ -599,13 +599,11 @@ export const ChatInput = React.forwardRef<HTMLDivElement, ChatInputProps>(
|
||||
)}
|
||||
<div
|
||||
ref={editorRef}
|
||||
contentEditable={!isDrawing}
|
||||
contentEditable
|
||||
suppressContentEditableWarning
|
||||
onInput={handleInput}
|
||||
onKeyDown={handleKeyDown}
|
||||
data-placeholder={
|
||||
isDrawing ? 'Drawing active...' : replyingTo ? 'Reply...' : 'Message...'
|
||||
}
|
||||
data-placeholder={replyingTo ? 'Reply...' : 'Message...'}
|
||||
className={`bg-transparent border-none focus:ring-0 resize-none min-h-[40px] leading-relaxed py-2 focus:outline-none block ${isTimestampEnabled && currentTime !== undefined && frameRate !== undefined && !hasContent ? 'pl-[120px]' : ''}`}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -379,7 +379,7 @@ const DrawingCanvas = ({
|
||||
width={boxWidth}
|
||||
height={boxHeight}
|
||||
stroke={annotation.color}
|
||||
strokeWidth={2 / scale}
|
||||
strokeWidth={2.6 / scale}
|
||||
listening={false}
|
||||
/>
|
||||
)
|
||||
@@ -391,7 +391,7 @@ const DrawingCanvas = ({
|
||||
key={i}
|
||||
points={points}
|
||||
stroke={annotation.color}
|
||||
strokeWidth={2 / scale}
|
||||
strokeWidth={2.6 / scale}
|
||||
fill={annotation.color}
|
||||
pointerLength={10 / scale}
|
||||
pointerWidth={10 / scale}
|
||||
@@ -407,7 +407,7 @@ const DrawingCanvas = ({
|
||||
key={i}
|
||||
points={points}
|
||||
stroke={annotation.color}
|
||||
strokeWidth={2 / scale}
|
||||
strokeWidth={2.6 / scale}
|
||||
tension={0.5}
|
||||
lineCap="round"
|
||||
lineJoin="round"
|
||||
@@ -463,16 +463,16 @@ const DrawingCanvas = ({
|
||||
<Group listening={false}>
|
||||
<Line
|
||||
ref={currentLineRef}
|
||||
strokeWidth={2 / scale}
|
||||
strokeWidth={2.6 / scale}
|
||||
lineCap="round"
|
||||
lineJoin="round"
|
||||
visible={false}
|
||||
/>
|
||||
<Rect ref={currentRectRef} strokeWidth={2 / scale} visible={false} />
|
||||
<Rect ref={currentRectRef} strokeWidth={2.6 / scale} visible={false} />
|
||||
<Arrow
|
||||
ref={currentArrowRef}
|
||||
points={[]}
|
||||
strokeWidth={2 / scale}
|
||||
strokeWidth={2.6 / scale}
|
||||
pointerLength={10 / scale}
|
||||
pointerWidth={10 / scale}
|
||||
visible={false}
|
||||
|
||||
Reference in New Issue
Block a user