瀏覽代碼

Fixed edge case of the selection at the position next to the end of paragraph when next paragraph is single-line.

Kuba Niegowski 5 年之前
父節點
當前提交
c3f5919ab5
共有 1 個文件被更改,包括 11 次插入5 次删除
  1. 11 5
      packages/ckeditor5-table/src/tablenavigation.js

+ 11 - 5
packages/ckeditor5-table/src/tablenavigation.js

@@ -342,12 +342,18 @@ export default class TableNavigation extends Plugin {
 		const editing = this.editor.editing;
 		const domConverter = editing.view.domConverter;
 
+		// Wrapped lines contain exactly the same position at the end of current line
+		// and at the beginning of next line. That position's client rect is at the end
+		// of current line. In case of caret at first position of the last line that 'dual'
+		// position would be detected as it's not the last line.
 		if ( isForward && !modelRange.start.isAtEnd ) {
-			// Wrapped lines contain exactly the same position at the end of current line
-			// and at the beginning of next line. That position's client rect is at the end
-			// of current line. In case of caret at first position of the last line that 'dual'
-			// position would be detected as it's not the last line.
-			modelRange = new ModelRange( modelRange.start.getShiftedBy( 1 ), modelRange.end );
+			const shiftedPosition = modelRange.start.getShiftedBy( 1 );
+
+			// If shifted position is at the end of the parent element then we can't skip it
+			// because we could detect a next paragraph as single-line.
+			if ( !shiftedPosition.isAtEnd ) {
+				modelRange = new ModelRange( shiftedPosition, modelRange.end );
+			}
 		}
 
 		const viewRange = editing.mapper.toViewRange( modelRange );