Secretmapper / react-image-annotation

An infinitely customizable image annotation library built on React
https://secretmapper.github.io/react-image-annotation/
MIT License
326 stars 135 forks source link

Expose types correctly and add support for generic annotations #60

Open joelpoloney opened 3 years ago

joelpoloney commented 3 years ago

Fixed 2 things:

  1. The TypeScript definitions were not being exposed correctly, the change to package.json fixes that. I followed the instructions at https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html.
  2. Expose the key property that is provided to renderHighlight -- this definition was out of date.

Added new:

  1. Support for generic IAnnotation objects so you can use your own version of the Annotation object and include your own data outside of just text and an id. You use it like this:

    import { IAnnotation } from 'react-image-annotation'
    
    export interface MyAnnotation extends Omit<IAnnotation, 'data'> {
      data: {
        id?: string
        updatedAt: Date
        type: string
        userVisibleName: string
        metadata: Record<string, unknown>
      }
    }