diff --git a/web/platform/src/modules/chat/components/message/Markdown/index.less b/web/platform/src/modules/chat/components/message/Markdown/index.less deleted file mode 100644 index 5c54106..0000000 --- a/web/platform/src/modules/chat/components/message/Markdown/index.less +++ /dev/null @@ -1,82 +0,0 @@ -.chat-msg-md { - max-width: 100%; - - p { - font-size: 14px; - line-height: 22px; - } - - li { - line-height: 22px; - } - - a { - text-decoration: none; - color: #1677ff; - } - - & > *:last-child { - margin-bottom: 0; - } -} - -.chat-msg-md-content { - color: #878c93; -} - -.chat-msg-md-message { - .chat-msg-md-code-pre code { - padding: 0; - font-size: unset; - // width: 646px; - display: inline-block; - } - - code { - padding: 0.2em 0.4em; - margin: 0; - font-size: 85%; - background-color: rgba(27, 31, 35, 5%); - border-radius: 3px; - } - - table { - border-spacing: 0; - border-collapse: collapse; - } - - td, - th { - padding: 0; - } - - // table { - // margin-top: 0; - // margin-bottom: 16px; - // } - - .chat-msg-md-markdown-body table { - display: block; - width: 100%; - overflow: auto; - } - - table th { - font-weight: 600; - } - - table td, - table th { - padding: 6px 13px; - border: 1px solid #dfe2e5; - } - - table tr { - background-color: #fff; - border-top: 1px solid #c6cbd1; - } - - table tr:nth-child(2n) { - background-color: #f6f8fa; - } -} diff --git a/web/platform/src/modules/chat/components/message/Markdown/index.tsx b/web/platform/src/modules/chat/components/message/Markdown/index.tsx deleted file mode 100644 index e798db8..0000000 --- a/web/platform/src/modules/chat/components/message/Markdown/index.tsx +++ /dev/null @@ -1,128 +0,0 @@ -import { Modal } from 'antd'; -import classNames from 'classnames'; -import { useEffect, useState } from 'react'; -import ReactMarkdown from 'react-markdown'; -import { TransformComponent, TransformWrapper } from 'react-zoom-pan-pinch'; -import breaks from 'remark-breaks'; -import remarkGfm from 'remark-gfm'; - -import { CodeBlock } from './modules/CodeBlock/index.js'; -import './index.less'; - -// const PreBlock = (...args:any) => { -// console.log(args) -// return
pre
-// } - -interface MarkdownProps { - children: any; - className?: string; - type?: 'message' | 'content'; -} - -function ImageModal({ src, alt }: any) { - const [visible, setVisible] = useState(false); - const [imageDimensions, setImageDimensions] = useState({ - width: 0, - height: 0, - }); - - useEffect(() => { - const img = new Image(); - img.src = src; - img.onload = () => { - setImageDimensions({ - width: img.width, - height: img.height, - }); - }; - }, [src]); - - const maxModalWidth = window.innerWidth * 0.8; // 80% of the viewport width - const maxModalHeight = window.innerHeight * 0.8; // 80% of the viewport height - - let adjustedWidth, adjustedHeight; - - const aspectRatio = imageDimensions.width / imageDimensions.height; - - if (imageDimensions.width > maxModalWidth) { - adjustedWidth = maxModalWidth; - adjustedHeight = adjustedWidth / aspectRatio; - } else if (imageDimensions.height > maxModalHeight) { - adjustedHeight = maxModalHeight; - adjustedWidth = adjustedHeight * aspectRatio; - } else { - adjustedWidth = imageDimensions.width; - adjustedHeight = imageDimensions.height; - } - - return ( -
- {alt} setVisible(true)} - onLoad={() => { - // 解决生成图片没有滚动到最下方的问题。 - document.getElementById('chat-main-scroll')?.scrollIntoView(false); - }} - /> - setVisible(false)} - bodyStyle={{ - padding: 0, - display: 'flex', - justifyContent: 'center', - alignItems: 'center', - height: adjustedHeight, - }} - > - - - {alt} - - - -
- ); -} - -export const Markdown = (props: MarkdownProps) => { - const { type = 'message', className } = props; - - useEffect(() => { - const links = document.querySelectorAll('a'); - for (let i = 0, length = links.length; i < length; i++) { - if (links[i].hostname !== window.location.hostname) { - links[i].target = '_blank'; - } - } - }, [props.children]); - - return ( - - {props.children} - - ); -}; diff --git a/web/platform/src/modules/chat/components/message/Markdown/modules/CodeBlock/index.less b/web/platform/src/modules/chat/components/message/Markdown/modules/CodeBlock/index.less deleted file mode 100644 index 7ae4ba6..0000000 --- a/web/platform/src/modules/chat/components/message/Markdown/modules/CodeBlock/index.less +++ /dev/null @@ -1,42 +0,0 @@ -.chat-msg-md-code-pre { - :global { - .md-code-pre { - margin: 0 !important; - padding: 1.5em !important; - } - } -} - -.chat-msg-md-code-wrap { - border-radius: 4px; - position: relative; - margin: 0; -} - -.chat-msg-md-code-lang { - position: absolute; - top: 9px; - right: 28px; - color: #fff; - opacity: 0.8; - font-size: 14px; - line-height: 16px; -} - -.chat-msg-md-code-copy { - font-size: 16px; - cursor: pointer; - position: absolute; - top: 9px; - right: 4px; - color: #fff; - opacity: 0.8; - - &:hover { - opacity: 1; - } -} - -.chat-msg-md-code-code { - display: block; -} diff --git a/web/platform/src/modules/chat/components/message/Markdown/modules/CodeBlock/index.tsx b/web/platform/src/modules/chat/components/message/Markdown/modules/CodeBlock/index.tsx deleted file mode 100644 index 0c1aa13..0000000 --- a/web/platform/src/modules/chat/components/message/Markdown/modules/CodeBlock/index.tsx +++ /dev/null @@ -1,38 +0,0 @@ -/* eslint-disable react-hooks/rules-of-hooks */ -import { CopyOutlined } from '@ant-design/icons'; -import { message } from 'antd'; -import copy from 'copy-to-clipboard'; -import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; -import { oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism'; - -import './index.less'; - -export const CodeBlock = (props: any) => { - const { className, children } = props; - - if (!props.inline) { - const [, lang] = /language-(\w+)/.exec(className || '') || []; - - return ( -
-        {lang && 
{lang}
} - { - copy(children); - message.success('代码已复制'); - }} - className={`chat-msg-md-code-copy`} - /> - - {typeof children === 'string' ? children.trim() : children} - -
- ); - } - - return {children}; -}; diff --git a/web/platform/src/modules/chat/components/message/Text/index.less b/web/platform/src/modules/chat/components/message/Text/index.less deleted file mode 100644 index 7c41d71..0000000 --- a/web/platform/src/modules/chat/components/message/Text/index.less +++ /dev/null @@ -1,17 +0,0 @@ -.text-message-text { - min-height: 40px; - line-height: 22px; - // display: flex; - // align-items: center; - white-space: pre-wrap; - // flex: 1 1; - overflow: hidden; - max-width: 420px; -} - -.text-message-textPop { - display: inline-block; - background-color: #e6f4ff; - border-radius: 8px; - padding: 12px 16px; -} diff --git a/web/platform/src/modules/chat/components/message/Text/index.tsx b/web/platform/src/modules/chat/components/message/Text/index.tsx deleted file mode 100644 index a432283..0000000 --- a/web/platform/src/modules/chat/components/message/Text/index.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import './index.less'; - -export const TextMessage = ({ content }: any) => { - return ( -
- {content} -
- ); -};