Chats: make links open in a new tab, fixes #371

better-thread-display
Alex Gleason 2020-09-01 00:23:40 -05:00
rodzic eec61b957b
commit 70bd26526b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 11 dodań i 0 usunięć

Wyświetl plik

@ -56,6 +56,16 @@ class ChatMessageList extends ImmutablePureComponent {
);
};
setRef = (c) => {
const links = c.querySelectorAll('a[rel="ugc"]');
links.forEach(link => {
link.classList.add('chat-link');
link.setAttribute('rel', 'ugc nofollow noopener');
link.setAttribute('target', '_blank');
});
}
componentDidUpdate(prevProps) {
if (prevProps.chatMessages !== this.props.chatMessages)
this.scrollToBottom();
@ -78,6 +88,7 @@ class ChatMessageList extends ImmutablePureComponent {
title={this.getFormattedTimestamp(chatMessage)}
className='chat-message__bubble'
dangerouslySetInnerHTML={{ __html: emojify(chatMessage.get('content') || '') }}
ref={this.setRef}
/>
</div>
))}