diff --git a/components.d.ts b/components.d.ts index e174cd2a5..4ebb50bce 100644 --- a/components.d.ts +++ b/components.d.ts @@ -16,6 +16,7 @@ declare module 'vue' { ColorPicker: typeof import('./src/components/ColorPicker.vue')['default'] EditorCanvas: typeof import('./src/components/EditorCanvas.vue')['default'] EffectsSection: typeof import('./src/components/properties/EffectsSection.vue')['default'] + ExportSection: typeof import('./src/components/properties/ExportSection.vue')['default'] FillPicker: typeof import('./src/components/FillPicker.vue')['default'] FillSection: typeof import('./src/components/properties/FillSection.vue')['default'] IconLucideALargeSmall: typeof import('~icons/lucide/a-large-small')['default'] diff --git a/src/components/properties/ExportSection.vue b/src/components/properties/ExportSection.vue index 98e34438a..6e59c6693 100644 --- a/src/components/properties/ExportSection.vue +++ b/src/components/properties/ExportSection.vue @@ -50,6 +50,8 @@ async function doExport() { } } +const PREVIEW_WIDTH = 480 + function updatePreview() { if (!showPreview.value) return if (previewUrl.value) { @@ -58,7 +60,15 @@ function updatePreview() { } const ids = [...store.state.selectedIds] if (ids.length === 0) return - const data = store.renderExportImage(ids, 0.5, 'PNG') + + let maxW = 0 + for (const id of ids) { + const node = store.graph.getNode(id) + if (node) maxW = Math.max(maxW, node.width) + } + const scale = maxW > 0 ? Math.min(PREVIEW_WIDTH / maxW, 2) : 1 + + const data = store.renderExportImage(ids, scale, 'PNG') if (data) { previewUrl.value = URL.createObjectURL(new Blob([data], { type: 'image/png' })) }