The VS Code of video editing, built for agents.
TypeScript
feat: implement escape key functionality to close prompt input and update command section order
konstantin-paulusc21f56a7050c
diff --git a/apps/web/src/components/genai/prompt-input.tsx b/apps/web/src/components/genai/prompt-input.tsxindex 1873accf..829288c5 100644--- a/apps/web/src/components/genai/prompt-input.tsx+++ b/apps/web/src/components/genai/prompt-input.tsx@@ -59,6 +59,8 @@ import { useEditor } from "@/engine/hooks";import { droppedFiles, importFiles, pickFiles } from "@/engine/asset-actions";import { useMediaSelection } from "./selection";import { ASSET_DRAG_TYPE } from "@/components/sidebar-left/folder-item";+import { useBarKey } from "@/components/canvas/action-bar";+import { usePromptInput } from "@/context/prompt-input";import type { ModelId, Resolution } from "@diffusionstudio/api-contract";import type { AssetCache } from "@diffusionstudio/assets";@@ -80,6 +82,13 @@ export function PromptInput(props: PromptInputProps) {const editor = useEditor();const { images: selectedImages } = useMediaSelection();const { generate } = useGenerate();+ const { setPromptInputOpen } = usePromptInput();++ // Esc puts the box down, what was typed kept for next time: from the+ // prompt, once the recent prompts are dismissed, and from anywhere else+ // but an open menu or another field.+ const close = () => setPromptInputOpen(false);+ useBarKey((event) => event.key === "Escape", close);let textareaRef!: HTMLTextAreaElement;let dragCounter = 0;@@ -306,6 +315,9 @@ export function PromptInput(props: PromptInputProps) {if (e.key === "Enter" && !e.shiftKey) {e.preventDefault();handleSubmit();+ } else if (e.key === "Escape") {+ e.preventDefault();+ close();}};diff --git a/apps/web/src/context/commands.tsx b/apps/web/src/context/commands.tsxindex a06306a8..26df5812 100644--- a/apps/web/src/context/commands.tsx+++ b/apps/web/src/context/commands.tsx@@ -16,7 +16,7 @@ import type { Accessor, Component, JSX, Owner } from "solid-js";* taken from the order commands register in, which depends on what mounted* first and changes as parts of the UI come and go.*/-export const SECTIONS = ["Timeline", "Assets", "Media", "Object", "Generate", "Tools", "Edit", "Window"] as const;+export const SECTIONS = ["Media", "Generate", "Assets", "Timeline", "Object", "Tools", "Edit", "Window"] as const;export type Section = (typeof SECTIONS)[number];