@ckeditor/ckeditor5-ckbox 40.1.0 → 41.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. package/LICENSE.md +1 -1
  2. package/build/ckbox.js +3 -3
  3. package/build/translations/ar.js +1 -1
  4. package/build/translations/az.js +1 -1
  5. package/build/translations/bg.js +1 -1
  6. package/build/translations/bn.js +1 -1
  7. package/build/translations/ca.js +1 -1
  8. package/build/translations/cs.js +1 -1
  9. package/build/translations/da.js +1 -1
  10. package/build/translations/de.js +1 -1
  11. package/build/translations/el.js +1 -1
  12. package/build/translations/en-au.js +1 -1
  13. package/build/translations/es-co.js +1 -1
  14. package/build/translations/es.js +1 -1
  15. package/build/translations/et.js +1 -1
  16. package/build/translations/fa.js +1 -1
  17. package/build/translations/fi.js +1 -1
  18. package/build/translations/fr.js +1 -1
  19. package/build/translations/gl.js +1 -1
  20. package/build/translations/he.js +1 -1
  21. package/build/translations/hi.js +1 -1
  22. package/build/translations/hr.js +1 -1
  23. package/build/translations/hu.js +1 -1
  24. package/build/translations/id.js +1 -1
  25. package/build/translations/it.js +1 -1
  26. package/build/translations/ja.js +1 -1
  27. package/build/translations/ko.js +1 -1
  28. package/build/translations/lt.js +1 -1
  29. package/build/translations/lv.js +1 -1
  30. package/build/translations/ms.js +1 -1
  31. package/build/translations/nl.js +1 -1
  32. package/build/translations/no.js +1 -1
  33. package/build/translations/pl.js +1 -1
  34. package/build/translations/pt-br.js +1 -1
  35. package/build/translations/pt.js +1 -1
  36. package/build/translations/ro.js +1 -1
  37. package/build/translations/ru.js +1 -1
  38. package/build/translations/sk.js +1 -1
  39. package/build/translations/sq.js +1 -1
  40. package/build/translations/sr-latn.js +1 -1
  41. package/build/translations/sr.js +1 -1
  42. package/build/translations/sv.js +1 -1
  43. package/build/translations/th.js +1 -1
  44. package/build/translations/tr.js +1 -1
  45. package/build/translations/ug.js +1 -1
  46. package/build/translations/uk.js +1 -1
  47. package/build/translations/ur.js +1 -1
  48. package/build/translations/uz.js +1 -1
  49. package/build/translations/vi.js +1 -1
  50. package/build/translations/zh-cn.js +1 -1
  51. package/build/translations/zh.js +1 -1
  52. package/ckeditor5-metadata.json +18 -1
  53. package/lang/contexts.json +6 -2
  54. package/lang/translations/ar.po +19 -3
  55. package/lang/translations/az.po +19 -3
  56. package/lang/translations/bg.po +19 -3
  57. package/lang/translations/bn.po +19 -3
  58. package/lang/translations/ca.po +19 -3
  59. package/lang/translations/cs.po +19 -3
  60. package/lang/translations/da.po +19 -3
  61. package/lang/translations/de.po +19 -3
  62. package/lang/translations/el.po +19 -3
  63. package/lang/translations/en-au.po +19 -3
  64. package/lang/translations/en.po +19 -3
  65. package/lang/translations/es-co.po +19 -3
  66. package/lang/translations/es.po +19 -3
  67. package/lang/translations/et.po +19 -3
  68. package/lang/translations/fa.po +19 -3
  69. package/lang/translations/fi.po +19 -3
  70. package/lang/translations/fr.po +19 -3
  71. package/lang/translations/gl.po +19 -3
  72. package/lang/translations/he.po +19 -3
  73. package/lang/translations/hi.po +19 -3
  74. package/lang/translations/hr.po +19 -3
  75. package/lang/translations/hu.po +19 -3
  76. package/lang/translations/id.po +19 -3
  77. package/lang/translations/it.po +19 -3
  78. package/lang/translations/ja.po +19 -3
  79. package/lang/translations/ko.po +19 -3
  80. package/lang/translations/lt.po +19 -3
  81. package/lang/translations/lv.po +19 -3
  82. package/lang/translations/ms.po +19 -3
  83. package/lang/translations/nl.po +19 -3
  84. package/lang/translations/no.po +19 -3
  85. package/lang/translations/pl.po +19 -3
  86. package/lang/translations/pt-br.po +19 -3
  87. package/lang/translations/pt.po +19 -3
  88. package/lang/translations/ro.po +19 -3
  89. package/lang/translations/ru.po +19 -3
  90. package/lang/translations/sk.po +19 -3
  91. package/lang/translations/sq.po +19 -3
  92. package/lang/translations/sr-latn.po +19 -3
  93. package/lang/translations/sr.po +19 -3
  94. package/lang/translations/sv.po +19 -3
  95. package/lang/translations/th.po +19 -3
  96. package/lang/translations/tr.po +19 -3
  97. package/lang/translations/ug.po +19 -3
  98. package/lang/translations/uk.po +19 -3
  99. package/lang/translations/ur.po +19 -3
  100. package/lang/translations/uz.po +19 -3
  101. package/lang/translations/vi.po +19 -3
  102. package/lang/translations/zh-cn.po +19 -3
  103. package/lang/translations/zh.po +19 -3
  104. package/package.json +5 -3
  105. package/src/augmentation.d.ts +12 -2
  106. package/src/augmentation.js +1 -1
  107. package/src/ckbox.d.ts +4 -4
  108. package/src/ckbox.js +4 -4
  109. package/src/ckboxcommand.d.ts +10 -8
  110. package/src/ckboxcommand.js +9 -5
  111. package/src/ckboxconfig.d.ts +27 -1
  112. package/src/ckboxconfig.js +1 -1
  113. package/src/ckboxediting.d.ts +8 -15
  114. package/src/ckboxediting.js +12 -60
  115. package/src/ckboximageedit/ckboximageeditcommand.d.ts +97 -0
  116. package/src/ckboximageedit/ckboximageeditcommand.js +299 -0
  117. package/src/ckboximageedit/ckboximageeditediting.d.ts +28 -0
  118. package/src/ckboximageedit/ckboximageeditediting.js +36 -0
  119. package/src/ckboximageedit/ckboximageeditui.d.ts +24 -0
  120. package/src/ckboximageedit/ckboximageeditui.js +48 -0
  121. package/src/ckboximageedit/utils.d.ts +10 -0
  122. package/src/ckboximageedit/utils.js +48 -0
  123. package/src/ckboximageedit.d.ts +24 -0
  124. package/src/ckboximageedit.js +28 -0
  125. package/src/ckboxui.d.ts +2 -2
  126. package/src/ckboxui.js +31 -5
  127. package/src/ckboxuploadadapter.d.ts +4 -9
  128. package/src/ckboxuploadadapter.js +19 -164
  129. package/src/ckboxutils.d.ts +50 -0
  130. package/src/ckboxutils.js +183 -0
  131. package/src/index.d.ts +11 -7
  132. package/src/index.js +8 -5
  133. package/src/utils.d.ts +33 -2
  134. package/src/utils.js +94 -1
  135. package/theme/ckboximageedit.css +53 -0
  136. package/theme/icons/ckbox-image-edit.svg +1 -0
  137. package/theme/icons/browse-files.svg +0 -1
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -17,7 +17,7 @@ msgstr ""
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
18
  "Content-Type: text/plain; charset=UTF-8\n"
