core/modules/ckeditor/ckeditor.module | 7 ++ core/modules/ckeditor/js/ckeditor.js | 60 ++++++++-- .../ckeditor/js/plugins/sharedspace/plugin.js | 123 ++++++++++++++++++++ .../plugins/sharedspace/samples/sharedspace.html | 119 +++++++++++++++++++ .../ckeditor/Plugin/editor/editor/CKEditor.php | 3 +- 5 files changed, 302 insertions(+), 10 deletions(-) diff --git a/core/modules/ckeditor/ckeditor.module b/core/modules/ckeditor/ckeditor.module index 08702ba..d9c0dac 100644 --- a/core/modules/ckeditor/ckeditor.module +++ b/core/modules/ckeditor/ckeditor.module @@ -277,6 +277,13 @@ function ckeditor_ckeditor_plugins() { 'enabled callback' => 'ckeditor_image_plugin_check', ); + // @see http://dev.ckeditor.com/ticket/9387 + $plugins['sharedspace'] = array( + 'path' => drupal_get_path('module', 'ckeditor') . '/js/plugins/sharedspace', + 'file' => 'plugin.js', + 'enabled callback' => TRUE, + ); + // The drupalbreak plugin provides support for Drupal's comment. $plugins['drupalbreak'] = array( 'path' => drupal_get_path('module', 'ckeditor') . '/js/plugins/drupalbreak', diff --git a/core/modules/ckeditor/js/ckeditor.js b/core/modules/ckeditor/js/ckeditor.js index d72cc04..42aff34 100644 --- a/core/modules/ckeditor/js/ckeditor.js +++ b/core/modules/ckeditor/js/ckeditor.js @@ -4,15 +4,7 @@ Drupal.editors.ckeditor = { attach: function (element, format) { - // Register additional Drupal plugins as necessary. - if (format.editorSettings.externalPlugins) { - for (var pluginName in format.editorSettings.externalPlugins) { - if (format.editorSettings.externalPlugins.hasOwnProperty(pluginName)) { - CKEDITOR.plugins.addExternal(pluginName, drupalSettings.basePath + format.editorSettings.externalPlugins[pluginName]['path'] + '/', format.editorSettings.externalPlugins[pluginName]['file']); - } - } - delete format.editorSettings.externalPlugins; - } + this._loadExternalPlugins(format); return !!CKEDITOR.replace(element, format.editorSettings); }, detach: function (element, format, trigger) { @@ -26,6 +18,56 @@ Drupal.editors.ckeditor = { } } return !!editor; + }, + onChange: function (element, callback) { + var editor = CKEDITOR.dom.element.get(element).getEditor(); + if (editor) { + var changed = function () { + callback(editor.getData()); + }; + // @todo Make this more elegant once http://dev.ckeditor.com/ticket/9794 + // is fixed. + editor.on('key', changed); + editor.on('paste', changed); + editor.on('afterCommandExec', changed); + } + return !!editor; + }, + attachInlineEditor: function (element, format, mainToolbarId, floatedToolbarId) { + this._loadExternalPlugins(format); + + var settings = $.extend(true, {}, format.editorSettings); + + // If a toolbar is already provided for "true WYSIWYG" (in-place editing), + // then use that toolbar instead: override the default settings to render + // CKEditor UI's top toolbar into mainToolbar, and don't render the bottom + // toolbar at all. (CKEditor doesn't need a floated toolbar.) + if (mainToolbarId) { + var settingsOverride = { + extraPlugins: 'sharedspace', + removePlugins: 'floatingspace,elementspath', + sharedSpaces: { + top: mainToolbarId + } + }; + settings.extraPlugins += ',' + settingsOverride.extraPlugins; + settings.removePlugins += ',' + settingsOverride.removePlugins; + settings.sharedSpaces = settingsOverride.sharedSpaces; + } + + return !!CKEDITOR.inline(element, settings); + }, + _loadExternalPlugins: function(format) { + debugger; + // Register additional Drupal plugins as necessary. + if (format.editorSettings.externalPlugins) { + for (var pluginName in format.editorSettings.externalPlugins) { + if (format.editorSettings.externalPlugins.hasOwnProperty(pluginName)) { + CKEDITOR.plugins.addExternal(pluginName, drupalSettings.basePath + format.editorSettings.externalPlugins[pluginName]['path'] + '/', format.editorSettings.externalPlugins[pluginName]['file']); + } + } + delete format.editorSettings.externalPlugins; + } } }; diff --git a/core/modules/ckeditor/js/plugins/sharedspace/plugin.js b/core/modules/ckeditor/js/plugins/sharedspace/plugin.js new file mode 100644 index 0000000..679723d --- /dev/null +++ b/core/modules/ckeditor/js/plugins/sharedspace/plugin.js @@ -0,0 +1,123 @@ +/** + * @license Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. + * For licensing, see LICENSE.html or http://ckeditor.com/license + */ + +'use strict'; + +(function() { + var containerTpl = CKEDITOR.addTemplate( 'sharedcontainer', '
+ This sample shows several editor instances that share the very same spaces for both the toolbar and the bottom bar. +
++ Aenean nonummy a, mattis varius. Cras aliquet. + Praesent magna non mattis ac, rhoncus nunc, rhoncus eget, cursus pulvinar mollis.
+Proin id nibh. Sed eu libero posuere sed, lectus. Phasellus dui gravida gravida feugiat mattis ac, felis.
+Integer condimentum sit amet, tempor elit odio, a dolor non ante at sapien. Sed ac lectus. Nulla ligula quis eleifend mi, id leo velit pede cursus arcu id nulla ac lectus. Phasellus vestibulum. Nunc viverra enim quis diam.
+Donec ullamcorper, risus tortor, pretium porttitor. Morbi quam quis lectus non leo.
+Integer faucibus scelerisque. Proin faucibus at, aliquet vulputate, odio at eros. Fusce gravida, erat vitae augue. Fusce urna fringilla gravida.
+In hac habitasse platea dictumst. Praesent wisi accumsan sit amet nibh. Maecenas orci luctus a, lacinia quam sem, posuere commodo, odio condimentum tempor, pede semper risus. Suspendisse pede. In hac habitasse platea dictumst. Nam sed laoreet sit amet erat. Integer.
+