mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-03 14:34:40 +00:00
feat(webui): support custom timestamp formatting for PDF viewer comments (P9)
This commit is contained in:
@@ -51,6 +51,7 @@ interface MessageCardProps {
|
|||||||
onSelect?: () => void
|
onSelect?: () => void
|
||||||
frameRate?: number
|
frameRate?: number
|
||||||
startTimecode?: string
|
startTimecode?: string
|
||||||
|
formatTimestamp?: (second: number) => string
|
||||||
rootParentId?: string
|
rootParentId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +112,7 @@ export const MessageCard: React.FC<MessageCardProps> = ({
|
|||||||
onSelect,
|
onSelect,
|
||||||
frameRate,
|
frameRate,
|
||||||
startTimecode,
|
startTimecode,
|
||||||
|
formatTimestamp,
|
||||||
}) => {
|
}) => {
|
||||||
const message = initialMessage
|
const message = initialMessage
|
||||||
const hasDrawInfo =
|
const hasDrawInfo =
|
||||||
@@ -124,10 +126,14 @@ export const MessageCard: React.FC<MessageCardProps> = ({
|
|||||||
|
|
||||||
const { videoTimeDisplayMode } = useUiStore()
|
const { videoTimeDisplayMode } = useUiStore()
|
||||||
const displayTime = React.useMemo(() => {
|
const displayTime = React.useMemo(() => {
|
||||||
if (message.second === null || message.second === undefined || !frameRate) return ''
|
if (message.second === null || message.second === undefined) return ''
|
||||||
|
if (formatTimestamp) {
|
||||||
|
return formatTimestamp(message.second)
|
||||||
|
}
|
||||||
|
if (!frameRate) return ''
|
||||||
const frameIndex = Math.round(message.second * frameRate)
|
const frameIndex = Math.round(message.second * frameRate)
|
||||||
return formatTimecode(frameIndex, frameRate, videoTimeDisplayMode, startTimecode)
|
return formatTimecode(frameIndex, frameRate, videoTimeDisplayMode, startTimecode)
|
||||||
}, [message.second, frameRate, videoTimeDisplayMode, startTimecode])
|
}, [message.second, frameRate, videoTimeDisplayMode, startTimecode, formatTimestamp])
|
||||||
|
|
||||||
const { data: me } = useQuery({
|
const { data: me } = useQuery({
|
||||||
queryKey: ['teams', teamId, 'me'],
|
queryKey: ['teams', teamId, 'me'],
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ interface ChatInputProps {
|
|||||||
currentTime?: number
|
currentTime?: number
|
||||||
frameRate?: number
|
frameRate?: number
|
||||||
startTimecode?: string
|
startTimecode?: string
|
||||||
|
formatTimestamp?: (second: number) => string
|
||||||
onTyping?: () => void
|
onTyping?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,6 +89,7 @@ export const ChatInput = React.forwardRef<HTMLDivElement, ChatInputProps>(
|
|||||||
currentTime,
|
currentTime,
|
||||||
frameRate,
|
frameRate,
|
||||||
startTimecode,
|
startTimecode,
|
||||||
|
formatTimestamp,
|
||||||
onTyping,
|
onTyping,
|
||||||
},
|
},
|
||||||
ref,
|
ref,
|
||||||
@@ -98,10 +100,14 @@ export const ChatInput = React.forwardRef<HTMLDivElement, ChatInputProps>(
|
|||||||
|
|
||||||
const { videoTimeDisplayMode } = useUiStore()
|
const { videoTimeDisplayMode } = useUiStore()
|
||||||
const displayTime = React.useMemo(() => {
|
const displayTime = React.useMemo(() => {
|
||||||
if (currentTime === undefined || !frameRate) return ''
|
if (currentTime === undefined) return ''
|
||||||
|
if (formatTimestamp) {
|
||||||
|
return formatTimestamp(currentTime)
|
||||||
|
}
|
||||||
|
if (!frameRate) return ''
|
||||||
const frameIndex = Math.round(currentTime * frameRate)
|
const frameIndex = Math.round(currentTime * frameRate)
|
||||||
return formatTimecode(frameIndex, frameRate, videoTimeDisplayMode, startTimecode)
|
return formatTimecode(frameIndex, frameRate, videoTimeDisplayMode, startTimecode)
|
||||||
}, [currentTime, frameRate, videoTimeDisplayMode, startTimecode])
|
}, [currentTime, frameRate, videoTimeDisplayMode, startTimecode, formatTimestamp])
|
||||||
|
|
||||||
const { teamId, ensureTeamIdForProject } = useTeamContextStore()
|
const { teamId, ensureTeamIdForProject } = useTeamContextStore()
|
||||||
const { members: storeMembers, loading: membersLoading, fetchMembers } = useMemberStore()
|
const { members: storeMembers, loading: membersLoading, fetchMembers } = useMemberStore()
|
||||||
@@ -135,7 +141,12 @@ export const ChatInput = React.forwardRef<HTMLDivElement, ChatInputProps>(
|
|||||||
const [hasContent, setHasContent] = useState(false)
|
const [hasContent, setHasContent] = useState(false)
|
||||||
|
|
||||||
const paddingLeftClass = React.useMemo(() => {
|
const paddingLeftClass = React.useMemo(() => {
|
||||||
if (!isTimestampEnabled || currentTime === undefined || !frameRate || hasContent) {
|
if (
|
||||||
|
!isTimestampEnabled ||
|
||||||
|
currentTime === undefined ||
|
||||||
|
(!formatTimestamp && !frameRate) ||
|
||||||
|
hasContent
|
||||||
|
) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
if (videoTimeDisplayMode === 'timecode') {
|
if (videoTimeDisplayMode === 'timecode') {
|
||||||
|
|||||||
@@ -355,6 +355,7 @@ export function FileViewerRightSidebar({
|
|||||||
onReply={setReplyingTo}
|
onReply={setReplyingTo}
|
||||||
onViewAttachment={setViewingAttachment}
|
onViewAttachment={setViewingAttachment}
|
||||||
hasReplies={!!comment.replies?.length}
|
hasReplies={!!comment.replies?.length}
|
||||||
|
formatTimestamp={viewerDef?.commentsConfig?.formatTimestamp}
|
||||||
frameRate={
|
frameRate={
|
||||||
viewerDef?.commentsConfig?.hasTimestamp
|
viewerDef?.commentsConfig?.hasTimestamp
|
||||||
? file?.media?.metadata?.frameRate || 30
|
? file?.media?.metadata?.frameRate || 30
|
||||||
@@ -381,6 +382,7 @@ export function FileViewerRightSidebar({
|
|||||||
onViewAttachment={setViewingAttachment}
|
onViewAttachment={setViewingAttachment}
|
||||||
hasReplies={false}
|
hasReplies={false}
|
||||||
isLastReply={index === (comment.replies?.length ?? 0) - 1}
|
isLastReply={index === (comment.replies?.length ?? 0) - 1}
|
||||||
|
formatTimestamp={viewerDef?.commentsConfig?.formatTimestamp}
|
||||||
frameRate={
|
frameRate={
|
||||||
viewerDef?.commentsConfig?.hasTimestamp
|
viewerDef?.commentsConfig?.hasTimestamp
|
||||||
? file?.media?.metadata?.frameRate || 30
|
? file?.media?.metadata?.frameRate || 30
|
||||||
@@ -419,6 +421,7 @@ export function FileViewerRightSidebar({
|
|||||||
hideAnnotationControl={hideAnnotationControl}
|
hideAnnotationControl={hideAnnotationControl}
|
||||||
disableMentions={isPublic}
|
disableMentions={isPublic}
|
||||||
currentTime={viewerDef?.commentsConfig?.hasTimestamp ? currentTime : undefined}
|
currentTime={viewerDef?.commentsConfig?.hasTimestamp ? currentTime : undefined}
|
||||||
|
formatTimestamp={viewerDef?.commentsConfig?.formatTimestamp}
|
||||||
frameRate={
|
frameRate={
|
||||||
viewerDef?.commentsConfig?.hasTimestamp
|
viewerDef?.commentsConfig?.hasTimestamp
|
||||||
? file?.media?.metadata?.frameRate || 30
|
? file?.media?.metadata?.frameRate || 30
|
||||||
|
|||||||
@@ -10,5 +10,6 @@ export const pdfTypeDefinition: FileTypeDefinition = {
|
|||||||
hasTimestamp: true,
|
hasTimestamp: true,
|
||||||
hasAnnotations: true,
|
hasAnnotations: true,
|
||||||
hasAiBots: true,
|
hasAiBots: true,
|
||||||
|
formatTimestamp: (second: number) => `P${Math.round(second)}`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,5 +49,6 @@ export interface FileTypeDefinition {
|
|||||||
hasTimestamp?: boolean
|
hasTimestamp?: boolean
|
||||||
hasAnnotations?: boolean
|
hasAnnotations?: boolean
|
||||||
hasAiBots?: boolean
|
hasAiBots?: boolean
|
||||||
|
formatTimestamp?: (second: number) => string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user