Refactor RTE embed URL check, minor fixes

What does this MR do and why?

Refactor RTE embed URL check and minor fixes.

We also:

  • show an error when you try to change an embed to a URL that doesn't match any provider. See below.
  • correctly handle the edge where embeds are enabled, but no providers ({} is truthy!).

resolveEmbed gains more users in stacked MRs (Add `<iframe>` embed insert to RTE (!265664 - merged), Detect embeddable URL in the RTE and offer to c... (!265667 - merged)).

Screenshots or screen recordings

How to set up and validate locally

The new error message is the only visible change, so we test that:

  1. Check out master.
  2. Enable the allow_iframes_in_markdown FF.
  3. Go to Admin → Settings → General → Embedded content.
  4. Check "Enable embedded content", "YouTube", and "Figma", then click "Save changes".
  5. Maybe restart your GDK/Caproni unless you're feeling the light of Providence shining upon you this day.
  6. Enter ![](https://www.youtube.com/watch?v=9MBLHvmpXqU) in a comment or WI/MR description in the plain-text editor.
  7. Switch to the rich-text editor.
  8. Click the embed, then the ✏️ icon that appears above it, and in the popup menu that opens, change the target to something unsavoury, like https://sugarstation.com.au.
  9. Click "Apply". After a moment, the popup simply vanishes, and nothing changes.
  10. Check this branch out.
  11. Repeat steps 6 through 9; instead of disappearing, you see an error like the recording above.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Asherah Connor

Merge request reports

Loading
Loading