- Issue created by @GasparM
- 🇬🇧United Kingdom oliveyrc Hampshire
Having the same issue here, tried adding target="_blank" in source view and it gets stripped as well.
- 🇨🇭Switzerland sir_squall
Same issue there, I'm using IMCE and when we put an image in the body, and we try to add a link to it and put this in "open in a new window" option, it's not working
- 🇨🇭Switzerland sir_squall
Does anyone know if this will be prioritized? It's having a significant impact on the end user. Not being able to open external links in new windows is quite annoying.
- 🇩🇪Germany lissy
@sir_squall You are so right with "significant impact on the end user."
My customer are not amused. - 🇨🇭Switzerland sir_squall
Yes, same on my side, my client don't understand why they cannot put external link on image and opening in an external window...
I hope this issue will be solve soon.
- 🇺🇸United States quicksketch
I ran into this same issue while porting link handling to Backdrop CMS (see https://github.com/backdrop-contrib/ckeditor5/issues/54). We started with the editor_advanced_link CKEditor plugin and adapted it for modal dialogs. Normal link handling works fine, but as is the case here, it does not work to apply attributes to images.
I'm investigating this in our own module, whatever solution we find I'll try to post back here.
- 🇺🇸United States quicksketch
It looks like for the most part, all attributes are already defined that editor_advanced_link needs, and they upcast and downcast fine. What's missing is that when setting or getting attributes for a link around an image, the attributes need to come from the image model, not the anchor. CKEditors LinkImage "absorbs" the wrapping
<a>
tag into the image model.Although this is not a comprehensive solution, in
_addExtraAttributeOnLinkCommandExecute()
something like this needs to be executed when link command is fired:// If there is an image within this link, apply the link attributes to // the image model's htmlLinkAttributes attribute. const imageUtils = editor.plugins.get('ImageUtils'); const closestImage = imageUtils.getClosestSelectedImageElement(selection); if (closestImage) { const htmlLinkAttributes = { attributes: extraAttributeValues }; writer.setAttribute('htmlLinkAttributes', htmlLinkAttributes, closestImage); }
Note when setting
htmlLinkAttributes
the actual attribute names should be used (i.e.rel
orid
) rather than the model names (linkRel
orlinkId
). - 🇨🇦Canada franckylfs Montreal
Like #4, I don't know why and I can't explain it, but on some image positions it doesn't work for me either.
I'm using CKEditor 5, Linkit 6.0 and Editor Advanced Link 2.2.4 on Drupal 9.5.11.
Same problem here Ckeditor 5, linkit 6, EAL 2.2.4 and drupal 10.2.2
title and target attributes are removed, only href works in my case.- 🇨🇭Switzerland sir_squall
The issue is still there, but no one is able to help us on that, unfortunately.
- 🇲🇶Martinique wildhostile
Hi,
target='_blank' works when using text-align to center the image.
As a workaround, you can choose aligned for the image position and use text-align (as if you were aligning a paragraph text) to align the image. - 🇧🇪Belgium jonas139
Also looking into this issue and was trying the workaround from #14 which worked but it's not necessary to add a text-alignment. I've noticed that when you wrap your image in a
element, the target attribute is also working. Still looking for a better solution but maybe this will also help some people.
I have same issu with Drupal 10.2.4 and Editor Advanced link 2.2.4.
No attributes are saved.
I tried adding them manually via edit source code when I save the attributes are deleted- 🇳🇿New Zealand Gold 20 minutes in the future
I'll add my +1 to this issue. I have just stripped out all but the bare minimum to get this to appear on the bar and after ensuring that it is configured to allow all the fields it offers none make it into the HTML. Not in the Source in the editor or on the rendered page.
My scenario has this happening on the addition to the Editor File upload → field. Adding values does not survive submission of the modal. The HTML has these extra fields striped so when editing the field again they're still empty.
I stood up a SimplyTest.me instance using the Standard profile with just editor_advanced_link and the standard Link field in CKEditor had the new fields and they worked as expected.
I added Editor File upload module, enabled it, added that button to the bar, and tested. The error described was present there also.
This is feeling slightly different to the scenario of the inital report, but it feels close enough that they're likely the same issue.
- 🇳🇿New Zealand Gold 20 minutes in the future
I'm still seeing this on 2.2.4.
Also, I'm seeing this on any file, not just images.
- 🇳🇿New Zealand Gold 20 minutes in the future
Further discovery:
I'm kinda old school and things like webpack are a hurdle for me. With the assistance of a co-worker though I got this to a point where I could debug things. Just in case others are in my position...
I checked out the module from git and edited
webpack.config.js
. Inconst bc = {}
I addeddevtools: 'inline-source-map'
and commented out the wholeoptimization: {}
section. From the module dir, runningnpm i
preped things andnpm run watch
would rebuild the JS that's actually used as the source files are edited.I’ve now got it to the point where the JS is clear and breakpoints are working. I’ve added a breakpoint to the start of literally every function in the JS in this module. Loading the page shows breakpoints are working. I also have XDebug running and submitting the form does trigger a callback to Drupal and I can see it track though
_editor_advanced_link_attributes_validate()
ineditor_advanced_link.module
. What I’m not seeing is any JS being triggered in the module upon return to CKEditor.This doesn’t feel right. It would seem to me that something in the EAL JS should be pulling details from the response and populating the link that is added in the body of CKEditor.
Anyway, this is where I got to. I'll continue to poke at this when I can, but if anyone knows CKEditor 5 plugins and knows how that trigger should happen please contribute to the discussion. I'm happy to do the work, I just need pointers.
I have same issu with Drupal 10.2.5 and Editor Advanced link 2.2.4.
No attributes are saved.- 🇳🇿New Zealand Gold 20 minutes in the future
@krish1505, nuts. I was just looking at the changelog and wondering if one of the CKE updates may have resolved this. Cheers for being on top of that.
- 🇳🇿New Zealand Gold 20 minutes in the future
Hey all,
My issue with this has been around using this module with the paired editor_file module.
It is looking like this issue is very similar and may have a working patch. It isn't working for me, but others are claiming it works for them.
https://www.drupal.org/project/editor_advanced_link/issues/3416599 ✨ Edit_Advanced_Link+Editor_file: conflicting field attributes RTBC
Can people head that way and test the patch there?
- 🇮🇹Italy nicoschi
Hi there, I'm dealing with the same issue when wrapping a "drupal-media" in CKEditor using "Embed media". I'm not using editor_file, anyway i tried the patch and it doen't work form me too. What I can say in addition is that the editor advanced link doesn't keep in place any tag attribute except the target one which all of you is complaining not working
- 🇺🇸United States timurtripp
I'm interested in this as well as another CKEditor 5 plugin developer, it was brought to my attention by @SnowCoder that the advanced link attributes are getting stripped from my Icon widgets as well as Drupal Media widgets. Drupal Media seems better than Icon at preserving the
target="_blank"
specifically but always strips the other attributes liketitle
andaria-label
just like Icon. - First commit to issue fork.
- Merge request !28Issue #3280990 by DuaelFr: test that the fields are available according to the... → (Open) created by godotislate
- Status changed to Needs review
4 months ago 10:20pm 18 September 2024 Thanks to some clues from @quicksketch in #11 🐛 Link attributes don't save Needs review , I have pushed an MR that preserves the attributes set by editor advanced link when the link wraps images or Drupal media (
<drupal-media>
), as far as we have tested. It also works wrapping<drupal-entity>
when using Entity Embed in our testing so far as well.One note:
"target" = "_blank"
only does not seem to be preserved when an image is set to a link to be opened in a new window, and that image is not otherwise wrapped in another tag. I was able to reproduce in an empty editor by adding/uploading an image only and setting the image to be a link to open in a new window. The target attribute is preserved however if the image is wrapped. It mght be related to this merged CKEditor5 PR that applies to linked images and manual decorators, since Editor Advanced Link uses a manual decorator to apply the target attribute. I don't know if the issue is an edge case, but our project isn't using the image plugin, only Entity Embed and Media, so we aren't focusing on that use case in user testing on our project.- 🇧🇷Brazil viniciusrp
@godotislate I tested your merge-request and all attirbutes works except
target="_blank"
, check the source after I tried to add the Title and Target attributes.<a href="http://www.google.com" title="Test"><img src="/system/files/inline-images/Test_0.png" data-entity-uuid="8ef3e54f-3412-40f8-b253-07e1eba2dca9" data-entity-type="file" alt="Test" width="1212" height="441"></a>
The CKEditor have only the image, nothing more.