A component for rendering popovers according to your current text selection
npm install react-text-selection-popover-cgnybash
npm install --save react-text-selection-popover
`
Usage
`tsx
import css from '@emotion/css'
render={
({ clientRect, isCollapsed, textContent }) => {
if (clientRect == null || isCollapsed) return null
// I'm using emotion for this example but you can use anything really
const style = css
return
Selecting {(textContent || '').length} characters
}
}
/>
`
$3
| name | type | description |
| --- | ---- | --- |
| render | ({ clientRect, isCollapsed, textContent }) => {} | __required__ Render prop for rendering your popover, see above for usage |
| mount | HTMLElement | Dom Element that Popover will be rendered into (This component uses React Portals. Defaults to document.body |
| target | HTMLElement` | Dom Element which the popover is constrained to |