@elementor/editor-editing-panel 1.40.0 → 1.41.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 +32 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1177 -732
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1070 -614
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -6
- package/src/action.tsx +26 -0
- package/src/components/add-or-remove-content.tsx +11 -3
- package/src/components/css-classes/css-class-item.tsx +3 -2
- package/src/components/css-classes/css-class-menu.tsx +15 -5
- package/src/components/css-classes/css-class-selector.tsx +1 -0
- package/src/components/css-classes/use-apply-and-unapply-class.ts +8 -4
- package/src/components/section-content.tsx +16 -6
- package/src/components/style-sections/background-section/background-section.tsx +6 -3
- package/src/components/style-sections/border-section/border-field.tsx +3 -0
- package/src/components/style-sections/layout-section/display-field.tsx +2 -1
- package/src/components/style-sections/layout-section/flex-order-field.tsx +5 -2
- package/src/components/style-sections/layout-section/flex-size-field.tsx +16 -12
- package/src/components/style-sections/typography-section/text-stroke-field.tsx +3 -0
- package/src/components/style-tab.tsx +1 -1
- package/src/contexts/style-context.tsx +11 -2
- package/src/contexts/styles-inheritance-context.tsx +9 -7
- package/src/controls-actions.ts +2 -0
- package/src/controls-registry/styles-field.tsx +3 -0
- package/src/init.ts +11 -1
- package/src/reset-style-props.tsx +31 -0
- package/src/styles-inheritance/components/action-icons.tsx +8 -0
- package/src/styles-inheritance/components/breakpoint-icon.tsx +47 -0
- package/src/styles-inheritance/components/index.ts +4 -0
- package/src/styles-inheritance/components/label-chip.tsx +43 -0
- package/src/styles-inheritance/components/value-component.tsx +25 -0
- package/src/styles-inheritance/consts.ts +17 -0
- package/src/styles-inheritance/create-styles-inheritance.ts +50 -12
- package/src/{hooks → styles-inheritance/hooks}/use-normalized-inheritance-chain-items.tsx +41 -11
- package/src/styles-inheritance/init-styles-inheritance-transformers.ts +38 -0
- package/src/styles-inheritance/init.ts +8 -0
- package/src/styles-inheritance/styles-inheritance-indicator.tsx +35 -32
- package/src/styles-inheritance/styles-inheritance-infotip.tsx +113 -19
- package/src/styles-inheritance/styles-inheritance-transformers-registry.tsx +3 -0
- package/src/styles-inheritance/transformers/background-color-overlay-transformer.tsx +27 -0
- package/src/styles-inheritance/transformers/background-gradient-overlay-transformer.tsx +50 -0
- package/src/styles-inheritance/transformers/background-image-overlay-transformer.tsx +79 -0
- package/src/styles-inheritance/transformers/background-overlay-transformer.tsx +20 -0
- package/src/styles-inheritance/types.ts +6 -2
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createTransformer } from '@elementor/editor-canvas';
|
|
3
|
+
import { Stack, styled, UnstableColorIndicator } from '@elementor/ui';
|
|
4
|
+
|
|
5
|
+
export type Color = {
|
|
6
|
+
color: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const backgroundColorOverlayTransformer = createTransformer( ( value: Color ) => (
|
|
10
|
+
<Stack direction="row" gap={ 10 }>
|
|
11
|
+
<ItemIconColor value={ value } />
|
|
12
|
+
<ItemLabelColor value={ value } />
|
|
13
|
+
</Stack>
|
|
14
|
+
) );
|
|
15
|
+
|
|
16
|
+
const ItemIconColor = ( { value }: { value: Color } ) => {
|
|
17
|
+
const { color } = value;
|
|
18
|
+
return <StyledUnstableColorIndicator size="inherit" component="span" value={ color } />;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const ItemLabelColor = ( { value: { color } }: { value: Color } ) => {
|
|
22
|
+
return <span>{ color }</span>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const StyledUnstableColorIndicator = styled( UnstableColorIndicator )( ( { theme } ) => ( {
|
|
26
|
+
borderRadius: `${ theme.shape.borderRadius / 2 }px`,
|
|
27
|
+
} ) );
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createTransformer } from '@elementor/editor-canvas';
|
|
3
|
+
import { Stack } from '@elementor/ui';
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
import { type Color, StyledUnstableColorIndicator } from './background-color-overlay-transformer';
|
|
7
|
+
|
|
8
|
+
type ColorStop = Color & {
|
|
9
|
+
offset: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type Gradient = {
|
|
13
|
+
type: string;
|
|
14
|
+
angle?: number;
|
|
15
|
+
positions?: string;
|
|
16
|
+
stops: ColorStop[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const backgroundGradientOverlayTransformer = createTransformer( ( value: Gradient ) => (
|
|
20
|
+
<Stack direction="row" gap={ 10 }>
|
|
21
|
+
<ItemIconGradient value={ value } />
|
|
22
|
+
<ItemLabelGradient value={ value } />
|
|
23
|
+
</Stack>
|
|
24
|
+
) );
|
|
25
|
+
|
|
26
|
+
const ItemIconGradient = ( { value }: { value: Gradient } ) => {
|
|
27
|
+
const gradient = getGradientValue( value );
|
|
28
|
+
|
|
29
|
+
return <StyledUnstableColorIndicator size="inherit" component="span" value={ gradient } />;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const ItemLabelGradient = ( { value }: { value: Gradient } ) => {
|
|
33
|
+
if ( value.type === 'linear' ) {
|
|
34
|
+
return <span>{ __( 'Linear Gradient', 'elementor' ) }</span>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return <span>{ __( 'Radial Gradient', 'elementor' ) }</span>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const getGradientValue = ( gradient: Gradient ) => {
|
|
41
|
+
const stops = gradient.stops
|
|
42
|
+
?.map( ( { color, offset }: ColorStop ) => `${ color } ${ offset ?? 0 }%` )
|
|
43
|
+
?.join( ',' );
|
|
44
|
+
|
|
45
|
+
if ( gradient.type === 'linear' ) {
|
|
46
|
+
return `linear-gradient(${ gradient.angle }deg, ${ stops })`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return `radial-gradient(circle at ${ gradient.positions }, ${ stops })`;
|
|
50
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createTransformer } from '@elementor/editor-canvas';
|
|
3
|
+
import { EllipsisWithTooltip } from '@elementor/editor-ui';
|
|
4
|
+
import { CardMedia, Stack, type Theme } from '@elementor/ui';
|
|
5
|
+
import { useWpMediaAttachment } from '@elementor/wp-media';
|
|
6
|
+
|
|
7
|
+
type ImageSrcAttachment = { id: number; url: null };
|
|
8
|
+
|
|
9
|
+
type ImageSrcUrl = { url: string; id: null };
|
|
10
|
+
|
|
11
|
+
type Image = {
|
|
12
|
+
image: {
|
|
13
|
+
src: ImageSrcAttachment | ImageSrcUrl;
|
|
14
|
+
size: 'thumbnail' | 'medium' | 'large' | 'full';
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const backgroundImageOverlayTransformer = createTransformer( ( value: Image ) => (
|
|
19
|
+
<Stack direction="row" gap={ 10 }>
|
|
20
|
+
<ItemIconImage value={ value } />
|
|
21
|
+
<ItemLabelImage value={ value } />
|
|
22
|
+
</Stack>
|
|
23
|
+
) );
|
|
24
|
+
|
|
25
|
+
const ItemIconImage = ( { value }: { value: Image } ) => {
|
|
26
|
+
const { imageUrl } = useImage( value );
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<CardMedia
|
|
30
|
+
image={ imageUrl }
|
|
31
|
+
sx={ ( theme: Theme ) => ( {
|
|
32
|
+
height: '1em',
|
|
33
|
+
width: '1em',
|
|
34
|
+
borderRadius: `${ theme.shape.borderRadius / 2 }px`,
|
|
35
|
+
outline: `1px solid ${ theme.palette.action.disabled }`,
|
|
36
|
+
} ) }
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const ItemLabelImage = ( { value }: { value: Image } ) => {
|
|
42
|
+
const { imageTitle } = useImage( value );
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<EllipsisWithTooltip title={ imageTitle }>
|
|
46
|
+
<span>{ imageTitle }</span>
|
|
47
|
+
</EllipsisWithTooltip>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const useImage = ( image: Image ) => {
|
|
52
|
+
let imageTitle,
|
|
53
|
+
imageUrl: string | null = null;
|
|
54
|
+
|
|
55
|
+
const imageSrc = image?.image.src;
|
|
56
|
+
const { data: attachment } = useWpMediaAttachment( imageSrc.id || null );
|
|
57
|
+
|
|
58
|
+
if ( imageSrc.id ) {
|
|
59
|
+
const imageFileTypeExtension = getFileExtensionFromFilename( attachment?.filename );
|
|
60
|
+
imageTitle = `${ attachment?.title }${ imageFileTypeExtension }` || null;
|
|
61
|
+
imageUrl = attachment?.url || null;
|
|
62
|
+
} else if ( imageSrc.url ) {
|
|
63
|
+
imageUrl = imageSrc.url;
|
|
64
|
+
imageTitle = imageUrl?.substring( imageUrl.lastIndexOf( '/' ) + 1 ) || null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return { imageTitle, imageUrl };
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const getFileExtensionFromFilename = ( filename?: string ) => {
|
|
71
|
+
if ( ! filename ) {
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// get the substring after the last . in the filename
|
|
76
|
+
const extension = filename.substring( filename.lastIndexOf( '.' ) + 1 );
|
|
77
|
+
|
|
78
|
+
return `.${ extension }`;
|
|
79
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import { createTransformer } from '@elementor/editor-canvas';
|
|
4
|
+
import { Stack } from '@elementor/ui';
|
|
5
|
+
|
|
6
|
+
type BackgroundOverlay = ReactNode[];
|
|
7
|
+
|
|
8
|
+
export const backgroundOverlayTransformer = createTransformer( ( values: BackgroundOverlay[] ) => {
|
|
9
|
+
if ( ! values || values.length === 0 ) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Stack direction="column">
|
|
15
|
+
{ values.map( ( item, index ) => (
|
|
16
|
+
<Stack key={ index }>{ item }</Stack>
|
|
17
|
+
) ) }
|
|
18
|
+
</Stack>
|
|
19
|
+
);
|
|
20
|
+
} );
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PropValue } from '@elementor/editor-props';
|
|
1
|
+
import { type PropKey, type PropType, type PropValue } from '@elementor/editor-props';
|
|
2
2
|
import { type BreakpointId } from '@elementor/editor-responsive';
|
|
3
3
|
import { type StyleDefinition, type StyleDefinitionState, type StyleDefinitionVariant } from '@elementor/editor-styles';
|
|
4
4
|
|
|
@@ -44,5 +44,9 @@ export type StylesInheritanceSnapshotGetter = (
|
|
|
44
44
|
|
|
45
45
|
export type StylesInheritanceAPI = {
|
|
46
46
|
getSnapshot: ( meta: StyleInheritanceMetaProps ) => StylesInheritanceSnapshot | undefined;
|
|
47
|
-
getInheritanceChain: (
|
|
47
|
+
getInheritanceChain: (
|
|
48
|
+
snapshotField: StylesInheritanceSnapshot,
|
|
49
|
+
path: PropKey[],
|
|
50
|
+
basePropType: PropType
|
|
51
|
+
) => SnapshotPropValue[];
|
|
48
52
|
};
|