@lobehub/ui
Version:
Lobe UI is an open-source UI component library for building AIGC web apps
1 lines • 1.93 kB
Source Map (JSON)
{"version":3,"file":"useMarkdownRehypePlugins.mjs","names":[],"sources":["../../../src/hooks/useMarkdown/useMarkdownRehypePlugins.ts"],"sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\nimport { rehypeGithubAlerts } from 'rehype-github-alerts';\nimport rehypeKatex from 'rehype-katex';\nimport rehypeRaw from 'rehype-raw';\nimport type { Pluggable } from 'unified';\n\nimport { useMarkdownContext } from '@/Markdown/components/MarkdownProvider';\nimport { rehypeCustomFootnotes } from '@/Markdown/plugins/rehypeCustomFootnotes';\nimport { rehypeKatexDir } from '@/Markdown/plugins/rehypeKatexDir';\nimport { rehypeStreamAnimated } from '@/Markdown/plugins/rehypeStreamAnimated';\n\nexport const useMarkdownRehypePlugins = (): Pluggable[] => {\n const {\n animated,\n enableLatex,\n enableCustomFootnotes,\n enableGithubAlert,\n allowHtml,\n rehypePlugins = [],\n rehypePluginsAhead = [],\n } = useMarkdownContext();\n\n const memoPlugins = useMemo(\n () =>\n [\n allowHtml && rehypeRaw,\n enableGithubAlert && rehypeGithubAlerts,\n enableLatex && rehypeKatex,\n enableLatex && rehypeKatexDir,\n enableCustomFootnotes && rehypeCustomFootnotes,\n animated && rehypeStreamAnimated,\n ].filter(Boolean) as Pluggable[],\n [animated, enableLatex, enableGithubAlert, enableCustomFootnotes, allowHtml],\n );\n\n return useMemo(\n () => [...rehypePluginsAhead, ...memoPlugins, ...rehypePlugins],\n [rehypePlugins, memoPlugins, rehypePluginsAhead],\n );\n};\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,iCAA8C;CACzD,MAAM,EACJ,UACA,aACA,uBACA,mBACA,WACA,gBAAgB,EAAE,EAClB,qBAAqB,EAAE,KACrB,oBAAoB;CAExB,MAAM,cAAc,cAEhB;EACE,aAAa;EACb,qBAAqB;EACrB,eAAe;EACf,eAAe;EACf,yBAAyB;EACzB,YAAY;EACb,CAAC,OAAO,QAAQ,EACnB;EAAC;EAAU;EAAa;EAAmB;EAAuB;EAAU,CAC7E;AAED,QAAO,cACC;EAAC,GAAG;EAAoB,GAAG;EAAa,GAAG;EAAc,EAC/D;EAAC;EAAe;EAAa;EAAmB,CACjD"}