2.0.1 • Published 21 days ago

@impelsys/react-mentions v2.0.1

Weekly downloads
1
License
BSD-3-Clause
Repository
github
Last release
21 days ago

Forked from react-mentions package.

React mentions input, fork from react-mentions with some additional customisation functionality for custom add mention calls, and suggestion keyboard override.

The idea of these changes are to permit customised suggestions menus, drill-in multiple level mentions and ultimately add mentions for items that are not in the flat data structure supported as standard. A PR is intended once the additions are mature.

The MentionsInput supports the following additional props:

Prop nameTypeDefault valueDescription
onKeyDownOverridefunction (event, { mutateState, state, addMention, ...* })undefinedOverride onKeyDown events within the suggestions menu, passes functions for mutating state and adding mentions
keyDownOverrideTriggerCodesobjectundefinedObject containing name/keyCode's to trigger onKeyDownOverride when pressed within suggestions
onClearSuggestionsfunction ()undefinedCalled when the suggestions menu is closed without any selection from the user

onKeyDownOverride is passed the following additional functions provided by react-mentions for custom key handling to provide standard support.

  • clearSuggestions() closes the suggestions list without any selection
  • shiftFocus(delta) where delta increments/decrements the currently focused root suggestion item e.g. shiftFocus(-1)
  • selectFocused() selects the currently focused root suggestion

For any custom operation or sub-menu suggestions you should manually handle using the following.

  • mutateState((updater, callback) => ...) effectively a pass through to the MentionInput setState function
  • state is the current MentionInput state object
  • addMention({ id, display }, queryInfo) pass through of MentionInput addMention function

React Mentions

Source package here https://www.npmjs.com/package/react-mentions, all credit and thanks to the authors.

2.0.1

21 days ago

2.0.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago