2016-11-17 57 views
1

我想添加一个功能到现有的插件,并希望在插件的菜单中添加一个额外的选项。如何在github原子编辑器插件中添加复选框切换

我想要的选项看起来像下面的“无题”条目:

Checkbox

选项会像现有的功能,我们在日食“自动构建”切换。

enter image description here

我想,一旦用户看到的Atom插件菜单此选项,他知道无论是启用。

我们是否有ATOM视图中存在的东西。所以,我可以寻找参考。

+1

这通常在包装设置菜单中进行,而不是Atom菜单。 –

+0

@MattSchuchard,这很有道理。你可以请这个评论一个答案。 :) – RanRag

回答

1

您可以通过几种方式将其添加到包设置菜单中,而不是Atom菜单中。

首先,有一种将它直接放入代码的方法。考虑在main.js以下为我包linter-ansible-linting

config: { 
    ansibleLintExecutablePath: { 
    title: 'Ansible-Lint Executable Path', 
    type: 'string', 
    description: 'Path to Ansible-Lint executable (e.g. /usr/bin/ansible-lint) if not in shell env path.', 
    default: 'ansible-lint', 
    }, 
    useRulesDirs: { 
    title: 'Use non-default rules directories with Ansible-Lint.', 
    type: 'boolean', 
    default: false, 
    }, 
    rulesDirs: { 
    title: 'Rules Directories', 
    type: 'array', 
    description: 'Non-default rules directories to use with Ansible-Lint. (only if use non-default rules directories checked)', 
    default: ['/usr/local/lib/python2.7/site-packages/ansiblelint/rules', '/usr/local/lib/python2.7/dist-packages/ansiblelint/rules'], 
    items: { 
     type: 'string' 
    } 
    } 
} 

你也可以把它放在package.json。考虑下面有人了Atom棉短绒组织放于包内东西我保持linter-puppet-lint

"configSchema": { 
    "executablePath": { 
    "title": "Executable path", 
    "type": "string", 
    "description": "Path to puppet-lint executable", 
    "default": "puppet-lint" 
    }, 
    "automaticFix": { 
    "title": "Attempt to automatically fix warnings and errors", 
    "type": "boolean", 
    "default": false 
    }, 
} 

这些都会使你的包在设置菜单中提供的配置设置。你的具体设置将是boolean,所以我建议遵循该类型的格式。

buildAutomatically: { 
    title: 'Build Automatically', 
    type: 'boolean', 
    default: false, 
} 

"buildAutomatically: { 
    "title": "Build Automatically", 
    "type": "boolean", 
    "default": false 
}