@ckeditor/ckeditor5-image 32.0.0 → 34.1.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.
@@ -1,63 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2022, 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
- /**
7
- * @module image/imagecaption/utils
8
- */
9
-
10
- /**
11
- * Returns the caption model element from a given image element. Returns `null` if no caption is found.
12
- *
13
- * @param {module:engine/model/element~Element} imageModelElement
14
- * @returns {module:engine/model/element~Element|null}
15
- */
16
- export function getCaptionFromImageModelElement( imageModelElement ) {
17
- for ( const node of imageModelElement.getChildren() ) {
18
- if ( !!node && node.is( 'element', 'caption' ) ) {
19
- return node;
20
- }
21
- }
22
-
23
- return null;
24
- }
25
-
26
- /**
27
- * Returns the caption model element for a model selection. Returns `null` if the selection has no caption element ancestor.
28
- *
29
- * @param {module:image/imageutils~ImageUtils} imageUtils
30
- * @param {module:engine/model/selection~Selection} selection
31
- * @returns {module:engine/model/element~Element|null}
32
- */
33
- export function getCaptionFromModelSelection( imageUtils, selection ) {
34
- const captionElement = selection.getFirstPosition().findAncestor( 'caption' );
35
-
36
- if ( !captionElement ) {
37
- return null;
38
- }
39
-
40
- if ( imageUtils.isBlockImage( captionElement.parent ) ) {
41
- return captionElement;
42
- }
43
-
44
- return null;
45
- }
46
-
47
- /**
48
- * {@link module:engine/view/matcher~Matcher} pattern. Checks if a given element is a `<figcaption>` element that is placed
49
- * inside the image `<figure>` element.
50
- *
51
- * @param {module:image/imageutils~ImageUtils} imageUtils
52
- * @param {module:engine/view/element~Element} element
53
- * @returns {Object|null} Returns the object accepted by {@link module:engine/view/matcher~Matcher} or `null` if the element
54
- * cannot be matched.
55
- */
56
- export function matchImageCaptionViewElement( imageUtils, element ) {
57
- // Convert only captions for images.
58
- if ( element.name == 'figcaption' && imageUtils.isBlockImageView( element.parent ) ) {
59
- return { name: true };
60
- }
61
-
62
- return null;
63
- }