mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 10:00:17 +05:30
Fix print preview to show content and improve file loading timing
Print Preview Fixes:
- Fixed print preview to show actual preview content instead of formatting menu
- Changed from generic 'preview' ID to active tab's 'preview-{tabId}' element
- Added CSS positioning to make preview fixed and full-screen during print
- Hide all dialog overlays (export, batch, PDF, converter) during print
- Restore dialogs after print completes
- Enhanced print-mode CSS with z-index and positioning for proper display
File Loading Timing Improvements:
- Increased renderer-ready delay from 500ms to 1000ms for slower first loads
- Increased openFileFromPath delay from 100ms to 300ms
- Ensures UI fully initializes before files are displayed
- Files now render correctly on first double-click launch
🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
+3
-3
@@ -1668,11 +1668,11 @@ function openFileFromPath(filePath) {
|
||||
currentFile = filePath;
|
||||
const content = fs.readFileSync(filePath, 'utf-8');
|
||||
if (mainWindow && mainWindow.webContents && rendererReady) {
|
||||
// Add a small delay to ensure renderer is fully prepared to display the file
|
||||
// This prevents timing issues where file opens before UI is ready
|
||||
// Add delay to ensure renderer is fully prepared to display the file
|
||||
// Increased delay for first-time load when UI is still initializing
|
||||
setTimeout(() => {
|
||||
mainWindow.webContents.send('file-opened', { path: filePath, content });
|
||||
}, 100);
|
||||
}, 300);
|
||||
} else {
|
||||
// Store file to open after renderer is ready
|
||||
app.pendingFile = filePath;
|
||||
|
||||
+23
-4
@@ -1044,9 +1044,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
// Delay renderer-ready signal to ensure all UI initialization completes
|
||||
// This prevents files from opening before the interface is fully loaded
|
||||
// Increased delay to account for slower first-time initialization
|
||||
setTimeout(() => {
|
||||
ipcRenderer.send('renderer-ready');
|
||||
}, 500);
|
||||
}, 1000);
|
||||
|
||||
// Set up auto-save interval
|
||||
setInterval(() => {
|
||||
@@ -1163,7 +1164,9 @@ ipcRenderer.on('print-preview-styled', () => {
|
||||
|
||||
// Print preview handler - prepare for printing
|
||||
ipcRenderer.on('prepare-print-preview', (event, withStyles) => {
|
||||
const previewContent = document.getElementById('preview');
|
||||
// Get the active tab's preview element
|
||||
const activeTabId = tabManager ? tabManager.activeTabId : 1;
|
||||
const previewContent = document.getElementById(`preview-${activeTabId}`);
|
||||
|
||||
if (!previewContent || !previewContent.innerHTML.trim()) {
|
||||
alert('Nothing to print. Please create or open a document and ensure the preview is visible.');
|
||||
@@ -1176,8 +1179,18 @@ ipcRenderer.on('prepare-print-preview', (event, withStyles) => {
|
||||
document.getElementById('tab-bar').style.display = 'none';
|
||||
document.getElementById('status-bar').style.display = 'none';
|
||||
|
||||
// Hide all export dialogs and other overlays
|
||||
const exportDialog = document.getElementById('export-dialog');
|
||||
const batchDialog = document.getElementById('batch-dialog');
|
||||
const pdfDialog = document.getElementById('pdf-editor-dialog');
|
||||
const converterDialog = document.getElementById('converter-dialog');
|
||||
if (exportDialog) exportDialog.style.display = 'none';
|
||||
if (batchDialog) batchDialog.style.display = 'none';
|
||||
if (pdfDialog) pdfDialog.style.display = 'none';
|
||||
if (converterDialog) converterDialog.style.display = 'none';
|
||||
|
||||
// Show preview in full width
|
||||
const preview = document.getElementById('preview');
|
||||
const preview = document.getElementById(`preview-${activeTabId}`);
|
||||
if (preview) {
|
||||
preview.classList.add('print-mode');
|
||||
if (!withStyles) {
|
||||
@@ -1192,7 +1205,13 @@ ipcRenderer.on('prepare-print-preview', (event, withStyles) => {
|
||||
document.getElementById('tab-bar').style.display = '';
|
||||
document.getElementById('status-bar').style.display = '';
|
||||
|
||||
const preview = document.getElementById('preview');
|
||||
// Restore dialog visibility if they were open
|
||||
if (exportDialog) exportDialog.style.display = '';
|
||||
if (batchDialog) batchDialog.style.display = '';
|
||||
if (pdfDialog) pdfDialog.style.display = '';
|
||||
if (converterDialog) converterDialog.style.display = '';
|
||||
|
||||
const preview = document.getElementById(`preview-${activeTabId}`);
|
||||
if (preview) {
|
||||
preview.classList.remove('print-mode', 'print-no-styles');
|
||||
}
|
||||
|
||||
@@ -2956,6 +2956,17 @@ body.theme-concrete-warm .status-bar {
|
||||
display: block !important;
|
||||
width: 100% !important;
|
||||
max-width: 100% !important;
|
||||
position: fixed !important;
|
||||
top: 0 !important;
|
||||
left: 0 !important;
|
||||
z-index: 9999 !important;
|
||||
background: white !important;
|
||||
padding: 20px !important;
|
||||
}
|
||||
|
||||
/* Ensure preview panes are visible in print mode */
|
||||
#preview-pane-1, #preview-pane-2, #preview-pane-3, #preview-pane-4, #preview-pane-5 {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
.print-no-styles .preview-content {
|
||||
|
||||
Reference in New Issue
Block a user