Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
fix pasting of plaintext content (prevent loads of <p>s) Fixes elemen…
Browse files Browse the repository at this point in the history
…t-hq/element-web#7043

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
  • Loading branch information
t3chguy committed Jul 17, 2018
1 parent 4149086 commit 1b467f6
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/components/views/rooms/MessageComposerInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -970,19 +970,21 @@ export default class MessageComposerInput extends React.Component {
onPaste = (event: Event, change: Change, editor: Editor): Change => {
const transfer = getEventTransfer(event);

if (transfer.type === "files") {
return this.props.onFilesPasted(transfer.files);
}
else if (transfer.type === "html") {
// FIXME: https://github.com/ianstormtaylor/slate/issues/1497 means
// that we will silently discard nested blocks (e.g. nested lists) :(
const fragment = this.html.deserialize(transfer.html);
if (this.state.isRichTextEnabled) {
return change.insertFragment(fragment.document);
}
else {
return change.insertText(this.md.serialize(fragment));
switch (transfer.type) {
case 'files':
return this.props.onFilesPasted(transfer.files);
case 'html': {
// FIXME: https://github.com/ianstormtaylor/slate/issues/1497 means
// that we will silently discard nested blocks (e.g. nested lists) :(
const fragment = this.html.deserialize(transfer.html);
if (this.state.isRichTextEnabled) {
return change.insertFragment(fragment.document);
} else {
return change.insertText(this.md.serialize(fragment));
}
}
case 'text':
return change.insertText(transfer.text);
}
};

Expand Down

0 comments on commit 1b467f6

Please sign in to comment.