@elementor/editor-editing-panel 4.5.0-1180 → 4.5.0-1182

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-editing-panel",
3
- "version": "4.5.0-1180",
3
+ "version": "4.5.0-1182",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,32 +39,32 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor": "4.5.0-1180",
43
- "@elementor/editor-canvas": "4.5.0-1180",
44
- "@elementor/editor-controls": "4.5.0-1180",
45
- "@elementor/editor-current-user": "4.5.0-1180",
46
- "@elementor/editor-documents": "4.5.0-1180",
47
- "@elementor/editor-elements": "4.5.0-1180",
48
- "@elementor/editor-interactions": "4.5.0-1180",
49
- "@elementor/editor-notifications": "4.5.0-1180",
50
- "@elementor/editor-panels": "4.5.0-1180",
51
- "@elementor/editor-props": "4.5.0-1180",
52
- "@elementor/editor-responsive": "4.5.0-1180",
53
- "@elementor/editor-styles": "4.5.0-1180",
54
- "@elementor/editor-styles-repository": "4.5.0-1180",
55
- "@elementor/editor-ui": "4.5.0-1180",
56
- "@elementor/editor-v1-adapters": "4.5.0-1180",
57
- "@elementor/http-client": "4.5.0-1180",
42
+ "@elementor/editor": "4.5.0-1182",
43
+ "@elementor/editor-canvas": "4.5.0-1182",
44
+ "@elementor/editor-controls": "4.5.0-1182",
45
+ "@elementor/editor-current-user": "4.5.0-1182",
46
+ "@elementor/editor-documents": "4.5.0-1182",
47
+ "@elementor/editor-elements": "4.5.0-1182",
48
+ "@elementor/editor-interactions": "4.5.0-1182",
49
+ "@elementor/editor-notifications": "4.5.0-1182",
50
+ "@elementor/editor-panels": "4.5.0-1182",
51
+ "@elementor/editor-props": "4.5.0-1182",
52
+ "@elementor/editor-responsive": "4.5.0-1182",
53
+ "@elementor/editor-styles": "4.5.0-1182",
54
+ "@elementor/editor-styles-repository": "4.5.0-1182",
55
+ "@elementor/editor-ui": "4.5.0-1182",
56
+ "@elementor/editor-v1-adapters": "4.5.0-1182",
57
+ "@elementor/http-client": "4.5.0-1182",
58
58
  "@elementor/icons": "~1.78.1",
59
- "@elementor/editor-variables": "4.5.0-1180",
60
- "@elementor/locations": "4.5.0-1180",
61
- "@elementor/menus": "4.5.0-1180",
62
- "@elementor/query": "4.5.0-1180",
63
- "@elementor/schema": "4.5.0-1180",
64
- "@elementor/session": "4.5.0-1180",
59
+ "@elementor/editor-variables": "4.5.0-1182",
60
+ "@elementor/locations": "4.5.0-1182",
61
+ "@elementor/menus": "4.5.0-1182",
62
+ "@elementor/query": "4.5.0-1182",
63
+ "@elementor/schema": "4.5.0-1182",
64
+ "@elementor/session": "4.5.0-1182",
65
65
  "@elementor/ui": "1.41.4",
66
- "@elementor/utils": "4.5.0-1180",
67
- "@elementor/wp-media": "4.5.0-1180",
66
+ "@elementor/utils": "4.5.0-1182",
67
+ "@elementor/wp-media": "4.5.0-1182",
68
68
  "@wordpress/i18n": "^5.13.0"
69
69
  },
