feat: markdown msg in widget

This commit is contained in:
Tristan Yang
2023-12-05 09:55:46 +08:00
parent eb53322bbc
commit 82330250a8
6 changed files with 216 additions and 247 deletions
+2 -1
View File
@@ -98,9 +98,10 @@ const Login = () => {
{/* input email as username */}
<Input required placeholder="Email" type="email" name="username" />
<StyledButton
style={{ backgroundColor: color, color: fgColor }}
disabled={isLoading}
type="submit"
className={clsx("small", `bg-[${color}] text-[${fgColor}]`)}
className={clsx("small")}
>
{t("start_chat")}
</StyledButton>
+15
View File
@@ -0,0 +1,15 @@
// import React from 'react';
// import clsx from "clsx";
// import { useWidget } from "../../WidgetContext";
import MarkdownRender from "@/components/MarkdownRender";
type Props = {
content: string;
};
const Markdown = ({ content }: Props) => {
return <MarkdownRender content={content} />;
};
export default Markdown;
+6 -2
View File
@@ -1,5 +1,4 @@
import { memo } from "react";
import clsx from "clsx";
import dayjs from "dayjs";
import localizedFormat from "dayjs/plugin/localizedFormat";
@@ -8,6 +7,8 @@ import Text from "./Text";
import Image from "./Image";
import { ContentType } from "@/types/message";
import { shallowEqual } from "react-redux";
import Markdown from "./Markdown";
import { cn } from "@/utils";
dayjs.extend(localizedFormat);
@@ -41,6 +42,9 @@ const Index = (props: IWidgetMessage) => {
case "text/plain":
contentContainer = <Text sending={sending} content={content} host={host} uid={uid} />;
break;
case "text/markdown":
contentContainer = <Markdown content={content} />;
break;
case "vocechat/file":
{
console.log("image file", content);
@@ -54,7 +58,7 @@ const Index = (props: IWidgetMessage) => {
}
return (
<div
className={clsx(
className={cn(
"group flex mb-3",
host ? "relative justify-start items-start" : "items-center justify-end px-3"
)}