Problem/Motivation

(for quick setup, Install Umami 8.8.x)

Steps to reproduce -

1. View an article, and click on quickedit on top-right corner
2. Place the cursor anywhere in the body, and click on add-media icon
3. Select the image from media_library
4. Click on "Insert Selected"

Result -
Image is not added, and there's an error in the console

plugin.js?t=0:148 Uncaught TypeError: Cannot read property 'getAttribute' of null
    at d.upcast (plugin.js?t=0:148)
    at Array.<anonymous> (<anonymous>:29:162)
    at iterator (<anonymous>:874:440)
    at window.CKEDITOR.window.CKEDITOR.dom.CKEDITOR.htmlParser.element.forEach (<anonymous>:294:397)
    at window.CKEDITOR.window.CKEDITOR.dom.CKEDITOR.htmlParser.fragment.forEach (<anonymous>:294:498)
    at e.<anonymous> (<anonymous>:887:94)
    at e.g (<anonymous>:10:70)
    at e.<anonymous> (<anonymous>:11:433)
    at e.window.CKEDITOR.window.CKEDITOR.dom.CKEDITOR.editor.CKEDITOR.editor.fire (<anonymous>:13:97)
    at CKEDITOR.htmlDataProcessor.toHtml (<anonymous>:315:222)

https://www.youtube.com/watch?v=nOCuBPgNink

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

shaal created an issue. See original summary.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

tuan.hmt’s picture

I got the same with Drupal 8.9.1, when I clicked in the CKEditor area to edit my content, the medias was disappeared

Uncaught TypeError: Cannot read property 'getAttribute' of null
    at c.upcast (plugin.js?t=qc484m:148)
    at Array.<anonymous> (<anonymous>:29:229)
    at iterator (<anonymous>:891:88)
    at CKEDITOR.htmlParser.element.forEach (<anonymous>:303:188)
    at CKEDITOR.htmlParser.element.forEach (<anonymous>:303:289)
    at b.<anonymous> (<anonymous>:904:453)
    at b.c (<anonymous>:10:70)
    at b.<anonymous> (<anonymous>:11:433)
    at b.CKEDITOR.editor.CKEDITOR.editor.fire (<anonymous>:13:97)
    at CKEDITOR.htmlDataProcessor.toHtml (<anonymous>:323:222)

The error related to the missing the attribute named "data-media-embed-host-entity-langcode":

var hostEntityLangcode = document.getElementById(editor.name).getAttribute('data-media-embed-host-entity-langcode');

phenaproxima’s picture

Priority: Normal » Major
Status: Active » Needs work
Issue tags: +Media Initiative, +Triaged Media Initiative issue, +Needs tests, +Usability, +quick edit

This could use a test, at the very least. :)

solantoast’s picture

Status: Needs work » Needs review
StatusFileSize
new1.62 KB

I added a patch that checks the element exists before getting any attributes from it. I was then able to add images to WYSIWYG fields using quick edit without errors.

manojithape’s picture

StatusFileSize
new308.15 KB
new522.39 KB

Verified and tested patch#5 on the drupal 8.9.x version. Patch applied successfully and one observation is there...

Testing Steps:

  1. Install drupal 8.9.x umami site
  2. Create Article Content type
  3. View an article, and click on quick-edit on the top-right corner
  4. Place the cursor anywhere in the body, and click on the add-media icon
  5. Select the image from media_library
  6. Click on "Insert Selected"
  7. Observe that the selected image not added successfully and below error message displayed on the console
Uncaught TypeError: Cannot read property 'getAttribute' of null
    at c.upcast (plugin.js?t=qc484m:148)
    at Array.<anonymous> (<anonymous>:29:229)
    at iterator (<anonymous>:891:88)
    at CKEDITOR.htmlParser.element.forEach (<anonymous>:303:188)
    at CKEDITOR.htmlParser.element.forEach (<anonymous>:303:289)
    at b.<anonymous> (<anonymous>:904:453)
    at b.c (<anonymous>:10:70)
    at b.<anonymous> (<anonymous>:11:433)
    at b.CKEDITOR.editor.CKEDITOR.editor.fire (<anonymous>:13:97)
    at CKEDITOR.htmlDataProcessor.toHtml (<anonymous>:323:222)

8. Now apply given patch and again follow above steps and verify that user is able to upload media file without any error message on console.

Testing Results:
After applying the patch user is able to upload the selected image successfully and also below error not displayed on the console.

