feat: Enhance Image Settings Modal with Extensibility Slots and classList Support#3053
feat: Enhance Image Settings Modal with Extensibility Slots and classList Support#3053xitij2000 wants to merge 8 commits into
Conversation
This commit is mainly to get git to reconise the rename so file history is maintained.
This change converts the Image Editor Modal to typescript and simplifies the hooks switching to Formik + Yup for form validation. It updates the tests to check the behaviour of the component as a whole rather than testing small components.
Introduce `ImageSettingsModalSlot` and `ImageAdditionalSettingsSlot` to enable easier extension of modal functionality. Update form handling with `Formik` and improve property mapping for image settings.
Include `classList` handling in ImageUploadModal and ImageSettingsModal to enable setting and managing custom CSS classes for uploaded images.
|
Thanks for the pull request, @xitij2000! 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. |
musaabhasan
left a comment
There was a problem hiding this comment.
I reviewed the new image additional-settings slot documentation and left two copy-paste correctness notes. The underlying extension point looks useful; these are small fixes that would help plugin authors avoid an accessibility regression or a runtime error when adapting the example.
| checked={checked} | ||
| onChange={handleChange} | ||
| /> | ||
| <Form.Label>Showcase Image</Form.Label> |
There was a problem hiding this comment.
For a copy-pasteable accessibility example, the checkbox should have an associated accessible name. As written, the Form.Label is rendered as a sibling and may not be associated with the input, so plugin authors could copy an unlabeled control into the image settings modal. The existing pattern elsewhere in this PR nests the label inside Form.Checkbox, which would keep the example safer for keyboard and screen-reader users.
There was a problem hiding this comment.
Thanks for the feedback! I've updated the code sample and also applied this to the example in the PR description.
| widget: { | ||
| id: 'showcase_class_editor', | ||
| type: 'DIRECT_PLUGIN', | ||
| RenderWidget: ShowCaseClassEditor, |
There was a problem hiding this comment.
This example defines ShowcaseClassEditor, but the widget references ShowCaseClassEditor. Copying the snippet as-is will throw because ShowCaseClassEditor is undefined. The RenderWidget value should match the component name above.
There was a problem hiding this comment.
Done! I've updated the example to use a consistent name,
There was a problem hiding this comment.
I've updated the example to use a consistent name.
32df029 to
dd9e370
Compare
dd9e370 to
7399639
Compare
Ensure proper initialization and fallback of `classList` in image-related components and tests. Update types and test cases for consistency and better validation.
Description
This set of changes improves the image editing experience in the authoring app by introducing extensibility points and support for custom CSS classes on images.
The changes are split across two primary areas:
ImageSettingsModalSlotandImageAdditionalSettingsSlot. These slots allow developers to extend the Image Settings Modal by adding custom form fields or modifying the modal's behavior (e.g., custom validation or value processing) via the plugin framework.ImageSettingsModalto use a more flexibleFormikimplementation, facilitating easier integration with these new slots.classList):classListhandling toImageSettingsModalandImageUploadModal.<img>tag in the editor.These improvements enable use cases such as adding a "Showcase" checkbox that applies a specific CSS class to an image, as demonstrated in the newly added documentation.
Testing Instructions
To verify these changes, please follow these steps:
1. Verify
classListPreservation:<img class="test-class" ... />).test-classis still present on the image tag.2. Verify Plugin Slot Functionality (Technical):
org.openedx.frontend.authoring.image_additional_settings.v1slot.classListin Formik context (similar to the example insrc/plugin-slots/ImageAdditionalSettingsSlot/README.md).Other information
This includes changes from #2993
The functionality from this proposal can be tested using the following:
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'