Adding a link around the image doesn't work properly

Created on 14 February 2022, almost 3 years ago
Updated 10 January 2024, about 1 year ago

Problem/Motivation

When adding a link around the image, this disapears after the content in saved or also when you press "Source" button to see the html code.

Steps to reproduce

1. Add an image.
2. Add a link around the image
3. Save node or click Source button.
4. Check how the link desapears from the html code.

Proposed resolution

Don't check if element.name is an img in the upcast function to avoid the return:

          var originalUpcast = widgetDefinition.upcast;
          widgetDefinition.upcast = function(element, data) {
           if (element.name !== "img") {
              return;
              // Don't initialize on pasted fake objects.
            } else if (element.attributes["data-cke-realelement"]) {
              return;
            }

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Closed: cannot reproduce

Version

2.0

Component

Code

Created by

🇪🇸Spain semapo82 Barcelona

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.

  • 🇷🇸Serbia levmyshkin Novi Sad, Serbia

    It looks like originalUpcast.call() returns 'a' element for images:

     if (element.name !== "img") {
                  return;
                  // Don't initialize on pasted fake objects.
                } else if (element.attributes["data-cke-realelement"]) {
                  return;
                }
    
                element = originalUpcast.call(this, element, data);
    
                // Need to skip 'a' tag again.
                if (element.name === "a") {
                  return;
                }
    
Production build 0.71.5 2024