Problem/Motivation
For '#disabled' => TRUE elements Form API sets either a disabled attribute or a readonly attribute depending on whether '#allow_focus' => TRUE is also set.
CKEditor supports being loaded in a readOnly state, which behaves analogous to a regular textarea with the readonly attribute.
However, this readOnly state is only triggered when the originating textarea has the disabled attribute. The readonly attribute is ignored.
Proposed resolution
Until CKEditor handles the readonly attribute itself, we should manually initialize the readOnly state by calling editor.setReadOnly() if the readonly attribute is present on the originating element.
Remaining tasks
User interface changes
Setting '#disabled' => TRUE and '#allow_focus' => TRUE for a CKEditor-enabled textarea actually has an effect. This is not used in core currently.
API changes
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | 2275491-15-ckeditor-readonly.patch | 2.95 KB | tstoeckler |
Comments
Comment #1
wim leersComment #2
wim leersA simple addition in
ckeditor.js'sDrupal.editors.ckeditor.attachshould do the trick.(We can't expect CKEditor to change this overnight, because this would constitute an API change.)
Comment #3
wim leersI just got word CKEditor will support the
readonlyattribute starting from version 4.5.Comment #4
tstoecklerThis works for me locally.
I'm a total JS and CKEditor noob, so please be gentle. :-)
I was only able to cook this up in the first place because the CKEditor folks have quite extensive docs. Very nice!!!
Comment #5
tstoecklerComment #6
wim leersI don't think I should be gentle… because this patch is pitch-perfect, including the JS. I can't even find nitpicks!
Also manually tested this, works perfectly.
Thanks! :)
Comment #8
wim leersMy pesky strict test coverage is the party pooper here. You'll have to update the tests, I'm afraid :)
Comment #9
tstoecklerHere we go.
Comment #10
Reinmar commentedTicket on CKEditor side: http://dev.ckeditor.com/ticket/12036
Comment #11
wim leersThe changes in #9 are solid; this is really RTBC this time :)
I tagged the upstream CKEditor issue with "Drupal" and linked back here. I've opened #2276187: Remove the CKEditor readonly attribute support work-around to track it on the Drupal side.
Comment #12
alexpottThe patch in #9 is not a patch - it is a diff stat
Comment #13
wim leersLOL!
Sorry about that, alexpott :( The interdiff is all I looked at, and was fine.
tstoeckler, quick reroll? :)
Comment #14
jackbravo commentedAdding needs reroll task. In preparation for the sprint on Friday of the DrupalCon Austin.
http://www.hook42.com/blog/prepping-drupalcon-austin-sprints-sprint-lead...
Comment #15
tstoecklerWow, what a massive #fail. Sorry.
Here we go. Going straight back to RTBC, because @Wim Leers already RTBCed the interdiff and I double checked this time that the patch is actually what it's supposed to be.
Comment #16
tstoecklerComment #17
alexpottCommitted 53fa22c and pushed to 8.x. Thanks!