Skip to content

Commit 2421c97

Browse files
youknowriadjameskostermtias
authored
Reorganize the site editor to introduce Browse Mode. (#44770)
Co-authored-by: James Koster <[email protected]> Co-authored-by: Matías Ventura <[email protected]>
1 parent 60acad5 commit 2421c97

File tree

83 files changed

+1373
-2239
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1373
-2239
lines changed

docs/reference-guides/data/data-core-edit-site.md

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,7 @@ _Returns_
2020

2121
### getCurrentTemplateNavigationPanelSubMenu
2222

23-
Returns the current template or template part's corresponding
24-
navigation panel's sub menu, to be used with `openNavigationPanelToMenu`.
25-
26-
_Parameters_
27-
28-
- _state_ `Object`: Global application state.
29-
30-
_Returns_
31-
32-
- `string`: The current template or template part's sub menu.
23+
> **Deprecated**
3324
3425
### getCurrentTemplateTemplateParts
3526

@@ -93,15 +84,7 @@ _Returns_
9384

9485
### getNavigationPanelActiveMenu
9586

96-
Returns the active menu in the navigation panel.
97-
98-
_Parameters_
99-
100-
- _state_ `Object`: Global application state.
101-
102-
_Returns_
103-
104-
- `string`: Active menu.
87+
> **Deprecated**
10588
10689
### getPage
10790

@@ -179,15 +162,7 @@ _Returns_
179162

180163
### isNavigationOpened
181164

182-
Returns the current opened/closed state of the navigation panel.
183-
184-
_Parameters_
185-
186-
- _state_ `Object`: Global application state.
187-
188-
_Returns_
189-
190-
- `boolean`: True if the navigation panel should be open; false if closed.
165+
> **Deprecated**
191166
192167
### isSaveViewOpened
193168

@@ -233,11 +208,9 @@ _Parameters_
233208

234209
### openNavigationPanelToMenu
235210

236-
Opens the navigation panel and sets its active menu at the same time.
237-
238-
_Parameters_
211+
> **Deprecated**
239212
240-
- _menu_ `string`: Identifies the menu to open.
213+
Opens the navigation panel and sets its active menu at the same time.
241214

242215
### removeTemplate
243216

@@ -290,11 +263,9 @@ _Parameters_
290263

291264
### setIsNavigationPanelOpened
292265

293-
Sets whether the navigation panel should be open.
294-
295-
_Parameters_
266+
> **Deprecated**
296267
297-
- _isOpen_ `boolean`: If true, opens the nav panel. If false, closes it. It does not toggle the state, but sets it directly.
268+
Sets whether the navigation panel should be open.
298269

299270
### setIsSaveViewOpened
300271

@@ -306,11 +277,9 @@ _Parameters_
306277

307278
### setNavigationPanelActiveMenu
308279

309-
Action that sets the active navigation panel menu.
310-
311-
_Parameters_
280+
> **Deprecated**
312281
313-
- _menu_ `string`: Menu prop of active menu.
282+
Action that sets the active navigation panel menu.
314283

315284
_Returns_
316285

lib/compat/wordpress-6.0/site-editor.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,3 @@ function gutenberg_site_editor_maybe_redirect() {
7373
}
7474
}
7575
add_action( 'load-site-editor.php', 'gutenberg_site_editor_maybe_redirect' );
76-
77-
/**
78-
* Add home template settings for WP 5.9.
79-
*
80-
* @param array $settings Existing block editor settings.
81-
* @param WP_Block_Editor_Context $context The current block editor context.
82-
* @return array
83-
*/
84-
function gutenberg_site_editor_homepage_setting( $settings, $context ) {
85-
if ( isset( $context->post ) ) {
86-
return $settings;
87-
}
88-
89-
if ( ! isset( $settings['__unstableHomeTemplate'] ) ) {
90-
$settings['__unstableHomeTemplate'] = gutenberg_resolve_home_template();
91-
}
92-
93-
return $settings;
94-
}
95-
add_filter( 'block_editor_settings_all', 'gutenberg_site_editor_homepage_setting', 10, 2 );

lib/compat/wordpress-6.1/template-parts-screen.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,8 @@ static function( $classes ) {
118118
'defaultTemplatePartAreas' => get_allowed_block_template_part_areas(),
119119
'supportsLayout' => wp_theme_has_theme_json(),
120120
'supportsTemplatePartsMode' => ! wp_is_block_theme() && current_theme_supports( 'block-template-parts' ),
121-
'__unstableHomeTemplate' => gutenberg_resolve_home_template(),
122121
);
123122

124-
/**
125-
* We don't need home template resolution when block template parts are supported.
126-
* Set the value to true to satisfy the editor initialization guard clause.
127-
*/
128-
if ( $custom_settings['supportsTemplatePartsMode'] ) {
129-
$custom_settings['__unstableHomeTemplate'] = true;
130-
}
131-
132123
// Add additional back-compat patterns registered by `current_screen` et al.
133124
$custom_settings['__experimentalAdditionalBlockPatterns'] = WP_Block_Patterns_Registry::get_instance()->get_all_registered( true );
134125
$custom_settings['__experimentalAdditionalBlockPatternCategories'] = WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered( true );
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Updates the site-editor.php file
4+
*
5+
* @package gutenberg
6+
*/
7+
8+
/**
9+
* Remove home template setting for WP 6.2.
10+
*
11+
* @param array $settings Existing block editor settings.
12+
* @param WP_Block_Editor_Context $context The current block editor context.
13+
* @return array
14+
*/
15+
function gutenberg_site_editor_unset_homepage_setting( $settings, $context ) {
16+
if ( isset( $context->post ) ) {
17+
return $settings;
18+
}
19+
20+
unset( $settings['__unstableHomeTemplate'] );
21+
22+
return $settings;
23+
}
24+
add_filter( 'block_editor_settings_all', 'gutenberg_site_editor_unset_homepage_setting', 10, 2 );

