diff --git a/frontend/src/components/v2/SecretInput/SecretInput.tsx b/frontend/src/components/v2/SecretInput/SecretInput.tsx index 666c41d69..1ef7feb94 100644 --- a/frontend/src/components/v2/SecretInput/SecretInput.tsx +++ b/frontend/src/components/v2/SecretInput/SecretInput.tsx @@ -1,6 +1,5 @@ /* eslint-disable react/no-danger */ -import { forwardRef, HTMLAttributes } from "react"; -import ContentEditable from "react-contenteditable"; +import { forwardRef, HTMLAttributes, useState } from "react"; import sanitizeHtml, { DisallowedTagsModes } from "sanitize-html"; import { useToggle } from "@app/hooks"; @@ -38,7 +37,7 @@ const syntaxHighlight = (content?: string | null, isVisible?: boolean) => { return newContent; }; -type Props = Omit, "onChange" | "onBlur"> & { +type Props = Omit, "onChange" | "onBlur"> & { value?: string | null; isVisible?: boolean; isDisabled?: boolean; @@ -46,30 +45,44 @@ type Props = Omit, "onChange" | "onBlur"> & { onBlur?: () => void; }; -export const SecretInput = forwardRef( - ({ value, isVisible, onChange, onBlur, isDisabled, ...props }, ref) => { +const commonClassName = + "font-mono text-base leading-5 caret-white border-none outline-none w-full break-all "; + +export const SecretInput = forwardRef( + ({ value, isVisible, onChange, onBlur, isDisabled, onFocus, ...props }, ref) => { const [isSecretFocused, setIsSecretFocused] = useToggle(); + const [text, setText] = useState(() => value || ""); + + const update = (code: string) => { + setText(code); + if (onChange) { + onChange(code); + } + }; + + const onInput = (event: any) => { + const code = event.target.value.trim() || ""; + update(code); + }; return ( -
-
+
+          
+            
+          
+        
+ +