mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 07:49:25 +08:00
Add rich text and learning blocks, media uploads, page trees, and revisioned notebook storage. Present AI suggestions at their target blocks with durable accept and dismiss actions. Unify saved outputs as Favorites with typed expandable blocks, stable source links, atomic batch insertion, nesting, dragging, and undo/redo. Validation: 99 frontend tests and 99 backend tests pass in an isolated snapshot, along with TypeScript, scoped ESLint, dependency architecture, and locale parity checks.
35 lines
803 B
TypeScript
35 lines
803 B
TypeScript
'use client'
|
|
|
|
import { useMemo } from 'react'
|
|
import katex from 'katex'
|
|
import 'katex/dist/katex.min.css'
|
|
|
|
// Math nodes already contain LaTeX, not Markdown. Keeping the mode explicit also
|
|
// prevents a lone inline formula from being normalized into a display paragraph.
|
|
export default function NoteMath({
|
|
formula,
|
|
display = false,
|
|
}: {
|
|
formula: string
|
|
display?: boolean
|
|
}) {
|
|
const html = useMemo(
|
|
() =>
|
|
katex.renderToString(formula, {
|
|
displayMode: display,
|
|
throwOnError: false,
|
|
trust: false,
|
|
strict: 'ignore',
|
|
maxExpand: 1000,
|
|
maxSize: 20,
|
|
}),
|
|
[formula, display]
|
|
)
|
|
return (
|
|
<span
|
|
className={display ? 'dt-note-formula display' : 'dt-note-formula'}
|
|
dangerouslySetInnerHTML={{ __html: html }}
|
|
/>
|
|
)
|
|
}
|