|
@@ -9,7 +9,6 @@
|
|
|
|
|
|
|
|
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
|
|
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
|
|
|
import Token from '@ckeditor/ckeditor-cloudservices-core/src/token/token';
|
|
import Token from '@ckeditor/ckeditor-cloudservices-core/src/token/token';
|
|
|
-import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Base plugin for Cloud Services. It takes care about the `cloudServices` config options and initializes token provider.
|
|
* Base plugin for Cloud Services. It takes care about the `cloudServices` config options and initializes token provider.
|
|
@@ -22,7 +21,7 @@ export default class CloudServices extends Plugin {
|
|
|
const editor = this.editor;
|
|
const editor = this.editor;
|
|
|
const config = editor.config;
|
|
const config = editor.config;
|
|
|
|
|
|
|
|
- const options = config.get( 'cloudServices' );
|
|
|
|
|
|
|
+ const options = config.get( 'cloudServices' ) || {};
|
|
|
|
|
|
|
|
for ( const optionName in options ) {
|
|
for ( const optionName in options ) {
|
|
|
this[ optionName ] = options[ optionName ];
|
|
this[ optionName ] = options[ optionName ];
|
|
@@ -35,22 +34,20 @@ export default class CloudServices extends Plugin {
|
|
|
* @member {String} #tokenUrl
|
|
* @member {String} #tokenUrl
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
- if ( !this.tokenUrl ) {
|
|
|
|
|
- /**
|
|
|
|
|
- * The authentication `cloudServices.tokenUrl` config is not provided.
|
|
|
|
|
- *
|
|
|
|
|
- * @error cloudservices-token-endpoint-not-provided
|
|
|
|
|
- */
|
|
|
|
|
- throw new CKEditorError(
|
|
|
|
|
- 'cloudservices-token-endpoint-not-provided: The authentication `cloudServices.tokenUrl` config is not provided.'
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Other plugins use this token for authorization process. It handles token requesting and refreshing.
|
|
* Other plugins use this token for authorization process. It handles token requesting and refreshing.
|
|
|
|
|
+ * Its value is null when `tokenUrl` is not provided.
|
|
|
*
|
|
*
|
|
|
* @readonly
|
|
* @readonly
|
|
|
|
|
+ * @member {Object|null} #token
|
|
|
*/
|
|
*/
|
|
|
|
|
+
|
|
|
|
|
+ if ( !this.tokenUrl ) {
|
|
|
|
|
+ this.token = null;
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
this.token = new CloudServices.Token( this.tokenUrl );
|
|
this.token = new CloudServices.Token( this.tokenUrl );
|
|
|
|
|
|
|
|
return this.token.init();
|
|
return this.token.init();
|