Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get clipboard type in Electron

I'm using GitHub's Electron to build a desktop app. I want to grab the type of the current clipboard contents in order to better use it (eg. if it's HTML then I want to do something different than if it's just text).

Looking at the docs there's no way to check the type, but type is required to properly read it. Is there an easy way to get the type?

Relevant docs.

like image 513
Mike Avatar asked Mar 17 '16 18:03

Mike


1 Answers

clipboard.availableFormats() actually returns the assumed mime-type of the clipboard contents. So, to test for plain text, it's simply plain/text, for images, something along the lines of image/png or image/jpeg is expected.

like image 121
Mike Avatar answered Nov 18 '22 09:11

Mike