Skip to content
Snippets Groups Projects

CKEditor5 plugin to open edit media modal

Closed Eric Smith requested to merge issue/edit_media_modal-3352274:3352274-ckeditor5 into 8.x-1.x
1 unresolved thread

The CKeditor5 model for drupalMedia includes the UUID and not the media id, so we need to be able to redirect to the edit form via UUID. This was take from how the entity_embed module provides the edit link in their plugin.

Closes #3352274

Merge request reports

Approval is optional

Closed by Eric SmithEric Smith 11 months ago (Mar 7, 2024 3:29am UTC)

Merge details

  • The changes were not merged into .

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
42 _createButton() {
43 const editor = this.editor;
44
45 editor.ui.componentFactory.add('editMediaButton', (locale) => {
46 const view = new ButtonView(locale);
47
48 view.set({
49 label: Drupal.t('Edit media'),
50 icon: icons.pencil,
51 tooltip: true,
52 });
53
54 this.listenTo(view, 'execute', (eventInfo) => {
55 const element = this.editor.model.document.selection.getSelectedElement();
56 const uuid = element.getAttribute('drupalMediaEntityUuid');
57 const editUrl = Drupal.url(`edit-media-modal/edit/${uuid}`)
  • At this point the element has the type and uuid but not the media id.

    We want to open the modal for the media id - I was hoping to get the ajax callback to work with following redirect but could not see how - so we probably want to alter the edit-media-modal/edit/${uuid} to be something like get id.

    At the moment the fetch command follows the redirect, then the ajax command requests it again - which is an expensive double up.

  • Eric Smith changed this line in version 2 of the diff

    changed this line in version 2 of the diff

  • Updated - didn't look like when using Drupal / jQuery ajax we can avoid a double call - so returning the edit form path.

  • Please register or sign in to reply
  • Eric Smith
  • Needs readme update with steps to compile plugin

  • Eric Smith
  • Eric Smith added 1 commit

    added 1 commit

    • 846fef5d - Change endpoint to return edit path - just Drupal.ckeditor.openDialog for opening modal

    Compare with previous version

  • Eric Smith added 1 commit

    added 1 commit

    • a3bc9514 - Add access check to getting the form url

    Compare with previous version

  • Eric Smith added 2 commits

    added 2 commits

    • f519b059 - CKEditor5 open dialog overrides width, stealing class from core to keep...
    • 26b5cca8 - Update README

    Compare with previous version

  • Eric Smith marked this merge request as ready

    marked this merge request as ready

  • Eric Smith added 3 commits

    added 3 commits

    Compare with previous version

  • Eric Smith added 1 commit

    added 1 commit

    • 658396f7 - Add CSS class to expand modal width

    Compare with previous version

  • Eric Smith added 4 commits

    added 4 commits

    • 2722ab20 - Typo in classname and phpcs fixes
    • dc5f9fb5 - Revert f519b059 - width still an issue, can...
    • 52339d46 - Add test for editing media within CKEditor
    • 1639b47d - Add CSS class to expand modal width

    Compare with previous version

  • closed

  • Please register or sign in to reply
    Loading