mirror of
https://git.zhongyuan.online/ytke/tap.git
synced 2026-11-24 22:15:18 -08:00
支持自部署需求管理、交付流程与飞书集成
This commit is contained in:
1 parent
4556a5b483
commit
e22b66d9dd
148 files changed
+8300
-6393
No files matched your search
@@ -0,0 +1,21 @@
|
||||
'use client';
|
||||
|
||||
import Markdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import { linkedDocument, type DocumentId } from '@/lib/documents';
|
||||
|
||||
export type TemplateDocumentProps = { text: string; onOpenDocument: (id: DocumentId) => void };
|
||||
|
||||
export default function TemplateDocument({ text, onOpenDocument }: TemplateDocumentProps) {
|
||||
return <article className="template-document"><Markdown remarkPlugins={[remarkGfm]} skipHtml components={{
|
||||
a: ({ href, children }) => {
|
||||
const related = linkedDocument(href || '');
|
||||
if (related) return <button type="button" className="template-inline-link" onClick={() => onOpenDocument(related.id)}>{children}</button>;
|
||||
if (!href || !/^https?:\/\//i.test(href)) return <span>{children}</span>;
|
||||
return <a href={href} target="_blank" rel="noopener noreferrer">{children}</a>;
|
||||
},
|
||||
img: ({ alt }) => <span>{alt ? `图片:${alt}` : '图片请查看原文档'}</span>,
|
||||
pre: ({ children }) => <div className="template-text-block">{children}</div>,
|
||||
table: ({ children }) => <div className="template-table-wrap"><table>{children}</table></div>,
|
||||
}}>{text}</Markdown></article>;
|
||||
}
|
||||
Reference in new issue
Block a user