@ckeditor/ckeditor5-image 34.2.0 → 35.1.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 (143) hide show
  1. package/CHANGELOG.md +423 -0
  2. package/LICENSE.md +4 -0
  3. package/build/image.js +2 -2
  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/bg.js +1 -1
  8. package/build/translations/bn.js +1 -0
  9. package/build/translations/bs.js +1 -1
  10. package/build/translations/ca.js +1 -0
  11. package/build/translations/cs.js +1 -1
  12. package/build/translations/da.js +1 -1
  13. package/build/translations/de-ch.js +1 -1
  14. package/build/translations/de.js +1 -1
  15. package/build/translations/el.js +1 -1
  16. package/build/translations/en-au.js +1 -1
  17. package/build/translations/en-gb.js +1 -1
  18. package/build/translations/eo.js +1 -1
  19. package/build/translations/es.js +1 -1
  20. package/build/translations/et.js +1 -1
  21. package/build/translations/eu.js +1 -1
  22. package/build/translations/fa.js +1 -1
  23. package/build/translations/fi.js +1 -1
  24. package/build/translations/fr.js +1 -1
  25. package/build/translations/gl.js +1 -1
  26. package/build/translations/he.js +1 -1
  27. package/build/translations/hi.js +1 -1
  28. package/build/translations/hr.js +1 -1
  29. package/build/translations/hu.js +1 -1
  30. package/build/translations/id.js +1 -1
  31. package/build/translations/it.js +1 -1
  32. package/build/translations/ja.js +1 -1
  33. package/build/translations/jv.js +1 -1
  34. package/build/translations/km.js +1 -1
  35. package/build/translations/kn.js +1 -1
  36. package/build/translations/ko.js +1 -1
  37. package/build/translations/ku.js +1 -1
  38. package/build/translations/lt.js +1 -1
  39. package/build/translations/lv.js +1 -1
  40. package/build/translations/ms.js +1 -0
  41. package/build/translations/nb.js +1 -1
  42. package/build/translations/ne.js +1 -1
  43. package/build/translations/nl.js +1 -1
  44. package/build/translations/no.js +1 -1
  45. package/build/translations/pl.js +1 -1
  46. package/build/translations/pt-br.js +1 -1
  47. package/build/translations/pt.js +1 -1
  48. package/build/translations/ro.js +1 -1
  49. package/build/translations/ru.js +1 -1
  50. package/build/translations/si.js +1 -1
  51. package/build/translations/sk.js +1 -1
  52. package/build/translations/sq.js +1 -1
  53. package/build/translations/sr-latn.js +1 -1
  54. package/build/translations/sr.js +1 -1
  55. package/build/translations/sv.js +1 -1
  56. package/build/translations/th.js +1 -1
  57. package/build/translations/tk.js +1 -1
  58. package/build/translations/tr.js +1 -1
  59. package/build/translations/tt.js +1 -0
  60. package/build/translations/ug.js +1 -1
  61. package/build/translations/uk.js +1 -1
  62. package/build/translations/ur.js +1 -1
  63. package/build/translations/uz.js +1 -1
  64. package/build/translations/vi.js +1 -1
  65. package/build/translations/zh-cn.js +1 -1
  66. package/build/translations/zh.js +1 -1
  67. package/lang/contexts.json +3 -1
  68. package/lang/translations/ar.po +21 -13
  69. package/lang/translations/ast.po +8 -0
  70. package/lang/translations/az.po +8 -0
  71. package/lang/translations/bg.po +30 -22
  72. package/lang/translations/bn.po +121 -0
  73. package/lang/translations/bs.po +8 -0
  74. package/lang/translations/ca.po +121 -0
  75. package/lang/translations/cs.po +8 -0
  76. package/lang/translations/da.po +20 -12
  77. package/lang/translations/de-ch.po +8 -0
  78. package/lang/translations/de.po +8 -0
  79. package/lang/translations/el.po +8 -0
  80. package/lang/translations/en-au.po +8 -0
  81. package/lang/translations/en-gb.po +8 -0
  82. package/lang/translations/en.po +8 -0
  83. package/lang/translations/eo.po +8 -0
  84. package/lang/translations/es.po +8 -0
  85. package/lang/translations/et.po +20 -12
  86. package/lang/translations/eu.po +8 -0
  87. package/lang/translations/fa.po +8 -0
  88. package/lang/translations/fi.po +21 -13
  89. package/lang/translations/fr.po +11 -3
  90. package/lang/translations/gl.po +8 -0
  91. package/lang/translations/he.po +20 -12
  92. package/lang/translations/hi.po +11 -3
  93. package/lang/translations/hr.po +8 -0
  94. package/lang/translations/hu.po +8 -0
  95. package/lang/translations/id.po +8 -0
  96. package/lang/translations/it.po +8 -0
  97. package/lang/translations/ja.po +11 -3
  98. package/lang/translations/jv.po +8 -0
  99. package/lang/translations/km.po +8 -0
  100. package/lang/translations/kn.po +8 -0
  101. package/lang/translations/ko.po +15 -7
  102. package/lang/translations/ku.po +8 -0
  103. package/lang/translations/lt.po +21 -13
  104. package/lang/translations/lv.po +8 -0
  105. package/lang/translations/ms.po +121 -0
  106. package/lang/translations/nb.po +8 -0
  107. package/lang/translations/ne.po +8 -0
  108. package/lang/translations/nl.po +18 -10
  109. package/lang/translations/no.po +20 -12
  110. package/lang/translations/pl.po +12 -4
  111. package/lang/translations/pt-br.po +8 -0
  112. package/lang/translations/pt.po +24 -16
  113. package/lang/translations/ro.po +11 -3
  114. package/lang/translations/ru.po +8 -0
  115. package/lang/translations/si.po +8 -0
  116. package/lang/translations/sk.po +8 -0
  117. package/lang/translations/sq.po +8 -0
  118. package/lang/translations/sr-latn.po +8 -0
  119. package/lang/translations/sr.po +8 -0
  120. package/lang/translations/sv.po +21 -13
  121. package/lang/translations/th.po +20 -12
  122. package/lang/translations/tk.po +8 -0
  123. package/lang/translations/tr.po +15 -7
  124. package/lang/translations/tt.po +121 -0
  125. package/lang/translations/ug.po +8 -0
  126. package/lang/translations/uk.po +11 -3
  127. package/lang/translations/ur.po +8 -0
  128. package/lang/translations/uz.po +8 -0
  129. package/lang/translations/vi.po +11 -3
  130. package/lang/translations/zh-cn.po +8 -0
  131. package/lang/translations/zh.po +11 -3
  132. package/package.json +33 -32
  133. package/src/image/ui/utils.js +1 -1
  134. package/src/imagecaption/imagecaptionediting.js +40 -1
  135. package/src/imagecaption/imagecaptionui.js +2 -0
  136. package/src/imageinsert/imageinsertui.js +45 -21
  137. package/src/imageinsert/ui/imageinsertpanelview.js +1 -37
  138. package/src/imageinsert.js +2 -1
  139. package/src/imageinsertviaurl.js +40 -0
  140. package/src/imageresize/imageresizehandles.js +1 -1
  141. package/src/imagestyle/imagestyleui.js +7 -1
  142. package/src/imageupload/imageuploadui.js +2 -0
  143. package/src/imageutils.js +7 -1
