feat: audio drag-drop and paste support (#9152)

This commit is contained in:
Dante
2026-02-24 18:59:57 +09:00
committed by GitHub
parent 09989b7aff
commit 02a38110cd
6 changed files with 265 additions and 30 deletions

View File

@@ -0,0 +1,26 @@
import { describe, expect, it } from 'vitest'
import { hasAudioType, hasImageType } from './eventUtils'
describe('hasImageType', () => {
it('should return true for image types', () => {
expect(hasImageType({ type: 'image/png' } as File)).toBe(true)
expect(hasImageType({ type: 'image/jpeg' } as File)).toBe(true)
})
it('should return false for non-image types', () => {
expect(hasImageType({ type: 'audio/mpeg' } as File)).toBe(false)
expect(hasImageType({ type: 'video/mp4' } as File)).toBe(false)
})
})
describe('hasAudioType', () => {
it('should return true for audio types', () => {
expect(hasAudioType({ type: 'audio/mpeg' } as File)).toBe(true)
expect(hasAudioType({ type: 'audio/wav' } as File)).toBe(true)
})
it('should return false for non-audio types', () => {
expect(hasAudioType({ type: 'image/png' } as File)).toBe(false)
expect(hasAudioType({ type: 'video/mp4' } as File)).toBe(false)
})
})

View File

@@ -28,3 +28,7 @@ export async function extractFilesFromDragEvent(
export function hasImageType({ type }: File): boolean {
return type.startsWith('image')
}
export function hasAudioType({ type }: File): boolean {
return type.startsWith('audio')
}