@ckeditor/ckeditor5-ckbox 47.6.1 → 48.0.0-alpha.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.
Files changed (186) hide show
  1. package/LICENSE.md +1 -1
  2. package/ckeditor5-metadata.json +4 -4
  3. package/{src → dist}/ckbox.d.ts +1 -1
  4. package/{src → dist}/ckboxcommand.d.ts +1 -1
  5. package/{src → dist}/ckboxconfig.d.ts +1 -1
  6. package/{src → dist}/ckboxediting.d.ts +4 -2
  7. package/{src → dist}/ckboximageedit/ckboximageeditcommand.d.ts +1 -1
  8. package/{src → dist}/ckboximageedit/ckboximageeditediting.d.ts +4 -3
  9. package/{src → dist}/ckboximageedit/ckboximageeditui.d.ts +1 -1
  10. package/{src → dist}/ckboximageedit/utils.d.ts +1 -1
  11. package/{src → dist}/ckboximageedit.d.ts +1 -1
  12. package/{src → dist}/ckboxui.d.ts +1 -1
  13. package/{src → dist}/ckboxuploadadapter.d.ts +4 -3
  14. package/{src → dist}/ckboxutils.d.ts +3 -3
  15. package/dist/index-editor.css +24 -28
  16. package/dist/index.css +25 -36
  17. package/dist/index.css.map +1 -1
  18. package/dist/index.js +14 -10
  19. package/dist/index.js.map +1 -1
  20. package/package.json +28 -51
  21. package/build/ckbox.js +0 -5
  22. package/build/translations/af.js +0 -1
  23. package/build/translations/ar.js +0 -1
  24. package/build/translations/ast.js +0 -1
  25. package/build/translations/az.js +0 -1
  26. package/build/translations/be.js +0 -1
  27. package/build/translations/bg.js +0 -1
  28. package/build/translations/bn.js +0 -1
  29. package/build/translations/bs.js +0 -1
  30. package/build/translations/ca.js +0 -1
  31. package/build/translations/cs.js +0 -1
  32. package/build/translations/da.js +0 -1
  33. package/build/translations/de-ch.js +0 -1
  34. package/build/translations/de.js +0 -1
  35. package/build/translations/el.js +0 -1
  36. package/build/translations/en-au.js +0 -1
  37. package/build/translations/en-gb.js +0 -1
  38. package/build/translations/eo.js +0 -1
  39. package/build/translations/es-co.js +0 -1
  40. package/build/translations/es.js +0 -1
  41. package/build/translations/et.js +0 -1
  42. package/build/translations/eu.js +0 -1
  43. package/build/translations/fa.js +0 -1
  44. package/build/translations/fi.js +0 -1
  45. package/build/translations/fr.js +0 -1
  46. package/build/translations/gl.js +0 -1
  47. package/build/translations/gu.js +0 -1
  48. package/build/translations/he.js +0 -1
  49. package/build/translations/hi.js +0 -1
  50. package/build/translations/hr.js +0 -1
  51. package/build/translations/hu.js +0 -1
  52. package/build/translations/hy.js +0 -1
  53. package/build/translations/id.js +0 -1
  54. package/build/translations/it.js +0 -1
  55. package/build/translations/ja.js +0 -1
  56. package/build/translations/jv.js +0 -1
  57. package/build/translations/kk.js +0 -1
  58. package/build/translations/km.js +0 -1
  59. package/build/translations/kn.js +0 -1
  60. package/build/translations/ko.js +0 -1
  61. package/build/translations/ku.js +0 -1
  62. package/build/translations/lt.js +0 -1
  63. package/build/translations/lv.js +0 -1
  64. package/build/translations/ms.js +0 -1
  65. package/build/translations/nb.js +0 -1
  66. package/build/translations/ne.js +0 -1
  67. package/build/translations/nl.js +0 -1
  68. package/build/translations/no.js +0 -1
  69. package/build/translations/oc.js +0 -1
  70. package/build/translations/pl.js +0 -1
  71. package/build/translations/pt-br.js +0 -1
  72. package/build/translations/pt.js +0 -1
  73. package/build/translations/ro.js +0 -1
  74. package/build/translations/ru.js +0 -1
  75. package/build/translations/si.js +0 -1
  76. package/build/translations/sk.js +0 -1
  77. package/build/translations/sl.js +0 -1
  78. package/build/translations/sq.js +0 -1
  79. package/build/translations/sr-latn.js +0 -1
  80. package/build/translations/sr.js +0 -1
  81. package/build/translations/sv.js +0 -1
  82. package/build/translations/th.js +0 -1
  83. package/build/translations/ti.js +0 -1
  84. package/build/translations/tk.js +0 -1
  85. package/build/translations/tr.js +0 -1
  86. package/build/translations/tt.js +0 -1
  87. package/build/translations/ug.js +0 -1
  88. package/build/translations/uk.js +0 -1
  89. package/build/translations/ur.js +0 -1
  90. package/build/translations/uz.js +0 -1
  91. package/build/translations/vi.js +0 -1
  92. package/build/translations/zh-cn.js +0 -1
  93. package/build/translations/zh.js +0 -1
  94. package/lang/contexts.json +0 -10
  95. package/lang/translations/af.po +0 -44
  96. package/lang/translations/ar.po +0 -44
  97. package/lang/translations/ast.po +0 -44
  98. package/lang/translations/az.po +0 -44
  99. package/lang/translations/be.po +0 -44
  100. package/lang/translations/bg.po +0 -44
  101. package/lang/translations/bn.po +0 -44
  102. package/lang/translations/bs.po +0 -44
  103. package/lang/translations/ca.po +0 -44
  104. package/lang/translations/cs.po +0 -44
  105. package/lang/translations/da.po +0 -44
  106. package/lang/translations/de-ch.po +0 -44
  107. package/lang/translations/de.po +0 -44
  108. package/lang/translations/el.po +0 -44
  109. package/lang/translations/en-au.po +0 -44
  110. package/lang/translations/en-gb.po +0 -44
  111. package/lang/translations/en.po +0 -44
  112. package/lang/translations/eo.po +0 -44
  113. package/lang/translations/es-co.po +0 -44
  114. package/lang/translations/es.po +0 -44
  115. package/lang/translations/et.po +0 -44
  116. package/lang/translations/eu.po +0 -44
  117. package/lang/translations/fa.po +0 -44
  118. package/lang/translations/fi.po +0 -44
  119. package/lang/translations/fr.po +0 -44
  120. package/lang/translations/gl.po +0 -44
  121. package/lang/translations/gu.po +0 -44
  122. package/lang/translations/he.po +0 -44
  123. package/lang/translations/hi.po +0 -44
  124. package/lang/translations/hr.po +0 -44
  125. package/lang/translations/hu.po +0 -44
  126. package/lang/translations/hy.po +0 -44
  127. package/lang/translations/id.po +0 -44
  128. package/lang/translations/it.po +0 -44
  129. package/lang/translations/ja.po +0 -44
  130. package/lang/translations/jv.po +0 -44
  131. package/lang/translations/kk.po +0 -44
  132. package/lang/translations/km.po +0 -44
  133. package/lang/translations/kn.po +0 -44
  134. package/lang/translations/ko.po +0 -44
  135. package/lang/translations/ku.po +0 -44
  136. package/lang/translations/lt.po +0 -44
  137. package/lang/translations/lv.po +0 -44
  138. package/lang/translations/ms.po +0 -44
  139. package/lang/translations/nb.po +0 -44
  140. package/lang/translations/ne.po +0 -44
  141. package/lang/translations/nl.po +0 -44
  142. package/lang/translations/no.po +0 -44
  143. package/lang/translations/oc.po +0 -44
  144. package/lang/translations/pl.po +0 -44
  145. package/lang/translations/pt-br.po +0 -44
  146. package/lang/translations/pt.po +0 -44
  147. package/lang/translations/ro.po +0 -44
  148. package/lang/translations/ru.po +0 -44
  149. package/lang/translations/si.po +0 -44
  150. package/lang/translations/sk.po +0 -44
  151. package/lang/translations/sl.po +0 -44
  152. package/lang/translations/sq.po +0 -44
  153. package/lang/translations/sr-latn.po +0 -44
  154. package/lang/translations/sr.po +0 -44
  155. package/lang/translations/sv.po +0 -44
  156. package/lang/translations/th.po +0 -44
  157. package/lang/translations/ti.po +0 -44
  158. package/lang/translations/tk.po +0 -44
  159. package/lang/translations/tr.po +0 -44
  160. package/lang/translations/tt.po +0 -44
  161. package/lang/translations/ug.po +0 -44
  162. package/lang/translations/uk.po +0 -44
  163. package/lang/translations/ur.po +0 -44
  164. package/lang/translations/uz.po +0 -44
  165. package/lang/translations/vi.po +0 -44
  166. package/lang/translations/zh-cn.po +0 -44
  167. package/lang/translations/zh.po +0 -44
  168. package/src/augmentation.js +0 -5
  169. package/src/ckbox.js +0 -43
  170. package/src/ckboxcommand.js +0 -382
  171. package/src/ckboxconfig.js +0 -5
  172. package/src/ckboxediting.js +0 -388
  173. package/src/ckboximageedit/ckboximageeditcommand.js +0 -318
  174. package/src/ckboximageedit/ckboximageeditediting.js +0 -42
  175. package/src/ckboximageedit/ckboximageeditui.js +0 -57
  176. package/src/ckboximageedit/utils.js +0 -48
  177. package/src/ckboximageedit.js +0 -34
  178. package/src/ckboxui.js +0 -139
  179. package/src/ckboxuploadadapter.js +0 -159
  180. package/src/ckboxutils.js +0 -215
  181. package/src/index.js +0 -21
  182. package/src/utils.js +0 -188
  183. package/theme/ckboximageedit.css +0 -53
  184. /package/{src → dist}/augmentation.d.ts +0 -0
  185. /package/{src → dist}/index.d.ts +0 -0
  186. /package/{src → dist}/utils.d.ts +0 -0
