Skip to content
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

(feat) Make the label in FormField optional to support Markdown content #411

Merged
merged 4 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"lodash-es": "^4.17.21",
"react-error-boundary": "^4.0.13",
"react-hook-form": "^7.52.0",
"react-markdown": "^7.1.2",
"react-markdown": "^9.0.1",
"react-waypoint": "^10.3.0",
"react-webcam": "^7.2.0"
},
Expand Down
12 changes: 11 additions & 1 deletion src/components/inputs/markdown/markdown-wrapper.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ const MarkdownWrapper: React.FC<{ markdown: string | string[] }> = ({ markdown }
<ReactMarkdown
children={Array.isArray(markdown) ? markdown.join('\n') : markdown}
unwrapDisallowed={true}
allowedElements={['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'strong', 'em']}
allowedElements={[
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'p',
'strong',
'em',
]}
Comment on lines +9 to +19
Copy link
Member

@denniskigen denniskigen Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Twiineenock AFAICT, it doesn't seem as though allowedElements has changed per this this diff. Does that invalidate the PR title? Is the main change here that we're just bumping react-markdown?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@denniskigen , I had added more allowedElements in the first commit.
I was later asked to maintain the current allowedElements as in this thread.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And yes the PR title has to change! Thanks!

/>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/types/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export interface FormSection {
}

export interface FormField {
label: string;
label?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samuelmale this was changed to be optional because markdown type inputs don't have a label. Does this seem okay?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense to me.

type: string;
questionOptions: FormQuestionOptions;
datePickerFormat?: 'both' | 'calendar' | 'timer';
Expand Down
Loading