core/modules/ckeditor/ckeditor.module | 61 +-- core/modules/ckeditor/css/ckeditor-caption.css | 42 --- core/modules/ckeditor/css/ckeditor-iframe.css | 16 - .../ckeditor/js/plugins/drupalbreak/plugin.js | 151 -------- .../ckeditor/js/plugins/drupalcaption/plugin.js | 350 ------------------ .../ckeditor/js/plugins/drupaldialog/plugin.js | 26 -- .../ckeditor/js/plugins/drupalimage/plugin.js | 319 ---------------- .../ckeditor/js/plugins/webkitdrag/_source.css | 84 ----- .../ckeditor/js/plugins/webkitdrag/plugin.js | 387 -------------------- .../ckeditor/Plugin/editor/editor/CKEditor.php | 2 - 10 files changed, 4 insertions(+), 1434 deletions(-) diff --git a/core/modules/ckeditor/ckeditor.module b/core/modules/ckeditor/ckeditor.module index 08702ba..3587a5a 100644 --- a/core/modules/ckeditor/ckeditor.module +++ b/core/modules/ckeditor/ckeditor.module @@ -221,6 +221,10 @@ function ckeditor_ckeditor_plugins() { 'label' => t('Font style'), 'image_alternative' => '' . t('Styles') . '', ), + 'Image' => array( + 'label' => t('Image'), + 'required_tags' => array('img'), + ), 'Table' => array( 'label' => t('Table'), 'required_tags' => array('table', 'thead', 'tbody', 'tr', 'td', 'th'), @@ -256,67 +260,10 @@ function ckeditor_ckeditor_plugins() { 'internal' => TRUE, ); - // The drupalimage plugin replaces normal image functionality. - $plugins['drupalimage'] = array( - 'path' => drupal_get_path('module', 'ckeditor') . '/js/plugins/drupalimage', - 'file' => 'plugin.js', - 'buttons' => array( - 'DrupalImage' => array( - 'label' => t('Image'), - 'required_tags' => array('img'), - 'image' => $image_prefix . '/image.png', - ), - ), - ); - - // The drupalcaption plugin provides consistent behaviors for image captions. - $plugins['drupalcaption'] = array( - 'path' => drupal_get_path('module', 'ckeditor') . '/js/plugins/drupalcaption', - 'file' => 'plugin.js', - 'css' => array(drupal_get_path('module', 'ckeditor') . '/css/ckeditor-caption.css'), - 'enabled callback' => 'ckeditor_image_plugin_check', - ); - - // The drupalbreak plugin provides support for Drupal's comment. - $plugins['drupalbreak'] = array( - 'path' => drupal_get_path('module', 'ckeditor') . '/js/plugins/drupalbreak', - 'file' => 'plugin.js', - 'buttons' => array( - 'DrupalBreak' => array( - 'label' => t('Teaser break'), - 'image' => $image_prefix . '/pagebreak.png', - 'image_rtl' => $image_prefix . '/pagebreak-rtl.png', - ), - ), - ); - - // Webkit support for resizing images. - $plugins['webkitdrag'] = array( - 'path' => drupal_get_path('module', 'ckeditor') . '/js/plugins/webkitdrag', - 'file' => 'plugin.js', - 'enabled callback' => 'ckeditor_image_plugin_check', - //'css' => array(drupal_get_path('module', 'ckeditor') . '/js/plugins/webkitdrag/webkitdrag.css'), - ); - return $plugins; } /** - * Enabled callback for hook_ckeditor_plugins(). - * - * Checks if our Caption plugin should be enabled based on the configuration of - * a text format and editor. - */ -function ckeditor_image_plugin_check($editor) { - // Automatically enable caption support if the DrupalImage button is enabled. - foreach ($editor->settings['toolbar']['buttons'] as $row) { - if (in_array('DrupalImage', $row)) { - return TRUE; - } - } -} - -/** * Retrieves the default theme's CKEditor stylesheets defined in the .info file. * * Themes may specify iFrame-specific CSS files for use with CKEditor by diff --git a/core/modules/ckeditor/css/ckeditor-caption.css b/core/modules/ckeditor/css/ckeditor-caption.css deleted file mode 100644 index 5e1db46..0000000 --- a/core/modules/ckeditor/css/ckeditor-caption.css +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file - * Caption: default styling for displaying image captions. - */ - -div.caption-inner { - border: 1px solid #CCC; - padding: 4px; - background: #F3F3F3; - font-size: 0.857em; /* assuming you have a base font size of 14px, this is 12px */ - text-align: center; -} - -div.caption p { - margin: .25em 0; -} - -div.caption img, -div.caption object { - margin-bottom: 5px; - display: block; -} - -/** aligned captions **/ -div.caption-left { - float: left; - margin: 10px 10px 10px 0; -} - -div.caption-right { - float: right; - margin: 10px 0 10px 10px; -} - -div.caption-center { - display: block; - text-align: center; -} - -div.caption-center .caption-inner { - display: inline-block; -} diff --git a/core/modules/ckeditor/css/ckeditor-iframe.css b/core/modules/ckeditor/css/ckeditor-iframe.css index e3d1fd0..8dda5d0 100644 --- a/core/modules/ckeditor/css/ckeditor-iframe.css +++ b/core/modules/ckeditor/css/ckeditor-iframe.css @@ -16,19 +16,3 @@ ol,ul,dl { * (CKEditor issues #6249,#8049) */ padding: 0 40px; } - -/* The Drupal tag is only shown in iFrame based editing. */ -.cke_editable img.cke_drupal_break { - background-image: url(../images/break-handle.png); - background-position: center center; - background-repeat: no-repeat; - clear: both; - display: block; - float: none; - width: 100%; - border-top: #999999 1px dotted; - border-bottom: #999999 1px dotted; - height: 5px; - cursor: move; - margin: 10px 0; -} diff --git a/core/modules/ckeditor/js/plugins/drupalbreak/plugin.js b/core/modules/ckeditor/js/plugins/drupalbreak/plugin.js deleted file mode 100644 index 2eb0e14..0000000 --- a/core/modules/ckeditor/js/plugins/drupalbreak/plugin.js +++ /dev/null @@ -1,151 +0,0 @@ -/** - * @file Drupal teaser break plugin. - * - * This file is a placeholder until we can implements true Drupal-side dialog - * handling, pending the patch at - * - * Note that this file follows coding standards for the CKEditor project rather - * than traditional Drupal coding standards for JavaScript. This keeps - * compatibility high when adapting code between the built-in plugins and the - * custom plugins that Drupal provides. - * - * @see http://dev.ckeditor.com/wiki/CodingStyle - */ -( function() -{ - -CKEDITOR.plugins.add( 'drupalbreak', -{ - requires : [ 'fakeobjects' ], - - init : function( editor ) - { - // Register the toolbar buttons. - editor.ui.addButton( 'DrupalBreak', - { - label : Drupal.t('Insert Teaser Break'), - icon : Drupal.settings.basePath + Drupal.settings.ckeditor.modulePath + '/images/buttons/pagebreak' + (editor.lang.dir === 'rtl' ? '-rtl' : '') + '.png', - command : 'drupalbreak' - }); - - editor.addCommand( 'drupalbreak', - { - exec : function() - { - // There should be only one in document. So, look - // for an image with class "cke_drupal_break" (the fake element). - var images = editor.document.getElementsByTag( 'img' ); - for ( var i = 0, len = images.count() ; i < len ; i++ ) - { - var img = images.getItem( i ); - if ( img.hasClass( 'cke_drupal_break' ) ) - { - if ( confirm( Drupal.t( 'The document already contains a teaser break. Do you want to proceed by removing it first?' ) ) ) - { - img.remove(); - break; - } - else - return; - } - } - - insertComment( 'break' ); - } - } ); - - editor.ui.addButton( 'DrupalPageBreak', - { - label : Drupal.t( 'Insert Page Break' ), - icon : this.path + 'images/drupalpagebreak.png', - command : 'drupalpagebreak' - }); - - editor.addCommand( 'drupalpagebreak', - { - exec : function() - { - insertComment( 'pagebreak' ); - } - } ); - - // This function effectively inserts the comment into the editor. - function insertComment( text ) - { - // Create the fake element that will be inserted into the document. - // The trick is declaring it as an
, so it will behave like a - // block element (and in effect it behaves much like an
). - if ( !CKEDITOR.dom.comment.prototype.getAttribute ) { - CKEDITOR.dom.comment.prototype.getAttribute = function() { - return ''; - }; - CKEDITOR.dom.comment.prototype.attributes = { - align : '' - }; - } - var fakeElement = editor.createFakeElement( new CKEDITOR.dom.comment( text ), 'cke_drupal_' + text, 'hr' ); - - // This is the trick part. We can't use editor.insertElement() - // because we need to put the comment directly at level. - // We need to do range manipulation for that. - - // Get a DOM range from the current selection. - var range = editor.getSelection().getRanges()[0], - elementsPath = new CKEDITOR.dom.elementPath( range.getCommonAncestor( true ) ), - element = ( elementsPath.block && elementsPath.block.getParent() ) || elementsPath.blockLimit, - hasMoved; - - // If we're not in go moving the position to after the - // elements until reaching it. This may happen when inside tables, - // lists, blockquotes, etc. - while ( element && element.getName() != 'body' ) - { - range.moveToPosition( element, CKEDITOR.POSITION_AFTER_END ); - hasMoved = 1; - element = element.getParent(); - } - - // Split the current block. - if ( !hasMoved ) - range.splitBlock( 'p' ); - - // Insert the fake element into the document. - range.insertNode( fakeElement ); - - // Now, we move the selection to the best possible place following - // our fake element. - var next = fakeElement; - while ( ( next = next.getNext() ) && !range.moveToElementEditStart( next ) ) - {} - - range.select(); - } - }, - - afterInit : function( editor ) - { - // Adds the comment processing rules to the data filter, so comments - // are replaced by fake elements. - editor.dataProcessor.dataFilter.addRules( - { - comment : function( value ) - { - if ( !CKEDITOR.htmlParser.comment.prototype.getAttribute ) { - CKEDITOR.htmlParser.comment.prototype.getAttribute = function() { - return ''; - }; - CKEDITOR.htmlParser.comment.prototype.attributes = { - align : '' - }; - } - - if ( value == 'break' || value == 'pagebreak' ) - return editor.createFakeParserElement( new CKEDITOR.htmlParser.comment( value ), 'cke_drupal_' + value, 'hr' ); - - return value; - } - }); - } -}); - -})(); diff --git a/core/modules/ckeditor/js/plugins/drupalcaption/plugin.js b/core/modules/ckeditor/js/plugins/drupalcaption/plugin.js deleted file mode 100644 index afa469b..0000000 --- a/core/modules/ckeditor/js/plugins/drupalcaption/plugin.js +++ /dev/null @@ -1,350 +0,0 @@ -/** - * @file Drupal Caption plugin. - * - * Note that this file follows coding standards for the CKEditor project rather - * than traditional Drupal coding standards for JavaScript. This keeps - * compatibility high when adapting code between the built-in plugins and the - * custom plugins that Drupal provides. - * - * @see http://dev.ckeditor.com/wiki/CodingStyle - */ - -(function() -{ - -CKEDITOR.plugins.add( 'drupalcaption', -{ - requires: [ 'drupalimage' ], - - init : function( editor ) - { - - if ( editor.blockless ) - { - return; - } - - CKEDITOR.on( 'dialogDefinition', function( e ) - { - if ( e.data.name == 'image' && !e.data.definition.getContents( 'caption' ) ) - { - var infoTab = e.data.definition.getContents('info'); - infoTab.add( { - type : 'text', - id : 'captionText', - label : 'Caption', - onHide : function() - { - this.enable(); - }, - setup : function( type, element ) - { - if ( type == 1 ) - { - var el = this.getDialog().cleanImageElement, - parent = el && el.getAscendant( 'div' ), - caption; - if ( parent && ( caption = parent.getParent() ) && caption.is( 'div' ) && caption.hasClass( 'caption' ) ) - { - var next = el.getNext(), - bogus = el.getParent().getBogus(); - if ( next ) - { - this.setValue( next.getHtml() ); - if ( ( next = next.getNext() ) && !next.equals( bogus ) ) - this.disable(); - } - - var select = this.getDialog().getContentElement( 'caption', 'captionStyle' ); - select && select.setValue( caption.hasClass( 'caption-right' ) ? 'right' : - caption.hasClass( 'caption-left' ) ? 'left' : - caption.hasClass( 'caption-center' ) ? 'center' : '' ); - - this.captionElement = caption; - } - } - }, - commit : function( type, element ) - { - if ( type == 1 ) - { - var caption = this.captionElement, - sel = editor.getSelection(), - selected = sel && sel.getSelectedElement(); - - if ( selected && !selected.is( 'img' ) ) - selected = null; - - if ( !caption ) - { - if ( !this.getValue() ) - return null; - - caption = CKEDITOR.dom.element.createFromHtml( '
' ); - if ( this.linkElement ) - { - caption.insertBefore( this.linkElement ); - this.linkElement.appendTo( caption.getFirst() ); - } - else - { - if ( selected ) - { - caption.insertBefore( selected ); - selected.move( caption.getFirst(), true ); - } - else - { - editor.insertElement( caption ); - var imageElement = this.getDialog().imageElement; - setTimeout( function(){ imageElement.move( caption.getFirst(), true ); }, 0 ); - } - } - } - - if ( this.isEnabled() ) - { - if ( !this.getValue() ) - { - if ( this.linkElement ) - this.linkElement.insertAfter( caption ); - else - selected.insertAfter( caption ); - caption.remove(); - } - else if ( this.isChanged() ) - { - var inner = caption.getFirst(); - if ( inner ) - { - var bogus = inner ? inner.getBogus() : null; - bogus && bogus.remove(); - inner.getLast().setHtml( this.getValue() ); - } - } - } - - var select = this.getDialog().getContentElement( 'caption', 'captionStyle' ); - if ( select && ( !select.getValue() || !caption.hasClass( 'caption-' + select.getValue() ) ) ) - { - caption.removeClass( 'caption-right' ); - caption.removeClass( 'caption-left' ); - caption.removeClass( 'caption-center' ); - select.getValue() && caption.addClass( 'caption-' + select.getValue() ); - } - } - } - }, 'txtAlt' ); - - // Place the field after the ALT text. - var altField = infoTab.get('txtAlt') - infoTab.remove('txtAlt'); - infoTab.add(altField, 'captionText'); - } - }); - - if ( editor.addMenuItem ) - { - editor.addCommand( 'removecaption', - { - modes : { wysiwyg : 1 }, - exec : function( editor ) - { - var sel = editor.getSelection(), - caption = sel && sel.getStartElement(); - if ( !caption || !( caption = getSelectedCaption( caption ) ) ) - return null; - var inner = caption.getFirst( function( node ) - { - return node.type == CKEDITOR.NODE_ELEMENT && node.is( 'div' ) && node.hasClass( 'caption-inner' ); - }); - caption.remove( true ); - inner.getFirst( function( node ) - { - return node.type == CKEDITOR.NODE_ELEMENT && node.is( 'img' ); - }).clone().insertAfter( inner ); - inner.remove(); - } - }); - editor.addMenuItem( 'removeCaption', - { - label : 'Remove Caption', - command : 'removecaption', - group : 'div', - order : 1 - }); - editor.contextMenu.addListener( function( element, selection ) - { - if ( !element || element.isReadOnly() ) - return null; - - if ( getSelectedCaption( element ) ) - return { removeCaption : CKEDITOR.TRISTATE_OFF }; - }); - } - - if ( editor.keystrokeHandler ) - { - var ks = editor.keystrokeHandler.keystrokes, - handler = ks[ 13 ]; - editor.addCommand( 'captionEnter', - { - modes : { wysiwyg : 1 }, - editorFocus : false, - exec : function( editor ) - { - var sel = editor.getSelection(), - caption = sel && sel.getStartElement(), - range = sel && sel.getRanges()[ 0 ]; - if ( caption && ( caption = getSelectedCaption( caption ) ) ) - { - CKEDITOR.env.ie && ( CKEDITOR.env.version < 9 ) && caption.getParent().focus(); - range.moveToPosition( caption, CKEDITOR.POSITION_AFTER_END ); - range.select(); - } - return editor.execCommand( handler ); - } - }); - ks[ 13 ] = 'captionEnter'; - } - }, - - afterInit : function( editor ) - { - if ( editor.blockless ) - { - return; - } - - // Make the image button select the image when inside a captioned area. - var imageCommand = editor.getCommand( 'image' ); - if ( imageCommand ) - { - imageCommand.on( 'exec', function( evt ) - { - sel = editor.getSelection(), - element = sel && sel.getStartElement(); - var image = getSelectedCaptionImage( element ); - if ( image ) - { - sel.selectElement( image ); - } - // Give a weight of 7 so it comes before the normal image execution - }, 7); - } - - // Customize the behavior of the alignment commands for captions. - setupAlignCommand( 'left' ); - setupAlignCommand( 'right' ); - setupAlignCommand( 'center' ); - setupAlignCommand( 'block' ); - - function setupAlignCommand( value ) - { - var command = editor.getCommand( 'justify' + value ); - if ( command ) - { - command.on( 'exec', function( evt ) - { - sel = editor.getSelection(), - element = sel && sel.getStartElement(); - var caption = getSelectedCaption( element ), align; - if ( caption ) - { - // Remove the state of the previous alignment button. - previousAlignment = getCaptionAlignment( caption ); - if (previousAlignment) - { - var previousCommand = editor.getCommand( 'justify' + previousAlignment ); - if ( previousCommand.state === CKEDITOR.TRISTATE_ON) - previousCommand.setState(CKEDITOR.TRISTATE_OFF); - } - // Set alignment and activate the current alignment button. - if ( setCaptionAlignment( caption, value ) ) { - command.setState(CKEDITOR.TRISTATE_ON); - } - - // Cancel upstream changes unless displaying as block. - if ( !( value === 'block' && element.is('img') ) ) - evt.cancel(); - } - // Register this event at position 8 (default is 10) so that it fires - // before image alignment. - }, null, null, 8); - - command.on( 'refresh', function( evt ) - { - var sel = editor.getSelection(), - element = sel && sel.getStartElement(); - var caption = getSelectedCaption( element ), align; - if ( caption ) - { - align = getCaptionAlignment( caption ); - - this.setState( ( align == value ) ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF ); - - // If an image is not selected in the caption, full justify is not - // supported. - if ( value === 'block' && !element.is('img') ) - this.setState( CKEDITOR.TRISTATE_DISABLED ); - - // Don't allow further handlers to adjust the button state. - if ( !( value === 'block' && element.is('img') ) ) - evt.cancel(); - } - }, null, null, 8); - } - } - } -}); - - -function getCaptionAlignment( element ) -{ - var align = false; - var justifyClasses = [ 'caption-left', 'caption-center', 'caption-right' ]; - var justifyNames = [ 'left', 'center', 'right' ]; - for (var classPosition = 0; classPosition < 3; classPosition++) { - if (element.hasClass(justifyClasses[classPosition])) - align = justifyNames[classPosition]; - } - - return align; -} - -function getSelectedCaption( element ) -{ - while ( element && !element.hasClass( 'caption' ) ) - element = element.getAscendant( 'div' ); - return element && element.hasClass( 'caption' ) ? element : null; -} - -function getSelectedCaptionImage( element ) -{ - var caption = getSelectedCaption( element ); - if ( caption ) - { - var nodeList = caption.$.getElementsByTagName( 'img' ); - if ( nodeList.length ) - { - return new CKEDITOR.dom.element( nodeList[0] ); - } - } -} - -function setCaptionAlignment( wrapper, value ) -{ - // Check existing alignment. - var align = getCaptionAlignment( wrapper ); - - // Remove existing alignment. - wrapper.removeClass( 'caption-' + align ); - - // If changing the alignment to a new value, set the new style. - if ( value && align !== value && value !== 'block' ) - wrapper.addClass( 'caption-' + value ); - - return align !== value && value !== 'block'; -} - -})(); diff --git a/core/modules/ckeditor/js/plugins/drupaldialog/plugin.js b/core/modules/ckeditor/js/plugins/drupaldialog/plugin.js deleted file mode 100644 index b02ef8c..0000000 --- a/core/modules/ckeditor/js/plugins/drupaldialog/plugin.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @file Drupal Dialog plugin. - * - * This file is a placeholder until we can implements true Drupal-side dialog - * handling, pending the patch at - * - * Note that this file follows coding standards for the CKEditor project rather - * than traditional Drupal coding standards for JavaScript. This keeps - * compatibility high when adapting code between the built-in plugins and the - * custom plugins that Drupal provides. - * - * @see http://dev.ckeditor.com/wiki/CodingStyle - */ - -(function() -{ - -CKEDITOR.plugins.add( 'drupaldialog', -{ - init : function( editor ) - { - var pluginName = 'drupaldialog'; - } -}); - -})(); diff --git a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js deleted file mode 100644 index a8dc9f9..0000000 --- a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js +++ /dev/null @@ -1,319 +0,0 @@ -/** - * @file Drupal Image plugin. - * - * Note that this file follows coding standards for the CKEditor project rather - * than traditional Drupal coding standards for JavaScript. This keeps - * compatibility high when adapting code between the built-in plugins and the - * custom plugins that Drupal provides. - * - * @see http://dev.ckeditor.com/wiki/CodingStyle - */ - -(function() -{ - -CKEDITOR.plugins.add( 'drupalimage', -{ - // @todo: Remove dependency on normal image dialog, build Drupal-based dialog. - requires: [ 'dialog' ], - - init : function( editor ) - { - var pluginName = 'drupalimage'; - - // Register the normal image dialog. - CKEDITOR.dialog.add( 'image', Drupal.settings.basePath + Drupal.settings.ckeditor.modulePath + '/lib/ckeditor/plugins/image/dialogs/image.js' ); - - // Register the toolbar button. - editor.ui.addButton( 'DrupalImage', - { - label : editor.lang.common.image, - command : 'image', - icon : Drupal.settings.basePath + Drupal.settings.ckeditor.modulePath + '/images/buttons/image.png', - }); - - // Register the image command. - editor.addCommand( 'image', new CKEDITOR.dialogCommand( 'image' ) ); - - // Double clicking an image opens its properties. - editor.on( 'doubleclick', function( evt ) - { - var element = evt.data.element; - - if ( element.is( 'img' ) && !element.data( 'cke-realelement' ) && !element.isReadOnly() ) - evt.data.dialog = 'image'; - }); - - // If the "menu" plugin is loaded, register the menu items. - if ( editor.addMenuItems ) - { - editor.addMenuItems( - { - image : - { - label : editor.lang.image.menu, - command : 'image', - group : 'image' - } - }); - } - - // If the "contextmenu" plugin is loaded, register the listeners. - if ( editor.contextMenu ) - { - editor.contextMenu.addListener( function( element, selection ) - { - if ( getSelectedImage( editor, element ) ) - return { image : CKEDITOR.TRISTATE_OFF }; - }); - } - - // Customize the built-in dialog for images. - CKEDITOR.on( 'dialogDefinition', function( evt ) { - if ( evt.data.name == 'image' ) - { - var infoPane = evt.data.definition.getContents('info'); - - // Remove unneeded options that write style attributes. - infoPane.remove('txtHSpace'); - infoPane.remove('txtVSpace'); - infoPane.remove('txtBorder'); - - // Add option for center alignment if supported. - var alignOption = infoPane.get('cmbAlign'); - if ( CKEDITOR.config.drupalimage_justifyClasses ) - alignOption.items.push([ editor.lang.common.alignCenter, 'center' ]); - - // Adjust the alignment options to use our alignment classes. - alignOption.setup = function ( type, element ) { - // Set alignment value based on active alignment state. - var value = ''; - var possibleButtons = [ 'left', 'center', 'right', 'block' ]; - for (var n = 0; n < 4; n++) { - var currentCommand = editor.getCommand('justify' + possibleButtons[n]); - if ( currentCommand && currentCommand.state === CKEDITOR.TRISTATE_ON ) - value = possibleButtons[n]; - } - if ( value ) - this.setValue( value ); - this.setupValue = value; - } - alignOption.commit = function( type, element, internalCommit ) { - // Constants from image plugin dialog.js. - var IMAGE = 1, LINK = 2, PREVIEW = 4, CLEANUP = 8; - var value = this.getValue(); - switch ( type ) - { - case IMAGE: - if ( value !== this.setupValue ) - { - if ( value ) - { - var alignCommand = editor.getCommand('justify' + value ); - if ( alignCommand.state === CKEDITOR.TRISTATE_OFF ) - alignCommand.exec(); - } - else if ( this.setupValue ) - { - var alignCommand = editor.getCommand('justify' + this.setupValue ); - if ( alignCommand.state === CKEDITOR.TRISTATE_ON ) - alignCommand.exec(); - } - } - break; - case PREVIEW: - setImageAlignment( element, value ); - break; - case CLEANUP: - setImageAlignment( element, false ); - break; - } - } - } - }); - - }, - afterInit : function( editor ) - { - // Use normal height/width attributes for images instead of styles (#5547). - // We may be able to remove this code once Drupal provides its own modal - // dialogs for manipulating images, but resizing an image via resize handles - // may make it necessary still. - var dataProcessor = editor.dataProcessor; - var htmlFilter = dataProcessor && dataProcessor.htmlFilter; - htmlFilter.addRules( - { - elements : - { - img : function( element ) - { - var style = element.attributes.style, match, width, height; - if ( style ) - { - // Get the width from the style. - match = /(?:^|\s)width\s*:\s*(\d+)px/i.exec( style ), - width = match && match[1]; - // Get the height from the style. - match = /(?:^|\s)height\s*:\s*(\d+)px/i.exec( style ); - height = match && match[1]; - if ( width.length ) - { - style = style.replace( /(?:^|\s)width\s*:\s*(\d+)px;?/i , '' ); - element.attributes.width = width; - } - if ( height.length ) - { - style = style.replace( /(?:^|\s)height\s*:\s*(\d+)px;?/i , '' ); - element.attributes.height = height; - } - if (style) - element.attributes.style = style; - else - delete element.attributes.style; - } - } - } - } - ); - - // Customize the behavior of the alignment commands. (#7430) - setupAlignCommand( 'left' ); - setupAlignCommand( 'right' ); - setupAlignCommand( 'center' ); - setupAlignCommand( 'block' ); - - function setupAlignCommand( value ) - { - var command = editor.getCommand( 'justify' + value ); - if ( command ) - { - command.on( 'exec', function( evt ) - { - var img = getSelectedImage( editor ), align; - if ( img ) - { - // Remove the state of the previous alignment button. - previousAlignment = getImageAlignment( img ); - if (previousAlignment) - { - var previousCommand = editor.getCommand( 'justify' + previousAlignment ); - if ( previousCommand.state === CKEDITOR.TRISTATE_ON) - previousCommand.setState(CKEDITOR.TRISTATE_OFF); - } - // Set alignment and activate the current alignment button. - if ( setImageAlignment( img, value ) ) { - command.setState(CKEDITOR.TRISTATE_ON); - } - evt.cancel(); - } - }); - - command.on( 'refresh', function( evt ) - { - var img = getSelectedImage( editor ), align; - if ( img ) - { - align = getImageAlignment( img ); - - this.setState( - ( align == value ) ? CKEDITOR.TRISTATE_ON : - ( CKEDITOR.config.drupalimage_justifyClasses || value == 'right' || value == 'left' ) ? CKEDITOR.TRISTATE_OFF : - CKEDITOR.TRISTATE_DISABLED ); - - evt.cancel(); - } - }); - } - } - } -}); - -function getSelectedImage( editor, element ) -{ - if ( !element ) - { - var sel = editor.getSelection(); - var selectedText = sel.getSelectedText().replace(/^\s\s*/, '').replace(/\s\s*$/, ''); - var isElement = sel.getType() === CKEDITOR.SELECTION_ELEMENT; - var isEmptySelection = sel.getType() === CKEDITOR.SELECTION_TEXT && selectedText.length === 0; - element = ( isElement || isEmptySelection ) && sel.getSelectedElement(); - } - - if ( element && element.is( 'img' ) && !element.data( 'cke-realelement' ) && !element.isReadOnly() ) - return element; -} - -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; - - if ( !align && CKEDITOR.config.drupalimage_justifyClasses ) { - var justifyClasses = CKEDITOR.config.drupalimage_justifyClasses; - var justifyNames = [ 'left', 'center', 'right', 'block' ]; - for (var classPosition = 0; classPosition < 4; classPosition++) { - if (element.hasClass(justifyClasses[classPosition])) - align = justifyNames[classPosition]; - } - } - - if ( !align ) - align = element.getAttribute( 'align' ); - - return align; -} - -function setImageAlignment( img, value ) -{ - align = getImageAlignment( img ); - if ( CKEDITOR.config.drupalimage_justifyClasses ) - { - var justifyClasses = CKEDITOR.config.drupalimage_justifyClasses; - var justifyNames = [ 'left', 'center', 'right', 'block' ]; - var justifyOldPosition = CKEDITOR.tools.indexOf( justifyNames, align ); - var justifyOldClassName = justifyOldPosition === -1 ? null : justifyClasses[justifyOldPosition]; - var justifyNewPosition = CKEDITOR.tools.indexOf( justifyNames, value ); - var justifyNewClassName = justifyNewPosition === -1 ? null : justifyClasses[justifyNewPosition]; - } - - // If this image is already aligned, remove existing alignment. - if ( align ) - { - img.removeStyle( 'float' ); - img.removeAttribute( 'align' ); - if ( justifyOldClassName ) - img.removeClass( justifyOldClassName ); - } - - // If changing the alignment to a new value, set the new style. - if ( value && align !== value ) - { - if ( justifyNewClassName ) - img.addClass( justifyNewClassName ); - else - img.setStyle( 'float', value ); - } - - return align !== value; -} - -})(); - -/** - * List of classes to use for aligning images. Each class will be used when - * an image is selected and the normal justify toolbar buttons are clicked. The - * array of classes should contain 4 members, in the following order: left, - * center, right, justify. If the list of classes is null, CSS style attributes - * will be used instead. - * - * @type Array - * @default true - * @example - * // Disable the list of classes and use styles instead. - * config.drupalimage_justifyClasses = null; - */ -CKEDITOR.config.drupalimage_justifyClasses = [ 'align-left', 'align-center', 'align-right', 'full-width' ]; diff --git a/core/modules/ckeditor/js/plugins/webkitdrag/_source.css b/core/modules/ckeditor/js/plugins/webkitdrag/_source.css deleted file mode 100644 index b4d0139..0000000 --- a/core/modules/ckeditor/js/plugins/webkitdrag/_source.css +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Unminified CSS Source - * This css file is not required for the plugin, because the styles - * are minified and hard-coded in plugin.js - * - */ - -img::selection { - color: rgba(0, 0, 0, 0); -} - -img.cke-resize { - outline: 1px dashed #000; -} - -#ckimgrsz { - position: absolute; - width: 0; - height: 0; - cursor: default; -} - -#ckimgrsz .preview { - position: absolute; - top: 0; - left: 0; - width: 0; - height: 0; - background-size: 100% 100%; - opacity: .65; - outline: 1px dashed #000; -} - -#ckimgrsz span { - position: absolute; - width: 5px; - height: 5px; - background: #fff; - border: 1px solid #000; -} - -#ckimgrsz span:hover, #ckimgrsz span.active { - background: #000; -} - -#ckimgrsz span.tl, -#ckimgrsz span.br { - cursor: nwse-resize; -} - -#ckimgrsz span.tm, -#ckimgrsz span.bm { - cursor: ns-resize; -} - -#ckimgrsz span.tr, -#ckimgrsz span.bl { - cursor: nesw-resize; -} - -#ckimgrsz span.lm, -#ckimgrsz span.rm { - cursor: ew-resize; -} - -body.dragging-tl, body.dragging-tl *, -body.dragging-br, body.dragging-br * { - cursor: nwse-resize !important; -} - -body.dragging-tm, body.dragging-tm *, -body.dragging-bm, body.dragging-bm * { - cursor: ns-resize !important; -} - -body.dragging-tr, body.dragging-tr *, -body.dragging-bl, body.dragging-bl * { - cursor: nesw-resize !important; -} - -body.dragging-lm, body.dragging-lm *, -body.dragging-rm, body.dragging-rm * { - cursor: ew-resize !important; -} diff --git a/core/modules/ckeditor/js/plugins/webkitdrag/plugin.js b/core/modules/ckeditor/js/plugins/webkitdrag/plugin.js deleted file mode 100755 index f746d1c..0000000 --- a/core/modules/ckeditor/js/plugins/webkitdrag/plugin.js +++ /dev/null @@ -1,387 +0,0 @@ -/** - * CKEditor plugin: Dragable image resizing for Webkit - * - Shows semi-transparent overlay while resizing - * - Enforces Aspect Ratio (unless holding shift) - * - Snap to size of other images in editor - * - Escape while dragging cancels resize - * - */ -(function() { - "use strict"; - - var PLUGIN_NAME = 'webkitdrag'; - - var IMAGE_SNAP_TO_SIZE = 7; - - /** - * Initializes the plugin - */ - CKEDITOR.plugins.add(PLUGIN_NAME, { - onLoad: function() { - // This plugin only applies to Webkit. - if (!CKEDITOR.env.webkit) { - return; - } - - // CSS is added in a compressed form - CKEDITOR.addCss('img::selection{color:rgba(0,0,0,0)}img.cke-resize {outline: 1px dashed #000}#ckimgrsz{position:absolute;width:0;height:0;cursor:default}#ckimgrsz .preview{position:absolute;top:0;left:0;width:0;height:0;background-size:100% 100%;opacity:.65;outline:1px dashed #000}#ckimgrsz span{position:absolute;width:5px;height:5px;background:#fff;border:1px solid #000}#ckimgrsz span:hover,#ckimgrsz span.active{background:#000}#ckimgrsz span.tl,#ckimgrsz span.br{cursor:nwse-resize}#ckimgrsz span.tm,#ckimgrsz span.bm{cursor:ns-resize}#ckimgrsz span.tr,#ckimgrsz span.bl{cursor:nesw-resize}#ckimgrsz span.lm,#ckimgrsz span.rm{cursor:ew-resize}body.dragging-tl,body.dragging-tl *,body.dragging-br,body.dragging-br *{cursor:nwse-resize!important}body.dragging-tm,body.dragging-tm *,body.dragging-bm,body.dragging-bm *{cursor:ns-resize!important}body.dragging-tr,body.dragging-tr *,body.dragging-bl,body.dragging-bl *{cursor:nesw-resize!important}body.dragging-lm,body.dragging-lm *,body.dragging-rm,body.dragging-rm *{cursor:ew-resize!important}'); - }, - init: function(editor) { - // This plugin only applies to Webkit - if (!CKEDITOR.env.webkit) { - return; - } - //onDomReady handler - editor.on('contentDom', function(evt) { - init(editor); - }); - } - }); - - function init(editor) { - var window = editor.window.$, document = editor.document.$, body = document.body; - var snapToSize = (typeof IMAGE_SNAP_TO_SIZE == 'undefined') ? null : IMAGE_SNAP_TO_SIZE; - - function DragEvent() { - this.events = { - mousemove: bind(this.mousemove, this), - keydown: bind(this.keydown, this), - mouseup: bind(this.mouseup, this) - }; - } - - DragEvent.prototype = { - start: function(e) { - if (e.button !== 0) { - //right-click or middle-click - return; - } - e.preventDefault(); - e.stopPropagation(); - this.target = e.target; - this.attr = e.target.className; - this.startPos = {x: e.clientX, y: e.clientY}; - this.update(e); - var events = this.events; - document.addEventListener('mousemove', events.mousemove, false); - document.addEventListener('keydown', events.keydown, false); - document.addEventListener('mouseup', events.mouseup, false); - body.className += ' dragging-' + this.attr; - this.onStart && this.onStart(); - }, - update: function(e) { - this.currentPos = {x: e.clientX, y: e.clientY}; - this.delta = {x: e.clientX - this.startPos.x, y: e.clientY - this.startPos.y}; - this.keys = {shift: e.shiftKey, ctrl: e.ctrlKey, alt: e.altKey}; - }, - mousemove: function(e) { - this.update(e); - this.onDrag && this.onDrag(); - if (e.which === 0) { - //mouse button released outside window; mouseup wasn't fired (Chrome) - this.mouseup(e); - } - }, - keydown: function(e) { - //escape key cancels dragging - if (e.keyCode == 27) { - this.release(); - } - }, - mouseup: function(e) { - this.update(e); - this.release(); - this.onComplete && this.onComplete(); - }, - release: function() { - body.className = body.className.replace('dragging-' + this.attr, ''); - var events = this.events; - document.removeEventListener('mousemove', events.mousemove, false); - document.removeEventListener('keydown', events.keydown, false); - document.removeEventListener('mouseup', events.mouseup, false); - this.onRelease && this.onRelease(); - } - }; - - function Resizer(element) { - this.el = element; - this.events = { - initDrag: bind(this.initDrag, this) - }; - this.init(); - this.show(); - } - - Resizer.prototype = { - init: function() { - var old = Resizer.instance; - Resizer.instance = this; - if (old) { - //reuse existing dom elements - old.hide(); - this.container = old.container; - this.preview = old.preview; - this.handles = old.handles; - return; - } - var container = this.container = document.createElement('div'); - container.id = 'ckimgrsz'; - var preview = this.preview = document.createElement('div'); - preview.className = 'preview'; - container.appendChild(preview); - var handles = this.handles = {}; - handles.tl = document.createElement('span'); - handles.tl.className = 'tl'; - handles.tm = document.createElement('span'); - handles.tm.className = 'tm'; - handles.tr = document.createElement('span'); - handles.tr.className = 'tr'; - handles.lm = document.createElement('span'); - handles.lm.className = 'lm'; - handles.rm = document.createElement('span'); - handles.rm.className = 'rm'; - handles.bl = document.createElement('span'); - handles.bl.className = 'bl'; - handles.bm = document.createElement('span'); - handles.bm.className = 'bm'; - handles.br = document.createElement('span'); - handles.br.className = 'br'; - for (var n in handles) { - container.appendChild(handles[n]); - } - }, - show: function() { - if (snapToSize) { - this.otherImages = toArray(document.getElementsByTagName('img')); - this.otherImages.splice(this.otherImages.indexOf(this.el), 1); - } - var box = this.box = getBoundingBox(window, this.el); - this.container.style.left = box.left + 'px'; - this.container.style.top = box.top + 'px'; - body.appendChild(this.container); - this.showHandles(); - }, - hide: function() { - if (this.container.parentNode) { - this.hideHandles(); - this.container.parentNode.removeChild(this.container); - } - }, - initDrag: function(e) { - var resizer = this; - var drag = new DragEvent(); - drag.onStart = function() { - resizer.showPreview(); - resizer.isDragging = true; - editor.getSelection().lock(); - }; - drag.onDrag = function() { - resizer.calculateSize(this); - resizer.updatePreview(); - resizer.updateHandles(resizer.previewBox); - }; - drag.onRelease = function() { - resizer.isDragging = false; - resizer.hidePreview(); - resizer.hide(); - - editor.getSelection().unlock(); - - // Save an undo snapshot before the image is permanently changed. - editor.fire('saveSnapshot'); - }; - drag.onComplete = function() { - resizer.resizeComplete(); - - // Save another snapshot after the image is changed. - editor.fire('saveSnapshot'); - }; - drag.start(e); - }, - updateHandles: function(box) { - var handles = this.handles; - handles.tl.style.left = '-3px'; - handles.tl.style.top = '-3px'; - handles.tm.style.left = (Math.round(box.width / 2) - 3) + 'px'; - handles.tm.style.top = '-3px'; - handles.tr.style.left = (box.width - 4) + 'px'; - handles.tr.style.top = '-3px'; - handles.lm.style.left = '-3px'; - handles.lm.style.top = (Math.round(box.height / 2) - 3) + 'px'; - handles.rm.style.left = (box.width - 4) + 'px'; - handles.rm.style.top = (Math.round(box.height / 2) - 3) + 'px'; - handles.bl.style.left = '-3px'; - handles.bl.style.top = (box.height - 4) + 'px'; - handles.bm.style.left = (Math.round(box.width / 2) - 3) + 'px'; - handles.bm.style.top = (box.height - 4) + 'px'; - handles.br.style.left = (box.width - 4) + 'px'; - handles.br.style.top = (box.height - 4) + 'px'; - }, - showHandles: function() { - var handles = this.handles; - this.updateHandles(this.box); - for (var n in handles) { - handles[n].style.display = 'block'; - handles[n].addEventListener('mousedown', this.events.initDrag, false); - } - this.el.className += ' cke-resize'; - }, - hideHandles: function() { - var handles = this.handles; - for (var n in handles) { - handles[n].removeEventListener('mousedown', this.events.initDrag, false); - handles[n].style.display = 'none'; - } - this.el.className = this.el.className.replace(/[ ]?cke-resize/g, ''); - }, - showPreview: function() { - this.preview.style.backgroundImage = 'url("' + this.el.src + '")'; - this.preview.style.display = 'block'; - // Move handles to the preview so they resize with it. - for (var n in this.handles) { - this.preview.appendChild(this.handles[n]); - } - this.calculateSize(); - this.updatePreview(); - this.preview.style.display = 'block'; - }, - updatePreview: function() { - var box = this.previewBox; - this.preview.style.top = box.top + 'px'; - this.preview.style.left = box.left + 'px'; - this.preview.style.width = box.width + 'px'; - this.preview.style.height = box.height + 'px'; - }, - hidePreview: function() { - var box = getBoundingBox(window, this.preview); - this.result = {width: box.width, height: box.height}; - // Move handles back to the wrapping container. - for (var n in this.handles) { - this.container.appendChild(this.handles[n]); - } - this.preview.style.display = 'none'; - }, - calculateSize: function(data) { - var box = this.previewBox = {top: 0, left: 0, width: this.box.width, height: this.box.height}; - if (!data) return; - var attr = data.target.className; - if (~attr.indexOf('r')) { - box.width = Math.max(32, this.box.width + data.delta.x); - } - if (~attr.indexOf('b')) { - box.height = Math.max(32, this.box.height + data.delta.y); - } - if (~attr.indexOf('l')) { - box.width = Math.max(32, this.box.width - data.delta.x); - } - if (~attr.indexOf('t')) { - box.height = Math.max(32, this.box.height - data.delta.y); - } - //if dragging corner, enforce aspect ratio (unless shift key is being held) - if (attr.indexOf('m') < 0 && !data.keys.shift) { - var ratio = this.box.width / this.box.height; - if (box.width / box.height > ratio) { - box.height = Math.round(box.width / ratio); - } else { - box.width = Math.round(box.height * ratio); - } - } - if (snapToSize) { - var others = this.otherImages; - for (var i = 0; i < others.length; i++) { - var other = getBoundingBox(window, others[i]); - if (Math.abs(box.width - other.width) <= snapToSize && Math.abs(box.height - other.height) <= snapToSize) { - box.width = other.width; - box.height = other.height; - break; - } - } - } - //recalculate left or top position - if (~attr.indexOf('l')) { - box.left = this.box.width - box.width; - } - if (~attr.indexOf('t')) { - box.top = this.box.height - box.height; - } - }, - resizeComplete: function() { - this.el.style.width = this.result.width + 'px'; - this.el.style.height = this.result.height + 'px'; - } - }; - Resizer.hide = function() { - this.instance && this.instance.hide(); - }; - - editor.on('selectionChange', function(evt) { - var data = evt.data; - - // If an element is selected and that element is an IMG. - if (data.selection.getType() != CKEDITOR.SELECTION_NONE && data.selection.getStartElement().is('img')) { - // And we're not right or middle clicking on the image. - if (!window.event || !window.event.button || window.event.button === 0) { - new Resizer(data.selection.getStartElement().$); - } - } else { - Resizer.hide(); - } - }); - editor.on('beforeUndoImage', function() { - // Remove the handles before undo images are saved. - Resizer.hide(); - }); - editor.on('afterUndoImage', function() { - // Restore the handles after undo images are saved. - editor.forceNextSelectionCheck(); - editor.selectionChange(); - }); - editor.on('beforeModeUnload', function self() { - editor.removeListener('beforeModeUnload', self); - Resizer.hide(); - }); - - // Check resizes to the window and update the selection. - var resizeTimeout = false; - editor.window.on('resize', resizeHandler); - function resizeHandler() { - if (!resizeTimeout) { - setTimeout(function() { - editor.forceNextSelectionCheck(); - editor.selectionChange(); - resizeTimeout = false; - }, 10); - resizeTimeout = true; - } - } - - } - - //helper functions - function toArray(obj) { - var len = obj.length, arr = new Array(len); - for (var i = 0; i < len; i++) { - arr[i] = obj[i]; - } - return arr; - } - - function bind(fn, ctx) { - if (fn.bind) { - return fn.bind(ctx); - } - return function() { - fn.apply(ctx, arguments); - }; - } - - function getBoundingBox(window, el) { - var rect = el.getBoundingClientRect(); - return { - left: rect.left + window.pageXOffset, - top: rect.top + window.pageYOffset, - width: rect.width, - height: rect.height - }; - } -})(); 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 dec95f5..22a296f 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 @@ -223,8 +223,6 @@ function getJSSettings(Editor $editor) { $settings = array( 'toolbar' => $toolbar, 'extraPlugins' => implode(',', array_keys($external_plugins)), - 'removePlugins' => 'image', - //'forcePasteAsPlainText' => TRUE, 'contentsCss' => array_values($css), 'pasteFromWordPromptCleanup' => TRUE, 'indentClasses' => array('indent1', 'indent2', 'indent3'),