image/image/utils
@ckeditor/ckeditor5-image/src/image/utils
Filtering
Functions
-
internal
createBlockImageViewElement( writer ) → ContainerElement
module:image/image/utils~createBlockImageViewElement
Creates a view element representing the block image.
<figure class="image"><img></img></figure>
Note that
alt
andsrc
attributes are converted separately, so they are not included.Parameters
writer : DowncastWriter
Returns
-
internal
createInlineImageViewElement( writer ) → ContainerElement
module:image/image/utils~createInlineImageViewElement
Creates a view element representing the inline image.
<span class="image-inline"><img></img></span>
Note that
alt
andsrc
attributes are converted separately, so they are not included.Parameters
writer : DowncastWriter
Returns
-
internal
determineImageTypeForInsertionAtSelection( schema, selection ) → 'imageBlock' | 'imageInline'
module:image/image/utils~determineImageTypeForInsertionAtSelection
Considering 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 : Schema
selection : Selection | DocumentSelection
Returns
'imageBlock' | 'imageInline'
-
internal
getImgViewElementMatcher( editor, matchImageType ) → MatcherPattern
module:image/image/utils~getImgViewElementMatcher
A function returning a
MatcherPattern
for a particular type of View images.Parameters
editor : Editor
matchImageType : 'imageBlock' | 'imageInline'
The type of created image.
Returns
-
getSizeValueIfInPx( size ) → number | null
module:image/image/utils~getSizeValueIfInPx
Returns parsed value of the size, but only if it contains unit: px.
Parameters
size : undefined | string
Returns
number | null
-
widthAndHeightStylesAreBothSet( viewElement ) → boolean
module:image/image/utils~widthAndHeightStylesAreBothSet
Returns 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 : Element
Returns
boolean
Every day, we work hard to keep our documentation complete. Have you spotted outdated information? Is something missing? Please report it via our issue tracker.
With the release of version 42.0.0, we have rewritten much of our documentation to reflect the new import paths and features. We appreciate your feedback to help us ensure its accuracy and completeness.