19
19
 
20
- msgctxt "Toolbar button tooltip for opening a file browser that allows inserting an image or a file to the editor."
20
+ msgctxt "A toolbar button tooltip for opening the file browser that allows inserting an image or a file to the editor."
21
21
  msgid "Open file manager"
22
22
  msgstr "打开文件管理器"
23
23
 
@@ -25,6 +25,22 @@ msgctxt "A message is displayed when CKEditor 5 cannot associate an image with a
25
25
  msgid "Cannot determine a category for the uploaded file."
26
26
  msgstr "无法确定上传文件的类别。"
27
27
 
28
- msgctxt "A message is displayed when the user is not authorised to access CKBox workspace configured as default one."
28
+ msgctxt "A message is displayed when the user is not authorised to access the CKBox workspace configured as default one."
29
29
  msgid "Cannot access default workspace."
30
30
  msgstr "无法访问默认工作区"
31
+
32
+ msgctxt "Image toolbar button tooltip for opening a dialog to manipulate the image."
33
+ msgid "Edit image"
34
+ msgstr "编辑图片"
35
+
36
+ msgctxt "A message stating that image editing is in progress."
37
+ msgid "Processing the edited image."
38
+ msgstr "正在处理已编辑的图片。"
39
+
40
+ msgctxt "A message is displayed when the server fails to process an image or doesn't respond."
41
+ msgid "Server failed to process the image."
42
+ msgstr "服务器未能处理图片。"
43
+
44
+ msgctxt "A message is displayed when category of the image user wants to edit can't be determined."
45
+ msgid "Failed to determine category of edited image."
46
+ msgstr "未能确定已编辑图片的类别。"
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
1
+ # Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
2
  #
3
3
  # !!! IMPORTANT !!!
4
4
  #
@@ -17,7 +17,7 @@ msgstr ""
17
17
  "Plural-Forms: nplurals=1; plural=0;\n"
18
18
  "Content-Type: text/plain; charset=UTF-8\n"
19
19
 
20
- msgctxt "Toolbar button tooltip for opening a file browser that allows inserting an image or a file to the editor."
20
+ msgctxt "A toolbar button tooltip for opening the file browser that allows inserting an image or a file to the editor."
21
21
  msgid "Open file manager"
22
22
  msgstr "開啟檔案管理程式"
23
23
 
@@ -25,6 +25,22 @@ msgctxt "A message is displayed when CKEditor 5 cannot associate an image with a
25
25
  msgid "Cannot determine a category for the uploaded file."
26
26
  msgstr "無法確定上傳檔案的分類。"
27
27
 
28
- msgctxt "A message is displayed when the user is not authorised to access CKBox workspace configured as default one."
28
+ msgctxt "A message is displayed when the user is not authorised to access the CKBox workspace configured as default one."
29
29
  msgid "Cannot access default workspace."
30
30
  msgstr "無法存取預設工作區。"
31
+
32
+ msgctxt "Image toolbar button tooltip for opening a dialog to manipulate the image."
33
+ msgid "Edit image"
34
+ msgstr "編輯圖片"
35
+
36
+ msgctxt "A message stating that image editing is in progress."
37
+ msgid "Processing the edited image."
38
+ msgstr "正在處理已編輯的圖片。"
39
+
40
+ msgctxt "A message is displayed when the server fails to process an image or doesn't respond."
41
+ msgid "Server failed to process the image."
42
+ msgstr "伺服器無法處理該圖片。"
43
+
44
+ msgctxt "A message is displayed when category of the image user wants to edit can't be determined."
45
+ msgid "Failed to determine category of edited image."
46
+ msgstr "無法判斷已編輯圖片的類別。"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-ckbox",
3
- "version": "40.1.0",
3
+ "version": "41.0.0",
4
4
  "description": "CKBox integration for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -10,10 +10,12 @@
10
10
  "ckeditor5-plugin",
11
11
  "ckeditor5-dll"
12
12
  ],
13
+ "type": "module",
13
14
  "main": "src/index.js",
14
15
  "dependencies": {
15
- "ckeditor5": "40.1.0",
16
- "blurhash": "^2.0.5"
16
+ "ckeditor5": "41.0.0",
17
+ "blurhash": "2.0.5",
18
+ "lodash-es": "4.17.21"
17
19
  },
18
20
  "author": "CKSource (http://cksource.com/)",
19
21
  "license": "GPL-2.0-or-later",
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
- import type { CKBox, CKBoxCommand, CKBoxConfig, CKBoxEditing } from './index';
5
+ import type { CKBox, CKBoxCommand, CKBoxConfig, CKBoxEditing, CKBoxImageEdit, CKBoxImageEditEditing, CKBoxImageEditCommand, CKBoxImageEditUI } from './index.js';
6
6
  declare module '@ckeditor/ckeditor5-core' {
7
7
  interface EditorConfig {
8
8
  /**
@@ -15,8 +15,18 @@ declare module '@ckeditor/ckeditor5-core' {
15
15
  interface PluginsMap {
16
16
  [CKBox.pluginName]: CKBox;
17
17
  [CKBoxEditing.pluginName]: CKBoxEditing;
18
+ [CKBoxImageEdit.pluginName]: CKBoxImageEdit;
19
+ [CKBoxImageEditEditing.pluginName]: CKBoxImageEditEditing;
20
+ [CKBoxImageEditUI.pluginName]: CKBoxImageEditUI;
18
21
  }
19
22
  interface CommandsMap {
20
23
  ckbox: CKBoxCommand;
24
+ ckboxImageEdit: CKBoxImageEditCommand;
21
25
  }
22
26
  }
27
+ declare global {
28
+ var CKBox: {
29
+ mount(wrapper: Element, options: Record<string, unknown>): void;
30
+ mountImageEditor(wrapper: Element, options: Record<string, unknown>): void;
31
+ };
32
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  export {};
package/src/ckbox.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  /**
6
6
  * @module ckbox/ckbox
7
7
  */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import CKBoxUI from './ckboxui';
10
- import CKBoxEditing from './ckboxediting';
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import CKBoxUI from './ckboxui.js';
10
+ import CKBoxEditing from './ckboxediting.js';
11
11
  /**
12
12
  * The CKBox feature, a bridge between the CKEditor 5 WYSIWYG editor and the CKBox file manager and uploader.
13
13
  *
package/src/ckbox.js CHANGED
@@ -1,13 +1,13 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  /**
6
6
  * @module ckbox/ckbox
7
7
  */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import CKBoxUI from './ckboxui';
10
- import CKBoxEditing from './ckboxediting';
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import CKBoxUI from './ckboxui.js';
10
+ import CKBoxEditing from './ckboxediting.js';
11
11
  /**
12
12
  * The CKBox feature, a bridge between the CKEditor 5 WYSIWYG editor and the CKBox file manager and uploader.
13
13
  *
@@ -1,14 +1,9 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
- import { Command, type Editor } from 'ckeditor5/src/core';
6
- import type { CKBoxAssetDefinition } from './ckboxconfig';
7
- declare global {
8
- var CKBox: {
9
- mount(wrapper: Element, options: Record<string, unknown>): void;
10
- };
11
- }
5
+ import { Command, type Editor } from 'ckeditor5/src/core.js';
6
+ import type { CKBoxAssetDefinition, CKBoxAssetImageAttributesDefinition, CKBoxRawAssetDefinition } from './ckboxconfig.js';
12
7
  /**
13
8
  * The CKBox command. It is used by the {@link module:ckbox/ckboxediting~CKBoxEditing CKBox editing feature} to open the CKBox file manager.
14
9
  * The file manager allows inserting an image or a link to a file into the editor content.
@@ -78,6 +73,7 @@ export default class CKBoxCommand extends Command {
78
73
  * - language The language for CKBox dialog.
79
74
  * - tokenUrl The token endpoint URL.
80
75
  * - serviceOrigin The base URL of the API service.
76
+ * - forceDemoLabel Whether to force "Powered by CKBox" link.
81
77
  * - dialog.onClose The callback function invoked after closing the CKBox dialog.
82
78
  * - assets.onChoose The callback function invoked after choosing the assets.
83
79
  */
@@ -110,3 +106,9 @@ export default class CKBoxCommand extends Command {
110
106
  */
111
107
  private _insertLink;
112
108
  }
109
+ /**
110
+ * Parses the assets attributes into the internal data format.
111
+ *
112
+ * @internal
113
+ */
114
+ export declare function prepareImageAssetAttributes(asset: CKBoxRawAssetDefinition): CKBoxAssetImageAttributesDefinition;
@@ -1,10 +1,10 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
- import { Command } from 'ckeditor5/src/core';
6
- import { createElement, toMap } from 'ckeditor5/src/utils';
7
- import { blurHashToDataUrl, getImageUrls } from './utils';
5
+ import { Command } from 'ckeditor5/src/core.js';
6
+ import { createElement, toMap } from 'ckeditor5/src/utils.js';
7
+ import { blurHashToDataUrl, getImageUrls } from './utils.js';
8
8
  // Defines the waiting time (in milliseconds) for inserting the chosen asset into the model. The chosen asset is temporarily stored in the
9
9
  // `CKBoxCommand#_chosenAssets` and it is removed from there automatically after this time. See `CKBoxCommand#_chosenAssets` for more
10
10
  // details.
@@ -94,6 +94,7 @@ export default class CKBoxCommand extends Command {
94
94
  * - language The language for CKBox dialog.
95
95
  * - tokenUrl The token endpoint URL.
96
96
  * - serviceOrigin The base URL of the API service.
97
+ * - forceDemoLabel Whether to force "Powered by CKBox" link.
97
98
  * - dialog.onClose The callback function invoked after closing the CKBox dialog.
98
99
  * - assets.onChoose The callback function invoked after choosing the assets.
99
100
  */
@@ -105,6 +106,7 @@ export default class CKBoxCommand extends Command {
105
106
  language: ckboxConfig.language,
106
107
  tokenUrl: ckboxConfig.tokenUrl,
107
108
  serviceOrigin: ckboxConfig.serviceOrigin,
109
+ forceDemoLabel: ckboxConfig.forceDemoLabel,
108
110
  dialog: {
109
111
  onClose: () => this.fire('ckbox:close')
110
112
  },
@@ -281,8 +283,10 @@ function prepareAssets({ assets, isImageAllowed, isLinkAllowed }) {
281
283
  }
282
284
  /**
283
285
  * Parses the assets attributes into the internal data format.
286
+ *
287
+ * @internal
284
288
  */
285
- function prepareImageAssetAttributes(asset) {
289
+ export function prepareImageAssetAttributes(asset) {
286
290
  const { imageFallbackUrl, imageSources } = getImageUrls(asset.data.imageUrls);
287
291
  const { description, width, height, blurHash } = asset.data.metadata;
288
292
  const imagePlaceholder = blurHashToDataUrl(blurHash);
@@ -1,11 +1,12 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  /**
6
6
  * @module ckbox/ckboxconfig
7
7
  */
8
8
  import type { TokenUrl } from '@ckeditor/ckeditor5-cloud-services';
9
+ import type { ArrayOrItem } from 'ckeditor5/src/utils.js';
9
10
  /**
10
11
  * The configuration of the {@link module:ckbox/ckbox~CKBox CKBox feature}.
11
12
  *
@@ -85,6 +86,27 @@ export interface CKBoxConfig {
85
86
  * If defined, it is an error, when the user has no access to the specified workspace.
86
87
  */
87
88
  defaultUploadWorkspaceId?: string;
89
+ /**
90
+ * Enforces displaying the "Powered by CKBox" link regardless of the CKBox plan used.
91
+ */
92
+ forceDemoLabel?: boolean;
93
+ /**
94
+ * Allows editing images that are not hosted in CKBox service.
95
+ *
96
+ * This configuration option should whitelist URL(s) of images that should be editable.
97
+ * Make sure that allowed image resources have CORS enabled.
98
+ *
99
+ * The image is editable if this option is:
100
+ * * a regular expression and it matches the image URL, or
101
+ * * a custom function that returns `true` for the image URL, or
102
+ * * `'origin'` literal and the image URL is from the same origin, or
103
+ * * an array of the above and the image URL matches one of the array elements.
104
+ *
105
+ * Images hosted in CKBox are always editable.
106
+ *
107
+ * @default []
108
+ */
109
+ allowExternalImagesEditing?: ArrayOrItem<RegExp | 'origin' | ((src: string) => boolean)>;
88
110
  /**
89
111
  * Inserts the unique asset ID as the `data-ckbox-resource-id` attribute. To disable this behavior, set it to `true`.
90
112
  *
@@ -296,4 +318,8 @@ export interface CKBoxRawAssetMetadataDefinition {
296
318
  * The blurhash placeholder value.
297
319
  */
298
320
  blurHash?: string;
321
+ /**
322
+ * The processing status of the asset.
323
+ */
324
+ metadataProcessingStatus?: string;
299
325
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
  export {};
@@ -1,13 +1,10 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
- /**
6
- * @module ckbox/ckboxediting
7
- */
8
- import type { InitializedToken } from '@ckeditor/ckeditor5-cloud-services';
9
- import { Plugin } from 'ckeditor5/src/core';
10
- import CKBoxUploadAdapter from './ckboxuploadadapter';
5
+ import { Plugin } from 'ckeditor5/src/core.js';
6
+ import CKBoxUploadAdapter from './ckboxuploadadapter.js';
7
+ import CKBoxUtils from './ckboxutils.js';
11
8
  /**
12
9
  * The CKBox editing feature. It introduces the {@link module:ckbox/ckboxcommand~CKBoxCommand CKBox command} and
13
10
  * {@link module:ckbox/ckboxuploadadapter~CKBoxUploadAdapter CKBox upload adapter}.
@@ -24,19 +21,15 @@ export default class CKBoxEditing extends Plugin {
24
21
  /**
25
22
  * @inheritDoc
26
23
  */
27
- static get requires(): readonly ["CloudServices", "LinkEditing", "PictureEditing", typeof CKBoxUploadAdapter];
24
+ static get requires(): readonly ["LinkEditing", "PictureEditing", typeof CKBoxUploadAdapter, typeof CKBoxUtils];
28
25
  /**
29
26
  * @inheritDoc
30
27
  */
31
- init(): Promise<void>;
32
- /**
33
- * Returns a token used by the CKBox plugin for communication with the CKBox service.
34
- */
35
- getToken(): InitializedToken;
28
+ init(): void;
36
29
  /**
37
- * Initializes the `ckbox` editor configuration.
30
+ * Checks if at least one image plugin is loaded.
38
31
  */
39
- private _initConfig;
32
+ private _checkImagePlugins;
40
33
  /**
41
34
  * Extends the schema to allow the `ckboxImageId` and `ckboxLinkId` attributes for links and images.
42
35
  */
@@ -1,13 +1,13 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
- import { Plugin } from 'ckeditor5/src/core';
6
- import { Range } from 'ckeditor5/src/engine';
7
- import { CKEditorError, logError } from 'ckeditor5/src/utils';
8
- import CKBoxCommand from './ckboxcommand';
9
- import CKBoxUploadAdapter from './ckboxuploadadapter';
10
- const DEFAULT_CKBOX_THEME_NAME = 'lark';
5
+ import { Plugin } from 'ckeditor5/src/core.js';
6
+ import { Range } from 'ckeditor5/src/engine.js';
7
+ import { logError } from 'ckeditor5/src/utils.js';
8
+ import CKBoxCommand from './ckboxcommand.js';
9
+ import CKBoxUploadAdapter from './ckboxuploadadapter.js';
10
+ import CKBoxUtils from './ckboxutils.js';
11
11
  /**
12
12
  * The CKBox editing feature. It introduces the {@link module:ckbox/ckboxcommand~CKBoxCommand CKBox command} and
13
13
  * {@link module:ckbox/ckboxuploadadapter~CKBoxUploadAdapter CKBox upload adapter}.
@@ -23,12 +23,12 @@ export default class CKBoxEditing extends Plugin {
23
23
  * @inheritDoc
24
24
  */
25
25
  static get requires() {
26
- return ['CloudServices', 'LinkEditing', 'PictureEditing', CKBoxUploadAdapter];
26
+ return ['LinkEditing', 'PictureEditing', CKBoxUploadAdapter, CKBoxUtils];
27
27
  }
28
28
  /**
29
29
  * @inheritDoc
30
30
  */
31
- async init() {
31
+ init() {
32
32
  const editor = this.editor;
33
33
  const hasConfiguration = !!editor.config.get('ckbox');
34
34
  const isLibraryLoaded = !!window.CKBox;
@@ -37,20 +37,7 @@ export default class CKBoxEditing extends Plugin {
37
37
  if (!hasConfiguration && !isLibraryLoaded) {
38
38
  return;
39
39
  }
40
- this._initConfig();
41
- const cloudServicesCore = editor.plugins.get('CloudServicesCore');
42
- const ckboxTokenUrl = editor.config.get('ckbox.tokenUrl');
43
- const cloudServicesTokenUrl = editor.config.get('cloudServices.tokenUrl');
44
- // To avoid fetching the same token twice we need to compare the `ckbox.tokenUrl` and `cloudServices.tokenUrl` values.
45
- // If they are equal, it's enough to take the token generated by the `CloudServices` plugin.
46
- if (ckboxTokenUrl === cloudServicesTokenUrl) {
47
- const cloudServices = editor.plugins.get('CloudServices');
48
- this._token = cloudServices.token;
49
- }
50
- // Otherwise, create a new token manually.
51
- else {
52
- this._token = await cloudServicesCore.createToken(ckboxTokenUrl).init();
53
- }
40
+ this._checkImagePlugins();
54
41
  // Extending the schema, registering converters and applying fixers only make sense if the configuration option to assign
55
42
  // the assets ID with the model elements is enabled.
56
43
  if (!editor.config.get('ckbox.ignoreDataId')) {
@@ -64,45 +51,10 @@ export default class CKBoxEditing extends Plugin {
64
51
  }
65
52
  }
66
53
  /**
67
- * Returns a token used by the CKBox plugin for communication with the CKBox service.
68
- */
69
- getToken() {
70
- return this._token;
71
- }
72
- /**
73
- * Initializes the `ckbox` editor configuration.
54
+ * Checks if at least one image plugin is loaded.
74
55
  */
75
- _initConfig() {
56
+ _checkImagePlugins() {
76
57
  const editor = this.editor;
77
- editor.config.define('ckbox', {
78
- serviceOrigin: 'https://api.ckbox.io',
79
- defaultUploadCategories: null,
80
- ignoreDataId: false,
81
- language: editor.locale.uiLanguage,
82
- theme: DEFAULT_CKBOX_THEME_NAME,
83
- tokenUrl: editor.config.get('cloudServices.tokenUrl')
84
- });
85
- const tokenUrl = editor.config.get('ckbox.tokenUrl');
86
- if (!tokenUrl) {
87
- /**
88
- * The {@link module:ckbox/ckboxconfig~CKBoxConfig#tokenUrl `config.ckbox.tokenUrl`} or the
89
- * {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl `config.cloudServices.tokenUrl`}
90
- * configuration is required for the CKBox plugin.
91
- *
92
- * ```ts
93
- * ClassicEditor.create( document.createElement( 'div' ), {
94
- * ckbox: {
95
- * tokenUrl: "YOUR_TOKEN_URL"
96
- * // ...
97
- * }
98
- * // ...
99
- * } );
100
- * ```
101
- *
102
- * @error ckbox-plugin-missing-token-url
103
- */
104
- throw new CKEditorError('ckbox-plugin-missing-token-url', this);
105
- }
106
58
  if (!editor.plugins.has('ImageBlockEditing') && !editor.plugins.has('ImageInlineEditing')) {
107
59
  /**
108
60
  * The CKBox feature requires one of the following plugins to be loaded to work correctly:
@@ -0,0 +1,97 @@
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/ckboximageeditcommand
7
+ */
8
+ import { Command, type Editor } from 'ckeditor5/src/core.js';
9
+ /**
10
+ * The CKBox edit image command.
11
+ *
12
+ * Opens the CKBox dialog for editing the image.
13
+ */
14
+ export default class CKBoxImageEditCommand extends Command {
15
+ /**
16
+ * Flag indicating whether the command is active, i.e. dialog is open.
17
+ */
18
+ value: boolean;
19
+ /**
20
+ * The DOM element that acts as a mounting point for the CKBox Edit Image dialog.
21
+ */
22
+ private _wrapper;
23
+ /**
24
+ * The states of image processing in progress.
25
+ */
26
+ private _processInProgress;
27
+ /**
28
+ * Determines if the element can be edited.
29
+ */
30
+ private _canEdit;
31
+ /**
32
+ * A wrapper function to prepare mount options. Ensures that at most one preparation is in-flight.
33
+ */
34
+ private _prepareOptions;
35
+ /**
36
+ * @inheritDoc
37
+ */
38
+ constructor(editor: Editor);
39
+ /**
40
+ * @inheritDoc
41
+ */
42
+ refresh(): void;
43
+ /**
44
+ * Opens the CKBox Image Editor dialog for editing the image.
45
+ */
46
+ execute(): void;
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ destroy(): void;
51
+ /**
52
+ * Indicates if the CKBox Image Editor dialog is already opened.
53
+ */
54
+ private _getValue;
55
+ /**
56
+ * Creates the options object for the CKBox Image Editor dialog.
57
+ */
58
+ private _prepareOptionsAbortable;
59
+ /**
60
+ * Initializes event lister for an event of removing an image.
61
+ */
62
+ private _prepareListeners;
63
+ /**
64
+ * Gets processing states of images that have been deleted in the mean time.
65
+ */
66
+ private _getProcessingStatesOfDeletedImages;
67
+ private _checkIfElementIsBeingProcessed;
68
+ /**
69
+ * Closes the CKBox Image Editor dialog.
70
+ */
71
+ private _handleImageEditorClose;
72
+ /**
73
+ * Save edited image. In case server respond with "success" replace with edited image,
74
+ * otherwise show notification error.
75
+ */
76
+ private _handleImageEditorSave;
77
+ /**
78
+ * Get asset's status on server. If server responds with "success" status then
79
+ * image is already proceeded and ready for saving.
80
+ */
81
+ private _getAssetStatusFromServer;
82
+ /**
83
+ * Waits for an asset to be processed.
84
+ * It retries retrieving asset status from the server in case of failure.
85
+ */
86
+ private _waitForAssetProcessed;
87
+ /**
88
+ * Shows processing indicator while image is processing.
89
+ *
90
+ * @param asset Data about certain asset.
91
+ */
92
+ private _showImageProcessingIndicator;
93
+ /**
94
+ * Replace the edited image with the new one.
95
+ */
96
+ private _replaceImage;
97
+ }