Problem/Motivation
In the issue queue of the Disable field module, issue #3353045: Not working on CKEditor5 Text(formatted, long) was reported, that it's no longer possible to disable ckeditor fields, since CKEditor5.
With CKEditor4 it was possible to disable the text editor by adding an disabled attribute to the underlying textarea. In CKEditor5, this needs some more changes:
https://ckeditor.com/docs/ckeditor5/latest/features/read-only.html
editor.enableReadOnlyMode()
Steps to reproduce
- Visit a page with an CKEditor5 text editor.
- Make the form element disabled. e.g.
$form['editor']['#disabled'] = TRUE;
Proposed resolution
When the underlying textarea is disabled, enable read only mode.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|
Issue fork drupal-3362386
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:
Comments
Comment #3
jeroentComment #4
jeroentComment #5
jeroentComment #6
smustgrave commentedSeems test-only patch passed.
MR should probably be updated for 11.x as that's the current development branch. Could be backported from there.
Comment #7
jeroentComment #10
jeroentComment #12
jeroentComment #13
smustgrave commentedThanks for the test-only patch.
Think this is good. Could almost move to feature request though.
Comment #14
lauriiiAsked question on the MR.
Comment #15
smustgrave commentedCould we extend the tests to include an additional text field?
Comment #16
dmitry.korhovre-rolled for 10.1
Comment #17
jeroentI've tested the MR with multiple CKEditor5 fields and the MR works.
The example on https://ckeditor.com/docs/ckeditor5/latest/features/read-only.html also uses the same ID "docs-snippet", which can be found in the following js files:
https://ckeditor.com/docs/ckeditor5/latest/snippets/features/read-only-h...
https://ckeditor.com/docs/ckeditor5/latest/snippets/features/read-only/s...
Comment #18
smustgrave commentedStill think the tests should be expanded for when there are multiple ckeditors on a form and only 1 is being disabled.
Comment #19
jeroentI've extended the tests to check if it still works with multiple fields.
Comment #20
smustgrave commentedThanks!
Comment #21
jeroentComment #23
wim leersFixed nits, RTBC++ — thank you, @JeroenT!
Comment #24
lauriiiCommitted b00c941 and pushed to 11.x. Cherry-picked to 10.1.x as a non-disruptive bug fix. Thanks!
Comment #28
dmitry.korhovHi laurii,
Would be nice to respect all the contributors with credit for participating in resolving this issue.
Thanks
Comment #29
dmitry.korhovComment #30
lauriii@dmitry.korkhau Thank you for your contributions to Drupal! I agree that it would be nice to grant all participants with issue credit. However, Drupal Core maintainers are trying to encourage contributors to contribute in ways that help the issue move forward. This means that we are not granting credit for certain types of participation that are not helping the issue move forward.
In the case of #16, the issue had been converted to an MR, meaning that posting additional patches of the MR is not helping the issue move forward. For that reason, I didn't grant credit for the additional patch posted.
More information on the issue credit guidelines.
Comment #31
wim leersClosed the duplicate (but older issue 😅) at #3351984: CKEditor 5 doesn't honour #disabled: enable CKEditor 5's readonly mode.