Problem/Motivation
The Editor module tracks when an editor has modified a field, and reverts the value of a field when its editor has not made any changes. When simply adding a link to a Drupal Media item in CKEditor, the "change" event is not fired and the field is not flagged as having been changed, which will cause the field to be reverted in some conditions. Strangely, the "change" event is correctly fired when adding a link to a Drupal Image item.
Steps to reproduce
- Edit a node with a body field that uses CKEditor with the Drupal Media CKEditor plugin enabled.
- Add media to your content.
- Save the node, then go back to the edit screen.
- Click on the Drupal Media item, then click the link icon in the CKEditor toolbar and add a link to wrap the media item.
- Use the code inspector to inspect the accompanying, hidden textarea (its name will be "body[0][value]").
- The "data-editor-value-is-changed" attribute should be "true", but is not.
- Make any other changes to content -- add a line break, add some text, etc.
- Inspect the textarea again. The "data-editor-value-is-changed" is now correctly set to "true".
Proposed resolution
Add code to the Drupal Media CKEditor plugin to correctly fire the "change" event when the link value is changed.
Remaining tasks
Develop and test.
User interface changes
n/a
API changes
n/a
Data model changes
n/a
Release notes snippet
n/a
Issue fork drupal-3275613
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3275613-adding-a-link
changes, plain diff MR !2124
Comments
Comment #2
justin2pin commentedComment #4
justin2pin commentedComment #5
justin2pin commentedIncludes tests, added to CKEditorIntegrationTest::testLinkability. Ready for review.
Comment #6
joelsteidl commentedHaving recently hit this bug, I can confirm that this patch solves the issue.
Previously the only way to get adding or removing a link from a media item to work would be to change some text in the WYSIWYG, which I imagine would fire
data-editor-value-is-changedattribute.I can now simply add or remove a link to a media item and my change is registered correctly.
Comment #8
sudesh.solaskar@justin2pun and @joelsteidl the MR is not working on drupal 9.3.17. Thew patch is getting applied successfully but when i add link to media item it does not work
Comment #9
smustgrave commentedThe files in the MR no longer exist in Drupal 9.5. So the relevant code should updated not sure what files it moved to.
Comment #13
smustgrave commentedClosing the old MR for 9.4
Wonder if this is still a problem in D11? Not seeing it myself.
Comment #14
acbramley commentedI tried adding the assertions to the new test for this same functionality in CKE5 but it passed so it does seem like this may be fixed.
As it's been over 3 months since #13 I'm going to close this out, but if it is still reproducible feel free to reopen and add the steps to the IS starting from Install Drupal.