import { TLVideoShape, track, useEditor, useValue } from '@tldraw/editor' import { useCallback } from 'react' import { useActions } from '../../context/actions' import { useUiEvents } from '../../context/events' import { useTranslation } from '../../hooks/useTranslation/useTranslation' import { TldrawUiButtonIcon } from '../primitives/Button/TldrawUiButtonIcon' import { TldrawUiToolbarButton } from '../primitives/TldrawUiToolbar' /** @public */ export interface DefaultVideoToolbarContentProps { videoShapeId: TLVideoShape['id'] onEditAltTextStart(): void } /** @public @react */ export const DefaultVideoToolbarContent = track(function DefaultVideoToolbarContent({ videoShapeId, onEditAltTextStart, }: DefaultVideoToolbarContentProps) { const editor = useEditor() const trackEvent = useUiEvents() const msg = useTranslation() const source = 'video-toolbar' const isReadonly = editor.getIsReadonly() const actions = useActions() const handleVideoReplace = useCallback( () => actions['video-replace'].onSelect('video-toolbar'), [actions] ) const handleVideoDownload = useCallback( () => actions['download-original'].onSelect('video-toolbar'), [actions] ) const altText = useValue( 'altText', () => editor.getShape(videoShapeId)!.props.altText, [editor, videoShapeId] ) return ( <> {!isReadonly && ( )} {(altText || !isReadonly) && ( { trackEvent('alt-text-start', { source }) onEditAltTextStart() }} > )} ) })