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

Unify the selection post fixing when selection is between limit elements.

Maciej Gołaszewski 6 лет назад
Родитель
Сommit
c1b431fdc8

+ 4 - 4
packages/ckeditor5-engine/src/model/utils/selection-post-fixer.js

@@ -121,16 +121,16 @@ function tryFixingCollapsedRange( range, schema ) {
 
 	let nearestSelectionRange = schema.getNearestSelectionRange( originalPosition );
 
-	// console.log( '-------------------' );
-	// console.log( range.start.path, range.end.path );
-	// console.log( nearestSelectionRange.start.path, nearestSelectionRange.end.path );
-
 	// This might be null ie when editor data is empty.
 	// In such cases there is no need to fix the selection range.
 	if ( !nearestSelectionRange ) {
 		return null;
 	}
 
+	if ( !nearestSelectionRange.isCollapsed ) {
+		return nearestSelectionRange;
+	}
+
 	let fixedPosition = nearestSelectionRange.start;
 
 	const startLimitElement = schema.getLimitElement( originalPosition );

+ 2 - 2
packages/ckeditor5-engine/tests/model/utils/selection-post-fixer.js

@@ -10,7 +10,7 @@ import { injectSelectionPostFixer } from '../../../src/model/utils/selection-pos
 import { getData as getModelData, setData as setModelData } from '../../../src/dev-utils/model';
 import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
-describe.only( 'Selection post-fixer', () => {
+describe( 'Selection post-fixer', () => {
 	describe( 'injectSelectionPostFixer()', () => {
 		it( 'is a function', () => {
 			expect( injectSelectionPostFixer ).to.be.a( 'function' );
@@ -1052,7 +1052,7 @@ describe.only( 'Selection post-fixer', () => {
 					'<paragraph>foo</paragraph>' +
 					'<table>' +
 						'<tableRow>' +
-							'<tableCell><paragraph>[]aaa</paragraph></tableCell>' +
+							'[<tableCell><paragraph>aaa</paragraph></tableCell>]' +
 							'<tableCell><paragraph>bbb</paragraph></tableCell>' +
 						'</tableRow>' +
 					'</table>' +