@ckeditor/ckeditor5-image 44.3.0-alpha.7 → 45.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 (331) hide show
  1. package/LICENSE.md +1 -1
  2. package/build/image.js +2 -2
  3. package/build/translations/af.js +1 -1
  4. package/build/translations/ar.js +1 -1
  5. package/build/translations/ast.js +1 -1
  6. package/build/translations/az.js +1 -1
  7. package/build/translations/be.js +1 -0
  8. package/build/translations/bg.js +1 -1
  9. package/build/translations/bn.js +1 -1
  10. package/build/translations/bs.js +1 -1
  11. package/build/translations/ca.js +1 -1
  12. package/build/translations/cs.js +1 -1
  13. package/build/translations/da.js +1 -1
  14. package/build/translations/de-ch.js +1 -1
  15. package/build/translations/de.js +1 -1
  16. package/build/translations/el.js +1 -1
  17. package/build/translations/en-au.js +1 -1
  18. package/build/translations/en-gb.js +1 -1
  19. package/build/translations/eo.js +1 -1
  20. package/build/translations/es-co.js +1 -1
  21. package/build/translations/es.js +1 -1
  22. package/build/translations/et.js +1 -1
  23. package/build/translations/eu.js +1 -1
  24. package/build/translations/fa.js +1 -1
  25. package/build/translations/fi.js +1 -1
  26. package/build/translations/fr.js +1 -1
  27. package/build/translations/gl.js +1 -1
  28. package/build/translations/gu.js +1 -1
  29. package/build/translations/he.js +1 -1
  30. package/build/translations/hi.js +1 -1
  31. package/build/translations/hr.js +1 -1
  32. package/build/translations/hu.js +1 -1
  33. package/build/translations/hy.js +1 -1
  34. package/build/translations/id.js +1 -1
  35. package/build/translations/it.js +1 -1
  36. package/build/translations/ja.js +1 -1
  37. package/build/translations/jv.js +1 -1
  38. package/build/translations/kk.js +1 -1
  39. package/build/translations/km.js +1 -1
  40. package/build/translations/kn.js +1 -1
  41. package/build/translations/ko.js +1 -1
  42. package/build/translations/ku.js +1 -1
  43. package/build/translations/lt.js +1 -1
  44. package/build/translations/lv.js +1 -1
  45. package/build/translations/ms.js +1 -1
  46. package/build/translations/nb.js +1 -1
  47. package/build/translations/ne.js +1 -1
  48. package/build/translations/nl.js +1 -1
  49. package/build/translations/no.js +1 -1
  50. package/build/translations/oc.js +1 -1
  51. package/build/translations/pl.js +1 -1
  52. package/build/translations/pt-br.js +1 -1
  53. package/build/translations/pt.js +1 -1
  54. package/build/translations/ro.js +1 -1
  55. package/build/translations/ru.js +1 -1
  56. package/build/translations/si.js +1 -1
  57. package/build/translations/sk.js +1 -1
  58. package/build/translations/sl.js +1 -1
  59. package/build/translations/sq.js +1 -1
  60. package/build/translations/sr-latn.js +1 -1
  61. package/build/translations/sr.js +1 -1
  62. package/build/translations/sv.js +1 -1
  63. package/build/translations/th.js +1 -1
  64. package/build/translations/ti.js +1 -1
  65. package/build/translations/tk.js +1 -1
  66. package/build/translations/tr.js +1 -1
  67. package/build/translations/tt.js +1 -1
  68. package/build/translations/ug.js +1 -1
  69. package/build/translations/uk.js +1 -1
  70. package/build/translations/ur.js +1 -1
  71. package/build/translations/uz.js +1 -1
  72. package/build/translations/vi.js +1 -1
  73. package/build/translations/zh-cn.js +1 -1
  74. package/build/translations/zh.js +1 -1
  75. package/ckeditor5-metadata.json +9 -9
  76. package/dist/index-editor.css +72 -59
  77. package/dist/index.css +90 -79
  78. package/dist/index.css.map +1 -1
  79. package/dist/index.js +178 -120
  80. package/dist/index.js.map +1 -1
  81. package/dist/translations/af.js +1 -1
  82. package/dist/translations/af.umd.js +1 -1
  83. package/dist/translations/ar.js +1 -1
  84. package/dist/translations/ar.umd.js +1 -1
  85. package/dist/translations/ast.js +1 -1
  86. package/dist/translations/ast.umd.js +1 -1
  87. package/dist/translations/az.js +1 -1
  88. package/dist/translations/az.umd.js +1 -1
  89. package/dist/translations/be.d.ts +8 -0
  90. package/dist/translations/be.js +5 -0
  91. package/dist/translations/be.umd.js +11 -0
  92. package/dist/translations/bg.js +1 -1
  93. package/dist/translations/bg.umd.js +1 -1
  94. package/dist/translations/bn.js +1 -1
  95. package/dist/translations/bn.umd.js +1 -1
  96. package/dist/translations/bs.js +1 -1
  97. package/dist/translations/bs.umd.js +1 -1
  98. package/dist/translations/ca.js +1 -1
  99. package/dist/translations/ca.umd.js +1 -1
  100. package/dist/translations/cs.js +1 -1
  101. package/dist/translations/cs.umd.js +1 -1
  102. package/dist/translations/da.js +1 -1
  103. package/dist/translations/da.umd.js +1 -1
  104. package/dist/translations/de-ch.js +1 -1
  105. package/dist/translations/de-ch.umd.js +1 -1
  106. package/dist/translations/de.js +1 -1
  107. package/dist/translations/de.umd.js +1 -1
  108. package/dist/translations/el.js +1 -1
  109. package/dist/translations/el.umd.js +1 -1
  110. package/dist/translations/en-au.js +1 -1
  111. package/dist/translations/en-au.umd.js +1 -1
  112. package/dist/translations/en-gb.js +1 -1
  113. package/dist/translations/en-gb.umd.js +1 -1
  114. package/dist/translations/en.js +1 -1
  115. package/dist/translations/en.umd.js +1 -1
  116. package/dist/translations/eo.js +1 -1
  117. package/dist/translations/eo.umd.js +1 -1
  118. package/dist/translations/es-co.js +1 -1
  119. package/dist/translations/es-co.umd.js +1 -1
  120. package/dist/translations/es.js +1 -1
  121. package/dist/translations/es.umd.js +1 -1
  122. package/dist/translations/et.js +1 -1
  123. package/dist/translations/et.umd.js +1 -1
  124. package/dist/translations/eu.js +1 -1
  125. package/dist/translations/eu.umd.js +1 -1
  126. package/dist/translations/fa.js +1 -1
  127. package/dist/translations/fa.umd.js +1 -1
  128. package/dist/translations/fi.js +1 -1
  129. package/dist/translations/fi.umd.js +1 -1
  130. package/dist/translations/fr.js +1 -1
  131. package/dist/translations/fr.umd.js +1 -1
  132. package/dist/translations/gl.js +1 -1
  133. package/dist/translations/gl.umd.js +1 -1
  134. package/dist/translations/gu.js +1 -1
  135. package/dist/translations/gu.umd.js +1 -1
  136. package/dist/translations/he.js +1 -1
  137. package/dist/translations/he.umd.js +1 -1
  138. package/dist/translations/hi.js +1 -1
  139. package/dist/translations/hi.umd.js +1 -1
  140. package/dist/translations/hr.js +1 -1
  141. package/dist/translations/hr.umd.js +1 -1
  142. package/dist/translations/hu.js +1 -1
  143. package/dist/translations/hu.umd.js +1 -1
  144. package/dist/translations/hy.js +1 -1
  145. package/dist/translations/hy.umd.js +1 -1
  146. package/dist/translations/id.js +1 -1
  147. package/dist/translations/id.umd.js +1 -1
  148. package/dist/translations/it.js +1 -1
  149. package/dist/translations/it.umd.js +1 -1
  150. package/dist/translations/ja.js +1 -1
  151. package/dist/translations/ja.umd.js +1 -1
  152. package/dist/translations/jv.js +1 -1
  153. package/dist/translations/jv.umd.js +1 -1
  154. package/dist/translations/kk.js +1 -1
  155. package/dist/translations/kk.umd.js +1 -1
  156. package/dist/translations/km.js +1 -1
  157. package/dist/translations/km.umd.js +1 -1
  158. package/dist/translations/kn.js +1 -1
  159. package/dist/translations/kn.umd.js +1 -1
  160. package/dist/translations/ko.js +1 -1
  161. package/dist/translations/ko.umd.js +1 -1
  162. package/dist/translations/ku.js +1 -1
  163. package/dist/translations/ku.umd.js +1 -1
  164. package/dist/translations/lt.js +1 -1
  165. package/dist/translations/lt.umd.js +1 -1
  166. package/dist/translations/lv.js +1 -1
  167. package/dist/translations/lv.umd.js +1 -1
  168. package/dist/translations/ms.js +1 -1
  169. package/dist/translations/ms.umd.js +1 -1
  170. package/dist/translations/nb.js +1 -1
  171. package/dist/translations/nb.umd.js +1 -1
  172. package/dist/translations/ne.js +1 -1
  173. package/dist/translations/ne.umd.js +1 -1
  174. package/dist/translations/nl.js +1 -1
  175. package/dist/translations/nl.umd.js +1 -1
  176. package/dist/translations/no.js +1 -1
  177. package/dist/translations/no.umd.js +1 -1
  178. package/dist/translations/oc.js +1 -1
  179. package/dist/translations/oc.umd.js +1 -1
  180. package/dist/translations/pl.js +1 -1
  181. package/dist/translations/pl.umd.js +1 -1
  182. package/dist/translations/pt-br.js +1 -1
  183. package/dist/translations/pt-br.umd.js +1 -1
  184. package/dist/translations/pt.js +1 -1
  185. package/dist/translations/pt.umd.js +1 -1
  186. package/dist/translations/ro.js +1 -1
  187. package/dist/translations/ro.umd.js +1 -1
  188. package/dist/translations/ru.js +1 -1
  189. package/dist/translations/ru.umd.js +1 -1
  190. package/dist/translations/si.js +1 -1
  191. package/dist/translations/si.umd.js +1 -1
  192. package/dist/translations/sk.js +1 -1
  193. package/dist/translations/sk.umd.js +1 -1
  194. package/dist/translations/sl.js +1 -1
  195. package/dist/translations/sl.umd.js +1 -1
  196. package/dist/translations/sq.js +1 -1
  197. package/dist/translations/sq.umd.js +1 -1
  198. package/dist/translations/sr-latn.js +1 -1
  199. package/dist/translations/sr-latn.umd.js +1 -1
  200. package/dist/translations/sr.js +1 -1
  201. package/dist/translations/sr.umd.js +1 -1
  202. package/dist/translations/sv.js +1 -1
  203. package/dist/translations/sv.umd.js +1 -1
  204. package/dist/translations/th.js +1 -1
  205. package/dist/translations/th.umd.js +1 -1
  206. package/dist/translations/ti.js +1 -1
  207. package/dist/translations/ti.umd.js +1 -1
  208. package/dist/translations/tk.js +1 -1
  209. package/dist/translations/tk.umd.js +1 -1
  210. package/dist/translations/tr.js +1 -1
  211. package/dist/translations/tr.umd.js +1 -1
  212. package/dist/translations/tt.js +1 -1
  213. package/dist/translations/tt.umd.js +1 -1
  214. package/dist/translations/ug.js +1 -1
  215. package/dist/translations/ug.umd.js +1 -1
  216. package/dist/translations/uk.js +1 -1
  217. package/dist/translations/uk.umd.js +1 -1
  218. package/dist/translations/ur.js +1 -1
  219. package/dist/translations/ur.umd.js +1 -1
  220. package/dist/translations/uz.js +1 -1
  221. package/dist/translations/uz.umd.js +1 -1
  222. package/dist/translations/vi.js +1 -1
  223. package/dist/translations/vi.umd.js +1 -1
  224. package/dist/translations/zh-cn.js +1 -1
  225. package/dist/translations/zh-cn.umd.js +1 -1
  226. package/dist/translations/zh.js +1 -1
  227. package/dist/translations/zh.umd.js +1 -1
  228. package/lang/contexts.json +4 -2
  229. package/lang/translations/af.po +8 -0
  230. package/lang/translations/ar.po +8 -0
  231. package/lang/translations/ast.po +8 -0
  232. package/lang/translations/az.po +8 -0
  233. package/lang/translations/be.po +196 -0
  234. package/lang/translations/bg.po +8 -0
  235. package/lang/translations/bn.po +8 -0
  236. package/lang/translations/bs.po +8 -0
  237. package/lang/translations/ca.po +8 -0
  238. package/lang/translations/cs.po +8 -0
  239. package/lang/translations/da.po +8 -0
  240. package/lang/translations/de-ch.po +8 -0
  241. package/lang/translations/de.po +8 -0
  242. package/lang/translations/el.po +8 -0
  243. package/lang/translations/en-au.po +8 -0
  244. package/lang/translations/en-gb.po +8 -0
  245. package/lang/translations/en.po +8 -0
  246. package/lang/translations/eo.po +8 -0
  247. package/lang/translations/es-co.po +8 -0
  248. package/lang/translations/es.po +8 -0
  249. package/lang/translations/et.po +8 -0
  250. package/lang/translations/eu.po +8 -0
  251. package/lang/translations/fa.po +8 -0
  252. package/lang/translations/fi.po +8 -0
  253. package/lang/translations/fr.po +8 -0
  254. package/lang/translations/gl.po +8 -0
  255. package/lang/translations/gu.po +8 -0
  256. package/lang/translations/he.po +8 -0
  257. package/lang/translations/hi.po +8 -0
  258. package/lang/translations/hr.po +8 -0
  259. package/lang/translations/hu.po +8 -0
  260. package/lang/translations/hy.po +8 -0
  261. package/lang/translations/id.po +8 -0
  262. package/lang/translations/it.po +8 -0
  263. package/lang/translations/ja.po +8 -0
  264. package/lang/translations/jv.po +8 -0
  265. package/lang/translations/kk.po +8 -0
  266. package/lang/translations/km.po +8 -0
  267. package/lang/translations/kn.po +8 -0
  268. package/lang/translations/ko.po +8 -0
  269. package/lang/translations/ku.po +8 -0
  270. package/lang/translations/lt.po +8 -0
  271. package/lang/translations/lv.po +8 -0
  272. package/lang/translations/ms.po +8 -0
  273. package/lang/translations/nb.po +8 -0
  274. package/lang/translations/ne.po +8 -0
  275. package/lang/translations/nl.po +8 -0
  276. package/lang/translations/no.po +8 -0
  277. package/lang/translations/oc.po +8 -0
  278. package/lang/translations/pl.po +8 -0
  279. package/lang/translations/pt-br.po +8 -0
  280. package/lang/translations/pt.po +8 -0
  281. package/lang/translations/ro.po +8 -0
  282. package/lang/translations/ru.po +8 -0
  283. package/lang/translations/si.po +8 -0
  284. package/lang/translations/sk.po +8 -0
  285. package/lang/translations/sl.po +8 -0
  286. package/lang/translations/sq.po +8 -0
  287. package/lang/translations/sr-latn.po +8 -0
  288. package/lang/translations/sr.po +8 -0
  289. package/lang/translations/sv.po +8 -0
  290. package/lang/translations/th.po +8 -0
  291. package/lang/translations/ti.po +8 -0
  292. package/lang/translations/tk.po +8 -0
  293. package/lang/translations/tr.po +8 -0
  294. package/lang/translations/tt.po +8 -0
  295. package/lang/translations/ug.po +8 -0
  296. package/lang/translations/uk.po +8 -0
  297. package/lang/translations/ur.po +8 -0
  298. package/lang/translations/uz.po +8 -0
  299. package/lang/translations/vi.po +8 -0
  300. package/lang/translations/zh-cn.po +8 -0
  301. package/lang/translations/zh.po +8 -0
  302. package/package.json +13 -12
  303. package/src/autoimage.js +10 -0
  304. package/src/image/imagetypecommand.js +4 -0
  305. package/src/imagecaption/imagecaptionediting.js +7 -0
  306. package/src/imagecaption/imagecaptionui.js +3 -2
  307. package/src/imageinsert/imageinsertui.js +11 -6
  308. package/src/imageinsert/imageinsertviaurlui.js +7 -6
  309. package/src/imageinsert/ui/imageinsertformview.js +20 -0
  310. package/src/imageinsert/ui/imageinserturlview.js +8 -0
  311. package/src/imageresize/imagecustomresizeui.js +8 -5
  312. package/src/imageresize/imageresizebuttons.d.ts +3 -0
  313. package/src/imageresize/imageresizebuttons.js +21 -13
  314. package/src/imageresize/resizeimagecommand.d.ts +1 -1
  315. package/src/imageresize/ui/imagecustomresizeformview.d.ts +19 -12
  316. package/src/imageresize/ui/imagecustomresizeformview.js +112 -36
  317. package/src/imagestyle/imagestylecommand.js +10 -0
  318. package/src/imagestyle/imagestyleediting.js +12 -0
  319. package/src/imagestyle/imagestyleui.js +1 -1
  320. package/src/imagestyle/utils.d.ts +1 -4
  321. package/src/imagestyle/utils.js +16 -16
  322. package/src/imagetextalternative/imagetextalternativeui.js +11 -7
  323. package/src/imagetextalternative/ui/textalternativeformview.d.ts +17 -10
  324. package/src/imagetextalternative/ui/textalternativeformview.js +105 -35
  325. package/src/imagetoolbar.js +1 -1
  326. package/src/imageupload/imageuploadediting.js +17 -7
  327. package/src/imageupload/imageuploadprogress.js +59 -53
  328. package/src/imageupload/imageuploadui.js +3 -2
  329. package/src/imageutils.js +4 -7
  330. package/theme/imagecustomresizeform.css +0 -29
  331. package/theme/textalternativeform.css +0 -28
