Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if ((keyboardEvent.which === KEYCODE_COLON || keyboardEvent.which === KEYCODE_COLON_FIREFOX) && wordBeforeCursor === ":") {
const { onKeyboardTriggered = NullFunction } = this.options;
this._setIsSuggesting(true);
onKeyboardTriggered();
} else if (wordBeforeCursor) {
const cursorData = cacheGetContentSearcher(event, this._editor);
const charBeforeCursor = cursorData ? cursorData.getSubStringBefore(1) : null;
// It is possible that the word before the cursor is ahead of the pluginEvent we are handling
// ex. WordBeforeCursor is ":D"" but the event we are currently handling is for the : key
// Check that the char before the cursor is actually the key event we are currently handling
// Otherwise we set canUndoEmoji to early and user is unable to backspace undo on the inserted emoji
if (keyboardEvent.key === charBeforeCursor) {
const emoji = matchShortcut(wordBeforeCursor);
if (emoji && this._insertEmoji(emoji, wordBeforeCursor)) {
clearContentSearcherCache(event);
this._canUndoEmoji = true;
}
}
}
}
editor.performAutoComplete(() => {
replaceWithNode(editor, linkData.originalUrl, anchor, false /* exactMatch */, searcher);
// The content at cursor has changed. Should also clear the cursor data cache
clearContentSearcherCache(event);
return anchor;
}, ChangeSource.AutoLink);
});