@ckeditor/ckeditor5-image 41.3.0 → 41.4.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.
Files changed (223) hide show
  1. package/build/image.js +1 -1
  2. package/ckeditor5-metadata.json +1 -1
  3. package/dist/index-content.css +105 -0
  4. package/dist/index-editor.css +132 -0
  5. package/dist/index.css +542 -0
  6. package/dist/index.css.map +1 -0
  7. package/dist/index.js +5638 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/translations/ar.d.ts +8 -0
  10. package/dist/translations/ar.js +5 -0
  11. package/dist/translations/ast.d.ts +8 -0
  12. package/dist/translations/ast.js +5 -0
  13. package/dist/translations/az.d.ts +8 -0
  14. package/dist/translations/az.js +5 -0
  15. package/dist/translations/bg.d.ts +8 -0
  16. package/dist/translations/bg.js +5 -0
  17. package/dist/translations/bn.d.ts +8 -0
  18. package/dist/translations/bn.js +5 -0
  19. package/dist/translations/bs.d.ts +8 -0
  20. package/dist/translations/bs.js +5 -0
  21. package/dist/translations/ca.d.ts +8 -0
  22. package/dist/translations/ca.js +5 -0
  23. package/dist/translations/cs.d.ts +8 -0
  24. package/dist/translations/cs.js +5 -0
  25. package/dist/translations/da.d.ts +8 -0
  26. package/dist/translations/da.js +5 -0
  27. package/dist/translations/de-ch.d.ts +8 -0
  28. package/dist/translations/de-ch.js +5 -0
  29. package/dist/translations/de.d.ts +8 -0
  30. package/dist/translations/de.js +5 -0
  31. package/dist/translations/el.d.ts +8 -0
  32. package/dist/translations/el.js +5 -0
  33. package/dist/translations/en-au.d.ts +8 -0
  34. package/dist/translations/en-au.js +5 -0
  35. package/dist/translations/en-gb.d.ts +8 -0
  36. package/dist/translations/en-gb.js +5 -0
  37. package/dist/translations/en.d.ts +8 -0
  38. package/dist/translations/en.js +5 -0
  39. package/dist/translations/eo.d.ts +8 -0
  40. package/dist/translations/eo.js +5 -0
  41. package/dist/translations/es-co.d.ts +8 -0
  42. package/dist/translations/es-co.js +5 -0
  43. package/dist/translations/es.d.ts +8 -0
  44. package/dist/translations/es.js +5 -0
  45. package/dist/translations/et.d.ts +8 -0
  46. package/dist/translations/et.js +5 -0
  47. package/dist/translations/eu.d.ts +8 -0
  48. package/dist/translations/eu.js +5 -0
  49. package/dist/translations/fa.d.ts +8 -0
  50. package/dist/translations/fa.js +5 -0
  51. package/dist/translations/fi.d.ts +8 -0
  52. package/dist/translations/fi.js +5 -0
  53. package/dist/translations/fr.d.ts +8 -0
  54. package/dist/translations/fr.js +5 -0
  55. package/dist/translations/gl.d.ts +8 -0
  56. package/dist/translations/gl.js +5 -0
  57. package/dist/translations/he.d.ts +8 -0
  58. package/dist/translations/he.js +5 -0
  59. package/dist/translations/hi.d.ts +8 -0
  60. package/dist/translations/hi.js +5 -0
  61. package/dist/translations/hr.d.ts +8 -0
  62. package/dist/translations/hr.js +5 -0
  63. package/dist/translations/hu.d.ts +8 -0
  64. package/dist/translations/hu.js +5 -0
  65. package/dist/translations/id.d.ts +8 -0
  66. package/dist/translations/id.js +5 -0
  67. package/dist/translations/it.d.ts +8 -0
  68. package/dist/translations/it.js +5 -0
  69. package/dist/translations/ja.d.ts +8 -0
  70. package/dist/translations/ja.js +5 -0
  71. package/dist/translations/jv.d.ts +8 -0
  72. package/dist/translations/jv.js +5 -0
  73. package/dist/translations/km.d.ts +8 -0
  74. package/dist/translations/km.js +5 -0
  75. package/dist/translations/kn.d.ts +8 -0
  76. package/dist/translations/kn.js +5 -0
  77. package/dist/translations/ko.d.ts +8 -0
  78. package/dist/translations/ko.js +5 -0
  79. package/dist/translations/ku.d.ts +8 -0
  80. package/dist/translations/ku.js +5 -0
  81. package/dist/translations/lt.d.ts +8 -0
  82. package/dist/translations/lt.js +5 -0
  83. package/dist/translations/lv.d.ts +8 -0
  84. package/dist/translations/lv.js +5 -0
  85. package/dist/translations/ms.d.ts +8 -0
  86. package/dist/translations/ms.js +5 -0
  87. package/dist/translations/nb.d.ts +8 -0
  88. package/dist/translations/nb.js +5 -0
  89. package/dist/translations/ne.d.ts +8 -0
  90. package/dist/translations/ne.js +5 -0
  91. package/dist/translations/nl.d.ts +8 -0
  92. package/dist/translations/nl.js +5 -0
  93. package/dist/translations/no.d.ts +8 -0
  94. package/dist/translations/no.js +5 -0
  95. package/dist/translations/pl.d.ts +8 -0
  96. package/dist/translations/pl.js +5 -0
  97. package/dist/translations/pt-br.d.ts +8 -0
  98. package/dist/translations/pt-br.js +5 -0
  99. package/dist/translations/pt.d.ts +8 -0
  100. package/dist/translations/pt.js +5 -0
  101. package/dist/translations/ro.d.ts +8 -0
  102. package/dist/translations/ro.js +5 -0
  103. package/dist/translations/ru.d.ts +8 -0
  104. package/dist/translations/ru.js +5 -0
  105. package/dist/translations/si.d.ts +8 -0
  106. package/dist/translations/si.js +5 -0
  107. package/dist/translations/sk.d.ts +8 -0
  108. package/dist/translations/sk.js +5 -0
  109. package/dist/translations/sq.d.ts +8 -0
  110. package/dist/translations/sq.js +5 -0
  111. package/dist/translations/sr-latn.d.ts +8 -0
  112. package/dist/translations/sr-latn.js +5 -0
  113. package/dist/translations/sr.d.ts +8 -0
  114. package/dist/translations/sr.js +5 -0
  115. package/dist/translations/sv.d.ts +8 -0
  116. package/dist/translations/sv.js +5 -0
  117. package/dist/translations/th.d.ts +8 -0
  118. package/dist/translations/th.js +5 -0
  119. package/dist/translations/tk.d.ts +8 -0
  120. package/dist/translations/tk.js +5 -0
  121. package/dist/translations/tr.d.ts +8 -0
  122. package/dist/translations/tr.js +5 -0
  123. package/dist/translations/tt.d.ts +8 -0
  124. package/dist/translations/tt.js +5 -0
  125. package/dist/translations/ug.d.ts +8 -0
  126. package/dist/translations/ug.js +5 -0
  127. package/dist/translations/uk.d.ts +8 -0
  128. package/dist/translations/uk.js +5 -0
  129. package/dist/translations/ur.d.ts +8 -0
  130. package/dist/translations/ur.js +5 -0
  131. package/dist/translations/uz.d.ts +8 -0
  132. package/dist/translations/uz.js +5 -0
  133. package/dist/translations/vi.d.ts +8 -0
  134. package/dist/translations/vi.js +5 -0
  135. package/dist/translations/zh-cn.d.ts +8 -0
  136. package/dist/translations/zh-cn.js +5 -0
  137. package/dist/translations/zh.d.ts +8 -0
  138. package/dist/translations/zh.js +5 -0
  139. package/dist/types/augmentation.d.ts +61 -0
  140. package/dist/types/autoimage.d.ts +56 -0
  141. package/dist/types/image/converters.d.ts +70 -0
  142. package/dist/types/image/imageblockediting.d.ts +63 -0
  143. package/dist/types/image/imageediting.d.ts +34 -0
  144. package/dist/types/image/imageinlineediting.d.ts +64 -0
  145. package/dist/types/image/imageloadobserver.d.ts +52 -0
  146. package/dist/types/image/imageplaceholder.d.ts +43 -0
  147. package/dist/types/image/imagetypecommand.d.ts +48 -0
  148. package/dist/types/image/insertimagecommand.d.ts +70 -0
  149. package/dist/types/image/replaceimagesourcecommand.d.ts +55 -0
  150. package/dist/types/image/ui/utils.d.ts +29 -0
  151. package/dist/types/image/utils.d.ts +68 -0
  152. package/dist/types/image.d.ts +38 -0
  153. package/dist/types/imageblock.d.ts +38 -0
  154. package/dist/types/imagecaption/imagecaptionediting.d.ts +93 -0
  155. package/dist/types/imagecaption/imagecaptionui.d.ts +30 -0
  156. package/dist/types/imagecaption/imagecaptionutils.d.ts +42 -0
  157. package/dist/types/imagecaption/toggleimagecaptioncommand.d.ts +70 -0
  158. package/dist/types/imagecaption.d.ts +30 -0
  159. package/dist/types/imageconfig.d.ts +716 -0
  160. package/dist/types/imageinline.d.ts +38 -0
  161. package/dist/types/imageinsert/imageinsertui.d.ts +78 -0
  162. package/dist/types/imageinsert/imageinsertviaurlui.d.ts +48 -0
  163. package/dist/types/imageinsert/ui/imageinsertformview.d.ts +60 -0
  164. package/dist/types/imageinsert/ui/imageinserturlview.d.ts +111 -0
  165. package/dist/types/imageinsert.d.ts +37 -0
  166. package/dist/types/imageinsertviaurl.d.ts +35 -0
  167. package/dist/types/imageresize/imagecustomresizeui.d.ts +65 -0
  168. package/dist/types/imageresize/imageresizebuttons.d.ts +68 -0
  169. package/dist/types/imageresize/imageresizeediting.d.ts +45 -0
  170. package/dist/types/imageresize/imageresizehandles.d.ts +35 -0
  171. package/dist/types/imageresize/resizeimagecommand.d.ts +46 -0
  172. package/dist/types/imageresize/ui/imagecustomresizeformview.d.ts +133 -0
  173. package/dist/types/imageresize/utils/getselectedimageeditornodes.d.ts +28 -0
  174. package/dist/types/imageresize/utils/getselectedimagepossibleresizerange.d.ts +28 -0
  175. package/dist/types/imageresize/utils/getselectedimagewidthinunits.d.ts +22 -0
  176. package/dist/types/imageresize/utils/tryparsedimensionwithunit.d.ts +41 -0
  177. package/dist/types/imageresize.d.ts +32 -0
  178. package/dist/types/imagesizeattributes.d.ts +38 -0
  179. package/dist/types/imagestyle/converters.d.ts +28 -0
  180. package/dist/types/imagestyle/imagestylecommand.d.ts +72 -0
  181. package/dist/types/imagestyle/imagestyleediting.d.ts +54 -0
  182. package/dist/types/imagestyle/imagestyleui.d.ts +60 -0
  183. package/dist/types/imagestyle/utils.d.ts +105 -0
  184. package/dist/types/imagestyle.d.ts +36 -0
  185. package/dist/types/imagetextalternative/imagetextalternativecommand.d.ts +38 -0
  186. package/dist/types/imagetextalternative/imagetextalternativeediting.d.ts +32 -0
  187. package/dist/types/imagetextalternative/imagetextalternativeui.d.ts +72 -0
  188. package/dist/types/imagetextalternative/ui/textalternativeformview.d.ts +94 -0
  189. package/dist/types/imagetextalternative.d.ts +33 -0
  190. package/dist/types/imagetoolbar.d.ts +39 -0
  191. package/dist/types/imageupload/imageuploadediting.d.ts +115 -0
  192. package/dist/types/imageupload/imageuploadprogress.d.ts +46 -0
  193. package/dist/types/imageupload/imageuploadui.d.ts +34 -0
  194. package/dist/types/imageupload/uploadimagecommand.d.ts +64 -0
  195. package/dist/types/imageupload/utils.d.ts +37 -0
  196. package/dist/types/imageupload.d.ts +36 -0
  197. package/dist/types/imageutils.d.ts +129 -0
  198. package/dist/types/index.d.ts +53 -0
  199. package/dist/types/pictureediting.d.ts +92 -0
  200. package/lang/contexts.json +9 -1
  201. package/package.json +4 -3
  202. package/src/augmentation.d.ts +2 -1
  203. package/src/imageresize/imagecustomresizeui.d.ts +61 -0
  204. package/src/imageresize/imagecustomresizeui.js +168 -0
  205. package/src/imageresize/imageresizebuttons.d.ts +0 -3
  206. package/src/imageresize/imageresizebuttons.js +95 -23
  207. package/src/imageresize/imageresizeediting.js +9 -2
  208. package/src/imageresize/ui/imagecustomresizeformview.d.ts +129 -0
  209. package/src/imageresize/ui/imagecustomresizeformview.js +186 -0
  210. package/src/imageresize/utils/getselectedimageeditornodes.d.ts +24 -0
  211. package/src/imageresize/utils/getselectedimageeditornodes.js +24 -0
  212. package/src/imageresize/utils/getselectedimagepossibleresizerange.d.ts +24 -0
  213. package/src/imageresize/utils/getselectedimagepossibleresizerange.js +32 -0
  214. package/src/imageresize/utils/getselectedimagewidthinunits.d.ts +18 -0
  215. package/src/imageresize/utils/getselectedimagewidthinunits.js +41 -0
  216. package/src/imageresize/utils/tryparsedimensionwithunit.d.ts +37 -0
  217. package/src/imageresize/utils/tryparsedimensionwithunit.js +56 -0
  218. package/src/imageresize.d.ts +2 -1
  219. package/src/imageresize.js +2 -1
  220. package/src/imageupload/imageuploadediting.js +9 -0
  221. package/src/index.d.ts +1 -0
  222. package/src/index.js +1 -0
  223. package/theme/imagecustomresizeform.css +33 -0
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module image/image/imagetypecommand
11
+ */
12
+ import type { Element } from 'ckeditor5/src/engine.js';
13
+ import { Command, type Editor } from 'ckeditor5/src/core.js';
14
+ /**
15
+ * The image type command. It changes the type of a selected image, depending on the configuration.
16
+ */
17
+ export default class ImageTypeCommand extends Command {
18
+ /**
19
+ * Model element name the command converts to.
20
+ */
21
+ private readonly _modelElementName;
22
+ /**
23
+ * @inheritDoc
24
+ *
25
+ * @param modelElementName Model element name the command converts to.
26
+ */
27
+ constructor(editor: Editor, modelElementName: 'imageBlock' | 'imageInline');
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ refresh(): void;
32
+ /**
33
+ * Executes the command and changes the type of a selected image.
34
+ *
35
+ * @fires execute
36
+ * @param options.setImageSizes Specifies whether the image `width` and `height` attributes should be set automatically.
37
+ * The default is `true`.
38
+ * @returns An object containing references to old and new model image elements
39
+ * (for before and after the change) so external integrations can hook into the decorated
40
+ * `execute` event and handle this change. `null` if the type change failed.
41
+ */
42
+ execute(options?: {
43
+ setImageSizes?: boolean;
44
+ }): {
45
+ oldElement: Element;
46
+ newElement: Element;
47
+ } | null;
48
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module image/image/insertimagecommand
11
+ */
12
+ import { Command, type Editor } from 'ckeditor5/src/core.js';
13
+ import { type ArrayOrItem } from 'ckeditor5/src/utils.js';
14
+ /**
15
+ * Insert image command.
16
+ *
17
+ * The command is registered by the {@link module:image/image/imageediting~ImageEditing} plugin as `insertImage`
18
+ * and it is also available via aliased `imageInsert` name.
19
+ *
20
+ * In order to insert an image at the current selection position
21
+ * (according to the {@link module:widget/utils~findOptimalInsertionRange} algorithm),
22
+ * execute the command and specify the image source:
23
+ *
24
+ * ```ts
25
+ * editor.execute( 'insertImage', { source: 'http://url.to.the/image' } );
26
+ * ```
27
+ *
28
+ * It is also possible to insert multiple images at once:
29
+ *
30
+ * ```ts
31
+ * editor.execute( 'insertImage', {
32
+ * source: [
33
+ * 'path/to/image.jpg',
34
+ * 'path/to/other-image.jpg'
35
+ * ]
36
+ * } );
37
+ * ```
38
+ *
39
+ * If you want to take the full control over the process, you can specify individual model attributes:
40
+ *
41
+ * ```ts
42
+ * editor.execute( 'insertImage', {
43
+ * source: [
44
+ * { src: 'path/to/image.jpg', alt: 'First alt text' },
45
+ * { src: 'path/to/other-image.jpg', alt: 'Second alt text', customAttribute: 'My attribute value' }
46
+ * ]
47
+ * } );
48
+ * ```
49
+ */
50
+ export default class InsertImageCommand extends Command {
51
+ /**
52
+ * @inheritDoc
53
+ */
54
+ constructor(editor: Editor);
55
+ /**
56
+ * @inheritDoc
57
+ */
58
+ refresh(): void;
59
+ /**
60
+ * Executes the command.
61
+ *
62
+ * @fires execute
63
+ * @param options Options for the executed command.
64
+ * @param options.source The image source or an array of image sources to insert.
65
+ * See the documentation of the command to learn more about accepted formats.
66
+ */
67
+ execute(options: {
68
+ source: ArrayOrItem<string | Record<string, unknown>>;
69
+ }): void;
70
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ import { Command, type Editor } from 'ckeditor5/src/core.js';
10
+ import type { Writer, Element } from 'ckeditor5/src/engine.js';
11
+ /**
12
+ * @module image/image/replaceimagesourcecommand
13
+ */
14
+ /**
15
+ * Replace image source command.
16
+ *
17
+ * Changes image source to the one provided. Can be executed as follows:
18
+ *
19
+ * ```ts
20
+ * editor.execute( 'replaceImageSource', { source: 'http://url.to.the/image' } );
21
+ * ```
22
+ */
23
+ export default class ReplaceImageSourceCommand extends Command {
24
+ value: string | null;
25
+ constructor(editor: Editor);
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ refresh(): void;
30
+ /**
31
+ * Executes the command.
32
+ *
33
+ * @fires execute
34
+ * @param options Options for the executed command.
35
+ * @param options.source The image source to replace.
36
+ */
37
+ execute(options: {
38
+ source: string;
39
+ }): void;
40
+ /**
41
+ * Cleanup image attributes that are not relevant to the new source.
42
+ *
43
+ * Removed attributes are: 'srcset', 'sizes', 'sources', 'width', 'height', 'alt'.
44
+ *
45
+ * This method is decorated, to allow custom cleanup logic.
46
+ * For example, to remove 'myImageId' attribute after 'src' has changed:
47
+ *
48
+ * ```ts
49
+ * replaceImageSourceCommand.on( 'cleanupImage', ( eventInfo, [ writer, image ] ) => {
50
+ * writer.removeAttribute( 'myImageId', image );
51
+ * } );
52
+ * ```
53
+ */
54
+ cleanupImage(writer: Writer, image: Element): void;
55
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module image/image/ui/utils
11
+ */
12
+ import type { PositionOptions } from 'ckeditor5/src/utils.js';
13
+ import type { Editor } from 'ckeditor5/src/core.js';
14
+ /**
15
+ * A helper utility that positions the
16
+ * {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon} instance
17
+ * with respect to the image in the editor content, if one is selected.
18
+ *
19
+ * @param editor The editor instance.
20
+ */
21
+ export declare function repositionContextualBalloon(editor: Editor): void;
22
+ /**
23
+ * Returns the positioning options that control the geometry of the
24
+ * {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon} with respect
25
+ * to the selected element in the editor content.
26
+ *
27
+ * @param editor The editor instance.
28
+ */
29
+ export declare function getBalloonPositionData(editor: Editor): Partial<PositionOptions>;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module image/image/utils
11
+ */
12
+ import type { DocumentSelection, MatcherPattern, Schema, Selection, ViewContainerElement, DowncastWriter, ViewElement } from 'ckeditor5/src/engine.js';
13
+ import type { Editor } from 'ckeditor5/src/core.js';
14
+ /**
15
+ * Creates a view element representing the inline image.
16
+ *
17
+ * ```html
18
+ * <span class="image-inline"><img></img></span>
19
+ * ```
20
+ *
21
+ * Note that `alt` and `src` attributes are converted separately, so they are not included.
22
+ *
23
+ * @internal
24
+ */
25
+ export declare function createInlineImageViewElement(writer: DowncastWriter): ViewContainerElement;
26
+ /**
27
+ * Creates a view element representing the block image.
28
+ *
29
+ * ```html
30
+ * <figure class="image"><img></img></figure>
31
+ * ```
32
+ *
33
+ * Note that `alt` and `src` attributes are converted separately, so they are not included.
34
+ *
35
+ * @internal
36
+ */
37
+ export declare function createBlockImageViewElement(writer: DowncastWriter): ViewContainerElement;
38
+ /**
39
+ * A function returning a `MatcherPattern` for a particular type of View images.
40
+ *
41
+ * @internal
42
+ * @param matchImageType The type of created image.
43
+ */
44
+ export declare function getImgViewElementMatcher(editor: Editor, matchImageType: 'imageBlock' | 'imageInline'): MatcherPattern;
45
+ /**
46
+ * Considering the current model selection, it returns the name of the model image element
47
+ * (`'imageBlock'` or `'imageInline'`) that will make most sense from the UX perspective if a new
48
+ * image was inserted (also: uploaded, dropped, pasted) at that selection.
49
+ *
50
+ * The assumption is that inserting images into empty blocks or on other block widgets should
51
+ * produce block images. Inline images should be inserted in other cases, e.g. in paragraphs
52
+ * that already contain some text.
53
+ *
54
+ * @internal
55
+ */
56
+ export declare function determineImageTypeForInsertionAtSelection(schema: Schema, selection: Selection | DocumentSelection): 'imageBlock' | 'imageInline';
57
+ /**
58
+ * Returns parsed value of the size, but only if it contains unit: px.
59
+ */
60
+ export declare function getSizeValueIfInPx(size: string | undefined): number | null;
61
+ /**
62
+ * Returns true if both styles (width and height) are set.
63
+ *
64
+ * If both image styles: width & height are set, they will override the image width & height attributes in the
65
+ * browser. In this case, the image looks the same as if these styles were applied to attributes instead of styles.
66
+ * That's why we can upcast these styles to width & height attributes instead of resizedWidth and resizedHeight.
67
+ */
68
+ export declare function widthAndHeightStylesAreBothSet(viewElement: ViewElement): boolean;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module image/image
11
+ */
12
+ import { Plugin } from 'ckeditor5/src/core.js';
13
+ import ImageBlock from './imageblock.js';
14
+ import ImageInline from './imageinline.js';
15
+ import '../theme/image.css';
16
+ /**
17
+ * The image plugin.
18
+ *
19
+ * For a detailed overview, check the {@glink features/images/images-overview image feature} documentation.
20
+ *
21
+ * This is a "glue" plugin which loads the following plugins:
22
+ *
23
+ * * {@link module:image/imageblock~ImageBlock},
24
+ * * {@link module:image/imageinline~ImageInline},
25
+ *
26
+ * Usually, it is used in conjunction with other plugins from this package. See the {@glink api/image package page}
27
+ * for more information.
28
+ */
29
+ export default class Image extends Plugin {
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ static get requires(): readonly [typeof ImageBlock, typeof ImageInline];
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ static get pluginName(): "Image";
38
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module image/imageblock
11
+ */
12
+ import { Plugin } from 'ckeditor5/src/core.js';
13
+ import { Widget } from 'ckeditor5/src/widget.js';
14
+ import ImageTextAlternative from './imagetextalternative.js';
15
+ import ImageBlockEditing from './image/imageblockediting.js';
16
+ import ImageInsertUI from './imageinsert/imageinsertui.js';
17
+ import '../theme/image.css';
18
+ /**
19
+ * The image block plugin.
20
+ *
21
+ * This is a "glue" plugin which loads the following plugins:
22
+ *
23
+ * * {@link module:image/image/imageblockediting~ImageBlockEditing},
24
+ * * {@link module:image/imagetextalternative~ImageTextAlternative}.
25
+ *
26
+ * Usually, it is used in conjunction with other plugins from this package. See the {@glink api/image package page}
27
+ * for more information.
28
+ */
29
+ export default class ImageBlock extends Plugin {
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ static get requires(): readonly [typeof ImageBlockEditing, typeof Widget, typeof ImageTextAlternative, typeof ImageInsertUI];
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ static get pluginName(): "ImageBlock";
38
+ }
@@ -0,0 +1,93 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module image/imagecaption/imagecaptionediting
11
+ */
12
+ import { type Editor, Plugin } from 'ckeditor5/src/core.js';
13
+ import { Element } from 'ckeditor5/src/engine.js';
14
+ import ImageUtils from '../imageutils.js';
15
+ import ImageCaptionUtils from './imagecaptionutils.js';
16
+ /**
17
+ * The image caption engine plugin. It is responsible for:
18
+ *
19
+ * * registering converters for the caption element,
20
+ * * registering converters for the caption model attribute,
21
+ * * registering the {@link module:image/imagecaption/toggleimagecaptioncommand~ToggleImageCaptionCommand `toggleImageCaption`} command.
22
+ */
23
+ export default class ImageCaptionEditing extends Plugin {
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ static get requires(): readonly [typeof ImageUtils, typeof ImageCaptionUtils];
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ static get pluginName(): "ImageCaptionEditing";
32
+ /**
33
+ * A map that keeps saved JSONified image captions and image model elements they are
34
+ * associated with.
35
+ *
36
+ * To learn more about this system, see {@link #_saveCaption}.
37
+ */
38
+ private _savedCaptionsMap;
39
+ /**
40
+ * @inheritDoc
41
+ */
42
+ constructor(editor: Editor);
43
+ /**
44
+ * @inheritDoc
45
+ */
46
+ init(): void;
47
+ /**
48
+ * Configures conversion pipelines to support upcasting and downcasting
49
+ * image captions.
50
+ */
51
+ private _setupConversion;
52
+ /**
53
+ * Integrates with {@link module:image/image/imagetypecommand~ImageTypeCommand image type commands}
54
+ * to make sure the caption is preserved when the type of an image changes so it can be restored
55
+ * in the future if the user decides they want their caption back.
56
+ */
57
+ private _setupImageTypeCommandsIntegration;
58
+ /**
59
+ * Returns the saved {@link module:engine/model/element~Element#toJSON JSONified} caption
60
+ * of an image model element.
61
+ *
62
+ * See {@link #_saveCaption}.
63
+ *
64
+ * @internal
65
+ * @param imageModelElement The model element the caption should be returned for.
66
+ * @returns The model caption element or `null` if there is none.
67
+ */
68
+ _getSavedCaption(imageModelElement: Element): Element | null;
69
+ /**
70
+ * Saves a {@link module:engine/model/element~Element#toJSON JSONified} caption for
71
+ * an image element to allow restoring it in the future.
72
+ *
73
+ * A caption is saved every time it gets hidden and/or the type of an image changes. The
74
+ * user should be able to restore it on demand.
75
+ *
76
+ * **Note**: The caption cannot be stored in the image model element attribute because,
77
+ * for instance, when the model state propagates to collaborators, the attribute would get
78
+ * lost (mainly because it does not convert to anything when the caption is hidden) and
79
+ * the states of collaborators' models would de-synchronize causing numerous issues.
80
+ *
81
+ * See {@link #_getSavedCaption}.
82
+ *
83
+ * @internal
84
+ * @param imageModelElement The model element the caption is saved for.
85
+ * @param caption The caption model element to be saved.
86
+ */
87
+ _saveCaption(imageModelElement: Element, caption: Element): void;
88
+ /**
89
+ * Reconverts image caption when image alt attribute changes.
90
+ * The change of alt attribute is reflected in caption's aria-label attribute.
91
+ */
92
+ private _registerCaptionReconversion;
93
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module image/imagecaption/imagecaptionui
11
+ */
12
+ import { Plugin } from 'ckeditor5/src/core.js';
13
+ import ImageCaptionUtils from './imagecaptionutils.js';
14
+ /**
15
+ * The image caption UI plugin. It introduces the `'toggleImageCaption'` UI button.
16
+ */
17
+ export default class ImageCaptionUI extends Plugin {
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ static get requires(): readonly [typeof ImageCaptionUtils];
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ static get pluginName(): "ImageCaptionUI";
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ init(): void;
30
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module image/imagecaption/imagecaptionutils
11
+ */
12
+ import type { DocumentSelection, Element, Selection, ViewElement, Match } from 'ckeditor5/src/engine.js';
13
+ import { Plugin } from 'ckeditor5/src/core.js';
14
+ import ImageUtils from '../imageutils.js';
15
+ /**
16
+ * The image caption utilities plugin.
17
+ */
18
+ export default class ImageCaptionUtils extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get pluginName(): "ImageCaptionUtils";
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get requires(): readonly [typeof ImageUtils];
27
+ /**
28
+ * Returns the caption model element from a given image element. Returns `null` if no caption is found.
29
+ */
30
+ getCaptionFromImageModelElement(imageModelElement: Element): Element | null;
31
+ /**
32
+ * Returns the caption model element for a model selection. Returns `null` if the selection has no caption element ancestor.
33
+ */
34
+ getCaptionFromModelSelection(selection: Selection | DocumentSelection): Element | null;
35
+ /**
36
+ * {@link module:engine/view/matcher~Matcher} pattern. Checks if a given element is a `<figcaption>` element that is placed
37
+ * inside the image `<figure>` element.
38
+ * @returns Returns the object accepted by {@link module:engine/view/matcher~Matcher} or `null` if the element
39
+ * cannot be matched.
40
+ */
41
+ matchImageCaptionViewElement(element: ViewElement): Match | null;
42
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ import { Command } from 'ckeditor5/src/core.js';
10
+ /**
11
+ * The toggle image caption command.
12
+ *
13
+ * This command is registered by {@link module:image/imagecaption/imagecaptionediting~ImageCaptionEditing} as the
14
+ * `'toggleImageCaption'` editor command.
15
+ *
16
+ * Executing this command:
17
+ *
18
+ * * either adds or removes the image caption of a selected image (depending on whether the caption is present or not),
19
+ * * removes the image caption if the selection is anchored in one.
20
+ *
21
+ * ```ts
22
+ * // Toggle the presence of the caption.
23
+ * editor.execute( 'toggleImageCaption' );
24
+ * ```
25
+ *
26
+ * **Note**: Upon executing this command, the selection will be set on the image if previously anchored in the caption element.
27
+ *
28
+ * **Note**: You can move the selection to the caption right away as it shows up upon executing this command by using
29
+ * the `focusCaptionOnShow` option:
30
+ *
31
+ * ```ts
32
+ * editor.execute( 'toggleImageCaption', { focusCaptionOnShow: true } );
33
+ * ```
34
+ */
35
+ export default class ToggleImageCaptionCommand extends Command {
36
+ value: boolean;
37
+ /**
38
+ * @inheritDoc
39
+ */
40
+ refresh(): void;
41
+ /**
42
+ * Executes the command.
43
+ *
44
+ * ```ts
45
+ * editor.execute( 'toggleImageCaption' );
46
+ * ```
47
+ *
48
+ * @param options Options for the executed command.
49
+ * @param options.focusCaptionOnShow When true and the caption shows up, the selection will be moved into it straight away.
50
+ * @fires execute
51
+ */
52
+ execute(options?: {
53
+ focusCaptionOnShow?: boolean;
54
+ }): void;
55
+ /**
56
+ * Shows the caption of the `<imageBlock>` or `<imageInline>`. Also:
57
+ *
58
+ * * it converts `<imageInline>` to `<imageBlock>` to show the caption,
59
+ * * it attempts to restore the caption content from the `ImageCaptionEditing` caption registry,
60
+ * * it moves the selection to the caption right away, it the `focusCaptionOnShow` option was set.
61
+ */
62
+ private _showImageCaption;
63
+ /**
64
+ * Hides the caption of a selected image (or an image caption the selection is anchored to).
65
+ *
66
+ * The content of the caption is stored in the `ImageCaptionEditing` caption registry to make this
67
+ * a reversible action.
68
+ */
69
+ private _hideImageCaption;
70
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
+ */
9
+ /**
10
+ * @module image/imagecaption
11
+ */
12
+ import { Plugin } from 'ckeditor5/src/core.js';
13
+ import ImageCaptionEditing from './imagecaption/imagecaptionediting.js';
14
+ import ImageCaptionUI from './imagecaption/imagecaptionui.js';
15
+ import '../theme/imagecaption.css';
16
+ /**
17
+ * The image caption plugin.
18
+ *
19
+ * For a detailed overview, check the {@glink features/images/images-captions image caption} documentation.
20
+ */
21
+ export default class ImageCaption extends Plugin {
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ static get requires(): readonly [typeof ImageCaptionEditing, typeof ImageCaptionUI];
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ static get pluginName(): "ImageCaption";
30
+ }