fix pasting of plaintext content (prevent loads of <p>s) Fixes vector-im/riot-web#7043
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
414908611d
commit
1b467f6ca8
1 changed files with 14 additions and 12 deletions
|
@ -970,19 +970,21 @@ export default class MessageComposerInput extends React.Component {
|
||||||
onPaste = (event: Event, change: Change, editor: Editor): Change => {
|
onPaste = (event: Event, change: Change, editor: Editor): Change => {
|
||||||
const transfer = getEventTransfer(event);
|
const transfer = getEventTransfer(event);
|
||||||
|
|
||||||
if (transfer.type === "files") {
|
switch (transfer.type) {
|
||||||
return this.props.onFilesPasted(transfer.files);
|
case 'files':
|
||||||
}
|
return this.props.onFilesPasted(transfer.files);
|
||||||
else if (transfer.type === "html") {
|
case 'html': {
|
||||||
// FIXME: https://github.com/ianstormtaylor/slate/issues/1497 means
|
// FIXME: https://github.com/ianstormtaylor/slate/issues/1497 means
|
||||||
// that we will silently discard nested blocks (e.g. nested lists) :(
|
// that we will silently discard nested blocks (e.g. nested lists) :(
|
||||||
const fragment = this.html.deserialize(transfer.html);
|
const fragment = this.html.deserialize(transfer.html);
|
||||||
if (this.state.isRichTextEnabled) {
|
if (this.state.isRichTextEnabled) {
|
||||||
return change.insertFragment(fragment.document);
|
return change.insertFragment(fragment.document);
|
||||||
}
|
} else {
|
||||||
else {
|
return change.insertText(this.md.serialize(fragment));
|
||||||
return change.insertText(this.md.serialize(fragment));
|
}
|
||||||
}
|
}
|
||||||
|
case 'text':
|
||||||
|
return change.insertText(transfer.text);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue