Add Clipboard component for handling global on_paste event #3513
+263
−1
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.
Supersede #3078 to fix #3055
Creates a new
rx.clipboard
component withon_paste
handler that will be called when pasting data into the page. If it has children components, then only those components will register thepaste
handler, otherwise, it gets registered at the top-leveldocument
(you can also passtargets
prop as a list of ids).The handler will be called with the data arg as list of tuples of
(mime_type, data)
. If the data is text, it will be a regular string. If the data is associated with a different type, then it will be returned as a base64 encoded data uri. There may be multiple entries in the data list for example if the data is available in several formats (text/plain
andtext/html
) or if several files have been pasted from the filesystem.Sample code