Repository navigation
fix: scope Annotatable JS and CSS to the block, and translate its editor - #366
irfanuddinahmad wants to merge 1 commit into
Conversation
Fixes gaps between the extracted Annotatable block and the built-in one that openedx/openedx-platform#38746 removes: - The student view JS selected toggles, spans, the instructions and the tooltip container page-wide, so with two Annotatable blocks on a page, "Hide Annotations" in one toggled both. Find them inside the block's element, as the built-in block's `this.$` did. - The editor's initializer was a global `XMLEditingDescriptor`, which replaces the platform's global of that name (xmodule/js/src/raw/edit/ xml.js) used by other blocks' XML editors. Rename it AnnotatableEditor. - The CSS rules were unscoped (the built-in scoped them to `.xmodule_display.xmodule_AnnotatableBlock`). Scope them to the block's `.annotatable-wrapper`, and the editor's to a new `.annotatable-editor` class; restore the built-in editor's CodeMirror rule. - The editor's save and error messages were English-only. Wrap them in gettext(), using the block's JS catalog, which studio_view now loads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the pull request, @irfanuddinahmad! 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. |
Summary
Changes
annotatable.jsfinds toggles, spans, instructions and the tooltip container inside the block's element, as the built-inthis.$did. The problem-input and return selectors stay page-wide, as in the built-in, because problems are separate blocks.XMLEditingDescriptorAnnotatableEditor(in the JS and ininitialize_js).annotatable-wrapper(tooltips render inside it), and editor rules to a new.annotatable-editorclass on the editor's root. The built-in editor's CodeMirror rule is restored.gettext(), using the block's JS catalog (window.XBlockAnnotatableI18N), whichstudio_viewnow loads, else the page's globalgettextTranslations: the three editor messages are new to this block's catalog, so they show in English until the next translation cycle.
Test plan
5 new tests in
src/xblock_annotatable/tests/test_annotatable.pyfail onmainand pass here. They cover the catalog loading before the editor JS, the global name, the translatable messages, the CSS scope, and the editor root class.Item 1 has a Karma spec with two blocks on a page (both specs fail on
main, pass here). It needs the JS test setup from test: port Annotatable JS spec from openedx-platform #319, so I'll add it once test: port Annotatable JS spec from openedx-platform #319 merges.pytest src/xblock_annotatable: 18 passed.ruff checkandpylint src/xblock_annotatableare clean.Live in a local Tutor (platform master, xblocks-core 4.0.0 with this PR's six Annotatable files on top; Annotatable is unchanged between 4.0.0 and
main), with two Annotatable blocks in one unit:The authoring MFE opens each editor in its own iframe, and the legacy container page now redirects to the MFE. So item 2 doesn't break anything in Studio today; the rename prevents the clash on any page that loads both editors.
Part of #365 and of the Slash-n-Burn Built-In XBlocks epic.
🤖 Generated with Claude Code