Module

ckbox/utils

@ckeditor/ckeditor5-ckbox/src/utils

module

Filtering

Functions

  • blurHashToDataUrl( [ hash ] ) → undefined | string

    Generates an image data URL from its blurhash representation.

    Parameters

    [ hash ] : string

    Returns

    undefined | string
  • convertMimeTypeToExtension( mimeType ) → string

    Returns an extension a typical file in the specified mimeType format would have.

    Parameters

    mimeType : string

    Returns

    string
  • getContentTypeOfUrl( url, options = { options.signal } ) → Promise<string>

    Tries to fetch the given url and returns 'content-type' of the response.

    Parameters

    url : string
    options : object
    Properties
    options.signal : AbortSignal

    Returns

    Promise<string>
  • getFileExtension( file ) → string

    Returns an extension from the given value.

    Parameters

    file : File

    Returns

    string
  • getImageUrls( imageUrls ) → object

    Converts image source set provided by the CKBox into an object containing:

    • responsive URLs for the "webp" image format,
    • one fallback URL for browsers that do not support the "webp" format.

    Parameters

    imageUrls : CKBoxImageUrls

    Returns

    object
  • getWorkspaceId( token, [ defaultWorkspaceId ] ) → null | string

    Returns a workspace id to use for communication with the CKBox service.

    Parameters

    token : InitializedToken
    [ defaultWorkspaceId ] : string

    The default workspace to use taken from editor config.

    Returns

    null | string
  • internal

    sendHttpRequest( options = { options.authorization, [options.data], [options.method], [options.onUploadProgress], options.signal, options.url } ) → Promise<any>

    Sends the HTTP request.

    Parameters

    options : object

    Configuration options

    Properties
    options.authorization : string

    The authorization token for the request.

    [ options.data ] : null | FormData

    Additional data to send.

    [ options.method ] : 'POST' | 'GET'

    The HTTP method (default: 'GET').

    Defaults to 'GET'

    [ options.onUploadProgress ] : ( evt: ProgressEvent ) => void

    A callback informing about the upload progress.

    options.signal : AbortSignal

    The AbortSignal to abort the request when needed.

    options.url : URL

    The URL where the request will be sent.

    Returns

    Promise<any>