@ckeditor/ckeditor5-widget 43.1.0-alpha.5 → 43.1.0-alpha.6

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -1695,6 +1695,10 @@ function selectionWillShrink(selection, isForward) {
1695
1695
  const view = editor.editing.view;
1696
1696
  const viewDocument = view.document;
1697
1697
  let element = domEventData.target;
1698
+ // Some of DOM elements have no view element representation so it may be null.
1699
+ if (!element) {
1700
+ return;
1701
+ }
1698
1702
  // If triple click should select entire paragraph.
1699
1703
  if (domEventData.domEvent.detail >= 3) {
1700
1704
  if (this._selectBlockContent(element)) {
@@ -1973,10 +1977,14 @@ function selectionWillShrink(selection, isForward) {
1973
1977
  * @returns The ViewElement associated with the mouse event, or null if not found.
1974
1978
  */ function getElementFromMouseEvent(view, domEventData) {
1975
1979
  const domRange = getRangeFromMouseEvent(domEventData.domEvent);
1976
- if (!domRange) {
1977
- return null;
1980
+ let viewRange = null;
1981
+ if (domRange) {
1982
+ viewRange = view.domConverter.domRangeToView(domRange);
1983
+ } else {
1984
+ // Fallback to create range in target element. It happens frequently on Safari browser.
1985
+ // See more: https://github.com/ckeditor/ckeditor5/issues/16978
1986
+ viewRange = view.createRange(view.createPositionAt(domEventData.target, 0));
1978
1987
  }
1979
- const viewRange = view.domConverter.domRangeToView(domRange);
1980
1988
  if (!viewRange) {
1981
1989
  return null;
1982
1990
  }