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

Comments

wim leers’s picture

Issue tags: +CKEditor in core
wim leers’s picture

Issue tags: +Novice, +js-novice

A simple addition in ckeditor.js's Drupal.editors.ckeditor.attach should do the trick.

(We can't expect CKEditor to change this overnight, because this would constitute an API change.)

wim leers’s picture

I just got word CKEditor will support the readonly attribute starting from version 4.5.

tstoeckler’s picture

This 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!!!

tstoeckler’s picture

Status: Active » Needs review
wim leers’s picture

Status: Needs review » Reviewed & tested by the community

I 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! :)

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 4: 2275491-4-ckeditor-readonly.patch, failed testing.

wim leers’s picture

My pesky strict test coverage is the party pooper here. You'll have to update the tests, I'm afraid :)

tstoeckler’s picture

Status: Needs work » Needs review
StatusFileSize
new1.43 KB
new247 bytes

Here we go.

Reinmar’s picture

Ticket on CKEditor side: http://dev.ckeditor.com/ticket/12036

wim leers’s picture

Status: Needs review » Reviewed & tested by the community
Related issues: +#2276187: Remove the CKEditor readonly attribute support work-around

The 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.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

The patch in #9 is not a patch - it is a diff stat

wim leers’s picture

LOL!

Sorry about that, alexpott :( The interdiff is all I looked at, and was fine.

tstoeckler, quick reroll? :)

jackbravo’s picture

Issue tags: +Needs reroll

Adding 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...

tstoeckler’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new2.95 KB

Wow, 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.

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 53fa22c and pushed to 8.x. Thanks!

  • Commit 53fa22c on 8.x by alexpott:
    Issue #2275491 by tstoeckler: Fixed CKEditor does not support the "...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.