image/image/converters
Functions
downcastImageAttribute( imageUtils, imageType, attributeKey ) → ( dispatcher: DowncastDispatcher ) => voidinternalmodule:image/image/converters~downcastImageAttributeConverter used to convert a given image attribute from the model to the view.
Parameters
imageUtils : ImageUtilsimageType : 'imageBlock' | 'imageInline'The type of the image.
attributeKey : stringThe name of the attribute to convert.
Returns
( dispatcher: DowncastDispatcher ) => void
downcastSourcesAttribute( imageUtils ) → ( dispatcher: DowncastDispatcher ) => voidinternalmodule:image/image/converters~downcastSourcesAttributeConverts the
sourcemodel attribute to the<picture><source /><source />...<img /></picture>view structure.Parameters
imageUtils : ImageUtils
Returns
( dispatcher: DowncastDispatcher ) => void
downcastSrcsetAttribute( imageUtils, imageType ) → ( dispatcher: DowncastDispatcher ) => voidinternalmodule:image/image/converters~downcastSrcsetAttributeConverter used to convert the
srcsetmodel image attribute to thesrcsetandsizesattributes in the view.Parameters
imageUtils : ImageUtilsimageType : 'imageBlock' | 'imageInline'The type of the image.
Returns
( dispatcher: DowncastDispatcher ) => void
upcastImageFigure( imageUtils ) → ( dispatcher: UpcastDispatcher ) => voidinternalmodule:image/image/converters~upcastImageFigureReturns a function that converts the image view representation:
<figure class="image"><img src="..." alt="..."></img></figure>Copy codeto the model representation:
<imageBlock src="..." alt="..."></imageBlock>Copy codeThe entire content of the
<figure>element except the first<img>is being converted as children of the<imageBlock>model element.Parameters
imageUtils : ImageUtils
Returns
( dispatcher: UpcastDispatcher ) => void
upcastImg( matchImageType, imageUtils ) → ( dispatcher: UpcastDispatcher ) => voidinternalmodule:image/image/converters~upcastImgReturns a function that upcasts an
<img>element to either animageBlockor animageInlinemodel element.The image type is first determined from the view structure (see
getViewImageType): an<img>wrapped in a<figure class="image">or styled withdisplay: blockbecomes animageBlock, otherwise animageInline.That structural type is then verified against the schema at the insertion position. If it cannot be placed there - neither directly (or after hoisting to an allowed ancestor) nor wrapped in an auto-created paragraph - the converter falls back to
matchImageType. This is what allows a block image to degrade to an inline image inside an inline root (and, symmetrically, an inline image to become a block image in a context that only accepts block images) instead of being dropped.Both
ImageBlockEditingandImageInlineEditingregister this converter, each passing the type it falls back to. When only one of them is loaded, that single type is always produced.Parameters
matchImageType : 'imageBlock' | 'imageInline'The image type to fall back to when the type resolved from the view cannot be placed at the insertion position.
imageUtils : ImageUtilsThe
ImageUtilsplugin instance.
Returns
( dispatcher: UpcastDispatcher ) => void
upcastPicture( imageUtils ) → ( dispatcher: UpcastDispatcher ) => voidinternalmodule:image/image/converters~upcastPictureReturns a function that converts the image view representation:
<picture><source ... /><source ... />...<img ... /></picture>Copy codeto the model representation as the
sourcesattribute:<image[Block|Inline] ... sources="..."></image[Block|Inline]>Copy codeParameters
imageUtils : ImageUtils
Returns
( dispatcher: UpcastDispatcher ) => void