@ckeditor/ckeditor5-widget 0.0.0-nightly-20240506.0 → 0.0.0-nightly-20240508.0

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.

Potentially problematic release.


This version of @ckeditor/ckeditor5-widget might be problematic. Click here for more details.

package/dist/index.js CHANGED
@@ -447,17 +447,21 @@ var dragHandleIcon = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/
447
447
  * Starting from a DOM resize host element (an element that receives dimensions as a result of resizing),
448
448
  * this helper returns the width of the found ancestor element.
449
449
  *
450
- * **Note**: This helper searches up to 5 levels of ancestors only.
450
+ * * It searches up to 5 levels of ancestors only.
451
451
  *
452
452
  * @param domResizeHost Resize host DOM element that receives dimensions as a result of resizing.
453
453
  * @returns Width of ancestor element in pixels or 0 if no ancestor with a computed width has been found.
454
454
  */ function calculateResizeHostAncestorWidth(domResizeHost) {
455
+ const getElementComputedWidth = (element)=>{
456
+ const { width, paddingLeft, paddingRight } = element.ownerDocument.defaultView.getComputedStyle(element);
457
+ return parseFloat(width) - (parseFloat(paddingLeft) || 0) - (parseFloat(paddingRight) || 0);
458
+ };
455
459
  const domResizeHostParent = domResizeHost.parentElement;
456
460
  if (!domResizeHostParent) {
457
461
  return 0;
458
462
  }
459
463
  // Need to use computed style as it properly excludes parent's paddings from the returned value.
460
- let parentWidth = parseFloat(domResizeHostParent.ownerDocument.defaultView.getComputedStyle(domResizeHostParent).width);
464
+ let parentWidth = getElementComputedWidth(domResizeHostParent);
461
465
  // Sometimes parent width cannot be accessed. If that happens we should go up in the elements tree
462
466
  // and try to get width from next ancestor.
463
467
  // https://github.com/ckeditor/ckeditor5/issues/10776
@@ -469,7 +473,7 @@ var dragHandleIcon = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/
469
473
  if (++currentLevel > ancestorLevelLimit) {
470
474
  return 0;
471
475
  }
472
- parentWidth = parseFloat(domResizeHostParent.ownerDocument.defaultView.getComputedStyle(checkedElement).width);
476
+ parentWidth = getElementComputedWidth(checkedElement);
473
477
  }
474
478
  return parentWidth;
475
479
  }