@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.
- package/CHANGELOG.md +423 -0
- package/LICENSE.md +4 -0
- package/build/image.js +2 -2
- package/build/translations/ar.js +1 -1
- package/build/translations/ast.js +1 -1
- package/build/translations/az.js +1 -1
- package/build/translations/bg.js +1 -1
- package/build/translations/bn.js +1 -0
- package/build/translations/bs.js +1 -1
- package/build/translations/ca.js +1 -0
- package/build/translations/cs.js +1 -1
- package/build/translations/da.js +1 -1
- package/build/translations/de-ch.js +1 -1
- package/build/translations/de.js +1 -1
- package/build/translations/el.js +1 -1
- package/build/translations/en-au.js +1 -1
- package/build/translations/en-gb.js +1 -1
- package/build/translations/eo.js +1 -1
- package/build/translations/es.js +1 -1
- package/build/translations/et.js +1 -1
- package/build/translations/eu.js +1 -1
- package/build/translations/fa.js +1 -1
- package/build/translations/fi.js +1 -1
- package/build/translations/fr.js +1 -1
- package/build/translations/gl.js +1 -1
- package/build/translations/he.js +1 -1
- package/build/translations/hi.js +1 -1
- package/build/translations/hr.js +1 -1
- package/build/translations/hu.js +1 -1
- package/build/translations/id.js +1 -1
- package/build/translations/it.js +1 -1
- package/build/translations/ja.js +1 -1
- package/build/translations/jv.js +1 -1
- package/build/translations/km.js +1 -1
- package/build/translations/kn.js +1 -1
- package/build/translations/ko.js +1 -1
- package/build/translations/ku.js +1 -1
- package/build/translations/lt.js +1 -1
- package/build/translations/lv.js +1 -1
- package/build/translations/ms.js +1 -0
- package/build/translations/nb.js +1 -1
- package/build/translations/ne.js +1 -1
- package/build/translations/nl.js +1 -1
- package/build/translations/no.js +1 -1
- package/build/translations/pl.js +1 -1
- package/build/translations/pt-br.js +1 -1
- package/build/translations/pt.js +1 -1
- package/build/translations/ro.js +1 -1
- package/build/translations/ru.js +1 -1
- package/build/translations/si.js +1 -1
- package/build/translations/sk.js +1 -1
- package/build/translations/sq.js +1 -1
- package/build/translations/sr-latn.js +1 -1
- package/build/translations/sr.js +1 -1
- package/build/translations/sv.js +1 -1
- package/build/translations/th.js +1 -1
- package/build/translations/tk.js +1 -1
- package/build/translations/tr.js +1 -1
- package/build/translations/tt.js +1 -0
- package/build/translations/ug.js +1 -1
- package/build/translations/uk.js +1 -1
- package/build/translations/ur.js +1 -1
- package/build/translations/uz.js +1 -1
- package/build/translations/vi.js +1 -1
- package/build/translations/zh-cn.js +1 -1
- package/build/translations/zh.js +1 -1
- package/lang/contexts.json +3 -1
- package/lang/translations/ar.po +21 -13
- package/lang/translations/ast.po +8 -0
- package/lang/translations/az.po +8 -0
- package/lang/translations/bg.po +30 -22
- package/lang/translations/bn.po +121 -0
- package/lang/translations/bs.po +8 -0
- package/lang/translations/ca.po +121 -0
- package/lang/translations/cs.po +8 -0
- package/lang/translations/da.po +20 -12
- package/lang/translations/de-ch.po +8 -0
- package/lang/translations/de.po +8 -0
- package/lang/translations/el.po +8 -0
- package/lang/translations/en-au.po +8 -0
- package/lang/translations/en-gb.po +8 -0
- package/lang/translations/en.po +8 -0
- package/lang/translations/eo.po +8 -0
- package/lang/translations/es.po +8 -0
- package/lang/translations/et.po +20 -12
- package/lang/translations/eu.po +8 -0
- package/lang/translations/fa.po +8 -0
- package/lang/translations/fi.po +21 -13
- package/lang/translations/fr.po +11 -3
- package/lang/translations/gl.po +8 -0
- package/lang/translations/he.po +20 -12
- package/lang/translations/hi.po +11 -3
- package/lang/translations/hr.po +8 -0
- package/lang/translations/hu.po +8 -0
- package/lang/translations/id.po +8 -0
- package/lang/translations/it.po +8 -0
- package/lang/translations/ja.po +11 -3
- package/lang/translations/jv.po +8 -0
- package/lang/translations/km.po +8 -0
- package/lang/translations/kn.po +8 -0
- package/lang/translations/ko.po +15 -7
- package/lang/translations/ku.po +8 -0
- package/lang/translations/lt.po +21 -13
- package/lang/translations/lv.po +8 -0
- package/lang/translations/ms.po +121 -0
- package/lang/translations/nb.po +8 -0
- package/lang/translations/ne.po +8 -0
- package/lang/translations/nl.po +18 -10
- package/lang/translations/no.po +20 -12
- package/lang/translations/pl.po +12 -4
- package/lang/translations/pt-br.po +8 -0
- package/lang/translations/pt.po +24 -16
- package/lang/translations/ro.po +11 -3
- package/lang/translations/ru.po +8 -0
- package/lang/translations/si.po +8 -0
- package/lang/translations/sk.po +8 -0
- package/lang/translations/sq.po +8 -0
- package/lang/translations/sr-latn.po +8 -0
- package/lang/translations/sr.po +8 -0
- package/lang/translations/sv.po +21 -13
- package/lang/translations/th.po +20 -12
- package/lang/translations/tk.po +8 -0
- package/lang/translations/tr.po +15 -7
- package/lang/translations/tt.po +121 -0
- package/lang/translations/ug.po +8 -0
- package/lang/translations/uk.po +11 -3
- package/lang/translations/ur.po +8 -0
- package/lang/translations/uz.po +8 -0
- package/lang/translations/vi.po +11 -3
- package/lang/translations/zh-cn.po +8 -0
- package/lang/translations/zh.po +11 -3
- package/package.json +33 -32
- package/src/image/ui/utils.js +1 -1
- package/src/imagecaption/imagecaptionediting.js +40 -1
- package/src/imagecaption/imagecaptionui.js +2 -0
- package/src/imageinsert/imageinsertui.js +45 -21
- package/src/imageinsert/ui/imageinsertpanelview.js +1 -37
- package/src/imageinsert.js +2 -1
- package/src/imageinsertviaurl.js +40 -0
- package/src/imageresize/imageresizehandles.js +1 -1
- package/src/imagestyle/imagestyleui.js +7 -1
- package/src/imageupload/imageuploadui.js +2 -0
- 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
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
|
81
|
+
class: 'ck-image-insert__panel'
|
|
71
82
|
}
|
|
72
83
|
} );
|
|
73
84
|
|
|
74
|
-
|
|
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:
|
|
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(
|
|
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,
|
|
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
|
*
|
package/src/imageinsert.js
CHANGED
|
@@ -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.
|
|
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
|
}
|
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 =
|
|
142
|
+
let parent = selectionPosition.parent;
|
|
137
143
|
|
|
138
144
|
while ( parent ) {
|
|
139
145
|
if ( parent.is( 'element' ) && this.isImageWidget( parent ) ) {
|