hide rich quoting behind flags, retaining original quoting for now

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2017-12-12 23:29:43 +00:00
parent 38e8488c2a
commit 4666ac7c83
No known key found for this signature in database
GPG key ID: 3F879DA5AD802A5E
3 changed files with 40 additions and 2 deletions

View file

@ -202,7 +202,9 @@ module.exports = React.createClass({
// update the current node with one that's now taken its place // update the current node with one that's now taken its place
node = pillContainer; 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. // only allow this branch if we're not already in a quote, as fun as infinite nesting is.
const quoteContainer = document.createElement('span'); const quoteContainer = document.createElement('span');

View file

@ -297,6 +297,36 @@ export default class MessageComposerInput extends React.Component {
}); });
} }
break; 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(`<blockquote>${body}</blockquote>`);
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 ( return (
<div className="mx_MessageComposer_input_wrapper"> <div className="mx_MessageComposer_input_wrapper">
<div className="mx_MessageComposer_autocomplete_wrapper"> <div className="mx_MessageComposer_autocomplete_wrapper">
<QuotePreview /> { SettingsStore.isFeatureEnabled("feature_rich_quoting") && <QuotePreview /> }
<Autocomplete <Autocomplete
ref={(e) => this.autocomplete = e} ref={(e) => this.autocomplete = e}
room={this.props.room} room={this.props.room}

View file

@ -76,6 +76,12 @@ export const SETTINGS = {
// // level is always appended to the end. // // level is always appended to the end.
// supportedLevelsAreOrdered: false, // supportedLevelsAreOrdered: false,
// }, // },
"feature_rich_quoting": {
isFeature: true,
displayName: _td("Rich Quoting"),
supportedLevels: LEVELS_FEATURE,
default: false,
},
"feature_pinning": { "feature_pinning": {
isFeature: true, isFeature: true,
displayName: _td("Message Pinning"), displayName: _td("Message Pinning"),