Browse Source

feat(nc-gui): convert to tree data format

pull/4931/head
Wing-Kam Wong 2 years ago
parent
commit
7fa2df4f6d
  1. 314
      packages/nc-gui/components/smartsheet/column/utils.ts

314
packages/nc-gui/components/smartsheet/column/utils.ts

@ -11,141 +11,181 @@ export function getRelationName(type: string) {
// supported mime types
// retrieved from https://github.com/sindresorhus/file-type/blob/main/supported.js#L146
export const fileMimeTypes = [
'image/jpeg',
'image/png',
'image/gif',
'image/webp',
'image/flif',
'image/x-xcf',
'image/x-canon-cr2',
'image/x-canon-cr3',
'image/tiff',
'image/bmp',
'image/vnd.ms-photo',
'image/vnd.adobe.photoshop',
'application/x-indesign',
'application/epub+zip',
'application/x-xpinstall',
'application/vnd.oasis.opendocument.text',
'application/vnd.oasis.opendocument.spreadsheet',
'application/vnd.oasis.opendocument.presentation',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/zip',
'application/x-tar',
'application/x-rar-compressed',
'application/gzip',
'application/x-bzip2',
'application/x-7z-compressed',
'application/x-apple-diskimage',
'application/x-apache-arrow',
'video/mp4',
'audio/midi',
'video/x-matroska',
'video/webm',
'video/quicktime',
'video/vnd.avi',
'audio/vnd.wave',
'audio/qcelp',
'audio/x-ms-asf',
'video/x-ms-asf',
'application/vnd.ms-asf',
'video/mpeg',
'video/3gpp',
'audio/mpeg',
'audio/mp4', // RFC 4337
'audio/opus',
'video/ogg',
'audio/ogg',
'application/ogg',
'audio/x-flac',
'audio/ape',
'audio/wavpack',
'audio/amr',
'application/pdf',
'application/x-elf',
'application/x-msdownload',
'application/x-shockwave-flash',
'application/rtf',
'application/wasm',
'font/woff',
'font/woff2',
'application/vnd.ms-fontobject',
'font/ttf',
'font/otf',
'image/x-icon',
'video/x-flv',
'application/postscript',
'application/eps',
'application/x-xz',
'application/x-sqlite3',
'application/x-nintendo-nes-rom',
'application/x-google-chrome-extension',
'application/vnd.ms-cab-compressed',
'application/x-deb',
'application/x-unix-archive',
'application/x-rpm',
'application/x-compress',
'application/x-lzip',
'application/x-cfb',
'application/x-mie',
'application/mxf',
'video/mp2t',
'application/x-blender',
'image/bpg',
'image/jp2',
'image/jpx',
'image/jpm',
'image/mj2',
'audio/aiff',
'application/xml',
'application/x-mobipocket-ebook',
'image/heif',
'image/heif-sequence',
'image/heic',
'image/heic-sequence',
'image/icns',
'image/ktx',
'application/dicom',
'audio/x-musepack',
'text/calendar',
'text/vcard',
'model/gltf-binary',
'application/vnd.tcpdump.pcap',
'audio/x-dsf', // Non-standard
'application/x.ms.shortcut', // Invented by us
'application/x.apple.alias', // Invented by us
'audio/x-voc',
'audio/vnd.dolby.dd-raw',
'audio/x-m4a',
'image/apng',
'image/x-olympus-orf',
'image/x-sony-arw',
'image/x-adobe-dng',
'image/x-nikon-nef',
'image/x-panasonic-rw2',
'image/x-fujifilm-raf',
'video/x-m4v',
'video/3gpp2',
'application/x-esri-shape',
'audio/aac',
'audio/x-it',
'audio/x-s3m',
'audio/x-xm',
'video/MP1S',
'video/MP2P',
'application/vnd.sketchup.skp',
'image/avif',
'application/x-lzh-compressed',
'application/pgp-encrypted',
'application/x-asar',
'model/stl',
'application/vnd.ms-htmlhelp',
'model/3mf',
'image/jxl',
'application/zstd',
'image/jls',
'application/vnd.ms-outlook',
'image/vnd.dwg',
{
title: 'Application',
key: 'application',
children: [
{ title: 'application/dicom', key: 'application/dicom' },
{ title: 'application/eps', key: 'application/eps' },
{ title: 'application/epub+zip', key: 'application/epub+zip' },
{ title: 'application/gzip', key: 'application/gzip' },
{ title: 'application/mxf', key: 'application/mxf' },
{ title: 'application/ogg', key: 'application/ogg' },
{ title: 'application/pdf', key: 'application/pdf' },
{ title: 'application/pgp-encrypted', key: 'application/pgp-encrypted' },
{ title: 'application/postscript', key: 'application/postscript' },
{ title: 'application/rtf', key: 'application/rtf' },
{ title: 'application/vnd.ms-asf', key: 'application/vnd.ms-asf' },
{ title: 'application/vnd.ms-cab-compressed', key: 'application/vnd.ms-cab-compressed' },
{ title: 'application/vnd.ms-fontobject', key: 'application/vnd.ms-fontobject' },
{ title: 'application/vnd.ms-htmlhelp', key: 'application/vnd.ms-htmlhelp' },
{ title: 'application/vnd.ms-outlook', key: 'application/vnd.ms-outlook' },
{ title: 'application/vnd.oasis.opendocument.presentation', key: 'application/vnd.oasis.opendocument.presentation' },
{ title: 'application/vnd.oasis.opendocument.spreadsheet', key: 'application/vnd.oasis.opendocument.spreadsheet' },
{ title: 'application/vnd.oasis.opendocument.text', key: 'application/vnd.oasis.opendocument.text' },
{
title: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
key: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
},
{
title: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
key: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
},
{
title: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
key: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
},
{ title: 'application/vnd.sketchup.skp', key: 'application/vnd.sketchup.skp' },
{ title: 'application/vnd.tcpdump.pcap', key: 'application/vnd.tcpdump.pcap' },
{ title: 'application/wasm', key: 'application/wasm' },
{ title: 'application/x-7z-compressed', key: 'application/x-7z-compressed' },
{ title: 'application/x-apache-arrow', key: 'application/x-apache-arrow' },
{ title: 'application/x-apple-diskimage', key: 'application/x-apple-diskimage' },
{ title: 'application/x-asar', key: 'application/x-asar' },
{ title: 'application/x-blender', key: 'application/x-blender' },
{ title: 'application/x-bzip2', key: 'application/x-bzip2' },
{ title: 'application/x-cfb', key: 'application/x-cfb' },
{ title: 'application/x-compress', key: 'application/x-compress' },
{ title: 'application/x-deb', key: 'application/x-deb' },
{ title: 'application/x-elf', key: 'application/x-elf' },
{ title: 'application/x-esri-shape', key: 'application/x-esri-shape' },
{ title: 'application/x-google-chrome-extension', key: 'application/x-google-chrome-extension' },
{ title: 'application/x-indesign', key: 'application/x-indesign' },
{ title: 'application/x-lzh-compressed', key: 'application/x-lzh-compressed' },
{ title: 'application/x-lzip', key: 'application/x-lzip' },
{ title: 'application/x-mie', key: 'application/x-mie' },
{ title: 'application/x-mobipocket-ebook', key: 'application/x-mobipocket-ebook' },
{ title: 'application/x-msdownload', key: 'application/x-msdownload' },
{ title: 'application/x-nintendo-nes-rom', key: 'application/x-nintendo-nes-rom' },
{ title: 'application/x-rar-compressed', key: 'application/x-rar-compressed' },
{ title: 'application/x-rpm', key: 'application/x-rpm' },
{ title: 'application/x-shockwave-flash', key: 'application/x-shockwave-flash' },
{ title: 'application/x-sqlite3', key: 'application/x-sqlite3' },
{ title: 'application/x-tar', key: 'application/x-tar' },
{ title: 'application/x-unix-archive', key: 'application/x-unix-archive' },
{ title: 'application/x-xpinstall', key: 'application/x-xpinstall' },
{ title: 'application/x-xz', key: 'application/x-xz' },
{ title: 'application/x.apple.alias', key: 'application/x.apple.alias' },
{ title: 'application/x.ms.shortcut', key: 'application/x.ms.shortcut' },
{ title: 'application/xml', key: 'application/xml' },
{ title: 'application/zip', key: 'application/zip' },
{ title: 'application/zstd', key: 'application/zstd' },
],
},
{
title: 'Audio',
key: 'audio',
children: [
{ title: 'audio/aac', key: 'audio/aac' },
{ title: 'audio/aiff', key: 'audio/aiff' },
{ title: 'audio/amr', key: 'audio/amr' },
{ title: 'audio/ape', key: 'audio/ape' },
{ title: 'audio/midi', key: 'audio/midi' },
{ title: 'audio/mp4', key: 'audio/mp4' },
{ title: 'audio/mpeg', key: 'audio/mpeg' },
{ title: 'audio/ogg', key: 'audio/ogg' },
{ title: 'audio/opus', key: 'audio/opus' },
{ title: 'audio/qcelp', key: 'audio/qcelp' },
{ title: 'audio/vnd.dolby.dd-raw', key: 'audio/vnd.dolby.dd-raw' },
{ title: 'audio/vnd.wave', key: 'audio/vnd.wave' },
{ title: 'audio/wavpack', key: 'audio/wavpack' },
{ title: 'audio/x-dsf', key: 'audio/x-dsf' },
{ title: 'audio/x-flac', key: 'audio/x-flac' },
{ title: 'audio/x-it', key: 'audio/x-it' },
{ title: 'audio/x-m4a', key: 'audio/x-m4a' },
{ title: 'audio/x-ms-asf', key: 'audio/x-ms-asf' },
{ title: 'audio/x-musepack', key: 'audio/x-musepack' },
{ title: 'audio/x-s3m', key: 'audio/x-s3m' },
{ title: 'audio/x-voc', key: 'audio/x-voc' },
{ title: 'audio/x-xm', key: 'audio/x-xm' },
],
},
{
title: 'Image',
key: 'image',
children: [
{ title: 'image/apng', key: 'image/apng' },
{ title: 'image/avif', key: 'image/avif' },
{ title: 'image/bmp', key: 'image/bmp' },
{ title: 'image/bpg', key: 'image/bpg' },
{ title: 'image/flif', key: 'image/flif' },
{ title: 'image/gif', key: 'image/gif' },
{ title: 'image/heic', key: 'image/heic' },
{ title: 'image/heic-sequence', key: 'image/heic-sequence' },
{ title: 'image/heif', key: 'image/heif' },
{ title: 'image/heif-sequence', key: 'image/heif-sequence' },
{ title: 'image/icns', key: 'image/icns' },
{ title: 'image/jls', key: 'image/jls' },
{ title: 'image/jp2', key: 'image/jp2' },
{ title: 'image/jpeg', key: 'image/jpeg' },
{ title: 'image/jpm', key: 'image/jpm' },
{ title: 'image/jpx', key: 'image/jpx' },
{ title: 'image/jxl', key: 'image/jxl' },
{ title: 'image/ktx', key: 'image/ktx' },
{ title: 'image/mj2', key: 'image/mj2' },
{ title: 'image/png', key: 'image/png' },
{ title: 'image/tiff', key: 'image/tiff' },
{ title: 'image/vnd.adobe.photoshop', key: 'image/vnd.adobe.photoshop' },
{ title: 'image/vnd.dwg', key: 'image/vnd.dwg' },
{ title: 'image/vnd.ms-photo', key: 'image/vnd.ms-photo' },
{ title: 'image/webp', key: 'image/webp' },
{ title: 'image/x-adobe-dng', key: 'image/x-adobe-dng' },
{ title: 'image/x-canon-cr2', key: 'image/x-canon-cr2' },
{ title: 'image/x-canon-cr3', key: 'image/x-canon-cr3' },
{ title: 'image/x-fujifilm-raf', key: 'image/x-fujifilm-raf' },
{ title: 'image/x-icon', key: 'image/x-icon' },
{ title: 'image/x-nikon-nef', key: 'image/x-nikon-nef' },
{ title: 'image/x-olympus-orf', key: 'image/x-olympus-orf' },
{ title: 'image/x-panasonic-rw2', key: 'image/x-panasonic-rw2' },
{ title: 'image/x-sony-arw', key: 'image/x-sony-arw' },
{ title: 'image/x-xcf', key: 'image/x-xcf' },
],
},
{
title: 'Video',
key: 'video',
children: [
{ title: 'video/3gpp', key: 'video/3gpp' },
{ title: 'video/3gpp2', key: 'video/3gpp2' },
{ title: 'video/MP1S', key: 'video/MP1S' },
{ title: 'video/MP2P', key: 'video/MP2P' },
{ title: 'video/mp2t', key: 'video/mp2t' },
{ title: 'video/mp4', key: 'video/mp4' },
{ title: 'video/mpeg', key: 'video/mpeg' },
{ title: 'video/ogg', key: 'video/ogg' },
{ title: 'video/quicktime', key: 'video/quicktime' },
{ title: 'video/vnd.avi', key: 'video/vnd.avi' },
{ title: 'video/webm', key: 'video/webm' },
{ title: 'video/x-flv', key: 'video/x-flv' },
{ title: 'video/x-m4v', key: 'video/x-m4v' },
{ title: 'video/x-matroska', key: 'video/x-matroska' },
{ title: 'video/x-ms-asf', key: 'video/x-ms-asf' },
],
},
{
title: 'Misc',
key: 'misc',
children: [
{ title: 'model/3mf', key: 'model/3mf' },
{ title: 'model/gltf-binary', key: 'model/gltf-binary' },
{ title: 'model/stl', key: 'model/stl' },
{ title: 'text/calendar', key: 'text/calendar' },
{ title: 'text/vcard', key: 'text/vcard' },
{ title: 'font/otf', key: 'font/otf' },
{ title: 'font/ttf', key: 'font/ttf' },
{ title: 'font/woff', key: 'font/woff' },
{ title: 'font/woff2', key: 'font/woff2' },
],
},
]

Loading…
Cancel
Save