Drupal.ckeditor5.openDialog missing existingValues param

Created on 11 August 2022, almost 2 years ago
Updated 4 May 2023, about 1 year ago

Problem/Motivation

Drupal.ckeditor.openDialog allowed passing existing values for the receiving route. In Drupal.ckeditor5.openDialog the param is missing, but it's still posting data.

CKE4:

      const ckeditorAjaxDialog = Drupal.ajax({
        dialog: dialogSettings,
        dialogType: 'modal',
        selector: '.ckeditor-dialog-loading-link',
        url,
        progress: { type: 'throbber' },
        submit: {
          editor_object: existingValues,
        },
      });
      ckeditorAjaxDialog.execute();

CKE5:

      const ckeditorAjaxDialog = Drupal.ajax({
        dialog: dialogSettings,
        dialogType: 'modal',
        selector: '.ckeditor5-dialog-loading-link',
        url,
        progress: { type: 'fullscreen' },
        submit: {
          editor_object: {},
        },
      });
      ckeditorAjaxDialog.execute();

Steps to reproduce

Try porting code from CKE4 to CKE5 which POSTs element data

Proposed resolution

Add back existingValues to the params.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ› Bug report
Status

Needs work

Version

10.1 โœจ

Component
CKEditor 5ย  โ†’

Last updated about 2 hours ago

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States mglaman WI, USA

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • JavaScript

    Affects the content, performance, or handling of Javascript.

  • Contributed project blocker

    It denotes an issue that prevents porting of a contributed project to the stable version of Drupal due to missing APIs, regressions, and so on.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฎ๐Ÿ‡ฉIndonesia el7cosmos ๐Ÿ‡ฎ๐Ÿ‡ฉ GMT+7

    This can potentially break contribs that calls this function

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany rgpublic Dรผsseldorf ๐Ÿ‡ฉ๐Ÿ‡ช ๐Ÿ‡ช๐Ÿ‡บ

    Yes, that's right. Although I wonder how many contribs actually use this. TBH, I only discovered this method due to this bug. I couldn't find any documentation on this. Neither any info on the related Drupal.ckeditor.openDialog.

    Especially due to the missing existingValues param this method (in contrast to the version for CK4) is almost useless, I guess. I resorted to a direct Drupal.ajax() call for now.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium Wim Leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    @mglaman Any chance you could write a test? ๐Ÿคž๐Ÿ™๐Ÿ˜Š

  • Assigned to mglaman
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mglaman WI, USA

    Yeah, I'll see what I can do. I'll pick this up for Monday.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada klimp Montrรฉal, QC

    Why not make existingValues the last parameter and default it to {}? This way we won't break any contrib calling this method without it

    ckeditor5.es6.js has been removed since the previous patch

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada klimp Montrรฉal, QC

    Also attaching the Drupal 9 patch version which includes ckeditor5.es6.js

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany rgpublic Dรผsseldorf ๐Ÿ‡ฉ๐Ÿ‡ช ๐Ÿ‡ช๐Ÿ‡บ

    The only argument against it would perhaps be the symmetry to the CKE4 version. But I don't really oppose the idea. Just a thought.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada klimp Montrรฉal, QC

    I see 2 options here:
    - keep the CKE4 parameters order in sake of the symmetry. Expect issues with the contrib modules calling Drupal.ckeditor5.openDialog. Not sure if there is a way to evaluate how many of them actually do that. Anyways this approach would require collaboration with the maintainers of each of those modules
    - move the existingValues param at the end and default it to {} as I did in the patches #11 and #12. Given the difference between CKE4 and CKE5 I think that the parameters inconsistency is less evil than having to adjust contrib modules

    One way or another I needed these patches in order to make the insert_view_adv contrib module work https://www.drupal.org/project/insert_view_adv/issues/3356931 ๐Ÿ› CKEditor 5 plugin doesn't default to the selected view when editing Needs work

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada b_sharpe

    I'd be in favor of option 2.

    Anyone who has used this function in CKE5 so far obviously hasn't used existing values or else would have needed a patch/custom solution, so better to keep the function backwards compatible

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium Wim Leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    The primary thing missing here is test coverage. Any takers? ๐Ÿ˜Š๐Ÿคž

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada b_sharpe

    Just adding that there isn't currently a test for this without the patch. Currently only the media library plugin calls this function in core (see core/modules/ckeditor5/ckeditor5.ckeditor5.yml)

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium Wim Leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    #17: valuable contribution, thanks ๐Ÿ˜Š That raises another question: why does the Media Library CKEditor 5 plugin in Drupal core not run into this problem? ๐Ÿค”

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany rgpublic Dรผsseldorf ๐Ÿ‡ฉ๐Ÿ‡ช ๐Ÿ‡ช๐Ÿ‡บ

    @Wim Leers. Very good question. I asked myself the same thing. The answer is: The Drupal Media Library plugin has no edit feature. If you click on the "Insert media" button a dialog is opened and you can select a media file. The media file is then inserted at the cursor position. However, there is no real way to "edit" the media file. You cannot double-click and if you highlight the media item and click on the button again, just normal dialog is opened again but the current file is not preselected. It's okay-ish I guess for this use-case. It would be nicer though, if the library would preselect the file. If you use sth. like media_directories this gets worse because you have to select the same folder again. Long story short, there currently isn't any information flow from CKEditor to the dialog - only from the dialog back to CKEditor. That's why this feature isn't needed.

  • last update about 1 year ago
    Custom Commands Failed
Production build 0.69.0 2024