@ckeditor/ckeditor5-ckbox 0.0.0-nightly-20240723.0 → 0.0.0-nightly-20240724.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/build/ckbox.js +1 -1
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/types/ckboxutils.d.ts +3 -3
- package/package.json +2 -2
- package/src/ckboximageedit/ckboximageeditcommand.js +1 -1
- package/src/ckboxuploadadapter.js +2 -2
- package/src/ckboxutils.d.ts +3 -3
- package/src/ckboxutils.js +8 -8
@@ -30,15 +30,15 @@ export default class CKBoxUtils extends Plugin {
|
|
30
30
|
/**
|
31
31
|
* @inheritDoc
|
32
32
|
*/
|
33
|
-
init():
|
33
|
+
init(): void;
|
34
34
|
/**
|
35
35
|
* Returns a token used by the CKBox plugin for communication with the CKBox service.
|
36
36
|
*/
|
37
|
-
getToken(): InitializedToken
|
37
|
+
getToken(): Promise<InitializedToken>;
|
38
38
|
/**
|
39
39
|
* The ID of workspace to use when uploading an image.
|
40
40
|
*/
|
41
|
-
getWorkspaceId(): string
|
41
|
+
getWorkspaceId(): Promise<string>;
|
42
42
|
/**
|
43
43
|
* Resolves a promise with an object containing a category with which the uploaded file is associated or an error code.
|
44
44
|
*/
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ckeditor/ckeditor5-ckbox",
|
3
|
-
"version": "0.0.0-nightly-
|
3
|
+
"version": "0.0.0-nightly-20240724.0",
|
4
4
|
"description": "CKBox integration for CKEditor 5.",
|
5
5
|
"keywords": [
|
6
6
|
"ckeditor",
|
@@ -13,7 +13,7 @@
|
|
13
13
|
"type": "module",
|
14
14
|
"main": "src/index.js",
|
15
15
|
"dependencies": {
|
16
|
-
"ckeditor5": "0.0.0-nightly-
|
16
|
+
"ckeditor5": "0.0.0-nightly-20240724.0",
|
17
17
|
"blurhash": "2.0.5",
|
18
18
|
"lodash-es": "4.17.21"
|
19
19
|
},
|
@@ -227,7 +227,7 @@ export default class CKBoxImageEditCommand extends Command {
|
|
227
227
|
const response = await sendHttpRequest({
|
228
228
|
url,
|
229
229
|
signal,
|
230
|
-
authorization: ckboxUtils.getToken().value
|
230
|
+
authorization: (await ckboxUtils.getToken()).value
|
231
231
|
});
|
232
232
|
const status = response.metadata.metadataProcessingStatus;
|
233
233
|
if (!status || status == 'queued') {
|
@@ -88,7 +88,7 @@ class Adapter {
|
|
88
88
|
const category = await ckboxUtils.getCategoryIdForFile(file, { signal: this.controller.signal });
|
89
89
|
const uploadUrl = new URL('assets', this.serviceOrigin);
|
90
90
|
const formData = new FormData();
|
91
|
-
uploadUrl.searchParams.set('workspaceId', ckboxUtils.getWorkspaceId());
|
91
|
+
uploadUrl.searchParams.set('workspaceId', await ckboxUtils.getWorkspaceId());
|
92
92
|
formData.append('categoryId', category);
|
93
93
|
formData.append('file', file);
|
94
94
|
const requestConfig = {
|
@@ -103,7 +103,7 @@ class Adapter {
|
|
103
103
|
}
|
104
104
|
},
|
105
105
|
signal: this.controller.signal,
|
106
|
-
authorization: this.token.value
|
106
|
+
authorization: (await this.token).value
|
107
107
|
};
|
108
108
|
return sendHttpRequest(requestConfig)
|
109
109
|
.then(async (data) => {
|
package/src/ckboxutils.d.ts
CHANGED
@@ -26,15 +26,15 @@ export default class CKBoxUtils extends Plugin {
|
|
26
26
|
/**
|
27
27
|
* @inheritDoc
|
28
28
|
*/
|
29
|
-
init():
|
29
|
+
init(): void;
|
30
30
|
/**
|
31
31
|
* Returns a token used by the CKBox plugin for communication with the CKBox service.
|
32
32
|
*/
|
33
|
-
getToken(): InitializedToken
|
33
|
+
getToken(): Promise<InitializedToken>;
|
34
34
|
/**
|
35
35
|
* The ID of workspace to use when uploading an image.
|
36
36
|
*/
|
37
|
-
getWorkspaceId(): string
|
37
|
+
getWorkspaceId(): Promise<string>;
|
38
38
|
/**
|
39
39
|
* Resolves a promise with an object containing a category with which the uploaded file is associated or an error code.
|
40
40
|
*/
|
package/src/ckboxutils.js
CHANGED
@@ -25,7 +25,7 @@ export default class CKBoxUtils extends Plugin {
|
|
25
25
|
/**
|
26
26
|
* @inheritDoc
|
27
27
|
*/
|
28
|
-
|
28
|
+
init() {
|
29
29
|
const editor = this.editor;
|
30
30
|
const hasConfiguration = !!editor.config.get('ckbox');
|
31
31
|
const isLibraryLoaded = !!window.CKBox;
|
@@ -66,10 +66,10 @@ export default class CKBoxUtils extends Plugin {
|
|
66
66
|
throw new CKEditorError('ckbox-plugin-missing-token-url', this);
|
67
67
|
}
|
68
68
|
if (ckboxTokenUrl == cloudServicesTokenUrl) {
|
69
|
-
this._token = cloudServices.token;
|
69
|
+
this._token = Promise.resolve(cloudServices.token);
|
70
70
|
}
|
71
71
|
else {
|
72
|
-
this._token =
|
72
|
+
this._token = cloudServices.registerTokenUrl(ckboxTokenUrl);
|
73
73
|
}
|
74
74
|
}
|
75
75
|
/**
|
@@ -81,11 +81,11 @@ export default class CKBoxUtils extends Plugin {
|
|
81
81
|
/**
|
82
82
|
* The ID of workspace to use when uploading an image.
|
83
83
|
*/
|
84
|
-
getWorkspaceId() {
|
84
|
+
async getWorkspaceId() {
|
85
85
|
const t = this.editor.t;
|
86
86
|
const cannotAccessDefaultWorkspaceError = t('Cannot access default workspace.');
|
87
87
|
const defaultWorkspaceId = this.editor.config.get('ckbox.defaultUploadWorkspaceId');
|
88
|
-
const workspaceId = getWorkspaceId(this._token, defaultWorkspaceId);
|
88
|
+
const workspaceId = getWorkspaceId(await this._token, defaultWorkspaceId);
|
89
89
|
if (workspaceId == null) {
|
90
90
|
/**
|
91
91
|
* The user is not authorized to access the workspace defined in the`ckbox.defaultUploadWorkspaceId` configuration.
|
@@ -145,7 +145,7 @@ export default class CKBoxUtils extends Plugin {
|
|
145
145
|
const token = this._token;
|
146
146
|
const { signal } = options;
|
147
147
|
const serviceOrigin = editor.config.get('ckbox.serviceOrigin');
|
148
|
-
const workspaceId = this.getWorkspaceId();
|
148
|
+
const workspaceId = await this.getWorkspaceId();
|
149
149
|
try {
|
150
150
|
const result = [];
|
151
151
|
let offset = 0;
|
@@ -168,7 +168,7 @@ export default class CKBoxUtils extends Plugin {
|
|
168
168
|
logError('ckbox-fetch-category-http-error');
|
169
169
|
return undefined;
|
170
170
|
}
|
171
|
-
function fetchCategories(offset) {
|
171
|
+
async function fetchCategories(offset) {
|
172
172
|
const categoryUrl = new URL('categories', serviceOrigin);
|
173
173
|
categoryUrl.searchParams.set('limit', String(ITEMS_PER_REQUEST));
|
174
174
|
categoryUrl.searchParams.set('offset', String(offset));
|
@@ -176,7 +176,7 @@ export default class CKBoxUtils extends Plugin {
|
|
176
176
|
return sendHttpRequest({
|
177
177
|
url: categoryUrl,
|
178
178
|
signal,
|
179
|
-
authorization: token.value
|
179
|
+
authorization: (await token).value
|
180
180
|
});
|
181
181
|
}
|
182
182
|
}
|