Selection Actions
ProNewHighlight any passage to summon a floating AI rewrite toolbar with inline diff preview and one-click replacement.
Installation
pnpm dlx shadcn@latest add @viewport/selection-actions
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| initialText* | stringEditable passage shown inside the document surface. | — |
| defaultHighlight | stringHighlighted span inside `initialText` to pre-select on mount (or let the user select any text). | — |
| actions* | RewriteAction[]Rewrite actions shown in the floating toolbar. | — |
| onApply | (nextText: string) => voidCalled whenever a rewrite is accepted. | — |
| className | string | — |
Accessibility
- Rewrite controls are grouped in a labelled toolbar with aria-pressed states.
- Proposed changes use semantic del and ins elements.
- Toolbar entrance and diff panel respect prefers-reduced-motion.