From d0483ba15b4ad13399a3385ae351cf33cca3db7f Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Fri, 18 Aug 2023 00:59:27 -0700 Subject: feat: :sparkles: alt+cmd+d to automatically debug terminal! --- .../src/components/UserInputContainer.tsx | 50 ++++++++++------------ 1 file changed, 22 insertions(+), 28 deletions(-) (limited to 'extension/react-app/src/components') 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); + }} /> ) : ( { ) : ( - <> - { - setIsEditing((prev) => !prev); - e.stopPropagation(); - }} - text="Edit" - > - - - - { - props.onDelete(); - e.stopPropagation(); - }} - text="Delete" - > - - - + { + props.onDelete(); + e.stopPropagation(); + }} + text="Delete" + > + + )} )} -- cgit v1.2.3-70-g09d2