better-react-mathjax
Version:
Up-to-date component for using MathJax in latest React (using functional components and hooks API). Focuses on being versatile and making the use of MathJax in React a pleasant experience without flashes of non-typeset content, both with respect to initia
47 lines (46 loc) • 1.95 kB
TypeScript
import React, { FC, ReactNode } from "react";
import type { MathJax2Config, MathJax2Object } from "../MathJax2";
import type { MathJax3Config, MathJax3Object, OptionList as MathJax3OptionList } from "../MathJax3";
import type { MathJax4Config, MathJax4Object, OptionList as MathJax4OptionList } from "../MathJax4";
export type TypesettingFunction = "tex2chtml" | "tex2chtmlPromise" | "tex2svg" | "tex2svgPromise" | "tex2mml" | "tex2mmlPromise" | "mathml2chtml" | "mathml2chtmlPromise" | "mathml2svg" | "mathml2svgPromise" | "mathml2mml" | "mathml2mmlPromise" | "asciimath2chtml" | "asciimath2chtmlPromise" | "asciimath2svg" | "asciimath2svgPromise" | "asciimath2mml" | "asciimath2mmlPromise";
export interface MathJaxOverrideableProps {
hideUntilTypeset?: "first" | "every";
typesettingOptions?: {
fn: TypesettingFunction;
options?: Omit<MathJax3OptionList | MathJax4OptionList, "display">;
};
renderMode?: "pre" | "post";
}
export type MathJaxSubscriberProps = ({
version: 2;
promise: Promise<MathJax2Object>;
} | {
version: 3;
promise: Promise<MathJax3Object>;
} | {
version: 4;
promise: Promise<MathJax4Object>;
}) & MathJaxOverrideableProps;
export declare const MathJaxBaseContext: React.Context<MathJaxSubscriberProps | undefined>;
interface MathJaxContextStaticProps extends MathJaxOverrideableProps {
src?: string;
asyncLoad?: boolean;
onLoad?: () => void;
onError?: (error: any) => void;
children?: ReactNode;
}
export type MathJaxContextProps = ({
config?: MathJax2Config;
version: 2;
onStartup?: (mathJax: MathJax2Object) => void;
} | {
config?: MathJax3Config;
version?: 3;
onStartup?: (mathJax: MathJax3Object) => void;
} | {
config?: MathJax4Config;
version?: 4;
onStartup?: (mathJax: MathJax4Object) => void;
}) & MathJaxContextStaticProps;
declare const MathJaxContext: FC<MathJaxContextProps>;
export default MathJaxContext;