Skip to content

Interface: IAnnotationsContext

Defines the context interface for managing annotations in a React application.

Description

Provides state and methods for handling annotation collections, current annotation selection, styling, and editor control.

Properties

add()

ts
add: (annotation) => void;

Add annotations

Parameters

annotation

AnnotationCollection | Annotation

Returns

void


annotations

ts
annotations: AnnotationCollection;

Current annotations in the application.


arrowStyle

ts
arrowStyle: ArrowStyles;

The current arrow style for annotations.


arrowWidthFactor

ts
arrowWidthFactor: number;

The current width factor for arrow annotations.


cancelDrawing()

ts
cancelDrawing: () => void;

Cancel the current drawing operation

Returns

void


canRedo

ts
canRedo: boolean;

Whether redo is available


canUndo

ts
canUndo: boolean;

Whether undo is available


clearHistory()

ts
clearHistory: () => void;

Clear the history

Returns

void


currentAnnotation

ts
currentAnnotation: AnnotationFeature<Geometry, AnnotationProps> | null;

The currently selected annotation in the application.


editor

ts
editor: Control;

The annotations editor for managing annotations. See AnnotationsEditor


enableBoxDrawing()

ts
enableBoxDrawing: (style?) => void;

Enable box drawing mode

Parameters

style?

Partial<BoxStyle | undefined>

Returns

void


enableCommentDrawing()

ts
enableCommentDrawing: (options?) => void;

Enable comment drawing mode

Parameters

options?
arrowStyle?

Partial<ArrowProperties>

commentStyle?

Partial<CommentProps>

offsetX?

number

offsetY?

number

Returns

void


enablePolygonDrawing()

ts
enablePolygonDrawing: (style?) => void;

Enable polygon drawing mode

Parameters

style?

Partial<PolygonStyle | undefined>

Returns

void


redo()

ts
redo: () => boolean;

Redo the last undone action

Returns

boolean


remove()

ts
remove: (annotation) => void;

Remove annotations

Parameters

annotation

AnnotationCollection | Annotation

Returns

void


select()

ts
select: (ids) => void;

Select annotations by ID

Parameters

ids

string | string[]

Returns

void


setArrowStyle()

ts
setArrowStyle: (arrowStyle) => void;

Sets the current arrow style for annotations.

Parameters

arrowStyle

ArrowStyles

Returns

void


setArrowWidthFactor()

ts
setArrowWidthFactor: (arrowWidthFactor) => void;

Sets the width factor for arrow annotations.

Parameters

arrowWidthFactor

number

Returns

void


setCurrentAnnotation()

ts
setCurrentAnnotation: (annotation) => void;

Sets the currently selected annotation in the application.

Parameters

annotation

AnnotationFeature<Geometry, AnnotationProps> | null

Returns

void


setEditor()

ts
setEditor: (editor) => void;

Sets the current annotations editor for managing annotations.

Parameters

editor

Control

Returns

void


setTextSizeFactor()

ts
setTextSizeFactor: (textSizeFactor) => void;

Sets the size factor for text annotations.

Parameters

textSizeFactor

number

Returns

void


setTextStyle()

ts
setTextStyle: (textStyle) => void;

Sets the current text style for annotations.

Parameters

textStyle

TextStyle

Returns

void


textSizeFactor

ts
textSizeFactor: number;

The current size factor for text annotations in regards to node sizes.


textStyle

ts
textStyle: TextStyle;

The current text style for annotations.


undo()

ts
undo: () => boolean;

Undo the last action

Returns

boolean