# react-nested-annotator

> A React Component for annotating nested text from html, usually used in NLP data processing task

Latest version **0.3.3** (published 2022-01-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-nested-annotator
pnpm add react-nested-annotator
yarn add react-nested-annotator
bun add react-nested-annotator
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.3 |
| Published | 2022-01-28 |
| First published | 2022-01-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 62.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | lulingbo |
| Maintainers | rollingball |
| Keywords | react, nested, annotator |

## Links

- npm: https://www.npmjs.com/package/react-nested-annotator
- Repository: https://github.com/Bollues/react-nested-annotator
- Homepage: https://github.com/Bollues/react-nested-annotator#readme
- Issues: https://github.com/Bollues/react-nested-annotator/issues
- npm.io page: https://npm.io/package/react-nested-annotator

## Dependencies (4)

- [react](https://npm.io/package/react.md) ^17.0.2
- [react-dom](https://npm.io/package/react-dom.md) ^17.0.2
- [@types/react](https://npm.io/package/@types/react.md) ^17.0.38
- [@types/react-dom](https://npm.io/package/@types/react-dom.md) ^17.0.11

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.3.3 (latest) — 2022-01-28
- 0.3.2 — 2022-01-28
- 0.3.1 — 2022-01-27
- 0.3.0 — 2022-01-27
- 0.2.1 — 2022-01-26
- 0.2.0 — 2022-01-26
- 0.1.9 — 2022-01-11
- 0.1.8 — 2022-01-11
- 0.1.7 — 2022-01-10
- 0.1.6 — 2022-01-10
- 0.1.5 — 2022-01-10
- 0.1.4 — 2022-01-10
- 0.1.3 — 2022-01-10
- 0.1.2 — 2022-01-10
- 0.1.1 — 2022-01-10
- … 1 more at https://npm.io/package/react-nested-annotator/versions

## README

## react-nested-annotator
A React Component for annotating nested text from html.

**Nested** means you can annotate on an annotated text, and select another tag.



### basic usage

```jsx
import { useState } from "react";
import { TextAnnotator } from "react-nested-annotator";

const TEXT = "这是一段话";
const argumentsTemplate = [];
const tags = {
  Tag1: "#3ee0b8",
  Tag2: "#84d2ff",
};

const App = () => {
  const [argument, setArguments] = useState(argumentsTemplate);

  return (
    <div className="container">
      <TextAnnotator
        content={TEXT}
        tags={tags}
        value={argument}
        onChange={function (value) {
          setArguments(value);
          return;
        }}
      />
    </div>
  );
};

export default App;
```



### how to Delete the label

move mouse over the annotated text, and then **rightclick**



### annotate with edge

```jsx
<TextAnnotator
  content={TEXT}
  tags={tags}
  value={argument}
  onChange={function (value) {
    setArguments(value);
    return;
  }}
+ useEdge={true}
/>
```



### DIY tag style

```jsx
<TextAnnotator
  content={TEXT}
  tags={tags}
  value={argument}
  onChange={function (value) {
    setArguments(value);
    return;
  }}
+ tagStyle={{
+   verticalAlign: "middle",
+   backgroundColor: "white",
+   color: "black",
+   borderRadius: "5px",
+   fontSize: "0.5rem",
+   fontWeight: "bold",
+   padding: "4px"
+ }}
/>
```



### codeSandBox

https://codesandbox.io/s/quirky-gauss-p6wfd?file=/src/App.js



### APIs

| key          | type                  | description            | default |
| ------------ | --------------------- | ---------------------- | ------- |
| **content**  | string                | text                   |         |
| **tags**     | object                | { tagName: color-Hex } |         |
| **value**    | object[]              | entities Array         |         |
| **onChange** | ( value: [] ) => void | value change callback  |         |
| useEdge      | boolean               | if annotate with edge  | false   |
| tagStyle     | CSSProperties         | diy tag style          | null    |

Bold **key** means it must be provided.

---
_Source: https://npm.io/package/react-nested-annotator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
