From 3f8f2b2089f5d50ced2d8ae87be904867882c5a5 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Wed, 3 Sep 2025 22:05:45 +0200 Subject: [PATCH] Refactors project structure for improved modularity Moves components and modules to more appropriate directories. This change improves project organization and maintainability by grouping related files into logical directories, enhancing code discoverability and reducing potential naming conflicts. --- main.ts | 8 ++++---- src/{ => converters}/MarkdownPreprocessor.ts | 0 src/converters/PandocTypstConverter.ts | 4 ++-- src/{ => converters}/PdfToImageConverter.ts | 0 src/converters/{types.ts => converterTypes.ts} | 0 src/core/ModalSettingsHelper.ts | 2 +- src/{types.ts => templates/templateTypes.ts} | 0 src/{ => ui}/components/FolderSuggest.ts | 0 src/{ => ui}/modal/ExportConfigModal.ts | 6 +++--- src/{modal/types.ts => ui/modal/modalTypes.ts} | 2 +- src/{ => ui}/modal/sections/BehaviorSection.ts | 2 +- src/{ => ui}/modal/sections/GeneralSection.ts | 4 ++-- src/{ => ui}/modal/sections/LayoutSection.ts | 4 ++-- src/{ => ui}/modal/sections/PageSetupSection.ts | 4 ++-- src/{ => ui}/modal/sections/TypographySection.ts | 2 +- src/{ => ui}/modal/state/ModalState.ts | 4 ++-- 16 files changed, 21 insertions(+), 21 deletions(-) rename src/{ => converters}/MarkdownPreprocessor.ts (100%) rename src/{ => converters}/PdfToImageConverter.ts (100%) rename src/converters/{types.ts => converterTypes.ts} (100%) rename src/{types.ts => templates/templateTypes.ts} (100%) rename src/{ => ui}/components/FolderSuggest.ts (100%) rename src/{ => ui}/modal/ExportConfigModal.ts (98%) rename src/{modal/types.ts => ui/modal/modalTypes.ts} (97%) rename src/{ => ui}/modal/sections/BehaviorSection.ts (95%) rename src/{ => ui}/modal/sections/GeneralSection.ts (97%) rename src/{ => ui}/modal/sections/LayoutSection.ts (96%) rename src/{ => ui}/modal/sections/PageSetupSection.ts (96%) rename src/{ => ui}/modal/sections/TypographySection.ts (98%) rename src/{ => ui}/modal/state/ModalState.ts (98%) diff --git a/main.ts b/main.ts index 79d1ae2..a89845c 100644 --- a/main.ts +++ b/main.ts @@ -26,10 +26,10 @@ import { ModalSettingsHelper } from './src/core/ModalSettingsHelper'; import { ExportErrorHandler } from './src/core/ExportErrorHandler'; import { TempDirectoryManager } from './src/core/TempDirectoryManager'; import { PandocTypstConverter } from './src/converters/PandocTypstConverter'; -import { ExportConfigModal } from './src/modal/ExportConfigModal'; -import { ExportConfig, ExportConfigModalSettings } from './src/modal/types'; +import { ExportConfigModal } from './src/ui/modal/ExportConfigModal'; +import { ExportConfig, ExportConfigModalSettings } from './src/ui/modal/modalTypes'; import { TemplateManager } from './src/templates/TemplateManager'; -import { FolderSuggest } from './src/components/FolderSuggest'; +import { FolderSuggest } from './src/ui/components/FolderSuggest'; import { SUPPORTED_PAPER_SIZES } from './src/utils/paperSizeMapper'; import * as path from 'path'; import * as fs from 'fs'; @@ -441,7 +441,7 @@ export class obsidianTypstPDFExport extends Plugin { const tempDir = tempManager.ensureTempDir('images'); // Preprocess the markdown content using MarkdownPreprocessor - const { MarkdownPreprocessor } = await import('./src/MarkdownPreprocessor'); + const { MarkdownPreprocessor } = await import('./src/converters/MarkdownPreprocessor'); const preprocessor = new MarkdownPreprocessor({ vaultPath: vaultPath, options: { diff --git a/src/MarkdownPreprocessor.ts b/src/converters/MarkdownPreprocessor.ts similarity index 100% rename from src/MarkdownPreprocessor.ts rename to src/converters/MarkdownPreprocessor.ts diff --git a/src/converters/PandocTypstConverter.ts b/src/converters/PandocTypstConverter.ts index f652f2f..f59bb5f 100644 --- a/src/converters/PandocTypstConverter.ts +++ b/src/converters/PandocTypstConverter.ts @@ -9,7 +9,7 @@ import { promises as fsPromises } from 'fs'; import * as path from 'path'; import * as os from 'os'; import { mapToTypstPaperSize } from '../utils/paperSizeMapper'; -import { PandocOptions, TypstSettings, ConversionResult, ProgressCallback } from './types'; +import { PandocOptions, TypstSettings, ConversionResult, ProgressCallback } from './converterTypes'; import type { obsidianTypstPDFExportSettings } from '../core/settings'; import { TempDirectoryManager } from '../core/TempDirectoryManager'; @@ -136,7 +136,7 @@ export class PandocTypstConverter { * Process PDF embeds by converting them to images and creating combined output */ async processPdfEmbeds(processedResult: any, vaultBasePath: string, tempDir: string): Promise { - const { PdfToImageConverter } = require('../PdfToImageConverter'); + const { PdfToImageConverter } = require('./PdfToImageConverter'); const converter = PdfToImageConverter.getInstance(this.plugin); for (const pdfEmbed of processedResult.metadata.pdfEmbeds) { diff --git a/src/PdfToImageConverter.ts b/src/converters/PdfToImageConverter.ts similarity index 100% rename from src/PdfToImageConverter.ts rename to src/converters/PdfToImageConverter.ts diff --git a/src/converters/types.ts b/src/converters/converterTypes.ts similarity index 100% rename from src/converters/types.ts rename to src/converters/converterTypes.ts diff --git a/src/core/ModalSettingsHelper.ts b/src/core/ModalSettingsHelper.ts index 5aaaeba..74e7645 100644 --- a/src/core/ModalSettingsHelper.ts +++ b/src/core/ModalSettingsHelper.ts @@ -4,7 +4,7 @@ import { TFile } from 'obsidian'; import { obsidianTypstPDFExportSettings } from './settings'; -import { ExportConfigModalSettings } from '../modal/types'; +import { ExportConfigModalSettings } from '../ui/modal/modalTypes'; export interface ModalSettingsInput { /** Primary file for the export */ diff --git a/src/types.ts b/src/templates/templateTypes.ts similarity index 100% rename from src/types.ts rename to src/templates/templateTypes.ts diff --git a/src/components/FolderSuggest.ts b/src/ui/components/FolderSuggest.ts similarity index 100% rename from src/components/FolderSuggest.ts rename to src/ui/components/FolderSuggest.ts diff --git a/src/modal/ExportConfigModal.ts b/src/ui/modal/ExportConfigModal.ts similarity index 98% rename from src/modal/ExportConfigModal.ts rename to src/ui/modal/ExportConfigModal.ts index f8d5d1f..b4c3dc5 100644 --- a/src/modal/ExportConfigModal.ts +++ b/src/ui/modal/ExportConfigModal.ts @@ -4,14 +4,14 @@ */ import { Modal, App, Notice } from 'obsidian'; -import { obsidianTypstPDFExport } from '../../main'; -import { ExportConfig, ExportConfigModalSettings, ModalSection } from './types'; +import { obsidianTypstPDFExport } from '../../../main'; +import { ExportConfig, ExportConfigModalSettings, ModalSection } from './modalTypes'; import { ModalState } from './state/ModalState'; import { GeneralSection } from './sections/GeneralSection'; import { TypographySection } from './sections/TypographySection'; import { PageSetupSection } from './sections/PageSetupSection'; import { BehaviorSection } from './sections/BehaviorSection'; -import { TemplateManager } from '../templates/TemplateManager'; +import { TemplateManager } from '../../templates/TemplateManager'; export class ExportConfigModal extends Modal { plugin: obsidianTypstPDFExport; diff --git a/src/modal/types.ts b/src/ui/modal/modalTypes.ts similarity index 97% rename from src/modal/types.ts rename to src/ui/modal/modalTypes.ts index 10ee1be..aa89e96 100644 --- a/src/modal/types.ts +++ b/src/ui/modal/modalTypes.ts @@ -3,7 +3,7 @@ */ import { TFile } from 'obsidian'; -import { ExportFormat } from '../core/settings'; +import { ExportFormat } from '../../core/settings'; export interface ExportConfig { /** Override default template */ diff --git a/src/modal/sections/BehaviorSection.ts b/src/ui/modal/sections/BehaviorSection.ts similarity index 95% rename from src/modal/sections/BehaviorSection.ts rename to src/ui/modal/sections/BehaviorSection.ts index 4809282..298dc9f 100644 --- a/src/modal/sections/BehaviorSection.ts +++ b/src/ui/modal/sections/BehaviorSection.ts @@ -4,7 +4,7 @@ */ import { Setting } from 'obsidian'; -import { ModalSection, ModalState, ValidationResult } from '../types'; +import { ModalSection, ModalState, ValidationResult } from '../modalTypes'; export class BehaviorSection implements ModalSection { private container: HTMLElement | null = null; diff --git a/src/modal/sections/GeneralSection.ts b/src/ui/modal/sections/GeneralSection.ts similarity index 97% rename from src/modal/sections/GeneralSection.ts rename to src/ui/modal/sections/GeneralSection.ts index 0cf43c7..e896214 100644 --- a/src/modal/sections/GeneralSection.ts +++ b/src/ui/modal/sections/GeneralSection.ts @@ -4,8 +4,8 @@ */ import { Setting, App } from 'obsidian'; -import { ModalSection, ModalState, ValidationResult } from '../types'; -import { ExportFormat } from '../../core/settings'; +import { ModalSection, ModalState, ValidationResult } from '../modalTypes'; +import { ExportFormat } from '../../../core/settings'; import { FolderSuggest } from '../../components/FolderSuggest'; export class GeneralSection implements ModalSection { diff --git a/src/modal/sections/LayoutSection.ts b/src/ui/modal/sections/LayoutSection.ts similarity index 96% rename from src/modal/sections/LayoutSection.ts rename to src/ui/modal/sections/LayoutSection.ts index cb58117..6a48240 100644 --- a/src/modal/sections/LayoutSection.ts +++ b/src/ui/modal/sections/LayoutSection.ts @@ -4,8 +4,8 @@ */ import { Setting } from 'obsidian'; -import { ModalSection, ModalState, ValidationResult } from '../types'; -import { SUPPORTED_PAPER_SIZES } from '../../utils/paperSizeMapper'; +import { ModalSection, ModalState, ValidationResult } from '../modalTypes'; +import { SUPPORTED_PAPER_SIZES } from '../../../utils/paperSizeMapper'; export class LayoutSection implements ModalSection { private container: HTMLElement | null = null; diff --git a/src/modal/sections/PageSetupSection.ts b/src/ui/modal/sections/PageSetupSection.ts similarity index 96% rename from src/modal/sections/PageSetupSection.ts rename to src/ui/modal/sections/PageSetupSection.ts index f44b845..0c09aed 100644 --- a/src/modal/sections/PageSetupSection.ts +++ b/src/ui/modal/sections/PageSetupSection.ts @@ -4,8 +4,8 @@ */ import { Setting } from 'obsidian'; -import { ModalSection, ModalState, ValidationResult } from '../types'; -import { SUPPORTED_PAPER_SIZES } from '../../utils/paperSizeMapper'; +import { ModalSection, ModalState, ValidationResult } from '../modalTypes'; +import { SUPPORTED_PAPER_SIZES } from '../../../utils/paperSizeMapper'; export class PageSetupSection implements ModalSection { private container: HTMLElement | null = null; diff --git a/src/modal/sections/TypographySection.ts b/src/ui/modal/sections/TypographySection.ts similarity index 98% rename from src/modal/sections/TypographySection.ts rename to src/ui/modal/sections/TypographySection.ts index c537439..1a94662 100644 --- a/src/modal/sections/TypographySection.ts +++ b/src/ui/modal/sections/TypographySection.ts @@ -4,7 +4,7 @@ */ import { Setting, App } from 'obsidian'; -import { ModalSection, ModalState, ValidationResult } from '../types'; +import { ModalSection, ModalState, ValidationResult } from '../modalTypes'; export class TypographySection implements ModalSection { private container: HTMLElement | null = null; diff --git a/src/modal/state/ModalState.ts b/src/ui/modal/state/ModalState.ts similarity index 98% rename from src/modal/state/ModalState.ts rename to src/ui/modal/state/ModalState.ts index af9c30c..b9b5d16 100644 --- a/src/modal/state/ModalState.ts +++ b/src/ui/modal/state/ModalState.ts @@ -3,8 +3,8 @@ * Centralized state management for the Export Configuration Modal */ -import { ExportConfigModalSettings, ExportConfig, ModalState as IModalState } from '../types'; -import { ExportFormat } from '../../core/settings'; +import { ExportConfigModalSettings, ExportConfig, ModalState as IModalState } from '../modalTypes'; +import { ExportFormat } from '../../../core/settings'; export class ModalState implements IModalState { settings: ExportConfigModalSettings;