mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-03 02:11:07 +05:30
fix(renderer): add window.electronAPI shim and update CSP for KaTeX
The main window uses nodeIntegration without preload, so window.electronAPI was undefined. This caused the DOMContentLoaded handler to crash at: await window.electronAPI.getAppVersion() which prevented the CodeMirror editor from being created (blank source window) and stopped renderer-ready from being sent (broken menu/options). Fixes: 1. Add window.electronAPI shim at top of renderer.js wrapping ipcRenderer. 2. Update CSP meta tag to allow KaTeX CDN (style-src, script-src, font-src). Amit Haridas
This commit is contained in:
@@ -4,6 +4,17 @@
|
||||
*/
|
||||
|
||||
const { ipcRenderer } = require('electron');
|
||||
|
||||
// Shim window.electronAPI for main window which uses nodeIntegration
|
||||
// without preload script (window.electronAPI is normally set by preload.js).
|
||||
if (typeof window !== 'undefined' && !window.electronAPI) {
|
||||
window.electronAPI = {
|
||||
getAppVersion: () => ipcRenderer.invoke('get-app-version'),
|
||||
invoke: (channel, data) => ipcRenderer.invoke(channel, data),
|
||||
on: (channel, callback) => ipcRenderer.on(channel, (event, ...args) => callback(...args))
|
||||
};
|
||||
}
|
||||
|
||||
const marked = require('marked');
|
||||
const { markedHighlight } = require('marked-highlight');
|
||||
const createDOMPurify = require('dompurify');
|
||||
|
||||
Reference in New Issue
Block a user