@ckeditor/ckeditor5-image 36.0.0 → 37.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.
- package/build/image.js +1 -1
- package/package.json +40 -35
- package/src/autoimage.d.ts +53 -0
- package/src/autoimage.js +111 -160
- package/src/image/converters.d.ts +66 -0
- package/src/image/converters.js +200 -261
- package/src/image/imageblockediting.d.ts +57 -0
- package/src/image/imageblockediting.js +111 -155
- package/src/image/imageediting.d.ts +34 -0
- package/src/image/imageediting.js +53 -67
- package/src/image/imageinlineediting.d.ts +53 -0
- package/src/image/imageinlineediting.js +135 -180
- package/src/image/imageloadobserver.d.ts +44 -0
- package/src/image/imageloadobserver.js +28 -47
- package/src/image/imagetypecommand.d.ts +46 -0
- package/src/image/imagetypecommand.js +67 -95
- package/src/image/insertimagecommand.d.ts +72 -0
- package/src/image/insertimagecommand.js +95 -101
- package/src/image/replaceimagesourcecommand.d.ts +39 -0
- package/src/image/replaceimagesourcecommand.js +28 -33
- package/src/image/ui/utils.d.ts +25 -0
- package/src/image/ui/utils.js +25 -35
- package/src/image/utils.d.ts +52 -0
- package/src/image/utils.js +63 -90
- package/src/image.d.ts +38 -0
- package/src/image.js +13 -43
- package/src/imageblock.d.ts +35 -0
- package/src/imageblock.js +12 -21
- package/src/imagecaption/imagecaptionediting.d.ts +92 -0
- package/src/imagecaption/imagecaptionediting.js +203 -262
- package/src/imagecaption/imagecaptionui.d.ts +30 -0
- package/src/imagecaption/imagecaptionui.js +46 -63
- package/src/imagecaption/imagecaptionutils.d.ts +42 -0
- package/src/imagecaption/imagecaptionutils.js +51 -78
- package/src/imagecaption/toggleimagecaptioncommand.d.ts +71 -0
- package/src/imagecaption/toggleimagecaptioncommand.js +112 -138
- package/src/imagecaption.d.ts +29 -0
- package/src/imagecaption.js +12 -19
- package/src/imageconfig.d.ts +723 -0
- package/src/imageconfig.js +5 -0
- package/src/imageinline.d.ts +35 -0
- package/src/imageinline.js +12 -21
- package/src/imageinsert/imageinsertui.d.ts +49 -0
- package/src/imageinsert/imageinsertui.js +120 -158
- package/src/imageinsert/ui/imageinsertformrowview.d.ts +61 -0
- package/src/imageinsert/ui/imageinsertformrowview.js +37 -86
- package/src/imageinsert/ui/imageinsertpanelview.d.ts +106 -0
- package/src/imageinsert/ui/imageinsertpanelview.js +148 -258
- package/src/imageinsert/utils.d.ts +26 -0
- package/src/imageinsert/utils.js +42 -58
- package/src/imageinsert.d.ts +35 -0
- package/src/imageinsert.js +13 -84
- package/src/imageinsertviaurl.d.ts +34 -0
- package/src/imageinsertviaurl.js +12 -18
- package/src/imageresize/imageresizebuttons.d.ts +66 -0
- package/src/imageresize/imageresizebuttons.js +190 -255
- package/src/imageresize/imageresizeediting.d.ts +42 -0
- package/src/imageresize/imageresizeediting.js +100 -125
- package/src/imageresize/imageresizehandles.d.ts +30 -0
- package/src/imageresize/imageresizehandles.js +91 -123
- package/src/imageresize/resizeimagecommand.d.ts +47 -0
- package/src/imageresize/resizeimagecommand.js +48 -55
- package/src/imageresize.d.ts +29 -0
- package/src/imageresize.js +12 -209
- package/src/imagestyle/converters.d.ts +24 -0
- package/src/imagestyle/converters.js +60 -78
- package/src/imagestyle/imagestylecommand.d.ts +70 -0
- package/src/imagestyle/imagestylecommand.js +88 -124
- package/src/imagestyle/imagestyleediting.d.ts +54 -0
- package/src/imagestyle/imagestyleediting.js +90 -137
- package/src/imagestyle/imagestyleui.d.ts +60 -0
- package/src/imagestyle/imagestyleui.js +169 -277
- package/src/imagestyle/utils.d.ts +61 -0
- package/src/imagestyle/utils.js +253 -306
- package/src/imagestyle.d.ts +35 -0
- package/src/imagestyle.js +13 -261
- package/src/imagetextalternative/imagetextalternativecommand.d.ts +39 -0
- package/src/imagetextalternative/imagetextalternativecommand.js +31 -47
- package/src/imagetextalternative/imagetextalternativeediting.d.ts +32 -0
- package/src/imagetextalternative/imagetextalternativeediting.js +18 -25
- package/src/imagetextalternative/imagetextalternativeui.d.ts +72 -0
- package/src/imagetextalternative/imagetextalternativeui.js +156 -219
- package/src/imagetextalternative/ui/textalternativeformview.d.ts +72 -0
- package/src/imagetextalternative/ui/textalternativeformview.js +103 -192
- package/src/imagetextalternative.d.ts +32 -0
- package/src/imagetextalternative.js +12 -18
- package/src/imagetoolbar.d.ts +38 -0
- package/src/imagetoolbar.js +31 -77
- package/src/imageupload/imageuploadediting.d.ts +114 -0
- package/src/imageupload/imageuploadediting.js +308 -427
- package/src/imageupload/imageuploadprogress.d.ts +47 -0
- package/src/imageupload/imageuploadprogress.js +180 -261
- package/src/imageupload/imageuploadui.d.ts +29 -0
- package/src/imageupload/imageuploadui.js +41 -57
- package/src/imageupload/uploadimagecommand.d.ts +65 -0
- package/src/imageupload/uploadimagecommand.js +73 -87
- package/src/imageupload/utils.d.ts +33 -0
- package/src/imageupload/utils.js +87 -112
- package/src/imageupload.d.ts +34 -0
- package/src/imageupload.js +12 -61
- package/src/imageutils.d.ts +108 -0
- package/src/imageutils.js +233 -329
- package/src/index.d.ts +31 -0
- package/src/index.js +0 -2
- package/src/pictureediting.d.ts +86 -0
- package/src/pictureediting.js +101 -120
|
@@ -2,209 +2,120 @@
|
|
|
2
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
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module image/imagetextalternative/ui/textalternativeformview
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
ButtonView,
|
|
12
|
-
FocusCycler,
|
|
13
|
-
LabeledFieldView,
|
|
14
|
-
View,
|
|
15
|
-
ViewCollection,
|
|
16
|
-
createLabeledInputText,
|
|
17
|
-
injectCssTransitionDisabler,
|
|
18
|
-
submitHandler
|
|
19
|
-
} from 'ckeditor5/src/ui';
|
|
8
|
+
import { ButtonView, FocusCycler, LabeledFieldView, View, ViewCollection, createLabeledInputText, submitHandler } from 'ckeditor5/src/ui';
|
|
20
9
|
import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils';
|
|
21
10
|
import { icons } from 'ckeditor5/src/core';
|
|
22
|
-
|
|
23
11
|
import '../../../theme/textalternativeform.css';
|
|
24
|
-
|
|
25
12
|
// See: #8833.
|
|
26
13
|
// eslint-disable-next-line ckeditor5-rules/ckeditor-imports
|
|
27
14
|
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
|
28
|
-
|
|
29
15
|
/**
|
|
30
16
|
* The TextAlternativeFormView class.
|
|
31
|
-
*
|
|
32
|
-
* @extends module:ui/view~View
|
|
33
17
|
*/
|
|
34
18
|
export default class TextAlternativeFormView extends View {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
render() {
|
|
138
|
-
super.render();
|
|
139
|
-
|
|
140
|
-
this.keystrokes.listenTo( this.element );
|
|
141
|
-
|
|
142
|
-
submitHandler( { view: this } );
|
|
143
|
-
|
|
144
|
-
[ this.labeledInput, this.saveButtonView, this.cancelButtonView ]
|
|
145
|
-
.forEach( v => {
|
|
146
|
-
// Register the view as focusable.
|
|
147
|
-
this._focusables.add( v );
|
|
148
|
-
|
|
149
|
-
// Register the view in the focus tracker.
|
|
150
|
-
this.focusTracker.add( v.element );
|
|
151
|
-
} );
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* @inheritDoc
|
|
156
|
-
*/
|
|
157
|
-
destroy() {
|
|
158
|
-
super.destroy();
|
|
159
|
-
|
|
160
|
-
this.focusTracker.destroy();
|
|
161
|
-
this.keystrokes.destroy();
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Creates the button view.
|
|
166
|
-
*
|
|
167
|
-
* @private
|
|
168
|
-
* @param {String} label The button label
|
|
169
|
-
* @param {String} icon The button's icon.
|
|
170
|
-
* @param {String} className The additional button CSS class name.
|
|
171
|
-
* @param {String} [eventName] The event name that the ButtonView#execute event will be delegated to.
|
|
172
|
-
* @returns {module:ui/button/buttonview~ButtonView} The button view instance.
|
|
173
|
-
*/
|
|
174
|
-
_createButton( label, icon, className, eventName ) {
|
|
175
|
-
const button = new ButtonView( this.locale );
|
|
176
|
-
|
|
177
|
-
button.set( {
|
|
178
|
-
label,
|
|
179
|
-
icon,
|
|
180
|
-
tooltip: true
|
|
181
|
-
} );
|
|
182
|
-
|
|
183
|
-
button.extendTemplate( {
|
|
184
|
-
attributes: {
|
|
185
|
-
class: className
|
|
186
|
-
}
|
|
187
|
-
} );
|
|
188
|
-
|
|
189
|
-
if ( eventName ) {
|
|
190
|
-
button.delegate( 'execute' ).to( this, eventName );
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return button;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Creates an input with a label.
|
|
198
|
-
*
|
|
199
|
-
* @private
|
|
200
|
-
* @returns {module:ui/labeledfield/labeledfieldview~LabeledFieldView} Labeled field view instance.
|
|
201
|
-
*/
|
|
202
|
-
_createLabeledInputView() {
|
|
203
|
-
const t = this.locale.t;
|
|
204
|
-
const labeledInput = new LabeledFieldView( this.locale, createLabeledInputText );
|
|
205
|
-
|
|
206
|
-
labeledInput.label = t( 'Text alternative' );
|
|
207
|
-
|
|
208
|
-
return labeledInput;
|
|
209
|
-
}
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
constructor(locale) {
|
|
23
|
+
super(locale);
|
|
24
|
+
const t = this.locale.t;
|
|
25
|
+
this.focusTracker = new FocusTracker();
|
|
26
|
+
this.keystrokes = new KeystrokeHandler();
|
|
27
|
+
this.labeledInput = this._createLabeledInputView();
|
|
28
|
+
this.saveButtonView = this._createButton(t('Save'), icons.check, 'ck-button-save');
|
|
29
|
+
this.saveButtonView.type = 'submit';
|
|
30
|
+
this.cancelButtonView = this._createButton(t('Cancel'), icons.cancel, 'ck-button-cancel', 'cancel');
|
|
31
|
+
this._focusables = new ViewCollection();
|
|
32
|
+
this._focusCycler = new FocusCycler({
|
|
33
|
+
focusables: this._focusables,
|
|
34
|
+
focusTracker: this.focusTracker,
|
|
35
|
+
keystrokeHandler: this.keystrokes,
|
|
36
|
+
actions: {
|
|
37
|
+
// Navigate form fields backwards using the Shift + Tab keystroke.
|
|
38
|
+
focusPrevious: 'shift + tab',
|
|
39
|
+
// Navigate form fields forwards using the Tab key.
|
|
40
|
+
focusNext: 'tab'
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
this.setTemplate({
|
|
44
|
+
tag: 'form',
|
|
45
|
+
attributes: {
|
|
46
|
+
class: [
|
|
47
|
+
'ck',
|
|
48
|
+
'ck-text-alternative-form',
|
|
49
|
+
'ck-responsive-form'
|
|
50
|
+
],
|
|
51
|
+
// https://github.com/ckeditor/ckeditor5-image/issues/40
|
|
52
|
+
tabindex: '-1'
|
|
53
|
+
},
|
|
54
|
+
children: [
|
|
55
|
+
this.labeledInput,
|
|
56
|
+
this.saveButtonView,
|
|
57
|
+
this.cancelButtonView
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @inheritDoc
|
|
63
|
+
*/
|
|
64
|
+
render() {
|
|
65
|
+
super.render();
|
|
66
|
+
this.keystrokes.listenTo(this.element);
|
|
67
|
+
submitHandler({ view: this });
|
|
68
|
+
[this.labeledInput, this.saveButtonView, this.cancelButtonView]
|
|
69
|
+
.forEach(v => {
|
|
70
|
+
// Register the view as focusable.
|
|
71
|
+
this._focusables.add(v);
|
|
72
|
+
// Register the view in the focus tracker.
|
|
73
|
+
this.focusTracker.add(v.element);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @inheritDoc
|
|
78
|
+
*/
|
|
79
|
+
destroy() {
|
|
80
|
+
super.destroy();
|
|
81
|
+
this.focusTracker.destroy();
|
|
82
|
+
this.keystrokes.destroy();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Creates the button view.
|
|
86
|
+
*
|
|
87
|
+
* @param label The button label
|
|
88
|
+
* @param icon The button's icon.
|
|
89
|
+
* @param className The additional button CSS class name.
|
|
90
|
+
* @param eventName The event name that the ButtonView#execute event will be delegated to.
|
|
91
|
+
* @returns The button view instance.
|
|
92
|
+
*/
|
|
93
|
+
_createButton(label, icon, className, eventName) {
|
|
94
|
+
const button = new ButtonView(this.locale);
|
|
95
|
+
button.set({
|
|
96
|
+
label,
|
|
97
|
+
icon,
|
|
98
|
+
tooltip: true
|
|
99
|
+
});
|
|
100
|
+
button.extendTemplate({
|
|
101
|
+
attributes: {
|
|
102
|
+
class: className
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
if (eventName) {
|
|
106
|
+
button.delegate('execute').to(this, eventName);
|
|
107
|
+
}
|
|
108
|
+
return button;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Creates an input with a label.
|
|
112
|
+
*
|
|
113
|
+
* @returns Labeled field view instance.
|
|
114
|
+
*/
|
|
115
|
+
_createLabeledInputView() {
|
|
116
|
+
const t = this.locale.t;
|
|
117
|
+
const labeledInput = new LabeledFieldView(this.locale, createLabeledInputText);
|
|
118
|
+
labeledInput.label = t('Text alternative');
|
|
119
|
+
return labeledInput;
|
|
120
|
+
}
|
|
210
121
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
* @module image/imagetextalternative
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The image text alternative plugin.
|
|
11
|
+
*
|
|
12
|
+
* For a detailed overview, check the {@glink features/images/images-styles image styles} documentation.
|
|
13
|
+
*
|
|
14
|
+
* This is a "glue" plugin which loads the
|
|
15
|
+
* {@link module:image/imagetextalternative/imagetextalternativeediting~ImageTextAlternativeEditing}
|
|
16
|
+
* and {@link module:image/imagetextalternative/imagetextalternativeui~ImageTextAlternativeUI} plugins.
|
|
17
|
+
*/
|
|
18
|
+
export default class ImageTextAlternative extends Plugin {
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get requires(): PluginDependencies;
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
static get pluginName(): 'ImageTextAlternative';
|
|
27
|
+
}
|
|
28
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
29
|
+
interface PluginsMap {
|
|
30
|
+
[ImageTextAlternative.pluginName]: ImageTextAlternative;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -2,15 +2,12 @@
|
|
|
2
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
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module image/imagetextalternative
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
9
|
import ImageTextAlternativeEditing from './imagetextalternative/imagetextalternativeediting';
|
|
12
10
|
import ImageTextAlternativeUI from './imagetextalternative/imagetextalternativeui';
|
|
13
|
-
|
|
14
11
|
/**
|
|
15
12
|
* The image text alternative plugin.
|
|
16
13
|
*
|
|
@@ -19,21 +16,18 @@ import ImageTextAlternativeUI from './imagetextalternative/imagetextalternativeu
|
|
|
19
16
|
* This is a "glue" plugin which loads the
|
|
20
17
|
* {@link module:image/imagetextalternative/imagetextalternativeediting~ImageTextAlternativeEditing}
|
|
21
18
|
* and {@link module:image/imagetextalternative/imagetextalternativeui~ImageTextAlternativeUI} plugins.
|
|
22
|
-
*
|
|
23
|
-
* @extends module:core/plugin~Plugin
|
|
24
19
|
*/
|
|
25
20
|
export default class ImageTextAlternative extends Plugin {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
static get requires() {
|
|
25
|
+
return [ImageTextAlternativeEditing, ImageTextAlternativeUI];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
static get pluginName() {
|
|
31
|
+
return 'ImageTextAlternative';
|
|
32
|
+
}
|
|
39
33
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
* @module image/imagetoolbar
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The image toolbar plugin. It creates and manages the image toolbar (the toolbar displayed when an image is selected).
|
|
11
|
+
*
|
|
12
|
+
* For an overview, check the {@glink features/images/images-overview#image-contextual-toolbar image contextual toolbar} documentation.
|
|
13
|
+
*
|
|
14
|
+
* Instances of toolbar components (e.g. buttons) are created using the editor's
|
|
15
|
+
* {@link module:ui/componentfactory~ComponentFactory component factory}
|
|
16
|
+
* based on the {@link module:image/imageconfig~ImageConfig#toolbar `image.toolbar` configuration option}.
|
|
17
|
+
*
|
|
18
|
+
* The toolbar uses the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon}.
|
|
19
|
+
*/
|
|
20
|
+
export default class ImageToolbar extends Plugin {
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
static get requires(): PluginDependencies;
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc
|
|
27
|
+
*/
|
|
28
|
+
static get pluginName(): 'ImageToolbar';
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
32
|
+
afterInit(): void;
|
|
33
|
+
}
|
|
34
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
35
|
+
interface PluginsMap {
|
|
36
|
+
[ImageToolbar.pluginName]: ImageToolbar;
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/imagetoolbar.js
CHANGED
|
@@ -2,16 +2,13 @@
|
|
|
2
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
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module image/imagetoolbar
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
9
|
import { WidgetToolbarRepository } from 'ckeditor5/src/widget';
|
|
12
10
|
import ImageUtils from './imageutils';
|
|
13
11
|
import { isObject } from 'lodash-es';
|
|
14
|
-
|
|
15
12
|
/**
|
|
16
13
|
* The image toolbar plugin. It creates and manages the image toolbar (the toolbar displayed when an image is selected).
|
|
17
14
|
*
|
|
@@ -19,85 +16,42 @@ import { isObject } from 'lodash-es';
|
|
|
19
16
|
*
|
|
20
17
|
* Instances of toolbar components (e.g. buttons) are created using the editor's
|
|
21
18
|
* {@link module:ui/componentfactory~ComponentFactory component factory}
|
|
22
|
-
* based on the {@link module:image/
|
|
19
|
+
* based on the {@link module:image/imageconfig~ImageConfig#toolbar `image.toolbar` configuration option}.
|
|
23
20
|
*
|
|
24
21
|
* The toolbar uses the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon}.
|
|
25
|
-
*
|
|
26
|
-
* @extends module:core/plugin~Plugin
|
|
27
22
|
*/
|
|
28
23
|
export default class ImageToolbar extends Plugin {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
getRelatedElement: selection => imageUtils.getClosestSelectedImageWidget( selection )
|
|
56
|
-
} );
|
|
57
|
-
}
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
static get requires() {
|
|
28
|
+
return [WidgetToolbarRepository, ImageUtils];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @inheritDoc
|
|
32
|
+
*/
|
|
33
|
+
static get pluginName() {
|
|
34
|
+
return 'ImageToolbar';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @inheritDoc
|
|
38
|
+
*/
|
|
39
|
+
afterInit() {
|
|
40
|
+
const editor = this.editor;
|
|
41
|
+
const t = editor.t;
|
|
42
|
+
const widgetToolbarRepository = editor.plugins.get(WidgetToolbarRepository);
|
|
43
|
+
const imageUtils = editor.plugins.get('ImageUtils');
|
|
44
|
+
widgetToolbarRepository.register('image', {
|
|
45
|
+
ariaLabel: t('Image toolbar'),
|
|
46
|
+
items: normalizeDeclarativeConfig(editor.config.get('image.toolbar') || []),
|
|
47
|
+
getRelatedElement: selection => imageUtils.getClosestSelectedImageWidget(selection)
|
|
48
|
+
});
|
|
49
|
+
}
|
|
58
50
|
}
|
|
59
|
-
|
|
60
51
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* Assuming that you use the following features:
|
|
65
|
-
*
|
|
66
|
-
* * {@link module:image/imagestyle~ImageStyle} (with a default configuration),
|
|
67
|
-
* * {@link module:image/imagetextalternative~ImageTextAlternative},
|
|
68
|
-
* * {@link module:image/imagecaption~ImageCaption},
|
|
69
|
-
*
|
|
70
|
-
* the following toolbar items will be available in {@link module:ui/componentfactory~ComponentFactory}:
|
|
71
|
-
* * `'imageTextAlternative'`,
|
|
72
|
-
* * `'toggleImageCaption'`,
|
|
73
|
-
* * {@link module:image/image~ImageConfig#styles buttons provided by the `ImageStyle` plugin},
|
|
74
|
-
* * {@link module:image/imagestyle/utils~DEFAULT_DROPDOWN_DEFINITIONS drop-downs provided by the `ImageStyle` plugin},
|
|
75
|
-
*
|
|
76
|
-
* so you can configure the toolbar like this:
|
|
77
|
-
*
|
|
78
|
-
* const imageConfig = {
|
|
79
|
-
* toolbar: [
|
|
80
|
-
* 'imageStyle:inline', 'imageStyle:wrapText', 'imageStyle:breakText', '|',
|
|
81
|
-
* 'toggleImageCaption', 'imageTextAlternative'
|
|
82
|
-
* ]
|
|
83
|
-
* };
|
|
84
|
-
*
|
|
85
|
-
* Besides that, the `ImageStyle` plugin allows to define a
|
|
86
|
-
* {@link module:image/imagestyle/imagestyleui~ImageStyleDropdownDefinition custom drop-down} while configuring the toolbar.
|
|
87
|
-
*
|
|
88
|
-
* The same items can also be used in the {@link module:core/editor/editorconfig~EditorConfig#toolbar main editor toolbar}.
|
|
89
|
-
*
|
|
90
|
-
* Read more about configuring toolbar in {@link module:core/editor/editorconfig~EditorConfig#toolbar}.
|
|
91
|
-
*
|
|
92
|
-
* @member {Array.<String>} module:image/image~ImageConfig#toolbar
|
|
52
|
+
* Convert the dropdown definitions to their keys registered in the ComponentFactory.
|
|
53
|
+
* The registration precess should be handled by the plugin which handles the UI of a particular feature.
|
|
93
54
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
// The registration precess should be handled by the plugin which handles the UI of a particular feature.
|
|
97
|
-
//
|
|
98
|
-
// @param {Array.<String|module:image/imagestyle/imagestyleui~ImageStyleDropdownDefinition>} config
|
|
99
|
-
//
|
|
100
|
-
// @returns {Array.<String>}
|
|
101
|
-
function normalizeDeclarativeConfig( config ) {
|
|
102
|
-
return config.map( item => isObject( item ) ? item.name : item );
|
|
55
|
+
function normalizeDeclarativeConfig(config) {
|
|
56
|
+
return config.map(item => isObject(item) ? item.name : item);
|
|
103
57
|
}
|