1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-20 16:22:28 +03:00

Merge pull request #3210 from matrix-org/bwindels/prevent-autocomplete-on-paste

Prevent autocomplete on paste, and verserev-ing text before and after :
This commit is contained in:
Bruno Windels
2019-07-12 08:25:06 +00:00
committed by GitHub
3 changed files with 38 additions and 9 deletions

View File

@@ -280,6 +280,7 @@ export default class MessageEditor extends React.Component {
}
componentWillUnmount() {
this._editorRef.removeEventListener("input", this._onInput, true);
const sel = document.getSelection();
const {caret} = getCaretOffsetAndText(this._editorRef, sel);
const parts = this.model.serializeParts();
@@ -292,6 +293,9 @@ export default class MessageEditor extends React.Component {
this._updateEditorState();
// initial caret position
this._initializeCaret();
// attach input listener by hand so React doesn't proxy the events,
// as the proxied event doesn't support inputType, which we need.
this._editorRef.addEventListener("input", this._onInput, true);
this._editorRef.focus();
}
@@ -359,7 +363,6 @@ export default class MessageEditor extends React.Component {
className="mx_MessageEditor_editor"
contentEditable="true"
tabIndex="1"
onInput={this._onInput}
onKeyDown={this._onKeyDown}
ref={ref => this._editorRef = ref}
aria-label={_t("Edit message")}