import { ReactElement } from 'react'; import { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema, getTestIds, getUiOptions, } from '@rjsf/utils'; import Markdown from 'markdown-to-jsx'; const TEST_IDS = getTestIds(); export interface RichHelpProps { /** The description text for a field, potentially containing markdown */ help: string | ReactElement; /** The uiSchema object for this base component */ uiSchema?: UiSchema; /** The `registry` object */ registry: Registry; } /** Renders the given `description` in the props as * * @param props - The `RichHelpProps` for this component */ export default function RichHelp({ help, registry, uiSchema = {}, }: RichHelpProps) { const { globalUiOptions } = registry; const uiOptions = getUiOptions(uiSchema, globalUiOptions); if (uiOptions.enableMarkdownInHelp && typeof help === 'string') { return ( {help} ); } return help; } RichHelp.TEST_IDS = TEST_IDS;