Add KaTeX copy-tex extension support for formula copying
This commit is contained in:
parent
aeaa0b32f9
commit
8f4bfbf1a3
2 changed files with 6 additions and 3 deletions
|
|
@ -76,13 +76,15 @@ export const ChatMessage = ({
|
||||||
? message.content
|
? message.content
|
||||||
: (displayContent !== undefined ? displayContent : (message.content || ''))
|
: (displayContent !== undefined ? displayContent : (message.content || ''))
|
||||||
|
|
||||||
// Load KaTeX dynamically with mhchem extension for chemistry formulas
|
// Load KaTeX dynamically with extensions
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadKaTeX = async () => {
|
const loadKaTeX = async () => {
|
||||||
try {
|
try {
|
||||||
// First load mhchem extension (must be loaded before rehype-katex)
|
// Load KaTeX extensions (must be loaded before rehype-katex)
|
||||||
// This enables \ce and \pu commands for chemistry formulas
|
// 1. mhchem: enables \ce and \pu commands for chemistry formulas
|
||||||
await import('katex/contrib/mhchem');
|
await import('katex/contrib/mhchem');
|
||||||
|
// 2. copy-tex: allows users to copy rendered formulas as LaTeX source code
|
||||||
|
await import('katex/contrib/copy-tex');
|
||||||
// Then load rehype-katex
|
// Then load rehype-katex
|
||||||
const { default: rehypeKatex } = await import('rehype-katex');
|
const { default: rehypeKatex } = await import('rehype-katex');
|
||||||
setKatexPlugin(() => rehypeKatex);
|
setKatexPlugin(() => rehypeKatex);
|
||||||
|
|
|
||||||
1
lightrag_webui/src/types/katex.d.ts
vendored
1
lightrag_webui/src/types/katex.d.ts
vendored
|
|
@ -1 +1,2 @@
|
||||||
declare module 'katex/contrib/mhchem';
|
declare module 'katex/contrib/mhchem';
|
||||||
|
declare module 'katex/contrib/copy-tex';
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue