@elementor/editor-editing-panel 0.18.0 → 1.0.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 +64 -0
- package/dist/index.d.mts +8 -24
- package/dist/index.d.ts +8 -24
- package/dist/index.js +1452 -1122
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1436 -1099
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -14
- package/src/components/accordion-section.tsx +3 -2
- package/src/components/add-or-remove-content.tsx +42 -0
- package/src/components/collapsible-field.tsx +34 -0
- package/src/components/editing-panel-error-fallback.tsx +12 -0
- package/src/components/editing-panel.tsx +27 -19
- package/src/components/settings-tab.tsx +12 -11
- package/src/components/style-sections/background-section/background-color-field.tsx +21 -0
- package/src/components/style-sections/background-section/background-section.tsx +15 -0
- package/src/components/style-sections/border-section/border-color-field.tsx +21 -0
- package/src/components/style-sections/border-section/border-field.tsx +47 -0
- package/src/components/style-sections/border-section/border-radius-field.tsx +48 -0
- package/src/components/style-sections/border-section/border-section.tsx +16 -0
- package/src/components/style-sections/border-section/border-style-field.tsx +32 -0
- package/src/components/style-sections/border-section/border-width-field.tsx +42 -0
- package/src/components/style-sections/effects-section/effects-section.tsx +5 -5
- package/src/components/style-sections/position-section/dimensions-field.tsx +46 -0
- package/src/components/style-sections/position-section/position-field.tsx +28 -0
- package/src/components/style-sections/position-section/position-section.tsx +15 -2
- package/src/components/style-sections/position-section/z-index-field.tsx +21 -0
- package/src/components/style-sections/size-section/overflow-field.tsx +45 -0
- package/src/components/style-sections/size-section/size-section.tsx +55 -0
- package/src/components/style-sections/spacing-section/spacing-section.tsx +6 -6
- package/src/components/style-sections/typography-section/font-size-field.tsx +21 -0
- package/src/components/style-sections/typography-section/{font-weight-control.tsx → font-weight-field.tsx} +7 -6
- package/src/components/style-sections/typography-section/letter-spacing-field.tsx +21 -0
- package/src/components/style-sections/typography-section/{text-alignment-control.tsx → text-alignment-field.tsx} +8 -8
- package/src/components/style-sections/typography-section/text-color-field.tsx +21 -0
- package/src/components/style-sections/typography-section/{text-direction-control.tsx → text-direction-field.tsx} +8 -8
- package/src/components/style-sections/typography-section/text-stroke-field.tsx +16 -0
- package/src/components/style-sections/typography-section/{text-style-control.tsx → text-style-field.tsx} +5 -5
- package/src/components/style-sections/typography-section/{transform-control.tsx → transform-field.tsx} +8 -7
- package/src/components/style-sections/typography-section/typography-section.tsx +20 -18
- package/src/components/style-sections/typography-section/word-spacing-field.tsx +21 -0
- package/src/components/style-tab.tsx +44 -25
- package/src/contexts/classes-prop-context.tsx +24 -0
- package/src/contexts/element-context.tsx +6 -10
- package/src/contexts/style-context.tsx +8 -22
- package/src/control-replacement.tsx +3 -0
- package/src/controls/bound-prop-context.tsx +30 -0
- package/src/controls/components/control-toggle-button-group.tsx +15 -6
- package/src/controls/components/repeater.tsx +1 -1
- package/src/controls/components/text-field-inner-selection.tsx +20 -24
- package/src/controls/control-actions/control-actions-context.tsx +27 -0
- package/src/controls/control-actions/control-actions-menu.ts +6 -7
- package/src/controls/control-actions/control-actions.tsx +14 -26
- package/src/{components/style-sections/effects-section/box-shadow-repeater.tsx → controls/controls/box-shadow-repeater-control.tsx} +51 -65
- package/src/controls/controls/color-control.tsx +25 -0
- package/src/controls/controls/equal-unequal-sizes-control.tsx +196 -0
- package/src/controls/{control-types → controls}/image-control.tsx +15 -23
- package/src/controls/{control-types → controls}/image-media-control.tsx +5 -14
- package/src/{components/style-sections/spacing-section → controls/controls}/linked-dimensions-control.tsx +10 -26
- package/src/controls/{control-types → controls}/number-control.tsx +2 -2
- package/src/controls/{control-types → controls}/select-control.tsx +4 -4
- package/src/controls/{control-types → controls}/size-control.tsx +8 -8
- package/src/controls/controls/stroke-control.tsx +105 -0
- package/src/controls/{control-types → controls}/text-area-control.tsx +3 -3
- package/src/controls/{control-types → controls}/text-control.tsx +3 -3
- package/src/controls/{control-types → controls}/toggle-control.tsx +4 -4
- package/src/controls/create-control-replacement.tsx +53 -0
- package/src/controls/create-control.tsx +12 -3
- package/src/controls/index.ts +24 -0
- package/src/controls-actions.ts +8 -0
- package/src/{controls/components → controls-registry}/control-type-container.tsx +1 -1
- package/src/{controls → controls-registry}/controls-registry.tsx +1 -6
- package/src/controls-registry/settings-field.tsx +35 -0
- package/src/controls-registry/styles-field.tsx +19 -0
- package/src/dynamics/components/dynamic-selection-control.tsx +11 -11
- package/src/dynamics/components/dynamic-selection.tsx +6 -6
- package/src/dynamics/dynamic-control.tsx +6 -5
- package/src/dynamics/hooks/use-dynamic-tag.ts +2 -2
- package/src/dynamics/hooks/use-prop-dynamic-action.tsx +7 -7
- package/src/dynamics/hooks/use-prop-dynamic-tags.ts +3 -3
- package/src/dynamics/hooks/use-prop-value-history.ts +3 -3
- package/src/dynamics/init.ts +2 -4
- package/src/dynamics/types.ts +2 -1
- package/src/dynamics/utils.ts +1 -2
- package/src/hooks/use-styles-field.ts +30 -0
- package/src/index.ts +3 -4
- package/src/sync/should-use-v2-panel.ts +1 -2
- package/src/sync/types.ts +3 -2
- package/src/components/style-sections/position-section/z-index-control.tsx +0 -20
- package/src/components/style-sections/size-section.tsx +0 -49
- package/src/components/style-sections/typography-section/font-size-control.tsx +0 -20
- package/src/components/style-sections/typography-section/letter-spacing-control.tsx +0 -20
- package/src/components/style-sections/typography-section/text-color-control.tsx +0 -20
- package/src/components/style-sections/typography-section/word-spacing-control.tsx +0 -20
- package/src/controls/control-context.tsx +0 -22
- package/src/controls/control-replacement.ts +0 -34
- package/src/controls/control-types/color-control.tsx +0 -27
- package/src/controls/hooks/use-style-control.ts +0 -29
- package/src/controls/settings-control.tsx +0 -37
- package/src/controls/style-control.tsx +0 -20
- package/src/hooks/use-element-style-prop.ts +0 -45
- package/src/hooks/use-element-styles.ts +0 -13
- package/src/hooks/use-element-type.ts +0 -33
- package/src/hooks/use-selected-elements.ts +0 -9
- package/src/hooks/use-widget-settings.ts +0 -16
- package/src/props/is-transformable.ts +0 -14
- package/src/sync/get-container.ts +0 -8
- package/src/sync/get-element-styles.ts +0 -9
- package/src/sync/get-selected-elements.ts +0 -21
- package/src/sync/get-widgets-cache.ts +0 -7
- package/src/sync/update-settings.ts +0 -14
- package/src/sync/update-style.ts +0 -24
- package/src/types.ts +0 -89
- package/src/{controls → controls-registry}/control.tsx +0 -0
- package/src/{controls/control-actions/actions/popover-action.tsx → popover-action.tsx} +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { __ } from '@wordpress/i18n';
|
|
3
|
+
import { Grid } from '@elementor/ui';
|
|
4
|
+
import { StylesField } from '../../../controls-registry/styles-field';
|
|
5
|
+
import { NumberControl } from '../../../controls';
|
|
6
|
+
import { ControlLabel } from '../../control-label';
|
|
7
|
+
|
|
8
|
+
export const ZIndexField = () => {
|
|
9
|
+
return (
|
|
10
|
+
<StylesField bind="z-index">
|
|
11
|
+
<Grid container spacing={ 1 } alignItems="center">
|
|
12
|
+
<Grid item xs={ 6 }>
|
|
13
|
+
<ControlLabel>{ __( 'Z-Index', 'elementor' ) }</ControlLabel>
|
|
14
|
+
</Grid>
|
|
15
|
+
<Grid item xs={ 6 }>
|
|
16
|
+
<NumberControl />
|
|
17
|
+
</Grid>
|
|
18
|
+
</Grid>
|
|
19
|
+
</StylesField>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { __ } from '@wordpress/i18n';
|
|
3
|
+
import { Grid } from '@elementor/ui';
|
|
4
|
+
import { EyeIcon, EyeOffIcon, ExpandBottomIcon } from '@elementor/icons';
|
|
5
|
+
import { ToggleButtonGroupItem, ToggleControl } from '../../../controls';
|
|
6
|
+
import { StylesField } from '../../../controls-registry/styles-field';
|
|
7
|
+
import { ControlLabel } from '../../control-label';
|
|
8
|
+
|
|
9
|
+
type Overflows = 'visible' | 'hidden' | 'auto';
|
|
10
|
+
|
|
11
|
+
const options: ToggleButtonGroupItem< Overflows >[] = [
|
|
12
|
+
{
|
|
13
|
+
value: 'visible',
|
|
14
|
+
label: __( 'Visible', 'elementor' ),
|
|
15
|
+
icon: EyeIcon,
|
|
16
|
+
showTooltip: true,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
value: 'hidden',
|
|
20
|
+
label: __( 'Hidden', 'elementor' ),
|
|
21
|
+
icon: EyeOffIcon,
|
|
22
|
+
showTooltip: true,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
value: 'auto',
|
|
26
|
+
label: __( 'Auto', 'elementor' ),
|
|
27
|
+
icon: ExpandBottomIcon,
|
|
28
|
+
showTooltip: true,
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
export const OverflowField = () => {
|
|
33
|
+
return (
|
|
34
|
+
<StylesField bind={ 'overflow' }>
|
|
35
|
+
<Grid container spacing={ 1 } alignItems="center">
|
|
36
|
+
<Grid item xs={ 6 }>
|
|
37
|
+
<ControlLabel>{ __( 'Overflow', 'elementor' ) }</ControlLabel>
|
|
38
|
+
</Grid>
|
|
39
|
+
<Grid item xs={ 6 } sx={ { display: 'flex', justifyContent: 'flex-end' } }>
|
|
40
|
+
<ToggleControl options={ options } />
|
|
41
|
+
</Grid>
|
|
42
|
+
</Grid>
|
|
43
|
+
</StylesField>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Divider, Grid, Stack } from '@elementor/ui';
|
|
3
|
+
import { __ } from '@wordpress/i18n';
|
|
4
|
+
import { OverflowField } from './overflow-field';
|
|
5
|
+
import { AccordionSection } from '../../accordion-section';
|
|
6
|
+
import { StylesField, StylesFieldProps } from '../../../controls-registry/styles-field';
|
|
7
|
+
import { ControlLabel } from '../../control-label';
|
|
8
|
+
import { SizeControl } from '../../../controls';
|
|
9
|
+
|
|
10
|
+
export const SizeSection = () => {
|
|
11
|
+
return (
|
|
12
|
+
<AccordionSection title={ __( 'Size', 'elementor' ) }>
|
|
13
|
+
<Stack gap={ 1.5 }>
|
|
14
|
+
<Grid container spacing={ 2 }>
|
|
15
|
+
<SizeField bind="width" label={ __( 'Width', 'elementor' ) } />
|
|
16
|
+
<SizeField bind="height" label={ __( 'Height', 'elementor' ) } />
|
|
17
|
+
</Grid>
|
|
18
|
+
<Grid container spacing={ 2 }>
|
|
19
|
+
<SizeField bind="min-width" label={ __( 'Min. Width', 'elementor' ) } />
|
|
20
|
+
<SizeField bind="min-height" label={ __( 'Min. Height', 'elementor' ) } />
|
|
21
|
+
</Grid>
|
|
22
|
+
<Grid container spacing={ 2 }>
|
|
23
|
+
<SizeField bind="max-width" label={ __( 'Max. Width', 'elementor' ) } />
|
|
24
|
+
<SizeField bind="max-height" label={ __( 'Max. Height', 'elementor' ) } />
|
|
25
|
+
</Grid>
|
|
26
|
+
<Divider />
|
|
27
|
+
<Stack>
|
|
28
|
+
<OverflowField />
|
|
29
|
+
</Stack>
|
|
30
|
+
</Stack>
|
|
31
|
+
</AccordionSection>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
type ControlProps = {
|
|
36
|
+
bind: StylesFieldProps[ 'bind' ];
|
|
37
|
+
label: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const SizeField = ( { label, bind }: ControlProps ) => {
|
|
41
|
+
return (
|
|
42
|
+
<Grid item xs={ 6 }>
|
|
43
|
+
<StylesField bind={ bind }>
|
|
44
|
+
<Grid container spacing={ 1 } alignItems="center">
|
|
45
|
+
<Grid item xs={ 12 }>
|
|
46
|
+
<ControlLabel>{ label }</ControlLabel>
|
|
47
|
+
</Grid>
|
|
48
|
+
<Grid item xs={ 12 }>
|
|
49
|
+
<SizeControl />
|
|
50
|
+
</Grid>
|
|
51
|
+
</Grid>
|
|
52
|
+
</StylesField>
|
|
53
|
+
</Grid>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
@@ -2,20 +2,20 @@ import * as React from 'react';
|
|
|
2
2
|
import { AccordionSection } from '../../accordion-section';
|
|
3
3
|
import { Divider, Stack } from '@elementor/ui';
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { StylesField } from '../../../controls-registry/styles-field';
|
|
6
|
+
import { LinkedDimensionsControl } from '../../../controls/controls/linked-dimensions-control';
|
|
7
7
|
|
|
8
8
|
export const SpacingSection = () => {
|
|
9
9
|
return (
|
|
10
10
|
<AccordionSection title={ __( 'Spacing', 'elementor' ) }>
|
|
11
11
|
<Stack gap={ 1.5 }>
|
|
12
|
-
<
|
|
12
|
+
<StylesField bind={ 'padding' }>
|
|
13
13
|
<LinkedDimensionsControl label={ __( 'Padding', 'elementor' ) } />
|
|
14
|
-
</
|
|
14
|
+
</StylesField>
|
|
15
15
|
<Divider />
|
|
16
|
-
<
|
|
16
|
+
<StylesField bind={ 'margin' }>
|
|
17
17
|
<LinkedDimensionsControl label={ __( 'Margin', 'elementor' ) } />
|
|
18
|
-
</
|
|
18
|
+
</StylesField>
|
|
19
19
|
</Stack>
|
|
20
20
|
</AccordionSection>
|
|
21
21
|
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { __ } from '@wordpress/i18n';
|
|
3
|
+
import { Grid } from '@elementor/ui';
|
|
4
|
+
import { StylesField } from '../../../controls-registry/styles-field';
|
|
5
|
+
import { SizeControl } from '../../../controls';
|
|
6
|
+
import { ControlLabel } from '../../control-label';
|
|
7
|
+
|
|
8
|
+
export const FontSizeField = () => {
|
|
9
|
+
return (
|
|
10
|
+
<StylesField bind="font-size">
|
|
11
|
+
<Grid container spacing={ 1 } alignItems="center">
|
|
12
|
+
<Grid item xs={ 6 }>
|
|
13
|
+
<ControlLabel>{ __( 'Font Size', 'elementor' ) }</ControlLabel>
|
|
14
|
+
</Grid>
|
|
15
|
+
<Grid item xs={ 6 }>
|
|
16
|
+
<SizeControl />
|
|
17
|
+
</Grid>
|
|
18
|
+
</Grid>
|
|
19
|
+
</StylesField>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { __ } from '@wordpress/i18n';
|
|
3
3
|
import { Grid } from '@elementor/ui';
|
|
4
|
-
import {
|
|
5
|
-
import { SelectControl } from '../../../controls
|
|
4
|
+
import { StylesField } from '../../../controls-registry/styles-field';
|
|
5
|
+
import { SelectControl } from '../../../controls';
|
|
6
|
+
import { ControlLabel } from '../../control-label';
|
|
6
7
|
|
|
7
8
|
const fontWeightOptions = [
|
|
8
9
|
{ label: __( 'Light - 400', 'elementor' ), value: '400' },
|
|
@@ -12,17 +13,17 @@ const fontWeightOptions = [
|
|
|
12
13
|
{ label: __( 'Black - 900', 'elementor' ), value: '900' },
|
|
13
14
|
];
|
|
14
15
|
|
|
15
|
-
export const
|
|
16
|
+
export const FontWeightField = () => {
|
|
16
17
|
return (
|
|
17
|
-
<
|
|
18
|
+
<StylesField bind="font-weight">
|
|
18
19
|
<Grid container spacing={ 1 } alignItems="center">
|
|
19
20
|
<Grid item xs={ 6 }>
|
|
20
|
-
<
|
|
21
|
+
<ControlLabel>{ __( 'Font Weight', 'elementor' ) }</ControlLabel>
|
|
21
22
|
</Grid>
|
|
22
23
|
<Grid item xs={ 6 }>
|
|
23
24
|
<SelectControl options={ fontWeightOptions } />
|
|
24
25
|
</Grid>
|
|
25
26
|
</Grid>
|
|
26
|
-
</
|
|
27
|
+
</StylesField>
|
|
27
28
|
);
|
|
28
29
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { __ } from '@wordpress/i18n';
|
|
3
|
+
import { Grid } from '@elementor/ui';
|
|
4
|
+
import { StylesField } from '../../../controls-registry/styles-field';
|
|
5
|
+
import { SizeControl } from '../../../controls';
|
|
6
|
+
import { ControlLabel } from '../../control-label';
|
|
7
|
+
|
|
8
|
+
export const LetterSpacingField = () => {
|
|
9
|
+
return (
|
|
10
|
+
<StylesField bind="letter-spacing">
|
|
11
|
+
<Grid container spacing={ 1 } alignItems="center">
|
|
12
|
+
<Grid item xs={ 6 }>
|
|
13
|
+
<ControlLabel>{ __( 'Letter Spacing', 'elementor' ) }</ControlLabel>
|
|
14
|
+
</Grid>
|
|
15
|
+
<Grid item xs={ 6 }>
|
|
16
|
+
<SizeControl />
|
|
17
|
+
</Grid>
|
|
18
|
+
</Grid>
|
|
19
|
+
</StylesField>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -2,9 +2,9 @@ import * as React from 'react';
|
|
|
2
2
|
import { __ } from '@wordpress/i18n';
|
|
3
3
|
import { Grid } from '@elementor/ui';
|
|
4
4
|
import { AlignLeftIcon, AlignCenterIcon, AlignRightIcon, AlignJustifiedIcon } from '@elementor/icons';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { StylesField } from '../../../controls-registry/styles-field';
|
|
6
|
+
import { ToggleControl, ToggleButtonGroupItem } from '../../../controls';
|
|
7
|
+
import { ControlLabel } from '../../control-label';
|
|
8
8
|
|
|
9
9
|
type Alignments = 'left' | 'center' | 'right' | 'justify';
|
|
10
10
|
|
|
@@ -31,17 +31,17 @@ const options: ToggleButtonGroupItem< Alignments >[] = [
|
|
|
31
31
|
},
|
|
32
32
|
];
|
|
33
33
|
|
|
34
|
-
export const
|
|
34
|
+
export const TextAlignmentField = () => {
|
|
35
35
|
return (
|
|
36
|
-
<
|
|
36
|
+
<StylesField bind={ 'text-align' }>
|
|
37
37
|
<Grid container spacing={ 1 } alignItems="center">
|
|
38
38
|
<Grid item xs={ 6 }>
|
|
39
|
-
<
|
|
39
|
+
<ControlLabel>{ __( 'Alignment', 'elementor' ) }</ControlLabel>
|
|
40
40
|
</Grid>
|
|
41
|
-
<Grid item xs={ 6 }>
|
|
41
|
+
<Grid item xs={ 6 } display="flex" justifyContent="end">
|
|
42
42
|
<ToggleControl options={ options } />
|
|
43
43
|
</Grid>
|
|
44
44
|
</Grid>
|
|
45
|
-
</
|
|
45
|
+
</StylesField>
|
|
46
46
|
);
|
|
47
47
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { __ } from '@wordpress/i18n';
|
|
3
|
+
import { Grid } from '@elementor/ui';
|
|
4
|
+
import { StylesField } from '../../../controls-registry/styles-field';
|
|
5
|
+
import { ColorControl } from '../../../controls';
|
|
6
|
+
import { ControlLabel } from '../../control-label';
|
|
7
|
+
|
|
8
|
+
export const TextColorField = () => {
|
|
9
|
+
return (
|
|
10
|
+
<StylesField bind="color">
|
|
11
|
+
<Grid container spacing={ 1 } alignItems="center">
|
|
12
|
+
<Grid item xs={ 6 }>
|
|
13
|
+
<ControlLabel>{ __( 'Text Color', 'elementor' ) }</ControlLabel>
|
|
14
|
+
</Grid>
|
|
15
|
+
<Grid item xs={ 6 }>
|
|
16
|
+
<ColorControl />
|
|
17
|
+
</Grid>
|
|
18
|
+
</Grid>
|
|
19
|
+
</StylesField>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -2,9 +2,9 @@ import * as React from 'react';
|
|
|
2
2
|
import { __ } from '@wordpress/i18n';
|
|
3
3
|
import { Grid } from '@elementor/ui';
|
|
4
4
|
import { TextDirectionLtrIcon, TextDirectionRtlIcon } from '@elementor/icons';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { StylesField } from '../../../controls-registry/styles-field';
|
|
6
|
+
import { ToggleControl, ToggleButtonGroupItem } from '../../../controls';
|
|
7
|
+
import { ControlLabel } from '../../control-label';
|
|
8
8
|
|
|
9
9
|
type Direction = 'ltr' | 'rtl';
|
|
10
10
|
|
|
@@ -21,17 +21,17 @@ const options: ToggleButtonGroupItem< Direction >[] = [
|
|
|
21
21
|
},
|
|
22
22
|
];
|
|
23
23
|
|
|
24
|
-
export const
|
|
24
|
+
export const TextDirectionField = () => {
|
|
25
25
|
return (
|
|
26
|
-
<
|
|
26
|
+
<StylesField bind={ 'direction' }>
|
|
27
27
|
<Grid container spacing={ 1 } alignItems="center">
|
|
28
28
|
<Grid item xs={ 6 }>
|
|
29
|
-
<
|
|
29
|
+
<ControlLabel>{ __( 'Direction', 'elementor' ) }</ControlLabel>
|
|
30
30
|
</Grid>
|
|
31
|
-
<Grid item xs={ 6 }>
|
|
31
|
+
<Grid item xs={ 6 } display="flex" justifyContent="end">
|
|
32
32
|
<ToggleControl options={ options } />
|
|
33
33
|
</Grid>
|
|
34
34
|
</Grid>
|
|
35
|
-
</
|
|
35
|
+
</StylesField>
|
|
36
36
|
);
|
|
37
37
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { __ } from '@wordpress/i18n';
|
|
3
|
+
import { CollapsibleField } from '../../collapsible-field';
|
|
4
|
+
import { ControlLabel } from '../../control-label';
|
|
5
|
+
import { StylesField } from '../../../controls-registry/styles-field';
|
|
6
|
+
import { StrokeControl } from '../../../controls';
|
|
7
|
+
|
|
8
|
+
export const TextStrokeField = () => {
|
|
9
|
+
return (
|
|
10
|
+
<StylesField bind="-webkit-text-stroke">
|
|
11
|
+
<CollapsibleField label={ <ControlLabel>{ __( 'Text Stroke', 'elementor' ) }</ControlLabel> }>
|
|
12
|
+
<StrokeControl />
|
|
13
|
+
</CollapsibleField>
|
|
14
|
+
</StylesField>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
@@ -3,13 +3,13 @@ import { __ } from '@wordpress/i18n';
|
|
|
3
3
|
import { Grid, ToggleButton as ToggleButtonBase, ToggleButtonGroup, ToggleButtonProps } from '@elementor/ui';
|
|
4
4
|
import { ItalicIcon, StrikethroughIcon, UnderlineIcon } from '@elementor/icons';
|
|
5
5
|
import { ControlLabel } from '../../control-label';
|
|
6
|
-
import {
|
|
6
|
+
import { useStylesField } from '../../../hooks/use-styles-field';
|
|
7
7
|
|
|
8
8
|
const buttonSize = 'tiny';
|
|
9
9
|
|
|
10
|
-
export const
|
|
11
|
-
const [ fontStyle, setFontStyle ] =
|
|
12
|
-
const [ textDecoration, setTextDecoration ] =
|
|
10
|
+
export const TextStyleField = () => {
|
|
11
|
+
const [ fontStyle, setFontStyle ] = useStylesField< string | null >( 'font-style' );
|
|
12
|
+
const [ textDecoration, setTextDecoration ] = useStylesField< string | null >( 'text-decoration' );
|
|
13
13
|
|
|
14
14
|
const formats = [ fontStyle, ...( textDecoration || '' ).split( ' ' ) ];
|
|
15
15
|
|
|
@@ -18,7 +18,7 @@ export const TextStyleControl = () => {
|
|
|
18
18
|
<Grid item xs={ 6 }>
|
|
19
19
|
<ControlLabel>{ __( 'Style', 'elementor' ) }</ControlLabel>
|
|
20
20
|
</Grid>
|
|
21
|
-
<Grid item xs={ 6 }>
|
|
21
|
+
<Grid item xs={ 6 } display="flex" justifyContent="end">
|
|
22
22
|
<ToggleButtonGroup value={ formats }>
|
|
23
23
|
<ToggleButton
|
|
24
24
|
value="italic"
|
|
@@ -2,8 +2,9 @@ import * as React from 'react';
|
|
|
2
2
|
import { __ } from '@wordpress/i18n';
|
|
3
3
|
import { Grid } from '@elementor/ui';
|
|
4
4
|
import { LetterCaseIcon, LetterCaseLowerIcon, LetterCaseUpperIcon } from '@elementor/icons';
|
|
5
|
-
import {
|
|
6
|
-
import { ToggleControl } from '../../../controls
|
|
5
|
+
import { StylesField } from '../../../controls-registry/styles-field';
|
|
6
|
+
import { ToggleControl } from '../../../controls';
|
|
7
|
+
import { ControlLabel } from '../../control-label';
|
|
7
8
|
|
|
8
9
|
const options = [
|
|
9
10
|
{ value: 'capitalize', label: __( 'Capitalize', 'elementor' ), icon: LetterCaseIcon },
|
|
@@ -11,15 +12,15 @@ const options = [
|
|
|
11
12
|
{ value: 'lowercase', label: __( 'Lowercase', 'elementor' ), icon: LetterCaseLowerIcon },
|
|
12
13
|
];
|
|
13
14
|
|
|
14
|
-
export const
|
|
15
|
-
<
|
|
15
|
+
export const TransformField = () => (
|
|
16
|
+
<StylesField bind={ 'text-transform' }>
|
|
16
17
|
<Grid container spacing={ 1 } alignItems="center">
|
|
17
18
|
<Grid item xs={ 6 }>
|
|
18
|
-
<
|
|
19
|
+
<ControlLabel>{ __( 'Transform', 'elementor' ) }</ControlLabel>
|
|
19
20
|
</Grid>
|
|
20
|
-
<Grid item xs={ 6 }>
|
|
21
|
+
<Grid item xs={ 6 } display="flex" justifyContent="end">
|
|
21
22
|
<ToggleControl options={ options } />
|
|
22
23
|
</Grid>
|
|
23
24
|
</Grid>
|
|
24
|
-
</
|
|
25
|
+
</StylesField>
|
|
25
26
|
);
|
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { AccordionSection } from '../../accordion-section';
|
|
3
3
|
import { Divider, Stack } from '@elementor/ui';
|
|
4
|
-
import {
|
|
4
|
+
import { TextStyleField } from './text-style-field';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
6
|
+
import { FontSizeField } from './font-size-field';
|
|
7
|
+
import { FontWeightField } from './font-weight-field';
|
|
8
|
+
import { TextColorField } from './text-color-field';
|
|
9
|
+
import { LetterSpacingField } from './letter-spacing-field';
|
|
10
|
+
import { WordSpacingField } from './word-spacing-field';
|
|
11
11
|
import { CollapsibleContent } from '../../collapsible-content';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
12
|
+
import { TransformField } from './transform-field';
|
|
13
|
+
import { TextAlignmentField } from './text-alignment-field';
|
|
14
|
+
import { TextDirectionField } from './text-direction-field';
|
|
15
|
+
import { TextStrokeField } from './text-stroke-field';
|
|
15
16
|
|
|
16
17
|
export const TypographySection = () => {
|
|
17
18
|
return (
|
|
18
19
|
<AccordionSection title={ __( 'Typography', 'elementor' ) }>
|
|
19
20
|
<Stack gap={ 1.5 }>
|
|
20
|
-
<
|
|
21
|
-
<
|
|
21
|
+
<FontWeightField />
|
|
22
|
+
<FontSizeField />
|
|
22
23
|
<Divider />
|
|
23
|
-
<
|
|
24
|
+
<TextColorField />
|
|
24
25
|
<CollapsibleContent>
|
|
25
26
|
<Stack gap={ 1.5 } sx={ { pt: 1.5 } }>
|
|
26
|
-
<
|
|
27
|
-
<
|
|
27
|
+
<LetterSpacingField />
|
|
28
|
+
<WordSpacingField />
|
|
28
29
|
<Divider />
|
|
29
|
-
<
|
|
30
|
-
<
|
|
31
|
-
<
|
|
32
|
-
<
|
|
30
|
+
<TextAlignmentField />
|
|
31
|
+
<TextStyleField />
|
|
32
|
+
<TransformField />
|
|
33
|
+
<TextDirectionField />
|
|
34
|
+
<TextStrokeField />
|
|
33
35
|
</Stack>
|
|
34
36
|
</CollapsibleContent>
|
|
35
37
|
</Stack>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { __ } from '@wordpress/i18n';
|
|
3
|
+
import { Grid } from '@elementor/ui';
|
|
4
|
+
import { StylesField } from '../../../controls-registry/styles-field';
|
|
5
|
+
import { SizeControl } from '../../../controls';
|
|
6
|
+
import { ControlLabel } from '../../control-label';
|
|
7
|
+
|
|
8
|
+
export const WordSpacingField = () => {
|
|
9
|
+
return (
|
|
10
|
+
<StylesField bind="word-spacing">
|
|
11
|
+
<Grid container spacing={ 1 } alignItems="center">
|
|
12
|
+
<Grid item xs={ 6 }>
|
|
13
|
+
<ControlLabel>{ __( 'Word Spacing', 'elementor' ) }</ControlLabel>
|
|
14
|
+
</Grid>
|
|
15
|
+
<Grid item xs={ 6 }>
|
|
16
|
+
<SizeControl />
|
|
17
|
+
</Grid>
|
|
18
|
+
</Grid>
|
|
19
|
+
</StylesField>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -1,36 +1,62 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { useElementContext } from '../contexts/element-context';
|
|
4
|
-
import { useElementStyles } from '../hooks/use-element-styles';
|
|
2
|
+
import { useState } from 'react';
|
|
5
3
|
import { Stack } from '@elementor/ui';
|
|
6
|
-
import {
|
|
4
|
+
import { generateId, StyleDefinition } from '@elementor/editor-styles';
|
|
5
|
+
import { useActiveBreakpoint } from '@elementor/editor-responsive';
|
|
6
|
+
import { getElementStyles, getElementSetting } from '@elementor/editor-elements';
|
|
7
|
+
import { StyleProvider } from '../contexts/style-context';
|
|
8
|
+
import { SizeSection } from './style-sections/size-section/size-section';
|
|
7
9
|
import { TypographySection } from './style-sections/typography-section/typography-section';
|
|
8
10
|
import { PositionSection } from './style-sections/position-section/position-section';
|
|
9
|
-
import { StyleDefinition } from '@elementor/editor-style';
|
|
10
11
|
import { SpacingSection } from './style-sections/spacing-section/spacing-section';
|
|
11
12
|
import { EffectsSection } from './style-sections/effects-section/effects-section';
|
|
13
|
+
import { BackgroundSection } from './style-sections/background-section/background-section';
|
|
14
|
+
import { BorderSection } from './style-sections/border-section/border-section';
|
|
15
|
+
import { useElement } from '../contexts/element-context';
|
|
16
|
+
import { ClassesPropValue, PropKey } from '@elementor/editor-props';
|
|
17
|
+
import { ClassesPropProvider } from '../contexts/classes-prop-context';
|
|
12
18
|
|
|
13
19
|
const CLASSES_PROP_KEY = 'classes';
|
|
14
20
|
|
|
15
21
|
export const StyleTab = () => {
|
|
16
|
-
const
|
|
17
|
-
const
|
|
22
|
+
const currentClassesProp = useCurrentClassesProp();
|
|
23
|
+
const [ selectedStyleDefId ] = useSelectedStyleDefId( currentClassesProp );
|
|
24
|
+
const breakpoint = useActiveBreakpoint();
|
|
18
25
|
|
|
19
26
|
return (
|
|
20
|
-
<
|
|
21
|
-
<
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
<ClassesPropProvider prop={ currentClassesProp }>
|
|
28
|
+
<StyleProvider meta={ { breakpoint, state: null } } id={ selectedStyleDefId }>
|
|
29
|
+
<Stack>
|
|
30
|
+
<SpacingSection />
|
|
31
|
+
<SizeSection />
|
|
32
|
+
<PositionSection />
|
|
33
|
+
<TypographySection />
|
|
34
|
+
<BackgroundSection />
|
|
35
|
+
<BorderSection />
|
|
36
|
+
<EffectsSection />
|
|
37
|
+
</Stack>
|
|
38
|
+
</StyleProvider>
|
|
39
|
+
</ClassesPropProvider>
|
|
29
40
|
);
|
|
30
41
|
};
|
|
31
42
|
|
|
32
|
-
function
|
|
33
|
-
const {
|
|
43
|
+
function useSelectedStyleDefId( currentClassesProp: PropKey ) {
|
|
44
|
+
const { element } = useElement();
|
|
45
|
+
|
|
46
|
+
const [ selectedStyleDefId, setSelectedStyleDefId ] = useState< StyleDefinition[ 'id' ] >( () => {
|
|
47
|
+
const styleIds = getElementSetting< ClassesPropValue >( element.id, currentClassesProp )?.value ?? [];
|
|
48
|
+
const stylesDefs = getElementStyles( element.id ) ?? {};
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
styleIds.find( ( id ) => id in stylesDefs ) ?? generateId( `e-${ element.id }-`, Object.keys( stylesDefs ) )
|
|
52
|
+
);
|
|
53
|
+
} );
|
|
54
|
+
|
|
55
|
+
return [ selectedStyleDefId, setSelectedStyleDefId ] as const;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function useCurrentClassesProp(): string {
|
|
59
|
+
const { elementType } = useElement();
|
|
34
60
|
|
|
35
61
|
const prop = Object.entries( elementType.propsSchema ).find(
|
|
36
62
|
( [ , propType ] ) => propType.kind === 'array' && propType.key === CLASSES_PROP_KEY
|
|
@@ -42,10 +68,3 @@ function useClassesProp(): string {
|
|
|
42
68
|
|
|
43
69
|
return prop[ 0 ];
|
|
44
70
|
}
|
|
45
|
-
|
|
46
|
-
function useStyleDefinition(): StyleDefinition | null {
|
|
47
|
-
const { element } = useElementContext();
|
|
48
|
-
const elementStyles = useElementStyles( element.id );
|
|
49
|
-
|
|
50
|
-
return Object.values( elementStyles || {} )[ 0 ] ?? null;
|
|
51
|
-
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createContext, PropsWithChildren, useContext } from 'react';
|
|
3
|
+
|
|
4
|
+
type ContextValue = {
|
|
5
|
+
prop: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const Context = createContext< ContextValue | null >( null );
|
|
9
|
+
|
|
10
|
+
type Props = PropsWithChildren< ContextValue >;
|
|
11
|
+
|
|
12
|
+
export function ClassesPropProvider( { children, prop }: Props ) {
|
|
13
|
+
return <Context.Provider value={ { prop } }>{ children }</Context.Provider>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function useClassesProp() {
|
|
17
|
+
const context = useContext( Context );
|
|
18
|
+
|
|
19
|
+
if ( ! context ) {
|
|
20
|
+
throw new Error( 'useClassesProp must be used within a ClassesPropProvider' );
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return context.prop;
|
|
24
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { createContext,
|
|
3
|
-
import {
|
|
2
|
+
import { createContext, PropsWithChildren, useContext } from 'react';
|
|
3
|
+
import { ElementType, Element } from '@elementor/editor-elements';
|
|
4
4
|
|
|
5
5
|
type ContextValue = {
|
|
6
6
|
element: Element;
|
|
@@ -9,21 +9,17 @@ type ContextValue = {
|
|
|
9
9
|
|
|
10
10
|
const Context = createContext< ContextValue | null >( null );
|
|
11
11
|
|
|
12
|
-
type Props =
|
|
13
|
-
element: Element;
|
|
14
|
-
elementType: ElementType;
|
|
15
|
-
children?: ReactNode;
|
|
16
|
-
};
|
|
12
|
+
type Props = PropsWithChildren< ContextValue >;
|
|
17
13
|
|
|
18
|
-
export function
|
|
14
|
+
export function ElementProvider( { children, element, elementType }: Props ) {
|
|
19
15
|
return <Context.Provider value={ { element, elementType } }>{ children }</Context.Provider>;
|
|
20
16
|
}
|
|
21
17
|
|
|
22
|
-
export function
|
|
18
|
+
export function useElement() {
|
|
23
19
|
const context = useContext( Context );
|
|
24
20
|
|
|
25
21
|
if ( ! context ) {
|
|
26
|
-
throw new Error( '
|
|
22
|
+
throw new Error( 'useElement must be used within a ElementProvider' );
|
|
27
23
|
}
|
|
28
24
|
|
|
29
25
|
return context;
|