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

No syntax highlighting #8

Closed zacksiri closed 7 years ago

zacksiri commented 8 years ago

Hey!

I am trying to use draft-js-prism with draft-js-code in my editor here is my code, I did inspect element its not even tokenizing the code.

edit: it seems that I can't use the editor from the draft-js-plugin

minardimedia commented 8 years ago

+1

I am getting this error with the demo files

dist.js:13308 Warning: Component's children should not be mutated.
    in pre
    in div (created by DraftEditorContents)
    in DraftEditorContents (created by DraftEditor)
    in div (created by DraftEditor)
    in div (created by DraftEditor)
    in div (created by DraftEditor)
    in DraftEditor (created by PrismEditorExample)
    in div (created by PrismEditorExample)
    in div (created by PrismEditorExample)
    in PrismEditorExample
whitejava commented 7 years ago

+1

warning.js:36 Warning: Component's children should not be mutated.
    in pre
    in div (created by DraftEditorContents)
    in DraftEditorContents (created by DraftEditor)
    in div (created by DraftEditor)
    in div (created by DraftEditor)
    in div (created by DraftEditor)
    in DraftEditor (created by PluginEditor)
    in PluginEditor (created by BasicHtmlEditor)
    in div (created by BasicHtmlEditor)
    in div (created by BasicHtmlEditor)
    in BasicHtmlEditor (created by Editor)
    in div (created by Editor)
    in Editor (created by exports)
    in div (created by exports)
    in div (created by exports)
    in exports (created by exports)
    in div (created by exports)
    in div (created by exports)
    in exports (created by exports)
    in exports (created by Main)
    in div (created by Main)
    in div (created by Main)
    in Main
agungsb commented 7 years ago

Hi, has anyone solved this problem?

yhaskell commented 7 years ago

Tried the following:

$ git clone https://github.com/SamyPesse/draft-js-prism.git
$ cd draft-js-prism
$ yarn && yarn start

Project starts, syntax highlighting however doesn't work: no tokenisation happening.

agungsb commented 7 years ago

I ended up using PrismDraftDecorator class from this gist instead of from draft-js-code. It's working well for me.

des-des commented 7 years ago

setting the javascript as the defaultSyntax in the options.js file gets it working

mxstbr commented 7 years ago

I've created a wrapper around this decorator specifically for draft-js-plugins, draft-js-prism-plugin, which works.

Feel free to open a new issue on the draft-js-prism-plugin repo if you're still experiencing this problem!