core/modules/ckeditor/js/ckeditor.js | 4 +- .../ckeditor/js/plugins/drupalimage/plugin.js | 15 ++--- .../ckeditor/Plugin/editor/editor/CKEditor.php | 2 +- core/modules/editor/editor.module | 2 +- core/modules/editor/js/editor.js | 63 +++++++++++++------- 5 files changed, 54 insertions(+), 32 deletions(-) diff --git a/core/modules/ckeditor/js/ckeditor.js b/core/modules/ckeditor/js/ckeditor.js index b931698..b95295e 100644 --- a/core/modules/ckeditor/js/ckeditor.js +++ b/core/modules/ckeditor/js/ckeditor.js @@ -15,10 +15,10 @@ Drupal.editors.ckeditor = { } delete format.editorSettings.drupalExternalPlugins; } - // Save settings that are Drupal-specific into the editor config. + // Also pass settings that are Drupal-specific. format.editorSettings.drupal = { format: format.format - } + }; return !!CKEDITOR.replace(element, format.editorSettings); }, diff --git a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js index a4e4377..508c98f 100644 --- a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js +++ b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js @@ -1,8 +1,9 @@ /** - * @file Drupal Image plugin. + * @file + * Drupal Image plugin. */ -(function ($, Drupal, drupalSettings) { +(function ($, Drupal, drupalSettings, CKEDITOR) { "use strict"; @@ -14,7 +15,7 @@ CKEDITOR.plugins.add('drupalimage', { editor.ui.addButton('DrupalImage', { label: editor.lang.common.image, command: 'image', - icon: Drupal.settings.basePath + Drupal.settings.ckeditor.modulePath + '/js/plugins/drupalimage/image.png', + icon: drupalSettings.basePath + drupalSettings.ckeditor.modulePath + '/js/plugins/drupalimage/image.png' }); // Register the image command. @@ -30,7 +31,7 @@ CKEDITOR.plugins.add('drupalimage', { // Width and height are populated by actual dimensions. var existingValues = { width: imageDOMElement ? imageDOMElement.width : '', - height: imageDOMElement ? imageDOMElement.height : '', + height: imageDOMElement ? imageDOMElement.height : '' }; // Populate all other attributes by their specified attribute values. var attribute = null; @@ -69,8 +70,8 @@ CKEDITOR.plugins.add('drupalimage', { var modalSettings = { dialogClass: 'editor-image-dialog', width: 500 - } - Drupal.editor.modalOpen(Drupal.settings.basePath + 'editor/image/nojs/' + editor.config.drupal.format, existingValues, saveCallback, modalSettings); + }; + Drupal.editor.modalOpen(drupalSettings.basePath + 'editor/image/nojs/' + editor.config.drupal.format, existingValues, saveCallback, modalSettings); }, modes: { wysiwyg : 1 }, canUndo: true @@ -115,4 +116,4 @@ function getSelectedImage (editor, element) { } } -})(jQuery, Drupal, drupalSettings); +})(jQuery, Drupal, drupalSettings, CKEDITOR); diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/editor/editor/CKEditor.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/editor/editor/CKEditor.php index 07c6a90..1efc5c7 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/editor/editor/CKEditor.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/editor/editor/CKEditor.php @@ -146,7 +146,7 @@ public function getLibraries(Editor $editor) { $libraries = array( array('ckeditor', 'drupal.ckeditor'), ); - // Add any libraries needed by individual plugins. + // Add any libraries needed by non-internal plugins. $manager = drupal_container()->get('plugin.manager.ckeditor.plugin'); $external_plugins = $manager->getEnabledPlugins($editor); foreach ($external_plugins as $plugin_id => $file) { diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 52f0c47..55f7cbb 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -98,7 +98,7 @@ function editor_library_info() { ), ); - // This library ensures that the Drupal AJAX and jQuery UI libraries are + // This library ensures that the Drupal AJAX and jQuery UI libraries are // loaded for dialogs. The JS/CSS for dialogs is included directly in the // drupal.editor library. $libraries['drupal.editor-dialog'] = array( diff --git a/core/modules/editor/js/editor.js b/core/modules/editor/js/editor.js index e27e82d..8da8a6b 100644 --- a/core/modules/editor/js/editor.js +++ b/core/modules/editor/js/editor.js @@ -94,24 +94,45 @@ Drupal.behaviors.editor = { } }; -Drupal.editor = {}; +Drupal.editor = { + + /** + * Attaches an editor to a field with a certain active text format. + * + * @param DOMNode field + * A textual field. + * @param format + * An object depending on the field's active text format, with the following + * keys: + * - format: A text format ID. + * - editor: The plugin ID of the corresponding text editor. + * - editorSettings: An object containing text editor settings. + */ + attach: function (field, format) { + if (format.editor) { + Drupal.editors[format.editor].attach(field, format); + } + }, -/** - * Attach an editor to a field. - */ -Drupal.editor.attach = function (field, format) { - if (format.editor) { - Drupal.editors[format.editor].attach(field, format); + /** + * Detaches an editor from a field with a certain trigger. + * + * @param DOMNode field + * A textual field. + * @param format + * See Drupal.editor.attach(). + * @param string trigger + * See Drupal.detachBehaviors(). + * + * @see Drupal.editor.attach() + * @see Drupal.detachBehaviors() + */ + detach: function (field, format, trigger) { + if (format.editor) { + Drupal.editors[format.editor].detach(field, format, trigger); + } } -}; -/** - * Remove an editor from a field. - */ -Drupal.editor.detach = function (field, format, trigger) { - if (format.editor) { - Drupal.editors[format.editor].detach(field, format, trigger); - } }; /** @@ -152,15 +173,15 @@ Drupal.editor.modalOpen = function (url, values, callback, callerSettings) { event: 'click', submit: { js: true, - editor_object: values, + editor_object: values } - } + }; Drupal.ajax[base] = new Drupal.ajax(base, $ajaxElement[0], ajaxSettings); $ajaxElement.triggerHandler('click'); Drupal.settings.editor.activeModal = $modal; -} +}; /** * Close a modal dialog and save its returned configuration @@ -168,14 +189,14 @@ Drupal.editor.modalOpen = function (url, values, callback, callerSettings) { Drupal.editor.modalClose = function (data) { Drupal.settings.editor.activeModal.data('saveCallback')(data); Drupal.settings.editor.activeModal.dialog('close'); -} +}; /** * Command to close and save an open modal dialog. */ Drupal.ajax.prototype.commands.editorModalSave = function (ajax, response, status) { Drupal.editor.modalClose(response.values); -} +}; /** * Command to set the title of the current modal dialog. @@ -184,6 +205,6 @@ Drupal.ajax.prototype.commands.editorModalTitle = function (ajax, response, stat if (Drupal.settings.editor.activeModal) { Drupal.settings.editor.activeModal.dialog('option', 'title', response.title); } -} +}; })(jQuery, Drupal);