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

Conversation

Twiineenock
Copy link
Contributor

@Twiineenock Twiineenock commented Oct 14, 2024

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

Problem Description

This pull request is part of ongoing work in PR #355.

In the interactive form builder, users should have the ability to create questions with markdown-rendered content. The markdown feature will allow question content to be formatted for better readability and accessibility.

Key Changes

  1. Upgrade react-markdown Version:

    • Upgraded react-markdown from version ^7.1.2 to ^9.0.1 to support an expanded range of markdown formatting options.
    • This update enables support for additional plugins and formatting elements, allowing for a richer editing experience.
  2. Extended Markdown Capabilities:

    • Extended the ReactMarkdown component to support more plugins and allowedElements for enhanced markdown rendering.
    • Updated the FormField interface to handle cases where the label is absent, but a value is present. This change provides more flexibility for displaying markdown content without requiring a label.

Technical Details

  • Dependencies:
    "react-markdown": "^9.0.1"
    
    

Screenshots

Related Issue

https://openmrs.atlassian.net/browse/O3-3946

Other

package.json Outdated
Comment on lines 40 to 41
"rehype-raw": "^7.0.0",
"remark-gfm": "^4.0.0"
Copy link
Contributor

@NethmiRodrigo NethmiRodrigo Oct 14, 2024

Choose a reason for hiding this comment

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

Do we need these three libraries?

@NethmiRodrigo
Copy link
Contributor

@Twiineenock I think you need to commit the yarn.lock

@samuelmale samuelmale changed the title feat: Tweak the markdown support (feat) Extend Allowed Elements in React Markdown Component Oct 14, 2024
@@ -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.

@NethmiRodrigo
Copy link
Contributor

@Twiineenock can you resolve the conflicts and update your branch?

Copy link
Member

@denniskigen denniskigen left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. I've left a comment seeking some clarification about the changes here.

Comment on lines +9 to +19
allowedElements={[
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'p',
'strong',
'em',
]}
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!

@Twiineenock Twiineenock changed the title (feat) Extend Allowed Elements in React Markdown Component (feat) Allow FormField field to support markdown value or label Oct 18, 2024
@NethmiRodrigo NethmiRodrigo changed the title (feat) Allow FormField field to support markdown value or label (feat) Make label optional to support Markdown content Oct 21, 2024
@NethmiRodrigo NethmiRodrigo changed the title (feat) Make label optional to support Markdown content (feat) Make the label in FormField optional to support Markdown content Oct 21, 2024
@NethmiRodrigo
Copy link
Contributor

LGTM! Thanks @Twiineenock!

@NethmiRodrigo NethmiRodrigo merged commit 4e0d67d into openmrs:main Oct 21, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants