Add keyboard shortcut for info sheet and fix input field shortcut blocki

This commit is contained in:
Riccardo Giorato
2025-12-26 21:36:55 +01:00
parent 0710982f9d
commit d8f0046c14
2 changed files with 28 additions and 8 deletions
+14 -6
View File
@@ -209,14 +209,18 @@ 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,
@@ -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
@@ -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);
}
};