You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-07 10:46:24 +03:00
force pasting as plain text in new composer
This commit is contained in:
@@ -25,10 +25,12 @@ import {
|
||||
formatRangeAsQuote,
|
||||
formatRangeAsCode,
|
||||
formatInline,
|
||||
replaceRangeAndMoveCaret,
|
||||
} from '../../../editor/operations';
|
||||
import {getCaretOffsetAndText, getRangeForSelection} from '../../../editor/dom';
|
||||
import Autocomplete from '../rooms/Autocomplete';
|
||||
import {autoCompleteCreator} from '../../../editor/parts';
|
||||
import {parsePlainTextMessage} from '../../../editor/deserialize';
|
||||
import {renderModel} from '../../../editor/render';
|
||||
import {Room} from 'matrix-js-sdk';
|
||||
import TypingStore from "../../../stores/TypingStore";
|
||||
@@ -169,6 +171,18 @@ export default class BasicMessageEditor extends React.Component {
|
||||
this._onInput({inputType: "insertCompositionText"});
|
||||
}
|
||||
|
||||
_onPaste = (event) => {
|
||||
const {model} = this.props;
|
||||
const {partCreator} = model;
|
||||
const text = event.clipboardData.getData("text/plain");
|
||||
if (text) {
|
||||
const range = getRangeForSelection(this._editorRef, model, document.getSelection());
|
||||
const parts = parsePlainTextMessage(text, partCreator);
|
||||
replaceRangeAndMoveCaret(range, parts);
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
_onInput = (event) => {
|
||||
// ignore any input while doing IME compositions
|
||||
if (this._isIMEComposing) {
|
||||
@@ -492,6 +506,7 @@ export default class BasicMessageEditor extends React.Component {
|
||||
tabIndex="1"
|
||||
onBlur={this._onBlur}
|
||||
onFocus={this._onFocus}
|
||||
onPaste={this._onPaste}
|
||||
onKeyDown={this._onKeyDown}
|
||||
ref={ref => this._editorRef = ref}
|
||||
aria-label={this.props.label}
|
||||
|
||||
Reference in New Issue
Block a user