@ckeditor/ckeditor5-ckbox 42.0.2 → 43.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 (219) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/build/ckbox.js +2 -2
  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/dist/ckboxcommand.d.ts +13 -1
  53. package/dist/ckboxconfig.d.ts +105 -0
  54. package/dist/ckboxediting.d.ts +7 -4
  55. package/dist/ckboxutils.d.ts +3 -3
  56. package/dist/index.js +90 -25
  57. package/dist/index.js.map +1 -1
  58. package/dist/translations/ar.js +1 -1
  59. package/dist/translations/ar.umd.js +1 -1
  60. package/dist/translations/az.js +1 -1
  61. package/dist/translations/az.umd.js +1 -1
  62. package/dist/translations/bg.js +1 -1
  63. package/dist/translations/bg.umd.js +1 -1
  64. package/dist/translations/bn.js +1 -1
  65. package/dist/translations/bn.umd.js +1 -1
  66. package/dist/translations/ca.js +1 -1
  67. package/dist/translations/ca.umd.js +1 -1
  68. package/dist/translations/cs.js +1 -1
  69. package/dist/translations/cs.umd.js +1 -1
  70. package/dist/translations/da.js +1 -1
  71. package/dist/translations/da.umd.js +1 -1
  72. package/dist/translations/de.js +1 -1
  73. package/dist/translations/de.umd.js +1 -1
  74. package/dist/translations/el.js +1 -1
  75. package/dist/translations/el.umd.js +1 -1
  76. package/dist/translations/en-au.js +1 -1
  77. package/dist/translations/en-au.umd.js +1 -1
  78. package/dist/translations/en.js +1 -1
  79. package/dist/translations/en.umd.js +1 -1
  80. package/dist/translations/es-co.js +1 -1
  81. package/dist/translations/es-co.umd.js +1 -1
  82. package/dist/translations/es.js +1 -1
  83. package/dist/translations/es.umd.js +1 -1
  84. package/dist/translations/et.js +1 -1
  85. package/dist/translations/et.umd.js +1 -1
  86. package/dist/translations/fa.js +1 -1
  87. package/dist/translations/fa.umd.js +1 -1
  88. package/dist/translations/fi.js +1 -1
  89. package/dist/translations/fi.umd.js +1 -1
  90. package/dist/translations/fr.js +1 -1
  91. package/dist/translations/fr.umd.js +1 -1
  92. package/dist/translations/gl.js +1 -1
  93. package/dist/translations/gl.umd.js +1 -1
  94. package/dist/translations/he.js +1 -1
  95. package/dist/translations/he.umd.js +1 -1
  96. package/dist/translations/hi.js +1 -1
  97. package/dist/translations/hi.umd.js +1 -1
  98. package/dist/translations/hr.js +1 -1
  99. package/dist/translations/hr.umd.js +1 -1
  100. package/dist/translations/hu.js +1 -1
  101. package/dist/translations/hu.umd.js +1 -1
  102. package/dist/translations/id.js +1 -1
  103. package/dist/translations/id.umd.js +1 -1
  104. package/dist/translations/it.js +1 -1
  105. package/dist/translations/it.umd.js +1 -1
  106. package/dist/translations/ja.js +1 -1
  107. package/dist/translations/ja.umd.js +1 -1
  108. package/dist/translations/ko.js +1 -1
  109. package/dist/translations/ko.umd.js +1 -1
  110. package/dist/translations/lt.js +1 -1
  111. package/dist/translations/lt.umd.js +1 -1
  112. package/dist/translations/lv.js +1 -1
  113. package/dist/translations/lv.umd.js +1 -1
  114. package/dist/translations/ms.js +1 -1
  115. package/dist/translations/ms.umd.js +1 -1
  116. package/dist/translations/nl.js +1 -1
  117. package/dist/translations/nl.umd.js +1 -1
  118. package/dist/translations/no.js +1 -1
  119. package/dist/translations/no.umd.js +1 -1
  120. package/dist/translations/pl.js +1 -1
  121. package/dist/translations/pl.umd.js +1 -1
  122. package/dist/translations/pt-br.js +1 -1
  123. package/dist/translations/pt-br.umd.js +1 -1
  124. package/dist/translations/pt.js +1 -1
  125. package/dist/translations/pt.umd.js +1 -1
  126. package/dist/translations/ro.js +1 -1
  127. package/dist/translations/ro.umd.js +1 -1
  128. package/dist/translations/ru.js +1 -1
  129. package/dist/translations/ru.umd.js +1 -1
  130. package/dist/translations/sk.js +1 -1
  131. package/dist/translations/sk.umd.js +1 -1
  132. package/dist/translations/sq.js +1 -1
  133. package/dist/translations/sq.umd.js +1 -1
  134. package/dist/translations/sr-latn.js +1 -1
  135. package/dist/translations/sr-latn.umd.js +1 -1
  136. package/dist/translations/sr.js +1 -1
  137. package/dist/translations/sr.umd.js +1 -1
  138. package/dist/translations/sv.js +1 -1
  139. package/dist/translations/sv.umd.js +1 -1
  140. package/dist/translations/th.js +1 -1
  141. package/dist/translations/th.umd.js +1 -1
  142. package/dist/translations/tr.js +1 -1
  143. package/dist/translations/tr.umd.js +1 -1
  144. package/dist/translations/ug.js +1 -1
  145. package/dist/translations/ug.umd.js +1 -1
  146. package/dist/translations/uk.js +1 -1
  147. package/dist/translations/uk.umd.js +1 -1
  148. package/dist/translations/ur.js +1 -1
  149. package/dist/translations/ur.umd.js +1 -1
  150. package/dist/translations/uz.js +1 -1
  151. package/dist/translations/uz.umd.js +1 -1
  152. package/dist/translations/vi.js +1 -1
  153. package/dist/translations/vi.umd.js +1 -1
  154. package/dist/translations/zh-cn.js +1 -1
  155. package/dist/translations/zh-cn.umd.js +1 -1
  156. package/dist/translations/zh.js +1 -1
  157. package/dist/translations/zh.umd.js +1 -1
  158. package/lang/contexts.json +1 -0
  159. package/lang/translations/ar.po +4 -0
  160. package/lang/translations/az.po +4 -0
  161. package/lang/translations/bg.po +4 -0
  162. package/lang/translations/bn.po +4 -0
  163. package/lang/translations/ca.po +4 -0
  164. package/lang/translations/cs.po +4 -0
  165. package/lang/translations/da.po +4 -0
  166. package/lang/translations/de.po +4 -0
  167. package/lang/translations/el.po +4 -0
  168. package/lang/translations/en-au.po +4 -0
  169. package/lang/translations/en.po +4 -0
  170. package/lang/translations/es-co.po +4 -0
  171. package/lang/translations/es.po +4 -0
  172. package/lang/translations/et.po +4 -0
  173. package/lang/translations/fa.po +4 -0
  174. package/lang/translations/fi.po +4 -0
  175. package/lang/translations/fr.po +4 -0
  176. package/lang/translations/gl.po +4 -0
  177. package/lang/translations/he.po +4 -0
  178. package/lang/translations/hi.po +4 -0
  179. package/lang/translations/hr.po +4 -0
  180. package/lang/translations/hu.po +4 -0
  181. package/lang/translations/id.po +4 -0
  182. package/lang/translations/it.po +4 -0
  183. package/lang/translations/ja.po +4 -0
  184. package/lang/translations/ko.po +4 -0
  185. package/lang/translations/lt.po +4 -0
  186. package/lang/translations/lv.po +4 -0
  187. package/lang/translations/ms.po +4 -0
  188. package/lang/translations/nl.po +4 -0
  189. package/lang/translations/no.po +4 -0
  190. package/lang/translations/pl.po +4 -0
  191. package/lang/translations/pt-br.po +4 -0
  192. package/lang/translations/pt.po +4 -0
  193. package/lang/translations/ro.po +4 -0
  194. package/lang/translations/ru.po +4 -0
  195. package/lang/translations/sk.po +4 -0
  196. package/lang/translations/sq.po +4 -0
  197. package/lang/translations/sr-latn.po +8 -4
  198. package/lang/translations/sr.po +4 -0
  199. package/lang/translations/sv.po +4 -0
  200. package/lang/translations/th.po +4 -0
  201. package/lang/translations/tr.po +4 -0
  202. package/lang/translations/ug.po +4 -0
  203. package/lang/translations/uk.po +4 -0
  204. package/lang/translations/ur.po +4 -0
  205. package/lang/translations/uz.po +4 -0
  206. package/lang/translations/vi.po +4 -0
  207. package/lang/translations/zh-cn.po +4 -0
  208. package/lang/translations/zh.po +4 -0
  209. package/package.json +7 -7
  210. package/src/ckboxcommand.d.ts +13 -1
  211. package/src/ckboxcommand.js +36 -4
  212. package/src/ckboxconfig.d.ts +105 -0
  213. package/src/ckboxediting.d.ts +7 -4
  214. package/src/ckboxediting.js +46 -4
  215. package/src/ckboximageedit/ckboximageeditcommand.js +1 -1
  216. package/src/ckboximageedit/ckboximageeditui.js +4 -1
  217. package/src/ckboxuploadadapter.js +2 -2
  218. package/src/ckboxutils.d.ts +3 -3
  219. package/src/ckboxutils.js +10 -10
