From d128ac92dc2626be30a4f79c73629c0693f36066 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 14 Mar 2026 00:06:34 +0100 Subject: [PATCH] Add custom prompt feature and enhance keyboard handling --- src/App.tsx | 68 ++++++++++++++++++++++++++++++++++++++++++--------- src/index.css | 22 +++++++++++++++++ 2 files changed, 79 insertions(+), 11 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index fc400ef..fa6227d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1259,15 +1259,6 @@ export default function App() { const handleOpenAiToolsMenu = useCallback(async () => { if (!selectedTextId || !hasText || isViewingHistory || isConverting) return; - if (aiPromptTemplates.length === 0) { - setConfirmState({ - title: "AI Tools", - message: "Add at least one prompt template in Settings first.", - actionLabel: "OK", - onConfirm: () => {} - }); - return; - } const menu = await Menu.new({ items: [ @@ -2151,6 +2142,14 @@ export default function App() { useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { if (event.defaultPrevented) return; + if (customPromptOpen && event.key === "Escape") { + event.preventDefault(); + setCustomPromptOpen(false); + return; + } + if (customPromptOpen) { + return; + } const isFind = (event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "f"; if (isFind && !settingsOpen && !confirmState) { @@ -2176,7 +2175,7 @@ export default function App() { window.addEventListener("keydown", handleKeyDown); return () => window.removeEventListener("keydown", handleKeyDown); - }, [confirmState, handleSaveVersion, openDocumentSearch, settingsOpen]); + }, [confirmState, customPromptOpen, handleSaveVersion, openDocumentSearch, settingsOpen]); const renderTextItem = (text: Text) => (
{isConverting ? "Cancel AI Edit" : "AI Tools"} @@ -2899,6 +2898,53 @@ export default function App() {
) : null} + {customPromptOpen ? ( +
+
setCustomPromptOpen(false)} /> +
+
Custom Prompt
+
+ Tell the AI what it should do with the current text. +
+