@@ -7,8 +7,9 @@
7
7
  * @module image/imageinsert/imageinsertui
8
8
  */
9
9
 
10
- import { Plugin } from 'ckeditor5/src/core';
10
+ import { Plugin, icons } from 'ckeditor5/src/core';
11
11
  import ImageInsertPanelView from './ui/imageinsertpanelview';
12
+ import { SplitButtonView, createDropdown } from 'ckeditor5/src/ui';
12
13
  import { prepareIntegrations } from './utils';
13
14
 
14
15
  /**
@@ -54,41 +55,66 @@ export default class ImageInsertUI extends Plugin {
54
55
  */
55
56
  _createDropdownView( locale ) {
56
57
  const editor = this.editor;
57
- const imageInsertView = new ImageInsertPanelView( locale, prepareIntegrations( editor ) );
58
- const command = editor.commands.get( 'uploadImage' );
59
-
60
- const dropdownView = imageInsertView.dropdownView;
61
- const splitButtonView = dropdownView.buttonView;
62
-
63
- splitButtonView.actionView = editor.ui.componentFactory.create( 'uploadImage' );
64
- // After we replaced action button with `uploadImage` component,
65
- // we have lost a proper styling and some minor visual quirks have appeared.
66
- // Brining back original split button classes helps fix the button styling
67
- // See https://github.com/ckeditor/ckeditor5/issues/7986.
68
- splitButtonView.actionView.extendTemplate( {
58
+ const t = locale.t;
59
+
60
+ const uploadImageCommand = editor.commands.get( 'uploadImage' );
61
+ const insertImageCommand = editor.commands.get( 'insertImage' );
62
+
63
+ /**
64
+ * The dropdown view responsible for displaying the image insert UI.
65
+ *
66
+ * @member {module:ui/dropdown/dropdownview~DropdownView}
67
+ */
68
+ this.dropdownView = createDropdown( locale, uploadImageCommand ? SplitButtonView : undefined );
69
+
70
+ const buttonView = this.dropdownView.buttonView;
71
+ const panelView = this.dropdownView.panelView;
72
+
73
+ buttonView.set( {
74
+ label: t( 'Insert image' ),
75
+ icon: icons.image,
76
+ tooltip: true
77
+ } );
78
+
79
+ panelView.extendTemplate( {
69
80
  attributes: {
70
- class: 'ck ck-button ck-splitbutton__action'
81
+ class: 'ck-image-insert__panel'
71
82
  }
72
83
  } );
73
84
 
74
- return this._setUpDropdown( dropdownView, imageInsertView, command );
85
+ if ( uploadImageCommand ) {
86
+ const splitButtonView = this.dropdownView.buttonView;
87
+
88
+ splitButtonView.actionView = editor.ui.componentFactory.create( 'uploadImage' );
89
+ // After we replaced action button with `uploadImage` component,
90
+ // we have lost a proper styling and some minor visual quirks have appeared.
91
+ // Brining back original split button classes helps fix the button styling
92
+ // See https://github.com/ckeditor/ckeditor5/issues/7986.
93
+ splitButtonView.actionView.extendTemplate( {
94
+ attributes: {
95
+ class: 'ck ck-button ck-splitbutton__action'
96
+ }
97
+ } );
98
+ }
99
+
100
+ return this._setUpDropdown( uploadImageCommand || insertImageCommand );
75
101
  }
76
102
 
77
103
  /**
78
104
  * Sets up the dropdown view.
79
105
  *
80
- * @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView A dropdownView.
81
- * @param {module:image/imageinsert/ui/imageinsertpanelview~ImageInsertPanelView} imageInsertView An imageInsertView.
82
- * @param {module:core/command~Command} command An insertImage command
106
+ * @param {module:core/command~Command} command An uploadImage or insertImage command.
83
107
  *
84
108
  * @private
85
109
  * @returns {module:ui/dropdown/dropdownview~DropdownView}
86
110
  */
87
- _setUpDropdown( dropdownView, imageInsertView, command ) {
111
+ _setUpDropdown( command ) {
88
112
  const editor = this.editor;
89
113
  const t = editor.t;
114
+ const imageInsertView = new ImageInsertPanelView( editor.locale, prepareIntegrations( editor ) );
90
115
  const insertButtonView = imageInsertView.insertButtonView;
91
116
  const insertImageViaUrlForm = imageInsertView.getIntegration( 'insertImageViaUrl' );
117
+ const dropdownView = this.dropdownView;
92
118
  const panelView = dropdownView.panelView;
93
119
  const imageUtils = this.editor.plugins.get( 'ImageUtils' );
94
120
 
@@ -104,8 +130,6 @@ export default class ImageInsertUI extends Plugin {
104
130
  const selectedElement = editor.model.document.selection.getSelectedElement();
105
131
 
106
132
  if ( dropdownView.isOpen ) {
107
- imageInsertView.focus();
108
-
109
133
  if ( imageUtils.isImage( selectedElement ) ) {
110
134
  imageInsertView.imageURLInputValue = selectedElement.getAttribute( 'src' );
111
135
  insertButtonView.label = t( 'Update' );
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  import { icons } from 'ckeditor5/src/core';
11
- import { ButtonView, View, SplitButtonView, ViewCollection, submitHandler, createDropdown, FocusCycler } from 'ckeditor5/src/ui';
11
+ import { ButtonView, View, ViewCollection, submitHandler, FocusCycler } from 'ckeditor5/src/ui';
12
12
  import { Collection, FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils';
13
13
 
14
14
  import ImageInsertFormRowView from './imageinsertformrowview';
@@ -49,13 +49,6 @@ export default class ImageInsertPanelView extends View {
49
49
  */
50
50
  this.cancelButtonView = cancelButtonView;
51
51
 
52
- /**
53
- * The dropdown view.
54
- *
55
- * @member {module:ui/dropdown/dropdownview~DropdownView}
56
- */
57
- this.dropdownView = this._createDropdownView( locale );
58
-
59
52
  /**
60
53
  * The value of the URL input.
61
54
  *
@@ -223,35 +216,6 @@ export default class ImageInsertPanelView extends View {
223
216
  return this._integrations.find( integration => integration.name === name );
224
217
  }
225
218
 
226
- /**
227
- * Creates the dropdown view.
228
- *
229
- * @param {module:utils/locale~Locale} locale The localization services instance.
230
- *
231
- * @private
232
- * @returns {module:ui/dropdown/dropdownview~DropdownView}
233
- */
234
- _createDropdownView( locale ) {
235
- const t = locale.t;
236
- const dropdownView = createDropdown( locale, SplitButtonView );
237
- const splitButtonView = dropdownView.buttonView;
238
- const panelView = dropdownView.panelView;
239
-
240
- splitButtonView.set( {
241
- label: t( 'Insert image' ),
242
- icon: icons.image,
243
- tooltip: true
244
- } );
245
-
246
- panelView.extendTemplate( {
247
- attributes: {
248
- class: 'ck-image-insert__panel'
249
- }
250
- } );
251
-
252
- return dropdownView;
253
- }
254
-
255
219
  /**
256
220
  * Creates the following form controls:
257
221
  *
@@ -9,6 +9,7 @@
9
9
 
10
10
  import { Plugin } from 'ckeditor5/src/core';
11
11
  import ImageUpload from './imageupload';
12
+ import ImageInsertViaUrl from './imageinsertviaurl';
12
13
  import ImageInsertUI from './imageinsert/imageinsertui';
13
14
 
14
15
  /**
@@ -37,7 +38,7 @@ export default class ImageInsert extends Plugin {
37
38
  * @inheritDoc
38
39
  */
39
40
  static get requires() {
40
- return [ ImageUpload, ImageInsertUI ];
41
+ return [ ImageUpload, ImageInsertViaUrl, ImageInsertUI ];
41
42
  }
42
43
  }
43
44
 
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /**
7
+ * @module image/imageinsertviaurl
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+ import ImageInsertUI from './imageinsert/imageinsertui';
12
+
13
+ /**
14
+ * The image insert via URL plugin.
15
+ *
16
+ * For a detailed overview, check the {@glink features/images/image-upload/images-inserting#inserting-images-via-source-url
17
+ * Insert images via source URL} documentation.
18
+ *
19
+ * This plugin does not do anything directly, but it loads a set of specific plugins
20
+ * to enable image inserting via implemented integrations:
21
+ *
22
+ * * {@link module:image/imageinsert/imageinsertui~ImageInsertUI},
23
+ *
24
+ * @extends module:core/plugin~Plugin
25
+ */
26
+ export default class ImageInsertViaUrl extends Plugin {
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ static get pluginName() {
31
+ return 'ImageInsertViaUrl';
32
+ }
33
+
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ static get requires() {
38
+ return [ ImageInsertUI ];
39
+ }
40
+ }
@@ -104,7 +104,7 @@ export default class ImageResizeHandles extends Plugin {
104
104
  },
105
105
  getResizeHost() {
106
106
  // Return the model image element parent to avoid setting an inline element (<a>/<span>) as a resize host.
107
- return domConverter.viewToDom( mapper.toViewElement( imageModel.parent ) );
107
+ return domConverter.mapViewToDom( mapper.toViewElement( imageModel.parent ) );
108
108
  },
109
109
  // TODO consider other positions.
110
110
  isCentered() {
@@ -131,7 +131,7 @@ export default class ImageStyleUI extends Plugin {
131
131
  const splitButtonView = dropdownView.buttonView;
132
132
  const splitButtonViewArrow = splitButtonView.arrowView;
133
133
 
134
- addToolbarToDropdown( dropdownView, buttonViews );
134
+ addToolbarToDropdown( dropdownView, buttonViews, { enableActiveItemFocusOnDropdownOpen: true } );
135
135
 
136
136
  splitButtonView.set( {
137
137
  label: getDropdownButtonTitle( title, defaultButton.label ),
@@ -172,6 +172,12 @@ export default class ImageStyleUI extends Plugin {
172
172
  dropdownView.bind( 'isEnabled' )
173
173
  .toMany( buttonViews, 'isEnabled', ( ...areEnabled ) => areEnabled.some( identity ) );
174
174
 
175
+ // Focus the editable after executing the command.
176
+ // Overrides a default behaviour where the focus is moved to the dropdown button (#12125).
177
+ this.listenTo( dropdownView, 'execute', () => {
178
+ this.editor.editing.view.focus();
179
+ } );
180
+
175
181
  return dropdownView;
176
182
  } );
177
183
  }
@@ -59,6 +59,8 @@ export default class ImageUploadUI extends Plugin {
59
59
 
60
60
  if ( imagesToUpload.length ) {
61
61
  editor.execute( 'uploadImage', { file: imagesToUpload } );
62
+
63
+ editor.editing.view.focus();
62
64
  }
63
65
  } );
64
66
 
package/src/imageutils.js CHANGED
@@ -127,13 +127,19 @@ export default class ImageUtils extends Plugin {
127
127
  * @returns {module:engine/view/element~Element|null}
128
128
  */
129
129
  getClosestSelectedImageWidget( selection ) {
130
+ const selectionPosition = selection.getFirstPosition();
131
+
132
+ if ( !selectionPosition ) {
133
+ return null;
134
+ }
135
+
130
136
  const viewElement = selection.getSelectedElement();
131
137
 
132
138
  if ( viewElement && this.isImageWidget( viewElement ) ) {
133
139
  return viewElement;
134
140
  }
135
141
 
136
- let parent = selection.getFirstPosition().parent;
142
+ let parent = selectionPosition.parent;
137
143
 
138
144
  while ( parent ) {
139
145
  if ( parent.is( 'element' ) && this.isImageWidget( parent ) ) {