@ckeditor/ckeditor5-ckbox 0.0.0-nightly-20250224.0 → 0.0.0-nightly-next-20250224.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/LICENSE.md +1 -0
- package/build/ckbox.js +1 -1
- package/ckeditor5-metadata.json +2 -2
- package/dist/index.js +11 -13
- package/dist/index.js.map +1 -1
- package/package.json +11 -10
- package/src/ckboxcommand.js +22 -22
- package/src/ckboximageedit/ckboximageeditcommand.js +25 -17
- package/src/ckboximageedit/ckboximageeditui.js +2 -2
- package/src/ckboxui.js +7 -6
- package/src/ckboxuploadadapter.js +24 -0
- package/src/ckboxutils.js +4 -0
- package/src/utils.js +2 -3
- package/theme/icons/ckbox-image-edit.svg +0 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ckeditor/ckeditor5-ckbox",
|
3
|
-
"version": "0.0.0-nightly-20250224.0",
|
3
|
+
"version": "0.0.0-nightly-next-20250224.0",
|
4
4
|
"description": "CKBox integration for CKEditor 5.",
|
5
5
|
"keywords": [
|
6
6
|
"ckeditor",
|
@@ -13,16 +13,17 @@
|
|
13
13
|
"type": "module",
|
14
14
|
"main": "src/index.js",
|
15
15
|
"dependencies": {
|
16
|
-
"@ckeditor/ckeditor5-cloud-services": "0.0.0-nightly-20250224.0",
|
17
|
-
"@ckeditor/ckeditor5-core": "0.0.0-nightly-20250224.0",
|
18
|
-
"@ckeditor/ckeditor5-engine": "0.0.0-nightly-20250224.0",
|
19
|
-
"@ckeditor/ckeditor5-
|
20
|
-
"@ckeditor/ckeditor5-
|
21
|
-
"@ckeditor/ckeditor5-
|
22
|
-
"@ckeditor/ckeditor5-
|
23
|
-
"ckeditor5": "0.0.0-nightly-20250224.0",
|
16
|
+
"@ckeditor/ckeditor5-cloud-services": "0.0.0-nightly-next-20250224.0",
|
17
|
+
"@ckeditor/ckeditor5-core": "0.0.0-nightly-next-20250224.0",
|
18
|
+
"@ckeditor/ckeditor5-engine": "0.0.0-nightly-next-20250224.0",
|
19
|
+
"@ckeditor/ckeditor5-icons": "0.0.0-nightly-next-20250224.0",
|
20
|
+
"@ckeditor/ckeditor5-image": "0.0.0-nightly-next-20250224.0",
|
21
|
+
"@ckeditor/ckeditor5-ui": "0.0.0-nightly-next-20250224.0",
|
22
|
+
"@ckeditor/ckeditor5-upload": "0.0.0-nightly-next-20250224.0",
|
23
|
+
"@ckeditor/ckeditor5-utils": "0.0.0-nightly-next-20250224.0",
|
24
|
+
"ckeditor5": "0.0.0-nightly-next-20250224.0",
|
24
25
|
"blurhash": "2.0.5",
|
25
|
-
"
|
26
|
+
"es-toolkit": "1.32.0"
|
26
27
|
},
|
27
28
|
"author": "CKSource (http://cksource.com/)",
|
28
29
|
"license": "SEE LICENSE IN LICENSE.md",
|
package/src/ckboxcommand.js
CHANGED
@@ -24,33 +24,33 @@ const ASSET_INSERTION_WAIT_TIMEOUT = 1000;
|
|
24
24
|
* {@link module:link/link~Link Link feature}.
|
25
25
|
*/
|
26
26
|
export default class CKBoxCommand extends Command {
|
27
|
+
/**
|
28
|
+
* A set of all chosen assets. They are stored temporarily and they are automatically removed 1 second after being chosen.
|
29
|
+
* Chosen assets have to be "remembered" for a while to be able to map the given asset with the element inserted into the model.
|
30
|
+
* This association map is then used to set the ID on the model element.
|
31
|
+
*
|
32
|
+
* All chosen assets are automatically removed after the timeout, because (theoretically) it may happen that they will never be
|
33
|
+
* inserted into the model, even if the {@link module:link/linkcommand~LinkCommand `'link'`} command or the
|
34
|
+
* {@link module:image/image/insertimagecommand~InsertImageCommand `'insertImage'`} command is enabled. Such a case may arise when
|
35
|
+
* another plugin blocks the command execution. Then, in order not to keep the chosen (but not inserted) assets forever, we delete
|
36
|
+
* them automatically to prevent memory leakage. The 1 second timeout is enough to insert the asset into the model and extract the
|
37
|
+
* ID from the chosen asset.
|
38
|
+
*
|
39
|
+
* The assets are stored only if
|
40
|
+
* the {@link module:ckbox/ckboxconfig~CKBoxConfig#ignoreDataId `config.ckbox.ignoreDataId`} option is set to `false` (by default).
|
41
|
+
*
|
42
|
+
* @internal
|
43
|
+
*/
|
44
|
+
_chosenAssets = new Set();
|
45
|
+
/**
|
46
|
+
* The DOM element that acts as a mounting point for the CKBox dialog.
|
47
|
+
*/
|
48
|
+
_wrapper = null;
|
27
49
|
/**
|
28
50
|
* @inheritDoc
|
29
51
|
*/
|
30
52
|
constructor(editor) {
|
31
53
|
super(editor);
|
32
|
-
/**
|
33
|
-
* A set of all chosen assets. They are stored temporarily and they are automatically removed 1 second after being chosen.
|
34
|
-
* Chosen assets have to be "remembered" for a while to be able to map the given asset with the element inserted into the model.
|
35
|
-
* This association map is then used to set the ID on the model element.
|
36
|
-
*
|
37
|
-
* All chosen assets are automatically removed after the timeout, because (theoretically) it may happen that they will never be
|
38
|
-
* inserted into the model, even if the {@link module:link/linkcommand~LinkCommand `'link'`} command or the
|
39
|
-
* {@link module:image/image/insertimagecommand~InsertImageCommand `'insertImage'`} command is enabled. Such a case may arise when
|
40
|
-
* another plugin blocks the command execution. Then, in order not to keep the chosen (but not inserted) assets forever, we delete
|
41
|
-
* them automatically to prevent memory leakage. The 1 second timeout is enough to insert the asset into the model and extract the
|
42
|
-
* ID from the chosen asset.
|
43
|
-
*
|
44
|
-
* The assets are stored only if
|
45
|
-
* the {@link module:ckbox/ckboxconfig~CKBoxConfig#ignoreDataId `config.ckbox.ignoreDataId`} option is set to `false` (by default).
|
46
|
-
*
|
47
|
-
* @internal
|
48
|
-
*/
|
49
|
-
this._chosenAssets = new Set();
|
50
|
-
/**
|
51
|
-
* The DOM element that acts as a mounting point for the CKBox dialog.
|
52
|
-
*/
|
53
|
-
this._wrapper = null;
|
54
54
|
this._initListeners();
|
55
55
|
}
|
56
56
|
/**
|
@@ -9,7 +9,7 @@
|
|
9
9
|
import { Command, PendingActions } from 'ckeditor5/src/core.js';
|
10
10
|
import { CKEditorError, abortableDebounce, createElement, retry, delay } from 'ckeditor5/src/utils.js';
|
11
11
|
import { Notification } from 'ckeditor5/src/ui.js';
|
12
|
-
import { isEqual } from '
|
12
|
+
import { isEqual } from 'es-toolkit/compat';
|
13
13
|
import { sendHttpRequest } from '../utils.js';
|
14
14
|
import { prepareImageAssetAttributes } from '../ckboxcommand.js';
|
15
15
|
import { createEditabilityChecker } from './utils.js';
|
@@ -20,27 +20,35 @@ import CKBoxUtils from '../ckboxutils.js';
|
|
20
20
|
* Opens the CKBox dialog for editing the image.
|
21
21
|
*/
|
22
22
|
export default class CKBoxImageEditCommand extends Command {
|
23
|
+
/**
|
24
|
+
* The DOM element that acts as a mounting point for the CKBox Edit Image dialog.
|
25
|
+
*/
|
26
|
+
_wrapper = null;
|
27
|
+
/**
|
28
|
+
* The states of image processing in progress.
|
29
|
+
*/
|
30
|
+
_processInProgress = new Set();
|
31
|
+
/**
|
32
|
+
* Determines if the element can be edited.
|
33
|
+
*/
|
34
|
+
_canEdit;
|
35
|
+
/**
|
36
|
+
* A wrapper function to prepare mount options. Ensures that at most one preparation is in-flight.
|
37
|
+
*/
|
38
|
+
_prepareOptions;
|
39
|
+
/**
|
40
|
+
* CKBox's onClose function runs before the final cleanup, potentially causing
|
41
|
+
* page layout changes after it finishes. To address this, we use a setTimeout hack
|
42
|
+
* to ensure that floating elements on the page maintain their correct position.
|
43
|
+
*
|
44
|
+
* See: https://github.com/ckeditor/ckeditor5/issues/16153.
|
45
|
+
*/
|
46
|
+
_updateUiDelayed = delay(() => this.editor.ui.update(), 0);
|
23
47
|
/**
|
24
48
|
* @inheritDoc
|
25
49
|
*/
|
26
50
|
constructor(editor) {
|
27
51
|
super(editor);
|
28
|
-
/**
|
29
|
-
* The DOM element that acts as a mounting point for the CKBox Edit Image dialog.
|
30
|
-
*/
|
31
|
-
this._wrapper = null;
|
32
|
-
/**
|
33
|
-
* The states of image processing in progress.
|
34
|
-
*/
|
35
|
-
this._processInProgress = new Set();
|
36
|
-
/**
|
37
|
-
* CKBox's onClose function runs before the final cleanup, potentially causing
|
38
|
-
* page layout changes after it finishes. To address this, we use a setTimeout hack
|
39
|
-
* to ensure that floating elements on the page maintain their correct position.
|
40
|
-
*
|
41
|
-
* See: https://github.com/ckeditor/ckeditor5/issues/16153.
|
42
|
-
*/
|
43
|
-
this._updateUiDelayed = delay(() => this.editor.ui.update(), 0);
|
44
52
|
this.value = false;
|
45
53
|
this._canEdit = createEditabilityChecker(editor.config.get('ckbox.allowExternalImagesEditing'));
|
46
54
|
this._prepareOptions = abortableDebounce((signal, state) => this._prepareOptionsAbortable(signal, state));
|
@@ -7,7 +7,7 @@
|
|
7
7
|
*/
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
9
9
|
import { ButtonView } from 'ckeditor5/src/ui.js';
|
10
|
-
import
|
10
|
+
import { IconCkboxImageEdit } from 'ckeditor5/src/icons.js';
|
11
11
|
/**
|
12
12
|
* The UI plugin of the CKBox image edit feature.
|
13
13
|
*
|
@@ -38,7 +38,7 @@ export default class CKBoxImageEditUI extends Plugin {
|
|
38
38
|
const view = new ButtonView(locale);
|
39
39
|
const t = locale.t;
|
40
40
|
view.set({
|
41
|
-
icon:
|
41
|
+
icon: IconCkboxImageEdit,
|
42
42
|
tooltip: true
|
43
43
|
});
|
44
44
|
view.bind('label').to(uploadImageCommand, 'isAccessAllowed', isAccessAllowed => isAccessAllowed ?
|
package/src/ckboxui.js
CHANGED
@@ -5,8 +5,9 @@
|
|
5
5
|
/**
|
6
6
|
* @module ckbox/ckboxui
|
7
7
|
*/
|
8
|
-
import {
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
9
9
|
import { ButtonView, MenuBarMenuListItemButtonView } from 'ckeditor5/src/ui.js';
|
10
|
+
import { IconBrowseFiles, IconImageAssetManager } from 'ckeditor5/src/icons.js';
|
10
11
|
/**
|
11
12
|
* Introduces UI components for the `CKBox` plugin.
|
12
13
|
*
|
@@ -72,7 +73,7 @@ export default class CKBoxUI extends Plugin {
|
|
72
73
|
_createFileToolbarButton() {
|
73
74
|
const t = this.editor.locale.t;
|
74
75
|
const button = this._createButton(ButtonView);
|
75
|
-
button.icon =
|
76
|
+
button.icon = IconBrowseFiles;
|
76
77
|
button.label = t('Open file manager');
|
77
78
|
button.tooltip = true;
|
78
79
|
return button;
|
@@ -84,7 +85,7 @@ export default class CKBoxUI extends Plugin {
|
|
84
85
|
const t = this.editor.locale.t;
|
85
86
|
const imageInsertUI = this.editor.plugins.get('ImageInsertUI');
|
86
87
|
const button = this._createButton(ButtonView);
|
87
|
-
button.icon =
|
88
|
+
button.icon = IconImageAssetManager;
|
88
89
|
button.bind('label').to(imageInsertUI, 'isImageSelected', isImageSelected => isImageSelected ? t('Replace image with file manager') : t('Insert image with file manager'));
|
89
90
|
button.tooltip = true;
|
90
91
|
return button;
|
@@ -96,7 +97,7 @@ export default class CKBoxUI extends Plugin {
|
|
96
97
|
const t = this.editor.locale.t;
|
97
98
|
const imageInsertUI = this.editor.plugins.get('ImageInsertUI');
|
98
99
|
const button = this._createButton(ButtonView);
|
99
|
-
button.icon =
|
100
|
+
button.icon = IconImageAssetManager;
|
100
101
|
button.withText = true;
|
101
102
|
button.bind('label').to(imageInsertUI, 'isImageSelected', isImageSelected => isImageSelected ? t('Replace with file manager') : t('Insert with file manager'));
|
102
103
|
button.on('execute', () => {
|
@@ -110,7 +111,7 @@ export default class CKBoxUI extends Plugin {
|
|
110
111
|
_createFileMenuBarButton() {
|
111
112
|
const t = this.editor.locale.t;
|
112
113
|
const button = this._createButton(MenuBarMenuListItemButtonView);
|
113
|
-
button.icon =
|
114
|
+
button.icon = IconBrowseFiles;
|
114
115
|
button.withText = true;
|
115
116
|
button.label = t('File');
|
116
117
|
return button;
|
@@ -123,7 +124,7 @@ export default class CKBoxUI extends Plugin {
|
|
123
124
|
const translateVariableKey = this.editor.locale.t;
|
124
125
|
const t = this.editor.locale.t;
|
125
126
|
const button = this._createButton(MenuBarMenuListItemButtonView);
|
126
|
-
button.icon =
|
127
|
+
button.icon = IconImageAssetManager;
|
127
128
|
button.withText = true;
|
128
129
|
switch (type) {
|
129
130
|
case 'insertOnly':
|
@@ -71,6 +71,30 @@ export default class CKBoxUploadAdapter extends Plugin {
|
|
71
71
|
* Upload adapter for CKBox.
|
72
72
|
*/
|
73
73
|
class Adapter {
|
74
|
+
/**
|
75
|
+
* FileLoader instance to use during the upload.
|
76
|
+
*/
|
77
|
+
loader;
|
78
|
+
/**
|
79
|
+
* CKEditor Cloud Services access token.
|
80
|
+
*/
|
81
|
+
token;
|
82
|
+
/**
|
83
|
+
* The editor instance.
|
84
|
+
*/
|
85
|
+
editor;
|
86
|
+
/**
|
87
|
+
* The abort controller for aborting asynchronous processes.
|
88
|
+
*/
|
89
|
+
controller;
|
90
|
+
/**
|
91
|
+
* The base URL where all requests should be sent.
|
92
|
+
*/
|
93
|
+
serviceOrigin;
|
94
|
+
/**
|
95
|
+
* The reference to CKBoxUtils plugin.
|
96
|
+
*/
|
97
|
+
ckboxUtils;
|
74
98
|
/**
|
75
99
|
* Creates a new adapter instance.
|
76
100
|
*/
|
package/src/ckboxutils.js
CHANGED
package/src/utils.js
CHANGED
@@ -38,12 +38,11 @@ export function getImageUrls(imageUrls) {
|
|
38
38
|
export function getWorkspaceId(token, defaultWorkspaceId) {
|
39
39
|
const [, binaryTokenPayload] = token.value.split('.');
|
40
40
|
const payload = JSON.parse(atob(binaryTokenPayload));
|
41
|
-
const workspaces =
|
41
|
+
const workspaces = payload.auth?.ckbox?.workspaces || [payload.aud];
|
42
42
|
if (!defaultWorkspaceId) {
|
43
43
|
return workspaces[0];
|
44
44
|
}
|
45
|
-
|
46
|
-
if (role == 'superadmin' || workspaces.includes(defaultWorkspaceId)) {
|
45
|
+
if (payload.auth?.ckbox?.role == 'superadmin' || workspaces.includes(defaultWorkspaceId)) {
|
47
46
|
return defaultWorkspaceId;
|
48
47
|
}
|
49
48
|
return null;
|
@@ -1 +0,0 @@
|
|
1
|
-
<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M1.201 1C.538 1 0 1.47 0 2.1v14.363c0 .64.534 1.037 1.186 1.037H5.06l5.058-5.078L6.617 9.15a.696.696 0 0 0-.957-.033L1.5 13.6V2.5h15v4.354a3.478 3.478 0 0 1 1.5.049V2.1c0-.63-.547-1.1-1.2-1.1H1.202Zm11.713 2.803a2.147 2.147 0 0 0-2.049 1.992 2.14 2.14 0 0 0 1.28 2.096 2.13 2.13 0 0 0 2.642-3.11 2.129 2.129 0 0 0-1.873-.978ZM8.089 17.635v2.388h2.389l7.046-7.046-2.39-2.39-7.045 7.048Zm11.282-6.507a.637.637 0 0 0 .139-.692.603.603 0 0 0-.139-.205l-1.49-1.488a.63.63 0 0 0-.899 0l-1.166 1.163 2.39 2.39 1.165-1.168Z"/></svg>
|