Commit 53fa22cf authored by alexpott's avatar alexpott

Issue #2275491 by tstoeckler: Fixed CKEditor does not support the "readonly" attribute.

parent 6ef0c0f9
......@@ -10,6 +10,15 @@
format.editorSettings.drupal = {
format: format.format
};
// CKEditor initializes itself in a read-only state if the 'disabled'
// attribute is set. It does not respect the 'readonly' attribute,
// however, so we set the 'readOnly' configuration property manually in
// that case.
if (element.hasAttribute('readonly')) {
format.editorSettings.readOnly = true;
}
return !!CKEDITOR.replace(element, format.editorSettings);
},
......
......@@ -257,9 +257,9 @@ function editor_pre_render_format($element) {
}
// filter_process_format() copies properties to the expanded 'value' child
// element. Skip this text format widget, if it contains no 'format' or when
// the current user does not have access to edit the value.
if (!isset($element['format']) || !empty($element['value']['#disabled'])) {
// element, including the #pre_render property. Skip this text format widget,
// if it contains no 'format'.
if (!isset($element['format'])) {
return $element;
}
$format_ids = array_keys($element['format']['format']['#options']);
......
......@@ -146,11 +146,12 @@ public function testLoading() {
));
// The untrusted user tries to edit content that is written in a text format
// that (s)he is not allowed to use.
// that (s)he is not allowed to use. The editor is still loaded. CKEditor,
// for example, supports being loaded in a disabled state.
$this->drupalGet('node/1/edit');
list( , $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck();
$this->assertFalse($editor_settings_present, 'No Text Editor module settings.');
$this->assertFalse($editor_js_present, 'No Text Editor JavaScript.');
$this->assertTrue($editor_settings_present, 'Text Editor module settings.');
$this->assertTrue($editor_js_present, 'Text Editor JavaScript.');
$this->assertTrue(count($body) === 1, 'A body field exists.');
$this->assertFieldByXPath('//textarea[@id="edit-body-0-value" and @disabled="disabled"]', t('This field has been disabled because you do not have sufficient permissions to edit it.'), 'Text format access denied message found.');
$this->assertTrue(count($format_selector) === 0, 'No text format selector exists on the page.');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment