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
@@ -5,6 +5,7 @@
|
||||
|
||||
import { Setting } from 'obsidian';
|
||||
import { ModalSection, ModalState, ValidationResult } from '../types';
|
||||
import { SUPPORTED_PAPER_SIZES } from '../../utils/paperSizeMapper';
|
||||
|
||||
export class LayoutSection implements ModalSection {
|
||||
private container: HTMLElement | null = null;
|
||||
@@ -26,12 +27,12 @@ export class LayoutSection implements ModalSection {
|
||||
.setName('Page size')
|
||||
.setDesc('Standard page sizes for the PDF document')
|
||||
.addDropdown(dropdown => {
|
||||
// Add all supported paper sizes
|
||||
SUPPORTED_PAPER_SIZES.forEach(paperSize => {
|
||||
dropdown.addOption(paperSize.key, paperSize.displayName);
|
||||
});
|
||||
|
||||
dropdown
|
||||
.addOption('a4', 'A4 (210 × 297 mm)')
|
||||
.addOption('letter', 'Letter (8.5 × 11 in)')
|
||||
.addOption('legal', 'Legal (8.5 × 14 in)')
|
||||
.addOption('a3', 'A3 (297 × 420 mm)')
|
||||
.addOption('a5', 'A5 (148 × 210 mm)')
|
||||
.setValue('a4') // Default to A4
|
||||
.onChange(value => {
|
||||
state.updateTemplateVariables({ pageSize: value });
|
||||
|
||||
Reference in new issue
Block a user