import InfoArea from "@/common/components/InfoArea"; import Button from "@/common/components/Button"; import {faShare} from "@fortawesome/free-solid-svg-icons"; import TextArea from "@/pages/tools/base64/components/TextArea"; import {useState} from "react"; import "./styles.sass"; import {useSearchParams} from "react-router-dom"; export const CharCounter = () => { const [searchParams] = useSearchParams(); const [inputString, setInputString] = useState(searchParams.get("input") || ""); const calculateWords = () => inputString.split("\n").filter(line => line !== "").map(line => line.split(" ") .filter(word => word !== "").length).reduce((a, b) => a + b, 0); const shareLink = () => { const url = new URL(window.location.href); url.searchParams.set("input", inputString); navigator.clipboard.writeText(url.href); } return ( <> setInputString(e.target.value)} placeholder="Text eingeben..." /> {inputString.length} Zeichen {calculateWords()} Wörter {inputString.split("\n").filter(line => line !== "").length} Zeilen > ); }