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

allow for no syntax? #4

Closed ianstormtaylor closed 8 years ago

ianstormtaylor commented 8 years ago

Currently the library breaks without a specified syntax, but I'd like to have the ability for users to set it to "none", or basically have the default be null, so that weird pieces don't get highlighted by accident. What do you think?

SamyPesse commented 8 years ago

I agree, currently in our application, we are running this tests in the filter option of the decorator (ensure that the syntax exists, etc)

Can you make a PR for this?

PS: You might be interested in checking out draft-js-code: demo to have a better UX when editing code blocks

PS 2: We are publishing an alpha version of our GitBook Editor which includes a WYSIWYG editor for markdown built with Draft (draft-js-prism, tree PR, metadata PR, etc), I'd love to get your feedback on the editing UX.

ianstormtaylor commented 8 years ago

Done! Also happy to take a look at the editor! I'm slightly worried about the tree PR ending up with an even more complex core haha, but hopefully it'll unlock tables at least.

draft-js-code looks awesome. There are a few things that feel a bit awkward. I like how Canvas handles returns in code blocks best. Regular return will add a new line of code (optionally indenting too), whereas cmd-return will exit the block. And the have an everpresent reminder for cmd-return. Basically, for code blocks my current philosophy is to try to make it so that inside the block, it feels the most like sublime/atom/etc. as possible, which means return by itself should add new lines.