@@ -1,44 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: vi\n"
11
- "Plural-Forms: nplurals=1; plural=0;\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "A toolbar button tooltip for opening the file browser that allows inserting an image or a file to the editor."
15
- msgid "Open file manager"
16
- msgstr "Mở trình quản lý tệp"
17
-
18
- msgctxt "A message is displayed when CKEditor 5 cannot associate an image with any of the categories defined in CKBox while uploading an asset."
19
- msgid "Cannot determine a category for the uploaded file."
20
- msgstr "Không thể xác định danh mục cho tệp được tải lên."
21
-
22
- msgctxt "A message is displayed when the user is not authorised to access the CKBox workspace configured as default one."
23
- msgid "Cannot access default workspace."
24
- msgstr "Không thể truy cập vào không gian làm việc mặc định."
25
-
26
- msgctxt "The title of the notification displayed when there is no permission to edit assets."
27
- msgid "You have no image editing permissions."
28
- msgstr "Bạn không có quyền chỉnh sửa ảnh."
29
-
30
- msgctxt "Image toolbar button tooltip for opening a dialog to manipulate the image."
31
- msgid "Edit image"
32
- msgstr "Chỉnh sửa hình ảnh"
33
-
34
- msgctxt "A message stating that image editing is in progress."
35
- msgid "Processing the edited image."
36
- msgstr "Xử lý hình ảnh đã chỉnh sửa."
37
-
38
- msgctxt "A message is displayed when the server fails to process an image or doesn't respond."
39
- msgid "Server failed to process the image."
40
- msgstr "Máy chủ không thể xử lý hình ảnh."
41
-
42
- msgctxt "A message is displayed when category of the image user wants to edit can't be determined."
43
- msgid "Failed to determine category of edited image."
44
- msgstr "Không thể xác định danh mục hình ảnh đã chỉnh sửa."
@@ -1,44 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: zh_CN\n"
11
- "Plural-Forms: nplurals=1; plural=0;\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "A toolbar button tooltip for opening the file browser that allows inserting an image or a file to the editor."
15
- msgid "Open file manager"
16
- msgstr "打开文件管理器"
17
-
18
- msgctxt "A message is displayed when CKEditor 5 cannot associate an image with any of the categories defined in CKBox while uploading an asset."
19
- msgid "Cannot determine a category for the uploaded file."
20
- msgstr "无法确定上传文件的类别。"
21
-
22
- msgctxt "A message is displayed when the user is not authorised to access the CKBox workspace configured as default one."
23
- msgid "Cannot access default workspace."
24
- msgstr "无法访问默认工作区"
25
-
26
- msgctxt "The title of the notification displayed when there is no permission to edit assets."
27
- msgid "You have no image editing permissions."
28
- msgstr "您没有编辑图片的权限。"
29
-
30
- msgctxt "Image toolbar button tooltip for opening a dialog to manipulate the image."
31
- msgid "Edit image"
32
- msgstr "编辑图片"
33
-
34
- msgctxt "A message stating that image editing is in progress."
35
- msgid "Processing the edited image."
36
- msgstr "正在处理已编辑的图片。"
37
-
38
- msgctxt "A message is displayed when the server fails to process an image or doesn't respond."
39
- msgid "Server failed to process the image."
40
- msgstr "服务器未能处理图片。"
41
-
42
- msgctxt "A message is displayed when category of the image user wants to edit can't be determined."
43
- msgid "Failed to determine category of edited image."
44
- msgstr "未能确定已编辑图片的类别。"
@@ -1,44 +0,0 @@
1
- # Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
2
- #
3
- # Want to contribute to this file? Submit your changes via a GitHub Pull Request.
4
- #
5
- # Check out the official contributor's guide:
6
- # https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
7
- #
8
- msgid ""
9
- msgstr ""
10
- "Language: zh_TW\n"
11
- "Plural-Forms: nplurals=1; plural=0;\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
-
14
- msgctxt "A toolbar button tooltip for opening the file browser that allows inserting an image or a file to the editor."
15
- msgid "Open file manager"
16
- msgstr "開啟檔案管理程式"
17
-
18
- msgctxt "A message is displayed when CKEditor 5 cannot associate an image with any of the categories defined in CKBox while uploading an asset."
19
- msgid "Cannot determine a category for the uploaded file."
20
- msgstr "無法確定上傳檔案的分類。"
21
-
22
- msgctxt "A message is displayed when the user is not authorised to access the CKBox workspace configured as default one."
23
- msgid "Cannot access default workspace."
24
- msgstr "無法存取預設工作區。"
25
-
26
- msgctxt "The title of the notification displayed when there is no permission to edit assets."
27
- msgid "You have no image editing permissions."
28
- msgstr "您沒有圖片編輯權限。"
29
-
30
- msgctxt "Image toolbar button tooltip for opening a dialog to manipulate the image."
31
- msgid "Edit image"
32
- msgstr "編輯圖片"
33
-
34
- msgctxt "A message stating that image editing is in progress."
35
- msgid "Processing the edited image."
36
- msgstr "正在處理已編輯的圖片。"
37
-
38
- msgctxt "A message is displayed when the server fails to process an image or doesn't respond."
39
- msgid "Server failed to process the image."
40
- msgstr "伺服器無法處理該圖片。"
41
-
42
- msgctxt "A message is displayed when category of the image user wants to edit can't be determined."
43
- msgid "Failed to determine category of edited image."
44
- msgstr "無法判斷已編輯圖片的類別。"
@@ -1,5 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- export {};
package/src/ckbox.js DELETED
@@ -1,43 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module ckbox/ckbox
7
- */
8
- import { Plugin } from 'ckeditor5/src/core.js';
9
- import { CKBoxUI } from './ckboxui.js';
10
- import { CKBoxEditing } from './ckboxediting.js';
11
- /**
12
- * The CKBox feature, a bridge between the CKEditor 5 WYSIWYG editor and the CKBox file manager and uploader.
13
- *
14
- * This is a "glue" plugin which enables:
15
- *
16
- * * {@link module:ckbox/ckboxediting~CKBoxEditing},
17
- * * {@link module:ckbox/ckboxui~CKBoxUI},
18
- *
19
- * See the {@glink features/file-management/ckbox CKBox integration} guide to learn how to configure and use this feature.
20
- *
21
- * Check out the {@glink features/images/image-upload/image-upload Image upload} guide to learn about other ways to upload
22
- * images into CKEditor 5.
23
- */
24
- export class CKBox extends Plugin {
25
- /**
26
- * @inheritDoc
27
- */
28
- static get pluginName() {
29
- return 'CKBox';
30
- }
31
- /**
32
- * @inheritDoc
33
- */
34
- static get isOfficialPlugin() {
35
- return true;
36
- }
37
- /**
38
- * @inheritDoc
39
- */
40
- static get requires() {
41
- return [CKBoxEditing, CKBoxUI];
42
- }
43
- }
@@ -1,382 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
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
- // Defines the waiting time (in milliseconds) for inserting the chosen asset into the model. The chosen asset is temporarily stored in the
9
- // `CKBoxCommand#_chosenAssets` and it is removed from there automatically after this time. See `CKBoxCommand#_chosenAssets` for more
10
- // details.
11
- const ASSET_INSERTION_WAIT_TIMEOUT = 1000;
12
- /**
13
- * The CKBox command. It is used by the {@link module:ckbox/ckboxediting~CKBoxEditing CKBox editing feature} to open the CKBox file manager.
14
- * The file manager allows inserting an image or a link to a file into the editor content.
15
- *
16
- * ```ts
17
- * editor.execute( 'ckbox' );
18
- * ```
19
- *
20
- * **Note:** This command uses other features to perform the following tasks:
21
- * - To insert images it uses the {@link module:image/image/insertimagecommand~InsertImageCommand 'insertImage'} command from the
22
- * {@link module:image/image~Image Image feature}.
23
- * - To insert links to other files it uses the {@link module:link/linkcommand~LinkCommand 'link'} command from the
24
- * {@link module:link/link~Link Link feature}.
25
- */
26
- export 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
- /**
50
- * @inheritDoc
51
- */
52
- constructor(editor) {
53
- super(editor);
54
- this._initListeners();
55
- }
56
- /**
57
- * @inheritDoc
58
- */
59
- refresh() {
60
- this.value = this._getValue();
61
- this.isEnabled = this._checkEnabled();
62
- }
63
- /**
64
- * @inheritDoc
65
- */
66
- execute() {
67
- this.fire('ckbox:open');
68
- }
69
- /**
70
- * Indicates if the CKBox dialog is already opened.
71
- *
72
- * @protected
73
- * @returns {Boolean}
74
- */
75
- _getValue() {
76
- return this._wrapper !== null;
77
- }
78
- /**
79
- * Checks whether the command can be enabled in the current context.
80
- */
81
- _checkEnabled() {
82
- const imageCommand = this.editor.commands.get('insertImage');
83
- const linkCommand = this.editor.commands.get('link');
84
- if (!imageCommand.isEnabled && !linkCommand.isEnabled) {
85
- return false;
86
- }
87
- return true;
88
- }
89
- /**
90
- * Creates the options object for the CKBox dialog.
91
- *
92
- * @returns The object with properties:
93
- * - theme The theme for CKBox dialog.
94
- * - language The language for CKBox dialog.
95
- * - tokenUrl The token endpoint URL.
96
- * - serviceOrigin The base URL of the API service.
97
- * - forceDemoLabel Whether to force "Powered by CKBox" link.
98
- * - assets.onChoose The callback function invoked after choosing the assets.
99
- * - dialog.onClose The callback function invoked after closing the CKBox dialog.
100
- * - dialog.width The dialog width in pixels.
101
- * - dialog.height The dialog height in pixels.
102
- * - categories.icons Allows setting custom icons for categories.
103
- * - view.openLastView Sets if the last view visited by the user will be reopened
104
- * on the next startup.
105
- * - view.startupFolderId Sets the ID of the folder that will be opened on startup.
106
- * - view.startupCategoryId Sets the ID of the category that will be opened on startup.
107
- * - view.hideMaximizeButton Sets whether to hide the ‘Maximize’ button.
108
- * - view.componentsHideTimeout Sets timeout after which upload components are hidden
109
- * after completed upload.
110
- * - view.dialogMinimizeTimeout Sets timeout after which upload dialog is minimized
111
- * after completed upload.
112
- */
113
- _prepareOptions() {
114
- const editor = this.editor;
115
- const ckboxConfig = editor.config.get('ckbox');
116
- const dialog = ckboxConfig.dialog;
117
- const categories = ckboxConfig.categories;
118
- const view = ckboxConfig.view;
119
- const upload = ckboxConfig.upload;
120
- return {
121
- theme: ckboxConfig.theme,
122
- language: ckboxConfig.language,
123
- tokenUrl: ckboxConfig.tokenUrl,
124
- serviceOrigin: ckboxConfig.serviceOrigin,
125
- forceDemoLabel: ckboxConfig.forceDemoLabel,
126
- choosableFileExtensions: ckboxConfig.choosableFileExtensions,
127
- assets: {
128
- onChoose: (assets) => this.fire('ckbox:choose', assets)
129
- },
130
- dialog: {
131
- onClose: () => this.fire('ckbox:close'),
132
- width: dialog && dialog.width,
133
- height: dialog && dialog.height
134
- },
135
- categories: categories && {
136
- icons: categories.icons
137
- },
138
- view: view && {
139
- openLastView: view.openLastView,
140
- startupFolderId: view.startupFolderId,
141
- startupCategoryId: view.startupCategoryId,
142
- hideMaximizeButton: view.hideMaximizeButton
143
- },
144
- upload: upload && {
145
- componentsHideTimeout: upload.componentsHideTimeout,
146
- dialogMinimizeTimeout: upload.dialogMinimizeTimeout
147
- }
148
- };
149
- }
150
- /**
151
- * Initializes various event listeners for the `ckbox:*` events, because all functionality of the `ckbox` command is event-based.
152
- */
153
- _initListeners() {
154
- const editor = this.editor;
155
- const model = editor.model;
156
- const shouldInsertDataId = !editor.config.get('ckbox.ignoreDataId');
157
- const downloadableFilesConfig = editor.config.get('ckbox.downloadableFiles');
158
- // Refresh the command after firing the `ckbox:*` event.
159
- this.on('ckbox', () => {
160
- this.refresh();
161
- }, { priority: 'low' });
162
- // Handle opening of the CKBox dialog.
163
- this.on('ckbox:open', () => {
164
- if (!this.isEnabled || this.value) {
165
- return;
166
- }
167
- this._wrapper = createElement(document, 'div', { class: 'ck ckbox-wrapper' });
168
- document.body.appendChild(this._wrapper);
169
- window.CKBox.mount(this._wrapper, this._prepareOptions());
170
- });
171
- // Handle closing of the CKBox dialog.
172
- this.on('ckbox:close', () => {
173
- if (!this.value) {
174
- return;
175
- }
176
- this._wrapper.remove();
177
- this._wrapper = null;
178
- editor.editing.view.focus();
179
- });
180
- // Handle choosing the assets.
181
- this.on('ckbox:choose', (evt, assets) => {
182
- if (!this.isEnabled) {
183
- return;
184
- }
185
- const imageCommand = editor.commands.get('insertImage');
186
- const linkCommand = editor.commands.get('link');
187
- const assetsToProcess = prepareAssets({
188
- assets,
189
- downloadableFilesConfig,
190
- isImageAllowed: imageCommand.isEnabled,
191
- isLinkAllowed: linkCommand.isEnabled
192
- });
193
- const assetsCount = assetsToProcess.length;
194
- if (assetsCount === 0) {
195
- return;
196
- }
197
- // All assets are inserted in one undo step.
198
- model.change(writer => {
199
- for (const asset of assetsToProcess) {
200
- const isLastAsset = asset === assetsToProcess[assetsCount - 1];
201
- const isSingleAsset = assetsCount === 1;
202
- this._insertAsset(asset, isLastAsset, writer, isSingleAsset);
203
- // If asset ID must be set for the inserted model element, store the asset temporarily and remove it automatically
204
- // after the timeout.
205
- if (shouldInsertDataId) {
206
- setTimeout(() => this._chosenAssets.delete(asset), ASSET_INSERTION_WAIT_TIMEOUT);
207
- this._chosenAssets.add(asset);
208
- }
209
- }
210
- });
211
- editor.editing.view.focus();
212
- });
213
- // Clean up after the editor is destroyed.
214
- this.listenTo(editor, 'destroy', () => {
215
- this.fire('ckbox:close');
216
- this._chosenAssets.clear();
217
- });
218
- }
219
- /**
220
- * Inserts the asset into the model.
221
- *
222
- * @param asset The asset to be inserted.
223
- * @param isLastAsset Indicates if the current asset is the last one from the chosen set.
224
- * @param writer An instance of the model writer.
225
- * @param isSingleAsset It's true when only one asset is processed.
226
- */
227
- _insertAsset(asset, isLastAsset, writer, isSingleAsset) {
228
- const editor = this.editor;
229
- const model = editor.model;
230
- const selection = model.document.selection;
231
- // Remove the `linkHref` attribute to not affect the asset to be inserted.
232
- writer.removeSelectionAttribute('linkHref');
233
- if (asset.type === 'image') {
234
- this._insertImage(asset);
235
- }
236
- else {
237
- this._insertLink(asset, writer, isSingleAsset);
238
- }
239
- // Except for the last chosen asset, move the selection to the end of the current range to avoid overwriting other, already
240
- // inserted assets.
241
- if (!isLastAsset) {
242
- writer.setSelection(selection.getLastPosition());
243
- }
244
- }
245
- /**
246
- * Inserts the image by calling the `insertImage` command.
247
- *
248
- * @param asset The asset to be inserted.
249
- */
250
- _insertImage(asset) {
251
- const editor = this.editor;
252
- const { imageFallbackUrl, imageSources, imageTextAlternative, imageWidth, imageHeight, imagePlaceholder } = asset.attributes;
253
- editor.execute('insertImage', {
254
- source: {
255
- src: imageFallbackUrl,
256
- sources: imageSources,
257
- alt: imageTextAlternative,
258
- width: imageWidth,
259
- height: imageHeight,
260
- ...(imagePlaceholder ? { placeholder: imagePlaceholder } : null)
261
- }
262
- });
263
- }
264
- /**
265
- * Inserts the link to the asset by calling the `link` command.
266
- *
267
- * @param asset The asset to be inserted.
268
- * @param writer An instance of the model writer.
269
- * @param isSingleAsset It's true when only one asset is processed.
270
- */
271
- _insertLink(asset, writer, isSingleAsset) {
272
- const editor = this.editor;
273
- const model = editor.model;
274
- const selection = model.document.selection;
275
- const { linkName, linkHref } = asset.attributes;
276
- // If the selection is collapsed, insert the asset name as the link label and select it.
277
- if (selection.isCollapsed) {
278
- const selectionAttributes = toMap(selection.getAttributes());
279
- const textNode = writer.createText(linkName, selectionAttributes);
280
- if (!isSingleAsset) {
281
- const selectionLastPosition = selection.getLastPosition();
282
- const parentElement = selectionLastPosition.parent;
283
- // Insert new `paragraph` when selection is not in an empty `paragraph`.
284
- if (!(parentElement.name === 'paragraph' && parentElement.isEmpty)) {
285
- editor.execute('insertParagraph', {
286
- position: selectionLastPosition
287
- });
288
- }
289
- const range = model.insertContent(textNode);
290
- writer.setSelection(range);
291
- editor.execute('link', linkHref);
292
- return;
293
- }
294
- const range = model.insertContent(textNode);
295
- writer.setSelection(range);
296
- }
297
- editor.execute('link', linkHref);
298
- }
299
- }
300
- /**
301
- * Parses the chosen assets into the internal data format. Filters out chosen assets that are not allowed.
302
- */
303
- function prepareAssets({ downloadableFilesConfig, assets, isImageAllowed, isLinkAllowed }) {
304
- return assets
305
- .map(asset => isImage(asset) ?
306
- {
307
- id: asset.data.id,
308
- type: 'image',
309
- attributes: prepareImageAssetAttributes(asset)
310
- } :
311
- {
312
- id: asset.data.id,
313
- type: 'link',
314
- attributes: prepareLinkAssetAttributes(asset, downloadableFilesConfig)
315
- })
316
- .filter(asset => asset.type === 'image' ? isImageAllowed : isLinkAllowed);
317
- }
318
- /**
319
- * Parses the assets attributes into the internal data format.
320
- *
321
- * @internal
322
- */
323
- export function prepareImageAssetAttributes(asset) {
324
- const { imageFallbackUrl, imageSources } = getImageUrls(asset.data.imageUrls);
325
- const { description, width, height, blurHash } = asset.data.metadata;
326
- const imagePlaceholder = blurHashToDataUrl(blurHash);
327
- return {
328
- imageFallbackUrl,
329
- imageSources,
330
- imageTextAlternative: description || '',
331
- imageWidth: width,
332
- imageHeight: height,
333
- ...(imagePlaceholder ? { imagePlaceholder } : null)
334
- };
335
- }
336
- /**
337
- * Parses the assets attributes into the internal data format.
338
- *
339
- * @param asset The asset to prepare the attributes for.
340
- * @param config The CKBox download asset configuration.
341
- */
342
- function prepareLinkAssetAttributes(asset, config) {
343
- return {
344
- linkName: asset.data.name,
345
- linkHref: getAssetUrl(asset, config)
346
- };
347
- }
348
- /**
349
- * Checks whether the asset is an image.
350
- */
351
- function isImage(asset) {
352
- const metadata = asset.data.metadata;
353
- if (!metadata) {
354
- return false;
355
- }
356
- return metadata.width && metadata.height;
357
- }
358
- /**
359
- * Creates the URL for the asset.
360
- *
361
- * @param asset The asset to create the URL for.
362
- * @param config The CKBox download asset configuration.
363
- */
364
- function getAssetUrl(asset, config) {
365
- const url = new URL(asset.data.url);
366
- if (isDownloadableAsset(asset, config)) {
367
- url.searchParams.set('download', 'true');
368
- }
369
- return url.toString();
370
- }
371
- /**
372
- * Determines if download should be enabled for given asset based on configuration.
373
- *
374
- * @param asset The asset to check.
375
- * @param config The CKBox download asset configuration.
376
- */
377
- function isDownloadableAsset(asset, config) {
378
- if (typeof config === 'function') {
379
- return config(asset);
380
- }
381
- return true;
382
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- export {};