copy on click and ctrl+c was added

This commit is contained in:
Vladimir Khvan 2023-02-13 16:36:56 +05:00
parent 700b5a88c3
commit c573c87066

View File

@ -57,6 +57,10 @@ const Textarea = ({
numerationValue.push(i); numerationValue.push(i);
} }
function onTextareaClick() {
areaRef.current.select();
}
useEffect(() => { useEffect(() => {
if (isJSONField) { if (isJSONField) {
if (modifiedValue && isJSON(modifiedValue)) { if (modifiedValue && isJSON(modifiedValue)) {
@ -74,7 +78,10 @@ const Textarea = ({
}, [areaSelect]); }, [areaSelect]);
return ( return (
<Wrapper> <Wrapper
isJSONField={isJSONField}
onFocus={isJSONField ? onTextareaClick : undefined}
>
{isJSONField && ( {isJSONField && (
<StyledCopyIcon <StyledCopyIcon
src={copyIcon} src={copyIcon}
@ -103,6 +110,7 @@ const Textarea = ({
<StyledTextarea <StyledTextarea
id={id} id={id}
isJSONField={isJSONField}
placeholder={placeholder} placeholder={placeholder}
onChange={(e) => onChange && onChange(e)} onChange={(e) => onChange && onChange(e)}
maxLength={maxLength} maxLength={maxLength}