@@ -3,7 +3,6 @@ import React, {useState} from 'react'
33
44export default function TextForm ( props ) {
55 const handleUpClick = ( ) => {
6- // console.log("Uppercase was clicked: " + text);
76 let newText = text . toUpperCase ( ) ;
87 setText ( newText )
98 props . showAlert ( "Converted to uppercase!" , "success" ) ;
@@ -22,17 +21,12 @@ export default function TextForm(props) {
2221 }
2322
2423 const handleOnChange = ( event ) => {
25- // console.log("On change");
2624 setText ( event . target . value )
2725 }
2826
2927 // Credits: A
3028 const handleCopy = ( ) => {
31- console . log ( "I am copy" ) ;
32- var text = document . getElementById ( "myBox" ) ;
33- text . select ( ) ;
34- navigator . clipboard . writeText ( text . value ) ;
35- document . getSelection ( ) . removeAllRanges ( ) ;
29+ navigator . clipboard . writeText ( text ) ;
3630 props . showAlert ( "Copied to Clipboard!" , "success" ) ;
3731 }
3832
@@ -61,7 +55,7 @@ export default function TextForm(props) {
6155 </ div >
6256 < div className = "container my-3" style = { { color : props . mode === 'dark' ?'white' :'#042743' } } >
6357 < h2 > Your text summary</ h2 >
64- < p > { text . split ( " " ) . filter ( ( element ) => { return element . length !== 0 } ) . length } words and { text . length } characters</ p >
58+ < p > { text . split ( / \s + / ) . filter ( ( element ) => { return element . length !== 0 } ) . length } words and { text . length } characters</ p >
6559 < p > { 0.008 * text . split ( " " ) . filter ( ( element ) => { return element . length !== 0 } ) . length } Minutes read</ p >
6660 < h2 > Preview</ h2 >
6761 < p > { text . length > 0 ?text :"Nothing to preview!" } </ p >
0 commit comments