feat: added markdown editor for editing problems in markdown format - #1805
Conversation
|
Thanks for the pull request, @Anas12091101! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
| @@ -0,0 +1,541 @@ | |||
| const convertMarkdownToXml = (markdown) => { | |||
There was a problem hiding this comment.
I guess this isn't really a new file and it may be too late anyways so I won't block on this, but when adding new files in any of our frontend repos, please use TypeScript .ts[x] instead of .js[x] ! Especially something with this much complicated logic.
| @@ -0,0 +1,305 @@ | |||
| import convertMarkdownToXml from './convertMarkdownToXML'; | |||
There was a problem hiding this comment.
Not blocker for merge, but new files should be .ts not .js.
| }; | ||
|
|
||
| export const SwitchEditorCardInternal = SwitchEditorCard; // For testing only | ||
| export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(SwitchEditorCard)); |
There was a problem hiding this comment.
I realize this file is just renamed, and not a new file, so consider this optional / non-blocking:
injectIntl is deprecated. Please use useIntl instead. openedx/frontend-app-learning#1634
Also, please don't use connect or really any other higher order components like this - instead of mapStateToProps and mapDispatchToProps, use the useSelector and useDispatch hooks respectively.
Once you do this you can likely get rid of SwitchEditorCardInternal as it won't be needed.
(Fine to leave in existing code, but new code should follow the new practices)
| SwitchEditorCard.propTypes = { | ||
| intl: intlShape.isRequired, | ||
| switchEditor: PropTypes.func.isRequired, | ||
| isMarkdownEditorEnabled: PropTypes.bool.isRequired, | ||
| problemType: PropTypes.string.isRequired, | ||
| editorType: PropTypes.string.isRequired, | ||
| }; |
There was a problem hiding this comment.
I realize this file is just renamed, and not a new file, so consider this optional / non-blocking:
- PropTypes were deprecated in April 2017 (React v15.5.0). Please use TypeScript types in new code.
| if (result.length === 1 || !result[1]) { | ||
| return label; | ||
| } | ||
| // xss-lint: disable=javascript-concat-html |
There was a problem hiding this comment.
I think you can remove all these xss-lint comments? We don't have this linter in React/MFE repos and don't need it.
| export { default as removeItemOnce } from './removeOnce'; | ||
| export { default as formatDuration } from './formatDuration'; | ||
| export { default as snakeCaseKeys } from './snakeCaseKeys'; | ||
| export { default as convertMarkdownToXml } from './convertMarkdownToXML'; |
There was a problem hiding this comment.
We no longer require the use of default exports, so you can make this a regular export in convertMarkdownToXML.js and then simplify this to export { convertMarkdownToXml } from './convertMarkdownToXML'; if you want. That's more flexible and consistent. But this is optional.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1805 +/- ##
==========================================
+ Coverage 93.63% 93.73% +0.09%
==========================================
Files 1141 1143 +2
Lines 23368 23784 +416
Branches 5025 5123 +98
==========================================
+ Hits 21881 22294 +413
- Misses 1411 1414 +3
Partials 76 76 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@Anas12091101 something went wrong with the 2nd screencast. Can you upload it again?
|
|
@pdpinch It's showing me fine. I have also checked on a private window: Re-adding it here: Screen.Recording.2025-04-10.at.8.15.16.PM.mov |
6101797 to
f9f13c4
Compare
This PR adds contentstore.use_react_markdown_editor course waffle flag in cms. This flag helps in enabling the markdown editor in the authoring mfe. This PR also adds the markdown_edited field in the Problem Xblock to persist the user's choice of switching to the markdown editor on the authoring MFE. More details in the authoring MFE PR: openedx/frontend-app-authoring#1805
|
Hi @bradenmacdonald, I wanted to check in on this PR as we’re hoping to get it merged before the Teak's cut. Would you be able to take a look when possible? Happy to address any concerns. |
f9f13c4 to
a6b3daa
Compare
|
Hi @Anas12091101, sure I can do the review for you soon. But is there someone from your team who can first test this thoroughly, and give a preliminary approval? I am not enough of a capa expert to know how to test this thoroughly. Also can you please add a couple more tests to increase the coverage to get the build passing? (Or add annotations to skip coverage if things definitely don't need tests). Code coverage checks must be passing or I can't merge it. And also I should have clarified: Just because I come by a PR and do a review doesn't mean that I'm committing to being the main reviewer for the whole PR and formally approving it. But I can do that for you here if you can help with the testing side, sure. |
We can look into adding those shortcut buttons after we wrap up the Teak work.
Thanks for catching that! This was due to a bug in the new Markdown-to-XML converter, which I’ve fixed here: a644ff5. |
bradenmacdonald
left a comment
There was a problem hiding this comment.
Looks pretty good, though I do wish you'd added typescript types to the markdown parser code. Just a few small issues I noticed:
Thanks @Anas12091101, This looks good now. |
|
I found another bug: From looking at the OLX, the problem is that the first edit adds @asadali145 Did you test the visual and advanced editors too? |
|
Here is where you need to make the fix (probably frontend-app-authoring/src/editors/data/constants/problem.ts Lines 227 to 241 in 74d7d66 markdown field commented out. Was the field previously named markdown or was it always named markdown_edited ?
Edit: Oh, I see there are two fields - Edit 2: an alternate fix would be to not add |
|
@bradenmacdonald, thanks for identifying this issue! It turns out the problem was specific to libraries and doesn't occur in courses. I’ve added the |
This PR adds contentstore.use_react_markdown_editor course waffle flag in cms. This flag helps in enabling the markdown editor in the authoring mfe. This PR also adds the markdown_edited field in the Problem Xblock to persist the user's choice of switching to the markdown editor on the authoring MFE. More details in the authoring MFE PR: openedx/frontend-app-authoring#1805
bradenmacdonald
left a comment
There was a problem hiding this comment.
Excellent, thanks for making that fix. I'm going to merge this now.
|
Thanks so much @bradenmacdonald for all your help throughout. Really appreciate it! |
|
Thanks for implementing this - it's great to have it (back) :) |
This PR adds contentstore.use_react_markdown_editor course waffle flag in cms. This flag helps in enabling the markdown editor in the authoring mfe. This PR also adds the markdown_edited field in the Problem Xblock to persist the user's choice of switching to the markdown editor on the authoring MFE. More details in the authoring MFE PR: openedx/frontend-app-authoring#1805





Description
This PR adds support for the Markdown editor in the new Authoring MFE, restoring functionality that was previously available only in the legacy Studio.
A new course-specific Waffle Flag,
contentstore.use_react_markdown_editor, has been introduced in this openedx/openedx-platform#36512 to control access to the Markdown editor.When the waffle flag is enabled for a course, the
Switch to Markdown Editorbutton will appear in the problem editor page, allowing authors to create and edit problems using Markdown.For Teak, as per the discussion here, once a user switches to the Markdown editor, they cannot revert to the form-based or advanced editors unless the waffle flag is turned off for that course.
Problems created using the form-based or advanced editors in the Authoring MFE do not support Markdown, as there is currently no OLX-to-Markdown converter available. As a result, the
Switch to Markdown Editorbutton will not be shown for these problems. Work on the converter can begin after the Teak release.Useful information to include:
Creating a new problem using markdown editor
Screen.Recording.2025-04-10.at.7.33.52.PM.mov
Editing existing problems which have valid markdown
Screen.Recording.2025-04-10.at.8.15.16.PM.mov
changes.
Supporting information
https://openedx.atlassian.net/wiki/spaces/OEPM/pages/4517232656/Re-enable+Markdown+editing+of+CAPA+problems+to+meet+various+use+cases
https://github.com/mitodl/hq/issues/6812
Testing instructions
Check out the branch
anas/add-markdown-waffle-flagin theedx-platformrepository.Create a Waffle Flag Course Override named
contentstore.use_react_markdown_editorfor the course where you want to enable the Markdown editor.In the authoring MFE, create a new problem by selecting any simple problem type.
On the problem editor page, click "Show advanced settings", then click "Switch to Markdown Editor".
You should see a default Markdown template for the selected problem type.
Edit the problem content as needed and save it.
Verify that:
For existing problems, the
Switch to Markdown Editorbutton will only be available if the problem was originally created in the legacy Studio using Markdown.Problems created in the authoring MFE using the form-based or advanced editors do not support Markdown yet, as there is currently no OLX-to-Markdown converter. Work on this converter can begin after the Teak release.
Other information
Include anything else that will help reviewers and consumers understand the change.