Expose data-vscode-theme-id attribute in webviews, fix #149661#154635
Expose data-vscode-theme-id attribute in webviews, fix #149661#154635mjbvz merged 4 commits intomicrosoft:mainfrom
Conversation
mjbvz
left a comment
There was a problem hiding this comment.
Instead of adding a new class, how about always using the default english name for data-vscode-theme-name. That way existing users don't have to adopt anything
|
@mjbvz I agree it's better not let existing users adopt anything. However, after some diggings around the code, I realized that theme label is defined in vscode/extensions/theme-red/package.json Line 15 in 042e505 and could be overwritten by i18n extension in When Keeping and passing a copy of English |
|
Introducing this new attribute both leaves the current broken behavior in place and introduces a new thing for users/extension authors to adopt. Not a fan @aeschli Any ideas on reading the default English value of a theme name? |
|
Yes, I don't think we don't know the original English label in the ThemeService as the translation happens in a layer below it. |
|
I found themes using |
|
Searching the top 6000 extensions on the Marketplace so far only |
|
After searching 37'800 extensions, I found blueplanet-ciena.ciena-blueplanet/resource-type-graph/main.91fb18098d9d6cca2a82.js My suggestion would be to deprecate |
|
Thank you for your research! And I am just curious. How did you search for source code of extensions on the Marketplace? |
|
@pingren An update to the docs would be fantastic. |
c6ffba7 to
b7560ee
Compare
b7560ee to
7ab7b48
Compare
|
@aeschli PR Updated. Please take a look when you have a moment. |
|
I'd rather not introduce the Instead you can do the following: Then the theme you get with |
…deprecate data-vscode-theme-name. Fixes microsoft#149661
7ab7b48 to
29fbfb5
Compare
|
Updated: use |
|
Thanks @pingren. Can you also remove the change in src/vs/workbench/contrib/terminal/test/common/terminalColorRegistry.test.ts? |
|
Thank you! Sorry for that. Updated: Remove the change in |
|
|
||
| const activeTheme = ApiThemeClassName.fromTheme(theme); | ||
| this._cachedWebViewThemeData = { styles, activeTheme, themeLabel: theme.label, }; | ||
| this._cachedWebViewThemeData = { styles, activeTheme, themeLabel: theme.label, themeId: theme.settingsId }; |
There was a problem hiding this comment.
@aeschli Can you please confirm that settingsId is a good value to use here? I switched to use this since theme.id is not friendly to consume. Here's some example values for Dark+:
theme.id—vs-dark vscode-theme-defaults-themes-dark_plus-jsontheme.settingsId—Default Dark+
There was a problem hiding this comment.
Yes, sorry for not realizing this. settingsId is what we want (it's unique and it's what can be used in the settings)
This PR fixes #149661
Context
data-vscode-theme-nameis exposed on webviews for theme extensions to write theme specific CSS.Changes
data-vscode-theme-name, rename it todata-vscode-theme-labeldata-vscode-theme-idOriginal PR