Add keyboard shortcut for info sheet and fix input field shortcut blocki
This commit is contained in:
@@ -209,14 +209,18 @@ Only return the JSON, no other text.`;
|
|||||||
}
|
}
|
||||||
|
|
||||||
const parsed = JSON.parse(jsonMatch[0]);
|
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();
|
const rawDescription = parsed.description?.trim();
|
||||||
|
|
||||||
// Enforce character limits
|
// Enforce character limits
|
||||||
const title = rawTitle.length > 60 ? rawTitle.substring(0, 57) + "..." : rawTitle;
|
const title =
|
||||||
const description = rawDescription && rawDescription.length > 200
|
rawTitle.length > 60 ? rawTitle.substring(0, 57) + "..." : rawTitle;
|
||||||
? rawDescription.substring(0, 197) + "..."
|
const description =
|
||||||
: rawDescription;
|
rawDescription && rawDescription.length > 200
|
||||||
|
? rawDescription.substring(0, 197) + "..."
|
||||||
|
: rawDescription;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title,
|
title,
|
||||||
@@ -309,7 +313,11 @@ Only return the JSON, no other text.`;
|
|||||||
description: generatedDescription,
|
description: generatedDescription,
|
||||||
});
|
});
|
||||||
// Update story object for response
|
// Update story object for response
|
||||||
story = { ...story, title: generatedTitle, description: generatedDescription };
|
story = {
|
||||||
|
...story,
|
||||||
|
title: generatedTitle,
|
||||||
|
description: generatedDescription,
|
||||||
|
};
|
||||||
} catch (dbError) {
|
} catch (dbError) {
|
||||||
console.error("Error updating story title/description:", dbError);
|
console.error("Error updating story title/description:", dbError);
|
||||||
// Continue even if update fails
|
// Continue even if update fails
|
||||||
|
|||||||
@@ -113,10 +113,22 @@ export function StoryEditorClient() {
|
|||||||
// Keyboard navigation
|
// Keyboard navigation
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleKeyDown = (e: KeyboardEvent) => {
|
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") {
|
if (e.key === "ArrowRight") {
|
||||||
setCurrentPage((prev) => (prev < pages.length - 1 ? prev + 1 : prev));
|
setCurrentPage((prev) => (prev < pages.length - 1 ? prev + 1 : prev));
|
||||||
} else if (e.key === "ArrowLeft") {
|
} else if (e.key === "ArrowLeft") {
|
||||||
setCurrentPage((prev) => (prev > 0 ? prev - 1 : prev));
|
setCurrentPage((prev) => (prev > 0 ? prev - 1 : prev));
|
||||||
|
} else if (e.key === "i" || e.key === "I") {
|
||||||
|
setShowInfoSheet(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user