Skip to content

Commit

Permalink
Merge pull request #9011 from ckeditor/i/8811
Browse files Browse the repository at this point in the history
Other (cloud-services-core): All classes available in the `@ckeditor/ckeditor-cloud-services-core` package have been moved to the `@ckeditor/ckeditor5-cloud-services` package. They should now be instantiated via factory methods on the `CloudServicesCore` plugin. Closes #8811.

Feature (cloud-services): Created the `CloudServicesCore` plugin that exposes the base API for communication with CKEditor Cloud Services.

MAJOR BREAKING CHANGE (cloud-services-core): The package has been merged into `@ckeditor/ckeditor5-cloud-services`. All classes that were available in the `@ckeditor/ckeditor-cloud-services-core` package have been moved to the `@ckeditor/ckeditor5-cloud-services` package. They should now be instantiated via factory methods on the `CloudServicesCore` plugin that's located in `@ckeditor/ckeditor5-cloud-services`. See #8811.
  • Loading branch information
Reinmar committed Feb 23, 2021
2 parents 2165447 + 5bb7d9e commit 959c1d6
Show file tree
Hide file tree
Showing 43 changed files with 947 additions and 199 deletions.
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,6 @@ See CKEditor 5 release blog posts [on the CKEditor blog](https://ckeditor.com/bl
</td>
</tr>

<tr>
<td>
<a href="https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor-cloud-services-core"><code>@ckeditor/ckeditor-cloud-services-core</code></a>
</td>
<td>
<a href="https://www.npmjs.com/package/@ckeditor/ckeditor-cloud-services-core"><img src="https://img.shields.io/npm/v/@ckeditor/ckeditor-cloud-services-core.svg" alt="@ckeditor/ckeditor-cloud-services-core npm package badge"></a>
</td>
<td>
CKEditor Cloud Services integration utils.
</td>
</tr>

</tbody>
</table>

Expand Down
9 changes: 6 additions & 3 deletions docs/_snippets/examples/multi-root-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,12 @@ MultirootEditor
footerleft: document.querySelector( '#footer-left' ),
footerright: document.querySelector( '#footer-right' )
}, {
plugins: [ Essentials, Paragraph, Heading, Bold, Italic, List, Link, BlockQuote, Image, ImageCaption,
ImageStyle, ImageToolbar, ImageUpload, Table, TableToolbar, MediaEmbed, EasyImage, CloudServices ],
toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'uploadImage', 'blockQuote',
plugins: [
Essentials, Paragraph, Heading, Bold, Italic, List, Link, BlockQuote, Image, ImageCaption,
ImageStyle, ImageToolbar, ImageUpload, Table, TableToolbar, MediaEmbed, EasyImage, CloudServices
],
toolbar: [
'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'uploadImage', 'blockQuote',
'insertTable', 'mediaEmbed', 'undo', 'redo' ],
image: {
toolbar: [ 'imageTextAlternative', '|', 'imageStyle:full',
Expand Down
2 changes: 0 additions & 2 deletions docs/builds/guides/development/dll-builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ The base DLL build contains:
* `@ckeditor/ckeditor5-widget`
* Other, frequently required plugins:
* `@ckeditor/ckeditor5-upload`
* Cloud Services plugins:
* `@ckeditor/ckeditor-cloud-services-core`

### The editor bundles

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"framework"
],
"dependencies": {
"@ckeditor/ckeditor-cloud-services-core": "^25.0.0",
"@ckeditor/ckeditor5-adapter-ckfinder": "^25.0.0",
"@ckeditor/ckeditor5-alignment": "^25.0.0",
"@ckeditor/ckeditor5-autoformat": "^25.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor-cloud-services-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CKEditor Cloud Services Core

## Documentation

See the [`@ckeditor/ckeditor-cloud-services-core` package](https://ckeditor.com/docs/ckeditor5/latest/api/cloud-services-core.html) page in [CKEditor 5 documentation](https://ckeditor.com/docs/ckeditor5/latest/).
**NOTE:** This package has been merged into `@ckeditor/ckeditor5-cloud-services`. See https://ckeditor.com/docs/ckeditor5/latest/api/module_cloud-services_cloudservicescore-CloudServicesCore.html

## License

Expand Down

This file was deleted.

7 changes: 0 additions & 7 deletions packages/ckeditor-cloud-services-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
"ckeditor5",
"ckeditor5-lib"
],
"main": "src/index.js",
"dependencies": {
"ckeditor5": "^25.0.0"
},
"devDependencies": {
"@ckeditor/ckeditor5-utils": "^25.0.0"
},
"engines": {
"node": ">=12.0.0",
"npm": ">=5.7.1"
Expand Down
12 changes: 0 additions & 12 deletions packages/ckeditor-cloud-services-core/src/index.js

This file was deleted.

10 changes: 10 additions & 0 deletions packages/ckeditor-cloud-services-core/tests/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

describe( 'Cloud Services Core', () => {
it( 'does not fail on CI because of 0 tests', () => {
expect( 1 ).to.equal( 1 ); // Bacause it's easier than reconfiguring CI scripts.
} );
} );

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/ckeditor5-build-balloon/build/ckeditor.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/ckeditor5-build-classic/build/ckeditor.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/ckeditor5-build-inline/build/ckeditor.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion packages/ckeditor5-cloud-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"ckeditor5": "^25.0.0"
},
"devDependencies": {
"@ckeditor/ckeditor-cloud-services-core": "^25.0.0",
"@ckeditor/ckeditor5-core": "^25.0.0",
"@ckeditor/ckeditor5-dev-utils": "^24.0.0",
"@ckeditor/ckeditor5-editor-classic": "^25.0.0",
Expand Down
25 changes: 15 additions & 10 deletions packages/ckeditor5-cloud-services/src/cloudservices.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
*/

import { ContextPlugin } from 'ckeditor5/src/core';
import { Token } from 'ckeditor5/src/cloud-services-core';
import { CKEditorError } from 'ckeditor5/src/utils';
import CloudServicesCore from './cloudservicescore';

/**
* Plugin introducing the integration between CKEditor 5 and CKEditor Cloud Services .
*
* It initializes the token provider based on
* the {@link module:cloud-services/cloudservices~CloudServicesConfig `config.cloudService`}.
*
* @extends module:core/plugin~Plugin
* @extends module:core/contextplugin~ContextPlugin
*/
export default class CloudServices extends ContextPlugin {
/**
Expand All @@ -27,6 +27,13 @@ export default class CloudServices extends ContextPlugin {
return 'CloudServices';
}

/**
* @inheritDoc
*/
static get requires() {
return [ CloudServicesCore ];
}

/**
* @inheritDoc
*/
Expand All @@ -43,7 +50,7 @@ export default class CloudServices extends ContextPlugin {
* A map of token object instances keyed by the token URLs.
*
* @private
* @type {Map.<String, module:cloud-services-core/token~Token>}
* @type {Map.<String, module:cloud-services/token~Token>}
*/
this._tokens = new Map();

Expand All @@ -67,7 +74,7 @@ export default class CloudServices extends ContextPlugin {
* Its value is `null` when {@link module:cloud-services/cloudservices~CloudServicesConfig#tokenUrl} is not provided.
*
* @readonly
* @member {module:cloud-services-core/token~Token|null} #token
* @member {module:cloud-services/token~Token|null} #token
*/

if ( !this.tokenUrl ) {
Expand All @@ -76,7 +83,7 @@ export default class CloudServices extends ContextPlugin {
return;
}

this.token = new CloudServices.Token( this.tokenUrl );
this.token = this.context.plugins.get( 'CloudServicesCore' ).createToken( this.tokenUrl );

this._tokens.set( this.tokenUrl, this.token );

Expand All @@ -88,15 +95,15 @@ export default class CloudServices extends ContextPlugin {
* {@link module:cloud-services/cloudservices~CloudServicesConfig#tokenUrl} for more details.
*
* @param {String|Function} tokenUrl The authentication token URL for CKEditor Cloud Services or a callback to the token value promise.
* @returns {Promise.<module:cloud-services-core/token~Token>}
* @returns {Promise.<module:cloud-services/token~Token>}
*/
registerTokenUrl( tokenUrl ) {
// Reuse the token instance in case of multiple features using the same token URL.
if ( this._tokens.has( tokenUrl ) ) {
return Promise.resolve( this.getTokenFor( tokenUrl ) );
}

const token = new CloudServices.Token( tokenUrl );
const token = this.context.plugins.get( 'CloudServicesCore' ).createToken( tokenUrl );

this._tokens.set( tokenUrl, token );

Expand All @@ -107,7 +114,7 @@ export default class CloudServices extends ContextPlugin {
* Returns an authentication token provider previously registered by {@link #registerTokenUrl}.
*
* @param {String|Function} tokenUrl The authentication token URL for CKEditor Cloud Services or a callback to the token value promise.
* @returns {module:cloud-services-core/token~Token}
* @returns {module:cloud-services/token~Token}
*/
getTokenFor( tokenUrl ) {
const token = this._tokens.get( tokenUrl );
Expand Down Expand Up @@ -136,8 +143,6 @@ export default class CloudServices extends ContextPlugin {
}
}

CloudServices.Token = Token;

/**
* The configuration of CKEditor Cloud Services. Introduced by the {@link module:cloud-services/cloudservices~CloudServices} plugin.
*
Expand Down
51 changes: 51 additions & 0 deletions packages/ckeditor5-cloud-services/src/cloudservicescore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/**
* @module cloud-services/cloudservicescore
*/

import { ContextPlugin } from 'ckeditor5/src/core';
import Token from './token/token';
import UploadGateway from './uploadgateway/uploadgateway';

/**
* The `CloudServicesCore` plugin exposes the base API for communication with CKEditor Cloud Services.
*
* @extends module:core/contextplugin~ContextPlugin
*/
export default class CloudServicesCore extends ContextPlugin {
/**
* @inheritDoc
*/
static get pluginName() {
return 'CloudServicesCore';
}

/**
* Creates the {@link module:cloud-services/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 module:cloud-services/token~refreshToken} interface.
* @param {Object} [options]
* @param {String} [options.initValue] Initial value of the token.
* @param {Boolean} [options.autoRefresh=true] Specifies whether to start the refresh automatically.
* @returns {module:cloud-services/token~Token}
*/
createToken( tokenUrlOrRefreshToken, options ) {
return new Token( tokenUrlOrRefreshToken, options );
}

/**
* Creates the {@link module:cloud-services/uploadgateway/uploadgateway~UploadGateway} instance.
*
* @param {module:cloud-services/token~Token} token Token used for authentication.
* @param {String} apiAddress API address.
* @returns {module:cloud-services/uploadgateway/uploadgateway~UploadGateway}
*/
createUploadGateway( token, apiAddress ) {
return new UploadGateway( token, apiAddress );
}
}
4 changes: 3 additions & 1 deletion packages/ckeditor5-cloud-services/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
*/

import CloudServices from './cloudservices';
import CloudServicesCore from './cloudservicescore';

export default {
CloudServices
CloudServices,
CloudServicesCore
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

/**
* @module cloud-services-core/token
* @module cloud-services/token
*/

/* globals XMLHttpRequest, setTimeout, clearTimeout, atob */
Expand All @@ -26,7 +26,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 module:cloud-services-core/token~refreshToken} interface.
* value is a function it has to match the {@link module:cloud-services/token~refreshToken} interface.
* @param {Object} options
* @param {String} [options.initValue] Initial value of the token.
* @param {Boolean} [options.autoRefresh=true] Specifies whether to start the refresh automatically.
Expand Down Expand Up @@ -82,7 +82,7 @@ class Token {
/**
* Initializes the token.
*
* @returns {Promise.<module:cloud-services-core/token~Token>}
* @returns {Promise.<module:cloud-services/token~Token>}
*/
init() {
return new Promise( ( resolve, reject ) => {
Expand Down Expand Up @@ -194,14 +194,14 @@ class Token {
}

/**
* Creates a initialized {@link module:cloud-services-core/token~Token} instance.
* Creates a initialized {@link module:cloud-services/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 module:cloud-services-core/token~refreshToken} interface.
* value is a function it has to match the {@link module:cloud-services/token~refreshToken} interface.
* @param {Object} options
* @param {String} [options.initValue] Initial value of the token.
* @param {Boolean} [options.autoRefresh=true] Specifies whether to start the refresh automatically.
* @returns {Promise.<module:cloud-services-core/token~Token>}
* @returns {Promise.<module:cloud-services/token~Token>}
*/
static create( tokenUrlOrRefreshToken, options = DEFAULT_OPTIONS ) {
const token = new Token( tokenUrlOrRefreshToken, options );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

/**
* @module cloud-services-core/uploadgateway/fileuploader
* @module cloud-services/uploadgateway/fileuploader
*/

/* globals XMLHttpRequest, FormData, Blob, atob */
Expand All @@ -21,7 +21,7 @@ export default class FileUploader {
* Creates `FileUploader` instance.
*
* @param {Blob|String} fileOrData A blob object or a data string encoded with Base64.
* @param {module:cloud-services-core/token~Token} token Token used for authentication.
* @param {module:cloud-services/token~Token} token Token used for authentication.
* @param {String} apiAddress API address.
*/
constructor( fileOrData, token, apiAddress ) {
Expand Down Expand Up @@ -62,7 +62,7 @@ export default class FileUploader {
/**
* CKEditor Cloud Services access token.
*
* @type {module:cloud-services-core/token~Token}
* @type {module:cloud-services/token~Token}
* @private
*/
this._token = token;
Expand All @@ -81,7 +81,7 @@ export default class FileUploader {
*
* @chainable
* @param {Function} callback
* @returns {module:cloud-services-core/uploadgateway/fileuploader~FileUploader}
* @returns {module:cloud-services/uploadgateway/fileuploader~FileUploader}
*/
onProgress( callback ) {
this.on( 'progress', ( event, data ) => callback( data ) );
Expand All @@ -94,7 +94,7 @@ export default class FileUploader {
*
* @chainable
* @param {Function} callback
* @returns {module:cloud-services-core/uploadgateway/fileuploader~FileUploader}
* @returns {module:cloud-services/uploadgateway/fileuploader~FileUploader}
*/
onError( callback ) {
this.once( 'error', ( event, data ) => callback( data ) );
Expand Down

0 comments on commit 959c1d6

Please sign in to comment.