@ckeditor/ckeditor5-image 44.2.0-alpha.15 → 44.2.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
@@ -1620,12 +1620,6 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
1620
1620
  } else {
1621
1621
  viewWriter.removeAttribute(viewAttributeName, img);
1622
1622
  }
1623
- const width = data.item.getAttribute('width');
1624
- const height = data.item.getAttribute('height');
1625
- const hasSizes = width && height;
1626
- if (hasSizes && isEditingDowncast) {
1627
- viewWriter.setAttribute('loading', 'lazy', img);
1628
- }
1629
1623
  // Do not set aspect-ratio for pictures. See https://github.com/ckeditor/ckeditor5/issues/14579.
1630
1624
  if (data.item.hasAttribute('sources')) {
1631
1625
  return;
@@ -1635,8 +1629,14 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
1635
1629
  if (imageType === 'imageInline' && !isResized && !setRatioForInlineImage) {
1636
1630
  return;
1637
1631
  }
1638
- if (hasSizes) {
1639
- viewWriter.setStyle('aspect-ratio', `${width}/${height}`, img);
1632
+ const width = data.item.getAttribute('width');
1633
+ const height = data.item.getAttribute('height');
1634
+ if (!width || !height) {
1635
+ return;
1636
+ }
1637
+ viewWriter.setStyle('aspect-ratio', `${width}/${height}`, img);
1638
+ if (isEditingDowncast) {
1639
+ viewWriter.setAttribute('loading', 'lazy', img);
1640
1640
  }
1641
1641
  });
1642
1642
  }
@@ -5056,6 +5056,7 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5056
5056
  }
5057
5057
  const imageParentWidthPx = calculateResizeHostAncestorWidth(imageNodes.dom);
5058
5058
  const imageHolderDimension = {
5059
+ unit: 'px',
5059
5060
  value: new Rect(imageNodes.dom).width
5060
5061
  };
5061
5062
  return tryCastDimensionsToUnit(imageParentWidthPx, imageHolderDimension, targetUnit);
@@ -5268,7 +5269,9 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5268
5269
  }
5269
5270
  const imageParentWidthPx = calculateResizeHostAncestorWidth(imageNodes.dom);
5270
5271
  const minimumImageWidth = tryParseDimensionWithUnit(window.getComputedStyle(imageNodes.dom).minWidth) || {
5271
- value: 1};
5272
+ value: 1,
5273
+ unit: 'px'
5274
+ };
5272
5275
  const lower = Math.max(0.1, tryCastDimensionsToUnit(imageParentWidthPx, minimumImageWidth, targetUnit).value);
5273
5276
  const upper = targetUnit === 'px' ? imageParentWidthPx : 100;
5274
5277
  return {