Binds a paste event handler. This also prevents Ctrl+C/Cmd+C/Shift+Insert presses from going to the game.
handler_script can be a script/function taking the following arguments:
-
data: for pasted text this is the text itself while for other formats it'll be base64 string such as"data:image/png;base64,..." -
name: name of the file pasted.
If the name is unknown, this is"".
For pasted text, this isundefined.
(comparing it toundefinedis how you figure out whether to decode base64) -
type: MIME type of whatever that you've got here.
filter_script can be a script/function taking the following arguments:
-
kind:"string"for text or"file"for files. -
type: MIME type of the item.
it can then return true or false based on whether you want to have it passed on to the handler_script.
Discarding unsupported files early can spare the page from loading files that you weren't going to process anyway.
If the handler is omitted (browser_paste_bind()), unbinds the handler.