70
70
  "peerDependencies": {
@@ -38,6 +38,7 @@ import {
38
38
  type ValidationEvent,
39
39
  type ValidationResult,
40
40
  } from '../creatable-autocomplete';
41
+ import { StyleTabHeaderSlot } from '../style-tab-header-location';
41
42
  import { CssClassItem } from './css-class-item';
42
43
  import { MissingClassesAlert } from './missing-classes-alert';
43
44
  import {
@@ -82,6 +83,7 @@ export const { Slot: ClassSelectorActionsSlot, inject: injectIntoClassSelectorAc
82
83
  */
83
84
 
84
85
  export function CssClassSelector() {
86
+ const { element } = useElement();
85
87
  const options = useOptions();
86
88
 
87
89
  const { id: activeId, setId: setActiveId } = useStyle();
@@ -117,6 +119,7 @@ export function CssClassSelector() {
117
119
  { __( 'Classes', 'elementor' ) }
118
120
  </FormLabel>
119
121
  <Stack direction="row" gap={ 1 }>
122
+ <StyleTabHeaderSlot elementId={ element.id } />
120
123
  <ClassSelectorActionsSlot />
121
124
  </Stack>
122
125
  </Stack>
@@ -0,0 +1,11 @@
1
+ import { createLocation } from '@elementor/locations';
2
+
3
+ export type CustomCssHeaderProps = {
4
+ elementId: string;
5
+ };
6
+
7
+ export const {
8
+ Slot: CustomCssHeaderSlot,
9
+ inject: injectIntoCustomCssHeader,
10
+ useInjections: useCustomCssHeaderInjections,
11
+ } = createLocation< CustomCssHeaderProps >();
@@ -9,11 +9,20 @@ type Props = PropsWithChildren< {
9
9
  title: string;
10
10
  defaultExpanded?: boolean;
11
11
  titleEnd?: CollapsibleValue< ReactNode | string >;
12
+ titleActions?: ReactNode;
12
13
  unmountOnExit?: boolean;
13
14
  action?: { component: ReactNode; onClick: () => void };
14
15
  } >;
15
16
 
16
- export function Section( { title, children, defaultExpanded = false, titleEnd, unmountOnExit = true, action }: Props ) {
17
+ export function Section( {
18
+ title,
19
+ children,
20
+ defaultExpanded = false,
21
+ titleEnd,
22
+ titleActions,
23
+ unmountOnExit = true,
24
+ action,
25
+ }: Props ) {
17
26
  const [ isOpen, setIsOpen ] = useStateByElement( title, !! defaultExpanded );
18
27
  const ref = useRef< HTMLElement >( null );
19
28
  const isDisabled = !! action;
@@ -46,6 +55,15 @@ export function Section( { title, children, defaultExpanded = false, titleEnd, u
46
55
  sx={ { flexGrow: 0, flexShrink: 1, marginInlineEnd: 1 } }
47
56
  />
48
57
  { getCollapsibleValue( titleEnd, isOpen ) }
58
+ { titleActions && (
59
+ <Stack
60
+ direction="row"
61
+ alignItems="center"
62
+ onClick={ ( event: React.MouseEvent ) => event.stopPropagation() }
63
+ >
64
+ { titleActions }
65
+ </Stack>
66
+ ) }
49
67
  </Stack>
50
68
  { action?.component }
51
69
  <CollapseIcon
@@ -0,0 +1,29 @@
1
+ import { type ComponentType, createElement } from 'react';
2
+ import { type ElementID } from '@elementor/editor-elements';
3
+ import { createLocation, type InjectArgs } from '@elementor/locations';
4
+
5
+ export type StyleSectionHeaderProps = {
6
+ elementId: ElementID;
7
+ sectionName: string;
8
+ };
9
+
10
+ const { Slot: StyleSectionHeaderSlot, inject: injectStyleSectionHeader } = createLocation< StyleSectionHeaderProps >();
11
+
12
+ type StyleSectionHeaderInjectArgs = Pick< InjectArgs< StyleSectionHeaderProps >, 'id' | 'component' > & {
13
+ sections?: string[];
14
+ options?: InjectArgs< StyleSectionHeaderProps >[ 'options' ];
15
+ };
16
+
17
+ export const injectIntoStyleSectionHeader = ( { id, component, sections, options }: StyleSectionHeaderInjectArgs ) => {
18
+ const filteredComponent: ComponentType< StyleSectionHeaderProps > = ( props ) => {
19
+ if ( sections && ! sections.includes( props.sectionName ) ) {
20
+ return null;
21
+ }
22
+
23
+ return createElement( component, props );
24
+ };
25
+
26
+ injectStyleSectionHeader( { id, component: filteredComponent, options } );
27
+ };
28
+
29
+ export { StyleSectionHeaderSlot };
@@ -0,0 +1,12 @@
1
+ import { type ElementID } from '@elementor/editor-elements';
2
+ import { createLocation } from '@elementor/locations';
3
+
4
+ export type StyleTabHeaderProps = {
5
+ elementId: ElementID;
6
+ };
7
+
8
+ export const {
9
+ Slot: StyleTabHeaderSlot,
10
+ inject: injectIntoStyleTabHeader,
11
+ useInjections: useStyleTabHeaderInjections,
12
+ } = createLocation< StyleTabHeaderProps >();
@@ -1,8 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import type { ReactNode } from 'react';
3
3
 
4
+ import { useElement } from '../contexts/element-context';
4
5
  import { useDefaultPanelSettings } from '../hooks/use-default-panel-settings';
5
6
  import { Section } from './section';
7
+ import { StyleSectionHeaderSlot } from './style-section-header-location';
6
8
  import { getStylesInheritanceIndicators } from './style-tab-collapsible-content';
7
9
 
8
10
  type SectionType = {
@@ -16,6 +18,7 @@ type Props = { section: SectionType; fields?: string[]; unmountOnExit?: boolean
16
18
 
17
19
  export const StyleTabSection = ( { section, fields = [], unmountOnExit = true }: Props ) => {
18
20
  const { component, name, title, action } = section;
21
+ const { element } = useElement();
19
22
  const tabDefaults = useDefaultPanelSettings();
20
23
  const SectionComponent = component || ( () => <></> );
21
24
  const isExpanded = tabDefaults.defaultSectionsExpanded.style?.includes( name );
@@ -25,6 +28,9 @@ export const StyleTabSection = ( { section, fields = [], unmountOnExit = true }:
25
28
  title={ title }
26
29
  defaultExpanded={ isExpanded }
27
30
  titleEnd={ getStylesInheritanceIndicators( fields ) }
31
+ titleActions={
32
+ element ? <StyleSectionHeaderSlot elementId={ element.id } sectionName={ name } /> : undefined
33
+ }
28
34
  unmountOnExit={ unmountOnExit }
29
35
  action={ action }
30
36
  >
@@ -87,7 +87,7 @@ const controlTypes = {
87
87
  toggle: { component: ToggleControl, layout: 'full', propTypeUtil: stringPropTypeUtil },
88
88
  'date-time': { component: DateTimeControl, layout: 'full', propTypeUtil: DateTimePropTypeUtil },
89
89
  video: { component: VideoMediaControl, layout: 'full', propTypeUtil: videoSrcPropTypeUtil },
90
- 'inline-editing': { component: InlineEditingControl, layout: 'full', propTypeUtil: escapedHtmlPropTypeUtil },
90
+ 'inline-editing': { component: InlineEditingControl, layout: 'custom', propTypeUtil: escapedHtmlPropTypeUtil },
91
91
  email: { component: EmailFormActionControl, layout: 'custom', propTypeUtil: emailsPropTypeUtil },
92
92
  'date-range': {
93
93
  component: DateRangeControl,
@@ -2,18 +2,32 @@ import * as React from 'react';
2
2
  import { useId } from 'react';
3
3
  import { ControlFormLabel, Repeater, type RepeaterItem, type SetRepeaterValuesMeta } from '@elementor/editor-controls';
4
4
  import {
5
+ type Control,
6
+ type ControlItem,
7
+ getElementType,
5
8
  updateElementEditorSettings,
6
9
  useElementChildren,
7
10
  useElementEditorSettings,
8
11
  type V1Element,
9
12
  } from '@elementor/editor-elements';
10
13
  import { type CreateOptions } from '@elementor/editor-props';
14
+ import { SessionStorageProvider } from '@elementor/session';
11
15
  import { Stack, TextField } from '@elementor/ui';
12
16
  import { __ } from '@wordpress/i18n';
13
17
 
14
- import { useElement } from '../../../contexts/element-context';
18
+ import { SettingsControl } from '../../../components/settings-control';
19
+ import { ElementProvider, useElement } from '../../../contexts/element-context';
15
20
  import { getElementByType } from '../get-element-by-type';
16
- import { MENU_ENTRY_ELEMENT_TYPE, MENU_ITEMS_ELEMENT_TYPE, type MenuItem, useActions } from './use-actions';
21
+ import {
22
+ MENU_ENTRY_ELEMENT_TYPE,
23
+ MENU_ITEM_ELEMENT_TYPE,
24
+ MENU_ITEMS_ELEMENT_TYPE,
25
+ type MenuItem,
26
+ useActions,
27
+ } from './use-actions';
28
+ import { useEntryItem } from './use-entry-item';
29
+
30
+ const LINK_BIND = 'link';
17
31
 
18
32
  export const MenuItemsControl = ( { label }: { label: string } ) => {
19
33
  const { element } = useElement();
@@ -48,7 +62,7 @@ export const MenuItemsControl = ( { label }: { label: string } ) => {
48
62
  }
49
63
 
50
64
  if ( meta?.action?.type === 'remove' ) {
51
- return removeItem( { items: meta.action.payload } );
65
+ return removeItem( { menuItemsId: menuItems.id, items: meta.action.payload } );
52
66
  }
53
67
 
54
68
  if ( meta?.action?.type === 'duplicate' ) {
@@ -109,6 +123,7 @@ const ItemContent = ( { value }: { value: MenuItem } ) => {
109
123
  return (
110
124
  <Stack p={ 2 } gap={ 1.5 }>
111
125
  <ItemNameControl elementId={ value.id } />
126
+ <ItemLinkControl entryId={ value.id } />
112
127
  </Stack>
113
128
  );
114
129
  };
@@ -119,7 +134,7 @@ const ItemNameControl = ( { elementId }: { elementId: string } ) => {
119
134
 
120
135
  return (
121
136
  <Stack gap={ 1 }>
122
- <ControlFormLabel htmlFor={ inputId }>{ __( 'Name', 'elementor' ) }</ControlFormLabel>
137
+ <ControlFormLabel htmlFor={ inputId }>{ __( 'Item name', 'elementor' ) }</ControlFormLabel>
123
138
  <TextField
124
139
  id={ inputId }
125
140
  size="tiny"
@@ -131,3 +146,43 @@ const ItemNameControl = ( { elementId }: { elementId: string } ) => {
131
146
  </Stack>
132
147
  );
133
148
  };
149
+
150
+ const ItemLinkControl = ( { entryId }: { entryId: string } ) => {
151
+ const { itemId, settings } = useEntryItem( entryId );
152
+ const elementType = itemId ? getElementType( MENU_ITEM_ELEMENT_TYPE ) : null;
153
+ const linkControl = elementType ? findControlByBind( elementType.controls, LINK_BIND ) : null;
154
+
155
+ if ( ! itemId || ! elementType || ! linkControl ) {
156
+ return null;
157
+ }
158
+
159
+ return (
160
+ <ElementProvider
161
+ element={ { id: itemId, type: MENU_ITEM_ELEMENT_TYPE } }
162
+ elementType={ elementType }
163
+ settings={ settings }
164
+ >
165
+ <SessionStorageProvider prefix={ itemId }>
166
+ <SettingsControl control={ linkControl } />
167
+ </SessionStorageProvider>
168
+ </ElementProvider>
169
+ );
170
+ };
171
+
172
+ const findControlByBind = ( items: ControlItem[], bind: string ): Control | null => {
173
+ for ( const item of items ) {
174
+ if ( item.type === 'section' ) {
175
+ const found = findControlByBind( item.value.items, bind );
176
+
177
+ if ( found ) {
178
+ return found;
179
+ }
180
+ }
181
+
182
+ if ( item.type === 'control' && item.value.bind === bind ) {
183
+ return item;
184
+ }
185
+ }
186
+
187
+ return null;
188
+ };
@@ -19,7 +19,8 @@ export type MenuItem = {
19
19
 
20
20
  export const MENU_ITEMS_ELEMENT_TYPE = 'e-menu-items';
21
21
  export const MENU_ENTRY_ELEMENT_TYPE = 'e-menu-entry';
22
- const MENU_ITEM_ELEMENT_TYPE = 'e-menu-item';
22
+ export const MENU_ITEM_ELEMENT_TYPE = 'e-menu-item';
23
+ const MIN_ENTRIES = 1;
23
24
  const PARAGRAPH_WIDGET_TYPE = 'e-paragraph';
24
25
 
25
26
  const getEntryTitle = () => __( 'Menu item', 'elementor' );
@@ -69,10 +70,20 @@ export const useActions = () => {
69
70
  } );
70
71
  };
71
72
 
72
- const removeItem = ( { items }: { items: ItemsActionPayload< MenuItem > } ) => {
73
+ const removeItem = ( { menuItemsId, items }: { menuItemsId: string; items: ItemsActionPayload< MenuItem > } ) => {
74
+ const entriesCount =
75
+ getContainer( menuItemsId )?.children?.filter(
76
+ ( child ) => child.model.get( 'elType' ) === MENU_ENTRY_ELEMENT_TYPE
77
+ ).length ?? 0;
78
+ const removableCount = Math.max( 0, Math.min( items.length, entriesCount - MIN_ENTRIES ) );
79
+
80
+ if ( removableCount === 0 ) {
81
+ return;
82
+ }
83
+
73
84
  removeElements( {
74
85
  title: __( 'Menu', 'elementor' ),
75
- elementIds: items.map( ( { item } ) => item.id ),
86
+ elementIds: items.slice( 0, removableCount ).map( ( { item } ) => item.id ),
76
87
  } );
77
88
  };
78
89
 
@@ -0,0 +1,33 @@
1
+ import { type ElementID, getContainer, getElementSettings, getElementType } from '@elementor/editor-elements';
2
+ import { type AnyTransformable } from '@elementor/editor-props';
3
+ import { __privateUseListenTo as useListenTo, commandEndEvent } from '@elementor/editor-v1-adapters';
4
+
5
+ import { MENU_ITEM_ELEMENT_TYPE } from './use-actions';
6
+
7
+ type EntryItem = {
8
+ itemId: ElementID | null;
9
+ settings: Record< string, AnyTransformable | null >;
10
+ };
11
+
12
+ export const useEntryItem = ( entryId: ElementID ): EntryItem => {
13
+ return useListenTo(
14
+ [ commandEndEvent( 'document/elements/set-settings' ), commandEndEvent( 'document/elements/settings' ) ],
15
+ () => {
16
+ const item = getContainer( entryId )?.children?.find(
17
+ ( child ) => child.model.get( 'elType' ) === MENU_ITEM_ELEMENT_TYPE
18
+ );
19
+
20
+ return {
21
+ itemId: item?.id ?? null,
22
+ settings: item ? getEntrySettings( item.id ) : {},
23
+ };
24
+ },
25
+ [ entryId ]
26
+ );
27
+ };
28
+
29
+ const getEntrySettings = ( itemId: ElementID ): EntryItem[ 'settings' ] => {
30
+ const propsSchema = getElementType( MENU_ITEM_ELEMENT_TYPE )?.propsSchema ?? {};
31
+
32
+ return getElementSettings< AnyTransformable >( itemId, Object.keys( propsSchema ) );
33
+ };
package/src/index.ts CHANGED
@@ -28,6 +28,13 @@ export { PseudoStateMenuItems } from './components/style-states/pseudo-state-men
28
28
  export { usePseudoStates } from './components/style-states/use-pseudo-states';
29
29
  export { injectIntoGridFields } from './components/style-sections/layout-section/layout-section';
30
30
  export { StyleTabSection } from './components/style-tab-section';
31
+ export {
32
+ CustomCssHeaderSlot,
33
+ injectIntoCustomCssHeader,
34
+ type CustomCssHeaderProps,
35
+ } from './components/custom-css-header-location';
36
+ export { injectIntoStyleSectionHeader, type StyleSectionHeaderProps } from './components/style-section-header-location';
37
+ export { injectIntoStyleTabHeader, type StyleTabHeaderProps } from './components/style-tab-header-location';
31
38
  export { ClassesPropProvider, useClassesProp } from './contexts/classes-prop-context';
32
39
  export { ElementProvider, useElement } from './contexts/element-context';
33
40
  export { StyleProvider, useStyle } from './contexts/style-context';
package/src/init.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { injectIntoLogic } from '@elementor/editor';
2
+ import { init as initEditorControls } from '@elementor/editor-controls';
2
3
  import { registerPanel } from '@elementor/editor-panels';
3
4
  import { blockCommand } from '@elementor/editor-v1-adapters';
4
5
 
@@ -12,6 +13,8 @@ import { init as initStylesInheritance } from './styles-inheritance/init';
12
13
  import { isAtomicWidgetSelected } from './sync/is-atomic-widget-selected';
13
14
 
14
15
  export function init() {
16
+ initEditorControls();
17
+
15
18
  registerPanel( panel );
16
19
  blockV1Panel();
17
20