|
|
@@ -7,6 +7,8 @@
|
|
|
* @module utils/dom/rect
|
|
|
*/
|
|
|
|
|
|
+/* global Node */
|
|
|
+
|
|
|
import isRange from './isrange';
|
|
|
import isWindow from './iswindow';
|
|
|
import isElement from '../lib/lodash/isElement';
|
|
|
@@ -361,12 +363,19 @@ export default class Rect {
|
|
|
// If there's no client rects for the Range, use parent container's bounding rect
|
|
|
// instead and adjust rect's width to simulate the actual geometry of such range.
|
|
|
// https://github.com/ckeditor/ckeditor5-utils/issues/153
|
|
|
+ // https://github.com/ckeditor/ckeditor5-ui/issues/317
|
|
|
else {
|
|
|
- const startContainerRect = new Rect( range.startContainer.getBoundingClientRect() );
|
|
|
- startContainerRect.right = startContainerRect.left;
|
|
|
- startContainerRect.width = 0;
|
|
|
+ let startContainer = range.startContainer;
|
|
|
+
|
|
|
+ if ( startContainer.nodeType === Node.TEXT_NODE ) {
|
|
|
+ startContainer = startContainer.parentNode;
|
|
|
+ }
|
|
|
+
|
|
|
+ const rect = new Rect( startContainer.getBoundingClientRect() );
|
|
|
+ rect.right = rect.left;
|
|
|
+ rect.width = 0;
|
|
|
|
|
|
- rects.push( startContainerRect );
|
|
|
+ rects.push( rect );
|
|
|
}
|
|
|
|
|
|
return rects;
|