choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
17 lines (16 loc) • 805 B
JavaScript
import { EditorState, Modifier } 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());
}
//# sourceMappingURL=clearMention.js.map