@elementor/editor-app-bar 3.33.0-98 → 3.34.2

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.
Files changed (30) hide show
  1. package/dist/index.d.mts +1 -1
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +319 -288
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +297 -266
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +9 -9
  8. package/src/components/locations/main-menu-location.tsx +4 -1
  9. package/src/components/locations/utilities-menu-location.tsx +1 -3
  10. package/src/extensions/connect/hooks/use-connect-link-config.tsx +4 -1
  11. package/src/extensions/documents-preview/index.ts +1 -1
  12. package/src/extensions/documents-settings/hooks/use-action-props.ts +51 -0
  13. package/src/extensions/documents-settings/index.ts +10 -0
  14. package/src/extensions/finder/index.ts +1 -1
  15. package/src/extensions/help/hooks/use-action-props.ts +26 -0
  16. package/src/extensions/help/index.ts +6 -29
  17. package/src/extensions/history/index.ts +3 -3
  18. package/src/extensions/index.ts +2 -2
  19. package/src/extensions/keyboard-shortcuts/index.ts +1 -1
  20. package/src/extensions/site-settings/hooks/use-action-props.ts +2 -2
  21. package/src/extensions/site-settings/index.ts +4 -3
  22. package/src/extensions/structure/hooks/structure-icon-with-popup.tsx +84 -0
  23. package/src/extensions/structure/hooks/use-action-props.ts +2 -2
  24. package/src/extensions/structure/index.ts +3 -3
  25. package/src/extensions/theme-builder/index.ts +2 -0
  26. package/src/extensions/user-preferences/index.ts +2 -1
  27. package/src/locations.ts +1 -1
  28. package/src/types.ts +10 -0
  29. package/src/extensions/documents-indicator/components/settings-button.tsx +0 -86
  30. package/src/extensions/documents-indicator/index.ts +0 -12
@@ -0,0 +1,51 @@
1
+ import {
2
+ __useActiveDocument as useActiveDocument,
3
+ __useHostDocument as useHostDocument,
4
+ } from '@elementor/editor-documents';
5
+ import {
6
+ __privateOpenRoute as openRoute,
7
+ __privateUseRouteStatus as useRouteStatus,
8
+ } from '@elementor/editor-v1-adapters';
9
+ import { FileSettingsIcon } from '@elementor/icons';
10
+ import { __ } from '@wordpress/i18n';
11
+
12
+ import { type ExtendedWindow } from '../../../types';
13
+
14
+ export default function useActionProps() {
15
+ const activeDocument = useActiveDocument();
16
+ const hostDocument = useHostDocument();
17
+ const { isActive, isBlocked } = useRouteStatus( 'panel/page-settings' );
18
+
19
+ const document = activeDocument && activeDocument.type.value !== 'kit' ? activeDocument : hostDocument;
20
+
21
+ const ButtonTitle = document
22
+ ? /* translators: %s: Post type label. */
23
+ __( '%s Settings', 'elementor' ).replace( '%s', document.type.label )
24
+ : __( 'Document Settings', 'elementor' );
25
+
26
+ return {
27
+ title: ButtonTitle,
28
+ icon: FileSettingsIcon,
29
+ onClick: () => {
30
+ if ( ! document ) {
31
+ return;
32
+ }
33
+
34
+ const extendedWindow = window as unknown as ExtendedWindow;
35
+ const config = extendedWindow?.elementorCommon?.eventsManager?.config;
36
+
37
+ if ( config ) {
38
+ extendedWindow.elementorCommon.eventsManager.dispatchEvent( config.names.topBar.documentSettings, {
39
+ location: config.locations.topBar,
40
+ secondaryLocation: config.secondaryLocations[ 'document-settings' ],
41
+ trigger: config.triggers.click,
42
+ element: config.elements.buttonIcon,
43
+ } );
44
+ }
45
+
46
+ openRoute( 'panel/page-settings/settings' );
47
+ },
48
+ selected: isActive,
49
+ disabled: isBlocked || ! document,
50
+ };
51
+ }
@@ -0,0 +1,10 @@
1
+ import { toolsMenu } from '../../locations';
2
+ import useActionProps from './hooks/use-action-props';
3
+
4
+ export function init() {
5
+ toolsMenu.registerToggleAction( {
6
+ id: 'document-settings-button',
7
+ priority: 2,
8
+ useProps: useActionProps,
9
+ } );
10
+ }
@@ -4,7 +4,7 @@ import useActionProps from './hooks/use-action-props';
4
4
  export function init() {
5
5
  utilitiesMenu.registerAction( {
6
6
  id: 'toggle-finder',
7
- priority: 15, // Before Preview.
7
+ priority: 15,
8
8
  useProps: useActionProps,
9
9
  } );
10
10
  }
