refactor: move modal methods to ExportOrchestrator (step 1.9)
Move export modal orchestration from main.ts to ExportOrchestrator: - Move showExportModal() and showExportModalForFiles() methods - Add required imports to ExportOrchestrator (MarkdownView, ExportConfigModal, ModalSettingsHelper) - Replace main.ts methods with delegation calls to ExportOrchestrator - Remove unused imports from main.ts (ModalSettingsHelper, ExportConfigModal, etc.) - Reduce main.ts from 351 → 290 lines (61 lines moved) Improves separation of concerns by consolidating all export orchestration logic in ExportOrchestrator, including modal creation and configuration. Modal functionality preserved through delegation pattern. Total progress: main.ts reduced from 1233 → 290 lines (943 lines extracted, 76% reduction) Build passes successfully ✅ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2 files changed
+78
-66
No files matched your search
@@ -3,9 +3,11 @@
|
||||
* Handles the coordination and execution of all export workflows
|
||||
*/
|
||||
|
||||
import { TFile, TFolder, Notice } from 'obsidian';
|
||||
import { TFile, TFolder, Notice, MarkdownView } from 'obsidian';
|
||||
import type { obsidianTypstPDFExport } from '../../main';
|
||||
import { ExportConfig } from '../ui/modal/modalTypes';
|
||||
import { ExportConfigModal } from '../ui/modal/ExportConfigModal';
|
||||
import { ModalSettingsHelper } from '../core/ModalSettingsHelper';
|
||||
import { MarkdownPreprocessor } from '../converters/MarkdownPreprocessor';
|
||||
import { TempDirectoryManager } from '../core/TempDirectoryManager';
|
||||
import { ExportErrorHandler } from '../core/ExportErrorHandler';
|
||||
@@ -55,6 +57,77 @@ export class ExportOrchestrator {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the export configuration modal
|
||||
*/
|
||||
async showExportModal(view: MarkdownView): Promise<void> {
|
||||
const file = view.file;
|
||||
if (!file) {
|
||||
new Notice('No active file to export');
|
||||
return;
|
||||
}
|
||||
|
||||
// Get available templates first
|
||||
const availableTemplates = await this.plugin.templateManager.getAvailableTemplates();
|
||||
|
||||
// Prepare modal settings using helper
|
||||
const modalSettings = ModalSettingsHelper.prepareForSingleFile(
|
||||
file,
|
||||
availableTemplates,
|
||||
this.plugin.settings
|
||||
);
|
||||
|
||||
// Show modal - ModalState will handle localStorage hierarchy automatically
|
||||
const modal = new ExportConfigModal(
|
||||
this.plugin.app,
|
||||
this.plugin,
|
||||
modalSettings,
|
||||
async (config: ExportConfig) => {
|
||||
await this.exportFileWithConfig(file, config);
|
||||
},
|
||||
() => {
|
||||
this.cancelExport();
|
||||
}
|
||||
);
|
||||
|
||||
modal.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the export configuration modal for multiple files
|
||||
*/
|
||||
async showExportModalForFiles(files: TFile[]): Promise<void> {
|
||||
if (files.length === 0) {
|
||||
new Notice('No files to export');
|
||||
return;
|
||||
}
|
||||
|
||||
// Get available templates first
|
||||
const availableTemplates = await this.plugin.templateManager.getAvailableTemplates();
|
||||
|
||||
// Prepare modal settings using helper
|
||||
const modalSettings = ModalSettingsHelper.prepareForMultiFile(
|
||||
files,
|
||||
availableTemplates,
|
||||
this.plugin.settings
|
||||
);
|
||||
|
||||
// Show modal - ModalState will handle localStorage hierarchy automatically
|
||||
const modal = new ExportConfigModal(
|
||||
this.plugin.app,
|
||||
this.plugin,
|
||||
modalSettings,
|
||||
async (config: ExportConfig) => {
|
||||
await this.exportFilesWithConfig(files, config);
|
||||
},
|
||||
() => {
|
||||
this.cancelExport();
|
||||
}
|
||||
);
|
||||
|
||||
modal.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* Export a file with specific configuration
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user