From a057a4cb3d4f6dc58065231c4096133f583e7a8d Mon Sep 17 00:00:00 2001 From: Ronald Langeveld Date: Mon, 27 Mar 2023 10:33:55 +0800 Subject: [PATCH] Added "file" `fileType` to lexical uploader refs https://github.com/TryGhost/Team/issues/2634 Added suport for type "file" which refers to basically any non-specific file type for use on the file card. Bypasses validation when a file gets uploaded. --- ghost/admin/app/components/koenig-lexical-editor.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ghost/admin/app/components/koenig-lexical-editor.js b/ghost/admin/app/components/koenig-lexical-editor.js index 818e543aca..00eeeff668 100644 --- a/ghost/admin/app/components/koenig-lexical-editor.js +++ b/ghost/admin/app/components/koenig-lexical-editor.js @@ -31,6 +31,10 @@ export const fileTypes = { endpoint: '/media/thumbnail/upload/', requestMethod: 'put', resourceName: 'media' + }, + file: { + endpoint: '/files/upload/', + resourceName: 'files' } }; @@ -177,6 +181,10 @@ export default class KoenigLexicalEditor extends Component { // we only check the file extension by default because IE doesn't always // expose the mime-type, we'll rely on the API for final validation function defaultValidator(file) { + // if type is file we don't need to validate since the card can accept any file type + if (type === 'file') { + return true; + } let extensions = fileTypes[type].extensions; let [, extension] = (/(?:\.([^.]+))?$/).exec(file.name);