https://github.com/Armaldio/electron-command-palette
Easily integrate a command palette inside your Electron aplication
https://github.com/Armaldio/electron-command-palette
armaldio command-palette electron nodejs
Last synced: 12 months ago
JSON representation
Easily integrate a command palette inside your Electron aplication
- Host: GitHub
- URL: https://github.com/Armaldio/electron-command-palette
- Owner: Armaldio
- Created: 2017-07-20T23:52:22.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-02-06T04:54:30.000Z (over 7 years ago)
- Last Synced: 2024-10-28T14:18:05.972Z (over 1 year ago)
- Topics: armaldio, command-palette, electron, nodejs
- Language: JavaScript
- Size: 441 KB
- Stars: 15
- Watchers: 3
- Forks: 4
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-command-palette - Electron command palette
README
# Electron Command Palette
A nice-looking command palette for Electron
[](https://badge.fury.io/js/electron-command-palette)
[](https://travis-ci.org/armaldio/electron-command-palette)
[](https://github.com/sindresorhus/xo)
[](https://github.com/armaldio/electron-command-palette)

## Features
* Searchable
* Highly customizable *
* Show **Title** - **Description** - **Shortcut** and **Category**
* Register local shortcuts *
* Register custom actions on click *
\* *planned feature*

## Installation
`$ npm install --save electron-command-palette`
## Usage
### Mandatory
**renderer.js** :
```js
const CmdPalette = require("electron-command-palette");
let palette = new CmdPalette();
```
### Add commands
```js
const cmds = require("./commands.json");
//JSON style
palette.add(cmds);
//inline style
palette.add({
"title": "New project",
"category": "Project",
"description": "Create a new project from scratch",
"shortcut": "CmdOrCtrl+Shift+N",
"action": "newproject"
})
```
**commands.json** :
```json
[
{
"title": "New project",
"category": "Project",
"description": "Create a new project from scratch",
"shortcut": "CmdOrCtrl+Shift+N",
"action": "newproject"
},
{
"title": "Title",
"category": "Optional categoty",
"description": "optional description",
"shortcut": "Electron accelerator",
"action": "Name of the function previously registered"
}
]
```
### Register functions
**renderer.js**:
```js
const functions = require("./functions");
//Module style
palette.register(functions);
//Inline style
palette.register("saveproject", function() {
Project.save();
});
```
**functions.js**:
```js
module.exports = [
{
"key" : "newproject",
"action": function () {
console.log("Save project");
}
},
{
"key" : "openproject",
"action": function () {
console.log("Open project");
}
}
];
```
### Display
```js
palette.show();
palette.hide();
```
## TODO
* [X] Tidy repo
* [X] Register functions
* [ ] register shortcuts
* [X] Trigger correct action on click
* [ ] Fix bad fuzzy search
* [ ] Customization options (position, CSS classes, themes)
## Contributors
* [Armaldio](https://github.com/armaldio/)
## License
MIT © [Armaldio](https://armaldio.xyz)