# react-wysiwyg-typescript

> A wrapper Component for react-draft-wysiwyg written in Typescript

Latest version **1.0.2** (published 2018-03-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-wysiwyg-typescript
pnpm add react-wysiwyg-typescript
yarn add react-wysiwyg-typescript
bun add react-wysiwyg-typescript
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-03-21 |
| First published | 2017-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 35.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 13 |
| Author | sumn2u |
| Maintainers | iamsuman |
| Keywords | react draft editor, editor, WYSIWYG Typescript |

## Links

- npm: https://www.npmjs.com/package/react-wysiwyg-typescript
- Repository: https://github.com/sumn2u/react-wysiwyg-typescript
- Homepage: https://github.com/sumn2u/react-wysiwyg-typescript#readme
- Issues: https://github.com/sumn2u/react-wysiwyg-typescript/issues
- npm.io page: https://npm.io/package/react-wysiwyg-typescript

## Dependencies (7)

- [draft-js](https://npm.io/package/draft-js.md) ^0.10.0
- [@types/draft-js](https://npm.io/package/@types/draft-js.md) ^0.10.0
- [draftjs-to-html](https://npm.io/package/draftjs-to-html.md) ^0.7.0
- [html-to-draftjs](https://npm.io/package/html-to-draftjs.md) ^0.1.0-beta7
- [react-html-parser](https://npm.io/package/react-html-parser.md) ^2.0.2
- [react-draft-wysiwyg](https://npm.io/package/react-draft-wysiwyg.md) ^1.8.4
- [draft-js-export-html](https://npm.io/package/draft-js-export-html.md) ^1.2.0

## Alternatives

- [ext-list](https://npm.io/package/ext-list.md) — 6.3M weekly downloads
- [@lexical/selection](https://npm.io/package/@lexical/selection.md) — 3.8M weekly downloads
- [@lexical/text](https://npm.io/package/@lexical/text.md) — 3.6M weekly downloads
- [@lexical/clipboard](https://npm.io/package/@lexical/clipboard.md) — 3.0M weekly downloads
- [@tiptap/extension-mention](https://npm.io/package/@tiptap/extension-mention.md) — 3.0M weekly downloads

## Recent versions

- 1.0.2 (latest) — 2018-03-21
- 1.0.1 — 2018-01-19
- 1.0.0 — 2018-01-12
- 0.0.9 — 2018-01-12
- 0.0.8 — 2018-01-12
- 0.0.7 — 2018-01-12
- 0.0.6 — 2018-01-11
- 0.0.5 — 2017-11-22
- 0.0.4 — 2017-11-22
- 0.0.3 — 2017-11-22
- 0.0.2 — 2017-11-22
- 0.0.1 — 2017-11-22

## README

# react-wysiwyg-typescript

[![GitHub issues](https://img.shields.io/github/issues/sumn2u/react-wysiwyg-typescript.svg)](https://github.com/sumn2u/react-wysiwyg-typescript/issues) [![GitHub forks](https://img.shields.io/github/forks/sumn2u/react-wysiwyg-typescript.svg)](https://github.com/sumn2u/react-wysiwyg-typescript/network) [![GitHub stars](https://img.shields.io/github/stars/sumn2u/react-wysiwyg-typescript.svg)](https://github.com/sumn2u/react-wysiwyg-typescript/stargazers) [![GitHub license](https://img.shields.io/github/license/sumn2u/react-wysiwyg-typescript.svg)](https://github.com/sumn2u/react-wysiwyg-typescript/blob/master/LICENSE) [![Twitter](https://img.shields.io/twitter/url/https/github.com/sumn2u/react-wysiwyg-typescript.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Fsumn2u%2Freact-wysiwyg-typescript)

![banner](assests/wysiwyg.png)

> A wrapper Component for react-draft-wysiwyg written in Typescript


This package require a css file, make sure you use webpack or similar tools for handler this file type.

## Table of Contents

- [Install](#install)
- [Usage](#usage)
- [Contribute](#contribute)
- [License](#license)

## Install

```sh
npm i react-wysiwyg-typescript -S

# or

yarn add react-wysiwyg-typescript

```

## Usage

```ts
import Draft, { htmlToDraft, draftToHtml, EmptyState, rawToDraft, draftToRaw , draftStateToHTML} from 'react-wysiwyg-typescript'

state = {
    editorState: htmlToDraft('Your html contents') // or use an EmptyState
}

<Draft
    editorState={this.state.editorState}
    onEditorStateChange={(editorState) => { this.setState({ editorState }) }}
/>

// save html to server

const html = draftToHtml(content)

// convert raw to draft

const toDraft = rawToDraft(content)

// convert draft to raw

const toRaw = draftToRaw(content)

// convert rawToDraft file to HTML

const toHTML = draftStateToHTML(content)

```

If you use antd's Form Component and you are ready to go.

```js

<FormItem label="Contents" {...alignProps} wrapperCol={{ span: 16 }}>
    {getFieldDecorator('Content', {
        rules: [{ required: true, message: 'Please leave a message...' }],
    })(
        <Draft
            editorState={this.state.editorState}
            onEditorStateChange={(editorState) => { this.setState({ editorState }) }}
        />
        )}
</FormItem>

// convert state to html

this.props.form.validateFields((err, data) => {
    if (err) {
        return
    }
    /**
    * do more check here.
    */
    if (data.Content) {
        data.Content = draftToHtml(data.Content)
    }
    // Now you have your html contents and ready to post to your server.
})

```

## Contribute



Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.

## License

MIT © sumn2u

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