-
Notifications
You must be signed in to change notification settings - Fork 8
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
fix: rendering tables [BB-6729] #18
Conversation
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.
Please remember to bump the version.
@Agrendalath I see CI is failing, and I know why, but this might be intentional. It has to do with the The simplest way I thought of fixing this for tests is to add the following to
This would fix the tests, but wouldn't fix the quality check, because it would still complain about passing unexpected arguments in the fallback for version 4.1.0. |
It won't overwrite the installed version. This XBlock does not have lots of dependencies on its own, so only the most important ones are defined in setup.py - it doesn't load anything from the I just pinned |
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.
👍
- I tested this: checked that relatively complex tables are rendered the same way in LMS, Studio, and the TinyMCE editor
- I read through the code
- I checked for accessibility issues: n/a
- Includes documentation: n/a
- I made sure any change in configuration variables is reflected in the corresponding client's
configuration-secure
repository: n/a
Oh, I made an assumption that Can we pin a |
Added a test for testing that tables are rendered correctly. I.e. without html elements, attributes or styles removed by the sanitizer.
Tables weren't being rendered correctly in LMS, because the sanitizer would filter out html element, attributes and styles of the tables. Added html elements, attributes and styles to the list of allow lists to fix the rendering.
Renamed functions and files for styles and scripts which are loaded only when editing the XBlock in studio, to make it easier to distinguish from the files which are loaded in the LMS view or in studio preview.
In studio preview of the xblocks there are global styles that remove borders from elements, including tables and elements that are parts of the tables. These global styles would overwrite the browser default styles for table borders, especially when `border` attribute was set on the table. The fix provides styles that are loaded only in the studio preview. The new styles try to fix the issue by overwriting the global styles and setting the border to the same styles as they would be by default.
2d8040c
to
47fb2e4
Compare
ade2618
to
659a87c
Compare
659a87c
to
ee50083
Compare
Looks like we've backported bleach version update to Nutmeg, so it makes sense to test its compatibility. We still need to support Maple, though, so I've added CI tests for both versions. |
Description
This PR fixes issues related to tables generated by TinyMCE editor.
Tables are not rendered correctly in LMS - certain element, inline attributes and styles are not rendered, when JavaScript is not allowed for the XBlock. Enabling JavaScript fixes the issue, because it disables the sanitization of the rendered HTML. We still want the HTML to be sanitized, so we add the relevant elements, attributes and styles to the allow list for sanitization.
Screenshots
LMS
Before
After
Studio preview
Before
After
Testing instructions
xblock-html
repo into<devstack-root>/src/
and change the branchlms
,studio
, andlearning
MFE:xblock-html
intolms
:xblock-html
intostudio
:edx@example.com
)html5
andexcluded_html5
inAdvanced Module List
html5
xblock - Advanced > TextThe following HTML was generated using TinyMCE visual editor using all the settings which affect the tables styling:
Notes
I added a unit test for checking how html of table generated by TinyMCE would be rendered. I had to modify the html by sorting the inline attributes and styles in alphabetical order, so the it matches the sanitizer's output. The test has been useful during the development, but can be difficult to maintain, so can be removed from the PR.