|
|
|
@ -1,8 +1,17 @@
|
|
|
|
|
import { Problem } from '@/components/Problem';
|
|
|
|
|
import React from 'react';
|
|
|
|
|
import styled from 'styled-components';
|
|
|
|
|
import { isValidStr, t } from 'tailchat-shared';
|
|
|
|
|
import { DocumentMarkdownRender } from './DocumentMarkdownRender';
|
|
|
|
|
|
|
|
|
|
const DocumentIframe = styled.iframe`
|
|
|
|
|
.tc-modal & {
|
|
|
|
|
width: 60vw;
|
|
|
|
|
height: 70vh;
|
|
|
|
|
min-width: 100%;
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
interface DocumentViewProps {
|
|
|
|
|
documentUrl?: string;
|
|
|
|
|
}
|
|
|
|
@ -16,7 +25,7 @@ export const DocumentView: React.FC<DocumentViewProps> = React.memo((props) => {
|
|
|
|
|
if (documentUrl.endsWith('.md')) {
|
|
|
|
|
return <DocumentMarkdownRender url={documentUrl} />;
|
|
|
|
|
} else if (documentUrl.endsWith('.html') || documentUrl.startsWith('http')) {
|
|
|
|
|
return <iframe src={documentUrl} />;
|
|
|
|
|
return <DocumentIframe src={documentUrl} />;
|
|
|
|
|
} else {
|
|
|
|
|
return <Problem text={t('不支持渲染的文档链接')} />;
|
|
|
|
|
}
|
|
|
|
|