diff --git a/src/common/highlight.ts b/src/common/highlight.ts index 5660489..3c3c15e 100644 --- a/src/common/highlight.ts +++ b/src/common/highlight.ts @@ -65,10 +65,10 @@ export const highlight = (message: string, keepMarkup = true): string => { } else if (token === '```') { stack.push(token); inCodeBlock = true; - resultHTML += ``; + resultHTML += `${keepToken ? token : ''}`; } else if (token === '`') { stack.push(token); - resultHTML += ``; + resultHTML += `${keepToken ? token : ''}`; } } diff --git a/src/games/storywriter/components/menu-sidebar.tsx b/src/games/storywriter/components/menu-sidebar.tsx index e1ddd8d..f4c4981 100644 --- a/src/games/storywriter/components/menu-sidebar.tsx +++ b/src/games/storywriter/components/menu-sidebar.tsx @@ -4,9 +4,9 @@ import { ConnectionSettingsModal } from "./connection-settings-modal"; import { SettingsModal } from "./settings-modal"; import { useAppState } from "../contexts/state"; import { useBool } from "@common/hooks/useBool"; +import { useInputState } from "@common/hooks/useInputState"; import type { Story } from "../contexts/state"; import styles from '../assets/menu-sidebar.module.css'; -import { useState } from "preact/hooks"; import { Pencil, X, Plus, Plug, Settings, Copy } from "lucide-preact"; // ─── Story Item ─────────────────────────────────────────────────────────────── @@ -21,14 +21,14 @@ interface StoryItemProps { } const StoryItem = ({ story, active, onSelect, onRename, onDelete, onDuplicate }: StoryItemProps) => { - const [isEditing, setIsEditing] = useState(false); - const [editTitle, setEditTitle] = useState(story.title); + const isEditing = useBool(false); + const [editTitle, setEditTitle] = useInputState(story.title); const handleSubmit = () => { if (editTitle.trim()) { onRename(editTitle.trim()); } - setIsEditing(false); + isEditing.setFalse(); }; const handleKeyDown = (e: KeyboardEvent) => { @@ -36,7 +36,7 @@ const StoryItem = ({ story, active, onSelect, onRename, onDelete, onDuplicate }: handleSubmit(); } else if (e.key === 'Escape') { setEditTitle(story.title); - setIsEditing(false); + isEditing.setFalse(); } }; @@ -44,13 +44,13 @@ const StoryItem = ({ story, active, onSelect, onRename, onDelete, onDuplicate }: handleSubmit(); }; - if (isEditing) { + if (isEditing.value) { return (
setEditTitle((e.target as HTMLInputElement).value)} + onInput={setEditTitle} onKeyDown={handleKeyDown} onBlur={handleBlur} autoFocus @@ -64,11 +64,12 @@ const StoryItem = ({ story, active, onSelect, onRename, onDelete, onDuplicate }:
-