lib/load.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ function gutenberg_is_experiment_enabled( $name ) {
108108
require __DIR__ . '/compat/wordpress-6.2/class-wp-theme-json-resolver-6-2.php';
109109
require __DIR__ . '/compat/wordpress-6.2/class-wp-theme-json-6-2.php';
110110
require __DIR__ . '/compat/wordpress-6.2/edit-form-blocks.php';
111+
require __DIR__ . '/compat/wordpress-6.2/site-editor.php';
111112

112113
// Experimental features.
113114
remove_action( 'plugins_loaded', '_wp_theme_json_webfonts_handler' ); // Turns off WP 6.0's stopgap handler for Webfonts API.

packages/base-styles/_variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ $admin-sidebar-width-big: 190px;
5757
$admin-sidebar-width-collapsed: 36px;
5858
$modal-min-width: 360px;
5959
$spinner-size: 16px;
60+
$canvas-padding: $grid-unit-30;
6061

6162

6263
/**

packages/base-styles/_z-index.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,6 @@ $z-layers: (
108108
// Show interface skeleton footer above interface skeleton drawer
109109
".interface-interface-skeleton__footer": 90,
110110

111-
// Show the navigation toggle above the skeleton header
112-
".edit-site-navigation-toggle": 31,
113-
// Show the navigation link above the skeleton header
114-
".edit-site-navigation-link": 31,
115-
116-
// Show the FSE template previews above the editor and any open block toolbars
117-
".edit-site-navigation-panel__preview": 32,
118-
119111
// Above the block list and the header.
120112
".block-editor-block-popover": 31,
121113

packages/block-editor/src/components/block-list/content.scss

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -434,18 +434,4 @@
434434
.block-editor-iframe__body {
435435
transition: all 0.3s;
436436
transform-origin: top center;
437-
438-
&.is-zoomed-out {
439-
margin: 100px 0;
440-
transform: scale(0.45);
441-
442-
// Add a bit more space between the top level blocks.
443-
.wp-site-blocks > * + * {
444-
margin-block-start: 2.5rem;
445-
}
446-
447-
> .block-list-appender {
448-
display: none;
449-
}
450-
}
451437
}

packages/block-editor/src/components/iframe/index.js

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,17 @@ async function loadScript( head, { id, src } ) {
188188
}
189189

190190
function Iframe(
191-
{ contentRef, children, head, tabIndex = 0, assets, isZoomedOut, ...props },
191+
{
192+
contentRef,
193+
children,
194+
head,
195+
tabIndex = 0,
196+
assets,
197+
scale = 1,
198+
frameSize = 0,
199+
readonly,
200+
...props
201+
},
192202
ref
193203
) {
194204
const [ , forceRender ] = useReducer( () => ( {} ) );
@@ -322,7 +332,7 @@ function Iframe(
322332
{ head }
323333
<style>
324334
{ `html { transition: background 5s; ${
325-
isZoomedOut
335+
frameSize
326336
? 'background: #2f2f2f; transition: background 0s;'
327337
: ''
328338
} }` }
@@ -333,23 +343,20 @@ function Iframe(
333343
className={ classnames(
334344
'block-editor-iframe__body',
335345
BODY_CLASS_NAME,
336-
...bodyClasses,
337-
{
338-
'is-zoomed-out': isZoomedOut,
339-
}
346+
...bodyClasses
340347
) }
341-
style={
342-
isZoomedOut
343-
? {
344-
// This is the remaining percentage from the scaling down
345-
// of the iframe body(`scale(0.45)`). We also need to subtract
346-
// the body's bottom margin.
347-
marginBottom: `-${
348-
contentHeight * 0.55 - 100
349-
}px`,
350-
}
351-
: {}
352-
}
348+
style={ {
349+
// This is the remaining percentage from the scaling down
350+
// of the iframe body(`scale(0.45)`). We also need to subtract
351+
// the body's bottom margin.
352+
marginBottom: `-${
353+
contentHeight * ( 1 - scale ) -
354+
frameSize
355+
}px`,
356+
marginTop: frameSize,
357+
transform: `scale( ${ scale } )`,
358+
} }
359+
inert={ readonly ? 'true' : undefined }
353360
>
354361
{ contentResizeListener }
355362
{ /*

packages/block-editor/src/components/list-view/style.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
height: auto;
113113
padding: ($grid-unit-15 * 0.5) $grid-unit-05 ($grid-unit-15 * 0.5) 0;
114114
text-align: left;
115-
color: $gray-900;
116115
border-radius: $radius-block-ui;
117116
position: relative;
118117
white-space: nowrap;

0 commit comments

Comments
 (0)