feat: add Shiki syntax highlighting with theme-aware light/dark mode for code blocks#55
Merged
feat: add Shiki syntax highlighting with theme-aware light/dark mode for code blocks#55
Conversation
…for code blocks - Add Shiki highlighter bundle with 27 precompiled languages and light-plus/dark-plus themes (via shiki-codegen) - Configure BlockNote code block spec with dual-theme Shiki parser that emits CSS variables for automatic light/dark switching - Override BlockNote's hardcoded dark background with theme-aware colors using OKLCH color space - Fix language selector label visibility in light mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add VS Code-quality syntax highlighting to code blocks in the editor using Shiki, with automatic light/dark theme switching.
Changes
light-plus/dark-plusthemes viashiki-codegenfor optimal loading performancecolorfor light,--shiki-darkfor dark)#161616code block background with OKLCH theme-responsive colors; activate--shiki-dark/--shiki-dark-bgCSS variables in dark modeSupported Languages (27)
JavaScript, TypeScript, JSX, TSX, HTML, CSS, JSON, Python, Rust, Bash, SQL, YAML, Markdown, Go, Java, C, C++, Ruby, PHP, Swift, Kotlin, Lua, Diff, TOML, XML, Dockerfile, GraphQL
How It Works
BlockNote internally uses
prosemirror-highlight/shikiwhich callscodeToTokenswith only the first loaded theme. By pre-populatingglobalThis[Symbol.for("blocknote.shikiParser")]with a dual-theme parser (using Shiki'sthemesoption), each token receives both light-modecolorand a--shiki-darkCSS variable. A companion CSS rule inindex.cssactivates the dark palette when.darkis present on the document root.