如何将vscode贡献的设置设置为颜色类型?

问题描述 投票:0回答:1

我创建了一个简单的VS Code扩展,它提供了一组配置设置。这是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设置的类型设置为彩色而不是任何字符串?似乎没有颜色或类似颜色。

如果设置编辑器可以理解它是一种颜色并像本节中一样显示颜色选择器,那就太好了:

enter image description here

visual-studio-code vscode-settings vscode-extensions
1个回答
2
投票

您需要添加格式属性:

"myconfig.someColor": {
    "type": "string",
    "format": "color-hex",
    "scope": "resource",
    "description": "Some Color"
}

我已经找到了一些文档:

https://github.com/microsoft/vscode/tree/master/extensions/json-language-features/server

© www.soinside.com 2019 - 2024. All rights reserved.