Conversation
|
Thanks for the pull request, @rpenido! 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. 🔘 Update the status of your PRYour PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate. 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. |
b5f4e97 to
ec088e7
Compare
ec088e7 to
25702c6
Compare
Description
Adds an opt-in
include_themesetting to the Text (HTML) XBlock. When it is on, the block renders its author-supplied HTML inside a shadow root and applies the deployment's Paragon theme to it, so page styles cannot reach the content and the content cannot leak styles back out into the page.Blocks created before this change, and blocks where the author leaves the setting off, render exactly as they did: the legacy
html.cssis loaded for them and skipped only for themed blocks.Testing instructions
Setup
To check the feature, the deployment has to publish Paragon theme URLs the block can read, including one that cannot be missed. A single Tutor plugin does all of it and carries its own check stylesheet, so there is nothing else to create or mount. It also adds the Studio origin to the LMS CORS whitelist: Studio renders the block in an iframe on its own origin, from where the config API is not reachable unless that origin is allowed. Save this as
xblock_theme_check.pyin yourTUTOR_PLUGINS_ROOT:Enable it and rebuild:
You will also need to have openedx/openedx-platform#39178 and openedx/frontend-app-authoring#3271 bind-mounted in your stack.
document.querySelector('.xblock_html').getRootNode().constructor.namereturns"ShadowRoot". Note thatdocument.querySelector('.xblock-root')returnsnullby design - that container is created inside the shadow root anddocument.querySelectordoes not cross the boundary; reach it withdocument.querySelector('.xblock_html').shadowRoot.querySelector('.xblock-root').body { font-family: ... }and confirm the block does not inherit it. The author's own CSS stays inside the block for the same reason. Expect one deliberate exception: the theme stylesheets are appended todocument.headas well as to the shadow root, because Paragon declares its custom properties on:rootand:rootdoes not cross a shadow boundary - so seeing the theme on the rest of the page is intended, not a leak.<html>element carriesinclude_theme="true"; with it off, the attribute is absent - the serializer only writes the field when it is set, so the default never appears in OLX. This depends on fix: serialize the Text (HTML) XBlock's include_theme setting [WIP] openedx-platform#39178 - the serializer uses a hardcoded allowlist and silently drops the field without it.Other information
Merge checklist:
Check off if complete or not applicable:
Private ref: FAL-4394