The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/app/colors/client/client.js

17 lines
502 B

import './style.css';
export const createHexColorPreviewMessageRenderer = () => (message) => {
if (!message.html?.trim()) {
return message;
}
const regex = /(?:^|\s|\n)(#[A-Fa-f0-9]{3}([A-Fa-f0-9]{3})?)\b/g;
message.html = message.html.replace(regex, (match, completeColor) =>
match.replace(
completeColor,
`<div class="message-color"><div class="message-color-sample" style="background-color:${completeColor}"></div>${completeColor.toUpperCase()}</div>`,
),
);
return message;
};