Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/evanc/backdraft-js

Simple function to turn a Draft.js RawDraftContentBlock into a marked-up string.
https://github.com/evanc/backdraft-js

Last synced: 3 months ago
JSON representation

Simple function to turn a Draft.js RawDraftContentBlock into a marked-up string.

Awesome Lists containing this project

README

        

# backdraft-js

Simple function to turn a Draft.js RawDraftContentBlock into a marked-up
string.

## Install

```
$ npm install --save backdraft-js
```

## Usage
```
var backdraft = require('backdraft-js');

var rawDraftContentBlock = Draft.convertToRaw(contentState);

var markup = {
'BOLD': ['', ''],
'ITALIC': ['', '']
};

var markedUpBlocks = backdraft(rawDraftContentBlock, markup);

```

## API

### `backdraft(rawDraftContentBlock, markup)` -> `array`

`markup` is an object, the key should be the DraftJS "style" identifier and the
value should be an array: the first item will be appended to the output to
"open" the style and the second tag will be appended to "close" the style. See
"Usage" above for a simple example.