textarea improvements

This commit is contained in:
Jing Hua 2023-03-04 10:05:15 +08:00
parent 79c7dd2603
commit 7f39bbf5b0

View file

@ -1,4 +1,4 @@
import React, { useState } from 'react'; import React, { useEffect, useState } from 'react';
import ReactMarkdown from 'react-markdown'; import ReactMarkdown from 'react-markdown';
import hljs from 'highlight.js'; import hljs from 'highlight.js';
import DOMPurify from 'dompurify'; import DOMPurify from 'dompurify';
@ -263,6 +263,13 @@ const EditView = ({
} }
}; };
useEffect(() => {
if (textareaRef.current) {
textareaRef.current.style.height = 'auto';
textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;
}
}, []);
return ( return (
<> <>
<textarea <textarea