Handle paste with text and images, preferring text #438
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
My daughter ran into an interesting bug with our new image handling:
In researching what is happening here, I learned that when you copy text in MS Word, it puts 4 things on the clipboard (i.e., 4 representations of the same text):
The final
image/png
is a bitmap of the formatted text. I guess the idea is to try to maintain the formatting on the text, even if it has to be rendered into an image!The result is that it's impossible to paste text when there's an image representation also in the same clipboard data.
I've updated our paste handling for the prompt form so that it prefers text if the text is available. If you copy an image, we'll only have the image, so that will get used.
I've also added
e.preventDefault()
to the image handling case so that we use our custom handler; however, in the case of text, we let it fall through and do the default thing (e.g. pasting the text).