-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Markdown in descriptions #4405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Markdown in descriptions #4405
Changes from 6 commits
e195be6
bc3acf3
234a0f0
a7529dc
de02a01
f2f0616
b9bddd8
5c00058
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,9 @@ import { | |
RJSFSchema, | ||
StrictRJSFSchema, | ||
WidgetProps, | ||
getUiOptions, | ||
} from '@rjsf/utils'; | ||
import Markdown from 'markdown-to-jsx'; | ||
|
||
/** The `CheckBoxWidget` is a widget for rendering boolean properties. | ||
* It is typically used to represent a boolean. | ||
|
@@ -32,6 +34,9 @@ function CheckboxWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F exte | |
onChange, | ||
registry, | ||
}: WidgetProps<T, S, F>) { | ||
const { globalUiOptions } = registry; | ||
const uiOptions = getUiOptions<T, S, F>(uiSchema, globalUiOptions); | ||
|
||
const DescriptionFieldTemplate = getTemplate<'DescriptionFieldTemplate', T, S, F>( | ||
'DescriptionFieldTemplate', | ||
registry, | ||
|
@@ -58,12 +63,18 @@ function CheckboxWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F exte | |
); | ||
const description = options.description ?? schema.description; | ||
|
||
const richDescription = uiOptions.enableMarkdownInDescription ? ( | ||
<Markdown options={{ disableParsingRawHTML: true }}>{description || ''}</Markdown> | ||
) : ( | ||
description || '' | ||
); | ||
|
||
|
||
return ( | ||
<div className={`checkbox ${disabled || readonly ? 'disabled' : ''}`}> | ||
{!hideLabel && !!description && ( | ||
<DescriptionFieldTemplate | ||
id={descriptionId<T>(id)} | ||
description={description} | ||
description={richDescription} | ||
schema={schema} | ||
uiSchema={uiSchema} | ||
registry={registry} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The package change is so small as to not require mentioning. What does want to be mentioned is that it is a new feature so requires
5.25.0
AND you want to mention the changes in each package.