I have a Drupal 10.5.6 site using the 2.3.3 release of Editor Advanced link.

In the main, it works as expected except when the contents of my field begin with a drupal-media object (ie an image embedded via the Drupal Media tool in CKEditor. When this is the case, the "Advanced" dropdown isn't shown in the link modal widget.

If I remove the media object, save and re-edit the node, the Advanced option reappears. If I add the image back to the top of the field, the Advanced option also continues ot show until I save and re-edit again and then it is lost again. If I place anything else before the media object, even just a <p>&nbsp;</p>, save and re-edit, the Advanced link works as normal. So the issue appears to be very specifically when the field starts with the media item.

So, broken when the field is starting:
<drupal-media …></drupal-media>

Fine when the field starts:

<p>Some text</p>
<drupal-media …></drupal-media>

There is an error shown in console when the problem occurs:
ckeditor5-dll.js?v=45.2.2:5 Uncaught CKEditorError: Cannot read properties of null (reading 'linkTitle') Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-Cannot read properties of null (reading 'linkTitle') at editorAdvancedLink.js?t75cxe:1:4870 at Array.forEach (<anonymous>) at a._registerComponents (editorAdvancedLink.js?t75cxe:1:4841) at C.<anonymous> (editorAdvancedLink.js?t75cxe:1:4635) at C.fire (ckeditor5-dll.js?v=45.2.2:5:638431) at C.set [as visibleView] (ckeditor5-dll.js?v=45.2.2:5:640887) at C.remove (ckeditor5-dll.js?v=45.2.2:5:604423) at re._hideToolbar (ckeditor5-dll.js?v=45.2.2:5:711015) at re._updateToolbarsVisibility (ckeditor5-dll.js?v=45.2.2:5:710943) at n.<anonymous> (ckeditor5-dll.js?v=45.2.2:5:709678)

CommentFileSizeAuthor
#3 pop-up-msg-error.png11.32 KBdrw

Comments

steveallen74 created an issue. See original summary.

steveallen74’s picture

Title: Advanced link options not shown when the field begins with a <drupal-meida...> obkect » Advanced link options not shown when the field begins with a <drupal-media...> object
drw’s picture

StatusFileSize
new11.32 KB

After updated from 2.3.2 to 2.3.3, I have an issue related with that message on console about "Cannot read properties of null (reading 'linkTitle')"
- D10.5.6
- 2.3.3 release of Editor Advanced link
I'm working with layouts, after did click twice on image appear a pop-up error message, after that I reviewed the console and have the same message that was reported at this issue:
ckeditor5-dll.js?v=45.2.2:5 Uncaught CKEditorError: Cannot read properties of null (reading 'linkTitle')

miiimooo’s picture

I can confirm this problem (with `<drupal-entity`) and that downgrading to 2.2.0 (from 2.3.3) solves the problem

steveallen74’s picture

Many thanks @miiimooo. Reverting to 2.2.0 for now has indeed resolved the issue.

miiimooo’s picture

@steveallen74 even downgrading just to 2.3.2 works

miiimooo’s picture

richgerdes’s picture

For context here, Drupal core has a plugin that works with media and will move the href attribute from the a tag to the drupal-media element (within the ckeditor data model). There isn't a way to turn this off, but the other plugins should handle this by doing the same (copying extra link attributes from the link to the content (media or text). This seems to work fine within this module for text content, but not for media. it may require some additional logic to port those attributes?

I am currently have a range of issues with compatibility between media, editor_advanced_link, and linkit. These issues existed for me in both 2.3.2 and 2.3.3. The three together can cause some interesting behaviors. I have had an extra link appear around the media entity, i've had a tag and linkit attributes get wiped completely, and the advanced link options have been grayed out. I did find that part of the issue is media moving the Href to the drupal-media element, which prevents the options from being available. I currently have an additional issue which is when using editor advanced link to set the target for the media link, it works the first time, but then doesn't work again after that. I've posted my steps for testing that in #3383824: Target blank non checked on link edit.

I have been able to get linkit to work reliably with media, by tampering with how the attributes are handled. I haven't found a long term fix for this though. Trying to sort out the cause of this here as well.

steveallen74’s picture

I've just retested this issue after updating to the new 2.3.4 release and this is now working as expected for me in the latest version.