Problem/Motivation

(Originally written at #2544020-28: CKEditor plugin not written with CKEditor >=4.4 in mind; rewrite it based on core's `drupalimage` plugin.)

One thing I learned from https://codepen.io/f1ames/pen/arQaYJ is https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_plugins_widget.h... — which is a single property that automatically masks the embedded content:

the widget's element will be covered with a transparent mask. This will prevent its content from being clickable, which matters in case of special elements like embedded Flash or iframes that generate a separate "context".

Yay, exactly what we need for Youtube embeds for example!

Unfortunately using that masks the entire widget, we need the caption editable to still be available for interaction in #2282957: Caption should work like the drupalimage plugin (editable in WYSIWYG, not in dialog). He came up with a clever hack to solve this: figcaption { position: relative; z-index: 1; }. 😀

Unfortunately … it doesn't work at all for us. 😩 Our combination of display: table plus float: right (for a right-aligned captioned embed) on <figure class="caption align-right"> means the widget CKEditor plugin's mask functionality doesn't work, because it relies on position: absolute; top:0; left:0; width:100%; heigh:100%; display:block; to cover the parent exactly through pure CSS. But our CSS — which we've had for more than half a decade and we cannot change since it'd break BC — makes that trick impossible.

See what happens when we just enable mask: true:

Proposed resolution

Figure out a way to use https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_plugins_widget.h... that does work.

Remaining tasks

TBD

User interface changes

Unable to interact with embedded entities.

API changes

None.

Data model changes

None.

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

Issue summary: View changes
Status: Active » Needs work
StatusFileSize
new967.27 KB
new711 bytes
wim leers’s picture

Hah, interesting. It seems the mask does work in some circumstances. Probably it works when the embedded entity is not aligned? The automated tests show that in that case, the caption is not clickable, which is where the z-index trick from the issue summary comes in :)

wim leers’s picture

Title: Add mask to prevent interaction with embedded entity » [upstream] Add mask to prevent interaction with embedded entity
Issue tags: +Needs upstream bugfix, +Needs upstream feature

I think it's reasonable to expect that this mask feature of CKEditor Widgets works in all circumstances, what we're doing here doesn't seem to be very far-fetched. The fact that Widgets supports nested editables and the mask feature doesn't support that points to an oversight/incompleteness. Which is understandable! We all have finite time. But given that the need has now clearly been established, I would hope that the CKEditor team adds support for it.

Not sure if this would be a bugfix or a feature in CKEditor, I think it can be argued either way :)

wim leers’s picture

Status: Needs work » Postponed
wim leers’s picture

This now has an upstream CKEditor issue, and is slated to ship with CKEditor 4.13: https://github.com/ckeditor/ckeditor-dev/issues/3240

wim leers’s picture

Title: [upstream] Add mask to prevent interaction with embedded entity » [PP-1] Add mask to prevent interaction with embedded entity
Issue tags: -Needs upstream bugfix, -Needs upstream feature
Related issues: +#3072382: Update CKEditor to version 4.13

CKEditor 4.13 was released today and includes that fix! So now we're blocked on Drupal core updating to CKEditor 4.13, which is happening in #3072382: Update CKEditor to version 4.13.

wim leers’s picture

Assigned: Unassigned » wim leers

I'm working with the CKEditor team. I'm running into issues doing this. Will keep you posted.

wim leers’s picture

Title: [PP-1] Add mask to prevent interaction with embedded entity » [PP-1] Add mask to prevent interaction with embedded media
Project: Entity Embed » Drupal core
Version: 8.x-1.x-dev » 8.8.x-dev
Component: CKEditor integration » action.module
Assigned: wim leers » Unassigned
Issue summary: View changes
StatusFileSize
new2.17 MB
new2.14 KB

Let's fix this first in Drupal core.

This works at least partially: a mask is created, but it still covers the entire widget:

instead of just the captioned media, despite the part being updated correctly:

I'm hoping the CKEditor team can provide guidance on how to fix this.

wim leers’s picture

StatusFileSize
new1.4 MB
wim leers’s picture

Component: action.module » media system

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

wim leers’s picture

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

wim leers’s picture

Title: [PP-1] Add mask to prevent interaction with embedded media » Add mask to prevent interaction with embedded media
Status: Postponed » Active

#3120022: Update CKEditor to version 4.14.0 landed 4 months ago, this has been unblocked since then.

phenaproxima’s picture

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.