react-text-annotate icon indicating copy to clipboard operation
react-text-annotate copied to clipboard

Custom `renderMark` for TextAnnotator

Open guillaumedsde opened this issue 5 years ago • 8 comments

Custom renderMark for TextAnnotator

Hi, I could be mistaken, but am I right in thinking, that it is possible to implement a custom renderMark optionally passed through props to the TextAnnotator component?

I am looking to implement a popover menu that appears above the selection and for that it would be useful for me to be able to pass a custom mark.

Example

is modifying TextAnnotator like so feasible?


class TextAnnotator extends React.Component<TextAnnotatorProps, {}> {
  static defaultProps = {
    renderMark: props => <Mark {...props} />,
  }

  // ...

  render() {
    const {content, value, style} = this.props
    const splits = splitWithOffsets(content, value)
    return (
      <div style={style} ref={this.rootRef}>
        {splits.map((split, i) =>
          split.mark ? (
            renderMark({
              key: `${split.start}-${split.end}`,
              ...split,
              onClick: this.handleSplitClick,
            })
          ) : (
            <Split key={`${split.start}-${split.end}`} {...split} onClick={this.handleSplitClick} />
          )
        )}
      </div>
    )
  }
}

guillaumedsde avatar Dec 13 '19 10:12 guillaumedsde

Working on in #8 - I need to refactor some of the click logic. Clicking on a mark currently deselects it

mcamac avatar Dec 15 '19 04:12 mcamac

Cheers, do you have a PayPal or somewhere I could buy you a coffee ? :)

guillaumedsde avatar Dec 15 '19 16:12 guillaumedsde

Hi, I am also interested in customizing the mark for the text annotator. Cheers to the good work thus far.

junwen29 avatar May 06 '20 12:05 junwen29

Is this resolved now? The PR is still open

v-sinha9004 avatar Aug 23 '21 08:08 v-sinha9004

@mcamac Text Annotator is really Great. Can you please let us know if renderMark for TextAnnotator is complete ? When is this PR getting merged ?

Thanks

chetandhadankar avatar Jan 31 '22 09:01 chetandhadankar

can you please add renderMark function to text annotator ???? its really urgent @mcamac

sparshva avatar May 24 '22 12:05 sparshva

Hi,

I'm looking to implement a selection popover similar to @guillaumedsde, however I wan to show a list of labels on selection, allowing to choose a label. Is this PR merged?

Thanks.

Dimiftb avatar Nov 22 '22 13:11 Dimiftb

Update for everyone, I solved the custom changes I wanted to do by taking his code and implementing it as plain typescript, seeing as this repo seems managed no longer.

Dimiftb avatar Nov 24 '22 13:11 Dimiftb