@wordpress/boot 0.20.0 → 0.21.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 +32 -0
- package/README.md +4 -0
- package/build-module/components/app/router.mjs +100 -4
- package/build-module/components/app/router.mjs.map +3 -3
- package/build-module/components/canvas/index.mjs +72 -13
- package/build-module/components/canvas/index.mjs.map +2 -2
- package/build-module/components/canvas/site-preview.mjs +50 -0
- package/build-module/components/canvas/site-preview.mjs.map +7 -0
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs +122 -0
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs.map +7 -0
- package/build-module/components/canvas/viewport.mjs +18 -0
- package/build-module/components/canvas/viewport.mjs.map +7 -0
- package/build-module/components/error-boundary/index.mjs +129 -0
- package/build-module/components/error-boundary/index.mjs.map +7 -0
- package/build-module/components/navigation/drilldown-item/index.mjs +91 -1
- package/build-module/components/navigation/drilldown-item/index.mjs.map +3 -3
- package/build-module/components/navigation/dropdown-item/index.mjs +98 -11
- package/build-module/components/navigation/dropdown-item/index.mjs.map +4 -4
- package/build-module/components/navigation/index.mjs +0 -1
- package/build-module/components/navigation/index.mjs.map +2 -2
- package/build-module/components/navigation/navigation-item/index.mjs +88 -15
- package/build-module/components/navigation/navigation-item/index.mjs.map +3 -3
- package/build-module/components/navigation/navigation-screen/index.mjs +111 -38
- package/build-module/components/navigation/navigation-screen/index.mjs.map +3 -3
- package/build-module/components/plugin-area/index.mjs +29 -0
- package/build-module/components/plugin-area/index.mjs.map +7 -0
- package/build-module/components/root/index.mjs +220 -122
- package/build-module/components/root/index.mjs.map +3 -3
- package/build-module/components/root/single-page.mjs +139 -47
- package/build-module/components/root/single-page.mjs.map +3 -3
- package/build-module/components/root/use-sync-body-background.mjs.map +1 -1
- package/build-module/components/save-button/index.mjs +127 -16
- package/build-module/components/save-button/index.mjs.map +3 -3
- package/build-module/components/save-panel/index.mjs +91 -1
- package/build-module/components/save-panel/index.mjs.map +3 -3
- package/build-module/components/sidebar/index.mjs +90 -10
- package/build-module/components/sidebar/index.mjs.map +3 -3
- package/build-module/index.mjs +0 -16
- package/build-module/index.mjs.map +3 -3
- package/build-module/store/actions.mjs +8 -0
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/reducer.mjs +16 -1
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +9 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-types/components/app/router.d.ts.map +1 -1
- package/build-types/components/canvas/index.d.ts.map +1 -1
- package/build-types/components/canvas/site-preview.d.ts +10 -0
- package/build-types/components/canvas/site-preview.d.ts.map +1 -0
- package/build-types/components/canvas/use-navigate-to-entity-record.d.ts +40 -0
- package/build-types/components/canvas/use-navigate-to-entity-record.d.ts.map +1 -0
- package/build-types/components/canvas/viewport.d.ts +15 -0
- package/build-types/components/canvas/viewport.d.ts.map +1 -0
- package/build-types/components/error-boundary/index.d.ts +22 -0
- package/build-types/components/error-boundary/index.d.ts.map +1 -0
- package/build-types/components/navigation/drilldown-item/index.d.ts.map +1 -1
- package/build-types/components/navigation/dropdown-item/index.d.ts +0 -1
- package/build-types/components/navigation/dropdown-item/index.d.ts.map +1 -1
- package/build-types/components/navigation/index.d.ts.map +1 -1
- package/build-types/components/navigation/navigation-item/index.d.ts +0 -1
- package/build-types/components/navigation/navigation-item/index.d.ts.map +1 -1
- package/build-types/components/navigation/navigation-screen/index.d.ts +0 -1
- package/build-types/components/navigation/navigation-screen/index.d.ts.map +1 -1
- package/build-types/components/plugin-area/index.d.ts +12 -0
- package/build-types/components/plugin-area/index.d.ts.map +1 -0
- package/build-types/components/root/index.d.ts +0 -1
- package/build-types/components/root/index.d.ts.map +1 -1
- package/build-types/components/root/single-page.d.ts +0 -1
- package/build-types/components/root/single-page.d.ts.map +1 -1
- package/build-types/components/root/use-sync-body-background.d.ts +1 -1
- package/build-types/components/save-button/index.d.ts +0 -1
- package/build-types/components/save-button/index.d.ts.map +1 -1
- package/build-types/components/save-panel/index.d.ts.map +1 -1
- package/build-types/components/sidebar/index.d.ts +0 -1
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/index.d.ts +0 -2
- package/build-types/index.d.ts.map +1 -1
- package/build-types/store/actions.d.ts +15 -2
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +12 -0
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/store/types.d.ts +34 -3
- package/build-types/store/types.d.ts.map +1 -1
- package/package.json +28 -25
- package/src/components/app/router.tsx +19 -7
- package/src/components/canvas/index.tsx +117 -15
- package/src/components/canvas/site-preview.tsx +64 -0
- package/src/components/canvas/use-navigate-to-entity-record.ts +220 -0
- package/src/components/canvas/viewport.ts +34 -0
- package/src/components/error-boundary/index.tsx +71 -0
- package/src/components/error-boundary/style.module.scss +13 -0
- package/src/components/navigation/drilldown-item/index.tsx +2 -1
- package/src/components/navigation/dropdown-item/index.tsx +10 -6
- package/src/components/navigation/dropdown-item/{style.scss → style.module.scss} +6 -2
- package/src/components/navigation/index.tsx +0 -1
- package/src/components/navigation/navigation-item/index.tsx +3 -6
- package/src/components/navigation/navigation-item/{style.scss → style.module.scss} +7 -14
- package/src/components/navigation/navigation-screen/index.tsx +6 -15
- package/src/components/navigation/navigation-screen/{style.scss → style.module.scss} +10 -9
- package/src/components/plugin-area/index.tsx +34 -0
- package/src/components/root/{style.scss → _layout.module.scss} +71 -40
- package/src/components/root/_view-transitions.module.scss +205 -0
- package/src/components/root/index.tsx +44 -24
- package/src/components/root/single-page.tsx +15 -7
- package/src/components/root/style.module.scss +2 -0
- package/src/components/root/use-sync-body-background.ts +1 -1
- package/src/components/save-button/index.tsx +36 -14
- package/src/components/save-button/style.module.scss +10 -0
- package/src/components/save-panel/index.tsx +2 -1
- package/src/components/save-panel/style.module.scss +7 -0
- package/src/components/sidebar/index.tsx +5 -5
- package/src/components/sidebar/style.module.scss +29 -0
- package/src/index.tsx +0 -2
- package/src/store/actions.ts +18 -1
- package/src/store/reducer.ts +19 -0
- package/src/store/selectors.ts +28 -0
- package/src/store/types.ts +37 -3
- package/build-style/style-rtl.css +0 -133
- package/build-style/style.css +0 -133
- package/build-style/view-transitions-rtl.css +0 -189
- package/build-style/view-transitions.css +0 -189
- package/src/components/save-button/style.scss +0 -9
- package/src/components/sidebar/style.scss +0 -23
- package/src/style.scss +0 -34
- package/src/view-transitions.scss +0 -221
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/navigation/index.tsx"],"names":[],"mappings":"AAUA,iBAAS,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/navigation/index.tsx"],"names":[],"mappings":"AAUA,iBAAS,UAAU,gCAyGlB;eAEc,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/navigation-item/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/navigation-item/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGrD,UAAU,mBAAmB;IAC5B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;CACX;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAE,EACvC,SAAS,EACT,IAAI,EACJ,qBAA4B,EAC5B,QAAQ,EACR,EAAE,GACF,EAAE,mBAAmB,+BA+BrB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ReactNode, RefObject } from 'react';
|
|
2
|
-
import './style.scss';
|
|
3
2
|
export default function NavigationScreen({ isRoot, title, actions, content, description, animationDirection, backMenuItem, backButtonRef, navigationKey, onNavigate, }: {
|
|
4
3
|
isRoot?: boolean;
|
|
5
4
|
title: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/navigation-screen/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/navigation-screen/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AA6BlD,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAE,EACzC,MAAM,EACN,KAAK,EACL,OAAO,EACP,OAAO,EACP,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,UAAU,GACV,EAAE;IACF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,SAAS,CAAC;IACnB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,SAAS,CAAE,iBAAiB,GAAG,IAAI,CAAE,CAAC;IACtD,kBAAkB,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,CAAE,EACb,EAAE,EACF,SAAS,GACT,EAAE;QACF,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,SAAS,EAAE,SAAS,GAAG,UAAU,CAAC;KAClC,KAAM,IAAI,CAAC;CACZ,+BAqEA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mounts every plugin registered with `registerPlugin`, so the fills they
|
|
3
|
+
* render reach their slots.
|
|
4
|
+
*
|
|
5
|
+
* Sits at the root rather than with the editor: a plugin's fills mostly target
|
|
6
|
+
* editor slots, but the component holding them is also where it registers
|
|
7
|
+
* commands and extends a list, which the routes without a canvas need too.
|
|
8
|
+
*
|
|
9
|
+
* @return The mount point. Renders whatever the plugins do, and nothing itself.
|
|
10
|
+
*/
|
|
11
|
+
export default function PluginArea(): import("react").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/plugin-area/index.tsx"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,gCAkBjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/root/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/root/index.tsx"],"names":[],"mappings":"AA8BA,MAAM,CAAC,OAAO,UAAU,IAAI,gCA6L3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single-page.d.ts","sourceRoot":"","sources":["../../../src/components/root/single-page.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"single-page.d.ts","sourceRoot":"","sources":["../../../src/components/root/single-page.tsx"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,gCAoErC"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* hook can be replaced with a CSS rule on `<body>`.
|
|
8
8
|
* See https://github.com/WordPress/gutenberg/pull/78587#discussion_r3481698286
|
|
9
9
|
*
|
|
10
|
-
* @return Ref to attach to the
|
|
10
|
+
* @return Ref to attach to the layout root element.
|
|
11
11
|
*/
|
|
12
12
|
export default function useSyncBodyBackground(): import("react").MutableRefObject<HTMLDivElement | null>;
|
|
13
13
|
//# sourceMappingURL=use-sync-body-background.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/save-button/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/save-button/index.tsx"],"names":[],"mappings":"AAqBA,MAAM,CAAC,OAAO,UAAU,UAAU,uCA4HjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/save-panel/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/save-panel/index.tsx"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,SAAS,wCAqBhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/sidebar/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/sidebar/index.tsx"],"names":[],"mappings":"AA2BA,MAAM,CAAC,OAAO,UAAU,OAAO,gCAY9B"}
|
package/build-types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MenuItem, Route } from './types';
|
|
1
|
+
import type { EntityLinks, MenuItem, Route } from './types';
|
|
2
2
|
export declare function registerMenuItem(id: string, menuItem: MenuItem): {
|
|
3
3
|
type: 'REGISTER_MENU_ITEM';
|
|
4
4
|
id: string;
|
|
@@ -13,9 +13,22 @@ export declare function registerRoute(route: Route): {
|
|
|
13
13
|
type: 'REGISTER_ROUTE';
|
|
14
14
|
route: Route;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Registers where entities of a post type are listed and edited.
|
|
18
|
+
*
|
|
19
|
+
* Register `default` to cover post types with no entry of their own.
|
|
20
|
+
*
|
|
21
|
+
* @param postType Post type the links belong to, or `default`.
|
|
22
|
+
* @param links Paths to list and edit an entity of that post type.
|
|
23
|
+
*/
|
|
24
|
+
export declare function registerEntityLinks(postType: string, links: EntityLinks): {
|
|
25
|
+
type: 'REGISTER_ENTITY_LINKS';
|
|
26
|
+
postType: string;
|
|
27
|
+
links: EntityLinks;
|
|
28
|
+
};
|
|
16
29
|
export declare function setDashboardLink(dashboardLink: string): {
|
|
17
30
|
type: 'SET_DASHBOARD_LINK';
|
|
18
31
|
dashboardLink: string;
|
|
19
32
|
};
|
|
20
|
-
export type Action = ReturnType<typeof registerMenuItem> | ReturnType<typeof updateMenuItem> | ReturnType<typeof registerRoute> | ReturnType<typeof setDashboardLink>;
|
|
33
|
+
export type Action = ReturnType<typeof registerMenuItem> | ReturnType<typeof updateMenuItem> | ReturnType<typeof registerRoute> | ReturnType<typeof registerEntityLinks> | ReturnType<typeof setDashboardLink>;
|
|
21
34
|
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/store/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/store/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAE5D,wBAAgB,gBAAgB,CAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ;UAExD,oBAAoB;;;EAI3B;AAED,wBAAgB,cAAc,CAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAE,QAAQ,CAAE;UAEhE,kBAAkB;;;EAIzB;AAED,wBAAgB,aAAa,CAAE,KAAK,EAAE,KAAK;UAEnC,gBAAgB;;EAGvB;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW;UAEjE,uBAAuB;;;EAI9B;AAED,wBAAgB,gBAAgB,CAAE,aAAa,EAAE,MAAM;UAE/C,oBAAoB;;EAG3B;AAED,MAAM,MAAM,MAAM,GACf,UAAU,CAAE,OAAO,gBAAgB,CAAE,GACrC,UAAU,CAAE,OAAO,cAAc,CAAE,GACnC,UAAU,CAAE,OAAO,aAAa,CAAE,GAClC,UAAU,CAAE,OAAO,mBAAmB,CAAE,GACxC,UAAU,CAAE,OAAO,gBAAgB,CAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/store/reducer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/store/reducer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AASrC,wBAAgB,OAAO,CAAE,KAAK,EAAE,KAAK,YAAe,EAAE,MAAM,EAAE,MAAM,GAAI,KAAK,CAuD5E"}
|
|
@@ -2,4 +2,16 @@ import type { State } from './types';
|
|
|
2
2
|
export declare function getMenuItems(state: State): import("./types").MenuItem[];
|
|
3
3
|
export declare function getRoutes(state: State): import("./types").Route[];
|
|
4
4
|
export declare function getDashboardLink(state: State): string | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Returns the path an entity is edited or listed at.
|
|
7
|
+
*
|
|
8
|
+
* Falls back to the links registered for `default`, so a post type with no
|
|
9
|
+
* entry of its own still resolves.
|
|
10
|
+
*
|
|
11
|
+
* @param state Store state.
|
|
12
|
+
* @param postType Post type to resolve for.
|
|
13
|
+
* @param postId Entity to edit. Omit for the list of the post type.
|
|
14
|
+
* @return The path, or undefined when nothing is registered for it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getEntityLink(state: State, postType: string, postId?: string | number): string | undefined;
|
|
5
17
|
//# sourceMappingURL=selectors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../src/store/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,wBAAgB,YAAY,CAAE,KAAK,EAAE,KAAK,gCAEzC;AAED,wBAAgB,SAAS,CAAE,KAAK,EAAE,KAAK,6BAEtC;AAED,wBAAgB,gBAAgB,CAAE,KAAK,EAAE,KAAK,sBAE7C"}
|
|
1
|
+
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../src/store/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,wBAAgB,YAAY,CAAE,KAAK,EAAE,KAAK,gCAEzC;AAED,wBAAgB,SAAS,CAAE,KAAK,EAAE,KAAK,6BAEtC;AAED,wBAAgB,gBAAgB,CAAE,KAAK,EAAE,KAAK,sBAE7C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC5B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,sBAYxB"}
|
|
@@ -46,11 +46,23 @@ export interface CanvasData {
|
|
|
46
46
|
* Indicates if the canvas is in preview mode.
|
|
47
47
|
*/
|
|
48
48
|
isPreview?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The routes an entity of a given post type is edited and listed at.
|
|
52
|
+
*
|
|
53
|
+
* Registered by the application rather than known here, so the shell holds no
|
|
54
|
+
* knowledge of any particular page's URLs.
|
|
55
|
+
*/
|
|
56
|
+
export interface EntityLinks {
|
|
49
57
|
/**
|
|
50
|
-
*
|
|
51
|
-
* When provided with isPreview: true, clicking the canvas navigates to this URL.
|
|
58
|
+
* Path the entities of this post type are listed at.
|
|
52
59
|
*/
|
|
53
|
-
|
|
60
|
+
list?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Path an entity of this post type is edited at. `{id}` is replaced with
|
|
63
|
+
* the encoded entity ID.
|
|
64
|
+
*/
|
|
65
|
+
edit?: string;
|
|
54
66
|
}
|
|
55
67
|
/**
|
|
56
68
|
* Route lifecycle configuration exported from route_module.
|
|
@@ -90,6 +102,24 @@ export interface RouteConfig {
|
|
|
90
102
|
* ```
|
|
91
103
|
*/
|
|
92
104
|
inspector?: (context: RouteLoaderContext) => boolean | Promise<boolean>;
|
|
105
|
+
/**
|
|
106
|
+
* Function that determines whether to show the stage.
|
|
107
|
+
* When not defined, defaults to true (always show stage if component exists).
|
|
108
|
+
* When it returns false, the stage is hidden even if a stage component is
|
|
109
|
+
* exported, leaving the canvas to fill the surfaces area.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```tsx
|
|
113
|
+
* export const route = {
|
|
114
|
+
* stage: async () => {
|
|
115
|
+
* // Only show the stage when there is something to edit
|
|
116
|
+
* const theme = await resolveSelect( coreStore ).getCurrentTheme();
|
|
117
|
+
* return !! theme?.is_block_theme;
|
|
118
|
+
* },
|
|
119
|
+
* };
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
stage?: (context: RouteLoaderContext) => boolean | Promise<boolean>;
|
|
93
123
|
/**
|
|
94
124
|
* Function that returns the document title for the route.
|
|
95
125
|
* The returned title will be formatted as: "{title} ‹ {siteTitle} — WordPress"
|
|
@@ -143,5 +173,6 @@ export interface State {
|
|
|
143
173
|
menuItems: Record<string, MenuItem>;
|
|
144
174
|
routes: Route[];
|
|
145
175
|
dashboardLink?: string;
|
|
176
|
+
entityLinks: Record<string, EntityLinks>;
|
|
146
177
|
}
|
|
147
178
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/store/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,SAAS,CAAC;AAE9D,MAAM,WAAW,QAAQ;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC7B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,SAAS,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,MAAM,EAAE,MAAM,CAAE,MAAM,EAAE,MAAM,CAAE,CAAC;IACjC,MAAM,EAAE,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/store/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,SAAS,CAAC;AAE9D,MAAM,WAAW,QAAQ;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC7B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,SAAS,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,MAAM,EAAE,MAAM,CAAE,MAAM,EAAE,MAAM,CAAE,CAAC;IACjC,MAAM,EAAE,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAE,OAAO,EAAE,kBAAkB,KAAM,IAAI,GAAG,OAAO,CAAE,IAAI,CAAE,CAAC;IAEvE;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAE,OAAO,EAAE,kBAAkB,KAAM,OAAO,CAAE,OAAO,CAAE,CAAC;IAE/D;;;;;OAKG;IACH,MAAM,CAAC,EAAE,CACR,OAAO,EAAE,kBAAkB,KACvB,OAAO,CAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAE,CAAC;IAE9C;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,EAAE,CAAE,OAAO,EAAE,kBAAkB,KAAM,OAAO,GAAG,OAAO,CAAE,OAAO,CAAE,CAAC;IAE5E;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,EAAE,CAAE,OAAO,EAAE,kBAAkB,KAAM,OAAO,GAAG,OAAO,CAAE,OAAO,CAAE,CAAC;IAExE;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,KAAK,CAAC,EAAE,CAAE,OAAO,EAAE,kBAAkB,KAAM,MAAM,GAAG,OAAO,CAAE,MAAM,CAAE,CAAC;CACtE;AAED;;;GAGG;AACH,MAAM,WAAW,KAAK;IACrB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,KAAK;IACrB,SAAS,EAAE,MAAM,CAAE,MAAM,EAAE,QAAQ,CAAE,CAAC;IACtC,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAE,MAAM,EAAE,WAAW,CAAE,CAAC;CAC3C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/boot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Minimal boot package for WordPress admin pages.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -40,29 +40,32 @@
|
|
|
40
40
|
"wpScriptModuleExports": "./build-module/index.mjs",
|
|
41
41
|
"types": "build-types",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@wordpress/a11y": "^4.
|
|
44
|
-
"@wordpress/admin-ui": "^2.
|
|
45
|
-
"@wordpress/base-styles": "^
|
|
46
|
-
"@wordpress/commands": "^1.
|
|
47
|
-
"@wordpress/components": "^
|
|
48
|
-
"@wordpress/compose": "^8.
|
|
49
|
-
"@wordpress/core-data": "^7.
|
|
50
|
-
"@wordpress/data": "^10.
|
|
51
|
-
"@wordpress/
|
|
52
|
-
"@wordpress/
|
|
53
|
-
"@wordpress/
|
|
54
|
-
"@wordpress/
|
|
55
|
-
"@wordpress/
|
|
56
|
-
"@wordpress/
|
|
57
|
-
"@wordpress/
|
|
58
|
-
"@wordpress/
|
|
59
|
-
"@wordpress/
|
|
60
|
-
"@wordpress/
|
|
61
|
-
"@wordpress/
|
|
62
|
-
"@wordpress/
|
|
63
|
-
"@wordpress/
|
|
64
|
-
"@wordpress/
|
|
65
|
-
"@wordpress/
|
|
43
|
+
"@wordpress/a11y": "^4.54.0",
|
|
44
|
+
"@wordpress/admin-ui": "^2.9.0",
|
|
45
|
+
"@wordpress/base-styles": "^13.0.0",
|
|
46
|
+
"@wordpress/commands": "^1.54.0",
|
|
47
|
+
"@wordpress/components": "^40.0.0",
|
|
48
|
+
"@wordpress/compose": "^8.7.0",
|
|
49
|
+
"@wordpress/core-data": "^7.54.0",
|
|
50
|
+
"@wordpress/data": "^10.54.0",
|
|
51
|
+
"@wordpress/dom": "^4.54.0",
|
|
52
|
+
"@wordpress/editor": "^14.54.0",
|
|
53
|
+
"@wordpress/element": "^8.6.0",
|
|
54
|
+
"@wordpress/html-entities": "^4.54.0",
|
|
55
|
+
"@wordpress/i18n": "^6.27.0",
|
|
56
|
+
"@wordpress/icons": "^15.5.0",
|
|
57
|
+
"@wordpress/keyboard-shortcuts": "^5.54.0",
|
|
58
|
+
"@wordpress/keycodes": "^4.54.0",
|
|
59
|
+
"@wordpress/lazy-editor": "^1.20.0",
|
|
60
|
+
"@wordpress/notices": "^5.54.0",
|
|
61
|
+
"@wordpress/plugins": "^7.54.0",
|
|
62
|
+
"@wordpress/primitives": "^4.54.0",
|
|
63
|
+
"@wordpress/private-apis": "^1.54.0",
|
|
64
|
+
"@wordpress/route": "^0.20.0",
|
|
65
|
+
"@wordpress/style-runtime": "^0.10.0",
|
|
66
|
+
"@wordpress/theme": "^2.0.0",
|
|
67
|
+
"@wordpress/ui": "^0.21.0",
|
|
68
|
+
"@wordpress/url": "^4.54.0",
|
|
66
69
|
"clsx": "^2.1.1"
|
|
67
70
|
},
|
|
68
71
|
"peerDependencies": {
|
|
@@ -78,5 +81,5 @@
|
|
|
78
81
|
"publishConfig": {
|
|
79
82
|
"access": "public"
|
|
80
83
|
},
|
|
81
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "5ef24f60261976bb198ad035db24bf81c1fb92b4"
|
|
82
85
|
}
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
import { resolveSelect } from '@wordpress/data';
|
|
10
10
|
import { store as coreStore } from '@wordpress/core-data';
|
|
11
11
|
import Root from '../root';
|
|
12
|
+
import styles from '../root/style.module.scss';
|
|
13
|
+
import ErrorBoundary from '../error-boundary';
|
|
12
14
|
import type { Route, RouteConfig, RouteLoaderContext } from '../../store/types';
|
|
13
15
|
import { unlock } from '../../lock-unlock';
|
|
14
16
|
|
|
@@ -26,7 +28,7 @@ const {
|
|
|
26
28
|
// Not found component
|
|
27
29
|
function NotFoundComponent() {
|
|
28
30
|
return (
|
|
29
|
-
<div className=
|
|
31
|
+
<div className={ styles.stage }>
|
|
30
32
|
<Page title={ __( 'Route not found' ) } hasPadding>
|
|
31
33
|
{ __( "The page you're looking for does not exist" ) }
|
|
32
34
|
</Page>
|
|
@@ -94,10 +96,16 @@ function createRouteFromDefinition( route: Route, parentRoute: AnyRoute ) {
|
|
|
94
96
|
inspector = await routeConfig.inspector( context );
|
|
95
97
|
}
|
|
96
98
|
|
|
99
|
+
let stage = true;
|
|
100
|
+
if ( routeConfig.stage ) {
|
|
101
|
+
stage = await routeConfig.stage( context );
|
|
102
|
+
}
|
|
103
|
+
|
|
97
104
|
return {
|
|
98
105
|
...( loaderData as any ),
|
|
99
106
|
canvas: canvasData,
|
|
100
107
|
inspector,
|
|
108
|
+
stage,
|
|
101
109
|
title: titleData,
|
|
102
110
|
routeContentModule: route.content_module,
|
|
103
111
|
};
|
|
@@ -116,19 +124,23 @@ function createRouteFromDefinition( route: Route, parentRoute: AnyRoute ) {
|
|
|
116
124
|
|
|
117
125
|
return createLazyRoute( route.path )( {
|
|
118
126
|
component: function RouteComponent() {
|
|
119
|
-
const { inspector: showInspector } =
|
|
127
|
+
const { inspector: showInspector, stage: showStage } =
|
|
120
128
|
useLoaderData( { from: route.path } ) ?? {};
|
|
121
129
|
|
|
122
130
|
return (
|
|
123
131
|
<>
|
|
124
|
-
{ Stage && (
|
|
125
|
-
<div className=
|
|
126
|
-
<
|
|
132
|
+
{ Stage && showStage && (
|
|
133
|
+
<div className={ styles.stage }>
|
|
134
|
+
<ErrorBoundary>
|
|
135
|
+
<Stage />
|
|
136
|
+
</ErrorBoundary>
|
|
127
137
|
</div>
|
|
128
138
|
) }
|
|
129
139
|
{ Inspector && showInspector && (
|
|
130
|
-
<div className=
|
|
131
|
-
<
|
|
140
|
+
<div className={ styles.inspector }>
|
|
141
|
+
<ErrorBoundary>
|
|
142
|
+
<Inspector />
|
|
143
|
+
</ErrorBoundary>
|
|
132
144
|
</div>
|
|
133
145
|
) }
|
|
134
146
|
</>
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import { useState, useEffect } from '@wordpress/element';
|
|
1
|
+
import { useState, useEffect, useMemo } from '@wordpress/element';
|
|
2
2
|
import { Spinner } from '@wordpress/components';
|
|
3
|
-
import { useNavigate } from '@wordpress/route';
|
|
3
|
+
import { useNavigate, useSearch } from '@wordpress/route';
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
7
|
+
import { store as bootStore } from '../../store';
|
|
4
8
|
import type { CanvasData } from '../../store/types';
|
|
5
9
|
import BootBackButton from './back-button';
|
|
10
|
+
import SitePreview from './site-preview';
|
|
11
|
+
import useNavigateToEntityRecord, {
|
|
12
|
+
useActionPerformed,
|
|
13
|
+
} from './use-navigate-to-entity-record';
|
|
14
|
+
import { getDeviceType } from './viewport';
|
|
6
15
|
|
|
7
16
|
interface CanvasProps {
|
|
8
17
|
canvas: CanvasData;
|
|
@@ -18,6 +27,88 @@ interface CanvasProps {
|
|
|
18
27
|
export default function Canvas( { canvas }: CanvasProps ) {
|
|
19
28
|
const [ Editor, setEditor ] = useState< any >( null );
|
|
20
29
|
const navigate = useNavigate();
|
|
30
|
+
const { onNavigateToEntityRecord, onNavigateToPreviousEntityRecord } =
|
|
31
|
+
useNavigateToEntityRecord();
|
|
32
|
+
const onActionPerformed = useActionPerformed( canvas.postType );
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* An entity can be asked to be edited at a particular width — a navigation
|
|
36
|
+
* overlay meant for mobile — and carries the width it was left at when
|
|
37
|
+
* returned to. Anything else opens at the default.
|
|
38
|
+
*/
|
|
39
|
+
const viewport = useSearch( {
|
|
40
|
+
strict: false,
|
|
41
|
+
select: ( search ) => ( search as { viewport?: string } ).viewport,
|
|
42
|
+
} ) as string | undefined;
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
* Where clicking a previewed canvas goes, resolved the same way the editor
|
|
46
|
+
* resolves anywhere else it sends you to edit an entity, and whether it
|
|
47
|
+
* should go anywhere at all: a trashed entity has to be restored before it
|
|
48
|
+
* can be edited.
|
|
49
|
+
*
|
|
50
|
+
* The record is the one the editor loads for this canvas, so reading it
|
|
51
|
+
* here costs no request of its own.
|
|
52
|
+
*/
|
|
53
|
+
/*
|
|
54
|
+
* A route that names no entity leaves the editor to resolve one, which it
|
|
55
|
+
* does from the block templates only a block theme has. `undefined` while
|
|
56
|
+
* the theme is still being read.
|
|
57
|
+
*/
|
|
58
|
+
const hasEntity = !! ( canvas.postType && canvas.postId );
|
|
59
|
+
const isBlockTheme = useSelect(
|
|
60
|
+
( select ) =>
|
|
61
|
+
(
|
|
62
|
+
select( coreStore ).getCurrentTheme() as
|
|
63
|
+
| { is_block_theme?: boolean }
|
|
64
|
+
| undefined
|
|
65
|
+
)?.is_block_theme,
|
|
66
|
+
[]
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const { editLink, isTrashed } = useSelect(
|
|
70
|
+
( select ) => {
|
|
71
|
+
if ( ! canvas.postType || ! canvas.postId ) {
|
|
72
|
+
return { editLink: undefined, isTrashed: false };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const record = select( coreStore ).getEntityRecord(
|
|
76
|
+
'postType',
|
|
77
|
+
canvas.postType,
|
|
78
|
+
canvas.postId
|
|
79
|
+
) as { status?: string } | undefined;
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
editLink: select( bootStore ).getEntityLink(
|
|
83
|
+
canvas.postType,
|
|
84
|
+
canvas.postId
|
|
85
|
+
),
|
|
86
|
+
isTrashed: record?.status === 'trash',
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
[ canvas.postType, canvas.postId ]
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
/*
|
|
93
|
+
* Memoized because the editor provider pushes these settings into the store
|
|
94
|
+
* whenever their identity changes, and the callbacks have to stay stable for
|
|
95
|
+
* the block inspector to keep offering the same affordance.
|
|
96
|
+
*/
|
|
97
|
+
const settings = useMemo(
|
|
98
|
+
() => ( {
|
|
99
|
+
isPreviewMode: canvas.isPreview,
|
|
100
|
+
styles: canvas.isPreview
|
|
101
|
+
? [ { css: 'body{min-height:100vh;}' } ]
|
|
102
|
+
: [],
|
|
103
|
+
onNavigateToEntityRecord,
|
|
104
|
+
onNavigateToPreviousEntityRecord,
|
|
105
|
+
} ),
|
|
106
|
+
[
|
|
107
|
+
canvas.isPreview,
|
|
108
|
+
onNavigateToEntityRecord,
|
|
109
|
+
onNavigateToPreviousEntityRecord,
|
|
110
|
+
]
|
|
111
|
+
);
|
|
21
112
|
|
|
22
113
|
useEffect( () => {
|
|
23
114
|
// Dynamically import the lazy-editor module
|
|
@@ -31,8 +122,14 @@ export default function Canvas( { canvas }: CanvasProps ) {
|
|
|
31
122
|
} );
|
|
32
123
|
}, [] );
|
|
33
124
|
|
|
34
|
-
//
|
|
35
|
-
if ( !
|
|
125
|
+
// Nothing for the editor to open, so show the site the route configures.
|
|
126
|
+
if ( ! hasEntity && isBlockTheme === false ) {
|
|
127
|
+
return <SitePreview />;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Show spinner while loading the editor module, and until it is known which
|
|
131
|
+
// of the two this canvas is, so the wrong one is never shown first.
|
|
132
|
+
if ( ! Editor || ( ! hasEntity && isBlockTheme === undefined ) ) {
|
|
36
133
|
return (
|
|
37
134
|
<div
|
|
38
135
|
style={ {
|
|
@@ -67,33 +164,38 @@ export default function Canvas( { canvas }: CanvasProps ) {
|
|
|
67
164
|
<Editor
|
|
68
165
|
postType={ canvas.postType }
|
|
69
166
|
postId={ canvas.postId }
|
|
70
|
-
settings={
|
|
71
|
-
isPreviewMode: canvas.isPreview,
|
|
72
|
-
styles: canvas.isPreview
|
|
73
|
-
? [ { css: 'body{min-height:100vh;}' } ]
|
|
74
|
-
: [],
|
|
75
|
-
} }
|
|
167
|
+
settings={ settings }
|
|
76
168
|
backButton={ backButton }
|
|
169
|
+
onActionPerformed={ onActionPerformed }
|
|
170
|
+
initialViewport={ getDeviceType( viewport ) }
|
|
77
171
|
/>
|
|
78
172
|
</div>
|
|
79
|
-
{ canvas.isPreview &&
|
|
173
|
+
{ canvas.isPreview && editLink && (
|
|
80
174
|
<div
|
|
81
|
-
onClick={
|
|
175
|
+
onClick={
|
|
176
|
+
isTrashed
|
|
177
|
+
? undefined
|
|
178
|
+
: () => navigate( { to: editLink } )
|
|
179
|
+
}
|
|
82
180
|
onKeyDown={ ( e ) => {
|
|
181
|
+
if ( isTrashed ) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
83
184
|
if ( e.key === 'Enter' || e.key === ' ' ) {
|
|
84
185
|
e.preventDefault();
|
|
85
|
-
navigate( { to:
|
|
186
|
+
navigate( { to: editLink } );
|
|
86
187
|
}
|
|
87
188
|
} }
|
|
88
189
|
style={ {
|
|
89
190
|
position: 'absolute',
|
|
90
191
|
inset: 0,
|
|
91
|
-
cursor: 'pointer',
|
|
192
|
+
cursor: isTrashed ? 'default' : 'pointer',
|
|
92
193
|
zIndex: 1,
|
|
93
194
|
} }
|
|
94
195
|
role="button"
|
|
95
196
|
tabIndex={ 0 }
|
|
96
|
-
aria-
|
|
197
|
+
aria-disabled={ isTrashed }
|
|
198
|
+
aria-label={ __( 'Edit' ) }
|
|
97
199
|
/>
|
|
98
200
|
) }
|
|
99
201
|
</div>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { __ } from '@wordpress/i18n';
|
|
2
|
+
import { useSelect } from '@wordpress/data';
|
|
3
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
4
|
+
import { focus } from '@wordpress/dom';
|
|
5
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Renders the site's front end in an iframe.
|
|
9
|
+
*
|
|
10
|
+
* Shown where the canvas has no entity to edit, so that a route still says
|
|
11
|
+
* something about the site it is configuring.
|
|
12
|
+
*
|
|
13
|
+
* @return The preview, or nothing until the site's address is known.
|
|
14
|
+
*/
|
|
15
|
+
export default function SitePreview() {
|
|
16
|
+
const siteUrl = useSelect( ( select ) => {
|
|
17
|
+
const siteData = select( coreStore ).getEntityRecord(
|
|
18
|
+
'root',
|
|
19
|
+
'__unstableBase'
|
|
20
|
+
) as { home?: unknown } | undefined;
|
|
21
|
+
return siteData?.home;
|
|
22
|
+
}, [] );
|
|
23
|
+
|
|
24
|
+
// `home` comes from the REST index. Without a usable URL the iframe would
|
|
25
|
+
// resolve its `src` against the current admin page and embed that instead,
|
|
26
|
+
// so render nothing until there is one.
|
|
27
|
+
if ( typeof siteUrl !== 'string' || ! siteUrl ) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<iframe
|
|
33
|
+
src={ addQueryArgs( siteUrl, {
|
|
34
|
+
// Parameter for hiding the admin bar.
|
|
35
|
+
wp_site_preview: 1,
|
|
36
|
+
} ) }
|
|
37
|
+
title={ __( 'Site Preview' ) }
|
|
38
|
+
style={ {
|
|
39
|
+
display: 'block',
|
|
40
|
+
width: '100%',
|
|
41
|
+
height: '100%',
|
|
42
|
+
backgroundColor: '#fff',
|
|
43
|
+
} }
|
|
44
|
+
onLoad={ ( event ) => {
|
|
45
|
+
const iframeDocument = ( event.target as HTMLIFrameElement )
|
|
46
|
+
.contentDocument;
|
|
47
|
+
|
|
48
|
+
// Not readable when the site is served from another origin.
|
|
49
|
+
if ( ! iframeDocument ) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Make interactive elements unclickable.
|
|
54
|
+
focus.focusable
|
|
55
|
+
.find( iframeDocument.documentElement )
|
|
56
|
+
.forEach( ( element ) => {
|
|
57
|
+
element.style.pointerEvents = 'none';
|
|
58
|
+
element.tabIndex = -1;
|
|
59
|
+
element.setAttribute( 'aria-hidden', 'true' );
|
|
60
|
+
} );
|
|
61
|
+
} }
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
}
|