-
Notifications
You must be signed in to change notification settings - Fork 166
fix: contentAnalyzer added to determine TinyMCE Editor type #2609
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
base: master
Are you sure you want to change the base?
fix: contentAnalyzer added to determine TinyMCE Editor type #2609
Conversation
|
Thanks for the pull request, @marslanabdulrauf! 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. Where 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. |
6975c25 to
2489cc7
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2609 +/- ##
========================================
Coverage 94.82% 94.83%
========================================
Files 1226 1232 +6
Lines 27559 27638 +79
Branches 6211 6056 -155
========================================
+ Hits 26133 26210 +77
- Misses 1355 1370 +15
+ Partials 71 58 -13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I don't quite understand this. When would it not be HTML? And even if it's just a string like "An interesting course." with no HTML, isn't that still HTML in a sense, just without tags? |
| /** | ||
| * Utility functions for detecting content type and | ||
| * determining appropriate editor type for TinyMCE editor | ||
| */ |
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.
New files added to this repo should be using TypeScript - please see the "Best practices checklist" in your PR description.
I wasn't sure if I should hard code the editorType as I also agree that |
|
I think it's fine to just hard-code it as HTML, as these are HTML fields. But if you can think of or find any bugs that would result from that, please let me know. |
fb208bb to
c864dea
Compare
|
While testing with the hardcoded If we provide plain text like "hello world", the HTML editor automatically wraps it in a We were trying to avoid this same situation when the overview content is actually HTML, but the editor type is set to If we’re certain that all overviews will be HTML-based, we can safely hardcode |
c864dea to
9436441
Compare
|
@bradenmacdonald could you please take another look ? |
Yep, that makes sense. However, it would be a one-time problem, and would only affect courses that have plain text in their "About" section, and we don't know if there are courses like that or not. So I don't think it's a big deal.
I am testing this with |
|
yes @bradenmacdonald that was the issue and it is because of the For all new courses it always shows "Save you changes" without any actual modification. And by saving it, it goes away -- As modified content is now stored. And Upon investigation found this same issue that you noticed in master branch with image source. When we shift to This PR fixes this issue by analyzing the content to try to identify the type of content for editor. The scenario I added in this #2609 (comment) could follow your path -- save it first time. Why going with html -- I think as the default content is |
|
@marslanabdulrauf If changing the editor type to If the issue is because of the image URL rewriting, isn't there a more direct way to fix it? The culprit seems to be frontend-app-authoring/src/editors/sharedComponents/TinyMceWidget/hooks.ts Lines 347 to 349 in 1d385c6
|
I haven't seen any bugs, it actually fixes the issue with images. With
@bradenmacdonald I agree that we should look into this issue as well where we are changing the image src urls in text editor. I have explored and found this PR in which this function was added but there is not explanation on why we are converting However I suggest we should still use |
|
@marslanabdulrauf I investigate this and put my findings here: #2668 . Please review that and let me know your thoughts. Your PR does solve most of the bugs, but it basically prevents any URL rewriting from happening, so URLs like |


Related Ticket (Internal)
https://github.com/mitodl/hq/issues/9166#event-20756793537
Description
This PR:
Steps to Reproduce
Supporting information
It happens because the default course over is in
htmle.g;<section>About ...</section>and when we serve it as text in TinyMCE Editor it changes the content which triggers the Alert to save the changes.Adding editorType
htmlfixes the issue however as the field is str in edx-platform we might not get html always.So a simple utility function is added to analyze and identify editorType from content.
Testing instructions
Best Practices Checklist
We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:
.ts,.tsx).propTypesanddefaultPropsin any new or modified code.src/testUtils.tsx(specificallyinitializeMocks)apiHooks.tsin this repo for examples.messages.tsfiles have adescriptionfor translators to use.../in import paths. To import from parent folders, use@src, e.g.import { initializeMocks } from '@src/testUtils';instead offrom '../../../../testUtils'