a tool for shared writing and social publishing

fix textarea wrapping issues

+12 -5
+1
components/Blocks/BaseTextareaBlock.tsx
··· 15 return ( 16 <AsyncValueAutosizeTextarea 17 {...passDownProps} 18 onKeyDown={(e) => { 19 if (e.key === "ArrowUp") { 20 let selection = e.currentTarget.selectionStart;
··· 15 return ( 16 <AsyncValueAutosizeTextarea 17 {...passDownProps} 18 + noWrap 19 onKeyDown={(e) => { 20 if (e.key === "ArrowUp") { 21 let selection = e.currentTarget.selectionStart;
+6 -4
components/utils/AutosizeTextarea.tsx
··· 10 export type AutosizeTextareaProps = React.DetailedHTMLProps< 11 React.TextareaHTMLAttributes<HTMLTextAreaElement>, 12 HTMLTextAreaElement 13 - >; 14 export const AutosizeTextarea = forwardRef< 15 HTMLTextAreaElement, 16 AutosizeTextareaProps 17 - >((props: AutosizeTextareaProps, ref) => { 18 let textarea = useRef<HTMLTextAreaElement | null>(null); 19 useImperativeHandle(ref, () => textarea.current as HTMLTextAreaElement); 20 21 return ( 22 <div 23 - className={`${styles["grow-wrap"]} ${props.className} `} 24 data-replicated-value={props.value} 25 style={props.style} 26 > 27 <textarea 28 rows={1} 29 - {...props} 30 ref={textarea} 31 className={`placeholder:text-tertiary bg-transparent ${props.className}`} 32 />
··· 10 export type AutosizeTextareaProps = React.DetailedHTMLProps< 11 React.TextareaHTMLAttributes<HTMLTextAreaElement>, 12 HTMLTextAreaElement 13 + > & { noWrap?: boolean }; 14 export const AutosizeTextarea = forwardRef< 15 HTMLTextAreaElement, 16 AutosizeTextareaProps 17 + >((props: AutosizeTextareaProps & { noWrap?: boolean }, ref) => { 18 let textarea = useRef<HTMLTextAreaElement | null>(null); 19 + let { noWrap, ...rest } = props; 20 useImperativeHandle(ref, () => textarea.current as HTMLTextAreaElement); 21 22 + console.log({ noWrap }); 23 return ( 24 <div 25 + className={`${styles["grow-wrap"]} ${props.className} ${noWrap ? styles["no-wrap"] : ""}`} 26 data-replicated-value={props.value} 27 style={props.style} 28 > 29 <textarea 30 rows={1} 31 + {...rest} 32 ref={textarea} 33 className={`placeholder:text-tertiary bg-transparent ${props.className}`} 34 />
+5 -1
components/utils/textarea-styles.module.css
··· 11 content: attr(data-replicated-value) " "; 12 13 /* This is how textarea text behaves */ 14 - white-space: pre; 15 16 /* Hidden from view, clicks, and screen readers */ 17 visibility: hidden; ··· 36 .grow-wrap > textarea:focus { 37 outline: none; 38 }
··· 11 content: attr(data-replicated-value) " "; 12 13 /* This is how textarea text behaves */ 14 + white-space: pre-wrap; 15 16 /* Hidden from view, clicks, and screen readers */ 17 visibility: hidden; ··· 36 .grow-wrap > textarea:focus { 37 outline: none; 38 } 39 + 40 + .no-wrap::after { 41 + white-space: pre !important; 42 + }