From c1edc0c32e72307669291370458f343861b3173c Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 14 Oct 2017 19:40:45 +0100 Subject: [PATCH 1/2] add option to disable BigEmoji Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/HtmlUtils.js | 7 +++---- src/components/structures/UserSettings.js | 4 ++++ src/components/views/messages/TextualBody.js | 4 +++- src/i18n/strings/en_EN.json | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/HtmlUtils.js b/src/HtmlUtils.js index 5620bc06df..b8a1c63dfb 100644 --- a/src/HtmlUtils.js +++ b/src/HtmlUtils.js @@ -385,10 +385,9 @@ class TextHighlighter extends BaseHighlighter { * highlights: optional list of words to highlight, ordered by longest word first * * opts.highlightLink: optional href to add to highlighted words + * opts.disableBigEmoji: optional argument to disable the big emoji class. */ -export function bodyToHtml(content, highlights, opts) { - opts = opts || {}; - +export function bodyToHtml(content, highlights, opts={}) { const isHtml = (content.format === "org.matrix.custom.html"); const body = isHtml ? content.formatted_body : escape(content.body); @@ -418,7 +417,7 @@ export function bodyToHtml(content, highlights, opts) { } let emojiBody = false; - if (bodyHasEmoji) { + if (!opts.disableBigEmoji && bodyHasEmoji) { EMOJI_REGEX.lastIndex = 0; const contentBodyTrimmed = content.body !== undefined ? content.body.trim() : ''; const match = EMOJI_REGEX.exec(contentBodyTrimmed); diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index d83434f5a8..25960f5182 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -114,6 +114,10 @@ const SETTINGS_LABELS = [ id: 'Pill.shouldHidePillAvatar', label: _td('Hide avatars in user and room mentions'), }, + { + id: 'TextualBody.disableBigEmoji', + label: _td('Disable big emoji in chat'), + } /* { id: 'useFixedWidthFont', diff --git a/src/components/views/messages/TextualBody.js b/src/components/views/messages/TextualBody.js index c0468c38c2..64b23238e5 100644 --- a/src/components/views/messages/TextualBody.js +++ b/src/components/views/messages/TextualBody.js @@ -354,7 +354,9 @@ module.exports = React.createClass({ const mxEvent = this.props.mxEvent; const content = mxEvent.getContent(); - let body = HtmlUtils.bodyToHtml(content, this.props.highlights, {}); + let body = HtmlUtils.bodyToHtml(content, this.props.highlights, { + disableBigEmoji: UserSettingsStore.getSyncedSetting('TextualBody.disableBigEmoji', false), + }); if (this.props.highlightLink) { body = { body }; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index ed07e503ce..6f46fd3257 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -289,6 +289,7 @@ "matrix-react-sdk version:": "matrix-react-sdk version:", "Matrix Apps": "Matrix Apps", "Members only": "Members only", + "Disable big emoji in chat": "Disable big emoji in chat", "Disable Emoji suggestions while typing": "Disable Emoji suggestions while typing", "Message not sent due to unknown devices being present": "Message not sent due to unknown devices being present", "Missing room_id in request": "Missing room_id in request", From c7c28c7ad2e7cbebf805216441d889a85f592bb6 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 14 Oct 2017 19:53:08 +0100 Subject: [PATCH 2/2] make linter happy Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/UserSettings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 25960f5182..7e8dbeff76 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -117,7 +117,7 @@ const SETTINGS_LABELS = [ { id: 'TextualBody.disableBigEmoji', label: _td('Disable big emoji in chat'), - } + }, /* { id: 'useFixedWidthFont',