瀏覽代碼

Code refactoring in the TableCellPropertiesUI class.

Aleksander Nowodzinski 5 年之前
父節點
當前提交
7371548dfb
共有 1 個文件被更改,包括 11 次插入22 次删除
  1. 11 22
      packages/ckeditor5-table/src/tablecellproperties/tablecellpropertiesui.js

+ 11 - 22
packages/ckeditor5-table/src/tablecellproperties/tablecellpropertiesui.js

@@ -184,28 +184,17 @@ export default class TableCellPropertiesUI extends Plugin {
 	 * @private
 	 */
 	_fillViewFormFromCommandValues() {
-		const editor = this.editor;
-		const data = {};
-
-		for ( const propertyName of CELL_PROPERTIES ) {
-			let value = editor.commands.get( propertyNameToCommandName( propertyName ) ).value;
-
-			if ( !value ) {
-				if ( propertyName === 'borderStyle' ) {
-					value = DEFAULT_BORDER_STYLE;
-				} else if ( propertyName === 'horizontalAlignment' ) {
-					value = DEFAULT_HORIZONTAL_ALIGNMENT;
-				} else if ( propertyName === 'verticalAlignment' ) {
-					value = DEFAULT_VERTICAL_ALIGNMENT;
-				} else {
-					value = '';
-				}
-			}
-
-			data[ propertyName ] = value;
-		}
-
-		this.view.set( data );
+		const commands = this.editor.commands;
+
+		this.view.set( {
+			borderStyle: commands.get( 'tableCellBorderStyle' ).value || DEFAULT_BORDER_STYLE,
+			borderColor: commands.get( 'tableCellBorderColor' ).value || '',
+			borderWidth: commands.get( 'tableCellBorderWidth' ).value || '',
+			padding: commands.get( 'tableCellPadding' ).value || '',
+			backgroundColor: commands.get( 'tableCellBackgroundColor' ).value || '',
+			horizontalAlignment: commands.get( 'tableCellHorizontalAlignment' ).value || DEFAULT_HORIZONTAL_ALIGNMENT,
+			verticalAlignment: commands.get( 'tableCellVerticalAlignment' ).value || DEFAULT_VERTICAL_ALIGNMENT,
+		} );
 	}
 
 	/**