package/dist/index.js CHANGED
@@ -2,16 +2,17 @@
2
2
  * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
- import { Plugin, Command, icons } from '@ckeditor/ckeditor5-core/dist/index.js';
5
+ import { Plugin, Command } from '@ckeditor/ckeditor5-core/dist/index.js';
6
6
  import { Clipboard, ClipboardPipeline } from '@ckeditor/ckeditor5-clipboard/dist/index.js';
7
7
  import { LivePosition, LiveRange, Observer, UpcastWriter, enablePlaceholder, Element } from '@ckeditor/ckeditor5-engine/dist/index.js';
8
8
  import { Undo } from '@ckeditor/ckeditor5-undo/dist/index.js';
9
9
  import { Delete } from '@ckeditor/ckeditor5-typing/dist/index.js';
10
10
  import { first, DomEmitterMixin, global, FocusTracker, KeystrokeHandler, logWarning, toArray, env, CKEditorError, Collection, Rect } from '@ckeditor/ckeditor5-utils/dist/index.js';
11
11
  import { toWidget, isWidget, findOptimalInsertionRange, Widget, toWidgetEditable, WidgetResize, calculateResizeHostAncestorWidth, WidgetToolbarRepository } from '@ckeditor/ckeditor5-widget/dist/index.js';
12
- import { View, ViewCollection, FocusCycler, submitHandler, ButtonView, LabeledFieldView, createLabeledInputText, BalloonPanelView, ContextualBalloon, CssTransitionDisablerMixin, clickOutsideHandler, CollapsibleView, SplitButtonView, createDropdown, MenuBarMenuView, MenuBarMenuListView, MenuBarMenuListItemView, FileDialogButtonView, MenuBarMenuListItemFileDialogButtonView, Notification, Dialog, MenuBarMenuListItemButtonView, ViewModel, DropdownButtonView, addListToDropdown, createLabeledInputNumber, addToolbarToDropdown } from '@ckeditor/ckeditor5-ui/dist/index.js';
12
+ import { View, FormRowView, ViewCollection, FocusCycler, submitHandler, ButtonView, FormHeaderView, LabeledFieldView, createLabeledInputText, BalloonPanelView, ContextualBalloon, CssTransitionDisablerMixin, clickOutsideHandler, CollapsibleView, SplitButtonView, createDropdown, MenuBarMenuView, MenuBarMenuListView, MenuBarMenuListItemView, FileDialogButtonView, MenuBarMenuListItemFileDialogButtonView, Notification, Dialog, MenuBarMenuListItemButtonView, ViewModel, DropdownButtonView, addListToDropdown, createLabeledInputNumber, addToolbarToDropdown } from '@ckeditor/ckeditor5-ui/dist/index.js';
13
+ import { IconPreviousArrow, IconTextAlternative, IconImage, IconCaption, IconImageUpload, IconImageUrl, IconObjectSizeFull, IconObjectSizeCustom, IconObjectSizeLarge, IconObjectSizeMedium, IconObjectSizeSmall, IconObjectInline, IconObjectInlineRight, IconObjectInlineLeft, IconObjectCenter, IconObjectRight, IconObjectLeft, IconObjectFullWidth } from '@ckeditor/ckeditor5-icons/dist/index.js';
13
14
  import { FileRepository } from '@ckeditor/ckeditor5-upload/dist/index.js';
