UNPKG

ds-markdown

Version:

> 🚀 React Markdown 打字动画组件,提供现代聊天界面效果

32 lines 1.09 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { createContext, useContext, useMemo } from 'react'; import defaultLocale from '../../i18n/zh/index.js'; const ConfigContext = createContext({ locale: defaultLocale, }); export const ConfigProvider = ({ locale, children, mermaidConfig, katexConfig }) => { const contextValue = useMemo(() => { const contextValue = { locale: locale || defaultLocale, }; if (mermaidConfig) { contextValue.mermaidConfig = mermaidConfig; } if (katexConfig) { contextValue.katexConfig = katexConfig; } return contextValue; }, [locale, mermaidConfig, katexConfig]); return _jsx(ConfigContext.Provider, { value: contextValue, children: children }); }; // Hook 用于在组件中使用配置 export const useConfig = () => { const context = useContext(ConfigContext); return context; }; // Hook 用于获取当前语言包 export const useLocale = () => { const { locale } = useConfig(); return locale; }; //# sourceMappingURL=index.js.map