mirror of
https://github.com/directus/directus.git
synced 2026-01-27 22:57:56 -05:00
@@ -30,6 +30,7 @@
|
||||
"lodash": "^4.17.15",
|
||||
"marked": "^1.1.0",
|
||||
"micromustache": "^7.1.0",
|
||||
"mime-types": "^2.1.27",
|
||||
"nanoid": "^3.1.9",
|
||||
"pinia": "0.0.5",
|
||||
"portal-vue": "^2.1.7",
|
||||
@@ -58,6 +59,7 @@
|
||||
"@types/base-64": "^0.1.3",
|
||||
"@types/jest": "^25.2.2",
|
||||
"@types/marked": "^0.7.4",
|
||||
"@types/mime-types": "^2.1.0",
|
||||
"@types/semver": "^7.2.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.33.0",
|
||||
"@typescript-eslint/parser": "^2.33.0",
|
||||
|
||||
@@ -10,6 +10,7 @@ import DisplayRating from './rating';
|
||||
import DisplayDateTime from './datetime';
|
||||
import DisplayTemplate from './template';
|
||||
import DisplayFilesize from './filesize';
|
||||
import DisplayMimeType from './mime-type';
|
||||
|
||||
export const displays = [
|
||||
DisplayIcon,
|
||||
@@ -24,5 +25,6 @@ export const displays = [
|
||||
DisplayDateTime,
|
||||
DisplayTemplate,
|
||||
DisplayFilesize,
|
||||
DisplayMimeType,
|
||||
];
|
||||
export default displays;
|
||||
|
||||
28
src/displays/mime-type/index.ts
Normal file
28
src/displays/mime-type/index.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import readableMimeType from '@/utils/readable-mime-type';
|
||||
import { extension } from 'mime-types';
|
||||
import { defineDisplay } from '@/displays/define';
|
||||
|
||||
export default defineDisplay(({ i18n }) => ({
|
||||
id: 'mime-type',
|
||||
name: i18n.t('mime-type'),
|
||||
icon: 'picture_as_pdf',
|
||||
options: [
|
||||
{
|
||||
field: 'showAsExtension',
|
||||
name: i18n.t('extension_only'),
|
||||
interface: 'toggle',
|
||||
options: {
|
||||
label: i18n.t('only_show_the_file_extension'),
|
||||
},
|
||||
default_value: false,
|
||||
},
|
||||
],
|
||||
types: ['string'],
|
||||
handler: (value: string, options) => {
|
||||
if (options && options.showAsExtension) {
|
||||
return extension(value);
|
||||
}
|
||||
|
||||
return readableMimeType(value);
|
||||
},
|
||||
}));
|
||||
@@ -4,6 +4,8 @@
|
||||
"half_width": "Half Width",
|
||||
"full_width": "Full Width",
|
||||
"fill_width": "Fill Width",
|
||||
"extension_only": "Extension Only",
|
||||
"only_show_the_file_extension": "Only show the file extension",
|
||||
"hide_field_on_detail": "Hide Field on Detail",
|
||||
"show_field_on_detail": "Show Field on Detail",
|
||||
"delete_field": "Delete Field",
|
||||
|
||||
17
yarn.lock
17
yarn.lock
@@ -1993,6 +1993,11 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/marked/-/marked-0.7.4.tgz#607685669bb1bbde2300bc58ba43486cbbee1f0a"
|
||||
integrity sha512-fdg0NO4qpuHWtZk6dASgsrBggY+8N4dWthl1bAQG9ceKUNKFjqpHaDKCAhRUI6y8vavG7hLSJ4YBwJtZyZEXqw==
|
||||
|
||||
"@types/mime-types@^2.1.0":
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/mime-types/-/mime-types-2.1.0.tgz#9ca52cda363f699c69466c2a6ccdaad913ea7a73"
|
||||
integrity sha1-nKUs2jY/aZxpRmwqbM2q2RPqenM=
|
||||
|
||||
"@types/minimatch@*":
|
||||
version "3.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
|
||||
@@ -9843,6 +9848,11 @@ mime-db@1.43.0, "mime-db@>= 1.43.0 < 2":
|
||||
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.43.0.tgz#0a12e0502650e473d735535050e7c8f4eb4fae58"
|
||||
integrity sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==
|
||||
|
||||
mime-db@1.44.0:
|
||||
version "1.44.0"
|
||||
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92"
|
||||
integrity sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==
|
||||
|
||||
mime-types@^2.1.12, mime-types@~2.1.17, mime-types@~2.1.19, mime-types@~2.1.24:
|
||||
version "2.1.26"
|
||||
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.26.tgz#9c921fc09b7e149a65dfdc0da4d20997200b0a06"
|
||||
@@ -9850,6 +9860,13 @@ mime-types@^2.1.12, mime-types@~2.1.17, mime-types@~2.1.19, mime-types@~2.1.24:
|
||||
dependencies:
|
||||
mime-db "1.43.0"
|
||||
|
||||
mime-types@^2.1.27:
|
||||
version "2.1.27"
|
||||
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.27.tgz#47949f98e279ea53119f5722e0f34e529bec009f"
|
||||
integrity sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==
|
||||
dependencies:
|
||||
mime-db "1.44.0"
|
||||
|
||||
mime@1.6.0:
|
||||
version "1.6.0"
|
||||
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"
|
||||
|
||||
Reference in New Issue
Block a user