https://github.com/chathurabuddi/draftjs-node-utils
🧰 This library provides a set of utility functions to convert draftJs content in a Node JS environment without browser dependencies.
https://github.com/chathurabuddi/draftjs-node-utils
draft-js draftjs html nodejs
Last synced: 4 months ago
JSON representation
🧰 This library provides a set of utility functions to convert draftJs content in a Node JS environment without browser dependencies.
- Host: GitHub
- URL: https://github.com/chathurabuddi/draftjs-node-utils
- Owner: chathurabuddi
- License: isc
- Created: 2022-12-01T04:26:22.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-06-12T12:18:51.000Z (12 months ago)
- Last Synced: 2025-10-21T22:24:46.115Z (7 months ago)
- Topics: draft-js, draftjs, html, nodejs
- Language: JavaScript
- Homepage:
- Size: 395 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
## DraftJs Node Utils
[](https://github.com/chathurabuddi/draftjs-node-utils/blob/master/LICENSE)
[](https://sonarcloud.io/dashboard?id=chathurabuddi_draftjs-node-utils)
[](https://codecov.io/gh/chathurabuddi/draftjs-node-utils)
[](https://github.com/chathurabuddi/draftjs-node-utils/releases/latest)
This library provides a set of utility functions to convert draftJs content in a Node JS environment without browser dependencies.
_Implementation was extracted from [sstur/draft-js-utils](https://github.com/sstur/draft-js-utils) and modified_
### Installation & Usage
Use npm to install the package. Alternatively you can find the latest downloads on the [release page](https://github.com/chathurabuddi/draftjs-node-utils/releases).
```bash
$ npm install draftjs-node-utils
```
__1. Convert HTML to DraftJS__
```javascript
import draftJs from 'draft-js';
import { htmlToDraftJs } from "draftjs-node-utils";
const contentState = htmlToDraftJs(html);
const draftJsRaw = draftJs.convertToRaw(contentState);
```
### Issues
Please make sure to read the
[issue reporting checklist](https://github.com/chathurabuddi/draftjs-node-utils/blob/main/CONTRIBUTING.md#issue-reporting-guidelines)
before opening an issue. Issues not conforming to the guidelines may be closed immediately.
### Changelog
Detailed changes for each release are documented in the [release notes](https://github.com/chathurabuddi/draftjs-node-utils/releases).
### Contribution
Contributions, issues and feature requests are welcome. Feel free to check
[issues page](https://github.com/chathurabuddi/draftjs-node-utils/issues)
if you want to contribute. Please make sure to read the
[contributing guide](https://github.com/chathurabuddi/draftjs-node-utils/blob/main/CONTRIBUTING.md)
before making a pull request.
### License
Copyright © 2022 Chathura Buddhika ([chathurabuddi](http://chathurabuddi.lk))
This project is [ISC](http://opensource.org/licenses/ISC) licensed.