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

Different language highlighting examples #23

Open yasuf opened 6 years ago

yasuf commented 6 years ago

Can you point me on the right direction as to how to select a different language other than JS when highlighting using this decorator?

I can try putting something together so that this repo could have an example on the README on how to do that.

sebalvarez07 commented 5 years ago

I have the same question! Thanks again:)

LuzLabLLC commented 4 years ago

Yeah same, I would like for it to auto detect which language!

pleerock commented 4 years ago

Here is how you are able to do that:


      {
        type: "code-block",
        text: 'var message = "This is awesome!";',
        data: {
          syntax: "javascript",
        },
      },
      {
        type: "code-block",
        text: "<h1>I am superman</h1>",
        data: {
          syntax: "html",
        },
      },

so, you just need to figure out how blocks are working and add a block with syntax you need