@@ -0,0 +1,26 @@
1
+ import { HelpIcon } from '@elementor/icons';
2
+ import { __ } from '@wordpress/i18n';
3
+
4
+ import { type ExtendedWindow } from '../../../types';
5
+
6
+ export default function useActionProps() {
7
+ return {
8
+ title: __( 'Help Center', 'elementor' ),
9
+ href: 'https://go.elementor.com/editor-top-bar-learn/',
10
+ icon: HelpIcon,
11
+ target: '_blank',
12
+ onClick: () => {
13
+ const extendedWindow = window as unknown as ExtendedWindow;
14
+ const config = extendedWindow?.elementorCommon?.eventsManager?.config;
15
+
16
+ if ( config ) {
17
+ extendedWindow.elementorCommon.eventsManager.dispatchEvent( config.names.topBar.help, {
18
+ location: config.locations.topBar,
19
+ secondaryLocation: config.secondaryLocations.help,
20
+ trigger: config.triggers.click,
21
+ element: config.elements.buttonIcon,
22
+ } );
23
+ }
24
+ },
25
+ };
26
+ }
@@ -1,34 +1,11 @@
1
- import { HelpIcon } from '@elementor/icons';
2
- import { __ } from '@wordpress/i18n';
3
-
4
- import { utilitiesMenu } from '../../locations';
5
- import { type ExtendedWindow } from '../../types';
1
+ import { mainMenu } from '../../locations';
2
+ import useActionProps from './hooks/use-action-props';
6
3
 
