From 81827e2debb456c329ab28ad2ab6749f25e98c29 Mon Sep 17 00:00:00 2001 From: nafees nazik Date: Mon, 18 Sep 2023 21:33:26 +0530 Subject: [PATCH 1/8] chore: remove content editable --- frontend/package-lock.json | 28 ++++------------------------ frontend/package.json | 1 - 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index e6847b42c..28ea1859e 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -72,7 +72,6 @@ "react": "^17.0.2", "react-beautiful-dnd": "^13.1.1", "react-code-input": "^3.10.1", - "react-contenteditable": "^3.3.7", "react-day-picker": "^8.8.0", "react-dom": "^17.0.2", "react-grid-layout": "^1.3.4", @@ -13340,7 +13339,8 @@ "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true }, "node_modules/fast-diff": { "version": "1.3.0", @@ -19594,18 +19594,6 @@ "react-dom": ">=16.8.0" } }, - "node_modules/react-contenteditable": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/react-contenteditable/-/react-contenteditable-3.3.7.tgz", - "integrity": "sha512-GA9NbC0DkDdpN3iGvib/OMHWTJzDX2cfkgy5Tt98JJAbA3kLnyrNbBIpsSpPpq7T8d3scD39DHP+j8mAM7BIfQ==", - "dependencies": { - "fast-deep-equal": "^3.1.3", - "prop-types": "^15.7.1" - }, - "peerDependencies": { - "react": ">=16.3" - } - }, "node_modules/react-day-picker": { "version": "8.8.0", "resolved": "https://registry.npmjs.org/react-day-picker/-/react-day-picker-8.8.0.tgz", @@ -33272,7 +33260,8 @@ "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true }, "fast-diff": { "version": "1.3.0", @@ -37807,15 +37796,6 @@ "dev": true, "requires": {} }, - "react-contenteditable": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/react-contenteditable/-/react-contenteditable-3.3.7.tgz", - "integrity": "sha512-GA9NbC0DkDdpN3iGvib/OMHWTJzDX2cfkgy5Tt98JJAbA3kLnyrNbBIpsSpPpq7T8d3scD39DHP+j8mAM7BIfQ==", - "requires": { - "fast-deep-equal": "^3.1.3", - "prop-types": "^15.7.1" - } - }, "react-day-picker": { "version": "8.8.0", "resolved": "https://registry.npmjs.org/react-day-picker/-/react-day-picker-8.8.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index d954da2a8..42cd32385 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -80,7 +80,6 @@ "react": "^17.0.2", "react-beautiful-dnd": "^13.1.1", "react-code-input": "^3.10.1", - "react-contenteditable": "^3.3.7", "react-day-picker": "^8.8.0", "react-dom": "^17.0.2", "react-grid-layout": "^1.3.4", From 7f753b23f80aeda8873a24d365e90922bb387ef9 Mon Sep 17 00:00:00 2001 From: nafees nazik Date: Mon, 18 Sep 2023 21:39:50 +0530 Subject: [PATCH 2/8] fix: secret input --- .../components/v2/SecretInput/SecretInput.tsx | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) 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 ( -
-
+
+          
+            
+          
+        
+ +