14
- import { map, isObject, identity } from 'lodash-es';
15
+ import { isObject, identity } from 'es-toolkit/compat';
15
16
 
16
17
  /**
17
18
  * Creates a view element representing the inline image.
@@ -623,12 +624,15 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
623
624
  /**
624
625
  * An input with a label.
625
626
  */ labeledInput;
627
+ /**
628
+ * The Back button view displayed in the header.
629
+ */ backButtonView;
626
630
  /**
627
631
  * A button used to submit the form.
628
632
  */ saveButtonView;
629
633
  /**
630
- * A button used to cancel the form.
631
- */ cancelButtonView;
634
+ * A collection of child views.
635
+ */ children;
632
636
  /**
633
637
  * A collection of views which can be focused in the form.
634
638
  */ _focusables;
@@ -639,14 +643,32 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
639
643
  * @inheritDoc
640
644
  */ constructor(locale){
641
645
  super(locale);
642
- const t = this.locale.t;
643
646
  this.focusTracker = new FocusTracker();
644
647
  this.keystrokes = new KeystrokeHandler();
648
+ // Create buttons.
649
+ this.backButtonView = this._createBackButton();
650
+ this.saveButtonView = this._createSaveButton();
651
+ // Create input fields.
645
652
  this.labeledInput = this._createLabeledInputView();
646
- this.saveButtonView = this._createButton(t('Save'), icons.check, 'ck-button-save');
647
- this.saveButtonView.type = 'submit';
648
- this.cancelButtonView = this._createButton(t('Cancel'), icons.cancel, 'ck-button-cancel', 'cancel');
653
+ this.children = this.createCollection([
654
+ this._createHeaderView()
655
+ ]);
656
+ this.children.add(new FormRowView(locale, {
657
+ children: [
658
+ this.labeledInput,
659
+ this.saveButtonView
660
+ ],
661
+ class: [
662
+ 'ck-form__row_with-submit',
663
+ 'ck-form__row_large-top-padding'
664
+ ]
665
+ }));
649
666
  this._focusables = new ViewCollection();
667
+ // Close the panel on esc key press when the **form has focus**.
668
+ this.keystrokes.set('Esc', (data, cancel)=>{
669
+ this.fire('cancel');
670
+ cancel();
671
+ });
650
672
  this._focusCycler = new FocusCycler({
651
673
  focusables: this._focusables,
652
674
  focusTracker: this.focusTracker,
@@ -663,37 +685,35 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
663
685
  attributes: {
664
686
  class: [
665
687
  'ck',
688
+ 'ck-form',
666
689
  'ck-text-alternative-form',
667
690
  'ck-responsive-form'
668
691
  ],
669
692
  // https://github.com/ckeditor/ckeditor5-image/issues/40
670
693
  tabindex: '-1'
671
694
  },
672
- children: [
673
- this.labeledInput,
674
- this.saveButtonView,
675
- this.cancelButtonView
676
- ]
695
+ children: this.children
677
696
  });
678
697
  }
