@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.
Files changed (106) hide show
  1. package/build/image.js +1 -1
  2. package/package.json +40 -35
  3. package/src/autoimage.d.ts +53 -0
  4. package/src/autoimage.js +111 -160
  5. package/src/image/converters.d.ts +66 -0
  6. package/src/image/converters.js +200 -261
  7. package/src/image/imageblockediting.d.ts +57 -0
  8. package/src/image/imageblockediting.js +111 -155
  9. package/src/image/imageediting.d.ts +34 -0
  10. package/src/image/imageediting.js +53 -67
  11. package/src/image/imageinlineediting.d.ts +53 -0
  12. package/src/image/imageinlineediting.js +135 -180
  13. package/src/image/imageloadobserver.d.ts +44 -0
  14. package/src/image/imageloadobserver.js +28 -47
  15. package/src/image/imagetypecommand.d.ts +46 -0
  16. package/src/image/imagetypecommand.js +67 -95
  17. package/src/image/insertimagecommand.d.ts +72 -0
  18. package/src/image/insertimagecommand.js +95 -101
  19. package/src/image/replaceimagesourcecommand.d.ts +39 -0
  20. package/src/image/replaceimagesourcecommand.js +28 -33
  21. package/src/image/ui/utils.d.ts +25 -0
  22. package/src/image/ui/utils.js +25 -35
  23. package/src/image/utils.d.ts +52 -0
  24. package/src/image/utils.js +63 -90
  25. package/src/image.d.ts +38 -0
  26. package/src/image.js +13 -43
  27. package/src/imageblock.d.ts +35 -0
  28. package/src/imageblock.js +12 -21
  29. package/src/imagecaption/imagecaptionediting.d.ts +92 -0
  30. package/src/imagecaption/imagecaptionediting.js +203 -262
  31. package/src/imagecaption/imagecaptionui.d.ts +30 -0
  32. package/src/imagecaption/imagecaptionui.js +46 -63
  33. package/src/imagecaption/imagecaptionutils.d.ts +42 -0
  34. package/src/imagecaption/imagecaptionutils.js +51 -78
  35. package/src/imagecaption/toggleimagecaptioncommand.d.ts +71 -0
  36. package/src/imagecaption/toggleimagecaptioncommand.js +112 -138
  37. package/src/imagecaption.d.ts +29 -0
  38. package/src/imagecaption.js +12 -19
  39. package/src/imageconfig.d.ts +723 -0
  40. package/src/imageconfig.js +5 -0
  41. package/src/imageinline.d.ts +35 -0
  42. package/src/imageinline.js +12 -21
  43. package/src/imageinsert/imageinsertui.d.ts +49 -0
  44. package/src/imageinsert/imageinsertui.js +120 -158
  45. package/src/imageinsert/ui/imageinsertformrowview.d.ts +61 -0
  46. package/src/imageinsert/ui/imageinsertformrowview.js +37 -86
  47. package/src/imageinsert/ui/imageinsertpanelview.d.ts +106 -0
  48. package/src/imageinsert/ui/imageinsertpanelview.js +148 -258
  49. package/src/imageinsert/utils.d.ts +26 -0
  50. package/src/imageinsert/utils.js +42 -58
  51. package/src/imageinsert.d.ts +35 -0
  52. package/src/imageinsert.js +13 -84
  53. package/src/imageinsertviaurl.d.ts +34 -0
  54. package/src/imageinsertviaurl.js +12 -18
  55. package/src/imageresize/imageresizebuttons.d.ts +66 -0
  56. package/src/imageresize/imageresizebuttons.js +190 -255
  57. package/src/imageresize/imageresizeediting.d.ts +42 -0
  58. package/src/imageresize/imageresizeediting.js +100 -125
  59. package/src/imageresize/imageresizehandles.d.ts +30 -0
  60. package/src/imageresize/imageresizehandles.js +91 -123
  61. package/src/imageresize/resizeimagecommand.d.ts +47 -0
  62. package/src/imageresize/resizeimagecommand.js +48 -55
  63. package/src/imageresize.d.ts +29 -0
  64. package/src/imageresize.js +12 -209
  65. package/src/imagestyle/converters.d.ts +24 -0
  66. package/src/imagestyle/converters.js +60 -78
  67. package/src/imagestyle/imagestylecommand.d.ts +70 -0
  68. package/src/imagestyle/imagestylecommand.js +88 -124
  69. package/src/imagestyle/imagestyleediting.d.ts +54 -0
  70. package/src/imagestyle/imagestyleediting.js +90 -137
  71. package/src/imagestyle/imagestyleui.d.ts +60 -0
  72. package/src/imagestyle/imagestyleui.js +169 -277
  73. package/src/imagestyle/utils.d.ts +61 -0
  74. package/src/imagestyle/utils.js +253 -306
  75. package/src/imagestyle.d.ts +35 -0
  76. package/src/imagestyle.js +13 -261
  77. package/src/imagetextalternative/imagetextalternativecommand.d.ts +39 -0
  78. package/src/imagetextalternative/imagetextalternativecommand.js +31 -47
  79. package/src/imagetextalternative/imagetextalternativeediting.d.ts +32 -0
  80. package/src/imagetextalternative/imagetextalternativeediting.js +18 -25
  81. package/src/imagetextalternative/imagetextalternativeui.d.ts +72 -0
  82. package/src/imagetextalternative/imagetextalternativeui.js +156 -219
  83. package/src/imagetextalternative/ui/textalternativeformview.d.ts +72 -0
  84. package/src/imagetextalternative/ui/textalternativeformview.js +103 -192
  85. package/src/imagetextalternative.d.ts +32 -0
  86. package/src/imagetextalternative.js +12 -18
  87. package/src/imagetoolbar.d.ts +38 -0
  88. package/src/imagetoolbar.js +31 -77
  89. package/src/imageupload/imageuploadediting.d.ts +114 -0
  90. package/src/imageupload/imageuploadediting.js +308 -427
  91. package/src/imageupload/imageuploadprogress.d.ts +47 -0
  92. package/src/imageupload/imageuploadprogress.js +180 -261
  93. package/src/imageupload/imageuploadui.d.ts +29 -0
  94. package/src/imageupload/imageuploadui.js +41 -57
  95. package/src/imageupload/uploadimagecommand.d.ts +65 -0
  96. package/src/imageupload/uploadimagecommand.js +73 -87
  97. package/src/imageupload/utils.d.ts +33 -0
  98. package/src/imageupload/utils.js +87 -112
  99. package/src/imageupload.d.ts +34 -0
  100. package/src/imageupload.js +12 -61
  101. package/src/imageutils.d.ts +108 -0
  102. package/src/imageutils.js +233 -329
  103. package/src/index.d.ts +31 -0
  104. package/src/index.js +0 -2
  105. package/src/pictureediting.d.ts +86 -0
  106. package/src/pictureediting.js +101 -120
@@ -2,30 +2,17 @@
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/image/imageblockediting
8
7
  */
9
-
10
8
  import { Plugin } from 'ckeditor5/src/core';
11
9
  import { ClipboardPipeline } from 'ckeditor5/src/clipboard';
12
10
  import { UpcastWriter } from 'ckeditor5/src/engine';
13
-
14
- import {
15
- downcastImageAttribute,
16
- downcastSrcsetAttribute,
17
- upcastImageFigure
18
- } from './converters';
19
-
11
+ import { downcastImageAttribute, downcastSrcsetAttribute, upcastImageFigure } from './converters';
20
12
  import ImageEditing from './imageediting';
21
13
  import ImageTypeCommand from './imagetypecommand';
22
14
  import ImageUtils from '../imageutils';
23
- import {
24
- getImgViewElementMatcher,
25
- createBlockImageViewElement,
26
- determineImageTypeForInsertionAtSelection
27
- } from '../image/utils';
28
-
15
+ import { getImgViewElementMatcher, createBlockImageViewElement, determineImageTypeForInsertionAtSelection } from '../image/utils';
29
16
  /**
30
17
  * The image block plugin.
31
18
  *
@@ -35,146 +22,115 @@ import {
35
22
  * * converters for editing and data pipelines.,
36
23
  * * {@link module:image/image/imagetypecommand~ImageTypeCommand `'imageTypeBlock'`} command that converts inline images into
37
24
  * block images.
38
- *
39
- * @extends module:core/plugin~Plugin
40
25
  */
41
26
  export default class ImageBlockEditing extends Plugin {
42
- /**
43
- * @inheritDoc
44
- */
45
- static get requires() {
46
- return [ ImageEditing, ImageUtils, ClipboardPipeline ];
47
- }
48
-
49
- /**
50
- * @inheritDoc
51
- */
52
- static get pluginName() {
53
- return 'ImageBlockEditing';
54
- }
55
-
56
- /**
57
- * @inheritDoc
58
- */
59
- init() {
60
- const editor = this.editor;
61
- const schema = editor.model.schema;
62
-
63
- // Converters 'alt' and 'srcset' are added in 'ImageEditing' plugin.
64
- schema.register( 'imageBlock', {
65
- inheritAllFrom: '$blockObject',
66
- allowAttributes: [ 'alt', 'src', 'srcset' ]
67
- } );
68
-
69
- this._setupConversion();
70
-
71
- if ( editor.plugins.has( 'ImageInlineEditing' ) ) {
72
- editor.commands.add( 'imageTypeBlock', new ImageTypeCommand( this.editor, 'imageBlock' ) );
73
-
74
- this._setupClipboardIntegration();
75
- }
76
- }
77
-
78
- /**
79
- * Configures conversion pipelines to support upcasting and downcasting
80
- * block images (block image widgets) and their attributes.
81
- *
82
- * @private
83
- */
84
- _setupConversion() {
85
- const editor = this.editor;
86
- const t = editor.t;
87
- const conversion = editor.conversion;
88
- const imageUtils = editor.plugins.get( 'ImageUtils' );
89
-
90
- conversion.for( 'dataDowncast' )
91
- .elementToStructure( {
92
- model: 'imageBlock',
93
- view: ( modelElement, { writer } ) => createBlockImageViewElement( writer )
94
- } );
95
-
96
- conversion.for( 'editingDowncast' )
97
- .elementToStructure( {
98
- model: 'imageBlock',
99
- view: ( modelElement, { writer } ) => imageUtils.toImageWidget(
100
- createBlockImageViewElement( writer ), writer, t( 'image widget' )
101
- )
102
- } );
103
-
104
- conversion.for( 'downcast' )
105
- .add( downcastImageAttribute( imageUtils, 'imageBlock', 'src' ) )
106
- .add( downcastImageAttribute( imageUtils, 'imageBlock', 'alt' ) )
107
- .add( downcastSrcsetAttribute( imageUtils, 'imageBlock' ) );
108
-
109
- // More image related upcasts are in 'ImageEditing' plugin.
110
- conversion.for( 'upcast' )
111
- .elementToElement( {
112
- view: getImgViewElementMatcher( editor, 'imageBlock' ),
113
- model: ( viewImage, { writer } ) => writer.createElement(
114
- 'imageBlock',
115
- viewImage.hasAttribute( 'src' ) ? { src: viewImage.getAttribute( 'src' ) } : null
116
- )
117
- } )
118
- .add( upcastImageFigure( imageUtils ) );
119
- }
120
-
121
- /**
122
- * Integrates the plugin with the clipboard pipeline.
123
- *
124
- * Idea is that the feature should recognize the user's intent when an **inline** image is
125
- * pasted or dropped. If such an image is pasted/dropped:
126
- *
127
- * * into an empty block (e.g. an empty paragraph),
128
- * * on another object (e.g. some block widget).
129
- *
130
- * it gets converted into a block image on the fly. We assume this is the user's intent
131
- * if they decided to put their image there.
132
- *
133
- * See the `ImageInlineEditing` for the similar integration that works in the opposite direction.
134
- *
135
- * @private
136
- */
137
- _setupClipboardIntegration() {
138
- const editor = this.editor;
139
- const model = editor.model;
140
- const editingView = editor.editing.view;
141
- const imageUtils = editor.plugins.get( 'ImageUtils' );
142
-
143
- this.listenTo( editor.plugins.get( 'ClipboardPipeline' ), 'inputTransformation', ( evt, data ) => {
144
- const docFragmentChildren = Array.from( data.content.getChildren() );
145
- let modelRange;
146
-
147
- // Make sure only <img> elements are dropped or pasted. Otherwise, if there some other HTML
148
- // mixed up, this should be handled as a regular paste.
149
- if ( !docFragmentChildren.every( imageUtils.isInlineImageView ) ) {
150
- return;
151
- }
152
-
153
- // When drag and dropping, data.targetRanges specifies where to drop because
154
- // this is usually a different place than the current model selection (the user
155
- // uses a drop marker to specify the drop location).
156
- if ( data.targetRanges ) {
157
- modelRange = editor.editing.mapper.toModelRange( data.targetRanges[ 0 ] );
158
- }
159
- // Pasting, however, always occurs at the current model selection.
160
- else {
161
- modelRange = model.document.selection.getFirstRange();
162
- }
163
-
164
- const selection = model.createSelection( modelRange );
165
-
166
- // Convert inline images into block images only when the currently selected block is empty
167
- // (e.g. an empty paragraph) or some object is selected (to replace it).
168
- if ( determineImageTypeForInsertionAtSelection( model.schema, selection ) === 'imageBlock' ) {
169
- const writer = new UpcastWriter( editingView.document );
170
-
171
- // Wrap <img ... /> -> <figure class="image"><img .../></figure>
172
- const blockViewImages = docFragmentChildren.map(
173
- inlineViewImage => writer.createElement( 'figure', { class: 'image' }, inlineViewImage )
174
- );
175
-
176
- data.content = writer.createDocumentFragment( blockViewImages );
177
- }
178
- } );
179
- }
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ static get requires() {
31
+ return [ImageEditing, ImageUtils, ClipboardPipeline];
32
+ }
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ static get pluginName() {
37
+ return 'ImageBlockEditing';
38
+ }
39
+ /**
40
+ * @inheritDoc
41
+ */
42
+ init() {
43
+ const editor = this.editor;
44
+ const schema = editor.model.schema;
45
+ // Converters 'alt' and 'srcset' are added in 'ImageEditing' plugin.
46
+ schema.register('imageBlock', {
47
+ inheritAllFrom: '$blockObject',
48
+ allowAttributes: ['alt', 'src', 'srcset']
49
+ });
50
+ this._setupConversion();
51
+ if (editor.plugins.has('ImageInlineEditing')) {
52
+ editor.commands.add('imageTypeBlock', new ImageTypeCommand(this.editor, 'imageBlock'));
53
+ this._setupClipboardIntegration();
54
+ }
55
+ }
56
+ /**
57
+ * Configures conversion pipelines to support upcasting and downcasting
58
+ * block images (block image widgets) and their attributes.
59
+ */
60
+ _setupConversion() {
61
+ const editor = this.editor;
62
+ const t = editor.t;
63
+ const conversion = editor.conversion;
64
+ const imageUtils = editor.plugins.get('ImageUtils');
65
+ conversion.for('dataDowncast')
66
+ .elementToStructure({
67
+ model: 'imageBlock',
68
+ view: (modelElement, { writer }) => createBlockImageViewElement(writer)
69
+ });
70
+ conversion.for('editingDowncast')
71
+ .elementToStructure({
72
+ model: 'imageBlock',
73
+ view: (modelElement, { writer }) => imageUtils.toImageWidget(createBlockImageViewElement(writer), writer, t('image widget'))
74
+ });
75
+ conversion.for('downcast')
76
+ .add(downcastImageAttribute(imageUtils, 'imageBlock', 'src'))
77
+ .add(downcastImageAttribute(imageUtils, 'imageBlock', 'alt'))
78
+ .add(downcastSrcsetAttribute(imageUtils, 'imageBlock'));
79
+ // More image related upcasts are in 'ImageEditing' plugin.
80
+ conversion.for('upcast')
81
+ .elementToElement({
82
+ view: getImgViewElementMatcher(editor, 'imageBlock'),
83
+ model: (viewImage, { writer }) => writer.createElement('imageBlock', viewImage.hasAttribute('src') ? { src: viewImage.getAttribute('src') } : undefined)
84
+ })
85
+ .add(upcastImageFigure(imageUtils));
86
+ }
87
+ /**
88
+ * Integrates the plugin with the clipboard pipeline.
89
+ *
90
+ * Idea is that the feature should recognize the user's intent when an **inline** image is
91
+ * pasted or dropped. If such an image is pasted/dropped:
92
+ *
93
+ * * into an empty block (e.g. an empty paragraph),
94
+ * * on another object (e.g. some block widget).
95
+ *
96
+ * it gets converted into a block image on the fly. We assume this is the user's intent
97
+ * if they decided to put their image there.
98
+ *
99
+ * See the `ImageInlineEditing` for the similar integration that works in the opposite direction.
100
+ */
101
+ _setupClipboardIntegration() {
102
+ const editor = this.editor;
103
+ const model = editor.model;
104
+ const editingView = editor.editing.view;
105
+ const imageUtils = editor.plugins.get('ImageUtils');
106
+ const clipboardPipeline = editor.plugins.get('ClipboardPipeline');
107
+ this.listenTo(clipboardPipeline, 'inputTransformation', (evt, data) => {
108
+ const docFragmentChildren = Array.from(data.content.getChildren());
109
+ let modelRange;
110
+ // Make sure only <img> elements are dropped or pasted. Otherwise, if there some other HTML
111
+ // mixed up, this should be handled as a regular paste.
112
+ if (!docFragmentChildren.every(imageUtils.isInlineImageView)) {
113
+ return;
114
+ }
115
+ // When drag and dropping, data.targetRanges specifies where to drop because
116
+ // this is usually a different place than the current model selection (the user
117
+ // uses a drop marker to specify the drop location).
118
+ if (data.targetRanges) {
119
+ modelRange = editor.editing.mapper.toModelRange(data.targetRanges[0]);
120
+ }
121
+ // Pasting, however, always occurs at the current model selection.
122
+ else {
123
+ modelRange = model.document.selection.getFirstRange();
124
+ }
125
+ const selection = model.createSelection(modelRange);
126
+ // Convert inline images into block images only when the currently selected block is empty
127
+ // (e.g. an empty paragraph) or some object is selected (to replace it).
128
+ if (determineImageTypeForInsertionAtSelection(model.schema, selection) === 'imageBlock') {
129
+ const writer = new UpcastWriter(editingView.document);
130
+ // Wrap <img ... /> -> <figure class="image"><img .../></figure>
131
+ const blockViewImages = docFragmentChildren.map(inlineViewImage => writer.createElement('figure', { class: 'image' }, inlineViewImage));
132
+ data.content = writer.createDocumentFragment(blockViewImages);
133
+ }
134
+ });
135
+ }
180
136
  }
@@ -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/image/imageediting
7
+ */
8
+ import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
9
+ /**
10
+ * The image engine plugin. This module loads common code shared between
11
+ * {@link module:image/image/imageinlineediting~ImageInlineEditing} and
12
+ * {@link module:image/image/imageblockediting~ImageBlockEditing} plugins.
13
+ *
14
+ * This plugin registers the {@link module:image/image/insertimagecommand~InsertImageCommand 'insertImage'} command.
15
+ */
16
+ export default class ImageEditing extends Plugin {
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ static get requires(): PluginDependencies;
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ static get pluginName(): 'ImageEditing';
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ init(): void;
29
+ }
30
+ declare module '@ckeditor/ckeditor5-core' {
31
+ interface PluginsMap {
32
+ [ImageEditing.pluginName]: ImageEditing;
33
+ }
34
+ }
@@ -2,87 +2,73 @@
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/image/imageediting
8
7
  */
9
-
10
8
  import { Plugin } from 'ckeditor5/src/core';
11
9
  import ImageLoadObserver from './imageloadobserver';
12
10
  import InsertImageCommand from './insertimagecommand';
13
11
  import ReplaceImageSourceCommand from './replaceimagesourcecommand';
14
12
  import ImageUtils from '../imageutils';
15
-
16
13
  /**
17
14
  * The image engine plugin. This module loads common code shared between
18
15
  * {@link module:image/image/imageinlineediting~ImageInlineEditing} and
19
16
  * {@link module:image/image/imageblockediting~ImageBlockEditing} plugins.
20
17
  *
21
18
  * This plugin registers the {@link module:image/image/insertimagecommand~InsertImageCommand 'insertImage'} command.
22
- *
23
- * @extends module:core/plugin~Plugin
24
19
  */
