@elementor/editor-controls 0.19.0 → 0.20.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elementor/editor-controls",
3
3
  "description": "This package contains the controls model and utils for the Elementor editor",
4
- "version": "0.19.0",
4
+ "version": "0.20.0",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -41,14 +41,15 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@elementor/editor-current-user": "0.3.0",
44
- "@elementor/editor-elements": "0.6.5",
44
+ "@elementor/editor-elements": "0.7.0",
45
45
  "@elementor/editor-props": "0.11.1",
46
+ "@elementor/editor-ui": "0.5.0",
46
47
  "@elementor/env": "0.3.5",
47
48
  "@elementor/http": "0.1.4",
48
49
  "@elementor/icons": "1.37.0",
49
50
  "@elementor/query": "0.2.4",
50
51
  "@elementor/session": "0.1.0",
51
- "@elementor/ui": "1.26.0",
52
+ "@elementor/ui": "1.32.1",
52
53
  "@elementor/utils": "0.4.0",
53
54
  "@elementor/wp-media": "0.6.0",
54
55
  "@tanstack/react-virtual": "3.13.3",
@@ -1,7 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { forwardRef, useId } from 'react';
3
3
  import { type PropValue } from '@elementor/editor-props';
4
- import { bindMenu, bindTrigger, Button, InputAdornment, Menu, MenuItem, TextField, usePopupState } from '@elementor/ui';
4
+ import { MenuListItem } from '@elementor/editor-ui';
5
+ import { bindMenu, bindTrigger, Button, InputAdornment, Menu, TextField, usePopupState } from '@elementor/ui';
5
6
 
6
7
  type TextFieldInnerSelectionProps = {
7
8
  placeholder?: string;
@@ -66,9 +67,9 @@ export const SelectionEndAdornment = < T extends string >( {
66
67
 
67
68
  <Menu MenuListProps={ { dense: true } } { ...bindMenu( popupState ) }>
68
69
  { options.map( ( option, index ) => (
69
- <MenuItem key={ option } onClick={ () => handleMenuItemClick( index ) }>
70
+ <MenuListItem key={ option } onClick={ () => handleMenuItemClick( index ) }>
70
71
  { option.toUpperCase() }
71
- </MenuItem>
72
+ </MenuListItem>
72
73
  ) ) }
73
74
  </Menu>
74
75
  </InputAdornment>
@@ -1,7 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { backgroundImagePositionOffsetPropTypeUtil, stringPropTypeUtil } from '@elementor/editor-props';
3
+ import { MenuListItem } from '@elementor/editor-ui';
3
4
  import { LetterXIcon, LetterYIcon } from '@elementor/icons';
4
- import { Grid, MenuItem, Select, type SelectChangeEvent } from '@elementor/ui';
5
+ import { Grid, Select, type SelectChangeEvent } from '@elementor/ui';
5
6
  import { __ } from '@wordpress/i18n';
6
7
 
7
8
  import { PropKeyProvider, PropProvider, useBoundProp } from '../../../../bound-prop-context';
@@ -65,9 +66,9 @@ export const BackgroundImageOverlayPosition = () => {
65
66
  fullWidth
66
67
  >
67
68
  { backgroundPositionOptions.map( ( { label, value } ) => (
68
- <MenuItem key={ value } value={ value ?? '' }>
69
+ <MenuListItem key={ value } value={ value ?? '' }>
69
70
  { label }
70
- </MenuItem>
71
+ </MenuListItem>
71
72
  ) ) }
72
73
  </Select>
73
74
  </Grid>
@@ -134,6 +134,7 @@ export function EqualUnequalSizesControl< TMultiPropType extends string, TPropVa
134
134
  } }
135
135
  { ...bindPopover( popupState ) }
136
136
  slotProps={ {
137
+ // eslint-disable-next-line react-compiler/react-compiler
137
138
  paper: { sx: { mt: 0.5, width: controlRef.current?.getBoundingClientRect().width } },
138
139
  } }
139
140
  >
@@ -10,8 +10,8 @@ import {
10
10
  IconButton,
11
11
  InputAdornment,
12
12
  Link,
13
- ListSubheader,
14
13
  MenuList,
14
+ MenuSubheader,
15
15
  Popover,
16
16
  Stack,
17
17
  styled,
@@ -189,6 +189,7 @@ const FontList = ( { fontListItems, setFontFamily, handleClose, fontFamily }: Fo
189
189
  () => {
190
190
  virtualizer.scrollToIndex( fontListItems.findIndex( ( item ) => item.value === fontFamily ) );
191
191
  },
192
+ // eslint-disable-next-line react-compiler/react-compiler
192
193
  // eslint-disable-next-line react-hooks/exhaustive-deps
193
194
  [ fontFamily ]
194
195
  );
@@ -221,14 +222,14 @@ const FontList = ( { fontListItems, setFontFamily, handleClose, fontFamily }: Fo
221
222
 
222
223
  if ( item.type === 'category' ) {
223
224
  return (
224
- <ListSubheader
225
+ <MenuSubheader
225
226
  key={ virtualRow.key }
226
227
  style={ {
227
228
  transform: `translateY(${ virtualRow.start }px)`,
228
229
  } }
229
230
  >
230
231
  { item.value }
231
- </ListSubheader>
232
+ </MenuSubheader>
232
233
  );
233
234
  }
234
235
 
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { useMemo, useState } from 'react';
3
+ import { getAncestorWithAnchorTag, getDescendantWithAnchorTag } from '@elementor/editor-elements';
3
4
  import {
4
5
  booleanPropTypeUtil,
5
6
  linkPropTypeUtil,
@@ -26,7 +27,6 @@ import {
26
27
  import { ControlLabel } from '../components/control-label';
27
28
  import ControlActions from '../control-actions/control-actions';
28
29
  import { createControl } from '../create-control';
29
- import { getLinkRestriction } from '../utils/link-restriction';
30
30
  import { type ControlProps } from '../utils/types';
31
31
 
32
32
  type Props = ControlProps< {
@@ -68,7 +68,7 @@ export const LinkControl = createControl( ( props: Props ) => {
68
68
  );
69
69
 
70
70
  const onEnabledChange = () => {
71
- const { shouldRestrict } = getLinkRestriction( elementId );
71
+ const shouldRestrict = getAncestorWithAnchorTag( elementId ) || getDescendantWithAnchorTag( elementId );
72
72
 
73
73
  if ( shouldRestrict && ! isEnabled ) {
74
74
  return;
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { stringPropTypeUtil, type StringPropValue } from '@elementor/editor-props';
3
- import { MenuItem, Select, type SelectChangeEvent } from '@elementor/ui';
3
+ import { MenuListItem } from '@elementor/editor-ui';
4
+ import { Select, type SelectChangeEvent } from '@elementor/ui';
4
5
 
5
6
  import { useBoundProp } from '../bound-prop-context';
6
7
  import ControlActions from '../control-actions/control-actions';
@@ -32,9 +33,9 @@ export const SelectControl = createControl( ( { options, onChange }: Props ) =>
32
33
  fullWidth
33
34
  >
34
35
  { options.map( ( { label, ...props } ) => (
35
- <MenuItem key={ props.value } { ...props } value={ props.value ?? '' }>
36
+ <MenuListItem key={ props.value } { ...props } value={ props.value ?? '' }>
36
37
  { label }
37
- </MenuItem>
38
+ </MenuListItem>
38
39
  ) ) }
39
40
  </Select>
40
41
  </ControlActions>
@@ -34,6 +34,7 @@ export const useSyncExternalState = < TValue, >( {
34
34
  useEffect( () => {
35
35
  setInternal( ( prevInternal ) => toInternal( external, prevInternal ) );
36
36
 
37
+ // eslint-disable-next-line react-compiler/react-compiler
37
38
  // eslint-disable-next-line react-hooks/exhaustive-deps
38
39
  }, [ external ] );
39
40
 
@@ -1,47 +0,0 @@
1
- import { getContainer } from '@elementor/editor-elements';
2
-
3
- type LinkRestriction =
4
- | {
5
- shouldRestrict: true;
6
- restrictReason: 'ancestor' | 'descendant';
7
- }
8
- | {
9
- shouldRestrict: false;
10
- restrictReason?: never;
11
- };
12
-
13
- export function getLinkRestriction( elementId: string ): LinkRestriction {
14
- if ( getAncestorAnchor( elementId ) ) {
15
- return {
16
- shouldRestrict: true,
17
- restrictReason: 'ancestor',
18
- };
19
- }
20
-
21
- if ( getDescendantAnchor( elementId ) ) {
22
- return {
23
- shouldRestrict: true,
24
- restrictReason: 'descendant',
25
- };
26
- }
27
-
28
- return { shouldRestrict: false };
29
- }
30
-
31
- function getAncestorAnchor( elementId: string ) {
32
- const element = getElementView( elementId );
33
-
34
- return element?.closest( 'a' ) || null;
35
- }
36
-
37
- function getDescendantAnchor( elementId: string ) {
38
- const element = getElementView( elementId );
39
-
40
- return element?.querySelector( 'a' ) || null;
41
- }
42
-
43
- function getElementView( id: string ) {
44
- const elementContainer = getContainer( id );
45
-
46
- return elementContainer?.view?.el || null;
47
- }