summaryrefslogtreecommitdiff
path: root/extension/react-app/src/components/TextDialog.tsx
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-07-24 01:31:54 -0700
committerNate Sesti <sestinj@gmail.com>2023-07-24 01:31:54 -0700
commit96b3f2c15de5f7cdab646323b65a92aeeb08ae17 (patch)
tree0c6235df9885079de82e5c392042eb2c7aae088c /extension/react-app/src/components/TextDialog.tsx
parentdac960348a938552de4a6fcfaff32e517e6ebcb1 (diff)
parent6efe8ce9db21f1991dc1b5cc68657f419afca825 (diff)
downloadsncontinue-96b3f2c15de5f7cdab646323b65a92aeeb08ae17.tar.gz
sncontinue-96b3f2c15de5f7cdab646323b65a92aeeb08ae17.tar.bz2
sncontinue-96b3f2c15de5f7cdab646323b65a92aeeb08ae17.zip
Merge branch 'main' into config-py
Diffstat (limited to 'extension/react-app/src/components/TextDialog.tsx')
-rw-r--r--extension/react-app/src/components/TextDialog.tsx60
1 files changed, 33 insertions, 27 deletions
diff --git a/extension/react-app/src/components/TextDialog.tsx b/extension/react-app/src/components/TextDialog.tsx
index 7c6ba052..7d8e9920 100644
--- a/extension/react-app/src/components/TextDialog.tsx
+++ b/extension/react-app/src/components/TextDialog.tsx
@@ -3,6 +3,7 @@ import React, { useEffect, useState } from "react";
import styled from "styled-components";
import { Button, secondaryDark, vscBackground, vscForeground } from ".";
import { isMetaEquivalentKeyPressed } from "../util";
+import { ReactMarkdown } from "react-markdown/lib/react-markdown";
const ScreenCover = styled.div`
position: fixed;
@@ -56,6 +57,7 @@ const TextDialog = (props: {
onEnter: (text: string) => void;
onClose: () => void;
message?: string;
+ entryOn?: boolean;
}) => {
const [text, setText] = useState("");
const textAreaRef = React.createRef<HTMLTextAreaElement>();
@@ -79,33 +81,37 @@ const TextDialog = (props: {
}}
>
<Dialog>
- <P>{props.message || ""}</P>
- <TextArea
- rows={10}
- ref={textAreaRef}
- onKeyDown={(e) => {
- if (
- e.key === "Enter" &&
- isMetaEquivalentKeyPressed(e) &&
- textAreaRef.current
- ) {
- props.onEnter(textAreaRef.current.value);
- setText("");
- } else if (e.key === "Escape") {
- props.onClose();
- }
- }}
- />
- <Button
- onClick={() => {
- if (textAreaRef.current) {
- props.onEnter(textAreaRef.current.value);
- setText("");
- }
- }}
- >
- Enter
- </Button>
+ <ReactMarkdown>{props.message || ""}</ReactMarkdown>
+ {props.entryOn && (
+ <>
+ <TextArea
+ rows={10}
+ ref={textAreaRef}
+ onKeyDown={(e) => {
+ if (
+ e.key === "Enter" &&
+ isMetaEquivalentKeyPressed(e) &&
+ textAreaRef.current
+ ) {
+ props.onEnter(textAreaRef.current.value);
+ setText("");
+ } else if (e.key === "Escape") {
+ props.onClose();
+ }
+ }}
+ />
+ <Button
+ onClick={() => {
+ if (textAreaRef.current) {
+ props.onEnter(textAreaRef.current.value);
+ setText("");
+ }
+ }}
+ >
+ Enter
+ </Button>
+ </>
+ )}
</Dialog>
</DialogContainer>
</ScreenCover>