File size: 805 Bytes
f5d25f5 836dd88 f5d25f5 836dd88 f5d25f5 836dd88 f5d25f5 836dd88 f5d25f5 f43196f f5d25f5 836dd88 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
'use client';
import { TitleBar } from "@/components/title-bar/TitleBar";
import { useTextStore } from "./TextStore";
import { useDebouncedCallback } from "use-debounce";
import wordsCount from "words-count";
export function TextWidget() {
const { text, updateText } = useTextStore();
const debounced = useDebouncedCallback(
(content: string) => {
updateText(content);
},
1000
)
return (
<section className="w-full flex flex-col">
<TitleBar label="Text Content">
{wordsCount(text)} words
</TitleBar>
<textarea
onInput={(e) => debounced(e.currentTarget.value)}
defaultValue={text}
className="w-full min-h-52 md:min-h-0 h-full outline-none p-12 text-lg"
placeholder="Begin writing..."
/>
</section>
)
}
|