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[];
|
additionalPaths: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Custom environment variables for subprocess execution */
|
||||||
|
customEnvironmentVariables: { [key: string]: string };
|
||||||
|
|
||||||
/** Export defaults */
|
/** Export defaults */
|
||||||
exportDefaults: {
|
exportDefaults: {
|
||||||
/** Default template to use for exports */
|
/** Default template to use for exports */
|
||||||
@@ -108,6 +111,8 @@ export const DEFAULT_SETTINGS: obsidianTypstPDFExportSettings = {
|
|||||||
additionalPaths: ['/opt/homebrew/bin', '/usr/local/bin', '/usr/bin']
|
additionalPaths: ['/opt/homebrew/bin', '/usr/local/bin', '/usr/bin']
|
||||||
},
|
},
|
||||||
|
|
||||||
|
customEnvironmentVariables: {},
|
||||||
|
|
||||||
exportDefaults: {
|
exportDefaults: {
|
||||||
template: 'default',
|
template: 'default',
|
||||||
format: ExportFormat.Standard,
|
format: ExportFormat.Standard,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export class EmbedProcessor {
|
|||||||
|
|
||||||
let updatedContent = processedResult.content;
|
let updatedContent = processedResult.content;
|
||||||
|
|
||||||
for (const pdfEmbed of processedResult.metadata.pdfEmbeds) {
|
for (const pdfEmbed of processedResult.metadata?.pdfEmbeds || []) {
|
||||||
try {
|
try {
|
||||||
// Resolve PDF path using helper method
|
// Resolve PDF path using helper method
|
||||||
const fullPdfPath = await this.resolvePdfPath(pdfEmbed.sanitizedPath, vaultBasePath, currentFile);
|
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> {
|
async processImageEmbeds(processedResult: PreprocessingResult, vaultBasePath: string, tempDir: string, currentFile?: TFile): Promise<void> {
|
||||||
let updatedContent = processedResult.content;
|
let updatedContent = processedResult.content;
|
||||||
|
|
||||||
for (const imageEmbed of processedResult.metadata.imageEmbeds) {
|
for (const imageEmbed of processedResult.metadata?.imageEmbeds || []) {
|
||||||
try {
|
try {
|
||||||
// Decode the URL-encoded sanitized path back to normal characters
|
// Decode the URL-encoded sanitized path back to normal characters
|
||||||
const decodedPath = decodeURIComponent(imageEmbed.sanitizedPath);
|
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> {
|
async processFileEmbeds(processedResult: PreprocessingResult, vaultBasePath: string, tempDir: string, currentFile?: TFile, embedAllFiles: boolean = true): Promise<void> {
|
||||||
let updatedContent = processedResult.content;
|
let updatedContent = processedResult.content;
|
||||||
|
|
||||||
for (const fileEmbed of processedResult.metadata.fileEmbeds) {
|
for (const fileEmbed of processedResult.metadata?.fileEmbeds || []) {
|
||||||
try {
|
try {
|
||||||
// Resolve file path using helper method (similar to PDF processing)
|
// Resolve file path using helper method (similar to PDF processing)
|
||||||
const fullFilePath = await this.resolveFilePath(fileEmbed.sanitizedPath, vaultBasePath, currentFile);
|
const fullFilePath = await this.resolveFilePath(fileEmbed.sanitizedPath, vaultBasePath, currentFile);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
import type { obsidianTypstPDFExport } from '../../main';
|
import type { obsidianTypstPDFExport } from '../../main';
|
||||||
import { ExportFormat } from '../core/settings';
|
import { ExportFormat } from '../core/settings';
|
||||||
import { SecurityUtils } from '../core/SecurityUtils';
|
import { SecurityUtils } from '../core/SecurityUtils';
|
||||||
|
import { ExportErrorHandler } from '../core/ExportErrorHandler';
|
||||||
import { FolderSuggest } from '../ui/components/FolderSuggest';
|
import { FolderSuggest } from '../ui/components/FolderSuggest';
|
||||||
import { SUPPORTED_PAPER_SIZES } from '../utils/paperSizeMapper';
|
import { SUPPORTED_PAPER_SIZES } from '../utils/paperSizeMapper';
|
||||||
|
|
||||||
|
|||||||
@@ -112,27 +112,8 @@ export class ExportConfigModal extends Modal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private handleReset(): void {
|
private handleReset(): void {
|
||||||
// Create plugin defaults object from settings tab values
|
// Reset state to plugin defaults using the full settings object
|
||||||
const pluginDefaults = {
|
this.state.reset(this.plugin.settings);
|
||||||
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);
|
|
||||||
|
|
||||||
// Re-render sections to update UI
|
// Re-render sections to update UI
|
||||||
this.renderer.refreshSections();
|
this.renderer.refreshSections();
|
||||||
|
|||||||
@@ -128,16 +128,16 @@ export class GeneralSection implements ModalSection {
|
|||||||
// Filter out universal-wrapper.pandoc.typ and clear/repopulate dropdown
|
// Filter out universal-wrapper.pandoc.typ and clear/repopulate dropdown
|
||||||
const filteredTemplates = templates.filter(template => template !== 'universal-wrapper.pandoc.typ');
|
const filteredTemplates = templates.filter(template => template !== 'universal-wrapper.pandoc.typ');
|
||||||
|
|
||||||
this.templateDropdown.selectEl.empty();
|
this.templateDropdown?.selectEl.empty();
|
||||||
filteredTemplates.forEach(template => {
|
filteredTemplates.forEach(template => {
|
||||||
this.templateDropdown.addOption(template, this.getTemplateDisplayName(template));
|
this.templateDropdown?.addOption(template, this.getTemplateDisplayName(template));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Restore selection if still available
|
// Restore selection if still available
|
||||||
if (filteredTemplates.includes(currentValue)) {
|
if (filteredTemplates.includes(currentValue)) {
|
||||||
this.templateDropdown.setValue(currentValue);
|
this.templateDropdown?.setValue(currentValue);
|
||||||
} else if (filteredTemplates.length > 0) {
|
} 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
|
// Reset to plugin defaults, not hardcoded defaults
|
||||||
this.settings = {
|
this.settings = {
|
||||||
...this.settings,
|
...this.settings,
|
||||||
template: pluginDefaults.template,
|
template: pluginDefaults.exportDefaults.template,
|
||||||
format: pluginDefaults.format,
|
format: pluginDefaults.exportDefaults.format,
|
||||||
outputFolder: pluginDefaults.outputFolder || 'exports',
|
outputFolder: pluginDefaults.outputFolder || 'exports',
|
||||||
templateVariables: {},
|
templateVariables: {},
|
||||||
progressPercent: 0,
|
progressPercent: 0,
|
||||||
currentOperation: '',
|
currentOperation: '',
|
||||||
isExporting: false,
|
isExporting: false,
|
||||||
canCancel: false,
|
canCancel: false,
|
||||||
openAfterExport: pluginDefaults.openAfterExport || false,
|
openAfterExport: pluginDefaults.behavior.openAfterExport || false,
|
||||||
preserveFolderStructure: pluginDefaults.preserveFolderStructure || false
|
preserveFolderStructure: pluginDefaults.behavior.preserveFolderStructure || false
|
||||||
};
|
};
|
||||||
|
|
||||||
this.templateVariables = {
|
this.templateVariables = {
|
||||||
pageSize: pluginDefaults.pageSize,
|
pageSize: pluginDefaults.exportDefaults.pageSize,
|
||||||
orientation: pluginDefaults.orientation,
|
orientation: pluginDefaults.exportDefaults.orientation,
|
||||||
flipped: pluginDefaults.orientation === 'landscape',
|
flipped: pluginDefaults.exportDefaults.orientation === 'landscape',
|
||||||
marginTop: pluginDefaults.marginTop,
|
marginTop: pluginDefaults.exportDefaults.marginTop,
|
||||||
marginBottom: pluginDefaults.marginBottom,
|
marginBottom: pluginDefaults.exportDefaults.marginBottom,
|
||||||
marginLeft: pluginDefaults.marginLeft,
|
marginLeft: pluginDefaults.exportDefaults.marginLeft,
|
||||||
marginRight: pluginDefaults.marginRight,
|
marginRight: pluginDefaults.exportDefaults.marginRight,
|
||||||
bodyFont: pluginDefaults.bodyFont,
|
bodyFont: pluginDefaults.exportDefaults.bodyFont,
|
||||||
headingFont: pluginDefaults.headingFont,
|
headingFont: pluginDefaults.exportDefaults.headingFont,
|
||||||
monospaceFont: pluginDefaults.monospaceFont,
|
monospaceFont: pluginDefaults.exportDefaults.monospaceFont,
|
||||||
bodyFontSize: pluginDefaults.bodyFontSize
|
bodyFontSize: pluginDefaults.exportDefaults.bodyFontSize
|
||||||
};
|
};
|
||||||
|
|
||||||
this.settings.templateVariables = this.templateVariables;
|
this.settings.templateVariables = this.templateVariables;
|
||||||
|
|||||||
Reference in new issue
Block a user