0.0.21 • Published 1 year ago
annotation-react v0.0.21
Annotation-React
This Component provides a React component that allows users to annotate article , like below:
Install
npm i annotation-react
Basic Usage
import React from "react";
import { Annotation } from "annotation-react";
import { createRoot } from "react-dom/client";
import "annotation-react/dist/style.css";
createRoot(document.getElementById("app")!).render(
<Annotation
onChange={(annos) => {
console.log({ annos });
}}
tags={[{ content: "error" }, { content: "success" }]}
sentence="A story is a component with a set of arguments that define how the component should render."
/>
);
The definition of Prop:
export interface PAnnotation {
/** content to be showed */
sentence?: string;
tags?: TTag[];
/**the annotations that already exist */
annoations?: TAnnoDetail[];
/**the fontSize of main content,now only support number, will use px unit */
fontSize?: number;
/** Ensure that there is enough space between the rows to fit a tag */
lineHeight?: string;
/** the color of marked text by annotation */
hightlightColor?: string;
hightlightBgColor?: string;
/** can not mark */
readonly?: boolean;
/** notify when annotations add or remove */
onChange?: (annoations: TAnnoDetail[]) => void;
}