diff --git a/plugins/chat/assets/javascripts/discourse/lib/simple-category-hash-mention-transform.js b/plugins/chat/assets/javascripts/discourse/lib/simple-category-hash-mention-transform.js deleted file mode 100644 index 37f85fb2c51..00000000000 --- a/plugins/chat/assets/javascripts/discourse/lib/simple-category-hash-mention-transform.js +++ /dev/null @@ -1,43 +0,0 @@ -import getURL from "discourse-common/lib/get-url"; - -const domParser = new DOMParser(); - -export default function transform(cooked, categories) { - let html = domParser.parseFromString(cooked, "text/html"); - transformMentions(html); - transformCategoryTagHashes(html, categories); - return html.body.innerHTML; -} - -function transformMentions(html) { - (html.querySelectorAll("span.mention") || []).forEach((mentionSpan) => { - let mentionLink = document.createElement("a"); - let mentionText = document.createTextNode(mentionSpan.innerText); - mentionLink.classList.add("mention"); - mentionLink.appendChild(mentionText); - mentionLink.href = getURL(`/u/${mentionSpan.innerText.substring(1)}`); - mentionSpan.parentNode.replaceChild(mentionLink, mentionSpan); - }); -} - -function transformCategoryTagHashes(html, categories) { - (html.querySelectorAll("span.hashtag") || []).forEach((hashSpan) => { - const categoryTagName = hashSpan.innerText.substring(1); - const matchingCategory = categories.find( - (category) => - category.name.toLowerCase() === categoryTagName.toLowerCase() - ); - const href = getURL( - matchingCategory - ? `/c/${matchingCategory.name}/${matchingCategory.id}` - : `/tag/${categoryTagName}` - ); - - let hashLink = document.createElement("a"); - let hashText = document.createTextNode(hashSpan.innerText); - hashLink.classList.add("hashtag"); - hashLink.appendChild(hashText); - hashLink.href = href; - hashSpan.parentNode.replaceChild(hashLink, hashSpan); - }); -} diff --git a/plugins/chat/assets/javascripts/discourse/models/chat-message.js b/plugins/chat/assets/javascripts/discourse/models/chat-message.js index 1cc2f2598fe..5c913750c19 100644 --- a/plugins/chat/assets/javascripts/discourse/models/chat-message.js +++ b/plugins/chat/assets/javascripts/discourse/models/chat-message.js @@ -5,7 +5,6 @@ import ChatMessageReaction from "discourse/plugins/chat/discourse/models/chat-me import Bookmark from "discourse/models/bookmark"; import I18n from "I18n"; import { generateCookFunction } from "discourse/lib/text"; -import simpleCategoryHashMentionTransform from "discourse/plugins/chat/discourse/lib/simple-category-hash-mention-transform"; import { getOwner } from "discourse-common/lib/get-owner"; import discourseLater from "discourse-common/lib/later"; @@ -192,10 +191,7 @@ export default class ChatMessage { } else { const cookFunction = await generateCookFunction(markdownOptions); ChatMessage.cookFunction = (raw) => { - return simpleCategoryHashMentionTransform( - cookFunction(raw), - site.categories - ); + return cookFunction(raw); }; this.cooked = ChatMessage.cookFunction(this.message);