Anchor "auto-linking" is selects too much text

Created on 17 September 2024, 3 months ago
Updated 18 September 2024, 3 months ago

Problem/Motivation

The anchor link plugin apparently attempts to "auto-link" strings that look like anchor targets, e.g. "#sometext". But it doesn't stop with the text immediately following the "#", it continues adding subsequent text to the link (and/or creates multiple links).

Probably best explained by a demo (click for full-size):

β†’

The resulting source shows that it actually creates several links to the same "anchor":

<p>
    I plan to link to a social media <a href="#hashtag,">#hashtag, but it get's</a> a<a href="#hashtag,">utolinked in a very</a> <a href="#hashtag,">suprising</a> way?
</p>

Not sure why the "a" in autolinked or the final "way" didn't make the cut.

Other than the general bugginess of the UX here, I wonder about the value of auto-linking anchors, when it seems much more likely that text that matches the format "#sometext" will end up linking to a hashtag than an anchor.

Proposed resolution

  1. Merge this PR to the northernco/ckeditor5-anchor-drupal plugin to correct the "greedy" anchor detection and linking

  2. Decide if there's value/usage for this auto-linking functionality (Handle this in a new issue?)
    1. If "yes" to #2, consider allowing auto-linking to be enabled/disabled in config
    2. If "no", remove it from the plugin entirely?

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • N/A
πŸ› Bug report
Status

RTBC

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States justcaldwell Austin, Texas

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

Comments & Activities

Production build 0.71.5 2024