custom-app
Version:
ITIMS��Ʒ�鿪��ר��React���,�Dz��ý��ּ�dhcc-app���������
19 lines (15 loc) • 767 B
JavaScript
import { Modifier, EditorState } from 'draft-js';
import getSearchWord from './getSearchWord';
export default function clearMention(editorState) {
var selection = editorState.getSelection();
var searchWord = getSearchWord(editorState, selection);
var begin = searchWord.begin,
end = searchWord.end;
var replacedContent = Modifier.replaceText(editorState.getCurrentContent(), selection.merge({
anchorOffset: begin,
focusOffset: end
}), '', null);
var InsertSpaceContent = Modifier.insertText(replacedContent, replacedContent.getSelectionAfter(), ' ');
var newEditorState = EditorState.push(editorState, InsertSpaceContent, 'insert-mention');
return EditorState.forceSelection(newEditorState, InsertSpaceContent.getSelectionAfter());
}