new PaletteCommand( [ options ] )

Description

Default options is litteraly


			const defaultOptions = {
			 isShortcut: event => event.ctrlKey && event.altKey && event.key === 'p',
			 navigationCallback(event) {
			   switch (event.key) {
			     case 'ArrowDown':
			       this.next();
			       break;
			     case 'ArrowUp':
			       this.prev();
			       break;
			     case 'Enter':
			       this.dispatch();
			       break;
			   }
			 }
			}
Parameters
Name Type Attributes Default Description
options PaletteCommand~ConstructorOptions <optional>
{}

Options for palette

Properties
Name Type Description
options PaletteCommand~ConstructorOptions

Merged options (Object.assign) you give to constructor with default options

Details

Methods


setCategory( commands [, category ] )

If no category specified, merge commands in generic category
else replace existent category (if exist) with this set of commands

.

Description

If no category specified, merge commands in generic category
else replace existent category (if exist) with this set of commands

Parameters
Name Type Attributes Default Description
commands Array.<PaletteCommand~Command>
category string | symbol <optional>
''
Examples

			// add commands to default context
			palette.setCategory([
			 {
			   name: 'foo',
			   description: 'log `foo` in console'
			   action() {
			     console.log('foo');
			   }
			 }
			]);
			
			// replace `Bar` context
			palette.setCategory([
			 {
			   name: 'foo',
			   description: 'log `foo` in console'
			   action() {
			     console.log('foo');
			   }
			 }
			], 'Bar');
Details

removeCategory( category )

Parameters
Name Type Description
category string | symbol
Details

addToCategory( commands [, category ] )

Add list (or single) Command to the category

.

Description

Add list (or single) Command to the category

Parameters
Name Type Attributes Default Description
commands PaletteCommand~Command | Array.<PaletteCommand~Command>
category string | symbol <optional>
''

Generic category if not specified

Details

show()

lazy load the command palette and display it

.

Description

lazy load the command palette and display it

Details

hide()

lazy load the command palette and hide it

.

Description

lazy load the command palette and hide it

Details

isShow() → {boolean}

lazy load the command palette and return if it display

.

Description

lazy load the command palette and return if it display

Returns
Details

isHide() → {boolean}

lazy load the command palette and return if it not display

.

Description

lazy load the command palette and return if it not display

Returns
Details

next()

lazy load the palette
and select next item in command list

.

Description

lazy load the palette
and select next item in command list

Details

prev()

lazy load the palette
and select previous item in command list

.

Description

lazy load the palette
and select previous item in command list

Details

lazy load palette
and hide items whose not respect the fuzzySearch terms

.

Description

lazy load palette
and hide items whose not respect the fuzzySearch terms

Parameters
Name Type Description
text string
Details

dispatch()

lazy load palette
and run selected command

.

Description

lazy load palette
and run selected command

Details

destroy()

Remove PaletteCommand from DOM

.

Description

Remove PaletteCommand from DOM

Details

Type Definitions


Command

Properties
Name Type Attributes Description
name string | symbol

Name of command (print in palette after category name)

description string <optional>

Detail text for explain action of command

action function

Callback when user press Enter on command when selected

Details
object

ConstructorOptionsNavigation( event )

Parameters
Name Type Description
event KeyboardEvent

keypress event from document

Details
function

ConstructorOptions

Properties
Name Type Attributes Description
cssClass string <optional>

add if you want stylize the palette with your own css ;-)

isShortcut PaletteCommand~ConstructorOptionsShortcut <optional>

take a KeyboardEvent and return if right shortcut, by default the shortcut is ctrl-alt-p

navigationCallback PaletteCommand~ConstructorOptionsNavigation <optional>

take a KeyboardEvent and execute your navigation

Details
object

ConstructorOptionsShortcut( event ) → {boolean}

Parameters
Name Type Description
event KeyboardEvent

keypress event from document

Returns
  • return true if keypress event is your shortcut
Details
function