TY
feat: Add Emoji Picker Option
TypeCellOS/BlockNote#854

/claim #808 fixes #808 this pull request adds the emoji picker option which is accessible by both the trigger character (:) and the slash menu.

Recordings

Screencast from 19-06-2024 20:11:04.webm

https://github.com/TypeCellOS/BlockNote/assets/89797440/aa1637e1-8bf1-47b6-a3a6-1dea329103c8

Approach

I started with a custom suggestion menu as suggested, with custom component and getItems function. The function fetches all the emojis from the Emojimart at initial render, and then returns the emojis as items on every search. This approach may sound unfamiliar as using emoji-mart as the picker would have been preferable, however the main issue with almost all emoji-pickers is that either they don’t allow filtering out the emojis shown, or even if indirectly allowed (like emoji-mart allows to hide some emoijs ), they don’t update dynamically to reflect those changes. Therefore I was left with an option of creating a custom picker, which worked pretty fine. I then proceeded to add the functionality in the useSuggestionMenuKeyboardNavigation.ts file to handle all sorts of navigation forward and backward arrows if it’s for the emojiMenu.

Secondly, the task was to make this menu accessible by the slash-menu, therefore I added a custom option to slash menu for emojis, which was similar to other options except that this option doesn’t insert anything into the editor, instead it just simulates a keydown when clicked, which is listened by the onKeyDown function specified in the plugin props in the suggestionPlugin.ts file, which then carries the logic and opens the emojiMenu

Tests

  • The code is vigorously tested on multiple network throttling levels to ensure that the emojis don’t take too much time to load.
  • All types of examples are used, including showing document Json and the one with mentions menu
  • All types of keyboard navigation is tested, including right and left arrows.

Claim

Total prize pool $100
Total paid $100
Status Approved
Submitted June 20, 2024
Last updated July 17, 2024

Contributors

HU

Hunain Ahmed

@hunxjunedo

100%

Sponsors

BL

BlockNote

@BlockNote

$100 paid