- Issue created by @DamienMcKenna
- Status changed to Needs review
about 1 year ago 6:15pm 6 November 2023 - Open on Drupal.org βCore: 10.1.4 + Environment: PHP 8.1 & MySQL 8last update
about 1 year ago Waiting for branch to pass - πΊπΈUnited States DamienMcKenna NH, USA
WIP, need to test to see if this covers it.
- πΊπΈUnited States m-simmons
- Status changed to RTBC
about 1 year ago 3:27pm 8 November 2023 - Status changed to Needs work
about 1 year ago 7:50pm 8 November 2023 - πΊπΈUnited States DamienMcKenna NH, USA
I can confirm that on the same site mikesimmons has the tag does not work as expected. This specific project has editor_advanced_link, which might be interfering. That said, viewing content in ckeditor 5 with an old
<a name="">
tag does not make it behave the same as clicking the anchor button and inserting a new anchor, so the plugin needs to be updated too. - πΊπΈUnited States DamienMcKenna NH, USA
FWIW at this point I'm considering writing an update script to convert existing data and training people to use the id= attribute.
Also related: β¨ Add "Anchor" button Needs work
- π¨π¦Canada dylan donkersgoed London, Ontario
A GitHub PR was opened for this at https://github.com/northernco/ckeditor5-anchor-drupal/pull/3. However, I'm not sure it's working. See the PR for details.
I've opened a new Github PR that I think addresses this issue:
https://github.com/northernco/ckeditor5-anchor-drupal/pull/9
Not sure if this implementation is the best way to go, but it seems to be working for me.
- Status changed to Needs review
12 months ago 12:46am 11 December 2023 - π¨π¦Canada dylan donkersgoed London, Ontario
I've merged in mkimmet's fix and it seems to be working for me. It discovers anchor links with the name attribute set and converts them to id anchor links, but never saves links with the deprecated attribute. Please let me know if that's not suitable for your use case/if it's not working for you. It's on the 3.0.x branch currently, but drupal.org hasn't generated the composer release yet.
This does not seem to require the patch from @DamienMcKenna, I think because it's not actually saving the attribute.
Thanks Dylan! Could we get a bump to 3.0.0-alpha2 (or some variation) on the list of releases on the project page with the new reference to the registry.npmjs.org ckeditor5-anchor-drupal-0.5.0.tgz? It seems when I reinstall the module I'm still getting 0.4.0 right now. Thanks!
Or maybe a bump to the dev version would be more appropriate, either way dev or alpha would work.
- Status changed to Needs work
11 months ago 2:16pm 18 December 2023 Moving to needs work, as I think think we need a new release on the for 3.0.x-dev (or alpha) which points to ckeditor5-anchor-drupal-0.5.0.tgz.
- Status changed to Needs review
11 months ago 7:15pm 20 December 2023 Thanks for updating the dev release Dylan! I did a test and it looks good to me. Moving back to Needs Review.
- Status changed to Needs work
6 months ago 11:02am 5 June 2024 - π©πͺGermany dbielke1986
alpha2 is not working for us.
The name attribute will be removed as soon as the Anchor Link Module is activated :-( - Status changed to Needs review
6 months ago 3:31pm 5 June 2024 - πΊπΈUnited States justcaldwell Austin, Texas
Hi, @dbielke1986. Unfortunately, the updated library is only in 3.0.x-dev. It hasn't made it to a tagged release yet. Back to NR.
On that note, we've been using dev for a couple months with no issues. I'd vote for RTBC.
- Status changed to Needs work
6 months ago 6:31am 6 June 2024 - π©πͺGermany dbielke1986
@justcaldwell
Unfortunately, I cannot confirm this. I used the dev version of βDevelopment version: 3.0.x-dev updated 20 Dec 2023 at 17:25 UTCβ and the name=" tag is removed.
- π§πͺBelgium joevagyok
You can work around this by creating your own filter plugin to ensure name tag is maintained.
class FilterAnchorLink extends FilterBase { /** * {@inheritdoc} */ public function process($text, $langcode) { $result = new FilterProcessResult($text); $dom = Html::load($text); $xpath = new \DOMXPath($dom); foreach ($xpath->query('//a') as $node) { $href = $node->getAttribute('href'); if (!empty($href)) { // If there is an "href" defined, we should not do anything. continue; } $name = $node->getAttribute('name'); if (empty($name)) { // If there is no deprecated "name" defined, we should not do anything. continue; } $id = $node->getAttribute('id'); if (!empty($id)) { // If there is an "id" defined, we should not do anything. continue; } $node->setAttribute('id', $name); } $result->setProcessedText(Html::serialize($dom)); return $result; } }
- Status changed to Needs review
6 months ago 4:09pm 6 June 2024 - πΊπΈUnited States justcaldwell Austin, Texas
Thanks for clarifying, @joevagyok!
That the name attribute doesn't survive the upcast is mentioned in a couple comments, so I updated the IS to clarify the proposed solution based on the current implementation.
Also hiding the patch from #2, as it's not necessary given the current approach.
- Status changed to RTBC
3 months ago 9:01pm 15 August 2024 - πΊπΈUnited States justcaldwell Austin, Texas
This seems to be working well β setting to RTBC. The library change for this issue actually shipped in the latest tagged release (3.0.0-beta1). So should it actually be marked as Fixed?
I also tweaked the issue summary to further clarify that name attributes are supported, but won't appear in the markup for new or edited content.
Regarding legacy content with only name attributes...If you have existing content with name attribute in the text, and you want to avoid big update path processing these texts, that needs to be converted to id attribute.
Though name is deprecated, browsers tend to support obsolete markup for a very long time. I suspect that browsers will support "named anchors" into the foreseeable future. If that's the case, I'm not sure there's any requirement to update older content to convert names to ids (at least not for the purposes of this issue).
- π§πͺBelgium joevagyok
I agree with @justcaldwell comment to move it into RTBC!
- π¬π§United Kingdom Rob230
How do I get this change into the module? I don't understand what the Github repo in PR #8 is for.
- πΊπΈUnited States justcaldwell Austin, Texas
@rob230 - this fix is actually included in the current release (3.0.0-beta1). The maintainers just haven't updated the issue status to Fixed.
- πΊπΈUnited States justcaldwell Austin, Texas
Here to eat my words π¬.
Given that there's still a large number of sites that haven't moved from CKEditor 4 (1.x and 2.x branch usage is still at ~18K), there may be a case for supporting an improved upgrade path that allows testing both CKE4 and CKE5 concurrently (see π Support concurrent use of CKEditor 4 and 5 Active ).
This would require allowing the
name
to continue to appear in the final source code. As I wrote in that issue:The plugin currently upcasts anchors with
name
attributes, but does not include thename
attribute in the resulting page source. As a result, anchor links that have been edited in CKEditor 5 will no longer be present if the text format is subsequently switched back to one using CKEditor 4.Even though
name
is deprecated, it might be preferable to continue full support for now, and remove it in a subsequent release or branch. - πΊπΈUnited States justcaldwell Austin, Texas
As I indicate in the MR, this still requires minimal changes in northernco/ckeditor5-anchor-drupal plugin. I can open a PR there if there's any interest in this.
At this point, we're just using a custom build of the plugin that resolves this and a few other issues in the queue to try to ensure a smooth transition from cke4 -> cke5.
- πΊπΈUnited States justcaldwell Austin, Texas
I opened PR 14 on northernco/ckeditor5-anchor-drupal in support of the MR here.
- πΊπΈUnited States justcaldwell Austin, Texas
Static patch of the current MR.