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