Kaynağa Gözat

Docs fixes.

Kamil Piechaczek 6 yıl önce
ebeveyn
işleme
612a818e2a

+ 0 - 1
packages/ckeditor-cloud-services-core/.gitignore

@@ -1,5 +1,4 @@
 node_modules
 coverage
 .idea
-
 package-lock.json

+ 13 - 7
packages/ckeditor-cloud-services-core/src/token/token.js

@@ -3,7 +3,11 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
-/* eslint-env browser */
+/**
+ * @module ckeditor-cloud-services-core/token
+ */
+
+/* globals XMLHttpRequest, setInterval, clearInterval */
 
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
@@ -23,7 +27,7 @@ class Token {
 	 * Method `init` should be called after using the constructor or use `create` method instead.
 	 *
 	 * @param {String|Function} tokenUrlOrRefreshToken Endpoint address to download the token or a callback that provides the token. If the
-	 * value is a function it has to match the {@link ~refreshToken} interface.
+	 * value is a function it has to match the {@link module:ckeditor-cloud-services-core/token~refreshToken} interface.
 	 * @param {Object} options
 	 * @param {String} [options.initValue] Initial value of the token.
 	 * @param {Number} [options.refreshInterval=3600000] Delay between refreshes. Default 1 hour.
@@ -76,7 +80,7 @@ class Token {
 	/**
 	 * Initializes the token.
 	 *
-	 * @returns {Promise.<Token>}
+	 * @returns {Promise.<module:ckeditor-cloud-services-core/token~Token>}
 	 */
 	init() {
 		return new Promise( ( resolve, reject ) => {
@@ -133,15 +137,15 @@ class Token {
 	}
 
 	/**
-	 * Creates a initialized {@link Token} instance.
+	 * Creates a initialized {@link module:ckeditor-cloud-services-core/token~Token} instance.
 	 *
 	 * @param {String|Function} tokenUrlOrRefreshToken Endpoint address to download the token or a callback that provides the token. If the
-	 * value is a function it has to match the {@link ~refreshToken} interface.
+	 * value is a function it has to match the {@link module:ckeditor-cloud-services-core/token~refreshToken} interface.
 	 * @param {Object} options
 	 * @param {String} [options.initValue] Initial value of the token.
 	 * @param {Number} [options.refreshInterval=3600000] Delay between refreshes. Default 1 hour.
 	 * @param {Boolean} [options.autoRefresh=true] Specifies whether to start the refresh automatically.
-	 * @returns {Promise.<Token>}
+	 * @returns {Promise.<module:ckeditor-cloud-services-core/token~Token>}
 	 */
 	static create( tokenUrlOrRefreshToken, options = DEFAULT_OPTIONS ) {
 		const token = new Token( tokenUrlOrRefreshToken, options );
@@ -181,7 +185,9 @@ function defaultRefreshToken( tokenUrl ) {
 				 *
 				 * @error token-cannot-download-new-token
 				 */
-				return reject( new CKEditorError( 'token-cannot-download-new-token: Cannot download new token from the provided url.', null ) );
+				return reject(
+					new CKEditorError( 'token-cannot-download-new-token: Cannot download new token from the provided url.', null )
+				);
 			}
 
 			return resolve( xhrResponse );

+ 9 - 5
packages/ckeditor-cloud-services-core/src/uploadgateway/fileuploader.js

@@ -3,7 +3,11 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
-/* eslint-env browser */
+/**
+ * @module ckeditor-cloud-services-core/fileuploader
+ */
+
+/* globals XMLHttpRequest, FormData, Blob, atob */
 
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
@@ -19,7 +23,7 @@ export default class FileUploader {
 	 * Creates `FileUploader` instance.
 	 *
 	 * @param {Blob|String} fileOrData A blob object or a data string encoded with Base64.
-	 * @param {Token} token Token used for authentication.
+	 * @param {module:ckeditor-cloud-services-core/token~Token} token Token used for authentication.
 	 * @param {String} apiAddress API address.
 	 */
 	constructor( fileOrData, token, apiAddress ) {
@@ -60,7 +64,7 @@ export default class FileUploader {
 		/**
 		 * CKEditor Cloud Services access token.
 		 *
-		 * @type {Token}
+		 * @type {module:ckeditor-cloud-services-core/token~Token}
 		 * @private
 		 */
 		this._token = token;
@@ -79,7 +83,7 @@ export default class FileUploader {
 	 *
 	 * @chainable
 	 * @param {Function} callback
-	 * @returns {FileUploader}
+	 * @returns {module:ckeditor-cloud-services-core/fileuploader~FileUploader}
 	 */
 	onProgress( callback ) {
 		this.on( 'progress', ( event, data ) => callback( data ) );
@@ -92,7 +96,7 @@ export default class FileUploader {
 	 *
 	 * @chainable
 	 * @param {Function} callback
-	 * @returns {FileUploader}
+	 * @returns {module:ckeditor-cloud-services-core/fileuploader~FileUploader}
 	 */
 	onError( callback ) {
 		this.once( 'error', ( event, data ) => callback( data ) );

+ 11 - 16
packages/ckeditor-cloud-services-core/src/uploadgateway/uploadgateway.js

@@ -3,6 +3,10 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
+/**
+ * @module ckeditor-cloud-services-core/uploadgateway
+ */
+
 import FileUploader from './fileuploader';
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 
@@ -13,7 +17,7 @@ export default class UploadGateway {
 	/**
 	 * Creates `UploadGateway` instance.
 	 *
-	 * @param {Token} token Token used for authentication.
+	 * @param {module:ckeditor-cloud-services-core/token~Token} token Token used for authentication.
 	 * @param {String} apiAddress API address.
 	 */
 	constructor( token, apiAddress ) {
@@ -38,7 +42,7 @@ export default class UploadGateway {
 		/**
 		 * CKEditor Cloud Services access token.
 		 *
-		 * @type {Token}
+		 * @type {module:ckeditor-cloud-services-core/token~Token}
 		 * @private
 		 */
 		this._token = token;
@@ -53,9 +57,9 @@ export default class UploadGateway {
 	}
 
 	/**
-	 * Creates a {@link FileUploader} instance that wraps file upload process.
-	 * The file is being sent at a time when the method {@link FileUploader#then then} is called
-	 * or when {@link FileUploader#send send} method is called.
+	 * Creates a {@link module:ckeditor-cloud-services-core/fileuploader~FileUploader} instance that wraps
+	 * file upload process. The file is being sent at a time when the
+	 * {@link module:ckeditor-cloud-services-core/fileuploader~FileUploader#send} method is called.
 	 *
 	 *     const token = await Token.create( 'https://token-endpoint' );
 	 *     new UploadGateway( token, 'https://example.org' )
@@ -64,17 +68,8 @@ export default class UploadGateway {
 	 *        .send()
 	 *        .then( ( response ) => console.log( response ) );
 	 *
-	 *     // OR
-	 *
-	 *     const token = await Token.create( 'https://token-endpoint' );
-	 *     new UploadGateway( token, 'https://example.org' )
-	 *         .upload( 'FILE' )
-	 *         .onProgress( ( data ) => console.log( data ) )
-	 *         .send()
-	 *         .then( ( response ) => console.log( response ) );
-	 *
-	 * @param {Blob/String} fileOrData A blob object or a data string encoded with Base64.
-	 * @returns {FileUploader} Returns `FileUploader` instance.
+	 * @param {Blob|String} fileOrData A blob object or a data string encoded with Base64.
+	 * @returns {module:ckeditor-cloud-services-core/fileuploader~FileUploader} Returns `FileUploader` instance.
 	 */
 	upload( fileOrData ) {
 		return new FileUploader( fileOrData, this._token, this._apiAddress );