@ckeditor/ckeditor5-image 38.1.0 → 38.1.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.
Files changed (109) hide show
  1. package/build/image.js +1 -1
  2. package/build/image.js.map +1 -0
  3. package/package.json +3 -3
  4. package/src/augmentation.d.ts +55 -55
  5. package/src/augmentation.js +5 -5
  6. package/src/autoimage.d.ts +52 -52
  7. package/src/autoimage.js +132 -132
  8. package/src/image/converters.d.ts +66 -66
  9. package/src/image/converters.js +242 -242
  10. package/src/image/imageblockediting.d.ts +55 -55
  11. package/src/image/imageblockediting.js +136 -136
  12. package/src/image/imageediting.d.ts +30 -30
  13. package/src/image/imageediting.js +74 -74
  14. package/src/image/imageinlineediting.d.ts +56 -56
  15. package/src/image/imageinlineediting.js +160 -160
  16. package/src/image/imageloadobserver.d.ts +48 -48
  17. package/src/image/imageloadobserver.js +52 -52
  18. package/src/image/imagetypecommand.d.ts +40 -40
  19. package/src/image/imagetypecommand.js +77 -77
  20. package/src/image/insertimagecommand.d.ts +66 -66
  21. package/src/image/insertimagecommand.js +120 -120
  22. package/src/image/replaceimagesourcecommand.d.ts +34 -34
  23. package/src/image/replaceimagesourcecommand.js +44 -44
  24. package/src/image/ui/utils.d.ts +25 -25
  25. package/src/image/ui/utils.js +44 -44
  26. package/src/image/utils.d.ts +52 -52
  27. package/src/image/utils.js +100 -100
  28. package/src/image.d.ts +34 -34
  29. package/src/image.js +38 -38
  30. package/src/imageblock.d.ts +33 -33
  31. package/src/imageblock.js +37 -37
  32. package/src/imagecaption/imagecaptionediting.d.ts +89 -89
  33. package/src/imagecaption/imagecaptionediting.js +225 -225
  34. package/src/imagecaption/imagecaptionui.d.ts +26 -26
  35. package/src/imagecaption/imagecaptionui.js +61 -61
  36. package/src/imagecaption/imagecaptionutils.d.ts +38 -38
  37. package/src/imagecaption/imagecaptionutils.js +62 -62
  38. package/src/imagecaption/toggleimagecaptioncommand.d.ts +66 -66
  39. package/src/imagecaption/toggleimagecaptioncommand.js +138 -138
  40. package/src/imagecaption.d.ts +26 -26
  41. package/src/imagecaption.js +30 -30
  42. package/src/imageconfig.d.ts +713 -713
  43. package/src/imageconfig.js +5 -5
  44. package/src/imageinline.d.ts +33 -33
  45. package/src/imageinline.js +37 -37
  46. package/src/imageinsert/imageinsertui.d.ts +44 -44
  47. package/src/imageinsert/imageinsertui.js +141 -141
  48. package/src/imageinsert/ui/imageinsertformrowview.d.ts +61 -61
  49. package/src/imageinsert/ui/imageinsertformrowview.js +54 -54
  50. package/src/imageinsert/ui/imageinsertpanelview.d.ts +106 -106
  51. package/src/imageinsert/ui/imageinsertpanelview.js +161 -161
  52. package/src/imageinsert/utils.d.ts +25 -25
  53. package/src/imageinsert/utils.js +58 -58
  54. package/src/imageinsert.d.ts +33 -33
  55. package/src/imageinsert.js +37 -37
  56. package/src/imageinsertviaurl.d.ts +30 -30
  57. package/src/imageinsertviaurl.js +34 -34
  58. package/src/imageresize/imageresizebuttons.d.ts +67 -67
  59. package/src/imageresize/imageresizebuttons.js +217 -217
  60. package/src/imageresize/imageresizeediting.d.ts +37 -37
  61. package/src/imageresize/imageresizeediting.js +114 -114
  62. package/src/imageresize/imageresizehandles.d.ts +30 -30
  63. package/src/imageresize/imageresizehandles.js +107 -107
  64. package/src/imageresize/resizeimagecommand.d.ts +42 -42
  65. package/src/imageresize/resizeimagecommand.js +61 -61
  66. package/src/imageresize.d.ts +27 -27
  67. package/src/imageresize.js +31 -31
  68. package/src/imagestyle/converters.d.ts +24 -24
  69. package/src/imagestyle/converters.js +79 -79
  70. package/src/imagestyle/imagestylecommand.d.ts +65 -65
  71. package/src/imagestyle/imagestylecommand.js +101 -101
  72. package/src/imagestyle/imagestyleediting.d.ts +50 -50
  73. package/src/imagestyle/imagestyleediting.js +108 -108
  74. package/src/imagestyle/imagestyleui.d.ts +56 -56
  75. package/src/imagestyle/imagestyleui.js +192 -192
  76. package/src/imagestyle/utils.d.ts +101 -101
  77. package/src/imagestyle/utils.js +329 -329
  78. package/src/imagestyle.d.ts +32 -32
  79. package/src/imagestyle.js +36 -36
  80. package/src/imagetextalternative/imagetextalternativecommand.d.ts +34 -34
  81. package/src/imagetextalternative/imagetextalternativecommand.js +44 -44
  82. package/src/imagetextalternative/imagetextalternativeediting.d.ts +28 -28
  83. package/src/imagetextalternative/imagetextalternativeediting.js +35 -35
  84. package/src/imagetextalternative/imagetextalternativeui.d.ts +68 -68
  85. package/src/imagetextalternative/imagetextalternativeui.js +173 -173
  86. package/src/imagetextalternative/ui/textalternativeformview.d.ts +72 -72
  87. package/src/imagetextalternative/ui/textalternativeformview.js +121 -121
  88. package/src/imagetextalternative.d.ts +29 -29
  89. package/src/imagetextalternative.js +33 -33
  90. package/src/imagetoolbar.d.ts +35 -35
  91. package/src/imagetoolbar.js +57 -57
  92. package/src/imageupload/imageuploadediting.d.ts +111 -111
  93. package/src/imageupload/imageuploadediting.js +335 -335
  94. package/src/imageupload/imageuploadprogress.d.ts +42 -42
  95. package/src/imageupload/imageuploadprogress.js +211 -211
  96. package/src/imageupload/imageuploadui.d.ts +23 -23
  97. package/src/imageupload/imageuploadui.js +57 -57
  98. package/src/imageupload/uploadimagecommand.d.ts +60 -60
  99. package/src/imageupload/uploadimagecommand.js +100 -100
  100. package/src/imageupload/utils.d.ts +33 -33
  101. package/src/imageupload/utils.js +112 -112
  102. package/src/imageupload.d.ts +32 -32
  103. package/src/imageupload.js +36 -36
  104. package/src/imageutils.d.ts +102 -102
  105. package/src/imageutils.js +248 -248
  106. package/src/index.d.ts +47 -47
  107. package/src/index.js +38 -38
  108. package/src/pictureediting.d.ts +88 -88
  109. package/src/pictureediting.js +130 -130
