diff --git a/src/components/views/messages/TextualBody.js b/src/components/views/messages/TextualBody.js index 1899e8428a..4c41cbe669 100644 --- a/src/components/views/messages/TextualBody.js +++ b/src/components/views/messages/TextualBody.js @@ -202,7 +202,9 @@ module.exports = React.createClass({ // update the current node with one that's now taken its place node = pillContainer; - } else if (this.props.tileShape !== 'quote' && Quote.isMessageUrl(href)) { + } else if (SettingsStore.isFeatureEnabled("feature_rich_quoting") && this.props.tileShape !== 'quote' && + Quote.isMessageUrl(href) + ) { // only allow this branch if we're not already in a quote, as fun as infinite nesting is. const quoteContainer = document.createElement('span'); diff --git a/src/components/views/rooms/MessageComposerInput.js b/src/components/views/rooms/MessageComposerInput.js index ad7e81ccb1..3305ba7994 100644 --- a/src/components/views/rooms/MessageComposerInput.js +++ b/src/components/views/rooms/MessageComposerInput.js @@ -297,6 +297,36 @@ export default class MessageComposerInput extends React.Component { }); } break; + + case 'quote': { // old quoting, whilst rich quoting is in labs + /// XXX: Not doing rich-text quoting from formatted-body because draft-js + /// has regressed such that when links are quoted, errors are thrown. See + /// https://github.com/vector-im/riot-web/issues/4756. + const body = escape(payload.text); + if (body) { + let content = RichText.htmlToContentState(`
${body}`); + if (!this.state.isRichtextEnabled) { + content = ContentState.createFromText(RichText.stateToMarkdown(content)); + } + + const blockMap = content.getBlockMap(); + let startSelection = SelectionState.createEmpty(contentState.getFirstBlock().getKey()); + contentState = Modifier.splitBlock(contentState, startSelection); + startSelection = SelectionState.createEmpty(contentState.getFirstBlock().getKey()); + contentState = Modifier.replaceWithFragment(contentState, + startSelection, + blockMap); + startSelection = SelectionState.createEmpty(contentState.getFirstBlock().getKey()); + if (this.state.isRichtextEnabled) { + contentState = Modifier.setBlockType(contentState, startSelection, 'blockquote'); + } + let editorState = EditorState.push(this.state.editorState, contentState, 'insert-characters'); + editorState = EditorState.moveSelectionToEnd(editorState); + this.onEditorContentChanged(editorState); + editor.focus(); + } + } + break; } }; @@ -1146,7 +1176,7 @@ export default class MessageComposerInput extends React.Component { return (