|
|
|
@ -2,8 +2,17 @@ |
|
|
|
|
|
|
|
|
|
const {contextBridge, ipcRenderer} = require("electron"); |
|
|
|
|
|
|
|
|
|
let fileOpenListener = null; |
|
|
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld("api", { |
|
|
|
|
openFileDialog : () => ipcRenderer.send("WindowManager::openFileDialog"), |
|
|
|
|
onFileOpen : callback => ipcRenderer.on("Ation::openFile", (_, presentation) => callback(presentation)), |
|
|
|
|
openFile : filePath => ipcRenderer.send("WindowManager::openFile", filePath) |
|
|
|
|
onFileOpen : callback => { |
|
|
|
|
if (fileOpenListener) |
|
|
|
|
ipcRenderer.off("Ation::openFile", fileOpenListener); |
|
|
|
|
fileOpenListener = (_, presentation) => callback(presentation); |
|
|
|
|
ipcRenderer.on("Ation::openFile", fileOpenListener); |
|
|
|
|
}, |
|
|
|
|
openFile : filePath => ipcRenderer.send("WindowManager::openFile", filePath), |
|
|
|
|
|
|
|
|
|
removeOnFileOpenListener : callback => ipcRenderer.off("Ation::openFile", callback) |
|
|
|
|
}); |