X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=_source%2Fplugins%2Fcolorbutton%2Fplugin.js;h=305c44d0fddb999222f3a1a931c7a681f3a01ced;hb=refs%2Ftags%2Fv3.3.2;hp=c87d068c38d8ee74cb33d39b68b43c42caf244a7;hpb=059b4c2fef02528bf1af189f7996e80652faddfb;p=ckeditor.git diff --git a/_source/plugins/colorbutton/plugin.js b/_source/plugins/colorbutton/plugin.js index c87d068..305c44d 100644 --- a/_source/plugins/colorbutton/plugin.js +++ b/_source/plugins/colorbutton/plugin.js @@ -40,12 +40,15 @@ CKEDITOR.plugins.add( 'colorbutton', block.autoSize = true; block.element.addClass( 'cke_colorblock' ); block.element.setHtml( renderColors( panel, type ) ); + // The block should not have scrollbars (#5933, #6056) + block.element.getDocument().getBody().setStyle( 'overflow', 'hidden' ); var keys = block.keys; - keys[ 39 ] = 'next'; // ARROW-RIGHT + var rtl = editor.lang.dir == 'rtl'; + keys[ rtl ? 37 : 39 ] = 'next'; // ARROW-RIGHT keys[ 40 ] = 'next'; // ARROW-DOWN keys[ 9 ] = 'next'; // TAB - keys[ 37 ] = 'prev'; // ARROW-LEFT + keys[ rtl ? 39 : 37 ] = 'prev'; // ARROW-LEFT keys[ 38 ] = 'prev'; // ARROW-UP keys[ CKEDITOR.SHIFT + 9 ] = 'prev'; // SHIFT + TAB keys[ 32 ] = 'click'; // SPACE @@ -86,13 +89,25 @@ CKEDITOR.plugins.add( 'colorbutton', panel.hide(); - var style = new CKEDITOR.style( config['colorButton_' + type + 'Style'], color && { color : color } ); editor.fire( 'saveSnapshot' ); + + // Clean up any conflicting style within the range. + new CKEDITOR.style( config['colorButton_' + type + 'Style'], { color : 'inherit' } ).remove( editor.document ); + if ( color ) - style.apply( editor.document ); - else - style.remove( editor.document ); + { + var colorStyle = config['colorButton_' + type + 'Style']; + + colorStyle.childRule = type == 'back' ? + // It's better to apply background color as the innermost style. (#3599) + function(){ return false; } : + // Fore color style must be applied inside links instead of around it. + function( element ){ return element.getName() != 'a'; }; + + new CKEDITOR.style( colorStyle, { color : color } ).apply( editor.document ); + } + editor.fire( 'saveSnapshot' ); }); @@ -122,13 +137,22 @@ CKEDITOR.plugins.add( 'colorbutton', if ( ( i % 8 ) === 0 ) output.push( '