Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #267 from ckeditor/i/6116
Browse files Browse the repository at this point in the history
Internal: We need to take care of putting the selection in a correct position. See ckeditor/ckeditor5#6116.
  • Loading branch information
Reinmar authored Mar 9, 2020
2 parents 0b105f4 + 7e83043 commit edbaf3a
Show file tree
Hide file tree
Showing 4 changed files with 326 additions and 264 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@ckeditor/ckeditor5-clipboard": "^17.0.0",
"@ckeditor/ckeditor5-editor-classic": "^17.0.0",
"@ckeditor/ckeditor5-engine": "^17.0.0",
"@ckeditor/ckeditor5-horizontal-line": "^17.0.0",
"@ckeditor/ckeditor5-image": "^17.0.0",
"@ckeditor/ckeditor5-indent": "^17.0.0",
"@ckeditor/ckeditor5-list": "^17.0.0",
Expand Down
14 changes: 8 additions & 6 deletions src/tableselection.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,14 @@ export default class TableSelection extends Plugin {

clearTableCellsContents( model, selectedTableCells );

// The insertContent() helper passes the actual DocumentSelection,
// while the deleteContent() helper always operates on the abstract clones.
if ( selection.is( 'documentSelection' ) ) {
writer.setSelection( tableCellToSelect, 'in' );
} else {
selection.setTo( tableCellToSelect, 'in' );
const rangeToSelect = model.schema.getNearestSelectionRange( writer.createPositionAt( tableCellToSelect, 0 ) );

if ( rangeToSelect ) {
if ( selection.is( 'documentSelection' ) ) {
writer.setSelection( rangeToSelect );
} else {
selection.setTo( rangeToSelect );
}
}
} );
}
Expand Down
Loading

0 comments on commit edbaf3a

Please sign in to comment.