@@ -19,9 +19,20 @@ export function MarkdownEditor({
1919 rows = 6
2020} : MarkdownEditorProps ) {
2121 const [ showPreview , setShowPreview ] = useState ( false ) ;
22+ const [ isMobile , setIsMobile ] = useState ( false ) ;
2223 const textareaRef = useRef < HTMLTextAreaElement > ( null ) ;
2324 const { t } = useTranslation ( ) ;
2425
26+ useEffect ( ( ) => {
27+ const checkMobile = ( ) => {
28+ setIsMobile ( window . innerWidth < 768 ) ;
29+ } ;
30+
31+ checkMobile ( ) ;
32+ window . addEventListener ( 'resize' , checkMobile ) ;
33+ return ( ) => window . removeEventListener ( 'resize' , checkMobile ) ;
34+ } , [ ] ) ;
35+
2536 const insertText = ( before : string , after : string = '' , placeholder : string = '' ) => {
2637 const textarea = textareaRef . current ;
2738 if ( ! textarea ) return ;
@@ -112,7 +123,7 @@ export function MarkdownEditor({
112123 } ;
113124
114125 return (
115- < div className = { `border border-gray-300 dark:border-gray-600 rounded-md ${ className } ` } >
126+ < div className = { `border border-gray-300 dark:border-gray-600 rounded-md ${ isMobile ? 'markdown-editor-mobile' : '' } ${ className } ` } >
116127 { /* Toolbar */ }
117128 < div className = "flex items-center gap-1 p-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 rounded-t-md" >
118129 { toolbarButtons . map ( ( button , index ) => (
@@ -161,7 +172,7 @@ export function MarkdownEditor({
161172 onKeyDown = { handleKeyDown }
162173 placeholder = { placeholder }
163174 rows = { rows }
164- className = " w-full p-4 bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 font-mono text-sm resize-y focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent rounded-b-md"
175+ className = { ` w-full p-4 bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 font-mono text-sm resize-y focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent rounded-b-md ${ isMobile ? 'max-w-full box-border' : '' } ` }
165176 />
166177 ) }
167178 </ div >
0 commit comments