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

Getting this to work with webpack #6

Closed Radivarig closed 8 years ago

Radivarig commented 8 years ago

There is no highlighting and when I inspect the text it is a single element while on the demo it is split by parts of different colors.

I also tried to use the code from draft-js-code demo

import 'RichEditor.css'
import 'draft-js/dist/Draft.css'
import 'prismjs/themes/prism.css'

import React from 'react'

const PrismDraftDecorator = require('draft-js-prism')
const CodeUtils = require('draft-js-code')

const Draft = require('draft-js')
const {
    Editor,
    EditorState,
    RichUtils,
    DefaultDraftBlockRenderMap,
    Decorator,
    convertFromRaw
} = Draft

const {Map, List} = require('immutable')
//...

and the rest is same as in demo.

Any ideas? Thanks

yanivtal commented 8 years ago

It's because the PrismDecorator isn't finding a syntax. If you set the defaultSyntax option it should work for you

const decorator = new PrismDecorator({ defaultSyntax: 'javascript' })
Radivarig commented 8 years ago

Yep, that was it. Thanks!