Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _insertEmoji(emoji: Emoji, wordBeforeCursor: string): boolean {
let inserted = false;
this._editor.addUndoSnapshot();
const node = this._editor.getDocument().createElement("span");
node.innerText = emoji.codePoint;
if (wordBeforeCursor && replaceWithNode(this._editor, wordBeforeCursor, node, false /*exactMatch*/)) {
inserted = true;
this._canUndoEmoji = true;
// Update the editor cursor to be after the inserted node
window.requestAnimationFrame(() => {
if (this._editor && this._editor.contains(node)) {
this._editor.select(node, PositionType.After);
this._editor.addUndoSnapshot();
}
});
} else {
inserted = this._editor.insertNode(node);
}
inserted && this._triggerChangeEvent();
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);
});
let insertNode = () => {
if (wordToReplace) {
replaceWithNode(
this.editor,
wordToReplace,
htmlNode,
true /* exactMatch */
);
} else {
this.editor.insertNode(htmlNode);
}
this.setIsSuggesting(false);
};