From f6318be6523433a83ef2374875c994c636a2dc41 Mon Sep 17 00:00:00 2001 From: Kyle Maas Date: Mon, 14 Nov 2022 01:23:22 +0000 Subject: [PATCH] Reformat media descriptions which include links to make them clickable --- .../static/js/components/media-page/ViewerInfoContent.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/static/js/components/media-page/ViewerInfoContent.js b/frontend/src/static/js/components/media-page/ViewerInfoContent.js index 28360a1..02c28b1 100755 --- a/frontend/src/static/js/components/media-page/ViewerInfoContent.js +++ b/frontend/src/static/js/components/media-page/ViewerInfoContent.js @@ -100,6 +100,10 @@ export default function ViewerInfoContent(props) { const { userCan } = useUser(); const description = props.description.trim(); + const encoder = document.createElement("div"); + encoder.appendChild(document.createTextNode(description)); + const descriptionHTML = encoder.innerHTML; + const descriptionHTMLWithLinks = descriptionHTML.replace(/http(s?):\/\/[^\s]+/g, (match) => { return "" + match + "" }); const tagsContent = !PageStore.get('config-enabled').taxonomies.tags || PageStore.get('config-enabled').taxonomies.tags.enabled ? metafield(MediaPageStore.get('media-tags')) @@ -186,7 +190,7 @@ export default function ViewerInfoContent(props) { PageStore.get('config-options').pages.media.htmlInDescription ? (
) : ( -
{description}
+
) ) : null} {hasSummary ? (