@ckeditor/ckeditor5-widget 43.1.0-alpha.0 → 43.1.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1984,9 +1984,19 @@ function selectionWillShrink(selection, isForward) {
1984
1984
  if (!viewPosition.parent) {
1985
1985
  return null;
1986
1986
  }
1987
- // Click after a widget tend to return position at the end of the editable element
1988
- // so use the node before it if range is at the end of a parent.
1989
- const viewNode = viewPosition.parent.is('editableElement') && viewPosition.isAtEnd && viewPosition.nodeBefore || viewPosition.parent;
1987
+ let viewNode = viewPosition.parent;
1988
+ if (viewPosition.parent.is('editableElement')) {
1989
+ if (viewPosition.isAtEnd && viewPosition.nodeBefore) {
1990
+ // Click after a widget tend to return position at the end of the editable element
1991
+ // so use the node before it if range is at the end of a parent.
1992
+ viewNode = viewPosition.nodeBefore;
1993
+ } else if (viewPosition.isAtStart && viewPosition.nodeAfter) {
1994
+ // Click before a widget tend to return position at the start of the editable element
1995
+ // so use the node after it if range is at the start of a parent.
1996
+ // See more: https://github.com/ckeditor/ckeditor5/issues/16992
1997
+ viewNode = viewPosition.nodeAfter;
1998
+ }
1999
+ }
1990
2000
  if (viewNode.is('$text')) {
1991
2001
  return viewNode.parent;
1992
2002
  }