Problem/Motivation

When Markdown is enabled, the Drupal Media plugin from core is not working, as the <drupal-media> is stripped away.

Steps to reproduce

Install this module following the instructions from module page.
Create a new text format with markdown support.
Add the media insert toolbar item.
Try to add media and save.
Observe that media reference is not saved.

Proposed resolution

Create a plugin to bypass <drupal-media> when Markdown and DrupalMedia plugins are enabled.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

a.dmitriiev created an issue. See original summary.

a.dmitriiev’s picture

@breidert was involved in the initial implementation and concept.

a.dmitriiev’s picture

Status: Active » Needs review
breidert’s picture

Status: Needs review » Reviewed & tested by the community

I tested it locally, it works fine.

For testing I added the patch to composer.json of a local Drupal installation.

"patches": {
    "drupal/ckeditor5_markdown_editor": {
        "[https://www.drupal.org/node/3575782] - Support DrupalMedia plugin": "./patches/ckeditor5_markdown_editor_media_embed_support.patch"
    }
}

Then I re-applied the patches.

$ ddev composer patches-repatch
...
- Patching drupal/ckeditor5_markdown_editor

After this I was able to insert media elements in CKEditor with Markdown enabled. After saving and re-opening the edit form the media elements was still there.

sebastix’s picture

Awesome, thanks for this contribution.
I haven't found the time yet to give it a deep-dive looking into every piece.

Here are some my first thoughts

  • Have you considered using Vite instead of Webpack?
  • The `ckeditor5-markdown-gfm` package is downloaded/updated with the AssetManager + using drush. The package is saved in `libraries/ckeditor5/plugins`