Extract command registration logic into dedicated CommandRegistry class to improve separation of concerns and reduce main.ts complexity. - Create src/plugin/CommandRegistry.ts (~35 lines) - Move registerCommands() method to CommandRegistry - Extract all 3 command definitions with callbacks: * export-current-note * export-with-config * check-dependencies - Update main.ts to delegate to CommandRegistry - Change exportCurrentNote() and showExportModal() to public - Remove old registerCommands() method from main.ts Part of comprehensive refactoring plan (main.ts: 1792 lines → 6 modules). Step 1.2 complete. Commands functionality preserved. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
/**
|
|
* Command Registration
|
|
* Handles registration of all plugin commands and their callbacks
|
|
*/
|
|
|
|
import { Editor, MarkdownView } from 'obsidian';
|
|
import type { obsidianTypstPDFExport } from '../../main';
|
|
|
|
export class CommandRegistry {
|
|
constructor(private plugin: obsidianTypstPDFExport) {}
|
|
|
|
/**
|
|
* Register all plugin commands
|
|
*/
|
|
registerCommands(): void {
|
|
// Export current note command
|
|
this.plugin.addCommand({
|
|
id: 'export-current-note',
|
|
name: 'Export current note(s)',
|
|
editorCallback: (editor: Editor, view: MarkdownView) => {
|
|
this.plugin.exportCurrentNote(view);
|
|
}
|
|
});
|
|
|
|
// Export with configuration command
|
|
this.plugin.addCommand({
|
|
id: 'export-with-config',
|
|
name: 'Export with configuration…',
|
|
editorCallback: (editor: Editor, view: MarkdownView) => {
|
|
this.plugin.showExportModal(view);
|
|
}
|
|
});
|
|
|
|
// Check dependencies command
|
|
this.plugin.addCommand({
|
|
id: 'check-dependencies',
|
|
name: 'Check Pandoc and Typst dependencies',
|
|
callback: () => {
|
|
this.plugin.showDependencyStatus();
|
|
}
|
|
});
|
|
}
|
|
} |