@elementor/editor-app-bar 0.7.1 → 0.7.3

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 CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.7.3](https://github.com/elementor/elementor-packages/compare/@elementor/editor-app-bar@0.7.2...@elementor/editor-app-bar@0.7.3) (2023-08-22)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **editor-documents:** disable document save on preview mode [ED-11667] ([#105](https://github.com/elementor/elementor-packages/issues/105)) ([e903233](https://github.com/elementor/elementor-packages/commit/e90323367289508e941ef4acc41bc08a3d0fd559))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.7.2](https://github.com/elementor/elementor-packages/compare/@elementor/editor-app-bar@0.7.1...@elementor/editor-app-bar@0.7.2) (2023-08-20)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **editor-site-navigation:** noWrap for the post title [ED-11626] ([#102](https://github.com/elementor/elementor-packages/issues/102)) ([d4e1a54](https://github.com/elementor/elementor-packages/commit/d4e1a547cb9ff91c42eb7efe4ce8cfadb54a2922))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [0.7.1](https://github.com/elementor/elementor-packages/compare/@elementor/editor-app-bar@0.7.0...@elementor/editor-app-bar@0.7.1) (2023-08-02)
7
29
 
8
30
  **Note:** Version bump only for package @elementor/editor-app-bar
package/README.md CHANGED
@@ -1,5 +1,102 @@
1
1
  # Editor App Bar
2
2
 
3
- > **Warning**
4
- >
3
+ > [!WARNING]
5
4
  > This package is under development and not ready for production use.
5
+
6
+ ## Usage
7
+
8
+ ### Menus
9
+
10
+ There are 5 types of menus:
11
+
12
+ - `mainMenu` - Provides access to the main features and functionality of the application. Represented by an Elementor logo that changes to a hamburger.
13
+ - `toolsMenu` - A menu where the user can access various editing tools (e.g. "add widget", "structure", etc.) for manipulating the data or interface in some way. This
14
+ section may contain a limited number of buttons for common tools, as well as a dropdown menu for accessing additional
15
+ ones.
16
+ - `utilitiesMenu` - A menu where the user can access various utility features that are not directly related to the main
17
+ functionality of the application. This may include options for accessing the finder, getting help, or accessing other miscellaneous features.
18
+ - `documentOptionsMenu` - A menu where the user can access various options for saving the document. This may include
19
+ options for saving as draft or conditional options related to the document (e.g. "display conditions", etc.).
20
+ - `integrationsMenu` - A sub-menu inside the `mainMenu` where the user can access various options for integrating with other services. This may
21
+ include options for connecting to a third-party service or accessing other miscellaneous features.
22
+
23
+ Each menu contains a list of items, each item can be:
24
+
25
+ - `Action` - A button that performs an action.
26
+ - `Link` - A link that navigates to a different page.
27
+ - `ToggleAction` - A button that toggles between two states (checked or unchecked).
28
+
29
+ Let's extend the `integrationsMenu` with multiple examples that will cover all the types of items:
30
+
31
+ #### Action
32
+
33
+ ```tsx
34
+ import { integrationsMenu } from '@elementor/editor-app-bar';
35
+ import { PlusIcon } from '@elementor/icons';
36
+ import { __ } from '@wordpress/i18n';
37
+
38
+ integrationsMenu.registerAction( {
39
+ id: 'example-action-id',
40
+ props: {
41
+ title: __( 'My Custom Action', 'elementor' ),
42
+ icon: PlusIcon, // A react component that renders an SVG icon
43
+ disabled: false, // Optional
44
+ onClick: () => alert( 'Custom action triggred!' ), // Optional
45
+ }
46
+ } );
47
+ ```
48
+
49
+ #### ToggleAction
50
+
51
+ ```tsx
52
+ import { integrationsMenu } from '@elementor/editor-app-bar';
53
+ import { EyeIcon } from '@elementor/icons';
54
+ import { __ } from '@wordpress/i18n';
55
+
56
+ integrationsMenu.registerToggleAction( {
57
+ name: 'my-custom-toggle',
58
+ useProps: () => {
59
+ const [ isSelected, setIsSelected ] = useState( false );
60
+
61
+ return {
62
+ title: __( 'My Custom Toggle', 'elementor' ),
63
+ icon: EyeIcon,
64
+ selected: isSelected, // Optional
65
+ onClick: () => setIsSelected( ( prev ) => ! prev ), // Optional
66
+ disabled: false, // Optional
67
+ };
68
+ },
69
+ } );
70
+ ```
71
+
72
+ #### Link
73
+
74
+ ```tsx
75
+ import { integrationsMenu } from '@elementor/editor-app-bar';
76
+ import { LinkIcon } from '@elementor/icons';
77
+ import { __ } from '@wordpress/i18n';
78
+
79
+ integrationsMenu.registerLink( {
80
+ name: 'my-custom-link',
81
+ props: {
82
+ title: __( 'My Custom Link', 'elementor' ),
83
+ icon: LinkIcon,
84
+ href: 'https://elementor.com', // Optional
85
+ target: '_blank', // Optional
86
+ },
87
+ } );
88
+ ```
89
+
90
+ ---
91
+
92
+ > [!NOTE]
93
+ > You can use either `props` or `useProps` (depending on your need) for all the items types:
94
+ > - `props` - An object with the action props.
95
+ > - `useProps` - A React hook that returns the action props and lets you make the props reactive.
96
+
97
+ > [!NOTE]
98
+ > The `icon` property can be any React component that renders an SVG icon, it is recommended to use `SVGIcon` from `@elementor/ui`
99
+
100
+ ### Custom Locations
101
+
102
+ TBD
package/dist/index.js CHANGED
@@ -262,7 +262,8 @@ function PopoverMenu({ children, ...props }) {
262
262
  },
263
263
  ...props,
264
264
  MenuListProps: {
265
- component: "div"
265
+ component: "div",
266
+ dense: true
266
267
  }
267
268
  },
268
269
  children
@@ -645,9 +646,11 @@ function PrimaryActionMenu(props) {
645
646
  var import_ui15 = require("@elementor/ui");
646
647
  var import_editor_documents5 = require("@elementor/editor-documents");
647
648
  var import_icons8 = require("@elementor/icons");
649
+ var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
648
650
  function PrimaryAction() {
649
651
  const document2 = (0, import_editor_documents5.useActiveDocument)();
650
652
  const { save } = (0, import_editor_documents5.useActiveDocumentActions)();
653
+ const isPreviewMode = (0, import_editor_v1_adapters4.useIsPreviewMode)();
651
654
  const popupState = (0, import_ui15.usePopupState)({
652
655
  variant: "popover",
653
656
  popupId: "document-save-options"
@@ -655,8 +658,9 @@ function PrimaryAction() {
655
658
  if (!document2) {
656
659
  return null;
657
660
  }
658
- const isDisabled = !isEnabled(document2);
659
- const shouldShowSpinner = document2.isSaving && !isDisabled;
661
+ const isPublishDisabled = isPreviewMode || !isPublishEnabled(document2);
662
+ const isSaveOptionsDisabled = isPreviewMode || document2.type.value === "kit";
663
+ const shouldShowSpinner = document2.isSaving && !isPublishDisabled;
660
664
  return /* @__PURE__ */ React24.createElement(React24.Fragment, null, /* @__PURE__ */ React24.createElement(import_ui15.ButtonGroup, { size: "medium", variant: "contained" }, /* @__PURE__ */ React24.createElement(
661
665
  import_ui15.Button,
662
666
  {
@@ -669,7 +673,7 @@ function PrimaryAction() {
669
673
  minWidth: "110px"
670
674
  }
671
675
  },
672
- disabled: isDisabled
676
+ disabled: isPublishDisabled
673
677
  },
674
678
  shouldShowSpinner ? /* @__PURE__ */ React24.createElement(import_ui15.CircularProgress, null) : getLabel(document2)
675
679
  ), /* @__PURE__ */ React24.createElement(
@@ -690,7 +694,7 @@ function PrimaryAction() {
690
694
  {
691
695
  ...(0, import_ui15.bindTrigger)(popupState),
692
696
  sx: { px: 0, height: "100%" },
693
- disabled: document2.type.value === "kit",
697
+ disabled: isSaveOptionsDisabled,
694
698
  "aria-label": (0, import_i18n8.__)("Save Options", "elementor")
695
699
  },
696
700
  /* @__PURE__ */ React24.createElement(import_icons8.ChevronDownIcon, null)
@@ -700,7 +704,7 @@ function PrimaryAction() {
700
704
  function getLabel(document2) {
701
705
  return document2.userCan.publish ? (0, import_i18n8.__)("Publish", "elementor") : (0, import_i18n8.__)("Submit", "elementor");
702
706
  }
703
- function isEnabled(document2) {
707
+ function isPublishEnabled(document2) {
704
708
  if (document2.type.value === "kit") {
705
709
  return false;
706
710
  }
@@ -731,21 +735,21 @@ function init3() {
731
735
 
732
736
  // src/extensions/elements/sync/sync-panel-title.ts
733
737
  var import_i18n9 = require("@wordpress/i18n");
734
- var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
738
+ var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
735
739
  function syncPanelTitle() {
736
740
  const panelTitle = (0, import_i18n9.__)("Elements", "elementor");
737
741
  const tabTitle = (0, import_i18n9.__)("Widgets", "elementor");
738
- (0, import_editor_v1_adapters4.listenTo)(
739
- (0, import_editor_v1_adapters4.routeOpenEvent)("panel/elements"),
742
+ (0, import_editor_v1_adapters5.listenTo)(
743
+ (0, import_editor_v1_adapters5.routeOpenEvent)("panel/elements"),
740
744
  () => {
741
745
  setPanelTitle(panelTitle);
742
746
  setTabTitle(tabTitle);
743
747
  }
744
748
  );
745
- (0, import_editor_v1_adapters4.listenTo)(
746
- (0, import_editor_v1_adapters4.v1ReadyEvent)(),
749
+ (0, import_editor_v1_adapters5.listenTo)(
750
+ (0, import_editor_v1_adapters5.v1ReadyEvent)(),
747
751
  () => {
748
- if ((0, import_editor_v1_adapters4.isRouteActive)("panel/elements")) {
752
+ if ((0, import_editor_v1_adapters5.isRouteActive)("panel/elements")) {
749
753
  setPanelTitle(panelTitle);
750
754
  setTabTitle(tabTitle);
751
755
  }
@@ -765,13 +769,13 @@ function setTabTitle(title) {
765
769
  // src/extensions/elements/hooks/use-action-props.ts
766
770
  var import_icons9 = require("@elementor/icons");
767
771
  var import_i18n10 = require("@wordpress/i18n");
768
- var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
772
+ var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
769
773
  function useActionProps2() {
770
- const { isActive, isBlocked } = (0, import_editor_v1_adapters5.useRouteStatus)("panel/elements");
774
+ const { isActive, isBlocked } = (0, import_editor_v1_adapters6.useRouteStatus)("panel/elements");
771
775
  return {
772
776
  title: (0, import_i18n10.__)("Add Element", "elementor"),
773
777
  icon: import_icons9.PlusIcon,
774
- onClick: () => (0, import_editor_v1_adapters5.openRoute)("panel/elements/categories"),
778
+ onClick: () => (0, import_editor_v1_adapters6.openRoute)("panel/elements/categories"),
775
779
  selected: isActive,
776
780
  disabled: isBlocked
777
781
  };
@@ -790,16 +794,16 @@ function init4() {
790
794
  // src/extensions/finder/hooks/use-action-props.ts
791
795
  var import_i18n11 = require("@wordpress/i18n");
792
796
  var import_icons10 = require("@elementor/icons");
793
- var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
797
+ var import_editor_v1_adapters7 = require("@elementor/editor-v1-adapters");
794
798
  function useActionProps3() {
795
- const { isActive, isBlocked } = (0, import_editor_v1_adapters6.useRouteStatus)("finder", {
799
+ const { isActive, isBlocked } = (0, import_editor_v1_adapters7.useRouteStatus)("finder", {
796
800
  blockOnKitRoutes: false,
797
801
  blockOnPreviewMode: false
798
802
  });
799
803
  return {
800
804
  title: (0, import_i18n11.__)("Finder", "elementor"),
801
805
  icon: import_icons10.SearchIcon,
802
- onClick: () => (0, import_editor_v1_adapters6.runCommand)("finder/toggle"),
806
+ onClick: () => (0, import_editor_v1_adapters7.runCommand)("finder/toggle"),
803
807
  selected: isActive,
804
808
  disabled: isBlocked
805
809
  };
@@ -837,13 +841,13 @@ function init6() {
837
841
  // src/extensions/history/hooks/use-action-props.ts
838
842
  var import_icons12 = require("@elementor/icons");
839
843
  var import_i18n13 = require("@wordpress/i18n");
840
- var import_editor_v1_adapters7 = require("@elementor/editor-v1-adapters");
844
+ var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
841
845
  function useActionProps4() {
842
- const { isActive, isBlocked } = (0, import_editor_v1_adapters7.useRouteStatus)("panel/history");
846
+ const { isActive, isBlocked } = (0, import_editor_v1_adapters8.useRouteStatus)("panel/history");
843
847
  return {
844
848
  title: (0, import_i18n13.__)("History", "elementor"),
845
849
  icon: import_icons12.HistoryIcon,
846
- onClick: () => (0, import_editor_v1_adapters7.openRoute)("panel/history/actions"),
850
+ onClick: () => (0, import_editor_v1_adapters8.openRoute)("panel/history/actions"),
847
851
  selected: isActive,
848
852
  disabled: isBlocked
849
853
  };
@@ -861,12 +865,12 @@ function init7() {
861
865
  // src/extensions/keyboard-shortcuts/hooks/use-action-props.ts
862
866
  var import_i18n14 = require("@wordpress/i18n");
863
867
  var import_icons13 = require("@elementor/icons");
864
- var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
868
+ var import_editor_v1_adapters9 = require("@elementor/editor-v1-adapters");
865
869
  function useActionProps5() {
866
870
  return {
867
871
  icon: import_icons13.KeyboardIcon,
868
872
  title: (0, import_i18n14.__)("Keyboard Shortcuts", "elementor"),
869
- onClick: () => (0, import_editor_v1_adapters8.runCommand)("shortcuts/open")
873
+ onClick: () => (0, import_editor_v1_adapters9.runCommand)("shortcuts/open")
870
874
  };
871
875
  }
872
876
 
@@ -890,12 +894,12 @@ var React27 = __toESM(require("react"));
890
894
  // src/extensions/site-settings/components/portal.tsx
891
895
  var React25 = __toESM(require("react"));
892
896
  var import_ui16 = require("@elementor/ui");
893
- var import_editor_v1_adapters9 = require("@elementor/editor-v1-adapters");
897
+ var import_editor_v1_adapters10 = require("@elementor/editor-v1-adapters");
894
898
  function Portal(props) {
895
- const containerRef = (0, import_editor_v1_adapters9.useListenTo)(
899
+ const containerRef = (0, import_editor_v1_adapters10.useListenTo)(
896
900
  [
897
- (0, import_editor_v1_adapters9.routeOpenEvent)("panel/global"),
898
- (0, import_editor_v1_adapters9.routeCloseEvent)("panel/global")
901
+ (0, import_editor_v1_adapters10.routeOpenEvent)("panel/global"),
902
+ (0, import_editor_v1_adapters10.routeCloseEvent)("panel/global")
899
903
  ],
900
904
  getContainerRef
901
905
  );
@@ -905,7 +909,7 @@ function Portal(props) {
905
909
  return /* @__PURE__ */ React25.createElement(import_ui16.Portal, { container: containerRef.current, ...props });
906
910
  }
907
911
  function getContainerRef() {
908
- return (0, import_editor_v1_adapters9.isRouteActive)("panel/global") ? { current: document.querySelector("#elementor-panel-inner") } : { current: null };
912
+ return (0, import_editor_v1_adapters10.isRouteActive)("panel/global") ? { current: document.querySelector("#elementor-panel-inner") } : { current: null };
909
913
  }
910
914
 
911
915
  // src/extensions/site-settings/components/primary-action.tsx
@@ -941,16 +945,16 @@ function PortalledPrimaryAction() {
941
945
 
942
946
  // src/extensions/site-settings/hooks/use-action-props.ts
943
947
  var import_i18n16 = require("@wordpress/i18n");
944
- var import_editor_v1_adapters10 = require("@elementor/editor-v1-adapters");
948
+ var import_editor_v1_adapters11 = require("@elementor/editor-v1-adapters");
945
949
  var import_icons14 = require("@elementor/icons");
946
950
  function useActionProps6() {
947
- const { isActive, isBlocked } = (0, import_editor_v1_adapters10.useRouteStatus)("panel/global", {
951
+ const { isActive, isBlocked } = (0, import_editor_v1_adapters11.useRouteStatus)("panel/global", {
948
952
  blockOnKitRoutes: false
949
953
  });
950
954
  return {
951
955
  title: (0, import_i18n16.__)("Site Settings", "elementor"),
952
956
  icon: import_icons14.AdjustmentsHorizontalIcon,
953
- onClick: () => isActive ? (0, import_editor_v1_adapters10.runCommand)("panel/global/close") : (0, import_editor_v1_adapters10.runCommand)("panel/global/open"),
957
+ onClick: () => isActive ? (0, import_editor_v1_adapters11.runCommand)("panel/global/close") : (0, import_editor_v1_adapters11.runCommand)("panel/global/open"),
954
958
  selected: isActive,
955
959
  disabled: isBlocked
956
960
  };
@@ -971,14 +975,14 @@ function init9() {
971
975
 
972
976
  // src/extensions/structure/hooks/use-action-props.ts
973
977
  var import_i18n17 = require("@wordpress/i18n");
974
- var import_editor_v1_adapters11 = require("@elementor/editor-v1-adapters");
978
+ var import_editor_v1_adapters12 = require("@elementor/editor-v1-adapters");
975
979
  var import_icons15 = require("@elementor/icons");
976
980
  function useActionProps7() {
977
- const { isActive, isBlocked } = (0, import_editor_v1_adapters11.useRouteStatus)("navigator");
981
+ const { isActive, isBlocked } = (0, import_editor_v1_adapters12.useRouteStatus)("navigator");
978
982
  return {
979
983
  title: (0, import_i18n17.__)("Structure", "elementor"),
980
984
  icon: import_icons15.StructureIcon,
981
- onClick: () => (0, import_editor_v1_adapters11.runCommand)("navigator/toggle"),
985
+ onClick: () => (0, import_editor_v1_adapters12.runCommand)("navigator/toggle"),
982
986
  selected: isActive,
983
987
  disabled: isBlocked
984
988
  };
@@ -996,12 +1000,12 @@ function init10() {
996
1000
  // src/extensions/theme-builder/hooks/use-action-props.ts
997
1001
  var import_i18n18 = require("@wordpress/i18n");
998
1002
  var import_icons16 = require("@elementor/icons");
999
- var import_editor_v1_adapters12 = require("@elementor/editor-v1-adapters");
1003
+ var import_editor_v1_adapters13 = require("@elementor/editor-v1-adapters");
1000
1004
  function useActionProps8() {
1001
1005
  return {
1002
1006
  icon: import_icons16.ThemeBuilderIcon,
1003
1007
  title: (0, import_i18n18.__)("Theme Builder", "elementor"),
1004
- onClick: () => (0, import_editor_v1_adapters12.runCommand)("app/open")
1008
+ onClick: () => (0, import_editor_v1_adapters13.runCommand)("app/open")
1005
1009
  };
1006
1010
  }
1007
1011
 
@@ -1016,13 +1020,13 @@ function init11() {
1016
1020
  // src/extensions/user-preferences/hooks/use-action-props.ts
1017
1021
  var import_i18n19 = require("@wordpress/i18n");
1018
1022
  var import_icons17 = require("@elementor/icons");
1019
- var import_editor_v1_adapters13 = require("@elementor/editor-v1-adapters");
1023
+ var import_editor_v1_adapters14 = require("@elementor/editor-v1-adapters");
1020
1024
  function useActionProps9() {
1021
- const { isActive, isBlocked } = (0, import_editor_v1_adapters13.useRouteStatus)("panel/editor-preferences");
1025
+ const { isActive, isBlocked } = (0, import_editor_v1_adapters14.useRouteStatus)("panel/editor-preferences");
1022
1026
  return {
1023
1027
  icon: import_icons17.ToggleRightIcon,
1024
1028
  title: (0, import_i18n19.__)("User Preferences", "elementor"),
1025
- onClick: () => (0, import_editor_v1_adapters13.openRoute)("panel/editor-preferences"),
1029
+ onClick: () => (0, import_editor_v1_adapters14.openRoute)("panel/editor-preferences"),
1026
1030
  selected: isActive,
1027
1031
  disabled: isBlocked
1028
1032
  };