// eslint-disable-next-line import/no-unresolved // eslint-disable-next-line import/no-duplicates import customComponentExampleCode from '!!raw-loader!../../../components/Examples/mention/CustomComponentMentionEditor/CustomComponentMentionEditor'; // eslint-disable-next-line import/no-unresolved import customComponentExampleStylesCode from '!!raw-loader!../../../components/Examples/mention/CustomComponentMentionEditor/CustomComponentMentionEditor.module.css'; // eslint-disable-next-line import/no-unresolved // eslint-disable-next-line import/no-duplicates import customExampleCode from '!!raw-loader!../../../components/Examples/mention/CustomMentionEditor/CustomMentionEditor'; // eslint-disable-next-line import/no-unresolved import customExampleEditorStylesCode from '!!raw-loader!../../../components/Examples/mention/CustomMentionEditor/CustomMentionEditor.module.css'; // eslint-disable-next-line import/no-unresolved import customExampleMentionsCode from '!!raw-loader!../../../components/Examples/mention/CustomMentionEditor/Mentions'; // eslint-disable-next-line import/no-unresolved import customExampleMentionsStylesCode from '!!raw-loader!../../../components/Examples/mention/CustomMentionEditor/MentionsStyles.module.css'; // eslint-disable-next-line import/no-unresolved // eslint-disable-next-line import/no-duplicates import multiComponentExampleCode from '!!raw-loader!../../../components/Examples/mention/MultiMentionTriggers/MultiMentionTriggers'; // eslint-disable-next-line import/no-unresolved import multiComponentExampleStylesCode from '!!raw-loader!../../../components/Examples/mention/MultiMentionTriggers/MultiMentionTriggers.module.css'; // eslint-disable-next-line import/no-unresolved // eslint-disable-next-line import/no-duplicates import remoteExampleCode from '!!raw-loader!../../../components/Examples/mention/RemoteMentionEditor/RemoteMentionEditor'; // eslint-disable-next-line import/no-unresolved import remoteExampleEditorStylesCode from '!!raw-loader!../../../components/Examples/mention/RemoteMentionEditor/RemoteMentionEditor.module.css'; // eslint-disable-next-line import/no-unresolved import simpleExampleMentionsCode from '!!raw-loader!../../../components/Examples/mention/SimpleMentionEditor/Mentions'; // eslint-disable-next-line import/no-unresolved // eslint-disable-next-line import/no-duplicates import simpleExampleCode from '!!raw-loader!../../../components/Examples/mention/SimpleMentionEditor/SimpleMentionEditor'; // eslint-disable-next-line import/no-unresolved import simpleExampleEditorStylesCode from '!!raw-loader!../../../components/Examples/mention/SimpleMentionEditor/SimpleMentionEditor.module.css'; // eslint-disable-next-line import/no-unresolved import webpackConfig from '!!raw-loader!../../../components/Examples/mention/webpackConfig'; import React, { ReactElement } from 'react'; import AlternateContainer from '../../../components/AlternateContainer/AlternateContainer'; import Code from '../../../components/Code/Code'; import Container from '../../../components/Container/Container'; // eslint-disable-next-line import/no-duplicates import CustomComponentMentionEditor from '../../../components/Examples/mention/CustomComponentMentionEditor/CustomComponentMentionEditor'; // eslint-disable-next-line import/no-duplicates import CustomMentionEditor from '../../../components/Examples/mention/CustomMentionEditor/CustomMentionEditor'; // eslint-disable-next-line import/no-duplicates import MultiMentionTriggers from '../../../components/Examples/mention/MultiMentionTriggers/MultiMentionTriggers'; // eslint-disable-next-line import/no-duplicates import RemoteMentionEditor from '../../../components/Examples/mention/RemoteMentionEditor/RemoteMentionEditor'; // eslint-disable-next-line import/no-duplicates import SimpleMentionEditor from '../../../components/Examples/mention/SimpleMentionEditor/SimpleMentionEditor'; import Heading from '../../../components/Heading/Heading'; import InlineCode from '../../../components/InlineCode/InlineCode'; import ExternalLink from '../../../components/Link/Link'; import PluginPageFrame from '../../../components/PluginPageFrame/PluginPageFrame'; import styles from './Mention.module.css'; export default function Mention(): ReactElement { return ( Mention

