-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In the local demo the code is not highlighted #20
Comments
I can't get this to work either. |
Ok, so looking at this a bit more. It looks like if there is no code present in the original state, then it will not set the decorator. You can get around this by making sure it is set during the onChange handler: onChange = (editorState) => {
const content = editorState.getCurrentContent()
this.setState({
editorState: EditorState.set(editorState, { decorator }),
})
} You also need to set the syntax, I'm not exactly sure how it determines the syntax it will use, but you can set the default: const decorator = new PrismDecorator({
// Provide your own instance of PrismJS
prism: Prism,
defaultSyntax: 'javascript',
}) I think two changes would be helpful:
|
Yeah, this is a super annoying design choice by DraftJS—imo decorators should be bound per-editor not per-state. You'll have to make sure to always set the decorator on any new editor state, PRs to fix the demo would be appreciated. |
Does anyone know how to change the language syntax aside from the defaultSyntax property? |
bump, I need some help on adding multiple languages or auto detecting them as you type. Thanks! |
Hi,
first of all thanks for this project!
I've tried to run the demo locally but the code is not highlighted. Just plain black text.
There are no errors in the console either.
Am I missing something?
Thanks,
Nicola
The text was updated successfully, but these errors were encountered: