Hey, currently I try to implement automatic code highlighting with highlight.js for code blocks. It’s already working but it’s not performant for large documents because it’s getting re-rendered on every change of the editor.
I can’t find any example for decorations in a similar use case. So basically here is what I’ve done already:
- I create a
Plugin()for adding my decorations
- I search in the
- I create an array of inline decorations for all code highlights of all code blocks and return them with a
At the moment I found only two ways to get this working:
- Re-render all decorations on every change
- Render all decorations only on init
But what I want is to render all decorations for
code_block nodes on init and re-render them individually whenever a
code_block node changes.
I have no clue how to solve this because nodes do not have any identifiers so if I try to cache all the decorations I do not know which decorations belongs to which nodes. Any idea?