image/image/utils
Functions
createBlockImageViewElement( writer ) → ViewContainerElementinternalmodule:image/image/utils~createBlockImageViewElementCreates a view element representing the block image.
<figure class="image"><img></img></figure>Copy codeNote that
altandsrcattributes are converted separately, so they are not included.Parameters
writer : ViewDowncastWriter
Returns
createInlineImageViewElement( writer ) → ViewContainerElementinternalmodule:image/image/utils~createInlineImageViewElementCreates a view element representing the inline image.
<span class="image-inline"><img></img></span>Copy codeNote that
altandsrcattributes are converted separately, so they are not included.Parameters
writer : ViewDowncastWriter
Returns
determineImageTypeForInsertionAtSelection( schema, selection ) → 'imageBlock' | 'imageInline'internalmodule:image/image/utils~determineImageTypeForInsertionAtSelectionConsidering the current model selection, it returns the name of the model image element (
'imageBlock'or'imageInline') that will make most sense from the UX perspective if a new image was inserted (also: uploaded, dropped, pasted) at that selection.The assumption is that inserting images into empty blocks or on other block widgets should produce block images. Inline images should be inserted in other cases, e.g. in paragraphs that already contain some text.
Parameters
schema : ModelSchemaselection : ModelSelection | ModelDocumentSelection
Returns
'imageBlock' | 'imageInline'
getImgViewElementMatcher( editor, matchImageType ) → MatcherPatterninternalmodule:image/image/utils~getImgViewElementMatcherA function returning a
MatcherPatternfor a particular type of View images.Parameters
editor : EditormatchImageType : 'imageBlock' | 'imageInline'The type of created image.
Returns
getSizeValueIfInPx( size ) → null | numberinternalmodule:image/image/utils~getSizeValueIfInPxReturns parsed value of the size, but only if it contains unit: px.
Parameters
size : undefined | string
Returns
null | number
widthAndHeightStylesAreBothSet( viewElement ) → booleaninternalmodule:image/image/utils~widthAndHeightStylesAreBothSetReturns true if both styles (width and height) are set.
If both image styles: width & height are set, they will override the image width & height attributes in the browser. In this case, the image looks the same as if these styles were applied to attributes instead of styles. That's why we can upcast these styles to width & height attributes instead of resizedWidth and resizedHeight.
Parameters
viewElement : ViewElement
Returns
boolean