UNPKG

react-tinymce-mention

Version:

@Mention functionality for TinyMCE, built with React and Redux.

15 lines (12 loc) 455 B
export function getLastChar(editor, negativeIndex = 1) { const start = editor.selection.getRng(true).startOffset; const text = editor.selection.getRng(true).startContainer.data || ''; const character = text.substr(start - negativeIndex, 1); return character; } export function collectMentionIds(editor, mentionClassName) { const mentions = editor.dom .select(mentionClassName) .map(mentionNode => mentionNode.id); return mentions; }