import React from 'react' import {hot} from 'react-hot-loader' import {TextAnnotator, TokenAnnotator} from '../../src' const TEXT = `On Monday night , Mr. Fallon will have a co-host for the first time : The rapper Cardi B , who just released her first album, " Invasion of Privacy . "` const TAG_COLORS = { ORG: '#00ffa2', PERSON: '#84d2ff', } const Card = ({children}) => (
{children}
) class App extends React.Component { state = { value: [{start: 17, end: 19, tag: 'PERSON'}], tag: 'PERSON', } handleChange = value => { this.setState({value}) } handleTagChange = e => { this.setState({tag: e.target.value}) } render() { return (

react-text-annotate

Github

A React component for interactively highlighting parts of text.

Default

({ ...span, tag: this.state.tag, color: TAG_COLORS[this.state.tag], })} />

Custom rendered mark

({ ...span, tag: this.state.tag, color: TAG_COLORS[this.state.tag], })} renderMark={props => ( props.onClick({start: props.start, end: props.end})} > {props.content} [{props.tag}] )} />

Current Value

{JSON.stringify(this.state.value, null, 2)}
) } } export default hot(module)(App)