Skip to content
Code highlighting for DraftJS using Prism
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib Fix default render option Oct 24, 2017
.travis.yml Initial commit May 25, 2016
LICENSE Initial commit May 25, 2016 Update Mar 21, 2018
package.json 1.0.6 Feb 3, 2018
preview.gif Initial commit May 25, 2016


NPM version Build Status

draft-js-prism is a decorator for DraftJS to highlight code blocks using Prism.

Note: It only decorates code blocks with syntax highlighting, if you're interested in providing a correct edition UX for code blocks, take a look at draft-js-code.



$ npm install draft-js-prism prismjs


var Draft = require('draft-js');
var PrismDecorator = require('draft-js-prism');
var Prism = require('prismjs')

var decorator = new PrismDecorator({
  // Provide your own instance of PrismJS
  prism: Prism,
var editorState = Draft.EditorState.createEmpty(decorator)

You'll also need to include the css for one of the Prism themes.

Usage with draft-js-plugins

If you're using draft-js-plugins simply use the draft-js-prism-plugin, a wrapper around this decorator.

Usage with other decorators

You can use this decorator combined with others by using draft-js-multidecorators

You can’t perform that action at this time.