#12036 closed Bug (fixed)
Initialize editor in readOnly mode when textarea has readonly attribute
Reported by: | Piotrek Koszuliński | Owned by: | Artur Delura |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 4.5.0 Beta |
Component: | General | Version: | |
Keywords: | Drupal | Cc: | wim.leers@… |
Description
Initialize editor on:
<textarea readonly></textarea>
Editor should be in readOnly mode. Currently we initialize editor in readOnly mode only when textarea has disabled attribute.
https://github.com/ckeditor/ckeditor-dev/blob/master/core/editor.js#L333-L346
Change History (11)
comment:1 Changed 11 years ago by
Status: | new → confirmed |
---|
comment:2 Changed 11 years ago by
Cc: | wim.leers@… added |
---|---|
Keywords: | Drupal added |
comment:3 follow-up: 4 Changed 11 years ago by
Note that per the HTML spec disabled
and readonly
in theory have a slightly different behavior: While readonly
still allows focus to be put inside the textarea and (thus) allows the text to be selected, this is not the case for the disabled
attribute. disabled
textareas generally appear as greyed out.
Quote from the spec (2): The difference between disabled and readonly is that read-only controls are still focusable, so the user can still select the text and interact with it, whereas disabled controls are entirely non-interactive. (For this reason, only text controls can be made read-only: it wouldn't make sense for checkboxes or buttons, for instances.)
CKEditor currently only supports the readonly
behavior (despite reacting to the disabled
attribute). So the question would be whether it would make sense to add a separate "disabled" mode which would be triggered by the disabled
attribute, and have the current "readOnly" mode actually react only to the disabled
attribute? That would be an API change, though, and I don't know how such things are handled here.
Links:
- HTML 5 disabled: http://www.w3.org/TR/html5/forms.html#attr-fe-disabled
- HTML 5 readonly: http://www.w3.org/TR/html5/forms.html#the-readonly-attribute
- HTML 4 disabled and readonly: http://www.w3.org/TR/html401/interact/forms.html#h-17.12
comment:4 Changed 10 years ago by
Owner: | set to Artur Delura |
---|---|
Status: | confirmed → review |
Replying to tstoeckler:
Note that per the HTML spec
disabled
andreadonly
in theory have a slightly different behavior
In CKEditor we handle both attributes in the same way - see here.
Changes and tests in branch:t/12036.
comment:5 Changed 10 years ago by
Thanks for the update.
Wouldn't it be preferable, though, to introduce a second mode that more closely maps to the native behavior?
comment:6 Changed 10 years ago by
@tstoeckler: that's probably not possible for backwards compatibility reasons.
Thanks for the diff, @a.delura!
The patch looks super simple and good to go, except for a single indentation error?
comment:7 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | review → closed |
Editor is basically html element in contenteditable
mode. In the readOnly
mode contenteditable
attribute is removed. To support disabled
mode every HTML element, editor can be build on, should support disabled
attribute.
I rebased this ticket on the newest major, pushed small changes and closed it: git:b709b28.
comment:8 follow-up: 9 Changed 10 years ago by
To support disabled mode every HTML element, editor can be build on, should support disabled attribute.
Alternatively, we would need to imitate the disabled mode which seems to be possible, but that would require another ticket, because such feature would need to be implemented separately (as a plugin). I'm not also sure whether having such feature would be worth the effort.
I rebased this ticket on the newest major, pushed small changes and closed it: git:b709b28.
Couldn't we make the code nicer (shorter horizontally) by caching editor.element
in a variable before this line?
comment:9 Changed 10 years ago by
Couldn't we make the code nicer (shorter horizontally) by caching
editor.element
in a variable before this line?
We could. In fact we could put it here and whole onConfigLoaded
refactor this way. But there are a lot of code style changes we could do to make this method looks better.
comment:10 Changed 10 years ago by
And in the isEditorReadOnly
method any line is not longer then 120 character so making it shorter horizontally and longer vertically is the matter of taste.
comment:11 Changed 10 years ago by
Yay, this means we'll be able to close https://www.drupal.org/node/2276187 when we upgrade to CKEditor 4.5 :)
Work-around in Drupal 8 for now: https://drupal.org/node/2275491 — following and tagging this so we don't forget to remove the work-around in Drupal 8.