【问题标题】:How set a vscode contributed setting to be of type color?如何将 vscode 贡献的设置设置为颜色类型?
【发布时间】:2020-04-07 12:30:54
【问题描述】:

我创建了一个简单的 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 设置的类型设置为颜色而不是任何字符串?似乎没有颜色类型或类似的。

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

【问题讨论】:

    标签: visual-studio-code vscode-settings vscode-extensions


    【解决方案1】:

    需要添加格式属性:

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

    我为此找到了一些文档:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-14
      • 1970-01-01
      • 2014-12-18
      • 2012-03-21
      • 2018-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多