@ckeditor/ckeditor5-ckbox 0.0.0-nightly-next-20250223.0 → 0.0.0-nightly-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-ckbox",
3
- "version": "0.0.0-nightly-next-20250223.0",
3
+ "version": "0.0.0-nightly-20250224.0",
4
4
  "description": "CKBox integration for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,17 +13,16 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "@ckeditor/ckeditor5-cloud-services": "0.0.0-nightly-next-20250223.0",
17
- "@ckeditor/ckeditor5-core": "0.0.0-nightly-next-20250223.0",
18
- "@ckeditor/ckeditor5-engine": "0.0.0-nightly-next-20250223.0",
19
- "@ckeditor/ckeditor5-icons": "0.0.0-nightly-next-20250223.0",
20
- "@ckeditor/ckeditor5-image": "0.0.0-nightly-next-20250223.0",
21
- "@ckeditor/ckeditor5-ui": "0.0.0-nightly-next-20250223.0",
22
- "@ckeditor/ckeditor5-upload": "0.0.0-nightly-next-20250223.0",
23
- "@ckeditor/ckeditor5-utils": "0.0.0-nightly-next-20250223.0",
24
- "ckeditor5": "0.0.0-nightly-next-20250223.0",
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-image": "0.0.0-nightly-20250224.0",
20
+ "@ckeditor/ckeditor5-ui": "0.0.0-nightly-20250224.0",
21
+ "@ckeditor/ckeditor5-upload": "0.0.0-nightly-20250224.0",
22
+ "@ckeditor/ckeditor5-utils": "0.0.0-nightly-20250224.0",
23
+ "ckeditor5": "0.0.0-nightly-20250224.0",
25
24
  "blurhash": "2.0.5",
26
- "es-toolkit": "1.32.0"
25
+ "lodash-es": "4.17.21"
27
26
  },
28
27
  "author": "CKSource (http://cksource.com/)",
29
28
  "license": "SEE LICENSE IN LICENSE.md",
@@ -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;
49
27
  /**
50
28
  * @inheritDoc
51
29
  */
52
30
  constructor(editor) {
53
31
  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 'es-toolkit/compat';
12
+ import { isEqual } from 'lodash-es';
13
13
  import { sendHttpRequest } from '../utils.js';
14
14
  import { prepareImageAssetAttributes } from '../ckboxcommand.js';
15
15
  import { createEditabilityChecker } from './utils.js';
@@ -20,35 +20,27 @@ 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);
47
23
  /**
48
24
  * @inheritDoc
49
25
  */
50
26
  constructor(editor) {
51
27
  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);
52
44
  this.value = false;
53
45
  this._canEdit = createEditabilityChecker(editor.config.get('ckbox.allowExternalImagesEditing'));
54
46
  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 { IconCkboxImageEdit } from 'ckeditor5/src/icons.js';
10
+ import ckboxImageEditIcon from '../../theme/icons/ckbox-image-edit.svg';
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: IconCkboxImageEdit,
41
+ icon: ckboxImageEditIcon,
42
42
  tooltip: true
43
43
  });
44
44
  view.bind('label').to(uploadImageCommand, 'isAccessAllowed', isAccessAllowed => isAccessAllowed ?
package/src/ckboxui.js CHANGED
@@ -5,9 +5,8 @@
5
5
  /**
6
6
  * @module ckbox/ckboxui
7
7
  */
8
- import { Plugin } from 'ckeditor5/src/core.js';
8
+ import { icons, 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';
11
10
  /**
12
11
  * Introduces UI components for the `CKBox` plugin.
13
12
  *
@@ -73,7 +72,7 @@ export default class CKBoxUI extends Plugin {
73
72
  _createFileToolbarButton() {
74
73
  const t = this.editor.locale.t;
75
74
  const button = this._createButton(ButtonView);
76
- button.icon = IconBrowseFiles;
75
+ button.icon = icons.browseFiles;
77
76
  button.label = t('Open file manager');
78
77
  button.tooltip = true;
79
78
  return button;
@@ -85,7 +84,7 @@ export default class CKBoxUI extends Plugin {
85
84
  const t = this.editor.locale.t;
86
85
  const imageInsertUI = this.editor.plugins.get('ImageInsertUI');
87
86
  const button = this._createButton(ButtonView);
88
- button.icon = IconImageAssetManager;
87
+ button.icon = icons.imageAssetManager;
89
88
  button.bind('label').to(imageInsertUI, 'isImageSelected', isImageSelected => isImageSelected ? t('Replace image with file manager') : t('Insert image with file manager'));
90
89
  button.tooltip = true;
91
90
  return button;
@@ -97,7 +96,7 @@ export default class CKBoxUI extends Plugin {
97
96
  const t = this.editor.locale.t;
98
97
  const imageInsertUI = this.editor.plugins.get('ImageInsertUI');
99
98
  const button = this._createButton(ButtonView);
100
- button.icon = IconImageAssetManager;
99
+ button.icon = icons.imageAssetManager;
101
100
  button.withText = true;
102
101
  button.bind('label').to(imageInsertUI, 'isImageSelected', isImageSelected => isImageSelected ? t('Replace with file manager') : t('Insert with file manager'));
103
102
  button.on('execute', () => {
@@ -111,7 +110,7 @@ export default class CKBoxUI extends Plugin {
111
110
  _createFileMenuBarButton() {
112
111
  const t = this.editor.locale.t;
113
112
  const button = this._createButton(MenuBarMenuListItemButtonView);
114
- button.icon = IconBrowseFiles;
113
+ button.icon = icons.browseFiles;
115
114
  button.withText = true;
116
115
  button.label = t('File');
117
116
  return button;
@@ -124,7 +123,7 @@ export default class CKBoxUI extends Plugin {
124
123
  const translateVariableKey = this.editor.locale.t;
125
124
  const t = this.editor.locale.t;
126
125
  const button = this._createButton(MenuBarMenuListItemButtonView);
127
- button.icon = IconImageAssetManager;
126
+ button.icon = icons.imageAssetManager;
128
127
  button.withText = true;
129
128
  switch (type) {
130
129
  case 'insertOnly':
@@ -71,30 +71,6 @@ 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;
98
74
  /**
99
75
  * Creates a new adapter instance.
100
76
  */
package/src/ckboxutils.js CHANGED
@@ -10,10 +10,6 @@ const DEFAULT_CKBOX_THEME_NAME = 'lark';
10
10
  * The CKBox utilities plugin.
11
11
  */
12
12
  export default class CKBoxUtils extends Plugin {
13
- /**
14
- * CKEditor Cloud Services access token.
15
- */
16
- _token;
17
13
  /**
18
14
  * @inheritDoc
19
15
  */
package/src/utils.js CHANGED
@@ -38,11 +38,12 @@ 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 = payload.auth?.ckbox?.workspaces || [payload.aud];
41
+ const workspaces = (payload.auth && payload.auth.ckbox && payload.auth.ckbox.workspaces) || [payload.aud];
42
42
  if (!defaultWorkspaceId) {
43
43
  return workspaces[0];
44
44
  }
45
- if (payload.auth?.ckbox?.role == 'superadmin' || workspaces.includes(defaultWorkspaceId)) {
45
+ const role = payload.auth && payload.auth.ckbox && payload.auth.ckbox.role;
46
+ if (role == 'superadmin' || workspaces.includes(defaultWorkspaceId)) {
46
47
  return defaultWorkspaceId;
47
48
  }
48
49
  return null;
@@ -0,0 +1 @@
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>