Преглед изворни кода

Internal: Simplified the logic in command execution code, to reuse modified method.

Marek Lewandowski пре 5 година
родитељ
комит
46069b6340
1 измењених фајлова са 3 додато и 11 уклоњено
  1. 3 11
      packages/ckeditor5-table/src/commands/splitcellcommand.js

+ 3 - 11
packages/ckeditor5-table/src/commands/splitcellcommand.js

@@ -8,7 +8,6 @@
  */
 
 import Command from '@ckeditor/ckeditor5-core/src/command';
-import { findAncestor } from './utils';
 import { getTableCellsInSelection } from '../tableselection/utils';
 
 /**
@@ -56,18 +55,11 @@ export default class SplitCellCommand extends Command {
 	 * @inheritDoc
 	 */
 	execute() {
-		const model = this.editor.model;
-		const document = model.document;
-		const selection = document.selection;
-
-		const firstPosition = selection.getFirstPosition();
-		const tableCell = findAncestor( 'tableCell', firstPosition );
-
-		const isHorizontally = this.direction === 'horizontally';
-
+		const tableCell = getTableCellsInSelection( this.editor.model.document.selection, true )[ 0 ];
+		const isHorizontal = this.direction === 'horizontally';
 		const tableUtils = this.editor.plugins.get( 'TableUtils' );
 
-		if ( isHorizontally ) {
+		if ( isHorizontal ) {
 			tableUtils.splitCellHorizontally( tableCell, 2 );
 		} else {
 			tableUtils.splitCellVertically( tableCell, 2 );