# braft-convert-2

> A convert helper for Braft Editor.

Latest version **2.3.1** (published 2023-06-08) · MIT license · 0 weekly downloads

## Install

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

## 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.1 |
| Published | 2023-06-08 |
| First published | 2023-06-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 70.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Margox |
| Maintainers | vernalxu |
| Keywords | convert, braft |

## Links

- npm: https://www.npmjs.com/package/braft-convert-2
- 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-2

## Dependencies (2)

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

## Recent versions

- 2.3.1 (latest) — 2023-06-08

## README

# forked from braft-convert

## 只支持React 16.3 及以上

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

##### 使用方法

```bash
# use yarn
yarn add braft-convert-2
# use npm
npm install --save braft-convert-2
```

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

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-2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
