@wordpress/edit-post 8.32.0 → 8.32.1-next.ff1cebbba.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 (184) hide show
  1. package/build/commands/use-commands.js +54 -47
  2. package/build/commands/use-commands.js.map +7 -1
  3. package/build/components/back-button/fullscreen-mode-close.js +127 -118
  4. package/build/components/back-button/fullscreen-mode-close.js.map +7 -1
  5. package/build/components/back-button/index.js +56 -54
  6. package/build/components/back-button/index.js.map +7 -1
  7. package/build/components/browser-url/index.js +45 -44
  8. package/build/components/browser-url/index.js.map +7 -1
  9. package/build/components/editor-initialization/index.js +24 -18
  10. package/build/components/editor-initialization/index.js.map +7 -1
  11. package/build/components/editor-initialization/listener-hooks.js +42 -43
  12. package/build/components/editor-initialization/listener-hooks.js.map +7 -1
  13. package/build/components/init-pattern-modal/index.js +100 -79
  14. package/build/components/init-pattern-modal/index.js.map +7 -1
  15. package/build/components/keyboard-shortcuts/index.js +37 -33
  16. package/build/components/keyboard-shortcuts/index.js.map +7 -1
  17. package/build/components/layout/index.js +447 -467
  18. package/build/components/layout/index.js.map +7 -1
  19. package/build/components/layout/use-padding-appender.js +66 -59
  20. package/build/components/layout/use-padding-appender.js.map +7 -1
  21. package/build/components/layout/use-should-iframe.js +36 -30
  22. package/build/components/layout/use-should-iframe.js.map +7 -1
  23. package/build/components/meta-boxes/index.js +46 -33
  24. package/build/components/meta-boxes/index.js.map +7 -1
  25. package/build/components/meta-boxes/meta-box-visibility.js +37 -22
  26. package/build/components/meta-boxes/meta-box-visibility.js.map +7 -1
  27. package/build/components/meta-boxes/meta-boxes-area/index.js +62 -53
  28. package/build/components/meta-boxes/meta-boxes-area/index.js.map +7 -1
  29. package/build/components/meta-boxes/use-meta-box-initialization.js +37 -32
  30. package/build/components/meta-boxes/use-meta-box-initialization.js.map +7 -1
  31. package/build/components/more-menu/index.js +64 -44
  32. package/build/components/more-menu/index.js.map +7 -1
  33. package/build/components/more-menu/manage-patterns-menu-item.js +39 -37
  34. package/build/components/more-menu/manage-patterns-menu-item.js.map +7 -1
  35. package/build/components/more-menu/welcome-guide-menu-item.js +39 -21
  36. package/build/components/more-menu/welcome-guide-menu-item.js.map +7 -1
  37. package/build/components/preferences-modal/enable-custom-fields.js +76 -66
  38. package/build/components/preferences-modal/enable-custom-fields.js.map +7 -1
  39. package/build/components/preferences-modal/enable-panel.js +47 -43
  40. package/build/components/preferences-modal/enable-panel.js.map +7 -1
  41. package/build/components/preferences-modal/index.js +51 -39
  42. package/build/components/preferences-modal/index.js.map +7 -1
  43. package/build/components/preferences-modal/meta-boxes-section.js +65 -52
  44. package/build/components/preferences-modal/meta-boxes-section.js.map +7 -1
  45. package/build/components/welcome-guide/default.js +134 -97
  46. package/build/components/welcome-guide/default.js.map +7 -1
  47. package/build/components/welcome-guide/image.js +34 -23
  48. package/build/components/welcome-guide/image.js.map +7 -1
  49. package/build/components/welcome-guide/index.js +51 -38
  50. package/build/components/welcome-guide/index.js.map +7 -1
  51. package/build/components/welcome-guide/template.js +65 -45
  52. package/build/components/welcome-guide/template.js.map +7 -1
  53. package/build/deprecated.js +84 -110
  54. package/build/deprecated.js.map +7 -1
  55. package/build/hooks/use-navigate-to-entity-record.js +60 -78
  56. package/build/hooks/use-navigate-to-entity-record.js.map +7 -1
  57. package/build/index.js +101 -136
  58. package/build/index.js.map +7 -1
  59. package/build/lock-unlock.js +31 -15
  60. package/build/lock-unlock.js.map +7 -1
  61. package/build/store/actions.js +239 -431
  62. package/build/store/actions.js.map +7 -1
  63. package/build/store/constants.js +33 -26
  64. package/build/store/constants.js.map +7 -1
  65. package/build/store/index.js +44 -32
  66. package/build/store/index.js.map +7 -1
  67. package/build/store/reducer.js +50 -57
  68. package/build/store/reducer.js.map +7 -1
  69. package/build/store/selectors.js +288 -459
  70. package/build/store/selectors.js.map +7 -1
  71. package/build/utils/meta-boxes.js +31 -19
  72. package/build/utils/meta-boxes.js.map +7 -1
  73. package/build-module/commands/use-commands.js +35 -40
  74. package/build-module/commands/use-commands.js.map +7 -1
  75. package/build-module/components/back-button/fullscreen-mode-close.js +102 -110
  76. package/build-module/components/back-button/fullscreen-mode-close.js.map +7 -1
  77. package/build-module/components/back-button/index.js +28 -47
  78. package/build-module/components/back-button/index.js.map +7 -1
  79. package/build-module/components/browser-url/index.js +23 -38
  80. package/build-module/components/browser-url/index.js.map +7 -1
  81. package/build-module/components/editor-initialization/index.js +6 -13
  82. package/build-module/components/editor-initialization/index.js.map +7 -1
  83. package/build-module/components/editor-initialization/listener-hooks.js +20 -34
  84. package/build-module/components/editor-initialization/listener-hooks.js.map +7 -1
  85. package/build-module/components/init-pattern-modal/index.js +90 -74
  86. package/build-module/components/init-pattern-modal/index.js.map +7 -1
  87. package/build-module/components/keyboard-shortcuts/index.js +21 -26
  88. package/build-module/components/keyboard-shortcuts/index.js.map +7 -1
  89. package/build-module/components/layout/index.js +439 -448
  90. package/build-module/components/layout/index.js.map +7 -1
  91. package/build-module/components/layout/use-padding-appender.js +44 -54
  92. package/build-module/components/layout/use-padding-appender.js.map +7 -1
  93. package/build-module/components/layout/use-should-iframe.js +15 -25
  94. package/build-module/components/layout/use-should-iframe.js.map +7 -1
  95. package/build-module/components/meta-boxes/index.js +18 -26
  96. package/build-module/components/meta-boxes/index.js.map +7 -1
  97. package/build-module/components/meta-boxes/meta-box-visibility.js +18 -15
  98. package/build-module/components/meta-boxes/meta-box-visibility.js.map +7 -1
  99. package/build-module/components/meta-boxes/meta-boxes-area/index.js +30 -44
  100. package/build-module/components/meta-boxes/meta-boxes-area/index.js.map +7 -1
  101. package/build-module/components/meta-boxes/use-meta-box-initialization.js +14 -25
  102. package/build-module/components/meta-boxes/use-meta-box-initialization.js.map +7 -1
  103. package/build-module/components/more-menu/index.js +36 -37
  104. package/build-module/components/more-menu/index.js.map +7 -1
  105. package/build-module/components/more-menu/manage-patterns-menu-item.js +21 -31
  106. package/build-module/components/more-menu/manage-patterns-menu-item.js.map +7 -1
  107. package/build-module/components/more-menu/welcome-guide-menu-item.js +22 -16
  108. package/build-module/components/more-menu/welcome-guide-menu-item.js.map +7 -1
  109. package/build-module/components/preferences-modal/enable-custom-fields.js +51 -56
  110. package/build-module/components/preferences-modal/enable-custom-fields.js.map +7 -1
  111. package/build-module/components/preferences-modal/enable-panel.js +30 -38
  112. package/build-module/components/preferences-modal/enable-panel.js.map +7 -1
  113. package/build-module/components/preferences-modal/index.js +24 -34
  114. package/build-module/components/preferences-modal/index.js.map +7 -1
  115. package/build-module/components/preferences-modal/meta-boxes-section.js +34 -45
  116. package/build-module/components/preferences-modal/meta-boxes-section.js.map +7 -1
  117. package/build-module/components/welcome-guide/default.js +107 -91
  118. package/build-module/components/welcome-guide/default.js.map +7 -1
  119. package/build-module/components/welcome-guide/image.js +16 -18
  120. package/build-module/components/welcome-guide/image.js.map +7 -1
  121. package/build-module/components/welcome-guide/index.js +23 -31
  122. package/build-module/components/welcome-guide/index.js.map +7 -1
  123. package/build-module/components/welcome-guide/template.js +38 -39
  124. package/build-module/components/welcome-guide/template.js.map +7 -1
  125. package/build-module/deprecated.js +62 -103
  126. package/build-module/deprecated.js.map +7 -1
  127. package/build-module/hooks/use-navigate-to-entity-record.js +42 -73
  128. package/build-module/hooks/use-navigate-to-entity-record.js.map +7 -1
  129. package/build-module/index.js +70 -95
  130. package/build-module/index.js.map +7 -1
  131. package/build-module/lock-unlock.js +8 -7
  132. package/build-module/lock-unlock.js.map +7 -1
  133. package/build-module/store/actions.js +158 -368
  134. package/build-module/store/actions.js.map +7 -1
  135. package/build-module/store/constants.js +9 -21
  136. package/build-module/store/constants.js.map +7 -1
  137. package/build-module/store/index.js +10 -22
  138. package/build-module/store/index.js.map +7 -1
  139. package/build-module/store/reducer.js +28 -51
  140. package/build-module/store/reducer.js.map +7 -1
  141. package/build-module/store/selectors.js +232 -442
  142. package/build-module/store/selectors.js.map +7 -1
  143. package/build-module/utils/meta-boxes.js +9 -13
  144. package/build-module/utils/meta-boxes.js.map +7 -1
  145. package/build-style/classic-rtl.css +0 -154
  146. package/build-style/classic.css +0 -154
  147. package/build-style/style-rtl.css +135 -110
  148. package/build-style/style.css +135 -110
  149. package/package.json +39 -31
  150. package/src/classic.scss +3 -0
  151. package/src/components/back-button/style.scss +3 -0
  152. package/src/components/layout/index.js +3 -2
  153. package/src/components/layout/style.scss +4 -0
  154. package/src/components/meta-boxes/meta-boxes-area/style.scss +3 -0
  155. package/src/components/welcome-guide/style.scss +3 -0
  156. package/src/style.scss +8 -4
  157. package/build/components/header/header-toolbar/index.native.js +0 -204
  158. package/build/components/header/header-toolbar/index.native.js.map +0 -1
  159. package/build/components/header/index.native.js +0 -59
  160. package/build/components/header/index.native.js.map +0 -1
  161. package/build/components/layout/index.native.js +0 -166
  162. package/build/components/layout/index.native.js.map +0 -1
  163. package/build/components/visual-editor/header.native.js +0 -63
  164. package/build/components/visual-editor/header.native.js.map +0 -1
  165. package/build/components/visual-editor/index.native.js +0 -44
  166. package/build/components/visual-editor/index.native.js.map +0 -1
  167. package/build/editor.native.js +0 -157
  168. package/build/editor.native.js.map +0 -1
  169. package/build/index.native.js +0 -58
  170. package/build/index.native.js.map +0 -1
  171. package/build-module/components/header/header-toolbar/index.native.js +0 -196
  172. package/build-module/components/header/header-toolbar/index.native.js.map +0 -1
  173. package/build-module/components/header/index.native.js +0 -50
  174. package/build-module/components/header/index.native.js.map +0 -1
  175. package/build-module/components/layout/index.native.js +0 -158
  176. package/build-module/components/layout/index.native.js.map +0 -1
  177. package/build-module/components/visual-editor/header.native.js +0 -56
  178. package/build-module/components/visual-editor/header.native.js.map +0 -1
  179. package/build-module/components/visual-editor/index.native.js +0 -35
  180. package/build-module/components/visual-editor/index.native.js.map +0 -1
  181. package/build-module/editor.native.js +0 -149
  182. package/build-module/editor.native.js.map +0 -1
  183. package/build-module/index.native.js +0 -45
  184. package/build-module/index.native.js.map +0 -1
