@ckeditor/ckeditor5-image 45.2.1-alpha.9 → 46.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/dist/index-content.css +18 -17
- package/dist/index-editor.css +96 -96
- package/dist/index.css +164 -163
- package/dist/index.css.map +1 -1
- package/dist/index.js +89 -44
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
- package/src/autoimage.d.ts +2 -2
- package/src/autoimage.js +8 -8
- package/src/image/converters.d.ts +1 -1
- package/src/image/imageblockediting.d.ts +5 -5
- package/src/image/imageblockediting.js +8 -8
- package/src/image/imageediting.d.ts +2 -2
- package/src/image/imageediting.js +5 -5
- package/src/image/imageinlineediting.d.ts +5 -5
- package/src/image/imageinlineediting.js +8 -8
- package/src/image/imageloadobserver.d.ts +7 -7
- package/src/image/imageloadobserver.js +6 -6
- package/src/image/imageplaceholder.d.ts +2 -2
- package/src/image/imageplaceholder.js +3 -3
- package/src/image/imagetypecommand.d.ts +4 -4
- package/src/image/imagetypecommand.js +1 -1
- package/src/image/insertimagecommand.d.ts +1 -1
- package/src/image/insertimagecommand.js +1 -1
- package/src/image/replaceimagesourcecommand.d.ts +3 -3
- package/src/image/replaceimagesourcecommand.js +1 -1
- package/src/image/ui/utils.d.ts +4 -2
- package/src/image/ui/utils.js +2 -0
- package/src/image/utils.d.ts +8 -4
- package/src/image/utils.js +4 -0
- package/src/image.d.ts +3 -3
- package/src/image.js +3 -3
- package/src/imageblock.d.ts +4 -4
- package/src/imageblock.js +4 -4
- package/src/imagecaption/imagecaptionediting.d.ts +8 -8
- package/src/imagecaption/imagecaptionediting.js +9 -9
- package/src/imagecaption/imagecaptionui.d.ts +2 -2
- package/src/imagecaption/imagecaptionui.js +2 -2
- package/src/imagecaption/imagecaptionutils.d.ts +5 -5
- package/src/imagecaption/imagecaptionutils.js +2 -2
- package/src/imagecaption/toggleimagecaptioncommand.d.ts +1 -1
- package/src/imagecaption/toggleimagecaptioncommand.js +2 -2
- package/src/imagecaption.d.ts +3 -3
- package/src/imagecaption.js +3 -3
- package/src/imageinline.d.ts +4 -4
- package/src/imageinline.js +4 -4
- package/src/imageinsert/imageinsertui.d.ts +2 -2
- package/src/imageinsert/imageinsertui.js +3 -3
- package/src/imageinsert/imageinsertviaurlui.d.ts +2 -2
- package/src/imageinsert/imageinsertviaurlui.js +3 -3
- package/src/imageinsert/ui/imageinsertformview.d.ts +3 -1
- package/src/imageinsert/ui/imageinsertformview.js +3 -1
- package/src/imageinsert/ui/imageinserturlview.d.ts +3 -1
- package/src/imageinsert/ui/imageinserturlview.js +3 -1
- package/src/imageinsert.d.ts +4 -4
- package/src/imageinsert.js +4 -4
- package/src/imageinsertviaurl.d.ts +3 -3
- package/src/imageinsertviaurl.js +3 -3
- package/src/imageresize/imagecustomresizeui.d.ts +1 -1
- package/src/imageresize/imagecustomresizeui.js +2 -2
- package/src/imageresize/imageresizebuttons.d.ts +2 -2
- package/src/imageresize/imageresizebuttons.js +5 -5
- package/src/imageresize/imageresizeediting.d.ts +2 -2
- package/src/imageresize/imageresizeediting.js +10 -5
- package/src/imageresize/imageresizehandles.d.ts +2 -2
- package/src/imageresize/imageresizehandles.js +3 -3
- package/src/imageresize/resizeimagecommand.d.ts +1 -1
- package/src/imageresize/resizeimagecommand.js +1 -1
- package/src/imageresize/ui/imagecustomresizeformview.d.ts +5 -1
- package/src/imageresize/ui/imagecustomresizeformview.js +3 -1
- package/src/imageresize/utils/getselectedimageeditornodes.d.ts +3 -2
- package/src/imageresize/utils/getselectedimageeditornodes.js +1 -0
- package/src/imageresize/utils/getselectedimagepossibleresizerange.d.ts +1 -0
- package/src/imageresize/utils/getselectedimagepossibleresizerange.js +1 -0
- package/src/imageresize/utils/getselectedimagewidthinunits.d.ts +1 -0
- package/src/imageresize/utils/getselectedimagewidthinunits.js +1 -0
- package/src/imageresize/utils/tryparsedimensionwithunit.d.ts +2 -0
- package/src/imageresize/utils/tryparsedimensionwithunit.js +2 -0
- package/src/imageresize.d.ts +5 -5
- package/src/imageresize.js +5 -5
- package/src/imagesizeattributes.d.ts +2 -2
- package/src/imagesizeattributes.js +5 -4
- package/src/imagestyle/converters.d.ts +2 -0
- package/src/imagestyle/converters.js +2 -0
- package/src/imagestyle/imagestylecommand.d.ts +3 -3
- package/src/imagestyle/imagestylecommand.js +1 -1
- package/src/imagestyle/imagestyleediting.d.ts +2 -2
- package/src/imagestyle/imagestyleediting.js +8 -7
- package/src/imagestyle/imagestyleui.d.ts +2 -2
- package/src/imagestyle/imagestyleui.js +3 -3
- package/src/imagestyle/utils.d.ts +8 -5
- package/src/imagestyle/utils.js +8 -5
- package/src/imagestyle.d.ts +3 -3
- package/src/imagestyle.js +3 -3
- package/src/imagetextalternative/imagetextalternativecommand.d.ts +1 -1
- package/src/imagetextalternative/imagetextalternativecommand.js +1 -1
- package/src/imagetextalternative/imagetextalternativeediting.d.ts +2 -2
- package/src/imagetextalternative/imagetextalternativeediting.js +3 -3
- package/src/imagetextalternative/imagetextalternativeui.d.ts +1 -1
- package/src/imagetextalternative/imagetextalternativeui.js +2 -2
- package/src/imagetextalternative/ui/textalternativeformview.d.ts +5 -1
- package/src/imagetextalternative/ui/textalternativeformview.js +3 -1
- package/src/imagetextalternative.d.ts +3 -3
- package/src/imagetextalternative.js +3 -3
- package/src/imagetoolbar.d.ts +2 -2
- package/src/imagetoolbar.js +2 -2
- package/src/imageupload/imageuploadediting.d.ts +9 -9
- package/src/imageupload/imageuploadediting.js +8 -8
- package/src/imageupload/imageuploadprogress.d.ts +1 -1
- package/src/imageupload/imageuploadprogress.js +5 -5
- package/src/imageupload/imageuploadui.d.ts +1 -1
- package/src/imageupload/imageuploadui.js +1 -1
- package/src/imageupload/uploadimagecommand.d.ts +1 -1
- package/src/imageupload/uploadimagecommand.js +1 -1
- package/src/imageupload/utils.d.ts +3 -1
- package/src/imageupload/utils.js +2 -0
- package/src/imageupload.d.ts +4 -4
- package/src/imageupload.js +4 -4
- package/src/imageutils.d.ts +13 -13
- package/src/imageutils.js +4 -4
- package/src/index.d.ts +63 -42
- package/src/index.js +58 -32
- package/src/pictureediting.d.ts +3 -3
- package/src/pictureediting.js +3 -3
- package/theme/imagecaption.css +7 -6
- package/theme/imagestyle.css +12 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-image",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "46.0.0-alpha.0",
|
|
4
4
|
"description": "Image feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -13,18 +13,18 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"main": "src/index.js",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@ckeditor/ckeditor5-clipboard": "
|
|
17
|
-
"@ckeditor/ckeditor5-core": "
|
|
18
|
-
"@ckeditor/ckeditor5-engine": "
|
|
19
|
-
"@ckeditor/ckeditor5-icons": "
|
|
20
|
-
"@ckeditor/ckeditor5-typing": "
|
|
21
|
-
"@ckeditor/ckeditor5-ui": "
|
|
22
|
-
"@ckeditor/ckeditor5-undo": "
|
|
23
|
-
"@ckeditor/ckeditor5-upload": "
|
|
24
|
-
"@ckeditor/ckeditor5-utils": "
|
|
25
|
-
"@ckeditor/ckeditor5-widget": "
|
|
26
|
-
"ckeditor5": "
|
|
27
|
-
"es-toolkit": "1.
|
|
16
|
+
"@ckeditor/ckeditor5-clipboard": "46.0.0-alpha.0",
|
|
17
|
+
"@ckeditor/ckeditor5-core": "46.0.0-alpha.0",
|
|
18
|
+
"@ckeditor/ckeditor5-engine": "46.0.0-alpha.0",
|
|
19
|
+
"@ckeditor/ckeditor5-icons": "46.0.0-alpha.0",
|
|
20
|
+
"@ckeditor/ckeditor5-typing": "46.0.0-alpha.0",
|
|
21
|
+
"@ckeditor/ckeditor5-ui": "46.0.0-alpha.0",
|
|
22
|
+
"@ckeditor/ckeditor5-undo": "46.0.0-alpha.0",
|
|
23
|
+
"@ckeditor/ckeditor5-upload": "46.0.0-alpha.0",
|
|
24
|
+
"@ckeditor/ckeditor5-utils": "46.0.0-alpha.0",
|
|
25
|
+
"@ckeditor/ckeditor5-widget": "46.0.0-alpha.0",
|
|
26
|
+
"ckeditor5": "46.0.0-alpha.0",
|
|
27
|
+
"es-toolkit": "1.39.5"
|
|
28
28
|
},
|
|
29
29
|
"author": "CKSource (http://cksource.com/)",
|
|
30
30
|
"license": "SEE LICENSE IN LICENSE.md",
|
package/src/autoimage.d.ts
CHANGED
|
@@ -9,12 +9,12 @@ import { Plugin, type Editor } from 'ckeditor5/src/core.js';
|
|
|
9
9
|
import { Clipboard } from 'ckeditor5/src/clipboard.js';
|
|
10
10
|
import { Undo } from 'ckeditor5/src/undo.js';
|
|
11
11
|
import { Delete } from 'ckeditor5/src/typing.js';
|
|
12
|
-
import ImageUtils from './imageutils.js';
|
|
12
|
+
import { ImageUtils } from './imageutils.js';
|
|
13
13
|
/**
|
|
14
14
|
* The auto-image plugin. It recognizes image links in the pasted content and embeds
|
|
15
15
|
* them shortly after they are injected into the document.
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export declare class AutoImage extends Plugin {
|
|
18
18
|
/**
|
|
19
19
|
* @inheritDoc
|
|
20
20
|
*/
|
package/src/autoimage.js
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
9
|
import { Clipboard } from 'ckeditor5/src/clipboard.js';
|
|
10
|
-
import {
|
|
10
|
+
import { ModelLivePosition, ModelLiveRange } from 'ckeditor5/src/engine.js';
|
|
11
11
|
import { Undo } from 'ckeditor5/src/undo.js';
|
|
12
12
|
import { Delete } from 'ckeditor5/src/typing.js';
|
|
13
13
|
import { global } from 'ckeditor5/src/utils.js';
|
|
14
|
-
import ImageUtils from './imageutils.js';
|
|
14
|
+
import { ImageUtils } from './imageutils.js';
|
|
15
15
|
// Implements the pattern: http(s)://(www.)example.com/path/to/resource.ext?query=params&maybe=too.
|
|
16
16
|
const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@!$&'()*+,;=%-]+/.source +
|
|
17
17
|
/\.(jpg|jpeg|png|gif|ico|webp|JPG|JPEG|PNG|GIF|ICO|WEBP)/.source +
|
|
@@ -21,7 +21,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
|
|
|
21
21
|
* The auto-image plugin. It recognizes image links in the pasted content and embeds
|
|
22
22
|
* them shortly after they are injected into the document.
|
|
23
23
|
*/
|
|
24
|
-
export
|
|
24
|
+
export class AutoImage extends Plugin {
|
|
25
25
|
/**
|
|
26
26
|
* @inheritDoc
|
|
27
27
|
*/
|
|
@@ -70,9 +70,9 @@ export default class AutoImage extends Plugin {
|
|
|
70
70
|
// into an image.
|
|
71
71
|
this.listenTo(clipboardPipeline, 'inputTransformation', () => {
|
|
72
72
|
const firstRange = modelDocument.selection.getFirstRange();
|
|
73
|
-
const leftLivePosition =
|
|
73
|
+
const leftLivePosition = ModelLivePosition.fromPosition(firstRange.start);
|
|
74
74
|
leftLivePosition.stickiness = 'toPrevious';
|
|
75
|
-
const rightLivePosition =
|
|
75
|
+
const rightLivePosition = ModelLivePosition.fromPosition(firstRange.end);
|
|
76
76
|
rightLivePosition.stickiness = 'toNext';
|
|
77
77
|
modelDocument.once('change:data', () => {
|
|
78
78
|
this._embedImageBetweenPositions(leftLivePosition, rightLivePosition);
|
|
@@ -98,8 +98,8 @@ export default class AutoImage extends Plugin {
|
|
|
98
98
|
*/
|
|
99
99
|
_embedImageBetweenPositions(leftPosition, rightPosition) {
|
|
100
100
|
const editor = this.editor;
|
|
101
|
-
// TODO: Use a marker instead of
|
|
102
|
-
const urlRange = new
|
|
101
|
+
// TODO: Use a marker instead of ModelLiveRange & LivePositions.
|
|
102
|
+
const urlRange = new ModelLiveRange(leftPosition, rightPosition);
|
|
103
103
|
const walker = urlRange.getWalker({ ignoreElementEnd: true });
|
|
104
104
|
const selectionAttributes = Object.fromEntries(editor.model.document.selection.getAttributes());
|
|
105
105
|
const imageUtils = this.editor.plugins.get('ImageUtils');
|
|
@@ -116,7 +116,7 @@ export default class AutoImage extends Plugin {
|
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
118
|
// Position will not be available in the `setTimeout` function so let's clone it.
|
|
119
|
-
this._positionToInsert =
|
|
119
|
+
this._positionToInsert = ModelLivePosition.fromPosition(leftPosition);
|
|
120
120
|
// This action mustn't be executed if undo was called between pasting and auto-embedding.
|
|
121
121
|
this._timeoutId = setTimeout(() => {
|
|
122
122
|
// Do nothing if image element cannot be inserted at the current position.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module image/image/converters
|
|
7
7
|
*/
|
|
8
8
|
import type { DowncastDispatcher, UpcastDispatcher } from 'ckeditor5/src/engine.js';
|
|
9
|
-
import type ImageUtils from '../imageutils.js';
|
|
9
|
+
import { type ImageUtils } from '../imageutils.js';
|
|
10
10
|
/**
|
|
11
11
|
* Returns a function that converts the image view representation:
|
|
12
12
|
*
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
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';
|
|
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
14
|
/**
|
|
15
15
|
* The image block plugin.
|
|
16
16
|
*
|
|
@@ -21,7 +21,7 @@ import ImagePlaceholder from './imageplaceholder.js';
|
|
|
21
21
|
* * {@link module:image/image/imagetypecommand~ImageTypeCommand `'imageTypeBlock'`} command that converts inline images into
|
|
22
22
|
* block images.
|
|
23
23
|
*/
|
|
24
|
-
export
|
|
24
|
+
export declare class ImageBlockEditing extends Plugin {
|
|
25
25
|
/**
|
|
26
26
|
* @inheritDoc
|
|
27
27
|
*/
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
9
|
import { ClipboardPipeline } from 'ckeditor5/src/clipboard.js';
|
|
10
|
-
import {
|
|
10
|
+
import { ViewUpcastWriter } from 'ckeditor5/src/engine.js';
|
|
11
11
|
import { downcastImageAttribute, downcastSrcsetAttribute, upcastImageFigure } from './converters.js';
|
|
12
|
-
import ImageEditing from './imageediting.js';
|
|
13
|
-
import ImageSizeAttributes from '../imagesizeattributes.js';
|
|
14
|
-
import ImageTypeCommand from './imagetypecommand.js';
|
|
15
|
-
import ImageUtils from '../imageutils.js';
|
|
12
|
+
import { ImageEditing } from './imageediting.js';
|
|
13
|
+
import { ImageSizeAttributes } from '../imagesizeattributes.js';
|
|
14
|
+
import { ImageTypeCommand } from './imagetypecommand.js';
|
|
15
|
+
import { ImageUtils } from '../imageutils.js';
|
|
16
16
|
import { getImgViewElementMatcher, createBlockImageViewElement, determineImageTypeForInsertionAtSelection } from './utils.js';
|
|
17
|
-
import ImagePlaceholder from './imageplaceholder.js';
|
|
17
|
+
import { ImagePlaceholder } from './imageplaceholder.js';
|
|
18
18
|
/**
|
|
19
19
|
* The image block plugin.
|
|
20
20
|
*
|
|
@@ -25,7 +25,7 @@ import ImagePlaceholder from './imageplaceholder.js';
|
|
|
25
25
|
* * {@link module:image/image/imagetypecommand~ImageTypeCommand `'imageTypeBlock'`} command that converts inline images into
|
|
26
26
|
* block images.
|
|
27
27
|
*/
|
|
28
|
-
export
|
|
28
|
+
export class ImageBlockEditing extends Plugin {
|
|
29
29
|
/**
|
|
30
30
|
* @inheritDoc
|
|
31
31
|
*/
|
|
@@ -136,7 +136,7 @@ export default class ImageBlockEditing extends Plugin {
|
|
|
136
136
|
// Convert inline images into block images only when the currently selected block is empty
|
|
137
137
|
// (e.g. an empty paragraph) or some object is selected (to replace it).
|
|
138
138
|
if (determineImageTypeForInsertionAtSelection(model.schema, selection) === 'imageBlock') {
|
|
139
|
-
const writer = new
|
|
139
|
+
const writer = new ViewUpcastWriter(editingView.document);
|
|
140
140
|
// Wrap <img ... /> -> <figure class="image"><img .../></figure>
|
|
141
141
|
const blockViewImages = docFragmentChildren.map(inlineViewImage => writer.createElement('figure', { class: 'image' }, inlineViewImage));
|
|
142
142
|
data.content = writer.createDocumentFragment(blockViewImages);
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module image/image/imageediting
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import ImageUtils from '../imageutils.js';
|
|
9
|
+
import { ImageUtils } from '../imageutils.js';
|
|
10
10
|
/**
|
|
11
11
|
* The image engine plugin. This module loads common code shared between
|
|
12
12
|
* {@link module:image/image/imageinlineediting~ImageInlineEditing} and
|
|
@@ -14,7 +14,7 @@ import ImageUtils from '../imageutils.js';
|
|
|
14
14
|
*
|
|
15
15
|
* This plugin registers the {@link module:image/image/insertimagecommand~InsertImageCommand 'insertImage'} command.
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export declare class ImageEditing extends Plugin {
|
|
18
18
|
/**
|
|
19
19
|
* @inheritDoc
|
|
20
20
|
*/
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* @module image/image/imageediting
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import ImageLoadObserver from './imageloadobserver.js';
|
|
10
|
-
import InsertImageCommand from './insertimagecommand.js';
|
|
11
|
-
import ReplaceImageSourceCommand from './replaceimagesourcecommand.js';
|
|
12
|
-
import ImageUtils from '../imageutils.js';
|
|
9
|
+
import { ImageLoadObserver } from './imageloadobserver.js';
|
|
10
|
+
import { InsertImageCommand } from './insertimagecommand.js';
|
|
11
|
+
import { ReplaceImageSourceCommand } from './replaceimagesourcecommand.js';
|
|
12
|
+
import { ImageUtils } from '../imageutils.js';
|
|
13
13
|
/**
|
|
14
14
|
* The image engine plugin. This module loads common code shared between
|
|
15
15
|
* {@link module:image/image/imageinlineediting~ImageInlineEditing} and
|
|
@@ -17,7 +17,7 @@ import ImageUtils from '../imageutils.js';
|
|
|
17
17
|
*
|
|
18
18
|
* This plugin registers the {@link module:image/image/insertimagecommand~InsertImageCommand 'insertImage'} command.
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
20
|
+
export class ImageEditing extends Plugin {
|
|
21
21
|
/**
|
|
22
22
|
* @inheritDoc
|
|
23
23
|
*/
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
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';
|
|
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
14
|
/**
|
|
15
15
|
* The image inline plugin.
|
|
16
16
|
*
|
|
@@ -21,7 +21,7 @@ import ImagePlaceholder from './imageplaceholder.js';
|
|
|
21
21
|
* * {@link module:image/image/imagetypecommand~ImageTypeCommand `'imageTypeInline'`} command that converts block images into
|
|
22
22
|
* inline images.
|
|
23
23
|
*/
|
|
24
|
-
export
|
|
24
|
+
export declare class ImageInlineEditing extends Plugin {
|
|
25
25
|
/**
|
|
26
26
|
* @inheritDoc
|
|
27
27
|
*/
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
9
|
import { ClipboardPipeline } from 'ckeditor5/src/clipboard.js';
|
|
10
|
-
import {
|
|
10
|
+
import { ViewUpcastWriter } from 'ckeditor5/src/engine.js';
|
|
11
11
|
import { downcastImageAttribute, downcastSrcsetAttribute } from './converters.js';
|
|
12
|
-
import ImageEditing from './imageediting.js';
|
|
13
|
-
import ImageSizeAttributes from '../imagesizeattributes.js';
|
|
14
|
-
import ImageTypeCommand from './imagetypecommand.js';
|
|
15
|
-
import ImageUtils from '../imageutils.js';
|
|
12
|
+
import { ImageEditing } from './imageediting.js';
|
|
13
|
+
import { ImageSizeAttributes } from '../imagesizeattributes.js';
|
|
14
|
+
import { ImageTypeCommand } from './imagetypecommand.js';
|
|
15
|
+
import { ImageUtils } from '../imageutils.js';
|
|
16
16
|
import { getImgViewElementMatcher, createInlineImageViewElement, determineImageTypeForInsertionAtSelection } from './utils.js';
|
|
17
|
-
import ImagePlaceholder from './imageplaceholder.js';
|
|
17
|
+
import { ImagePlaceholder } from './imageplaceholder.js';
|
|
18
18
|
/**
|
|
19
19
|
* The image inline plugin.
|
|
20
20
|
*
|
|
@@ -25,7 +25,7 @@ import ImagePlaceholder from './imageplaceholder.js';
|
|
|
25
25
|
* * {@link module:image/image/imagetypecommand~ImageTypeCommand `'imageTypeInline'`} command that converts block images into
|
|
26
26
|
* inline images.
|
|
27
27
|
*/
|
|
28
|
-
export
|
|
28
|
+
export class ImageInlineEditing extends Plugin {
|
|
29
29
|
/**
|
|
30
30
|
* @inheritDoc
|
|
31
31
|
*/
|
|
@@ -139,7 +139,7 @@ export default class ImageInlineEditing extends Plugin {
|
|
|
139
139
|
// Convert block images into inline images only when pasting or dropping into non-empty blocks
|
|
140
140
|
// and when the block is not an object (e.g. pasting to replace another widget).
|
|
141
141
|
if (determineImageTypeForInsertionAtSelection(model.schema, selection) === 'imageInline') {
|
|
142
|
-
const writer = new
|
|
142
|
+
const writer = new ViewUpcastWriter(editingView.document);
|
|
143
143
|
// Unwrap <figure class="image"><img .../></figure> -> <img ... />
|
|
144
144
|
// but <figure class="image"><img .../><figcaption>...</figcaption></figure> -> stays the same
|
|
145
145
|
const inlineViewImages = docFragmentChildren.map(blockViewImage => {
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Observer } from 'ckeditor5/src/engine.js';
|
|
9
9
|
/**
|
|
10
|
-
* Observes all new images added to the {@link module:engine/view/document~
|
|
11
|
-
* fires {@link module:engine/view/document~
|
|
12
|
-
* {@link module:engine/view/document~
|
|
10
|
+
* Observes all new images added to the {@link module:engine/view/document~ViewDocument},
|
|
11
|
+
* fires {@link module:engine/view/document~ViewDocument#event:imageLoaded} and
|
|
12
|
+
* {@link module:engine/view/document~ViewDocument#event:layoutChanged} event every time when the new image
|
|
13
13
|
* has been loaded.
|
|
14
14
|
*
|
|
15
15
|
* **Note:** This event is not fired for images that has been added to the document and rendered as `complete` (already loaded).
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export declare class ImageLoadObserver extends Observer {
|
|
18
18
|
/**
|
|
19
19
|
* @inheritDoc
|
|
20
20
|
*/
|
|
@@ -24,8 +24,8 @@ export default class ImageLoadObserver extends Observer {
|
|
|
24
24
|
*/
|
|
25
25
|
stopObserving(domRoot: HTMLElement): void;
|
|
26
26
|
/**
|
|
27
|
-
* Fires {@link module:engine/view/document~
|
|
28
|
-
* {@link module:engine/view/document~
|
|
27
|
+
* Fires {@link module:engine/view/document~ViewDocument#event:layoutChanged} and
|
|
28
|
+
* {@link module:engine/view/document~ViewDocument#event:imageLoaded}
|
|
29
29
|
* if observer {@link #isEnabled is enabled}.
|
|
30
30
|
*
|
|
31
31
|
* @param domEvent The DOM event.
|
|
@@ -39,7 +39,7 @@ export default class ImageLoadObserver extends Observer {
|
|
|
39
39
|
*
|
|
40
40
|
* @see module:image/image/imageloadobserver~ImageLoadObserver
|
|
41
41
|
*
|
|
42
|
-
* @eventName module:engine/view/document~
|
|
42
|
+
* @eventName module:engine/view/document~ViewDocument#imageLoaded
|
|
43
43
|
* @param data Event data.
|
|
44
44
|
*/
|
|
45
45
|
export type ImageLoadedEvent = {
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Observer } from 'ckeditor5/src/engine.js';
|
|
9
9
|
/**
|
|
10
|
-
* Observes all new images added to the {@link module:engine/view/document~
|
|
11
|
-
* fires {@link module:engine/view/document~
|
|
12
|
-
* {@link module:engine/view/document~
|
|
10
|
+
* Observes all new images added to the {@link module:engine/view/document~ViewDocument},
|
|
11
|
+
* fires {@link module:engine/view/document~ViewDocument#event:imageLoaded} and
|
|
12
|
+
* {@link module:engine/view/document~ViewDocument#event:layoutChanged} event every time when the new image
|
|
13
13
|
* has been loaded.
|
|
14
14
|
*
|
|
15
15
|
* **Note:** This event is not fired for images that has been added to the document and rendered as `complete` (already loaded).
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export class ImageLoadObserver extends Observer {
|
|
18
18
|
/**
|
|
19
19
|
* @inheritDoc
|
|
20
20
|
*/
|
|
@@ -37,8 +37,8 @@ export default class ImageLoadObserver extends Observer {
|
|
|
37
37
|
this.stopListening(domRoot);
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Fires {@link module:engine/view/document~
|
|
41
|
-
* {@link module:engine/view/document~
|
|
40
|
+
* Fires {@link module:engine/view/document~ViewDocument#event:layoutChanged} and
|
|
41
|
+
* {@link module:engine/view/document~ViewDocument#event:imageLoaded}
|
|
42
42
|
* if observer {@link #isEnabled is enabled}.
|
|
43
43
|
*
|
|
44
44
|
* @param domEvent The DOM event.
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
* @module image/image/imageplaceholder
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import ImageUtils from '../imageutils.js';
|
|
9
|
+
import { ImageUtils } from '../imageutils.js';
|
|
10
10
|
import '../../theme/imageplaceholder.css';
|
|
11
11
|
/**
|
|
12
12
|
* Adds support for image placeholder that is automatically removed when the image is loaded.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export declare class ImagePlaceholder extends Plugin {
|
|
15
15
|
/**
|
|
16
16
|
* @inheritDoc
|
|
17
17
|
*/
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* @module image/image/imageplaceholder
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import ImageUtils from '../imageutils.js';
|
|
10
|
-
import ImageLoadObserver from './imageloadobserver.js';
|
|
9
|
+
import { ImageUtils } from '../imageutils.js';
|
|
10
|
+
import { ImageLoadObserver } from './imageloadobserver.js';
|
|
11
11
|
import '../../theme/imageplaceholder.css';
|
|
12
12
|
/**
|
|
13
13
|
* Adds support for image placeholder that is automatically removed when the image is loaded.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export class ImagePlaceholder extends Plugin {
|
|
16
16
|
/**
|
|
17
17
|
* @inheritDoc
|
|
18
18
|
*/
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module image/image/imagetypecommand
|
|
7
7
|
*/
|
|
8
|
-
import type {
|
|
8
|
+
import type { ModelElement } from 'ckeditor5/src/engine.js';
|
|
9
9
|
import { Command, type Editor } from 'ckeditor5/src/core.js';
|
|
10
10
|
/**
|
|
11
11
|
* The image type command. It changes the type of a selected image, depending on the configuration.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export declare class ImageTypeCommand extends Command {
|
|
14
14
|
/**
|
|
15
15
|
* Model element name the command converts to.
|
|
16
16
|
*/
|
|
@@ -38,7 +38,7 @@ export default class ImageTypeCommand extends Command {
|
|
|
38
38
|
execute(options?: {
|
|
39
39
|
setImageSizes?: boolean;
|
|
40
40
|
}): {
|
|
41
|
-
oldElement:
|
|
42
|
-
newElement:
|
|
41
|
+
oldElement: ModelElement;
|
|
42
|
+
newElement: ModelElement;
|
|
43
43
|
} | null;
|
|
44
44
|
}
|
|
@@ -6,7 +6,7 @@ import { Command } from 'ckeditor5/src/core.js';
|
|
|
6
6
|
/**
|
|
7
7
|
* The image type command. It changes the type of a selected image, depending on the configuration.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export class ImageTypeCommand extends Command {
|
|
10
10
|
/**
|
|
11
11
|
* Model element name the command converts to.
|
|
12
12
|
*/
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
import { Command, type Editor } from 'ckeditor5/src/core.js';
|
|
6
|
-
import type {
|
|
6
|
+
import type { ModelWriter, ModelElement } from 'ckeditor5/src/engine.js';
|
|
7
7
|
/**
|
|
8
8
|
* @module image/image/replaceimagesourcecommand
|
|
9
9
|
*/
|
|
@@ -16,7 +16,7 @@ import type { Writer, Element } from 'ckeditor5/src/engine.js';
|
|
|
16
16
|
* editor.execute( 'replaceImageSource', { source: 'http://url.to.the/image' } );
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export declare class ReplaceImageSourceCommand extends Command {
|
|
20
20
|
value: string | null;
|
|
21
21
|
constructor(editor: Editor);
|
|
22
22
|
/**
|
|
@@ -47,5 +47,5 @@ export default class ReplaceImageSourceCommand extends Command {
|
|
|
47
47
|
* } );
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
|
-
cleanupImage(writer:
|
|
50
|
+
cleanupImage(writer: ModelWriter, image: ModelElement): void;
|
|
51
51
|
}
|
|
@@ -15,7 +15,7 @@ import { Command } from 'ckeditor5/src/core.js';
|
|
|
15
15
|
* editor.execute( 'replaceImageSource', { source: 'http://url.to.the/image' } );
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export class ReplaceImageSourceCommand extends Command {
|
|
19
19
|
constructor(editor) {
|
|
20
20
|
super(editor);
|
|
21
21
|
this.decorate('cleanupImage');
|
package/src/image/ui/utils.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module image/image/ui/utils
|
|
7
7
|
*/
|
|
8
|
-
import type {
|
|
8
|
+
import type { DomOptimalPositionOptions } from 'ckeditor5/src/utils.js';
|
|
9
9
|
import type { Editor } from 'ckeditor5/src/core.js';
|
|
10
10
|
/**
|
|
11
11
|
* A helper utility that positions the
|
|
@@ -13,6 +13,7 @@ import type { Editor } from 'ckeditor5/src/core.js';
|
|
|
13
13
|
* with respect to the image in the editor content, if one is selected.
|
|
14
14
|
*
|
|
15
15
|
* @param editor The editor instance.
|
|
16
|
+
* @internal
|
|
16
17
|
*/
|
|
17
18
|
export declare function repositionContextualBalloon(editor: Editor): void;
|
|
18
19
|
/**
|
|
@@ -21,5 +22,6 @@ export declare function repositionContextualBalloon(editor: Editor): void;
|
|
|
21
22
|
* to the selected element in the editor content.
|
|
22
23
|
*
|
|
23
24
|
* @param editor The editor instance.
|
|
25
|
+
* @internal
|
|
24
26
|
*/
|
|
25
|
-
export declare function getBalloonPositionData(editor: Editor): Partial<
|
|
27
|
+
export declare function getBalloonPositionData(editor: Editor): Partial<DomOptimalPositionOptions>;
|
package/src/image/ui/utils.js
CHANGED
|
@@ -9,6 +9,7 @@ import { BalloonPanelView } from 'ckeditor5/src/ui.js';
|
|
|
9
9
|
* with respect to the image in the editor content, if one is selected.
|
|
10
10
|
*
|
|
11
11
|
* @param editor The editor instance.
|
|
12
|
+
* @internal
|
|
12
13
|
*/
|
|
13
14
|
export function repositionContextualBalloon(editor) {
|
|
14
15
|
const balloon = editor.plugins.get('ContextualBalloon');
|
|
@@ -24,6 +25,7 @@ export function repositionContextualBalloon(editor) {
|
|
|
24
25
|
* to the selected element in the editor content.
|
|
25
26
|
*
|
|
26
27
|
* @param editor The editor instance.
|
|
28
|
+
* @internal
|
|
27
29
|
*/
|
|
28
30
|
export function getBalloonPositionData(editor) {
|
|
29
31
|
const editingView = editor.editing.view;
|
package/src/image/utils.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module image/image/utils
|
|
7
7
|
*/
|
|
8
|
-
import type {
|
|
8
|
+
import type { ModelDocumentSelection, MatcherPattern, ModelSchema, ModelSelection, ViewContainerElement, ViewDowncastWriter, ViewElement } from 'ckeditor5/src/engine.js';
|
|
9
9
|
import type { Editor } from 'ckeditor5/src/core.js';
|
|
10
10
|
/**
|
|
11
11
|
* Creates a view element representing the inline image.
|
|
@@ -18,7 +18,7 @@ import type { Editor } from 'ckeditor5/src/core.js';
|
|
|
18
18
|
*
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|
|
21
|
-
export declare function createInlineImageViewElement(writer:
|
|
21
|
+
export declare function createInlineImageViewElement(writer: ViewDowncastWriter): ViewContainerElement;
|
|
22
22
|
/**
|
|
23
23
|
* Creates a view element representing the block image.
|
|
24
24
|
*
|
|
@@ -30,7 +30,7 @@ export declare function createInlineImageViewElement(writer: DowncastWriter): Vi
|
|
|
30
30
|
*
|
|
31
31
|
* @internal
|
|
32
32
|
*/
|
|
33
|
-
export declare function createBlockImageViewElement(writer:
|
|
33
|
+
export declare function createBlockImageViewElement(writer: ViewDowncastWriter): ViewContainerElement;
|
|
34
34
|
/**
|
|
35
35
|
* A function returning a `MatcherPattern` for a particular type of View images.
|
|
36
36
|
*
|
|
@@ -49,9 +49,11 @@ export declare function getImgViewElementMatcher(editor: Editor, matchImageType:
|
|
|
49
49
|
*
|
|
50
50
|
* @internal
|
|
51
51
|
*/
|
|
52
|
-
export declare function determineImageTypeForInsertionAtSelection(schema:
|
|
52
|
+
export declare function determineImageTypeForInsertionAtSelection(schema: ModelSchema, selection: ModelSelection | ModelDocumentSelection): 'imageBlock' | 'imageInline';
|
|
53
53
|
/**
|
|
54
54
|
* Returns parsed value of the size, but only if it contains unit: px.
|
|
55
|
+
*
|
|
56
|
+
* @internal
|
|
55
57
|
*/
|
|
56
58
|
export declare function getSizeValueIfInPx(size: string | undefined): number | null;
|
|
57
59
|
/**
|
|
@@ -60,5 +62,7 @@ export declare function getSizeValueIfInPx(size: string | undefined): number | n
|
|
|
60
62
|
* If both image styles: width & height are set, they will override the image width & height attributes in the
|
|
61
63
|
* browser. In this case, the image looks the same as if these styles were applied to attributes instead of styles.
|
|
62
64
|
* That's why we can upcast these styles to width & height attributes instead of resizedWidth and resizedHeight.
|
|
65
|
+
*
|
|
66
|
+
* @internal
|
|
63
67
|
*/
|
|
64
68
|
export declare function widthAndHeightStylesAreBothSet(viewElement: ViewElement): boolean;
|
package/src/image/utils.js
CHANGED
|
@@ -100,6 +100,8 @@ export function determineImageTypeForInsertionAtSelection(schema, selection) {
|
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* Returns parsed value of the size, but only if it contains unit: px.
|
|
103
|
+
*
|
|
104
|
+
* @internal
|
|
103
105
|
*/
|
|
104
106
|
export function getSizeValueIfInPx(size) {
|
|
105
107
|
if (size && size.endsWith('px')) {
|
|
@@ -113,6 +115,8 @@ export function getSizeValueIfInPx(size) {
|
|
|
113
115
|
* If both image styles: width & height are set, they will override the image width & height attributes in the
|
|
114
116
|
* browser. In this case, the image looks the same as if these styles were applied to attributes instead of styles.
|
|
115
117
|
* That's why we can upcast these styles to width & height attributes instead of resizedWidth and resizedHeight.
|
|
118
|
+
*
|
|
119
|
+
* @internal
|
|
116
120
|
*/
|
|
117
121
|
export function widthAndHeightStylesAreBothSet(viewElement) {
|
|
118
122
|
const widthStyle = getSizeValueIfInPx(viewElement.getStyle('width'));
|
package/src/image.d.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* @module image/image
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import ImageBlock from './imageblock.js';
|
|
10
|
-
import ImageInline from './imageinline.js';
|
|
9
|
+
import { ImageBlock } from './imageblock.js';
|
|
10
|
+
import { ImageInline } from './imageinline.js';
|
|
11
11
|
import '../theme/image.css';
|
|
12
12
|
/**
|
|
13
13
|
* The image plugin.
|
|
@@ -22,7 +22,7 @@ import '../theme/image.css';
|
|
|
22
22
|
* Usually, it is used in conjunction with other plugins from this package. See the {@glink api/image package page}
|
|
23
23
|
* for more information.
|
|
24
24
|
*/
|
|
25
|
-
export
|
|
25
|
+
export declare class Image extends Plugin {
|
|
26
26
|
/**
|
|
27
27
|
* @inheritDoc
|
|
28
28
|
*/
|
package/src/image.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* @module image/image
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import ImageBlock from './imageblock.js';
|
|
10
|
-
import ImageInline from './imageinline.js';
|
|
9
|
+
import { ImageBlock } from './imageblock.js';
|
|
10
|
+
import { ImageInline } from './imageinline.js';
|
|
11
11
|
import '../theme/image.css';
|
|
12
12
|
/**
|
|
13
13
|
* The image plugin.
|
|
@@ -22,7 +22,7 @@ import '../theme/image.css';
|
|
|
22
22
|
* Usually, it is used in conjunction with other plugins from this package. See the {@glink api/image package page}
|
|
23
23
|
* for more information.
|
|
24
24
|
*/
|
|
25
|
-
export
|
|
25
|
+
export class Image extends Plugin {
|
|
26
26
|
/**
|
|
27
27
|
* @inheritDoc
|
|
28
28
|
*/
|