-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Edge/FF] Exception after dragging the selection through the image #5416
Comments
In FF the selection starts at the end of the text that's inside the header, so in the https://github.com/ckeditor/ckeditor5-utils/blob/ac06329334e9f981e10df18237a986b56a43112e/src/dom/rect.js#L365, the |
( |
Maybe it can be solved by using the parent element instead of the original element when the |
But why isn't this throwing in all browsers? |
It's interesting that the error doesn't occur in the manual tests: http://localhost:8125/ckeditor5-image/tests/manual/caption.html. |
When the selection starts inside the header, its start moves to the caption during dragging down. When dragging up all works fine. |
Actually, this is caused by the BalloonEditor which calculates the rect for its position. It can be reproduced here too http://localhost:8125/ckeditor5-editor-balloon/tests/manual/ballooneditor.html |
It's connected to https://github.com/ckeditor/ckeditor5-engine/issues/1156. There's a moment before the crash when selection starts at the end of the text and ends in the main editable element just after the text node. So there's no native rectangle available from |
I briefly checked this issue and the problem is in this line https://github.com/ckeditor/ckeditor5-utils/blob/7211d0269bf3e3ab7586afa987785e3dcbbcf31c/src/dom/rect.js#L365. The Generally speaking, the client rects interface in Firefox is very experimental. Such DOM range: <h>Foo[</h>
<img>
<p>Ba]r</p> has 0 rects in I anticipated this situation a couple months ago and used a hack that retrieves the parent of the ATM the best we can achieve is: with the following fix: diff --git a/src/dom/rect.js b/src/dom/rect.js
index 480452f..7ec5444 100644
--- a/src/dom/rect.js
+++ b/src/dom/rect.js
@@ -3,6 +3,8 @@
* For licensing, see LICENSE.md.
*/
+/* global Node */
+
/**
* @module utils/dom/rect
*/
@@ -362,11 +364,17 @@ export default class Rect {
// instead and adjust rect's width to simulate the actual geometry of such range.
// https://github.com/ckeditor/ckeditor5-utils/issues/153
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; Later on, we could also consider |
Fix: `Rect.getDomRangeRects()` should not throw if the provided DOM range starts in a text node. Closes ckeditor/ckeditor5-ui#317.
Steps to reproduce
Current result
Error
GIF
Other information
OS: Windows 10
Browser: Edge 16, Firefox
Release: 0.11.0
The text was updated successfully, but these errors were encountered: