Add partial support for area elements ( <area href >)

Created on 21 October 2021, almost 3 years ago
Updated 7 March 2024, 6 months ago

Problem/Motivation

We have a bunch of area elements which are essentially anchor tags that allow clickable areas such as provinces or states (illustration below)

The content was migrated and the linkit attributes were added via script, that's when we noticed linkit didn't process area elements as expected. With that said, we will need an interface way to select creating an area link instead of an a anchor element. For now, we've created a patch that at least allows linkit to process area elements as expected.

Steps to reproduce

HTML for an area tag with the href="..." replaced with the linkit information using the script above:

<area shape="poly" coords="95,142,103,265,235,296,236,249,184,228,154,180,160,163,204,196,225,76" href="/node/884" data-entity-substitution="canonical" data-entity-type="node" data-entity-uuid="44c47878-da27-4dfc-9676-c9553e7732f6" alt="Northwest Territories" title="Northwest Territories">

or import such code from another cms with code similar like this section:

// Obtain url of associated drupal node to reference.

          foreach ($entity_ids as $id) {
            $entity = Node::load($id);
            $url = 'node/' . $entity->id();
            $url = Url::fromUri("base://$url")->toString();
            $str .= $url;
          }

// Linkit set-up.

          $linkit_attributes = ' data-entity-substitution="canonical"';
          $linkit_attributes .= ' data-entity-type="node"';
          $linkit_attributes .= ' data-entity-uuid="' . $entity->uuid() . '"';

          Log::msg('  Repl: ' . $str . ' with linkit attrs' . $linkit_attributes);
          return 'href="' . $str . '" ' . $linkit_attributes;

Proposed resolution

see the patch, which is a partial solution , adds area element processing correctly

Remaining tasks

review patch, in a future issue or patch, the option to select area element vs a anchor could be added, for starters lets add area processing

User interface changes

TBD

API changes

adds area element processing as if it was an anchor

Data model changes

N/A

Feature request
Status

Active

Version

5.0

Component

Code

Created by

🇨🇦Canada nancyHebert

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.

Production build 0.71.5 2024