mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-04-10 10:18:24 +00:00
Remove PDF mimetype
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
ed9f4aefab
commit
baa4af7f30
3 changed files with 6 additions and 16 deletions
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
export const supportedMimeTypes: string[] = [
|
||||
'application/pdf',
|
||||
'image/apng',
|
||||
'image/bmp',
|
||||
'image/gif',
|
||||
|
@ -19,5 +18,3 @@ export const supportedMimeTypes: string[] = [
|
|||
'image/tiff',
|
||||
'image/webp'
|
||||
]
|
||||
|
||||
export const supportedMimeTypesJoined = supportedMimeTypes.join(', ')
|
|
@ -11,12 +11,14 @@ import { useTranslation } from 'react-i18next'
|
|||
import { ForkAwesomeIcon } from '../../../common/fork-awesome/fork-awesome-icon'
|
||||
import { UploadInput } from '../../sidebar/upload-input'
|
||||
import { handleUpload } from '../upload-handler'
|
||||
import { supportedMimeTypesJoined } from './utils/upload-image-mimetypes'
|
||||
import { supportedMimeTypes } from '../../../common/upload-image-mimetypes'
|
||||
|
||||
export interface UploadImageButtonProps {
|
||||
editor?: Editor
|
||||
}
|
||||
|
||||
const acceptedMimeTypes = supportedMimeTypes.join(', ')
|
||||
|
||||
export const UploadImageButton: React.FC<UploadImageButtonProps> = ({ editor }) => {
|
||||
const { t } = useTranslation()
|
||||
const clickRef = useRef<() => void>()
|
||||
|
@ -43,7 +45,7 @@ export const UploadImageButton: React.FC<UploadImageButtonProps> = ({ editor })
|
|||
<Button variant='light' onClick={buttonClick} title={t('editor.editorToolbar.uploadImage')}>
|
||||
<ForkAwesomeIcon icon={'upload'} />
|
||||
</Button>
|
||||
<UploadInput onLoad={onUploadImage} acceptedFiles={supportedMimeTypesJoined} onClickRef={clickRef} />
|
||||
<UploadInput onLoad={onUploadImage} acceptedFiles={acceptedMimeTypes} onClickRef={clickRef} />
|
||||
</Fragment>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import { Editor } from 'codemirror'
|
|||
import i18n from 'i18next'
|
||||
import { uploadFile } from '../../../api/media'
|
||||
import { store } from '../../../redux'
|
||||
import { supportedMimeTypes } from './tool-bar/utils/upload-image-mimetypes'
|
||||
import { supportedMimeTypes } from '../../common/upload-image-mimetypes'
|
||||
|
||||
export const handleUpload = (file: File, editor: Editor): void => {
|
||||
if (!file) {
|
||||
|
@ -25,7 +25,7 @@ export const handleUpload = (file: File, editor: Editor): void => {
|
|||
uploadFile(noteId, file)
|
||||
.then(({ link }) => {
|
||||
editor.replaceRange(
|
||||
getCorrectSyntaxForLink(mimeType, link),
|
||||
``,
|
||||
cursor,
|
||||
{
|
||||
line: cursor.line,
|
||||
|
@ -46,12 +46,3 @@ export const handleUpload = (file: File, editor: Editor): void => {
|
|||
)
|
||||
})
|
||||
}
|
||||
|
||||
const getCorrectSyntaxForLink = (mimeType: string, link: string): string => {
|
||||
switch (mimeType) {
|
||||
case 'application/pdf':
|
||||
return `{%pdf ${link} %}`
|
||||
default:
|
||||
return ``
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue