@ckeditor/ckeditor5-image 35.4.0 → 36.0.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/LICENSE.md +1 -1
- package/build/image.js +2 -2
- package/build/translations/sr-latn.js +1 -1
- package/build/translations/sr.js +1 -1
- package/lang/translations/sr-latn.po +2 -2
- package/lang/translations/sr.po +2 -2
- package/package.json +32 -32
- package/src/autoimage.js +1 -1
- package/src/image/converters.js +1 -1
- package/src/image/imageblockediting.js +1 -1
- package/src/image/imageediting.js +6 -2
- package/src/image/imageinlineediting.js +1 -1
- package/src/image/imageloadobserver.js +1 -1
- package/src/image/imagetypecommand.js +1 -1
- package/src/image/insertimagecommand.js +1 -1
- package/src/image/replaceimagesourcecommand.js +49 -0
- package/src/image/ui/utils.js +1 -1
- package/src/image/utils.js +1 -1
- package/src/image.js +1 -1
- package/src/imageblock.js +1 -1
- package/src/imagecaption/imagecaptionediting.js +1 -1
- package/src/imagecaption/imagecaptionui.js +1 -1
- package/src/imagecaption/imagecaptionutils.js +1 -1
- package/src/imagecaption/toggleimagecaptioncommand.js +1 -1
- package/src/imagecaption.js +1 -1
- package/src/imageinline.js +1 -1
- package/src/imageinsert/imageinsertui.js +11 -13
- package/src/imageinsert/ui/imageinsertformrowview.js +1 -1
- package/src/imageinsert/ui/imageinsertpanelview.js +1 -1
- package/src/imageinsert/utils.js +1 -1
- package/src/imageinsert.js +1 -1
- package/src/imageinsertviaurl.js +1 -1
- package/src/imageresize/imageresizebuttons.js +4 -4
- package/src/imageresize/imageresizeediting.js +1 -1
- package/src/imageresize/imageresizehandles.js +1 -1
- package/src/imageresize/resizeimagecommand.js +1 -1
- package/src/imageresize.js +1 -1
- package/src/imagestyle/converters.js +1 -1
- package/src/imagestyle/imagestylecommand.js +1 -1
- package/src/imagestyle/imagestyleediting.js +1 -1
- package/src/imagestyle/imagestyleui.js +1 -1
- package/src/imagestyle/utils.js +1 -1
- package/src/imagestyle.js +1 -1
- package/src/imagetextalternative/imagetextalternativecommand.js +1 -1
- package/src/imagetextalternative/imagetextalternativeediting.js +1 -1
- package/src/imagetextalternative/imagetextalternativeui.js +11 -6
- package/src/imagetextalternative/ui/textalternativeformview.js +1 -1
- package/src/imagetextalternative.js +1 -1
- package/src/imagetoolbar.js +1 -1
- package/src/imageupload/imageuploadediting.js +1 -1
- package/src/imageupload/imageuploadprogress.js +1 -1
- package/src/imageupload/imageuploadui.js +1 -1
- package/src/imageupload/uploadimagecommand.js +1 -1
- package/src/imageupload/utils.js +1 -1
- package/src/imageupload.js +1 -1
- package/src/imageutils.js +1 -1
- package/src/index.js +1 -1
- package/src/pictureediting.js +1 -1
- package/theme/image.css +1 -1
- package/theme/imagecaption.css +1 -1
- package/theme/imageinsert.css +1 -1
- package/theme/imageinsertformrowview.css +1 -1
- package/theme/imageresize.css +1 -1
- package/theme/imagestyle.css +1 -1
- package/theme/imageuploadicon.css +1 -1
- package/theme/imageuploadloader.css +1 -1
- package/theme/imageuploadprogress.css +1 -1
- package/theme/textalternativeform.css +1 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, 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
|
+
import { Command } from 'ckeditor5/src/core';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @module image/image/replaceimagesourcecommand
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Replace image source command.
|
|
14
|
+
*
|
|
15
|
+
* Changes image source to the one provided. Can be executed as follows:
|
|
16
|
+
*
|
|
17
|
+
* editor.execute( 'replaceImageSource', { source: 'http://url.to.the/image' } );
|
|
18
|
+
*
|
|
19
|
+
* @extends module:core/command~Command
|
|
20
|
+
*/
|
|
21
|
+
export default class ReplaceImageSourceCommand extends Command {
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
refresh() {
|
|
26
|
+
const editor = this.editor;
|
|
27
|
+
const imageUtils = editor.plugins.get( 'ImageUtils' );
|
|
28
|
+
const element = this.editor.model.document.selection.getSelectedElement();
|
|
29
|
+
|
|
30
|
+
this.isEnabled = imageUtils.isImage( element );
|
|
31
|
+
this.value = this.isEnabled ? element.getAttribute( 'src' ) : null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Executes the command.
|
|
36
|
+
*
|
|
37
|
+
* @fires execute
|
|
38
|
+
* @param {Object} options Options for the executed command.
|
|
39
|
+
* @param {String} [options.source] The image source to replace.
|
|
40
|
+
*/
|
|
41
|
+
execute( options ) {
|
|
42
|
+
const image = this.editor.model.document.selection.getSelectedElement();
|
|
43
|
+
this.editor.model.change( writer => {
|
|
44
|
+
writer.setAttribute( 'src', options.source, image );
|
|
45
|
+
writer.removeAttribute( 'srcset', image );
|
|
46
|
+
writer.removeAttribute( 'sizes', image );
|
|
47
|
+
} );
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/image/ui/utils.js
CHANGED
package/src/image/utils.js
CHANGED
package/src/image.js
CHANGED
package/src/imageblock.js
CHANGED
package/src/imagecaption.js
CHANGED
package/src/imageinline.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -111,27 +111,30 @@ export default class ImageInsertUI extends Plugin {
|
|
|
111
111
|
_setUpDropdown( command ) {
|
|
112
112
|
const editor = this.editor;
|
|
113
113
|
const t = editor.t;
|
|
114
|
-
const imageInsertView = new ImageInsertPanelView( editor.locale, prepareIntegrations( editor ) );
|
|
115
|
-
const insertButtonView = imageInsertView.insertButtonView;
|
|
116
|
-
const insertImageViaUrlForm = imageInsertView.getIntegration( 'insertImageViaUrl' );
|
|
117
114
|
const dropdownView = this.dropdownView;
|
|
118
115
|
const panelView = dropdownView.panelView;
|
|
119
116
|
const imageUtils = this.editor.plugins.get( 'ImageUtils' );
|
|
117
|
+
const replaceImageSourceCommand = editor.commands.get( 'replaceImageSource' );
|
|
118
|
+
|
|
119
|
+
let imageInsertView;
|
|
120
120
|
|
|
121
121
|
dropdownView.bind( 'isEnabled' ).to( command );
|
|
122
122
|
|
|
123
|
-
// Defer the children injection to improve initial performance.
|
|
124
|
-
// See https://github.com/ckeditor/ckeditor5/pull/8019#discussion_r484069652.
|
|
125
123
|
dropdownView.once( 'change:isOpen', () => {
|
|
124
|
+
imageInsertView = new ImageInsertPanelView( editor.locale, prepareIntegrations( editor ) );
|
|
125
|
+
|
|
126
|
+
imageInsertView.delegate( 'submit', 'cancel' ).to( dropdownView );
|
|
126
127
|
panelView.children.add( imageInsertView );
|
|
127
128
|
} );
|
|
128
129
|
|
|
129
130
|
dropdownView.on( 'change:isOpen', () => {
|
|
130
131
|
const selectedElement = editor.model.document.selection.getSelectedElement();
|
|
132
|
+
const insertButtonView = imageInsertView.insertButtonView;
|
|
133
|
+
const insertImageViaUrlForm = imageInsertView.getIntegration( 'insertImageViaUrl' );
|
|
131
134
|
|
|
132
135
|
if ( dropdownView.isOpen ) {
|
|
133
136
|
if ( imageUtils.isImage( selectedElement ) ) {
|
|
134
|
-
imageInsertView.imageURLInputValue =
|
|
137
|
+
imageInsertView.imageURLInputValue = replaceImageSourceCommand.value;
|
|
135
138
|
insertButtonView.label = t( 'Update' );
|
|
136
139
|
insertImageViaUrlForm.label = t( 'Update image URL' );
|
|
137
140
|
} else {
|
|
@@ -145,7 +148,6 @@ export default class ImageInsertUI extends Plugin {
|
|
|
145
148
|
// invisible form/input cannot be focused/selected.
|
|
146
149
|
}, { priority: 'low' } );
|
|
147
150
|
|
|
148
|
-
imageInsertView.delegate( 'submit', 'cancel' ).to( dropdownView );
|
|
149
151
|
this.delegate( 'cancel' ).to( dropdownView );
|
|
150
152
|
|
|
151
153
|
dropdownView.on( 'submit', () => {
|
|
@@ -161,11 +163,7 @@ export default class ImageInsertUI extends Plugin {
|
|
|
161
163
|
const selectedElement = editor.model.document.selection.getSelectedElement();
|
|
162
164
|
|
|
163
165
|
if ( imageUtils.isImage( selectedElement ) ) {
|
|
164
|
-
editor.
|
|
165
|
-
writer.setAttribute( 'src', imageInsertView.imageURLInputValue, selectedElement );
|
|
166
|
-
writer.removeAttribute( 'srcset', selectedElement );
|
|
167
|
-
writer.removeAttribute( 'sizes', selectedElement );
|
|
168
|
-
} );
|
|
166
|
+
editor.execute( 'replaceImageSource', { source: imageInsertView.imageURLInputValue } );
|
|
169
167
|
} else {
|
|
170
168
|
editor.execute( 'insertImage', { source: imageInsertView.imageURLInputValue } );
|
|
171
169
|
}
|
package/src/imageinsert/utils.js
CHANGED
package/src/imageinsert.js
CHANGED
package/src/imageinsertviaurl.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -167,9 +167,9 @@ export default class ImageResizeButtons extends Plugin {
|
|
|
167
167
|
dropdownView.bind( 'isOn' ).to( command );
|
|
168
168
|
dropdownView.bind( 'isEnabled' ).to( this );
|
|
169
169
|
|
|
170
|
-
addListToDropdown( dropdownView, this._getResizeDropdownListItemDefinitions( options, command )
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
addListToDropdown( dropdownView, () => this._getResizeDropdownListItemDefinitions( options, command ), {
|
|
171
|
+
ariaLabel: t( 'Image resize list' )
|
|
172
|
+
} );
|
|
173
173
|
|
|
174
174
|
// Execute command when an item from the dropdown is selected.
|
|
175
175
|
this.listenTo( dropdownView, 'execute', evt => {
|
package/src/imageresize.js
CHANGED
package/src/imagestyle/utils.js
CHANGED
package/src/imagestyle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Copyright (c) 2003-
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -40,7 +40,6 @@ export default class ImageTextAlternativeUI extends Plugin {
|
|
|
40
40
|
*/
|
|
41
41
|
init() {
|
|
42
42
|
this._createButton();
|
|
43
|
-
this._createForm();
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
/**
|
|
@@ -50,7 +49,9 @@ export default class ImageTextAlternativeUI extends Plugin {
|
|
|
50
49
|
super.destroy();
|
|
51
50
|
|
|
52
51
|
// Destroy created UI components as they are not automatically destroyed (see ckeditor5#1341).
|
|
53
|
-
this._form
|
|
52
|
+
if ( this._form ) {
|
|
53
|
+
this._form.destroy();
|
|
54
|
+
}
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
/**
|
|
@@ -145,7 +146,7 @@ export default class ImageTextAlternativeUI extends Plugin {
|
|
|
145
146
|
clickOutsideHandler( {
|
|
146
147
|
emitter: this._form,
|
|
147
148
|
activator: () => this._isVisible,
|
|
148
|
-
contextElements: [ this._balloon.view.element ],
|
|
149
|
+
contextElements: () => [ this._balloon.view.element ],
|
|
149
150
|
callback: () => this._hideForm()
|
|
150
151
|
} );
|
|
151
152
|
}
|
|
@@ -160,6 +161,10 @@ export default class ImageTextAlternativeUI extends Plugin {
|
|
|
160
161
|
return;
|
|
161
162
|
}
|
|
162
163
|
|
|
164
|
+
if ( !this._form ) {
|
|
165
|
+
this._createForm();
|
|
166
|
+
}
|
|
167
|
+
|
|
163
168
|
const editor = this.editor;
|
|
164
169
|
const command = editor.commands.get( 'imageTextAlternative' );
|
|
165
170
|
const labeledInput = this._form.labeledInput;
|
|
@@ -216,7 +221,7 @@ export default class ImageTextAlternativeUI extends Plugin {
|
|
|
216
221
|
* @type {Boolean}
|
|
217
222
|
*/
|
|
218
223
|
get _isVisible() {
|
|
219
|
-
return this._balloon.visibleView === this._form;
|
|
224
|
+
return !!this._balloon && this._balloon.visibleView === this._form;
|
|
220
225
|
}
|
|
221
226
|
|
|
222
227
|
/**
|
|
@@ -226,6 +231,6 @@ export default class ImageTextAlternativeUI extends Plugin {
|
|
|
226
231
|
* @type {Boolean}
|
|
227
232
|
*/
|
|
228
233
|
get _isInBalloon() {
|
|
229
|
-
return this._balloon.hasView( this._form );
|
|
234
|
+
return !!this._balloon && this._balloon.hasView( this._form );
|
|
230
235
|
}
|
|
231
236
|
}
|
package/src/imagetoolbar.js
CHANGED
package/src/imageupload/utils.js
CHANGED
package/src/imageupload.js
CHANGED
package/src/imageutils.js
CHANGED
package/src/index.js
CHANGED
package/src/pictureediting.js
CHANGED
package/theme/image.css
CHANGED
package/theme/imagecaption.css
CHANGED
package/theme/imageinsert.css
CHANGED
package/theme/imageresize.css
CHANGED
package/theme/imagestyle.css
CHANGED