update 9/5/21: new version of the plugin with the copy image function from this PR has been posted! see here.
I’m trying to bang away again at fixing the Right Click → Copy image function from my fork of NomarCub’s obsidian-copy-url-in-preview plugin.
I know I need to assemble a
NativeImage object to write it to the clipboard with
Does any kind soul know how I might access the
contents.copyImageAt(x, y) function from within a plugin? It seems from reading the
webContents docs that I need to import
BrowserWindow but I don’t know how to access the
contents. object for the view that Obsidian has already created.
The “solution” I came up with before was to grab the properties of the clicked element and literally read the file from disk or re-download the image again… embarrassingly inefficient and obviously doesn’t work if you’re offline or the webserver has died
There must be a way to just copy the blob / base64 image data off the canvas and shove it into the clipboard without reaching out to the filesystem or making http requests…
Can anyone help?