fix(monaco): support high contrast themes in shikiToMonaco#1185
fix(monaco): support high contrast themes in shikiToMonaco#1185Yashsingh045 wants to merge 2 commits intoshikijs:mainfrom
Conversation
✅ Deploy Preview for shiki-next ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for shiki-matsu ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1185 +/- ##
=======================================
Coverage 95.20% 95.20%
=======================================
Files 92 92
Lines 7922 7922
Branches 1689 1689
=======================================
Hits 7542 7542
Misses 374 374
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I wonder if #1099 would be easier and simple. Do you see any other cases that need more customizations? |
|
hey @antfu , I checked #1099. The auto-detection based on theme name is definitely simpler for the common ‘happy path’, but relying only on string matching can be limiting for more advanced setups. For example, any high-contrast theme that doesn’t follow the exact naming convention — such as my-accessible-theme or company-contrast-theme — wouldn’t be recognized correctly. Since #1099 doesn’t provide an override mechanism, users would have no way to handle these cases. My PR #1185 introduces a themes option that acts as an explicit escape hatch. It lets users define high-contrast behavior for any theme, not just the ones that match predefined naming patterns. This keeps shikiToMonaco simple for typical use cases while still offering flexibility for custom or non-standard themes. |
|
Hi @antfu , |
Description
This PR adds support for high-contrast themes in shikiToMonaco.
Previously, shikiToMonaco would assign
vsorvs-darkas the base theme based on the theme type (lightordark). This caused issues with high-contrast themes (like GitHub High Contrast) where the selection foreground color would not be visible because Monaco only applieseditor.selectionForegroundwhen the base theme ishc-blackorhc-light.I have added a new
themesoption to ShikiToMonacoOptions that allows users to explicitly specify the theme type, includinghcandhc-light.Fixes #1081
Changes
themesproperty for overrides.hc-black,hc-light,vs, orvs-dark) based on the configuration.Verification
hctype correctly sets the base theme tohc-black.packages/monaco/test/repro.test.tsstill pass.Usage Example