ckbox/utils
module
Functions
-
blurHashToDataUrl( [ hash ] ) → undefined | string
internalmodule:ckbox/utils~blurHashToDataUrl
Generates an image data URL from its
blurhash
representation.Parameters
[ hash ] : string
Returns
undefined | string
-
convertMimeTypeToExtension( mimeType ) → string
internalmodule:ckbox/utils~convertMimeTypeToExtension
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>
internalmodule:ckbox/utils~getContentTypeOfUrl
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
internalmodule:ckbox/utils~getFileExtension
Returns an extension from the given value.
Parameters
file : File
Returns
string
-
getImageUrls( imageUrls ) → object
internalmodule:ckbox/utils~getImageUrls
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
internalmodule:ckbox/utils~getWorkspaceId
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
-
sendHttpRequest( options = { options.authorization, [options.data], [options.method], [options.onUploadProgress], options.signal, options.url } ) → Promise<any>
internalmodule:ckbox/utils~sendHttpRequest
Sends the HTTP request.
Parameters
options : object
Configuration options
Propertiesoptions.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>