@elementor/editor-editing-panel 1.44.0 → 1.45.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.
- package/CHANGELOG.md +20 -0
- package/dist/index.js +479 -391
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +410 -320
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/components/style-sections/border-section/border-radius-field.tsx +12 -9
- package/src/components/style-sections/layout-section/align-content-field.tsx +10 -14
- package/src/components/style-sections/layout-section/align-items-field.tsx +13 -17
- package/src/components/style-sections/layout-section/align-self-child-field.tsx +13 -17
- package/src/components/style-sections/layout-section/flex-direction-field.tsx +13 -17
- package/src/components/style-sections/layout-section/flex-order-field.tsx +30 -33
- package/src/components/style-sections/layout-section/flex-size-field.tsx +60 -59
- package/src/components/style-sections/layout-section/justify-content-field.tsx +10 -14
- package/src/components/style-sections/layout-section/wrap-field.tsx +13 -17
- package/src/components/style-sections/position-section/dimensions-field.tsx +39 -21
- package/src/components/style-sections/position-section/offset-field.tsx +5 -2
- package/src/components/style-sections/size-section/size-section.tsx +51 -36
- package/src/components/style-sections/spacing-section/spacing-section.tsx +1 -1
- package/src/components/style-sections/typography-section/column-gap-field.tsx +5 -2
- package/src/components/style-sections/typography-section/font-size-field.tsx +5 -2
- package/src/components/style-sections/typography-section/letter-spacing-field.tsx +5 -2
- package/src/components/style-sections/typography-section/line-height-field.tsx +5 -2
- package/src/components/style-sections/typography-section/text-alignment-field.tsx +12 -9
- package/src/components/style-sections/typography-section/word-spacing-field.tsx +5 -2
- package/src/dynamics/components/background-control-dynamic-tag.tsx +48 -0
- package/src/dynamics/init.ts +21 -0
- package/src/styles-inheritance/components/ui-providers.tsx +18 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { type MutableRefObject, useRef } from 'react';
|
|
2
3
|
import { SizeControl } from '@elementor/editor-controls';
|
|
3
4
|
import { SideBottomIcon, SideLeftIcon, SideRightIcon, SideTopIcon } from '@elementor/icons';
|
|
4
5
|
import { Grid, Stack, withDirection } from '@elementor/ui';
|
|
@@ -6,6 +7,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
6
7
|
|
|
7
8
|
import { StylesField } from '../../../controls-registry/styles-field';
|
|
8
9
|
import { useDirection } from '../../../hooks/use-direction';
|
|
10
|
+
import { UiProviders } from '../../../styles-inheritance/components/ui-providers';
|
|
9
11
|
import { ControlLabel } from '../../control-label';
|
|
10
12
|
import { RotatedIcon } from '../layout-section/utils/rotated-icon';
|
|
11
13
|
|
|
@@ -29,31 +31,47 @@ const getInlineEndLabel = ( isSiteRtl: boolean ) =>
|
|
|
29
31
|
|
|
30
32
|
export const DimensionsField = () => {
|
|
31
33
|
const { isSiteRtl } = useDirection();
|
|
34
|
+
const rowRefs: MutableRefObject< HTMLElement | undefined >[] = [ useRef(), useRef() ];
|
|
32
35
|
|
|
33
36
|
return (
|
|
34
|
-
|
|
35
|
-
<Stack direction="row" gap={ 2 } flexWrap="nowrap">
|
|
36
|
-
<DimensionField side="inset-block-start" label={ __( 'Top', 'elementor' ) } />
|
|
37
|
-
<DimensionField
|
|
37
|
+
<UiProviders>
|
|
38
|
+
<Stack direction="row" gap={ 2 } flexWrap="nowrap" ref={ rowRefs[ 0 ] }>
|
|
39
|
+
<DimensionField side="inset-block-start" label={ __( 'Top', 'elementor' ) } rowRef={ rowRefs[ 0 ] } />
|
|
40
|
+
<DimensionField
|
|
41
|
+
side="inset-inline-end"
|
|
42
|
+
label={ getInlineEndLabel( isSiteRtl ) }
|
|
43
|
+
rowRef={ rowRefs[ 0 ] }
|
|
44
|
+
/>
|
|
38
45
|
</Stack>
|
|
39
|
-
<Stack direction="row" gap={ 2 } flexWrap="nowrap">
|
|
40
|
-
<DimensionField side="inset-block-end" label={ __( 'Bottom', 'elementor' ) } />
|
|
41
|
-
<DimensionField
|
|
46
|
+
<Stack direction="row" gap={ 2 } flexWrap="nowrap" ref={ rowRefs[ 1 ] }>
|
|
47
|
+
<DimensionField side="inset-block-end" label={ __( 'Bottom', 'elementor' ) } rowRef={ rowRefs[ 1 ] } />
|
|
48
|
+
<DimensionField
|
|
49
|
+
side="inset-inline-start"
|
|
50
|
+
label={ getInlineStartLabel( isSiteRtl ) }
|
|
51
|
+
rowRef={ rowRefs[ 1 ] }
|
|
52
|
+
/>
|
|
42
53
|
</Stack>
|
|
43
|
-
|
|
54
|
+
</UiProviders>
|
|
44
55
|
);
|
|
45
56
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
|
|
58
|
+
const DimensionField = ( {
|
|
59
|
+
side,
|
|
60
|
+
label,
|
|
61
|
+
rowRef,
|
|
62
|
+
}: {
|
|
63
|
+
side: Side;
|
|
64
|
+
label: string;
|
|
65
|
+
rowRef: MutableRefObject< HTMLElement | undefined >;
|
|
66
|
+
} ) => (
|
|
67
|
+
<StylesField bind={ side }>
|
|
68
|
+
<Grid container gap={ 0.75 } alignItems="center">
|
|
69
|
+
<Grid item xs={ 12 }>
|
|
70
|
+
<ControlLabel>{ label }</ControlLabel>
|
|
56
71
|
</Grid>
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
72
|
+
<Grid item xs={ 12 }>
|
|
73
|
+
<SizeControl startIcon={ sideIcons[ side ] } extendedOptions={ [ 'auto' ] } anchorRef={ rowRef } />
|
|
74
|
+
</Grid>
|
|
75
|
+
</Grid>
|
|
76
|
+
</StylesField>
|
|
77
|
+
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { type MutableRefObject, useRef } from 'react';
|
|
2
3
|
import { SizeControl } from '@elementor/editor-controls';
|
|
3
4
|
import { Grid } from '@elementor/ui';
|
|
4
5
|
import { __ } from '@wordpress/i18n';
|
|
@@ -7,14 +8,16 @@ import { StylesField } from '../../../controls-registry/styles-field';
|
|
|
7
8
|
import { ControlLabel } from '../../control-label';
|
|
8
9
|
|
|
9
10
|
export const OffsetField = () => {
|
|
11
|
+
const rowRef: MutableRefObject< HTMLElement | undefined > = useRef();
|
|
12
|
+
|
|
10
13
|
return (
|
|
11
14
|
<StylesField bind="scroll-margin-top">
|
|
12
|
-
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
15
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap" ref={ rowRef }>
|
|
13
16
|
<Grid item xs={ 6 }>
|
|
14
17
|
<ControlLabel>{ __( 'Anchor offset', 'elementor' ) }</ControlLabel>
|
|
15
18
|
</Grid>
|
|
16
19
|
<Grid item xs={ 6 }>
|
|
17
|
-
<SizeControl units={ [ 'px', 'em', 'rem', 'vw', 'vh' ] } />
|
|
20
|
+
<SizeControl units={ [ 'px', 'em', 'rem', 'vw', 'vh' ] } anchorRef={ rowRef } />
|
|
18
21
|
</Grid>
|
|
19
22
|
</Grid>
|
|
20
23
|
</StylesField>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { type MutableRefObject, useRef } from 'react';
|
|
3
|
+
import { AspectRatioControl, type ExtendedOption, SizeControl } from '@elementor/editor-controls';
|
|
3
4
|
import type { StringPropValue } from '@elementor/editor-props';
|
|
4
5
|
import { isExperimentActive } from '@elementor/editor-v1-adapters';
|
|
5
6
|
import { Grid, Stack } from '@elementor/ui';
|
|
@@ -15,47 +16,60 @@ import { ObjectFitField } from './object-fit-field';
|
|
|
15
16
|
import { ObjectPositionField } from './object-position-field';
|
|
16
17
|
import { OverflowField } from './overflow-field';
|
|
17
18
|
|
|
19
|
+
const EXPERIMENT_ID = 'e_v_3_30';
|
|
20
|
+
|
|
21
|
+
const CssSizeProps = [
|
|
22
|
+
[
|
|
23
|
+
{
|
|
24
|
+
bind: 'width',
|
|
25
|
+
label: __( 'Width', 'elementor' ),
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
bind: 'height',
|
|
29
|
+
label: __( 'Height', 'elementor' ),
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
[
|
|
33
|
+
{
|
|
34
|
+
bind: 'min-width',
|
|
35
|
+
label: __( 'Min width', 'elementor' ),
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
bind: 'min-height',
|
|
39
|
+
label: __( 'Min height', 'elementor' ),
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
[
|
|
43
|
+
{
|
|
44
|
+
bind: 'max-width',
|
|
45
|
+
label: __( 'Max width', 'elementor' ),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
bind: 'max-height',
|
|
49
|
+
label: __( 'Max height', 'elementor' ),
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
];
|
|
53
|
+
|
|
18
54
|
export const SizeSection = () => {
|
|
19
55
|
const [ fitValue ] = useStylesField< StringPropValue >( 'object-fit' );
|
|
20
56
|
|
|
21
57
|
const isNotFill = fitValue && fitValue?.value !== 'fill';
|
|
22
58
|
|
|
23
|
-
const
|
|
59
|
+
const gridRowRefs: MutableRefObject< HTMLElement | undefined >[] = [ useRef(), useRef(), useRef() ];
|
|
60
|
+
const isVersion330Active = isExperimentActive( EXPERIMENT_ID );
|
|
24
61
|
|
|
25
62
|
return (
|
|
26
63
|
<SectionContent>
|
|
27
|
-
|
|
28
|
-
<Grid
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
</Grid>
|
|
35
|
-
<Grid container gap={ 2 } flexWrap="nowrap">
|
|
36
|
-
<Grid item xs={ 6 }>
|
|
37
|
-
<SizeField
|
|
38
|
-
bind="min-width"
|
|
39
|
-
label={ __( 'Min width', 'elementor' ) }
|
|
40
|
-
extendedValues={ [ 'auto' ] }
|
|
41
|
-
/>
|
|
64
|
+
{ CssSizeProps.map( ( row, rowIndex ) => (
|
|
65
|
+
<Grid key={ rowIndex } container gap={ 2 } flexWrap="nowrap" ref={ gridRowRefs[ rowIndex ] }>
|
|
66
|
+
{ row.map( ( props ) => (
|
|
67
|
+
<Grid item xs={ 6 } key={ props.bind }>
|
|
68
|
+
<SizeField { ...props } rowRef={ gridRowRefs[ rowIndex ] } extendedOptions={ [ 'auto' ] } />
|
|
69
|
+
</Grid>
|
|
70
|
+
) ) }
|
|
42
71
|
</Grid>
|
|
43
|
-
|
|
44
|
-
<SizeField
|
|
45
|
-
bind="min-height"
|
|
46
|
-
label={ __( 'Min height', 'elementor' ) }
|
|
47
|
-
extendedValues={ [ 'auto' ] }
|
|
48
|
-
/>
|
|
49
|
-
</Grid>
|
|
50
|
-
</Grid>
|
|
51
|
-
<Grid container gap={ 2 } flexWrap="nowrap">
|
|
52
|
-
<Grid item xs={ 6 }>
|
|
53
|
-
<SizeField bind="max-width" label={ __( 'Max width', 'elementor' ) } />
|
|
54
|
-
</Grid>
|
|
55
|
-
<Grid item xs={ 6 }>
|
|
56
|
-
<SizeField bind="max-height" label={ __( 'Max height', 'elementor' ) } />
|
|
57
|
-
</Grid>
|
|
58
|
-
</Grid>
|
|
72
|
+
) ) }
|
|
59
73
|
<PanelDivider />
|
|
60
74
|
<Stack>
|
|
61
75
|
<OverflowField />
|
|
@@ -83,10 +97,11 @@ export const SizeSection = () => {
|
|
|
83
97
|
type ControlProps = {
|
|
84
98
|
bind: StylesFieldProps[ 'bind' ];
|
|
85
99
|
label: string;
|
|
86
|
-
|
|
100
|
+
rowRef: MutableRefObject< HTMLElement | undefined >;
|
|
101
|
+
extendedOptions?: ExtendedOption[];
|
|
87
102
|
};
|
|
88
103
|
|
|
89
|
-
const SizeField = ( { label, bind,
|
|
104
|
+
const SizeField = ( { label, bind, rowRef, extendedOptions }: ControlProps ) => {
|
|
90
105
|
return (
|
|
91
106
|
<StylesField bind={ bind }>
|
|
92
107
|
<Grid container gap={ 0.75 } alignItems="center">
|
|
@@ -94,7 +109,7 @@ const SizeField = ( { label, bind, extendedValues }: ControlProps ) => {
|
|
|
94
109
|
<ControlLabel>{ label }</ControlLabel>
|
|
95
110
|
</Grid>
|
|
96
111
|
<Grid item xs={ 12 }>
|
|
97
|
-
<SizeControl
|
|
112
|
+
<SizeControl extendedOptions={ extendedOptions } anchorRef={ rowRef } />
|
|
98
113
|
</Grid>
|
|
99
114
|
</Grid>
|
|
100
115
|
</StylesField>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { type MutableRefObject, useRef } from 'react';
|
|
2
3
|
import { SizeControl } from '@elementor/editor-controls';
|
|
3
4
|
import { Grid } from '@elementor/ui';
|
|
4
5
|
import { __ } from '@wordpress/i18n';
|
|
@@ -7,14 +8,16 @@ import { StylesField } from '../../../controls-registry/styles-field';
|
|
|
7
8
|
import { ControlLabel } from '../../control-label';
|
|
8
9
|
|
|
9
10
|
export const ColumnGapField = () => {
|
|
11
|
+
const rowRef: MutableRefObject< HTMLElement | undefined > = useRef();
|
|
12
|
+
|
|
10
13
|
return (
|
|
11
14
|
<StylesField bind="column-gap">
|
|
12
|
-
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
15
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap" ref={ rowRef }>
|
|
13
16
|
<Grid item xs={ 6 }>
|
|
14
17
|
<ControlLabel>{ __( 'Column gap', 'elementor' ) }</ControlLabel>
|
|
15
18
|
</Grid>
|
|
16
19
|
<Grid item xs={ 6 }>
|
|
17
|
-
<SizeControl />
|
|
20
|
+
<SizeControl anchorRef={ rowRef } />
|
|
18
21
|
</Grid>
|
|
19
22
|
</Grid>
|
|
20
23
|
</StylesField>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { type MutableRefObject, useRef } from 'react';
|
|
2
3
|
import { SizeControl } from '@elementor/editor-controls';
|
|
3
4
|
import { Grid } from '@elementor/ui';
|
|
4
5
|
import { __ } from '@wordpress/i18n';
|
|
@@ -7,14 +8,16 @@ import { StylesField } from '../../../controls-registry/styles-field';
|
|
|
7
8
|
import { ControlLabel } from '../../control-label';
|
|
8
9
|
|
|
9
10
|
export const FontSizeField = () => {
|
|
11
|
+
const rowRef: MutableRefObject< HTMLElement | undefined > = useRef();
|
|
12
|
+
|
|
10
13
|
return (
|
|
11
14
|
<StylesField bind="font-size">
|
|
12
|
-
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
15
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap" ref={ rowRef }>
|
|
13
16
|
<Grid item xs={ 6 }>
|
|
14
17
|
<ControlLabel>{ __( 'Font size', 'elementor' ) }</ControlLabel>
|
|
15
18
|
</Grid>
|
|
16
19
|
<Grid item xs={ 6 }>
|
|
17
|
-
<SizeControl />
|
|
20
|
+
<SizeControl anchorRef={ rowRef } />
|
|
18
21
|
</Grid>
|
|
19
22
|
</Grid>
|
|
20
23
|
</StylesField>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { type MutableRefObject, useRef } from 'react';
|
|
2
3
|
import { SizeControl } from '@elementor/editor-controls';
|
|
3
4
|
import { Grid } from '@elementor/ui';
|
|
4
5
|
import { __ } from '@wordpress/i18n';
|
|
@@ -7,14 +8,16 @@ import { StylesField } from '../../../controls-registry/styles-field';
|
|
|
7
8
|
import { ControlLabel } from '../../control-label';
|
|
8
9
|
|
|
9
10
|
export const LetterSpacingField = () => {
|
|
11
|
+
const rowRef: MutableRefObject< HTMLElement | undefined > = useRef();
|
|
12
|
+
|
|
10
13
|
return (
|
|
11
14
|
<StylesField bind="letter-spacing">
|
|
12
|
-
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
15
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap" ref={ rowRef }>
|
|
13
16
|
<Grid item xs={ 6 }>
|
|
14
17
|
<ControlLabel>{ __( 'Letter spacing', 'elementor' ) }</ControlLabel>
|
|
15
18
|
</Grid>
|
|
16
19
|
<Grid item xs={ 6 }>
|
|
17
|
-
<SizeControl />
|
|
20
|
+
<SizeControl anchorRef={ rowRef } />
|
|
18
21
|
</Grid>
|
|
19
22
|
</Grid>
|
|
20
23
|
</StylesField>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { type MutableRefObject, useRef } from 'react';
|
|
2
3
|
import { SizeControl } from '@elementor/editor-controls';
|
|
3
4
|
import { Grid } from '@elementor/ui';
|
|
4
5
|
import { __ } from '@wordpress/i18n';
|
|
@@ -7,14 +8,16 @@ import { StylesField } from '../../../controls-registry/styles-field';
|
|
|
7
8
|
import { ControlLabel } from '../../control-label';
|
|
8
9
|
|
|
9
10
|
export const LineHeightField = () => {
|
|
11
|
+
const rowRef: MutableRefObject< HTMLElement | undefined > = useRef();
|
|
12
|
+
|
|
10
13
|
return (
|
|
11
14
|
<StylesField bind="line-height">
|
|
12
|
-
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
15
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap" ref={ rowRef }>
|
|
13
16
|
<Grid item xs={ 6 }>
|
|
14
17
|
<ControlLabel>{ __( 'Line height', 'elementor' ) }</ControlLabel>
|
|
15
18
|
</Grid>
|
|
16
19
|
<Grid item xs={ 6 }>
|
|
17
|
-
<SizeControl />
|
|
20
|
+
<SizeControl anchorRef={ rowRef } />
|
|
18
21
|
</Grid>
|
|
19
22
|
</Grid>
|
|
20
23
|
</StylesField>
|
|
@@ -5,6 +5,7 @@ import { Grid, withDirection } from '@elementor/ui';
|
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
|
|
7
7
|
import { StylesField } from '../../../controls-registry/styles-field';
|
|
8
|
+
import { UiProviders } from '../../../styles-inheritance/components/ui-providers';
|
|
8
9
|
import { ControlLabel } from '../../control-label';
|
|
9
10
|
|
|
10
11
|
type Alignments = 'start' | 'center' | 'end' | 'justify';
|
|
@@ -41,15 +42,17 @@ const options: ToggleButtonGroupItem< Alignments >[] = [
|
|
|
41
42
|
|
|
42
43
|
export const TextAlignmentField = () => {
|
|
43
44
|
return (
|
|
44
|
-
<
|
|
45
|
-
<
|
|
46
|
-
<Grid
|
|
47
|
-
<
|
|
45
|
+
<UiProviders>
|
|
46
|
+
<StylesField bind={ 'text-align' }>
|
|
47
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
48
|
+
<Grid item xs={ 6 }>
|
|
49
|
+
<ControlLabel>{ __( 'Text align', 'elementor' ) }</ControlLabel>
|
|
50
|
+
</Grid>
|
|
51
|
+
<Grid item xs={ 6 } display="flex" justifyContent="end">
|
|
52
|
+
<ToggleControl options={ options } />
|
|
53
|
+
</Grid>
|
|
48
54
|
</Grid>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
</Grid>
|
|
52
|
-
</Grid>
|
|
53
|
-
</StylesField>
|
|
55
|
+
</StylesField>
|
|
56
|
+
</UiProviders>
|
|
54
57
|
);
|
|
55
58
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { type MutableRefObject, useRef } from 'react';
|
|
2
3
|
import { SizeControl } from '@elementor/editor-controls';
|
|
3
4
|
import { Grid } from '@elementor/ui';
|
|
4
5
|
import { __ } from '@wordpress/i18n';
|
|
@@ -7,14 +8,16 @@ import { StylesField } from '../../../controls-registry/styles-field';
|
|
|
7
8
|
import { ControlLabel } from '../../control-label';
|
|
8
9
|
|
|
9
10
|
export const WordSpacingField = () => {
|
|
11
|
+
const rowRef: MutableRefObject< HTMLElement | undefined > = useRef();
|
|
12
|
+
|
|
10
13
|
return (
|
|
11
14
|
<StylesField bind="word-spacing">
|
|
12
|
-
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
15
|
+
<Grid container gap={ 2 } alignItems="center" flexWrap="nowrap" ref={ rowRef }>
|
|
13
16
|
<Grid item xs={ 6 }>
|
|
14
17
|
<ControlLabel>{ __( 'Word spacing', 'elementor' ) }</ControlLabel>
|
|
15
18
|
</Grid>
|
|
16
19
|
<Grid item xs={ 6 }>
|
|
17
|
-
<SizeControl />
|
|
20
|
+
<SizeControl anchorRef={ rowRef } />
|
|
18
21
|
</Grid>
|
|
19
22
|
</Grid>
|
|
20
23
|
</StylesField>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { PropKeyProvider, PropProvider, useBoundProp } from '@elementor/editor-controls';
|
|
3
|
+
import {
|
|
4
|
+
backgroundImageOverlayPropTypeUtil,
|
|
5
|
+
type BackgroundOverlayImagePropType,
|
|
6
|
+
type BackgroundOverlayPropType,
|
|
7
|
+
type ObjectPropType,
|
|
8
|
+
type UnionPropType,
|
|
9
|
+
} from '@elementor/editor-props';
|
|
10
|
+
import { DatabaseIcon } from '@elementor/icons';
|
|
11
|
+
|
|
12
|
+
import { useDynamicTag } from '../hooks/use-dynamic-tag';
|
|
13
|
+
|
|
14
|
+
// Since this is injected, the initial prop provider does not dig into the nested structure of the value.
|
|
15
|
+
// We need to synthetically create a type that matches the expected structure of the value.
|
|
16
|
+
|
|
17
|
+
export const BackgroundControlDynamicTagIcon = () => <DatabaseIcon fontSize="tiny" />;
|
|
18
|
+
|
|
19
|
+
export const BackgroundControlDynamicTagLabel = ( { value }: { value: BackgroundOverlayPropType } ) => {
|
|
20
|
+
const context = useBoundProp( backgroundImageOverlayPropTypeUtil );
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<PropProvider { ...context } value={ value.value }>
|
|
24
|
+
<PropKeyProvider bind="image">
|
|
25
|
+
<Wrapper rawValue={ value.value } />
|
|
26
|
+
</PropKeyProvider>
|
|
27
|
+
</PropProvider>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const Wrapper = ( { rawValue }: { rawValue: BackgroundOverlayPropType[ 'value' ] } ) => {
|
|
32
|
+
const { propType } = useBoundProp< BackgroundOverlayPropType, UnionPropType >();
|
|
33
|
+
|
|
34
|
+
const imageOverlayPropType = propType.prop_types[ 'background-image-overlay' ] as ObjectPropType;
|
|
35
|
+
return (
|
|
36
|
+
<PropProvider propType={ imageOverlayPropType.shape.image } value={ rawValue } setValue={ () => void 0 }>
|
|
37
|
+
<PropKeyProvider bind="src">
|
|
38
|
+
<Content rawValue={ rawValue.image } />
|
|
39
|
+
</PropKeyProvider>
|
|
40
|
+
</PropProvider>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const Content = ( { rawValue }: { rawValue: BackgroundOverlayImagePropType } ) => {
|
|
45
|
+
const src = rawValue.value.src;
|
|
46
|
+
const dynamicTag = useDynamicTag( src.value.name || '' );
|
|
47
|
+
return <React.Fragment>{ dynamicTag?.label }</React.Fragment>;
|
|
48
|
+
};
|
package/src/dynamics/init.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { settingsTransformersRegistry, styleTransformersRegistry } from '@elementor/editor-canvas';
|
|
2
|
+
import { injectIntoRepeaterItemIcon, injectIntoRepeaterItemLabel } from '@elementor/editor-controls';
|
|
3
|
+
import { type BackgroundOverlayPropType, type PropValue } from '@elementor/editor-props';
|
|
4
|
+
import { type InjectedComponent } from '@elementor/locations';
|
|
2
5
|
|
|
3
6
|
import { registerControlReplacement } from '../control-replacement';
|
|
4
7
|
import { controlActionsMenu } from '../controls-actions';
|
|
8
|
+
import {
|
|
9
|
+
BackgroundControlDynamicTagIcon,
|
|
10
|
+
BackgroundControlDynamicTagLabel,
|
|
11
|
+
} from './components/background-control-dynamic-tag';
|
|
5
12
|
import { DynamicSelectionControl } from './components/dynamic-selection-control';
|
|
6
13
|
import { dynamicTransformer } from './dynamic-transformer';
|
|
7
14
|
import { usePropDynamicAction } from './hooks/use-prop-dynamic-action';
|
|
@@ -15,6 +22,20 @@ export const init = () => {
|
|
|
15
22
|
condition: ( { value } ) => isDynamicPropValue( value ),
|
|
16
23
|
} );
|
|
17
24
|
|
|
25
|
+
injectIntoRepeaterItemLabel( {
|
|
26
|
+
id: 'dynamic-background-image',
|
|
27
|
+
condition: ( { value } ) =>
|
|
28
|
+
isDynamicPropValue( ( value as BackgroundOverlayPropType ).value?.image?.value?.src ),
|
|
29
|
+
component: BackgroundControlDynamicTagLabel as InjectedComponent< { value: PropValue } >,
|
|
30
|
+
} );
|
|
31
|
+
|
|
32
|
+
injectIntoRepeaterItemIcon( {
|
|
33
|
+
id: 'dynamic-background-image',
|
|
34
|
+
condition: ( { value } ) =>
|
|
35
|
+
isDynamicPropValue( ( value as BackgroundOverlayPropType ).value?.image?.value?.src ),
|
|
36
|
+
component: BackgroundControlDynamicTagIcon,
|
|
37
|
+
} );
|
|
38
|
+
|
|
18
39
|
registerPopoverAction( {
|
|
19
40
|
id: 'dynamic-tags',
|
|
20
41
|
useProps: usePropDynamicAction,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DirectionProvider, ThemeProvider } from '@elementor/ui';
|
|
3
|
+
|
|
4
|
+
import { useDirection } from '../../hooks/use-direction';
|
|
5
|
+
|
|
6
|
+
interface UiProvidersProps {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const UiProviders: React.FC< UiProvidersProps > = ( { children } ) => {
|
|
11
|
+
const { isSiteRtl } = useDirection();
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<DirectionProvider rtl={ isSiteRtl }>
|
|
15
|
+
<ThemeProvider>{ children }</ThemeProvider>
|
|
16
|
+
</DirectionProvider>
|
|
17
|
+
);
|
|
18
|
+
};
|