mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 18:10:18 +05:30
Fix print null errors and add main process logging to renderer console
- Added null checks for toolbar, tab-bar, status-bar before accessing .style - Prevents TypeError when elements don't exist - Added executeJavaScript to send main process logs to renderer console - Now we can see main process state in DevTools - Print should now work without errors 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1183,10 +1183,19 @@ ipcMain.on('do-print', (event, { withStyles }) => {
|
||||
// Handle renderer ready for file association
|
||||
ipcMain.on('renderer-ready', (event) => {
|
||||
console.log('[MAIN] renderer-ready received, rendererReady was:', rendererReady);
|
||||
if (mainWindow) {
|
||||
mainWindow.webContents.executeJavaScript(`console.log('[MAIN->RENDERER] renderer-ready received, rendererReady was: ${rendererReady}')`);
|
||||
}
|
||||
rendererReady = true;
|
||||
console.log('[MAIN] app.pendingFile:', app.pendingFile);
|
||||
if (mainWindow) {
|
||||
mainWindow.webContents.executeJavaScript(`console.log('[MAIN->RENDERER] app.pendingFile: ${app.pendingFile}')`);
|
||||
}
|
||||
if (app.pendingFile) {
|
||||
console.log('[MAIN] Opening pending file:', app.pendingFile);
|
||||
if (mainWindow) {
|
||||
mainWindow.webContents.executeJavaScript(`console.log('[MAIN->RENDERER] Opening pending file: ${app.pendingFile}')`);
|
||||
}
|
||||
openFileFromPath(app.pendingFile);
|
||||
app.pendingFile = null;
|
||||
}
|
||||
|
||||
+10
-6
@@ -1185,9 +1185,13 @@ function handlePrintPreview(withStyles) {
|
||||
}
|
||||
|
||||
// Hide UI elements
|
||||
document.getElementById('toolbar').style.display = 'none';
|
||||
document.getElementById('tab-bar').style.display = 'none';
|
||||
document.getElementById('status-bar').style.display = 'none';
|
||||
const toolbar = document.getElementById('toolbar');
|
||||
const tabBar = document.getElementById('tab-bar');
|
||||
const statusBar = document.getElementById('status-bar');
|
||||
|
||||
if (toolbar) toolbar.style.display = 'none';
|
||||
if (tabBar) tabBar.style.display = 'none';
|
||||
if (statusBar) statusBar.style.display = 'none';
|
||||
|
||||
const editorPane = document.getElementById(`editor-pane-${activeTabId}`);
|
||||
if (editorPane) {
|
||||
@@ -1221,9 +1225,9 @@ function handlePrintPreview(withStyles) {
|
||||
|
||||
// Restore UI after a delay (printer will have captured the output by then)
|
||||
setTimeout(() => {
|
||||
document.getElementById('toolbar').style.display = '';
|
||||
document.getElementById('tab-bar').style.display = '';
|
||||
document.getElementById('status-bar').style.display = '';
|
||||
if (toolbar) toolbar.style.display = '';
|
||||
if (tabBar) tabBar.style.display = '';
|
||||
if (statusBar) statusBar.style.display = '';
|
||||
|
||||
if (editorPane) {
|
||||
editorPane.style.display = '';
|
||||
|
||||
Reference in New Issue
Block a user