27 lines
1.3 KiB
JavaScript
27 lines
1.3 KiB
JavaScript
const { contextBridge, ipcRenderer, webUtils } = require('electron')
|
|
|
|
|
|
contextBridge.exposeInMainWorld('electron', {
|
|
node: () => process.versions.node,
|
|
chrome: () => process.versions.chrome,
|
|
electron: () => process.versions.electron,
|
|
});
|
|
|
|
contextBridge.exposeInMainWorld('main', {
|
|
onMenuActions: (callback) => ipcRenderer.on('menu-actions', (_event, action) => callback(action)),
|
|
quit: () => ipcRenderer.invoke("quit"),
|
|
toggleFullScreen: () => ipcRenderer.invoke("toggleFullScreen"),
|
|
});
|
|
|
|
contextBridge.exposeInMainWorld('fs', {
|
|
getLspConfigData: () => ipcRenderer.invoke("getLspConfigData"),
|
|
getFileContents: (path) => ipcRenderer.invoke("getFileContents", path),
|
|
openFiles: (startPath) => ipcRenderer.invoke("openFiles", startPath),
|
|
saveFile: (path, content) => ipcRenderer.invoke("saveFile", path, content),
|
|
saveFileAs: (content) => ipcRenderer.invoke("saveFileAs", content),
|
|
closeFile: (path) => ipcRenderer.invoke("closeFile", path),
|
|
getPathForFile: (file) => webUtils.getPathForFile(file),
|
|
onLoadFiles: (callback) => ipcRenderer.on('load-files', (_event, paths) => callback(paths)),
|
|
onChangedFile: (callback) => ipcRenderer.on('file-changed', (_event, path) => callback(path)),
|
|
onDeletedFile: (callback) => ipcRenderer.on('file-deleted', (_event, path) => callback(path)),
|
|
}); |