|
|
@@ -756,29 +756,9 @@ export default class Renderer {
|
|
|
domSelection.collapse( anchor.parent, anchor.offset );
|
|
|
domSelection.extend( focus.parent, focus.offset );
|
|
|
|
|
|
- // The following is a Firefox–specific hack (https://github.com/ckeditor/ckeditor5-engine/issues/1439).
|
|
|
- // When the native DOM selection is at the end of the block and preceded by <br /> e.g.
|
|
|
- //
|
|
|
- // <p>foo<br/>[]</p>
|
|
|
- //
|
|
|
- // which happens a lot when using the soft line break, the browser fails to (visually) move the
|
|
|
- // caret to the new line. A quick fix is as simple as force–refreshing the selection with the same range.
|
|
|
+ // Firefox–specific hack (https://github.com/ckeditor/ckeditor5-engine/issues/1439).
|
|
|
if ( env.isGecko ) {
|
|
|
- const parent = focus.parent;
|
|
|
-
|
|
|
- // This fix works only when the focus point is at the very end of an element.
|
|
|
- // There is no point in running it in cases unrelated to the browser bug.
|
|
|
- if ( parent.nodeType != Node.ELEMENT_NODE || focus.offset != parent.childNodes.length - 1 ) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- const childAtOffset = parent.childNodes[ focus.offset ];
|
|
|
-
|
|
|
- // To stay on the safe side, the fix being as specific as possible, it targets only the
|
|
|
- // selection which is at the very end of the element and preceded by <br />.
|
|
|
- if ( childAtOffset && childAtOffset.tagName == 'BR' ) {
|
|
|
- domSelection.addRange( domSelection.getRangeAt( 0 ) );
|
|
|
- }
|
|
|
+ fixGeckoSelectionAfterBr( focus, domSelection );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -951,3 +931,28 @@ function sameNodes( blockFiller, actualDomChild, expectedDomChild ) {
|
|
|
// Not matching types.
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+// The following is a Firefox–specific hack (https://github.com/ckeditor/ckeditor5-engine/issues/1439).
|
|
|
+// When the native DOM selection is at the end of the block and preceded by <br /> e.g.
|
|
|
+//
|
|
|
+// <p>foo<br/>[]</p>
|
|
|
+//
|
|
|
+// which happens a lot when using the soft line break, the browser fails to (visually) move the
|
|
|
+// caret to the new line. A quick fix is as simple as force–refreshing the selection with the same range.
|
|
|
+function fixGeckoSelectionAfterBr( focus, domSelection ) {
|
|
|
+ const parent = focus.parent;
|
|
|
+
|
|
|
+ // This fix works only when the focus point is at the very end of an element.
|
|
|
+ // There is no point in running it in cases unrelated to the browser bug.
|
|
|
+ if ( parent.nodeType != Node.ELEMENT_NODE || focus.offset != parent.childNodes.length - 1 ) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const childAtOffset = parent.childNodes[ focus.offset ];
|
|
|
+
|
|
|
+ // To stay on the safe side, the fix being as specific as possible, it targets only the
|
|
|
+ // selection which is at the very end of the element and preceded by <br />.
|
|
|
+ if ( childAtOffset && childAtOffset.tagName == 'BR' ) {
|
|
|
+ domSelection.addRange( domSelection.getRangeAt( 0 ) );
|
|
|
+ }
|
|
|
+}
|