# braft-convert

> A convert helper for Braft Editor.

Latest version **2.3.0** (published 2019-06-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install braft-convert
pnpm add braft-convert
yarn add braft-convert
bun add braft-convert
```

## 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 | 2.3.0 |
| Published | 2019-06-12 |
| First published | 2018-01-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 70.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Margox |
| Maintainers | margox |
| Keywords | convert, braft |

## Links

- npm: https://www.npmjs.com/package/braft-convert
- Repository: https://github.com/margox/braft-convert
- Homepage: https://github.com/margox/braft-convert#readme
- Issues: https://github.com/margox/braft-convert/issues
- npm.io page: https://npm.io/package/braft-convert

## Dependencies (2)

- [draft-js](https://npm.io/package/draft-js.md) ^0.10.3
- [draft-convert](https://npm.io/package/draft-convert.md) ^2.0.0

## Recent versions

- 2.3.0 (latest) — 2019-06-12
- 2.1.7 (beta) — 2018-10-23
- 2.1.14 — 2019-06-12
- 2.1.12 — 2019-01-15
- 2.1.11 — 2018-12-14
- 2.1.10 — 2018-11-21
- 2.1.9 — 2018-10-26
- 2.1.6 — 2018-10-23
- 2.1.5 — 2018-10-13
- 2.1.4 — 2018-10-05
- 2.1.3 — 2018-09-30
- 2.1.2 — 2018-09-30
- 2.1.1 — 2018-09-30
- 2.1.0 — 2018-09-30
- 2.0.3 — 2018-09-26
- … 22 more at https://npm.io/package/braft-convert/versions

## README

# braft-convert
### 与braft-editor搭配使用的数据转换工具


##### 使用方法
```bash
# use yarn
yarn add braft-convert
# use npm
npm install --save braft-convert
```

```javascript
import { convertRawToHTML, convertHTMLToRaw } from 'braft-convert'

const draftRawData = '{"blocks":[{"key":"9hu83","text":"Hello World!","type":"unstyled","depth":0,"inlineStyleRanges":[{"offset":6,"length":5,"style":"BOLD"},{"offset":6,"length":5,"style":"COLOR-F32784"}],"entityRanges":[],"data":{}}],"entityMap":{}}'
const htmlString = '<p>Hello <strong><span style="color:#f32784">World</span></strong>!</p>'

convertRawToHTML(JSON.parse(draftRawData))
// <p>Hello <strong><span style="color:#f32784">World</span></strong>!</p>

JSON.stringify(convertHTMLToRaw(htmlString))
// {"blocks":[{"key":"8v6eh","text":"Hello World!","type":"unstyled","depth":0,"inlineStyleRanges":[{"offset":6,"length":5,"style":"BOLD"},{"offset":6,"length":5,"style":"COLOR-F32784"}],"entityRanges":[],"data":{}}],"entityMap":{}}

```

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