8
0
Просмотр исходного кода

Enable background color again in manual test.

Mateusz Samsel 6 лет назад
Родитель
Сommit
9f51916ac6

+ 5 - 12
packages/ckeditor5-font/src/fontbackgroundcolor/fontbackgroundcolorui.js

@@ -8,7 +8,6 @@
  */
 
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
-import SplitButtonView from '@ckeditor/ckeditor5-ui/src/dropdown/button/splitbuttonview';
 
 import fontBackgroundColorIcon from '../../theme/icons/font-family.svg';
 import { createDropdown } from '@ckeditor/ckeditor5-ui/src/dropdown/utils';
@@ -26,8 +25,7 @@ export default class FontBackgroundColorUI extends Plugin {
 
 		// Register UI component.
 		editor.ui.componentFactory.add( FONT_BACKGROUND_COLOR, locale => {
-			const dropdownView = createDropdown( locale, SplitButtonView );
-			const splitButtonView = dropdownView.buttonView;
+			const dropdownView = createDropdown( locale );
 			const colorTableView = colorUI.addColorsToDropdown(
 				dropdownView,
 				options.map( element => ( {
@@ -38,13 +36,10 @@ export default class FontBackgroundColorUI extends Plugin {
 					}
 				} ) )
 			);
-			colorTableView.set( 'removeButtonTooltip', t( 'Remove background color' ) );
+			colorTableView.set( 'removeButtonTooltip', t( 'Remove color' ) );
 
 			colorTableView.bind( 'selectedColor' ).to( command, 'value' );
 
-			// Preselect first element on color list.
-			dropdownView.set( 'lastlySelectedColor', { value: options[ 0 ].model } );
-
 			dropdownView.buttonView.set( {
 				label: t( 'Font Background Color' ),
 				icon: fontBackgroundColorIcon,
@@ -60,14 +55,12 @@ export default class FontBackgroundColorUI extends Plugin {
 			dropdownView.bind( 'isEnabled' ).to( command );
 
 			dropdownView.on( 'execute', ( evt, val ) => {
-				dropdownView.set( 'lastlySelectedColor', val );
+				if ( val.value !== null ) {
+					colorTableView.recentlyUsedColors.add( { color: val.value, hasBorder: val.hasBorder }, 0 );
+				}
 				editor.execute( FONT_BACKGROUND_COLOR, val );
 			} );
 
-			splitButtonView.on( 'execute', () => {
-				editor.execute( FONT_BACKGROUND_COLOR, dropdownView.lastlySelectedColor );
-			} );
-
 			return dropdownView;
 		} );
 	}

+ 1 - 1
packages/ckeditor5-font/src/fontcolor/fontcolorui.js

@@ -36,7 +36,7 @@ export default class FontColorUI extends Plugin {
 					}
 				} ) )
 			);
-			colorTableView.set( 'removeButtonTooltip', t( 'Remove text color' ) );
+			colorTableView.set( 'removeButtonTooltip', t( 'Remove color' ) );
 
 			colorTableView.bind( 'selectedColor' ).to( command, 'value' );
 

+ 13 - 5
packages/ckeditor5-font/tests/manual/font-color.js

@@ -8,20 +8,28 @@
 import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
 import FontColor from '../../src/fontcolor';
-// import FontBackgroundColor from '../../src/fontbackgroundcolor';
+import FontBackgroundColor from '../../src/fontbackgroundcolor';
 
 ClassicEditor
 	.create( document.querySelector( '#editor' ), {
 		plugins: [
 			ArticlePluginSet,
 			FontColor,
-			// FontBackgroundColor
+			FontBackgroundColor
 		],
 		toolbar: [
-			'heading', '|',
+			'heading',
+			'|',
 			'fontColor',
-			// 'fontBackgroundColor',
-			'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo'
+			'fontBackgroundColor',
+			'bold',
+			'italic',
+			'link',
+			'bulletedList',
+			'numberedList',
+			'blockQuote',
+			'undo',
+			'redo'
 		]
 	} )
 	.then( editor => {