@labelu/image-annotator-react
Version:
image annotator for react
59 lines • 2.51 kB
TypeScript
/// <reference types="react" />
import type { ILabel, TextAnnotationType, TagAnnotationType, TextAttribute, EnumerableAttribute } from '@labelu/interface';
import type { AnnotationData, ToolName, Annotator as ImageAnnotatorClass, EditType } from '@labelu/image';
import type { ImageAnnotatorOptions } from './hooks/useImageAnnotator';
import type { AllAnnotationType, GlobalAnnotation } from './context/annotation.context';
import type { GlobalToolConfig } from './context/tool.context';
import type { ImageSample } from './context/sample.context';
export type { ImageAnnotatorOptions } from './hooks/useImageAnnotator';
export interface AnnotatorRef {
getAnnotations: () => Partial<Record<AllAnnotationType, AnnotationData[] | GlobalAnnotation[]>> | undefined;
getSample: () => ImageSample | undefined;
getEngine: () => ImageAnnotatorClass | null;
}
export interface ImageAnnotatorProps {
samples?: ImageSample[];
config?: ImageAnnotatorOptions & Partial<GlobalToolConfig>;
/**
* 预标注的标签配置
*/
preAnnotationLabels?: Partial<Record<ToolName | TextAnnotationType | TagAnnotationType, ILabel[] | TextAttribute[] | EnumerableAttribute[]>>;
preAnnotations?: Partial<Record<ToolName | TextAnnotationType | TagAnnotationType, AnnotationData[] | GlobalAnnotation[]>>;
renderSidebar?: null | (() => React.ReactNode);
renderAttributes?: () => React.ReactNode;
editingSample?: ImageSample;
maxHistoryCount?: number;
primaryColor?: string;
toolbarExtra?: React.ReactNode;
toolbarRight?: React.ReactNode;
onError?: (error: {
type: string;
message: string;
value?: any;
}) => void;
onLoad?: (engine: ImageAnnotatorClass) => void;
onLabelChange?: (toolName: ToolName | undefined, label: ILabel | undefined) => void;
onToolChange?: (toolName: ToolName) => void;
selectedLabel?: string;
selectedTool?: ToolName;
/**
* 是否禁用
*/
disabled?: boolean;
/**
* 标注是否可编辑,权重低于全局的disabled,粒度更细
*/
requestEdit?: (type: EditType, payload: {
toolName: ToolName;
label?: string;
modifiedProperty?: string;
}) => boolean;
/**
* 顶部距离
*
* @default 0
*/
offsetTop?: number;
}
export declare const Annotator: import("react").ForwardRefExoticComponent<ImageAnnotatorProps & import("react").RefAttributes<AnnotatorRef>>;
//# sourceMappingURL=ImageAnnotator.d.ts.map