refactor: code block & math block syntax highlighting#2873
Conversation
Logged-out buyers now go straight to Polar checkout instead of being sent to /signup first.
De-duplication: when an extension with a given key is already registered, skip registering another one with the same key (the first registration wins). This lets an extension declare a dependency on another via `blockNoteExtensions` without conflicting when that same extension is also registered directly by the user. Ordering: a sub-extension declared via `blockNoteExtensions` is a dependency of the extension that declares it, so it now runs before its parent. The dependency is recorded as the sub is resolved (before the de-duplication check), so it holds even when multiple parents declare the same sub-extension and when a parent has a higher base priority via `runsBefore`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… & math block can configure a highlighter for
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
The goal of this refactor was to use #2872 which allows for "sub extensions" (a blocknote extension within a blocknote extension) to be de-duped. And, leverage that to allow both the code-block & math block to operate with the syntax highlighting extension.
Now, the math block & code block declares how to highlight their contents & the syntax highlighting extension will pickup on them as being the nodes they should try to syntax highlight upon.
I've made the code block accept the syntax highlighter like it was accepting before. And, now the math block can accept a syntax highlighter (if for some reason you only care to configure the math block highlighting but not the code block one).
The trouble is how to handle both code block & the math extension wanting to configure the highlighter in different ways. Well, extensions can now only be registered once per key with #2872 so it will just silently drop one of the configurations and use one of the highlight instances to try to highlight both the math & code blocks.
I think this is a fine tradeoff for now, since you can really just leave the code block syntax highlighting on & get both code blocks & math blocks "for free". There is a larger question on how to do this in the more general case for extensions which depend on each other, but that is just a hard problem in programming in general.
Rationale
Changes
Impact
Testing
Screenshots/Video
Checklist
Additional Notes