@elementor/editor-app-bar 0.14.4 → 0.14.6
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 +27 -233
- package/dist/index.js +156 -260
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +223 -286
- package/dist/index.mjs.map +1 -1
- package/package.json +46 -46
- package/src/components/__tests__/app-bar.test.tsx +6 -2
- package/src/components/actions/action.tsx +1 -5
- package/src/components/actions/actions-group.tsx +7 -7
- package/src/components/actions/link.tsx +2 -6
- package/src/components/actions/toggle-action.tsx +1 -5
- package/src/components/app-bar.tsx +1 -2
- package/src/components/locations/__tests__/menus.test.tsx +1 -6
- package/src/components/locations/integrations-menu-location.tsx +4 -8
- package/src/components/locations/main-menu-location.tsx +14 -21
- package/src/components/locations/page-indication-location.tsx +1 -3
- package/src/components/locations/primary-action-location.tsx +1 -3
- package/src/components/locations/responsive-location.tsx +1 -3
- package/src/components/locations/tools-menu-location.tsx +6 -2
- package/src/components/locations/utilities-menu-location.tsx +9 -9
- package/src/components/ui/popover-menu-item.tsx +12 -9
- package/src/components/ui/popover-menu.tsx +1 -1
- package/src/components/ui/popover-sub-menu.tsx +1 -4
- package/src/components/ui/toolbar-logo.tsx +2 -2
- package/src/components/ui/toolbar-menu-item.tsx +12 -10
- package/src/components/ui/toolbar-menu-more.tsx +2 -2
- package/src/components/ui/toolbar-menu-toggle-item.tsx +2 -2
- package/src/contexts/menu-context.tsx +4 -8
- package/src/extensions/documents-indicator/components/__tests__/settings-button.test.tsx +9 -4
- package/src/extensions/documents-indicator/components/settings-button.tsx +27 -25
- package/src/extensions/documents-preview/hooks/use-action-props.ts +6 -9
- package/src/extensions/documents-save/components/__tests__/primary-action.test.tsx +4 -1
- package/src/extensions/documents-save/components/primary-action-menu.tsx +7 -7
- package/src/extensions/documents-save/components/primary-action.tsx +12 -13
- package/src/extensions/documents-save/hooks/__tests__/use-document-save-draft-props.test.ts +4 -1
- package/src/extensions/documents-save/hooks/use-document-copy-and-share-props.ts +6 -5
- package/src/extensions/documents-save/hooks/use-document-save-draft-props.ts +4 -1
- package/src/extensions/documents-save/hooks/use-document-view-page-props.ts +5 -3
- package/src/extensions/elements/hooks/__tests__/use-action-props.test.ts +4 -1
- package/src/extensions/elements/hooks/use-action-props.ts +10 -10
- package/src/extensions/elements/sync/__tests__/sync-panel-title.test.ts +18 -14
- package/src/extensions/elements/sync/sync-panel-title.ts +18 -19
- package/src/extensions/finder/hooks/__tests__/use-action-props.test.ts +4 -1
- package/src/extensions/finder/hooks/use-action-props.ts +10 -10
- package/src/extensions/help/index.ts +6 -9
- package/src/extensions/history/hooks/__tests__/use-action-props.test.ts +4 -1
- package/src/extensions/history/hooks/use-action-props.ts +10 -10
- package/src/extensions/keyboard-shortcuts/hooks/use-action-props.ts +6 -9
- package/src/extensions/site-settings/components/__tests__/portalled-primary-action.test.tsx +9 -4
- package/src/extensions/site-settings/components/__tests__/primary-action.test.tsx +11 -6
- package/src/extensions/site-settings/components/portal.tsx +9 -9
- package/src/extensions/site-settings/components/primary-action.tsx +14 -13
- package/src/extensions/site-settings/hooks/__tests__/use-action-props.test.ts +4 -1
- package/src/extensions/site-settings/hooks/use-action-props.ts +10 -10
- package/src/extensions/structure/hooks/__tests__/use-action-props.test.ts +4 -1
- package/src/extensions/structure/hooks/use-action-props.ts +10 -10
- package/src/extensions/theme-builder/hooks/use-action-props.ts +6 -9
- package/src/extensions/user-preferences/hooks/__tests__/use-action-props.test.ts +4 -1
- package/src/extensions/user-preferences/hooks/use-action-props.ts +10 -10
- package/src/extensions/wordpress/index.ts +6 -9
- package/src/index.ts +1 -5
- package/src/locations/__tests__/menus.test.tsx +5 -6
- package/src/locations/index.ts +5 -14
- package/src/locations/menus.tsx +60 -75
- package/src/sync/__tests__/redirect-old-menus.test.ts +14 -10
- package/src/sync/redirect-old-menus.ts +5 -1
- package/src/types.ts +11 -11
|
@@ -5,7 +5,7 @@ import { __createStore, SliceState, Store, __StoreProvider as Provider } from '@
|
|
|
5
5
|
import { slice } from '@elementor/editor-documents';
|
|
6
6
|
|
|
7
7
|
describe( 'AppBar component', () => {
|
|
8
|
-
let store: Store<SliceState<typeof slice
|
|
8
|
+
let store: Store< SliceState< typeof slice > >;
|
|
9
9
|
|
|
10
10
|
beforeEach( () => {
|
|
11
11
|
store = __createStore();
|
|
@@ -13,7 +13,11 @@ describe( 'AppBar component', () => {
|
|
|
13
13
|
|
|
14
14
|
it( 'should render elementor logo', () => {
|
|
15
15
|
// Act.
|
|
16
|
-
render(
|
|
16
|
+
render(
|
|
17
|
+
<Provider store={ store }>
|
|
18
|
+
<AppBar />
|
|
19
|
+
</Provider>
|
|
20
|
+
);
|
|
17
21
|
|
|
18
22
|
// Assert.
|
|
19
23
|
const logoTitle = screen.queryByText( 'Elementor Logo' );
|
|
@@ -24,10 +24,6 @@ export default function Action( { icon: Icon, title, visible = true, ...props }:
|
|
|
24
24
|
<Icon />
|
|
25
25
|
</ToolbarMenuItem>
|
|
26
26
|
) : (
|
|
27
|
-
<PopoverMenuItem
|
|
28
|
-
{ ...props }
|
|
29
|
-
text={ title }
|
|
30
|
-
icon={ <Icon /> }
|
|
31
|
-
/>
|
|
27
|
+
<PopoverMenuItem { ...props } text={ title } icon={ <Icon /> } />
|
|
32
28
|
);
|
|
33
29
|
}
|
|
@@ -42,7 +42,9 @@ export default function ActionsGroup( { icon: Icon, title, visible = true, items
|
|
|
42
42
|
open={ popupState.isOpen }
|
|
43
43
|
popupState={ popupState }
|
|
44
44
|
>
|
|
45
|
-
{ items.map( ( { MenuItem, id: key } ) =>
|
|
45
|
+
{ items.map( ( { MenuItem, id: key } ) => (
|
|
46
|
+
<MenuItem key={ key } />
|
|
47
|
+
) ) }
|
|
46
48
|
</PopoverMenu>
|
|
47
49
|
</>
|
|
48
50
|
);
|
|
@@ -57,12 +59,10 @@ export default function ActionsGroup( { icon: Icon, title, visible = true, items
|
|
|
57
59
|
icon={ <Icon /> }
|
|
58
60
|
isGroupParent
|
|
59
61
|
/>
|
|
60
|
-
<PopoverSubMenu
|
|
61
|
-
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
>
|
|
65
|
-
{ items.map( ( { MenuItem, id: key } ) => <MenuItem key={ key } /> ) }
|
|
62
|
+
<PopoverSubMenu { ...props } { ...bindPopover( popupState ) } popupState={ popupState }>
|
|
63
|
+
{ items.map( ( { MenuItem, id: key } ) => (
|
|
64
|
+
<MenuItem key={ key } />
|
|
65
|
+
) ) }
|
|
66
66
|
</PopoverSubMenu>
|
|
67
67
|
</>
|
|
68
68
|
);
|
|
@@ -10,7 +10,7 @@ export type Props = {
|
|
|
10
10
|
href?: string;
|
|
11
11
|
visible?: boolean;
|
|
12
12
|
target?: string;
|
|
13
|
-
}
|
|
13
|
+
};
|
|
14
14
|
|
|
15
15
|
export default function Link( { icon: Icon, title, visible = true, ...props }: Props ) {
|
|
16
16
|
const { type } = useMenuContext();
|
|
@@ -24,10 +24,6 @@ export default function Link( { icon: Icon, title, visible = true, ...props }: P
|
|
|
24
24
|
<Icon />
|
|
25
25
|
</ToolbarMenuItem>
|
|
26
26
|
) : (
|
|
27
|
-
<PopoverMenuItem
|
|
28
|
-
{ ...props }
|
|
29
|
-
text={ title }
|
|
30
|
-
icon={ <Icon /> }
|
|
31
|
-
/>
|
|
27
|
+
<PopoverMenuItem { ...props } text={ title } icon={ <Icon /> } />
|
|
32
28
|
);
|
|
33
29
|
}
|
|
@@ -26,10 +26,6 @@ export default function ToggleAction( { icon: Icon, title, value, visible = true
|
|
|
26
26
|
<Icon />
|
|
27
27
|
</ToolbarMenuToggleItem>
|
|
28
28
|
) : (
|
|
29
|
-
<PopoverMenuItem
|
|
30
|
-
{ ...props }
|
|
31
|
-
text={ title }
|
|
32
|
-
icon={ <Icon /> }
|
|
33
|
-
/>
|
|
29
|
+
<PopoverMenuItem { ...props } text={ title } icon={ <Icon /> } />
|
|
34
30
|
);
|
|
35
31
|
}
|
|
@@ -18,8 +18,7 @@ export default function AppBar() {
|
|
|
18
18
|
<Box display="grid" gridTemplateColumns="repeat(3, 1fr)" flexGrow={ 1 }>
|
|
19
19
|
<Grid container>
|
|
20
20
|
<MainMenuLocation />
|
|
21
|
-
{ document?.permissions?.allowAddingWidgets &&
|
|
22
|
-
<ToolsMenuLocation /> }
|
|
21
|
+
{ document?.permissions?.allowAddingWidgets && <ToolsMenuLocation /> }
|
|
23
22
|
</Grid>
|
|
24
23
|
<Grid container justifyContent="center">
|
|
25
24
|
<ToolbarMenu spacing={ 1.5 }>
|
|
@@ -4,12 +4,7 @@ import MainMenuLocation from '../main-menu-location';
|
|
|
4
4
|
import ToolsMenuLocation from '../tools-menu-location';
|
|
5
5
|
import UtilitiesMenuLocation from '../utilities-menu-location';
|
|
6
6
|
import { integrationsMenu, mainMenu, toolsMenu, utilitiesMenu } from '../../../locations';
|
|
7
|
-
import {
|
|
8
|
-
createMockMenuAction,
|
|
9
|
-
createMockMenuLink,
|
|
10
|
-
createMockMenuToggleAction,
|
|
11
|
-
createMockSubMenu,
|
|
12
|
-
} from 'test-utils';
|
|
7
|
+
import { createMockMenuAction, createMockMenuLink, createMockMenuToggleAction, createMockSubMenu } from 'test-utils';
|
|
13
8
|
|
|
14
9
|
describe( 'Menus components', () => {
|
|
15
10
|
describe( 'Main menu', () => {
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { integrationsMenu } from '../../locations';
|
|
3
|
-
import {
|
|
4
|
-
bindMenu,
|
|
5
|
-
bindTrigger,
|
|
6
|
-
usePopupState,
|
|
7
|
-
} from '@elementor/ui';
|
|
3
|
+
import { bindMenu, bindTrigger, usePopupState } from '@elementor/ui';
|
|
8
4
|
import { __ } from '@wordpress/i18n';
|
|
9
5
|
import { PlugIcon } from '@elementor/icons';
|
|
10
6
|
import PopoverMenu from '../ui/popover-menu';
|
|
@@ -35,9 +31,9 @@ export default function IntegrationsMenuLocation() {
|
|
|
35
31
|
marginThreshold={ 8 }
|
|
36
32
|
open={ popupState.isOpen }
|
|
37
33
|
>
|
|
38
|
-
{ menuItems.default.map(
|
|
39
|
-
|
|
40
|
-
) }
|
|
34
|
+
{ menuItems.default.map( ( { MenuItem: IntegrationsMenuItem, id } ) => (
|
|
35
|
+
<IntegrationsMenuItem key={ id } />
|
|
36
|
+
) ) }
|
|
41
37
|
</PopoverMenu>
|
|
42
38
|
</>
|
|
43
39
|
);
|
|
@@ -22,15 +22,12 @@ export default function MainMenuLocation() {
|
|
|
22
22
|
const config = extendedWindow?.elementor?.editorEvents?.config;
|
|
23
23
|
|
|
24
24
|
if ( config ) {
|
|
25
|
-
extendedWindow.elementor.editorEvents.dispatchEvent(
|
|
26
|
-
config.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
element: config.elements.buttonIcon,
|
|
32
|
-
},
|
|
33
|
-
);
|
|
25
|
+
extendedWindow.elementor.editorEvents.dispatchEvent( config.names.topBar.elementorLogoDropdown, {
|
|
26
|
+
location: config.locations.topBar,
|
|
27
|
+
secondaryLocation: config.secondaryLocations.elementorLogo,
|
|
28
|
+
trigger: config.triggers.dropdownClick,
|
|
29
|
+
element: config.elements.buttonIcon,
|
|
30
|
+
} );
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
toolbarLogoProps.onClick( e );
|
|
@@ -38,19 +35,15 @@ export default function MainMenuLocation() {
|
|
|
38
35
|
|
|
39
36
|
return (
|
|
40
37
|
<Stack sx={ { paddingInlineStart: 3 } } direction="row" alignItems="center">
|
|
41
|
-
<ToolbarLogo
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<PopoverMenu
|
|
47
|
-
onClick={ popupState.close }
|
|
48
|
-
{ ...bindMenu( popupState ) }
|
|
49
|
-
marginThreshold={ 8 }
|
|
50
|
-
>
|
|
51
|
-
{ menuItems.default.map( ( { MenuItem, id } ) => <MenuItem key={ id } /> ) }
|
|
38
|
+
<ToolbarLogo { ...toolbarLogoProps } onClick={ onToolbarClick } selected={ popupState.isOpen } />
|
|
39
|
+
<PopoverMenu onClick={ popupState.close } { ...bindMenu( popupState ) } marginThreshold={ 8 }>
|
|
40
|
+
{ menuItems.default.map( ( { MenuItem, id } ) => (
|
|
41
|
+
<MenuItem key={ id } />
|
|
42
|
+
) ) }
|
|
52
43
|
{ menuItems.exits.length > 0 && <Divider /> }
|
|
53
|
-
{ menuItems.exits.map( ( { MenuItem, id } ) =>
|
|
44
|
+
{ menuItems.exits.map( ( { MenuItem, id } ) => (
|
|
45
|
+
<MenuItem key={ id } />
|
|
46
|
+
) ) }
|
|
54
47
|
</PopoverMenu>
|
|
55
48
|
</Stack>
|
|
56
49
|
);
|
|
@@ -16,11 +16,15 @@ export default function ToolsMenuLocation() {
|
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
18
|
<ToolbarMenu>
|
|
19
|
-
{ toolbarMenuItems.map( ( { MenuItem, id } ) =>
|
|
19
|
+
{ toolbarMenuItems.map( ( { MenuItem, id } ) => (
|
|
20
|
+
<MenuItem key={ id } />
|
|
21
|
+
) ) }
|
|
20
22
|
<IntegrationsMenuLocation />
|
|
21
23
|
{ popoverMenuItems.length > 0 && (
|
|
22
24
|
<ToolbarMenuMore id="elementor-editor-app-bar-tools-more">
|
|
23
|
-
{ popoverMenuItems.map( ( { MenuItem, id } ) =>
|
|
25
|
+
{ popoverMenuItems.map( ( { MenuItem, id } ) => (
|
|
26
|
+
<MenuItem key={ id } />
|
|
27
|
+
) ) }
|
|
24
28
|
</ToolbarMenuMore>
|
|
25
29
|
) }
|
|
26
30
|
</ToolbarMenu>
|
|
@@ -17,17 +17,17 @@ export default function UtilitiesMenuLocation() {
|
|
|
17
17
|
|
|
18
18
|
return (
|
|
19
19
|
<ToolbarMenu>
|
|
20
|
-
{ toolbarMenuItems.map(
|
|
21
|
-
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
)
|
|
27
|
-
) }
|
|
20
|
+
{ toolbarMenuItems.map( ( { MenuItem, id }, index ) => (
|
|
21
|
+
<Fragment key={ id }>
|
|
22
|
+
{ index === 0 && <Divider orientation="vertical" /> }
|
|
23
|
+
<MenuItem />
|
|
24
|
+
</Fragment>
|
|
25
|
+
) ) }
|
|
28
26
|
{ popoverMenuItems.length > 0 && (
|
|
29
27
|
<ToolbarMenuMore id="elementor-editor-app-bar-utilities-more">
|
|
30
|
-
{ popoverMenuItems.map( ( { MenuItem, id } ) =>
|
|
28
|
+
{ popoverMenuItems.map( ( { MenuItem, id } ) => (
|
|
29
|
+
<MenuItem key={ id } />
|
|
30
|
+
) ) }
|
|
31
31
|
</ToolbarMenuMore>
|
|
32
32
|
) }
|
|
33
33
|
</ToolbarMenu>
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
MenuItem,
|
|
4
|
-
MenuItemProps,
|
|
5
|
-
ListItemText,
|
|
6
|
-
ListItemIcon,
|
|
7
|
-
withDirection,
|
|
8
|
-
} from '@elementor/ui';
|
|
2
|
+
import { MenuItem, MenuItemProps, ListItemText, ListItemIcon, withDirection } from '@elementor/ui';
|
|
9
3
|
import { ArrowUpRightIcon, ChevronRightIcon } from '@elementor/icons';
|
|
10
4
|
|
|
11
5
|
type ExtraProps = {
|
|
@@ -14,14 +8,23 @@ type ExtraProps = {
|
|
|
14
8
|
text?: string;
|
|
15
9
|
icon?: JSX.Element;
|
|
16
10
|
isGroupParent?: boolean;
|
|
17
|
-
}
|
|
11
|
+
};
|
|
18
12
|
|
|
19
13
|
export type PopoverMenuItemProps = MenuItemProps & ExtraProps;
|
|
20
14
|
|
|
21
15
|
const DirectionalArrowIcon = withDirection( ArrowUpRightIcon );
|
|
22
16
|
const DirectionalChevronIcon = withDirection( ChevronRightIcon );
|
|
23
17
|
|
|
24
|
-
export default function PopoverMenuItem( {
|
|
18
|
+
export default function PopoverMenuItem( {
|
|
19
|
+
text,
|
|
20
|
+
icon,
|
|
21
|
+
onClick,
|
|
22
|
+
href,
|
|
23
|
+
target,
|
|
24
|
+
disabled,
|
|
25
|
+
isGroupParent,
|
|
26
|
+
...props
|
|
27
|
+
}: PopoverMenuItemProps ) {
|
|
25
28
|
const isExternalLink = href && target === '_blank';
|
|
26
29
|
|
|
27
30
|
return (
|
|
@@ -3,7 +3,7 @@ import { Menu, MenuProps, PopupState } from '@elementor/ui';
|
|
|
3
3
|
import { MenuContextProvider } from '../../contexts/menu-context';
|
|
4
4
|
|
|
5
5
|
export type PopoverMenuProps = MenuProps & {
|
|
6
|
-
popupState?: PopupState
|
|
6
|
+
popupState?: PopupState;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export default function PopoverMenu( { children, popupState, ...props }: PopoverMenuProps ) {
|
|
@@ -12,10 +12,7 @@ export default function PopoverSubMenu( { children, ...props }: PopoverMenuProps
|
|
|
12
12
|
PaperProps={ {
|
|
13
13
|
sx: {
|
|
14
14
|
// This is a workaround to support RTL in PopoverMenu, since it doesn't support it yet.
|
|
15
|
-
...( isRTL
|
|
16
|
-
? { marginInlineEnd: -1 }
|
|
17
|
-
: { marginInlineStart: 1 }
|
|
18
|
-
),
|
|
15
|
+
...( isRTL ? { marginInlineEnd: -1 } : { marginInlineStart: 1 } ),
|
|
19
16
|
pointerEvents: 'auto',
|
|
20
17
|
},
|
|
21
18
|
} }
|
|
@@ -7,7 +7,7 @@ interface StyledElementorLogoProps extends SvgIconProps {
|
|
|
7
7
|
showMenuIcon?: boolean;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
type ToolbarLogoProps = Omit<ToggleButtonProps, 'value'>;
|
|
10
|
+
type ToolbarLogoProps = Omit< ToggleButtonProps, 'value' >;
|
|
11
11
|
|
|
12
12
|
const ElementorLogo = ( props: SvgIconProps ) => {
|
|
13
13
|
return (
|
|
@@ -37,7 +37,7 @@ const StyledToggleButton = styled( ToggleButton )( ( { theme } ) => ( {
|
|
|
37
37
|
|
|
38
38
|
const StyledElementorLogo = styled( ElementorLogo, {
|
|
39
39
|
shouldForwardProp: ( prop ) => prop !== 'showMenuIcon',
|
|
40
|
-
} )<StyledElementorLogoProps>( ( { theme, showMenuIcon } ) => ( {
|
|
40
|
+
} )< StyledElementorLogoProps >( ( { theme, showMenuIcon } ) => ( {
|
|
41
41
|
'& path': {
|
|
42
42
|
fill: theme.palette.background.default,
|
|
43
43
|
transition: 'all 0.2s linear',
|
|
@@ -4,7 +4,7 @@ import { Box, IconButton, IconButtonProps, Tooltip as BaseTooltip, TooltipProps
|
|
|
4
4
|
export type ToolbarMenuItemProps = IconButtonProps & {
|
|
5
5
|
title?: string;
|
|
6
6
|
selected?: boolean;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
8
|
|
|
9
9
|
export default function ToolbarMenuItem( { title, ...props }: ToolbarMenuItemProps ) {
|
|
10
10
|
return (
|
|
@@ -32,14 +32,16 @@ export default function ToolbarMenuItem( { title, ...props }: ToolbarMenuItemPro
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function Tooltip( props: TooltipProps ) {
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
return (
|
|
36
|
+
<BaseTooltip
|
|
37
|
+
PopperProps={ {
|
|
38
|
+
sx: {
|
|
39
|
+
'&.MuiTooltip-popper .MuiTooltip-tooltip.MuiTooltip-tooltipPlacementBottom': {
|
|
40
|
+
mt: 2,
|
|
41
|
+
},
|
|
40
42
|
},
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
} }
|
|
44
|
+
{ ...props }
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
45
47
|
}
|
|
@@ -6,9 +6,9 @@ import { __ } from '@wordpress/i18n';
|
|
|
6
6
|
import { DotsVerticalIcon } from '@elementor/icons';
|
|
7
7
|
import PopoverMenu from './popover-menu';
|
|
8
8
|
|
|
9
|
-
export type ToolbarMenuMoreProps = PropsWithChildren<{
|
|
9
|
+
export type ToolbarMenuMoreProps = PropsWithChildren< {
|
|
10
10
|
id: string;
|
|
11
|
-
}
|
|
11
|
+
} >;
|
|
12
12
|
|
|
13
13
|
export default function ToolbarMenuMore( { children, id }: ToolbarMenuMoreProps ) {
|
|
14
14
|
const popupState = usePopupState( {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Box, ToggleButton, ToggleButtonProps, Tooltip } from '@elementor/ui';
|
|
3
3
|
|
|
4
|
-
export type ToolbarMenuToggleItemProps = Omit<ToggleButtonProps, 'onChange'> & {
|
|
4
|
+
export type ToolbarMenuToggleItemProps = Omit< ToggleButtonProps, 'onChange' > & {
|
|
5
5
|
title?: string;
|
|
6
6
|
onClick?: () => void;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
8
|
|
|
9
9
|
export default function ToolbarMenuToggleItem( { title, onClick, ...props }: ToolbarMenuToggleItemProps ) {
|
|
10
10
|
return (
|
|
@@ -5,18 +5,14 @@ import { PopupState } from '@elementor/ui';
|
|
|
5
5
|
type MenuContextValue = {
|
|
6
6
|
type: 'toolbar' | 'popover';
|
|
7
7
|
popupState?: PopupState;
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
|
|
10
|
-
const MenuContext = createContext<MenuContextValue>( {
|
|
10
|
+
const MenuContext = createContext< MenuContextValue >( {
|
|
11
11
|
type: 'toolbar',
|
|
12
12
|
} );
|
|
13
13
|
|
|
14
|
-
export function MenuContextProvider( { type, popupState, children }: PropsWithChildren<MenuContextValue> ) {
|
|
15
|
-
return
|
|
16
|
-
<MenuContext.Provider value={ { type, popupState } }>
|
|
17
|
-
{ children }
|
|
18
|
-
</MenuContext.Provider>
|
|
19
|
-
);
|
|
14
|
+
export function MenuContextProvider( { type, popupState, children }: PropsWithChildren< MenuContextValue > ) {
|
|
15
|
+
return <MenuContext.Provider value={ { type, popupState } }>{ children }</MenuContext.Provider>;
|
|
20
16
|
}
|
|
21
17
|
|
|
22
18
|
export function useMenuContext() {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import SettingsButton from '../settings-button';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
__privateOpenRoute as openRoute,
|
|
5
|
+
__privateUseRouteStatus as useRouteStatus,
|
|
6
|
+
} from '@elementor/editor-v1-adapters';
|
|
4
7
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
5
8
|
import { __useActiveDocument as useActiveDocument } from '@elementor/editor-documents';
|
|
6
9
|
import { createMockDocument } from 'test-utils';
|
|
@@ -17,9 +20,11 @@ jest.mock( '@elementor/editor-documents', () => ( {
|
|
|
17
20
|
|
|
18
21
|
describe( '@elementor/editor-app-bar - App bar document settings button', () => {
|
|
19
22
|
beforeEach( () => {
|
|
20
|
-
jest.mocked( useActiveDocument ).mockReturnValue(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
jest.mocked( useActiveDocument ).mockReturnValue(
|
|
24
|
+
createMockDocument( {
|
|
25
|
+
type: { value: 'wp-page', label: 'Page' },
|
|
26
|
+
} )
|
|
27
|
+
);
|
|
23
28
|
} );
|
|
24
29
|
|
|
25
30
|
it( 'should open the document settings panel on click', () => {
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Box, ToggleButton, Tooltip as BaseTooltip, TooltipProps } from '@elementor/ui';
|
|
3
3
|
import { __ } from '@wordpress/i18n';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
__privateOpenRoute as openRoute,
|
|
6
|
+
__privateUseRouteStatus as useRouteStatus,
|
|
7
|
+
} from '@elementor/editor-v1-adapters';
|
|
5
8
|
import { SettingsIcon } from '@elementor/icons';
|
|
6
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
__useActiveDocument as useActiveDocument,
|
|
11
|
+
__useHostDocument as useHostDocument,
|
|
12
|
+
} from '@elementor/editor-documents';
|
|
7
13
|
import { ExtendedWindow } from '../../../types';
|
|
8
14
|
|
|
9
15
|
export default function SettingsButton() {
|
|
10
16
|
const activeDocument = useActiveDocument();
|
|
11
17
|
const hostDocument = useHostDocument();
|
|
12
18
|
|
|
13
|
-
const document = activeDocument && activeDocument.type.value !== 'kit'
|
|
14
|
-
? activeDocument
|
|
15
|
-
: hostDocument;
|
|
19
|
+
const document = activeDocument && activeDocument.type.value !== 'kit' ? activeDocument : hostDocument;
|
|
16
20
|
|
|
17
21
|
const { isActive, isBlocked } = useRouteStatus( 'panel/page-settings' );
|
|
18
22
|
|
|
@@ -21,8 +25,7 @@ export default function SettingsButton() {
|
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
/* translators: %s: Post type label. */
|
|
24
|
-
const title = __( '%s Settings', 'elementor' )
|
|
25
|
-
.replace( '%s', document.type.label );
|
|
28
|
+
const title = __( '%s Settings', 'elementor' ).replace( '%s', document.type.label );
|
|
26
29
|
|
|
27
30
|
return (
|
|
28
31
|
<Tooltip title={ title }>
|
|
@@ -37,15 +40,12 @@ export default function SettingsButton() {
|
|
|
37
40
|
const config = extendedWindow?.elementor?.editorEvents?.config;
|
|
38
41
|
|
|
39
42
|
if ( config ) {
|
|
40
|
-
extendedWindow.elementor.editorEvents.dispatchEvent(
|
|
41
|
-
config.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
element: config.elements.buttonIcon,
|
|
47
|
-
},
|
|
48
|
-
);
|
|
43
|
+
extendedWindow.elementor.editorEvents.dispatchEvent( config.names.topBar.documentSettings, {
|
|
44
|
+
location: config.locations.topBar,
|
|
45
|
+
secondaryLocation: config.secondaryLocations[ 'document-settings' ],
|
|
46
|
+
trigger: config.triggers.click,
|
|
47
|
+
element: config.elements.buttonIcon,
|
|
48
|
+
} );
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
openRoute( 'panel/page-settings/settings' );
|
|
@@ -67,14 +67,16 @@ export default function SettingsButton() {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
function Tooltip( props: TooltipProps ) {
|
|
70
|
-
return
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
return (
|
|
71
|
+
<BaseTooltip
|
|
72
|
+
PopperProps={ {
|
|
73
|
+
sx: {
|
|
74
|
+
'&.MuiTooltip-popper .MuiTooltip-tooltip.MuiTooltip-tooltipPlacementBottom': {
|
|
75
|
+
mt: 1.7,
|
|
76
|
+
},
|
|
75
77
|
},
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
} }
|
|
79
|
+
{ ...props }
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
80
82
|
}
|
|
@@ -15,15 +15,12 @@ export default function useActionProps() {
|
|
|
15
15
|
const config = extendedWindow?.elementor?.editorEvents?.config;
|
|
16
16
|
|
|
17
17
|
if ( config ) {
|
|
18
|
-
extendedWindow.elementor.editorEvents.dispatchEvent(
|
|
19
|
-
config.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
element: config.elements.buttonIcon,
|
|
25
|
-
},
|
|
26
|
-
);
|
|
18
|
+
extendedWindow.elementor.editorEvents.dispatchEvent( config.names.topBar.previewPage, {
|
|
19
|
+
location: config.locations.topBar,
|
|
20
|
+
secondaryLocation: config.secondaryLocations[ 'preview-page' ],
|
|
21
|
+
trigger: config.triggers.click,
|
|
22
|
+
element: config.elements.buttonIcon,
|
|
23
|
+
} );
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
if ( document ) {
|
|
@@ -2,7 +2,10 @@ import * as React from 'react';
|
|
|
2
2
|
import PrimaryAction from '../primary-action';
|
|
3
3
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
4
4
|
import { createMockDocument } from 'test-utils';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
__useActiveDocument as useActiveDocument,
|
|
7
|
+
__useActiveDocumentActions as useActiveDocumentActions,
|
|
8
|
+
} from '@elementor/editor-documents';
|
|
6
9
|
import { __privateUseIsPreviewMode as useIsPreviewMode } from '@elementor/editor-v1-adapters';
|
|
7
10
|
|
|
8
11
|
jest.mock( '@elementor/editor-documents', () => ( {
|
|
@@ -12,7 +12,7 @@ const StyledPopoverMenu = styled( PopoverMenu )`
|
|
|
12
12
|
display: none;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
& > *:not(.MuiDivider-root):not(:last-of-type) + .MuiDivider-root {
|
|
15
|
+
& > *:not( .MuiDivider-root ):not( :last-of-type ) + .MuiDivider-root {
|
|
16
16
|
display: block;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -37,17 +37,17 @@ export default function PrimaryActionMenu( props: PopoverMenuProps ) {
|
|
|
37
37
|
sx: { mt: 0.5 },
|
|
38
38
|
} }
|
|
39
39
|
>
|
|
40
|
-
{ saveActions.map( ( { MenuItem, id }, index ) =>
|
|
41
|
-
|
|
40
|
+
{ saveActions.map( ( { MenuItem, id }, index ) => [
|
|
41
|
+
index > 0 && <Divider key={ `${ id }-divider` } />,
|
|
42
42
|
<MenuItem key={ id } />,
|
|
43
|
-
] )
|
|
43
|
+
] ) }
|
|
44
44
|
|
|
45
45
|
{ saveActions.length > 0 && defaultActions.length > 0 && <Divider /> }
|
|
46
46
|
|
|
47
|
-
{ defaultActions.map( ( { MenuItem, id }, index ) =>
|
|
48
|
-
|
|
47
|
+
{ defaultActions.map( ( { MenuItem, id }, index ) => [
|
|
48
|
+
index > 0 && <Divider key={ `${ id }-divider` } />,
|
|
49
49
|
<MenuItem key={ id } />,
|
|
50
|
-
] )
|
|
50
|
+
] ) }
|
|
51
51
|
</StyledPopoverMenu>
|
|
52
52
|
);
|
|
53
53
|
}
|