Files
dify/web/app/components/workflow/skill/viewer/media-file-preview.tsx
yyh bc9ce23fdc refactor(skill): rename components for semantic clarity
Rename components and reorganize directory structure:
- skill-doc-editor.tsx → file-content-panel.tsx (handles edit/preview/download)
- editor-area.tsx → content-area.tsx
- editor-body.tsx → content-body.tsx
- editor-tabs.tsx → file-tabs.tsx
- editor-tab-item.tsx → file-tab-item.tsx

Create viewer/ directory for non-editor components:
- Move media-file-preview.tsx from editor/ to viewer/
- Move unsupported-file-download.tsx from editor/ to viewer/

This clarifies the distinction between:
- editor/: actual file editors (code, markdown)
- viewer/: preview and download components (media, unsupported files)
2026-01-19 23:50:08 +08:00

44 lines
1003 B
TypeScript

import type { FC } from 'react'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
type MediaFilePreviewProps = {
type: 'image' | 'video'
src: string
}
const MediaFilePreview: FC<MediaFilePreviewProps> = ({ type, src }) => {
const { t } = useTranslation('workflow')
if (!src) {
return (
<div className="flex h-full w-full items-center justify-center text-text-tertiary">
<span className="system-sm-regular">
{t('skillEditor.previewUnavailable')}
</span>
</div>
)
}
return (
<div className="flex h-full w-full items-center justify-center p-6">
{type === 'image' && (
<img
src={src}
alt=""
className="max-h-full max-w-full object-contain"
/>
)}
{type === 'video' && (
<video
src={src}
controls
className="max-h-full max-w-full"
/>
)}
</div>
)
}
export default React.memo(MediaFilePreview)