@wordpress/edit-site 6.11.0 → 6.12.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 +2 -0
- package/build/components/app/index.js +0 -2
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/use-editor-iframe-props.js +6 -8
- package/build/components/block-editor/use-editor-iframe-props.js.map +1 -1
- package/build/components/editor/index.js +9 -4
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor/use-editor-title.js +29 -12
- package/build/components/editor/use-editor-title.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +24 -22
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build/components/global-styles/shadows-edit-panel.js +2 -3
- package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +42 -2
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles-renderer/index.js +6 -8
- package/build/components/global-styles-renderer/index.js.map +1 -1
- package/build/components/layout/hooks.js +1 -10
- package/build/components/layout/hooks.js.map +1 -1
- package/build/components/layout/index.js +1 -0
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page-patterns/fields.js +3 -7
- package/build/components/page-patterns/fields.js.map +1 -1
- package/build/components/page-templates/fields.js +1 -2
- package/build/components/page-templates/fields.js.map +1 -1
- package/build/components/post-edit/index.js +14 -8
- package/build/components/post-edit/index.js.map +1 -1
- package/build/components/post-fields/index.js +3 -197
- package/build/components/post-fields/index.js.map +1 -1
- package/build/components/post-list/index.js +11 -1
- package/build/components/post-list/index.js.map +1 -1
- package/build/components/sidebar/index.js +11 -3
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-global-styles-wrapper/index.js +129 -0
- package/build/components/sidebar-global-styles-wrapper/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-global-styles/index.js +14 -72
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +43 -42
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/site-editor-routes/styles-edit.js +6 -1
- package/build/components/site-editor-routes/styles-edit.js.map +1 -1
- package/build/components/site-editor-routes/styles-view.js +8 -2
- package/build/components/site-editor-routes/styles-view.js.map +1 -1
- package/build/components/site-hub/index.js +19 -6
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/style-book/constants.js +10 -3
- package/build/components/style-book/constants.js.map +1 -1
- package/build/components/style-book/examples.js +71 -1
- package/build/components/style-book/examples.js.map +1 -1
- package/build/components/style-book/index.js +70 -11
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +32 -32
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/welcome-guide/index.js +4 -2
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/welcome-guide/page.js +1 -9
- package/build/components/welcome-guide/page.js.map +1 -1
- package/build/components/welcome-guide/template.js +1 -12
- package/build/components/welcome-guide/template.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +15 -15
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/posts.js +1 -0
- package/build/posts.js.map +1 -1
- package/build-module/components/app/index.js +0 -2
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/use-editor-iframe-props.js +6 -8
- package/build-module/components/block-editor/use-editor-iframe-props.js.map +1 -1
- package/build-module/components/editor/index.js +9 -4
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor/use-editor-title.js +29 -12
- package/build-module/components/editor/use-editor-title.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +25 -23
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build-module/components/global-styles/shadows-edit-panel.js +2 -3
- package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +43 -3
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles-renderer/index.js +6 -8
- package/build-module/components/global-styles-renderer/index.js.map +1 -1
- package/build-module/components/layout/hooks.js +1 -9
- package/build-module/components/layout/hooks.js.map +1 -1
- package/build-module/components/layout/index.js +1 -0
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page-patterns/fields.js +4 -8
- package/build-module/components/page-patterns/fields.js.map +1 -1
- package/build-module/components/page-templates/fields.js +1 -2
- package/build-module/components/page-templates/fields.js.map +1 -1
- package/build-module/components/post-edit/index.js +14 -8
- package/build-module/components/post-edit/index.js.map +1 -1
- package/build-module/components/post-fields/index.js +7 -202
- package/build-module/components/post-fields/index.js.map +1 -1
- package/build-module/components/post-list/index.js +11 -1
- package/build-module/components/post-list/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +11 -3
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-global-styles-wrapper/index.js +121 -0
- package/build-module/components/sidebar-global-styles-wrapper/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +15 -73
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +43 -43
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/site-editor-routes/styles-edit.js +6 -1
- package/build-module/components/site-editor-routes/styles-edit.js.map +1 -1
- package/build-module/components/site-editor-routes/styles-view.js +8 -2
- package/build-module/components/site-editor-routes/styles-view.js.map +1 -1
- package/build-module/components/site-hub/index.js +19 -6
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/style-book/constants.js +10 -3
- package/build-module/components/style-book/constants.js.map +1 -1
- package/build-module/components/style-book/examples.js +71 -1
- package/build-module/components/style-book/examples.js.map +1 -1
- package/build-module/components/style-book/index.js +71 -12
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +32 -32
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +4 -2
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/welcome-guide/page.js +1 -9
- package/build-module/components/welcome-guide/page.js.map +1 -1
- package/build-module/components/welcome-guide/template.js +1 -11
- package/build-module/components/welcome-guide/template.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +15 -15
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/posts.js +1 -0
- package/build-module/posts.js.map +1 -1
- package/build-style/posts-rtl.css +54 -5
- package/build-style/posts.css +54 -5
- package/build-style/style-rtl.css +109 -28
- package/build-style/style.css +109 -28
- package/package.json +3 -4
- package/src/components/app/index.js +0 -2
- package/src/components/block-editor/use-editor-iframe-props.js +2 -3
- package/src/components/editor/index.js +16 -4
- package/src/components/editor/use-editor-title.js +37 -13
- package/src/components/editor-canvas-container/style.scss +0 -1
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +28 -31
- package/src/components/global-styles/screen-revisions/style.scss +11 -17
- package/src/components/global-styles/shadows-edit-panel.js +4 -2
- package/src/components/global-styles/ui.js +42 -2
- package/src/components/global-styles-renderer/index.js +4 -10
- package/src/components/layout/hooks.js +1 -7
- package/src/components/layout/index.js +6 -1
- package/src/components/page-patterns/fields.js +6 -12
- package/src/components/page-patterns/style.scss +0 -5
- package/src/components/page-templates/fields.js +2 -3
- package/src/components/post-edit/index.js +38 -30
- package/src/components/post-edit/style.scss +7 -0
- package/src/components/post-fields/index.js +19 -273
- package/src/components/post-list/index.js +9 -3
- package/src/components/post-list/style.scss +29 -3
- package/src/components/sidebar/index.js +23 -7
- package/src/components/sidebar-global-styles-wrapper/index.js +150 -0
- package/src/components/sidebar-global-styles-wrapper/style.scss +35 -0
- package/src/components/sidebar-navigation-item/style.scss +2 -2
- package/src/components/sidebar-navigation-screen-global-styles/index.js +13 -88
- package/src/components/sidebar-navigation-screen-main/index.js +46 -45
- package/src/components/site-editor-routes/styles-edit.js +10 -1
- package/src/components/site-editor-routes/styles-view.js +11 -1
- package/src/components/site-hub/index.js +33 -16
- package/src/components/site-icon/style.scss +16 -0
- package/src/components/style-book/constants.ts +11 -3
- package/src/components/style-book/examples.tsx +105 -1
- package/src/components/style-book/index.js +86 -8
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +54 -64
- package/src/components/welcome-guide/index.js +3 -3
- package/src/components/welcome-guide/page.js +1 -7
- package/src/components/welcome-guide/template.js +1 -8
- package/src/hooks/commands/use-common-commands.js +253 -246
- package/src/index.js +1 -0
- package/src/posts.js +1 -0
- package/src/style.scss +2 -3
- package/build/components/async/index.js +0 -51
- package/build/components/async/index.js.map +0 -1
- package/build/components/use-edited-entity-record/index.js +0 -60
- package/build/components/use-edited-entity-record/index.js.map +0 -1
- package/build/hooks/commands/use-edit-mode-commands.js +0 -179
- package/build/hooks/commands/use-edit-mode-commands.js.map +0 -1
- package/build-module/components/async/index.js +0 -44
- package/build-module/components/async/index.js.map +0 -1
- package/build-module/components/use-edited-entity-record/index.js +0 -53
- package/build-module/components/use-edited-entity-record/index.js.map +0 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +0 -171
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +0 -1
- package/src/components/async/index.js +0 -43
- package/src/components/use-edited-entity-record/index.js +0 -58
- package/src/hooks/commands/use-edit-mode-commands.js +0 -168
|
@@ -48,6 +48,44 @@ function isObjectEmpty(object) {
|
|
|
48
48
|
return !object || Object.keys(object).length === 0;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Scrolls to a section within an iframe.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} anchorId The id of the element to scroll to.
|
|
55
|
+
* @param {HTMLIFrameElement} iframe The target iframe.
|
|
56
|
+
*/
|
|
57
|
+
const scrollToSection = (anchorId, iframe) => {
|
|
58
|
+
if (!iframe || !iframe?.contentDocument) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const element = iframe.contentDocument.getElementById(anchorId);
|
|
62
|
+
if (element) {
|
|
63
|
+
element.scrollIntoView({
|
|
64
|
+
behavior: 'smooth'
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Parses a Block Editor navigation path to extract the block name and
|
|
71
|
+
* build a style book navigation path. The object can be extended to include a category,
|
|
72
|
+
* representing a style book tab/section.
|
|
73
|
+
*
|
|
74
|
+
* @param {string} path An internal Block Editor navigation path.
|
|
75
|
+
* @return {null|{block: string}} An object containing the example to navigate to.
|
|
76
|
+
*/
|
|
77
|
+
const getStyleBookNavigationFromPath = path => {
|
|
78
|
+
if (path && typeof path === 'string') {
|
|
79
|
+
let block = path.includes('/blocks/') ? decodeURIComponent(path.split('/blocks/')[1]) : null;
|
|
80
|
+
// Default to theme-colors if the path ends with /colors.
|
|
81
|
+
block = path.endsWith('/colors') ? 'theme-colors' : block;
|
|
82
|
+
return {
|
|
83
|
+
block
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
};
|
|
88
|
+
|
|
51
89
|
/**
|
|
52
90
|
* Retrieves colors, gradients, and duotone filters from Global Styles.
|
|
53
91
|
* The inclusion of default (Core) palettes is controlled by the relevant
|
|
@@ -102,7 +140,8 @@ function StyleBook({
|
|
|
102
140
|
showCloseButton = true,
|
|
103
141
|
onClose,
|
|
104
142
|
showTabs = true,
|
|
105
|
-
userConfig = {}
|
|
143
|
+
userConfig = {},
|
|
144
|
+
path = ''
|
|
106
145
|
}) {
|
|
107
146
|
const [resizeObserver, sizes] = (0, _compose.useResizeObserver)();
|
|
108
147
|
const [textColor] = useGlobalStyle('color.text');
|
|
@@ -110,9 +149,19 @@ function StyleBook({
|
|
|
110
149
|
const colors = useMultiOriginPalettes();
|
|
111
150
|
const examples = (0, _element.useMemo)(() => (0, _examples.getExamples)(colors), [colors]);
|
|
112
151
|
const tabs = (0, _element.useMemo)(() => (0, _categories.getTopLevelStyleBookCategories)().filter(category => examples.some(example => example.category === category.slug)), [examples]);
|
|
152
|
+
const examplesForSinglePageUse = [];
|
|
153
|
+
const overviewCategoryExamples = (0, _categories.getExamplesByCategory)({
|
|
154
|
+
slug: 'overview'
|
|
155
|
+
}, examples);
|
|
156
|
+
examplesForSinglePageUse.push(...overviewCategoryExamples.examples);
|
|
157
|
+
const otherExamples = examples.filter(example => {
|
|
158
|
+
return example.category !== 'overview' && !overviewCategoryExamples.examples.find(overviewExample => overviewExample.name === example.name);
|
|
159
|
+
});
|
|
160
|
+
examplesForSinglePageUse.push(...otherExamples);
|
|
113
161
|
const {
|
|
114
162
|
base: baseConfig
|
|
115
163
|
} = (0, _element.useContext)(GlobalStylesContext);
|
|
164
|
+
const goTo = getStyleBookNavigationFromPath(path);
|
|
116
165
|
const mergedConfig = (0, _element.useMemo)(() => {
|
|
117
166
|
if (!isObjectEmpty(userConfig) && !isObjectEmpty(baseConfig)) {
|
|
118
167
|
return mergeBaseAndUserConfigs(baseConfig, userConfig);
|
|
@@ -162,16 +211,18 @@ function StyleBook({
|
|
|
162
211
|
onSelect: onSelect,
|
|
163
212
|
settings: settings,
|
|
164
213
|
sizes: sizes,
|
|
165
|
-
title: tab.title
|
|
214
|
+
title: tab.title,
|
|
215
|
+
goTo: goTo
|
|
166
216
|
})
|
|
167
217
|
}, tab.slug))]
|
|
168
218
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(StyleBookBody, {
|
|
169
|
-
examples:
|
|
219
|
+
examples: examplesForSinglePageUse,
|
|
170
220
|
isSelected: isSelected,
|
|
171
221
|
onClick: onClick,
|
|
172
222
|
onSelect: onSelect,
|
|
173
223
|
settings: settings,
|
|
174
|
-
sizes: sizes
|
|
224
|
+
sizes: sizes,
|
|
225
|
+
goTo: goTo
|
|
175
226
|
})]
|
|
176
227
|
})
|
|
177
228
|
});
|
|
@@ -184,10 +235,12 @@ const StyleBookBody = ({
|
|
|
184
235
|
onSelect,
|
|
185
236
|
settings,
|
|
186
237
|
sizes,
|
|
187
|
-
title
|
|
238
|
+
title,
|
|
239
|
+
goTo
|
|
188
240
|
}) => {
|
|
189
241
|
const [isFocused, setIsFocused] = (0, _element.useState)(false);
|
|
190
|
-
|
|
242
|
+
const [hasIframeLoaded, setHasIframeLoaded] = (0, _element.useState)(false);
|
|
243
|
+
const iframeRef = (0, _element.useRef)(null);
|
|
191
244
|
// The presence of an `onClick` prop indicates that the Style Book is being used as a button.
|
|
192
245
|
// In this case, add additional props to the iframe to make it behave like a button.
|
|
193
246
|
const buttonModeProps = {
|
|
@@ -217,7 +270,15 @@ const StyleBookBody = ({
|
|
|
217
270
|
},
|
|
218
271
|
readonly: true
|
|
219
272
|
};
|
|
273
|
+
const handleLoad = () => setHasIframeLoaded(true);
|
|
274
|
+
(0, _element.useLayoutEffect)(() => {
|
|
275
|
+
if (goTo?.block && hasIframeLoaded && iframeRef?.current) {
|
|
276
|
+
scrollToSection(`example-${goTo?.block}`, iframeRef?.current);
|
|
277
|
+
}
|
|
278
|
+
}, [iframeRef?.current, goTo?.block, scrollToSection, hasIframeLoaded]);
|
|
220
279
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_blockEditor.__unstableIframe, {
|
|
280
|
+
onLoad: handleLoad,
|
|
281
|
+
ref: iframeRef,
|
|
221
282
|
className: (0, _clsx.default)('edit-site-style-book__iframe', {
|
|
222
283
|
'is-focused': isFocused && !!onClick,
|
|
223
284
|
'is-button': !!onClick
|
|
@@ -265,10 +326,8 @@ const Examples = (0, _element.memo)(({
|
|
|
265
326
|
title: example.title,
|
|
266
327
|
content: example.content,
|
|
267
328
|
blocks: example.blocks,
|
|
268
|
-
isSelected: isSelected(example.name),
|
|
269
|
-
onClick: () =>
|
|
270
|
-
onSelect?.(example.name);
|
|
271
|
-
}
|
|
329
|
+
isSelected: isSelected?.(example.name),
|
|
330
|
+
onClick: () => onSelect?.(example.name)
|
|
272
331
|
}, example.name)), !!filteredExamples?.subcategories?.length && filteredExamples.subcategories.map(subcategory => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Composite.Group, {
|
|
273
332
|
className: "edit-site-style-book__subcategory",
|
|
274
333
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Composite.GroupLabel, {
|
|
@@ -294,7 +353,7 @@ const Subcategory = ({
|
|
|
294
353
|
title: example.title,
|
|
295
354
|
content: example.content,
|
|
296
355
|
blocks: example.blocks,
|
|
297
|
-
isSelected: isSelected(example.name),
|
|
356
|
+
isSelected: isSelected?.(example.name),
|
|
298
357
|
onClick: () => {
|
|
299
358
|
onSelect?.(example.name);
|
|
300
359
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_blockEditor","_editor","_data","_compose","_element","_keycodes","_lockUnlock","_editorCanvasContainer","_constants","_categories","_examples","_jsxRuntime","ExperimentalBlockEditorProvider","useGlobalStyle","GlobalStylesContext","useGlobalStylesOutputWithConfig","unlock","blockEditorPrivateApis","mergeBaseAndUserConfigs","editorPrivateApis","Tabs","componentsPrivateApis","isObjectEmpty","object","Object","keys","length","useMultiOriginPalettes","colors","gradients","useMultipleOriginColorsAndGradients","shouldDisplayDefaultDuotones","customDuotones","themeDuotones","defaultDuotones","useSettings","palettes","useMemo","result","duotones","push","name","_x","slug","StyleBook","enableResizing","isSelected","onClick","onSelect","showCloseButton","onClose","showTabs","userConfig","resizeObserver","sizes","useResizeObserver","textColor","backgroundColor","examples","getExamples","tabs","getTopLevelStyleBookCategories","filter","category","some","example","base","baseConfig","useContext","mergedConfig","originalSettings","useSelect","select","blockEditorStore","getSettings","globalStyles","settings","styles","isPreviewMode","jsx","default","closeButtonLabel","__","children","jsxs","className","clsx","width","style","color","background","TabList","map","tab","Tab","tabId","title","TabPanel","focusable","StyleBookBody","isFocused","setIsFocused","useState","buttonModeProps","role","onFocus","onBlur","onKeyDown","event","defaultPrevented","keyCode","ENTER","SPACE","preventDefault","readonly","__unstableIframe","tabIndex","__unstableEditorStyles","STYLE_BOOK_IFRAME_STYLES","Examples","label","sprintf","memo","categoryDefinition","find","_category","filteredExamples","getExamplesByCategory","Composite","orientation","Example","id","content","blocks","subcategories","subcategory","Group","GroupLabel","Subcategory","disabledExamples","focusMode","renderedBlocks","Array","isArray","disabledProps","includes","disabled","accessibleWhenDisabled","Item","render","Disabled","value","BlockList","renderAppender","_default","exports"],"sources":["@wordpress/edit-site/src/components/style-book/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tDisabled,\n\tComposite,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport {\n\tBlockList,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n\tuseSettings,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n\t__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,\n} from '@wordpress/block-editor';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { useSelect } from '@wordpress/data';\nimport { useResizeObserver } from '@wordpress/compose';\nimport { useMemo, useState, memo, useContext } from '@wordpress/element';\nimport { ENTER, SPACE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport EditorCanvasContainer from '../editor-canvas-container';\nimport { STYLE_BOOK_IFRAME_STYLES } from './constants';\nimport {\n\tgetExamplesByCategory,\n\tgetTopLevelStyleBookCategories,\n} from './categories';\nimport { getExamples } from './examples';\n\nconst {\n\tExperimentalBlockEditorProvider,\n\tuseGlobalStyle,\n\tGlobalStylesContext,\n\tuseGlobalStylesOutputWithConfig,\n} = unlock( blockEditorPrivateApis );\nconst { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nfunction isObjectEmpty( object ) {\n\treturn ! object || Object.keys( object ).length === 0;\n}\n\n/**\n * Retrieves colors, gradients, and duotone filters from Global Styles.\n * The inclusion of default (Core) palettes is controlled by the relevant\n * theme.json property e.g. defaultPalette, defaultGradients, defaultDuotone.\n *\n * @return {Object} Object containing properties for each type of palette.\n */\nfunction useMultiOriginPalettes() {\n\tconst { colors, gradients } = useMultipleOriginColorsAndGradients();\n\n\t// Add duotone filters to the palettes data.\n\tconst [\n\t\tshouldDisplayDefaultDuotones,\n\t\tcustomDuotones,\n\t\tthemeDuotones,\n\t\tdefaultDuotones,\n\t] = useSettings(\n\t\t'color.defaultDuotone',\n\t\t'color.duotone.custom',\n\t\t'color.duotone.theme',\n\t\t'color.duotone.default'\n\t);\n\n\tconst palettes = useMemo( () => {\n\t\tconst result = { colors, gradients, duotones: [] };\n\n\t\tif ( themeDuotones && themeDuotones.length ) {\n\t\t\tresult.duotones.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates these duotone filters come from the theme.'\n\t\t\t\t),\n\t\t\t\tslug: 'theme',\n\t\t\t\tduotones: themeDuotones,\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tshouldDisplayDefaultDuotones &&\n\t\t\tdefaultDuotones &&\n\t\t\tdefaultDuotones.length\n\t\t) {\n\t\t\tresult.duotones.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates these duotone filters come from WordPress.'\n\t\t\t\t),\n\t\t\t\tslug: 'default',\n\t\t\t\tduotones: defaultDuotones,\n\t\t\t} );\n\t\t}\n\t\tif ( customDuotones && customDuotones.length ) {\n\t\t\tresult.duotones.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates these doutone filters are created by the user.'\n\t\t\t\t),\n\t\t\t\tslug: 'custom',\n\t\t\t\tduotones: customDuotones,\n\t\t\t} );\n\t\t}\n\n\t\treturn result;\n\t}, [\n\t\tcolors,\n\t\tgradients,\n\t\tcustomDuotones,\n\t\tthemeDuotones,\n\t\tdefaultDuotones,\n\t\tshouldDisplayDefaultDuotones,\n\t] );\n\n\treturn palettes;\n}\n\nfunction StyleBook( {\n\tenableResizing = true,\n\tisSelected,\n\tonClick,\n\tonSelect,\n\tshowCloseButton = true,\n\tonClose,\n\tshowTabs = true,\n\tuserConfig = {},\n} ) {\n\tconst [ resizeObserver, sizes ] = useResizeObserver();\n\tconst [ textColor ] = useGlobalStyle( 'color.text' );\n\tconst [ backgroundColor ] = useGlobalStyle( 'color.background' );\n\tconst colors = useMultiOriginPalettes();\n\tconst examples = useMemo( () => getExamples( colors ), [ colors ] );\n\tconst tabs = useMemo(\n\t\t() =>\n\t\t\tgetTopLevelStyleBookCategories().filter( ( category ) =>\n\t\t\t\texamples.some(\n\t\t\t\t\t( example ) => example.category === category.slug\n\t\t\t\t)\n\t\t\t),\n\t\t[ examples ]\n\t);\n\n\tconst { base: baseConfig } = useContext( GlobalStylesContext );\n\n\tconst mergedConfig = useMemo( () => {\n\t\tif ( ! isObjectEmpty( userConfig ) && ! isObjectEmpty( baseConfig ) ) {\n\t\t\treturn mergeBaseAndUserConfigs( baseConfig, userConfig );\n\t\t}\n\t\treturn {};\n\t}, [ baseConfig, userConfig ] );\n\n\t// Copied from packages/edit-site/src/components/revisions/index.js\n\t// could we create a shared hook?\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst [ globalStyles ] = useGlobalStylesOutputWithConfig( mergedConfig );\n\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...originalSettings,\n\t\t\tstyles:\n\t\t\t\t! isObjectEmpty( globalStyles ) && ! isObjectEmpty( userConfig )\n\t\t\t\t\t? globalStyles\n\t\t\t\t\t: originalSettings.styles,\n\t\t\tisPreviewMode: true,\n\t\t} ),\n\t\t[ globalStyles, originalSettings, userConfig ]\n\t);\n\n\treturn (\n\t\t<EditorCanvasContainer\n\t\t\tonClose={ onClose }\n\t\t\tenableResizing={ enableResizing }\n\t\t\tcloseButtonLabel={ showCloseButton ? __( 'Close' ) : null }\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={ clsx( 'edit-site-style-book', {\n\t\t\t\t\t'is-wide': sizes.width > 600,\n\t\t\t\t\t'is-button': !! onClick,\n\t\t\t\t} ) }\n\t\t\t\tstyle={ {\n\t\t\t\t\tcolor: textColor,\n\t\t\t\t\tbackground: backgroundColor,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ resizeObserver }\n\t\t\t\t{ showTabs ? (\n\t\t\t\t\t<Tabs>\n\t\t\t\t\t\t<div className=\"edit-site-style-book__tablist-container\">\n\t\t\t\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t\t\t\t\t<Tabs.Tab\n\t\t\t\t\t\t\t\t\t\ttabId={ tab.slug }\n\t\t\t\t\t\t\t\t\t\tkey={ tab.slug }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t</Tabs.TabList>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\tkey={ tab.slug }\n\t\t\t\t\t\t\t\ttabId={ tab.slug }\n\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\tclassName=\"edit-site-style-book__tabpanel\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<StyleBookBody\n\t\t\t\t\t\t\t\t\tcategory={ tab.slug }\n\t\t\t\t\t\t\t\t\texamples={ examples }\n\t\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\t\tsizes={ sizes }\n\t\t\t\t\t\t\t\t\ttitle={ tab.title }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</Tabs>\n\t\t\t\t) : (\n\t\t\t\t\t<StyleBookBody\n\t\t\t\t\t\texamples={ examples }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\tsizes={ sizes }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</EditorCanvasContainer>\n\t);\n}\n\nconst StyleBookBody = ( {\n\tcategory,\n\texamples,\n\tisSelected,\n\tonClick,\n\tonSelect,\n\tsettings,\n\tsizes,\n\ttitle,\n} ) => {\n\tconst [ isFocused, setIsFocused ] = useState( false );\n\n\t// The presence of an `onClick` prop indicates that the Style Book is being used as a button.\n\t// In this case, add additional props to the iframe to make it behave like a button.\n\tconst buttonModeProps = {\n\t\trole: 'button',\n\t\tonFocus: () => setIsFocused( true ),\n\t\tonBlur: () => setIsFocused( false ),\n\t\tonKeyDown: ( event ) => {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { keyCode } = event;\n\t\t\tif ( onClick && ( keyCode === ENTER || keyCode === SPACE ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonClick( event );\n\t\t\t}\n\t\t},\n\t\tonClick: ( event ) => {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( onClick ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonClick( event );\n\t\t\t}\n\t\t},\n\t\treadonly: true,\n\t};\n\n\treturn (\n\t\t<Iframe\n\t\t\tclassName={ clsx( 'edit-site-style-book__iframe', {\n\t\t\t\t'is-focused': isFocused && !! onClick,\n\t\t\t\t'is-button': !! onClick,\n\t\t\t} ) }\n\t\t\tname=\"style-book-canvas\"\n\t\t\ttabIndex={ 0 }\n\t\t\t{ ...( onClick ? buttonModeProps : {} ) }\n\t\t>\n\t\t\t<EditorStyles styles={ settings.styles } />\n\t\t\t<style>\n\t\t\t\t{ STYLE_BOOK_IFRAME_STYLES }\n\t\t\t\t{ !! onClick &&\n\t\t\t\t\t'body { cursor: pointer; } body * { pointer-events: none; }' }\n\t\t\t</style>\n\t\t\t<Examples\n\t\t\t\tclassName={ clsx( 'edit-site-style-book__examples', {\n\t\t\t\t\t'is-wide': sizes.width > 600,\n\t\t\t\t} ) }\n\t\t\t\texamples={ examples }\n\t\t\t\tcategory={ category }\n\t\t\t\tlabel={\n\t\t\t\t\ttitle\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Category of blocks, e.g. Text.\n\t\t\t\t\t\t\t\t__( 'Examples of blocks in the %s category' ),\n\t\t\t\t\t\t\t\ttitle\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Examples of blocks' )\n\t\t\t\t}\n\t\t\t\tisSelected={ isSelected }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tkey={ category }\n\t\t\t/>\n\t\t</Iframe>\n\t);\n};\n\nconst Examples = memo(\n\t( { className, examples, category, label, isSelected, onSelect } ) => {\n\t\tconst categoryDefinition = category\n\t\t\t? getTopLevelStyleBookCategories().find(\n\t\t\t\t\t( _category ) => _category.slug === category\n\t\t\t )\n\t\t\t: null;\n\n\t\tconst filteredExamples = categoryDefinition\n\t\t\t? getExamplesByCategory( categoryDefinition, examples )\n\t\t\t: { examples };\n\n\t\treturn (\n\t\t\t<Composite\n\t\t\t\torientation=\"vertical\"\n\t\t\t\tclassName={ className }\n\t\t\t\taria-label={ label }\n\t\t\t\trole=\"grid\"\n\t\t\t>\n\t\t\t\t{ !! filteredExamples?.examples?.length &&\n\t\t\t\t\tfilteredExamples.examples.map( ( example ) => (\n\t\t\t\t\t\t<Example\n\t\t\t\t\t\t\tkey={ example.name }\n\t\t\t\t\t\t\tid={ `example-${ example.name }` }\n\t\t\t\t\t\t\ttitle={ example.title }\n\t\t\t\t\t\t\tcontent={ example.content }\n\t\t\t\t\t\t\tblocks={ example.blocks }\n\t\t\t\t\t\t\tisSelected={ isSelected( example.name ) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tonSelect?.( example.name );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t{ !! filteredExamples?.subcategories?.length &&\n\t\t\t\t\tfilteredExamples.subcategories.map( ( subcategory ) => (\n\t\t\t\t\t\t<Composite.Group\n\t\t\t\t\t\t\tclassName=\"edit-site-style-book__subcategory\"\n\t\t\t\t\t\t\tkey={ `subcategory-${ subcategory.slug }` }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Composite.GroupLabel>\n\t\t\t\t\t\t\t\t<h2 className=\"edit-site-style-book__subcategory-title\">\n\t\t\t\t\t\t\t\t\t{ subcategory.title }\n\t\t\t\t\t\t\t\t</h2>\n\t\t\t\t\t\t\t</Composite.GroupLabel>\n\t\t\t\t\t\t\t<Subcategory\n\t\t\t\t\t\t\t\texamples={ subcategory.examples }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Composite.Group>\n\t\t\t\t\t) ) }\n\t\t\t</Composite>\n\t\t);\n\t}\n);\n\nconst Subcategory = ( { examples, isSelected, onSelect } ) => {\n\treturn (\n\t\t!! examples?.length &&\n\t\texamples.map( ( example ) => (\n\t\t\t<Example\n\t\t\t\tkey={ example.name }\n\t\t\t\tid={ `example-${ example.name }` }\n\t\t\t\ttitle={ example.title }\n\t\t\t\tcontent={ example.content }\n\t\t\t\tblocks={ example.blocks }\n\t\t\t\tisSelected={ isSelected( example.name ) }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tonSelect?.( example.name );\n\t\t\t\t} }\n\t\t\t/>\n\t\t) )\n\t);\n};\n\nconst disabledExamples = [ 'example-duotones' ];\n\nconst Example = ( { id, title, blocks, isSelected, onClick, content } ) => {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...originalSettings,\n\t\t\tfocusMode: false, // Disable \"Spotlight mode\".\n\t\t\tisPreviewMode: true,\n\t\t} ),\n\t\t[ originalSettings ]\n\t);\n\n\t// Cache the list of blocks to avoid additional processing when the component is re-rendered.\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tconst disabledProps = disabledExamples.includes( id )\n\t\t? {\n\t\t\t\tdisabled: true,\n\t\t\t\taccessibleWhenDisabled: true,\n\t\t }\n\t\t: {};\n\n\treturn (\n\t\t<div role=\"row\">\n\t\t\t<div role=\"gridcell\">\n\t\t\t\t<Composite.Item\n\t\t\t\t\tclassName={ clsx( 'edit-site-style-book__example', {\n\t\t\t\t\t\t'is-selected': isSelected,\n\t\t\t\t\t\t'is-disabled-example': !! disabledProps?.disabled,\n\t\t\t\t\t} ) }\n\t\t\t\t\tid={ id }\n\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t// translators: %s: Title of a block, e.g. Heading.\n\t\t\t\t\t\t__( 'Open %s styles in Styles panel' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t\t) }\n\t\t\t\t\trender={ <div /> }\n\t\t\t\t\trole=\"button\"\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t{ ...disabledProps }\n\t\t\t\t>\n\t\t\t\t\t<span className=\"edit-site-style-book__example-title\">\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</span>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"edit-site-style-book__example-preview\"\n\t\t\t\t\t\taria-hidden\n\t\t\t\t\t>\n\t\t\t\t\t\t<Disabled className=\"edit-site-style-book__example-preview__content\">\n\t\t\t\t\t\t\t{ content ? (\n\t\t\t\t\t\t\t\tcontent\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\t\t\t\t\t\tvalue={ renderedBlocks }\n\t\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<EditorStyles />\n\t\t\t\t\t\t\t\t\t<BlockList renderAppender={ false } />\n\t\t\t\t\t\t\t\t</ExperimentalBlockEditorProvider>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Disabled>\n\t\t\t\t\t</div>\n\t\t\t\t</Composite.Item>\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport default StyleBook;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AASA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AAKA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,sBAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,UAAA,GAAAX,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AAIA,IAAAa,SAAA,GAAAb,OAAA;AAAyC,IAAAc,WAAA,GAAAd,OAAA;AAvCzC;AACA;AACA;;AAGA;AACA;AACA;;AAsBA;AACA;AACA;;AAUA,MAAM;EACLe,+BAA+B;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xE,WAAA,CAAAoE,GAAA;UAAMM,SAAS,EAAC,qCAAqC;UAAAF,QAAA,EAClDa;QAAK,CACF,CAAC,eACP,IAAArF,WAAA,CAAAoE,GAAA;UACCM,SAAS,EAAC,uCAAuC;UACjD,mBAAW;UAAAF,QAAA,eAEX,IAAAxE,WAAA,CAAAoE,GAAA,EAACjF,WAAA,CAAAwJ,QAAQ;YAACjE,SAAS,EAAC,gDAAgD;YAAAF,QAAA,EACjEiD,OAAO,GACRA,OAAO,gBAEP,IAAAzH,WAAA,CAAAyE,IAAA,EAACxE,+BAA+B;cAC/B2I,KAAK,EAAGV,cAAgB;cACxBjE,QAAQ,EAAGA,QAAU;cAAAO,QAAA,gBAErB,IAAAxE,WAAA,CAAAoE,GAAA,EAAC/E,YAAA,CAAAqH,sBAAY,IAAE,CAAC,eAChB,IAAA1G,WAAA,CAAAoE,GAAA,EAAC/E,YAAA,CAAAwJ,SAAS;gBAACC,cAAc,EAAG;cAAO,CAAE,CAAC;YAAA,CACN;UACjC,CACQ;QAAC,CACP,CAAC;MAAA,CACS;IAAC,CACb;EAAC,CACF,CAAC;AAER,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA3E,OAAA,GAEapC,SAAS","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_blockEditor","_editor","_data","_compose","_element","_keycodes","_lockUnlock","_editorCanvasContainer","_constants","_categories","_examples","_jsxRuntime","ExperimentalBlockEditorProvider","useGlobalStyle","GlobalStylesContext","useGlobalStylesOutputWithConfig","unlock","blockEditorPrivateApis","mergeBaseAndUserConfigs","editorPrivateApis","Tabs","componentsPrivateApis","isObjectEmpty","object","Object","keys","length","scrollToSection","anchorId","iframe","contentDocument","element","getElementById","scrollIntoView","behavior","getStyleBookNavigationFromPath","path","block","includes","decodeURIComponent","split","endsWith","useMultiOriginPalettes","colors","gradients","useMultipleOriginColorsAndGradients","shouldDisplayDefaultDuotones","customDuotones","themeDuotones","defaultDuotones","useSettings","palettes","useMemo","result","duotones","push","name","_x","slug","StyleBook","enableResizing","isSelected","onClick","onSelect","showCloseButton","onClose","showTabs","userConfig","resizeObserver","sizes","useResizeObserver","textColor","backgroundColor","examples","getExamples","tabs","getTopLevelStyleBookCategories","filter","category","some","example","examplesForSinglePageUse","overviewCategoryExamples","getExamplesByCategory","otherExamples","find","overviewExample","base","baseConfig","useContext","goTo","mergedConfig","originalSettings","useSelect","select","blockEditorStore","getSettings","globalStyles","settings","styles","isPreviewMode","jsx","default","closeButtonLabel","__","children","jsxs","className","clsx","width","style","color","background","TabList","map","tab","Tab","tabId","title","TabPanel","focusable","StyleBookBody","isFocused","setIsFocused","useState","hasIframeLoaded","setHasIframeLoaded","iframeRef","useRef","buttonModeProps","role","onFocus","onBlur","onKeyDown","event","defaultPrevented","keyCode","ENTER","SPACE","preventDefault","readonly","handleLoad","useLayoutEffect","current","__unstableIframe","onLoad","ref","tabIndex","__unstableEditorStyles","STYLE_BOOK_IFRAME_STYLES","Examples","label","sprintf","memo","categoryDefinition","_category","filteredExamples","Composite","orientation","Example","id","content","blocks","subcategories","subcategory","Group","GroupLabel","Subcategory","disabledExamples","focusMode","renderedBlocks","Array","isArray","disabledProps","disabled","accessibleWhenDisabled","Item","render","Disabled","value","BlockList","renderAppender","_default","exports"],"sources":["@wordpress/edit-site/src/components/style-book/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tDisabled,\n\tComposite,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport {\n\tBlockList,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n\tuseSettings,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n\t__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,\n} from '@wordpress/block-editor';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { useSelect } from '@wordpress/data';\nimport { useResizeObserver } from '@wordpress/compose';\nimport {\n\tuseMemo,\n\tuseState,\n\tmemo,\n\tuseContext,\n\tuseRef,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { ENTER, SPACE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport EditorCanvasContainer from '../editor-canvas-container';\nimport { STYLE_BOOK_IFRAME_STYLES } from './constants';\nimport {\n\tgetExamplesByCategory,\n\tgetTopLevelStyleBookCategories,\n} from './categories';\nimport { getExamples } from './examples';\n\nconst {\n\tExperimentalBlockEditorProvider,\n\tuseGlobalStyle,\n\tGlobalStylesContext,\n\tuseGlobalStylesOutputWithConfig,\n} = unlock( blockEditorPrivateApis );\nconst { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nfunction isObjectEmpty( object ) {\n\treturn ! object || Object.keys( object ).length === 0;\n}\n\n/**\n * Scrolls to a section within an iframe.\n *\n * @param {string} anchorId The id of the element to scroll to.\n * @param {HTMLIFrameElement} iframe The target iframe.\n */\nconst scrollToSection = ( anchorId, iframe ) => {\n\tif ( ! iframe || ! iframe?.contentDocument ) {\n\t\treturn;\n\t}\n\n\tconst element = iframe.contentDocument.getElementById( anchorId );\n\tif ( element ) {\n\t\telement.scrollIntoView( {\n\t\t\tbehavior: 'smooth',\n\t\t} );\n\t}\n};\n\n/**\n * Parses a Block Editor navigation path to extract the block name and\n * build a style book navigation path. The object can be extended to include a category,\n * representing a style book tab/section.\n *\n * @param {string} path An internal Block Editor navigation path.\n * @return {null|{block: string}} An object containing the example to navigate to.\n */\nconst getStyleBookNavigationFromPath = ( path ) => {\n\tif ( path && typeof path === 'string' ) {\n\t\tlet block = path.includes( '/blocks/' )\n\t\t\t? decodeURIComponent( path.split( '/blocks/' )[ 1 ] )\n\t\t\t: null;\n\t\t// Default to theme-colors if the path ends with /colors.\n\t\tblock = path.endsWith( '/colors' ) ? 'theme-colors' : block;\n\n\t\treturn {\n\t\t\tblock,\n\t\t};\n\t}\n\treturn null;\n};\n\n/**\n * Retrieves colors, gradients, and duotone filters from Global Styles.\n * The inclusion of default (Core) palettes is controlled by the relevant\n * theme.json property e.g. defaultPalette, defaultGradients, defaultDuotone.\n *\n * @return {Object} Object containing properties for each type of palette.\n */\nfunction useMultiOriginPalettes() {\n\tconst { colors, gradients } = useMultipleOriginColorsAndGradients();\n\n\t// Add duotone filters to the palettes data.\n\tconst [\n\t\tshouldDisplayDefaultDuotones,\n\t\tcustomDuotones,\n\t\tthemeDuotones,\n\t\tdefaultDuotones,\n\t] = useSettings(\n\t\t'color.defaultDuotone',\n\t\t'color.duotone.custom',\n\t\t'color.duotone.theme',\n\t\t'color.duotone.default'\n\t);\n\n\tconst palettes = useMemo( () => {\n\t\tconst result = { colors, gradients, duotones: [] };\n\n\t\tif ( themeDuotones && themeDuotones.length ) {\n\t\t\tresult.duotones.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates these duotone filters come from the theme.'\n\t\t\t\t),\n\t\t\t\tslug: 'theme',\n\t\t\t\tduotones: themeDuotones,\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tshouldDisplayDefaultDuotones &&\n\t\t\tdefaultDuotones &&\n\t\t\tdefaultDuotones.length\n\t\t) {\n\t\t\tresult.duotones.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates these duotone filters come from WordPress.'\n\t\t\t\t),\n\t\t\t\tslug: 'default',\n\t\t\t\tduotones: defaultDuotones,\n\t\t\t} );\n\t\t}\n\t\tif ( customDuotones && customDuotones.length ) {\n\t\t\tresult.duotones.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates these doutone filters are created by the user.'\n\t\t\t\t),\n\t\t\t\tslug: 'custom',\n\t\t\t\tduotones: customDuotones,\n\t\t\t} );\n\t\t}\n\n\t\treturn result;\n\t}, [\n\t\tcolors,\n\t\tgradients,\n\t\tcustomDuotones,\n\t\tthemeDuotones,\n\t\tdefaultDuotones,\n\t\tshouldDisplayDefaultDuotones,\n\t] );\n\n\treturn palettes;\n}\n\nfunction StyleBook( {\n\tenableResizing = true,\n\tisSelected,\n\tonClick,\n\tonSelect,\n\tshowCloseButton = true,\n\tonClose,\n\tshowTabs = true,\n\tuserConfig = {},\n\tpath = '',\n} ) {\n\tconst [ resizeObserver, sizes ] = useResizeObserver();\n\tconst [ textColor ] = useGlobalStyle( 'color.text' );\n\tconst [ backgroundColor ] = useGlobalStyle( 'color.background' );\n\tconst colors = useMultiOriginPalettes();\n\tconst examples = useMemo( () => getExamples( colors ), [ colors ] );\n\tconst tabs = useMemo(\n\t\t() =>\n\t\t\tgetTopLevelStyleBookCategories().filter( ( category ) =>\n\t\t\t\texamples.some(\n\t\t\t\t\t( example ) => example.category === category.slug\n\t\t\t\t)\n\t\t\t),\n\t\t[ examples ]\n\t);\n\n\tconst examplesForSinglePageUse = [];\n\tconst overviewCategoryExamples = getExamplesByCategory(\n\t\t{ slug: 'overview' },\n\t\texamples\n\t);\n\texamplesForSinglePageUse.push( ...overviewCategoryExamples.examples );\n\tconst otherExamples = examples.filter( ( example ) => {\n\t\treturn (\n\t\t\texample.category !== 'overview' &&\n\t\t\t! overviewCategoryExamples.examples.find(\n\t\t\t\t( overviewExample ) => overviewExample.name === example.name\n\t\t\t)\n\t\t);\n\t} );\n\texamplesForSinglePageUse.push( ...otherExamples );\n\n\tconst { base: baseConfig } = useContext( GlobalStylesContext );\n\tconst goTo = getStyleBookNavigationFromPath( path );\n\n\tconst mergedConfig = useMemo( () => {\n\t\tif ( ! isObjectEmpty( userConfig ) && ! isObjectEmpty( baseConfig ) ) {\n\t\t\treturn mergeBaseAndUserConfigs( baseConfig, userConfig );\n\t\t}\n\t\treturn {};\n\t}, [ baseConfig, userConfig ] );\n\n\t// Copied from packages/edit-site/src/components/revisions/index.js\n\t// could we create a shared hook?\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst [ globalStyles ] = useGlobalStylesOutputWithConfig( mergedConfig );\n\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...originalSettings,\n\t\t\tstyles:\n\t\t\t\t! isObjectEmpty( globalStyles ) && ! isObjectEmpty( userConfig )\n\t\t\t\t\t? globalStyles\n\t\t\t\t\t: originalSettings.styles,\n\t\t\tisPreviewMode: true,\n\t\t} ),\n\t\t[ globalStyles, originalSettings, userConfig ]\n\t);\n\n\treturn (\n\t\t<EditorCanvasContainer\n\t\t\tonClose={ onClose }\n\t\t\tenableResizing={ enableResizing }\n\t\t\tcloseButtonLabel={ showCloseButton ? __( 'Close' ) : null }\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={ clsx( 'edit-site-style-book', {\n\t\t\t\t\t'is-wide': sizes.width > 600,\n\t\t\t\t\t'is-button': !! onClick,\n\t\t\t\t} ) }\n\t\t\t\tstyle={ {\n\t\t\t\t\tcolor: textColor,\n\t\t\t\t\tbackground: backgroundColor,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ resizeObserver }\n\t\t\t\t{ showTabs ? (\n\t\t\t\t\t<Tabs>\n\t\t\t\t\t\t<div className=\"edit-site-style-book__tablist-container\">\n\t\t\t\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t\t\t\t\t<Tabs.Tab\n\t\t\t\t\t\t\t\t\t\ttabId={ tab.slug }\n\t\t\t\t\t\t\t\t\t\tkey={ tab.slug }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t</Tabs.TabList>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\tkey={ tab.slug }\n\t\t\t\t\t\t\t\ttabId={ tab.slug }\n\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\tclassName=\"edit-site-style-book__tabpanel\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<StyleBookBody\n\t\t\t\t\t\t\t\t\tcategory={ tab.slug }\n\t\t\t\t\t\t\t\t\texamples={ examples }\n\t\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\t\tsizes={ sizes }\n\t\t\t\t\t\t\t\t\ttitle={ tab.title }\n\t\t\t\t\t\t\t\t\tgoTo={ goTo }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</Tabs>\n\t\t\t\t) : (\n\t\t\t\t\t<StyleBookBody\n\t\t\t\t\t\texamples={ examplesForSinglePageUse }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\tsizes={ sizes }\n\t\t\t\t\t\tgoTo={ goTo }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</EditorCanvasContainer>\n\t);\n}\n\nconst StyleBookBody = ( {\n\tcategory,\n\texamples,\n\tisSelected,\n\tonClick,\n\tonSelect,\n\tsettings,\n\tsizes,\n\ttitle,\n\tgoTo,\n} ) => {\n\tconst [ isFocused, setIsFocused ] = useState( false );\n\tconst [ hasIframeLoaded, setHasIframeLoaded ] = useState( false );\n\tconst iframeRef = useRef( null );\n\t// The presence of an `onClick` prop indicates that the Style Book is being used as a button.\n\t// In this case, add additional props to the iframe to make it behave like a button.\n\tconst buttonModeProps = {\n\t\trole: 'button',\n\t\tonFocus: () => setIsFocused( true ),\n\t\tonBlur: () => setIsFocused( false ),\n\t\tonKeyDown: ( event ) => {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { keyCode } = event;\n\t\t\tif ( onClick && ( keyCode === ENTER || keyCode === SPACE ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonClick( event );\n\t\t\t}\n\t\t},\n\t\tonClick: ( event ) => {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( onClick ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonClick( event );\n\t\t\t}\n\t\t},\n\t\treadonly: true,\n\t};\n\n\tconst handleLoad = () => setHasIframeLoaded( true );\n\tuseLayoutEffect( () => {\n\t\tif ( goTo?.block && hasIframeLoaded && iframeRef?.current ) {\n\t\t\tscrollToSection( `example-${ goTo?.block }`, iframeRef?.current );\n\t\t}\n\t}, [ iframeRef?.current, goTo?.block, scrollToSection, hasIframeLoaded ] );\n\n\treturn (\n\t\t<Iframe\n\t\t\tonLoad={ handleLoad }\n\t\t\tref={ iframeRef }\n\t\t\tclassName={ clsx( 'edit-site-style-book__iframe', {\n\t\t\t\t'is-focused': isFocused && !! onClick,\n\t\t\t\t'is-button': !! onClick,\n\t\t\t} ) }\n\t\t\tname=\"style-book-canvas\"\n\t\t\ttabIndex={ 0 }\n\t\t\t{ ...( onClick ? buttonModeProps : {} ) }\n\t\t>\n\t\t\t<EditorStyles styles={ settings.styles } />\n\t\t\t<style>\n\t\t\t\t{ STYLE_BOOK_IFRAME_STYLES }\n\t\t\t\t{ !! onClick &&\n\t\t\t\t\t'body { cursor: pointer; } body * { pointer-events: none; }' }\n\t\t\t</style>\n\t\t\t<Examples\n\t\t\t\tclassName={ clsx( 'edit-site-style-book__examples', {\n\t\t\t\t\t'is-wide': sizes.width > 600,\n\t\t\t\t} ) }\n\t\t\t\texamples={ examples }\n\t\t\t\tcategory={ category }\n\t\t\t\tlabel={\n\t\t\t\t\ttitle\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Category of blocks, e.g. Text.\n\t\t\t\t\t\t\t\t__( 'Examples of blocks in the %s category' ),\n\t\t\t\t\t\t\t\ttitle\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Examples of blocks' )\n\t\t\t\t}\n\t\t\t\tisSelected={ isSelected }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tkey={ category }\n\t\t\t/>\n\t\t</Iframe>\n\t);\n};\n\nconst Examples = memo(\n\t( { className, examples, category, label, isSelected, onSelect } ) => {\n\t\tconst categoryDefinition = category\n\t\t\t? getTopLevelStyleBookCategories().find(\n\t\t\t\t\t( _category ) => _category.slug === category\n\t\t\t )\n\t\t\t: null;\n\n\t\tconst filteredExamples = categoryDefinition\n\t\t\t? getExamplesByCategory( categoryDefinition, examples )\n\t\t\t: { examples };\n\n\t\treturn (\n\t\t\t<Composite\n\t\t\t\torientation=\"vertical\"\n\t\t\t\tclassName={ className }\n\t\t\t\taria-label={ label }\n\t\t\t\trole=\"grid\"\n\t\t\t>\n\t\t\t\t{ !! filteredExamples?.examples?.length &&\n\t\t\t\t\tfilteredExamples.examples.map( ( example ) => (\n\t\t\t\t\t\t<Example\n\t\t\t\t\t\t\tkey={ example.name }\n\t\t\t\t\t\t\tid={ `example-${ example.name }` }\n\t\t\t\t\t\t\ttitle={ example.title }\n\t\t\t\t\t\t\tcontent={ example.content }\n\t\t\t\t\t\t\tblocks={ example.blocks }\n\t\t\t\t\t\t\tisSelected={ isSelected?.( example.name ) }\n\t\t\t\t\t\t\tonClick={ () => onSelect?.( example.name ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t{ !! filteredExamples?.subcategories?.length &&\n\t\t\t\t\tfilteredExamples.subcategories.map( ( subcategory ) => (\n\t\t\t\t\t\t<Composite.Group\n\t\t\t\t\t\t\tclassName=\"edit-site-style-book__subcategory\"\n\t\t\t\t\t\t\tkey={ `subcategory-${ subcategory.slug }` }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Composite.GroupLabel>\n\t\t\t\t\t\t\t\t<h2 className=\"edit-site-style-book__subcategory-title\">\n\t\t\t\t\t\t\t\t\t{ subcategory.title }\n\t\t\t\t\t\t\t\t</h2>\n\t\t\t\t\t\t\t</Composite.GroupLabel>\n\t\t\t\t\t\t\t<Subcategory\n\t\t\t\t\t\t\t\texamples={ subcategory.examples }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Composite.Group>\n\t\t\t\t\t) ) }\n\t\t\t</Composite>\n\t\t);\n\t}\n);\n\nconst Subcategory = ( { examples, isSelected, onSelect } ) => {\n\treturn (\n\t\t!! examples?.length &&\n\t\texamples.map( ( example ) => (\n\t\t\t<Example\n\t\t\t\tkey={ example.name }\n\t\t\t\tid={ `example-${ example.name }` }\n\t\t\t\ttitle={ example.title }\n\t\t\t\tcontent={ example.content }\n\t\t\t\tblocks={ example.blocks }\n\t\t\t\tisSelected={ isSelected?.( example.name ) }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tonSelect?.( example.name );\n\t\t\t\t} }\n\t\t\t/>\n\t\t) )\n\t);\n};\n\nconst disabledExamples = [ 'example-duotones' ];\n\nconst Example = ( { id, title, blocks, isSelected, onClick, content } ) => {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( {\n\t\t\t...originalSettings,\n\t\t\tfocusMode: false, // Disable \"Spotlight mode\".\n\t\t\tisPreviewMode: true,\n\t\t} ),\n\t\t[ originalSettings ]\n\t);\n\n\t// Cache the list of blocks to avoid additional processing when the component is re-rendered.\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\tconst disabledProps = disabledExamples.includes( id )\n\t\t? {\n\t\t\t\tdisabled: true,\n\t\t\t\taccessibleWhenDisabled: true,\n\t\t }\n\t\t: {};\n\n\treturn (\n\t\t<div role=\"row\">\n\t\t\t<div role=\"gridcell\">\n\t\t\t\t<Composite.Item\n\t\t\t\t\tclassName={ clsx( 'edit-site-style-book__example', {\n\t\t\t\t\t\t'is-selected': isSelected,\n\t\t\t\t\t\t'is-disabled-example': !! disabledProps?.disabled,\n\t\t\t\t\t} ) }\n\t\t\t\t\tid={ id }\n\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t// translators: %s: Title of a block, e.g. Heading.\n\t\t\t\t\t\t__( 'Open %s styles in Styles panel' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t\t) }\n\t\t\t\t\trender={ <div /> }\n\t\t\t\t\trole=\"button\"\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\t{ ...disabledProps }\n\t\t\t\t>\n\t\t\t\t\t<span className=\"edit-site-style-book__example-title\">\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</span>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"edit-site-style-book__example-preview\"\n\t\t\t\t\t\taria-hidden\n\t\t\t\t\t>\n\t\t\t\t\t\t<Disabled className=\"edit-site-style-book__example-preview__content\">\n\t\t\t\t\t\t\t{ content ? (\n\t\t\t\t\t\t\t\tcontent\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\t\t\t\t\t\tvalue={ renderedBlocks }\n\t\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<EditorStyles />\n\t\t\t\t\t\t\t\t\t<BlockList renderAppender={ false } />\n\t\t\t\t\t\t\t\t</ExperimentalBlockEditorProvider>\n\t\t\t\t\t\t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qB,EAAE,CAAC,CAAEgH,aAAa,EAAEC;QAC1C,CAAE,CAAG;QACLd,EAAE,EAAGA,EAAI;QACT,cAAa,IAAAR,aAAO;QACnB;QACA,IAAAhD,QAAE,EAAE,gCAAiC,CAAC,EACtCc,KACD,CAAG;QACH2D,MAAM,eAAG,IAAAtK,WAAA,CAAA0F,GAAA,WAAM,CAAG;QAClB6B,IAAI,EAAC,QAAQ;QACbpE,OAAO,EAAGA,OAAS;QAAA,GACd+G,aAAa;QAAApE,QAAA,gBAElB,IAAA9F,WAAA,CAAA0F,GAAA;UAAMM,SAAS,EAAC,qCAAqC;UAAAF,QAAA,EAClDa;QAAK,CACF,CAAC,eACP,IAAA3G,WAAA,CAAA0F,GAAA;UACCM,SAAS,EAAC,uCAAuC;UACjD,mBAAW;UAAAF,QAAA,eAEX,IAAA9F,WAAA,CAAA0F,GAAA,EAACvG,WAAA,CAAAoL,QAAQ;YAACvE,SAAS,EAAC,gDAAgD;YAAAF,QAAA,EACjEwD,OAAO,GACRA,OAAO,gBAEP,IAAAtJ,WAAA,CAAA+F,IAAA,EAAC9F,+BAA+B;cAC/BuK,KAAK,EAAGT,cAAgB;cACxBxE,QAAQ,EAAGA,QAAU;cAAAO,QAAA,gBAErB,IAAA9F,WAAA,CAAA0F,GAAA,EAACrG,YAAA,CAAAoJ,sBAAY,IAAE,CAAC,eAChB,IAAAzI,WAAA,CAAA0F,GAAA,EAACrG,YAAA,CAAAoL,SAAS;gBAACC,cAAc,EAAG;cAAO,CAAE,CAAC;YAAA,CACN;UACjC,CACQ;QAAC,CACP,CAAC;MAAA,CACS;IAAC,CACb;EAAC,CACF,CAAC;AAER,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAjF,OAAA,GAEa3C,SAAS","ignoreList":[]}
|
|
@@ -32,33 +32,19 @@ function useResolveEditedEntityAndContext({
|
|
|
32
32
|
const {
|
|
33
33
|
hasLoadedAllDependencies,
|
|
34
34
|
homepageId,
|
|
35
|
-
postsPageId
|
|
36
|
-
url,
|
|
37
|
-
frontPageTemplateId
|
|
35
|
+
postsPageId
|
|
38
36
|
} = (0, _data.useSelect)(select => {
|
|
39
37
|
const {
|
|
40
|
-
getEntityRecord
|
|
41
|
-
getEntityRecords
|
|
38
|
+
getEntityRecord
|
|
42
39
|
} = select(_coreData.store);
|
|
43
40
|
const siteData = getEntityRecord('root', 'site');
|
|
44
|
-
const base = getEntityRecord('root', '__unstableBase');
|
|
45
|
-
const templates = getEntityRecords('postType', _constants.TEMPLATE_POST_TYPE, {
|
|
46
|
-
per_page: -1
|
|
47
|
-
});
|
|
48
41
|
const _homepageId = siteData?.show_on_front === 'page' && ['number', 'string'].includes(typeof siteData.page_on_front) && !!+siteData.page_on_front // We also need to check if it's not zero(`0`).
|
|
49
42
|
? siteData.page_on_front.toString() : null;
|
|
50
43
|
const _postsPageId = siteData?.show_on_front === 'page' && ['number', 'string'].includes(typeof siteData.page_for_posts) ? siteData.page_for_posts.toString() : null;
|
|
51
|
-
let _frontPageTemplateId;
|
|
52
|
-
if (templates) {
|
|
53
|
-
const frontPageTemplate = templates.find(t => t.slug === 'front-page');
|
|
54
|
-
_frontPageTemplateId = frontPageTemplate ? frontPageTemplate.id : false;
|
|
55
|
-
}
|
|
56
44
|
return {
|
|
57
|
-
hasLoadedAllDependencies: !!
|
|
45
|
+
hasLoadedAllDependencies: !!siteData,
|
|
58
46
|
homepageId: _homepageId,
|
|
59
|
-
postsPageId: _postsPageId
|
|
60
|
-
url: base?.home,
|
|
61
|
-
frontPageTemplateId: _frontPageTemplateId
|
|
47
|
+
postsPageId: _postsPageId
|
|
62
48
|
};
|
|
63
49
|
}, []);
|
|
64
50
|
|
|
@@ -82,20 +68,33 @@ function useResolveEditedEntityAndContext({
|
|
|
82
68
|
const {
|
|
83
69
|
getEditedEntityRecord,
|
|
84
70
|
getEntityRecords,
|
|
85
|
-
getDefaultTemplateId
|
|
86
|
-
__experimentalGetTemplateForLink
|
|
71
|
+
getDefaultTemplateId
|
|
87
72
|
} = select(_coreData.store);
|
|
88
73
|
function resolveTemplateForPostTypeAndId(postTypeToResolve, postIdToResolve) {
|
|
89
74
|
// For the front page, we always use the front page template if existing.
|
|
90
75
|
if (postTypeToResolve === 'page' && homepageId === postIdToResolve) {
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
if
|
|
76
|
+
// The /lookup endpoint cannot currently handle a lookup
|
|
77
|
+
// when a page is set as the front page, so specifically in
|
|
78
|
+
// that case, we want to check if there is a front page
|
|
79
|
+
// template, and instead of falling back to the home
|
|
80
|
+
// template, we want to fall back to the page template.
|
|
81
|
+
const templates = getEntityRecords('postType', _constants.TEMPLATE_POST_TYPE, {
|
|
82
|
+
per_page: -1
|
|
83
|
+
});
|
|
84
|
+
if (templates) {
|
|
85
|
+
const id = templates?.find(({
|
|
86
|
+
slug
|
|
87
|
+
}) => slug === 'front-page')?.id;
|
|
88
|
+
if (id) {
|
|
89
|
+
return id;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// If no front page template is found, continue with the
|
|
93
|
+
// logic below (fetching the page template).
|
|
94
|
+
} else {
|
|
95
|
+
// Still resolving `templates`.
|
|
94
96
|
return undefined;
|
|
95
97
|
}
|
|
96
|
-
if (!!frontPageTemplateId) {
|
|
97
|
-
return frontPageTemplateId;
|
|
98
|
-
}
|
|
99
98
|
}
|
|
100
99
|
const editedEntity = getEditedEntityRecord('postType', postTypeToResolve, postIdToResolve);
|
|
101
100
|
if (!editedEntity) {
|
|
@@ -103,7 +102,9 @@ function useResolveEditedEntityAndContext({
|
|
|
103
102
|
}
|
|
104
103
|
// Check if the current page is the posts page.
|
|
105
104
|
if (postTypeToResolve === 'page' && postsPageId === postIdToResolve) {
|
|
106
|
-
return
|
|
105
|
+
return getDefaultTemplateId({
|
|
106
|
+
slug: 'home'
|
|
107
|
+
});
|
|
107
108
|
}
|
|
108
109
|
// First see if the post/page has an assigned template and fetch it.
|
|
109
110
|
const currentTemplateSlug = editedEntity.template;
|
|
@@ -148,11 +149,10 @@ function useResolveEditedEntityAndContext({
|
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
// If we're not rendering a specific page, use the front page template.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}, [homepageId, postsPageId, hasLoadedAllDependencies, url, postId, postType, frontPageTemplateId]);
|
|
152
|
+
return getDefaultTemplateId({
|
|
153
|
+
slug: 'front-page'
|
|
154
|
+
});
|
|
155
|
+
}, [homepageId, postsPageId, hasLoadedAllDependencies, postId, postType]);
|
|
156
156
|
const context = (0, _element.useMemo)(() => {
|
|
157
157
|
if (postTypesWithoutParentTemplate.includes(postType) && postId) {
|
|
158
158
|
return {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_data","_coreData","_router","_blockEditor","_store","_lockUnlock","_constants","useLocation","unlock","routerPrivateApis","postTypesWithoutParentTemplate","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","NAVIGATION_POST_TYPE","PATTERN_TYPES","user","authorizedPostTypes","useResolveEditedEntityAndContext","postId","postType","hasLoadedAllDependencies","homepageId","postsPageId","url","frontPageTemplateId","useSelect","select","getEntityRecord","getEntityRecords","coreDataStore","siteData","base","templates","per_page","_homepageId","show_on_front","includes","page_on_front","toString","_postsPageId","page_for_posts","_frontPageTemplateId","frontPageTemplate","find","t","slug","id","home","resolvedTemplateId","undefined","getEditedEntityRecord","getDefaultTemplateId","__experimentalGetTemplateForLink","resolveTemplateForPostTypeAndId","postTypeToResolve","postIdToResolve","editedEntity","link","currentTemplateSlug","template","currentTemplate","slugToCheck","context","useMemo","isReady","useInitEditedEntityFromURL","params","setEditedEntity","useDispatch","editSiteStore","resetZoomLevel","blockEditorStore","useEffect"],"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES,\n} from '../../utils/constants';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nconst postTypesWithoutParentTemplate = [\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES.user,\n];\n\nconst authorizedPostTypes = [ 'page', 'post' ];\n\nfunction useResolveEditedEntityAndContext( { postId, postType } ) {\n\tconst {\n\t\thasLoadedAllDependencies,\n\t\thomepageId,\n\t\tpostsPageId,\n\t\turl,\n\t\tfrontPageTemplateId,\n\t} = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, getEntityRecords } = select( coreDataStore );\n\t\tconst siteData = getEntityRecord( 'root', 'site' );\n\t\tconst base = getEntityRecord( 'root', '__unstableBase' );\n\t\tconst templates = getEntityRecords( 'postType', TEMPLATE_POST_TYPE, {\n\t\t\tper_page: -1,\n\t\t} );\n\t\tconst _homepageId =\n\t\t\tsiteData?.show_on_front === 'page' &&\n\t\t\t[ 'number', 'string' ].includes( typeof siteData.page_on_front ) &&\n\t\t\t!! +siteData.page_on_front // We also need to check if it's not zero(`0`).\n\t\t\t\t? siteData.page_on_front.toString()\n\t\t\t\t: null;\n\t\tconst _postsPageId =\n\t\t\tsiteData?.show_on_front === 'page' &&\n\t\t\t[ 'number', 'string' ].includes( typeof siteData.page_for_posts )\n\t\t\t\t? siteData.page_for_posts.toString()\n\t\t\t\t: null;\n\t\tlet _frontPageTemplateId;\n\t\tif ( templates ) {\n\t\t\tconst frontPageTemplate = templates.find(\n\t\t\t\t( t ) => t.slug === 'front-page'\n\t\t\t);\n\t\t\t_frontPageTemplateId = frontPageTemplate\n\t\t\t\t? frontPageTemplate.id\n\t\t\t\t: false;\n\t\t}\n\t\treturn {\n\t\t\thasLoadedAllDependencies: !! base && !! siteData,\n\t\t\thomepageId: _homepageId,\n\t\t\tpostsPageId: _postsPageId,\n\t\t\turl: base?.home,\n\t\t\tfrontPageTemplateId: _frontPageTemplateId,\n\t\t};\n\t}, [] );\n\n\t/**\n\t * This is a hook that recreates the logic to resolve a template for a given WordPress postID postTypeId\n\t * in order to match the frontend as closely as possible in the site editor.\n\t *\n\t * It is not possible to rely on the server logic because there maybe unsaved changes that impact the template resolution.\n\t */\n\tconst resolvedTemplateId = useSelect(\n\t\t( select ) => {\n\t\t\t// If we're rendering a post type that doesn't have a template\n\t\t\t// no need to resolve its template.\n\t\t\tif (\n\t\t\t\tpostTypesWithoutParentTemplate.includes( postType ) &&\n\t\t\t\tpostId\n\t\t\t) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// Don't trigger resolution for multi-selected posts.\n\t\t\tif ( postId && postId.includes( ',' ) ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t\tgetEntityRecords,\n\t\t\t\tgetDefaultTemplateId,\n\t\t\t\t__experimentalGetTemplateForLink,\n\t\t\t} = select( coreDataStore );\n\n\t\t\tfunction resolveTemplateForPostTypeAndId(\n\t\t\t\tpostTypeToResolve,\n\t\t\t\tpostIdToResolve\n\t\t\t) {\n\t\t\t\t// For the front page, we always use the front page template if existing.\n\t\t\t\tif (\n\t\t\t\t\tpostTypeToResolve === 'page' &&\n\t\t\t\t\thomepageId === postIdToResolve\n\t\t\t\t) {\n\t\t\t\t\t// We're still checking whether the front page template exists.\n\t\t\t\t\t// Don't resolve the template yet.\n\t\t\t\t\tif ( frontPageTemplateId === undefined ) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( !! frontPageTemplateId ) {\n\t\t\t\t\t\treturn frontPageTemplateId;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst editedEntity = getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostTypeToResolve,\n\t\t\t\t\tpostIdToResolve\n\t\t\t\t);\n\t\t\t\tif ( ! editedEntity ) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\t// Check if the current page is the posts page.\n\t\t\t\tif (\n\t\t\t\t\tpostTypeToResolve === 'page' &&\n\t\t\t\t\tpostsPageId === postIdToResolve\n\t\t\t\t) {\n\t\t\t\t\treturn __experimentalGetTemplateForLink( editedEntity.link )\n\t\t\t\t\t\t?.id;\n\t\t\t\t}\n\t\t\t\t// First see if the post/page has an assigned template and fetch it.\n\t\t\t\tconst currentTemplateSlug = editedEntity.template;\n\t\t\t\tif ( currentTemplateSlug ) {\n\t\t\t\t\tconst currentTemplate = getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t\t}\n\t\t\t\t\t)?.find( ( { slug } ) => slug === currentTemplateSlug );\n\t\t\t\t\tif ( currentTemplate ) {\n\t\t\t\t\t\treturn currentTemplate.id;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// If no template is assigned, use the default template.\n\t\t\t\tlet slugToCheck;\n\t\t\t\t// In `draft` status we might not have a slug available, so we use the `single`\n\t\t\t\t// post type templates slug(ex page, single-post, single-product etc..).\n\t\t\t\t// Pages do not need the `single` prefix in the slug to be prioritized\n\t\t\t\t// through template hierarchy.\n\t\t\t\tif ( editedEntity.slug ) {\n\t\t\t\t\tslugToCheck =\n\t\t\t\t\t\tpostTypeToResolve === 'page'\n\t\t\t\t\t\t\t? `${ postTypeToResolve }-${ editedEntity.slug }`\n\t\t\t\t\t\t\t: `single-${ postTypeToResolve }-${ editedEntity.slug }`;\n\t\t\t\t} else {\n\t\t\t\t\tslugToCheck =\n\t\t\t\t\t\tpostTypeToResolve === 'page'\n\t\t\t\t\t\t\t? 'page'\n\t\t\t\t\t\t\t: `single-${ postTypeToResolve }`;\n\t\t\t\t}\n\t\t\t\treturn getDefaultTemplateId( {\n\t\t\t\t\tslug: slugToCheck,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( ! hasLoadedAllDependencies ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// If we're rendering a specific page, we need to resolve its template.\n\t\t\t// The site editor only supports pages for now, not other CPTs.\n\t\t\tif (\n\t\t\t\tpostType &&\n\t\t\t\tpostId &&\n\t\t\t\tauthorizedPostTypes.includes( postType )\n\t\t\t) {\n\t\t\t\treturn resolveTemplateForPostTypeAndId( postType, postId );\n\t\t\t}\n\n\t\t\t// If we're rendering the home page, and we have a static home page, resolve its template.\n\t\t\tif ( homepageId ) {\n\t\t\t\treturn resolveTemplateForPostTypeAndId( 'page', homepageId );\n\t\t\t}\n\n\t\t\t// If we're not rendering a specific page, use the front page template.\n\t\t\tif ( url ) {\n\t\t\t\tconst template = __experimentalGetTemplateForLink( url );\n\t\t\t\treturn template?.id;\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\thomepageId,\n\t\t\tpostsPageId,\n\t\t\thasLoadedAllDependencies,\n\t\t\turl,\n\t\t\tpostId,\n\t\t\tpostType,\n\t\t\tfrontPageTemplateId,\n\t\t]\n\t);\n\n\tconst context = useMemo( () => {\n\t\tif ( postTypesWithoutParentTemplate.includes( postType ) && postId ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tif ( postType && postId && authorizedPostTypes.includes( postType ) ) {\n\t\t\treturn { postType, postId };\n\t\t}\n\t\t// TODO: for post types lists we should probably not render the front page, but maybe a placeholder\n\t\t// with a message like \"Select a page\" or something similar.\n\t\tif ( homepageId ) {\n\t\t\treturn { postType: 'page', postId: homepageId };\n\t\t}\n\n\t\treturn {};\n\t}, [ homepageId, postType, postId ] );\n\n\tif ( postTypesWithoutParentTemplate.includes( postType ) && postId ) {\n\t\treturn { isReady: true, postType, postId, context };\n\t}\n\n\tif ( hasLoadedAllDependencies ) {\n\t\treturn {\n\t\t\tisReady: resolvedTemplateId !== undefined,\n\t\t\tpostType: TEMPLATE_POST_TYPE,\n\t\t\tpostId: resolvedTemplateId,\n\t\t\tcontext,\n\t\t};\n\t}\n\n\treturn { isReady: false };\n}\n\nexport default function useInitEditedEntityFromURL() {\n\tconst { params = {} } = useLocation();\n\tconst { postType, postId, context, isReady } =\n\t\tuseResolveEditedEntityAndContext( params );\n\n\tconst { setEditedEntity } = useDispatch( editSiteStore );\n\tconst { resetZoomLevel } = unlock( useDispatch( blockEditorStore ) );\n\n\tuseEffect( () => {\n\t\tif ( isReady ) {\n\t\t\tresetZoomLevel();\n\t\t\tsetEditedEntity( postType, postId, context );\n\t\t}\n\t}, [\n\t\tisReady,\n\t\tpostType,\n\t\tpostId,\n\t\tcontext,\n\t\tsetEditedEntity,\n\t\tresetZoomLevel,\n\t] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AAdA;AACA;AACA;;AAOA;AACA;AACA;;AAUA,MAAM;EAAEQ;AAAY,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAEnD,MAAMC,8BAA8B,GAAG,CACtCC,6BAAkB,EAClBC,kCAAuB,EACvBC,+BAAoB,EACpBC,wBAAa,CAACC,IAAI,CAClB;AAED,MAAMC,mBAAmB,GAAG,CAAE,MAAM,EAAE,MAAM,CAAE;AAE9C,SAASC,gCAA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;EAAe,CAAC,GAAG,IAAA9D,kBAAM,EAAE,IAAA4D,iBAAW,EAAEG,kBAAiB,CAAE,CAAC;EAEpE,IAAAC,kBAAS,EAAE,MAAM;IAChB,IAAKR,OAAO,EAAG;MACdM,cAAc,CAAC,CAAC;MAChBH,eAAe,CAAEhD,QAAQ,EAAED,MAAM,EAAE4C,OAAQ,CAAC;IAC7C;EACD,CAAC,EAAE,CACFE,OAAO,EACP7C,QAAQ,EACRD,MAAM,EACN4C,OAAO,EACPK,eAAe,EACfG,cAAc,CACb,CAAC;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_coreData","_router","_blockEditor","_store","_lockUnlock","_constants","useLocation","unlock","routerPrivateApis","postTypesWithoutParentTemplate","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","NAVIGATION_POST_TYPE","PATTERN_TYPES","user","authorizedPostTypes","useResolveEditedEntityAndContext","postId","postType","hasLoadedAllDependencies","homepageId","postsPageId","useSelect","select","getEntityRecord","coreDataStore","siteData","_homepageId","show_on_front","includes","page_on_front","toString","_postsPageId","page_for_posts","resolvedTemplateId","undefined","getEditedEntityRecord","getEntityRecords","getDefaultTemplateId","resolveTemplateForPostTypeAndId","postTypeToResolve","postIdToResolve","templates","per_page","id","find","slug","editedEntity","currentTemplateSlug","template","currentTemplate","slugToCheck","context","useMemo","isReady","useInitEditedEntityFromURL","params","setEditedEntity","useDispatch","editSiteStore","resetZoomLevel","blockEditorStore","useEffect"],"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES,\n} from '../../utils/constants';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nconst postTypesWithoutParentTemplate = [\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES.user,\n];\n\nconst authorizedPostTypes = [ 'page', 'post' ];\n\nfunction useResolveEditedEntityAndContext( { postId, postType } ) {\n\tconst { hasLoadedAllDependencies, homepageId, postsPageId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreDataStore );\n\t\t\tconst siteData = getEntityRecord( 'root', 'site' );\n\t\t\tconst _homepageId =\n\t\t\t\tsiteData?.show_on_front === 'page' &&\n\t\t\t\t[ 'number', 'string' ].includes(\n\t\t\t\t\ttypeof siteData.page_on_front\n\t\t\t\t) &&\n\t\t\t\t!! +siteData.page_on_front // We also need to check if it's not zero(`0`).\n\t\t\t\t\t? siteData.page_on_front.toString()\n\t\t\t\t\t: null;\n\t\t\tconst _postsPageId =\n\t\t\t\tsiteData?.show_on_front === 'page' &&\n\t\t\t\t[ 'number', 'string' ].includes(\n\t\t\t\t\ttypeof siteData.page_for_posts\n\t\t\t\t)\n\t\t\t\t\t? siteData.page_for_posts.toString()\n\t\t\t\t\t: null;\n\t\t\treturn {\n\t\t\t\thasLoadedAllDependencies: !! siteData,\n\t\t\t\thomepageId: _homepageId,\n\t\t\t\tpostsPageId: _postsPageId,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\t/**\n\t * This is a hook that recreates the logic to resolve a template for a given WordPress postID postTypeId\n\t * in order to match the frontend as closely as possible in the site editor.\n\t *\n\t * It is not possible to rely on the server logic because there maybe unsaved changes that impact the template resolution.\n\t */\n\tconst resolvedTemplateId = useSelect(\n\t\t( select ) => {\n\t\t\t// If we're rendering a post type that doesn't have a template\n\t\t\t// no need to resolve its template.\n\t\t\tif (\n\t\t\t\tpostTypesWithoutParentTemplate.includes( postType ) &&\n\t\t\t\tpostId\n\t\t\t) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// Don't trigger resolution for multi-selected posts.\n\t\t\tif ( postId && postId.includes( ',' ) ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t\tgetEntityRecords,\n\t\t\t\tgetDefaultTemplateId,\n\t\t\t} = select( coreDataStore );\n\n\t\t\tfunction resolveTemplateForPostTypeAndId(\n\t\t\t\tpostTypeToResolve,\n\t\t\t\tpostIdToResolve\n\t\t\t) {\n\t\t\t\t// For the front page, we always use the front page template if existing.\n\t\t\t\tif (\n\t\t\t\t\tpostTypeToResolve === 'page' &&\n\t\t\t\t\thomepageId === postIdToResolve\n\t\t\t\t) {\n\t\t\t\t\t// The /lookup endpoint cannot currently handle a lookup\n\t\t\t\t\t// when a page is set as the front page, so specifically in\n\t\t\t\t\t// that case, we want to check if there is a front page\n\t\t\t\t\t// template, and instead of falling back to the home\n\t\t\t\t\t// template, we want to fall back to the page template.\n\t\t\t\t\tconst templates = getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tif ( templates ) {\n\t\t\t\t\t\tconst id = templates?.find(\n\t\t\t\t\t\t\t( { slug } ) => slug === 'front-page'\n\t\t\t\t\t\t)?.id;\n\t\t\t\t\t\tif ( id ) {\n\t\t\t\t\t\t\treturn id;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// If no front page template is found, continue with the\n\t\t\t\t\t\t// logic below (fetching the page template).\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Still resolving `templates`.\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst editedEntity = getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostTypeToResolve,\n\t\t\t\t\tpostIdToResolve\n\t\t\t\t);\n\t\t\t\tif ( ! editedEntity ) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\t// Check if the current page is the posts page.\n\t\t\t\tif (\n\t\t\t\t\tpostTypeToResolve === 'page' &&\n\t\t\t\t\tpostsPageId === postIdToResolve\n\t\t\t\t) {\n\t\t\t\t\treturn getDefaultTemplateId( { slug: 'home' } );\n\t\t\t\t}\n\t\t\t\t// First see if the post/page has an assigned template and fetch it.\n\t\t\t\tconst currentTemplateSlug = editedEntity.template;\n\t\t\t\tif ( currentTemplateSlug ) {\n\t\t\t\t\tconst currentTemplate = getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t\t}\n\t\t\t\t\t)?.find( ( { slug } ) => slug === currentTemplateSlug );\n\t\t\t\t\tif ( currentTemplate ) {\n\t\t\t\t\t\treturn currentTemplate.id;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// If no template is assigned, use the default template.\n\t\t\t\tlet slugToCheck;\n\t\t\t\t// In `draft` status we might not have a slug available, so we use the `single`\n\t\t\t\t// post type templates slug(ex page, single-post, single-product etc..).\n\t\t\t\t// Pages do not need the `single` prefix in the slug to be prioritized\n\t\t\t\t// through template hierarchy.\n\t\t\t\tif ( editedEntity.slug ) {\n\t\t\t\t\tslugToCheck =\n\t\t\t\t\t\tpostTypeToResolve === 'page'\n\t\t\t\t\t\t\t? `${ postTypeToResolve }-${ editedEntity.slug }`\n\t\t\t\t\t\t\t: `single-${ postTypeToResolve }-${ editedEntity.slug }`;\n\t\t\t\t} else {\n\t\t\t\t\tslugToCheck =\n\t\t\t\t\t\tpostTypeToResolve === 'page'\n\t\t\t\t\t\t\t? 'page'\n\t\t\t\t\t\t\t: `single-${ postTypeToResolve }`;\n\t\t\t\t}\n\t\t\t\treturn getDefaultTemplateId( {\n\t\t\t\t\tslug: slugToCheck,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( ! hasLoadedAllDependencies ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// If we're rendering a specific page, we need to resolve its template.\n\t\t\t// The site editor only supports pages for now, not other CPTs.\n\t\t\tif (\n\t\t\t\tpostType &&\n\t\t\t\tpostId &&\n\t\t\t\tauthorizedPostTypes.includes( postType )\n\t\t\t) {\n\t\t\t\treturn resolveTemplateForPostTypeAndId( postType, postId );\n\t\t\t}\n\n\t\t\t// If we're rendering the home page, and we have a static home page, resolve its template.\n\t\t\tif ( homepageId ) {\n\t\t\t\treturn resolveTemplateForPostTypeAndId( 'page', homepageId );\n\t\t\t}\n\n\t\t\t// If we're not rendering a specific page, use the front page template.\n\t\t\treturn getDefaultTemplateId( { slug: 'front-page' } );\n\t\t},\n\t\t[ homepageId, postsPageId, hasLoadedAllDependencies, postId, postType ]\n\t);\n\n\tconst context = useMemo( () => {\n\t\tif ( postTypesWithoutParentTemplate.includes( postType ) && postId ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tif ( postType && postId && authorizedPostTypes.includes( postType ) ) {\n\t\t\treturn { postType, postId };\n\t\t}\n\t\t// TODO: for post types lists we should probably not render the front page, but maybe a placeholder\n\t\t// with a message like \"Select a page\" or something similar.\n\t\tif ( homepageId ) {\n\t\t\treturn { postType: 'page', postId: homepageId };\n\t\t}\n\n\t\treturn {};\n\t}, [ homepageId, postType, postId ] );\n\n\tif ( postTypesWithoutParentTemplate.includes( postType ) && postId ) {\n\t\treturn { isReady: true, postType, postId, context };\n\t}\n\n\tif ( hasLoadedAllDependencies ) {\n\t\treturn {\n\t\t\tisReady: resolvedTemplateId !== undefined,\n\t\t\tpostType: TEMPLATE_POST_TYPE,\n\t\t\tpostId: resolvedTemplateId,\n\t\t\tcontext,\n\t\t};\n\t}\n\n\treturn { isReady: false };\n}\n\nexport default function useInitEditedEntityFromURL() {\n\tconst { params = {} } = useLocation();\n\tconst { postType, postId, context, isReady } =\n\t\tuseResolveEditedEntityAndContext( params );\n\n\tconst { setEditedEntity } = useDispatch( editSiteStore );\n\tconst { resetZoomLevel } = unlock( useDispatch( blockEditorStore ) );\n\n\tuseEffect( () => {\n\t\tif ( isReady ) {\n\t\t\tresetZoomLevel();\n\t\t\tsetEditedEntity( postType, postId, context );\n\t\t}\n\t}, [\n\t\tisReady,\n\t\tpostType,\n\t\tpostId,\n\t\tcontext,\n\t\tsetEditedEntity,\n\t\tresetZoomLevel,\n\t] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AAdA;AACA;AACA;;AAOA;AACA;AACA;;AAUA,MAAM;EAAEQ;AAAY,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAEnD,MAAMC,8BAA8B,GAAG,CACtCC,6BAAkB,EAClBC,kCAAuB,EACvBC,+BAAoB,EACpBC,wBAAa,CAACC,IAAI,CAClB;AAED,MAAMC,mBAAmB,GAAG,CAAE,MAAM,EAAE,MAAM,CAAE;AAE9C,SAASC,gCAAgCA,CAAE;EAAEC,MAAM;EAAEC;AAAS,CAAC,EAAG;EACjE,MAAM;IAAEC,wBAAwB;IAAEC,UAAU;IAAEC;EAAY,CAAC,GAAG,IAAAC,eAAS,EACpEC,MAAM,IAAM;IACb,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAEE,eAAc,CAAC;IACnD,MAAMC,QA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pC,QAAQ;MAAED,MAAM;MAAEmC;IAAQ,CAAC;EACpD;EAEA,IAAKjC,wBAAwB,EAAG;IAC/B,OAAO;MACNmC,OAAO,EAAEpB,kBAAkB,KAAKC,SAAS;MACzCjB,QAAQ,EAAER,6BAAkB;MAC5BO,MAAM,EAAEiB,kBAAkB;MAC1BkB;IACD,CAAC;EACF;EAEA,OAAO;IAAEE,OAAO,EAAE;EAAM,CAAC;AAC1B;AAEe,SAASC,0BAA0BA,CAAA,EAAG;EACpD,MAAM;IAAEC,MAAM,GAAG,CAAC;EAAE,CAAC,GAAGlD,WAAW,CAAC,CAAC;EACrC,MAAM;IAAEY,QAAQ;IAAED,MAAM;IAAEmC,OAAO;IAAEE;EAAQ,CAAC,GAC3CtC,gCAAgC,CAAEwC,MAAO,CAAC;EAE3C,MAAM;IAAEC;EAAgB,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAc,CAAC;EACxD,MAAM;IAAEC;EAAe,CAAC,GAAG,IAAArD,kBAAM,EAAE,IAAAmD,iBAAW,EAAEG,kBAAiB,CAAE,CAAC;EAEpE,IAAAC,kBAAS,EAAE,MAAM;IAChB,IAAKR,OAAO,EAAG;MACdM,cAAc,CAAC,CAAC;MAChBH,eAAe,CAAEvC,QAAQ,EAAED,MAAM,EAAEmC,OAAQ,CAAC;IAC7C;EACD,CAAC,EAAE,CACFE,OAAO,EACPpC,QAAQ,EACRD,MAAM,EACNmC,OAAO,EACPK,eAAe,EACfG,cAAc,CACb,CAAC;AACJ","ignoreList":[]}
|
|
@@ -14,9 +14,11 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
function WelcomeGuide(
|
|
17
|
+
function WelcomeGuide({
|
|
18
|
+
postType
|
|
19
|
+
}) {
|
|
18
20
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
19
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_editor.default, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.default, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_page.default, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_template.default, {})]
|
|
21
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_editor.default, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.default, {}), postType === 'page' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_page.default, {}), postType === 'wp_template' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_template.default, {})]
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_editor","_interopRequireDefault","require","_styles","_page","_template","_jsxRuntime","WelcomeGuide","jsxs","Fragment","children","jsx","default"],"sources":["@wordpress/edit-site/src/components/welcome-guide/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport WelcomeGuideEditor from './editor';\nimport WelcomeGuideStyles from './styles';\nimport WelcomeGuidePage from './page';\nimport WelcomeGuideTemplate from './template';\n\nexport default function WelcomeGuide() {\n\treturn (\n\t\t<>\n\t\t\t<WelcomeGuideEditor />\n\t\t\t<WelcomeGuideStyles />\n\t\t\t<WelcomeGuidePage
|
|
1
|
+
{"version":3,"names":["_editor","_interopRequireDefault","require","_styles","_page","_template","_jsxRuntime","WelcomeGuide","postType","jsxs","Fragment","children","jsx","default"],"sources":["@wordpress/edit-site/src/components/welcome-guide/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport WelcomeGuideEditor from './editor';\nimport WelcomeGuideStyles from './styles';\nimport WelcomeGuidePage from './page';\nimport WelcomeGuideTemplate from './template';\n\nexport default function WelcomeGuide( { postType } ) {\n\treturn (\n\t\t<>\n\t\t\t<WelcomeGuideEditor />\n\t\t\t<WelcomeGuideStyles />\n\t\t\t{ postType === 'page' && <WelcomeGuidePage /> }\n\t\t\t{ postType === 'wp_template' && <WelcomeGuideTemplate /> }\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,SAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAA8C,IAAAI,WAAA,GAAAJ,OAAA;AAN9C;AACA;AACA;;AAMe,SAASK,YAAYA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACpD,oBACC,IAAAF,WAAA,CAAAG,IAAA,EAAAH,WAAA,CAAAI,QAAA;IAAAC,QAAA,gBACC,IAAAL,WAAA,CAAAM,GAAA,EAACZ,OAAA,CAAAa,OAAkB,IAAE,CAAC,eACtB,IAAAP,WAAA,CAAAM,GAAA,EAACT,OAAA,CAAAU,OAAkB,IAAE,CAAC,EACpBL,QAAQ,KAAK,MAAM,iBAAI,IAAAF,WAAA,CAAAM,GAAA,EAACR,KAAA,CAAAS,OAAgB,IAAE,CAAC,EAC3CL,QAAQ,KAAK,aAAa,iBAAI,IAAAF,WAAA,CAAAM,GAAA,EAACP,SAAA,CAAAQ,OAAoB,IAAE,CAAC;EAAA,CACvD,CAAC;AAEL","ignoreList":[]}
|
|
@@ -8,16 +8,11 @@ var _data = require("@wordpress/data");
|
|
|
8
8
|
var _components = require("@wordpress/components");
|
|
9
9
|
var _i18n = require("@wordpress/i18n");
|
|
10
10
|
var _preferences = require("@wordpress/preferences");
|
|
11
|
-
var _store = require("../../store");
|
|
12
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
12
|
/**
|
|
14
13
|
* WordPress dependencies
|
|
15
14
|
*/
|
|
16
15
|
|
|
17
|
-
/**
|
|
18
|
-
* Internal dependencies
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
16
|
function WelcomeGuidePage() {
|
|
22
17
|
const {
|
|
23
18
|
toggle
|
|
@@ -25,10 +20,7 @@ function WelcomeGuidePage() {
|
|
|
25
20
|
const isVisible = (0, _data.useSelect)(select => {
|
|
26
21
|
const isPageActive = !!select(_preferences.store).get('core/edit-site', 'welcomeGuidePage');
|
|
27
22
|
const isEditorActive = !!select(_preferences.store).get('core/edit-site', 'welcomeGuide');
|
|
28
|
-
|
|
29
|
-
isPage
|
|
30
|
-
} = select(_store.store);
|
|
31
|
-
return isPageActive && !isEditorActive && isPage();
|
|
23
|
+
return isPageActive && !isEditorActive;
|
|
32
24
|
}, []);
|
|
33
25
|
if (!isVisible) {
|
|
34
26
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_components","_i18n","_preferences","
|
|
1
|
+
{"version":3,"names":["_data","require","_components","_i18n","_preferences","_jsxRuntime","WelcomeGuidePage","toggle","useDispatch","preferencesStore","isVisible","useSelect","select","isPageActive","get","isEditorActive","heading","__","jsx","Guide","className","contentLabel","finishButtonText","onFinish","pages","image","autoPlay","loop","muted","width","height","children","src","type","content","jsxs","Fragment"],"sources":["@wordpress/edit-site/src/components/welcome-guide/page.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { Guide } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\nexport default function WelcomeGuidePage() {\n\tconst { toggle } = useDispatch( preferencesStore );\n\n\tconst isVisible = useSelect( ( select ) => {\n\t\tconst isPageActive = !! select( preferencesStore ).get(\n\t\t\t'core/edit-site',\n\t\t\t'welcomeGuidePage'\n\t\t);\n\t\tconst isEditorActive = !! select( preferencesStore ).get(\n\t\t\t'core/edit-site',\n\t\t\t'welcomeGuide'\n\t\t);\n\t\treturn isPageActive && ! isEditorActive;\n\t}, [] );\n\n\tif ( ! isVisible ) {\n\t\treturn null;\n\t}\n\n\tconst heading = __( 'Editing a page' );\n\n\treturn (\n\t\t<Guide\n\t\t\tclassName=\"edit-site-welcome-guide guide-page\"\n\t\t\tcontentLabel={ heading }\n\t\t\tfinishButtonText={ __( 'Continue' ) }\n\t\t\tonFinish={ () => toggle( 'core/edit-site', 'welcomeGuidePage' ) }\n\t\t\tpages={ [\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<video\n\t\t\t\t\t\t\tclassName=\"edit-site-welcome-guide__video\"\n\t\t\t\t\t\t\tautoPlay\n\t\t\t\t\t\t\tloop\n\t\t\t\t\t\t\tmuted\n\t\t\t\t\t\t\twidth=\"312\"\n\t\t\t\t\t\t\theight=\"240\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<source\n\t\t\t\t\t\t\t\tsrc=\"https://s.w.org/images/block-editor/editing-your-page.mp4\"\n\t\t\t\t\t\t\t\ttype=\"video/mp4\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</video>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-site-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ heading }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-site-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'It’s now possible to edit page content in the site editor. To customise other parts of the page like the header and footer switch to editing the template using the settings sidebar.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t] }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAAmE,IAAAI,WAAA,GAAAJ,OAAA;AANnE;AACA;AACA;;AAMe,SAASK,gBAAgBA,CAAA,EAAG;EAC1C,MAAM;IAAEC;EAAO,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7Cf;QAAO,CACN,CAAC,eACL,IAAAX,WAAA,CAAAa,GAAA;UAAGE,SAAS,EAAC,+BAA+B;UAAAW,QAAA,EACzC,IAAAd,QAAE,EACH,uLACD;QAAC,CACC,CAAC;MAAA,CACH;IAEJ,CAAC;EACC,CACH,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -10,25 +9,15 @@ var _components = require("@wordpress/components");
|
|
|
10
9
|
var _i18n = require("@wordpress/i18n");
|
|
11
10
|
var _preferences = require("@wordpress/preferences");
|
|
12
11
|
var _editor = require("@wordpress/editor");
|
|
13
|
-
var _useEditedEntityRecord = _interopRequireDefault(require("../use-edited-entity-record"));
|
|
14
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
13
|
/**
|
|
16
14
|
* WordPress dependencies
|
|
17
15
|
*/
|
|
18
16
|
|
|
19
|
-
/**
|
|
20
|
-
* Internal dependencies
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
17
|
function WelcomeGuideTemplate() {
|
|
24
18
|
const {
|
|
25
19
|
toggle
|
|
26
20
|
} = (0, _data.useDispatch)(_preferences.store);
|
|
27
|
-
const {
|
|
28
|
-
isLoaded,
|
|
29
|
-
record
|
|
30
|
-
} = (0, _useEditedEntityRecord.default)();
|
|
31
|
-
const isPostTypeTemplate = isLoaded && record.type === 'wp_template';
|
|
32
21
|
const {
|
|
33
22
|
isActive,
|
|
34
23
|
hasPreviousEntity
|
|
@@ -44,7 +33,7 @@ function WelcomeGuideTemplate() {
|
|
|
44
33
|
hasPreviousEntity: !!getEditorSettings().onNavigateToPreviousEntityRecord
|
|
45
34
|
};
|
|
46
35
|
}, []);
|
|
47
|
-
const isVisible = isActive &&
|
|
36
|
+
const isVisible = isActive && hasPreviousEntity;
|
|
48
37
|
if (!isVisible) {
|
|
49
38
|
return null;
|
|
50
39
|
}
|