# react-select-tool

> a select-text-tool component for React

Latest version **1.0.2** (published 2019-10-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-select-tool
pnpm add react-select-tool
yarn add react-select-tool
bun add react-select-tool
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2019-10-30 |
| First published | 2019-10-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 1 |
| Unpacked size | 47.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ShowPenZ |
| Maintainers | showpenz |
| Keywords | select-text, react |

## Links

- npm: https://www.npmjs.com/package/react-select-tool
- npm.io page: https://npm.io/package/react-select-tool

## Dependencies (1)

- [classnames](https://npm.io/package/classnames.md) ^2.2.6

## 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

- 1.0.2 (latest) — 2019-10-30
- 1.0.1 — 2019-10-30
- 1.0.0 — 2019-10-30

## README

# react-select-tool

> a select-text-tool component for React 

## Installation

```
$ npm install react-select-tool --save
$ yarn add react-select-tool
```

## Usage 
用法1 仅针对当前插入的SelectText dom
```javascript
import { SelectText, selectTextFn } from "react-select-tool";

class App extends React.Component {
  render() {
    ////这个回调拿到相应被选择的信息 txt: 选择的文本, target: 被选择的整个dom对象, num: 选择的文本字数
    const handler = (txt, target, num) => {
      console.log(txt, target, num);
    };

    return <SelectText handler={handler}>这是一个测试 文本!</SelectText>;
  }
}

export default App;

```
用法2 挂载方法到当前整个页面
```javascript
import { SelectText, selectTextFn } from "react-select-tool";

class App extends React.Component {
  componentDidMount() {
    const that = this;
    selectedText(document, that.handler);
  }

  //这个回调拿到相应被选择的信息
  handler = (txt, tar, num) => {
    console.log(txt, tar, num);
  };

  render() {
    return <div>这是一个测试 文本!</div>;
  }
}

export default App;

```


## Properties

```javascript
  static propTypes = {
    nickName: PropTypes.string,
    handler: PropTypes.func.isRequired, //选中文本后的回调
  };

  static defaultProps = {
    nickName: "",
  };
```

# License

MIT

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