@wordpress/edit-post 8.46.0 → 8.47.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 (30) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/back-button/fullscreen-mode-close.cjs +10 -3
  3. package/build/components/back-button/fullscreen-mode-close.cjs.map +3 -3
  4. package/build/components/layout/index.cjs +34 -21
  5. package/build/components/layout/index.cjs.map +3 -3
  6. package/build/components/meta-boxes/use-meta-box-initialization.cjs +21 -7
  7. package/build/components/meta-boxes/use-meta-box-initialization.cjs.map +2 -2
  8. package/build/index.cjs +120 -9
  9. package/build/index.cjs.map +3 -3
  10. package/build-module/components/back-button/fullscreen-mode-close.mjs +21 -8
  11. package/build-module/components/back-button/fullscreen-mode-close.mjs.map +2 -2
  12. package/build-module/components/layout/index.mjs +37 -25
  13. package/build-module/components/layout/index.mjs.map +2 -2
  14. package/build-module/components/meta-boxes/use-meta-box-initialization.mjs +21 -7
  15. package/build-module/components/meta-boxes/use-meta-box-initialization.mjs.map +2 -2
  16. package/build-module/index.mjs +121 -10
  17. package/build-module/index.mjs.map +2 -2
  18. package/build-style/experimental-admin-bar-in-editor-rtl.css +50 -0
  19. package/build-style/experimental-admin-bar-in-editor.css +50 -0
  20. package/build-style/style-rtl.css +51 -0
  21. package/build-style/style.css +51 -0
  22. package/package.json +36 -36
  23. package/src/components/back-button/fullscreen-mode-close.js +39 -21
  24. package/src/components/layout/index.js +75 -66
  25. package/src/components/layout/index.native.js +3 -3
  26. package/src/components/meta-boxes/test/use-meta-box-initialization.js +31 -0
  27. package/src/components/meta-boxes/use-meta-box-initialization.js +30 -11
  28. package/src/experimental-admin-bar-in-editor.scss +67 -0
  29. package/src/index.js +155 -11
  30. package/src/style.scss +1 -0
@@ -38,9 +38,8 @@ import { addQueryArgs } from '@wordpress/url';
38
38
  import { decodeEntities } from '@wordpress/html-entities';
39
39
  import { store as coreStore } from '@wordpress/core-data';
40
40
  import {
41
- Icon,
41
+ Icon as WCIcon,
42
42
  SlotFillProvider,
43
- Tooltip,
44
43
  __unstableUseNavigateRegions as useNavigateRegions,
45
44
  privateApis as componentsPrivateApis,
46
45
  } from '@wordpress/components';
@@ -50,7 +49,8 @@ import {
50
49
  useRefEffect,
51
50
  useViewportMatch,
52
51
  } from '@wordpress/compose';
53
- import { VisuallyHidden } from '@wordpress/ui';
52
+ // eslint-disable-next-line @wordpress/use-recommended-components -- `Tooltip` is not yet on the recommended `@wordpress/ui` allow-list; landing as a migration step ahead of the wider rollout.
53
+ import { Tooltip, VisuallyHidden } from '@wordpress/ui';
54
54
 
