Unverified Commit b51ab0da authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3275237 by hooroomoo, lauriii, Wim Leers, nod_: Don't convert, instead...

Issue #3275237 by hooroomoo, lauriii, Wim Leers, nod_: Don't convert, instead use response.entity_type in DrupalImageUploadEditing
parent ce0ec61f
Loading
Loading
Loading
Loading
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+3 −7
Original line number Diff line number Diff line
@@ -5,11 +5,6 @@
 * Upload adapter.
 *
 * Copied from @ckeditor5/ckeditor5-upload/src/adapters/simpleuploadadapter
 * Adds a mapping from `response.uuid` to `dataEntityUuid` and
 * `response.entity_type` to `dataEntityType` for the callback after the file
 * upload in the `_initListeners` method.
 *
 * @todo use response.entity_type directly instead of converting it https://www.drupal.org/project/drupal/issues/3275237
 *
 * @private
 * @implements module:upload/filerepository~UploadAdapter
@@ -110,10 +105,11 @@ export default class DrupalImageUploadAdapter {
            : genericErrorText,
        );
      }
      // Resolve with the `urls` property and pass the response
      // to allow customizing the behavior of features relying on the upload adapters.
      resolve({
        response,
        urls: { default: response.url },
        dataEntityUuid: response.uuid ? response.uuid : '',
        dataEntityType: response.entity_type ? response.entity_type : '',
      });
    });

+2 −6
Original line number Diff line number Diff line
@@ -15,14 +15,10 @@ export default class DrupalImageUploadEditing extends Plugin {
    const imageUploadEditing = editor.plugins.get('ImageUploadEditing');
    imageUploadEditing.on('uploadComplete', (evt, { data, imageElement }) => {
      editor.model.change((writer) => {
        writer.setAttribute(
          'dataEntityUuid',
          data.dataEntityUuid,
          imageElement,
        );
        writer.setAttribute('dataEntityUuid', data.response.uuid, imageElement);
        writer.setAttribute(
          'dataEntityType',
          data.dataEntityType,
          data.response.entity_type,
          imageElement,
        );
      });