@ckeditor/ckeditor5-image 36.0.1 → 37.0.0-alpha.1
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/augmentation.d.ts +55 -0
- package/src/augmentation.js +5 -0
- package/src/autoimage.d.ts +48 -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 +52 -0
- package/src/image/imageblockediting.js +111 -155
- package/src/image/imageediting.d.ts +29 -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 +40 -0
- package/src/image/imagetypecommand.js +67 -95
- package/src/image/insertimagecommand.d.ts +66 -0
- package/src/image/insertimagecommand.js +94 -101
- package/src/image/replaceimagesourcecommand.d.ts +34 -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 +32 -0
- package/src/image.js +12 -43
- package/src/imageblock.d.ts +30 -0
- package/src/imageblock.js +12 -21
- package/src/imagecaption/imagecaptionediting.d.ts +87 -0
- package/src/imagecaption/imagecaptionediting.js +203 -262
- package/src/imagecaption/imagecaptionui.d.ts +25 -0
- package/src/imagecaption/imagecaptionui.js +46 -63
- package/src/imagecaption/imagecaptionutils.d.ts +37 -0
- package/src/imagecaption/imagecaptionutils.js +51 -78
- package/src/imagecaption/toggleimagecaptioncommand.d.ts +66 -0
- package/src/imagecaption/toggleimagecaptioncommand.js +112 -138
- package/src/imagecaption.d.ts +24 -0
- package/src/imagecaption.js +12 -19
- package/src/imageconfig.d.ts +713 -0
- package/src/imageconfig.js +5 -0
- package/src/imageinline.d.ts +30 -0
- package/src/imageinline.js +12 -21
- package/src/imageinsert/imageinsertui.d.ts +44 -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 +25 -0
- package/src/imageinsert/utils.js +41 -58
- package/src/imageinsert.d.ts +30 -0
- package/src/imageinsert.js +13 -84
- package/src/imageinsertviaurl.d.ts +29 -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 +36 -0
- package/src/imageresize/imageresizeediting.js +99 -125
- package/src/imageresize/imageresizehandles.d.ts +29 -0
- package/src/imageresize/imageresizehandles.js +90 -123
- package/src/imageresize/resizeimagecommand.d.ts +42 -0
- package/src/imageresize/resizeimagecommand.js +48 -55
- package/src/imageresize.d.ts +24 -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 +65 -0
- package/src/imagestyle/imagestylecommand.js +88 -124
- package/src/imagestyle/imagestyleediting.d.ts +49 -0
- package/src/imagestyle/imagestyleediting.js +90 -137
- package/src/imagestyle/imagestyleui.d.ts +55 -0
- package/src/imagestyle/imagestyleui.js +170 -278
- package/src/imagestyle/utils.d.ts +101 -0
- package/src/imagestyle/utils.js +256 -309
- package/src/imagestyle.d.ts +30 -0
- package/src/imagestyle.js +13 -261
- package/src/imagetextalternative/imagetextalternativecommand.d.ts +34 -0
- package/src/imagetextalternative/imagetextalternativecommand.js +31 -47
- package/src/imagetextalternative/imagetextalternativeediting.d.ts +27 -0
- package/src/imagetextalternative/imagetextalternativeediting.js +18 -25
- package/src/imagetextalternative/imagetextalternativeui.d.ts +67 -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 +27 -0
- package/src/imagetextalternative.js +12 -18
- package/src/imagetoolbar.d.ts +33 -0
- package/src/imagetoolbar.js +31 -77
- package/src/imageupload/imageuploadediting.d.ts +108 -0
- package/src/imageupload/imageuploadediting.js +307 -427
- package/src/imageupload/imageuploadprogress.d.ts +42 -0
- package/src/imageupload/imageuploadprogress.js +180 -261
- package/src/imageupload/imageuploadui.d.ts +23 -0
- package/src/imageupload/imageuploadui.js +40 -57
- package/src/imageupload/uploadimagecommand.d.ts +60 -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 +29 -0
- package/src/imageupload.js +12 -61
- package/src/imageutils.d.ts +102 -0
- package/src/imageutils.js +232 -329
- package/src/index.d.ts +47 -0
- package/src/index.js +1 -2
- package/src/pictureediting.d.ts +86 -0
- package/src/pictureediting.js +101 -120
|
@@ -0,0 +1,30 @@
|
|
|
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/imagestyle
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The image style plugin.
|
|
11
|
+
*
|
|
12
|
+
* For a detailed overview of the image styles feature, check the {@glink features/images/images-styles documentation}.
|
|
13
|
+
*
|
|
14
|
+
* This is a "glue" plugin which loads the following plugins:
|
|
15
|
+
* * {@link module:image/imagestyle/imagestyleediting~ImageStyleEditing},
|
|
16
|
+
* * {@link module:image/imagestyle/imagestyleui~ImageStyleUI}
|
|
17
|
+
*
|
|
18
|
+
* It provides a default configuration, which can be extended or overwritten.
|
|
19
|
+
* Read more about the {@link module:image/imageconfig~ImageConfig#styles image styles configuration}.
|
|
20
|
+
*/
|
|
21
|
+
export default class ImageStyle extends Plugin {
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get requires(): PluginDependencies;
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
static get pluginName(): 'ImageStyle';
|
|
30
|
+
}
|
package/src/imagestyle.js
CHANGED
|
@@ -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/imagestyle
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
9
|
import ImageStyleEditing from './imagestyle/imagestyleediting';
|
|
12
10
|
import ImageStyleUI from './imagestyle/imagestyleui';
|
|
13
|
-
|
|
14
11
|
/**
|
|
15
12
|
* The image style plugin.
|
|
16
13
|
*
|
|
@@ -21,264 +18,19 @@ import ImageStyleUI from './imagestyle/imagestyleui';
|
|
|
21
18
|
* * {@link module:image/imagestyle/imagestyleui~ImageStyleUI}
|
|
22
19
|
*
|
|
23
20
|
* It provides a default configuration, which can be extended or overwritten.
|
|
24
|
-
* Read more about the {@link module:image/
|
|
25
|
-
*
|
|
26
|
-
* @extends module:core/plugin~Plugin
|
|
21
|
+
* Read more about the {@link module:image/imageconfig~ImageConfig#styles image styles configuration}.
|
|
27
22
|
*/
|
|
28
23
|
export default class ImageStyle extends Plugin {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
static get requires() {
|
|
28
|
+
return [ImageStyleEditing, ImageStyleUI];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @inheritDoc
|
|
32
|
+
*/
|
|
33
|
+
static get pluginName() {
|
|
34
|
+
return 'ImageStyle';
|
|
35
|
+
}
|
|
42
36
|
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* The configuration for the {@link module:image/imagestyle~ImageStyle} plugin that should be provided
|
|
46
|
-
* while creating the editor instance.
|
|
47
|
-
*
|
|
48
|
-
* A detailed information about the default configuration and customization can be found in
|
|
49
|
-
* {@link module:image/image~ImageConfig#styles `ImageConfig#styles`}.
|
|
50
|
-
*
|
|
51
|
-
* @interface ImageStyleConfig
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* A list of the image style options.
|
|
56
|
-
*
|
|
57
|
-
* @member {Array.<module:image/imagestyle~ImageStyleOptionDefinition>} module:image/imagestyle~ImageStyleConfig#options
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* The {@link module:image/imagestyle `ImageStyle`} plugin requires a list of the
|
|
62
|
-
* {@link module:image/imagestyle~ImageStyleConfig#options image style options} to work properly.
|
|
63
|
-
* The default configuration is provided (listed below) and can be customized while creating the editor instance.
|
|
64
|
-
*
|
|
65
|
-
* # **Command**
|
|
66
|
-
*
|
|
67
|
-
* The {@link module:image/imagestyle/imagestylecommand~ImageStyleCommand `imageStyleCommand`}
|
|
68
|
-
* is configured based on the defined options,
|
|
69
|
-
* so you can change the style of the selected image by executing the following command:
|
|
70
|
-
*
|
|
71
|
-
* editor.execute( 'imageStyle' { value: 'alignLeft' } );
|
|
72
|
-
*
|
|
73
|
-
* # **Buttons**
|
|
74
|
-
*
|
|
75
|
-
* All of the image style options provided in the configuration are registered
|
|
76
|
-
* in the {@link module:ui/componentfactory~ComponentFactory UI components factory} with the "imageStyle:" prefixes and can be used
|
|
77
|
-
* in the {@link module:image/image~ImageConfig#toolbar image toolbar configuration}. The buttons available by default depending
|
|
78
|
-
* on the loaded plugins are listed in the next section.
|
|
79
|
-
*
|
|
80
|
-
* Read more about styling images in the {@glink features/images/images-styles Image styles guide}.
|
|
81
|
-
*
|
|
82
|
-
* # **Default options and buttons**
|
|
83
|
-
*
|
|
84
|
-
* If the custom configuration is not provided, the default configuration will be used depending on the loaded
|
|
85
|
-
* image editing plugins.
|
|
86
|
-
*
|
|
87
|
-
* * If both {@link module:image/image/imageblockediting~ImageBlockEditing `ImageBlockEditing`} and
|
|
88
|
-
* {@link module:image/image/imageinlineediting~ImageInlineEditing `ImageInlineEditing`} plugins are loaded
|
|
89
|
-
* (which is usually the default editor configuration), the following options will be available for the toolbar
|
|
90
|
-
* configuration. These options will be registered as the buttons with the "imageStyle:" prefixes.
|
|
91
|
-
*
|
|
92
|
-
* const imageDefaultConfig = {
|
|
93
|
-
* styles: {
|
|
94
|
-
* options: [
|
|
95
|
-
* 'inline', 'alignLeft', 'alignRight',
|
|
96
|
-
* 'alignCenter', 'alignBlockLeft', 'alignBlockRight',
|
|
97
|
-
* 'block', 'side'
|
|
98
|
-
* ]
|
|
99
|
-
* }
|
|
100
|
-
* };
|
|
101
|
-
*
|
|
102
|
-
* * If only the {@link module:image/image/imageblockediting~ImageBlockEditing `ImageBlockEditing`} plugin is loaded,
|
|
103
|
-
* the following buttons (options) and groups will be available for the toolbar configuration.
|
|
104
|
-
* These options will be registered as the buttons with the "imageStyle:" prefixes.
|
|
105
|
-
*
|
|
106
|
-
* const imageDefaultConfig = {
|
|
107
|
-
* styles: {
|
|
108
|
-
* options: [ 'block', 'side' ]
|
|
109
|
-
* }
|
|
110
|
-
* };
|
|
111
|
-
*
|
|
112
|
-
* * If only the {@link module:image/image/imageinlineediting~ImageInlineEditing `ImageInlineEditing`} plugin is loaded,
|
|
113
|
-
* the following buttons (options) and groups will available for the toolbar configuration.
|
|
114
|
-
* These options will be registered as the buttons with the "imageStyle:" prefixes.
|
|
115
|
-
*
|
|
116
|
-
* const imageDefaultConfig = {
|
|
117
|
-
* styles: {
|
|
118
|
-
* options: [ 'inline', 'alignLeft', 'alignRight' ]
|
|
119
|
-
* }
|
|
120
|
-
* };
|
|
121
|
-
*
|
|
122
|
-
* Read more about the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options}.
|
|
123
|
-
*
|
|
124
|
-
* # **Custom configuration**
|
|
125
|
-
*
|
|
126
|
-
* The image styles configuration can be customized in several ways:
|
|
127
|
-
*
|
|
128
|
-
* * Any of the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options}
|
|
129
|
-
* can be loaded by the reference to its name as follows:
|
|
130
|
-
*
|
|
131
|
-
* ClassicEditor
|
|
132
|
-
* .create( editorElement, {
|
|
133
|
-
* image: {
|
|
134
|
-
* styles: {
|
|
135
|
-
* options: [ 'alignLeft', 'alignRight' ]
|
|
136
|
-
* }
|
|
137
|
-
* }
|
|
138
|
-
* } );
|
|
139
|
-
*
|
|
140
|
-
* * Each of the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default image style options} can be customized,
|
|
141
|
-
* e.g. to change the `icon`, `title` or CSS `className` of the style. The feature also provides several
|
|
142
|
-
* {@link module:image/imagestyle/utils~DEFAULT_ICONS default icons} to choose from.
|
|
143
|
-
*
|
|
144
|
-
* import customIcon from 'custom-icon.svg';
|
|
145
|
-
*
|
|
146
|
-
* // ...
|
|
147
|
-
*
|
|
148
|
-
* ClassicEditor.create( editorElement, { image:
|
|
149
|
-
* styles: {
|
|
150
|
-
* options: {
|
|
151
|
-
* // This will only customize the icon of the "block" style.
|
|
152
|
-
* // Note: 'right' is one of default icons provided by the feature.
|
|
153
|
-
* {
|
|
154
|
-
* name: 'block',
|
|
155
|
-
* icon: 'right'
|
|
156
|
-
* },
|
|
157
|
-
*
|
|
158
|
-
* // This will customize the icon, title and CSS class of the default "side" style.
|
|
159
|
-
* {
|
|
160
|
-
* name: 'side',
|
|
161
|
-
* icon: customIcon,
|
|
162
|
-
* title: 'My side style',
|
|
163
|
-
* className: 'custom-side-image'
|
|
164
|
-
* }
|
|
165
|
-
* }
|
|
166
|
-
* }
|
|
167
|
-
* } );
|
|
168
|
-
*
|
|
169
|
-
* * If none of the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default image style options}
|
|
170
|
-
* works for the integration, it is possible to define independent custom styles, too.
|
|
171
|
-
*
|
|
172
|
-
* See the documentation about the image style {@link module:image/imagestyle~ImageStyleOptionDefinition options}
|
|
173
|
-
* to define the custom image style configuration properly.
|
|
174
|
-
*
|
|
175
|
-
* import redIcon from 'red-icon.svg';
|
|
176
|
-
* import blueIcon from 'blue-icon.svg';
|
|
177
|
-
*
|
|
178
|
-
* // ...
|
|
179
|
-
*
|
|
180
|
-
* ClassicEditor.create( editorElement, { image:
|
|
181
|
-
* styles: {
|
|
182
|
-
* // A list of completely custom styling options.
|
|
183
|
-
* options: [
|
|
184
|
-
* {
|
|
185
|
-
* name: 'regular',
|
|
186
|
-
* modelElements: [ 'imageBlock', 'imageInline' ],
|
|
187
|
-
* title: 'Regular image',
|
|
188
|
-
* icon: 'full',
|
|
189
|
-
* isDefault: true
|
|
190
|
-
* }, {
|
|
191
|
-
* name: 'blue',
|
|
192
|
-
* modelElements: [ 'imageInline' ],
|
|
193
|
-
* title: 'Blue image',
|
|
194
|
-
* icon: blueIcon,
|
|
195
|
-
* className: 'image-blue'
|
|
196
|
-
* }, {
|
|
197
|
-
* name: 'red',
|
|
198
|
-
* modelElements: [ 'imageBlock' ],
|
|
199
|
-
* title: 'Red image',
|
|
200
|
-
* icon: redIcon,
|
|
201
|
-
* className: 'image-red'
|
|
202
|
-
* }
|
|
203
|
-
* ]
|
|
204
|
-
* }
|
|
205
|
-
* } );
|
|
206
|
-
*
|
|
207
|
-
* @member {module:image/imagestyle~ImageStyleConfig} module:image/image~ImageConfig#styles
|
|
208
|
-
*/
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* The image styling option definition descriptor.
|
|
212
|
-
*
|
|
213
|
-
* This definition should be implemented in the `Image` plugin {@link module:image/image~ImageConfig#styles configuration} for:
|
|
214
|
-
*
|
|
215
|
-
* * customizing one of the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options} by providing the proper name
|
|
216
|
-
* of the default style and the properties that should be overridden,
|
|
217
|
-
* * or defining a completely custom styling option by providing a custom name and implementing the following properties.
|
|
218
|
-
*
|
|
219
|
-
* import fullSizeIcon from 'path/to/icon.svg';
|
|
220
|
-
*
|
|
221
|
-
* const imageStyleOptionDefinition = {
|
|
222
|
-
* name: 'fullSize',
|
|
223
|
-
* icon: fullSizeIcon,
|
|
224
|
-
* title: 'Full size image',
|
|
225
|
-
* className: 'image-full-size',
|
|
226
|
-
* modelElements: [ 'imageBlock', 'imageInline' ]
|
|
227
|
-
* }
|
|
228
|
-
*
|
|
229
|
-
* The styling option will be registered as the button under the name `'imageStyle:{name}'` in the
|
|
230
|
-
* {@link module:ui/componentfactory~ComponentFactory UI components factory} (this functionality is provided by the
|
|
231
|
-
* {@link module:image/imagestyle/imagestyleui~ImageStyleUI} plugin).
|
|
232
|
-
*
|
|
233
|
-
* @property {String} name The unique name of the styling option. It will be used to:
|
|
234
|
-
*
|
|
235
|
-
* * refer to one of the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options} or define the custom style,
|
|
236
|
-
* * store the chosen style in the model by setting the `imageStyle` attribute of the model image element,
|
|
237
|
-
* * as a value of the {@link module:image/imagestyle/imagestylecommand~ImageStyleCommand#execute `imageStyle` command},
|
|
238
|
-
* * when registering a button for the style in the following manner: (`'imageStyle:{name}'`).
|
|
239
|
-
*
|
|
240
|
-
* @property {Boolean} [isDefault] When set, the style will be used as the default one for the model elements
|
|
241
|
-
* listed in the `modelElements` property. A default style does not apply any CSS class to the view element.
|
|
242
|
-
*
|
|
243
|
-
* If this property is not defined, its value is inherited
|
|
244
|
-
* from the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options} addressed in the name property.
|
|
245
|
-
*
|
|
246
|
-
* @property {String} icon One of the following to be used when creating the styles's button:
|
|
247
|
-
*
|
|
248
|
-
* * an SVG icon source (as an XML string),
|
|
249
|
-
* * one of the keys in {@link module:image/imagestyle/utils~DEFAULT_ICONS} to use one of default icons provided by the plugin.
|
|
250
|
-
*
|
|
251
|
-
* If this property is not defined, its value is inherited
|
|
252
|
-
* from the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options} addressed in the name property.
|
|
253
|
-
*
|
|
254
|
-
* @property {String} title The styles's title. Setting `title` to one of
|
|
255
|
-
* {@link module:image/imagestyle/imagestyleui~ImageStyleUI#localizedDefaultStylesTitles}
|
|
256
|
-
* will automatically translate it to the language of the editor.
|
|
257
|
-
*
|
|
258
|
-
* If this property is not defined, its value is inherited
|
|
259
|
-
* from the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options} addressed in the name property.
|
|
260
|
-
*
|
|
261
|
-
* @property {String} [className] The CSS class used to represent the style in the view.
|
|
262
|
-
* It should be used only for the non-default styles.
|
|
263
|
-
*
|
|
264
|
-
* If this property is not defined, its value is inherited
|
|
265
|
-
* from the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options} addressed in the name property.
|
|
266
|
-
*
|
|
267
|
-
* @property {Array.<String>} modelElements The list of the names of the model elements that are supported by the style.
|
|
268
|
-
* The possible values are:
|
|
269
|
-
* * `[ 'imageBlock' ]` if the style can be applied to the image type introduced by the
|
|
270
|
-
* {@link module:image/image/imageblockediting~ImageBlockEditing `ImageBlockEditing`} plugin,
|
|
271
|
-
* * `[ 'imageInline' ]` if the style can be applied to the image type introduced by the
|
|
272
|
-
* {@link module:image/image/imageinlineediting~ImageInlineEditing `ImageInlineEditing`} plugin,
|
|
273
|
-
* * `[ 'imageInline', 'imageBlock' ]` if the style can be applied to both image types introduced by the plugins mentioned above.
|
|
274
|
-
*
|
|
275
|
-
* This property determines which model element names work with the style. If the model element name of the currently selected
|
|
276
|
-
* image is different, upon executing the
|
|
277
|
-
* {@link module:image/imagestyle/imagestylecommand~ImageStyleCommand#execute `imageStyle`} command the image type (model element name)
|
|
278
|
-
* will automatically change.
|
|
279
|
-
*
|
|
280
|
-
* If this property is not defined, its value is inherited
|
|
281
|
-
* from the {@link module:image/imagestyle/utils~DEFAULT_OPTIONS default styling options} addressed in the name property.
|
|
282
|
-
*
|
|
283
|
-
* @typedef {Object} module:image/imagestyle~ImageStyleOptionDefinition
|
|
284
|
-
*/
|
|
@@ -0,0 +1,34 @@
|
|
|
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/imagetextalternativecommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The image text alternative command. It is used to change the `alt` attribute of `<imageBlock>` and `<imageInline>` model elements.
|
|
11
|
+
*/
|
|
12
|
+
export default class ImageTextAlternativeCommand extends Command {
|
|
13
|
+
/**
|
|
14
|
+
* The command value: `false` if there is no `alt` attribute, otherwise the value of the `alt` attribute.
|
|
15
|
+
*
|
|
16
|
+
* @readonly
|
|
17
|
+
* @observable
|
|
18
|
+
*/
|
|
19
|
+
value: string | false;
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
refresh(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Executes the command.
|
|
26
|
+
*
|
|
27
|
+
* @fires execute
|
|
28
|
+
* @param options
|
|
29
|
+
* @param options.newValue The new value of the `alt` attribute to set.
|
|
30
|
+
*/
|
|
31
|
+
execute(options: {
|
|
32
|
+
newValue: string;
|
|
33
|
+
}): void;
|
|
34
|
+
}
|
|
@@ -2,59 +2,43 @@
|
|
|
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/imagetextalternativecommand
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Command } from 'ckeditor5/src/core';
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* The image text alternative command. It is used to change the `alt` attribute of `<imageBlock>` and `<imageInline>` model elements.
|
|
14
|
-
*
|
|
15
|
-
* @extends module:core/command~Command
|
|
16
11
|
*/
|
|
17
12
|
export default class ImageTextAlternativeCommand extends Command {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*/
|
|
50
|
-
execute( options ) {
|
|
51
|
-
const editor = this.editor;
|
|
52
|
-
const imageUtils = editor.plugins.get( 'ImageUtils' );
|
|
53
|
-
const model = editor.model;
|
|
54
|
-
const imageElement = imageUtils.getClosestSelectedImageElement( model.document.selection );
|
|
55
|
-
|
|
56
|
-
model.change( writer => {
|
|
57
|
-
writer.setAttribute( 'alt', options.newValue, imageElement );
|
|
58
|
-
} );
|
|
59
|
-
}
|
|
13
|
+
/**
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
refresh() {
|
|
17
|
+
const editor = this.editor;
|
|
18
|
+
const imageUtils = editor.plugins.get('ImageUtils');
|
|
19
|
+
const element = imageUtils.getClosestSelectedImageElement(this.editor.model.document.selection);
|
|
20
|
+
this.isEnabled = !!element;
|
|
21
|
+
if (this.isEnabled && element.hasAttribute('alt')) {
|
|
22
|
+
this.value = element.getAttribute('alt');
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
this.value = false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Executes the command.
|
|
30
|
+
*
|
|
31
|
+
* @fires execute
|
|
32
|
+
* @param options
|
|
33
|
+
* @param options.newValue The new value of the `alt` attribute to set.
|
|
34
|
+
*/
|
|
35
|
+
execute(options) {
|
|
36
|
+
const editor = this.editor;
|
|
37
|
+
const imageUtils = editor.plugins.get('ImageUtils');
|
|
38
|
+
const model = editor.model;
|
|
39
|
+
const imageElement = imageUtils.getClosestSelectedImageElement(model.document.selection);
|
|
40
|
+
model.change(writer => {
|
|
41
|
+
writer.setAttribute('alt', options.newValue, imageElement);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
60
44
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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/imagetextalternativeediting
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The image text alternative editing plugin.
|
|
11
|
+
*
|
|
12
|
+
* Registers the `'imageTextAlternative'` command.
|
|
13
|
+
*/
|
|
14
|
+
export default class ImageTextAlternativeEditing extends Plugin {
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
static get requires(): PluginDependencies;
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get pluginName(): 'ImageTextAlternativeEditing';
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
init(): void;
|
|
27
|
+
}
|
|
@@ -2,41 +2,34 @@
|
|
|
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/imagetextalternativeediting
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
9
|
import ImageTextAlternativeCommand from './imagetextalternativecommand';
|
|
12
10
|
import ImageUtils from '../imageutils';
|
|
13
|
-
|
|
14
11
|
/**
|
|
15
12
|
* The image text alternative editing plugin.
|
|
16
13
|
*
|
|
17
14
|
* Registers the `'imageTextAlternative'` command.
|
|
18
|
-
*
|
|
19
|
-
* @extends module:core/plugin~Plugin
|
|
20
15
|
*/
|
|
21
16
|
export default class ImageTextAlternativeEditing extends Plugin {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.editor.commands.add( 'imageTextAlternative', new ImageTextAlternativeCommand( this.editor ) );
|
|
41
|
-
}
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
static get requires() {
|
|
21
|
+
return [ImageUtils];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
static get pluginName() {
|
|
27
|
+
return 'ImageTextAlternativeEditing';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
32
|
+
init() {
|
|
33
|
+
this.editor.commands.add('imageTextAlternative', new ImageTextAlternativeCommand(this.editor));
|
|
34
|
+
}
|
|
42
35
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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/imagetextalternativeui
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The image text alternative UI plugin.
|
|
11
|
+
*
|
|
12
|
+
* The plugin uses the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon}.
|
|
13
|
+
*/
|
|
14
|
+
export default class ImageTextAlternativeUI extends Plugin {
|
|
15
|
+
/**
|
|
16
|
+
* The contextual balloon plugin instance.
|
|
17
|
+
*/
|
|
18
|
+
private _balloon?;
|
|
19
|
+
/**
|
|
20
|
+
* A form containing a textarea and buttons, used to change the `alt` text value.
|
|
21
|
+
*/
|
|
22
|
+
private _form?;
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
static get requires(): PluginDependencies;
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
static get pluginName(): 'ImageTextAlternativeUI';
|
|
31
|
+
/**
|
|
32
|
+
* @inheritDoc
|
|
33
|
+
*/
|
|
34
|
+
init(): void;
|
|
35
|
+
/**
|
|
36
|
+
* @inheritDoc
|
|
37
|
+
*/
|
|
38
|
+
destroy(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a button showing the balloon panel for changing the image text alternative and
|
|
41
|
+
* registers it in the editor {@link module:ui/componentfactory~ComponentFactory ComponentFactory}.
|
|
42
|
+
*/
|
|
43
|
+
private _createButton;
|
|
44
|
+
/**
|
|
45
|
+
* Creates the {@link module:image/imagetextalternative/ui/textalternativeformview~TextAlternativeFormView}
|
|
46
|
+
* form.
|
|
47
|
+
*/
|
|
48
|
+
private _createForm;
|
|
49
|
+
/**
|
|
50
|
+
* Shows the {@link #_form} in the {@link #_balloon}.
|
|
51
|
+
*/
|
|
52
|
+
private _showForm;
|
|
53
|
+
/**
|
|
54
|
+
* Removes the {@link #_form} from the {@link #_balloon}.
|
|
55
|
+
*
|
|
56
|
+
* @param focusEditable Controls whether the editing view is focused afterwards.
|
|
57
|
+
*/
|
|
58
|
+
private _hideForm;
|
|
59
|
+
/**
|
|
60
|
+
* Returns `true` when the {@link #_form} is the visible view in the {@link #_balloon}.
|
|
61
|
+
*/
|
|
62
|
+
private get _isVisible();
|
|
63
|
+
/**
|
|
64
|
+
* Returns `true` when the {@link #_form} is in the {@link #_balloon}.
|
|
65
|
+
*/
|
|
66
|
+
private get _isInBalloon();
|
|
67
|
+
}
|