jpuri / react-draft-wysiwyg

A Wysiwyg editor build on top of ReactJS and DraftJS. https://jpuri.github.io/react-draft-wysiwyg
MIT License
6.41k stars 1.16k forks source link

toolbarCustomButtons throws e.getSelection error #1130

Open lorenzo-octoenergy opened 3 years ago

lorenzo-octoenergy commented 3 years ago

Unable to add a file-uploader as a toolbar custom button!

Attempting to select a file to upload causes react-draft-wysiwyg to throw an error:

Screenshot 2021-05-21 at 13 18 21

Code Sandbox: https://codesandbox.io/s/angry-sunset-kt3wj

Steps to reproduce:

  1. Load sandbox from above.
  2. Click on 'Choose file` button.
  3. Select any file in the popup dialog and click 'Open'.
xithalius commented 1 year ago

This issue is still present btw. Any work-arounds are appreciated.

xithalius commented 1 year ago

Caused by https://github.com/jpuri/react-draft-wysiwyg/blob/b5a6b84053f8d4725e334a9cbd141c73f1dc73d2/src/Editor/index.js#LL183. Tested by setting read-only to true.