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