Explorar el Código

Add function getClipboardData to preload.js

Sander Borst hace 2 años
padre
commit
3960e94ce8
Se han modificado 1 ficheros con 16 adiciones y 0 borrados
  1. 16 0
      resources/js/preload.js

+ 16 - 0
resources/js/preload.js

@@ -18,6 +18,20 @@ function getFilePathFromClipboard () {
   }
 }
 
+/**
+ * Read the contents of the clipboard for a custom format.
+ * @param  {string} format The custom format to read.
+ * @returns Buffer containing the contents of the clipboard for the specified format, or null if not available.
+ */
+function getClipboardData (format) {
+  if (clipboard.has(mime, "clipboard")) {
+    return clipboard.readBuffer(mime)
+  }
+  else {
+    return null;
+  }
+}
+
 contextBridge.exposeInMainWorld('apis', {
   doAction: async (arg) => {
     return await ipcRenderer.invoke('main', arg)
@@ -172,6 +186,8 @@ contextBridge.exposeInMainWorld('apis', {
 
   getFilePathFromClipboard,
 
+  getClipboardData,
+
   setZoomFactor (factor) {
     webFrame.setZoomFactor(factor)
   },