@ckeditor/ckeditor5-cloud-services 41.2.0 → 41.3.0-alpha.1
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/dist/content-index.css +4 -0
- package/dist/editor-index.css +4 -0
- package/dist/index.css +4 -0
- package/dist/index.js +562 -0
- package/dist/index.js.map +1 -0
- package/dist/types/augmentation.d.ts +19 -0
- package/dist/types/cloudservices.d.ts +84 -0
- package/dist/types/cloudservicesconfig.d.ts +121 -0
- package/dist/types/cloudservicescore.d.ts +36 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/token/token.d.ts +96 -0
- package/dist/types/uploadgateway/fileuploader.d.ts +94 -0
- package/dist/types/uploadgateway/uploadgateway.d.ts +47 -0
- package/package.json +3 -2
- package/src/index.d.ts +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
* @module cloud-services/uploadgateway/fileuploader
|
|
7
|
+
*/
|
|
8
|
+
import type { UploadResponse } from 'ckeditor5/src/upload.js';
|
|
9
|
+
import type { InitializedToken } from '../token/token.js';
|
|
10
|
+
declare const FileUploader_base: {
|
|
11
|
+
new (): import("ckeditor5/src/utils.js").Emitter;
|
|
12
|
+
prototype: import("ckeditor5/src/utils.js").Emitter;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* FileUploader class used to upload single file.
|
|
16
|
+
*/
|
|
17
|
+
export default class FileUploader extends FileUploader_base {
|
|
18
|
+
/**
|
|
19
|
+
* A file that is being uploaded.
|
|
20
|
+
*/
|
|
21
|
+
readonly file: Blob;
|
|
22
|
+
xhr?: XMLHttpRequest;
|
|
23
|
+
/**
|
|
24
|
+
* CKEditor Cloud Services access token.
|
|
25
|
+
*/
|
|
26
|
+
private readonly _token;
|
|
27
|
+
/**
|
|
28
|
+
* CKEditor Cloud Services API address.
|
|
29
|
+
*/
|
|
30
|
+
private readonly _apiAddress;
|
|
31
|
+
/**
|
|
32
|
+
* Creates `FileUploader` instance.
|
|
33
|
+
*
|
|
34
|
+
* @param fileOrData A blob object or a data string encoded with Base64.
|
|
35
|
+
* @param token Token used for authentication.
|
|
36
|
+
* @param apiAddress API address.
|
|
37
|
+
*/
|
|
38
|
+
constructor(fileOrData: string | Blob, token: InitializedToken, apiAddress: string);
|
|
39
|
+
/**
|
|
40
|
+
* Registers callback on `progress` event.
|
|
41
|
+
*/
|
|
42
|
+
onProgress(callback: (status: {
|
|
43
|
+
total: number;
|
|
44
|
+
uploaded: number;
|
|
45
|
+
}) => void): this;
|
|
46
|
+
/**
|
|
47
|
+
* Registers callback on `error` event. Event is called once when error occurs.
|
|
48
|
+
*/
|
|
49
|
+
onError(callback: (error: string) => void): this;
|
|
50
|
+
/**
|
|
51
|
+
* Aborts upload process.
|
|
52
|
+
*/
|
|
53
|
+
abort(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Sends XHR request to API.
|
|
56
|
+
*/
|
|
57
|
+
send(): Promise<UploadResponse>;
|
|
58
|
+
/**
|
|
59
|
+
* Prepares XHR request.
|
|
60
|
+
*/
|
|
61
|
+
private _prepareRequest;
|
|
62
|
+
/**
|
|
63
|
+
* Attaches listeners to the XHR.
|
|
64
|
+
*/
|
|
65
|
+
private _attachXHRListeners;
|
|
66
|
+
/**
|
|
67
|
+
* Sends XHR request.
|
|
68
|
+
*/
|
|
69
|
+
private _sendRequest;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Fired when error occurs.
|
|
73
|
+
*
|
|
74
|
+
* @eventName ~FileUploader#error
|
|
75
|
+
* @param error Error message
|
|
76
|
+
*/
|
|
77
|
+
export type FileUploaderErrorEvent = {
|
|
78
|
+
name: 'error';
|
|
79
|
+
args: [error: string];
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Fired on upload progress.
|
|
83
|
+
*
|
|
84
|
+
* @eventName ~FileUploader#progress
|
|
85
|
+
* @param status Total and uploaded status
|
|
86
|
+
*/
|
|
87
|
+
export type FileUploaderProgressErrorEvent = {
|
|
88
|
+
name: 'progress';
|
|
89
|
+
args: [status: {
|
|
90
|
+
total: number;
|
|
91
|
+
uploaded: number;
|
|
92
|
+
}];
|
|
93
|
+
};
|
|
94
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
* @module cloud-services/uploadgateway/uploadgateway
|
|
7
|
+
*/
|
|
8
|
+
import FileUploader from './fileuploader.js';
|
|
9
|
+
import type { InitializedToken } from '../token/token.js';
|
|
10
|
+
/**
|
|
11
|
+
* UploadGateway abstracts file uploads to CKEditor Cloud Services.
|
|
12
|
+
*/
|
|
13
|
+
export default class UploadGateway {
|
|
14
|
+
/**
|
|
15
|
+
* CKEditor Cloud Services access token.
|
|
16
|
+
*/
|
|
17
|
+
private readonly _token;
|
|
18
|
+
/**
|
|
19
|
+
* CKEditor Cloud Services API address.
|
|
20
|
+
*/
|
|
21
|
+
private readonly _apiAddress;
|
|
22
|
+
/**
|
|
23
|
+
* Creates `UploadGateway` instance.
|
|
24
|
+
*
|
|
25
|
+
* @param token Token used for authentication.
|
|
26
|
+
* @param apiAddress API address.
|
|
27
|
+
*/
|
|
28
|
+
constructor(token: InitializedToken, apiAddress: string);
|
|
29
|
+
/**
|
|
30
|
+
* Creates a {@link module:cloud-services/uploadgateway/fileuploader~FileUploader} instance that wraps
|
|
31
|
+
* file upload process. The file is being sent at a time when the
|
|
32
|
+
* {@link module:cloud-services/uploadgateway/fileuploader~FileUploader#send} method is called.
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* const token = await Token.create( 'https://token-endpoint' );
|
|
36
|
+
* new UploadGateway( token, 'https://example.org' )
|
|
37
|
+
* .upload( 'FILE' )
|
|
38
|
+
* .onProgress( ( data ) => console.log( data ) )
|
|
39
|
+
* .send()
|
|
40
|
+
* .then( ( response ) => console.log( response ) );
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @param {Blob|String} fileOrData A blob object or a data string encoded with Base64.
|
|
44
|
+
* @returns {module:cloud-services/uploadgateway/fileuploader~FileUploader} Returns `FileUploader` instance.
|
|
45
|
+
*/
|
|
46
|
+
upload(fileOrData: string | Blob): FileUploader;
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-cloud-services",
|
|
3
|
-
"version": "41.
|
|
3
|
+
"version": "41.3.0-alpha.1",
|
|
4
4
|
"description": "CKEditor 5's Cloud Services integration layer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"type": "module",
|
|
13
13
|
"main": "src/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"ckeditor5": "41.
|
|
15
|
+
"ckeditor5": "41.3.0-alpha.1"
|
|
16
16
|
},
|
|
17
17
|
"author": "CKSource (http://cksource.com/)",
|
|
18
18
|
"license": "GPL-2.0-or-later",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"directory": "packages/ckeditor5-cloud-services"
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
|
+
"dist",
|
|
27
28
|
"lang",
|
|
28
29
|
"src/**/*.js",
|
|
29
30
|
"src/**/*.d.ts",
|
package/src/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { default as CloudServices } from './cloudservices.js';
|
|
9
9
|
export { default as CloudServicesCore } from './cloudservicescore.js';
|
|
10
|
-
export { TokenUrl,
|
|
10
|
+
export type { TokenUrl, CloudServicesConfig } from './cloudservicesconfig.js';
|
|
11
11
|
export type { default as Token, InitializedToken } from './token/token.js';
|
|
12
12
|
export type { default as UploadGateway } from './uploadgateway/uploadgateway.js';
|
|
13
13
|
export type { default as FileUploader } from './uploadgateway/fileuploader.js';
|