@ckeditor/ckeditor5-cloud-services 0.0.0-internal-20241017.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/LICENSE.md +17 -0
- package/README.md +22 -0
- package/build/cloud-services.js +4 -0
- package/ckeditor5-metadata.json +11 -0
- package/dist/augmentation.d.ts +23 -0
- package/dist/cloudservices.d.ts +92 -0
- package/dist/cloudservicesconfig.d.ts +128 -0
- package/dist/cloudservicescore.d.ts +44 -0
- package/dist/index-content.css +4 -0
- package/dist/index-editor.css +4 -0
- package/dist/index.css +4 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +573 -0
- package/dist/index.js.map +1 -0
- package/dist/token/token.d.ts +113 -0
- package/dist/uploadgateway/fileuploader.d.ts +98 -0
- package/dist/uploadgateway/uploadgateway.d.ts +51 -0
- package/package.json +39 -0
- package/src/augmentation.d.ts +19 -0
- package/src/augmentation.js +5 -0
- package/src/cloudservices.d.ts +88 -0
- package/src/cloudservices.js +109 -0
- package/src/cloudservicesconfig.d.ts +124 -0
- package/src/cloudservicesconfig.js +5 -0
- package/src/cloudservicescore.d.ts +40 -0
- package/src/cloudservicescore.js +47 -0
- package/src/index.d.ts +14 -0
- package/src/index.js +10 -0
- package/src/token/token.d.ts +109 -0
- package/src/token/token.js +206 -0
- package/src/uploadgateway/fileuploader.d.ts +94 -0
- package/src/uploadgateway/fileuploader.js +183 -0
- package/src/uploadgateway/uploadgateway.d.ts +47 -0
- package/src/uploadgateway/uploadgateway.js +60 -0
package/CHANGELOG.md
ADDED
package/LICENSE.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Software License Agreement
|
|
2
|
+
==========================
|
|
3
|
+
|
|
4
|
+
**CKEditor 5 Cloud Services integration** – https://github.com/ckeditor/ckeditor5-cloud-services <br>
|
|
5
|
+
Copyright (c) 2003–2024, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
|
|
6
|
+
|
|
7
|
+
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
|
|
8
|
+
|
|
9
|
+
Sources of Intellectual Property Included in CKEditor
|
|
10
|
+
-----------------------------------------------------
|
|
11
|
+
|
|
12
|
+
Where not otherwise indicated, all CKEditor content is authored by CKSource engineers and consists of CKSource-owned intellectual property. In some specific instances, CKEditor will incorporate work done by developers outside of CKSource with their express permission.
|
|
13
|
+
|
|
14
|
+
Trademarks
|
|
15
|
+
----------
|
|
16
|
+
|
|
17
|
+
**CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks, or service marks of their respective holders.
|
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
CKEditor 5's Cloud Services integration
|
|
2
|
+
=======================================
|
|
3
|
+
|
|
4
|
+
[](https://www.npmjs.com/package/@ckeditor/ckeditor5-cloud-services)
|
|
5
|
+
[](https://coveralls.io/github/ckeditor/ckeditor5?branch=master)
|
|
6
|
+
[](https://app.travis-ci.com/github/ckeditor/ckeditor5)
|
|
7
|
+
|
|
8
|
+
CKEditor 5's [Cloud Services](https://ckeditor.com/ckeditor-cloud-services/) integration layer, which handles `config.cloudServices` and tokens.
|
|
9
|
+
|
|
10
|
+
## Documentation
|
|
11
|
+
|
|
12
|
+
See the [`@ckeditor/ckeditor5-cloud-services` package](https://ckeditor.com/docs/ckeditor5/latest/api/cloud-services.html) page in [CKEditor 5 documentation](https://ckeditor.com/docs/ckeditor5/latest/).
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install ckeditor5
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## License
|
|
21
|
+
|
|
22
|
+
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html). For full details about the license, please check the `LICENSE.md` file or [https://ckeditor.com/legal/ckeditor-oss-license](https://ckeditor.com/legal/ckeditor-oss-license).
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md.
|
|
4
|
+
*/(()=>{var e={782:(e,t,r)=>{e.exports=r(237)("./src/core.js")},584:(e,t,r)=>{e.exports=r(237)("./src/utils.js")},237:e=>{"use strict";e.exports=CKEditor5.dll}},t={};function r(s){var o=t[s];if(void 0!==o)return o.exports;var n=t[s]={exports:{}};return e[s](n,n.exports,r),n.exports}r.d=(e,t)=>{for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};(()=>{"use strict";r.r(s),r.d(s,{CloudServices:()=>d,CloudServicesCore:()=>h});var e=r(782),t=r(584);const o={autoRefresh:!0},n=36e5;class i extends((0,t.ObservableMixin)()){constructor(e,r={}){if(super(),!e)throw new t.CKEditorError("token-missing-token-url",this);r.initValue&&this._validateTokenValue(r.initValue),this.set("value",r.initValue),this._refresh="function"==typeof e?e:()=>{return r=e,new Promise(((e,s)=>{const o=new XMLHttpRequest;o.open("GET",r),o.addEventListener("load",(()=>{const r=o.status,n=o.response;return r<200||r>299?s(new t.CKEditorError("token-cannot-download-new-token",null)):e(n)})),o.addEventListener("error",(()=>s(new Error("Network Error")))),o.addEventListener("abort",(()=>s(new Error("Abort")))),o.send()}));var r},this._options={...o,...r}}init(){return new Promise(((e,t)=>{this.value?(this._options.autoRefresh&&this._registerRefreshTokenTimeout(),e(this)):this.refreshToken().then(e).catch(t)}))}refreshToken(){const e=this._options.autoRefresh;return this._refresh().then((t=>(this._validateTokenValue(t),this.set("value",t),e&&this._registerRefreshTokenTimeout(),this))).catch((r=>{throw(0,t.logWarning)("token-refresh-failed",{autoRefresh:e}),e&&this._registerRefreshTokenTimeout(5e3),r}))}destroy(){clearTimeout(this._tokenRefreshTimeout)}_validateTokenValue(e){const r="string"==typeof e,s=!/^".*"$/.test(e),o=r&&3===e.split(".").length;if(!s||!o)throw new t.CKEditorError("token-not-in-jwt-format",this)}_registerRefreshTokenTimeout(e){const t=e||this._getTokenRefreshTimeoutTime();clearTimeout(this._tokenRefreshTimeout),this._tokenRefreshTimeout=setTimeout((()=>{this.refreshToken()}),t)}_getTokenRefreshTimeoutTime(){try{const[,e]=this.value.split("."),{exp:t}=JSON.parse(atob(e));if(!t)return n;return Math.floor((1e3*t-Date.now())/2)}catch(e){return n}}static create(e,t={}){return new i(e,t).init()}}const a=/^data:(\S*?);base64,/;class u extends((0,t.EmitterMixin)()){constructor(e,r,s){if(super(),!e)throw new t.CKEditorError("fileuploader-missing-file",null);if(!r)throw new t.CKEditorError("fileuploader-missing-token",null);if(!s)throw new t.CKEditorError("fileuploader-missing-api-address",null);this.file=function(e){if("string"!=typeof e)return!1;const t=e.match(a);return!(!t||!t.length)}(e)?function(e,r=512){try{const t=e.match(a)[1],s=atob(e.replace(a,"")),o=[];for(let e=0;e<s.length;e+=r){const t=s.slice(e,e+r),n=new Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);o.push(new Uint8Array(n))}return new Blob(o,{type:t})}catch(e){throw new t.CKEditorError("fileuploader-decoding-image-data-error",null)}}(e):e,this._token=r,this._apiAddress=s}onProgress(e){return this.on("progress",((t,r)=>e(r))),this}onError(e){return this.once("error",((t,r)=>e(r))),this}abort(){this.xhr.abort()}send(){return this._prepareRequest(),this._attachXHRListeners(),this._sendRequest()}_prepareRequest(){const e=new XMLHttpRequest;e.open("POST",this._apiAddress),e.setRequestHeader("Authorization",this._token.value),e.responseType="json",this.xhr=e}_attachXHRListeners(){const e=this.xhr,t=e=>()=>this.fire("error",e);e.addEventListener("error",t("Network Error")),e.addEventListener("abort",t("Abort")),e.upload&&e.upload.addEventListener("progress",(e=>{e.lengthComputable&&this.fire("progress",{total:e.total,uploaded:e.loaded})})),e.addEventListener("load",(()=>{const t=e.status,r=e.response;if(t<200||t>299)return this.fire("error",r.message||r.error)}))}_sendRequest(){const e=new FormData,r=this.xhr;return e.append("file",this.file),new Promise(((s,o)=>{r.addEventListener("load",(()=>{const e=r.status,n=r.response;return e<200||e>299?n.message?o(new t.CKEditorError("fileuploader-uploading-data-failed",this,{message:n.message})):o(n.error):s(n)})),r.addEventListener("error",(()=>o(new Error("Network Error")))),r.addEventListener("abort",(()=>o(new Error("Abort")))),r.send(e)}))}}class l{constructor(e,r){if(!e)throw new t.CKEditorError("uploadgateway-missing-token",null);if(!r)throw new t.CKEditorError("uploadgateway-missing-api-address",null);this._token=e,this._apiAddress=r}upload(e){return new u(e,this._token,this._apiAddress)}}class h extends e.ContextPlugin{static get pluginName(){return"CloudServicesCore"}static get isOfficialPlugin(){return!0}createToken(e,t){return new i(e,t)}createUploadGateway(e,t){return new l(e,t)}}class d extends e.ContextPlugin{constructor(){super(...arguments),this.token=null,this._tokens=new Map}static get pluginName(){return"CloudServices"}static get isOfficialPlugin(){return!0}static get requires(){return[h]}async init(){const e=this.context.config.get("cloudServices")||{};for(const[t,r]of Object.entries(e))this[t]=r;if(!this.tokenUrl)return void(this.token=null);const t=this.context.plugins.get("CloudServicesCore");this.token=await t.createToken(this.tokenUrl).init(),this._tokens.set(this.tokenUrl,this.token)}async registerTokenUrl(e){if(this._tokens.has(e))return this.getTokenFor(e);const t=this.context.plugins.get("CloudServicesCore"),r=await t.createToken(e).init();return this._tokens.set(e,r),r}getTokenFor(e){const r=this._tokens.get(e);if(!r)throw new t.CKEditorError("cloudservices-token-not-registered",this);return r}destroy(){super.destroy();for(const e of this._tokens.values())e.destroy()}}})(),(window.CKEditor5=window.CKEditor5||{}).cloudServices=s})();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"plugins": [
|
|
3
|
+
{
|
|
4
|
+
"name": "Cloud Services",
|
|
5
|
+
"className": "CloudServices",
|
|
6
|
+
"description": "A backend integration layer for selected CKEditor 5 premium features, both SaaS and on-premises.",
|
|
7
|
+
"path": "src/cloudservices.js",
|
|
8
|
+
"docs": "https://ckeditor.com/ckeditor-cloud-services"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
+
*/
|
|
9
|
+
import type { CloudServices, CloudServicesConfig, CloudServicesCore } from './index.js';
|
|
10
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
11
|
+
interface EditorConfig {
|
|
12
|
+
/**
|
|
13
|
+
* The configuration of CKEditor Cloud Services. Introduced by the {@link module:cloud-services/cloudservices~CloudServices} plugin.
|
|
14
|
+
*
|
|
15
|
+
* Read more in {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig}.
|
|
16
|
+
*/
|
|
17
|
+
cloudServices?: CloudServicesConfig;
|
|
18
|
+
}
|
|
19
|
+
interface PluginsMap {
|
|
20
|
+
[CloudServices.pluginName]: CloudServices;
|
|
21
|
+
[CloudServicesCore.pluginName]: CloudServicesCore;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @module cloud-services/cloudservices
|
|
11
|
+
*/
|
|
12
|
+
import { ContextPlugin } from 'ckeditor5/src/core.js';
|
|
13
|
+
import CloudServicesCore from './cloudservicescore.js';
|
|
14
|
+
import type { CloudServicesConfig, TokenUrl } from './cloudservicesconfig.js';
|
|
15
|
+
import type { InitializedToken } from './token/token.js';
|
|
16
|
+
/**
|
|
17
|
+
* Plugin introducing the integration between CKEditor 5 and CKEditor Cloud Services .
|
|
18
|
+
*
|
|
19
|
+
* It initializes the token provider based on
|
|
20
|
+
* the {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig `config.cloudService`}.
|
|
21
|
+
*/
|
|
22
|
+
export default class CloudServices extends ContextPlugin implements CloudServicesConfig {
|
|
23
|
+
/**
|
|
24
|
+
* The authentication token URL for CKEditor Cloud Services or a callback to the token value promise. See the
|
|
25
|
+
* {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl} for more details.
|
|
26
|
+
*/
|
|
27
|
+
readonly tokenUrl?: TokenUrl;
|
|
28
|
+
/**
|
|
29
|
+
* The URL to which the files should be uploaded.
|
|
30
|
+
*/
|
|
31
|
+
readonly uploadUrl?: string;
|
|
32
|
+
/**
|
|
33
|
+
* The URL for web socket communication, used by the `RealTimeCollaborativeEditing` plugin. Every customer (organization in the CKEditor
|
|
34
|
+
* Ecosystem dashboard) has their own, unique URLs to communicate with CKEditor Cloud Services. The URL can be found in the
|
|
35
|
+
* CKEditor Ecosystem customer dashboard.
|
|
36
|
+
*
|
|
37
|
+
* Note: Unlike most plugins, `RealTimeCollaborativeEditing` is not included in any CKEditor 5 build and needs to be installed manually.
|
|
38
|
+
* Check [Collaboration overview](https://ckeditor.com/docs/ckeditor5/latest/features/collaboration/overview.html) for more details.
|
|
39
|
+
*/
|
|
40
|
+
readonly webSocketUrl?: string;
|
|
41
|
+
/**
|
|
42
|
+
* An optional parameter used for integration with CKEditor Cloud Services when uploading the editor build to cloud services.
|
|
43
|
+
*
|
|
44
|
+
* Whenever the editor build or the configuration changes, this parameter should be set to a new, unique value to differentiate
|
|
45
|
+
* the new bundle (build + configuration) from the old ones.
|
|
46
|
+
*/
|
|
47
|
+
readonly bundleVersion?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Other plugins use this token for the authorization process. It handles token requesting and refreshing.
|
|
50
|
+
* Its value is `null` when {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl} is not provided.
|
|
51
|
+
*
|
|
52
|
+
* @readonly
|
|
53
|
+
*/
|
|
54
|
+
token: InitializedToken | null;
|
|
55
|
+
/**
|
|
56
|
+
* A map of token object instances keyed by the token URLs.
|
|
57
|
+
*/
|
|
58
|
+
private readonly _tokens;
|
|
59
|
+
/**
|
|
60
|
+
* @inheritDoc
|
|
61
|
+
*/
|
|
62
|
+
static get pluginName(): "CloudServices";
|
|
63
|
+
/**
|
|
64
|
+
* @inheritDoc
|
|
65
|
+
*/
|
|
66
|
+
static get isOfficialPlugin(): true;
|
|
67
|
+
/**
|
|
68
|
+
* @inheritDoc
|
|
69
|
+
*/
|
|
70
|
+
static get requires(): readonly [typeof CloudServicesCore];
|
|
71
|
+
/**
|
|
72
|
+
* @inheritDoc
|
|
73
|
+
*/
|
|
74
|
+
init(): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Registers an additional authentication token URL for CKEditor Cloud Services or a callback to the token value promise. See the
|
|
77
|
+
* {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl} for more details.
|
|
78
|
+
*
|
|
79
|
+
* @param tokenUrl The authentication token URL for CKEditor Cloud Services or a callback to the token value promise.
|
|
80
|
+
*/
|
|
81
|
+
registerTokenUrl(tokenUrl: TokenUrl): Promise<InitializedToken>;
|
|
82
|
+
/**
|
|
83
|
+
* Returns an authentication token provider previously registered by {@link #registerTokenUrl}.
|
|
84
|
+
*
|
|
85
|
+
* @param tokenUrl The authentication token URL for CKEditor Cloud Services or a callback to the token value promise.
|
|
86
|
+
*/
|
|
87
|
+
getTokenFor(tokenUrl: TokenUrl): InitializedToken;
|
|
88
|
+
/**
|
|
89
|
+
* @inheritDoc
|
|
90
|
+
*/
|
|
91
|
+
destroy(): void;
|
|
92
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @module cloud-services/cloudservicesconfig
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Endpoint address to download the token or a callback that provides the token.
|
|
14
|
+
*/
|
|
15
|
+
export type TokenUrl = string | (() => Promise<string>);
|
|
16
|
+
/**
|
|
17
|
+
* The configuration for all plugins using CKEditor Cloud Services.
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* ClassicEditor
|
|
21
|
+
* .create( document.querySelector( '#editor' ), {
|
|
22
|
+
* cloudServices: {
|
|
23
|
+
* tokenUrl: 'https://example.com/cs-token-endpoint',
|
|
24
|
+
* uploadUrl: 'https://your-organization-id.cke-cs.com/easyimage/upload/'
|
|
25
|
+
* }
|
|
26
|
+
* } )
|
|
27
|
+
* .then( ... )
|
|
28
|
+
* .catch( ... );
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
32
|
+
*/
|
|
33
|
+
export interface CloudServicesConfig {
|
|
34
|
+
/**
|
|
35
|
+
* A token URL or a token request function.
|
|
36
|
+
*
|
|
37
|
+
* As a string, it should be a URL to the security token endpoint in your application.
|
|
38
|
+
* The role of this endpoint is to securely authorize
|
|
39
|
+
* the end users of your application to use [CKEditor Cloud Services](https://ckeditor.com/ckeditor-cloud-services) only
|
|
40
|
+
* if they should have access e.g. to upload files with {@glink features/file-management/ckbox CKBox} or to use the
|
|
41
|
+
* {@glink @cs guides/collaboration/quick-start Collaboration} service.
|
|
42
|
+
*
|
|
43
|
+
* ```ts
|
|
44
|
+
* ClassicEditor
|
|
45
|
+
* .create( document.querySelector( '#editor' ), {
|
|
46
|
+
* cloudServices: {
|
|
47
|
+
* tokenUrl: 'https://example.com/cs-token-endpoint',
|
|
48
|
+
* ...
|
|
49
|
+
* }
|
|
50
|
+
* } )
|
|
51
|
+
* .then( ... )
|
|
52
|
+
* .catch( ... );
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* As a function, it should provide a promise to the token value,
|
|
56
|
+
* so you can highly customize the token and provide your token URL endpoint.
|
|
57
|
+
* By using this approach you can set your own headers for the request.
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* ClassicEditor
|
|
61
|
+
* .create( document.querySelector( '#editor' ), {
|
|
62
|
+
* cloudServices: {
|
|
63
|
+
* tokenUrl: () => new Promise( ( resolve, reject ) => {
|
|
64
|
+
* const xhr = new XMLHttpRequest();
|
|
65
|
+
*
|
|
66
|
+
* xhr.open( 'GET', 'https://example.com/cs-token-endpoint' );
|
|
67
|
+
*
|
|
68
|
+
* xhr.addEventListener( 'load', () => {
|
|
69
|
+
* const statusCode = xhr.status;
|
|
70
|
+
* const xhrResponse = xhr.response;
|
|
71
|
+
*
|
|
72
|
+
* if ( statusCode < 200 || statusCode > 299 ) {
|
|
73
|
+
* return reject( new Error( 'Cannot download new token!' ) );
|
|
74
|
+
* }
|
|
75
|
+
*
|
|
76
|
+
* return resolve( xhrResponse );
|
|
77
|
+
* } );
|
|
78
|
+
*
|
|
79
|
+
* xhr.addEventListener( 'error', () => reject( new Error( 'Network Error' ) ) );
|
|
80
|
+
* xhr.addEventListener( 'abort', () => reject( new Error( 'Abort' ) ) );
|
|
81
|
+
*
|
|
82
|
+
* xhr.setRequestHeader( customHeader, customValue );
|
|
83
|
+
*
|
|
84
|
+
* xhr.send();
|
|
85
|
+
* } ),
|
|
86
|
+
* ...
|
|
87
|
+
* }
|
|
88
|
+
* } )
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* If the request to the token endpoint fails, the editor will call the token request function every 5 seconds in attempt
|
|
92
|
+
* to refresh the token.
|
|
93
|
+
*
|
|
94
|
+
* You can find more information about token endpoints in the
|
|
95
|
+
* {@glink @cs guides/easy-image/quick-start##configuration Cloud Services - Quick start}
|
|
96
|
+
* and {@glink @cs developer-resources/security/token-endpoint Cloud Services - Token endpoint} documentation.
|
|
97
|
+
*
|
|
98
|
+
* Without a properly working token endpoint (token URL) CKEditor plugins will not be able to connect to CKEditor Cloud Services.
|
|
99
|
+
*/
|
|
100
|
+
tokenUrl?: TokenUrl;
|
|
101
|
+
/**
|
|
102
|
+
* The endpoint URL for [CKEditor Cloud Services](https://ckeditor.com/ckeditor-cloud-services) uploads.
|
|
103
|
+
* This option must be set for Easy Image to work correctly.
|
|
104
|
+
*
|
|
105
|
+
* The upload URL is unique for each customer and can be found in the
|
|
106
|
+
* [CKEditor Ecosystem customer dashboard](https://dashboard.ckeditor.com) after subscribing to the Easy Image service.
|
|
107
|
+
* To learn how to start using Easy Image, check the {@glink @cs guides/easy-image/quick-start Easy Image - Quick start} documentation.
|
|
108
|
+
*
|
|
109
|
+
* Note: Make sure to also set the {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl} configuration option.
|
|
110
|
+
*/
|
|
111
|
+
uploadUrl?: string;
|
|
112
|
+
/**
|
|
113
|
+
* The URL for web socket communication, used by the `RealTimeCollaborativeEditing` plugin. Every customer (organization in the CKEditor
|
|
114
|
+
* Ecosystem dashboard) has their own, unique URLs to communicate with CKEditor Cloud Services. The URL can be found in the
|
|
115
|
+
* CKEditor Ecosystem customer dashboard.
|
|
116
|
+
*
|
|
117
|
+
* Note: Unlike most plugins, `RealTimeCollaborativeEditing` is not included in any CKEditor 5 build and needs to be installed manually.
|
|
118
|
+
* Check [Collaboration overview](https://ckeditor.com/docs/ckeditor5/latest/features/collaboration/overview.html) for more details.
|
|
119
|
+
*/
|
|
120
|
+
webSocketUrl?: string;
|
|
121
|
+
/**
|
|
122
|
+
* An optional parameter used for integration with CKEditor Cloud Services when uploading the editor build to cloud services.
|
|
123
|
+
*
|
|
124
|
+
* Whenever the editor build or the configuration changes, this parameter should be set to a new, unique value to differentiate
|
|
125
|
+
* the new bundle (build + configuration) from the old ones.
|
|
126
|
+
*/
|
|
127
|
+
bundleVersion?: string;
|
|
128
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @module cloud-services/cloudservicescore
|
|
11
|
+
*/
|
|
12
|
+
import { ContextPlugin } from 'ckeditor5/src/core.js';
|
|
13
|
+
import type { TokenUrl } from './cloudservicesconfig.js';
|
|
14
|
+
import Token, { type InitializedToken, type TokenOptions } from './token/token.js';
|
|
15
|
+
import UploadGateway from './uploadgateway/uploadgateway.js';
|
|
16
|
+
/**
|
|
17
|
+
* The `CloudServicesCore` plugin exposes the base API for communication with CKEditor Cloud Services.
|
|
18
|
+
*/
|
|
19
|
+
export default class CloudServicesCore extends ContextPlugin {
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
static get pluginName(): "CloudServicesCore";
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
static get isOfficialPlugin(): true;
|
|
28
|
+
/**
|
|
29
|
+
* Creates the {@link module:cloud-services/token/token~Token} instance.
|
|
30
|
+
*
|
|
31
|
+
* @param tokenUrlOrRefreshToken Endpoint address to download the token or a callback that provides the token. If the
|
|
32
|
+
* value is a function it has to match the {@link module:cloud-services/token/token~Token#refreshToken} interface.
|
|
33
|
+
* @param options.initValue Initial value of the token.
|
|
34
|
+
* @param options.autoRefresh Specifies whether to start the refresh automatically.
|
|
35
|
+
*/
|
|
36
|
+
createToken(tokenUrlOrRefreshToken: TokenUrl, options?: TokenOptions): Token;
|
|
37
|
+
/**
|
|
38
|
+
* Creates the {@link module:cloud-services/uploadgateway/uploadgateway~UploadGateway} instance.
|
|
39
|
+
*
|
|
40
|
+
* @param token Token used for authentication.
|
|
41
|
+
* @param apiAddress API address.
|
|
42
|
+
*/
|
|
43
|
+
createUploadGateway(token: InitializedToken, apiAddress: string): UploadGateway;
|
|
44
|
+
}
|
package/dist/index.css
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @module cloud-services
|
|
11
|
+
*/
|
|
12
|
+
export { default as CloudServices } from './cloudservices.js';
|
|
13
|
+
export { default as CloudServicesCore } from './cloudservicescore.js';
|
|
14
|
+
export type { TokenUrl, CloudServicesConfig } from './cloudservicesconfig.js';
|
|
15
|
+
export type { default as Token, InitializedToken } from './token/token.js';
|
|
16
|
+
export type { default as UploadGateway } from './uploadgateway/uploadgateway.js';
|
|
17
|
+
export type { default as FileUploader } from './uploadgateway/fileuploader.js';
|
|
18
|
+
import './augmentation.js';
|