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

Internal: Integrated header row command's isEnabled and value properties with multiple cell selection.

Marek Lewandowski 5 лет назад
Родитель
Сommit
9017defe53
1 измененных файлов с 4 добавлено и 7 удалено
  1. 4 7
      packages/ckeditor5-table/src/commands/setheaderrowcommand.js

+ 4 - 7
packages/ckeditor5-table/src/commands/setheaderrowcommand.js

@@ -10,6 +10,7 @@
 import Command from '@ckeditor/ckeditor5-core/src/command';
 
 import { createEmptyTableCell, findAncestor, updateNumericAttribute } from './utils';
+import { getTableCellsInSelection } from '../tableselection/utils';
 import TableWalker from '../tablewalker';
 
 /**
@@ -32,12 +33,8 @@ export default class SetHeaderRowCommand extends Command {
 	 */
 	refresh() {
 		const model = this.editor.model;
-		const doc = model.document;
-		const selection = doc.selection;
-
-		const position = selection.getFirstPosition();
-		const tableCell = findAncestor( 'tableCell', position );
-		const isInTable = !!tableCell;
+		const selectedCells = getTableCellsInSelection( model.document.selection, true );
+		const isInTable = selectedCells.length > 0;
 
 		this.isEnabled = isInTable;
 
@@ -49,7 +46,7 @@ export default class SetHeaderRowCommand extends Command {
 		 * @readonly
 		 * @member {Boolean} #value
 		 */
-		this.value = isInTable && this._isInHeading( tableCell, tableCell.parent.parent );
+		this.value = isInTable && selectedCells.every( cell => this._isInHeading( cell, cell.parent.parent ) );
 	}
 
 	/**