0.3.3 • Published 2 years ago

react-nested-annotator v0.3.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

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

<TextAnnotator
  content={TEXT}
  tags={tags}
  value={argument}
  onChange={function (value) {
    setArguments(value);
    return;
  }}
+ useEdge={true}
/>

DIY tag style

<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

keytypedescriptiondefault
contentstringtext
tagsobject{ tagName: color-Hex }
valueobject[]entities Array
onChange( value: [] ) => voidvalue change callback
useEdgebooleanif annotate with edgefalse
tagStyleCSSPropertiesdiy tag stylenull

Bold key means it must be provided.

0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago