File tree Expand file tree Collapse file tree
src/web/pmPlugins/MentionPlugin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,8 +41,11 @@ export function setMention(
4141
4242 // avoid inserting a space if there already is one
4343 const parentEnd = state . doc . resolve ( extendedTo ) . end ( ) ;
44- const charAfter = state . doc . textBetween ( extendedTo , extendedTo + 1 , '' ) ;
45- const hasSpaceAfter = extendedTo < parentEnd && / \s / . test ( charAfter ) ;
44+ let hasSpaceAfter = false ;
45+ if ( extendedTo < parentEnd ) {
46+ const charAfter = state . doc . textBetween ( extendedTo , extendedTo + 1 , '' ) ;
47+ hasSpaceAfter = / \s / . test ( charAfter ) ;
48+ }
4649
4750 const mentionMark = mentionType . create ( {
4851 indicator,
Original file line number Diff line number Diff line change @@ -47,14 +47,14 @@ export function useMentionEvents(
4747
4848 const mention = getMentionInCurrentSelection ( editor ) ;
4949 if ( ! mention ) {
50- wasInMention = false ;
51- prevMentionKey = null ;
5250 if ( wasInMention ) {
5351 cb . onMentionDetected ( {
5452 text : '' ,
5553 indicator : '' ,
5654 attributes : { } ,
5755 } ) ;
56+ wasInMention = false ;
57+ prevMentionKey = null ;
5858 }
5959 } else {
6060 wasInMention = true ;
You can’t perform that action at this time.
0 commit comments