@ckeditor/ckeditor5-ckbox 41.1.0 → 41.3.0-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- package/build/ckbox.js +1 -1
- package/dist/content-index.css +4 -0
- package/dist/editor-index.css +31 -0
- package/dist/index.css +55 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +1713 -0
- package/dist/index.js.map +1 -0
- package/dist/types/augmentation.d.ts +32 -0
- package/dist/types/ckbox.d.ts +33 -0
- package/dist/types/ckboxcommand.d.ts +114 -0
- package/dist/types/ckboxconfig.d.ts +325 -0
- package/dist/types/ckboxediting.d.ts +54 -0
- package/dist/types/ckboximageedit/ckboximageeditcommand.d.ts +97 -0
- package/dist/types/ckboximageedit/ckboximageeditediting.d.ts +28 -0
- package/dist/types/ckboximageedit/ckboximageeditui.d.ts +24 -0
- package/dist/types/ckboximageedit/utils.d.ts +10 -0
- package/dist/types/ckboximageedit.d.ts +24 -0
- package/dist/types/ckboxui.d.ts +21 -0
- package/dist/types/ckboxuploadadapter.d.ts +33 -0
- package/dist/types/ckboxutils.d.ts +50 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/utils.d.ts +63 -0
- package/lang/translations/he.po +1 -1
- package/package.json +3 -2
- package/src/ckboxediting.d.ts +9 -0
- package/src/ckboxediting.js +29 -9
- package/src/ckboxui.js +4 -3
@@ -0,0 +1,24 @@
|
|
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 ckbox/ckboximageedit/ckboximageeditui
|
7
|
+
*/
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
9
|
+
/**
|
10
|
+
* The UI plugin of the CKBox image edit feature.
|
11
|
+
*
|
12
|
+
* It registers the `'ckboxImageEdit'` UI button in the editor's {@link module:ui/componentfactory~ComponentFactory component factory}
|
13
|
+
* that allows you to open the CKBox dialog and edit the image.
|
14
|
+
*/
|
15
|
+
export default class CKBoxImageEditUI extends Plugin {
|
16
|
+
/**
|
17
|
+
* @inheritDoc
|
18
|
+
*/
|
19
|
+
static get pluginName(): "CKBoxImageEditUI";
|
20
|
+
/**
|
21
|
+
* @inheritDoc
|
22
|
+
*/
|
23
|
+
init(): void;
|
24
|
+
}
|
@@ -0,0 +1,10 @@
|
|
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
|
+
import type { Element } from 'ckeditor5/src/engine.js';
|
6
|
+
import type { CKBoxConfig } from '../ckboxconfig.js';
|
7
|
+
/**
|
8
|
+
* @internal
|
9
|
+
*/
|
10
|
+
export declare function createEditabilityChecker(allowExternalImagesEditing: CKBoxConfig['allowExternalImagesEditing']): (element: Element) => boolean;
|
@@ -0,0 +1,24 @@
|
|
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 ckbox/ckboximageedit
|
7
|
+
*/
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
9
|
+
import CKBoxImageEditEditing from './ckboximageedit/ckboximageeditediting.js';
|
10
|
+
import CKBoxImageEditUI from './ckboximageedit/ckboximageeditui.js';
|
11
|
+
import '../theme/ckboximageedit.css';
|
12
|
+
/**
|
13
|
+
* The CKBox image edit feature.
|
14
|
+
*/
|
15
|
+
export default class CKBoxImageEdit extends Plugin {
|
16
|
+
/**
|
17
|
+
* @inheritDoc
|
18
|
+
*/
|
19
|
+
static get pluginName(): "CKBoxImageEdit";
|
20
|
+
/**
|
21
|
+
* @inheritDoc
|
22
|
+
*/
|
23
|
+
static get requires(): readonly [typeof CKBoxImageEditEditing, typeof CKBoxImageEditUI];
|
24
|
+
}
|
@@ -0,0 +1,21 @@
|
|
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 ckbox/ckboxui
|
7
|
+
*/
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
9
|
+
/**
|
10
|
+
* The CKBoxUI plugin. It introduces the `'ckbox'` toolbar button.
|
11
|
+
*/
|
12
|
+
export default class CKBoxUI extends Plugin {
|
13
|
+
/**
|
14
|
+
* @inheritDoc
|
15
|
+
*/
|
16
|
+
static get pluginName(): "CKBoxUI";
|
17
|
+
/**
|
18
|
+
* @inheritDoc
|
19
|
+
*/
|
20
|
+
afterInit(): void;
|
21
|
+
}
|
@@ -0,0 +1,33 @@
|
|
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 ckbox/ckboxuploadadapter
|
7
|
+
*/
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
9
|
+
import { FileRepository } from 'ckeditor5/src/upload.js';
|
10
|
+
import CKBoxEditing from './ckboxediting.js';
|
11
|
+
/**
|
12
|
+
* A plugin that enables file uploads in CKEditor 5 using the CKBox server–side connector.
|
13
|
+
* See the {@glink features/file-management/ckbox CKBox file manager integration} guide to learn how to configure
|
14
|
+
* and use this feature as well as find out more about the full integration with the file manager
|
15
|
+
* provided by the {@link module:ckbox/ckbox~CKBox} plugin.
|
16
|
+
*
|
17
|
+
* Check out the {@glink features/images/image-upload/image-upload Image upload overview} guide to learn about
|
18
|
+
* other ways to upload images into CKEditor 5.
|
19
|
+
*/
|
20
|
+
export default class CKBoxUploadAdapter extends Plugin {
|
21
|
+
/**
|
22
|
+
* @inheritDoc
|
23
|
+
*/
|
24
|
+
static get requires(): readonly ["ImageUploadEditing", "ImageUploadProgress", typeof FileRepository, typeof CKBoxEditing];
|
25
|
+
/**
|
26
|
+
* @inheritDoc
|
27
|
+
*/
|
28
|
+
static get pluginName(): "CKBoxUploadAdapter";
|
29
|
+
/**
|
30
|
+
* @inheritDoc
|
31
|
+
*/
|
32
|
+
afterInit(): Promise<void>;
|
33
|
+
}
|
@@ -0,0 +1,50 @@
|
|
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 ckbox/ckboxutils
|
7
|
+
*/
|
8
|
+
import type { InitializedToken } from '@ckeditor/ckeditor5-cloud-services';
|
9
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
10
|
+
/**
|
11
|
+
* The CKBox utilities plugin.
|
12
|
+
*/
|
13
|
+
export default class CKBoxUtils extends Plugin {
|
14
|
+
/**
|
15
|
+
* CKEditor Cloud Services access token.
|
16
|
+
*/
|
17
|
+
private _token;
|
18
|
+
/**
|
19
|
+
* @inheritDoc
|
20
|
+
*/
|
21
|
+
static get pluginName(): "CKBoxUtils";
|
22
|
+
/**
|
23
|
+
* @inheritDoc
|
24
|
+
*/
|
25
|
+
static get requires(): readonly ["CloudServices"];
|
26
|
+
/**
|
27
|
+
* @inheritDoc
|
28
|
+
*/
|
29
|
+
init(): Promise<void>;
|
30
|
+
/**
|
31
|
+
* Returns a token used by the CKBox plugin for communication with the CKBox service.
|
32
|
+
*/
|
33
|
+
getToken(): InitializedToken;
|
34
|
+
/**
|
35
|
+
* The ID of workspace to use when uploading an image.
|
36
|
+
*/
|
37
|
+
getWorkspaceId(): string;
|
38
|
+
/**
|
39
|
+
* Resolves a promise with an object containing a category with which the uploaded file is associated or an error code.
|
40
|
+
*/
|
41
|
+
getCategoryIdForFile(fileOrUrl: File | string, options: {
|
42
|
+
signal: AbortSignal;
|
43
|
+
}): Promise<string>;
|
44
|
+
/**
|
45
|
+
* Resolves a promise with an array containing available categories with which the uploaded file can be associated.
|
46
|
+
*
|
47
|
+
* If the API returns limited results, the method will collect all items.
|
48
|
+
*/
|
49
|
+
private _getAvailableCategories;
|
50
|
+
}
|
@@ -0,0 +1,17 @@
|
|
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 ckbox
|
7
|
+
*/
|
8
|
+
export { default as CKBox } from './ckbox.js';
|
9
|
+
export { default as CKBoxEditing } from './ckboxediting.js';
|
10
|
+
export { default as CKBoxUI } from './ckboxui.js';
|
11
|
+
export { default as CKBoxImageEditEditing } from './ckboximageedit/ckboximageeditediting.js';
|
12
|
+
export { default as CKBoxImageEditUI } from './ckboximageedit/ckboximageeditui.js';
|
13
|
+
export { default as CKBoxImageEdit } from './ckboximageedit.js';
|
14
|
+
export type { default as CKBoxCommand } from './ckboxcommand.js';
|
15
|
+
export type { default as CKBoxImageEditCommand } from './ckboximageedit/ckboximageeditcommand.js';
|
16
|
+
export type { CKBoxConfig } from './ckboxconfig.js';
|
17
|
+
import './augmentation.js';
|
@@ -0,0 +1,63 @@
|
|
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 ckbox/utils
|
7
|
+
*/
|
8
|
+
import type { InitializedToken } from '@ckeditor/ckeditor5-cloud-services';
|
9
|
+
import type { CKBoxImageUrls } from './ckboxconfig.js';
|
10
|
+
/**
|
11
|
+
* Converts image source set provided by the CKBox into an object containing:
|
12
|
+
* - responsive URLs for the "webp" image format,
|
13
|
+
* - one fallback URL for browsers that do not support the "webp" format.
|
14
|
+
*/
|
15
|
+
export declare function getImageUrls(imageUrls: CKBoxImageUrls): {
|
16
|
+
imageFallbackUrl: string;
|
17
|
+
imageSources: Array<{
|
18
|
+
srcset: string;
|
19
|
+
sizes: string;
|
20
|
+
type: string;
|
21
|
+
}>;
|
22
|
+
};
|
23
|
+
/**
|
24
|
+
* Returns a workspace id to use for communication with the CKBox service.
|
25
|
+
*
|
26
|
+
* @param defaultWorkspaceId The default workspace to use taken from editor config.
|
27
|
+
*/
|
28
|
+
export declare function getWorkspaceId(token: InitializedToken, defaultWorkspaceId?: string): string | null;
|
29
|
+
/**
|
30
|
+
* Generates an image data URL from its `blurhash` representation.
|
31
|
+
*/
|
32
|
+
export declare function blurHashToDataUrl(hash?: string): string | undefined;
|
33
|
+
/**
|
34
|
+
* Sends the HTTP request.
|
35
|
+
*
|
36
|
+
* @internal
|
37
|
+
* @param config.url the URL where the request will be sent.
|
38
|
+
* @param config.method The HTTP method.
|
39
|
+
* @param config.data Additional data to send.
|
40
|
+
* @param config.onUploadProgress A callback informing about the upload progress.
|
41
|
+
*/
|
42
|
+
export declare function sendHttpRequest({ url, method, data, onUploadProgress, signal, authorization }: {
|
43
|
+
url: URL;
|
44
|
+
signal: AbortSignal;
|
45
|
+
authorization: string;
|
46
|
+
method?: 'GET' | 'POST';
|
47
|
+
data?: FormData | null;
|
48
|
+
onUploadProgress?: (evt: ProgressEvent) => void;
|
49
|
+
}): Promise<any>;
|
50
|
+
/**
|
51
|
+
* Returns an extension a typical file in the specified `mimeType` format would have.
|
52
|
+
*/
|
53
|
+
export declare function convertMimeTypeToExtension(mimeType: string): string;
|
54
|
+
/**
|
55
|
+
* Tries to fetch the given `url` and returns 'content-type' of the response.
|
56
|
+
*/
|
57
|
+
export declare function getContentTypeOfUrl(url: string, options: {
|
58
|
+
signal: AbortSignal;
|
59
|
+
}): Promise<string>;
|
60
|
+
/**
|
61
|
+
* Returns an extension from the given value.
|
62
|
+
*/
|
63
|
+
export declare function getFileExtension(file: File): string;
|
package/lang/translations/he.po
CHANGED
@@ -14,7 +14,7 @@ msgid ""
|
|
14
14
|
msgstr ""
|
15
15
|
"Language-Team: Hebrew (https://app.transifex.com/ckeditor/teams/11143/he/)\n"
|
16
16
|
"Language: he\n"
|
17
|
-
"Plural-Forms: nplurals=
|
17
|
+
"Plural-Forms: nplurals=3; plural=(n == 1 && n % 1 == 0) ? 0 : (n == 2 && n % 1 == 0) ? 1: 2;\n"
|
18
18
|
"Content-Type: text/plain; charset=UTF-8\n"
|
19
19
|
|
20
20
|
msgctxt "A toolbar button tooltip for opening the file browser that allows inserting an image or a file to the editor."
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ckeditor/ckeditor5-ckbox",
|
3
|
-
"version": "41.
|
3
|
+
"version": "41.3.0-alpha.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": "41.
|
16
|
+
"ckeditor5": "41.3.0-alpha.0",
|
17
17
|
"blurhash": "2.0.5",
|
18
18
|
"lodash-es": "4.17.21"
|
19
19
|
},
|
@@ -27,6 +27,7 @@
|
|
27
27
|
"directory": "packages/ckeditor5-ckbox"
|
28
28
|
},
|
29
29
|
"files": [
|
30
|
+
"dist",
|
30
31
|
"lang",
|
31
32
|
"src/**/*.js",
|
32
33
|
"src/**/*.d.ts",
|
package/src/ckboxediting.d.ts
CHANGED
@@ -26,6 +26,15 @@ export default class CKBoxEditing extends Plugin {
|
|
26
26
|
* @inheritDoc
|
27
27
|
*/
|
28
28
|
init(): void;
|
29
|
+
/**
|
30
|
+
* @inheritDoc
|
31
|
+
*/
|
32
|
+
afterInit(): void;
|
33
|
+
/**
|
34
|
+
* Returns true only when the integrator intentionally wants to use the plugin, i.e. when the `config.ckbox` exists or
|
35
|
+
* the CKBox JavaScript library is loaded.
|
36
|
+
*/
|
37
|
+
private _shouldBeInitialised;
|
29
38
|
/**
|
30
39
|
* Checks if at least one image plugin is loaded.
|
31
40
|
*/
|
package/src/ckboxediting.js
CHANGED
@@ -30,14 +30,23 @@ export default class CKBoxEditing extends Plugin {
|
|
30
30
|
*/
|
31
31
|
init() {
|
32
32
|
const editor = this.editor;
|
33
|
-
|
34
|
-
const isLibraryLoaded = !!window.CKBox;
|
35
|
-
// Proceed with plugin initialization only when the integrator intentionally wants to use it, i.e. when the `config.ckbox` exists or
|
36
|
-
// the CKBox JavaScript library is loaded.
|
37
|
-
if (!hasConfiguration && !isLibraryLoaded) {
|
33
|
+
if (!this._shouldBeInitialised()) {
|
38
34
|
return;
|
39
35
|
}
|
40
36
|
this._checkImagePlugins();
|
37
|
+
// Registering the `ckbox` command makes sense only if the CKBox library is loaded, as the `ckbox` command opens the CKBox dialog.
|
38
|
+
if (isLibraryLoaded()) {
|
39
|
+
editor.commands.add('ckbox', new CKBoxCommand(editor));
|
40
|
+
}
|
41
|
+
}
|
42
|
+
/**
|
43
|
+
* @inheritDoc
|
44
|
+
*/
|
45
|
+
afterInit() {
|
46
|
+
const editor = this.editor;
|
47
|
+
if (!this._shouldBeInitialised()) {
|
48
|
+
return;
|
49
|
+
}
|
41
50
|
// Extending the schema, registering converters and applying fixers only make sense if the configuration option to assign
|
42
51
|
// the assets ID with the model elements is enabled.
|
43
52
|
if (!editor.config.get('ckbox.ignoreDataId')) {
|
@@ -45,10 +54,15 @@ export default class CKBoxEditing extends Plugin {
|
|
45
54
|
this._initConversion();
|
46
55
|
this._initFixers();
|
47
56
|
}
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
57
|
+
}
|
58
|
+
/**
|
59
|
+
* Returns true only when the integrator intentionally wants to use the plugin, i.e. when the `config.ckbox` exists or
|
60
|
+
* the CKBox JavaScript library is loaded.
|
61
|
+
*/
|
62
|
+
_shouldBeInitialised() {
|
63
|
+
const editor = this.editor;
|
64
|
+
const hasConfiguration = !!editor.config.get('ckbox');
|
65
|
+
return hasConfiguration || isLibraryLoaded();
|
52
66
|
}
|
53
67
|
/**
|
54
68
|
* Checks if at least one image plugin is loaded.
|
@@ -319,3 +333,9 @@ function shouldUpcastAttributeForNode(node) {
|
|
319
333
|
}
|
320
334
|
return false;
|
321
335
|
}
|
336
|
+
/**
|
337
|
+
* Returns true if the CKBox library is loaded, false otherwise.
|
338
|
+
*/
|
339
|
+
function isLibraryLoaded() {
|
340
|
+
return !!window.CKBox;
|
341
|
+
}
|
package/src/ckboxui.js
CHANGED
@@ -22,14 +22,15 @@ export default class CKBoxUI extends Plugin {
|
|
22
22
|
*/
|
23
23
|
afterInit() {
|
24
24
|
const editor = this.editor;
|
25
|
-
const command = editor.commands.get('ckbox');
|
26
25
|
// Do not register the `ckbox` button if the command does not exist.
|
27
|
-
|
26
|
+
// This might happen when CKBox library is not loaded on the page.
|
27
|
+
if (!editor.commands.get('ckbox')) {
|
28
28
|
return;
|
29
29
|
}
|
30
30
|
const t = editor.t;
|
31
31
|
const componentFactory = editor.ui.componentFactory;
|
32
32
|
componentFactory.add('ckbox', locale => {
|
33
|
+
const command = editor.commands.get('ckbox');
|
33
34
|
const button = new ButtonView(locale);
|
34
35
|
button.set({
|
35
36
|
label: t('Open file manager'),
|
@@ -46,7 +47,7 @@ export default class CKBoxUI extends Plugin {
|
|
46
47
|
const imageInsertUI = editor.plugins.get('ImageInsertUI');
|
47
48
|
imageInsertUI.registerIntegration({
|
48
49
|
name: 'assetManager',
|
49
|
-
observable:
|
50
|
+
observable: () => editor.commands.get('ckbox'),
|
50
51
|
buttonViewCreator: () => {
|
51
52
|
const button = this.editor.ui.componentFactory.create('ckbox');
|
52
53
|
button.icon = icons.imageAssetManager;
|