From d8f0046c149ff79f20228c5d8fcba599b4e0f6e1 Mon Sep 17 00:00:00 2001 From: Riccardo Giorato Date: Fri, 26 Dec 2025 21:36:55 +0100 Subject: [PATCH] Add keyboard shortcut for info sheet and fix input field shortcut blocki --- app/api/generate-comic/route.ts | 24 ++++++++++++------- .../[storySlug]/story-editor-client.tsx | 12 ++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/app/api/generate-comic/route.ts b/app/api/generate-comic/route.ts index abc512b..6f71c9f 100644 --- a/app/api/generate-comic/route.ts +++ b/app/api/generate-comic/route.ts @@ -209,15 +209,19 @@ Only return the JSON, no other text.`; } const parsed = JSON.parse(jsonMatch[0]); - const rawTitle = parsed.title?.trim() || (prompt.length > 50 ? prompt.substring(0, 50) + "..." : prompt); + const rawTitle = + parsed.title?.trim() || + (prompt.length > 50 ? prompt.substring(0, 50) + "..." : prompt); const rawDescription = parsed.description?.trim(); - + // Enforce character limits - const title = rawTitle.length > 60 ? rawTitle.substring(0, 57) + "..." : rawTitle; - const description = rawDescription && rawDescription.length > 200 - ? rawDescription.substring(0, 197) + "..." - : rawDescription; - + const title = + rawTitle.length > 60 ? rawTitle.substring(0, 57) + "..." : rawTitle; + const description = + rawDescription && rawDescription.length > 200 + ? rawDescription.substring(0, 197) + "..." + : rawDescription; + return { title, description: description || undefined, @@ -309,7 +313,11 @@ Only return the JSON, no other text.`; description: generatedDescription, }); // Update story object for response - story = { ...story, title: generatedTitle, description: generatedDescription }; + story = { + ...story, + title: generatedTitle, + description: generatedDescription, + }; } catch (dbError) { console.error("Error updating story title/description:", dbError); // Continue even if update fails diff --git a/app/editor/[storySlug]/story-editor-client.tsx b/app/editor/[storySlug]/story-editor-client.tsx index 8f811a9..56ad6f2 100644 --- a/app/editor/[storySlug]/story-editor-client.tsx +++ b/app/editor/[storySlug]/story-editor-client.tsx @@ -113,10 +113,22 @@ export function StoryEditorClient() { // Keyboard navigation useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { + // Don't trigger shortcuts if user is typing in an input field + const target = e.target as HTMLElement; + if ( + target.tagName === "INPUT" || + target.tagName === "TEXTAREA" || + target.isContentEditable + ) { + return; + } + if (e.key === "ArrowRight") { setCurrentPage((prev) => (prev < pages.length - 1 ? prev + 1 : prev)); } else if (e.key === "ArrowLeft") { setCurrentPage((prev) => (prev > 0 ? prev - 1 : prev)); + } else if (e.key === "i" || e.key === "I") { + setShowInfoSheet(true); } };