Enhances paper size selection and handling
Updates the paper size selection in settings and modals to use a predefined list of supported sizes, ensuring consistency across the plugin and compatibility with Typst. It also maps the selected paper size to its Typst equivalent before passing it to the converter, preventing issues with unsupported sizes. The change also ensures that template validation uses the correct paper sizes.
This commit is contained in:
6 files changed
+134
-24
No files matched your search
@@ -24,6 +24,7 @@ import { ExportConfigModal } from './src/modal/ExportConfigModal';
|
||||
import { ExportConfig, ExportConfigModalSettings } from './src/modal/types';
|
||||
import { TemplateManager } from './src/templates/TemplateManager';
|
||||
import { FolderSuggest } from './src/components/FolderSuggest';
|
||||
import { SUPPORTED_PAPER_SIZES } from './src/utils/paperSizeMapper';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
|
||||
@@ -1205,17 +1206,19 @@ class ObsidianTypstPDFExportSettingTab extends PluginSettingTab {
|
||||
new Setting(containerEl)
|
||||
.setName('Page size')
|
||||
.setDesc('Paper size for PDF output')
|
||||
.addDropdown(dropdown => dropdown
|
||||
.addOption('a4', 'A4')
|
||||
.addOption('a5', 'A5')
|
||||
.addOption('letter', 'US Letter')
|
||||
.addOption('legal', 'US Legal')
|
||||
.addOption('a3', 'A3')
|
||||
.setValue(this.plugin.settings.pageSetup.size)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.pageSetup.size = value;
|
||||
await this.plugin.saveSettings();
|
||||
}));
|
||||
.addDropdown(dropdown => {
|
||||
// Add all supported paper sizes
|
||||
SUPPORTED_PAPER_SIZES.forEach(paperSize => {
|
||||
dropdown.addOption(paperSize.key, paperSize.displayName);
|
||||
});
|
||||
|
||||
return dropdown
|
||||
.setValue(this.plugin.settings.pageSetup.size)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.pageSetup.size = value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Page orientation')
|
||||
|
||||
Reference in new issue
Block a user