@@ -1 +1 @@
1
- !function(e){const i=e.ug=e.ug||{};i.dictionary=Object.assign(i.dictionary||{},{"Cannot access default workspace.":"كۆڭۈلدىكى خىزمەت بوشلۇقىنى زىيارەت قىلالمايدۇ","Cannot determine a category for the uploaded file.":"يۈكلەيدىغان ھۆججەتنىڭ تۈرىنى جەزملىيەلمىدى.","Edit image":"","Failed to determine category of edited image.":"","Open file manager":"ھۆججەت باشقۇرغۇچنى ئاچ","Processing the edited image.":"","Server failed to process the image.":""})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
1
+ !function(e){const i=e.ug=e.ug||{};i.dictionary=Object.assign(i.dictionary||{},{"Cannot access default workspace.":"كۆڭۈلدىكى خىزمەت بوشلۇقىنى زىيارەت قىلالمايدۇ","Cannot determine a category for the uploaded file.":"يۈكلەيدىغان ھۆججەتنىڭ تۈرىنى جەزملىيەلمىدى.","Edit image":"","Failed to determine category of edited image.":"","No permission for image editing. Try using the file manager or contact your administrator.":"","Open file manager":"ھۆججەت باشقۇرغۇچنى ئاچ","Processing the edited image.":"","Server failed to process the image.":""})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
@@ -1 +1 @@
1
- !function(e){const i=e.uk=e.uk||{};i.dictionary=Object.assign(i.dictionary||{},{"Cannot access default workspace.":"Немає доступу до робочого простору за замовчуванням.","Cannot determine a category for the uploaded file.":"Не вдається визначити категорію для завантаженого файлу.","Edit image":"Редагувати зображення","Failed to determine category of edited image.":"Не вдалося визначити категорію відредагованого зображення.","Open file manager":"Відкрити менеджер файлів","Processing the edited image.":"Обробка відредагованого зображення.","Server failed to process the image.":"Серверу не вдалося обробити зображення."})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
1
+ !function(e){const i=e.uk=e.uk||{};i.dictionary=Object.assign(i.dictionary||{},{"Cannot access default workspace.":"Немає доступу до робочого простору за замовчуванням.","Cannot determine a category for the uploaded file.":"Не вдається визначити категорію для завантаженого файлу.","Edit image":"Редагувати зображення","Failed to determine category of edited image.":"Не вдалося визначити категорію відредагованого зображення.","No permission for image editing. Try using the file manager or contact your administrator.":"","Open file manager":"Відкрити менеджер файлів","Processing the edited image.":"Обробка відредагованого зображення.","Server failed to process the image.":"Серверу не вдалося обробити зображення."})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
@@ -1 +1 @@
1
- !function(e){const i=e.ur=e.ur||{};i.dictionary=Object.assign(i.dictionary||{},{"Cannot access default workspace.":"","Cannot determine a category for the uploaded file.":"اپلوڈ کی گئی فائل کا ذمرے کا تعین نہیں ہو سکا","Edit image":"","Failed to determine category of edited image.":"","Open file manager":"فائل مینیجر کھولیں","Processing the edited image.":"","Server failed to process the image.":""})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
1
+ !function(e){const i=e.ur=e.ur||{};i.dictionary=Object.assign(i.dictionary||{},{"Cannot access default workspace.":"","Cannot determine a category for the uploaded file.":"اپلوڈ کی گئی فائل کا ذمرے کا تعین نہیں ہو سکا","Edit image":"","Failed to determine category of edited image.":"","No permission for image editing. Try using the file manager or contact your administrator.":"","Open file manager":"فائل مینیجر کھولیں","Processing the edited image.":"","Server failed to process the image.":""})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
@@ -1 +1 @@
1
- !function(e){const i=e.uz=e.uz||{};i.dictionary=Object.assign(i.dictionary||{},{"Cannot access default workspace.":"","Cannot determine a category for the uploaded file.":"Yuklangan fayl uchun toifani aniqlab bo‘lmadi.","Edit image":"","Failed to determine category of edited image.":"","Open file manager":"Fayl menejerini ochish","Processing the edited image.":"","Server failed to process the image.":""})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
1
+ !function(e){const i=e.uz=e.uz||{};i.dictionary=Object.assign(i.dictionary||{},{"Cannot access default workspace.":"","Cannot determine a category for the uploaded file.":"Yuklangan fayl uchun toifani aniqlab bo‘lmadi.","Edit image":"","Failed to determine category of edited image.":"","No permission for image editing. Try using the file manager or contact your administrator.":"","Open file manager":"Fayl menejerini ochish","Processing the edited image.":"","Server failed to process the image.":""})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
@@ -1 +1 @@
1
- !function(n){const h=n.vi=n.vi||{};h.dictionary=Object.assign(h.dictionary||{},{"Cannot access default workspace.":"Không thể truy cập vào không gian làm việc mặc định.","Cannot determine a category for the uploaded file.":"Không thể xác định danh mục cho tệp được tải lên.","Edit image":"Chỉnh sửa hình ảnh","Failed to determine category of edited image.":"Không thể xác định danh mục hình ảnh đã chỉnh sửa.","Open file manager":"Mở trình quản lý tệp","Processing the edited image.":"Xử lý hình ảnh đã chỉnh sửa.","Server failed to process the image.":"Máy chủ không thể xử lý hình ảnh."})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
1
+ !function(n){const e=n.vi=n.vi||{};e.dictionary=Object.assign(e.dictionary||{},{"Cannot access default workspace.":"Không thể truy cập vào không gian làm việc mặc định.","Cannot determine a category for the uploaded file.":"Không thể xác định danh mục cho tệp được tải lên.","Edit image":"Chỉnh sửa hình ảnh","Failed to determine category of edited image.":"Không thể xác định danh mục hình ảnh đã chỉnh sửa.","No permission for image editing. Try using the file manager or contact your administrator.":"","Open file manager":"Mở trình quản lý tệp","Processing the edited image.":"Xử lý hình ảnh đã chỉnh sửa.","Server failed to process the image.":"Máy chủ không thể xử lý hình ảnh."})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
@@ -1 +1 @@
1
- !function(e){const i=e["zh-cn"]=e["zh-cn"]||{};i.dictionary=Object.assign(i.dictionary||{},{"Cannot access default workspace.":"无法访问默认工作区","Cannot determine a category for the uploaded file.":"无法确定上传文件的类别。","Edit image":"编辑图片","Failed to determine category of edited image.":"未能确定已编辑图片的类别。","Open file manager":"打开文件管理器","Processing the edited image.":"正在处理已编辑的图片。","Server failed to process the image.":"服务器未能处理图片。"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
1
+ !function(e){const i=e["zh-cn"]=e["zh-cn"]||{};i.dictionary=Object.assign(i.dictionary||{},{"Cannot access default workspace.":"无法访问默认工作区","Cannot determine a category for the uploaded file.":"无法确定上传文件的类别。","Edit image":"编辑图片","Failed to determine category of edited image.":"未能确定已编辑图片的类别。","No permission for image editing. Try using the file manager or contact your administrator.":"","Open file manager":"打开文件管理器","Processing the edited image.":"正在处理已编辑的图片。","Server failed to process the image.":"服务器未能处理图片。"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
@@ -1 +1 @@
1
- !function(e){const i=e.zh=e.zh||{};i.dictionary=Object.assign(i.dictionary||{},{"Cannot access default workspace.":"無法存取預設工作區。","Cannot determine a category for the uploaded file.":"無法確定上傳檔案的分類。","Edit image":"編輯圖片","Failed to determine category of edited image.":"無法判斷已編輯圖片的類別。","Open file manager":"開啟檔案管理程式","Processing the edited image.":"正在處理已編輯的圖片。","Server failed to process the image.":"伺服器無法處理該圖片。"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
1
+ !function(e){const i=e.zh=e.zh||{};i.dictionary=Object.assign(i.dictionary||{},{"Cannot access default workspace.":"無法存取預設工作區。","Cannot determine a category for the uploaded file.":"無法確定上傳檔案的分類。","Edit image":"編輯圖片","Failed to determine category of edited image.":"無法判斷已編輯圖片的類別。","No permission for image editing. Try using the file manager or contact your administrator.":"","Open file manager":"開啟檔案管理程式","Processing the edited image.":"正在處理已編輯的圖片。","Server failed to process the image.":"伺服器無法處理該圖片。"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
@@ -78,8 +78,20 @@ export default class CKBoxCommand extends Command {
78
78
  * - tokenUrl The token endpoint URL.
79
79
  * - serviceOrigin The base URL of the API service.
80
80
  * - forceDemoLabel Whether to force "Powered by CKBox" link.
81
- * - dialog.onClose The callback function invoked after closing the CKBox dialog.
82
81
  * - assets.onChoose The callback function invoked after choosing the assets.
82
+ * - dialog.onClose The callback function invoked after closing the CKBox dialog.
83
+ * - dialog.width The dialog width in pixels.
84
+ * - dialog.height The dialog height in pixels.
85
+ * - categories.icons Allows setting custom icons for categories.
86
+ * - view.openLastView Sets if the last view visited by the user will be reopened
87
+ * on the next startup.
88
+ * - view.startupFolderId Sets the ID of the folder that will be opened on startup.
89
+ * - view.startupCategoryId Sets the ID of the category that will be opened on startup.
90
+ * - view.hideMaximizeButton Sets whether to hide the ‘Maximize’ button.
91
+ * - view.componentsHideTimeout Sets timeout after which upload components are hidden
92
+ * after completed upload.
93
+ * - view.dialogMinimizeTimeout Sets timeout after which upload dialog is minimized
94
+ * after completed upload.
83
95
  */
84
96
  private _prepareOptions;
85
97
  /**
@@ -129,6 +129,111 @@ export interface CKBoxConfig {
129
129
  * Defaults to {@link module:utils/locale~Locale#uiLanguage `Locale#uiLanguage`}
130
130
  */
131
131
  language?: string;
132
+ /**
133
+ * This option allows opening CKBox in dialog mode. It takes a configuration object with
134
+ * the width and height attributes.
135
+ */
136
+ dialog?: CKBoxDialogConfig;
137
+ /**
138
+ * Allows setting custom icons for categories.
139
+ */
140
+ categories?: CKBoxCategoriesConfig;
141
+ /**
142
+ * Configures the view of CKBox.
143
+ */
144
+ view?: CKBoxViewConfig;
145
+ /**
146
+ * Configures when dialog should be minimized and hidden.
147
+ */
148
+ upload?: CKBoxUploadConfig;
149
+ /**
150
+ * Specifies the file extensions considered valid for user interaction. Whith this
151
+ * option developers can restrict user interaction to only those assets whose file
152
+ * extensions match those listed in the array. Assets whose file
153
+ * extensions are not listed in the `choosableFileExtensions` array are
154
+ * automatically disabled within the CKBox interface.
155
+ *
156
+ * ```ts
157
+ * const ckboxConfig = {
158
+ * choosableFileExtensions: ['jpg', 'png']
159
+ * };
160
+ * ```
161
+ */
162
+ choosableFileExtensions?: Array<string>;
163
+ }
164
+ export interface CKBoxDialogConfig {
165
+ /**
166
+ * The dialog width in pixels.
167
+ */
168
+ width: number;
169
+ /**
170
+ * The dialog height in pixels.
171
+ */
172
+ height: number;
173
+ }
174
+ export interface CKBoxCategoriesConfig {
175
+ /**
176
+ * This option takes an object with categories and icons that should be used instead
177
+ * of the default ones. Categories can be defined using either their name or id.
178
+ * Icons should be defined as strings containing the SVG images, or as React components.
179
+ *
180
+ * ```ts
181
+ * const ckboxConfig = {
182
+ * categories: {
183
+ * icons: {
184
+ * Images: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path ... /></svg>',
185
+ * // Category can be referenced by ID
186
+ * // 'fdf2a647-b67f-4a6c-b692-5ba1dc1ed87b': '<svg...'
187
+ * }
188
+ * }
189
+ * }
190
+ * ```
191
+ */
192
+ icons?: {
193
+ [key: string]: string;
194
+ };
195
+ }
196
+ export interface CKBoxViewConfig {
197
+ /**
198
+ * If it is set to `false` the last view visited by the user will not be reopened on
199
+ * the next startup.
200
+ */
201
+ openLastView?: boolean;
202
+ /**
203
+ * Sets the ID of the folder that will be opened on startup. This option can be paired
204
+ * with setting `view.openLastView` to `false` to enforce CKBox to always open in a given
205
+ * folder at startup.
206
+ */
207
+ startupFolderId?: string;
208
+ /**
209
+ * Sets the ID of the category that will be opened on startup. This option can be paired
210
+ * with setting `view.openLastView` to `false` to enforce CKBox to always open in a given
211
+ * category at startup. If `view.startupCategoryId` is passed along with the
212
+ * `view.startupFolderId` option, CKBox will prioritize opening category view on the startup.
213
+ */
214
+ startupCategoryId?: string;
215
+ /**
216
+ * Sets whether to hide the ‘Maximize’ button. By default, the button is shown and enabling
217
+ * this option will hide it.
218
+ */
219
+ hideMaximizeButton?: boolean;
220
+ }
221
+ export interface CKBoxUploadConfig {
222
+ /**
223
+ * Sets timeout (in milliseconds) after which upload components (dialog and indicator) are
224
+ * hidden. By default, these components hide automatically after 10 seconds.
225
+ *
226
+ * Read more: https://ckeditor.com/docs/ckbox/latest/guides/configuration/configuration-options.html#uploadcomponentshidetimeout
227
+ */
228
+ componentsHideTimeout?: number;
229
+ /**
230
+ * Sets timeout (in milliseconds) after which upload dialog is minimized once upload is
231
+ * finished and all uploads were successful. By default, upload dialog is never minimized
232
+ * automatically.
233
+ *
234
+ * Read more: https://ckeditor.com/docs/ckbox/latest/guides/configuration/configuration-options.html#uploaddialogminimizetimeout
235
+ */
236
+ dialogMinimizeTimeout?: number;
132
237
  }
133
238
  /**
134
239
  * Asset definition.
@@ -6,6 +6,9 @@
6
6
  * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
7
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
8
  */
9
+ /**
10
+ * @module ckbox/ckboxediting
11
+ */
9
12
  import { Plugin } from 'ckeditor5/src/core.js';
10
13
  import CKBoxUploadAdapter from './ckboxuploadadapter.js';
11
14
  import CKBoxUtils from './ckboxutils.js';
@@ -14,10 +17,6 @@ import CKBoxUtils from './ckboxutils.js';
14
17
  * {@link module:ckbox/ckboxuploadadapter~CKBoxUploadAdapter CKBox upload adapter}.
15
18
  */
16
19
  export default class CKBoxEditing extends Plugin {
17
- /**
18
- * CKEditor Cloud Services access token.
19
- */
20
- private _token;
21
20
  /**
22
21
  * @inheritDoc
23
22
  */
@@ -39,6 +38,10 @@ export default class CKBoxEditing extends Plugin {
39
38
  * the CKBox JavaScript library is loaded.
40
39
  */
41
40
  private _shouldBeInitialised;
41
+ /**
42
+ * Blocks `uploadImage` and `ckboxImageEdit` commands.
43
+ */
44
+ private _blockImageCommands;
42
45
  /**
43
46
  * Checks if at least one image plugin is loaded.
44
47
  */
@@ -30,15 +30,15 @@ export default class CKBoxUtils extends Plugin {
30
30
  /**
31
31
  * @inheritDoc
32
32
  */
33
- init(): Promise<void>;
33
+ init(): void;
34
34
  /**
35
35
  * Returns a token used by the CKBox plugin for communication with the CKBox service.
36
36
  */
37
- getToken(): InitializedToken;
37
+ getToken(): Promise<InitializedToken>;
38
38
  /**
39
39
  * The ID of workspace to use when uploading an image.
40
40
  */
41
- getWorkspaceId(): string;
41
+ getWorkspaceId(): Promise<string>;
42
42
  /**
43
43
  * Resolves a promise with an object containing a category with which the uploaded file is associated or an error code.
44
44
  */
package/dist/index.js CHANGED
@@ -369,22 +369,54 @@ const ASSET_INSERTION_WAIT_TIMEOUT = 1000;
369
369
  * - tokenUrl The token endpoint URL.
370
370
  * - serviceOrigin The base URL of the API service.
371
371
  * - forceDemoLabel Whether to force "Powered by CKBox" link.
372
- * - dialog.onClose The callback function invoked after closing the CKBox dialog.
373
372
  * - assets.onChoose The callback function invoked after choosing the assets.
373
+ * - dialog.onClose The callback function invoked after closing the CKBox dialog.
374
+ * - dialog.width The dialog width in pixels.
375
+ * - dialog.height The dialog height in pixels.
376
+ * - categories.icons Allows setting custom icons for categories.
377
+ * - view.openLastView Sets if the last view visited by the user will be reopened
378
+ * on the next startup.
379
+ * - view.startupFolderId Sets the ID of the folder that will be opened on startup.
380
+ * - view.startupCategoryId Sets the ID of the category that will be opened on startup.
381
+ * - view.hideMaximizeButton Sets whether to hide the ‘Maximize’ button.
382
+ * - view.componentsHideTimeout Sets timeout after which upload components are hidden
383
+ * after completed upload.
384
+ * - view.dialogMinimizeTimeout Sets timeout after which upload dialog is minimized
385
+ * after completed upload.
374
386
  */ _prepareOptions() {
375
387
  const editor = this.editor;
376
388
  const ckboxConfig = editor.config.get('ckbox');
389
+ const dialog = ckboxConfig.dialog;
390
+ const categories = ckboxConfig.categories;
391
+ const view = ckboxConfig.view;
392
+ const upload = ckboxConfig.upload;
377
393
  return {
378
394
  theme: ckboxConfig.theme,
379
395
  language: ckboxConfig.language,
380
396
  tokenUrl: ckboxConfig.tokenUrl,
381
397
  serviceOrigin: ckboxConfig.serviceOrigin,
382
398
  forceDemoLabel: ckboxConfig.forceDemoLabel,
383
- dialog: {
384
- onClose: ()=>this.fire('ckbox:close')
385
- },
399
+ choosableFileExtensions: ckboxConfig.choosableFileExtensions,
386
400
  assets: {
387
401
  onChoose: (assets)=>this.fire('ckbox:choose', assets)
402
+ },
403
+ dialog: {
404
+ onClose: ()=>this.fire('ckbox:close'),
405
+ width: dialog && dialog.width,
406
+ height: dialog && dialog.height
407
+ },
408
+ categories: categories && {
409
+ icons: categories.icons
410
+ },
411
+ view: view && {
412
+ openLastView: view.openLastView,
413
+ startupFolderId: view.startupFolderId,
414
+ startupCategoryId: view.startupCategoryId,
415
+ hideMaximizeButton: view.hideMaximizeButton
416
+ },
417
+ upload: upload && {
418
+ componentsHideTimeout: upload.componentsHideTimeout,
419
+ dialogMinimizeTimeout: upload.dialogMinimizeTimeout
388
420
  }
389
421
  };
390
422
  }
@@ -619,7 +651,7 @@ const DEFAULT_CKBOX_THEME_NAME = 'lark';
619
651
  }
620
652
  /**
621
653
  * @inheritDoc
622
- */ async init() {
654
+ */ init() {
623
655
  const editor = this.editor;
624
656
  const hasConfiguration = !!editor.config.get('ckbox');
625
657
  const isLibraryLoaded = !!window.CKBox;
@@ -659,9 +691,9 @@ const DEFAULT_CKBOX_THEME_NAME = 'lark';
659
691
  */ throw new CKEditorError('ckbox-plugin-missing-token-url', this);
660
692
  }
661
693
  if (ckboxTokenUrl == cloudServicesTokenUrl) {
662
- this._token = cloudServices.token;
694
+ this._token = Promise.resolve(cloudServices.token);
663
695
  } else {
664
- this._token = await cloudServices.registerTokenUrl(ckboxTokenUrl);
696
+ this._token = cloudServices.registerTokenUrl(ckboxTokenUrl);
665
697
  }
666
698
  }
667
699
  /**
@@ -671,11 +703,11 @@ const DEFAULT_CKBOX_THEME_NAME = 'lark';
671
703
  }
672
704
  /**
673
705
  * The ID of workspace to use when uploading an image.
674
- */ getWorkspaceId() {
706
+ */ async getWorkspaceId() {
675
707
  const t = this.editor.t;
676
708
  const cannotAccessDefaultWorkspaceError = t('Cannot access default workspace.');
677
709
  const defaultWorkspaceId = this.editor.config.get('ckbox.defaultUploadWorkspaceId');
678
- const workspaceId = getWorkspaceId(this._token, defaultWorkspaceId);
710
+ const workspaceId = getWorkspaceId(await this._token, defaultWorkspaceId);
679
711
  if (workspaceId == null) {
680
712
  /**
681
713
  * The user is not authorized to access the workspace defined in the`ckbox.defaultUploadWorkspaceId` configuration.
@@ -730,7 +762,7 @@ const DEFAULT_CKBOX_THEME_NAME = 'lark';
730
762
  const token = this._token;
731
763
  const { signal } = options;
732
764
  const serviceOrigin = editor.config.get('ckbox.serviceOrigin');
733
- const workspaceId = this.getWorkspaceId();
765
+ const workspaceId = await this.getWorkspaceId();
734
766
  try {
735
767
  const result = [];
736
768
  let offset = 0;
@@ -751,15 +783,15 @@ const DEFAULT_CKBOX_THEME_NAME = 'lark';
751
783
  */ logError('ckbox-fetch-category-http-error');
752
784
  return undefined;
753
785
  }
754
- function fetchCategories(offset) {
786
+ async function fetchCategories(offset) {
755
787
  const categoryUrl = new URL('categories', serviceOrigin);
756
- categoryUrl.searchParams.set('limit', ITEMS_PER_REQUEST.toString());
757
- categoryUrl.searchParams.set('offset', offset.toString());
788
+ categoryUrl.searchParams.set('limit', String(ITEMS_PER_REQUEST));
789
+ categoryUrl.searchParams.set('offset', String(offset));
758
790
  categoryUrl.searchParams.set('workspaceId', workspaceId);
759
791
  return sendHttpRequest({
760
792
  url: categoryUrl,
761
793
  signal,
762
- authorization: token.value
794
+ authorization: (await token).value
763
795
  });
764
796
  }
765
797
  }
@@ -860,7 +892,7 @@ const DEFAULT_CKBOX_THEME_NAME = 'lark';
860
892
  });
861
893
  const uploadUrl = new URL('assets', this.serviceOrigin);
862
894
  const formData = new FormData();
863
- uploadUrl.searchParams.set('workspaceId', ckboxUtils.getWorkspaceId());
895
+ uploadUrl.searchParams.set('workspaceId', await ckboxUtils.getWorkspaceId());
864
896
  formData.append('categoryId', category);
865
897
  formData.append('file', file);
866
898
  const requestConfig = {
@@ -874,7 +906,7 @@ const DEFAULT_CKBOX_THEME_NAME = 'lark';
874
906
  }
875
907
  },
876
908
  signal: this.controller.signal,
877
- authorization: this.token.value
909
+ authorization: (await this.token).value
878
910
  };
879
911
  return sendHttpRequest(requestConfig).then(async (data)=>{
880
912
  const imageUrls = getImageUrls(data.imageUrls);
@@ -897,13 +929,11 @@ const DEFAULT_CKBOX_THEME_NAME = 'lark';
897
929
  }
898
930
  }
899
931
 
932
+ const COMMAND_FORCE_DISABLE_ID = 'NoPermission';
900
933
  /**
901
934
  * The CKBox editing feature. It introduces the {@link module:ckbox/ckboxcommand~CKBoxCommand CKBox command} and
902
935
  * {@link module:ckbox/ckboxuploadadapter~CKBoxUploadAdapter CKBox upload adapter}.
903
936
  */ class CKBoxEditing extends Plugin {
904
- /**
905
- * CKEditor Cloud Services access token.
906
- */ _token;
907
937
  /**
908
938
  * @inheritDoc
909
939
  */ static get pluginName() {
@@ -931,6 +961,12 @@ const DEFAULT_CKBOX_THEME_NAME = 'lark';
931
961
  if (isLibraryLoaded()) {
932
962
  editor.commands.add('ckbox', new CKBoxCommand(editor));
933
963
  }
964
+ // Promise is not handled intentionally. Errors should be displayed in console if there are so.
965
+ isUploadPermissionGranted(editor).then((isCreateAssetAllowed)=>{
966
+ if (!isCreateAssetAllowed) {
967
+ this._blockImageCommands();
968
+ }
969
+ });
934
970
  }
935
971
  /**
936
972
  * @inheritDoc
@@ -955,6 +991,20 @@ const DEFAULT_CKBOX_THEME_NAME = 'lark';
955
991
  const hasConfiguration = !!editor.config.get('ckbox');
956
992
  return hasConfiguration || isLibraryLoaded();
957
993
  }
994
+ /**
995
+ * Blocks `uploadImage` and `ckboxImageEdit` commands.
996
+ */ _blockImageCommands() {
997
+ const editor = this.editor;
998
+ const uploadImageCommand = editor.commands.get('uploadImage');
999
+ const imageEditingCommand = editor.commands.get('ckboxImageEdit');
1000
+ if (uploadImageCommand) {
1001
+ uploadImageCommand.isAccessAllowed = false;
1002
+ uploadImageCommand.forceDisabled(COMMAND_FORCE_DISABLE_ID);
1003
+ }
1004
+ if (imageEditingCommand) {
1005
+ imageEditingCommand.forceDisabled(COMMAND_FORCE_DISABLE_ID);
1006
+ }
1007
+ }
958
1008
  /**
959
1009
  * Checks if at least one image plugin is loaded.
960
1010
  */ _checkImagePlugins() {
@@ -998,12 +1048,12 @@ const DEFAULT_CKBOX_THEME_NAME = 'lark';
998
1048
  ]
999
1049
  });
1000
1050
  }
1001
- schema.addAttributeCheck((context, attributeName)=>{
1002
- const isLink = !!context.last.getAttribute('linkHref');
1003
- if (!isLink && attributeName === 'ckboxLinkId') {
1051
+ schema.addAttributeCheck((context)=>{
1052
+ // Don't allow `ckboxLinkId` on elements which do not have `linkHref` attribute.
1053
+ if (!context.last.getAttribute('linkHref')) {
1004
1054
  return false;
1005
1055
  }
1006
- });
1056
+ }, 'ckboxLinkId');
1007
1057
  }
1008
1058
  /**
1009
1059
  * Configures the upcast and downcast conversions for the `ckboxImageId` and `ckboxLinkId` attributes.
@@ -1241,6 +1291,20 @@ const DEFAULT_CKBOX_THEME_NAME = 'lark';
1241
1291
  */ function isLibraryLoaded() {
1242
1292
  return !!window.CKBox;
1243
1293
  }
1294
+ /**
1295
+ * Checks is access allowed to upload assets.
1296
+ */ async function isUploadPermissionGranted(editor) {
1297
+ const ckboxUtils = editor.plugins.get(CKBoxUtils);
1298
+ const origin = editor.config.get('ckbox.serviceOrigin');
1299
+ const url = new URL('permissions', origin);
1300
+ const { value } = await ckboxUtils.getToken();
1301
+ const response = await sendHttpRequest({
1302
+ url,
1303
+ authorization: value,
1304
+ signal: new AbortController().signal // Aborting is unnecessary.
1305
+ });
1306
+ return Object.values(response).some((category)=>category['asset:create']);
1307
+ }
1244
1308
 
1245
1309
  /**
1246
1310
  * The CKBox feature, a bridge between the CKEditor 5 WYSIWYG editor and the CKBox file manager and uploader.
@@ -1510,7 +1574,7 @@ function createUrlChecker(allowExternalImagesEditing) {
1510
1574
  const response = await sendHttpRequest({
1511
1575
  url,
1512
1576
  signal,
1513
- authorization: ckboxUtils.getToken().value
1577
+ authorization: (await ckboxUtils.getToken()).value
1514
1578
  });
1515
1579
  const status = response.metadata.metadataProcessingStatus;
1516
1580
  if (!status || status == 'queued') {
@@ -1641,13 +1705,14 @@ var ckboxImageEditIcon = "<svg viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2
1641
1705
  const editor = this.editor;
1642
1706
  editor.ui.componentFactory.add('ckboxImageEdit', (locale)=>{
1643
1707
  const command = editor.commands.get('ckboxImageEdit');
1708
+ const uploadImageCommand = editor.commands.get('uploadImage');
1644
1709
  const view = new ButtonView(locale);
1645
1710
  const t = locale.t;
1646
1711
  view.set({
1647
- label: t('Edit image'),
1648
1712
  icon: ckboxImageEditIcon,
1649
1713
  tooltip: true
1650
1714
  });
1715
+ view.bind('label').to(uploadImageCommand, 'isAccessAllowed', (isAccessAllowed)=>isAccessAllowed ? t('Edit image') : t('No permission for image editing. Try using the file manager or contact your administrator.'));
1651
1716
  view.bind('isOn').to(command, 'value', command, 'isEnabled', (value, isEnabled)=>value && isEnabled);
1652
1717
  view.bind('isEnabled').to(command);
1653
1718
  // Execute the command.