Skip to content

Commit

Permalink
Use new script
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Mar 6, 2019
1 parent eb35ffb commit bcc28bf
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 46 deletions.
2 changes: 1 addition & 1 deletion bin/update-readmes.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const packages = [
'escape-html',
//'html-entities',
//'i18n',
//'keycodes',
'keycodes',
//'plugins',
//'priority-queue',
//'redux-routine',
Expand Down
86 changes: 49 additions & 37 deletions packages/keycodes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,37 +40,37 @@ onKeyDown( event ) {

### ALT

[src/index.js#L40-L40](src/index.js#L40-L40)
[src/index.js#L74-L74](src/index.js#L74-L74)

Undocumented declaration.
Keycode for ALT key.

### BACKSPACE

[src/index.js#L27-L27](src/index.js#L27-L27)
[src/index.js#L30-L30](src/index.js#L30-L30)

Undocumented declaration.
Keycode for BACKSPACE key.

### COMMAND

[src/index.js#L42-L42](src/index.js#L42-L42)
[src/index.js#L82-L82](src/index.js#L82-L82)

Undocumented declaration.
Keycode for COMMAND/META key.

### CTRL

[src/index.js#L41-L41](src/index.js#L41-L41)
[src/index.js#L78-L78](src/index.js#L78-L78)

Undocumented declaration.
Keycode for CTRL key.

### DELETE

[src/index.js#L36-L36](src/index.js#L36-L36)
[src/index.js#L66-L66](src/index.js#L66-L66)

Undocumented declaration.
Keycode for DELETE key.

### displayShortcut

[src/index.js#L108-L110](src/index.js#L108-L110)
[src/index.js#L166-L168](src/index.js#L166-L168)

An object that contains functions to display shortcuts.
E.g. displayShortcut.primary( 'm' ) will return '⌘M' on Mac.
Expand All @@ -81,7 +81,7 @@ E.g. displayShortcut.primary( 'm' ) will return '⌘M' on Mac.

### displayShortcutList

[src/index.js#L77-L100](src/index.js#L77-L100)
[src/index.js#L135-L158](src/index.js#L135-L158)

Return an array of the parts of a keyboard shortcut chord for display
E.g displayShortcutList.primary( 'm' ) will return [ '⌘', 'M' ] on Mac.
Expand All @@ -92,31 +92,31 @@ E.g displayShortcutList.primary( 'm' ) will return [ '⌘', 'M' ] on Mac.

### DOWN

[src/index.js#L35-L35](src/index.js#L35-L35)
[src/index.js#L62-L62](src/index.js#L62-L62)

Undocumented declaration.
Keycode for DOWN key.

### ENTER

[src/index.js#L29-L29](src/index.js#L29-L29)
[src/index.js#L38-L38](src/index.js#L38-L38)

Undocumented declaration.
Keycode for ENTER key.

### ESCAPE

[src/index.js#L30-L30](src/index.js#L30-L30)
[src/index.js#L42-L42](src/index.js#L42-L42)

Undocumented declaration.
Keycode for ESCAPE key.

### F10

[src/index.js#L38-L38](src/index.js#L38-L38)
[src/index.js#L70-L70](src/index.js#L70-L70)

Undocumented declaration.
Keycode for F10 key.

### isKeyboardEvent

[src/index.js#L146-L160](src/index.js#L146-L160)
[src/index.js#L204-L218](src/index.js#L204-L218)

An object that contains functions to check if a keyboard event matches a
predefined shortcut combination.
Expand All @@ -129,19 +129,31 @@ signals pressing ⌘M.

### LEFT

[src/index.js#L32-L32](src/index.js#L32-L32)
[src/index.js#L50-L50](src/index.js#L50-L50)

Undocumented declaration.
Keycode for LEFT key.

### modifiers

[src/index.js#L45-L56](src/index.js#L45-L56)
[src/index.js#L103-L114](src/index.js#L103-L114)

Object that contains functions that return the available modifier
depending on platform.

Undocumented declaration.
- `primary`: takes a isApple function as a parameter.
- `primaryShift`: takes a isApple function as a parameter.
- `primaryAlt`: takes a isApple function as a parameter.
- `secondary`: takes a isApple function as a parameter.
- `access`: takes a isApple function as a parameter.
- `ctrl`
- `alt`
- `ctrlShift`
- `shift`
- `shiftAlt`

### rawShortcut

[src/index.js#L65-L69](src/index.js#L65-L69)
[src/index.js#L123-L127](src/index.js#L123-L127)

An object that contains functions to get raw shortcuts.
E.g. rawShortcut.primary( 'm' ) will return 'meta+m' on Mac.
Expand All @@ -153,40 +165,40 @@ These are intended for user with the KeyboardShortcuts component or TinyMCE.

### RIGHT

[src/index.js#L34-L34](src/index.js#L34-L34)
[src/index.js#L58-L58](src/index.js#L58-L58)

Undocumented declaration.
Keycode for RIGHT key.

### SHIFT

[src/index.js#L43-L43](src/index.js#L43-L43)
[src/index.js#L86-L86](src/index.js#L86-L86)

Undocumented declaration.
Keycode for SHIFT key.

### shortcutAriaLabel

[src/index.js#L116-L136](src/index.js#L116-L136)
[src/index.js#L174-L194](src/index.js#L174-L194)

An object that contains functions to return an aria label for a keyboard shortcut.
E.g. shortcutAriaLabel.primary( '.' ) will return 'Command + Period' on Mac.

### SPACE

[src/index.js#L31-L31](src/index.js#L31-L31)
[src/index.js#L46-L46](src/index.js#L46-L46)

Undocumented declaration.
Keycode for SPACE key.

### TAB

[src/index.js#L28-L28](src/index.js#L28-L28)
[src/index.js#L34-L34](src/index.js#L34-L34)

Undocumented declaration.
Keycode for TAB key.

### UP

[src/index.js#L33-L33](src/index.js#L33-L33)
[src/index.js#L54-L54](src/index.js#L54-L54)

Undocumented declaration.
Keycode for UP key.


<!-- END TOKEN(Autogenerated API docs) -->
Expand Down
6 changes: 0 additions & 6 deletions packages/keycodes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@
"@wordpress/i18n": "file:../i18n",
"lodash": "^4.17.11"
},
"devDependencies": {
"@wordpress/docgen": "file:../docgen"
},
"publishConfig": {
"access": "public"
},
"scripts": {
"docs:generate": "docgen ./src/index.js --output ./README.md --to-token"
}
}
62 changes: 60 additions & 2 deletions packages/keycodes/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,82 @@ import { __ } from '@wordpress/i18n';
*/
import { isAppleOS } from './platform';

/**
* Keycode for BACKSPACE key.
*/
export const BACKSPACE = 8;
/**
* Keycode for TAB key.
*/
export const TAB = 9;
/**
* Keycode for ENTER key.
*/
export const ENTER = 13;
/**
* Keycode for ESCAPE key.
*/
export const ESCAPE = 27;
/**
* Keycode for SPACE key.
*/
export const SPACE = 32;
/**
* Keycode for LEFT key.
*/
export const LEFT = 37;
/**
* Keycode for UP key.
*/
export const UP = 38;
/**
* Keycode for RIGHT key.
*/
export const RIGHT = 39;
/**
* Keycode for DOWN key.
*/
export const DOWN = 40;
/**
* Keycode for DELETE key.
*/
export const DELETE = 46;

/**
* Keycode for F10 key.
*/
export const F10 = 121;

/**
* Keycode for ALT key.
*/
export const ALT = 'alt';
/**
* Keycode for CTRL key.
*/
export const CTRL = 'ctrl';
/**
* Keycode for COMMAND/META key.
*/
export const COMMAND = 'meta';
/**
* Keycode for SHIFT key.
*/
export const SHIFT = 'shift';

/**
* Object that contains functions that return the available modifier
* depending on platform.
*
* - `primary`: takes a isApple function as a parameter.
* - `primaryShift`: takes a isApple function as a parameter.
* - `primaryAlt`: takes a isApple function as a parameter.
* - `secondary`: takes a isApple function as a parameter.
* - `access`: takes a isApple function as a parameter.
* - `ctrl`
* - `alt`
* - `ctrlShift`
* - `shift`
* - `shiftAlt`
*/
export const modifiers = {
primary: ( _isApple ) => _isApple() ? [ COMMAND ] : [ CTRL ],
primaryShift: ( _isApple ) => _isApple() ? [ SHIFT, COMMAND ] : [ CTRL, SHIFT ],
Expand Down

0 comments on commit bcc28bf

Please sign in to comment.