I’m using PrimeReact’s component and trying to add syntax highlighting to it. It is based on the Quill library so I tried to use highlight.js
lib as the Quill’s documentation says:
import hljs from "highlight.js";
// ...
<Editor
modules={{
syntax: { hljs }
}}
// ...
onTextChange={(e) => {
changeSomeStateWith(e.htmlValue ?? "");
}}
/>
Only one thing has changed in the Editor’s view after it. Now I can see a select with some programming languages when I try to add a code block:
Nothing is being highlighted and e.htmlValue
now contains the code of the select element.
ChatGPT says I must manipulate DOM to integrate highlight.js
in this case. Can I do it without DOM manipulation in React?