diff --git a/src/react-components/chat-message.js b/src/react-components/chat-message.js index e9de62640e..7b9950277b 100644 --- a/src/react-components/chat-message.js +++ b/src/react-components/chat-message.js @@ -41,7 +41,16 @@ const messageBodyDom = (body, from, fromSessionId, onViewProfile, emojiClassName return { content, multiline, emoji }; }; +const bubbleColorRegEx = /^.*\s?(-color=)(#?[0-9a-fA-Z]{6}|[0-9a-fA-Z]{3})\s?.*$/; function renderChatMessage(body, from, allowEmojiRender) { + const matches = body.match(bubbleColorRegEx); + let bubbleColor; + if (matches) { + matches.shift(); + bubbleColor = matches[1]; + body = matches.reduce((acc, cur) => acc.replace(cur, ""), body); + } + const { content, emoji, multiline } = messageBodyDom(body, from, null, null, styles.emoji); const isEmoji = allowEmojiRender && emoji; const el = document.createElement("div"); @@ -55,6 +64,7 @@ function renderChatMessage(body, from, allowEmojiRender) { [styles.presenceLogEntryOneLine]: !isEmoji && !multiline, [styles.presenceLogEmoji]: isEmoji })} + style={{ backgroundColor: `${bubbleColor}` }} > {content}