ckbox/utils
module
Functions
blurHashToDataUrl( hash? ) → string | undefinedinternalmodule:ckbox/utils~blurHashToDataUrlGenerates an image data URL from its
blurhashrepresentation.Parameters
hash?: string
Returns
string | undefined
convertMimeTypeToExtension( mimeType ) → stringinternalmodule:ckbox/utils~convertMimeTypeToExtensionReturns an extension a typical file in the specified
mimeTypeformat would have.Parameters
mimeType: string
Returns
string
getContentTypeOfUrl( url, options = { options.signal } ) → Promise<string>internalmodule:ckbox/utils~getContentTypeOfUrlTries to fetch the given
urland returns 'content-type' of the response.Parameters
url: stringoptions: object- Properties
options.signal: AbortSignal
Returns
Promise<string>
getFileExtension( file ) → stringinternalmodule:ckbox/utils~getFileExtensionReturns an extension from the given value.
Parameters
file: File
Returns
string
getImageUrls( imageUrls ) → objectinternalmodule:ckbox/utils~getImageUrlsConverts 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? ) → string | nullinternalmodule:ckbox/utils~getWorkspaceIdReturns a workspace id to use for communication with the CKBox service.
Parameters
token: InitializedTokendefaultWorkspaceId?: stringThe default workspace to use taken from editor config.
Returns
string | null
sendHttpRequest( options = { options.authorization, options.data?, options.method?, options.onUploadProgress?, options.signal, options.url } ) → Promise<any>internalmodule:ckbox/utils~sendHttpRequestSends the HTTP request.
Parameters
options: objectConfiguration options
Propertiesoptions.authorization: stringThe authorization token for the request.
options.data?: FormData | nullAdditional data to send.
options.method?: 'POST' | 'GET'The HTTP method (default: 'GET').
Defaults to
'GET'options.onUploadProgress?: ( evt: ProgressEvent ) => voidA callback informing about the upload progress.
options.signal: AbortSignalThe AbortSignal to abort the request when needed.
options.url: URLThe URL where the request will be sent.
Returns
Promise<any>