@@ -16,6 +16,7 @@ limitations under the License.
1616*/
1717
1818import { split } from "lodash" ;
19+ import EMOJIBASE_REGEX from "emojibase-regex" ;
1920import { MatrixClient } from "matrix-js-sdk/src/client" ;
2021import { RoomMember } from "matrix-js-sdk/src/models/room-member" ;
2122import { Room } from "matrix-js-sdk/src/models/room" ;
@@ -25,7 +26,7 @@ import AutocompleteWrapperModel, {
2526 UpdateCallback ,
2627 UpdateQuery ,
2728} from "./autocomplete" ;
28- import { mightContainEmoji , unicodeToShortcode } from "../HtmlUtils" ;
29+ import { unicodeToShortcode } from "../HtmlUtils" ;
2930import * as Avatar from "../Avatar" ;
3031import defaultDispatcher from "../dispatcher/dispatcher" ;
3132import { Action } from "../dispatcher/actions" ;
@@ -191,7 +192,7 @@ abstract class BasePart {
191192
192193abstract class PlainBasePart extends BasePart {
193194 protected acceptsInsertion ( chr : string , offset : number , inputType : string ) : boolean {
194- if ( chr === "\n" || mightContainEmoji ( chr ) ) {
195+ if ( chr === "\n" || EMOJIBASE_REGEX . test ( chr ) ) {
195196 return false ;
196197 }
197198 // when not pasting or dropping text, reject characters that should start a pill candidate
@@ -361,7 +362,7 @@ class NewlinePart extends BasePart implements IBasePart {
361362
362363class EmojiPart extends BasePart implements IBasePart {
363364 protected acceptsInsertion ( chr : string , offset : number ) : boolean {
364- return mightContainEmoji ( chr ) ;
365+ return EMOJIBASE_REGEX . test ( chr ) ;
365366 }
366367
367368 protected acceptsRemoval ( position : number , chr : string ) : boolean {
@@ -553,7 +554,7 @@ export class PartCreator {
553554 case "\n" :
554555 return new NewlinePart ( ) ;
555556 default :
556- if ( mightContainEmoji ( input [ 0 ] ) ) {
557+ if ( EMOJIBASE_REGEX . test ( input [ 0 ] ) ) {
557558 return new EmojiPart ( ) ;
558559 }
559560 return new PlainPart ( ) ;
@@ -627,7 +628,7 @@ export class PartCreator {
627628
628629 // We use lodash's grapheme splitter to avoid breaking apart compound emojis
629630 for ( const char of split ( text , "" ) ) {
630- if ( mightContainEmoji ( char ) ) {
631+ if ( EMOJIBASE_REGEX . test ( char ) ) {
631632 if ( plainText ) {
632633 parts . push ( this . plain ( plainText ) ) ;
633634 plainText = "" ;
0 commit comments