/** * Shared MathLive typesetting helpers. * * LaTeX is the single source of truth for in-text math. It is carried on a * canonical wrapper element: * * …markup… * * The inner markup is MathLive's `convertLatexToMarkup` output, preserved in the * stored HTML so the static render paths (`v-html`) and ProseMirror round-trips * never need to re-typeset existing content. MathLive (JS + `static.css` + * `fonts.css`) is lazy-loaded the first time math actually appears or an editor * opens, so decks without math never pull it into the bundle. */ export { MATH_CLASS, estimateInlineMathBox, htmlHasFikaMath, isPlausibleInlineMathBox } from './inlineMathBox'; type ConvertLatexToMarkup = (latex: string, options?: { defaultMode?: 'inline-math' | 'math' | 'text'; }) => string; type ConvertLatexToMathMl = (latex: string, options?: { generateID?: boolean; }) => string; interface MathliveModule { convertLatexToMarkup: ConvertLatexToMarkup; convertLatexToMathMl: ConvertLatexToMathMl; initVirtualKeyboardInCurrentBrowsingContext?: () => void; MathfieldElement: { fontsDirectory: string | null; soundsDirectory: string | null; stylesheetScope: string | null; }; } /** * MathLive's default keyboard container is `document.body`. When shown it * writes `padding-bottom` onto the body so page content scrolls above the * keys. Fika's canvas is `height: 100%` of that body, so the padding * shrinks the slide and the viewport observer refits it smaller. * * Dock the keyboard in a host that spans the portal (the Fika root) instead — * MathLive skips the padding whenever `container !== document.body`, and its * custom-container rules stack the keys at the host's bottom edge. */ export declare function dockMathVirtualKeyboard(): void; /** * Reactive flag flipped to `true` once MathLive has loaded. Reading it inside a * render (e.g. table `formatText`) registers a dependency so the math re-renders * the moment the engine becomes available. */ export declare const mathReady: { value: boolean; }; /** Lazily import MathLive and configure it for a bundled (offline) font setup. */ export declare function ensureMathliveReady(): Promise; /** * Recover LaTeX that passed through XML/HTML entity encoding. * `entities.decodeXML` turns `<` into `<`. A leftover `\<` is the * `<` → `\<` → HTML-decode artifact, not a TeX control sequence. */ export declare function normalizeImportedLatex(latex: string): string; /** Escape a string for safe inclusion in a double-quoted HTML attribute. */ export declare function escapeLatexAttr(latex: string): string; /** * Render `latex` to the canonical `span.fika-math` wrapper HTML string. Must * only be called once {@link ensureMathliveReady} has resolved (the markdown * pipeline and editor await it; tables fall back to literal source until ready). */ export declare function renderMathToHtml(latex: string, display?: boolean): string; /** * Build a real `span.fika-math` DOM node for the given latex/markup. Used by * the ProseMirror schema `toDOM` so the editor DOM (and the innerHTML persisted * on edit) is the same canonical wrapper the parser reads back. */ export declare function buildMathElement(latex: string, html: string, display?: boolean): HTMLSpanElement; /** Engine adapter that lets `markdown-it-texmath` typeset via MathLive. */ export declare const texmathEngine: { renderToString(latex: string, options?: { displayMode?: boolean; }): string; }; /** * Sync MathML conversion — only valid after {@link ensureMathliveReady} has resolved. * Throws if MathLive is not loaded yet. */ export declare function convertLatexToMathMlSync(latex: string): string; /** Unscaled font-size used when measuring and painting standalone formula elements. */ export declare const LATEX_ELEMENT_FONT_SIZE = 36; /** * Typeset a standalone formula element. Same MathLive/KaTeX-font pipeline as * inline math — not the old hfmath stroke paths. */ export declare function renderLatexElementHtml(latex: string): string; /** * Sync natural box of inline/display math at `fontSize`. Returns null until * MathLive can typeset; callers should fall back to {@link estimateInlineMathBox}. */ export declare function measureInlineMathBox(latex: string, fontSize: number, display?: boolean): { width: number; height: number; } | null; /** Measured box when MathLive is ready, otherwise a conservative estimate. */ export declare function inlineMathBox(latex: string, fontSize: number, display?: boolean): { width: number; height: number; }; /** Natural box of a formula at {@link LATEX_ELEMENT_FONT_SIZE}, plus padding. */ export declare function measureLatexElement(latex: string): Promise<{ width: number; height: number; }>; /** True when an HTML string already contains rendered/wrapped math. */ export declare function htmlContainsMath(html: string): boolean; /** True when a stored deck needs MathLive CSS to paint stacked fractions. */ export declare function deckHasMath(slides: ReadonlyArray<{ elements?: ReadonlyArray; }>): boolean; /** Load MathLive CSS/fonts when the deck already has typeset math. */ export declare function ensureMathStylesForSlides(slides: ReadonlyArray<{ elements?: ReadonlyArray; }>): void;