@ckeditor/ckeditor5-image 45.0.0-alpha.9 → 45.1.0-alpha.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.
package/dist/index.js CHANGED
@@ -1635,6 +1635,20 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
1635
1635
  attachDowncastConverter(dispatcher, 'width', 'width', false);
1636
1636
  attachDowncastConverter(dispatcher, 'height', 'height', false);
1637
1637
  });
1638
+ // Consume `aspect-ratio` style if `width` and `height` attributes are set on the image.
1639
+ editor.conversion.for('upcast').add((dispatcher)=>{
1640
+ dispatcher.on('element:img', (evt, data, conversionApi)=>{
1641
+ const width = data.viewItem.getAttribute('width');
1642
+ const height = data.viewItem.getAttribute('height');
1643
+ if (width && height) {
1644
+ conversionApi.consumable.consume(data.viewItem, {
1645
+ styles: [
1646
+ 'aspect-ratio'
1647
+ ]
1648
+ });
1649
+ }
1650
+ });
1651
+ });
1638
1652
  function attachDowncastConverter(dispatcher, modelAttributeName, viewAttributeName, setRatioForInlineImage, isEditingDowncast = false) {
1639
1653
  dispatcher.on(`attribute:${modelAttributeName}:${imageType}`, (evt, data, conversionApi)=>{
1640
1654
  if (!conversionApi.consumable.consume(data.item, evt.name)) {
@@ -4606,6 +4620,15 @@ function getImagesFromChangeItem(editor, item) {
4606
4620
  }
4607
4621
  }
4608
4622
  });
4623
+ editor.conversion.for('upcast').add((dispatcher)=>{
4624
+ dispatcher.on(`element:${imageType === 'imageBlock' ? 'figure' : 'img'}`, (evt, data, conversionApi)=>{
4625
+ conversionApi.consumable.consume(data.viewItem, {
4626
+ classes: [
4627
+ 'image_resized'
4628
+ ]
4629
+ });
4630
+ });
4631
+ });
4609
4632
  }
4610
4633
  }
4611
4634
 
@@ -4663,7 +4686,7 @@ const RESIZE_ICONS = /* #__PURE__ */ (()=>({
4663
4686
  /**
4664
4687
  * A helper function that creates a standalone button component for the plugin.
4665
4688
  *
4666
- * @param resizeOption A model of the resize option.
4689
+ * @param option A model of the resize option.
4667
4690
  */ _registerImageResizeButton(option) {
4668
4691
  const editor = this.editor;
4669
4692
  const { name, value, icon } = option;
@@ -4680,7 +4703,7 @@ const RESIZE_ICONS = /* #__PURE__ */ (()=>({
4680
4703
  * {@link module:image/imageconfig~ImageResizeOption plugin configuration}.
4681
4704
  *
4682
4705
  * @error imageresizebuttons-missing-icon
4683
- * @param option Invalid image resize option.
4706
+ * @param {module:image/imageconfig~ImageResizeOption} option Invalid image resize option.
4684
4707
  */ throw new CKEditorError('imageresizebuttons-missing-icon', editor, option);
4685
4708
  }
4686
4709
  button.set({
@@ -5932,8 +5955,8 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5932
5955
  * are missing. Make sure these plugins are loaded in your editor to get this image style option working.
5933
5956
  *
5934
5957
  * @error image-style-missing-dependency
5935
- * @param {String} [option] The name of the unsupported option.
5936
- * @param {String} [missingPlugins] The names of the plugins one of which has to be loaded for the particular option.
5958
+ * @param {string} style The name of the unsupported option.
5959
+ * @param {Array.<string>} missingPlugins The names of the plugins one of which has to be loaded for the particular option.
5937
5960
  */ logWarning('image-style-missing-dependency', {
5938
5961
  style: option,
5939
5962
  missingPlugins: modelElements.map((name)=>name === 'imageBlock' ? 'ImageBlockEditing' : 'ImageInlineEditing')
@@ -5969,8 +5992,7 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5969
5992
  * * {@link module:image/imageconfig~ImageStyleDropdownDefinition image style dropdown definition}
5970
5993
  *
5971
5994
  * @error image-style-configuration-definition-invalid
5972
- * @param {String} [dropdown] The name of the invalid drop-down
5973
- * @param {String} [style] The name of the invalid image style option
5995
+ * @param {object} info The information about the invalid definition.
5974
5996
  */ logWarning('image-style-configuration-definition-invalid', info);
5975
5997
  }
5976
5998
  var utils = {