$95 GRAYBYTE WORDPRESS FILE MANAGER $98

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 172.67.217.254 | ADMIN IP 216.73.216.180
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : mail

/home/bravrvjk/dantho.rw/wp-content/plugins/extendify/src/Draft/components/

HOME
Current File : /home/bravrvjk/dantho.rw/wp-content/plugins/extendify/src/Draft/components//DynamicTextarea.jsx
import {
	useLayoutEffect,
	useEffect,
	useRef,
	useState,
} from '@wordpress/element';
import { motion, AnimatePresence } from 'framer-motion';

export const DynamicTextarea = ({
	value,
	className,
	onChange,
	onKeyDown,
	disabled,
	placeholder,
}) => {
	const ref = useRef(null);
	const [height, setHeight] = useState('auto');

	// Dynamically resize the input by creating a temporary version and measuring the height.
	// This is a workaround for scrollHeight not reducing when text is deleted.
	useLayoutEffect(() => {
		const tempTextarea = document.createElement('textarea');
		tempTextarea.value = value || placeholder;
		tempTextarea.rows = 1; // Start at 1

		const styleProps = [
			'paddingTop',
			'paddingBottom',
			'paddingLeft',
			'paddingRight',
			'width',
			'fontFamily',
			'fontSize',
			'borderWidth',
		];

		const styles = window.getComputedStyle(ref.current);

		// apply styles to the temporary textarea
		styleProps.forEach((prop) => (tempTextarea.style[prop] = styles[prop]));

		Object.assign(tempTextarea.style, {
			position: 'absolute',
			left: '-9999px',
		});

		document.body.appendChild(tempTextarea);
		setHeight(`${tempTextarea.scrollHeight}px`);
		document.body.removeChild(tempTextarea);
	}, [value, placeholder]);

	// Focus the input.
	useEffect(() => {
		const input = ref.current;
		if (!input) return;
		if (document.activeElement === input) return;

		const inputLength = input.value.length;
		input.focus();
		input.setSelectionRange(inputLength, inputLength); // Place cursor at the end of the input.
	}, [value]);

	return (
		<AnimatePresence>
			<motion.div
				className="m-0.5 w-full"
				key="input"
				animate={{ height }}
				transition={{ duration: 0.2 }}
				style={{ lineHeight: 0 }}>
				<label htmlFor="draft-ai-textarea" className="sr-only">
					{placeholder}
				</label>
				<textarea
					ref={ref}
					id="draft-ai-textarea"
					disabled={disabled}
					className={className}
					value={value}
					rows={1}
					onChange={onChange}
					onKeyDown={onKeyDown}
					onScroll={(event) => {
						event.target.scrollTop = 0;
					}}
					placeholder={placeholder}
				/>
			</motion.div>
		</AnimatePresence>
	);
};


Current_dir [ WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
6 Nov 2025 10.43 AM
bravrvjk / bravrvjk
0755
image-generation
--
6 Nov 2025 10.43 AM
bravrvjk / bravrvjk
0755
stock-images
--
6 Nov 2025 10.43 AM
bravrvjk / bravrvjk
0755
Completion.jsx
0.599 KB
16 Jul 2024 11.59 PM
bravrvjk / bravrvjk
0644
ConsentSidebar.jsx
0.765 KB
27 Aug 2025 5.47 PM
bravrvjk / bravrvjk
0644
DraftMenu.jsx
1.219 KB
4 Mar 2024 10.54 AM
bravrvjk / bravrvjk
0644
DynamicTextarea.jsx
2.137 KB
16 Jul 2024 11.59 PM
bravrvjk / bravrvjk
0644
EditMenu.jsx
2.359 KB
3 Dec 2024 1.47 AM
bravrvjk / bravrvjk
0644
GenerateImageButtons.jsx
5.097 KB
26 Mar 2025 6.03 PM
bravrvjk / bravrvjk
0644
Input.jsx
2.51 KB
27 Aug 2025 5.47 PM
bravrvjk / bravrvjk
0644
InsertMenu.jsx
7.491 KB
15 Sep 2025 11.30 PM
bravrvjk / bravrvjk
0644
SelectedText.jsx
1.67 KB
27 Aug 2025 5.47 PM
bravrvjk / bravrvjk
0644
ToolbarMenu.jsx
5 KB
3 Dec 2024 1.47 AM
bravrvjk / bravrvjk
0644
TranslationDropdown.jsx
6.226 KB
4 Aug 2025 7.41 PM
bravrvjk / bravrvjk
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF