@elementor/editor-editing-panel 4.5.0-1218 → 4.5.0-1219

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.
Files changed (47) hide show
  1. package/dist/index.d.mts +96 -75
  2. package/dist/index.d.ts +96 -75
  3. package/dist/index.js +1026 -934
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +681 -595
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +25 -25
  8. package/src/components/editing-panel-tabs.tsx +8 -4
  9. package/src/components/style-sections/border-section/border-color-field.tsx +4 -4
  10. package/src/components/style-sections/border-section/border-radius-field.tsx +4 -4
  11. package/src/components/style-sections/border-section/border-style-field.tsx +4 -4
  12. package/src/components/style-sections/border-section/border-width-field.tsx +4 -4
  13. package/src/components/style-sections/effects-section/blend-mode-field.tsx +4 -4
  14. package/src/components/style-sections/effects-section/opacity-control-field.tsx +4 -4
  15. package/src/components/style-sections/layout-section/align-content-field.tsx +4 -4
  16. package/src/components/style-sections/layout-section/align-items-field.tsx +4 -4
  17. package/src/components/style-sections/layout-section/display-field.tsx +4 -4
  18. package/src/components/style-sections/layout-section/flex-direction-field.tsx +4 -4
  19. package/src/components/style-sections/layout-section/gap-control-field.tsx +4 -4
  20. package/src/components/style-sections/layout-section/grid-justify-items-field.tsx +4 -4
  21. package/src/components/style-sections/layout-section/justify-content-field.tsx +4 -4
  22. package/src/components/style-sections/layout-section/wrap-field.tsx +4 -4
  23. package/src/components/style-sections/position-section/offset-field.tsx +4 -4
  24. package/src/components/style-sections/position-section/position-field.tsx +4 -4
  25. package/src/components/style-sections/position-section/z-index-field.tsx +4 -4
  26. package/src/components/style-sections/size-section/object-fit-field.tsx +4 -4
  27. package/src/components/style-sections/size-section/overflow-field.tsx +4 -4
  28. package/src/components/style-sections/typography-section/column-count-field.tsx +4 -4
  29. package/src/components/style-sections/typography-section/column-gap-field.tsx +4 -4
  30. package/src/components/style-sections/typography-section/font-family-field.tsx +5 -9
  31. package/src/components/style-sections/typography-section/font-size-field.tsx +5 -5
  32. package/src/components/style-sections/typography-section/font-style-field.tsx +4 -4
  33. package/src/components/style-sections/typography-section/font-weight-field.tsx +4 -4
  34. package/src/components/style-sections/typography-section/letter-spacing-field.tsx +4 -4
  35. package/src/components/style-sections/typography-section/line-height-field.tsx +4 -4
  36. package/src/components/style-sections/typography-section/text-alignment-field.tsx +4 -4
  37. package/src/components/style-sections/typography-section/text-color-field.tsx +4 -4
  38. package/src/components/style-sections/typography-section/text-decoration-field.tsx +4 -4
  39. package/src/components/style-sections/typography-section/text-direction-field.tsx +4 -4
  40. package/src/components/style-sections/typography-section/transform-field.tsx +4 -4
  41. package/src/components/style-sections/typography-section/word-spacing-field.tsx +4 -4
  42. package/src/contexts/styles-field-targets-context.tsx +17 -0
  43. package/src/controls-registry/styles-field.tsx +4 -0
  44. package/src/hooks/use-styles-fields.ts +89 -56
  45. package/src/index.ts +5 -2
  46. package/src/styles-field-registry.ts +79 -0
  47. package/src/utils/element-local-style.ts +30 -0
@@ -3,18 +3,18 @@ import { useRef } from 'react';
3
3
  import { SizeControl } from '@elementor/editor-controls';
4
4
  import { __ } from '@wordpress/i18n';
5
5
 
6
- import { StylesField } from '../../../controls-registry/styles-field';
6
+ import { StylesField, type StylesFieldLabelProps } from '../../../controls-registry/styles-field';
7
7
  import { StylesFieldLayout } from '../../styles-field-layout';
8
8
 
9
9
  const FONT_SIZE_LABEL = __( 'Font size', 'elementor' );
10
10
 
11
- export const FontSizeField = () => {
11
+ export const FontSizeField = ( { label = FONT_SIZE_LABEL }: StylesFieldLabelProps ) => {
12
12
  const rowRef = useRef< HTMLDivElement >( null );
13
13
 
14
14
  return (
15
- <StylesField bind="font-size" propDisplayName={ FONT_SIZE_LABEL }>
16
- <StylesFieldLayout label={ FONT_SIZE_LABEL } ref={ rowRef }>
17
- <SizeControl anchorRef={ rowRef } ariaLabel={ FONT_SIZE_LABEL } />
15
+ <StylesField bind="font-size" propDisplayName={ label }>
16
+ <StylesFieldLayout label={ label } ref={ rowRef }>
17
+ <SizeControl anchorRef={ rowRef } ariaLabel={ label } />
18
18
  </StylesFieldLayout>
19
19
  </StylesField>
20
20
  );
@@ -3,7 +3,7 @@ import { type ToggleButtonGroupItem, ToggleControl } from '@elementor/editor-con
3
3
  import { ItalicIcon, MinusIcon } from '@elementor/icons';
4
4
  import { __ } from '@wordpress/i18n';
5
5
 
6
- import { StylesField } from '../../../controls-registry/styles-field';
6
+ import { StylesField, type StylesFieldLabelProps } from '../../../controls-registry/styles-field';
7
7
  import { StylesFieldLayout } from '../../styles-field-layout';
8
8
 
9
9
  type FontStyle = 'normal' | 'italic';
@@ -25,10 +25,10 @@ const options: ToggleButtonGroupItem< FontStyle >[] = [
25
25
  },
26
26
  ];
27
27
 
28
- export const FontStyleField = () => {
28
+ export const FontStyleField = ( { label = FONT_STYLE_LABEL }: StylesFieldLabelProps ) => {
29
29
  return (
30
- <StylesField bind="font-style" propDisplayName={ FONT_STYLE_LABEL }>
31
- <StylesFieldLayout label={ FONT_STYLE_LABEL }>
30
+ <StylesField bind="font-style" propDisplayName={ label }>
31
+ <StylesFieldLayout label={ label }>
32
32
  <ToggleControl options={ options } />
33
33
  </StylesFieldLayout>
34
34
  </StylesField>
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { SelectControl } from '@elementor/editor-controls';
3
3
  import { __ } from '@wordpress/i18n';
4
4
 
5
- import { StylesField } from '../../../controls-registry/styles-field';
5
+ import { StylesField, type StylesFieldLabelProps } from '../../../controls-registry/styles-field';
6
6
  import { StylesFieldLayout } from '../../styles-field-layout';
7
7
 
8
8
  const FONT_WEIGHT_LABEL = __( 'Font weight', 'elementor' );
@@ -19,10 +19,10 @@ const fontWeightOptions = [
19
19
  { value: '900', label: __( '900 - Black', 'elementor' ) },
20
20
  ];
21
21
 
22
- export const FontWeightField = () => {
22
+ export const FontWeightField = ( { label = FONT_WEIGHT_LABEL }: StylesFieldLabelProps ) => {
23
23
  return (
24
- <StylesField bind="font-weight" propDisplayName={ FONT_WEIGHT_LABEL }>
25
- <StylesFieldLayout label={ FONT_WEIGHT_LABEL }>
24
+ <StylesField bind="font-weight" propDisplayName={ label }>
25
+ <StylesFieldLayout label={ label }>
26
26
  <SelectControl options={ fontWeightOptions } />
27
27
  </StylesFieldLayout>
28
28
  </StylesField>
@@ -3,17 +3,17 @@ import { useRef } from 'react';
3
3
  import { SizeControl } from '@elementor/editor-controls';
4
4
  import { __ } from '@wordpress/i18n';
5
5
 
6
- import { StylesField } from '../../../controls-registry/styles-field';
6
+ import { StylesField, type StylesFieldLabelProps } from '../../../controls-registry/styles-field';
7
7
  import { StylesFieldLayout } from '../../styles-field-layout';
8
8
 
9
9
  const LETTER_SPACING_LABEL = __( 'Letter spacing', 'elementor' );
10
10
 
11
- export const LetterSpacingField = () => {
11
+ export const LetterSpacingField = ( { label = LETTER_SPACING_LABEL }: StylesFieldLabelProps ) => {
12
12
  const rowRef = useRef< HTMLDivElement >( null );
13
13
 
14
14
  return (
15
- <StylesField bind="letter-spacing" propDisplayName={ LETTER_SPACING_LABEL }>
16
- <StylesFieldLayout label={ LETTER_SPACING_LABEL } ref={ rowRef }>
15
+ <StylesField bind="letter-spacing" propDisplayName={ label }>
16
+ <StylesFieldLayout label={ label } ref={ rowRef }>
17
17
  <SizeControl anchorRef={ rowRef } min={ -Number.MAX_SAFE_INTEGER } />
18
18
  </StylesFieldLayout>
19
19
  </StylesField>
@@ -3,17 +3,17 @@ import { useRef } from 'react';
3
3
  import { SizeControl } from '@elementor/editor-controls';
4
4
  import { __ } from '@wordpress/i18n';
5
5
 
6
- import { StylesField } from '../../../controls-registry/styles-field';
6
+ import { StylesField, type StylesFieldLabelProps } from '../../../controls-registry/styles-field';
7
7
  import { StylesFieldLayout } from '../../styles-field-layout';
8
8
 
9
9
  const LINE_HEIGHT_LABEL = __( 'Line height', 'elementor' );
10
10
 
11
- export const LineHeightField = () => {
11
+ export const LineHeightField = ( { label = LINE_HEIGHT_LABEL }: StylesFieldLabelProps ) => {
12
12
  const rowRef = useRef< HTMLDivElement >( null );
13
13
 
14
14
  return (
15
- <StylesField bind="line-height" propDisplayName={ LINE_HEIGHT_LABEL }>
16
- <StylesFieldLayout label={ LINE_HEIGHT_LABEL } ref={ rowRef }>
15
+ <StylesField bind="line-height" propDisplayName={ label }>
16
+ <StylesFieldLayout label={ label } ref={ rowRef }>
17
17
  <SizeControl anchorRef={ rowRef } />
18
18
  </StylesFieldLayout>
19
19
  </StylesField>
@@ -4,7 +4,7 @@ import { AlignCenterIcon, AlignJustifiedIcon, AlignLeftIcon, AlignRightIcon } fr
4
4
  import { withDirection } from '@elementor/ui';
5
5
  import { __ } from '@wordpress/i18n';
6
6
 
7
- import { StylesField } from '../../../controls-registry/styles-field';
7
+ import { StylesField, type StylesFieldLabelProps } from '../../../controls-registry/styles-field';
8
8
  import { UiProviders } from '../../../styles-inheritance/components/ui-providers';
9
9
  import { StylesFieldLayout } from '../../styles-field-layout';
10
10
 
@@ -42,11 +42,11 @@ const options: ToggleButtonGroupItem< Alignments >[] = [
42
42
  },
43
43
  ];
44
44
 
45
- export const TextAlignmentField = () => {
45
+ export const TextAlignmentField = ( { label = TEXT_ALIGNMENT_LABEL }: StylesFieldLabelProps ) => {
46
46
  return (
47
- <StylesField bind="text-align" propDisplayName={ TEXT_ALIGNMENT_LABEL }>
47
+ <StylesField bind="text-align" propDisplayName={ label }>
48
48
  <UiProviders>
49
- <StylesFieldLayout label={ TEXT_ALIGNMENT_LABEL }>
49
+ <StylesFieldLayout label={ label }>
50
50
  <ToggleControl options={ options } />
51
51
  </StylesFieldLayout>
52
52
  </UiProviders>
@@ -2,15 +2,15 @@ import * as React from 'react';
2
2
  import { ColorControl } from '@elementor/editor-controls';
3
3
  import { __ } from '@wordpress/i18n';
4
4
 
5
- import { StylesField } from '../../../controls-registry/styles-field';
5
+ import { StylesField, type StylesFieldLabelProps } from '../../../controls-registry/styles-field';
6
6
  import { StylesFieldLayout } from '../../styles-field-layout';
7
7
 
8
8
  const TEXT_COLOR_LABEL = __( 'Text color', 'elementor' );
9
9
 
10
- export const TextColorField = () => {
10
+ export const TextColorField = ( { label = TEXT_COLOR_LABEL }: StylesFieldLabelProps ) => {
11
11
  return (
12
- <StylesField bind="color" propDisplayName={ TEXT_COLOR_LABEL }>
13
- <StylesFieldLayout label={ TEXT_COLOR_LABEL }>
12
+ <StylesField bind="color" propDisplayName={ label }>
13
+ <StylesFieldLayout label={ label }>
14
14
  <ColorControl id="text-color-control" />
15
15
  </StylesFieldLayout>
16
16
  </StylesField>
@@ -3,7 +3,7 @@ import { ToggleControl, type ToggleControlProps } from '@elementor/editor-contro
3
3
  import { MinusIcon, OverlineIcon, StrikethroughIcon, UnderlineIcon } from '@elementor/icons';
4
4
  import { __ } from '@wordpress/i18n';
5
5
 
6
- import { StylesField } from '../../../controls-registry/styles-field';
6
+ import { StylesField, type StylesFieldLabelProps } from '../../../controls-registry/styles-field';
7
7
  import { StylesFieldLayout } from '../../styles-field-layout';
8
8
 
9
9
  type Decoration = 'none' | 'underline' | 'line-through' | 'overline';
@@ -37,9 +37,9 @@ const options: ToggleControlProps< Decoration >[ 'options' ] = [
37
37
  showTooltip: true,
38
38
  },
39
39
  ];
40
- export const TextDecorationField = () => (
41
- <StylesField bind="text-decoration" propDisplayName={ TEXT_DECORATION_LABEL }>
42
- <StylesFieldLayout label={ TEXT_DECORATION_LABEL }>
40
+ export const TextDecorationField = ( { label = TEXT_DECORATION_LABEL }: StylesFieldLabelProps ) => (
41
+ <StylesField bind="text-decoration" propDisplayName={ label }>
42
+ <StylesFieldLayout label={ label }>
43
43
  <ToggleControl options={ options } exclusive={ false } />
44
44
  </StylesFieldLayout>
45
45
  </StylesField>
@@ -3,7 +3,7 @@ import { type ToggleButtonGroupItem, ToggleControl } from '@elementor/editor-con
3
3
  import { TextDirectionLtrIcon, TextDirectionRtlIcon } from '@elementor/icons';
4
4
  import { __ } from '@wordpress/i18n';
5
5
 
6
- import { StylesField } from '../../../controls-registry/styles-field';
6
+ import { StylesField, type StylesFieldLabelProps } from '../../../controls-registry/styles-field';
7
7
  import { StylesFieldLayout } from '../../styles-field-layout';
8
8
 
9
9
  type Direction = 'ltr' | 'rtl';
@@ -25,10 +25,10 @@ const options: ToggleButtonGroupItem< Direction >[] = [
25
25
  },
26
26
  ];
27
27
 
28
- export const TextDirectionField = () => {
28
+ export const TextDirectionField = ( { label = TEXT_DIRECTION_LABEL }: StylesFieldLabelProps ) => {
29
29
  return (
30
- <StylesField bind="direction" propDisplayName={ TEXT_DIRECTION_LABEL }>
31
- <StylesFieldLayout label={ TEXT_DIRECTION_LABEL }>
30
+ <StylesField bind="direction" propDisplayName={ label }>
31
+ <StylesFieldLayout label={ label }>
32
32
  <ToggleControl options={ options } />
33
33
  </StylesFieldLayout>
34
34
  </StylesField>
@@ -3,7 +3,7 @@ import { type ToggleButtonGroupItem, ToggleControl } from '@elementor/editor-con
3
3
  import { LetterCaseIcon, LetterCaseLowerIcon, LetterCaseUpperIcon, MinusIcon } from '@elementor/icons';
4
4
  import { __ } from '@wordpress/i18n';
5
5
 
6
- import { StylesField } from '../../../controls-registry/styles-field';
6
+ import { StylesField, type StylesFieldLabelProps } from '../../../controls-registry/styles-field';
7
7
  import { StylesFieldLayout } from '../../styles-field-layout';
8
8
 
9
9
  type Transforms = 'none' | 'capitalize' | 'uppercase' | 'lowercase';
@@ -37,9 +37,9 @@ const options: ToggleButtonGroupItem< Transforms >[] = [
37
37
  },
38
38
  ];
39
39
 
40
- export const TransformField = () => (
41
- <StylesField bind="text-transform" propDisplayName={ TEXT_TRANSFORM_LABEL }>
42
- <StylesFieldLayout label={ TEXT_TRANSFORM_LABEL }>
40
+ export const TransformField = ( { label = TEXT_TRANSFORM_LABEL }: StylesFieldLabelProps ) => (
41
+ <StylesField bind="text-transform" propDisplayName={ label }>
42
+ <StylesFieldLayout label={ label }>
43
43
  <ToggleControl options={ options } />
44
44
  </StylesFieldLayout>
45
45
  </StylesField>
@@ -3,17 +3,17 @@ import { useRef } from 'react';
3
3
  import { SizeControl } from '@elementor/editor-controls';
4
4
  import { __ } from '@wordpress/i18n';
5
5
 
6
- import { StylesField } from '../../../controls-registry/styles-field';
6
+ import { StylesField, type StylesFieldLabelProps } from '../../../controls-registry/styles-field';
7
7
  import { StylesFieldLayout } from '../../styles-field-layout';
8
8
 
9
9
  const WORD_SPACING_LABEL = __( 'Word spacing', 'elementor' );
10
10
 
11
- export const WordSpacingField = () => {
11
+ export const WordSpacingField = ( { label = WORD_SPACING_LABEL }: StylesFieldLabelProps ) => {
12
12
  const rowRef = useRef< HTMLDivElement >( null );
13
13
 
14
14
  return (
15
- <StylesField bind="word-spacing" propDisplayName={ WORD_SPACING_LABEL }>
16
- <StylesFieldLayout label={ WORD_SPACING_LABEL } ref={ rowRef }>
15
+ <StylesField bind="word-spacing" propDisplayName={ label }>
16
+ <StylesFieldLayout label={ label } ref={ rowRef }>
17
17
  <SizeControl anchorRef={ rowRef } min={ -Number.MAX_SAFE_INTEGER } />
18
18
  </StylesFieldLayout>
19
19
  </StylesField>
@@ -0,0 +1,17 @@
1
+ import * as React from 'react';
2
+ import { createContext, type PropsWithChildren, useContext } from 'react';
3
+ import { type ElementID } from '@elementor/editor-elements';
4
+
5
+ const Context = createContext< ElementID[] | null >( null );
6
+
7
+ type Props = PropsWithChildren< {
8
+ elementIds: ElementID[];
9
+ } >;
10
+
11
+ export function StylesFieldTargetsProvider( { children, elementIds }: Props ) {
12
+ return <Context.Provider value={ elementIds }>{ children }</Context.Provider>;
13
+ }
14
+
15
+ export function useStylesFieldTargets() {
16
+ return useContext( Context );
17
+ }
@@ -86,6 +86,10 @@ function buildResolvedPlaceholder( chain: { value: PropValue }[], startIndex: nu
86
86
  } );
87
87
  }
88
88
 
89
+ export type StylesFieldLabelProps = {
90
+ label?: string;
91
+ };
92
+
89
93
  export type StylesFieldProps = {
90
94
  bind: PropKey;
91
95
  placeholder?: PropValue;
@@ -16,7 +16,9 @@ import { __ } from '@wordpress/i18n';
16
16
  import { useClassesProp } from '../contexts/classes-prop-context';
17
17
  import { useElement } from '../contexts/element-context';
18
18
  import { useStyle } from '../contexts/style-context';
19
+ import { useStylesFieldTargets } from '../contexts/styles-field-targets-context';
19
20
  import { StyleNotFoundUnderProviderError, StylesProviderCannotUpdatePropsError } from '../errors';
21
+ import { getElementClassesProp, getElementLocalStyle } from '../utils/element-local-style';
20
22
  import { useStylesRerender } from './use-styles-rerender';
21
23
 
22
24
  export const HISTORY_DEBOUNCE_WAIT = 800;
@@ -26,24 +28,51 @@ export function useStylesFields< T extends Props >( propNames: ( keyof T & strin
26
28
  element: { id: elementId },
27
29
  } = useElement();
28
30
  const { id: styleId, meta, provider, canEdit } = useStyle();
31
+ const classesProp = useClassesProp();
32
+ const targetElementIds = useStylesFieldTargets();
29
33
 
30
- const undoableUpdateStyle = useUndoableActions( { elementId, meta } );
34
+ const undoableUpdateStyle = useUndoableActions( { meta } );
31
35
 
32
36
  useStylesRerender();
33
37
 
34
38
  const values = getProps< T >( { elementId, styleId, provider, meta, propNames } );
35
39
 
36
40
  const setValues = ( props: T, { history: { propDisplayName } }: { history: { propDisplayName: string } } ) => {
37
- if ( ! styleId ) {
38
- undoableUpdateStyle( { styleId: null, provider: null, props, propDisplayName } );
39
- } else {
40
- undoableUpdateStyle( { styleId, provider, props, propDisplayName } );
41
+ const targets = targetElementIds
42
+ ? getLocalStyleTargets( targetElementIds )
43
+ : [ { elementId, classesProp, styleId, provider } ];
44
+
45
+ if ( ! targets.length ) {
46
+ return;
41
47
  }
48
+
49
+ undoableUpdateStyle( { targets, props, propDisplayName } );
42
50
  };
43
51
 
44
52
  return { values, setValues, canEdit };
45
53
  }
46
54
 
55
+ function getLocalStyleTargets( elementIds: ElementID[] ): StyleTarget[] {
56
+ return elementIds.flatMap( ( elementId ) => {
57
+ const classesProp = getElementClassesProp( elementId );
58
+
59
+ if ( ! classesProp ) {
60
+ return [];
61
+ }
62
+
63
+ const localStyle = getElementLocalStyle( elementId );
64
+
65
+ return [
66
+ {
67
+ elementId,
68
+ classesProp,
69
+ styleId: localStyle?.styleId ?? null,
70
+ provider: localStyle?.provider ?? null,
71
+ },
72
+ ];
73
+ } );
74
+ }
75
+
47
76
  type GetPropsArgs = {
48
77
  provider: StylesProvider | null;
49
78
  styleId: StyleDefinition[ 'id' ] | null;
@@ -74,18 +103,16 @@ function getProps< T extends Props >( { styleId, elementId, provider, meta, prop
74
103
  ) as NullableValues< T >;
75
104
  }
76
105
 
77
- type UpdateStyleArgs = {
78
- styleId: StyleDefinition[ 'id' ];
79
- provider: StylesProvider;
80
- props: Props;
81
- propDisplayName: string;
106
+ type StyleTarget = {
107
+ elementId: ElementID;
108
+ classesProp: string;
109
+ styleId: StyleDefinition[ 'id' ] | null;
110
+ provider: StylesProvider | null;
82
111
  };
83
112
 
84
- type CreateStyleArgs = {
85
- styleId: null;
86
- provider: null;
87
- props: Props;
88
- propDisplayName: string;
113
+ type UpdateStyleTarget = StyleTarget & {
114
+ styleId: StyleDefinition[ 'id' ];
115
+ provider: StylesProvider;
89
116
  };
90
117
 
91
118
  type UpdateStyleReturn = {
@@ -98,67 +125,73 @@ type CreateStyleReturn = {
98
125
  createdStyleId: StyleDefinition[ 'id' ];
99
126
  };
100
127
 
101
- type UndoableUpdateStylePayload = UpdateStyleArgs | CreateStyleArgs;
102
- type UndoableUpdateStyleReturn = UpdateStyleReturn | CreateStyleReturn;
128
+ type UndoableUpdateStylePayload = {
129
+ targets: StyleTarget[];
130
+ props: Props;
131
+ propDisplayName: string;
132
+ };
103
133
 
104
- function useUndoableActions( {
105
- elementId,
106
- meta: { breakpoint, state },
107
- }: {
108
- elementId: ElementID;
109
- meta: StyleDefinitionVariant[ 'meta' ];
110
- } ) {
111
- const classesProp = useClassesProp();
134
+ type TargetReturn = UpdateStyleReturn | CreateStyleReturn;
112
135
 
136
+ function useUndoableActions( { meta: { breakpoint, state } }: { meta: StyleDefinitionVariant[ 'meta' ] } ) {
113
137
  return useMemo( () => {
114
138
  const meta = { breakpoint, state };
115
139
 
116
- const createStyleArgs = { elementId, classesProp, meta, label: ELEMENTS_STYLES_RESERVED_LABEL };
117
-
118
140
  return undoable(
119
141
  {
120
- do: ( payload: UndoableUpdateStylePayload ): UndoableUpdateStyleReturn => {
121
- if ( shouldCreateNewLocalStyle< StylesProvider >( payload ) ) {
122
- return create( payload as CreateStyleArgs );
123
- }
124
- return update( payload as UpdateStyleArgs );
125
- },
126
- undo: ( payload: UndoableUpdateStylePayload, doReturn: UndoableUpdateStyleReturn ) => {
127
- const wasLocalStyleCreated = shouldCreateNewLocalStyle< StylesProvider >( payload );
128
-
129
- if ( wasLocalStyleCreated ) {
130
- return undoCreate( payload as CreateStyleArgs, doReturn as CreateStyleReturn );
131
- }
132
- return undo( payload as UpdateStyleArgs, doReturn as UpdateStyleReturn );
133
- },
134
- redo: ( payload: UndoableUpdateStylePayload, doReturn: UndoableUpdateStyleReturn ) => {
135
- const wasLocalStyleCreated = shouldCreateNewLocalStyle< StylesProvider >( payload );
136
-
137
- if ( wasLocalStyleCreated ) {
138
- return create( payload as CreateStyleArgs, doReturn as CreateStyleReturn );
139
- }
140
- return update( payload as UpdateStyleArgs );
142
+ do: ( { targets, props }: UndoableUpdateStylePayload ): TargetReturn[] =>
143
+ targets.map( ( target ) =>
144
+ shouldCreateNewLocalStyle< StylesProvider >( target )
145
+ ? create( target, props )
146
+ : update( target as UpdateStyleTarget, props )
147
+ ),
148
+ undo: ( { targets }: UndoableUpdateStylePayload, doReturn: TargetReturn[] ) => {
149
+ targets.forEach( ( target, index ) => {
150
+ if ( shouldCreateNewLocalStyle< StylesProvider >( target ) ) {
151
+ undoCreate( target, doReturn[ index ] as CreateStyleReturn );
152
+ } else {
153
+ undo( target, doReturn[ index ] as UpdateStyleReturn );
154
+ }
155
+ } );
141
156
  },
157
+ redo: ( { targets, props }: UndoableUpdateStylePayload, doReturn: TargetReturn[] ): TargetReturn[] =>
158
+ targets.map( ( target, index ) =>
159
+ shouldCreateNewLocalStyle< StylesProvider >( target )
160
+ ? create( target, props, doReturn[ index ] as CreateStyleReturn )
161
+ : update( target as UpdateStyleTarget, props )
162
+ ),
142
163
  },
143
164
  {
144
- title: ( { provider, styleId } ) => getTitle( { provider, styleId, elementId } ),
145
- subtitle: ( { provider, styleId, propDisplayName } ) =>
165
+ title: ( { targets: [ { provider, styleId, elementId } ] } ) =>
166
+ getTitle( { provider, styleId, elementId } ),
167
+ subtitle: ( { targets: [ { provider, styleId, elementId } ], propDisplayName } ) =>
146
168
  getSubtitle( { provider, styleId, elementId, propDisplayName } ),
147
169
  debounce: { wait: HISTORY_DEBOUNCE_WAIT },
148
170
  }
149
171
  );
150
172
 
151
- function create( { props }: CreateStyleArgs, redoArgs?: CreateStyleReturn ): CreateStyleReturn {
152
- const createdStyle = createElementStyle( { ...createStyleArgs, props, styleId: redoArgs?.createdStyleId } );
173
+ function create(
174
+ { elementId, classesProp }: StyleTarget,
175
+ props: Props,
176
+ redoArgs?: CreateStyleReturn
177
+ ): CreateStyleReturn {
178
+ const createdStyle = createElementStyle( {
179
+ elementId,
180
+ classesProp,
181
+ meta,
182
+ label: ELEMENTS_STYLES_RESERVED_LABEL,
183
+ props,
184
+ styleId: redoArgs?.createdStyleId,
185
+ } );
153
186
 
154
187
  return { createdStyleId: createdStyle };
155
188
  }
156
189
 
157
- function undoCreate( _: UndoableUpdateStylePayload, { createdStyleId }: CreateStyleReturn ) {
190
+ function undoCreate( { elementId }: StyleTarget, { createdStyleId }: CreateStyleReturn ) {
158
191
  deleteElementStyle( elementId, createdStyleId );
159
192
  }
160
193
 
161
- function update( { provider, styleId, props }: UpdateStyleArgs ): UpdateStyleReturn {
194
+ function update( { elementId, provider, styleId }: UpdateStyleTarget, props: Props ): UpdateStyleReturn {
162
195
  if ( ! provider.actions.updateProps ) {
163
196
  throw new StylesProviderCannotUpdatePropsError( {
164
197
  context: { providerKey: provider.getKey() },
@@ -173,10 +206,10 @@ function useUndoableActions( {
173
206
  return { styleId, provider, prevProps };
174
207
  }
175
208
 
176
- function undo( _: UndoableUpdateStylePayload, { styleId, provider, prevProps }: UpdateStyleReturn ) {
209
+ function undo( { elementId }: StyleTarget, { styleId, provider, prevProps }: UpdateStyleReturn ) {
177
210
  provider.actions.updateProps?.( { id: styleId, meta, props: prevProps, mode: 'replace' }, { elementId } );
178
211
  }
179
- }, [ elementId, breakpoint, state, classesProp ] );
212
+ }, [ breakpoint, state ] );
180
213
  }
181
214
 
182
215
  function getCurrentProps( style: StyleDefinition | null, meta: StyleDefinitionVariant[ 'meta' ] ) {
package/src/index.ts CHANGED
@@ -10,7 +10,7 @@ export { ControlLabel } from './components/control-label';
10
10
  export { injectIntoClassSelectorActions } from './components/css-classes/css-class-selector';
11
11
  export { CustomCssIndicator } from './components/custom-css-indicator';
12
12
  export { injectIntoPanelHeaderTop } from './components/editing-panel';
13
- export { EditingPanelTabs, injectIntoSettingsTab } from './components/editing-panel-tabs';
13
+ export { EditingPanelTabs, injectIntoSettingsTab, injectIntoStyleTabContent } from './components/editing-panel-tabs';
14
14
  export { Section } from './components/section';
15
15
  export { SectionContent } from './components/section-content';
16
16
  export { SectionsList } from './components/sections-list';
@@ -18,7 +18,7 @@ export { SettingsControl } from './components/settings-control';
18
18
  export { SettingsTab } from './components/settings-tab';
19
19
  export { SettingsField } from './controls-registry/settings-field';
20
20
  export { StyleIndicator } from './components/style-indicator';
21
- export { injectIntoStyleTab, StyleTabSlot } from './components/style-tab';
21
+ export { injectIntoStyleTab, StyleTab, StyleTabSlot } from './components/style-tab';
22
22
  export { StyleSections } from './components/style-sections';
23
23
  export {
24
24
  STYLE_SECTION_NAMES,
@@ -41,6 +41,7 @@ export { ClassesPropProvider, useClassesProp } from './contexts/classes-prop-con
41
41
  export { ElementProvider, useElement } from './contexts/element-context';
42
42
  export { StyleProvider, useStyle } from './contexts/style-context';
43
43
  export { StyleInheritanceProvider } from './contexts/styles-inheritance-context';
44
+ export { StylesFieldTargetsProvider } from './contexts/styles-field-targets-context';
44
45
  export { Control as BaseControl } from './controls-registry/control';
45
46
  export { ControlTypeContainer } from './controls-registry/control-type-container';
46
47
  export { controlsRegistry, type ControlType } from './controls-registry/controls-registry';
@@ -55,6 +56,7 @@ export { init } from './init';
55
56
  export { usePanelActions, usePanelStatus } from './panel';
56
57
  export { registerStyleProviderToColors } from './provider-colors-registry';
57
58
  export { getFieldIndicators, registerFieldIndicator, FIELD_TYPE } from './field-indicators-registry';
59
+ export { getStylesFieldComponent, type StylesFieldComponent } from './styles-field-registry';
58
60
  export { registerEditingPanelReplacement } from './editing-panel-replacement-registry';
59
61
  export { registerElementPanelDefaults, type ElementPanelDefaults } from './hooks/use-default-panel-settings';
60
62
 
@@ -69,6 +71,7 @@ export {
69
71
  getUpdatedValues,
70
72
  extractOrderedDependencies,
71
73
  } from './utils/prop-dependency-utils';
74
+ export { getElementClassesProp, getElementLocalStyle } from './utils/element-local-style';
72
75
  export {
73
76
  registerSubmenuToggle,
74
77
  type SubmenuToggleProps,
@@ -0,0 +1,79 @@
1
+ import { type ComponentType } from 'react';
2
+ import { type PropKey } from '@elementor/editor-props';
3
+
4
+ import { BorderColorField } from './components/style-sections/border-section/border-color-field';
5
+ import { BorderRadiusField } from './components/style-sections/border-section/border-radius-field';
6
+ import { BorderStyleField } from './components/style-sections/border-section/border-style-field';
7
+ import { BorderWidthField } from './components/style-sections/border-section/border-width-field';
8
+ import { BlendModeField } from './components/style-sections/effects-section/blend-mode-field';
9
+ import { OpacityControlField } from './components/style-sections/effects-section/opacity-control-field';
10
+ import { AlignContentField } from './components/style-sections/layout-section/align-content-field';
11
+ import { AlignItemsField } from './components/style-sections/layout-section/align-items-field';
12
+ import { DisplayField } from './components/style-sections/layout-section/display-field';
13
+ import { FlexDirectionField } from './components/style-sections/layout-section/flex-direction-field';
14
+ import { GapControlField } from './components/style-sections/layout-section/gap-control-field';
15
+ import { GridJustifyItemsField } from './components/style-sections/layout-section/grid-justify-items-field';
16
+ import { JustifyContentField } from './components/style-sections/layout-section/justify-content-field';
17
+ import { WrapField } from './components/style-sections/layout-section/wrap-field';
18
+ import { OffsetField } from './components/style-sections/position-section/offset-field';
19
+ import { PositionField } from './components/style-sections/position-section/position-field';
20
+ import { ZIndexField } from './components/style-sections/position-section/z-index-field';
21
+ import { ObjectFitField } from './components/style-sections/size-section/object-fit-field';
22
+ import { OverflowField } from './components/style-sections/size-section/overflow-field';
23
+ import { ColumnCountField } from './components/style-sections/typography-section/column-count-field';
24
+ import { ColumnGapField } from './components/style-sections/typography-section/column-gap-field';
25
+ import { FontFamilyField } from './components/style-sections/typography-section/font-family-field';
26
+ import { FontSizeField } from './components/style-sections/typography-section/font-size-field';
27
+ import { FontStyleField } from './components/style-sections/typography-section/font-style-field';
28
+ import { FontWeightField } from './components/style-sections/typography-section/font-weight-field';
29
+ import { LetterSpacingField } from './components/style-sections/typography-section/letter-spacing-field';
30
+ import { LineHeightField } from './components/style-sections/typography-section/line-height-field';
31
+ import { TextAlignmentField } from './components/style-sections/typography-section/text-alignment-field';
32
+ import { TextColorField } from './components/style-sections/typography-section/text-color-field';
33
+ import { TextDecorationField } from './components/style-sections/typography-section/text-decoration-field';
34
+ import { TextDirectionField } from './components/style-sections/typography-section/text-direction-field';
35
+ import { TransformField } from './components/style-sections/typography-section/transform-field';
36
+ import { WordSpacingField } from './components/style-sections/typography-section/word-spacing-field';
37
+ import { type StylesFieldLabelProps } from './controls-registry/styles-field';
38
+
39
+ export type StylesFieldComponent = ComponentType< StylesFieldLabelProps >;
40
+
41
+ const stylesFields: Record< PropKey, StylesFieldComponent > = {
42
+ display: DisplayField,
43
+ 'flex-direction': FlexDirectionField,
44
+ 'justify-content': JustifyContentField,
45
+ 'align-items': AlignItemsField,
46
+ 'align-content': AlignContentField,
47
+ 'flex-wrap': WrapField,
48
+ gap: GapControlField,
49
+ 'justify-items': GridJustifyItemsField,
50
+ overflow: OverflowField,
51
+ 'object-fit': ObjectFitField,
52
+ position: PositionField,
53
+ 'z-index': ZIndexField,
54
+ 'scroll-margin-top': OffsetField,
55
+ 'font-family': FontFamilyField,
56
+ 'font-weight': FontWeightField,
57
+ 'font-size': FontSizeField,
58
+ 'text-align': TextAlignmentField,
59
+ color: TextColorField,
60
+ 'line-height': LineHeightField,
61
+ 'letter-spacing': LetterSpacingField,
62
+ 'word-spacing': WordSpacingField,
63
+ 'column-count': ColumnCountField,
64
+ 'column-gap': ColumnGapField,
65
+ 'text-decoration': TextDecorationField,
66
+ 'text-transform': TransformField,
67
+ direction: TextDirectionField,
68
+ 'font-style': FontStyleField,
69
+ 'border-radius': BorderRadiusField,
70
+ 'border-width': BorderWidthField,
71
+ 'border-color': BorderColorField,
72
+ 'border-style': BorderStyleField,
73
+ 'mix-blend-mode': BlendModeField,
74
+ opacity: OpacityControlField,
75
+ };
76
+
77
+ export function getStylesFieldComponent( propKey: PropKey ): StylesFieldComponent | null {
78
+ return stylesFields[ propKey ] ?? null;
79
+ }