feat(KB-234): add double-click edit and Escape key handling to SpecEditor

- Add double-click handler to SpecEditor for quick edit mode entry

- Implement Escape key handler to exit edit mode

- Add comprehensive double-click interaction tests

- Add CSS styles for improved editor UX
This commit is contained in:
gsxdsm
2026-03-30 19:09:52 -07:00
parent 3f2a86d4d5
commit 6e5befb73d
3 changed files with 74 additions and 2 deletions

View File

@@ -47,7 +47,7 @@ export function SpecEditor({
setFeedback("");
}, [onRequestRevision, feedback, isRequesting]);
// Keyboard shortcut: Ctrl/Cmd+Enter to save in edit mode
// Keyboard shortcut: Ctrl/Cmd+Enter to save in edit mode, Escape to cancel
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if (isEditing && (e.metaKey || e.ctrlKey) && e.key === "Enter") {
@@ -55,6 +55,9 @@ export function SpecEditor({
if (canSave) {
void handleSave();
}
} else if (isEditing && e.key === "Escape") {
e.preventDefault();
handleCancelEdit();
}
};
@@ -72,6 +75,13 @@ export function SpecEditor({
setEditContent(content);
};
const handleDoubleClick = useCallback((e: React.MouseEvent) => {
if (!readOnly && !isEditing) {
e.stopPropagation();
handleEnterEditMode();
}
}, [readOnly, isEditing, content]);
const stripLeadingHeading = (text: string): string => {
return text.replace(/^#\s+[^\n]*\n+/, "");
};
@@ -130,7 +140,7 @@ export function SpecEditor({
placeholder="Enter task specification in Markdown..."
/>
) : content ? (
<div className="markdown-body">
<div className="markdown-body" onDoubleClick={handleDoubleClick}>
<ReactMarkdown remarkPlugins={[remarkGfm]}>
{stripLeadingHeading(content)}
</ReactMarkdown>