pdf-annotator-react
Version:
A React component library for PDF annotation
83 lines (82 loc) • 2.4 kB
TypeScript
import { CompetenciaInterface, CompetenciaWithTags, TagInterface } from 'lingapp-revisao-redacao';
export type Point = {
x: number;
y: number;
};
export type AnnotationRect = {
x: number;
y: number;
width: number;
height: number;
pageIndex: number;
};
export declare enum AnnotationType {
HIGHLIGHT = "highlight",
UNDERLINE = "underline",
STRIKEOUT = "strikeout",
RECTANGLE = "rectangle",
DRAWING = "drawing",
HIGHLIGHTING = "highlighting",
TEXT = "text",
COMMENT = "comment",
PIN = "pin"
}
export interface Annotation {
id: string;
type: AnnotationType;
rect: AnnotationRect;
pageIndex: number;
color: string;
content: string;
points?: Point[];
tags?: TagInterface[];
createdAt: Date;
updatedAt?: Date;
category?: CompetenciaInterface;
thickness?: number;
}
export type AnnotationEventCallbacks = {
onAnnotationCreate?: (annotation: Annotation) => void;
onAnnotationUpdate?: (annotation: Annotation) => void;
onAnnotationDelete?: (annotationId: string) => void;
onAnnotationSelect?: (annotation: Annotation | null) => void;
};
export declare enum AnnotationMode {
NONE = "none",
HIGHLIGHT = "highlight",
UNDERLINE = "underline",
STRIKEOUT = "strikeout",
RECTANGLE = "rectangle",
DRAWING = "drawing",
HIGHLIGHTING = "highlighting",
TEXT = "text",
COMMENT = "comment",
PIN = "pin"
}
export type PDFAnnotatorProps = {
url: string;
annotations?: Annotation[];
scale?: number;
pageNumber?: number;
onDocumentLoadSuccess?: (numPages: number) => void;
onPageChange?: (pageNumber: number) => void;
annotationMode?: AnnotationMode;
onAnnotationModeChange?: (mode: AnnotationMode) => void;
currentCategory?: CompetenciaInterface;
onCategoryChange?: (category: CompetenciaInterface | undefined) => void;
onAnnotationsChange?: (annotations: Annotation[]) => void;
customCategories?: CompetenciaWithTags[];
highlightColor?: string;
underlineColor?: string;
strikeoutColor?: string;
rectangleColor?: string;
drawingColor?: string;
textColor?: string;
commentColor?: string;
pinColor?: string;
highlightingColor?: string;
pdfWorkerSrc?: string;
fitToWidth?: boolean;
defaultThickness?: number;
viewOnly?: boolean;
} & AnnotationEventCallbacks;