Add the Nook "Rich Text Editor" component to this project, exactly as Nook ships it.
A small editor for formatted text: headings, lists, quotes and links.
Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add rich-text-editor`. It writes `components/ui/rich-text-editor.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/rich-text-editor.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:
```tsx
import { Label } from "@/components/ui/label";
import { RichTextEditor } from "@/components/ui/rich-text-editor";
const NOTES = `
Release notes
Version 2.4 ships saved filters and a faster search.
Filters stay after a reload
Search answers in under a second
Thanks to everyone who tested the beta.
`;
export default function RichTextEditorDefault() {
return (
);
}
```
API
- `RichTextEditor`: The toolbar and the writing area. Pasted content comes in as plain text.
- `defaultValue` (`string`): The starting content, as HTML you trust.
- `onValueChange` (`(html: string) => void`): Called with the HTML after every change. Sanitize it before showing it elsewhere.
- `placeholder` (`string`): Shown while empty.
- `name` (`string`): Name submitted with a form. The value is the HTML.
- `disabled` (`boolean`): Prevents editing.
Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: The writing area is a multi-line textbox: name it with `aria-label` or `aria-labelledby`. The toolbar is one Tab stop; arrow keys move between tools and each reports whether it is on. Ctrl or ⌘ with B, I, U and Z work as usual.
Done when the component renders like the example in light and dark mode and the project type-checks.