8
0
Quellcode durchsuchen

Extract button tooltip to observable.

Mateusz Samsel vor 6 Jahren
Ursprung
Commit
0129fe75ab

+ 2 - 2
packages/ckeditor5-font/src/fontbackgroundcolor/fontbackgroundcolorui.js

@@ -29,9 +29,9 @@ export default class FontBackgroundColorUI extends Plugin {
 			const dropdownView = createDropdown( locale );
 
 			const colorTableView = new ColorTableView( locale, {
-				colors: options.map( item => ( { name: item.label, color: item.model } ) ),
-				removeButtonTooltip: t( 'Remove background color' )
+				colors: options.map( item => ( { name: item.label, color: item.model } ) )
 			} );
+			colorTableView.set( 'removeButtonTooltip', t( 'Remove background color' ) );
 
 			dropdownView.panelView.children.add( colorTableView );
 

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

@@ -29,10 +29,10 @@ export default class FontColorUI extends Plugin {
 			const dropdownView = createDropdown( locale );
 
 			const colorTableView = new ColorTableView( locale, {
-				colors: options.map( item => ( { name: item.label, color: item.model } ) ),
-				removeButtonTooltip: t( 'Remove text color' )
+				colors: options.map( item => ( { name: item.label, color: item.model } ) )
 			} );
 
+			colorTableView.set( 'removeButtonTooltip', t( 'Remove text color' ) );
 			dropdownView.panelView.children.add( colorTableView );
 
 			colorTableView.bind( 'selectedColor' ).to( command, 'value' );

+ 4 - 4
packages/ckeditor5-font/src/ui/colortableview.js

@@ -9,16 +9,16 @@ import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
 
 import '../../theme/fontcolor.css';
 export default class ColorTableView extends View {
-	constructor( locale, { colors, removeButtonTooltip, columns = 6 } ) {
+	constructor( locale, { colors } ) {
 		super( locale );
 		const bind = this.bindTemplate;
 
-		this.COLUMNS = columns;
+		this.COLUMNS = 6;
 		this.colorsDefinition = colors;
-		this.removeButtonTooltip = removeButtonTooltip;
 
 		this.set( 'selectedColor' );
 		this.set( 'hoveredColor' );
+		this.set( 'removeButtonTooltip' );
 
 		this.setTemplate( {
 			tag: 'div',
@@ -39,9 +39,9 @@ export default class ColorTableView extends View {
 		const btnView = new ButtonView();
 		btnView.set( {
 			label: 'X',
-			tooltip: this.removeButtonTooltip,
 			withText: true
 		} );
+		btnView.bind( 'tooltip' ).to( this, 'removeButtonTooltip' );
 		btnView.class = 'ck-color-table__remove-color';
 		btnView.on( 'execute', () => {
 			this.fire( 'colorPicked', { value: null } );