refactor(skill): remove Office file special handling, merge into unsupported

Remove the Office file placeholder that only showed "Preview will be
supported in a future update" without any download option. Office files
(pdf, doc, docx, xls, xlsx, ppt, pptx) now fall through to the generic
"unsupported file" handler which provides a download button.

Removed:
- OfficeFilePlaceholder component
- isOfficeFile function and OFFICE_EXTENSIONS constant
- isOffice flag from useFileTypeInfo hook
- i18n keys for officePlaceholder

This simplifies the file type handling to just three categories:
- Editable: markdown, code, text files → editor
- Previewable: image, video files → media preview
- Everything else: download button
This commit is contained in:
yyh
2026-01-19 23:39:32 +08:00
parent b3793b0198
commit cab33d440b
6 changed files with 4 additions and 37 deletions

View File

@@ -1,17 +0,0 @@
import type { FC } from 'react'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
const OfficeFilePlaceholder: FC = () => {
const { t } = useTranslation('workflow')
return (
<div className="flex h-full w-full items-center justify-center text-text-tertiary">
<span className="system-sm-regular">
{t('skillEditor.officePlaceholder')}
</span>
</div>
)
}
export default React.memo(OfficeFilePlaceholder)

View File

@@ -5,7 +5,6 @@ import {
isCodeOrTextFile,
isImageFile,
isMarkdownFile,
isOfficeFile,
isVideoFile,
} from '../utils/file-utils'
@@ -14,14 +13,13 @@ export type FileTypeInfo = {
isCodeOrText: boolean
isImage: boolean
isVideo: boolean
isOffice: boolean
isEditable: boolean
isMediaFile: boolean
}
/**
* Hook to determine file type information based on file node.
* Returns flags for markdown, code/text, image, video, office files.
* Returns flags for markdown, code/text, image, video files.
*/
export function useFileTypeInfo(fileNode: AppAssetTreeView | undefined): FileTypeInfo {
return useMemo(() => {
@@ -36,7 +34,6 @@ export function useFileTypeInfo(fileNode: AppAssetTreeView | undefined): FileTyp
isCodeOrText: codeOrText,
isImage: image,
isVideo: video,
isOffice: isOfficeFile(ext),
isEditable: markdown || codeOrText,
isMediaFile: image || video,
}

View File

@@ -15,7 +15,6 @@ import { basePath } from '@/utils/var'
import CodeFileEditor from './editor/code-file-editor'
import MarkdownFileEditor from './editor/markdown-file-editor'
import MediaFilePreview from './editor/media-file-preview'
import OfficeFilePlaceholder from './editor/office-file-placeholder'
import UnsupportedFileDownload from './editor/unsupported-file-download'
import { useFileTypeInfo } from './hooks/use-file-type-info'
import { useSkillAssetNodeMap } from './hooks/use-skill-asset-tree'
@@ -44,7 +43,7 @@ const SkillDocEditor: FC = () => {
const currentFileNode = activeTabId ? nodeMap?.get(activeTabId) : undefined
const { isMarkdown, isCodeOrText, isImage, isVideo, isOffice, isEditable } = useFileTypeInfo(currentFileNode)
const { isMarkdown, isCodeOrText, isImage, isVideo, isEditable } = useFileTypeInfo(currentFileNode)
const { fileContent, downloadUrlData, isLoading, error } = useSkillFileData(appId, activeTabId, isEditable)
@@ -150,11 +149,11 @@ const SkillDocEditor: FC = () => {
)
}
// For non-editable files (media, office, unsupported), use download URL
// For non-editable files (media, unsupported), use download URL
const downloadUrl = downloadUrlData?.download_url || ''
const fileName = currentFileNode?.name || ''
const fileSize = currentFileNode?.size
const isUnsupportedFile = !isMarkdown && !isCodeOrText && !isImage && !isVideo && !isOffice
const isUnsupportedFile = !isMarkdown && !isCodeOrText && !isImage && !isVideo
return (
<div className="h-full w-full overflow-auto bg-components-panel-bg">
@@ -187,11 +186,6 @@ const SkillDocEditor: FC = () => {
/>
)
: null}
{isOffice
? (
<OfficeFilePlaceholder />
)
: null}
{isUnsupportedFile
? (
<UnsupportedFileDownload

View File

@@ -5,7 +5,6 @@ const CODE_EXTENSIONS = ['json', 'yaml', 'yml', 'toml', 'js', 'jsx', 'ts', 'tsx'
const TEXT_EXTENSIONS = ['txt', 'log', 'ini', 'env']
const IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg', 'bmp', 'ico']
const VIDEO_EXTENSIONS = ['mp4', 'mov', 'webm', 'mpeg', 'mpg', 'm4v', 'avi']
const OFFICE_EXTENSIONS = ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']
export function getFileExtension(name?: string, extension?: string): string {
if (extension)
@@ -43,10 +42,6 @@ export function isVideoFile(extension: string): boolean {
return VIDEO_EXTENSIONS.includes(extension)
}
export function isOfficeFile(extension: string): boolean {
return OFFICE_EXTENSIONS.includes(extension)
}
export function getFileLanguage(name: string): string {
const extension = name.split('.').pop()?.toLowerCase() ?? ''

View File

@@ -995,7 +995,6 @@
"singleRun.testRun": "Test Run",
"singleRun.testRunIteration": "Test Run Iteration",
"singleRun.testRunLoop": "Test Run Loop",
"skillEditor.officePlaceholder": "Preview will be supported in a future update",
"skillEditor.previewUnavailable": "Preview unavailable",
"skillEditor.referenceFiles": "Reference files",
"skillEditor.unsupportedPreview": "This file type is not supported for preview",

View File

@@ -989,7 +989,6 @@
"singleRun.testRun": "测试运行",
"singleRun.testRunIteration": "测试运行迭代",
"singleRun.testRunLoop": "测试运行循环",
"skillEditor.officePlaceholder": "预览功能将在后续版本支持",
"skillEditor.previewUnavailable": "无法预览",
"skillEditor.referenceFiles": "引用文件",
"skillEditor.unsupportedPreview": "该文件类型不支持预览",