@elementor/editor-editing-panel 1.35.0 → 1.37.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 +29 -0
- package/dist/index.js +472 -394
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +377 -299
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
- package/src/components/creatable-autocomplete/creatable-autocomplete.tsx +27 -15
- package/src/components/creatable-autocomplete/use-autocomplete-states.ts +15 -1
- package/src/components/css-classes/css-class-item.tsx +4 -1
- package/src/components/css-classes/css-class-selector.tsx +58 -44
- package/src/components/style-sections/layout-section/display-field.tsx +1 -1
- package/src/components/style-sections/position-section/position-section.tsx +1 -1
- package/src/components/style-sections/size-section/object-fit-field.tsx +34 -0
- package/src/components/style-sections/size-section/object-position-field.tsx +38 -0
- package/src/components/style-sections/size-section/size-section.tsx +26 -0
- package/src/hooks/use-state-by-element.ts +3 -1
- package/src/styles-inheritance/styles-inheritance-indicator.tsx +1 -1
- package/src/sync/get-elementor-globals.ts +0 -6
- package/src/sync/is-experiment-active.ts +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-editing-panel",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.37.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,18 +39,18 @@
|
|
|
39
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@elementor/editor": "0.19.
|
|
43
|
-
"@elementor/editor-canvas": "0.21.
|
|
44
|
-
"@elementor/editor-controls": "0.30.
|
|
42
|
+
"@elementor/editor": "0.19.3",
|
|
43
|
+
"@elementor/editor-canvas": "0.21.3",
|
|
44
|
+
"@elementor/editor-controls": "0.30.1",
|
|
45
45
|
"@elementor/editor-current-user": "0.3.2",
|
|
46
|
-
"@elementor/editor-elements": "0.8.
|
|
47
|
-
"@elementor/editor-panels": "0.15.
|
|
46
|
+
"@elementor/editor-elements": "0.8.3",
|
|
47
|
+
"@elementor/editor-panels": "0.15.3",
|
|
48
48
|
"@elementor/editor-props": "0.12.0",
|
|
49
|
-
"@elementor/editor-responsive": "0.13.
|
|
50
|
-
"@elementor/editor-styles": "0.6.
|
|
51
|
-
"@elementor/editor-styles-repository": "0.8.
|
|
52
|
-
"@elementor/editor-ui": "0.8.
|
|
53
|
-
"@elementor/editor-v1-adapters": "0.
|
|
49
|
+
"@elementor/editor-responsive": "0.13.5",
|
|
50
|
+
"@elementor/editor-styles": "0.6.7",
|
|
51
|
+
"@elementor/editor-styles-repository": "0.8.8",
|
|
52
|
+
"@elementor/editor-ui": "0.8.2",
|
|
53
|
+
"@elementor/editor-v1-adapters": "0.12.0",
|
|
54
54
|
"@elementor/icons": "1.40.1",
|
|
55
55
|
"@elementor/locations": "0.8.0",
|
|
56
56
|
"@elementor/menus": "0.1.5",
|
|
@@ -19,17 +19,28 @@ import { useInputState, useOpenState } from './use-autocomplete-states';
|
|
|
19
19
|
import { useCreateOption } from './use-create-option';
|
|
20
20
|
import { useFilterOptions } from './use-filter-options';
|
|
21
21
|
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
export const CreatableAutocomplete = React.forwardRef( CreatableAutocompleteInner ) as <
|
|
23
|
+
TOption extends SafeOptionConstraint,
|
|
24
|
+
>(
|
|
25
|
+
props: CreatableAutocompleteProps< TOption > & {
|
|
26
|
+
ref?: React.ForwardedRef< HTMLElement >;
|
|
27
|
+
}
|
|
28
|
+
) => ReturnType< typeof CreatableAutocompleteInner >;
|
|
29
|
+
|
|
30
|
+
function CreatableAutocompleteInner< TOption extends SafeOptionConstraint >(
|
|
31
|
+
{
|
|
32
|
+
selected,
|
|
33
|
+
options,
|
|
34
|
+
entityName,
|
|
35
|
+
onSelect,
|
|
36
|
+
placeholder,
|
|
37
|
+
onCreate,
|
|
38
|
+
validate,
|
|
39
|
+
...props
|
|
40
|
+
}: CreatableAutocompleteProps< TOption >,
|
|
41
|
+
ref: React.ForwardedRef< HTMLElement >
|
|
42
|
+
) {
|
|
43
|
+
const { inputValue, setInputValue, error, setError, inputHandlers } = useInputState( validate );
|
|
33
44
|
const { open, openDropdown, closeDropdown } = useOpenState( props.open );
|
|
34
45
|
const { createOption, loading } = useCreateOption( { onCreate, validate, setInputValue, setError, closeDropdown } );
|
|
35
46
|
|
|
@@ -60,6 +71,7 @@ export function CreatableAutocomplete< TOption extends SafeOptionConstraint >( {
|
|
|
60
71
|
) );
|
|
61
72
|
} }
|
|
62
73
|
{ ...( props as AutocompleteProps< InternalOption< TOption >, true, true, true > ) }
|
|
74
|
+
ref={ ref }
|
|
63
75
|
freeSolo
|
|
64
76
|
multiple
|
|
65
77
|
clearOnBlur
|
|
@@ -75,8 +87,8 @@ export function CreatableAutocomplete< TOption extends SafeOptionConstraint >( {
|
|
|
75
87
|
options={ internalOptions }
|
|
76
88
|
ListboxComponent={
|
|
77
89
|
error
|
|
78
|
-
? React.forwardRef< HTMLElement, ErrorTextProps >( ( _,
|
|
79
|
-
<ErrorText ref={
|
|
90
|
+
? React.forwardRef< HTMLElement, ErrorTextProps >( ( _, errorTextRef ) => (
|
|
91
|
+
<ErrorText ref={ errorTextRef } error={ error } />
|
|
80
92
|
) )
|
|
81
93
|
: undefined
|
|
82
94
|
}
|
|
@@ -88,7 +100,7 @@ export function CreatableAutocomplete< TOption extends SafeOptionConstraint >( {
|
|
|
88
100
|
{ ...params }
|
|
89
101
|
placeholder={ placeholder }
|
|
90
102
|
error={ Boolean( error ) }
|
|
91
|
-
|
|
103
|
+
{ ...inputHandlers }
|
|
92
104
|
sx={ ( theme: Theme ) => ( {
|
|
93
105
|
'.MuiAutocomplete-inputRoot.MuiInputBase-adornedStart': {
|
|
94
106
|
paddingLeft: theme.spacing( 0.25 ),
|
|
@@ -149,7 +161,7 @@ const ErrorText = React.forwardRef< HTMLElement, ErrorTextProps >( ( { error = '
|
|
|
149
161
|
padding: theme.spacing( 2 ),
|
|
150
162
|
} ) }
|
|
151
163
|
>
|
|
152
|
-
<Typography variant="caption" sx={ { color: 'error.main' } }>
|
|
164
|
+
<Typography variant="caption" sx={ { color: 'error.main', display: 'inline-block' } }>
|
|
153
165
|
{ error }
|
|
154
166
|
</Typography>
|
|
155
167
|
</Box>
|
|
@@ -29,7 +29,21 @@ export function useInputState( validate?: ( value: string, event: ValidationEven
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
const handleInputBlur = () => {
|
|
33
|
+
setInputValue( '' );
|
|
34
|
+
setError( null );
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
inputValue,
|
|
39
|
+
setInputValue,
|
|
40
|
+
error,
|
|
41
|
+
setError,
|
|
42
|
+
inputHandlers: {
|
|
43
|
+
onChange: handleInputChange,
|
|
44
|
+
onBlur: handleInputBlur,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
33
47
|
}
|
|
34
48
|
|
|
35
49
|
export function useOpenState( initialOpen: boolean = false ) {
|
|
@@ -30,6 +30,7 @@ type CssClassItemProps = {
|
|
|
30
30
|
onClickActive: ( id: string | null ) => void;
|
|
31
31
|
renameLabel: ( newLabel: string ) => void;
|
|
32
32
|
validateLabel?: ( newLabel: string ) => string | undefined | null;
|
|
33
|
+
setError?: ( error: string | null ) => void;
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
const CHIP_SIZE = 'tiny';
|
|
@@ -44,6 +45,7 @@ export function CssClassItem( {
|
|
|
44
45
|
chipProps,
|
|
45
46
|
onClickActive,
|
|
46
47
|
renameLabel,
|
|
48
|
+
setError,
|
|
47
49
|
}: CssClassItemProps ) {
|
|
48
50
|
const { meta, setMetaState } = useStyle();
|
|
49
51
|
const popupState = usePopupState( { variant: 'popover' } );
|
|
@@ -60,6 +62,7 @@ export function CssClassItem( {
|
|
|
60
62
|
value: label,
|
|
61
63
|
onSubmit: renameLabel,
|
|
62
64
|
validation: validateLabel,
|
|
65
|
+
onError: setError,
|
|
63
66
|
} );
|
|
64
67
|
|
|
65
68
|
const color = error ? 'error' : colorProp;
|
|
@@ -84,7 +87,7 @@ export function CssClassItem( {
|
|
|
84
87
|
size={ CHIP_SIZE }
|
|
85
88
|
label={
|
|
86
89
|
isEditing ? (
|
|
87
|
-
<EditableField ref={ ref }
|
|
90
|
+
<EditableField ref={ ref } { ...getEditableProps() } />
|
|
88
91
|
) : (
|
|
89
92
|
<EllipsisWithTooltip maxWidth="10ch" title={ label } as="div" />
|
|
90
93
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { type ReactElement } from 'react';
|
|
2
|
+
import { type ReactElement, useRef, useState } from 'react';
|
|
3
3
|
import { getElementSetting, updateElementSettings, useElementSetting } from '@elementor/editor-elements';
|
|
4
4
|
import { classesPropTypeUtil, type ClassesPropValue } from '@elementor/editor-props';
|
|
5
5
|
import { type StyleDefinitionID } from '@elementor/editor-styles';
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
useProviders,
|
|
13
13
|
validateStyleLabel,
|
|
14
14
|
} from '@elementor/editor-styles-repository';
|
|
15
|
+
import { WarningInfotip } from '@elementor/editor-ui';
|
|
15
16
|
import { MapPinIcon } from '@elementor/icons';
|
|
16
17
|
import { createLocation } from '@elementor/locations';
|
|
17
18
|
import { Chip, FormLabel, Stack } from '@elementor/ui';
|
|
@@ -60,6 +61,9 @@ export function CssClassSelector() {
|
|
|
60
61
|
const { value: appliedIds, setValue: setAppliedIds, pushValue: pushAppliedId } = useAppliedClassesIds();
|
|
61
62
|
const { id: activeId, setId: setActiveId } = useStyle();
|
|
62
63
|
|
|
64
|
+
const autocompleteRef = useRef< HTMLElement | null >( null );
|
|
65
|
+
const [ renameError, setRenameError ] = useState< string | null >( null );
|
|
66
|
+
|
|
63
67
|
const handleApply = useHandleApply( appliedIds, setAppliedIds );
|
|
64
68
|
const { create, validate, entityName } = useCreateAction( { pushAppliedId, setActiveId } );
|
|
65
69
|
|
|
@@ -78,49 +82,59 @@ export function CssClassSelector() {
|
|
|
78
82
|
<ClassSelectorActionsSlot />
|
|
79
83
|
</Stack>
|
|
80
84
|
</Stack>
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
85
|
+
<WarningInfotip
|
|
86
|
+
open={ Boolean( renameError ) }
|
|
87
|
+
text={ renameError ?? '' }
|
|
88
|
+
placement="bottom"
|
|
89
|
+
width={ autocompleteRef.current?.getBoundingClientRect().width }
|
|
90
|
+
offset={ [ 0, -15 ] }
|
|
91
|
+
>
|
|
92
|
+
<CreatableAutocomplete< StyleDefOption >
|
|
93
|
+
id={ ID }
|
|
94
|
+
ref={ autocompleteRef }
|
|
95
|
+
size="tiny"
|
|
96
|
+
placeholder={ showPlaceholder ? __( 'Type class name', 'elementor' ) : undefined }
|
|
97
|
+
options={ options }
|
|
98
|
+
selected={ applied }
|
|
99
|
+
entityName={ entityName }
|
|
100
|
+
onSelect={ handleApply }
|
|
101
|
+
onCreate={ create ?? undefined }
|
|
102
|
+
validate={ validate ?? undefined }
|
|
103
|
+
limitTags={ TAGS_LIMIT }
|
|
104
|
+
getLimitTagsText={ ( more ) => (
|
|
105
|
+
<Chip size="tiny" variant="standard" label={ `+${ more }` } clickable />
|
|
106
|
+
) }
|
|
107
|
+
renderTags={ ( values, getTagProps ) =>
|
|
108
|
+
values.map( ( value, index ) => {
|
|
109
|
+
const chipProps = getTagProps( { index } );
|
|
110
|
+
const isActive = value.value === active?.value;
|
|
111
|
+
|
|
112
|
+
const renameLabel = ( newLabel: string ) => {
|
|
113
|
+
if ( ! value.value ) {
|
|
114
|
+
throw new Error( `Cannot rename a class without style id` );
|
|
115
|
+
}
|
|
116
|
+
return updateClassByProvider( value.provider, { label: newLabel, id: value.value } );
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<CssClassItem
|
|
121
|
+
key={ chipProps.key }
|
|
122
|
+
label={ value.label }
|
|
123
|
+
provider={ value.provider }
|
|
124
|
+
id={ value.value }
|
|
125
|
+
isActive={ isActive }
|
|
126
|
+
color={ isActive && value.color ? value.color : 'default' }
|
|
127
|
+
icon={ value.icon }
|
|
128
|
+
chipProps={ chipProps }
|
|
129
|
+
onClickActive={ () => setActiveId( value.value ) }
|
|
130
|
+
renameLabel={ renameLabel }
|
|
131
|
+
setError={ setRenameError }
|
|
132
|
+
/>
|
|
133
|
+
);
|
|
134
|
+
} )
|
|
135
|
+
}
|
|
136
|
+
/>
|
|
137
|
+
</WarningInfotip>
|
|
124
138
|
</Stack>
|
|
125
139
|
);
|
|
126
140
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type ToggleButtonGroupItem, ToggleControl } from '@elementor/editor-controls';
|
|
3
|
+
import { isExperimentActive } from '@elementor/editor-v1-adapters';
|
|
3
4
|
import { Stack } from '@elementor/ui';
|
|
4
5
|
import { __ } from '@wordpress/i18n';
|
|
5
6
|
|
|
6
7
|
import { useStylesInheritanceField } from '../../../contexts/styles-inheritance-context';
|
|
7
8
|
import { StylesField } from '../../../controls-registry/styles-field';
|
|
8
|
-
import { isExperimentActive } from '../../../sync/is-experiment-active';
|
|
9
9
|
import { ControlLabel } from '../../control-label';
|
|
10
10
|
|
|
11
11
|
type Displays = 'block' | 'flex' | 'inline-block' | 'inline-flex' | 'none';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type StringPropValue } from '@elementor/editor-props';
|
|
3
|
+
import { isExperimentActive } from '@elementor/editor-v1-adapters';
|
|
3
4
|
import { useSessionStorage } from '@elementor/session';
|
|
4
5
|
|
|
5
6
|
import { useStyle } from '../../../contexts/style-context';
|
|
6
7
|
import { useStylesField } from '../../../hooks/use-styles-field';
|
|
7
8
|
import { useStylesFields } from '../../../hooks/use-styles-fields';
|
|
8
|
-
import { isExperimentActive } from '../../../sync/is-experiment-active';
|
|
9
9
|
import { PanelDivider } from '../../panel-divider';
|
|
10
10
|
import { SectionContent } from '../../section-content';
|
|
11
11
|
import { DimensionsField } from './dimensions-field';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SelectControl } from '@elementor/editor-controls';
|
|
3
|
+
import { Grid } from '@elementor/ui';
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
import { StylesField } from '../../../controls-registry/styles-field';
|
|
7
|
+
import { ControlLabel } from '../../control-label';
|
|
8
|
+
|
|
9
|
+
const positionOptions = [
|
|
10
|
+
{ label: __( 'Fill', 'elementor' ), value: 'fill' },
|
|
11
|
+
{ label: __( 'Cover', 'elementor' ), value: 'cover' },
|
|
12
|
+
{ label: __( 'Contain', 'elementor' ), value: 'contain' },
|
|
13
|
+
{ label: __( 'None', 'elementor' ), value: 'none' },
|
|
14
|
+
{ label: __( 'Scale down', 'elementor' ), value: 'scale-down' },
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
type Props = {
|
|
18
|
+
onChange?: ( newValue: string | null, previousValue: string | null | undefined ) => void;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const ObjectFitField = ( { onChange }: Props ) => {
|
|
22
|
+
return (
|
|
23
|
+
<StylesField bind="object-fit">
|
|
24
|
+
<Grid container pt={ 2 } gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
25
|
+
<Grid item xs={ 6 }>
|
|
26
|
+
<ControlLabel>{ __( 'Object fit', 'elementor' ) }</ControlLabel>
|
|
27
|
+
</Grid>
|
|
28
|
+
<Grid item xs={ 6 } sx={ { overflow: 'hidden' } }>
|
|
29
|
+
<SelectControl options={ positionOptions } onChange={ onChange } />
|
|
30
|
+
</Grid>
|
|
31
|
+
</Grid>
|
|
32
|
+
</StylesField>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SelectControl } from '@elementor/editor-controls';
|
|
3
|
+
import { Grid } from '@elementor/ui';
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
import { StylesField } from '../../../controls-registry/styles-field';
|
|
7
|
+
import { ControlLabel } from '../../control-label';
|
|
8
|
+
|
|
9
|
+
const positionOptions = [
|
|
10
|
+
{ label: __( 'Center center', 'elementor' ), value: 'center center' },
|
|
11
|
+
{ label: __( 'Center left', 'elementor' ), value: 'center left' },
|
|
12
|
+
{ label: __( 'Center right', 'elementor' ), value: 'center right' },
|
|
13
|
+
{ label: __( 'Top center', 'elementor' ), value: 'top center' },
|
|
14
|
+
{ label: __( 'Top left', 'elementor' ), value: 'top left' },
|
|
15
|
+
{ label: __( 'Top right', 'elementor' ), value: 'top right' },
|
|
16
|
+
{ label: __( 'Bottom center', 'elementor' ), value: 'bottom center' },
|
|
17
|
+
{ label: __( 'Bottom left', 'elementor' ), value: 'bottom left' },
|
|
18
|
+
{ label: __( 'Bottom right', 'elementor' ), value: 'bottom right' },
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
type Props = {
|
|
22
|
+
onChange?: ( newValue: string | null, previousValue: string | null | undefined ) => void;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const ObjectPositionField = ( { onChange }: Props ) => {
|
|
26
|
+
return (
|
|
27
|
+
<StylesField bind="object-position">
|
|
28
|
+
<Grid container pt={ 2 } gap={ 2 } alignItems="center" flexWrap="nowrap">
|
|
29
|
+
<Grid item xs={ 6 }>
|
|
30
|
+
<ControlLabel>{ __( 'Object position', 'elementor' ) }</ControlLabel>
|
|
31
|
+
</Grid>
|
|
32
|
+
<Grid item xs={ 6 } sx={ { overflow: 'hidden' } }>
|
|
33
|
+
<SelectControl options={ positionOptions } onChange={ onChange } />
|
|
34
|
+
</Grid>
|
|
35
|
+
</Grid>
|
|
36
|
+
</StylesField>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type ExtendedValue, SizeControl } from '@elementor/editor-controls';
|
|
3
|
+
import type { StringPropValue } from '@elementor/editor-props';
|
|
4
|
+
import { isExperimentActive } from '@elementor/editor-v1-adapters';
|
|
3
5
|
import { Grid, Stack } from '@elementor/ui';
|
|
4
6
|
import { __ } from '@wordpress/i18n';
|
|
5
7
|
|
|
6
8
|
import { StylesField, type StylesFieldProps } from '../../../controls-registry/styles-field';
|
|
9
|
+
import { useStylesField } from '../../../hooks/use-styles-field';
|
|
10
|
+
import { CollapsibleContent } from '../../collapsible-content';
|
|
7
11
|
import { ControlLabel } from '../../control-label';
|
|
8
12
|
import { PanelDivider } from '../../panel-divider';
|
|
9
13
|
import { SectionContent } from '../../section-content';
|
|
14
|
+
import { ObjectFitField } from './object-fit-field';
|
|
15
|
+
import { ObjectPositionField } from './object-position-field';
|
|
10
16
|
import { OverflowField } from './overflow-field';
|
|
11
17
|
|
|
12
18
|
export const SizeSection = () => {
|
|
19
|
+
const [ fitValue, setFitValue ] = useStylesField< StringPropValue >( 'object-fit' );
|
|
20
|
+
const isNotFill = fitValue && fitValue?.value !== 'fill';
|
|
21
|
+
|
|
22
|
+
const onFitChange = ( newFit: string | null, previousValue: string | null | undefined ) => {
|
|
23
|
+
if ( newFit && newFit !== previousValue ) {
|
|
24
|
+
setFitValue( {
|
|
25
|
+
value: newFit,
|
|
26
|
+
$$type: 'string',
|
|
27
|
+
} );
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const isVersion330Active = isExperimentActive( 'e_v_3_30' );
|
|
13
31
|
return (
|
|
14
32
|
<SectionContent>
|
|
15
33
|
<Grid container gap={ 2 } flexWrap="nowrap">
|
|
@@ -48,6 +66,14 @@ export const SizeSection = () => {
|
|
|
48
66
|
<Stack>
|
|
49
67
|
<OverflowField />
|
|
50
68
|
</Stack>
|
|
69
|
+
{ isVersion330Active && (
|
|
70
|
+
<CollapsibleContent>
|
|
71
|
+
<ObjectFitField onChange={ onFitChange } />
|
|
72
|
+
<Grid item xs={ 6 }>
|
|
73
|
+
{ isNotFill && <ObjectPositionField /> }
|
|
74
|
+
</Grid>
|
|
75
|
+
</CollapsibleContent>
|
|
76
|
+
) }
|
|
51
77
|
</SectionContent>
|
|
52
78
|
);
|
|
53
79
|
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
+
import { isExperimentActive } from '@elementor/editor-v1-adapters';
|
|
2
3
|
import { getSessionStorageItem, setSessionStorageItem } from '@elementor/session';
|
|
3
4
|
|
|
4
5
|
import { useElement } from '../contexts/element-context';
|
|
5
6
|
|
|
6
7
|
export const useStateByElement = < T >( key: string, initialValue: T ) => {
|
|
7
8
|
const { element } = useElement();
|
|
9
|
+
const isFeatureActive = isExperimentActive( 'e_v_3_30' );
|
|
8
10
|
const lookup = `elementor/editor-state/${ element.id }/${ key }`;
|
|
9
|
-
const storedValue = getSessionStorageItem< T >( lookup );
|
|
11
|
+
const storedValue = isFeatureActive ? getSessionStorageItem< T >( lookup ) : initialValue;
|
|
10
12
|
const [ value, setValue ] = useState( storedValue ?? initialValue );
|
|
11
13
|
|
|
12
14
|
const doUpdate = ( newValue: T ) => {
|
|
@@ -2,13 +2,13 @@ import * as React from 'react';
|
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { useBoundProp } from '@elementor/editor-controls';
|
|
4
4
|
import { ELEMENTS_BASE_STYLES_PROVIDER_KEY, isElementsStylesProvider } from '@elementor/editor-styles-repository';
|
|
5
|
+
import { isExperimentActive } from '@elementor/editor-v1-adapters';
|
|
5
6
|
import { IconButton, Infotip } from '@elementor/ui';
|
|
6
7
|
import { __ } from '@wordpress/i18n';
|
|
7
8
|
|
|
8
9
|
import { StyleIndicator } from '../components/style-indicator';
|
|
9
10
|
import { useStyle } from '../contexts/style-context';
|
|
10
11
|
import { useStylesInheritanceField } from '../contexts/styles-inheritance-context';
|
|
11
|
-
import { isExperimentActive } from '../sync/is-experiment-active';
|
|
12
12
|
import { StyleIndicatorInfotip } from './styles-inheritance-infotip';
|
|
13
13
|
|
|
14
14
|
export const StylesInheritanceIndicator = () => {
|
|
@@ -11,9 +11,3 @@ export const getElementorFrontendConfig = () => {
|
|
|
11
11
|
|
|
12
12
|
return extendedWindow.elementorFrontend?.config ?? {};
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
export const getElementorCommonConfig = () => {
|
|
16
|
-
const extendedWindow = window as unknown as ExtendedWindow;
|
|
17
|
-
|
|
18
|
-
return extendedWindow.elementorCommon?.config ?? {};
|
|
19
|
-
};
|