Prevent drupal links being added to embedded entities that contain links when rendered

Created on 13 June 2019, over 5 years ago
Updated 10 November 2023, about 1 year ago

Problem/Motivation

✨ Image entities/fields embedded using Entity Embed cannot be linked in CKEditor Fixed introduced the ability to directly warp embedded entities in links inside CKEditor (which is πŸŽ‰πŸŽ‰πŸŽ‰ by the way!).

However, editors tend to use whatever is available to them, and some embeddable entities might include rendered markup with links. This would lead to the ability to have <a> tags with <a> tags, which isn't ideal.

If it's feasible, it would be ideal to allow links only on entities that don't include links in their markup, when rendered.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

✨ Feature request
Status

Active

Version

1.0

Component

CKEditor integration

Created by

πŸ‡ͺπŸ‡ΈSpain marcoscano Barcelona, Spain

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.

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

    Just updated to 1.5 on Drupal 10.1.6 and I came here hoping to find an option to turn off linking on embedded entities.

    We use entity_embed exclusively for Paragraphs, which all handle links their own way. I need a way to prevent users from trying to add links around all that. Even if there was a check-and-fix for a tags within a tags before rendering, I don't want a confusing UI offering options that won't work and obscuring the options that will.

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

    Here's a super-simple patch that I think just removes the link button from the UI without touching anything else:

    t("Entity Embed toolbar"),items:["entityEmbedEdit","entityEmbedLink","editEmbeddedEntity"] becomes t("Entity Embed toolbar"),items:["entityEmbedEdit","editEmbeddedEntity"]

    (editEmbeddedEntity doesn't do anything for me but show a gear with an incorrect message about how I don't have permission to edit the entity, so I'm removing that too on my own site, but it's out-of-scope in this conversation.)

    As discussed above, I'd love to see some options built in - to turn the linking on or off entirely, or as suggested, per entity - but this will let me move ahead with my use case.

    Thanks to all who work on this! I can see that adding links was a huge effort, and just because I need it to not be there doesn't mean I don't appreciate all the time everyone put on it!

  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

    I think all the options available in ckeditor5 (edit, link, align, caption, etc.) should all be configurable on the media bundle, or view mode.

  • As Kasey_MK , we use entity embed with entity that can't contain be linked, this button must be hide in my case, it would be great to choose which entity can use it, case by cas (per example media image like it but media map in my case not).
    I put here a patch that merges #12 and another bug https://www.drupal.org/project/entity_embed/issues/3416277 πŸ› Edit the embedded entity in tab always opens the first opened entity Active (#2).
    Thanks for your patch Kasey_MK

  • The problem with @kasey_mx patch is that it replaces the build script entirely, so any new releases of this module will have the build code reverted to the specific version of this patch without you noticing it. Ideally a config option should be added for allowing or removing linking as asked above.

Production build 0.71.5 2024