Skip to content

Commit a057a4c

Browse files
Added "file" fileType to lexical uploader
refs TryGhost/Product#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.
1 parent 234853a commit a057a4c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ghost/admin/app/components/koenig-lexical-editor.js

+8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export const fileTypes = {
3131
endpoint: '/media/thumbnail/upload/',
3232
requestMethod: 'put',
3333
resourceName: 'media'
34+
},
35+
file: {
36+
endpoint: '/files/upload/',
37+
resourceName: 'files'
3438
}
3539
};
3640

@@ -177,6 +181,10 @@ export default class KoenigLexicalEditor extends Component {
177181
// we only check the file extension by default because IE doesn't always
178182
// expose the mime-type, we'll rely on the API for final validation
179183
function defaultValidator(file) {
184+
// if type is file we don't need to validate since the card can accept any file type
185+
if (type === 'file') {
186+
return true;
187+
}
180188
let extensions = fileTypes[type].extensions;
181189
let [, extension] = (/(?:\.([^.]+))?$/).exec(file.name);
182190

0 commit comments

Comments
 (0)