mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-23 19:47:03 -04: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[] = [
|
export const supportedMimeTypes: string[] = [
|
||||||
'application/pdf',
|
|
||||||
'image/apng',
|
'image/apng',
|
||||||
'image/bmp',
|
'image/bmp',
|
||||||
'image/gif',
|
'image/gif',
|
||||||
|
@ -19,5 +18,3 @@ export const supportedMimeTypes: string[] = [
|
||||||
'image/tiff',
|
'image/tiff',
|
||||||
'image/webp'
|
'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 { ForkAwesomeIcon } from '../../../common/fork-awesome/fork-awesome-icon'
|
||||||
import { UploadInput } from '../../sidebar/upload-input'
|
import { UploadInput } from '../../sidebar/upload-input'
|
||||||
import { handleUpload } from '../upload-handler'
|
import { handleUpload } from '../upload-handler'
|
||||||
import { supportedMimeTypesJoined } from './utils/upload-image-mimetypes'
|
import { supportedMimeTypes } from '../../../common/upload-image-mimetypes'
|
||||||
|
|
||||||
export interface UploadImageButtonProps {
|
export interface UploadImageButtonProps {
|
||||||
editor?: Editor
|
editor?: Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const acceptedMimeTypes = supportedMimeTypes.join(', ')
|
||||||
|
|
||||||
export const UploadImageButton: React.FC<UploadImageButtonProps> = ({ editor }) => {
|
export const UploadImageButton: React.FC<UploadImageButtonProps> = ({ editor }) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const clickRef = useRef<() => void>()
|
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')}>
|
<Button variant='light' onClick={buttonClick} title={t('editor.editorToolbar.uploadImage')}>
|
||||||
<ForkAwesomeIcon icon={'upload'} />
|
<ForkAwesomeIcon icon={'upload'} />
|
||||||
</Button>
|
</Button>
|
||||||
<UploadInput onLoad={onUploadImage} acceptedFiles={supportedMimeTypesJoined} onClickRef={clickRef} />
|
<UploadInput onLoad={onUploadImage} acceptedFiles={acceptedMimeTypes} onClickRef={clickRef} />
|
||||||
</Fragment>
|
</Fragment>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { Editor } from 'codemirror'
|
||||||
import i18n from 'i18next'
|
import i18n from 'i18next'
|
||||||
import { uploadFile } from '../../../api/media'
|
import { uploadFile } from '../../../api/media'
|
||||||
import { store } from '../../../redux'
|
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 => {
|
export const handleUpload = (file: File, editor: Editor): void => {
|
||||||
if (!file) {
|
if (!file) {
|
||||||
|
@ -25,7 +25,7 @@ export const handleUpload = (file: File, editor: Editor): void => {
|
||||||
uploadFile(noteId, file)
|
uploadFile(noteId, file)
|
||||||
.then(({ link }) => {
|
.then(({ link }) => {
|
||||||
editor.replaceRange(
|
editor.replaceRange(
|
||||||
getCorrectSyntaxForLink(mimeType, link),
|
``,
|
||||||
cursor,
|
cursor,
|
||||||
{
|
{
|
||||||
line: cursor.line,
|
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
Add a link
Reference in a new issue