@@ -1,61 +1,61 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module image/imageresize/resizeimagecommand
7
- */
8
- import { Command } from 'ckeditor5/src/core';
9
- /**
10
- * The resize image command. Currently, it only supports the width attribute.
11
- */
12
- export default class ResizeImageCommand extends Command {
13
- /**
14
- * @inheritDoc
15
- */
16
- refresh() {
17
- const editor = this.editor;
18
- const imageUtils = editor.plugins.get('ImageUtils');
19
- const element = imageUtils.getClosestSelectedImageElement(editor.model.document.selection);
20
- this.isEnabled = !!element;
21
- if (!element || !element.hasAttribute('width')) {
22
- this.value = null;
23
- }
24
- else {
25
- this.value = {
26
- width: element.getAttribute('width'),
27
- height: null
28
- };
29
- }
30
- }
31
- /**
32
- * Executes the command.
33
- *
34
- * ```ts
35
- * // Sets the width to 50%:
36
- * editor.execute( 'resizeImage', { width: '50%' } );
37
- *
38
- * // Removes the width attribute:
39
- * editor.execute( 'resizeImage', { width: null } );
40
- * ```
41
- *
42
- * @param options
43
- * @param options.width The new width of the image.
44
- * @fires execute
45
- */
46
- execute(options) {
47
- const editor = this.editor;
48
- const model = editor.model;
49
- const imageUtils = editor.plugins.get('ImageUtils');
50
- const imageElement = imageUtils.getClosestSelectedImageElement(model.document.selection);
51
- this.value = {
52
- width: options.width,
53
- height: null
54
- };
55
- if (imageElement) {
56
- model.change(writer => {
57
- writer.setAttribute('width', options.width, imageElement);
58
- });
59
- }
60
- }
61
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module image/imageresize/resizeimagecommand
7
+ */
8
+ import { Command } from 'ckeditor5/src/core';
9
+ /**
10
+ * The resize image command. Currently, it only supports the width attribute.
11
+ */
12
+ export default class ResizeImageCommand extends Command {
13
+ /**
14
+ * @inheritDoc
15
+ */
16
+ refresh() {
17
+ const editor = this.editor;
18
+ const imageUtils = editor.plugins.get('ImageUtils');
19
+ const element = imageUtils.getClosestSelectedImageElement(editor.model.document.selection);
20
+ this.isEnabled = !!element;
21
+ if (!element || !element.hasAttribute('width')) {
22
+ this.value = null;
23
+ }
24
+ else {
25
+ this.value = {
26
+ width: element.getAttribute('width'),
27
+ height: null
28
+ };
29
+ }
30
+ }
31
+ /**
32
+ * Executes the command.
33
+ *
34
+ * ```ts
35
+ * // Sets the width to 50%:
36
+ * editor.execute( 'resizeImage', { width: '50%' } );
37
+ *
38
+ * // Removes the width attribute:
39
+ * editor.execute( 'resizeImage', { width: null } );
40
+ * ```
41
+ *
42
+ * @param options
43
+ * @param options.width The new width of the image.
44
+ * @fires execute
45
+ */
46
+ execute(options) {
47
+ const editor = this.editor;
48
+ const model = editor.model;
49
+ const imageUtils = editor.plugins.get('ImageUtils');
50
+ const imageElement = imageUtils.getClosestSelectedImageElement(model.document.selection);
51
+ this.value = {
52
+ width: options.width,
53
+ height: null
54
+ };
55
+ if (imageElement) {
56
+ model.change(writer => {
57
+ writer.setAttribute('width', options.width, imageElement);
58
+ });
59
+ }
60
+ }
61
+ }
@@ -1,27 +1,27 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module image/imageresize
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import ImageResizeButtons from './imageresize/imageresizebuttons';
10
- import ImageResizeEditing from './imageresize/imageresizeediting';
11
- import ImageResizeHandles from './imageresize/imageresizehandles';
12
- import '../theme/imageresize.css';
13
- /**
14
- * The image resize plugin.
15
- *
16
- * It adds a possibility to resize each image using handles.
17
- */
18
- export default class ImageResize extends Plugin {
19
- /**
20
- * @inheritDoc
21
- */
22
- static get requires(): readonly [typeof ImageResizeEditing, typeof ImageResizeHandles, typeof ImageResizeButtons];
23
- /**
24
- * @inheritDoc
25
- */
26
- static get pluginName(): "ImageResize";
27
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module image/imageresize
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import ImageResizeButtons from './imageresize/imageresizebuttons';
10
+ import ImageResizeEditing from './imageresize/imageresizeediting';
11
+ import ImageResizeHandles from './imageresize/imageresizehandles';
12
+ import '../theme/imageresize.css';
13
+ /**
14
+ * The image resize plugin.
15
+ *
16
+ * It adds a possibility to resize each image using handles.
17
+ */
18
+ export default class ImageResize extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get requires(): readonly [typeof ImageResizeEditing, typeof ImageResizeHandles, typeof ImageResizeButtons];
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get pluginName(): "ImageResize";
27
+ }
@@ -1,31 +1,31 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module image/imageresize
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import ImageResizeButtons from './imageresize/imageresizebuttons';
10
- import ImageResizeEditing from './imageresize/imageresizeediting';
11
- import ImageResizeHandles from './imageresize/imageresizehandles';
12
- import '../theme/imageresize.css';
13
- /**
14
- * The image resize plugin.
15
- *
16
- * It adds a possibility to resize each image using handles.
17
- */
18
- export default class ImageResize extends Plugin {
19
- /**
20
- * @inheritDoc
21
- */
22
- static get requires() {
23
- return [ImageResizeEditing, ImageResizeHandles, ImageResizeButtons];
24
- }
25
- /**
26
- * @inheritDoc
27
- */
28
- static get pluginName() {
29
- return 'ImageResize';
30
- }
31
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module image/imageresize
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import ImageResizeButtons from './imageresize/imageresizebuttons';
10
+ import ImageResizeEditing from './imageresize/imageresizeediting';
11
+ import ImageResizeHandles from './imageresize/imageresizehandles';
12
+ import '../theme/imageresize.css';
13
+ /**
14
+ * The image resize plugin.
15
+ *
16
+ * It adds a possibility to resize each image using handles.
17
+ */
18
+ export default class ImageResize extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get requires() {
23
+ return [ImageResizeEditing, ImageResizeHandles, ImageResizeButtons];
24
+ }
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ static get pluginName() {
29
+ return 'ImageResize';
30
+ }
31
+ }
@@ -1,24 +1,24 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- import type { DowncastAttributeEvent, UpcastElementEvent } from 'ckeditor5/src/engine';
6
- import { type GetCallback } from 'ckeditor5/src/utils';
7
- import type { ImageStyleOptionDefinition } from '../imageconfig';
8
- /**
9
- * @module image/imagestyle/converters
10
- */
11
- /**
12
- * Returns a converter for the `imageStyle` attribute. It can be used for adding, changing and removing the attribute.
13
- *
14
- * @param styles An array containing available image style options.
15
- * @returns A model-to-view attribute converter.
16
- */
17
- export declare function modelToViewStyleAttribute(styles: Array<ImageStyleOptionDefinition>): GetCallback<DowncastAttributeEvent>;
18
- /**
19
- * Returns a view-to-model converter converting image CSS classes to a proper value in the model.
20
- *
21
- * @param styles Image style options for which the converter is created.
22
- * @returns A view-to-model converter.
23
- */
24
- export declare function viewToModelStyleAttribute(styles: Array<ImageStyleOptionDefinition>): GetCallback<UpcastElementEvent>;
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ import type { DowncastAttributeEvent, UpcastElementEvent } from 'ckeditor5/src/engine';
6
+ import { type GetCallback } from 'ckeditor5/src/utils';
7
+ import type { ImageStyleOptionDefinition } from '../imageconfig';
8
+ /**
9
+ * @module image/imagestyle/converters
10
+ */
11
+ /**
12
+ * Returns a converter for the `imageStyle` attribute. It can be used for adding, changing and removing the attribute.
13
+ *
14
+ * @param styles An array containing available image style options.
15
+ * @returns A model-to-view attribute converter.
16
+ */
17
+ export declare function modelToViewStyleAttribute(styles: Array<ImageStyleOptionDefinition>): GetCallback<DowncastAttributeEvent>;
18
+ /**
19
+ * Returns a view-to-model converter converting image CSS classes to a proper value in the model.
20
+ *
21
+ * @param styles Image style options for which the converter is created.
22
+ * @returns A view-to-model converter.
23
+ */
24
+ export declare function viewToModelStyleAttribute(styles: Array<ImageStyleOptionDefinition>): GetCallback<UpcastElementEvent>;
@@ -1,79 +1,79 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- import { first } from 'ckeditor5/src/utils';
6
- /**
7
- * @module image/imagestyle/converters
8
- */
9
- /**
10
- * Returns a converter for the `imageStyle` attribute. It can be used for adding, changing and removing the attribute.
11
- *
12
- * @param styles An array containing available image style options.
13
- * @returns A model-to-view attribute converter.
14
- */
15
- export function modelToViewStyleAttribute(styles) {
16
- return (evt, data, conversionApi) => {
17
- if (!conversionApi.consumable.consume(data.item, evt.name)) {
18
- return;
19
- }
20
- // Check if there is class name associated with given value.
21
- const newStyle = getStyleDefinitionByName(data.attributeNewValue, styles);
22
- const oldStyle = getStyleDefinitionByName(data.attributeOldValue, styles);
23
- const viewElement = conversionApi.mapper.toViewElement(data.item);
24
- const viewWriter = conversionApi.writer;
25
- if (oldStyle) {
26
- viewWriter.removeClass(oldStyle.className, viewElement);
27
- }
28
- if (newStyle) {
29
- viewWriter.addClass(newStyle.className, viewElement);
30
- }
31
- };
32
- }
33
- /**
34
- * Returns a view-to-model converter converting image CSS classes to a proper value in the model.
35
- *
36
- * @param styles Image style options for which the converter is created.
37
- * @returns A view-to-model converter.
38
- */
39
- export function viewToModelStyleAttribute(styles) {
40
- // Convert only non–default styles.
41
- const nonDefaultStyles = {
42
- imageInline: styles.filter(style => !style.isDefault && style.modelElements.includes('imageInline')),
43
- imageBlock: styles.filter(style => !style.isDefault && style.modelElements.includes('imageBlock'))
44
- };
45
- return (evt, data, conversionApi) => {
46
- if (!data.modelRange) {
47
- return;
48
- }
49
- const viewElement = data.viewItem;
50
- const modelImageElement = first(data.modelRange.getItems());
51
- // Run this converter only if an image has been found in the model.
52
- // In some cases it may not be found (for example if we run this on a figure with different type than image).
53
- if (!modelImageElement) {
54
- return;
55
- }
56
- // ...and the `imageStyle` attribute is allowed for that element, otherwise stop conversion early.
57
- if (!conversionApi.schema.checkAttribute(modelImageElement, 'imageStyle')) {
58
- return;
59
- }
60
- // Convert styles one by one.
61
- for (const style of nonDefaultStyles[modelImageElement.name]) {
62
- // Try to consume class corresponding with the style.
63
- if (conversionApi.consumable.consume(viewElement, { classes: style.className })) {
64
- // And convert this style to model attribute.
65
- conversionApi.writer.setAttribute('imageStyle', style.name, modelImageElement);
66
- }
67
- }
68
- };
69
- }
70
- /**
71
- * Returns the style with a given `name` from an array of styles.
72
- */
73
- function getStyleDefinitionByName(name, styles) {
74
- for (const style of styles) {
75
- if (style.name === name) {
76
- return style;
77
- }
78
- }
79
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ import { first } from 'ckeditor5/src/utils';
6
+ /**
7
+ * @module image/imagestyle/converters
8
+ */
9
+ /**
10
+ * Returns a converter for the `imageStyle` attribute. It can be used for adding, changing and removing the attribute.
11
+ *
12
+ * @param styles An array containing available image style options.
13
+ * @returns A model-to-view attribute converter.
14
+ */
15
+ export function modelToViewStyleAttribute(styles) {
16
+ return (evt, data, conversionApi) => {
17
+ if (!conversionApi.consumable.consume(data.item, evt.name)) {
18
+ return;
19
+ }
20
+ // Check if there is class name associated with given value.
21
+ const newStyle = getStyleDefinitionByName(data.attributeNewValue, styles);
22
+ const oldStyle = getStyleDefinitionByName(data.attributeOldValue, styles);
23
+ const viewElement = conversionApi.mapper.toViewElement(data.item);
24
+ const viewWriter = conversionApi.writer;
25
+ if (oldStyle) {
26
+ viewWriter.removeClass(oldStyle.className, viewElement);
27
+ }
28
+ if (newStyle) {
29
+ viewWriter.addClass(newStyle.className, viewElement);
30
+ }
31
+ };
32
+ }
33
+ /**
34
+ * Returns a view-to-model converter converting image CSS classes to a proper value in the model.
35
+ *
36
+ * @param styles Image style options for which the converter is created.
37
+ * @returns A view-to-model converter.
38
+ */
39
+ export function viewToModelStyleAttribute(styles) {
40
+ // Convert only non–default styles.
41
+ const nonDefaultStyles = {
42
+ imageInline: styles.filter(style => !style.isDefault && style.modelElements.includes('imageInline')),
43
+ imageBlock: styles.filter(style => !style.isDefault && style.modelElements.includes('imageBlock'))
44
+ };
45
+ return (evt, data, conversionApi) => {
46
+ if (!data.modelRange) {
47
+ return;
48
+ }
49
+ const viewElement = data.viewItem;
50
+ const modelImageElement = first(data.modelRange.getItems());
51
+ // Run this converter only if an image has been found in the model.
52
+ // In some cases it may not be found (for example if we run this on a figure with different type than image).
53
+ if (!modelImageElement) {
54
+ return;
55
+ }
56
+ // ...and the `imageStyle` attribute is allowed for that element, otherwise stop conversion early.
57
+ if (!conversionApi.schema.checkAttribute(modelImageElement, 'imageStyle')) {
58
+ return;
59
+ }
60
+ // Convert styles one by one.
61
+ for (const style of nonDefaultStyles[modelImageElement.name]) {
62
+ // Try to consume class corresponding with the style.
63
+ if (conversionApi.consumable.consume(viewElement, { classes: style.className })) {
64
+ // And convert this style to model attribute.
65
+ conversionApi.writer.setAttribute('imageStyle', style.name, modelImageElement);
66
+ }
67
+ }
68
+ };
69
+ }
70
+ /**
71
+ * Returns the style with a given `name` from an array of styles.
72
+ */
73
+ function getStyleDefinitionByName(name, styles) {
74
+ for (const style of styles) {
75
+ if (style.name === name) {
76
+ return style;
77
+ }
78
+ }
79
+ }
@@ -1,65 +1,65 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module image/imagestyle/imagestylecommand
7
- */
8
- import type { Element } from 'ckeditor5/src/engine';
9
- import { Command, type Editor } from 'ckeditor5/src/core';
10
- import type { ImageStyleOptionDefinition } from '../imageconfig';
11
- /**
12
- * The image style command. It is used to apply {@link module:image/imageconfig~ImageStyleConfig#options image style option}
13
- * to a selected image.
14
- *
15
- * **Note**: Executing this command may change the image model element if the desired style requires an image of a different
16
- * type. See {@link module:image/imagestyle/imagestylecommand~ImageStyleCommand#execute} to learn more.
17
- */
18
- export default class ImageStyleCommand extends Command {
19
- /**
20
- * An object containing names of default style options for the inline and block images.
21
- * If there is no default style option for the given image type in the configuration,
22
- * the name will be `false`.
23
- */
24
- private _defaultStyles;
25
- /**
26
- * The styles handled by this command.
27
- */
28
- private _styles;
29
- /**
30
- * Creates an instance of the image style command. When executed, the command applies one of
31
- * {@link module:image/imageconfig~ImageStyleConfig#options style options} to the currently selected image.
32
- *
33
- * @param editor The editor instance.
34
- * @param styles The style options that this command supports.
35
- */
36
- constructor(editor: Editor, styles: Array<ImageStyleOptionDefinition>);
37
- /**
38
- * @inheritDoc
39
- */
40
- refresh(): void;
41
- /**
42
- * Executes the command and applies the style to the currently selected image:
43
- *
44
- * ```ts
45
- * editor.execute( 'imageStyle', { value: 'side' } );
46
- * ```
47
- *
48
- * **Note**: Executing this command may change the image model element if the desired style requires an image
49
- * of a different type. Learn more about {@link module:image/imageconfig~ImageStyleOptionDefinition#modelElements model element}
50
- * configuration for the style option.
51
- *
52
- * @param options.value The name of the style (as configured in {@link module:image/imageconfig~ImageStyleConfig#options}).
53
- * @fires execute
54
- */
55
- execute(options?: {
56
- value?: string;
57
- }): void;
58
- /**
59
- * Returns `true` if requested style change would trigger the image type change.
60
- *
61
- * @param requestedStyle The name of the style (as configured in {@link module:image/imageconfig~ImageStyleConfig#options}).
62
- * @param imageElement The image model element.
63
- */
64
- shouldConvertImageType(requestedStyle: string, imageElement: Element): boolean;
65
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module image/imagestyle/imagestylecommand
7
+ */
8
+ import type { Element } from 'ckeditor5/src/engine';
9
+ import { Command, type Editor } from 'ckeditor5/src/core';
10
+ import type { ImageStyleOptionDefinition } from '../imageconfig';
11
+ /**
12
+ * The image style command. It is used to apply {@link module:image/imageconfig~ImageStyleConfig#options image style option}
13
+ * to a selected image.
14
+ *
15
+ * **Note**: Executing this command may change the image model element if the desired style requires an image of a different
16
+ * type. See {@link module:image/imagestyle/imagestylecommand~ImageStyleCommand#execute} to learn more.
17
+ */
18
+ export default class ImageStyleCommand extends Command {
19
+ /**
20
+ * An object containing names of default style options for the inline and block images.
21
+ * If there is no default style option for the given image type in the configuration,
22
+ * the name will be `false`.
23
+ */
24
+ private _defaultStyles;
25
+ /**
26
+ * The styles handled by this command.
27
+ */
28
+ private _styles;
29
+ /**
30
+ * Creates an instance of the image style command. When executed, the command applies one of
31
+ * {@link module:image/imageconfig~ImageStyleConfig#options style options} to the currently selected image.
32
+ *
33
+ * @param editor The editor instance.
34
+ * @param styles The style options that this command supports.
35
+ */
36
+ constructor(editor: Editor, styles: Array<ImageStyleOptionDefinition>);
37
+ /**
38
+ * @inheritDoc
39
+ */
40
+ refresh(): void;
41
+ /**
42
+ * Executes the command and applies the style to the currently selected image:
43
+ *
44
+ * ```ts
45
+ * editor.execute( 'imageStyle', { value: 'side' } );
46
+ * ```
47
+ *
48
+ * **Note**: Executing this command may change the image model element if the desired style requires an image
49
+ * of a different type. Learn more about {@link module:image/imageconfig~ImageStyleOptionDefinition#modelElements model element}
50
+ * configuration for the style option.
51
+ *
52
+ * @param options.value The name of the style (as configured in {@link module:image/imageconfig~ImageStyleConfig#options}).
53
+ * @fires execute
54
+ */
55
+ execute(options?: {
56
+ value?: string;
57
+ }): void;
58
+ /**
59
+ * Returns `true` if requested style change would trigger the image type change.
60
+ *
61
+ * @param requestedStyle The name of the style (as configured in {@link module:image/imageconfig~ImageStyleConfig#options}).
62
+ * @param imageElement The image model element.
63
+ */
64
+ shouldConvertImageType(requestedStyle: string, imageElement: Element): boolean;
65
+ }