mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-10-01 17:29:29 +05:30
fix(renderer): migrate File.path reads to webUtils.getPathForFile for Electron 41
This commit is contained in:
+16
-1
@@ -12,7 +12,7 @@
|
||||
* @version 4.4.1
|
||||
*/
|
||||
|
||||
const { contextBridge, ipcRenderer } = require('electron');
|
||||
const { contextBridge, ipcRenderer, webUtils } = require('electron');
|
||||
|
||||
// Define allowed IPC channels for security
|
||||
const ALLOWED_SEND_CHANNELS = [
|
||||
@@ -431,6 +431,21 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
updateSettings: (settings) => ipcRenderer.send('update-page-settings', settings),
|
||||
},
|
||||
|
||||
/**
|
||||
* Resolve a File object chosen via `<input type="file">` to its absolute
|
||||
* path. `File.path` was removed in Electron 32; `webUtils.getPathForFile`
|
||||
* is its replacement. Falls back to `file.path` on older Electron where
|
||||
* webUtils is unavailable.
|
||||
* @param {File} file - File object from a file input's files list
|
||||
* @returns {string | undefined} Absolute filesystem path when resolvable
|
||||
*/
|
||||
getFilePath: (file) => {
|
||||
if (webUtils && typeof webUtils.getPathForFile === 'function') {
|
||||
return webUtils.getPathForFile(file);
|
||||
}
|
||||
return file && file.path;
|
||||
},
|
||||
|
||||
// PDF Operations
|
||||
pdf: {
|
||||
processOperation: (data) => ipcRenderer.send('process-pdf-operation', data),
|
||||
|
||||
Reference in New Issue
Block a user