SamyPesse / draft-js-prism

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

More languages for highlighing #7

Closed Radivarig closed 7 years ago

Radivarig commented 8 years ago

Changing const decorator = new PrismDecorator({ defaultSyntax: 'language' }) works for few language definitions included in prismjs, as mentioned in this prism ticket [ 'extend', 'insertBefore', 'DFS', 'markup', 'css', 'clike', 'javascript' ] and for the other ones from languages-list it gives Error: Cannot read property 'rest' of undefined.

Mentioned in the same prism ticket there is a wrapper called prism-languages that provides a full list.

Could it be added to draft-js-prism?

danielfarrell commented 7 years ago

You just have to load the language file from prism first. For example, I have this at the top of my editor file:

import 'prismjs';
import 'prismjs/components/prism-markdown';

Each of the language components registers itself.