ckbox/utils
module
Functions
blurHashToDataUrl( [ hash ] ) → undefined | stringinternalmodule:ckbox/utils~blurHashToDataUrlGenerates an image data URL from its
blurhashrepresentation.Parameters
[ hash ] : string
Returns
undefined | string
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 ] ) → null | stringinternalmodule:ckbox/utils~getWorkspaceIdReturns a workspace id to use for communication with the CKBox service.
Parameters
token : InitializedToken[ defaultWorkspaceId ] : stringThe default workspace to use taken from editor config.
Returns
null | string
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 ] : null | FormDataAdditional 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>