import React from "react"; import type * as std from "../../law/std"; import type { HTMLComponentProps } from "../common/html"; import { elProps, wrapHTMLComponent } from "../common/html"; import type { DOCXComponentProps } from "../common/docx/component"; import { wrapDOCXComponent } from "../common/docx/component"; import { w } from "../common/docx/tags"; import { DOCXAnyELsToBlocks, HTMLAnyELsToBlocks } from "./any"; import TextBoxRun from "../common/docx/TextBoxRun"; import { withKey } from "../common"; export interface ArithFormulaRunProps { el: std.ArithFormula, } export const HTMLArithFormulaRunCSS = /*css*/` `; export const HTMLArithFormulaRun = wrapHTMLComponent("HTMLArithFormulaRun", ((props: HTMLComponentProps & ArithFormulaRunProps) => { const { el, htmlOptions } = props; const rawBlocks = HTMLAnyELsToBlocks({ els: el.children, indent: 0, htmlOptions, }); if (rawBlocks.every(Array.isArray)) { const runs = (rawBlocks as React.JSX.Element[][]).flat(); return (( {withKey(runs)} )); } else { const blocks: React.JSX.Element[] = []; for (const rawBlock of rawBlocks) { if (Array.isArray(rawBlock)) { blocks.push((
{withKey(rawBlock)}
)); } else { blocks.push(rawBlock); } } return ( {withKey(blocks)} ); } })); export const DOCXArithFormulaRun = wrapDOCXComponent("DOCXArithFormulaRun", ((props: DOCXComponentProps & ArithFormulaRunProps) => { const { el, docxOptions } = props; const rawBlocks = DOCXAnyELsToBlocks({ els: el.children, indent: 0, docxOptions, }); if (rawBlocks.every(Array.isArray)) { const runs = (rawBlocks as React.JSX.Element[][]).flat(); return (<> {withKey(runs)} ); } else { const blocks: React.JSX.Element[] = []; for (const rawBlock of rawBlocks) { if (Array.isArray(rawBlock)) { blocks.push(( {withKey(rawBlock)} )); } else { blocks.push(rawBlock); } } return ( {withKey(blocks)} ); } }));