2

I am trying to create a text editor using react-draft-wysiwyg.

Editor code

<Editor 
  editorState={this.state.editorState}
  onEditorStateChange={this.onEditorStateChange}
  toolbar={{
    options: ['inline', 'fontSize', 'fontFamily','list', 
            'textAlign', 'colorPicker', 'link', 'image'],
    link:{
        defaultTargetOption:'_blank',
        popupClassName:"mail-editor-link"
    },
    image:{
        urlEnabled: true,
        uploadEnabled:true,
        uploadCallback:this.uploadImageCallBack,
        alignmentEnabled: true,
        defaultSize: {
            height: 'auto',
            width: 'auto',
        },
        inputAccept: 'image/gif,image/jpeg,image/jpg,image/png,image/svg'
    }
  }}
/>

I would like to add file with extensions like pdfs,txt,docx,xls as attachments. Can anyone guide me how to achieve the file attachment?

aham
  • 137
  • 11

1 Answers1

0

You need to add more MIME types to the inputAccept.

inputAccept: 'application/pdf,text/plain,application/vnd.openxmlformatsofficedocument.wordprocessingml.document,application/msword,application/vnd.ms-excel'

Here is a list of MIME types:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types

Tom Dee
  • 2,516
  • 4
  • 17
  • 25
  • When I change inputAccept I am able to upload the file but after uploading it is shown as image icon – aham Dec 05 '18 at 05:25