From fcd8321a63c0525b11b264ebc995f8dcaf028765 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 6 Jul 2017 13:49:13 +0100 Subject: [PATCH] Allow underline through MD and in RTE (MD) using which works with CM Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/Markdown.js | 2 +- src/components/views/rooms/MessageComposer.js | 9 ++------- src/components/views/rooms/MessageComposerInput.js | 4 ++-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Markdown.js b/src/Markdown.js index 4a46ce4f24..5730e42a09 100644 --- a/src/Markdown.js +++ b/src/Markdown.js @@ -17,7 +17,7 @@ limitations under the License. import commonmark from 'commonmark'; import escape from 'lodash/escape'; -const ALLOWED_HTML_TAGS = ['del']; +const ALLOWED_HTML_TAGS = ['del', 'u']; // These types of node are definitely text const TEXT_NODES = ['text', 'softbreak', 'linebreak', 'paragraph', 'document']; diff --git a/src/components/views/rooms/MessageComposer.js b/src/components/views/rooms/MessageComposer.js index c83e32d9a8..27d5e11119 100644 --- a/src/components/views/rooms/MessageComposer.js +++ b/src/components/views/rooms/MessageComposer.js @@ -21,7 +21,6 @@ import Modal from '../../../Modal'; import sdk from '../../../index'; import dis from '../../../dispatcher'; import Autocomplete from './Autocomplete'; -import classNames from 'classnames'; import UserSettingsStore from '../../../UserSettingsStore'; @@ -408,14 +407,10 @@ export default class MessageComposer extends React.Component { const active = style.includes(name) || blockType === name; const suffix = active ? '-o-n' : ''; const onFormatButtonClicked = this.onFormatButtonClicked.bind(this, name); - const disabled = !this.state.inputState.isRichtextEnabled && 'underline' === name; - const className = classNames("mx_MessageComposer_format_button", { - mx_MessageComposer_format_button_disabled: disabled, - mx_filterFlipColor: true, - }); + const className = 'mx_MessageComposer_format_button mx_filterFlipColor'; return ; diff --git a/src/components/views/rooms/MessageComposerInput.js b/src/components/views/rooms/MessageComposerInput.js index 294cbdb84c..9be797e8c0 100644 --- a/src/components/views/rooms/MessageComposerInput.js +++ b/src/components/views/rooms/MessageComposerInput.js @@ -408,7 +408,7 @@ export default class MessageComposerInput extends React.Component { const modifyFn = { 'bold': (text) => `**${text}**`, 'italic': (text) => `*${text}*`, - 'underline': (text) => `_${text}_`, // there's actually no valid underline in Markdown, but *shrug* + 'underline': (text) => `${text}`, 'strike': (text) => `${text}`, 'code-block': (text) => `\`\`\`\n${text}\n\`\`\`\n`, 'blockquote': (text) => text.split('\n').map((line) => `> ${line}\n`).join('') + '\n', @@ -419,7 +419,7 @@ export default class MessageComposerInput extends React.Component { const selectionAfterOffset = { 'bold': -2, 'italic': -1, - 'underline': -1, + 'underline': -4, 'strike': -6, 'code-block': -5, 'blockquote': -2,