Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/evanc/backdraft-js
- Owner: evanc
- Archived: true
- Created: 2016-02-23T07:57:14.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-02-23T08:23:52.000Z (over 8 years ago)
- Last Synced: 2024-04-09T22:27:32.908Z (7 months ago)
- Language: JavaScript
- Size: 0 Bytes
- Stars: 48
- Watchers: 2
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-draft-js - BackDraft.js - Function to turn a rawContentBlock into a marked-up string. (Common Utilities)
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.