55
55
  /**
56
56
  * Internal dependencies
@@ -162,8 +162,8 @@ function MetaBoxesMain( { isLegacy } ) {
162
162
  if ( ! container ) {
163
163
  return;
164
164
  }
165
- const noticeLists = container.querySelectorAll(
166
- ':scope > .components-notice-list'
165
+ const noticeContainer = container.querySelector(
166
+ ':scope > .notices-inline-notices-wrapper'
167
167
  );
168
168
  const resizeHandle = container.querySelector(
169
169
  '.edit-post-meta-boxes-main__presenter'
@@ -171,16 +171,16 @@ function MetaBoxesMain( { isLegacy } ) {
171
171
  const deriveConstraints = () => {
172
172
  const fullHeight = container.offsetHeight;
173
173
  let nextMax = fullHeight;
174
- for ( const element of noticeLists ) {
175
- nextMax -= element.offsetHeight;
174
+ if ( noticeContainer ) {
175
+ nextMax -= noticeContainer.offsetHeight;
176
176
  }
177
- const nextMin = resizeHandle.offsetHeight;
177
+ const nextMin = resizeHandle?.offsetHeight ?? 0;
178
178
  setHeightConstraints( { min: nextMin, max: nextMax } );
179
179
  };
180
180
  const observer = new window.ResizeObserver( deriveConstraints );
181
181
  observer.observe( container );
182
- for ( const element of noticeLists ) {
183
- observer.observe( element );
182
+ if ( noticeContainer ) {
183
+ observer.observe( noticeContainer );
184
184
  }
185
185
  return () => observer.disconnect();
186
186
  }, [] );
@@ -321,23 +321,28 @@ function MetaBoxesMain( { isLegacy } ) {
321
321
  { ...( ! isShort && bindDragGesture( persistIsOpen ) ) }
322
322
  >
323
323
  { paneLabel }
324
- <Icon icon={ isOpen ? chevronUp : chevronDown } />
324
+ <WCIcon icon={ isOpen ? chevronUp : chevronDown } />
325
325
  </button>
326
326
  );
327
327
 
328
328
  // The separator button that provides a11y for resizing.
329
329
  const separator = ! isShort && (
330
330
  <>
331
- <Tooltip text={ __( 'Drag to resize' ) }>
332
- <button
333
- ref={ separatorRef }
334
- role="separator" // eslint-disable-line jsx-a11y/no-interactive-element-to-noninteractive-role
335
- aria-valuenow={ usedAriaValueNow }
336
- aria-label={ __( 'Drag to resize' ) }
337
- aria-describedby={ separatorHelpId }
338
- { ...bindDragGesture() }
331
+ <Tooltip.Root>
332
+ <Tooltip.Trigger
333
+ render={
334
+ <button
335
+ ref={ separatorRef }
336
+ role="separator" // eslint-disable-line jsx-a11y/no-interactive-element-to-noninteractive-role
337
+ aria-valuenow={ usedAriaValueNow }
338
+ aria-label={ __( 'Drag to resize' ) }
339
+ aria-describedby={ separatorHelpId }
340
+ { ...bindDragGesture() }
341
+ />
342
+ }
339
343
  />
340
- </Tooltip>
344
+ <Tooltip.Popup>{ __( 'Drag to resize' ) }</Tooltip.Popup>
345
+ </Tooltip.Root>
341
346
  <VisuallyHidden id={ separatorHelpId }>
342
347
  { __(
343
348
  'Use up and down arrow keys to resize the meta box pane.'
@@ -572,52 +577,56 @@ function Layout( {
572
577
 
573
578
  return (
574
579
  <SlotFillProvider>
575
- <ErrorBoundary canCopyContent>
576
- <WelcomeGuide postType={ currentPostType } />
577
- <div { ...navigateRegionsProps }>
578
- <Editor
579
- settings={ editorSettings }
580
- initialEdits={ initialEdits }
581
- postType={ currentPostType }
582
- postId={ currentPostId }
583
- templateId={ templateId }
584
- className={ className }
585
- forceIsDirty={ hasActiveMetaboxes }
586
- disableIframe={ ! shouldIframe }
587
- // We should auto-focus the canvas (title) on load.
588
- // eslint-disable-next-line jsx-a11y/no-autofocus
589
- autoFocus={ ! isWelcomeGuideVisible }
590
- onActionPerformed={ onActionPerformed }
591
- extraSidebarPanels={
592
- showMetaBoxes && <MetaBoxes location="side" />
593
- }
594
- extraContent={
595
- ! isDistractionFree &&
596
- showMetaBoxes && (
597
- <MetaBoxesMain isLegacy={ isDevicePreview } />
598
- )
599
- }
600
- >
601
- <PostLockedModal />
602
- <EditorInitialization />
603
- <FullscreenMode isActive={ isFullscreenActive } />
604
- <BrowserURL />
605
- <UnsavedChangesWarning />
606
- <AutosaveMonitor />
607
- <LocalAutosaveMonitor />
608
- <EditPostKeyboardShortcuts />
609
- <EditorKeyboardShortcutsRegister />
610
- <BlockKeyboardShortcuts />
611
- { currentPostType === 'wp_block' && (
612
- <InitPatternModal />
613
- ) }
614
- <PluginArea onError={ onPluginAreaError } />
615
- <PostEditorMoreMenu />
616
- { backButton }
617
- <SnackbarNotices className="edit-post-layout__snackbar" />
618
- </Editor>
619
- </div>
620
- </ErrorBoundary>
580
+ <Tooltip.Provider>
581
+ <ErrorBoundary canCopyContent>
582
+ <WelcomeGuide postType={ currentPostType } />
583
+ <div { ...navigateRegionsProps }>
584
+ <Editor
585
+ settings={ editorSettings }
586
+ initialEdits={ initialEdits }
587
+ postType={ currentPostType }
588
+ postId={ currentPostId }
589
+ templateId={ templateId }
590
+ className={ className }
591
+ forceIsDirty={ hasActiveMetaboxes }
592
+ disableIframe={ ! shouldIframe }
593
+ // We should auto-focus the canvas (title) on load.
594
+ // eslint-disable-next-line jsx-a11y/no-autofocus
595
+ autoFocus={ ! isWelcomeGuideVisible }
596
+ onActionPerformed={ onActionPerformed }
597
+ extraSidebarPanels={
598
+ showMetaBoxes && <MetaBoxes location="side" />
599
+ }
600
+ extraContent={
601
+ ! isDistractionFree &&
602
+ showMetaBoxes && (
603
+ <MetaBoxesMain
604
+ isLegacy={ isDevicePreview }
605
+ />
606
+ )
607
+ }
608
+ >
609
+ <PostLockedModal />
610
+ <EditorInitialization />
611
+ <FullscreenMode isActive={ isFullscreenActive } />
612
+ <BrowserURL />
613
+ <UnsavedChangesWarning />
614
+ <AutosaveMonitor />
615
+ <LocalAutosaveMonitor />
616
+ <EditPostKeyboardShortcuts />
617
+ <EditorKeyboardShortcutsRegister />
618
+ <BlockKeyboardShortcuts />
619
+ { currentPostType === 'wp_block' && (
620
+ <InitPatternModal />
621
+ ) }
622
+ <PluginArea onError={ onPluginAreaError } />
623
+ <PostEditorMoreMenu />
624
+ { backButton }
625
+ <SnackbarNotices className="edit-post-layout__snackbar" />
626
+ </Editor>
627
+ </div>
628
+ </ErrorBoundary>
629
+ </Tooltip.Provider>
621
630
  </SlotFillProvider>
622
631
  );
623
632
  }
@@ -19,7 +19,7 @@ import {
19
19
  HTMLTextInput,
20
20
  KeyboardAvoidingView,
21
21
  NoticeList,
22
- Tooltip,
22
+ Tooltip as WCTooltip,
23
23
  __unstableAutocompletionItemsSlot as AutocompletionItemsSlot,
24
24
  } from '@wordpress/components';
25
25
  import {
@@ -145,7 +145,7 @@ class Layout extends Component {
145
145
  ];
146
146
 
147
147
  return (
148
- <Tooltip.Slot>
148
+ <WCTooltip.Slot>
149
149
  <SafeAreaView
150
150
  style={ containerStyles }
151
151
  onLayout={ this.onRootViewLayout }
@@ -184,7 +184,7 @@ class Layout extends Component {
184
184
  ) }
185
185
  { Platform.OS === 'android' && <AutocompletionItemsSlot /> }
186
186
  </SafeAreaView>
187
- </Tooltip.Slot>
187
+ </WCTooltip.Slot>
188
188
  );
189
189
  }
190
190
  }
@@ -35,6 +35,10 @@ const initializeMetaBoxes = jest.fn( () => ( {
35
35
  type: 'META_BOXES_INITIALIZED',
36
36
  } ) );
37
37
 
38
+ const updateEditorSettings = jest.fn( () => ( {
39
+ type: 'UPDATE_EDITOR_SETTINGS',
40
+ } ) );
41
+
38
42
  function createMockStores( {
39
43
  isEditorReady = true,
40
44
  isCollaborationEnabled = true,
@@ -43,6 +47,10 @@ function createMockStores( {
43
47
  return {
44
48
  'core/editor': {
45
49
  ...storeConfig,
50
+ actions: {
51
+ ...storeConfig.actions,
52
+ updateEditorSettings,
53
+ },
46
54
  selectors: {
47
55
  __unstableIsEditorReady: jest.fn( () => isEditorReady ),
48
56
  isCollaborationEnabledForCurrentPost: jest.fn(
@@ -91,6 +99,7 @@ describe( 'useMetaBoxInitialization', () => {
91
99
  afterEach( () => {
92
100
  setCollaborationSupported.mockClear();
93
101
  initializeMetaBoxes.mockClear();
102
+ updateEditorSettings.mockClear();
94
103
  } );
95
104
 
96
105
  it( 'disables collaboration when metaboxes are present', () => {
@@ -188,4 +197,26 @@ describe( 'useMetaBoxInitialization', () => {
188
197
 
189
198
  expect( setCollaborationSupported ).not.toHaveBeenCalled();
190
199
  } );
200
+
201
+ it( 'disables visual revisions when metaboxes are present', () => {
202
+ const mockStores = createMockStores( {
203
+ metaBoxes: [ { id: 'my-metabox', title: 'My Meta Box' } ],
204
+ } );
205
+ const registry = createRegistry( mockStores );
206
+
207
+ renderHook( registry );
208
+
209
+ expect( updateEditorSettings ).toHaveBeenCalledWith( {
210
+ disableVisualRevisions: true,
211
+ } );
212
+ } );
213
+
214
+ it( 'does not disable visual revisions when there are no metaboxes', () => {
215
+ const mockStores = createMockStores( { metaBoxes: [] } );
216
+ const registry = createRegistry( mockStores );
217
+
218
+ renderHook( registry );
219
+
220
+ expect( updateEditorSettings ).not.toHaveBeenCalled();
221
+ } );
191
222
  } );
@@ -22,21 +22,29 @@ export const useMetaBoxInitialization = ( enabled ) => {
22
22
  isEnabledAndEditorReady,
23
23
  isCollaborationEnabled,
24
24
  hasIncompatibleMetaBoxes,
25
+ hasActiveMetaBoxes,
25
26
  } = useSelect(
26
- ( select ) => ( {
27
- isEnabledAndEditorReady:
28
- enabled && select( editorStore ).__unstableIsEditorReady(),
29
- isCollaborationEnabled:
30
- select( editorStore ).isCollaborationEnabledForCurrentPost(),
31
- hasIncompatibleMetaBoxes: enabled
32
- ? select( editPostStore )
33
- .getAllMetaBoxes()
34
- .some( ( metaBox ) => ! metaBox.__rtc_compatible )
35
- : false,
36
- } ),
27
+ ( select ) => {
28
+ const {
29
+ __unstableIsEditorReady,
30
+ isCollaborationEnabledForCurrentPost,
31
+ } = unlock( select( editorStore ) );
32
+ return {
33
+ isEnabledAndEditorReady: enabled && __unstableIsEditorReady(),
34
+ isCollaborationEnabled: isCollaborationEnabledForCurrentPost(),
35
+ hasIncompatibleMetaBoxes: enabled
36
+ ? select( editPostStore )
37
+ .getAllMetaBoxes()
38
+ .some( ( metaBox ) => ! metaBox.__rtc_compatible )
39
+ : false,
40
+ hasActiveMetaBoxes:
41
+ enabled && select( editPostStore ).hasMetaBoxes(),
42
+ };
43
+ },
37
44
  [ enabled ]
38
45
  );
39
46
  const { setCollaborationSupported } = unlock( useDispatch( coreStore ) );
47
+ const { updateEditorSettings } = useDispatch( editorStore );
40
48
  const { initializeMetaBoxes } = useDispatch( editPostStore );
41
49
 
42
50
  // The effect has to rerun when the editor is ready because initializeMetaBoxes
@@ -49,6 +57,15 @@ export const useMetaBoxInitialization = ( enabled ) => {
49
57
  if ( isCollaborationEnabled && hasIncompatibleMetaBoxes ) {
50
58
  setCollaborationSupported( false );
51
59
  }
60
+
61
+ // Classic meta box values are saved through a separate
62
+ // admin-ajax submission that the in-editor revisions restore
63
+ // does not drive, so visual revisions would silently leave
64
+ // them untouched. Fall back to the classic revision.php
65
+ // admin screen instead.
66
+ if ( hasActiveMetaBoxes ) {
67
+ updateEditorSettings( { disableVisualRevisions: true } );
68
+ }
52
69
  }
53
70
  }, [
54
71
  isEnabledAndEditorReady,
@@ -56,5 +73,7 @@ export const useMetaBoxInitialization = ( enabled ) => {
56
73
  isCollaborationEnabled,
57
74
  setCollaborationSupported,
58
75
  hasIncompatibleMetaBoxes,
76
+ hasActiveMetaBoxes,
77
+ updateEditorSettings,
59
78
  ] );
60
79
  };
@@ -0,0 +1,67 @@
1
+ // Styles for the experimental admin bar in editor.
2
+
3
+ body.has-admin-bar-in-editor {
4
+ .edit-post-fullscreen-mode-close__view-mode-toggle {
5
+ display: flex;
6
+ align-items: center;
7
+ justify-content: center;
8
+ width: 32px;
9
+ height: 32px;
10
+
11
+ .edit-post-fullscreen-mode-close__back-icon {
12
+ top: auto;
13
+ left: auto;
14
+ width: 32px;
15
+ height: 32px;
16
+ background: transparent;
17
+ }
18
+
19
+ &:hover .edit-post-fullscreen-mode-close__back-icon {
20
+ color: var(--wp-admin-theme-color);
21
+ }
22
+ }
23
+
24
+ &.is-fullscreen-mode {
25
+ .editor-header:has(> .editor-header__back-button) {
26
+ grid-template-columns: 32px minmax(0, max-content) minmax(min-content, 1fr) 64px;
27
+ }
28
+
29
+ .editor-header:has(> .editor-header__back-button):has(> .editor-header__center) {
30
+ grid-template-columns: 32px min-content 1fr min-content 64px;
31
+ }
32
+
33
+ .editor-header__back-button {
34
+ padding-left: 8px;
35
+ }
36
+ }
37
+
38
+ @media (min-width: 782px) {
39
+ &.is-fullscreen-mode {
40
+ margin-top: 0;
41
+ height: 100%;
42
+
43
+ #wpadminbar {
44
+ display: block;
45
+ }
46
+
47
+ .interface-interface-skeleton,
48
+ .editor-post-publish-panel,
49
+ .is-entity-save-view-open .interface-interface-skeleton__actions:focus,
50
+ .is-entity-save-view-open .interface-interface-skeleton__actions:focus-within {
51
+ top: var(--wp-admin--admin-bar--height, 0);
52
+ }
53
+
54
+ .block-editor__container {
55
+ min-height: calc(100vh - var(--wp-admin--admin-bar--height, 0));
56
+ }
57
+
58
+ &:has(.editor-editor-interface.is-distraction-free) {
59
+ --wp-admin--admin-bar--height: 0;
60
+
61
+ #wpadminbar {
62
+ display: none;
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
package/src/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  } from '@wordpress/block-library';
9
9
  import deprecated from '@wordpress/deprecated';
10
10
  import { createRoot, StrictMode } from '@wordpress/element';
11
- import { dispatch, select } from '@wordpress/data';
11
+ import { dispatch, resolveSelect, select } from '@wordpress/data';
12
12
  import { store as preferencesStore } from '@wordpress/preferences';
13
13
  import {
14
14
  registerLegacyWidgetBlock,
@@ -18,6 +18,8 @@ import {
18
18
  store as editorStore,
19
19
  privateApis as editorPrivateApis,
20
20
  } from '@wordpress/editor';
21
+ import { store as coreDataStore } from '@wordpress/core-data';
22
+ import apiFetch from '@wordpress/api-fetch';
21
23
 
22
24
  /**
23
25
  * Internal dependencies
@@ -30,6 +32,10 @@ const {
30
32
  registerCoreBlockBindingsSources,
31
33
  } = unlock( editorPrivateApis );
32
34
 
35
+ const { enablePreloadMultiUse, clearPreloadedData } = unlock(
36
+ apiFetch.privateApis
37
+ );
38
+
33
39
  /**
34
40
  * Initializes and returns an instance of Editor.
35
41
  *
@@ -150,20 +156,158 @@ export function initializeEditor(
150
156
  window.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );
151
157
  window.addEventListener( 'drop', ( e ) => e.preventDefault(), false );
152
158
 
153
- root.render(
154
- <StrictMode>
155
- <Layout
156
- settings={ settings }
157
- postId={ postId }
158
- postType={ postType }
159
- initialEdits={ initialEdits }
160
- />
161
- </StrictMode>
162
- );
159
+ // Drive the resolvers whose data `createPreloadingMiddleware`
160
+ // already has cached so every metadata entry they touch is
161
+ // `finished` by the time React mounts — no `setTimeout(0)`
162
+ // resolution dance on first render. Multi-use lets a single
163
+ // preloaded URL back several selectors (e.g. /wp/v2/settings GET +
164
+ // OPTIONS serves `getEntitiesConfig`, `canUser`, `getEntityRecord`).
165
+ enablePreloadMultiUse();
166
+ const preloadedResolutions = preloadResolutions( postType, postId );
167
+
168
+ preloadedResolutions.finally( () => {
169
+ // Anything not consumed by the kickoff falls through to a real
170
+ // network request from here on. `clearPreloadedData` logs which
171
+ // preload entries (if any) were never served.
172
+ clearPreloadedData();
173
+ if ( postType && postId ) {
174
+ const post = select( coreDataStore ).getEntityRecord(
175
+ 'postType',
176
+ postType,
177
+ postId
178
+ );
179
+ if ( post ) {
180
+ dispatch( editorStore ).setupEditor(
181
+ post,
182
+ initialEdits,
183
+ settings.template
184
+ );
185
+ }
186
+ }
187
+ root.render(
188
+ <StrictMode>
189
+ <Layout
190
+ settings={ settings }
191
+ postId={ postId }
192
+ postType={ postType }
193
+ initialEdits={ initialEdits }
194
+ />
195
+ </StrictMode>
196
+ );
197
+ } );
163
198
 
164
199
  return root;
165
200
  }
166
201
 
202
+ /**
203
+ * Drive resolvers to completion against the preload cache before React
204
+ * mounts. Two phases: known-up-front args (post id + type), then args
205
+ * derived from phase-1 state (post slug → template, current global
206
+ * styles id → record + canUser).
207
+ *
208
+ * @param {string} postType Current post type.
209
+ * @param {number} postId Current post id.
210
+ * @return {Promise<void>} Resolves when the kickoff resolvers settle.
211
+ */
212
+ async function preloadResolutions( postType, postId ) {
213
+ const core = resolveSelect( coreDataStore );
214
+ const coreSelect = select( coreDataStore );
215
+
216
+ try {
217
+ await Promise.all( [
218
+ core.getCurrentUser(),
219
+ core.getEntitiesConfig( 'postType' ),
220
+ core.getEntitiesConfig( 'taxonomy' ),
221
+ core.getEntitiesConfig( 'root' ),
222
+ core.getEntityRecords( 'root', 'taxonomy' ),
223
+ core.getCurrentTheme(),
224
+ // Forward-resolver alias of `getCurrentTheme` with its own
225
+ // resolution metadata, so it needs a separate kick.
226
+ core.getThemeSupports(),
227
+ core.getBlockPatternCategories(),
228
+ core.__experimentalGetCurrentGlobalStylesId(),
229
+ core.__experimentalGetCurrentThemeBaseGlobalStyles(),
230
+ core.__experimentalGetCurrentThemeGlobalStylesVariations(),
231
+ core.getEntityRecord( 'root', '__unstableBase' ),
232
+ core.getEntityRecord( 'root', 'site' ),
233
+ core.canUser( 'read', { kind: 'root', name: 'site' } ),
234
+ core.canUser( 'create', { kind: 'postType', name: 'attachment' } ),
235
+ core.canUser( 'create', { kind: 'postType', name: 'page' } ),
236
+ core.canUser( 'create', { kind: 'postType', name: 'wp_block' } ),
237
+ core.canUser( 'create', {
238
+ kind: 'postType',
239
+ name: 'wp_template',
240
+ } ),
241
+ // Per-post resolvers. `getPostType` and `getEditedEntityRecord`
242
+ // are shorthand/forward-resolver aliases with their own
243
+ // resolution metadata, so they need separate kicks.
244
+ ...( postType && postId
245
+ ? [
246
+ core.getPostType( postType ),
247
+ core.getEntityRecord( 'postType', postType, postId ),
248
+ core.getEditedEntityRecord(
249
+ 'postType',
250
+ postType,
251
+ postId
252
+ ),
253
+ core.getAutosaves( postType, postId ),
254
+ core.getDefaultTemplateId( { slug: 'front-page' } ),
255
+ core.canUser( 'create', {
256
+ kind: 'postType',
257
+ name: postType,
258
+ } ),
259
+ ]
260
+ : [] ),
261
+ ] );
262
+
263
+ // Phase 2: read derived data out of state.
264
+ const tasks = [];
265
+ const globalStylesId =
266
+ coreSelect.__experimentalGetCurrentGlobalStylesId();
267
+ if ( globalStylesId ) {
268
+ tasks.push(
269
+ core.getEntityRecord( 'root', 'globalStyles', globalStylesId ),
270
+ core.canUser( 'read', {
271
+ kind: 'root',
272
+ name: 'globalStyles',
273
+ id: globalStylesId,
274
+ } )
275
+ );
276
+ }
277
+
278
+ if ( postType && postId ) {
279
+ const post = coreSelect.getEntityRecord(
280
+ 'postType',
281
+ postType,
282
+ postId
283
+ );
284
+ if ( post ) {
285
+ // Mirrors core-data's `getDefaultTemplate` slug formula.
286
+ let slug = 'page' === postType ? 'page' : 'single-' + postType;
287
+ if ( post.slug ) {
288
+ slug += '-' + post.slug;
289
+ }
290
+ tasks.push( core.getDefaultTemplateId( { slug } ) );
291
+
292
+ if ( post.author ) {
293
+ tasks.push(
294
+ core.getUser( post.author, {
295
+ context: 'view',
296
+ _fields: 'id,name',
297
+ } )
298
+ );
299
+ }
300
+ }
301
+ }
302
+
303
+ if ( tasks.length ) {
304
+ await Promise.all( tasks );
305
+ }
306
+ } catch {
307
+ // Resolver failures here would also surface on demand; don't block render.
308
+ }
309
+ }
310
+
167
311
  /**
168
312
  * Used to reinitialize the editor after an error. Now it's a deprecated noop function.
169
313
  */
package/src/style.scss CHANGED
@@ -5,6 +5,7 @@
5
5
  @use "./components/layout/style.scss" as *;
6
6
  @use "./components/meta-boxes/meta-boxes-area/style.scss" as *;
7
7
  @use "./components/welcome-guide/style.scss" as *;
8
+ @use "./experimental-admin-bar-in-editor.scss" as *;
8
9
 
9
10
  body.js.block-editor-page {
10
11
  @include wp-admin-reset( ".block-editor" );