mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 10:00:17 +05:30
Release v1.8.3: Major UI and Export Enhancements
This release includes significant improvements to PDF Editor UI, enhanced PDF/Word export functionality, print fixes, and configurable template settings. 🎯 v1.8.1 - Streamlined PDF Editor UI: - Clean, focused interface showing only the selected PDF operation - Smooth fade-in animations when switching between functions - Optimized dialog sizing (max-width 600px, max-height 85vh) - Enhanced file list styling with better contrast - Complete dark theme support for all PDF editor components - Better scrolling behavior for long forms 📄 v1.8.2 - Enhanced PDF Export & Print Fix: - New "PDF (Enhanced)" export option using Word template + LibreOffice conversion - Added to both single-file export and batch converter - Keyboard shortcut: Ctrl+Shift+P for enhanced PDF export - Fixed print preview showing blank output issue - Simplified print handler using CSS @media print rules - Better print styling with proper element hiding/showing ⚙️ v1.8.3 - Configurable Template Settings: - Added "Template Settings..." menu option - Configurable start page for Word template content insertion - Choose from Pages 1-5 or custom page number (1-100) - Settings persisted across sessions - Updated WordTemplateExporter to use configurable start page - Works with both DOCX (Enhanced) and PDF (Enhanced) export - Applied to single-file and batch conversion workflows 🔧 Technical Improvements: - Enhanced WordTemplateExporter constructor to accept startPage parameter - Updated insertContentAfterPage method for flexible page insertion - Added Template Settings dialog with quick-select buttons - IPC communication for custom page number input - Settings stored in userData/settings.json - Improved CSS specificity with PDF editor-specific classes - Fixed @media print rules to ensure preview content is visible 🎨 UI/UX Enhancements: - PDF Editor sections now animate smoothly when switching - File lists for merge operations styled with proper contrast - Remove buttons styled with danger color (#dc3545) - Template settings dialog shows current template and start page - All enhancements support all 22 existing themes The application now provides professional-grade PDF editing, enhanced export capabilities with full control over template-based generation, and a streamlined user interface that makes complex operations simple and intuitive. 🤖 Generated with Claude Code
This commit is contained in:
+24
-10
@@ -10,8 +10,9 @@ const PizZip = require('pizzip');
|
||||
const Docx = require('docx4js').default;
|
||||
|
||||
class WordTemplateExporter {
|
||||
constructor(templatePath) {
|
||||
constructor(templatePath, startPage = 3) {
|
||||
this.templatePath = templatePath || path.join(__dirname, '../word_template.docx');
|
||||
this.startPage = startPage; // Which page to start inserting content
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,8 +30,8 @@ class WordTemplateExporter {
|
||||
// Parse markdown and generate Word XML
|
||||
const newContentXml = this.markdownToWordXml(markdownContent);
|
||||
|
||||
// Insert new content after page 2 (after the section break)
|
||||
const modifiedXml = this.insertContentAfterPage2(documentXml, newContentXml);
|
||||
// Insert new content after the specified start page
|
||||
const modifiedXml = this.insertContentAfterPage(documentXml, newContentXml, this.startPage);
|
||||
|
||||
// Update the zip with modified XML
|
||||
zip.file('word/document.xml', modifiedXml);
|
||||
@@ -47,20 +48,33 @@ class WordTemplateExporter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert markdown content after page 2 in the document
|
||||
* Insert markdown content after the specified page in the document
|
||||
* @param {string} documentXml - The document XML
|
||||
* @param {string} newContentXml - The new content to insert
|
||||
* @param {number} afterPage - Insert content after this page number (1-based)
|
||||
*/
|
||||
insertContentAfterPage2(documentXml, newContentXml) {
|
||||
// Find the last section break (after page 2)
|
||||
insertContentAfterPage(documentXml, newContentXml, afterPage) {
|
||||
// Find section breaks that mark page boundaries
|
||||
// Look for the section properties tag that marks page breaks
|
||||
const sectionBreakRegex = /<w:sectPr[^>]*>[\s\S]*?<\/w:sectPr>/g;
|
||||
const matches = [...documentXml.matchAll(sectionBreakRegex)];
|
||||
|
||||
if (matches.length >= 2) {
|
||||
// Insert after the 2nd section break
|
||||
const insertPoint = matches[1].index + matches[1][0].length;
|
||||
// Calculate which section break to insert after
|
||||
// Page 1 = before 1st section break
|
||||
// Page 2 = after 1st section break
|
||||
// Page 3 = after 2nd section break, etc.
|
||||
const sectionIndex = afterPage - 1;
|
||||
|
||||
if (matches.length >= sectionIndex && sectionIndex > 0) {
|
||||
// Insert after the specified section break
|
||||
const insertPoint = matches[sectionIndex - 1].index + matches[sectionIndex - 1][0].length;
|
||||
return documentXml.slice(0, insertPoint) + newContentXml + documentXml.slice(insertPoint);
|
||||
} else if (afterPage === 1 || matches.length === 0) {
|
||||
// Insert at the beginning (after <w:body>) or if no section breaks found
|
||||
const bodyStart = documentXml.indexOf('<w:body>') + 8;
|
||||
return documentXml.slice(0, bodyStart) + newContentXml + documentXml.slice(bodyStart);
|
||||
} else {
|
||||
// If no section breaks found, insert before closing body tag
|
||||
// If not enough section breaks, insert before closing body tag
|
||||
return documentXml.replace('</w:body>', newContentXml + '</w:body>');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user