Skip to content

Commit

Permalink
Simpler function name
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewPrigorshnev committed Aug 22, 2023
1 parent 1ddca74 commit b08ca91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Expand Up @@ -2,13 +2,13 @@ import getURL from "discourse-common/lib/get-url";

const domParser = new DOMParser();

export default function transform(cooked) {
export default function transformMentions(cooked) {
const html = domParser.parseFromString(cooked, "text/html");
transformMentions(html);
transform(html);
return html.body.innerHTML;
}

function transformMentions(html) {
function transform(html) {
(html.querySelectorAll("span.mention") || []).forEach((mentionSpan) => {
let mentionLink = document.createElement("a");
let mentionText = document.createTextNode(mentionSpan.innerText);
Expand Down
Expand Up @@ -5,7 +5,7 @@ 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 transformMentions from "discourse/plugins/chat/discourse/lib/transform-mentions";
import { getOwner } from "discourse-common/lib/get-owner";
import discourseLater from "discourse-common/lib/later";

Expand Down Expand Up @@ -192,7 +192,7 @@ export default class ChatMessage {
} else {
const cookFunction = await generateCookFunction(markdownOptions);
ChatMessage.cookFunction = (raw) => {
return simpleCategoryHashMentionTransform(cookFunction(raw));
return transformMentions(cookFunction(raw));
};

this.cooked = ChatMessage.cookFunction(this.message);
Expand Down

0 comments on commit b08ca91

Please sign in to comment.