PluginProbe
Gutenberg / trunk
Gutenberg vtrunk
24.1.0 24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 All 404 releases
← All changes | build/routes/styles/route.js +82 -3 23.2.2 → trunk View file →
@@ -23,8 +23,29 @@
23 23 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24 24 mod
25 25 ));
26 26
27 +// package-external:@wordpress/data
28 +var require_data = __commonJS({
29 + "package-external:@wordpress/data"(exports, module) {
30 + module.exports = window.wp.data;
31 + }
32 +});
33 +
34 +// package-external:@wordpress/core-data
35 +var require_core_data = __commonJS({
36 + "package-external:@wordpress/core-data"(exports, module) {
37 + module.exports = window.wp.coreData;
38 + }
39 +});
40 +
41 +// package-external:@wordpress/html-entities
42 +var require_html_entities = __commonJS({
43 + "package-external:@wordpress/html-entities"(exports, module) {
44 + module.exports = window.wp.htmlEntities;
45 + }
46 +});
47 +
27 48 // package-external:@wordpress/i18n
28 49 var require_i18n = __commonJS({
29 50 "package-external:@wordpress/i18n"(exports, module) {
30 51 module.exports = window.wp.i18n;
@@ -30,18 +51,76 @@
30 51 module.exports = window.wp.i18n;
31 52 }
32 53 });
33 54
55 +// package-external:@wordpress/url
56 +var require_url = __commonJS({
57 + "package-external:@wordpress/url"(exports, module) {
58 + module.exports = window.wp.url;
59 + }
60 +});
61 +
34 62 // routes/styles/route.ts
63 +var import_data = __toESM(require_data());
64 +var import_core_data = __toESM(require_core_data());
65 +var import_html_entities = __toESM(require_html_entities());
66 +var import_i18n2 = __toESM(require_i18n());
67 +import { notFound } from "@wordpress/route";
68 +
69 +// routes/styles/previewed-theme.ts
35 70 var import_i18n = __toESM(require_i18n());
71 +var import_url = __toESM(require_url());
72 +var THEME_PREVIEW_ADMIN_PAGE = "theme-preview-wp-admin";
73 +var previewedStylesheet = (() => {
74 + const value = (0, import_url.getQueryArg)(window.location.href, "wp_theme_preview");
75 + return typeof value === "string" ? value : "";
76 +})();
77 +function getPreviewedStylesheet() {
78 + return previewedStylesheet;
79 +}
80 +function isThemePreviewAdminPage() {
81 + return new URLSearchParams(window.location.search).get("page") === THEME_PREVIEW_ADMIN_PAGE;
82 +}
83 +function getPreviewTitle(themeName) {
84 + return themeName ? (0, import_i18n.sprintf)(
85 + /* translators: %s: Theme name. */
86 + (0, import_i18n.__)("Previewing %s"),
87 + themeName
88 + ) : (0, import_i18n.__)("Theme Preview");
89 +}
90 +
91 +// routes/styles/route.ts
92 +async function isBlockTheme() {
93 + const currentTheme = await (0, import_data.resolveSelect)(import_core_data.store).getCurrentTheme();
94 + return !!currentTheme?.is_block_theme;
95 +}
36 96 var route = {
37 - title: () => (0, import_i18n.__)("Styles"),
97 + beforeLoad: () => {
98 + if (isThemePreviewAdminPage() && !getPreviewedStylesheet()) {
99 + throw notFound();
100 + }
101 + },
102 + title: async () => {
103 + if (!getPreviewedStylesheet()) {
104 + return (0, import_i18n2.__)("Styles");
105 + }
106 + const theme = await (0, import_data.resolveSelect)(import_core_data.store).getCurrentTheme();
107 + return getPreviewTitle(
108 + theme?.name?.rendered ? (0, import_html_entities.decodeEntities)(theme.name.rendered) : void 0
109 + );
110 + },
111 + // Classic themes have no global styles to edit, so the style book is all
112 + // this route has to show.
113 + stage: isBlockTheme,
38 114 async canvas(context) {
39 - if (context.search.preview === "stylebook") {
115 + if (context.search.preview === "stylebook" || !await isBlockTheme()) {
40 116 return null;
41 117 }
42 118 return {
43 - isPreview: true
119 + isPreview: true,
120 + // Styling the site means styling the template around it, so it is
121 + // shown even when the canvas resolves to a static front page.
122 + renderingMode: "template-locked"
44 123 };
45 124 }
46 125 };
47 126 export {