25
20
  export default class ImageEditing extends Plugin {
26
- /**
27
- * @inheritDoc
28
- */
29
- static get requires() {
30
- return [ ImageUtils ];
31
- }
32
-
33
- /**
34
- * @inheritDoc
35
- */
36
- static get pluginName() {
37
- return 'ImageEditing';
38
- }
39
-
40
- /**
41
- * @inheritDoc
42
- */
43
- init() {
44
- const editor = this.editor;
45
- const conversion = editor.conversion;
46
-
47
- // See https://github.com/ckeditor/ckeditor5-image/issues/142.
48
- editor.editing.view.addObserver( ImageLoadObserver );
49
-
50
- conversion.for( 'upcast' )
51
- .attributeToAttribute( {
52
- view: {
53
- name: 'img',
54
- key: 'alt'
55
- },
56
- model: 'alt'
57
- } )
58
- .attributeToAttribute( {
59
- view: {
60
- name: 'img',
61
- key: 'srcset'
62
- },
63
- model: {
64
- key: 'srcset',
65
- value: viewImage => {
66
- const value = {
67
- data: viewImage.getAttribute( 'srcset' )
68
- };
69
-
70
- if ( viewImage.hasAttribute( 'width' ) ) {
71
- value.width = viewImage.getAttribute( 'width' );
72
- }
73
-
74
- return value;
75
- }
76
- }
77
- } );
78
-
79
- const insertImageCommand = new InsertImageCommand( editor );
80
- const replaceImageSourceCommand = new ReplaceImageSourceCommand( editor );
81
-
82
- editor.commands.add( 'insertImage', insertImageCommand );
83
- editor.commands.add( 'replaceImageSource', replaceImageSourceCommand );
84
-
85
- // `imageInsert` is an alias for backward compatibility.
86
- editor.commands.add( 'imageInsert', insertImageCommand );
87
- }
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ static get requires() {
25
+ return [ImageUtils];
26
+ }
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ static get pluginName() {
31
+ return 'ImageEditing';
32
+ }
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ init() {
37
+ const editor = this.editor;
38
+ const conversion = editor.conversion;
39
+ // See https://github.com/ckeditor/ckeditor5-image/issues/142.
40
+ editor.editing.view.addObserver(ImageLoadObserver);
41
+ conversion.for('upcast')
42
+ .attributeToAttribute({
43
+ view: {
44
+ name: 'img',
45
+ key: 'alt'
46
+ },
47
+ model: 'alt'
48
+ })
49
+ .attributeToAttribute({
50
+ view: {
51
+ name: 'img',
52
+ key: 'srcset'
53
+ },
54
+ model: {
55
+ key: 'srcset',
56
+ value: (viewImage) => {
57
+ const value = {
58
+ data: viewImage.getAttribute('srcset')
59
+ };
60
+ if (viewImage.hasAttribute('width')) {
61
+ value.width = viewImage.getAttribute('width');
62
+ }
63
+ return value;
64
+ }
65
+ }
66
+ });
67
+ const insertImageCommand = new InsertImageCommand(editor);
68
+ const replaceImageSourceCommand = new ReplaceImageSourceCommand(editor);
69
+ editor.commands.add('insertImage', insertImageCommand);
70
+ editor.commands.add('replaceImageSource', replaceImageSourceCommand);
71
+ // `imageInsert` is an alias for backward compatibility.
72
+ editor.commands.add('imageInsert', insertImageCommand);
73
+ }
88
74
  }
@@ -0,0 +1,53 @@
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/image/imageinlineediting
7
+ */
8
+ import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
9
+ /**
10
+ * The image inline plugin.
11
+ *
12
+ * It registers:
13
+ *
14
+ * * `<imageInline>` as an inline element in the document schema, and allows `alt`, `src` and `srcset` attributes.
15
+ * * converters for editing and data pipelines.
16
+ * * {@link module:image/image/imagetypecommand~ImageTypeCommand `'imageTypeInline'`} command that converts block images into
17
+ * inline images.
18
+ */
19
+ export default class ImageInlineEditing extends Plugin {
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ static get requires(): PluginDependencies;
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ static get pluginName(): 'ImageInlineEditing';
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ init(): void;
32
+ /**
33
+ * Configures conversion pipelines to support upcasting and downcasting
34
+ * inline images (inline image widgets) and their attributes.
35
+ */
36
+ private _setupConversion;
37
+ /**
38
+ * Integrates the plugin with the clipboard pipeline.
39
+ *
40
+ * Idea is that the feature should recognize the user's intent when an **block** image is
41
+ * pasted or dropped. If such an image is pasted/dropped into a non-empty block
42
+ * (e.g. a paragraph with some text) it gets converted into an inline image on the fly.
43
+ *
44
+ * We assume this is the user's intent if they decided to put their image there.
45
+ *
46
+ * **Note**: If a block image has a caption, it will not be converted to an inline image
47
+ * to avoid the confusion. Captions are added on purpose and they should never be lost
48
+ * in the clipboard pipeline.
49
+ *
50
+ * See the `ImageBlockEditing` for the similar integration that works in the opposite direction.
51
+ */
52
+ private _setupClipboardIntegration;
53
+ }