Pasting image with data URL source
See original GitHub issueDo you want to request a feature or report a bug? It’s hard to say, I’d say missing feature or not handled case.
What is the current behavior? When image with data:
URL is pasted to the editor, that huge, meaningless (for the user) blob of text becomes a content of newly created block. I cannot say it’s not expected behavior (it does make sense for regular URLs, usually not so long and much more readable), but for big images (or even not so big, like 800 x 600 JPG) it causes very poor performance because of amount of data to process. 65K long string
itself is shared under the hood, so that’s not a problem, but CharacterList
of such length may be. As result of that, editor freezes for a moment when image is pasted. Look at example here: https://jsfiddle.net/erykpiast/jwsdokwz/
Once I altered this line to node.textContent = '_'
(it cannot be empty or white-space only for some reason), there is no slow down experienced.
What is the expected behavior? I’m not sure. There may be naive check for data:
URLs, so in such case node text content is set to something like data:image/jpeg;base64
, not a full URL. For “regular” URLs behavior may stay as it is now. Do you think it’d be breaking change that cannot be introduced as a patch?
Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js? Draft 0.10.0, any browser. It’s a “bug” introduced in v0.10 as previous versions didn’t care about pasted images.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
It sounds like @aadsm might pick this up - heads up in case anyone else was looking at working on it.
Thanks again for fixing this @aadsm !