Implement old composer feature that inserts ': ' or ' '
after a user completion
This commit is contained in:
parent
0e8ad75248
commit
352f70f9ce
2 changed files with 9 additions and 2 deletions
|
@ -928,7 +928,7 @@ export default class MessageComposerInput extends React.Component {
|
|||
return false;
|
||||
}
|
||||
|
||||
const {range = {}, completion = '', entity = null} = displayedCompletion;
|
||||
const {range = {}, completion = '', entity = null, suffix = ''} = displayedCompletion;
|
||||
let entityKey;
|
||||
if (entity) {
|
||||
entityKey = Entity.create(
|
||||
|
@ -938,7 +938,7 @@ export default class MessageComposerInput extends React.Component {
|
|||
);
|
||||
}
|
||||
|
||||
const contentState = Modifier.replaceText(
|
||||
let contentState = Modifier.replaceText(
|
||||
activeEditorState.getCurrentContent(),
|
||||
RichText.textOffsetsToSelectionState(
|
||||
range, activeEditorState.getCurrentContent().getBlocksAsArray(),
|
||||
|
@ -948,6 +948,12 @@ export default class MessageComposerInput extends React.Component {
|
|||
entityKey,
|
||||
);
|
||||
|
||||
// Move the selection to the end of the block
|
||||
const afterSelection = contentState.getSelectionAfter();
|
||||
if (suffix) {
|
||||
contentState = Modifier.replaceText(contentState, afterSelection, suffix);
|
||||
}
|
||||
|
||||
let editorState = EditorState.push(activeEditorState, contentState, 'insert-characters');
|
||||
editorState = EditorState.forceSelection(editorState, contentState.getSelectionAfter());
|
||||
this.setState({editorState, originalEditorState: activeEditorState});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue