paste event does not have access to the clipboard data

(Working with the patch given in preventDefault does not work in onPaste which added the ‘paste’ event)

The event passed to ‘paste’ does not contain the clipboardData that would normally be present in addEventListener('paste', and so it is not possible to access the clipboard content from the paste handler

See for example jsfiddle - if you paste into the first CM the event does not have clipboardData but does in the second.

I am not sure what is happening here or why there would be a difference between the two versions ?

That’s not an event, that’s a CodeMirror instance. The second argument passed to your handler is the browser event.

yes I see I missed that, it works now :slight_smile: thank you

A request, is it possible to provide ‘copy’ and ‘cut’ as well for completion ? ATM I need to use addEventListener for these two but if I understand correctly they can be provided by CM. This will give allow handling the full clipboard functionality from within CM. (as in the paste markdown scenario etc)

Thx!

Sure. I’ve pushed another patch to also signal cut and copy.