@elementor/editor-app-bar 0.2.1 → 0.4.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/CHANGELOG.md +40 -0
- package/dist/index.d.ts +27 -42
- package/dist/index.js +81 -106
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -108
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -6
- package/src/components/locations/__tests__/locations-components.test.tsx +1 -1
- package/src/components/locations/__tests__/menus.test.tsx +4 -4
- package/src/components/locations/page-indication-location.tsx +2 -3
- package/src/components/locations/primary-action-location.tsx +2 -3
- package/src/components/locations/responsive-location.tsx +2 -3
- package/src/extensions/documents-indicator/index.ts +1 -1
- package/src/extensions/documents-preview/index.ts +1 -1
- package/src/extensions/documents-save/components/__tests__/primary-action-menu.test.tsx +2 -2
- package/src/extensions/documents-save/index.ts +3 -3
- package/src/extensions/elements/index.ts +1 -1
- package/src/extensions/finder/index.ts +1 -1
- package/src/extensions/help/index.ts +1 -1
- package/src/extensions/history/index.ts +1 -1
- package/src/extensions/keyboard-shortcuts/index.ts +1 -1
- package/src/extensions/site-settings/index.ts +2 -2
- package/src/extensions/structure/index.ts +1 -1
- package/src/extensions/theme-builder/index.ts +1 -1
- package/src/extensions/user-preferences/index.ts +1 -1
- package/src/extensions/wordpress/index.ts +10 -7
- package/src/init.ts +1 -4
- package/src/locations/__tests__/menus.test.tsx +15 -30
- package/src/locations/index.ts +19 -21
- package/src/locations/menus.tsx +57 -69
- package/src/env.ts +0 -17
- package/src/locations/consts.ts +0 -4
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/locations/menus.tsx
|
|
2
2
|
import * as React8 from "react";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { createLocation } from "@elementor/locations";
|
|
5
5
|
|
|
6
6
|
// src/components/actions/action.tsx
|
|
7
7
|
import * as React4 from "react";
|
|
@@ -112,30 +112,30 @@ function Link({ icon: Icon, title, visible = true, ...props }) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
// src/locations/menus.tsx
|
|
115
|
-
function createMenu(
|
|
115
|
+
function createMenu(groups = []) {
|
|
116
116
|
const menuGroups = [
|
|
117
117
|
...groups,
|
|
118
118
|
"default"
|
|
119
119
|
];
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
120
|
+
const locations = menuGroups.reduce(
|
|
121
|
+
(carry, group) => ({
|
|
122
|
+
...carry,
|
|
123
|
+
[group]: createLocation()
|
|
124
|
+
}),
|
|
125
|
+
{}
|
|
126
|
+
);
|
|
127
|
+
const [
|
|
128
|
+
registerAction,
|
|
129
|
+
registerToggleAction,
|
|
130
|
+
registerLink
|
|
131
|
+
] = [Action, ToggleAction, Link].map(
|
|
132
|
+
(Component) => createRegisterMenuItem({
|
|
133
|
+
locations,
|
|
134
|
+
menuGroups,
|
|
135
|
+
component: Component
|
|
136
|
+
})
|
|
137
|
+
);
|
|
138
|
+
const useMenuItems5 = createUseMenuItems(locations);
|
|
139
139
|
return {
|
|
140
140
|
registerAction,
|
|
141
141
|
registerToggleAction,
|
|
@@ -143,8 +143,8 @@ function createMenu({ name: menuName, groups = [] }) {
|
|
|
143
143
|
useMenuItems: useMenuItems5
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
|
-
function createRegisterMenuItem({
|
|
147
|
-
return ({ group = "default",
|
|
146
|
+
function createRegisterMenuItem({ locations, menuGroups, component }) {
|
|
147
|
+
return ({ group = "default", id, overwrite, priority, ...args }) => {
|
|
148
148
|
if (!menuGroups.includes(group)) {
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
@@ -154,10 +154,8 @@ function createRegisterMenuItem({ menuName, menuGroups, component }) {
|
|
|
154
154
|
const componentProps = useProps();
|
|
155
155
|
return /* @__PURE__ */ React8.createElement(Component, { ...props, ...componentProps });
|
|
156
156
|
};
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
location,
|
|
160
|
-
name,
|
|
157
|
+
locations[group].inject({
|
|
158
|
+
id,
|
|
161
159
|
filler: Filler,
|
|
162
160
|
options: {
|
|
163
161
|
priority,
|
|
@@ -166,54 +164,44 @@ function createRegisterMenuItem({ menuName, menuGroups, component }) {
|
|
|
166
164
|
});
|
|
167
165
|
};
|
|
168
166
|
}
|
|
169
|
-
function createUseMenuItems(
|
|
170
|
-
const locations = menuGroups.map((group) => getMenuLocationId(menuName, group));
|
|
167
|
+
function createUseMenuItems(locations) {
|
|
171
168
|
return () => {
|
|
172
|
-
const injectionsGroups = useInjectionsOf(locations);
|
|
173
169
|
return useMemo(() => {
|
|
174
|
-
return
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
...acc,
|
|
178
|
-
[groupName]: injections.map((injection) => ({
|
|
170
|
+
return Object.entries(locations).reduce(
|
|
171
|
+
(carry, [groupName, location]) => {
|
|
172
|
+
const items = location.getInjections().map((injection) => ({
|
|
179
173
|
id: injection.id,
|
|
180
174
|
MenuItem: injection.filler
|
|
181
|
-
}))
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
175
|
+
}));
|
|
176
|
+
return {
|
|
177
|
+
...carry,
|
|
178
|
+
[groupName]: items
|
|
179
|
+
};
|
|
180
|
+
},
|
|
181
|
+
{}
|
|
182
|
+
);
|
|
183
|
+
}, []);
|
|
185
184
|
};
|
|
186
185
|
}
|
|
187
|
-
function getMenuLocationId(menu, group) {
|
|
188
|
-
return `editor/app-bar/${menu}/${group}`;
|
|
189
|
-
}
|
|
190
186
|
|
|
191
187
|
// src/locations/index.ts
|
|
192
|
-
import {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
var
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
var
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
var
|
|
208
|
-
|
|
209
|
-
});
|
|
210
|
-
var utilitiesMenu = createMenu({
|
|
211
|
-
name: "utilities"
|
|
212
|
-
});
|
|
213
|
-
var documentOptionsMenu = createMenu({
|
|
214
|
-
name: "document-options",
|
|
215
|
-
groups: ["save"]
|
|
216
|
-
});
|
|
188
|
+
import { createLocation as createLocation2 } from "@elementor/locations";
|
|
189
|
+
var {
|
|
190
|
+
inject: injectIntoPageIndication,
|
|
191
|
+
Slot: PageIndicationSlot
|
|
192
|
+
} = createLocation2();
|
|
193
|
+
var {
|
|
194
|
+
inject: injectIntoResponsive,
|
|
195
|
+
Slot: ResponsiveSlot
|
|
196
|
+
} = createLocation2();
|
|
197
|
+
var {
|
|
198
|
+
inject: injectIntoPrimaryAction,
|
|
199
|
+
Slot: PrimaryActionSlot
|
|
200
|
+
} = createLocation2();
|
|
201
|
+
var mainMenu = createMenu(["exits"]);
|
|
202
|
+
var toolsMenu = createMenu();
|
|
203
|
+
var utilitiesMenu = createMenu();
|
|
204
|
+
var documentOptionsMenu = createMenu(["save"]);
|
|
217
205
|
|
|
218
206
|
// src/components/app-bar.tsx
|
|
219
207
|
import * as React19 from "react";
|
|
@@ -391,23 +379,20 @@ function UtilitiesMenuLocation() {
|
|
|
391
379
|
|
|
392
380
|
// src/components/locations/primary-action-location.tsx
|
|
393
381
|
import * as React16 from "react";
|
|
394
|
-
import { Slot } from "@elementor/locations";
|
|
395
382
|
function PrimaryActionLocation() {
|
|
396
|
-
return /* @__PURE__ */ React16.createElement(
|
|
383
|
+
return /* @__PURE__ */ React16.createElement(PrimaryActionSlot, null);
|
|
397
384
|
}
|
|
398
385
|
|
|
399
386
|
// src/components/locations/page-indication-location.tsx
|
|
400
387
|
import * as React17 from "react";
|
|
401
|
-
import { Slot as Slot2 } from "@elementor/locations";
|
|
402
388
|
function PageIndicationLocation() {
|
|
403
|
-
return /* @__PURE__ */ React17.createElement(
|
|
389
|
+
return /* @__PURE__ */ React17.createElement(PageIndicationSlot, null);
|
|
404
390
|
}
|
|
405
391
|
|
|
406
392
|
// src/components/locations/responsive-location.tsx
|
|
407
393
|
import * as React18 from "react";
|
|
408
|
-
import { Slot as Slot3 } from "@elementor/locations";
|
|
409
394
|
function ResponsiveLocation() {
|
|
410
|
-
return /* @__PURE__ */ React18.createElement(
|
|
395
|
+
return /* @__PURE__ */ React18.createElement(ResponsiveSlot, null);
|
|
411
396
|
}
|
|
412
397
|
|
|
413
398
|
// src/components/app-bar.tsx
|
|
@@ -459,7 +444,7 @@ function SettingsButton() {
|
|
|
459
444
|
// src/extensions/documents-indicator/index.ts
|
|
460
445
|
function init() {
|
|
461
446
|
injectIntoPageIndication({
|
|
462
|
-
|
|
447
|
+
id: "document-settings-button",
|
|
463
448
|
filler: SettingsButton,
|
|
464
449
|
options: {
|
|
465
450
|
priority: 20
|
|
@@ -488,7 +473,7 @@ function useActionProps() {
|
|
|
488
473
|
// src/extensions/documents-preview/index.ts
|
|
489
474
|
function init2() {
|
|
490
475
|
utilitiesMenu.registerAction({
|
|
491
|
-
|
|
476
|
+
id: "document-preview-button",
|
|
492
477
|
priority: 30,
|
|
493
478
|
// After help.
|
|
494
479
|
useProps: useActionProps
|
|
@@ -638,19 +623,19 @@ function isEnabled(document2) {
|
|
|
638
623
|
// src/extensions/documents-save/index.ts
|
|
639
624
|
function init3() {
|
|
640
625
|
injectIntoPrimaryAction({
|
|
641
|
-
|
|
626
|
+
id: "document-primary-action",
|
|
642
627
|
filler: PrimaryAction
|
|
643
628
|
});
|
|
644
629
|
documentOptionsMenu.registerAction({
|
|
645
630
|
group: "save",
|
|
646
|
-
|
|
631
|
+
id: "document-save-draft",
|
|
647
632
|
priority: 10,
|
|
648
633
|
// Before save as template.
|
|
649
634
|
useProps: useDocumentSaveDraftProps
|
|
650
635
|
});
|
|
651
636
|
documentOptionsMenu.registerAction({
|
|
652
637
|
group: "save",
|
|
653
|
-
|
|
638
|
+
id: "document-save-as-template",
|
|
654
639
|
priority: 20,
|
|
655
640
|
// After save draft.
|
|
656
641
|
useProps: useDocumentSaveTemplateProps
|
|
@@ -709,7 +694,7 @@ function useActionProps2() {
|
|
|
709
694
|
function init4() {
|
|
710
695
|
syncPanelTitle();
|
|
711
696
|
toolsMenu.registerToggleAction({
|
|
712
|
-
|
|
697
|
+
id: "open-elements-panel",
|
|
713
698
|
priority: 1,
|
|
714
699
|
useProps: useActionProps2
|
|
715
700
|
});
|
|
@@ -736,7 +721,7 @@ function useActionProps3() {
|
|
|
736
721
|
// src/extensions/finder/index.ts
|
|
737
722
|
function init5() {
|
|
738
723
|
utilitiesMenu.registerToggleAction({
|
|
739
|
-
|
|
724
|
+
id: "toggle-finder",
|
|
740
725
|
priority: 10,
|
|
741
726
|
// Before help.
|
|
742
727
|
useProps: useActionProps3
|
|
@@ -748,7 +733,7 @@ import { __ as __11 } from "@wordpress/i18n";
|
|
|
748
733
|
import { HelpIcon } from "@elementor/icons";
|
|
749
734
|
function init6() {
|
|
750
735
|
utilitiesMenu.registerLink({
|
|
751
|
-
|
|
736
|
+
id: "open-help-center",
|
|
752
737
|
priority: 20,
|
|
753
738
|
// After Finder.
|
|
754
739
|
useProps: () => {
|
|
@@ -780,7 +765,7 @@ function useActionProps4() {
|
|
|
780
765
|
// src/extensions/history/index.ts
|
|
781
766
|
function init7() {
|
|
782
767
|
mainMenu.registerToggleAction({
|
|
783
|
-
|
|
768
|
+
id: "open-history",
|
|
784
769
|
priority: 20,
|
|
785
770
|
useProps: useActionProps4
|
|
786
771
|
});
|
|
@@ -801,7 +786,7 @@ function useActionProps5() {
|
|
|
801
786
|
// src/extensions/keyboard-shortcuts/index.ts
|
|
802
787
|
function init8() {
|
|
803
788
|
mainMenu.registerAction({
|
|
804
|
-
|
|
789
|
+
id: "open-keyboard-shortcuts",
|
|
805
790
|
group: "default",
|
|
806
791
|
priority: 40,
|
|
807
792
|
// After user preferences.
|
|
@@ -887,11 +872,11 @@ function useActionProps6() {
|
|
|
887
872
|
// src/extensions/site-settings/index.ts
|
|
888
873
|
function init9() {
|
|
889
874
|
injectIntoTop({
|
|
890
|
-
|
|
875
|
+
id: "site-settings-primary-action-portal",
|
|
891
876
|
filler: PortalledPrimaryAction
|
|
892
877
|
});
|
|
893
878
|
toolsMenu.registerToggleAction({
|
|
894
|
-
|
|
879
|
+
id: "toggle-site-settings",
|
|
895
880
|
priority: 2,
|
|
896
881
|
useProps: useActionProps6
|
|
897
882
|
});
|
|
@@ -915,7 +900,7 @@ function useActionProps7() {
|
|
|
915
900
|
// src/extensions/structure/index.ts
|
|
916
901
|
function init10() {
|
|
917
902
|
toolsMenu.registerToggleAction({
|
|
918
|
-
|
|
903
|
+
id: "toggle-structure-view",
|
|
919
904
|
priority: 3,
|
|
920
905
|
useProps: useActionProps7
|
|
921
906
|
});
|
|
@@ -936,7 +921,7 @@ function useActionProps8() {
|
|
|
936
921
|
// src/extensions/theme-builder/index.ts
|
|
937
922
|
function init11() {
|
|
938
923
|
mainMenu.registerAction({
|
|
939
|
-
|
|
924
|
+
id: "open-theme-builder",
|
|
940
925
|
useProps: useActionProps8
|
|
941
926
|
});
|
|
942
927
|
}
|
|
@@ -959,37 +944,28 @@ function useActionProps9() {
|
|
|
959
944
|
// src/extensions/user-preferences/index.ts
|
|
960
945
|
function init12() {
|
|
961
946
|
mainMenu.registerToggleAction({
|
|
962
|
-
|
|
947
|
+
id: "open-user-preferences",
|
|
963
948
|
priority: 30,
|
|
964
949
|
// After history.
|
|
965
950
|
useProps: useActionProps9
|
|
966
951
|
});
|
|
967
952
|
}
|
|
968
953
|
|
|
969
|
-
// src/env.ts
|
|
970
|
-
import { parseEnv, InvalidEnvError } from "@elementor/env";
|
|
971
|
-
var { env, validateEnv } = parseEnv("@elementor/editor-app-bar", (envData) => {
|
|
972
|
-
if (!isValid(envData)) {
|
|
973
|
-
throw new InvalidEnvError("Invalid admin URL");
|
|
974
|
-
}
|
|
975
|
-
return envData;
|
|
976
|
-
});
|
|
977
|
-
function isValid(subject) {
|
|
978
|
-
return "admin_url" in subject && typeof subject.admin_url === "string";
|
|
979
|
-
}
|
|
980
|
-
|
|
981
954
|
// src/extensions/wordpress/index.ts
|
|
982
955
|
import { __ as __19 } from "@wordpress/i18n";
|
|
983
956
|
import { WordpressIcon } from "@elementor/icons";
|
|
957
|
+
import { useActiveDocument as useActiveDocument6 } from "@elementor/editor-documents";
|
|
984
958
|
function init13() {
|
|
985
959
|
mainMenu.registerLink({
|
|
986
|
-
|
|
960
|
+
id: "exit-to-wordpress",
|
|
987
961
|
group: "exits",
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
962
|
+
useProps: () => {
|
|
963
|
+
const document2 = useActiveDocument6();
|
|
964
|
+
return {
|
|
965
|
+
title: __19("Exit to WordPress", "elementor"),
|
|
966
|
+
href: document2?.links?.platformEdit,
|
|
967
|
+
icon: WordpressIcon
|
|
968
|
+
};
|
|
993
969
|
}
|
|
994
970
|
});
|
|
995
971
|
}
|
|
@@ -1013,11 +989,10 @@ function init14() {
|
|
|
1013
989
|
|
|
1014
990
|
// src/init.ts
|
|
1015
991
|
function init15() {
|
|
1016
|
-
validateEnv();
|
|
1017
992
|
redirectOldMenus();
|
|
1018
993
|
init14();
|
|
1019
994
|
injectIntoTop2({
|
|
1020
|
-
|
|
995
|
+
id: "app-bar",
|
|
1021
996
|
filler: AppBar
|
|
1022
997
|
});
|
|
1023
998
|
}
|