Uncaught TypeError: Cannot read property 'getAttribute' of null
    at c.upcast (plugin.js?t=qc484m:148)
    at Array.<anonymous> (<anonymous>:29:229)
    at iterator (<anonymous>:891:88)
    at CKEDITOR.htmlParser.element.forEach (<anonymous>:303:188)
    at CKEDITOR.htmlParser.element.forEach (<anonymous>:303:289)
    at b.<anonymous> (<anonymous>:904:453)
    at b.c (<anonymous>:10:70)
    at b.<anonymous> (<anonymous>:11:433)
    at b.CKEDITOR.editor.CKEDITOR.editor.fire (<anonymous>:13:97)
    at CKEDITOR.htmlDataProcessor.toHtml (<anonymous>:323:222

Observation:
The user is able to upload the image successfully but the below error displayed on the console.

Uncaught Error: Quick Edit could not associate the rendered entity field markup (with [data-quickedit-field-id="media/1/field_media_image/en/responsive_3x2"]) with the corresponding rendered entity markup: no parent DOM node found with [data-quickedit-entity-id="media/1"]. This is typically caused by the theme's template for this entity type forgetting to print the attributes.
    at processField (js_20uEPClt5OZerksYE0DzqtzDCVlOEqFOjxmu6S-NnB4.js:2170)
    at HTMLDivElement.<anonymous> (js_20uEPClt5OZerksYE0DzqtzDCVlOEqFOjxmu6S-NnB4.js:2287)
    at Function.each (js_20uEPClt5OZerksYE0DzqtzDCVlOEqFOjxmu6S-NnB4.js:2)
    at S.fn.init.each (js_20uEPClt5OZerksYE0DzqtzDCVlOEqFOjxmu6S-NnB4.js:2)
    at Object.attach (js_20uEPClt5OZerksYE0DzqtzDCVlOEqFOjxmu6S-NnB4.js:2286)
    at js_20uEPClt5OZerksYE0DzqtzDCVlOEqFOjxmu6S-NnB4.js:59
    at Array.forEach (<anonymous>)
    at Object.Drupal.attachBehaviors (js_20uEPClt5OZerksYE0DzqtzDCVlOEqFOjxmu6S-NnB4.js:56)
    at renderField (js_20uEPClt5OZerksYE0DzqtzDCVlOEqFOjxmu6S-NnB4.js:3233)
    at js_20uEPClt5OZerksYE0DzqtzDCVlOEqFOjxmu6S-NnB4.js:324
solantoast’s picture

@manojithape - I was able to get rid of that error with additional preprocessing as explained in another issue's comment: https://www.drupal.org/project/drupal/issues/3101267#comment-13711587

manojithape’s picture

@solantoast: Ok, Then we can move this ticket to RTBC by referring comments #6 and #7.

gauravvvv’s picture

StatusFileSize
new1.67 KB

@manojithape, Patch #5, is failing the Drupal CI. Please don't make RTBC when a patch is failing Drupal CI.
Re-rolled patch #5. attached interdiff for the same.
Please review.

gauravvvv’s picture

StatusFileSize
new1.43 KB
boby_ui’s picture

+1 I can confirm that patching the #9 version fixed the issue

chetanbharambe’s picture

StatusFileSize
new1.78 MB
new9.86 MB

Hi Community Members,

I have tested this issue on the 8.9.x-dev version (Umami Site)
Everything looks good to me and I don't see any errors in the console.

Testing Steps:
# Install drupal 8.9.x umami site
# Create Article Content type
# View an article and click on quick-edit on the top-right corner
# Place the cursor anywhere in the body and click on the add-media icon
# Select the image from media_library
# Click on "Insert Selected"

Here, Attaching the video and screenshots for the same which looks good to me.
Can be a move to +1 RTBC.

abhijith s’s picture

StatusFileSize
new15.36 MB
new13.08 MB

Applied patch #9 and media can be added via quick-edit after applying this patch.

Before patch:
before

After patch:
after

RTBC +1

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
zhawkins’s picture

StatusFileSize
new1.64 KB

Rerolled patch.

ranjith_kumar_k_u’s picture

StatusFileSize
new1.63 KB
new628 bytes

Fixed CS error.

Akash Kadam’s picture

StatusFileSize
new741.94 KB
new1.66 MB

#17 Patch applied successfully and media can be added via quick-edit after applying this patch.

For reference added Before Patch and After Patch Screenshots

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

aarti zikre’s picture

Version: 9.4.x-dev » 10.0.x-dev
StatusFileSize
new147.33 KB
new76.59 KB

#17 applied successfully.
Testing steps:

* Install new instance of drupal 9.4.
* Enable media and media library modules.
* Go to /admin/config/content/formats/manage/basic_html?destination=/admin/config/content/formats and drag the "Insert from Media Library" button into the CKEditor toolbar. Enable the "Embed media" filter, and click "Save configuration".
* Go to your artical click on quick edit.
* In body try to add media.

Problem:
Image is not added, and there's an error in the console

After Patch:
Problem Got resolve we can successfully add the media from quick edit.

SS for reference:

Before patch With error:
2022-08-09/3092593 before patch.png

After Patch:
2022-08-09/3092593 afterpatch.png

Test result Pass

aarti zikre’s picture

StatusFileSize
new1.66 KB

Re-rolling patch for Drupal 10.
Confirming this same issue happens in Drupal 10.

aarti zikre’s picture

Please review this

jatingupta40’s picture

Assigned: Unassigned » jatingupta40

I will review the patch.

aarti zikre’s picture

StatusFileSize
new1.66 KB

Resolve custom command

jatingupta40’s picture

Assigned: jatingupta40 » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new158.51 KB
new110.33 KB

The patch #24 applied cleanly.
Tried the working/functionality refering steps in #20 and the functionality works absolutely fine.

Before applying the patch :
The image didn't add and showed an error in the console.

After applying the patch :
The image got applied and didn't show any error on the console.

Screenshot for before and after patch applied.

Moving to RTBC.

Thanks.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

We still need tests for this change as @phenaproxima asked for in #4. Also 10.x javascript no longer has .es6.js files. Plus quickedit does not exist there (but it is in contrib).

zhawkins’s picture

StatusFileSize
new1.69 KB

Rerolled patch against 9.5.3.

lauriii’s picture

Project: Drupal core » Quick Edit
Version: 10.0.x-dev » 1.0.x-dev
Component: media system » Code
Issue tags: -Media Initiative, -Triaged Media Initiative issue

Moving to the Quick Edit issue queue since the module has been removed from core.