@elementor/editor-site-navigation 0.19.10 → 0.20.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 +22 -0
- package/dist/index.js +142 -68
- package/dist/index.mjs +134 -58
- package/package.json +3 -2
- package/src/api/post.ts +1 -1
- package/src/api/settings.ts +5 -9
- package/src/api/user.ts +20 -0
- package/src/components/panel/actions-menu/actions/__tests__/delete.test.tsx +8 -0
- package/src/components/panel/actions-menu/actions/__tests__/set-home.test.tsx +52 -0
- package/src/components/panel/actions-menu/actions/__tests__/view.test.tsx +4 -0
- package/src/components/panel/actions-menu/actions/delete.tsx +4 -1
- package/src/components/panel/actions-menu/actions/duplicate.tsx +5 -1
- package/src/components/panel/actions-menu/actions/rename.tsx +1 -0
- package/src/components/panel/actions-menu/actions/set-home.tsx +9 -1
- package/src/components/panel/add-new-button.tsx +3 -0
- package/src/components/panel/posts-list/__tests__/post-list-item.test.tsx +20 -0
- package/src/components/panel/posts-list/__tests__/posts-collapsible-list.test.tsx +13 -7
- package/src/components/panel/posts-list/list-items/list-item-rename.tsx +17 -6
- package/src/components/panel/posts-list/list-items/list-item-view.tsx +52 -29
- package/src/components/panel/posts-list/posts-collapsible-list.tsx +1 -4
- package/src/components/shared/page-title-and-status.tsx +2 -3
- package/src/components/top-bar/__tests__/add-new-page.test.tsx +36 -0
- package/src/components/top-bar/__tests__/recently-edited.test.tsx +69 -1
- package/src/components/top-bar/create-post-list-item.tsx +3 -1
- package/src/components/top-bar/post-list-item.tsx +1 -0
- package/src/components/top-bar/recently-edited.tsx +1 -10
- package/src/hooks/__tests__/use-homepage.test.ts +1 -1
- package/src/hooks/__tests__/use-posts.test.ts +1 -1
- package/src/hooks/use-rename-active-document.ts +23 -0
- package/src/hooks/use-user.ts +11 -0
- package/src/types.ts +8 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';
|
|
2
|
+
import { ExtendedWindow } from '@elementor/editor-documents';
|
|
3
|
+
|
|
4
|
+
function getV1DocumentsManager() {
|
|
5
|
+
const documentsManager = ( window as unknown as ExtendedWindow ).elementor?.documents;
|
|
6
|
+
|
|
7
|
+
if ( ! documentsManager ) {
|
|
8
|
+
throw new Error( 'Elementor Editor V1 documents manager not found' );
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return documentsManager;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default function useRenameActiveDocument() {
|
|
15
|
+
return async ( title: string ) => {
|
|
16
|
+
const currentDocument = getV1DocumentsManager().getCurrent();
|
|
17
|
+
const container = currentDocument.container;
|
|
18
|
+
await runCommand( 'document/elements/settings', {
|
|
19
|
+
container,
|
|
20
|
+
settings: { post_title: title },
|
|
21
|
+
} );
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useQuery } from '@elementor/query';
|
|
2
|
+
import { getUser } from '../api/user';
|
|
3
|
+
|
|
4
|
+
export const userQueryKey = () => [ 'site-navigation', 'user' ];
|
|
5
|
+
|
|
6
|
+
export default function useUser( ) {
|
|
7
|
+
return useQuery( {
|
|
8
|
+
queryKey: userQueryKey(),
|
|
9
|
+
queryFn: () => getUser(),
|
|
10
|
+
} );
|
|
11
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -6,7 +6,11 @@ export type Post = {
|
|
|
6
6
|
type: string;
|
|
7
7
|
title: {
|
|
8
8
|
rendered: string;
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
|
+
user_can: {
|
|
11
|
+
edit: boolean;
|
|
12
|
+
delete: boolean;
|
|
13
|
+
};
|
|
10
14
|
};
|
|
11
15
|
|
|
12
16
|
export type RecentPost = {
|
|
@@ -19,4 +23,7 @@ export type RecentPost = {
|
|
|
19
23
|
label: string,
|
|
20
24
|
},
|
|
21
25
|
date_modified: number,
|
|
26
|
+
user_can: {
|
|
27
|
+
edit: boolean,
|
|
28
|
+
},
|
|
22
29
|
}
|