Skip to content

fix: scope Annotatable JS and CSS to the block, and translate its editor - #366

Open
irfanuddinahmad wants to merge 1 commit into
openedx:mainfrom
irfanuddinahmad:irfanuddinahmad/annotatable-leftovers
Open

irfanuddinahmad wants to merge 1 commit into
openedx:mainfrom
irfanuddinahmad:irfanuddinahmad/annotatable-leftovers

Conversation

@irfanuddinahmad

Copy link
Copy Markdown
Contributor

Summary

Why it's needed: openedx/openedx-platform#38746 removes the built-in Annotatable block, so it should merge after this is released.

Changes

#365 item Fix
1. Blocks on one page control each other annotatable.js finds toggles, spans, instructions and the tooltip container inside the block's element, as the built-in this.$ did. The problem-input and return selectors stay page-wide, as in the built-in, because problems are separate blocks.
2. Global XMLEditingDescriptor The editor's initializer is renamed to AnnotatableEditor (in the JS and in initialize_js)
3. Unscoped CSS Display rules are scoped to .annotatable-wrapper (tooltips render inside it), and editor rules to a new .annotatable-editor class on the editor's root. The built-in editor's CodeMirror rule is restored.
4. Untranslated editor messages Wrapped in gettext(), using the block's JS catalog (window.XBlockAnnotatableI18N), which studio_view now loads, else the page's global gettext

Translations: 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.py fail on main and 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 check and pylint src/xblock_annotatable are 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:

    Stock This PR
    "Hide Annotations" in the first block Both blocks hide Only the first
    "Collapse Instructions" in the first block Both collapse Only the first
    Hovering a highlight in the second block Tooltip placed in the first block's wrapper In its own wrapper, same styling
    Studio editor (authoring MFE) Opens; CodeMirror at 14px Opens; CodeMirror at 13px, as in the built-in
    A customtag's XML editor in the same unit Opens Opens

    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.

Stock This PR
stock: clicking the first block collapsed both this PR: only the first block collapsed

Part of #365 and of the Slash-n-Burn Built-In XBlocks epic.

🤖 Generated with Claude Code

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>
@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Dec 4, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @irfanuddinahmad!

This repository is currently maintained by @openedx/axim-engineering.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

2 participants