mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-02 05:54:44 +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 { client } from '@/ui/api/client'
|
||||||
import { Button } from '@/ui/components/ui/button'
|
import { Button } from '@/ui/components/ui/button'
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
DialogDescription,
|
DialogDescription,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from '@/ui/components/ui/dialog'
|
} from '@/ui/components/ui/dialog'
|
||||||
import { Separator } from '@/ui/components/ui/separator'
|
import { Separator } from '@/ui/components/ui/separator'
|
||||||
import { formatTimeAgo } from '@/ui/lib/time'
|
import { formatTimeAgo } from '@/ui/lib/time'
|
||||||
@@ -16,6 +16,7 @@ import { Download, File, Terminal } from 'lucide-react'
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import Markdown from 'react-markdown'
|
import Markdown from 'react-markdown'
|
||||||
import { Avatar, AvatarFallback } from '../ui/avatar'
|
import { Avatar, AvatarFallback } from '../ui/avatar'
|
||||||
|
import { DrawAnnotation } from '../ui/icons'
|
||||||
import { Skeleton } from '../ui/skeleton'
|
import { Skeleton } from '../ui/skeleton'
|
||||||
import { formatTimestamp } from '../viewers/utils'
|
import { formatTimestamp } from '../viewers/utils'
|
||||||
|
|
||||||
@@ -81,6 +82,8 @@ export const MessageCard: React.FC<MessageCardProps> = ({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const message = polledMessage || initialMessage
|
const message = polledMessage || initialMessage
|
||||||
|
const hasDrawInfo =
|
||||||
|
!!message.annotations && Array.isArray(message.annotations) && message.annotations.length > 0
|
||||||
const creator = message.creator
|
const creator = message.creator
|
||||||
const showSkeleton =
|
const showSkeleton =
|
||||||
!!message.sessionId && !!message.message && message.message in AI_PLACEHOLDERS
|
!!message.sessionId && !!message.message && message.message in AI_PLACEHOLDERS
|
||||||
@@ -182,6 +185,15 @@ export const MessageCard: React.FC<MessageCardProps> = ({
|
|||||||
</div>
|
</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 ? (
|
{showSkeleton ? (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Skeleton className="h-4 w-3/4" />
|
<Skeleton className="h-4 w-3/4" />
|
||||||
|
|||||||
@@ -599,13 +599,11 @@ export const ChatInput = React.forwardRef<HTMLDivElement, ChatInputProps>(
|
|||||||
)}
|
)}
|
||||||
<div
|
<div
|
||||||
ref={editorRef}
|
ref={editorRef}
|
||||||
contentEditable={!isDrawing}
|
contentEditable
|
||||||
suppressContentEditableWarning
|
suppressContentEditableWarning
|
||||||
onInput={handleInput}
|
onInput={handleInput}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
data-placeholder={
|
data-placeholder={replyingTo ? 'Reply...' : 'Message...'}
|
||||||
isDrawing ? 'Drawing active...' : 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]' : ''}`}
|
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>
|
</div>
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ const DrawingCanvas = ({
|
|||||||
width={boxWidth}
|
width={boxWidth}
|
||||||
height={boxHeight}
|
height={boxHeight}
|
||||||
stroke={annotation.color}
|
stroke={annotation.color}
|
||||||
strokeWidth={2 / scale}
|
strokeWidth={2.6 / scale}
|
||||||
listening={false}
|
listening={false}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
@@ -391,7 +391,7 @@ const DrawingCanvas = ({
|
|||||||
key={i}
|
key={i}
|
||||||
points={points}
|
points={points}
|
||||||
stroke={annotation.color}
|
stroke={annotation.color}
|
||||||
strokeWidth={2 / scale}
|
strokeWidth={2.6 / scale}
|
||||||
fill={annotation.color}
|
fill={annotation.color}
|
||||||
pointerLength={10 / scale}
|
pointerLength={10 / scale}
|
||||||
pointerWidth={10 / scale}
|
pointerWidth={10 / scale}
|
||||||
@@ -407,7 +407,7 @@ const DrawingCanvas = ({
|
|||||||
key={i}
|
key={i}
|
||||||
points={points}
|
points={points}
|
||||||
stroke={annotation.color}
|
stroke={annotation.color}
|
||||||
strokeWidth={2 / scale}
|
strokeWidth={2.6 / scale}
|
||||||
tension={0.5}
|
tension={0.5}
|
||||||
lineCap="round"
|
lineCap="round"
|
||||||
lineJoin="round"
|
lineJoin="round"
|
||||||
@@ -463,16 +463,16 @@ const DrawingCanvas = ({
|
|||||||
<Group listening={false}>
|
<Group listening={false}>
|
||||||
<Line
|
<Line
|
||||||
ref={currentLineRef}
|
ref={currentLineRef}
|
||||||
strokeWidth={2 / scale}
|
strokeWidth={2.6 / scale}
|
||||||
lineCap="round"
|
lineCap="round"
|
||||||
lineJoin="round"
|
lineJoin="round"
|
||||||
visible={false}
|
visible={false}
|
||||||
/>
|
/>
|
||||||
<Rect ref={currentRectRef} strokeWidth={2 / scale} visible={false} />
|
<Rect ref={currentRectRef} strokeWidth={2.6 / scale} visible={false} />
|
||||||
<Arrow
|
<Arrow
|
||||||
ref={currentArrowRef}
|
ref={currentArrowRef}
|
||||||
points={[]}
|
points={[]}
|
||||||
strokeWidth={2 / scale}
|
strokeWidth={2.6 / scale}
|
||||||
pointerLength={10 / scale}
|
pointerLength={10 / scale}
|
||||||
pointerWidth={10 / scale}
|
pointerWidth={10 / scale}
|
||||||
visible={false}
|
visible={false}
|
||||||
|
|||||||
Reference in New Issue
Block a user