diff options
| author | Nate Sesti <sestinj@gmail.com> | 2023-08-18 00:59:27 -0700 | 
|---|---|---|
| committer | Nate Sesti <sestinj@gmail.com> | 2023-08-18 00:59:27 -0700 | 
| commit | d0483ba15b4ad13399a3385ae351cf33cca3db7f (patch) | |
| tree | 1aeb6f954a9ef8a5cd4b6360d5349acedf2df62b /extension/react-app/src/components | |
| parent | 6abe7be1680b5d8ebc7b540df2393ae6e1f268b7 (diff) | |
| download | sncontinue-d0483ba15b4ad13399a3385ae351cf33cca3db7f.tar.gz sncontinue-d0483ba15b4ad13399a3385ae351cf33cca3db7f.tar.bz2 sncontinue-d0483ba15b4ad13399a3385ae351cf33cca3db7f.zip  | |
feat: :sparkles: alt+cmd+d to automatically debug terminal!
Diffstat (limited to 'extension/react-app/src/components')
| -rw-r--r-- | extension/react-app/src/components/UserInputContainer.tsx | 50 | 
1 files changed, 22 insertions, 28 deletions
diff --git a/extension/react-app/src/components/UserInputContainer.tsx b/extension/react-app/src/components/UserInputContainer.tsx index 9784a615..fe85c431 100644 --- a/extension/react-app/src/components/UserInputContainer.tsx +++ b/extension/react-app/src/components/UserInputContainer.tsx @@ -1,5 +1,4 @@  import React, { useContext, useEffect, useRef, useState } from "react"; -import ReactMarkdown from "react-markdown";  import styled from "styled-components";  import {    defaultBorderRadius, @@ -8,11 +7,9 @@ import {    vscForeground,  } from ".";  import HeaderButtonWithText from "./HeaderButtonWithText"; -import { XMarkIcon, PencilIcon, CheckIcon } from "@heroicons/react/24/outline"; +import { XMarkIcon, CheckIcon } from "@heroicons/react/24/outline";  import { HistoryNode } from "../../../schema/HistoryNode"; -import StyledMarkdownPreview from "./StyledMarkdownPreview";  import { GUIClientContext } from "../App"; -import { text } from "stream/consumers";  interface UserInputContainerProps {    onDelete: () => void; @@ -80,13 +77,19 @@ const UserInputContainer = (props: UserInputContainerProps) => {    const client = useContext(GUIClientContext);    useEffect(() => { -    if (isEditing) { -      textAreaRef.current?.focus(); +    if (isEditing && textAreaRef.current) { +      textAreaRef.current.focus();        // Select all text -      textAreaRef.current?.setSelectionRange( +      textAreaRef.current.setSelectionRange(          0,          textAreaRef.current.value.length        ); +      // Change the size to match the contents (up to a max) +      textAreaRef.current.style.height = "auto"; +      textAreaRef.current.style.height = +        (textAreaRef.current.scrollHeight > 500 +          ? 500 +          : textAreaRef.current.scrollHeight) + "px";      }    }, [isEditing]); @@ -130,6 +133,9 @@ const UserInputContainer = (props: UserInputContainerProps) => {              }            }}            defaultValue={props.children} +          onBlur={() => { +            setIsEditing(false); +          }}          />        ) : (          <StyledPre @@ -155,27 +161,15 @@ const UserInputContainer = (props: UserInputContainerProps) => {                  <CheckIcon width="1.4em" height="1.4em" />                </HeaderButtonWithText>              ) : ( -              <> -                <HeaderButtonWithText -                  onClick={(e) => { -                    setIsEditing((prev) => !prev); -                    e.stopPropagation(); -                  }} -                  text="Edit" -                > -                  <PencilIcon width="1.4em" height="1.4em" /> -                </HeaderButtonWithText> - -                <HeaderButtonWithText -                  onClick={(e) => { -                    props.onDelete(); -                    e.stopPropagation(); -                  }} -                  text="Delete" -                > -                  <XMarkIcon width="1.4em" height="1.4em" /> -                </HeaderButtonWithText> -              </> +              <HeaderButtonWithText +                onClick={(e) => { +                  props.onDelete(); +                  e.stopPropagation(); +                }} +                text="Delete" +              > +                <XMarkIcon width="1.4em" height="1.4em" /> +              </HeaderButtonWithText>              )}            </div>          )}  | 
