@ckeditor/ckeditor5-image 36.0.1 → 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
package/src/image/ui/utils.js
CHANGED
|
@@ -2,53 +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
|
-
/**
|
|
7
|
-
* @module image/image/ui/utils
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
5
|
import { BalloonPanelView } from 'ckeditor5/src/ui';
|
|
11
|
-
|
|
12
6
|
/**
|
|
13
7
|
* A helper utility that positions the
|
|
14
8
|
* {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon} instance
|
|
15
9
|
* with respect to the image in the editor content, if one is selected.
|
|
16
10
|
*
|
|
17
|
-
* @param
|
|
11
|
+
* @param editor The editor instance.
|
|
18
12
|
*/
|
|
19
|
-
export function repositionContextualBalloon(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
13
|
+
export function repositionContextualBalloon(editor) {
|
|
14
|
+
const balloon = editor.plugins.get('ContextualBalloon');
|
|
15
|
+
const imageUtils = editor.plugins.get('ImageUtils');
|
|
16
|
+
if (imageUtils.getClosestSelectedImageWidget(editor.editing.view.document.selection)) {
|
|
17
|
+
const position = getBalloonPositionData(editor);
|
|
18
|
+
balloon.updatePosition(position);
|
|
19
|
+
}
|
|
27
20
|
}
|
|
28
|
-
|
|
29
21
|
/**
|
|
30
22
|
* Returns the positioning options that control the geometry of the
|
|
31
23
|
* {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon} with respect
|
|
32
24
|
* to the selected element in the editor content.
|
|
33
25
|
*
|
|
34
|
-
* @param
|
|
35
|
-
* @returns {module:utils/dom/position~Options}
|
|
26
|
+
* @param editor The editor instance.
|
|
36
27
|
*/
|
|
37
|
-
export function getBalloonPositionData(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
28
|
+
export function getBalloonPositionData(editor) {
|
|
29
|
+
const editingView = editor.editing.view;
|
|
30
|
+
const defaultPositions = BalloonPanelView.defaultPositions;
|
|
31
|
+
const imageUtils = editor.plugins.get('ImageUtils');
|
|
32
|
+
return {
|
|
33
|
+
target: editingView.domConverter.mapViewToDom(imageUtils.getClosestSelectedImageWidget(editingView.document.selection)),
|
|
34
|
+
positions: [
|
|
35
|
+
defaultPositions.northArrowSouth,
|
|
36
|
+
defaultPositions.northArrowSouthWest,
|
|
37
|
+
defaultPositions.northArrowSouthEast,
|
|
38
|
+
defaultPositions.southArrowNorth,
|
|
39
|
+
defaultPositions.southArrowNorthWest,
|
|
40
|
+
defaultPositions.southArrowNorthEast,
|
|
41
|
+
defaultPositions.viewportStickyNorth
|
|
42
|
+
]
|
|
43
|
+
};
|
|
54
44
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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/utils
|
|
7
|
+
*/
|
|
8
|
+
import type { DocumentSelection, MatcherPattern, Schema, Selection, ViewContainerElement, DowncastWriter } from 'ckeditor5/src/engine';
|
|
9
|
+
import type { Editor } from 'ckeditor5/src/core';
|
|
10
|
+
/**
|
|
11
|
+
* Creates a view element representing the inline image.
|
|
12
|
+
*
|
|
13
|
+
* ```html
|
|
14
|
+
* <span class="image-inline"><img></img></span>
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Note that `alt` and `src` attributes are converted separately, so they are not included.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare function createInlineImageViewElement(writer: DowncastWriter): ViewContainerElement;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a view element representing the block image.
|
|
24
|
+
*
|
|
25
|
+
* ```html
|
|
26
|
+
* <figure class="image"><img></img></figure>
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* Note that `alt` and `src` attributes are converted separately, so they are not included.
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export declare function createBlockImageViewElement(writer: DowncastWriter): ViewContainerElement;
|
|
34
|
+
/**
|
|
35
|
+
* A function returning a `MatcherPattern` for a particular type of View images.
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
* @param matchImageType The type of created image.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getImgViewElementMatcher(editor: Editor, matchImageType: 'imageBlock' | 'imageInline'): MatcherPattern;
|
|
41
|
+
/**
|
|
42
|
+
* Considering the current model selection, it returns the name of the model image element
|
|
43
|
+
* (`'imageBlock'` or `'imageInline'`) that will make most sense from the UX perspective if a new
|
|
44
|
+
* image was inserted (also: uploaded, dropped, pasted) at that selection.
|
|
45
|
+
*
|
|
46
|
+
* The assumption is that inserting images into empty blocks or on other block widgets should
|
|
47
|
+
* produce block images. Inline images should be inserted in other cases, e.g. in paragraphs
|
|
48
|
+
* that already contain some text.
|
|
49
|
+
*
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
export declare function determineImageTypeForInsertionAtSelection(schema: Schema, selection: Selection | DocumentSelection): 'imageBlock' | 'imageInline';
|
package/src/image/utils.js
CHANGED
|
@@ -2,98 +2,77 @@
|
|
|
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
|
-
/**
|
|
7
|
-
* @module image/image/utils
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
5
|
import { first } from 'ckeditor5/src/utils';
|
|
11
|
-
|
|
12
6
|
/**
|
|
13
7
|
* Creates a view element representing the inline image.
|
|
14
8
|
*
|
|
15
|
-
*
|
|
9
|
+
* ```html
|
|
10
|
+
* <span class="image-inline"><img></img></span>
|
|
11
|
+
* ```
|
|
16
12
|
*
|
|
17
13
|
* Note that `alt` and `src` attributes are converted separately, so they are not included.
|
|
18
14
|
*
|
|
19
|
-
* @
|
|
20
|
-
* @param {module:engine/view/downcastwriter~DowncastWriter} writer
|
|
21
|
-
* @returns {module:engine/view/containerelement~ContainerElement}
|
|
15
|
+
* @internal
|
|
22
16
|
*/
|
|
23
|
-
export function createInlineImageViewElement(
|
|
24
|
-
|
|
25
|
-
writer.createEmptyElement( 'img' )
|
|
26
|
-
);
|
|
17
|
+
export function createInlineImageViewElement(writer) {
|
|
18
|
+
return writer.createContainerElement('span', { class: 'image-inline' }, writer.createEmptyElement('img'));
|
|
27
19
|
}
|
|
28
|
-
|
|
29
20
|
/**
|
|
30
21
|
* Creates a view element representing the block image.
|
|
31
22
|
*
|
|
32
|
-
*
|
|
23
|
+
* ```html
|
|
24
|
+
* <figure class="image"><img></img></figure>
|
|
25
|
+
* ```
|
|
33
26
|
*
|
|
34
27
|
* Note that `alt` and `src` attributes are converted separately, so they are not included.
|
|
35
28
|
*
|
|
36
|
-
* @
|
|
37
|
-
* @param {module:engine/view/downcastwriter~DowncastWriter} writer
|
|
38
|
-
* @returns {module:engine/view/containerelement~ContainerElement}
|
|
29
|
+
* @internal
|
|
39
30
|
*/
|
|
40
|
-
export function createBlockImageViewElement(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
export function createBlockImageViewElement(writer) {
|
|
32
|
+
return writer.createContainerElement('figure', { class: 'image' }, [
|
|
33
|
+
writer.createEmptyElement('img'),
|
|
34
|
+
writer.createSlot('children')
|
|
35
|
+
]);
|
|
45
36
|
}
|
|
46
|
-
|
|
47
37
|
/**
|
|
48
38
|
* A function returning a `MatcherPattern` for a particular type of View images.
|
|
49
39
|
*
|
|
50
|
-
* @
|
|
51
|
-
* @param
|
|
52
|
-
* @param {'imageBlock'|'imageInline'} matchImageType The type of created image.
|
|
53
|
-
* @returns {module:engine/view/matcher~MatcherPattern}
|
|
40
|
+
* @internal
|
|
41
|
+
* @param matchImageType The type of created image.
|
|
54
42
|
*/
|
|
55
|
-
export function getImgViewElementMatcher(
|
|
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
|
-
// This will trigger src consumption (See https://github.com/ckeditor/ckeditor5/issues/11530).
|
|
89
|
-
if ( element.hasAttribute( 'src' ) ) {
|
|
90
|
-
pattern.attributes = [ 'src' ];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return pattern;
|
|
94
|
-
}
|
|
43
|
+
export function getImgViewElementMatcher(editor, matchImageType) {
|
|
44
|
+
const imageUtils = editor.plugins.get('ImageUtils');
|
|
45
|
+
const areBothImagePluginsLoaded = editor.plugins.has('ImageInlineEditing') && editor.plugins.has('ImageBlockEditing');
|
|
46
|
+
return element => {
|
|
47
|
+
// Check if the matched view element is an <img>.
|
|
48
|
+
if (!imageUtils.isInlineImageView(element)) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
// If just one of the plugins is loaded (block or inline), it will match all kinds of images.
|
|
52
|
+
if (!areBothImagePluginsLoaded) {
|
|
53
|
+
return getPositiveMatchPattern(element);
|
|
54
|
+
}
|
|
55
|
+
// The <img> can be standalone, wrapped in <figure>...</figure> (ImageBlock plugin) or
|
|
56
|
+
// wrapped in <figure><a>...</a></figure> (LinkImage plugin).
|
|
57
|
+
const imageType = element.getStyle('display') == 'block' || element.findAncestor(imageUtils.isBlockImageView) ?
|
|
58
|
+
'imageBlock' :
|
|
59
|
+
'imageInline';
|
|
60
|
+
if (imageType !== matchImageType) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return getPositiveMatchPattern(element);
|
|
64
|
+
};
|
|
65
|
+
function getPositiveMatchPattern(element) {
|
|
66
|
+
const pattern = {
|
|
67
|
+
name: true
|
|
68
|
+
};
|
|
69
|
+
// This will trigger src consumption (See https://github.com/ckeditor/ckeditor5/issues/11530).
|
|
70
|
+
if (element.hasAttribute('src')) {
|
|
71
|
+
pattern.attributes = ['src'];
|
|
72
|
+
}
|
|
73
|
+
return pattern;
|
|
74
|
+
}
|
|
95
75
|
}
|
|
96
|
-
|
|
97
76
|
/**
|
|
98
77
|
* Considering the current model selection, it returns the name of the model image element
|
|
99
78
|
* (`'imageBlock'` or `'imageInline'`) that will make most sense from the UX perspective if a new
|
|
@@ -103,25 +82,19 @@ export function getImgViewElementMatcher( editor, matchImageType ) {
|
|
|
103
82
|
* produce block images. Inline images should be inserted in other cases, e.g. in paragraphs
|
|
104
83
|
* that already contain some text.
|
|
105
84
|
*
|
|
106
|
-
* @
|
|
107
|
-
* @param {module:engine/model/schema~Schema} schema
|
|
108
|
-
* @param {module:engine/model/selection~Selection|module:engine/model/documentselection~DocumentSelection} selection
|
|
109
|
-
* @returns {'imageBlock'|'imageInline'}
|
|
85
|
+
* @internal
|
|
110
86
|
*/
|
|
111
|
-
export function determineImageTypeForInsertionAtSelection(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
// Otherwise insert an inline image.
|
|
126
|
-
return 'imageInline';
|
|
87
|
+
export function determineImageTypeForInsertionAtSelection(schema, selection) {
|
|
88
|
+
const firstBlock = first(selection.getSelectedBlocks());
|
|
89
|
+
// Insert a block image if the selection is not in/on block elements or it's on a block widget.
|
|
90
|
+
if (!firstBlock || schema.isObject(firstBlock)) {
|
|
91
|
+
return 'imageBlock';
|
|
92
|
+
}
|
|
93
|
+
// A block image should also be inserted into an empty block element
|
|
94
|
+
// (that is not an empty list item so the list won't get split).
|
|
95
|
+
if (firstBlock.isEmpty && firstBlock.name != 'listItem') {
|
|
96
|
+
return 'imageBlock';
|
|
97
|
+
}
|
|
98
|
+
// Otherwise insert an inline image.
|
|
99
|
+
return 'imageInline';
|
|
127
100
|
}
|
package/src/image.d.ts
ADDED
|
@@ -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/image
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
import '../theme/image.css';
|
|
10
|
+
import './imageconfig';
|
|
11
|
+
/**
|
|
12
|
+
* The image plugin.
|
|
13
|
+
*
|
|
14
|
+
* For a detailed overview, check the {@glink features/images/images-overview image feature} documentation.
|
|
15
|
+
*
|
|
16
|
+
* This is a "glue" plugin which loads the following plugins:
|
|
17
|
+
*
|
|
18
|
+
* * {@link module:image/imageblock~ImageBlock},
|
|
19
|
+
* * {@link module:image/imageinline~ImageInline},
|
|
20
|
+
*
|
|
21
|
+
* Usually, it is used in conjunction with other plugins from this package. See the {@glink api/image package page}
|
|
22
|
+
* for more information.
|
|
23
|
+
*/
|
|
24
|
+
export default class Image extends Plugin {
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc
|
|
27
|
+
*/
|
|
28
|
+
static get requires(): PluginDependencies;
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
32
|
+
static get pluginName(): 'Image';
|
|
33
|
+
}
|
|
34
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
35
|
+
interface PluginsMap {
|
|
36
|
+
[Image.pluginName]: Image;
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/image.js
CHANGED
|
@@ -2,18 +2,14 @@
|
|
|
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
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
|
|
12
9
|
import ImageBlock from './imageblock';
|
|
13
10
|
import ImageInline from './imageinline';
|
|
14
|
-
|
|
15
11
|
import '../theme/image.css';
|
|
16
|
-
|
|
12
|
+
import './imageconfig';
|
|
17
13
|
/**
|
|
18
14
|
* The image plugin.
|
|
19
15
|
*
|
|
@@ -26,44 +22,18 @@ import '../theme/image.css';
|
|
|
26
22
|
*
|
|
27
23
|
* Usually, it is used in conjunction with other plugins from this package. See the {@glink api/image package page}
|
|
28
24
|
* for more information.
|
|
29
|
-
*
|
|
30
|
-
* @extends module:core/plugin~Plugin
|
|
31
25
|
*/
|
|
32
26
|
export default class Image extends Plugin {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
static get requires() {
|
|
31
|
+
return [ImageBlock, ImageInline];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @inheritDoc
|
|
35
|
+
*/
|
|
36
|
+
static get pluginName() {
|
|
37
|
+
return 'Image';
|
|
38
|
+
}
|
|
46
39
|
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* The configuration of the image features. Used by the image features in the `@ckeditor/ckeditor5-image` package.
|
|
50
|
-
*
|
|
51
|
-
* Read more in {@link module:image/image~ImageConfig}.
|
|
52
|
-
*
|
|
53
|
-
* @member {module:image/image~ImageConfig} module:core/editor/editorconfig~EditorConfig#image
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* The configuration of the image features. Used by the image features in the `@ckeditor/ckeditor5-image` package.
|
|
58
|
-
*
|
|
59
|
-
* ClassicEditor
|
|
60
|
-
* .create( editorElement, {
|
|
61
|
-
* image: ... // Image feature options.
|
|
62
|
-
* } )
|
|
63
|
-
* .then( ... )
|
|
64
|
-
* .catch( ... );
|
|
65
|
-
*
|
|
66
|
-
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
67
|
-
*
|
|
68
|
-
* @interface ImageConfig
|
|
69
|
-
*/
|
|
@@ -0,0 +1,35 @@
|
|
|
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/imageblock
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
import '../theme/image.css';
|
|
10
|
+
/**
|
|
11
|
+
* The image block plugin.
|
|
12
|
+
*
|
|
13
|
+
* This is a "glue" plugin which loads the following plugins:
|
|
14
|
+
*
|
|
15
|
+
* * {@link module:image/image/imageblockediting~ImageBlockEditing},
|
|
16
|
+
* * {@link module:image/imagetextalternative~ImageTextAlternative}.
|
|
17
|
+
*
|
|
18
|
+
* Usually, it is used in conjunction with other plugins from this package. See the {@glink api/image package page}
|
|
19
|
+
* for more information.
|
|
20
|
+
*/
|
|
21
|
+
export default class ImageBlock extends Plugin {
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get requires(): PluginDependencies;
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
static get pluginName(): 'ImageBlock';
|
|
30
|
+
}
|
|
31
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
32
|
+
interface PluginsMap {
|
|
33
|
+
[ImageBlock.pluginName]: ImageBlock;
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/imageblock.js
CHANGED
|
@@ -2,19 +2,14 @@
|
|
|
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/imageblock
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
9
|
import { Widget } from 'ckeditor5/src/widget';
|
|
12
|
-
|
|
13
10
|
import ImageTextAlternative from './imagetextalternative';
|
|
14
11
|
import ImageBlockEditing from './image/imageblockediting';
|
|
15
|
-
|
|
16
12
|
import '../theme/image.css';
|
|
17
|
-
|
|
18
13
|
/**
|
|
19
14
|
* The image block plugin.
|
|
20
15
|
*
|
|
@@ -25,22 +20,18 @@ import '../theme/image.css';
|
|
|
25
20
|
*
|
|
26
21
|
* Usually, it is used in conjunction with other plugins from this package. See the {@glink api/image package page}
|
|
27
22
|
* for more information.
|
|
28
|
-
*
|
|
29
|
-
* @extends module:core/plugin~Plugin
|
|
30
23
|
*/
|
|
31
24
|
export default class ImageBlock extends Plugin {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc
|
|
27
|
+
*/
|
|
28
|
+
static get requires() {
|
|
29
|
+
return [ImageBlockEditing, Widget, ImageTextAlternative];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @inheritDoc
|
|
33
|
+
*/
|
|
34
|
+
static get pluginName() {
|
|
35
|
+
return 'ImageBlock';
|
|
36
|
+
}
|
|
45
37
|
}
|
|
46
|
-
|
|
@@ -0,0 +1,92 @@
|
|
|
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/imagecaption/imagecaptionediting
|
|
7
|
+
*/
|
|
8
|
+
import { type Editor, Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
import { Element } from 'ckeditor5/src/engine';
|
|
10
|
+
/**
|
|
11
|
+
* The image caption engine plugin. It is responsible for:
|
|
12
|
+
*
|
|
13
|
+
* * registering converters for the caption element,
|
|
14
|
+
* * registering converters for the caption model attribute,
|
|
15
|
+
* * registering the {@link module:image/imagecaption/toggleimagecaptioncommand~ToggleImageCaptionCommand `toggleImageCaption`} command.
|
|
16
|
+
*/
|
|
17
|
+
export default class ImageCaptionEditing extends Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get requires(): PluginDependencies;
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get pluginName(): 'ImageCaptionEditing';
|
|
26
|
+
/**
|
|
27
|
+
* A map that keeps saved JSONified image captions and image model elements they are
|
|
28
|
+
* associated with.
|
|
29
|
+
*
|
|
30
|
+
* To learn more about this system, see {@link #_saveCaption}.
|
|
31
|
+
*/
|
|
32
|
+
private _savedCaptionsMap;
|
|
33
|
+
/**
|
|
34
|
+
* @inheritDoc
|
|
35
|
+
*/
|
|
36
|
+
constructor(editor: Editor);
|
|
37
|
+
/**
|
|
38
|
+
* @inheritDoc
|
|
39
|
+
*/
|
|
40
|
+
init(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Configures conversion pipelines to support upcasting and downcasting
|
|
43
|
+
* image captions.
|
|
44
|
+
*/
|
|
45
|
+
private _setupConversion;
|
|
46
|
+
/**
|
|
47
|
+
* Integrates with {@link module:image/image/imagetypecommand~ImageTypeCommand image type commands}
|
|
48
|
+
* to make sure the caption is preserved when the type of an image changes so it can be restored
|
|
49
|
+
* in the future if the user decides they want their caption back.
|
|
50
|
+
*/
|
|
51
|
+
private _setupImageTypeCommandsIntegration;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the saved {@link module:engine/model/element~Element#toJSON JSONified} caption
|
|
54
|
+
* of an image model element.
|
|
55
|
+
*
|
|
56
|
+
* See {@link #_saveCaption}.
|
|
57
|
+
*
|
|
58
|
+
* @internal
|
|
59
|
+
* @param imageModelElement The model element the caption should be returned for.
|
|
60
|
+
* @returns The model caption element or `null` if there is none.
|
|
61
|
+
*/
|
|
62
|
+
_getSavedCaption(imageModelElement: Element): Element | null;
|
|
63
|
+
/**
|
|
64
|
+
* Saves a {@link module:engine/model/element~Element#toJSON JSONified} caption for
|
|
65
|
+
* an image element to allow restoring it in the future.
|
|
66
|
+
*
|
|
67
|
+
* A caption is saved every time it gets hidden and/or the type of an image changes. The
|
|
68
|
+
* user should be able to restore it on demand.
|
|
69
|
+
*
|
|
70
|
+
* **Note**: The caption cannot be stored in the image model element attribute because,
|
|
71
|
+
* for instance, when the model state propagates to collaborators, the attribute would get
|
|
72
|
+
* lost (mainly because it does not convert to anything when the caption is hidden) and
|
|
73
|
+
* the states of collaborators' models would de-synchronize causing numerous issues.
|
|
74
|
+
*
|
|
75
|
+
* See {@link #_getSavedCaption}.
|
|
76
|
+
*
|
|
77
|
+
* @internal
|
|
78
|
+
* @param imageModelElement The model element the caption is saved for.
|
|
79
|
+
* @param caption The caption model element to be saved.
|
|
80
|
+
*/
|
|
81
|
+
_saveCaption(imageModelElement: Element, caption: Element): void;
|
|
82
|
+
/**
|
|
83
|
+
* Reconverts image caption when image alt attribute changes.
|
|
84
|
+
* The change of alt attribute is reflected in caption's aria-label attribute.
|
|
85
|
+
*/
|
|
86
|
+
private _registerCaptionReconversion;
|
|
87
|
+
}
|
|
88
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
89
|
+
interface PluginsMap {
|
|
90
|
+
[ImageCaptionEditing.pluginName]: ImageCaptionEditing;
|
|
91
|
+
}
|
|
92
|
+
}
|