Fix export functionality and improve Windows build

- Fixed export function issues with comprehensive pandoc detection
- Added built-in HTML and PDF export fallbacks (no pandoc required)
- Improved error handling with clear user messages
- Enhanced code quality with optional chaining and better error handling
- Fixed NSIS installer script issues for Windows build
- Added comprehensive logging and debugging for export process
- Created test files and documentation for export functionality
- Successfully builds Windows release with proper XLSX support

Resolves export failures and provides robust fallback mechanisms.
This commit is contained in:
2025-09-21 22:56:23 +05:30
parent 978e642f0c
commit 2a12a1b034
7 changed files with 495 additions and 163 deletions
+12 -10
View File
@@ -9,7 +9,10 @@ marked.setOptions({
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(code, { language: lang }).value;
} catch (err) {}
} catch (err) {
// Fallback to auto highlighting if language-specific highlighting fails
console.warn('Syntax highlighting failed for language:', lang, err.message);
}
}
return hljs.highlightAuto(code).value;
},
@@ -71,6 +74,7 @@ class TabManager {
if (e.ctrlKey || e.metaKey) {
switch (e.key) {
case 'n':
case 't':
e.preventDefault();
this.createNewTab();
break;
@@ -80,10 +84,6 @@ class TabManager {
this.closeTab(this.activeTabId);
}
break;
case 't':
e.preventDefault();
this.createNewTab();
break;
case 'Tab':
if (this.tabs.size > 1) {
e.preventDefault();
@@ -152,7 +152,7 @@ class TabManager {
// Notify main process about current file for exports
const tab = this.tabs.get(tabId);
if (tab && tab.filePath) {
if (tab?.filePath) {
ipcRenderer.send('set-current-file', tab.filePath);
}
}
@@ -169,14 +169,16 @@ class TabManager {
const tab = this.tabs.get(tabId);
if (tab.isDirty) {
// TODO: Show confirmation dialog
// Show confirmation dialog for unsaved changes
const result = confirm('You have unsaved changes. Do you want to close this tab without saving?');
if (!result) return;
}
// Remove tab elements
const tabElement = document.querySelector(`[data-tab-id="${tabId}"]`);
const tabContent = document.getElementById(`tab-content-${tabId}`);
if (tabElement && tabElement.classList.contains('tab')) {
if (tabElement?.classList.contains('tab')) {
tabElement.remove();
}
if (tabContent) {
@@ -258,7 +260,6 @@ class TabManager {
if (!tab) return;
const editor = document.getElementById(`editor-${tabId}`);
const preview = document.getElementById(`preview-${tabId}`);
if (editor) {
editor.value = tab.content;
@@ -285,7 +286,8 @@ class TabManager {
const sanitizedHtml = DOMPurify.sanitize(html);
preview.innerHTML = sanitizedHtml;
} catch (error) {
preview.innerHTML = '<p>Error rendering preview</p>';
console.error('Error rendering preview:', error);
preview.innerHTML = '<p class="error">Error rendering preview. Please check your markdown syntax.</p>';
}
}