679
698
  /**
680
699
  * @inheritDoc
681
700
  */ render() {
682
701
  super.render();
683
- this.keystrokes.listenTo(this.element);
684
702
  submitHandler({
685
703
  view: this
686
704
  });
687
- [
705
+ const childViews = [
706
+ this.backButtonView,
688
707
  this.labeledInput,
689
- this.saveButtonView,
690
- this.cancelButtonView
691
- ].forEach((v)=>{
708
+ this.saveButtonView
709
+ ];
710
+ childViews.forEach((v)=>{
692
711
  // Register the view as focusable.
693
712
  this._focusables.add(v);
694
713
  // Register the view in the focus tracker.
695
714
  this.focusTracker.add(v.element);
696
715
  });
716
+ this.keystrokes.listenTo(this.element);
697
717
  }
698
718
  /**
699
719
  * @inheritDoc
@@ -703,29 +723,41 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
703
723
  this.keystrokes.destroy();
704
724
  }
705
725
  /**
706
- * Creates the button view.
707
- *
708
- * @param label The button label
709
- * @param icon The button's icon.
710
- * @param className The additional button CSS class name.
711
- * @param eventName The event name that the ButtonView#execute event will be delegated to.
712
- * @returns The button view instance.
713
- */ _createButton(label, icon, className, eventName) {
714
- const button = new ButtonView(this.locale);
715
- button.set({
716
- label,
717
- icon,
726
+ * Creates a back button view that cancels the form.
727
+ */ _createBackButton() {
728
+ const t = this.locale.t;
729
+ const backButton = new ButtonView(this.locale);
730
+ backButton.set({
731
+ class: 'ck-button-back',
732
+ label: t('Back'),
733
+ icon: IconPreviousArrow,
718
734
  tooltip: true
719
735
  });
720
- button.extendTemplate({
721
- attributes: {
722
- class: className
723
- }
736
+ backButton.delegate('execute').to(this, 'cancel');
737
+ return backButton;
738
+ }
739
+ /**
740
+ * Creates a save button view that text alternative the image.
741
+ */ _createSaveButton() {
742
+ const t = this.locale.t;
743
+ const saveButton = new ButtonView(this.locale);
744
+ saveButton.set({
745
+ label: t('Save'),
746
+ withText: true,
747
+ type: 'submit',
748
+ class: 'ck-button-action ck-button-bold'
724
749
  });
725
- if (eventName) {
726
- button.delegate('execute').to(this, eventName);
727
- }
728
- return button;
750
+ return saveButton;
751
+ }
752
+ /**
753
+ * Creates a header view for the form.
754
+ */ _createHeaderView() {
755
+ const t = this.locale.t;
756
+ const header = new FormHeaderView(this.locale, {
757
+ label: t('Text Alternative')
758
+ });
759
+ header.children.add(this.backButtonView, 0);
760
+ return header;
729
761
  }
730
762
  /**
731
763
  * Creates an input with a label.
@@ -735,6 +767,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
735
767
  const t = this.locale.t;
736
768
  const labeledInput = new LabeledFieldView(this.locale, createLabeledInputText);
737
769
  labeledInput.label = t('Text alternative');
770
+ labeledInput.class = 'ck-labeled-field-view_full-width';
738
771
  return labeledInput;
739
772
  }
740
773
  }
@@ -830,7 +863,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
830
863
  const view = new ButtonView(locale);
831
864
  view.set({
832
865
  label: t('Change image text alternative'),
833
- icon: icons.textAlternative,
866
+ icon: IconTextAlternative,
834
867
  tooltip: true
835
868
  });
836
869
  view.bind('isEnabled').to(command, 'isEnabled');
@@ -862,11 +895,6 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
862
895
  this.listenTo(this._form, 'cancel', ()=>{
863
896
  this._hideForm(true);
864
897
  });
865
- // Close the form on Esc key press.
866
- this._form.keystrokes.set('Esc', (data, cancel)=>{
867
- this._hideForm(true);
868
- cancel();
869
- });
870
898
  // Reposition the balloon or hide the form if an image widget is no longer selected.
871
899
  this.listenTo(editor.ui, 'update', ()=>{
872
900
  if (!imageUtils.getClosestSelectedImageWidget(viewDocument.selection)) {
@@ -2194,7 +2222,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
2194
2222
  const listView = new MenuBarMenuListView(locale);
2195
2223
  resultView.panelView.children.add(listView);
2196
2224
  resultView.buttonView.set({
2197
- icon: icons.image,
2225
+ icon: IconImage,
2198
2226
  label: t('Image')
2199
2227
  });
2200
2228
  for (const integrationView of integrationViews){
@@ -2956,7 +2984,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
2956
2984
  const command = editor.commands.get('toggleImageCaption');
2957
2985
  const view = new ButtonView(locale);
2958
2986
  view.set({
2959
- icon: icons.caption,
2987
+ icon: IconCaption,
2960
2988
  tooltip: true,
2961
2989
  isToggleable: true
2962
2990
  });
@@ -3164,7 +3192,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
3164
3192
  acceptedType: imageTypes.map((type)=>`image/${type}`).join(','),
3165
3193
  allowMultipleFiles: true,
3166
3194
  label: t('Upload from computer'),
3167
- icon: icons.imageUpload
3195
+ icon: IconImageUpload
3168
3196
  });
3169
3197
  view.bind('isEnabled').to(command);
3170
3198
  view.on('done', (evt, files)=>{
@@ -4179,7 +4207,7 @@ function getImagesFromChangeItem(editor, item) {
4179
4207
  * Creates the base for various kinds of the button component provided by this feature.
4180
4208
  */ _createInsertUrlButton(ButtonClass) {
4181
4209
  const button = new ButtonClass(this.editor.locale);
4182
- button.icon = icons.imageUrl;
4210
+ button.icon = IconImageUrl;
4183
4211
  button.on('execute', ()=>{
4184
4212
  this._showModal();
4185
4213
  });
@@ -4252,7 +4280,7 @@ function getImagesFromChangeItem(editor, item) {
4252
4280
  this._formView.imageURLInputValue = replaceImageSourceCommand.value || '';
4253
4281
  dialog.show({
4254
4282
  id: 'insertImageViaUrl',
4255
- title: this._imageInsertUI.isImageSelected ? t('Update image URL') : t('Insert image via URL'),
4283
+ title: t('Image via URL'),
4256
4284
  isModal: true,
4257
4285
  content: this._formView,
4258
4286
  actionButtons: [
@@ -4262,7 +4290,7 @@ function getImagesFromChangeItem(editor, item) {
4262
4290
  onExecute: ()=>dialog.hide()
4263
4291
  },
4264
4292
  {
4265
- label: t('Accept'),
4293
+ label: this._imageInsertUI.isImageSelected ? t('Save') : t('Insert'),
4266
4294
  class: 'ck-button-action',
4267
4295
  withText: true,
4268
4296
  onExecute: ()=>this._handleSave()
@@ -4582,11 +4610,11 @@ function getImagesFromChangeItem(editor, item) {
4582
4610
  }
4583
4611
 
4584
4612
  const RESIZE_ICONS = /* #__PURE__ */ (()=>({
4585
- small: icons.objectSizeSmall,
4586
- medium: icons.objectSizeMedium,
4587
- large: icons.objectSizeLarge,
4588
- custom: icons.objectSizeCustom,
4589
- original: icons.objectSizeFull
4613
+ small: IconObjectSizeSmall,
4614
+ medium: IconObjectSizeMedium,
4615
+ large: IconObjectSizeLarge,
4616
+ custom: IconObjectSizeCustom,
4617
+ original: IconObjectSizeFull
4590
4618
  }))();
4591
4619
  /**
4592
4620
  * The image resize buttons plugin.
@@ -4671,7 +4699,7 @@ const RESIZE_ICONS = /* #__PURE__ */ (()=>({
4671
4699
  });
4672
4700
  } else {
4673
4701
  const optionValueWithUnit = value ? value + this._resizeUnit : null;
4674
- button.bind('isOn').to(command, 'value', getIsOnButtonCallback(optionValueWithUnit));
4702
+ button.bind('isOn').to(command, 'value', command, 'isEnabled', getIsOnButtonCallback(optionValueWithUnit));
4675
4703
  this.listenTo(button, 'execute', ()=>{
4676
4704
  editor.execute('resizeImage', {
4677
4705
  width: optionValueWithUnit
@@ -4807,8 +4835,8 @@ const RESIZE_ICONS = /* #__PURE__ */ (()=>({
4807
4835
  }
4808
4836
  })
4809
4837
  };
4810
- const allDropdownValues = map(optionsWithSerializedValues, 'valueWithUnits');
4811
- definition.model.bind('isOn').to(command, 'value', getIsOnCustomButtonCallback(allDropdownValues));
4838
+ const allDropdownValues = Object.values(optionsWithSerializedValues).map((option)=>option.valueWithUnits);
4839
+ definition.model.bind('isOn').to(command, 'value', command, 'isEnabled', getIsOnCustomButtonCallback(allDropdownValues));
4812
4840
  } else {
4813
4841
  definition = {
4814
4842
  type: 'button',
@@ -4821,7 +4849,7 @@ const RESIZE_ICONS = /* #__PURE__ */ (()=>({
4821
4849
  icon: null
4822
4850
  })
4823
4851
  };
4824
- definition.model.bind('isOn').to(command, 'value', getIsOnButtonCallback(option.valueWithUnits));
4852
+ definition.model.bind('isOn').to(command, 'value', command, 'isEnabled', getIsOnButtonCallback(option.valueWithUnits));
4825
4853
  }
4826
4854
  definition.model.bind('isEnabled').to(command, 'isEnabled');
4827
4855
  itemDefinitions.add(definition);
@@ -4837,8 +4865,11 @@ const RESIZE_ICONS = /* #__PURE__ */ (()=>({
4837
4865
  /**
4838
4866
  * A helper function for setting the `isOn` state of buttons in value bindings.
4839
4867
  */ function getIsOnButtonCallback(value) {
4840
- return (commandValue)=>{
4868
+ return (commandValue, isEnabled)=>{
4841
4869
  const objectCommandValue = commandValue;
4870
+ if (objectCommandValue === undefined || !isEnabled) {
4871
+ return false;
4872
+ }
4842
4873
  if (value === null && objectCommandValue === value) {
4843
4874
  return true;
4844
4875
  }
@@ -4848,7 +4879,7 @@ const RESIZE_ICONS = /* #__PURE__ */ (()=>({
4848
4879
  /**
4849
4880
  * A helper function for setting the `isOn` state of custom size button in value bindings.
4850
4881
  */ function getIsOnCustomButtonCallback(allDropdownValues) {
4851
- return (commandValue)=>!allDropdownValues.some((dropdownValue)=>getIsOnButtonCallback(dropdownValue)(commandValue));
4882
+ return (commandValue, isEnabled)=>!allDropdownValues.some((dropdownValue)=>getIsOnButtonCallback(dropdownValue)(commandValue, isEnabled));
4852
4883
  }
4853
4884
 
4854
4885
  const RESIZABLE_IMAGES_CSS_SELECTOR = 'figure.image.ck-widget > img,' + 'figure.image.ck-widget > picture > img,' + 'figure.image.ck-widget > a > img,' + 'figure.image.ck-widget > a > picture > img,' + 'span.image-inline.ck-widget > img,' + 'span.image-inline.ck-widget > picture > img';
@@ -5074,14 +5105,17 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5074
5105
  * Resize unit shortcut.
5075
5106
  */ unit;
5076
5107
  /**
5077
- * An input with a label.
5078
- */ labeledInput;
5108
+ * The Back button view displayed in the header.
5109
+ */ backButtonView;
5079
5110
  /**
5080
5111
  * A button used to submit the form.
5081
5112
  */ saveButtonView;
5082
5113
  /**
5083
- * A button used to cancel the form.
5084
- */ cancelButtonView;
5114
+ * An input with a label.
5115
+ */ labeledInput;
5116
+ /**
5117
+ * A collection of child views.
5118
+ */ children;
5085
5119
  /**
5086
5120
  * A collection of views which can be focused in the form.
5087
5121
  */ _focusables;
@@ -5095,16 +5129,34 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5095
5129
  * @inheritDoc
5096
5130
  */ constructor(locale, unit, validators){
5097
5131
  super(locale);
5098
- const t = this.locale.t;
5099
5132
  this.focusTracker = new FocusTracker();
5100
5133
  this.keystrokes = new KeystrokeHandler();
5101
5134
  this.unit = unit;
5135
+ // Create buttons.
5136
+ this.backButtonView = this._createBackButton();
5137
+ this.saveButtonView = this._createSaveButton();
5138
+ // Create input fields.
5102
5139
  this.labeledInput = this._createLabeledInputView();
5103
- this.saveButtonView = this._createButton(t('Save'), icons.check, 'ck-button-save');
5104
- this.saveButtonView.type = 'submit';
5105
- this.cancelButtonView = this._createButton(t('Cancel'), icons.cancel, 'ck-button-cancel', 'cancel');
5140
+ this.children = this.createCollection([
5141
+ this._createHeaderView()
5142
+ ]);
5143
+ this.children.add(new FormRowView(locale, {
5144
+ children: [
5145
+ this.labeledInput,
5146
+ this.saveButtonView
5147
+ ],
5148
+ class: [
5149
+ 'ck-form__row_with-submit',
5150
+ 'ck-form__row_large-top-padding'
5151
+ ]
5152
+ }));
5106
5153
  this._focusables = new ViewCollection();
5107
5154
  this._validators = validators;
5155
+ // Close the panel on esc key press when the **form has focus**.
5156
+ this.keystrokes.set('Esc', (data, cancel)=>{
5157
+ this.fire('cancel');
5158
+ cancel();
5159
+ });
5108
5160
  this._focusCycler = new FocusCycler({
5109
5161
  focusables: this._focusables,
5110
5162
  focusTracker: this.focusTracker,
@@ -5121,37 +5173,35 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5121
5173
  attributes: {
5122
5174
  class: [
5123
5175
  'ck',
5176
+ 'ck-form',
5124
5177
  'ck-image-custom-resize-form',
5125
5178
  'ck-responsive-form'
5126
5179
  ],
5127
5180
  // https://github.com/ckeditor/ckeditor5-image/issues/40
5128
5181
  tabindex: '-1'
5129
5182
  },
5130
- children: [
5131
- this.labeledInput,
5132
- this.saveButtonView,
5133
- this.cancelButtonView
5134
- ]
5183
+ children: this.children
5135
5184
  });
5136
5185
  }
5137
5186
  /**
5138
5187
  * @inheritDoc
5139
5188
  */ render() {
5140
5189
  super.render();
5141
- this.keystrokes.listenTo(this.element);
5142
5190
  submitHandler({
5143
5191
  view: this
5144
5192
  });
5145
- [
5193
+ const childViews = [
5194
+ this.backButtonView,
5146
5195
  this.labeledInput,
5147
- this.saveButtonView,
5148
- this.cancelButtonView
5149
- ].forEach((v)=>{
5196
+ this.saveButtonView
5197
+ ];
5198
+ childViews.forEach((v)=>{
5150
5199
  // Register the view as focusable.
5151
5200
  this._focusables.add(v);
5152
5201
  // Register the view in the focus tracker.
5153
5202
  this.focusTracker.add(v.element);
5154
5203
  });
5204
+ this.keystrokes.listenTo(this.element);
5155
5205
  }
5156
5206
  /**
5157
5207
  * @inheritDoc
@@ -5161,29 +5211,41 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5161
5211
  this.keystrokes.destroy();
5162
5212
  }
5163
5213
  /**
5164
- * Creates the button view.
5165
- *
5166
- * @param label The button label
5167
- * @param icon The button's icon.
5168
- * @param className The additional button CSS class name.
5169
- * @param eventName The event name that the ButtonView#execute event will be delegated to.
5170
- * @returns The button view instance.
5171
- */ _createButton(label, icon, className, eventName) {
5172
- const button = new ButtonView(this.locale);
5173
- button.set({
5174
- label,
5175
- icon,
5214
+ * Creates a back button view that cancels the form.
5215
+ */ _createBackButton() {
5216
+ const t = this.locale.t;
5217
+ const backButton = new ButtonView(this.locale);
5218
+ backButton.set({
5219
+ class: 'ck-button-back',
5220
+ label: t('Back'),
5221
+ icon: IconPreviousArrow,
5176
5222
  tooltip: true
5177
5223
  });
5178
- button.extendTemplate({
5179
- attributes: {
5180
- class: className
5181
- }
5224
+ backButton.delegate('execute').to(this, 'cancel');
5225
+ return backButton;
5226
+ }
5227
+ /**
5228
+ * Creates a save button view that resize the image.
5229
+ */ _createSaveButton() {
5230
+ const t = this.locale.t;
5231
+ const saveButton = new ButtonView(this.locale);
5232
+ saveButton.set({
5233
+ label: t('Save'),
5234
+ withText: true,
5235
+ type: 'submit',
5236
+ class: 'ck-button-action ck-button-bold'
5182
5237
  });
5183
- if (eventName) {
5184
- button.delegate('execute').to(this, eventName);
5185
- }
5186
- return button;
5238
+ return saveButton;
5239
+ }
5240
+ /**
5241
+ * Creates a header view for the form.
5242
+ */ _createHeaderView() {
5243
+ const t = this.locale.t;
5244
+ const header = new FormHeaderView(this.locale, {
5245
+ label: t('Image Resize')
5246
+ });
5247
+ header.children.add(this.backButtonView, 0);
5248
+ return header;
5187
5249
  }
5188
5250
  /**
5189
5251
  * Creates an input with a label.
@@ -5193,6 +5255,7 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5193
5255
  const t = this.locale.t;
5194
5256
  const labeledInput = new LabeledFieldView(this.locale, createLabeledInputNumber);
5195
5257
  labeledInput.label = t('Resize image (in %0)', this.unit);
5258
+ labeledInput.class = 'ck-labeled-field-view_full-width';
5196
5259
  labeledInput.fieldView.set({
5197
5260
  step: 0.1
5198
5261
  });
@@ -5339,11 +5402,6 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5339
5402
  this.listenTo(this._form, 'cancel', ()=>{
5340
5403
  this._hideForm(true);
5341
5404
  });
5342
- // Close the form on Esc key press.
5343
- this._form.keystrokes.set('Esc', (data, cancel)=>{
5344
- this._hideForm(true);
5345
- cancel();
5346
- });
5347
5405
  // Close on click outside of balloon panel element.
5348
5406
  clickOutsideHandler({
5349
5407
  emitter: this._form,
@@ -5597,7 +5655,7 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5597
5655
  return {
5598
5656
  name: 'inline',
5599
5657
  title: 'In line',
5600
- icon: icons.objectInline,
5658
+ icon: IconObjectInline,
5601
5659
  modelElements: [
5602
5660
  'imageInline'
5603
5661
  ],
@@ -5609,7 +5667,7 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5609
5667
  return {
5610
5668
  name: 'alignLeft',
5611
5669
  title: 'Left aligned image',
5612
- icon: icons.objectLeft,
5670
+ icon: IconObjectInlineLeft,
5613
5671
  modelElements: [
5614
5672
  'imageBlock',
5615
5673
  'imageInline'
@@ -5622,7 +5680,7 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5622
5680
  return {
5623
5681
  name: 'alignBlockLeft',
5624
5682
  title: 'Left aligned image',
5625
- icon: icons.objectBlockLeft,
5683
+ icon: IconObjectLeft,
5626
5684
  modelElements: [
5627
5685
  'imageBlock'
5628
5686
  ],
@@ -5634,7 +5692,7 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5634
5692
  return {
5635
5693
  name: 'alignCenter',
5636
5694
  title: 'Centered image',
5637
- icon: icons.objectCenter,
5695
+ icon: IconObjectCenter,
5638
5696
  modelElements: [
5639
5697
  'imageBlock'
5640
5698
  ],
@@ -5646,7 +5704,7 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5646
5704
  return {
5647
5705
  name: 'alignRight',
5648
5706
  title: 'Right aligned image',
5649
- icon: icons.objectRight,
5707
+ icon: IconObjectInlineRight,
5650
5708
  modelElements: [
5651
5709
  'imageBlock',
5652
5710
  'imageInline'
@@ -5659,7 +5717,7 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5659
5717
  return {
5660
5718
  name: 'alignBlockRight',
5661
5719
  title: 'Right aligned image',
5662
- icon: icons.objectBlockRight,
5720
+ icon: IconObjectRight,
5663
5721
  modelElements: [
5664
5722
  'imageBlock'
5665
5723
  ],
@@ -5671,7 +5729,7 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5671
5729
  return {
5672
5730
  name: 'block',
5673
5731
  title: 'Centered image',
5674
- icon: icons.objectCenter,
5732
+ icon: IconObjectCenter,
5675
5733
  modelElements: [
5676
5734
  'imageBlock'
5677
5735
  ],
@@ -5683,7 +5741,7 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5683
5741
  return {
5684
5742
  name: 'side',
5685
5743
  title: 'Side image',
5686
- icon: icons.objectRight,
5744
+ icon: IconObjectInlineRight,
5687
5745
  modelElements: [
5688
5746
  'imageBlock'
5689
5747
  ],
@@ -5699,13 +5757,13 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5699
5757
  *
5700
5758
  * There are 7 default icons available: `'full'`, `'left'`, `'inlineLeft'`, `'center'`, `'right'`, `'inlineRight'`, and `'inline'`.
5701
5759
  */ const DEFAULT_ICONS = /* #__PURE__ */ (()=>({
5702
- full: icons.objectFullWidth,
5703
- left: icons.objectBlockLeft,
5704
- right: icons.objectBlockRight,
5705
- center: icons.objectCenter,
5706
- inlineLeft: icons.objectLeft,
5707
- inlineRight: icons.objectRight,
5708
- inline: icons.objectInline
5760
+ full: IconObjectFullWidth,
5761
+ left: IconObjectLeft,
5762
+ right: IconObjectRight,
5763
+ center: IconObjectCenter,
5764
+ inlineLeft: IconObjectInlineLeft,
5765
+ inlineRight: IconObjectInlineRight,
5766
+ inline: IconObjectInline
5709
5767
  }))();
5710
5768
  /**
5711
5769
  * Default drop-downs provided by the plugin that can be referred in the {@link module:image/imageconfig~ImageConfig#toolbar}