@ckeditor/ckeditor5-image 41.2.0 → 41.3.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/dist/content-index.css +105 -0
- package/dist/editor-index.css +108 -0
- package/dist/index.css +462 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +5865 -0
- package/dist/index.js.map +1 -0
- package/dist/types/augmentation.d.ts +56 -0
- package/dist/types/autoimage.d.ts +52 -0
- package/dist/types/image/converters.d.ts +66 -0
- package/dist/types/image/imageblockediting.d.ts +59 -0
- package/dist/types/image/imageediting.d.ts +30 -0
- package/dist/types/image/imageinlineediting.d.ts +60 -0
- package/dist/types/image/imageloadobserver.d.ts +48 -0
- package/dist/types/image/imageplaceholder.d.ts +39 -0
- package/dist/types/image/imagetypecommand.d.ts +44 -0
- package/dist/types/image/insertimagecommand.d.ts +66 -0
- package/dist/types/image/replaceimagesourcecommand.d.ts +51 -0
- package/dist/types/image/ui/utils.d.ts +25 -0
- package/dist/types/image/utils.d.ts +64 -0
- package/dist/types/image.d.ts +34 -0
- package/dist/types/imageblock.d.ts +34 -0
- package/dist/types/imagecaption/imagecaptionediting.d.ts +89 -0
- package/dist/types/imagecaption/imagecaptionui.d.ts +26 -0
- package/dist/types/imagecaption/imagecaptionutils.d.ts +38 -0
- package/dist/types/imagecaption/toggleimagecaptioncommand.d.ts +66 -0
- package/dist/types/imagecaption.d.ts +26 -0
- package/dist/types/imageconfig.d.ts +712 -0
- package/dist/types/imageinline.d.ts +34 -0
- package/dist/types/imageinsert/imageinsertui.d.ts +74 -0
- package/dist/types/imageinsert/imageinsertviaurlui.d.ts +44 -0
- package/dist/types/imageinsert/ui/imageinsertformview.d.ts +56 -0
- package/dist/types/imageinsert/ui/imageinserturlview.d.ts +107 -0
- package/dist/types/imageinsert.d.ts +33 -0
- package/dist/types/imageinsertviaurl.d.ts +31 -0
- package/dist/types/imageresize/imageresizebuttons.d.ts +67 -0
- package/dist/types/imageresize/imageresizeediting.d.ts +41 -0
- package/dist/types/imageresize/imageresizehandles.d.ts +31 -0
- package/dist/types/imageresize/resizeimagecommand.d.ts +42 -0
- package/dist/types/imageresize.d.ts +27 -0
- package/dist/types/imagesizeattributes.d.ts +34 -0
- package/dist/types/imagestyle/converters.d.ts +24 -0
- package/dist/types/imagestyle/imagestylecommand.d.ts +68 -0
- package/dist/types/imagestyle/imagestyleediting.d.ts +50 -0
- package/dist/types/imagestyle/imagestyleui.d.ts +56 -0
- package/dist/types/imagestyle/utils.d.ts +101 -0
- package/dist/types/imagestyle.d.ts +32 -0
- package/dist/types/imagetextalternative/imagetextalternativecommand.d.ts +34 -0
- package/dist/types/imagetextalternative/imagetextalternativeediting.d.ts +28 -0
- package/dist/types/imagetextalternative/imagetextalternativeui.d.ts +68 -0
- package/dist/types/imagetextalternative/ui/textalternativeformview.d.ts +90 -0
- package/dist/types/imagetextalternative.d.ts +29 -0
- package/dist/types/imagetoolbar.d.ts +35 -0
- package/dist/types/imageupload/imageuploadediting.d.ts +111 -0
- package/dist/types/imageupload/imageuploadprogress.d.ts +42 -0
- package/dist/types/imageupload/imageuploadui.d.ts +23 -0
- package/dist/types/imageupload/uploadimagecommand.d.ts +60 -0
- package/dist/types/imageupload/utils.d.ts +33 -0
- package/dist/types/imageupload.d.ts +32 -0
- package/dist/types/imageutils.d.ts +125 -0
- package/dist/types/index.d.ts +48 -0
- package/dist/types/pictureediting.d.ts +88 -0
- package/package.json +4 -3
- package/src/imageresize/imageresizeediting.d.ts +4 -0
- package/src/imageresize/imageresizeediting.js +6 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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
|
+
import type { ImageConfig, AutoImage, Image, ImageBlock, ImageCaption, ImageInline, ImageInsert, ImageInsertViaUrl, ImageResize, ImageStyle, ImageTextAlternative, ImageToolbar, ImageUpload, ImageUtils, ImageBlockEditing, ImageEditing, ImageCaptionEditing, ImageCaptionUI, ImageCaptionUtils, ImageInsertUI, ImageResizeEditing, ImageSizeAttributes, ImageStyleEditing, ImageStyleUI, ImageTextAlternativeEditing, ImageTextAlternativeUI, ImageUploadEditing, ImageUploadProgress, ImageUploadUI, ImageTypeCommand, InsertImageCommand, ReplaceImageSourceCommand, ToggleImageCaptionCommand, ResizeImageCommand, ImageStyleCommand, ImageTextAlternativeCommand, UploadImageCommand } from './index.js';
|
|
6
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
7
|
+
interface EditorConfig {
|
|
8
|
+
/**
|
|
9
|
+
* The configuration of the image features. Used by the image features in the `@ckeditor/ckeditor5-image` package.
|
|
10
|
+
*
|
|
11
|
+
* Read more in {@link module:image/imageconfig~ImageConfig}.
|
|
12
|
+
*/
|
|
13
|
+
image?: ImageConfig;
|
|
14
|
+
}
|
|
15
|
+
interface PluginsMap {
|
|
16
|
+
[AutoImage.pluginName]: AutoImage;
|
|
17
|
+
[Image.pluginName]: Image;
|
|
18
|
+
[ImageBlock.pluginName]: ImageBlock;
|
|
19
|
+
[ImageCaption.pluginName]: ImageCaption;
|
|
20
|
+
[ImageInline.pluginName]: ImageInline;
|
|
21
|
+
[ImageInsert.pluginName]: ImageInsert;
|
|
22
|
+
[ImageInsertViaUrl.pluginName]: ImageInsertViaUrl;
|
|
23
|
+
[ImageResize.pluginName]: ImageResize;
|
|
24
|
+
[ImageStyle.pluginName]: ImageStyle;
|
|
25
|
+
[ImageTextAlternative.pluginName]: ImageTextAlternative;
|
|
26
|
+
[ImageToolbar.pluginName]: ImageToolbar;
|
|
27
|
+
[ImageUpload.pluginName]: ImageUpload;
|
|
28
|
+
[ImageUtils.pluginName]: ImageUtils;
|
|
29
|
+
[ImageBlockEditing.pluginName]: ImageBlockEditing;
|
|
30
|
+
[ImageEditing.pluginName]: ImageEditing;
|
|
31
|
+
[ImageCaptionEditing.pluginName]: ImageCaptionEditing;
|
|
32
|
+
[ImageCaptionUI.pluginName]: ImageCaptionUI;
|
|
33
|
+
[ImageCaptionUtils.pluginName]: ImageCaptionUtils;
|
|
34
|
+
[ImageInsertUI.pluginName]: ImageInsertUI;
|
|
35
|
+
[ImageResizeEditing.pluginName]: ImageResizeEditing;
|
|
36
|
+
[ImageSizeAttributes.pluginName]: ImageSizeAttributes;
|
|
37
|
+
[ImageStyleEditing.pluginName]: ImageStyleEditing;
|
|
38
|
+
[ImageStyleUI.pluginName]: ImageStyleUI;
|
|
39
|
+
[ImageTextAlternativeEditing.pluginName]: ImageTextAlternativeEditing;
|
|
40
|
+
[ImageTextAlternativeUI.pluginName]: ImageTextAlternativeUI;
|
|
41
|
+
[ImageUploadEditing.pluginName]: ImageUploadEditing;
|
|
42
|
+
[ImageUploadProgress.pluginName]: ImageUploadProgress;
|
|
43
|
+
[ImageUploadUI.pluginName]: ImageUploadUI;
|
|
44
|
+
}
|
|
45
|
+
interface CommandsMap {
|
|
46
|
+
imageTypeBlock: ImageTypeCommand;
|
|
47
|
+
imageTypeInline: ImageTypeCommand;
|
|
48
|
+
insertImage: InsertImageCommand;
|
|
49
|
+
replaceImageSource: ReplaceImageSourceCommand;
|
|
50
|
+
toggleImageCaption: ToggleImageCaptionCommand;
|
|
51
|
+
resizeImage: ResizeImageCommand;
|
|
52
|
+
imageStyle: ImageStyleCommand;
|
|
53
|
+
imageTextAlternative: ImageTextAlternativeCommand;
|
|
54
|
+
uploadImage: UploadImageCommand;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/autoimage
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type Editor } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { Clipboard } from 'ckeditor5/src/clipboard.js';
|
|
10
|
+
import { Undo } from 'ckeditor5/src/undo.js';
|
|
11
|
+
import { Delete } from 'ckeditor5/src/typing.js';
|
|
12
|
+
import ImageUtils from './imageutils.js';
|
|
13
|
+
/**
|
|
14
|
+
* The auto-image plugin. It recognizes image links in the pasted content and embeds
|
|
15
|
+
* them shortly after they are injected into the document.
|
|
16
|
+
*/
|
|
17
|
+
export default class AutoImage extends Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get requires(): readonly [typeof Clipboard, typeof ImageUtils, typeof Undo, typeof Delete];
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get pluginName(): "AutoImage";
|
|
26
|
+
/**
|
|
27
|
+
* The paste–to–embed `setTimeout` ID. Stored as a property to allow
|
|
28
|
+
* cleaning of the timeout.
|
|
29
|
+
*/
|
|
30
|
+
private _timeoutId;
|
|
31
|
+
/**
|
|
32
|
+
* The position where the `<imageBlock>` element will be inserted after the timeout,
|
|
33
|
+
* determined each time a new content is pasted into the document.
|
|
34
|
+
*/
|
|
35
|
+
private _positionToInsert;
|
|
36
|
+
/**
|
|
37
|
+
* @inheritDoc
|
|
38
|
+
*/
|
|
39
|
+
constructor(editor: Editor);
|
|
40
|
+
/**
|
|
41
|
+
* @inheritDoc
|
|
42
|
+
*/
|
|
43
|
+
init(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Analyzes the part of the document between provided positions in search for a URL representing an image.
|
|
46
|
+
* When the URL is found, it is automatically converted into an image.
|
|
47
|
+
*
|
|
48
|
+
* @param leftPosition Left position of the selection.
|
|
49
|
+
* @param rightPosition Right position of the selection.
|
|
50
|
+
*/
|
|
51
|
+
private _embedImageBetweenPositions;
|
|
52
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/converters
|
|
7
|
+
*/
|
|
8
|
+
import type { DowncastDispatcher, UpcastDispatcher } from 'ckeditor5/src/engine.js';
|
|
9
|
+
import type ImageUtils from '../imageutils.js';
|
|
10
|
+
/**
|
|
11
|
+
* Returns a function that converts the image view representation:
|
|
12
|
+
*
|
|
13
|
+
* ```html
|
|
14
|
+
* <figure class="image"><img src="..." alt="..."></img></figure>
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* to the model representation:
|
|
18
|
+
*
|
|
19
|
+
* ```html
|
|
20
|
+
* <imageBlock src="..." alt="..."></imageBlock>
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* The entire content of the `<figure>` element except the first `<img>` is being converted as children
|
|
24
|
+
* of the `<imageBlock>` model element.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export declare function upcastImageFigure(imageUtils: ImageUtils): (dispatcher: UpcastDispatcher) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Returns a function that converts the image view representation:
|
|
31
|
+
*
|
|
32
|
+
* ```html
|
|
33
|
+
* <picture><source ... /><source ... />...<img ... /></picture>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* to the model representation as the `sources` attribute:
|
|
37
|
+
*
|
|
38
|
+
* ```html
|
|
39
|
+
* <image[Block|Inline] ... sources="..."></image[Block|Inline]>
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
export declare function upcastPicture(imageUtils: ImageUtils): (dispatcher: UpcastDispatcher) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Converter used to convert the `srcset` model image attribute to the `srcset` and `sizes` attributes in the view.
|
|
47
|
+
*
|
|
48
|
+
* @internal
|
|
49
|
+
* @param imageType The type of the image.
|
|
50
|
+
*/
|
|
51
|
+
export declare function downcastSrcsetAttribute(imageUtils: ImageUtils, imageType: 'imageBlock' | 'imageInline'): (dispatcher: DowncastDispatcher) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Converts the `source` model attribute to the `<picture><source /><source />...<img /></picture>`
|
|
54
|
+
* view structure.
|
|
55
|
+
*
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
export declare function downcastSourcesAttribute(imageUtils: ImageUtils): (dispatcher: DowncastDispatcher) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Converter used to convert a given image attribute from the model to the view.
|
|
61
|
+
*
|
|
62
|
+
* @internal
|
|
63
|
+
* @param imageType The type of the image.
|
|
64
|
+
* @param attributeKey The name of the attribute to convert.
|
|
65
|
+
*/
|
|
66
|
+
export declare function downcastImageAttribute(imageUtils: ImageUtils, imageType: 'imageBlock' | 'imageInline', attributeKey: string): (dispatcher: DowncastDispatcher) => void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/imageblockediting
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { ClipboardPipeline } from 'ckeditor5/src/clipboard.js';
|
|
10
|
+
import ImageEditing from './imageediting.js';
|
|
11
|
+
import ImageSizeAttributes from '../imagesizeattributes.js';
|
|
12
|
+
import ImageUtils from '../imageutils.js';
|
|
13
|
+
import ImagePlaceholder from './imageplaceholder.js';
|
|
14
|
+
/**
|
|
15
|
+
* The image block plugin.
|
|
16
|
+
*
|
|
17
|
+
* It registers:
|
|
18
|
+
*
|
|
19
|
+
* * `<imageBlock>` as a block element in the document schema, and allows `alt`, `src` and `srcset` attributes.
|
|
20
|
+
* * converters for editing and data pipelines.,
|
|
21
|
+
* * {@link module:image/image/imagetypecommand~ImageTypeCommand `'imageTypeBlock'`} command that converts inline images into
|
|
22
|
+
* block images.
|
|
23
|
+
*/
|
|
24
|
+
export default class ImageBlockEditing extends Plugin {
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc
|
|
27
|
+
*/
|
|
28
|
+
static get requires(): readonly [typeof ImageEditing, typeof ImageSizeAttributes, typeof ImageUtils, typeof ImagePlaceholder, typeof ClipboardPipeline];
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
32
|
+
static get pluginName(): "ImageBlockEditing";
|
|
33
|
+
/**
|
|
34
|
+
* @inheritDoc
|
|
35
|
+
*/
|
|
36
|
+
init(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Configures conversion pipelines to support upcasting and downcasting
|
|
39
|
+
* block images (block image widgets) and their attributes.
|
|
40
|
+
*/
|
|
41
|
+
private _setupConversion;
|
|
42
|
+
/**
|
|
43
|
+
* Integrates the plugin with the clipboard pipeline.
|
|
44
|
+
*
|
|
45
|
+
* Idea is that the feature should recognize the user's intent when an **inline** image is
|
|
46
|
+
* pasted or dropped. If such an image is pasted/dropped:
|
|
47
|
+
*
|
|
48
|
+
* * into an empty block (e.g. an empty paragraph),
|
|
49
|
+
* * on another object (e.g. some block widget).
|
|
50
|
+
*
|
|
51
|
+
* it gets converted into a block image on the fly. We assume this is the user's intent
|
|
52
|
+
* if they decided to put their image there.
|
|
53
|
+
*
|
|
54
|
+
* See the `ImageInlineEditing` for the similar integration that works in the opposite direction.
|
|
55
|
+
*
|
|
56
|
+
* The feature also sets image `width` and `height` attributes on paste.
|
|
57
|
+
*/
|
|
58
|
+
private _setupClipboardIntegration;
|
|
59
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 } from 'ckeditor5/src/core.js';
|
|
9
|
+
import ImageUtils from '../imageutils.js';
|
|
10
|
+
/**
|
|
11
|
+
* The image engine plugin. This module loads common code shared between
|
|
12
|
+
* {@link module:image/image/imageinlineediting~ImageInlineEditing} and
|
|
13
|
+
* {@link module:image/image/imageblockediting~ImageBlockEditing} plugins.
|
|
14
|
+
*
|
|
15
|
+
* This plugin registers the {@link module:image/image/insertimagecommand~InsertImageCommand 'insertImage'} command.
|
|
16
|
+
*/
|
|
17
|
+
export default class ImageEditing extends Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get requires(): readonly [typeof ImageUtils];
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get pluginName(): "ImageEditing";
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
init(): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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 } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { ClipboardPipeline } from 'ckeditor5/src/clipboard.js';
|
|
10
|
+
import ImageEditing from './imageediting.js';
|
|
11
|
+
import ImageSizeAttributes from '../imagesizeattributes.js';
|
|
12
|
+
import ImageUtils from '../imageutils.js';
|
|
13
|
+
import ImagePlaceholder from './imageplaceholder.js';
|
|
14
|
+
/**
|
|
15
|
+
* The image inline plugin.
|
|
16
|
+
*
|
|
17
|
+
* It registers:
|
|
18
|
+
*
|
|
19
|
+
* * `<imageInline>` as an inline element in the document schema, and allows `alt`, `src` and `srcset` attributes.
|
|
20
|
+
* * converters for editing and data pipelines.
|
|
21
|
+
* * {@link module:image/image/imagetypecommand~ImageTypeCommand `'imageTypeInline'`} command that converts block images into
|
|
22
|
+
* inline images.
|
|
23
|
+
*/
|
|
24
|
+
export default class ImageInlineEditing extends Plugin {
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc
|
|
27
|
+
*/
|
|
28
|
+
static get requires(): readonly [typeof ImageEditing, typeof ImageSizeAttributes, typeof ImageUtils, typeof ImagePlaceholder, typeof ClipboardPipeline];
|
|
29
|
+
/**
|
|
30
|
+
* @inheritDoc
|
|
31
|
+
*/
|
|
32
|
+
static get pluginName(): "ImageInlineEditing";
|
|
33
|
+
/**
|
|
34
|
+
* @inheritDoc
|
|
35
|
+
*/
|
|
36
|
+
init(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Configures conversion pipelines to support upcasting and downcasting
|
|
39
|
+
* inline images (inline image widgets) and their attributes.
|
|
40
|
+
*/
|
|
41
|
+
private _setupConversion;
|
|
42
|
+
/**
|
|
43
|
+
* Integrates the plugin with the clipboard pipeline.
|
|
44
|
+
*
|
|
45
|
+
* Idea is that the feature should recognize the user's intent when an **block** image is
|
|
46
|
+
* pasted or dropped. If such an image is pasted/dropped into a non-empty block
|
|
47
|
+
* (e.g. a paragraph with some text) it gets converted into an inline image on the fly.
|
|
48
|
+
*
|
|
49
|
+
* We assume this is the user's intent if they decided to put their image there.
|
|
50
|
+
*
|
|
51
|
+
* **Note**: If a block image has a caption, it will not be converted to an inline image
|
|
52
|
+
* to avoid the confusion. Captions are added on purpose and they should never be lost
|
|
53
|
+
* in the clipboard pipeline.
|
|
54
|
+
*
|
|
55
|
+
* See the `ImageBlockEditing` for the similar integration that works in the opposite direction.
|
|
56
|
+
*
|
|
57
|
+
* The feature also sets image `width` and `height` attributes when pasting.
|
|
58
|
+
*/
|
|
59
|
+
private _setupClipboardIntegration;
|
|
60
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/imageloadobserver
|
|
7
|
+
*/
|
|
8
|
+
import { Observer } from 'ckeditor5/src/engine.js';
|
|
9
|
+
/**
|
|
10
|
+
* Observes all new images added to the {@link module:engine/view/document~Document},
|
|
11
|
+
* fires {@link module:engine/view/document~Document#event:imageLoaded} and
|
|
12
|
+
* {@link module:engine/view/document~Document#event:layoutChanged} event every time when the new image
|
|
13
|
+
* has been loaded.
|
|
14
|
+
*
|
|
15
|
+
* **Note:** This event is not fired for images that has been added to the document and rendered as `complete` (already loaded).
|
|
16
|
+
*/
|
|
17
|
+
export default class ImageLoadObserver extends Observer {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
observe(domRoot: HTMLElement): void;
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
stopObserving(domRoot: HTMLElement): void;
|
|
26
|
+
/**
|
|
27
|
+
* Fires {@link module:engine/view/document~Document#event:layoutChanged} and
|
|
28
|
+
* {@link module:engine/view/document~Document#event:imageLoaded}
|
|
29
|
+
* if observer {@link #isEnabled is enabled}.
|
|
30
|
+
*
|
|
31
|
+
* @param domEvent The DOM event.
|
|
32
|
+
*/
|
|
33
|
+
private _fireEvents;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Fired when an <img/> DOM element has been loaded in the DOM root.
|
|
37
|
+
*
|
|
38
|
+
* Introduced by {@link module:image/image/imageloadobserver~ImageLoadObserver}.
|
|
39
|
+
*
|
|
40
|
+
* @see module:image/image/imageloadobserver~ImageLoadObserver
|
|
41
|
+
*
|
|
42
|
+
* @eventName module:engine/view/document~Document#imageLoaded
|
|
43
|
+
* @param data Event data.
|
|
44
|
+
*/
|
|
45
|
+
export type ImageLoadedEvent = {
|
|
46
|
+
name: 'imageLoaded';
|
|
47
|
+
args: [Event];
|
|
48
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/imageplaceholder
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import ImageUtils from '../imageutils.js';
|
|
10
|
+
import '../../theme/imageplaceholder.css';
|
|
11
|
+
/**
|
|
12
|
+
* Adds support for image placeholder that is automatically removed when the image is loaded.
|
|
13
|
+
*/
|
|
14
|
+
export default class ImagePlaceholder extends Plugin {
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
static get requires(): readonly [typeof ImageUtils];
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get pluginName(): "ImagePlaceholder";
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
afterInit(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Extends model schema.
|
|
29
|
+
*/
|
|
30
|
+
private _setupSchema;
|
|
31
|
+
/**
|
|
32
|
+
* Registers converters.
|
|
33
|
+
*/
|
|
34
|
+
private _setupConversion;
|
|
35
|
+
/**
|
|
36
|
+
* Prepares listener for image load.
|
|
37
|
+
*/
|
|
38
|
+
private _setupLoadListener;
|
|
39
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/imagetypecommand
|
|
7
|
+
*/
|
|
8
|
+
import type { Element } from 'ckeditor5/src/engine.js';
|
|
9
|
+
import { Command, type Editor } from 'ckeditor5/src/core.js';
|
|
10
|
+
/**
|
|
11
|
+
* The image type command. It changes the type of a selected image, depending on the configuration.
|
|
12
|
+
*/
|
|
13
|
+
export default class ImageTypeCommand extends Command {
|
|
14
|
+
/**
|
|
15
|
+
* Model element name the command converts to.
|
|
16
|
+
*/
|
|
17
|
+
private readonly _modelElementName;
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*
|
|
21
|
+
* @param modelElementName Model element name the command converts to.
|
|
22
|
+
*/
|
|
23
|
+
constructor(editor: Editor, modelElementName: 'imageBlock' | 'imageInline');
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
refresh(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Executes the command and changes the type of a selected image.
|
|
30
|
+
*
|
|
31
|
+
* @fires execute
|
|
32
|
+
* @param options.setImageSizes Specifies whether the image `width` and `height` attributes should be set automatically.
|
|
33
|
+
* The default is `true`.
|
|
34
|
+
* @returns An object containing references to old and new model image elements
|
|
35
|
+
* (for before and after the change) so external integrations can hook into the decorated
|
|
36
|
+
* `execute` event and handle this change. `null` if the type change failed.
|
|
37
|
+
*/
|
|
38
|
+
execute(options?: {
|
|
39
|
+
setImageSizes?: boolean;
|
|
40
|
+
}): {
|
|
41
|
+
oldElement: Element;
|
|
42
|
+
newElement: Element;
|
|
43
|
+
} | null;
|
|
44
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/insertimagecommand
|
|
7
|
+
*/
|
|
8
|
+
import { Command, type Editor } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { type ArrayOrItem } from 'ckeditor5/src/utils.js';
|
|
10
|
+
/**
|
|
11
|
+
* Insert image command.
|
|
12
|
+
*
|
|
13
|
+
* The command is registered by the {@link module:image/image/imageediting~ImageEditing} plugin as `insertImage`
|
|
14
|
+
* and it is also available via aliased `imageInsert` name.
|
|
15
|
+
*
|
|
16
|
+
* In order to insert an image at the current selection position
|
|
17
|
+
* (according to the {@link module:widget/utils~findOptimalInsertionRange} algorithm),
|
|
18
|
+
* execute the command and specify the image source:
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* editor.execute( 'insertImage', { source: 'http://url.to.the/image' } );
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* It is also possible to insert multiple images at once:
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* editor.execute( 'insertImage', {
|
|
28
|
+
* source: [
|
|
29
|
+
* 'path/to/image.jpg',
|
|
30
|
+
* 'path/to/other-image.jpg'
|
|
31
|
+
* ]
|
|
32
|
+
* } );
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* If you want to take the full control over the process, you can specify individual model attributes:
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* editor.execute( 'insertImage', {
|
|
39
|
+
* source: [
|
|
40
|
+
* { src: 'path/to/image.jpg', alt: 'First alt text' },
|
|
41
|
+
* { src: 'path/to/other-image.jpg', alt: 'Second alt text', customAttribute: 'My attribute value' }
|
|
42
|
+
* ]
|
|
43
|
+
* } );
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export default class InsertImageCommand extends Command {
|
|
47
|
+
/**
|
|
48
|
+
* @inheritDoc
|
|
49
|
+
*/
|
|
50
|
+
constructor(editor: Editor);
|
|
51
|
+
/**
|
|
52
|
+
* @inheritDoc
|
|
53
|
+
*/
|
|
54
|
+
refresh(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Executes the command.
|
|
57
|
+
*
|
|
58
|
+
* @fires execute
|
|
59
|
+
* @param options Options for the executed command.
|
|
60
|
+
* @param options.source The image source or an array of image sources to insert.
|
|
61
|
+
* See the documentation of the command to learn more about accepted formats.
|
|
62
|
+
*/
|
|
63
|
+
execute(options: {
|
|
64
|
+
source: ArrayOrItem<string | Record<string, unknown>>;
|
|
65
|
+
}): void;
|
|
66
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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
|
+
import { Command, type Editor } from 'ckeditor5/src/core.js';
|
|
6
|
+
import type { Writer, Element } from 'ckeditor5/src/engine.js';
|
|
7
|
+
/**
|
|
8
|
+
* @module image/image/replaceimagesourcecommand
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Replace image source command.
|
|
12
|
+
*
|
|
13
|
+
* Changes image source to the one provided. Can be executed as follows:
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* editor.execute( 'replaceImageSource', { source: 'http://url.to.the/image' } );
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export default class ReplaceImageSourceCommand extends Command {
|
|
20
|
+
value: string | null;
|
|
21
|
+
constructor(editor: Editor);
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
refresh(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Executes the command.
|
|
28
|
+
*
|
|
29
|
+
* @fires execute
|
|
30
|
+
* @param options Options for the executed command.
|
|
31
|
+
* @param options.source The image source to replace.
|
|
32
|
+
*/
|
|
33
|
+
execute(options: {
|
|
34
|
+
source: string;
|
|
35
|
+
}): void;
|
|
36
|
+
/**
|
|
37
|
+
* Cleanup image attributes that are not relevant to the new source.
|
|
38
|
+
*
|
|
39
|
+
* Removed attributes are: 'srcset', 'sizes', 'sources', 'width', 'height', 'alt'.
|
|
40
|
+
*
|
|
41
|
+
* This method is decorated, to allow custom cleanup logic.
|
|
42
|
+
* For example, to remove 'myImageId' attribute after 'src' has changed:
|
|
43
|
+
*
|
|
44
|
+
* ```ts
|
|
45
|
+
* replaceImageSourceCommand.on( 'cleanupImage', ( eventInfo, [ writer, image ] ) => {
|
|
46
|
+
* writer.removeAttribute( 'myImageId', image );
|
|
47
|
+
* } );
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
cleanupImage(writer: Writer, image: Element): void;
|
|
51
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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/ui/utils
|
|
7
|
+
*/
|
|
8
|
+
import type { PositionOptions } from 'ckeditor5/src/utils.js';
|
|
9
|
+
import type { Editor } from 'ckeditor5/src/core.js';
|
|
10
|
+
/**
|
|
11
|
+
* A helper utility that positions the
|
|
12
|
+
* {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon} instance
|
|
13
|
+
* with respect to the image in the editor content, if one is selected.
|
|
14
|
+
*
|
|
15
|
+
* @param editor The editor instance.
|
|
16
|
+
*/
|
|
17
|
+
export declare function repositionContextualBalloon(editor: Editor): void;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the positioning options that control the geometry of the
|
|
20
|
+
* {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon} with respect
|
|
21
|
+
* to the selected element in the editor content.
|
|
22
|
+
*
|
|
23
|
+
* @param editor The editor instance.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getBalloonPositionData(editor: Editor): Partial<PositionOptions>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2024, 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, ViewElement } from 'ckeditor5/src/engine.js';
|
|
9
|
+
import type { Editor } from 'ckeditor5/src/core.js';
|
|
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';
|
|
53
|
+
/**
|
|
54
|
+
* Returns parsed value of the size, but only if it contains unit: px.
|
|
55
|
+
*/
|
|
56
|
+
export declare function getSizeValueIfInPx(size: string | undefined): number | null;
|
|
57
|
+
/**
|
|
58
|
+
* Returns true if both styles (width and height) are set.
|
|
59
|
+
*
|
|
60
|
+
* If both image styles: width & height are set, they will override the image width & height attributes in the
|
|
61
|
+
* browser. In this case, the image looks the same as if these styles were applied to attributes instead of styles.
|
|
62
|
+
* That's why we can upcast these styles to width & height attributes instead of resizedWidth and resizedHeight.
|
|
63
|
+
*/
|
|
64
|
+
export declare function widthAndHeightStylesAreBothSet(viewElement: ViewElement): boolean;
|