7
4
  export function init() {
8
- utilitiesMenu.registerLink( {
5
+ mainMenu.registerLink( {
9
6
  id: 'open-help-center',
10
- priority: 25, // After Finder.
11
- useProps: () => {
12
- return {
13
- title: __( 'Help', 'elementor' ),
14
- href: 'https://go.elementor.com/editor-top-bar-learn/',
15
- icon: HelpIcon,
16
- target: '_blank',
17
- showExternalLinkIcon: true,
18
- onClick: () => {
19
- const extendedWindow = window as unknown as ExtendedWindow;
20
- const config = extendedWindow?.elementorCommon?.eventsManager?.config;
21
-
22
- if ( config ) {
23
- extendedWindow.elementorCommon.eventsManager.dispatchEvent( config.names.topBar.help, {
24
- location: config.locations.topBar,
25
- secondaryLocation: config.secondaryLocations.help,
26
- trigger: config.triggers.click,
27
- element: config.elements.buttonIcon,
28
- } );
29
- }
30
- },
31
- };
32
- },
7
+ group: 'help',
8
+ priority: 10,
9
+ useProps: useActionProps,
33
10
  } );
34
11
  }
@@ -1,10 +1,10 @@
1
- import { mainMenu } from '../../locations';
1
+ import { toolsMenu } from '../../locations';
2
2
  import useActionProps from './hooks/use-action-props';
3
3
 
4
4
  export function init() {
5
- mainMenu.registerToggleAction( {
5
+ toolsMenu.registerToggleAction( {
6
6
  id: 'open-history',
7
- priority: 20,
7
+ priority: 15,
8
8
  useProps: useActionProps,
9
9
  } );
10
10
  }
@@ -4,9 +4,9 @@
4
4
  */
5
5
 
6
6
  import { init as initConnect } from './connect';
7
- import { init as initDocumentsIndicator } from './documents-indicator';
8
7
  import { init as initDocumentsPreview } from './documents-preview';
9
8
  import { init as initDocumentsSave } from './documents-save';
9
+ import { init as initDocumentsSettings } from './documents-settings';
10
10
  import { init as initElements } from './elements';
11
11
  import { init as initFinder } from './finder';
12
12
  import { init as initHelp } from './help';
@@ -20,9 +20,9 @@ import { init as initUserPreferences } from './user-preferences';
20
20
  import { init as initWordpress } from './wordpress';
21
21
 
22
22
  export function init() {
23
- initDocumentsIndicator();
24
23
  initDocumentsPreview();
25
24
  initDocumentsSave();
25
+ initDocumentsSettings();
26
26
  initElements();
27
27
  initFinder();
28
28
  initHelp();
@@ -5,7 +5,7 @@ export function init() {
5
5
  mainMenu.registerAction( {
6
6
  id: 'open-keyboard-shortcuts',
7
7
  group: 'default',
8
- priority: 40, // After user preferences.
8
+ priority: 40,
9
9
  useProps: useActionProps,
10
10
  } );
11
11
  }
@@ -2,7 +2,7 @@ import {
2
2
  __privateRunCommand as runCommand,
3
3
  __privateUseRouteStatus as useRouteStatus,
4
4
  } from '@elementor/editor-v1-adapters';
5
- import { AdjustmentsHorizontalIcon } from '@elementor/icons';
5
+ import { SettingsIcon } from '@elementor/icons';
6
6
  import { __ } from '@wordpress/i18n';
7
7
 
8
8
  import { type ExtendedWindow, type ToggleActionProps } from '../../../types';
@@ -14,7 +14,7 @@ export default function useActionProps(): ToggleActionProps {
14
14
 
15
15
  return {
16
16
  title: __( 'Site Settings', 'elementor' ),
17
- icon: AdjustmentsHorizontalIcon,
17
+ icon: SettingsIcon,
18
18
  onClick: () => {
19
19
  const extendedWindow = window as unknown as ExtendedWindow;
20
20
  const config = extendedWindow?.elementorCommon?.eventsManager?.config;
@@ -1,6 +1,6 @@
1
1
  import { injectIntoTop } from '@elementor/editor';
2
2
 
3
- import { toolsMenu } from '../../locations';
3
+ import { mainMenu } from '../../locations';
4
4
  import PortalledPrimaryAction from './components/portalled-primary-action';
5
5
  import useActionProps from './hooks/use-action-props';
6
6
 
@@ -11,9 +11,10 @@ export function init() {
11
11
  component: PortalledPrimaryAction,
12
12
  } );
13
13
 
14
- toolsMenu.registerToggleAction( {
14
+ mainMenu.registerToggleAction( {
15
15
  id: 'toggle-site-settings',
16
- priority: 2,
16
+ group: 'default',
17
+ priority: 1,
17
18
  useProps: useActionProps,
18
19
  } );
19
20
  }
@@ -0,0 +1,84 @@
1
+ import * as React from 'react';
2
+ import { useEffect, useState } from 'react';
3
+ import { StructureIcon } from '@elementor/icons';
4
+ import { Button, Card, CardActions, CardContent, Infotip, Typography } from '@elementor/ui';
5
+ import { __ } from '@wordpress/i18n';
6
+
7
+ import { type ExtendedWindow } from '../../../types';
8
+
9
+ const extendedWindow = window as unknown as ExtendedWindow;
10
+
11
+ const StructurePopupContent = ( { onClose }: { onClose: () => void } ) => {
12
+ const handleDismiss = async () => {
13
+ onClose();
14
+
15
+ extendedWindow.elementorCommon?.ajax?.addRequest?.( 'structure_popup_dismiss' ).catch( () => {} );
16
+ };
17
+
18
+ const stopEventPropagation = ( event: React.MouseEvent ) => {
19
+ event.stopPropagation();
20
+ };
21
+
22
+ return (
23
+ <Card elevation={ 0 } sx={ { maxWidth: 300 } } onClick={ stopEventPropagation }>
24
+ <CardContent>
25
+ <Typography variant="subtitle2" sx={ { mb: 2 } }>
26
+ { __( 'Refreshed Top Bar layout!', 'elementor' ) }
27
+ </Typography>
28
+ <Typography variant="body2">
29
+ { __( 'We’ve fine-tuned the Top Bar to make navigation faster and smoother.', 'elementor' ) }
30
+ </Typography>
31
+ </CardContent>
32
+ <CardActions sx={ { pt: 0 } }>
33
+ <Button
34
+ size="small"
35
+ color="secondary"
36
+ href="https://go.elementor.com/editor-top-bar-learn/"
37
+ target="_blank"
38
+ >
39
+ { __( 'Learn More', 'elementor' ) }
40
+ </Button>
41
+ <Button size="small" variant="contained" onClick={ handleDismiss }>
42
+ { __( 'Got it', 'elementor' ) }
43
+ </Button>
44
+ </CardActions>
45
+ </Card>
46
+ );
47
+ };
48
+
49
+ export const StructureIconWithPopup = () => {
50
+ const [ showPopup, setShowPopup ] = useState( false );
51
+
52
+ useEffect( () => {
53
+ if ( extendedWindow.elementorShowInfotip?.shouldShow === '1' ) {
54
+ setShowPopup( true );
55
+ }
56
+ }, [] );
57
+
58
+ const handleClosePopup = () => {
59
+ setShowPopup( false );
60
+ };
61
+
62
+ if ( extendedWindow.elementorShowInfotip?.shouldShow !== '1' ) {
63
+ return <StructureIcon />;
64
+ }
65
+
66
+ return (
67
+ <Infotip
68
+ placement="bottom"
69
+ arrow={ false }
70
+ content={ <StructurePopupContent onClose={ handleClosePopup } /> }
71
+ open={ showPopup }
72
+ PopperProps={ {
73
+ modifiers: [
74
+ {
75
+ name: 'offset',
76
+ options: { offset: [ -16, 12 ] },
77
+ },
78
+ ],
79
+ } }
80
+ >
81
+ <StructureIcon />
82
+ </Infotip>
83
+ );
84
+ };
@@ -2,17 +2,17 @@ import {
2
2
  __privateRunCommand as runCommand,
3
3
  __privateUseRouteStatus as useRouteStatus,
4
4
  } from '@elementor/editor-v1-adapters';
5
- import { StructureIcon } from '@elementor/icons';
6
5
  import { __ } from '@wordpress/i18n';
7
6
 
8
7
  import { type ExtendedWindow, type ToggleActionProps } from '../../../types';
8
+ import { StructureIconWithPopup } from './structure-icon-with-popup';
9
9
 
10
10
  export default function useActionProps(): ToggleActionProps {
11
11
  const { isActive, isBlocked } = useRouteStatus( 'navigator' );
12
12
 
13
13
  return {
14
14
  title: __( 'Structure', 'elementor' ),
15
- icon: StructureIcon,
15
+ icon: StructureIconWithPopup,
16
16
  onClick: () => {
17
17
  const extendedWindow = window as unknown as ExtendedWindow;
18
18
  const config = extendedWindow?.elementorCommon?.eventsManager?.config;
@@ -1,10 +1,10 @@
1
- import { toolsMenu } from '../../locations';
1
+ import { utilitiesMenu } from '../../locations';
2
2
  import useActionProps from './hooks/use-action-props';
3
3
 
4
4
  export function init() {
5
- toolsMenu.registerToggleAction( {
5
+ utilitiesMenu.registerToggleAction( {
6
6
  id: 'toggle-structure-view',
7
- priority: 3,
7
+ priority: 25,
8
8
  useProps: useActionProps,
9
9
  } );
10
10
  }
@@ -4,6 +4,8 @@ import useThemeBuilderActionProps from './hooks/use-action-props';
4
4
  export function init() {
5
5
  mainMenu.registerAction( {
6
6
  id: 'open-theme-builder',
7
+ group: 'default',
8
+ priority: 10,
7
9
  useProps: useThemeBuilderActionProps,
8
10
  } );
9
11
  }
@@ -4,7 +4,8 @@ import useActionProps from './hooks/use-action-props';
4
4
  export function init() {
5
5
  mainMenu.registerToggleAction( {
6
6
  id: 'open-user-preferences',
7
- priority: 30, // After history.
7
+ group: 'default',
8
+ priority: 30,
8
9
  useProps: useActionProps,
9
10
  } );
10
11
  }
package/src/locations.ts CHANGED
@@ -18,7 +18,7 @@ const components = {
18
18
  };
19
19
 
20
20
  export const mainMenu = createMenu( {
21
- groups: [ 'exits' ],
21
+ groups: [ 'help', 'exits' ],
22
22
  components,
23
23
  } );
24
24
 
package/src/types.ts CHANGED
@@ -12,12 +12,22 @@ export type ExtendedWindow = Window & {
12
12
  };
13
13
  };
14
14
  };
15
+
16
+ ajax?: {
17
+ addRequest: ( action: string, options?: Record< string, unknown > ) => Promise< unknown >;
18
+ };
19
+
15
20
  config: {
16
21
  library_connect: {
17
22
  is_connected: boolean;
18
23
  };
19
24
  };
20
25
  };
26
+
27
+ elementorShowInfotip?: {
28
+ shouldShow: string;
29
+ };
30
+
21
31
  elementor: {
22
32
  helpers: {
23
33
  hasPro: () => boolean;
@@ -1,86 +0,0 @@
1
- import * as React from 'react';
2
- import {
3
- __useActiveDocument as useActiveDocument,
4
- __useHostDocument as useHostDocument,
5
- } from '@elementor/editor-documents';
6
- import {
7
- __privateOpenRoute as openRoute,
8
- __privateUseRouteStatus as useRouteStatus,
9
- } from '@elementor/editor-v1-adapters';
10
- import { SettingsIcon } from '@elementor/icons';
11
- import { Box, ToggleButton, Tooltip as BaseTooltip, type TooltipProps } from '@elementor/ui';
12
- import { __ } from '@wordpress/i18n';
13
-
14
- import { type ExtendedWindow } from '../../../types';
15
-
16
- export default function SettingsButton() {
17
- const activeDocument = useActiveDocument();
18
- const hostDocument = useHostDocument();
19
-
20
- const document = activeDocument && activeDocument.type.value !== 'kit' ? activeDocument : hostDocument;
21
-
22
- const { isActive, isBlocked } = useRouteStatus( 'panel/page-settings' );
23
-
24
- if ( ! document ) {
25
- return null;
26
- }
27
-
28
- /* translators: %s: Post type label. */
29
- const title = __( '%s Settings', 'elementor' ).replace( '%s', document.type.label );
30
-
31
- return (
32
- <Tooltip title={ title }>
33
- { /* @see https://mui.com/material-ui/react-tooltip/#disabled-elements */ }
34
- <Box component="span" aria-label={ undefined }>
35
- <ToggleButton
36
- value="document-settings"
37
- selected={ isActive }
38
- disabled={ isBlocked }
39
- onChange={ () => {
40
- const extendedWindow = window as unknown as ExtendedWindow;
41
- const config = extendedWindow?.elementorCommon?.eventsManager?.config;
42
-
43
- if ( config ) {
44
- extendedWindow.elementorCommon.eventsManager.dispatchEvent(
45
- config.names.topBar.documentSettings,
46
- {
47
- location: config.locations.topBar,
48
- secondaryLocation: config.secondaryLocations[ 'document-settings' ],
49
- trigger: config.triggers.click,
50
- element: config.elements.buttonIcon,
51
- }
52
- );
53
- }
54
-
55
- openRoute( 'panel/page-settings/settings' );
56
- } }
57
- aria-label={ title }
58
- size="small"
59
- sx={ {
60
- border: 0, // Temp fix until the style of the ToggleButton component will be decided.
61
- '&.Mui-disabled': {
62
- border: 0, // Temp fix until the style of the ToggleButton component will be decided.
63
- },
64
- } }
65
- >
66
- <SettingsIcon fontSize="small" />
67
- </ToggleButton>
68
- </Box>
69
- </Tooltip>
70
- );
71
- }
72
-
73
- function Tooltip( props: TooltipProps ) {
74
- return (
75
- <BaseTooltip
76
- PopperProps={ {
77
- sx: {
78
- '&.MuiTooltip-popper .MuiTooltip-tooltip.MuiTooltip-tooltipPlacementBottom': {
79
- mt: 1.7,
80
- },
81
- },
82
- } }
83
- { ...props }
84
- />
85
- );
86
- }
@@ -1,12 +0,0 @@
1
- import { injectIntoPageIndication } from '../../locations';
2
- import SettingsButton from './components/settings-button';
3
-
4
- export function init() {
5
- injectIntoPageIndication( {
6
- id: 'document-settings-button',
7
- component: SettingsButton,
8
- options: {
9
- priority: 20, // After document indicator.
10
- },
11
- } );
12
- }