restore insert mention
for this, we need to store the last caret in the editor, to know where to insert the user pill. Because clicking on a member blurs the editor, and the selection is moved away from the editor. For this reason, we keep as cache of the last caretOffset object, invalidated by a selection with different values. The selection needs to be cloned because apparently the browser mutates the object instead of returning a new one.
This commit is contained in:
parent
71286b5610
commit
c135cd60d2
3 changed files with 111 additions and 17 deletions
|
@ -97,6 +97,15 @@ export default class SendMessageComposer extends React.Component {
|
|||
case 'focus_composer':
|
||||
this._editorRef.focus();
|
||||
break;
|
||||
case 'insert_mention': {
|
||||
const userId = payload.user_id;
|
||||
const member = this.props.room.getMember(userId);
|
||||
const displayName = member ?
|
||||
member.rawDisplayName : payload.user_id;
|
||||
const userPillPart = this.model.partCreator.userPill(displayName, userId);
|
||||
this.model.insertPartAt(userPillPart, this._editorRef.getCaret());
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue