fix: resolve TypeScript compilation errors after refactoring
- Add missing ExportErrorHandler import in SettingsTab.ts - Add customEnvironmentVariables property to settings interface - Fix undefined metadata access with optional chaining in EmbedProcessor.ts - Update ModalState.ts to use new nested settings structure - Simplify ExportConfigModal.ts to use full settings object - Add null safety checks for templateDropdown in GeneralSection.ts
This commit is contained in:
6 files changed
+30
-43
No files matched your search
@@ -25,6 +25,9 @@ export interface obsidianTypstPDFExportSettings {
|
||||
additionalPaths: string[];
|
||||
};
|
||||
|
||||
/** Custom environment variables for subprocess execution */
|
||||
customEnvironmentVariables: { [key: string]: string };
|
||||
|
||||
/** Export defaults */
|
||||
exportDefaults: {
|
||||
/** Default template to use for exports */
|
||||
@@ -108,6 +111,8 @@ export const DEFAULT_SETTINGS: obsidianTypstPDFExportSettings = {
|
||||
additionalPaths: ['/opt/homebrew/bin', '/usr/local/bin', '/usr/bin']
|
||||
},
|
||||
|
||||
customEnvironmentVariables: {},
|
||||
|
||||
exportDefaults: {
|
||||
template: 'default',
|
||||
format: ExportFormat.Standard,
|
||||
|
||||
@@ -22,7 +22,7 @@ export class EmbedProcessor {
|
||||
|
||||
let updatedContent = processedResult.content;
|
||||
|
||||
for (const pdfEmbed of processedResult.metadata.pdfEmbeds) {
|
||||
for (const pdfEmbed of processedResult.metadata?.pdfEmbeds || []) {
|
||||
try {
|
||||
// Resolve PDF path using helper method
|
||||
const fullPdfPath = await this.resolvePdfPath(pdfEmbed.sanitizedPath, vaultBasePath, currentFile);
|
||||
@@ -106,7 +106,7 @@ export class EmbedProcessor {
|
||||
async processImageEmbeds(processedResult: PreprocessingResult, vaultBasePath: string, tempDir: string, currentFile?: TFile): Promise<void> {
|
||||
let updatedContent = processedResult.content;
|
||||
|
||||
for (const imageEmbed of processedResult.metadata.imageEmbeds) {
|
||||
for (const imageEmbed of processedResult.metadata?.imageEmbeds || []) {
|
||||
try {
|
||||
// Decode the URL-encoded sanitized path back to normal characters
|
||||
const decodedPath = decodeURIComponent(imageEmbed.sanitizedPath);
|
||||
@@ -232,7 +232,7 @@ export class EmbedProcessor {
|
||||
async processFileEmbeds(processedResult: PreprocessingResult, vaultBasePath: string, tempDir: string, currentFile?: TFile, embedAllFiles: boolean = true): Promise<void> {
|
||||
let updatedContent = processedResult.content;
|
||||
|
||||
for (const fileEmbed of processedResult.metadata.fileEmbeds) {
|
||||
for (const fileEmbed of processedResult.metadata?.fileEmbeds || []) {
|
||||
try {
|
||||
// Resolve file path using helper method (similar to PDF processing)
|
||||
const fullFilePath = await this.resolveFilePath(fileEmbed.sanitizedPath, vaultBasePath, currentFile);
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
import type { obsidianTypstPDFExport } from '../../main';
|
||||
import { ExportFormat } from '../core/settings';
|
||||
import { SecurityUtils } from '../core/SecurityUtils';
|
||||
import { ExportErrorHandler } from '../core/ExportErrorHandler';
|
||||
import { FolderSuggest } from '../ui/components/FolderSuggest';
|
||||
import { SUPPORTED_PAPER_SIZES } from '../utils/paperSizeMapper';
|
||||
|
||||
|
||||
@@ -112,27 +112,8 @@ export class ExportConfigModal extends Modal {
|
||||
}
|
||||
|
||||
private handleReset(): void {
|
||||
// Create plugin defaults object from settings tab values
|
||||
const pluginDefaults = {
|
||||
template: this.plugin.settings.exportDefaults.template,
|
||||
format: this.plugin.settings.exportDefaults.format,
|
||||
outputFolder: this.plugin.settings.outputFolder,
|
||||
openAfterExport: this.plugin.settings.behavior.openAfterExport,
|
||||
preserveFolderStructure: this.plugin.settings.behavior.preserveFolderStructure,
|
||||
pageSize: this.plugin.settings.pageSetup.size,
|
||||
orientation: this.plugin.settings.pageSetup.orientation,
|
||||
marginTop: this.plugin.settings.pageSetup.margins.top.toString(),
|
||||
marginBottom: this.plugin.settings.pageSetup.margins.bottom.toString(),
|
||||
marginLeft: this.plugin.settings.pageSetup.margins.left.toString(),
|
||||
marginRight: this.plugin.settings.pageSetup.margins.right.toString(),
|
||||
bodyFont: this.plugin.settings.typography.fonts.body,
|
||||
headingFont: this.plugin.settings.typography.fonts.heading,
|
||||
monospaceFont: this.plugin.settings.typography.fonts.monospace,
|
||||
bodyFontSize: this.plugin.settings.typography.fontSizes.body
|
||||
};
|
||||
|
||||
// Reset state to plugin defaults
|
||||
this.state.reset(pluginDefaults);
|
||||
// Reset state to plugin defaults using the full settings object
|
||||
this.state.reset(this.plugin.settings);
|
||||
|
||||
// Re-render sections to update UI
|
||||
this.renderer.refreshSections();
|
||||
|
||||
@@ -128,16 +128,16 @@ export class GeneralSection implements ModalSection {
|
||||
// Filter out universal-wrapper.pandoc.typ and clear/repopulate dropdown
|
||||
const filteredTemplates = templates.filter(template => template !== 'universal-wrapper.pandoc.typ');
|
||||
|
||||
this.templateDropdown.selectEl.empty();
|
||||
this.templateDropdown?.selectEl.empty();
|
||||
filteredTemplates.forEach(template => {
|
||||
this.templateDropdown.addOption(template, this.getTemplateDisplayName(template));
|
||||
this.templateDropdown?.addOption(template, this.getTemplateDisplayName(template));
|
||||
});
|
||||
|
||||
// Restore selection if still available
|
||||
if (filteredTemplates.includes(currentValue)) {
|
||||
this.templateDropdown.setValue(currentValue);
|
||||
this.templateDropdown?.setValue(currentValue);
|
||||
} else if (filteredTemplates.length > 0) {
|
||||
this.templateDropdown.setValue(filteredTemplates[0]);
|
||||
this.templateDropdown?.setValue(filteredTemplates[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,30 +142,30 @@ export class ModalState implements IModalState {
|
||||
// Reset to plugin defaults, not hardcoded defaults
|
||||
this.settings = {
|
||||
...this.settings,
|
||||
template: pluginDefaults.template,
|
||||
format: pluginDefaults.format,
|
||||
template: pluginDefaults.exportDefaults.template,
|
||||
format: pluginDefaults.exportDefaults.format,
|
||||
outputFolder: pluginDefaults.outputFolder || 'exports',
|
||||
templateVariables: {},
|
||||
progressPercent: 0,
|
||||
currentOperation: '',
|
||||
isExporting: false,
|
||||
canCancel: false,
|
||||
openAfterExport: pluginDefaults.openAfterExport || false,
|
||||
preserveFolderStructure: pluginDefaults.preserveFolderStructure || false
|
||||
openAfterExport: pluginDefaults.behavior.openAfterExport || false,
|
||||
preserveFolderStructure: pluginDefaults.behavior.preserveFolderStructure || false
|
||||
};
|
||||
|
||||
this.templateVariables = {
|
||||
pageSize: pluginDefaults.pageSize,
|
||||
orientation: pluginDefaults.orientation,
|
||||
flipped: pluginDefaults.orientation === 'landscape',
|
||||
marginTop: pluginDefaults.marginTop,
|
||||
marginBottom: pluginDefaults.marginBottom,
|
||||
marginLeft: pluginDefaults.marginLeft,
|
||||
marginRight: pluginDefaults.marginRight,
|
||||
bodyFont: pluginDefaults.bodyFont,
|
||||
headingFont: pluginDefaults.headingFont,
|
||||
monospaceFont: pluginDefaults.monospaceFont,
|
||||
bodyFontSize: pluginDefaults.bodyFontSize
|
||||
pageSize: pluginDefaults.exportDefaults.pageSize,
|
||||
orientation: pluginDefaults.exportDefaults.orientation,
|
||||
flipped: pluginDefaults.exportDefaults.orientation === 'landscape',
|
||||
marginTop: pluginDefaults.exportDefaults.marginTop,
|
||||
marginBottom: pluginDefaults.exportDefaults.marginBottom,
|
||||
marginLeft: pluginDefaults.exportDefaults.marginLeft,
|
||||
marginRight: pluginDefaults.exportDefaults.marginRight,
|
||||
bodyFont: pluginDefaults.exportDefaults.bodyFont,
|
||||
headingFont: pluginDefaults.exportDefaults.headingFont,
|
||||
monospaceFont: pluginDefaults.exportDefaults.monospaceFont,
|
||||
bodyFontSize: pluginDefaults.exportDefaults.bodyFontSize
|
||||
};
|
||||
|
||||
this.settings.templateVariables = this.templateVariables;
|
||||
|
||||
Reference in new issue
Block a user