0.1.2 • Published 3 months ago

react-slate-mentions v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

React Slate Mentions

React component for enabling hashtags and mentions while editing. This is enabled while using either # or @ preceeding the text to be inserted.

Getting started

Install the react-slate-mentions using the command below:

npm install react-slate-mentions

Usage

Import the component to be used using the following:

import { MentionEditor } from 'react-slate-mentions'

Optionally, you can also import the base css styles.

import 'react-slate-mentions/dis/style.css'

Integrate the component into your project using the example below

<MentionEditor
  editorClassname={...}
  editorId={...}
  placeholder={...}
  hashTagEnabled
  menuItems={...}
  collectedItems={...}
  isProcessing={...}
  handleSearch={...}
  searchContainerClassName={...}
  searchMenuItemClassName={...}
  elementClassName={...}
  handleItemsCollected={...}
  handleOnChange={...}
  initialValue={...}
  allowUniqueHashTags={...}
  allowUniqueMentions={...}
  loadingComponent={...}
  isReadOnly={...}
/>

Component Props

The following are the available props for the component and their defaults

NameTypeRequiredDescriptionDefault
editorIdstringfalseEditor IDundefined
placeholderstringfalseEditor placeholder textundefined
editorClassnamestringfalseEditor classnameundefined
menuItemsArray<{ key: string; value: string}>falseList of dropdown items per triggerundefined
collectedItemsArray<{ key: string; value: string; prefix?: string }>falseList of dropdown items for unique sortingundefined
isProcessingbooleanfalseState for pensing operationsundefined
handleSearchFunctionfalseHandle preparation of dropdown items in this functionundefined
searchContainerClassNamestringfalseClassname for editor menu containerundefined
searchMenuItemClassNamestringfalseClassname for editor dropdown menu itemsundefined
elementClassNamestringfalseClassname for editor elements during renderundefined
handleItemsCollectedFunctionfalseFunction for returning newly added itemsundefined
handleOnChangeFunctionfalseFunction for getting editor contentsundefined
allowUniqueHashTagsbooleanfalseBoolean for allowing/denying unique entriesundefined
allowUniqueMentionsbooleanfalseBoolean for allowing/denying unique entriesundefined
loadingComponentReact.ReactNodefalseComponent for displaying no result in the dropdownundefined
isReadOnlybooleanfalseBoolean for triggering edit/no-edit modeundefined