@elementor/editor-site-navigation 0.18.4 → 0.19.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 +17 -0
- package/dist/index.js +17 -18
- package/dist/index.mjs +26 -27
- package/package.json +6 -6
- package/src/components/panel/actions-menu/actions/__tests__/delete.test.tsx +1 -1
- package/src/components/panel/actions-menu/actions/delete.tsx +2 -2
- package/src/components/panel/panel.ts +2 -2
- package/src/components/panel/posts-list/__tests__/post-list-item.test.tsx +4 -4
- package/src/components/panel/posts-list/__tests__/posts-collapsible-list.test.tsx +10 -6
- package/src/components/panel/posts-list/list-items/list-item-create.tsx +2 -2
- package/src/components/panel/posts-list/list-items/list-item-duplicate.tsx +2 -2
- package/src/components/panel/posts-list/list-items/list-item-view.tsx +3 -3
- package/src/components/top-bar/__tests__/add-new-page.test.tsx +15 -41
- package/src/components/top-bar/__tests__/recently-edited.test.tsx +63 -68
- package/src/components/top-bar/chip-doc-type.tsx +2 -2
- package/src/components/top-bar/create-post-list-item.tsx +2 -2
- package/src/components/top-bar/indicator.tsx +2 -2
- package/src/components/top-bar/post-list-item.tsx +2 -2
- package/src/components/top-bar/recently-edited.tsx +5 -6
- package/src/init.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
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.19.0](https://github.com/elementor/elementor-packages/compare/@elementor/editor-site-navigation@0.18.4...@elementor/editor-site-navigation@0.19.0) (2023-09-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* ui adaptations [ED-11933] ([#107](https://github.com/elementor/elementor-packages/issues/107)) ([18ef329](https://github.com/elementor/elementor-packages/commit/18ef32928cbe921d7f5340c37c3c965b117d8d63))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **editor-documents:** mark experimental functions [ED-12066] ([#112](https://github.com/elementor/elementor-packages/issues/112)) ([f4b7a9a](https://github.com/elementor/elementor-packages/commit/f4b7a9ac7953a2b48062349495acff05b5640de3))
|
|
17
|
+
* **editor-panels:** mark experimental functions [ED-12067] ([#113](https://github.com/elementor/elementor-packages/issues/113)) ([152ef9f](https://github.com/elementor/elementor-packages/commit/152ef9f6980cd27571537db1738c69de63e2d4bb))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
6
23
|
## [0.18.4](https://github.com/elementor/elementor-packages/compare/@elementor/editor-site-navigation@0.18.3...@elementor/editor-site-navigation@0.18.4) (2023-08-22)
|
|
7
24
|
|
|
8
25
|
**Note:** Version bump only for package @elementor/editor-site-navigation
|
package/dist/index.js
CHANGED
|
@@ -61,7 +61,7 @@ var import_editor_documents3 = require("@elementor/editor-documents");
|
|
|
61
61
|
var React = __toESM(require("react"));
|
|
62
62
|
var import_ui = require("@elementor/ui");
|
|
63
63
|
function Indicator({ title, status }) {
|
|
64
|
-
return /* @__PURE__ */ React.createElement(Tooltip, { title }, /* @__PURE__ */ React.createElement(import_ui.Stack, { component: "span", direction: "row", alignItems: "center", spacing:
|
|
64
|
+
return /* @__PURE__ */ React.createElement(Tooltip, { title }, /* @__PURE__ */ React.createElement(import_ui.Stack, { component: "span", direction: "row", alignItems: "center", spacing: 0.5 }, /* @__PURE__ */ React.createElement(import_ui.Typography, { component: "span", variant: "body2", sx: { maxWidth: "120px" }, noWrap: true }, title), status.value !== "publish" && /* @__PURE__ */ React.createElement(import_ui.Typography, { component: "span", variant: "body2", sx: { fontStyle: "italic" } }, "(", status.label, ")")));
|
|
65
65
|
}
|
|
66
66
|
function Tooltip(props) {
|
|
67
67
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -70,7 +70,7 @@ function Tooltip(props) {
|
|
|
70
70
|
PopperProps: {
|
|
71
71
|
sx: {
|
|
72
72
|
"&.MuiTooltip-popper .MuiTooltip-tooltip.MuiTooltip-tooltipPlacementBottom": {
|
|
73
|
-
mt: 7
|
|
73
|
+
mt: 2.7
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
},
|
|
@@ -126,13 +126,13 @@ function DocTypeChip({ postType, docType, label }) {
|
|
|
126
126
|
import_ui2.Chip,
|
|
127
127
|
{
|
|
128
128
|
component: "span",
|
|
129
|
-
size: "
|
|
129
|
+
size: "small",
|
|
130
130
|
variant: "standard",
|
|
131
131
|
label,
|
|
132
132
|
"data-value": docType,
|
|
133
133
|
color,
|
|
134
134
|
icon: /* @__PURE__ */ React2.createElement(Icon, null),
|
|
135
|
-
sx: { ml:
|
|
135
|
+
sx: { ml: 1, cursor: "inherit" }
|
|
136
136
|
}
|
|
137
137
|
);
|
|
138
138
|
}
|
|
@@ -156,7 +156,7 @@ function useReverseHtmlEntities(escapedHTML = "") {
|
|
|
156
156
|
|
|
157
157
|
// src/components/top-bar/post-list-item.tsx
|
|
158
158
|
function PostListItem({ post, closePopup, ...props }) {
|
|
159
|
-
const navigateToDocument = (0, import_editor_documents.
|
|
159
|
+
const navigateToDocument = (0, import_editor_documents.__useNavigateToDocument)();
|
|
160
160
|
const postTitle = useReverseHtmlEntities(post.title);
|
|
161
161
|
return /* @__PURE__ */ React3.createElement(
|
|
162
162
|
import_ui3.MenuItem,
|
|
@@ -218,7 +218,7 @@ var import_i18n = require("@wordpress/i18n");
|
|
|
218
218
|
var import_editor_documents2 = require("@elementor/editor-documents");
|
|
219
219
|
function CreatePostListItem({ closePopup, ...props }) {
|
|
220
220
|
const { create, isLoading } = useCreatePage();
|
|
221
|
-
const navigateToDocument = (0, import_editor_documents2.
|
|
221
|
+
const navigateToDocument = (0, import_editor_documents2.__useNavigateToDocument)();
|
|
222
222
|
return /* @__PURE__ */ React4.createElement(
|
|
223
223
|
import_ui4.MenuItem,
|
|
224
224
|
{
|
|
@@ -236,8 +236,8 @@ function CreatePostListItem({ closePopup, ...props }) {
|
|
|
236
236
|
|
|
237
237
|
// src/components/top-bar/recently-edited.tsx
|
|
238
238
|
function RecentlyEdited() {
|
|
239
|
-
const activeDocument = (0, import_editor_documents3.
|
|
240
|
-
const hostDocument = (0, import_editor_documents3.
|
|
239
|
+
const activeDocument = (0, import_editor_documents3.__useActiveDocument)();
|
|
240
|
+
const hostDocument = (0, import_editor_documents3.__useHostDocument)();
|
|
241
241
|
const document2 = activeDocument && activeDocument.type.value !== "kit" ? activeDocument : hostDocument;
|
|
242
242
|
const { recentPosts } = useRecentPosts(document2?.id);
|
|
243
243
|
const popupState = (0, import_ui5.usePopupState)({
|
|
@@ -267,10 +267,9 @@ function RecentlyEdited() {
|
|
|
267
267
|
import_ui5.Menu,
|
|
268
268
|
{
|
|
269
269
|
MenuListProps: {
|
|
270
|
-
|
|
271
|
-
subheader: /* @__PURE__ */ React5.createElement(import_ui5.ListSubheader, { sx: { fontStyle: "italic", fontWeight: "300" } }, (0, import_i18n2.__)("Recent", "elementor"))
|
|
270
|
+
subheader: /* @__PURE__ */ React5.createElement(import_ui5.ListSubheader, { color: "primary", sx: { fontStyle: "italic", fontWeight: "300" } }, (0, import_i18n2.__)("Recent", "elementor"))
|
|
272
271
|
},
|
|
273
|
-
PaperProps: { sx: { mt:
|
|
272
|
+
PaperProps: { sx: { mt: 2.5, width: 320 } },
|
|
274
273
|
...(0, import_ui5.bindMenu)(popupState)
|
|
275
274
|
},
|
|
276
275
|
recentPosts.map((post) => /* @__PURE__ */ React5.createElement(PostListItem, { key: post.id, post, closePopup: popupState.close })),
|
|
@@ -595,7 +594,7 @@ var import_editor_documents4 = require("@elementor/editor-documents");
|
|
|
595
594
|
function ListItemCreate() {
|
|
596
595
|
const { type, resetEditMode } = usePostListContext();
|
|
597
596
|
const { createPost } = usePostActions(type);
|
|
598
|
-
const navigateToDocument = (0, import_editor_documents4.
|
|
597
|
+
const navigateToDocument = (0, import_editor_documents4.__useNavigateToDocument)();
|
|
599
598
|
const createPostCallback = (inputValue) => {
|
|
600
599
|
createPost.mutateAsync({
|
|
601
600
|
title: inputValue,
|
|
@@ -616,7 +615,7 @@ var import_i18n6 = require("@wordpress/i18n");
|
|
|
616
615
|
var import_editor_documents5 = require("@elementor/editor-documents");
|
|
617
616
|
function ListItemDuplicate() {
|
|
618
617
|
const { type, editMode, resetEditMode } = usePostListContext();
|
|
619
|
-
const navigateToDocument = (0, import_editor_documents5.
|
|
618
|
+
const navigateToDocument = (0, import_editor_documents5.__useNavigateToDocument)();
|
|
620
619
|
const { duplicatePost } = usePostActions(type);
|
|
621
620
|
if ("duplicate" !== editMode.mode) {
|
|
622
621
|
return null;
|
|
@@ -762,7 +761,7 @@ var import_react7 = require("react");
|
|
|
762
761
|
var import_editor_documents6 = require("@elementor/editor-documents");
|
|
763
762
|
function Delete({ post }) {
|
|
764
763
|
const [isDialogOpen, setIsDialogOpen] = (0, import_react7.useState)(false);
|
|
765
|
-
const activeDocument = (0, import_editor_documents6.
|
|
764
|
+
const activeDocument = (0, import_editor_documents6.__useActiveDocument)();
|
|
766
765
|
const isPostActive = activeDocument?.id === post.id;
|
|
767
766
|
return /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(
|
|
768
767
|
ActionMenuItem,
|
|
@@ -901,8 +900,8 @@ function SetHome({ post }) {
|
|
|
901
900
|
// src/components/panel/posts-list/list-items/list-item-view.tsx
|
|
902
901
|
var import_i18n12 = require("@wordpress/i18n");
|
|
903
902
|
function ListItemView({ post }) {
|
|
904
|
-
const activeDocument = (0, import_editor_documents7.
|
|
905
|
-
const navigateToDocument = (0, import_editor_documents7.
|
|
903
|
+
const activeDocument = (0, import_editor_documents7.__useActiveDocument)();
|
|
904
|
+
const navigateToDocument = (0, import_editor_documents7.__useNavigateToDocument)();
|
|
906
905
|
const popupState = (0, import_ui12.usePopupState)({
|
|
907
906
|
variant: "popover",
|
|
908
907
|
popupId: "post-actions",
|
|
@@ -1055,7 +1054,7 @@ var {
|
|
|
1055
1054
|
panel,
|
|
1056
1055
|
usePanelStatus,
|
|
1057
1056
|
usePanelActions
|
|
1058
|
-
} = (0, import_editor_panels2.
|
|
1057
|
+
} = (0, import_editor_panels2.__createPanel)({
|
|
1059
1058
|
id: "site-navigation-panel",
|
|
1060
1059
|
component: shell_default
|
|
1061
1060
|
});
|
|
@@ -1086,7 +1085,7 @@ var { env, validateEnv } = (0, import_env.parseEnv)("@elementor/editor-site-navi
|
|
|
1086
1085
|
function init() {
|
|
1087
1086
|
registerTopBarMenuItems();
|
|
1088
1087
|
if (env.is_pages_panel_active) {
|
|
1089
|
-
(0, import_editor_panels3.
|
|
1088
|
+
(0, import_editor_panels3.__registerPanel)(panel);
|
|
1090
1089
|
registerButton();
|
|
1091
1090
|
}
|
|
1092
1091
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -35,13 +35,13 @@ import {
|
|
|
35
35
|
MenuItem as MenuItem3
|
|
36
36
|
} from "@elementor/ui";
|
|
37
37
|
import { ChevronDownIcon } from "@elementor/icons";
|
|
38
|
-
import {
|
|
38
|
+
import { __useActiveDocument, __useHostDocument } from "@elementor/editor-documents";
|
|
39
39
|
|
|
40
40
|
// src/components/top-bar/indicator.tsx
|
|
41
41
|
import * as React from "react";
|
|
42
42
|
import { Typography, Stack, Tooltip as BaseTooltip } from "@elementor/ui";
|
|
43
43
|
function Indicator({ title, status }) {
|
|
44
|
-
return /* @__PURE__ */ React.createElement(Tooltip, { title }, /* @__PURE__ */ React.createElement(Stack, { component: "span", direction: "row", alignItems: "center", spacing:
|
|
44
|
+
return /* @__PURE__ */ React.createElement(Tooltip, { title }, /* @__PURE__ */ React.createElement(Stack, { component: "span", direction: "row", alignItems: "center", spacing: 0.5 }, /* @__PURE__ */ React.createElement(Typography, { component: "span", variant: "body2", sx: { maxWidth: "120px" }, noWrap: true }, title), status.value !== "publish" && /* @__PURE__ */ React.createElement(Typography, { component: "span", variant: "body2", sx: { fontStyle: "italic" } }, "(", status.label, ")")));
|
|
45
45
|
}
|
|
46
46
|
function Tooltip(props) {
|
|
47
47
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -50,7 +50,7 @@ function Tooltip(props) {
|
|
|
50
50
|
PopperProps: {
|
|
51
51
|
sx: {
|
|
52
52
|
"&.MuiTooltip-popper .MuiTooltip-tooltip.MuiTooltip-tooltipPlacementBottom": {
|
|
53
|
-
mt: 7
|
|
53
|
+
mt: 2.7
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
},
|
|
@@ -108,13 +108,13 @@ function DocTypeChip({ postType, docType, label }) {
|
|
|
108
108
|
Chip,
|
|
109
109
|
{
|
|
110
110
|
component: "span",
|
|
111
|
-
size: "
|
|
111
|
+
size: "small",
|
|
112
112
|
variant: "standard",
|
|
113
113
|
label,
|
|
114
114
|
"data-value": docType,
|
|
115
115
|
color,
|
|
116
116
|
icon: /* @__PURE__ */ React2.createElement(Icon, null),
|
|
117
|
-
sx: { ml:
|
|
117
|
+
sx: { ml: 1, cursor: "inherit" }
|
|
118
118
|
}
|
|
119
119
|
);
|
|
120
120
|
}
|
|
@@ -122,7 +122,7 @@ function DocTypeChip({ postType, docType, label }) {
|
|
|
122
122
|
// src/components/top-bar/post-list-item.tsx
|
|
123
123
|
import { MenuItem, ListItemText } from "@elementor/ui";
|
|
124
124
|
import * as React3 from "react";
|
|
125
|
-
import {
|
|
125
|
+
import { __useNavigateToDocument } from "@elementor/editor-documents";
|
|
126
126
|
|
|
127
127
|
// src/hooks/use-reverse-html-entities.ts
|
|
128
128
|
import { useMemo } from "react";
|
|
@@ -138,7 +138,7 @@ function useReverseHtmlEntities(escapedHTML = "") {
|
|
|
138
138
|
|
|
139
139
|
// src/components/top-bar/post-list-item.tsx
|
|
140
140
|
function PostListItem({ post, closePopup, ...props }) {
|
|
141
|
-
const navigateToDocument =
|
|
141
|
+
const navigateToDocument = __useNavigateToDocument();
|
|
142
142
|
const postTitle = useReverseHtmlEntities(post.title);
|
|
143
143
|
return /* @__PURE__ */ React3.createElement(
|
|
144
144
|
MenuItem,
|
|
@@ -197,10 +197,10 @@ async function addNewPage() {
|
|
|
197
197
|
// src/components/top-bar/create-post-list-item.tsx
|
|
198
198
|
import { PlusIcon } from "@elementor/icons";
|
|
199
199
|
import { __ } from "@wordpress/i18n";
|
|
200
|
-
import {
|
|
200
|
+
import { __useNavigateToDocument as __useNavigateToDocument2 } from "@elementor/editor-documents";
|
|
201
201
|
function CreatePostListItem({ closePopup, ...props }) {
|
|
202
202
|
const { create, isLoading } = useCreatePage();
|
|
203
|
-
const navigateToDocument =
|
|
203
|
+
const navigateToDocument = __useNavigateToDocument2();
|
|
204
204
|
return /* @__PURE__ */ React4.createElement(
|
|
205
205
|
MenuItem2,
|
|
206
206
|
{
|
|
@@ -218,8 +218,8 @@ function CreatePostListItem({ closePopup, ...props }) {
|
|
|
218
218
|
|
|
219
219
|
// src/components/top-bar/recently-edited.tsx
|
|
220
220
|
function RecentlyEdited() {
|
|
221
|
-
const activeDocument =
|
|
222
|
-
const hostDocument =
|
|
221
|
+
const activeDocument = __useActiveDocument();
|
|
222
|
+
const hostDocument = __useHostDocument();
|
|
223
223
|
const document2 = activeDocument && activeDocument.type.value !== "kit" ? activeDocument : hostDocument;
|
|
224
224
|
const { recentPosts } = useRecentPosts(document2?.id);
|
|
225
225
|
const popupState = usePopupState({
|
|
@@ -249,10 +249,9 @@ function RecentlyEdited() {
|
|
|
249
249
|
Menu,
|
|
250
250
|
{
|
|
251
251
|
MenuListProps: {
|
|
252
|
-
|
|
253
|
-
subheader: /* @__PURE__ */ React5.createElement(ListSubheader, { sx: { fontStyle: "italic", fontWeight: "300" } }, __2("Recent", "elementor"))
|
|
252
|
+
subheader: /* @__PURE__ */ React5.createElement(ListSubheader, { color: "primary", sx: { fontStyle: "italic", fontWeight: "300" } }, __2("Recent", "elementor"))
|
|
254
253
|
},
|
|
255
|
-
PaperProps: { sx: { mt:
|
|
254
|
+
PaperProps: { sx: { mt: 2.5, width: 320 } },
|
|
256
255
|
...bindMenu(popupState)
|
|
257
256
|
},
|
|
258
257
|
recentPosts.map((post) => /* @__PURE__ */ React5.createElement(PostListItem, { key: post.id, post, closePopup: popupState.close })),
|
|
@@ -279,7 +278,7 @@ import { __ as __15 } from "@wordpress/i18n";
|
|
|
279
278
|
import { PagesIcon } from "@elementor/icons";
|
|
280
279
|
|
|
281
280
|
// src/components/panel/panel.ts
|
|
282
|
-
import {
|
|
281
|
+
import { __createPanel } from "@elementor/editor-panels";
|
|
283
282
|
|
|
284
283
|
// src/components/panel/shell.tsx
|
|
285
284
|
import * as React23 from "react";
|
|
@@ -579,11 +578,11 @@ function ListItemRename({ post }) {
|
|
|
579
578
|
// src/components/panel/posts-list/list-items/list-item-create.tsx
|
|
580
579
|
import * as React10 from "react";
|
|
581
580
|
import { __ as __5 } from "@wordpress/i18n";
|
|
582
|
-
import {
|
|
581
|
+
import { __useNavigateToDocument as __useNavigateToDocument3 } from "@elementor/editor-documents";
|
|
583
582
|
function ListItemCreate() {
|
|
584
583
|
const { type, resetEditMode } = usePostListContext();
|
|
585
584
|
const { createPost } = usePostActions(type);
|
|
586
|
-
const navigateToDocument =
|
|
585
|
+
const navigateToDocument = __useNavigateToDocument3();
|
|
587
586
|
const createPostCallback = (inputValue) => {
|
|
588
587
|
createPost.mutateAsync({
|
|
589
588
|
title: inputValue,
|
|
@@ -601,10 +600,10 @@ function ListItemCreate() {
|
|
|
601
600
|
// src/components/panel/posts-list/list-items/list-item-duplicate.tsx
|
|
602
601
|
import * as React11 from "react";
|
|
603
602
|
import { __ as __6 } from "@wordpress/i18n";
|
|
604
|
-
import {
|
|
603
|
+
import { __useNavigateToDocument as __useNavigateToDocument4 } from "@elementor/editor-documents";
|
|
605
604
|
function ListItemDuplicate() {
|
|
606
605
|
const { type, editMode, resetEditMode } = usePostListContext();
|
|
607
|
-
const navigateToDocument =
|
|
606
|
+
const navigateToDocument = __useNavigateToDocument4();
|
|
608
607
|
const { duplicatePost } = usePostActions(type);
|
|
609
608
|
if ("duplicate" !== editMode.mode) {
|
|
610
609
|
return null;
|
|
@@ -638,7 +637,7 @@ import {
|
|
|
638
637
|
usePopupState as usePopupState2
|
|
639
638
|
} from "@elementor/ui";
|
|
640
639
|
import { DotsVerticalIcon, HomeIcon as HomeIcon2 } from "@elementor/icons";
|
|
641
|
-
import {
|
|
640
|
+
import { __useActiveDocument as __useActiveDocument3, __useNavigateToDocument as __useNavigateToDocument5 } from "@elementor/editor-documents";
|
|
642
641
|
|
|
643
642
|
// src/components/shared/page-title-and-status.tsx
|
|
644
643
|
import * as React12 from "react";
|
|
@@ -772,10 +771,10 @@ import {
|
|
|
772
771
|
Divider as Divider3
|
|
773
772
|
} from "@elementor/ui";
|
|
774
773
|
import { useState as useState6 } from "react";
|
|
775
|
-
import {
|
|
774
|
+
import { __useActiveDocument as __useActiveDocument2 } from "@elementor/editor-documents";
|
|
776
775
|
function Delete({ post }) {
|
|
777
776
|
const [isDialogOpen, setIsDialogOpen] = useState6(false);
|
|
778
|
-
const activeDocument =
|
|
777
|
+
const activeDocument = __useActiveDocument2();
|
|
779
778
|
const isPostActive = activeDocument?.id === post.id;
|
|
780
779
|
return /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(
|
|
781
780
|
ActionMenuItem,
|
|
@@ -914,8 +913,8 @@ function SetHome({ post }) {
|
|
|
914
913
|
// src/components/panel/posts-list/list-items/list-item-view.tsx
|
|
915
914
|
import { __ as __12 } from "@wordpress/i18n";
|
|
916
915
|
function ListItemView({ post }) {
|
|
917
|
-
const activeDocument =
|
|
918
|
-
const navigateToDocument =
|
|
916
|
+
const activeDocument = __useActiveDocument3();
|
|
917
|
+
const navigateToDocument = __useNavigateToDocument5();
|
|
919
918
|
const popupState = usePopupState2({
|
|
920
919
|
variant: "popover",
|
|
921
920
|
popupId: "post-actions",
|
|
@@ -1068,7 +1067,7 @@ var {
|
|
|
1068
1067
|
panel,
|
|
1069
1068
|
usePanelStatus,
|
|
1070
1069
|
usePanelActions
|
|
1071
|
-
} =
|
|
1070
|
+
} = __createPanel({
|
|
1072
1071
|
id: "site-navigation-panel",
|
|
1073
1072
|
component: shell_default
|
|
1074
1073
|
});
|
|
@@ -1087,7 +1086,7 @@ function useToggleButtonProps() {
|
|
|
1087
1086
|
}
|
|
1088
1087
|
|
|
1089
1088
|
// src/init.ts
|
|
1090
|
-
import {
|
|
1089
|
+
import { __registerPanel } from "@elementor/editor-panels";
|
|
1091
1090
|
|
|
1092
1091
|
// src/env.ts
|
|
1093
1092
|
import { parseEnv } from "@elementor/env";
|
|
@@ -1099,7 +1098,7 @@ var { env, validateEnv } = parseEnv("@elementor/editor-site-navigation", (envDat
|
|
|
1099
1098
|
function init() {
|
|
1100
1099
|
registerTopBarMenuItems();
|
|
1101
1100
|
if (env.is_pages_panel_active) {
|
|
1102
|
-
|
|
1101
|
+
__registerPanel(panel);
|
|
1103
1102
|
registerButton();
|
|
1104
1103
|
}
|
|
1105
1104
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-site-navigation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@elementor/editor-app-bar": "^0.
|
|
36
|
-
"@elementor/editor-documents": "^0.
|
|
37
|
-
"@elementor/editor-panels": "^0.
|
|
38
|
-
"@elementor/env": "^0.
|
|
35
|
+
"@elementor/editor-app-bar": "^0.8.0",
|
|
36
|
+
"@elementor/editor-documents": "^0.9.0",
|
|
37
|
+
"@elementor/editor-panels": "^0.3.0",
|
|
38
|
+
"@elementor/env": "^0.3.0",
|
|
39
39
|
"@elementor/icons": "^0.7.0",
|
|
40
40
|
"@elementor/query": "^0.1.1",
|
|
41
41
|
"@elementor/ui": "^1.4.53",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"elementor": {
|
|
50
50
|
"type": "extension"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "7dc3971d2dd061848d6547aa2caed8332e7b9167"
|
|
53
53
|
}
|
|
@@ -14,7 +14,7 @@ jest.mock( '../../../../../hooks/use-posts-actions', () => ( {
|
|
|
14
14
|
} ) );
|
|
15
15
|
|
|
16
16
|
jest.mock( '@elementor/editor-documents', () => ( {
|
|
17
|
-
|
|
17
|
+
__useActiveDocument: jest.fn(),
|
|
18
18
|
} ) );
|
|
19
19
|
|
|
20
20
|
describe( '@elementor/editor-site-navigation/pages-panel-actions - Delete', () => {
|
|
@@ -16,11 +16,11 @@ import {
|
|
|
16
16
|
} from '@elementor/ui';
|
|
17
17
|
import { usePostListContext } from '../../../../contexts/post-list-context';
|
|
18
18
|
import { useState } from 'react';
|
|
19
|
-
import {
|
|
19
|
+
import { __useActiveDocument } from '@elementor/editor-documents';
|
|
20
20
|
|
|
21
21
|
export default function Delete( { post }: { post: Post } ) {
|
|
22
22
|
const [ isDialogOpen, setIsDialogOpen ] = useState( false );
|
|
23
|
-
const activeDocument =
|
|
23
|
+
const activeDocument = __useActiveDocument();
|
|
24
24
|
|
|
25
25
|
const isPostActive = activeDocument?.id === post.id;
|
|
26
26
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __createPanel } from '@elementor/editor-panels';
|
|
2
2
|
import Shell from './shell';
|
|
3
3
|
|
|
4
4
|
export const {
|
|
5
5
|
panel,
|
|
6
6
|
usePanelStatus,
|
|
7
7
|
usePanelActions,
|
|
8
|
-
} =
|
|
8
|
+
} = __createPanel( {
|
|
9
9
|
id: 'site-navigation-panel',
|
|
10
10
|
component: Shell,
|
|
11
11
|
} );
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { act, fireEvent, screen, waitFor } from '@testing-library/react';
|
|
3
3
|
import { Post } from '../../../../types';
|
|
4
4
|
import PostListItem from '../post-list-item';
|
|
5
|
-
import {
|
|
5
|
+
import { __useNavigateToDocument } from '@elementor/editor-documents';
|
|
6
6
|
import { renderWithQuery } from 'test-utils';
|
|
7
7
|
import { PostListContextProvider } from '../../../../contexts/post-list-context';
|
|
8
8
|
|
|
@@ -17,8 +17,8 @@ jest.mock( '../../../../hooks/use-posts-actions', () => ( {
|
|
|
17
17
|
} ) );
|
|
18
18
|
|
|
19
19
|
jest.mock( '@elementor/editor-documents', () => ( {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
__useActiveDocument: jest.fn(),
|
|
21
|
+
__useNavigateToDocument: jest.fn(),
|
|
22
22
|
} ) );
|
|
23
23
|
|
|
24
24
|
describe( '@elementor/editor-site-navigation - PostListItem', () => {
|
|
@@ -105,7 +105,7 @@ describe( '@elementor/editor-site-navigation - PostListItem', () => {
|
|
|
105
105
|
it( 'should navigate to document on click', () => {
|
|
106
106
|
// Arrange.
|
|
107
107
|
const navigateToDocument = jest.fn();
|
|
108
|
-
jest.mocked(
|
|
108
|
+
jest.mocked( __useNavigateToDocument ).mockReturnValue( navigateToDocument );
|
|
109
109
|
|
|
110
110
|
const id = 10;
|
|
111
111
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { fireEvent, screen, waitFor } from '@testing-library/react';
|
|
3
3
|
import PostsCollapsibleList from '../posts-collapsible-list';
|
|
4
|
-
import { renderWithQuery } from 'test-utils';
|
|
4
|
+
import { createMockDocument, renderWithQuery } from 'test-utils';
|
|
5
5
|
import { PostListContextProvider } from '../../../../contexts/post-list-context';
|
|
6
|
+
import { __useActiveDocument } from '@elementor/editor-documents';
|
|
6
7
|
|
|
7
8
|
const mockMutateAsync = jest.fn();
|
|
8
9
|
jest.mock( '../../../../hooks/use-posts-actions', () => ( {
|
|
@@ -41,14 +42,17 @@ jest.mock( '../../../../hooks/use-homepage', () => ( {
|
|
|
41
42
|
} ) );
|
|
42
43
|
|
|
43
44
|
jest.mock( '@elementor/editor-documents', () => ( {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
id: 2,
|
|
47
|
-
} ) ),
|
|
48
|
-
useNavigateToDocument: jest.fn(),
|
|
45
|
+
__useActiveDocument: jest.fn(),
|
|
46
|
+
__useNavigateToDocument: jest.fn(),
|
|
49
47
|
} ) );
|
|
50
48
|
|
|
51
49
|
describe( '@elementor/editor-site-navigation - PostsCollapsibleList', () => {
|
|
50
|
+
beforeEach( () => {
|
|
51
|
+
jest.mocked( __useActiveDocument ).mockReturnValue( createMockDocument( ( {
|
|
52
|
+
id: 2,
|
|
53
|
+
} ) ) );
|
|
54
|
+
} );
|
|
55
|
+
|
|
52
56
|
afterEach( () => {
|
|
53
57
|
jest.clearAllMocks();
|
|
54
58
|
} );
|
|
@@ -3,12 +3,12 @@ import { __ } from '@wordpress/i18n';
|
|
|
3
3
|
import { usePostListContext } from '../../../../contexts/post-list-context';
|
|
4
4
|
import { usePostActions } from '../../../../hooks/use-posts-actions';
|
|
5
5
|
import EditModeTemplate from './edit-mode-template';
|
|
6
|
-
import {
|
|
6
|
+
import { __useNavigateToDocument } from '@elementor/editor-documents';
|
|
7
7
|
|
|
8
8
|
export default function ListItemCreate() {
|
|
9
9
|
const { type, resetEditMode } = usePostListContext();
|
|
10
10
|
const { createPost } = usePostActions( type );
|
|
11
|
-
const navigateToDocument =
|
|
11
|
+
const navigateToDocument = __useNavigateToDocument();
|
|
12
12
|
|
|
13
13
|
const createPostCallback = ( inputValue: string ) => {
|
|
14
14
|
createPost.mutateAsync( {
|
|
@@ -3,11 +3,11 @@ import { __ } from '@wordpress/i18n';
|
|
|
3
3
|
import { usePostListContext } from '../../../../contexts/post-list-context';
|
|
4
4
|
import { usePostActions } from '../../../../hooks/use-posts-actions';
|
|
5
5
|
import EditModeTemplate from './edit-mode-template';
|
|
6
|
-
import {
|
|
6
|
+
import { __useNavigateToDocument } from '@elementor/editor-documents';
|
|
7
7
|
|
|
8
8
|
export default function ListItemDuplicate() {
|
|
9
9
|
const { type, editMode, resetEditMode } = usePostListContext();
|
|
10
|
-
const navigateToDocument =
|
|
10
|
+
const navigateToDocument = __useNavigateToDocument();
|
|
11
11
|
const { duplicatePost } = usePostActions( type );
|
|
12
12
|
|
|
13
13
|
if ( 'duplicate' !== editMode.mode ) {
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
usePopupState,
|
|
13
13
|
} from '@elementor/ui';
|
|
14
14
|
import { DotsVerticalIcon, HomeIcon } from '@elementor/icons';
|
|
15
|
-
import {
|
|
15
|
+
import { __useActiveDocument, __useNavigateToDocument } from '@elementor/editor-documents';
|
|
16
16
|
import PageTitleAndStatus from '../../../shared/page-title-and-status';
|
|
17
17
|
import Rename from '../../actions-menu/actions/rename';
|
|
18
18
|
import Duplicate from '../../actions-menu/actions/duplicate';
|
|
@@ -23,8 +23,8 @@ import { Post } from '../../../../types';
|
|
|
23
23
|
import { __ } from '@wordpress/i18n';
|
|
24
24
|
|
|
25
25
|
export default function ListItemView( { post }: { post: Post } ) {
|
|
26
|
-
const activeDocument =
|
|
27
|
-
const navigateToDocument =
|
|
26
|
+
const activeDocument = __useActiveDocument();
|
|
27
|
+
const navigateToDocument = __useNavigateToDocument();
|
|
28
28
|
|
|
29
29
|
const popupState = usePopupState( {
|
|
30
30
|
variant: 'popover',
|
|
@@ -1,45 +1,34 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
3
|
-
import {
|
|
3
|
+
import { __useActiveDocument, __useNavigateToDocument } from '@elementor/editor-documents';
|
|
4
4
|
import RecentlyEdited from '../recently-edited';
|
|
5
5
|
import { createMockDocument } from 'test-utils';
|
|
6
6
|
import useRecentPosts, { Post } from '../../../hooks/use-recent-posts';
|
|
7
7
|
import useCreatePage from '../../../hooks/use-create-page';
|
|
8
8
|
|
|
9
9
|
jest.mock( '@elementor/editor-documents', () => ( {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
__useActiveDocument: jest.fn(),
|
|
11
|
+
__useHostDocument: jest.fn(),
|
|
12
|
+
__useNavigateToDocument: jest.fn(),
|
|
13
13
|
} ) );
|
|
14
14
|
|
|
15
|
-
jest.mock( '../../../hooks/use-recent-posts', () => (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
|
|
24
|
-
__esModule: true,
|
|
25
|
-
}
|
|
26
|
-
) );
|
|
15
|
+
jest.mock( '../../../hooks/use-recent-posts', () => ( {
|
|
16
|
+
__esModule: true,
|
|
17
|
+
default: jest.fn( () => ( { isLoading: false, recentPosts: [] } ) ),
|
|
18
|
+
} ) );
|
|
19
|
+
|
|
20
|
+
jest.mock( '../../../hooks/use-create-page', () => ( {
|
|
21
|
+
__esModule: true,
|
|
22
|
+
default: jest.fn( () => ( { create: jest.fn(), isLoading: false } ) ),
|
|
23
|
+
} ) );
|
|
27
24
|
|
|
28
25
|
describe( '@elementor/recently-edited - Top bar add new page', () => {
|
|
29
26
|
beforeEach( () => {
|
|
30
|
-
jest.mocked(
|
|
31
|
-
createMockDocument( { id: 1, title: 'Active Document' } )
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
jest.mocked( useHostDocument ).mockImplementation( () =>
|
|
35
|
-
createMockDocument( { id: 2, title: 'Host Document' } )
|
|
36
|
-
);
|
|
27
|
+
jest.mocked( __useActiveDocument ).mockReturnValue( createMockDocument() );
|
|
37
28
|
} );
|
|
38
29
|
|
|
39
30
|
it( 'should render add new page button', () => {
|
|
40
31
|
// Arrange.
|
|
41
|
-
mockActiveDocument();
|
|
42
|
-
|
|
43
32
|
const isLoading = false;
|
|
44
33
|
const recentPosts: Post[] = [];
|
|
45
34
|
|
|
@@ -58,8 +47,6 @@ describe( '@elementor/recently-edited - Top bar add new page', () => {
|
|
|
58
47
|
|
|
59
48
|
it( 'should trigger create page hook on click', async () => {
|
|
60
49
|
// Arrange.
|
|
61
|
-
mockActiveDocument();
|
|
62
|
-
|
|
63
50
|
const isLoading = false;
|
|
64
51
|
const recentPosts: Post[] = [];
|
|
65
52
|
const create = jest.fn().mockReturnValue( Promise.resolve( { id: 123 } ) );
|
|
@@ -67,7 +54,7 @@ describe( '@elementor/recently-edited - Top bar add new page', () => {
|
|
|
67
54
|
|
|
68
55
|
jest.mocked( useRecentPosts ).mockReturnValue( { isLoading, recentPosts } );
|
|
69
56
|
jest.mocked( useCreatePage ).mockReturnValue( { isLoading, create } );
|
|
70
|
-
jest.mocked(
|
|
57
|
+
jest.mocked( __useNavigateToDocument ).mockReturnValue( navigateToDocument );
|
|
71
58
|
|
|
72
59
|
render( <RecentlyEdited /> );
|
|
73
60
|
|
|
@@ -86,16 +73,3 @@ describe( '@elementor/recently-edited - Top bar add new page', () => {
|
|
|
86
73
|
expect( navigateToDocument ).toHaveBeenCalledWith( 123 );
|
|
87
74
|
} );
|
|
88
75
|
} );
|
|
89
|
-
|
|
90
|
-
function mockActiveDocument() {
|
|
91
|
-
jest.mocked( useActiveDocument ).mockImplementation( () =>
|
|
92
|
-
createMockDocument( {
|
|
93
|
-
id: 1,
|
|
94
|
-
title: 'Header',
|
|
95
|
-
type: {
|
|
96
|
-
value: 'header',
|
|
97
|
-
label: 'Header',
|
|
98
|
-
},
|
|
99
|
-
} )
|
|
100
|
-
);
|
|
101
|
-
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
-
import {
|
|
3
|
+
import { __useHostDocument, __useActiveDocument, __useNavigateToDocument } from '@elementor/editor-documents';
|
|
4
4
|
import RecentlyEdited from '../recently-edited';
|
|
5
5
|
import { createMockDocument } from 'test-utils';
|
|
6
6
|
import useRecentPosts, { Post } from '../../../hooks/use-recent-posts';
|
|
7
7
|
|
|
8
8
|
jest.mock( '@elementor/editor-documents', () => ( {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
__useActiveDocument: jest.fn(),
|
|
10
|
+
__useHostDocument: jest.fn(),
|
|
11
|
+
__useNavigateToDocument: jest.fn(),
|
|
12
12
|
} ) );
|
|
13
13
|
|
|
14
14
|
jest.mock( '../../../hooks/use-recent-posts', () => (
|
|
@@ -19,17 +19,13 @@ jest.mock( '../../../hooks/use-recent-posts', () => (
|
|
|
19
19
|
) );
|
|
20
20
|
|
|
21
21
|
describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
22
|
-
beforeEach( () => {
|
|
23
|
-
jest.mocked( useActiveDocument ).mockImplementation( () =>
|
|
24
|
-
createMockDocument( { id: 1, title: 'Active Document' } )
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
jest.mocked( useHostDocument ).mockImplementation( () =>
|
|
28
|
-
createMockDocument( { id: 2, title: 'Host Document' } )
|
|
29
|
-
);
|
|
30
|
-
} );
|
|
31
|
-
|
|
32
22
|
it( 'should show the title of the active document without its status when the document is published', async () => {
|
|
23
|
+
// Arrange.
|
|
24
|
+
jest.mocked( __useActiveDocument ).mockReturnValue( createMockDocument( {
|
|
25
|
+
id: 1,
|
|
26
|
+
title: 'Active Document',
|
|
27
|
+
} ) );
|
|
28
|
+
|
|
33
29
|
// Act.
|
|
34
30
|
render( <RecentlyEdited /> );
|
|
35
31
|
|
|
@@ -40,16 +36,14 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
40
36
|
|
|
41
37
|
it( 'should show the title of the active document with its status when the document is not published', async () => {
|
|
42
38
|
// Arrange.
|
|
43
|
-
jest.mocked(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
} )
|
|
52
|
-
);
|
|
39
|
+
jest.mocked( __useActiveDocument ).mockReturnValue( createMockDocument( {
|
|
40
|
+
id: 1,
|
|
41
|
+
title: 'Active Document',
|
|
42
|
+
status: {
|
|
43
|
+
value: 'draft',
|
|
44
|
+
label: 'Draft',
|
|
45
|
+
},
|
|
46
|
+
} ) );
|
|
53
47
|
|
|
54
48
|
// Act.
|
|
55
49
|
render( <RecentlyEdited /> );
|
|
@@ -61,7 +55,12 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
61
55
|
|
|
62
56
|
it( 'should show the title of the host document when there is no active document', () => {
|
|
63
57
|
// Arrange.
|
|
64
|
-
jest.mocked(
|
|
58
|
+
jest.mocked( __useActiveDocument ).mockReturnValue( null );
|
|
59
|
+
|
|
60
|
+
jest.mocked( __useHostDocument ).mockReturnValue( createMockDocument( {
|
|
61
|
+
id: 1,
|
|
62
|
+
title: 'Host Document',
|
|
63
|
+
} ) );
|
|
65
64
|
|
|
66
65
|
// Act.
|
|
67
66
|
render( <RecentlyEdited /> );
|
|
@@ -72,17 +71,19 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
72
71
|
|
|
73
72
|
it( 'should show the title of the host document when the active document is kit', () => {
|
|
74
73
|
// Arrange.
|
|
74
|
+
jest.mocked( __useActiveDocument ).mockReturnValue( createMockDocument( {
|
|
75
|
+
id: 1,
|
|
76
|
+
title: 'Active Document',
|
|
77
|
+
type: {
|
|
78
|
+
value: 'kit',
|
|
79
|
+
label: 'Kit',
|
|
80
|
+
},
|
|
81
|
+
} ) );
|
|
75
82
|
|
|
76
|
-
jest.mocked(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
type: {
|
|
81
|
-
value: 'kit',
|
|
82
|
-
label: 'Kit',
|
|
83
|
-
},
|
|
84
|
-
} )
|
|
85
|
-
);
|
|
83
|
+
jest.mocked( __useHostDocument ).mockReturnValue( createMockDocument( {
|
|
84
|
+
id: 2,
|
|
85
|
+
title: 'Host Document',
|
|
86
|
+
} ) );
|
|
86
87
|
|
|
87
88
|
// Act.
|
|
88
89
|
render( <RecentlyEdited /> );
|
|
@@ -93,8 +94,8 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
93
94
|
|
|
94
95
|
it( 'should show nothing if there are no documents', () => {
|
|
95
96
|
// Arrange.
|
|
96
|
-
jest.mocked(
|
|
97
|
-
jest.mocked(
|
|
97
|
+
jest.mocked( __useActiveDocument ).mockReturnValue( null );
|
|
98
|
+
jest.mocked( __useHostDocument ).mockReturnValue( null );
|
|
98
99
|
|
|
99
100
|
// Act.
|
|
100
101
|
render( <RecentlyEdited /> );
|
|
@@ -106,16 +107,14 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
106
107
|
|
|
107
108
|
it( 'should show empty state', () => {
|
|
108
109
|
// Arrange.
|
|
109
|
-
jest.mocked(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
} )
|
|
118
|
-
);
|
|
110
|
+
jest.mocked( __useActiveDocument ).mockReturnValue( createMockDocument( {
|
|
111
|
+
id: 1,
|
|
112
|
+
title: 'Header',
|
|
113
|
+
type: {
|
|
114
|
+
value: 'header',
|
|
115
|
+
label: 'Header',
|
|
116
|
+
},
|
|
117
|
+
} ) );
|
|
119
118
|
|
|
120
119
|
const isLoading = false;
|
|
121
120
|
const recentPosts: Post[] = [];
|
|
@@ -135,16 +134,14 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
135
134
|
|
|
136
135
|
it( 'should open the recently edited menu on click', () => {
|
|
137
136
|
// Arrange.
|
|
138
|
-
jest.mocked(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
} )
|
|
147
|
-
);
|
|
137
|
+
jest.mocked( __useActiveDocument ).mockReturnValue( createMockDocument( {
|
|
138
|
+
id: 1,
|
|
139
|
+
title: 'Header',
|
|
140
|
+
type: {
|
|
141
|
+
value: 'header',
|
|
142
|
+
label: 'Header',
|
|
143
|
+
},
|
|
144
|
+
} ) );
|
|
148
145
|
|
|
149
146
|
const isLoading = false;
|
|
150
147
|
const recentPosts: Post[] = [ {
|
|
@@ -179,16 +176,14 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
179
176
|
|
|
180
177
|
it( 'should render titles with HTML entities', () => {
|
|
181
178
|
// Arrange.
|
|
182
|
-
jest.mocked(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
} )
|
|
191
|
-
);
|
|
179
|
+
jest.mocked( __useActiveDocument ).mockReturnValue( createMockDocument( {
|
|
180
|
+
id: 1,
|
|
181
|
+
title: 'Header title with special char ¥',
|
|
182
|
+
type: {
|
|
183
|
+
value: 'header',
|
|
184
|
+
label: 'Header',
|
|
185
|
+
},
|
|
186
|
+
} ) );
|
|
192
187
|
|
|
193
188
|
const isLoading = false;
|
|
194
189
|
const recentPosts: Post[] = [
|
|
@@ -236,7 +231,7 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
236
231
|
// Arrange.
|
|
237
232
|
const navigateToDocument = jest.fn();
|
|
238
233
|
|
|
239
|
-
jest.mocked(
|
|
234
|
+
jest.mocked( __useNavigateToDocument ).mockReturnValue( navigateToDocument );
|
|
240
235
|
|
|
241
236
|
jest.mocked( useRecentPosts ).mockReturnValue( {
|
|
242
237
|
isLoading: false,
|
|
@@ -20,13 +20,13 @@ export default function DocTypeChip( { postType, docType, label }: Props ) {
|
|
|
20
20
|
return (
|
|
21
21
|
<Chip
|
|
22
22
|
component="span"
|
|
23
|
-
size="
|
|
23
|
+
size="small"
|
|
24
24
|
variant="standard"
|
|
25
25
|
label={ label }
|
|
26
26
|
data-value={ docType }
|
|
27
27
|
color={ color }
|
|
28
28
|
icon={ <Icon /> }
|
|
29
|
-
sx={ { ml:
|
|
29
|
+
sx={ { ml: 1, cursor: 'inherit' } }
|
|
30
30
|
/>
|
|
31
31
|
);
|
|
32
32
|
}
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import useCreatePage from '../../hooks/use-create-page';
|
|
4
4
|
import { PlusIcon } from '@elementor/icons';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import {
|
|
6
|
+
import { __useNavigateToDocument } from '@elementor/editor-documents';
|
|
7
7
|
|
|
8
8
|
type Props = MenuItemProps & {
|
|
9
9
|
closePopup: () => void;
|
|
@@ -11,7 +11,7 @@ type Props = MenuItemProps & {
|
|
|
11
11
|
|
|
12
12
|
export function CreatePostListItem( { closePopup, ...props }: Props ) {
|
|
13
13
|
const { create, isLoading } = useCreatePage();
|
|
14
|
-
const navigateToDocument =
|
|
14
|
+
const navigateToDocument = __useNavigateToDocument();
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
17
|
<MenuItem
|
|
@@ -10,7 +10,7 @@ type Props = {
|
|
|
10
10
|
export default function Indicator( { title, status }: Props ) {
|
|
11
11
|
return (
|
|
12
12
|
<Tooltip title={ title }>
|
|
13
|
-
<Stack component="span" direction="row" alignItems="center" spacing={
|
|
13
|
+
<Stack component="span" direction="row" alignItems="center" spacing={ 0.5 }>
|
|
14
14
|
<Typography component="span" variant="body2" sx={ { maxWidth: '120px' } } noWrap>
|
|
15
15
|
{ title }
|
|
16
16
|
</Typography>
|
|
@@ -29,7 +29,7 @@ function Tooltip( props: TooltipProps ) {
|
|
|
29
29
|
PopperProps={ {
|
|
30
30
|
sx: {
|
|
31
31
|
'&.MuiTooltip-popper .MuiTooltip-tooltip.MuiTooltip-tooltipPlacementBottom': {
|
|
32
|
-
mt: 7,
|
|
32
|
+
mt: 2.7,
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
35
|
} }
|
|
@@ -2,7 +2,7 @@ import DocTypeChip from './chip-doc-type';
|
|
|
2
2
|
import { MenuItem, MenuItemProps, ListItemText } from '@elementor/ui';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { Post } from '../../hooks/use-recent-posts';
|
|
5
|
-
import {
|
|
5
|
+
import { __useNavigateToDocument } from '@elementor/editor-documents';
|
|
6
6
|
import { useReverseHtmlEntities } from '../../hooks/use-reverse-html-entities';
|
|
7
7
|
|
|
8
8
|
type Props = MenuItemProps & {
|
|
@@ -11,7 +11,7 @@ type Props = MenuItemProps & {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export function PostListItem( { post, closePopup, ...props }: Props ) {
|
|
14
|
-
const navigateToDocument =
|
|
14
|
+
const navigateToDocument = __useNavigateToDocument();
|
|
15
15
|
const postTitle = useReverseHtmlEntities( post.title );
|
|
16
16
|
|
|
17
17
|
return (
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
MenuItem,
|
|
12
12
|
} from '@elementor/ui';
|
|
13
13
|
import { ChevronDownIcon } from '@elementor/icons';
|
|
14
|
-
import {
|
|
14
|
+
import { __useActiveDocument, __useHostDocument } from '@elementor/editor-documents';
|
|
15
15
|
import Indicator from './indicator';
|
|
16
16
|
import useRecentPosts from '../../hooks/use-recent-posts';
|
|
17
17
|
import { __ } from '@wordpress/i18n';
|
|
@@ -20,8 +20,8 @@ import { CreatePostListItem } from './create-post-list-item';
|
|
|
20
20
|
import { useReverseHtmlEntities } from '../../hooks/use-reverse-html-entities';
|
|
21
21
|
|
|
22
22
|
export default function RecentlyEdited() {
|
|
23
|
-
const activeDocument =
|
|
24
|
-
const hostDocument =
|
|
23
|
+
const activeDocument = __useActiveDocument();
|
|
24
|
+
const hostDocument = __useHostDocument();
|
|
25
25
|
const document = activeDocument && activeDocument.type.value !== 'kit'
|
|
26
26
|
? activeDocument
|
|
27
27
|
: hostDocument;
|
|
@@ -54,14 +54,13 @@ export default function RecentlyEdited() {
|
|
|
54
54
|
</Button>
|
|
55
55
|
<Menu
|
|
56
56
|
MenuListProps={ {
|
|
57
|
-
dense: true,
|
|
58
57
|
subheader: (
|
|
59
|
-
<ListSubheader sx={ { fontStyle: 'italic', fontWeight: '300' } }>
|
|
58
|
+
<ListSubheader color="primary" sx={ { fontStyle: 'italic', fontWeight: '300' } }>
|
|
60
59
|
{ __( 'Recent', 'elementor' ) }
|
|
61
60
|
</ListSubheader>
|
|
62
61
|
),
|
|
63
62
|
} }
|
|
64
|
-
PaperProps={ { sx: { mt:
|
|
63
|
+
PaperProps={ { sx: { mt: 2.5, width: 320 } } }
|
|
65
64
|
{ ...bindMenu( popupState ) }
|
|
66
65
|
>
|
|
67
66
|
{ recentPosts.map( ( post ) => (
|
package/src/init.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import RecentlyEdited from './components/top-bar/recently-edited';
|
|
2
2
|
import { injectIntoPageIndication, toolsMenu } from '@elementor/editor-app-bar';
|
|
3
3
|
import { useToggleButtonProps } from './hooks/use-toggle-button-props';
|
|
4
|
-
import {
|
|
4
|
+
import { __registerPanel } from '@elementor/editor-panels';
|
|
5
5
|
import { panel } from './components/panel/panel';
|
|
6
6
|
import { env } from './env';
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ export default function init() {
|
|
|
9
9
|
registerTopBarMenuItems();
|
|
10
10
|
// TODO 06/06/2023 : remove if when we are production ready
|
|
11
11
|
if ( env.is_pages_panel_active ) {
|
|
12
|
-
|
|
12
|
+
__registerPanel( panel );
|
|
13
13
|
registerButton();
|
|
14
14
|
}
|
|
15
15
|
}
|