Problem/Motivation
When both Insert media (MediaEmbed) and Drupal media (drupalMedia) buttons are in the CKEditor 5 toolbar, pasting any text into
the editor triggers:
Oops… It seems that the editor encountered an error.
The root cause is in ckeditor_media_embed.ckeditor5.yml. Even though mediaEmbed.AutoMediaEmbed is commented out, loading
mediaEmbed.MediaEmbed always forces it — because the CKEditor 5 MediaEmbed class declares it as a hard dependency via
static get
requires():
static get requires() {
return [ MediaEmbedEditing, MediaEmbedUI, AutoMediaEmbed ];
}
AutoMediaEmbed intercepts every paste event to auto-convert URLs into embeds, which conflicts with Drupal core's DrupalMedia paste
handler — causing the fatal error.
Steps to reproduce
- Enable
ckeditor_media_embedandmediamodules. - Add both Insert media (MediaEmbed) and Drupal media (drupalMedia) to a CKEditor 5 toolbar.
- Go to a node edit form using that text format.
- Paste any text into the body field.
- The editor crashes with "Oops… It seems that the editor encountered an error."
Proposed resolution
Replace mediaEmbed.MediaEmbed with its two sub-plugins directly, bypassing the forced AutoMediaEmbed dependency:
# Before:
ckeditor5:
plugins:
- mediaEmbed.MediaEmbed
# - mediaEmbed.AutoMediaEmbed
# After:
ckeditor5:
plugins:
- mediaEmbed.MediaEmbedEditing
- mediaEmbed.MediaEmbedUI
Both classes are already exported from the existing build/media-embed.js bundle. This keeps full MediaEmbed functionality — toolbar button, embed
dialog, and <oembed> rendering — without loading AutoMediaEmbed.
Remaining tasks
- ✅ File an issue
- ✅ Addition/Change/Update/Fix
- ✅ Testing to ensure no regression
- ➖ Automated unit testing coverage
- ➖ Automated functional testing coverage
- ➖ UX/UI designer responsibilities
- ➖ Readability
- ➖ Accessibility
- ➖ Performance
- ➖ Security
- ➖ Documentation
- ✅ Code review by maintainers
- ✅ Full testing and approval
- ✅ Credit contributors
- ✅ Review with the product owner
- ✅ Release notes snippet
- ✅ Release ckeditor_media_embed-2.0.6
API changes
- N/A
Data model changes
- N/A
Release notes snippet
- fix: #3579176 CKEditor 5 having Oops error on paste when both MediaEmbed and DrupalMedia buttons are in toolbar AutoMediaEmbed conflict
Comments
Comment #2
rajab natshahComment #4
rajab natshahComment #5
rajab natshah✅ Released ckeditor_media_embed-2.0.6