@wordpress/edit-post 8.9.0 → 8.11.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/init-pattern-modal/index.js +1 -1
  3. package/build/components/init-pattern-modal/index.js.map +1 -1
  4. package/build/components/keyboard-shortcuts/index.js +1 -1
  5. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  6. package/build/components/layout/index.js +176 -171
  7. package/build/components/layout/index.js.map +1 -1
  8. package/build/components/layout/use-padding-appender.js +19 -16
  9. package/build/components/layout/use-padding-appender.js.map +1 -1
  10. package/build/components/layout/use-should-iframe.js +16 -8
  11. package/build/components/layout/use-should-iframe.js.map +1 -1
  12. package/build/components/meta-boxes/meta-box-visibility.js.map +1 -1
  13. package/build/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
  14. package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
  15. package/build/deprecated.js.map +1 -1
  16. package/build/index.js +2 -4
  17. package/build/index.js.map +1 -1
  18. package/build/store/actions.js +1 -1
  19. package/build/store/actions.js.map +1 -1
  20. package/build/store/private-selectors.js.map +1 -1
  21. package/build/store/selectors.js.map +1 -1
  22. package/build/utils/meta-boxes.js.map +1 -1
  23. package/build-module/components/header/header-toolbar/index.native.js +1 -2
  24. package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
  25. package/build-module/components/init-pattern-modal/index.js +2 -4
  26. package/build-module/components/init-pattern-modal/index.js.map +1 -1
  27. package/build-module/components/keyboard-shortcuts/index.js +1 -1
  28. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  29. package/build-module/components/layout/index.js +178 -175
  30. package/build-module/components/layout/index.js.map +1 -1
  31. package/build-module/components/layout/index.native.js +1 -3
  32. package/build-module/components/layout/index.native.js.map +1 -1
  33. package/build-module/components/layout/use-padding-appender.js +20 -16
  34. package/build-module/components/layout/use-padding-appender.js.map +1 -1
  35. package/build-module/components/layout/use-should-iframe.js +16 -8
  36. package/build-module/components/layout/use-should-iframe.js.map +1 -1
  37. package/build-module/components/meta-boxes/index.js +1 -3
  38. package/build-module/components/meta-boxes/index.js.map +1 -1
  39. package/build-module/components/meta-boxes/meta-box-visibility.js.map +1 -1
  40. package/build-module/components/meta-boxes/meta-boxes-area/index.js +1 -2
  41. package/build-module/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
  42. package/build-module/components/more-menu/index.js +1 -3
  43. package/build-module/components/more-menu/index.js.map +1 -1
  44. package/build-module/components/preferences-modal/enable-custom-fields.js +1 -3
  45. package/build-module/components/preferences-modal/enable-custom-fields.js.map +1 -1
  46. package/build-module/components/preferences-modal/meta-boxes-section.js +1 -2
  47. package/build-module/components/preferences-modal/meta-boxes-section.js.map +1 -1
  48. package/build-module/components/welcome-guide/default.js +1 -3
  49. package/build-module/components/welcome-guide/default.js.map +1 -1
  50. package/build-module/components/welcome-guide/image.js +1 -2
  51. package/build-module/components/welcome-guide/image.js.map +1 -1
  52. package/build-module/components/welcome-guide/template.js +1 -3
  53. package/build-module/components/welcome-guide/template.js.map +1 -1
  54. package/build-module/deprecated.js.map +1 -1
  55. package/build-module/index.js +2 -4
  56. package/build-module/index.js.map +1 -1
  57. package/build-module/store/actions.js +1 -1
  58. package/build-module/store/actions.js.map +1 -1
  59. package/build-module/store/private-selectors.js.map +1 -1
  60. package/build-module/store/selectors.js.map +1 -1
  61. package/build-module/utils/meta-boxes.js.map +1 -1
  62. package/build-style/style-rtl.css +65 -29
  63. package/build-style/style.css +65 -29
  64. package/package.json +33 -32
  65. package/src/components/init-pattern-modal/index.js +2 -2
  66. package/src/components/keyboard-shortcuts/index.js +1 -1
  67. package/src/components/layout/index.js +170 -174
  68. package/src/components/layout/style.scss +83 -43
  69. package/src/components/layout/use-padding-appender.js +21 -18
  70. package/src/components/layout/use-should-iframe.js +18 -7
  71. package/src/index.js +0 -2
  72. package/src/store/actions.js +1 -1
