fix: replying message render with mention

This commit is contained in:
zerosoul
2022-05-18 22:17:21 +08:00
parent 8cd7e73942
commit 202855559c
+11 -1
View File
@@ -1,5 +1,7 @@
// import React from 'react'
import { useDispatch, useSelector } from "react-redux";
import reactStringReplace from "react-string-replace";
import Mention from "../Message/Mention";
import { ContentTypes } from "../../../app/config";
import MrakdownRender from "../MrakdownRender";
import closeIcon from "../../../assets/icons/close.circle.svg?url";
@@ -84,7 +86,15 @@ const renderContent = (data) => {
let res = null;
switch (content_type) {
case ContentTypes.text:
res = content;
res = reactStringReplace(
content,
/(\s{1}@[0-9]+\s{1})/g,
(match, idx) => {
console.log("match", match);
const uid = match.trim().slice(1);
return <Mention popover={false} key={idx} uid={uid} />;
}
);
break;
case ContentTypes.markdown:
res = (