diff --git a/core/modules/ckeditor/ckeditor.admin.inc b/core/modules/ckeditor/ckeditor.admin.inc index 0dff9f5..7e6bda7 100644 --- a/core/modules/ckeditor/ckeditor.admin.inc +++ b/core/modules/ckeditor/ckeditor.admin.inc @@ -57,7 +57,7 @@ function theme_ckeditor_settings_toolbar($variables) { $value = $button['image_alternative' . $rtl]; } elseif (isset($button['image'])) { - $value = theme('image', array('uri' => $button['image' . $rtl], 'title' => $button['label'])); + $value = '' . theme('image', array('uri' => $button['image' . $rtl], 'title' => $button['label'])) . ''; } else { $value = '?'; diff --git a/core/modules/ckeditor/css/ckeditor.admin.css b/core/modules/ckeditor/css/ckeditor.admin.css index 272e3ea..41af514 100644 --- a/core/modules/ckeditor/css/ckeditor.admin.css +++ b/core/modules/ckeditor/css/ckeditor.admin.css @@ -85,8 +85,10 @@ ul.ckeditor-buttons li .cke-icon-only { text-indent: -9999px; width: 16px; } -ul.ckeditor-buttons li a:focus { +ul.ckeditor-buttons li a:focus, +ul.ckeditor-multiple-buttons li a:focus { z-index: 11; /* Ensure focused buttons show their outline on all sides. */ + outline: 1px dotted #333; } ul.ckeditor-buttons li:first-child a { border-top-left-radius: 2px; /* LTR */ diff --git a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js index 9b920be..28705c1 100644 --- a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js +++ b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js @@ -78,7 +78,12 @@ CKEDITOR.plugins.add('drupalimage', { } }; - Drupal.editor.modalOpen(Drupal.settings.basePath + 'editor/image/nojs/' + editor.config.drupal.format, Drupal.t('Insert/Edit Image'), existingValues, saveCallback); + var modalSettings = { + title: Drupal.t('Insert/Edit Image'), + dialogClass: 'editor-image-dialog', + width: 500 + } + Drupal.editor.modalOpen(Drupal.settings.basePath + 'editor/image/nojs/' + editor.config.drupal.format, existingValues, saveCallback, modalSettings); }, modes: { wysiwyg : 1 }, canUndo: true @@ -151,6 +156,9 @@ CKEDITOR.plugins.add('drupalimage', { } }); +/** + * Finds an img tag anywhere in the current editor selection. + */ function getSelectedImage (editor, element) { if (!element) { var sel = editor.getSelection(); @@ -165,13 +173,22 @@ function getSelectedImage (editor, element) { } } +/** + * Given an image element, get the alignment based on precedence of display. + * + * Matching browsers, this order is: + * 1) inline style + * 2) class style + * 3) align attribute + * + * @return string|false + * A string "left", "center", "right", or "block". Or false if the image is + * not aligned at all. + */ function getImageAlignment (element) { - // Get alignment based on precedence of display used in browsers: - // 1) inline style, 2) class style, then 3) align attribute. var align = element.getStyle('float'); - if (align == 'inherit' || align == 'none') { - align = 0; + align = false; } if (!align && CKEDITOR.config.drupalimage_justifyClasses) { @@ -191,6 +208,16 @@ function getImageAlignment (element) { return align; } +/** + * Set an image alignment using classes if available, inline style otherwise. + * + * @param img + * CKEditor element for the image. + * @param value + * One of the following string values: "left", "center", "right", or "block". + * @return boolean + * Returns true if the alignment has been changed, false otherwise. + */ function setImageAlignment (img, value) { align = getImageAlignment(img); if (CKEDITOR.config.drupalimage_justifyClasses) { diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginBase.php b/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginBase.php index d1fc68f..71d93a4 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginBase.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginBase.php @@ -52,4 +52,11 @@ function getDependencies() { function getLibraries(Editor $editor) { return array(); } + + /** + * Implements \Drupal\ckeditor\Plugin\CKEditorPluginInterface::getConfig(). + */ + function getConfig(Editor $editor) { + return array(); + } } diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/ckeditor/plugin/Internal.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/ckeditor/plugin/Internal.php index 16e58c6..4988893 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/ckeditor/plugin/Internal.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/ckeditor/plugin/Internal.php @@ -48,7 +48,7 @@ public function getConfig(Editor $editor) { $config = array( 'customConfig' => '', // Don't load CKEditor's config.js file. 'pasteFromWordPromptCleanup' => TRUE, - 'removeDialogTabs' => 'image:Link;image:advanced;link:advanced', + 'removeDialogTabs' => 'link:advanced', 'resize_dir' => 'vertical', 'keystrokes' => array( // 0x11000 is CKEDITOR.CTRL, see http://docs.ckeditor.com/#!/api/CKEDITOR-property-CTRL. diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorLoadingTest.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorLoadingTest.php index 308906a..755a505 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorLoadingTest.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorLoadingTest.php @@ -90,6 +90,7 @@ function testLoading() { $ckeditor_plugin = drupal_container()->get('plugin.manager.editor')->createInstance('ckeditor'); $editor = entity_load('editor', 'filtered_html'); $expected = array('formats' => array('filtered_html' => array( + 'format' => 'filtered_html', 'editor' => 'ckeditor', 'editorSettings' => $ckeditor_plugin->getJSSettings($editor), ))); @@ -116,6 +117,7 @@ function testLoading() { $this->drupalGet('node/add/article'); list($settings, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck(); $expected = array('formats' => array('filtered_html' => array( + 'format' => 'filtered_html', 'editor' => 'ckeditor', 'editorSettings' => $ckeditor_plugin->getJSSettings($editor), ))); diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorPluginManagerTest.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorPluginManagerTest.php index fc56910..f68b6eb 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorPluginManagerTest.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorPluginManagerTest.php @@ -69,7 +69,7 @@ function testEnabledPlugins() { // Case 1: no CKEditor plugins. $definitions = array_keys($this->manager->getDefinitions()); sort($definitions); - $this->assertIdentical(array('internal', 'stylescombo'), $definitions, 'No CKEditor plugins found besides the built-in ones.'); + $this->assertIdentical(array('drupalimage', 'internal', 'stylescombo'), $definitions, 'No CKEditor plugins found besides the built-in ones.'); $this->assertIdentical(array(), $this->manager->getEnabledPlugins($editor), 'Only built-in plugins are enabled.'); $this->assertIdentical(array('internal' => NULL), $this->manager->getEnabledPlugins($editor, TRUE), 'Only the "internal" plugin is enabled.'); @@ -82,7 +82,7 @@ function testEnabledPlugins() { // Case 2: CKEditor plugins are available. $plugin_ids = array_keys($this->manager->getDefinitions()); sort($plugin_ids); - $this->assertIdentical(array('internal', 'llama', 'llama_button', 'llama_contextual', 'llama_contextual_and_button', 'stylescombo'), $plugin_ids, 'Additional CKEditor plugins found.'); + $this->assertIdentical(array('drupalimage', 'internal', 'llama', 'llama_button', 'llama_contextual', 'llama_contextual_and_button', 'stylescombo'), $plugin_ids, 'Additional CKEditor plugins found.'); $this->assertIdentical(array(), $this->manager->getEnabledPlugins($editor), 'Only the internal plugins are enabled.'); $this->assertIdentical(array('internal' => NULL), $this->manager->getEnabledPlugins($editor, TRUE), 'Only the "internal" plugin is enabled.'); diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php index a71a725..b66e19d 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php @@ -79,9 +79,12 @@ function testGetJSSettings() { 'toolbar' => $this->getDefaultToolbarConfig(), 'contentsCss' => $this->getDefaultContentsCssConfig(), 'extraPlugins' => '', + 'removePlugins' => 'image', 'language' => 'en', + 'allowedContent' => TRUE, 'drupalExternalPlugins' => array(), ); + debug($this->ckeditor->getJSSettings($editor)); $this->assertIdentical($expected_config, $this->ckeditor->getJSSettings($editor), 'Generated JS settings are correct for default configuration.'); // Customize the configuration: add button, have two contextually enabled @@ -97,6 +100,8 @@ function testGetJSSettings() { $expected_config['toolbar'][] = '/'; $expected_config['format_tags'] = 'p;h4;h5;h6'; $expected_config['extraPlugins'] = 'llama_contextual,llama_contextual_and_button'; + $expected_config['removePlugins'] = 'image'; + $expected_config['allowedContent'] = TRUE; $expected_config['drupalExternalPlugins']['llama_contextual'] = file_create_url('core/modules/ckeditor/tests/modules/js/llama_contextual.js'); $expected_config['drupalExternalPlugins']['llama_contextual_and_button'] = file_create_url('core/modules/ckeditor/tests/modules/js/llama_contextual_and_button.js'); $expected_config['contentsCss'][] = file_create_url('core/modules/ckeditor/tests/modules/ckeditor_test.css'); @@ -227,7 +232,7 @@ protected function getDefaultInternalConfig() { return array( 'customConfig' => '', 'pasteFromWordPromptCleanup' => TRUE, - 'removeDialogTabs' => 'image:Link;image:advanced;link:advanced', + 'removeDialogTabs' => 'link:advanced', 'resize_dir' => 'vertical', 'keystrokes' => array(array(0x110000 + 75, 'link'), array(0x110000 + 76, NULL)), ); diff --git a/core/modules/ckeditor/tests/modules/lib/Drupal/ckeditor_test/Plugin/ckeditor/plugin/Llama.php b/core/modules/ckeditor/tests/modules/lib/Drupal/ckeditor_test/Plugin/ckeditor/plugin/Llama.php index d2e0732..029099e 100644 --- a/core/modules/ckeditor/tests/modules/lib/Drupal/ckeditor_test/Plugin/ckeditor/plugin/Llama.php +++ b/core/modules/ckeditor/tests/modules/lib/Drupal/ckeditor_test/Plugin/ckeditor/plugin/Llama.php @@ -7,8 +7,8 @@ namespace Drupal\ckeditor_test\Plugin\ckeditor\plugin; +use Drupal\ckeditor\CKEditorPluginBase; use Drupal\ckeditor\CKEditorPluginInterface; -use Drupal\Component\Plugin\PluginBase; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; use Drupal\editor\Plugin\Core\Entity\Editor; @@ -31,14 +31,7 @@ * module = "ckeditor_test" * ) */ -class Llama extends PluginBase implements CKEditorPluginInterface { - - /** - * Implements \Drupal\ckeditor\Plugin\CKEditorPluginInterface::isInternal(). - */ - function isInternal() { - return FALSE; - } +class Llama extends CKEditorPluginBase { /** * Implements \Drupal\ckeditor\Plugin\CKEditorPluginInterface::getFile(). @@ -47,11 +40,4 @@ function getFile() { return drupal_get_path('module', 'ckeditor_test') . '/js/llama.js'; } - /** - * Implements \Drupal\ckeditor\Plugin\CKEditorPluginInterface::getButtons(). - */ - public function getConfig(Editor $editor) { - return array(); - } - } diff --git a/core/modules/editor/css/editor.css b/core/modules/editor/css/editor.css new file mode 100644 index 0000000..4f71f1a --- /dev/null +++ b/core/modules/editor/css/editor.css @@ -0,0 +1,8 @@ +/** + * @file + * Styles for text editors. + */ +.editor-image-dialog { + width: 80%; + max-width: 500px; +} diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 9519cc7..52f0c47 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -87,6 +87,9 @@ function editor_library_info() { 'js' => array( $path . '/js/editor.js' => array('group' => JS_DEFAULT), ), + 'css' => array( + $path . '/css/editor.css' => array('group' => CSS_DEFAULT), + ), 'dependencies' => array( array('system', 'jquery'), array('system', 'drupal'), diff --git a/core/modules/editor/editor.pages.inc b/core/modules/editor/editor.pages.inc index 6fc1499..70a8d13 100644 --- a/core/modules/editor/editor.pages.inc +++ b/core/modules/editor/editor.pages.inc @@ -55,6 +55,11 @@ function editor_image_form($form, $form_state, $format) { '#type' => 'textfield', '#default_value' => isset($input['src']) ? $input['src'] : '', ); + $form['attributes']['alt'] = array( + '#title' => t('Alternative text'), + '#type' => 'textfield', + '#default_value' => isset($input['alt']) ? $input['alt'] : '', + ); $form['attributes']['width'] = array( '#title' => t('Width'), '#type' => 'textfield', diff --git a/core/modules/editor/js/editor.js b/core/modules/editor/js/editor.js index cf08eaf..e6b1693 100644 --- a/core/modules/editor/js/editor.js +++ b/core/modules/editor/js/editor.js @@ -127,7 +127,7 @@ Drupal.editor.detach = function (field, format, trigger) { * When this dialog is completed, this function will receive the returned * data. */ -Drupal.editor.modalOpen = function (url, title, values, callback) { +Drupal.editor.modalOpen = function (url, values, callback, callerSettings) { // Remove any existing modal. var $modal = $('#editor-modal'); if ($modal.length) { @@ -137,10 +137,10 @@ Drupal.editor.modalOpen = function (url, title, values, callback) { // Create a new modal dialog container. $modal = $('
').hide().appendTo('body'); var $ajaxElement = $('').attr('href', url); - var modalSettings = { - modal: true, - title: title - } + var modalSettings = {}; + $.extend(modalSettings, { + modal: true + }, callerSettings); $modal.data('saveCallback', callback); $modal.html($ajaxElement);