Mentions for everyone! This plugin allows the user to choose an entry from a list. After selection an entry the search text will be replace with the selected entity. The list of suggestions mentions needs to contain at least a name to display. If desired a link and/or an avatar image can be provided.

Escape Behaviour

While the suggestion popover is open, the user can close it by pressing ESC. This will be stored for as long as the the selection stays inside the word that triggered the search. After the selection left this word once the escape behaviour will be reset. The suggestions will appear again once the user selects the word that that triggered the selection.

Supported Environment
Getting Started Importing the default styles

The plugin ships with a default styling available at this location in the installed package:  

Webpack Usage
  • 1. Install Webpack loaders:  
  • 2. Add the below section to Webpack config (if your config already has a loaders array, simply add the below loader object to your existing list.
  • 3. Add the below import line to your component to tell Webpack to inject the style to your component.
  • 4. Restart Webpack.
Configuration Parameters
theme Object of CSS classes with the following keys.
mention: CSS class for mention text.
mentionSuggestions: CSS class for suggestions component.
mentionSuggestionsPopup: CSS class for popup.js suggestions component.
mentionSuggestionsPopupVisible: CSS class for popup.js suggestions component when it is visible. Can be used for animations.
mentionSuggestionsEntry: CSS class for an entry in the suggestions component.
mentionSuggestionsEntryFocused: CSS class for the focused entry in the suggestions component.
mentionSuggestionsEntryText: CSS class for an entry’s text in the suggestions component.
mentionSuggestionsEntryAvatar: CSS class for an entry’s avatar image in the suggestions component.
positionSuggestions Deprecated, use popperOptions instead The function can be used to manipulate the position of the popover containing the suggestions. It receives one object as arguments containing the visible rectangle surrounding the decorated search string including the @. In addition the object contains prevProps and props. An object should be returned which can contain all sorts of styles. The defined properties will be applied as inline-styles.
popperOptions This options will be used to initialize popper.js. Read in detail about it{' '} here.
entityMutability Can be one of: "IMMUTABLE", "SEGMENTED" or "MUTABLE". Read in detail about it  here
mentionPrefix By default it is an empty String. For Twitter or Slack like mention behaviour you can provide an `@`
mentionTrigger Allows you to provide a array custom character to change when the search is triggered. By default it is set to `@`. By default typing `@` will trigger the search for mentions. It also does support a multi-charater mentionTrigger. You can use it like `mentionTrigger: ['@', '(']`.
mentionRegExp Allows you to overwrite the regular expression for initiating the dropdown. By default this supports any alphanumeric character as well as Chinese, Japanese & Korean characters. We are happy to accept pull requests to extend the default mentionRegExp as well.
supportWhitespace Allows you to support a whitespace while typing a search option, useful for searching first and last names. By default this is set to `false`
mentionComponent If provided the passed component is used to render a Mention. It receives the following props: entityKey, mention, className & decoratedText
MentionSuggestions
The MentionSuggestions component is part of the plugin and should placed somewhere in the JSX after the Editor. It takes the following props:
open Controlled state of mention popup.
onOpenChange A callback which is triggered whenever the suggestions popover should be opened or closed.
suggestions The list of suggestions to be shown.
onSearchChange A callback which is triggered whenever the search term changes. The first argument is an object which contains the search term in the property value.
entryComponent Component to be used as the template for each of the suggestions entry.
onAddMention A callback which is triggered whenever the mention is about to be added. The first argument of this callback will contain the mention entry.
popoverComponent Deprecated, use popperOptions/popoverContainer instead{' '} Component to be used as the template for the popover (the parent of entryComponent). Defaults to a div.
popoverContainer Defaults to a div which is bound to popper.js. If don't want to have a popover you can overwrite the component with you own.
renderEmptyPopup If set to true if will render the popup even if there are no mentions to show. This can for example be used to show a message that there are no matching mentions.
mentionSuggestionsComponent Component to be used to render the suggestions dropdown. It must implement the same interface like{' '} . Defaults to{' '} .
Additional properties are passed to the{' '}
Additional Exports
In addition to the plugin the module exports{' '} . As first argument it takes the search term as a String. The second argument is an array of mentions. The third argument is a trigger that is used to filter multi mentions. The function returns the filter list based on substring matches.
Simple Example Custom Themed Mention Example Remote Data Mention Example Custom Mention Component Example Multi Mention Triggers
); }