draft-js-utils icon indicating copy to clipboard operation
draft-js-utils copied to clipboard

Code Highlighting inside blockRenderers

Open agjs opened this issue 3 years ago • 0 comments

Hey guys. I'm trying to use SyntaxHighlighter inside blockRenderers for code-block but naturally, as each block inside blockRenderers expects to return a string (and not a Node, aka, Element), this won't work.

Example:

    blockRenderers: {
      "code-block": block => {
        return (
          <SyntaxHighlighter language='javascript' style={docco}>
            {block.getText()}
          </SyntaxHighlighter>
        );
      }
    }

So I wonder, what is the alternative to this. How can we add code highlighting inside blockRenderers?

Thanks a bunch in advance.

agjs avatar May 28 '22 09:05 agjs