0Words
0Characters
0Lines
0Min read
Clean up a draft without sending a single character anywhere.
Text Pocket is a collection of small, predictable text transforms. Nothing is sent away and nothing clever happens behind a loading spinner.
Each button runs one pure function. That makes the result easy to test and avoids a chain of hidden changes the visitor did not ask for.
Word count, line count, character count, and reading time are recalculated from the current text with useMemo. There is no second copy of the truth to drift out of sync.
Whitespace is cleaned line by line first. Only runs of three or more newlines become a normal paragraph break, so intentional structure remains.
value.split("\n")
.map(line => line.replace(/\s+/g, " ").trim())
.join("\n")
.replace(/\n{3,}/g, "\n\n")
.trim();