import { Textcomplete , Textarea } from "textcomplete" ; import { AUTO_COMPLETE_MAX_CANDIDATES } from "../../shared/constants" ; param textComplete param nameList export const registerAutoComplete = ( textComplete , nameList ) : void => { const editor = new Textarea ( textComplete ) ; const autoCompleteContent = new Textcomplete ( editor ) ; autoCompleteContent . register ( [ { match : /(.*)@(.*?)$/ , search : ( term , callback ) : void => { callback ( nameList . filter ( name => { return name . startsWith ( term ) ; } ) . slice ( 0 , AUTO_COMPLETE_MAX_CANDIDATES ) ) ; } , replace : ( value ) => { return "$1@" + value + " " ; } } ] ) ; } ;