UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

42 lines (39 loc) 1.4 kB
'use client'; import { useMarkdownContext } from "../../Markdown/components/MarkdownProvider.mjs"; import { rehypeCustomFootnotes } from "../../Markdown/plugins/rehypeCustomFootnotes.mjs"; import { rehypeKatexDir } from "../../Markdown/plugins/rehypeKatexDir.mjs"; import { rehypeStreamAnimated } from "../../Markdown/plugins/rehypeStreamAnimated.mjs"; import { useMemo } from "react"; import { rehypeGithubAlerts } from "rehype-github-alerts"; import rehypeKatex from "rehype-katex"; import rehypeRaw from "rehype-raw"; //#region src/hooks/useMarkdown/useMarkdownRehypePlugins.ts const useMarkdownRehypePlugins = () => { const { animated, enableLatex, enableCustomFootnotes, enableGithubAlert, allowHtml, rehypePlugins = [], rehypePluginsAhead = [] } = useMarkdownContext(); const memoPlugins = useMemo(() => [ allowHtml && rehypeRaw, enableGithubAlert && rehypeGithubAlerts, enableLatex && rehypeKatex, enableLatex && rehypeKatexDir, enableCustomFootnotes && rehypeCustomFootnotes, animated && rehypeStreamAnimated ].filter(Boolean), [ animated, enableLatex, enableGithubAlert, enableCustomFootnotes, allowHtml ]); return useMemo(() => [ ...rehypePluginsAhead, ...memoPlugins, ...rehypePlugins ], [ rehypePlugins, memoPlugins, rehypePluginsAhead ]); }; //#endregion export { useMarkdownRehypePlugins }; //# sourceMappingURL=useMarkdownRehypePlugins.mjs.map