diff --git a/app/src/components/code/JSONEditor.tsx b/app/src/components/code/JSONEditor.tsx index f3adf4c76b..913a15afe0 100644 --- a/app/src/components/code/JSONEditor.tsx +++ b/app/src/components/code/JSONEditor.tsx @@ -1,7 +1,8 @@ import React, { useEffect, useMemo } from "react"; +import { defaultKeymap } from "@codemirror/commands"; import { json, jsonLanguage, jsonParseLinter } from "@codemirror/lang-json"; import { linter } from "@codemirror/lint"; -import { EditorView, hoverTooltip } from "@codemirror/view"; +import { EditorView, hoverTooltip, keymap } from "@codemirror/view"; import { githubLight } from "@uiw/codemirror-theme-github"; import { nord } from "@uiw/codemirror-theme-nord"; import CodeMirror, { ReactCodeMirrorProps } from "@uiw/react-codemirror"; @@ -45,7 +46,14 @@ export function JSONEditor(props: JSONEditorProps) { // If optionalLint is true, we only lint when there is content to allow for empty json values const shouldLint = !optionalLint || (contentLength && contentLength > 0); const extensions = useMemo(() => { - const baseExtensions = [json(), EditorView.lineWrapping]; + const baseExtensions = [ + json(), + EditorView.lineWrapping, + // Reserve Mod-Enter for the submit button + keymap.of([ + ...defaultKeymap.filter((binding) => binding.key !== "Mod-Enter"), + ]), + ]; if (shouldLint) { baseExtensions.push(linter(jsonParseLinter())); diff --git a/app/src/pages/playground/PlaygroundRunButton.tsx b/app/src/pages/playground/PlaygroundRunButton.tsx index ea4912bc5e..7632930baa 100644 --- a/app/src/pages/playground/PlaygroundRunButton.tsx +++ b/app/src/pages/playground/PlaygroundRunButton.tsx @@ -1,8 +1,8 @@ import React, { useCallback } from "react"; +import { useHotkeys } from "react-hotkeys-hook"; import { Button, Icon, Icons } from "@phoenix/components"; import { usePlaygroundContext } from "@phoenix/contexts/PlaygroundContext"; -import { useHotkeys } from "react-hotkeys-hook"; export function PlaygroundRunButton() { const runPlaygroundInstances = usePlaygroundContext(