mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 18:10:18 +05:30
Fix critical bugs in v1.7.8: file association and print preview
- Fixed command-line argument parsing for packaged apps using app.isPackaged - Fixed print preview to show markdown content instead of toolbar - Rewrote print handler to rely on CSS @media print rules - Enhanced CSS with attribute selectors for dynamic preview panes - Removed DevTools auto-open for production build - Updated version to 1.7.8 across all files 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
+42
-22
@@ -68,17 +68,24 @@ if (!gotTheLock) {
|
||||
}
|
||||
|
||||
// Check if a file was passed to the second instance
|
||||
// commandLine is an array like: ['electron.exe', 'app.asar', 'file.md']
|
||||
const fileArgs = commandLine.slice(2);
|
||||
// commandLine is an array like: ['PanConverter.exe', 'file.md']
|
||||
console.log('[MAIN] Second instance commandLine:', JSON.stringify(commandLine));
|
||||
const startIndex = app.isPackaged ? 1 : 2;
|
||||
const fileArgs = commandLine.slice(startIndex);
|
||||
console.log('[MAIN] Second instance file args:', fileArgs);
|
||||
for (const arg of fileArgs) {
|
||||
if ((arg.endsWith('.md') || arg.endsWith('.markdown')) && fs.existsSync(arg)) {
|
||||
// Open the file in the existing instance
|
||||
if (rendererReady) {
|
||||
openFileFromPath(arg);
|
||||
} else {
|
||||
app.pendingFile = arg;
|
||||
if ((arg.endsWith('.md') || arg.endsWith('.markdown'))) {
|
||||
const resolvedPath = path.isAbsolute(arg) ? arg : path.resolve(workingDirectory, arg);
|
||||
console.log('[MAIN] Second instance resolved path:', resolvedPath);
|
||||
if (fs.existsSync(resolvedPath)) {
|
||||
// Open the file in the existing instance
|
||||
if (rendererReady) {
|
||||
openFileFromPath(resolvedPath);
|
||||
} else {
|
||||
app.pendingFile = resolvedPath;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -112,9 +119,6 @@ function createWindow() {
|
||||
|
||||
mainWindow.loadFile(path.join(__dirname, 'index.html'));
|
||||
|
||||
// Open DevTools for debugging
|
||||
mainWindow.webContents.openDevTools();
|
||||
|
||||
createMenu();
|
||||
|
||||
mainWindow.on('closed', () => {
|
||||
@@ -463,7 +467,7 @@ function createMenu() {
|
||||
type: 'info',
|
||||
title: 'About PanConverter',
|
||||
message: 'PanConverter',
|
||||
detail: 'A cross-platform Markdown editor and converter using Pandoc.\n\nVersion: 1.7.7\nAuthor: Amit Haridas\nEmail: amit.wh@gmail.com\nLicense: MIT\n\nFeatures:\n• Modern glassmorphism UI with gradient backgrounds\n• Comprehensive PDF Editor (merge, split, compress, rotate, watermark, encrypt)\n• Universal File Converter (LibreOffice, ImageMagick, FFmpeg, Pandoc)\n• Windows Explorer context menu integration\n• Tabbed interface for multiple files\n• Advanced markdown editing with live preview\n• Real-time preview updates while typing\n• Full toolbar markdown editing functions\n• Enhanced PDF export with built-in Electron fallback\n• File association support for .md files\n• Command-line interface for batch conversion\n• Advanced export options with templates and metadata\n• Batch file conversion with progress tracking\n• Improved preview typography and spacing\n• Adjustable font sizes via menu (Ctrl+Shift+Plus/Minus)\n• Complete theme support including Monokai fixes\n• Find & replace with match highlighting\n• Line numbers and auto-indentation\n• Export to multiple formats via Pandoc\n• PowerPoint & presentation export\n• Export tables to Excel/ODS spreadsheets\n• Document import & conversion\n• Table creation helper\n• 22 beautiful themes (including Dracula, Nord, Tokyo Night, Gruvbox, Ayu, Concrete, and more)\n• Undo/redo functionality\n• Live word count and statistics',
|
||||
detail: 'A cross-platform Markdown editor and converter using Pandoc.\n\nVersion: 1.7.8\nAuthor: Amit Haridas\nEmail: amit.wh@gmail.com\nLicense: MIT\n\nFeatures:\n• Modern glassmorphism UI with gradient backgrounds\n• Comprehensive PDF Editor (merge, split, compress, rotate, watermark, encrypt)\n• Universal File Converter (LibreOffice, ImageMagick, FFmpeg, Pandoc)\n• Windows Explorer context menu integration\n• Tabbed interface for multiple files\n• Advanced markdown editing with live preview\n• Real-time preview updates while typing\n• Full toolbar markdown editing functions\n• Enhanced PDF export with built-in Electron fallback\n• File association support for .md files\n• Command-line interface for batch conversion\n• Advanced export options with templates and metadata\n• Batch file conversion with progress tracking\n• Improved preview typography and spacing\n• Adjustable font sizes via menu (Ctrl+Shift+Plus/Minus)\n• Complete theme support including Monokai fixes\n• Find & replace with match highlighting\n• Line numbers and auto-indentation\n• Export to multiple formats via Pandoc\n• PowerPoint & presentation export\n• Export tables to Excel/ODS spreadsheets\n• Document import & conversion\n• Table creation helper\n• 22 beautiful themes (including Dracula, Nord, Tokyo Night, Gruvbox, Ayu, Concrete, and more)\n• Undo/redo functionality\n• Live word count and statistics',
|
||||
buttons: ['OK']
|
||||
});
|
||||
}
|
||||
@@ -1596,16 +1600,32 @@ app.whenReady().then(() => {
|
||||
createWindow();
|
||||
|
||||
// Handle file association on app startup
|
||||
// Process all command line arguments except the first two (node and script path)
|
||||
const fileArgs = process.argv.slice(2);
|
||||
console.log('[MAIN] Command line args:', process.argv);
|
||||
console.log('[MAIN] File args to process:', fileArgs);
|
||||
// In packaged apps, process.argv structure is different:
|
||||
// Development: ['electron', 'app.js', 'file.md'] - need slice(2)
|
||||
// Packaged: ['PanConverter.exe', 'file.md'] - need slice(1)
|
||||
// We'll check all arguments after the executable
|
||||
console.log('[MAIN] Full command line args:', JSON.stringify(process.argv));
|
||||
console.log('[MAIN] App is packaged:', app.isPackaged);
|
||||
|
||||
// Start from index 1 (skip executable) and check each argument
|
||||
const startIndex = app.isPackaged ? 1 : 2;
|
||||
const fileArgs = process.argv.slice(startIndex);
|
||||
console.log('[MAIN] File args to process (starting from index', startIndex + '):', fileArgs);
|
||||
|
||||
for (const arg of fileArgs) {
|
||||
if ((arg.endsWith('.md') || arg.endsWith('.markdown')) && fs.existsSync(arg)) {
|
||||
// Store the file to open after window is ready
|
||||
console.log('[MAIN] Setting pendingFile to:', arg);
|
||||
app.pendingFile = arg;
|
||||
break;
|
||||
console.log('[MAIN] Checking arg:', arg);
|
||||
if ((arg.endsWith('.md') || arg.endsWith('.markdown'))) {
|
||||
// Try to resolve the path (might be relative)
|
||||
const resolvedPath = path.isAbsolute(arg) ? arg : path.resolve(process.cwd(), arg);
|
||||
console.log('[MAIN] Resolved path:', resolvedPath);
|
||||
if (fs.existsSync(resolvedPath)) {
|
||||
// Store the file to open after window is ready
|
||||
console.log('[MAIN] Setting pendingFile to:', resolvedPath);
|
||||
app.pendingFile = resolvedPath;
|
||||
break;
|
||||
} else {
|
||||
console.log('[MAIN] File does not exist:', resolvedPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log('[MAIN] Final app.pendingFile:', app.pendingFile);
|
||||
|
||||
+11
-53
@@ -1184,65 +1184,23 @@ function handlePrintPreview(withStyles) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Hide UI elements
|
||||
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) {
|
||||
editorPane.style.display = 'none';
|
||||
// Add print style classes to body for styling control
|
||||
// The @media print CSS will handle hiding toolbar/tabs automatically
|
||||
if (!withStyles) {
|
||||
document.body.classList.add('printing-no-styles');
|
||||
}
|
||||
document.body.classList.add('printing');
|
||||
|
||||
// Hide all dialogs
|
||||
const dialogs = [
|
||||
'export-dialog', 'batch-dialog', 'pdf-editor-dialog',
|
||||
'converter-dialog', 'find-dialog'
|
||||
];
|
||||
dialogs.forEach(id => {
|
||||
const dialog = document.getElementById(id);
|
||||
if (dialog) dialog.style.display = 'none';
|
||||
});
|
||||
|
||||
// Apply print-mode to preview pane
|
||||
const previewPane = document.getElementById(`preview-pane-${activeTabId}`);
|
||||
if (previewPane) {
|
||||
previewPane.classList.add('print-mode');
|
||||
if (!withStyles) {
|
||||
previewPane.classList.add('print-no-styles');
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for DOM to render the changes before printing
|
||||
// Use setTimeout to ensure browser has time to repaint
|
||||
// Give browser time to apply classes before printing
|
||||
setTimeout(() => {
|
||||
// Tell main process to print - the DOM is now fully rendered
|
||||
// Tell main process to print
|
||||
ipcRenderer.send('do-print', { withStyles });
|
||||
|
||||
// Restore UI after a delay (printer will have captured the output by then)
|
||||
// Restore classes after print dialog appears
|
||||
setTimeout(() => {
|
||||
if (toolbar) toolbar.style.display = '';
|
||||
if (tabBar) tabBar.style.display = '';
|
||||
if (statusBar) statusBar.style.display = '';
|
||||
|
||||
if (editorPane) {
|
||||
editorPane.style.display = '';
|
||||
}
|
||||
|
||||
dialogs.forEach(id => {
|
||||
const dialog = document.getElementById(id);
|
||||
if (dialog) dialog.style.display = '';
|
||||
});
|
||||
|
||||
if (previewPane) {
|
||||
previewPane.classList.remove('print-mode', 'print-no-styles');
|
||||
}
|
||||
}, 500);
|
||||
}, 300);
|
||||
document.body.classList.remove('printing', 'printing-no-styles');
|
||||
}, 1000);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
// Export Dialog functionality
|
||||
|
||||
+21
-3
@@ -2833,14 +2833,19 @@ body.theme-concrete-warm .status-bar {
|
||||
#editor-container,
|
||||
.editor-container,
|
||||
#status-bar,
|
||||
.status-bar {
|
||||
.status-bar,
|
||||
.editor-pane,
|
||||
[id^="editor-pane-"] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Show preview in full width */
|
||||
#preview,
|
||||
.preview,
|
||||
.preview-content {
|
||||
.preview-content,
|
||||
[id^="preview-"],
|
||||
[id^="preview-pane-"],
|
||||
.tab-content {
|
||||
display: block !important;
|
||||
width: 100% !important;
|
||||
max-width: 100% !important;
|
||||
@@ -2848,10 +2853,12 @@ body.theme-concrete-warm .status-bar {
|
||||
margin: 0 !important;
|
||||
padding: 20px !important;
|
||||
overflow: visible !important;
|
||||
position: static !important;
|
||||
}
|
||||
|
||||
/* Optimize preview content for printing */
|
||||
.preview-content {
|
||||
.preview-content,
|
||||
[id^="preview-"] {
|
||||
line-height: 1.6;
|
||||
font-size: 12pt;
|
||||
color: #000 !important;
|
||||
@@ -2969,11 +2976,20 @@ body.theme-concrete-warm .status-bar {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
/* No-styles printing mode */
|
||||
body.printing-no-styles .preview-content,
|
||||
body.printing-no-styles [id^="preview-"],
|
||||
.print-no-styles .preview-content {
|
||||
color: #000 !important;
|
||||
background: white !important;
|
||||
}
|
||||
|
||||
body.printing-no-styles .preview-content h1,
|
||||
body.printing-no-styles .preview-content h2,
|
||||
body.printing-no-styles .preview-content h3,
|
||||
body.printing-no-styles .preview-content h4,
|
||||
body.printing-no-styles .preview-content h5,
|
||||
body.printing-no-styles .preview-content h6,
|
||||
.print-no-styles .preview-content h1,
|
||||
.print-no-styles .preview-content h2,
|
||||
.print-no-styles .preview-content h3,
|
||||
@@ -2984,11 +3000,13 @@ body.theme-concrete-warm .status-bar {
|
||||
border-color: #999 !important;
|
||||
}
|
||||
|
||||
body.printing-no-styles .preview-content code,
|
||||
.print-no-styles .preview-content code {
|
||||
background: #f5f5f5 !important;
|
||||
color: #000 !important;
|
||||
}
|
||||
|
||||
body.printing-no-styles .preview-content pre,
|
||||
.print-no-styles .preview-content pre {
|
||||
background: #f5f5f5 !important;
|
||||
color: #000 !important;
|
||||
|
||||
Reference in New Issue
Block a user