Skip to content

Commit 6e9390a

Browse files
committed
added the ui:enableMarkdownInHelp flag in UiSchema
1 parent bdc063b commit 6e9390a

File tree

16 files changed

+3802
-3693
lines changed

16 files changed

+3802
-3693
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,54 +19,69 @@ should change the heading of the (upcoming) version to include a major version b
1919

2020
## @rjsf/antd
2121

22+
- Updated ``
2223
- Updated `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
2324
- Updated `ArrayFieldTemplate` and `ObjectFieldTemplate` to remove the rendering of a duplicate description (since the `FieldTemplate` already does it), fixing [#3624](https://github.com/rjsf-team/react-jsonschema-form/issues/3624)
2425

2526
## @rjsf/chakra-ui
2627

2728
- Modified `CheckboxesWidget` to render the Title, fixing ([#4840](https://github.com/rjsf-team/react-jsonschema-form/issues/4840))
2829
- Updated `CheckboxWidget` to handle label and description rendering consistently, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
30+
- Updated `FieldHelpTemplate` to render markdown when `ui:enableMarkdownInHelp` is true
2931

3032
## @rjsf/core
3133

3234
- Fixed duplicate label and description rendering in `CheckboxWidget` by conditionally rendering them based on widget type
3335
- Updated `CheckboxWidget` to handle label and description rendering consistently
3436
- Modified `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
3537
- Updated `ObjectField` to change the removal of an additional property to defer the work to the `processPendingChange()` handler in `Form`, fixing [#4850](https://github.com/rjsf-team/react-jsonschema-form/issues/4850)
38+
- Added support for rendering `ui:help` as markdown via new `ui:enableMarkdownInHelp` flag in `FieldHelpTemplate`
3639

3740
## @rjsf/fluentui-rc
3841

3942
- Updated `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
43+
- Updated `FieldHelpTemplate` to render markdown when `ui:enableMarkdownInHelp` is true
44+
45+
## @rjsf/daisyui
46+
47+
- Updated `FieldHelpTemplate` to render markdown when `ui:enableMarkdownInHelp` is true
4048

4149
## @rjsf/mantine
4250

4351
- Updated `CheckboxWidget` to handle label and description rendering consistently, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
52+
- Updated `FieldHelpTemplate` to render markdown when `ui:enableMarkdownInHelp` is true
4453

4554
## @rjsf/mui
4655

4756
- Updated `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
57+
- Updated `FieldHelpTemplate` to render markdown when `ui:enableMarkdownInHelp` is true
4858

4959
## @rjsf/primereact
5060

5161
- Updated `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
62+
- Updated `FieldHelpTemplate` to render markdown when `ui:enableMarkdownInHelp` is true
5263

5364
## @rjsf/react-bootstrap
5465

5566
- Updated `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
67+
- Updated `FieldHelpTemplate` to render markdown when `ui:enableMarkdownInHelp` is true
5668

5769
## @rjsf/semantic-ui
5870

5971
- Updated `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
72+
- Updated `FieldHelpTemplate` to render markdown when `ui:enableMarkdownInHelp` is true
6073

6174
## @rjsf/shadcn
6275

6376
- Updated `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
6477
- Updated the `Command` component to properly handle `forwardRef`
78+
- Updated `FieldHelpTemplate` to render markdown when `ui:enableMarkdownInHelp` is true
6579

6680
## @rjsf/utils
6781

6882
- Updated `getDefaultFormState()` to not save an undefined field value into an object when the type is `null` and `excludeObjectChildren` is provided, fixing [#4821](https://github.com/rjsf-team/react-jsonschema-form/issues/4821)
6983
- Added new `ADDITIONAL_PROPERTY_KEY_REMOVE` constant
84+
- Added new global UI option `enableMarkdownInHelp` to control markdown rendering of `ui:help`
7085

7186
## Dev / docs / playground
7287

packages/antd/test/__snapshots__/Array.test.tsx.snap

Lines changed: 743 additions & 743 deletions
Large diffs are not rendered by default.

packages/antd/test/__snapshots__/Form.test.tsx.snap

Lines changed: 1594 additions & 1594 deletions
Large diffs are not rendered by default.

packages/antd/test/__snapshots__/Grid.test.tsx.snap

Lines changed: 692 additions & 692 deletions
Large diffs are not rendered by default.

packages/antd/test/__snapshots__/Object.test.tsx.snap

Lines changed: 643 additions & 643 deletions
Large diffs are not rendered by default.

packages/chakra-ui/src/FieldHelpTemplate/FieldHelpTemplate.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Text } from '@chakra-ui/react';
2-
import { helpId, FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2+
import { helpId, FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema, getUiOptions } from '@rjsf/utils';
3+
import Markdown from 'markdown-to-jsx';
34

45
/** The `FieldHelpTemplate` component renders any help desired for a field
56
*
@@ -10,10 +11,18 @@ export default function FieldHelpTemplate<
1011
S extends StrictRJSFSchema = RJSFSchema,
1112
F extends FormContextType = any,
1213
>(props: FieldHelpProps<T, S, F>) {
13-
const { fieldPathId, help } = props;
14+
const { fieldPathId, help, uiSchema = {}, registry } = props;
1415
if (!help) {
1516
return null;
1617
}
1718
const id = helpId(fieldPathId);
19+
const uiOptions = getUiOptions<T, S, F>(uiSchema, registry?.globalUiOptions);
20+
if (typeof help === 'string' && uiOptions.enableMarkdownInHelp) {
21+
return (
22+
<Text id={id}>
23+
<Markdown options={{ disableParsingRawHTML: true }}>{help}</Markdown>
24+
</Text>
25+
);
26+
}
1827
return <Text id={id}>{help}</Text>;
1928
}

packages/core/src/components/templates/FieldHelpTemplate.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { helpId, FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
1+
import { helpId, FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema, getUiOptions } from '@rjsf/utils';
2+
import Markdown from 'markdown-to-jsx';
23

34
/** The `FieldHelpTemplate` component renders any help desired for a field
45
*
@@ -9,12 +10,20 @@ export default function FieldHelpTemplate<
910
S extends StrictRJSFSchema = RJSFSchema,
1011
F extends FormContextType = any,
1112
>(props: FieldHelpProps<T, S, F>) {
12-
const { fieldPathId, help } = props;
13+
const { fieldPathId, help, uiSchema = {}, registry } = props;
1314
if (!help) {
1415
return null;
1516
}
1617
const id = helpId(fieldPathId);
18+
const uiOptions = getUiOptions<T, S, F>(uiSchema, registry?.globalUiOptions);
1719
if (typeof help === 'string') {
20+
if (uiOptions.enableMarkdownInHelp) {
21+
return (
22+
<div id={id} className='help-block'>
23+
<Markdown options={{ disableParsingRawHTML: true }}>{help}</Markdown>
24+
</div>
25+
);
26+
}
1827
return (
1928
<p id={id} className='help-block'>
2029
{help}

packages/daisyui/src/templates/FieldHelpTemplate/FieldHelpTemplate.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { FieldHelpProps, StrictRJSFSchema, RJSFSchema, FormContextType } from '@rjsf/utils';
1+
import { FieldHelpProps, StrictRJSFSchema, RJSFSchema, FormContextType, getUiOptions } from '@rjsf/utils';
2+
import Markdown from 'markdown-to-jsx';
23

34
/** The `FieldHelpTemplate` component renders help text for a specific form field
45
* with DaisyUI styling. It displays the help text in a subtle gray color and smaller size
@@ -14,7 +15,17 @@ export default function FieldHelpTemplate<
1415
S extends StrictRJSFSchema = RJSFSchema,
1516
F extends FormContextType = any,
1617
>(props: FieldHelpProps<T, S, F>) {
17-
const { help } = props;
18+
const { help, uiSchema = {}, registry } = props;
19+
const uiOptions = getUiOptions<T, S, F>(uiSchema, registry?.globalUiOptions);
20+
if (typeof help === 'string' && uiOptions.enableMarkdownInHelp) {
21+
return (
22+
<div className='rjsf-field-help-template text-gray-500 text-sm'>
23+
<div>
24+
<Markdown options={{ disableParsingRawHTML: true }}>{help}</Markdown>
25+
</div>
26+
</div>
27+
);
28+
}
1829
return (
1930
<div className='rjsf-field-help-template text-gray-500 text-sm'>
2031
<div>{help}</div>

packages/fluentui-rc/src/FieldHelpTemplate/FieldHelpTemplate.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Caption1 } from '@fluentui/react-components';
2-
import { helpId, FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2+
import { helpId, FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema, getUiOptions } from '@rjsf/utils';
3+
import Markdown from 'markdown-to-jsx';
34

45
/** The `FieldHelpTemplate` component renders any help desired for a field
56
*
@@ -10,10 +11,18 @@ export default function FieldHelpTemplate<
1011
S extends StrictRJSFSchema = RJSFSchema,
1112
F extends FormContextType = any,
1213
>(props: FieldHelpProps<T, S, F>) {
13-
const { fieldPathId, help } = props;
14+
const { fieldPathId, help, uiSchema = {}, registry } = props;
1415
if (!help) {
1516
return null;
1617
}
1718
const id = helpId(fieldPathId);
19+
const uiOptions = getUiOptions<T, S, F>(uiSchema, registry?.globalUiOptions);
20+
if (typeof help === 'string' && uiOptions.enableMarkdownInHelp) {
21+
return (
22+
<Caption1 id={id}>
23+
<Markdown options={{ disableParsingRawHTML: true }}>{help}</Markdown>
24+
</Caption1>
25+
);
26+
}
1827
return <Caption1 id={id}>{help}</Caption1>;
1928
}

packages/mantine/src/templates/FieldHelpTemplate.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { helpId, FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
1+
import { helpId, FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema, getUiOptions } from '@rjsf/utils';
22
import { Text } from '@mantine/core';
3+
import Markdown from 'markdown-to-jsx';
34

45
/** The `FieldHelpTemplate` component renders any help desired for a field
56
*
@@ -10,14 +11,21 @@ export default function FieldHelpTemplate<
1011
S extends StrictRJSFSchema = RJSFSchema,
1112
F extends FormContextType = any,
1213
>(props: FieldHelpProps<T, S, F>) {
13-
const { fieldPathId, help } = props;
14+
const { fieldPathId, help, uiSchema = {}, registry } = props;
1415

1516
if (!help) {
1617
return null;
1718
}
1819

1920
const id = helpId(fieldPathId);
20-
21+
const uiOptions = getUiOptions<T, S, F>(uiSchema, registry?.globalUiOptions);
22+
if (typeof help === 'string' && uiOptions.enableMarkdownInHelp) {
23+
return (
24+
<Text id={id} size='sm' my='xs' c='dimmed'>
25+
<Markdown options={{ disableParsingRawHTML: true }}>{help}</Markdown>
26+
</Text>
27+
);
28+
}
2129
return (
2230
<Text id={id} size='sm' my='xs' c='dimmed'>
2331
{help}

0 commit comments

Comments
 (0)