From f548dd23fd465a0a490808baa36b0e6854c789e3 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Wed, 24 Jul 2024 07:23:26 +0000 Subject: [PATCH] feat: support office file types --- .../components/cell/attachment/Carousel.vue | 13 +++++++ .../cell/attachment/Preview/MiscOffice.vue | 37 +++++++++++++++++++ packages/nc-gui/utils/fileUtils.ts | 37 ++++++++++++++++++- 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 packages/nc-gui/components/cell/attachment/Preview/MiscOffice.vue diff --git a/packages/nc-gui/components/cell/attachment/Carousel.vue b/packages/nc-gui/components/cell/attachment/Carousel.vue index 6f2e8280b2..8ec0cdba4b 100644 --- a/packages/nc-gui/components/cell/attachment/Carousel.vue +++ b/packages/nc-gui/components/cell/attachment/Carousel.vue @@ -1,6 +1,7 @@ + + + + diff --git a/packages/nc-gui/utils/fileUtils.ts b/packages/nc-gui/utils/fileUtils.ts index 46c1f6f350..94eec1e448 100644 --- a/packages/nc-gui/utils/fileUtils.ts +++ b/packages/nc-gui/utils/fileUtils.ts @@ -36,6 +36,37 @@ const videoExt = [ 'ts', ] +const officeExt = [ + 'txt', + 'css', + 'html', + 'php', + 'c', + 'cpp', + 'h', + 'hpp', + 'js', + 'doc', + 'docx', + 'xls', + 'xlsx', + 'ppt', + 'pptx', + 'pdf', + 'pages', + 'ai', + 'psd', + 'tiff', + 'dxf', + 'svg', + 'eps', + 'ps', + 'ttf', + 'xps', + 'zip', + 'rar', +] + const isVideo = (name: string, mimetype?: string) => { return videoExt.some((e) => name?.toLowerCase().endsWith(`.${e}`)) || mimetype?.startsWith('video/') } @@ -48,7 +79,11 @@ const isPdf = (name: string, mimetype?: string) => { return name?.toLowerCase().endsWith('.pdf') || mimetype?.startsWith('application/pdf') } -export { isImage, imageExt, isVideo, isPdf } +const isOffice = (name: string, mimetype?: string) => { + return officeExt.some((e) => name?.toLowerCase().endsWith(`.${e}`)) +} + +export { isImage, imageExt, isVideo, isPdf, isOffice } // Ref : https://stackoverflow.com/a/12002275 // Tested in Mozilla Firefox browser, Chrome