File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ export default function App() {
5555
5656 const handleSetValue = ( text = 'default value' ) => {
5757 textRef . current = text ;
58- inputRef . current ?. setText ( value ) ;
58+ inputRef . current ?. setText ( text ) ;
5959 inputRef . current ?. setSelection ( text . length , text . length ) ;
6060 } ;
6161
@@ -295,7 +295,23 @@ export default function App() {
295295 ) ;
296296}
297297
298- const ImageInfo = ( { image } : { image : any } ) => {
298+ const ImageInfo = ( { image } : { image : onPasteImageEventData } ) => {
299+ function formatFileSize ( bytes : number ) : string {
300+ if ( bytes <= 0 ) return '0 KB' ;
301+
302+ const KB = 1024 ;
303+ const MB = KB * KB ;
304+
305+ const sizeInMB = bytes / MB ;
306+
307+ if ( sizeInMB < 0.9 ) {
308+ const sizeInKB = bytes / KB ;
309+ return `${ sizeInKB . toFixed ( 1 ) } KB` ;
310+ }
311+
312+ return `${ sizeInMB . toFixed ( 2 ) } MB` ;
313+ }
314+
299315 return (
300316 < View >
301317 < Text style = { { color : 'red' , fontWeight : 'bold' } } >
@@ -319,7 +335,7 @@ const ImageInfo = ({ image }: { image: any }) => {
319335 fontWeight : 'regular' ,
320336 } }
321337 >
322- { image . fileSize }
338+ { image . fileSize } ( { formatFileSize ( image . fileSize ) } )
323339 </ Text >
324340 </ Text >
325341 < Text style = { { color : 'red' , fontWeight : 'bold' } } >
You can’t perform that action at this time.
0 commit comments