如何将 vscode 贡献的设置设置为颜色类型?
How set a vscode contributed setting to be of type color?
我创建了一个简单的 VS 代码扩展,它提供了一组配置设置。这是来自 package.json
:
的块的简化示例
"configuration": {
"type": "object",
"title": "abc",
"properties": {
"xyz": {
"type": [
"array"
],
"items": {
"title": "Custom patterns to highlight.",
"type": "object",
"properties": {
"foreground": {
"pattern": "^[^$|^\s]",
"type": "string",
"title": "The color.",
"description": "The foreground color that will be used for highlighting."
}
}
}
}
}
}
有没有办法将 foreground
设置的类型设置为颜色而不是任何字符串?好像没有色系之类的。
如果设置编辑器能够理解它是一种颜色并像本节中那样显示颜色选择器,那就太好了:
您需要添加格式属性:
"myconfig.someColor": {
"type": "string",
"format": "color-hex",
"scope": "resource",
"description": "Some Color"
}
我找到了一些相关文档:
https://github.com/microsoft/vscode/tree/master/extensions/json-language-features/server
我创建了一个简单的 VS 代码扩展,它提供了一组配置设置。这是来自 package.json
:
"configuration": {
"type": "object",
"title": "abc",
"properties": {
"xyz": {
"type": [
"array"
],
"items": {
"title": "Custom patterns to highlight.",
"type": "object",
"properties": {
"foreground": {
"pattern": "^[^$|^\s]",
"type": "string",
"title": "The color.",
"description": "The foreground color that will be used for highlighting."
}
}
}
}
}
}
有没有办法将 foreground
设置的类型设置为颜色而不是任何字符串?好像没有色系之类的。
如果设置编辑器能够理解它是一种颜色并像本节中那样显示颜色选择器,那就太好了:
您需要添加格式属性:
"myconfig.someColor": {
"type": "string",
"format": "color-hex",
"scope": "resource",
"description": "Some Color"
}
我找到了一些相关文档:
https://github.com/microsoft/vscode/tree/master/extensions/json-language-features/server