@ckeditor/ckeditor5-ckbox 39.0.1 → 40.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE.md +1 -1
- package/README.md +3 -3
- package/build/ckbox.js.map +1 -0
- package/build/translations/fa.js +1 -1
- package/build/translations/gl.js +1 -1
- package/lang/translations/ar.po +1 -0
- package/lang/translations/az.po +1 -0
- package/lang/translations/bg.po +1 -0
- package/lang/translations/bn.po +1 -0
- package/lang/translations/ca.po +1 -0
- package/lang/translations/cs.po +1 -0
- package/lang/translations/da.po +1 -0
- package/lang/translations/de.po +1 -0
- package/lang/translations/el.po +1 -0
- package/lang/translations/en-au.po +1 -0
- package/lang/translations/en.po +1 -0
- package/lang/translations/es-co.po +1 -0
- package/lang/translations/es.po +1 -0
- package/lang/translations/et.po +1 -0
- package/lang/translations/fa.po +2 -1
- package/lang/translations/fi.po +1 -0
- package/lang/translations/fr.po +1 -0
- package/lang/translations/gl.po +3 -2
- package/lang/translations/he.po +1 -0
- package/lang/translations/hi.po +1 -0
- package/lang/translations/hr.po +1 -0
- package/lang/translations/hu.po +1 -0
- package/lang/translations/id.po +1 -0
- package/lang/translations/it.po +1 -0
- package/lang/translations/ja.po +1 -0
- package/lang/translations/ko.po +1 -0
- package/lang/translations/lt.po +1 -0
- package/lang/translations/lv.po +1 -0
- package/lang/translations/ms.po +1 -0
- package/lang/translations/nl.po +1 -0
- package/lang/translations/no.po +1 -0
- package/lang/translations/pl.po +1 -0
- package/lang/translations/pt-br.po +1 -0
- package/lang/translations/pt.po +1 -0
- package/lang/translations/ro.po +1 -0
- package/lang/translations/ru.po +1 -0
- package/lang/translations/sk.po +1 -0
- package/lang/translations/sq.po +1 -0
- package/lang/translations/sr-latn.po +1 -0
- package/lang/translations/sr.po +1 -0
- package/lang/translations/sv.po +1 -0
- package/lang/translations/th.po +1 -0
- package/lang/translations/tr.po +1 -0
- package/lang/translations/ug.po +1 -0
- package/lang/translations/uk.po +1 -0
- package/lang/translations/ur.po +1 -0
- package/lang/translations/uz.po +1 -0
- package/lang/translations/vi.po +1 -0
- package/lang/translations/zh-cn.po +1 -0
- package/lang/translations/zh.po +1 -0
- package/package.json +2 -6
- package/src/augmentation.d.ts +22 -22
- package/src/augmentation.js +5 -5
- package/src/ckbox.d.ts +33 -33
- package/src/ckbox.js +37 -37
- package/src/ckboxcommand.d.ts +110 -110
- package/src/ckboxcommand.js +302 -302
- package/src/ckboxconfig.d.ts +283 -283
- package/src/ckboxconfig.js +5 -5
- package/src/ckboxediting.d.ts +52 -52
- package/src/ckboxediting.js +362 -362
- package/src/ckboxui.d.ts +21 -21
- package/src/ckboxui.js +47 -47
- package/src/ckboxuploadadapter.d.ts +38 -38
- package/src/ckboxuploadadapter.js +275 -275
- package/src/index.d.ts +13 -13
- package/src/index.js +11 -11
- package/src/utils.d.ts +28 -28
- package/src/utils.js +49 -49
package/src/utils.js
CHANGED
@@ -1,49 +1,49 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2023, 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
|
-
* Converts image source set provided by the CKBox into an object containing:
|
7
|
-
* - responsive URLs for the "webp" image format,
|
8
|
-
* - one fallback URL for browsers that do not support the "webp" format.
|
9
|
-
*/
|
10
|
-
export function getImageUrls(imageUrls) {
|
11
|
-
const responsiveUrls = [];
|
12
|
-
let maxWidth = 0;
|
13
|
-
for (const key in imageUrls) {
|
14
|
-
const width = parseInt(key, 10);
|
15
|
-
if (!isNaN(width)) {
|
16
|
-
if (width > maxWidth) {
|
17
|
-
maxWidth = width;
|
18
|
-
}
|
19
|
-
responsiveUrls.push(`${imageUrls[key]} ${key}w`);
|
20
|
-
}
|
21
|
-
}
|
22
|
-
const imageSources = [{
|
23
|
-
srcset: responsiveUrls.join(','),
|
24
|
-
sizes: `(max-width: ${maxWidth}px) 100vw, ${maxWidth}px`,
|
25
|
-
type: 'image/webp'
|
26
|
-
}];
|
27
|
-
return {
|
28
|
-
imageFallbackUrl: imageUrls.default,
|
29
|
-
imageSources
|
30
|
-
};
|
31
|
-
}
|
32
|
-
/**
|
33
|
-
* Returns workspace id to use for communication with the CKBox service.
|
34
|
-
*
|
35
|
-
* @param defaultWorkspaceId The default workspace to use taken from editor config.
|
36
|
-
*/
|
37
|
-
export function getWorkspaceId(token, defaultWorkspaceId) {
|
38
|
-
const [, binaryTokenPayload] = token.value.split('.');
|
39
|
-
const payload = JSON.parse(atob(binaryTokenPayload));
|
40
|
-
const workspaces = (payload.auth && payload.auth.ckbox && payload.auth.ckbox.workspaces) || [payload.aud];
|
41
|
-
if (!defaultWorkspaceId) {
|
42
|
-
return workspaces[0];
|
43
|
-
}
|
44
|
-
const role = payload.auth && payload.auth.ckbox && payload.auth.ckbox.role;
|
45
|
-
if (role == 'superadmin' || workspaces.includes(defaultWorkspaceId)) {
|
46
|
-
return defaultWorkspaceId;
|
47
|
-
}
|
48
|
-
return null;
|
49
|
-
}
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, 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
|
+
* Converts image source set provided by the CKBox into an object containing:
|
7
|
+
* - responsive URLs for the "webp" image format,
|
8
|
+
* - one fallback URL for browsers that do not support the "webp" format.
|
9
|
+
*/
|
10
|
+
export function getImageUrls(imageUrls) {
|
11
|
+
const responsiveUrls = [];
|
12
|
+
let maxWidth = 0;
|
13
|
+
for (const key in imageUrls) {
|
14
|
+
const width = parseInt(key, 10);
|
15
|
+
if (!isNaN(width)) {
|
16
|
+
if (width > maxWidth) {
|
17
|
+
maxWidth = width;
|
18
|
+
}
|
19
|
+
responsiveUrls.push(`${imageUrls[key]} ${key}w`);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
const imageSources = [{
|
23
|
+
srcset: responsiveUrls.join(','),
|
24
|
+
sizes: `(max-width: ${maxWidth}px) 100vw, ${maxWidth}px`,
|
25
|
+
type: 'image/webp'
|
26
|
+
}];
|
27
|
+
return {
|
28
|
+
imageFallbackUrl: imageUrls.default,
|
29
|
+
imageSources
|
30
|
+
};
|
31
|
+
}
|
32
|
+
/**
|
33
|
+
* Returns a workspace id to use for communication with the CKBox service.
|
34
|
+
*
|
35
|
+
* @param defaultWorkspaceId The default workspace to use taken from editor config.
|
36
|
+
*/
|
37
|
+
export function getWorkspaceId(token, defaultWorkspaceId) {
|
38
|
+
const [, binaryTokenPayload] = token.value.split('.');
|
39
|
+
const payload = JSON.parse(atob(binaryTokenPayload));
|
40
|
+
const workspaces = (payload.auth && payload.auth.ckbox && payload.auth.ckbox.workspaces) || [payload.aud];
|
41
|
+
if (!defaultWorkspaceId) {
|
42
|
+
return workspaces[0];
|
43
|
+
}
|
44
|
+
const role = payload.auth && payload.auth.ckbox && payload.auth.ckbox.role;
|
45
|
+
if (role == 'superadmin' || workspaces.includes(defaultWorkspaceId)) {
|
46
|
+
return defaultWorkspaceId;
|
47
|
+
}
|
48
|
+
return null;
|
49
|
+
}
|