Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Docs: Image upload API docs corrected. [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaTomanek committed Oct 18, 2019
1 parent 93aa0bb commit 63e610b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions src/imageupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,20 @@ export default class ImageUpload extends Plugin {
*/

/**
* List of accepted image types.
* The list of accepted image types.
*
* The accepted types of images can be customize to allow only certain types of images:
* The accepted types of images can be customized to allow only certain types of images:
*
* // Allow only JPEG and PNG images:
* const imageUploadConfig = {
* types: [ 'png', 'jpeg' ]
* };
*
* The type string should match [one of the sub-types](https://www.iana.org/assignments/media-types/media-types.xhtml#image)
* of the image mime-type. E.g. for the `image/jpeg` mime-type add `'jpeg'`.
* of the image MIME type. E.g. for the `image/jpeg` MIME type, add `'jpeg'` to your image upload configuration.
*
* **Note:** This setting only restricts some image types to be selected and uploaded through the CKEditor UI and commands. Image type
* recognition and filtering should be also implemented on the server which accepts image uploads
* recognition and filtering should also be implemented on the server which accepts image uploads.
*
* @member {Array.<String>} module:image/imageupload~ImageUploadConfig#types
* @default [ 'jpeg', 'png', 'gif', 'bmp', 'webp', 'tiff' ]
Expand Down
2 changes: 1 addition & 1 deletion src/imageupload/imageuploadcommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { insertImage, isImageAllowed } from '../image/utils';
*/

/**
* Image upload command.
* The image upload command.
*
* The command is registered by the {@link module:image/imageupload/imageuploadediting~ImageUploadEditing} plugin as `'imageUpload'`.
*
Expand Down
10 changes: 5 additions & 5 deletions src/imageupload/imageuploadediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ export default class ImageUploadEditing extends Plugin {
}

/**
* Read and upload an image.
* Reads and uploads an image.
*
* The image is read from the disk and as a base64 encoded string it is set temporarily to
* `image[src]`. When the image is successfully uploaded the temporary data is replaced with the target
* The image is read from the disk and as a Base64-encoded string it is set temporarily to
* `image[src]`. When the image is successfully uploaded, the temporary data is replaced with the target
* image's URL (the URL to the uploaded image on the server).
*
* @protected
Expand Down Expand Up @@ -291,11 +291,11 @@ export default class ImageUploadEditing extends Plugin {
}

/**
* Creates `srcset` attribute based on a given file upload response and sets it as an attribute to a specific image element.
* Creates the `srcset` attribute based on a given file upload response and sets it as an attribute to a specific image element.
*
* @protected
* @param {Object} data Data object from which `srcset` will be created.
* @param {module:engine/model/element~Element} image The image element on which `srcset` attribute will be set.
* @param {module:engine/model/element~Element} image The image element on which the `srcset` attribute will be set.
* @param {module:engine/model/writer~Writer} writer
*/
_parseAndSetSrcsetAttributeOnImage( data, image, writer ) {
Expand Down
28 changes: 14 additions & 14 deletions src/imageupload/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/* global fetch, File */

/**
* Creates a RegExp used to test for image files.
* Creates a regular expression used to test for image files.
*
* const imageType = createImageTypeRegExp( [ 'png', 'jpeg', 'svg+xml', 'vnd.microsoft.icon' ] );
*
Expand All @@ -20,18 +20,18 @@
* @returns {RegExp}
*/
export function createImageTypeRegExp( types ) {
// Sanitize mime-type name which may include: "+", "-" or ".".
// Sanitize the MIME type name which may include: "+", "-" or ".".
const regExpSafeNames = types.map( type => type.replace( '+', '\\+' ) );

return new RegExp( `^image\\/(${ regExpSafeNames.join( '|' ) })$` );
}

/**
* Creates a promise which fetches the image local source (base64 or blob) and resolves with a `File` object.
* Creates a promise that fetches the image local source (Base64 or blob) and resolves with a `File` object.
*
* @param {module:engine/view/element~Element} image Image which source to fetch.
* @returns {Promise.<File>} A promise which resolves when image source is fetched and converted to `File` instance.
* It resolves with a `File` object. If there were any errors during file processing the promise will be rejected.
* @param {module:engine/view/element~Element} image Image whose source to fetch.
* @returns {Promise.<File>} A promise which resolves when an image source is fetched and converted to a `File` instance.
* It resolves with a `File` object. If there were any errors during file processing, the promise will be rejected.
*/
export function fetchLocalImage( image ) {
return new Promise( ( resolve, reject ) => {
Expand All @@ -53,9 +53,9 @@ export function fetchLocalImage( image ) {
}

/**
* Checks whether given node is an image element with local source (base64 or blob).
* Checks whether a given node is an image element with a local source (Base64 or blob).
*
* @param {module:engine/view/node~Node} node Node to check.
* @param {module:engine/view/node~Node} node The node to check.
* @returns {Boolean}
*/
export function isLocalImage( node ) {
Expand All @@ -67,9 +67,9 @@ export function isLocalImage( node ) {
node.getAttribute( 'src' ).match( /^blob:/g );
}

// Extracts image type based on its blob representation or its source.
// Extracts an image type based on its blob representation or its source.
//
// @param {String} src Image src attribute value.
// @param {String} src Image `src` attribute value.
// @param {Blob} blob Image blob representation.
// @returns {String}
function getImageMimeType( blob, src ) {
Expand All @@ -83,11 +83,11 @@ function getImageMimeType( blob, src ) {
}
}

// Creates `File` instance from the given `Blob` instance using specified filename.
// Creates a `File` instance from the given `Blob` instance using the specified file name.
//
// @param {Blob} blob The `Blob` instance from which file will be created.
// @param {String} filename Filename used during file creation.
// @param {String} mimeType File mime type.
// @param {Blob} blob The `Blob` instance from which the file will be created.
// @param {String} filename The file name used during the file creation.
// @param {String} mimeType The file MIME type.
// @returns {File|null} The `File` instance created from the given blob or `null` if `File API` is not available.
function createFileFromBlob( blob, filename, mimeType ) {
try {
Expand Down

0 comments on commit 63e610b

Please sign in to comment.