Add a basic matcher for anchors

Created on 19 April 2021, about 3 years ago
Updated 23 May 2024, about 1 month ago

Problem/Motivation

When people add links to anchors on the same page, they get the message that Linkit could not find any suggestions. This is confusing some users, leading them to believe the anchor won't work at all.

Steps to reproduce

Add a link to an anchor, like "#example", and note that Linkit says it can't find suggestions.

Proposed resolution

Create a basic matcher for anchors that just takes anything that starts with "#" and tells people that it is an anchor.

A more advanced version of this could check within the current CKeditor window, but that might actually be more confusing for people as potentially there are other anchors on the published page that didn't come from the same CKeditor window (e.g. a page built with a lot of layout builder blocks).

Remaining tasks

A patch adding a basic anchor matcher, and a test for the same, is coming shortly. It's based off how the email matcher works.

User interface changes

This adds an optional "Anchor (basic)" matcher to the list of available matchers.

API changes

None.

Data model changes

None.

✨ Feature request
Status

RTBC

Version

7.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada kpaxman

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡§πŸ‡ͺBelgium kriboogh

    Tested and works +1
    Been 2 years, what is holding us back to get this in ?

  • Status changed to Needs review 10 months ago
  • πŸ‡ΊπŸ‡ΈUnited States mark_fullmer Tucson

    Been 2 years, what is holding us back to get this in ?

    Thanks for checking in on this. The previous maintainers of this module moved on to other things; I have taken over active maintainership since April 2023, and have been making my way through the backlog of nearly 200 issues. Since there had been no activity on this issue in 2 years, I hadn't yet seen it.

    In principle I agree with the goal of this basic matcher: "Create a basic matcher for anchors that just takes anything that starts with "#" and tells people that it is an anchor."

    This will need to be tested against the 6.x branch; active development is no longer happening in 8.x-5.x. I'll set the version number to 6.1.x and set it back to "Needs review." If someone can functionally test it against the 6.1.x branch and demonstrate that the automated test suite passes, that would be great.

  • First commit to issue fork.
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    47 pass, 2 fail
  • Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 9 months ago
    Not currently mergeable.
  • @sleitner opened merge request.
  • Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 9 months ago
    Not currently mergeable.
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 9 months ago
    84 pass
  • Status changed to RTBC 9 months ago
  • πŸ‡©πŸ‡ͺGermany sleitner

    Tested and works fine.

  • πŸ‡ΊπŸ‡ΈUnited States mark_fullmer Tucson
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Tested patch #10 and doesn't appear to be working for us. Doesn't do a search.

  • πŸ‡¨πŸ‡¦Canada kpaxman

    As noted, this is just a basic matcher. It doesn't try to search existing anchors, it just assumes anything that starts with # is an anchor.

    It could probably be extended to search anchors within an existing editor block, but I'm not sure how this would work in a field or in a layout builder environment when you have multiple blocks on a page, each potentially with anchors, not necessarily served by an editor.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    So what's the difference with ✨ Add better support for linking to anchors RTBC

  • πŸ‡¨πŸ‡¦Canada kpaxman

    While noting that it's been years since I wrote this, at a glance I would say the difference is that this tackles the first bullet point from that other ticket, which from what I can tell the other one makes no attempt to solve. This patch makes no effort to solve the other bullet point, which *does* seem to be getting solved in the other ticket.

Production build 0.69.0 2024