API

API

The browser module parses, renders and edits one annotation format. The React package wraps the image and the editor.

NameDescription
parseAnnotations(value)Reads a version 1 document, its JSON string, or a bare array. Invalid annotations are dropped. An unknown version throws.
serializeAnnotations(value)Writes the version 1 JSON document.
annotationsToHtml(value), annotationsFromHtml(element)Writes the annotations as an ordered list in HTML, and reads them back from it.
renderAnnotations(value, { ratio, id })Returns the overlay markup for an image ratio and a unique id, for server rendering.
createAnnotatedImage(root, options)Renders an image with its annotations and keeps them placed on resize. Returns update and destroy.
createAnnotationEditor(root, options)A controlled editor. It reports every change through onChange and leaves storage to you.
setAnnotations, setTool, updateSelection, removeSelection, undo, redo, destroyThe editor's methods. The keyboard reaches the same actions.
AnnotatedImage, AnnotationEditorThe React components around the same code. The editor adds a toolbar and a label field.