@@ -20,6 +20,8 @@ import { Emoji } from '../../components/emoji/Emoji';
2020import { EmojiPickDataType } from '../../components/emoji/EmojiPicker' ;
2121import { getBlotTextPartitions , matchBlotTextPartitions } from '../util' ;
2222
23+ const Keyboard = Quill . import ( 'modules/keyboard' ) ;
24+
2325interface EmojiPickerOptions {
2426 onPickEmoji : ( emoji : EmojiPickDataType ) => void ;
2527 setEmojiPickerElement : ( element : JSX . Element | null ) => void ;
@@ -61,10 +63,10 @@ export class EmojiCompletion {
6163 return true ;
6264 } ;
6365
64- this . quill . keyboard . addBinding ( { key : 37 } , clearResults ) ; // 37 = Left
65- this . quill . keyboard . addBinding ( { key : 38 } , changeIndex ( - 1 ) ) ; // 38 = Up
66- this . quill . keyboard . addBinding ( { key : 39 } , clearResults ) ; // 39 = Right
67- this . quill . keyboard . addBinding ( { key : 40 } , changeIndex ( 1 ) ) ; // 40 = Down
66+ this . quill . keyboard . addBinding ( { key : Keyboard . keys . UP } , changeIndex ( - 1 ) ) ;
67+ this . quill . keyboard . addBinding ( { key : Keyboard . keys . RIGHT } , clearResults ) ;
68+ this . quill . keyboard . addBinding ( { key : Keyboard . keys . DOWN } , changeIndex ( 1 ) ) ;
69+ this . quill . keyboard . addBinding ( { key : Keyboard . keys . LEFT } , clearResults ) ;
6870 this . quill . keyboard . addBinding (
6971 {
7072 // 186 + Shift = Colon
@@ -181,6 +183,7 @@ export class EmojiCompletion {
181183
182184 if ( showEmojiResults . length > 0 ) {
183185 this . results = showEmojiResults ;
186+ this . index = Math . min ( this . results . length - 1 , this . index ) ;
184187 this . render ( ) ;
185188 } else if ( this . results . length !== 0 ) {
186189 this . reset ( ) ;
0 commit comments