@ckeditor/ckeditor5-image 45.2.1 → 46.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/image.js +1 -1
- package/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 +93 -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 +11 -5
- package/src/imagestyle/utils.js +11 -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 +11 -9
- package/src/imageupload/imageuploadediting.js +10 -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
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* @module image/imageresize/imageresizebuttons
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import { ButtonView, DropdownButtonView,
|
|
9
|
+
import { ButtonView, DropdownButtonView, UIModel, createDropdown, addListToDropdown } from 'ckeditor5/src/ui.js';
|
|
10
10
|
import { CKEditorError, Collection } from 'ckeditor5/src/utils.js';
|
|
11
11
|
import { IconObjectSizeCustom, IconObjectSizeFull, IconObjectSizeLarge, IconObjectSizeMedium, IconObjectSizeSmall } from 'ckeditor5/src/icons.js';
|
|
12
|
-
import ImageResizeEditing from './imageresizeediting.js';
|
|
12
|
+
import { ImageResizeEditing } from './imageresizeediting.js';
|
|
13
13
|
const RESIZE_ICONS = /* #__PURE__ */ (() => ({
|
|
14
14
|
small: IconObjectSizeSmall,
|
|
15
15
|
medium: IconObjectSizeMedium,
|
|
@@ -22,7 +22,7 @@ const RESIZE_ICONS = /* #__PURE__ */ (() => ({
|
|
|
22
22
|
*
|
|
23
23
|
* It adds a possibility to resize images using the toolbar dropdown or individual buttons, depending on the plugin configuration.
|
|
24
24
|
*/
|
|
25
|
-
export
|
|
25
|
+
export class ImageResizeButtons extends Plugin {
|
|
26
26
|
/**
|
|
27
27
|
* @inheritDoc
|
|
28
28
|
*/
|
|
@@ -241,7 +241,7 @@ export default class ImageResizeButtons extends Plugin {
|
|
|
241
241
|
const customResizeUI = editor.plugins.get('ImageCustomResizeUI');
|
|
242
242
|
definition = {
|
|
243
243
|
type: 'button',
|
|
244
|
-
model: new
|
|
244
|
+
model: new UIModel({
|
|
245
245
|
label: this._getOptionLabelValue(option),
|
|
246
246
|
role: 'menuitemradio',
|
|
247
247
|
withText: true,
|
|
@@ -257,7 +257,7 @@ export default class ImageResizeButtons extends Plugin {
|
|
|
257
257
|
else {
|
|
258
258
|
definition = {
|
|
259
259
|
type: 'button',
|
|
260
|
-
model: new
|
|
260
|
+
model: new UIModel({
|
|
261
261
|
commandName: 'resizeImage',
|
|
262
262
|
commandValue: option.valueWithUnits,
|
|
263
263
|
label: this._getOptionLabelValue(option),
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
import { type Editor, Plugin } from 'ckeditor5/src/core.js';
|
|
6
|
-
import ImageUtils from '../imageutils.js';
|
|
6
|
+
import { ImageUtils } from '../imageutils.js';
|
|
7
7
|
/**
|
|
8
8
|
* The image resize editing feature.
|
|
9
9
|
*
|
|
10
10
|
* It adds the ability to resize each image using handles or manually by
|
|
11
11
|
* {@link module:image/imageresize/imageresizebuttons~ImageResizeButtons} buttons.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export declare class ImageResizeEditing extends Plugin {
|
|
14
14
|
/**
|
|
15
15
|
* @inheritDoc
|
|
16
16
|
*/
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
5
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
6
|
-
import ImageUtils from '../imageutils.js';
|
|
7
|
-
import ResizeImageCommand from './resizeimagecommand.js';
|
|
6
|
+
import { ImageUtils } from '../imageutils.js';
|
|
7
|
+
import { ResizeImageCommand } from './resizeimagecommand.js';
|
|
8
8
|
import { widthAndHeightStylesAreBothSet } from '../image/utils.js';
|
|
9
9
|
/**
|
|
10
10
|
* The image resize editing feature.
|
|
@@ -12,7 +12,7 @@ import { widthAndHeightStylesAreBothSet } from '../image/utils.js';
|
|
|
12
12
|
* It adds the ability to resize each image using handles or manually by
|
|
13
13
|
* {@link module:image/imageresize/imageresizebuttons~ImageResizeButtons} buttons.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export class ImageResizeEditing extends Plugin {
|
|
16
16
|
/**
|
|
17
17
|
* @inheritDoc
|
|
18
18
|
*/
|
|
@@ -86,11 +86,16 @@ export default class ImageResizeEditing extends Plugin {
|
|
|
86
86
|
this._registerSchema();
|
|
87
87
|
}
|
|
88
88
|
_registerSchema() {
|
|
89
|
+
const schema = this.editor.model.schema;
|
|
89
90
|
if (this.editor.plugins.has('ImageBlockEditing')) {
|
|
90
|
-
|
|
91
|
+
schema.extend('imageBlock', { allowAttributes: ['resizedWidth', 'resizedHeight'] });
|
|
92
|
+
schema.setAttributeProperties('resizedWidth', { isFormatting: true });
|
|
93
|
+
schema.setAttributeProperties('resizedHeight', { isFormatting: true });
|
|
91
94
|
}
|
|
92
95
|
if (this.editor.plugins.has('ImageInlineEditing')) {
|
|
93
|
-
|
|
96
|
+
schema.extend('imageInline', { allowAttributes: ['resizedWidth', 'resizedHeight'] });
|
|
97
|
+
schema.setAttributeProperties('resizedWidth', { isFormatting: true });
|
|
98
|
+
schema.setAttributeProperties('resizedHeight', { isFormatting: true });
|
|
94
99
|
}
|
|
95
100
|
}
|
|
96
101
|
/**
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
6
6
|
import { WidgetResize } from 'ckeditor5/src/widget.js';
|
|
7
|
-
import ImageUtils from '../imageutils.js';
|
|
7
|
+
import { ImageUtils } from '../imageutils.js';
|
|
8
8
|
/**
|
|
9
9
|
* The image resize by handles feature.
|
|
10
10
|
*
|
|
11
11
|
* It adds the ability to resize each image using handles or manually by
|
|
12
12
|
* {@link module:image/imageresize/imageresizebuttons~ImageResizeButtons} buttons.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export declare class ImageResizeHandles extends Plugin {
|
|
15
15
|
/**
|
|
16
16
|
* @inheritDoc
|
|
17
17
|
*/
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
6
6
|
import { WidgetResize } from 'ckeditor5/src/widget.js';
|
|
7
|
-
import ImageUtils from '../imageutils.js';
|
|
8
|
-
import ImageLoadObserver from '../image/imageloadobserver.js';
|
|
7
|
+
import { ImageUtils } from '../imageutils.js';
|
|
8
|
+
import { ImageLoadObserver } from '../image/imageloadobserver.js';
|
|
9
9
|
const RESIZABLE_IMAGES_CSS_SELECTOR = 'figure.image.ck-widget > img,' +
|
|
10
10
|
'figure.image.ck-widget > picture > img,' +
|
|
11
11
|
'figure.image.ck-widget > a > img,' +
|
|
@@ -19,7 +19,7 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
|
|
|
19
19
|
* It adds the ability to resize each image using handles or manually by
|
|
20
20
|
* {@link module:image/imageresize/imageresizebuttons~ImageResizeButtons} buttons.
|
|
21
21
|
*/
|
|
22
|
-
export
|
|
22
|
+
export class ImageResizeHandles extends Plugin {
|
|
23
23
|
/**
|
|
24
24
|
* @inheritDoc
|
|
25
25
|
*/
|
|
@@ -9,7 +9,7 @@ import { Command } from 'ckeditor5/src/core.js';
|
|
|
9
9
|
/**
|
|
10
10
|
* The resize image command. Currently, it only supports the width attribute.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export declare class ResizeImageCommand extends Command {
|
|
13
13
|
/**
|
|
14
14
|
* Desired image width and height.
|
|
15
15
|
*/
|
|
@@ -9,7 +9,7 @@ import { Command } from 'ckeditor5/src/core.js';
|
|
|
9
9
|
/**
|
|
10
10
|
* The resize image command. Currently, it only supports the width attribute.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export class ResizeImageCommand extends Command {
|
|
13
13
|
/**
|
|
14
14
|
* @inheritDoc
|
|
15
15
|
*/
|
|
@@ -12,8 +12,10 @@ import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.c
|
|
|
12
12
|
import '@ckeditor/ckeditor5-ui/theme/components/form/form.css';
|
|
13
13
|
/**
|
|
14
14
|
* The ImageCustomResizeFormView class.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
15
17
|
*/
|
|
16
|
-
export
|
|
18
|
+
export declare class ImageCustomResizeFormView extends View {
|
|
17
19
|
/**
|
|
18
20
|
* Tracks information about the DOM focus in the form.
|
|
19
21
|
*/
|
|
@@ -114,6 +116,8 @@ export default class ImageCustomResizeFormView extends View {
|
|
|
114
116
|
*
|
|
115
117
|
* * If `undefined` is returned, it is assumed that the form value is correct and there is no error.
|
|
116
118
|
* * If string is returned, it is assumed that the form value is incorrect and the returned string is displayed in the error label
|
|
119
|
+
*
|
|
120
|
+
* @internal
|
|
117
121
|
*/
|
|
118
122
|
export type ImageCustomResizeFormValidatorCallback = (form: ImageCustomResizeFormView) => string | undefined;
|
|
119
123
|
/**
|
|
@@ -16,8 +16,10 @@ import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.c
|
|
|
16
16
|
import '@ckeditor/ckeditor5-ui/theme/components/form/form.css';
|
|
17
17
|
/**
|
|
18
18
|
* The ImageCustomResizeFormView class.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
19
21
|
*/
|
|
20
|
-
export
|
|
22
|
+
export class ImageCustomResizeFormView extends View {
|
|
21
23
|
/**
|
|
22
24
|
* Tracks information about the DOM focus in the form.
|
|
23
25
|
*/
|
|
@@ -5,19 +5,20 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module image/imageresize/utils/getselectedimageeditornodes
|
|
7
7
|
*/
|
|
8
|
-
import type { ViewElement,
|
|
8
|
+
import type { ViewElement, ModelElement } from 'ckeditor5/src/engine.js';
|
|
9
9
|
import type { Editor } from 'ckeditor5/src/core.js';
|
|
10
10
|
/**
|
|
11
11
|
* Finds model, view and DOM element for selected image element. Returns `null` if there is no image selected.
|
|
12
12
|
*
|
|
13
13
|
* @param editor Editor instance.
|
|
14
|
+
* @internal
|
|
14
15
|
*/
|
|
15
16
|
export declare function getSelectedImageEditorNodes(editor: Editor): ImageEditorNodes | null;
|
|
16
17
|
/**
|
|
17
18
|
* @internal;
|
|
18
19
|
*/
|
|
19
20
|
type ImageEditorNodes = {
|
|
20
|
-
model:
|
|
21
|
+
model: ModelElement;
|
|
21
22
|
view: ViewElement;
|
|
22
23
|
dom: HTMLElement;
|
|
23
24
|
};
|
|
@@ -12,6 +12,7 @@ import type { Editor } from 'ckeditor5/src/core.js';
|
|
|
12
12
|
* @param editor Editor instance.
|
|
13
13
|
* @param targetUnit Unit in which dimension will be returned.
|
|
14
14
|
* @returns Possible resize range in numeric form.
|
|
15
|
+
* @internal
|
|
15
16
|
*/
|
|
16
17
|
export declare function getSelectedImagePossibleResizeRange(editor: Editor, targetUnit: string): PossibleResizeImageRange | null;
|
|
17
18
|
/**
|
|
@@ -11,6 +11,7 @@ import { tryCastDimensionsToUnit, tryParseDimensionWithUnit } from './tryparsedi
|
|
|
11
11
|
* @param editor Editor instance.
|
|
12
12
|
* @param targetUnit Unit in which dimension will be returned.
|
|
13
13
|
* @returns Possible resize range in numeric form.
|
|
14
|
+
* @internal
|
|
14
15
|
*/
|
|
15
16
|
export function getSelectedImagePossibleResizeRange(editor, targetUnit) {
|
|
16
17
|
const imageNodes = getSelectedImageEditorNodes(editor);
|
|
@@ -14,5 +14,6 @@ import { type DimensionWithUnit } from './tryparsedimensionwithunit.js';
|
|
|
14
14
|
* @param editor Editor instance.
|
|
15
15
|
* @param targetUnit Unit in which dimension will be returned.
|
|
16
16
|
* @returns Parsed image width after resize (with unit).
|
|
17
|
+
* @internal
|
|
17
18
|
*/
|
|
18
19
|
export declare function getSelectedImageWidthInUnits(editor: Editor, targetUnit: string): DimensionWithUnit | null;
|
|
@@ -19,6 +19,7 @@ import { getSelectedImageEditorNodes } from './getselectedimageeditornodes.js';
|
|
|
19
19
|
* @param editor Editor instance.
|
|
20
20
|
* @param targetUnit Unit in which dimension will be returned.
|
|
21
21
|
* @returns Parsed image width after resize (with unit).
|
|
22
|
+
* @internal
|
|
22
23
|
*/
|
|
23
24
|
export function getSelectedImageWidthInUnits(editor, targetUnit) {
|
|
24
25
|
const imageNodes = getSelectedImageEditorNodes(editor);
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
* @param dimension Unsafe string with dimension.
|
|
20
20
|
* @returns Parsed dimension with extracted numeric value and units.
|
|
21
|
+
* @internal
|
|
21
22
|
*/
|
|
22
23
|
export declare function tryParseDimensionWithUnit(dimension: string | null | undefined): DimensionWithUnit | null;
|
|
23
24
|
/**
|
|
@@ -26,6 +27,7 @@ export declare function tryParseDimensionWithUnit(dimension: string | null | und
|
|
|
26
27
|
* @param parentDimensionPx Dimension of parent element that contains measured element.
|
|
27
28
|
* @param dimension Measured element dimension.
|
|
28
29
|
* @returns Casted dimension.
|
|
30
|
+
* @internal
|
|
29
31
|
*/
|
|
30
32
|
export declare function tryCastDimensionsToUnit(parentDimensionPx: number, dimension: DimensionWithUnit, targetUnit: string): DimensionWithUnit;
|
|
31
33
|
/**
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
* @param dimension Unsafe string with dimension.
|
|
20
20
|
* @returns Parsed dimension with extracted numeric value and units.
|
|
21
|
+
* @internal
|
|
21
22
|
*/
|
|
22
23
|
export function tryParseDimensionWithUnit(dimension) {
|
|
23
24
|
if (!dimension) {
|
|
@@ -39,6 +40,7 @@ export function tryParseDimensionWithUnit(dimension) {
|
|
|
39
40
|
* @param parentDimensionPx Dimension of parent element that contains measured element.
|
|
40
41
|
* @param dimension Measured element dimension.
|
|
41
42
|
* @returns Casted dimension.
|
|
43
|
+
* @internal
|
|
42
44
|
*/
|
|
43
45
|
export function tryCastDimensionsToUnit(parentDimensionPx, dimension, targetUnit) {
|
|
44
46
|
// "%" -> "px" conversion
|
package/src/imageresize.d.ts
CHANGED
|
@@ -6,17 +6,17 @@
|
|
|
6
6
|
* @module image/imageresize
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import ImageResizeButtons from './imageresize/imageresizebuttons.js';
|
|
10
|
-
import ImageResizeEditing from './imageresize/imageresizeediting.js';
|
|
11
|
-
import ImageResizeHandles from './imageresize/imageresizehandles.js';
|
|
12
|
-
import ImageCustomResizeUI from './imageresize/imagecustomresizeui.js';
|
|
9
|
+
import { ImageResizeButtons } from './imageresize/imageresizebuttons.js';
|
|
10
|
+
import { ImageResizeEditing } from './imageresize/imageresizeediting.js';
|
|
11
|
+
import { ImageResizeHandles } from './imageresize/imageresizehandles.js';
|
|
12
|
+
import { ImageCustomResizeUI } from './imageresize/imagecustomresizeui.js';
|
|
13
13
|
import '../theme/imageresize.css';
|
|
14
14
|
/**
|
|
15
15
|
* The image resize plugin.
|
|
16
16
|
*
|
|
17
17
|
* It adds a possibility to resize each image using handles.
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export declare class ImageResize extends Plugin {
|
|
20
20
|
/**
|
|
21
21
|
* @inheritDoc
|
|
22
22
|
*/
|
package/src/imageresize.js
CHANGED
|
@@ -6,17 +6,17 @@
|
|
|
6
6
|
* @module image/imageresize
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import ImageResizeButtons from './imageresize/imageresizebuttons.js';
|
|
10
|
-
import ImageResizeEditing from './imageresize/imageresizeediting.js';
|
|
11
|
-
import ImageResizeHandles from './imageresize/imageresizehandles.js';
|
|
12
|
-
import ImageCustomResizeUI from './imageresize/imagecustomresizeui.js';
|
|
9
|
+
import { ImageResizeButtons } from './imageresize/imageresizebuttons.js';
|
|
10
|
+
import { ImageResizeEditing } from './imageresize/imageresizeediting.js';
|
|
11
|
+
import { ImageResizeHandles } from './imageresize/imageresizehandles.js';
|
|
12
|
+
import { ImageCustomResizeUI } from './imageresize/imagecustomresizeui.js';
|
|
13
13
|
import '../theme/imageresize.css';
|
|
14
14
|
/**
|
|
15
15
|
* The image resize plugin.
|
|
16
16
|
*
|
|
17
17
|
* It adds a possibility to resize each image using handles.
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export class ImageResize extends Plugin {
|
|
20
20
|
/**
|
|
21
21
|
* @inheritDoc
|
|
22
22
|
*/
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* @module image/imagesizeattributes
|
|
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
|
* This plugin enables `width` and `height` attributes in inline and block image elements.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export declare class ImageSizeAttributes extends Plugin {
|
|
14
14
|
/**
|
|
15
15
|
* @inheritDoc
|
|
16
16
|
*/
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
* @module image/imagesizeattributes
|
|
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 { widthAndHeightStylesAreBothSet, getSizeValueIfInPx } from './image/utils.js';
|
|
11
11
|
/**
|
|
12
12
|
* This plugin enables `width` and `height` attributes in inline and block image elements.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export class ImageSizeAttributes extends Plugin {
|
|
15
15
|
/**
|
|
16
16
|
* @inheritDoc
|
|
17
17
|
*/
|
|
@@ -42,11 +42,12 @@ export default class ImageSizeAttributes extends Plugin {
|
|
|
42
42
|
* Registers the `width` and `height` attributes for inline and block images.
|
|
43
43
|
*/
|
|
44
44
|
_registerSchema() {
|
|
45
|
+
const schema = this.editor.model.schema;
|
|
45
46
|
if (this.editor.plugins.has('ImageBlockEditing')) {
|
|
46
|
-
|
|
47
|
+
schema.extend('imageBlock', { allowAttributes: ['width', 'height'] });
|
|
47
48
|
}
|
|
48
49
|
if (this.editor.plugins.has('ImageInlineEditing')) {
|
|
49
|
-
|
|
50
|
+
schema.extend('imageInline', { allowAttributes: ['width', 'height'] });
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
/**
|
|
@@ -13,6 +13,7 @@ import type { ImageStyleOptionDefinition } from '../imageconfig.js';
|
|
|
13
13
|
*
|
|
14
14
|
* @param styles An array containing available image style options.
|
|
15
15
|
* @returns A model-to-view attribute converter.
|
|
16
|
+
* @internal
|
|
16
17
|
*/
|
|
17
18
|
export declare function modelToViewStyleAttribute(styles: Array<ImageStyleOptionDefinition>): GetCallback<DowncastAttributeEvent>;
|
|
18
19
|
/**
|
|
@@ -20,5 +21,6 @@ export declare function modelToViewStyleAttribute(styles: Array<ImageStyleOption
|
|
|
20
21
|
*
|
|
21
22
|
* @param styles Image style options for which the converter is created.
|
|
22
23
|
* @returns A view-to-model converter.
|
|
24
|
+
* @internal
|
|
23
25
|
*/
|
|
24
26
|
export declare function viewToModelStyleAttribute(styles: Array<ImageStyleOptionDefinition>): GetCallback<UpcastElementEvent>;
|
|
@@ -11,6 +11,7 @@ import { first } from 'ckeditor5/src/utils.js';
|
|
|
11
11
|
*
|
|
12
12
|
* @param styles An array containing available image style options.
|
|
13
13
|
* @returns A model-to-view attribute converter.
|
|
14
|
+
* @internal
|
|
14
15
|
*/
|
|
15
16
|
export function modelToViewStyleAttribute(styles) {
|
|
16
17
|
return (evt, data, conversionApi) => {
|
|
@@ -35,6 +36,7 @@ export function modelToViewStyleAttribute(styles) {
|
|
|
35
36
|
*
|
|
36
37
|
* @param styles Image style options for which the converter is created.
|
|
37
38
|
* @returns A view-to-model converter.
|
|
39
|
+
* @internal
|
|
38
40
|
*/
|
|
39
41
|
export function viewToModelStyleAttribute(styles) {
|
|
40
42
|
// Convert only non–default styles.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module image/imagestyle/imagestylecommand
|
|
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
|
import type { ImageStyleOptionDefinition } from '../imageconfig.js';
|
|
11
11
|
/**
|
|
@@ -15,7 +15,7 @@ import type { ImageStyleOptionDefinition } from '../imageconfig.js';
|
|
|
15
15
|
* **Note**: Executing this command may change the image model element if the desired style requires an image of a different
|
|
16
16
|
* type. See {@link module:image/imagestyle/imagestylecommand~ImageStyleCommand#execute} to learn more.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export declare class ImageStyleCommand extends Command {
|
|
19
19
|
/**
|
|
20
20
|
* An object containing names of default style options for the inline and block images.
|
|
21
21
|
* If there is no default style option for the given image type in the configuration,
|
|
@@ -64,5 +64,5 @@ export default class ImageStyleCommand extends Command {
|
|
|
64
64
|
* @param requestedStyle The name of the style (as configured in {@link module:image/imageconfig~ImageStyleConfig#options}).
|
|
65
65
|
* @param imageElement The image model element.
|
|
66
66
|
*/
|
|
67
|
-
shouldConvertImageType(requestedStyle: string, imageElement:
|
|
67
|
+
shouldConvertImageType(requestedStyle: string, imageElement: ModelElement): boolean;
|
|
68
68
|
}
|
|
@@ -10,7 +10,7 @@ import { Command } from 'ckeditor5/src/core.js';
|
|
|
10
10
|
* **Note**: Executing this command may change the image model element if the desired style requires an image of a different
|
|
11
11
|
* type. See {@link module:image/imagestyle/imagestylecommand~ImageStyleCommand#execute} to learn more.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export class ImageStyleCommand extends Command {
|
|
14
14
|
/**
|
|
15
15
|
* An object containing names of default style options for the inline and block images.
|
|
16
16
|
* If there is no default style option for the given image type in the configuration,
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* @module image/imagestyle/imagestyleediting
|
|
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 type { ImageStyleOptionDefinition } from '../imageconfig.js';
|
|
11
11
|
/**
|
|
12
12
|
* The image style engine plugin. It sets the default configuration, creates converters and registers
|
|
13
13
|
* {@link module:image/imagestyle/imagestylecommand~ImageStyleCommand ImageStyleCommand}.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export declare class ImageStyleEditing extends Plugin {
|
|
16
16
|
/**
|
|
17
17
|
* @inheritDoc
|
|
18
18
|
*/
|
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
* @module image/imagestyle/imagestyleediting
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import ImageStyleCommand from './imagestylecommand.js';
|
|
10
|
-
import ImageUtils from '../imageutils.js';
|
|
11
|
-
import utils from './utils.js';
|
|
9
|
+
import { ImageStyleCommand } from './imagestylecommand.js';
|
|
10
|
+
import { ImageUtils } from '../imageutils.js';
|
|
11
|
+
import { utils } from './utils.js';
|
|
12
12
|
import { viewToModelStyleAttribute, modelToViewStyleAttribute } from './converters.js';
|
|
13
13
|
/**
|
|
14
14
|
* The image style engine plugin. It sets the default configuration, creates converters and registers
|
|
15
15
|
* {@link module:image/imagestyle/imagestylecommand~ImageStyleCommand ImageStyleCommand}.
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export class ImageStyleEditing extends Plugin {
|
|
18
18
|
/**
|
|
19
19
|
* @inheritDoc
|
|
20
20
|
*/
|
|
@@ -49,12 +49,11 @@ export default class ImageStyleEditing extends Plugin {
|
|
|
49
49
|
* @inheritDoc
|
|
50
50
|
*/
|
|
51
51
|
init() {
|
|
52
|
-
const { normalizeStyles, getDefaultStylesConfiguration } = utils;
|
|
53
52
|
const editor = this.editor;
|
|
54
53
|
const isBlockPluginLoaded = editor.plugins.has('ImageBlockEditing');
|
|
55
54
|
const isInlinePluginLoaded = editor.plugins.has('ImageInlineEditing');
|
|
56
|
-
editor.config.define('image.styles', getDefaultStylesConfiguration(isBlockPluginLoaded, isInlinePluginLoaded));
|
|
57
|
-
this.normalizedStyles = normalizeStyles({
|
|
55
|
+
editor.config.define('image.styles', utils.getDefaultStylesConfiguration(isBlockPluginLoaded, isInlinePluginLoaded));
|
|
56
|
+
this.normalizedStyles = utils.normalizeStyles({
|
|
58
57
|
configuredStyles: editor.config.get('image.styles'),
|
|
59
58
|
isBlockPluginLoaded,
|
|
60
59
|
isInlinePluginLoaded
|
|
@@ -80,11 +79,13 @@ export default class ImageStyleEditing extends Plugin {
|
|
|
80
79
|
// We could call it 'style' but https://github.com/ckeditor/ckeditor5-engine/issues/559.
|
|
81
80
|
if (isBlockPluginLoaded) {
|
|
82
81
|
schema.extend('imageBlock', { allowAttributes: 'imageStyle' });
|
|
82
|
+
schema.setAttributeProperties('imageStyle', { isFormatting: true });
|
|
83
83
|
// Converter for figure element from view to model.
|
|
84
84
|
editor.data.upcastDispatcher.on('element:figure', viewToModelConverter, { priority: 'low' });
|
|
85
85
|
}
|
|
86
86
|
if (isInlinePluginLoaded) {
|
|
87
87
|
schema.extend('imageInline', { allowAttributes: 'imageStyle' });
|
|
88
|
+
schema.setAttributeProperties('imageStyle', { isFormatting: true });
|
|
88
89
|
// Converter for the img element from view to model.
|
|
89
90
|
editor.data.upcastDispatcher.on('element:img', viewToModelConverter, { priority: 'low' });
|
|
90
91
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module image/imagestyle/imagestyleui
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import ImageStyleEditing from './imagestyleediting.js';
|
|
9
|
+
import { ImageStyleEditing } from './imagestyleediting.js';
|
|
10
10
|
import '../../theme/imagestyle.css';
|
|
11
11
|
/**
|
|
12
12
|
* The image style UI plugin.
|
|
@@ -15,7 +15,7 @@ import '../../theme/imagestyle.css';
|
|
|
15
15
|
* It also registers the {@link module:image/imagestyle/utils#DEFAULT_DROPDOWN_DEFINITIONS default drop-downs} and the
|
|
16
16
|
* custom drop-downs defined by the developer in the {@link module:image/imageconfig~ImageConfig#toolbar} configuration.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export declare class ImageStyleUI extends Plugin {
|
|
19
19
|
/**
|
|
20
20
|
* @inheritDoc
|
|
21
21
|
*/
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
9
|
import { ButtonView, createDropdown, addToolbarToDropdown, SplitButtonView } from 'ckeditor5/src/ui.js';
|
|
10
10
|
import { isObject, identity } from 'es-toolkit/compat';
|
|
11
|
-
import ImageStyleEditing from './imagestyleediting.js';
|
|
12
|
-
import utils from './utils.js';
|
|
11
|
+
import { ImageStyleEditing } from './imagestyleediting.js';
|
|
12
|
+
import { utils } from './utils.js';
|
|
13
13
|
import '../../theme/imagestyle.css';
|
|
14
14
|
/**
|
|
15
15
|
* The image style UI plugin.
|
|
@@ -18,7 +18,7 @@ import '../../theme/imagestyle.css';
|
|
|
18
18
|
* It also registers the {@link module:image/imagestyle/utils#DEFAULT_DROPDOWN_DEFINITIONS default drop-downs} and the
|
|
19
19
|
* custom drop-downs defined by the developer in the {@link module:image/imageconfig~ImageConfig#toolbar} configuration.
|
|
20
20
|
*/
|
|
21
|
-
export
|
|
21
|
+
export class ImageStyleUI extends Plugin {
|
|
22
22
|
/**
|
|
23
23
|
* @inheritDoc
|
|
24
24
|
*/
|
|
@@ -21,6 +21,8 @@ import type { ImageStyleConfig, ImageStyleDropdownDefinition, ImageStyleOptionDe
|
|
|
21
21
|
* * **`'inline'`** is an inline image without any CSS class,
|
|
22
22
|
* * **`'block'`** is a block image without any CSS class,
|
|
23
23
|
* * **`'side'`** is a block image styled with the `image-style-side` CSS class.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
24
26
|
*/
|
|
25
27
|
export declare const DEFAULT_OPTIONS: Record<string, ImageStyleOptionDefinition>;
|
|
26
28
|
/**
|
|
@@ -30,6 +32,8 @@ export declare const DEFAULT_OPTIONS: Record<string, ImageStyleOptionDefinition>
|
|
|
30
32
|
* See {@link module:image/imageconfig~ImageStyleOptionDefinition#icon} to learn more.
|
|
31
33
|
*
|
|
32
34
|
* There are 7 default icons available: `'full'`, `'left'`, `'inlineLeft'`, `'center'`, `'right'`, `'inlineRight'`, and `'inline'`.
|
|
35
|
+
*
|
|
36
|
+
* @internal
|
|
33
37
|
*/
|
|
34
38
|
export declare const DEFAULT_ICONS: Record<string, string>;
|
|
35
39
|
/**
|
|
@@ -42,6 +46,8 @@ export declare const DEFAULT_ICONS: Record<string, string>;
|
|
|
42
46
|
* those that wraps the text around the image,
|
|
43
47
|
* * **`'imageStyle:breakText'`**, which contains the `alignBlockLeft`, `alignCenter` and `alignBlockRight` options, that is,
|
|
44
48
|
* those that breaks the text around the image.
|
|
49
|
+
*
|
|
50
|
+
* @internal
|
|
45
51
|
*/
|
|
46
52
|
export declare const DEFAULT_DROPDOWN_DEFINITIONS: Array<ImageStyleDropdownDefinition>;
|
|
47
53
|
/**
|
|
@@ -86,13 +92,13 @@ declare function getDefaultDropdownDefinitions(pluginCollection: PluginCollectio
|
|
|
86
92
|
* Displays a console warning with the 'image-style-configuration-definition-invalid' error.
|
|
87
93
|
*/
|
|
88
94
|
declare function warnInvalidStyle(info: object): void;
|
|
89
|
-
|
|
95
|
+
/**
|
|
96
|
+
* @internal
|
|
97
|
+
*/
|
|
98
|
+
export declare const utils: {
|
|
90
99
|
normalizeStyles: typeof normalizeStyles;
|
|
91
100
|
getDefaultStylesConfiguration: typeof getDefaultStylesConfiguration;
|
|
92
101
|
getDefaultDropdownDefinitions: typeof getDefaultDropdownDefinitions;
|
|
93
102
|
warnInvalidStyle: typeof warnInvalidStyle;
|
|
94
|
-
DEFAULT_OPTIONS: Record<string, ImageStyleOptionDefinition>;
|
|
95
|
-
DEFAULT_ICONS: Record<string, string>;
|
|
96
|
-
DEFAULT_DROPDOWN_DEFINITIONS: ImageStyleDropdownDefinition[];
|
|
97
103
|
};
|
|
98
|
-
export
|
|
104
|
+
export {};
|