@@ -12,6 +12,7 @@ import { privateApis as blockEditorPrivateApis, store as blockEditorStore } from
12
12
  import { PluginArea } from '@wordpress/plugins';
13
13
  import { __, sprintf } from '@wordpress/i18n';
14
14
  import { useCallback, useMemo, useId, useRef, useState } from '@wordpress/element';
15
+ import { chevronDown, chevronUp } from '@wordpress/icons';
15
16
  import { store as noticesStore } from '@wordpress/notices';
16
17
  import { store as preferencesStore } from '@wordpress/preferences';
17
18
  import { CommandMenu, privateApis as commandsPrivateApis } from '@wordpress/commands';
@@ -20,7 +21,7 @@ import { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library
20
21
  import { addQueryArgs } from '@wordpress/url';
21
22
  import { decodeEntities } from '@wordpress/html-entities';
22
23
  import { store as coreStore } from '@wordpress/core-data';
23
- import { ResizableBox, SlotFillProvider, Tooltip, VisuallyHidden } from '@wordpress/components';
24
+ import { Icon, ResizableBox, SlotFillProvider, Tooltip, VisuallyHidden, __unstableUseNavigateRegions as useNavigateRegions } from '@wordpress/components';
24
25
  import { useMediaQuery, useRefEffect, useViewportMatch } from '@wordpress/compose';
25
26
 
26
27
  /**
@@ -40,9 +41,7 @@ import useEditPostCommands from '../../commands/use-commands';
40
41
  import { usePaddingAppender } from './use-padding-appender';
41
42
  import { useShouldIframe } from './use-should-iframe';
42
43
  import useNavigateToEntityRecord from '../../hooks/use-navigate-to-entity-record';
43
- import { jsx as _jsx } from "react/jsx-runtime";
44
- import { jsxs as _jsxs } from "react/jsx-runtime";
45
- import { Fragment as _Fragment } from "react/jsx-runtime";
44
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
46
45
  const {
47
46
  getLayoutStyles
48
47
  } = unlock(blockEditorPrivateApis);
@@ -54,36 +53,24 @@ const {
54
53
  } = unlock(commandsPrivateApis);
55
54
  const {
56
55
  Editor,
57
- FullscreenMode
56
+ FullscreenMode,
57
+ NavigableRegion
58
58
  } = unlock(editorPrivateApis);
59
59
  const {
60
60
  BlockKeyboardShortcuts
61
61
  } = unlock(blockLibraryPrivateApis);
62
62
  const DESIGN_POST_TYPES = ['wp_template', 'wp_template_part', 'wp_block', 'wp_navigation'];
63
- function useEditorStyles() {
63
+ function useEditorStyles(...additionalStyles) {
64
64
  const {
65
65
  hasThemeStyleSupport,
66
- editorSettings,
67
- isZoomedOutView,
68
- renderingMode,
69
- postType
66
+ editorSettings
70
67
  } = useSelect(select => {
71
- const {
72
- __unstableGetEditorMode
73
- } = select(blockEditorStore);
74
- const {
75
- getCurrentPostType,
76
- getRenderingMode
77
- } = select(editorStore);
78
- const _postType = getCurrentPostType();
79
68
  return {
80
69
  hasThemeStyleSupport: select(editPostStore).isFeatureActive('themeStyles'),
81
- editorSettings: select(editorStore).getEditorSettings(),
82
- isZoomedOutView: __unstableGetEditorMode() === 'zoom-out',
83
- renderingMode: getRenderingMode(),
84
- postType: _postType
70
+ editorSettings: select(editorStore).getEditorSettings()
85
71
  };
86
72
  }, []);
73
+ const addedStyles = additionalStyles.join('\n');
87
74
 
88
75
  // Compute the default styles.
89
76
  return useMemo(() => {
@@ -108,16 +95,13 @@ function useEditorStyles() {
108
95
  });
109
96
  }
110
97
  const baseStyles = hasThemeStyles ? (_editorSettings$style3 = editorSettings.styles) !== null && _editorSettings$style3 !== void 0 ? _editorSettings$style3 : [] : defaultEditorStyles;
111
-
112
- // Add a space for the typewriter effect. When typing in the last block,
113
- // there needs to be room to scroll up.
114
- if (!isZoomedOutView && renderingMode === 'post-only' && !DESIGN_POST_TYPES.includes(postType)) {
98
+ if (addedStyles) {
115
99
  return [...baseStyles, {
116
- css: ':root :where(.editor-styles-wrapper)::after {content: ""; display: block; height: 40vh;}'
100
+ css: addedStyles
117
101
  }];
118
102
  }
119
103
  return baseStyles;
120
- }, [editorSettings.defaultEditorStyles, editorSettings.disableLayoutStyles, editorSettings.styles, hasThemeStyleSupport, postType]);
104
+ }, [editorSettings.defaultEditorStyles, editorSettings.disableLayoutStyles, editorSettings.styles, hasThemeStyleSupport, addedStyles]);
121
105
  }
122
106
 
123
107
  /**
@@ -139,7 +123,7 @@ function MetaBoxesMain({
139
123
  const {
140
124
  set: setPreference
141
125
  } = useDispatch(preferencesStore);
142
- const resizableBoxRef = useRef();
126
+ const metaBoxesMainRef = useRef();
143
127
  const isShort = useMediaQuery('(max-height: 549px)');
144
128
  const [{
145
129
  min,
@@ -151,8 +135,8 @@ function MetaBoxesMain({
151
135
  const effectSizeConstraints = useRefEffect(node => {
152
136
  const container = node.closest('.interface-interface-skeleton__content');
153
137
  const noticeLists = container.querySelectorAll(':scope > .components-notice-list');
154
- const resizeHandle = container.querySelector('.edit-post-meta-boxes-main__resize-handle');
155
- const actualize = () => {
138
+ const resizeHandle = container.querySelector('.edit-post-meta-boxes-main__presenter');
139
+ const deriveConstraints = () => {
156
140
  const fullHeight = container.offsetHeight;
157
141
  let nextMax = fullHeight;
158
142
  for (const element of noticeLists) {
@@ -164,7 +148,7 @@ function MetaBoxesMain({
164
148
  max: nextMax
165
149
  });
166
150
  };
167
- const observer = new window.ResizeObserver(actualize);
151
+ const observer = new window.ResizeObserver(deriveConstraints);
168
152
  observer.observe(container);
169
153
  for (const element of noticeLists) {
170
154
  observer.observe(element);
@@ -174,14 +158,32 @@ function MetaBoxesMain({
174
158
  const separatorRef = useRef();
175
159
  const separatorHelpId = useId();
176
160
  const [isUntouched, setIsUntouched] = useState(true);
161
+ const applyHeight = (candidateHeight, isPersistent, isInstant) => {
162
+ const nextHeight = Math.min(max, Math.max(min, candidateHeight));
163
+ if (isPersistent) {
164
+ setPreference('core/edit-post', 'metaBoxesMainOpenHeight', nextHeight);
165
+ } else {
166
+ separatorRef.current.ariaValueNow = getAriaValueNow(nextHeight);
167
+ }
168
+ if (isInstant) {
169
+ metaBoxesMainRef.current.updateSize({
170
+ height: nextHeight,
171
+ // Oddly, when the event that triggered this was not from the mouse (e.g. keydown),
172
+ // if `width` is left unspecified a subsequent drag gesture applies a fixed
173
+ // width and the pane fails to widen/narrow with parent width changes from
174
+ // sidebars opening/closing or window resizes.
175
+ width: 'auto'
176
+ });
177
+ }
178
+ };
177
179
  if (!hasAnyVisible) {
178
180
  return;
179
181
  }
180
- const className = 'edit-post-meta-boxes-main';
181
182
  const contents = /*#__PURE__*/_jsxs("div", {
182
183
  className: clsx(
183
184
  // The class name 'edit-post-layout__metaboxes' is retained because some plugins use it.
184
185
  'edit-post-layout__metaboxes', !isLegacy && 'edit-post-meta-boxes-main__liner'),
186
+ hidden: !isLegacy && isShort && !isOpen,
185
187
  children: [/*#__PURE__*/_jsx(MetaBoxes, {
186
188
  location: "normal"
187
189
  }), /*#__PURE__*/_jsx(MetaBoxes, {
@@ -199,20 +201,7 @@ function MetaBoxesMain({
199
201
  }
200
202
  const getAriaValueNow = height => Math.round((height - min) / (max - min) * 100);
201
203
  const usedAriaValueNow = max === undefined || isAutoHeight ? 50 : getAriaValueNow(openHeight);
202
- if (isShort) {
203
- return /*#__PURE__*/_jsxs("details", {
204
- className: className,
205
- open: isOpen,
206
- onToggle: ({
207
- target
208
- }) => {
209
- setPreference('core/edit-post', 'metaBoxesMainIsOpen', target.open);
210
- },
211
- children: [/*#__PURE__*/_jsx("summary", {
212
- children: __('Meta Boxes')
213
- }), contents]
214
- });
215
- }
204
+ const toggle = () => setPreference('core/edit-post', 'metaBoxesMainIsOpen', !isOpen);
216
205
 
217
206
  // TODO: Support more/all keyboard interactions from the window splitter pattern:
218
207
  // https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/
@@ -222,99 +211,97 @@ function MetaBoxesMain({
222
211
  ArrowDown: -20
223
212
  }[event.key];
224
213
  if (delta) {
225
- const {
226
- resizable
227
- } = resizableBoxRef.current;
228
- const fromHeight = isAutoHeight ? resizable.offsetHeight : openHeight;
229
- const nextHeight = Math.min(max, Math.max(min, delta + fromHeight));
230
- resizableBoxRef.current.updateSize({
231
- height: nextHeight,
232
- // Oddly, if left unspecified a subsequent drag gesture applies a fixed
233
- // width and the pane fails to shrink/grow with parent width changes from
234
- // sidebars opening/closing or window resizes.
235
- width: 'auto'
236
- });
237
- setPreference('core/edit-post', 'metaBoxesMainOpenHeight', nextHeight);
214
+ const pane = metaBoxesMainRef.current.resizable;
215
+ const fromHeight = isAutoHeight ? pane.offsetHeight : openHeight;
216
+ const nextHeight = delta + fromHeight;
217
+ applyHeight(nextHeight, true, true);
218
+ event.preventDefault();
238
219
  }
239
220
  };
240
- return /*#__PURE__*/_jsxs(ResizableBox, {
241
- className: className,
242
- defaultSize: {
243
- height: openHeight
244
- },
245
- ref: resizableBoxRef,
246
- enable: {
247
- top: true,
248
- right: false,
249
- bottom: false,
250
- left: false,
251
- topLeft: false,
252
- topRight: false,
253
- bottomRight: false,
254
- bottomLeft: false
255
- },
256
- minHeight: min,
257
- maxHeight: usedMax,
258
- bounds: "parent",
259
- boundsByDirection: true
260
- // Avoids hiccups while dragging over objects like iframes and ensures that
261
- // the event to end the drag is captured by the target (resize handle)
262
- // whether or not it’s under the pointer.
263
- ,
264
- onPointerDown: ({
265
- pointerId,
266
- target
267
- }) => {
268
- target.setPointerCapture(pointerId);
269
- },
270
- onResizeStart: (event, direction, elementRef) => {
271
- if (isAutoHeight) {
272
- const heightNow = elementRef.offsetHeight;
273
- // Sets the starting height to avoid visual jumps in height and
274
- // aria-valuenow being `NaN` for the first (few) resize events.
275
- resizableBoxRef.current.updateSize({
276
- height: heightNow
277
- });
278
- // Causes `maxHeight` to update to full `max` value instead of half.
279
- setIsUntouched(false);
280
- }
281
- },
282
- onResize: () => {
283
- const {
284
- height
285
- } = resizableBoxRef.current.state;
286
- const separator = separatorRef.current;
287
- separator.ariaValueNow = getAriaValueNow(height);
288
- },
289
- onResizeStop: () => {
290
- const nextHeight = resizableBoxRef.current.state.height;
291
- setPreference('core/edit-post', 'metaBoxesMainOpenHeight', nextHeight);
292
- },
293
- handleClasses: {
294
- top: 'edit-post-meta-boxes-main__resize-handle'
295
- },
296
- handleComponent: {
297
- top: /*#__PURE__*/_jsxs(_Fragment, {
298
- children: [/*#__PURE__*/_jsx(Tooltip, {
299
- text: __('Drag to resize'),
300
- children: /*#__PURE__*/_jsx("button", {
301
- ref: separatorRef,
302
- "aria-label": __('Drag to resize'),
303
- "aria-describedby": separatorHelpId,
304
- onKeyDown: onSeparatorKeyDown
305
- // Disable reason: buttons are allowed to be separator role.
306
- // eslint-disable-next-line jsx-a11y/no-interactive-element-to-noninteractive-role
307
- ,
308
- role: "separator",
309
- "aria-valuenow": usedAriaValueNow
310
- })
311
- }), /*#__PURE__*/_jsx(VisuallyHidden, {
312
- id: separatorHelpId,
313
- children: __('Use up and down arrow keys to resize the metabox panel.')
314
- })]
315
- })
316
- },
317
- children: [/*#__PURE__*/_jsx("meta", {
221
+ const className = 'edit-post-meta-boxes-main';
222
+ const paneLabel = __('Meta Boxes');
223
+ let Pane, paneProps;
224
+ if (isShort) {
225
+ Pane = NavigableRegion;
226
+ paneProps = {
227
+ className: clsx(className, 'is-toggle-only')
228
+ };
229
+ } else {
230
+ Pane = ResizableBox;
231
+ paneProps = /** @type {Parameters<typeof ResizableBox>[0]} */{
232
+ as: NavigableRegion,
233
+ ref: metaBoxesMainRef,
234
+ className: clsx(className, 'is-resizable'),
235
+ defaultSize: {
236
+ height: openHeight
237
+ },
238
+ minHeight: min,
239
+ maxHeight: usedMax,
240
+ enable: {
241
+ top: true,
242
+ right: false,
243
+ bottom: false,
244
+ left: false,
245
+ topLeft: false,
246
+ topRight: false,
247
+ bottomRight: false,
248
+ bottomLeft: false
249
+ },
250
+ handleClasses: {
251
+ top: 'edit-post-meta-boxes-main__presenter'
252
+ },
253
+ handleComponent: {
254
+ top: /*#__PURE__*/_jsxs(_Fragment, {
255
+ children: [/*#__PURE__*/_jsx(Tooltip, {
256
+ text: __('Drag to resize'),
257
+ children: /*#__PURE__*/_jsx("button", {
258
+ // eslint-disable-line jsx-a11y/role-supports-aria-props
259
+ ref: separatorRef,
260
+ role: "separator" // eslint-disable-line jsx-a11y/no-interactive-element-to-noninteractive-role
261
+ ,
262
+ "aria-valuenow": usedAriaValueNow,
263
+ "aria-label": __('Drag to resize'),
264
+ "aria-describedby": separatorHelpId,
265
+ onKeyDown: onSeparatorKeyDown
266
+ })
267
+ }), /*#__PURE__*/_jsx(VisuallyHidden, {
268
+ id: separatorHelpId,
269
+ children: __('Use up and down arrow keys to resize the meta box panel.')
270
+ })]
271
+ })
272
+ },
273
+ // Avoids hiccups while dragging over objects like iframes and ensures that
274
+ // the event to end the drag is captured by the target (resize handle)
275
+ // whether or not it’s under the pointer.
276
+ onPointerDown: ({
277
+ pointerId,
278
+ target
279
+ }) => {
280
+ target.setPointerCapture(pointerId);
281
+ },
282
+ onResizeStart: (event, direction, elementRef) => {
283
+ if (isAutoHeight) {
284
+ // Sets the starting height to avoid visual jumps in height and
285
+ // aria-valuenow being `NaN` for the first (few) resize events.
286
+ applyHeight(elementRef.offsetHeight, false, true);
287
+ setIsUntouched(false);
288
+ }
289
+ },
290
+ onResize: () => applyHeight(metaBoxesMainRef.current.state.height),
291
+ onResizeStop: () => applyHeight(metaBoxesMainRef.current.state.height, true)
292
+ };
293
+ }
294
+ return /*#__PURE__*/_jsxs(Pane, {
295
+ "aria-label": paneLabel,
296
+ ...paneProps,
297
+ children: [isShort ? /*#__PURE__*/_jsxs("button", {
298
+ "aria-expanded": isOpen,
299
+ className: "edit-post-meta-boxes-main__presenter",
300
+ onClick: toggle,
301
+ children: [paneLabel, /*#__PURE__*/_jsx(Icon, {
302
+ icon: isOpen ? chevronUp : chevronDown
303
+ })]
304
+ }) : /*#__PURE__*/_jsx("meta", {
318
305
  ref: effectSizeConstraints
319
306
  }), contents]
320
307
  });
@@ -327,7 +314,6 @@ function Layout({
327
314
  }) {
328
315
  useCommands();
329
316
  useEditPostCommands();
330
- const paddingAppenderRef = usePaddingAppender();
331
317
  const shouldIframe = useShouldIframe();
332
318
  const {
333
319
  createErrorNotice
@@ -351,7 +337,8 @@ function Layout({
351
337
  showMetaBoxes,
352
338
  hasHistory,
353
339
  isWelcomeGuideVisible,
354
- templateId
340
+ templateId,
341
+ enablePaddingAppender
355
342
  } = useSelect(select => {
356
343
  var _getPostType$viewable;
357
344
  const {
@@ -371,18 +358,28 @@ function Layout({
371
358
  kind: 'postType',
372
359
  name: 'wp_template'
373
360
  });
361
+ const {
362
+ isZoomOut
363
+ } = unlock(select(blockEditorStore));
364
+ const {
365
+ getEditorMode,
366
+ getRenderingMode
367
+ } = select(editorStore);
368
+ const isRenderingPostOnly = getRenderingMode() === 'post-only';
374
369
  return {
375
- mode: select(editorStore).getEditorMode(),
370
+ mode: getEditorMode(),
376
371
  isFullscreenActive: select(editPostStore).isFeatureActive('fullscreenMode'),
377
372
  hasActiveMetaboxes: select(editPostStore).hasMetaBoxes(),
378
373
  hasBlockSelected: !!select(blockEditorStore).getBlockSelectionStart(),
379
374
  showIconLabels: get('core', 'showIconLabels'),
380
375
  isDistractionFree: get('core', 'distractionFree'),
381
- showMetaBoxes: !DESIGN_POST_TYPES.includes(currentPostType) && select(editorStore).getRenderingMode() === 'post-only',
376
+ showMetaBoxes: !DESIGN_POST_TYPES.includes(currentPostType) && isRenderingPostOnly,
382
377
  isWelcomeGuideVisible: isFeatureActive('welcomeGuide'),
383
- templateId: supportsTemplateMode && isViewable && canViewTemplate && !isEditingTemplate ? getEditedPostTemplateId() : null
378
+ templateId: supportsTemplateMode && isViewable && canViewTemplate && !isEditingTemplate ? getEditedPostTemplateId() : null,
379
+ enablePaddingAppender: !isZoomOut() && isRenderingPostOnly && !DESIGN_POST_TYPES.includes(currentPostType)
384
380
  };
385
381
  }, [currentPostType, isEditingTemplate, settings.supportsTemplateMode]);
382
+ const [paddingAppenderRef, paddingStyle] = usePaddingAppender(enablePaddingAppender);
386
383
 
387
384
  // Set the right context for the command palette
388
385
  const commandContext = hasBlockSelected ? 'block-selection-edit' : 'entity-edit';
@@ -393,7 +390,7 @@ function Layout({
393
390
  onNavigateToPreviousEntityRecord,
394
391
  defaultRenderingMode: 'post-only'
395
392
  }), [settings, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord]);
396
- const styles = useEditorStyles();
393
+ const styles = useEditorStyles(paddingStyle);
397
394
 
398
395
  // We need to add the show-icon-labels class to the body element so it is applied to modals.
399
396
  if (showIconLabels) {
@@ -401,11 +398,12 @@ function Layout({
401
398
  } else {
402
399
  document.body.classList.remove('show-icon-labels');
403
400
  }
401
+ const navigateRegionsProps = useNavigateRegions();
404
402
  const className = clsx('edit-post-layout', 'is-mode-' + mode, {
405
403
  'has-metaboxes': hasActiveMetaboxes
406
404
  });
407
405
  function onPluginAreaError(name) {
408
- createErrorNotice(sprintf( /* translators: %s: plugin name */
406
+ createErrorNotice(sprintf(/* translators: %s: plugin name */
409
407
  __('The "%s" plugin has encountered an error and cannot be rendered.'), name));
410
408
  }
411
409
  const {
@@ -427,7 +425,7 @@ function Layout({
427
425
  const newItem = items[0];
428
426
  const title = typeof newItem.title === 'string' ? newItem.title : newItem.title?.rendered;
429
427
  createSuccessNotice(sprintf(
430
- // translators: %s: Title of the created post e.g: "Post 1".
428
+ // translators: %s: Title of the created post or template, e.g: "Hello world".
431
429
  __('"%s" successfully created.'), decodeEntities(title)), {
432
430
  type: 'snackbar',
433
431
  id: 'duplicate-post-action',
@@ -459,35 +457,40 @@ function Layout({
459
457
  children: /*#__PURE__*/_jsxs(ErrorBoundary, {
460
458
  children: [/*#__PURE__*/_jsx(CommandMenu, {}), /*#__PURE__*/_jsx(WelcomeGuide, {
461
459
  postType: currentPostType
462
- }), /*#__PURE__*/_jsxs(Editor, {
463
- settings: editorSettings,
464
- initialEdits: initialEdits,
465
- postType: currentPostType,
466
- postId: currentPostId,
467
- templateId: templateId,
468
- className: className,
469
- styles: styles,
470
- forceIsDirty: hasActiveMetaboxes,
471
- contentRef: paddingAppenderRef,
472
- disableIframe: !shouldIframe
473
- // We should auto-focus the canvas (title) on load.
474
- // eslint-disable-next-line jsx-a11y/no-autofocus
475
- ,
476
- autoFocus: !isWelcomeGuideVisible,
477
- onActionPerformed: onActionPerformed,
478
- extraSidebarPanels: showMetaBoxes && /*#__PURE__*/_jsx(MetaBoxes, {
479
- location: "side"
480
- }),
481
- extraContent: !isDistractionFree && showMetaBoxes && /*#__PURE__*/_jsx(MetaBoxesMain, {
482
- isLegacy: !shouldIframe
483
- }),
484
- children: [/*#__PURE__*/_jsx(PostLockedModal, {}), /*#__PURE__*/_jsx(EditorInitialization, {}), /*#__PURE__*/_jsx(FullscreenMode, {
485
- isActive: isFullscreenActive
486
- }), /*#__PURE__*/_jsx(BrowserURL, {
487
- hasHistory: hasHistory
488
- }), /*#__PURE__*/_jsx(UnsavedChangesWarning, {}), /*#__PURE__*/_jsx(AutosaveMonitor, {}), /*#__PURE__*/_jsx(LocalAutosaveMonitor, {}), /*#__PURE__*/_jsx(EditPostKeyboardShortcuts, {}), /*#__PURE__*/_jsx(EditorKeyboardShortcutsRegister, {}), /*#__PURE__*/_jsx(BlockKeyboardShortcuts, {}), /*#__PURE__*/_jsx(InitPatternModal, {}), /*#__PURE__*/_jsx(PluginArea, {
489
- onError: onPluginAreaError
490
- }), /*#__PURE__*/_jsx(PostEditorMoreMenu, {}), backButton, /*#__PURE__*/_jsx(EditorSnackbars, {})]
460
+ }), /*#__PURE__*/_jsx("div", {
461
+ className: navigateRegionsProps.className,
462
+ ...navigateRegionsProps,
463
+ ref: navigateRegionsProps.ref,
464
+ children: /*#__PURE__*/_jsxs(Editor, {
465
+ settings: editorSettings,
466
+ initialEdits: initialEdits,
467
+ postType: currentPostType,
468
+ postId: currentPostId,
469
+ templateId: templateId,
470
+ className: className,
471
+ styles: styles,
472
+ forceIsDirty: hasActiveMetaboxes,
473
+ contentRef: paddingAppenderRef,
474
+ disableIframe: !shouldIframe
475
+ // We should auto-focus the canvas (title) on load.
476
+ // eslint-disable-next-line jsx-a11y/no-autofocus
477
+ ,
478
+ autoFocus: !isWelcomeGuideVisible,
479
+ onActionPerformed: onActionPerformed,
480
+ extraSidebarPanels: showMetaBoxes && /*#__PURE__*/_jsx(MetaBoxes, {
481
+ location: "side"
482
+ }),
483
+ extraContent: !isDistractionFree && showMetaBoxes && /*#__PURE__*/_jsx(MetaBoxesMain, {
484
+ isLegacy: !shouldIframe
485
+ }),
486
+ children: [/*#__PURE__*/_jsx(PostLockedModal, {}), /*#__PURE__*/_jsx(EditorInitialization, {}), /*#__PURE__*/_jsx(FullscreenMode, {
487
+ isActive: isFullscreenActive
488
+ }), /*#__PURE__*/_jsx(BrowserURL, {
489
+ hasHistory: hasHistory
490
+ }), /*#__PURE__*/_jsx(UnsavedChangesWarning, {}), /*#__PURE__*/_jsx(AutosaveMonitor, {}), /*#__PURE__*/_jsx(LocalAutosaveMonitor, {}), /*#__PURE__*/_jsx(EditPostKeyboardShortcuts, {}), /*#__PURE__*/_jsx(EditorKeyboardShortcutsRegister, {}), /*#__PURE__*/_jsx(BlockKeyboardShortcuts, {}), /*#__PURE__*/_jsx(InitPatternModal, {}), /*#__PURE__*/_jsx(PluginArea, {
491
+ onError: onPluginAreaError
492
+ }), /*#__PURE__*/_jsx(PostEditorMoreMenu, {}), backButton, /*#__PURE__*/_jsx(EditorSnackbars, {})]
493
+ })
491
494
  })]
492
495
  })
493
496
  });