Skip to content
Simple function to turn a Draft.js RawDraftContentBlock into a marked-up string.
JavaScript
Branch: master
Clone or download
Latest commit bca28bb Feb 23, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial Commit Feb 23, 2016
README.md Initial Commit Feb 23, 2016
index.js Initial Commit Feb 23, 2016
package.json Initial Commit Feb 23, 2016
test.js Initial Commit Feb 23, 2016

README.md

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': ['<strong>', '</strong>'],
	'ITALIC': ['<em>', '</em>']
};

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.

You can’t perform that action at this time.