@@ -8,40 +8,46 @@ export class ReplaceMediaOption extends BaseOptionComponent {
8
8
this . state = useDomState ( ( editingElement ) => ( {
9
9
canSetLink : this . canSetLink ( editingElement ) ,
10
10
hasHref : this . hasHref ( editingElement ) ,
11
+ isProductPageImage : isProductPageImage ( editingElement ) ,
11
12
} ) ) ;
12
13
}
13
14
canSetLink ( editingElement ) {
14
15
return (
15
- this . isImageSupportedForStyle ( editingElement ) &&
16
+ isImageSupportedForStyle ( editingElement ) &&
16
17
! searchSupportedParentLinkEl ( editingElement ) . matches ( "a[data-oe-xpath]" )
17
18
) ;
18
19
}
19
20
hasHref ( editingElement ) {
20
21
const parentEl = searchSupportedParentLinkEl ( editingElement ) ;
21
22
return parentEl . tagName === "A" && parentEl . hasAttribute ( "href" ) ;
22
23
}
23
- isImageSupportedForStyle ( img ) {
24
- if ( ! img . parentElement ) {
25
- return false ;
26
- }
24
+ }
27
25
28
- // See also `[data-oe-type='image'] > img` added as data-exclude of some
29
- // snippet options.
30
- const isTFieldImg = "oeType" in img . parentElement . dataset ;
26
+ export function isImageSupportedForStyle ( img ) {
27
+ if ( ! img . parentElement ) {
28
+ return false ;
29
+ }
31
30
32
- // Editable root elements are technically *potentially* supported here (if
33
- // the edited attributes are not computed inside the related view, they
34
- // could technically be saved... but as we cannot tell the computed ones
35
- // apart from the "static" ones, we choose to not support edition at all in
36
- // those "root" cases).
37
- // See also `[data-oe-xpath]` added as data-exclude of some snippet options.
38
- const isEditableRootElement = "oeXpath" in img . dataset ;
31
+ // See also `[data-oe-type='image'] > img` added as data-exclude of some
32
+ // snippet options.
33
+ const isTFieldImg = "oeType" in img . parentElement . dataset ;
39
34
40
- return ! isTFieldImg && ! isEditableRootElement ;
41
- }
35
+ // Editable root elements are technically *potentially* supported here (if
36
+ // the edited attributes are not computed inside the related view, they
37
+ // could technically be saved... but as we cannot tell the computed ones
38
+ // apart from the "static" ones, we choose to not support edition at all in
39
+ // those "root" cases).
40
+ // See also `[data-oe-xpath]` added as data-exclude of some snippet options.
41
+ const isEditableRootElement = "oeXpath" in img . dataset ;
42
+
43
+ return ! isTFieldImg && ! isEditableRootElement ;
42
44
}
43
45
44
46
export function searchSupportedParentLinkEl ( editingElement ) {
45
47
const parentEl = editingElement . parentElement ;
46
48
return parentEl . matches ( "figure" ) ? parentEl . parentElement : parentEl ;
47
49
}
50
+
51
+ export function isProductPageImage ( editingElement ) {
52
+ return ! ! editingElement . closest ( ".o_wsale_product_images" ) ;
53
+ }
0 commit comments