question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pasting image with data URL source

See original GitHub issue

Do 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:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
flarniecommented, Aug 29, 2017

It sounds like @aadsm might pick this up - heads up in case anyone else was looking at working on it.

0reactions
flarniecommented, Sep 5, 2017

Thanks again for fixing this @aadsm !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Copy image with src="dataUrl" to Office application
I seem to be able to past "Data-Url" images to paint. Pasting to Word/Excel fails. unless the paste special option is used. Example:...
Read more >
Copy image as data URI - Chrome Developers
Right click on an image preview within the Resources Panel to copy it as a Data URI (base 64 encoded).
Read more >
Data URIs | CSS-Tricks
You can embed the image data directly into the document with data URIs. (It's equally correct to say “Data URL”, which I think...
Read more >
How to Copy a Web Image's URL - Lifewire
Go to the image whose address you want to copy. Screenshot of copying an image's URL · Right-click on the image and select...
Read more >
Image to Data URI Converter - Tech Grapple
You can either upload the image from your computer or paste any image URL and hit Enter key. The Data URI will now...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found