From 817ab051f05ce25bf3013175c6e967b677fb4584 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Sun, 31 May 2026 16:06:31 -0400 Subject: [PATCH] Metadata: auto-pick category for slide / deck / pixel / custom art MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Creating a Slide, Slide Deck, Pixel Art, or Custom Art template already auto-set state.meta.category in applyLayout — but the auto-fill was inconsistent (slide / deck / pixelart unconditionally overwrote, customart only filled when empty) AND it didn't apply when importing / forking a design whose payload arrived without a category set. Fix: - defaultCategoryForMode(mode) — new shared helper that maps the canvas modes to their canonical mediaCategories entries: 'slide' → 'slide' 'deck' → 'slide-deck' 'pixelart' → 'pixel-art' 'customart'→ 'custom-art' Physical-media modes (cover / disc / jewel / disc-design) return '' so the user picks DVD / Blu-ray / PS3 / etc. — there's no one obvious default. - syncInputs runs the helper at the top: if state.meta.category is empty, fill it from the current mode. Idempotent — leaves a user-picked value alone. Covers BOTH create-new and import / fork / loadProjectFromText paths via the one entry point all state changes pass through. - applyLayout's inline mode → category switch replaced with the shared helper, also made consistently only-if-empty so a user-picked category survives a mode switch. --- src/index.html | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/index.html b/src/index.html index b16e942..3d29cc0 100644 --- a/src/index.html +++ b/src/index.html @@ -7832,8 +7832,30 @@ render(); } + // Map a template / app mode to the canonical mediaCategories value + // that makes sense for it. Physical-media modes (cover / disc / + // jewel / disc-design) return '' so the user picks DVD / Blu-ray / + // PS3 / etc. — there's no single right answer there. + function defaultCategoryForMode(mode) { + switch (mode) { + case 'slide': return 'slide'; + case 'deck': return 'slide-deck'; + case 'pixelart': return 'pixel-art'; + case 'customart':return 'custom-art'; + default: return ''; + } + } + function syncInputs() { const isDesignerApp = state.appMode === 'designer'; + // Auto-fill the category when it's empty and the current mode has + // a canonical default. Applies to brand-new templates created via + // applyLayout AND to imports / forks that arrived without a + // category set. Idempotent: leaves a user-picked category alone. + if (state.meta && !state.meta.category) { + const def = defaultCategoryForMode(isDesignerApp ? 'disc-design' : state.templateMode); + if (def) state.meta.category = def; + } const layoutActive = { cover: !isDesignerApp && state.templateMode === 'cover', disc: !isDesignerApp && state.templateMode === 'disc', @@ -24250,14 +24272,15 @@ state.preset = 'dvd'; Object.assign(state, presets.dvd); } - // First time into Custom Art / Slide, default the category and (for a - // slide) lock the canvas to a 16:9 resolution. - // Slides and decks always classify under their own category; Custom - // Art just gets a default the user can override. - if (layout === 'slide') state.meta.category = 'slide'; - else if (layout === 'deck') state.meta.category = 'slide-deck'; - else if (layout === 'pixelart') state.meta.category = 'pixel-art'; - else if (layout === 'customart' && !state.meta.category) state.meta.category = 'custom-art'; + // First time into Custom Art / Slide / Deck / Pixel Art, default + // the category based on the layout (slide / slide-deck / pixel-art + // / custom-art). Only fills when empty so a user-picked category + // sticks across switches. Lock the canvas to 16:9 for slides + // below. + if (!state.meta.category) { + const def = defaultCategoryForMode(layout); + if (def) state.meta.category = def; + } if (layout === 'pixelart' && !state.pixelArt) state.pixelArt = defaultPixelArt(32, 32); if (layout === 'slide') { const ca = state.customArt || {};