Comparing version 0.7.0 to 0.8.0
import { Token } from 'phosphor-di'; | ||
import { IDisposable } from 'phosphor-disposable'; | ||
import { ISignal } from 'phosphor-signaling'; | ||
import { Widget } from 'phosphor-widget'; | ||
/** | ||
* The public interface of the command palette. | ||
* | ||
* #### Notes | ||
* In addition to the public API, an `ICommandPalette` instance also needs to | ||
* register the following commands: | ||
* 1. `'command-palette:focus-input'`, which takes no arguments and focuses the | ||
* search bar. | ||
*/ | ||
export interface ICommandPalette { | ||
/** | ||
* A signal emitted when a command is triggered by the palette. | ||
* | ||
* #### Note | ||
* The order in which the command executes and the signal emits is undefined. | ||
*/ | ||
commandTriggered: ISignal<ICommandPalette, { | ||
id: string; | ||
args: any; | ||
}>; | ||
/** | ||
* The underlying palette widget. | ||
*/ | ||
widget: Widget; | ||
/** | ||
* Add new command items to the palette. | ||
@@ -22,6 +43,2 @@ * | ||
}[]): IDisposable; | ||
/** | ||
* The underlying palette widget. | ||
*/ | ||
widget: Widget; | ||
} | ||
@@ -28,0 +45,0 @@ /** |
@@ -12,2 +12,3 @@ /*----------------------------------------------------------------------------- | ||
var phosphor_disposable_1 = require('phosphor-disposable'); | ||
var phosphor_signaling_1 = require('phosphor-signaling'); | ||
var index_1 = require('./index'); | ||
@@ -43,2 +44,7 @@ var index_2 = require('../commandregistry/index'); | ||
function CommandPaletteManager(commandRegistry, shortcutManager) { | ||
var _this = this; | ||
this._commandHandler = function (commandSpec) { | ||
_this.commandTriggered.emit(commandSpec); | ||
_this._commandRegistry.execute(commandSpec.id, commandSpec.args); | ||
}; | ||
this._paletteModel = new phosphor_commandpalette_1.StandardPaletteModel(); | ||
@@ -49,3 +55,25 @@ this._commandPalette = new phosphor_commandpalette_1.CommandPalette(); | ||
this._shortcutManager = shortcutManager; | ||
commandRegistry.add([ | ||
{ | ||
id: 'command-palette:focus-input', | ||
handler: function () { | ||
_this._commandPalette.inputNode.focus(); | ||
_this._commandPalette.inputNode.select(); | ||
} | ||
} | ||
]); | ||
} | ||
Object.defineProperty(CommandPaletteManager.prototype, "commandTriggered", { | ||
/** | ||
* A signal emitted when a command is triggered by the palette. | ||
* | ||
* #### Note | ||
* The order in which the command executes and the signal emits is undefined. | ||
*/ | ||
get: function () { | ||
return CommandPaletteManagerPrivate.commandTriggeredSignal.bind(this); | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(CommandPaletteManager.prototype, "widget", { | ||
@@ -75,10 +103,9 @@ /** | ||
var options = { | ||
handler: function (args) { | ||
_this._commandRegistry.execute(item.id, args); | ||
}, | ||
args: item.args, | ||
handler: _this._commandHandler, | ||
args: { id: item.id, args: item.args }, | ||
text: item.text, | ||
shortcut: '', | ||
category: item.category, | ||
caption: item.caption }; | ||
caption: item.caption | ||
}; | ||
var shortcut = _this._shortcutManager.getSequences(item.id, item.args); | ||
@@ -100,1 +127,14 @@ if (shortcut && shortcut.length > 0) { | ||
}()); | ||
/** | ||
* The namespace for the `CommandPaletteManager` class private data. | ||
*/ | ||
var CommandPaletteManagerPrivate; | ||
(function (CommandPaletteManagerPrivate) { | ||
/** | ||
* A signal emitted when a command is triggered by the palette. | ||
* | ||
* #### Note | ||
* The order in which the command executes and the signal emits is undefined. | ||
*/ | ||
CommandPaletteManagerPrivate.commandTriggeredSignal = new phosphor_signaling_1.Signal(); | ||
})(CommandPaletteManagerPrivate || (CommandPaletteManagerPrivate = {})); |
{ | ||
"name": "phosphide", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "Slightly opinionated scaffolding for building plugin-based IDE-style applications.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
174848
5201