import { createBlockConfig } from "@blocknote/core"; import { createReactBlockSpec } from "@blocknote/react"; import { MathBlockInputRulesExtension } from "./helpers/extensions/MathBlockInputRulesExtension.js"; import { parseBlockMathMLElement, parseBlockMathMLContent, } from "./helpers/parse/parseBlockMathMLElement.js"; import { MathBlockPreviewWithPopup } from "./helpers/render/MathBlockPreviewWithPopup.js"; import { BlockMathMLElement } from "./helpers/toExternalHTML/BlockMathMLElement.js"; export const createMathBlockConfig = createBlockConfig( () => ({ type: "mathBlock" as const, propSchema: {}, content: "plain" as const, }) as const, ); export type MathBlockConfig = ReturnType; export const createReactMathBlockSpec = createReactBlockSpec( createMathBlockConfig, { meta: { code: true, defining: true, isolating: false, highlight: () => "latex", hasPreview: true, hardBreakShortcut: "shift+enter", }, parse: parseBlockMathMLElement, parseContent: parseBlockMathMLContent, render: MathBlockPreviewWithPopup, toExternalHTML: BlockMathMLElement, }, [MathBlockInputRulesExtension], );