如何在 JSON 中显示 VSCode 颜色选择器而不考虑键?
How do you display the VSCode color picker in JSON regardless of the key?
我正在开发一个主题并希望所有 HEX 颜色在它们旁边显示 VSCode 颜色选择器。
有人问 , but I wasn't sure how to implement it even after looking at the docs。
所以我尝试在 this example here (Github) 之后创建一个 JSON 模式。
我得到以下代码可以工作,但只有当 JSON key
字符串的名称为 hex-color
:
时它才有效
...
"type": "object",
"properties": {
"hex-color": {"type": "string","format": "color"}
}
...
所以
{
"test": "#000", // Does not work
"hex-color": "#000" // Works
}
创建 VSCode 主题时,为模式的主题文件中可能的每个 属性 键命名非常困难且耗时。有没有办法创建通配符键,或者有更好的方法来检测值是否为十六进制颜色?
我解决了颜色选择器未显示在 VSCode 主题 JSON 文件中的问题。 (此解决方案可能不适用于其他 JSON 文件。)
将以下行添加到您的主题中:
"$schema": "vscode://schemas/color-theme",
这会将文件的架构设置为 VSCode 的颜色主题架构,其中大部分(如果不是全部)架构都可以在 HEX 颜色上显示颜色选择器。经过更多研究,我发现 the following repo (Github) @wraith13 上传了 VSCode 的 JSON 模式。
可以找到 color-theme
架构 here (v1.58.2)。
我正在开发一个主题并希望所有 HEX 颜色在它们旁边显示 VSCode 颜色选择器。
有人问
所以我尝试在 this example here (Github) 之后创建一个 JSON 模式。
我得到以下代码可以工作,但只有当 JSON key
字符串的名称为 hex-color
:
...
"type": "object",
"properties": {
"hex-color": {"type": "string","format": "color"}
}
...
所以
{
"test": "#000", // Does not work
"hex-color": "#000" // Works
}
创建 VSCode 主题时,为模式的主题文件中可能的每个 属性 键命名非常困难且耗时。有没有办法创建通配符键,或者有更好的方法来检测值是否为十六进制颜色?
我解决了颜色选择器未显示在 VSCode 主题 JSON 文件中的问题。 (此解决方案可能不适用于其他 JSON 文件。)
将以下行添加到您的主题中:
"$schema": "vscode://schemas/color-theme",
这会将文件的架构设置为 VSCode 的颜色主题架构,其中大部分(如果不是全部)架构都可以在 HEX 颜色上显示颜色选择器。经过更多研究,我发现 the following repo (Github) @wraith13 上传了 VSCode 的 JSON 模式。
可以找到 color-theme
架构 here (v1.58.2)。