@elementor/editor-editing-panel 1.8.1 → 1.9.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 +42 -0
- package/dist/index.d.mts +15 -3
- package/dist/index.d.ts +15 -3
- package/dist/index.js +392 -369
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +378 -358
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -11
- package/src/components/css-class-menu.tsx +2 -2
- package/src/components/css-class-selector.tsx +13 -5
- package/src/components/editable-field.tsx +10 -2
- package/src/components/style-sections/layout-section/flex-size-field.tsx +3 -2
- package/src/components/style-tab.tsx +2 -2
- package/src/contexts/css-class-item-context.tsx +2 -2
- package/src/contexts/style-context.tsx +3 -3
- package/src/controls-registry/settings-field.tsx +2 -2
- package/src/css-classes.ts +2 -2
- package/src/hooks/use-styles-fields.ts +18 -8
- package/src/hooks/use-unapply-class.ts +3 -3
- package/src/index.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-editing-panel",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,20 +39,21 @@
|
|
|
39
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@elementor/editor": "0.17.
|
|
43
|
-
"@elementor/editor-controls": "0.
|
|
44
|
-
"@elementor/editor-elements": "0.
|
|
45
|
-
"@elementor/menus": "0.1.
|
|
46
|
-
"@elementor/editor-props": "0.
|
|
47
|
-
"@elementor/editor-panels": "0.10.
|
|
42
|
+
"@elementor/editor": "0.17.4",
|
|
43
|
+
"@elementor/editor-controls": "0.7.0",
|
|
44
|
+
"@elementor/editor-elements": "0.5.0",
|
|
45
|
+
"@elementor/menus": "0.1.3",
|
|
46
|
+
"@elementor/editor-props": "0.8.0",
|
|
47
|
+
"@elementor/editor-panels": "0.10.4",
|
|
48
48
|
"@elementor/editor-responsive": "0.12.5",
|
|
49
|
-
"@elementor/editor-styles": "0.5.
|
|
50
|
-
"@elementor/editor-styles-repository": "0.
|
|
49
|
+
"@elementor/editor-styles": "0.5.3",
|
|
50
|
+
"@elementor/editor-styles-repository": "0.5.0",
|
|
51
51
|
"@elementor/editor-v1-adapters": "0.9.0",
|
|
52
|
-
"@elementor/icons": "
|
|
52
|
+
"@elementor/icons": "1.24.0",
|
|
53
|
+
"@elementor/locations": "0.7.6",
|
|
53
54
|
"@elementor/schema": "0.1.2",
|
|
54
55
|
"@elementor/session": "0.1.0",
|
|
55
|
-
"@elementor/ui": "
|
|
56
|
+
"@elementor/ui": "1.23.3",
|
|
56
57
|
"@elementor/utils": "0.3.0",
|
|
57
58
|
"@wordpress/i18n": "^5.13.0"
|
|
58
59
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type RefObject } from 'react';
|
|
3
|
-
import { type
|
|
3
|
+
import { type StyleDefinitionState } from '@elementor/editor-styles';
|
|
4
4
|
import { CheckIcon } from '@elementor/icons';
|
|
5
5
|
import { createMenu } from '@elementor/menus';
|
|
6
6
|
import {
|
|
@@ -68,7 +68,7 @@ export function CssClassMenu( {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
type StateMenuItemProps = {
|
|
71
|
-
state:
|
|
71
|
+
state: StyleDefinitionState;
|
|
72
72
|
disabled?: boolean;
|
|
73
73
|
};
|
|
74
74
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useId, useRef } from 'react';
|
|
3
|
-
import { getElementSetting,
|
|
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';
|
|
6
6
|
import {
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
useCreateActionsByProvider,
|
|
12
12
|
} from '@elementor/editor-styles-repository';
|
|
13
13
|
import { DotsVerticalIcon } from '@elementor/icons';
|
|
14
|
+
import { createLocation } from '@elementor/locations';
|
|
14
15
|
import {
|
|
15
16
|
type AutocompleteRenderGetTagProps,
|
|
16
17
|
bindTrigger,
|
|
@@ -48,6 +49,8 @@ const EMPTY_OPTION = {
|
|
|
48
49
|
provider: ELEMENTS_STYLES_PROVIDER_KEY,
|
|
49
50
|
} satisfies StyleDefOption;
|
|
50
51
|
|
|
52
|
+
export const { Slot: ClassSelectorActionsSlot, inject: injectIntoClassSelectorActions } = createLocation();
|
|
53
|
+
|
|
51
54
|
/**
|
|
52
55
|
* Applied - Classes applied to an element.
|
|
53
56
|
* Active - Class that is currently on edit mode.
|
|
@@ -69,9 +72,14 @@ export function CssClassSelector() {
|
|
|
69
72
|
|
|
70
73
|
return (
|
|
71
74
|
<Stack gap={ 1 } p={ 2 }>
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
<Stack direction="row" gap={ 1 } alignItems="baseline" justifyContent="space-between">
|
|
76
|
+
<Typography component="label" variant="caption" htmlFor={ ID }>
|
|
77
|
+
{ __( 'CSS Classes', 'elementor' ) }
|
|
78
|
+
</Typography>
|
|
79
|
+
<Stack direction="row" gap={ 1 }>
|
|
80
|
+
<ClassSelectorActionsSlot />
|
|
81
|
+
</Stack>
|
|
82
|
+
</Stack>
|
|
75
83
|
<MultiCombobox
|
|
76
84
|
id={ ID }
|
|
77
85
|
size="tiny"
|
|
@@ -321,7 +329,7 @@ function useAppliedClassesIds() {
|
|
|
321
329
|
const value = useElementSetting< ClassesPropValue >( element.id, currentClassesProp )?.value || [];
|
|
322
330
|
|
|
323
331
|
const setValue = ( ids: StyleDefinitionID[] ) => {
|
|
324
|
-
|
|
332
|
+
updateElementSettings( {
|
|
325
333
|
id: element.id,
|
|
326
334
|
props: {
|
|
327
335
|
[ currentClassesProp ]: classesPropTypeUtil.create( ids ),
|
|
@@ -86,7 +86,7 @@ export const EditableFieldProvider = ( {
|
|
|
86
86
|
|
|
87
87
|
type EditableFieldProps = ComponentProps< 'div' >;
|
|
88
88
|
|
|
89
|
-
export const EditableField = ( { children, ...props }: EditableFieldProps ) => {
|
|
89
|
+
export const EditableField = ( { children, onClick, ...props }: EditableFieldProps ) => {
|
|
90
90
|
const ref = useRef< HTMLElement >( null );
|
|
91
91
|
const { isEditing, closeEditMode, value, onChange, error, submit, editable } = useEditableField();
|
|
92
92
|
|
|
@@ -110,6 +110,14 @@ export const EditableField = ( { children, ...props }: EditableFieldProps ) => {
|
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
+
const handleClick = ( event: React.MouseEvent< HTMLDivElement > ) => {
|
|
114
|
+
if ( isEditing ) {
|
|
115
|
+
event.stopPropagation();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
onClick?.( event );
|
|
119
|
+
};
|
|
120
|
+
|
|
113
121
|
const selectAll = () => {
|
|
114
122
|
const selection = getSelection();
|
|
115
123
|
|
|
@@ -131,7 +139,7 @@ export const EditableField = ( { children, ...props }: EditableFieldProps ) => {
|
|
|
131
139
|
return (
|
|
132
140
|
<Tooltip open={ !! error } title={ error } placement="top">
|
|
133
141
|
{ /* eslint-disable-next-line jsx-a11y/no-static-element-interactions */ }
|
|
134
|
-
<div onKeyDown={ handleKeyDown } { ...props }>
|
|
142
|
+
<div onKeyDown={ handleKeyDown } onClick={ handleClick } { ...props }>
|
|
135
143
|
<span
|
|
136
144
|
ref={ ref }
|
|
137
145
|
role="textbox"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { useMemo, useState } from 'react';
|
|
2
3
|
import {
|
|
3
4
|
ControlLabel,
|
|
4
5
|
ControlToggleButtonGroup,
|
|
@@ -50,8 +51,8 @@ export const FlexSizeField = () => {
|
|
|
50
51
|
shrink = shrinkField?.value || null,
|
|
51
52
|
basis = basisField?.value || null;
|
|
52
53
|
|
|
53
|
-
const currentGroup =
|
|
54
|
-
[ activeGroup, setActiveGroup ] =
|
|
54
|
+
const currentGroup = useMemo( () => getActiveGroup( { grow, shrink, basis } ), [ grow, shrink, basis ] ),
|
|
55
|
+
[ activeGroup, setActiveGroup ] = useState( currentGroup );
|
|
55
56
|
|
|
56
57
|
const onChangeGroup = ( group: GroupItem | null = null ) => {
|
|
57
58
|
setActiveGroup( group );
|
|
@@ -3,7 +3,7 @@ import { useState } from 'react';
|
|
|
3
3
|
import { useElementSetting, useElementStyles } from '@elementor/editor-elements';
|
|
4
4
|
import { type ClassesPropValue, type PropKey } from '@elementor/editor-props';
|
|
5
5
|
import { useActiveBreakpoint } from '@elementor/editor-responsive';
|
|
6
|
-
import { type StyleDefinitionID, type
|
|
6
|
+
import { type StyleDefinitionID, type StyleDefinitionState } from '@elementor/editor-styles';
|
|
7
7
|
import { SessionStorageProvider } from '@elementor/session';
|
|
8
8
|
import { Divider } from '@elementor/ui';
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
@@ -28,7 +28,7 @@ const CLASSES_PROP_KEY = 'classes';
|
|
|
28
28
|
export const StyleTab = () => {
|
|
29
29
|
const currentClassesProp = useCurrentClassesProp();
|
|
30
30
|
const [ activeStyleDefId, setActiveStyleDefId ] = useActiveStyleDefId( currentClassesProp );
|
|
31
|
-
const [ activeStyleState, setActiveStyleState ] = useState<
|
|
31
|
+
const [ activeStyleState, setActiveStyleState ] = useState< StyleDefinitionState | null >( null );
|
|
32
32
|
const breakpoint = useActiveBreakpoint();
|
|
33
33
|
|
|
34
34
|
return (
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { createContext, type PropsWithChildren } from 'react';
|
|
2
|
+
import { createContext, type PropsWithChildren, useContext } from 'react';
|
|
3
3
|
|
|
4
4
|
type ClassItemContextType = {
|
|
5
5
|
styleId: string;
|
|
@@ -21,7 +21,7 @@ export function CssClassItemProvider( { styleId, isGlobal, isActive, children }:
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export function useCssClassItem() {
|
|
24
|
-
const context =
|
|
24
|
+
const context = useContext( ClassItemContext );
|
|
25
25
|
|
|
26
26
|
if ( ! context ) {
|
|
27
27
|
throw new Error( 'useCssClassItem must be used within a CssClassItemProvider' );
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { createContext, type Dispatch, type PropsWithChildren, useContext } from 'react';
|
|
3
|
-
import { type StyleDefinition, type
|
|
3
|
+
import { type StyleDefinition, type StyleDefinitionState, type StyleDefinitionVariant } from '@elementor/editor-styles';
|
|
4
4
|
|
|
5
5
|
type ContextValue = {
|
|
6
6
|
id: StyleDefinition[ 'id' ] | null;
|
|
7
7
|
setId: Dispatch< StyleDefinition[ 'id' ] | null >;
|
|
8
|
-
meta:
|
|
9
|
-
setMetaState: Dispatch<
|
|
8
|
+
meta: StyleDefinitionVariant[ 'meta' ];
|
|
9
|
+
setMetaState: Dispatch< StyleDefinitionState >;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
const Context = createContext< ContextValue | null >( null );
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { PropKeyProvider, PropProvider } from '@elementor/editor-controls';
|
|
3
|
-
import {
|
|
3
|
+
import { updateElementSettings, useElementSetting } from '@elementor/editor-elements';
|
|
4
4
|
import { type PropKey, type PropValue } from '@elementor/editor-props';
|
|
5
5
|
|
|
6
6
|
import { useElement } from '../contexts/element-context';
|
|
@@ -20,7 +20,7 @@ export const SettingsField = ( { bind, children }: Props ) => {
|
|
|
20
20
|
const propType = createTopLevelOjectType( { schema: elementType.propsSchema } );
|
|
21
21
|
|
|
22
22
|
const setValue = ( newValue: Record< string, PropValue > ) => {
|
|
23
|
-
|
|
23
|
+
updateElementSettings( {
|
|
24
24
|
id: element.id,
|
|
25
25
|
props: { ...newValue },
|
|
26
26
|
} );
|
package/src/css-classes.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type StyleDefinitionState } from '@elementor/editor-styles';
|
|
2
2
|
|
|
3
3
|
import { registerGlobalClassMenuItem, registerStateMenuItem } from './components/css-class-menu';
|
|
4
4
|
import { useCssClassItem } from './contexts/css-class-item-context';
|
|
5
5
|
import { useUnapplyClass } from './hooks/use-unapply-class';
|
|
6
6
|
|
|
7
|
-
const STATES: NonNullable<
|
|
7
|
+
const STATES: NonNullable< StyleDefinitionState >[] = [ 'hover', 'focus', 'active' ];
|
|
8
8
|
|
|
9
9
|
export function initCssClasses() {
|
|
10
10
|
registerStateItems();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createElementStyle, updateElementStyle, useElementStyleProps } from '@elementor/editor-elements';
|
|
2
2
|
import type { Props } from '@elementor/editor-props';
|
|
3
3
|
import { __ } from '@wordpress/i18n';
|
|
4
4
|
|
|
@@ -18,14 +18,24 @@ export function useStylesFields< T extends Props >( propNames: ( keyof T & strin
|
|
|
18
18
|
propNames,
|
|
19
19
|
} );
|
|
20
20
|
|
|
21
|
-
const setValue = (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
const setValue = ( props: T ) => {
|
|
22
|
+
if ( id === null ) {
|
|
23
|
+
createElementStyle( {
|
|
24
|
+
elementId: element.id,
|
|
25
|
+
classesProp,
|
|
26
|
+
meta,
|
|
27
|
+
props,
|
|
28
|
+
label: __( 'local', 'elementor' ),
|
|
29
|
+
} );
|
|
30
|
+
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
updateElementStyle( {
|
|
35
|
+
elementId: element.id,
|
|
36
|
+
styleId: id,
|
|
37
|
+
props,
|
|
26
38
|
meta,
|
|
27
|
-
bind: classesProp,
|
|
28
|
-
label: __( 'local', 'elementor' ),
|
|
29
39
|
} );
|
|
30
40
|
};
|
|
31
41
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { updateElementSettings, useElementSetting } from '@elementor/editor-elements';
|
|
2
2
|
import { type ClassesPropValue } from '@elementor/editor-props';
|
|
3
3
|
|
|
4
4
|
import { useClassesProp } from '../contexts/classes-prop-context';
|
|
@@ -9,10 +9,10 @@ export const useUnapplyClass = ( classId: string ) => {
|
|
|
9
9
|
const classesProp = useClassesProp();
|
|
10
10
|
|
|
11
11
|
const classes = useElementSetting< ClassesPropValue >( element.id, classesProp );
|
|
12
|
-
const filteredClasses = classes?.value.filter( ( className ) => className !== classId );
|
|
12
|
+
const filteredClasses = classes?.value.filter( ( className ) => className !== classId ) ?? [];
|
|
13
13
|
|
|
14
14
|
return () => {
|
|
15
|
-
|
|
15
|
+
updateElementSettings( {
|
|
16
16
|
id: element.id,
|
|
17
17
|
props: {
|
|
18
18
|
[ classesProp ]: {
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,8 @@ export { useBoundProp } from '@elementor/editor-controls';
|
|
|
2
2
|
export type { PopoverActionProps } from './popover-action';
|
|
3
3
|
export { replaceControl } from './control-replacement';
|
|
4
4
|
export { registerGlobalClassMenuItem, registerStateMenuItem } from './components/css-class-menu';
|
|
5
|
+
export { injectIntoClassSelectorActions } from './components/css-class-selector';
|
|
6
|
+
export { usePanelActions, usePanelStatus } from './panel';
|
|
5
7
|
|
|
6
8
|
import init from './init';
|
|
7
9
|
|