SamyPesse / draft-js-prism

Code highlighting for DraftJS using Prism
http://samypesse.github.io/draft-js-prism/
Apache License 2.0
275 stars 36 forks source link

block.getData() #3

Closed ianstormtaylor closed 8 years ago

ianstormtaylor commented 8 years ago

Does this library currently depend on the "metadata for blocks" branch? Just wondering how you've gone about getting the syntax to work.

In other news, setting this up was amazingly simple. Thanks for sharing!

SamyPesse commented 8 years ago

It doesn't depend on it, but it works well with it: https://github.com/SamyPesse/draft-js-prism/blob/master/lib/options.js#L22

You can change the options to use a custom syntax resolver:

var decorator = new PrismDecorator({
    getSyntax: function(block) {
         return 'python'
    }
});

(Keep in mind that the syntax should exists in Prism.languages otherwise it'll throw an error.