feat: mentions #56

Merged
verbiricha merged 8 commits from mentions into main 2023-01-15 09:59:08 +00:00
Showing only changes of commit fa3793362c - Show all commits

View File

@ -12,6 +12,7 @@ import './Text.css'
import { useMemo } from "react"; import { useMemo } from "react";
function transformHttpLink(a) { function transformHttpLink(a) {
try {
const url = new URL(a); const url = new URL(a);
const youtubeId = YoutubeUrlRegex.test(a) && RegExp.$1; const youtubeId = YoutubeUrlRegex.test(a) && RegExp.$1;
const tweetId = TweetUrlRegex.test(a) && RegExp.$2; const tweetId = TweetUrlRegex.test(a) && RegExp.$2;
@ -38,7 +39,7 @@ function transformHttpLink(a) {
} }
} else if (tweetId) { } else if (tweetId) {
return ( return (
<div className="tweet"> <div className="tweet" key={tweetId}>
<TwitterTweetEmbed tweetId={tweetId} /> <TwitterTweetEmbed tweetId={tweetId} />
</div> </div>
) )
@ -50,6 +51,7 @@ function transformHttpLink(a) {
className="w-max" className="w-max"
src={`https://www.youtube.com/embed/${youtubeId}`} src={`https://www.youtube.com/embed/${youtubeId}`}
title="YouTube video player" title="YouTube video player"
key={youtubeId}
frameBorder="0" frameBorder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowFullScreen="" allowFullScreen=""
@ -60,6 +62,8 @@ function transformHttpLink(a) {
} else { } else {
return <a href={a} onClick={(e) => e.stopPropagation()}>{a}</a> return <a href={a} onClick={(e) => e.stopPropagation()}>{a}</a>
} }
} catch (error) {
}
return <a href={a} onClick={(e) => e.stopPropagation()}>{a}</a> return <a href={a} onClick={(e) => e.stopPropagation()}>{a}</a>
} }