react-taggy icon indicating copy to clipboard operation
react-taggy copied to clipboard

Add onClick and onHighlight callbacks

Open vemonet opened this issue 3 years ago • 0 comments

Hi @johncmunson , thanks a lot for this simple, yet useful library!

I added callbacks when a tag is clicked or the text is highlighted, plus fixed small things

It was mentioned in this issue: https://github.com/johncmunson/react-taggy/issues/2

Here are the detailed changes:

  • Add a clickTag(event, tag, elemIndex) prop to pass a function triggered when a tag is clicked (useful to edit or delete tags)
  • Add a onHighlight(event, text, spanIndex, start, end) prop to pass a function triggered when text is highlighted using the mouse (useful to add new tags)
  • Additional properties passed to the spans objects are now kept (instead of just adding start, end and token)
  • Fix bug when the spans array is not sorted by start position

You can see it in action here (after running the prediction): https://collaboratory.semanticscience.org

vemonet avatar Mar 22 '22 11:03 vemonet