@@ -1,141 +1,148 @@
1
- /**
2
- * External dependencies
3
- */
4
- import clsx from 'clsx';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { AutosaveMonitor, LocalAutosaveMonitor, UnsavedChangesWarning, EditorKeyboardShortcutsRegister, EditorSnackbars, ErrorBoundary, PostLockedModal, store as editorStore, privateApis as editorPrivateApis } from '@wordpress/editor';
10
- import { useSelect, useDispatch } from '@wordpress/data';
11
- import { privateApis as blockEditorPrivateApis, store as blockEditorStore } from '@wordpress/block-editor';
12
- import { PluginArea } from '@wordpress/plugins';
13
- import { __, sprintf } from '@wordpress/i18n';
14
- import { useCallback, useEffect, useMemo, useId, useRef, useState } from '@wordpress/element';
15
- import { chevronDown, chevronUp } from '@wordpress/icons';
16
- import { store as noticesStore } from '@wordpress/notices';
17
- import { store as preferencesStore } from '@wordpress/preferences';
18
- import { privateApis as commandsPrivateApis } from '@wordpress/commands';
19
- import { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library';
20
- import { addQueryArgs } from '@wordpress/url';
21
- import { decodeEntities } from '@wordpress/html-entities';
22
- import { store as coreStore } from '@wordpress/core-data';
23
- import { Icon, ResizableBox, SlotFillProvider, Tooltip, VisuallyHidden, __unstableUseNavigateRegions as useNavigateRegions } from '@wordpress/components';
24
- import { useEvent, useMediaQuery, useRefEffect, useViewportMatch } from '@wordpress/compose';
25
-
26
- /**
27
- * Internal dependencies
28
- */
29
- import BackButton from '../back-button';
30
- import EditorInitialization from '../editor-initialization';
31
- import EditPostKeyboardShortcuts from '../keyboard-shortcuts';
32
- import InitPatternModal from '../init-pattern-modal';
33
- import BrowserURL from '../browser-url';
34
- import MetaBoxes from '../meta-boxes';
35
- import PostEditorMoreMenu from '../more-menu';
36
- import WelcomeGuide from '../welcome-guide';
37
- import { store as editPostStore } from '../../store';
38
- import { unlock } from '../../lock-unlock';
39
- import useEditPostCommands from '../../commands/use-commands';
40
- import { usePaddingAppender } from './use-padding-appender';
41
- import { useShouldIframe } from './use-should-iframe';
42
- import useNavigateToEntityRecord from '../../hooks/use-navigate-to-entity-record';
43
- import { useMetaBoxInitialization } from '../meta-boxes/use-meta-box-initialization';
44
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
45
- const {
46
- getLayoutStyles
47
- } = unlock(blockEditorPrivateApis);
48
- const {
49
- useCommandContext
50
- } = unlock(commandsPrivateApis);
51
- const {
52
- Editor,
53
- FullscreenMode,
54
- NavigableRegion
55
- } = unlock(editorPrivateApis);
56
- const {
57
- BlockKeyboardShortcuts
58
- } = unlock(blockLibraryPrivateApis);
59
- const DESIGN_POST_TYPES = ['wp_template', 'wp_template_part', 'wp_block', 'wp_navigation', 'wp_registered_template'];
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import clsx from "clsx";
3
+ import { NavigableRegion } from "@wordpress/admin-ui";
4
+ import {
5
+ AutosaveMonitor,
6
+ LocalAutosaveMonitor,
7
+ UnsavedChangesWarning,
8
+ EditorKeyboardShortcutsRegister,
9
+ EditorSnackbars,
10
+ ErrorBoundary,
11
+ PostLockedModal,
12
+ store as editorStore,
13
+ privateApis as editorPrivateApis
14
+ } from "@wordpress/editor";
15
+ import { useSelect, useDispatch } from "@wordpress/data";
16
+ import {
17
+ privateApis as blockEditorPrivateApis,
18
+ store as blockEditorStore
19
+ } from "@wordpress/block-editor";
20
+ import { PluginArea } from "@wordpress/plugins";
21
+ import { __, sprintf } from "@wordpress/i18n";
22
+ import {
23
+ useCallback,
24
+ useEffect,
25
+ useMemo,
26
+ useId,
27
+ useRef,
28
+ useState
29
+ } from "@wordpress/element";
30
+ import { chevronDown, chevronUp } from "@wordpress/icons";
31
+ import { store as noticesStore } from "@wordpress/notices";
32
+ import { store as preferencesStore } from "@wordpress/preferences";
33
+ import { privateApis as commandsPrivateApis } from "@wordpress/commands";
34
+ import { privateApis as blockLibraryPrivateApis } from "@wordpress/block-library";
35
+ import { addQueryArgs } from "@wordpress/url";
36
+ import { decodeEntities } from "@wordpress/html-entities";
37
+ import { store as coreStore } from "@wordpress/core-data";
38
+ import {
39
+ Icon,
40
+ ResizableBox,
41
+ SlotFillProvider,
42
+ Tooltip,
43
+ VisuallyHidden,
44
+ __unstableUseNavigateRegions as useNavigateRegions
45
+ } from "@wordpress/components";
46
+ import {
47
+ useEvent,
48
+ useMediaQuery,
49
+ useRefEffect,
50
+ useViewportMatch
51
+ } from "@wordpress/compose";
52
+ import BackButton from "../back-button";
53
+ import EditorInitialization from "../editor-initialization";
54
+ import EditPostKeyboardShortcuts from "../keyboard-shortcuts";
55
+ import InitPatternModal from "../init-pattern-modal";
56
+ import BrowserURL from "../browser-url";
57
+ import MetaBoxes from "../meta-boxes";
58
+ import PostEditorMoreMenu from "../more-menu";
59
+ import WelcomeGuide from "../welcome-guide";
60
+ import { store as editPostStore } from "../../store";
61
+ import { unlock } from "../../lock-unlock";
62
+ import useEditPostCommands from "../../commands/use-commands";
63
+ import { usePaddingAppender } from "./use-padding-appender";
64
+ import { useShouldIframe } from "./use-should-iframe";
65
+ import useNavigateToEntityRecord from "../../hooks/use-navigate-to-entity-record";
66
+ import { useMetaBoxInitialization } from "../meta-boxes/use-meta-box-initialization";
67
+ const { getLayoutStyles } = unlock(blockEditorPrivateApis);
68
+ const { useCommandContext } = unlock(commandsPrivateApis);
69
+ const { Editor, FullscreenMode } = unlock(editorPrivateApis);
70
+ const { BlockKeyboardShortcuts } = unlock(blockLibraryPrivateApis);
71
+ const DESIGN_POST_TYPES = [
72
+ "wp_template",
73
+ "wp_template_part",
74
+ "wp_block",
75
+ "wp_navigation",
76
+ "wp_registered_template"
77
+ ];
60
78
  function useEditorStyles(...additionalStyles) {
61
- const {
62
- hasThemeStyleSupport,
63
- editorSettings
64
- } = useSelect(select => {
79
+ const { hasThemeStyleSupport, editorSettings } = useSelect((select) => {
65
80
  return {
66
- hasThemeStyleSupport: select(editPostStore).isFeatureActive('themeStyles'),
81
+ hasThemeStyleSupport: select(editPostStore).isFeatureActive("themeStyles"),
67
82
  editorSettings: select(editorStore).getEditorSettings()
68
83
  };
69
84
  }, []);
70
- const addedStyles = additionalStyles.join('\n');
71
-
72
- // Compute the default styles.
85
+ const addedStyles = additionalStyles.join("\n");
73
86
  return useMemo(() => {
74
- var _editorSettings$style, _editorSettings$defau, _editorSettings$style2, _editorSettings$style3;
75
- const presetStyles = (_editorSettings$style = editorSettings.styles?.filter(style => style.__unstableType && style.__unstableType !== 'theme')) !== null && _editorSettings$style !== void 0 ? _editorSettings$style : [];
76
- const defaultEditorStyles = [...((_editorSettings$defau = editorSettings?.defaultEditorStyles) !== null && _editorSettings$defau !== void 0 ? _editorSettings$defau : []), ...presetStyles];
77
-
78
- // Has theme styles if the theme supports them and if some styles were not preset styles (in which case they're theme styles).
79
- const hasThemeStyles = hasThemeStyleSupport && presetStyles.length !== ((_editorSettings$style2 = editorSettings.styles?.length) !== null && _editorSettings$style2 !== void 0 ? _editorSettings$style2 : 0);
80
-
81
- // If theme styles are not present or displayed, ensure that
82
- // base layout styles are still present in the editor.
87
+ const presetStyles = editorSettings.styles?.filter(
88
+ (style) => style.__unstableType && style.__unstableType !== "theme"
89
+ ) ?? [];
90
+ const defaultEditorStyles = [
91
+ ...editorSettings?.defaultEditorStyles ?? [],
92
+ ...presetStyles
93
+ ];
94
+ const hasThemeStyles = hasThemeStyleSupport && presetStyles.length !== (editorSettings.styles?.length ?? 0);
83
95
  if (!editorSettings.disableLayoutStyles && !hasThemeStyles) {
84
96
  defaultEditorStyles.push({
85
97
  css: getLayoutStyles({
86
98
  style: {},
87
- selector: 'body',
99
+ selector: "body",
88
100
  hasBlockGapSupport: false,
89
101
  hasFallbackGapSupport: true,
90
- fallbackGapValue: '0.5em'
102
+ fallbackGapValue: "0.5em"
91
103
  })
92
104
  });
93
105
  }
94
- const baseStyles = hasThemeStyles ? (_editorSettings$style3 = editorSettings.styles) !== null && _editorSettings$style3 !== void 0 ? _editorSettings$style3 : [] : defaultEditorStyles;
106
+ const baseStyles = hasThemeStyles ? editorSettings.styles ?? [] : defaultEditorStyles;
95
107
  if (addedStyles) {
96
- return [...baseStyles, {
97
- css: addedStyles
98
- }];
108
+ return [...baseStyles, { css: addedStyles }];
99
109
  }
100
110
  return baseStyles;
101
- }, [editorSettings.defaultEditorStyles, editorSettings.disableLayoutStyles, editorSettings.styles, hasThemeStyleSupport, addedStyles]);
111
+ }, [
112
+ editorSettings.defaultEditorStyles,
113
+ editorSettings.disableLayoutStyles,
114
+ editorSettings.styles,
115
+ hasThemeStyleSupport,
116
+ addedStyles
117
+ ]);
102
118
  }
103
-
104
- /**
105
- * @param {Object} props
106
- * @param {boolean} props.isLegacy True when the editor canvas is not in an iframe.
107
- */
108
- function MetaBoxesMain({
109
- isLegacy
110
- }) {
111
- const [isOpen, openHeight, hasAnyVisible] = useSelect(select => {
112
- const {
113
- get
114
- } = select(preferencesStore);
115
- const {
116
- isMetaBoxLocationVisible
117
- } = select(editPostStore);
118
- return [!!get('core/edit-post', 'metaBoxesMainIsOpen'), get('core/edit-post', 'metaBoxesMainOpenHeight'), isMetaBoxLocationVisible('normal') || isMetaBoxLocationVisible('advanced') || isMetaBoxLocationVisible('side')];
119
+ function MetaBoxesMain({ isLegacy }) {
120
+ const [isOpen, openHeight, hasAnyVisible] = useSelect((select) => {
121
+ const { get } = select(preferencesStore);
122
+ const { isMetaBoxLocationVisible } = select(editPostStore);
123
+ return [
124
+ !!get("core/edit-post", "metaBoxesMainIsOpen"),
125
+ get("core/edit-post", "metaBoxesMainOpenHeight"),
126
+ isMetaBoxLocationVisible("normal") || isMetaBoxLocationVisible("advanced") || isMetaBoxLocationVisible("side")
127
+ ];
119
128
  }, []);
120
- const {
121
- set: setPreference
122
- } = useDispatch(preferencesStore);
129
+ const { set: setPreference } = useDispatch(preferencesStore);
123
130
  const metaBoxesMainRef = useRef();
124
- const isShort = useMediaQuery('(max-height: 549px)');
125
- const [{
126
- min,
127
- max
128
- }, setHeightConstraints] = useState(() => ({}));
129
- // Keeps the resizable area’s size constraints updated taking into account
130
- // editor notices. The constraints are also used to derive the value for the
131
- // aria-valuenow attribute on the separator.
132
- const effectSizeConstraints = useRefEffect(node => {
133
- const container = node.closest('.interface-interface-skeleton__content');
131
+ const isShort = useMediaQuery("(max-height: 549px)");
132
+ const [{ min, max }, setHeightConstraints] = useState(() => ({}));
133
+ const effectSizeConstraints = useRefEffect((node) => {
134
+ const container = node.closest(
135
+ ".interface-interface-skeleton__content"
136
+ );
134
137
  if (!container) {
135
138
  return;
136
139
  }
137
- const noticeLists = container.querySelectorAll(':scope > .components-notice-list');
138
- const resizeHandle = container.querySelector('.edit-post-meta-boxes-main__presenter');
140
+ const noticeLists = container.querySelectorAll(
141
+ ":scope > .components-notice-list"
142
+ );
143
+ const resizeHandle = container.querySelector(
144
+ ".edit-post-meta-boxes-main__presenter"
145
+ );
139
146
  const deriveConstraints = () => {
140
147
  const fullHeight = container.offsetHeight;
141
148
  let nextMax = fullHeight;
@@ -143,10 +150,7 @@ function MetaBoxesMain({
143
150
  nextMax -= element.offsetHeight;
144
151
  }
145
152
  const nextMin = resizeHandle.offsetHeight;
146
- setHeightConstraints({
147
- min: nextMin,
148
- max: nextMax
149
- });
153
+ setHeightConstraints({ min: nextMin, max: nextMax });
150
154
  };
151
155
  const observer = new window.ResizeObserver(deriveConstraints);
152
156
  observer.observe(container);
@@ -158,24 +162,19 @@ function MetaBoxesMain({
158
162
  const resizeDataRef = useRef({});
159
163
  const separatorRef = useRef();
160
164
  const separatorHelpId = useId();
161
-
162
- /**
163
- * @param {number|'auto'} [candidateHeight] Height in pixels or 'auto'.
164
- * @param {boolean} isPersistent Whether to persist the height in preferences.
165
- * @param {boolean} isInstant Whether to update the height in the DOM.
166
- */
167
- const applyHeight = (candidateHeight = 'auto', isPersistent, isInstant) => {
168
- if (candidateHeight === 'auto') {
169
- isPersistent = false; // Just in case — “auto” should never persist.
165
+ const applyHeight = (candidateHeight = "auto", isPersistent, isInstant) => {
166
+ if (candidateHeight === "auto") {
167
+ isPersistent = false;
170
168
  } else {
171
169
  candidateHeight = Math.min(max, Math.max(min, candidateHeight));
172
170
  }
173
171
  if (isPersistent) {
174
- setPreference('core/edit-post', 'metaBoxesMainOpenHeight', candidateHeight);
175
- }
176
- // Updates aria-valuenow only when not persisting the value because otherwise
177
- // it's done by the render that persisting the value causes.
178
- else if (!isShort) {
172
+ setPreference(
173
+ "core/edit-post",
174
+ "metaBoxesMainOpenHeight",
175
+ candidateHeight
176
+ );
177
+ } else if (!isShort) {
179
178
  separatorRef.current.ariaValueNow = getAriaValueNow(candidateHeight);
180
179
  }
181
180
  if (isInstant) {
@@ -185,22 +184,15 @@ function MetaBoxesMain({
185
184
  // if `width` is left unspecified a subsequent drag gesture applies a fixed
186
185
  // width and the pane fails to widen/narrow with parent width changes from
187
186
  // sidebars opening/closing or window resizes.
188
- width: 'auto'
187
+ width: "auto"
189
188
  });
190
189
  }
191
190
  };
192
- const getRenderValues = useEvent(() => ({
193
- isOpen,
194
- openHeight,
195
- min
196
- }));
197
- // Sets the height to 'auto' when not resizable (isShort) and to the
198
- // preferred height when resizable.
191
+ const getRenderValues = useEvent(() => ({ isOpen, openHeight, min }));
199
192
  useEffect(() => {
200
193
  const fresh = getRenderValues();
201
- // Tests for `min` having a value to skip the first render.
202
- if (fresh.min !== undefined && metaBoxesMainRef.current) {
203
- const usedOpenHeight = isShort ? 'auto' : fresh.openHeight;
194
+ if (fresh.min !== void 0 && metaBoxesMainRef.current) {
195
+ const usedOpenHeight = isShort ? "auto" : fresh.openHeight;
204
196
  const usedHeight = fresh.isOpen ? usedOpenHeight : fresh.min;
205
197
  applyHeight(usedHeight, false, true);
206
198
  }
@@ -208,31 +200,26 @@ function MetaBoxesMain({
208
200
  if (!hasAnyVisible) {
209
201
  return;
210
202
  }
211
- const contents = /*#__PURE__*/_jsxs("div", {
212
- // The class name 'edit-post-layout__metaboxes' is retained because some plugins use it.
213
- className: "edit-post-layout__metaboxes edit-post-meta-boxes-main__liner",
214
- hidden: !isOpen,
215
- children: [/*#__PURE__*/_jsx(MetaBoxes, {
216
- location: "normal"
217
- }), /*#__PURE__*/_jsx(MetaBoxes, {
218
- location: "advanced"
219
- })]
220
- });
203
+ const contents = /* @__PURE__ */ jsxs(
204
+ "div",
205
+ {
206
+ className: "edit-post-layout__metaboxes edit-post-meta-boxes-main__liner",
207
+ hidden: !isLegacy && !isOpen,
208
+ children: [
209
+ /* @__PURE__ */ jsx(MetaBoxes, { location: "normal" }),
210
+ /* @__PURE__ */ jsx(MetaBoxes, { location: "advanced" })
211
+ ]
212
+ }
213
+ );
221
214
  if (isLegacy) {
222
215
  return contents;
223
216
  }
224
- const isAutoHeight = openHeight === undefined;
225
- const getAriaValueNow = height => Math.round((height - min) / (max - min) * 100);
226
- const usedAriaValueNow = max === undefined || isAutoHeight ? 50 : getAriaValueNow(openHeight);
227
- const persistIsOpen = (to = !isOpen) => setPreference('core/edit-post', 'metaBoxesMainIsOpen', to);
228
-
229
- // TODO: Support more/all keyboard interactions from the window splitter pattern:
230
- // https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/
231
- const onSeparatorKeyDown = event => {
232
- const delta = {
233
- ArrowUp: 20,
234
- ArrowDown: -20
235
- }[event.key];
217
+ const isAutoHeight = openHeight === void 0;
218
+ const getAriaValueNow = (height) => Math.round((height - min) / (max - min) * 100);
219
+ const usedAriaValueNow = max === void 0 || isAutoHeight ? 50 : getAriaValueNow(openHeight);
220
+ const persistIsOpen = (to = !isOpen) => setPreference("core/edit-post", "metaBoxesMainIsOpen", to);
221
+ const onSeparatorKeyDown = (event) => {
222
+ const delta = { ArrowUp: 20, ArrowDown: -20 }[event.key];
236
223
  if (delta) {
237
224
  const pane = metaBoxesMainRef.current.resizable;
238
225
  const fromHeight = isAutoHeight ? pane.offsetHeight : openHeight;
@@ -242,136 +229,107 @@ function MetaBoxesMain({
242
229
  event.preventDefault();
243
230
  }
244
231
  };
245
- const paneLabel = __('Meta Boxes');
246
- const toggle = /*#__PURE__*/_jsxs("button", {
247
- "aria-expanded": isOpen,
248
- onClick: ({
249
- detail
250
- }) => {
251
- const {
252
- isToggleInferred
253
- } = resizeDataRef.current;
254
- if (isShort || !detail || isToggleInferred) {
255
- persistIsOpen();
256
- const usedOpenHeight = isShort ? 'auto' : openHeight;
257
- const usedHeight = isOpen ? min : usedOpenHeight;
258
- applyHeight(usedHeight, false, true);
259
- }
232
+ const paneLabel = __("Meta Boxes");
233
+ const toggle = /* @__PURE__ */ jsxs(
234
+ "button",
235
+ {
236
+ "aria-expanded": isOpen,
237
+ onClick: ({ detail }) => {
238
+ const { isToggleInferred } = resizeDataRef.current;
239
+ if (isShort || !detail || isToggleInferred) {
240
+ persistIsOpen();
241
+ const usedOpenHeight = isShort ? "auto" : openHeight;
242
+ const usedHeight = isOpen ? min : usedOpenHeight;
243
+ applyHeight(usedHeight, false, true);
244
+ }
245
+ },
246
+ ...isShort && {
247
+ onMouseDown: (event) => event.stopPropagation(),
248
+ onTouchStart: (event) => event.stopPropagation()
249
+ },
250
+ children: [
251
+ paneLabel,
252
+ /* @__PURE__ */ jsx(Icon, { icon: isOpen ? chevronUp : chevronDown })
253
+ ]
260
254
  }
261
- // Prevents resizing in short viewports.
262
- ,
263
- ...(isShort && {
264
- onMouseDown: event => event.stopPropagation(),
265
- onTouchStart: event => event.stopPropagation()
266
- }),
267
- children: [paneLabel, /*#__PURE__*/_jsx(Icon, {
268
- icon: isOpen ? chevronUp : chevronDown
269
- })]
270
- });
271
- const separator = !isShort && /*#__PURE__*/_jsxs(_Fragment, {
272
- children: [/*#__PURE__*/_jsx(Tooltip, {
273
- text: __('Drag to resize'),
274
- children: /*#__PURE__*/_jsx("button", {
275
- // eslint-disable-line jsx-a11y/role-supports-aria-props
255
+ );
256
+ const separator = !isShort && /* @__PURE__ */ jsxs(Fragment, { children: [
257
+ /* @__PURE__ */ jsx(Tooltip, { text: __("Drag to resize"), children: /* @__PURE__ */ jsx(
258
+ "button",
259
+ {
276
260
  ref: separatorRef,
277
- role: "separator" // eslint-disable-line jsx-a11y/no-interactive-element-to-noninteractive-role
278
- ,
261
+ role: "separator",
279
262
  "aria-valuenow": usedAriaValueNow,
280
- "aria-label": __('Drag to resize'),
263
+ "aria-label": __("Drag to resize"),
281
264
  "aria-describedby": separatorHelpId,
282
265
  onKeyDown: onSeparatorKeyDown
283
- })
284
- }), /*#__PURE__*/_jsx(VisuallyHidden, {
285
- id: separatorHelpId,
286
- children: __('Use up and down arrow keys to resize the meta box panel.')
287
- })]
288
- });
289
- const paneProps = /** @type {Parameters<typeof ResizableBox>[0]} */{
290
- as: NavigableRegion,
291
- ref: metaBoxesMainRef,
292
- className: 'edit-post-meta-boxes-main',
293
- defaultSize: {
294
- height: isOpen ? openHeight : 0
295
- },
296
- minHeight: min,
297
- maxHeight: max,
298
- enable: {
299
- top: true
300
- },
301
- handleClasses: {
302
- top: 'edit-post-meta-boxes-main__presenter'
303
- },
304
- handleComponent: {
305
- top: /*#__PURE__*/_jsxs(_Fragment, {
306
- children: [toggle, separator]
307
- })
308
- },
309
- // Avoids hiccups while dragging over objects like iframes and ensures that
310
- // the event to end the drag is captured by the target (resize handle)
311
- // whether or not it’s under the pointer.
312
- onPointerDown: ({
313
- pointerId,
314
- target
315
- }) => {
316
- if (separatorRef.current?.parentElement.contains(target)) {
317
- target.setPointerCapture(pointerId);
318
- }
319
- },
320
- onResizeStart: ({
321
- timeStamp
322
- }, direction, elementRef) => {
323
- if (isAutoHeight) {
324
- // Sets the starting height to avoid visual jumps in height and
325
- // aria-valuenow being `NaN` for the first (few) resize events.
326
- applyHeight(elementRef.offsetHeight, false, true);
327
266
  }
328
- elementRef.classList.add('is-resizing');
329
- resizeDataRef.current = {
330
- timeStamp,
331
- maxDelta: 0
332
- };
333
- },
334
- onResize: (event, direction, elementRef, delta) => {
335
- const {
336
- maxDelta
337
- } = resizeDataRef.current;
338
- const newDelta = Math.abs(delta.height);
339
- resizeDataRef.current.maxDelta = Math.max(maxDelta, newDelta);
340
- applyHeight(metaBoxesMainRef.current.state.height);
341
- },
342
- onResizeStop: (event, direction, elementRef) => {
343
- elementRef.classList.remove('is-resizing');
344
- const duration = event.timeStamp - resizeDataRef.current.timeStamp;
345
- const wasSeparator = event.target === separatorRef.current;
346
- const {
347
- maxDelta
348
- } = resizeDataRef.current;
349
- const isToggleInferred = maxDelta < 1 || duration < 144 && maxDelta < 5;
350
- if (isShort || !wasSeparator && isToggleInferred) {
351
- resizeDataRef.current.isToggleInferred = true;
352
- } else {
353
- const {
354
- height
355
- } = metaBoxesMainRef.current.state;
356
- const nextIsOpen = height > min;
357
- persistIsOpen(nextIsOpen);
358
- // Persists height only if still open. This is so that when closed by a drag the
359
- // prior height can be restored by the toggle button instead of having to drag
360
- // the pane open again. Also, if already closed, a click on the separator won’t
361
- // persist the height as the minimum.
362
- if (nextIsOpen) {
363
- applyHeight(height, true);
267
+ ) }),
268
+ /* @__PURE__ */ jsx(VisuallyHidden, { id: separatorHelpId, children: __(
269
+ "Use up and down arrow keys to resize the meta box panel."
270
+ ) })
271
+ ] });
272
+ const paneProps = (
273
+ /** @type {Parameters<typeof ResizableBox>[0]} */
274
+ {
275
+ as: NavigableRegion,
276
+ ref: metaBoxesMainRef,
277
+ className: "edit-post-meta-boxes-main",
278
+ defaultSize: { height: isOpen ? openHeight : 0 },
279
+ minHeight: min,
280
+ maxHeight: max,
281
+ enable: { top: true },
282
+ handleClasses: { top: "edit-post-meta-boxes-main__presenter" },
283
+ handleComponent: {
284
+ top: /* @__PURE__ */ jsxs(Fragment, { children: [
285
+ toggle,
286
+ separator
287
+ ] })
288
+ },
289
+ // Avoids hiccups while dragging over objects like iframes and ensures that
290
+ // the event to end the drag is captured by the target (resize handle)
291
+ // whether or not it’s under the pointer.
292
+ onPointerDown: ({ pointerId, target }) => {
293
+ if (separatorRef.current?.parentElement.contains(target)) {
294
+ target.setPointerCapture(pointerId);
295
+ }
296
+ },
297
+ onResizeStart: ({ timeStamp }, direction, elementRef) => {
298
+ if (isAutoHeight) {
299
+ applyHeight(elementRef.offsetHeight, false, true);
300
+ }
301
+ elementRef.classList.add("is-resizing");
302
+ resizeDataRef.current = { timeStamp, maxDelta: 0 };
303
+ },
304
+ onResize: (event, direction, elementRef, delta) => {
305
+ const { maxDelta } = resizeDataRef.current;
306
+ const newDelta = Math.abs(delta.height);
307
+ resizeDataRef.current.maxDelta = Math.max(maxDelta, newDelta);
308
+ applyHeight(metaBoxesMainRef.current.state.height);
309
+ },
310
+ onResizeStop: (event, direction, elementRef) => {
311
+ elementRef.classList.remove("is-resizing");
312
+ const duration = event.timeStamp - resizeDataRef.current.timeStamp;
313
+ const wasSeparator = event.target === separatorRef.current;
314
+ const { maxDelta } = resizeDataRef.current;
315
+ const isToggleInferred = maxDelta < 1 || duration < 144 && maxDelta < 5;
316
+ if (isShort || !wasSeparator && isToggleInferred) {
317
+ resizeDataRef.current.isToggleInferred = true;
318
+ } else {
319
+ const { height } = metaBoxesMainRef.current.state;
320
+ const nextIsOpen = height > min;
321
+ persistIsOpen(nextIsOpen);
322
+ if (nextIsOpen) {
323
+ applyHeight(height, true);
324
+ }
364
325
  }
365
326
  }
366
327
  }
367
- };
368
- return /*#__PURE__*/_jsxs(ResizableBox, {
369
- "aria-label": paneLabel,
370
- ...paneProps,
371
- children: [/*#__PURE__*/_jsx("meta", {
372
- ref: effectSizeConstraints
373
- }), contents]
374
- });
328
+ );
329
+ return /* @__PURE__ */ jsxs(ResizableBox, { "aria-label": paneLabel, ...paneProps, children: [
330
+ /* @__PURE__ */ jsx("meta", { ref: effectSizeConstraints }),
331
+ contents
332
+ ] });
375
333
  }
376
334
  function Layout({
377
335
  postId: initialPostId,
@@ -381,18 +339,17 @@ function Layout({
381
339
  }) {
382
340
  useEditPostCommands();
383
341
  const shouldIframe = useShouldIframe();
342
+ const { createErrorNotice } = useDispatch(noticesStore);
384
343
  const {
385
- createErrorNotice
386
- } = useDispatch(noticesStore);
387
- const {
388
- currentPost: {
389
- postId: currentPostId,
390
- postType: currentPostType
391
- },
344
+ currentPost: { postId: currentPostId, postType: currentPostType },
392
345
  onNavigateToEntityRecord,
393
346
  onNavigateToPreviousEntityRecord
394
- } = useNavigateToEntityRecord(initialPostId, initialPostType, 'post-only');
395
- const isEditingTemplate = currentPostType === 'wp_template';
347
+ } = useNavigateToEntityRecord(
348
+ initialPostId,
349
+ initialPostType,
350
+ "post-only"
351
+ );
352
+ const isEditingTemplate = currentPostType === "wp_template";
396
353
  const {
397
354
  mode,
398
355
  isFullscreenActive,
@@ -406,177 +363,211 @@ function Layout({
406
363
  templateId,
407
364
  enablePaddingAppender,
408
365
  isDevicePreview
409
- } = useSelect(select => {
410
- var _getPostType$viewable;
411
- const {
412
- get
413
- } = select(preferencesStore);
414
- const {
415
- isFeatureActive,
416
- hasMetaBoxes
417
- } = select(editPostStore);
418
- const {
419
- canUser,
420
- getPostType,
421
- getTemplateId
422
- } = unlock(select(coreStore));
423
- const supportsTemplateMode = settings.supportsTemplateMode;
424
- const isViewable = (_getPostType$viewable = getPostType(currentPostType)?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false;
425
- const canViewTemplate = canUser('read', {
426
- kind: 'postType',
427
- name: 'wp_template'
428
- });
429
- const {
430
- getBlockSelectionStart,
431
- isZoomOut
432
- } = unlock(select(blockEditorStore));
433
- const {
434
- getEditorMode,
435
- getRenderingMode,
436
- getDefaultRenderingMode,
437
- getDeviceType
438
- } = unlock(select(editorStore));
439
- const isRenderingPostOnly = getRenderingMode() === 'post-only';
440
- const isNotDesignPostType = !DESIGN_POST_TYPES.includes(currentPostType);
441
- const isDirectlyEditingPattern = currentPostType === 'wp_block' && !onNavigateToPreviousEntityRecord;
442
- const _templateId = getTemplateId(currentPostType, currentPostId);
443
- const defaultMode = getDefaultRenderingMode(currentPostType);
444
- return {
445
- mode: getEditorMode(),
446
- isFullscreenActive: isFeatureActive('fullscreenMode'),
447
- hasActiveMetaboxes: hasMetaBoxes(),
448
- hasResolvedMode: defaultMode === 'template-locked' ? !!_templateId : defaultMode !== undefined,
449
- hasBlockSelected: !!getBlockSelectionStart(),
450
- showIconLabels: get('core', 'showIconLabels'),
451
- isDistractionFree: get('core', 'distractionFree'),
452
- showMetaBoxes: isNotDesignPostType && !isZoomOut() || isDirectlyEditingPattern,
453
- isWelcomeGuideVisible: isFeatureActive('welcomeGuide'),
454
- templateId: supportsTemplateMode && isViewable && canViewTemplate && !isEditingTemplate ? _templateId : null,
455
- enablePaddingAppender: !isZoomOut() && isRenderingPostOnly && isNotDesignPostType,
456
- isDevicePreview: getDeviceType() !== 'Desktop'
457
- };
458
- }, [currentPostType, currentPostId, isEditingTemplate, settings.supportsTemplateMode, onNavigateToPreviousEntityRecord]);
366
+ } = useSelect(
367
+ (select) => {
368
+ const { get } = select(preferencesStore);
369
+ const { isFeatureActive, hasMetaBoxes } = select(editPostStore);
370
+ const { canUser, getPostType, getTemplateId } = unlock(
371
+ select(coreStore)
372
+ );
373
+ const supportsTemplateMode = settings.supportsTemplateMode;
374
+ const isViewable = getPostType(currentPostType)?.viewable ?? false;
375
+ const canViewTemplate = canUser("read", {
376
+ kind: "postType",
377
+ name: "wp_template"
378
+ });
379
+ const { getBlockSelectionStart, isZoomOut } = unlock(
380
+ select(blockEditorStore)
381
+ );
382
+ const {
383
+ getEditorMode,
384
+ getRenderingMode,
385
+ getDefaultRenderingMode,
386
+ getDeviceType
387
+ } = unlock(select(editorStore));
388
+ const isRenderingPostOnly = getRenderingMode() === "post-only";
389
+ const isNotDesignPostType = !DESIGN_POST_TYPES.includes(currentPostType);
390
+ const isDirectlyEditingPattern = currentPostType === "wp_block" && !onNavigateToPreviousEntityRecord;
391
+ const _templateId = getTemplateId(currentPostType, currentPostId);
392
+ const defaultMode = getDefaultRenderingMode(currentPostType);
393
+ return {
394
+ mode: getEditorMode(),
395
+ isFullscreenActive: isFeatureActive("fullscreenMode"),
396
+ hasActiveMetaboxes: hasMetaBoxes(),
397
+ hasResolvedMode: defaultMode === "template-locked" ? !!_templateId : defaultMode !== void 0,
398
+ hasBlockSelected: !!getBlockSelectionStart(),
399
+ showIconLabels: get("core", "showIconLabels"),
400
+ isDistractionFree: get("core", "distractionFree"),
401
+ showMetaBoxes: isNotDesignPostType && !isZoomOut() || isDirectlyEditingPattern,
402
+ isWelcomeGuideVisible: isFeatureActive("welcomeGuide"),
403
+ templateId: supportsTemplateMode && isViewable && canViewTemplate && !isEditingTemplate ? _templateId : null,
404
+ enablePaddingAppender: !isZoomOut() && isRenderingPostOnly && isNotDesignPostType,
405
+ isDevicePreview: getDeviceType() !== "Desktop"
406
+ };
407
+ },
408
+ [
409
+ currentPostType,
410
+ currentPostId,
411
+ isEditingTemplate,
412
+ settings.supportsTemplateMode,
413
+ onNavigateToPreviousEntityRecord
414
+ ]
415
+ );
459
416
  useMetaBoxInitialization(hasActiveMetaboxes && hasResolvedMode);
460
- const editableResolvedTemplateId = useSelect(select => {
461
- if (typeof templateId !== 'string') {
462
- return templateId;
463
- }
464
- return unlock(select(coreStore)).getTemplateAutoDraftId(templateId);
465
- }, [templateId]);
466
- const [paddingAppenderRef, paddingStyle] = usePaddingAppender(enablePaddingAppender);
467
-
468
- // Set the right context for the command palette
469
- const commandContext = hasBlockSelected ? 'block-selection-edit' : 'entity-edit';
417
+ const editableResolvedTemplateId = useSelect(
418
+ (select) => {
419
+ if (typeof templateId !== "string") {
420
+ return templateId;
421
+ }
422
+ return unlock(select(coreStore)).getTemplateAutoDraftId(
423
+ templateId
424
+ );
425
+ },
426
+ [templateId]
427
+ );
428
+ const [paddingAppenderRef, paddingStyle] = usePaddingAppender(
429
+ enablePaddingAppender
430
+ );
431
+ const commandContext = hasBlockSelected ? "block-selection-edit" : "entity-edit";
470
432
  useCommandContext(commandContext);
471
- const editorSettings = useMemo(() => ({
472
- ...settings,
473
- onNavigateToEntityRecord,
474
- onNavigateToPreviousEntityRecord,
475
- defaultRenderingMode: 'post-only'
476
- }), [settings, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord]);
433
+ const editorSettings = useMemo(
434
+ () => ({
435
+ ...settings,
436
+ onNavigateToEntityRecord,
437
+ onNavigateToPreviousEntityRecord,
438
+ defaultRenderingMode: "post-only"
439
+ }),
440
+ [settings, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord]
441
+ );
477
442
  const styles = useEditorStyles(paddingStyle);
478
-
479
- // We need to add the show-icon-labels class to the body element so it is applied to modals.
480
443
  if (showIconLabels) {
481
- document.body.classList.add('show-icon-labels');
444
+ document.body.classList.add("show-icon-labels");
482
445
  } else {
483
- document.body.classList.remove('show-icon-labels');
446
+ document.body.classList.remove("show-icon-labels");
484
447
  }
485
448
  const navigateRegionsProps = useNavigateRegions();
486
- const className = clsx('edit-post-layout', 'is-mode-' + mode, {
487
- 'has-metaboxes': hasActiveMetaboxes
449
+ const className = clsx("edit-post-layout", "is-mode-" + mode, {
450
+ "has-metaboxes": hasActiveMetaboxes
488
451
  });
489
452
  function onPluginAreaError(name) {
490
- createErrorNotice(sprintf(/* translators: %s: plugin name */
491
- __('The "%s" plugin has encountered an error and cannot be rendered.'), name));
453
+ createErrorNotice(
454
+ sprintf(
455
+ /* translators: %s: plugin name */
456
+ __(
457
+ 'The "%s" plugin has encountered an error and cannot be rendered.'
458
+ ),
459
+ name
460
+ )
461
+ );
492
462
  }
493
- const {
494
- createSuccessNotice
495
- } = useDispatch(noticesStore);
496
- const onActionPerformed = useCallback((actionId, items) => {
497
- switch (actionId) {
498
- case 'move-to-trash':
499
- {
500
- document.location.href = addQueryArgs('edit.php', {
501
- trashed: 1,
502
- post_type: items[0].type,
503
- ids: items[0].id
504
- });
505
- }
506
- break;
507
- case 'duplicate-post':
508
- {
509
- const newItem = items[0];
510
- const title = typeof newItem.title === 'string' ? newItem.title : newItem.title?.rendered;
511
- createSuccessNotice(sprintf(
512
- // translators: %s: Title of the created post or template, e.g: "Hello world".
513
- __('"%s" successfully created.'), decodeEntities(title) || __('(no title)')), {
514
- type: 'snackbar',
515
- id: 'duplicate-post-action',
516
- actions: [{
517
- label: __('Edit'),
518
- onClick: () => {
519
- const postId = newItem.id;
520
- document.location.href = addQueryArgs('post.php', {
521
- post: postId,
522
- action: 'edit'
523
- });
463
+ const { createSuccessNotice } = useDispatch(noticesStore);
464
+ const onActionPerformed = useCallback(
465
+ (actionId, items) => {
466
+ switch (actionId) {
467
+ case "move-to-trash":
468
+ {
469
+ document.location.href = addQueryArgs("edit.php", {
470
+ trashed: 1,
471
+ post_type: items[0].type,
472
+ ids: items[0].id
473
+ });
474
+ }
475
+ break;
476
+ case "duplicate-post":
477
+ {
478
+ const newItem = items[0];
479
+ const title = typeof newItem.title === "string" ? newItem.title : newItem.title?.rendered;
480
+ createSuccessNotice(
481
+ sprintf(
482
+ // translators: %s: Title of the created post or template, e.g: "Hello world".
483
+ __('"%s" successfully created.'),
484
+ decodeEntities(title) || __("(no title)")
485
+ ),
486
+ {
487
+ type: "snackbar",
488
+ id: "duplicate-post-action",
489
+ actions: [
490
+ {
491
+ label: __("Edit"),
492
+ onClick: () => {
493
+ const postId = newItem.id;
494
+ document.location.href = addQueryArgs("post.php", {
495
+ post: postId,
496
+ action: "edit"
497
+ });
498
+ }
499
+ }
500
+ ]
524
501
  }
525
- }]
526
- });
527
- }
528
- break;
529
- }
530
- }, [createSuccessNotice]);
502
+ );
503
+ }
504
+ break;
505
+ }
506
+ },
507
+ [createSuccessNotice]
508
+ );
531
509
  const initialPost = useMemo(() => {
532
510
  return {
533
511
  type: initialPostType,
534
512
  id: initialPostId
535
513
  };
536
514
  }, [initialPostType, initialPostId]);
537
- const backButton = useViewportMatch('medium') && isFullscreenActive ? /*#__PURE__*/_jsx(BackButton, {
538
- initialPost: initialPost
539
- }) : null;
540
- return /*#__PURE__*/_jsx(SlotFillProvider, {
541
- children: /*#__PURE__*/_jsxs(ErrorBoundary, {
542
- canCopyContent: true,
543
- children: [/*#__PURE__*/_jsx(WelcomeGuide, {
544
- postType: currentPostType
545
- }), /*#__PURE__*/_jsx("div", {
515
+ const backButton = useViewportMatch("medium") && isFullscreenActive ? /* @__PURE__ */ jsx(BackButton, { initialPost }) : null;
516
+ return /* @__PURE__ */ jsx(SlotFillProvider, { children: /* @__PURE__ */ jsxs(ErrorBoundary, { canCopyContent: true, children: [
517
+ /* @__PURE__ */ jsx(WelcomeGuide, { postType: currentPostType }),
518
+ /* @__PURE__ */ jsx(
519
+ "div",
520
+ {
546
521
  className: navigateRegionsProps.className,
547
522
  ...navigateRegionsProps,
548
523
  ref: navigateRegionsProps.ref,
549
- children: /*#__PURE__*/_jsxs(Editor, {
550
- settings: editorSettings,
551
- initialEdits: initialEdits,
552
- postType: currentPostType,
553
- postId: currentPostId,
554
- templateId: editableResolvedTemplateId,
555
- className: className,
556
- styles: styles,
557
- forceIsDirty: hasActiveMetaboxes,
558
- contentRef: paddingAppenderRef,
559
- disableIframe: !shouldIframe
560
- // We should auto-focus the canvas (title) on load.
561
- // eslint-disable-next-line jsx-a11y/no-autofocus
562
- ,
563
- autoFocus: !isWelcomeGuideVisible,
564
- onActionPerformed: onActionPerformed,
565
- extraSidebarPanels: showMetaBoxes && /*#__PURE__*/_jsx(MetaBoxes, {
566
- location: "side"
567
- }),
568
- extraContent: !isDistractionFree && showMetaBoxes && /*#__PURE__*/_jsx(MetaBoxesMain, {
569
- isLegacy: !shouldIframe || isDevicePreview
570
- }),
571
- children: [/*#__PURE__*/_jsx(PostLockedModal, {}), /*#__PURE__*/_jsx(EditorInitialization, {}), /*#__PURE__*/_jsx(FullscreenMode, {
572
- isActive: isFullscreenActive
573
- }), /*#__PURE__*/_jsx(BrowserURL, {}), /*#__PURE__*/_jsx(UnsavedChangesWarning, {}), /*#__PURE__*/_jsx(AutosaveMonitor, {}), /*#__PURE__*/_jsx(LocalAutosaveMonitor, {}), /*#__PURE__*/_jsx(EditPostKeyboardShortcuts, {}), /*#__PURE__*/_jsx(EditorKeyboardShortcutsRegister, {}), /*#__PURE__*/_jsx(BlockKeyboardShortcuts, {}), /*#__PURE__*/_jsx(InitPatternModal, {}), /*#__PURE__*/_jsx(PluginArea, {
574
- onError: onPluginAreaError
575
- }), /*#__PURE__*/_jsx(PostEditorMoreMenu, {}), backButton, /*#__PURE__*/_jsx(EditorSnackbars, {})]
576
- })
577
- })]
578
- })
579
- });
524
+ children: /* @__PURE__ */ jsxs(
525
+ Editor,
526
+ {
527
+ settings: editorSettings,
528
+ initialEdits,
529
+ postType: currentPostType,
530
+ postId: currentPostId,
531
+ templateId: editableResolvedTemplateId,
532
+ className,
533
+ styles,
534
+ forceIsDirty: hasActiveMetaboxes,
535
+ contentRef: paddingAppenderRef,
536
+ disableIframe: !shouldIframe,
537
+ autoFocus: !isWelcomeGuideVisible,
538
+ onActionPerformed,
539
+ extraSidebarPanels: showMetaBoxes && /* @__PURE__ */ jsx(MetaBoxes, { location: "side" }),
540
+ extraContent: !isDistractionFree && showMetaBoxes && /* @__PURE__ */ jsx(
541
+ MetaBoxesMain,
542
+ {
543
+ isLegacy: !shouldIframe || isDevicePreview
544
+ }
545
+ ),
546
+ children: [
547
+ /* @__PURE__ */ jsx(PostLockedModal, {}),
548
+ /* @__PURE__ */ jsx(EditorInitialization, {}),
549
+ /* @__PURE__ */ jsx(FullscreenMode, { isActive: isFullscreenActive }),
550
+ /* @__PURE__ */ jsx(BrowserURL, {}),
551
+ /* @__PURE__ */ jsx(UnsavedChangesWarning, {}),
552
+ /* @__PURE__ */ jsx(AutosaveMonitor, {}),
553
+ /* @__PURE__ */ jsx(LocalAutosaveMonitor, {}),
554
+ /* @__PURE__ */ jsx(EditPostKeyboardShortcuts, {}),
555
+ /* @__PURE__ */ jsx(EditorKeyboardShortcutsRegister, {}),
556
+ /* @__PURE__ */ jsx(BlockKeyboardShortcuts, {}),
557
+ /* @__PURE__ */ jsx(InitPatternModal, {}),
558
+ /* @__PURE__ */ jsx(PluginArea, { onError: onPluginAreaError }),
559
+ /* @__PURE__ */ jsx(PostEditorMoreMenu, {}),
560
+ backButton,
561
+ /* @__PURE__ */ jsx(EditorSnackbars, {})
562
+ ]
563
+ }
564
+ )
565
+ }
566
+ )
567
+ ] }) });
580
568
  }
581
- export default Layout;
582
- //# sourceMappingURL=index.js.map
569
+ var layout_default = Layout;
570
+ export {
571
+ layout_default as default
572
+ };
573
+ //# sourceMappingURL=index.js.map