import React from "react"; import type * as std from "../../law/std"; import type { HTMLFigData, HTMLComponentProps } from "../common/html"; import { elProps, wrapHTMLComponent } from "../common/html"; import type { DOCXComponentProps, DOCXFigData, DOCXFigDataManager } from "../common/docx/component"; import { wrapDOCXComponent } from "../common/docx/component"; import { w, wp, a, pic, o, v } from "../common/docx/tags"; import { NotImplementedError } from "../../util"; export interface FigRunProps { el: std.Fig, } export const HTMLFigRunCSS = /*css*/` .fig-iframe { width: 100%; height: 80vh; border: 1px solid gray; } .fig-img { max-width: 100%; } `; export const HTMLFigRun = wrapHTMLComponent("HTMLFigRun", ((props: HTMLComponentProps & FigRunProps) => { const { el, htmlOptions } = props; const { getFigData } = htmlOptions; if (el.children.length > 0) { throw new NotImplementedError(el.outerXML()); } if (getFigData) { const figData = getFigData(el.attr.src); return figData === null ? ( <>[{el.attr.src}] ) : ( ); } else { return ( {el.attr.src} ); } })); export const HTMLFigRunWithFigData = (props: HTMLComponentProps & FigRunProps & { figData: HTMLFigData, fig: std.Fig }) => { const { el, figData, htmlOptions, fig } = props; const { renderPDFAsLink } = htmlOptions; return ( figData.type.startsWith("image/") ? ( ) : ((!renderPDFAsLink) && figData.type.includes("pdf")) ? (