Files
bentopdf/src/js/handlers/toolSelectionHandler.ts
T
syazkun 16b82c5a2c feat: Add Markdown to PDF conversion functionality
- Implement dual-panel interface with live preview
- Support 3 Markdown flavors: GitHub, CommonMark, Pandoc
- Add file upload support for .md files
- Implement image quality settings (High/Medium/Low)
- Add professional user messaging and error handling
- Support all common Markdown elements (headers, lists, tables, code blocks, etc.)
- Add automatic navigation back to tool after completion

Resolves #37
2025-10-19 23:30:20 +08:00

43 lines
1.2 KiB
TypeScript

import { state } from '../state.js';
import { dom, switchView, toolTemplates } from '../ui.js';
import { setupFileInputHandler } from './fileHandler.js';
import { toolLogic } from '../logic/index.js';
import { createIcons, icons } from 'lucide';
const SETUP_AFTER_UPLOAD = ['sign-pdf'];
export function setupToolInterface(toolId: any) {
window.scrollTo({
top: 0,
left: 0,
behavior: 'instant' as ScrollBehavior,
});
state.activeTool = toolId;
dom.toolContent.innerHTML = toolTemplates[toolId]();
createIcons({ icons });
switchView('tool');
const fileInput = document.getElementById('file-input');
const processBtn = document.getElementById('process-btn');
// Set up process button for tools that don't require file input OR for specific tools
if (processBtn) {
const logic = toolLogic[toolId];
if (logic) {
const func = typeof logic.process === 'function' ? logic.process : logic;
processBtn.onclick = func;
}
}
if (toolLogic[toolId] && typeof toolLogic[toolId].setup === 'function') {
if (!SETUP_AFTER_UPLOAD.includes(toolId)) {
toolLogic[toolId].setup();
}
}
if (fileInput) {
setupFileInputHandler(toolId);
}
}