Summary
We want to load the hCaptcha scripts when a user interacts with the VisualEditor edit form, when we know that the user will need to complete hCaptcha before they start to make their edit.
Background
- ConfirmEdit (CAPTCHA extension) has a hCaptcha VisualEditor plugin that handles displaying the hCaptcha challenge in the edit summary window
- This is displayed if the visualeditoredit fails with a captcha requirement being hcaptcha
- Therefore, the user will have to press "Save changes", then complete hCaptcha, and then press "Save changes" again
- This is not an ideal flow, and instead we want to be able to load the hCaptcha SDK earlier
- We can load the hCaptcha SDK when the user starts interacting with any field on the edit form, like in the wikitext editor
- Because the VisualEditor "textarea" isn't actually an input element, this doesn't work out of the gate and we may need to handle VisualEditor methods to listen to when a user starts interacting with the field
- We can load the hCaptcha SDK when the user starts interacting with any field on the edit form, like in the wikitext editor
Technical notes
- We need some code that listens for when a user starts interacting with the edit field in the VisualEditor edit source mode
- If this happens then the code should check that hCaptcha will need to be completed to complete any edit (i.e. it should not worry about the case where AbuseFilter requires a captcha due a filter being matched)
- If this is also the case, then the hCaptcha SDK should be loaded
- We may need to also update the relevant utils.js file to be okay with having loadHCaptcha called multiple times and still just load it once
- Currently, calling loadHCaptcha more than once will cause the hCaptcha SDK to be loaded each time the method is called
- We may need to also update the relevant utils.js file to be okay with having loadHCaptcha called multiple times and still just load it once
Acceptance criteria
- When a user interacts with the VisualEditor editing "textarea", the hCaptcha SDK is loaded in the background via a call to loadHCaptcha from utils.js