Skip to content

Commit

Permalink
Simplified match callback change for starting emojis with space
Browse files Browse the repository at this point in the history
  • Loading branch information
engineering-this authored and msamsel committed Aug 3, 2018
1 parent b090729 commit d358f3a
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions plugins/emoji/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,13 @@

function matchCallback( text, offset ) {
var left = text.slice( 0, offset ),
match = left.match( new RegExp( ':\\S{' + charactersToStart + '}\\S*$' ) );
// Positive lookbehind for space, as emoji should be started with space or newline (#2195).
match = left.match( new RegExp( '(?<=\\s\|^):\\S{' + charactersToStart + '}\\S*$' ) );

if ( !match ) {
return null;
}

// Do not proceed if a query is a part of word.
var prevChar = text[ match.index - 1];
if ( prevChar !== undefined && !prevChar.match( /\s+/ ) ) {
return null;
}

return { start: match.index, end: offset };
}

Expand Down

0 comments on commit d358f3a

Please sign in to comment.